2 * set the version of bootstrap based on the stylesheet...
6 Roo.bootstrap.version = (
9 Roo.each(document.styleSheets, function(s) {
10 if (s.href.match(/css-bootstrap4/)) {
18 * base class for bootstrap elements.
22 Roo.bootstrap = Roo.bootstrap || {};
24 * @class Roo.bootstrap.Component
25 * @extends Roo.Component
26 * Bootstrap Component base class
27 * @cfg {String} cls css class
28 * @cfg {String} style any extra css
29 * @cfg {Object} xattr extra attributes to add to 'element' (used by builder to store stuff.)
30 * @cfg {Boolean} can_build_overlaid True if element can be rebuild from a HTML page
31 * @cfg {string} dataId cutomer id
32 * @cfg {string} name Specifies name attribute
33 * @cfg {string} tooltip Text for the tooltip
34 * @cfg {string} container_method method to fetch parents container element (used by NavHeaderbar - getHeaderChildContainer)
35 * @cfg {string|object} visibilityEl (el|parent) What element to use for visibility (@see getVisibilityEl())
38 * Do not use directly - it does not do anything..
39 * @param {Object} config The config object
44 Roo.bootstrap.Component = function(config){
45 Roo.bootstrap.Component.superclass.constructor.call(this, config);
49 * @event childrenrendered
50 * Fires when the children have been rendered..
51 * @param {Roo.bootstrap.Component} this
53 "childrenrendered" : true
61 Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent, {
64 allowDomMove : false, // to stop relocations in parent onRender...
74 * Initialize Events for the element
76 initEvents : function() { },
82 can_build_overlaid : true,
84 container_method : false,
91 // returns the parent component..
92 return Roo.ComponentMgr.get(this.parentId)
98 onRender : function(ct, position)
100 // Roo.log("Call onRender: " + this.xtype);
102 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
105 if (this.el.attr('xtype')) {
106 this.el.attr('xtypex', this.el.attr('xtype'));
107 this.el.dom.removeAttribute('xtype');
117 var cfg = Roo.apply({}, this.getAutoCreate());
119 cfg.id = this.id || Roo.id();
121 // fill in the extra attributes
122 if (this.xattr && typeof(this.xattr) =='object') {
123 for (var i in this.xattr) {
124 cfg[i] = this.xattr[i];
129 cfg.dataId = this.dataId;
133 cfg.cls = (typeof(cfg.cls) == 'undefined') ? this.cls : cfg.cls + ' ' + this.cls;
136 if (this.style) { // fixme needs to support more complex style data.
137 cfg.style = this.style;
141 cfg.name = this.name;
144 this.el = ct.createChild(cfg, position);
147 this.tooltipEl().attr('tooltip', this.tooltip);
150 if(this.tabIndex !== undefined){
151 this.el.dom.setAttribute('tabIndex', this.tabIndex);
158 * Fetch the element to add children to
159 * @return {Roo.Element} defaults to this.el
161 getChildContainer : function()
166 * Fetch the element to display the tooltip on.
167 * @return {Roo.Element} defaults to this.el
169 tooltipEl : function()
174 * This is really a wrapper for addxtypeChild
175 * it handles stuff relating to flexy:foreach / flexy:if
176 * = some of our projects use a flat rendering of the output, and try and overlay it with dynamic data.
177 * -- this is a bit of a nightmare... and is even more confusing to debug..
182 addxtype : function(tree,cntr)
184 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
186 var cn = Roo.factory(tree); // this is posibly the first of two times that the ctor get's called...
187 cn.parentType = this.xtype; //??
188 cn.parentId = this.id;
189 if (typeof(cn.container_method) == 'string') {
190 cntr = cn.container_method;
194 var has_flexy_each = (typeof(tree['flexy:foreach']) != 'undefined');
196 var has_flexy_if = (typeof(tree['flexy:if']) != 'undefined');
198 var build_from_html = Roo.XComponent.build_from_html;
200 var is_body = (tree.xtype == 'Body') ;
202 var page_has_body = (Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body');
204 var self_cntr_el = Roo.get(this[cntr](false));
206 // do not try and build conditional elements
207 if ((has_flexy_each || has_flexy_if || this.can_build_overlaid == false ) && build_from_html) {
211 if (!has_flexy_each || !build_from_html || is_body || !page_has_body) {
212 if(!has_flexy_if || typeof(tree.name) == 'undefined' || !build_from_html || is_body || !page_has_body){
213 return this.addxtypeChild(tree,cntr, is_body);
216 var echild =self_cntr_el ? self_cntr_el.child('>*[name=' + tree.name + ']') : false;
219 return this.addxtypeChild(Roo.apply({}, tree),cntr);
222 Roo.log('skipping render');
228 if (!build_from_html) {
232 // this i think handles overlaying multiple children of the same type
233 // with the sam eelement.. - which might be buggy..
235 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
241 if (echild && echild.attr('xtype').split('.').pop() != cn.xtype) {
245 ret = this.addxtypeChild(Roo.apply({}, tree),cntr);
251 * add a child to this element
252 * - turn the child.cfg into a child_instance
253 * - call child_instance.render( this { getContainerMethod()} )
254 * - loop through the children, and call addxtype.. (reall this) on newly created child.
258 addxtypeChild : function (tree, cntr, is_body)
260 Roo.debug && Roo.log('addxtypeChild:' + cntr);
262 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
265 var has_flexy = (typeof(tree['flexy:if']) != 'undefined') ||
266 (typeof(tree['flexy:foreach']) != 'undefined');
270 skip_children = false;
271 // render the element if it's not BODY.
274 // if parent was disabled, then do not try and create the children..
275 if(!this[cntr](true)){
280 cn = Roo.factory(tree);
282 cn.parentType = this.xtype; //??
283 cn.parentId = this.id;
285 var build_from_html = Roo.XComponent.build_from_html;
288 // does the container contain child eleemnts with 'xtype' attributes.
289 // that match this xtype..
290 // note - when we render we create these as well..
291 // so we should check to see if body has xtype set.
292 if (build_from_html && Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body') {
294 var self_cntr_el = Roo.get(this[cntr](false));
295 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
297 //Roo.log(Roo.XComponent.build_from_html);
298 //Roo.log("got echild:");
301 // there is a scenario where some of the child elements are flexy:if (and all of the same type)
302 // and are not displayed -this causes this to use up the wrong element when matching.
303 // at present the only work around for this is to nest flexy:if elements in another element that is always rendered.
306 if (echild && echild.attr('xtype').split('.').pop() == cn.xtype) {
307 // Roo.log("found child for " + this.xtype +": " + echild.attr('xtype') );
313 //echild.dom.removeAttribute('xtype');
315 Roo.debug && Roo.log("MISSING " + cn.xtype + " on child of " + (this.el ? this.el.attr('xbuilderid') : 'no parent'));
316 Roo.debug && Roo.log(self_cntr_el);
317 Roo.debug && Roo.log(echild);
318 Roo.debug && Roo.log(cn);
324 // if object has flexy:if - then it may or may not be rendered.
325 if (build_from_html && has_flexy && !cn.el && cn.can_build_overlaid) {
326 // skip a flexy if element.
327 Roo.debug && Roo.log('skipping render');
328 Roo.debug && Roo.log(tree);
330 Roo.debug && Roo.log('skipping all children');
331 skip_children = true;
336 // actually if flexy:foreach is found, we really want to create
337 // multiple copies here...
339 //Roo.log(this[cntr]());
340 // some elements do not have render methods.. like the layouts...
342 if(this[cntr](true) === false){
347 cn.render && cn.render(this[cntr](true));
350 // then add the element..
357 cn.addxtypeChildren(tree.items, skip_children);
363 * add a number of children to this object,
364 * which in turn calls render...
368 addxtypeChildren: function(child_array, skip_children)
371 if (!child_array || !child_array.length ) {
376 for(var i =0;i < child_array.length;i++) {
380 // Roo.log(['add child', items[i]]);
381 nitems.push(this.addxtype(Roo.apply({}, child_array[i])));
385 this.fireEvent('childrenrendered', this);
392 * Set the element that will be used to show or hide
394 setVisibilityEl : function(el)
396 this.visibilityEl = el;
400 * Get the element that will be used to show or hide
402 getVisibilityEl : function()
404 if (typeof(this.visibilityEl) == 'object') {
405 return this.visibilityEl;
408 if (typeof(this.visibilityEl) == 'string') {
409 return this.visibilityEl == 'parent' ? this.parent().getEl() : this.getEl();
416 * Show a component - removes 'hidden' class
420 if(!this.getVisibilityEl()){
424 this.getVisibilityEl().removeClass(['hidden','d-none']);
426 this.fireEvent('show', this);
431 * Hide a component - adds 'hidden' class
435 if(!this.getVisibilityEl()){
439 this.getVisibilityEl().addClass(['hidden','d-none']);
441 this.fireEvent('hide', this);
454 * @class Roo.bootstrap.Body
455 * @extends Roo.bootstrap.Component
456 * Bootstrap Body class
460 * @param {Object} config The config object
461 * @cfg {DomElement} do_render - if this is set, then the constructor will try and initialize render, using this as the start point
465 Roo.bootstrap.Body = function(config){
467 config = config || {};
469 Roo.bootstrap.Body.superclass.constructor.call(this, config);
470 this.el = Roo.get(config.el ? config.el : document.body );
471 if (this.cls && this.cls.length) {
472 Roo.get(document.body).addClass(this.cls);
474 if (config.do_render) {
475 this.onRender(config.do_render, '');
476 this.addxtypeChildren(config.items);
481 Roo.extend(Roo.bootstrap.Body, Roo.bootstrap.Component, {
484 is_body : true,// just to make sure it's constructed?
489 onRender : function(ct, position)
491 if (!this.do_render) {
494 this.el = Roo.get(this.do_render);
495 /* Roo.log("Roo.bootstrap.Body - onRender");
496 if (this.cls && this.cls.length) {
497 Roo.get(document.body).addClass(this.cls);
516 * @class Roo.bootstrap.ButtonGroup
517 * @extends Roo.bootstrap.Component
518 * Bootstrap ButtonGroup class
519 * @cfg {String} size lg | sm | xs (default empty normal)
520 * @cfg {String} align vertical | justified (default none)
521 * @cfg {String} direction up | down (default down)
522 * @cfg {Boolean} toolbar false | true
523 * @cfg {Boolean} btn true | false
528 * @param {Object} config The config object
531 Roo.bootstrap.ButtonGroup = function(config){
532 Roo.bootstrap.ButtonGroup.superclass.constructor.call(this, config);
535 Roo.extend(Roo.bootstrap.ButtonGroup, Roo.bootstrap.Component, {
543 getAutoCreate : function(){
549 cfg.html = this.html || cfg.html;
560 if (['vertical','justified'].indexOf(this.align)!==-1) {
561 cfg.cls = 'btn-group-' + this.align;
563 if (this.align == 'justified') {
564 console.log(this.items);
568 if (['lg','sm','xs'].indexOf(this.size)!==-1) {
569 cfg.cls += ' btn-group-' + this.size;
572 if (this.direction == 'up') {
573 cfg.cls += ' dropup' ;
579 * Add a button to the group (similar to NavItem API.)
581 addItem : function(cfg)
583 var cn = new Roo.bootstrap.Button(cfg);
585 cn.parentId = this.id;
586 cn.onRender(this.el, null);
600 * @class Roo.bootstrap.Button
601 * @extends Roo.bootstrap.Component
602 * Bootstrap Button class
603 * @cfg {String} html The button content
604 * @cfg {String} weight (default | primary | secondary | success | info | warning | danger | link ) default
605 * @cfg {String} badge_weight (default | primary | secondary | success | info | warning | danger | link ) default (same as button)
606 * @cfg {Boolean} outline default false (except for weight=default which emulates old behaveiour with an outline)
607 * @cfg {String} size ( lg | sm | xs)
608 * @cfg {String} tag ( a | input | submit)
609 * @cfg {String} href empty or href
610 * @cfg {Boolean} disabled default false;
611 * @cfg {Boolean} isClose default false;
612 * @cfg {String} glyphicon depricated - use fa
613 * @cfg {String} fa fontawesome icon - eg. 'comment' - without the fa/fas etc..
614 * @cfg {String} badge text for badge
615 * @cfg {String} theme (default|glow)
616 * @cfg {Boolean} inverse dark themed version
617 * @cfg {Boolean} toggle is it a slidy toggle button
618 * @cfg {Boolean} pressed (true|false) default null - if the button ahs active state
619 * @cfg {String} ontext text for on slidy toggle state
620 * @cfg {String} offtext text for off slidy toggle state
621 * @cfg {Boolean} preventDefault default true (stop click event triggering the URL if it's a link.)
622 * @cfg {Boolean} removeClass remove the standard class..
623 * @cfg {String} target target for a href. (_self|_blank|_parent|_top| other)
626 * Create a new button
627 * @param {Object} config The config object
631 Roo.bootstrap.Button = function(config){
632 Roo.bootstrap.Button.superclass.constructor.call(this, config);
633 this.weightClass = ["btn-default btn-outline-secondary",
645 * When a butotn is pressed
646 * @param {Roo.bootstrap.Button} btn
647 * @param {Roo.EventObject} e
652 * After the button has been toggles
653 * @param {Roo.bootstrap.Button} btn
654 * @param {Roo.EventObject} e
655 * @param {boolean} pressed (also available as button.pressed)
661 Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, {
682 preventDefault: true,
690 getAutoCreate : function(){
698 if (['a', 'button', 'input', 'submit'].indexOf(this.tag) < 0) {
699 throw "Invalid value for tag: " + this.tag + ". must be a, button, input or submit.";
704 cfg.html = '<span class="roo-button-text">' + (this.html || cfg.html) + '</span>';
706 if (this.toggle == true) {
709 cls: 'slider-frame roo-button',
714 'data-off-text':'OFF',
715 cls: 'slider-button',
721 if (['default', 'secondary' , 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
722 cfg.cls += ' '+this.weight;
731 cfg["aria-hidden"] = true;
733 cfg.html = "×";
739 if (this.theme==='default') {
740 cfg.cls = 'btn roo-button';
742 //if (this.parentType != 'Navbar') {
743 this.weight = this.weight.length ? this.weight : 'default';
745 if (['default', 'primary', 'secondary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
747 var outline = this.outline || this.weight == 'default' ? 'outline-' : '';
748 var weight = this.weight == 'default' ? 'secondary' : this.weight;
749 cfg.cls += ' btn-' + outline + weight;
750 if (this.weight == 'default') {
752 cfg.cls += ' btn-' + this.weight;
755 } else if (this.theme==='glow') {
758 cfg.cls = 'btn-glow roo-button';
760 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
762 cfg.cls += ' ' + this.weight;
768 this.cls += ' inverse';
772 if (this.active || this.pressed === true) {
773 cfg.cls += ' active';
777 cfg.disabled = 'disabled';
781 Roo.log('changing to ul' );
783 this.glyphicon = 'caret';
784 if (Roo.bootstrap.version == 4) {
785 this.fa = 'caret-down';
790 cfg.cls += this.size.length ? (' btn-' + this.size) : '';
792 //gsRoo.log(this.parentType);
793 if (this.parentType === 'Navbar' && !this.parent().bar) {
794 Roo.log('changing to li?');
803 href : this.href || '#'
806 cfg.cn[0].html = this.html + ' <span class="caret"></span>';
807 cfg.cls += ' dropdown';
814 cfg.cls += this.parentType === 'Navbar' ? ' navbar-btn' : '';
816 if (this.glyphicon) {
817 cfg.html = ' ' + cfg.html;
822 cls: 'glyphicon glyphicon-' + this.glyphicon
827 cfg.html = ' ' + cfg.html;
832 cls: 'fa fas fa-' + this.fa
842 // cfg.cls='btn roo-button';
846 var value = cfg.html;
851 cls: 'glyphicon glyphicon-' + this.glyphicon,
858 cls: 'fa fas fa-' + this.fa,
863 var bw = this.badge_weight.length ? this.badge_weight :
864 (this.weight.length ? this.weight : 'secondary');
865 bw = bw == 'default' ? 'secondary' : bw;
871 cls: 'badge badge-' + bw,
880 cfg.cls += ' dropdown';
881 cfg.html = typeof(cfg.html) != 'undefined' ?
882 cfg.html + ' <span class="caret"></span>' : '<span class="caret"></span>';
885 if (cfg.tag !== 'a' && this.href !== '') {
886 throw "Tag must be a to set href.";
887 } else if (this.href.length > 0) {
888 cfg.href = this.href;
891 if(this.removeClass){
896 cfg.target = this.target;
901 initEvents: function() {
902 // Roo.log('init events?');
903 // Roo.log(this.el.dom);
906 if (typeof (this.menu) != 'undefined') {
907 this.menu.parentType = this.xtype;
908 this.menu.triggerEl = this.el;
909 this.addxtype(Roo.apply({}, this.menu));
913 if (this.el.hasClass('roo-button')) {
914 this.el.on('click', this.onClick, this);
916 this.el.select('.roo-button').on('click', this.onClick, this);
919 if(this.removeClass){
920 this.el.on('click', this.onClick, this);
923 this.el.enableDisplayMode();
926 onClick : function(e)
932 Roo.log('button on click ');
933 if(this.preventDefault){
937 if (this.pressed === true || this.pressed === false) {
938 this.toggleActive(e);
942 this.fireEvent('click', this, e);
946 * Enables this button
950 this.disabled = false;
951 this.el.removeClass('disabled');
955 * Disable this button
959 this.disabled = true;
960 this.el.addClass('disabled');
963 * sets the active state on/off,
964 * @param {Boolean} state (optional) Force a particular state
966 setActive : function(v) {
968 this.el[v ? 'addClass' : 'removeClass']('active');
972 * toggles the current active state
974 toggleActive : function(e)
976 this.setActive(!this.pressed);
977 this.fireEvent('toggle', this, e, !this.pressed);
980 * get the current active state
981 * @return {boolean} true if it's active
983 isActive : function()
985 return this.el.hasClass('active');
988 * set the text of the first selected button
990 setText : function(str)
992 this.el.select('.roo-button-text',true).first().dom.innerHTML = str;
995 * get the text of the first selected button
999 return this.el.select('.roo-button-text',true).first().dom.innerHTML;
1002 setWeight : function(str)
1004 this.el.removeClass(this.weightClass);
1006 var outline = this.outline ? 'outline-' : '';
1007 if (str == 'default') {
1008 this.el.addClass('btn-default btn-outline-secondary');
1011 this.el.addClass('btn-' + outline + str);
1025 * @class Roo.bootstrap.Column
1026 * @extends Roo.bootstrap.Component
1027 * Bootstrap Column class
1028 * @cfg {Number} xs colspan out of 12 for mobile-sized screens or 0 for hidden
1029 * @cfg {Number} sm colspan out of 12 for tablet-sized screens or 0 for hidden
1030 * @cfg {Number} md colspan out of 12 for computer-sized screens or 0 for hidden
1031 * @cfg {Number} lg colspan out of 12 for large computer-sized screens or 0 for hidden
1032 * @cfg {Number} xsoff colspan offset out of 12 for mobile-sized screens or 0 for hidden
1033 * @cfg {Number} smoff colspan offset out of 12 for tablet-sized screens or 0 for hidden
1034 * @cfg {Number} mdoff colspan offset out of 12 for computer-sized screens or 0 for hidden
1035 * @cfg {Number} lgoff colspan offset out of 12 for large computer-sized screens or 0 for hidden
1038 * @cfg {Boolean} hidden (true|false) hide the element
1039 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1040 * @cfg {String} fa (ban|check|...) font awesome icon
1041 * @cfg {Number} fasize (1|2|....) font awsome size
1043 * @cfg {String} icon (info-sign|check|...) glyphicon name
1045 * @cfg {String} html content of column.
1048 * Create a new Column
1049 * @param {Object} config The config object
1052 Roo.bootstrap.Column = function(config){
1053 Roo.bootstrap.Column.superclass.constructor.call(this, config);
1056 Roo.extend(Roo.bootstrap.Column, Roo.bootstrap.Component, {
1074 getAutoCreate : function(){
1075 var cfg = Roo.apply({}, Roo.bootstrap.Column.superclass.getAutoCreate.call(this));
1083 ['xs','sm','md','lg'].map(function(size){
1084 //Roo.log( size + ':' + settings[size]);
1086 if (settings[size+'off'] !== false) {
1087 cfg.cls += ' col-' + size + '-offset-' + settings[size+'off'] ;
1090 if (settings[size] === false) {
1094 if (!settings[size]) { // 0 = hidden
1095 cfg.cls += ' hidden-' + size + ' hidden' + size + '-down';;
1098 cfg.cls += ' col-' + size + '-' + settings[size] + (
1099 size == 'xs' ? (' col-' + settings[size] ) : '' // bs4 col-{num} replaces col-xs
1105 cfg.cls += ' hidden';
1108 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1109 cfg.cls +=' alert alert-' + this.alert;
1113 if (this.html.length) {
1114 cfg.html = this.html;
1118 if (this.fasize > 1) {
1119 fasize = ' fa-' + this.fasize + 'x';
1121 cfg.html = '<i class="fa fa-'+this.fa + fasize + '"></i>' + (cfg.html || '');
1126 cfg.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + (cfg.html || '');
1145 * @class Roo.bootstrap.Container
1146 * @extends Roo.bootstrap.Component
1147 * Bootstrap Container class
1148 * @cfg {Boolean} jumbotron is it a jumbotron element
1149 * @cfg {String} html content of element
1150 * @cfg {String} well (lg|sm|md) a well, large, small or medium.
1151 * @cfg {String} panel (default|primary|success|info|warning|danger) render as panel - type - primary/success.....
1152 * @cfg {String} header content of header (for panel)
1153 * @cfg {String} footer content of footer (for panel)
1154 * @cfg {String} sticky (footer|wrap|push) block to use as footer or body- needs css-bootstrap/sticky-footer.css
1155 * @cfg {String} tag (header|aside|section) type of HTML tag.
1156 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1157 * @cfg {String} fa font awesome icon
1158 * @cfg {String} icon (info-sign|check|...) glyphicon name
1159 * @cfg {Boolean} hidden (true|false) hide the element
1160 * @cfg {Boolean} expandable (true|false) default false
1161 * @cfg {Boolean} expanded (true|false) default true
1162 * @cfg {String} rheader contet on the right of header
1163 * @cfg {Boolean} clickable (true|false) default false
1167 * Create a new Container
1168 * @param {Object} config The config object
1171 Roo.bootstrap.Container = function(config){
1172 Roo.bootstrap.Container.superclass.constructor.call(this, config);
1178 * After the panel has been expand
1180 * @param {Roo.bootstrap.Container} this
1185 * After the panel has been collapsed
1187 * @param {Roo.bootstrap.Container} this
1192 * When a element is chick
1193 * @param {Roo.bootstrap.Container} this
1194 * @param {Roo.EventObject} e
1200 Roo.extend(Roo.bootstrap.Container, Roo.bootstrap.Component, {
1218 getChildContainer : function() {
1224 if (this.panel.length) {
1225 return this.el.select('.panel-body',true).first();
1232 getAutoCreate : function(){
1235 tag : this.tag || 'div',
1239 if (this.jumbotron) {
1240 cfg.cls = 'jumbotron';
1245 // - this is applied by the parent..
1247 // cfg.cls = this.cls + '';
1250 if (this.sticky.length) {
1252 var bd = Roo.get(document.body);
1253 if (!bd.hasClass('bootstrap-sticky')) {
1254 bd.addClass('bootstrap-sticky');
1255 Roo.select('html',true).setStyle('height', '100%');
1258 cfg.cls += 'bootstrap-sticky-' + this.sticky;
1262 if (this.well.length) {
1263 switch (this.well) {
1266 cfg.cls +=' well well-' +this.well;
1275 cfg.cls += ' hidden';
1279 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1280 cfg.cls +=' alert alert-' + this.alert;
1285 if (this.panel.length) {
1286 cfg.cls += ' panel panel-' + this.panel;
1288 if (this.header.length) {
1292 if(this.expandable){
1294 cfg.cls = cfg.cls + ' expandable';
1298 cls: (this.expanded ? 'fa fa-minus' : 'fa fa-plus')
1306 cls : 'panel-title',
1307 html : (this.expandable ? ' ' : '') + this.header
1311 cls: 'panel-header-right',
1317 cls : 'panel-heading',
1318 style : this.expandable ? 'cursor: pointer' : '',
1326 cls : 'panel-body' + (this.expanded ? '' : ' hide'),
1331 if (this.footer.length) {
1333 cls : 'panel-footer',
1342 body.html = this.html || cfg.html;
1343 // prefix with the icons..
1345 body.html = '<i class="fa fa-'+this.fa + '"></i>' + body.html ;
1348 body.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + body.html ;
1353 if ((!this.cls || !this.cls.length) && (!cfg.cls || !cfg.cls.length)) {
1354 cfg.cls = 'container';
1360 initEvents: function()
1362 if(this.expandable){
1363 var headerEl = this.headerEl();
1366 headerEl.on('click', this.onToggleClick, this);
1371 this.el.on('click', this.onClick, this);
1376 onToggleClick : function()
1378 var headerEl = this.headerEl();
1394 if(this.fireEvent('expand', this)) {
1396 this.expanded = true;
1398 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).show();
1400 this.el.select('.panel-body',true).first().removeClass('hide');
1402 var toggleEl = this.toggleEl();
1408 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-minus']);
1413 collapse : function()
1415 if(this.fireEvent('collapse', this)) {
1417 this.expanded = false;
1419 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).hide();
1420 this.el.select('.panel-body',true).first().addClass('hide');
1422 var toggleEl = this.toggleEl();
1428 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-plus']);
1432 toggleEl : function()
1434 if(!this.el || !this.panel.length || !this.header.length || !this.expandable){
1438 return this.el.select('.panel-heading .fa',true).first();
1441 headerEl : function()
1443 if(!this.el || !this.panel.length || !this.header.length){
1447 return this.el.select('.panel-heading',true).first()
1452 if(!this.el || !this.panel.length){
1456 return this.el.select('.panel-body',true).first()
1459 titleEl : function()
1461 if(!this.el || !this.panel.length || !this.header.length){
1465 return this.el.select('.panel-title',true).first();
1468 setTitle : function(v)
1470 var titleEl = this.titleEl();
1476 titleEl.dom.innerHTML = v;
1479 getTitle : function()
1482 var titleEl = this.titleEl();
1488 return titleEl.dom.innerHTML;
1491 setRightTitle : function(v)
1493 var t = this.el.select('.panel-header-right',true).first();
1499 t.dom.innerHTML = v;
1502 onClick : function(e)
1506 this.fireEvent('click', this, e);
1519 * @class Roo.bootstrap.Img
1520 * @extends Roo.bootstrap.Component
1521 * Bootstrap Img class
1522 * @cfg {Boolean} imgResponsive false | true
1523 * @cfg {String} border rounded | circle | thumbnail
1524 * @cfg {String} src image source
1525 * @cfg {String} alt image alternative text
1526 * @cfg {String} href a tag href
1527 * @cfg {String} target (_self|_blank|_parent|_top)target for a href.
1528 * @cfg {String} xsUrl xs image source
1529 * @cfg {String} smUrl sm image source
1530 * @cfg {String} mdUrl md image source
1531 * @cfg {String} lgUrl lg image source
1534 * Create a new Input
1535 * @param {Object} config The config object
1538 Roo.bootstrap.Img = function(config){
1539 Roo.bootstrap.Img.superclass.constructor.call(this, config);
1545 * The img click event for the img.
1546 * @param {Roo.EventObject} e
1552 Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, {
1554 imgResponsive: true,
1564 getAutoCreate : function()
1566 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1567 return this.createSingleImg();
1572 cls: 'roo-image-responsive-group',
1577 Roo.each(['xs', 'sm', 'md', 'lg'], function(size){
1579 if(!_this[size + 'Url']){
1585 cls: (_this.imgResponsive) ? 'img-responsive' : '',
1586 html: _this.html || cfg.html,
1587 src: _this[size + 'Url']
1590 img.cls += ' roo-image-responsive-' + size;
1592 var s = ['xs', 'sm', 'md', 'lg'];
1594 s.splice(s.indexOf(size), 1);
1596 Roo.each(s, function(ss){
1597 img.cls += ' hidden-' + ss;
1600 if (['rounded','circle','thumbnail'].indexOf(_this.border)>-1) {
1601 cfg.cls += ' img-' + _this.border;
1605 cfg.alt = _this.alt;
1618 a.target = _this.target;
1622 cfg.cn.push((_this.href) ? a : img);
1629 createSingleImg : function()
1633 cls: (this.imgResponsive) ? 'img-responsive' : '',
1635 src : 'about:blank' // just incase src get's set to undefined?!?
1638 cfg.html = this.html || cfg.html;
1640 cfg.src = this.src || cfg.src;
1642 if (['rounded','circle','thumbnail'].indexOf(this.border)>-1) {
1643 cfg.cls += ' img-' + this.border;
1660 a.target = this.target;
1665 return (this.href) ? a : cfg;
1668 initEvents: function()
1671 this.el.on('click', this.onClick, this);
1676 onClick : function(e)
1678 Roo.log('img onclick');
1679 this.fireEvent('click', this, e);
1682 * Sets the url of the image - used to update it
1683 * @param {String} url the url of the image
1686 setSrc : function(url)
1690 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1691 this.el.dom.src = url;
1695 this.el.select('img', true).first().dom.src = url;
1711 * @class Roo.bootstrap.Link
1712 * @extends Roo.bootstrap.Component
1713 * Bootstrap Link Class
1714 * @cfg {String} alt image alternative text
1715 * @cfg {String} href a tag href
1716 * @cfg {String} target (_self|_blank|_parent|_top) target for a href.
1717 * @cfg {String} html the content of the link.
1718 * @cfg {String} anchor name for the anchor link
1719 * @cfg {String} fa - favicon
1721 * @cfg {Boolean} preventDefault (true | false) default false
1725 * Create a new Input
1726 * @param {Object} config The config object
1729 Roo.bootstrap.Link = function(config){
1730 Roo.bootstrap.Link.superclass.constructor.call(this, config);
1736 * The img click event for the img.
1737 * @param {Roo.EventObject} e
1743 Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component, {
1747 preventDefault: false,
1753 getAutoCreate : function()
1755 var html = this.html || '';
1757 if (this.fa !== false) {
1758 html = '<i class="fa fa-' + this.fa + '"></i>';
1763 // anchor's do not require html/href...
1764 if (this.anchor === false) {
1766 cfg.href = this.href || '#';
1768 cfg.name = this.anchor;
1769 if (this.html !== false || this.fa !== false) {
1772 if (this.href !== false) {
1773 cfg.href = this.href;
1777 if(this.alt !== false){
1782 if(this.target !== false) {
1783 cfg.target = this.target;
1789 initEvents: function() {
1791 if(!this.href || this.preventDefault){
1792 this.el.on('click', this.onClick, this);
1796 onClick : function(e)
1798 if(this.preventDefault){
1801 //Roo.log('img onclick');
1802 this.fireEvent('click', this, e);
1815 * @class Roo.bootstrap.Header
1816 * @extends Roo.bootstrap.Component
1817 * Bootstrap Header class
1818 * @cfg {String} html content of header
1819 * @cfg {Number} level (1|2|3|4|5|6) default 1
1822 * Create a new Header
1823 * @param {Object} config The config object
1827 Roo.bootstrap.Header = function(config){
1828 Roo.bootstrap.Header.superclass.constructor.call(this, config);
1831 Roo.extend(Roo.bootstrap.Header, Roo.bootstrap.Component, {
1839 getAutoCreate : function(){
1844 tag: 'h' + (1 *this.level),
1845 html: this.html || ''
1857 * Ext JS Library 1.1.1
1858 * Copyright(c) 2006-2007, Ext JS, LLC.
1860 * Originally Released Under LGPL - original licence link has changed is not relivant.
1863 * <script type="text/javascript">
1867 * @class Roo.bootstrap.MenuMgr
1868 * Provides a common registry of all menu items on a page so that they can be easily accessed by id.
1871 Roo.bootstrap.MenuMgr = function(){
1872 var menus, active, groups = {}, attached = false, lastShow = new Date();
1874 // private - called when first menu is created
1877 active = new Roo.util.MixedCollection();
1878 Roo.get(document).addKeyListener(27, function(){
1879 if(active.length > 0){
1887 if(active && active.length > 0){
1888 var c = active.clone();
1898 if(active.length < 1){
1899 Roo.get(document).un("mouseup", onMouseDown);
1907 var last = active.last();
1908 lastShow = new Date();
1911 Roo.get(document).on("mouseup", onMouseDown);
1916 //m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
1917 m.parentMenu.activeChild = m;
1918 }else if(last && last.isVisible()){
1919 //m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
1924 function onBeforeHide(m){
1926 m.activeChild.hide();
1928 if(m.autoHideTimer){
1929 clearTimeout(m.autoHideTimer);
1930 delete m.autoHideTimer;
1935 function onBeforeShow(m){
1936 var pm = m.parentMenu;
1937 if(!pm && !m.allowOtherMenus){
1939 }else if(pm && pm.activeChild && active != m){
1940 pm.activeChild.hide();
1944 // private this should really trigger on mouseup..
1945 function onMouseDown(e){
1946 Roo.log("on Mouse Up");
1948 if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".dropdown-menu") && !e.getTarget('.user-menu')){
1949 Roo.log("MenuManager hideAll");
1958 function onBeforeCheck(mi, state){
1960 var g = groups[mi.group];
1961 for(var i = 0, l = g.length; i < l; i++){
1963 g[i].setChecked(false);
1972 * Hides all menus that are currently visible
1974 hideAll : function(){
1979 register : function(menu){
1983 menus[menu.id] = menu;
1984 menu.on("beforehide", onBeforeHide);
1985 menu.on("hide", onHide);
1986 menu.on("beforeshow", onBeforeShow);
1987 menu.on("show", onShow);
1989 if(g && menu.events["checkchange"]){
1993 groups[g].push(menu);
1994 menu.on("checkchange", onCheck);
1999 * Returns a {@link Roo.menu.Menu} object
2000 * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will
2001 * be used to generate and return a new Menu instance.
2003 get : function(menu){
2004 if(typeof menu == "string"){ // menu id
2006 }else if(menu.events){ // menu instance
2009 /*else if(typeof menu.length == 'number'){ // array of menu items?
2010 return new Roo.bootstrap.Menu({items:menu});
2011 }else{ // otherwise, must be a config
2012 return new Roo.bootstrap.Menu(menu);
2019 unregister : function(menu){
2020 delete menus[menu.id];
2021 menu.un("beforehide", onBeforeHide);
2022 menu.un("hide", onHide);
2023 menu.un("beforeshow", onBeforeShow);
2024 menu.un("show", onShow);
2026 if(g && menu.events["checkchange"]){
2027 groups[g].remove(menu);
2028 menu.un("checkchange", onCheck);
2033 registerCheckable : function(menuItem){
2034 var g = menuItem.group;
2039 groups[g].push(menuItem);
2040 menuItem.on("beforecheckchange", onBeforeCheck);
2045 unregisterCheckable : function(menuItem){
2046 var g = menuItem.group;
2048 groups[g].remove(menuItem);
2049 menuItem.un("beforecheckchange", onBeforeCheck);
2061 * @class Roo.bootstrap.Menu
2062 * @extends Roo.bootstrap.Component
2063 * Bootstrap Menu class - container for MenuItems
2064 * @cfg {String} type (dropdown|treeview|submenu) type of menu
2065 * @cfg {bool} hidden if the menu should be hidden when rendered.
2066 * @cfg {bool} stopEvent (true|false) Stop event after trigger press (default true)
2067 * @cfg {bool} isLink (true|false) the menu has link disable auto expand and collaspe (default false)
2071 * @param {Object} config The config object
2075 Roo.bootstrap.Menu = function(config){
2076 Roo.bootstrap.Menu.superclass.constructor.call(this, config);
2077 if (this.registerMenu && this.type != 'treeview') {
2078 Roo.bootstrap.MenuMgr.register(this);
2085 * Fires before this menu is displayed (return false to block)
2086 * @param {Roo.menu.Menu} this
2091 * Fires before this menu is hidden (return false to block)
2092 * @param {Roo.menu.Menu} this
2097 * Fires after this menu is displayed
2098 * @param {Roo.menu.Menu} this
2103 * Fires after this menu is hidden
2104 * @param {Roo.menu.Menu} this
2109 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
2110 * @param {Roo.menu.Menu} this
2111 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2112 * @param {Roo.EventObject} e
2117 * Fires when the mouse is hovering over this menu
2118 * @param {Roo.menu.Menu} this
2119 * @param {Roo.EventObject} e
2120 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2125 * Fires when the mouse exits this menu
2126 * @param {Roo.menu.Menu} this
2127 * @param {Roo.EventObject} e
2128 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2133 * Fires when a menu item contained in this menu is clicked
2134 * @param {Roo.menu.BaseItem} baseItem The BaseItem that was clicked
2135 * @param {Roo.EventObject} e
2139 this.menuitems = new Roo.util.MixedCollection(false, function(o) { return o.el.id; });
2142 Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, {
2146 triggerEl : false, // is this set by component builder? -- it should really be fetched from parent()???
2149 * @cfg {Boolean} registerMenu True (default) - means that clicking on screen etc. hides it.
2151 registerMenu : true,
2153 menuItems :false, // stores the menu items..
2163 getChildContainer : function() {
2167 getAutoCreate : function(){
2169 //if (['right'].indexOf(this.align)!==-1) {
2170 // cfg.cn[1].cls += ' pull-right'
2176 cls : 'dropdown-menu' ,
2177 style : 'z-index:1000'
2181 if (this.type === 'submenu') {
2182 cfg.cls = 'submenu active';
2184 if (this.type === 'treeview') {
2185 cfg.cls = 'treeview-menu';
2190 initEvents : function() {
2192 // Roo.log("ADD event");
2193 // Roo.log(this.triggerEl.dom);
2195 this.triggerEl.on('click', this.onTriggerClick, this);
2197 this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this);
2200 if (this.triggerEl.hasClass('nav-item')) {
2201 // dropdown toggle on the 'a' in BS4?
2202 this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle');
2204 this.triggerEl.addClass('dropdown-toggle');
2207 this.el.on('touchstart' , this.onTouch, this);
2209 this.el.on('click' , this.onClick, this);
2211 this.el.on("mouseover", this.onMouseOver, this);
2212 this.el.on("mouseout", this.onMouseOut, this);
2216 findTargetItem : function(e)
2218 var t = e.getTarget(".dropdown-menu-item", this.el, true);
2222 //Roo.log(t); Roo.log(t.id);
2224 //Roo.log(this.menuitems);
2225 return this.menuitems.get(t.id);
2227 //return this.items.get(t.menuItemId);
2233 onTouch : function(e)
2235 Roo.log("menu.onTouch");
2236 //e.stopEvent(); this make the user popdown broken
2240 onClick : function(e)
2242 Roo.log("menu.onClick");
2244 var t = this.findTargetItem(e);
2245 if(!t || t.isContainer){
2250 if (Roo.isTouch && e.type == 'touchstart' && t.menu && !t.disabled) {
2251 if(t == this.activeItem && t.shouldDeactivate(e)){
2252 this.activeItem.deactivate();
2253 delete this.activeItem;
2257 this.setActiveItem(t, true);
2265 Roo.log('pass click event');
2269 this.fireEvent("click", this, t, e);
2273 if(!t.href.length || t.href == '#'){
2274 (function() { _this.hide(); }).defer(100);
2279 onMouseOver : function(e){
2280 var t = this.findTargetItem(e);
2283 // if(t.canActivate && !t.disabled){
2284 // this.setActiveItem(t, true);
2288 this.fireEvent("mouseover", this, e, t);
2290 isVisible : function(){
2291 return !this.hidden;
2293 onMouseOut : function(e){
2294 var t = this.findTargetItem(e);
2297 // if(t == this.activeItem && t.shouldDeactivate(e)){
2298 // this.activeItem.deactivate();
2299 // delete this.activeItem;
2302 this.fireEvent("mouseout", this, e, t);
2307 * Displays this menu relative to another element
2308 * @param {String/HTMLElement/Roo.Element} element The element to align to
2309 * @param {String} position (optional) The {@link Roo.Element#alignTo} anchor position to use in aligning to
2310 * the element (defaults to this.defaultAlign)
2311 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2313 show : function(el, pos, parentMenu)
2315 if (false === this.fireEvent("beforeshow", this)) {
2316 Roo.log("show canceled");
2319 this.parentMenu = parentMenu;
2324 this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign), parentMenu, false);
2327 * Displays this menu at a specific xy position
2328 * @param {Array} xyPosition Contains X & Y [x, y] values for the position at which to show the menu (coordinates are page-based)
2329 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2331 showAt : function(xy, parentMenu, /* private: */_e){
2332 this.parentMenu = parentMenu;
2337 this.fireEvent("beforeshow", this);
2338 //xy = this.el.adjustForConstraints(xy);
2342 this.hideMenuItems();
2343 this.hidden = false;
2344 this.triggerEl.addClass('open');
2345 this.el.addClass('show');
2347 // reassign x when hitting right
2348 if(this.el.getWidth() + xy[0] >= Roo.lib.Dom.getViewWidth()){
2349 xy[0] = xy[0] - this.el.getWidth() + this.triggerEl.getWidth();
2352 // reassign y when hitting bottom
2353 if(this.el.getHeight() + xy[1] >= Roo.lib.Dom.getViewHeight()){
2354 xy[1] = xy[1] - this.el.getHeight() - this.triggerEl.getHeight();
2357 // but the list may align on trigger left or trigger top... should it be a properity?
2359 if(this.el.getStyle('top') != 'auto' && this.el.getStyle('top').slice(-1) != "%"){
2364 this.fireEvent("show", this);
2370 this.doFocus.defer(50, this);
2374 doFocus : function(){
2376 this.focusEl.focus();
2381 * Hides this menu and optionally all parent menus
2382 * @param {Boolean} deep (optional) True to hide all parent menus recursively, if any (defaults to false)
2384 hide : function(deep)
2386 if (false === this.fireEvent("beforehide", this)) {
2387 Roo.log("hide canceled");
2390 this.hideMenuItems();
2391 if(this.el && this.isVisible()){
2393 if(this.activeItem){
2394 this.activeItem.deactivate();
2395 this.activeItem = null;
2397 this.triggerEl.removeClass('open');;
2398 this.el.removeClass('show');
2400 this.fireEvent("hide", this);
2402 if(deep === true && this.parentMenu){
2403 this.parentMenu.hide(true);
2407 onTriggerClick : function(e)
2409 Roo.log('trigger click');
2411 var target = e.getTarget();
2413 Roo.log(target.nodeName.toLowerCase());
2415 if(target.nodeName.toLowerCase() === 'i'){
2421 onTriggerPress : function(e)
2423 Roo.log('trigger press');
2424 //Roo.log(e.getTarget());
2425 // Roo.log(this.triggerEl.dom);
2427 // trigger only occurs on normal menu's -- if it's a treeview or dropdown... do not hide/show..
2428 var pel = Roo.get(e.getTarget());
2429 if (pel.findParent('.dropdown-menu') || pel.findParent('.treeview-menu') ) {
2430 Roo.log('is treeview or dropdown?');
2434 if(e.getTarget().nodeName.toLowerCase() !== 'i' && this.isLink){
2438 if (this.isVisible()) {
2443 this.show(this.triggerEl, '?', false);
2446 if(this.stopEvent || e.getTarget().nodeName.toLowerCase() === 'i'){
2453 hideMenuItems : function()
2455 Roo.log("hide Menu Items");
2460 this.el.select('.open',true).each(function(aa) {
2462 aa.removeClass('open');
2466 addxtypeChild : function (tree, cntr) {
2467 var comp= Roo.bootstrap.Menu.superclass.addxtypeChild.call(this, tree, cntr);
2469 this.menuitems.add(comp);
2481 this.getEl().dom.innerHTML = '';
2482 this.menuitems.clear();
2496 * @class Roo.bootstrap.MenuItem
2497 * @extends Roo.bootstrap.Component
2498 * Bootstrap MenuItem class
2499 * @cfg {String} html the menu label
2500 * @cfg {String} href the link
2501 * @cfg {Boolean} preventDefault do not trigger A href on clicks (default false).
2502 * @cfg {Boolean} isContainer is it a container - just returns a drop down item..
2503 * @cfg {Boolean} active used on sidebars to highlight active itesm
2504 * @cfg {String} fa favicon to show on left of menu item.
2505 * @cfg {Roo.bootsrap.Menu} menu the child menu.
2509 * Create a new MenuItem
2510 * @param {Object} config The config object
2514 Roo.bootstrap.MenuItem = function(config){
2515 Roo.bootstrap.MenuItem.superclass.constructor.call(this, config);
2520 * The raw click event for the entire grid.
2521 * @param {Roo.bootstrap.MenuItem} this
2522 * @param {Roo.EventObject} e
2528 Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component, {
2532 preventDefault: false,
2533 isContainer : false,
2537 getAutoCreate : function(){
2539 if(this.isContainer){
2542 cls: 'dropdown-menu-item '
2552 cls : 'dropdown-item',
2557 if (this.fa !== false) {
2560 cls : 'fa fa-' + this.fa
2569 cls: 'dropdown-menu-item',
2572 if (this.parent().type == 'treeview') {
2573 cfg.cls = 'treeview-menu';
2576 cfg.cls += ' active';
2581 anc.href = this.href || cfg.cn[0].href ;
2582 ctag.html = this.html || cfg.cn[0].html ;
2586 initEvents: function()
2588 if (this.parent().type == 'treeview') {
2589 this.el.select('a').on('click', this.onClick, this);
2593 this.menu.parentType = this.xtype;
2594 this.menu.triggerEl = this.el;
2595 this.menu = this.addxtype(Roo.apply({}, this.menu));
2599 onClick : function(e)
2601 Roo.log('item on click ');
2603 if(this.preventDefault){
2606 //this.parent().hideMenuItems();
2608 this.fireEvent('click', this, e);
2627 * @class Roo.bootstrap.MenuSeparator
2628 * @extends Roo.bootstrap.Component
2629 * Bootstrap MenuSeparator class
2632 * Create a new MenuItem
2633 * @param {Object} config The config object
2637 Roo.bootstrap.MenuSeparator = function(config){
2638 Roo.bootstrap.MenuSeparator.superclass.constructor.call(this, config);
2641 Roo.extend(Roo.bootstrap.MenuSeparator, Roo.bootstrap.Component, {
2643 getAutoCreate : function(){
2662 * @class Roo.bootstrap.Modal
2663 * @extends Roo.bootstrap.Component
2664 * Bootstrap Modal class
2665 * @cfg {String} title Title of dialog
2666 * @cfg {String} html - the body of the dialog (for simple ones) - you can also use template..
2667 * @cfg {Roo.Template} tmpl - a template with variables. to use it, add a handler in show:method adn
2668 * @cfg {Boolean} specificTitle default false
2669 * @cfg {Array} buttons Array of buttons or standard button set..
2670 * @cfg {String} buttonPosition (left|right|center) default right (DEPRICATED) - use mr-auto on buttons to put them on the left
2671 * @cfg {Boolean} animate default true
2672 * @cfg {Boolean} allow_close default true
2673 * @cfg {Boolean} fitwindow default false
2674 * @cfg {String} size (sm|lg) default empty
2675 * @cfg {Number} max_width set the max width of modal
2679 * Create a new Modal Dialog
2680 * @param {Object} config The config object
2683 Roo.bootstrap.Modal = function(config){
2684 Roo.bootstrap.Modal.superclass.constructor.call(this, config);
2689 * The raw btnclick event for the button
2690 * @param {Roo.EventObject} e
2695 * Fire when dialog resize
2696 * @param {Roo.bootstrap.Modal} this
2697 * @param {Roo.EventObject} e
2701 this.buttons = this.buttons || [];
2704 this.tmpl = Roo.factory(this.tmpl);
2709 Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, {
2711 title : 'test dialog',
2721 specificTitle: false,
2723 buttonPosition: 'right',
2746 onRender : function(ct, position)
2748 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
2751 var cfg = Roo.apply({}, this.getAutoCreate());
2754 // cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
2756 //if (!cfg.name.length) {
2760 cfg.cls += ' ' + this.cls;
2763 cfg.style = this.style;
2765 this.el = Roo.get(document.body).createChild(cfg, position);
2767 //var type = this.el.dom.type;
2770 if(this.tabIndex !== undefined){
2771 this.el.dom.setAttribute('tabIndex', this.tabIndex);
2774 this.dialogEl = this.el.select('.modal-dialog',true).first();
2775 this.bodyEl = this.el.select('.modal-body',true).first();
2776 this.closeEl = this.el.select('.modal-header .close', true).first();
2777 this.headerEl = this.el.select('.modal-header',true).first();
2778 this.titleEl = this.el.select('.modal-title',true).first();
2779 this.footerEl = this.el.select('.modal-footer',true).first();
2781 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
2783 //this.el.addClass("x-dlg-modal");
2785 if (this.buttons.length) {
2786 Roo.each(this.buttons, function(bb) {
2787 var b = Roo.apply({}, bb);
2788 b.xns = b.xns || Roo.bootstrap;
2789 b.xtype = b.xtype || 'Button';
2790 if (typeof(b.listeners) == 'undefined') {
2791 b.listeners = { click : this.onButtonClick.createDelegate(this) };
2794 var btn = Roo.factory(b);
2796 btn.render(this.getButtonContainer());
2800 // render the children.
2803 if(typeof(this.items) != 'undefined'){
2804 var items = this.items;
2807 for(var i =0;i < items.length;i++) {
2808 nitems.push(this.addxtype(Roo.apply({}, items[i])));
2812 this.items = nitems;
2814 // where are these used - they used to be body/close/footer
2818 //this.el.addClass([this.fieldClass, this.cls]);
2822 getAutoCreate : function()
2826 html : this.html || ''
2831 cls : 'modal-title',
2835 if(this.specificTitle){
2841 if (this.allow_close && Roo.bootstrap.version == 3) {
2851 if (this.allow_close && Roo.bootstrap.version == 4) {
2861 if(this.size.length){
2862 size = 'modal-' + this.size;
2865 var footer = Roo.bootstrap.version == 3 ?
2867 cls : 'modal-footer',
2871 cls: 'btn-' + this.buttonPosition
2876 { // BS4 uses mr-auto on left buttons....
2877 cls : 'modal-footer'
2888 cls: "modal-dialog " + size,
2891 cls : "modal-content",
2894 cls : 'modal-header',
2909 modal.cls += ' fade';
2915 getChildContainer : function() {
2920 getButtonContainer : function() {
2922 return Roo.bootstrap.version == 4 ?
2923 this.el.select('.modal-footer',true).first()
2924 : this.el.select('.modal-footer div',true).first();
2927 initEvents : function()
2929 if (this.allow_close) {
2930 this.closeEl.on('click', this.hide, this);
2932 Roo.EventManager.onWindowResize(this.resize, this, true);
2940 this.maskEl.setSize(
2941 Roo.lib.Dom.getViewWidth(true),
2942 Roo.lib.Dom.getViewHeight(true)
2945 if (this.fitwindow) {
2949 this.width || Roo.lib.Dom.getViewportWidth(true) - 30,
2950 this.height || Roo.lib.Dom.getViewportHeight(true) // catering margin-top 30 margin-bottom 30
2955 if(this.max_width !== 0) {
2957 var w = Math.min(this.max_width, Roo.lib.Dom.getViewportWidth(true) - 30);
2960 this.setSize(w, this.height);
2964 if(this.max_height) {
2965 this.setSize(w,Math.min(
2967 Roo.lib.Dom.getViewportHeight(true) - 60
2973 if(!this.fit_content) {
2974 this.setSize(w, Roo.lib.Dom.getViewportHeight(true) - 60);
2978 this.setSize(w, Math.min(
2980 this.headerEl.getHeight() +
2981 this.footerEl.getHeight() +
2982 this.getChildHeight(this.bodyEl.dom.childNodes),
2983 Roo.lib.Dom.getViewportHeight(true) - 60)
2989 setSize : function(w,h)
3000 if (!this.rendered) {
3004 //this.el.setStyle('display', 'block');
3005 this.el.removeClass('hideing');
3006 this.el.dom.style.display='block';
3008 Roo.get(document.body).addClass('modal-open');
3010 if(this.animate){ // element has 'fade' - so stuff happens after .3s ?- not sure why the delay?
3013 this.el.addClass('show');
3014 this.el.addClass('in');
3017 this.el.addClass('show');
3018 this.el.addClass('in');
3021 // not sure how we can show data in here..
3023 // this.getChildContainer().dom.innerHTML = this.tmpl.applyTemplate(this);
3026 Roo.get(document.body).addClass("x-body-masked");
3028 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
3029 this.maskEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
3030 this.maskEl.dom.style.display = 'block';
3031 this.maskEl.addClass('show');
3036 this.fireEvent('show', this);
3038 // set zindex here - otherwise it appears to be ignored...
3039 this.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
3042 this.items.forEach( function(e) {
3043 e.layout ? e.layout() : false;
3051 if(this.fireEvent("beforehide", this) !== false){
3053 this.maskEl.removeClass('show');
3055 this.maskEl.dom.style.display = '';
3056 Roo.get(document.body).removeClass("x-body-masked");
3057 this.el.removeClass('in');
3058 this.el.select('.modal-dialog', true).first().setStyle('transform','');
3060 if(this.animate){ // why
3061 this.el.addClass('hideing');
3062 this.el.removeClass('show');
3064 if (!this.el.hasClass('hideing')) {
3065 return; // it's been shown again...
3068 this.el.dom.style.display='';
3070 Roo.get(document.body).removeClass('modal-open');
3071 this.el.removeClass('hideing');
3075 this.el.removeClass('show');
3076 this.el.dom.style.display='';
3077 Roo.get(document.body).removeClass('modal-open');
3080 this.fireEvent('hide', this);
3083 isVisible : function()
3086 return this.el.hasClass('show') && !this.el.hasClass('hideing');
3090 addButton : function(str, cb)
3094 var b = Roo.apply({}, { html : str } );
3095 b.xns = b.xns || Roo.bootstrap;
3096 b.xtype = b.xtype || 'Button';
3097 if (typeof(b.listeners) == 'undefined') {
3098 b.listeners = { click : cb.createDelegate(this) };
3101 var btn = Roo.factory(b);
3103 btn.render(this.getButtonContainer());
3109 setDefaultButton : function(btn)
3111 //this.el.select('.modal-footer').()
3114 resizeTo: function(w,h)
3116 this.dialogEl.setWidth(w);
3118 var diff = this.headerEl.getHeight() + this.footerEl.getHeight() + 60; // dialog margin-bottom: 30
3120 this.bodyEl.setHeight(h - diff);
3122 this.fireEvent('resize', this);
3125 setContentSize : function(w, h)
3129 onButtonClick: function(btn,e)
3132 this.fireEvent('btnclick', btn.name, e);
3135 * Set the title of the Dialog
3136 * @param {String} str new Title
3138 setTitle: function(str) {
3139 this.titleEl.dom.innerHTML = str;
3142 * Set the body of the Dialog
3143 * @param {String} str new Title
3145 setBody: function(str) {
3146 this.bodyEl.dom.innerHTML = str;
3149 * Set the body of the Dialog using the template
3150 * @param {Obj} data - apply this data to the template and replace the body contents.
3152 applyBody: function(obj)
3155 Roo.log("Error - using apply Body without a template");
3158 this.tmpl.overwrite(this.bodyEl, obj);
3161 getChildHeight : function(child_nodes)
3165 child_nodes.length == 0
3170 var child_height = 0;
3172 for(var i = 0; i < child_nodes.length; i++) {
3175 * for modal with tabs...
3176 if(child_nodes[i].classList.contains('roo-layout-panel')) {
3178 var layout_childs = child_nodes[i].childNodes;
3180 for(var j = 0; j < layout_childs.length; j++) {
3182 if(layout_childs[j].classList.contains('roo-layout-panel-body')) {
3184 var layout_body_childs = layout_childs[j].childNodes;
3186 for(var k = 0; k < layout_body_childs.length; k++) {
3188 if(layout_body_childs[k].classList.contains('navbar')) {
3189 child_height += layout_body_childs[k].offsetHeight;
3193 if(layout_body_childs[k].classList.contains('roo-layout-tabs-body')) {
3195 var layout_body_tab_childs = layout_body_childs[k].childNodes;
3197 for(var m = 0; m < layout_body_tab_childs.length; m++) {
3199 if(layout_body_tab_childs[m].classList.contains('roo-layout-active-content')) {
3200 child_height += this.getChildHeight(layout_body_tab_childs[m].childNodes);
3215 child_height += child_nodes[i].offsetHeight;
3216 // Roo.log(child_nodes[i].offsetHeight);
3219 return child_height;
3225 Roo.apply(Roo.bootstrap.Modal, {
3227 * Button config that displays a single OK button
3236 * Button config that displays Yes and No buttons
3252 * Button config that displays OK and Cancel buttons
3267 * Button config that displays Yes, No and Cancel buttons
3291 * messagebox - can be used as a replace
3295 * @class Roo.MessageBox
3296 * Utility class for generating different styles of message boxes. The alias Roo.Msg can also be used.
3300 Roo.Msg.alert('Status', 'Changes saved successfully.');
3302 // Prompt for user data:
3303 Roo.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
3305 // process text value...
3309 // Show a dialog using config options:
3311 title:'Save Changes?',
3312 msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',
3313 buttons: Roo.Msg.YESNOCANCEL,
3320 Roo.bootstrap.MessageBox = function(){
3321 var dlg, opt, mask, waitTimer;
3322 var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp;
3323 var buttons, activeTextEl, bwidth;
3327 var handleButton = function(button){
3329 Roo.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
3333 var handleHide = function(){
3335 dlg.el.removeClass(opt.cls);
3338 // Roo.TaskMgr.stop(waitTimer);
3339 // waitTimer = null;
3344 var updateButtons = function(b){
3347 buttons["ok"].hide();
3348 buttons["cancel"].hide();
3349 buttons["yes"].hide();
3350 buttons["no"].hide();
3351 dlg.footerEl.hide();
3355 dlg.footerEl.show();
3356 for(var k in buttons){
3357 if(typeof buttons[k] != "function"){
3360 buttons[k].setText(typeof b[k] == "string" ? b[k] : Roo.bootstrap.MessageBox.buttonText[k]);
3361 width += buttons[k].el.getWidth()+15;
3371 var handleEsc = function(d, k, e){
3372 if(opt && opt.closable !== false){
3382 * Returns a reference to the underlying {@link Roo.BasicDialog} element
3383 * @return {Roo.BasicDialog} The BasicDialog element
3385 getDialog : function(){
3387 dlg = new Roo.bootstrap.Modal( {
3390 //constraintoviewport:false,
3392 //collapsible : false,
3397 //buttonAlign:"center",
3398 closeClick : function(){
3399 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
3402 handleButton("cancel");
3407 dlg.on("hide", handleHide);
3409 //dlg.addKeyListener(27, handleEsc);
3411 this.buttons = buttons;
3412 var bt = this.buttonText;
3413 buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
3414 buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
3415 buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
3416 buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
3418 bodyEl = dlg.bodyEl.createChild({
3420 html:'<span class="roo-mb-text"></span><br /><input type="text" class="roo-mb-input" />' +
3421 '<textarea class="roo-mb-textarea"></textarea>' +
3422 '<div class="roo-mb-progress-wrap"><div class="roo-mb-progress"><div class="roo-mb-progress-bar"> </div></div></div>'
3424 msgEl = bodyEl.dom.firstChild;
3425 textboxEl = Roo.get(bodyEl.dom.childNodes[2]);
3426 textboxEl.enableDisplayMode();
3427 textboxEl.addKeyListener([10,13], function(){
3428 if(dlg.isVisible() && opt && opt.buttons){
3431 }else if(opt.buttons.yes){
3432 handleButton("yes");
3436 textareaEl = Roo.get(bodyEl.dom.childNodes[3]);
3437 textareaEl.enableDisplayMode();
3438 progressEl = Roo.get(bodyEl.dom.childNodes[4]);
3439 progressEl.enableDisplayMode();
3441 // This is supposed to be the progessElement.. but I think it's controlling the height of everything..
3442 var pf = progressEl.dom.firstChild;
3444 pp = Roo.get(pf.firstChild);
3445 pp.setHeight(pf.offsetHeight);
3453 * Updates the message box body text
3454 * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
3455 * the XHTML-compliant non-breaking space character '&#160;')
3456 * @return {Roo.MessageBox} This message box
3458 updateText : function(text)
3460 if(!dlg.isVisible() && !opt.width){
3461 dlg.dialogEl.setStyle({ 'max-width' : this.maxWidth});
3462 // dlg.resizeTo(this.maxWidth, 100); // forcing the height breaks long alerts()
3464 msgEl.innerHTML = text || ' ';
3466 var cw = Math.max(msgEl.offsetWidth, msgEl.parentNode.scrollWidth);
3467 //Roo.log("guesed size: " + JSON.stringify([cw,msgEl.offsetWidth, msgEl.parentNode.scrollWidth]));
3469 Math.min(opt.width || cw , this.maxWidth),
3470 Math.max(opt.minWidth || this.minWidth, bwidth)
3473 activeTextEl.setWidth(w);
3475 if(dlg.isVisible()){
3476 dlg.fixedcenter = false;
3478 // to big, make it scroll. = But as usual stupid IE does not support
3481 if ( bodyEl.getHeight() > (Roo.lib.Dom.getViewHeight() - 100)) {
3482 bodyEl.setHeight ( Roo.lib.Dom.getViewHeight() - 100 );
3483 bodyEl.dom.style.overflowY = 'auto' + ( Roo.isIE ? '' : ' !important');
3485 bodyEl.dom.style.height = '';
3486 bodyEl.dom.style.overflowY = '';
3489 bodyEl.dom.style.get = 'auto' + ( Roo.isIE ? '' : ' !important');
3491 bodyEl.dom.style.overflowX = '';
3494 dlg.setContentSize(w, bodyEl.getHeight());
3495 if(dlg.isVisible()){
3496 dlg.fixedcenter = true;
3502 * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
3503 * initiated via {@link Roo.MessageBox#progress} or by calling {@link Roo.MessageBox#show} with progress: true.
3504 * @param {Number} value Any number between 0 and 1 (e.g., .5)
3505 * @param {String} text (optional) If defined, the message box's body text is replaced with the specified string (defaults to undefined)
3506 * @return {Roo.MessageBox} This message box
3508 updateProgress : function(value, text){
3510 this.updateText(text);
3513 if (pp) { // weird bug on my firefox - for some reason this is not defined
3514 pp.setWidth(Math.floor(value*progressEl.dom.firstChild.offsetWidth));
3515 pp.setHeight(Math.floor(progressEl.dom.firstChild.offsetHeight));
3521 * Returns true if the message box is currently displayed
3522 * @return {Boolean} True if the message box is visible, else false
3524 isVisible : function(){
3525 return dlg && dlg.isVisible();
3529 * Hides the message box if it is displayed
3532 if(this.isVisible()){
3538 * Displays a new message box, or reinitializes an existing message box, based on the config options
3539 * passed in. All functions (e.g. prompt, alert, etc) on MessageBox call this function internally.
3540 * The following config object properties are supported:
3542 Property Type Description
3543 ---------- --------------- ------------------------------------------------------------------------------------
3544 animEl String/Element An id or Element from which the message box should animate as it opens and
3545 closes (defaults to undefined)
3546 buttons Object/Boolean A button config object (e.g., Roo.MessageBox.OKCANCEL or {ok:'Foo',
3547 cancel:'Bar'}), or false to not show any buttons (defaults to false)
3548 closable Boolean False to hide the top-right close button (defaults to true). Note that
3549 progress and wait dialogs will ignore this property and always hide the
3550 close button as they can only be closed programmatically.
3551 cls String A custom CSS class to apply to the message box element
3552 defaultTextHeight Number The default height in pixels of the message box's multiline textarea if
3553 displayed (defaults to 75)
3554 fn Function A callback function to execute after closing the dialog. The arguments to the
3555 function will be btn (the name of the button that was clicked, if applicable,
3556 e.g. "ok"), and text (the value of the active text field, if applicable).
3557 Progress and wait dialogs will ignore this option since they do not respond to
3558 user actions and can only be closed programmatically, so any required function
3559 should be called by the same code after it closes the dialog.
3560 icon String A CSS class that provides a background image to be used as an icon for
3561 the dialog (e.g., Roo.MessageBox.WARNING or 'custom-class', defaults to '')
3562 maxWidth Number The maximum width in pixels of the message box (defaults to 600)
3563 minWidth Number The minimum width in pixels of the message box (defaults to 100)
3564 modal Boolean False to allow user interaction with the page while the message box is
3565 displayed (defaults to true)
3566 msg String A string that will replace the existing message box body text (defaults
3567 to the XHTML-compliant non-breaking space character ' ')
3568 multiline Boolean True to prompt the user to enter multi-line text (defaults to false)
3569 progress Boolean True to display a progress bar (defaults to false)
3570 progressText String The text to display inside the progress bar if progress = true (defaults to '')
3571 prompt Boolean True to prompt the user to enter single-line text (defaults to false)
3572 proxyDrag Boolean True to display a lightweight proxy while dragging (defaults to false)
3573 title String The title text
3574 value String The string value to set into the active textbox element if displayed
3575 wait Boolean True to display a progress bar (defaults to false)
3576 width Number The width of the dialog in pixels
3583 msg: 'Please enter your address:',
3585 buttons: Roo.MessageBox.OKCANCEL,
3588 animEl: 'addAddressBtn'
3591 * @param {Object} config Configuration options
3592 * @return {Roo.MessageBox} This message box
3594 show : function(options)
3597 // this causes nightmares if you show one dialog after another
3598 // especially on callbacks..
3600 if(this.isVisible()){
3603 Roo.log("[Roo.Messagebox] Show called while message displayed:" );
3604 Roo.log("Old Dialog Message:" + msgEl.innerHTML );
3605 Roo.log("New Dialog Message:" + options.msg )
3606 //this.alert("ERROR", "Multiple dialogs where displayed at the same time");
3607 //throw "Roo.MessageBox ERROR : Multiple dialogs where displayed at the same time";
3610 var d = this.getDialog();
3612 d.setTitle(opt.title || " ");
3613 d.closeEl.setDisplayed(opt.closable !== false);
3614 activeTextEl = textboxEl;
3615 opt.prompt = opt.prompt || (opt.multiline ? true : false);
3620 textareaEl.setHeight(typeof opt.multiline == "number" ?
3621 opt.multiline : this.defaultTextHeight);
3622 activeTextEl = textareaEl;
3631 progressEl.setDisplayed(opt.progress === true);
3633 d.animate = false; // do not animate progress, as it may not have finished animating before we close it..
3635 this.updateProgress(0);
3636 activeTextEl.dom.value = opt.value || "";
3638 dlg.setDefaultButton(activeTextEl);
3640 var bs = opt.buttons;
3644 }else if(bs && bs.yes){
3645 db = buttons["yes"];
3647 dlg.setDefaultButton(db);
3649 bwidth = updateButtons(opt.buttons);
3650 this.updateText(opt.msg);
3652 d.el.addClass(opt.cls);
3654 d.proxyDrag = opt.proxyDrag === true;
3655 d.modal = opt.modal !== false;
3656 d.mask = opt.modal !== false ? mask : false;
3658 // force it to the end of the z-index stack so it gets a cursor in FF
3659 document.body.appendChild(dlg.el.dom);
3660 d.animateTarget = null;
3661 d.show(options.animEl);
3667 * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
3668 * the user. You are responsible for updating the progress bar as needed via {@link Roo.MessageBox#updateProgress}
3669 * and closing the message box when the process is complete.
3670 * @param {String} title The title bar text
3671 * @param {String} msg The message box body text
3672 * @return {Roo.MessageBox} This message box
3674 progress : function(title, msg){
3681 minWidth: this.minProgressWidth,
3688 * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
3689 * If a callback function is passed it will be called after the user clicks the button, and the
3690 * id of the button that was clicked will be passed as the only parameter to the callback
3691 * (could also be the top-right close button).
3692 * @param {String} title The title bar text
3693 * @param {String} msg The message box body text
3694 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3695 * @param {Object} scope (optional) The scope of the callback function
3696 * @return {Roo.MessageBox} This message box
3698 alert : function(title, msg, fn, scope)
3713 * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
3714 * interaction while waiting for a long-running process to complete that does not have defined intervals.
3715 * You are responsible for closing the message box when the process is complete.
3716 * @param {String} msg The message box body text
3717 * @param {String} title (optional) The title bar text
3718 * @return {Roo.MessageBox} This message box
3720 wait : function(msg, title){
3731 waitTimer = Roo.TaskMgr.start({
3733 Roo.MessageBox.updateProgress(((((i+20)%20)+1)*5)*.01);
3741 * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
3742 * If a callback function is passed it will be called after the user clicks either button, and the id of the
3743 * button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
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 * @return {Roo.MessageBox} This message box
3750 confirm : function(title, msg, fn, scope){
3754 buttons: this.YESNO,
3763 * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to
3764 * JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function
3765 * is passed it will be called after the user clicks either button, and the id of the button that was clicked
3766 * (could also be the top-right close button) and the text that was entered will be passed as the two
3767 * parameters to the callback.
3768 * @param {String} title The title bar text
3769 * @param {String} msg The message box body text
3770 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3771 * @param {Object} scope (optional) The scope of the callback function
3772 * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
3773 * property, or the height in pixels to create the textbox (defaults to false / single-line)
3774 * @return {Roo.MessageBox} This message box
3776 prompt : function(title, msg, fn, scope, multiline){
3780 buttons: this.OKCANCEL,
3785 multiline: multiline,
3792 * Button config that displays a single OK button
3797 * Button config that displays Yes and No buttons
3800 YESNO : {yes:true, no:true},
3802 * Button config that displays OK and Cancel buttons
3805 OKCANCEL : {ok:true, cancel:true},
3807 * Button config that displays Yes, No and Cancel buttons
3810 YESNOCANCEL : {yes:true, no:true, cancel:true},
3813 * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
3816 defaultTextHeight : 75,
3818 * The maximum width in pixels of the message box (defaults to 600)
3823 * The minimum width in pixels of the message box (defaults to 100)
3828 * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
3829 * for setting a different minimum width than text-only dialogs may need (defaults to 250)
3832 minProgressWidth : 250,
3834 * An object containing the default button text strings that can be overriden for localized language support.
3835 * Supported properties are: ok, cancel, yes and no.
3836 * Customize the default text like so: Roo.MessageBox.buttonText.yes = "S?";
3849 * Shorthand for {@link Roo.MessageBox}
3851 Roo.MessageBox = Roo.MessageBox || Roo.bootstrap.MessageBox;
3852 Roo.Msg = Roo.Msg || Roo.MessageBox;
3861 * @class Roo.bootstrap.Navbar
3862 * @extends Roo.bootstrap.Component
3863 * Bootstrap Navbar class
3866 * Create a new Navbar
3867 * @param {Object} config The config object
3871 Roo.bootstrap.Navbar = function(config){
3872 Roo.bootstrap.Navbar.superclass.constructor.call(this, config);
3876 * @event beforetoggle
3877 * Fire before toggle the menu
3878 * @param {Roo.EventObject} e
3880 "beforetoggle" : true
3884 Roo.extend(Roo.bootstrap.Navbar, Roo.bootstrap.Component, {
3893 getAutoCreate : function(){
3896 throw { message : "nav bar is now a abstract base class - use NavSimplebar / NavHeaderbar / NavSidebar etc..."};
3900 initEvents :function ()
3902 //Roo.log(this.el.select('.navbar-toggle',true));
3903 this.el.select('.navbar-toggle',true).on('click', this.onToggle , this);
3910 this.maskEl = Roo.DomHelper.append(this.el, mark, true);
3912 var size = this.el.getSize();
3913 this.maskEl.setSize(size.width, size.height);
3914 this.maskEl.enableDisplayMode("block");
3923 getChildContainer : function()
3925 if (this.el && this.el.select('.collapse').getCount()) {
3926 return this.el.select('.collapse',true).first();
3941 onToggle : function()
3944 if(this.fireEvent('beforetoggle', this) === false){
3947 var ce = this.el.select('.navbar-collapse',true).first();
3949 if (!ce.hasClass('show')) {
3959 * Expand the navbar pulldown
3961 expand : function ()
3964 var ce = this.el.select('.navbar-collapse',true).first();
3965 if (ce.hasClass('collapsing')) {
3968 ce.dom.style.height = '';
3970 ce.addClass('in'); // old...
3971 ce.removeClass('collapse');
3972 ce.addClass('show');
3973 var h = ce.getHeight();
3975 ce.removeClass('show');
3976 // at this point we should be able to see it..
3977 ce.addClass('collapsing');
3979 ce.setHeight(0); // resize it ...
3980 ce.on('transitionend', function() {
3981 //Roo.log('done transition');
3982 ce.removeClass('collapsing');
3983 ce.addClass('show');
3984 ce.removeClass('collapse');
3986 ce.dom.style.height = '';
3987 }, this, { single: true} );
3989 ce.dom.scrollTop = 0;
3992 * Collapse the navbar pulldown
3994 collapse : function()
3996 var ce = this.el.select('.navbar-collapse',true).first();
3998 if (ce.hasClass('collapsing') || ce.hasClass('collapse') ) {
3999 // it's collapsed or collapsing..
4002 ce.removeClass('in'); // old...
4003 ce.setHeight(ce.getHeight());
4004 ce.removeClass('show');
4005 ce.addClass('collapsing');
4007 ce.on('transitionend', function() {
4008 ce.dom.style.height = '';
4009 ce.removeClass('collapsing');
4010 ce.addClass('collapse');
4011 }, this, { single: true} );
4031 * @class Roo.bootstrap.NavSimplebar
4032 * @extends Roo.bootstrap.Navbar
4033 * Bootstrap Sidebar class
4035 * @cfg {Boolean} inverse is inverted color
4037 * @cfg {String} type (nav | pills | tabs)
4038 * @cfg {Boolean} arrangement stacked | justified
4039 * @cfg {String} align (left | right) alignment
4041 * @cfg {Boolean} main (true|false) main nav bar? default false
4042 * @cfg {Boolean} loadMask (true|false) loadMask on the bar
4044 * @cfg {String} tag (header|footer|nav|div) default is nav
4046 * @cfg {String} weight (light|primary|secondary|success|danger|warning|info|dark|white) default is light.
4050 * Create a new Sidebar
4051 * @param {Object} config The config object
4055 Roo.bootstrap.NavSimplebar = function(config){
4056 Roo.bootstrap.NavSimplebar.superclass.constructor.call(this, config);
4059 Roo.extend(Roo.bootstrap.NavSimplebar, Roo.bootstrap.Navbar, {
4075 getAutoCreate : function(){
4079 tag : this.tag || 'div',
4080 cls : 'navbar roo-navbar-simple' //navbar-expand-lg ??
4082 if (['light','white'].indexOf(this.weight) > -1) {
4083 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
4085 cfg.cls += ' bg-' + this.weight;
4088 cfg.cls += ' navbar-inverse';
4092 // i'm not actually sure these are really used - normally we add a navGroup to a navbar
4094 if (Roo.bootstrap.version == 4 && this.xtype == 'NavSimplebar') {
4103 cls: 'nav nav-' + this.xtype,
4109 this.type = this.type || 'nav';
4110 if (['tabs','pills'].indexOf(this.type) != -1) {
4111 cfg.cn[0].cls += ' nav-' + this.type
4115 if (this.type!=='nav') {
4116 Roo.log('nav type must be nav/tabs/pills')
4118 cfg.cn[0].cls += ' navbar-nav'
4124 if (['stacked','justified'].indexOf(this.arrangement) != -1) {
4125 cfg.cn[0].cls += ' nav-' + this.arrangement;
4129 if (this.align === 'right') {
4130 cfg.cn[0].cls += ' navbar-right';
4155 * navbar-expand-md fixed-top
4159 * @class Roo.bootstrap.NavHeaderbar
4160 * @extends Roo.bootstrap.NavSimplebar
4161 * Bootstrap Sidebar class
4163 * @cfg {String} brand what is brand
4164 * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
4165 * @cfg {String} brand_href href of the brand
4166 * @cfg {Boolean} srButton generate the (screen reader / mobile) sr-only button default true
4167 * @cfg {Boolean} autohide a top nav bar header that hides on scroll.
4168 * @cfg {Boolean} desktopCenter should the header be centered on desktop using a container class
4169 * @cfg {Roo.bootstrap.Row} mobilerow - a row to display on mobile only..
4172 * Create a new Sidebar
4173 * @param {Object} config The config object
4177 Roo.bootstrap.NavHeaderbar = function(config){
4178 Roo.bootstrap.NavHeaderbar.superclass.constructor.call(this, config);
4182 Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar, {
4189 desktopCenter : false,
4192 getAutoCreate : function(){
4195 tag: this.nav || 'nav',
4196 cls: 'navbar navbar-expand-md',
4202 if (this.desktopCenter) {
4203 cn.push({cls : 'container', cn : []});
4211 cls: 'navbar-toggle navbar-toggler',
4212 'data-toggle': 'collapse',
4217 html: 'Toggle navigation'
4221 cls: 'icon-bar navbar-toggler-icon'
4234 cn.push( Roo.bootstrap.version == 4 ? btn : {
4236 cls: 'navbar-header',
4245 cls: Roo.bootstrap.version == 4 ? 'nav flex-row roo-navbar-collapse' : 'collapse navbar-collapse roo-navbar-collapse',
4249 cfg.cls += this.inverse ? ' navbar-inverse navbar-dark bg-dark' : ' navbar-default';
4251 if (['light','white'].indexOf(this.weight) > -1) {
4252 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
4254 cfg.cls += ' bg-' + this.weight;
4257 if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
4258 cfg.cls += ' navbar-' + this.position + ' ' + this.position ;
4260 // tag can override this..
4262 cfg.tag = this.tag || (this.position == 'fixed-bottom' ? 'footer' : 'header');
4265 if (this.brand !== '') {
4266 var cp = Roo.bootstrap.version == 4 ? cn : cn[0].cn;
4267 cp.unshift({ // changed from push ?? BS4 needs it at the start? - does this break or exsiting?
4269 href: this.brand_href ? this.brand_href : '#',
4270 cls: 'navbar-brand',
4278 cfg.cls += ' main-nav';
4286 getHeaderChildContainer : function()
4288 if (this.srButton && this.el.select('.navbar-header').getCount()) {
4289 return this.el.select('.navbar-header',true).first();
4292 return this.getChildContainer();
4296 initEvents : function()
4298 Roo.bootstrap.NavHeaderbar.superclass.initEvents.call(this);
4300 if (this.autohide) {
4305 Roo.get(document).on('scroll',function(e) {
4306 var ns = Roo.get(document).getScroll().top;
4307 var os = prevScroll;
4311 ft.removeClass('slideDown');
4312 ft.addClass('slideUp');
4315 ft.removeClass('slideUp');
4316 ft.addClass('slideDown');
4337 * @class Roo.bootstrap.NavSidebar
4338 * @extends Roo.bootstrap.Navbar
4339 * Bootstrap Sidebar class
4342 * Create a new Sidebar
4343 * @param {Object} config The config object
4347 Roo.bootstrap.NavSidebar = function(config){
4348 Roo.bootstrap.NavSidebar.superclass.constructor.call(this, config);
4351 Roo.extend(Roo.bootstrap.NavSidebar, Roo.bootstrap.Navbar, {
4353 sidebar : true, // used by Navbar Item and NavbarGroup at present...
4355 getAutoCreate : function(){
4360 cls: 'sidebar sidebar-nav'
4382 * @class Roo.bootstrap.NavGroup
4383 * @extends Roo.bootstrap.Component
4384 * Bootstrap NavGroup class
4385 * @cfg {String} align (left|right)
4386 * @cfg {Boolean} inverse
4387 * @cfg {String} type (nav|pills|tab) default nav
4388 * @cfg {String} navId - reference Id for navbar.
4392 * Create a new nav group
4393 * @param {Object} config The config object
4396 Roo.bootstrap.NavGroup = function(config){
4397 Roo.bootstrap.NavGroup.superclass.constructor.call(this, config);
4400 Roo.bootstrap.NavGroup.register(this);
4404 * Fires when the active item changes
4405 * @param {Roo.bootstrap.NavGroup} this
4406 * @param {Roo.bootstrap.Navbar.Item} selected The item selected
4407 * @param {Roo.bootstrap.Navbar.Item} prev The previously selected item
4414 Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, {
4425 getAutoCreate : function()
4427 var cfg = Roo.apply({}, Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));
4433 if (Roo.bootstrap.version == 4) {
4434 if (['tabs','pills'].indexOf(this.type) != -1) {
4435 cfg.cls += ' nav-' + this.type;
4437 // trying to remove so header bar can right align top?
4438 if (this.parent() && this.parent().xtype != 'NavHeaderbar') {
4439 // do not use on header bar...
4440 cfg.cls += ' navbar-nav';
4445 if (['tabs','pills'].indexOf(this.type) != -1) {
4446 cfg.cls += ' nav-' + this.type
4448 if (this.type !== 'nav') {
4449 Roo.log('nav type must be nav/tabs/pills')
4451 cfg.cls += ' navbar-nav'
4455 if (this.parent() && this.parent().sidebar) {
4458 cls: 'dashboard-menu sidebar-menu'
4464 if (this.form === true) {
4467 cls: 'navbar-form form-inline'
4469 //nav navbar-right ml-md-auto
4470 if (this.align === 'right') {
4471 cfg.cls += ' navbar-right ml-md-auto';
4473 cfg.cls += ' navbar-left';
4477 if (this.align === 'right') {
4478 cfg.cls += ' navbar-right ml-md-auto';
4480 cfg.cls += ' mr-auto';
4484 cfg.cls += ' navbar-inverse';
4492 * sets the active Navigation item
4493 * @param {Roo.bootstrap.NavItem} the new current navitem
4495 setActiveItem : function(item)
4498 Roo.each(this.navItems, function(v){
4503 v.setActive(false, true);
4510 item.setActive(true, true);
4511 this.fireEvent('changed', this, item, prev);
4516 * gets the active Navigation item
4517 * @return {Roo.bootstrap.NavItem} the current navitem
4519 getActive : function()
4523 Roo.each(this.navItems, function(v){
4534 indexOfNav : function()
4538 Roo.each(this.navItems, function(v,i){
4549 * adds a Navigation item
4550 * @param {Roo.bootstrap.NavItem} the navitem to add
4552 addItem : function(cfg)
4554 if (this.form && Roo.bootstrap.version == 4) {
4557 var cn = new Roo.bootstrap.NavItem(cfg);
4559 cn.parentId = this.id;
4560 cn.onRender(this.el, null);
4564 * register a Navigation item
4565 * @param {Roo.bootstrap.NavItem} the navitem to add
4567 register : function(item)
4569 this.navItems.push( item);
4570 item.navId = this.navId;
4575 * clear all the Navigation item
4578 clearAll : function()
4581 this.el.dom.innerHTML = '';
4584 getNavItem: function(tabId)
4587 Roo.each(this.navItems, function(e) {
4588 if (e.tabId == tabId) {
4598 setActiveNext : function()
4600 var i = this.indexOfNav(this.getActive());
4601 if (i > this.navItems.length) {
4604 this.setActiveItem(this.navItems[i+1]);
4606 setActivePrev : function()
4608 var i = this.indexOfNav(this.getActive());
4612 this.setActiveItem(this.navItems[i-1]);
4614 clearWasActive : function(except) {
4615 Roo.each(this.navItems, function(e) {
4616 if (e.tabId != except.tabId && e.was_active) {
4617 e.was_active = false;
4624 getWasActive : function ()
4627 Roo.each(this.navItems, function(e) {
4642 Roo.apply(Roo.bootstrap.NavGroup, {
4646 * register a Navigation Group
4647 * @param {Roo.bootstrap.NavGroup} the navgroup to add
4649 register : function(navgrp)
4651 this.groups[navgrp.navId] = navgrp;
4655 * fetch a Navigation Group based on the navigation ID
4656 * @param {string} the navgroup to add
4657 * @returns {Roo.bootstrap.NavGroup} the navgroup
4659 get: function(navId) {
4660 if (typeof(this.groups[navId]) == 'undefined') {
4662 //this.register(new Roo.bootstrap.NavGroup({ navId : navId }));
4664 return this.groups[navId] ;
4679 * @class Roo.bootstrap.NavItem
4680 * @extends Roo.bootstrap.Component
4681 * Bootstrap Navbar.NavItem class
4682 * @cfg {String} href link to
4683 * @cfg {String} button_weight (default | primary | secondary | success | info | warning | danger | link ) default none
4685 * @cfg {String} html content of button
4686 * @cfg {String} badge text inside badge
4687 * @cfg {String} badgecls (bg-green|bg-red|bg-yellow)the extra classes for the badge
4688 * @cfg {String} glyphicon DEPRICATED - use fa
4689 * @cfg {String} icon DEPRICATED - use fa
4690 * @cfg {String} fa - Fontawsome icon name (can add stuff to it like fa-2x)
4691 * @cfg {Boolean} active Is item active
4692 * @cfg {Boolean} disabled Is item disabled
4694 * @cfg {Boolean} preventDefault (true | false) default false
4695 * @cfg {String} tabId the tab that this item activates.
4696 * @cfg {String} tagtype (a|span) render as a href or span?
4697 * @cfg {Boolean} animateRef (true|false) link to element default false
4700 * Create a new Navbar Item
4701 * @param {Object} config The config object
4703 Roo.bootstrap.NavItem = function(config){
4704 Roo.bootstrap.NavItem.superclass.constructor.call(this, config);
4709 * The raw click event for the entire grid.
4710 * @param {Roo.EventObject} e
4715 * Fires when the active item active state changes
4716 * @param {Roo.bootstrap.NavItem} this
4717 * @param {boolean} state the new state
4723 * Fires when scroll to element
4724 * @param {Roo.bootstrap.NavItem} this
4725 * @param {Object} options
4726 * @param {Roo.EventObject} e
4734 Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, {
4743 preventDefault : false,
4751 button_outline : false,
4755 getAutoCreate : function(){
4763 cfg.cls = typeof(cfg.cls) == 'undefined' ? 'active' : cfg.cls + ' active';
4765 if (this.disabled) {
4766 cfg.cls += ' disabled';
4770 if (this.button_weight.length) {
4771 cfg.tag = this.href ? 'a' : 'button';
4772 cfg.html = this.html || '';
4773 cfg.cls += ' btn btn' + (this.button_outline ? '-outline' : '') + '-' + this.button_weight;
4775 cfg.href = this.href;
4778 cfg.html = '<i class="fa fas fa-'+this.fa+'"></i> <span>' + this.html + '</span>';
4781 // menu .. should add dropdown-menu class - so no need for carat..
4783 if (this.badge !== '') {
4785 cfg.html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
4790 if (this.href || this.html || this.glyphicon || this.icon || this.fa) {
4794 href : this.href || "#",
4795 html: this.html || ''
4798 if (this.tagtype == 'a') {
4799 cfg.cn[0].cls = 'nav-link';
4802 cfg.cn[0].html = '<i class="'+this.icon+'"></i> <span>' + cfg.cn[0].html + '</span>';
4805 cfg.cn[0].html = '<i class="fa fas fa-'+this.fa+'"></i> <span>' + cfg.cn[0].html + '</span>';
4807 if(this.glyphicon) {
4808 cfg.cn[0].html = '<span class="glyphicon glyphicon-' + this.glyphicon + '"></span> ' + cfg.cn[0].html;
4813 cfg.cn[0].html += " <span class='caret'></span>";
4817 if (this.badge !== '') {
4819 cfg.cn[0].html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
4827 onRender : function(ct, position)
4829 // Roo.log("Call onRender: " + this.xtype);
4830 if (Roo.bootstrap.version == 4 && ct.dom.type != 'ul') {
4834 var ret = Roo.bootstrap.NavItem.superclass.onRender.call(this, ct, position);
4835 this.navLink = this.el.select('.nav-link',true).first();
4840 initEvents: function()
4842 if (typeof (this.menu) != 'undefined') {
4843 this.menu.parentType = this.xtype;
4844 this.menu.triggerEl = this.el;
4845 this.menu = this.addxtype(Roo.apply({}, this.menu));
4848 this.el.select('a',true).on('click', this.onClick, this);
4850 if(this.tagtype == 'span'){
4851 this.el.select('span',true).on('click', this.onClick, this);
4854 // at this point parent should be available..
4855 this.parent().register(this);
4858 onClick : function(e)
4860 if (e.getTarget('.dropdown-menu-item')) {
4861 // did you click on a menu itemm.... - then don't trigger onclick..
4866 this.preventDefault ||
4869 Roo.log("NavItem - prevent Default?");
4873 if (this.disabled) {
4877 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4878 if (tg && tg.transition) {
4879 Roo.log("waiting for the transitionend");
4885 //Roo.log("fire event clicked");
4886 if(this.fireEvent('click', this, e) === false){
4890 if(this.tagtype == 'span'){
4894 //Roo.log(this.href);
4895 var ael = this.el.select('a',true).first();
4898 if(ael && this.animateRef && this.href.indexOf('#') > -1){
4899 //Roo.log(["test:",ael.dom.href.split("#")[0], document.location.toString().split("#")[0]]);
4900 if (ael.dom.href.split("#")[0] != document.location.toString().split("#")[0]) {
4901 return; // ignore... - it's a 'hash' to another page.
4903 Roo.log("NavItem - prevent Default?");
4905 this.scrollToElement(e);
4909 var p = this.parent();
4911 if (['tabs','pills'].indexOf(p.type)!==-1) {
4912 if (typeof(p.setActiveItem) !== 'undefined') {
4913 p.setActiveItem(this);
4917 // if parent is a navbarheader....- and link is probably a '#' page ref.. then remove the expanded menu.
4918 if (p.parentType == 'NavHeaderbar' && !this.menu) {
4919 // remove the collapsed menu expand...
4920 p.parent().el.select('.roo-navbar-collapse',true).removeClass('in');
4924 isActive: function () {
4927 setActive : function(state, fire, is_was_active)
4929 if (this.active && !state && this.navId) {
4930 this.was_active = true;
4931 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4933 nv.clearWasActive(this);
4937 this.active = state;
4940 this.el.removeClass('active');
4941 this.navLink ? this.navLink.removeClass('active') : false;
4942 } else if (!this.el.hasClass('active')) {
4944 this.el.addClass('active');
4945 if (Roo.bootstrap.version == 4 && this.navLink ) {
4946 this.navLink.addClass('active');
4951 this.fireEvent('changed', this, state);
4954 // show a panel if it's registered and related..
4956 if (!this.navId || !this.tabId || !state || is_was_active) {
4960 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4964 var pan = tg.getPanelByName(this.tabId);
4968 // if we can not flip to new panel - go back to old nav highlight..
4969 if (false == tg.showPanel(pan)) {
4970 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4972 var onav = nv.getWasActive();
4974 onav.setActive(true, false, true);
4983 // this should not be here...
4984 setDisabled : function(state)
4986 this.disabled = state;
4988 this.el.removeClass('disabled');
4989 } else if (!this.el.hasClass('disabled')) {
4990 this.el.addClass('disabled');
4996 * Fetch the element to display the tooltip on.
4997 * @return {Roo.Element} defaults to this.el
4999 tooltipEl : function()
5001 return this.el.select('' + this.tagtype + '', true).first();
5004 scrollToElement : function(e)
5006 var c = document.body;
5009 * Firefox / IE places the overflow at the html level, unless specifically styled to behave differently.
5011 if(Roo.isFirefox || Roo.isIE || Roo.isIE11){
5012 c = document.documentElement;
5015 var target = Roo.get(c).select('a[name=' + this.href.split('#')[1] +']', true).first();
5021 var o = target.calcOffsetsTo(c);
5028 this.fireEvent('scrollto', this, options, e);
5030 Roo.get(c).scrollTo('top', options.value, true);
5043 * <span> icon </span>
5044 * <span> text </span>
5045 * <span>badge </span>
5049 * @class Roo.bootstrap.NavSidebarItem
5050 * @extends Roo.bootstrap.NavItem
5051 * Bootstrap Navbar.NavSidebarItem class
5052 * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
5053 * {Boolean} open is the menu open
5054 * {Boolean} buttonView use button as the tigger el rather that a (default false)
5055 * {String} buttonWeight (default|primary|success|info|warning|danger)the extra classes for the button
5056 * {String} buttonSize (sm|md|lg)the extra classes for the button
5057 * {Boolean} showArrow show arrow next to the text (default true)
5059 * Create a new Navbar Button
5060 * @param {Object} config The config object
5062 Roo.bootstrap.NavSidebarItem = function(config){
5063 Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this, config);
5068 * The raw click event for the entire grid.
5069 * @param {Roo.EventObject} e
5074 * Fires when the active item active state changes
5075 * @param {Roo.bootstrap.NavSidebarItem} this
5076 * @param {boolean} state the new state
5084 Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem, {
5086 badgeWeight : 'default',
5092 buttonWeight : 'default',
5098 getAutoCreate : function(){
5103 href : this.href || '#',
5109 if(this.buttonView){
5112 href : this.href || '#',
5113 cls: 'btn btn-' + this.buttonWeight + ' btn-' + this.buttonSize + 'roo-button-dropdown-toggle',
5126 cfg.cls += ' active';
5129 if (this.disabled) {
5130 cfg.cls += ' disabled';
5133 cfg.cls += ' open x-open';
5136 if (this.glyphicon || this.icon) {
5137 var c = this.glyphicon ? ('glyphicon glyphicon-'+this.glyphicon) : this.icon;
5138 a.cn.push({ tag : 'i', cls : c }) ;
5141 if(!this.buttonView){
5144 html : this.html || ''
5151 if (this.badge !== '') {
5152 a.cn.push({ tag: 'span', cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge });
5158 a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
5161 a.cls += ' dropdown-toggle treeview' ;
5167 initEvents : function()
5169 if (typeof (this.menu) != 'undefined') {
5170 this.menu.parentType = this.xtype;
5171 this.menu.triggerEl = this.el;
5172 this.menu = this.addxtype(Roo.apply({}, this.menu));
5175 this.el.on('click', this.onClick, this);
5177 if(this.badge !== ''){
5178 this.badgeEl = this.el.select('.badge', true).first().setVisibilityMode(Roo.Element.DISPLAY);
5183 onClick : function(e)
5190 if(this.preventDefault){
5194 this.fireEvent('click', this, e);
5197 disable : function()
5199 this.setDisabled(true);
5204 this.setDisabled(false);
5207 setDisabled : function(state)
5209 if(this.disabled == state){
5213 this.disabled = state;
5216 this.el.addClass('disabled');
5220 this.el.removeClass('disabled');
5225 setActive : function(state)
5227 if(this.active == state){
5231 this.active = state;
5234 this.el.addClass('active');
5238 this.el.removeClass('active');
5243 isActive: function ()
5248 setBadge : function(str)
5254 this.badgeEl.dom.innerHTML = str;
5271 * @class Roo.bootstrap.Row
5272 * @extends Roo.bootstrap.Component
5273 * Bootstrap Row class (contains columns...)
5277 * @param {Object} config The config object
5280 Roo.bootstrap.Row = function(config){
5281 Roo.bootstrap.Row.superclass.constructor.call(this, config);
5284 Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component, {
5286 getAutoCreate : function(){
5305 * @class Roo.bootstrap.Element
5306 * @extends Roo.bootstrap.Component
5307 * Bootstrap Element class
5308 * @cfg {String} html contents of the element
5309 * @cfg {String} tag tag of the element
5310 * @cfg {String} cls class of the element
5311 * @cfg {Boolean} preventDefault (true|false) default false
5312 * @cfg {Boolean} clickable (true|false) default false
5315 * Create a new Element
5316 * @param {Object} config The config object
5319 Roo.bootstrap.Element = function(config){
5320 Roo.bootstrap.Element.superclass.constructor.call(this, config);
5326 * When a element is chick
5327 * @param {Roo.bootstrap.Element} this
5328 * @param {Roo.EventObject} e
5334 Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, {
5339 preventDefault: false,
5342 getAutoCreate : function(){
5346 // cls: this.cls, double assign in parent class Component.js :: onRender
5353 initEvents: function()
5355 Roo.bootstrap.Element.superclass.initEvents.call(this);
5358 this.el.on('click', this.onClick, this);
5363 onClick : function(e)
5365 if(this.preventDefault){
5369 this.fireEvent('click', this, e);
5372 getValue : function()
5374 return this.el.dom.innerHTML;
5377 setValue : function(value)
5379 this.el.dom.innerHTML = value;
5394 * @class Roo.bootstrap.Pagination
5395 * @extends Roo.bootstrap.Component
5396 * Bootstrap Pagination class
5397 * @cfg {String} size xs | sm | md | lg
5398 * @cfg {Boolean} inverse false | true
5401 * Create a new Pagination
5402 * @param {Object} config The config object
5405 Roo.bootstrap.Pagination = function(config){
5406 Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
5409 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component, {
5415 getAutoCreate : function(){
5421 cfg.cls += ' inverse';
5427 cfg.cls += " " + this.cls;
5445 * @class Roo.bootstrap.PaginationItem
5446 * @extends Roo.bootstrap.Component
5447 * Bootstrap PaginationItem class
5448 * @cfg {String} html text
5449 * @cfg {String} href the link
5450 * @cfg {Boolean} preventDefault (true | false) default true
5451 * @cfg {Boolean} active (true | false) default false
5452 * @cfg {Boolean} disabled default false
5456 * Create a new PaginationItem
5457 * @param {Object} config The config object
5461 Roo.bootstrap.PaginationItem = function(config){
5462 Roo.bootstrap.PaginationItem.superclass.constructor.call(this, config);
5467 * The raw click event for the entire grid.
5468 * @param {Roo.EventObject} e
5474 Roo.extend(Roo.bootstrap.PaginationItem, Roo.bootstrap.Component, {
5478 preventDefault: true,
5483 getAutoCreate : function(){
5489 href : this.href ? this.href : '#',
5490 html : this.html ? this.html : ''
5500 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' disabled' : 'disabled';
5504 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' active' : 'active';
5510 initEvents: function() {
5512 this.el.on('click', this.onClick, this);
5515 onClick : function(e)
5517 Roo.log('PaginationItem on click ');
5518 if(this.preventDefault){
5526 this.fireEvent('click', this, e);
5542 * @class Roo.bootstrap.Slider
5543 * @extends Roo.bootstrap.Component
5544 * Bootstrap Slider class
5547 * Create a new Slider
5548 * @param {Object} config The config object
5551 Roo.bootstrap.Slider = function(config){
5552 Roo.bootstrap.Slider.superclass.constructor.call(this, config);
5555 Roo.extend(Roo.bootstrap.Slider, Roo.bootstrap.Component, {
5557 getAutoCreate : function(){
5561 cls: 'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',
5565 cls: 'ui-slider-handle ui-state-default ui-corner-all'
5577 * Ext JS Library 1.1.1
5578 * Copyright(c) 2006-2007, Ext JS, LLC.
5580 * Originally Released Under LGPL - original licence link has changed is not relivant.
5583 * <script type="text/javascript">
5588 * @class Roo.grid.ColumnModel
5589 * @extends Roo.util.Observable
5590 * This is the default implementation of a ColumnModel used by the Grid. It defines
5591 * the columns in the grid.
5594 var colModel = new Roo.grid.ColumnModel([
5595 {header: "Ticker", width: 60, sortable: true, locked: true},
5596 {header: "Company Name", width: 150, sortable: true},
5597 {header: "Market Cap.", width: 100, sortable: true},
5598 {header: "$ Sales", width: 100, sortable: true, renderer: money},
5599 {header: "Employees", width: 100, sortable: true, resizable: false}
5604 * The config options listed for this class are options which may appear in each
5605 * individual column definition.
5606 * <br/>RooJS Fix - column id's are not sequential but use Roo.id() - fixes bugs with layouts.
5608 * @param {Object} config An Array of column config objects. See this class's
5609 * config objects for details.
5611 Roo.grid.ColumnModel = function(config){
5613 * The config passed into the constructor
5615 this.config = config;
5618 // if no id, create one
5619 // if the column does not have a dataIndex mapping,
5620 // map it to the order it is in the config
5621 for(var i = 0, len = config.length; i < len; i++){
5623 if(typeof c.dataIndex == "undefined"){
5626 if(typeof c.renderer == "string"){
5627 c.renderer = Roo.util.Format[c.renderer];
5629 if(typeof c.id == "undefined"){
5632 if(c.editor && c.editor.xtype){
5633 c.editor = Roo.factory(c.editor, Roo.grid);
5635 if(c.editor && c.editor.isFormField){
5636 c.editor = new Roo.grid.GridEditor(c.editor);
5638 this.lookup[c.id] = c;
5642 * The width of columns which have no width specified (defaults to 100)
5645 this.defaultWidth = 100;
5648 * Default sortable of columns which have no sortable specified (defaults to false)
5651 this.defaultSortable = false;
5655 * @event widthchange
5656 * Fires when the width of a column changes.
5657 * @param {ColumnModel} this
5658 * @param {Number} columnIndex The column index
5659 * @param {Number} newWidth The new width
5661 "widthchange": true,
5663 * @event headerchange
5664 * Fires when the text of a header changes.
5665 * @param {ColumnModel} this
5666 * @param {Number} columnIndex The column index
5667 * @param {Number} newText The new header text
5669 "headerchange": true,
5671 * @event hiddenchange
5672 * Fires when a column is hidden or "unhidden".
5673 * @param {ColumnModel} this
5674 * @param {Number} columnIndex The column index
5675 * @param {Boolean} hidden true if hidden, false otherwise
5677 "hiddenchange": true,
5679 * @event columnmoved
5680 * Fires when a column is moved.
5681 * @param {ColumnModel} this
5682 * @param {Number} oldIndex
5683 * @param {Number} newIndex
5685 "columnmoved" : true,
5687 * @event columlockchange
5688 * Fires when a column's locked state is changed
5689 * @param {ColumnModel} this
5690 * @param {Number} colIndex
5691 * @param {Boolean} locked true if locked
5693 "columnlockchange" : true
5695 Roo.grid.ColumnModel.superclass.constructor.call(this);
5697 Roo.extend(Roo.grid.ColumnModel, Roo.util.Observable, {
5699 * @cfg {String} header The header text to display in the Grid view.
5702 * @cfg {String} dataIndex (Optional) The name of the field in the grid's {@link Roo.data.Store}'s
5703 * {@link Roo.data.Record} definition from which to draw the column's value. If not
5704 * specified, the column's index is used as an index into the Record's data Array.
5707 * @cfg {Number} width (Optional) The initial width in pixels of the column. Using this
5708 * instead of {@link Roo.grid.Grid#autoSizeColumns} is more efficient.
5711 * @cfg {Boolean} sortable (Optional) True if sorting is to be allowed on this column.
5712 * Defaults to the value of the {@link #defaultSortable} property.
5713 * Whether local/remote sorting is used is specified in {@link Roo.data.Store#remoteSort}.
5716 * @cfg {Boolean} locked (Optional) True to lock the column in place while scrolling the Grid. Defaults to false.
5719 * @cfg {Boolean} fixed (Optional) True if the column width cannot be changed. Defaults to false.
5722 * @cfg {Boolean} resizable (Optional) False to disable column resizing. Defaults to true.
5725 * @cfg {Boolean} hidden (Optional) True to hide the column. Defaults to false.
5728 * @cfg {Function} renderer (Optional) A function used to generate HTML markup for a cell
5729 * given the cell's data value. See {@link #setRenderer}. If not specified, the
5730 * default renderer returns the escaped data value. If an object is returned (bootstrap only)
5731 * then it is treated as a Roo Component object instance, and it is rendered after the initial row is rendered
5734 * @cfg {Roo.grid.GridEditor} editor (Optional) For grid editors - returns the grid editor
5737 * @cfg {String} align (Optional) Set the CSS text-align property of the column. Defaults to undefined.
5740 * @cfg {String} valign (Optional) Set the CSS vertical-align property of the column (eg. middle, top, bottom etc). Defaults to undefined.
5743 * @cfg {String} cursor (Optional)
5746 * @cfg {String} tooltip (Optional)
5749 * @cfg {Number} xs (Optional)
5752 * @cfg {Number} sm (Optional)
5755 * @cfg {Number} md (Optional)
5758 * @cfg {Number} lg (Optional)
5761 * Returns the id of the column at the specified index.
5762 * @param {Number} index The column index
5763 * @return {String} the id
5765 getColumnId : function(index){
5766 return this.config[index].id;
5770 * Returns the column for a specified id.
5771 * @param {String} id The column id
5772 * @return {Object} the column
5774 getColumnById : function(id){
5775 return this.lookup[id];
5780 * Returns the column for a specified dataIndex.
5781 * @param {String} dataIndex The column dataIndex
5782 * @return {Object|Boolean} the column or false if not found
5784 getColumnByDataIndex: function(dataIndex){
5785 var index = this.findColumnIndex(dataIndex);
5786 return index > -1 ? this.config[index] : false;
5790 * Returns the index for a specified column id.
5791 * @param {String} id The column id
5792 * @return {Number} the index, or -1 if not found
5794 getIndexById : function(id){
5795 for(var i = 0, len = this.config.length; i < len; i++){
5796 if(this.config[i].id == id){
5804 * Returns the index for a specified column dataIndex.
5805 * @param {String} dataIndex The column dataIndex
5806 * @return {Number} the index, or -1 if not found
5809 findColumnIndex : function(dataIndex){
5810 for(var i = 0, len = this.config.length; i < len; i++){
5811 if(this.config[i].dataIndex == dataIndex){
5819 moveColumn : function(oldIndex, newIndex){
5820 var c = this.config[oldIndex];
5821 this.config.splice(oldIndex, 1);
5822 this.config.splice(newIndex, 0, c);
5823 this.dataMap = null;
5824 this.fireEvent("columnmoved", this, oldIndex, newIndex);
5827 isLocked : function(colIndex){
5828 return this.config[colIndex].locked === true;
5831 setLocked : function(colIndex, value, suppressEvent){
5832 if(this.isLocked(colIndex) == value){
5835 this.config[colIndex].locked = value;
5837 this.fireEvent("columnlockchange", this, colIndex, value);
5841 getTotalLockedWidth : function(){
5843 for(var i = 0; i < this.config.length; i++){
5844 if(this.isLocked(i) && !this.isHidden(i)){
5845 this.totalWidth += this.getColumnWidth(i);
5851 getLockedCount : function(){
5852 for(var i = 0, len = this.config.length; i < len; i++){
5853 if(!this.isLocked(i)){
5858 return this.config.length;
5862 * Returns the number of columns.
5865 getColumnCount : function(visibleOnly){
5866 if(visibleOnly === true){
5868 for(var i = 0, len = this.config.length; i < len; i++){
5869 if(!this.isHidden(i)){
5875 return this.config.length;
5879 * Returns the column configs that return true by the passed function that is called with (columnConfig, index)
5880 * @param {Function} fn
5881 * @param {Object} scope (optional)
5882 * @return {Array} result
5884 getColumnsBy : function(fn, scope){
5886 for(var i = 0, len = this.config.length; i < len; i++){
5887 var c = this.config[i];
5888 if(fn.call(scope||this, c, i) === true){
5896 * Returns true if the specified column is sortable.
5897 * @param {Number} col The column index
5900 isSortable : function(col){
5901 if(typeof this.config[col].sortable == "undefined"){
5902 return this.defaultSortable;
5904 return this.config[col].sortable;
5908 * Returns the rendering (formatting) function defined for the column.
5909 * @param {Number} col The column index.
5910 * @return {Function} The function used to render the cell. See {@link #setRenderer}.
5912 getRenderer : function(col){
5913 if(!this.config[col].renderer){
5914 return Roo.grid.ColumnModel.defaultRenderer;
5916 return this.config[col].renderer;
5920 * Sets the rendering (formatting) function for a column.
5921 * @param {Number} col The column index
5922 * @param {Function} fn The function to use to process the cell's raw data
5923 * to return HTML markup for the grid view. The render function is called with
5924 * the following parameters:<ul>
5925 * <li>Data value.</li>
5926 * <li>Cell metadata. An object in which you may set the following attributes:<ul>
5927 * <li>css A CSS style string to apply to the table cell.</li>
5928 * <li>attr An HTML attribute definition string to apply to the data container element <i>within</i> the table cell.</li></ul>
5929 * <li>The {@link Roo.data.Record} from which the data was extracted.</li>
5930 * <li>Row index</li>
5931 * <li>Column index</li>
5932 * <li>The {@link Roo.data.Store} object from which the Record was extracted</li></ul>
5934 setRenderer : function(col, fn){
5935 this.config[col].renderer = fn;
5939 * Returns the width for the specified column.
5940 * @param {Number} col The column index
5943 getColumnWidth : function(col){
5944 return this.config[col].width * 1 || this.defaultWidth;
5948 * Sets the width for a column.
5949 * @param {Number} col The column index
5950 * @param {Number} width The new width
5952 setColumnWidth : function(col, width, suppressEvent){
5953 this.config[col].width = width;
5954 this.totalWidth = null;
5956 this.fireEvent("widthchange", this, col, width);
5961 * Returns the total width of all columns.
5962 * @param {Boolean} includeHidden True to include hidden column widths
5965 getTotalWidth : function(includeHidden){
5966 if(!this.totalWidth){
5967 this.totalWidth = 0;
5968 for(var i = 0, len = this.config.length; i < len; i++){
5969 if(includeHidden || !this.isHidden(i)){
5970 this.totalWidth += this.getColumnWidth(i);
5974 return this.totalWidth;
5978 * Returns the header for the specified column.
5979 * @param {Number} col The column index
5982 getColumnHeader : function(col){
5983 return this.config[col].header;
5987 * Sets the header for a column.
5988 * @param {Number} col The column index
5989 * @param {String} header The new header
5991 setColumnHeader : function(col, header){
5992 this.config[col].header = header;
5993 this.fireEvent("headerchange", this, col, header);
5997 * Returns the tooltip for the specified column.
5998 * @param {Number} col The column index
6001 getColumnTooltip : function(col){
6002 return this.config[col].tooltip;
6005 * Sets the tooltip for a column.
6006 * @param {Number} col The column index
6007 * @param {String} tooltip The new tooltip
6009 setColumnTooltip : function(col, tooltip){
6010 this.config[col].tooltip = tooltip;
6014 * Returns the dataIndex for the specified column.
6015 * @param {Number} col The column index
6018 getDataIndex : function(col){
6019 return this.config[col].dataIndex;
6023 * Sets the dataIndex for a column.
6024 * @param {Number} col The column index
6025 * @param {Number} dataIndex The new dataIndex
6027 setDataIndex : function(col, dataIndex){
6028 this.config[col].dataIndex = dataIndex;
6034 * Returns true if the cell is editable.
6035 * @param {Number} colIndex The column index
6036 * @param {Number} rowIndex The row index - this is nto actually used..?
6039 isCellEditable : function(colIndex, rowIndex){
6040 return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
6044 * Returns the editor defined for the cell/column.
6045 * return false or null to disable editing.
6046 * @param {Number} colIndex The column index
6047 * @param {Number} rowIndex The row index
6050 getCellEditor : function(colIndex, rowIndex){
6051 return this.config[colIndex].editor;
6055 * Sets if a column is editable.
6056 * @param {Number} col The column index
6057 * @param {Boolean} editable True if the column is editable
6059 setEditable : function(col, editable){
6060 this.config[col].editable = editable;
6065 * Returns true if the column is hidden.
6066 * @param {Number} colIndex The column index
6069 isHidden : function(colIndex){
6070 return this.config[colIndex].hidden;
6075 * Returns true if the column width cannot be changed
6077 isFixed : function(colIndex){
6078 return this.config[colIndex].fixed;
6082 * Returns true if the column can be resized
6085 isResizable : function(colIndex){
6086 return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
6089 * Sets if a column is hidden.
6090 * @param {Number} colIndex The column index
6091 * @param {Boolean} hidden True if the column is hidden
6093 setHidden : function(colIndex, hidden){
6094 this.config[colIndex].hidden = hidden;
6095 this.totalWidth = null;
6096 this.fireEvent("hiddenchange", this, colIndex, hidden);
6100 * Sets the editor for a column.
6101 * @param {Number} col The column index
6102 * @param {Object} editor The editor object
6104 setEditor : function(col, editor){
6105 this.config[col].editor = editor;
6109 Roo.grid.ColumnModel.defaultRenderer = function(value)
6111 if(typeof value == "object") {
6114 if(typeof value == "string" && value.length < 1){
6118 return String.format("{0}", value);
6121 // Alias for backwards compatibility
6122 Roo.grid.DefaultColumnModel = Roo.grid.ColumnModel;
6125 * Ext JS Library 1.1.1
6126 * Copyright(c) 2006-2007, Ext JS, LLC.
6128 * Originally Released Under LGPL - original licence link has changed is not relivant.
6131 * <script type="text/javascript">
6135 * @class Roo.LoadMask
6136 * A simple utility class for generically masking elements while loading data. If the element being masked has
6137 * an underlying {@link Roo.data.Store}, the masking will be automatically synchronized with the store's loading
6138 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
6139 * element's UpdateManager load indicator and will be destroyed after the initial load.
6141 * Create a new LoadMask
6142 * @param {String/HTMLElement/Roo.Element} el The element or DOM node, or its id
6143 * @param {Object} config The config object
6145 Roo.LoadMask = function(el, config){
6146 this.el = Roo.get(el);
6147 Roo.apply(this, config);
6149 this.store.on('beforeload', this.onBeforeLoad, this);
6150 this.store.on('load', this.onLoad, this);
6151 this.store.on('loadexception', this.onLoadException, this);
6152 this.removeMask = false;
6154 var um = this.el.getUpdateManager();
6155 um.showLoadIndicator = false; // disable the default indicator
6156 um.on('beforeupdate', this.onBeforeLoad, this);
6157 um.on('update', this.onLoad, this);
6158 um.on('failure', this.onLoad, this);
6159 this.removeMask = true;
6163 Roo.LoadMask.prototype = {
6165 * @cfg {Boolean} removeMask
6166 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
6167 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
6171 * The text to display in a centered loading message box (defaults to 'Loading...')
6175 * @cfg {String} msgCls
6176 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
6178 msgCls : 'x-mask-loading',
6181 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
6187 * Disables the mask to prevent it from being displayed
6189 disable : function(){
6190 this.disabled = true;
6194 * Enables the mask so that it can be displayed
6196 enable : function(){
6197 this.disabled = false;
6200 onLoadException : function()
6204 if (typeof(arguments[3]) != 'undefined') {
6205 Roo.MessageBox.alert("Error loading",arguments[3]);
6209 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
6210 Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
6217 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
6222 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
6226 onBeforeLoad : function(){
6228 (function() { this.el.mask(this.msg, this.msgCls); }).defer(50, this);
6233 destroy : function(){
6235 this.store.un('beforeload', this.onBeforeLoad, this);
6236 this.store.un('load', this.onLoad, this);
6237 this.store.un('loadexception', this.onLoadException, this);
6239 var um = this.el.getUpdateManager();
6240 um.un('beforeupdate', this.onBeforeLoad, this);
6241 um.un('update', this.onLoad, this);
6242 um.un('failure', this.onLoad, this);
6253 * @class Roo.bootstrap.Table
6254 * @extends Roo.bootstrap.Component
6255 * Bootstrap Table class
6256 * @cfg {String} cls table class
6257 * @cfg {String} align (left|center|right) Specifies the alignment of a table according to surrounding text
6258 * @cfg {String} bgcolor Specifies the background color for a table
6259 * @cfg {Number} border Specifies whether the table cells should have borders or not
6260 * @cfg {Number} cellpadding Specifies the space between the cell wall and the cell content
6261 * @cfg {Number} cellspacing Specifies the space between cells
6262 * @cfg {String} frame Specifies which parts of the outside borders that should be visible
6263 * @cfg {String} rules Specifies which parts of the inside borders that should be visible
6264 * @cfg {String} sortable Specifies that the table should be sortable
6265 * @cfg {String} summary Specifies a summary of the content of a table
6266 * @cfg {Number} width Specifies the width of a table
6267 * @cfg {String} layout table layout (auto | fixed | initial | inherit)
6269 * @cfg {boolean} striped Should the rows be alternative striped
6270 * @cfg {boolean} bordered Add borders to the table
6271 * @cfg {boolean} hover Add hover highlighting
6272 * @cfg {boolean} condensed Format condensed
6273 * @cfg {boolean} responsive Format condensed
6274 * @cfg {Boolean} loadMask (true|false) default false
6275 * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
6276 * @cfg {Boolean} headerShow (true|false) generate thead, default true
6277 * @cfg {Boolean} rowSelection (true|false) default false
6278 * @cfg {Boolean} cellSelection (true|false) default false
6279 * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header
6280 * @cfg {Roo.bootstrap.PagingToolbar} footer a paging toolbar
6281 * @cfg {Boolean} lazyLoad auto load data while scrolling to the end (default false)
6282 * @cfg {Boolean} auto_hide_footer auto hide footer if only one page (default false)
6286 * Create a new Table
6287 * @param {Object} config The config object
6290 Roo.bootstrap.Table = function(config){
6291 Roo.bootstrap.Table.superclass.constructor.call(this, config);
6296 this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
6297 this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
6298 this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
6299 this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
6301 this.sm = this.sm || {xtype: 'RowSelectionModel'};
6303 this.sm.grid = this;
6304 this.selModel = Roo.factory(this.sm, Roo.bootstrap.Table);
6305 this.sm = this.selModel;
6306 this.sm.xmodule = this.xmodule || false;
6309 if (this.cm && typeof(this.cm.config) == 'undefined') {
6310 this.colModel = new Roo.grid.ColumnModel(this.cm);
6311 this.cm = this.colModel;
6312 this.cm.xmodule = this.xmodule || false;
6315 this.store= Roo.factory(this.store, Roo.data);
6316 this.ds = this.store;
6317 this.ds.xmodule = this.xmodule || false;
6320 if (this.footer && this.store) {
6321 this.footer.dataSource = this.ds;
6322 this.footer = Roo.factory(this.footer);
6329 * Fires when a cell is clicked
6330 * @param {Roo.bootstrap.Table} this
6331 * @param {Roo.Element} el
6332 * @param {Number} rowIndex
6333 * @param {Number} columnIndex
6334 * @param {Roo.EventObject} e
6338 * @event celldblclick
6339 * Fires when a cell is double clicked
6340 * @param {Roo.bootstrap.Table} this
6341 * @param {Roo.Element} el
6342 * @param {Number} rowIndex
6343 * @param {Number} columnIndex
6344 * @param {Roo.EventObject} e
6346 "celldblclick" : true,
6349 * Fires when a row is clicked
6350 * @param {Roo.bootstrap.Table} this
6351 * @param {Roo.Element} el
6352 * @param {Number} rowIndex
6353 * @param {Roo.EventObject} e
6357 * @event rowdblclick
6358 * Fires when a row is double clicked
6359 * @param {Roo.bootstrap.Table} this
6360 * @param {Roo.Element} el
6361 * @param {Number} rowIndex
6362 * @param {Roo.EventObject} e
6364 "rowdblclick" : true,
6367 * Fires when a mouseover occur
6368 * @param {Roo.bootstrap.Table} this
6369 * @param {Roo.Element} el
6370 * @param {Number} rowIndex
6371 * @param {Number} columnIndex
6372 * @param {Roo.EventObject} e
6377 * Fires when a mouseout occur
6378 * @param {Roo.bootstrap.Table} this
6379 * @param {Roo.Element} el
6380 * @param {Number} rowIndex
6381 * @param {Number} columnIndex
6382 * @param {Roo.EventObject} e
6387 * Fires when a row is rendered, so you can change add a style to it.
6388 * @param {Roo.bootstrap.Table} this
6389 * @param {Object} rowcfg contains record rowIndex colIndex and rowClass - set rowClass to add a style.
6393 * @event rowsrendered
6394 * Fires when all the rows have been rendered
6395 * @param {Roo.bootstrap.Table} this
6397 'rowsrendered' : true,
6399 * @event contextmenu
6400 * The raw contextmenu event for the entire grid.
6401 * @param {Roo.EventObject} e
6403 "contextmenu" : true,
6405 * @event rowcontextmenu
6406 * Fires when a row is right clicked
6407 * @param {Roo.bootstrap.Table} this
6408 * @param {Number} rowIndex
6409 * @param {Roo.EventObject} e
6411 "rowcontextmenu" : true,
6413 * @event cellcontextmenu
6414 * Fires when a cell is right clicked
6415 * @param {Roo.bootstrap.Table} this
6416 * @param {Number} rowIndex
6417 * @param {Number} cellIndex
6418 * @param {Roo.EventObject} e
6420 "cellcontextmenu" : true,
6422 * @event headercontextmenu
6423 * Fires when a header is right clicked
6424 * @param {Roo.bootstrap.Table} this
6425 * @param {Number} columnIndex
6426 * @param {Roo.EventObject} e
6428 "headercontextmenu" : true
6432 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
6458 rowSelection : false,
6459 cellSelection : false,
6462 // Roo.Element - the tbody
6464 // Roo.Element - thead element
6467 container: false, // used by gridpanel...
6473 auto_hide_footer : false,
6475 getAutoCreate : function()
6477 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
6484 if (this.scrollBody) {
6485 cfg.cls += ' table-body-fixed';
6488 cfg.cls += ' table-striped';
6492 cfg.cls += ' table-hover';
6494 if (this.bordered) {
6495 cfg.cls += ' table-bordered';
6497 if (this.condensed) {
6498 cfg.cls += ' table-condensed';
6500 if (this.responsive) {
6501 cfg.cls += ' table-responsive';
6505 cfg.cls+= ' ' +this.cls;
6508 // this lot should be simplifed...
6521 ].forEach(function(k) {
6529 cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
6532 if(this.store || this.cm){
6533 if(this.headerShow){
6534 cfg.cn.push(this.renderHeader());
6537 cfg.cn.push(this.renderBody());
6539 if(this.footerShow){
6540 cfg.cn.push(this.renderFooter());
6542 // where does this come from?
6543 //cfg.cls+= ' TableGrid';
6546 return { cn : [ cfg ] };
6549 initEvents : function()
6551 if(!this.store || !this.cm){
6554 if (this.selModel) {
6555 this.selModel.initEvents();
6559 //Roo.log('initEvents with ds!!!!');
6561 this.mainBody = this.el.select('tbody', true).first();
6562 this.mainHead = this.el.select('thead', true).first();
6563 this.mainFoot = this.el.select('tfoot', true).first();
6569 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6570 e.on('click', _this.sort, _this);
6573 this.mainBody.on("click", this.onClick, this);
6574 this.mainBody.on("dblclick", this.onDblClick, this);
6576 // why is this done????? = it breaks dialogs??
6577 //this.parent().el.setStyle('position', 'relative');
6581 this.footer.parentId = this.id;
6582 this.footer.onRender(this.el.select('tfoot tr td').first(), null);
6585 this.el.select('tfoot tr td').first().addClass('hide');
6590 this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
6593 this.store.on('load', this.onLoad, this);
6594 this.store.on('beforeload', this.onBeforeLoad, this);
6595 this.store.on('update', this.onUpdate, this);
6596 this.store.on('add', this.onAdd, this);
6597 this.store.on("clear", this.clear, this);
6599 this.el.on("contextmenu", this.onContextMenu, this);
6601 this.mainBody.on('scroll', this.onBodyScroll, this);
6603 this.cm.on("headerchange", this.onHeaderChange, this);
6605 this.cm.on("hiddenchange", this.onHiddenChange, this, arguments);
6609 onContextMenu : function(e, t)
6611 this.processEvent("contextmenu", e);
6614 processEvent : function(name, e)
6616 if (name != 'touchstart' ) {
6617 this.fireEvent(name, e);
6620 var t = e.getTarget();
6622 var cell = Roo.get(t);
6628 if(cell.findParent('tfoot', false, true)){
6632 if(cell.findParent('thead', false, true)){
6634 if(e.getTarget().nodeName.toLowerCase() != 'th'){
6635 cell = Roo.get(t).findParent('th', false, true);
6637 Roo.log("failed to find th in thead?");
6638 Roo.log(e.getTarget());
6643 var cellIndex = cell.dom.cellIndex;
6645 var ename = name == 'touchstart' ? 'click' : name;
6646 this.fireEvent("header" + ename, this, cellIndex, e);
6651 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6652 cell = Roo.get(t).findParent('td', false, true);
6654 Roo.log("failed to find th in tbody?");
6655 Roo.log(e.getTarget());
6660 var row = cell.findParent('tr', false, true);
6661 var cellIndex = cell.dom.cellIndex;
6662 var rowIndex = row.dom.rowIndex - 1;
6666 this.fireEvent("row" + name, this, rowIndex, e);
6670 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
6676 onMouseover : function(e, el)
6678 var cell = Roo.get(el);
6684 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6685 cell = cell.findParent('td', false, true);
6688 var row = cell.findParent('tr', false, true);
6689 var cellIndex = cell.dom.cellIndex;
6690 var rowIndex = row.dom.rowIndex - 1; // start from 0
6692 this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
6696 onMouseout : function(e, el)
6698 var cell = Roo.get(el);
6704 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6705 cell = cell.findParent('td', false, true);
6708 var row = cell.findParent('tr', false, true);
6709 var cellIndex = cell.dom.cellIndex;
6710 var rowIndex = row.dom.rowIndex - 1; // start from 0
6712 this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
6716 onClick : function(e, el)
6718 var cell = Roo.get(el);
6720 if(!cell || (!this.cellSelection && !this.rowSelection)){
6724 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6725 cell = cell.findParent('td', false, true);
6728 if(!cell || typeof(cell) == 'undefined'){
6732 var row = cell.findParent('tr', false, true);
6734 if(!row || typeof(row) == 'undefined'){
6738 var cellIndex = cell.dom.cellIndex;
6739 var rowIndex = this.getRowIndex(row);
6741 // why??? - should these not be based on SelectionModel?
6742 if(this.cellSelection){
6743 this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
6746 if(this.rowSelection){
6747 this.fireEvent('rowclick', this, row, rowIndex, e);
6753 onDblClick : function(e,el)
6755 var cell = Roo.get(el);
6757 if(!cell || (!this.cellSelection && !this.rowSelection)){
6761 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6762 cell = cell.findParent('td', false, true);
6765 if(!cell || typeof(cell) == 'undefined'){
6769 var row = cell.findParent('tr', false, true);
6771 if(!row || typeof(row) == 'undefined'){
6775 var cellIndex = cell.dom.cellIndex;
6776 var rowIndex = this.getRowIndex(row);
6778 if(this.cellSelection){
6779 this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
6782 if(this.rowSelection){
6783 this.fireEvent('rowdblclick', this, row, rowIndex, e);
6787 sort : function(e,el)
6789 var col = Roo.get(el);
6791 if(!col.hasClass('sortable')){
6795 var sort = col.attr('sort');
6798 if(col.select('i', true).first().hasClass('glyphicon-arrow-up')){
6802 this.store.sortInfo = {field : sort, direction : dir};
6805 Roo.log("calling footer first");
6806 this.footer.onClick('first');
6809 this.store.load({ params : { start : 0 } });
6813 renderHeader : function()
6821 this.totalWidth = 0;
6823 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
6825 var config = cm.config[i];
6829 cls : 'x-hcol-' + i,
6831 html: cm.getColumnHeader(i)
6836 if(typeof(config.sortable) != 'undefined' && config.sortable){
6838 c.html = '<i class="glyphicon"></i>' + c.html;
6841 // could use BS4 hidden-..-down
6843 if(typeof(config.lgHeader) != 'undefined'){
6844 hh += '<span class="hidden-xs hidden-sm hidden-md ">' + config.lgHeader + '</span>';
6847 if(typeof(config.mdHeader) != 'undefined'){
6848 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
6851 if(typeof(config.smHeader) != 'undefined'){
6852 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
6855 if(typeof(config.xsHeader) != 'undefined'){
6856 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
6863 if(typeof(config.tooltip) != 'undefined'){
6864 c.tooltip = config.tooltip;
6867 if(typeof(config.colspan) != 'undefined'){
6868 c.colspan = config.colspan;
6871 if(typeof(config.hidden) != 'undefined' && config.hidden){
6872 c.style += ' display:none;';
6875 if(typeof(config.dataIndex) != 'undefined'){
6876 c.sort = config.dataIndex;
6881 if(typeof(config.align) != 'undefined' && config.align.length){
6882 c.style += ' text-align:' + config.align + ';';
6885 if(typeof(config.width) != 'undefined'){
6886 c.style += ' width:' + config.width + 'px;';
6887 this.totalWidth += config.width;
6889 this.totalWidth += 100; // assume minimum of 100 per column?
6892 if(typeof(config.cls) != 'undefined'){
6893 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
6896 ['xs','sm','md','lg'].map(function(size){
6898 if(typeof(config[size]) == 'undefined'){
6902 if (!config[size]) { // 0 = hidden
6903 // BS 4 '0' is treated as hide that column and below.
6904 c.cls += ' hidden-' + size + ' hidden' + size + '-down';
6908 c.cls += ' col-' + size + '-' + config[size] + (
6909 size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
6921 renderBody : function()
6931 colspan : this.cm.getColumnCount()
6941 renderFooter : function()
6951 colspan : this.cm.getColumnCount()
6965 // Roo.log('ds onload');
6970 var ds = this.store;
6972 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6973 e.select('i', true).removeClass(['glyphicon-arrow-up', 'glyphicon-arrow-down']);
6974 if (_this.store.sortInfo) {
6976 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
6977 e.select('i', true).addClass(['glyphicon-arrow-up']);
6980 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
6981 e.select('i', true).addClass(['glyphicon-arrow-down']);
6986 var tbody = this.mainBody;
6988 if(ds.getCount() > 0){
6989 ds.data.each(function(d,rowIndex){
6990 var row = this.renderRow(cm, ds, rowIndex);
6992 tbody.createChild(row);
6996 if(row.cellObjects.length){
6997 Roo.each(row.cellObjects, function(r){
6998 _this.renderCellObject(r);
7005 var tfoot = this.el.select('tfoot', true).first();
7007 if(this.footerShow && this.auto_hide_footer && this.mainFoot){
7009 this.mainFoot.setVisibilityMode(Roo.Element.DISPLAY).hide();
7011 var total = this.ds.getTotalCount();
7013 if(this.footer.pageSize < total){
7014 this.mainFoot.show();
7018 Roo.each(this.el.select('tbody td', true).elements, function(e){
7019 e.on('mouseover', _this.onMouseover, _this);
7022 Roo.each(this.el.select('tbody td', true).elements, function(e){
7023 e.on('mouseout', _this.onMouseout, _this);
7025 this.fireEvent('rowsrendered', this);
7031 onUpdate : function(ds,record)
7033 this.refreshRow(record);
7037 onRemove : function(ds, record, index, isUpdate){
7038 if(isUpdate !== true){
7039 this.fireEvent("beforerowremoved", this, index, record);
7041 var bt = this.mainBody.dom;
7043 var rows = this.el.select('tbody > tr', true).elements;
7045 if(typeof(rows[index]) != 'undefined'){
7046 bt.removeChild(rows[index].dom);
7049 // if(bt.rows[index]){
7050 // bt.removeChild(bt.rows[index]);
7053 if(isUpdate !== true){
7054 //this.stripeRows(index);
7055 //this.syncRowHeights(index, index);
7057 this.fireEvent("rowremoved", this, index, record);
7061 onAdd : function(ds, records, rowIndex)
7063 //Roo.log('on Add called');
7064 // - note this does not handle multiple adding very well..
7065 var bt = this.mainBody.dom;
7066 for (var i =0 ; i < records.length;i++) {
7067 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
7068 //Roo.log(records[i]);
7069 //Roo.log(this.store.getAt(rowIndex+i));
7070 this.insertRow(this.store, rowIndex + i, false);
7077 refreshRow : function(record){
7078 var ds = this.store, index;
7079 if(typeof record == 'number'){
7081 record = ds.getAt(index);
7083 index = ds.indexOf(record);
7085 this.insertRow(ds, index, true);
7087 this.onRemove(ds, record, index+1, true);
7089 //this.syncRowHeights(index, index);
7091 this.fireEvent("rowupdated", this, index, record);
7094 insertRow : function(dm, rowIndex, isUpdate){
7097 this.fireEvent("beforerowsinserted", this, rowIndex);
7099 //var s = this.getScrollState();
7100 var row = this.renderRow(this.cm, this.store, rowIndex);
7101 // insert before rowIndex..
7102 var e = this.mainBody.createChild(row,this.getRowDom(rowIndex));
7106 if(row.cellObjects.length){
7107 Roo.each(row.cellObjects, function(r){
7108 _this.renderCellObject(r);
7113 this.fireEvent("rowsinserted", this, rowIndex);
7114 //this.syncRowHeights(firstRow, lastRow);
7115 //this.stripeRows(firstRow);
7122 getRowDom : function(rowIndex)
7124 var rows = this.el.select('tbody > tr', true).elements;
7126 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
7129 // returns the object tree for a tr..
7132 renderRow : function(cm, ds, rowIndex)
7134 var d = ds.getAt(rowIndex);
7138 cls : 'x-row-' + rowIndex,
7142 var cellObjects = [];
7144 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
7145 var config = cm.config[i];
7147 var renderer = cm.getRenderer(i);
7151 if(typeof(renderer) !== 'undefined'){
7152 value = renderer(d.data[cm.getDataIndex(i)], false, d);
7154 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
7155 // and are rendered into the cells after the row is rendered - using the id for the element.
7157 if(typeof(value) === 'object'){
7167 rowIndex : rowIndex,
7172 this.fireEvent('rowclass', this, rowcfg);
7176 cls : rowcfg.rowClass + ' x-col-' + i,
7178 html: (typeof(value) === 'object') ? '' : value
7185 if(typeof(config.colspan) != 'undefined'){
7186 td.colspan = config.colspan;
7189 if(typeof(config.hidden) != 'undefined' && config.hidden){
7190 td.style += ' display:none;';
7193 if(typeof(config.align) != 'undefined' && config.align.length){
7194 td.style += ' text-align:' + config.align + ';';
7196 if(typeof(config.valign) != 'undefined' && config.valign.length){
7197 td.style += ' vertical-align:' + config.valign + ';';
7200 if(typeof(config.width) != 'undefined'){
7201 td.style += ' width:' + config.width + 'px;';
7204 if(typeof(config.cursor) != 'undefined'){
7205 td.style += ' cursor:' + config.cursor + ';';
7208 if(typeof(config.cls) != 'undefined'){
7209 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
7212 ['xs','sm','md','lg'].map(function(size){
7214 if(typeof(config[size]) == 'undefined'){
7220 if (!config[size]) { // 0 = hidden
7221 // BS 4 '0' is treated as hide that column and below.
7222 td.cls += ' hidden-' + size + ' hidden' + size + '-down';
7226 td.cls += ' col-' + size + '-' + config[size] + (
7227 size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
7237 row.cellObjects = cellObjects;
7245 onBeforeLoad : function()
7254 this.el.select('tbody', true).first().dom.innerHTML = '';
7257 * Show or hide a row.
7258 * @param {Number} rowIndex to show or hide
7259 * @param {Boolean} state hide
7261 setRowVisibility : function(rowIndex, state)
7263 var bt = this.mainBody.dom;
7265 var rows = this.el.select('tbody > tr', true).elements;
7267 if(typeof(rows[rowIndex]) == 'undefined'){
7270 rows[rowIndex].dom.style.display = state ? '' : 'none';
7274 getSelectionModel : function(){
7276 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
7278 return this.selModel;
7281 * Render the Roo.bootstrap object from renderder
7283 renderCellObject : function(r)
7287 r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
7289 var t = r.cfg.render(r.container);
7292 Roo.each(r.cfg.cn, function(c){
7294 container: t.getChildContainer(),
7297 _this.renderCellObject(child);
7302 getRowIndex : function(row)
7306 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
7317 * Returns the grid's underlying element = used by panel.Grid
7318 * @return {Element} The element
7320 getGridEl : function(){
7324 * Forces a resize - used by panel.Grid
7325 * @return {Element} The element
7327 autoSize : function()
7329 //var ctr = Roo.get(this.container.dom.parentElement);
7330 var ctr = Roo.get(this.el.dom);
7332 var thd = this.getGridEl().select('thead',true).first();
7333 var tbd = this.getGridEl().select('tbody', true).first();
7334 var tfd = this.getGridEl().select('tfoot', true).first();
7336 var cw = ctr.getWidth();
7340 tbd.setSize(ctr.getWidth(),
7341 ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
7343 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
7346 cw = Math.max(cw, this.totalWidth);
7347 this.getGridEl().select('tr',true).setWidth(cw);
7348 // resize 'expandable coloumn?
7350 return; // we doe not have a view in this design..
7353 onBodyScroll: function()
7355 //Roo.log("body scrolled');" + this.mainBody.dom.scrollLeft);
7357 this.mainHead.setStyle({
7358 'position' : 'relative',
7359 'left': (-1* this.mainBody.dom.scrollLeft) + 'px'
7365 var scrollHeight = this.mainBody.dom.scrollHeight;
7367 var scrollTop = Math.ceil(this.mainBody.getScroll().top);
7369 var height = this.mainBody.getHeight();
7371 if(scrollHeight - height == scrollTop) {
7373 var total = this.ds.getTotalCount();
7375 if(this.footer.cursor + this.footer.pageSize < total){
7377 this.footer.ds.load({
7379 start : this.footer.cursor + this.footer.pageSize,
7380 limit : this.footer.pageSize
7390 onHeaderChange : function()
7392 var header = this.renderHeader();
7393 var table = this.el.select('table', true).first();
7395 this.mainHead.remove();
7396 this.mainHead = table.createChild(header, this.mainBody, false);
7399 onHiddenChange : function(colModel, colIndex, hidden)
7401 var thSelector = '#' + this.id + ' .x-hcol-' + colIndex;
7402 var tdSelector = '#' + this.id + ' .x-col-' + colIndex;
7404 this.CSS.updateRule(thSelector, "display", "");
7405 this.CSS.updateRule(tdSelector, "display", "");
7408 this.CSS.updateRule(thSelector, "display", "none");
7409 this.CSS.updateRule(tdSelector, "display", "none");
7412 this.onHeaderChange();
7416 setColumnWidth: function(col_index, width)
7418 // width = "md-2 xs-2..."
7419 if(!this.colModel.config[col_index]) {
7423 var w = width.split(" ");
7425 var rows = this.el.dom.getElementsByClassName("x-col-"+col_index);
7427 var h_row = this.el.dom.getElementsByClassName("x-hcol-"+col_index);
7430 for(var j = 0; j < w.length; j++) {
7436 var size_cls = w[j].split("-");
7438 if(!Number.isInteger(size_cls[1] * 1)) {
7442 if(!this.colModel.config[col_index][size_cls[0]]) {
7446 if(!h_row[0].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
7450 h_row[0].classList.replace(
7451 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
7452 "col-"+size_cls[0]+"-"+size_cls[1]
7455 for(var i = 0; i < rows.length; i++) {
7457 var size_cls = w[j].split("-");
7459 if(!Number.isInteger(size_cls[1] * 1)) {
7463 if(!this.colModel.config[col_index][size_cls[0]]) {
7467 if(!rows[i].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
7471 rows[i].classList.replace(
7472 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
7473 "col-"+size_cls[0]+"-"+size_cls[1]
7477 this.colModel.config[col_index][size_cls[0]] = size_cls[1];
7492 * @class Roo.bootstrap.TableCell
7493 * @extends Roo.bootstrap.Component
7494 * Bootstrap TableCell class
7495 * @cfg {String} html cell contain text
7496 * @cfg {String} cls cell class
7497 * @cfg {String} tag cell tag (td|th) default td
7498 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
7499 * @cfg {String} align Aligns the content in a cell
7500 * @cfg {String} axis Categorizes cells
7501 * @cfg {String} bgcolor Specifies the background color of a cell
7502 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7503 * @cfg {Number} colspan Specifies the number of columns a cell should span
7504 * @cfg {String} headers Specifies one or more header cells a cell is related to
7505 * @cfg {Number} height Sets the height of a cell
7506 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
7507 * @cfg {Number} rowspan Sets the number of rows a cell should span
7508 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
7509 * @cfg {String} valign Vertical aligns the content in a cell
7510 * @cfg {Number} width Specifies the width of a cell
7513 * Create a new TableCell
7514 * @param {Object} config The config object
7517 Roo.bootstrap.TableCell = function(config){
7518 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
7521 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
7541 getAutoCreate : function(){
7542 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
7562 cfg.align=this.align
7568 cfg.bgcolor=this.bgcolor
7571 cfg.charoff=this.charoff
7574 cfg.colspan=this.colspan
7577 cfg.headers=this.headers
7580 cfg.height=this.height
7583 cfg.nowrap=this.nowrap
7586 cfg.rowspan=this.rowspan
7589 cfg.scope=this.scope
7592 cfg.valign=this.valign
7595 cfg.width=this.width
7614 * @class Roo.bootstrap.TableRow
7615 * @extends Roo.bootstrap.Component
7616 * Bootstrap TableRow class
7617 * @cfg {String} cls row class
7618 * @cfg {String} align Aligns the content in a table row
7619 * @cfg {String} bgcolor Specifies a background color for a table row
7620 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7621 * @cfg {String} valign Vertical aligns the content in a table row
7624 * Create a new TableRow
7625 * @param {Object} config The config object
7628 Roo.bootstrap.TableRow = function(config){
7629 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
7632 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
7640 getAutoCreate : function(){
7641 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
7651 cfg.align = this.align;
7654 cfg.bgcolor = this.bgcolor;
7657 cfg.charoff = this.charoff;
7660 cfg.valign = this.valign;
7678 * @class Roo.bootstrap.TableBody
7679 * @extends Roo.bootstrap.Component
7680 * Bootstrap TableBody class
7681 * @cfg {String} cls element class
7682 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
7683 * @cfg {String} align Aligns the content inside the element
7684 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
7685 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
7688 * Create a new TableBody
7689 * @param {Object} config The config object
7692 Roo.bootstrap.TableBody = function(config){
7693 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
7696 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
7704 getAutoCreate : function(){
7705 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
7719 cfg.align = this.align;
7722 cfg.charoff = this.charoff;
7725 cfg.valign = this.valign;
7732 // initEvents : function()
7739 // this.store = Roo.factory(this.store, Roo.data);
7740 // this.store.on('load', this.onLoad, this);
7742 // this.store.load();
7746 // onLoad: function ()
7748 // this.fireEvent('load', this);
7758 * Ext JS Library 1.1.1
7759 * Copyright(c) 2006-2007, Ext JS, LLC.
7761 * Originally Released Under LGPL - original licence link has changed is not relivant.
7764 * <script type="text/javascript">
7767 // as we use this in bootstrap.
7768 Roo.namespace('Roo.form');
7770 * @class Roo.form.Action
7771 * Internal Class used to handle form actions
7773 * @param {Roo.form.BasicForm} el The form element or its id
7774 * @param {Object} config Configuration options
7779 // define the action interface
7780 Roo.form.Action = function(form, options){
7782 this.options = options || {};
7785 * Client Validation Failed
7788 Roo.form.Action.CLIENT_INVALID = 'client';
7790 * Server Validation Failed
7793 Roo.form.Action.SERVER_INVALID = 'server';
7795 * Connect to Server Failed
7798 Roo.form.Action.CONNECT_FAILURE = 'connect';
7800 * Reading Data from Server Failed
7803 Roo.form.Action.LOAD_FAILURE = 'load';
7805 Roo.form.Action.prototype = {
7807 failureType : undefined,
7808 response : undefined,
7812 run : function(options){
7817 success : function(response){
7822 handleResponse : function(response){
7826 // default connection failure
7827 failure : function(response){
7829 this.response = response;
7830 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7831 this.form.afterAction(this, false);
7834 processResponse : function(response){
7835 this.response = response;
7836 if(!response.responseText){
7839 this.result = this.handleResponse(response);
7843 // utility functions used internally
7844 getUrl : function(appendParams){
7845 var url = this.options.url || this.form.url || this.form.el.dom.action;
7847 var p = this.getParams();
7849 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
7855 getMethod : function(){
7856 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
7859 getParams : function(){
7860 var bp = this.form.baseParams;
7861 var p = this.options.params;
7863 if(typeof p == "object"){
7864 p = Roo.urlEncode(Roo.applyIf(p, bp));
7865 }else if(typeof p == 'string' && bp){
7866 p += '&' + Roo.urlEncode(bp);
7869 p = Roo.urlEncode(bp);
7874 createCallback : function(){
7876 success: this.success,
7877 failure: this.failure,
7879 timeout: (this.form.timeout*1000),
7880 upload: this.form.fileUpload ? this.success : undefined
7885 Roo.form.Action.Submit = function(form, options){
7886 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
7889 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
7892 haveProgress : false,
7893 uploadComplete : false,
7895 // uploadProgress indicator.
7896 uploadProgress : function()
7898 if (!this.form.progressUrl) {
7902 if (!this.haveProgress) {
7903 Roo.MessageBox.progress("Uploading", "Uploading");
7905 if (this.uploadComplete) {
7906 Roo.MessageBox.hide();
7910 this.haveProgress = true;
7912 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
7914 var c = new Roo.data.Connection();
7916 url : this.form.progressUrl,
7921 success : function(req){
7922 //console.log(data);
7926 rdata = Roo.decode(req.responseText)
7928 Roo.log("Invalid data from server..");
7932 if (!rdata || !rdata.success) {
7934 Roo.MessageBox.alert(Roo.encode(rdata));
7937 var data = rdata.data;
7939 if (this.uploadComplete) {
7940 Roo.MessageBox.hide();
7945 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
7946 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
7949 this.uploadProgress.defer(2000,this);
7952 failure: function(data) {
7953 Roo.log('progress url failed ');
7964 // run get Values on the form, so it syncs any secondary forms.
7965 this.form.getValues();
7967 var o = this.options;
7968 var method = this.getMethod();
7969 var isPost = method == 'POST';
7970 if(o.clientValidation === false || this.form.isValid()){
7972 if (this.form.progressUrl) {
7973 this.form.findField('UPLOAD_IDENTIFIER').setValue(
7974 (new Date() * 1) + '' + Math.random());
7979 Roo.Ajax.request(Roo.apply(this.createCallback(), {
7980 form:this.form.el.dom,
7981 url:this.getUrl(!isPost),
7983 params:isPost ? this.getParams() : null,
7984 isUpload: this.form.fileUpload,
7985 formData : this.form.formData
7988 this.uploadProgress();
7990 }else if (o.clientValidation !== false){ // client validation failed
7991 this.failureType = Roo.form.Action.CLIENT_INVALID;
7992 this.form.afterAction(this, false);
7996 success : function(response)
7998 this.uploadComplete= true;
7999 if (this.haveProgress) {
8000 Roo.MessageBox.hide();
8004 var result = this.processResponse(response);
8005 if(result === true || result.success){
8006 this.form.afterAction(this, true);
8010 this.form.markInvalid(result.errors);
8011 this.failureType = Roo.form.Action.SERVER_INVALID;
8013 this.form.afterAction(this, false);
8015 failure : function(response)
8017 this.uploadComplete= true;
8018 if (this.haveProgress) {
8019 Roo.MessageBox.hide();
8022 this.response = response;
8023 this.failureType = Roo.form.Action.CONNECT_FAILURE;
8024 this.form.afterAction(this, false);
8027 handleResponse : function(response){
8028 if(this.form.errorReader){
8029 var rs = this.form.errorReader.read(response);
8032 for(var i = 0, len = rs.records.length; i < len; i++) {
8033 var r = rs.records[i];
8037 if(errors.length < 1){
8041 success : rs.success,
8047 ret = Roo.decode(response.responseText);
8051 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
8061 Roo.form.Action.Load = function(form, options){
8062 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
8063 this.reader = this.form.reader;
8066 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
8071 Roo.Ajax.request(Roo.apply(
8072 this.createCallback(), {
8073 method:this.getMethod(),
8074 url:this.getUrl(false),
8075 params:this.getParams()
8079 success : function(response){
8081 var result = this.processResponse(response);
8082 if(result === true || !result.success || !result.data){
8083 this.failureType = Roo.form.Action.LOAD_FAILURE;
8084 this.form.afterAction(this, false);
8087 this.form.clearInvalid();
8088 this.form.setValues(result.data);
8089 this.form.afterAction(this, true);
8092 handleResponse : function(response){
8093 if(this.form.reader){
8094 var rs = this.form.reader.read(response);
8095 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
8097 success : rs.success,
8101 return Roo.decode(response.responseText);
8105 Roo.form.Action.ACTION_TYPES = {
8106 'load' : Roo.form.Action.Load,
8107 'submit' : Roo.form.Action.Submit
8116 * @class Roo.bootstrap.Form
8117 * @extends Roo.bootstrap.Component
8118 * Bootstrap Form class
8119 * @cfg {String} method GET | POST (default POST)
8120 * @cfg {String} labelAlign top | left (default top)
8121 * @cfg {String} align left | right - for navbars
8122 * @cfg {Boolean} loadMask load mask when submit (default true)
8127 * @param {Object} config The config object
8131 Roo.bootstrap.Form = function(config){
8133 Roo.bootstrap.Form.superclass.constructor.call(this, config);
8135 Roo.bootstrap.Form.popover.apply();
8139 * @event clientvalidation
8140 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
8141 * @param {Form} this
8142 * @param {Boolean} valid true if the form has passed client-side validation
8144 clientvalidation: true,
8146 * @event beforeaction
8147 * Fires before any action is performed. Return false to cancel the action.
8148 * @param {Form} this
8149 * @param {Action} action The action to be performed
8153 * @event actionfailed
8154 * Fires when an action fails.
8155 * @param {Form} this
8156 * @param {Action} action The action that failed
8158 actionfailed : true,
8160 * @event actioncomplete
8161 * Fires when an action is completed.
8162 * @param {Form} this
8163 * @param {Action} action The action that completed
8165 actioncomplete : true
8169 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
8172 * @cfg {String} method
8173 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
8178 * The URL to use for form actions if one isn't supplied in the action options.
8181 * @cfg {Boolean} fileUpload
8182 * Set to true if this form is a file upload.
8186 * @cfg {Object} baseParams
8187 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
8191 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
8195 * @cfg {Sting} align (left|right) for navbar forms
8200 activeAction : null,
8203 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
8204 * element by passing it or its id or mask the form itself by passing in true.
8207 waitMsgTarget : false,
8212 * @cfg {Boolean} errorMask (true|false) default false
8217 * @cfg {Number} maskOffset Default 100
8222 * @cfg {Boolean} maskBody
8226 getAutoCreate : function(){
8230 method : this.method || 'POST',
8231 id : this.id || Roo.id(),
8234 if (this.parent().xtype.match(/^Nav/)) {
8235 cfg.cls = 'navbar-form form-inline navbar-' + this.align;
8239 if (this.labelAlign == 'left' ) {
8240 cfg.cls += ' form-horizontal';
8246 initEvents : function()
8248 this.el.on('submit', this.onSubmit, this);
8249 // this was added as random key presses on the form where triggering form submit.
8250 this.el.on('keypress', function(e) {
8251 if (e.getCharCode() != 13) {
8254 // we might need to allow it for textareas.. and some other items.
8255 // check e.getTarget().
8257 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
8261 Roo.log("keypress blocked");
8269 onSubmit : function(e){
8274 * Returns true if client-side validation on the form is successful.
8277 isValid : function(){
8278 var items = this.getItems();
8282 items.each(function(f){
8288 Roo.log('invalid field: ' + f.name);
8292 if(!target && f.el.isVisible(true)){
8298 if(this.errorMask && !valid){
8299 Roo.bootstrap.Form.popover.mask(this, target);
8306 * Returns true if any fields in this form have changed since their original load.
8309 isDirty : function(){
8311 var items = this.getItems();
8312 items.each(function(f){
8322 * Performs a predefined action (submit or load) or custom actions you define on this form.
8323 * @param {String} actionName The name of the action type
8324 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
8325 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
8326 * accept other config options):
8328 Property Type Description
8329 ---------------- --------------- ----------------------------------------------------------------------------------
8330 url String The url for the action (defaults to the form's url)
8331 method String The form method to use (defaults to the form's method, or POST if not defined)
8332 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
8333 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
8334 validate the form on the client (defaults to false)
8336 * @return {BasicForm} this
8338 doAction : function(action, options){
8339 if(typeof action == 'string'){
8340 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
8342 if(this.fireEvent('beforeaction', this, action) !== false){
8343 this.beforeAction(action);
8344 action.run.defer(100, action);
8350 beforeAction : function(action){
8351 var o = action.options;
8356 Roo.get(document.body).mask(o.waitMsg || "Sending", 'x-mask-loading')
8358 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
8361 // not really supported yet.. ??
8363 //if(this.waitMsgTarget === true){
8364 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
8365 //}else if(this.waitMsgTarget){
8366 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
8367 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
8369 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
8375 afterAction : function(action, success){
8376 this.activeAction = null;
8377 var o = action.options;
8382 Roo.get(document.body).unmask();
8388 //if(this.waitMsgTarget === true){
8389 // this.el.unmask();
8390 //}else if(this.waitMsgTarget){
8391 // this.waitMsgTarget.unmask();
8393 // Roo.MessageBox.updateProgress(1);
8394 // Roo.MessageBox.hide();
8401 Roo.callback(o.success, o.scope, [this, action]);
8402 this.fireEvent('actioncomplete', this, action);
8406 // failure condition..
8407 // we have a scenario where updates need confirming.
8408 // eg. if a locking scenario exists..
8409 // we look for { errors : { needs_confirm : true }} in the response.
8411 (typeof(action.result) != 'undefined') &&
8412 (typeof(action.result.errors) != 'undefined') &&
8413 (typeof(action.result.errors.needs_confirm) != 'undefined')
8416 Roo.log("not supported yet");
8419 Roo.MessageBox.confirm(
8420 "Change requires confirmation",
8421 action.result.errorMsg,
8426 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
8436 Roo.callback(o.failure, o.scope, [this, action]);
8437 // show an error message if no failed handler is set..
8438 if (!this.hasListener('actionfailed')) {
8439 Roo.log("need to add dialog support");
8441 Roo.MessageBox.alert("Error",
8442 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
8443 action.result.errorMsg :
8444 "Saving Failed, please check your entries or try again"
8449 this.fireEvent('actionfailed', this, action);
8454 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
8455 * @param {String} id The value to search for
8458 findField : function(id){
8459 var items = this.getItems();
8460 var field = items.get(id);
8462 items.each(function(f){
8463 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
8470 return field || null;
8473 * Mark fields in this form invalid in bulk.
8474 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
8475 * @return {BasicForm} this
8477 markInvalid : function(errors){
8478 if(errors instanceof Array){
8479 for(var i = 0, len = errors.length; i < len; i++){
8480 var fieldError = errors[i];
8481 var f = this.findField(fieldError.id);
8483 f.markInvalid(fieldError.msg);
8489 if(typeof errors[id] != 'function' && (field = this.findField(id))){
8490 field.markInvalid(errors[id]);
8494 //Roo.each(this.childForms || [], function (f) {
8495 // f.markInvalid(errors);
8502 * Set values for fields in this form in bulk.
8503 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
8504 * @return {BasicForm} this
8506 setValues : function(values){
8507 if(values instanceof Array){ // array of objects
8508 for(var i = 0, len = values.length; i < len; i++){
8510 var f = this.findField(v.id);
8512 f.setValue(v.value);
8513 if(this.trackResetOnLoad){
8514 f.originalValue = f.getValue();
8518 }else{ // object hash
8521 if(typeof values[id] != 'function' && (field = this.findField(id))){
8523 if (field.setFromData &&
8525 field.displayField &&
8526 // combos' with local stores can
8527 // be queried via setValue()
8528 // to set their value..
8529 (field.store && !field.store.isLocal)
8533 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
8534 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
8535 field.setFromData(sd);
8537 } else if(field.setFromData && (field.store && !field.store.isLocal)) {
8539 field.setFromData(values);
8542 field.setValue(values[id]);
8546 if(this.trackResetOnLoad){
8547 field.originalValue = field.getValue();
8553 //Roo.each(this.childForms || [], function (f) {
8554 // f.setValues(values);
8561 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
8562 * they are returned as an array.
8563 * @param {Boolean} asString
8566 getValues : function(asString){
8567 //if (this.childForms) {
8568 // copy values from the child forms
8569 // Roo.each(this.childForms, function (f) {
8570 // this.setValues(f.getValues());
8576 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
8577 if(asString === true){
8580 return Roo.urlDecode(fs);
8584 * Returns the fields in this form as an object with key/value pairs.
8585 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
8588 getFieldValues : function(with_hidden)
8590 var items = this.getItems();
8592 items.each(function(f){
8598 var v = f.getValue();
8600 if (f.inputType =='radio') {
8601 if (typeof(ret[f.getName()]) == 'undefined') {
8602 ret[f.getName()] = ''; // empty..
8605 if (!f.el.dom.checked) {
8613 if(f.xtype == 'MoneyField'){
8614 ret[f.currencyName] = f.getCurrency();
8617 // not sure if this supported any more..
8618 if ((typeof(v) == 'object') && f.getRawValue) {
8619 v = f.getRawValue() ; // dates..
8621 // combo boxes where name != hiddenName...
8622 if (f.name !== false && f.name != '' && f.name != f.getName()) {
8623 ret[f.name] = f.getRawValue();
8625 ret[f.getName()] = v;
8632 * Clears all invalid messages in this form.
8633 * @return {BasicForm} this
8635 clearInvalid : function(){
8636 var items = this.getItems();
8638 items.each(function(f){
8647 * @return {BasicForm} this
8650 var items = this.getItems();
8651 items.each(function(f){
8655 Roo.each(this.childForms || [], function (f) {
8663 getItems : function()
8665 var r=new Roo.util.MixedCollection(false, function(o){
8666 return o.id || (o.id = Roo.id());
8668 var iter = function(el) {
8675 Roo.each(el.items,function(e) {
8684 hideFields : function(items)
8686 Roo.each(items, function(i){
8688 var f = this.findField(i);
8699 showFields : function(items)
8701 Roo.each(items, function(i){
8703 var f = this.findField(i);
8716 Roo.apply(Roo.bootstrap.Form, {
8743 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
8744 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
8745 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
8746 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
8749 this.maskEl.top.enableDisplayMode("block");
8750 this.maskEl.left.enableDisplayMode("block");
8751 this.maskEl.bottom.enableDisplayMode("block");
8752 this.maskEl.right.enableDisplayMode("block");
8754 this.toolTip = new Roo.bootstrap.Tooltip({
8755 cls : 'roo-form-error-popover',
8757 'left' : ['r-l', [-2,0], 'right'],
8758 'right' : ['l-r', [2,0], 'left'],
8759 'bottom' : ['tl-bl', [0,2], 'top'],
8760 'top' : [ 'bl-tl', [0,-2], 'bottom']
8764 this.toolTip.render(Roo.get(document.body));
8766 this.toolTip.el.enableDisplayMode("block");
8768 Roo.get(document.body).on('click', function(){
8772 Roo.get(document.body).on('touchstart', function(){
8776 this.isApplied = true
8779 mask : function(form, target)
8783 this.target = target;
8785 if(!this.form.errorMask || !target.el){
8789 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
8791 Roo.log(scrollable);
8793 var ot = this.target.el.calcOffsetsTo(scrollable);
8795 var scrollTo = ot[1] - this.form.maskOffset;
8797 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
8799 scrollable.scrollTo('top', scrollTo);
8801 var box = this.target.el.getBox();
8803 var zIndex = Roo.bootstrap.Modal.zIndex++;
8806 this.maskEl.top.setStyle('position', 'absolute');
8807 this.maskEl.top.setStyle('z-index', zIndex);
8808 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
8809 this.maskEl.top.setLeft(0);
8810 this.maskEl.top.setTop(0);
8811 this.maskEl.top.show();
8813 this.maskEl.left.setStyle('position', 'absolute');
8814 this.maskEl.left.setStyle('z-index', zIndex);
8815 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
8816 this.maskEl.left.setLeft(0);
8817 this.maskEl.left.setTop(box.y - this.padding);
8818 this.maskEl.left.show();
8820 this.maskEl.bottom.setStyle('position', 'absolute');
8821 this.maskEl.bottom.setStyle('z-index', zIndex);
8822 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
8823 this.maskEl.bottom.setLeft(0);
8824 this.maskEl.bottom.setTop(box.bottom + this.padding);
8825 this.maskEl.bottom.show();
8827 this.maskEl.right.setStyle('position', 'absolute');
8828 this.maskEl.right.setStyle('z-index', zIndex);
8829 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
8830 this.maskEl.right.setLeft(box.right + this.padding);
8831 this.maskEl.right.setTop(box.y - this.padding);
8832 this.maskEl.right.show();
8834 this.toolTip.bindEl = this.target.el;
8836 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
8838 var tip = this.target.blankText;
8840 if(this.target.getValue() !== '' ) {
8842 if (this.target.invalidText.length) {
8843 tip = this.target.invalidText;
8844 } else if (this.target.regexText.length){
8845 tip = this.target.regexText;
8849 this.toolTip.show(tip);
8851 this.intervalID = window.setInterval(function() {
8852 Roo.bootstrap.Form.popover.unmask();
8855 window.onwheel = function(){ return false;};
8857 (function(){ this.isMasked = true; }).defer(500, this);
8863 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
8867 this.maskEl.top.setStyle('position', 'absolute');
8868 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
8869 this.maskEl.top.hide();
8871 this.maskEl.left.setStyle('position', 'absolute');
8872 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
8873 this.maskEl.left.hide();
8875 this.maskEl.bottom.setStyle('position', 'absolute');
8876 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
8877 this.maskEl.bottom.hide();
8879 this.maskEl.right.setStyle('position', 'absolute');
8880 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
8881 this.maskEl.right.hide();
8883 this.toolTip.hide();
8885 this.toolTip.el.hide();
8887 window.onwheel = function(){ return true;};
8889 if(this.intervalID){
8890 window.clearInterval(this.intervalID);
8891 this.intervalID = false;
8894 this.isMasked = false;
8904 * Ext JS Library 1.1.1
8905 * Copyright(c) 2006-2007, Ext JS, LLC.
8907 * Originally Released Under LGPL - original licence link has changed is not relivant.
8910 * <script type="text/javascript">
8913 * @class Roo.form.VTypes
8914 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
8917 Roo.form.VTypes = function(){
8918 // closure these in so they are only created once.
8919 var alpha = /^[a-zA-Z_]+$/;
8920 var alphanum = /^[a-zA-Z0-9_]+$/;
8921 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
8922 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
8924 // All these messages and functions are configurable
8927 * The function used to validate email addresses
8928 * @param {String} value The email address
8930 'email' : function(v){
8931 return email.test(v);
8934 * The error text to display when the email validation function returns false
8937 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
8939 * The keystroke filter mask to be applied on email input
8942 'emailMask' : /[a-z0-9_\.\-@]/i,
8945 * The function used to validate URLs
8946 * @param {String} value The URL
8948 'url' : function(v){
8952 * The error text to display when the url validation function returns false
8955 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
8958 * The function used to validate alpha values
8959 * @param {String} value The value
8961 'alpha' : function(v){
8962 return alpha.test(v);
8965 * The error text to display when the alpha validation function returns false
8968 'alphaText' : 'This field should only contain letters and _',
8970 * The keystroke filter mask to be applied on alpha input
8973 'alphaMask' : /[a-z_]/i,
8976 * The function used to validate alphanumeric values
8977 * @param {String} value The value
8979 'alphanum' : function(v){
8980 return alphanum.test(v);
8983 * The error text to display when the alphanumeric validation function returns false
8986 'alphanumText' : 'This field should only contain letters, numbers and _',
8988 * The keystroke filter mask to be applied on alphanumeric input
8991 'alphanumMask' : /[a-z0-9_]/i
9001 * @class Roo.bootstrap.Input
9002 * @extends Roo.bootstrap.Component
9003 * Bootstrap Input class
9004 * @cfg {Boolean} disabled is it disabled
9005 * @cfg {String} inputType button | checkbox | email | file | hidden | image | number | password | radio | range | reset | search | submit | text
9006 * @cfg {String} name name of the input
9007 * @cfg {string} fieldLabel - the label associated
9008 * @cfg {string} placeholder - placeholder to put in text.
9009 * @cfg {string} before - input group add on before
9010 * @cfg {string} after - input group add on after
9011 * @cfg {string} size - (lg|sm) or leave empty..
9012 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
9013 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
9014 * @cfg {Number} md colspan out of 12 for computer-sized screens
9015 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
9016 * @cfg {string} value default value of the input
9017 * @cfg {Number} labelWidth set the width of label
9018 * @cfg {Number} labellg set the width of label (1-12)
9019 * @cfg {Number} labelmd set the width of label (1-12)
9020 * @cfg {Number} labelsm set the width of label (1-12)
9021 * @cfg {Number} labelxs set the width of label (1-12)
9022 * @cfg {String} labelAlign (top|left)
9023 * @cfg {Boolean} readOnly Specifies that the field should be read-only
9024 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
9025 * @cfg {String} indicatorpos (left|right) default left
9026 * @cfg {String} capture (user|camera) use for file input only. (default empty)
9027 * @cfg {String} accept (image|video|audio) use for file input only. (default empty)
9029 * @cfg {String} align (left|center|right) Default left
9030 * @cfg {Boolean} forceFeedback (true|false) Default false
9033 * Create a new Input
9034 * @param {Object} config The config object
9037 Roo.bootstrap.Input = function(config){
9039 Roo.bootstrap.Input.superclass.constructor.call(this, config);
9044 * Fires when this field receives input focus.
9045 * @param {Roo.form.Field} this
9050 * Fires when this field loses input focus.
9051 * @param {Roo.form.Field} this
9056 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
9057 * {@link Roo.EventObject#getKey} to determine which key was pressed.
9058 * @param {Roo.form.Field} this
9059 * @param {Roo.EventObject} e The event object
9064 * Fires just before the field blurs if the field value has changed.
9065 * @param {Roo.form.Field} this
9066 * @param {Mixed} newValue The new value
9067 * @param {Mixed} oldValue The original value
9072 * Fires after the field has been marked as invalid.
9073 * @param {Roo.form.Field} this
9074 * @param {String} msg The validation message
9079 * Fires after the field has been validated with no errors.
9080 * @param {Roo.form.Field} this
9085 * Fires after the key up
9086 * @param {Roo.form.Field} this
9087 * @param {Roo.EventObject} e The event Object
9093 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
9095 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
9096 automatic validation (defaults to "keyup").
9098 validationEvent : "keyup",
9100 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
9102 validateOnBlur : true,
9104 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
9106 validationDelay : 250,
9108 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
9110 focusClass : "x-form-focus", // not needed???
9114 * @cfg {String} invalidClass DEPRICATED - code uses BS4 - is-valid / is-invalid
9116 invalidClass : "has-warning",
9119 * @cfg {String} validClass DEPRICATED - code uses BS4 - is-valid / is-invalid
9121 validClass : "has-success",
9124 * @cfg {Boolean} hasFeedback (true|false) default true
9129 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
9131 invalidFeedbackClass : "glyphicon-warning-sign",
9134 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
9136 validFeedbackClass : "glyphicon-ok",
9139 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
9141 selectOnFocus : false,
9144 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
9148 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
9153 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
9155 disableKeyFilter : false,
9158 * @cfg {Boolean} disabled True to disable the field (defaults to false).
9162 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
9166 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
9168 blankText : "Please complete this mandatory field",
9171 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
9175 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
9177 maxLength : Number.MAX_VALUE,
9179 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
9181 minLengthText : "The minimum length for this field is {0}",
9183 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
9185 maxLengthText : "The maximum length for this field is {0}",
9189 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
9190 * If available, this function will be called only after the basic validators all return true, and will be passed the
9191 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
9195 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
9196 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
9197 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
9201 * @cfg {String} regexText -- Depricated - use Invalid Text
9206 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
9212 autocomplete: false,
9231 formatedValue : false,
9232 forceFeedback : false,
9234 indicatorpos : 'left',
9244 parentLabelAlign : function()
9247 while (parent.parent()) {
9248 parent = parent.parent();
9249 if (typeof(parent.labelAlign) !='undefined') {
9250 return parent.labelAlign;
9257 getAutoCreate : function()
9259 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
9265 if(this.inputType != 'hidden'){
9266 cfg.cls = 'form-group' //input-group
9272 type : this.inputType,
9274 cls : 'form-control',
9275 placeholder : this.placeholder || '',
9276 autocomplete : this.autocomplete || 'new-password'
9279 if(this.capture.length){
9280 input.capture = this.capture;
9283 if(this.accept.length){
9284 input.accept = this.accept + "/*";
9288 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
9291 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
9292 input.maxLength = this.maxLength;
9295 if (this.disabled) {
9296 input.disabled=true;
9299 if (this.readOnly) {
9300 input.readonly=true;
9304 input.name = this.name;
9308 input.cls += ' input-' + this.size;
9312 ['xs','sm','md','lg'].map(function(size){
9313 if (settings[size]) {
9314 cfg.cls += ' col-' + size + '-' + settings[size];
9318 var inputblock = input;
9322 cls: 'glyphicon form-control-feedback'
9325 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9328 cls : 'has-feedback',
9336 if (this.before || this.after) {
9339 cls : 'input-group',
9343 if (this.before && typeof(this.before) == 'string') {
9345 inputblock.cn.push({
9347 cls : 'roo-input-before input-group-addon input-group-prepend input-group-text',
9351 if (this.before && typeof(this.before) == 'object') {
9352 this.before = Roo.factory(this.before);
9354 inputblock.cn.push({
9356 cls : 'roo-input-before input-group-prepend input-group-text input-group-' +
9357 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
9361 inputblock.cn.push(input);
9363 if (this.after && typeof(this.after) == 'string') {
9364 inputblock.cn.push({
9366 cls : 'roo-input-after input-group-append input-group-text input-group-addon',
9370 if (this.after && typeof(this.after) == 'object') {
9371 this.after = Roo.factory(this.after);
9373 inputblock.cn.push({
9375 cls : 'roo-input-after input-group-append input-group-text input-group-' +
9376 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
9380 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9381 inputblock.cls += ' has-feedback';
9382 inputblock.cn.push(feedback);
9387 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
9388 tooltip : 'This field is required'
9390 if (Roo.bootstrap.version == 4) {
9393 style : 'display-none'
9396 if (align ==='left' && this.fieldLabel.length) {
9398 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
9405 cls : 'control-label col-form-label',
9406 html : this.fieldLabel
9417 var labelCfg = cfg.cn[1];
9418 var contentCfg = cfg.cn[2];
9420 if(this.indicatorpos == 'right'){
9425 cls : 'control-label col-form-label',
9429 html : this.fieldLabel
9443 labelCfg = cfg.cn[0];
9444 contentCfg = cfg.cn[1];
9448 if(this.labelWidth > 12){
9449 labelCfg.style = "width: " + this.labelWidth + 'px';
9452 if(this.labelWidth < 13 && this.labelmd == 0){
9453 this.labelmd = this.labelWidth;
9456 if(this.labellg > 0){
9457 labelCfg.cls += ' col-lg-' + this.labellg;
9458 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
9461 if(this.labelmd > 0){
9462 labelCfg.cls += ' col-md-' + this.labelmd;
9463 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
9466 if(this.labelsm > 0){
9467 labelCfg.cls += ' col-sm-' + this.labelsm;
9468 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
9471 if(this.labelxs > 0){
9472 labelCfg.cls += ' col-xs-' + this.labelxs;
9473 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
9477 } else if ( this.fieldLabel.length) {
9482 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
9483 tooltip : 'This field is required'
9487 //cls : 'input-group-addon',
9488 html : this.fieldLabel
9496 if(this.indicatorpos == 'right'){
9501 //cls : 'input-group-addon',
9502 html : this.fieldLabel
9507 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
9508 tooltip : 'This field is required'
9528 if (this.parentType === 'Navbar' && this.parent().bar) {
9529 cfg.cls += ' navbar-form';
9532 if (this.parentType === 'NavGroup' && !(Roo.bootstrap.version == 4 && this.parent().form)) {
9533 // on BS4 we do this only if not form
9534 cfg.cls += ' navbar-form';
9542 * return the real input element.
9544 inputEl: function ()
9546 return this.el.select('input.form-control',true).first();
9549 tooltipEl : function()
9551 return this.inputEl();
9554 indicatorEl : function()
9556 if (Roo.bootstrap.version == 4) {
9557 return false; // not enabled in v4 yet.
9560 var indicator = this.el.select('i.roo-required-indicator',true).first();
9570 setDisabled : function(v)
9572 var i = this.inputEl().dom;
9574 i.removeAttribute('disabled');
9578 i.setAttribute('disabled','true');
9580 initEvents : function()
9583 this.inputEl().on("keydown" , this.fireKey, this);
9584 this.inputEl().on("focus", this.onFocus, this);
9585 this.inputEl().on("blur", this.onBlur, this);
9587 this.inputEl().relayEvent('keyup', this);
9589 this.indicator = this.indicatorEl();
9592 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible'); // changed from invisible??? -
9595 // reference to original value for reset
9596 this.originalValue = this.getValue();
9597 //Roo.form.TextField.superclass.initEvents.call(this);
9598 if(this.validationEvent == 'keyup'){
9599 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
9600 this.inputEl().on('keyup', this.filterValidation, this);
9602 else if(this.validationEvent !== false){
9603 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
9606 if(this.selectOnFocus){
9607 this.on("focus", this.preFocus, this);
9610 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
9611 this.inputEl().on("keypress", this.filterKeys, this);
9613 this.inputEl().relayEvent('keypress', this);
9616 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
9617 this.el.on("click", this.autoSize, this);
9620 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
9621 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
9624 if (typeof(this.before) == 'object') {
9625 this.before.render(this.el.select('.roo-input-before',true).first());
9627 if (typeof(this.after) == 'object') {
9628 this.after.render(this.el.select('.roo-input-after',true).first());
9631 this.inputEl().on('change', this.onChange, this);
9634 filterValidation : function(e){
9635 if(!e.isNavKeyPress()){
9636 this.validationTask.delay(this.validationDelay);
9640 * Validates the field value
9641 * @return {Boolean} True if the value is valid, else false
9643 validate : function(){
9644 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
9645 if(this.disabled || this.validateValue(this.getRawValue())){
9656 * Validates a value according to the field's validation rules and marks the field as invalid
9657 * if the validation fails
9658 * @param {Mixed} value The value to validate
9659 * @return {Boolean} True if the value is valid, else false
9661 validateValue : function(value)
9663 if(this.getVisibilityEl().hasClass('hidden')){
9667 if(value.length < 1) { // if it's blank
9668 if(this.allowBlank){
9674 if(value.length < this.minLength){
9677 if(value.length > this.maxLength){
9681 var vt = Roo.form.VTypes;
9682 if(!vt[this.vtype](value, this)){
9686 if(typeof this.validator == "function"){
9687 var msg = this.validator(value);
9691 if (typeof(msg) == 'string') {
9692 this.invalidText = msg;
9696 if(this.regex && !this.regex.test(value)){
9704 fireKey : function(e){
9705 //Roo.log('field ' + e.getKey());
9706 if(e.isNavKeyPress()){
9707 this.fireEvent("specialkey", this, e);
9710 focus : function (selectText){
9712 this.inputEl().focus();
9713 if(selectText === true){
9714 this.inputEl().dom.select();
9720 onFocus : function(){
9721 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9722 // this.el.addClass(this.focusClass);
9725 this.hasFocus = true;
9726 this.startValue = this.getValue();
9727 this.fireEvent("focus", this);
9731 beforeBlur : Roo.emptyFn,
9735 onBlur : function(){
9737 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9738 //this.el.removeClass(this.focusClass);
9740 this.hasFocus = false;
9741 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
9744 var v = this.getValue();
9745 if(String(v) !== String(this.startValue)){
9746 this.fireEvent('change', this, v, this.startValue);
9748 this.fireEvent("blur", this);
9751 onChange : function(e)
9753 var v = this.getValue();
9754 if(String(v) !== String(this.startValue)){
9755 this.fireEvent('change', this, v, this.startValue);
9761 * Resets the current field value to the originally loaded value and clears any validation messages
9764 this.setValue(this.originalValue);
9768 * Returns the name of the field
9769 * @return {Mixed} name The name field
9771 getName: function(){
9775 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
9776 * @return {Mixed} value The field value
9778 getValue : function(){
9780 var v = this.inputEl().getValue();
9785 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
9786 * @return {Mixed} value The field value
9788 getRawValue : function(){
9789 var v = this.inputEl().getValue();
9795 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
9796 * @param {Mixed} value The value to set
9798 setRawValue : function(v){
9799 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9802 selectText : function(start, end){
9803 var v = this.getRawValue();
9805 start = start === undefined ? 0 : start;
9806 end = end === undefined ? v.length : end;
9807 var d = this.inputEl().dom;
9808 if(d.setSelectionRange){
9809 d.setSelectionRange(start, end);
9810 }else if(d.createTextRange){
9811 var range = d.createTextRange();
9812 range.moveStart("character", start);
9813 range.moveEnd("character", v.length-end);
9820 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
9821 * @param {Mixed} value The value to set
9823 setValue : function(v){
9826 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9832 processValue : function(value){
9833 if(this.stripCharsRe){
9834 var newValue = value.replace(this.stripCharsRe, '');
9835 if(newValue !== value){
9836 this.setRawValue(newValue);
9843 preFocus : function(){
9845 if(this.selectOnFocus){
9846 this.inputEl().dom.select();
9849 filterKeys : function(e){
9851 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
9854 var c = e.getCharCode(), cc = String.fromCharCode(c);
9855 if(Roo.isIE && (e.isSpecialKey() || !cc)){
9858 if(!this.maskRe.test(cc)){
9863 * Clear any invalid styles/messages for this field
9865 clearInvalid : function(){
9867 if(!this.el || this.preventMark){ // not rendered
9872 this.el.removeClass([this.invalidClass, 'is-invalid']);
9874 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9876 var feedback = this.el.select('.form-control-feedback', true).first();
9879 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9885 this.indicator.removeClass('visible');
9886 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9889 this.fireEvent('valid', this);
9893 * Mark this field as valid
9895 markValid : function()
9897 if(!this.el || this.preventMark){ // not rendered...
9901 this.el.removeClass([this.invalidClass, this.validClass]);
9902 this.inputEl().removeClass(['is-valid', 'is-invalid']);
9904 var feedback = this.el.select('.form-control-feedback', true).first();
9907 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9911 this.indicator.removeClass('visible');
9912 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9919 if(this.allowBlank && !this.getRawValue().length){
9922 if (Roo.bootstrap.version == 3) {
9923 this.el.addClass(this.validClass);
9925 this.inputEl().addClass('is-valid');
9928 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9930 var feedback = this.el.select('.form-control-feedback', true).first();
9933 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9934 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9939 this.fireEvent('valid', this);
9943 * Mark this field as invalid
9944 * @param {String} msg The validation message
9946 markInvalid : function(msg)
9948 if(!this.el || this.preventMark){ // not rendered
9952 this.el.removeClass([this.invalidClass, this.validClass]);
9953 this.inputEl().removeClass(['is-valid', 'is-invalid']);
9955 var feedback = this.el.select('.form-control-feedback', true).first();
9958 this.el.select('.form-control-feedback', true).first().removeClass(
9959 [this.invalidFeedbackClass, this.validFeedbackClass]);
9966 if(this.allowBlank && !this.getRawValue().length){
9971 this.indicator.removeClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9972 this.indicator.addClass('visible');
9974 if (Roo.bootstrap.version == 3) {
9975 this.el.addClass(this.invalidClass);
9977 this.inputEl().addClass('is-invalid');
9982 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9984 var feedback = this.el.select('.form-control-feedback', true).first();
9987 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9989 if(this.getValue().length || this.forceFeedback){
9990 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9997 this.fireEvent('invalid', this, msg);
10000 SafariOnKeyDown : function(event)
10002 // this is a workaround for a password hang bug on chrome/ webkit.
10003 if (this.inputEl().dom.type != 'password') {
10007 var isSelectAll = false;
10009 if(this.inputEl().dom.selectionEnd > 0){
10010 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
10012 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
10013 event.preventDefault();
10018 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
10020 event.preventDefault();
10021 // this is very hacky as keydown always get's upper case.
10023 var cc = String.fromCharCode(event.getCharCode());
10024 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
10028 adjustWidth : function(tag, w){
10029 tag = tag.toLowerCase();
10030 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
10031 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
10032 if(tag == 'input'){
10035 if(tag == 'textarea'){
10038 }else if(Roo.isOpera){
10039 if(tag == 'input'){
10042 if(tag == 'textarea'){
10050 setFieldLabel : function(v)
10052 if(!this.rendered){
10056 if(this.indicatorEl()){
10057 var ar = this.el.select('label > span',true);
10059 if (ar.elements.length) {
10060 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
10061 this.fieldLabel = v;
10065 var br = this.el.select('label',true);
10067 if(br.elements.length) {
10068 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
10069 this.fieldLabel = v;
10073 Roo.log('Cannot Found any of label > span || label in input');
10077 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
10078 this.fieldLabel = v;
10093 * @class Roo.bootstrap.TextArea
10094 * @extends Roo.bootstrap.Input
10095 * Bootstrap TextArea class
10096 * @cfg {Number} cols Specifies the visible width of a text area
10097 * @cfg {Number} rows Specifies the visible number of lines in a text area
10098 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
10099 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
10100 * @cfg {string} html text
10103 * Create a new TextArea
10104 * @param {Object} config The config object
10107 Roo.bootstrap.TextArea = function(config){
10108 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
10112 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
10122 getAutoCreate : function(){
10124 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
10130 if(this.inputType != 'hidden'){
10131 cfg.cls = 'form-group' //input-group
10139 value : this.value || '',
10140 html: this.html || '',
10141 cls : 'form-control',
10142 placeholder : this.placeholder || ''
10146 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
10147 input.maxLength = this.maxLength;
10151 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
10155 input.cols = this.cols;
10158 if (this.readOnly) {
10159 input.readonly = true;
10163 input.name = this.name;
10167 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
10171 ['xs','sm','md','lg'].map(function(size){
10172 if (settings[size]) {
10173 cfg.cls += ' col-' + size + '-' + settings[size];
10177 var inputblock = input;
10179 if(this.hasFeedback && !this.allowBlank){
10183 cls: 'glyphicon form-control-feedback'
10187 cls : 'has-feedback',
10196 if (this.before || this.after) {
10199 cls : 'input-group',
10203 inputblock.cn.push({
10205 cls : 'input-group-addon',
10210 inputblock.cn.push(input);
10212 if(this.hasFeedback && !this.allowBlank){
10213 inputblock.cls += ' has-feedback';
10214 inputblock.cn.push(feedback);
10218 inputblock.cn.push({
10220 cls : 'input-group-addon',
10227 if (align ==='left' && this.fieldLabel.length) {
10232 cls : 'control-label',
10233 html : this.fieldLabel
10244 if(this.labelWidth > 12){
10245 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
10248 if(this.labelWidth < 13 && this.labelmd == 0){
10249 this.labelmd = this.labelWidth;
10252 if(this.labellg > 0){
10253 cfg.cn[0].cls += ' col-lg-' + this.labellg;
10254 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
10257 if(this.labelmd > 0){
10258 cfg.cn[0].cls += ' col-md-' + this.labelmd;
10259 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
10262 if(this.labelsm > 0){
10263 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
10264 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
10267 if(this.labelxs > 0){
10268 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
10269 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
10272 } else if ( this.fieldLabel.length) {
10277 //cls : 'input-group-addon',
10278 html : this.fieldLabel
10296 if (this.disabled) {
10297 input.disabled=true;
10304 * return the real textarea element.
10306 inputEl: function ()
10308 return this.el.select('textarea.form-control',true).first();
10312 * Clear any invalid styles/messages for this field
10314 clearInvalid : function()
10317 if(!this.el || this.preventMark){ // not rendered
10321 var label = this.el.select('label', true).first();
10322 var icon = this.el.select('i.fa-star', true).first();
10327 this.el.removeClass( this.validClass);
10328 this.inputEl().removeClass('is-invalid');
10330 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10332 var feedback = this.el.select('.form-control-feedback', true).first();
10335 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
10340 this.fireEvent('valid', this);
10344 * Mark this field as valid
10346 markValid : function()
10348 if(!this.el || this.preventMark){ // not rendered
10352 this.el.removeClass([this.invalidClass, this.validClass]);
10353 this.inputEl().removeClass(['is-valid', 'is-invalid']);
10355 var feedback = this.el.select('.form-control-feedback', true).first();
10358 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10361 if(this.disabled || this.allowBlank){
10365 var label = this.el.select('label', true).first();
10366 var icon = this.el.select('i.fa-star', true).first();
10371 if (Roo.bootstrap.version == 3) {
10372 this.el.addClass(this.validClass);
10374 this.inputEl().addClass('is-valid');
10378 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
10380 var feedback = this.el.select('.form-control-feedback', true).first();
10383 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10384 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
10389 this.fireEvent('valid', this);
10393 * Mark this field as invalid
10394 * @param {String} msg The validation message
10396 markInvalid : function(msg)
10398 if(!this.el || this.preventMark){ // not rendered
10402 this.el.removeClass([this.invalidClass, this.validClass]);
10403 this.inputEl().removeClass(['is-valid', 'is-invalid']);
10405 var feedback = this.el.select('.form-control-feedback', true).first();
10408 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10411 if(this.disabled || this.allowBlank){
10415 var label = this.el.select('label', true).first();
10416 var icon = this.el.select('i.fa-star', true).first();
10418 if(!this.getValue().length && label && !icon){
10419 this.el.createChild({
10421 cls : 'text-danger fa fa-lg fa-star',
10422 tooltip : 'This field is required',
10423 style : 'margin-right:5px;'
10427 if (Roo.bootstrap.version == 3) {
10428 this.el.addClass(this.invalidClass);
10430 this.inputEl().addClass('is-invalid');
10433 // fixme ... this may be depricated need to test..
10434 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10436 var feedback = this.el.select('.form-control-feedback', true).first();
10439 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10441 if(this.getValue().length || this.forceFeedback){
10442 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
10449 this.fireEvent('invalid', this, msg);
10457 * trigger field - base class for combo..
10462 * @class Roo.bootstrap.TriggerField
10463 * @extends Roo.bootstrap.Input
10464 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
10465 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
10466 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
10467 * for which you can provide a custom implementation. For example:
10469 var trigger = new Roo.bootstrap.TriggerField();
10470 trigger.onTriggerClick = myTriggerFn;
10471 trigger.applyTo('my-field');
10474 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
10475 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
10476 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
10477 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
10478 * @cfg {String} caret (search|calendar) BS3 only - carat fa name
10481 * Create a new TriggerField.
10482 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
10483 * to the base TextField)
10485 Roo.bootstrap.TriggerField = function(config){
10486 this.mimicing = false;
10487 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
10490 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
10492 * @cfg {String} triggerClass A CSS class to apply to the trigger
10495 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
10500 * @cfg {Boolean} removable (true|false) special filter default false
10504 /** @cfg {Boolean} grow @hide */
10505 /** @cfg {Number} growMin @hide */
10506 /** @cfg {Number} growMax @hide */
10512 autoSize: Roo.emptyFn,
10516 deferHeight : true,
10519 actionMode : 'wrap',
10524 getAutoCreate : function(){
10526 var align = this.labelAlign || this.parentLabelAlign();
10531 cls: 'form-group' //input-group
10538 type : this.inputType,
10539 cls : 'form-control',
10540 autocomplete: 'new-password',
10541 placeholder : this.placeholder || ''
10545 input.name = this.name;
10548 input.cls += ' input-' + this.size;
10551 if (this.disabled) {
10552 input.disabled=true;
10555 var inputblock = input;
10557 if(this.hasFeedback && !this.allowBlank){
10561 cls: 'glyphicon form-control-feedback'
10564 if(this.removable && !this.editable && !this.tickable){
10566 cls : 'has-feedback',
10572 cls : 'roo-combo-removable-btn close'
10579 cls : 'has-feedback',
10588 if(this.removable && !this.editable && !this.tickable){
10590 cls : 'roo-removable',
10596 cls : 'roo-combo-removable-btn close'
10603 if (this.before || this.after) {
10606 cls : 'input-group',
10610 inputblock.cn.push({
10612 cls : 'input-group-addon input-group-prepend input-group-text',
10617 inputblock.cn.push(input);
10619 if(this.hasFeedback && !this.allowBlank){
10620 inputblock.cls += ' has-feedback';
10621 inputblock.cn.push(feedback);
10625 inputblock.cn.push({
10627 cls : 'input-group-addon input-group-append input-group-text',
10636 var ibwrap = inputblock;
10641 cls: 'roo-select2-choices',
10645 cls: 'roo-select2-search-field',
10657 cls: 'roo-select2-container input-group',
10662 cls: 'form-hidden-field'
10668 if(!this.multiple && this.showToggleBtn){
10674 if (this.caret != false) {
10677 cls: 'fa fa-' + this.caret
10684 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
10686 Roo.bootstrap.version == 3 ? caret : '',
10689 cls: 'combobox-clear',
10703 combobox.cls += ' roo-select2-container-multi';
10707 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
10708 tooltip : 'This field is required'
10710 if (Roo.bootstrap.version == 4) {
10713 style : 'display:none'
10718 if (align ==='left' && this.fieldLabel.length) {
10720 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
10727 cls : 'control-label',
10728 html : this.fieldLabel
10740 var labelCfg = cfg.cn[1];
10741 var contentCfg = cfg.cn[2];
10743 if(this.indicatorpos == 'right'){
10748 cls : 'control-label',
10752 html : this.fieldLabel
10766 labelCfg = cfg.cn[0];
10767 contentCfg = cfg.cn[1];
10770 if(this.labelWidth > 12){
10771 labelCfg.style = "width: " + this.labelWidth + 'px';
10774 if(this.labelWidth < 13 && this.labelmd == 0){
10775 this.labelmd = this.labelWidth;
10778 if(this.labellg > 0){
10779 labelCfg.cls += ' col-lg-' + this.labellg;
10780 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
10783 if(this.labelmd > 0){
10784 labelCfg.cls += ' col-md-' + this.labelmd;
10785 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
10788 if(this.labelsm > 0){
10789 labelCfg.cls += ' col-sm-' + this.labelsm;
10790 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
10793 if(this.labelxs > 0){
10794 labelCfg.cls += ' col-xs-' + this.labelxs;
10795 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
10798 } else if ( this.fieldLabel.length) {
10799 // Roo.log(" label");
10804 //cls : 'input-group-addon',
10805 html : this.fieldLabel
10813 if(this.indicatorpos == 'right'){
10821 html : this.fieldLabel
10835 // Roo.log(" no label && no align");
10842 ['xs','sm','md','lg'].map(function(size){
10843 if (settings[size]) {
10844 cfg.cls += ' col-' + size + '-' + settings[size];
10855 onResize : function(w, h){
10856 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
10857 // if(typeof w == 'number'){
10858 // var x = w - this.trigger.getWidth();
10859 // this.inputEl().setWidth(this.adjustWidth('input', x));
10860 // this.trigger.setStyle('left', x+'px');
10865 adjustSize : Roo.BoxComponent.prototype.adjustSize,
10868 getResizeEl : function(){
10869 return this.inputEl();
10873 getPositionEl : function(){
10874 return this.inputEl();
10878 alignErrorIcon : function(){
10879 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
10883 initEvents : function(){
10887 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
10888 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
10889 if(!this.multiple && this.showToggleBtn){
10890 this.trigger = this.el.select('span.dropdown-toggle',true).first();
10891 if(this.hideTrigger){
10892 this.trigger.setDisplayed(false);
10894 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
10898 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
10901 if(this.removable && !this.editable && !this.tickable){
10902 var close = this.closeTriggerEl();
10905 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
10906 close.on('click', this.removeBtnClick, this, close);
10910 //this.trigger.addClassOnOver('x-form-trigger-over');
10911 //this.trigger.addClassOnClick('x-form-trigger-click');
10914 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
10918 closeTriggerEl : function()
10920 var close = this.el.select('.roo-combo-removable-btn', true).first();
10921 return close ? close : false;
10924 removeBtnClick : function(e, h, el)
10926 e.preventDefault();
10928 if(this.fireEvent("remove", this) !== false){
10930 this.fireEvent("afterremove", this)
10934 createList : function()
10936 this.list = Roo.get(document.body).createChild({
10937 tag: Roo.bootstrap.version == 4 ? 'div' : 'ul',
10938 cls: 'typeahead typeahead-long dropdown-menu',
10939 style: 'display:none'
10942 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
10947 initTrigger : function(){
10952 onDestroy : function(){
10954 this.trigger.removeAllListeners();
10955 // this.trigger.remove();
10958 // this.wrap.remove();
10960 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
10964 onFocus : function(){
10965 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
10967 if(!this.mimicing){
10968 this.wrap.addClass('x-trigger-wrap-focus');
10969 this.mimicing = true;
10970 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
10971 if(this.monitorTab){
10972 this.el.on("keydown", this.checkTab, this);
10979 checkTab : function(e){
10980 if(e.getKey() == e.TAB){
10981 this.triggerBlur();
10986 onBlur : function(){
10991 mimicBlur : function(e, t){
10993 if(!this.wrap.contains(t) && this.validateBlur()){
10994 this.triggerBlur();
11000 triggerBlur : function(){
11001 this.mimicing = false;
11002 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
11003 if(this.monitorTab){
11004 this.el.un("keydown", this.checkTab, this);
11006 //this.wrap.removeClass('x-trigger-wrap-focus');
11007 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
11011 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
11012 validateBlur : function(e, t){
11017 onDisable : function(){
11018 this.inputEl().dom.disabled = true;
11019 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
11021 // this.wrap.addClass('x-item-disabled');
11026 onEnable : function(){
11027 this.inputEl().dom.disabled = false;
11028 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
11030 // this.el.removeClass('x-item-disabled');
11035 onShow : function(){
11036 var ae = this.getActionEl();
11039 ae.dom.style.display = '';
11040 ae.dom.style.visibility = 'visible';
11046 onHide : function(){
11047 var ae = this.getActionEl();
11048 ae.dom.style.display = 'none';
11052 * The function that should handle the trigger's click event. This method does nothing by default until overridden
11053 * by an implementing function.
11055 * @param {EventObject} e
11057 onTriggerClick : Roo.emptyFn
11061 * Ext JS Library 1.1.1
11062 * Copyright(c) 2006-2007, Ext JS, LLC.
11064 * Originally Released Under LGPL - original licence link has changed is not relivant.
11067 * <script type="text/javascript">
11072 * @class Roo.data.SortTypes
11074 * Defines the default sorting (casting?) comparison functions used when sorting data.
11076 Roo.data.SortTypes = {
11078 * Default sort that does nothing
11079 * @param {Mixed} s The value being converted
11080 * @return {Mixed} The comparison value
11082 none : function(s){
11087 * The regular expression used to strip tags
11091 stripTagsRE : /<\/?[^>]+>/gi,
11094 * Strips all HTML tags to sort on text only
11095 * @param {Mixed} s The value being converted
11096 * @return {String} The comparison value
11098 asText : function(s){
11099 return String(s).replace(this.stripTagsRE, "");
11103 * Strips all HTML tags to sort on text only - Case insensitive
11104 * @param {Mixed} s The value being converted
11105 * @return {String} The comparison value
11107 asUCText : function(s){
11108 return String(s).toUpperCase().replace(this.stripTagsRE, "");
11112 * Case insensitive string
11113 * @param {Mixed} s The value being converted
11114 * @return {String} The comparison value
11116 asUCString : function(s) {
11117 return String(s).toUpperCase();
11122 * @param {Mixed} s The value being converted
11123 * @return {Number} The comparison value
11125 asDate : function(s) {
11129 if(s instanceof Date){
11130 return s.getTime();
11132 return Date.parse(String(s));
11137 * @param {Mixed} s The value being converted
11138 * @return {Float} The comparison value
11140 asFloat : function(s) {
11141 var val = parseFloat(String(s).replace(/,/g, ""));
11150 * @param {Mixed} s The value being converted
11151 * @return {Number} The comparison value
11153 asInt : function(s) {
11154 var val = parseInt(String(s).replace(/,/g, ""));
11162 * Ext JS Library 1.1.1
11163 * Copyright(c) 2006-2007, Ext JS, LLC.
11165 * Originally Released Under LGPL - original licence link has changed is not relivant.
11168 * <script type="text/javascript">
11172 * @class Roo.data.Record
11173 * Instances of this class encapsulate both record <em>definition</em> information, and record
11174 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
11175 * to access Records cached in an {@link Roo.data.Store} object.<br>
11177 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
11178 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
11181 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
11183 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
11184 * {@link #create}. The parameters are the same.
11185 * @param {Array} data An associative Array of data values keyed by the field name.
11186 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
11187 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
11188 * not specified an integer id is generated.
11190 Roo.data.Record = function(data, id){
11191 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
11196 * Generate a constructor for a specific record layout.
11197 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
11198 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
11199 * Each field definition object may contain the following properties: <ul>
11200 * <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,
11201 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
11202 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
11203 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
11204 * is being used, then this is a string containing the javascript expression to reference the data relative to
11205 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
11206 * to the data item relative to the record element. If the mapping expression is the same as the field name,
11207 * this may be omitted.</p></li>
11208 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
11209 * <ul><li>auto (Default, implies no conversion)</li>
11214 * <li>date</li></ul></p></li>
11215 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
11216 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
11217 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
11218 * by the Reader into an object that will be stored in the Record. It is passed the
11219 * following parameters:<ul>
11220 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
11222 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
11224 * <br>usage:<br><pre><code>
11225 var TopicRecord = Roo.data.Record.create(
11226 {name: 'title', mapping: 'topic_title'},
11227 {name: 'author', mapping: 'username'},
11228 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
11229 {name: 'lastPost', mapping: 'post_time', type: 'date'},
11230 {name: 'lastPoster', mapping: 'user2'},
11231 {name: 'excerpt', mapping: 'post_text'}
11234 var myNewRecord = new TopicRecord({
11235 title: 'Do my job please',
11238 lastPost: new Date(),
11239 lastPoster: 'Animal',
11240 excerpt: 'No way dude!'
11242 myStore.add(myNewRecord);
11247 Roo.data.Record.create = function(o){
11248 var f = function(){
11249 f.superclass.constructor.apply(this, arguments);
11251 Roo.extend(f, Roo.data.Record);
11252 var p = f.prototype;
11253 p.fields = new Roo.util.MixedCollection(false, function(field){
11256 for(var i = 0, len = o.length; i < len; i++){
11257 p.fields.add(new Roo.data.Field(o[i]));
11259 f.getField = function(name){
11260 return p.fields.get(name);
11265 Roo.data.Record.AUTO_ID = 1000;
11266 Roo.data.Record.EDIT = 'edit';
11267 Roo.data.Record.REJECT = 'reject';
11268 Roo.data.Record.COMMIT = 'commit';
11270 Roo.data.Record.prototype = {
11272 * Readonly flag - true if this record has been modified.
11281 join : function(store){
11282 this.store = store;
11286 * Set the named field to the specified value.
11287 * @param {String} name The name of the field to set.
11288 * @param {Object} value The value to set the field to.
11290 set : function(name, value){
11291 if(this.data[name] == value){
11295 if(!this.modified){
11296 this.modified = {};
11298 if(typeof this.modified[name] == 'undefined'){
11299 this.modified[name] = this.data[name];
11301 this.data[name] = value;
11302 if(!this.editing && this.store){
11303 this.store.afterEdit(this);
11308 * Get the value of the named field.
11309 * @param {String} name The name of the field to get the value of.
11310 * @return {Object} The value of the field.
11312 get : function(name){
11313 return this.data[name];
11317 beginEdit : function(){
11318 this.editing = true;
11319 this.modified = {};
11323 cancelEdit : function(){
11324 this.editing = false;
11325 delete this.modified;
11329 endEdit : function(){
11330 this.editing = false;
11331 if(this.dirty && this.store){
11332 this.store.afterEdit(this);
11337 * Usually called by the {@link Roo.data.Store} which owns the Record.
11338 * Rejects all changes made to the Record since either creation, or the last commit operation.
11339 * Modified fields are reverted to their original values.
11341 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
11342 * of reject operations.
11344 reject : function(){
11345 var m = this.modified;
11347 if(typeof m[n] != "function"){
11348 this.data[n] = m[n];
11351 this.dirty = false;
11352 delete this.modified;
11353 this.editing = false;
11355 this.store.afterReject(this);
11360 * Usually called by the {@link Roo.data.Store} which owns the Record.
11361 * Commits all changes made to the Record since either creation, or the last commit operation.
11363 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
11364 * of commit operations.
11366 commit : function(){
11367 this.dirty = false;
11368 delete this.modified;
11369 this.editing = false;
11371 this.store.afterCommit(this);
11376 hasError : function(){
11377 return this.error != null;
11381 clearError : function(){
11386 * Creates a copy of this record.
11387 * @param {String} id (optional) A new record id if you don't want to use this record's id
11390 copy : function(newId) {
11391 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
11395 * Ext JS Library 1.1.1
11396 * Copyright(c) 2006-2007, Ext JS, LLC.
11398 * Originally Released Under LGPL - original licence link has changed is not relivant.
11401 * <script type="text/javascript">
11407 * @class Roo.data.Store
11408 * @extends Roo.util.Observable
11409 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
11410 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
11412 * 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
11413 * has no knowledge of the format of the data returned by the Proxy.<br>
11415 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
11416 * instances from the data object. These records are cached and made available through accessor functions.
11418 * Creates a new Store.
11419 * @param {Object} config A config object containing the objects needed for the Store to access data,
11420 * and read the data into Records.
11422 Roo.data.Store = function(config){
11423 this.data = new Roo.util.MixedCollection(false);
11424 this.data.getKey = function(o){
11427 this.baseParams = {};
11429 this.paramNames = {
11434 "multisort" : "_multisort"
11437 if(config && config.data){
11438 this.inlineData = config.data;
11439 delete config.data;
11442 Roo.apply(this, config);
11444 if(this.reader){ // reader passed
11445 this.reader = Roo.factory(this.reader, Roo.data);
11446 this.reader.xmodule = this.xmodule || false;
11447 if(!this.recordType){
11448 this.recordType = this.reader.recordType;
11450 if(this.reader.onMetaChange){
11451 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
11455 if(this.recordType){
11456 this.fields = this.recordType.prototype.fields;
11458 this.modified = [];
11462 * @event datachanged
11463 * Fires when the data cache has changed, and a widget which is using this Store
11464 * as a Record cache should refresh its view.
11465 * @param {Store} this
11467 datachanged : true,
11469 * @event metachange
11470 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
11471 * @param {Store} this
11472 * @param {Object} meta The JSON metadata
11477 * Fires when Records have been added to the Store
11478 * @param {Store} this
11479 * @param {Roo.data.Record[]} records The array of Records added
11480 * @param {Number} index The index at which the record(s) were added
11485 * Fires when a Record has been removed from the Store
11486 * @param {Store} this
11487 * @param {Roo.data.Record} record The Record that was removed
11488 * @param {Number} index The index at which the record was removed
11493 * Fires when a Record has been updated
11494 * @param {Store} this
11495 * @param {Roo.data.Record} record The Record that was updated
11496 * @param {String} operation The update operation being performed. Value may be one of:
11498 Roo.data.Record.EDIT
11499 Roo.data.Record.REJECT
11500 Roo.data.Record.COMMIT
11506 * Fires when the data cache has been cleared.
11507 * @param {Store} this
11511 * @event beforeload
11512 * Fires before a request is made for a new data object. If the beforeload handler returns false
11513 * the load action will be canceled.
11514 * @param {Store} this
11515 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11519 * @event beforeloadadd
11520 * Fires after a new set of Records has been loaded.
11521 * @param {Store} this
11522 * @param {Roo.data.Record[]} records The Records that were loaded
11523 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11525 beforeloadadd : true,
11528 * Fires after a new set of Records has been loaded, before they are added to the store.
11529 * @param {Store} this
11530 * @param {Roo.data.Record[]} records The Records that were loaded
11531 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11532 * @params {Object} return from reader
11536 * @event loadexception
11537 * Fires if an exception occurs in the Proxy during loading.
11538 * Called with the signature of the Proxy's "loadexception" event.
11539 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
11542 * @param {Object} return from JsonData.reader() - success, totalRecords, records
11543 * @param {Object} load options
11544 * @param {Object} jsonData from your request (normally this contains the Exception)
11546 loadexception : true
11550 this.proxy = Roo.factory(this.proxy, Roo.data);
11551 this.proxy.xmodule = this.xmodule || false;
11552 this.relayEvents(this.proxy, ["loadexception"]);
11554 this.sortToggle = {};
11555 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
11557 Roo.data.Store.superclass.constructor.call(this);
11559 if(this.inlineData){
11560 this.loadData(this.inlineData);
11561 delete this.inlineData;
11565 Roo.extend(Roo.data.Store, Roo.util.Observable, {
11567 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
11568 * without a remote query - used by combo/forms at present.
11572 * @cfg {Roo.data.DataProxy} proxy The Proxy object which provides access to a data object.
11575 * @cfg {Array} data Inline data to be loaded when the store is initialized.
11578 * @cfg {Roo.data.Reader} reader The Reader object which processes the data object and returns
11579 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
11582 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
11583 * on any HTTP request
11586 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
11589 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
11593 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
11594 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
11596 remoteSort : false,
11599 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
11600 * loaded or when a record is removed. (defaults to false).
11602 pruneModifiedRecords : false,
11605 lastOptions : null,
11608 * Add Records to the Store and fires the add event.
11609 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11611 add : function(records){
11612 records = [].concat(records);
11613 for(var i = 0, len = records.length; i < len; i++){
11614 records[i].join(this);
11616 var index = this.data.length;
11617 this.data.addAll(records);
11618 this.fireEvent("add", this, records, index);
11622 * Remove a Record from the Store and fires the remove event.
11623 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
11625 remove : function(record){
11626 var index = this.data.indexOf(record);
11627 this.data.removeAt(index);
11629 if(this.pruneModifiedRecords){
11630 this.modified.remove(record);
11632 this.fireEvent("remove", this, record, index);
11636 * Remove all Records from the Store and fires the clear event.
11638 removeAll : function(){
11640 if(this.pruneModifiedRecords){
11641 this.modified = [];
11643 this.fireEvent("clear", this);
11647 * Inserts Records to the Store at the given index and fires the add event.
11648 * @param {Number} index The start index at which to insert the passed Records.
11649 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11651 insert : function(index, records){
11652 records = [].concat(records);
11653 for(var i = 0, len = records.length; i < len; i++){
11654 this.data.insert(index, records[i]);
11655 records[i].join(this);
11657 this.fireEvent("add", this, records, index);
11661 * Get the index within the cache of the passed Record.
11662 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
11663 * @return {Number} The index of the passed Record. Returns -1 if not found.
11665 indexOf : function(record){
11666 return this.data.indexOf(record);
11670 * Get the index within the cache of the Record with the passed id.
11671 * @param {String} id The id of the Record to find.
11672 * @return {Number} The index of the Record. Returns -1 if not found.
11674 indexOfId : function(id){
11675 return this.data.indexOfKey(id);
11679 * Get the Record with the specified id.
11680 * @param {String} id The id of the Record to find.
11681 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
11683 getById : function(id){
11684 return this.data.key(id);
11688 * Get the Record at the specified index.
11689 * @param {Number} index The index of the Record to find.
11690 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
11692 getAt : function(index){
11693 return this.data.itemAt(index);
11697 * Returns a range of Records between specified indices.
11698 * @param {Number} startIndex (optional) The starting index (defaults to 0)
11699 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
11700 * @return {Roo.data.Record[]} An array of Records
11702 getRange : function(start, end){
11703 return this.data.getRange(start, end);
11707 storeOptions : function(o){
11708 o = Roo.apply({}, o);
11711 this.lastOptions = o;
11715 * Loads the Record cache from the configured Proxy using the configured Reader.
11717 * If using remote paging, then the first load call must specify the <em>start</em>
11718 * and <em>limit</em> properties in the options.params property to establish the initial
11719 * position within the dataset, and the number of Records to cache on each read from the Proxy.
11721 * <strong>It is important to note that for remote data sources, loading is asynchronous,
11722 * and this call will return before the new data has been loaded. Perform any post-processing
11723 * in a callback function, or in a "load" event handler.</strong>
11725 * @param {Object} options An object containing properties which control loading options:<ul>
11726 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
11727 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
11728 * passed the following arguments:<ul>
11729 * <li>r : Roo.data.Record[]</li>
11730 * <li>options: Options object from the load call</li>
11731 * <li>success: Boolean success indicator</li></ul></li>
11732 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
11733 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
11736 load : function(options){
11737 options = options || {};
11738 if(this.fireEvent("beforeload", this, options) !== false){
11739 this.storeOptions(options);
11740 var p = Roo.apply(options.params || {}, this.baseParams);
11741 // if meta was not loaded from remote source.. try requesting it.
11742 if (!this.reader.metaFromRemote) {
11743 p._requestMeta = 1;
11745 if(this.sortInfo && this.remoteSort){
11746 var pn = this.paramNames;
11747 p[pn["sort"]] = this.sortInfo.field;
11748 p[pn["dir"]] = this.sortInfo.direction;
11750 if (this.multiSort) {
11751 var pn = this.paramNames;
11752 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
11755 this.proxy.load(p, this.reader, this.loadRecords, this, options);
11760 * Reloads the Record cache from the configured Proxy using the configured Reader and
11761 * the options from the last load operation performed.
11762 * @param {Object} options (optional) An object containing properties which may override the options
11763 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
11764 * the most recently used options are reused).
11766 reload : function(options){
11767 this.load(Roo.applyIf(options||{}, this.lastOptions));
11771 // Called as a callback by the Reader during a load operation.
11772 loadRecords : function(o, options, success){
11773 if(!o || success === false){
11774 if(success !== false){
11775 this.fireEvent("load", this, [], options, o);
11777 if(options.callback){
11778 options.callback.call(options.scope || this, [], options, false);
11782 // if data returned failure - throw an exception.
11783 if (o.success === false) {
11784 // show a message if no listener is registered.
11785 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
11786 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
11788 // loadmask wil be hooked into this..
11789 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
11792 var r = o.records, t = o.totalRecords || r.length;
11794 this.fireEvent("beforeloadadd", this, r, options, o);
11796 if(!options || options.add !== true){
11797 if(this.pruneModifiedRecords){
11798 this.modified = [];
11800 for(var i = 0, len = r.length; i < len; i++){
11804 this.data = this.snapshot;
11805 delete this.snapshot;
11808 this.data.addAll(r);
11809 this.totalLength = t;
11811 this.fireEvent("datachanged", this);
11813 this.totalLength = Math.max(t, this.data.length+r.length);
11817 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
11819 var e = new Roo.data.Record({});
11821 e.set(this.parent.displayField, this.parent.emptyTitle);
11822 e.set(this.parent.valueField, '');
11827 this.fireEvent("load", this, r, options, o);
11828 if(options.callback){
11829 options.callback.call(options.scope || this, r, options, true);
11835 * Loads data from a passed data block. A Reader which understands the format of the data
11836 * must have been configured in the constructor.
11837 * @param {Object} data The data block from which to read the Records. The format of the data expected
11838 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
11839 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
11841 loadData : function(o, append){
11842 var r = this.reader.readRecords(o);
11843 this.loadRecords(r, {add: append}, true);
11847 * Gets the number of cached records.
11849 * <em>If using paging, this may not be the total size of the dataset. If the data object
11850 * used by the Reader contains the dataset size, then the getTotalCount() function returns
11851 * the data set size</em>
11853 getCount : function(){
11854 return this.data.length || 0;
11858 * Gets the total number of records in the dataset as returned by the server.
11860 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
11861 * the dataset size</em>
11863 getTotalCount : function(){
11864 return this.totalLength || 0;
11868 * Returns the sort state of the Store as an object with two properties:
11870 field {String} The name of the field by which the Records are sorted
11871 direction {String} The sort order, "ASC" or "DESC"
11874 getSortState : function(){
11875 return this.sortInfo;
11879 applySort : function(){
11880 if(this.sortInfo && !this.remoteSort){
11881 var s = this.sortInfo, f = s.field;
11882 var st = this.fields.get(f).sortType;
11883 var fn = function(r1, r2){
11884 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
11885 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
11887 this.data.sort(s.direction, fn);
11888 if(this.snapshot && this.snapshot != this.data){
11889 this.snapshot.sort(s.direction, fn);
11895 * Sets the default sort column and order to be used by the next load operation.
11896 * @param {String} fieldName The name of the field to sort by.
11897 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11899 setDefaultSort : function(field, dir){
11900 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
11904 * Sort the Records.
11905 * If remote sorting is used, the sort is performed on the server, and the cache is
11906 * reloaded. If local sorting is used, the cache is sorted internally.
11907 * @param {String} fieldName The name of the field to sort by.
11908 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11910 sort : function(fieldName, dir){
11911 var f = this.fields.get(fieldName);
11913 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
11915 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
11916 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
11921 this.sortToggle[f.name] = dir;
11922 this.sortInfo = {field: f.name, direction: dir};
11923 if(!this.remoteSort){
11925 this.fireEvent("datachanged", this);
11927 this.load(this.lastOptions);
11932 * Calls the specified function for each of the Records in the cache.
11933 * @param {Function} fn The function to call. The Record is passed as the first parameter.
11934 * Returning <em>false</em> aborts and exits the iteration.
11935 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
11937 each : function(fn, scope){
11938 this.data.each(fn, scope);
11942 * Gets all records modified since the last commit. Modified records are persisted across load operations
11943 * (e.g., during paging).
11944 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
11946 getModifiedRecords : function(){
11947 return this.modified;
11951 createFilterFn : function(property, value, anyMatch){
11952 if(!value.exec){ // not a regex
11953 value = String(value);
11954 if(value.length == 0){
11957 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
11959 return function(r){
11960 return value.test(r.data[property]);
11965 * Sums the value of <i>property</i> for each record between start and end and returns the result.
11966 * @param {String} property A field on your records
11967 * @param {Number} start The record index to start at (defaults to 0)
11968 * @param {Number} end The last record index to include (defaults to length - 1)
11969 * @return {Number} The sum
11971 sum : function(property, start, end){
11972 var rs = this.data.items, v = 0;
11973 start = start || 0;
11974 end = (end || end === 0) ? end : rs.length-1;
11976 for(var i = start; i <= end; i++){
11977 v += (rs[i].data[property] || 0);
11983 * Filter the records by a specified property.
11984 * @param {String} field A field on your records
11985 * @param {String/RegExp} value Either a string that the field
11986 * should start with or a RegExp to test against the field
11987 * @param {Boolean} anyMatch True to match any part not just the beginning
11989 filter : function(property, value, anyMatch){
11990 var fn = this.createFilterFn(property, value, anyMatch);
11991 return fn ? this.filterBy(fn) : this.clearFilter();
11995 * Filter by a function. The specified function will be called with each
11996 * record in this data source. If the function returns true the record is included,
11997 * otherwise it is filtered.
11998 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11999 * @param {Object} scope (optional) The scope of the function (defaults to this)
12001 filterBy : function(fn, scope){
12002 this.snapshot = this.snapshot || this.data;
12003 this.data = this.queryBy(fn, scope||this);
12004 this.fireEvent("datachanged", this);
12008 * Query the records by a specified property.
12009 * @param {String} field A field on your records
12010 * @param {String/RegExp} value Either a string that the field
12011 * should start with or a RegExp to test against the field
12012 * @param {Boolean} anyMatch True to match any part not just the beginning
12013 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
12015 query : function(property, value, anyMatch){
12016 var fn = this.createFilterFn(property, value, anyMatch);
12017 return fn ? this.queryBy(fn) : this.data.clone();
12021 * Query by a function. The specified function will be called with each
12022 * record in this data source. If the function returns true the record is included
12024 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
12025 * @param {Object} scope (optional) The scope of the function (defaults to this)
12026 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
12028 queryBy : function(fn, scope){
12029 var data = this.snapshot || this.data;
12030 return data.filterBy(fn, scope||this);
12034 * Collects unique values for a particular dataIndex from this store.
12035 * @param {String} dataIndex The property to collect
12036 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
12037 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
12038 * @return {Array} An array of the unique values
12040 collect : function(dataIndex, allowNull, bypassFilter){
12041 var d = (bypassFilter === true && this.snapshot) ?
12042 this.snapshot.items : this.data.items;
12043 var v, sv, r = [], l = {};
12044 for(var i = 0, len = d.length; i < len; i++){
12045 v = d[i].data[dataIndex];
12047 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
12056 * Revert to a view of the Record cache with no filtering applied.
12057 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
12059 clearFilter : function(suppressEvent){
12060 if(this.snapshot && this.snapshot != this.data){
12061 this.data = this.snapshot;
12062 delete this.snapshot;
12063 if(suppressEvent !== true){
12064 this.fireEvent("datachanged", this);
12070 afterEdit : function(record){
12071 if(this.modified.indexOf(record) == -1){
12072 this.modified.push(record);
12074 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
12078 afterReject : function(record){
12079 this.modified.remove(record);
12080 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
12084 afterCommit : function(record){
12085 this.modified.remove(record);
12086 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
12090 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
12091 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
12093 commitChanges : function(){
12094 var m = this.modified.slice(0);
12095 this.modified = [];
12096 for(var i = 0, len = m.length; i < len; i++){
12102 * Cancel outstanding changes on all changed records.
12104 rejectChanges : function(){
12105 var m = this.modified.slice(0);
12106 this.modified = [];
12107 for(var i = 0, len = m.length; i < len; i++){
12112 onMetaChange : function(meta, rtype, o){
12113 this.recordType = rtype;
12114 this.fields = rtype.prototype.fields;
12115 delete this.snapshot;
12116 this.sortInfo = meta.sortInfo || this.sortInfo;
12117 this.modified = [];
12118 this.fireEvent('metachange', this, this.reader.meta);
12121 moveIndex : function(data, type)
12123 var index = this.indexOf(data);
12125 var newIndex = index + type;
12129 this.insert(newIndex, data);
12134 * Ext JS Library 1.1.1
12135 * Copyright(c) 2006-2007, Ext JS, LLC.
12137 * Originally Released Under LGPL - original licence link has changed is not relivant.
12140 * <script type="text/javascript">
12144 * @class Roo.data.SimpleStore
12145 * @extends Roo.data.Store
12146 * Small helper class to make creating Stores from Array data easier.
12147 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
12148 * @cfg {Array} fields An array of field definition objects, or field name strings.
12149 * @cfg {Array} data The multi-dimensional array of data
12151 * @param {Object} config
12153 Roo.data.SimpleStore = function(config){
12154 Roo.data.SimpleStore.superclass.constructor.call(this, {
12156 reader: new Roo.data.ArrayReader({
12159 Roo.data.Record.create(config.fields)
12161 proxy : new Roo.data.MemoryProxy(config.data)
12165 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
12167 * Ext JS Library 1.1.1
12168 * Copyright(c) 2006-2007, Ext JS, LLC.
12170 * Originally Released Under LGPL - original licence link has changed is not relivant.
12173 * <script type="text/javascript">
12178 * @extends Roo.data.Store
12179 * @class Roo.data.JsonStore
12180 * Small helper class to make creating Stores for JSON data easier. <br/>
12182 var store = new Roo.data.JsonStore({
12183 url: 'get-images.php',
12185 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
12188 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
12189 * JsonReader and HttpProxy (unless inline data is provided).</b>
12190 * @cfg {Array} fields An array of field definition objects, or field name strings.
12192 * @param {Object} config
12194 Roo.data.JsonStore = function(c){
12195 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
12196 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
12197 reader: new Roo.data.JsonReader(c, c.fields)
12200 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
12202 * Ext JS Library 1.1.1
12203 * Copyright(c) 2006-2007, Ext JS, LLC.
12205 * Originally Released Under LGPL - original licence link has changed is not relivant.
12208 * <script type="text/javascript">
12212 Roo.data.Field = function(config){
12213 if(typeof config == "string"){
12214 config = {name: config};
12216 Roo.apply(this, config);
12219 this.type = "auto";
12222 var st = Roo.data.SortTypes;
12223 // named sortTypes are supported, here we look them up
12224 if(typeof this.sortType == "string"){
12225 this.sortType = st[this.sortType];
12228 // set default sortType for strings and dates
12229 if(!this.sortType){
12232 this.sortType = st.asUCString;
12235 this.sortType = st.asDate;
12238 this.sortType = st.none;
12243 var stripRe = /[\$,%]/g;
12245 // prebuilt conversion function for this field, instead of
12246 // switching every time we're reading a value
12248 var cv, dateFormat = this.dateFormat;
12253 cv = function(v){ return v; };
12256 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
12260 return v !== undefined && v !== null && v !== '' ?
12261 parseInt(String(v).replace(stripRe, ""), 10) : '';
12266 return v !== undefined && v !== null && v !== '' ?
12267 parseFloat(String(v).replace(stripRe, ""), 10) : '';
12272 cv = function(v){ return v === true || v === "true" || v == 1; };
12279 if(v instanceof Date){
12283 if(dateFormat == "timestamp"){
12284 return new Date(v*1000);
12286 return Date.parseDate(v, dateFormat);
12288 var parsed = Date.parse(v);
12289 return parsed ? new Date(parsed) : null;
12298 Roo.data.Field.prototype = {
12306 * Ext JS Library 1.1.1
12307 * Copyright(c) 2006-2007, Ext JS, LLC.
12309 * Originally Released Under LGPL - original licence link has changed is not relivant.
12312 * <script type="text/javascript">
12315 // Base class for reading structured data from a data source. This class is intended to be
12316 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
12319 * @class Roo.data.DataReader
12320 * Base class for reading structured data from a data source. This class is intended to be
12321 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
12324 Roo.data.DataReader = function(meta, recordType){
12328 this.recordType = recordType instanceof Array ?
12329 Roo.data.Record.create(recordType) : recordType;
12332 Roo.data.DataReader.prototype = {
12334 * Create an empty record
12335 * @param {Object} data (optional) - overlay some values
12336 * @return {Roo.data.Record} record created.
12338 newRow : function(d) {
12340 this.recordType.prototype.fields.each(function(c) {
12342 case 'int' : da[c.name] = 0; break;
12343 case 'date' : da[c.name] = new Date(); break;
12344 case 'float' : da[c.name] = 0.0; break;
12345 case 'boolean' : da[c.name] = false; break;
12346 default : da[c.name] = ""; break;
12350 return new this.recordType(Roo.apply(da, d));
12355 * Ext JS Library 1.1.1
12356 * Copyright(c) 2006-2007, Ext JS, LLC.
12358 * Originally Released Under LGPL - original licence link has changed is not relivant.
12361 * <script type="text/javascript">
12365 * @class Roo.data.DataProxy
12366 * @extends Roo.data.Observable
12367 * This class is an abstract base class for implementations which provide retrieval of
12368 * unformatted data objects.<br>
12370 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
12371 * (of the appropriate type which knows how to parse the data object) to provide a block of
12372 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
12374 * Custom implementations must implement the load method as described in
12375 * {@link Roo.data.HttpProxy#load}.
12377 Roo.data.DataProxy = function(){
12380 * @event beforeload
12381 * Fires before a network request is made to retrieve a data object.
12382 * @param {Object} This DataProxy object.
12383 * @param {Object} params The params parameter to the load function.
12388 * Fires before the load method's callback is called.
12389 * @param {Object} This DataProxy object.
12390 * @param {Object} o The data object.
12391 * @param {Object} arg The callback argument object passed to the load function.
12395 * @event loadexception
12396 * Fires if an Exception occurs during data retrieval.
12397 * @param {Object} This DataProxy object.
12398 * @param {Object} o The data object.
12399 * @param {Object} arg The callback argument object passed to the load function.
12400 * @param {Object} e The Exception.
12402 loadexception : true
12404 Roo.data.DataProxy.superclass.constructor.call(this);
12407 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
12410 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
12414 * Ext JS Library 1.1.1
12415 * Copyright(c) 2006-2007, Ext JS, LLC.
12417 * Originally Released Under LGPL - original licence link has changed is not relivant.
12420 * <script type="text/javascript">
12423 * @class Roo.data.MemoryProxy
12424 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
12425 * to the Reader when its load method is called.
12427 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
12429 Roo.data.MemoryProxy = function(data){
12433 Roo.data.MemoryProxy.superclass.constructor.call(this);
12437 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
12440 * Load data from the requested source (in this case an in-memory
12441 * data object passed to the constructor), read the data object into
12442 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12443 * process that block using the passed callback.
12444 * @param {Object} params This parameter is not used by the MemoryProxy class.
12445 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12446 * object into a block of Roo.data.Records.
12447 * @param {Function} callback The function into which to pass the block of Roo.data.records.
12448 * The function must be passed <ul>
12449 * <li>The Record block object</li>
12450 * <li>The "arg" argument from the load function</li>
12451 * <li>A boolean success indicator</li>
12453 * @param {Object} scope The scope in which to call the callback
12454 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12456 load : function(params, reader, callback, scope, arg){
12457 params = params || {};
12460 result = reader.readRecords(params.data ? params.data :this.data);
12462 this.fireEvent("loadexception", this, arg, null, e);
12463 callback.call(scope, null, arg, false);
12466 callback.call(scope, result, arg, true);
12470 update : function(params, records){
12475 * Ext JS Library 1.1.1
12476 * Copyright(c) 2006-2007, Ext JS, LLC.
12478 * Originally Released Under LGPL - original licence link has changed is not relivant.
12481 * <script type="text/javascript">
12484 * @class Roo.data.HttpProxy
12485 * @extends Roo.data.DataProxy
12486 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
12487 * configured to reference a certain URL.<br><br>
12489 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
12490 * from which the running page was served.<br><br>
12492 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
12494 * Be aware that to enable the browser to parse an XML document, the server must set
12495 * the Content-Type header in the HTTP response to "text/xml".
12497 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
12498 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
12499 * will be used to make the request.
12501 Roo.data.HttpProxy = function(conn){
12502 Roo.data.HttpProxy.superclass.constructor.call(this);
12503 // is conn a conn config or a real conn?
12505 this.useAjax = !conn || !conn.events;
12509 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
12510 // thse are take from connection...
12513 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
12516 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
12517 * extra parameters to each request made by this object. (defaults to undefined)
12520 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
12521 * to each request made by this object. (defaults to undefined)
12524 * @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)
12527 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
12530 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
12536 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
12540 * Return the {@link Roo.data.Connection} object being used by this Proxy.
12541 * @return {Connection} The Connection object. This object may be used to subscribe to events on
12542 * a finer-grained basis than the DataProxy events.
12544 getConnection : function(){
12545 return this.useAjax ? Roo.Ajax : this.conn;
12549 * Load data from the configured {@link Roo.data.Connection}, read the data object into
12550 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
12551 * process that block using the passed callback.
12552 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12553 * for the request to the remote server.
12554 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12555 * object into a block of Roo.data.Records.
12556 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12557 * The function must be passed <ul>
12558 * <li>The Record block object</li>
12559 * <li>The "arg" argument from the load function</li>
12560 * <li>A boolean success indicator</li>
12562 * @param {Object} scope The scope in which to call the callback
12563 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12565 load : function(params, reader, callback, scope, arg){
12566 if(this.fireEvent("beforeload", this, params) !== false){
12568 params : params || {},
12570 callback : callback,
12575 callback : this.loadResponse,
12579 Roo.applyIf(o, this.conn);
12580 if(this.activeRequest){
12581 Roo.Ajax.abort(this.activeRequest);
12583 this.activeRequest = Roo.Ajax.request(o);
12585 this.conn.request(o);
12588 callback.call(scope||this, null, arg, false);
12593 loadResponse : function(o, success, response){
12594 delete this.activeRequest;
12596 this.fireEvent("loadexception", this, o, response);
12597 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12602 result = o.reader.read(response);
12604 this.fireEvent("loadexception", this, o, response, e);
12605 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12609 this.fireEvent("load", this, o, o.request.arg);
12610 o.request.callback.call(o.request.scope, result, o.request.arg, true);
12614 update : function(dataSet){
12619 updateResponse : function(dataSet){
12624 * Ext JS Library 1.1.1
12625 * Copyright(c) 2006-2007, Ext JS, LLC.
12627 * Originally Released Under LGPL - original licence link has changed is not relivant.
12630 * <script type="text/javascript">
12634 * @class Roo.data.ScriptTagProxy
12635 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
12636 * other than the originating domain of the running page.<br><br>
12638 * <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
12639 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
12641 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
12642 * source code that is used as the source inside a <script> tag.<br><br>
12644 * In order for the browser to process the returned data, the server must wrap the data object
12645 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
12646 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
12647 * depending on whether the callback name was passed:
12650 boolean scriptTag = false;
12651 String cb = request.getParameter("callback");
12654 response.setContentType("text/javascript");
12656 response.setContentType("application/x-json");
12658 Writer out = response.getWriter();
12660 out.write(cb + "(");
12662 out.print(dataBlock.toJsonString());
12669 * @param {Object} config A configuration object.
12671 Roo.data.ScriptTagProxy = function(config){
12672 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
12673 Roo.apply(this, config);
12674 this.head = document.getElementsByTagName("head")[0];
12677 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
12679 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
12681 * @cfg {String} url The URL from which to request the data object.
12684 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
12688 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
12689 * the server the name of the callback function set up by the load call to process the returned data object.
12690 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
12691 * javascript output which calls this named function passing the data object as its only parameter.
12693 callbackParam : "callback",
12695 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
12696 * name to the request.
12701 * Load data from the configured URL, read the data object into
12702 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12703 * process that block using the passed callback.
12704 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12705 * for the request to the remote server.
12706 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12707 * object into a block of Roo.data.Records.
12708 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12709 * The function must be passed <ul>
12710 * <li>The Record block object</li>
12711 * <li>The "arg" argument from the load function</li>
12712 * <li>A boolean success indicator</li>
12714 * @param {Object} scope The scope in which to call the callback
12715 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12717 load : function(params, reader, callback, scope, arg){
12718 if(this.fireEvent("beforeload", this, params) !== false){
12720 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
12722 var url = this.url;
12723 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
12725 url += "&_dc=" + (new Date().getTime());
12727 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
12730 cb : "stcCallback"+transId,
12731 scriptId : "stcScript"+transId,
12735 callback : callback,
12741 window[trans.cb] = function(o){
12742 conn.handleResponse(o, trans);
12745 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
12747 if(this.autoAbort !== false){
12751 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
12753 var script = document.createElement("script");
12754 script.setAttribute("src", url);
12755 script.setAttribute("type", "text/javascript");
12756 script.setAttribute("id", trans.scriptId);
12757 this.head.appendChild(script);
12759 this.trans = trans;
12761 callback.call(scope||this, null, arg, false);
12766 isLoading : function(){
12767 return this.trans ? true : false;
12771 * Abort the current server request.
12773 abort : function(){
12774 if(this.isLoading()){
12775 this.destroyTrans(this.trans);
12780 destroyTrans : function(trans, isLoaded){
12781 this.head.removeChild(document.getElementById(trans.scriptId));
12782 clearTimeout(trans.timeoutId);
12784 window[trans.cb] = undefined;
12786 delete window[trans.cb];
12789 // if hasn't been loaded, wait for load to remove it to prevent script error
12790 window[trans.cb] = function(){
12791 window[trans.cb] = undefined;
12793 delete window[trans.cb];
12800 handleResponse : function(o, trans){
12801 this.trans = false;
12802 this.destroyTrans(trans, true);
12805 result = trans.reader.readRecords(o);
12807 this.fireEvent("loadexception", this, o, trans.arg, e);
12808 trans.callback.call(trans.scope||window, null, trans.arg, false);
12811 this.fireEvent("load", this, o, trans.arg);
12812 trans.callback.call(trans.scope||window, result, trans.arg, true);
12816 handleFailure : function(trans){
12817 this.trans = false;
12818 this.destroyTrans(trans, false);
12819 this.fireEvent("loadexception", this, null, trans.arg);
12820 trans.callback.call(trans.scope||window, null, trans.arg, false);
12824 * Ext JS Library 1.1.1
12825 * Copyright(c) 2006-2007, Ext JS, LLC.
12827 * Originally Released Under LGPL - original licence link has changed is not relivant.
12830 * <script type="text/javascript">
12834 * @class Roo.data.JsonReader
12835 * @extends Roo.data.DataReader
12836 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
12837 * based on mappings in a provided Roo.data.Record constructor.
12839 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
12840 * in the reply previously.
12845 var RecordDef = Roo.data.Record.create([
12846 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
12847 {name: 'occupation'} // This field will use "occupation" as the mapping.
12849 var myReader = new Roo.data.JsonReader({
12850 totalProperty: "results", // The property which contains the total dataset size (optional)
12851 root: "rows", // The property which contains an Array of row objects
12852 id: "id" // The property within each row object that provides an ID for the record (optional)
12856 * This would consume a JSON file like this:
12858 { 'results': 2, 'rows': [
12859 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
12860 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
12863 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
12864 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
12865 * paged from the remote server.
12866 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
12867 * @cfg {String} root name of the property which contains the Array of row objects.
12868 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
12869 * @cfg {Array} fields Array of field definition objects
12871 * Create a new JsonReader
12872 * @param {Object} meta Metadata configuration options
12873 * @param {Object} recordType Either an Array of field definition objects,
12874 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
12876 Roo.data.JsonReader = function(meta, recordType){
12879 // set some defaults:
12880 Roo.applyIf(meta, {
12881 totalProperty: 'total',
12882 successProperty : 'success',
12887 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
12889 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
12892 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
12893 * Used by Store query builder to append _requestMeta to params.
12896 metaFromRemote : false,
12898 * This method is only used by a DataProxy which has retrieved data from a remote server.
12899 * @param {Object} response The XHR object which contains the JSON data in its responseText.
12900 * @return {Object} data A data block which is used by an Roo.data.Store object as
12901 * a cache of Roo.data.Records.
12903 read : function(response){
12904 var json = response.responseText;
12906 var o = /* eval:var:o */ eval("("+json+")");
12908 throw {message: "JsonReader.read: Json object not found"};
12914 this.metaFromRemote = true;
12915 this.meta = o.metaData;
12916 this.recordType = Roo.data.Record.create(o.metaData.fields);
12917 this.onMetaChange(this.meta, this.recordType, o);
12919 return this.readRecords(o);
12922 // private function a store will implement
12923 onMetaChange : function(meta, recordType, o){
12930 simpleAccess: function(obj, subsc) {
12937 getJsonAccessor: function(){
12939 return function(expr) {
12941 return(re.test(expr))
12942 ? new Function("obj", "return obj." + expr)
12947 return Roo.emptyFn;
12952 * Create a data block containing Roo.data.Records from an XML document.
12953 * @param {Object} o An object which contains an Array of row objects in the property specified
12954 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
12955 * which contains the total size of the dataset.
12956 * @return {Object} data A data block which is used by an Roo.data.Store object as
12957 * a cache of Roo.data.Records.
12959 readRecords : function(o){
12961 * After any data loads, the raw JSON data is available for further custom processing.
12965 var s = this.meta, Record = this.recordType,
12966 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
12968 // Generate extraction functions for the totalProperty, the root, the id, and for each field
12970 if(s.totalProperty) {
12971 this.getTotal = this.getJsonAccessor(s.totalProperty);
12973 if(s.successProperty) {
12974 this.getSuccess = this.getJsonAccessor(s.successProperty);
12976 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
12978 var g = this.getJsonAccessor(s.id);
12979 this.getId = function(rec) {
12981 return (r === undefined || r === "") ? null : r;
12984 this.getId = function(){return null;};
12987 for(var jj = 0; jj < fl; jj++){
12989 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
12990 this.ef[jj] = this.getJsonAccessor(map);
12994 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
12995 if(s.totalProperty){
12996 var vt = parseInt(this.getTotal(o), 10);
13001 if(s.successProperty){
13002 var vs = this.getSuccess(o);
13003 if(vs === false || vs === 'false'){
13008 for(var i = 0; i < c; i++){
13011 var id = this.getId(n);
13012 for(var j = 0; j < fl; j++){
13014 var v = this.ef[j](n);
13016 Roo.log('missing convert for ' + f.name);
13020 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
13022 var record = new Record(values, id);
13024 records[i] = record;
13030 totalRecords : totalRecords
13035 * Ext JS Library 1.1.1
13036 * Copyright(c) 2006-2007, Ext JS, LLC.
13038 * Originally Released Under LGPL - original licence link has changed is not relivant.
13041 * <script type="text/javascript">
13045 * @class Roo.data.ArrayReader
13046 * @extends Roo.data.DataReader
13047 * Data reader class to create an Array of Roo.data.Record objects from an Array.
13048 * Each element of that Array represents a row of data fields. The
13049 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
13050 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
13054 var RecordDef = Roo.data.Record.create([
13055 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
13056 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
13058 var myReader = new Roo.data.ArrayReader({
13059 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
13063 * This would consume an Array like this:
13065 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
13069 * Create a new JsonReader
13070 * @param {Object} meta Metadata configuration options.
13071 * @param {Object|Array} recordType Either an Array of field definition objects
13073 * @cfg {Array} fields Array of field definition objects
13074 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
13075 * as specified to {@link Roo.data.Record#create},
13076 * or an {@link Roo.data.Record} object
13079 * created using {@link Roo.data.Record#create}.
13081 Roo.data.ArrayReader = function(meta, recordType){
13084 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType||meta.fields);
13087 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
13089 * Create a data block containing Roo.data.Records from an XML document.
13090 * @param {Object} o An Array of row objects which represents the dataset.
13091 * @return {Object} A data block which is used by an {@link Roo.data.Store} object as
13092 * a cache of Roo.data.Records.
13094 readRecords : function(o){
13095 var sid = this.meta ? this.meta.id : null;
13096 var recordType = this.recordType, fields = recordType.prototype.fields;
13099 for(var i = 0; i < root.length; i++){
13102 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
13103 for(var j = 0, jlen = fields.length; j < jlen; j++){
13104 var f = fields.items[j];
13105 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
13106 var v = n[k] !== undefined ? n[k] : f.defaultValue;
13108 values[f.name] = v;
13110 var record = new recordType(values, id);
13112 records[records.length] = record;
13116 totalRecords : records.length
13125 * @class Roo.bootstrap.ComboBox
13126 * @extends Roo.bootstrap.TriggerField
13127 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
13128 * @cfg {Boolean} append (true|false) default false
13129 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
13130 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
13131 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
13132 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
13133 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
13134 * @cfg {Boolean} animate default true
13135 * @cfg {Boolean} emptyResultText only for touch device
13136 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
13137 * @cfg {String} emptyTitle default ''
13139 * Create a new ComboBox.
13140 * @param {Object} config Configuration options
13142 Roo.bootstrap.ComboBox = function(config){
13143 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
13147 * Fires when the dropdown list is expanded
13148 * @param {Roo.bootstrap.ComboBox} combo This combo box
13153 * Fires when the dropdown list is collapsed
13154 * @param {Roo.bootstrap.ComboBox} combo This combo box
13158 * @event beforeselect
13159 * Fires before a list item is selected. Return false to cancel the selection.
13160 * @param {Roo.bootstrap.ComboBox} combo This combo box
13161 * @param {Roo.data.Record} record The data record returned from the underlying store
13162 * @param {Number} index The index of the selected item in the dropdown list
13164 'beforeselect' : true,
13167 * Fires when a list item is selected
13168 * @param {Roo.bootstrap.ComboBox} combo This combo box
13169 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
13170 * @param {Number} index The index of the selected item in the dropdown list
13174 * @event beforequery
13175 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
13176 * The event object passed has these properties:
13177 * @param {Roo.bootstrap.ComboBox} combo This combo box
13178 * @param {String} query The query
13179 * @param {Boolean} forceAll true to force "all" query
13180 * @param {Boolean} cancel true to cancel the query
13181 * @param {Object} e The query event object
13183 'beforequery': true,
13186 * Fires when the 'add' icon is pressed (add a listener to enable add button)
13187 * @param {Roo.bootstrap.ComboBox} combo This combo box
13192 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
13193 * @param {Roo.bootstrap.ComboBox} combo This combo box
13194 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
13199 * Fires when the remove value from the combobox array
13200 * @param {Roo.bootstrap.ComboBox} combo This combo box
13204 * @event afterremove
13205 * Fires when the remove value from the combobox array
13206 * @param {Roo.bootstrap.ComboBox} combo This combo box
13208 'afterremove' : true,
13210 * @event specialfilter
13211 * Fires when specialfilter
13212 * @param {Roo.bootstrap.ComboBox} combo This combo box
13214 'specialfilter' : true,
13217 * Fires when tick the element
13218 * @param {Roo.bootstrap.ComboBox} combo This combo box
13222 * @event touchviewdisplay
13223 * Fires when touch view require special display (default is using displayField)
13224 * @param {Roo.bootstrap.ComboBox} combo This combo box
13225 * @param {Object} cfg set html .
13227 'touchviewdisplay' : true
13232 this.tickItems = [];
13234 this.selectedIndex = -1;
13235 if(this.mode == 'local'){
13236 if(config.queryDelay === undefined){
13237 this.queryDelay = 10;
13239 if(config.minChars === undefined){
13245 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
13248 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
13249 * rendering into an Roo.Editor, defaults to false)
13252 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
13253 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
13256 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
13259 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
13260 * the dropdown list (defaults to undefined, with no header element)
13264 * @cfg {String/Roo.Template} tpl The template to use to render the output
13268 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
13270 listWidth: undefined,
13272 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
13273 * mode = 'remote' or 'text' if mode = 'local')
13275 displayField: undefined,
13278 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
13279 * mode = 'remote' or 'value' if mode = 'local').
13280 * Note: use of a valueField requires the user make a selection
13281 * in order for a value to be mapped.
13283 valueField: undefined,
13285 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
13290 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
13291 * field's data value (defaults to the underlying DOM element's name)
13293 hiddenName: undefined,
13295 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
13299 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
13301 selectedClass: 'active',
13304 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
13308 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
13309 * anchor positions (defaults to 'tl-bl')
13311 listAlign: 'tl-bl?',
13313 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
13317 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
13318 * query specified by the allQuery config option (defaults to 'query')
13320 triggerAction: 'query',
13322 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
13323 * (defaults to 4, does not apply if editable = false)
13327 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
13328 * delay (typeAheadDelay) if it matches a known value (defaults to false)
13332 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
13333 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
13337 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
13338 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
13342 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
13343 * when editable = true (defaults to false)
13345 selectOnFocus:false,
13347 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
13349 queryParam: 'query',
13351 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
13352 * when mode = 'remote' (defaults to 'Loading...')
13354 loadingText: 'Loading...',
13356 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
13360 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
13364 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
13365 * traditional select (defaults to true)
13369 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
13373 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
13377 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
13378 * listWidth has a higher value)
13382 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
13383 * allow the user to set arbitrary text into the field (defaults to false)
13385 forceSelection:false,
13387 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
13388 * if typeAhead = true (defaults to 250)
13390 typeAheadDelay : 250,
13392 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
13393 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
13395 valueNotFoundText : undefined,
13397 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
13399 blockFocus : false,
13402 * @cfg {Boolean} disableClear Disable showing of clear button.
13404 disableClear : false,
13406 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
13408 alwaysQuery : false,
13411 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
13416 * @cfg {String} invalidClass DEPRICATED - uses BS4 is-valid now
13418 invalidClass : "has-warning",
13421 * @cfg {String} validClass DEPRICATED - uses BS4 is-valid now
13423 validClass : "has-success",
13426 * @cfg {Boolean} specialFilter (true|false) special filter default false
13428 specialFilter : false,
13431 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
13433 mobileTouchView : true,
13436 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
13438 useNativeIOS : false,
13441 * @cfg {Boolean} mobile_restrict_height (true|false) restrict height for touch view
13443 mobile_restrict_height : false,
13445 ios_options : false,
13457 btnPosition : 'right',
13458 triggerList : true,
13459 showToggleBtn : true,
13461 emptyResultText: 'Empty',
13462 triggerText : 'Select',
13465 // element that contains real text value.. (when hidden is used..)
13467 getAutoCreate : function()
13472 * Render classic select for iso
13475 if(Roo.isIOS && this.useNativeIOS){
13476 cfg = this.getAutoCreateNativeIOS();
13484 if(Roo.isTouch && this.mobileTouchView){
13485 cfg = this.getAutoCreateTouchView();
13492 if(!this.tickable){
13493 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
13498 * ComboBox with tickable selections
13501 var align = this.labelAlign || this.parentLabelAlign();
13504 cls : 'form-group roo-combobox-tickable' //input-group
13507 var btn_text_select = '';
13508 var btn_text_done = '';
13509 var btn_text_cancel = '';
13511 if (this.btn_text_show) {
13512 btn_text_select = 'Select';
13513 btn_text_done = 'Done';
13514 btn_text_cancel = 'Cancel';
13519 cls : 'tickable-buttons',
13524 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
13525 //html : this.triggerText
13526 html: btn_text_select
13532 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
13534 html: btn_text_done
13540 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
13542 html: btn_text_cancel
13548 buttons.cn.unshift({
13550 cls: 'roo-select2-search-field-input'
13556 Roo.each(buttons.cn, function(c){
13558 c.cls += ' btn-' + _this.size;
13561 if (_this.disabled) {
13568 style : 'display: contents',
13573 cls: 'form-hidden-field'
13577 cls: 'roo-select2-choices',
13581 cls: 'roo-select2-search-field',
13592 cls: 'roo-select2-container input-group roo-select2-container-multi',
13598 // cls: 'typeahead typeahead-long dropdown-menu',
13599 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
13604 if(this.hasFeedback && !this.allowBlank){
13608 cls: 'glyphicon form-control-feedback'
13611 combobox.cn.push(feedback);
13616 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
13617 tooltip : 'This field is required'
13619 if (Roo.bootstrap.version == 4) {
13622 style : 'display:none'
13625 if (align ==='left' && this.fieldLabel.length) {
13627 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
13634 cls : 'control-label col-form-label',
13635 html : this.fieldLabel
13647 var labelCfg = cfg.cn[1];
13648 var contentCfg = cfg.cn[2];
13651 if(this.indicatorpos == 'right'){
13657 cls : 'control-label col-form-label',
13661 html : this.fieldLabel
13677 labelCfg = cfg.cn[0];
13678 contentCfg = cfg.cn[1];
13682 if(this.labelWidth > 12){
13683 labelCfg.style = "width: " + this.labelWidth + 'px';
13686 if(this.labelWidth < 13 && this.labelmd == 0){
13687 this.labelmd = this.labelWidth;
13690 if(this.labellg > 0){
13691 labelCfg.cls += ' col-lg-' + this.labellg;
13692 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
13695 if(this.labelmd > 0){
13696 labelCfg.cls += ' col-md-' + this.labelmd;
13697 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
13700 if(this.labelsm > 0){
13701 labelCfg.cls += ' col-sm-' + this.labelsm;
13702 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
13705 if(this.labelxs > 0){
13706 labelCfg.cls += ' col-xs-' + this.labelxs;
13707 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
13711 } else if ( this.fieldLabel.length) {
13712 // Roo.log(" label");
13717 //cls : 'input-group-addon',
13718 html : this.fieldLabel
13723 if(this.indicatorpos == 'right'){
13727 //cls : 'input-group-addon',
13728 html : this.fieldLabel
13738 // Roo.log(" no label && no align");
13745 ['xs','sm','md','lg'].map(function(size){
13746 if (settings[size]) {
13747 cfg.cls += ' col-' + size + '-' + settings[size];
13755 _initEventsCalled : false,
13758 initEvents: function()
13760 if (this._initEventsCalled) { // as we call render... prevent looping...
13763 this._initEventsCalled = true;
13766 throw "can not find store for combo";
13769 this.indicator = this.indicatorEl();
13771 this.store = Roo.factory(this.store, Roo.data);
13772 this.store.parent = this;
13774 // if we are building from html. then this element is so complex, that we can not really
13775 // use the rendered HTML.
13776 // so we have to trash and replace the previous code.
13777 if (Roo.XComponent.build_from_html) {
13778 // remove this element....
13779 var e = this.el.dom, k=0;
13780 while (e ) { e = e.previousSibling; ++k;}
13785 this.rendered = false;
13787 this.render(this.parent().getChildContainer(true), k);
13790 if(Roo.isIOS && this.useNativeIOS){
13791 this.initIOSView();
13799 if(Roo.isTouch && this.mobileTouchView){
13800 this.initTouchView();
13805 this.initTickableEvents();
13809 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
13811 if(this.hiddenName){
13813 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13815 this.hiddenField.dom.value =
13816 this.hiddenValue !== undefined ? this.hiddenValue :
13817 this.value !== undefined ? this.value : '';
13819 // prevent input submission
13820 this.el.dom.removeAttribute('name');
13821 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13826 // this.el.dom.setAttribute('autocomplete', 'off');
13829 var cls = 'x-combo-list';
13831 //this.list = new Roo.Layer({
13832 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
13838 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13839 _this.list.setWidth(lw);
13842 this.list.on('mouseover', this.onViewOver, this);
13843 this.list.on('mousemove', this.onViewMove, this);
13844 this.list.on('scroll', this.onViewScroll, this);
13847 this.list.swallowEvent('mousewheel');
13848 this.assetHeight = 0;
13851 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
13852 this.assetHeight += this.header.getHeight();
13855 this.innerList = this.list.createChild({cls:cls+'-inner'});
13856 this.innerList.on('mouseover', this.onViewOver, this);
13857 this.innerList.on('mousemove', this.onViewMove, this);
13858 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13860 if(this.allowBlank && !this.pageSize && !this.disableClear){
13861 this.footer = this.list.createChild({cls:cls+'-ft'});
13862 this.pageTb = new Roo.Toolbar(this.footer);
13866 this.footer = this.list.createChild({cls:cls+'-ft'});
13867 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
13868 {pageSize: this.pageSize});
13872 if (this.pageTb && this.allowBlank && !this.disableClear) {
13874 this.pageTb.add(new Roo.Toolbar.Fill(), {
13875 cls: 'x-btn-icon x-btn-clear',
13877 handler: function()
13880 _this.clearValue();
13881 _this.onSelect(false, -1);
13886 this.assetHeight += this.footer.getHeight();
13891 this.tpl = Roo.bootstrap.version == 4 ?
13892 '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>' : // 4 does not need <li> and it get's really confisued.
13893 '<li><a class="dropdown-item" href="#">{' + this.displayField + '}</a></li>';
13896 this.view = new Roo.View(this.list, this.tpl, {
13897 singleSelect:true, store: this.store, selectedClass: this.selectedClass
13899 //this.view.wrapEl.setDisplayed(false);
13900 this.view.on('click', this.onViewClick, this);
13903 this.store.on('beforeload', this.onBeforeLoad, this);
13904 this.store.on('load', this.onLoad, this);
13905 this.store.on('loadexception', this.onLoadException, this);
13907 if(this.resizable){
13908 this.resizer = new Roo.Resizable(this.list, {
13909 pinned:true, handles:'se'
13911 this.resizer.on('resize', function(r, w, h){
13912 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
13913 this.listWidth = w;
13914 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
13915 this.restrictHeight();
13917 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
13920 if(!this.editable){
13921 this.editable = true;
13922 this.setEditable(false);
13927 if (typeof(this.events.add.listeners) != 'undefined') {
13929 this.addicon = this.wrap.createChild(
13930 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
13932 this.addicon.on('click', function(e) {
13933 this.fireEvent('add', this);
13936 if (typeof(this.events.edit.listeners) != 'undefined') {
13938 this.editicon = this.wrap.createChild(
13939 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
13940 if (this.addicon) {
13941 this.editicon.setStyle('margin-left', '40px');
13943 this.editicon.on('click', function(e) {
13945 // we fire even if inothing is selected..
13946 this.fireEvent('edit', this, this.lastData );
13952 this.keyNav = new Roo.KeyNav(this.inputEl(), {
13953 "up" : function(e){
13954 this.inKeyMode = true;
13958 "down" : function(e){
13959 if(!this.isExpanded()){
13960 this.onTriggerClick();
13962 this.inKeyMode = true;
13967 "enter" : function(e){
13968 // this.onViewClick();
13972 if(this.fireEvent("specialkey", this, e)){
13973 this.onViewClick(false);
13979 "esc" : function(e){
13983 "tab" : function(e){
13986 if(this.fireEvent("specialkey", this, e)){
13987 this.onViewClick(false);
13995 doRelay : function(foo, bar, hname){
13996 if(hname == 'down' || this.scope.isExpanded()){
13997 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
14006 this.queryDelay = Math.max(this.queryDelay || 10,
14007 this.mode == 'local' ? 10 : 250);
14010 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
14012 if(this.typeAhead){
14013 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
14015 if(this.editable !== false){
14016 this.inputEl().on("keyup", this.onKeyUp, this);
14018 if(this.forceSelection){
14019 this.inputEl().on('blur', this.doForce, this);
14023 this.choices = this.el.select('ul.roo-select2-choices', true).first();
14024 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
14028 initTickableEvents: function()
14032 if(this.hiddenName){
14034 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
14036 this.hiddenField.dom.value =
14037 this.hiddenValue !== undefined ? this.hiddenValue :
14038 this.value !== undefined ? this.value : '';
14040 // prevent input submission
14041 this.el.dom.removeAttribute('name');
14042 this.hiddenField.dom.setAttribute('name', this.hiddenName);
14047 // this.list = this.el.select('ul.dropdown-menu',true).first();
14049 this.choices = this.el.select('ul.roo-select2-choices', true).first();
14050 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
14051 if(this.triggerList){
14052 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
14055 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
14056 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
14058 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
14059 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
14061 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
14062 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
14064 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
14065 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
14066 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
14069 this.cancelBtn.hide();
14074 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
14075 _this.list.setWidth(lw);
14078 this.list.on('mouseover', this.onViewOver, this);
14079 this.list.on('mousemove', this.onViewMove, this);
14081 this.list.on('scroll', this.onViewScroll, this);
14084 this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}"' +
14085 'type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
14088 this.view = new Roo.View(this.list, this.tpl, {
14093 selectedClass: this.selectedClass
14096 //this.view.wrapEl.setDisplayed(false);
14097 this.view.on('click', this.onViewClick, this);
14101 this.store.on('beforeload', this.onBeforeLoad, this);
14102 this.store.on('load', this.onLoad, this);
14103 this.store.on('loadexception', this.onLoadException, this);
14106 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
14107 "up" : function(e){
14108 this.inKeyMode = true;
14112 "down" : function(e){
14113 this.inKeyMode = true;
14117 "enter" : function(e){
14118 if(this.fireEvent("specialkey", this, e)){
14119 this.onViewClick(false);
14125 "esc" : function(e){
14126 this.onTickableFooterButtonClick(e, false, false);
14129 "tab" : function(e){
14130 this.fireEvent("specialkey", this, e);
14132 this.onTickableFooterButtonClick(e, false, false);
14139 doRelay : function(e, fn, key){
14140 if(this.scope.isExpanded()){
14141 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
14150 this.queryDelay = Math.max(this.queryDelay || 10,
14151 this.mode == 'local' ? 10 : 250);
14154 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
14156 if(this.typeAhead){
14157 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
14160 if(this.editable !== false){
14161 this.tickableInputEl().on("keyup", this.onKeyUp, this);
14164 this.indicator = this.indicatorEl();
14166 if(this.indicator){
14167 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
14168 this.indicator.hide();
14173 onDestroy : function(){
14175 this.view.setStore(null);
14176 this.view.el.removeAllListeners();
14177 this.view.el.remove();
14178 this.view.purgeListeners();
14181 this.list.dom.innerHTML = '';
14185 this.store.un('beforeload', this.onBeforeLoad, this);
14186 this.store.un('load', this.onLoad, this);
14187 this.store.un('loadexception', this.onLoadException, this);
14189 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
14193 fireKey : function(e){
14194 if(e.isNavKeyPress() && !this.list.isVisible()){
14195 this.fireEvent("specialkey", this, e);
14200 onResize: function(w, h){
14201 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
14203 // if(typeof w != 'number'){
14204 // // we do not handle it!?!?
14207 // var tw = this.trigger.getWidth();
14208 // // tw += this.addicon ? this.addicon.getWidth() : 0;
14209 // // tw += this.editicon ? this.editicon.getWidth() : 0;
14211 // this.inputEl().setWidth( this.adjustWidth('input', x));
14213 // //this.trigger.setStyle('left', x+'px');
14215 // if(this.list && this.listWidth === undefined){
14216 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
14217 // this.list.setWidth(lw);
14218 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
14226 * Allow or prevent the user from directly editing the field text. If false is passed,
14227 * the user will only be able to select from the items defined in the dropdown list. This method
14228 * is the runtime equivalent of setting the 'editable' config option at config time.
14229 * @param {Boolean} value True to allow the user to directly edit the field text
14231 setEditable : function(value){
14232 if(value == this.editable){
14235 this.editable = value;
14237 this.inputEl().dom.setAttribute('readOnly', true);
14238 this.inputEl().on('mousedown', this.onTriggerClick, this);
14239 this.inputEl().addClass('x-combo-noedit');
14241 this.inputEl().dom.setAttribute('readOnly', false);
14242 this.inputEl().un('mousedown', this.onTriggerClick, this);
14243 this.inputEl().removeClass('x-combo-noedit');
14249 onBeforeLoad : function(combo,opts){
14250 if(!this.hasFocus){
14254 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
14256 this.restrictHeight();
14257 this.selectedIndex = -1;
14261 onLoad : function(){
14263 this.hasQuery = false;
14265 if(!this.hasFocus){
14269 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
14270 this.loading.hide();
14273 if(this.store.getCount() > 0){
14276 this.restrictHeight();
14277 if(this.lastQuery == this.allQuery){
14278 if(this.editable && !this.tickable){
14279 this.inputEl().dom.select();
14283 !this.selectByValue(this.value, true) &&
14286 !this.store.lastOptions ||
14287 typeof(this.store.lastOptions.add) == 'undefined' ||
14288 this.store.lastOptions.add != true
14291 this.select(0, true);
14294 if(this.autoFocus){
14297 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
14298 this.taTask.delay(this.typeAheadDelay);
14302 this.onEmptyResults();
14308 onLoadException : function()
14310 this.hasQuery = false;
14312 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
14313 this.loading.hide();
14316 if(this.tickable && this.editable){
14321 // only causes errors at present
14322 //Roo.log(this.store.reader.jsonData);
14323 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
14325 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
14331 onTypeAhead : function(){
14332 if(this.store.getCount() > 0){
14333 var r = this.store.getAt(0);
14334 var newValue = r.data[this.displayField];
14335 var len = newValue.length;
14336 var selStart = this.getRawValue().length;
14338 if(selStart != len){
14339 this.setRawValue(newValue);
14340 this.selectText(selStart, newValue.length);
14346 onSelect : function(record, index){
14348 if(this.fireEvent('beforeselect', this, record, index) !== false){
14350 this.setFromData(index > -1 ? record.data : false);
14353 this.fireEvent('select', this, record, index);
14358 * Returns the currently selected field value or empty string if no value is set.
14359 * @return {String} value The selected value
14361 getValue : function()
14363 if(Roo.isIOS && this.useNativeIOS){
14364 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
14368 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
14371 if(this.valueField){
14372 return typeof this.value != 'undefined' ? this.value : '';
14374 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
14378 getRawValue : function()
14380 if(Roo.isIOS && this.useNativeIOS){
14381 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
14384 var v = this.inputEl().getValue();
14390 * Clears any text/value currently set in the field
14392 clearValue : function(){
14394 if(this.hiddenField){
14395 this.hiddenField.dom.value = '';
14398 this.setRawValue('');
14399 this.lastSelectionText = '';
14400 this.lastData = false;
14402 var close = this.closeTriggerEl();
14413 * Sets the specified value into the field. If the value finds a match, the corresponding record text
14414 * will be displayed in the field. If the value does not match the data value of an existing item,
14415 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
14416 * Otherwise the field will be blank (although the value will still be set).
14417 * @param {String} value The value to match
14419 setValue : function(v)
14421 if(Roo.isIOS && this.useNativeIOS){
14422 this.setIOSValue(v);
14432 if(this.valueField){
14433 var r = this.findRecord(this.valueField, v);
14435 text = r.data[this.displayField];
14436 }else if(this.valueNotFoundText !== undefined){
14437 text = this.valueNotFoundText;
14440 this.lastSelectionText = text;
14441 if(this.hiddenField){
14442 this.hiddenField.dom.value = v;
14444 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
14447 var close = this.closeTriggerEl();
14450 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
14456 * @property {Object} the last set data for the element
14461 * Sets the value of the field based on a object which is related to the record format for the store.
14462 * @param {Object} value the value to set as. or false on reset?
14464 setFromData : function(o){
14471 var dv = ''; // display value
14472 var vv = ''; // value value..
14474 if (this.displayField) {
14475 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14477 // this is an error condition!!!
14478 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
14481 if(this.valueField){
14482 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
14485 var close = this.closeTriggerEl();
14488 if(dv.length || vv * 1 > 0){
14490 this.blockFocus=true;
14496 if(this.hiddenField){
14497 this.hiddenField.dom.value = vv;
14499 this.lastSelectionText = dv;
14500 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
14504 // no hidden field.. - we store the value in 'value', but still display
14505 // display field!!!!
14506 this.lastSelectionText = dv;
14507 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
14514 reset : function(){
14515 // overridden so that last data is reset..
14522 this.setValue(this.originalValue);
14523 //this.clearInvalid();
14524 this.lastData = false;
14526 this.view.clearSelections();
14532 findRecord : function(prop, value){
14534 if(this.store.getCount() > 0){
14535 this.store.each(function(r){
14536 if(r.data[prop] == value){
14546 getName: function()
14548 // returns hidden if it's set..
14549 if (!this.rendered) {return ''};
14550 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
14554 onViewMove : function(e, t){
14555 this.inKeyMode = false;
14559 onViewOver : function(e, t){
14560 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
14563 var item = this.view.findItemFromChild(t);
14566 var index = this.view.indexOf(item);
14567 this.select(index, false);
14572 onViewClick : function(view, doFocus, el, e)
14574 var index = this.view.getSelectedIndexes()[0];
14576 var r = this.store.getAt(index);
14580 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
14587 Roo.each(this.tickItems, function(v,k){
14589 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
14591 _this.tickItems.splice(k, 1);
14593 if(typeof(e) == 'undefined' && view == false){
14594 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
14606 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
14607 this.tickItems.push(r.data);
14610 if(typeof(e) == 'undefined' && view == false){
14611 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
14618 this.onSelect(r, index);
14620 if(doFocus !== false && !this.blockFocus){
14621 this.inputEl().focus();
14626 restrictHeight : function(){
14627 //this.innerList.dom.style.height = '';
14628 //var inner = this.innerList.dom;
14629 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
14630 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
14631 //this.list.beginUpdate();
14632 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
14633 this.list.alignTo(this.inputEl(), this.listAlign);
14634 this.list.alignTo(this.inputEl(), this.listAlign);
14635 //this.list.endUpdate();
14639 onEmptyResults : function(){
14641 if(this.tickable && this.editable){
14642 this.hasFocus = false;
14643 this.restrictHeight();
14651 * Returns true if the dropdown list is expanded, else false.
14653 isExpanded : function(){
14654 return this.list.isVisible();
14658 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
14659 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14660 * @param {String} value The data value of the item to select
14661 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14662 * selected item if it is not currently in view (defaults to true)
14663 * @return {Boolean} True if the value matched an item in the list, else false
14665 selectByValue : function(v, scrollIntoView){
14666 if(v !== undefined && v !== null){
14667 var r = this.findRecord(this.valueField || this.displayField, v);
14669 this.select(this.store.indexOf(r), scrollIntoView);
14677 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
14678 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14679 * @param {Number} index The zero-based index of the list item to select
14680 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14681 * selected item if it is not currently in view (defaults to true)
14683 select : function(index, scrollIntoView){
14684 this.selectedIndex = index;
14685 this.view.select(index);
14686 if(scrollIntoView !== false){
14687 var el = this.view.getNode(index);
14689 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
14692 this.list.scrollChildIntoView(el, false);
14698 selectNext : function(){
14699 var ct = this.store.getCount();
14701 if(this.selectedIndex == -1){
14703 }else if(this.selectedIndex < ct-1){
14704 this.select(this.selectedIndex+1);
14710 selectPrev : function(){
14711 var ct = this.store.getCount();
14713 if(this.selectedIndex == -1){
14715 }else if(this.selectedIndex != 0){
14716 this.select(this.selectedIndex-1);
14722 onKeyUp : function(e){
14723 if(this.editable !== false && !e.isSpecialKey()){
14724 this.lastKey = e.getKey();
14725 this.dqTask.delay(this.queryDelay);
14730 validateBlur : function(){
14731 return !this.list || !this.list.isVisible();
14735 initQuery : function(){
14737 var v = this.getRawValue();
14739 if(this.tickable && this.editable){
14740 v = this.tickableInputEl().getValue();
14747 doForce : function(){
14748 if(this.inputEl().dom.value.length > 0){
14749 this.inputEl().dom.value =
14750 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
14756 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
14757 * query allowing the query action to be canceled if needed.
14758 * @param {String} query The SQL query to execute
14759 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
14760 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
14761 * saved in the current store (defaults to false)
14763 doQuery : function(q, forceAll){
14765 if(q === undefined || q === null){
14770 forceAll: forceAll,
14774 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
14779 forceAll = qe.forceAll;
14780 if(forceAll === true || (q.length >= this.minChars)){
14782 this.hasQuery = true;
14784 if(this.lastQuery != q || this.alwaysQuery){
14785 this.lastQuery = q;
14786 if(this.mode == 'local'){
14787 this.selectedIndex = -1;
14789 this.store.clearFilter();
14792 if(this.specialFilter){
14793 this.fireEvent('specialfilter', this);
14798 this.store.filter(this.displayField, q);
14801 this.store.fireEvent("datachanged", this.store);
14808 this.store.baseParams[this.queryParam] = q;
14810 var options = {params : this.getParams(q)};
14813 options.add = true;
14814 options.params.start = this.page * this.pageSize;
14817 this.store.load(options);
14820 * this code will make the page width larger, at the beginning, the list not align correctly,
14821 * we should expand the list on onLoad
14822 * so command out it
14827 this.selectedIndex = -1;
14832 this.loadNext = false;
14836 getParams : function(q){
14838 //p[this.queryParam] = q;
14842 p.limit = this.pageSize;
14848 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
14850 collapse : function(){
14851 if(!this.isExpanded()){
14857 this.hasFocus = false;
14861 this.cancelBtn.hide();
14862 this.trigger.show();
14865 this.tickableInputEl().dom.value = '';
14866 this.tickableInputEl().blur();
14871 Roo.get(document).un('mousedown', this.collapseIf, this);
14872 Roo.get(document).un('mousewheel', this.collapseIf, this);
14873 if (!this.editable) {
14874 Roo.get(document).un('keydown', this.listKeyPress, this);
14876 this.fireEvent('collapse', this);
14882 collapseIf : function(e){
14883 var in_combo = e.within(this.el);
14884 var in_list = e.within(this.list);
14885 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
14887 if (in_combo || in_list || is_list) {
14888 //e.stopPropagation();
14893 this.onTickableFooterButtonClick(e, false, false);
14901 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
14903 expand : function(){
14905 if(this.isExpanded() || !this.hasFocus){
14909 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
14910 this.list.setWidth(lw);
14916 this.restrictHeight();
14920 this.tickItems = Roo.apply([], this.item);
14923 this.cancelBtn.show();
14924 this.trigger.hide();
14927 this.tickableInputEl().focus();
14932 Roo.get(document).on('mousedown', this.collapseIf, this);
14933 Roo.get(document).on('mousewheel', this.collapseIf, this);
14934 if (!this.editable) {
14935 Roo.get(document).on('keydown', this.listKeyPress, this);
14938 this.fireEvent('expand', this);
14942 // Implements the default empty TriggerField.onTriggerClick function
14943 onTriggerClick : function(e)
14945 Roo.log('trigger click');
14947 if(this.disabled || !this.triggerList){
14952 this.loadNext = false;
14954 if(this.isExpanded()){
14956 if (!this.blockFocus) {
14957 this.inputEl().focus();
14961 this.hasFocus = true;
14962 if(this.triggerAction == 'all') {
14963 this.doQuery(this.allQuery, true);
14965 this.doQuery(this.getRawValue());
14967 if (!this.blockFocus) {
14968 this.inputEl().focus();
14973 onTickableTriggerClick : function(e)
14980 this.loadNext = false;
14981 this.hasFocus = true;
14983 if(this.triggerAction == 'all') {
14984 this.doQuery(this.allQuery, true);
14986 this.doQuery(this.getRawValue());
14990 onSearchFieldClick : function(e)
14992 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
14993 this.onTickableFooterButtonClick(e, false, false);
14997 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
15002 this.loadNext = false;
15003 this.hasFocus = true;
15005 if(this.triggerAction == 'all') {
15006 this.doQuery(this.allQuery, true);
15008 this.doQuery(this.getRawValue());
15012 listKeyPress : function(e)
15014 //Roo.log('listkeypress');
15015 // scroll to first matching element based on key pres..
15016 if (e.isSpecialKey()) {
15019 var k = String.fromCharCode(e.getKey()).toUpperCase();
15022 var csel = this.view.getSelectedNodes();
15023 var cselitem = false;
15025 var ix = this.view.indexOf(csel[0]);
15026 cselitem = this.store.getAt(ix);
15027 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
15033 this.store.each(function(v) {
15035 // start at existing selection.
15036 if (cselitem.id == v.id) {
15042 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
15043 match = this.store.indexOf(v);
15049 if (match === false) {
15050 return true; // no more action?
15053 this.view.select(match);
15054 var sn = Roo.get(this.view.getSelectedNodes()[0]);
15055 sn.scrollIntoView(sn.dom.parentNode, false);
15058 onViewScroll : function(e, t){
15060 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){
15064 this.hasQuery = true;
15066 this.loading = this.list.select('.loading', true).first();
15068 if(this.loading === null){
15069 this.list.createChild({
15071 cls: 'loading roo-select2-more-results roo-select2-active',
15072 html: 'Loading more results...'
15075 this.loading = this.list.select('.loading', true).first();
15077 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
15079 this.loading.hide();
15082 this.loading.show();
15087 this.loadNext = true;
15089 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
15094 addItem : function(o)
15096 var dv = ''; // display value
15098 if (this.displayField) {
15099 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
15101 // this is an error condition!!!
15102 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
15109 var choice = this.choices.createChild({
15111 cls: 'roo-select2-search-choice',
15120 cls: 'roo-select2-search-choice-close fa fa-times',
15125 }, this.searchField);
15127 var close = choice.select('a.roo-select2-search-choice-close', true).first();
15129 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
15137 this.inputEl().dom.value = '';
15142 onRemoveItem : function(e, _self, o)
15144 e.preventDefault();
15146 this.lastItem = Roo.apply([], this.item);
15148 var index = this.item.indexOf(o.data) * 1;
15151 Roo.log('not this item?!');
15155 this.item.splice(index, 1);
15160 this.fireEvent('remove', this, e);
15166 syncValue : function()
15168 if(!this.item.length){
15175 Roo.each(this.item, function(i){
15176 if(_this.valueField){
15177 value.push(i[_this.valueField]);
15184 this.value = value.join(',');
15186 if(this.hiddenField){
15187 this.hiddenField.dom.value = this.value;
15190 this.store.fireEvent("datachanged", this.store);
15195 clearItem : function()
15197 if(!this.multiple){
15203 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
15211 if(this.tickable && !Roo.isTouch){
15212 this.view.refresh();
15216 inputEl: function ()
15218 if(Roo.isIOS && this.useNativeIOS){
15219 return this.el.select('select.roo-ios-select', true).first();
15222 if(Roo.isTouch && this.mobileTouchView){
15223 return this.el.select('input.form-control',true).first();
15227 return this.searchField;
15230 return this.el.select('input.form-control',true).first();
15233 onTickableFooterButtonClick : function(e, btn, el)
15235 e.preventDefault();
15237 this.lastItem = Roo.apply([], this.item);
15239 if(btn && btn.name == 'cancel'){
15240 this.tickItems = Roo.apply([], this.item);
15249 Roo.each(this.tickItems, function(o){
15257 validate : function()
15259 if(this.getVisibilityEl().hasClass('hidden')){
15263 var v = this.getRawValue();
15266 v = this.getValue();
15269 if(this.disabled || this.allowBlank || v.length){
15274 this.markInvalid();
15278 tickableInputEl : function()
15280 if(!this.tickable || !this.editable){
15281 return this.inputEl();
15284 return this.inputEl().select('.roo-select2-search-field-input', true).first();
15288 getAutoCreateTouchView : function()
15293 cls: 'form-group' //input-group
15299 type : this.inputType,
15300 cls : 'form-control x-combo-noedit',
15301 autocomplete: 'new-password',
15302 placeholder : this.placeholder || '',
15307 input.name = this.name;
15311 input.cls += ' input-' + this.size;
15314 if (this.disabled) {
15315 input.disabled = true;
15326 inputblock.cls += ' input-group';
15328 inputblock.cn.unshift({
15330 cls : 'input-group-addon input-group-prepend input-group-text',
15335 if(this.removable && !this.multiple){
15336 inputblock.cls += ' roo-removable';
15338 inputblock.cn.push({
15341 cls : 'roo-combo-removable-btn close'
15345 if(this.hasFeedback && !this.allowBlank){
15347 inputblock.cls += ' has-feedback';
15349 inputblock.cn.push({
15351 cls: 'glyphicon form-control-feedback'
15358 inputblock.cls += (this.before) ? '' : ' input-group';
15360 inputblock.cn.push({
15362 cls : 'input-group-addon input-group-append input-group-text',
15368 var ibwrap = inputblock;
15373 cls: 'roo-select2-choices',
15377 cls: 'roo-select2-search-field',
15390 cls: 'roo-select2-container input-group roo-touchview-combobox ',
15395 cls: 'form-hidden-field'
15401 if(!this.multiple && this.showToggleBtn){
15407 if (this.caret != false) {
15410 cls: 'fa fa-' + this.caret
15417 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
15419 Roo.bootstrap.version == 3 ? caret : '',
15422 cls: 'combobox-clear',
15436 combobox.cls += ' roo-select2-container-multi';
15439 var align = this.labelAlign || this.parentLabelAlign();
15441 if (align ==='left' && this.fieldLabel.length) {
15446 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
15447 tooltip : 'This field is required'
15451 cls : 'control-label col-form-label',
15452 html : this.fieldLabel
15463 var labelCfg = cfg.cn[1];
15464 var contentCfg = cfg.cn[2];
15467 if(this.indicatorpos == 'right'){
15472 cls : 'control-label col-form-label',
15476 html : this.fieldLabel
15480 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
15481 tooltip : 'This field is required'
15494 labelCfg = cfg.cn[0];
15495 contentCfg = cfg.cn[1];
15500 if(this.labelWidth > 12){
15501 labelCfg.style = "width: " + this.labelWidth + 'px';
15504 if(this.labelWidth < 13 && this.labelmd == 0){
15505 this.labelmd = this.labelWidth;
15508 if(this.labellg > 0){
15509 labelCfg.cls += ' col-lg-' + this.labellg;
15510 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
15513 if(this.labelmd > 0){
15514 labelCfg.cls += ' col-md-' + this.labelmd;
15515 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
15518 if(this.labelsm > 0){
15519 labelCfg.cls += ' col-sm-' + this.labelsm;
15520 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
15523 if(this.labelxs > 0){
15524 labelCfg.cls += ' col-xs-' + this.labelxs;
15525 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
15529 } else if ( this.fieldLabel.length) {
15533 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
15534 tooltip : 'This field is required'
15538 cls : 'control-label',
15539 html : this.fieldLabel
15550 if(this.indicatorpos == 'right'){
15554 cls : 'control-label',
15555 html : this.fieldLabel,
15559 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
15560 tooltip : 'This field is required'
15577 var settings = this;
15579 ['xs','sm','md','lg'].map(function(size){
15580 if (settings[size]) {
15581 cfg.cls += ' col-' + size + '-' + settings[size];
15588 initTouchView : function()
15590 this.renderTouchView();
15592 this.touchViewEl.on('scroll', function(){
15593 this.el.dom.scrollTop = 0;
15596 this.originalValue = this.getValue();
15598 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
15600 this.inputEl().on("click", this.showTouchView, this);
15601 if (this.triggerEl) {
15602 this.triggerEl.on("click", this.showTouchView, this);
15606 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
15607 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
15609 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
15611 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
15612 this.store.on('load', this.onTouchViewLoad, this);
15613 this.store.on('loadexception', this.onTouchViewLoadException, this);
15615 if(this.hiddenName){
15617 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
15619 this.hiddenField.dom.value =
15620 this.hiddenValue !== undefined ? this.hiddenValue :
15621 this.value !== undefined ? this.value : '';
15623 this.el.dom.removeAttribute('name');
15624 this.hiddenField.dom.setAttribute('name', this.hiddenName);
15628 this.choices = this.el.select('ul.roo-select2-choices', true).first();
15629 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
15632 if(this.removable && !this.multiple){
15633 var close = this.closeTriggerEl();
15635 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
15636 close.on('click', this.removeBtnClick, this, close);
15640 * fix the bug in Safari iOS8
15642 this.inputEl().on("focus", function(e){
15643 document.activeElement.blur();
15646 this._touchViewMask = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
15653 renderTouchView : function()
15655 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
15656 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15658 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
15659 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15661 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
15662 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15663 this.touchViewBodyEl.setStyle('overflow', 'auto');
15665 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
15666 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15668 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
15669 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15673 showTouchView : function()
15679 this.touchViewHeaderEl.hide();
15681 if(this.modalTitle.length){
15682 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
15683 this.touchViewHeaderEl.show();
15686 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
15687 this.touchViewEl.show();
15689 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
15691 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
15692 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15694 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15696 if(this.modalTitle.length){
15697 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15700 this.touchViewBodyEl.setHeight(bodyHeight);
15704 (function(){ _this.touchViewEl.addClass('in'); }).defer(50);
15706 this.touchViewEl.addClass('in');
15709 if(this._touchViewMask){
15710 Roo.get(document.body).addClass("x-body-masked");
15711 this._touchViewMask.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15712 this._touchViewMask.setStyle('z-index', 10000);
15713 this._touchViewMask.addClass('show');
15716 this.doTouchViewQuery();
15720 hideTouchView : function()
15722 this.touchViewEl.removeClass('in');
15726 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
15728 this.touchViewEl.setStyle('display', 'none');
15731 if(this._touchViewMask){
15732 this._touchViewMask.removeClass('show');
15733 Roo.get(document.body).removeClass("x-body-masked");
15737 setTouchViewValue : function()
15744 Roo.each(this.tickItems, function(o){
15749 this.hideTouchView();
15752 doTouchViewQuery : function()
15761 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
15765 if(!this.alwaysQuery || this.mode == 'local'){
15766 this.onTouchViewLoad();
15773 onTouchViewBeforeLoad : function(combo,opts)
15779 onTouchViewLoad : function()
15781 if(this.store.getCount() < 1){
15782 this.onTouchViewEmptyResults();
15786 this.clearTouchView();
15788 var rawValue = this.getRawValue();
15790 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
15792 this.tickItems = [];
15794 this.store.data.each(function(d, rowIndex){
15795 var row = this.touchViewListGroup.createChild(template);
15797 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
15798 row.addClass(d.data.cls);
15801 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15804 html : d.data[this.displayField]
15807 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
15808 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
15811 row.removeClass('selected');
15812 if(!this.multiple && this.valueField &&
15813 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
15816 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15817 row.addClass('selected');
15820 if(this.multiple && this.valueField &&
15821 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
15825 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15826 this.tickItems.push(d.data);
15829 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
15833 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
15835 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15837 if(this.modalTitle.length){
15838 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15841 var listHeight = this.touchViewListGroup.getHeight() + this.touchViewBodyEl.getPadding('tb') * 2;
15843 if(this.mobile_restrict_height && listHeight < bodyHeight){
15844 this.touchViewBodyEl.setHeight(listHeight);
15849 if(firstChecked && listHeight > bodyHeight){
15850 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
15855 onTouchViewLoadException : function()
15857 this.hideTouchView();
15860 onTouchViewEmptyResults : function()
15862 this.clearTouchView();
15864 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
15866 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
15870 clearTouchView : function()
15872 this.touchViewListGroup.dom.innerHTML = '';
15875 onTouchViewClick : function(e, el, o)
15877 e.preventDefault();
15880 var rowIndex = o.rowIndex;
15882 var r = this.store.getAt(rowIndex);
15884 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
15886 if(!this.multiple){
15887 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
15888 c.dom.removeAttribute('checked');
15891 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15893 this.setFromData(r.data);
15895 var close = this.closeTriggerEl();
15901 this.hideTouchView();
15903 this.fireEvent('select', this, r, rowIndex);
15908 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
15909 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
15910 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
15914 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15915 this.addItem(r.data);
15916 this.tickItems.push(r.data);
15920 getAutoCreateNativeIOS : function()
15923 cls: 'form-group' //input-group,
15928 cls : 'roo-ios-select'
15932 combobox.name = this.name;
15935 if (this.disabled) {
15936 combobox.disabled = true;
15939 var settings = this;
15941 ['xs','sm','md','lg'].map(function(size){
15942 if (settings[size]) {
15943 cfg.cls += ' col-' + size + '-' + settings[size];
15953 initIOSView : function()
15955 this.store.on('load', this.onIOSViewLoad, this);
15960 onIOSViewLoad : function()
15962 if(this.store.getCount() < 1){
15966 this.clearIOSView();
15968 if(this.allowBlank) {
15970 var default_text = '-- SELECT --';
15972 if(this.placeholder.length){
15973 default_text = this.placeholder;
15976 if(this.emptyTitle.length){
15977 default_text += ' - ' + this.emptyTitle + ' -';
15980 var opt = this.inputEl().createChild({
15983 html : default_text
15987 o[this.valueField] = 0;
15988 o[this.displayField] = default_text;
15990 this.ios_options.push({
15997 this.store.data.each(function(d, rowIndex){
16001 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
16002 html = d.data[this.displayField];
16007 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
16008 value = d.data[this.valueField];
16017 if(this.value == d.data[this.valueField]){
16018 option['selected'] = true;
16021 var opt = this.inputEl().createChild(option);
16023 this.ios_options.push({
16030 this.inputEl().on('change', function(){
16031 this.fireEvent('select', this);
16036 clearIOSView: function()
16038 this.inputEl().dom.innerHTML = '';
16040 this.ios_options = [];
16043 setIOSValue: function(v)
16047 if(!this.ios_options){
16051 Roo.each(this.ios_options, function(opts){
16053 opts.el.dom.removeAttribute('selected');
16055 if(opts.data[this.valueField] != v){
16059 opts.el.dom.setAttribute('selected', true);
16065 * @cfg {Boolean} grow
16069 * @cfg {Number} growMin
16073 * @cfg {Number} growMax
16082 Roo.apply(Roo.bootstrap.ComboBox, {
16086 cls: 'modal-header',
16108 cls: 'list-group-item',
16112 cls: 'roo-combobox-list-group-item-value'
16116 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
16130 listItemCheckbox : {
16132 cls: 'list-group-item',
16136 cls: 'roo-combobox-list-group-item-value'
16140 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
16156 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
16161 cls: 'modal-footer',
16169 cls: 'col-xs-6 text-left',
16172 cls: 'btn btn-danger roo-touch-view-cancel',
16178 cls: 'col-xs-6 text-right',
16181 cls: 'btn btn-success roo-touch-view-ok',
16192 Roo.apply(Roo.bootstrap.ComboBox, {
16194 touchViewTemplate : {
16196 cls: 'modal fade roo-combobox-touch-view',
16200 cls: 'modal-dialog',
16201 style : 'position:fixed', // we have to fix position....
16205 cls: 'modal-content',
16207 Roo.bootstrap.ComboBox.header,
16208 Roo.bootstrap.ComboBox.body,
16209 Roo.bootstrap.ComboBox.footer
16218 * Ext JS Library 1.1.1
16219 * Copyright(c) 2006-2007, Ext JS, LLC.
16221 * Originally Released Under LGPL - original licence link has changed is not relivant.
16224 * <script type="text/javascript">
16229 * @extends Roo.util.Observable
16230 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
16231 * This class also supports single and multi selection modes. <br>
16232 * Create a data model bound view:
16234 var store = new Roo.data.Store(...);
16236 var view = new Roo.View({
16238 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
16240 singleSelect: true,
16241 selectedClass: "ydataview-selected",
16245 // listen for node click?
16246 view.on("click", function(vw, index, node, e){
16247 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
16251 dataModel.load("foobar.xml");
16253 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
16255 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
16256 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
16258 * Note: old style constructor is still suported (container, template, config)
16261 * Create a new View
16262 * @param {Object} config The config object
16265 Roo.View = function(config, depreciated_tpl, depreciated_config){
16267 this.parent = false;
16269 if (typeof(depreciated_tpl) == 'undefined') {
16270 // new way.. - universal constructor.
16271 Roo.apply(this, config);
16272 this.el = Roo.get(this.el);
16275 this.el = Roo.get(config);
16276 this.tpl = depreciated_tpl;
16277 Roo.apply(this, depreciated_config);
16279 this.wrapEl = this.el.wrap().wrap();
16280 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
16283 if(typeof(this.tpl) == "string"){
16284 this.tpl = new Roo.Template(this.tpl);
16286 // support xtype ctors..
16287 this.tpl = new Roo.factory(this.tpl, Roo);
16291 this.tpl.compile();
16296 * @event beforeclick
16297 * Fires before a click is processed. Returns false to cancel the default action.
16298 * @param {Roo.View} this
16299 * @param {Number} index The index of the target node
16300 * @param {HTMLElement} node The target node
16301 * @param {Roo.EventObject} e The raw event object
16303 "beforeclick" : true,
16306 * Fires when a template node is clicked.
16307 * @param {Roo.View} this
16308 * @param {Number} index The index of the target node
16309 * @param {HTMLElement} node The target node
16310 * @param {Roo.EventObject} e The raw event object
16315 * Fires when a template node is double clicked.
16316 * @param {Roo.View} this
16317 * @param {Number} index The index of the target node
16318 * @param {HTMLElement} node The target node
16319 * @param {Roo.EventObject} e The raw event object
16323 * @event contextmenu
16324 * Fires when a template node is right clicked.
16325 * @param {Roo.View} this
16326 * @param {Number} index The index of the target node
16327 * @param {HTMLElement} node The target node
16328 * @param {Roo.EventObject} e The raw event object
16330 "contextmenu" : true,
16332 * @event selectionchange
16333 * Fires when the selected nodes change.
16334 * @param {Roo.View} this
16335 * @param {Array} selections Array of the selected nodes
16337 "selectionchange" : true,
16340 * @event beforeselect
16341 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
16342 * @param {Roo.View} this
16343 * @param {HTMLElement} node The node to be selected
16344 * @param {Array} selections Array of currently selected nodes
16346 "beforeselect" : true,
16348 * @event preparedata
16349 * Fires on every row to render, to allow you to change the data.
16350 * @param {Roo.View} this
16351 * @param {Object} data to be rendered (change this)
16353 "preparedata" : true
16361 "click": this.onClick,
16362 "dblclick": this.onDblClick,
16363 "contextmenu": this.onContextMenu,
16367 this.selections = [];
16369 this.cmp = new Roo.CompositeElementLite([]);
16371 this.store = Roo.factory(this.store, Roo.data);
16372 this.setStore(this.store, true);
16375 if ( this.footer && this.footer.xtype) {
16377 var fctr = this.wrapEl.appendChild(document.createElement("div"));
16379 this.footer.dataSource = this.store;
16380 this.footer.container = fctr;
16381 this.footer = Roo.factory(this.footer, Roo);
16382 fctr.insertFirst(this.el);
16384 // this is a bit insane - as the paging toolbar seems to detach the el..
16385 // dom.parentNode.parentNode.parentNode
16386 // they get detached?
16390 Roo.View.superclass.constructor.call(this);
16395 Roo.extend(Roo.View, Roo.util.Observable, {
16398 * @cfg {Roo.data.Store} store Data store to load data from.
16403 * @cfg {String|Roo.Element} el The container element.
16408 * @cfg {String|Roo.Template} tpl The template used by this View
16412 * @cfg {String} dataName the named area of the template to use as the data area
16413 * Works with domtemplates roo-name="name"
16417 * @cfg {String} selectedClass The css class to add to selected nodes
16419 selectedClass : "x-view-selected",
16421 * @cfg {String} emptyText The empty text to show when nothing is loaded.
16426 * @cfg {String} text to display on mask (default Loading)
16430 * @cfg {Boolean} multiSelect Allow multiple selection
16432 multiSelect : false,
16434 * @cfg {Boolean} singleSelect Allow single selection
16436 singleSelect: false,
16439 * @cfg {Boolean} toggleSelect - selecting
16441 toggleSelect : false,
16444 * @cfg {Boolean} tickable - selecting
16449 * Returns the element this view is bound to.
16450 * @return {Roo.Element}
16452 getEl : function(){
16453 return this.wrapEl;
16459 * Refreshes the view. - called by datachanged on the store. - do not call directly.
16461 refresh : function(){
16462 //Roo.log('refresh');
16465 // if we are using something like 'domtemplate', then
16466 // the what gets used is:
16467 // t.applySubtemplate(NAME, data, wrapping data..)
16468 // the outer template then get' applied with
16469 // the store 'extra data'
16470 // and the body get's added to the
16471 // roo-name="data" node?
16472 // <span class='roo-tpl-{name}'></span> ?????
16476 this.clearSelections();
16477 this.el.update("");
16479 var records = this.store.getRange();
16480 if(records.length < 1) {
16482 // is this valid?? = should it render a template??
16484 this.el.update(this.emptyText);
16488 if (this.dataName) {
16489 this.el.update(t.apply(this.store.meta)); //????
16490 el = this.el.child('.roo-tpl-' + this.dataName);
16493 for(var i = 0, len = records.length; i < len; i++){
16494 var data = this.prepareData(records[i].data, i, records[i]);
16495 this.fireEvent("preparedata", this, data, i, records[i]);
16497 var d = Roo.apply({}, data);
16500 Roo.apply(d, {'roo-id' : Roo.id()});
16504 Roo.each(this.parent.item, function(item){
16505 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
16508 Roo.apply(d, {'roo-data-checked' : 'checked'});
16512 html[html.length] = Roo.util.Format.trim(
16514 t.applySubtemplate(this.dataName, d, this.store.meta) :
16521 el.update(html.join(""));
16522 this.nodes = el.dom.childNodes;
16523 this.updateIndexes(0);
16528 * Function to override to reformat the data that is sent to
16529 * the template for each node.
16530 * DEPRICATED - use the preparedata event handler.
16531 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
16532 * a JSON object for an UpdateManager bound view).
16534 prepareData : function(data, index, record)
16536 this.fireEvent("preparedata", this, data, index, record);
16540 onUpdate : function(ds, record){
16541 // Roo.log('on update');
16542 this.clearSelections();
16543 var index = this.store.indexOf(record);
16544 var n = this.nodes[index];
16545 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
16546 n.parentNode.removeChild(n);
16547 this.updateIndexes(index, index);
16553 onAdd : function(ds, records, index)
16555 //Roo.log(['on Add', ds, records, index] );
16556 this.clearSelections();
16557 if(this.nodes.length == 0){
16561 var n = this.nodes[index];
16562 for(var i = 0, len = records.length; i < len; i++){
16563 var d = this.prepareData(records[i].data, i, records[i]);
16565 this.tpl.insertBefore(n, d);
16568 this.tpl.append(this.el, d);
16571 this.updateIndexes(index);
16574 onRemove : function(ds, record, index){
16575 // Roo.log('onRemove');
16576 this.clearSelections();
16577 var el = this.dataName ?
16578 this.el.child('.roo-tpl-' + this.dataName) :
16581 el.dom.removeChild(this.nodes[index]);
16582 this.updateIndexes(index);
16586 * Refresh an individual node.
16587 * @param {Number} index
16589 refreshNode : function(index){
16590 this.onUpdate(this.store, this.store.getAt(index));
16593 updateIndexes : function(startIndex, endIndex){
16594 var ns = this.nodes;
16595 startIndex = startIndex || 0;
16596 endIndex = endIndex || ns.length - 1;
16597 for(var i = startIndex; i <= endIndex; i++){
16598 ns[i].nodeIndex = i;
16603 * Changes the data store this view uses and refresh the view.
16604 * @param {Store} store
16606 setStore : function(store, initial){
16607 if(!initial && this.store){
16608 this.store.un("datachanged", this.refresh);
16609 this.store.un("add", this.onAdd);
16610 this.store.un("remove", this.onRemove);
16611 this.store.un("update", this.onUpdate);
16612 this.store.un("clear", this.refresh);
16613 this.store.un("beforeload", this.onBeforeLoad);
16614 this.store.un("load", this.onLoad);
16615 this.store.un("loadexception", this.onLoad);
16619 store.on("datachanged", this.refresh, this);
16620 store.on("add", this.onAdd, this);
16621 store.on("remove", this.onRemove, this);
16622 store.on("update", this.onUpdate, this);
16623 store.on("clear", this.refresh, this);
16624 store.on("beforeload", this.onBeforeLoad, this);
16625 store.on("load", this.onLoad, this);
16626 store.on("loadexception", this.onLoad, this);
16634 * onbeforeLoad - masks the loading area.
16637 onBeforeLoad : function(store,opts)
16639 //Roo.log('onBeforeLoad');
16641 this.el.update("");
16643 this.el.mask(this.mask ? this.mask : "Loading" );
16645 onLoad : function ()
16652 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
16653 * @param {HTMLElement} node
16654 * @return {HTMLElement} The template node
16656 findItemFromChild : function(node){
16657 var el = this.dataName ?
16658 this.el.child('.roo-tpl-' + this.dataName,true) :
16661 if(!node || node.parentNode == el){
16664 var p = node.parentNode;
16665 while(p && p != el){
16666 if(p.parentNode == el){
16675 onClick : function(e){
16676 var item = this.findItemFromChild(e.getTarget());
16678 var index = this.indexOf(item);
16679 if(this.onItemClick(item, index, e) !== false){
16680 this.fireEvent("click", this, index, item, e);
16683 this.clearSelections();
16688 onContextMenu : function(e){
16689 var item = this.findItemFromChild(e.getTarget());
16691 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
16696 onDblClick : function(e){
16697 var item = this.findItemFromChild(e.getTarget());
16699 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
16703 onItemClick : function(item, index, e)
16705 if(this.fireEvent("beforeclick", this, index, item, e) === false){
16708 if (this.toggleSelect) {
16709 var m = this.isSelected(item) ? 'unselect' : 'select';
16712 _t[m](item, true, false);
16715 if(this.multiSelect || this.singleSelect){
16716 if(this.multiSelect && e.shiftKey && this.lastSelection){
16717 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
16719 this.select(item, this.multiSelect && e.ctrlKey);
16720 this.lastSelection = item;
16723 if(!this.tickable){
16724 e.preventDefault();
16732 * Get the number of selected nodes.
16735 getSelectionCount : function(){
16736 return this.selections.length;
16740 * Get the currently selected nodes.
16741 * @return {Array} An array of HTMLElements
16743 getSelectedNodes : function(){
16744 return this.selections;
16748 * Get the indexes of the selected nodes.
16751 getSelectedIndexes : function(){
16752 var indexes = [], s = this.selections;
16753 for(var i = 0, len = s.length; i < len; i++){
16754 indexes.push(s[i].nodeIndex);
16760 * Clear all selections
16761 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
16763 clearSelections : function(suppressEvent){
16764 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
16765 this.cmp.elements = this.selections;
16766 this.cmp.removeClass(this.selectedClass);
16767 this.selections = [];
16768 if(!suppressEvent){
16769 this.fireEvent("selectionchange", this, this.selections);
16775 * Returns true if the passed node is selected
16776 * @param {HTMLElement/Number} node The node or node index
16777 * @return {Boolean}
16779 isSelected : function(node){
16780 var s = this.selections;
16784 node = this.getNode(node);
16785 return s.indexOf(node) !== -1;
16790 * @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
16791 * @param {Boolean} keepExisting (optional) true to keep existing selections
16792 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16794 select : function(nodeInfo, keepExisting, suppressEvent){
16795 if(nodeInfo instanceof Array){
16797 this.clearSelections(true);
16799 for(var i = 0, len = nodeInfo.length; i < len; i++){
16800 this.select(nodeInfo[i], true, true);
16804 var node = this.getNode(nodeInfo);
16805 if(!node || this.isSelected(node)){
16806 return; // already selected.
16809 this.clearSelections(true);
16812 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
16813 Roo.fly(node).addClass(this.selectedClass);
16814 this.selections.push(node);
16815 if(!suppressEvent){
16816 this.fireEvent("selectionchange", this, this.selections);
16824 * @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
16825 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
16826 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16828 unselect : function(nodeInfo, keepExisting, suppressEvent)
16830 if(nodeInfo instanceof Array){
16831 Roo.each(this.selections, function(s) {
16832 this.unselect(s, nodeInfo);
16836 var node = this.getNode(nodeInfo);
16837 if(!node || !this.isSelected(node)){
16838 //Roo.log("not selected");
16839 return; // not selected.
16843 Roo.each(this.selections, function(s) {
16845 Roo.fly(node).removeClass(this.selectedClass);
16852 this.selections= ns;
16853 this.fireEvent("selectionchange", this, this.selections);
16857 * Gets a template node.
16858 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16859 * @return {HTMLElement} The node or null if it wasn't found
16861 getNode : function(nodeInfo){
16862 if(typeof nodeInfo == "string"){
16863 return document.getElementById(nodeInfo);
16864 }else if(typeof nodeInfo == "number"){
16865 return this.nodes[nodeInfo];
16871 * Gets a range template nodes.
16872 * @param {Number} startIndex
16873 * @param {Number} endIndex
16874 * @return {Array} An array of nodes
16876 getNodes : function(start, end){
16877 var ns = this.nodes;
16878 start = start || 0;
16879 end = typeof end == "undefined" ? ns.length - 1 : end;
16882 for(var i = start; i <= end; i++){
16886 for(var i = start; i >= end; i--){
16894 * Finds the index of the passed node
16895 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16896 * @return {Number} The index of the node or -1
16898 indexOf : function(node){
16899 node = this.getNode(node);
16900 if(typeof node.nodeIndex == "number"){
16901 return node.nodeIndex;
16903 var ns = this.nodes;
16904 for(var i = 0, len = ns.length; i < len; i++){
16915 * based on jquery fullcalendar
16919 Roo.bootstrap = Roo.bootstrap || {};
16921 * @class Roo.bootstrap.Calendar
16922 * @extends Roo.bootstrap.Component
16923 * Bootstrap Calendar class
16924 * @cfg {Boolean} loadMask (true|false) default false
16925 * @cfg {Object} header generate the user specific header of the calendar, default false
16928 * Create a new Container
16929 * @param {Object} config The config object
16934 Roo.bootstrap.Calendar = function(config){
16935 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
16939 * Fires when a date is selected
16940 * @param {DatePicker} this
16941 * @param {Date} date The selected date
16945 * @event monthchange
16946 * Fires when the displayed month changes
16947 * @param {DatePicker} this
16948 * @param {Date} date The selected month
16950 'monthchange': true,
16952 * @event evententer
16953 * Fires when mouse over an event
16954 * @param {Calendar} this
16955 * @param {event} Event
16957 'evententer': true,
16959 * @event eventleave
16960 * Fires when the mouse leaves an
16961 * @param {Calendar} this
16964 'eventleave': true,
16966 * @event eventclick
16967 * Fires when the mouse click an
16968 * @param {Calendar} this
16977 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
16980 * @cfg {Number} startDay
16981 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
16989 getAutoCreate : function(){
16992 var fc_button = function(name, corner, style, content ) {
16993 return Roo.apply({},{
16995 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
16997 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
17000 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
17011 style : 'width:100%',
17018 cls : 'fc-header-left',
17020 fc_button('prev', 'left', 'arrow', '‹' ),
17021 fc_button('next', 'right', 'arrow', '›' ),
17022 { tag: 'span', cls: 'fc-header-space' },
17023 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
17031 cls : 'fc-header-center',
17035 cls: 'fc-header-title',
17038 html : 'month / year'
17046 cls : 'fc-header-right',
17048 /* fc_button('month', 'left', '', 'month' ),
17049 fc_button('week', '', '', 'week' ),
17050 fc_button('day', 'right', '', 'day' )
17062 header = this.header;
17065 var cal_heads = function() {
17067 // fixme - handle this.
17069 for (var i =0; i < Date.dayNames.length; i++) {
17070 var d = Date.dayNames[i];
17073 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
17074 html : d.substring(0,3)
17078 ret[0].cls += ' fc-first';
17079 ret[6].cls += ' fc-last';
17082 var cal_cell = function(n) {
17085 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
17090 cls: 'fc-day-number',
17094 cls: 'fc-day-content',
17098 style: 'position: relative;' // height: 17px;
17110 var cal_rows = function() {
17113 for (var r = 0; r < 6; r++) {
17120 for (var i =0; i < Date.dayNames.length; i++) {
17121 var d = Date.dayNames[i];
17122 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
17125 row.cn[0].cls+=' fc-first';
17126 row.cn[0].cn[0].style = 'min-height:90px';
17127 row.cn[6].cls+=' fc-last';
17131 ret[0].cls += ' fc-first';
17132 ret[4].cls += ' fc-prev-last';
17133 ret[5].cls += ' fc-last';
17140 cls: 'fc-border-separate',
17141 style : 'width:100%',
17149 cls : 'fc-first fc-last',
17167 cls : 'fc-content',
17168 style : "position: relative;",
17171 cls : 'fc-view fc-view-month fc-grid',
17172 style : 'position: relative',
17173 unselectable : 'on',
17176 cls : 'fc-event-container',
17177 style : 'position:absolute;z-index:8;top:0;left:0;'
17195 initEvents : function()
17198 throw "can not find store for calendar";
17204 style: "text-align:center",
17208 style: "background-color:white;width:50%;margin:250 auto",
17212 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
17223 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
17225 var size = this.el.select('.fc-content', true).first().getSize();
17226 this.maskEl.setSize(size.width, size.height);
17227 this.maskEl.enableDisplayMode("block");
17228 if(!this.loadMask){
17229 this.maskEl.hide();
17232 this.store = Roo.factory(this.store, Roo.data);
17233 this.store.on('load', this.onLoad, this);
17234 this.store.on('beforeload', this.onBeforeLoad, this);
17238 this.cells = this.el.select('.fc-day',true);
17239 //Roo.log(this.cells);
17240 this.textNodes = this.el.query('.fc-day-number');
17241 this.cells.addClassOnOver('fc-state-hover');
17243 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
17244 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
17245 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
17246 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
17248 this.on('monthchange', this.onMonthChange, this);
17250 this.update(new Date().clearTime());
17253 resize : function() {
17254 var sz = this.el.getSize();
17256 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
17257 this.el.select('.fc-day-content div',true).setHeight(34);
17262 showPrevMonth : function(e){
17263 this.update(this.activeDate.add("mo", -1));
17265 showToday : function(e){
17266 this.update(new Date().clearTime());
17269 showNextMonth : function(e){
17270 this.update(this.activeDate.add("mo", 1));
17274 showPrevYear : function(){
17275 this.update(this.activeDate.add("y", -1));
17279 showNextYear : function(){
17280 this.update(this.activeDate.add("y", 1));
17285 update : function(date)
17287 var vd = this.activeDate;
17288 this.activeDate = date;
17289 // if(vd && this.el){
17290 // var t = date.getTime();
17291 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
17292 // Roo.log('using add remove');
17294 // this.fireEvent('monthchange', this, date);
17296 // this.cells.removeClass("fc-state-highlight");
17297 // this.cells.each(function(c){
17298 // if(c.dateValue == t){
17299 // c.addClass("fc-state-highlight");
17300 // setTimeout(function(){
17301 // try{c.dom.firstChild.focus();}catch(e){}
17311 var days = date.getDaysInMonth();
17313 var firstOfMonth = date.getFirstDateOfMonth();
17314 var startingPos = firstOfMonth.getDay()-this.startDay;
17316 if(startingPos < this.startDay){
17320 var pm = date.add(Date.MONTH, -1);
17321 var prevStart = pm.getDaysInMonth()-startingPos;
17323 this.cells = this.el.select('.fc-day',true);
17324 this.textNodes = this.el.query('.fc-day-number');
17325 this.cells.addClassOnOver('fc-state-hover');
17327 var cells = this.cells.elements;
17328 var textEls = this.textNodes;
17330 Roo.each(cells, function(cell){
17331 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
17334 days += startingPos;
17336 // convert everything to numbers so it's fast
17337 var day = 86400000;
17338 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
17341 //Roo.log(prevStart);
17343 var today = new Date().clearTime().getTime();
17344 var sel = date.clearTime().getTime();
17345 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
17346 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
17347 var ddMatch = this.disabledDatesRE;
17348 var ddText = this.disabledDatesText;
17349 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
17350 var ddaysText = this.disabledDaysText;
17351 var format = this.format;
17353 var setCellClass = function(cal, cell){
17357 //Roo.log('set Cell Class');
17359 var t = d.getTime();
17363 cell.dateValue = t;
17365 cell.className += " fc-today";
17366 cell.className += " fc-state-highlight";
17367 cell.title = cal.todayText;
17370 // disable highlight in other month..
17371 //cell.className += " fc-state-highlight";
17376 cell.className = " fc-state-disabled";
17377 cell.title = cal.minText;
17381 cell.className = " fc-state-disabled";
17382 cell.title = cal.maxText;
17386 if(ddays.indexOf(d.getDay()) != -1){
17387 cell.title = ddaysText;
17388 cell.className = " fc-state-disabled";
17391 if(ddMatch && format){
17392 var fvalue = d.dateFormat(format);
17393 if(ddMatch.test(fvalue)){
17394 cell.title = ddText.replace("%0", fvalue);
17395 cell.className = " fc-state-disabled";
17399 if (!cell.initialClassName) {
17400 cell.initialClassName = cell.dom.className;
17403 cell.dom.className = cell.initialClassName + ' ' + cell.className;
17408 for(; i < startingPos; i++) {
17409 textEls[i].innerHTML = (++prevStart);
17410 d.setDate(d.getDate()+1);
17412 cells[i].className = "fc-past fc-other-month";
17413 setCellClass(this, cells[i]);
17418 for(; i < days; i++){
17419 intDay = i - startingPos + 1;
17420 textEls[i].innerHTML = (intDay);
17421 d.setDate(d.getDate()+1);
17423 cells[i].className = ''; // "x-date-active";
17424 setCellClass(this, cells[i]);
17428 for(; i < 42; i++) {
17429 textEls[i].innerHTML = (++extraDays);
17430 d.setDate(d.getDate()+1);
17432 cells[i].className = "fc-future fc-other-month";
17433 setCellClass(this, cells[i]);
17436 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
17438 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
17440 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
17441 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
17443 if(totalRows != 6){
17444 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
17445 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
17448 this.fireEvent('monthchange', this, date);
17452 if(!this.internalRender){
17453 var main = this.el.dom.firstChild;
17454 var w = main.offsetWidth;
17455 this.el.setWidth(w + this.el.getBorderWidth("lr"));
17456 Roo.fly(main).setWidth(w);
17457 this.internalRender = true;
17458 // opera does not respect the auto grow header center column
17459 // then, after it gets a width opera refuses to recalculate
17460 // without a second pass
17461 if(Roo.isOpera && !this.secondPass){
17462 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
17463 this.secondPass = true;
17464 this.update.defer(10, this, [date]);
17471 findCell : function(dt) {
17472 dt = dt.clearTime().getTime();
17474 this.cells.each(function(c){
17475 //Roo.log("check " +c.dateValue + '?=' + dt);
17476 if(c.dateValue == dt){
17486 findCells : function(ev) {
17487 var s = ev.start.clone().clearTime().getTime();
17489 var e= ev.end.clone().clearTime().getTime();
17492 this.cells.each(function(c){
17493 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
17495 if(c.dateValue > e){
17498 if(c.dateValue < s){
17507 // findBestRow: function(cells)
17511 // for (var i =0 ; i < cells.length;i++) {
17512 // ret = Math.max(cells[i].rows || 0,ret);
17519 addItem : function(ev)
17521 // look for vertical location slot in
17522 var cells = this.findCells(ev);
17524 // ev.row = this.findBestRow(cells);
17526 // work out the location.
17530 for(var i =0; i < cells.length; i++) {
17532 cells[i].row = cells[0].row;
17535 cells[i].row = cells[i].row + 1;
17545 if (crow.start.getY() == cells[i].getY()) {
17547 crow.end = cells[i];
17564 cells[0].events.push(ev);
17566 this.calevents.push(ev);
17569 clearEvents: function() {
17571 if(!this.calevents){
17575 Roo.each(this.cells.elements, function(c){
17581 Roo.each(this.calevents, function(e) {
17582 Roo.each(e.els, function(el) {
17583 el.un('mouseenter' ,this.onEventEnter, this);
17584 el.un('mouseleave' ,this.onEventLeave, this);
17589 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
17595 renderEvents: function()
17599 this.cells.each(function(c) {
17608 if(c.row != c.events.length){
17609 r = 4 - (4 - (c.row - c.events.length));
17612 c.events = ev.slice(0, r);
17613 c.more = ev.slice(r);
17615 if(c.more.length && c.more.length == 1){
17616 c.events.push(c.more.pop());
17619 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
17623 this.cells.each(function(c) {
17625 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
17628 for (var e = 0; e < c.events.length; e++){
17629 var ev = c.events[e];
17630 var rows = ev.rows;
17632 for(var i = 0; i < rows.length; i++) {
17634 // how many rows should it span..
17637 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
17638 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
17640 unselectable : "on",
17643 cls: 'fc-event-inner',
17647 // cls: 'fc-event-time',
17648 // html : cells.length > 1 ? '' : ev.time
17652 cls: 'fc-event-title',
17653 html : String.format('{0}', ev.title)
17660 cls: 'ui-resizable-handle ui-resizable-e',
17661 html : '  '
17668 cfg.cls += ' fc-event-start';
17670 if ((i+1) == rows.length) {
17671 cfg.cls += ' fc-event-end';
17674 var ctr = _this.el.select('.fc-event-container',true).first();
17675 var cg = ctr.createChild(cfg);
17677 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
17678 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
17680 var r = (c.more.length) ? 1 : 0;
17681 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
17682 cg.setWidth(ebox.right - sbox.x -2);
17684 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
17685 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
17686 cg.on('click', _this.onEventClick, _this, ev);
17697 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
17698 style : 'position: absolute',
17699 unselectable : "on",
17702 cls: 'fc-event-inner',
17706 cls: 'fc-event-title',
17714 cls: 'ui-resizable-handle ui-resizable-e',
17715 html : '  '
17721 var ctr = _this.el.select('.fc-event-container',true).first();
17722 var cg = ctr.createChild(cfg);
17724 var sbox = c.select('.fc-day-content',true).first().getBox();
17725 var ebox = c.select('.fc-day-content',true).first().getBox();
17727 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
17728 cg.setWidth(ebox.right - sbox.x -2);
17730 cg.on('click', _this.onMoreEventClick, _this, c.more);
17740 onEventEnter: function (e, el,event,d) {
17741 this.fireEvent('evententer', this, el, event);
17744 onEventLeave: function (e, el,event,d) {
17745 this.fireEvent('eventleave', this, el, event);
17748 onEventClick: function (e, el,event,d) {
17749 this.fireEvent('eventclick', this, el, event);
17752 onMonthChange: function () {
17756 onMoreEventClick: function(e, el, more)
17760 this.calpopover.placement = 'right';
17761 this.calpopover.setTitle('More');
17763 this.calpopover.setContent('');
17765 var ctr = this.calpopover.el.select('.popover-content', true).first();
17767 Roo.each(more, function(m){
17769 cls : 'fc-event-hori fc-event-draggable',
17772 var cg = ctr.createChild(cfg);
17774 cg.on('click', _this.onEventClick, _this, m);
17777 this.calpopover.show(el);
17782 onLoad: function ()
17784 this.calevents = [];
17787 if(this.store.getCount() > 0){
17788 this.store.data.each(function(d){
17791 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
17792 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
17793 time : d.data.start_time,
17794 title : d.data.title,
17795 description : d.data.description,
17796 venue : d.data.venue
17801 this.renderEvents();
17803 if(this.calevents.length && this.loadMask){
17804 this.maskEl.hide();
17808 onBeforeLoad: function()
17810 this.clearEvents();
17812 this.maskEl.show();
17826 * @class Roo.bootstrap.Popover
17827 * @extends Roo.bootstrap.Component
17828 * Bootstrap Popover class
17829 * @cfg {String} html contents of the popover (or false to use children..)
17830 * @cfg {String} title of popover (or false to hide)
17831 * @cfg {String} placement how it is placed
17832 * @cfg {String} trigger click || hover (or false to trigger manually)
17833 * @cfg {String} over what (parent or false to trigger manually.)
17834 * @cfg {Number} delay - delay before showing
17837 * Create a new Popover
17838 * @param {Object} config The config object
17841 Roo.bootstrap.Popover = function(config){
17842 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
17848 * After the popover show
17850 * @param {Roo.bootstrap.Popover} this
17855 * After the popover hide
17857 * @param {Roo.bootstrap.Popover} this
17863 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
17865 title: 'Fill in a title',
17868 placement : 'right',
17869 trigger : 'hover', // hover
17875 can_build_overlaid : false,
17877 getChildContainer : function()
17879 return this.el.select('.popover-content',true).first();
17882 getAutoCreate : function(){
17885 cls : 'popover roo-dynamic',
17886 style: 'display:block',
17892 cls : 'popover-inner',
17896 cls: 'popover-title popover-header',
17900 cls : 'popover-content popover-body',
17911 setTitle: function(str)
17914 this.el.select('.popover-title',true).first().dom.innerHTML = str;
17916 setContent: function(str)
17919 this.el.select('.popover-content',true).first().dom.innerHTML = str;
17921 // as it get's added to the bottom of the page.
17922 onRender : function(ct, position)
17924 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
17926 var cfg = Roo.apply({}, this.getAutoCreate());
17930 cfg.cls += ' ' + this.cls;
17933 cfg.style = this.style;
17935 //Roo.log("adding to ");
17936 this.el = Roo.get(document.body).createChild(cfg, position);
17937 // Roo.log(this.el);
17942 initEvents : function()
17944 this.el.select('.popover-title',true).setVisibilityMode(Roo.Element.DISPLAY);
17945 this.el.enableDisplayMode('block');
17947 if (this.over === false) {
17950 if (this.triggers === false) {
17953 var on_el = (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17954 var triggers = this.trigger ? this.trigger.split(' ') : [];
17955 Roo.each(triggers, function(trigger) {
17957 if (trigger == 'click') {
17958 on_el.on('click', this.toggle, this);
17959 } else if (trigger != 'manual') {
17960 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
17961 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
17963 on_el.on(eventIn ,this.enter, this);
17964 on_el.on(eventOut, this.leave, this);
17975 toggle : function () {
17976 this.hoverState == 'in' ? this.leave() : this.enter();
17979 enter : function () {
17981 clearTimeout(this.timeout);
17983 this.hoverState = 'in';
17985 if (!this.delay || !this.delay.show) {
17990 this.timeout = setTimeout(function () {
17991 if (_t.hoverState == 'in') {
17994 }, this.delay.show)
17997 leave : function() {
17998 clearTimeout(this.timeout);
18000 this.hoverState = 'out';
18002 if (!this.delay || !this.delay.hide) {
18007 this.timeout = setTimeout(function () {
18008 if (_t.hoverState == 'out') {
18011 }, this.delay.hide)
18014 show : function (on_el)
18017 on_el= (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
18021 this.el.select('.popover-title',true).first().dom.innerHtml = this.title;
18022 if (this.html !== false) {
18023 this.el.select('.popover-content',true).first().dom.innerHtml = this.html;
18025 this.el.removeClass([
18026 'fade','top','bottom', 'left', 'right','in',
18027 'bs-popover-top','bs-popover-bottom', 'bs-popover-left', 'bs-popover-right'
18029 if (!this.title.length) {
18030 this.el.select('.popover-title',true).hide();
18033 var placement = typeof this.placement == 'function' ?
18034 this.placement.call(this, this.el, on_el) :
18037 var autoToken = /\s?auto?\s?/i;
18038 var autoPlace = autoToken.test(placement);
18040 placement = placement.replace(autoToken, '') || 'top';
18044 //this.el.setXY([0,0]);
18046 this.el.dom.style.display='block';
18047 this.el.addClass(placement);
18049 //this.el.appendTo(on_el);
18051 var p = this.getPosition();
18052 var box = this.el.getBox();
18057 var align = Roo.bootstrap.Popover.alignment[placement];
18060 this.el.alignTo(on_el, align[0],align[1]);
18061 //var arrow = this.el.select('.arrow',true).first();
18062 //arrow.set(align[2],
18064 this.el.addClass('in');
18067 if (this.el.hasClass('fade')) {
18071 this.hoverState = 'in';
18073 this.fireEvent('show', this);
18078 this.el.setXY([0,0]);
18079 this.el.removeClass('in');
18081 this.hoverState = null;
18083 this.fireEvent('hide', this);
18088 Roo.bootstrap.Popover.alignment = {
18089 'left' : ['r-l', [-10,0], 'right bs-popover-right'],
18090 'right' : ['l-r', [10,0], 'left bs-popover-left'],
18091 'bottom' : ['t-b', [0,10], 'top bs-popover-top'],
18092 'top' : [ 'b-t', [0,-10], 'bottom bs-popover-bottom']
18103 * @class Roo.bootstrap.Progress
18104 * @extends Roo.bootstrap.Component
18105 * Bootstrap Progress class
18106 * @cfg {Boolean} striped striped of the progress bar
18107 * @cfg {Boolean} active animated of the progress bar
18111 * Create a new Progress
18112 * @param {Object} config The config object
18115 Roo.bootstrap.Progress = function(config){
18116 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
18119 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
18124 getAutoCreate : function(){
18132 cfg.cls += ' progress-striped';
18136 cfg.cls += ' active';
18155 * @class Roo.bootstrap.ProgressBar
18156 * @extends Roo.bootstrap.Component
18157 * Bootstrap ProgressBar class
18158 * @cfg {Number} aria_valuenow aria-value now
18159 * @cfg {Number} aria_valuemin aria-value min
18160 * @cfg {Number} aria_valuemax aria-value max
18161 * @cfg {String} label label for the progress bar
18162 * @cfg {String} panel (success | info | warning | danger )
18163 * @cfg {String} role role of the progress bar
18164 * @cfg {String} sr_only text
18168 * Create a new ProgressBar
18169 * @param {Object} config The config object
18172 Roo.bootstrap.ProgressBar = function(config){
18173 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
18176 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
18180 aria_valuemax : 100,
18186 getAutoCreate : function()
18191 cls: 'progress-bar',
18192 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
18204 cfg.role = this.role;
18207 if(this.aria_valuenow){
18208 cfg['aria-valuenow'] = this.aria_valuenow;
18211 if(this.aria_valuemin){
18212 cfg['aria-valuemin'] = this.aria_valuemin;
18215 if(this.aria_valuemax){
18216 cfg['aria-valuemax'] = this.aria_valuemax;
18219 if(this.label && !this.sr_only){
18220 cfg.html = this.label;
18224 cfg.cls += ' progress-bar-' + this.panel;
18230 update : function(aria_valuenow)
18232 this.aria_valuenow = aria_valuenow;
18234 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
18249 * @class Roo.bootstrap.TabGroup
18250 * @extends Roo.bootstrap.Column
18251 * Bootstrap Column class
18252 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
18253 * @cfg {Boolean} carousel true to make the group behave like a carousel
18254 * @cfg {Boolean} bullets show bullets for the panels
18255 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
18256 * @cfg {Number} timer auto slide timer .. default 0 millisecond
18257 * @cfg {Boolean} showarrow (true|false) show arrow default true
18260 * Create a new TabGroup
18261 * @param {Object} config The config object
18264 Roo.bootstrap.TabGroup = function(config){
18265 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
18267 this.navId = Roo.id();
18270 Roo.bootstrap.TabGroup.register(this);
18274 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
18277 transition : false,
18282 slideOnTouch : false,
18285 getAutoCreate : function()
18287 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
18289 cfg.cls += ' tab-content';
18291 if (this.carousel) {
18292 cfg.cls += ' carousel slide';
18295 cls : 'carousel-inner',
18299 if(this.bullets && !Roo.isTouch){
18302 cls : 'carousel-bullets',
18306 if(this.bullets_cls){
18307 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
18314 cfg.cn[0].cn.push(bullets);
18317 if(this.showarrow){
18318 cfg.cn[0].cn.push({
18320 class : 'carousel-arrow',
18324 class : 'carousel-prev',
18328 class : 'fa fa-chevron-left'
18334 class : 'carousel-next',
18338 class : 'fa fa-chevron-right'
18351 initEvents: function()
18353 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
18354 // this.el.on("touchstart", this.onTouchStart, this);
18357 if(this.autoslide){
18360 this.slideFn = window.setInterval(function() {
18361 _this.showPanelNext();
18365 if(this.showarrow){
18366 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
18367 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
18373 // onTouchStart : function(e, el, o)
18375 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
18379 // this.showPanelNext();
18383 getChildContainer : function()
18385 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
18389 * register a Navigation item
18390 * @param {Roo.bootstrap.NavItem} the navitem to add
18392 register : function(item)
18394 this.tabs.push( item);
18395 item.navId = this.navId; // not really needed..
18400 getActivePanel : function()
18403 Roo.each(this.tabs, function(t) {
18413 getPanelByName : function(n)
18416 Roo.each(this.tabs, function(t) {
18417 if (t.tabId == n) {
18425 indexOfPanel : function(p)
18428 Roo.each(this.tabs, function(t,i) {
18429 if (t.tabId == p.tabId) {
18438 * show a specific panel
18439 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
18440 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
18442 showPanel : function (pan)
18444 if(this.transition || typeof(pan) == 'undefined'){
18445 Roo.log("waiting for the transitionend");
18449 if (typeof(pan) == 'number') {
18450 pan = this.tabs[pan];
18453 if (typeof(pan) == 'string') {
18454 pan = this.getPanelByName(pan);
18457 var cur = this.getActivePanel();
18460 Roo.log('pan or acitve pan is undefined');
18464 if (pan.tabId == this.getActivePanel().tabId) {
18468 if (false === cur.fireEvent('beforedeactivate')) {
18472 if(this.bullets > 0 && !Roo.isTouch){
18473 this.setActiveBullet(this.indexOfPanel(pan));
18476 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
18478 //class="carousel-item carousel-item-next carousel-item-left"
18480 this.transition = true;
18481 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
18482 var lr = dir == 'next' ? 'left' : 'right';
18483 pan.el.addClass(dir); // or prev
18484 pan.el.addClass('carousel-item-' + dir); // or prev
18485 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
18486 cur.el.addClass(lr); // or right
18487 pan.el.addClass(lr);
18488 cur.el.addClass('carousel-item-' +lr); // or right
18489 pan.el.addClass('carousel-item-' +lr);
18493 cur.el.on('transitionend', function() {
18494 Roo.log("trans end?");
18496 pan.el.removeClass([lr,dir, 'carousel-item-' + lr, 'carousel-item-' + dir]);
18497 pan.setActive(true);
18499 cur.el.removeClass([lr, 'carousel-item-' + lr]);
18500 cur.setActive(false);
18502 _this.transition = false;
18504 }, this, { single: true } );
18509 cur.setActive(false);
18510 pan.setActive(true);
18515 showPanelNext : function()
18517 var i = this.indexOfPanel(this.getActivePanel());
18519 if (i >= this.tabs.length - 1 && !this.autoslide) {
18523 if (i >= this.tabs.length - 1 && this.autoslide) {
18527 this.showPanel(this.tabs[i+1]);
18530 showPanelPrev : function()
18532 var i = this.indexOfPanel(this.getActivePanel());
18534 if (i < 1 && !this.autoslide) {
18538 if (i < 1 && this.autoslide) {
18539 i = this.tabs.length;
18542 this.showPanel(this.tabs[i-1]);
18546 addBullet: function()
18548 if(!this.bullets || Roo.isTouch){
18551 var ctr = this.el.select('.carousel-bullets',true).first();
18552 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
18553 var bullet = ctr.createChild({
18554 cls : 'bullet bullet-' + i
18555 },ctr.dom.lastChild);
18560 bullet.on('click', (function(e, el, o, ii, t){
18562 e.preventDefault();
18564 this.showPanel(ii);
18566 if(this.autoslide && this.slideFn){
18567 clearInterval(this.slideFn);
18568 this.slideFn = window.setInterval(function() {
18569 _this.showPanelNext();
18573 }).createDelegate(this, [i, bullet], true));
18578 setActiveBullet : function(i)
18584 Roo.each(this.el.select('.bullet', true).elements, function(el){
18585 el.removeClass('selected');
18588 var bullet = this.el.select('.bullet-' + i, true).first();
18594 bullet.addClass('selected');
18605 Roo.apply(Roo.bootstrap.TabGroup, {
18609 * register a Navigation Group
18610 * @param {Roo.bootstrap.NavGroup} the navgroup to add
18612 register : function(navgrp)
18614 this.groups[navgrp.navId] = navgrp;
18618 * fetch a Navigation Group based on the navigation ID
18619 * if one does not exist , it will get created.
18620 * @param {string} the navgroup to add
18621 * @returns {Roo.bootstrap.NavGroup} the navgroup
18623 get: function(navId) {
18624 if (typeof(this.groups[navId]) == 'undefined') {
18625 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
18627 return this.groups[navId] ;
18642 * @class Roo.bootstrap.TabPanel
18643 * @extends Roo.bootstrap.Component
18644 * Bootstrap TabPanel class
18645 * @cfg {Boolean} active panel active
18646 * @cfg {String} html panel content
18647 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
18648 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
18649 * @cfg {String} href click to link..
18653 * Create a new TabPanel
18654 * @param {Object} config The config object
18657 Roo.bootstrap.TabPanel = function(config){
18658 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
18662 * Fires when the active status changes
18663 * @param {Roo.bootstrap.TabPanel} this
18664 * @param {Boolean} state the new state
18669 * @event beforedeactivate
18670 * Fires before a tab is de-activated - can be used to do validation on a form.
18671 * @param {Roo.bootstrap.TabPanel} this
18672 * @return {Boolean} false if there is an error
18675 'beforedeactivate': true
18678 this.tabId = this.tabId || Roo.id();
18682 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
18690 getAutoCreate : function(){
18695 // item is needed for carousel - not sure if it has any effect otherwise
18696 cls: 'carousel-item tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
18697 html: this.html || ''
18701 cfg.cls += ' active';
18705 cfg.tabId = this.tabId;
18713 initEvents: function()
18715 var p = this.parent();
18717 this.navId = this.navId || p.navId;
18719 if (typeof(this.navId) != 'undefined') {
18720 // not really needed.. but just in case.. parent should be a NavGroup.
18721 var tg = Roo.bootstrap.TabGroup.get(this.navId);
18725 var i = tg.tabs.length - 1;
18727 if(this.active && tg.bullets > 0 && i < tg.bullets){
18728 tg.setActiveBullet(i);
18732 this.el.on('click', this.onClick, this);
18735 this.el.on("touchstart", this.onTouchStart, this);
18736 this.el.on("touchmove", this.onTouchMove, this);
18737 this.el.on("touchend", this.onTouchEnd, this);
18742 onRender : function(ct, position)
18744 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
18747 setActive : function(state)
18749 Roo.log("panel - set active " + this.tabId + "=" + state);
18751 this.active = state;
18753 this.el.removeClass('active');
18755 } else if (!this.el.hasClass('active')) {
18756 this.el.addClass('active');
18759 this.fireEvent('changed', this, state);
18762 onClick : function(e)
18764 e.preventDefault();
18766 if(!this.href.length){
18770 window.location.href = this.href;
18779 onTouchStart : function(e)
18781 this.swiping = false;
18783 this.startX = e.browserEvent.touches[0].clientX;
18784 this.startY = e.browserEvent.touches[0].clientY;
18787 onTouchMove : function(e)
18789 this.swiping = true;
18791 this.endX = e.browserEvent.touches[0].clientX;
18792 this.endY = e.browserEvent.touches[0].clientY;
18795 onTouchEnd : function(e)
18802 var tabGroup = this.parent();
18804 if(this.endX > this.startX){ // swiping right
18805 tabGroup.showPanelPrev();
18809 if(this.startX > this.endX){ // swiping left
18810 tabGroup.showPanelNext();
18829 * @class Roo.bootstrap.DateField
18830 * @extends Roo.bootstrap.Input
18831 * Bootstrap DateField class
18832 * @cfg {Number} weekStart default 0
18833 * @cfg {String} viewMode default empty, (months|years)
18834 * @cfg {String} minViewMode default empty, (months|years)
18835 * @cfg {Number} startDate default -Infinity
18836 * @cfg {Number} endDate default Infinity
18837 * @cfg {Boolean} todayHighlight default false
18838 * @cfg {Boolean} todayBtn default false
18839 * @cfg {Boolean} calendarWeeks default false
18840 * @cfg {Object} daysOfWeekDisabled default empty
18841 * @cfg {Boolean} singleMode default false (true | false)
18843 * @cfg {Boolean} keyboardNavigation default true
18844 * @cfg {String} language default en
18847 * Create a new DateField
18848 * @param {Object} config The config object
18851 Roo.bootstrap.DateField = function(config){
18852 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
18856 * Fires when this field show.
18857 * @param {Roo.bootstrap.DateField} this
18858 * @param {Mixed} date The date value
18863 * Fires when this field hide.
18864 * @param {Roo.bootstrap.DateField} this
18865 * @param {Mixed} date The date value
18870 * Fires when select a date.
18871 * @param {Roo.bootstrap.DateField} this
18872 * @param {Mixed} date The date value
18876 * @event beforeselect
18877 * Fires when before select a date.
18878 * @param {Roo.bootstrap.DateField} this
18879 * @param {Mixed} date The date value
18881 beforeselect : true
18885 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
18888 * @cfg {String} format
18889 * The default date format string which can be overriden for localization support. The format must be
18890 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
18894 * @cfg {String} altFormats
18895 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
18896 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
18898 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
18906 todayHighlight : false,
18912 keyboardNavigation: true,
18914 calendarWeeks: false,
18916 startDate: -Infinity,
18920 daysOfWeekDisabled: [],
18924 singleMode : false,
18926 UTCDate: function()
18928 return new Date(Date.UTC.apply(Date, arguments));
18931 UTCToday: function()
18933 var today = new Date();
18934 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
18937 getDate: function() {
18938 var d = this.getUTCDate();
18939 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
18942 getUTCDate: function() {
18946 setDate: function(d) {
18947 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
18950 setUTCDate: function(d) {
18952 this.setValue(this.formatDate(this.date));
18955 onRender: function(ct, position)
18958 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
18960 this.language = this.language || 'en';
18961 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
18962 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
18964 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
18965 this.format = this.format || 'm/d/y';
18966 this.isInline = false;
18967 this.isInput = true;
18968 this.component = this.el.select('.add-on', true).first() || false;
18969 this.component = (this.component && this.component.length === 0) ? false : this.component;
18970 this.hasInput = this.component && this.inputEl().length;
18972 if (typeof(this.minViewMode === 'string')) {
18973 switch (this.minViewMode) {
18975 this.minViewMode = 1;
18978 this.minViewMode = 2;
18981 this.minViewMode = 0;
18986 if (typeof(this.viewMode === 'string')) {
18987 switch (this.viewMode) {
19000 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
19002 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
19004 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19006 this.picker().on('mousedown', this.onMousedown, this);
19007 this.picker().on('click', this.onClick, this);
19009 this.picker().addClass('datepicker-dropdown');
19011 this.startViewMode = this.viewMode;
19013 if(this.singleMode){
19014 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
19015 v.setVisibilityMode(Roo.Element.DISPLAY);
19019 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
19020 v.setStyle('width', '189px');
19024 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
19025 if(!this.calendarWeeks){
19030 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
19031 v.attr('colspan', function(i, val){
19032 return parseInt(val) + 1;
19037 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
19039 this.setStartDate(this.startDate);
19040 this.setEndDate(this.endDate);
19042 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
19049 if(this.isInline) {
19054 picker : function()
19056 return this.pickerEl;
19057 // return this.el.select('.datepicker', true).first();
19060 fillDow: function()
19062 var dowCnt = this.weekStart;
19071 if(this.calendarWeeks){
19079 while (dowCnt < this.weekStart + 7) {
19083 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
19087 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
19090 fillMonths: function()
19093 var months = this.picker().select('>.datepicker-months td', true).first();
19095 months.dom.innerHTML = '';
19101 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
19104 months.createChild(month);
19111 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;
19113 if (this.date < this.startDate) {
19114 this.viewDate = new Date(this.startDate);
19115 } else if (this.date > this.endDate) {
19116 this.viewDate = new Date(this.endDate);
19118 this.viewDate = new Date(this.date);
19126 var d = new Date(this.viewDate),
19127 year = d.getUTCFullYear(),
19128 month = d.getUTCMonth(),
19129 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
19130 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
19131 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
19132 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
19133 currentDate = this.date && this.date.valueOf(),
19134 today = this.UTCToday();
19136 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
19138 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
19140 // this.picker.select('>tfoot th.today').
19141 // .text(dates[this.language].today)
19142 // .toggle(this.todayBtn !== false);
19144 this.updateNavArrows();
19147 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
19149 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
19151 prevMonth.setUTCDate(day);
19153 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
19155 var nextMonth = new Date(prevMonth);
19157 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
19159 nextMonth = nextMonth.valueOf();
19161 var fillMonths = false;
19163 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
19165 while(prevMonth.valueOf() <= nextMonth) {
19168 if (prevMonth.getUTCDay() === this.weekStart) {
19170 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
19178 if(this.calendarWeeks){
19179 // ISO 8601: First week contains first thursday.
19180 // ISO also states week starts on Monday, but we can be more abstract here.
19182 // Start of current week: based on weekstart/current date
19183 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
19184 // Thursday of this week
19185 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
19186 // First Thursday of year, year from thursday
19187 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
19188 // Calendar week: ms between thursdays, div ms per day, div 7 days
19189 calWeek = (th - yth) / 864e5 / 7 + 1;
19191 fillMonths.cn.push({
19199 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
19201 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
19204 if (this.todayHighlight &&
19205 prevMonth.getUTCFullYear() == today.getFullYear() &&
19206 prevMonth.getUTCMonth() == today.getMonth() &&
19207 prevMonth.getUTCDate() == today.getDate()) {
19208 clsName += ' today';
19211 if (currentDate && prevMonth.valueOf() === currentDate) {
19212 clsName += ' active';
19215 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
19216 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
19217 clsName += ' disabled';
19220 fillMonths.cn.push({
19222 cls: 'day ' + clsName,
19223 html: prevMonth.getDate()
19226 prevMonth.setDate(prevMonth.getDate()+1);
19229 var currentYear = this.date && this.date.getUTCFullYear();
19230 var currentMonth = this.date && this.date.getUTCMonth();
19232 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
19234 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
19235 v.removeClass('active');
19237 if(currentYear === year && k === currentMonth){
19238 v.addClass('active');
19241 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
19242 v.addClass('disabled');
19248 year = parseInt(year/10, 10) * 10;
19250 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
19252 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
19255 for (var i = -1; i < 11; i++) {
19256 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
19258 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
19266 showMode: function(dir)
19269 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
19272 Roo.each(this.picker().select('>div',true).elements, function(v){
19273 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19276 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
19281 if(this.isInline) {
19285 this.picker().removeClass(['bottom', 'top']);
19287 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
19289 * place to the top of element!
19293 this.picker().addClass('top');
19294 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
19299 this.picker().addClass('bottom');
19301 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
19304 parseDate : function(value)
19306 if(!value || value instanceof Date){
19309 var v = Date.parseDate(value, this.format);
19310 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
19311 v = Date.parseDate(value, 'Y-m-d');
19313 if(!v && this.altFormats){
19314 if(!this.altFormatsArray){
19315 this.altFormatsArray = this.altFormats.split("|");
19317 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
19318 v = Date.parseDate(value, this.altFormatsArray[i]);
19324 formatDate : function(date, fmt)
19326 return (!date || !(date instanceof Date)) ?
19327 date : date.dateFormat(fmt || this.format);
19330 onFocus : function()
19332 Roo.bootstrap.DateField.superclass.onFocus.call(this);
19336 onBlur : function()
19338 Roo.bootstrap.DateField.superclass.onBlur.call(this);
19340 var d = this.inputEl().getValue();
19347 showPopup : function()
19349 this.picker().show();
19353 this.fireEvent('showpopup', this, this.date);
19356 hidePopup : function()
19358 if(this.isInline) {
19361 this.picker().hide();
19362 this.viewMode = this.startViewMode;
19365 this.fireEvent('hidepopup', this, this.date);
19369 onMousedown: function(e)
19371 e.stopPropagation();
19372 e.preventDefault();
19377 Roo.bootstrap.DateField.superclass.keyup.call(this);
19381 setValue: function(v)
19383 if(this.fireEvent('beforeselect', this, v) !== false){
19384 var d = new Date(this.parseDate(v) ).clearTime();
19386 if(isNaN(d.getTime())){
19387 this.date = this.viewDate = '';
19388 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19392 v = this.formatDate(d);
19394 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
19396 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
19400 this.fireEvent('select', this, this.date);
19404 getValue: function()
19406 return this.formatDate(this.date);
19409 fireKey: function(e)
19411 if (!this.picker().isVisible()){
19412 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19418 var dateChanged = false,
19420 newDate, newViewDate;
19425 e.preventDefault();
19429 if (!this.keyboardNavigation) {
19432 dir = e.keyCode == 37 ? -1 : 1;
19435 newDate = this.moveYear(this.date, dir);
19436 newViewDate = this.moveYear(this.viewDate, dir);
19437 } else if (e.shiftKey){
19438 newDate = this.moveMonth(this.date, dir);
19439 newViewDate = this.moveMonth(this.viewDate, dir);
19441 newDate = new Date(this.date);
19442 newDate.setUTCDate(this.date.getUTCDate() + dir);
19443 newViewDate = new Date(this.viewDate);
19444 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
19446 if (this.dateWithinRange(newDate)){
19447 this.date = newDate;
19448 this.viewDate = newViewDate;
19449 this.setValue(this.formatDate(this.date));
19451 e.preventDefault();
19452 dateChanged = true;
19457 if (!this.keyboardNavigation) {
19460 dir = e.keyCode == 38 ? -1 : 1;
19462 newDate = this.moveYear(this.date, dir);
19463 newViewDate = this.moveYear(this.viewDate, dir);
19464 } else if (e.shiftKey){
19465 newDate = this.moveMonth(this.date, dir);
19466 newViewDate = this.moveMonth(this.viewDate, dir);
19468 newDate = new Date(this.date);
19469 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
19470 newViewDate = new Date(this.viewDate);
19471 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
19473 if (this.dateWithinRange(newDate)){
19474 this.date = newDate;
19475 this.viewDate = newViewDate;
19476 this.setValue(this.formatDate(this.date));
19478 e.preventDefault();
19479 dateChanged = true;
19483 this.setValue(this.formatDate(this.date));
19485 e.preventDefault();
19488 this.setValue(this.formatDate(this.date));
19502 onClick: function(e)
19504 e.stopPropagation();
19505 e.preventDefault();
19507 var target = e.getTarget();
19509 if(target.nodeName.toLowerCase() === 'i'){
19510 target = Roo.get(target).dom.parentNode;
19513 var nodeName = target.nodeName;
19514 var className = target.className;
19515 var html = target.innerHTML;
19516 //Roo.log(nodeName);
19518 switch(nodeName.toLowerCase()) {
19520 switch(className) {
19526 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
19527 switch(this.viewMode){
19529 this.viewDate = this.moveMonth(this.viewDate, dir);
19533 this.viewDate = this.moveYear(this.viewDate, dir);
19539 var date = new Date();
19540 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
19542 this.setValue(this.formatDate(this.date));
19549 if (className.indexOf('disabled') < 0) {
19550 this.viewDate.setUTCDate(1);
19551 if (className.indexOf('month') > -1) {
19552 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
19554 var year = parseInt(html, 10) || 0;
19555 this.viewDate.setUTCFullYear(year);
19559 if(this.singleMode){
19560 this.setValue(this.formatDate(this.viewDate));
19571 //Roo.log(className);
19572 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
19573 var day = parseInt(html, 10) || 1;
19574 var year = this.viewDate.getUTCFullYear(),
19575 month = this.viewDate.getUTCMonth();
19577 if (className.indexOf('old') > -1) {
19584 } else if (className.indexOf('new') > -1) {
19592 //Roo.log([year,month,day]);
19593 this.date = this.UTCDate(year, month, day,0,0,0,0);
19594 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
19596 //Roo.log(this.formatDate(this.date));
19597 this.setValue(this.formatDate(this.date));
19604 setStartDate: function(startDate)
19606 this.startDate = startDate || -Infinity;
19607 if (this.startDate !== -Infinity) {
19608 this.startDate = this.parseDate(this.startDate);
19611 this.updateNavArrows();
19614 setEndDate: function(endDate)
19616 this.endDate = endDate || Infinity;
19617 if (this.endDate !== Infinity) {
19618 this.endDate = this.parseDate(this.endDate);
19621 this.updateNavArrows();
19624 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
19626 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
19627 if (typeof(this.daysOfWeekDisabled) !== 'object') {
19628 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
19630 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
19631 return parseInt(d, 10);
19634 this.updateNavArrows();
19637 updateNavArrows: function()
19639 if(this.singleMode){
19643 var d = new Date(this.viewDate),
19644 year = d.getUTCFullYear(),
19645 month = d.getUTCMonth();
19647 Roo.each(this.picker().select('.prev', true).elements, function(v){
19649 switch (this.viewMode) {
19652 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
19658 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
19665 Roo.each(this.picker().select('.next', true).elements, function(v){
19667 switch (this.viewMode) {
19670 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
19676 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
19684 moveMonth: function(date, dir)
19689 var new_date = new Date(date.valueOf()),
19690 day = new_date.getUTCDate(),
19691 month = new_date.getUTCMonth(),
19692 mag = Math.abs(dir),
19694 dir = dir > 0 ? 1 : -1;
19697 // If going back one month, make sure month is not current month
19698 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
19700 return new_date.getUTCMonth() == month;
19702 // If going forward one month, make sure month is as expected
19703 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
19705 return new_date.getUTCMonth() != new_month;
19707 new_month = month + dir;
19708 new_date.setUTCMonth(new_month);
19709 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
19710 if (new_month < 0 || new_month > 11) {
19711 new_month = (new_month + 12) % 12;
19714 // For magnitudes >1, move one month at a time...
19715 for (var i=0; i<mag; i++) {
19716 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
19717 new_date = this.moveMonth(new_date, dir);
19719 // ...then reset the day, keeping it in the new month
19720 new_month = new_date.getUTCMonth();
19721 new_date.setUTCDate(day);
19723 return new_month != new_date.getUTCMonth();
19726 // Common date-resetting loop -- if date is beyond end of month, make it
19729 new_date.setUTCDate(--day);
19730 new_date.setUTCMonth(new_month);
19735 moveYear: function(date, dir)
19737 return this.moveMonth(date, dir*12);
19740 dateWithinRange: function(date)
19742 return date >= this.startDate && date <= this.endDate;
19748 this.picker().remove();
19751 validateValue : function(value)
19753 if(this.getVisibilityEl().hasClass('hidden')){
19757 if(value.length < 1) {
19758 if(this.allowBlank){
19764 if(value.length < this.minLength){
19767 if(value.length > this.maxLength){
19771 var vt = Roo.form.VTypes;
19772 if(!vt[this.vtype](value, this)){
19776 if(typeof this.validator == "function"){
19777 var msg = this.validator(value);
19783 if(this.regex && !this.regex.test(value)){
19787 if(typeof(this.parseDate(value)) == 'undefined'){
19791 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
19795 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
19805 this.date = this.viewDate = '';
19807 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19812 Roo.apply(Roo.bootstrap.DateField, {
19823 html: '<i class="fa fa-arrow-left"/>'
19833 html: '<i class="fa fa-arrow-right"/>'
19875 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
19876 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
19877 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
19878 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
19879 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
19892 navFnc: 'FullYear',
19897 navFnc: 'FullYear',
19902 Roo.apply(Roo.bootstrap.DateField, {
19906 cls: 'datepicker dropdown-menu roo-dynamic',
19910 cls: 'datepicker-days',
19914 cls: 'table-condensed',
19916 Roo.bootstrap.DateField.head,
19920 Roo.bootstrap.DateField.footer
19927 cls: 'datepicker-months',
19931 cls: 'table-condensed',
19933 Roo.bootstrap.DateField.head,
19934 Roo.bootstrap.DateField.content,
19935 Roo.bootstrap.DateField.footer
19942 cls: 'datepicker-years',
19946 cls: 'table-condensed',
19948 Roo.bootstrap.DateField.head,
19949 Roo.bootstrap.DateField.content,
19950 Roo.bootstrap.DateField.footer
19969 * @class Roo.bootstrap.TimeField
19970 * @extends Roo.bootstrap.Input
19971 * Bootstrap DateField class
19975 * Create a new TimeField
19976 * @param {Object} config The config object
19979 Roo.bootstrap.TimeField = function(config){
19980 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
19984 * Fires when this field show.
19985 * @param {Roo.bootstrap.DateField} thisthis
19986 * @param {Mixed} date The date value
19991 * Fires when this field hide.
19992 * @param {Roo.bootstrap.DateField} this
19993 * @param {Mixed} date The date value
19998 * Fires when select a date.
19999 * @param {Roo.bootstrap.DateField} this
20000 * @param {Mixed} date The date value
20006 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
20009 * @cfg {String} format
20010 * The default time format string which can be overriden for localization support. The format must be
20011 * valid according to {@link Date#parseDate} (defaults to 'H:i').
20015 onRender: function(ct, position)
20018 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
20020 this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.TimeField.template);
20022 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
20024 this.pop = this.picker().select('>.datepicker-time',true).first();
20025 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
20027 this.picker().on('mousedown', this.onMousedown, this);
20028 this.picker().on('click', this.onClick, this);
20030 this.picker().addClass('datepicker-dropdown');
20035 this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
20036 this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
20037 this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
20038 this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
20039 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
20040 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
20044 fireKey: function(e){
20045 if (!this.picker().isVisible()){
20046 if (e.keyCode == 27) { // allow escape to hide and re-show picker
20052 e.preventDefault();
20060 this.onTogglePeriod();
20063 this.onIncrementMinutes();
20066 this.onDecrementMinutes();
20075 onClick: function(e) {
20076 e.stopPropagation();
20077 e.preventDefault();
20080 picker : function()
20082 return this.el.select('.datepicker', true).first();
20085 fillTime: function()
20087 var time = this.pop.select('tbody', true).first();
20089 time.dom.innerHTML = '';
20104 cls: 'hours-up glyphicon glyphicon-chevron-up'
20124 cls: 'minutes-up glyphicon glyphicon-chevron-up'
20145 cls: 'timepicker-hour',
20160 cls: 'timepicker-minute',
20175 cls: 'btn btn-primary period',
20197 cls: 'hours-down glyphicon glyphicon-chevron-down'
20217 cls: 'minutes-down glyphicon glyphicon-chevron-down'
20235 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
20242 var hours = this.time.getHours();
20243 var minutes = this.time.getMinutes();
20256 hours = hours - 12;
20260 hours = '0' + hours;
20264 minutes = '0' + minutes;
20267 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
20268 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
20269 this.pop.select('button', true).first().dom.innerHTML = period;
20275 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
20277 var cls = ['bottom'];
20279 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
20286 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
20291 this.picker().addClass(cls.join('-'));
20295 Roo.each(cls, function(c){
20297 _this.picker().setTop(_this.inputEl().getHeight());
20301 _this.picker().setTop(0 - _this.picker().getHeight());
20306 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
20310 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
20317 onFocus : function()
20319 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
20323 onBlur : function()
20325 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
20331 this.picker().show();
20336 this.fireEvent('show', this, this.date);
20341 this.picker().hide();
20344 this.fireEvent('hide', this, this.date);
20347 setTime : function()
20350 this.setValue(this.time.format(this.format));
20352 this.fireEvent('select', this, this.date);
20357 onMousedown: function(e){
20358 e.stopPropagation();
20359 e.preventDefault();
20362 onIncrementHours: function()
20364 Roo.log('onIncrementHours');
20365 this.time = this.time.add(Date.HOUR, 1);
20370 onDecrementHours: function()
20372 Roo.log('onDecrementHours');
20373 this.time = this.time.add(Date.HOUR, -1);
20377 onIncrementMinutes: function()
20379 Roo.log('onIncrementMinutes');
20380 this.time = this.time.add(Date.MINUTE, 1);
20384 onDecrementMinutes: function()
20386 Roo.log('onDecrementMinutes');
20387 this.time = this.time.add(Date.MINUTE, -1);
20391 onTogglePeriod: function()
20393 Roo.log('onTogglePeriod');
20394 this.time = this.time.add(Date.HOUR, 12);
20401 Roo.apply(Roo.bootstrap.TimeField, {
20431 cls: 'btn btn-info ok',
20443 Roo.apply(Roo.bootstrap.TimeField, {
20447 cls: 'datepicker dropdown-menu',
20451 cls: 'datepicker-time',
20455 cls: 'table-condensed',
20457 Roo.bootstrap.TimeField.content,
20458 Roo.bootstrap.TimeField.footer
20477 * @class Roo.bootstrap.MonthField
20478 * @extends Roo.bootstrap.Input
20479 * Bootstrap MonthField class
20481 * @cfg {String} language default en
20484 * Create a new MonthField
20485 * @param {Object} config The config object
20488 Roo.bootstrap.MonthField = function(config){
20489 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
20494 * Fires when this field show.
20495 * @param {Roo.bootstrap.MonthField} this
20496 * @param {Mixed} date The date value
20501 * Fires when this field hide.
20502 * @param {Roo.bootstrap.MonthField} this
20503 * @param {Mixed} date The date value
20508 * Fires when select a date.
20509 * @param {Roo.bootstrap.MonthField} this
20510 * @param {String} oldvalue The old value
20511 * @param {String} newvalue The new value
20517 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
20519 onRender: function(ct, position)
20522 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
20524 this.language = this.language || 'en';
20525 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
20526 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
20528 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
20529 this.isInline = false;
20530 this.isInput = true;
20531 this.component = this.el.select('.add-on', true).first() || false;
20532 this.component = (this.component && this.component.length === 0) ? false : this.component;
20533 this.hasInput = this.component && this.inputEL().length;
20535 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
20537 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
20539 this.picker().on('mousedown', this.onMousedown, this);
20540 this.picker().on('click', this.onClick, this);
20542 this.picker().addClass('datepicker-dropdown');
20544 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
20545 v.setStyle('width', '189px');
20552 if(this.isInline) {
20558 setValue: function(v, suppressEvent)
20560 var o = this.getValue();
20562 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
20566 if(suppressEvent !== true){
20567 this.fireEvent('select', this, o, v);
20572 getValue: function()
20577 onClick: function(e)
20579 e.stopPropagation();
20580 e.preventDefault();
20582 var target = e.getTarget();
20584 if(target.nodeName.toLowerCase() === 'i'){
20585 target = Roo.get(target).dom.parentNode;
20588 var nodeName = target.nodeName;
20589 var className = target.className;
20590 var html = target.innerHTML;
20592 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
20596 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
20598 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20604 picker : function()
20606 return this.pickerEl;
20609 fillMonths: function()
20612 var months = this.picker().select('>.datepicker-months td', true).first();
20614 months.dom.innerHTML = '';
20620 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
20623 months.createChild(month);
20632 if(typeof(this.vIndex) == 'undefined' && this.value.length){
20633 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
20636 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
20637 e.removeClass('active');
20639 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
20640 e.addClass('active');
20647 if(this.isInline) {
20651 this.picker().removeClass(['bottom', 'top']);
20653 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
20655 * place to the top of element!
20659 this.picker().addClass('top');
20660 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
20665 this.picker().addClass('bottom');
20667 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
20670 onFocus : function()
20672 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
20676 onBlur : function()
20678 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
20680 var d = this.inputEl().getValue();
20689 this.picker().show();
20690 this.picker().select('>.datepicker-months', true).first().show();
20694 this.fireEvent('show', this, this.date);
20699 if(this.isInline) {
20702 this.picker().hide();
20703 this.fireEvent('hide', this, this.date);
20707 onMousedown: function(e)
20709 e.stopPropagation();
20710 e.preventDefault();
20715 Roo.bootstrap.MonthField.superclass.keyup.call(this);
20719 fireKey: function(e)
20721 if (!this.picker().isVisible()){
20722 if (e.keyCode == 27) {// allow escape to hide and re-show picker
20733 e.preventDefault();
20737 dir = e.keyCode == 37 ? -1 : 1;
20739 this.vIndex = this.vIndex + dir;
20741 if(this.vIndex < 0){
20745 if(this.vIndex > 11){
20749 if(isNaN(this.vIndex)){
20753 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20759 dir = e.keyCode == 38 ? -1 : 1;
20761 this.vIndex = this.vIndex + dir * 4;
20763 if(this.vIndex < 0){
20767 if(this.vIndex > 11){
20771 if(isNaN(this.vIndex)){
20775 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20780 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20781 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20785 e.preventDefault();
20788 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20789 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20805 this.picker().remove();
20810 Roo.apply(Roo.bootstrap.MonthField, {
20829 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
20830 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
20835 Roo.apply(Roo.bootstrap.MonthField, {
20839 cls: 'datepicker dropdown-menu roo-dynamic',
20843 cls: 'datepicker-months',
20847 cls: 'table-condensed',
20849 Roo.bootstrap.DateField.content
20869 * @class Roo.bootstrap.CheckBox
20870 * @extends Roo.bootstrap.Input
20871 * Bootstrap CheckBox class
20873 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
20874 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
20875 * @cfg {String} boxLabel The text that appears beside the checkbox
20876 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
20877 * @cfg {Boolean} checked initnal the element
20878 * @cfg {Boolean} inline inline the element (default false)
20879 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
20880 * @cfg {String} tooltip label tooltip
20883 * Create a new CheckBox
20884 * @param {Object} config The config object
20887 Roo.bootstrap.CheckBox = function(config){
20888 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
20893 * Fires when the element is checked or unchecked.
20894 * @param {Roo.bootstrap.CheckBox} this This input
20895 * @param {Boolean} checked The new checked value
20900 * Fires when the element is click.
20901 * @param {Roo.bootstrap.CheckBox} this This input
20908 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
20910 inputType: 'checkbox',
20919 getAutoCreate : function()
20921 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
20927 cfg.cls = 'form-group ' + this.inputType; //input-group
20930 cfg.cls += ' ' + this.inputType + '-inline';
20936 type : this.inputType,
20937 value : this.inputValue,
20938 cls : 'roo-' + this.inputType, //'form-box',
20939 placeholder : this.placeholder || ''
20943 if(this.inputType != 'radio'){
20947 cls : 'roo-hidden-value',
20948 value : this.checked ? this.inputValue : this.valueOff
20953 if (this.weight) { // Validity check?
20954 cfg.cls += " " + this.inputType + "-" + this.weight;
20957 if (this.disabled) {
20958 input.disabled=true;
20962 input.checked = this.checked;
20967 input.name = this.name;
20969 if(this.inputType != 'radio'){
20970 hidden.name = this.name;
20971 input.name = '_hidden_' + this.name;
20976 input.cls += ' input-' + this.size;
20981 ['xs','sm','md','lg'].map(function(size){
20982 if (settings[size]) {
20983 cfg.cls += ' col-' + size + '-' + settings[size];
20987 var inputblock = input;
20989 if (this.before || this.after) {
20992 cls : 'input-group',
20997 inputblock.cn.push({
20999 cls : 'input-group-addon',
21004 inputblock.cn.push(input);
21006 if(this.inputType != 'radio'){
21007 inputblock.cn.push(hidden);
21011 inputblock.cn.push({
21013 cls : 'input-group-addon',
21020 if (align ==='left' && this.fieldLabel.length) {
21021 // Roo.log("left and has label");
21026 cls : 'control-label',
21027 html : this.fieldLabel
21037 if(this.labelWidth > 12){
21038 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
21041 if(this.labelWidth < 13 && this.labelmd == 0){
21042 this.labelmd = this.labelWidth;
21045 if(this.labellg > 0){
21046 cfg.cn[0].cls += ' col-lg-' + this.labellg;
21047 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
21050 if(this.labelmd > 0){
21051 cfg.cn[0].cls += ' col-md-' + this.labelmd;
21052 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
21055 if(this.labelsm > 0){
21056 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
21057 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
21060 if(this.labelxs > 0){
21061 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
21062 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
21065 } else if ( this.fieldLabel.length) {
21066 // Roo.log(" label");
21070 tag: this.boxLabel ? 'span' : 'label',
21072 cls: 'control-label box-input-label',
21073 //cls : 'input-group-addon',
21074 html : this.fieldLabel
21083 // Roo.log(" no label && no align");
21084 cfg.cn = [ inputblock ] ;
21090 var boxLabelCfg = {
21092 //'for': id, // box label is handled by onclick - so no for...
21094 html: this.boxLabel
21098 boxLabelCfg.tooltip = this.tooltip;
21101 cfg.cn.push(boxLabelCfg);
21104 if(this.inputType != 'radio'){
21105 cfg.cn.push(hidden);
21113 * return the real input element.
21115 inputEl: function ()
21117 return this.el.select('input.roo-' + this.inputType,true).first();
21119 hiddenEl: function ()
21121 return this.el.select('input.roo-hidden-value',true).first();
21124 labelEl: function()
21126 return this.el.select('label.control-label',true).first();
21128 /* depricated... */
21132 return this.labelEl();
21135 boxLabelEl: function()
21137 return this.el.select('label.box-label',true).first();
21140 initEvents : function()
21142 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
21144 this.inputEl().on('click', this.onClick, this);
21146 if (this.boxLabel) {
21147 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
21150 this.startValue = this.getValue();
21153 Roo.bootstrap.CheckBox.register(this);
21157 onClick : function(e)
21159 if(this.fireEvent('click', this, e) !== false){
21160 this.setChecked(!this.checked);
21165 setChecked : function(state,suppressEvent)
21167 this.startValue = this.getValue();
21169 if(this.inputType == 'radio'){
21171 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21172 e.dom.checked = false;
21175 this.inputEl().dom.checked = true;
21177 this.inputEl().dom.value = this.inputValue;
21179 if(suppressEvent !== true){
21180 this.fireEvent('check', this, true);
21188 this.checked = state;
21190 this.inputEl().dom.checked = state;
21193 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
21195 if(suppressEvent !== true){
21196 this.fireEvent('check', this, state);
21202 getValue : function()
21204 if(this.inputType == 'radio'){
21205 return this.getGroupValue();
21208 return this.hiddenEl().dom.value;
21212 getGroupValue : function()
21214 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
21218 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
21221 setValue : function(v,suppressEvent)
21223 if(this.inputType == 'radio'){
21224 this.setGroupValue(v, suppressEvent);
21228 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
21233 setGroupValue : function(v, suppressEvent)
21235 this.startValue = this.getValue();
21237 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21238 e.dom.checked = false;
21240 if(e.dom.value == v){
21241 e.dom.checked = true;
21245 if(suppressEvent !== true){
21246 this.fireEvent('check', this, true);
21254 validate : function()
21256 if(this.getVisibilityEl().hasClass('hidden')){
21262 (this.inputType == 'radio' && this.validateRadio()) ||
21263 (this.inputType == 'checkbox' && this.validateCheckbox())
21269 this.markInvalid();
21273 validateRadio : function()
21275 if(this.getVisibilityEl().hasClass('hidden')){
21279 if(this.allowBlank){
21285 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21286 if(!e.dom.checked){
21298 validateCheckbox : function()
21301 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
21302 //return (this.getValue() == this.inputValue) ? true : false;
21305 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21313 for(var i in group){
21314 if(group[i].el.isVisible(true)){
21322 for(var i in group){
21327 r = (group[i].getValue() == group[i].inputValue) ? true : false;
21334 * Mark this field as valid
21336 markValid : function()
21340 this.fireEvent('valid', this);
21342 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21345 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21352 if(this.inputType == 'radio'){
21353 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21354 var fg = e.findParent('.form-group', false, true);
21355 if (Roo.bootstrap.version == 3) {
21356 fg.removeClass([_this.invalidClass, _this.validClass]);
21357 fg.addClass(_this.validClass);
21359 fg.removeClass(['is-valid', 'is-invalid']);
21360 fg.addClass('is-valid');
21368 var fg = this.el.findParent('.form-group', false, true);
21369 if (Roo.bootstrap.version == 3) {
21370 fg.removeClass([this.invalidClass, this.validClass]);
21371 fg.addClass(this.validClass);
21373 fg.removeClass(['is-valid', 'is-invalid']);
21374 fg.addClass('is-valid');
21379 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21385 for(var i in group){
21386 var fg = group[i].el.findParent('.form-group', false, true);
21387 if (Roo.bootstrap.version == 3) {
21388 fg.removeClass([this.invalidClass, this.validClass]);
21389 fg.addClass(this.validClass);
21391 fg.removeClass(['is-valid', 'is-invalid']);
21392 fg.addClass('is-valid');
21398 * Mark this field as invalid
21399 * @param {String} msg The validation message
21401 markInvalid : function(msg)
21403 if(this.allowBlank){
21409 this.fireEvent('invalid', this, msg);
21411 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21414 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21418 label.markInvalid();
21421 if(this.inputType == 'radio'){
21423 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21424 var fg = e.findParent('.form-group', false, true);
21425 if (Roo.bootstrap.version == 3) {
21426 fg.removeClass([_this.invalidClass, _this.validClass]);
21427 fg.addClass(_this.invalidClass);
21429 fg.removeClass(['is-invalid', 'is-valid']);
21430 fg.addClass('is-invalid');
21438 var fg = this.el.findParent('.form-group', false, true);
21439 if (Roo.bootstrap.version == 3) {
21440 fg.removeClass([_this.invalidClass, _this.validClass]);
21441 fg.addClass(_this.invalidClass);
21443 fg.removeClass(['is-invalid', 'is-valid']);
21444 fg.addClass('is-invalid');
21449 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21455 for(var i in group){
21456 var fg = group[i].el.findParent('.form-group', false, true);
21457 if (Roo.bootstrap.version == 3) {
21458 fg.removeClass([_this.invalidClass, _this.validClass]);
21459 fg.addClass(_this.invalidClass);
21461 fg.removeClass(['is-invalid', 'is-valid']);
21462 fg.addClass('is-invalid');
21468 clearInvalid : function()
21470 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
21472 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
21474 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21476 if (label && label.iconEl) {
21477 label.iconEl.removeClass([ label.validClass, label.invalidClass ]);
21478 label.iconEl.removeClass(['is-invalid', 'is-valid']);
21482 disable : function()
21484 if(this.inputType != 'radio'){
21485 Roo.bootstrap.CheckBox.superclass.disable.call(this);
21492 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21493 _this.getActionEl().addClass(this.disabledClass);
21494 e.dom.disabled = true;
21498 this.disabled = true;
21499 this.fireEvent("disable", this);
21503 enable : function()
21505 if(this.inputType != 'radio'){
21506 Roo.bootstrap.CheckBox.superclass.enable.call(this);
21513 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21514 _this.getActionEl().removeClass(this.disabledClass);
21515 e.dom.disabled = false;
21519 this.disabled = false;
21520 this.fireEvent("enable", this);
21524 setBoxLabel : function(v)
21529 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21535 Roo.apply(Roo.bootstrap.CheckBox, {
21540 * register a CheckBox Group
21541 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
21543 register : function(checkbox)
21545 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
21546 this.groups[checkbox.groupId] = {};
21549 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
21553 this.groups[checkbox.groupId][checkbox.name] = checkbox;
21557 * fetch a CheckBox Group based on the group ID
21558 * @param {string} the group ID
21559 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
21561 get: function(groupId) {
21562 if (typeof(this.groups[groupId]) == 'undefined') {
21566 return this.groups[groupId] ;
21579 * @class Roo.bootstrap.Radio
21580 * @extends Roo.bootstrap.Component
21581 * Bootstrap Radio class
21582 * @cfg {String} boxLabel - the label associated
21583 * @cfg {String} value - the value of radio
21586 * Create a new Radio
21587 * @param {Object} config The config object
21589 Roo.bootstrap.Radio = function(config){
21590 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
21594 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
21600 getAutoCreate : function()
21604 cls : 'form-group radio',
21609 html : this.boxLabel
21617 initEvents : function()
21619 this.parent().register(this);
21621 this.el.on('click', this.onClick, this);
21625 onClick : function(e)
21627 if(this.parent().fireEvent('click', this.parent(), this, e) !== false){
21628 this.setChecked(true);
21632 setChecked : function(state, suppressEvent)
21634 this.parent().setValue(this.value, suppressEvent);
21638 setBoxLabel : function(v)
21643 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21658 * @class Roo.bootstrap.SecurePass
21659 * @extends Roo.bootstrap.Input
21660 * Bootstrap SecurePass class
21664 * Create a new SecurePass
21665 * @param {Object} config The config object
21668 Roo.bootstrap.SecurePass = function (config) {
21669 // these go here, so the translation tool can replace them..
21671 PwdEmpty: "Please type a password, and then retype it to confirm.",
21672 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21673 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21674 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21675 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21676 FNInPwd: "Your password can't contain your first name. Please type a different password.",
21677 LNInPwd: "Your password can't contain your last name. Please type a different password.",
21678 TooWeak: "Your password is Too Weak."
21680 this.meterLabel = "Password strength:";
21681 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
21682 this.meterClass = [
21683 "roo-password-meter-tooweak",
21684 "roo-password-meter-weak",
21685 "roo-password-meter-medium",
21686 "roo-password-meter-strong",
21687 "roo-password-meter-grey"
21692 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
21695 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
21697 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
21699 * PwdEmpty: "Please type a password, and then retype it to confirm.",
21700 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21701 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21702 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21703 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21704 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
21705 * LNInPwd: "Your password can't contain your last name. Please type a different password."
21715 * @cfg {String/Object} Label for the strength meter (defaults to
21716 * 'Password strength:')
21721 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
21722 * ['Weak', 'Medium', 'Strong'])
21725 pwdStrengths: false,
21738 initEvents: function ()
21740 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
21742 if (this.el.is('input[type=password]') && Roo.isSafari) {
21743 this.el.on('keydown', this.SafariOnKeyDown, this);
21746 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
21749 onRender: function (ct, position)
21751 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
21752 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
21753 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
21755 this.trigger.createChild({
21760 cls: 'roo-password-meter-grey col-xs-12',
21763 //width: this.meterWidth + 'px'
21767 cls: 'roo-password-meter-text'
21773 if (this.hideTrigger) {
21774 this.trigger.setDisplayed(false);
21776 this.setSize(this.width || '', this.height || '');
21779 onDestroy: function ()
21781 if (this.trigger) {
21782 this.trigger.removeAllListeners();
21783 this.trigger.remove();
21786 this.wrap.remove();
21788 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
21791 checkStrength: function ()
21793 var pwd = this.inputEl().getValue();
21794 if (pwd == this._lastPwd) {
21799 if (this.ClientSideStrongPassword(pwd)) {
21801 } else if (this.ClientSideMediumPassword(pwd)) {
21803 } else if (this.ClientSideWeakPassword(pwd)) {
21809 Roo.log('strength1: ' + strength);
21811 //var pm = this.trigger.child('div/div/div').dom;
21812 var pm = this.trigger.child('div/div');
21813 pm.removeClass(this.meterClass);
21814 pm.addClass(this.meterClass[strength]);
21817 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21819 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21821 this._lastPwd = pwd;
21825 Roo.bootstrap.SecurePass.superclass.reset.call(this);
21827 this._lastPwd = '';
21829 var pm = this.trigger.child('div/div');
21830 pm.removeClass(this.meterClass);
21831 pm.addClass('roo-password-meter-grey');
21834 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21837 this.inputEl().dom.type='password';
21840 validateValue: function (value)
21843 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
21846 if (value.length == 0) {
21847 if (this.allowBlank) {
21848 this.clearInvalid();
21852 this.markInvalid(this.errors.PwdEmpty);
21853 this.errorMsg = this.errors.PwdEmpty;
21861 if ('[\x21-\x7e]*'.match(value)) {
21862 this.markInvalid(this.errors.PwdBadChar);
21863 this.errorMsg = this.errors.PwdBadChar;
21866 if (value.length < 6) {
21867 this.markInvalid(this.errors.PwdShort);
21868 this.errorMsg = this.errors.PwdShort;
21871 if (value.length > 16) {
21872 this.markInvalid(this.errors.PwdLong);
21873 this.errorMsg = this.errors.PwdLong;
21877 if (this.ClientSideStrongPassword(value)) {
21879 } else if (this.ClientSideMediumPassword(value)) {
21881 } else if (this.ClientSideWeakPassword(value)) {
21888 if (strength < 2) {
21889 //this.markInvalid(this.errors.TooWeak);
21890 this.errorMsg = this.errors.TooWeak;
21895 console.log('strength2: ' + strength);
21897 //var pm = this.trigger.child('div/div/div').dom;
21899 var pm = this.trigger.child('div/div');
21900 pm.removeClass(this.meterClass);
21901 pm.addClass(this.meterClass[strength]);
21903 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21905 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21907 this.errorMsg = '';
21911 CharacterSetChecks: function (type)
21914 this.fResult = false;
21917 isctype: function (character, type)
21920 case this.kCapitalLetter:
21921 if (character >= 'A' && character <= 'Z') {
21926 case this.kSmallLetter:
21927 if (character >= 'a' && character <= 'z') {
21933 if (character >= '0' && character <= '9') {
21938 case this.kPunctuation:
21939 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
21950 IsLongEnough: function (pwd, size)
21952 return !(pwd == null || isNaN(size) || pwd.length < size);
21955 SpansEnoughCharacterSets: function (word, nb)
21957 if (!this.IsLongEnough(word, nb))
21962 var characterSetChecks = new Array(
21963 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
21964 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
21967 for (var index = 0; index < word.length; ++index) {
21968 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21969 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
21970 characterSetChecks[nCharSet].fResult = true;
21977 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21978 if (characterSetChecks[nCharSet].fResult) {
21983 if (nCharSets < nb) {
21989 ClientSideStrongPassword: function (pwd)
21991 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
21994 ClientSideMediumPassword: function (pwd)
21996 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
21999 ClientSideWeakPassword: function (pwd)
22001 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
22004 })//<script type="text/javascript">
22007 * Based Ext JS Library 1.1.1
22008 * Copyright(c) 2006-2007, Ext JS, LLC.
22014 * @class Roo.HtmlEditorCore
22015 * @extends Roo.Component
22016 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
22018 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
22021 Roo.HtmlEditorCore = function(config){
22024 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
22029 * @event initialize
22030 * Fires when the editor is fully initialized (including the iframe)
22031 * @param {Roo.HtmlEditorCore} this
22036 * Fires when the editor is first receives the focus. Any insertion must wait
22037 * until after this event.
22038 * @param {Roo.HtmlEditorCore} this
22042 * @event beforesync
22043 * Fires before the textarea is updated with content from the editor iframe. Return false
22044 * to cancel the sync.
22045 * @param {Roo.HtmlEditorCore} this
22046 * @param {String} html
22050 * @event beforepush
22051 * Fires before the iframe editor is updated with content from the textarea. Return false
22052 * to cancel the push.
22053 * @param {Roo.HtmlEditorCore} this
22054 * @param {String} html
22059 * Fires when the textarea is updated with content from the editor iframe.
22060 * @param {Roo.HtmlEditorCore} this
22061 * @param {String} html
22066 * Fires when the iframe editor is updated with content from the textarea.
22067 * @param {Roo.HtmlEditorCore} this
22068 * @param {String} html
22073 * @event editorevent
22074 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
22075 * @param {Roo.HtmlEditorCore} this
22081 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
22083 // defaults : white / black...
22084 this.applyBlacklists();
22091 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
22095 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
22101 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
22106 * @cfg {Number} height (in pixels)
22110 * @cfg {Number} width (in pixels)
22115 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
22118 stylesheets: false,
22123 // private properties
22124 validationEvent : false,
22126 initialized : false,
22128 sourceEditMode : false,
22129 onFocus : Roo.emptyFn,
22131 hideMode:'offsets',
22135 // blacklist + whitelisted elements..
22142 * Protected method that will not generally be called directly. It
22143 * is called when the editor initializes the iframe with HTML contents. Override this method if you
22144 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
22146 getDocMarkup : function(){
22150 // inherit styels from page...??
22151 if (this.stylesheets === false) {
22153 Roo.get(document.head).select('style').each(function(node) {
22154 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
22157 Roo.get(document.head).select('link').each(function(node) {
22158 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
22161 } else if (!this.stylesheets.length) {
22163 st = '<style type="text/css">' +
22164 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
22167 st = '<style type="text/css">' +
22172 st += '<style type="text/css">' +
22173 'IMG { cursor: pointer } ' +
22176 var cls = 'roo-htmleditor-body';
22178 if(this.bodyCls.length){
22179 cls += ' ' + this.bodyCls;
22182 return '<html><head>' + st +
22183 //<style type="text/css">' +
22184 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
22186 ' </head><body class="' + cls + '"></body></html>';
22190 onRender : function(ct, position)
22193 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
22194 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
22197 this.el.dom.style.border = '0 none';
22198 this.el.dom.setAttribute('tabIndex', -1);
22199 this.el.addClass('x-hidden hide');
22203 if(Roo.isIE){ // fix IE 1px bogus margin
22204 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
22208 this.frameId = Roo.id();
22212 var iframe = this.owner.wrap.createChild({
22214 cls: 'form-control', // bootstrap..
22216 name: this.frameId,
22217 frameBorder : 'no',
22218 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
22223 this.iframe = iframe.dom;
22225 this.assignDocWin();
22227 this.doc.designMode = 'on';
22230 this.doc.write(this.getDocMarkup());
22234 var task = { // must defer to wait for browser to be ready
22236 //console.log("run task?" + this.doc.readyState);
22237 this.assignDocWin();
22238 if(this.doc.body || this.doc.readyState == 'complete'){
22240 this.doc.designMode="on";
22244 Roo.TaskMgr.stop(task);
22245 this.initEditor.defer(10, this);
22252 Roo.TaskMgr.start(task);
22257 onResize : function(w, h)
22259 Roo.log('resize: ' +w + ',' + h );
22260 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
22264 if(typeof w == 'number'){
22266 this.iframe.style.width = w + 'px';
22268 if(typeof h == 'number'){
22270 this.iframe.style.height = h + 'px';
22272 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
22279 * Toggles the editor between standard and source edit mode.
22280 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
22282 toggleSourceEdit : function(sourceEditMode){
22284 this.sourceEditMode = sourceEditMode === true;
22286 if(this.sourceEditMode){
22288 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
22291 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
22292 //this.iframe.className = '';
22295 //this.setSize(this.owner.wrap.getSize());
22296 //this.fireEvent('editmodechange', this, this.sourceEditMode);
22303 * Protected method that will not generally be called directly. If you need/want
22304 * custom HTML cleanup, this is the method you should override.
22305 * @param {String} html The HTML to be cleaned
22306 * return {String} The cleaned HTML
22308 cleanHtml : function(html){
22309 html = String(html);
22310 if(html.length > 5){
22311 if(Roo.isSafari){ // strip safari nonsense
22312 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
22315 if(html == ' '){
22322 * HTML Editor -> Textarea
22323 * Protected method that will not generally be called directly. Syncs the contents
22324 * of the editor iframe with the textarea.
22326 syncValue : function(){
22327 if(this.initialized){
22328 var bd = (this.doc.body || this.doc.documentElement);
22329 //this.cleanUpPaste(); -- this is done else where and causes havoc..
22330 var html = bd.innerHTML;
22332 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
22333 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
22335 html = '<div style="'+m[0]+'">' + html + '</div>';
22338 html = this.cleanHtml(html);
22339 // fix up the special chars.. normaly like back quotes in word...
22340 // however we do not want to do this with chinese..
22341 html = html.replace(/([\x80-\uffff])/g, function (a, b) {
22342 var cc = b.charCodeAt();
22344 (cc >= 0x4E00 && cc < 0xA000 ) ||
22345 (cc >= 0x3400 && cc < 0x4E00 ) ||
22346 (cc >= 0xf900 && cc < 0xfb00 )
22352 if(this.owner.fireEvent('beforesync', this, html) !== false){
22353 this.el.dom.value = html;
22354 this.owner.fireEvent('sync', this, html);
22360 * Protected method that will not generally be called directly. Pushes the value of the textarea
22361 * into the iframe editor.
22363 pushValue : function(){
22364 if(this.initialized){
22365 var v = this.el.dom.value.trim();
22367 // if(v.length < 1){
22371 if(this.owner.fireEvent('beforepush', this, v) !== false){
22372 var d = (this.doc.body || this.doc.documentElement);
22374 this.cleanUpPaste();
22375 this.el.dom.value = d.innerHTML;
22376 this.owner.fireEvent('push', this, v);
22382 deferFocus : function(){
22383 this.focus.defer(10, this);
22387 focus : function(){
22388 if(this.win && !this.sourceEditMode){
22395 assignDocWin: function()
22397 var iframe = this.iframe;
22400 this.doc = iframe.contentWindow.document;
22401 this.win = iframe.contentWindow;
22403 // if (!Roo.get(this.frameId)) {
22406 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22407 // this.win = Roo.get(this.frameId).dom.contentWindow;
22409 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
22413 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22414 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
22419 initEditor : function(){
22420 //console.log("INIT EDITOR");
22421 this.assignDocWin();
22425 this.doc.designMode="on";
22427 this.doc.write(this.getDocMarkup());
22430 var dbody = (this.doc.body || this.doc.documentElement);
22431 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
22432 // this copies styles from the containing element into thsi one..
22433 // not sure why we need all of this..
22434 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
22436 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
22437 //ss['background-attachment'] = 'fixed'; // w3c
22438 dbody.bgProperties = 'fixed'; // ie
22439 //Roo.DomHelper.applyStyles(dbody, ss);
22440 Roo.EventManager.on(this.doc, {
22441 //'mousedown': this.onEditorEvent,
22442 'mouseup': this.onEditorEvent,
22443 'dblclick': this.onEditorEvent,
22444 'click': this.onEditorEvent,
22445 'keyup': this.onEditorEvent,
22450 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
22452 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
22453 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
22455 this.initialized = true;
22457 this.owner.fireEvent('initialize', this);
22462 onDestroy : function(){
22468 //for (var i =0; i < this.toolbars.length;i++) {
22469 // // fixme - ask toolbars for heights?
22470 // this.toolbars[i].onDestroy();
22473 //this.wrap.dom.innerHTML = '';
22474 //this.wrap.remove();
22479 onFirstFocus : function(){
22481 this.assignDocWin();
22484 this.activated = true;
22487 if(Roo.isGecko){ // prevent silly gecko errors
22489 var s = this.win.getSelection();
22490 if(!s.focusNode || s.focusNode.nodeType != 3){
22491 var r = s.getRangeAt(0);
22492 r.selectNodeContents((this.doc.body || this.doc.documentElement));
22497 this.execCmd('useCSS', true);
22498 this.execCmd('styleWithCSS', false);
22501 this.owner.fireEvent('activate', this);
22505 adjustFont: function(btn){
22506 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
22507 //if(Roo.isSafari){ // safari
22510 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
22511 if(Roo.isSafari){ // safari
22512 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
22513 v = (v < 10) ? 10 : v;
22514 v = (v > 48) ? 48 : v;
22515 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
22520 v = Math.max(1, v+adjust);
22522 this.execCmd('FontSize', v );
22525 onEditorEvent : function(e)
22527 this.owner.fireEvent('editorevent', this, e);
22528 // this.updateToolbar();
22529 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
22532 insertTag : function(tg)
22534 // could be a bit smarter... -> wrap the current selected tRoo..
22535 if (tg.toLowerCase() == 'span' || tg.toLowerCase() == 'code') {
22537 range = this.createRange(this.getSelection());
22538 var wrappingNode = this.doc.createElement(tg.toLowerCase());
22539 wrappingNode.appendChild(range.extractContents());
22540 range.insertNode(wrappingNode);
22547 this.execCmd("formatblock", tg);
22551 insertText : function(txt)
22555 var range = this.createRange();
22556 range.deleteContents();
22557 //alert(Sender.getAttribute('label'));
22559 range.insertNode(this.doc.createTextNode(txt));
22565 * Executes a Midas editor command on the editor document and performs necessary focus and
22566 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
22567 * @param {String} cmd The Midas command
22568 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22570 relayCmd : function(cmd, value){
22572 this.execCmd(cmd, value);
22573 this.owner.fireEvent('editorevent', this);
22574 //this.updateToolbar();
22575 this.owner.deferFocus();
22579 * Executes a Midas editor command directly on the editor document.
22580 * For visual commands, you should use {@link #relayCmd} instead.
22581 * <b>This should only be called after the editor is initialized.</b>
22582 * @param {String} cmd The Midas command
22583 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22585 execCmd : function(cmd, value){
22586 this.doc.execCommand(cmd, false, value === undefined ? null : value);
22593 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
22595 * @param {String} text | dom node..
22597 insertAtCursor : function(text)
22600 if(!this.activated){
22606 var r = this.doc.selection.createRange();
22617 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
22621 // from jquery ui (MIT licenced)
22623 var win = this.win;
22625 if (win.getSelection && win.getSelection().getRangeAt) {
22626 range = win.getSelection().getRangeAt(0);
22627 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
22628 range.insertNode(node);
22629 } else if (win.document.selection && win.document.selection.createRange) {
22630 // no firefox support
22631 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22632 win.document.selection.createRange().pasteHTML(txt);
22634 // no firefox support
22635 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22636 this.execCmd('InsertHTML', txt);
22645 mozKeyPress : function(e){
22647 var c = e.getCharCode(), cmd;
22650 c = String.fromCharCode(c).toLowerCase();
22664 this.cleanUpPaste.defer(100, this);
22672 e.preventDefault();
22680 fixKeys : function(){ // load time branching for fastest keydown performance
22682 return function(e){
22683 var k = e.getKey(), r;
22686 r = this.doc.selection.createRange();
22689 r.pasteHTML('    ');
22696 r = this.doc.selection.createRange();
22698 var target = r.parentElement();
22699 if(!target || target.tagName.toLowerCase() != 'li'){
22701 r.pasteHTML('<br />');
22707 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22708 this.cleanUpPaste.defer(100, this);
22714 }else if(Roo.isOpera){
22715 return function(e){
22716 var k = e.getKey();
22720 this.execCmd('InsertHTML','    ');
22723 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22724 this.cleanUpPaste.defer(100, this);
22729 }else if(Roo.isSafari){
22730 return function(e){
22731 var k = e.getKey();
22735 this.execCmd('InsertText','\t');
22739 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22740 this.cleanUpPaste.defer(100, this);
22748 getAllAncestors: function()
22750 var p = this.getSelectedNode();
22753 a.push(p); // push blank onto stack..
22754 p = this.getParentElement();
22758 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
22762 a.push(this.doc.body);
22766 lastSelNode : false,
22769 getSelection : function()
22771 this.assignDocWin();
22772 return Roo.isIE ? this.doc.selection : this.win.getSelection();
22775 getSelectedNode: function()
22777 // this may only work on Gecko!!!
22779 // should we cache this!!!!
22784 var range = this.createRange(this.getSelection()).cloneRange();
22787 var parent = range.parentElement();
22789 var testRange = range.duplicate();
22790 testRange.moveToElementText(parent);
22791 if (testRange.inRange(range)) {
22794 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
22797 parent = parent.parentElement;
22802 // is ancestor a text element.
22803 var ac = range.commonAncestorContainer;
22804 if (ac.nodeType == 3) {
22805 ac = ac.parentNode;
22808 var ar = ac.childNodes;
22811 var other_nodes = [];
22812 var has_other_nodes = false;
22813 for (var i=0;i<ar.length;i++) {
22814 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
22817 // fullly contained node.
22819 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
22824 // probably selected..
22825 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
22826 other_nodes.push(ar[i]);
22830 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
22835 has_other_nodes = true;
22837 if (!nodes.length && other_nodes.length) {
22838 nodes= other_nodes;
22840 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
22846 createRange: function(sel)
22848 // this has strange effects when using with
22849 // top toolbar - not sure if it's a great idea.
22850 //this.editor.contentWindow.focus();
22851 if (typeof sel != "undefined") {
22853 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
22855 return this.doc.createRange();
22858 return this.doc.createRange();
22861 getParentElement: function()
22864 this.assignDocWin();
22865 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
22867 var range = this.createRange(sel);
22870 var p = range.commonAncestorContainer;
22871 while (p.nodeType == 3) { // text node
22882 * Range intersection.. the hard stuff...
22886 * [ -- selected range --- ]
22890 * if end is before start or hits it. fail.
22891 * if start is after end or hits it fail.
22893 * if either hits (but other is outside. - then it's not
22899 // @see http://www.thismuchiknow.co.uk/?p=64.
22900 rangeIntersectsNode : function(range, node)
22902 var nodeRange = node.ownerDocument.createRange();
22904 nodeRange.selectNode(node);
22906 nodeRange.selectNodeContents(node);
22909 var rangeStartRange = range.cloneRange();
22910 rangeStartRange.collapse(true);
22912 var rangeEndRange = range.cloneRange();
22913 rangeEndRange.collapse(false);
22915 var nodeStartRange = nodeRange.cloneRange();
22916 nodeStartRange.collapse(true);
22918 var nodeEndRange = nodeRange.cloneRange();
22919 nodeEndRange.collapse(false);
22921 return rangeStartRange.compareBoundaryPoints(
22922 Range.START_TO_START, nodeEndRange) == -1 &&
22923 rangeEndRange.compareBoundaryPoints(
22924 Range.START_TO_START, nodeStartRange) == 1;
22928 rangeCompareNode : function(range, node)
22930 var nodeRange = node.ownerDocument.createRange();
22932 nodeRange.selectNode(node);
22934 nodeRange.selectNodeContents(node);
22938 range.collapse(true);
22940 nodeRange.collapse(true);
22942 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
22943 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
22945 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
22947 var nodeIsBefore = ss == 1;
22948 var nodeIsAfter = ee == -1;
22950 if (nodeIsBefore && nodeIsAfter) {
22953 if (!nodeIsBefore && nodeIsAfter) {
22954 return 1; //right trailed.
22957 if (nodeIsBefore && !nodeIsAfter) {
22958 return 2; // left trailed.
22964 // private? - in a new class?
22965 cleanUpPaste : function()
22967 // cleans up the whole document..
22968 Roo.log('cleanuppaste');
22970 this.cleanUpChildren(this.doc.body);
22971 var clean = this.cleanWordChars(this.doc.body.innerHTML);
22972 if (clean != this.doc.body.innerHTML) {
22973 this.doc.body.innerHTML = clean;
22978 cleanWordChars : function(input) {// change the chars to hex code
22979 var he = Roo.HtmlEditorCore;
22981 var output = input;
22982 Roo.each(he.swapCodes, function(sw) {
22983 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
22985 output = output.replace(swapper, sw[1]);
22992 cleanUpChildren : function (n)
22994 if (!n.childNodes.length) {
22997 for (var i = n.childNodes.length-1; i > -1 ; i--) {
22998 this.cleanUpChild(n.childNodes[i]);
23005 cleanUpChild : function (node)
23008 //console.log(node);
23009 if (node.nodeName == "#text") {
23010 // clean up silly Windows -- stuff?
23013 if (node.nodeName == "#comment") {
23014 node.parentNode.removeChild(node);
23015 // clean up silly Windows -- stuff?
23018 var lcname = node.tagName.toLowerCase();
23019 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
23020 // whitelist of tags..
23022 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
23024 node.parentNode.removeChild(node);
23029 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
23031 // remove <a name=....> as rendering on yahoo mailer is borked with this.
23032 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
23034 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
23035 // remove_keep_children = true;
23038 if (remove_keep_children) {
23039 this.cleanUpChildren(node);
23040 // inserts everything just before this node...
23041 while (node.childNodes.length) {
23042 var cn = node.childNodes[0];
23043 node.removeChild(cn);
23044 node.parentNode.insertBefore(cn, node);
23046 node.parentNode.removeChild(node);
23050 if (!node.attributes || !node.attributes.length) {
23051 this.cleanUpChildren(node);
23055 function cleanAttr(n,v)
23058 if (v.match(/^\./) || v.match(/^\//)) {
23061 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/) || v.match(/^ftp:/)) {
23064 if (v.match(/^#/)) {
23067 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
23068 node.removeAttribute(n);
23072 var cwhite = this.cwhite;
23073 var cblack = this.cblack;
23075 function cleanStyle(n,v)
23077 if (v.match(/expression/)) { //XSS?? should we even bother..
23078 node.removeAttribute(n);
23082 var parts = v.split(/;/);
23085 Roo.each(parts, function(p) {
23086 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
23090 var l = p.split(':').shift().replace(/\s+/g,'');
23091 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
23093 if ( cwhite.length && cblack.indexOf(l) > -1) {
23094 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
23095 //node.removeAttribute(n);
23099 // only allow 'c whitelisted system attributes'
23100 if ( cwhite.length && cwhite.indexOf(l) < 0) {
23101 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
23102 //node.removeAttribute(n);
23112 if (clean.length) {
23113 node.setAttribute(n, clean.join(';'));
23115 node.removeAttribute(n);
23121 for (var i = node.attributes.length-1; i > -1 ; i--) {
23122 var a = node.attributes[i];
23125 if (a.name.toLowerCase().substr(0,2)=='on') {
23126 node.removeAttribute(a.name);
23129 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
23130 node.removeAttribute(a.name);
23133 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
23134 cleanAttr(a.name,a.value); // fixme..
23137 if (a.name == 'style') {
23138 cleanStyle(a.name,a.value);
23141 /// clean up MS crap..
23142 // tecnically this should be a list of valid class'es..
23145 if (a.name == 'class') {
23146 if (a.value.match(/^Mso/)) {
23147 node.className = '';
23150 if (a.value.match(/^body$/)) {
23151 node.className = '';
23162 this.cleanUpChildren(node);
23168 * Clean up MS wordisms...
23170 cleanWord : function(node)
23175 this.cleanWord(this.doc.body);
23178 if (node.nodeName == "#text") {
23179 // clean up silly Windows -- stuff?
23182 if (node.nodeName == "#comment") {
23183 node.parentNode.removeChild(node);
23184 // clean up silly Windows -- stuff?
23188 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
23189 node.parentNode.removeChild(node);
23193 // remove - but keep children..
23194 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|font)/)) {
23195 while (node.childNodes.length) {
23196 var cn = node.childNodes[0];
23197 node.removeChild(cn);
23198 node.parentNode.insertBefore(cn, node);
23200 node.parentNode.removeChild(node);
23201 this.iterateChildren(node, this.cleanWord);
23205 if (node.className.length) {
23207 var cn = node.className.split(/\W+/);
23209 Roo.each(cn, function(cls) {
23210 if (cls.match(/Mso[a-zA-Z]+/)) {
23215 node.className = cna.length ? cna.join(' ') : '';
23217 node.removeAttribute("class");
23221 if (node.hasAttribute("lang")) {
23222 node.removeAttribute("lang");
23225 if (node.hasAttribute("style")) {
23227 var styles = node.getAttribute("style").split(";");
23229 Roo.each(styles, function(s) {
23230 if (!s.match(/:/)) {
23233 var kv = s.split(":");
23234 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
23237 // what ever is left... we allow.
23240 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
23241 if (!nstyle.length) {
23242 node.removeAttribute('style');
23245 this.iterateChildren(node, this.cleanWord);
23251 * iterateChildren of a Node, calling fn each time, using this as the scole..
23252 * @param {DomNode} node node to iterate children of.
23253 * @param {Function} fn method of this class to call on each item.
23255 iterateChildren : function(node, fn)
23257 if (!node.childNodes.length) {
23260 for (var i = node.childNodes.length-1; i > -1 ; i--) {
23261 fn.call(this, node.childNodes[i])
23267 * cleanTableWidths.
23269 * Quite often pasting from word etc.. results in tables with column and widths.
23270 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
23273 cleanTableWidths : function(node)
23278 this.cleanTableWidths(this.doc.body);
23283 if (node.nodeName == "#text" || node.nodeName == "#comment") {
23286 Roo.log(node.tagName);
23287 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
23288 this.iterateChildren(node, this.cleanTableWidths);
23291 if (node.hasAttribute('width')) {
23292 node.removeAttribute('width');
23296 if (node.hasAttribute("style")) {
23299 var styles = node.getAttribute("style").split(";");
23301 Roo.each(styles, function(s) {
23302 if (!s.match(/:/)) {
23305 var kv = s.split(":");
23306 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
23309 // what ever is left... we allow.
23312 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
23313 if (!nstyle.length) {
23314 node.removeAttribute('style');
23318 this.iterateChildren(node, this.cleanTableWidths);
23326 domToHTML : function(currentElement, depth, nopadtext) {
23328 depth = depth || 0;
23329 nopadtext = nopadtext || false;
23331 if (!currentElement) {
23332 return this.domToHTML(this.doc.body);
23335 //Roo.log(currentElement);
23337 var allText = false;
23338 var nodeName = currentElement.nodeName;
23339 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
23341 if (nodeName == '#text') {
23343 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
23348 if (nodeName != 'BODY') {
23351 // Prints the node tagName, such as <A>, <IMG>, etc
23354 for(i = 0; i < currentElement.attributes.length;i++) {
23356 var aname = currentElement.attributes.item(i).name;
23357 if (!currentElement.attributes.item(i).value.length) {
23360 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
23363 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
23372 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
23375 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
23380 // Traverse the tree
23382 var currentElementChild = currentElement.childNodes.item(i);
23383 var allText = true;
23384 var innerHTML = '';
23386 while (currentElementChild) {
23387 // Formatting code (indent the tree so it looks nice on the screen)
23388 var nopad = nopadtext;
23389 if (lastnode == 'SPAN') {
23393 if (currentElementChild.nodeName == '#text') {
23394 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
23395 toadd = nopadtext ? toadd : toadd.trim();
23396 if (!nopad && toadd.length > 80) {
23397 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
23399 innerHTML += toadd;
23402 currentElementChild = currentElement.childNodes.item(i);
23408 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
23410 // Recursively traverse the tree structure of the child node
23411 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
23412 lastnode = currentElementChild.nodeName;
23414 currentElementChild=currentElement.childNodes.item(i);
23420 // The remaining code is mostly for formatting the tree
23421 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
23426 ret+= "</"+tagName+">";
23432 applyBlacklists : function()
23434 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
23435 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
23439 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
23440 if (b.indexOf(tag) > -1) {
23443 this.white.push(tag);
23447 Roo.each(w, function(tag) {
23448 if (b.indexOf(tag) > -1) {
23451 if (this.white.indexOf(tag) > -1) {
23454 this.white.push(tag);
23459 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
23460 if (w.indexOf(tag) > -1) {
23463 this.black.push(tag);
23467 Roo.each(b, function(tag) {
23468 if (w.indexOf(tag) > -1) {
23471 if (this.black.indexOf(tag) > -1) {
23474 this.black.push(tag);
23479 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
23480 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
23484 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
23485 if (b.indexOf(tag) > -1) {
23488 this.cwhite.push(tag);
23492 Roo.each(w, function(tag) {
23493 if (b.indexOf(tag) > -1) {
23496 if (this.cwhite.indexOf(tag) > -1) {
23499 this.cwhite.push(tag);
23504 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
23505 if (w.indexOf(tag) > -1) {
23508 this.cblack.push(tag);
23512 Roo.each(b, function(tag) {
23513 if (w.indexOf(tag) > -1) {
23516 if (this.cblack.indexOf(tag) > -1) {
23519 this.cblack.push(tag);
23524 setStylesheets : function(stylesheets)
23526 if(typeof(stylesheets) == 'string'){
23527 Roo.get(this.iframe.contentDocument.head).createChild({
23529 rel : 'stylesheet',
23538 Roo.each(stylesheets, function(s) {
23543 Roo.get(_this.iframe.contentDocument.head).createChild({
23545 rel : 'stylesheet',
23554 removeStylesheets : function()
23558 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
23563 setStyle : function(style)
23565 Roo.get(this.iframe.contentDocument.head).createChild({
23574 // hide stuff that is not compatible
23588 * @event specialkey
23592 * @cfg {String} fieldClass @hide
23595 * @cfg {String} focusClass @hide
23598 * @cfg {String} autoCreate @hide
23601 * @cfg {String} inputType @hide
23604 * @cfg {String} invalidClass @hide
23607 * @cfg {String} invalidText @hide
23610 * @cfg {String} msgFx @hide
23613 * @cfg {String} validateOnBlur @hide
23617 Roo.HtmlEditorCore.white = [
23618 'area', 'br', 'img', 'input', 'hr', 'wbr',
23620 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
23621 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
23622 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
23623 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
23624 'table', 'ul', 'xmp',
23626 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
23629 'dir', 'menu', 'ol', 'ul', 'dl',
23635 Roo.HtmlEditorCore.black = [
23636 // 'embed', 'object', // enable - backend responsiblity to clean thiese
23638 'base', 'basefont', 'bgsound', 'blink', 'body',
23639 'frame', 'frameset', 'head', 'html', 'ilayer',
23640 'iframe', 'layer', 'link', 'meta', 'object',
23641 'script', 'style' ,'title', 'xml' // clean later..
23643 Roo.HtmlEditorCore.clean = [
23644 'script', 'style', 'title', 'xml'
23646 Roo.HtmlEditorCore.remove = [
23651 Roo.HtmlEditorCore.ablack = [
23655 Roo.HtmlEditorCore.aclean = [
23656 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
23660 Roo.HtmlEditorCore.pwhite= [
23661 'http', 'https', 'mailto'
23664 // white listed style attributes.
23665 Roo.HtmlEditorCore.cwhite= [
23666 // 'text-align', /// default is to allow most things..
23672 // black listed style attributes.
23673 Roo.HtmlEditorCore.cblack= [
23674 // 'font-size' -- this can be set by the project
23678 Roo.HtmlEditorCore.swapCodes =[
23697 * @class Roo.bootstrap.HtmlEditor
23698 * @extends Roo.bootstrap.TextArea
23699 * Bootstrap HtmlEditor class
23702 * Create a new HtmlEditor
23703 * @param {Object} config The config object
23706 Roo.bootstrap.HtmlEditor = function(config){
23707 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
23708 if (!this.toolbars) {
23709 this.toolbars = [];
23712 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
23715 * @event initialize
23716 * Fires when the editor is fully initialized (including the iframe)
23717 * @param {HtmlEditor} this
23722 * Fires when the editor is first receives the focus. Any insertion must wait
23723 * until after this event.
23724 * @param {HtmlEditor} this
23728 * @event beforesync
23729 * Fires before the textarea is updated with content from the editor iframe. Return false
23730 * to cancel the sync.
23731 * @param {HtmlEditor} this
23732 * @param {String} html
23736 * @event beforepush
23737 * Fires before the iframe editor is updated with content from the textarea. Return false
23738 * to cancel the push.
23739 * @param {HtmlEditor} this
23740 * @param {String} html
23745 * Fires when the textarea is updated with content from the editor iframe.
23746 * @param {HtmlEditor} this
23747 * @param {String} html
23752 * Fires when the iframe editor is updated with content from the textarea.
23753 * @param {HtmlEditor} this
23754 * @param {String} html
23758 * @event editmodechange
23759 * Fires when the editor switches edit modes
23760 * @param {HtmlEditor} this
23761 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
23763 editmodechange: true,
23765 * @event editorevent
23766 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
23767 * @param {HtmlEditor} this
23771 * @event firstfocus
23772 * Fires when on first focus - needed by toolbars..
23773 * @param {HtmlEditor} this
23778 * Auto save the htmlEditor value as a file into Events
23779 * @param {HtmlEditor} this
23783 * @event savedpreview
23784 * preview the saved version of htmlEditor
23785 * @param {HtmlEditor} this
23792 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
23796 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
23801 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
23806 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
23811 * @cfg {Number} height (in pixels)
23815 * @cfg {Number} width (in pixels)
23820 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
23823 stylesheets: false,
23828 // private properties
23829 validationEvent : false,
23831 initialized : false,
23834 onFocus : Roo.emptyFn,
23836 hideMode:'offsets',
23838 tbContainer : false,
23842 toolbarContainer :function() {
23843 return this.wrap.select('.x-html-editor-tb',true).first();
23847 * Protected method that will not generally be called directly. It
23848 * is called when the editor creates its toolbar. Override this method if you need to
23849 * add custom toolbar buttons.
23850 * @param {HtmlEditor} editor
23852 createToolbar : function(){
23853 Roo.log('renewing');
23854 Roo.log("create toolbars");
23856 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
23857 this.toolbars[0].render(this.toolbarContainer());
23861 // if (!editor.toolbars || !editor.toolbars.length) {
23862 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
23865 // for (var i =0 ; i < editor.toolbars.length;i++) {
23866 // editor.toolbars[i] = Roo.factory(
23867 // typeof(editor.toolbars[i]) == 'string' ?
23868 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
23869 // Roo.bootstrap.HtmlEditor);
23870 // editor.toolbars[i].init(editor);
23876 onRender : function(ct, position)
23878 // Roo.log("Call onRender: " + this.xtype);
23880 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
23882 this.wrap = this.inputEl().wrap({
23883 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
23886 this.editorcore.onRender(ct, position);
23888 if (this.resizable) {
23889 this.resizeEl = new Roo.Resizable(this.wrap, {
23893 minHeight : this.height,
23894 height: this.height,
23895 handles : this.resizable,
23898 resize : function(r, w, h) {
23899 _t.onResize(w,h); // -something
23905 this.createToolbar(this);
23908 if(!this.width && this.resizable){
23909 this.setSize(this.wrap.getSize());
23911 if (this.resizeEl) {
23912 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
23913 // should trigger onReize..
23919 onResize : function(w, h)
23921 Roo.log('resize: ' +w + ',' + h );
23922 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
23926 if(this.inputEl() ){
23927 if(typeof w == 'number'){
23928 var aw = w - this.wrap.getFrameWidth('lr');
23929 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
23932 if(typeof h == 'number'){
23933 var tbh = -11; // fixme it needs to tool bar size!
23934 for (var i =0; i < this.toolbars.length;i++) {
23935 // fixme - ask toolbars for heights?
23936 tbh += this.toolbars[i].el.getHeight();
23937 //if (this.toolbars[i].footer) {
23938 // tbh += this.toolbars[i].footer.el.getHeight();
23946 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
23947 ah -= 5; // knock a few pixes off for look..
23948 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
23952 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
23953 this.editorcore.onResize(ew,eh);
23958 * Toggles the editor between standard and source edit mode.
23959 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
23961 toggleSourceEdit : function(sourceEditMode)
23963 this.editorcore.toggleSourceEdit(sourceEditMode);
23965 if(this.editorcore.sourceEditMode){
23966 Roo.log('editor - showing textarea');
23969 // Roo.log(this.syncValue());
23971 this.inputEl().removeClass(['hide', 'x-hidden']);
23972 this.inputEl().dom.removeAttribute('tabIndex');
23973 this.inputEl().focus();
23975 Roo.log('editor - hiding textarea');
23977 // Roo.log(this.pushValue());
23980 this.inputEl().addClass(['hide', 'x-hidden']);
23981 this.inputEl().dom.setAttribute('tabIndex', -1);
23982 //this.deferFocus();
23985 if(this.resizable){
23986 this.setSize(this.wrap.getSize());
23989 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
23992 // private (for BoxComponent)
23993 adjustSize : Roo.BoxComponent.prototype.adjustSize,
23995 // private (for BoxComponent)
23996 getResizeEl : function(){
24000 // private (for BoxComponent)
24001 getPositionEl : function(){
24006 initEvents : function(){
24007 this.originalValue = this.getValue();
24011 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
24014 // markInvalid : Roo.emptyFn,
24016 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
24019 // clearInvalid : Roo.emptyFn,
24021 setValue : function(v){
24022 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
24023 this.editorcore.pushValue();
24028 deferFocus : function(){
24029 this.focus.defer(10, this);
24033 focus : function(){
24034 this.editorcore.focus();
24040 onDestroy : function(){
24046 for (var i =0; i < this.toolbars.length;i++) {
24047 // fixme - ask toolbars for heights?
24048 this.toolbars[i].onDestroy();
24051 this.wrap.dom.innerHTML = '';
24052 this.wrap.remove();
24057 onFirstFocus : function(){
24058 //Roo.log("onFirstFocus");
24059 this.editorcore.onFirstFocus();
24060 for (var i =0; i < this.toolbars.length;i++) {
24061 this.toolbars[i].onFirstFocus();
24067 syncValue : function()
24069 this.editorcore.syncValue();
24072 pushValue : function()
24074 this.editorcore.pushValue();
24078 // hide stuff that is not compatible
24092 * @event specialkey
24096 * @cfg {String} fieldClass @hide
24099 * @cfg {String} focusClass @hide
24102 * @cfg {String} autoCreate @hide
24105 * @cfg {String} inputType @hide
24109 * @cfg {String} invalidText @hide
24112 * @cfg {String} msgFx @hide
24115 * @cfg {String} validateOnBlur @hide
24124 Roo.namespace('Roo.bootstrap.htmleditor');
24126 * @class Roo.bootstrap.HtmlEditorToolbar1
24132 new Roo.bootstrap.HtmlEditor({
24135 new Roo.bootstrap.HtmlEditorToolbar1({
24136 disable : { fonts: 1 , format: 1, ..., ... , ...],
24142 * @cfg {Object} disable List of elements to disable..
24143 * @cfg {Array} btns List of additional buttons.
24147 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
24150 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
24153 Roo.apply(this, config);
24155 // default disabled, based on 'good practice'..
24156 this.disable = this.disable || {};
24157 Roo.applyIf(this.disable, {
24160 specialElements : true
24162 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
24164 this.editor = config.editor;
24165 this.editorcore = config.editor.editorcore;
24167 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
24169 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
24170 // dont call parent... till later.
24172 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
24177 editorcore : false,
24182 "h1","h2","h3","h4","h5","h6",
24184 "abbr", "acronym", "address", "cite", "samp", "var",
24188 onRender : function(ct, position)
24190 // Roo.log("Call onRender: " + this.xtype);
24192 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
24194 this.el.dom.style.marginBottom = '0';
24196 var editorcore = this.editorcore;
24197 var editor= this.editor;
24200 var btn = function(id,cmd , toggle, handler, html){
24202 var event = toggle ? 'toggle' : 'click';
24207 xns: Roo.bootstrap,
24211 enableToggle:toggle !== false,
24213 pressed : toggle ? false : null,
24216 a.listeners[toggle ? 'toggle' : 'click'] = function() {
24217 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
24223 // var cb_box = function...
24228 xns: Roo.bootstrap,
24233 xns: Roo.bootstrap,
24237 Roo.each(this.formats, function(f) {
24238 style.menu.items.push({
24240 xns: Roo.bootstrap,
24241 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
24246 editorcore.insertTag(this.tagname);
24253 children.push(style);
24255 btn('bold',false,true);
24256 btn('italic',false,true);
24257 btn('align-left', 'justifyleft',true);
24258 btn('align-center', 'justifycenter',true);
24259 btn('align-right' , 'justifyright',true);
24260 btn('link', false, false, function(btn) {
24261 //Roo.log("create link?");
24262 var url = prompt(this.createLinkText, this.defaultLinkValue);
24263 if(url && url != 'http:/'+'/'){
24264 this.editorcore.relayCmd('createlink', url);
24267 btn('list','insertunorderedlist',true);
24268 btn('pencil', false,true, function(btn){
24270 this.toggleSourceEdit(btn.pressed);
24273 if (this.editor.btns.length > 0) {
24274 for (var i = 0; i<this.editor.btns.length; i++) {
24275 children.push(this.editor.btns[i]);
24283 xns: Roo.bootstrap,
24288 xns: Roo.bootstrap,
24293 cog.menu.items.push({
24295 xns: Roo.bootstrap,
24296 html : Clean styles,
24301 editorcore.insertTag(this.tagname);
24310 this.xtype = 'NavSimplebar';
24312 for(var i=0;i< children.length;i++) {
24314 this.buttons.add(this.addxtypeChild(children[i]));
24318 editor.on('editorevent', this.updateToolbar, this);
24320 onBtnClick : function(id)
24322 this.editorcore.relayCmd(id);
24323 this.editorcore.focus();
24327 * Protected method that will not generally be called directly. It triggers
24328 * a toolbar update by reading the markup state of the current selection in the editor.
24330 updateToolbar: function(){
24332 if(!this.editorcore.activated){
24333 this.editor.onFirstFocus(); // is this neeed?
24337 var btns = this.buttons;
24338 var doc = this.editorcore.doc;
24339 btns.get('bold').setActive(doc.queryCommandState('bold'));
24340 btns.get('italic').setActive(doc.queryCommandState('italic'));
24341 //btns.get('underline').setActive(doc.queryCommandState('underline'));
24343 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
24344 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
24345 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
24347 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
24348 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
24351 var ans = this.editorcore.getAllAncestors();
24352 if (this.formatCombo) {
24355 var store = this.formatCombo.store;
24356 this.formatCombo.setValue("");
24357 for (var i =0; i < ans.length;i++) {
24358 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
24360 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
24368 // hides menus... - so this cant be on a menu...
24369 Roo.bootstrap.MenuMgr.hideAll();
24371 Roo.bootstrap.MenuMgr.hideAll();
24372 //this.editorsyncValue();
24374 onFirstFocus: function() {
24375 this.buttons.each(function(item){
24379 toggleSourceEdit : function(sourceEditMode){
24382 if(sourceEditMode){
24383 Roo.log("disabling buttons");
24384 this.buttons.each( function(item){
24385 if(item.cmd != 'pencil'){
24391 Roo.log("enabling buttons");
24392 if(this.editorcore.initialized){
24393 this.buttons.each( function(item){
24399 Roo.log("calling toggole on editor");
24400 // tell the editor that it's been pressed..
24401 this.editor.toggleSourceEdit(sourceEditMode);
24411 * @class Roo.bootstrap.Table.AbstractSelectionModel
24412 * @extends Roo.util.Observable
24413 * Abstract base class for grid SelectionModels. It provides the interface that should be
24414 * implemented by descendant classes. This class should not be directly instantiated.
24417 Roo.bootstrap.Table.AbstractSelectionModel = function(){
24418 this.locked = false;
24419 Roo.bootstrap.Table.AbstractSelectionModel.superclass.constructor.call(this);
24423 Roo.extend(Roo.bootstrap.Table.AbstractSelectionModel, Roo.util.Observable, {
24424 /** @ignore Called by the grid automatically. Do not call directly. */
24425 init : function(grid){
24431 * Locks the selections.
24434 this.locked = true;
24438 * Unlocks the selections.
24440 unlock : function(){
24441 this.locked = false;
24445 * Returns true if the selections are locked.
24446 * @return {Boolean}
24448 isLocked : function(){
24449 return this.locked;
24453 * @extends Roo.bootstrap.Table.AbstractSelectionModel
24454 * @class Roo.bootstrap.Table.RowSelectionModel
24455 * The default SelectionModel used by {@link Roo.bootstrap.Table}.
24456 * It supports multiple selections and keyboard selection/navigation.
24458 * @param {Object} config
24461 Roo.bootstrap.Table.RowSelectionModel = function(config){
24462 Roo.apply(this, config);
24463 this.selections = new Roo.util.MixedCollection(false, function(o){
24468 this.lastActive = false;
24472 * @event selectionchange
24473 * Fires when the selection changes
24474 * @param {SelectionModel} this
24476 "selectionchange" : true,
24478 * @event afterselectionchange
24479 * Fires after the selection changes (eg. by key press or clicking)
24480 * @param {SelectionModel} this
24482 "afterselectionchange" : true,
24484 * @event beforerowselect
24485 * Fires when a row is selected being selected, return false to cancel.
24486 * @param {SelectionModel} this
24487 * @param {Number} rowIndex The selected index
24488 * @param {Boolean} keepExisting False if other selections will be cleared
24490 "beforerowselect" : true,
24493 * Fires when a row is selected.
24494 * @param {SelectionModel} this
24495 * @param {Number} rowIndex The selected index
24496 * @param {Roo.data.Record} r The record
24498 "rowselect" : true,
24500 * @event rowdeselect
24501 * Fires when a row is deselected.
24502 * @param {SelectionModel} this
24503 * @param {Number} rowIndex The selected index
24505 "rowdeselect" : true
24507 Roo.bootstrap.Table.RowSelectionModel.superclass.constructor.call(this);
24508 this.locked = false;
24511 Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSelectionModel, {
24513 * @cfg {Boolean} singleSelect
24514 * True to allow selection of only one row at a time (defaults to false)
24516 singleSelect : false,
24519 initEvents : function()
24522 //if(!this.grid.enableDragDrop && !this.grid.enableDrag){
24523 // this.growclickrid.on("mousedown", this.handleMouseDown, this);
24524 //}else{ // allow click to work like normal
24525 // this.grid.on("rowclick", this.handleDragableRowClick, this);
24527 //this.grid.on("rowdblclick", this.handleMouseDBClick, this);
24528 this.grid.on("rowclick", this.handleMouseDown, this);
24530 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
24531 "up" : function(e){
24533 this.selectPrevious(e.shiftKey);
24534 }else if(this.last !== false && this.lastActive !== false){
24535 var last = this.last;
24536 this.selectRange(this.last, this.lastActive-1);
24537 this.grid.getView().focusRow(this.lastActive);
24538 if(last !== false){
24542 this.selectFirstRow();
24544 this.fireEvent("afterselectionchange", this);
24546 "down" : function(e){
24548 this.selectNext(e.shiftKey);
24549 }else if(this.last !== false && this.lastActive !== false){
24550 var last = this.last;
24551 this.selectRange(this.last, this.lastActive+1);
24552 this.grid.getView().focusRow(this.lastActive);
24553 if(last !== false){
24557 this.selectFirstRow();
24559 this.fireEvent("afterselectionchange", this);
24563 this.grid.store.on('load', function(){
24564 this.selections.clear();
24567 var view = this.grid.view;
24568 view.on("refresh", this.onRefresh, this);
24569 view.on("rowupdated", this.onRowUpdated, this);
24570 view.on("rowremoved", this.onRemove, this);
24575 onRefresh : function()
24577 var ds = this.grid.store, i, v = this.grid.view;
24578 var s = this.selections;
24579 s.each(function(r){
24580 if((i = ds.indexOfId(r.id)) != -1){
24589 onRemove : function(v, index, r){
24590 this.selections.remove(r);
24594 onRowUpdated : function(v, index, r){
24595 if(this.isSelected(r)){
24596 v.onRowSelect(index);
24602 * @param {Array} records The records to select
24603 * @param {Boolean} keepExisting (optional) True to keep existing selections
24605 selectRecords : function(records, keepExisting)
24608 this.clearSelections();
24610 var ds = this.grid.store;
24611 for(var i = 0, len = records.length; i < len; i++){
24612 this.selectRow(ds.indexOf(records[i]), true);
24617 * Gets the number of selected rows.
24620 getCount : function(){
24621 return this.selections.length;
24625 * Selects the first row in the grid.
24627 selectFirstRow : function(){
24632 * Select the last row.
24633 * @param {Boolean} keepExisting (optional) True to keep existing selections
24635 selectLastRow : function(keepExisting){
24636 //this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
24637 this.selectRow(this.grid.store.getCount() - 1, keepExisting);
24641 * Selects the row immediately following the last selected row.
24642 * @param {Boolean} keepExisting (optional) True to keep existing selections
24644 selectNext : function(keepExisting)
24646 if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
24647 this.selectRow(this.last+1, keepExisting);
24648 this.grid.getView().focusRow(this.last);
24653 * Selects the row that precedes the last selected row.
24654 * @param {Boolean} keepExisting (optional) True to keep existing selections
24656 selectPrevious : function(keepExisting){
24658 this.selectRow(this.last-1, keepExisting);
24659 this.grid.getView().focusRow(this.last);
24664 * Returns the selected records
24665 * @return {Array} Array of selected records
24667 getSelections : function(){
24668 return [].concat(this.selections.items);
24672 * Returns the first selected record.
24675 getSelected : function(){
24676 return this.selections.itemAt(0);
24681 * Clears all selections.
24683 clearSelections : function(fast)
24689 var ds = this.grid.store;
24690 var s = this.selections;
24691 s.each(function(r){
24692 this.deselectRow(ds.indexOfId(r.id));
24696 this.selections.clear();
24703 * Selects all rows.
24705 selectAll : function(){
24709 this.selections.clear();
24710 for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
24711 this.selectRow(i, true);
24716 * Returns True if there is a selection.
24717 * @return {Boolean}
24719 hasSelection : function(){
24720 return this.selections.length > 0;
24724 * Returns True if the specified row is selected.
24725 * @param {Number/Record} record The record or index of the record to check
24726 * @return {Boolean}
24728 isSelected : function(index){
24729 var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
24730 return (r && this.selections.key(r.id) ? true : false);
24734 * Returns True if the specified record id is selected.
24735 * @param {String} id The id of record to check
24736 * @return {Boolean}
24738 isIdSelected : function(id){
24739 return (this.selections.key(id) ? true : false);
24744 handleMouseDBClick : function(e, t){
24748 handleMouseDown : function(e, t)
24750 var rowIndex = this.grid.headerShow ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
24751 if(this.isLocked() || rowIndex < 0 ){
24754 if(e.shiftKey && this.last !== false){
24755 var last = this.last;
24756 this.selectRange(last, rowIndex, e.ctrlKey);
24757 this.last = last; // reset the last
24761 var isSelected = this.isSelected(rowIndex);
24762 //Roo.log("select row:" + rowIndex);
24764 this.deselectRow(rowIndex);
24766 this.selectRow(rowIndex, true);
24770 if(e.button !== 0 && isSelected){
24771 alert('rowIndex 2: ' + rowIndex);
24772 view.focusRow(rowIndex);
24773 }else if(e.ctrlKey && isSelected){
24774 this.deselectRow(rowIndex);
24775 }else if(!isSelected){
24776 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
24777 view.focusRow(rowIndex);
24781 this.fireEvent("afterselectionchange", this);
24784 handleDragableRowClick : function(grid, rowIndex, e)
24786 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
24787 this.selectRow(rowIndex, false);
24788 grid.view.focusRow(rowIndex);
24789 this.fireEvent("afterselectionchange", this);
24794 * Selects multiple rows.
24795 * @param {Array} rows Array of the indexes of the row to select
24796 * @param {Boolean} keepExisting (optional) True to keep existing selections
24798 selectRows : function(rows, keepExisting){
24800 this.clearSelections();
24802 for(var i = 0, len = rows.length; i < len; i++){
24803 this.selectRow(rows[i], true);
24808 * Selects a range of rows. All rows in between startRow and endRow are also selected.
24809 * @param {Number} startRow The index of the first row in the range
24810 * @param {Number} endRow The index of the last row in the range
24811 * @param {Boolean} keepExisting (optional) True to retain existing selections
24813 selectRange : function(startRow, endRow, keepExisting){
24818 this.clearSelections();
24820 if(startRow <= endRow){
24821 for(var i = startRow; i <= endRow; i++){
24822 this.selectRow(i, true);
24825 for(var i = startRow; i >= endRow; i--){
24826 this.selectRow(i, true);
24832 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
24833 * @param {Number} startRow The index of the first row in the range
24834 * @param {Number} endRow The index of the last row in the range
24836 deselectRange : function(startRow, endRow, preventViewNotify){
24840 for(var i = startRow; i <= endRow; i++){
24841 this.deselectRow(i, preventViewNotify);
24847 * @param {Number} row The index of the row to select
24848 * @param {Boolean} keepExisting (optional) True to keep existing selections
24850 selectRow : function(index, keepExisting, preventViewNotify)
24852 if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
24855 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
24856 if(!keepExisting || this.singleSelect){
24857 this.clearSelections();
24860 var r = this.grid.store.getAt(index);
24861 //console.log('selectRow - record id :' + r.id);
24863 this.selections.add(r);
24864 this.last = this.lastActive = index;
24865 if(!preventViewNotify){
24866 var proxy = new Roo.Element(
24867 this.grid.getRowDom(index)
24869 proxy.addClass('bg-info info');
24871 this.fireEvent("rowselect", this, index, r);
24872 this.fireEvent("selectionchange", this);
24878 * @param {Number} row The index of the row to deselect
24880 deselectRow : function(index, preventViewNotify)
24885 if(this.last == index){
24888 if(this.lastActive == index){
24889 this.lastActive = false;
24892 var r = this.grid.store.getAt(index);
24897 this.selections.remove(r);
24898 //.console.log('deselectRow - record id :' + r.id);
24899 if(!preventViewNotify){
24901 var proxy = new Roo.Element(
24902 this.grid.getRowDom(index)
24904 proxy.removeClass('bg-info info');
24906 this.fireEvent("rowdeselect", this, index);
24907 this.fireEvent("selectionchange", this);
24911 restoreLast : function(){
24913 this.last = this._last;
24918 acceptsNav : function(row, col, cm){
24919 return !cm.isHidden(col) && cm.isCellEditable(col, row);
24923 onEditorKey : function(field, e){
24924 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
24929 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
24931 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
24933 }else if(k == e.ENTER && !e.ctrlKey){
24937 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
24939 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
24941 }else if(k == e.ESC){
24945 g.startEditing(newCell[0], newCell[1]);
24951 * Ext JS Library 1.1.1
24952 * Copyright(c) 2006-2007, Ext JS, LLC.
24954 * Originally Released Under LGPL - original licence link has changed is not relivant.
24957 * <script type="text/javascript">
24961 * @class Roo.bootstrap.PagingToolbar
24962 * @extends Roo.bootstrap.NavSimplebar
24963 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
24965 * Create a new PagingToolbar
24966 * @param {Object} config The config object
24967 * @param {Roo.data.Store} store
24969 Roo.bootstrap.PagingToolbar = function(config)
24971 // old args format still supported... - xtype is prefered..
24972 // created from xtype...
24974 this.ds = config.dataSource;
24976 if (config.store && !this.ds) {
24977 this.store= Roo.factory(config.store, Roo.data);
24978 this.ds = this.store;
24979 this.ds.xmodule = this.xmodule || false;
24982 this.toolbarItems = [];
24983 if (config.items) {
24984 this.toolbarItems = config.items;
24987 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
24992 this.bind(this.ds);
24995 if (Roo.bootstrap.version == 4) {
24996 this.navgroup = new Roo.bootstrap.ButtonGroup({ cls: 'pagination' });
24998 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
25003 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
25005 * @cfg {Roo.data.Store} dataSource
25006 * The underlying data store providing the paged data
25009 * @cfg {String/HTMLElement/Element} container
25010 * container The id or element that will contain the toolbar
25013 * @cfg {Boolean} displayInfo
25014 * True to display the displayMsg (defaults to false)
25017 * @cfg {Number} pageSize
25018 * The number of records to display per page (defaults to 20)
25022 * @cfg {String} displayMsg
25023 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
25025 displayMsg : 'Displaying {0} - {1} of {2}',
25027 * @cfg {String} emptyMsg
25028 * The message to display when no records are found (defaults to "No data to display")
25030 emptyMsg : 'No data to display',
25032 * Customizable piece of the default paging text (defaults to "Page")
25035 beforePageText : "Page",
25037 * Customizable piece of the default paging text (defaults to "of %0")
25040 afterPageText : "of {0}",
25042 * Customizable piece of the default paging text (defaults to "First Page")
25045 firstText : "First Page",
25047 * Customizable piece of the default paging text (defaults to "Previous Page")
25050 prevText : "Previous Page",
25052 * Customizable piece of the default paging text (defaults to "Next Page")
25055 nextText : "Next Page",
25057 * Customizable piece of the default paging text (defaults to "Last Page")
25060 lastText : "Last Page",
25062 * Customizable piece of the default paging text (defaults to "Refresh")
25065 refreshText : "Refresh",
25069 onRender : function(ct, position)
25071 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
25072 this.navgroup.parentId = this.id;
25073 this.navgroup.onRender(this.el, null);
25074 // add the buttons to the navgroup
25076 if(this.displayInfo){
25077 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
25078 this.displayEl = this.el.select('.x-paging-info', true).first();
25079 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
25080 // this.displayEl = navel.el.select('span',true).first();
25086 Roo.each(_this.buttons, function(e){ // this might need to use render????
25087 Roo.factory(e).render(_this.el);
25091 Roo.each(_this.toolbarItems, function(e) {
25092 _this.navgroup.addItem(e);
25096 this.first = this.navgroup.addItem({
25097 tooltip: this.firstText,
25098 cls: "prev btn-outline-secondary",
25099 html : ' <i class="fa fa-step-backward"></i>',
25101 preventDefault: true,
25102 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
25105 this.prev = this.navgroup.addItem({
25106 tooltip: this.prevText,
25107 cls: "prev btn-outline-secondary",
25108 html : ' <i class="fa fa-backward"></i>',
25110 preventDefault: true,
25111 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
25113 //this.addSeparator();
25116 var field = this.navgroup.addItem( {
25118 cls : 'x-paging-position btn-outline-secondary',
25120 html : this.beforePageText +
25121 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
25122 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
25125 this.field = field.el.select('input', true).first();
25126 this.field.on("keydown", this.onPagingKeydown, this);
25127 this.field.on("focus", function(){this.dom.select();});
25130 this.afterTextEl = field.el.select('.x-paging-after',true).first();
25131 //this.field.setHeight(18);
25132 //this.addSeparator();
25133 this.next = this.navgroup.addItem({
25134 tooltip: this.nextText,
25135 cls: "next btn-outline-secondary",
25136 html : ' <i class="fa fa-forward"></i>',
25138 preventDefault: true,
25139 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
25141 this.last = this.navgroup.addItem({
25142 tooltip: this.lastText,
25143 html : ' <i class="fa fa-step-forward"></i>',
25144 cls: "next btn-outline-secondary",
25146 preventDefault: true,
25147 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
25149 //this.addSeparator();
25150 this.loading = this.navgroup.addItem({
25151 tooltip: this.refreshText,
25152 cls: "btn-outline-secondary",
25153 html : ' <i class="fa fa-refresh"></i>',
25154 preventDefault: true,
25155 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
25161 updateInfo : function(){
25162 if(this.displayEl){
25163 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
25164 var msg = count == 0 ?
25168 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
25170 this.displayEl.update(msg);
25175 onLoad : function(ds, r, o)
25177 this.cursor = o.params.start ? o.params.start : 0;
25179 var d = this.getPageData(),
25184 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
25185 this.field.dom.value = ap;
25186 this.first.setDisabled(ap == 1);
25187 this.prev.setDisabled(ap == 1);
25188 this.next.setDisabled(ap == ps);
25189 this.last.setDisabled(ap == ps);
25190 this.loading.enable();
25195 getPageData : function(){
25196 var total = this.ds.getTotalCount();
25199 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
25200 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
25205 onLoadError : function(){
25206 this.loading.enable();
25210 onPagingKeydown : function(e){
25211 var k = e.getKey();
25212 var d = this.getPageData();
25214 var v = this.field.dom.value, pageNum;
25215 if(!v || isNaN(pageNum = parseInt(v, 10))){
25216 this.field.dom.value = d.activePage;
25219 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
25220 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
25223 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))
25225 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
25226 this.field.dom.value = pageNum;
25227 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
25230 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
25232 var v = this.field.dom.value, pageNum;
25233 var increment = (e.shiftKey) ? 10 : 1;
25234 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
25237 if(!v || isNaN(pageNum = parseInt(v, 10))) {
25238 this.field.dom.value = d.activePage;
25241 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
25243 this.field.dom.value = parseInt(v, 10) + increment;
25244 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
25245 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
25252 beforeLoad : function(){
25254 this.loading.disable();
25259 onClick : function(which){
25268 ds.load({params:{start: 0, limit: this.pageSize}});
25271 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
25274 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
25277 var total = ds.getTotalCount();
25278 var extra = total % this.pageSize;
25279 var lastStart = extra ? (total - extra) : total-this.pageSize;
25280 ds.load({params:{start: lastStart, limit: this.pageSize}});
25283 ds.load({params:{start: this.cursor, limit: this.pageSize}});
25289 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
25290 * @param {Roo.data.Store} store The data store to unbind
25292 unbind : function(ds){
25293 ds.un("beforeload", this.beforeLoad, this);
25294 ds.un("load", this.onLoad, this);
25295 ds.un("loadexception", this.onLoadError, this);
25296 ds.un("remove", this.updateInfo, this);
25297 ds.un("add", this.updateInfo, this);
25298 this.ds = undefined;
25302 * Binds the paging toolbar to the specified {@link Roo.data.Store}
25303 * @param {Roo.data.Store} store The data store to bind
25305 bind : function(ds){
25306 ds.on("beforeload", this.beforeLoad, this);
25307 ds.on("load", this.onLoad, this);
25308 ds.on("loadexception", this.onLoadError, this);
25309 ds.on("remove", this.updateInfo, this);
25310 ds.on("add", this.updateInfo, this);
25321 * @class Roo.bootstrap.MessageBar
25322 * @extends Roo.bootstrap.Component
25323 * Bootstrap MessageBar class
25324 * @cfg {String} html contents of the MessageBar
25325 * @cfg {String} weight (info | success | warning | danger) default info
25326 * @cfg {String} beforeClass insert the bar before the given class
25327 * @cfg {Boolean} closable (true | false) default false
25328 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
25331 * Create a new Element
25332 * @param {Object} config The config object
25335 Roo.bootstrap.MessageBar = function(config){
25336 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
25339 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
25345 beforeClass: 'bootstrap-sticky-wrap',
25347 getAutoCreate : function(){
25351 cls: 'alert alert-dismissable alert-' + this.weight,
25356 html: this.html || ''
25362 cfg.cls += ' alert-messages-fixed';
25376 onRender : function(ct, position)
25378 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
25381 var cfg = Roo.apply({}, this.getAutoCreate());
25385 cfg.cls += ' ' + this.cls;
25388 cfg.style = this.style;
25390 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
25392 this.el.setVisibilityMode(Roo.Element.DISPLAY);
25395 this.el.select('>button.close').on('click', this.hide, this);
25401 if (!this.rendered) {
25407 this.fireEvent('show', this);
25413 if (!this.rendered) {
25419 this.fireEvent('hide', this);
25422 update : function()
25424 // var e = this.el.dom.firstChild;
25426 // if(this.closable){
25427 // e = e.nextSibling;
25430 // e.data = this.html || '';
25432 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
25448 * @class Roo.bootstrap.Graph
25449 * @extends Roo.bootstrap.Component
25450 * Bootstrap Graph class
25454 @cfg {String} graphtype bar | vbar | pie
25455 @cfg {number} g_x coodinator | centre x (pie)
25456 @cfg {number} g_y coodinator | centre y (pie)
25457 @cfg {number} g_r radius (pie)
25458 @cfg {number} g_height height of the chart (respected by all elements in the set)
25459 @cfg {number} g_width width of the chart (respected by all elements in the set)
25460 @cfg {Object} title The title of the chart
25463 -opts (object) options for the chart
25465 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
25466 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
25468 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.
25469 o stacked (boolean) whether or not to tread values as in a stacked bar chart
25471 o stretch (boolean)
25473 -opts (object) options for the pie
25476 o startAngle (number)
25477 o endAngle (number)
25481 * Create a new Input
25482 * @param {Object} config The config object
25485 Roo.bootstrap.Graph = function(config){
25486 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
25492 * The img click event for the img.
25493 * @param {Roo.EventObject} e
25499 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
25510 //g_colors: this.colors,
25517 getAutoCreate : function(){
25528 onRender : function(ct,position){
25531 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
25533 if (typeof(Raphael) == 'undefined') {
25534 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
25538 this.raphael = Raphael(this.el.dom);
25540 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25541 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25542 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25543 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
25545 r.text(160, 10, "Single Series Chart").attr(txtattr);
25546 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
25547 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
25548 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
25550 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
25551 r.barchart(330, 10, 300, 220, data1);
25552 r.barchart(10, 250, 300, 220, data2, {stacked: true});
25553 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
25556 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25557 // r.barchart(30, 30, 560, 250, xdata, {
25558 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
25559 // axis : "0 0 1 1",
25560 // axisxlabels : xdata
25561 // //yvalues : cols,
25564 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25566 // this.load(null,xdata,{
25567 // axis : "0 0 1 1",
25568 // axisxlabels : xdata
25573 load : function(graphtype,xdata,opts)
25575 this.raphael.clear();
25577 graphtype = this.graphtype;
25582 var r = this.raphael,
25583 fin = function () {
25584 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
25586 fout = function () {
25587 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
25589 pfin = function() {
25590 this.sector.stop();
25591 this.sector.scale(1.1, 1.1, this.cx, this.cy);
25594 this.label[0].stop();
25595 this.label[0].attr({ r: 7.5 });
25596 this.label[1].attr({ "font-weight": 800 });
25599 pfout = function() {
25600 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
25603 this.label[0].animate({ r: 5 }, 500, "bounce");
25604 this.label[1].attr({ "font-weight": 400 });
25610 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25613 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25616 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
25617 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
25619 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
25626 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
25631 setTitle: function(o)
25636 initEvents: function() {
25639 this.el.on('click', this.onClick, this);
25643 onClick : function(e)
25645 Roo.log('img onclick');
25646 this.fireEvent('click', this, e);
25658 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25661 * @class Roo.bootstrap.dash.NumberBox
25662 * @extends Roo.bootstrap.Component
25663 * Bootstrap NumberBox class
25664 * @cfg {String} headline Box headline
25665 * @cfg {String} content Box content
25666 * @cfg {String} icon Box icon
25667 * @cfg {String} footer Footer text
25668 * @cfg {String} fhref Footer href
25671 * Create a new NumberBox
25672 * @param {Object} config The config object
25676 Roo.bootstrap.dash.NumberBox = function(config){
25677 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
25681 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
25690 getAutoCreate : function(){
25694 cls : 'small-box ',
25702 cls : 'roo-headline',
25703 html : this.headline
25707 cls : 'roo-content',
25708 html : this.content
25722 cls : 'ion ' + this.icon
25731 cls : 'small-box-footer',
25732 href : this.fhref || '#',
25736 cfg.cn.push(footer);
25743 onRender : function(ct,position){
25744 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
25751 setHeadline: function (value)
25753 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
25756 setFooter: function (value, href)
25758 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
25761 this.el.select('a.small-box-footer',true).first().attr('href', href);
25766 setContent: function (value)
25768 this.el.select('.roo-content',true).first().dom.innerHTML = value;
25771 initEvents: function()
25785 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25788 * @class Roo.bootstrap.dash.TabBox
25789 * @extends Roo.bootstrap.Component
25790 * Bootstrap TabBox class
25791 * @cfg {String} title Title of the TabBox
25792 * @cfg {String} icon Icon of the TabBox
25793 * @cfg {Boolean} showtabs (true|false) show the tabs default true
25794 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
25797 * Create a new TabBox
25798 * @param {Object} config The config object
25802 Roo.bootstrap.dash.TabBox = function(config){
25803 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
25808 * When a pane is added
25809 * @param {Roo.bootstrap.dash.TabPane} pane
25813 * @event activatepane
25814 * When a pane is activated
25815 * @param {Roo.bootstrap.dash.TabPane} pane
25817 "activatepane" : true
25825 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
25830 tabScrollable : false,
25832 getChildContainer : function()
25834 return this.el.select('.tab-content', true).first();
25837 getAutoCreate : function(){
25841 cls: 'pull-left header',
25849 cls: 'fa ' + this.icon
25855 cls: 'nav nav-tabs pull-right',
25861 if(this.tabScrollable){
25868 cls: 'nav nav-tabs pull-right',
25879 cls: 'nav-tabs-custom',
25884 cls: 'tab-content no-padding',
25892 initEvents : function()
25894 //Roo.log('add add pane handler');
25895 this.on('addpane', this.onAddPane, this);
25898 * Updates the box title
25899 * @param {String} html to set the title to.
25901 setTitle : function(value)
25903 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
25905 onAddPane : function(pane)
25907 this.panes.push(pane);
25908 //Roo.log('addpane');
25910 // tabs are rendere left to right..
25911 if(!this.showtabs){
25915 var ctr = this.el.select('.nav-tabs', true).first();
25918 var existing = ctr.select('.nav-tab',true);
25919 var qty = existing.getCount();;
25922 var tab = ctr.createChild({
25924 cls : 'nav-tab' + (qty ? '' : ' active'),
25932 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
25935 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
25937 pane.el.addClass('active');
25942 onTabClick : function(ev,un,ob,pane)
25944 //Roo.log('tab - prev default');
25945 ev.preventDefault();
25948 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
25949 pane.tab.addClass('active');
25950 //Roo.log(pane.title);
25951 this.getChildContainer().select('.tab-pane',true).removeClass('active');
25952 // technically we should have a deactivate event.. but maybe add later.
25953 // and it should not de-activate the selected tab...
25954 this.fireEvent('activatepane', pane);
25955 pane.el.addClass('active');
25956 pane.fireEvent('activate');
25961 getActivePane : function()
25964 Roo.each(this.panes, function(p) {
25965 if(p.el.hasClass('active')){
25986 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25988 * @class Roo.bootstrap.TabPane
25989 * @extends Roo.bootstrap.Component
25990 * Bootstrap TabPane class
25991 * @cfg {Boolean} active (false | true) Default false
25992 * @cfg {String} title title of panel
25996 * Create a new TabPane
25997 * @param {Object} config The config object
26000 Roo.bootstrap.dash.TabPane = function(config){
26001 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
26007 * When a pane is activated
26008 * @param {Roo.bootstrap.dash.TabPane} pane
26015 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
26020 // the tabBox that this is attached to.
26023 getAutoCreate : function()
26031 cfg.cls += ' active';
26036 initEvents : function()
26038 //Roo.log('trigger add pane handler');
26039 this.parent().fireEvent('addpane', this)
26043 * Updates the tab title
26044 * @param {String} html to set the title to.
26046 setTitle: function(str)
26052 this.tab.select('a', true).first().dom.innerHTML = str;
26069 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26072 * @class Roo.bootstrap.menu.Menu
26073 * @extends Roo.bootstrap.Component
26074 * Bootstrap Menu class - container for Menu
26075 * @cfg {String} html Text of the menu
26076 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
26077 * @cfg {String} icon Font awesome icon
26078 * @cfg {String} pos Menu align to (top | bottom) default bottom
26082 * Create a new Menu
26083 * @param {Object} config The config object
26087 Roo.bootstrap.menu.Menu = function(config){
26088 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
26092 * @event beforeshow
26093 * Fires before this menu is displayed
26094 * @param {Roo.bootstrap.menu.Menu} this
26098 * @event beforehide
26099 * Fires before this menu is hidden
26100 * @param {Roo.bootstrap.menu.Menu} this
26105 * Fires after this menu is displayed
26106 * @param {Roo.bootstrap.menu.Menu} this
26111 * Fires after this menu is hidden
26112 * @param {Roo.bootstrap.menu.Menu} this
26117 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
26118 * @param {Roo.bootstrap.menu.Menu} this
26119 * @param {Roo.EventObject} e
26126 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
26130 weight : 'default',
26135 getChildContainer : function() {
26136 if(this.isSubMenu){
26140 return this.el.select('ul.dropdown-menu', true).first();
26143 getAutoCreate : function()
26148 cls : 'roo-menu-text',
26156 cls : 'fa ' + this.icon
26167 cls : 'dropdown-button btn btn-' + this.weight,
26172 cls : 'dropdown-toggle btn btn-' + this.weight,
26182 cls : 'dropdown-menu'
26188 if(this.pos == 'top'){
26189 cfg.cls += ' dropup';
26192 if(this.isSubMenu){
26195 cls : 'dropdown-menu'
26202 onRender : function(ct, position)
26204 this.isSubMenu = ct.hasClass('dropdown-submenu');
26206 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
26209 initEvents : function()
26211 if(this.isSubMenu){
26215 this.hidden = true;
26217 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
26218 this.triggerEl.on('click', this.onTriggerPress, this);
26220 this.buttonEl = this.el.select('button.dropdown-button', true).first();
26221 this.buttonEl.on('click', this.onClick, this);
26227 if(this.isSubMenu){
26231 return this.el.select('ul.dropdown-menu', true).first();
26234 onClick : function(e)
26236 this.fireEvent("click", this, e);
26239 onTriggerPress : function(e)
26241 if (this.isVisible()) {
26248 isVisible : function(){
26249 return !this.hidden;
26254 this.fireEvent("beforeshow", this);
26256 this.hidden = false;
26257 this.el.addClass('open');
26259 Roo.get(document).on("mouseup", this.onMouseUp, this);
26261 this.fireEvent("show", this);
26268 this.fireEvent("beforehide", this);
26270 this.hidden = true;
26271 this.el.removeClass('open');
26273 Roo.get(document).un("mouseup", this.onMouseUp);
26275 this.fireEvent("hide", this);
26278 onMouseUp : function()
26292 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26295 * @class Roo.bootstrap.menu.Item
26296 * @extends Roo.bootstrap.Component
26297 * Bootstrap MenuItem class
26298 * @cfg {Boolean} submenu (true | false) default false
26299 * @cfg {String} html text of the item
26300 * @cfg {String} href the link
26301 * @cfg {Boolean} disable (true | false) default false
26302 * @cfg {Boolean} preventDefault (true | false) default true
26303 * @cfg {String} icon Font awesome icon
26304 * @cfg {String} pos Submenu align to (left | right) default right
26308 * Create a new Item
26309 * @param {Object} config The config object
26313 Roo.bootstrap.menu.Item = function(config){
26314 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
26318 * Fires when the mouse is hovering over this menu
26319 * @param {Roo.bootstrap.menu.Item} this
26320 * @param {Roo.EventObject} e
26325 * Fires when the mouse exits this menu
26326 * @param {Roo.bootstrap.menu.Item} this
26327 * @param {Roo.EventObject} e
26333 * The raw click event for the entire grid.
26334 * @param {Roo.EventObject} e
26340 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
26345 preventDefault: true,
26350 getAutoCreate : function()
26355 cls : 'roo-menu-item-text',
26363 cls : 'fa ' + this.icon
26372 href : this.href || '#',
26379 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
26383 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
26385 if(this.pos == 'left'){
26386 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
26393 initEvents : function()
26395 this.el.on('mouseover', this.onMouseOver, this);
26396 this.el.on('mouseout', this.onMouseOut, this);
26398 this.el.select('a', true).first().on('click', this.onClick, this);
26402 onClick : function(e)
26404 if(this.preventDefault){
26405 e.preventDefault();
26408 this.fireEvent("click", this, e);
26411 onMouseOver : function(e)
26413 if(this.submenu && this.pos == 'left'){
26414 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
26417 this.fireEvent("mouseover", this, e);
26420 onMouseOut : function(e)
26422 this.fireEvent("mouseout", this, e);
26434 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26437 * @class Roo.bootstrap.menu.Separator
26438 * @extends Roo.bootstrap.Component
26439 * Bootstrap Separator class
26442 * Create a new Separator
26443 * @param {Object} config The config object
26447 Roo.bootstrap.menu.Separator = function(config){
26448 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
26451 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
26453 getAutoCreate : function(){
26474 * @class Roo.bootstrap.Tooltip
26475 * Bootstrap Tooltip class
26476 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
26477 * to determine which dom element triggers the tooltip.
26479 * It needs to add support for additional attributes like tooltip-position
26482 * Create a new Toolti
26483 * @param {Object} config The config object
26486 Roo.bootstrap.Tooltip = function(config){
26487 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
26489 this.alignment = Roo.bootstrap.Tooltip.alignment;
26491 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
26492 this.alignment = config.alignment;
26497 Roo.apply(Roo.bootstrap.Tooltip, {
26499 * @function init initialize tooltip monitoring.
26503 currentTip : false,
26504 currentRegion : false,
26510 Roo.get(document).on('mouseover', this.enter ,this);
26511 Roo.get(document).on('mouseout', this.leave, this);
26514 this.currentTip = new Roo.bootstrap.Tooltip();
26517 enter : function(ev)
26519 var dom = ev.getTarget();
26521 //Roo.log(['enter',dom]);
26522 var el = Roo.fly(dom);
26523 if (this.currentEl) {
26525 //Roo.log(this.currentEl);
26526 //Roo.log(this.currentEl.contains(dom));
26527 if (this.currentEl == el) {
26530 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
26536 if (this.currentTip.el) {
26537 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
26541 if(!el || el.dom == document){
26547 // you can not look for children, as if el is the body.. then everythign is the child..
26548 if (!el.attr('tooltip')) { //
26549 if (!el.select("[tooltip]").elements.length) {
26552 // is the mouse over this child...?
26553 bindEl = el.select("[tooltip]").first();
26554 var xy = ev.getXY();
26555 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
26556 //Roo.log("not in region.");
26559 //Roo.log("child element over..");
26562 this.currentEl = bindEl;
26563 this.currentTip.bind(bindEl);
26564 this.currentRegion = Roo.lib.Region.getRegion(dom);
26565 this.currentTip.enter();
26568 leave : function(ev)
26570 var dom = ev.getTarget();
26571 //Roo.log(['leave',dom]);
26572 if (!this.currentEl) {
26577 if (dom != this.currentEl.dom) {
26580 var xy = ev.getXY();
26581 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
26584 // only activate leave if mouse cursor is outside... bounding box..
26589 if (this.currentTip) {
26590 this.currentTip.leave();
26592 //Roo.log('clear currentEl');
26593 this.currentEl = false;
26598 'left' : ['r-l', [-2,0], 'right'],
26599 'right' : ['l-r', [2,0], 'left'],
26600 'bottom' : ['t-b', [0,2], 'top'],
26601 'top' : [ 'b-t', [0,-2], 'bottom']
26607 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
26612 delay : null, // can be { show : 300 , hide: 500}
26616 hoverState : null, //???
26618 placement : 'bottom',
26622 getAutoCreate : function(){
26629 cls : 'tooltip-arrow'
26632 cls : 'tooltip-inner'
26639 bind : function(el)
26645 enter : function () {
26647 if (this.timeout != null) {
26648 clearTimeout(this.timeout);
26651 this.hoverState = 'in';
26652 //Roo.log("enter - show");
26653 if (!this.delay || !this.delay.show) {
26658 this.timeout = setTimeout(function () {
26659 if (_t.hoverState == 'in') {
26662 }, this.delay.show);
26666 clearTimeout(this.timeout);
26668 this.hoverState = 'out';
26669 if (!this.delay || !this.delay.hide) {
26675 this.timeout = setTimeout(function () {
26676 //Roo.log("leave - timeout");
26678 if (_t.hoverState == 'out') {
26680 Roo.bootstrap.Tooltip.currentEl = false;
26685 show : function (msg)
26688 this.render(document.body);
26691 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
26693 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
26695 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
26697 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
26699 var placement = typeof this.placement == 'function' ?
26700 this.placement.call(this, this.el, on_el) :
26703 var autoToken = /\s?auto?\s?/i;
26704 var autoPlace = autoToken.test(placement);
26706 placement = placement.replace(autoToken, '') || 'top';
26710 //this.el.setXY([0,0]);
26712 //this.el.dom.style.display='block';
26714 //this.el.appendTo(on_el);
26716 var p = this.getPosition();
26717 var box = this.el.getBox();
26723 var align = this.alignment[placement];
26725 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
26727 if(placement == 'top' || placement == 'bottom'){
26729 placement = 'right';
26732 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
26733 placement = 'left';
26736 var scroll = Roo.select('body', true).first().getScroll();
26738 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
26742 align = this.alignment[placement];
26745 this.el.alignTo(this.bindEl, align[0],align[1]);
26746 //var arrow = this.el.select('.arrow',true).first();
26747 //arrow.set(align[2],
26749 this.el.addClass(placement);
26751 this.el.addClass('in fade');
26753 this.hoverState = null;
26755 if (this.el.hasClass('fade')) {
26766 //this.el.setXY([0,0]);
26767 this.el.removeClass('in');
26783 * @class Roo.bootstrap.LocationPicker
26784 * @extends Roo.bootstrap.Component
26785 * Bootstrap LocationPicker class
26786 * @cfg {Number} latitude Position when init default 0
26787 * @cfg {Number} longitude Position when init default 0
26788 * @cfg {Number} zoom default 15
26789 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
26790 * @cfg {Boolean} mapTypeControl default false
26791 * @cfg {Boolean} disableDoubleClickZoom default false
26792 * @cfg {Boolean} scrollwheel default true
26793 * @cfg {Boolean} streetViewControl default false
26794 * @cfg {Number} radius default 0
26795 * @cfg {String} locationName
26796 * @cfg {Boolean} draggable default true
26797 * @cfg {Boolean} enableAutocomplete default false
26798 * @cfg {Boolean} enableReverseGeocode default true
26799 * @cfg {String} markerTitle
26802 * Create a new LocationPicker
26803 * @param {Object} config The config object
26807 Roo.bootstrap.LocationPicker = function(config){
26809 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
26814 * Fires when the picker initialized.
26815 * @param {Roo.bootstrap.LocationPicker} this
26816 * @param {Google Location} location
26820 * @event positionchanged
26821 * Fires when the picker position changed.
26822 * @param {Roo.bootstrap.LocationPicker} this
26823 * @param {Google Location} location
26825 positionchanged : true,
26828 * Fires when the map resize.
26829 * @param {Roo.bootstrap.LocationPicker} this
26834 * Fires when the map show.
26835 * @param {Roo.bootstrap.LocationPicker} this
26840 * Fires when the map hide.
26841 * @param {Roo.bootstrap.LocationPicker} this
26846 * Fires when click the map.
26847 * @param {Roo.bootstrap.LocationPicker} this
26848 * @param {Map event} e
26852 * @event mapRightClick
26853 * Fires when right click the map.
26854 * @param {Roo.bootstrap.LocationPicker} this
26855 * @param {Map event} e
26857 mapRightClick : true,
26859 * @event markerClick
26860 * Fires when click the marker.
26861 * @param {Roo.bootstrap.LocationPicker} this
26862 * @param {Map event} e
26864 markerClick : true,
26866 * @event markerRightClick
26867 * Fires when right click the marker.
26868 * @param {Roo.bootstrap.LocationPicker} this
26869 * @param {Map event} e
26871 markerRightClick : true,
26873 * @event OverlayViewDraw
26874 * Fires when OverlayView Draw
26875 * @param {Roo.bootstrap.LocationPicker} this
26877 OverlayViewDraw : true,
26879 * @event OverlayViewOnAdd
26880 * Fires when OverlayView Draw
26881 * @param {Roo.bootstrap.LocationPicker} this
26883 OverlayViewOnAdd : true,
26885 * @event OverlayViewOnRemove
26886 * Fires when OverlayView Draw
26887 * @param {Roo.bootstrap.LocationPicker} this
26889 OverlayViewOnRemove : true,
26891 * @event OverlayViewShow
26892 * Fires when OverlayView Draw
26893 * @param {Roo.bootstrap.LocationPicker} this
26894 * @param {Pixel} cpx
26896 OverlayViewShow : true,
26898 * @event OverlayViewHide
26899 * Fires when OverlayView Draw
26900 * @param {Roo.bootstrap.LocationPicker} this
26902 OverlayViewHide : true,
26904 * @event loadexception
26905 * Fires when load google lib failed.
26906 * @param {Roo.bootstrap.LocationPicker} this
26908 loadexception : true
26913 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
26915 gMapContext: false,
26921 mapTypeControl: false,
26922 disableDoubleClickZoom: false,
26924 streetViewControl: false,
26928 enableAutocomplete: false,
26929 enableReverseGeocode: true,
26932 getAutoCreate: function()
26937 cls: 'roo-location-picker'
26943 initEvents: function(ct, position)
26945 if(!this.el.getWidth() || this.isApplied()){
26949 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26954 initial: function()
26956 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
26957 this.fireEvent('loadexception', this);
26961 if(!this.mapTypeId){
26962 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
26965 this.gMapContext = this.GMapContext();
26967 this.initOverlayView();
26969 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
26973 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
26974 _this.setPosition(_this.gMapContext.marker.position);
26977 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
26978 _this.fireEvent('mapClick', this, event);
26982 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
26983 _this.fireEvent('mapRightClick', this, event);
26987 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
26988 _this.fireEvent('markerClick', this, event);
26992 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
26993 _this.fireEvent('markerRightClick', this, event);
26997 this.setPosition(this.gMapContext.location);
26999 this.fireEvent('initial', this, this.gMapContext.location);
27002 initOverlayView: function()
27006 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
27010 _this.fireEvent('OverlayViewDraw', _this);
27015 _this.fireEvent('OverlayViewOnAdd', _this);
27018 onRemove: function()
27020 _this.fireEvent('OverlayViewOnRemove', _this);
27023 show: function(cpx)
27025 _this.fireEvent('OverlayViewShow', _this, cpx);
27030 _this.fireEvent('OverlayViewHide', _this);
27036 fromLatLngToContainerPixel: function(event)
27038 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
27041 isApplied: function()
27043 return this.getGmapContext() == false ? false : true;
27046 getGmapContext: function()
27048 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
27051 GMapContext: function()
27053 var position = new google.maps.LatLng(this.latitude, this.longitude);
27055 var _map = new google.maps.Map(this.el.dom, {
27058 mapTypeId: this.mapTypeId,
27059 mapTypeControl: this.mapTypeControl,
27060 disableDoubleClickZoom: this.disableDoubleClickZoom,
27061 scrollwheel: this.scrollwheel,
27062 streetViewControl: this.streetViewControl,
27063 locationName: this.locationName,
27064 draggable: this.draggable,
27065 enableAutocomplete: this.enableAutocomplete,
27066 enableReverseGeocode: this.enableReverseGeocode
27069 var _marker = new google.maps.Marker({
27070 position: position,
27072 title: this.markerTitle,
27073 draggable: this.draggable
27080 location: position,
27081 radius: this.radius,
27082 locationName: this.locationName,
27083 addressComponents: {
27084 formatted_address: null,
27085 addressLine1: null,
27086 addressLine2: null,
27088 streetNumber: null,
27092 stateOrProvince: null
27095 domContainer: this.el.dom,
27096 geodecoder: new google.maps.Geocoder()
27100 drawCircle: function(center, radius, options)
27102 if (this.gMapContext.circle != null) {
27103 this.gMapContext.circle.setMap(null);
27107 options = Roo.apply({}, options, {
27108 strokeColor: "#0000FF",
27109 strokeOpacity: .35,
27111 fillColor: "#0000FF",
27115 options.map = this.gMapContext.map;
27116 options.radius = radius;
27117 options.center = center;
27118 this.gMapContext.circle = new google.maps.Circle(options);
27119 return this.gMapContext.circle;
27125 setPosition: function(location)
27127 this.gMapContext.location = location;
27128 this.gMapContext.marker.setPosition(location);
27129 this.gMapContext.map.panTo(location);
27130 this.drawCircle(location, this.gMapContext.radius, {});
27134 if (this.gMapContext.settings.enableReverseGeocode) {
27135 this.gMapContext.geodecoder.geocode({
27136 latLng: this.gMapContext.location
27137 }, function(results, status) {
27139 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
27140 _this.gMapContext.locationName = results[0].formatted_address;
27141 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
27143 _this.fireEvent('positionchanged', this, location);
27150 this.fireEvent('positionchanged', this, location);
27155 google.maps.event.trigger(this.gMapContext.map, "resize");
27157 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
27159 this.fireEvent('resize', this);
27162 setPositionByLatLng: function(latitude, longitude)
27164 this.setPosition(new google.maps.LatLng(latitude, longitude));
27167 getCurrentPosition: function()
27170 latitude: this.gMapContext.location.lat(),
27171 longitude: this.gMapContext.location.lng()
27175 getAddressName: function()
27177 return this.gMapContext.locationName;
27180 getAddressComponents: function()
27182 return this.gMapContext.addressComponents;
27185 address_component_from_google_geocode: function(address_components)
27189 for (var i = 0; i < address_components.length; i++) {
27190 var component = address_components[i];
27191 if (component.types.indexOf("postal_code") >= 0) {
27192 result.postalCode = component.short_name;
27193 } else if (component.types.indexOf("street_number") >= 0) {
27194 result.streetNumber = component.short_name;
27195 } else if (component.types.indexOf("route") >= 0) {
27196 result.streetName = component.short_name;
27197 } else if (component.types.indexOf("neighborhood") >= 0) {
27198 result.city = component.short_name;
27199 } else if (component.types.indexOf("locality") >= 0) {
27200 result.city = component.short_name;
27201 } else if (component.types.indexOf("sublocality") >= 0) {
27202 result.district = component.short_name;
27203 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
27204 result.stateOrProvince = component.short_name;
27205 } else if (component.types.indexOf("country") >= 0) {
27206 result.country = component.short_name;
27210 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
27211 result.addressLine2 = "";
27215 setZoomLevel: function(zoom)
27217 this.gMapContext.map.setZoom(zoom);
27230 this.fireEvent('show', this);
27241 this.fireEvent('hide', this);
27246 Roo.apply(Roo.bootstrap.LocationPicker, {
27248 OverlayView : function(map, options)
27250 options = options || {};
27257 * @class Roo.bootstrap.Alert
27258 * @extends Roo.bootstrap.Component
27259 * Bootstrap Alert class - shows an alert area box
27261 * <div class="alert alert-danger" role="alert"><span class="fa fa-exclamation-triangle"></span><span class="sr-only">Error:</span>
27262 Enter a valid email address
27265 * @cfg {String} title The title of alert
27266 * @cfg {String} html The content of alert
27267 * @cfg {String} weight ( success | info | warning | danger )
27268 * @cfg {String} faicon font-awesomeicon
27271 * Create a new alert
27272 * @param {Object} config The config object
27276 Roo.bootstrap.Alert = function(config){
27277 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
27281 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
27288 getAutoCreate : function()
27297 cls : 'roo-alert-icon'
27302 cls : 'roo-alert-title',
27307 cls : 'roo-alert-text',
27314 cfg.cn[0].cls += ' fa ' + this.faicon;
27318 cfg.cls += ' alert-' + this.weight;
27324 initEvents: function()
27326 this.el.setVisibilityMode(Roo.Element.DISPLAY);
27329 setTitle : function(str)
27331 this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
27334 setText : function(str)
27336 this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
27339 setWeight : function(weight)
27342 this.el.select('.alert',true).first().removeClass('alert-' + this.weight);
27345 this.weight = weight;
27347 this.el.select('.alert',true).first().addClass('alert-' + this.weight);
27350 setIcon : function(icon)
27353 this.el.select('.roo-alert-icon',true).first().removeClass(['fa', 'fa-' + this.faicon]);
27356 this.faicon = icon;
27358 this.el.select('.roo-alert-icon',true).first().addClass(['fa', 'fa-' + this.faicon]);
27379 * @class Roo.bootstrap.UploadCropbox
27380 * @extends Roo.bootstrap.Component
27381 * Bootstrap UploadCropbox class
27382 * @cfg {String} emptyText show when image has been loaded
27383 * @cfg {String} rotateNotify show when image too small to rotate
27384 * @cfg {Number} errorTimeout default 3000
27385 * @cfg {Number} minWidth default 300
27386 * @cfg {Number} minHeight default 300
27387 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
27388 * @cfg {Boolean} isDocument (true|false) default false
27389 * @cfg {String} url action url
27390 * @cfg {String} paramName default 'imageUpload'
27391 * @cfg {String} method default POST
27392 * @cfg {Boolean} loadMask (true|false) default true
27393 * @cfg {Boolean} loadingText default 'Loading...'
27396 * Create a new UploadCropbox
27397 * @param {Object} config The config object
27400 Roo.bootstrap.UploadCropbox = function(config){
27401 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
27405 * @event beforeselectfile
27406 * Fire before select file
27407 * @param {Roo.bootstrap.UploadCropbox} this
27409 "beforeselectfile" : true,
27412 * Fire after initEvent
27413 * @param {Roo.bootstrap.UploadCropbox} this
27418 * Fire after initEvent
27419 * @param {Roo.bootstrap.UploadCropbox} this
27420 * @param {String} data
27425 * Fire when preparing the file data
27426 * @param {Roo.bootstrap.UploadCropbox} this
27427 * @param {Object} file
27432 * Fire when get exception
27433 * @param {Roo.bootstrap.UploadCropbox} this
27434 * @param {XMLHttpRequest} xhr
27436 "exception" : true,
27438 * @event beforeloadcanvas
27439 * Fire before load the canvas
27440 * @param {Roo.bootstrap.UploadCropbox} this
27441 * @param {String} src
27443 "beforeloadcanvas" : true,
27446 * Fire when trash image
27447 * @param {Roo.bootstrap.UploadCropbox} this
27452 * Fire when download the image
27453 * @param {Roo.bootstrap.UploadCropbox} this
27457 * @event footerbuttonclick
27458 * Fire when footerbuttonclick
27459 * @param {Roo.bootstrap.UploadCropbox} this
27460 * @param {String} type
27462 "footerbuttonclick" : true,
27466 * @param {Roo.bootstrap.UploadCropbox} this
27471 * Fire when rotate the image
27472 * @param {Roo.bootstrap.UploadCropbox} this
27473 * @param {String} pos
27478 * Fire when inspect the file
27479 * @param {Roo.bootstrap.UploadCropbox} this
27480 * @param {Object} file
27485 * Fire when xhr upload the file
27486 * @param {Roo.bootstrap.UploadCropbox} this
27487 * @param {Object} data
27492 * Fire when arrange the file data
27493 * @param {Roo.bootstrap.UploadCropbox} this
27494 * @param {Object} formData
27499 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
27502 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
27504 emptyText : 'Click to upload image',
27505 rotateNotify : 'Image is too small to rotate',
27506 errorTimeout : 3000,
27520 cropType : 'image/jpeg',
27522 canvasLoaded : false,
27523 isDocument : false,
27525 paramName : 'imageUpload',
27527 loadingText : 'Loading...',
27530 getAutoCreate : function()
27534 cls : 'roo-upload-cropbox',
27538 cls : 'roo-upload-cropbox-selector',
27543 cls : 'roo-upload-cropbox-body',
27544 style : 'cursor:pointer',
27548 cls : 'roo-upload-cropbox-preview'
27552 cls : 'roo-upload-cropbox-thumb'
27556 cls : 'roo-upload-cropbox-empty-notify',
27557 html : this.emptyText
27561 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
27562 html : this.rotateNotify
27568 cls : 'roo-upload-cropbox-footer',
27571 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
27581 onRender : function(ct, position)
27583 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
27585 if (this.buttons.length) {
27587 Roo.each(this.buttons, function(bb) {
27589 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
27591 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
27597 this.maskEl = this.el;
27601 initEvents : function()
27603 this.urlAPI = (window.createObjectURL && window) ||
27604 (window.URL && URL.revokeObjectURL && URL) ||
27605 (window.webkitURL && webkitURL);
27607 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
27608 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27610 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
27611 this.selectorEl.hide();
27613 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
27614 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27616 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
27617 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27618 this.thumbEl.hide();
27620 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
27621 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27623 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
27624 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27625 this.errorEl.hide();
27627 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
27628 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27629 this.footerEl.hide();
27631 this.setThumbBoxSize();
27637 this.fireEvent('initial', this);
27644 window.addEventListener("resize", function() { _this.resize(); } );
27646 this.bodyEl.on('click', this.beforeSelectFile, this);
27649 this.bodyEl.on('touchstart', this.onTouchStart, this);
27650 this.bodyEl.on('touchmove', this.onTouchMove, this);
27651 this.bodyEl.on('touchend', this.onTouchEnd, this);
27655 this.bodyEl.on('mousedown', this.onMouseDown, this);
27656 this.bodyEl.on('mousemove', this.onMouseMove, this);
27657 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
27658 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
27659 Roo.get(document).on('mouseup', this.onMouseUp, this);
27662 this.selectorEl.on('change', this.onFileSelected, this);
27668 this.baseScale = 1;
27670 this.baseRotate = 1;
27671 this.dragable = false;
27672 this.pinching = false;
27675 this.cropData = false;
27676 this.notifyEl.dom.innerHTML = this.emptyText;
27678 this.selectorEl.dom.value = '';
27682 resize : function()
27684 if(this.fireEvent('resize', this) != false){
27685 this.setThumbBoxPosition();
27686 this.setCanvasPosition();
27690 onFooterButtonClick : function(e, el, o, type)
27693 case 'rotate-left' :
27694 this.onRotateLeft(e);
27696 case 'rotate-right' :
27697 this.onRotateRight(e);
27700 this.beforeSelectFile(e);
27715 this.fireEvent('footerbuttonclick', this, type);
27718 beforeSelectFile : function(e)
27720 e.preventDefault();
27722 if(this.fireEvent('beforeselectfile', this) != false){
27723 this.selectorEl.dom.click();
27727 onFileSelected : function(e)
27729 e.preventDefault();
27731 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
27735 var file = this.selectorEl.dom.files[0];
27737 if(this.fireEvent('inspect', this, file) != false){
27738 this.prepare(file);
27743 trash : function(e)
27745 this.fireEvent('trash', this);
27748 download : function(e)
27750 this.fireEvent('download', this);
27753 loadCanvas : function(src)
27755 if(this.fireEvent('beforeloadcanvas', this, src) != false){
27759 this.imageEl = document.createElement('img');
27763 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
27765 this.imageEl.src = src;
27769 onLoadCanvas : function()
27771 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
27772 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
27774 this.bodyEl.un('click', this.beforeSelectFile, this);
27776 this.notifyEl.hide();
27777 this.thumbEl.show();
27778 this.footerEl.show();
27780 this.baseRotateLevel();
27782 if(this.isDocument){
27783 this.setThumbBoxSize();
27786 this.setThumbBoxPosition();
27788 this.baseScaleLevel();
27794 this.canvasLoaded = true;
27797 this.maskEl.unmask();
27802 setCanvasPosition : function()
27804 if(!this.canvasEl){
27808 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
27809 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
27811 this.previewEl.setLeft(pw);
27812 this.previewEl.setTop(ph);
27816 onMouseDown : function(e)
27820 this.dragable = true;
27821 this.pinching = false;
27823 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
27824 this.dragable = false;
27828 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27829 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27833 onMouseMove : function(e)
27837 if(!this.canvasLoaded){
27841 if (!this.dragable){
27845 var minX = Math.ceil(this.thumbEl.getLeft(true));
27846 var minY = Math.ceil(this.thumbEl.getTop(true));
27848 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
27849 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
27851 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27852 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27854 x = x - this.mouseX;
27855 y = y - this.mouseY;
27857 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
27858 var bgY = Math.ceil(y + this.previewEl.getTop(true));
27860 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
27861 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
27863 this.previewEl.setLeft(bgX);
27864 this.previewEl.setTop(bgY);
27866 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27867 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27870 onMouseUp : function(e)
27874 this.dragable = false;
27877 onMouseWheel : function(e)
27881 this.startScale = this.scale;
27883 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
27885 if(!this.zoomable()){
27886 this.scale = this.startScale;
27895 zoomable : function()
27897 var minScale = this.thumbEl.getWidth() / this.minWidth;
27899 if(this.minWidth < this.minHeight){
27900 minScale = this.thumbEl.getHeight() / this.minHeight;
27903 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
27904 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
27908 (this.rotate == 0 || this.rotate == 180) &&
27910 width > this.imageEl.OriginWidth ||
27911 height > this.imageEl.OriginHeight ||
27912 (width < this.minWidth && height < this.minHeight)
27920 (this.rotate == 90 || this.rotate == 270) &&
27922 width > this.imageEl.OriginWidth ||
27923 height > this.imageEl.OriginHeight ||
27924 (width < this.minHeight && height < this.minWidth)
27931 !this.isDocument &&
27932 (this.rotate == 0 || this.rotate == 180) &&
27934 width < this.minWidth ||
27935 width > this.imageEl.OriginWidth ||
27936 height < this.minHeight ||
27937 height > this.imageEl.OriginHeight
27944 !this.isDocument &&
27945 (this.rotate == 90 || this.rotate == 270) &&
27947 width < this.minHeight ||
27948 width > this.imageEl.OriginWidth ||
27949 height < this.minWidth ||
27950 height > this.imageEl.OriginHeight
27960 onRotateLeft : function(e)
27962 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27964 var minScale = this.thumbEl.getWidth() / this.minWidth;
27966 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27967 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27969 this.startScale = this.scale;
27971 while (this.getScaleLevel() < minScale){
27973 this.scale = this.scale + 1;
27975 if(!this.zoomable()){
27980 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27981 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27986 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27993 this.scale = this.startScale;
27995 this.onRotateFail();
28000 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
28002 if(this.isDocument){
28003 this.setThumbBoxSize();
28004 this.setThumbBoxPosition();
28005 this.setCanvasPosition();
28010 this.fireEvent('rotate', this, 'left');
28014 onRotateRight : function(e)
28016 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
28018 var minScale = this.thumbEl.getWidth() / this.minWidth;
28020 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
28021 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
28023 this.startScale = this.scale;
28025 while (this.getScaleLevel() < minScale){
28027 this.scale = this.scale + 1;
28029 if(!this.zoomable()){
28034 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
28035 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
28040 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
28047 this.scale = this.startScale;
28049 this.onRotateFail();
28054 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
28056 if(this.isDocument){
28057 this.setThumbBoxSize();
28058 this.setThumbBoxPosition();
28059 this.setCanvasPosition();
28064 this.fireEvent('rotate', this, 'right');
28067 onRotateFail : function()
28069 this.errorEl.show(true);
28073 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
28078 this.previewEl.dom.innerHTML = '';
28080 var canvasEl = document.createElement("canvas");
28082 var contextEl = canvasEl.getContext("2d");
28084 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
28085 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
28086 var center = this.imageEl.OriginWidth / 2;
28088 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
28089 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
28090 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
28091 center = this.imageEl.OriginHeight / 2;
28094 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
28096 contextEl.translate(center, center);
28097 contextEl.rotate(this.rotate * Math.PI / 180);
28099 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
28101 this.canvasEl = document.createElement("canvas");
28103 this.contextEl = this.canvasEl.getContext("2d");
28105 switch (this.rotate) {
28108 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
28109 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
28111 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28116 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
28117 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
28119 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28120 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);
28124 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28129 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
28130 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
28132 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28133 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);
28137 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);
28142 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
28143 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
28145 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28146 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
28150 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);
28157 this.previewEl.appendChild(this.canvasEl);
28159 this.setCanvasPosition();
28164 if(!this.canvasLoaded){
28168 var imageCanvas = document.createElement("canvas");
28170 var imageContext = imageCanvas.getContext("2d");
28172 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
28173 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
28175 var center = imageCanvas.width / 2;
28177 imageContext.translate(center, center);
28179 imageContext.rotate(this.rotate * Math.PI / 180);
28181 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
28183 var canvas = document.createElement("canvas");
28185 var context = canvas.getContext("2d");
28187 canvas.width = this.minWidth;
28188 canvas.height = this.minHeight;
28190 switch (this.rotate) {
28193 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
28194 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
28196 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28197 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28199 var targetWidth = this.minWidth - 2 * x;
28200 var targetHeight = this.minHeight - 2 * y;
28204 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28205 scale = targetWidth / width;
28208 if(x > 0 && y == 0){
28209 scale = targetHeight / height;
28212 if(x > 0 && y > 0){
28213 scale = targetWidth / width;
28215 if(width < height){
28216 scale = targetHeight / height;
28220 context.scale(scale, scale);
28222 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28223 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28225 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28226 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28228 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28233 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
28234 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
28236 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28237 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28239 var targetWidth = this.minWidth - 2 * x;
28240 var targetHeight = this.minHeight - 2 * y;
28244 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28245 scale = targetWidth / width;
28248 if(x > 0 && y == 0){
28249 scale = targetHeight / height;
28252 if(x > 0 && y > 0){
28253 scale = targetWidth / width;
28255 if(width < height){
28256 scale = targetHeight / height;
28260 context.scale(scale, scale);
28262 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28263 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28265 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28266 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28268 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
28270 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28275 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
28276 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
28278 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28279 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28281 var targetWidth = this.minWidth - 2 * x;
28282 var targetHeight = this.minHeight - 2 * y;
28286 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28287 scale = targetWidth / width;
28290 if(x > 0 && y == 0){
28291 scale = targetHeight / height;
28294 if(x > 0 && y > 0){
28295 scale = targetWidth / width;
28297 if(width < height){
28298 scale = targetHeight / height;
28302 context.scale(scale, scale);
28304 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28305 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28307 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28308 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28310 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28311 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
28313 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28318 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
28319 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
28321 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28322 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28324 var targetWidth = this.minWidth - 2 * x;
28325 var targetHeight = this.minHeight - 2 * y;
28329 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28330 scale = targetWidth / width;
28333 if(x > 0 && y == 0){
28334 scale = targetHeight / height;
28337 if(x > 0 && y > 0){
28338 scale = targetWidth / width;
28340 if(width < height){
28341 scale = targetHeight / height;
28345 context.scale(scale, scale);
28347 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28348 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28350 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28351 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28353 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28355 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28362 this.cropData = canvas.toDataURL(this.cropType);
28364 if(this.fireEvent('crop', this, this.cropData) !== false){
28365 this.process(this.file, this.cropData);
28372 setThumbBoxSize : function()
28376 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
28377 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
28378 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
28380 this.minWidth = width;
28381 this.minHeight = height;
28383 if(this.rotate == 90 || this.rotate == 270){
28384 this.minWidth = height;
28385 this.minHeight = width;
28390 width = Math.ceil(this.minWidth * height / this.minHeight);
28392 if(this.minWidth > this.minHeight){
28394 height = Math.ceil(this.minHeight * width / this.minWidth);
28397 this.thumbEl.setStyle({
28398 width : width + 'px',
28399 height : height + 'px'
28406 setThumbBoxPosition : function()
28408 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
28409 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
28411 this.thumbEl.setLeft(x);
28412 this.thumbEl.setTop(y);
28416 baseRotateLevel : function()
28418 this.baseRotate = 1;
28421 typeof(this.exif) != 'undefined' &&
28422 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
28423 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
28425 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
28428 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
28432 baseScaleLevel : function()
28436 if(this.isDocument){
28438 if(this.baseRotate == 6 || this.baseRotate == 8){
28440 height = this.thumbEl.getHeight();
28441 this.baseScale = height / this.imageEl.OriginWidth;
28443 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
28444 width = this.thumbEl.getWidth();
28445 this.baseScale = width / this.imageEl.OriginHeight;
28451 height = this.thumbEl.getHeight();
28452 this.baseScale = height / this.imageEl.OriginHeight;
28454 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
28455 width = this.thumbEl.getWidth();
28456 this.baseScale = width / this.imageEl.OriginWidth;
28462 if(this.baseRotate == 6 || this.baseRotate == 8){
28464 width = this.thumbEl.getHeight();
28465 this.baseScale = width / this.imageEl.OriginHeight;
28467 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
28468 height = this.thumbEl.getWidth();
28469 this.baseScale = height / this.imageEl.OriginHeight;
28472 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28473 height = this.thumbEl.getWidth();
28474 this.baseScale = height / this.imageEl.OriginHeight;
28476 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
28477 width = this.thumbEl.getHeight();
28478 this.baseScale = width / this.imageEl.OriginWidth;
28485 width = this.thumbEl.getWidth();
28486 this.baseScale = width / this.imageEl.OriginWidth;
28488 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
28489 height = this.thumbEl.getHeight();
28490 this.baseScale = height / this.imageEl.OriginHeight;
28493 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28495 height = this.thumbEl.getHeight();
28496 this.baseScale = height / this.imageEl.OriginHeight;
28498 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
28499 width = this.thumbEl.getWidth();
28500 this.baseScale = width / this.imageEl.OriginWidth;
28508 getScaleLevel : function()
28510 return this.baseScale * Math.pow(1.1, this.scale);
28513 onTouchStart : function(e)
28515 if(!this.canvasLoaded){
28516 this.beforeSelectFile(e);
28520 var touches = e.browserEvent.touches;
28526 if(touches.length == 1){
28527 this.onMouseDown(e);
28531 if(touches.length != 2){
28537 for(var i = 0, finger; finger = touches[i]; i++){
28538 coords.push(finger.pageX, finger.pageY);
28541 var x = Math.pow(coords[0] - coords[2], 2);
28542 var y = Math.pow(coords[1] - coords[3], 2);
28544 this.startDistance = Math.sqrt(x + y);
28546 this.startScale = this.scale;
28548 this.pinching = true;
28549 this.dragable = false;
28553 onTouchMove : function(e)
28555 if(!this.pinching && !this.dragable){
28559 var touches = e.browserEvent.touches;
28566 this.onMouseMove(e);
28572 for(var i = 0, finger; finger = touches[i]; i++){
28573 coords.push(finger.pageX, finger.pageY);
28576 var x = Math.pow(coords[0] - coords[2], 2);
28577 var y = Math.pow(coords[1] - coords[3], 2);
28579 this.endDistance = Math.sqrt(x + y);
28581 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
28583 if(!this.zoomable()){
28584 this.scale = this.startScale;
28592 onTouchEnd : function(e)
28594 this.pinching = false;
28595 this.dragable = false;
28599 process : function(file, crop)
28602 this.maskEl.mask(this.loadingText);
28605 this.xhr = new XMLHttpRequest();
28607 file.xhr = this.xhr;
28609 this.xhr.open(this.method, this.url, true);
28612 "Accept": "application/json",
28613 "Cache-Control": "no-cache",
28614 "X-Requested-With": "XMLHttpRequest"
28617 for (var headerName in headers) {
28618 var headerValue = headers[headerName];
28620 this.xhr.setRequestHeader(headerName, headerValue);
28626 this.xhr.onload = function()
28628 _this.xhrOnLoad(_this.xhr);
28631 this.xhr.onerror = function()
28633 _this.xhrOnError(_this.xhr);
28636 var formData = new FormData();
28638 formData.append('returnHTML', 'NO');
28641 formData.append('crop', crop);
28644 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
28645 formData.append(this.paramName, file, file.name);
28648 if(typeof(file.filename) != 'undefined'){
28649 formData.append('filename', file.filename);
28652 if(typeof(file.mimetype) != 'undefined'){
28653 formData.append('mimetype', file.mimetype);
28656 if(this.fireEvent('arrange', this, formData) != false){
28657 this.xhr.send(formData);
28661 xhrOnLoad : function(xhr)
28664 this.maskEl.unmask();
28667 if (xhr.readyState !== 4) {
28668 this.fireEvent('exception', this, xhr);
28672 var response = Roo.decode(xhr.responseText);
28674 if(!response.success){
28675 this.fireEvent('exception', this, xhr);
28679 var response = Roo.decode(xhr.responseText);
28681 this.fireEvent('upload', this, response);
28685 xhrOnError : function()
28688 this.maskEl.unmask();
28691 Roo.log('xhr on error');
28693 var response = Roo.decode(xhr.responseText);
28699 prepare : function(file)
28702 this.maskEl.mask(this.loadingText);
28708 if(typeof(file) === 'string'){
28709 this.loadCanvas(file);
28713 if(!file || !this.urlAPI){
28718 this.cropType = file.type;
28722 if(this.fireEvent('prepare', this, this.file) != false){
28724 var reader = new FileReader();
28726 reader.onload = function (e) {
28727 if (e.target.error) {
28728 Roo.log(e.target.error);
28732 var buffer = e.target.result,
28733 dataView = new DataView(buffer),
28735 maxOffset = dataView.byteLength - 4,
28739 if (dataView.getUint16(0) === 0xffd8) {
28740 while (offset < maxOffset) {
28741 markerBytes = dataView.getUint16(offset);
28743 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
28744 markerLength = dataView.getUint16(offset + 2) + 2;
28745 if (offset + markerLength > dataView.byteLength) {
28746 Roo.log('Invalid meta data: Invalid segment size.');
28750 if(markerBytes == 0xffe1){
28751 _this.parseExifData(
28758 offset += markerLength;
28768 var url = _this.urlAPI.createObjectURL(_this.file);
28770 _this.loadCanvas(url);
28775 reader.readAsArrayBuffer(this.file);
28781 parseExifData : function(dataView, offset, length)
28783 var tiffOffset = offset + 10,
28787 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28788 // No Exif data, might be XMP data instead
28792 // Check for the ASCII code for "Exif" (0x45786966):
28793 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28794 // No Exif data, might be XMP data instead
28797 if (tiffOffset + 8 > dataView.byteLength) {
28798 Roo.log('Invalid Exif data: Invalid segment size.');
28801 // Check for the two null bytes:
28802 if (dataView.getUint16(offset + 8) !== 0x0000) {
28803 Roo.log('Invalid Exif data: Missing byte alignment offset.');
28806 // Check the byte alignment:
28807 switch (dataView.getUint16(tiffOffset)) {
28809 littleEndian = true;
28812 littleEndian = false;
28815 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
28818 // Check for the TIFF tag marker (0x002A):
28819 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
28820 Roo.log('Invalid Exif data: Missing TIFF marker.');
28823 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
28824 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
28826 this.parseExifTags(
28829 tiffOffset + dirOffset,
28834 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
28839 if (dirOffset + 6 > dataView.byteLength) {
28840 Roo.log('Invalid Exif data: Invalid directory offset.');
28843 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
28844 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
28845 if (dirEndOffset + 4 > dataView.byteLength) {
28846 Roo.log('Invalid Exif data: Invalid directory size.');
28849 for (i = 0; i < tagsNumber; i += 1) {
28853 dirOffset + 2 + 12 * i, // tag offset
28857 // Return the offset to the next directory:
28858 return dataView.getUint32(dirEndOffset, littleEndian);
28861 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
28863 var tag = dataView.getUint16(offset, littleEndian);
28865 this.exif[tag] = this.getExifValue(
28869 dataView.getUint16(offset + 2, littleEndian), // tag type
28870 dataView.getUint32(offset + 4, littleEndian), // tag length
28875 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
28877 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
28886 Roo.log('Invalid Exif data: Invalid tag type.');
28890 tagSize = tagType.size * length;
28891 // Determine if the value is contained in the dataOffset bytes,
28892 // or if the value at the dataOffset is a pointer to the actual data:
28893 dataOffset = tagSize > 4 ?
28894 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
28895 if (dataOffset + tagSize > dataView.byteLength) {
28896 Roo.log('Invalid Exif data: Invalid data offset.');
28899 if (length === 1) {
28900 return tagType.getValue(dataView, dataOffset, littleEndian);
28903 for (i = 0; i < length; i += 1) {
28904 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
28907 if (tagType.ascii) {
28909 // Concatenate the chars:
28910 for (i = 0; i < values.length; i += 1) {
28912 // Ignore the terminating NULL byte(s):
28913 if (c === '\u0000') {
28925 Roo.apply(Roo.bootstrap.UploadCropbox, {
28927 'Orientation': 0x0112
28931 1: 0, //'top-left',
28933 3: 180, //'bottom-right',
28934 // 4: 'bottom-left',
28936 6: 90, //'right-top',
28937 // 7: 'right-bottom',
28938 8: 270 //'left-bottom'
28942 // byte, 8-bit unsigned int:
28944 getValue: function (dataView, dataOffset) {
28945 return dataView.getUint8(dataOffset);
28949 // ascii, 8-bit byte:
28951 getValue: function (dataView, dataOffset) {
28952 return String.fromCharCode(dataView.getUint8(dataOffset));
28957 // short, 16 bit int:
28959 getValue: function (dataView, dataOffset, littleEndian) {
28960 return dataView.getUint16(dataOffset, littleEndian);
28964 // long, 32 bit int:
28966 getValue: function (dataView, dataOffset, littleEndian) {
28967 return dataView.getUint32(dataOffset, littleEndian);
28971 // rational = two long values, first is numerator, second is denominator:
28973 getValue: function (dataView, dataOffset, littleEndian) {
28974 return dataView.getUint32(dataOffset, littleEndian) /
28975 dataView.getUint32(dataOffset + 4, littleEndian);
28979 // slong, 32 bit signed int:
28981 getValue: function (dataView, dataOffset, littleEndian) {
28982 return dataView.getInt32(dataOffset, littleEndian);
28986 // srational, two slongs, first is numerator, second is denominator:
28988 getValue: function (dataView, dataOffset, littleEndian) {
28989 return dataView.getInt32(dataOffset, littleEndian) /
28990 dataView.getInt32(dataOffset + 4, littleEndian);
29000 cls : 'btn-group roo-upload-cropbox-rotate-left',
29001 action : 'rotate-left',
29005 cls : 'btn btn-default',
29006 html : '<i class="fa fa-undo"></i>'
29012 cls : 'btn-group roo-upload-cropbox-picture',
29013 action : 'picture',
29017 cls : 'btn btn-default',
29018 html : '<i class="fa fa-picture-o"></i>'
29024 cls : 'btn-group roo-upload-cropbox-rotate-right',
29025 action : 'rotate-right',
29029 cls : 'btn btn-default',
29030 html : '<i class="fa fa-repeat"></i>'
29038 cls : 'btn-group roo-upload-cropbox-rotate-left',
29039 action : 'rotate-left',
29043 cls : 'btn btn-default',
29044 html : '<i class="fa fa-undo"></i>'
29050 cls : 'btn-group roo-upload-cropbox-download',
29051 action : 'download',
29055 cls : 'btn btn-default',
29056 html : '<i class="fa fa-download"></i>'
29062 cls : 'btn-group roo-upload-cropbox-crop',
29067 cls : 'btn btn-default',
29068 html : '<i class="fa fa-crop"></i>'
29074 cls : 'btn-group roo-upload-cropbox-trash',
29079 cls : 'btn btn-default',
29080 html : '<i class="fa fa-trash"></i>'
29086 cls : 'btn-group roo-upload-cropbox-rotate-right',
29087 action : 'rotate-right',
29091 cls : 'btn btn-default',
29092 html : '<i class="fa fa-repeat"></i>'
29100 cls : 'btn-group roo-upload-cropbox-rotate-left',
29101 action : 'rotate-left',
29105 cls : 'btn btn-default',
29106 html : '<i class="fa fa-undo"></i>'
29112 cls : 'btn-group roo-upload-cropbox-rotate-right',
29113 action : 'rotate-right',
29117 cls : 'btn btn-default',
29118 html : '<i class="fa fa-repeat"></i>'
29131 * @class Roo.bootstrap.DocumentManager
29132 * @extends Roo.bootstrap.Component
29133 * Bootstrap DocumentManager class
29134 * @cfg {String} paramName default 'imageUpload'
29135 * @cfg {String} toolTipName default 'filename'
29136 * @cfg {String} method default POST
29137 * @cfg {String} url action url
29138 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
29139 * @cfg {Boolean} multiple multiple upload default true
29140 * @cfg {Number} thumbSize default 300
29141 * @cfg {String} fieldLabel
29142 * @cfg {Number} labelWidth default 4
29143 * @cfg {String} labelAlign (left|top) default left
29144 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
29145 * @cfg {Number} labellg set the width of label (1-12)
29146 * @cfg {Number} labelmd set the width of label (1-12)
29147 * @cfg {Number} labelsm set the width of label (1-12)
29148 * @cfg {Number} labelxs set the width of label (1-12)
29151 * Create a new DocumentManager
29152 * @param {Object} config The config object
29155 Roo.bootstrap.DocumentManager = function(config){
29156 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
29159 this.delegates = [];
29164 * Fire when initial the DocumentManager
29165 * @param {Roo.bootstrap.DocumentManager} this
29170 * inspect selected file
29171 * @param {Roo.bootstrap.DocumentManager} this
29172 * @param {File} file
29177 * Fire when xhr load exception
29178 * @param {Roo.bootstrap.DocumentManager} this
29179 * @param {XMLHttpRequest} xhr
29181 "exception" : true,
29183 * @event afterupload
29184 * Fire when xhr load exception
29185 * @param {Roo.bootstrap.DocumentManager} this
29186 * @param {XMLHttpRequest} xhr
29188 "afterupload" : true,
29191 * prepare the form data
29192 * @param {Roo.bootstrap.DocumentManager} this
29193 * @param {Object} formData
29198 * Fire when remove the file
29199 * @param {Roo.bootstrap.DocumentManager} this
29200 * @param {Object} file
29205 * Fire after refresh the file
29206 * @param {Roo.bootstrap.DocumentManager} this
29211 * Fire after click the image
29212 * @param {Roo.bootstrap.DocumentManager} this
29213 * @param {Object} file
29218 * Fire when upload a image and editable set to true
29219 * @param {Roo.bootstrap.DocumentManager} this
29220 * @param {Object} file
29224 * @event beforeselectfile
29225 * Fire before select file
29226 * @param {Roo.bootstrap.DocumentManager} this
29228 "beforeselectfile" : true,
29231 * Fire before process file
29232 * @param {Roo.bootstrap.DocumentManager} this
29233 * @param {Object} file
29237 * @event previewrendered
29238 * Fire when preview rendered
29239 * @param {Roo.bootstrap.DocumentManager} this
29240 * @param {Object} file
29242 "previewrendered" : true,
29245 "previewResize" : true
29250 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
29259 paramName : 'imageUpload',
29260 toolTipName : 'filename',
29263 labelAlign : 'left',
29273 getAutoCreate : function()
29275 var managerWidget = {
29277 cls : 'roo-document-manager',
29281 cls : 'roo-document-manager-selector',
29286 cls : 'roo-document-manager-uploader',
29290 cls : 'roo-document-manager-upload-btn',
29291 html : '<i class="fa fa-plus"></i>'
29302 cls : 'column col-md-12',
29307 if(this.fieldLabel.length){
29312 cls : 'column col-md-12',
29313 html : this.fieldLabel
29317 cls : 'column col-md-12',
29322 if(this.labelAlign == 'left'){
29327 html : this.fieldLabel
29336 if(this.labelWidth > 12){
29337 content[0].style = "width: " + this.labelWidth + 'px';
29340 if(this.labelWidth < 13 && this.labelmd == 0){
29341 this.labelmd = this.labelWidth;
29344 if(this.labellg > 0){
29345 content[0].cls += ' col-lg-' + this.labellg;
29346 content[1].cls += ' col-lg-' + (12 - this.labellg);
29349 if(this.labelmd > 0){
29350 content[0].cls += ' col-md-' + this.labelmd;
29351 content[1].cls += ' col-md-' + (12 - this.labelmd);
29354 if(this.labelsm > 0){
29355 content[0].cls += ' col-sm-' + this.labelsm;
29356 content[1].cls += ' col-sm-' + (12 - this.labelsm);
29359 if(this.labelxs > 0){
29360 content[0].cls += ' col-xs-' + this.labelxs;
29361 content[1].cls += ' col-xs-' + (12 - this.labelxs);
29369 cls : 'row clearfix',
29377 initEvents : function()
29379 this.managerEl = this.el.select('.roo-document-manager', true).first();
29380 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29382 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
29383 this.selectorEl.hide();
29386 this.selectorEl.attr('multiple', 'multiple');
29389 this.selectorEl.on('change', this.onFileSelected, this);
29391 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
29392 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29394 this.uploader.on('click', this.onUploaderClick, this);
29396 this.renderProgressDialog();
29400 window.addEventListener("resize", function() { _this.refresh(); } );
29402 this.fireEvent('initial', this);
29405 renderProgressDialog : function()
29409 this.progressDialog = new Roo.bootstrap.Modal({
29410 cls : 'roo-document-manager-progress-dialog',
29411 allow_close : false,
29422 btnclick : function() {
29423 _this.uploadCancel();
29429 this.progressDialog.render(Roo.get(document.body));
29431 this.progress = new Roo.bootstrap.Progress({
29432 cls : 'roo-document-manager-progress',
29437 this.progress.render(this.progressDialog.getChildContainer());
29439 this.progressBar = new Roo.bootstrap.ProgressBar({
29440 cls : 'roo-document-manager-progress-bar',
29443 aria_valuemax : 12,
29447 this.progressBar.render(this.progress.getChildContainer());
29450 onUploaderClick : function(e)
29452 e.preventDefault();
29454 if(this.fireEvent('beforeselectfile', this) != false){
29455 this.selectorEl.dom.click();
29460 onFileSelected : function(e)
29462 e.preventDefault();
29464 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
29468 Roo.each(this.selectorEl.dom.files, function(file){
29469 if(this.fireEvent('inspect', this, file) != false){
29470 this.files.push(file);
29480 this.selectorEl.dom.value = '';
29482 if(!this.files || !this.files.length){
29486 if(this.boxes > 0 && this.files.length > this.boxes){
29487 this.files = this.files.slice(0, this.boxes);
29490 this.uploader.show();
29492 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29493 this.uploader.hide();
29502 Roo.each(this.files, function(file){
29504 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29505 var f = this.renderPreview(file);
29510 if(file.type.indexOf('image') != -1){
29511 this.delegates.push(
29513 _this.process(file);
29514 }).createDelegate(this)
29522 _this.process(file);
29523 }).createDelegate(this)
29528 this.files = files;
29530 this.delegates = this.delegates.concat(docs);
29532 if(!this.delegates.length){
29537 this.progressBar.aria_valuemax = this.delegates.length;
29544 arrange : function()
29546 if(!this.delegates.length){
29547 this.progressDialog.hide();
29552 var delegate = this.delegates.shift();
29554 this.progressDialog.show();
29556 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
29558 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
29563 refresh : function()
29565 this.uploader.show();
29567 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29568 this.uploader.hide();
29571 Roo.isTouch ? this.closable(false) : this.closable(true);
29573 this.fireEvent('refresh', this);
29576 onRemove : function(e, el, o)
29578 e.preventDefault();
29580 this.fireEvent('remove', this, o);
29584 remove : function(o)
29588 Roo.each(this.files, function(file){
29589 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
29598 this.files = files;
29605 Roo.each(this.files, function(file){
29610 file.target.remove();
29619 onClick : function(e, el, o)
29621 e.preventDefault();
29623 this.fireEvent('click', this, o);
29627 closable : function(closable)
29629 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
29631 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29643 xhrOnLoad : function(xhr)
29645 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29649 if (xhr.readyState !== 4) {
29651 this.fireEvent('exception', this, xhr);
29655 var response = Roo.decode(xhr.responseText);
29657 if(!response.success){
29659 this.fireEvent('exception', this, xhr);
29663 var file = this.renderPreview(response.data);
29665 this.files.push(file);
29669 this.fireEvent('afterupload', this, xhr);
29673 xhrOnError : function(xhr)
29675 Roo.log('xhr on error');
29677 var response = Roo.decode(xhr.responseText);
29684 process : function(file)
29686 if(this.fireEvent('process', this, file) !== false){
29687 if(this.editable && file.type.indexOf('image') != -1){
29688 this.fireEvent('edit', this, file);
29692 this.uploadStart(file, false);
29699 uploadStart : function(file, crop)
29701 this.xhr = new XMLHttpRequest();
29703 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29708 file.xhr = this.xhr;
29710 this.managerEl.createChild({
29712 cls : 'roo-document-manager-loading',
29716 tooltip : file.name,
29717 cls : 'roo-document-manager-thumb',
29718 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29724 this.xhr.open(this.method, this.url, true);
29727 "Accept": "application/json",
29728 "Cache-Control": "no-cache",
29729 "X-Requested-With": "XMLHttpRequest"
29732 for (var headerName in headers) {
29733 var headerValue = headers[headerName];
29735 this.xhr.setRequestHeader(headerName, headerValue);
29741 this.xhr.onload = function()
29743 _this.xhrOnLoad(_this.xhr);
29746 this.xhr.onerror = function()
29748 _this.xhrOnError(_this.xhr);
29751 var formData = new FormData();
29753 formData.append('returnHTML', 'NO');
29756 formData.append('crop', crop);
29759 formData.append(this.paramName, file, file.name);
29766 if(this.fireEvent('prepare', this, formData, options) != false){
29768 if(options.manually){
29772 this.xhr.send(formData);
29776 this.uploadCancel();
29779 uploadCancel : function()
29785 this.delegates = [];
29787 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29794 renderPreview : function(file)
29796 if(typeof(file.target) != 'undefined' && file.target){
29800 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
29802 var previewEl = this.managerEl.createChild({
29804 cls : 'roo-document-manager-preview',
29808 tooltip : file[this.toolTipName],
29809 cls : 'roo-document-manager-thumb',
29810 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
29815 html : '<i class="fa fa-times-circle"></i>'
29820 var close = previewEl.select('button.close', true).first();
29822 close.on('click', this.onRemove, this, file);
29824 file.target = previewEl;
29826 var image = previewEl.select('img', true).first();
29830 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
29832 image.on('click', this.onClick, this, file);
29834 this.fireEvent('previewrendered', this, file);
29840 onPreviewLoad : function(file, image)
29842 if(typeof(file.target) == 'undefined' || !file.target){
29846 var width = image.dom.naturalWidth || image.dom.width;
29847 var height = image.dom.naturalHeight || image.dom.height;
29849 if(!this.previewResize) {
29853 if(width > height){
29854 file.target.addClass('wide');
29858 file.target.addClass('tall');
29863 uploadFromSource : function(file, crop)
29865 this.xhr = new XMLHttpRequest();
29867 this.managerEl.createChild({
29869 cls : 'roo-document-manager-loading',
29873 tooltip : file.name,
29874 cls : 'roo-document-manager-thumb',
29875 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29881 this.xhr.open(this.method, this.url, true);
29884 "Accept": "application/json",
29885 "Cache-Control": "no-cache",
29886 "X-Requested-With": "XMLHttpRequest"
29889 for (var headerName in headers) {
29890 var headerValue = headers[headerName];
29892 this.xhr.setRequestHeader(headerName, headerValue);
29898 this.xhr.onload = function()
29900 _this.xhrOnLoad(_this.xhr);
29903 this.xhr.onerror = function()
29905 _this.xhrOnError(_this.xhr);
29908 var formData = new FormData();
29910 formData.append('returnHTML', 'NO');
29912 formData.append('crop', crop);
29914 if(typeof(file.filename) != 'undefined'){
29915 formData.append('filename', file.filename);
29918 if(typeof(file.mimetype) != 'undefined'){
29919 formData.append('mimetype', file.mimetype);
29924 if(this.fireEvent('prepare', this, formData) != false){
29925 this.xhr.send(formData);
29935 * @class Roo.bootstrap.DocumentViewer
29936 * @extends Roo.bootstrap.Component
29937 * Bootstrap DocumentViewer class
29938 * @cfg {Boolean} showDownload (true|false) show download button (default true)
29939 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
29942 * Create a new DocumentViewer
29943 * @param {Object} config The config object
29946 Roo.bootstrap.DocumentViewer = function(config){
29947 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
29952 * Fire after initEvent
29953 * @param {Roo.bootstrap.DocumentViewer} this
29959 * @param {Roo.bootstrap.DocumentViewer} this
29964 * Fire after download button
29965 * @param {Roo.bootstrap.DocumentViewer} this
29970 * Fire after trash button
29971 * @param {Roo.bootstrap.DocumentViewer} this
29978 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
29980 showDownload : true,
29984 getAutoCreate : function()
29988 cls : 'roo-document-viewer',
29992 cls : 'roo-document-viewer-body',
29996 cls : 'roo-document-viewer-thumb',
30000 cls : 'roo-document-viewer-image'
30008 cls : 'roo-document-viewer-footer',
30011 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
30015 cls : 'btn-group roo-document-viewer-download',
30019 cls : 'btn btn-default',
30020 html : '<i class="fa fa-download"></i>'
30026 cls : 'btn-group roo-document-viewer-trash',
30030 cls : 'btn btn-default',
30031 html : '<i class="fa fa-trash"></i>'
30044 initEvents : function()
30046 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
30047 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
30049 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
30050 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
30052 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
30053 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
30055 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
30056 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
30058 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
30059 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
30061 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
30062 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
30064 this.bodyEl.on('click', this.onClick, this);
30065 this.downloadBtn.on('click', this.onDownload, this);
30066 this.trashBtn.on('click', this.onTrash, this);
30068 this.downloadBtn.hide();
30069 this.trashBtn.hide();
30071 if(this.showDownload){
30072 this.downloadBtn.show();
30075 if(this.showTrash){
30076 this.trashBtn.show();
30079 if(!this.showDownload && !this.showTrash) {
30080 this.footerEl.hide();
30085 initial : function()
30087 this.fireEvent('initial', this);
30091 onClick : function(e)
30093 e.preventDefault();
30095 this.fireEvent('click', this);
30098 onDownload : function(e)
30100 e.preventDefault();
30102 this.fireEvent('download', this);
30105 onTrash : function(e)
30107 e.preventDefault();
30109 this.fireEvent('trash', this);
30121 * @class Roo.bootstrap.NavProgressBar
30122 * @extends Roo.bootstrap.Component
30123 * Bootstrap NavProgressBar class
30126 * Create a new nav progress bar
30127 * @param {Object} config The config object
30130 Roo.bootstrap.NavProgressBar = function(config){
30131 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
30133 this.bullets = this.bullets || [];
30135 // Roo.bootstrap.NavProgressBar.register(this);
30139 * Fires when the active item changes
30140 * @param {Roo.bootstrap.NavProgressBar} this
30141 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
30142 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
30149 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
30154 getAutoCreate : function()
30156 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
30160 cls : 'roo-navigation-bar-group',
30164 cls : 'roo-navigation-top-bar'
30168 cls : 'roo-navigation-bullets-bar',
30172 cls : 'roo-navigation-bar'
30179 cls : 'roo-navigation-bottom-bar'
30189 initEvents: function()
30194 onRender : function(ct, position)
30196 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30198 if(this.bullets.length){
30199 Roo.each(this.bullets, function(b){
30208 addItem : function(cfg)
30210 var item = new Roo.bootstrap.NavProgressItem(cfg);
30212 item.parentId = this.id;
30213 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
30216 var top = new Roo.bootstrap.Element({
30218 cls : 'roo-navigation-bar-text'
30221 var bottom = new Roo.bootstrap.Element({
30223 cls : 'roo-navigation-bar-text'
30226 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
30227 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
30229 var topText = new Roo.bootstrap.Element({
30231 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
30234 var bottomText = new Roo.bootstrap.Element({
30236 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
30239 topText.onRender(top.el, null);
30240 bottomText.onRender(bottom.el, null);
30243 item.bottomEl = bottom;
30246 this.barItems.push(item);
30251 getActive : function()
30253 var active = false;
30255 Roo.each(this.barItems, function(v){
30257 if (!v.isActive()) {
30269 setActiveItem : function(item)
30273 Roo.each(this.barItems, function(v){
30274 if (v.rid == item.rid) {
30278 if (v.isActive()) {
30279 v.setActive(false);
30284 item.setActive(true);
30286 this.fireEvent('changed', this, item, prev);
30289 getBarItem: function(rid)
30293 Roo.each(this.barItems, function(e) {
30294 if (e.rid != rid) {
30305 indexOfItem : function(item)
30309 Roo.each(this.barItems, function(v, i){
30311 if (v.rid != item.rid) {
30322 setActiveNext : function()
30324 var i = this.indexOfItem(this.getActive());
30326 if (i > this.barItems.length) {
30330 this.setActiveItem(this.barItems[i+1]);
30333 setActivePrev : function()
30335 var i = this.indexOfItem(this.getActive());
30341 this.setActiveItem(this.barItems[i-1]);
30344 format : function()
30346 if(!this.barItems.length){
30350 var width = 100 / this.barItems.length;
30352 Roo.each(this.barItems, function(i){
30353 i.el.setStyle('width', width + '%');
30354 i.topEl.el.setStyle('width', width + '%');
30355 i.bottomEl.el.setStyle('width', width + '%');
30364 * Nav Progress Item
30369 * @class Roo.bootstrap.NavProgressItem
30370 * @extends Roo.bootstrap.Component
30371 * Bootstrap NavProgressItem class
30372 * @cfg {String} rid the reference id
30373 * @cfg {Boolean} active (true|false) Is item active default false
30374 * @cfg {Boolean} disabled (true|false) Is item active default false
30375 * @cfg {String} html
30376 * @cfg {String} position (top|bottom) text position default bottom
30377 * @cfg {String} icon show icon instead of number
30380 * Create a new NavProgressItem
30381 * @param {Object} config The config object
30383 Roo.bootstrap.NavProgressItem = function(config){
30384 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
30389 * The raw click event for the entire grid.
30390 * @param {Roo.bootstrap.NavProgressItem} this
30391 * @param {Roo.EventObject} e
30398 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
30404 position : 'bottom',
30407 getAutoCreate : function()
30409 var iconCls = 'roo-navigation-bar-item-icon';
30411 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
30415 cls: 'roo-navigation-bar-item',
30425 cfg.cls += ' active';
30428 cfg.cls += ' disabled';
30434 disable : function()
30436 this.setDisabled(true);
30439 enable : function()
30441 this.setDisabled(false);
30444 initEvents: function()
30446 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
30448 this.iconEl.on('click', this.onClick, this);
30451 onClick : function(e)
30453 e.preventDefault();
30459 if(this.fireEvent('click', this, e) === false){
30463 this.parent().setActiveItem(this);
30466 isActive: function ()
30468 return this.active;
30471 setActive : function(state)
30473 if(this.active == state){
30477 this.active = state;
30480 this.el.addClass('active');
30484 this.el.removeClass('active');
30489 setDisabled : function(state)
30491 if(this.disabled == state){
30495 this.disabled = state;
30498 this.el.addClass('disabled');
30502 this.el.removeClass('disabled');
30505 tooltipEl : function()
30507 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
30520 * @class Roo.bootstrap.FieldLabel
30521 * @extends Roo.bootstrap.Component
30522 * Bootstrap FieldLabel class
30523 * @cfg {String} html contents of the element
30524 * @cfg {String} tag tag of the element default label
30525 * @cfg {String} cls class of the element
30526 * @cfg {String} target label target
30527 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
30528 * @cfg {String} invalidClass DEPRICATED - BS4 uses is-invalid
30529 * @cfg {String} validClass DEPRICATED - BS4 uses is-valid
30530 * @cfg {String} iconTooltip default "This field is required"
30531 * @cfg {String} indicatorpos (left|right) default left
30534 * Create a new FieldLabel
30535 * @param {Object} config The config object
30538 Roo.bootstrap.FieldLabel = function(config){
30539 Roo.bootstrap.Element.superclass.constructor.call(this, config);
30544 * Fires after the field has been marked as invalid.
30545 * @param {Roo.form.FieldLabel} this
30546 * @param {String} msg The validation message
30551 * Fires after the field has been validated with no errors.
30552 * @param {Roo.form.FieldLabel} this
30558 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
30565 invalidClass : 'has-warning',
30566 validClass : 'has-success',
30567 iconTooltip : 'This field is required',
30568 indicatorpos : 'left',
30570 getAutoCreate : function(){
30573 if (!this.allowBlank) {
30579 cls : 'roo-bootstrap-field-label ' + this.cls,
30584 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star ' + cls,
30585 tooltip : this.iconTooltip
30594 if(this.indicatorpos == 'right'){
30597 cls : 'roo-bootstrap-field-label ' + this.cls,
30606 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star '+ cls,
30607 tooltip : this.iconTooltip
30616 initEvents: function()
30618 Roo.bootstrap.Element.superclass.initEvents.call(this);
30620 this.indicator = this.indicatorEl();
30622 if(this.indicator){
30623 this.indicator.removeClass('visible');
30624 this.indicator.addClass('invisible');
30627 Roo.bootstrap.FieldLabel.register(this);
30630 indicatorEl : function()
30632 var indicator = this.el.select('i.roo-required-indicator',true).first();
30643 * Mark this field as valid
30645 markValid : function()
30647 if(this.indicator){
30648 this.indicator.removeClass('visible');
30649 this.indicator.addClass('invisible');
30651 if (Roo.bootstrap.version == 3) {
30652 this.el.removeClass(this.invalidClass);
30653 this.el.addClass(this.validClass);
30655 this.el.removeClass('is-invalid');
30656 this.el.addClass('is-valid');
30660 this.fireEvent('valid', this);
30664 * Mark this field as invalid
30665 * @param {String} msg The validation message
30667 markInvalid : function(msg)
30669 if(this.indicator){
30670 this.indicator.removeClass('invisible');
30671 this.indicator.addClass('visible');
30673 if (Roo.bootstrap.version == 3) {
30674 this.el.removeClass(this.validClass);
30675 this.el.addClass(this.invalidClass);
30677 this.el.removeClass('is-valid');
30678 this.el.addClass('is-invalid');
30682 this.fireEvent('invalid', this, msg);
30688 Roo.apply(Roo.bootstrap.FieldLabel, {
30693 * register a FieldLabel Group
30694 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
30696 register : function(label)
30698 if(this.groups.hasOwnProperty(label.target)){
30702 this.groups[label.target] = label;
30706 * fetch a FieldLabel Group based on the target
30707 * @param {string} target
30708 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
30710 get: function(target) {
30711 if (typeof(this.groups[target]) == 'undefined') {
30715 return this.groups[target] ;
30724 * page DateSplitField.
30730 * @class Roo.bootstrap.DateSplitField
30731 * @extends Roo.bootstrap.Component
30732 * Bootstrap DateSplitField class
30733 * @cfg {string} fieldLabel - the label associated
30734 * @cfg {Number} labelWidth set the width of label (0-12)
30735 * @cfg {String} labelAlign (top|left)
30736 * @cfg {Boolean} dayAllowBlank (true|false) default false
30737 * @cfg {Boolean} monthAllowBlank (true|false) default false
30738 * @cfg {Boolean} yearAllowBlank (true|false) default false
30739 * @cfg {string} dayPlaceholder
30740 * @cfg {string} monthPlaceholder
30741 * @cfg {string} yearPlaceholder
30742 * @cfg {string} dayFormat default 'd'
30743 * @cfg {string} monthFormat default 'm'
30744 * @cfg {string} yearFormat default 'Y'
30745 * @cfg {Number} labellg set the width of label (1-12)
30746 * @cfg {Number} labelmd set the width of label (1-12)
30747 * @cfg {Number} labelsm set the width of label (1-12)
30748 * @cfg {Number} labelxs set the width of label (1-12)
30752 * Create a new DateSplitField
30753 * @param {Object} config The config object
30756 Roo.bootstrap.DateSplitField = function(config){
30757 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
30763 * getting the data of years
30764 * @param {Roo.bootstrap.DateSplitField} this
30765 * @param {Object} years
30770 * getting the data of days
30771 * @param {Roo.bootstrap.DateSplitField} this
30772 * @param {Object} days
30777 * Fires after the field has been marked as invalid.
30778 * @param {Roo.form.Field} this
30779 * @param {String} msg The validation message
30784 * Fires after the field has been validated with no errors.
30785 * @param {Roo.form.Field} this
30791 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
30794 labelAlign : 'top',
30796 dayAllowBlank : false,
30797 monthAllowBlank : false,
30798 yearAllowBlank : false,
30799 dayPlaceholder : '',
30800 monthPlaceholder : '',
30801 yearPlaceholder : '',
30805 isFormField : true,
30811 getAutoCreate : function()
30815 cls : 'row roo-date-split-field-group',
30820 cls : 'form-hidden-field roo-date-split-field-group-value',
30826 var labelCls = 'col-md-12';
30827 var contentCls = 'col-md-4';
30829 if(this.fieldLabel){
30833 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
30837 html : this.fieldLabel
30842 if(this.labelAlign == 'left'){
30844 if(this.labelWidth > 12){
30845 label.style = "width: " + this.labelWidth + 'px';
30848 if(this.labelWidth < 13 && this.labelmd == 0){
30849 this.labelmd = this.labelWidth;
30852 if(this.labellg > 0){
30853 labelCls = ' col-lg-' + this.labellg;
30854 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
30857 if(this.labelmd > 0){
30858 labelCls = ' col-md-' + this.labelmd;
30859 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
30862 if(this.labelsm > 0){
30863 labelCls = ' col-sm-' + this.labelsm;
30864 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
30867 if(this.labelxs > 0){
30868 labelCls = ' col-xs-' + this.labelxs;
30869 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
30873 label.cls += ' ' + labelCls;
30875 cfg.cn.push(label);
30878 Roo.each(['day', 'month', 'year'], function(t){
30881 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
30888 inputEl: function ()
30890 return this.el.select('.roo-date-split-field-group-value', true).first();
30893 onRender : function(ct, position)
30897 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30899 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
30901 this.dayField = new Roo.bootstrap.ComboBox({
30902 allowBlank : this.dayAllowBlank,
30903 alwaysQuery : true,
30904 displayField : 'value',
30907 forceSelection : true,
30909 placeholder : this.dayPlaceholder,
30910 selectOnFocus : true,
30911 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30912 triggerAction : 'all',
30914 valueField : 'value',
30915 store : new Roo.data.SimpleStore({
30916 data : (function() {
30918 _this.fireEvent('days', _this, days);
30921 fields : [ 'value' ]
30924 select : function (_self, record, index)
30926 _this.setValue(_this.getValue());
30931 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
30933 this.monthField = new Roo.bootstrap.MonthField({
30934 after : '<i class=\"fa fa-calendar\"></i>',
30935 allowBlank : this.monthAllowBlank,
30936 placeholder : this.monthPlaceholder,
30939 render : function (_self)
30941 this.el.select('span.input-group-addon', true).first().on('click', function(e){
30942 e.preventDefault();
30946 select : function (_self, oldvalue, newvalue)
30948 _this.setValue(_this.getValue());
30953 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
30955 this.yearField = new Roo.bootstrap.ComboBox({
30956 allowBlank : this.yearAllowBlank,
30957 alwaysQuery : true,
30958 displayField : 'value',
30961 forceSelection : true,
30963 placeholder : this.yearPlaceholder,
30964 selectOnFocus : true,
30965 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30966 triggerAction : 'all',
30968 valueField : 'value',
30969 store : new Roo.data.SimpleStore({
30970 data : (function() {
30972 _this.fireEvent('years', _this, years);
30975 fields : [ 'value' ]
30978 select : function (_self, record, index)
30980 _this.setValue(_this.getValue());
30985 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
30988 setValue : function(v, format)
30990 this.inputEl.dom.value = v;
30992 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
30994 var d = Date.parseDate(v, f);
31001 this.setDay(d.format(this.dayFormat));
31002 this.setMonth(d.format(this.monthFormat));
31003 this.setYear(d.format(this.yearFormat));
31010 setDay : function(v)
31012 this.dayField.setValue(v);
31013 this.inputEl.dom.value = this.getValue();
31018 setMonth : function(v)
31020 this.monthField.setValue(v, true);
31021 this.inputEl.dom.value = this.getValue();
31026 setYear : function(v)
31028 this.yearField.setValue(v);
31029 this.inputEl.dom.value = this.getValue();
31034 getDay : function()
31036 return this.dayField.getValue();
31039 getMonth : function()
31041 return this.monthField.getValue();
31044 getYear : function()
31046 return this.yearField.getValue();
31049 getValue : function()
31051 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
31053 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
31063 this.inputEl.dom.value = '';
31068 validate : function()
31070 var d = this.dayField.validate();
31071 var m = this.monthField.validate();
31072 var y = this.yearField.validate();
31077 (!this.dayAllowBlank && !d) ||
31078 (!this.monthAllowBlank && !m) ||
31079 (!this.yearAllowBlank && !y)
31084 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
31093 this.markInvalid();
31098 markValid : function()
31101 var label = this.el.select('label', true).first();
31102 var icon = this.el.select('i.fa-star', true).first();
31108 this.fireEvent('valid', this);
31112 * Mark this field as invalid
31113 * @param {String} msg The validation message
31115 markInvalid : function(msg)
31118 var label = this.el.select('label', true).first();
31119 var icon = this.el.select('i.fa-star', true).first();
31121 if(label && !icon){
31122 this.el.select('.roo-date-split-field-label', true).createChild({
31124 cls : 'text-danger fa fa-lg fa-star',
31125 tooltip : 'This field is required',
31126 style : 'margin-right:5px;'
31130 this.fireEvent('invalid', this, msg);
31133 clearInvalid : function()
31135 var label = this.el.select('label', true).first();
31136 var icon = this.el.select('i.fa-star', true).first();
31142 this.fireEvent('valid', this);
31145 getName: function()
31155 * http://masonry.desandro.com
31157 * The idea is to render all the bricks based on vertical width...
31159 * The original code extends 'outlayer' - we might need to use that....
31165 * @class Roo.bootstrap.LayoutMasonry
31166 * @extends Roo.bootstrap.Component
31167 * Bootstrap Layout Masonry class
31170 * Create a new Element
31171 * @param {Object} config The config object
31174 Roo.bootstrap.LayoutMasonry = function(config){
31176 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
31180 Roo.bootstrap.LayoutMasonry.register(this);
31186 * Fire after layout the items
31187 * @param {Roo.bootstrap.LayoutMasonry} this
31188 * @param {Roo.EventObject} e
31195 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
31198 * @cfg {Boolean} isLayoutInstant = no animation?
31200 isLayoutInstant : false, // needed?
31203 * @cfg {Number} boxWidth width of the columns
31208 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
31213 * @cfg {Number} padWidth padding below box..
31218 * @cfg {Number} gutter gutter width..
31223 * @cfg {Number} maxCols maximum number of columns
31229 * @cfg {Boolean} isAutoInitial defalut true
31231 isAutoInitial : true,
31236 * @cfg {Boolean} isHorizontal defalut false
31238 isHorizontal : false,
31240 currentSize : null,
31246 bricks: null, //CompositeElement
31250 _isLayoutInited : false,
31252 // isAlternative : false, // only use for vertical layout...
31255 * @cfg {Number} alternativePadWidth padding below box..
31257 alternativePadWidth : 50,
31259 selectedBrick : [],
31261 getAutoCreate : function(){
31263 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
31267 cls: 'blog-masonary-wrapper ' + this.cls,
31269 cls : 'mas-boxes masonary'
31276 getChildContainer: function( )
31278 if (this.boxesEl) {
31279 return this.boxesEl;
31282 this.boxesEl = this.el.select('.mas-boxes').first();
31284 return this.boxesEl;
31288 initEvents : function()
31292 if(this.isAutoInitial){
31293 Roo.log('hook children rendered');
31294 this.on('childrenrendered', function() {
31295 Roo.log('children rendered');
31301 initial : function()
31303 this.selectedBrick = [];
31305 this.currentSize = this.el.getBox(true);
31307 Roo.EventManager.onWindowResize(this.resize, this);
31309 if(!this.isAutoInitial){
31317 //this.layout.defer(500,this);
31321 resize : function()
31323 var cs = this.el.getBox(true);
31326 this.currentSize.width == cs.width &&
31327 this.currentSize.x == cs.x &&
31328 this.currentSize.height == cs.height &&
31329 this.currentSize.y == cs.y
31331 Roo.log("no change in with or X or Y");
31335 this.currentSize = cs;
31341 layout : function()
31343 this._resetLayout();
31345 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
31347 this.layoutItems( isInstant );
31349 this._isLayoutInited = true;
31351 this.fireEvent('layout', this);
31355 _resetLayout : function()
31357 if(this.isHorizontal){
31358 this.horizontalMeasureColumns();
31362 this.verticalMeasureColumns();
31366 verticalMeasureColumns : function()
31368 this.getContainerWidth();
31370 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31371 // this.colWidth = Math.floor(this.containerWidth * 0.8);
31375 var boxWidth = this.boxWidth + this.padWidth;
31377 if(this.containerWidth < this.boxWidth){
31378 boxWidth = this.containerWidth
31381 var containerWidth = this.containerWidth;
31383 var cols = Math.floor(containerWidth / boxWidth);
31385 this.cols = Math.max( cols, 1 );
31387 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
31389 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
31391 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
31393 this.colWidth = boxWidth + avail - this.padWidth;
31395 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
31396 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
31399 horizontalMeasureColumns : function()
31401 this.getContainerWidth();
31403 var boxWidth = this.boxWidth;
31405 if(this.containerWidth < boxWidth){
31406 boxWidth = this.containerWidth;
31409 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
31411 this.el.setHeight(boxWidth);
31415 getContainerWidth : function()
31417 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
31420 layoutItems : function( isInstant )
31422 Roo.log(this.bricks);
31424 var items = Roo.apply([], this.bricks);
31426 if(this.isHorizontal){
31427 this._horizontalLayoutItems( items , isInstant );
31431 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31432 // this._verticalAlternativeLayoutItems( items , isInstant );
31436 this._verticalLayoutItems( items , isInstant );
31440 _verticalLayoutItems : function ( items , isInstant)
31442 if ( !items || !items.length ) {
31447 ['xs', 'xs', 'xs', 'tall'],
31448 ['xs', 'xs', 'tall'],
31449 ['xs', 'xs', 'sm'],
31450 ['xs', 'xs', 'xs'],
31456 ['sm', 'xs', 'xs'],
31460 ['tall', 'xs', 'xs', 'xs'],
31461 ['tall', 'xs', 'xs'],
31473 Roo.each(items, function(item, k){
31475 switch (item.size) {
31476 // these layouts take up a full box,
31487 boxes.push([item]);
31510 var filterPattern = function(box, length)
31518 var pattern = box.slice(0, length);
31522 Roo.each(pattern, function(i){
31523 format.push(i.size);
31526 Roo.each(standard, function(s){
31528 if(String(s) != String(format)){
31537 if(!match && length == 1){
31542 filterPattern(box, length - 1);
31546 queue.push(pattern);
31548 box = box.slice(length, box.length);
31550 filterPattern(box, 4);
31556 Roo.each(boxes, function(box, k){
31562 if(box.length == 1){
31567 filterPattern(box, 4);
31571 this._processVerticalLayoutQueue( queue, isInstant );
31575 // _verticalAlternativeLayoutItems : function( items , isInstant )
31577 // if ( !items || !items.length ) {
31581 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
31585 _horizontalLayoutItems : function ( items , isInstant)
31587 if ( !items || !items.length || items.length < 3) {
31593 var eItems = items.slice(0, 3);
31595 items = items.slice(3, items.length);
31598 ['xs', 'xs', 'xs', 'wide'],
31599 ['xs', 'xs', 'wide'],
31600 ['xs', 'xs', 'sm'],
31601 ['xs', 'xs', 'xs'],
31607 ['sm', 'xs', 'xs'],
31611 ['wide', 'xs', 'xs', 'xs'],
31612 ['wide', 'xs', 'xs'],
31625 Roo.each(items, function(item, k){
31627 switch (item.size) {
31638 boxes.push([item]);
31662 var filterPattern = function(box, length)
31670 var pattern = box.slice(0, length);
31674 Roo.each(pattern, function(i){
31675 format.push(i.size);
31678 Roo.each(standard, function(s){
31680 if(String(s) != String(format)){
31689 if(!match && length == 1){
31694 filterPattern(box, length - 1);
31698 queue.push(pattern);
31700 box = box.slice(length, box.length);
31702 filterPattern(box, 4);
31708 Roo.each(boxes, function(box, k){
31714 if(box.length == 1){
31719 filterPattern(box, 4);
31726 var pos = this.el.getBox(true);
31730 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31732 var hit_end = false;
31734 Roo.each(queue, function(box){
31738 Roo.each(box, function(b){
31740 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31750 Roo.each(box, function(b){
31752 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31755 mx = Math.max(mx, b.x);
31759 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
31763 Roo.each(box, function(b){
31765 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31779 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
31782 /** Sets position of item in DOM
31783 * @param {Element} item
31784 * @param {Number} x - horizontal position
31785 * @param {Number} y - vertical position
31786 * @param {Boolean} isInstant - disables transitions
31788 _processVerticalLayoutQueue : function( queue, isInstant )
31790 var pos = this.el.getBox(true);
31795 for (var i = 0; i < this.cols; i++){
31799 Roo.each(queue, function(box, k){
31801 var col = k % this.cols;
31803 Roo.each(box, function(b,kk){
31805 b.el.position('absolute');
31807 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31808 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31810 if(b.size == 'md-left' || b.size == 'md-right'){
31811 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31812 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31815 b.el.setWidth(width);
31816 b.el.setHeight(height);
31818 b.el.select('iframe',true).setSize(width,height);
31822 for (var i = 0; i < this.cols; i++){
31824 if(maxY[i] < maxY[col]){
31829 col = Math.min(col, i);
31833 x = pos.x + col * (this.colWidth + this.padWidth);
31837 var positions = [];
31839 switch (box.length){
31841 positions = this.getVerticalOneBoxColPositions(x, y, box);
31844 positions = this.getVerticalTwoBoxColPositions(x, y, box);
31847 positions = this.getVerticalThreeBoxColPositions(x, y, box);
31850 positions = this.getVerticalFourBoxColPositions(x, y, box);
31856 Roo.each(box, function(b,kk){
31858 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31860 var sz = b.el.getSize();
31862 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
31870 for (var i = 0; i < this.cols; i++){
31871 mY = Math.max(mY, maxY[i]);
31874 this.el.setHeight(mY - pos.y);
31878 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
31880 // var pos = this.el.getBox(true);
31883 // var maxX = pos.right;
31885 // var maxHeight = 0;
31887 // Roo.each(items, function(item, k){
31891 // item.el.position('absolute');
31893 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
31895 // item.el.setWidth(width);
31897 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
31899 // item.el.setHeight(height);
31902 // item.el.setXY([x, y], isInstant ? false : true);
31904 // item.el.setXY([maxX - width, y], isInstant ? false : true);
31907 // y = y + height + this.alternativePadWidth;
31909 // maxHeight = maxHeight + height + this.alternativePadWidth;
31913 // this.el.setHeight(maxHeight);
31917 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
31919 var pos = this.el.getBox(true);
31924 var maxX = pos.right;
31926 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
31928 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31930 Roo.each(queue, function(box, k){
31932 Roo.each(box, function(b, kk){
31934 b.el.position('absolute');
31936 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31937 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31939 if(b.size == 'md-left' || b.size == 'md-right'){
31940 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31941 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31944 b.el.setWidth(width);
31945 b.el.setHeight(height);
31953 var positions = [];
31955 switch (box.length){
31957 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
31960 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
31963 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
31966 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
31972 Roo.each(box, function(b,kk){
31974 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31976 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
31984 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
31986 Roo.each(eItems, function(b,k){
31988 b.size = (k == 0) ? 'sm' : 'xs';
31989 b.x = (k == 0) ? 2 : 1;
31990 b.y = (k == 0) ? 2 : 1;
31992 b.el.position('absolute');
31994 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31996 b.el.setWidth(width);
31998 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
32000 b.el.setHeight(height);
32004 var positions = [];
32007 x : maxX - this.unitWidth * 2 - this.gutter,
32012 x : maxX - this.unitWidth,
32013 y : minY + (this.unitWidth + this.gutter) * 2
32017 x : maxX - this.unitWidth * 3 - this.gutter * 2,
32021 Roo.each(eItems, function(b,k){
32023 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
32029 getVerticalOneBoxColPositions : function(x, y, box)
32033 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
32035 if(box[0].size == 'md-left'){
32039 if(box[0].size == 'md-right'){
32044 x : x + (this.unitWidth + this.gutter) * rand,
32051 getVerticalTwoBoxColPositions : function(x, y, box)
32055 if(box[0].size == 'xs'){
32059 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
32063 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
32077 x : x + (this.unitWidth + this.gutter) * 2,
32078 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
32085 getVerticalThreeBoxColPositions : function(x, y, box)
32089 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
32097 x : x + (this.unitWidth + this.gutter) * 1,
32102 x : x + (this.unitWidth + this.gutter) * 2,
32110 if(box[0].size == 'xs' && box[1].size == 'xs'){
32119 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
32123 x : x + (this.unitWidth + this.gutter) * 1,
32137 x : x + (this.unitWidth + this.gutter) * 2,
32142 x : x + (this.unitWidth + this.gutter) * 2,
32143 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
32150 getVerticalFourBoxColPositions : function(x, y, box)
32154 if(box[0].size == 'xs'){
32163 y : y + (this.unitHeight + this.gutter) * 1
32168 y : y + (this.unitHeight + this.gutter) * 2
32172 x : x + (this.unitWidth + this.gutter) * 1,
32186 x : x + (this.unitWidth + this.gutter) * 2,
32191 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
32192 y : y + (this.unitHeight + this.gutter) * 1
32196 x : x + (this.unitWidth + this.gutter) * 2,
32197 y : y + (this.unitWidth + this.gutter) * 2
32204 getHorizontalOneBoxColPositions : function(maxX, minY, box)
32208 if(box[0].size == 'md-left'){
32210 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
32217 if(box[0].size == 'md-right'){
32219 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
32220 y : minY + (this.unitWidth + this.gutter) * 1
32226 var rand = Math.floor(Math.random() * (4 - box[0].y));
32229 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32230 y : minY + (this.unitWidth + this.gutter) * rand
32237 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
32241 if(box[0].size == 'xs'){
32244 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32249 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32250 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
32258 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32263 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32264 y : minY + (this.unitWidth + this.gutter) * 2
32271 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
32275 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
32278 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32283 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32284 y : minY + (this.unitWidth + this.gutter) * 1
32288 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32289 y : minY + (this.unitWidth + this.gutter) * 2
32296 if(box[0].size == 'xs' && box[1].size == 'xs'){
32299 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32304 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32309 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32310 y : minY + (this.unitWidth + this.gutter) * 1
32318 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32323 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32324 y : minY + (this.unitWidth + this.gutter) * 2
32328 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32329 y : minY + (this.unitWidth + this.gutter) * 2
32336 getHorizontalFourBoxColPositions : function(maxX, minY, box)
32340 if(box[0].size == 'xs'){
32343 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32348 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32353 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),
32358 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
32359 y : minY + (this.unitWidth + this.gutter) * 1
32367 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32372 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32373 y : minY + (this.unitWidth + this.gutter) * 2
32377 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32378 y : minY + (this.unitWidth + this.gutter) * 2
32382 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),
32383 y : minY + (this.unitWidth + this.gutter) * 2
32391 * remove a Masonry Brick
32392 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
32394 removeBrick : function(brick_id)
32400 for (var i = 0; i<this.bricks.length; i++) {
32401 if (this.bricks[i].id == brick_id) {
32402 this.bricks.splice(i,1);
32403 this.el.dom.removeChild(Roo.get(brick_id).dom);
32410 * adds a Masonry Brick
32411 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32413 addBrick : function(cfg)
32415 var cn = new Roo.bootstrap.MasonryBrick(cfg);
32416 //this.register(cn);
32417 cn.parentId = this.id;
32418 cn.render(this.el);
32423 * register a Masonry Brick
32424 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32427 register : function(brick)
32429 this.bricks.push(brick);
32430 brick.masonryId = this.id;
32434 * clear all the Masonry Brick
32436 clearAll : function()
32439 //this.getChildContainer().dom.innerHTML = "";
32440 this.el.dom.innerHTML = '';
32443 getSelected : function()
32445 if (!this.selectedBrick) {
32449 return this.selectedBrick;
32453 Roo.apply(Roo.bootstrap.LayoutMasonry, {
32457 * register a Masonry Layout
32458 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
32461 register : function(layout)
32463 this.groups[layout.id] = layout;
32466 * fetch a Masonry Layout based on the masonry layout ID
32467 * @param {string} the masonry layout to add
32468 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
32471 get: function(layout_id) {
32472 if (typeof(this.groups[layout_id]) == 'undefined') {
32475 return this.groups[layout_id] ;
32487 * http://masonry.desandro.com
32489 * The idea is to render all the bricks based on vertical width...
32491 * The original code extends 'outlayer' - we might need to use that....
32497 * @class Roo.bootstrap.LayoutMasonryAuto
32498 * @extends Roo.bootstrap.Component
32499 * Bootstrap Layout Masonry class
32502 * Create a new Element
32503 * @param {Object} config The config object
32506 Roo.bootstrap.LayoutMasonryAuto = function(config){
32507 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
32510 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
32513 * @cfg {Boolean} isFitWidth - resize the width..
32515 isFitWidth : false, // options..
32517 * @cfg {Boolean} isOriginLeft = left align?
32519 isOriginLeft : true,
32521 * @cfg {Boolean} isOriginTop = top align?
32523 isOriginTop : false,
32525 * @cfg {Boolean} isLayoutInstant = no animation?
32527 isLayoutInstant : false, // needed?
32529 * @cfg {Boolean} isResizingContainer = not sure if this is used..
32531 isResizingContainer : true,
32533 * @cfg {Number} columnWidth width of the columns
32539 * @cfg {Number} maxCols maximum number of columns
32544 * @cfg {Number} padHeight padding below box..
32550 * @cfg {Boolean} isAutoInitial defalut true
32553 isAutoInitial : true,
32559 initialColumnWidth : 0,
32560 currentSize : null,
32562 colYs : null, // array.
32569 bricks: null, //CompositeElement
32570 cols : 0, // array?
32571 // element : null, // wrapped now this.el
32572 _isLayoutInited : null,
32575 getAutoCreate : function(){
32579 cls: 'blog-masonary-wrapper ' + this.cls,
32581 cls : 'mas-boxes masonary'
32588 getChildContainer: function( )
32590 if (this.boxesEl) {
32591 return this.boxesEl;
32594 this.boxesEl = this.el.select('.mas-boxes').first();
32596 return this.boxesEl;
32600 initEvents : function()
32604 if(this.isAutoInitial){
32605 Roo.log('hook children rendered');
32606 this.on('childrenrendered', function() {
32607 Roo.log('children rendered');
32614 initial : function()
32616 this.reloadItems();
32618 this.currentSize = this.el.getBox(true);
32620 /// was window resize... - let's see if this works..
32621 Roo.EventManager.onWindowResize(this.resize, this);
32623 if(!this.isAutoInitial){
32628 this.layout.defer(500,this);
32631 reloadItems: function()
32633 this.bricks = this.el.select('.masonry-brick', true);
32635 this.bricks.each(function(b) {
32636 //Roo.log(b.getSize());
32637 if (!b.attr('originalwidth')) {
32638 b.attr('originalwidth', b.getSize().width);
32643 Roo.log(this.bricks.elements.length);
32646 resize : function()
32649 var cs = this.el.getBox(true);
32651 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
32652 Roo.log("no change in with or X");
32655 this.currentSize = cs;
32659 layout : function()
32662 this._resetLayout();
32663 //this._manageStamps();
32665 // don't animate first layout
32666 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
32667 this.layoutItems( isInstant );
32669 // flag for initalized
32670 this._isLayoutInited = true;
32673 layoutItems : function( isInstant )
32675 //var items = this._getItemsForLayout( this.items );
32676 // original code supports filtering layout items.. we just ignore it..
32678 this._layoutItems( this.bricks , isInstant );
32680 this._postLayout();
32682 _layoutItems : function ( items , isInstant)
32684 //this.fireEvent( 'layout', this, items );
32687 if ( !items || !items.elements.length ) {
32688 // no items, emit event with empty array
32693 items.each(function(item) {
32694 Roo.log("layout item");
32696 // get x/y object from method
32697 var position = this._getItemLayoutPosition( item );
32699 position.item = item;
32700 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
32701 queue.push( position );
32704 this._processLayoutQueue( queue );
32706 /** Sets position of item in DOM
32707 * @param {Element} item
32708 * @param {Number} x - horizontal position
32709 * @param {Number} y - vertical position
32710 * @param {Boolean} isInstant - disables transitions
32712 _processLayoutQueue : function( queue )
32714 for ( var i=0, len = queue.length; i < len; i++ ) {
32715 var obj = queue[i];
32716 obj.item.position('absolute');
32717 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
32723 * Any logic you want to do after each layout,
32724 * i.e. size the container
32726 _postLayout : function()
32728 this.resizeContainer();
32731 resizeContainer : function()
32733 if ( !this.isResizingContainer ) {
32736 var size = this._getContainerSize();
32738 this.el.setSize(size.width,size.height);
32739 this.boxesEl.setSize(size.width,size.height);
32745 _resetLayout : function()
32747 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
32748 this.colWidth = this.el.getWidth();
32749 //this.gutter = this.el.getWidth();
32751 this.measureColumns();
32757 this.colYs.push( 0 );
32763 measureColumns : function()
32765 this.getContainerWidth();
32766 // if columnWidth is 0, default to outerWidth of first item
32767 if ( !this.columnWidth ) {
32768 var firstItem = this.bricks.first();
32769 Roo.log(firstItem);
32770 this.columnWidth = this.containerWidth;
32771 if (firstItem && firstItem.attr('originalwidth') ) {
32772 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
32774 // columnWidth fall back to item of first element
32775 Roo.log("set column width?");
32776 this.initialColumnWidth = this.columnWidth ;
32778 // if first elem has no width, default to size of container
32783 if (this.initialColumnWidth) {
32784 this.columnWidth = this.initialColumnWidth;
32789 // column width is fixed at the top - however if container width get's smaller we should
32792 // this bit calcs how man columns..
32794 var columnWidth = this.columnWidth += this.gutter;
32796 // calculate columns
32797 var containerWidth = this.containerWidth + this.gutter;
32799 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
32800 // fix rounding errors, typically with gutters
32801 var excess = columnWidth - containerWidth % columnWidth;
32804 // if overshoot is less than a pixel, round up, otherwise floor it
32805 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
32806 cols = Math[ mathMethod ]( cols );
32807 this.cols = Math.max( cols, 1 );
32808 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
32810 // padding positioning..
32811 var totalColWidth = this.cols * this.columnWidth;
32812 var padavail = this.containerWidth - totalColWidth;
32813 // so for 2 columns - we need 3 'pads'
32815 var padNeeded = (1+this.cols) * this.padWidth;
32817 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
32819 this.columnWidth += padExtra
32820 //this.padWidth = Math.floor(padavail / ( this.cols));
32822 // adjust colum width so that padding is fixed??
32824 // we have 3 columns ... total = width * 3
32825 // we have X left over... that should be used by
32827 //if (this.expandC) {
32835 getContainerWidth : function()
32837 /* // container is parent if fit width
32838 var container = this.isFitWidth ? this.element.parentNode : this.element;
32839 // check that this.size and size are there
32840 // IE8 triggers resize on body size change, so they might not be
32842 var size = getSize( container ); //FIXME
32843 this.containerWidth = size && size.innerWidth; //FIXME
32846 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
32850 _getItemLayoutPosition : function( item ) // what is item?
32852 // we resize the item to our columnWidth..
32854 item.setWidth(this.columnWidth);
32855 item.autoBoxAdjust = false;
32857 var sz = item.getSize();
32859 // how many columns does this brick span
32860 var remainder = this.containerWidth % this.columnWidth;
32862 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
32863 // round if off by 1 pixel, otherwise use ceil
32864 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
32865 colSpan = Math.min( colSpan, this.cols );
32867 // normally this should be '1' as we dont' currently allow multi width columns..
32869 var colGroup = this._getColGroup( colSpan );
32870 // get the minimum Y value from the columns
32871 var minimumY = Math.min.apply( Math, colGroup );
32872 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32874 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
32876 // position the brick
32878 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
32879 y: this.currentSize.y + minimumY + this.padHeight
32883 // apply setHeight to necessary columns
32884 var setHeight = minimumY + sz.height + this.padHeight;
32885 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32887 var setSpan = this.cols + 1 - colGroup.length;
32888 for ( var i = 0; i < setSpan; i++ ) {
32889 this.colYs[ shortColIndex + i ] = setHeight ;
32896 * @param {Number} colSpan - number of columns the element spans
32897 * @returns {Array} colGroup
32899 _getColGroup : function( colSpan )
32901 if ( colSpan < 2 ) {
32902 // if brick spans only one column, use all the column Ys
32907 // how many different places could this brick fit horizontally
32908 var groupCount = this.cols + 1 - colSpan;
32909 // for each group potential horizontal position
32910 for ( var i = 0; i < groupCount; i++ ) {
32911 // make an array of colY values for that one group
32912 var groupColYs = this.colYs.slice( i, i + colSpan );
32913 // and get the max value of the array
32914 colGroup[i] = Math.max.apply( Math, groupColYs );
32919 _manageStamp : function( stamp )
32921 var stampSize = stamp.getSize();
32922 var offset = stamp.getBox();
32923 // get the columns that this stamp affects
32924 var firstX = this.isOriginLeft ? offset.x : offset.right;
32925 var lastX = firstX + stampSize.width;
32926 var firstCol = Math.floor( firstX / this.columnWidth );
32927 firstCol = Math.max( 0, firstCol );
32929 var lastCol = Math.floor( lastX / this.columnWidth );
32930 // lastCol should not go over if multiple of columnWidth #425
32931 lastCol -= lastX % this.columnWidth ? 0 : 1;
32932 lastCol = Math.min( this.cols - 1, lastCol );
32934 // set colYs to bottom of the stamp
32935 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
32938 for ( var i = firstCol; i <= lastCol; i++ ) {
32939 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
32944 _getContainerSize : function()
32946 this.maxY = Math.max.apply( Math, this.colYs );
32951 if ( this.isFitWidth ) {
32952 size.width = this._getContainerFitWidth();
32958 _getContainerFitWidth : function()
32960 var unusedCols = 0;
32961 // count unused columns
32964 if ( this.colYs[i] !== 0 ) {
32969 // fit container to columns that have been used
32970 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
32973 needsResizeLayout : function()
32975 var previousWidth = this.containerWidth;
32976 this.getContainerWidth();
32977 return previousWidth !== this.containerWidth;
32992 * @class Roo.bootstrap.MasonryBrick
32993 * @extends Roo.bootstrap.Component
32994 * Bootstrap MasonryBrick class
32997 * Create a new MasonryBrick
32998 * @param {Object} config The config object
33001 Roo.bootstrap.MasonryBrick = function(config){
33003 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
33005 Roo.bootstrap.MasonryBrick.register(this);
33011 * When a MasonryBrick is clcik
33012 * @param {Roo.bootstrap.MasonryBrick} this
33013 * @param {Roo.EventObject} e
33019 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
33022 * @cfg {String} title
33026 * @cfg {String} html
33030 * @cfg {String} bgimage
33034 * @cfg {String} videourl
33038 * @cfg {String} cls
33042 * @cfg {String} href
33046 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
33051 * @cfg {String} placetitle (center|bottom)
33056 * @cfg {Boolean} isFitContainer defalut true
33058 isFitContainer : true,
33061 * @cfg {Boolean} preventDefault defalut false
33063 preventDefault : false,
33066 * @cfg {Boolean} inverse defalut false
33068 maskInverse : false,
33070 getAutoCreate : function()
33072 if(!this.isFitContainer){
33073 return this.getSplitAutoCreate();
33076 var cls = 'masonry-brick masonry-brick-full';
33078 if(this.href.length){
33079 cls += ' masonry-brick-link';
33082 if(this.bgimage.length){
33083 cls += ' masonry-brick-image';
33086 if(this.maskInverse){
33087 cls += ' mask-inverse';
33090 if(!this.html.length && !this.maskInverse && !this.videourl.length){
33091 cls += ' enable-mask';
33095 cls += ' masonry-' + this.size + '-brick';
33098 if(this.placetitle.length){
33100 switch (this.placetitle) {
33102 cls += ' masonry-center-title';
33105 cls += ' masonry-bottom-title';
33112 if(!this.html.length && !this.bgimage.length){
33113 cls += ' masonry-center-title';
33116 if(!this.html.length && this.bgimage.length){
33117 cls += ' masonry-bottom-title';
33122 cls += ' ' + this.cls;
33126 tag: (this.href.length) ? 'a' : 'div',
33131 cls: 'masonry-brick-mask'
33135 cls: 'masonry-brick-paragraph',
33141 if(this.href.length){
33142 cfg.href = this.href;
33145 var cn = cfg.cn[1].cn;
33147 if(this.title.length){
33150 cls: 'masonry-brick-title',
33155 if(this.html.length){
33158 cls: 'masonry-brick-text',
33163 if (!this.title.length && !this.html.length) {
33164 cfg.cn[1].cls += ' hide';
33167 if(this.bgimage.length){
33170 cls: 'masonry-brick-image-view',
33175 if(this.videourl.length){
33176 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
33177 // youtube support only?
33180 cls: 'masonry-brick-image-view',
33183 allowfullscreen : true
33191 getSplitAutoCreate : function()
33193 var cls = 'masonry-brick masonry-brick-split';
33195 if(this.href.length){
33196 cls += ' masonry-brick-link';
33199 if(this.bgimage.length){
33200 cls += ' masonry-brick-image';
33204 cls += ' masonry-' + this.size + '-brick';
33207 switch (this.placetitle) {
33209 cls += ' masonry-center-title';
33212 cls += ' masonry-bottom-title';
33215 if(!this.bgimage.length){
33216 cls += ' masonry-center-title';
33219 if(this.bgimage.length){
33220 cls += ' masonry-bottom-title';
33226 cls += ' ' + this.cls;
33230 tag: (this.href.length) ? 'a' : 'div',
33235 cls: 'masonry-brick-split-head',
33239 cls: 'masonry-brick-paragraph',
33246 cls: 'masonry-brick-split-body',
33252 if(this.href.length){
33253 cfg.href = this.href;
33256 if(this.title.length){
33257 cfg.cn[0].cn[0].cn.push({
33259 cls: 'masonry-brick-title',
33264 if(this.html.length){
33265 cfg.cn[1].cn.push({
33267 cls: 'masonry-brick-text',
33272 if(this.bgimage.length){
33273 cfg.cn[0].cn.push({
33275 cls: 'masonry-brick-image-view',
33280 if(this.videourl.length){
33281 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
33282 // youtube support only?
33283 cfg.cn[0].cn.cn.push({
33285 cls: 'masonry-brick-image-view',
33288 allowfullscreen : true
33295 initEvents: function()
33297 switch (this.size) {
33330 this.el.on('touchstart', this.onTouchStart, this);
33331 this.el.on('touchmove', this.onTouchMove, this);
33332 this.el.on('touchend', this.onTouchEnd, this);
33333 this.el.on('contextmenu', this.onContextMenu, this);
33335 this.el.on('mouseenter' ,this.enter, this);
33336 this.el.on('mouseleave', this.leave, this);
33337 this.el.on('click', this.onClick, this);
33340 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
33341 this.parent().bricks.push(this);
33346 onClick: function(e, el)
33348 var time = this.endTimer - this.startTimer;
33349 // Roo.log(e.preventDefault());
33352 e.preventDefault();
33357 if(!this.preventDefault){
33361 e.preventDefault();
33363 if (this.activeClass != '') {
33364 this.selectBrick();
33367 this.fireEvent('click', this, e);
33370 enter: function(e, el)
33372 e.preventDefault();
33374 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
33378 if(this.bgimage.length && this.html.length){
33379 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33383 leave: function(e, el)
33385 e.preventDefault();
33387 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
33391 if(this.bgimage.length && this.html.length){
33392 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
33396 onTouchStart: function(e, el)
33398 // e.preventDefault();
33400 this.touchmoved = false;
33402 if(!this.isFitContainer){
33406 if(!this.bgimage.length || !this.html.length){
33410 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33412 this.timer = new Date().getTime();
33416 onTouchMove: function(e, el)
33418 this.touchmoved = true;
33421 onContextMenu : function(e,el)
33423 e.preventDefault();
33424 e.stopPropagation();
33428 onTouchEnd: function(e, el)
33430 // e.preventDefault();
33432 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
33439 if(!this.bgimage.length || !this.html.length){
33441 if(this.href.length){
33442 window.location.href = this.href;
33448 if(!this.isFitContainer){
33452 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
33454 window.location.href = this.href;
33457 //selection on single brick only
33458 selectBrick : function() {
33460 if (!this.parentId) {
33464 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
33465 var index = m.selectedBrick.indexOf(this.id);
33468 m.selectedBrick.splice(index,1);
33469 this.el.removeClass(this.activeClass);
33473 for(var i = 0; i < m.selectedBrick.length; i++) {
33474 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
33475 b.el.removeClass(b.activeClass);
33478 m.selectedBrick = [];
33480 m.selectedBrick.push(this.id);
33481 this.el.addClass(this.activeClass);
33485 isSelected : function(){
33486 return this.el.hasClass(this.activeClass);
33491 Roo.apply(Roo.bootstrap.MasonryBrick, {
33494 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
33496 * register a Masonry Brick
33497 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
33500 register : function(brick)
33502 //this.groups[brick.id] = brick;
33503 this.groups.add(brick.id, brick);
33506 * fetch a masonry brick based on the masonry brick ID
33507 * @param {string} the masonry brick to add
33508 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
33511 get: function(brick_id)
33513 // if (typeof(this.groups[brick_id]) == 'undefined') {
33516 // return this.groups[brick_id] ;
33518 if(this.groups.key(brick_id)) {
33519 return this.groups.key(brick_id);
33537 * @class Roo.bootstrap.Brick
33538 * @extends Roo.bootstrap.Component
33539 * Bootstrap Brick class
33542 * Create a new Brick
33543 * @param {Object} config The config object
33546 Roo.bootstrap.Brick = function(config){
33547 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
33553 * When a Brick is click
33554 * @param {Roo.bootstrap.Brick} this
33555 * @param {Roo.EventObject} e
33561 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
33564 * @cfg {String} title
33568 * @cfg {String} html
33572 * @cfg {String} bgimage
33576 * @cfg {String} cls
33580 * @cfg {String} href
33584 * @cfg {String} video
33588 * @cfg {Boolean} square
33592 getAutoCreate : function()
33594 var cls = 'roo-brick';
33596 if(this.href.length){
33597 cls += ' roo-brick-link';
33600 if(this.bgimage.length){
33601 cls += ' roo-brick-image';
33604 if(!this.html.length && !this.bgimage.length){
33605 cls += ' roo-brick-center-title';
33608 if(!this.html.length && this.bgimage.length){
33609 cls += ' roo-brick-bottom-title';
33613 cls += ' ' + this.cls;
33617 tag: (this.href.length) ? 'a' : 'div',
33622 cls: 'roo-brick-paragraph',
33628 if(this.href.length){
33629 cfg.href = this.href;
33632 var cn = cfg.cn[0].cn;
33634 if(this.title.length){
33637 cls: 'roo-brick-title',
33642 if(this.html.length){
33645 cls: 'roo-brick-text',
33652 if(this.bgimage.length){
33655 cls: 'roo-brick-image-view',
33663 initEvents: function()
33665 if(this.title.length || this.html.length){
33666 this.el.on('mouseenter' ,this.enter, this);
33667 this.el.on('mouseleave', this.leave, this);
33670 Roo.EventManager.onWindowResize(this.resize, this);
33672 if(this.bgimage.length){
33673 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
33674 this.imageEl.on('load', this.onImageLoad, this);
33681 onImageLoad : function()
33686 resize : function()
33688 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
33690 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
33692 if(this.bgimage.length){
33693 var image = this.el.select('.roo-brick-image-view', true).first();
33695 image.setWidth(paragraph.getWidth());
33698 image.setHeight(paragraph.getWidth());
33701 this.el.setHeight(image.getHeight());
33702 paragraph.setHeight(image.getHeight());
33708 enter: function(e, el)
33710 e.preventDefault();
33712 if(this.bgimage.length){
33713 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
33714 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
33718 leave: function(e, el)
33720 e.preventDefault();
33722 if(this.bgimage.length){
33723 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
33724 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
33739 * @class Roo.bootstrap.NumberField
33740 * @extends Roo.bootstrap.Input
33741 * Bootstrap NumberField class
33747 * Create a new NumberField
33748 * @param {Object} config The config object
33751 Roo.bootstrap.NumberField = function(config){
33752 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
33755 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
33758 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
33760 allowDecimals : true,
33762 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
33764 decimalSeparator : ".",
33766 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
33768 decimalPrecision : 2,
33770 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
33772 allowNegative : true,
33775 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
33779 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
33781 minValue : Number.NEGATIVE_INFINITY,
33783 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
33785 maxValue : Number.MAX_VALUE,
33787 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
33789 minText : "The minimum value for this field is {0}",
33791 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
33793 maxText : "The maximum value for this field is {0}",
33795 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
33796 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
33798 nanText : "{0} is not a valid number",
33800 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
33802 thousandsDelimiter : false,
33804 * @cfg {String} valueAlign alignment of value
33806 valueAlign : "left",
33808 getAutoCreate : function()
33810 var hiddenInput = {
33814 cls: 'hidden-number-input'
33818 hiddenInput.name = this.name;
33823 var cfg = Roo.bootstrap.NumberField.superclass.getAutoCreate.call(this);
33825 this.name = hiddenInput.name;
33827 if(cfg.cn.length > 0) {
33828 cfg.cn.push(hiddenInput);
33835 initEvents : function()
33837 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
33839 var allowed = "0123456789";
33841 if(this.allowDecimals){
33842 allowed += this.decimalSeparator;
33845 if(this.allowNegative){
33849 if(this.thousandsDelimiter) {
33853 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
33855 var keyPress = function(e){
33857 var k = e.getKey();
33859 var c = e.getCharCode();
33862 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
33863 allowed.indexOf(String.fromCharCode(c)) === -1
33869 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
33873 if(allowed.indexOf(String.fromCharCode(c)) === -1){
33878 this.el.on("keypress", keyPress, this);
33881 validateValue : function(value)
33884 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
33888 var num = this.parseValue(value);
33891 this.markInvalid(String.format(this.nanText, value));
33895 if(num < this.minValue){
33896 this.markInvalid(String.format(this.minText, this.minValue));
33900 if(num > this.maxValue){
33901 this.markInvalid(String.format(this.maxText, this.maxValue));
33908 getValue : function()
33910 var v = this.hiddenEl().getValue();
33912 return this.fixPrecision(this.parseValue(v));
33915 parseValue : function(value)
33917 if(this.thousandsDelimiter) {
33919 r = new RegExp(",", "g");
33920 value = value.replace(r, "");
33923 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
33924 return isNaN(value) ? '' : value;
33927 fixPrecision : function(value)
33929 if(this.thousandsDelimiter) {
33931 r = new RegExp(",", "g");
33932 value = value.replace(r, "");
33935 var nan = isNaN(value);
33937 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
33938 return nan ? '' : value;
33940 return parseFloat(value).toFixed(this.decimalPrecision);
33943 setValue : function(v)
33945 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
33951 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
33953 this.inputEl().dom.value = (v == '') ? '' :
33954 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
33956 if(!this.allowZero && v === '0') {
33957 this.hiddenEl().dom.value = '';
33958 this.inputEl().dom.value = '';
33965 decimalPrecisionFcn : function(v)
33967 return Math.floor(v);
33970 beforeBlur : function()
33972 var v = this.parseValue(this.getRawValue());
33974 if(v || v === 0 || v === ''){
33979 hiddenEl : function()
33981 return this.el.select('input.hidden-number-input',true).first();
33993 * @class Roo.bootstrap.DocumentSlider
33994 * @extends Roo.bootstrap.Component
33995 * Bootstrap DocumentSlider class
33998 * Create a new DocumentViewer
33999 * @param {Object} config The config object
34002 Roo.bootstrap.DocumentSlider = function(config){
34003 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
34010 * Fire after initEvent
34011 * @param {Roo.bootstrap.DocumentSlider} this
34016 * Fire after update
34017 * @param {Roo.bootstrap.DocumentSlider} this
34023 * @param {Roo.bootstrap.DocumentSlider} this
34029 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
34035 getAutoCreate : function()
34039 cls : 'roo-document-slider',
34043 cls : 'roo-document-slider-header',
34047 cls : 'roo-document-slider-header-title'
34053 cls : 'roo-document-slider-body',
34057 cls : 'roo-document-slider-prev',
34061 cls : 'fa fa-chevron-left'
34067 cls : 'roo-document-slider-thumb',
34071 cls : 'roo-document-slider-image'
34077 cls : 'roo-document-slider-next',
34081 cls : 'fa fa-chevron-right'
34093 initEvents : function()
34095 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
34096 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
34098 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
34099 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
34101 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
34102 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
34104 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
34105 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
34107 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
34108 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
34110 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
34111 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
34113 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
34114 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
34116 this.thumbEl.on('click', this.onClick, this);
34118 this.prevIndicator.on('click', this.prev, this);
34120 this.nextIndicator.on('click', this.next, this);
34124 initial : function()
34126 if(this.files.length){
34127 this.indicator = 1;
34131 this.fireEvent('initial', this);
34134 update : function()
34136 this.imageEl.attr('src', this.files[this.indicator - 1]);
34138 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
34140 this.prevIndicator.show();
34142 if(this.indicator == 1){
34143 this.prevIndicator.hide();
34146 this.nextIndicator.show();
34148 if(this.indicator == this.files.length){
34149 this.nextIndicator.hide();
34152 this.thumbEl.scrollTo('top');
34154 this.fireEvent('update', this);
34157 onClick : function(e)
34159 e.preventDefault();
34161 this.fireEvent('click', this);
34166 e.preventDefault();
34168 this.indicator = Math.max(1, this.indicator - 1);
34175 e.preventDefault();
34177 this.indicator = Math.min(this.files.length, this.indicator + 1);
34191 * @class Roo.bootstrap.RadioSet
34192 * @extends Roo.bootstrap.Input
34193 * Bootstrap RadioSet class
34194 * @cfg {String} indicatorpos (left|right) default left
34195 * @cfg {Boolean} inline (true|false) inline the element (default true)
34196 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
34198 * Create a new RadioSet
34199 * @param {Object} config The config object
34202 Roo.bootstrap.RadioSet = function(config){
34204 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
34208 Roo.bootstrap.RadioSet.register(this);
34213 * Fires when the element is checked or unchecked.
34214 * @param {Roo.bootstrap.RadioSet} this This radio
34215 * @param {Roo.bootstrap.Radio} item The checked item
34220 * Fires when the element is click.
34221 * @param {Roo.bootstrap.RadioSet} this This radio set
34222 * @param {Roo.bootstrap.Radio} item The checked item
34223 * @param {Roo.EventObject} e The event object
34230 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
34238 indicatorpos : 'left',
34240 getAutoCreate : function()
34244 cls : 'roo-radio-set-label',
34248 html : this.fieldLabel
34252 if (Roo.bootstrap.version == 3) {
34255 if(this.indicatorpos == 'left'){
34258 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
34259 tooltip : 'This field is required'
34264 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
34265 tooltip : 'This field is required'
34271 cls : 'roo-radio-set-items'
34274 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
34276 if (align === 'left' && this.fieldLabel.length) {
34279 cls : "roo-radio-set-right",
34285 if(this.labelWidth > 12){
34286 label.style = "width: " + this.labelWidth + 'px';
34289 if(this.labelWidth < 13 && this.labelmd == 0){
34290 this.labelmd = this.labelWidth;
34293 if(this.labellg > 0){
34294 label.cls += ' col-lg-' + this.labellg;
34295 items.cls += ' col-lg-' + (12 - this.labellg);
34298 if(this.labelmd > 0){
34299 label.cls += ' col-md-' + this.labelmd;
34300 items.cls += ' col-md-' + (12 - this.labelmd);
34303 if(this.labelsm > 0){
34304 label.cls += ' col-sm-' + this.labelsm;
34305 items.cls += ' col-sm-' + (12 - this.labelsm);
34308 if(this.labelxs > 0){
34309 label.cls += ' col-xs-' + this.labelxs;
34310 items.cls += ' col-xs-' + (12 - this.labelxs);
34316 cls : 'roo-radio-set',
34320 cls : 'roo-radio-set-input',
34323 value : this.value ? this.value : ''
34330 if(this.weight.length){
34331 cfg.cls += ' roo-radio-' + this.weight;
34335 cfg.cls += ' roo-radio-set-inline';
34339 ['xs','sm','md','lg'].map(function(size){
34340 if (settings[size]) {
34341 cfg.cls += ' col-' + size + '-' + settings[size];
34349 initEvents : function()
34351 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
34352 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
34354 if(!this.fieldLabel.length){
34355 this.labelEl.hide();
34358 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
34359 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
34361 this.indicator = this.indicatorEl();
34363 if(this.indicator){
34364 this.indicator.addClass('invisible');
34367 this.originalValue = this.getValue();
34371 inputEl: function ()
34373 return this.el.select('.roo-radio-set-input', true).first();
34376 getChildContainer : function()
34378 return this.itemsEl;
34381 register : function(item)
34383 this.radioes.push(item);
34387 validate : function()
34389 if(this.getVisibilityEl().hasClass('hidden')){
34395 Roo.each(this.radioes, function(i){
34404 if(this.allowBlank) {
34408 if(this.disabled || valid){
34413 this.markInvalid();
34418 markValid : function()
34420 if(this.labelEl.isVisible(true) && this.indicatorEl()){
34421 this.indicatorEl().removeClass('visible');
34422 this.indicatorEl().addClass('invisible');
34426 if (Roo.bootstrap.version == 3) {
34427 this.el.removeClass([this.invalidClass, this.validClass]);
34428 this.el.addClass(this.validClass);
34430 this.el.removeClass(['is-invalid','is-valid']);
34431 this.el.addClass(['is-valid']);
34433 this.fireEvent('valid', this);
34436 markInvalid : function(msg)
34438 if(this.allowBlank || this.disabled){
34442 if(this.labelEl.isVisible(true) && this.indicatorEl()){
34443 this.indicatorEl().removeClass('invisible');
34444 this.indicatorEl().addClass('visible');
34446 if (Roo.bootstrap.version == 3) {
34447 this.el.removeClass([this.invalidClass, this.validClass]);
34448 this.el.addClass(this.invalidClass);
34450 this.el.removeClass(['is-invalid','is-valid']);
34451 this.el.addClass(['is-invalid']);
34454 this.fireEvent('invalid', this, msg);
34458 setValue : function(v, suppressEvent)
34460 if(this.value === v){
34467 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
34470 Roo.each(this.radioes, function(i){
34472 i.el.removeClass('checked');
34475 Roo.each(this.radioes, function(i){
34477 if(i.value === v || i.value.toString() === v.toString()){
34479 i.el.addClass('checked');
34481 if(suppressEvent !== true){
34482 this.fireEvent('check', this, i);
34493 clearInvalid : function(){
34495 if(!this.el || this.preventMark){
34499 this.el.removeClass([this.invalidClass]);
34501 this.fireEvent('valid', this);
34506 Roo.apply(Roo.bootstrap.RadioSet, {
34510 register : function(set)
34512 this.groups[set.name] = set;
34515 get: function(name)
34517 if (typeof(this.groups[name]) == 'undefined') {
34521 return this.groups[name] ;
34527 * Ext JS Library 1.1.1
34528 * Copyright(c) 2006-2007, Ext JS, LLC.
34530 * Originally Released Under LGPL - original licence link has changed is not relivant.
34533 * <script type="text/javascript">
34538 * @class Roo.bootstrap.SplitBar
34539 * @extends Roo.util.Observable
34540 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
34544 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
34545 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
34546 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
34547 split.minSize = 100;
34548 split.maxSize = 600;
34549 split.animate = true;
34550 split.on('moved', splitterMoved);
34553 * Create a new SplitBar
34554 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
34555 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
34556 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34557 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
34558 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
34559 position of the SplitBar).
34561 Roo.bootstrap.SplitBar = function(cfg){
34566 // dragElement : elm
34567 // resizingElement: el,
34569 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
34570 // placement : Roo.bootstrap.SplitBar.LEFT ,
34571 // existingProxy ???
34574 this.el = Roo.get(cfg.dragElement, true);
34575 this.el.dom.unselectable = "on";
34577 this.resizingEl = Roo.get(cfg.resizingElement, true);
34581 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34582 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
34585 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
34588 * The minimum size of the resizing element. (Defaults to 0)
34594 * The maximum size of the resizing element. (Defaults to 2000)
34597 this.maxSize = 2000;
34600 * Whether to animate the transition to the new size
34603 this.animate = false;
34606 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
34609 this.useShim = false;
34614 if(!cfg.existingProxy){
34616 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
34618 this.proxy = Roo.get(cfg.existingProxy).dom;
34621 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
34624 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
34627 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
34630 this.dragSpecs = {};
34633 * @private The adapter to use to positon and resize elements
34635 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34636 this.adapter.init(this);
34638 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34640 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
34641 this.el.addClass("roo-splitbar-h");
34644 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
34645 this.el.addClass("roo-splitbar-v");
34651 * Fires when the splitter is moved (alias for {@link #event-moved})
34652 * @param {Roo.bootstrap.SplitBar} this
34653 * @param {Number} newSize the new width or height
34658 * Fires when the splitter is moved
34659 * @param {Roo.bootstrap.SplitBar} this
34660 * @param {Number} newSize the new width or height
34664 * @event beforeresize
34665 * Fires before the splitter is dragged
34666 * @param {Roo.bootstrap.SplitBar} this
34668 "beforeresize" : true,
34670 "beforeapply" : true
34673 Roo.util.Observable.call(this);
34676 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
34677 onStartProxyDrag : function(x, y){
34678 this.fireEvent("beforeresize", this);
34680 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
34682 o.enableDisplayMode("block");
34683 // all splitbars share the same overlay
34684 Roo.bootstrap.SplitBar.prototype.overlay = o;
34686 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
34687 this.overlay.show();
34688 Roo.get(this.proxy).setDisplayed("block");
34689 var size = this.adapter.getElementSize(this);
34690 this.activeMinSize = this.getMinimumSize();;
34691 this.activeMaxSize = this.getMaximumSize();;
34692 var c1 = size - this.activeMinSize;
34693 var c2 = Math.max(this.activeMaxSize - size, 0);
34694 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34695 this.dd.resetConstraints();
34696 this.dd.setXConstraint(
34697 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
34698 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
34700 this.dd.setYConstraint(0, 0);
34702 this.dd.resetConstraints();
34703 this.dd.setXConstraint(0, 0);
34704 this.dd.setYConstraint(
34705 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
34706 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
34709 this.dragSpecs.startSize = size;
34710 this.dragSpecs.startPoint = [x, y];
34711 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
34715 * @private Called after the drag operation by the DDProxy
34717 onEndProxyDrag : function(e){
34718 Roo.get(this.proxy).setDisplayed(false);
34719 var endPoint = Roo.lib.Event.getXY(e);
34721 this.overlay.hide();
34724 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34725 newSize = this.dragSpecs.startSize +
34726 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
34727 endPoint[0] - this.dragSpecs.startPoint[0] :
34728 this.dragSpecs.startPoint[0] - endPoint[0]
34731 newSize = this.dragSpecs.startSize +
34732 (this.placement == Roo.bootstrap.SplitBar.TOP ?
34733 endPoint[1] - this.dragSpecs.startPoint[1] :
34734 this.dragSpecs.startPoint[1] - endPoint[1]
34737 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
34738 if(newSize != this.dragSpecs.startSize){
34739 if(this.fireEvent('beforeapply', this, newSize) !== false){
34740 this.adapter.setElementSize(this, newSize);
34741 this.fireEvent("moved", this, newSize);
34742 this.fireEvent("resize", this, newSize);
34748 * Get the adapter this SplitBar uses
34749 * @return The adapter object
34751 getAdapter : function(){
34752 return this.adapter;
34756 * Set the adapter this SplitBar uses
34757 * @param {Object} adapter A SplitBar adapter object
34759 setAdapter : function(adapter){
34760 this.adapter = adapter;
34761 this.adapter.init(this);
34765 * Gets the minimum size for the resizing element
34766 * @return {Number} The minimum size
34768 getMinimumSize : function(){
34769 return this.minSize;
34773 * Sets the minimum size for the resizing element
34774 * @param {Number} minSize The minimum size
34776 setMinimumSize : function(minSize){
34777 this.minSize = minSize;
34781 * Gets the maximum size for the resizing element
34782 * @return {Number} The maximum size
34784 getMaximumSize : function(){
34785 return this.maxSize;
34789 * Sets the maximum size for the resizing element
34790 * @param {Number} maxSize The maximum size
34792 setMaximumSize : function(maxSize){
34793 this.maxSize = maxSize;
34797 * Sets the initialize size for the resizing element
34798 * @param {Number} size The initial size
34800 setCurrentSize : function(size){
34801 var oldAnimate = this.animate;
34802 this.animate = false;
34803 this.adapter.setElementSize(this, size);
34804 this.animate = oldAnimate;
34808 * Destroy this splitbar.
34809 * @param {Boolean} removeEl True to remove the element
34811 destroy : function(removeEl){
34813 this.shim.remove();
34816 this.proxy.parentNode.removeChild(this.proxy);
34824 * @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.
34826 Roo.bootstrap.SplitBar.createProxy = function(dir){
34827 var proxy = new Roo.Element(document.createElement("div"));
34828 proxy.unselectable();
34829 var cls = 'roo-splitbar-proxy';
34830 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
34831 document.body.appendChild(proxy.dom);
34836 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
34837 * Default Adapter. It assumes the splitter and resizing element are not positioned
34838 * elements and only gets/sets the width of the element. Generally used for table based layouts.
34840 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
34843 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
34844 // do nothing for now
34845 init : function(s){
34849 * Called before drag operations to get the current size of the resizing element.
34850 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34852 getElementSize : function(s){
34853 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34854 return s.resizingEl.getWidth();
34856 return s.resizingEl.getHeight();
34861 * Called after drag operations to set the size of the resizing element.
34862 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34863 * @param {Number} newSize The new size to set
34864 * @param {Function} onComplete A function to be invoked when resizing is complete
34866 setElementSize : function(s, newSize, onComplete){
34867 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34869 s.resizingEl.setWidth(newSize);
34871 onComplete(s, newSize);
34874 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
34879 s.resizingEl.setHeight(newSize);
34881 onComplete(s, newSize);
34884 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
34891 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
34892 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
34893 * Adapter that moves the splitter element to align with the resized sizing element.
34894 * Used with an absolute positioned SplitBar.
34895 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
34896 * document.body, make sure you assign an id to the body element.
34898 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
34899 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34900 this.container = Roo.get(container);
34903 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
34904 init : function(s){
34905 this.basic.init(s);
34908 getElementSize : function(s){
34909 return this.basic.getElementSize(s);
34912 setElementSize : function(s, newSize, onComplete){
34913 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
34916 moveSplitter : function(s){
34917 var yes = Roo.bootstrap.SplitBar;
34918 switch(s.placement){
34920 s.el.setX(s.resizingEl.getRight());
34923 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
34926 s.el.setY(s.resizingEl.getBottom());
34929 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
34936 * Orientation constant - Create a vertical SplitBar
34940 Roo.bootstrap.SplitBar.VERTICAL = 1;
34943 * Orientation constant - Create a horizontal SplitBar
34947 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
34950 * Placement constant - The resizing element is to the left of the splitter element
34954 Roo.bootstrap.SplitBar.LEFT = 1;
34957 * Placement constant - The resizing element is to the right of the splitter element
34961 Roo.bootstrap.SplitBar.RIGHT = 2;
34964 * Placement constant - The resizing element is positioned above the splitter element
34968 Roo.bootstrap.SplitBar.TOP = 3;
34971 * Placement constant - The resizing element is positioned under splitter element
34975 Roo.bootstrap.SplitBar.BOTTOM = 4;
34976 Roo.namespace("Roo.bootstrap.layout");/*
34978 * Ext JS Library 1.1.1
34979 * Copyright(c) 2006-2007, Ext JS, LLC.
34981 * Originally Released Under LGPL - original licence link has changed is not relivant.
34984 * <script type="text/javascript">
34988 * @class Roo.bootstrap.layout.Manager
34989 * @extends Roo.bootstrap.Component
34990 * Base class for layout managers.
34992 Roo.bootstrap.layout.Manager = function(config)
34994 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
35000 /** false to disable window resize monitoring @type Boolean */
35001 this.monitorWindowResize = true;
35006 * Fires when a layout is performed.
35007 * @param {Roo.LayoutManager} this
35011 * @event regionresized
35012 * Fires when the user resizes a region.
35013 * @param {Roo.LayoutRegion} region The resized region
35014 * @param {Number} newSize The new size (width for east/west, height for north/south)
35016 "regionresized" : true,
35018 * @event regioncollapsed
35019 * Fires when a region is collapsed.
35020 * @param {Roo.LayoutRegion} region The collapsed region
35022 "regioncollapsed" : true,
35024 * @event regionexpanded
35025 * Fires when a region is expanded.
35026 * @param {Roo.LayoutRegion} region The expanded region
35028 "regionexpanded" : true
35030 this.updating = false;
35033 this.el = Roo.get(config.el);
35039 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
35044 monitorWindowResize : true,
35050 onRender : function(ct, position)
35053 this.el = Roo.get(ct);
35056 //this.fireEvent('render',this);
35060 initEvents: function()
35064 // ie scrollbar fix
35065 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
35066 document.body.scroll = "no";
35067 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
35068 this.el.position('relative');
35070 this.id = this.el.id;
35071 this.el.addClass("roo-layout-container");
35072 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
35073 if(this.el.dom != document.body ) {
35074 this.el.on('resize', this.layout,this);
35075 this.el.on('show', this.layout,this);
35081 * Returns true if this layout is currently being updated
35082 * @return {Boolean}
35084 isUpdating : function(){
35085 return this.updating;
35089 * Suspend the LayoutManager from doing auto-layouts while
35090 * making multiple add or remove calls
35092 beginUpdate : function(){
35093 this.updating = true;
35097 * Restore auto-layouts and optionally disable the manager from performing a layout
35098 * @param {Boolean} noLayout true to disable a layout update
35100 endUpdate : function(noLayout){
35101 this.updating = false;
35107 layout: function(){
35111 onRegionResized : function(region, newSize){
35112 this.fireEvent("regionresized", region, newSize);
35116 onRegionCollapsed : function(region){
35117 this.fireEvent("regioncollapsed", region);
35120 onRegionExpanded : function(region){
35121 this.fireEvent("regionexpanded", region);
35125 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
35126 * performs box-model adjustments.
35127 * @return {Object} The size as an object {width: (the width), height: (the height)}
35129 getViewSize : function()
35132 if(this.el.dom != document.body){
35133 size = this.el.getSize();
35135 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
35137 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
35138 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
35143 * Returns the Element this layout is bound to.
35144 * @return {Roo.Element}
35146 getEl : function(){
35151 * Returns the specified region.
35152 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
35153 * @return {Roo.LayoutRegion}
35155 getRegion : function(target){
35156 return this.regions[target.toLowerCase()];
35159 onWindowResize : function(){
35160 if(this.monitorWindowResize){
35167 * Ext JS Library 1.1.1
35168 * Copyright(c) 2006-2007, Ext JS, LLC.
35170 * Originally Released Under LGPL - original licence link has changed is not relivant.
35173 * <script type="text/javascript">
35176 * @class Roo.bootstrap.layout.Border
35177 * @extends Roo.bootstrap.layout.Manager
35178 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
35179 * please see: examples/bootstrap/nested.html<br><br>
35181 <b>The container the layout is rendered into can be either the body element or any other element.
35182 If it is not the body element, the container needs to either be an absolute positioned element,
35183 or you will need to add "position:relative" to the css of the container. You will also need to specify
35184 the container size if it is not the body element.</b>
35187 * Create a new Border
35188 * @param {Object} config Configuration options
35190 Roo.bootstrap.layout.Border = function(config){
35191 config = config || {};
35192 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
35196 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
35197 if(config[region]){
35198 config[region].region = region;
35199 this.addRegion(config[region]);
35205 Roo.bootstrap.layout.Border.regions = ["north","south","east","west","center"];
35207 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
35209 parent : false, // this might point to a 'nest' or a ???
35212 * Creates and adds a new region if it doesn't already exist.
35213 * @param {String} target The target region key (north, south, east, west or center).
35214 * @param {Object} config The regions config object
35215 * @return {BorderLayoutRegion} The new region
35217 addRegion : function(config)
35219 if(!this.regions[config.region]){
35220 var r = this.factory(config);
35221 this.bindRegion(r);
35223 return this.regions[config.region];
35227 bindRegion : function(r){
35228 this.regions[r.config.region] = r;
35230 r.on("visibilitychange", this.layout, this);
35231 r.on("paneladded", this.layout, this);
35232 r.on("panelremoved", this.layout, this);
35233 r.on("invalidated", this.layout, this);
35234 r.on("resized", this.onRegionResized, this);
35235 r.on("collapsed", this.onRegionCollapsed, this);
35236 r.on("expanded", this.onRegionExpanded, this);
35240 * Performs a layout update.
35242 layout : function()
35244 if(this.updating) {
35248 // render all the rebions if they have not been done alreayd?
35249 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
35250 if(this.regions[region] && !this.regions[region].bodyEl){
35251 this.regions[region].onRender(this.el)
35255 var size = this.getViewSize();
35256 var w = size.width;
35257 var h = size.height;
35262 //var x = 0, y = 0;
35264 var rs = this.regions;
35265 var north = rs["north"];
35266 var south = rs["south"];
35267 var west = rs["west"];
35268 var east = rs["east"];
35269 var center = rs["center"];
35270 //if(this.hideOnLayout){ // not supported anymore
35271 //c.el.setStyle("display", "none");
35273 if(north && north.isVisible()){
35274 var b = north.getBox();
35275 var m = north.getMargins();
35276 b.width = w - (m.left+m.right);
35279 centerY = b.height + b.y + m.bottom;
35280 centerH -= centerY;
35281 north.updateBox(this.safeBox(b));
35283 if(south && south.isVisible()){
35284 var b = south.getBox();
35285 var m = south.getMargins();
35286 b.width = w - (m.left+m.right);
35288 var totalHeight = (b.height + m.top + m.bottom);
35289 b.y = h - totalHeight + m.top;
35290 centerH -= totalHeight;
35291 south.updateBox(this.safeBox(b));
35293 if(west && west.isVisible()){
35294 var b = west.getBox();
35295 var m = west.getMargins();
35296 b.height = centerH - (m.top+m.bottom);
35298 b.y = centerY + m.top;
35299 var totalWidth = (b.width + m.left + m.right);
35300 centerX += totalWidth;
35301 centerW -= totalWidth;
35302 west.updateBox(this.safeBox(b));
35304 if(east && east.isVisible()){
35305 var b = east.getBox();
35306 var m = east.getMargins();
35307 b.height = centerH - (m.top+m.bottom);
35308 var totalWidth = (b.width + m.left + m.right);
35309 b.x = w - totalWidth + m.left;
35310 b.y = centerY + m.top;
35311 centerW -= totalWidth;
35312 east.updateBox(this.safeBox(b));
35315 var m = center.getMargins();
35317 x: centerX + m.left,
35318 y: centerY + m.top,
35319 width: centerW - (m.left+m.right),
35320 height: centerH - (m.top+m.bottom)
35322 //if(this.hideOnLayout){
35323 //center.el.setStyle("display", "block");
35325 center.updateBox(this.safeBox(centerBox));
35328 this.fireEvent("layout", this);
35332 safeBox : function(box){
35333 box.width = Math.max(0, box.width);
35334 box.height = Math.max(0, box.height);
35339 * Adds a ContentPanel (or subclass) to this layout.
35340 * @param {String} target The target region key (north, south, east, west or center).
35341 * @param {Roo.ContentPanel} panel The panel to add
35342 * @return {Roo.ContentPanel} The added panel
35344 add : function(target, panel){
35346 target = target.toLowerCase();
35347 return this.regions[target].add(panel);
35351 * Remove a ContentPanel (or subclass) to this layout.
35352 * @param {String} target The target region key (north, south, east, west or center).
35353 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
35354 * @return {Roo.ContentPanel} The removed panel
35356 remove : function(target, panel){
35357 target = target.toLowerCase();
35358 return this.regions[target].remove(panel);
35362 * Searches all regions for a panel with the specified id
35363 * @param {String} panelId
35364 * @return {Roo.ContentPanel} The panel or null if it wasn't found
35366 findPanel : function(panelId){
35367 var rs = this.regions;
35368 for(var target in rs){
35369 if(typeof rs[target] != "function"){
35370 var p = rs[target].getPanel(panelId);
35380 * Searches all regions for a panel with the specified id and activates (shows) it.
35381 * @param {String/ContentPanel} panelId The panels id or the panel itself
35382 * @return {Roo.ContentPanel} The shown panel or null
35384 showPanel : function(panelId) {
35385 var rs = this.regions;
35386 for(var target in rs){
35387 var r = rs[target];
35388 if(typeof r != "function"){
35389 if(r.hasPanel(panelId)){
35390 return r.showPanel(panelId);
35398 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
35399 * @param {Roo.state.Provider} provider (optional) An alternate state provider
35402 restoreState : function(provider){
35404 provider = Roo.state.Manager;
35406 var sm = new Roo.LayoutStateManager();
35407 sm.init(this, provider);
35413 * Adds a xtype elements to the layout.
35417 xtype : 'ContentPanel',
35424 xtype : 'NestedLayoutPanel',
35430 items : [ ... list of content panels or nested layout panels.. ]
35434 * @param {Object} cfg Xtype definition of item to add.
35436 addxtype : function(cfg)
35438 // basically accepts a pannel...
35439 // can accept a layout region..!?!?
35440 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
35443 // theory? children can only be panels??
35445 //if (!cfg.xtype.match(/Panel$/)) {
35450 if (typeof(cfg.region) == 'undefined') {
35451 Roo.log("Failed to add Panel, region was not set");
35455 var region = cfg.region;
35461 xitems = cfg.items;
35466 if ( region == 'center') {
35467 Roo.log("Center: " + cfg.title);
35473 case 'Content': // ContentPanel (el, cfg)
35474 case 'Scroll': // ContentPanel (el, cfg)
35476 cfg.autoCreate = cfg.autoCreate || true;
35477 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35479 // var el = this.el.createChild();
35480 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
35483 this.add(region, ret);
35487 case 'TreePanel': // our new panel!
35488 cfg.el = this.el.createChild();
35489 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35490 this.add(region, ret);
35495 // create a new Layout (which is a Border Layout...
35497 var clayout = cfg.layout;
35498 clayout.el = this.el.createChild();
35499 clayout.items = clayout.items || [];
35503 // replace this exitems with the clayout ones..
35504 xitems = clayout.items;
35506 // force background off if it's in center...
35507 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
35508 cfg.background = false;
35510 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
35513 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35514 //console.log('adding nested layout panel ' + cfg.toSource());
35515 this.add(region, ret);
35516 nb = {}; /// find first...
35521 // needs grid and region
35523 //var el = this.getRegion(region).el.createChild();
35525 *var el = this.el.createChild();
35526 // create the grid first...
35527 cfg.grid.container = el;
35528 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
35531 if (region == 'center' && this.active ) {
35532 cfg.background = false;
35535 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35537 this.add(region, ret);
35539 if (cfg.background) {
35540 // render grid on panel activation (if panel background)
35541 ret.on('activate', function(gp) {
35542 if (!gp.grid.rendered) {
35543 // gp.grid.render(el);
35547 // cfg.grid.render(el);
35553 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
35554 // it was the old xcomponent building that caused this before.
35555 // espeically if border is the top element in the tree.
35565 if (typeof(Roo[cfg.xtype]) != 'undefined') {
35567 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35568 this.add(region, ret);
35572 throw "Can not add '" + cfg.xtype + "' to Border";
35578 this.beginUpdate();
35582 Roo.each(xitems, function(i) {
35583 region = nb && i.region ? i.region : false;
35585 var add = ret.addxtype(i);
35588 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
35589 if (!i.background) {
35590 abn[region] = nb[region] ;
35597 // make the last non-background panel active..
35598 //if (nb) { Roo.log(abn); }
35601 for(var r in abn) {
35602 region = this.getRegion(r);
35604 // tried using nb[r], but it does not work..
35606 region.showPanel(abn[r]);
35617 factory : function(cfg)
35620 var validRegions = Roo.bootstrap.layout.Border.regions;
35622 var target = cfg.region;
35625 var r = Roo.bootstrap.layout;
35629 return new r.North(cfg);
35631 return new r.South(cfg);
35633 return new r.East(cfg);
35635 return new r.West(cfg);
35637 return new r.Center(cfg);
35639 throw 'Layout region "'+target+'" not supported.';
35646 * Ext JS Library 1.1.1
35647 * Copyright(c) 2006-2007, Ext JS, LLC.
35649 * Originally Released Under LGPL - original licence link has changed is not relivant.
35652 * <script type="text/javascript">
35656 * @class Roo.bootstrap.layout.Basic
35657 * @extends Roo.util.Observable
35658 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
35659 * and does not have a titlebar, tabs or any other features. All it does is size and position
35660 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
35661 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35662 * @cfg {string} region the region that it inhabits..
35663 * @cfg {bool} skipConfig skip config?
35667 Roo.bootstrap.layout.Basic = function(config){
35669 this.mgr = config.mgr;
35671 this.position = config.region;
35673 var skipConfig = config.skipConfig;
35677 * @scope Roo.BasicLayoutRegion
35681 * @event beforeremove
35682 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
35683 * @param {Roo.LayoutRegion} this
35684 * @param {Roo.ContentPanel} panel The panel
35685 * @param {Object} e The cancel event object
35687 "beforeremove" : true,
35689 * @event invalidated
35690 * Fires when the layout for this region is changed.
35691 * @param {Roo.LayoutRegion} this
35693 "invalidated" : true,
35695 * @event visibilitychange
35696 * Fires when this region is shown or hidden
35697 * @param {Roo.LayoutRegion} this
35698 * @param {Boolean} visibility true or false
35700 "visibilitychange" : true,
35702 * @event paneladded
35703 * Fires when a panel is added.
35704 * @param {Roo.LayoutRegion} this
35705 * @param {Roo.ContentPanel} panel The panel
35707 "paneladded" : true,
35709 * @event panelremoved
35710 * Fires when a panel is removed.
35711 * @param {Roo.LayoutRegion} this
35712 * @param {Roo.ContentPanel} panel The panel
35714 "panelremoved" : true,
35716 * @event beforecollapse
35717 * Fires when this region before collapse.
35718 * @param {Roo.LayoutRegion} this
35720 "beforecollapse" : true,
35723 * Fires when this region is collapsed.
35724 * @param {Roo.LayoutRegion} this
35726 "collapsed" : true,
35729 * Fires when this region is expanded.
35730 * @param {Roo.LayoutRegion} this
35735 * Fires when this region is slid into view.
35736 * @param {Roo.LayoutRegion} this
35738 "slideshow" : true,
35741 * Fires when this region slides out of view.
35742 * @param {Roo.LayoutRegion} this
35744 "slidehide" : true,
35746 * @event panelactivated
35747 * Fires when a panel is activated.
35748 * @param {Roo.LayoutRegion} this
35749 * @param {Roo.ContentPanel} panel The activated panel
35751 "panelactivated" : true,
35754 * Fires when the user resizes this region.
35755 * @param {Roo.LayoutRegion} this
35756 * @param {Number} newSize The new size (width for east/west, height for north/south)
35760 /** A collection of panels in this region. @type Roo.util.MixedCollection */
35761 this.panels = new Roo.util.MixedCollection();
35762 this.panels.getKey = this.getPanelId.createDelegate(this);
35764 this.activePanel = null;
35765 // ensure listeners are added...
35767 if (config.listeners || config.events) {
35768 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
35769 listeners : config.listeners || {},
35770 events : config.events || {}
35774 if(skipConfig !== true){
35775 this.applyConfig(config);
35779 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
35781 getPanelId : function(p){
35785 applyConfig : function(config){
35786 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35787 this.config = config;
35792 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
35793 * the width, for horizontal (north, south) the height.
35794 * @param {Number} newSize The new width or height
35796 resizeTo : function(newSize){
35797 var el = this.el ? this.el :
35798 (this.activePanel ? this.activePanel.getEl() : null);
35800 switch(this.position){
35803 el.setWidth(newSize);
35804 this.fireEvent("resized", this, newSize);
35808 el.setHeight(newSize);
35809 this.fireEvent("resized", this, newSize);
35815 getBox : function(){
35816 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
35819 getMargins : function(){
35820 return this.margins;
35823 updateBox : function(box){
35825 var el = this.activePanel.getEl();
35826 el.dom.style.left = box.x + "px";
35827 el.dom.style.top = box.y + "px";
35828 this.activePanel.setSize(box.width, box.height);
35832 * Returns the container element for this region.
35833 * @return {Roo.Element}
35835 getEl : function(){
35836 return this.activePanel;
35840 * Returns true if this region is currently visible.
35841 * @return {Boolean}
35843 isVisible : function(){
35844 return this.activePanel ? true : false;
35847 setActivePanel : function(panel){
35848 panel = this.getPanel(panel);
35849 if(this.activePanel && this.activePanel != panel){
35850 this.activePanel.setActiveState(false);
35851 this.activePanel.getEl().setLeftTop(-10000,-10000);
35853 this.activePanel = panel;
35854 panel.setActiveState(true);
35856 panel.setSize(this.box.width, this.box.height);
35858 this.fireEvent("panelactivated", this, panel);
35859 this.fireEvent("invalidated");
35863 * Show the specified panel.
35864 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
35865 * @return {Roo.ContentPanel} The shown panel or null
35867 showPanel : function(panel){
35868 panel = this.getPanel(panel);
35870 this.setActivePanel(panel);
35876 * Get the active panel for this region.
35877 * @return {Roo.ContentPanel} The active panel or null
35879 getActivePanel : function(){
35880 return this.activePanel;
35884 * Add the passed ContentPanel(s)
35885 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35886 * @return {Roo.ContentPanel} The panel added (if only one was added)
35888 add : function(panel){
35889 if(arguments.length > 1){
35890 for(var i = 0, len = arguments.length; i < len; i++) {
35891 this.add(arguments[i]);
35895 if(this.hasPanel(panel)){
35896 this.showPanel(panel);
35899 var el = panel.getEl();
35900 if(el.dom.parentNode != this.mgr.el.dom){
35901 this.mgr.el.dom.appendChild(el.dom);
35903 if(panel.setRegion){
35904 panel.setRegion(this);
35906 this.panels.add(panel);
35907 el.setStyle("position", "absolute");
35908 if(!panel.background){
35909 this.setActivePanel(panel);
35910 if(this.config.initialSize && this.panels.getCount()==1){
35911 this.resizeTo(this.config.initialSize);
35914 this.fireEvent("paneladded", this, panel);
35919 * Returns true if the panel is in this region.
35920 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35921 * @return {Boolean}
35923 hasPanel : function(panel){
35924 if(typeof panel == "object"){ // must be panel obj
35925 panel = panel.getId();
35927 return this.getPanel(panel) ? true : false;
35931 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35932 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35933 * @param {Boolean} preservePanel Overrides the config preservePanel option
35934 * @return {Roo.ContentPanel} The panel that was removed
35936 remove : function(panel, preservePanel){
35937 panel = this.getPanel(panel);
35942 this.fireEvent("beforeremove", this, panel, e);
35943 if(e.cancel === true){
35946 var panelId = panel.getId();
35947 this.panels.removeKey(panelId);
35952 * Returns the panel specified or null if it's not in this region.
35953 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35954 * @return {Roo.ContentPanel}
35956 getPanel : function(id){
35957 if(typeof id == "object"){ // must be panel obj
35960 return this.panels.get(id);
35964 * Returns this regions position (north/south/east/west/center).
35967 getPosition: function(){
35968 return this.position;
35972 * Ext JS Library 1.1.1
35973 * Copyright(c) 2006-2007, Ext JS, LLC.
35975 * Originally Released Under LGPL - original licence link has changed is not relivant.
35978 * <script type="text/javascript">
35982 * @class Roo.bootstrap.layout.Region
35983 * @extends Roo.bootstrap.layout.Basic
35984 * This class represents a region in a layout manager.
35986 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
35987 * @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})
35988 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
35989 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
35990 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
35991 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
35992 * @cfg {String} title The title for the region (overrides panel titles)
35993 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
35994 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
35995 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
35996 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
35997 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
35998 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
35999 * the space available, similar to FireFox 1.5 tabs (defaults to false)
36000 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
36001 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
36002 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
36004 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
36005 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
36006 * @cfg {Boolean} disableTabTips True to disable tab tooltips
36007 * @cfg {Number} width For East/West panels
36008 * @cfg {Number} height For North/South panels
36009 * @cfg {Boolean} split To show the splitter
36010 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
36012 * @cfg {string} cls Extra CSS classes to add to region
36014 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
36015 * @cfg {string} region the region that it inhabits..
36018 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
36019 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
36021 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
36022 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
36023 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
36025 Roo.bootstrap.layout.Region = function(config)
36027 this.applyConfig(config);
36029 var mgr = config.mgr;
36030 var pos = config.region;
36031 config.skipConfig = true;
36032 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
36035 this.onRender(mgr.el);
36038 this.visible = true;
36039 this.collapsed = false;
36040 this.unrendered_panels = [];
36043 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
36045 position: '', // set by wrapper (eg. north/south etc..)
36046 unrendered_panels : null, // unrendered panels.
36048 tabPosition : false,
36050 mgr: false, // points to 'Border'
36053 createBody : function(){
36054 /** This region's body element
36055 * @type Roo.Element */
36056 this.bodyEl = this.el.createChild({
36058 cls: "roo-layout-panel-body tab-content" // bootstrap added...
36062 onRender: function(ctr, pos)
36064 var dh = Roo.DomHelper;
36065 /** This region's container element
36066 * @type Roo.Element */
36067 this.el = dh.append(ctr.dom, {
36069 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
36071 /** This region's title element
36072 * @type Roo.Element */
36074 this.titleEl = dh.append(this.el.dom, {
36076 unselectable: "on",
36077 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
36079 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
36080 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
36084 this.titleEl.enableDisplayMode();
36085 /** This region's title text element
36086 * @type HTMLElement */
36087 this.titleTextEl = this.titleEl.dom.firstChild;
36088 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
36090 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
36091 this.closeBtn.enableDisplayMode();
36092 this.closeBtn.on("click", this.closeClicked, this);
36093 this.closeBtn.hide();
36095 this.createBody(this.config);
36096 if(this.config.hideWhenEmpty){
36098 this.on("paneladded", this.validateVisibility, this);
36099 this.on("panelremoved", this.validateVisibility, this);
36101 if(this.autoScroll){
36102 this.bodyEl.setStyle("overflow", "auto");
36104 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
36106 //if(c.titlebar !== false){
36107 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
36108 this.titleEl.hide();
36110 this.titleEl.show();
36111 if(this.config.title){
36112 this.titleTextEl.innerHTML = this.config.title;
36116 if(this.config.collapsed){
36117 this.collapse(true);
36119 if(this.config.hidden){
36123 if (this.unrendered_panels && this.unrendered_panels.length) {
36124 for (var i =0;i< this.unrendered_panels.length; i++) {
36125 this.add(this.unrendered_panels[i]);
36127 this.unrendered_panels = null;
36133 applyConfig : function(c)
36136 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
36137 var dh = Roo.DomHelper;
36138 if(c.titlebar !== false){
36139 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
36140 this.collapseBtn.on("click", this.collapse, this);
36141 this.collapseBtn.enableDisplayMode();
36143 if(c.showPin === true || this.showPin){
36144 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
36145 this.stickBtn.enableDisplayMode();
36146 this.stickBtn.on("click", this.expand, this);
36147 this.stickBtn.hide();
36152 /** This region's collapsed element
36153 * @type Roo.Element */
36156 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
36157 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
36160 if(c.floatable !== false){
36161 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
36162 this.collapsedEl.on("click", this.collapseClick, this);
36165 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
36166 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
36167 id: "message", unselectable: "on", style:{"float":"left"}});
36168 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
36170 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
36171 this.expandBtn.on("click", this.expand, this);
36175 if(this.collapseBtn){
36176 this.collapseBtn.setVisible(c.collapsible == true);
36179 this.cmargins = c.cmargins || this.cmargins ||
36180 (this.position == "west" || this.position == "east" ?
36181 {top: 0, left: 2, right:2, bottom: 0} :
36182 {top: 2, left: 0, right:0, bottom: 2});
36184 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
36187 this.tabPosition = [ 'top','bottom', 'west'].indexOf(c.tabPosition) > -1 ? c.tabPosition : "top";
36189 this.autoScroll = c.autoScroll || false;
36194 this.duration = c.duration || .30;
36195 this.slideDuration = c.slideDuration || .45;
36200 * Returns true if this region is currently visible.
36201 * @return {Boolean}
36203 isVisible : function(){
36204 return this.visible;
36208 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
36209 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
36211 //setCollapsedTitle : function(title){
36212 // title = title || " ";
36213 // if(this.collapsedTitleTextEl){
36214 // this.collapsedTitleTextEl.innerHTML = title;
36218 getBox : function(){
36220 // if(!this.collapsed){
36221 b = this.el.getBox(false, true);
36223 // b = this.collapsedEl.getBox(false, true);
36228 getMargins : function(){
36229 return this.margins;
36230 //return this.collapsed ? this.cmargins : this.margins;
36233 highlight : function(){
36234 this.el.addClass("x-layout-panel-dragover");
36237 unhighlight : function(){
36238 this.el.removeClass("x-layout-panel-dragover");
36241 updateBox : function(box)
36243 if (!this.bodyEl) {
36244 return; // not rendered yet..
36248 if(!this.collapsed){
36249 this.el.dom.style.left = box.x + "px";
36250 this.el.dom.style.top = box.y + "px";
36251 this.updateBody(box.width, box.height);
36253 this.collapsedEl.dom.style.left = box.x + "px";
36254 this.collapsedEl.dom.style.top = box.y + "px";
36255 this.collapsedEl.setSize(box.width, box.height);
36258 this.tabs.autoSizeTabs();
36262 updateBody : function(w, h)
36265 this.el.setWidth(w);
36266 w -= this.el.getBorderWidth("rl");
36267 if(this.config.adjustments){
36268 w += this.config.adjustments[0];
36271 if(h !== null && h > 0){
36272 this.el.setHeight(h);
36273 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
36274 h -= this.el.getBorderWidth("tb");
36275 if(this.config.adjustments){
36276 h += this.config.adjustments[1];
36278 this.bodyEl.setHeight(h);
36280 h = this.tabs.syncHeight(h);
36283 if(this.panelSize){
36284 w = w !== null ? w : this.panelSize.width;
36285 h = h !== null ? h : this.panelSize.height;
36287 if(this.activePanel){
36288 var el = this.activePanel.getEl();
36289 w = w !== null ? w : el.getWidth();
36290 h = h !== null ? h : el.getHeight();
36291 this.panelSize = {width: w, height: h};
36292 this.activePanel.setSize(w, h);
36294 if(Roo.isIE && this.tabs){
36295 this.tabs.el.repaint();
36300 * Returns the container element for this region.
36301 * @return {Roo.Element}
36303 getEl : function(){
36308 * Hides this region.
36311 //if(!this.collapsed){
36312 this.el.dom.style.left = "-2000px";
36315 // this.collapsedEl.dom.style.left = "-2000px";
36316 // this.collapsedEl.hide();
36318 this.visible = false;
36319 this.fireEvent("visibilitychange", this, false);
36323 * Shows this region if it was previously hidden.
36326 //if(!this.collapsed){
36329 // this.collapsedEl.show();
36331 this.visible = true;
36332 this.fireEvent("visibilitychange", this, true);
36335 closeClicked : function(){
36336 if(this.activePanel){
36337 this.remove(this.activePanel);
36341 collapseClick : function(e){
36343 e.stopPropagation();
36346 e.stopPropagation();
36352 * Collapses this region.
36353 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
36356 collapse : function(skipAnim, skipCheck = false){
36357 if(this.collapsed) {
36361 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
36363 this.collapsed = true;
36365 this.split.el.hide();
36367 if(this.config.animate && skipAnim !== true){
36368 this.fireEvent("invalidated", this);
36369 this.animateCollapse();
36371 this.el.setLocation(-20000,-20000);
36373 this.collapsedEl.show();
36374 this.fireEvent("collapsed", this);
36375 this.fireEvent("invalidated", this);
36381 animateCollapse : function(){
36386 * Expands this region if it was previously collapsed.
36387 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
36388 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
36391 expand : function(e, skipAnim){
36393 e.stopPropagation();
36395 if(!this.collapsed || this.el.hasActiveFx()) {
36399 this.afterSlideIn();
36402 this.collapsed = false;
36403 if(this.config.animate && skipAnim !== true){
36404 this.animateExpand();
36408 this.split.el.show();
36410 this.collapsedEl.setLocation(-2000,-2000);
36411 this.collapsedEl.hide();
36412 this.fireEvent("invalidated", this);
36413 this.fireEvent("expanded", this);
36417 animateExpand : function(){
36421 initTabs : function()
36423 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
36425 var ts = new Roo.bootstrap.panel.Tabs({
36426 el: this.bodyEl.dom,
36428 tabPosition: this.tabPosition ? this.tabPosition : 'top',
36429 disableTooltips: this.config.disableTabTips,
36430 toolbar : this.config.toolbar
36433 if(this.config.hideTabs){
36434 ts.stripWrap.setDisplayed(false);
36437 ts.resizeTabs = this.config.resizeTabs === true;
36438 ts.minTabWidth = this.config.minTabWidth || 40;
36439 ts.maxTabWidth = this.config.maxTabWidth || 250;
36440 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
36441 ts.monitorResize = false;
36442 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
36443 ts.bodyEl.addClass('roo-layout-tabs-body');
36444 this.panels.each(this.initPanelAsTab, this);
36447 initPanelAsTab : function(panel){
36448 var ti = this.tabs.addTab(
36452 this.config.closeOnTab && panel.isClosable(),
36455 if(panel.tabTip !== undefined){
36456 ti.setTooltip(panel.tabTip);
36458 ti.on("activate", function(){
36459 this.setActivePanel(panel);
36462 if(this.config.closeOnTab){
36463 ti.on("beforeclose", function(t, e){
36465 this.remove(panel);
36469 panel.tabItem = ti;
36474 updatePanelTitle : function(panel, title)
36476 if(this.activePanel == panel){
36477 this.updateTitle(title);
36480 var ti = this.tabs.getTab(panel.getEl().id);
36482 if(panel.tabTip !== undefined){
36483 ti.setTooltip(panel.tabTip);
36488 updateTitle : function(title){
36489 if(this.titleTextEl && !this.config.title){
36490 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
36494 setActivePanel : function(panel)
36496 panel = this.getPanel(panel);
36497 if(this.activePanel && this.activePanel != panel){
36498 if(this.activePanel.setActiveState(false) === false){
36502 this.activePanel = panel;
36503 panel.setActiveState(true);
36504 if(this.panelSize){
36505 panel.setSize(this.panelSize.width, this.panelSize.height);
36508 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
36510 this.updateTitle(panel.getTitle());
36512 this.fireEvent("invalidated", this);
36514 this.fireEvent("panelactivated", this, panel);
36518 * Shows the specified panel.
36519 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
36520 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
36522 showPanel : function(panel)
36524 panel = this.getPanel(panel);
36527 var tab = this.tabs.getTab(panel.getEl().id);
36528 if(tab.isHidden()){
36529 this.tabs.unhideTab(tab.id);
36533 this.setActivePanel(panel);
36540 * Get the active panel for this region.
36541 * @return {Roo.ContentPanel} The active panel or null
36543 getActivePanel : function(){
36544 return this.activePanel;
36547 validateVisibility : function(){
36548 if(this.panels.getCount() < 1){
36549 this.updateTitle(" ");
36550 this.closeBtn.hide();
36553 if(!this.isVisible()){
36560 * Adds the passed ContentPanel(s) to this region.
36561 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
36562 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
36564 add : function(panel)
36566 if(arguments.length > 1){
36567 for(var i = 0, len = arguments.length; i < len; i++) {
36568 this.add(arguments[i]);
36573 // if we have not been rendered yet, then we can not really do much of this..
36574 if (!this.bodyEl) {
36575 this.unrendered_panels.push(panel);
36582 if(this.hasPanel(panel)){
36583 this.showPanel(panel);
36586 panel.setRegion(this);
36587 this.panels.add(panel);
36588 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
36589 // sinle panel - no tab...?? would it not be better to render it with the tabs,
36590 // and hide them... ???
36591 this.bodyEl.dom.appendChild(panel.getEl().dom);
36592 if(panel.background !== true){
36593 this.setActivePanel(panel);
36595 this.fireEvent("paneladded", this, panel);
36602 this.initPanelAsTab(panel);
36606 if(panel.background !== true){
36607 this.tabs.activate(panel.getEl().id);
36609 this.fireEvent("paneladded", this, panel);
36614 * Hides the tab for the specified panel.
36615 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36617 hidePanel : function(panel){
36618 if(this.tabs && (panel = this.getPanel(panel))){
36619 this.tabs.hideTab(panel.getEl().id);
36624 * Unhides the tab for a previously hidden panel.
36625 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36627 unhidePanel : function(panel){
36628 if(this.tabs && (panel = this.getPanel(panel))){
36629 this.tabs.unhideTab(panel.getEl().id);
36633 clearPanels : function(){
36634 while(this.panels.getCount() > 0){
36635 this.remove(this.panels.first());
36640 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
36641 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36642 * @param {Boolean} preservePanel Overrides the config preservePanel option
36643 * @return {Roo.ContentPanel} The panel that was removed
36645 remove : function(panel, preservePanel)
36647 panel = this.getPanel(panel);
36652 this.fireEvent("beforeremove", this, panel, e);
36653 if(e.cancel === true){
36656 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
36657 var panelId = panel.getId();
36658 this.panels.removeKey(panelId);
36660 document.body.appendChild(panel.getEl().dom);
36663 this.tabs.removeTab(panel.getEl().id);
36664 }else if (!preservePanel){
36665 this.bodyEl.dom.removeChild(panel.getEl().dom);
36667 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
36668 var p = this.panels.first();
36669 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
36670 tempEl.appendChild(p.getEl().dom);
36671 this.bodyEl.update("");
36672 this.bodyEl.dom.appendChild(p.getEl().dom);
36674 this.updateTitle(p.getTitle());
36676 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
36677 this.setActivePanel(p);
36679 panel.setRegion(null);
36680 if(this.activePanel == panel){
36681 this.activePanel = null;
36683 if(this.config.autoDestroy !== false && preservePanel !== true){
36684 try{panel.destroy();}catch(e){}
36686 this.fireEvent("panelremoved", this, panel);
36691 * Returns the TabPanel component used by this region
36692 * @return {Roo.TabPanel}
36694 getTabs : function(){
36698 createTool : function(parentEl, className){
36699 var btn = Roo.DomHelper.append(parentEl, {
36701 cls: "x-layout-tools-button",
36704 cls: "roo-layout-tools-button-inner " + className,
36708 btn.addClassOnOver("roo-layout-tools-button-over");
36713 * Ext JS Library 1.1.1
36714 * Copyright(c) 2006-2007, Ext JS, LLC.
36716 * Originally Released Under LGPL - original licence link has changed is not relivant.
36719 * <script type="text/javascript">
36725 * @class Roo.SplitLayoutRegion
36726 * @extends Roo.LayoutRegion
36727 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
36729 Roo.bootstrap.layout.Split = function(config){
36730 this.cursor = config.cursor;
36731 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
36734 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
36736 splitTip : "Drag to resize.",
36737 collapsibleSplitTip : "Drag to resize. Double click to hide.",
36738 useSplitTips : false,
36740 applyConfig : function(config){
36741 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
36744 onRender : function(ctr,pos) {
36746 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
36747 if(!this.config.split){
36752 var splitEl = Roo.DomHelper.append(ctr.dom, {
36754 id: this.el.id + "-split",
36755 cls: "roo-layout-split roo-layout-split-"+this.position,
36758 /** The SplitBar for this region
36759 * @type Roo.SplitBar */
36760 // does not exist yet...
36761 Roo.log([this.position, this.orientation]);
36763 this.split = new Roo.bootstrap.SplitBar({
36764 dragElement : splitEl,
36765 resizingElement: this.el,
36766 orientation : this.orientation
36769 this.split.on("moved", this.onSplitMove, this);
36770 this.split.useShim = this.config.useShim === true;
36771 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
36772 if(this.useSplitTips){
36773 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
36775 //if(config.collapsible){
36776 // this.split.el.on("dblclick", this.collapse, this);
36779 if(typeof this.config.minSize != "undefined"){
36780 this.split.minSize = this.config.minSize;
36782 if(typeof this.config.maxSize != "undefined"){
36783 this.split.maxSize = this.config.maxSize;
36785 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
36786 this.hideSplitter();
36791 getHMaxSize : function(){
36792 var cmax = this.config.maxSize || 10000;
36793 var center = this.mgr.getRegion("center");
36794 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
36797 getVMaxSize : function(){
36798 var cmax = this.config.maxSize || 10000;
36799 var center = this.mgr.getRegion("center");
36800 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
36803 onSplitMove : function(split, newSize){
36804 this.fireEvent("resized", this, newSize);
36808 * Returns the {@link Roo.SplitBar} for this region.
36809 * @return {Roo.SplitBar}
36811 getSplitBar : function(){
36816 this.hideSplitter();
36817 Roo.bootstrap.layout.Split.superclass.hide.call(this);
36820 hideSplitter : function(){
36822 this.split.el.setLocation(-2000,-2000);
36823 this.split.el.hide();
36829 this.split.el.show();
36831 Roo.bootstrap.layout.Split.superclass.show.call(this);
36834 beforeSlide: function(){
36835 if(Roo.isGecko){// firefox overflow auto bug workaround
36836 this.bodyEl.clip();
36838 this.tabs.bodyEl.clip();
36840 if(this.activePanel){
36841 this.activePanel.getEl().clip();
36843 if(this.activePanel.beforeSlide){
36844 this.activePanel.beforeSlide();
36850 afterSlide : function(){
36851 if(Roo.isGecko){// firefox overflow auto bug workaround
36852 this.bodyEl.unclip();
36854 this.tabs.bodyEl.unclip();
36856 if(this.activePanel){
36857 this.activePanel.getEl().unclip();
36858 if(this.activePanel.afterSlide){
36859 this.activePanel.afterSlide();
36865 initAutoHide : function(){
36866 if(this.autoHide !== false){
36867 if(!this.autoHideHd){
36868 var st = new Roo.util.DelayedTask(this.slideIn, this);
36869 this.autoHideHd = {
36870 "mouseout": function(e){
36871 if(!e.within(this.el, true)){
36875 "mouseover" : function(e){
36881 this.el.on(this.autoHideHd);
36885 clearAutoHide : function(){
36886 if(this.autoHide !== false){
36887 this.el.un("mouseout", this.autoHideHd.mouseout);
36888 this.el.un("mouseover", this.autoHideHd.mouseover);
36892 clearMonitor : function(){
36893 Roo.get(document).un("click", this.slideInIf, this);
36896 // these names are backwards but not changed for compat
36897 slideOut : function(){
36898 if(this.isSlid || this.el.hasActiveFx()){
36901 this.isSlid = true;
36902 if(this.collapseBtn){
36903 this.collapseBtn.hide();
36905 this.closeBtnState = this.closeBtn.getStyle('display');
36906 this.closeBtn.hide();
36908 this.stickBtn.show();
36911 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
36912 this.beforeSlide();
36913 this.el.setStyle("z-index", 10001);
36914 this.el.slideIn(this.getSlideAnchor(), {
36915 callback: function(){
36917 this.initAutoHide();
36918 Roo.get(document).on("click", this.slideInIf, this);
36919 this.fireEvent("slideshow", this);
36926 afterSlideIn : function(){
36927 this.clearAutoHide();
36928 this.isSlid = false;
36929 this.clearMonitor();
36930 this.el.setStyle("z-index", "");
36931 if(this.collapseBtn){
36932 this.collapseBtn.show();
36934 this.closeBtn.setStyle('display', this.closeBtnState);
36936 this.stickBtn.hide();
36938 this.fireEvent("slidehide", this);
36941 slideIn : function(cb){
36942 if(!this.isSlid || this.el.hasActiveFx()){
36946 this.isSlid = false;
36947 this.beforeSlide();
36948 this.el.slideOut(this.getSlideAnchor(), {
36949 callback: function(){
36950 this.el.setLeftTop(-10000, -10000);
36952 this.afterSlideIn();
36960 slideInIf : function(e){
36961 if(!e.within(this.el)){
36966 animateCollapse : function(){
36967 this.beforeSlide();
36968 this.el.setStyle("z-index", 20000);
36969 var anchor = this.getSlideAnchor();
36970 this.el.slideOut(anchor, {
36971 callback : function(){
36972 this.el.setStyle("z-index", "");
36973 this.collapsedEl.slideIn(anchor, {duration:.3});
36975 this.el.setLocation(-10000,-10000);
36977 this.fireEvent("collapsed", this);
36984 animateExpand : function(){
36985 this.beforeSlide();
36986 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
36987 this.el.setStyle("z-index", 20000);
36988 this.collapsedEl.hide({
36991 this.el.slideIn(this.getSlideAnchor(), {
36992 callback : function(){
36993 this.el.setStyle("z-index", "");
36996 this.split.el.show();
36998 this.fireEvent("invalidated", this);
36999 this.fireEvent("expanded", this);
37027 getAnchor : function(){
37028 return this.anchors[this.position];
37031 getCollapseAnchor : function(){
37032 return this.canchors[this.position];
37035 getSlideAnchor : function(){
37036 return this.sanchors[this.position];
37039 getAlignAdj : function(){
37040 var cm = this.cmargins;
37041 switch(this.position){
37057 getExpandAdj : function(){
37058 var c = this.collapsedEl, cm = this.cmargins;
37059 switch(this.position){
37061 return [-(cm.right+c.getWidth()+cm.left), 0];
37064 return [cm.right+c.getWidth()+cm.left, 0];
37067 return [0, -(cm.top+cm.bottom+c.getHeight())];
37070 return [0, cm.top+cm.bottom+c.getHeight()];
37076 * Ext JS Library 1.1.1
37077 * Copyright(c) 2006-2007, Ext JS, LLC.
37079 * Originally Released Under LGPL - original licence link has changed is not relivant.
37082 * <script type="text/javascript">
37085 * These classes are private internal classes
37087 Roo.bootstrap.layout.Center = function(config){
37088 config.region = "center";
37089 Roo.bootstrap.layout.Region.call(this, config);
37090 this.visible = true;
37091 this.minWidth = config.minWidth || 20;
37092 this.minHeight = config.minHeight || 20;
37095 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
37097 // center panel can't be hidden
37101 // center panel can't be hidden
37104 getMinWidth: function(){
37105 return this.minWidth;
37108 getMinHeight: function(){
37109 return this.minHeight;
37123 Roo.bootstrap.layout.North = function(config)
37125 config.region = 'north';
37126 config.cursor = 'n-resize';
37128 Roo.bootstrap.layout.Split.call(this, config);
37132 this.split.placement = Roo.bootstrap.SplitBar.TOP;
37133 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
37134 this.split.el.addClass("roo-layout-split-v");
37136 var size = config.initialSize || config.height;
37137 if(typeof size != "undefined"){
37138 this.el.setHeight(size);
37141 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
37143 orientation: Roo.bootstrap.SplitBar.VERTICAL,
37147 getBox : function(){
37148 if(this.collapsed){
37149 return this.collapsedEl.getBox();
37151 var box = this.el.getBox();
37153 box.height += this.split.el.getHeight();
37158 updateBox : function(box){
37159 if(this.split && !this.collapsed){
37160 box.height -= this.split.el.getHeight();
37161 this.split.el.setLeft(box.x);
37162 this.split.el.setTop(box.y+box.height);
37163 this.split.el.setWidth(box.width);
37165 if(this.collapsed){
37166 this.updateBody(box.width, null);
37168 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37176 Roo.bootstrap.layout.South = function(config){
37177 config.region = 'south';
37178 config.cursor = 's-resize';
37179 Roo.bootstrap.layout.Split.call(this, config);
37181 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
37182 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
37183 this.split.el.addClass("roo-layout-split-v");
37185 var size = config.initialSize || config.height;
37186 if(typeof size != "undefined"){
37187 this.el.setHeight(size);
37191 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
37192 orientation: Roo.bootstrap.SplitBar.VERTICAL,
37193 getBox : function(){
37194 if(this.collapsed){
37195 return this.collapsedEl.getBox();
37197 var box = this.el.getBox();
37199 var sh = this.split.el.getHeight();
37206 updateBox : function(box){
37207 if(this.split && !this.collapsed){
37208 var sh = this.split.el.getHeight();
37211 this.split.el.setLeft(box.x);
37212 this.split.el.setTop(box.y-sh);
37213 this.split.el.setWidth(box.width);
37215 if(this.collapsed){
37216 this.updateBody(box.width, null);
37218 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37222 Roo.bootstrap.layout.East = function(config){
37223 config.region = "east";
37224 config.cursor = "e-resize";
37225 Roo.bootstrap.layout.Split.call(this, config);
37227 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
37228 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
37229 this.split.el.addClass("roo-layout-split-h");
37231 var size = config.initialSize || config.width;
37232 if(typeof size != "undefined"){
37233 this.el.setWidth(size);
37236 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
37237 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
37238 getBox : function(){
37239 if(this.collapsed){
37240 return this.collapsedEl.getBox();
37242 var box = this.el.getBox();
37244 var sw = this.split.el.getWidth();
37251 updateBox : function(box){
37252 if(this.split && !this.collapsed){
37253 var sw = this.split.el.getWidth();
37255 this.split.el.setLeft(box.x);
37256 this.split.el.setTop(box.y);
37257 this.split.el.setHeight(box.height);
37260 if(this.collapsed){
37261 this.updateBody(null, box.height);
37263 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37267 Roo.bootstrap.layout.West = function(config){
37268 config.region = "west";
37269 config.cursor = "w-resize";
37271 Roo.bootstrap.layout.Split.call(this, config);
37273 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
37274 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
37275 this.split.el.addClass("roo-layout-split-h");
37279 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
37280 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
37282 onRender: function(ctr, pos)
37284 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
37285 var size = this.config.initialSize || this.config.width;
37286 if(typeof size != "undefined"){
37287 this.el.setWidth(size);
37291 getBox : function(){
37292 if(this.collapsed){
37293 return this.collapsedEl.getBox();
37295 var box = this.el.getBox();
37297 box.width += this.split.el.getWidth();
37302 updateBox : function(box){
37303 if(this.split && !this.collapsed){
37304 var sw = this.split.el.getWidth();
37306 this.split.el.setLeft(box.x+box.width);
37307 this.split.el.setTop(box.y);
37308 this.split.el.setHeight(box.height);
37310 if(this.collapsed){
37311 this.updateBody(null, box.height);
37313 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
37315 });Roo.namespace("Roo.bootstrap.panel");/*
37317 * Ext JS Library 1.1.1
37318 * Copyright(c) 2006-2007, Ext JS, LLC.
37320 * Originally Released Under LGPL - original licence link has changed is not relivant.
37323 * <script type="text/javascript">
37326 * @class Roo.ContentPanel
37327 * @extends Roo.util.Observable
37328 * A basic ContentPanel element.
37329 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
37330 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
37331 * @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
37332 * @cfg {Boolean} closable True if the panel can be closed/removed
37333 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
37334 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
37335 * @cfg {Toolbar} toolbar A toolbar for this panel
37336 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
37337 * @cfg {String} title The title for this panel
37338 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
37339 * @cfg {String} url Calls {@link #setUrl} with this value
37340 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
37341 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
37342 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
37343 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
37344 * @cfg {Boolean} badges render the badges
37347 * Create a new ContentPanel.
37348 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
37349 * @param {String/Object} config A string to set only the title or a config object
37350 * @param {String} content (optional) Set the HTML content for this panel
37351 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
37353 Roo.bootstrap.panel.Content = function( config){
37355 this.tpl = config.tpl || false;
37357 var el = config.el;
37358 var content = config.content;
37360 if(config.autoCreate){ // xtype is available if this is called from factory
37363 this.el = Roo.get(el);
37364 if(!this.el && config && config.autoCreate){
37365 if(typeof config.autoCreate == "object"){
37366 if(!config.autoCreate.id){
37367 config.autoCreate.id = config.id||el;
37369 this.el = Roo.DomHelper.append(document.body,
37370 config.autoCreate, true);
37372 var elcfg = { tag: "div",
37373 cls: "roo-layout-inactive-content",
37377 elcfg.html = config.html;
37381 this.el = Roo.DomHelper.append(document.body, elcfg , true);
37384 this.closable = false;
37385 this.loaded = false;
37386 this.active = false;
37389 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
37391 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
37393 this.wrapEl = this.el; //this.el.wrap();
37395 if (config.toolbar.items) {
37396 ti = config.toolbar.items ;
37397 delete config.toolbar.items ;
37401 this.toolbar.render(this.wrapEl, 'before');
37402 for(var i =0;i < ti.length;i++) {
37403 // Roo.log(['add child', items[i]]);
37404 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37406 this.toolbar.items = nitems;
37407 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
37408 delete config.toolbar;
37412 // xtype created footer. - not sure if will work as we normally have to render first..
37413 if (this.footer && !this.footer.el && this.footer.xtype) {
37414 if (!this.wrapEl) {
37415 this.wrapEl = this.el.wrap();
37418 this.footer.container = this.wrapEl.createChild();
37420 this.footer = Roo.factory(this.footer, Roo);
37425 if(typeof config == "string"){
37426 this.title = config;
37428 Roo.apply(this, config);
37432 this.resizeEl = Roo.get(this.resizeEl, true);
37434 this.resizeEl = this.el;
37436 // handle view.xtype
37444 * Fires when this panel is activated.
37445 * @param {Roo.ContentPanel} this
37449 * @event deactivate
37450 * Fires when this panel is activated.
37451 * @param {Roo.ContentPanel} this
37453 "deactivate" : true,
37457 * Fires when this panel is resized if fitToFrame is true.
37458 * @param {Roo.ContentPanel} this
37459 * @param {Number} width The width after any component adjustments
37460 * @param {Number} height The height after any component adjustments
37466 * Fires when this tab is created
37467 * @param {Roo.ContentPanel} this
37478 if(this.autoScroll){
37479 this.resizeEl.setStyle("overflow", "auto");
37481 // fix randome scrolling
37482 //this.el.on('scroll', function() {
37483 // Roo.log('fix random scolling');
37484 // this.scrollTo('top',0);
37487 content = content || this.content;
37489 this.setContent(content);
37491 if(config && config.url){
37492 this.setUrl(this.url, this.params, this.loadOnce);
37497 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
37499 if (this.view && typeof(this.view.xtype) != 'undefined') {
37500 this.view.el = this.el.appendChild(document.createElement("div"));
37501 this.view = Roo.factory(this.view);
37502 this.view.render && this.view.render(false, '');
37506 this.fireEvent('render', this);
37509 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
37513 setRegion : function(region){
37514 this.region = region;
37515 this.setActiveClass(region && !this.background);
37519 setActiveClass: function(state)
37522 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
37523 this.el.setStyle('position','relative');
37525 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
37526 this.el.setStyle('position', 'absolute');
37531 * Returns the toolbar for this Panel if one was configured.
37532 * @return {Roo.Toolbar}
37534 getToolbar : function(){
37535 return this.toolbar;
37538 setActiveState : function(active)
37540 this.active = active;
37541 this.setActiveClass(active);
37543 if(this.fireEvent("deactivate", this) === false){
37548 this.fireEvent("activate", this);
37552 * Updates this panel's element
37553 * @param {String} content The new content
37554 * @param {Boolean} loadScripts (optional) true to look for and process scripts
37556 setContent : function(content, loadScripts){
37557 this.el.update(content, loadScripts);
37560 ignoreResize : function(w, h){
37561 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
37564 this.lastSize = {width: w, height: h};
37569 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
37570 * @return {Roo.UpdateManager} The UpdateManager
37572 getUpdateManager : function(){
37573 return this.el.getUpdateManager();
37576 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
37577 * @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:
37580 url: "your-url.php",
37581 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
37582 callback: yourFunction,
37583 scope: yourObject, //(optional scope)
37586 text: "Loading...",
37591 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
37592 * 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.
37593 * @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}
37594 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
37595 * @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.
37596 * @return {Roo.ContentPanel} this
37599 var um = this.el.getUpdateManager();
37600 um.update.apply(um, arguments);
37606 * 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.
37607 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
37608 * @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)
37609 * @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)
37610 * @return {Roo.UpdateManager} The UpdateManager
37612 setUrl : function(url, params, loadOnce){
37613 if(this.refreshDelegate){
37614 this.removeListener("activate", this.refreshDelegate);
37616 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
37617 this.on("activate", this.refreshDelegate);
37618 return this.el.getUpdateManager();
37621 _handleRefresh : function(url, params, loadOnce){
37622 if(!loadOnce || !this.loaded){
37623 var updater = this.el.getUpdateManager();
37624 updater.update(url, params, this._setLoaded.createDelegate(this));
37628 _setLoaded : function(){
37629 this.loaded = true;
37633 * Returns this panel's id
37636 getId : function(){
37641 * Returns this panel's element - used by regiosn to add.
37642 * @return {Roo.Element}
37644 getEl : function(){
37645 return this.wrapEl || this.el;
37650 adjustForComponents : function(width, height)
37652 //Roo.log('adjustForComponents ');
37653 if(this.resizeEl != this.el){
37654 width -= this.el.getFrameWidth('lr');
37655 height -= this.el.getFrameWidth('tb');
37658 var te = this.toolbar.getEl();
37659 te.setWidth(width);
37660 height -= te.getHeight();
37663 var te = this.footer.getEl();
37664 te.setWidth(width);
37665 height -= te.getHeight();
37669 if(this.adjustments){
37670 width += this.adjustments[0];
37671 height += this.adjustments[1];
37673 return {"width": width, "height": height};
37676 setSize : function(width, height){
37677 if(this.fitToFrame && !this.ignoreResize(width, height)){
37678 if(this.fitContainer && this.resizeEl != this.el){
37679 this.el.setSize(width, height);
37681 var size = this.adjustForComponents(width, height);
37682 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
37683 this.fireEvent('resize', this, size.width, size.height);
37688 * Returns this panel's title
37691 getTitle : function(){
37693 if (typeof(this.title) != 'object') {
37698 for (var k in this.title) {
37699 if (!this.title.hasOwnProperty(k)) {
37703 if (k.indexOf('-') >= 0) {
37704 var s = k.split('-');
37705 for (var i = 0; i<s.length; i++) {
37706 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
37709 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
37716 * Set this panel's title
37717 * @param {String} title
37719 setTitle : function(title){
37720 this.title = title;
37722 this.region.updatePanelTitle(this, title);
37727 * Returns true is this panel was configured to be closable
37728 * @return {Boolean}
37730 isClosable : function(){
37731 return this.closable;
37734 beforeSlide : function(){
37736 this.resizeEl.clip();
37739 afterSlide : function(){
37741 this.resizeEl.unclip();
37745 * Force a content refresh from the URL specified in the {@link #setUrl} method.
37746 * Will fail silently if the {@link #setUrl} method has not been called.
37747 * This does not activate the panel, just updates its content.
37749 refresh : function(){
37750 if(this.refreshDelegate){
37751 this.loaded = false;
37752 this.refreshDelegate();
37757 * Destroys this panel
37759 destroy : function(){
37760 this.el.removeAllListeners();
37761 var tempEl = document.createElement("span");
37762 tempEl.appendChild(this.el.dom);
37763 tempEl.innerHTML = "";
37769 * form - if the content panel contains a form - this is a reference to it.
37770 * @type {Roo.form.Form}
37774 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
37775 * This contains a reference to it.
37781 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
37791 * @param {Object} cfg Xtype definition of item to add.
37795 getChildContainer: function () {
37796 return this.getEl();
37801 var ret = new Roo.factory(cfg);
37806 if (cfg.xtype.match(/^Form$/)) {
37809 //if (this.footer) {
37810 // el = this.footer.container.insertSibling(false, 'before');
37812 el = this.el.createChild();
37815 this.form = new Roo.form.Form(cfg);
37818 if ( this.form.allItems.length) {
37819 this.form.render(el.dom);
37823 // should only have one of theses..
37824 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
37825 // views.. should not be just added - used named prop 'view''
37827 cfg.el = this.el.appendChild(document.createElement("div"));
37830 var ret = new Roo.factory(cfg);
37832 ret.render && ret.render(false, ''); // render blank..
37842 * @class Roo.bootstrap.panel.Grid
37843 * @extends Roo.bootstrap.panel.Content
37845 * Create a new GridPanel.
37846 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
37847 * @param {Object} config A the config object
37853 Roo.bootstrap.panel.Grid = function(config)
37857 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
37858 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
37860 config.el = this.wrapper;
37861 //this.el = this.wrapper;
37863 if (config.container) {
37864 // ctor'ed from a Border/panel.grid
37867 this.wrapper.setStyle("overflow", "hidden");
37868 this.wrapper.addClass('roo-grid-container');
37873 if(config.toolbar){
37874 var tool_el = this.wrapper.createChild();
37875 this.toolbar = Roo.factory(config.toolbar);
37877 if (config.toolbar.items) {
37878 ti = config.toolbar.items ;
37879 delete config.toolbar.items ;
37883 this.toolbar.render(tool_el);
37884 for(var i =0;i < ti.length;i++) {
37885 // Roo.log(['add child', items[i]]);
37886 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37888 this.toolbar.items = nitems;
37890 delete config.toolbar;
37893 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
37894 config.grid.scrollBody = true;;
37895 config.grid.monitorWindowResize = false; // turn off autosizing
37896 config.grid.autoHeight = false;
37897 config.grid.autoWidth = false;
37899 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
37901 if (config.background) {
37902 // render grid on panel activation (if panel background)
37903 this.on('activate', function(gp) {
37904 if (!gp.grid.rendered) {
37905 gp.grid.render(this.wrapper);
37906 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37911 this.grid.render(this.wrapper);
37912 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37915 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
37916 // ??? needed ??? config.el = this.wrapper;
37921 // xtype created footer. - not sure if will work as we normally have to render first..
37922 if (this.footer && !this.footer.el && this.footer.xtype) {
37924 var ctr = this.grid.getView().getFooterPanel(true);
37925 this.footer.dataSource = this.grid.dataSource;
37926 this.footer = Roo.factory(this.footer, Roo);
37927 this.footer.render(ctr);
37937 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
37938 getId : function(){
37939 return this.grid.id;
37943 * Returns the grid for this panel
37944 * @return {Roo.bootstrap.Table}
37946 getGrid : function(){
37950 setSize : function(width, height){
37951 if(!this.ignoreResize(width, height)){
37952 var grid = this.grid;
37953 var size = this.adjustForComponents(width, height);
37954 var gridel = grid.getGridEl();
37955 gridel.setSize(size.width, size.height);
37957 var thd = grid.getGridEl().select('thead',true).first();
37958 var tbd = grid.getGridEl().select('tbody', true).first();
37960 tbd.setSize(width, height - thd.getHeight());
37969 beforeSlide : function(){
37970 this.grid.getView().scroller.clip();
37973 afterSlide : function(){
37974 this.grid.getView().scroller.unclip();
37977 destroy : function(){
37978 this.grid.destroy();
37980 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
37985 * @class Roo.bootstrap.panel.Nest
37986 * @extends Roo.bootstrap.panel.Content
37988 * Create a new Panel, that can contain a layout.Border.
37991 * @param {Roo.BorderLayout} layout The layout for this panel
37992 * @param {String/Object} config A string to set only the title or a config object
37994 Roo.bootstrap.panel.Nest = function(config)
37996 // construct with only one argument..
37997 /* FIXME - implement nicer consturctors
37998 if (layout.layout) {
38000 layout = config.layout;
38001 delete config.layout;
38003 if (layout.xtype && !layout.getEl) {
38004 // then layout needs constructing..
38005 layout = Roo.factory(layout, Roo);
38009 config.el = config.layout.getEl();
38011 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
38013 config.layout.monitorWindowResize = false; // turn off autosizing
38014 this.layout = config.layout;
38015 this.layout.getEl().addClass("roo-layout-nested-layout");
38016 this.layout.parent = this;
38023 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
38025 setSize : function(width, height){
38026 if(!this.ignoreResize(width, height)){
38027 var size = this.adjustForComponents(width, height);
38028 var el = this.layout.getEl();
38029 if (size.height < 1) {
38030 el.setWidth(size.width);
38032 el.setSize(size.width, size.height);
38034 var touch = el.dom.offsetWidth;
38035 this.layout.layout();
38036 // ie requires a double layout on the first pass
38037 if(Roo.isIE && !this.initialized){
38038 this.initialized = true;
38039 this.layout.layout();
38044 // activate all subpanels if not currently active..
38046 setActiveState : function(active){
38047 this.active = active;
38048 this.setActiveClass(active);
38051 this.fireEvent("deactivate", this);
38055 this.fireEvent("activate", this);
38056 // not sure if this should happen before or after..
38057 if (!this.layout) {
38058 return; // should not happen..
38061 for (var r in this.layout.regions) {
38062 reg = this.layout.getRegion(r);
38063 if (reg.getActivePanel()) {
38064 //reg.showPanel(reg.getActivePanel()); // force it to activate..
38065 reg.setActivePanel(reg.getActivePanel());
38068 if (!reg.panels.length) {
38071 reg.showPanel(reg.getPanel(0));
38080 * Returns the nested BorderLayout for this panel
38081 * @return {Roo.BorderLayout}
38083 getLayout : function(){
38084 return this.layout;
38088 * Adds a xtype elements to the layout of the nested panel
38092 xtype : 'ContentPanel',
38099 xtype : 'NestedLayoutPanel',
38105 items : [ ... list of content panels or nested layout panels.. ]
38109 * @param {Object} cfg Xtype definition of item to add.
38111 addxtype : function(cfg) {
38112 return this.layout.addxtype(cfg);
38117 * Ext JS Library 1.1.1
38118 * Copyright(c) 2006-2007, Ext JS, LLC.
38120 * Originally Released Under LGPL - original licence link has changed is not relivant.
38123 * <script type="text/javascript">
38126 * @class Roo.TabPanel
38127 * @extends Roo.util.Observable
38128 * A lightweight tab container.
38132 // basic tabs 1, built from existing content
38133 var tabs = new Roo.TabPanel("tabs1");
38134 tabs.addTab("script", "View Script");
38135 tabs.addTab("markup", "View Markup");
38136 tabs.activate("script");
38138 // more advanced tabs, built from javascript
38139 var jtabs = new Roo.TabPanel("jtabs");
38140 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
38142 // set up the UpdateManager
38143 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
38144 var updater = tab2.getUpdateManager();
38145 updater.setDefaultUrl("ajax1.htm");
38146 tab2.on('activate', updater.refresh, updater, true);
38148 // Use setUrl for Ajax loading
38149 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
38150 tab3.setUrl("ajax2.htm", null, true);
38153 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
38156 jtabs.activate("jtabs-1");
38159 * Create a new TabPanel.
38160 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
38161 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
38163 Roo.bootstrap.panel.Tabs = function(config){
38165 * The container element for this TabPanel.
38166 * @type Roo.Element
38168 this.el = Roo.get(config.el);
38171 if(typeof config == "boolean"){
38172 this.tabPosition = config ? "bottom" : "top";
38174 Roo.apply(this, config);
38178 if(this.tabPosition == "bottom"){
38179 // if tabs are at the bottom = create the body first.
38180 this.bodyEl = Roo.get(this.createBody(this.el.dom));
38181 this.el.addClass("roo-tabs-bottom");
38183 // next create the tabs holders
38185 if (this.tabPosition == "west"){
38187 var reg = this.region; // fake it..
38189 if (!reg.mgr.parent) {
38192 reg = reg.mgr.parent.region;
38194 Roo.log("got nest?");
38196 if (reg.mgr.getRegion('west')) {
38197 var ctrdom = reg.mgr.getRegion('west').bodyEl.dom;
38198 this.stripWrap = Roo.get(this.createStrip(ctrdom ), true);
38199 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
38200 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
38201 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
38209 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
38210 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
38211 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
38212 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
38217 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
38220 // finally - if tabs are at the top, then create the body last..
38221 if(this.tabPosition != "bottom"){
38222 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
38223 * @type Roo.Element
38225 this.bodyEl = Roo.get(this.createBody(this.el.dom));
38226 this.el.addClass("roo-tabs-top");
38230 this.bodyEl.setStyle("position", "relative");
38232 this.active = null;
38233 this.activateDelegate = this.activate.createDelegate(this);
38238 * Fires when the active tab changes
38239 * @param {Roo.TabPanel} this
38240 * @param {Roo.TabPanelItem} activePanel The new active tab
38244 * @event beforetabchange
38245 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
38246 * @param {Roo.TabPanel} this
38247 * @param {Object} e Set cancel to true on this object to cancel the tab change
38248 * @param {Roo.TabPanelItem} tab The tab being changed to
38250 "beforetabchange" : true
38253 Roo.EventManager.onWindowResize(this.onResize, this);
38254 this.cpad = this.el.getPadding("lr");
38255 this.hiddenCount = 0;
38258 // toolbar on the tabbar support...
38259 if (this.toolbar) {
38260 alert("no toolbar support yet");
38261 this.toolbar = false;
38263 var tcfg = this.toolbar;
38264 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
38265 this.toolbar = new Roo.Toolbar(tcfg);
38266 if (Roo.isSafari) {
38267 var tbl = tcfg.container.child('table', true);
38268 tbl.setAttribute('width', '100%');
38276 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
38279 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
38281 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
38283 tabPosition : "top",
38285 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
38287 currentTabWidth : 0,
38289 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
38293 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
38297 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
38299 preferredTabWidth : 175,
38301 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
38303 resizeTabs : false,
38305 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
38307 monitorResize : true,
38309 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
38311 toolbar : false, // set by caller..
38313 region : false, /// set by caller
38315 disableTooltips : true, // not used yet...
38318 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
38319 * @param {String} id The id of the div to use <b>or create</b>
38320 * @param {String} text The text for the tab
38321 * @param {String} content (optional) Content to put in the TabPanelItem body
38322 * @param {Boolean} closable (optional) True to create a close icon on the tab
38323 * @return {Roo.TabPanelItem} The created TabPanelItem
38325 addTab : function(id, text, content, closable, tpl)
38327 var item = new Roo.bootstrap.panel.TabItem({
38331 closable : closable,
38334 this.addTabItem(item);
38336 item.setContent(content);
38342 * Returns the {@link Roo.TabPanelItem} with the specified id/index
38343 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
38344 * @return {Roo.TabPanelItem}
38346 getTab : function(id){
38347 return this.items[id];
38351 * Hides the {@link Roo.TabPanelItem} with the specified id/index
38352 * @param {String/Number} id The id or index of the TabPanelItem to hide.
38354 hideTab : function(id){
38355 var t = this.items[id];
38358 this.hiddenCount++;
38359 this.autoSizeTabs();
38364 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
38365 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
38367 unhideTab : function(id){
38368 var t = this.items[id];
38370 t.setHidden(false);
38371 this.hiddenCount--;
38372 this.autoSizeTabs();
38377 * Adds an existing {@link Roo.TabPanelItem}.
38378 * @param {Roo.TabPanelItem} item The TabPanelItem to add
38380 addTabItem : function(item)
38382 this.items[item.id] = item;
38383 this.items.push(item);
38384 this.autoSizeTabs();
38385 // if(this.resizeTabs){
38386 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
38387 // this.autoSizeTabs();
38389 // item.autoSize();
38394 * Removes a {@link Roo.TabPanelItem}.
38395 * @param {String/Number} id The id or index of the TabPanelItem to remove.
38397 removeTab : function(id){
38398 var items = this.items;
38399 var tab = items[id];
38400 if(!tab) { return; }
38401 var index = items.indexOf(tab);
38402 if(this.active == tab && items.length > 1){
38403 var newTab = this.getNextAvailable(index);
38408 this.stripEl.dom.removeChild(tab.pnode.dom);
38409 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
38410 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
38412 items.splice(index, 1);
38413 delete this.items[tab.id];
38414 tab.fireEvent("close", tab);
38415 tab.purgeListeners();
38416 this.autoSizeTabs();
38419 getNextAvailable : function(start){
38420 var items = this.items;
38422 // look for a next tab that will slide over to
38423 // replace the one being removed
38424 while(index < items.length){
38425 var item = items[++index];
38426 if(item && !item.isHidden()){
38430 // if one isn't found select the previous tab (on the left)
38433 var item = items[--index];
38434 if(item && !item.isHidden()){
38442 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
38443 * @param {String/Number} id The id or index of the TabPanelItem to disable.
38445 disableTab : function(id){
38446 var tab = this.items[id];
38447 if(tab && this.active != tab){
38453 * Enables a {@link Roo.TabPanelItem} that is disabled.
38454 * @param {String/Number} id The id or index of the TabPanelItem to enable.
38456 enableTab : function(id){
38457 var tab = this.items[id];
38462 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
38463 * @param {String/Number} id The id or index of the TabPanelItem to activate.
38464 * @return {Roo.TabPanelItem} The TabPanelItem.
38466 activate : function(id)
38468 //Roo.log('activite:' + id);
38470 var tab = this.items[id];
38474 if(tab == this.active || tab.disabled){
38478 this.fireEvent("beforetabchange", this, e, tab);
38479 if(e.cancel !== true && !tab.disabled){
38481 this.active.hide();
38483 this.active = this.items[id];
38484 this.active.show();
38485 this.fireEvent("tabchange", this, this.active);
38491 * Gets the active {@link Roo.TabPanelItem}.
38492 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
38494 getActiveTab : function(){
38495 return this.active;
38499 * Updates the tab body element to fit the height of the container element
38500 * for overflow scrolling
38501 * @param {Number} targetHeight (optional) Override the starting height from the elements height
38503 syncHeight : function(targetHeight){
38504 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
38505 var bm = this.bodyEl.getMargins();
38506 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
38507 this.bodyEl.setHeight(newHeight);
38511 onResize : function(){
38512 if(this.monitorResize){
38513 this.autoSizeTabs();
38518 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
38520 beginUpdate : function(){
38521 this.updating = true;
38525 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
38527 endUpdate : function(){
38528 this.updating = false;
38529 this.autoSizeTabs();
38533 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
38535 autoSizeTabs : function()
38537 var count = this.items.length;
38538 var vcount = count - this.hiddenCount;
38541 this.stripEl.hide();
38543 this.stripEl.show();
38546 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
38551 var w = Math.max(this.el.getWidth() - this.cpad, 10);
38552 var availWidth = Math.floor(w / vcount);
38553 var b = this.stripBody;
38554 if(b.getWidth() > w){
38555 var tabs = this.items;
38556 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
38557 if(availWidth < this.minTabWidth){
38558 /*if(!this.sleft){ // incomplete scrolling code
38559 this.createScrollButtons();
38562 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
38565 if(this.currentTabWidth < this.preferredTabWidth){
38566 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
38572 * Returns the number of tabs in this TabPanel.
38575 getCount : function(){
38576 return this.items.length;
38580 * Resizes all the tabs to the passed width
38581 * @param {Number} The new width
38583 setTabWidth : function(width){
38584 this.currentTabWidth = width;
38585 for(var i = 0, len = this.items.length; i < len; i++) {
38586 if(!this.items[i].isHidden()) {
38587 this.items[i].setWidth(width);
38593 * Destroys this TabPanel
38594 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
38596 destroy : function(removeEl){
38597 Roo.EventManager.removeResizeListener(this.onResize, this);
38598 for(var i = 0, len = this.items.length; i < len; i++){
38599 this.items[i].purgeListeners();
38601 if(removeEl === true){
38602 this.el.update("");
38607 createStrip : function(container)
38609 var strip = document.createElement("nav");
38610 strip.className = Roo.bootstrap.version == 4 ?
38611 "navbar-light bg-light" :
38612 "navbar navbar-default"; //"x-tabs-wrap";
38613 container.appendChild(strip);
38617 createStripList : function(strip)
38619 // div wrapper for retard IE
38620 // returns the "tr" element.
38621 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
38622 //'<div class="x-tabs-strip-wrap">'+
38623 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
38624 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
38625 return strip.firstChild; //.firstChild.firstChild.firstChild;
38627 createBody : function(container)
38629 var body = document.createElement("div");
38630 Roo.id(body, "tab-body");
38631 //Roo.fly(body).addClass("x-tabs-body");
38632 Roo.fly(body).addClass("tab-content");
38633 container.appendChild(body);
38636 createItemBody :function(bodyEl, id){
38637 var body = Roo.getDom(id);
38639 body = document.createElement("div");
38642 //Roo.fly(body).addClass("x-tabs-item-body");
38643 Roo.fly(body).addClass("tab-pane");
38644 bodyEl.insertBefore(body, bodyEl.firstChild);
38648 createStripElements : function(stripEl, text, closable, tpl)
38650 var td = document.createElement("li"); // was td..
38651 td.className = 'nav-item';
38653 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
38656 stripEl.appendChild(td);
38658 td.className = "x-tabs-closable";
38659 if(!this.closeTpl){
38660 this.closeTpl = new Roo.Template(
38661 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38662 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
38663 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
38666 var el = this.closeTpl.overwrite(td, {"text": text});
38667 var close = el.getElementsByTagName("div")[0];
38668 var inner = el.getElementsByTagName("em")[0];
38669 return {"el": el, "close": close, "inner": inner};
38672 // not sure what this is..
38673 // if(!this.tabTpl){
38674 //this.tabTpl = new Roo.Template(
38675 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38676 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
38678 // this.tabTpl = new Roo.Template(
38679 // '<a href="#">' +
38680 // '<span unselectable="on"' +
38681 // (this.disableTooltips ? '' : ' title="{text}"') +
38682 // ' >{text}</span></a>'
38688 var template = tpl || this.tabTpl || false;
38691 template = new Roo.Template(
38692 Roo.bootstrap.version == 4 ?
38694 '<a class="nav-link" href="#" unselectable="on"' +
38695 (this.disableTooltips ? '' : ' title="{text}"') +
38698 '<a class="nav-link" href="#">' +
38699 '<span unselectable="on"' +
38700 (this.disableTooltips ? '' : ' title="{text}"') +
38701 ' >{text}</span></a>'
38706 switch (typeof(template)) {
38710 template = new Roo.Template(template);
38716 var el = template.overwrite(td, {"text": text});
38718 var inner = el.getElementsByTagName("span")[0];
38720 return {"el": el, "inner": inner};
38728 * @class Roo.TabPanelItem
38729 * @extends Roo.util.Observable
38730 * Represents an individual item (tab plus body) in a TabPanel.
38731 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
38732 * @param {String} id The id of this TabPanelItem
38733 * @param {String} text The text for the tab of this TabPanelItem
38734 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
38736 Roo.bootstrap.panel.TabItem = function(config){
38738 * The {@link Roo.TabPanel} this TabPanelItem belongs to
38739 * @type Roo.TabPanel
38741 this.tabPanel = config.panel;
38743 * The id for this TabPanelItem
38746 this.id = config.id;
38748 this.disabled = false;
38750 this.text = config.text;
38752 this.loaded = false;
38753 this.closable = config.closable;
38756 * The body element for this TabPanelItem.
38757 * @type Roo.Element
38759 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
38760 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
38761 this.bodyEl.setStyle("display", "block");
38762 this.bodyEl.setStyle("zoom", "1");
38763 //this.hideAction();
38765 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
38767 this.el = Roo.get(els.el);
38768 this.inner = Roo.get(els.inner, true);
38769 this.textEl = Roo.bootstrap.version == 4 ?
38770 this.el : Roo.get(this.el.dom.firstChild, true);
38772 this.pnode = this.linode = Roo.get(els.el.parentNode, true);
38773 this.status_node = Roo.bootstrap.version == 4 ? this.el : this.linode;
38776 // this.el.on("mousedown", this.onTabMouseDown, this);
38777 this.el.on("click", this.onTabClick, this);
38779 if(config.closable){
38780 var c = Roo.get(els.close, true);
38781 c.dom.title = this.closeText;
38782 c.addClassOnOver("close-over");
38783 c.on("click", this.closeClick, this);
38789 * Fires when this tab becomes the active tab.
38790 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38791 * @param {Roo.TabPanelItem} this
38795 * @event beforeclose
38796 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
38797 * @param {Roo.TabPanelItem} this
38798 * @param {Object} e Set cancel to true on this object to cancel the close.
38800 "beforeclose": true,
38803 * Fires when this tab is closed.
38804 * @param {Roo.TabPanelItem} this
38808 * @event deactivate
38809 * Fires when this tab is no longer the active tab.
38810 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38811 * @param {Roo.TabPanelItem} this
38813 "deactivate" : true
38815 this.hidden = false;
38817 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
38820 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
38822 purgeListeners : function(){
38823 Roo.util.Observable.prototype.purgeListeners.call(this);
38824 this.el.removeAllListeners();
38827 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
38830 this.status_node.addClass("active");
38833 this.tabPanel.stripWrap.repaint();
38835 this.fireEvent("activate", this.tabPanel, this);
38839 * Returns true if this tab is the active tab.
38840 * @return {Boolean}
38842 isActive : function(){
38843 return this.tabPanel.getActiveTab() == this;
38847 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
38850 this.status_node.removeClass("active");
38852 this.fireEvent("deactivate", this.tabPanel, this);
38855 hideAction : function(){
38856 this.bodyEl.hide();
38857 this.bodyEl.setStyle("position", "absolute");
38858 this.bodyEl.setLeft("-20000px");
38859 this.bodyEl.setTop("-20000px");
38862 showAction : function(){
38863 this.bodyEl.setStyle("position", "relative");
38864 this.bodyEl.setTop("");
38865 this.bodyEl.setLeft("");
38866 this.bodyEl.show();
38870 * Set the tooltip for the tab.
38871 * @param {String} tooltip The tab's tooltip
38873 setTooltip : function(text){
38874 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
38875 this.textEl.dom.qtip = text;
38876 this.textEl.dom.removeAttribute('title');
38878 this.textEl.dom.title = text;
38882 onTabClick : function(e){
38883 e.preventDefault();
38884 this.tabPanel.activate(this.id);
38887 onTabMouseDown : function(e){
38888 e.preventDefault();
38889 this.tabPanel.activate(this.id);
38892 getWidth : function(){
38893 return this.inner.getWidth();
38896 setWidth : function(width){
38897 var iwidth = width - this.linode.getPadding("lr");
38898 this.inner.setWidth(iwidth);
38899 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
38900 this.linode.setWidth(width);
38904 * Show or hide the tab
38905 * @param {Boolean} hidden True to hide or false to show.
38907 setHidden : function(hidden){
38908 this.hidden = hidden;
38909 this.linode.setStyle("display", hidden ? "none" : "");
38913 * Returns true if this tab is "hidden"
38914 * @return {Boolean}
38916 isHidden : function(){
38917 return this.hidden;
38921 * Returns the text for this tab
38924 getText : function(){
38928 autoSize : function(){
38929 //this.el.beginMeasure();
38930 this.textEl.setWidth(1);
38932 * #2804 [new] Tabs in Roojs
38933 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
38935 //this.setWidth(this.textEl.dom.scrollWidth+this.linode.getPadding("lr")+this.inner.getPadding("lr") + 2);
38936 //this.el.endMeasure();
38940 * Sets the text for the tab (Note: this also sets the tooltip text)
38941 * @param {String} text The tab's text and tooltip
38943 setText : function(text){
38945 this.textEl.update(text);
38946 this.setTooltip(text);
38947 //if(!this.tabPanel.resizeTabs){
38948 // this.autoSize();
38952 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
38954 activate : function(){
38955 this.tabPanel.activate(this.id);
38959 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
38961 disable : function(){
38962 if(this.tabPanel.active != this){
38963 this.disabled = true;
38964 this.status_node.addClass("disabled");
38969 * Enables this TabPanelItem if it was previously disabled.
38971 enable : function(){
38972 this.disabled = false;
38973 this.status_node.removeClass("disabled");
38977 * Sets the content for this TabPanelItem.
38978 * @param {String} content The content
38979 * @param {Boolean} loadScripts true to look for and load scripts
38981 setContent : function(content, loadScripts){
38982 this.bodyEl.update(content, loadScripts);
38986 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
38987 * @return {Roo.UpdateManager} The UpdateManager
38989 getUpdateManager : function(){
38990 return this.bodyEl.getUpdateManager();
38994 * Set a URL to be used to load the content for this TabPanelItem.
38995 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
38996 * @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)
38997 * @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)
38998 * @return {Roo.UpdateManager} The UpdateManager
39000 setUrl : function(url, params, loadOnce){
39001 if(this.refreshDelegate){
39002 this.un('activate', this.refreshDelegate);
39004 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
39005 this.on("activate", this.refreshDelegate);
39006 return this.bodyEl.getUpdateManager();
39010 _handleRefresh : function(url, params, loadOnce){
39011 if(!loadOnce || !this.loaded){
39012 var updater = this.bodyEl.getUpdateManager();
39013 updater.update(url, params, this._setLoaded.createDelegate(this));
39018 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
39019 * Will fail silently if the setUrl method has not been called.
39020 * This does not activate the panel, just updates its content.
39022 refresh : function(){
39023 if(this.refreshDelegate){
39024 this.loaded = false;
39025 this.refreshDelegate();
39030 _setLoaded : function(){
39031 this.loaded = true;
39035 closeClick : function(e){
39038 this.fireEvent("beforeclose", this, o);
39039 if(o.cancel !== true){
39040 this.tabPanel.removeTab(this.id);
39044 * The text displayed in the tooltip for the close icon.
39047 closeText : "Close this tab"
39050 * This script refer to:
39051 * Title: International Telephone Input
39052 * Author: Jack O'Connor
39053 * Code version: v12.1.12
39054 * Availability: https://github.com/jackocnr/intl-tel-input.git
39057 Roo.bootstrap.PhoneInputData = function() {
39060 "Afghanistan (افغانستان)",
39065 "Albania (Shqipëri)",
39070 "Algeria (الجزائر)",
39095 "Antigua and Barbuda",
39105 "Armenia (Հայաստան)",
39121 "Austria (Österreich)",
39126 "Azerbaijan (Azərbaycan)",
39136 "Bahrain (البحرين)",
39141 "Bangladesh (বাংলাদেশ)",
39151 "Belarus (Беларусь)",
39156 "Belgium (België)",
39186 "Bosnia and Herzegovina (Босна и Херцеговина)",
39201 "British Indian Ocean Territory",
39206 "British Virgin Islands",
39216 "Bulgaria (България)",
39226 "Burundi (Uburundi)",
39231 "Cambodia (កម្ពុជា)",
39236 "Cameroon (Cameroun)",
39245 ["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"]
39248 "Cape Verde (Kabu Verdi)",
39253 "Caribbean Netherlands",
39264 "Central African Republic (République centrafricaine)",
39284 "Christmas Island",
39290 "Cocos (Keeling) Islands",
39301 "Comoros (جزر القمر)",
39306 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
39311 "Congo (Republic) (Congo-Brazzaville)",
39331 "Croatia (Hrvatska)",
39352 "Czech Republic (Česká republika)",
39357 "Denmark (Danmark)",
39372 "Dominican Republic (República Dominicana)",
39376 ["809", "829", "849"]
39394 "Equatorial Guinea (Guinea Ecuatorial)",
39414 "Falkland Islands (Islas Malvinas)",
39419 "Faroe Islands (Føroyar)",
39440 "French Guiana (Guyane française)",
39445 "French Polynesia (Polynésie française)",
39460 "Georgia (საქართველო)",
39465 "Germany (Deutschland)",
39485 "Greenland (Kalaallit Nunaat)",
39522 "Guinea-Bissau (Guiné Bissau)",
39547 "Hungary (Magyarország)",
39552 "Iceland (Ísland)",
39572 "Iraq (العراق)",
39588 "Israel (ישראל)",
39615 "Jordan (الأردن)",
39620 "Kazakhstan (Казахстан)",
39641 "Kuwait (الكويت)",
39646 "Kyrgyzstan (Кыргызстан)",
39656 "Latvia (Latvija)",
39661 "Lebanon (لبنان)",
39676 "Libya (ليبيا)",
39686 "Lithuania (Lietuva)",
39701 "Macedonia (FYROM) (Македонија)",
39706 "Madagascar (Madagasikara)",
39736 "Marshall Islands",
39746 "Mauritania (موريتانيا)",
39751 "Mauritius (Moris)",
39772 "Moldova (Republica Moldova)",
39782 "Mongolia (Монгол)",
39787 "Montenegro (Crna Gora)",
39797 "Morocco (المغرب)",
39803 "Mozambique (Moçambique)",
39808 "Myanmar (Burma) (မြန်မာ)",
39813 "Namibia (Namibië)",
39828 "Netherlands (Nederland)",
39833 "New Caledonia (Nouvelle-Calédonie)",
39868 "North Korea (조선 민주주의 인민 공화국)",
39873 "Northern Mariana Islands",
39889 "Pakistan (پاکستان)",
39899 "Palestine (فلسطين)",
39909 "Papua New Guinea",
39951 "Réunion (La Réunion)",
39957 "Romania (România)",
39973 "Saint Barthélemy",
39984 "Saint Kitts and Nevis",
39994 "Saint Martin (Saint-Martin (partie française))",
40000 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
40005 "Saint Vincent and the Grenadines",
40020 "São Tomé and Príncipe (São Tomé e Príncipe)",
40025 "Saudi Arabia (المملكة العربية السعودية)",
40030 "Senegal (Sénégal)",
40060 "Slovakia (Slovensko)",
40065 "Slovenia (Slovenija)",
40075 "Somalia (Soomaaliya)",
40085 "South Korea (대한민국)",
40090 "South Sudan (جنوب السودان)",
40100 "Sri Lanka (ශ්රී ලංකාව)",
40105 "Sudan (السودان)",
40115 "Svalbard and Jan Mayen",
40126 "Sweden (Sverige)",
40131 "Switzerland (Schweiz)",
40136 "Syria (سوريا)",
40181 "Trinidad and Tobago",
40186 "Tunisia (تونس)",
40191 "Turkey (Türkiye)",
40201 "Turks and Caicos Islands",
40211 "U.S. Virgin Islands",
40221 "Ukraine (Україна)",
40226 "United Arab Emirates (الإمارات العربية المتحدة)",
40248 "Uzbekistan (Oʻzbekiston)",
40258 "Vatican City (Città del Vaticano)",
40269 "Vietnam (Việt Nam)",
40274 "Wallis and Futuna (Wallis-et-Futuna)",
40279 "Western Sahara (الصحراء الغربية)",
40285 "Yemen (اليمن)",
40309 * This script refer to:
40310 * Title: International Telephone Input
40311 * Author: Jack O'Connor
40312 * Code version: v12.1.12
40313 * Availability: https://github.com/jackocnr/intl-tel-input.git
40317 * @class Roo.bootstrap.PhoneInput
40318 * @extends Roo.bootstrap.TriggerField
40319 * An input with International dial-code selection
40321 * @cfg {String} defaultDialCode default '+852'
40322 * @cfg {Array} preferedCountries default []
40325 * Create a new PhoneInput.
40326 * @param {Object} config Configuration options
40329 Roo.bootstrap.PhoneInput = function(config) {
40330 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
40333 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
40335 listWidth: undefined,
40337 selectedClass: 'active',
40339 invalidClass : "has-warning",
40341 validClass: 'has-success',
40343 allowed: '0123456789',
40348 * @cfg {String} defaultDialCode The default dial code when initializing the input
40350 defaultDialCode: '+852',
40353 * @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
40355 preferedCountries: false,
40357 getAutoCreate : function()
40359 var data = Roo.bootstrap.PhoneInputData();
40360 var align = this.labelAlign || this.parentLabelAlign();
40363 this.allCountries = [];
40364 this.dialCodeMapping = [];
40366 for (var i = 0; i < data.length; i++) {
40368 this.allCountries[i] = {
40372 priority: c[3] || 0,
40373 areaCodes: c[4] || null
40375 this.dialCodeMapping[c[2]] = {
40378 priority: c[3] || 0,
40379 areaCodes: c[4] || null
40391 // type: 'number', -- do not use number - we get the flaky up/down arrows.
40392 maxlength: this.max_length,
40393 cls : 'form-control tel-input',
40394 autocomplete: 'new-password'
40397 var hiddenInput = {
40400 cls: 'hidden-tel-input'
40404 hiddenInput.name = this.name;
40407 if (this.disabled) {
40408 input.disabled = true;
40411 var flag_container = {
40428 cls: this.hasFeedback ? 'has-feedback' : '',
40434 cls: 'dial-code-holder',
40441 cls: 'roo-select2-container input-group',
40448 if (this.fieldLabel.length) {
40451 tooltip: 'This field is required'
40457 cls: 'control-label',
40463 html: this.fieldLabel
40466 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40472 if(this.indicatorpos == 'right') {
40473 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
40480 if(align == 'left') {
40488 if(this.labelWidth > 12){
40489 label.style = "width: " + this.labelWidth + 'px';
40491 if(this.labelWidth < 13 && this.labelmd == 0){
40492 this.labelmd = this.labelWidth;
40494 if(this.labellg > 0){
40495 label.cls += ' col-lg-' + this.labellg;
40496 input.cls += ' col-lg-' + (12 - this.labellg);
40498 if(this.labelmd > 0){
40499 label.cls += ' col-md-' + this.labelmd;
40500 container.cls += ' col-md-' + (12 - this.labelmd);
40502 if(this.labelsm > 0){
40503 label.cls += ' col-sm-' + this.labelsm;
40504 container.cls += ' col-sm-' + (12 - this.labelsm);
40506 if(this.labelxs > 0){
40507 label.cls += ' col-xs-' + this.labelxs;
40508 container.cls += ' col-xs-' + (12 - this.labelxs);
40518 var settings = this;
40520 ['xs','sm','md','lg'].map(function(size){
40521 if (settings[size]) {
40522 cfg.cls += ' col-' + size + '-' + settings[size];
40526 this.store = new Roo.data.Store({
40527 proxy : new Roo.data.MemoryProxy({}),
40528 reader : new Roo.data.JsonReader({
40539 'name' : 'dialCode',
40543 'name' : 'priority',
40547 'name' : 'areaCodes',
40554 if(!this.preferedCountries) {
40555 this.preferedCountries = [
40562 var p = this.preferedCountries.reverse();
40565 for (var i = 0; i < p.length; i++) {
40566 for (var j = 0; j < this.allCountries.length; j++) {
40567 if(this.allCountries[j].iso2 == p[i]) {
40568 var t = this.allCountries[j];
40569 this.allCountries.splice(j,1);
40570 this.allCountries.unshift(t);
40576 this.store.proxy.data = {
40578 data: this.allCountries
40584 initEvents : function()
40587 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
40589 this.indicator = this.indicatorEl();
40590 this.flag = this.flagEl();
40591 this.dialCodeHolder = this.dialCodeHolderEl();
40593 this.trigger = this.el.select('div.flag-box',true).first();
40594 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
40599 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40600 _this.list.setWidth(lw);
40603 this.list.on('mouseover', this.onViewOver, this);
40604 this.list.on('mousemove', this.onViewMove, this);
40605 this.inputEl().on("keyup", this.onKeyUp, this);
40606 this.inputEl().on("keypress", this.onKeyPress, this);
40608 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
40610 this.view = new Roo.View(this.list, this.tpl, {
40611 singleSelect:true, store: this.store, selectedClass: this.selectedClass
40614 this.view.on('click', this.onViewClick, this);
40615 this.setValue(this.defaultDialCode);
40618 onTriggerClick : function(e)
40620 Roo.log('trigger click');
40625 if(this.isExpanded()){
40627 this.hasFocus = false;
40629 this.store.load({});
40630 this.hasFocus = true;
40635 isExpanded : function()
40637 return this.list.isVisible();
40640 collapse : function()
40642 if(!this.isExpanded()){
40646 Roo.get(document).un('mousedown', this.collapseIf, this);
40647 Roo.get(document).un('mousewheel', this.collapseIf, this);
40648 this.fireEvent('collapse', this);
40652 expand : function()
40656 if(this.isExpanded() || !this.hasFocus){
40660 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
40661 this.list.setWidth(lw);
40664 this.restrictHeight();
40666 Roo.get(document).on('mousedown', this.collapseIf, this);
40667 Roo.get(document).on('mousewheel', this.collapseIf, this);
40669 this.fireEvent('expand', this);
40672 restrictHeight : function()
40674 this.list.alignTo(this.inputEl(), this.listAlign);
40675 this.list.alignTo(this.inputEl(), this.listAlign);
40678 onViewOver : function(e, t)
40680 if(this.inKeyMode){
40683 var item = this.view.findItemFromChild(t);
40686 var index = this.view.indexOf(item);
40687 this.select(index, false);
40692 onViewClick : function(view, doFocus, el, e)
40694 var index = this.view.getSelectedIndexes()[0];
40696 var r = this.store.getAt(index);
40699 this.onSelect(r, index);
40701 if(doFocus !== false && !this.blockFocus){
40702 this.inputEl().focus();
40706 onViewMove : function(e, t)
40708 this.inKeyMode = false;
40711 select : function(index, scrollIntoView)
40713 this.selectedIndex = index;
40714 this.view.select(index);
40715 if(scrollIntoView !== false){
40716 var el = this.view.getNode(index);
40718 this.list.scrollChildIntoView(el, false);
40723 createList : function()
40725 this.list = Roo.get(document.body).createChild({
40727 cls: 'typeahead typeahead-long dropdown-menu tel-list',
40728 style: 'display:none'
40731 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
40734 collapseIf : function(e)
40736 var in_combo = e.within(this.el);
40737 var in_list = e.within(this.list);
40738 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
40740 if (in_combo || in_list || is_list) {
40746 onSelect : function(record, index)
40748 if(this.fireEvent('beforeselect', this, record, index) !== false){
40750 this.setFlagClass(record.data.iso2);
40751 this.setDialCode(record.data.dialCode);
40752 this.hasFocus = false;
40754 this.fireEvent('select', this, record, index);
40758 flagEl : function()
40760 var flag = this.el.select('div.flag',true).first();
40767 dialCodeHolderEl : function()
40769 var d = this.el.select('input.dial-code-holder',true).first();
40776 setDialCode : function(v)
40778 this.dialCodeHolder.dom.value = '+'+v;
40781 setFlagClass : function(n)
40783 this.flag.dom.className = 'flag '+n;
40786 getValue : function()
40788 var v = this.inputEl().getValue();
40789 if(this.dialCodeHolder) {
40790 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
40795 setValue : function(v)
40797 var d = this.getDialCode(v);
40799 //invalid dial code
40800 if(v.length == 0 || !d || d.length == 0) {
40802 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
40803 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
40809 this.setFlagClass(this.dialCodeMapping[d].iso2);
40810 this.setDialCode(d);
40811 this.inputEl().dom.value = v.replace('+'+d,'');
40812 this.hiddenEl().dom.value = this.getValue();
40817 getDialCode : function(v)
40821 if (v.length == 0) {
40822 return this.dialCodeHolder.dom.value;
40826 if (v.charAt(0) != "+") {
40829 var numericChars = "";
40830 for (var i = 1; i < v.length; i++) {
40831 var c = v.charAt(i);
40834 if (this.dialCodeMapping[numericChars]) {
40835 dialCode = v.substr(1, i);
40837 if (numericChars.length == 4) {
40847 this.setValue(this.defaultDialCode);
40851 hiddenEl : function()
40853 return this.el.select('input.hidden-tel-input',true).first();
40856 // after setting val
40857 onKeyUp : function(e){
40858 this.setValue(this.getValue());
40861 onKeyPress : function(e){
40862 if(this.allowed.indexOf(String.fromCharCode(e.getCharCode())) === -1){
40869 * @class Roo.bootstrap.MoneyField
40870 * @extends Roo.bootstrap.ComboBox
40871 * Bootstrap MoneyField class
40874 * Create a new MoneyField.
40875 * @param {Object} config Configuration options
40878 Roo.bootstrap.MoneyField = function(config) {
40880 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
40884 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
40887 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
40889 allowDecimals : true,
40891 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
40893 decimalSeparator : ".",
40895 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
40897 decimalPrecision : 0,
40899 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
40901 allowNegative : true,
40903 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
40907 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
40909 minValue : Number.NEGATIVE_INFINITY,
40911 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
40913 maxValue : Number.MAX_VALUE,
40915 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
40917 minText : "The minimum value for this field is {0}",
40919 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
40921 maxText : "The maximum value for this field is {0}",
40923 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
40924 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
40926 nanText : "{0} is not a valid number",
40928 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
40932 * @cfg {String} defaults currency of the MoneyField
40933 * value should be in lkey
40935 defaultCurrency : false,
40937 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
40939 thousandsDelimiter : false,
40941 * @cfg {Number} max_length Maximum input field length allowed (defaults to Number.MAX_VALUE)
40952 getAutoCreate : function()
40954 var align = this.labelAlign || this.parentLabelAlign();
40966 cls : 'form-control roo-money-amount-input',
40967 autocomplete: 'new-password'
40970 var hiddenInput = {
40974 cls: 'hidden-number-input'
40977 if(this.max_length) {
40978 input.maxlength = this.max_length;
40982 hiddenInput.name = this.name;
40985 if (this.disabled) {
40986 input.disabled = true;
40989 var clg = 12 - this.inputlg;
40990 var cmd = 12 - this.inputmd;
40991 var csm = 12 - this.inputsm;
40992 var cxs = 12 - this.inputxs;
40996 cls : 'row roo-money-field',
41000 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
41004 cls: 'roo-select2-container input-group',
41008 cls : 'form-control roo-money-currency-input',
41009 autocomplete: 'new-password',
41011 name : this.currencyName
41015 cls : 'input-group-addon',
41029 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
41033 cls: this.hasFeedback ? 'has-feedback' : '',
41044 if (this.fieldLabel.length) {
41047 tooltip: 'This field is required'
41053 cls: 'control-label',
41059 html: this.fieldLabel
41062 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
41068 if(this.indicatorpos == 'right') {
41069 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
41076 if(align == 'left') {
41084 if(this.labelWidth > 12){
41085 label.style = "width: " + this.labelWidth + 'px';
41087 if(this.labelWidth < 13 && this.labelmd == 0){
41088 this.labelmd = this.labelWidth;
41090 if(this.labellg > 0){
41091 label.cls += ' col-lg-' + this.labellg;
41092 input.cls += ' col-lg-' + (12 - this.labellg);
41094 if(this.labelmd > 0){
41095 label.cls += ' col-md-' + this.labelmd;
41096 container.cls += ' col-md-' + (12 - this.labelmd);
41098 if(this.labelsm > 0){
41099 label.cls += ' col-sm-' + this.labelsm;
41100 container.cls += ' col-sm-' + (12 - this.labelsm);
41102 if(this.labelxs > 0){
41103 label.cls += ' col-xs-' + this.labelxs;
41104 container.cls += ' col-xs-' + (12 - this.labelxs);
41115 var settings = this;
41117 ['xs','sm','md','lg'].map(function(size){
41118 if (settings[size]) {
41119 cfg.cls += ' col-' + size + '-' + settings[size];
41126 initEvents : function()
41128 this.indicator = this.indicatorEl();
41130 this.initCurrencyEvent();
41132 this.initNumberEvent();
41135 initCurrencyEvent : function()
41138 throw "can not find store for combo";
41141 this.store = Roo.factory(this.store, Roo.data);
41142 this.store.parent = this;
41146 this.triggerEl = this.el.select('.input-group-addon', true).first();
41148 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
41153 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
41154 _this.list.setWidth(lw);
41157 this.list.on('mouseover', this.onViewOver, this);
41158 this.list.on('mousemove', this.onViewMove, this);
41159 this.list.on('scroll', this.onViewScroll, this);
41162 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
41165 this.view = new Roo.View(this.list, this.tpl, {
41166 singleSelect:true, store: this.store, selectedClass: this.selectedClass
41169 this.view.on('click', this.onViewClick, this);
41171 this.store.on('beforeload', this.onBeforeLoad, this);
41172 this.store.on('load', this.onLoad, this);
41173 this.store.on('loadexception', this.onLoadException, this);
41175 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
41176 "up" : function(e){
41177 this.inKeyMode = true;
41181 "down" : function(e){
41182 if(!this.isExpanded()){
41183 this.onTriggerClick();
41185 this.inKeyMode = true;
41190 "enter" : function(e){
41193 if(this.fireEvent("specialkey", this, e)){
41194 this.onViewClick(false);
41200 "esc" : function(e){
41204 "tab" : function(e){
41207 if(this.fireEvent("specialkey", this, e)){
41208 this.onViewClick(false);
41216 doRelay : function(foo, bar, hname){
41217 if(hname == 'down' || this.scope.isExpanded()){
41218 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
41226 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
41230 initNumberEvent : function(e)
41232 this.inputEl().on("keydown" , this.fireKey, this);
41233 this.inputEl().on("focus", this.onFocus, this);
41234 this.inputEl().on("blur", this.onBlur, this);
41236 this.inputEl().relayEvent('keyup', this);
41238 if(this.indicator){
41239 this.indicator.addClass('invisible');
41242 this.originalValue = this.getValue();
41244 if(this.validationEvent == 'keyup'){
41245 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
41246 this.inputEl().on('keyup', this.filterValidation, this);
41248 else if(this.validationEvent !== false){
41249 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
41252 if(this.selectOnFocus){
41253 this.on("focus", this.preFocus, this);
41256 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
41257 this.inputEl().on("keypress", this.filterKeys, this);
41259 this.inputEl().relayEvent('keypress', this);
41262 var allowed = "0123456789";
41264 if(this.allowDecimals){
41265 allowed += this.decimalSeparator;
41268 if(this.allowNegative){
41272 if(this.thousandsDelimiter) {
41276 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
41278 var keyPress = function(e){
41280 var k = e.getKey();
41282 var c = e.getCharCode();
41285 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
41286 allowed.indexOf(String.fromCharCode(c)) === -1
41292 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
41296 if(allowed.indexOf(String.fromCharCode(c)) === -1){
41301 this.inputEl().on("keypress", keyPress, this);
41305 onTriggerClick : function(e)
41312 this.loadNext = false;
41314 if(this.isExpanded()){
41319 this.hasFocus = true;
41321 if(this.triggerAction == 'all') {
41322 this.doQuery(this.allQuery, true);
41326 this.doQuery(this.getRawValue());
41329 getCurrency : function()
41331 var v = this.currencyEl().getValue();
41336 restrictHeight : function()
41338 this.list.alignTo(this.currencyEl(), this.listAlign);
41339 this.list.alignTo(this.currencyEl(), this.listAlign);
41342 onViewClick : function(view, doFocus, el, e)
41344 var index = this.view.getSelectedIndexes()[0];
41346 var r = this.store.getAt(index);
41349 this.onSelect(r, index);
41353 onSelect : function(record, index){
41355 if(this.fireEvent('beforeselect', this, record, index) !== false){
41357 this.setFromCurrencyData(index > -1 ? record.data : false);
41361 this.fireEvent('select', this, record, index);
41365 setFromCurrencyData : function(o)
41369 this.lastCurrency = o;
41371 if (this.currencyField) {
41372 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
41374 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
41377 this.lastSelectionText = currency;
41379 //setting default currency
41380 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
41381 this.setCurrency(this.defaultCurrency);
41385 this.setCurrency(currency);
41388 setFromData : function(o)
41392 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
41394 this.setFromCurrencyData(c);
41399 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
41401 Roo.log('no value set for '+ (this.name ? this.name : this.id));
41404 this.setValue(value);
41408 setCurrency : function(v)
41410 this.currencyValue = v;
41413 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
41418 setValue : function(v)
41420 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
41426 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
41428 this.inputEl().dom.value = (v == '') ? '' :
41429 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
41431 if(!this.allowZero && v === '0') {
41432 this.hiddenEl().dom.value = '';
41433 this.inputEl().dom.value = '';
41440 getRawValue : function()
41442 var v = this.inputEl().getValue();
41447 getValue : function()
41449 return this.fixPrecision(this.parseValue(this.getRawValue()));
41452 parseValue : function(value)
41454 if(this.thousandsDelimiter) {
41456 r = new RegExp(",", "g");
41457 value = value.replace(r, "");
41460 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
41461 return isNaN(value) ? '' : value;
41465 fixPrecision : function(value)
41467 if(this.thousandsDelimiter) {
41469 r = new RegExp(",", "g");
41470 value = value.replace(r, "");
41473 var nan = isNaN(value);
41475 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
41476 return nan ? '' : value;
41478 return parseFloat(value).toFixed(this.decimalPrecision);
41481 decimalPrecisionFcn : function(v)
41483 return Math.floor(v);
41486 validateValue : function(value)
41488 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
41492 var num = this.parseValue(value);
41495 this.markInvalid(String.format(this.nanText, value));
41499 if(num < this.minValue){
41500 this.markInvalid(String.format(this.minText, this.minValue));
41504 if(num > this.maxValue){
41505 this.markInvalid(String.format(this.maxText, this.maxValue));
41512 validate : function()
41514 if(this.disabled || this.allowBlank){
41519 var currency = this.getCurrency();
41521 if(this.validateValue(this.getRawValue()) && currency.length){
41526 this.markInvalid();
41530 getName: function()
41535 beforeBlur : function()
41541 var v = this.parseValue(this.getRawValue());
41548 onBlur : function()
41552 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
41553 //this.el.removeClass(this.focusClass);
41556 this.hasFocus = false;
41558 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
41562 var v = this.getValue();
41564 if(String(v) !== String(this.startValue)){
41565 this.fireEvent('change', this, v, this.startValue);
41568 this.fireEvent("blur", this);
41571 inputEl : function()
41573 return this.el.select('.roo-money-amount-input', true).first();
41576 currencyEl : function()
41578 return this.el.select('.roo-money-currency-input', true).first();
41581 hiddenEl : function()
41583 return this.el.select('input.hidden-number-input',true).first();
41587 * @class Roo.bootstrap.BezierSignature
41588 * @extends Roo.bootstrap.Component
41589 * Bootstrap BezierSignature class
41590 * This script refer to:
41591 * Title: Signature Pad
41593 * Availability: https://github.com/szimek/signature_pad
41596 * Create a new BezierSignature
41597 * @param {Object} config The config object
41600 Roo.bootstrap.BezierSignature = function(config){
41601 Roo.bootstrap.BezierSignature.superclass.constructor.call(this, config);
41607 Roo.extend(Roo.bootstrap.BezierSignature, Roo.bootstrap.Component,
41614 mouse_btn_down: true,
41617 * @cfg {int} canvas height
41619 canvas_height: '200px',
41622 * @cfg {float|function} Radius of a single dot.
41627 * @cfg {float} Minimum width of a line. Defaults to 0.5.
41632 * @cfg {float} Maximum width of a line. Defaults to 2.5.
41637 * @cfg {integer} Draw the next point at most once per every x milliseconds. Set it to 0 to turn off throttling. Defaults to 16.
41642 * @cfg {integer} Add the next point only if the previous one is farther than x pixels. Defaults to 5.
41647 * @cfg {string} Color used to clear the background. Can be any color format accepted by context.fillStyle. Defaults to "rgba(0,0,0,0)" (transparent black). Use a non-transparent color e.g. "rgb(255,255,255)" (opaque white) if you'd like to save signatures as JPEG images.
41649 bg_color: 'rgba(0, 0, 0, 0)',
41652 * @cfg {string} Color used to draw the lines. Can be any color format accepted by context.fillStyle. Defaults to "black".
41654 dot_color: 'black',
41657 * @cfg {float} Weight used to modify new velocity based on the previous velocity. Defaults to 0.7.
41659 velocity_filter_weight: 0.7,
41662 * @cfg {function} Callback when stroke begin.
41667 * @cfg {function} Callback when stroke end.
41671 getAutoCreate : function()
41673 var cls = 'roo-signature column';
41676 cls += ' ' + this.cls;
41686 for(var i = 0; i < col_sizes.length; i++) {
41687 if(this[col_sizes[i]]) {
41688 cls += " col-"+col_sizes[i]+"-"+this[col_sizes[i]];
41698 cls: 'roo-signature-body',
41702 cls: 'roo-signature-body-canvas',
41703 height: this.canvas_height,
41704 width: this.canvas_width
41711 style: 'display: none'
41719 initEvents: function()
41721 Roo.bootstrap.BezierSignature.superclass.initEvents.call(this);
41723 var canvas = this.canvasEl();
41725 // mouse && touch event swapping...
41726 canvas.dom.style.touchAction = 'none';
41727 canvas.dom.style.msTouchAction = 'none';
41729 this.mouse_btn_down = false;
41730 canvas.on('mousedown', this._handleMouseDown, this);
41731 canvas.on('mousemove', this._handleMouseMove, this);
41732 Roo.select('html').first().on('mouseup', this._handleMouseUp, this);
41734 if (window.PointerEvent) {
41735 canvas.on('pointerdown', this._handleMouseDown, this);
41736 canvas.on('pointermove', this._handleMouseMove, this);
41737 Roo.select('html').first().on('pointerup', this._handleMouseUp, this);
41740 if ('ontouchstart' in window) {
41741 canvas.on('touchstart', this._handleTouchStart, this);
41742 canvas.on('touchmove', this._handleTouchMove, this);
41743 canvas.on('touchend', this._handleTouchEnd, this);
41746 Roo.EventManager.onWindowResize(this.resize, this, true);
41748 // file input event
41749 this.fileEl().on('change', this.uploadImage, this);
41756 resize: function(){
41758 var canvas = this.canvasEl().dom;
41759 var ctx = this.canvasElCtx();
41760 var img_data = false;
41762 if(canvas.width > 0) {
41763 var img_data = ctx.getImageData(0, 0, canvas.width, canvas.height);
41765 // setting canvas width will clean img data
41768 var style = window.getComputedStyle ?
41769 getComputedStyle(this.el.dom, null) : this.el.dom.currentStyle;
41771 var padding_left = parseInt(style.paddingLeft) || 0;
41772 var padding_right = parseInt(style.paddingRight) || 0;
41774 canvas.width = this.el.dom.clientWidth - padding_left - padding_right;
41777 ctx.putImageData(img_data, 0, 0);
41781 _handleMouseDown: function(e)
41783 if (e.browserEvent.which === 1) {
41784 this.mouse_btn_down = true;
41785 this.strokeBegin(e);
41789 _handleMouseMove: function (e)
41791 if (this.mouse_btn_down) {
41792 this.strokeMoveUpdate(e);
41796 _handleMouseUp: function (e)
41798 if (e.browserEvent.which === 1 && this.mouse_btn_down) {
41799 this.mouse_btn_down = false;
41804 _handleTouchStart: function (e) {
41806 e.preventDefault();
41807 if (e.browserEvent.targetTouches.length === 1) {
41808 // var touch = e.browserEvent.changedTouches[0];
41809 // this.strokeBegin(touch);
41811 this.strokeBegin(e); // assume e catching the correct xy...
41815 _handleTouchMove: function (e) {
41816 e.preventDefault();
41817 // var touch = event.targetTouches[0];
41818 // _this._strokeMoveUpdate(touch);
41819 this.strokeMoveUpdate(e);
41822 _handleTouchEnd: function (e) {
41823 var wasCanvasTouched = e.target === this.canvasEl().dom;
41824 if (wasCanvasTouched) {
41825 e.preventDefault();
41826 // var touch = event.changedTouches[0];
41827 // _this._strokeEnd(touch);
41832 reset: function () {
41833 this._lastPoints = [];
41834 this._lastVelocity = 0;
41835 this._lastWidth = (this.min_width + this.max_width) / 2;
41836 this.canvasElCtx().fillStyle = this.dot_color;
41839 strokeMoveUpdate: function(e)
41841 this.strokeUpdate(e);
41843 if (this.throttle) {
41844 this.throttleStroke(this.strokeUpdate, this.throttle);
41847 this.strokeUpdate(e);
41851 strokeBegin: function(e)
41853 var newPointGroup = {
41854 color: this.dot_color,
41858 if (typeof this.onBegin === 'function') {
41862 this.curve_data.push(newPointGroup);
41864 this.strokeUpdate(e);
41867 strokeUpdate: function(e)
41869 var rect = this.canvasEl().dom.getBoundingClientRect();
41870 var point = new this.Point(e.xy[0] - rect.left, e.xy[1] - rect.top, new Date().getTime());
41871 var lastPointGroup = this.curve_data[this.curve_data.length - 1];
41872 var lastPoints = lastPointGroup.points;
41873 var lastPoint = lastPoints.length > 0 && lastPoints[lastPoints.length - 1];
41874 var isLastPointTooClose = lastPoint
41875 ? point.distanceTo(lastPoint) <= this.min_distance
41877 var color = lastPointGroup.color;
41878 if (!lastPoint || !(lastPoint && isLastPointTooClose)) {
41879 var curve = this.addPoint(point);
41881 this.drawDot({color: color, point: point});
41884 this.drawCurve({color: color, curve: curve});
41894 strokeEnd: function(e)
41896 this.strokeUpdate(e);
41897 if (typeof this.onEnd === 'function') {
41902 addPoint: function (point) {
41903 var _lastPoints = this._lastPoints;
41904 _lastPoints.push(point);
41905 if (_lastPoints.length > 2) {
41906 if (_lastPoints.length === 3) {
41907 _lastPoints.unshift(_lastPoints[0]);
41909 var widths = this.calculateCurveWidths(_lastPoints[1], _lastPoints[2]);
41910 var curve = this.Bezier.fromPoints(_lastPoints, widths, this);
41911 _lastPoints.shift();
41917 calculateCurveWidths: function (startPoint, endPoint) {
41918 var velocity = this.velocity_filter_weight * endPoint.velocityFrom(startPoint) +
41919 (1 - this.velocity_filter_weight) * this._lastVelocity;
41921 var newWidth = Math.max(this.max_width / (velocity + 1), this.min_width);
41924 start: this._lastWidth
41927 this._lastVelocity = velocity;
41928 this._lastWidth = newWidth;
41932 drawDot: function (_a) {
41933 var color = _a.color, point = _a.point;
41934 var ctx = this.canvasElCtx();
41935 var width = typeof this.dot_size === 'function' ? this.dot_size() : this.dot_size;
41937 this.drawCurveSegment(point.x, point.y, width);
41939 ctx.fillStyle = color;
41943 drawCurve: function (_a) {
41944 var color = _a.color, curve = _a.curve;
41945 var ctx = this.canvasElCtx();
41946 var widthDelta = curve.endWidth - curve.startWidth;
41947 var drawSteps = Math.floor(curve.length()) * 2;
41949 ctx.fillStyle = color;
41950 for (var i = 0; i < drawSteps; i += 1) {
41951 var t = i / drawSteps;
41957 var x = uuu * curve.startPoint.x;
41958 x += 3 * uu * t * curve.control1.x;
41959 x += 3 * u * tt * curve.control2.x;
41960 x += ttt * curve.endPoint.x;
41961 var y = uuu * curve.startPoint.y;
41962 y += 3 * uu * t * curve.control1.y;
41963 y += 3 * u * tt * curve.control2.y;
41964 y += ttt * curve.endPoint.y;
41965 var width = curve.startWidth + ttt * widthDelta;
41966 this.drawCurveSegment(x, y, width);
41972 drawCurveSegment: function (x, y, width) {
41973 var ctx = this.canvasElCtx();
41975 ctx.arc(x, y, width, 0, 2 * Math.PI, false);
41976 this.is_empty = false;
41981 var ctx = this.canvasElCtx();
41982 var canvas = this.canvasEl().dom;
41983 ctx.fillStyle = this.bg_color;
41984 ctx.clearRect(0, 0, canvas.width, canvas.height);
41985 ctx.fillRect(0, 0, canvas.width, canvas.height);
41986 this.curve_data = [];
41988 this.is_empty = true;
41993 return this.el.select('input',true).first();
41996 canvasEl: function()
41998 return this.el.select('canvas',true).first();
42001 canvasElCtx: function()
42003 return this.el.select('canvas',true).first().dom.getContext('2d');
42006 getImage: function(type)
42008 if(this.is_empty) {
42013 return this.canvasEl().dom.toDataURL('image/'+type, 1);
42016 drawFromImage: function(img_src)
42018 var img = new Image();
42020 img.onload = function(){
42021 this.canvasElCtx().drawImage(img, 0, 0);
42026 this.is_empty = false;
42029 selectImage: function()
42031 this.fileEl().dom.click();
42034 uploadImage: function(e)
42036 var reader = new FileReader();
42038 reader.onload = function(e){
42039 var img = new Image();
42040 img.onload = function(){
42042 this.canvasElCtx().drawImage(img, 0, 0);
42044 img.src = e.target.result;
42047 reader.readAsDataURL(e.target.files[0]);
42050 // Bezier Point Constructor
42051 Point: (function () {
42052 function Point(x, y, time) {
42055 this.time = time || Date.now();
42057 Point.prototype.distanceTo = function (start) {
42058 return Math.sqrt(Math.pow(this.x - start.x, 2) + Math.pow(this.y - start.y, 2));
42060 Point.prototype.equals = function (other) {
42061 return this.x === other.x && this.y === other.y && this.time === other.time;
42063 Point.prototype.velocityFrom = function (start) {
42064 return this.time !== start.time
42065 ? this.distanceTo(start) / (this.time - start.time)
42072 // Bezier Constructor
42073 Bezier: (function () {
42074 function Bezier(startPoint, control2, control1, endPoint, startWidth, endWidth) {
42075 this.startPoint = startPoint;
42076 this.control2 = control2;
42077 this.control1 = control1;
42078 this.endPoint = endPoint;
42079 this.startWidth = startWidth;
42080 this.endWidth = endWidth;
42082 Bezier.fromPoints = function (points, widths, scope) {
42083 var c2 = this.calculateControlPoints(points[0], points[1], points[2], scope).c2;
42084 var c3 = this.calculateControlPoints(points[1], points[2], points[3], scope).c1;
42085 return new Bezier(points[1], c2, c3, points[2], widths.start, widths.end);
42087 Bezier.calculateControlPoints = function (s1, s2, s3, scope) {
42088 var dx1 = s1.x - s2.x;
42089 var dy1 = s1.y - s2.y;
42090 var dx2 = s2.x - s3.x;
42091 var dy2 = s2.y - s3.y;
42092 var m1 = { x: (s1.x + s2.x) / 2.0, y: (s1.y + s2.y) / 2.0 };
42093 var m2 = { x: (s2.x + s3.x) / 2.0, y: (s2.y + s3.y) / 2.0 };
42094 var l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
42095 var l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
42096 var dxm = m1.x - m2.x;
42097 var dym = m1.y - m2.y;
42098 var k = l2 / (l1 + l2);
42099 var cm = { x: m2.x + dxm * k, y: m2.y + dym * k };
42100 var tx = s2.x - cm.x;
42101 var ty = s2.y - cm.y;
42103 c1: new scope.Point(m1.x + tx, m1.y + ty),
42104 c2: new scope.Point(m2.x + tx, m2.y + ty)
42107 Bezier.prototype.length = function () {
42112 for (var i = 0; i <= steps; i += 1) {
42114 var cx = this.point(t, this.startPoint.x, this.control1.x, this.control2.x, this.endPoint.x);
42115 var cy = this.point(t, this.startPoint.y, this.control1.y, this.control2.y, this.endPoint.y);
42117 var xdiff = cx - px;
42118 var ydiff = cy - py;
42119 length += Math.sqrt(xdiff * xdiff + ydiff * ydiff);
42126 Bezier.prototype.point = function (t, start, c1, c2, end) {
42127 return (start * (1.0 - t) * (1.0 - t) * (1.0 - t))
42128 + (3.0 * c1 * (1.0 - t) * (1.0 - t) * t)
42129 + (3.0 * c2 * (1.0 - t) * t * t)
42130 + (end * t * t * t);
42135 throttleStroke: function(fn, wait) {
42136 if (wait === void 0) { wait = 250; }
42138 var timeout = null;
42142 var later = function () {
42143 previous = Date.now();
42145 result = fn.apply(storedContext, storedArgs);
42147 storedContext = null;
42151 return function wrapper() {
42153 for (var _i = 0; _i < arguments.length; _i++) {
42154 args[_i] = arguments[_i];
42156 var now = Date.now();
42157 var remaining = wait - (now - previous);
42158 storedContext = this;
42160 if (remaining <= 0 || remaining > wait) {
42162 clearTimeout(timeout);
42166 result = fn.apply(storedContext, storedArgs);
42168 storedContext = null;
42172 else if (!timeout) {
42173 timeout = window.setTimeout(later, remaining);