2 * set the version of bootstrap based on the stylesheet...
6 Roo.bootstrap.version = ( function() {
8 Roo.each(document.styleSheets, function(s) {
9 if ( s.href && s.href.match(/css-bootstrap4/)) {
14 Roo.Element.prototype.visibilityMode = Roo.Element.DISPLAY;
17 })(); Roo.bootstrap.menu = Roo.bootstrap.menu || {};
18 Roo.bootstrap.nav = {};
20 Roo.bootstrap.form = {};Roo.bootstrap.panel = {};Roo.bootstrap.layout = {};/*
22 * Ext JS Library 1.1.1
23 * Copyright(c) 2006-2007, Ext JS, LLC.
25 * Originally Released Under LGPL - original licence link has changed is not relivant.
28 * <script type="text/javascript">
34 * Simple class that can provide a shadow effect for any element. Note that the element MUST be absolutely positioned,
35 * and the shadow does not provide any shimming. This should be used only in simple cases -- for more advanced
36 * functionality that can also provide the same shadow effect, see the {@link Roo.Layer} class.
39 * @param {Object} config The config object
41 Roo.Shadow = function(config){
42 Roo.apply(this, config);
43 if(typeof this.mode != "string"){
44 this.mode = this.defaultMode;
46 var o = this.offset, a = {h: 0};
47 var rad = Math.floor(this.offset/2);
48 switch(this.mode.toLowerCase()){ // all this hideous nonsense calculates the various offsets for shadows
54 a.l -= this.offset + rad;
55 a.t -= this.offset + rad;
66 a.l -= (this.offset - rad);
67 a.t -= this.offset + rad;
69 a.w -= (this.offset - rad)*2;
80 a.l -= (this.offset - rad);
81 a.t -= (this.offset - rad);
83 a.w -= (this.offset + rad + 1);
84 a.h -= (this.offset + rad);
93 Roo.Shadow.prototype = {
96 * The shadow display mode. Supports the following options:<br />
97 * sides: Shadow displays on both sides and bottom only<br />
98 * frame: Shadow displays equally on all four sides<br />
99 * drop: Traditional bottom-right drop shadow (default)
103 * @cfg {String} offset
104 * The number of pixels to offset the shadow from the element (defaults to 4)
112 * Displays the shadow under the target element
113 * @param {String/HTMLElement/Element} targetEl The id or element under which the shadow should display
115 show : function(target){
116 target = Roo.get(target);
118 this.el = Roo.Shadow.Pool.pull();
119 if(this.el.dom.nextSibling != target.dom){
120 this.el.insertBefore(target);
123 this.el.setStyle("z-index", this.zIndex || parseInt(target.getStyle("z-index"), 10)-1);
125 this.el.dom.style.filter="progid:DXImageTransform.Microsoft.alpha(opacity=50) progid:DXImageTransform.Microsoft.Blur(pixelradius="+(this.offset)+")";
128 target.getLeft(true),
133 this.el.dom.style.display = "block";
137 * Returns true if the shadow is visible, else false
139 isVisible : function(){
140 return this.el ? true : false;
144 * Direct alignment when values are already available. Show must be called at least once before
145 * calling this method to ensure it is initialized.
146 * @param {Number} left The target element left position
147 * @param {Number} top The target element top position
148 * @param {Number} width The target element width
149 * @param {Number} height The target element height
151 realign : function(l, t, w, h){
155 var a = this.adjusts, d = this.el.dom, s = d.style;
157 s.left = (l+a.l)+"px";
158 s.top = (t+a.t)+"px";
159 var sw = (w+a.w), sh = (h+a.h), sws = sw +"px", shs = sh + "px";
161 if(s.width != sws || s.height != shs){
165 var cn = d.childNodes;
166 var sww = Math.max(0, (sw-12))+"px";
167 cn[0].childNodes[1].style.width = sww;
168 cn[1].childNodes[1].style.width = sww;
169 cn[2].childNodes[1].style.width = sww;
170 cn[1].style.height = Math.max(0, (sh-12))+"px";
180 this.el.dom.style.display = "none";
181 Roo.Shadow.Pool.push(this.el);
187 * Adjust the z-index of this shadow
188 * @param {Number} zindex The new z-index
190 setZIndex : function(z){
193 this.el.setStyle("z-index", z);
198 // Private utility class that manages the internal Shadow cache
199 Roo.Shadow.Pool = function(){
201 var markup = Roo.isIE ?
202 '<div class="x-ie-shadow"></div>' :
203 '<div class="x-shadow"><div class="xst"><div class="xstl"></div><div class="xstc"></div><div class="xstr"></div></div><div class="xsc"><div class="xsml"></div><div class="xsmc"></div><div class="xsmr"></div></div><div class="xsb"><div class="xsbl"></div><div class="xsbc"></div><div class="xsbr"></div></div></div>';
208 sh = Roo.get(Roo.DomHelper.insertHtml("beforeBegin", document.body.firstChild, markup));
209 sh.autoBoxAdjust = false;
221 * base class for bootstrap elements.
225 Roo.bootstrap = Roo.bootstrap || {};
227 * @class Roo.bootstrap.Component
228 * @extends Roo.Component
230 * @children Roo.bootstrap.Component
231 * Bootstrap Component base class
232 * @cfg {String} cls css class
233 * @cfg {String} style any extra css
234 * @cfg {Object} xattr extra attributes to add to 'element' (used by builder to store stuff.)
235 * @cfg {Boolean} can_build_overlaid True if element can be rebuild from a HTML page
236 * @cfg {string} dataId cutomer id
237 * @cfg {string} name Specifies name attribute
238 * @cfg {string} tooltip Text for the tooltip
239 * @cfg {string} container_method method to fetch parents container element (used by NavHeaderbar - getHeaderChildContainer)
240 * @cfg {string|object} visibilityEl (el|parent) What element to use for visibility (@see getVisibilityEl())
243 * Do not use directly - it does not do anything..
244 * @param {Object} config The config object
249 Roo.bootstrap.Component = function(config){
250 Roo.bootstrap.Component.superclass.constructor.call(this, config);
254 * @event childrenrendered
255 * Fires when the children have been rendered..
256 * @param {Roo.bootstrap.Component} this
258 "childrenrendered" : true
267 Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent, {
270 allowDomMove : false, // to stop relocations in parent onRender...
280 * Initialize Events for the element
282 initEvents : function() { },
288 can_build_overlaid : true,
290 container_method : false,
297 // returns the parent component..
298 return Roo.ComponentMgr.get(this.parentId)
304 onRender : function(ct, position)
306 // Roo.log("Call onRender: " + this.xtype);
308 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
311 if (this.el.attr('xtype')) {
312 this.el.attr('xtypex', this.el.attr('xtype'));
313 this.el.dom.removeAttribute('xtype');
323 var cfg = Roo.apply({}, this.getAutoCreate());
325 cfg.id = this.id || Roo.id();
327 // fill in the extra attributes
328 if (this.xattr && typeof(this.xattr) =='object') {
329 for (var i in this.xattr) {
330 cfg[i] = this.xattr[i];
335 cfg.dataId = this.dataId;
339 cfg.cls = (typeof(cfg.cls) == 'undefined' ? this.cls : cfg.cls) + ' ' + this.cls;
342 if (this.style) { // fixme needs to support more complex style data.
343 cfg.style = (typeof(cfg.style) == 'undefined' ? this.style : cfg.style) + '; ' + this.style;
347 cfg.name = this.name;
350 this.el = ct.createChild(cfg, position);
353 this.tooltipEl().attr('tooltip', this.tooltip);
356 if(this.tabIndex !== undefined){
357 this.el.dom.setAttribute('tabIndex', this.tabIndex);
364 * Fetch the element to add children to
365 * @return {Roo.Element} defaults to this.el
367 getChildContainer : function()
371 getDocumentBody : function() // used by menus - as they are attached to the body so zIndexes work
373 return Roo.get(document.body);
377 * Fetch the element to display the tooltip on.
378 * @return {Roo.Element} defaults to this.el
380 tooltipEl : function()
385 addxtype : function(tree,cntr)
389 cn = Roo.factory(tree);
390 //Roo.log(['addxtype', cn]);
392 cn.parentType = this.xtype; //??
393 cn.parentId = this.id;
395 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
396 if (typeof(cn.container_method) == 'string') {
397 cntr = cn.container_method;
401 var has_flexy_each = (typeof(tree['flexy:foreach']) != 'undefined');
403 var has_flexy_if = (typeof(tree['flexy:if']) != 'undefined');
405 var build_from_html = Roo.XComponent.build_from_html;
407 var is_body = (tree.xtype == 'Body') ;
409 var page_has_body = (Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body');
411 var self_cntr_el = Roo.get(this[cntr](false));
413 // do not try and build conditional elements
414 if ((has_flexy_each || has_flexy_if || this.can_build_overlaid == false ) && build_from_html) {
418 if (!has_flexy_each || !build_from_html || is_body || !page_has_body) {
419 if(!has_flexy_if || typeof(tree.name) == 'undefined' || !build_from_html || is_body || !page_has_body){
420 return this.addxtypeChild(tree,cntr, is_body);
423 var echild =self_cntr_el ? self_cntr_el.child('>*[name=' + tree.name + ']') : false;
426 return this.addxtypeChild(Roo.apply({}, tree),cntr);
429 Roo.log('skipping render');
435 if (!build_from_html) {
439 // this i think handles overlaying multiple children of the same type
440 // with the sam eelement.. - which might be buggy..
442 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
448 if (echild && echild.attr('xtype').split('.').pop() != cn.xtype) {
452 ret = this.addxtypeChild(Roo.apply({}, tree),cntr);
459 addxtypeChild : function (tree, cntr, is_body)
461 Roo.debug && Roo.log('addxtypeChild:' + cntr);
463 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
466 var has_flexy = (typeof(tree['flexy:if']) != 'undefined') ||
467 (typeof(tree['flexy:foreach']) != 'undefined');
471 skip_children = false;
472 // render the element if it's not BODY.
475 // if parent was disabled, then do not try and create the children..
476 if(!this[cntr](true)){
481 cn = Roo.factory(tree);
483 cn.parentType = this.xtype; //??
484 cn.parentId = this.id;
486 var build_from_html = Roo.XComponent.build_from_html;
489 // does the container contain child eleemnts with 'xtype' attributes.
490 // that match this xtype..
491 // note - when we render we create these as well..
492 // so we should check to see if body has xtype set.
493 if (build_from_html && Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body') {
495 var self_cntr_el = Roo.get(this[cntr](false));
496 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
498 //Roo.log(Roo.XComponent.build_from_html);
499 //Roo.log("got echild:");
502 // there is a scenario where some of the child elements are flexy:if (and all of the same type)
503 // and are not displayed -this causes this to use up the wrong element when matching.
504 // at present the only work around for this is to nest flexy:if elements in another element that is always rendered.
507 if (echild && echild.attr('xtype').split('.').pop() == cn.xtype) {
508 // Roo.log("found child for " + this.xtype +": " + echild.attr('xtype') );
514 //echild.dom.removeAttribute('xtype');
516 Roo.debug && Roo.log("MISSING " + cn.xtype + " on child of " + (this.el ? this.el.attr('xbuilderid') : 'no parent'));
517 Roo.debug && Roo.log(self_cntr_el);
518 Roo.debug && Roo.log(echild);
519 Roo.debug && Roo.log(cn);
525 // if object has flexy:if - then it may or may not be rendered.
526 if (build_from_html && has_flexy && !cn.el && cn.can_build_overlaid) {
527 // skip a flexy if element.
528 Roo.debug && Roo.log('skipping render');
529 Roo.debug && Roo.log(tree);
531 Roo.debug && Roo.log('skipping all children');
532 skip_children = true;
537 // actually if flexy:foreach is found, we really want to create
538 // multiple copies here...
540 //Roo.log(this[cntr]());
541 // some elements do not have render methods.. like the layouts...
543 if(this[cntr](true) === false){
548 cn.render && cn.render(this[cntr](true));
551 // then add the element..
558 if (typeof (tree.menu) != 'undefined') {
559 tree.menu.parentType = cn.xtype;
560 tree.menu.triggerEl = cn.el;
561 nitems.push(cn.addxtype(Roo.apply({}, tree.menu)));
565 if (!tree.items || !tree.items.length) {
567 //Roo.log(["no children", this]);
572 var items = tree.items;
575 //Roo.log(items.length);
577 if (!skip_children) {
578 for(var i =0;i < items.length;i++) {
579 // Roo.log(['add child', items[i]]);
580 nitems.push(cn.addxtype(Roo.apply({}, items[i])));
586 //Roo.log("fire childrenrendered");
588 cn.fireEvent('childrenrendered', this);
594 * Set the element that will be used to show or hide
596 setVisibilityEl : function(el)
598 this.visibilityEl = el;
602 * Get the element that will be used to show or hide
604 getVisibilityEl : function()
606 if (typeof(this.visibilityEl) == 'object') {
607 return this.visibilityEl;
610 if (typeof(this.visibilityEl) == 'string') {
611 return this.visibilityEl == 'parent' ? this.parent().getEl() : this.getEl();
618 * Show a component - removes 'hidden' class
622 if(!this.getVisibilityEl()){
626 this.getVisibilityEl().removeClass(['hidden','d-none']);
628 this.fireEvent('show', this);
633 * Hide a component - adds 'hidden' class
637 if(!this.getVisibilityEl()){
641 this.getVisibilityEl().addClass(['hidden','d-none']);
643 this.fireEvent('hide', this);
656 * @class Roo.bootstrap.Element
657 * @extends Roo.bootstrap.Component
658 * @children Roo.bootstrap.Component
659 * Bootstrap Element class (basically a DIV used to make random stuff )
661 * @cfg {String} html contents of the element
662 * @cfg {String} tag tag of the element
663 * @cfg {String} cls class of the element
664 * @cfg {Boolean} preventDefault (true|false) default false
665 * @cfg {Boolean} clickable (true|false) default false
666 * @cfg {String} role default blank - set to button to force cursor pointer
670 * Create a new Element
671 * @param {Object} config The config object
674 Roo.bootstrap.Element = function(config){
675 Roo.bootstrap.Element.superclass.constructor.call(this, config);
681 * When a element is chick
682 * @param {Roo.bootstrap.Element} this
683 * @param {Roo.EventObject} e
691 Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, {
696 preventDefault: false,
701 getAutoCreate : function(){
705 // cls: this.cls, double assign in parent class Component.js :: onRender
708 if (this.role !== false) {
709 cfg.role = this.role;
715 initEvents: function()
717 Roo.bootstrap.Element.superclass.initEvents.call(this);
720 this.el.on('click', this.onClick, this);
726 onClick : function(e)
728 if(this.preventDefault){
732 this.fireEvent('click', this, e); // why was this double click before?
740 getValue : function()
742 return this.el.dom.innerHTML;
745 setValue : function(value)
747 this.el.dom.innerHTML = value;
762 * @class Roo.bootstrap.DropTarget
763 * @extends Roo.bootstrap.Element
764 * Bootstrap DropTarget class
766 * @cfg {string} name dropable name
769 * Create a new Dropable Area
770 * @param {Object} config The config object
773 Roo.bootstrap.DropTarget = function(config){
774 Roo.bootstrap.DropTarget.superclass.constructor.call(this, config);
780 * When a element is chick
781 * @param {Roo.bootstrap.Element} this
782 * @param {Roo.EventObject} e
788 Roo.extend(Roo.bootstrap.DropTarget, Roo.bootstrap.Element, {
791 getAutoCreate : function(){
796 initEvents: function()
798 Roo.bootstrap.DropTarget.superclass.initEvents.call(this);
799 this.dropZone = new Roo.dd.DropTarget(this.getEl(), {
802 drop : this.dragDrop.createDelegate(this),
803 enter : this.dragEnter.createDelegate(this),
804 out : this.dragOut.createDelegate(this),
805 over : this.dragOver.createDelegate(this)
809 this.dropZone.DDM.useCache = false // so data gets refreshed when we resize stuff
812 dragDrop : function(source,e,data)
814 // user has to decide how to impliment this.
817 //this.fireEvent('drop', this, source, e ,data);
821 dragEnter : function(n, dd, e, data)
823 // probably want to resize the element to match the dropped element..
825 this.originalSize = this.el.getSize();
826 this.el.setSize( n.el.getSize());
827 this.dropZone.DDM.refreshCache(this.name);
828 Roo.log([n, dd, e, data]);
831 dragOut : function(value)
833 // resize back to normal
835 this.el.setSize(this.originalSize);
836 this.dropZone.resetConstraints();
839 dragOver : function()
856 * @class Roo.bootstrap.Body
857 * @extends Roo.bootstrap.Component
858 * @children Roo.bootstrap.Component
859 * @parent none builder
860 * Bootstrap Body class
864 * @param {Object} config The config object
867 Roo.bootstrap.Body = function(config){
869 config = config || {};
871 Roo.bootstrap.Body.superclass.constructor.call(this, config);
872 this.el = Roo.get(config.el ? config.el : document.body );
873 if (this.cls && this.cls.length) {
874 Roo.get(document.body).addClass(this.cls);
878 Roo.extend(Roo.bootstrap.Body, Roo.bootstrap.Component, {
880 is_body : true,// just to make sure it's constructed?
885 onRender : function(ct, position)
887 /* Roo.log("Roo.bootstrap.Body - onRender");
888 if (this.cls && this.cls.length) {
889 Roo.get(document.body).addClass(this.cls);
908 * @class Roo.bootstrap.ButtonGroup
909 * @extends Roo.bootstrap.Component
910 * Bootstrap ButtonGroup class
911 * @children Roo.bootstrap.Button Roo.bootstrap.form.Form
913 * @cfg {String} size lg | sm | xs (default empty normal)
914 * @cfg {String} align vertical | justified (default none)
915 * @cfg {String} direction up | down (default down)
916 * @cfg {Boolean} toolbar false | true
917 * @cfg {Boolean} btn true | false
922 * @param {Object} config The config object
925 Roo.bootstrap.ButtonGroup = function(config){
926 Roo.bootstrap.ButtonGroup.superclass.constructor.call(this, config);
929 Roo.extend(Roo.bootstrap.ButtonGroup, Roo.bootstrap.Component, {
937 getAutoCreate : function(){
943 cfg.html = this.html || cfg.html;
954 if (['vertical','justified'].indexOf(this.align)!==-1) {
955 cfg.cls = 'btn-group-' + this.align;
957 if (this.align == 'justified') {
958 console.log(this.items);
962 if (['lg','sm','xs'].indexOf(this.size)!==-1) {
963 cfg.cls += ' btn-group-' + this.size;
966 if (this.direction == 'up') {
967 cfg.cls += ' dropup' ;
973 * Add a button to the group (similar to NavItem API.)
975 addItem : function(cfg)
977 var cn = new Roo.bootstrap.Button(cfg);
979 cn.parentId = this.id;
980 cn.onRender(this.el, null);
994 * @class Roo.bootstrap.Button
995 * @extends Roo.bootstrap.Component
996 * Bootstrap Button class
997 * @cfg {String} html The button content
998 * @cfg {String} weight (default|primary|secondary|success|info|warning|danger|link|light|dark) default
999 * @cfg {String} badge_weight (default|primary|secondary|success|info|warning|danger|link|light|dark) default (same as button)
1000 * @cfg {Boolean} outline default false (except for weight=default which emulates old behaveiour with an outline)
1001 * @cfg {String} size (lg|sm|xs)
1002 * @cfg {String} tag (a|input|submit)
1003 * @cfg {String} href empty or href
1004 * @cfg {Boolean} disabled default false;
1005 * @cfg {Boolean} isClose default false;
1006 * @cfg {String} glyphicon depricated - use fa
1007 * @cfg {String} fa fontawesome icon - eg. 'comment' - without the fa/fas etc..
1008 * @cfg {String} badge text for badge
1009 * @cfg {String} theme (default|glow)
1010 * @cfg {Boolean} inverse dark themed version
1011 * @cfg {Boolean} toggle is it a slidy toggle button
1012 * @cfg {Boolean} pressed default null - if the button ahs active state
1013 * @cfg {String} ontext text for on slidy toggle state
1014 * @cfg {String} offtext text for off slidy toggle state
1015 * @cfg {Boolean} preventDefault default true (stop click event triggering the URL if it's a link.)
1016 * @cfg {Boolean} removeClass remove the standard class..
1017 * @cfg {String} target (_self|_blank|_parent|_top|other) target for a href.
1018 * @cfg {Boolean} grpup if parent is a btn group - then it turns it into a toogleGroup.
1019 * @cfg {Roo.bootstrap.menu.Menu} menu a Menu
1022 * Create a new button
1023 * @param {Object} config The config object
1027 Roo.bootstrap.Button = function(config){
1028 Roo.bootstrap.Button.superclass.constructor.call(this, config);
1034 * When a button is pressed
1035 * @param {Roo.bootstrap.Button} btn
1036 * @param {Roo.EventObject} e
1041 * When a button is double clicked
1042 * @param {Roo.bootstrap.Button} btn
1043 * @param {Roo.EventObject} e
1048 * After the button has been toggles
1049 * @param {Roo.bootstrap.Button} btn
1050 * @param {Roo.EventObject} e
1051 * @param {boolean} pressed (also available as button.pressed)
1057 Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, {
1078 preventDefault: true,
1087 getAutoCreate : function(){
1095 if (['a', 'button', 'input', 'submit'].indexOf(this.tag) < 0) {
1096 throw "Invalid value for tag: " + this.tag + ". must be a, button, input or submit.";
1097 this.tag = 'button';
1101 cfg.html = '<span class="roo-button-text">' + (this.html || cfg.html) + '</span>';
1103 if (this.toggle == true) {
1106 cls: 'slider-frame roo-button',
1110 'data-on-text':'ON',
1111 'data-off-text':'OFF',
1112 cls: 'slider-button',
1117 // why are we validating the weights?
1118 if (Roo.bootstrap.Button.weights.indexOf(this.weight) > -1) {
1119 cfg.cls += ' ' + this.weight;
1126 cfg.cls += ' close';
1128 cfg["aria-hidden"] = true;
1130 cfg.html = "×";
1136 if (this.theme==='default') {
1137 cfg.cls = 'btn roo-button';
1139 //if (this.parentType != 'Navbar') {
1140 this.weight = this.weight.length ? this.weight : 'default';
1142 if (Roo.bootstrap.Button.weights.indexOf(this.weight) > -1) {
1144 var outline = this.outline || this.weight == 'default' ? 'outline-' : '';
1145 var weight = this.weight == 'default' ? 'secondary' : this.weight;
1146 cfg.cls += ' btn-' + outline + weight;
1147 if (this.weight == 'default') {
1149 cfg.cls += ' btn-' + this.weight;
1152 } else if (this.theme==='glow') {
1155 cfg.cls = 'btn-glow roo-button';
1157 if (Roo.bootstrap.Button.weights.indexOf(this.weight) > -1) {
1159 cfg.cls += ' ' + this.weight;
1165 this.cls += ' inverse';
1169 if (this.active || this.pressed === true) {
1170 cfg.cls += ' active';
1173 if (this.disabled) {
1174 cfg.disabled = 'disabled';
1178 Roo.log('changing to ul' );
1180 this.glyphicon = 'caret';
1181 if (Roo.bootstrap.version == 4) {
1182 this.fa = 'caret-down';
1187 cfg.cls += this.size.length ? (' btn-' + this.size) : '';
1189 //gsRoo.log(this.parentType);
1190 if (this.parentType === 'Navbar' && !this.parent().bar) {
1191 Roo.log('changing to li?');
1200 href : this.href || '#'
1203 cfg.cn[0].html = this.html + ' <span class="caret"></span>';
1204 cfg.cls += ' dropdown';
1211 cfg.cls += this.parentType === 'Navbar' ? ' navbar-btn' : '';
1213 if (this.glyphicon) {
1214 cfg.html = ' ' + cfg.html;
1219 cls: 'glyphicon glyphicon-' + this.glyphicon
1224 cfg.html = ' ' + cfg.html;
1229 cls: 'fa fas fa-' + this.fa
1239 // cfg.cls='btn roo-button';
1243 var value = cfg.html;
1248 cls: 'glyphicon glyphicon-' + this.glyphicon,
1255 cls: 'fa fas fa-' + this.fa,
1260 var bw = this.badge_weight.length ? this.badge_weight :
1261 (this.weight.length ? this.weight : 'secondary');
1262 bw = bw == 'default' ? 'secondary' : bw;
1268 cls: 'badge badge-' + bw,
1277 cfg.cls += ' dropdown';
1278 cfg.html = typeof(cfg.html) != 'undefined' ?
1279 cfg.html + ' <span class="caret"></span>' : '<span class="caret"></span>';
1282 if (cfg.tag !== 'a' && this.href !== '') {
1283 throw "Tag must be a to set href.";
1284 } else if (this.href.length > 0) {
1285 cfg.href = this.href;
1288 if(this.removeClass){
1293 cfg.target = this.target;
1298 initEvents: function() {
1299 // Roo.log('init events?');
1300 // Roo.log(this.el.dom);
1303 if (typeof (this.menu) != 'undefined') {
1304 this.menu.parentType = this.xtype;
1305 this.menu.triggerEl = this.el;
1306 this.addxtype(Roo.apply({}, this.menu));
1310 if (this.el.hasClass('roo-button')) {
1311 this.el.on('click', this.onClick, this);
1312 this.el.on('dblclick', this.onDblClick, this);
1314 this.el.select('.roo-button').on('click', this.onClick, this);
1315 this.el.select('.roo-button').on('dblclick', this.onDblClick, this);
1319 if(this.removeClass){
1320 this.el.on('click', this.onClick, this);
1323 if (this.group === true) {
1324 if (this.pressed === false || this.pressed === true) {
1327 this.pressed = false;
1328 this.setActive(this.pressed);
1333 this.el.enableDisplayMode();
1336 onClick : function(e)
1338 if (this.disabled) {
1342 Roo.log('button on click ');
1343 if(this.preventDefault){
1352 this.setActive(true);
1353 var pi = this.parent().items;
1354 for (var i = 0;i < pi.length;i++) {
1355 if (this == pi[i]) {
1358 if (pi[i].el.hasClass('roo-button')) {
1359 pi[i].setActive(false);
1362 this.fireEvent('click', this, e);
1366 if (this.pressed === true || this.pressed === false) {
1367 this.toggleActive(e);
1371 this.fireEvent('click', this, e);
1373 onDblClick: function(e)
1375 if (this.disabled) {
1378 if(this.preventDefault){
1381 this.fireEvent('dblclick', this, e);
1384 * Enables this button
1388 this.disabled = false;
1389 this.el.removeClass('disabled');
1390 this.el.dom.removeAttribute("disabled");
1394 * Disable this button
1396 disable : function()
1398 this.disabled = true;
1399 this.el.addClass('disabled');
1400 this.el.attr("disabled", "disabled")
1403 * sets the active state on/off,
1404 * @param {Boolean} state (optional) Force a particular state
1406 setActive : function(v) {
1408 this.el[v ? 'addClass' : 'removeClass']('active');
1412 * toggles the current active state
1414 toggleActive : function(e)
1416 this.setActive(!this.pressed); // this modifies pressed...
1417 this.fireEvent('toggle', this, e, this.pressed);
1420 * get the current active state
1421 * @return {boolean} true if it's active
1423 isActive : function()
1425 return this.el.hasClass('active');
1428 * set the text of the first selected button
1430 setText : function(str)
1432 this.el.select('.roo-button-text',true).first().dom.innerHTML = str;
1435 * get the text of the first selected button
1437 getText : function()
1439 return this.el.select('.roo-button-text',true).first().dom.innerHTML;
1442 setWeight : function(str)
1444 this.el.removeClass(Roo.bootstrap.Button.weights.map(function(w) { return 'btn-' + w; } ) );
1445 this.el.removeClass(Roo.bootstrap.Button.weights.map(function(w) { return 'btn-outline-' + w; } ) );
1447 var outline = this.outline ? 'outline-' : '';
1448 if (str == 'default') {
1449 this.el.addClass('btn-default btn-outline-secondary');
1452 this.el.addClass('btn-' + outline + str);
1457 // fixme - this is probably generic bootstrap - should go in some kind of enum file.. - like sizes.
1459 Roo.bootstrap.Button.weights = [
1479 * @class Roo.bootstrap.Column
1480 * @extends Roo.bootstrap.Component
1481 * @children Roo.bootstrap.Component
1482 * Bootstrap Column class
1483 * @cfg {Number} xs colspan out of 12 for mobile-sized screens or 0 for hidden
1484 * @cfg {Number} sm colspan out of 12 for tablet-sized screens or 0 for hidden
1485 * @cfg {Number} md colspan out of 12 for computer-sized screens or 0 for hidden
1486 * @cfg {Number} lg colspan out of 12 for large computer-sized screens or 0 for hidden
1487 * @cfg {Number} xsoff colspan offset out of 12 for mobile-sized screens or 0 for hidden
1488 * @cfg {Number} smoff colspan offset out of 12 for tablet-sized screens or 0 for hidden
1489 * @cfg {Number} mdoff colspan offset out of 12 for computer-sized screens or 0 for hidden
1490 * @cfg {Number} lgoff colspan offset out of 12 for large computer-sized screens or 0 for hidden
1493 * @cfg {Boolean} hidden (true|false) hide the element
1494 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1495 * @cfg {String} fa (ban|check|...) font awesome icon
1496 * @cfg {Number} fasize (1|2|....) font awsome size
1498 * @cfg {String} icon (info-sign|check|...) glyphicon name
1500 * @cfg {String} html content of column.
1503 * Create a new Column
1504 * @param {Object} config The config object
1507 Roo.bootstrap.Column = function(config){
1508 Roo.bootstrap.Column.superclass.constructor.call(this, config);
1511 Roo.extend(Roo.bootstrap.Column, Roo.bootstrap.Component, {
1529 getAutoCreate : function(){
1530 var cfg = Roo.apply({}, Roo.bootstrap.Column.superclass.getAutoCreate.call(this));
1538 var sizes = ['xs','sm','md','lg'];
1539 sizes.map(function(size ,ix){
1540 //Roo.log( size + ':' + settings[size]);
1542 if (settings[size+'off'] !== false) {
1543 cfg.cls += ' col-' + size + '-offset-' + settings[size+'off'] ;
1546 if (settings[size] === false) {
1550 if (!settings[size]) { // 0 = hidden
1551 cfg.cls += ' hidden-' + size + ' hidden-' + size + '-down';
1553 for (var i = ix; i > -1; i--) {
1554 cfg.cls += ' d-' + sizes[i] + '-none';
1560 cfg.cls += ' col-' + size + '-' + settings[size] + (
1561 size == 'xs' ? (' col-' + settings[size] ) : '' // bs4 col-{num} replaces col-xs
1567 cfg.cls += ' hidden';
1570 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1571 cfg.cls +=' alert alert-' + this.alert;
1575 if (this.html.length) {
1576 cfg.html = this.html;
1580 if (this.fasize > 1) {
1581 fasize = ' fa-' + this.fasize + 'x';
1583 cfg.html = '<i class="fa fa-'+this.fa + fasize + '"></i>' + (cfg.html || '');
1588 cfg.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + (cfg.html || '');
1607 * @class Roo.bootstrap.Container
1608 * @extends Roo.bootstrap.Component
1609 * @children Roo.bootstrap.Component
1611 * Bootstrap Container class
1612 * @cfg {Boolean} jumbotron is it a jumbotron element
1613 * @cfg {String} html content of element
1614 * @cfg {String} well (lg|sm|md) a well, large, small or medium.
1615 * @cfg {String} panel (default|primary|success|info|warning|danger) render as panel - type - primary/success.....
1616 * @cfg {String} header content of header (for panel)
1617 * @cfg {String} footer content of footer (for panel)
1618 * @cfg {String} sticky (footer|wrap|push) block to use as footer or body- needs css-bootstrap/sticky-footer.css
1619 * @cfg {String} tag (header|aside|section) type of HTML tag.
1620 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1621 * @cfg {String} fa font awesome icon
1622 * @cfg {String} icon (info-sign|check|...) glyphicon name
1623 * @cfg {Boolean} hidden (true|false) hide the element
1624 * @cfg {Boolean} expandable (true|false) default false
1625 * @cfg {Boolean} expanded (true|false) default true
1626 * @cfg {String} rheader contet on the right of header
1627 * @cfg {Boolean} clickable (true|false) default false
1631 * Create a new Container
1632 * @param {Object} config The config object
1635 Roo.bootstrap.Container = function(config){
1636 Roo.bootstrap.Container.superclass.constructor.call(this, config);
1642 * After the panel has been expand
1644 * @param {Roo.bootstrap.Container} this
1649 * After the panel has been collapsed
1651 * @param {Roo.bootstrap.Container} this
1656 * When a element is chick
1657 * @param {Roo.bootstrap.Container} this
1658 * @param {Roo.EventObject} e
1664 Roo.extend(Roo.bootstrap.Container, Roo.bootstrap.Component, {
1682 getChildContainer : function() {
1688 if (this.panel.length) {
1689 return this.el.select('.panel-body',true).first();
1696 getAutoCreate : function(){
1699 tag : this.tag || 'div',
1703 if (this.jumbotron) {
1704 cfg.cls = 'jumbotron';
1709 // - this is applied by the parent..
1711 // cfg.cls = this.cls + '';
1714 if (this.sticky.length) {
1716 var bd = Roo.get(document.body);
1717 if (!bd.hasClass('bootstrap-sticky')) {
1718 bd.addClass('bootstrap-sticky');
1719 Roo.select('html',true).setStyle('height', '100%');
1722 cfg.cls += 'bootstrap-sticky-' + this.sticky;
1726 if (this.well.length) {
1727 switch (this.well) {
1730 cfg.cls +=' well well-' +this.well;
1739 cfg.cls += ' hidden';
1743 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1744 cfg.cls +=' alert alert-' + this.alert;
1749 if (this.panel.length) {
1750 cfg.cls += ' panel panel-' + this.panel;
1752 if (this.header.length) {
1756 if(this.expandable){
1758 cfg.cls = cfg.cls + ' expandable';
1762 cls: (this.expanded ? 'fa fa-minus' : 'fa fa-plus')
1770 cls : 'panel-title',
1771 html : (this.expandable ? ' ' : '') + this.header
1775 cls: 'panel-header-right',
1781 cls : 'panel-heading',
1782 style : this.expandable ? 'cursor: pointer' : '',
1790 cls : 'panel-body' + (this.expanded ? '' : ' hide'),
1795 if (this.footer.length) {
1797 cls : 'panel-footer',
1806 body.html = this.html || cfg.html;
1807 // prefix with the icons..
1809 body.html = '<i class="fa fa-'+this.fa + '"></i>' + body.html ;
1812 body.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + body.html ;
1817 if ((!this.cls || !this.cls.length) && (!cfg.cls || !cfg.cls.length)) {
1818 cfg.cls = 'container';
1824 initEvents: function()
1826 if(this.expandable){
1827 var headerEl = this.headerEl();
1830 headerEl.on('click', this.onToggleClick, this);
1835 this.el.on('click', this.onClick, this);
1840 onToggleClick : function()
1842 var headerEl = this.headerEl();
1858 if(this.fireEvent('expand', this)) {
1860 this.expanded = true;
1862 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).show();
1864 this.el.select('.panel-body',true).first().removeClass('hide');
1866 var toggleEl = this.toggleEl();
1872 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-minus']);
1877 collapse : function()
1879 if(this.fireEvent('collapse', this)) {
1881 this.expanded = false;
1883 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).hide();
1884 this.el.select('.panel-body',true).first().addClass('hide');
1886 var toggleEl = this.toggleEl();
1892 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-plus']);
1896 toggleEl : function()
1898 if(!this.el || !this.panel.length || !this.header.length || !this.expandable){
1902 return this.el.select('.panel-heading .fa',true).first();
1905 headerEl : function()
1907 if(!this.el || !this.panel.length || !this.header.length){
1911 return this.el.select('.panel-heading',true).first()
1916 if(!this.el || !this.panel.length){
1920 return this.el.select('.panel-body',true).first()
1923 titleEl : function()
1925 if(!this.el || !this.panel.length || !this.header.length){
1929 return this.el.select('.panel-title',true).first();
1932 setTitle : function(v)
1934 var titleEl = this.titleEl();
1940 titleEl.dom.innerHTML = v;
1943 getTitle : function()
1946 var titleEl = this.titleEl();
1952 return titleEl.dom.innerHTML;
1955 setRightTitle : function(v)
1957 var t = this.el.select('.panel-header-right',true).first();
1963 t.dom.innerHTML = v;
1966 onClick : function(e)
1970 this.fireEvent('click', this, e);
1975 * @class Roo.bootstrap.Card
1976 * @extends Roo.bootstrap.Component
1977 * @children Roo.bootstrap.Component
1979 * Bootstrap Card class - note this has children as CardHeader/ImageTop/Footer.. - which should really be listed properties?
1982 * possible... may not be implemented..
1983 * @cfg {String} header_image src url of image.
1984 * @cfg {String|Object} header
1985 * @cfg {Number} header_size (0|1|2|3|4|5) H1 or H2 etc.. 0 indicates default
1986 * @cfg {Number} header_weight (primary|secondary|success|info|warning|danger|light|dark)
1988 * @cfg {String} title
1989 * @cfg {String} subtitle
1990 * @cfg {String|Boolean} html -- html contents - or just use children.. use false to hide it..
1991 * @cfg {String} footer
1993 * @cfg {String} weight (primary|warning|info|danger|secondary|success|light|dark)
1995 * @cfg {String} margin (0|1|2|3|4|5|auto)
1996 * @cfg {String} margin_top (0|1|2|3|4|5|auto)
1997 * @cfg {String} margin_bottom (0|1|2|3|4|5|auto)
1998 * @cfg {String} margin_left (0|1|2|3|4|5|auto)
1999 * @cfg {String} margin_right (0|1|2|3|4|5|auto)
2000 * @cfg {String} margin_x (0|1|2|3|4|5|auto)
2001 * @cfg {String} margin_y (0|1|2|3|4|5|auto)
2003 * @cfg {String} padding (0|1|2|3|4|5)
2004 * @cfg {String} padding_top (0|1|2|3|4|5)next_to_card
2005 * @cfg {String} padding_bottom (0|1|2|3|4|5)
2006 * @cfg {String} padding_left (0|1|2|3|4|5)
2007 * @cfg {String} padding_right (0|1|2|3|4|5)
2008 * @cfg {String} padding_x (0|1|2|3|4|5)
2009 * @cfg {String} padding_y (0|1|2|3|4|5)
2011 * @cfg {String} display (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
2012 * @cfg {String} display_xs (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
2013 * @cfg {String} display_sm (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
2014 * @cfg {String} display_lg (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
2015 * @cfg {String} display_xl (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
2017 * @config {Boolean} dragable if this card can be dragged.
2018 * @config {String} drag_group group for drag
2019 * @config {Boolean} dropable if this card can recieve other cards being dropped onto it..
2020 * @config {String} drop_group group for drag
2022 * @config {Boolean} collapsable can the body be collapsed.
2023 * @config {Boolean} collapsed is the body collapsed when rendered...
2024 * @config {Boolean} rotateable can the body be rotated by clicking on it..
2025 * @config {Boolean} rotated is the body rotated when rendered...
2028 * Create a new Container
2029 * @param {Object} config The config object
2032 Roo.bootstrap.Card = function(config){
2033 Roo.bootstrap.Card.superclass.constructor.call(this, config);
2039 * When a element a card is dropped
2040 * @param {Roo.bootstrap.Card} this
2043 * @param {Roo.bootstrap.Card} move_card the card being dropped?
2044 * @param {String} position 'above' or 'below'
2045 * @param {Roo.bootstrap.Card} next_to_card What card position is relative to of 'false' for empty list.
2051 * When a element a card is rotate
2052 * @param {Roo.bootstrap.Card} this
2053 * @param {Roo.Element} n the node being dropped?
2054 * @param {Boolean} rotate status
2059 * When a card element is dragged over ready to drop (return false to block dropable)
2060 * @param {Roo.bootstrap.Card} this
2061 * @param {Object} data from dragdrop
2069 Roo.extend(Roo.bootstrap.Card, Roo.bootstrap.Component, {
2074 margin: '', /// may be better in component?
2104 collapsable : false,
2113 childContainer : false,
2114 dropEl : false, /// the dom placeholde element that indicates drop location.
2115 containerEl: false, // body container
2116 bodyEl: false, // card-body
2117 headerContainerEl : false, //
2119 header_imageEl : false,
2122 layoutCls : function()
2126 Roo.log(this.margin_bottom.length);
2127 ['', 'top', 'bottom', 'left', 'right', 'x', 'y' ].forEach(function(v) {
2128 // in theory these can do margin_top : ml-xs-3 ??? but we don't support that yet
2130 if (('' + t['margin' + (v.length ? '_' : '') + v]).length) {
2131 cls += ' m' + (v.length ? v[0] : '') + '-' + t['margin' + (v.length ? '_' : '') + v];
2133 if (('' + t['padding' + (v.length ? '_' : '') + v]).length) {
2134 cls += ' p' + (v.length ? v[0] : '') + '-' + t['padding' + (v.length ? '_' : '') + v];
2138 ['', 'xs', 'sm', 'lg', 'xl'].forEach(function(v) {
2139 if (('' + t['display' + (v.length ? '_' : '') + v]).length) {
2140 cls += ' d' + (v.length ? '-' : '') + v + '-' + t['display' + (v.length ? '_' : '') + v]
2144 // more generic support?
2152 // Roo.log("Call onRender: " + this.xtype);
2153 /* We are looking at something like this.
2155 <img src="..." class="card-img-top" alt="...">
2156 <div class="card-body">
2157 <h5 class="card-title">Card title</h5>
2158 <h6 class="card-subtitle mb-2 text-muted">Card subtitle</h6>
2160 >> this bit is really the body...
2161 <div> << we will ad dthis in hopefully it will not break shit.
2163 ** card text does not actually have any styling...
2165 <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
2168 <a href="#" class="card-link">Card link</a>
2171 <div class="card-footer">
2172 <small class="text-muted">Last updated 3 mins ago</small>
2176 getAutoCreate : function(){
2184 if (this.weight.length && this.weight != 'light') {
2185 cfg.cls += ' text-white';
2187 cfg.cls += ' text-dark'; // need as it's nested..
2189 if (this.weight.length) {
2190 cfg.cls += ' bg-' + this.weight;
2193 cfg.cls += ' ' + this.layoutCls();
2196 var hdr_ctr = false;
2197 if (this.header.length) {
2199 tag : this.header_size > 0 ? 'h' + this.header_size : 'div',
2200 cls : 'card-header ' + (this.header_weight ? 'bg-' + this.header_weight : ''),
2208 cls : 'card-header d-none ' + (this.header_weight ? 'bg-' + this.header_weight : ''),
2214 if (this.collapsable) {
2217 cls : 'd-block user-select-none',
2221 cls : 'roo-collapse-toggle fa fa-chevron-down float-right ' + (this.collapsed ? 'collapsed' : '')
2226 hdr.cn.push(hdr_ctr);
2231 cls: 'roo-card-header-ctr' + ( this.header.length ? '' : ' d-none'),
2236 if (this.header_image.length) {
2239 cls : 'card-img-top',
2240 src: this.header_image // escape?
2245 cls : 'card-img-top d-none'
2251 cls : 'card-body' + (this.html === false ? ' d-none' : ''),
2255 if (this.collapsable || this.rotateable) {
2258 cls : 'roo-collapsable collapse ' + (this.collapsed || this.rotated ? '' : 'show'),
2265 if (this.title.length) {
2269 src: this.title // escape?
2273 if (this.subtitle.length) {
2277 src: this.subtitle // escape?
2283 cls : 'roo-card-body-ctr'
2286 if (this.html.length) {
2292 // fixme ? handle objects?
2294 if (this.footer.length) {
2297 cls : 'card-footer ' + (this.rotated ? 'd-none' : ''),
2302 cfg.cn.push({cls : 'card-footer d-none'});
2311 getCardHeader : function()
2313 var ret = this.el.select('.card-header',true).first();
2314 if (ret.hasClass('d-none')) {
2315 ret.removeClass('d-none');
2320 getCardFooter : function()
2322 var ret = this.el.select('.card-footer',true).first();
2323 if (ret.hasClass('d-none')) {
2324 ret.removeClass('d-none');
2329 getCardImageTop : function()
2331 var ret = this.header_imageEl;
2332 if (ret.hasClass('d-none')) {
2333 ret.removeClass('d-none');
2339 getChildContainer : function()
2345 return this.el.select('.roo-card-body-ctr',true).first();
2348 initEvents: function()
2350 this.bodyEl = this.el.select('.card-body',true).first();
2351 this.containerEl = this.getChildContainer();
2353 this.dragZone = new Roo.dd.DragZone(this.getEl(), {
2354 containerScroll: true,
2355 ddGroup: this.drag_group || 'default_card_drag_group'
2357 this.dragZone.getDragData = this.getDragData.createDelegate(this);
2359 if (this.dropable) {
2360 this.dropZone = new Roo.dd.DropZone(this.el.select('.card-body',true).first() , {
2361 containerScroll: true,
2362 ddGroup: this.drop_group || 'default_card_drag_group'
2364 this.dropZone.getTargetFromEvent = this.getTargetFromEvent.createDelegate(this);
2365 this.dropZone.onNodeEnter = this.onNodeEnter.createDelegate(this);
2366 this.dropZone.onNodeOver = this.onNodeOver.createDelegate(this);
2367 this.dropZone.onNodeOut = this.onNodeOut.createDelegate(this);
2368 this.dropZone.onNodeDrop = this.onNodeDrop.createDelegate(this);
2371 if (this.collapsable) {
2372 this.el.select('.card-header',true).on('click', this.onToggleCollapse, this);
2374 if (this.rotateable) {
2375 this.el.select('.card-header',true).on('click', this.onToggleRotate, this);
2377 this.collapsableEl = this.el.select('.roo-collapsable',true).first();
2379 this.footerEl = this.el.select('.card-footer',true).first();
2380 this.collapsableToggleEl = this.el.select('.roo-collapse-toggle',true).first();
2381 this.headerContainerEl = this.el.select('.roo-card-header-ctr',true).first();
2382 this.headerEl = this.el.select('.card-header',true).first();
2385 this.el.addClass('roo-card-rotated');
2386 this.fireEvent('rotate', this, true);
2388 this.header_imageEl = this.el.select('.card-img-top',true).first();
2389 this.header_imageEl.on('load', this.onHeaderImageLoad, this );
2392 getDragData : function(e)
2394 var target = this.getEl();
2396 //this.handleSelection(e);
2401 nodes: this.getEl(),
2406 dragData.ddel = target.dom ; // the div element
2407 Roo.log(target.getWidth( ));
2408 dragData.ddel.style.width = target.getWidth() + 'px';
2415 * Part of the Roo.dd.DropZone interface. If no target node is found, the
2416 * whole Element becomes the target, and this causes the drop gesture to append.
2418 * Returns an object:
2421 position : 'below' or 'above'
2422 card : relateive to card OBJECT (or true for no cards listed)
2423 items_n : relative to nth item in list
2424 card_n : relative to nth card in list
2429 getTargetFromEvent : function(e, dragged_card_el)
2431 var target = e.getTarget();
2432 while ((target !== null) && (target.parentNode != this.containerEl.dom)) {
2433 target = target.parentNode;
2444 //Roo.log([ 'target' , target ? target.id : '--nothing--']);
2445 // see if target is one of the 'cards'...
2448 //Roo.log(this.items.length);
2451 var last_card_n = 0;
2453 for (var i = 0;i< this.items.length;i++) {
2455 if (!this.items[i].el.hasClass('card')) {
2458 pos = this.getDropPoint(e, this.items[i].el.dom);
2460 cards_len = ret.cards.length;
2461 //Roo.log(this.items[i].el.dom.id);
2462 ret.cards.push(this.items[i]);
2464 if (ret.card_n < 0 && pos == 'above') {
2465 ret.position = cards_len > 0 ? 'below' : pos;
2466 ret.items_n = i > 0 ? i - 1 : 0;
2467 ret.card_n = cards_len > 0 ? cards_len - 1 : 0;
2468 ret.card = ret.cards[ret.card_n];
2471 if (!ret.cards.length) {
2473 ret.position = 'below';
2477 // could not find a card.. stick it at the end..
2478 if (ret.card_n < 0) {
2479 ret.card_n = last_card_n;
2480 ret.card = ret.cards[last_card_n];
2481 ret.items_n = this.items.indexOf(ret.cards[last_card_n]);
2482 ret.position = 'below';
2485 if (this.items[ret.items_n].el == dragged_card_el) {
2489 if (ret.position == 'below') {
2490 var card_after = ret.card_n+1 == ret.cards.length ? false : ret.cards[ret.card_n+1];
2492 if (card_after && card_after.el == dragged_card_el) {
2499 var card_before = ret.card_n > 0 ? ret.cards[ret.card_n-1] : false;
2501 if (card_before && card_before.el == dragged_card_el) {
2508 onNodeEnter : function(n, dd, e, data){
2511 onNodeOver : function(n, dd, e, data)
2514 var target_info = this.getTargetFromEvent(e,data.source.el);
2515 if (target_info === false) {
2516 this.dropPlaceHolder('hide');
2519 Roo.log(['getTargetFromEvent', target_info ]);
2522 if (this.fireEvent('cardover', this, [ data ]) === false) {
2526 this.dropPlaceHolder('show', target_info,data);
2530 onNodeOut : function(n, dd, e, data){
2531 this.dropPlaceHolder('hide');
2534 onNodeDrop : function(n, dd, e, data)
2537 // call drop - return false if
2539 // this could actually fail - if the Network drops..
2540 // we will ignore this at present..- client should probably reload
2541 // the whole set of cards if stuff like that fails.
2544 var info = this.getTargetFromEvent(e,data.source.el);
2545 if (info === false) {
2548 this.dropPlaceHolder('hide');
2552 this.acceptCard(data.source, info.position, info.card, info.items_n);
2556 firstChildCard : function()
2558 for (var i = 0;i< this.items.length;i++) {
2560 if (!this.items[i].el.hasClass('card')) {
2563 return this.items[i];
2565 return this.items.length ? this.items[this.items.length-1] : false; // don't try and put stuff after the cards...
2570 * - card.acceptCard(move_card, info.position, info.card, info.items_n);
2572 acceptCard : function(move_card, position, next_to_card )
2574 if (this.fireEvent("drop", this, move_card, position, next_to_card) === false) {
2578 var to_items_n = next_to_card ? this.items.indexOf(next_to_card) : 0;
2580 move_card.parent().removeCard(move_card);
2583 var dom = move_card.el.dom;
2584 dom.style.width = ''; // clear with - which is set by drag.
2586 if (next_to_card !== false && next_to_card !== true && next_to_card.el.dom.parentNode) {
2587 var cardel = next_to_card.el.dom;
2589 if (position == 'above' ) {
2590 cardel.parentNode.insertBefore(dom, cardel);
2591 } else if (cardel.nextSibling) {
2592 cardel.parentNode.insertBefore(dom,cardel.nextSibling);
2594 cardel.parentNode.append(dom);
2597 // card container???
2598 this.containerEl.dom.append(dom);
2601 //FIXME HANDLE card = true
2603 // add this to the correct place in items.
2605 // remove Card from items.
2608 if (this.items.length) {
2610 //Roo.log([info.items_n, info.position, this.items.length]);
2611 for (var i =0; i < this.items.length; i++) {
2612 if (i == to_items_n && position == 'above') {
2613 nitems.push(move_card);
2615 nitems.push(this.items[i]);
2616 if (i == to_items_n && position == 'below') {
2617 nitems.push(move_card);
2620 this.items = nitems;
2621 Roo.log(this.items);
2623 this.items.push(move_card);
2626 move_card.parentId = this.id;
2632 removeCard : function(c)
2634 this.items = this.items.filter(function(e) { return e != c });
2637 dom.parentNode.removeChild(dom);
2638 dom.style.width = ''; // clear with - which is set by drag.
2643 /** Decide whether to drop above or below a View node. */
2644 getDropPoint : function(e, n, dd)
2649 if (n == this.containerEl.dom) {
2652 var t = Roo.lib.Dom.getY(n), b = t + n.offsetHeight;
2653 var c = t + (b - t) / 2;
2654 var y = Roo.lib.Event.getPageY(e);
2661 onToggleCollapse : function(e)
2663 if (this.collapsed) {
2664 this.el.select('.roo-collapse-toggle').removeClass('collapsed');
2665 this.collapsableEl.addClass('show');
2666 this.collapsed = false;
2669 this.el.select('.roo-collapse-toggle').addClass('collapsed');
2670 this.collapsableEl.removeClass('show');
2671 this.collapsed = true;
2676 onToggleRotate : function(e)
2678 this.collapsableEl.removeClass('show');
2679 this.footerEl.removeClass('d-none');
2680 this.el.removeClass('roo-card-rotated');
2681 this.el.removeClass('d-none');
2684 this.collapsableEl.addClass('show');
2685 this.rotated = false;
2686 this.fireEvent('rotate', this, this.rotated);
2689 this.el.addClass('roo-card-rotated');
2690 this.footerEl.addClass('d-none');
2691 this.el.select('.roo-collapsable').removeClass('show');
2693 this.rotated = true;
2694 this.fireEvent('rotate', this, this.rotated);
2698 dropPlaceHolder: function (action, info, data)
2700 if (this.dropEl === false) {
2701 this.dropEl = Roo.DomHelper.append(this.containerEl, {
2705 this.dropEl.removeClass(['d-none', 'd-block']);
2706 if (action == 'hide') {
2708 this.dropEl.addClass('d-none');
2711 // FIXME - info.card == true!!!
2712 this.dropEl.dom.parentNode.removeChild(this.dropEl.dom);
2714 if (info.card !== true) {
2715 var cardel = info.card.el.dom;
2717 if (info.position == 'above') {
2718 cardel.parentNode.insertBefore(this.dropEl.dom, cardel);
2719 } else if (cardel.nextSibling) {
2720 cardel.parentNode.insertBefore(this.dropEl.dom,cardel.nextSibling);
2722 cardel.parentNode.append(this.dropEl.dom);
2725 // card container???
2726 this.containerEl.dom.append(this.dropEl.dom);
2729 this.dropEl.addClass('d-block roo-card-dropzone');
2731 this.dropEl.setHeight( Roo.get(data.ddel).getHeight() );
2738 setHeaderText: function(html)
2741 if (this.headerContainerEl) {
2742 this.headerContainerEl.dom.innerHTML = html;
2745 onHeaderImageLoad : function(ev, he)
2747 if (!this.header_image_fit_square) {
2751 var hw = he.naturalHeight / he.naturalWidth;
2754 //var w = he.dom.naturalWidth;
2757 he.style.position = 'relative';
2759 var nw = (ww * (1/hw));
2760 Roo.get(he).setSize( ww * (1/hw), ww);
2761 he.style.left = ((ww - nw)/ 2) + 'px';
2762 he.style.position = 'relative';
2773 * Card header - holder for the card header elements.
2778 * @class Roo.bootstrap.CardHeader
2779 * @extends Roo.bootstrap.Element
2780 * @parent Roo.bootstrap.Card
2781 * @children Roo.bootstrap.Component
2782 * Bootstrap CardHeader class
2784 * Create a new Card Header - that you can embed children into
2785 * @param {Object} config The config object
2788 Roo.bootstrap.CardHeader = function(config){
2789 Roo.bootstrap.CardHeader.superclass.constructor.call(this, config);
2792 Roo.extend(Roo.bootstrap.CardHeader, Roo.bootstrap.Element, {
2795 container_method : 'getCardHeader'
2808 * Card footer - holder for the card footer elements.
2813 * @class Roo.bootstrap.CardFooter
2814 * @extends Roo.bootstrap.Element
2815 * @parent Roo.bootstrap.Card
2816 * @children Roo.bootstrap.Component
2817 * Bootstrap CardFooter class
2820 * Create a new Card Footer - that you can embed children into
2821 * @param {Object} config The config object
2824 Roo.bootstrap.CardFooter = function(config){
2825 Roo.bootstrap.CardFooter.superclass.constructor.call(this, config);
2828 Roo.extend(Roo.bootstrap.CardFooter, Roo.bootstrap.Element, {
2831 container_method : 'getCardFooter'
2844 * Card header - holder for the card header elements.
2849 * @class Roo.bootstrap.CardImageTop
2850 * @extends Roo.bootstrap.Element
2851 * @parent Roo.bootstrap.Card
2852 * @children Roo.bootstrap.Component
2853 * Bootstrap CardImageTop class
2856 * Create a new Card Image Top container
2857 * @param {Object} config The config object
2860 Roo.bootstrap.CardImageTop = function(config){
2861 Roo.bootstrap.CardImageTop.superclass.constructor.call(this, config);
2864 Roo.extend(Roo.bootstrap.CardImageTop, Roo.bootstrap.Element, {
2867 container_method : 'getCardImageTop'
2882 * @class Roo.bootstrap.ButtonUploader
2883 * @extends Roo.bootstrap.Button
2884 * Bootstrap Button Uploader class - it's a button which when you add files to it
2887 * @cfg {Number} errorTimeout default 3000
2888 * @cfg {Array} images an array of ?? Img objects ??? when loading existing files..
2889 * @cfg {Array} html The button text.
2890 * @cfg {Boolean} multiple (default true) Should the upload allow multiple files to be uploaded.
2893 * Create a new CardUploader
2894 * @param {Object} config The config object
2897 Roo.bootstrap.ButtonUploader = function(config){
2901 Roo.bootstrap.ButtonUploader.superclass.constructor.call(this, config);
2907 * @event beforeselect
2908 * When button is pressed, before show upload files dialog is shown
2909 * @param {Roo.bootstrap.UploaderButton} this
2912 'beforeselect' : true,
2914 * @event fired when files have been selected,
2915 * When a the download link is clicked
2916 * @param {Roo.bootstrap.UploaderButton} this
2917 * @param {Array} Array of files that have been uploaded
2924 Roo.extend(Roo.bootstrap.ButtonUploader, Roo.bootstrap.Button, {
2927 errorTimeout : 3000,
2931 fileCollection : false,
2936 getAutoCreate : function()
2941 cls : 'd-none roo-card-upload-selector'
2944 if (this.multiple) {
2945 im.multiple = 'multiple';
2951 Roo.bootstrap.Button.prototype.getAutoCreate.call(this),
2961 initEvents : function()
2964 Roo.bootstrap.Button.prototype.initEvents.call(this);
2970 this.urlAPI = (window.createObjectURL && window) ||
2971 (window.URL && URL.revokeObjectURL && URL) ||
2972 (window.webkitURL && webkitURL);
2977 this.selectorEl = this.el.select('.roo-card-upload-selector', true).first();
2979 this.selectorEl.on('change', this.onFileSelected, this);
2986 onClick : function(e)
2990 if ( this.fireEvent('beforeselect', this) === false) {
2994 this.selectorEl.dom.click();
2998 onFileSelected : function(e)
3002 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
3005 var files = Array.prototype.slice.call(this.selectorEl.dom.files);
3006 this.selectorEl.dom.value = '';// hopefully reset..
3008 this.fireEvent('uploaded', this, files );
3016 * addCard - add an Attachment to the uploader
3017 * @param data - the data about the image to upload
3021 title : "Title of file",
3022 is_uploaded : false,
3023 src : "http://.....",
3024 srcfile : { the File upload object },
3025 mimetype : file.type,
3028 .. any other data...
3053 * @class Roo.bootstrap.Img
3054 * @extends Roo.bootstrap.Component
3055 * Bootstrap Img class
3056 * @cfg {Boolean} imgResponsive false | true
3057 * @cfg {String} border rounded | circle | thumbnail
3058 * @cfg {String} src image source
3059 * @cfg {String} alt image alternative text
3060 * @cfg {String} href a tag href
3061 * @cfg {String} target (_self|_blank|_parent|_top)target for a href.
3062 * @cfg {String} xsUrl xs image source
3063 * @cfg {String} smUrl sm image source
3064 * @cfg {String} mdUrl md image source
3065 * @cfg {String} lgUrl lg image source
3066 * @cfg {Boolean} backgroundContain (use style background and contain image in content)
3069 * Create a new Input
3070 * @param {Object} config The config object
3073 Roo.bootstrap.Img = function(config){
3074 Roo.bootstrap.Img.superclass.constructor.call(this, config);
3080 * The img click event for the img.
3081 * @param {Roo.EventObject} e
3086 * The when any image loads
3087 * @param {Roo.EventObject} e
3093 Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, {
3095 imgResponsive: true,
3104 backgroundContain : false,
3106 getAutoCreate : function()
3108 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
3109 return this.createSingleImg();
3114 cls: 'roo-image-responsive-group',
3119 Roo.each(['xs', 'sm', 'md', 'lg'], function(size){
3121 if(!_this[size + 'Url']){
3127 cls: (_this.imgResponsive) ? 'img-responsive' : '',
3128 html: _this.html || cfg.html,
3129 src: _this[size + 'Url']
3132 img.cls += ' roo-image-responsive-' + size;
3134 var s = ['xs', 'sm', 'md', 'lg'];
3136 s.splice(s.indexOf(size), 1);
3138 Roo.each(s, function(ss){
3139 img.cls += ' hidden-' + ss;
3142 if (['rounded','circle','thumbnail'].indexOf(_this.border)>-1) {
3143 cfg.cls += ' img-' + _this.border;
3147 cfg.alt = _this.alt;
3160 a.target = _this.target;
3164 cfg.cn.push((_this.href) ? a : img);
3171 createSingleImg : function()
3175 cls: (this.imgResponsive) ? 'img-responsive' : '',
3177 src : Roo.BLANK_IMAGE_URL // just incase src get's set to undefined?!?
3180 if (this.backgroundContain) {
3181 cfg.cls += ' background-contain';
3184 cfg.html = this.html || cfg.html;
3186 if (this.backgroundContain) {
3187 cfg.style="background-image: url(" + this.src + ')';
3189 cfg.src = this.src || cfg.src;
3192 if (['rounded','circle','thumbnail'].indexOf(this.border)>-1) {
3193 cfg.cls += ' img-' + this.border;
3210 a.target = this.target;
3215 return (this.href) ? a : cfg;
3218 initEvents: function()
3221 this.el.on('click', this.onClick, this);
3223 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
3224 this.el.on('load', this.onImageLoad, this);
3226 // not sure if this works.. not tested
3227 this.el.select('img', true).on('load', this.onImageLoad, this);
3232 onClick : function(e)
3234 Roo.log('img onclick');
3235 this.fireEvent('click', this, e);
3237 onImageLoad: function(e)
3239 Roo.log('img load');
3240 this.fireEvent('load', this, e);
3244 * Sets the url of the image - used to update it
3245 * @param {String} url the url of the image
3248 setSrc : function(url)
3252 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
3253 if (this.backgroundContain) {
3254 this.el.dom.style.backgroundImage = 'url(' + url + ')';
3256 this.el.dom.src = url;
3261 this.el.select('img', true).first().dom.src = url;
3277 * @class Roo.bootstrap.Link
3278 * @extends Roo.bootstrap.Component
3279 * @children Roo.bootstrap.Component
3280 * Bootstrap Link Class (eg. '<a href>')
3282 * @cfg {String} alt image alternative text
3283 * @cfg {String} href a tag href
3284 * @cfg {String} target (_self|_blank|_parent|_top) target for a href.
3285 * @cfg {String} html the content of the link.
3286 * @cfg {String} anchor name for the anchor link
3287 * @cfg {String} fa - favicon
3289 * @cfg {Boolean} preventDefault (true | false) default false
3293 * Create a new Input
3294 * @param {Object} config The config object
3297 Roo.bootstrap.Link = function(config){
3298 Roo.bootstrap.Link.superclass.constructor.call(this, config);
3304 * The img click event for the img.
3305 * @param {Roo.EventObject} e
3311 Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component, {
3315 preventDefault: false,
3321 getAutoCreate : function()
3323 var html = this.html || '';
3325 if (this.fa !== false) {
3326 html = '<i class="fa fa-' + this.fa + '"></i>';
3331 // anchor's do not require html/href...
3332 if (this.anchor === false) {
3334 cfg.href = this.href || '#';
3336 cfg.name = this.anchor;
3337 if (this.html !== false || this.fa !== false) {
3340 if (this.href !== false) {
3341 cfg.href = this.href;
3345 if(this.alt !== false){
3350 if(this.target !== false) {
3351 cfg.target = this.target;
3357 initEvents: function() {
3359 if(!this.href || this.preventDefault){
3360 this.el.on('click', this.onClick, this);
3364 onClick : function(e)
3366 if(this.preventDefault){
3369 //Roo.log('img onclick');
3370 this.fireEvent('click', this, e);
3383 * @class Roo.bootstrap.Header
3384 * @extends Roo.bootstrap.Component
3385 * @children Roo.bootstrap.Component
3386 * Bootstrap Header class
3389 * @cfg {String} html content of header
3390 * @cfg {Number} level (1|2|3|4|5|6) default 1
3393 * Create a new Header
3394 * @param {Object} config The config object
3398 Roo.bootstrap.Header = function(config){
3399 Roo.bootstrap.Header.superclass.constructor.call(this, config);
3402 Roo.extend(Roo.bootstrap.Header, Roo.bootstrap.Component, {
3410 getAutoCreate : function(){
3415 tag: 'h' + (1 *this.level),
3416 html: this.html || ''
3427 * @class Roo.bootstrap.MenuMgr
3429 * Provides a common registry of all menu items on a page so that they can be easily accessed by id.
3432 Roo.bootstrap.menu.Manager = function(){
3433 var menus, active, groups = {}, attached = false, lastShow = new Date();
3435 // private - called when first menu is created
3438 active = new Roo.util.MixedCollection();
3439 Roo.get(document).addKeyListener(27, function(){
3440 if(active.length > 0){
3448 if(active && active.length > 0){
3449 var c = active.clone();
3459 if(active.length < 1){
3460 Roo.get(document).un("mouseup", onMouseDown);
3468 var last = active.last();
3469 lastShow = new Date();
3472 Roo.get(document).on("mouseup", onMouseDown);
3477 //m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
3478 m.parentMenu.activeChild = m;
3479 }else if(last && last.isVisible()){
3480 //m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
3485 function onBeforeHide(m){
3487 m.activeChild.hide();
3489 if(m.autoHideTimer){
3490 clearTimeout(m.autoHideTimer);
3491 delete m.autoHideTimer;
3496 function onBeforeShow(m){
3497 var pm = m.parentMenu;
3498 if(!pm && !m.allowOtherMenus){
3500 }else if(pm && pm.activeChild && active != m){
3501 pm.activeChild.hide();
3505 // private this should really trigger on mouseup..
3506 function onMouseDown(e){
3507 Roo.log("on Mouse Up");
3509 if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".dropdown-menu") && !e.getTarget('.user-menu')){
3510 Roo.log("MenuManager hideAll");
3519 function onBeforeCheck(mi, state){
3521 var g = groups[mi.group];
3522 for(var i = 0, l = g.length; i < l; i++){
3524 g[i].setChecked(false);
3533 * Hides all menus that are currently visible
3535 hideAll : function(){
3540 register : function(menu){
3544 menus[menu.id] = menu;
3545 menu.on("beforehide", onBeforeHide);
3546 menu.on("hide", onHide);
3547 menu.on("beforeshow", onBeforeShow);
3548 menu.on("show", onShow);
3550 if(g && menu.events["checkchange"]){
3554 groups[g].push(menu);
3555 menu.on("checkchange", onCheck);
3560 * Returns a {@link Roo.menu.Menu} object
3561 * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will
3562 * be used to generate and return a new Menu instance.
3564 get : function(menu){
3565 if(typeof menu == "string"){ // menu id
3567 }else if(menu.events){ // menu instance
3570 /*else if(typeof menu.length == 'number'){ // array of menu items?
3571 return new Roo.bootstrap.Menu({items:menu});
3572 }else{ // otherwise, must be a config
3573 return new Roo.bootstrap.Menu(menu);
3580 unregister : function(menu){
3581 delete menus[menu.id];
3582 menu.un("beforehide", onBeforeHide);
3583 menu.un("hide", onHide);
3584 menu.un("beforeshow", onBeforeShow);
3585 menu.un("show", onShow);
3587 if(g && menu.events["checkchange"]){
3588 groups[g].remove(menu);
3589 menu.un("checkchange", onCheck);
3594 registerCheckable : function(menuItem){
3595 var g = menuItem.group;
3600 groups[g].push(menuItem);
3601 menuItem.on("beforecheckchange", onBeforeCheck);
3606 unregisterCheckable : function(menuItem){
3607 var g = menuItem.group;
3609 groups[g].remove(menuItem);
3610 menuItem.un("beforecheckchange", onBeforeCheck);
3616 * @class Roo.bootstrap.menu.Menu
3617 * @extends Roo.bootstrap.Component
3619 * @children Roo.bootstrap.menu.Item
3621 * Bootstrap Menu class - container for MenuItems - normally has to be added to a object that supports the menu property
3623 * @cfg {String} type (dropdown|treeview|submenu) type of menu
3624 * @cfg {bool} hidden if the menu should be hidden when rendered.
3625 * @cfg {bool} stopEvent (true|false) Stop event after trigger press (default true)
3626 * @cfg {bool} isLink (true|false) the menu has link disable auto expand and collaspe (default false)
3627 * @cfg {bool} hideTrigger (true|false) default false - hide the carret for trigger.
3628 * @cfg {String} align default tl-bl? == below - how the menu should be aligned.
3632 * @param {Object} config The config objectQ
3636 Roo.bootstrap.menu.Menu = function(config){
3638 if (config.type == 'treeview') {
3639 // normally menu's are drawn attached to the document to handle layering etc..
3640 // however treeview (used by the docs menu is drawn into the parent element)
3641 this.container_method = 'getChildContainer';
3644 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
3645 if (this.registerMenu && this.type != 'treeview') {
3646 Roo.bootstrap.menu.Manager.register(this);
3653 * Fires before this menu is displayed (return false to block)
3654 * @param {Roo.menu.Menu} this
3659 * Fires before this menu is hidden (return false to block)
3660 * @param {Roo.menu.Menu} this
3665 * Fires after this menu is displayed
3666 * @param {Roo.menu.Menu} this
3671 * Fires after this menu is hidden
3672 * @param {Roo.menu.Menu} this
3677 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
3678 * @param {Roo.menu.Menu} this
3679 * @param {Roo.menu.Item} menuItem The menu item that was clicked
3680 * @param {Roo.EventObject} e
3685 * Fires when the mouse is hovering over this menu
3686 * @param {Roo.menu.Menu} this
3687 * @param {Roo.EventObject} e
3688 * @param {Roo.menu.Item} menuItem The menu item that was clicked
3693 * Fires when the mouse exits this menu
3694 * @param {Roo.menu.Menu} this
3695 * @param {Roo.EventObject} e
3696 * @param {Roo.menu.Item} menuItem The menu item that was clicked
3701 * Fires when a menu item contained in this menu is clicked
3702 * @param {Roo.menu.BaseItem} baseItem The BaseItem that was clicked
3703 * @param {Roo.EventObject} e
3707 this.menuitems = new Roo.util.MixedCollection(false, function(o) { return o.el.id; });
3710 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
3714 triggerEl : false, // is this set by component builder? -- it should really be fetched from parent()???
3717 * @cfg {Boolean} registerMenu True (default) - means that clicking on screen etc. hides it.
3719 registerMenu : true,
3721 menuItems :false, // stores the menu items..
3731 container_method : 'getDocumentBody', // so the menu is rendered on the body and zIndex works.
3733 hideTrigger : false,
3738 getChildContainer : function() {
3742 getAutoCreate : function(){
3744 //if (['right'].indexOf(this.align)!==-1) {
3745 // cfg.cn[1].cls += ' pull-right'
3750 cls : 'dropdown-menu shadow' ,
3751 style : 'z-index:1000'
3755 if (this.type === 'submenu') {
3756 cfg.cls = 'submenu active';
3758 if (this.type === 'treeview') {
3759 cfg.cls = 'treeview-menu';
3764 initEvents : function() {
3766 // Roo.log("ADD event");
3767 // Roo.log(this.triggerEl.dom);
3768 if (this.triggerEl) {
3770 this.triggerEl.on('click', this.onTriggerClick, this);
3772 this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this);
3774 if (!this.hideTrigger) {
3775 if (this.triggerEl.hasClass('nav-item') && this.triggerEl.select('.nav-link',true).length) {
3776 // dropdown toggle on the 'a' in BS4?
3777 this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle');
3779 this.triggerEl.addClass('dropdown-toggle');
3785 this.el.on('touchstart' , this.onTouch, this);
3787 this.el.on('click' , this.onClick, this);
3789 this.el.on("mouseover", this.onMouseOver, this);
3790 this.el.on("mouseout", this.onMouseOut, this);
3794 findTargetItem : function(e)
3796 var t = e.getTarget(".dropdown-menu-item", this.el, true);
3800 //Roo.log(t); Roo.log(t.id);
3802 //Roo.log(this.menuitems);
3803 return this.menuitems.get(t.id);
3805 //return this.items.get(t.menuItemId);
3811 onTouch : function(e)
3813 Roo.log("menu.onTouch");
3814 //e.stopEvent(); this make the user popdown broken
3818 onClick : function(e)
3820 Roo.log("menu.onClick");
3822 var t = this.findTargetItem(e);
3823 if(!t || t.isContainer){
3828 if (Roo.isTouch && e.type == 'touchstart' && t.menu && !t.disabled) {
3829 if(t == this.activeItem && t.shouldDeactivate(e)){
3830 this.activeItem.deactivate();
3831 delete this.activeItem;
3835 this.setActiveItem(t, true);
3843 Roo.log('pass click event');
3847 this.fireEvent("click", this, t, e);
3851 if(!t.href.length || t.href == '#'){
3852 (function() { _this.hide(); }).defer(100);
3857 onMouseOver : function(e){
3858 var t = this.findTargetItem(e);
3861 // if(t.canActivate && !t.disabled){
3862 // this.setActiveItem(t, true);
3866 this.fireEvent("mouseover", this, e, t);
3868 isVisible : function(){
3869 return !this.hidden;
3871 onMouseOut : function(e){
3872 var t = this.findTargetItem(e);
3875 // if(t == this.activeItem && t.shouldDeactivate(e)){
3876 // this.activeItem.deactivate();
3877 // delete this.activeItem;
3880 this.fireEvent("mouseout", this, e, t);
3885 * Displays this menu relative to another element
3886 * @param {String/HTMLElement/Roo.Element} element The element to align to
3887 * @param {String} position (optional) The {@link Roo.Element#alignTo} anchor position to use in aligning to
3888 * the element (defaults to this.defaultAlign)
3889 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
3891 show : function(el, pos, parentMenu)
3893 if (false === this.fireEvent("beforeshow", this)) {
3894 Roo.log("show canceled");
3897 this.parentMenu = parentMenu;
3901 this.el.addClass('show'); // show otherwise we do not know how big we are..
3903 var xy = this.el.getAlignToXY(el, pos);
3905 // bl-tl << left align below
3906 // tl-bl << left align
3908 if(this.el.getWidth() + xy[0] >= Roo.lib.Dom.getViewWidth()){
3909 // if it goes to far to the right.. -> align left.
3910 xy = this.el.getAlignToXY(el, this.align.replace('/l/g', 'r'))
3913 // was left align - go right?
3914 xy = this.el.getAlignToXY(el, this.align.replace('/r/g', 'l'))
3917 // goes down the bottom
3918 if(this.el.getHeight() + xy[1] >= Roo.lib.Dom.getViewHeight() ||
3920 var a = this.align.replace('?', '').split('-');
3921 xy = this.el.getAlignToXY(el, a[1] + '-' + a[0] + '?')
3925 this.showAt( xy , parentMenu, false);
3928 * Displays this menu at a specific xy position
3929 * @param {Array} xyPosition Contains X & Y [x, y] values for the position at which to show the menu (coordinates are page-based)
3930 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
3932 showAt : function(xy, parentMenu, /* private: */_e){
3933 this.parentMenu = parentMenu;
3938 this.fireEvent("beforeshow", this);
3939 //xy = this.el.adjustForConstraints(xy);
3943 this.hideMenuItems();
3944 this.hidden = false;
3945 if (this.triggerEl) {
3946 this.triggerEl.addClass('open');
3949 this.el.addClass('show');
3953 // reassign x when hitting right
3955 // reassign y when hitting bottom
3957 // but the list may align on trigger left or trigger top... should it be a properity?
3959 if(this.el.getStyle('top') != 'auto' && this.el.getStyle('top').slice(-1) != "%"){
3964 this.fireEvent("show", this);
3970 this.doFocus.defer(50, this);
3974 doFocus : function(){
3976 this.focusEl.focus();
3981 * Hides this menu and optionally all parent menus
3982 * @param {Boolean} deep (optional) True to hide all parent menus recursively, if any (defaults to false)
3984 hide : function(deep)
3986 if (false === this.fireEvent("beforehide", this)) {
3987 Roo.log("hide canceled");
3990 this.hideMenuItems();
3991 if(this.el && this.isVisible()){
3993 if(this.activeItem){
3994 this.activeItem.deactivate();
3995 this.activeItem = null;
3997 if (this.triggerEl) {
3998 this.triggerEl.removeClass('open');
4001 this.el.removeClass('show');
4003 this.fireEvent("hide", this);
4005 if(deep === true && this.parentMenu){
4006 this.parentMenu.hide(true);
4010 onTriggerClick : function(e)
4012 Roo.log('trigger click');
4014 var target = e.getTarget();
4016 Roo.log(target.nodeName.toLowerCase());
4018 if(target.nodeName.toLowerCase() === 'i'){
4024 onTriggerPress : function(e)
4026 Roo.log('trigger press');
4027 //Roo.log(e.getTarget());
4028 // Roo.log(this.triggerEl.dom);
4030 // trigger only occurs on normal menu's -- if it's a treeview or dropdown... do not hide/show..
4031 var pel = Roo.get(e.getTarget());
4032 if (pel.findParent('.dropdown-menu') || pel.findParent('.treeview-menu') ) {
4033 Roo.log('is treeview or dropdown?');
4037 if(e.getTarget().nodeName.toLowerCase() !== 'i' && this.isLink){
4041 if (this.isVisible()) {
4047 this.show(this.triggerEl, this.align, false);
4050 if(this.stopEvent || e.getTarget().nodeName.toLowerCase() === 'i'){
4057 hideMenuItems : function()
4059 Roo.log("hide Menu Items");
4064 this.el.select('.open',true).each(function(aa) {
4066 aa.removeClass('open');
4070 addxtypeChild : function (tree, cntr) {
4071 var comp= Roo.bootstrap.menu.Menu.superclass.addxtypeChild.call(this, tree, cntr);
4073 this.menuitems.add(comp);
4085 this.getEl().dom.innerHTML = '';
4086 this.menuitems.clear();
4092 * @class Roo.bootstrap.menu.Item
4093 * @extends Roo.bootstrap.Component
4094 * @children Roo.bootstrap.Button Roo.bootstrap.ButtonUploader Roo.bootstrap.Row Roo.bootstrap.Column Roo.bootstrap.Container
4095 * @parent Roo.bootstrap.menu.Menu
4097 * Bootstrap MenuItem class
4099 * @cfg {String} html the menu label
4100 * @cfg {String} href the link
4101 * @cfg {Boolean} preventDefault do not trigger A href on clicks (default false).
4102 * @cfg {Boolean} isContainer is it a container - just returns a drop down item..
4103 * @cfg {Boolean} active used on sidebars to highlight active itesm
4104 * @cfg {String} fa favicon to show on left of menu item.
4105 * @cfg {Roo.bootsrap.Menu} menu the child menu.
4109 * Create a new MenuItem
4110 * @param {Object} config The config object
4114 Roo.bootstrap.menu.Item = function(config){
4115 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
4120 * The raw click event for the entire grid.
4121 * @param {Roo.bootstrap.menu.Item} this
4122 * @param {Roo.EventObject} e
4128 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
4132 preventDefault: false,
4133 isContainer : false,
4137 getAutoCreate : function(){
4139 if(this.isContainer){
4142 cls: 'dropdown-menu-item '
4152 cls : 'dropdown-item',
4157 if (this.fa !== false) {
4160 cls : 'fa fa-' + this.fa
4169 cls: 'dropdown-menu-item',
4172 if (this.parent().type == 'treeview') {
4173 cfg.cls = 'treeview-menu';
4176 cfg.cls += ' active';
4181 anc.href = this.href || cfg.cn[0].href ;
4182 ctag.html = this.html || cfg.cn[0].html ;
4186 initEvents: function()
4188 if (this.parent().type == 'treeview') {
4189 this.el.select('a').on('click', this.onClick, this);
4193 this.menu.parentType = this.xtype;
4194 this.menu.triggerEl = this.el;
4195 this.menu = this.addxtype(Roo.apply({}, this.menu));
4199 onClick : function(e)
4201 Roo.log('item on click ');
4203 if(this.preventDefault){
4206 //this.parent().hideMenuItems();
4208 this.fireEvent('click', this, e);
4222 * @class Roo.bootstrap.menu.Separator
4223 * @extends Roo.bootstrap.Component
4225 * @parent Roo.bootstrap.menu.Menu
4226 * Bootstrap Separator class
4229 * Create a new Separator
4230 * @param {Object} config The config object
4234 Roo.bootstrap.menu.Separator = function(config){
4235 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
4238 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
4240 getAutoCreate : function(){
4243 cls: 'dropdown-divider divider'
4259 * @class Roo.bootstrap.Modal
4260 * @extends Roo.bootstrap.Component
4261 * @parent none builder
4262 * @children Roo.bootstrap.Component
4263 * Bootstrap Modal class
4264 * @cfg {String} title Title of dialog
4265 * @cfg {String} html - the body of the dialog (for simple ones) - you can also use template..
4266 * @cfg {Roo.Template} tmpl - a template with variables. to use it, add a handler in show:method adn
4267 * @cfg {Boolean} specificTitle default false
4268 * @cfg {Roo.bootstrap.Button} buttons[] Array of buttons or standard button set..
4269 * @cfg {String} buttonPosition (left|right|center) default right (DEPRICATED) - use mr-auto on buttons to put them on the left
4270 * @cfg {Boolean} animate default true
4271 * @cfg {Boolean} allow_close default true
4272 * @cfg {Boolean} fitwindow default false
4273 * @cfg {Boolean} bodyOverflow should the body element have overflow auto added default false
4274 * @cfg {Number} width fixed width - usefull for chrome extension only really.
4275 * @cfg {Number} height fixed height - usefull for chrome extension only really.
4276 * @cfg {String} size (sm|lg|xl) default empty
4277 * @cfg {Number} max_width set the max width of modal
4278 * @cfg {Boolean} editableTitle can the title be edited
4283 * Create a new Modal Dialog
4284 * @param {Object} config The config object
4287 Roo.bootstrap.Modal = function(config){
4288 Roo.bootstrap.Modal.superclass.constructor.call(this, config);
4293 * The raw btnclick event for the button
4294 * @param {Roo.EventObject} e
4299 * Fire when dialog resize
4300 * @param {Roo.bootstrap.Modal} this
4301 * @param {Roo.EventObject} e
4305 * @event titlechanged
4306 * Fire when the editable title has been changed
4307 * @param {Roo.bootstrap.Modal} this
4308 * @param {Roo.EventObject} value
4310 "titlechanged" : true
4313 this.buttons = this.buttons || [];
4316 this.tmpl = Roo.factory(this.tmpl);
4321 Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, {
4323 title : 'test dialog',
4333 specificTitle: false,
4335 buttonPosition: 'right',
4357 editableTitle : false,
4359 onRender : function(ct, position)
4361 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
4364 var cfg = Roo.apply({}, this.getAutoCreate());
4367 // cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
4369 //if (!cfg.name.length) {
4373 cfg.cls += ' ' + this.cls;
4376 cfg.style = this.style;
4378 this.el = Roo.get(document.body).createChild(cfg, position);
4380 //var type = this.el.dom.type;
4383 if(this.tabIndex !== undefined){
4384 this.el.dom.setAttribute('tabIndex', this.tabIndex);
4387 this.dialogEl = this.el.select('.modal-dialog',true).first();
4388 this.bodyEl = this.el.select('.modal-body',true).first();
4389 this.closeEl = this.el.select('.modal-header .close', true).first();
4390 this.headerEl = this.el.select('.modal-header',true).first();
4391 this.titleEl = this.el.select('.modal-title',true).first();
4392 this.footerEl = this.el.select('.modal-footer',true).first();
4394 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
4396 //this.el.addClass("x-dlg-modal");
4398 if (this.buttons.length) {
4399 Roo.each(this.buttons, function(bb) {
4400 var b = Roo.apply({}, bb);
4401 b.xns = b.xns || Roo.bootstrap;
4402 b.xtype = b.xtype || 'Button';
4403 if (typeof(b.listeners) == 'undefined') {
4404 b.listeners = { click : this.onButtonClick.createDelegate(this) };
4407 var btn = Roo.factory(b);
4409 btn.render(this.getButtonContainer());
4413 // render the children.
4416 if(typeof(this.items) != 'undefined'){
4417 var items = this.items;
4420 for(var i =0;i < items.length;i++) {
4421 nitems.push(this.addxtype(Roo.apply({}, items[i])));
4425 this.items = nitems;
4427 // where are these used - they used to be body/close/footer
4431 //this.el.addClass([this.fieldClass, this.cls]);
4435 getAutoCreate : function()
4437 // we will default to modal-body-overflow - might need to remove or make optional later.
4439 cls : 'modal-body ' + (this.bodyOverflow ? 'overflow-auto' : ''),
4440 html : this.html || ''
4445 cls : 'modal-title',
4449 if(this.specificTitle){ // WTF is this?
4454 if (this.allow_close && Roo.bootstrap.version == 3) {
4464 if (this.editableTitle) {
4466 cls: 'form-control roo-editable-title d-none',
4472 if (this.allow_close && Roo.bootstrap.version == 4) {
4482 if(this.size.length){
4483 size = 'modal-' + this.size;
4486 var footer = Roo.bootstrap.version == 3 ?
4488 cls : 'modal-footer',
4492 cls: 'btn-' + this.buttonPosition
4497 { // BS4 uses mr-auto on left buttons....
4498 cls : 'modal-footer'
4509 cls: "modal-dialog " + size,
4512 cls : "modal-content",
4515 cls : 'modal-header',
4530 modal.cls += ' fade';
4536 getChildContainer : function() {
4541 getButtonContainer : function() {
4543 return Roo.bootstrap.version == 4 ?
4544 this.el.select('.modal-footer',true).first()
4545 : this.el.select('.modal-footer div',true).first();
4548 initEvents : function()
4550 if (this.allow_close) {
4551 this.closeEl.on('click', this.hide, this);
4553 Roo.EventManager.onWindowResize(this.resize, this, true);
4554 if (this.editableTitle) {
4555 this.headerEditEl = this.headerEl.select('.form-control',true).first();
4556 this.headerEl.on('click', function() { this.toggleHeaderInput(true) } , this);
4557 this.headerEditEl.on('keyup', function(e) {
4558 if([ e.RETURN , e.TAB , e.ESC ].indexOf(e.keyCode) > -1) {
4559 this.toggleHeaderInput(false)
4562 this.headerEditEl.on('blur', function(e) {
4563 this.toggleHeaderInput(false)
4572 this.maskEl.setSize(
4573 Roo.lib.Dom.getViewWidth(true),
4574 Roo.lib.Dom.getViewHeight(true)
4577 if (this.fitwindow) {
4579 this.dialogEl.setStyle( { 'max-width' : '100%' });
4581 this.width || Roo.lib.Dom.getViewportWidth(true) - 30,
4582 this.height || Roo.lib.Dom.getViewportHeight(true) // catering margin-top 30 margin-bottom 30
4587 if(this.max_width !== 0) {
4589 var w = Math.min(this.max_width, Roo.lib.Dom.getViewportWidth(true) - 30);
4592 this.setSize(w, this.height);
4596 if(this.max_height) {
4597 this.setSize(w,Math.min(
4599 Roo.lib.Dom.getViewportHeight(true) - 60
4605 if(!this.fit_content) {
4606 this.setSize(w, Roo.lib.Dom.getViewportHeight(true) - 60);
4610 this.setSize(w, Math.min(
4612 this.headerEl.getHeight() +
4613 this.footerEl.getHeight() +
4614 this.getChildHeight(this.bodyEl.dom.childNodes),
4615 Roo.lib.Dom.getViewportHeight(true) - 60)
4621 setSize : function(w,h)
4632 if (!this.rendered) {
4635 this.toggleHeaderInput(false);
4636 //this.el.setStyle('display', 'block');
4637 this.el.removeClass('hideing');
4638 this.el.dom.style.display='block';
4640 Roo.get(document.body).addClass('modal-open');
4642 if(this.animate){ // element has 'fade' - so stuff happens after .3s ?- not sure why the delay?
4645 this.el.addClass('show');
4646 this.el.addClass('in');
4649 this.el.addClass('show');
4650 this.el.addClass('in');
4653 // not sure how we can show data in here..
4655 // this.getChildContainer().dom.innerHTML = this.tmpl.applyTemplate(this);
4658 Roo.get(document.body).addClass("x-body-masked");
4660 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
4661 this.maskEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
4662 this.maskEl.dom.style.display = 'block';
4663 this.maskEl.addClass('show');
4668 this.fireEvent('show', this);
4670 // set zindex here - otherwise it appears to be ignored...
4671 this.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
4674 this.items.forEach( function(e) {
4675 e.layout ? e.layout() : false;
4683 if(this.fireEvent("beforehide", this) !== false){
4685 this.maskEl.removeClass('show');
4687 this.maskEl.dom.style.display = '';
4688 Roo.get(document.body).removeClass("x-body-masked");
4689 this.el.removeClass('in');
4690 this.el.select('.modal-dialog', true).first().setStyle('transform','');
4692 if(this.animate){ // why
4693 this.el.addClass('hideing');
4694 this.el.removeClass('show');
4696 if (!this.el.hasClass('hideing')) {
4697 return; // it's been shown again...
4700 this.el.dom.style.display='';
4702 Roo.get(document.body).removeClass('modal-open');
4703 this.el.removeClass('hideing');
4707 this.el.removeClass('show');
4708 this.el.dom.style.display='';
4709 Roo.get(document.body).removeClass('modal-open');
4712 this.fireEvent('hide', this);
4715 isVisible : function()
4718 return this.el.hasClass('show') && !this.el.hasClass('hideing');
4722 addButton : function(str, cb)
4726 var b = Roo.apply({}, { html : str } );
4727 b.xns = b.xns || Roo.bootstrap;
4728 b.xtype = b.xtype || 'Button';
4729 if (typeof(b.listeners) == 'undefined') {
4730 b.listeners = { click : cb.createDelegate(this) };
4733 var btn = Roo.factory(b);
4735 btn.render(this.getButtonContainer());
4741 setDefaultButton : function(btn)
4743 //this.el.select('.modal-footer').()
4746 resizeTo: function(w,h)
4748 this.dialogEl.setWidth(w);
4750 var diff = this.headerEl.getHeight() + this.footerEl.getHeight() + 60; // dialog margin-bottom: 30
4752 this.bodyEl.setHeight(h - diff);
4754 this.fireEvent('resize', this);
4757 setContentSize : function(w, h)
4761 onButtonClick: function(btn,e)
4764 this.fireEvent('btnclick', btn.name, e);
4767 * Set the title of the Dialog
4768 * @param {String} str new Title
4770 setTitle: function(str) {
4771 this.titleEl.dom.innerHTML = str;
4775 * Set the body of the Dialog
4776 * @param {String} str new Title
4778 setBody: function(str) {
4779 this.bodyEl.dom.innerHTML = str;
4782 * Set the body of the Dialog using the template
4783 * @param {Obj} data - apply this data to the template and replace the body contents.
4785 applyBody: function(obj)
4788 Roo.log("Error - using apply Body without a template");
4791 this.tmpl.overwrite(this.bodyEl, obj);
4794 getChildHeight : function(child_nodes)
4798 child_nodes.length == 0
4803 var child_height = 0;
4805 for(var i = 0; i < child_nodes.length; i++) {
4808 * for modal with tabs...
4809 if(child_nodes[i].classList.contains('roo-layout-panel')) {
4811 var layout_childs = child_nodes[i].childNodes;
4813 for(var j = 0; j < layout_childs.length; j++) {
4815 if(layout_childs[j].classList.contains('roo-layout-panel-body')) {
4817 var layout_body_childs = layout_childs[j].childNodes;
4819 for(var k = 0; k < layout_body_childs.length; k++) {
4821 if(layout_body_childs[k].classList.contains('navbar')) {
4822 child_height += layout_body_childs[k].offsetHeight;
4826 if(layout_body_childs[k].classList.contains('roo-layout-tabs-body')) {
4828 var layout_body_tab_childs = layout_body_childs[k].childNodes;
4830 for(var m = 0; m < layout_body_tab_childs.length; m++) {
4832 if(layout_body_tab_childs[m].classList.contains('roo-layout-active-content')) {
4833 child_height += this.getChildHeight(layout_body_tab_childs[m].childNodes);
4848 child_height += child_nodes[i].offsetHeight;
4849 // Roo.log(child_nodes[i].offsetHeight);
4852 return child_height;
4854 toggleHeaderInput : function(is_edit)
4856 if (!this.editableTitle) {
4857 return; // not editable.
4859 if (is_edit && this.is_header_editing) {
4860 return; // already editing..
4864 this.headerEditEl.dom.value = this.title;
4865 this.headerEditEl.removeClass('d-none');
4866 this.headerEditEl.dom.focus();
4867 this.titleEl.addClass('d-none');
4869 this.is_header_editing = true;
4872 // flip back to not editing.
4873 this.title = this.headerEditEl.dom.value;
4874 this.headerEditEl.addClass('d-none');
4875 this.titleEl.removeClass('d-none');
4876 this.titleEl.dom.innerHTML = String.format('{0}', this.title);
4877 this.is_header_editing = false;
4878 this.fireEvent('titlechanged', this, this.title);
4887 Roo.apply(Roo.bootstrap.Modal, {
4889 * Button config that displays a single OK button
4898 * Button config that displays Yes and No buttons
4914 * Button config that displays OK and Cancel buttons
4929 * Button config that displays Yes, No and Cancel buttons
4954 * messagebox - can be used as a replace
4958 * @class Roo.MessageBox
4959 * Utility class for generating different styles of message boxes. The alias Roo.Msg can also be used.
4963 Roo.Msg.alert('Status', 'Changes saved successfully.');
4965 // Prompt for user data:
4966 Roo.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
4968 // process text value...
4972 // Show a dialog using config options:
4974 title:'Save Changes?',
4975 msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',
4976 buttons: Roo.Msg.YESNOCANCEL,
4983 Roo.bootstrap.MessageBox = function(){
4984 var dlg, opt, mask, waitTimer;
4985 var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp;
4986 var buttons, activeTextEl, bwidth;
4990 var handleButton = function(button){
4992 Roo.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
4996 var handleHide = function(){
4998 dlg.el.removeClass(opt.cls);
5001 // Roo.TaskMgr.stop(waitTimer);
5002 // waitTimer = null;
5007 var updateButtons = function(b){
5010 buttons["ok"].hide();
5011 buttons["cancel"].hide();
5012 buttons["yes"].hide();
5013 buttons["no"].hide();
5014 dlg.footerEl.hide();
5018 dlg.footerEl.show();
5019 for(var k in buttons){
5020 if(typeof buttons[k] != "function"){
5023 buttons[k].setText(typeof b[k] == "string" ? b[k] : Roo.bootstrap.MessageBox.buttonText[k]);
5024 width += buttons[k].el.getWidth()+15;
5034 var handleEsc = function(d, k, e){
5035 if(opt && opt.closable !== false){
5045 * Returns a reference to the underlying {@link Roo.BasicDialog} element
5046 * @return {Roo.BasicDialog} The BasicDialog element
5048 getDialog : function(){
5050 dlg = new Roo.bootstrap.Modal( {
5053 //constraintoviewport:false,
5055 //collapsible : false,
5060 //buttonAlign:"center",
5061 closeClick : function(){
5062 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
5065 handleButton("cancel");
5070 dlg.on("hide", handleHide);
5072 //dlg.addKeyListener(27, handleEsc);
5074 this.buttons = buttons;
5075 var bt = this.buttonText;
5076 buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
5077 buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
5078 buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
5079 buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
5081 bodyEl = dlg.bodyEl.createChild({
5083 html:'<span class="roo-mb-text"></span><br /><input type="text" class="roo-mb-input" />' +
5084 '<textarea class="roo-mb-textarea"></textarea>' +
5085 '<div class="roo-mb-progress-wrap"><div class="roo-mb-progress"><div class="roo-mb-progress-bar"> </div></div></div>'
5087 msgEl = bodyEl.dom.firstChild;
5088 textboxEl = Roo.get(bodyEl.dom.childNodes[2]);
5089 textboxEl.enableDisplayMode();
5090 textboxEl.addKeyListener([10,13], function(){
5091 if(dlg.isVisible() && opt && opt.buttons){
5094 }else if(opt.buttons.yes){
5095 handleButton("yes");
5099 textareaEl = Roo.get(bodyEl.dom.childNodes[3]);
5100 textareaEl.enableDisplayMode();
5101 progressEl = Roo.get(bodyEl.dom.childNodes[4]);
5102 progressEl.enableDisplayMode();
5104 // This is supposed to be the progessElement.. but I think it's controlling the height of everything..
5105 var pf = progressEl.dom.firstChild;
5107 pp = Roo.get(pf.firstChild);
5108 pp.setHeight(pf.offsetHeight);
5116 * Updates the message box body text
5117 * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
5118 * the XHTML-compliant non-breaking space character '&#160;')
5119 * @return {Roo.MessageBox} This message box
5121 updateText : function(text)
5123 if(!dlg.isVisible() && !opt.width){
5124 dlg.dialogEl.setStyle({ 'max-width' : this.maxWidth});
5125 // dlg.resizeTo(this.maxWidth, 100); // forcing the height breaks long alerts()
5127 msgEl.innerHTML = text || ' ';
5129 var cw = Math.max(msgEl.offsetWidth, msgEl.parentNode.scrollWidth);
5130 //Roo.log("guesed size: " + JSON.stringify([cw,msgEl.offsetWidth, msgEl.parentNode.scrollWidth]));
5132 Math.min(opt.width || cw , this.maxWidth),
5133 Math.max(opt.minWidth || this.minWidth, bwidth)
5136 activeTextEl.setWidth(w);
5138 if(dlg.isVisible()){
5139 dlg.fixedcenter = false;
5141 // to big, make it scroll. = But as usual stupid IE does not support
5144 if ( bodyEl.getHeight() > (Roo.lib.Dom.getViewHeight() - 100)) {
5145 bodyEl.setHeight ( Roo.lib.Dom.getViewHeight() - 100 );
5146 bodyEl.dom.style.overflowY = 'auto' + ( Roo.isIE ? '' : ' !important');
5148 bodyEl.dom.style.height = '';
5149 bodyEl.dom.style.overflowY = '';
5152 bodyEl.dom.style.get = 'auto' + ( Roo.isIE ? '' : ' !important');
5154 bodyEl.dom.style.overflowX = '';
5157 dlg.setContentSize(w, bodyEl.getHeight());
5158 if(dlg.isVisible()){
5159 dlg.fixedcenter = true;
5165 * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
5166 * initiated via {@link Roo.MessageBox#progress} or by calling {@link Roo.MessageBox#show} with progress: true.
5167 * @param {Number} value Any number between 0 and 1 (e.g., .5)
5168 * @param {String} text (optional) If defined, the message box's body text is replaced with the specified string (defaults to undefined)
5169 * @return {Roo.MessageBox} This message box
5171 updateProgress : function(value, text){
5173 this.updateText(text);
5176 if (pp) { // weird bug on my firefox - for some reason this is not defined
5177 pp.setWidth(Math.floor(value*progressEl.dom.firstChild.offsetWidth));
5178 pp.setHeight(Math.floor(progressEl.dom.firstChild.offsetHeight));
5184 * Returns true if the message box is currently displayed
5185 * @return {Boolean} True if the message box is visible, else false
5187 isVisible : function(){
5188 return dlg && dlg.isVisible();
5192 * Hides the message box if it is displayed
5195 if(this.isVisible()){
5201 * Displays a new message box, or reinitializes an existing message box, based on the config options
5202 * passed in. All functions (e.g. prompt, alert, etc) on MessageBox call this function internally.
5203 * The following config object properties are supported:
5205 Property Type Description
5206 ---------- --------------- ------------------------------------------------------------------------------------
5207 animEl String/Element An id or Element from which the message box should animate as it opens and
5208 closes (defaults to undefined)
5209 buttons Object/Boolean A button config object (e.g., Roo.MessageBox.OKCANCEL or {ok:'Foo',
5210 cancel:'Bar'}), or false to not show any buttons (defaults to false)
5211 closable Boolean False to hide the top-right close button (defaults to true). Note that
5212 progress and wait dialogs will ignore this property and always hide the
5213 close button as they can only be closed programmatically.
5214 cls String A custom CSS class to apply to the message box element
5215 defaultTextHeight Number The default height in pixels of the message box's multiline textarea if
5216 displayed (defaults to 75)
5217 fn Function A callback function to execute after closing the dialog. The arguments to the
5218 function will be btn (the name of the button that was clicked, if applicable,
5219 e.g. "ok"), and text (the value of the active text field, if applicable).
5220 Progress and wait dialogs will ignore this option since they do not respond to
5221 user actions and can only be closed programmatically, so any required function
5222 should be called by the same code after it closes the dialog.
5223 icon String A CSS class that provides a background image to be used as an icon for
5224 the dialog (e.g., Roo.MessageBox.WARNING or 'custom-class', defaults to '')
5225 maxWidth Number The maximum width in pixels of the message box (defaults to 600)
5226 minWidth Number The minimum width in pixels of the message box (defaults to 100)
5227 modal Boolean False to allow user interaction with the page while the message box is
5228 displayed (defaults to true)
5229 msg String A string that will replace the existing message box body text (defaults
5230 to the XHTML-compliant non-breaking space character ' ')
5231 multiline Boolean True to prompt the user to enter multi-line text (defaults to false)
5232 progress Boolean True to display a progress bar (defaults to false)
5233 progressText String The text to display inside the progress bar if progress = true (defaults to '')
5234 prompt Boolean True to prompt the user to enter single-line text (defaults to false)
5235 proxyDrag Boolean True to display a lightweight proxy while dragging (defaults to false)
5236 title String The title text
5237 value String The string value to set into the active textbox element if displayed
5238 wait Boolean True to display a progress bar (defaults to false)
5239 width Number The width of the dialog in pixels
5246 msg: 'Please enter your address:',
5248 buttons: Roo.MessageBox.OKCANCEL,
5251 animEl: 'addAddressBtn'
5254 * @param {Object} config Configuration options
5255 * @return {Roo.MessageBox} This message box
5257 show : function(options)
5260 // this causes nightmares if you show one dialog after another
5261 // especially on callbacks..
5263 if(this.isVisible()){
5266 Roo.log("[Roo.Messagebox] Show called while message displayed:" );
5267 Roo.log("Old Dialog Message:" + msgEl.innerHTML );
5268 Roo.log("New Dialog Message:" + options.msg )
5269 //this.alert("ERROR", "Multiple dialogs where displayed at the same time");
5270 //throw "Roo.MessageBox ERROR : Multiple dialogs where displayed at the same time";
5273 var d = this.getDialog();
5275 d.setTitle(opt.title || " ");
5276 d.closeEl.setDisplayed(opt.closable !== false);
5277 activeTextEl = textboxEl;
5278 opt.prompt = opt.prompt || (opt.multiline ? true : false);
5283 textareaEl.setHeight(typeof opt.multiline == "number" ?
5284 opt.multiline : this.defaultTextHeight);
5285 activeTextEl = textareaEl;
5294 progressEl.setDisplayed(opt.progress === true);
5296 d.animate = false; // do not animate progress, as it may not have finished animating before we close it..
5298 this.updateProgress(0);
5299 activeTextEl.dom.value = opt.value || "";
5301 dlg.setDefaultButton(activeTextEl);
5303 var bs = opt.buttons;
5307 }else if(bs && bs.yes){
5308 db = buttons["yes"];
5310 dlg.setDefaultButton(db);
5312 bwidth = updateButtons(opt.buttons);
5313 this.updateText(opt.msg);
5315 d.el.addClass(opt.cls);
5317 d.proxyDrag = opt.proxyDrag === true;
5318 d.modal = opt.modal !== false;
5319 d.mask = opt.modal !== false ? mask : false;
5321 // force it to the end of the z-index stack so it gets a cursor in FF
5322 document.body.appendChild(dlg.el.dom);
5323 d.animateTarget = null;
5324 d.show(options.animEl);
5330 * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
5331 * the user. You are responsible for updating the progress bar as needed via {@link Roo.MessageBox#updateProgress}
5332 * and closing the message box when the process is complete.
5333 * @param {String} title The title bar text
5334 * @param {String} msg The message box body text
5335 * @return {Roo.MessageBox} This message box
5337 progress : function(title, msg){
5344 minWidth: this.minProgressWidth,
5351 * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
5352 * If a callback function is passed it will be called after the user clicks the button, and the
5353 * id of the button that was clicked will be passed as the only parameter to the callback
5354 * (could also be the top-right close button).
5355 * @param {String} title The title bar text
5356 * @param {String} msg The message box body text
5357 * @param {Function} fn (optional) The callback function invoked after the message box is closed
5358 * @param {Object} scope (optional) The scope of the callback function
5359 * @return {Roo.MessageBox} This message box
5361 alert : function(title, msg, fn, scope)
5376 * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
5377 * interaction while waiting for a long-running process to complete that does not have defined intervals.
5378 * You are responsible for closing the message box when the process is complete.
5379 * @param {String} msg The message box body text
5380 * @param {String} title (optional) The title bar text
5381 * @return {Roo.MessageBox} This message box
5383 wait : function(msg, title){
5394 waitTimer = Roo.TaskMgr.start({
5396 Roo.MessageBox.updateProgress(((((i+20)%20)+1)*5)*.01);
5404 * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
5405 * If a callback function is passed it will be called after the user clicks either button, and the id of the
5406 * button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
5407 * @param {String} title The title bar text
5408 * @param {String} msg The message box body text
5409 * @param {Function} fn (optional) The callback function invoked after the message box is closed
5410 * @param {Object} scope (optional) The scope of the callback function
5411 * @return {Roo.MessageBox} This message box
5413 confirm : function(title, msg, fn, scope){
5417 buttons: this.YESNO,
5426 * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to
5427 * JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function
5428 * is passed it will be called after the user clicks either button, and the id of the button that was clicked
5429 * (could also be the top-right close button) and the text that was entered will be passed as the two
5430 * parameters to the callback.
5431 * @param {String} title The title bar text
5432 * @param {String} msg The message box body text
5433 * @param {Function} fn (optional) The callback function invoked after the message box is closed
5434 * @param {Object} scope (optional) The scope of the callback function
5435 * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
5436 * property, or the height in pixels to create the textbox (defaults to false / single-line)
5437 * @return {Roo.MessageBox} This message box
5439 prompt : function(title, msg, fn, scope, multiline){
5443 buttons: this.OKCANCEL,
5448 multiline: multiline,
5455 * Button config that displays a single OK button
5460 * Button config that displays Yes and No buttons
5463 YESNO : {yes:true, no:true},
5465 * Button config that displays OK and Cancel buttons
5468 OKCANCEL : {ok:true, cancel:true},
5470 * Button config that displays Yes, No and Cancel buttons
5473 YESNOCANCEL : {yes:true, no:true, cancel:true},
5476 * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
5479 defaultTextHeight : 75,
5481 * The maximum width in pixels of the message box (defaults to 600)
5486 * The minimum width in pixels of the message box (defaults to 100)
5491 * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
5492 * for setting a different minimum width than text-only dialogs may need (defaults to 250)
5495 minProgressWidth : 250,
5497 * An object containing the default button text strings that can be overriden for localized language support.
5498 * Supported properties are: ok, cancel, yes and no.
5499 * Customize the default text like so: Roo.MessageBox.buttonText.yes = "S?";
5512 * Shorthand for {@link Roo.MessageBox}
5514 Roo.MessageBox = Roo.MessageBox || Roo.bootstrap.MessageBox;
5515 Roo.Msg = Roo.Msg || Roo.MessageBox;
5524 * @class Roo.bootstrap.nav.Bar
5525 * @extends Roo.bootstrap.Component
5527 * Bootstrap Navbar class
5530 * Create a new Navbar
5531 * @param {Object} config The config object
5535 Roo.bootstrap.nav.Bar = function(config){
5536 Roo.bootstrap.nav.Bar.superclass.constructor.call(this, config);
5540 * @event beforetoggle
5541 * Fire before toggle the menu
5542 * @param {Roo.EventObject} e
5544 "beforetoggle" : true
5548 Roo.extend(Roo.bootstrap.nav.Bar, Roo.bootstrap.Component, {
5557 getAutoCreate : function(){
5560 throw { message : "nav bar is now a abstract base class - use NavSimplebar / NavHeaderbar / NavSidebar etc..."};
5564 initEvents :function ()
5566 //Roo.log(this.el.select('.navbar-toggle',true));
5567 this.el.select('.navbar-toggle',true).on('click', this.onToggle , this);
5574 this.maskEl = Roo.DomHelper.append(this.el, mark, true);
5576 var size = this.el.getSize();
5577 this.maskEl.setSize(size.width, size.height);
5578 this.maskEl.enableDisplayMode("block");
5587 getChildContainer : function()
5589 if (this.el && this.el.select('.collapse').getCount()) {
5590 return this.el.select('.collapse',true).first();
5605 onToggle : function()
5608 if(this.fireEvent('beforetoggle', this) === false){
5611 var ce = this.el.select('.navbar-collapse',true).first();
5613 if (!ce.hasClass('show')) {
5623 * Expand the navbar pulldown
5625 expand : function ()
5628 var ce = this.el.select('.navbar-collapse',true).first();
5629 if (ce.hasClass('collapsing')) {
5632 ce.dom.style.height = '';
5634 ce.addClass('in'); // old...
5635 ce.removeClass('collapse');
5636 ce.addClass('show');
5637 var h = ce.getHeight();
5639 ce.removeClass('show');
5640 // at this point we should be able to see it..
5641 ce.addClass('collapsing');
5643 ce.setHeight(0); // resize it ...
5644 ce.on('transitionend', function() {
5645 //Roo.log('done transition');
5646 ce.removeClass('collapsing');
5647 ce.addClass('show');
5648 ce.removeClass('collapse');
5650 ce.dom.style.height = '';
5651 }, this, { single: true} );
5653 ce.dom.scrollTop = 0;
5656 * Collapse the navbar pulldown
5658 collapse : function()
5660 var ce = this.el.select('.navbar-collapse',true).first();
5662 if (ce.hasClass('collapsing') || ce.hasClass('collapse') ) {
5663 // it's collapsed or collapsing..
5666 ce.removeClass('in'); // old...
5667 ce.setHeight(ce.getHeight());
5668 ce.removeClass('show');
5669 ce.addClass('collapsing');
5671 ce.on('transitionend', function() {
5672 ce.dom.style.height = '';
5673 ce.removeClass('collapsing');
5674 ce.addClass('collapse');
5675 }, this, { single: true} );
5695 * @class Roo.bootstrap.nav.Simplebar
5696 * @extends Roo.bootstrap.nav.Bar
5697 * @children Roo.bootstrap.nav.Group Roo.bootstrap.Container Roo.bootstrap.form.Form Roo.bootstrap.Row Roo.bootstrap.Column Roo.bootstrap.Link
5698 * Bootstrap Sidebar class
5700 * @cfg {Boolean} inverse is inverted color
5702 * @cfg {String} type (nav | pills | tabs)
5703 * @cfg {Boolean} arrangement stacked | justified
5704 * @cfg {String} align (left | right) alignment
5706 * @cfg {Boolean} main (true|false) main nav bar? default false
5707 * @cfg {Boolean} loadMask (true|false) loadMask on the bar
5709 * @cfg {String} tag (header|footer|nav|div) default is nav
5711 * @cfg {String} weight (light|primary|secondary|success|danger|warning|info|dark|white) default is light.
5715 * Create a new Sidebar
5716 * @param {Object} config The config object
5720 Roo.bootstrap.nav.Simplebar = function(config){
5721 Roo.bootstrap.nav.Simplebar.superclass.constructor.call(this, config);
5724 Roo.extend(Roo.bootstrap.nav.Simplebar, Roo.bootstrap.nav.Bar, {
5740 getAutoCreate : function(){
5744 tag : this.tag || 'div',
5745 cls : 'navbar roo-navbar-simple' //navbar-expand-lg ??
5747 if (['light','white'].indexOf(this.weight) > -1) {
5748 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
5750 cfg.cls += ' bg-' + this.weight;
5753 cfg.cls += ' navbar-inverse';
5757 // i'm not actually sure these are really used - normally we add a navGroup to a navbar
5759 if (Roo.bootstrap.version == 4 && this.xtype == 'NavSimplebar') {
5768 cls: 'nav nav-' + this.xtype,
5774 this.type = this.type || 'nav';
5775 if (['tabs','pills'].indexOf(this.type) != -1) {
5776 cfg.cn[0].cls += ' nav-' + this.type
5780 if (this.type!=='nav') {
5781 Roo.log('nav type must be nav/tabs/pills')
5783 cfg.cn[0].cls += ' navbar-nav'
5789 if (['stacked','justified'].indexOf(this.arrangement) != -1) {
5790 cfg.cn[0].cls += ' nav-' + this.arrangement;
5794 if (this.align === 'right') {
5795 cfg.cn[0].cls += ' navbar-right';
5820 * navbar-expand-md fixed-top
5824 * @class Roo.bootstrap.nav.Headerbar
5825 * @extends Roo.bootstrap.nav.Simplebar
5826 * @children Roo.bootstrap.nav.Group Roo.bootstrap.Container Roo.bootstrap.form.Form Roo.bootstrap.Row Roo.bootstrap.Column Roo.bootstrap.Link
5827 * Bootstrap Sidebar class
5829 * @cfg {String} brand what is brand
5830 * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
5831 * @cfg {String} brand_href href of the brand
5832 * @cfg {Boolean} srButton generate the (screen reader / mobile) sr-only button default true
5833 * @cfg {Boolean} autohide a top nav bar header that hides on scroll.
5834 * @cfg {Boolean} desktopCenter should the header be centered on desktop using a container class
5835 * @cfg {Roo.bootstrap.Row} mobilerow - a row to display on mobile only..
5838 * Create a new Sidebar
5839 * @param {Object} config The config object
5843 Roo.bootstrap.nav.Headerbar = function(config){
5844 Roo.bootstrap.nav.Headerbar.superclass.constructor.call(this, config);
5848 Roo.extend(Roo.bootstrap.nav.Headerbar, Roo.bootstrap.nav.Simplebar, {
5855 desktopCenter : false,
5858 getAutoCreate : function(){
5861 tag: this.nav || 'nav',
5862 cls: 'navbar navbar-expand-md',
5868 if (this.desktopCenter) {
5869 cn.push({cls : 'container', cn : []});
5877 cls: 'navbar-toggle navbar-toggler',
5878 'data-toggle': 'collapse',
5883 html: 'Toggle navigation'
5887 cls: 'icon-bar navbar-toggler-icon'
5900 cn.push( Roo.bootstrap.version == 4 ? btn : {
5902 cls: 'navbar-header',
5911 cls: Roo.bootstrap.version == 4 ? 'nav flex-row roo-navbar-collapse collapse navbar-collapse' : 'collapse navbar-collapse roo-navbar-collapse',
5915 cfg.cls += this.inverse ? ' navbar-inverse navbar-dark bg-dark' : ' navbar-default';
5917 if (['light','white'].indexOf(this.weight) > -1) {
5918 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
5920 cfg.cls += ' bg-' + this.weight;
5923 if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
5924 cfg.cls += ' navbar-' + this.position + ' ' + this.position ;
5926 // tag can override this..
5928 cfg.tag = this.tag || (this.position == 'fixed-bottom' ? 'footer' : 'header');
5931 if (this.brand !== '') {
5932 var cp = Roo.bootstrap.version == 4 ? cn : cn[0].cn;
5933 cp.unshift({ // changed from push ?? BS4 needs it at the start? - does this break or exsiting?
5935 href: this.brand_href ? this.brand_href : '#',
5936 cls: 'navbar-brand',
5944 cfg.cls += ' main-nav';
5952 getHeaderChildContainer : function()
5954 if (this.srButton && this.el.select('.navbar-header').getCount()) {
5955 return this.el.select('.navbar-header',true).first();
5958 return this.getChildContainer();
5961 getChildContainer : function()
5964 return this.el.select('.roo-navbar-collapse',true).first();
5969 initEvents : function()
5971 Roo.bootstrap.nav.Headerbar.superclass.initEvents.call(this);
5973 if (this.autohide) {
5978 Roo.get(document).on('scroll',function(e) {
5979 var ns = Roo.get(document).getScroll().top;
5980 var os = prevScroll;
5984 ft.removeClass('slideDown');
5985 ft.addClass('slideUp');
5988 ft.removeClass('slideUp');
5989 ft.addClass('slideDown');
6010 * @class Roo.bootstrap.nav.Sidebar
6011 * @extends Roo.bootstrap.nav.Bar
6012 * @children Roo.bootstrap.nav.Group Roo.bootstrap.Container Roo.bootstrap.form.Form Roo.bootstrap.Row Roo.bootstrap.Column Roo.bootstrap.Link
6013 * Bootstrap Sidebar class
6016 * Create a new Sidebar
6017 * @param {Object} config The config object
6021 Roo.bootstrap.nav.Sidebar = function(config){
6022 Roo.bootstrap.nav.Sidebar.superclass.constructor.call(this, config);
6025 Roo.extend(Roo.bootstrap.nav.Sidebar, Roo.bootstrap.nav.Bar, {
6027 sidebar : true, // used by Navbar Item and NavbarGroup at present...
6029 getAutoCreate : function(){
6034 cls: 'sidebar sidebar-nav'
6056 * @class Roo.bootstrap.nav.Group
6057 * @extends Roo.bootstrap.Component
6058 * @children Roo.bootstrap.nav.Item
6059 * Bootstrap NavGroup class
6060 * @cfg {String} align (left|right)
6061 * @cfg {Boolean} inverse
6062 * @cfg {String} type (nav|pills|tab) default nav
6063 * @cfg {String} navId - reference Id for navbar.
6064 * @cfg {Boolean} pilltype default true (turn to off to disable active toggle)
6067 * Create a new nav group
6068 * @param {Object} config The config object
6071 Roo.bootstrap.nav.Group = function(config){
6072 Roo.bootstrap.nav.Group.superclass.constructor.call(this, config);
6075 Roo.bootstrap.nav.Group.register(this);
6079 * Fires when the active item changes
6080 * @param {Roo.bootstrap.nav.Group} this
6081 * @param {Roo.bootstrap.Navbar.Item} selected The item selected
6082 * @param {Roo.bootstrap.Navbar.Item} prev The previously selected item
6089 Roo.extend(Roo.bootstrap.nav.Group, Roo.bootstrap.Component, {
6101 getAutoCreate : function()
6103 var cfg = Roo.apply({}, Roo.bootstrap.nav.Group.superclass.getAutoCreate.call(this));
6109 if (Roo.bootstrap.version == 4) {
6110 if (['tabs','pills'].indexOf(this.type) != -1) {
6111 cfg.cls += ' nav-' + this.type;
6113 // trying to remove so header bar can right align top?
6114 if (this.parent() && this.parent().xtype != 'NavHeaderbar') {
6115 // do not use on header bar...
6116 cfg.cls += ' navbar-nav';
6121 if (['tabs','pills'].indexOf(this.type) != -1) {
6122 cfg.cls += ' nav-' + this.type
6124 if (this.type !== 'nav') {
6125 Roo.log('nav type must be nav/tabs/pills')
6127 cfg.cls += ' navbar-nav'
6131 if (this.parent() && this.parent().sidebar) {
6134 cls: 'dashboard-menu sidebar-menu'
6140 if (this.form === true) {
6143 cls: 'navbar-form form-inline'
6145 //nav navbar-right ml-md-auto
6146 if (this.align === 'right') {
6147 cfg.cls += ' navbar-right ml-md-auto';
6149 cfg.cls += ' navbar-left';
6153 if (this.align === 'right') {
6154 cfg.cls += ' navbar-right ml-md-auto';
6156 cfg.cls += ' mr-auto';
6160 cfg.cls += ' navbar-inverse';
6168 * sets the active Navigation item
6169 * @param {Roo.bootstrap.nav.Item} the new current navitem
6171 setActiveItem : function(item)
6174 Roo.each(this.navItems, function(v){
6179 v.setActive(false, true);
6186 item.setActive(true, true);
6187 this.fireEvent('changed', this, item, prev);
6192 * gets the active Navigation item
6193 * @return {Roo.bootstrap.nav.Item} the current navitem
6195 getActive : function()
6199 Roo.each(this.navItems, function(v){
6210 indexOfNav : function()
6214 Roo.each(this.navItems, function(v,i){
6225 * adds a Navigation item
6226 * @param {Roo.bootstrap.nav.Item} the navitem to add
6228 addItem : function(cfg)
6230 if (this.form && Roo.bootstrap.version == 4) {
6233 var cn = new Roo.bootstrap.nav.Item(cfg);
6235 cn.parentId = this.id;
6236 cn.onRender(this.el, null);
6240 * register a Navigation item
6241 * @param {Roo.bootstrap.nav.Item} the navitem to add
6243 register : function(item)
6245 this.navItems.push( item);
6246 item.navId = this.navId;
6251 * clear all the Navigation item
6254 clearAll : function()
6257 this.el.dom.innerHTML = '';
6260 getNavItem: function(tabId)
6263 Roo.each(this.navItems, function(e) {
6264 if (e.tabId == tabId) {
6274 setActiveNext : function()
6276 var i = this.indexOfNav(this.getActive());
6277 if (i > this.navItems.length) {
6280 this.setActiveItem(this.navItems[i+1]);
6282 setActivePrev : function()
6284 var i = this.indexOfNav(this.getActive());
6288 this.setActiveItem(this.navItems[i-1]);
6290 clearWasActive : function(except) {
6291 Roo.each(this.navItems, function(e) {
6292 if (e.tabId != except.tabId && e.was_active) {
6293 e.was_active = false;
6300 getWasActive : function ()
6303 Roo.each(this.navItems, function(e) {
6318 Roo.apply(Roo.bootstrap.nav.Group, {
6322 * register a Navigation Group
6323 * @param {Roo.bootstrap.nav.Group} the navgroup to add
6325 register : function(navgrp)
6327 this.groups[navgrp.navId] = navgrp;
6331 * fetch a Navigation Group based on the navigation ID
6332 * @param {string} the navgroup to add
6333 * @returns {Roo.bootstrap.nav.Group} the navgroup
6335 get: function(navId) {
6336 if (typeof(this.groups[navId]) == 'undefined') {
6338 //this.register(new Roo.bootstrap.nav.Group({ navId : navId }));
6340 return this.groups[navId] ;
6348 * @class Roo.bootstrap.nav.Item
6349 * @extends Roo.bootstrap.Component
6350 * @children Roo.bootstrap.Container Roo.bootstrap.Button
6351 * @parent Roo.bootstrap.nav.Group
6353 * Bootstrap Navbar.NavItem class
6355 * @cfg {String} href link to
6356 * @cfg {String} button_weight (default|primary|secondary|success|info|warning|danger|link|light|dark) default none
6357 * @cfg {Boolean} button_outline show and outlined button
6358 * @cfg {String} html content of button
6359 * @cfg {String} badge text inside badge
6360 * @cfg {String} badgecls (bg-green|bg-red|bg-yellow)the extra classes for the badge
6361 * @cfg {String} glyphicon DEPRICATED - use fa
6362 * @cfg {String} icon DEPRICATED - use fa
6363 * @cfg {String} fa - Fontawsome icon name (can add stuff to it like fa-2x)
6364 * @cfg {Boolean} active Is item active
6365 * @cfg {Boolean} disabled Is item disabled
6366 * @cfg {String} linkcls Link Class
6367 * @cfg {Boolean} preventDefault (true | false) default false
6368 * @cfg {String} tabId the tab that this item activates.
6369 * @cfg {String} tagtype (a|span) render as a href or span?
6370 * @cfg {Boolean} animateRef (true|false) link to element default false
6371 * @cfg {Roo.bootstrap.menu.Menu} menu a Menu
6374 * Create a new Navbar Item
6375 * @param {Object} config The config object
6377 Roo.bootstrap.nav.Item = function(config){
6378 Roo.bootstrap.nav.Item.superclass.constructor.call(this, config);
6383 * The raw click event for the entire grid.
6384 * @param {Roo.EventObject} e
6389 * Fires when the active item active state changes
6390 * @param {Roo.bootstrap.nav.Item} this
6391 * @param {boolean} state the new state
6397 * Fires when scroll to element
6398 * @param {Roo.bootstrap.nav.Item} this
6399 * @param {Object} options
6400 * @param {Roo.EventObject} e
6408 Roo.extend(Roo.bootstrap.nav.Item, Roo.bootstrap.Component, {
6417 preventDefault : false,
6425 button_outline : false,
6429 getAutoCreate : function(){
6436 cfg.cls = typeof(cfg.cls) == 'undefined' ? '' : cfg.cls;
6439 cfg.cls += ' active' ;
6441 if (this.disabled) {
6442 cfg.cls += ' disabled';
6446 if (this.button_weight.length) {
6447 cfg.tag = this.href ? 'a' : 'button';
6448 cfg.html = this.html || '';
6449 cfg.cls += ' btn btn' + (this.button_outline ? '-outline' : '') + '-' + this.button_weight;
6451 cfg.href = this.href;
6454 cfg.html = '<i class="fa fas fa-'+this.fa+'"></i> <span class="nav-html">' + this.html + '</span>';
6456 cfg.cls += " nav-html";
6459 // menu .. should add dropdown-menu class - so no need for carat..
6461 if (this.badge !== '') {
6463 cfg.html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
6468 if (this.href || this.html || this.glyphicon || this.icon || this.fa) {
6472 href : this.href || "#",
6473 html: this.html || '',
6477 if (this.tagtype == 'a') {
6478 cfg.cn[0].cls = 'nav-link' + (this.active ? ' active' : '') + ' ' + this.linkcls;
6482 cfg.cn[0].html = '<i class="'+this.icon+'"></i> <span class="nav-html">' + cfg.cn[0].html + '</span>';
6483 } else if (this.fa) {
6484 cfg.cn[0].html = '<i class="fa fas fa-'+this.fa+'"></i> <span class="nav-html">' + cfg.cn[0].html + '</span>';
6485 } else if(this.glyphicon) {
6486 cfg.cn[0].html = '<span class="glyphicon glyphicon-' + this.glyphicon + '"></span> ' + cfg.cn[0].html;
6488 cfg.cn[0].cls += " nav-html";
6492 cfg.cn[0].html += " <span class='caret'></span>";
6496 if (this.badge !== '') {
6497 cfg.cn[0].html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
6505 onRender : function(ct, position)
6507 // Roo.log("Call onRender: " + this.xtype);
6508 if (Roo.bootstrap.version == 4 && ct.dom.type != 'ul') {
6512 var ret = Roo.bootstrap.nav.Item.superclass.onRender.call(this, ct, position);
6513 this.navLink = this.el.select('.nav-link',true).first();
6514 this.htmlEl = this.el.hasClass('nav-html') ? this.el : this.el.select('.nav-html',true).first();
6519 initEvents: function()
6521 if (typeof (this.menu) != 'undefined') {
6522 this.menu.parentType = this.xtype;
6523 this.menu.triggerEl = this.el;
6524 this.menu = this.addxtype(Roo.apply({}, this.menu));
6527 this.el.on('click', this.onClick, this);
6529 //if(this.tagtype == 'span'){
6530 // this.el.select('span',true).on('click', this.onClick, this);
6533 // at this point parent should be available..
6534 this.parent().register(this);
6537 onClick : function(e)
6539 if (e.getTarget('.dropdown-menu-item')) {
6540 // did you click on a menu itemm.... - then don't trigger onclick..
6545 this.preventDefault ||
6548 Roo.log("NavItem - prevent Default?");
6552 if (this.disabled) {
6556 var tg = Roo.bootstrap.TabGroup.get(this.navId);
6557 if (tg && tg.transition) {
6558 Roo.log("waiting for the transitionend");
6564 //Roo.log("fire event clicked");
6565 if(this.fireEvent('click', this, e) === false){
6569 if(this.tagtype == 'span'){
6573 //Roo.log(this.href);
6574 var ael = this.el.select('a',true).first();
6577 if(ael && this.animateRef && this.href.indexOf('#') > -1){
6578 //Roo.log(["test:",ael.dom.href.split("#")[0], document.location.toString().split("#")[0]]);
6579 if (ael.dom.href.split("#")[0] != document.location.toString().split("#")[0]) {
6580 return; // ignore... - it's a 'hash' to another page.
6582 Roo.log("NavItem - prevent Default?");
6584 this.scrollToElement(e);
6588 var p = this.parent();
6590 if (['tabs','pills'].indexOf(p.type)!==-1 && p.pilltype) {
6591 if (typeof(p.setActiveItem) !== 'undefined') {
6592 p.setActiveItem(this);
6596 // if parent is a navbarheader....- and link is probably a '#' page ref.. then remove the expanded menu.
6597 if (p.parentType == 'NavHeaderbar' && !this.menu) {
6598 // remove the collapsed menu expand...
6599 p.parent().el.select('.roo-navbar-collapse',true).removeClass('in');
6603 isActive: function () {
6606 setActive : function(state, fire, is_was_active)
6608 if (this.active && !state && this.navId) {
6609 this.was_active = true;
6610 var nv = Roo.bootstrap.nav.Group.get(this.navId);
6612 nv.clearWasActive(this);
6616 this.active = state;
6619 this.el.removeClass('active');
6620 this.navLink ? this.navLink.removeClass('active') : false;
6621 } else if (!this.el.hasClass('active')) {
6623 this.el.addClass('active');
6624 if (Roo.bootstrap.version == 4 && this.navLink ) {
6625 this.navLink.addClass('active');
6630 this.fireEvent('changed', this, state);
6633 // show a panel if it's registered and related..
6635 if (!this.navId || !this.tabId || !state || is_was_active) {
6639 var tg = Roo.bootstrap.TabGroup.get(this.navId);
6643 var pan = tg.getPanelByName(this.tabId);
6647 // if we can not flip to new panel - go back to old nav highlight..
6648 if (false == tg.showPanel(pan)) {
6649 var nv = Roo.bootstrap.nav.Group.get(this.navId);
6651 var onav = nv.getWasActive();
6653 onav.setActive(true, false, true);
6662 // this should not be here...
6663 setDisabled : function(state)
6665 this.disabled = state;
6667 this.el.removeClass('disabled');
6668 } else if (!this.el.hasClass('disabled')) {
6669 this.el.addClass('disabled');
6675 * Fetch the element to display the tooltip on.
6676 * @return {Roo.Element} defaults to this.el
6678 tooltipEl : function()
6680 return this.el; //this.tagtype == 'a' ? this.el : this.el.select('' + this.tagtype + '', true).first();
6683 scrollToElement : function(e)
6685 var c = document.body;
6688 * Firefox / IE places the overflow at the html level, unless specifically styled to behave differently.
6690 if(Roo.isFirefox || Roo.isIE || Roo.isIE11){
6691 c = document.documentElement;
6694 var target = Roo.get(c).select('a[name=' + this.href.split('#')[1] +']', true).first();
6700 var o = target.calcOffsetsTo(c);
6707 this.fireEvent('scrollto', this, options, e);
6709 Roo.get(c).scrollTo('top', options.value, true);
6714 * Set the HTML (text content) of the item
6715 * @param {string} html content for the nav item
6717 setHtml : function(html)
6720 this.htmlEl.dom.innerHTML = html;
6732 * <span> icon </span>
6733 * <span> text </span>
6734 * <span>badge </span>
6738 * @class Roo.bootstrap.nav.SidebarItem
6739 * @extends Roo.bootstrap.nav.Item
6740 * Bootstrap Navbar.NavSidebarItem class
6742 * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
6743 * {Boolean} open is the menu open
6744 * {Boolean} buttonView use button as the tigger el rather that a (default false)
6745 * {String} buttonWeight (default|primary|success|info|warning|danger)the extra classes for the button
6746 * {String} buttonSize (sm|md|lg)the extra classes for the button
6747 * {Boolean} showArrow show arrow next to the text (default true)
6749 * Create a new Navbar Button
6750 * @param {Object} config The config object
6752 Roo.bootstrap.nav.SidebarItem = function(config){
6753 Roo.bootstrap.nav.SidebarItem.superclass.constructor.call(this, config);
6758 * The raw click event for the entire grid.
6759 * @param {Roo.EventObject} e
6764 * Fires when the active item active state changes
6765 * @param {Roo.bootstrap.nav.SidebarItem} this
6766 * @param {boolean} state the new state
6774 Roo.extend(Roo.bootstrap.nav.SidebarItem, Roo.bootstrap.nav.Item, {
6776 badgeWeight : 'default',
6782 buttonWeight : 'default',
6788 getAutoCreate : function(){
6793 href : this.href || '#',
6799 if(this.buttonView){
6802 href : this.href || '#',
6803 cls: 'btn btn-' + this.buttonWeight + ' btn-' + this.buttonSize + 'roo-button-dropdown-toggle',
6816 cfg.cls += ' active';
6819 if (this.disabled) {
6820 cfg.cls += ' disabled';
6823 cfg.cls += ' open x-open';
6826 if (this.glyphicon || this.icon) {
6827 var c = this.glyphicon ? ('glyphicon glyphicon-'+this.glyphicon) : this.icon;
6828 a.cn.push({ tag : 'i', cls : c }) ;
6831 if(!this.buttonView){
6834 html : this.html || ''
6841 if (this.badge !== '') {
6842 a.cn.push({ tag: 'span', cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge });
6848 a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
6851 a.cls += ' dropdown-toggle treeview' ;
6857 initEvents : function()
6859 if (typeof (this.menu) != 'undefined') {
6860 this.menu.parentType = this.xtype;
6861 this.menu.triggerEl = this.el;
6862 this.menu = this.addxtype(Roo.apply({}, this.menu));
6865 this.el.on('click', this.onClick, this);
6867 if(this.badge !== ''){
6868 this.badgeEl = this.el.select('.badge', true).first().setVisibilityMode(Roo.Element.DISPLAY);
6873 onClick : function(e)
6880 if(this.preventDefault){
6884 this.fireEvent('click', this, e);
6887 disable : function()
6889 this.setDisabled(true);
6894 this.setDisabled(false);
6897 setDisabled : function(state)
6899 if(this.disabled == state){
6903 this.disabled = state;
6906 this.el.addClass('disabled');
6910 this.el.removeClass('disabled');
6915 setActive : function(state)
6917 if(this.active == state){
6921 this.active = state;
6924 this.el.addClass('active');
6928 this.el.removeClass('active');
6933 isActive: function ()
6938 setBadge : function(str)
6944 this.badgeEl.dom.innerHTML = str;
6961 * @class Roo.bootstrap.nav.ProgressBar
6962 * @extends Roo.bootstrap.Component
6963 * @children Roo.bootstrap.nav.ProgressBarItem
6964 * Bootstrap NavProgressBar class
6967 * Create a new nav progress bar - a bar indicating step along a process
6968 * @param {Object} config The config object
6971 Roo.bootstrap.nav.ProgressBar = function(config){
6972 Roo.bootstrap.nav.ProgressBar.superclass.constructor.call(this, config);
6974 this.bullets = this.bullets || [];
6976 // Roo.bootstrap.nav.ProgressBar.register(this);
6980 * Fires when the active item changes
6981 * @param {Roo.bootstrap.nav.ProgressBar} this
6982 * @param {Roo.bootstrap.nav.ProgressItem} selected The item selected
6983 * @param {Roo.bootstrap.nav.ProgressItem} prev The previously selected item
6990 Roo.extend(Roo.bootstrap.nav.ProgressBar, Roo.bootstrap.Component, {
6992 * @cfg {Roo.bootstrap.nav.ProgressItem} NavProgressBar:bullets[]
6993 * Bullets for the Nav Progress bar for the toolbar
6998 getAutoCreate : function()
7000 var cfg = Roo.apply({}, Roo.bootstrap.nav.ProgressBar.superclass.getAutoCreate.call(this));
7004 cls : 'roo-navigation-bar-group',
7008 cls : 'roo-navigation-top-bar'
7012 cls : 'roo-navigation-bullets-bar',
7016 cls : 'roo-navigation-bar'
7023 cls : 'roo-navigation-bottom-bar'
7033 initEvents: function()
7038 onRender : function(ct, position)
7040 Roo.bootstrap.nav.ProgressBar.superclass.onRender.call(this, ct, position);
7042 if(this.bullets.length){
7043 Roo.each(this.bullets, function(b){
7052 addItem : function(cfg)
7054 var item = new Roo.bootstrap.nav.ProgressItem(cfg);
7056 item.parentId = this.id;
7057 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
7060 var top = new Roo.bootstrap.Element({
7062 cls : 'roo-navigation-bar-text'
7065 var bottom = new Roo.bootstrap.Element({
7067 cls : 'roo-navigation-bar-text'
7070 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
7071 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
7073 var topText = new Roo.bootstrap.Element({
7075 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
7078 var bottomText = new Roo.bootstrap.Element({
7080 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
7083 topText.onRender(top.el, null);
7084 bottomText.onRender(bottom.el, null);
7087 item.bottomEl = bottom;
7090 this.barItems.push(item);
7095 getActive : function()
7099 Roo.each(this.barItems, function(v){
7101 if (!v.isActive()) {
7113 setActiveItem : function(item)
7117 Roo.each(this.barItems, function(v){
7118 if (v.rid == item.rid) {
7128 item.setActive(true);
7130 this.fireEvent('changed', this, item, prev);
7133 getBarItem: function(rid)
7137 Roo.each(this.barItems, function(e) {
7149 indexOfItem : function(item)
7153 Roo.each(this.barItems, function(v, i){
7155 if (v.rid != item.rid) {
7166 setActiveNext : function()
7168 var i = this.indexOfItem(this.getActive());
7170 if (i > this.barItems.length) {
7174 this.setActiveItem(this.barItems[i+1]);
7177 setActivePrev : function()
7179 var i = this.indexOfItem(this.getActive());
7185 this.setActiveItem(this.barItems[i-1]);
7190 if(!this.barItems.length){
7194 var width = 100 / this.barItems.length;
7196 Roo.each(this.barItems, function(i){
7197 i.el.setStyle('width', width + '%');
7198 i.topEl.el.setStyle('width', width + '%');
7199 i.bottomEl.el.setStyle('width', width + '%');
7213 * @class Roo.bootstrap.nav.ProgressBarItem
7214 * @extends Roo.bootstrap.Component
7215 * Bootstrap NavProgressBarItem class
7216 * @cfg {String} rid the reference id
7217 * @cfg {Boolean} active (true|false) Is item active default false
7218 * @cfg {Boolean} disabled (true|false) Is item active default false
7219 * @cfg {String} html
7220 * @cfg {String} position (top|bottom) text position default bottom
7221 * @cfg {String} icon show icon instead of number
7224 * Create a new NavProgressBarItem
7225 * @param {Object} config The config object
7227 Roo.bootstrap.nav.ProgressBarItem = function(config){
7228 Roo.bootstrap.nav.ProgressBarItem.superclass.constructor.call(this, config);
7233 * The raw click event for the entire grid.
7234 * @param {Roo.bootstrap.nav.ProgressBarItem} this
7235 * @param {Roo.EventObject} e
7242 Roo.extend(Roo.bootstrap.nav.ProgressBarItem, Roo.bootstrap.Component, {
7248 position : 'bottom',
7251 getAutoCreate : function()
7253 var iconCls = 'roo-navigation-bar-item-icon';
7255 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
7259 cls: 'roo-navigation-bar-item',
7269 cfg.cls += ' active';
7272 cfg.cls += ' disabled';
7278 disable : function()
7280 this.setDisabled(true);
7285 this.setDisabled(false);
7288 initEvents: function()
7290 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
7292 this.iconEl.on('click', this.onClick, this);
7295 onClick : function(e)
7303 if(this.fireEvent('click', this, e) === false){
7307 this.parent().setActiveItem(this);
7310 isActive: function ()
7315 setActive : function(state)
7317 if(this.active == state){
7321 this.active = state;
7324 this.el.addClass('active');
7328 this.el.removeClass('active');
7333 setDisabled : function(state)
7335 if(this.disabled == state){
7339 this.disabled = state;
7342 this.el.addClass('disabled');
7346 this.el.removeClass('disabled');
7349 tooltipEl : function()
7351 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
7362 Roo.namespace('Roo.bootstrap.breadcrumb');
7366 * @class Roo.bootstrap.breadcrumb.Nav
7367 * @extends Roo.bootstrap.Component
7368 * Bootstrap Breadcrumb Nav Class
7370 * @children Roo.bootstrap.breadcrumb.Item
7373 * Create a new breadcrumb.Nav
7374 * @param {Object} config The config object
7378 Roo.bootstrap.breadcrumb.Nav = function(config){
7379 Roo.bootstrap.breadcrumb.Nav.superclass.constructor.call(this, config);
7384 Roo.extend(Roo.bootstrap.breadcrumb.Nav, Roo.bootstrap.Component, {
7386 getAutoCreate : function()
7403 initEvents: function()
7405 this.olEl = this.el.select('ol',true).first();
7407 getChildContainer : function()
7423 * @class Roo.bootstrap.breadcrumb.Nav
7424 * @extends Roo.bootstrap.Component
7425 * @children Roo.bootstrap.Component
7426 * @parent Roo.bootstrap.breadcrumb.Nav
7427 * Bootstrap Breadcrumb Nav Class
7430 * @cfg {String} html the content of the link.
7431 * @cfg {String} href where it links to if '#' is used the link will be handled by onClick.
7432 * @cfg {Boolean} active is it active
7436 * Create a new breadcrumb.Nav
7437 * @param {Object} config The config object
7440 Roo.bootstrap.breadcrumb.Item = function(config){
7441 Roo.bootstrap.breadcrumb.Item.superclass.constructor.call(this, config);
7446 * The img click event for the img.
7447 * @param {Roo.EventObject} e
7454 Roo.extend(Roo.bootstrap.breadcrumb.Item, Roo.bootstrap.Component, {
7459 getAutoCreate : function()
7464 cls : 'breadcrumb-item' + (this.active ? ' active' : '')
7466 if (this.href !== false) {
7473 cfg.html = this.html;
7479 initEvents: function()
7482 this.el.select('a', true).first().on('click',this.onClick, this)
7486 onClick : function(e)
7489 this.fireEvent('click',this, e);
7502 * @class Roo.bootstrap.Row
7503 * @extends Roo.bootstrap.Component
7504 * @children Roo.bootstrap.Component
7505 * Bootstrap Row class (contains columns...)
7509 * @param {Object} config The config object
7512 Roo.bootstrap.Row = function(config){
7513 Roo.bootstrap.Row.superclass.constructor.call(this, config);
7516 Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component, {
7518 getAutoCreate : function(){
7537 * @class Roo.bootstrap.Pagination
7538 * @extends Roo.bootstrap.Component
7539 * @children Roo.bootstrap.Pagination
7540 * Bootstrap Pagination class
7542 * @cfg {String} size (xs|sm|md|lg|xl)
7543 * @cfg {Boolean} inverse
7546 * Create a new Pagination
7547 * @param {Object} config The config object
7550 Roo.bootstrap.Pagination = function(config){
7551 Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
7554 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component, {
7560 getAutoCreate : function(){
7566 cfg.cls += ' inverse';
7572 cfg.cls += " " + this.cls;
7590 * @class Roo.bootstrap.PaginationItem
7591 * @extends Roo.bootstrap.Component
7592 * Bootstrap PaginationItem class
7593 * @cfg {String} html text
7594 * @cfg {String} href the link
7595 * @cfg {Boolean} preventDefault (true | false) default true
7596 * @cfg {Boolean} active (true | false) default false
7597 * @cfg {Boolean} disabled default false
7601 * Create a new PaginationItem
7602 * @param {Object} config The config object
7606 Roo.bootstrap.PaginationItem = function(config){
7607 Roo.bootstrap.PaginationItem.superclass.constructor.call(this, config);
7612 * The raw click event for the entire grid.
7613 * @param {Roo.EventObject} e
7619 Roo.extend(Roo.bootstrap.PaginationItem, Roo.bootstrap.Component, {
7623 preventDefault: true,
7628 getAutoCreate : function(){
7634 href : this.href ? this.href : '#',
7635 html : this.html ? this.html : ''
7645 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' disabled' : 'disabled';
7649 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' active' : 'active';
7655 initEvents: function() {
7657 this.el.on('click', this.onClick, this);
7660 onClick : function(e)
7662 Roo.log('PaginationItem on click ');
7663 if(this.preventDefault){
7671 this.fireEvent('click', this, e);
7687 * @class Roo.bootstrap.Slider
7688 * @extends Roo.bootstrap.Component
7689 * Bootstrap Slider class
7692 * Create a new Slider
7693 * @param {Object} config The config object
7696 Roo.bootstrap.Slider = function(config){
7697 Roo.bootstrap.Slider.superclass.constructor.call(this, config);
7700 Roo.extend(Roo.bootstrap.Slider, Roo.bootstrap.Component, {
7702 getAutoCreate : function(){
7706 cls: 'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',
7710 cls: 'ui-slider-handle ui-state-default ui-corner-all'
7722 * Ext JS Library 1.1.1
7723 * Copyright(c) 2006-2007, Ext JS, LLC.
7725 * Originally Released Under LGPL - original licence link has changed is not relivant.
7728 * <script type="text/javascript">
7731 * @extends Roo.dd.DDProxy
7732 * @class Roo.grid.SplitDragZone
7733 * Support for Column Header resizing
7735 * @param {Object} config
7738 // This is a support class used internally by the Grid components
7739 Roo.grid.SplitDragZone = function(grid, hd, hd2){
7741 this.view = grid.getView();
7742 this.proxy = this.view.resizeProxy;
7743 Roo.grid.SplitDragZone.superclass.constructor.call(
7746 "gridSplitters" + this.grid.getGridEl().id, // SGROUP
7748 dragElId : Roo.id(this.proxy.dom),
7753 this.setHandleElId(Roo.id(hd));
7754 if (hd2 !== false) {
7755 this.setOuterHandleElId(Roo.id(hd2));
7758 this.scroll = false;
7760 Roo.extend(Roo.grid.SplitDragZone, Roo.dd.DDProxy, {
7761 fly: Roo.Element.fly,
7763 b4StartDrag : function(x, y){
7764 this.view.headersDisabled = true;
7765 var h = this.view.mainWrap ? this.view.mainWrap.getHeight() : (
7766 this.view.headEl.getHeight() + this.view.bodyEl.getHeight()
7768 this.proxy.setHeight(h);
7770 // for old system colWidth really stored the actual width?
7771 // in bootstrap we tried using xs/ms/etc.. to do % sizing?
7772 // which in reality did not work.. - it worked only for fixed sizes
7773 // for resizable we need to use actual sizes.
7774 var w = this.cm.getColumnWidth(this.cellIndex);
7775 if (!this.view.mainWrap) {
7777 w = this.view.getHeaderIndex(this.cellIndex).getWidth();
7782 // this was w-this.grid.minColumnWidth;
7783 // doesnt really make sense? - w = thie curren width or the rendered one?
7784 var minw = Math.max(w-this.grid.minColumnWidth, 0);
7785 this.resetConstraints();
7786 this.setXConstraint(minw, 1000);
7787 this.setYConstraint(0, 0);
7788 this.minX = x - minw;
7789 this.maxX = x + 1000;
7791 if (!this.view.mainWrap) { // this is Bootstrap code..
7792 this.getDragEl().style.display='block';
7795 Roo.dd.DDProxy.prototype.b4StartDrag.call(this, x, y);
7799 handleMouseDown : function(e){
7800 ev = Roo.EventObject.setEvent(e);
7801 var t = this.fly(ev.getTarget());
7802 if(t.hasClass("x-grid-split")){
7803 this.cellIndex = this.view.getCellIndex(t.dom);
7805 this.cm = this.grid.colModel;
7806 if(this.cm.isResizable(this.cellIndex) && !this.cm.isFixed(this.cellIndex)){
7807 Roo.grid.SplitDragZone.superclass.handleMouseDown.apply(this, arguments);
7812 endDrag : function(e){
7813 this.view.headersDisabled = false;
7814 var endX = Math.max(this.minX, Roo.lib.Event.getPageX(e));
7815 var diff = endX - this.startPos;
7817 var w = this.cm.getColumnWidth(this.cellIndex);
7818 if (!this.view.mainWrap) {
7821 this.view.onColumnSplitterMoved(this.cellIndex, w+diff);
7824 autoOffset : function(){
7829 * Ext JS Library 1.1.1
7830 * Copyright(c) 2006-2007, Ext JS, LLC.
7832 * Originally Released Under LGPL - original licence link has changed is not relivant.
7835 * <script type="text/javascript">
7839 * @class Roo.grid.AbstractSelectionModel
7840 * @extends Roo.util.Observable
7842 * Abstract base class for grid SelectionModels. It provides the interface that should be
7843 * implemented by descendant classes. This class should not be directly instantiated.
7846 Roo.grid.AbstractSelectionModel = function(){
7847 this.locked = false;
7848 Roo.grid.AbstractSelectionModel.superclass.constructor.call(this);
7851 Roo.extend(Roo.grid.AbstractSelectionModel, Roo.util.Observable, {
7852 /** @ignore Called by the grid automatically. Do not call directly. */
7853 init : function(grid){
7859 * Locks the selections.
7866 * Unlocks the selections.
7868 unlock : function(){
7869 this.locked = false;
7873 * Returns true if the selections are locked.
7876 isLocked : function(){
7881 * Ext JS Library 1.1.1
7882 * Copyright(c) 2006-2007, Ext JS, LLC.
7884 * Originally Released Under LGPL - original licence link has changed is not relivant.
7887 * <script type="text/javascript">
7890 * @extends Roo.grid.AbstractSelectionModel
7891 * @class Roo.grid.RowSelectionModel
7892 * The default SelectionModel used by {@link Roo.grid.Grid}.
7893 * It supports multiple selections and keyboard selection/navigation.
7895 * @param {Object} config
7897 Roo.grid.RowSelectionModel = function(config){
7898 Roo.apply(this, config);
7899 this.selections = new Roo.util.MixedCollection(false, function(o){
7904 this.lastActive = false;
7908 * @event selectionchange
7909 * Fires when the selection changes
7910 * @param {SelectionModel} this
7912 "selectionchange" : true,
7914 * @event afterselectionchange
7915 * Fires after the selection changes (eg. by key press or clicking)
7916 * @param {SelectionModel} this
7918 "afterselectionchange" : true,
7920 * @event beforerowselect
7921 * Fires when a row is selected being selected, return false to cancel.
7922 * @param {SelectionModel} this
7923 * @param {Number} rowIndex The selected index
7924 * @param {Boolean} keepExisting False if other selections will be cleared
7926 "beforerowselect" : true,
7929 * Fires when a row is selected.
7930 * @param {SelectionModel} this
7931 * @param {Number} rowIndex The selected index
7932 * @param {Roo.data.Record} r The record
7936 * @event rowdeselect
7937 * Fires when a row is deselected.
7938 * @param {SelectionModel} this
7939 * @param {Number} rowIndex The selected index
7941 "rowdeselect" : true
7943 Roo.grid.RowSelectionModel.superclass.constructor.call(this);
7944 this.locked = false;
7947 Roo.extend(Roo.grid.RowSelectionModel, Roo.grid.AbstractSelectionModel, {
7949 * @cfg {Boolean} singleSelect
7950 * True to allow selection of only one row at a time (defaults to false)
7952 singleSelect : false,
7955 initEvents : function(){
7957 if(!this.grid.enableDragDrop && !this.grid.enableDrag){
7958 this.grid.on("mousedown", this.handleMouseDown, this);
7959 }else{ // allow click to work like normal
7960 this.grid.on("rowclick", this.handleDragableRowClick, this);
7962 // bootstrap does not have a view..
7963 var view = this.grid.view ? this.grid.view : this.grid;
7964 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
7967 this.selectPrevious(e.shiftKey);
7968 }else if(this.last !== false && this.lastActive !== false){
7969 var last = this.last;
7970 this.selectRange(this.last, this.lastActive-1);
7971 view.focusRow(this.lastActive);
7976 this.selectFirstRow();
7978 this.fireEvent("afterselectionchange", this);
7980 "down" : function(e){
7982 this.selectNext(e.shiftKey);
7983 }else if(this.last !== false && this.lastActive !== false){
7984 var last = this.last;
7985 this.selectRange(this.last, this.lastActive+1);
7986 view.focusRow(this.lastActive);
7991 this.selectFirstRow();
7993 this.fireEvent("afterselectionchange", this);
7999 view.on("refresh", this.onRefresh, this);
8000 view.on("rowupdated", this.onRowUpdated, this);
8001 view.on("rowremoved", this.onRemove, this);
8005 onRefresh : function(){
8006 var ds = this.grid.ds, i, v = this.grid.view;
8007 var s = this.selections;
8009 if((i = ds.indexOfId(r.id)) != -1){
8011 s.add(ds.getAt(i)); // updating the selection relate data
8019 onRemove : function(v, index, r){
8020 this.selections.remove(r);
8024 onRowUpdated : function(v, index, r){
8025 if(this.isSelected(r)){
8026 v.onRowSelect(index);
8032 * @param {Array} records The records to select
8033 * @param {Boolean} keepExisting (optional) True to keep existing selections
8035 selectRecords : function(records, keepExisting){
8037 this.clearSelections();
8039 var ds = this.grid.ds;
8040 for(var i = 0, len = records.length; i < len; i++){
8041 this.selectRow(ds.indexOf(records[i]), true);
8046 * Gets the number of selected rows.
8049 getCount : function(){
8050 return this.selections.length;
8054 * Selects the first row in the grid.
8056 selectFirstRow : function(){
8061 * Select the last row.
8062 * @param {Boolean} keepExisting (optional) True to keep existing selections
8064 selectLastRow : function(keepExisting){
8065 this.selectRow(this.grid.ds.getCount() - 1, keepExisting);
8069 * Selects the row immediately following the last selected row.
8070 * @param {Boolean} keepExisting (optional) True to keep existing selections
8072 selectNext : function(keepExisting){
8073 if(this.last !== false && (this.last+1) < this.grid.ds.getCount()){
8074 this.selectRow(this.last+1, keepExisting);
8075 var view = this.grid.view ? this.grid.view : this.grid;
8076 view.focusRow(this.last);
8081 * Selects the row that precedes the last selected row.
8082 * @param {Boolean} keepExisting (optional) True to keep existing selections
8084 selectPrevious : function(keepExisting){
8086 this.selectRow(this.last-1, keepExisting);
8087 var view = this.grid.view ? this.grid.view : this.grid;
8088 view.focusRow(this.last);
8093 * Returns the selected records
8094 * @return {Array} Array of selected records
8096 getSelections : function(){
8097 return [].concat(this.selections.items);
8101 * Returns the first selected record.
8104 getSelected : function(){
8105 return this.selections.itemAt(0);
8110 * Clears all selections.
8112 clearSelections : function(fast){
8117 var ds = this.grid.ds;
8118 var s = this.selections;
8120 this.deselectRow(ds.indexOfId(r.id));
8124 this.selections.clear();
8133 selectAll : function(){
8137 this.selections.clear();
8138 for(var i = 0, len = this.grid.ds.getCount(); i < len; i++){
8139 this.selectRow(i, true);
8144 * Returns True if there is a selection.
8147 hasSelection : function(){
8148 return this.selections.length > 0;
8152 * Returns True if the specified row is selected.
8153 * @param {Number/Record} record The record or index of the record to check
8156 isSelected : function(index){
8157 var r = typeof index == "number" ? this.grid.ds.getAt(index) : index;
8158 return (r && this.selections.key(r.id) ? true : false);
8162 * Returns True if the specified record id is selected.
8163 * @param {String} id The id of record to check
8166 isIdSelected : function(id){
8167 return (this.selections.key(id) ? true : false);
8171 handleMouseDown : function(e, t)
8173 var view = this.grid.view ? this.grid.view : this.grid;
8175 if(this.isLocked() || (rowIndex = view.findRowIndex(t)) === false){
8178 if(e.shiftKey && this.last !== false){
8179 var last = this.last;
8180 this.selectRange(last, rowIndex, e.ctrlKey);
8181 this.last = last; // reset the last
8182 view.focusRow(rowIndex);
8184 var isSelected = this.isSelected(rowIndex);
8185 if(e.button !== 0 && isSelected){
8186 view.focusRow(rowIndex);
8187 }else if(e.ctrlKey && isSelected){
8188 this.deselectRow(rowIndex);
8189 }else if(!isSelected){
8190 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
8191 view.focusRow(rowIndex);
8194 this.fireEvent("afterselectionchange", this);
8197 handleDragableRowClick : function(grid, rowIndex, e)
8199 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
8200 this.selectRow(rowIndex, false);
8201 var view = this.grid.view ? this.grid.view : this.grid;
8202 view.focusRow(rowIndex);
8203 this.fireEvent("afterselectionchange", this);
8208 * Selects multiple rows.
8209 * @param {Array} rows Array of the indexes of the row to select
8210 * @param {Boolean} keepExisting (optional) True to keep existing selections
8212 selectRows : function(rows, keepExisting){
8214 this.clearSelections();
8216 for(var i = 0, len = rows.length; i < len; i++){
8217 this.selectRow(rows[i], true);
8222 * Selects a range of rows. All rows in between startRow and endRow are also selected.
8223 * @param {Number} startRow The index of the first row in the range
8224 * @param {Number} endRow The index of the last row in the range
8225 * @param {Boolean} keepExisting (optional) True to retain existing selections
8227 selectRange : function(startRow, endRow, keepExisting){
8232 this.clearSelections();
8234 if(startRow <= endRow){
8235 for(var i = startRow; i <= endRow; i++){
8236 this.selectRow(i, true);
8239 for(var i = startRow; i >= endRow; i--){
8240 this.selectRow(i, true);
8246 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
8247 * @param {Number} startRow The index of the first row in the range
8248 * @param {Number} endRow The index of the last row in the range
8250 deselectRange : function(startRow, endRow, preventViewNotify){
8254 for(var i = startRow; i <= endRow; i++){
8255 this.deselectRow(i, preventViewNotify);
8261 * @param {Number} row The index of the row to select
8262 * @param {Boolean} keepExisting (optional) True to keep existing selections
8264 selectRow : function(index, keepExisting, preventViewNotify){
8265 if(this.locked || (index < 0 || index >= this.grid.ds.getCount())) {
8268 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
8269 if(!keepExisting || this.singleSelect){
8270 this.clearSelections();
8272 var r = this.grid.ds.getAt(index);
8273 this.selections.add(r);
8274 this.last = this.lastActive = index;
8275 if(!preventViewNotify){
8276 var view = this.grid.view ? this.grid.view : this.grid;
8277 view.onRowSelect(index);
8279 this.fireEvent("rowselect", this, index, r);
8280 this.fireEvent("selectionchange", this);
8286 * @param {Number} row The index of the row to deselect
8288 deselectRow : function(index, preventViewNotify){
8292 if(this.last == index){
8295 if(this.lastActive == index){
8296 this.lastActive = false;
8298 var r = this.grid.ds.getAt(index);
8299 this.selections.remove(r);
8300 if(!preventViewNotify){
8301 var view = this.grid.view ? this.grid.view : this.grid;
8302 view.onRowDeselect(index);
8304 this.fireEvent("rowdeselect", this, index);
8305 this.fireEvent("selectionchange", this);
8309 restoreLast : function(){
8311 this.last = this._last;
8316 acceptsNav : function(row, col, cm){
8317 return !cm.isHidden(col) && cm.isCellEditable(col, row);
8321 onEditorKey : function(field, e){
8322 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
8327 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
8329 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
8331 }else if(k == e.ENTER && !e.ctrlKey){
8335 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
8337 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
8339 }else if(k == e.ESC){
8343 g.startEditing(newCell[0], newCell[1]);
8348 * Ext JS Library 1.1.1
8349 * Copyright(c) 2006-2007, Ext JS, LLC.
8351 * Originally Released Under LGPL - original licence link has changed is not relivant.
8354 * <script type="text/javascript">
8359 * @class Roo.grid.ColumnModel
8360 * @extends Roo.util.Observable
8361 * This is the default implementation of a ColumnModel used by the Grid. It defines
8362 * the columns in the grid.
8365 var colModel = new Roo.grid.ColumnModel([
8366 {header: "Ticker", width: 60, sortable: true, locked: true},
8367 {header: "Company Name", width: 150, sortable: true},
8368 {header: "Market Cap.", width: 100, sortable: true},
8369 {header: "$ Sales", width: 100, sortable: true, renderer: money},
8370 {header: "Employees", width: 100, sortable: true, resizable: false}
8375 * The config options listed for this class are options which may appear in each
8376 * individual column definition.
8377 * <br/>RooJS Fix - column id's are not sequential but use Roo.id() - fixes bugs with layouts.
8379 * @param {Object} config An Array of column config objects. See this class's
8380 * config objects for details.
8382 Roo.grid.ColumnModel = function(config){
8384 * The config passed into the constructor
8386 this.config = []; //config;
8389 // if no id, create one
8390 // if the column does not have a dataIndex mapping,
8391 // map it to the order it is in the config
8392 for(var i = 0, len = config.length; i < len; i++){
8393 this.addColumn(config[i]);
8398 * The width of columns which have no width specified (defaults to 100)
8401 this.defaultWidth = 100;
8404 * Default sortable of columns which have no sortable specified (defaults to false)
8407 this.defaultSortable = false;
8411 * @event widthchange
8412 * Fires when the width of a column changes.
8413 * @param {ColumnModel} this
8414 * @param {Number} columnIndex The column index
8415 * @param {Number} newWidth The new width
8417 "widthchange": true,
8419 * @event headerchange
8420 * Fires when the text of a header changes.
8421 * @param {ColumnModel} this
8422 * @param {Number} columnIndex The column index
8423 * @param {Number} newText The new header text
8425 "headerchange": true,
8427 * @event hiddenchange
8428 * Fires when a column is hidden or "unhidden".
8429 * @param {ColumnModel} this
8430 * @param {Number} columnIndex The column index
8431 * @param {Boolean} hidden true if hidden, false otherwise
8433 "hiddenchange": true,
8435 * @event columnmoved
8436 * Fires when a column is moved.
8437 * @param {ColumnModel} this
8438 * @param {Number} oldIndex
8439 * @param {Number} newIndex
8441 "columnmoved" : true,
8443 * @event columlockchange
8444 * Fires when a column's locked state is changed
8445 * @param {ColumnModel} this
8446 * @param {Number} colIndex
8447 * @param {Boolean} locked true if locked
8449 "columnlockchange" : true
8451 Roo.grid.ColumnModel.superclass.constructor.call(this);
8453 Roo.extend(Roo.grid.ColumnModel, Roo.util.Observable, {
8455 * @cfg {String} header The header text to display in the Grid view.
8458 * @cfg {String} xsHeader Header at Bootsrap Extra Small width (default for all)
8461 * @cfg {String} smHeader Header at Bootsrap Small width
8464 * @cfg {String} mdHeader Header at Bootsrap Medium width
8467 * @cfg {String} lgHeader Header at Bootsrap Large width
8470 * @cfg {String} xlHeader Header at Bootsrap extra Large width
8473 * @cfg {String} dataIndex (Optional) The name of the field in the grid's {@link Roo.data.Store}'s
8474 * {@link Roo.data.Record} definition from which to draw the column's value. If not
8475 * specified, the column's index is used as an index into the Record's data Array.
8478 * @cfg {Number} width (Optional) The initial width in pixels of the column. Using this
8479 * instead of {@link Roo.grid.Grid#autoSizeColumns} is more efficient.
8482 * @cfg {Boolean} sortable (Optional) True if sorting is to be allowed on this column.
8483 * Defaults to the value of the {@link #defaultSortable} property.
8484 * Whether local/remote sorting is used is specified in {@link Roo.data.Store#remoteSort}.
8487 * @cfg {Boolean} locked (Optional) True to lock the column in place while scrolling the Grid. Defaults to false.
8490 * @cfg {Boolean} fixed (Optional) True if the column width cannot be changed. Defaults to false.
8493 * @cfg {Boolean} resizable (Optional) False to disable column resizing. Defaults to true.
8496 * @cfg {Boolean} hidden (Optional) True to hide the column. Defaults to false.
8499 * @cfg {Function} renderer (Optional) A function used to generate HTML markup for a cell
8500 * given the cell's data value. See {@link #setRenderer}. If not specified, the
8501 * default renderer returns the escaped data value. If an object is returned (bootstrap only)
8502 * then it is treated as a Roo Component object instance, and it is rendered after the initial row is rendered
8505 * @cfg {Roo.grid.GridEditor} editor (Optional) For grid editors - returns the grid editor
8508 * @cfg {String} align (Optional) Set the CSS text-align property of the column. Defaults to undefined.
8511 * @cfg {String} valign (Optional) Set the CSS vertical-align property of the column (eg. middle, top, bottom etc). Defaults to undefined.
8514 * @cfg {String} cursor (Optional)
8517 * @cfg {String} tooltip (Optional)
8520 * @cfg {Number} xs (Optional) can be '0' for hidden at this size (number less than 12)
8523 * @cfg {Number} sm (Optional) can be '0' for hidden at this size (number less than 12)
8526 * @cfg {Number} md (Optional) can be '0' for hidden at this size (number less than 12)
8529 * @cfg {Number} lg (Optional) can be '0' for hidden at this size (number less than 12)
8532 * @cfg {Number} xl (Optional) can be '0' for hidden at this size (number less than 12)
8535 * Returns the id of the column at the specified index.
8536 * @param {Number} index The column index
8537 * @return {String} the id
8539 getColumnId : function(index){
8540 return this.config[index].id;
8544 * Returns the column for a specified id.
8545 * @param {String} id The column id
8546 * @return {Object} the column
8548 getColumnById : function(id){
8549 return this.lookup[id];
8554 * Returns the column Object for a specified dataIndex.
8555 * @param {String} dataIndex The column dataIndex
8556 * @return {Object|Boolean} the column or false if not found
8558 getColumnByDataIndex: function(dataIndex){
8559 var index = this.findColumnIndex(dataIndex);
8560 return index > -1 ? this.config[index] : false;
8564 * Returns the index for a specified column id.
8565 * @param {String} id The column id
8566 * @return {Number} the index, or -1 if not found
8568 getIndexById : function(id){
8569 for(var i = 0, len = this.config.length; i < len; i++){
8570 if(this.config[i].id == id){
8578 * Returns the index for a specified column dataIndex.
8579 * @param {String} dataIndex The column dataIndex
8580 * @return {Number} the index, or -1 if not found
8583 findColumnIndex : function(dataIndex){
8584 for(var i = 0, len = this.config.length; i < len; i++){
8585 if(this.config[i].dataIndex == dataIndex){
8593 moveColumn : function(oldIndex, newIndex){
8594 var c = this.config[oldIndex];
8595 this.config.splice(oldIndex, 1);
8596 this.config.splice(newIndex, 0, c);
8597 this.dataMap = null;
8598 this.fireEvent("columnmoved", this, oldIndex, newIndex);
8601 isLocked : function(colIndex){
8602 return this.config[colIndex].locked === true;
8605 setLocked : function(colIndex, value, suppressEvent){
8606 if(this.isLocked(colIndex) == value){
8609 this.config[colIndex].locked = value;
8611 this.fireEvent("columnlockchange", this, colIndex, value);
8615 getTotalLockedWidth : function(){
8617 for(var i = 0; i < this.config.length; i++){
8618 if(this.isLocked(i) && !this.isHidden(i)){
8619 this.totalWidth += this.getColumnWidth(i);
8625 getLockedCount : function(){
8626 for(var i = 0, len = this.config.length; i < len; i++){
8627 if(!this.isLocked(i)){
8632 return this.config.length;
8636 * Returns the number of columns.
8639 getColumnCount : function(visibleOnly){
8640 if(visibleOnly === true){
8642 for(var i = 0, len = this.config.length; i < len; i++){
8643 if(!this.isHidden(i)){
8649 return this.config.length;
8653 * Returns the column configs that return true by the passed function that is called with (columnConfig, index)
8654 * @param {Function} fn
8655 * @param {Object} scope (optional)
8656 * @return {Array} result
8658 getColumnsBy : function(fn, scope){
8660 for(var i = 0, len = this.config.length; i < len; i++){
8661 var c = this.config[i];
8662 if(fn.call(scope||this, c, i) === true){
8670 * Returns true if the specified column is sortable.
8671 * @param {Number} col The column index
8674 isSortable : function(col){
8675 if(typeof this.config[col].sortable == "undefined"){
8676 return this.defaultSortable;
8678 return this.config[col].sortable;
8682 * Returns the rendering (formatting) function defined for the column.
8683 * @param {Number} col The column index.
8684 * @return {Function} The function used to render the cell. See {@link #setRenderer}.
8686 getRenderer : function(col){
8687 if(!this.config[col].renderer){
8688 return Roo.grid.ColumnModel.defaultRenderer;
8690 return this.config[col].renderer;
8694 * Sets the rendering (formatting) function for a column.
8695 * @param {Number} col The column index
8696 * @param {Function} fn The function to use to process the cell's raw data
8697 * to return HTML markup for the grid view. The render function is called with
8698 * the following parameters:<ul>
8699 * <li>Data value.</li>
8700 * <li>Cell metadata. An object in which you may set the following attributes:<ul>
8701 * <li>css A CSS style string to apply to the table cell.</li>
8702 * <li>attr An HTML attribute definition string to apply to the data container element <i>within</i> the table cell.</li></ul>
8703 * <li>The {@link Roo.data.Record} from which the data was extracted.</li>
8704 * <li>Row index</li>
8705 * <li>Column index</li>
8706 * <li>The {@link Roo.data.Store} object from which the Record was extracted</li></ul>
8708 setRenderer : function(col, fn){
8709 this.config[col].renderer = fn;
8713 * Returns the width for the specified column.
8714 * @param {Number} col The column index
8715 * @param (optional) {String} gridSize bootstrap width size.
8718 getColumnWidth : function(col, gridSize)
8720 var cfg = this.config[col];
8722 if (typeof(gridSize) == 'undefined') {
8723 return cfg.width * 1 || this.defaultWidth;
8725 if (gridSize === false) { // if we set it..
8726 return cfg.width || false;
8728 var sizes = ['xl', 'lg', 'md', 'sm', 'xs'];
8730 for(var i = sizes.indexOf(gridSize); i < sizes.length; i++) {
8731 if (typeof(cfg[ sizes[i] ] ) == 'undefined') {
8734 return cfg[ sizes[i] ];
8741 * Sets the width for a column.
8742 * @param {Number} col The column index
8743 * @param {Number} width The new width
8745 setColumnWidth : function(col, width, suppressEvent){
8746 this.config[col].width = width;
8747 this.totalWidth = null;
8749 this.fireEvent("widthchange", this, col, width);
8754 * Returns the total width of all columns.
8755 * @param {Boolean} includeHidden True to include hidden column widths
8758 getTotalWidth : function(includeHidden){
8759 if(!this.totalWidth){
8760 this.totalWidth = 0;
8761 for(var i = 0, len = this.config.length; i < len; i++){
8762 if(includeHidden || !this.isHidden(i)){
8763 this.totalWidth += this.getColumnWidth(i);
8767 return this.totalWidth;
8771 * Returns the header for the specified column.
8772 * @param {Number} col The column index
8775 getColumnHeader : function(col){
8776 return this.config[col].header;
8780 * Sets the header for a column.
8781 * @param {Number} col The column index
8782 * @param {String} header The new header
8784 setColumnHeader : function(col, header){
8785 this.config[col].header = header;
8786 this.fireEvent("headerchange", this, col, header);
8790 * Returns the tooltip for the specified column.
8791 * @param {Number} col The column index
8794 getColumnTooltip : function(col){
8795 return this.config[col].tooltip;
8798 * Sets the tooltip for a column.
8799 * @param {Number} col The column index
8800 * @param {String} tooltip The new tooltip
8802 setColumnTooltip : function(col, tooltip){
8803 this.config[col].tooltip = tooltip;
8807 * Returns the dataIndex for the specified column.
8808 * @param {Number} col The column index
8811 getDataIndex : function(col){
8812 return this.config[col].dataIndex;
8816 * Sets the dataIndex for a column.
8817 * @param {Number} col The column index
8818 * @param {Number} dataIndex The new dataIndex
8820 setDataIndex : function(col, dataIndex){
8821 this.config[col].dataIndex = dataIndex;
8827 * Returns true if the cell is editable.
8828 * @param {Number} colIndex The column index
8829 * @param {Number} rowIndex The row index - this is nto actually used..?
8832 isCellEditable : function(colIndex, rowIndex){
8833 return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
8837 * Returns the editor defined for the cell/column.
8838 * return false or null to disable editing.
8839 * @param {Number} colIndex The column index
8840 * @param {Number} rowIndex The row index
8843 getCellEditor : function(colIndex, rowIndex){
8844 return this.config[colIndex].editor;
8848 * Sets if a column is editable.
8849 * @param {Number} col The column index
8850 * @param {Boolean} editable True if the column is editable
8852 setEditable : function(col, editable){
8853 this.config[col].editable = editable;
8858 * Returns true if the column is hidden.
8859 * @param {Number} colIndex The column index
8862 isHidden : function(colIndex){
8863 return this.config[colIndex].hidden;
8868 * Returns true if the column width cannot be changed
8870 isFixed : function(colIndex){
8871 return this.config[colIndex].fixed;
8875 * Returns true if the column can be resized
8878 isResizable : function(colIndex){
8879 return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
8882 * Sets if a column is hidden.
8883 * @param {Number} colIndex The column index
8884 * @param {Boolean} hidden True if the column is hidden
8886 setHidden : function(colIndex, hidden){
8887 this.config[colIndex].hidden = hidden;
8888 this.totalWidth = null;
8889 this.fireEvent("hiddenchange", this, colIndex, hidden);
8893 * Sets the editor for a column.
8894 * @param {Number} col The column index
8895 * @param {Object} editor The editor object
8897 setEditor : function(col, editor){
8898 this.config[col].editor = editor;
8901 * Add a column (experimental...) - defaults to adding to the end..
8902 * @param {Object} config
8904 addColumn : function(c)
8907 var i = this.config.length;
8910 if(typeof c.dataIndex == "undefined"){
8913 if(typeof c.renderer == "string"){
8914 c.renderer = Roo.util.Format[c.renderer];
8916 if(typeof c.id == "undefined"){
8919 if(c.editor && c.editor.xtype){
8920 c.editor = Roo.factory(c.editor, Roo.grid);
8922 if(c.editor && c.editor.isFormField){
8923 c.editor = new Roo.grid.GridEditor(c.editor);
8925 this.lookup[c.id] = c;
8930 Roo.grid.ColumnModel.defaultRenderer = function(value)
8932 if(typeof value == "object") {
8935 if(typeof value == "string" && value.length < 1){
8939 return String.format("{0}", value);
8942 // Alias for backwards compatibility
8943 Roo.grid.DefaultColumnModel = Roo.grid.ColumnModel;
8946 * Ext JS Library 1.1.1
8947 * Copyright(c) 2006-2007, Ext JS, LLC.
8949 * Originally Released Under LGPL - original licence link has changed is not relivant.
8952 * <script type="text/javascript">
8956 * @class Roo.LoadMask
8957 * A simple utility class for generically masking elements while loading data. If the element being masked has
8958 * an underlying {@link Roo.data.Store}, the masking will be automatically synchronized with the store's loading
8959 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
8960 * element's UpdateManager load indicator and will be destroyed after the initial load.
8962 * Create a new LoadMask
8963 * @param {String/HTMLElement/Roo.Element} el The element or DOM node, or its id
8964 * @param {Object} config The config object
8966 Roo.LoadMask = function(el, config){
8967 this.el = Roo.get(el);
8968 Roo.apply(this, config);
8970 this.store.on('beforeload', this.onBeforeLoad, this);
8971 this.store.on('load', this.onLoad, this);
8972 this.store.on('loadexception', this.onLoadException, this);
8973 this.removeMask = false;
8975 var um = this.el.getUpdateManager();
8976 um.showLoadIndicator = false; // disable the default indicator
8977 um.on('beforeupdate', this.onBeforeLoad, this);
8978 um.on('update', this.onLoad, this);
8979 um.on('failure', this.onLoad, this);
8980 this.removeMask = true;
8984 Roo.LoadMask.prototype = {
8986 * @cfg {Boolean} removeMask
8987 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
8988 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
8993 * The text to display in a centered loading message box (defaults to 'Loading...')
8997 * @cfg {String} msgCls
8998 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
9000 msgCls : 'x-mask-loading',
9003 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
9009 * Disables the mask to prevent it from being displayed
9011 disable : function(){
9012 this.disabled = true;
9016 * Enables the mask so that it can be displayed
9018 enable : function(){
9019 this.disabled = false;
9022 onLoadException : function()
9026 if (typeof(arguments[3]) != 'undefined') {
9027 Roo.MessageBox.alert("Error loading",arguments[3]);
9031 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
9032 Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
9039 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
9044 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
9048 onBeforeLoad : function(){
9050 (function() { this.el.mask(this.msg, this.msgCls); }).defer(50, this);
9055 destroy : function(){
9057 this.store.un('beforeload', this.onBeforeLoad, this);
9058 this.store.un('load', this.onLoad, this);
9059 this.store.un('loadexception', this.onLoadException, this);
9061 var um = this.el.getUpdateManager();
9062 um.un('beforeupdate', this.onBeforeLoad, this);
9063 um.un('update', this.onLoad, this);
9064 um.un('failure', this.onLoad, this);
9068 * @class Roo.bootstrap.Table
9070 * @extends Roo.bootstrap.Component
9071 * @children Roo.bootstrap.TableBody
9072 * Bootstrap Table class. This class represents the primary interface of a component based grid control.
9073 * Similar to Roo.grid.Grid
9075 var table = Roo.factory({
9077 xns : Roo.bootstrap,
9078 autoSizeColumns: true,
9085 sortInfo : { direction : 'ASC', field: 'name' },
9087 xtype : 'HttpProxy',
9090 url : 'https://example.com/some.data.url.json'
9093 xtype : 'JsonReader',
9095 fields : [ 'id', 'name', whatever' ],
9102 xtype : 'ColumnModel',
9106 dataIndex : 'is_in_group',
9109 renderer : function(v, x , r) {
9111 return String.format("{0}", v)
9117 xtype : 'RowSelectionModel',
9118 xns : Roo.bootstrap.Table
9119 // you can add listeners to catch selection change here....
9125 grid.render(Roo.get("some-div"));
9128 Currently the Table uses multiple headers to try and handle XL / Medium etc... styling
9133 * @cfg {Roo.grid.AbstractSelectionModel} sm The selection model to use (cell selection is not supported yet)
9134 * @cfg {Roo.data.Store} store The data store to use
9135 * @cfg {Roo.grid.ColumnModel} cm[] A column for the grid.
9137 * @cfg {String} cls table class
9140 * @cfg {boolean} striped Should the rows be alternative striped
9141 * @cfg {boolean} bordered Add borders to the table
9142 * @cfg {boolean} hover Add hover highlighting
9143 * @cfg {boolean} condensed Format condensed
9144 * @cfg {boolean} responsive default false - if this is on, columns are rendered with col-xs-4 etc. classes, otherwise columns will be sized by CSS,
9145 * also adds table-responsive (see bootstrap docs for details)
9146 * @cfg {Boolean} loadMask (true|false) default false
9147 * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
9148 * @cfg {Boolean} headerShow (true|false) generate thead, default true
9149 * @cfg {Boolean} rowSelection (true|false) default false
9150 * @cfg {Boolean} cellSelection (true|false) default false
9151 * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header (with resizable columns)
9152 * @cfg {Roo.bootstrap.PagingToolbar} footer a paging toolbar
9153 * @cfg {Boolean} lazyLoad auto load data while scrolling to the end (default false)
9154 * @cfg {Boolean} auto_hide_footer auto hide footer if only one page (default false)
9155 * @cfg {Boolean} enableColumnResize default true if columns can be resized = needs scrollBody to be set to work (drag/drop)
9157 * @cfg {Number} minColumnWidth default 50 pixels minimum column width
9160 * Create a new Table
9161 * @param {Object} config The config object
9164 Roo.bootstrap.Table = function(config)
9166 Roo.bootstrap.Table.superclass.constructor.call(this, config);
9169 this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
9170 this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
9171 this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
9172 this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
9174 this.view = this; // compat with grid.
9176 this.sm = this.sm || {xtype: 'RowSelectionModel'};
9178 this.sm.grid = this;
9179 this.selModel = Roo.factory(this.sm, Roo.grid);
9180 this.sm = this.selModel;
9181 this.sm.xmodule = this.xmodule || false;
9184 if (this.cm && typeof(this.cm.config) == 'undefined') {
9185 this.colModel = new Roo.grid.ColumnModel(this.cm);
9186 this.cm = this.colModel;
9187 this.cm.xmodule = this.xmodule || false;
9190 this.store= Roo.factory(this.store, Roo.data);
9191 this.ds = this.store;
9192 this.ds.xmodule = this.xmodule || false;
9195 if (this.footer && this.store) {
9196 this.footer.dataSource = this.ds;
9197 this.footer = Roo.factory(this.footer);
9204 * Fires when a cell is clicked
9205 * @param {Roo.bootstrap.Table} this
9206 * @param {Roo.Element} el
9207 * @param {Number} rowIndex
9208 * @param {Number} columnIndex
9209 * @param {Roo.EventObject} e
9213 * @event celldblclick
9214 * Fires when a cell is double clicked
9215 * @param {Roo.bootstrap.Table} this
9216 * @param {Roo.Element} el
9217 * @param {Number} rowIndex
9218 * @param {Number} columnIndex
9219 * @param {Roo.EventObject} e
9221 "celldblclick" : true,
9224 * Fires when a row is clicked
9225 * @param {Roo.bootstrap.Table} this
9226 * @param {Roo.Element} el
9227 * @param {Number} rowIndex
9228 * @param {Roo.EventObject} e
9232 * @event rowdblclick
9233 * Fires when a row is double clicked
9234 * @param {Roo.bootstrap.Table} this
9235 * @param {Roo.Element} el
9236 * @param {Number} rowIndex
9237 * @param {Roo.EventObject} e
9239 "rowdblclick" : true,
9242 * Fires when a mouseover occur
9243 * @param {Roo.bootstrap.Table} this
9244 * @param {Roo.Element} el
9245 * @param {Number} rowIndex
9246 * @param {Number} columnIndex
9247 * @param {Roo.EventObject} e
9252 * Fires when a mouseout occur
9253 * @param {Roo.bootstrap.Table} this
9254 * @param {Roo.Element} el
9255 * @param {Number} rowIndex
9256 * @param {Number} columnIndex
9257 * @param {Roo.EventObject} e
9262 * Fires when a row is rendered, so you can change add a style to it.
9263 * @param {Roo.bootstrap.Table} this
9264 * @param {Object} rowcfg contains record rowIndex colIndex and rowClass - set rowClass to add a style.
9268 * @event rowsrendered
9269 * Fires when all the rows have been rendered
9270 * @param {Roo.bootstrap.Table} this
9272 'rowsrendered' : true,
9274 * @event contextmenu
9275 * The raw contextmenu event for the entire grid.
9276 * @param {Roo.EventObject} e
9278 "contextmenu" : true,
9280 * @event rowcontextmenu
9281 * Fires when a row is right clicked
9282 * @param {Roo.bootstrap.Table} this
9283 * @param {Number} rowIndex
9284 * @param {Roo.EventObject} e
9286 "rowcontextmenu" : true,
9288 * @event cellcontextmenu
9289 * Fires when a cell is right clicked
9290 * @param {Roo.bootstrap.Table} this
9291 * @param {Number} rowIndex
9292 * @param {Number} cellIndex
9293 * @param {Roo.EventObject} e
9295 "cellcontextmenu" : true,
9297 * @event headercontextmenu
9298 * Fires when a header is right clicked
9299 * @param {Roo.bootstrap.Table} this
9300 * @param {Number} columnIndex
9301 * @param {Roo.EventObject} e
9303 "headercontextmenu" : true,
9306 * The raw mousedown event for the entire grid.
9307 * @param {Roo.EventObject} e
9314 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
9330 enableColumnResize: true,
9332 rowSelection : false,
9333 cellSelection : false,
9336 minColumnWidth : 50,
9338 // Roo.Element - the tbody
9339 bodyEl: false, // <tbody> Roo.Element - thead element
9340 headEl: false, // <thead> Roo.Element - thead element
9341 resizeProxy : false, // proxy element for dragging?
9345 container: false, // used by gridpanel...
9351 auto_hide_footer : false,
9353 view: false, // actually points to this..
9355 getAutoCreate : function()
9357 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
9364 // this get's auto added by panel.Grid
9365 if (this.scrollBody) {
9366 cfg.cls += ' table-body-fixed';
9369 cfg.cls += ' table-striped';
9373 cfg.cls += ' table-hover';
9375 if (this.bordered) {
9376 cfg.cls += ' table-bordered';
9378 if (this.condensed) {
9379 cfg.cls += ' table-condensed';
9382 if (this.responsive) {
9383 cfg.cls += ' table-responsive';
9387 cfg.cls+= ' ' +this.cls;
9393 cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
9396 if(this.store || this.cm){
9397 if(this.headerShow){
9398 cfg.cn.push(this.renderHeader());
9401 cfg.cn.push(this.renderBody());
9403 if(this.footerShow){
9404 cfg.cn.push(this.renderFooter());
9406 // where does this come from?
9407 //cfg.cls+= ' TableGrid';
9410 return { cn : [ cfg ] };
9413 initEvents : function()
9415 if(!this.store || !this.cm){
9418 if (this.selModel) {
9419 this.selModel.initEvents();
9423 //Roo.log('initEvents with ds!!!!');
9425 this.bodyEl = this.el.select('tbody', true).first();
9426 this.headEl = this.el.select('thead', true).first();
9427 this.mainFoot = this.el.select('tfoot', true).first();
9432 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
9433 e.on('click', this.sort, this);
9437 // why is this done????? = it breaks dialogs??
9438 //this.parent().el.setStyle('position', 'relative');
9442 this.footer.parentId = this.id;
9443 this.footer.onRender(this.el.select('tfoot tr td').first(), null);
9446 this.el.select('tfoot tr td').first().addClass('hide');
9451 this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
9454 this.store.on('load', this.onLoad, this);
9455 this.store.on('beforeload', this.onBeforeLoad, this);
9456 this.store.on('update', this.onUpdate, this);
9457 this.store.on('add', this.onAdd, this);
9458 this.store.on("clear", this.clear, this);
9460 this.el.on("contextmenu", this.onContextMenu, this);
9463 this.cm.on("headerchange", this.onHeaderChange, this);
9464 this.cm.on("hiddenchange", this.onHiddenChange, this, arguments);
9466 //?? does bodyEl get replaced on render?
9467 this.bodyEl.on("click", this.onClick, this);
9468 this.bodyEl.on("dblclick", this.onDblClick, this);
9469 this.bodyEl.on('scroll', this.onBodyScroll, this);
9471 // guessing mainbody will work - this relays usually caught by selmodel at present.
9472 this.relayEvents(this.bodyEl, ["mousedown","mouseup","mouseover","mouseout","keypress"]);
9475 this.resizeProxy = Roo.get(document.body).createChild({ cls:"x-grid-resize-proxy", html: ' ' });
9478 if(this.headEl && this.enableColumnResize !== false && Roo.grid.SplitDragZone){
9479 new Roo.grid.SplitDragZone(this, this.headEl.dom, false); // not sure what 'lockedHd is for this implementation..)
9484 // Compatibility with grid - we implement all the view features at present.
9485 getView : function()
9490 initCSS : function()
9494 var cm = this.cm, styles = [];
9495 this.CSS.removeStyleSheet(this.id + '-cssrules');
9496 var headHeight = this.headEl ? this.headEl.dom.clientHeight : 0;
9497 // we can honour xs/sm/md/xl as widths...
9498 // we first have to decide what widht we are currently at...
9499 var sz = Roo.getGridSize();
9503 var cols = []; // visable cols.
9505 for(var i = 0, len = cm.getColumnCount(); i < len; i++) {
9506 var w = cm.getColumnWidth(i, false);
9508 cols.push( { rel : false, abs : 0 });
9512 cols.push( { rel : false, abs : w });
9514 last = i; // not really..
9517 var w = cm.getColumnWidth(i, sz);
9522 cols.push( { rel : w, abs : false });
9525 var avail = this.bodyEl.dom.clientWidth - total_abs;
9527 var unitWidth = Math.floor(avail / total);
9528 var rem = avail - (unitWidth * total);
9530 var hidden, width, pos = 0 , splithide , left;
9531 for(var i = 0, len = cm.getColumnCount(); i < len; i++) {
9533 hidden = 'display:none;';
9535 width = 'width:0px;';
9537 if(!cm.isHidden(i)){
9541 // we can honour xs/sm/md/xl ?
9542 var w = cols[i].rel == false ? cols[i].abs : (cols[i].rel * unitWidth);
9544 hidden = 'display:none;';
9546 // width should return a small number...
9548 w+=rem; // add the remaining with..
9551 left = "left:" + (pos -4) + "px;";
9552 width = "width:" + w+ "px;";
9555 if (this.responsive) {
9558 hidden = cm.isHidden(i) ? 'display:none;' : '';
9559 splithide = 'display: none;';
9562 styles.push( '#' , this.id , ' .x-col-' , i, " {", cm.config[i].css, width, hidden, "}\n" );
9565 splithide = 'display:none;';
9568 styles.push('#' , this.id , ' .x-hcol-' , i, " { ", width, hidden," }\n",
9569 '#' , this.id , ' .x-grid-split-' , i, " { ", left, splithide, 'height:', (headHeight - 4), "px;}\n",
9570 // this is the popover version..
9571 '.popover-inner #' , this.id , ' .x-grid-split-' , i, " { ", left, splithide, 'height:', 100, "%;}\n"
9576 //Roo.log(styles.join(''));
9577 this.CSS.createStyleSheet( styles.join(''), this.id + '-cssrules');
9583 onContextMenu : function(e, t)
9585 this.processEvent("contextmenu", e);
9588 processEvent : function(name, e)
9590 if (name != 'touchstart' ) {
9591 this.fireEvent(name, e);
9594 var t = e.getTarget();
9596 var cell = Roo.get(t);
9602 if(cell.findParent('tfoot', false, true)){
9606 if(cell.findParent('thead', false, true)){
9608 if(e.getTarget().nodeName.toLowerCase() != 'th'){
9609 cell = Roo.get(t).findParent('th', false, true);
9611 Roo.log("failed to find th in thead?");
9612 Roo.log(e.getTarget());
9617 var cellIndex = cell.dom.cellIndex;
9619 var ename = name == 'touchstart' ? 'click' : name;
9620 this.fireEvent("header" + ename, this, cellIndex, e);
9625 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9626 cell = Roo.get(t).findParent('td', false, true);
9628 Roo.log("failed to find th in tbody?");
9629 Roo.log(e.getTarget());
9634 var row = cell.findParent('tr', false, true);
9635 var cellIndex = cell.dom.cellIndex;
9636 var rowIndex = row.dom.rowIndex - 1;
9640 this.fireEvent("row" + name, this, rowIndex, e);
9644 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
9650 onMouseover : function(e, el)
9652 var cell = Roo.get(el);
9658 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9659 cell = cell.findParent('td', false, true);
9662 var row = cell.findParent('tr', false, true);
9663 var cellIndex = cell.dom.cellIndex;
9664 var rowIndex = row.dom.rowIndex - 1; // start from 0
9666 this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
9670 onMouseout : function(e, el)
9672 var cell = Roo.get(el);
9678 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9679 cell = cell.findParent('td', false, true);
9682 var row = cell.findParent('tr', false, true);
9683 var cellIndex = cell.dom.cellIndex;
9684 var rowIndex = row.dom.rowIndex - 1; // start from 0
9686 this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
9690 onClick : function(e, el)
9692 var cell = Roo.get(el);
9694 if(!cell || (!this.cellSelection && !this.rowSelection)){
9698 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9699 cell = cell.findParent('td', false, true);
9702 if(!cell || typeof(cell) == 'undefined'){
9706 var row = cell.findParent('tr', false, true);
9708 if(!row || typeof(row) == 'undefined'){
9712 var cellIndex = cell.dom.cellIndex;
9713 var rowIndex = this.getRowIndex(row);
9715 // why??? - should these not be based on SelectionModel?
9716 //if(this.cellSelection){
9717 this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
9720 //if(this.rowSelection){
9721 this.fireEvent('rowclick', this, row, rowIndex, e);
9726 onDblClick : function(e,el)
9728 var cell = Roo.get(el);
9730 if(!cell || (!this.cellSelection && !this.rowSelection)){
9734 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9735 cell = cell.findParent('td', false, true);
9738 if(!cell || typeof(cell) == 'undefined'){
9742 var row = cell.findParent('tr', false, true);
9744 if(!row || typeof(row) == 'undefined'){
9748 var cellIndex = cell.dom.cellIndex;
9749 var rowIndex = this.getRowIndex(row);
9751 if(this.cellSelection){
9752 this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
9755 if(this.rowSelection){
9756 this.fireEvent('rowdblclick', this, row, rowIndex, e);
9759 findRowIndex : function(el)
9761 var cell = Roo.get(el);
9765 var row = cell.findParent('tr', false, true);
9767 if(!row || typeof(row) == 'undefined'){
9770 return this.getRowIndex(row);
9772 sort : function(e,el)
9774 var col = Roo.get(el);
9776 if(!col.hasClass('sortable')){
9780 var sort = col.attr('sort');
9783 if(col.select('i', true).first().hasClass('fa-arrow-up')){
9787 this.store.sortInfo = {field : sort, direction : dir};
9790 Roo.log("calling footer first");
9791 this.footer.onClick('first');
9794 this.store.load({ params : { start : 0 } });
9798 renderHeader : function()
9806 this.totalWidth = 0;
9808 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
9810 var config = cm.config[i];
9814 cls : 'x-hcol-' + i,
9817 html: cm.getColumnHeader(i)
9820 var tooltip = cm.getColumnTooltip(i);
9822 c.tooltip = tooltip;
9828 if(typeof(config.sortable) != 'undefined' && config.sortable){
9829 c.cls += ' sortable';
9830 c.html = '<i class="fa"></i>' + c.html;
9833 // could use BS4 hidden-..-down
9835 if(typeof(config.lgHeader) != 'undefined'){
9836 hh += '<span class="hidden-xs hidden-sm hidden-md ">' + config.lgHeader + '</span>';
9839 if(typeof(config.mdHeader) != 'undefined'){
9840 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
9843 if(typeof(config.smHeader) != 'undefined'){
9844 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
9847 if(typeof(config.xsHeader) != 'undefined'){
9848 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
9855 if(typeof(config.tooltip) != 'undefined'){
9856 c.tooltip = config.tooltip;
9859 if(typeof(config.colspan) != 'undefined'){
9860 c.colspan = config.colspan;
9863 // hidden is handled by CSS now
9865 if(typeof(config.dataIndex) != 'undefined'){
9866 c.sort = config.dataIndex;
9871 if(typeof(config.align) != 'undefined' && config.align.length){
9872 c.style += ' text-align:' + config.align + ';';
9875 /* width is done in CSS
9876 *if(typeof(config.width) != 'undefined'){
9877 c.style += ' width:' + config.width + 'px;';
9878 this.totalWidth += config.width;
9880 this.totalWidth += 100; // assume minimum of 100 per column?
9884 if(typeof(config.cls) != 'undefined'){
9885 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
9887 // this is the bit that doesnt reall work at all...
9889 if (this.responsive) {
9892 ['xs','sm','md','lg'].map(function(size){
9894 if(typeof(config[size]) == 'undefined'){
9898 if (!config[size]) { // 0 = hidden
9899 // BS 4 '0' is treated as hide that column and below.
9900 c.cls += ' hidden-' + size + ' hidden' + size + '-down';
9904 c.cls += ' col-' + size + '-' + config[size] + (
9905 size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
9913 c.html +=' <span class="x-grid-split x-grid-split-' + i + '"></span>';
9924 renderBody : function()
9934 colspan : this.cm.getColumnCount()
9944 renderFooter : function()
9954 colspan : this.cm.getColumnCount()
9968 // Roo.log('ds onload');
9973 var ds = this.store;
9975 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
9976 e.select('i', true).removeClass(['fa-arrow-up', 'fa-arrow-down']);
9977 if (_this.store.sortInfo) {
9979 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
9980 e.select('i', true).addClass(['fa-arrow-up']);
9983 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
9984 e.select('i', true).addClass(['fa-arrow-down']);
9989 var tbody = this.bodyEl;
9991 if(ds.getCount() > 0){
9992 ds.data.each(function(d,rowIndex){
9993 var row = this.renderRow(cm, ds, rowIndex);
9995 tbody.createChild(row);
9999 if(row.cellObjects.length){
10000 Roo.each(row.cellObjects, function(r){
10001 _this.renderCellObject(r);
10008 var tfoot = this.el.select('tfoot', true).first();
10010 if(this.footerShow && this.auto_hide_footer && this.mainFoot){
10012 this.mainFoot.setVisibilityMode(Roo.Element.DISPLAY).hide();
10014 var total = this.ds.getTotalCount();
10016 if(this.footer.pageSize < total){
10017 this.mainFoot.show();
10021 Roo.each(this.el.select('tbody td', true).elements, function(e){
10022 e.on('mouseover', _this.onMouseover, _this);
10025 Roo.each(this.el.select('tbody td', true).elements, function(e){
10026 e.on('mouseout', _this.onMouseout, _this);
10028 this.fireEvent('rowsrendered', this);
10032 this.initCSS(); /// resize cols
10038 onUpdate : function(ds,record)
10040 this.refreshRow(record);
10044 onRemove : function(ds, record, index, isUpdate){
10045 if(isUpdate !== true){
10046 this.fireEvent("beforerowremoved", this, index, record);
10048 var bt = this.bodyEl.dom;
10050 var rows = this.el.select('tbody > tr', true).elements;
10052 if(typeof(rows[index]) != 'undefined'){
10053 bt.removeChild(rows[index].dom);
10056 // if(bt.rows[index]){
10057 // bt.removeChild(bt.rows[index]);
10060 if(isUpdate !== true){
10061 //this.stripeRows(index);
10062 //this.syncRowHeights(index, index);
10064 this.fireEvent("rowremoved", this, index, record);
10068 onAdd : function(ds, records, rowIndex)
10070 //Roo.log('on Add called');
10071 // - note this does not handle multiple adding very well..
10072 var bt = this.bodyEl.dom;
10073 for (var i =0 ; i < records.length;i++) {
10074 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
10075 //Roo.log(records[i]);
10076 //Roo.log(this.store.getAt(rowIndex+i));
10077 this.insertRow(this.store, rowIndex + i, false);
10084 refreshRow : function(record){
10085 var ds = this.store, index;
10086 if(typeof record == 'number'){
10088 record = ds.getAt(index);
10090 index = ds.indexOf(record);
10092 return; // should not happen - but seems to
10095 this.insertRow(ds, index, true);
10097 this.onRemove(ds, record, index+1, true);
10099 //this.syncRowHeights(index, index);
10101 this.fireEvent("rowupdated", this, index, record);
10103 // private - called by RowSelection
10104 onRowSelect : function(rowIndex){
10105 var row = this.getRowDom(rowIndex);
10106 row.addClass(['bg-info','info']);
10108 // private - called by RowSelection
10109 onRowDeselect : function(rowIndex)
10111 if (rowIndex < 0) {
10114 var row = this.getRowDom(rowIndex);
10115 row.removeClass(['bg-info','info']);
10118 * Focuses the specified row.
10119 * @param {Number} row The row index
10121 focusRow : function(row)
10123 //Roo.log('GridView.focusRow');
10124 var x = this.bodyEl.dom.scrollLeft;
10125 this.focusCell(row, 0, false);
10126 this.bodyEl.dom.scrollLeft = x;
10130 * Focuses the specified cell.
10131 * @param {Number} row The row index
10132 * @param {Number} col The column index
10133 * @param {Boolean} hscroll false to disable horizontal scrolling
10135 focusCell : function(row, col, hscroll)
10137 //Roo.log('GridView.focusCell');
10138 var el = this.ensureVisible(row, col, hscroll);
10139 // not sure what focusEL achives = it's a <a> pos relative
10140 //this.focusEl.alignTo(el, "tl-tl");
10142 // this.focusEl.focus();
10144 // this.focusEl.focus.defer(1, this.focusEl);
10149 * Scrolls the specified cell into view
10150 * @param {Number} row The row index
10151 * @param {Number} col The column index
10152 * @param {Boolean} hscroll false to disable horizontal scrolling
10154 ensureVisible : function(row, col, hscroll)
10156 //Roo.log('GridView.ensureVisible,' + row + ',' + col);
10157 //return null; //disable for testing.
10158 if(typeof row != "number"){
10159 row = row.rowIndex;
10161 if(row < 0 && row >= this.ds.getCount()){
10164 col = (col !== undefined ? col : 0);
10166 while(cm.isHidden(col)){
10170 var el = this.getCellDom(row, col);
10174 var c = this.bodyEl.dom;
10176 var ctop = parseInt(el.offsetTop, 10);
10177 var cleft = parseInt(el.offsetLeft, 10);
10178 var cbot = ctop + el.offsetHeight;
10179 var cright = cleft + el.offsetWidth;
10181 //var ch = c.clientHeight - this.mainHd.dom.offsetHeight;
10182 var ch = 0; //?? header is not withing the area?
10183 var stop = parseInt(c.scrollTop, 10);
10184 var sleft = parseInt(c.scrollLeft, 10);
10185 var sbot = stop + ch;
10186 var sright = sleft + c.clientWidth;
10188 Roo.log('GridView.ensureVisible:' +
10190 ' c.clientHeight:' + c.clientHeight +
10191 ' this.mainHd.dom.offsetHeight:' + this.mainHd.dom.offsetHeight +
10199 c.scrollTop = ctop;
10200 //Roo.log("set scrolltop to ctop DISABLE?");
10201 }else if(cbot > sbot){
10202 //Roo.log("set scrolltop to cbot-ch");
10203 c.scrollTop = cbot-ch;
10206 if(hscroll !== false){
10208 c.scrollLeft = cleft;
10209 }else if(cright > sright){
10210 c.scrollLeft = cright-c.clientWidth;
10218 insertRow : function(dm, rowIndex, isUpdate){
10221 this.fireEvent("beforerowsinserted", this, rowIndex);
10223 //var s = this.getScrollState();
10224 var row = this.renderRow(this.cm, this.store, rowIndex);
10225 // insert before rowIndex..
10226 var e = this.bodyEl.createChild(row,this.getRowDom(rowIndex));
10230 if(row.cellObjects.length){
10231 Roo.each(row.cellObjects, function(r){
10232 _this.renderCellObject(r);
10237 this.fireEvent("rowsinserted", this, rowIndex);
10238 //this.syncRowHeights(firstRow, lastRow);
10239 //this.stripeRows(firstRow);
10246 getRowDom : function(rowIndex)
10248 var rows = this.el.select('tbody > tr', true).elements;
10250 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
10253 getCellDom : function(rowIndex, colIndex)
10255 var row = this.getRowDom(rowIndex);
10256 if (row === false) {
10259 var cols = row.select('td', true).elements;
10260 return (typeof(cols[colIndex]) == 'undefined') ? false : cols[colIndex];
10264 // returns the object tree for a tr..
10267 renderRow : function(cm, ds, rowIndex)
10269 var d = ds.getAt(rowIndex);
10273 cls : 'x-row-' + rowIndex,
10277 var cellObjects = [];
10279 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
10280 var config = cm.config[i];
10282 var renderer = cm.getRenderer(i);
10286 if(typeof(renderer) !== 'undefined'){
10287 value = renderer(d.data[cm.getDataIndex(i)], false, d);
10289 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
10290 // and are rendered into the cells after the row is rendered - using the id for the element.
10292 if(typeof(value) === 'object'){
10302 rowIndex : rowIndex,
10307 this.fireEvent('rowclass', this, rowcfg);
10311 // this might end up displaying HTML?
10312 // this is too messy... - better to only do it on columsn you know are going to be too long
10313 //tooltip : (typeof(value) === 'object') ? '' : value,
10314 cls : rowcfg.rowClass + ' x-col-' + i,
10316 html: (typeof(value) === 'object') ? '' : value
10323 if(typeof(config.colspan) != 'undefined'){
10324 td.colspan = config.colspan;
10329 if(typeof(config.align) != 'undefined' && config.align.length){
10330 td.style += ' text-align:' + config.align + ';';
10332 if(typeof(config.valign) != 'undefined' && config.valign.length){
10333 td.style += ' vertical-align:' + config.valign + ';';
10336 if(typeof(config.width) != 'undefined'){
10337 td.style += ' width:' + config.width + 'px;';
10341 if(typeof(config.cursor) != 'undefined'){
10342 td.style += ' cursor:' + config.cursor + ';';
10345 if(typeof(config.cls) != 'undefined'){
10346 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
10348 if (this.responsive) {
10349 ['xs','sm','md','lg'].map(function(size){
10351 if(typeof(config[size]) == 'undefined'){
10357 if (!config[size]) { // 0 = hidden
10358 // BS 4 '0' is treated as hide that column and below.
10359 td.cls += ' hidden-' + size + ' hidden' + size + '-down';
10363 td.cls += ' col-' + size + '-' + config[size] + (
10364 size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
10374 row.cellObjects = cellObjects;
10382 onBeforeLoad : function()
10391 this.el.select('tbody', true).first().dom.innerHTML = '';
10394 * Show or hide a row.
10395 * @param {Number} rowIndex to show or hide
10396 * @param {Boolean} state hide
10398 setRowVisibility : function(rowIndex, state)
10400 var bt = this.bodyEl.dom;
10402 var rows = this.el.select('tbody > tr', true).elements;
10404 if(typeof(rows[rowIndex]) == 'undefined'){
10407 rows[rowIndex][ state ? 'removeClass' : 'addClass']('d-none');
10412 getSelectionModel : function(){
10413 if(!this.selModel){
10414 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
10416 return this.selModel;
10419 * Render the Roo.bootstrap object from renderder
10421 renderCellObject : function(r)
10425 r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
10427 var t = r.cfg.render(r.container);
10430 Roo.each(r.cfg.cn, function(c){
10432 container: t.getChildContainer(),
10435 _this.renderCellObject(child);
10440 * get the Row Index from a dom element.
10441 * @param {Roo.Element} row The row to look for
10442 * @returns {Number} the row
10444 getRowIndex : function(row)
10448 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
10459 * get the header TH element for columnIndex
10460 * @param {Number} columnIndex
10461 * @returns {Roo.Element}
10463 getHeaderIndex: function(colIndex)
10465 var cols = this.headEl.select('th', true).elements;
10466 return cols[colIndex];
10469 * get the Column Index from a dom element. (using regex on x-hcol-{colid})
10470 * @param {domElement} cell to look for
10471 * @returns {Number} the column
10473 getCellIndex : function(cell)
10475 var id = String(cell.className).match(Roo.bootstrap.Table.cellRE);
10477 return parseInt(id[1], 10);
10482 * Returns the grid's underlying element = used by panel.Grid
10483 * @return {Element} The element
10485 getGridEl : function(){
10489 * Forces a resize - used by panel.Grid
10490 * @return {Element} The element
10492 autoSize : function()
10494 //var ctr = Roo.get(this.container.dom.parentElement);
10495 var ctr = Roo.get(this.el.dom);
10497 var thd = this.getGridEl().select('thead',true).first();
10498 var tbd = this.getGridEl().select('tbody', true).first();
10499 var tfd = this.getGridEl().select('tfoot', true).first();
10501 var cw = ctr.getWidth();
10502 this.getGridEl().select('tfoot tr, tfoot td',true).setWidth(cw);
10506 tbd.setWidth(ctr.getWidth());
10507 // if the body has a max height - and then scrolls - we should perhaps set up the height here
10508 // this needs fixing for various usage - currently only hydra job advers I think..
10510 // ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
10512 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
10515 cw = Math.max(cw, this.totalWidth);
10516 this.getGridEl().select('tbody tr',true).setWidth(cw);
10519 // resize 'expandable coloumn?
10521 return; // we doe not have a view in this design..
10524 onBodyScroll: function()
10526 //Roo.log("body scrolled');" + this.bodyEl.dom.scrollLeft);
10528 this.headEl.setStyle({
10529 'position' : 'relative',
10530 'left': (-1* this.bodyEl.dom.scrollLeft) + 'px'
10536 var scrollHeight = this.bodyEl.dom.scrollHeight;
10538 var scrollTop = Math.ceil(this.bodyEl.getScroll().top);
10540 var height = this.bodyEl.getHeight();
10542 if(scrollHeight - height == scrollTop) {
10544 var total = this.ds.getTotalCount();
10546 if(this.footer.cursor + this.footer.pageSize < total){
10548 this.footer.ds.load({
10550 start : this.footer.cursor + this.footer.pageSize,
10551 limit : this.footer.pageSize
10560 onColumnSplitterMoved : function(i, diff)
10562 this.userResized = true;
10564 var cm = this.colModel;
10566 var w = this.getHeaderIndex(i).getWidth() + diff;
10569 cm.setColumnWidth(i, w, true);
10571 //var cid = cm.getColumnId(i); << not used in this version?
10572 /* Roo.log(['#' + this.id + ' .x-col-' + i, "width", w + "px"]);
10574 this.CSS.updateRule( '#' + this.id + ' .x-col-' + i, "width", w + "px");
10575 this.CSS.updateRule('#' + this.id + ' .x-hcol-' + i, "width", w + "px");
10576 this.CSS.updateRule('#' + this.id + ' .x-grid-split-' + i, "left", w + "px");
10578 //this.updateSplitters();
10579 //this.layout(); << ??
10580 this.fireEvent("columnresize", i, w);
10582 onHeaderChange : function()
10584 var header = this.renderHeader();
10585 var table = this.el.select('table', true).first();
10587 this.headEl.remove();
10588 this.headEl = table.createChild(header, this.bodyEl, false);
10590 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
10591 e.on('click', this.sort, this);
10594 if(this.enableColumnResize !== false && Roo.grid.SplitDragZone){
10595 new Roo.grid.SplitDragZone(this, this.headEl.dom, false); // not sure what 'lockedHd is for this implementation..)
10600 onHiddenChange : function(colModel, colIndex, hidden)
10603 this.cm.setHidden()
10604 var thSelector = '#' + this.id + ' .x-hcol-' + colIndex;
10605 var tdSelector = '#' + this.id + ' .x-col-' + colIndex;
10607 this.CSS.updateRule(thSelector, "display", "");
10608 this.CSS.updateRule(tdSelector, "display", "");
10611 this.CSS.updateRule(thSelector, "display", "none");
10612 this.CSS.updateRule(tdSelector, "display", "none");
10615 // onload calls initCSS()
10616 this.onHeaderChange();
10620 setColumnWidth: function(col_index, width)
10622 // width = "md-2 xs-2..."
10623 if(!this.colModel.config[col_index]) {
10627 var w = width.split(" ");
10629 var rows = this.el.dom.getElementsByClassName("x-col-"+col_index);
10631 var h_row = this.el.dom.getElementsByClassName("x-hcol-"+col_index);
10634 for(var j = 0; j < w.length; j++) {
10640 var size_cls = w[j].split("-");
10642 if(!Number.isInteger(size_cls[1] * 1)) {
10646 if(!this.colModel.config[col_index][size_cls[0]]) {
10650 if(!h_row[0].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
10654 h_row[0].classList.replace(
10655 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
10656 "col-"+size_cls[0]+"-"+size_cls[1]
10659 for(var i = 0; i < rows.length; i++) {
10661 var size_cls = w[j].split("-");
10663 if(!Number.isInteger(size_cls[1] * 1)) {
10667 if(!this.colModel.config[col_index][size_cls[0]]) {
10671 if(!rows[i].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
10675 rows[i].classList.replace(
10676 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
10677 "col-"+size_cls[0]+"-"+size_cls[1]
10681 this.colModel.config[col_index][size_cls[0]] = size_cls[1];
10686 // currently only used to find the split on drag..
10687 Roo.bootstrap.Table.cellRE = /(?:.*?)x-grid-(?:hd|cell|split)-([\d]+)(?:.*?)/;
10692 Roo.bootstrap.Table.AbstractSelectionModel = Roo.grid.AbstractSelectionModel;
10693 Roo.bootstrap.Table.RowSelectionModel = Roo.grid.RowSelectionModel;
10702 * @class Roo.bootstrap.TableCell
10703 * @extends Roo.bootstrap.Component
10704 * @children Roo.bootstrap.Component
10705 * @parent Roo.bootstrap.TableRow
10706 * Bootstrap TableCell class
10708 * @cfg {String} html cell contain text
10709 * @cfg {String} cls cell class
10710 * @cfg {String} tag cell tag (td|th) default td
10711 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
10712 * @cfg {String} align Aligns the content in a cell
10713 * @cfg {String} axis Categorizes cells
10714 * @cfg {String} bgcolor Specifies the background color of a cell
10715 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
10716 * @cfg {Number} colspan Specifies the number of columns a cell should span
10717 * @cfg {String} headers Specifies one or more header cells a cell is related to
10718 * @cfg {Number} height Sets the height of a cell
10719 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
10720 * @cfg {Number} rowspan Sets the number of rows a cell should span
10721 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
10722 * @cfg {String} valign Vertical aligns the content in a cell
10723 * @cfg {Number} width Specifies the width of a cell
10726 * Create a new TableCell
10727 * @param {Object} config The config object
10730 Roo.bootstrap.TableCell = function(config){
10731 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
10734 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
10754 getAutoCreate : function(){
10755 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
10762 cfg.tag = this.tag;
10775 cfg.align=this.align
10780 if (this.bgcolor) {
10781 cfg.bgcolor=this.bgcolor
10783 if (this.charoff) {
10784 cfg.charoff=this.charoff
10786 if (this.colspan) {
10787 cfg.colspan=this.colspan
10789 if (this.headers) {
10790 cfg.headers=this.headers
10793 cfg.height=this.height
10796 cfg.nowrap=this.nowrap
10798 if (this.rowspan) {
10799 cfg.rowspan=this.rowspan
10802 cfg.scope=this.scope
10805 cfg.valign=this.valign
10808 cfg.width=this.width
10827 * @class Roo.bootstrap.TableRow
10828 * @extends Roo.bootstrap.Component
10829 * @children Roo.bootstrap.TableCell
10830 * @parent Roo.bootstrap.TableBody
10831 * Bootstrap TableRow class
10832 * @cfg {String} cls row class
10833 * @cfg {String} align Aligns the content in a table row
10834 * @cfg {String} bgcolor Specifies a background color for a table row
10835 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
10836 * @cfg {String} valign Vertical aligns the content in a table row
10839 * Create a new TableRow
10840 * @param {Object} config The config object
10843 Roo.bootstrap.TableRow = function(config){
10844 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
10847 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
10855 getAutoCreate : function(){
10856 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
10863 cfg.cls = this.cls;
10866 cfg.align = this.align;
10869 cfg.bgcolor = this.bgcolor;
10872 cfg.charoff = this.charoff;
10875 cfg.valign = this.valign;
10893 * @class Roo.bootstrap.TableBody
10894 * @extends Roo.bootstrap.Component
10895 * @children Roo.bootstrap.TableRow
10896 * @parent Roo.bootstrap.Table
10897 * Bootstrap TableBody class
10898 * @cfg {String} cls element class
10899 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
10900 * @cfg {String} align Aligns the content inside the element
10901 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
10902 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
10905 * Create a new TableBody
10906 * @param {Object} config The config object
10909 Roo.bootstrap.TableBody = function(config){
10910 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
10913 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
10921 getAutoCreate : function(){
10922 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
10932 cfg.tag = this.tag;
10936 cfg.align = this.align;
10939 cfg.charoff = this.charoff;
10942 cfg.valign = this.valign;
10949 // initEvents : function()
10952 // if(!this.store){
10956 // this.store = Roo.factory(this.store, Roo.data);
10957 // this.store.on('load', this.onLoad, this);
10959 // this.store.load();
10963 // onLoad: function ()
10965 // this.fireEvent('load', this);
10975 * Ext JS Library 1.1.1
10976 * Copyright(c) 2006-2007, Ext JS, LLC.
10978 * Originally Released Under LGPL - original licence link has changed is not relivant.
10981 * <script type="text/javascript">
10984 // as we use this in bootstrap.
10985 Roo.namespace('Roo.form');
10987 * @class Roo.form.Action
10988 * Internal Class used to handle form actions
10990 * @param {Roo.form.BasicForm} el The form element or its id
10991 * @param {Object} config Configuration options
10996 // define the action interface
10997 Roo.form.Action = function(form, options){
10999 this.options = options || {};
11002 * Client Validation Failed
11005 Roo.form.Action.CLIENT_INVALID = 'client';
11007 * Server Validation Failed
11010 Roo.form.Action.SERVER_INVALID = 'server';
11012 * Connect to Server Failed
11015 Roo.form.Action.CONNECT_FAILURE = 'connect';
11017 * Reading Data from Server Failed
11020 Roo.form.Action.LOAD_FAILURE = 'load';
11022 Roo.form.Action.prototype = {
11024 failureType : undefined,
11025 response : undefined,
11026 result : undefined,
11028 // interface method
11029 run : function(options){
11033 // interface method
11034 success : function(response){
11038 // interface method
11039 handleResponse : function(response){
11043 // default connection failure
11044 failure : function(response){
11046 this.response = response;
11047 this.failureType = Roo.form.Action.CONNECT_FAILURE;
11048 this.form.afterAction(this, false);
11051 processResponse : function(response){
11052 this.response = response;
11053 if(!response.responseText){
11056 this.result = this.handleResponse(response);
11057 return this.result;
11060 // utility functions used internally
11061 getUrl : function(appendParams){
11062 var url = this.options.url || this.form.url || this.form.el.dom.action;
11064 var p = this.getParams();
11066 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
11072 getMethod : function(){
11073 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
11076 getParams : function(){
11077 var bp = this.form.baseParams;
11078 var p = this.options.params;
11080 if(typeof p == "object"){
11081 p = Roo.urlEncode(Roo.applyIf(p, bp));
11082 }else if(typeof p == 'string' && bp){
11083 p += '&' + Roo.urlEncode(bp);
11086 p = Roo.urlEncode(bp);
11091 createCallback : function(){
11093 success: this.success,
11094 failure: this.failure,
11096 timeout: (this.form.timeout*1000),
11097 upload: this.form.fileUpload ? this.success : undefined
11102 Roo.form.Action.Submit = function(form, options){
11103 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
11106 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
11109 haveProgress : false,
11110 uploadComplete : false,
11112 // uploadProgress indicator.
11113 uploadProgress : function()
11115 if (!this.form.progressUrl) {
11119 if (!this.haveProgress) {
11120 Roo.MessageBox.progress("Uploading", "Uploading");
11122 if (this.uploadComplete) {
11123 Roo.MessageBox.hide();
11127 this.haveProgress = true;
11129 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
11131 var c = new Roo.data.Connection();
11133 url : this.form.progressUrl,
11138 success : function(req){
11139 //console.log(data);
11143 rdata = Roo.decode(req.responseText)
11145 Roo.log("Invalid data from server..");
11149 if (!rdata || !rdata.success) {
11151 Roo.MessageBox.alert(Roo.encode(rdata));
11154 var data = rdata.data;
11156 if (this.uploadComplete) {
11157 Roo.MessageBox.hide();
11162 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
11163 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
11166 this.uploadProgress.defer(2000,this);
11169 failure: function(data) {
11170 Roo.log('progress url failed ');
11181 // run get Values on the form, so it syncs any secondary forms.
11182 this.form.getValues();
11184 var o = this.options;
11185 var method = this.getMethod();
11186 var isPost = method == 'POST';
11187 if(o.clientValidation === false || this.form.isValid()){
11189 if (this.form.progressUrl) {
11190 this.form.findField('UPLOAD_IDENTIFIER').setValue(
11191 (new Date() * 1) + '' + Math.random());
11196 Roo.Ajax.request(Roo.apply(this.createCallback(), {
11197 form:this.form.el.dom,
11198 url:this.getUrl(!isPost),
11200 params:isPost ? this.getParams() : null,
11201 isUpload: this.form.fileUpload,
11202 formData : this.form.formData
11205 this.uploadProgress();
11207 }else if (o.clientValidation !== false){ // client validation failed
11208 this.failureType = Roo.form.Action.CLIENT_INVALID;
11209 this.form.afterAction(this, false);
11213 success : function(response)
11215 this.uploadComplete= true;
11216 if (this.haveProgress) {
11217 Roo.MessageBox.hide();
11221 var result = this.processResponse(response);
11222 if(result === true || result.success){
11223 this.form.afterAction(this, true);
11227 this.form.markInvalid(result.errors);
11228 this.failureType = Roo.form.Action.SERVER_INVALID;
11230 this.form.afterAction(this, false);
11232 failure : function(response)
11234 this.uploadComplete= true;
11235 if (this.haveProgress) {
11236 Roo.MessageBox.hide();
11239 this.response = response;
11240 this.failureType = Roo.form.Action.CONNECT_FAILURE;
11241 this.form.afterAction(this, false);
11244 handleResponse : function(response){
11245 if(this.form.errorReader){
11246 var rs = this.form.errorReader.read(response);
11249 for(var i = 0, len = rs.records.length; i < len; i++) {
11250 var r = rs.records[i];
11251 errors[i] = r.data;
11254 if(errors.length < 1){
11258 success : rs.success,
11264 ret = Roo.decode(response.responseText);
11268 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
11278 Roo.form.Action.Load = function(form, options){
11279 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
11280 this.reader = this.form.reader;
11283 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
11288 Roo.Ajax.request(Roo.apply(
11289 this.createCallback(), {
11290 method:this.getMethod(),
11291 url:this.getUrl(false),
11292 params:this.getParams()
11296 success : function(response){
11298 var result = this.processResponse(response);
11299 if(result === true || !result.success || !result.data){
11300 this.failureType = Roo.form.Action.LOAD_FAILURE;
11301 this.form.afterAction(this, false);
11304 this.form.clearInvalid();
11305 this.form.setValues(result.data);
11306 this.form.afterAction(this, true);
11309 handleResponse : function(response){
11310 if(this.form.reader){
11311 var rs = this.form.reader.read(response);
11312 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
11314 success : rs.success,
11318 return Roo.decode(response.responseText);
11322 Roo.form.Action.ACTION_TYPES = {
11323 'load' : Roo.form.Action.Load,
11324 'submit' : Roo.form.Action.Submit
11333 * @class Roo.bootstrap.form.Form
11334 * @extends Roo.bootstrap.Component
11335 * @children Roo.bootstrap.Component
11336 * Bootstrap Form class
11337 * @cfg {String} method GET | POST (default POST)
11338 * @cfg {String} labelAlign top | left (default top)
11339 * @cfg {String} align left | right - for navbars
11340 * @cfg {Boolean} loadMask load mask when submit (default true)
11344 * Create a new Form
11345 * @param {Object} config The config object
11349 Roo.bootstrap.form.Form = function(config){
11351 Roo.bootstrap.form.Form.superclass.constructor.call(this, config);
11353 Roo.bootstrap.form.Form.popover.apply();
11357 * @event clientvalidation
11358 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
11359 * @param {Form} this
11360 * @param {Boolean} valid true if the form has passed client-side validation
11362 clientvalidation: true,
11364 * @event beforeaction
11365 * Fires before any action is performed. Return false to cancel the action.
11366 * @param {Form} this
11367 * @param {Action} action The action to be performed
11369 beforeaction: true,
11371 * @event actionfailed
11372 * Fires when an action fails.
11373 * @param {Form} this
11374 * @param {Action} action The action that failed
11376 actionfailed : true,
11378 * @event actioncomplete
11379 * Fires when an action is completed.
11380 * @param {Form} this
11381 * @param {Action} action The action that completed
11383 actioncomplete : true
11387 Roo.extend(Roo.bootstrap.form.Form, Roo.bootstrap.Component, {
11390 * @cfg {String} method
11391 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
11395 * @cfg {String} url
11396 * The URL to use for form actions if one isn't supplied in the action options.
11399 * @cfg {Boolean} fileUpload
11400 * Set to true if this form is a file upload.
11404 * @cfg {Object} baseParams
11405 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
11409 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
11413 * @cfg {Sting} align (left|right) for navbar forms
11418 activeAction : null,
11421 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
11422 * element by passing it or its id or mask the form itself by passing in true.
11425 waitMsgTarget : false,
11430 * @cfg {Boolean} errorMask (true|false) default false
11435 * @cfg {Number} maskOffset Default 100
11440 * @cfg {Boolean} maskBody
11444 getAutoCreate : function(){
11448 method : this.method || 'POST',
11449 id : this.id || Roo.id(),
11452 if (this.parent().xtype.match(/^Nav/)) {
11453 cfg.cls = 'navbar-form form-inline navbar-' + this.align;
11457 if (this.labelAlign == 'left' ) {
11458 cfg.cls += ' form-horizontal';
11464 initEvents : function()
11466 this.el.on('submit', this.onSubmit, this);
11467 // this was added as random key presses on the form where triggering form submit.
11468 this.el.on('keypress', function(e) {
11469 if (e.getCharCode() != 13) {
11472 // we might need to allow it for textareas.. and some other items.
11473 // check e.getTarget().
11475 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
11479 Roo.log("keypress blocked");
11481 e.preventDefault();
11487 onSubmit : function(e){
11492 * Returns true if client-side validation on the form is successful.
11495 isValid : function(){
11496 var items = this.getItems();
11498 var target = false;
11500 items.each(function(f){
11506 Roo.log('invalid field: ' + f.name);
11510 if(!target && f.el.isVisible(true)){
11516 if(this.errorMask && !valid){
11517 Roo.bootstrap.form.Form.popover.mask(this, target);
11524 * Returns true if any fields in this form have changed since their original load.
11527 isDirty : function(){
11529 var items = this.getItems();
11530 items.each(function(f){
11540 * Performs a predefined action (submit or load) or custom actions you define on this form.
11541 * @param {String} actionName The name of the action type
11542 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
11543 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
11544 * accept other config options):
11546 Property Type Description
11547 ---------------- --------------- ----------------------------------------------------------------------------------
11548 url String The url for the action (defaults to the form's url)
11549 method String The form method to use (defaults to the form's method, or POST if not defined)
11550 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
11551 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
11552 validate the form on the client (defaults to false)
11554 * @return {BasicForm} this
11556 doAction : function(action, options){
11557 if(typeof action == 'string'){
11558 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
11560 if(this.fireEvent('beforeaction', this, action) !== false){
11561 this.beforeAction(action);
11562 action.run.defer(100, action);
11568 beforeAction : function(action){
11569 var o = action.options;
11574 Roo.get(document.body).mask(o.waitMsg || "Sending", 'x-mask-loading')
11576 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
11579 // not really supported yet.. ??
11581 //if(this.waitMsgTarget === true){
11582 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
11583 //}else if(this.waitMsgTarget){
11584 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
11585 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
11587 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
11593 afterAction : function(action, success){
11594 this.activeAction = null;
11595 var o = action.options;
11600 Roo.get(document.body).unmask();
11606 //if(this.waitMsgTarget === true){
11607 // this.el.unmask();
11608 //}else if(this.waitMsgTarget){
11609 // this.waitMsgTarget.unmask();
11611 // Roo.MessageBox.updateProgress(1);
11612 // Roo.MessageBox.hide();
11619 Roo.callback(o.success, o.scope, [this, action]);
11620 this.fireEvent('actioncomplete', this, action);
11624 // failure condition..
11625 // we have a scenario where updates need confirming.
11626 // eg. if a locking scenario exists..
11627 // we look for { errors : { needs_confirm : true }} in the response.
11629 (typeof(action.result) != 'undefined') &&
11630 (typeof(action.result.errors) != 'undefined') &&
11631 (typeof(action.result.errors.needs_confirm) != 'undefined')
11634 Roo.log("not supported yet");
11637 Roo.MessageBox.confirm(
11638 "Change requires confirmation",
11639 action.result.errorMsg,
11644 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
11654 Roo.callback(o.failure, o.scope, [this, action]);
11655 // show an error message if no failed handler is set..
11656 if (!this.hasListener('actionfailed')) {
11657 Roo.log("need to add dialog support");
11659 Roo.MessageBox.alert("Error",
11660 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
11661 action.result.errorMsg :
11662 "Saving Failed, please check your entries or try again"
11667 this.fireEvent('actionfailed', this, action);
11672 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
11673 * @param {String} id The value to search for
11676 findField : function(id){
11677 var items = this.getItems();
11678 var field = items.get(id);
11680 items.each(function(f){
11681 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
11688 return field || null;
11691 * Mark fields in this form invalid in bulk.
11692 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
11693 * @return {BasicForm} this
11695 markInvalid : function(errors){
11696 if(errors instanceof Array){
11697 for(var i = 0, len = errors.length; i < len; i++){
11698 var fieldError = errors[i];
11699 var f = this.findField(fieldError.id);
11701 f.markInvalid(fieldError.msg);
11707 if(typeof errors[id] != 'function' && (field = this.findField(id))){
11708 field.markInvalid(errors[id]);
11712 //Roo.each(this.childForms || [], function (f) {
11713 // f.markInvalid(errors);
11720 * Set values for fields in this form in bulk.
11721 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
11722 * @return {BasicForm} this
11724 setValues : function(values){
11725 if(values instanceof Array){ // array of objects
11726 for(var i = 0, len = values.length; i < len; i++){
11728 var f = this.findField(v.id);
11730 f.setValue(v.value);
11731 if(this.trackResetOnLoad){
11732 f.originalValue = f.getValue();
11736 }else{ // object hash
11739 if(typeof values[id] != 'function' && (field = this.findField(id))){
11741 if (field.setFromData &&
11742 field.valueField &&
11743 field.displayField &&
11744 // combos' with local stores can
11745 // be queried via setValue()
11746 // to set their value..
11747 (field.store && !field.store.isLocal)
11751 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
11752 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
11753 field.setFromData(sd);
11755 } else if(field.setFromData && (field.store && !field.store.isLocal)) {
11757 field.setFromData(values);
11760 field.setValue(values[id]);
11764 if(this.trackResetOnLoad){
11765 field.originalValue = field.getValue();
11771 //Roo.each(this.childForms || [], function (f) {
11772 // f.setValues(values);
11779 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
11780 * they are returned as an array.
11781 * @param {Boolean} asString
11784 getValues : function(asString){
11785 //if (this.childForms) {
11786 // copy values from the child forms
11787 // Roo.each(this.childForms, function (f) {
11788 // this.setValues(f.getValues());
11794 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
11795 if(asString === true){
11798 return Roo.urlDecode(fs);
11802 * Returns the fields in this form as an object with key/value pairs.
11803 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
11806 getFieldValues : function(with_hidden)
11808 var items = this.getItems();
11810 items.each(function(f){
11812 if (!f.getName()) {
11816 var v = f.getValue();
11818 if (f.inputType =='radio') {
11819 if (typeof(ret[f.getName()]) == 'undefined') {
11820 ret[f.getName()] = ''; // empty..
11823 if (!f.el.dom.checked) {
11827 v = f.el.dom.value;
11831 if(f.xtype == 'MoneyField'){
11832 ret[f.currencyName] = f.getCurrency();
11835 // not sure if this supported any more..
11836 if ((typeof(v) == 'object') && f.getRawValue) {
11837 v = f.getRawValue() ; // dates..
11839 // combo boxes where name != hiddenName...
11840 if (f.name !== false && f.name != '' && f.name != f.getName()) {
11841 ret[f.name] = f.getRawValue();
11843 ret[f.getName()] = v;
11850 * Clears all invalid messages in this form.
11851 * @return {BasicForm} this
11853 clearInvalid : function(){
11854 var items = this.getItems();
11856 items.each(function(f){
11864 * Resets this form.
11865 * @return {BasicForm} this
11867 reset : function(){
11868 var items = this.getItems();
11869 items.each(function(f){
11873 Roo.each(this.childForms || [], function (f) {
11881 getItems : function()
11883 var r=new Roo.util.MixedCollection(false, function(o){
11884 return o.id || (o.id = Roo.id());
11886 var iter = function(el) {
11893 Roo.each(el.items,function(e) {
11902 hideFields : function(items)
11904 Roo.each(items, function(i){
11906 var f = this.findField(i);
11917 showFields : function(items)
11919 Roo.each(items, function(i){
11921 var f = this.findField(i);
11934 Roo.apply(Roo.bootstrap.form.Form, {
11950 intervalID : false,
11956 if(this.isApplied){
11961 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
11962 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
11963 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
11964 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
11967 this.maskEl.top.enableDisplayMode("block");
11968 this.maskEl.left.enableDisplayMode("block");
11969 this.maskEl.bottom.enableDisplayMode("block");
11970 this.maskEl.right.enableDisplayMode("block");
11972 this.toolTip = new Roo.bootstrap.Tooltip({
11973 cls : 'roo-form-error-popover',
11975 'left' : ['r-l', [-2,0], 'right'],
11976 'right' : ['l-r', [2,0], 'left'],
11977 'bottom' : ['tl-bl', [0,2], 'top'],
11978 'top' : [ 'bl-tl', [0,-2], 'bottom']
11982 this.toolTip.render(Roo.get(document.body));
11984 this.toolTip.el.enableDisplayMode("block");
11986 Roo.get(document.body).on('click', function(){
11990 Roo.get(document.body).on('touchstart', function(){
11994 this.isApplied = true
11997 mask : function(form, target)
12001 this.target = target;
12003 if(!this.form.errorMask || !target.el){
12007 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
12009 Roo.log(scrollable);
12011 var ot = this.target.el.calcOffsetsTo(scrollable);
12013 var scrollTo = ot[1] - this.form.maskOffset;
12015 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
12017 scrollable.scrollTo('top', scrollTo);
12019 var box = this.target.el.getBox();
12021 var zIndex = Roo.bootstrap.Modal.zIndex++;
12024 this.maskEl.top.setStyle('position', 'absolute');
12025 this.maskEl.top.setStyle('z-index', zIndex);
12026 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
12027 this.maskEl.top.setLeft(0);
12028 this.maskEl.top.setTop(0);
12029 this.maskEl.top.show();
12031 this.maskEl.left.setStyle('position', 'absolute');
12032 this.maskEl.left.setStyle('z-index', zIndex);
12033 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
12034 this.maskEl.left.setLeft(0);
12035 this.maskEl.left.setTop(box.y - this.padding);
12036 this.maskEl.left.show();
12038 this.maskEl.bottom.setStyle('position', 'absolute');
12039 this.maskEl.bottom.setStyle('z-index', zIndex);
12040 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
12041 this.maskEl.bottom.setLeft(0);
12042 this.maskEl.bottom.setTop(box.bottom + this.padding);
12043 this.maskEl.bottom.show();
12045 this.maskEl.right.setStyle('position', 'absolute');
12046 this.maskEl.right.setStyle('z-index', zIndex);
12047 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
12048 this.maskEl.right.setLeft(box.right + this.padding);
12049 this.maskEl.right.setTop(box.y - this.padding);
12050 this.maskEl.right.show();
12052 this.toolTip.bindEl = this.target.el;
12054 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
12056 var tip = this.target.blankText;
12058 if(this.target.getValue() !== '' ) {
12060 if (this.target.invalidText.length) {
12061 tip = this.target.invalidText;
12062 } else if (this.target.regexText.length){
12063 tip = this.target.regexText;
12067 this.toolTip.show(tip);
12069 this.intervalID = window.setInterval(function() {
12070 Roo.bootstrap.form.Form.popover.unmask();
12073 window.onwheel = function(){ return false;};
12075 (function(){ this.isMasked = true; }).defer(500, this);
12079 unmask : function()
12081 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
12085 this.maskEl.top.setStyle('position', 'absolute');
12086 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
12087 this.maskEl.top.hide();
12089 this.maskEl.left.setStyle('position', 'absolute');
12090 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
12091 this.maskEl.left.hide();
12093 this.maskEl.bottom.setStyle('position', 'absolute');
12094 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
12095 this.maskEl.bottom.hide();
12097 this.maskEl.right.setStyle('position', 'absolute');
12098 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
12099 this.maskEl.right.hide();
12101 this.toolTip.hide();
12103 this.toolTip.el.hide();
12105 window.onwheel = function(){ return true;};
12107 if(this.intervalID){
12108 window.clearInterval(this.intervalID);
12109 this.intervalID = false;
12112 this.isMasked = false;
12122 * Ext JS Library 1.1.1
12123 * Copyright(c) 2006-2007, Ext JS, LLC.
12125 * Originally Released Under LGPL - original licence link has changed is not relivant.
12128 * <script type="text/javascript">
12131 * @class Roo.form.VTypes
12132 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
12135 Roo.form.VTypes = function(){
12136 // closure these in so they are only created once.
12137 var alpha = /^[a-zA-Z_]+$/;
12138 var alphanum = /^[a-zA-Z0-9_]+$/;
12139 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
12140 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
12142 // All these messages and functions are configurable
12145 * The function used to validate email addresses
12146 * @param {String} value The email address
12148 'email' : function(v){
12149 return email.test(v);
12152 * The error text to display when the email validation function returns false
12155 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
12157 * The keystroke filter mask to be applied on email input
12160 'emailMask' : /[a-z0-9_\.\-@]/i,
12163 * The function used to validate URLs
12164 * @param {String} value The URL
12166 'url' : function(v){
12167 return url.test(v);
12170 * The error text to display when the url validation function returns false
12173 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
12176 * The function used to validate alpha values
12177 * @param {String} value The value
12179 'alpha' : function(v){
12180 return alpha.test(v);
12183 * The error text to display when the alpha validation function returns false
12186 'alphaText' : 'This field should only contain letters and _',
12188 * The keystroke filter mask to be applied on alpha input
12191 'alphaMask' : /[a-z_]/i,
12194 * The function used to validate alphanumeric values
12195 * @param {String} value The value
12197 'alphanum' : function(v){
12198 return alphanum.test(v);
12201 * The error text to display when the alphanumeric validation function returns false
12204 'alphanumText' : 'This field should only contain letters, numbers and _',
12206 * The keystroke filter mask to be applied on alphanumeric input
12209 'alphanumMask' : /[a-z0-9_]/i
12219 * @class Roo.bootstrap.form.Input
12220 * @extends Roo.bootstrap.Component
12221 * Bootstrap Input class
12222 * @cfg {Boolean} disabled is it disabled
12223 * @cfg {String} inputType (button|checkbox|email|file|hidden|image|number|password|radio|range|reset|search|submit|text)
12224 * @cfg {String} name name of the input
12225 * @cfg {string} fieldLabel - the label associated
12226 * @cfg {string} placeholder - placeholder to put in text.
12227 * @cfg {string} before - input group add on before
12228 * @cfg {string} after - input group add on after
12229 * @cfg {string} size - (lg|sm) or leave empty..
12230 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
12231 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
12232 * @cfg {Number} md colspan out of 12 for computer-sized screens
12233 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
12234 * @cfg {string} value default value of the input
12235 * @cfg {Number} labelWidth set the width of label
12236 * @cfg {Number} labellg set the width of label (1-12)
12237 * @cfg {Number} labelmd set the width of label (1-12)
12238 * @cfg {Number} labelsm set the width of label (1-12)
12239 * @cfg {Number} labelxs set the width of label (1-12)
12240 * @cfg {String} labelAlign (top|left)
12241 * @cfg {Boolean} readOnly Specifies that the field should be read-only
12242 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
12243 * @cfg {String} indicatorpos (left|right) default left
12244 * @cfg {String} capture (user|camera) use for file input only. (default empty)
12245 * @cfg {String} accept (image|video|audio) use for file input only. (default empty)
12246 * @cfg {Boolean} preventMark Do not show tick or cross if error/success
12247 * @cfg {Roo.bootstrap.Button} before Button to show before
12248 * @cfg {Roo.bootstrap.Button} afterButton to show before
12249 * @cfg {String} align (left|center|right) Default left
12250 * @cfg {Boolean} forceFeedback (true|false) Default false
12253 * Create a new Input
12254 * @param {Object} config The config object
12257 Roo.bootstrap.form.Input = function(config){
12259 Roo.bootstrap.form.Input.superclass.constructor.call(this, config);
12264 * Fires when this field receives input focus.
12265 * @param {Roo.form.Field} this
12270 * Fires when this field loses input focus.
12271 * @param {Roo.form.Field} this
12275 * @event specialkey
12276 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
12277 * {@link Roo.EventObject#getKey} to determine which key was pressed.
12278 * @param {Roo.form.Field} this
12279 * @param {Roo.EventObject} e The event object
12284 * Fires just before the field blurs if the field value has changed.
12285 * @param {Roo.form.Field} this
12286 * @param {Mixed} newValue The new value
12287 * @param {Mixed} oldValue The original value
12292 * Fires after the field has been marked as invalid.
12293 * @param {Roo.form.Field} this
12294 * @param {String} msg The validation message
12299 * Fires after the field has been validated with no errors.
12300 * @param {Roo.form.Field} this
12305 * Fires after the key up
12306 * @param {Roo.form.Field} this
12307 * @param {Roo.EventObject} e The event Object
12312 * Fires after the user pastes into input
12313 * @param {Roo.form.Field} this
12314 * @param {Roo.EventObject} e The event Object
12320 Roo.extend(Roo.bootstrap.form.Input, Roo.bootstrap.Component, {
12322 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
12323 automatic validation (defaults to "keyup").
12325 validationEvent : "keyup",
12327 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
12329 validateOnBlur : true,
12331 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
12333 validationDelay : 250,
12335 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
12337 focusClass : "x-form-focus", // not needed???
12341 * @cfg {String} invalidClass DEPRICATED - code uses BS4 - is-valid / is-invalid
12343 invalidClass : "has-warning",
12346 * @cfg {String} validClass DEPRICATED - code uses BS4 - is-valid / is-invalid
12348 validClass : "has-success",
12351 * @cfg {Boolean} hasFeedback (true|false) default true
12353 hasFeedback : true,
12356 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
12358 invalidFeedbackClass : "glyphicon-warning-sign",
12361 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
12363 validFeedbackClass : "glyphicon-ok",
12366 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
12368 selectOnFocus : false,
12371 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
12375 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
12380 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
12382 disableKeyFilter : false,
12385 * @cfg {Boolean} disabled True to disable the field (defaults to false).
12389 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
12393 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
12395 blankText : "Please complete this mandatory field",
12398 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
12402 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
12404 maxLength : Number.MAX_VALUE,
12406 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
12408 minLengthText : "The minimum length for this field is {0}",
12410 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
12412 maxLengthText : "The maximum length for this field is {0}",
12416 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
12417 * If available, this function will be called only after the basic validators all return true, and will be passed the
12418 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
12422 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
12423 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
12424 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
12428 * @cfg {String} regexText -- Depricated - use Invalid Text
12433 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
12439 autocomplete: false,
12443 inputType : 'text',
12446 placeholder: false,
12451 preventMark: false,
12452 isFormField : true,
12455 labelAlign : false,
12458 formatedValue : false,
12459 forceFeedback : false,
12461 indicatorpos : 'left',
12471 parentLabelAlign : function()
12474 while (parent.parent()) {
12475 parent = parent.parent();
12476 if (typeof(parent.labelAlign) !='undefined') {
12477 return parent.labelAlign;
12484 getAutoCreate : function()
12486 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
12492 if(this.inputType != 'hidden'){
12493 cfg.cls = 'form-group' //input-group
12499 type : this.inputType,
12500 value : this.value,
12501 cls : 'form-control',
12502 placeholder : this.placeholder || '',
12503 autocomplete : this.autocomplete || 'new-password'
12505 if (this.inputType == 'file') {
12506 input.style = 'overflow:hidden'; // why not in CSS?
12509 if(this.capture.length){
12510 input.capture = this.capture;
12513 if(this.accept.length){
12514 input.accept = this.accept + "/*";
12518 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
12521 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
12522 input.maxLength = this.maxLength;
12525 if (this.disabled) {
12526 input.disabled=true;
12529 if (this.readOnly) {
12530 input.readonly=true;
12534 input.name = this.name;
12538 input.cls += ' input-' + this.size;
12542 ['xs','sm','md','lg'].map(function(size){
12543 if (settings[size]) {
12544 cfg.cls += ' col-' + size + '-' + settings[size];
12548 var inputblock = input;
12552 cls: 'glyphicon form-control-feedback'
12555 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
12558 cls : 'has-feedback',
12566 if (this.before || this.after) {
12569 cls : 'input-group',
12573 if (this.before && typeof(this.before) == 'string') {
12575 inputblock.cn.push({
12577 cls : 'roo-input-before input-group-addon input-group-prepend input-group-text',
12581 if (this.before && typeof(this.before) == 'object') {
12582 this.before = Roo.factory(this.before);
12584 inputblock.cn.push({
12586 cls : 'roo-input-before input-group-prepend input-group-' +
12587 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
12591 inputblock.cn.push(input);
12593 if (this.after && typeof(this.after) == 'string') {
12594 inputblock.cn.push({
12596 cls : 'roo-input-after input-group-append input-group-text input-group-addon',
12600 if (this.after && typeof(this.after) == 'object') {
12601 this.after = Roo.factory(this.after);
12603 inputblock.cn.push({
12605 cls : 'roo-input-after input-group-append input-group-' +
12606 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
12610 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
12611 inputblock.cls += ' has-feedback';
12612 inputblock.cn.push(feedback);
12617 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
12618 tooltip : 'This field is required'
12620 if (this.allowBlank ) {
12621 indicator.style = this.allowBlank ? ' display:none' : '';
12623 if (align ==='left' && this.fieldLabel.length) {
12625 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
12632 cls : 'control-label col-form-label',
12633 html : this.fieldLabel
12644 var labelCfg = cfg.cn[1];
12645 var contentCfg = cfg.cn[2];
12647 if(this.indicatorpos == 'right'){
12652 cls : 'control-label col-form-label',
12656 html : this.fieldLabel
12670 labelCfg = cfg.cn[0];
12671 contentCfg = cfg.cn[1];
12675 if(this.labelWidth > 12){
12676 labelCfg.style = "width: " + this.labelWidth + 'px';
12679 if(this.labelWidth < 13 && this.labelmd == 0){
12680 this.labellg = this.labellg > 0 ? this.labellg : this.labelWidth;
12683 if(this.labellg > 0){
12684 labelCfg.cls += ' col-lg-' + this.labellg;
12685 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
12688 if(this.labelmd > 0){
12689 labelCfg.cls += ' col-md-' + this.labelmd;
12690 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
12693 if(this.labelsm > 0){
12694 labelCfg.cls += ' col-sm-' + this.labelsm;
12695 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
12698 if(this.labelxs > 0){
12699 labelCfg.cls += ' col-xs-' + this.labelxs;
12700 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
12704 } else if ( this.fieldLabel.length) {
12711 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
12712 tooltip : 'This field is required',
12713 style : this.allowBlank ? ' display:none' : ''
12717 //cls : 'input-group-addon',
12718 html : this.fieldLabel
12726 if(this.indicatorpos == 'right'){
12731 //cls : 'input-group-addon',
12732 html : this.fieldLabel
12737 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
12738 tooltip : 'This field is required',
12739 style : this.allowBlank ? ' display:none' : ''
12759 if (this.parentType === 'Navbar' && this.parent().bar) {
12760 cfg.cls += ' navbar-form';
12763 if (this.parentType === 'NavGroup' && !(Roo.bootstrap.version == 4 && this.parent().form)) {
12764 // on BS4 we do this only if not form
12765 cfg.cls += ' navbar-form';
12773 * return the real input element.
12775 inputEl: function ()
12777 return this.el.select('input.form-control',true).first();
12780 tooltipEl : function()
12782 return this.inputEl();
12785 indicatorEl : function()
12787 if (Roo.bootstrap.version == 4) {
12788 return false; // not enabled in v4 yet.
12791 var indicator = this.el.select('i.roo-required-indicator',true).first();
12801 setDisabled : function(v)
12803 var i = this.inputEl().dom;
12805 i.removeAttribute('disabled');
12809 i.setAttribute('disabled','true');
12811 initEvents : function()
12814 this.inputEl().on("keydown" , this.fireKey, this);
12815 this.inputEl().on("focus", this.onFocus, this);
12816 this.inputEl().on("blur", this.onBlur, this);
12818 this.inputEl().relayEvent('keyup', this);
12819 this.inputEl().relayEvent('paste', this);
12821 this.indicator = this.indicatorEl();
12823 if(this.indicator){
12824 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible'); // changed from invisible??? -
12827 // reference to original value for reset
12828 this.originalValue = this.getValue();
12829 //Roo.form.TextField.superclass.initEvents.call(this);
12830 if(this.validationEvent == 'keyup'){
12831 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
12832 this.inputEl().on('keyup', this.filterValidation, this);
12834 else if(this.validationEvent !== false){
12835 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
12838 if(this.selectOnFocus){
12839 this.on("focus", this.preFocus, this);
12842 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
12843 this.inputEl().on("keypress", this.filterKeys, this);
12845 this.inputEl().relayEvent('keypress', this);
12848 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
12849 this.el.on("click", this.autoSize, this);
12852 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
12853 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
12856 if (typeof(this.before) == 'object') {
12857 this.before.render(this.el.select('.roo-input-before',true).first());
12859 if (typeof(this.after) == 'object') {
12860 this.after.render(this.el.select('.roo-input-after',true).first());
12863 this.inputEl().on('change', this.onChange, this);
12866 filterValidation : function(e){
12867 if(!e.isNavKeyPress()){
12868 this.validationTask.delay(this.validationDelay);
12872 * Validates the field value
12873 * @return {Boolean} True if the value is valid, else false
12875 validate : function(){
12876 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
12877 if(this.disabled || this.validateValue(this.getRawValue())){
12882 this.markInvalid();
12888 * Validates a value according to the field's validation rules and marks the field as invalid
12889 * if the validation fails
12890 * @param {Mixed} value The value to validate
12891 * @return {Boolean} True if the value is valid, else false
12893 validateValue : function(value)
12895 if(this.getVisibilityEl().hasClass('hidden')){
12899 if(value.length < 1) { // if it's blank
12900 if(this.allowBlank){
12906 if(value.length < this.minLength){
12909 if(value.length > this.maxLength){
12913 var vt = Roo.form.VTypes;
12914 if(!vt[this.vtype](value, this)){
12918 if(typeof this.validator == "function"){
12919 var msg = this.validator(value);
12923 if (typeof(msg) == 'string') {
12924 this.invalidText = msg;
12928 if(this.regex && !this.regex.test(value)){
12936 fireKey : function(e){
12937 //Roo.log('field ' + e.getKey());
12938 if(e.isNavKeyPress()){
12939 this.fireEvent("specialkey", this, e);
12942 focus : function (selectText){
12944 this.inputEl().focus();
12945 if(selectText === true){
12946 this.inputEl().dom.select();
12952 onFocus : function(){
12953 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
12954 // this.el.addClass(this.focusClass);
12956 if(!this.hasFocus){
12957 this.hasFocus = true;
12958 this.startValue = this.getValue();
12959 this.fireEvent("focus", this);
12963 beforeBlur : Roo.emptyFn,
12967 onBlur : function(){
12969 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
12970 //this.el.removeClass(this.focusClass);
12972 this.hasFocus = false;
12973 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
12976 var v = this.getValue();
12977 if(String(v) !== String(this.startValue)){
12978 this.fireEvent('change', this, v, this.startValue);
12980 this.fireEvent("blur", this);
12983 onChange : function(e)
12985 var v = this.getValue();
12986 if(String(v) !== String(this.startValue)){
12987 this.fireEvent('change', this, v, this.startValue);
12993 * Resets the current field value to the originally loaded value and clears any validation messages
12995 reset : function(){
12996 this.setValue(this.originalValue);
13000 * Returns the name of the field
13001 * @return {Mixed} name The name field
13003 getName: function(){
13007 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
13008 * @return {Mixed} value The field value
13010 getValue : function(){
13012 var v = this.inputEl().getValue();
13017 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
13018 * @return {Mixed} value The field value
13020 getRawValue : function(){
13021 var v = this.inputEl().getValue();
13027 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
13028 * @param {Mixed} value The value to set
13030 setRawValue : function(v){
13031 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
13034 selectText : function(start, end){
13035 var v = this.getRawValue();
13037 start = start === undefined ? 0 : start;
13038 end = end === undefined ? v.length : end;
13039 var d = this.inputEl().dom;
13040 if(d.setSelectionRange){
13041 d.setSelectionRange(start, end);
13042 }else if(d.createTextRange){
13043 var range = d.createTextRange();
13044 range.moveStart("character", start);
13045 range.moveEnd("character", v.length-end);
13052 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
13053 * @param {Mixed} value The value to set
13055 setValue : function(v){
13058 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
13064 processValue : function(value){
13065 if(this.stripCharsRe){
13066 var newValue = value.replace(this.stripCharsRe, '');
13067 if(newValue !== value){
13068 this.setRawValue(newValue);
13075 preFocus : function(){
13077 if(this.selectOnFocus){
13078 this.inputEl().dom.select();
13081 filterKeys : function(e){
13082 var k = e.getKey();
13083 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
13086 var c = e.getCharCode(), cc = String.fromCharCode(c);
13087 if(Roo.isIE && (e.isSpecialKey() || !cc)){
13090 if(!this.maskRe.test(cc)){
13095 * Clear any invalid styles/messages for this field
13097 clearInvalid : function(){
13099 if(!this.el || this.preventMark){ // not rendered
13104 this.el.removeClass([this.invalidClass, 'is-invalid']);
13106 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
13108 var feedback = this.el.select('.form-control-feedback', true).first();
13111 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
13116 if(this.indicator){
13117 this.indicator.removeClass('visible');
13118 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
13121 this.fireEvent('valid', this);
13125 * Mark this field as valid
13127 markValid : function()
13129 if(!this.el || this.preventMark){ // not rendered...
13133 this.el.removeClass([this.invalidClass, this.validClass]);
13134 this.inputEl().removeClass(['is-valid', 'is-invalid']);
13136 var feedback = this.el.select('.form-control-feedback', true).first();
13139 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13142 if(this.indicator){
13143 this.indicator.removeClass('visible');
13144 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
13152 if(this.allowBlank && !this.getRawValue().length){
13155 if (Roo.bootstrap.version == 3) {
13156 this.el.addClass(this.validClass);
13158 this.inputEl().addClass('is-valid');
13161 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
13163 var feedback = this.el.select('.form-control-feedback', true).first();
13166 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13167 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
13172 this.fireEvent('valid', this);
13176 * Mark this field as invalid
13177 * @param {String} msg The validation message
13179 markInvalid : function(msg)
13181 if(!this.el || this.preventMark){ // not rendered
13185 this.el.removeClass([this.invalidClass, this.validClass]);
13186 this.inputEl().removeClass(['is-valid', 'is-invalid']);
13188 var feedback = this.el.select('.form-control-feedback', true).first();
13191 this.el.select('.form-control-feedback', true).first().removeClass(
13192 [this.invalidFeedbackClass, this.validFeedbackClass]);
13199 if(this.allowBlank && !this.getRawValue().length){
13203 if(this.indicator){
13204 this.indicator.removeClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
13205 this.indicator.addClass('visible');
13207 if (Roo.bootstrap.version == 3) {
13208 this.el.addClass(this.invalidClass);
13210 this.inputEl().addClass('is-invalid');
13215 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
13217 var feedback = this.el.select('.form-control-feedback', true).first();
13220 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13222 if(this.getValue().length || this.forceFeedback){
13223 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
13230 this.fireEvent('invalid', this, msg);
13233 SafariOnKeyDown : function(event)
13235 // this is a workaround for a password hang bug on chrome/ webkit.
13236 if (this.inputEl().dom.type != 'password') {
13240 var isSelectAll = false;
13242 if(this.inputEl().dom.selectionEnd > 0){
13243 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
13245 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
13246 event.preventDefault();
13251 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
13253 event.preventDefault();
13254 // this is very hacky as keydown always get's upper case.
13256 var cc = String.fromCharCode(event.getCharCode());
13257 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
13261 adjustWidth : function(tag, w){
13262 tag = tag.toLowerCase();
13263 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
13264 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
13265 if(tag == 'input'){
13268 if(tag == 'textarea'){
13271 }else if(Roo.isOpera){
13272 if(tag == 'input'){
13275 if(tag == 'textarea'){
13283 setFieldLabel : function(v)
13285 if(!this.rendered){
13289 if(this.indicatorEl()){
13290 var ar = this.el.select('label > span',true);
13292 if (ar.elements.length) {
13293 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
13294 this.fieldLabel = v;
13298 var br = this.el.select('label',true);
13300 if(br.elements.length) {
13301 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
13302 this.fieldLabel = v;
13306 Roo.log('Cannot Found any of label > span || label in input');
13310 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
13311 this.fieldLabel = v;
13326 * @class Roo.bootstrap.form.TextArea
13327 * @extends Roo.bootstrap.form.Input
13328 * Bootstrap TextArea class
13329 * @cfg {Number} cols Specifies the visible width of a text area
13330 * @cfg {Number} rows Specifies the visible number of lines in a text area
13331 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
13332 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
13333 * @cfg {string} html text
13336 * Create a new TextArea
13337 * @param {Object} config The config object
13340 Roo.bootstrap.form.TextArea = function(config){
13341 Roo.bootstrap.form.TextArea.superclass.constructor.call(this, config);
13345 Roo.extend(Roo.bootstrap.form.TextArea, Roo.bootstrap.form.Input, {
13355 getAutoCreate : function(){
13357 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
13363 if(this.inputType != 'hidden'){
13364 cfg.cls = 'form-group' //input-group
13372 value : this.value || '',
13373 html: this.html || '',
13374 cls : 'form-control',
13375 placeholder : this.placeholder || ''
13379 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
13380 input.maxLength = this.maxLength;
13384 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
13388 input.cols = this.cols;
13391 if (this.readOnly) {
13392 input.readonly = true;
13396 input.name = this.name;
13400 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
13404 ['xs','sm','md','lg'].map(function(size){
13405 if (settings[size]) {
13406 cfg.cls += ' col-' + size + '-' + settings[size];
13410 var inputblock = input;
13412 if(this.hasFeedback && !this.allowBlank){
13416 cls: 'glyphicon form-control-feedback'
13420 cls : 'has-feedback',
13429 if (this.before || this.after) {
13432 cls : 'input-group',
13436 inputblock.cn.push({
13438 cls : 'input-group-addon',
13443 inputblock.cn.push(input);
13445 if(this.hasFeedback && !this.allowBlank){
13446 inputblock.cls += ' has-feedback';
13447 inputblock.cn.push(feedback);
13451 inputblock.cn.push({
13453 cls : 'input-group-addon',
13460 if (align ==='left' && this.fieldLabel.length) {
13465 cls : 'control-label',
13466 html : this.fieldLabel
13477 if(this.labelWidth > 12){
13478 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
13481 if(this.labelWidth < 13 && this.labelmd == 0){
13482 this.labelmd = this.labelWidth;
13485 if(this.labellg > 0){
13486 cfg.cn[0].cls += ' col-lg-' + this.labellg;
13487 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
13490 if(this.labelmd > 0){
13491 cfg.cn[0].cls += ' col-md-' + this.labelmd;
13492 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
13495 if(this.labelsm > 0){
13496 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
13497 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
13500 if(this.labelxs > 0){
13501 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
13502 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
13505 } else if ( this.fieldLabel.length) {
13510 //cls : 'input-group-addon',
13511 html : this.fieldLabel
13529 if (this.disabled) {
13530 input.disabled=true;
13537 * return the real textarea element.
13539 inputEl: function ()
13541 return this.el.select('textarea.form-control',true).first();
13545 * Clear any invalid styles/messages for this field
13547 clearInvalid : function()
13550 if(!this.el || this.preventMark){ // not rendered
13554 var label = this.el.select('label', true).first();
13555 var icon = this.el.select('i.fa-star', true).first();
13560 this.el.removeClass( this.validClass);
13561 this.inputEl().removeClass('is-invalid');
13563 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
13565 var feedback = this.el.select('.form-control-feedback', true).first();
13568 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
13573 this.fireEvent('valid', this);
13577 * Mark this field as valid
13579 markValid : function()
13581 if(!this.el || this.preventMark){ // not rendered
13585 this.el.removeClass([this.invalidClass, this.validClass]);
13586 this.inputEl().removeClass(['is-valid', 'is-invalid']);
13588 var feedback = this.el.select('.form-control-feedback', true).first();
13591 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13594 if(this.disabled || this.allowBlank){
13598 var label = this.el.select('label', true).first();
13599 var icon = this.el.select('i.fa-star', true).first();
13604 if (Roo.bootstrap.version == 3) {
13605 this.el.addClass(this.validClass);
13607 this.inputEl().addClass('is-valid');
13611 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
13613 var feedback = this.el.select('.form-control-feedback', true).first();
13616 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13617 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
13622 this.fireEvent('valid', this);
13626 * Mark this field as invalid
13627 * @param {String} msg The validation message
13629 markInvalid : function(msg)
13631 if(!this.el || this.preventMark){ // not rendered
13635 this.el.removeClass([this.invalidClass, this.validClass]);
13636 this.inputEl().removeClass(['is-valid', 'is-invalid']);
13638 var feedback = this.el.select('.form-control-feedback', true).first();
13641 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13644 if(this.disabled || this.allowBlank){
13648 var label = this.el.select('label', true).first();
13649 var icon = this.el.select('i.fa-star', true).first();
13651 if(!this.getValue().length && label && !icon){
13652 this.el.createChild({
13654 cls : 'text-danger fa fa-lg fa-star',
13655 tooltip : 'This field is required',
13656 style : 'margin-right:5px;'
13660 if (Roo.bootstrap.version == 3) {
13661 this.el.addClass(this.invalidClass);
13663 this.inputEl().addClass('is-invalid');
13666 // fixme ... this may be depricated need to test..
13667 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
13669 var feedback = this.el.select('.form-control-feedback', true).first();
13672 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13674 if(this.getValue().length || this.forceFeedback){
13675 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
13682 this.fireEvent('invalid', this, msg);
13690 * trigger field - base class for combo..
13695 * @class Roo.bootstrap.form.TriggerField
13696 * @extends Roo.bootstrap.form.Input
13697 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
13698 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
13699 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
13700 * for which you can provide a custom implementation. For example:
13702 var trigger = new Roo.bootstrap.form.TriggerField();
13703 trigger.onTriggerClick = myTriggerFn;
13704 trigger.applyTo('my-field');
13707 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
13708 * {@link Roo.bootstrap.form.DateField} and {@link Roo.bootstrap.form.ComboBox} are perfect examples of this.
13709 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
13710 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
13711 * @cfg {String} caret (search|calendar) BS3 only - carat fa name
13714 * Create a new TriggerField.
13715 * @param {Object} config Configuration options (valid {@Roo.bootstrap.form.Input} config options will also be applied
13716 * to the base TextField)
13718 Roo.bootstrap.form.TriggerField = function(config){
13719 this.mimicing = false;
13720 Roo.bootstrap.form.TriggerField.superclass.constructor.call(this, config);
13723 Roo.extend(Roo.bootstrap.form.TriggerField, Roo.bootstrap.form.Input, {
13725 * @cfg {String} triggerClass A CSS class to apply to the trigger
13728 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
13733 * @cfg {Boolean} removable (true|false) special filter default false
13737 /** @cfg {Boolean} grow @hide */
13738 /** @cfg {Number} growMin @hide */
13739 /** @cfg {Number} growMax @hide */
13745 autoSize: Roo.emptyFn,
13749 deferHeight : true,
13752 actionMode : 'wrap',
13757 getAutoCreate : function(){
13759 var align = this.labelAlign || this.parentLabelAlign();
13764 cls: 'form-group' //input-group
13771 type : this.inputType,
13772 cls : 'form-control',
13773 autocomplete: 'new-password',
13774 placeholder : this.placeholder || ''
13778 input.name = this.name;
13781 input.cls += ' input-' + this.size;
13784 if (this.disabled) {
13785 input.disabled=true;
13788 var inputblock = input;
13790 if(this.hasFeedback && !this.allowBlank){
13794 cls: 'glyphicon form-control-feedback'
13797 if(this.removable && !this.editable ){
13799 cls : 'has-feedback',
13805 cls : 'roo-combo-removable-btn close'
13812 cls : 'has-feedback',
13821 if(this.removable && !this.editable ){
13823 cls : 'roo-removable',
13829 cls : 'roo-combo-removable-btn close'
13836 if (this.before || this.after) {
13839 cls : 'input-group',
13843 inputblock.cn.push({
13845 cls : 'input-group-addon input-group-prepend input-group-text',
13850 inputblock.cn.push(input);
13852 if(this.hasFeedback && !this.allowBlank){
13853 inputblock.cls += ' has-feedback';
13854 inputblock.cn.push(feedback);
13858 inputblock.cn.push({
13860 cls : 'input-group-addon input-group-append input-group-text',
13869 var ibwrap = inputblock;
13874 cls: 'roo-select2-choices',
13878 cls: 'roo-select2-search-field',
13890 cls: 'roo-select2-container input-group',
13895 cls: 'form-hidden-field'
13901 if(!this.multiple && this.showToggleBtn){
13907 if (this.caret != false) {
13910 cls: 'fa fa-' + this.caret
13917 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
13919 Roo.bootstrap.version == 3 ? caret : '',
13922 cls: 'combobox-clear',
13936 combobox.cls += ' roo-select2-container-multi';
13940 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
13941 tooltip : 'This field is required'
13943 if (Roo.bootstrap.version == 4) {
13946 style : 'display:none'
13951 if (align ==='left' && this.fieldLabel.length) {
13953 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
13960 cls : 'control-label',
13961 html : this.fieldLabel
13973 var labelCfg = cfg.cn[1];
13974 var contentCfg = cfg.cn[2];
13976 if(this.indicatorpos == 'right'){
13981 cls : 'control-label',
13985 html : this.fieldLabel
13999 labelCfg = cfg.cn[0];
14000 contentCfg = cfg.cn[1];
14003 if(this.labelWidth > 12){
14004 labelCfg.style = "width: " + this.labelWidth + 'px';
14007 if(this.labelWidth < 13 && this.labelmd == 0){
14008 this.labelmd = this.labelWidth;
14011 if(this.labellg > 0){
14012 labelCfg.cls += ' col-lg-' + this.labellg;
14013 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
14016 if(this.labelmd > 0){
14017 labelCfg.cls += ' col-md-' + this.labelmd;
14018 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
14021 if(this.labelsm > 0){
14022 labelCfg.cls += ' col-sm-' + this.labelsm;
14023 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
14026 if(this.labelxs > 0){
14027 labelCfg.cls += ' col-xs-' + this.labelxs;
14028 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
14031 } else if ( this.fieldLabel.length) {
14032 // Roo.log(" label");
14037 //cls : 'input-group-addon',
14038 html : this.fieldLabel
14046 if(this.indicatorpos == 'right'){
14054 html : this.fieldLabel
14068 // Roo.log(" no label && no align");
14075 ['xs','sm','md','lg'].map(function(size){
14076 if (settings[size]) {
14077 cfg.cls += ' col-' + size + '-' + settings[size];
14088 onResize : function(w, h){
14089 // Roo.bootstrap.form.TriggerField.superclass.onResize.apply(this, arguments);
14090 // if(typeof w == 'number'){
14091 // var x = w - this.trigger.getWidth();
14092 // this.inputEl().setWidth(this.adjustWidth('input', x));
14093 // this.trigger.setStyle('left', x+'px');
14098 adjustSize : Roo.BoxComponent.prototype.adjustSize,
14101 getResizeEl : function(){
14102 return this.inputEl();
14106 getPositionEl : function(){
14107 return this.inputEl();
14111 alignErrorIcon : function(){
14112 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
14116 initEvents : function(){
14120 Roo.bootstrap.form.TriggerField.superclass.initEvents.call(this);
14121 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
14122 if(!this.multiple && this.showToggleBtn){
14123 this.trigger = this.el.select('span.dropdown-toggle',true).first();
14124 if(this.hideTrigger){
14125 this.trigger.setDisplayed(false);
14127 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
14131 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
14134 if(this.removable && !this.editable && !this.tickable){
14135 var close = this.closeTriggerEl();
14138 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
14139 close.on('click', this.removeBtnClick, this, close);
14143 //this.trigger.addClassOnOver('x-form-trigger-over');
14144 //this.trigger.addClassOnClick('x-form-trigger-click');
14147 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
14151 closeTriggerEl : function()
14153 var close = this.el.select('.roo-combo-removable-btn', true).first();
14154 return close ? close : false;
14157 removeBtnClick : function(e, h, el)
14159 e.preventDefault();
14161 if(this.fireEvent("remove", this) !== false){
14163 this.fireEvent("afterremove", this)
14167 createList : function()
14169 this.list = Roo.get(document.body).createChild({
14170 tag: Roo.bootstrap.version == 4 ? 'div' : 'ul',
14171 cls: 'typeahead typeahead-long dropdown-menu shadow',
14172 style: 'display:none'
14175 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
14180 initTrigger : function(){
14185 onDestroy : function(){
14187 this.trigger.removeAllListeners();
14188 // this.trigger.remove();
14191 // this.wrap.remove();
14193 Roo.bootstrap.form.TriggerField.superclass.onDestroy.call(this);
14197 onFocus : function(){
14198 Roo.bootstrap.form.TriggerField.superclass.onFocus.call(this);
14200 if(!this.mimicing){
14201 this.wrap.addClass('x-trigger-wrap-focus');
14202 this.mimicing = true;
14203 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
14204 if(this.monitorTab){
14205 this.el.on("keydown", this.checkTab, this);
14212 checkTab : function(e){
14213 if(e.getKey() == e.TAB){
14214 this.triggerBlur();
14219 onBlur : function(){
14224 mimicBlur : function(e, t){
14226 if(!this.wrap.contains(t) && this.validateBlur()){
14227 this.triggerBlur();
14233 triggerBlur : function(){
14234 this.mimicing = false;
14235 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
14236 if(this.monitorTab){
14237 this.el.un("keydown", this.checkTab, this);
14239 //this.wrap.removeClass('x-trigger-wrap-focus');
14240 Roo.bootstrap.form.TriggerField.superclass.onBlur.call(this);
14244 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
14245 validateBlur : function(e, t){
14250 onDisable : function(){
14251 this.inputEl().dom.disabled = true;
14252 //Roo.bootstrap.form.TriggerField.superclass.onDisable.call(this);
14254 // this.wrap.addClass('x-item-disabled');
14259 onEnable : function(){
14260 this.inputEl().dom.disabled = false;
14261 //Roo.bootstrap.form.TriggerField.superclass.onEnable.call(this);
14263 // this.el.removeClass('x-item-disabled');
14268 onShow : function(){
14269 var ae = this.getActionEl();
14272 ae.dom.style.display = '';
14273 ae.dom.style.visibility = 'visible';
14279 onHide : function(){
14280 var ae = this.getActionEl();
14281 ae.dom.style.display = 'none';
14285 * The function that should handle the trigger's click event. This method does nothing by default until overridden
14286 * by an implementing function.
14288 * @param {EventObject} e
14290 onTriggerClick : Roo.emptyFn
14298 * @class Roo.bootstrap.form.CardUploader
14299 * @extends Roo.bootstrap.Button
14300 * Bootstrap Card Uploader class - it's a button which when you add files to it, adds cards below with preview and the name...
14301 * @cfg {Number} errorTimeout default 3000
14302 * @cfg {Array} images an array of ?? Img objects ??? when loading existing files..
14303 * @cfg {Array} html The button text.
14307 * Create a new CardUploader
14308 * @param {Object} config The config object
14311 Roo.bootstrap.form.CardUploader = function(config){
14315 Roo.bootstrap.form.CardUploader.superclass.constructor.call(this, config);
14318 this.fileCollection = new Roo.util.MixedCollection(false,function(r) {
14326 * When a image is clicked on - and needs to display a slideshow or similar..
14327 * @param {Roo.bootstrap.Card} this
14328 * @param {Object} The image information data
14334 * When a the download link is clicked
14335 * @param {Roo.bootstrap.Card} this
14336 * @param {Object} The image information data contains
14343 Roo.extend(Roo.bootstrap.form.CardUploader, Roo.bootstrap.form.Input, {
14346 errorTimeout : 3000,
14350 fileCollection : false,
14353 getAutoCreate : function()
14357 cls :'form-group' ,
14362 //cls : 'input-group-addon',
14363 html : this.fieldLabel
14371 value : this.value,
14372 cls : 'd-none form-control'
14377 multiple : 'multiple',
14379 cls : 'd-none roo-card-upload-selector'
14383 cls : 'roo-card-uploader-button-container w-100 mb-2'
14386 cls : 'card-columns roo-card-uploader-container'
14396 getChildContainer : function() /// what children are added to.
14398 return this.containerEl;
14401 getButtonContainer : function() /// what children are added to.
14403 return this.el.select(".roo-card-uploader-button-container").first();
14406 initEvents : function()
14409 Roo.bootstrap.form.Input.prototype.initEvents.call(this);
14413 xns: Roo.bootstrap,
14416 container_method : 'getButtonContainer' ,
14417 html : this.html, // fix changable?
14420 'click' : function(btn, e) {
14429 this.urlAPI = (window.createObjectURL && window) ||
14430 (window.URL && URL.revokeObjectURL && URL) ||
14431 (window.webkitURL && webkitURL);
14436 this.selectorEl = this.el.select('.roo-card-upload-selector', true).first();
14438 this.selectorEl.on('change', this.onFileSelected, this);
14441 this.images.forEach(function(img) {
14444 this.images = false;
14446 this.containerEl = this.el.select('.roo-card-uploader-container', true).first();
14452 onClick : function(e)
14454 e.preventDefault();
14456 this.selectorEl.dom.click();
14460 onFileSelected : function(e)
14462 e.preventDefault();
14464 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
14468 Roo.each(this.selectorEl.dom.files, function(file){
14469 this.addFile(file);
14478 addFile : function(file)
14481 if(typeof(file) === 'string'){
14482 throw "Add file by name?"; // should not happen
14486 if(!file || !this.urlAPI){
14496 var url = _this.urlAPI.createObjectURL( file);
14499 id : Roo.bootstrap.form.CardUploader.ID--,
14500 is_uploaded : false,
14504 mimetype : file.type,
14512 * addCard - add an Attachment to the uploader
14513 * @param data - the data about the image to upload
14517 title : "Title of file",
14518 is_uploaded : false,
14519 src : "http://.....",
14520 srcfile : { the File upload object },
14521 mimetype : file.type,
14524 .. any other data...
14530 addCard : function (data)
14532 // hidden input element?
14533 // if the file is not an image...
14534 //then we need to use something other that and header_image
14539 xns : Roo.bootstrap,
14540 xtype : 'CardFooter',
14543 xns : Roo.bootstrap,
14549 xns : Roo.bootstrap,
14551 html : String.format("<small>{0}</small>", data.title),
14552 cls : 'col-10 text-left',
14557 click : function() {
14559 t.fireEvent( "download", t, data );
14565 xns : Roo.bootstrap,
14567 style: 'max-height: 28px; ',
14573 click : function() {
14574 t.removeCard(data.id)
14586 var cn = this.addxtype(
14589 xns : Roo.bootstrap,
14592 header : !data.mimetype.match(/image/) && !data.preview ? "Document": false,
14593 header_image : data.mimetype.match(/image/) ? data.src : data.preview,
14594 header_image_fit_square: true, // fixme - we probably need to use the 'Img' element to do stuff like this.
14599 initEvents : function() {
14600 Roo.bootstrap.Card.prototype.initEvents.call(this);
14602 this.imgEl = this.el.select('.card-img-top').first();
14604 this.imgEl.on('click', function() { t.fireEvent( "preview", t, data ); }, this);
14605 this.imgEl.set({ 'pointer' : 'cursor' });
14608 this.getCardFooter().addClass('p-1');
14615 // dont' really need ot update items.
14616 // this.items.push(cn);
14617 this.fileCollection.add(cn);
14619 if (!data.srcfile) {
14620 this.updateInput();
14625 var reader = new FileReader();
14626 reader.addEventListener("load", function() {
14627 data.srcdata = reader.result;
14630 reader.readAsDataURL(data.srcfile);
14635 removeCard : function(id)
14638 var card = this.fileCollection.get(id);
14639 card.data.is_deleted = 1;
14640 card.data.src = ''; /// delete the source - so it reduces size of not uploaded images etc.
14641 //this.fileCollection.remove(card);
14642 //this.items = this.items.filter(function(e) { return e != card });
14643 // dont' really need ot update items.
14644 card.el.dom.parentNode.removeChild(card.el.dom);
14645 this.updateInput();
14651 this.fileCollection.each(function(card) {
14652 if (card.el.dom && card.el.dom.parentNode) {
14653 card.el.dom.parentNode.removeChild(card.el.dom);
14656 this.fileCollection.clear();
14657 this.updateInput();
14660 updateInput : function()
14663 this.fileCollection.each(function(e) {
14667 this.inputEl().dom.value = JSON.stringify(data);
14677 Roo.bootstrap.form.CardUploader.ID = -1;/*
14679 * Ext JS Library 1.1.1
14680 * Copyright(c) 2006-2007, Ext JS, LLC.
14682 * Originally Released Under LGPL - original licence link has changed is not relivant.
14685 * <script type="text/javascript">
14690 * @class Roo.data.SortTypes
14692 * Defines the default sorting (casting?) comparison functions used when sorting data.
14694 Roo.data.SortTypes = {
14696 * Default sort that does nothing
14697 * @param {Mixed} s The value being converted
14698 * @return {Mixed} The comparison value
14700 none : function(s){
14705 * The regular expression used to strip tags
14709 stripTagsRE : /<\/?[^>]+>/gi,
14712 * Strips all HTML tags to sort on text only
14713 * @param {Mixed} s The value being converted
14714 * @return {String} The comparison value
14716 asText : function(s){
14717 return String(s).replace(this.stripTagsRE, "");
14721 * Strips all HTML tags to sort on text only - Case insensitive
14722 * @param {Mixed} s The value being converted
14723 * @return {String} The comparison value
14725 asUCText : function(s){
14726 return String(s).toUpperCase().replace(this.stripTagsRE, "");
14730 * Case insensitive string
14731 * @param {Mixed} s The value being converted
14732 * @return {String} The comparison value
14734 asUCString : function(s) {
14735 return String(s).toUpperCase();
14740 * @param {Mixed} s The value being converted
14741 * @return {Number} The comparison value
14743 asDate : function(s) {
14747 if(s instanceof Date){
14748 return s.getTime();
14750 return Date.parse(String(s));
14755 * @param {Mixed} s The value being converted
14756 * @return {Float} The comparison value
14758 asFloat : function(s) {
14759 var val = parseFloat(String(s).replace(/,/g, ""));
14768 * @param {Mixed} s The value being converted
14769 * @return {Number} The comparison value
14771 asInt : function(s) {
14772 var val = parseInt(String(s).replace(/,/g, ""));
14780 * Ext JS Library 1.1.1
14781 * Copyright(c) 2006-2007, Ext JS, LLC.
14783 * Originally Released Under LGPL - original licence link has changed is not relivant.
14786 * <script type="text/javascript">
14790 * @class Roo.data.Record
14791 * Instances of this class encapsulate both record <em>definition</em> information, and record
14792 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
14793 * to access Records cached in an {@link Roo.data.Store} object.<br>
14795 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
14796 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
14799 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
14801 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
14802 * {@link #create}. The parameters are the same.
14803 * @param {Array} data An associative Array of data values keyed by the field name.
14804 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
14805 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
14806 * not specified an integer id is generated.
14808 Roo.data.Record = function(data, id){
14809 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
14814 * Generate a constructor for a specific record layout.
14815 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
14816 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
14817 * Each field definition object may contain the following properties: <ul>
14818 * <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,
14819 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
14820 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
14821 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
14822 * is being used, then this is a string containing the javascript expression to reference the data relative to
14823 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
14824 * to the data item relative to the record element. If the mapping expression is the same as the field name,
14825 * this may be omitted.</p></li>
14826 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
14827 * <ul><li>auto (Default, implies no conversion)</li>
14832 * <li>date</li></ul></p></li>
14833 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
14834 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
14835 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
14836 * by the Reader into an object that will be stored in the Record. It is passed the
14837 * following parameters:<ul>
14838 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
14840 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
14842 * <br>usage:<br><pre><code>
14843 var TopicRecord = Roo.data.Record.create(
14844 {name: 'title', mapping: 'topic_title'},
14845 {name: 'author', mapping: 'username'},
14846 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
14847 {name: 'lastPost', mapping: 'post_time', type: 'date'},
14848 {name: 'lastPoster', mapping: 'user2'},
14849 {name: 'excerpt', mapping: 'post_text'}
14852 var myNewRecord = new TopicRecord({
14853 title: 'Do my job please',
14856 lastPost: new Date(),
14857 lastPoster: 'Animal',
14858 excerpt: 'No way dude!'
14860 myStore.add(myNewRecord);
14865 Roo.data.Record.create = function(o){
14866 var f = function(){
14867 f.superclass.constructor.apply(this, arguments);
14869 Roo.extend(f, Roo.data.Record);
14870 var p = f.prototype;
14871 p.fields = new Roo.util.MixedCollection(false, function(field){
14874 for(var i = 0, len = o.length; i < len; i++){
14875 p.fields.add(new Roo.data.Field(o[i]));
14877 f.getField = function(name){
14878 return p.fields.get(name);
14883 Roo.data.Record.AUTO_ID = 1000;
14884 Roo.data.Record.EDIT = 'edit';
14885 Roo.data.Record.REJECT = 'reject';
14886 Roo.data.Record.COMMIT = 'commit';
14888 Roo.data.Record.prototype = {
14890 * Readonly flag - true if this record has been modified.
14899 join : function(store){
14900 this.store = store;
14904 * Set the named field to the specified value.
14905 * @param {String} name The name of the field to set.
14906 * @param {Object} value The value to set the field to.
14908 set : function(name, value){
14909 if(this.data[name] == value){
14913 if(!this.modified){
14914 this.modified = {};
14916 if(typeof this.modified[name] == 'undefined'){
14917 this.modified[name] = this.data[name];
14919 this.data[name] = value;
14920 if(!this.editing && this.store){
14921 this.store.afterEdit(this);
14926 * Get the value of the named field.
14927 * @param {String} name The name of the field to get the value of.
14928 * @return {Object} The value of the field.
14930 get : function(name){
14931 return this.data[name];
14935 beginEdit : function(){
14936 this.editing = true;
14937 this.modified = {};
14941 cancelEdit : function(){
14942 this.editing = false;
14943 delete this.modified;
14947 endEdit : function(){
14948 this.editing = false;
14949 if(this.dirty && this.store){
14950 this.store.afterEdit(this);
14955 * Usually called by the {@link Roo.data.Store} which owns the Record.
14956 * Rejects all changes made to the Record since either creation, or the last commit operation.
14957 * Modified fields are reverted to their original values.
14959 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
14960 * of reject operations.
14962 reject : function(){
14963 var m = this.modified;
14965 if(typeof m[n] != "function"){
14966 this.data[n] = m[n];
14969 this.dirty = false;
14970 delete this.modified;
14971 this.editing = false;
14973 this.store.afterReject(this);
14978 * Usually called by the {@link Roo.data.Store} which owns the Record.
14979 * Commits all changes made to the Record since either creation, or the last commit operation.
14981 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
14982 * of commit operations.
14984 commit : function(){
14985 this.dirty = false;
14986 delete this.modified;
14987 this.editing = false;
14989 this.store.afterCommit(this);
14994 hasError : function(){
14995 return this.error != null;
14999 clearError : function(){
15004 * Creates a copy of this record.
15005 * @param {String} id (optional) A new record id if you don't want to use this record's id
15008 copy : function(newId) {
15009 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
15013 * Ext JS Library 1.1.1
15014 * Copyright(c) 2006-2007, Ext JS, LLC.
15016 * Originally Released Under LGPL - original licence link has changed is not relivant.
15019 * <script type="text/javascript">
15025 * @class Roo.data.Store
15026 * @extends Roo.util.Observable
15027 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
15028 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
15030 * 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
15031 * has no knowledge of the format of the data returned by the Proxy.<br>
15033 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
15034 * instances from the data object. These records are cached and made available through accessor functions.
15036 * Creates a new Store.
15037 * @param {Object} config A config object containing the objects needed for the Store to access data,
15038 * and read the data into Records.
15040 Roo.data.Store = function(config){
15041 this.data = new Roo.util.MixedCollection(false);
15042 this.data.getKey = function(o){
15045 this.baseParams = {};
15047 this.paramNames = {
15052 "multisort" : "_multisort"
15055 if(config && config.data){
15056 this.inlineData = config.data;
15057 delete config.data;
15060 Roo.apply(this, config);
15062 if(this.reader){ // reader passed
15063 this.reader = Roo.factory(this.reader, Roo.data);
15064 this.reader.xmodule = this.xmodule || false;
15065 if(!this.recordType){
15066 this.recordType = this.reader.recordType;
15068 if(this.reader.onMetaChange){
15069 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
15073 if(this.recordType){
15074 this.fields = this.recordType.prototype.fields;
15076 this.modified = [];
15080 * @event datachanged
15081 * Fires when the data cache has changed, and a widget which is using this Store
15082 * as a Record cache should refresh its view.
15083 * @param {Store} this
15085 datachanged : true,
15087 * @event metachange
15088 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
15089 * @param {Store} this
15090 * @param {Object} meta The JSON metadata
15095 * Fires when Records have been added to the Store
15096 * @param {Store} this
15097 * @param {Roo.data.Record[]} records The array of Records added
15098 * @param {Number} index The index at which the record(s) were added
15103 * Fires when a Record has been removed from the Store
15104 * @param {Store} this
15105 * @param {Roo.data.Record} record The Record that was removed
15106 * @param {Number} index The index at which the record was removed
15111 * Fires when a Record has been updated
15112 * @param {Store} this
15113 * @param {Roo.data.Record} record The Record that was updated
15114 * @param {String} operation The update operation being performed. Value may be one of:
15116 Roo.data.Record.EDIT
15117 Roo.data.Record.REJECT
15118 Roo.data.Record.COMMIT
15124 * Fires when the data cache has been cleared.
15125 * @param {Store} this
15129 * @event beforeload
15130 * Fires before a request is made for a new data object. If the beforeload handler returns false
15131 * the load action will be canceled.
15132 * @param {Store} this
15133 * @param {Object} options The loading options that were specified (see {@link #load} for details)
15137 * @event beforeloadadd
15138 * Fires after a new set of Records has been loaded.
15139 * @param {Store} this
15140 * @param {Roo.data.Record[]} records The Records that were loaded
15141 * @param {Object} options The loading options that were specified (see {@link #load} for details)
15143 beforeloadadd : true,
15146 * Fires after a new set of Records has been loaded, before they are added to the store.
15147 * @param {Store} this
15148 * @param {Roo.data.Record[]} records The Records that were loaded
15149 * @param {Object} options The loading options that were specified (see {@link #load} for details)
15150 * @params {Object} return from reader
15154 * @event loadexception
15155 * Fires if an exception occurs in the Proxy during loading.
15156 * Called with the signature of the Proxy's "loadexception" event.
15157 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
15160 * @param {Object} return from JsonData.reader() - success, totalRecords, records
15161 * @param {Object} load options
15162 * @param {Object} jsonData from your request (normally this contains the Exception)
15164 loadexception : true
15168 this.proxy = Roo.factory(this.proxy, Roo.data);
15169 this.proxy.xmodule = this.xmodule || false;
15170 this.relayEvents(this.proxy, ["loadexception"]);
15172 this.sortToggle = {};
15173 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
15175 Roo.data.Store.superclass.constructor.call(this);
15177 if(this.inlineData){
15178 this.loadData(this.inlineData);
15179 delete this.inlineData;
15183 Roo.extend(Roo.data.Store, Roo.util.Observable, {
15185 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
15186 * without a remote query - used by combo/forms at present.
15190 * @cfg {Roo.data.DataProxy} proxy [required] The Proxy object which provides access to a data object.
15193 * @cfg {Array} data Inline data to be loaded when the store is initialized.
15196 * @cfg {Roo.data.DataReader} reader [required] The Reader object which processes the data object and returns
15197 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
15200 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
15201 * on any HTTP request
15204 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
15207 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
15211 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
15212 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
15214 remoteSort : false,
15217 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
15218 * loaded or when a record is removed. (defaults to false).
15220 pruneModifiedRecords : false,
15223 lastOptions : null,
15226 * Add Records to the Store and fires the add event.
15227 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
15229 add : function(records){
15230 records = [].concat(records);
15231 for(var i = 0, len = records.length; i < len; i++){
15232 records[i].join(this);
15234 var index = this.data.length;
15235 this.data.addAll(records);
15236 this.fireEvent("add", this, records, index);
15240 * Remove a Record from the Store and fires the remove event.
15241 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
15243 remove : function(record){
15244 var index = this.data.indexOf(record);
15245 this.data.removeAt(index);
15247 if(this.pruneModifiedRecords){
15248 this.modified.remove(record);
15250 this.fireEvent("remove", this, record, index);
15254 * Remove all Records from the Store and fires the clear event.
15256 removeAll : function(){
15258 if(this.pruneModifiedRecords){
15259 this.modified = [];
15261 this.fireEvent("clear", this);
15265 * Inserts Records to the Store at the given index and fires the add event.
15266 * @param {Number} index The start index at which to insert the passed Records.
15267 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
15269 insert : function(index, records){
15270 records = [].concat(records);
15271 for(var i = 0, len = records.length; i < len; i++){
15272 this.data.insert(index, records[i]);
15273 records[i].join(this);
15275 this.fireEvent("add", this, records, index);
15279 * Get the index within the cache of the passed Record.
15280 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
15281 * @return {Number} The index of the passed Record. Returns -1 if not found.
15283 indexOf : function(record){
15284 return this.data.indexOf(record);
15288 * Get the index within the cache of the Record with the passed id.
15289 * @param {String} id The id of the Record to find.
15290 * @return {Number} The index of the Record. Returns -1 if not found.
15292 indexOfId : function(id){
15293 return this.data.indexOfKey(id);
15297 * Get the Record with the specified id.
15298 * @param {String} id The id of the Record to find.
15299 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
15301 getById : function(id){
15302 return this.data.key(id);
15306 * Get the Record at the specified index.
15307 * @param {Number} index The index of the Record to find.
15308 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
15310 getAt : function(index){
15311 return this.data.itemAt(index);
15315 * Returns a range of Records between specified indices.
15316 * @param {Number} startIndex (optional) The starting index (defaults to 0)
15317 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
15318 * @return {Roo.data.Record[]} An array of Records
15320 getRange : function(start, end){
15321 return this.data.getRange(start, end);
15325 storeOptions : function(o){
15326 o = Roo.apply({}, o);
15329 this.lastOptions = o;
15333 * Loads the Record cache from the configured Proxy using the configured Reader.
15335 * If using remote paging, then the first load call must specify the <em>start</em>
15336 * and <em>limit</em> properties in the options.params property to establish the initial
15337 * position within the dataset, and the number of Records to cache on each read from the Proxy.
15339 * <strong>It is important to note that for remote data sources, loading is asynchronous,
15340 * and this call will return before the new data has been loaded. Perform any post-processing
15341 * in a callback function, or in a "load" event handler.</strong>
15343 * @param {Object} options An object containing properties which control loading options:<ul>
15344 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
15345 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
15346 * passed the following arguments:<ul>
15347 * <li>r : Roo.data.Record[]</li>
15348 * <li>options: Options object from the load call</li>
15349 * <li>success: Boolean success indicator</li></ul></li>
15350 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
15351 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
15354 load : function(options){
15355 options = options || {};
15356 if(this.fireEvent("beforeload", this, options) !== false){
15357 this.storeOptions(options);
15358 var p = Roo.apply(options.params || {}, this.baseParams);
15359 // if meta was not loaded from remote source.. try requesting it.
15360 if (!this.reader.metaFromRemote) {
15361 p._requestMeta = 1;
15363 if(this.sortInfo && this.remoteSort){
15364 var pn = this.paramNames;
15365 p[pn["sort"]] = this.sortInfo.field;
15366 p[pn["dir"]] = this.sortInfo.direction;
15368 if (this.multiSort) {
15369 var pn = this.paramNames;
15370 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
15373 this.proxy.load(p, this.reader, this.loadRecords, this, options);
15378 * Reloads the Record cache from the configured Proxy using the configured Reader and
15379 * the options from the last load operation performed.
15380 * @param {Object} options (optional) An object containing properties which may override the options
15381 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
15382 * the most recently used options are reused).
15384 reload : function(options){
15385 this.load(Roo.applyIf(options||{}, this.lastOptions));
15389 // Called as a callback by the Reader during a load operation.
15390 loadRecords : function(o, options, success){
15393 if(success !== false){
15394 this.fireEvent("load", this, [], options, o);
15396 if(options.callback){
15397 options.callback.call(options.scope || this, [], options, false);
15401 // if data returned failure - throw an exception.
15402 if (o.success === false) {
15403 // show a message if no listener is registered.
15404 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
15405 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
15407 // loadmask wil be hooked into this..
15408 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
15411 var r = o.records, t = o.totalRecords || r.length;
15413 this.fireEvent("beforeloadadd", this, r, options, o);
15415 if(!options || options.add !== true){
15416 if(this.pruneModifiedRecords){
15417 this.modified = [];
15419 for(var i = 0, len = r.length; i < len; i++){
15423 this.data = this.snapshot;
15424 delete this.snapshot;
15427 this.data.addAll(r);
15428 this.totalLength = t;
15430 this.fireEvent("datachanged", this);
15432 this.totalLength = Math.max(t, this.data.length+r.length);
15436 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
15438 var e = new Roo.data.Record({});
15440 e.set(this.parent.displayField, this.parent.emptyTitle);
15441 e.set(this.parent.valueField, '');
15446 this.fireEvent("load", this, r, options, o);
15447 if(options.callback){
15448 options.callback.call(options.scope || this, r, options, true);
15454 * Loads data from a passed data block. A Reader which understands the format of the data
15455 * must have been configured in the constructor.
15456 * @param {Object} data The data block from which to read the Records. The format of the data expected
15457 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
15458 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
15460 loadData : function(o, append){
15461 var r = this.reader.readRecords(o);
15462 this.loadRecords(r, {add: append}, true);
15466 * using 'cn' the nested child reader read the child array into it's child stores.
15467 * @param {Object} rec The record with a 'children array
15469 loadDataFromChildren : function(rec)
15471 this.loadData(this.reader.toLoadData(rec));
15476 * Gets the number of cached records.
15478 * <em>If using paging, this may not be the total size of the dataset. If the data object
15479 * used by the Reader contains the dataset size, then the getTotalCount() function returns
15480 * the data set size</em>
15482 getCount : function(){
15483 return this.data.length || 0;
15487 * Gets the total number of records in the dataset as returned by the server.
15489 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
15490 * the dataset size</em>
15492 getTotalCount : function(){
15493 return this.totalLength || 0;
15497 * Returns the sort state of the Store as an object with two properties:
15499 field {String} The name of the field by which the Records are sorted
15500 direction {String} The sort order, "ASC" or "DESC"
15503 getSortState : function(){
15504 return this.sortInfo;
15508 applySort : function(){
15509 if(this.sortInfo && !this.remoteSort){
15510 var s = this.sortInfo, f = s.field;
15511 var st = this.fields.get(f).sortType;
15512 var fn = function(r1, r2){
15513 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
15514 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
15516 this.data.sort(s.direction, fn);
15517 if(this.snapshot && this.snapshot != this.data){
15518 this.snapshot.sort(s.direction, fn);
15524 * Sets the default sort column and order to be used by the next load operation.
15525 * @param {String} fieldName The name of the field to sort by.
15526 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
15528 setDefaultSort : function(field, dir){
15529 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
15533 * Sort the Records.
15534 * If remote sorting is used, the sort is performed on the server, and the cache is
15535 * reloaded. If local sorting is used, the cache is sorted internally.
15536 * @param {String} fieldName The name of the field to sort by.
15537 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
15539 sort : function(fieldName, dir){
15540 var f = this.fields.get(fieldName);
15542 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
15544 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
15545 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
15550 this.sortToggle[f.name] = dir;
15551 this.sortInfo = {field: f.name, direction: dir};
15552 if(!this.remoteSort){
15554 this.fireEvent("datachanged", this);
15556 this.load(this.lastOptions);
15561 * Calls the specified function for each of the Records in the cache.
15562 * @param {Function} fn The function to call. The Record is passed as the first parameter.
15563 * Returning <em>false</em> aborts and exits the iteration.
15564 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
15566 each : function(fn, scope){
15567 this.data.each(fn, scope);
15571 * Gets all records modified since the last commit. Modified records are persisted across load operations
15572 * (e.g., during paging).
15573 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
15575 getModifiedRecords : function(){
15576 return this.modified;
15580 createFilterFn : function(property, value, anyMatch){
15581 if(!value.exec){ // not a regex
15582 value = String(value);
15583 if(value.length == 0){
15586 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
15588 return function(r){
15589 return value.test(r.data[property]);
15594 * Sums the value of <i>property</i> for each record between start and end and returns the result.
15595 * @param {String} property A field on your records
15596 * @param {Number} start The record index to start at (defaults to 0)
15597 * @param {Number} end The last record index to include (defaults to length - 1)
15598 * @return {Number} The sum
15600 sum : function(property, start, end){
15601 var rs = this.data.items, v = 0;
15602 start = start || 0;
15603 end = (end || end === 0) ? end : rs.length-1;
15605 for(var i = start; i <= end; i++){
15606 v += (rs[i].data[property] || 0);
15612 * Filter the records by a specified property.
15613 * @param {String} field A field on your records
15614 * @param {String/RegExp} value Either a string that the field
15615 * should start with or a RegExp to test against the field
15616 * @param {Boolean} anyMatch True to match any part not just the beginning
15618 filter : function(property, value, anyMatch){
15619 var fn = this.createFilterFn(property, value, anyMatch);
15620 return fn ? this.filterBy(fn) : this.clearFilter();
15624 * Filter by a function. The specified function will be called with each
15625 * record in this data source. If the function returns true the record is included,
15626 * otherwise it is filtered.
15627 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
15628 * @param {Object} scope (optional) The scope of the function (defaults to this)
15630 filterBy : function(fn, scope){
15631 this.snapshot = this.snapshot || this.data;
15632 this.data = this.queryBy(fn, scope||this);
15633 this.fireEvent("datachanged", this);
15637 * Query the records by a specified property.
15638 * @param {String} field A field on your records
15639 * @param {String/RegExp} value Either a string that the field
15640 * should start with or a RegExp to test against the field
15641 * @param {Boolean} anyMatch True to match any part not just the beginning
15642 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
15644 query : function(property, value, anyMatch){
15645 var fn = this.createFilterFn(property, value, anyMatch);
15646 return fn ? this.queryBy(fn) : this.data.clone();
15650 * Query by a function. The specified function will be called with each
15651 * record in this data source. If the function returns true the record is included
15653 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
15654 * @param {Object} scope (optional) The scope of the function (defaults to this)
15655 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
15657 queryBy : function(fn, scope){
15658 var data = this.snapshot || this.data;
15659 return data.filterBy(fn, scope||this);
15663 * Collects unique values for a particular dataIndex from this store.
15664 * @param {String} dataIndex The property to collect
15665 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
15666 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
15667 * @return {Array} An array of the unique values
15669 collect : function(dataIndex, allowNull, bypassFilter){
15670 var d = (bypassFilter === true && this.snapshot) ?
15671 this.snapshot.items : this.data.items;
15672 var v, sv, r = [], l = {};
15673 for(var i = 0, len = d.length; i < len; i++){
15674 v = d[i].data[dataIndex];
15676 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
15685 * Revert to a view of the Record cache with no filtering applied.
15686 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
15688 clearFilter : function(suppressEvent){
15689 if(this.snapshot && this.snapshot != this.data){
15690 this.data = this.snapshot;
15691 delete this.snapshot;
15692 if(suppressEvent !== true){
15693 this.fireEvent("datachanged", this);
15699 afterEdit : function(record){
15700 if(this.modified.indexOf(record) == -1){
15701 this.modified.push(record);
15703 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
15707 afterReject : function(record){
15708 this.modified.remove(record);
15709 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
15713 afterCommit : function(record){
15714 this.modified.remove(record);
15715 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
15719 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
15720 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
15722 commitChanges : function(){
15723 var m = this.modified.slice(0);
15724 this.modified = [];
15725 for(var i = 0, len = m.length; i < len; i++){
15731 * Cancel outstanding changes on all changed records.
15733 rejectChanges : function(){
15734 var m = this.modified.slice(0);
15735 this.modified = [];
15736 for(var i = 0, len = m.length; i < len; i++){
15741 onMetaChange : function(meta, rtype, o){
15742 this.recordType = rtype;
15743 this.fields = rtype.prototype.fields;
15744 delete this.snapshot;
15745 this.sortInfo = meta.sortInfo || this.sortInfo;
15746 this.modified = [];
15747 this.fireEvent('metachange', this, this.reader.meta);
15750 moveIndex : function(data, type)
15752 var index = this.indexOf(data);
15754 var newIndex = index + type;
15758 this.insert(newIndex, data);
15763 * Ext JS Library 1.1.1
15764 * Copyright(c) 2006-2007, Ext JS, LLC.
15766 * Originally Released Under LGPL - original licence link has changed is not relivant.
15769 * <script type="text/javascript">
15773 * @class Roo.data.SimpleStore
15774 * @extends Roo.data.Store
15775 * Small helper class to make creating Stores from Array data easier.
15776 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
15777 * @cfg {Array} fields An array of field definition objects, or field name strings.
15778 * @cfg {Object} an existing reader (eg. copied from another store)
15779 * @cfg {Array} data The multi-dimensional array of data
15780 * @cfg {Roo.data.DataProxy} proxy [not-required]
15781 * @cfg {Roo.data.Reader} reader [not-required]
15783 * @param {Object} config
15785 Roo.data.SimpleStore = function(config)
15787 Roo.data.SimpleStore.superclass.constructor.call(this, {
15789 reader: typeof(config.reader) != 'undefined' ? config.reader : new Roo.data.ArrayReader({
15792 Roo.data.Record.create(config.fields)
15794 proxy : new Roo.data.MemoryProxy(config.data)
15798 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
15800 * Ext JS Library 1.1.1
15801 * Copyright(c) 2006-2007, Ext JS, LLC.
15803 * Originally Released Under LGPL - original licence link has changed is not relivant.
15806 * <script type="text/javascript">
15811 * @extends Roo.data.Store
15812 * @class Roo.data.JsonStore
15813 * Small helper class to make creating Stores for JSON data easier. <br/>
15815 var store = new Roo.data.JsonStore({
15816 url: 'get-images.php',
15818 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
15821 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
15822 * JsonReader and HttpProxy (unless inline data is provided).</b>
15823 * @cfg {Array} fields An array of field definition objects, or field name strings.
15825 * @param {Object} config
15827 Roo.data.JsonStore = function(c){
15828 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
15829 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
15830 reader: new Roo.data.JsonReader(c, c.fields)
15833 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
15835 * Ext JS Library 1.1.1
15836 * Copyright(c) 2006-2007, Ext JS, LLC.
15838 * Originally Released Under LGPL - original licence link has changed is not relivant.
15841 * <script type="text/javascript">
15845 Roo.data.Field = function(config){
15846 if(typeof config == "string"){
15847 config = {name: config};
15849 Roo.apply(this, config);
15852 this.type = "auto";
15855 var st = Roo.data.SortTypes;
15856 // named sortTypes are supported, here we look them up
15857 if(typeof this.sortType == "string"){
15858 this.sortType = st[this.sortType];
15861 // set default sortType for strings and dates
15862 if(!this.sortType){
15865 this.sortType = st.asUCString;
15868 this.sortType = st.asDate;
15871 this.sortType = st.none;
15876 var stripRe = /[\$,%]/g;
15878 // prebuilt conversion function for this field, instead of
15879 // switching every time we're reading a value
15881 var cv, dateFormat = this.dateFormat;
15886 cv = function(v){ return v; };
15889 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
15893 return v !== undefined && v !== null && v !== '' ?
15894 parseInt(String(v).replace(stripRe, ""), 10) : '';
15899 return v !== undefined && v !== null && v !== '' ?
15900 parseFloat(String(v).replace(stripRe, ""), 10) : '';
15905 cv = function(v){ return v === true || v === "true" || v == 1; };
15912 if(v instanceof Date){
15916 if(dateFormat == "timestamp"){
15917 return new Date(v*1000);
15919 return Date.parseDate(v, dateFormat);
15921 var parsed = Date.parse(v);
15922 return parsed ? new Date(parsed) : null;
15931 Roo.data.Field.prototype = {
15939 * Ext JS Library 1.1.1
15940 * Copyright(c) 2006-2007, Ext JS, LLC.
15942 * Originally Released Under LGPL - original licence link has changed is not relivant.
15945 * <script type="text/javascript">
15948 // Base class for reading structured data from a data source. This class is intended to be
15949 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
15952 * @class Roo.data.DataReader
15954 * Base class for reading structured data from a data source. This class is intended to be
15955 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
15958 Roo.data.DataReader = function(meta, recordType){
15962 this.recordType = recordType instanceof Array ?
15963 Roo.data.Record.create(recordType) : recordType;
15966 Roo.data.DataReader.prototype = {
15969 readerType : 'Data',
15971 * Create an empty record
15972 * @param {Object} data (optional) - overlay some values
15973 * @return {Roo.data.Record} record created.
15975 newRow : function(d) {
15977 this.recordType.prototype.fields.each(function(c) {
15979 case 'int' : da[c.name] = 0; break;
15980 case 'date' : da[c.name] = new Date(); break;
15981 case 'float' : da[c.name] = 0.0; break;
15982 case 'boolean' : da[c.name] = false; break;
15983 default : da[c.name] = ""; break;
15987 return new this.recordType(Roo.apply(da, d));
15993 * Ext JS Library 1.1.1
15994 * Copyright(c) 2006-2007, Ext JS, LLC.
15996 * Originally Released Under LGPL - original licence link has changed is not relivant.
15999 * <script type="text/javascript">
16003 * @class Roo.data.DataProxy
16004 * @extends Roo.util.Observable
16006 * This class is an abstract base class for implementations which provide retrieval of
16007 * unformatted data objects.<br>
16009 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
16010 * (of the appropriate type which knows how to parse the data object) to provide a block of
16011 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
16013 * Custom implementations must implement the load method as described in
16014 * {@link Roo.data.HttpProxy#load}.
16016 Roo.data.DataProxy = function(){
16019 * @event beforeload
16020 * Fires before a network request is made to retrieve a data object.
16021 * @param {Object} This DataProxy object.
16022 * @param {Object} params The params parameter to the load function.
16027 * Fires before the load method's callback is called.
16028 * @param {Object} This DataProxy object.
16029 * @param {Object} o The data object.
16030 * @param {Object} arg The callback argument object passed to the load function.
16034 * @event loadexception
16035 * Fires if an Exception occurs during data retrieval.
16036 * @param {Object} This DataProxy object.
16037 * @param {Object} o The data object.
16038 * @param {Object} arg The callback argument object passed to the load function.
16039 * @param {Object} e The Exception.
16041 loadexception : true
16043 Roo.data.DataProxy.superclass.constructor.call(this);
16046 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
16049 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
16053 * Ext JS Library 1.1.1
16054 * Copyright(c) 2006-2007, Ext JS, LLC.
16056 * Originally Released Under LGPL - original licence link has changed is not relivant.
16059 * <script type="text/javascript">
16062 * @class Roo.data.MemoryProxy
16063 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
16064 * to the Reader when its load method is called.
16066 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
16068 Roo.data.MemoryProxy = function(data){
16072 Roo.data.MemoryProxy.superclass.constructor.call(this);
16076 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
16079 * Load data from the requested source (in this case an in-memory
16080 * data object passed to the constructor), read the data object into
16081 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
16082 * process that block using the passed callback.
16083 * @param {Object} params This parameter is not used by the MemoryProxy class.
16084 * @param {Roo.data.DataReader} reader The Reader object which converts the data
16085 * object into a block of Roo.data.Records.
16086 * @param {Function} callback The function into which to pass the block of Roo.data.records.
16087 * The function must be passed <ul>
16088 * <li>The Record block object</li>
16089 * <li>The "arg" argument from the load function</li>
16090 * <li>A boolean success indicator</li>
16092 * @param {Object} scope The scope in which to call the callback
16093 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
16095 load : function(params, reader, callback, scope, arg){
16096 params = params || {};
16099 result = reader.readRecords(params.data ? params.data :this.data);
16101 this.fireEvent("loadexception", this, arg, null, e);
16102 callback.call(scope, null, arg, false);
16105 callback.call(scope, result, arg, true);
16109 update : function(params, records){
16114 * Ext JS Library 1.1.1
16115 * Copyright(c) 2006-2007, Ext JS, LLC.
16117 * Originally Released Under LGPL - original licence link has changed is not relivant.
16120 * <script type="text/javascript">
16123 * @class Roo.data.HttpProxy
16124 * @extends Roo.data.DataProxy
16125 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
16126 * configured to reference a certain URL.<br><br>
16128 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
16129 * from which the running page was served.<br><br>
16131 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
16133 * Be aware that to enable the browser to parse an XML document, the server must set
16134 * the Content-Type header in the HTTP response to "text/xml".
16136 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
16137 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
16138 * will be used to make the request.
16140 Roo.data.HttpProxy = function(conn){
16141 Roo.data.HttpProxy.superclass.constructor.call(this);
16142 // is conn a conn config or a real conn?
16144 this.useAjax = !conn || !conn.events;
16148 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
16149 // thse are take from connection...
16152 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
16155 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
16156 * extra parameters to each request made by this object. (defaults to undefined)
16159 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
16160 * to each request made by this object. (defaults to undefined)
16163 * @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)
16166 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
16169 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
16175 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
16179 * Return the {@link Roo.data.Connection} object being used by this Proxy.
16180 * @return {Connection} The Connection object. This object may be used to subscribe to events on
16181 * a finer-grained basis than the DataProxy events.
16183 getConnection : function(){
16184 return this.useAjax ? Roo.Ajax : this.conn;
16188 * Load data from the configured {@link Roo.data.Connection}, read the data object into
16189 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
16190 * process that block using the passed callback.
16191 * @param {Object} params An object containing properties which are to be used as HTTP parameters
16192 * for the request to the remote server.
16193 * @param {Roo.data.DataReader} reader The Reader object which converts the data
16194 * object into a block of Roo.data.Records.
16195 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
16196 * The function must be passed <ul>
16197 * <li>The Record block object</li>
16198 * <li>The "arg" argument from the load function</li>
16199 * <li>A boolean success indicator</li>
16201 * @param {Object} scope The scope in which to call the callback
16202 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
16204 load : function(params, reader, callback, scope, arg){
16205 if(this.fireEvent("beforeload", this, params) !== false){
16207 params : params || {},
16209 callback : callback,
16214 callback : this.loadResponse,
16218 Roo.applyIf(o, this.conn);
16219 if(this.activeRequest){
16220 Roo.Ajax.abort(this.activeRequest);
16222 this.activeRequest = Roo.Ajax.request(o);
16224 this.conn.request(o);
16227 callback.call(scope||this, null, arg, false);
16232 loadResponse : function(o, success, response){
16233 delete this.activeRequest;
16235 this.fireEvent("loadexception", this, o, response);
16236 o.request.callback.call(o.request.scope, null, o.request.arg, false);
16241 result = o.reader.read(response);
16243 this.fireEvent("loadexception", this, o, response, e);
16244 o.request.callback.call(o.request.scope, {
16247 errorMsg : response.responseText
16250 }, o.request.arg, false);
16254 this.fireEvent("load", this, o, o.request.arg);
16255 o.request.callback.call(o.request.scope, result, o.request.arg, true);
16259 update : function(dataSet){
16264 updateResponse : function(dataSet){
16269 * Ext JS Library 1.1.1
16270 * Copyright(c) 2006-2007, Ext JS, LLC.
16272 * Originally Released Under LGPL - original licence link has changed is not relivant.
16275 * <script type="text/javascript">
16279 * @class Roo.data.ScriptTagProxy
16280 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
16281 * other than the originating domain of the running page.<br><br>
16283 * <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
16284 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
16286 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
16287 * source code that is used as the source inside a <script> tag.<br><br>
16289 * In order for the browser to process the returned data, the server must wrap the data object
16290 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
16291 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
16292 * depending on whether the callback name was passed:
16295 boolean scriptTag = false;
16296 String cb = request.getParameter("callback");
16299 response.setContentType("text/javascript");
16301 response.setContentType("application/x-json");
16303 Writer out = response.getWriter();
16305 out.write(cb + "(");
16307 out.print(dataBlock.toJsonString());
16314 * @param {Object} config A configuration object.
16316 Roo.data.ScriptTagProxy = function(config){
16317 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
16318 Roo.apply(this, config);
16319 this.head = document.getElementsByTagName("head")[0];
16322 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
16324 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
16326 * @cfg {String} url The URL from which to request the data object.
16329 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
16333 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
16334 * the server the name of the callback function set up by the load call to process the returned data object.
16335 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
16336 * javascript output which calls this named function passing the data object as its only parameter.
16338 callbackParam : "callback",
16340 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
16341 * name to the request.
16346 * Load data from the configured URL, read the data object into
16347 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
16348 * process that block using the passed callback.
16349 * @param {Object} params An object containing properties which are to be used as HTTP parameters
16350 * for the request to the remote server.
16351 * @param {Roo.data.DataReader} reader The Reader object which converts the data
16352 * object into a block of Roo.data.Records.
16353 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
16354 * The function must be passed <ul>
16355 * <li>The Record block object</li>
16356 * <li>The "arg" argument from the load function</li>
16357 * <li>A boolean success indicator</li>
16359 * @param {Object} scope The scope in which to call the callback
16360 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
16362 load : function(params, reader, callback, scope, arg){
16363 if(this.fireEvent("beforeload", this, params) !== false){
16365 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
16367 var url = this.url;
16368 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
16370 url += "&_dc=" + (new Date().getTime());
16372 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
16375 cb : "stcCallback"+transId,
16376 scriptId : "stcScript"+transId,
16380 callback : callback,
16386 window[trans.cb] = function(o){
16387 conn.handleResponse(o, trans);
16390 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
16392 if(this.autoAbort !== false){
16396 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
16398 var script = document.createElement("script");
16399 script.setAttribute("src", url);
16400 script.setAttribute("type", "text/javascript");
16401 script.setAttribute("id", trans.scriptId);
16402 this.head.appendChild(script);
16404 this.trans = trans;
16406 callback.call(scope||this, null, arg, false);
16411 isLoading : function(){
16412 return this.trans ? true : false;
16416 * Abort the current server request.
16418 abort : function(){
16419 if(this.isLoading()){
16420 this.destroyTrans(this.trans);
16425 destroyTrans : function(trans, isLoaded){
16426 this.head.removeChild(document.getElementById(trans.scriptId));
16427 clearTimeout(trans.timeoutId);
16429 window[trans.cb] = undefined;
16431 delete window[trans.cb];
16434 // if hasn't been loaded, wait for load to remove it to prevent script error
16435 window[trans.cb] = function(){
16436 window[trans.cb] = undefined;
16438 delete window[trans.cb];
16445 handleResponse : function(o, trans){
16446 this.trans = false;
16447 this.destroyTrans(trans, true);
16450 result = trans.reader.readRecords(o);
16452 this.fireEvent("loadexception", this, o, trans.arg, e);
16453 trans.callback.call(trans.scope||window, null, trans.arg, false);
16456 this.fireEvent("load", this, o, trans.arg);
16457 trans.callback.call(trans.scope||window, result, trans.arg, true);
16461 handleFailure : function(trans){
16462 this.trans = false;
16463 this.destroyTrans(trans, false);
16464 this.fireEvent("loadexception", this, null, trans.arg);
16465 trans.callback.call(trans.scope||window, null, trans.arg, false);
16469 * Ext JS Library 1.1.1
16470 * Copyright(c) 2006-2007, Ext JS, LLC.
16472 * Originally Released Under LGPL - original licence link has changed is not relivant.
16475 * <script type="text/javascript">
16479 * @class Roo.data.JsonReader
16480 * @extends Roo.data.DataReader
16481 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
16482 * based on mappings in a provided Roo.data.Record constructor.
16484 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
16485 * in the reply previously.
16490 var RecordDef = Roo.data.Record.create([
16491 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
16492 {name: 'occupation'} // This field will use "occupation" as the mapping.
16494 var myReader = new Roo.data.JsonReader({
16495 totalProperty: "results", // The property which contains the total dataset size (optional)
16496 root: "rows", // The property which contains an Array of row objects
16497 id: "id" // The property within each row object that provides an ID for the record (optional)
16501 * This would consume a JSON file like this:
16503 { 'results': 2, 'rows': [
16504 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
16505 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
16508 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
16509 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
16510 * paged from the remote server.
16511 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
16512 * @cfg {String} root name of the property which contains the Array of row objects.
16513 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
16514 * @cfg {Array} fields Array of field definition objects
16516 * Create a new JsonReader
16517 * @param {Object} meta Metadata configuration options
16518 * @param {Object} recordType Either an Array of field definition objects,
16519 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
16521 Roo.data.JsonReader = function(meta, recordType){
16524 // set some defaults:
16525 Roo.applyIf(meta, {
16526 totalProperty: 'total',
16527 successProperty : 'success',
16532 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
16534 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
16536 readerType : 'Json',
16539 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
16540 * Used by Store query builder to append _requestMeta to params.
16543 metaFromRemote : false,
16545 * This method is only used by a DataProxy which has retrieved data from a remote server.
16546 * @param {Object} response The XHR object which contains the JSON data in its responseText.
16547 * @return {Object} data A data block which is used by an Roo.data.Store object as
16548 * a cache of Roo.data.Records.
16550 read : function(response){
16551 var json = response.responseText;
16553 var o = /* eval:var:o */ eval("("+json+")");
16555 throw {message: "JsonReader.read: Json object not found"};
16561 this.metaFromRemote = true;
16562 this.meta = o.metaData;
16563 this.recordType = Roo.data.Record.create(o.metaData.fields);
16564 this.onMetaChange(this.meta, this.recordType, o);
16566 return this.readRecords(o);
16569 // private function a store will implement
16570 onMetaChange : function(meta, recordType, o){
16577 simpleAccess: function(obj, subsc) {
16584 getJsonAccessor: function(){
16586 return function(expr) {
16588 return(re.test(expr))
16589 ? new Function("obj", "return obj." + expr)
16594 return Roo.emptyFn;
16599 * Create a data block containing Roo.data.Records from an XML document.
16600 * @param {Object} o An object which contains an Array of row objects in the property specified
16601 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
16602 * which contains the total size of the dataset.
16603 * @return {Object} data A data block which is used by an Roo.data.Store object as
16604 * a cache of Roo.data.Records.
16606 readRecords : function(o){
16608 * After any data loads, the raw JSON data is available for further custom processing.
16612 var s = this.meta, Record = this.recordType,
16613 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
16615 // Generate extraction functions for the totalProperty, the root, the id, and for each field
16617 if(s.totalProperty) {
16618 this.getTotal = this.getJsonAccessor(s.totalProperty);
16620 if(s.successProperty) {
16621 this.getSuccess = this.getJsonAccessor(s.successProperty);
16623 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
16625 var g = this.getJsonAccessor(s.id);
16626 this.getId = function(rec) {
16628 return (r === undefined || r === "") ? null : r;
16631 this.getId = function(){return null;};
16634 for(var jj = 0; jj < fl; jj++){
16636 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
16637 this.ef[jj] = this.getJsonAccessor(map);
16641 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
16642 if(s.totalProperty){
16643 var vt = parseInt(this.getTotal(o), 10);
16648 if(s.successProperty){
16649 var vs = this.getSuccess(o);
16650 if(vs === false || vs === 'false'){
16655 for(var i = 0; i < c; i++){
16658 var id = this.getId(n);
16659 for(var j = 0; j < fl; j++){
16661 var v = this.ef[j](n);
16663 Roo.log('missing convert for ' + f.name);
16667 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
16669 var record = new Record(values, id);
16671 records[i] = record;
16677 totalRecords : totalRecords
16680 // used when loading children.. @see loadDataFromChildren
16681 toLoadData: function(rec)
16683 // expect rec just to be an array.. eg [a,b,c, [...] << cn ]
16684 var data = typeof(rec.data.cn) == 'undefined' ? [] : rec.data.cn;
16685 return { data : data, total : data.length };
16690 * Ext JS Library 1.1.1
16691 * Copyright(c) 2006-2007, Ext JS, LLC.
16693 * Originally Released Under LGPL - original licence link has changed is not relivant.
16696 * <script type="text/javascript">
16700 * @class Roo.data.ArrayReader
16701 * @extends Roo.data.DataReader
16702 * Data reader class to create an Array of Roo.data.Record objects from an Array.
16703 * Each element of that Array represents a row of data fields. The
16704 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
16705 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
16709 var RecordDef = Roo.data.Record.create([
16710 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
16711 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
16713 var myReader = new Roo.data.ArrayReader({
16714 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
16718 * This would consume an Array like this:
16720 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
16724 * Create a new JsonReader
16725 * @param {Object} meta Metadata configuration options.
16726 * @param {Object|Array} recordType Either an Array of field definition objects
16728 * @cfg {Array} fields Array of field definition objects
16729 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
16730 * as specified to {@link Roo.data.Record#create},
16731 * or an {@link Roo.data.Record} object
16734 * created using {@link Roo.data.Record#create}.
16736 Roo.data.ArrayReader = function(meta, recordType)
16738 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType||meta.fields);
16741 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
16744 * Create a data block containing Roo.data.Records from an XML document.
16745 * @param {Object} o An Array of row objects which represents the dataset.
16746 * @return {Object} A data block which is used by an {@link Roo.data.Store} object as
16747 * a cache of Roo.data.Records.
16749 readRecords : function(o)
16751 var sid = this.meta ? this.meta.id : null;
16752 var recordType = this.recordType, fields = recordType.prototype.fields;
16755 for(var i = 0; i < root.length; i++){
16758 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
16759 for(var j = 0, jlen = fields.length; j < jlen; j++){
16760 var f = fields.items[j];
16761 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
16762 var v = n[k] !== undefined ? n[k] : f.defaultValue;
16764 values[f.name] = v;
16766 var record = new recordType(values, id);
16768 records[records.length] = record;
16772 totalRecords : records.length
16775 // used when loading children.. @see loadDataFromChildren
16776 toLoadData: function(rec)
16778 // expect rec just to be an array.. eg [a,b,c, [...] << cn ]
16779 return typeof(rec.data.cn) == 'undefined' ? [] : rec.data.cn;
16790 * @class Roo.bootstrap.form.ComboBox
16791 * @extends Roo.bootstrap.form.TriggerField
16792 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
16793 * @cfg {Boolean} append (true|false) default false
16794 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
16795 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
16796 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
16797 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
16798 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
16799 * @cfg {Boolean} animate default true
16800 * @cfg {Boolean} emptyResultText only for touch device
16801 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
16802 * @cfg {String} emptyTitle default ''
16803 * @cfg {Number} width fixed with? experimental
16805 * Create a new ComboBox.
16806 * @param {Object} config Configuration options
16808 Roo.bootstrap.form.ComboBox = function(config){
16809 Roo.bootstrap.form.ComboBox.superclass.constructor.call(this, config);
16813 * Fires when the dropdown list is expanded
16814 * @param {Roo.bootstrap.form.ComboBox} combo This combo box
16819 * Fires when the dropdown list is collapsed
16820 * @param {Roo.bootstrap.form.ComboBox} combo This combo box
16824 * @event beforeselect
16825 * Fires before a list item is selected. Return false to cancel the selection.
16826 * @param {Roo.bootstrap.form.ComboBox} combo This combo box
16827 * @param {Roo.data.Record} record The data record returned from the underlying store
16828 * @param {Number} index The index of the selected item in the dropdown list
16830 'beforeselect' : true,
16833 * Fires when a list item is selected
16834 * @param {Roo.bootstrap.form.ComboBox} combo This combo box
16835 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
16836 * @param {Number} index The index of the selected item in the dropdown list
16840 * @event beforequery
16841 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
16842 * The event object passed has these properties:
16843 * @param {Roo.bootstrap.form.ComboBox} combo This combo box
16844 * @param {String} query The query
16845 * @param {Boolean} forceAll true to force "all" query
16846 * @param {Boolean} cancel true to cancel the query
16847 * @param {Object} e The query event object
16849 'beforequery': true,
16852 * Fires when the 'add' icon is pressed (add a listener to enable add button)
16853 * @param {Roo.bootstrap.form.ComboBox} combo This combo box
16858 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
16859 * @param {Roo.bootstrap.form.ComboBox} combo This combo box
16860 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
16865 * Fires when the remove value from the combobox array
16866 * @param {Roo.bootstrap.form.ComboBox} combo This combo box
16870 * @event afterremove
16871 * Fires when the remove value from the combobox array
16872 * @param {Roo.bootstrap.form.ComboBox} combo This combo box
16874 'afterremove' : true,
16876 * @event specialfilter
16877 * Fires when specialfilter
16878 * @param {Roo.bootstrap.form.ComboBox} combo This combo box
16880 'specialfilter' : true,
16883 * Fires when tick the element
16884 * @param {Roo.bootstrap.form.ComboBox} combo This combo box
16888 * @event touchviewdisplay
16889 * Fires when touch view require special display (default is using displayField)
16890 * @param {Roo.bootstrap.form.ComboBox} combo This combo box
16891 * @param {Object} cfg set html .
16893 'touchviewdisplay' : true
16898 this.tickItems = [];
16900 this.selectedIndex = -1;
16901 if(this.mode == 'local'){
16902 if(config.queryDelay === undefined){
16903 this.queryDelay = 10;
16905 if(config.minChars === undefined){
16911 Roo.extend(Roo.bootstrap.form.ComboBox, Roo.bootstrap.form.TriggerField, {
16914 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
16915 * rendering into an Roo.Editor, defaults to false)
16918 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
16919 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
16922 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
16925 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
16926 * the dropdown list (defaults to undefined, with no header element)
16930 * @cfg {String/Roo.Template} tpl The template to use to render the output default is '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>'
16934 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
16936 listWidth: undefined,
16938 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
16939 * mode = 'remote' or 'text' if mode = 'local')
16941 displayField: undefined,
16944 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
16945 * mode = 'remote' or 'value' if mode = 'local').
16946 * Note: use of a valueField requires the user make a selection
16947 * in order for a value to be mapped.
16949 valueField: undefined,
16951 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
16956 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
16957 * field's data value (defaults to the underlying DOM element's name)
16959 hiddenName: undefined,
16961 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
16965 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
16967 selectedClass: 'active',
16970 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
16974 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
16975 * anchor positions (defaults to 'tl-bl')
16977 listAlign: 'tl-bl?',
16979 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
16983 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
16984 * query specified by the allQuery config option (defaults to 'query')
16986 triggerAction: 'query',
16988 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
16989 * (defaults to 4, does not apply if editable = false)
16993 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
16994 * delay (typeAheadDelay) if it matches a known value (defaults to false)
16998 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
16999 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
17003 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
17004 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
17008 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
17009 * when editable = true (defaults to false)
17011 selectOnFocus:false,
17013 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
17015 queryParam: 'query',
17017 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
17018 * when mode = 'remote' (defaults to 'Loading...')
17020 loadingText: 'Loading...',
17022 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
17026 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
17030 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
17031 * traditional select (defaults to true)
17035 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
17039 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
17043 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
17044 * listWidth has a higher value)
17048 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
17049 * allow the user to set arbitrary text into the field (defaults to false)
17051 forceSelection:false,
17053 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
17054 * if typeAhead = true (defaults to 250)
17056 typeAheadDelay : 250,
17058 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
17059 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
17061 valueNotFoundText : undefined,
17063 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
17065 blockFocus : false,
17068 * @cfg {Boolean} disableClear Disable showing of clear button.
17070 disableClear : false,
17072 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
17074 alwaysQuery : false,
17077 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
17082 * @cfg {String} invalidClass DEPRICATED - uses BS4 is-valid now
17084 invalidClass : "has-warning",
17087 * @cfg {String} validClass DEPRICATED - uses BS4 is-valid now
17089 validClass : "has-success",
17092 * @cfg {Boolean} specialFilter (true|false) special filter default false
17094 specialFilter : false,
17097 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
17099 mobileTouchView : true,
17102 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
17104 useNativeIOS : false,
17107 * @cfg {Boolean} mobile_restrict_height (true|false) restrict height for touch view
17109 mobile_restrict_height : false,
17111 ios_options : false,
17123 btnPosition : 'right',
17124 triggerList : true,
17125 showToggleBtn : true,
17127 emptyResultText: 'Empty',
17128 triggerText : 'Select',
17132 // element that contains real text value.. (when hidden is used..)
17134 getAutoCreate : function()
17139 * Render classic select for iso
17142 if(Roo.isIOS && this.useNativeIOS){
17143 cfg = this.getAutoCreateNativeIOS();
17151 if(Roo.isTouch && this.mobileTouchView){
17152 cfg = this.getAutoCreateTouchView();
17159 if(!this.tickable){
17160 cfg = Roo.bootstrap.form.ComboBox.superclass.getAutoCreate.call(this);
17165 * ComboBox with tickable selections
17168 var align = this.labelAlign || this.parentLabelAlign();
17171 cls : 'form-group roo-combobox-tickable' //input-group
17174 var btn_text_select = '';
17175 var btn_text_done = '';
17176 var btn_text_cancel = '';
17178 if (this.btn_text_show) {
17179 btn_text_select = 'Select';
17180 btn_text_done = 'Done';
17181 btn_text_cancel = 'Cancel';
17186 cls : 'tickable-buttons',
17191 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
17192 //html : this.triggerText
17193 html: btn_text_select
17199 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
17201 html: btn_text_done
17207 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
17209 html: btn_text_cancel
17215 buttons.cn.unshift({
17217 cls: 'roo-select2-search-field-input'
17223 Roo.each(buttons.cn, function(c){
17225 c.cls += ' btn-' + _this.size;
17228 if (_this.disabled) {
17235 style : 'display: contents',
17240 cls: 'form-hidden-field'
17244 cls: 'roo-select2-choices',
17248 cls: 'roo-select2-search-field',
17259 cls: 'roo-select2-container input-group roo-select2-container-multi',
17265 // cls: 'typeahead typeahead-long dropdown-menu',
17266 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
17271 if(this.hasFeedback && !this.allowBlank){
17275 cls: 'glyphicon form-control-feedback'
17278 combobox.cn.push(feedback);
17285 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
17286 tooltip : 'This field is required'
17288 if (Roo.bootstrap.version == 4) {
17291 style : 'display:none'
17294 if (align ==='left' && this.fieldLabel.length) {
17296 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
17303 cls : 'control-label col-form-label',
17304 html : this.fieldLabel
17316 var labelCfg = cfg.cn[1];
17317 var contentCfg = cfg.cn[2];
17320 if(this.indicatorpos == 'right'){
17326 cls : 'control-label col-form-label',
17330 html : this.fieldLabel
17346 labelCfg = cfg.cn[0];
17347 contentCfg = cfg.cn[1];
17351 if(this.labelWidth > 12){
17352 labelCfg.style = "width: " + this.labelWidth + 'px';
17354 if(this.width * 1 > 0){
17355 contentCfg.style = "width: " + this.width + 'px';
17357 if(this.labelWidth < 13 && this.labelmd == 0){
17358 this.labelmd = this.labelWidth;
17361 if(this.labellg > 0){
17362 labelCfg.cls += ' col-lg-' + this.labellg;
17363 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
17366 if(this.labelmd > 0){
17367 labelCfg.cls += ' col-md-' + this.labelmd;
17368 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
17371 if(this.labelsm > 0){
17372 labelCfg.cls += ' col-sm-' + this.labelsm;
17373 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
17376 if(this.labelxs > 0){
17377 labelCfg.cls += ' col-xs-' + this.labelxs;
17378 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
17382 } else if ( this.fieldLabel.length) {
17383 // Roo.log(" label");
17388 //cls : 'input-group-addon',
17389 html : this.fieldLabel
17394 if(this.indicatorpos == 'right'){
17398 //cls : 'input-group-addon',
17399 html : this.fieldLabel
17409 // Roo.log(" no label && no align");
17416 ['xs','sm','md','lg'].map(function(size){
17417 if (settings[size]) {
17418 cfg.cls += ' col-' + size + '-' + settings[size];
17426 _initEventsCalled : false,
17429 initEvents: function()
17431 if (this._initEventsCalled) { // as we call render... prevent looping...
17434 this._initEventsCalled = true;
17437 throw "can not find store for combo";
17440 this.indicator = this.indicatorEl();
17442 this.store = Roo.factory(this.store, Roo.data);
17443 this.store.parent = this;
17445 // if we are building from html. then this element is so complex, that we can not really
17446 // use the rendered HTML.
17447 // so we have to trash and replace the previous code.
17448 if (Roo.XComponent.build_from_html) {
17449 // remove this element....
17450 var e = this.el.dom, k=0;
17451 while (e ) { e = e.previousSibling; ++k;}
17456 this.rendered = false;
17458 this.render(this.parent().getChildContainer(true), k);
17461 if(Roo.isIOS && this.useNativeIOS){
17462 this.initIOSView();
17470 if(Roo.isTouch && this.mobileTouchView){
17471 this.initTouchView();
17476 this.initTickableEvents();
17480 Roo.bootstrap.form.ComboBox.superclass.initEvents.call(this);
17482 if(this.hiddenName){
17484 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
17486 this.hiddenField.dom.value =
17487 this.hiddenValue !== undefined ? this.hiddenValue :
17488 this.value !== undefined ? this.value : '';
17490 // prevent input submission
17491 this.el.dom.removeAttribute('name');
17492 this.hiddenField.dom.setAttribute('name', this.hiddenName);
17497 // this.el.dom.setAttribute('autocomplete', 'off');
17500 var cls = 'x-combo-list';
17502 //this.list = new Roo.Layer({
17503 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
17509 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
17510 _this.list.setWidth(lw);
17513 this.list.on('mouseover', this.onViewOver, this);
17514 this.list.on('mousemove', this.onViewMove, this);
17515 this.list.on('scroll', this.onViewScroll, this);
17518 this.list.swallowEvent('mousewheel');
17519 this.assetHeight = 0;
17522 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
17523 this.assetHeight += this.header.getHeight();
17526 this.innerList = this.list.createChild({cls:cls+'-inner'});
17527 this.innerList.on('mouseover', this.onViewOver, this);
17528 this.innerList.on('mousemove', this.onViewMove, this);
17529 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
17531 if(this.allowBlank && !this.pageSize && !this.disableClear){
17532 this.footer = this.list.createChild({cls:cls+'-ft'});
17533 this.pageTb = new Roo.Toolbar(this.footer);
17537 this.footer = this.list.createChild({cls:cls+'-ft'});
17538 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
17539 {pageSize: this.pageSize});
17543 if (this.pageTb && this.allowBlank && !this.disableClear) {
17545 this.pageTb.add(new Roo.Toolbar.Fill(), {
17546 cls: 'x-btn-icon x-btn-clear',
17548 handler: function()
17551 _this.clearValue();
17552 _this.onSelect(false, -1);
17557 this.assetHeight += this.footer.getHeight();
17562 this.tpl = Roo.bootstrap.version == 4 ?
17563 '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>' : // 4 does not need <li> and it get's really confisued.
17564 '<li><a class="dropdown-item" href="#">{' + this.displayField + '}</a></li>';
17567 this.view = new Roo.View(this.list, this.tpl, {
17568 singleSelect:true, store: this.store, selectedClass: this.selectedClass
17570 //this.view.wrapEl.setDisplayed(false);
17571 this.view.on('click', this.onViewClick, this);
17574 this.store.on('beforeload', this.onBeforeLoad, this);
17575 this.store.on('load', this.onLoad, this);
17576 this.store.on('loadexception', this.onLoadException, this);
17578 if(this.resizable){
17579 this.resizer = new Roo.Resizable(this.list, {
17580 pinned:true, handles:'se'
17582 this.resizer.on('resize', function(r, w, h){
17583 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
17584 this.listWidth = w;
17585 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
17586 this.restrictHeight();
17588 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
17591 if(!this.editable){
17592 this.editable = true;
17593 this.setEditable(false);
17598 if (typeof(this.events.add.listeners) != 'undefined') {
17600 this.addicon = this.wrap.createChild(
17601 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
17603 this.addicon.on('click', function(e) {
17604 this.fireEvent('add', this);
17607 if (typeof(this.events.edit.listeners) != 'undefined') {
17609 this.editicon = this.wrap.createChild(
17610 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
17611 if (this.addicon) {
17612 this.editicon.setStyle('margin-left', '40px');
17614 this.editicon.on('click', function(e) {
17616 // we fire even if inothing is selected..
17617 this.fireEvent('edit', this, this.lastData );
17623 this.keyNav = new Roo.KeyNav(this.inputEl(), {
17624 "up" : function(e){
17625 this.inKeyMode = true;
17629 "down" : function(e){
17630 if(!this.isExpanded()){
17631 this.onTriggerClick();
17633 this.inKeyMode = true;
17638 "enter" : function(e){
17639 // this.onViewClick();
17643 if(this.fireEvent("specialkey", this, e)){
17644 this.onViewClick(false);
17650 "esc" : function(e){
17654 "tab" : function(e){
17657 if(this.fireEvent("specialkey", this, e)){
17658 this.onViewClick(false);
17666 doRelay : function(foo, bar, hname){
17667 if(hname == 'down' || this.scope.isExpanded()){
17668 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
17677 this.queryDelay = Math.max(this.queryDelay || 10,
17678 this.mode == 'local' ? 10 : 250);
17681 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
17683 if(this.typeAhead){
17684 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
17686 if(this.editable !== false){
17687 this.inputEl().on("keyup", this.onKeyUp, this);
17689 if(this.forceSelection){
17690 this.inputEl().on('blur', this.doForce, this);
17694 this.choices = this.el.select('ul.roo-select2-choices', true).first();
17695 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
17699 initTickableEvents: function()
17703 if(this.hiddenName){
17705 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
17707 this.hiddenField.dom.value =
17708 this.hiddenValue !== undefined ? this.hiddenValue :
17709 this.value !== undefined ? this.value : '';
17711 // prevent input submission
17712 this.el.dom.removeAttribute('name');
17713 this.hiddenField.dom.setAttribute('name', this.hiddenName);
17718 // this.list = this.el.select('ul.dropdown-menu',true).first();
17720 this.choices = this.el.select('ul.roo-select2-choices', true).first();
17721 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
17722 if(this.triggerList){
17723 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
17726 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
17727 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
17729 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
17730 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
17732 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
17733 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
17735 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
17736 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
17737 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
17740 this.cancelBtn.hide();
17745 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
17746 _this.list.setWidth(lw);
17749 this.list.on('mouseover', this.onViewOver, this);
17750 this.list.on('mousemove', this.onViewMove, this);
17752 this.list.on('scroll', this.onViewScroll, this);
17755 this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}"' +
17756 'type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
17759 this.view = new Roo.View(this.list, this.tpl, {
17764 selectedClass: this.selectedClass
17767 //this.view.wrapEl.setDisplayed(false);
17768 this.view.on('click', this.onViewClick, this);
17772 this.store.on('beforeload', this.onBeforeLoad, this);
17773 this.store.on('load', this.onLoad, this);
17774 this.store.on('loadexception', this.onLoadException, this);
17777 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
17778 "up" : function(e){
17779 this.inKeyMode = true;
17783 "down" : function(e){
17784 this.inKeyMode = true;
17788 "enter" : function(e){
17789 if(this.fireEvent("specialkey", this, e)){
17790 this.onViewClick(false);
17796 "esc" : function(e){
17797 this.onTickableFooterButtonClick(e, false, false);
17800 "tab" : function(e){
17801 this.fireEvent("specialkey", this, e);
17803 this.onTickableFooterButtonClick(e, false, false);
17810 doRelay : function(e, fn, key){
17811 if(this.scope.isExpanded()){
17812 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
17821 this.queryDelay = Math.max(this.queryDelay || 10,
17822 this.mode == 'local' ? 10 : 250);
17825 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
17827 if(this.typeAhead){
17828 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
17831 if(this.editable !== false){
17832 this.tickableInputEl().on("keyup", this.onKeyUp, this);
17835 this.indicator = this.indicatorEl();
17837 if(this.indicator){
17838 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
17839 this.indicator.hide();
17844 onDestroy : function(){
17846 this.view.setStore(null);
17847 this.view.el.removeAllListeners();
17848 this.view.el.remove();
17849 this.view.purgeListeners();
17852 this.list.dom.innerHTML = '';
17856 this.store.un('beforeload', this.onBeforeLoad, this);
17857 this.store.un('load', this.onLoad, this);
17858 this.store.un('loadexception', this.onLoadException, this);
17860 Roo.bootstrap.form.ComboBox.superclass.onDestroy.call(this);
17864 fireKey : function(e){
17865 if(e.isNavKeyPress() && !this.list.isVisible()){
17866 this.fireEvent("specialkey", this, e);
17871 onResize: function(w, h)
17875 // Roo.bootstrap.form.ComboBox.superclass.onResize.apply(this, arguments);
17877 // if(typeof w != 'number'){
17878 // // we do not handle it!?!?
17881 // var tw = this.trigger.getWidth();
17882 // // tw += this.addicon ? this.addicon.getWidth() : 0;
17883 // // tw += this.editicon ? this.editicon.getWidth() : 0;
17885 // this.inputEl().setWidth( this.adjustWidth('input', x));
17887 // //this.trigger.setStyle('left', x+'px');
17889 // if(this.list && this.listWidth === undefined){
17890 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
17891 // this.list.setWidth(lw);
17892 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
17900 * Allow or prevent the user from directly editing the field text. If false is passed,
17901 * the user will only be able to select from the items defined in the dropdown list. This method
17902 * is the runtime equivalent of setting the 'editable' config option at config time.
17903 * @param {Boolean} value True to allow the user to directly edit the field text
17905 setEditable : function(value){
17906 if(value == this.editable){
17909 this.editable = value;
17911 this.inputEl().dom.setAttribute('readOnly', true);
17912 this.inputEl().on('mousedown', this.onTriggerClick, this);
17913 this.inputEl().addClass('x-combo-noedit');
17915 this.inputEl().dom.removeAttribute('readOnly');
17916 this.inputEl().un('mousedown', this.onTriggerClick, this);
17917 this.inputEl().removeClass('x-combo-noedit');
17923 onBeforeLoad : function(combo,opts){
17924 if(!this.hasFocus){
17928 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
17930 this.restrictHeight();
17931 this.selectedIndex = -1;
17935 onLoad : function(){
17937 this.hasQuery = false;
17939 if(!this.hasFocus){
17943 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
17944 this.loading.hide();
17947 if(this.store.getCount() > 0){
17950 this.restrictHeight();
17951 if(this.lastQuery == this.allQuery){
17952 if(this.editable && !this.tickable){
17953 this.inputEl().dom.select();
17957 !this.selectByValue(this.value, true) &&
17960 !this.store.lastOptions ||
17961 typeof(this.store.lastOptions.add) == 'undefined' ||
17962 this.store.lastOptions.add != true
17965 this.select(0, true);
17968 if(this.autoFocus){
17971 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
17972 this.taTask.delay(this.typeAheadDelay);
17976 this.onEmptyResults();
17982 onLoadException : function()
17984 this.hasQuery = false;
17986 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
17987 this.loading.hide();
17990 if(this.tickable && this.editable){
17995 // only causes errors at present
17996 //Roo.log(this.store.reader.jsonData);
17997 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
17999 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
18005 onTypeAhead : function(){
18006 if(this.store.getCount() > 0){
18007 var r = this.store.getAt(0);
18008 var newValue = r.data[this.displayField];
18009 var len = newValue.length;
18010 var selStart = this.getRawValue().length;
18012 if(selStart != len){
18013 this.setRawValue(newValue);
18014 this.selectText(selStart, newValue.length);
18020 onSelect : function(record, index){
18022 if(this.fireEvent('beforeselect', this, record, index) !== false){
18024 this.setFromData(index > -1 ? record.data : false);
18027 this.fireEvent('select', this, record, index);
18032 * Returns the currently selected field value or empty string if no value is set.
18033 * @return {String} value The selected value
18035 getValue : function()
18037 if(Roo.isIOS && this.useNativeIOS){
18038 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
18042 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
18045 if(this.valueField){
18046 return typeof this.value != 'undefined' ? this.value : '';
18048 return Roo.bootstrap.form.ComboBox.superclass.getValue.call(this);
18052 getRawValue : function()
18054 if(Roo.isIOS && this.useNativeIOS){
18055 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
18058 var v = this.inputEl().getValue();
18064 * Clears any text/value currently set in the field
18066 clearValue : function(){
18068 if(this.hiddenField){
18069 this.hiddenField.dom.value = '';
18072 this.setRawValue('');
18073 this.lastSelectionText = '';
18074 this.lastData = false;
18076 var close = this.closeTriggerEl();
18087 * Sets the specified value into the field. If the value finds a match, the corresponding record text
18088 * will be displayed in the field. If the value does not match the data value of an existing item,
18089 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
18090 * Otherwise the field will be blank (although the value will still be set).
18091 * @param {String} value The value to match
18093 setValue : function(v)
18095 if(Roo.isIOS && this.useNativeIOS){
18096 this.setIOSValue(v);
18106 if(this.valueField){
18107 var r = this.findRecord(this.valueField, v);
18109 text = r.data[this.displayField];
18110 }else if(this.valueNotFoundText !== undefined){
18111 text = this.valueNotFoundText;
18114 this.lastSelectionText = text;
18115 if(this.hiddenField){
18116 this.hiddenField.dom.value = v;
18118 Roo.bootstrap.form.ComboBox.superclass.setValue.call(this, text);
18121 var close = this.closeTriggerEl();
18124 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
18130 * @property {Object} the last set data for the element
18135 * Sets the value of the field based on a object which is related to the record format for the store.
18136 * @param {Object} value the value to set as. or false on reset?
18138 setFromData : function(o){
18145 var dv = ''; // display value
18146 var vv = ''; // value value..
18148 if (this.displayField) {
18149 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
18151 // this is an error condition!!!
18152 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
18155 if(this.valueField){
18156 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
18159 var close = this.closeTriggerEl();
18162 if(dv.length || vv * 1 > 0){
18164 this.blockFocus=true;
18170 if(this.hiddenField){
18171 this.hiddenField.dom.value = vv;
18173 this.lastSelectionText = dv;
18174 Roo.bootstrap.form.ComboBox.superclass.setValue.call(this, dv);
18178 // no hidden field.. - we store the value in 'value', but still display
18179 // display field!!!!
18180 this.lastSelectionText = dv;
18181 Roo.bootstrap.form.ComboBox.superclass.setValue.call(this, dv);
18188 reset : function(){
18189 // overridden so that last data is reset..
18196 this.setValue(this.originalValue);
18197 //this.clearInvalid();
18198 this.lastData = false;
18200 this.view.clearSelections();
18206 findRecord : function(prop, value){
18208 if(this.store.getCount() > 0){
18209 this.store.each(function(r){
18210 if(r.data[prop] == value){
18220 getName: function()
18222 // returns hidden if it's set..
18223 if (!this.rendered) {return ''};
18224 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
18228 onViewMove : function(e, t){
18229 this.inKeyMode = false;
18233 onViewOver : function(e, t){
18234 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
18237 var item = this.view.findItemFromChild(t);
18240 var index = this.view.indexOf(item);
18241 this.select(index, false);
18246 onViewClick : function(view, doFocus, el, e)
18248 var index = this.view.getSelectedIndexes()[0];
18250 var r = this.store.getAt(index);
18254 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
18261 Roo.each(this.tickItems, function(v,k){
18263 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
18265 _this.tickItems.splice(k, 1);
18267 if(typeof(e) == 'undefined' && view == false){
18268 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
18280 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
18281 this.tickItems.push(r.data);
18284 if(typeof(e) == 'undefined' && view == false){
18285 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
18292 this.onSelect(r, index);
18294 if(doFocus !== false && !this.blockFocus){
18295 this.inputEl().focus();
18300 restrictHeight : function(){
18301 //this.innerList.dom.style.height = '';
18302 //var inner = this.innerList.dom;
18303 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
18304 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
18305 //this.list.beginUpdate();
18306 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
18307 this.list.alignTo(this.inputEl(), this.listAlign);
18308 this.list.alignTo(this.inputEl(), this.listAlign);
18309 //this.list.endUpdate();
18313 onEmptyResults : function(){
18315 if(this.tickable && this.editable){
18316 this.hasFocus = false;
18317 this.restrictHeight();
18325 * Returns true if the dropdown list is expanded, else false.
18327 isExpanded : function(){
18328 return this.list.isVisible();
18332 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
18333 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
18334 * @param {String} value The data value of the item to select
18335 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
18336 * selected item if it is not currently in view (defaults to true)
18337 * @return {Boolean} True if the value matched an item in the list, else false
18339 selectByValue : function(v, scrollIntoView){
18340 if(v !== undefined && v !== null){
18341 var r = this.findRecord(this.valueField || this.displayField, v);
18343 this.select(this.store.indexOf(r), scrollIntoView);
18351 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
18352 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
18353 * @param {Number} index The zero-based index of the list item to select
18354 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
18355 * selected item if it is not currently in view (defaults to true)
18357 select : function(index, scrollIntoView){
18358 this.selectedIndex = index;
18359 this.view.select(index);
18360 if(scrollIntoView !== false){
18361 var el = this.view.getNode(index);
18363 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
18366 this.list.scrollChildIntoView(el, false);
18372 selectNext : function(){
18373 var ct = this.store.getCount();
18375 if(this.selectedIndex == -1){
18377 }else if(this.selectedIndex < ct-1){
18378 this.select(this.selectedIndex+1);
18384 selectPrev : function(){
18385 var ct = this.store.getCount();
18387 if(this.selectedIndex == -1){
18389 }else if(this.selectedIndex != 0){
18390 this.select(this.selectedIndex-1);
18396 onKeyUp : function(e){
18397 if(this.editable !== false && !e.isSpecialKey()){
18398 this.lastKey = e.getKey();
18399 this.dqTask.delay(this.queryDelay);
18404 validateBlur : function(){
18405 return !this.list || !this.list.isVisible();
18409 initQuery : function(){
18411 var v = this.getRawValue();
18413 if(this.tickable && this.editable){
18414 v = this.tickableInputEl().getValue();
18421 doForce : function(){
18422 if(this.inputEl().dom.value.length > 0){
18423 this.inputEl().dom.value =
18424 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
18430 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
18431 * query allowing the query action to be canceled if needed.
18432 * @param {String} query The SQL query to execute
18433 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
18434 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
18435 * saved in the current store (defaults to false)
18437 doQuery : function(q, forceAll){
18439 if(q === undefined || q === null){
18444 forceAll: forceAll,
18448 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
18453 forceAll = qe.forceAll;
18454 if(forceAll === true || (q.length >= this.minChars)){
18456 this.hasQuery = true;
18458 if(this.lastQuery != q || this.alwaysQuery){
18459 this.lastQuery = q;
18460 if(this.mode == 'local'){
18461 this.selectedIndex = -1;
18463 this.store.clearFilter();
18466 if(this.specialFilter){
18467 this.fireEvent('specialfilter', this);
18472 this.store.filter(this.displayField, q);
18475 this.store.fireEvent("datachanged", this.store);
18482 this.store.baseParams[this.queryParam] = q;
18484 var options = {params : this.getParams(q)};
18487 options.add = true;
18488 options.params.start = this.page * this.pageSize;
18491 this.store.load(options);
18494 * this code will make the page width larger, at the beginning, the list not align correctly,
18495 * we should expand the list on onLoad
18496 * so command out it
18501 this.selectedIndex = -1;
18506 this.loadNext = false;
18510 getParams : function(q){
18512 //p[this.queryParam] = q;
18516 p.limit = this.pageSize;
18522 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
18524 collapse : function(){
18525 if(!this.isExpanded()){
18531 this.hasFocus = false;
18535 this.cancelBtn.hide();
18536 this.trigger.show();
18539 this.tickableInputEl().dom.value = '';
18540 this.tickableInputEl().blur();
18545 Roo.get(document).un('mousedown', this.collapseIf, this);
18546 Roo.get(document).un('mousewheel', this.collapseIf, this);
18547 if (!this.editable) {
18548 Roo.get(document).un('keydown', this.listKeyPress, this);
18550 this.fireEvent('collapse', this);
18556 collapseIf : function(e){
18557 var in_combo = e.within(this.el);
18558 var in_list = e.within(this.list);
18559 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
18561 if (in_combo || in_list || is_list) {
18562 //e.stopPropagation();
18567 this.onTickableFooterButtonClick(e, false, false);
18575 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
18577 expand : function(){
18579 if(this.isExpanded() || !this.hasFocus){
18583 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
18584 this.list.setWidth(lw);
18590 this.restrictHeight();
18594 this.tickItems = Roo.apply([], this.item);
18597 this.cancelBtn.show();
18598 this.trigger.hide();
18601 this.tickableInputEl().focus();
18606 Roo.get(document).on('mousedown', this.collapseIf, this);
18607 Roo.get(document).on('mousewheel', this.collapseIf, this);
18608 if (!this.editable) {
18609 Roo.get(document).on('keydown', this.listKeyPress, this);
18612 this.fireEvent('expand', this);
18616 // Implements the default empty TriggerField.onTriggerClick function
18617 onTriggerClick : function(e)
18619 Roo.log('trigger click');
18621 if(this.disabled || !this.triggerList){
18626 this.loadNext = false;
18628 if(this.isExpanded()){
18630 if (!this.blockFocus) {
18631 this.inputEl().focus();
18635 this.hasFocus = true;
18636 if(this.triggerAction == 'all') {
18637 this.doQuery(this.allQuery, true);
18639 this.doQuery(this.getRawValue());
18641 if (!this.blockFocus) {
18642 this.inputEl().focus();
18647 onTickableTriggerClick : function(e)
18654 this.loadNext = false;
18655 this.hasFocus = true;
18657 if(this.triggerAction == 'all') {
18658 this.doQuery(this.allQuery, true);
18660 this.doQuery(this.getRawValue());
18664 onSearchFieldClick : function(e)
18666 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
18667 this.onTickableFooterButtonClick(e, false, false);
18671 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
18676 this.loadNext = false;
18677 this.hasFocus = true;
18679 if(this.triggerAction == 'all') {
18680 this.doQuery(this.allQuery, true);
18682 this.doQuery(this.getRawValue());
18686 listKeyPress : function(e)
18688 //Roo.log('listkeypress');
18689 // scroll to first matching element based on key pres..
18690 if (e.isSpecialKey()) {
18693 var k = String.fromCharCode(e.getKey()).toUpperCase();
18696 var csel = this.view.getSelectedNodes();
18697 var cselitem = false;
18699 var ix = this.view.indexOf(csel[0]);
18700 cselitem = this.store.getAt(ix);
18701 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
18707 this.store.each(function(v) {
18709 // start at existing selection.
18710 if (cselitem.id == v.id) {
18716 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
18717 match = this.store.indexOf(v);
18723 if (match === false) {
18724 return true; // no more action?
18727 this.view.select(match);
18728 var sn = Roo.get(this.view.getSelectedNodes()[0]);
18729 sn.scrollIntoView(sn.dom.parentNode, false);
18732 onViewScroll : function(e, t){
18734 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){
18738 this.hasQuery = true;
18740 this.loading = this.list.select('.loading', true).first();
18742 if(this.loading === null){
18743 this.list.createChild({
18745 cls: 'loading roo-select2-more-results roo-select2-active',
18746 html: 'Loading more results...'
18749 this.loading = this.list.select('.loading', true).first();
18751 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
18753 this.loading.hide();
18756 this.loading.show();
18761 this.loadNext = true;
18763 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
18768 addItem : function(o)
18770 var dv = ''; // display value
18772 if (this.displayField) {
18773 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
18775 // this is an error condition!!!
18776 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
18783 var choice = this.choices.createChild({
18785 cls: 'roo-select2-search-choice',
18794 cls: 'roo-select2-search-choice-close fa fa-times',
18799 }, this.searchField);
18801 var close = choice.select('a.roo-select2-search-choice-close', true).first();
18803 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
18811 this.inputEl().dom.value = '';
18816 onRemoveItem : function(e, _self, o)
18818 e.preventDefault();
18820 this.lastItem = Roo.apply([], this.item);
18822 var index = this.item.indexOf(o.data) * 1;
18825 Roo.log('not this item?!');
18829 this.item.splice(index, 1);
18834 this.fireEvent('remove', this, e);
18840 syncValue : function()
18842 if(!this.item.length){
18849 Roo.each(this.item, function(i){
18850 if(_this.valueField){
18851 value.push(i[_this.valueField]);
18858 this.value = value.join(',');
18860 if(this.hiddenField){
18861 this.hiddenField.dom.value = this.value;
18864 this.store.fireEvent("datachanged", this.store);
18869 clearItem : function()
18871 if(!this.multiple){
18877 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
18885 if(this.tickable && !Roo.isTouch){
18886 this.view.refresh();
18890 inputEl: function ()
18892 if(Roo.isIOS && this.useNativeIOS){
18893 return this.el.select('select.roo-ios-select', true).first();
18896 if(Roo.isTouch && this.mobileTouchView){
18897 return this.el.select('input.form-control',true).first();
18901 return this.searchField;
18904 return this.el.select('input.form-control',true).first();
18907 onTickableFooterButtonClick : function(e, btn, el)
18909 e.preventDefault();
18911 this.lastItem = Roo.apply([], this.item);
18913 if(btn && btn.name == 'cancel'){
18914 this.tickItems = Roo.apply([], this.item);
18923 Roo.each(this.tickItems, function(o){
18931 validate : function()
18933 if(this.getVisibilityEl().hasClass('hidden')){
18937 var v = this.getRawValue();
18940 v = this.getValue();
18943 if(this.disabled || this.allowBlank || v.length){
18948 this.markInvalid();
18952 tickableInputEl : function()
18954 if(!this.tickable || !this.editable){
18955 return this.inputEl();
18958 return this.inputEl().select('.roo-select2-search-field-input', true).first();
18962 getAutoCreateTouchView : function()
18967 cls: 'form-group' //input-group
18973 type : this.inputType,
18974 cls : 'form-control x-combo-noedit',
18975 autocomplete: 'new-password',
18976 placeholder : this.placeholder || '',
18981 input.name = this.name;
18985 input.cls += ' input-' + this.size;
18988 if (this.disabled) {
18989 input.disabled = true;
18993 cls : 'roo-combobox-wrap',
19000 inputblock.cls += ' input-group';
19002 inputblock.cn.unshift({
19004 cls : 'input-group-addon input-group-prepend input-group-text',
19009 if(this.removable && !this.multiple){
19010 inputblock.cls += ' roo-removable';
19012 inputblock.cn.push({
19015 cls : 'roo-combo-removable-btn close'
19019 if(this.hasFeedback && !this.allowBlank){
19021 inputblock.cls += ' has-feedback';
19023 inputblock.cn.push({
19025 cls: 'glyphicon form-control-feedback'
19032 inputblock.cls += (this.before) ? '' : ' input-group';
19034 inputblock.cn.push({
19036 cls : 'input-group-addon input-group-append input-group-text',
19042 var ibwrap = inputblock;
19047 cls: 'roo-select2-choices',
19051 cls: 'roo-select2-search-field',
19064 cls: 'roo-select2-container input-group roo-touchview-combobox ',
19069 cls: 'form-hidden-field'
19075 if(!this.multiple && this.showToggleBtn){
19081 if (this.caret != false) {
19084 cls: 'fa fa-' + this.caret
19091 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
19093 Roo.bootstrap.version == 3 ? caret : '',
19096 cls: 'combobox-clear',
19110 combobox.cls += ' roo-select2-container-multi';
19113 var required = this.allowBlank ? {
19115 style: 'display: none'
19118 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
19119 tooltip : 'This field is required'
19122 var align = this.labelAlign || this.parentLabelAlign();
19124 if (align ==='left' && this.fieldLabel.length) {
19130 cls : 'control-label col-form-label',
19131 html : this.fieldLabel
19135 cls : 'roo-combobox-wrap ',
19142 var labelCfg = cfg.cn[1];
19143 var contentCfg = cfg.cn[2];
19146 if(this.indicatorpos == 'right'){
19151 cls : 'control-label col-form-label',
19155 html : this.fieldLabel
19161 cls : "roo-combobox-wrap ",
19169 labelCfg = cfg.cn[0];
19170 contentCfg = cfg.cn[1];
19175 if(this.labelWidth > 12){
19176 labelCfg.style = "width: " + this.labelWidth + 'px';
19179 if(this.labelWidth < 13 && this.labelmd == 0){
19180 this.labelmd = this.labelWidth;
19183 if(this.labellg > 0){
19184 labelCfg.cls += ' col-lg-' + this.labellg;
19185 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
19188 if(this.labelmd > 0){
19189 labelCfg.cls += ' col-md-' + this.labelmd;
19190 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
19193 if(this.labelsm > 0){
19194 labelCfg.cls += ' col-sm-' + this.labelsm;
19195 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
19198 if(this.labelxs > 0){
19199 labelCfg.cls += ' col-xs-' + this.labelxs;
19200 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
19204 } else if ( this.fieldLabel.length) {
19209 cls : 'control-label',
19210 html : this.fieldLabel
19221 if(this.indicatorpos == 'right'){
19225 cls : 'control-label',
19226 html : this.fieldLabel,
19244 var settings = this;
19246 ['xs','sm','md','lg'].map(function(size){
19247 if (settings[size]) {
19248 cfg.cls += ' col-' + size + '-' + settings[size];
19255 initTouchView : function()
19257 this.renderTouchView();
19259 this.touchViewEl.on('scroll', function(){
19260 this.el.dom.scrollTop = 0;
19263 this.originalValue = this.getValue();
19265 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
19267 this.inputEl().on("click", this.showTouchView, this);
19268 if (this.triggerEl) {
19269 this.triggerEl.on("click", this.showTouchView, this);
19273 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
19274 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
19276 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
19278 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
19279 this.store.on('load', this.onTouchViewLoad, this);
19280 this.store.on('loadexception', this.onTouchViewLoadException, this);
19282 if(this.hiddenName){
19284 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
19286 this.hiddenField.dom.value =
19287 this.hiddenValue !== undefined ? this.hiddenValue :
19288 this.value !== undefined ? this.value : '';
19290 this.el.dom.removeAttribute('name');
19291 this.hiddenField.dom.setAttribute('name', this.hiddenName);
19295 this.choices = this.el.select('ul.roo-select2-choices', true).first();
19296 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
19299 if(this.removable && !this.multiple){
19300 var close = this.closeTriggerEl();
19302 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
19303 close.on('click', this.removeBtnClick, this, close);
19307 * fix the bug in Safari iOS8
19309 this.inputEl().on("focus", function(e){
19310 document.activeElement.blur();
19313 this._touchViewMask = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
19320 renderTouchView : function()
19322 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.form.ComboBox.touchViewTemplate);
19323 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19325 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
19326 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19328 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
19329 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19330 this.touchViewBodyEl.setStyle('overflow', 'auto');
19332 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
19333 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19335 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
19336 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19340 showTouchView : function()
19346 this.touchViewHeaderEl.hide();
19348 if(this.modalTitle.length){
19349 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
19350 this.touchViewHeaderEl.show();
19353 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
19354 this.touchViewEl.show();
19356 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
19358 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
19359 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
19361 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
19363 if(this.modalTitle.length){
19364 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
19367 this.touchViewBodyEl.setHeight(bodyHeight);
19371 (function(){ _this.touchViewEl.addClass(['in','show']); }).defer(50);
19373 this.touchViewEl.addClass(['in','show']);
19376 if(this._touchViewMask){
19377 Roo.get(document.body).addClass("x-body-masked");
19378 this._touchViewMask.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
19379 this._touchViewMask.setStyle('z-index', 10000);
19380 this._touchViewMask.addClass('show');
19383 this.doTouchViewQuery();
19387 hideTouchView : function()
19389 this.touchViewEl.removeClass(['in','show']);
19393 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
19395 this.touchViewEl.setStyle('display', 'none');
19398 if(this._touchViewMask){
19399 this._touchViewMask.removeClass('show');
19400 Roo.get(document.body).removeClass("x-body-masked");
19404 setTouchViewValue : function()
19411 Roo.each(this.tickItems, function(o){
19416 this.hideTouchView();
19419 doTouchViewQuery : function()
19428 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
19432 if(!this.alwaysQuery || this.mode == 'local'){
19433 this.onTouchViewLoad();
19440 onTouchViewBeforeLoad : function(combo,opts)
19446 onTouchViewLoad : function()
19448 if(this.store.getCount() < 1){
19449 this.onTouchViewEmptyResults();
19453 this.clearTouchView();
19455 var rawValue = this.getRawValue();
19457 var template = (this.multiple) ? Roo.bootstrap.form.ComboBox.listItemCheckbox : Roo.bootstrap.form.ComboBox.listItemRadio;
19459 this.tickItems = [];
19461 this.store.data.each(function(d, rowIndex){
19462 var row = this.touchViewListGroup.createChild(template);
19464 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
19465 row.addClass(d.data.cls);
19468 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
19471 html : d.data[this.displayField]
19474 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
19475 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
19478 row.removeClass('selected');
19479 if(!this.multiple && this.valueField &&
19480 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
19483 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
19484 row.addClass('selected');
19487 if(this.multiple && this.valueField &&
19488 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
19492 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
19493 this.tickItems.push(d.data);
19496 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
19500 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
19502 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
19504 if(this.modalTitle.length){
19505 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
19508 var listHeight = this.touchViewListGroup.getHeight() + this.touchViewBodyEl.getPadding('tb') * 2;
19510 if(this.mobile_restrict_height && listHeight < bodyHeight){
19511 this.touchViewBodyEl.setHeight(listHeight);
19516 if(firstChecked && listHeight > bodyHeight){
19517 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
19522 onTouchViewLoadException : function()
19524 this.hideTouchView();
19527 onTouchViewEmptyResults : function()
19529 this.clearTouchView();
19531 this.touchViewListGroup.createChild(Roo.bootstrap.form.ComboBox.emptyResult);
19533 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
19537 clearTouchView : function()
19539 this.touchViewListGroup.dom.innerHTML = '';
19542 onTouchViewClick : function(e, el, o)
19544 e.preventDefault();
19547 var rowIndex = o.rowIndex;
19549 var r = this.store.getAt(rowIndex);
19551 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
19553 if(!this.multiple){
19554 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
19555 c.dom.removeAttribute('checked');
19558 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
19560 this.setFromData(r.data);
19562 var close = this.closeTriggerEl();
19568 this.hideTouchView();
19570 this.fireEvent('select', this, r, rowIndex);
19575 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
19576 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
19577 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
19581 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
19582 this.addItem(r.data);
19583 this.tickItems.push(r.data);
19587 getAutoCreateNativeIOS : function()
19590 cls: 'form-group' //input-group,
19595 cls : 'roo-ios-select'
19599 combobox.name = this.name;
19602 if (this.disabled) {
19603 combobox.disabled = true;
19606 var settings = this;
19608 ['xs','sm','md','lg'].map(function(size){
19609 if (settings[size]) {
19610 cfg.cls += ' col-' + size + '-' + settings[size];
19620 initIOSView : function()
19622 this.store.on('load', this.onIOSViewLoad, this);
19627 onIOSViewLoad : function()
19629 if(this.store.getCount() < 1){
19633 this.clearIOSView();
19635 if(this.allowBlank) {
19637 var default_text = '-- SELECT --';
19639 if(this.placeholder.length){
19640 default_text = this.placeholder;
19643 if(this.emptyTitle.length){
19644 default_text += ' - ' + this.emptyTitle + ' -';
19647 var opt = this.inputEl().createChild({
19650 html : default_text
19654 o[this.valueField] = 0;
19655 o[this.displayField] = default_text;
19657 this.ios_options.push({
19664 this.store.data.each(function(d, rowIndex){
19668 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
19669 html = d.data[this.displayField];
19674 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
19675 value = d.data[this.valueField];
19684 if(this.value == d.data[this.valueField]){
19685 option['selected'] = true;
19688 var opt = this.inputEl().createChild(option);
19690 this.ios_options.push({
19697 this.inputEl().on('change', function(){
19698 this.fireEvent('select', this);
19703 clearIOSView: function()
19705 this.inputEl().dom.innerHTML = '';
19707 this.ios_options = [];
19710 setIOSValue: function(v)
19714 if(!this.ios_options){
19718 Roo.each(this.ios_options, function(opts){
19720 opts.el.dom.removeAttribute('selected');
19722 if(opts.data[this.valueField] != v){
19726 opts.el.dom.setAttribute('selected', true);
19732 * @cfg {Boolean} grow
19736 * @cfg {Number} growMin
19740 * @cfg {Number} growMax
19749 Roo.apply(Roo.bootstrap.form.ComboBox, {
19753 cls: 'modal-header',
19775 cls: 'list-group-item',
19779 cls: 'roo-combobox-list-group-item-value'
19783 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
19797 listItemCheckbox : {
19799 cls: 'list-group-item',
19803 cls: 'roo-combobox-list-group-item-value'
19807 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
19823 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
19828 cls: 'modal-footer',
19836 cls: 'col-xs-6 text-left',
19839 cls: 'btn btn-danger roo-touch-view-cancel',
19845 cls: 'col-xs-6 text-right',
19848 cls: 'btn btn-success roo-touch-view-ok',
19859 Roo.apply(Roo.bootstrap.form.ComboBox, {
19861 touchViewTemplate : {
19863 cls: 'modal fade roo-combobox-touch-view',
19867 cls: 'modal-dialog',
19868 style : 'position:fixed', // we have to fix position....
19872 cls: 'modal-content',
19874 Roo.bootstrap.form.ComboBox.header,
19875 Roo.bootstrap.form.ComboBox.body,
19876 Roo.bootstrap.form.ComboBox.footer
19885 * Ext JS Library 1.1.1
19886 * Copyright(c) 2006-2007, Ext JS, LLC.
19888 * Originally Released Under LGPL - original licence link has changed is not relivant.
19891 * <script type="text/javascript">
19896 * @extends Roo.util.Observable
19897 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
19898 * This class also supports single and multi selection modes. <br>
19899 * Create a data model bound view:
19901 var store = new Roo.data.Store(...);
19903 var view = new Roo.View({
19905 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
19907 singleSelect: true,
19908 selectedClass: "ydataview-selected",
19912 // listen for node click?
19913 view.on("click", function(vw, index, node, e){
19914 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
19918 dataModel.load("foobar.xml");
19920 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
19922 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
19923 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
19925 * Note: old style constructor is still suported (container, template, config)
19928 * Create a new View
19929 * @param {Object} config The config object
19932 Roo.View = function(config, depreciated_tpl, depreciated_config){
19934 this.parent = false;
19936 if (typeof(depreciated_tpl) == 'undefined') {
19937 // new way.. - universal constructor.
19938 Roo.apply(this, config);
19939 this.el = Roo.get(this.el);
19942 this.el = Roo.get(config);
19943 this.tpl = depreciated_tpl;
19944 Roo.apply(this, depreciated_config);
19946 this.wrapEl = this.el.wrap().wrap();
19947 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
19950 if(typeof(this.tpl) == "string"){
19951 this.tpl = new Roo.Template(this.tpl);
19953 // support xtype ctors..
19954 this.tpl = new Roo.factory(this.tpl, Roo);
19958 this.tpl.compile();
19963 * @event beforeclick
19964 * Fires before a click is processed. Returns false to cancel the default action.
19965 * @param {Roo.View} this
19966 * @param {Number} index The index of the target node
19967 * @param {HTMLElement} node The target node
19968 * @param {Roo.EventObject} e The raw event object
19970 "beforeclick" : true,
19973 * Fires when a template node is clicked.
19974 * @param {Roo.View} this
19975 * @param {Number} index The index of the target node
19976 * @param {HTMLElement} node The target node
19977 * @param {Roo.EventObject} e The raw event object
19982 * Fires when a template node is double clicked.
19983 * @param {Roo.View} this
19984 * @param {Number} index The index of the target node
19985 * @param {HTMLElement} node The target node
19986 * @param {Roo.EventObject} e The raw event object
19990 * @event contextmenu
19991 * Fires when a template node is right clicked.
19992 * @param {Roo.View} this
19993 * @param {Number} index The index of the target node
19994 * @param {HTMLElement} node The target node
19995 * @param {Roo.EventObject} e The raw event object
19997 "contextmenu" : true,
19999 * @event selectionchange
20000 * Fires when the selected nodes change.
20001 * @param {Roo.View} this
20002 * @param {Array} selections Array of the selected nodes
20004 "selectionchange" : true,
20007 * @event beforeselect
20008 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
20009 * @param {Roo.View} this
20010 * @param {HTMLElement} node The node to be selected
20011 * @param {Array} selections Array of currently selected nodes
20013 "beforeselect" : true,
20015 * @event preparedata
20016 * Fires on every row to render, to allow you to change the data.
20017 * @param {Roo.View} this
20018 * @param {Object} data to be rendered (change this)
20020 "preparedata" : true
20028 "click": this.onClick,
20029 "dblclick": this.onDblClick,
20030 "contextmenu": this.onContextMenu,
20034 this.selections = [];
20036 this.cmp = new Roo.CompositeElementLite([]);
20038 this.store = Roo.factory(this.store, Roo.data);
20039 this.setStore(this.store, true);
20042 if ( this.footer && this.footer.xtype) {
20044 var fctr = this.wrapEl.appendChild(document.createElement("div"));
20046 this.footer.dataSource = this.store;
20047 this.footer.container = fctr;
20048 this.footer = Roo.factory(this.footer, Roo);
20049 fctr.insertFirst(this.el);
20051 // this is a bit insane - as the paging toolbar seems to detach the el..
20052 // dom.parentNode.parentNode.parentNode
20053 // they get detached?
20057 Roo.View.superclass.constructor.call(this);
20062 Roo.extend(Roo.View, Roo.util.Observable, {
20065 * @cfg {Roo.data.Store} store Data store to load data from.
20070 * @cfg {String|Roo.Element} el The container element.
20075 * @cfg {String|Roo.Template} tpl The template used by this View
20079 * @cfg {String} dataName the named area of the template to use as the data area
20080 * Works with domtemplates roo-name="name"
20084 * @cfg {String} selectedClass The css class to add to selected nodes
20086 selectedClass : "x-view-selected",
20088 * @cfg {String} emptyText The empty text to show when nothing is loaded.
20093 * @cfg {String} text to display on mask (default Loading)
20097 * @cfg {Boolean} multiSelect Allow multiple selection
20099 multiSelect : false,
20101 * @cfg {Boolean} singleSelect Allow single selection
20103 singleSelect: false,
20106 * @cfg {Boolean} toggleSelect - selecting
20108 toggleSelect : false,
20111 * @cfg {Boolean} tickable - selecting
20116 * Returns the element this view is bound to.
20117 * @return {Roo.Element}
20119 getEl : function(){
20120 return this.wrapEl;
20126 * Refreshes the view. - called by datachanged on the store. - do not call directly.
20128 refresh : function(){
20129 //Roo.log('refresh');
20132 // if we are using something like 'domtemplate', then
20133 // the what gets used is:
20134 // t.applySubtemplate(NAME, data, wrapping data..)
20135 // the outer template then get' applied with
20136 // the store 'extra data'
20137 // and the body get's added to the
20138 // roo-name="data" node?
20139 // <span class='roo-tpl-{name}'></span> ?????
20143 this.clearSelections();
20144 this.el.update("");
20146 var records = this.store.getRange();
20147 if(records.length < 1) {
20149 // is this valid?? = should it render a template??
20151 this.el.update(this.emptyText);
20155 if (this.dataName) {
20156 this.el.update(t.apply(this.store.meta)); //????
20157 el = this.el.child('.roo-tpl-' + this.dataName);
20160 for(var i = 0, len = records.length; i < len; i++){
20161 var data = this.prepareData(records[i].data, i, records[i]);
20162 this.fireEvent("preparedata", this, data, i, records[i]);
20164 var d = Roo.apply({}, data);
20167 Roo.apply(d, {'roo-id' : Roo.id()});
20171 Roo.each(this.parent.item, function(item){
20172 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
20175 Roo.apply(d, {'roo-data-checked' : 'checked'});
20179 html[html.length] = Roo.util.Format.trim(
20181 t.applySubtemplate(this.dataName, d, this.store.meta) :
20188 el.update(html.join(""));
20189 this.nodes = el.dom.childNodes;
20190 this.updateIndexes(0);
20195 * Function to override to reformat the data that is sent to
20196 * the template for each node.
20197 * DEPRICATED - use the preparedata event handler.
20198 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
20199 * a JSON object for an UpdateManager bound view).
20201 prepareData : function(data, index, record)
20203 this.fireEvent("preparedata", this, data, index, record);
20207 onUpdate : function(ds, record){
20208 // Roo.log('on update');
20209 this.clearSelections();
20210 var index = this.store.indexOf(record);
20211 var n = this.nodes[index];
20212 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
20213 n.parentNode.removeChild(n);
20214 this.updateIndexes(index, index);
20220 onAdd : function(ds, records, index)
20222 //Roo.log(['on Add', ds, records, index] );
20223 this.clearSelections();
20224 if(this.nodes.length == 0){
20228 var n = this.nodes[index];
20229 for(var i = 0, len = records.length; i < len; i++){
20230 var d = this.prepareData(records[i].data, i, records[i]);
20232 this.tpl.insertBefore(n, d);
20235 this.tpl.append(this.el, d);
20238 this.updateIndexes(index);
20241 onRemove : function(ds, record, index){
20242 // Roo.log('onRemove');
20243 this.clearSelections();
20244 var el = this.dataName ?
20245 this.el.child('.roo-tpl-' + this.dataName) :
20248 el.dom.removeChild(this.nodes[index]);
20249 this.updateIndexes(index);
20253 * Refresh an individual node.
20254 * @param {Number} index
20256 refreshNode : function(index){
20257 this.onUpdate(this.store, this.store.getAt(index));
20260 updateIndexes : function(startIndex, endIndex){
20261 var ns = this.nodes;
20262 startIndex = startIndex || 0;
20263 endIndex = endIndex || ns.length - 1;
20264 for(var i = startIndex; i <= endIndex; i++){
20265 ns[i].nodeIndex = i;
20270 * Changes the data store this view uses and refresh the view.
20271 * @param {Store} store
20273 setStore : function(store, initial){
20274 if(!initial && this.store){
20275 this.store.un("datachanged", this.refresh);
20276 this.store.un("add", this.onAdd);
20277 this.store.un("remove", this.onRemove);
20278 this.store.un("update", this.onUpdate);
20279 this.store.un("clear", this.refresh);
20280 this.store.un("beforeload", this.onBeforeLoad);
20281 this.store.un("load", this.onLoad);
20282 this.store.un("loadexception", this.onLoad);
20286 store.on("datachanged", this.refresh, this);
20287 store.on("add", this.onAdd, this);
20288 store.on("remove", this.onRemove, this);
20289 store.on("update", this.onUpdate, this);
20290 store.on("clear", this.refresh, this);
20291 store.on("beforeload", this.onBeforeLoad, this);
20292 store.on("load", this.onLoad, this);
20293 store.on("loadexception", this.onLoad, this);
20301 * onbeforeLoad - masks the loading area.
20304 onBeforeLoad : function(store,opts)
20306 //Roo.log('onBeforeLoad');
20308 this.el.update("");
20310 this.el.mask(this.mask ? this.mask : "Loading" );
20312 onLoad : function ()
20319 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
20320 * @param {HTMLElement} node
20321 * @return {HTMLElement} The template node
20323 findItemFromChild : function(node){
20324 var el = this.dataName ?
20325 this.el.child('.roo-tpl-' + this.dataName,true) :
20328 if(!node || node.parentNode == el){
20331 var p = node.parentNode;
20332 while(p && p != el){
20333 if(p.parentNode == el){
20342 onClick : function(e){
20343 var item = this.findItemFromChild(e.getTarget());
20345 var index = this.indexOf(item);
20346 if(this.onItemClick(item, index, e) !== false){
20347 this.fireEvent("click", this, index, item, e);
20350 this.clearSelections();
20355 onContextMenu : function(e){
20356 var item = this.findItemFromChild(e.getTarget());
20358 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
20363 onDblClick : function(e){
20364 var item = this.findItemFromChild(e.getTarget());
20366 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
20370 onItemClick : function(item, index, e)
20372 if(this.fireEvent("beforeclick", this, index, item, e) === false){
20375 if (this.toggleSelect) {
20376 var m = this.isSelected(item) ? 'unselect' : 'select';
20379 _t[m](item, true, false);
20382 if(this.multiSelect || this.singleSelect){
20383 if(this.multiSelect && e.shiftKey && this.lastSelection){
20384 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
20386 this.select(item, this.multiSelect && e.ctrlKey);
20387 this.lastSelection = item;
20390 if(!this.tickable){
20391 e.preventDefault();
20399 * Get the number of selected nodes.
20402 getSelectionCount : function(){
20403 return this.selections.length;
20407 * Get the currently selected nodes.
20408 * @return {Array} An array of HTMLElements
20410 getSelectedNodes : function(){
20411 return this.selections;
20415 * Get the indexes of the selected nodes.
20418 getSelectedIndexes : function(){
20419 var indexes = [], s = this.selections;
20420 for(var i = 0, len = s.length; i < len; i++){
20421 indexes.push(s[i].nodeIndex);
20427 * Clear all selections
20428 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
20430 clearSelections : function(suppressEvent){
20431 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
20432 this.cmp.elements = this.selections;
20433 this.cmp.removeClass(this.selectedClass);
20434 this.selections = [];
20435 if(!suppressEvent){
20436 this.fireEvent("selectionchange", this, this.selections);
20442 * Returns true if the passed node is selected
20443 * @param {HTMLElement/Number} node The node or node index
20444 * @return {Boolean}
20446 isSelected : function(node){
20447 var s = this.selections;
20451 node = this.getNode(node);
20452 return s.indexOf(node) !== -1;
20457 * @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
20458 * @param {Boolean} keepExisting (optional) true to keep existing selections
20459 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
20461 select : function(nodeInfo, keepExisting, suppressEvent){
20462 if(nodeInfo instanceof Array){
20464 this.clearSelections(true);
20466 for(var i = 0, len = nodeInfo.length; i < len; i++){
20467 this.select(nodeInfo[i], true, true);
20471 var node = this.getNode(nodeInfo);
20472 if(!node || this.isSelected(node)){
20473 return; // already selected.
20476 this.clearSelections(true);
20479 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
20480 Roo.fly(node).addClass(this.selectedClass);
20481 this.selections.push(node);
20482 if(!suppressEvent){
20483 this.fireEvent("selectionchange", this, this.selections);
20491 * @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
20492 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
20493 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
20495 unselect : function(nodeInfo, keepExisting, suppressEvent)
20497 if(nodeInfo instanceof Array){
20498 Roo.each(this.selections, function(s) {
20499 this.unselect(s, nodeInfo);
20503 var node = this.getNode(nodeInfo);
20504 if(!node || !this.isSelected(node)){
20505 //Roo.log("not selected");
20506 return; // not selected.
20510 Roo.each(this.selections, function(s) {
20512 Roo.fly(node).removeClass(this.selectedClass);
20519 this.selections= ns;
20520 this.fireEvent("selectionchange", this, this.selections);
20524 * Gets a template node.
20525 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
20526 * @return {HTMLElement} The node or null if it wasn't found
20528 getNode : function(nodeInfo){
20529 if(typeof nodeInfo == "string"){
20530 return document.getElementById(nodeInfo);
20531 }else if(typeof nodeInfo == "number"){
20532 return this.nodes[nodeInfo];
20538 * Gets a range template nodes.
20539 * @param {Number} startIndex
20540 * @param {Number} endIndex
20541 * @return {Array} An array of nodes
20543 getNodes : function(start, end){
20544 var ns = this.nodes;
20545 start = start || 0;
20546 end = typeof end == "undefined" ? ns.length - 1 : end;
20549 for(var i = start; i <= end; i++){
20553 for(var i = start; i >= end; i--){
20561 * Finds the index of the passed node
20562 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
20563 * @return {Number} The index of the node or -1
20565 indexOf : function(node){
20566 node = this.getNode(node);
20567 if(typeof node.nodeIndex == "number"){
20568 return node.nodeIndex;
20570 var ns = this.nodes;
20571 for(var i = 0, len = ns.length; i < len; i++){
20582 * based on jquery fullcalendar
20586 Roo.bootstrap = Roo.bootstrap || {};
20588 * @class Roo.bootstrap.Calendar
20589 * @extends Roo.bootstrap.Component
20590 * Bootstrap Calendar class
20591 * @cfg {Boolean} loadMask (true|false) default false
20592 * @cfg {Object} header generate the user specific header of the calendar, default false
20595 * Create a new Container
20596 * @param {Object} config The config object
20601 Roo.bootstrap.Calendar = function(config){
20602 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
20606 * Fires when a date is selected
20607 * @param {DatePicker} this
20608 * @param {Date} date The selected date
20612 * @event monthchange
20613 * Fires when the displayed month changes
20614 * @param {DatePicker} this
20615 * @param {Date} date The selected month
20617 'monthchange': true,
20619 * @event evententer
20620 * Fires when mouse over an event
20621 * @param {Calendar} this
20622 * @param {event} Event
20624 'evententer': true,
20626 * @event eventleave
20627 * Fires when the mouse leaves an
20628 * @param {Calendar} this
20631 'eventleave': true,
20633 * @event eventclick
20634 * Fires when the mouse click an
20635 * @param {Calendar} this
20644 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
20647 * @cfg {Roo.data.Store} store
20648 * The data source for the calendar
20652 * @cfg {Number} startDay
20653 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
20661 getAutoCreate : function(){
20664 var fc_button = function(name, corner, style, content ) {
20665 return Roo.apply({},{
20667 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
20669 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
20672 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
20683 style : 'width:100%',
20690 cls : 'fc-header-left',
20692 fc_button('prev', 'left', 'arrow', '‹' ),
20693 fc_button('next', 'right', 'arrow', '›' ),
20694 { tag: 'span', cls: 'fc-header-space' },
20695 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
20703 cls : 'fc-header-center',
20707 cls: 'fc-header-title',
20710 html : 'month / year'
20718 cls : 'fc-header-right',
20720 /* fc_button('month', 'left', '', 'month' ),
20721 fc_button('week', '', '', 'week' ),
20722 fc_button('day', 'right', '', 'day' )
20734 header = this.header;
20737 var cal_heads = function() {
20739 // fixme - handle this.
20741 for (var i =0; i < Date.dayNames.length; i++) {
20742 var d = Date.dayNames[i];
20745 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
20746 html : d.substring(0,3)
20750 ret[0].cls += ' fc-first';
20751 ret[6].cls += ' fc-last';
20754 var cal_cell = function(n) {
20757 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
20762 cls: 'fc-day-number',
20766 cls: 'fc-day-content',
20770 style: 'position: relative;' // height: 17px;
20782 var cal_rows = function() {
20785 for (var r = 0; r < 6; r++) {
20792 for (var i =0; i < Date.dayNames.length; i++) {
20793 var d = Date.dayNames[i];
20794 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
20797 row.cn[0].cls+=' fc-first';
20798 row.cn[0].cn[0].style = 'min-height:90px';
20799 row.cn[6].cls+=' fc-last';
20803 ret[0].cls += ' fc-first';
20804 ret[4].cls += ' fc-prev-last';
20805 ret[5].cls += ' fc-last';
20812 cls: 'fc-border-separate',
20813 style : 'width:100%',
20821 cls : 'fc-first fc-last',
20839 cls : 'fc-content',
20840 style : "position: relative;",
20843 cls : 'fc-view fc-view-month fc-grid',
20844 style : 'position: relative',
20845 unselectable : 'on',
20848 cls : 'fc-event-container',
20849 style : 'position:absolute;z-index:8;top:0;left:0;'
20867 initEvents : function()
20870 throw "can not find store for calendar";
20876 style: "text-align:center",
20880 style: "background-color:white;width:50%;margin:250 auto",
20884 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
20895 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
20897 var size = this.el.select('.fc-content', true).first().getSize();
20898 this.maskEl.setSize(size.width, size.height);
20899 this.maskEl.enableDisplayMode("block");
20900 if(!this.loadMask){
20901 this.maskEl.hide();
20904 this.store = Roo.factory(this.store, Roo.data);
20905 this.store.on('load', this.onLoad, this);
20906 this.store.on('beforeload', this.onBeforeLoad, this);
20910 this.cells = this.el.select('.fc-day',true);
20911 //Roo.log(this.cells);
20912 this.textNodes = this.el.query('.fc-day-number');
20913 this.cells.addClassOnOver('fc-state-hover');
20915 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
20916 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
20917 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
20918 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
20920 this.on('monthchange', this.onMonthChange, this);
20922 this.update(new Date().clearTime());
20925 resize : function() {
20926 var sz = this.el.getSize();
20928 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
20929 this.el.select('.fc-day-content div',true).setHeight(34);
20934 showPrevMonth : function(e){
20935 this.update(this.activeDate.add("mo", -1));
20937 showToday : function(e){
20938 this.update(new Date().clearTime());
20941 showNextMonth : function(e){
20942 this.update(this.activeDate.add("mo", 1));
20946 showPrevYear : function(){
20947 this.update(this.activeDate.add("y", -1));
20951 showNextYear : function(){
20952 this.update(this.activeDate.add("y", 1));
20957 update : function(date)
20959 var vd = this.activeDate;
20960 this.activeDate = date;
20961 // if(vd && this.el){
20962 // var t = date.getTime();
20963 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
20964 // Roo.log('using add remove');
20966 // this.fireEvent('monthchange', this, date);
20968 // this.cells.removeClass("fc-state-highlight");
20969 // this.cells.each(function(c){
20970 // if(c.dateValue == t){
20971 // c.addClass("fc-state-highlight");
20972 // setTimeout(function(){
20973 // try{c.dom.firstChild.focus();}catch(e){}
20983 var days = date.getDaysInMonth();
20985 var firstOfMonth = date.getFirstDateOfMonth();
20986 var startingPos = firstOfMonth.getDay()-this.startDay;
20988 if(startingPos < this.startDay){
20992 var pm = date.add(Date.MONTH, -1);
20993 var prevStart = pm.getDaysInMonth()-startingPos;
20995 this.cells = this.el.select('.fc-day',true);
20996 this.textNodes = this.el.query('.fc-day-number');
20997 this.cells.addClassOnOver('fc-state-hover');
20999 var cells = this.cells.elements;
21000 var textEls = this.textNodes;
21002 Roo.each(cells, function(cell){
21003 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
21006 days += startingPos;
21008 // convert everything to numbers so it's fast
21009 var day = 86400000;
21010 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
21013 //Roo.log(prevStart);
21015 var today = new Date().clearTime().getTime();
21016 var sel = date.clearTime().getTime();
21017 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
21018 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
21019 var ddMatch = this.disabledDatesRE;
21020 var ddText = this.disabledDatesText;
21021 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
21022 var ddaysText = this.disabledDaysText;
21023 var format = this.format;
21025 var setCellClass = function(cal, cell){
21029 //Roo.log('set Cell Class');
21031 var t = d.getTime();
21035 cell.dateValue = t;
21037 cell.className += " fc-today";
21038 cell.className += " fc-state-highlight";
21039 cell.title = cal.todayText;
21042 // disable highlight in other month..
21043 //cell.className += " fc-state-highlight";
21048 cell.className = " fc-state-disabled";
21049 cell.title = cal.minText;
21053 cell.className = " fc-state-disabled";
21054 cell.title = cal.maxText;
21058 if(ddays.indexOf(d.getDay()) != -1){
21059 cell.title = ddaysText;
21060 cell.className = " fc-state-disabled";
21063 if(ddMatch && format){
21064 var fvalue = d.dateFormat(format);
21065 if(ddMatch.test(fvalue)){
21066 cell.title = ddText.replace("%0", fvalue);
21067 cell.className = " fc-state-disabled";
21071 if (!cell.initialClassName) {
21072 cell.initialClassName = cell.dom.className;
21075 cell.dom.className = cell.initialClassName + ' ' + cell.className;
21080 for(; i < startingPos; i++) {
21081 textEls[i].innerHTML = (++prevStart);
21082 d.setDate(d.getDate()+1);
21084 cells[i].className = "fc-past fc-other-month";
21085 setCellClass(this, cells[i]);
21090 for(; i < days; i++){
21091 intDay = i - startingPos + 1;
21092 textEls[i].innerHTML = (intDay);
21093 d.setDate(d.getDate()+1);
21095 cells[i].className = ''; // "x-date-active";
21096 setCellClass(this, cells[i]);
21100 for(; i < 42; i++) {
21101 textEls[i].innerHTML = (++extraDays);
21102 d.setDate(d.getDate()+1);
21104 cells[i].className = "fc-future fc-other-month";
21105 setCellClass(this, cells[i]);
21108 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
21110 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
21112 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
21113 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
21115 if(totalRows != 6){
21116 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
21117 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
21120 this.fireEvent('monthchange', this, date);
21124 if(!this.internalRender){
21125 var main = this.el.dom.firstChild;
21126 var w = main.offsetWidth;
21127 this.el.setWidth(w + this.el.getBorderWidth("lr"));
21128 Roo.fly(main).setWidth(w);
21129 this.internalRender = true;
21130 // opera does not respect the auto grow header center column
21131 // then, after it gets a width opera refuses to recalculate
21132 // without a second pass
21133 if(Roo.isOpera && !this.secondPass){
21134 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
21135 this.secondPass = true;
21136 this.update.defer(10, this, [date]);
21143 findCell : function(dt) {
21144 dt = dt.clearTime().getTime();
21146 this.cells.each(function(c){
21147 //Roo.log("check " +c.dateValue + '?=' + dt);
21148 if(c.dateValue == dt){
21158 findCells : function(ev) {
21159 var s = ev.start.clone().clearTime().getTime();
21161 var e= ev.end.clone().clearTime().getTime();
21164 this.cells.each(function(c){
21165 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
21167 if(c.dateValue > e){
21170 if(c.dateValue < s){
21179 // findBestRow: function(cells)
21183 // for (var i =0 ; i < cells.length;i++) {
21184 // ret = Math.max(cells[i].rows || 0,ret);
21191 addItem : function(ev)
21193 // look for vertical location slot in
21194 var cells = this.findCells(ev);
21196 // ev.row = this.findBestRow(cells);
21198 // work out the location.
21202 for(var i =0; i < cells.length; i++) {
21204 cells[i].row = cells[0].row;
21207 cells[i].row = cells[i].row + 1;
21217 if (crow.start.getY() == cells[i].getY()) {
21219 crow.end = cells[i];
21236 cells[0].events.push(ev);
21238 this.calevents.push(ev);
21241 clearEvents: function() {
21243 if(!this.calevents){
21247 Roo.each(this.cells.elements, function(c){
21253 Roo.each(this.calevents, function(e) {
21254 Roo.each(e.els, function(el) {
21255 el.un('mouseenter' ,this.onEventEnter, this);
21256 el.un('mouseleave' ,this.onEventLeave, this);
21261 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
21267 renderEvents: function()
21271 this.cells.each(function(c) {
21280 if(c.row != c.events.length){
21281 r = 4 - (4 - (c.row - c.events.length));
21284 c.events = ev.slice(0, r);
21285 c.more = ev.slice(r);
21287 if(c.more.length && c.more.length == 1){
21288 c.events.push(c.more.pop());
21291 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
21295 this.cells.each(function(c) {
21297 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
21300 for (var e = 0; e < c.events.length; e++){
21301 var ev = c.events[e];
21302 var rows = ev.rows;
21304 for(var i = 0; i < rows.length; i++) {
21306 // how many rows should it span..
21309 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
21310 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
21312 unselectable : "on",
21315 cls: 'fc-event-inner',
21319 // cls: 'fc-event-time',
21320 // html : cells.length > 1 ? '' : ev.time
21324 cls: 'fc-event-title',
21325 html : String.format('{0}', ev.title)
21332 cls: 'ui-resizable-handle ui-resizable-e',
21333 html : '  '
21340 cfg.cls += ' fc-event-start';
21342 if ((i+1) == rows.length) {
21343 cfg.cls += ' fc-event-end';
21346 var ctr = _this.el.select('.fc-event-container',true).first();
21347 var cg = ctr.createChild(cfg);
21349 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
21350 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
21352 var r = (c.more.length) ? 1 : 0;
21353 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
21354 cg.setWidth(ebox.right - sbox.x -2);
21356 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
21357 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
21358 cg.on('click', _this.onEventClick, _this, ev);
21369 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
21370 style : 'position: absolute',
21371 unselectable : "on",
21374 cls: 'fc-event-inner',
21378 cls: 'fc-event-title',
21386 cls: 'ui-resizable-handle ui-resizable-e',
21387 html : '  '
21393 var ctr = _this.el.select('.fc-event-container',true).first();
21394 var cg = ctr.createChild(cfg);
21396 var sbox = c.select('.fc-day-content',true).first().getBox();
21397 var ebox = c.select('.fc-day-content',true).first().getBox();
21399 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
21400 cg.setWidth(ebox.right - sbox.x -2);
21402 cg.on('click', _this.onMoreEventClick, _this, c.more);
21412 onEventEnter: function (e, el,event,d) {
21413 this.fireEvent('evententer', this, el, event);
21416 onEventLeave: function (e, el,event,d) {
21417 this.fireEvent('eventleave', this, el, event);
21420 onEventClick: function (e, el,event,d) {
21421 this.fireEvent('eventclick', this, el, event);
21424 onMonthChange: function () {
21428 onMoreEventClick: function(e, el, more)
21432 this.calpopover.placement = 'right';
21433 this.calpopover.setTitle('More');
21435 this.calpopover.setContent('');
21437 var ctr = this.calpopover.el.select('.popover-content', true).first();
21439 Roo.each(more, function(m){
21441 cls : 'fc-event-hori fc-event-draggable',
21444 var cg = ctr.createChild(cfg);
21446 cg.on('click', _this.onEventClick, _this, m);
21449 this.calpopover.show(el);
21454 onLoad: function ()
21456 this.calevents = [];
21459 if(this.store.getCount() > 0){
21460 this.store.data.each(function(d){
21463 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
21464 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
21465 time : d.data.start_time,
21466 title : d.data.title,
21467 description : d.data.description,
21468 venue : d.data.venue
21473 this.renderEvents();
21475 if(this.calevents.length && this.loadMask){
21476 this.maskEl.hide();
21480 onBeforeLoad: function()
21482 this.clearEvents();
21484 this.maskEl.show();
21498 * @class Roo.bootstrap.Popover
21499 * @extends Roo.bootstrap.Component
21500 * @parent none builder
21501 * @children Roo.bootstrap.Component
21502 * Bootstrap Popover class
21503 * @cfg {String} html contents of the popover (or false to use children..)
21504 * @cfg {String} title of popover (or false to hide)
21505 * @cfg {String|function} (right|top|bottom|left|auto) placement how it is placed
21506 * @cfg {String} trigger click || hover (or false to trigger manually)
21507 * @cfg {Boolean} modal - popovers that are modal will mask the screen, and must be closed with another event.
21508 * @cfg {String|Boolean|Roo.Element} add click hander to trigger show over what element
21509 * - if false and it has a 'parent' then it will be automatically added to that element
21510 * - if string - Roo.get will be called
21511 * @cfg {Number} delay - delay before showing
21514 * Create a new Popover
21515 * @param {Object} config The config object
21518 Roo.bootstrap.Popover = function(config){
21519 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
21525 * After the popover show
21527 * @param {Roo.bootstrap.Popover} this
21532 * After the popover hide
21534 * @param {Roo.bootstrap.Popover} this
21540 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
21545 placement : 'right',
21546 trigger : 'hover', // hover
21552 can_build_overlaid : false,
21554 maskEl : false, // the mask element
21557 alignEl : false, // when show is called with an element - this get's stored.
21559 getChildContainer : function()
21561 return this.contentEl;
21564 getPopoverHeader : function()
21566 this.title = true; // flag not to hide it..
21567 this.headerEl.addClass('p-0');
21568 return this.headerEl
21572 getAutoCreate : function(){
21575 cls : 'popover roo-dynamic shadow roo-popover' + (this.modal ? '-modal' : ''),
21576 style: 'display:block',
21582 cls : 'popover-inner ',
21586 cls: 'popover-title popover-header',
21587 html : this.title === false ? '' : this.title
21590 cls : 'popover-content popover-body ' + (this.cls || ''),
21591 html : this.html || ''
21602 * @param {string} the title
21604 setTitle: function(str)
21608 this.headerEl.dom.innerHTML = str;
21613 * @param {string} the body content
21615 setContent: function(str)
21618 if (this.contentEl) {
21619 this.contentEl.dom.innerHTML = str;
21623 // as it get's added to the bottom of the page.
21624 onRender : function(ct, position)
21626 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
21631 var cfg = Roo.apply({}, this.getAutoCreate());
21635 cfg.cls += ' ' + this.cls;
21638 cfg.style = this.style;
21640 //Roo.log("adding to ");
21641 this.el = Roo.get(document.body).createChild(cfg, position);
21642 // Roo.log(this.el);
21645 this.contentEl = this.el.select('.popover-content',true).first();
21646 this.headerEl = this.el.select('.popover-title',true).first();
21649 if(typeof(this.items) != 'undefined'){
21650 var items = this.items;
21653 for(var i =0;i < items.length;i++) {
21654 nitems.push(this.addxtype(Roo.apply({}, items[i])));
21658 this.items = nitems;
21660 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
21661 Roo.EventManager.onWindowResize(this.resizeMask, this, true);
21668 resizeMask : function()
21670 this.maskEl.setSize(
21671 Roo.lib.Dom.getViewWidth(true),
21672 Roo.lib.Dom.getViewHeight(true)
21676 initEvents : function()
21680 Roo.bootstrap.Popover.register(this);
21683 this.arrowEl = this.el.select('.arrow',true).first();
21684 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY); // probably not needed as it's default in BS4
21685 this.el.enableDisplayMode('block');
21689 if (this.over === false && !this.parent()) {
21692 if (this.triggers === false) {
21697 var on_el = (this.over == 'parent' || this.over === false) ? this.parent().el : Roo.get(this.over);
21698 var triggers = this.trigger ? this.trigger.split(' ') : [];
21699 Roo.each(triggers, function(trigger) {
21701 if (trigger == 'click') {
21702 on_el.on('click', this.toggle, this);
21703 } else if (trigger != 'manual') {
21704 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
21705 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
21707 on_el.on(eventIn ,this.enter, this);
21708 on_el.on(eventOut, this.leave, this);
21718 toggle : function () {
21719 this.hoverState == 'in' ? this.leave() : this.enter();
21722 enter : function () {
21724 clearTimeout(this.timeout);
21726 this.hoverState = 'in';
21728 if (!this.delay || !this.delay.show) {
21733 this.timeout = setTimeout(function () {
21734 if (_t.hoverState == 'in') {
21737 }, this.delay.show)
21740 leave : function() {
21741 clearTimeout(this.timeout);
21743 this.hoverState = 'out';
21745 if (!this.delay || !this.delay.hide) {
21750 this.timeout = setTimeout(function () {
21751 if (_t.hoverState == 'out') {
21754 }, this.delay.hide)
21758 * update the position of the dialog
21759 * normally this is needed if the popover get's bigger - due to a Table reload etc..
21764 doAlign : function()
21767 if (this.alignEl) {
21768 this.updatePosition(this.placement, true);
21771 // this is usually just done by the builder = to show the popoup in the middle of the scren.
21772 var es = this.el.getSize();
21773 var x = Roo.lib.Dom.getViewWidth()/2;
21774 var y = Roo.lib.Dom.getViewHeight()/2;
21775 this.el.setXY([ x-(es.width/2), y-(es.height/2)] );
21787 * @param {Roo.Element|string|Boolean} - element to align and point to. (set align to [ pos, offset ])
21788 * @param {string} (left|right|top|bottom) position
21790 show : function (on_el, placement)
21792 this.placement = typeof(placement) == 'undefined' ? this.placement : placement;
21793 on_el = on_el || false; // default to false
21796 if (this.parent() && (this.over == 'parent' || (this.over === false))) {
21797 on_el = this.parent().el;
21798 } else if (this.over) {
21799 on_el = Roo.get(this.over);
21804 this.alignEl = Roo.get( on_el );
21807 this.render(document.body);
21813 if (this.title === false) {
21814 this.headerEl.hide();
21819 this.el.dom.style.display = 'block';
21823 //var arrow = this.el.select('.arrow',true).first();
21824 //arrow.set(align[2],
21826 this.el.addClass('in');
21830 this.hoverState = 'in';
21833 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
21834 this.maskEl.setStyle('z-index', Roo.bootstrap.Popover.zIndex++);
21835 this.maskEl.dom.style.display = 'block';
21836 this.maskEl.addClass('show');
21838 this.el.setStyle('z-index', Roo.bootstrap.Popover.zIndex++);
21840 this.fireEvent('show', this);
21844 * fire this manually after loading a grid in the table for example
21845 * @param {string} (left|right|top|bottom) where to try and put it (use false to use the last one)
21846 * @param {Boolean} try and move it if we cant get right position.
21848 updatePosition : function(placement, try_move)
21850 // allow for calling with no parameters
21851 placement = placement ? placement : this.placement;
21852 try_move = typeof(try_move) == 'undefined' ? true : try_move;
21854 this.el.removeClass([
21855 'fade','top','bottom', 'left', 'right','in',
21856 'bs-popover-top','bs-popover-bottom', 'bs-popover-left', 'bs-popover-right'
21858 this.el.addClass(placement + ' bs-popover-' + placement);
21860 if (!this.alignEl ) {
21864 switch (placement) {
21866 var exact = this.el.getAlignToXY(this.alignEl, 'tl-tr', [10,0]);
21867 var offset = this.el.getAlignToXY(this.alignEl, 'tl-tr?',[10,0]);
21868 if (!try_move || exact.equals(offset) || exact[0] == offset[0] ) {
21869 //normal display... or moved up/down.
21870 this.el.setXY(offset);
21871 var xy = this.alignEl.getAnchorXY('tr', false);
21873 this.arrowEl.setXY(xy);
21876 // continue through...
21877 return this.updatePosition('left', false);
21881 var exact = this.el.getAlignToXY(this.alignEl, 'tr-tl', [-10,0]);
21882 var offset = this.el.getAlignToXY(this.alignEl, 'tr-tl?',[-10,0]);
21883 if (!try_move || exact.equals(offset) || exact[0] == offset[0] ) {
21884 //normal display... or moved up/down.
21885 this.el.setXY(offset);
21886 var xy = this.alignEl.getAnchorXY('tl', false);
21887 xy[0]-=10;xy[1]+=5; // << fix me
21888 this.arrowEl.setXY(xy);
21892 return this.updatePosition('right', false);
21895 var exact = this.el.getAlignToXY(this.alignEl, 'b-t', [0,-10]);
21896 var offset = this.el.getAlignToXY(this.alignEl, 'b-t?',[0,-10]);
21897 if (!try_move || exact.equals(offset) || exact[1] == offset[1] ) {
21898 //normal display... or moved up/down.
21899 this.el.setXY(offset);
21900 var xy = this.alignEl.getAnchorXY('t', false);
21901 xy[1]-=10; // << fix me
21902 this.arrowEl.setXY(xy);
21906 return this.updatePosition('bottom', false);
21909 var exact = this.el.getAlignToXY(this.alignEl, 't-b', [0,10]);
21910 var offset = this.el.getAlignToXY(this.alignEl, 't-b?',[0,10]);
21911 if (!try_move || exact.equals(offset) || exact[1] == offset[1] ) {
21912 //normal display... or moved up/down.
21913 this.el.setXY(offset);
21914 var xy = this.alignEl.getAnchorXY('b', false);
21915 xy[1]+=2; // << fix me
21916 this.arrowEl.setXY(xy);
21920 return this.updatePosition('top', false);
21931 this.el.setXY([0,0]);
21932 this.el.removeClass('in');
21934 this.hoverState = null;
21935 this.maskEl.hide(); // always..
21936 this.fireEvent('hide', this);
21942 Roo.apply(Roo.bootstrap.Popover, {
21945 'left' : ['r-l', [-10,0], 'left bs-popover-left'],
21946 'right' : ['l-br', [10,0], 'right bs-popover-right'],
21947 'bottom' : ['t-b', [0,10], 'top bs-popover-top'],
21948 'top' : [ 'b-t', [0,-10], 'bottom bs-popover-bottom']
21953 clickHander : false,
21957 onMouseDown : function(e)
21959 if (this.popups.length && !e.getTarget(".roo-popover")) {
21960 /// what is nothing is showing..
21969 register : function(popup)
21971 if (!Roo.bootstrap.Popover.clickHandler) {
21972 Roo.bootstrap.Popover.clickHandler = Roo.get(document).on("mousedown", Roo.bootstrap.Popover.onMouseDown, Roo.bootstrap.Popover);
21974 // hide other popups.
21975 popup.on('show', Roo.bootstrap.Popover.onShow, popup);
21976 popup.on('hide', Roo.bootstrap.Popover.onHide, popup);
21977 this.hideAll(); //<< why?
21978 //this.popups.push(popup);
21980 hideAll : function()
21982 this.popups.forEach(function(p) {
21986 onShow : function() {
21987 Roo.bootstrap.Popover.popups.push(this);
21989 onHide : function() {
21990 Roo.bootstrap.Popover.popups.remove(this);
21995 * @class Roo.bootstrap.PopoverNav
21996 * @extends Roo.bootstrap.nav.Simplebar
21997 * @parent Roo.bootstrap.Popover
21998 * @children Roo.bootstrap.nav.Group Roo.bootstrap.Container
22000 * Bootstrap Popover header navigation class
22001 * FIXME? should this go under nav?
22005 * Create a new Popover Header Navigation
22006 * @param {Object} config The config object
22009 Roo.bootstrap.PopoverNav = function(config){
22010 Roo.bootstrap.PopoverNav.superclass.constructor.call(this, config);
22013 Roo.extend(Roo.bootstrap.PopoverNav, Roo.bootstrap.nav.Simplebar, {
22016 container_method : 'getPopoverHeader'
22034 * @class Roo.bootstrap.Progress
22035 * @extends Roo.bootstrap.Component
22036 * @children Roo.bootstrap.ProgressBar
22037 * Bootstrap Progress class
22038 * @cfg {Boolean} striped striped of the progress bar
22039 * @cfg {Boolean} active animated of the progress bar
22043 * Create a new Progress
22044 * @param {Object} config The config object
22047 Roo.bootstrap.Progress = function(config){
22048 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
22051 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
22056 getAutoCreate : function(){
22064 cfg.cls += ' progress-striped';
22068 cfg.cls += ' active';
22087 * @class Roo.bootstrap.ProgressBar
22088 * @extends Roo.bootstrap.Component
22089 * Bootstrap ProgressBar class
22090 * @cfg {Number} aria_valuenow aria-value now
22091 * @cfg {Number} aria_valuemin aria-value min
22092 * @cfg {Number} aria_valuemax aria-value max
22093 * @cfg {String} label label for the progress bar
22094 * @cfg {String} panel (success | info | warning | danger )
22095 * @cfg {String} role role of the progress bar
22096 * @cfg {String} sr_only text
22100 * Create a new ProgressBar
22101 * @param {Object} config The config object
22104 Roo.bootstrap.ProgressBar = function(config){
22105 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
22108 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
22112 aria_valuemax : 100,
22118 getAutoCreate : function()
22123 cls: 'progress-bar',
22124 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
22136 cfg.role = this.role;
22139 if(this.aria_valuenow){
22140 cfg['aria-valuenow'] = this.aria_valuenow;
22143 if(this.aria_valuemin){
22144 cfg['aria-valuemin'] = this.aria_valuemin;
22147 if(this.aria_valuemax){
22148 cfg['aria-valuemax'] = this.aria_valuemax;
22151 if(this.label && !this.sr_only){
22152 cfg.html = this.label;
22156 cfg.cls += ' progress-bar-' + this.panel;
22162 update : function(aria_valuenow)
22164 this.aria_valuenow = aria_valuenow;
22166 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
22174 * @class Roo.bootstrap.TabGroup
22175 * @extends Roo.bootstrap.Column
22176 * @children Roo.bootstrap.TabPanel
22177 * Bootstrap Column class
22178 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
22179 * @cfg {Boolean} carousel true to make the group behave like a carousel
22180 * @cfg {Boolean} bullets show bullets for the panels
22181 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
22182 * @cfg {Number} timer auto slide timer .. default 0 millisecond
22183 * @cfg {Boolean} showarrow (true|false) show arrow default true
22186 * Create a new TabGroup
22187 * @param {Object} config The config object
22190 Roo.bootstrap.TabGroup = function(config){
22191 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
22193 this.navId = Roo.id();
22196 Roo.bootstrap.TabGroup.register(this);
22200 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
22203 transition : false,
22208 slideOnTouch : false,
22211 getAutoCreate : function()
22213 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
22215 cfg.cls += ' tab-content';
22217 if (this.carousel) {
22218 cfg.cls += ' carousel slide';
22221 cls : 'carousel-inner',
22225 if(this.bullets && !Roo.isTouch){
22228 cls : 'carousel-bullets',
22232 if(this.bullets_cls){
22233 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
22240 cfg.cn[0].cn.push(bullets);
22243 if(this.showarrow){
22244 cfg.cn[0].cn.push({
22246 class : 'carousel-arrow',
22250 class : 'carousel-prev',
22254 class : 'fa fa-chevron-left'
22260 class : 'carousel-next',
22264 class : 'fa fa-chevron-right'
22277 initEvents: function()
22279 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
22280 // this.el.on("touchstart", this.onTouchStart, this);
22283 if(this.autoslide){
22286 this.slideFn = window.setInterval(function() {
22287 _this.showPanelNext();
22291 if(this.showarrow){
22292 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
22293 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
22299 // onTouchStart : function(e, el, o)
22301 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
22305 // this.showPanelNext();
22309 getChildContainer : function()
22311 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
22315 * register a Navigation item
22316 * @param {Roo.bootstrap.nav.Item} the navitem to add
22318 register : function(item)
22320 this.tabs.push( item);
22321 item.navId = this.navId; // not really needed..
22326 getActivePanel : function()
22329 Roo.each(this.tabs, function(t) {
22339 getPanelByName : function(n)
22342 Roo.each(this.tabs, function(t) {
22343 if (t.tabId == n) {
22351 indexOfPanel : function(p)
22354 Roo.each(this.tabs, function(t,i) {
22355 if (t.tabId == p.tabId) {
22364 * show a specific panel
22365 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
22366 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
22368 showPanel : function (pan)
22370 if(this.transition || typeof(pan) == 'undefined'){
22371 Roo.log("waiting for the transitionend");
22375 if (typeof(pan) == 'number') {
22376 pan = this.tabs[pan];
22379 if (typeof(pan) == 'string') {
22380 pan = this.getPanelByName(pan);
22383 var cur = this.getActivePanel();
22386 Roo.log('pan or acitve pan is undefined');
22390 if (pan.tabId == this.getActivePanel().tabId) {
22394 if (false === cur.fireEvent('beforedeactivate')) {
22398 if(this.bullets > 0 && !Roo.isTouch){
22399 this.setActiveBullet(this.indexOfPanel(pan));
22402 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
22404 //class="carousel-item carousel-item-next carousel-item-left"
22406 this.transition = true;
22407 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
22408 var lr = dir == 'next' ? 'left' : 'right';
22409 pan.el.addClass(dir); // or prev
22410 pan.el.addClass('carousel-item-' + dir); // or prev
22411 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
22412 cur.el.addClass(lr); // or right
22413 pan.el.addClass(lr);
22414 cur.el.addClass('carousel-item-' +lr); // or right
22415 pan.el.addClass('carousel-item-' +lr);
22419 cur.el.on('transitionend', function() {
22420 Roo.log("trans end?");
22422 pan.el.removeClass([lr,dir, 'carousel-item-' + lr, 'carousel-item-' + dir]);
22423 pan.setActive(true);
22425 cur.el.removeClass([lr, 'carousel-item-' + lr]);
22426 cur.setActive(false);
22428 _this.transition = false;
22430 }, this, { single: true } );
22435 cur.setActive(false);
22436 pan.setActive(true);
22441 showPanelNext : function()
22443 var i = this.indexOfPanel(this.getActivePanel());
22445 if (i >= this.tabs.length - 1 && !this.autoslide) {
22449 if (i >= this.tabs.length - 1 && this.autoslide) {
22453 this.showPanel(this.tabs[i+1]);
22456 showPanelPrev : function()
22458 var i = this.indexOfPanel(this.getActivePanel());
22460 if (i < 1 && !this.autoslide) {
22464 if (i < 1 && this.autoslide) {
22465 i = this.tabs.length;
22468 this.showPanel(this.tabs[i-1]);
22472 addBullet: function()
22474 if(!this.bullets || Roo.isTouch){
22477 var ctr = this.el.select('.carousel-bullets',true).first();
22478 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
22479 var bullet = ctr.createChild({
22480 cls : 'bullet bullet-' + i
22481 },ctr.dom.lastChild);
22486 bullet.on('click', (function(e, el, o, ii, t){
22488 e.preventDefault();
22490 this.showPanel(ii);
22492 if(this.autoslide && this.slideFn){
22493 clearInterval(this.slideFn);
22494 this.slideFn = window.setInterval(function() {
22495 _this.showPanelNext();
22499 }).createDelegate(this, [i, bullet], true));
22504 setActiveBullet : function(i)
22510 Roo.each(this.el.select('.bullet', true).elements, function(el){
22511 el.removeClass('selected');
22514 var bullet = this.el.select('.bullet-' + i, true).first();
22520 bullet.addClass('selected');
22531 Roo.apply(Roo.bootstrap.TabGroup, {
22535 * register a Navigation Group
22536 * @param {Roo.bootstrap.nav.Group} the navgroup to add
22538 register : function(navgrp)
22540 this.groups[navgrp.navId] = navgrp;
22544 * fetch a Navigation Group based on the navigation ID
22545 * if one does not exist , it will get created.
22546 * @param {string} the navgroup to add
22547 * @returns {Roo.bootstrap.nav.Group} the navgroup
22549 get: function(navId) {
22550 if (typeof(this.groups[navId]) == 'undefined') {
22551 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
22553 return this.groups[navId] ;
22568 * @class Roo.bootstrap.TabPanel
22569 * @extends Roo.bootstrap.Component
22570 * @children Roo.bootstrap.Component
22571 * Bootstrap TabPanel class
22572 * @cfg {Boolean} active panel active
22573 * @cfg {String} html panel content
22574 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
22575 * @cfg {String} navId The Roo.bootstrap.nav.Group which triggers show hide ()
22576 * @cfg {String} href click to link..
22577 * @cfg {Boolean} touchSlide if swiping slides tab to next panel (default off)
22581 * Create a new TabPanel
22582 * @param {Object} config The config object
22585 Roo.bootstrap.TabPanel = function(config){
22586 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
22590 * Fires when the active status changes
22591 * @param {Roo.bootstrap.TabPanel} this
22592 * @param {Boolean} state the new state
22597 * @event beforedeactivate
22598 * Fires before a tab is de-activated - can be used to do validation on a form.
22599 * @param {Roo.bootstrap.TabPanel} this
22600 * @return {Boolean} false if there is an error
22603 'beforedeactivate': true
22606 this.tabId = this.tabId || Roo.id();
22610 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
22617 touchSlide : false,
22618 getAutoCreate : function(){
22623 // item is needed for carousel - not sure if it has any effect otherwise
22624 cls: 'carousel-item tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
22625 html: this.html || ''
22629 cfg.cls += ' active';
22633 cfg.tabId = this.tabId;
22641 initEvents: function()
22643 var p = this.parent();
22645 this.navId = this.navId || p.navId;
22647 if (typeof(this.navId) != 'undefined') {
22648 // not really needed.. but just in case.. parent should be a NavGroup.
22649 var tg = Roo.bootstrap.TabGroup.get(this.navId);
22653 var i = tg.tabs.length - 1;
22655 if(this.active && tg.bullets > 0 && i < tg.bullets){
22656 tg.setActiveBullet(i);
22660 this.el.on('click', this.onClick, this);
22662 if(Roo.isTouch && this.touchSlide){
22663 this.el.on("touchstart", this.onTouchStart, this);
22664 this.el.on("touchmove", this.onTouchMove, this);
22665 this.el.on("touchend", this.onTouchEnd, this);
22670 onRender : function(ct, position)
22672 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
22675 setActive : function(state)
22677 Roo.log("panel - set active " + this.tabId + "=" + state);
22679 this.active = state;
22681 this.el.removeClass('active');
22683 } else if (!this.el.hasClass('active')) {
22684 this.el.addClass('active');
22687 this.fireEvent('changed', this, state);
22690 onClick : function(e)
22692 e.preventDefault();
22694 if(!this.href.length){
22698 window.location.href = this.href;
22707 onTouchStart : function(e)
22709 this.swiping = false;
22711 this.startX = e.browserEvent.touches[0].clientX;
22712 this.startY = e.browserEvent.touches[0].clientY;
22715 onTouchMove : function(e)
22717 this.swiping = true;
22719 this.endX = e.browserEvent.touches[0].clientX;
22720 this.endY = e.browserEvent.touches[0].clientY;
22723 onTouchEnd : function(e)
22730 var tabGroup = this.parent();
22732 if(this.endX > this.startX){ // swiping right
22733 tabGroup.showPanelPrev();
22737 if(this.startX > this.endX){ // swiping left
22738 tabGroup.showPanelNext();
22757 * @class Roo.bootstrap.form.DateField
22758 * @extends Roo.bootstrap.form.Input
22759 * Bootstrap DateField class
22760 * @cfg {Number} weekStart default 0
22761 * @cfg {String} viewMode default empty, (months|years)
22762 * @cfg {String} minViewMode default empty, (months|years)
22763 * @cfg {Number} startDate default -Infinity
22764 * @cfg {Number} endDate default Infinity
22765 * @cfg {Boolean} todayHighlight default false
22766 * @cfg {Boolean} todayBtn default false
22767 * @cfg {Boolean} calendarWeeks default false
22768 * @cfg {Object} daysOfWeekDisabled default empty
22769 * @cfg {Boolean} singleMode default false (true | false)
22771 * @cfg {Boolean} keyboardNavigation default true
22772 * @cfg {String} language default en
22775 * Create a new DateField
22776 * @param {Object} config The config object
22779 Roo.bootstrap.form.DateField = function(config){
22780 Roo.bootstrap.form.DateField.superclass.constructor.call(this, config);
22784 * Fires when this field show.
22785 * @param {Roo.bootstrap.form.DateField} this
22786 * @param {Mixed} date The date value
22791 * Fires when this field hide.
22792 * @param {Roo.bootstrap.form.DateField} this
22793 * @param {Mixed} date The date value
22798 * Fires when select a date.
22799 * @param {Roo.bootstrap.form.DateField} this
22800 * @param {Mixed} date The date value
22804 * @event beforeselect
22805 * Fires when before select a date.
22806 * @param {Roo.bootstrap.form.DateField} this
22807 * @param {Mixed} date The date value
22809 beforeselect : true
22813 Roo.extend(Roo.bootstrap.form.DateField, Roo.bootstrap.form.Input, {
22816 * @cfg {String} format
22817 * The default date format string which can be overriden for localization support. The format must be
22818 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
22822 * @cfg {String} altFormats
22823 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
22824 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
22826 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
22834 todayHighlight : false,
22840 keyboardNavigation: true,
22842 calendarWeeks: false,
22844 startDate: -Infinity,
22848 daysOfWeekDisabled: [],
22852 singleMode : false,
22854 UTCDate: function()
22856 return new Date(Date.UTC.apply(Date, arguments));
22859 UTCToday: function()
22861 var today = new Date();
22862 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
22865 getDate: function() {
22866 var d = this.getUTCDate();
22867 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
22870 getUTCDate: function() {
22874 setDate: function(d) {
22875 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
22878 setUTCDate: function(d) {
22880 this.setValue(this.formatDate(this.date));
22883 onRender: function(ct, position)
22886 Roo.bootstrap.form.DateField.superclass.onRender.call(this, ct, position);
22888 this.language = this.language || 'en';
22889 this.language = this.language in Roo.bootstrap.form.DateField.dates ? this.language : this.language.split('-')[0];
22890 this.language = this.language in Roo.bootstrap.form.DateField.dates ? this.language : "en";
22892 this.isRTL = Roo.bootstrap.form.DateField.dates[this.language].rtl || false;
22893 this.format = this.format || 'm/d/y';
22894 this.isInline = false;
22895 this.isInput = true;
22896 this.component = this.el.select('.add-on', true).first() || false;
22897 this.component = (this.component && this.component.length === 0) ? false : this.component;
22898 this.hasInput = this.component && this.inputEl().length;
22900 if (typeof(this.minViewMode === 'string')) {
22901 switch (this.minViewMode) {
22903 this.minViewMode = 1;
22906 this.minViewMode = 2;
22909 this.minViewMode = 0;
22914 if (typeof(this.viewMode === 'string')) {
22915 switch (this.viewMode) {
22928 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.form.DateField.template);
22930 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.form.DateField.template);
22932 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
22934 this.picker().on('mousedown', this.onMousedown, this);
22935 this.picker().on('click', this.onClick, this);
22937 this.picker().addClass('datepicker-dropdown');
22939 this.startViewMode = this.viewMode;
22941 if(this.singleMode){
22942 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
22943 v.setVisibilityMode(Roo.Element.DISPLAY);
22947 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
22948 v.setStyle('width', '189px');
22952 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
22953 if(!this.calendarWeeks){
22958 v.dom.innerHTML = Roo.bootstrap.form.DateField.dates[this.language].today;
22959 v.attr('colspan', function(i, val){
22960 return parseInt(val) + 1;
22965 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
22967 this.setStartDate(this.startDate);
22968 this.setEndDate(this.endDate);
22970 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
22977 if(this.isInline) {
22982 picker : function()
22984 return this.pickerEl;
22985 // return this.el.select('.datepicker', true).first();
22988 fillDow: function()
22990 var dowCnt = this.weekStart;
22999 if(this.calendarWeeks){
23007 while (dowCnt < this.weekStart + 7) {
23011 html: Roo.bootstrap.form.DateField.dates[this.language].daysMin[(dowCnt++)%7]
23015 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
23018 fillMonths: function()
23021 var months = this.picker().select('>.datepicker-months td', true).first();
23023 months.dom.innerHTML = '';
23029 html: Roo.bootstrap.form.DateField.dates[this.language].monthsShort[i++]
23032 months.createChild(month);
23039 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;
23041 if (this.date < this.startDate) {
23042 this.viewDate = new Date(this.startDate);
23043 } else if (this.date > this.endDate) {
23044 this.viewDate = new Date(this.endDate);
23046 this.viewDate = new Date(this.date);
23054 var d = new Date(this.viewDate),
23055 year = d.getUTCFullYear(),
23056 month = d.getUTCMonth(),
23057 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
23058 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
23059 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
23060 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
23061 currentDate = this.date && this.date.valueOf(),
23062 today = this.UTCToday();
23064 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.form.DateField.dates[this.language].months[month]+' '+year;
23066 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.form.DateField.dates[this.language].today;
23068 // this.picker.select('>tfoot th.today').
23069 // .text(dates[this.language].today)
23070 // .toggle(this.todayBtn !== false);
23072 this.updateNavArrows();
23075 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
23077 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
23079 prevMonth.setUTCDate(day);
23081 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
23083 var nextMonth = new Date(prevMonth);
23085 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
23087 nextMonth = nextMonth.valueOf();
23089 var fillMonths = false;
23091 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
23093 while(prevMonth.valueOf() <= nextMonth) {
23096 if (prevMonth.getUTCDay() === this.weekStart) {
23098 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
23106 if(this.calendarWeeks){
23107 // ISO 8601: First week contains first thursday.
23108 // ISO also states week starts on Monday, but we can be more abstract here.
23110 // Start of current week: based on weekstart/current date
23111 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
23112 // Thursday of this week
23113 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
23114 // First Thursday of year, year from thursday
23115 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
23116 // Calendar week: ms between thursdays, div ms per day, div 7 days
23117 calWeek = (th - yth) / 864e5 / 7 + 1;
23119 fillMonths.cn.push({
23127 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
23129 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
23132 if (this.todayHighlight &&
23133 prevMonth.getUTCFullYear() == today.getFullYear() &&
23134 prevMonth.getUTCMonth() == today.getMonth() &&
23135 prevMonth.getUTCDate() == today.getDate()) {
23136 clsName += ' today';
23139 if (currentDate && prevMonth.valueOf() === currentDate) {
23140 clsName += ' active';
23143 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
23144 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
23145 clsName += ' disabled';
23148 fillMonths.cn.push({
23150 cls: 'day ' + clsName,
23151 html: prevMonth.getDate()
23154 prevMonth.setDate(prevMonth.getDate()+1);
23157 var currentYear = this.date && this.date.getUTCFullYear();
23158 var currentMonth = this.date && this.date.getUTCMonth();
23160 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
23162 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
23163 v.removeClass('active');
23165 if(currentYear === year && k === currentMonth){
23166 v.addClass('active');
23169 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
23170 v.addClass('disabled');
23176 year = parseInt(year/10, 10) * 10;
23178 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
23180 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
23183 for (var i = -1; i < 11; i++) {
23184 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
23186 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
23194 showMode: function(dir)
23197 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
23200 Roo.each(this.picker().select('>div',true).elements, function(v){
23201 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
23204 this.picker().select('>.datepicker-'+Roo.bootstrap.form.DateField.modes[this.viewMode].clsName, true).first().show();
23209 if(this.isInline) {
23213 this.picker().removeClass(['bottom', 'top']);
23215 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
23217 * place to the top of element!
23221 this.picker().addClass('top');
23222 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
23227 this.picker().addClass('bottom');
23229 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
23232 parseDate : function(value)
23234 if(!value || value instanceof Date){
23237 var v = Date.parseDate(value, this.format);
23238 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
23239 v = Date.parseDate(value, 'Y-m-d');
23241 if(!v && this.altFormats){
23242 if(!this.altFormatsArray){
23243 this.altFormatsArray = this.altFormats.split("|");
23245 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
23246 v = Date.parseDate(value, this.altFormatsArray[i]);
23252 formatDate : function(date, fmt)
23254 return (!date || !(date instanceof Date)) ?
23255 date : date.dateFormat(fmt || this.format);
23258 onFocus : function()
23260 Roo.bootstrap.form.DateField.superclass.onFocus.call(this);
23264 onBlur : function()
23266 Roo.bootstrap.form.DateField.superclass.onBlur.call(this);
23268 var d = this.inputEl().getValue();
23275 showPopup : function()
23277 this.picker().show();
23281 this.fireEvent('showpopup', this, this.date);
23284 hidePopup : function()
23286 if(this.isInline) {
23289 this.picker().hide();
23290 this.viewMode = this.startViewMode;
23293 this.fireEvent('hidepopup', this, this.date);
23297 onMousedown: function(e)
23299 e.stopPropagation();
23300 e.preventDefault();
23305 Roo.bootstrap.form.DateField.superclass.keyup.call(this);
23309 setValue: function(v)
23311 if(this.fireEvent('beforeselect', this, v) !== false){
23312 var d = new Date(this.parseDate(v) ).clearTime();
23314 if(isNaN(d.getTime())){
23315 this.date = this.viewDate = '';
23316 Roo.bootstrap.form.DateField.superclass.setValue.call(this, '');
23320 v = this.formatDate(d);
23322 Roo.bootstrap.form.DateField.superclass.setValue.call(this, v);
23324 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
23328 this.fireEvent('select', this, this.date);
23332 getValue: function()
23334 return this.formatDate(this.date);
23337 fireKey: function(e)
23339 if (!this.picker().isVisible()){
23340 if (e.keyCode == 27) { // allow escape to hide and re-show picker
23346 var dateChanged = false,
23348 newDate, newViewDate;
23353 e.preventDefault();
23357 if (!this.keyboardNavigation) {
23360 dir = e.keyCode == 37 ? -1 : 1;
23363 newDate = this.moveYear(this.date, dir);
23364 newViewDate = this.moveYear(this.viewDate, dir);
23365 } else if (e.shiftKey){
23366 newDate = this.moveMonth(this.date, dir);
23367 newViewDate = this.moveMonth(this.viewDate, dir);
23369 newDate = new Date(this.date);
23370 newDate.setUTCDate(this.date.getUTCDate() + dir);
23371 newViewDate = new Date(this.viewDate);
23372 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
23374 if (this.dateWithinRange(newDate)){
23375 this.date = newDate;
23376 this.viewDate = newViewDate;
23377 this.setValue(this.formatDate(this.date));
23379 e.preventDefault();
23380 dateChanged = true;
23385 if (!this.keyboardNavigation) {
23388 dir = e.keyCode == 38 ? -1 : 1;
23390 newDate = this.moveYear(this.date, dir);
23391 newViewDate = this.moveYear(this.viewDate, dir);
23392 } else if (e.shiftKey){
23393 newDate = this.moveMonth(this.date, dir);
23394 newViewDate = this.moveMonth(this.viewDate, dir);
23396 newDate = new Date(this.date);
23397 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
23398 newViewDate = new Date(this.viewDate);
23399 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
23401 if (this.dateWithinRange(newDate)){
23402 this.date = newDate;
23403 this.viewDate = newViewDate;
23404 this.setValue(this.formatDate(this.date));
23406 e.preventDefault();
23407 dateChanged = true;
23411 this.setValue(this.formatDate(this.date));
23413 e.preventDefault();
23416 this.setValue(this.formatDate(this.date));
23430 onClick: function(e)
23432 e.stopPropagation();
23433 e.preventDefault();
23435 var target = e.getTarget();
23437 if(target.nodeName.toLowerCase() === 'i'){
23438 target = Roo.get(target).dom.parentNode;
23441 var nodeName = target.nodeName;
23442 var className = target.className;
23443 var html = target.innerHTML;
23444 //Roo.log(nodeName);
23446 switch(nodeName.toLowerCase()) {
23448 switch(className) {
23454 var dir = Roo.bootstrap.form.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
23455 switch(this.viewMode){
23457 this.viewDate = this.moveMonth(this.viewDate, dir);
23461 this.viewDate = this.moveYear(this.viewDate, dir);
23467 var date = new Date();
23468 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
23470 this.setValue(this.formatDate(this.date));
23477 if (className.indexOf('disabled') < 0) {
23478 if (!this.viewDate) {
23479 this.viewDate = new Date();
23481 this.viewDate.setUTCDate(1);
23482 if (className.indexOf('month') > -1) {
23483 this.viewDate.setUTCMonth(Roo.bootstrap.form.DateField.dates[this.language].monthsShort.indexOf(html));
23485 var year = parseInt(html, 10) || 0;
23486 this.viewDate.setUTCFullYear(year);
23490 if(this.singleMode){
23491 this.setValue(this.formatDate(this.viewDate));
23502 //Roo.log(className);
23503 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
23504 var day = parseInt(html, 10) || 1;
23505 var year = (this.viewDate || new Date()).getUTCFullYear(),
23506 month = (this.viewDate || new Date()).getUTCMonth();
23508 if (className.indexOf('old') > -1) {
23515 } else if (className.indexOf('new') > -1) {
23523 //Roo.log([year,month,day]);
23524 this.date = this.UTCDate(year, month, day,0,0,0,0);
23525 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
23527 //Roo.log(this.formatDate(this.date));
23528 this.setValue(this.formatDate(this.date));
23535 setStartDate: function(startDate)
23537 this.startDate = startDate || -Infinity;
23538 if (this.startDate !== -Infinity) {
23539 this.startDate = this.parseDate(this.startDate);
23542 this.updateNavArrows();
23545 setEndDate: function(endDate)
23547 this.endDate = endDate || Infinity;
23548 if (this.endDate !== Infinity) {
23549 this.endDate = this.parseDate(this.endDate);
23552 this.updateNavArrows();
23555 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
23557 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
23558 if (typeof(this.daysOfWeekDisabled) !== 'object') {
23559 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
23561 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
23562 return parseInt(d, 10);
23565 this.updateNavArrows();
23568 updateNavArrows: function()
23570 if(this.singleMode){
23574 var d = new Date(this.viewDate),
23575 year = d.getUTCFullYear(),
23576 month = d.getUTCMonth();
23578 Roo.each(this.picker().select('.prev', true).elements, function(v){
23580 switch (this.viewMode) {
23583 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
23589 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
23596 Roo.each(this.picker().select('.next', true).elements, function(v){
23598 switch (this.viewMode) {
23601 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
23607 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
23615 moveMonth: function(date, dir)
23620 var new_date = new Date(date.valueOf()),
23621 day = new_date.getUTCDate(),
23622 month = new_date.getUTCMonth(),
23623 mag = Math.abs(dir),
23625 dir = dir > 0 ? 1 : -1;
23628 // If going back one month, make sure month is not current month
23629 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
23631 return new_date.getUTCMonth() == month;
23633 // If going forward one month, make sure month is as expected
23634 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
23636 return new_date.getUTCMonth() != new_month;
23638 new_month = month + dir;
23639 new_date.setUTCMonth(new_month);
23640 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
23641 if (new_month < 0 || new_month > 11) {
23642 new_month = (new_month + 12) % 12;
23645 // For magnitudes >1, move one month at a time...
23646 for (var i=0; i<mag; i++) {
23647 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
23648 new_date = this.moveMonth(new_date, dir);
23650 // ...then reset the day, keeping it in the new month
23651 new_month = new_date.getUTCMonth();
23652 new_date.setUTCDate(day);
23654 return new_month != new_date.getUTCMonth();
23657 // Common date-resetting loop -- if date is beyond end of month, make it
23660 new_date.setUTCDate(--day);
23661 new_date.setUTCMonth(new_month);
23666 moveYear: function(date, dir)
23668 return this.moveMonth(date, dir*12);
23671 dateWithinRange: function(date)
23673 return date >= this.startDate && date <= this.endDate;
23679 this.picker().remove();
23682 validateValue : function(value)
23684 if(this.getVisibilityEl().hasClass('hidden')){
23688 if(value.length < 1) {
23689 if(this.allowBlank){
23695 if(value.length < this.minLength){
23698 if(value.length > this.maxLength){
23702 var vt = Roo.form.VTypes;
23703 if(!vt[this.vtype](value, this)){
23707 if(typeof this.validator == "function"){
23708 var msg = this.validator(value);
23714 if(this.regex && !this.regex.test(value)){
23718 if(typeof(this.parseDate(value)) == 'undefined'){
23722 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
23726 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
23736 this.date = this.viewDate = '';
23738 Roo.bootstrap.form.DateField.superclass.setValue.call(this, '');
23743 Roo.apply(Roo.bootstrap.form.DateField, {
23754 html: '<i class="fa fa-arrow-left"/>'
23764 html: '<i class="fa fa-arrow-right"/>'
23806 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
23807 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
23808 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
23809 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
23810 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
23823 navFnc: 'FullYear',
23828 navFnc: 'FullYear',
23833 Roo.apply(Roo.bootstrap.form.DateField, {
23837 cls: 'datepicker dropdown-menu roo-dynamic shadow',
23841 cls: 'datepicker-days',
23845 cls: 'table-condensed',
23847 Roo.bootstrap.form.DateField.head,
23851 Roo.bootstrap.form.DateField.footer
23858 cls: 'datepicker-months',
23862 cls: 'table-condensed',
23864 Roo.bootstrap.form.DateField.head,
23865 Roo.bootstrap.form.DateField.content,
23866 Roo.bootstrap.form.DateField.footer
23873 cls: 'datepicker-years',
23877 cls: 'table-condensed',
23879 Roo.bootstrap.form.DateField.head,
23880 Roo.bootstrap.form.DateField.content,
23881 Roo.bootstrap.form.DateField.footer
23900 * @class Roo.bootstrap.form.TimeField
23901 * @extends Roo.bootstrap.form.Input
23902 * Bootstrap DateField class
23906 * Create a new TimeField
23907 * @param {Object} config The config object
23910 Roo.bootstrap.form.TimeField = function(config){
23911 Roo.bootstrap.form.TimeField.superclass.constructor.call(this, config);
23915 * Fires when this field show.
23916 * @param {Roo.bootstrap.form.DateField} thisthis
23917 * @param {Mixed} date The date value
23922 * Fires when this field hide.
23923 * @param {Roo.bootstrap.form.DateField} this
23924 * @param {Mixed} date The date value
23929 * Fires when select a date.
23930 * @param {Roo.bootstrap.form.DateField} this
23931 * @param {Mixed} date The date value
23937 Roo.extend(Roo.bootstrap.form.TimeField, Roo.bootstrap.form.Input, {
23940 * @cfg {String} format
23941 * The default time format string which can be overriden for localization support. The format must be
23942 * valid according to {@link Date#parseDate} (defaults to 'H:i').
23946 getAutoCreate : function()
23948 this.after = '<i class="fa far fa-clock"></i>';
23949 return Roo.bootstrap.form.TimeField.superclass.getAutoCreate.call(this);
23953 onRender: function(ct, position)
23956 Roo.bootstrap.form.TimeField.superclass.onRender.call(this, ct, position);
23958 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.form.TimeField.template);
23960 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
23962 this.pop = this.picker().select('>.datepicker-time',true).first();
23963 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
23965 this.picker().on('mousedown', this.onMousedown, this);
23966 this.picker().on('click', this.onClick, this);
23968 this.picker().addClass('datepicker-dropdown');
23973 this.pop.select('.hours-up', true).first().on('click', this.onIncrementHours, this);
23974 this.pop.select('.hours-down', true).first().on('click', this.onDecrementHours, this);
23975 this.pop.select('.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
23976 this.pop.select('.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
23977 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
23978 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
23982 fireKey: function(e){
23983 if (!this.picker().isVisible()){
23984 if (e.keyCode == 27) { // allow escape to hide and re-show picker
23990 e.preventDefault();
23998 this.onTogglePeriod();
24001 this.onIncrementMinutes();
24004 this.onDecrementMinutes();
24013 onClick: function(e) {
24014 e.stopPropagation();
24015 e.preventDefault();
24018 picker : function()
24020 return this.pickerEl;
24023 fillTime: function()
24025 var time = this.pop.select('tbody', true).first();
24027 time.dom.innerHTML = '';
24042 cls: 'hours-up fa fas fa-chevron-up'
24062 cls: 'minutes-up fa fas fa-chevron-up'
24083 cls: 'timepicker-hour',
24098 cls: 'timepicker-minute',
24113 cls: 'btn btn-primary period',
24135 cls: 'hours-down fa fas fa-chevron-down'
24155 cls: 'minutes-down fa fas fa-chevron-down'
24173 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
24180 var hours = this.time.getHours();
24181 var minutes = this.time.getMinutes();
24194 hours = hours - 12;
24198 hours = '0' + hours;
24202 minutes = '0' + minutes;
24205 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
24206 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
24207 this.pop.select('button', true).first().dom.innerHTML = period;
24213 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
24215 var cls = ['bottom'];
24217 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
24224 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
24228 //this.picker().setXY(20000,20000);
24229 this.picker().addClass(cls.join('-'));
24233 Roo.each(cls, function(c){
24238 _this.picker().alignTo(_this.inputEl(), "tr-br", [0, 10], false);
24239 //_this.picker().setTop(_this.inputEl().getHeight());
24243 _this.picker().alignTo(_this.inputEl(), "br-tr", [0, 10], false);
24245 //_this.picker().setTop(0 - _this.picker().getHeight());
24250 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
24254 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
24262 onFocus : function()
24264 Roo.bootstrap.form.TimeField.superclass.onFocus.call(this);
24268 onBlur : function()
24270 Roo.bootstrap.form.TimeField.superclass.onBlur.call(this);
24276 this.picker().show();
24281 this.fireEvent('show', this, this.date);
24286 this.picker().hide();
24289 this.fireEvent('hide', this, this.date);
24292 setTime : function()
24295 this.setValue(this.time.format(this.format));
24297 this.fireEvent('select', this, this.date);
24302 onMousedown: function(e){
24303 e.stopPropagation();
24304 e.preventDefault();
24307 onIncrementHours: function()
24309 Roo.log('onIncrementHours');
24310 this.time = this.time.add(Date.HOUR, 1);
24315 onDecrementHours: function()
24317 Roo.log('onDecrementHours');
24318 this.time = this.time.add(Date.HOUR, -1);
24322 onIncrementMinutes: function()
24324 Roo.log('onIncrementMinutes');
24325 this.time = this.time.add(Date.MINUTE, 1);
24329 onDecrementMinutes: function()
24331 Roo.log('onDecrementMinutes');
24332 this.time = this.time.add(Date.MINUTE, -1);
24336 onTogglePeriod: function()
24338 Roo.log('onTogglePeriod');
24339 this.time = this.time.add(Date.HOUR, 12);
24347 Roo.apply(Roo.bootstrap.form.TimeField, {
24351 cls: 'datepicker dropdown-menu',
24355 cls: 'datepicker-time',
24359 cls: 'table-condensed',
24388 cls: 'btn btn-info ok',
24416 * @class Roo.bootstrap.form.MonthField
24417 * @extends Roo.bootstrap.form.Input
24418 * Bootstrap MonthField class
24420 * @cfg {String} language default en
24423 * Create a new MonthField
24424 * @param {Object} config The config object
24427 Roo.bootstrap.form.MonthField = function(config){
24428 Roo.bootstrap.form.MonthField.superclass.constructor.call(this, config);
24433 * Fires when this field show.
24434 * @param {Roo.bootstrap.form.MonthField} this
24435 * @param {Mixed} date The date value
24440 * Fires when this field hide.
24441 * @param {Roo.bootstrap.form.MonthField} this
24442 * @param {Mixed} date The date value
24447 * Fires when select a date.
24448 * @param {Roo.bootstrap.form.MonthField} this
24449 * @param {String} oldvalue The old value
24450 * @param {String} newvalue The new value
24456 Roo.extend(Roo.bootstrap.form.MonthField, Roo.bootstrap.form.Input, {
24458 onRender: function(ct, position)
24461 Roo.bootstrap.form.MonthField.superclass.onRender.call(this, ct, position);
24463 this.language = this.language || 'en';
24464 this.language = this.language in Roo.bootstrap.form.MonthField.dates ? this.language : this.language.split('-')[0];
24465 this.language = this.language in Roo.bootstrap.form.MonthField.dates ? this.language : "en";
24467 this.isRTL = Roo.bootstrap.form.MonthField.dates[this.language].rtl || false;
24468 this.isInline = false;
24469 this.isInput = true;
24470 this.component = this.el.select('.add-on', true).first() || false;
24471 this.component = (this.component && this.component.length === 0) ? false : this.component;
24472 this.hasInput = this.component && this.inputEL().length;
24474 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.form.MonthField.template);
24476 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
24478 this.picker().on('mousedown', this.onMousedown, this);
24479 this.picker().on('click', this.onClick, this);
24481 this.picker().addClass('datepicker-dropdown');
24483 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
24484 v.setStyle('width', '189px');
24491 if(this.isInline) {
24497 setValue: function(v, suppressEvent)
24499 var o = this.getValue();
24501 Roo.bootstrap.form.MonthField.superclass.setValue.call(this, v);
24505 if(suppressEvent !== true){
24506 this.fireEvent('select', this, o, v);
24511 getValue: function()
24516 onClick: function(e)
24518 e.stopPropagation();
24519 e.preventDefault();
24521 var target = e.getTarget();
24523 if(target.nodeName.toLowerCase() === 'i'){
24524 target = Roo.get(target).dom.parentNode;
24527 var nodeName = target.nodeName;
24528 var className = target.className;
24529 var html = target.innerHTML;
24531 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
24535 this.vIndex = Roo.bootstrap.form.MonthField.dates[this.language].monthsShort.indexOf(html);
24537 this.setValue(Roo.bootstrap.form.MonthField.dates[this.language].months[this.vIndex]);
24543 picker : function()
24545 return this.pickerEl;
24548 fillMonths: function()
24551 var months = this.picker().select('>.datepicker-months td', true).first();
24553 months.dom.innerHTML = '';
24559 html: Roo.bootstrap.form.MonthField.dates[this.language].monthsShort[i++]
24562 months.createChild(month);
24571 if(typeof(this.vIndex) == 'undefined' && this.value.length){
24572 this.vIndex = Roo.bootstrap.form.MonthField.dates[this.language].months.indexOf(this.value);
24575 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
24576 e.removeClass('active');
24578 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
24579 e.addClass('active');
24586 if(this.isInline) {
24590 this.picker().removeClass(['bottom', 'top']);
24592 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
24594 * place to the top of element!
24598 this.picker().addClass('top');
24599 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
24604 this.picker().addClass('bottom');
24606 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
24609 onFocus : function()
24611 Roo.bootstrap.form.MonthField.superclass.onFocus.call(this);
24615 onBlur : function()
24617 Roo.bootstrap.form.MonthField.superclass.onBlur.call(this);
24619 var d = this.inputEl().getValue();
24628 this.picker().show();
24629 this.picker().select('>.datepicker-months', true).first().show();
24633 this.fireEvent('show', this, this.date);
24638 if(this.isInline) {
24641 this.picker().hide();
24642 this.fireEvent('hide', this, this.date);
24646 onMousedown: function(e)
24648 e.stopPropagation();
24649 e.preventDefault();
24654 Roo.bootstrap.form.MonthField.superclass.keyup.call(this);
24658 fireKey: function(e)
24660 if (!this.picker().isVisible()){
24661 if (e.keyCode == 27) {// allow escape to hide and re-show picker
24672 e.preventDefault();
24676 dir = e.keyCode == 37 ? -1 : 1;
24678 this.vIndex = this.vIndex + dir;
24680 if(this.vIndex < 0){
24684 if(this.vIndex > 11){
24688 if(isNaN(this.vIndex)){
24692 this.setValue(Roo.bootstrap.form.MonthField.dates[this.language].months[this.vIndex]);
24698 dir = e.keyCode == 38 ? -1 : 1;
24700 this.vIndex = this.vIndex + dir * 4;
24702 if(this.vIndex < 0){
24706 if(this.vIndex > 11){
24710 if(isNaN(this.vIndex)){
24714 this.setValue(Roo.bootstrap.form.MonthField.dates[this.language].months[this.vIndex]);
24719 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
24720 this.setValue(Roo.bootstrap.form.MonthField.dates[this.language].months[this.vIndex]);
24724 e.preventDefault();
24727 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
24728 this.setValue(Roo.bootstrap.form.MonthField.dates[this.language].months[this.vIndex]);
24744 this.picker().remove();
24749 Roo.apply(Roo.bootstrap.form.MonthField, {
24768 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
24769 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
24774 Roo.apply(Roo.bootstrap.form.MonthField, {
24778 cls: 'datepicker dropdown-menu roo-dynamic',
24782 cls: 'datepicker-months',
24786 cls: 'table-condensed',
24788 Roo.bootstrap.form.DateField.content
24808 * @class Roo.bootstrap.form.CheckBox
24809 * @extends Roo.bootstrap.form.Input
24810 * Bootstrap CheckBox class
24812 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
24813 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
24814 * @cfg {String} boxLabel The text that appears beside the checkbox
24815 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
24816 * @cfg {Boolean} checked initnal the element
24817 * @cfg {Boolean} inline inline the element (default false)
24818 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
24819 * @cfg {String} tooltip label tooltip
24822 * Create a new CheckBox
24823 * @param {Object} config The config object
24826 Roo.bootstrap.form.CheckBox = function(config){
24827 Roo.bootstrap.form.CheckBox.superclass.constructor.call(this, config);
24832 * Fires when the element is checked or unchecked.
24833 * @param {Roo.bootstrap.form.CheckBox} this This input
24834 * @param {Boolean} checked The new checked value
24839 * Fires when the element is click.
24840 * @param {Roo.bootstrap.form.CheckBox} this This input
24847 Roo.extend(Roo.bootstrap.form.CheckBox, Roo.bootstrap.form.Input, {
24849 inputType: 'checkbox',
24858 // checkbox success does not make any sense really..
24863 getAutoCreate : function()
24865 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
24871 cfg.cls = 'form-group form-check ' + this.inputType; //input-group
24874 cfg.cls += ' ' + this.inputType + '-inline form-check-inline';
24880 type : this.inputType,
24881 value : this.inputValue,
24882 cls : 'roo-' + this.inputType, //'form-box',
24883 placeholder : this.placeholder || ''
24887 if(this.inputType != 'radio'){
24891 cls : 'roo-hidden-value',
24892 value : this.checked ? this.inputValue : this.valueOff
24897 if (this.weight) { // Validity check?
24898 cfg.cls += " " + this.inputType + "-" + this.weight;
24901 if (this.disabled) {
24902 input.disabled=true;
24906 input.checked = this.checked;
24911 input.name = this.name;
24913 if(this.inputType != 'radio'){
24914 hidden.name = this.name;
24915 input.name = '_hidden_' + this.name;
24920 input.cls += ' input-' + this.size;
24925 ['xs','sm','md','lg'].map(function(size){
24926 if (settings[size]) {
24927 cfg.cls += ' col-' + size + '-' + settings[size];
24931 var inputblock = input;
24933 if (this.before || this.after) {
24936 cls : 'input-group',
24941 inputblock.cn.push({
24943 cls : 'input-group-addon',
24948 inputblock.cn.push(input);
24950 if(this.inputType != 'radio'){
24951 inputblock.cn.push(hidden);
24955 inputblock.cn.push({
24957 cls : 'input-group-addon',
24963 var boxLabelCfg = false;
24969 //'for': id, // box label is handled by onclick - so no for...
24971 html: this.boxLabel
24974 boxLabelCfg.tooltip = this.tooltip;
24980 if (align ==='left' && this.fieldLabel.length) {
24981 // Roo.log("left and has label");
24986 cls : 'control-label',
24987 html : this.fieldLabel
24998 cfg.cn[1].cn.push(boxLabelCfg);
25001 if(this.labelWidth > 12){
25002 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
25005 if(this.labelWidth < 13 && this.labelmd == 0){
25006 this.labelmd = this.labelWidth;
25009 if(this.labellg > 0){
25010 cfg.cn[0].cls += ' col-lg-' + this.labellg;
25011 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
25014 if(this.labelmd > 0){
25015 cfg.cn[0].cls += ' col-md-' + this.labelmd;
25016 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
25019 if(this.labelsm > 0){
25020 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
25021 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
25024 if(this.labelxs > 0){
25025 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
25026 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
25029 } else if ( this.fieldLabel.length) {
25030 // Roo.log(" label");
25034 tag: this.boxLabel ? 'span' : 'label',
25036 cls: 'control-label box-input-label',
25037 //cls : 'input-group-addon',
25038 html : this.fieldLabel
25045 cfg.cn.push(boxLabelCfg);
25050 // Roo.log(" no label && no align");
25051 cfg.cn = [ inputblock ] ;
25053 cfg.cn.push(boxLabelCfg);
25061 if(this.inputType != 'radio'){
25062 cfg.cn.push(hidden);
25070 * return the real input element.
25072 inputEl: function ()
25074 return this.el.select('input.roo-' + this.inputType,true).first();
25076 hiddenEl: function ()
25078 return this.el.select('input.roo-hidden-value',true).first();
25081 labelEl: function()
25083 return this.el.select('label.control-label',true).first();
25085 /* depricated... */
25089 return this.labelEl();
25092 boxLabelEl: function()
25094 return this.el.select('label.box-label',true).first();
25097 initEvents : function()
25099 // Roo.bootstrap.form.CheckBox.superclass.initEvents.call(this);
25101 this.inputEl().on('click', this.onClick, this);
25103 if (this.boxLabel) {
25104 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
25107 this.startValue = this.getValue();
25110 Roo.bootstrap.form.CheckBox.register(this);
25114 onClick : function(e)
25116 if(this.fireEvent('click', this, e) !== false){
25117 this.setChecked(!this.checked);
25122 setChecked : function(state,suppressEvent)
25124 this.startValue = this.getValue();
25126 if(this.inputType == 'radio'){
25128 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
25129 e.dom.checked = false;
25132 this.inputEl().dom.checked = true;
25134 this.inputEl().dom.value = this.inputValue;
25136 if(suppressEvent !== true){
25137 this.fireEvent('check', this, true);
25145 this.checked = state;
25147 this.inputEl().dom.checked = state;
25150 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
25152 if(suppressEvent !== true){
25153 this.fireEvent('check', this, state);
25159 getValue : function()
25161 if(this.inputType == 'radio'){
25162 return this.getGroupValue();
25165 return this.hiddenEl().dom.value;
25169 getGroupValue : function()
25171 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
25175 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
25178 setValue : function(v,suppressEvent)
25180 if(this.inputType == 'radio'){
25181 this.setGroupValue(v, suppressEvent);
25185 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
25190 setGroupValue : function(v, suppressEvent)
25192 this.startValue = this.getValue();
25194 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
25195 e.dom.checked = false;
25197 if(e.dom.value == v){
25198 e.dom.checked = true;
25202 if(suppressEvent !== true){
25203 this.fireEvent('check', this, true);
25211 validate : function()
25213 if(this.getVisibilityEl().hasClass('hidden')){
25219 (this.inputType == 'radio' && this.validateRadio()) ||
25220 (this.inputType == 'checkbox' && this.validateCheckbox())
25226 this.markInvalid();
25230 validateRadio : function()
25232 if(this.getVisibilityEl().hasClass('hidden')){
25236 if(this.allowBlank){
25242 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
25243 if(!e.dom.checked){
25255 validateCheckbox : function()
25258 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
25259 //return (this.getValue() == this.inputValue) ? true : false;
25262 var group = Roo.bootstrap.form.CheckBox.get(this.groupId);
25270 for(var i in group){
25271 if(group[i].el.isVisible(true)){
25279 for(var i in group){
25284 r = (group[i].getValue() == group[i].inputValue) ? true : false;
25291 * Mark this field as valid
25293 markValid : function()
25297 this.fireEvent('valid', this);
25299 var label = Roo.bootstrap.form.FieldLabel.get(this.name + '-group');
25302 label = Roo.bootstrap.form.FieldLabel.get(this.groupId + '-group');
25309 if(this.inputType == 'radio'){
25310 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
25311 var fg = e.findParent('.form-group', false, true);
25312 if (Roo.bootstrap.version == 3) {
25313 fg.removeClass([_this.invalidClass, _this.validClass]);
25314 fg.addClass(_this.validClass);
25316 fg.removeClass(['is-valid', 'is-invalid']);
25317 fg.addClass('is-valid');
25325 var fg = this.el.findParent('.form-group', false, true);
25326 if (Roo.bootstrap.version == 3) {
25327 fg.removeClass([this.invalidClass, this.validClass]);
25328 fg.addClass(this.validClass);
25330 fg.removeClass(['is-valid', 'is-invalid']);
25331 fg.addClass('is-valid');
25336 var group = Roo.bootstrap.form.CheckBox.get(this.groupId);
25342 for(var i in group){
25343 var fg = group[i].el.findParent('.form-group', false, true);
25344 if (Roo.bootstrap.version == 3) {
25345 fg.removeClass([this.invalidClass, this.validClass]);
25346 fg.addClass(this.validClass);
25348 fg.removeClass(['is-valid', 'is-invalid']);
25349 fg.addClass('is-valid');
25355 * Mark this field as invalid
25356 * @param {String} msg The validation message
25358 markInvalid : function(msg)
25360 if(this.allowBlank){
25366 this.fireEvent('invalid', this, msg);
25368 var label = Roo.bootstrap.form.FieldLabel.get(this.name + '-group');
25371 label = Roo.bootstrap.form.FieldLabel.get(this.groupId + '-group');
25375 label.markInvalid();
25378 if(this.inputType == 'radio'){
25380 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
25381 var fg = e.findParent('.form-group', false, true);
25382 if (Roo.bootstrap.version == 3) {
25383 fg.removeClass([_this.invalidClass, _this.validClass]);
25384 fg.addClass(_this.invalidClass);
25386 fg.removeClass(['is-invalid', 'is-valid']);
25387 fg.addClass('is-invalid');
25395 var fg = this.el.findParent('.form-group', false, true);
25396 if (Roo.bootstrap.version == 3) {
25397 fg.removeClass([_this.invalidClass, _this.validClass]);
25398 fg.addClass(_this.invalidClass);
25400 fg.removeClass(['is-invalid', 'is-valid']);
25401 fg.addClass('is-invalid');
25406 var group = Roo.bootstrap.form.CheckBox.get(this.groupId);
25412 for(var i in group){
25413 var fg = group[i].el.findParent('.form-group', false, true);
25414 if (Roo.bootstrap.version == 3) {
25415 fg.removeClass([_this.invalidClass, _this.validClass]);
25416 fg.addClass(_this.invalidClass);
25418 fg.removeClass(['is-invalid', 'is-valid']);
25419 fg.addClass('is-invalid');
25425 clearInvalid : function()
25427 Roo.bootstrap.form.Input.prototype.clearInvalid.call(this);
25429 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
25431 var label = Roo.bootstrap.form.FieldLabel.get(this.name + '-group');
25433 if (label && label.iconEl) {
25434 label.iconEl.removeClass([ label.validClass, label.invalidClass ]);
25435 label.iconEl.removeClass(['is-invalid', 'is-valid']);
25439 disable : function()
25441 if(this.inputType != 'radio'){
25442 Roo.bootstrap.form.CheckBox.superclass.disable.call(this);
25449 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
25450 _this.getActionEl().addClass(this.disabledClass);
25451 e.dom.disabled = true;
25455 this.disabled = true;
25456 this.fireEvent("disable", this);
25460 enable : function()
25462 if(this.inputType != 'radio'){
25463 Roo.bootstrap.form.CheckBox.superclass.enable.call(this);
25470 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
25471 _this.getActionEl().removeClass(this.disabledClass);
25472 e.dom.disabled = false;
25476 this.disabled = false;
25477 this.fireEvent("enable", this);
25481 setBoxLabel : function(v)
25486 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
25492 Roo.apply(Roo.bootstrap.form.CheckBox, {
25497 * register a CheckBox Group
25498 * @param {Roo.bootstrap.form.CheckBox} the CheckBox to add
25500 register : function(checkbox)
25502 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
25503 this.groups[checkbox.groupId] = {};
25506 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
25510 this.groups[checkbox.groupId][checkbox.name] = checkbox;
25514 * fetch a CheckBox Group based on the group ID
25515 * @param {string} the group ID
25516 * @returns {Roo.bootstrap.form.CheckBox} the CheckBox group
25518 get: function(groupId) {
25519 if (typeof(this.groups[groupId]) == 'undefined') {
25523 return this.groups[groupId] ;
25536 * @class Roo.bootstrap.form.Radio
25537 * @extends Roo.bootstrap.Component
25538 * Bootstrap Radio class
25539 * @cfg {String} boxLabel - the label associated
25540 * @cfg {String} value - the value of radio
25543 * Create a new Radio
25544 * @param {Object} config The config object
25546 Roo.bootstrap.form.Radio = function(config){
25547 Roo.bootstrap.form.Radio.superclass.constructor.call(this, config);
25551 Roo.extend(Roo.bootstrap.form.Radio, Roo.bootstrap.Component, {
25557 getAutoCreate : function()
25561 cls : 'form-group radio',
25566 html : this.boxLabel
25574 initEvents : function()
25576 this.parent().register(this);
25578 this.el.on('click', this.onClick, this);
25582 onClick : function(e)
25584 if(this.parent().fireEvent('click', this.parent(), this, e) !== false){
25585 this.setChecked(true);
25589 setChecked : function(state, suppressEvent)
25591 this.parent().setValue(this.value, suppressEvent);
25595 setBoxLabel : function(v)
25600 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
25615 * @class Roo.bootstrap.form.SecurePass
25616 * @extends Roo.bootstrap.form.Input
25617 * Bootstrap SecurePass class
25621 * Create a new SecurePass
25622 * @param {Object} config The config object
25625 Roo.bootstrap.form.SecurePass = function (config) {
25626 // these go here, so the translation tool can replace them..
25628 PwdEmpty: "Please type a password, and then retype it to confirm.",
25629 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
25630 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
25631 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
25632 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
25633 FNInPwd: "Your password can't contain your first name. Please type a different password.",
25634 LNInPwd: "Your password can't contain your last name. Please type a different password.",
25635 TooWeak: "Your password is Too Weak."
25637 this.meterLabel = "Password strength:";
25638 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
25639 this.meterClass = [
25640 "roo-password-meter-tooweak",
25641 "roo-password-meter-weak",
25642 "roo-password-meter-medium",
25643 "roo-password-meter-strong",
25644 "roo-password-meter-grey"
25649 Roo.bootstrap.form.SecurePass.superclass.constructor.call(this, config);
25652 Roo.extend(Roo.bootstrap.form.SecurePass, Roo.bootstrap.form.Input, {
25654 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
25656 * PwdEmpty: "Please type a password, and then retype it to confirm.",
25657 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
25658 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
25659 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
25660 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
25661 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
25662 * LNInPwd: "Your password can't contain your last name. Please type a different password."
25672 * @cfg {String/Object} Label for the strength meter (defaults to
25673 * 'Password strength:')
25678 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
25679 * ['Weak', 'Medium', 'Strong'])
25682 pwdStrengths: false,
25695 initEvents: function ()
25697 Roo.bootstrap.form.SecurePass.superclass.initEvents.call(this);
25699 if (this.el.is('input[type=password]') && Roo.isSafari) {
25700 this.el.on('keydown', this.SafariOnKeyDown, this);
25703 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
25706 onRender: function (ct, position)
25708 Roo.bootstrap.form.SecurePass.superclass.onRender.call(this, ct, position);
25709 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
25710 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
25712 this.trigger.createChild({
25717 cls: 'roo-password-meter-grey col-xs-12',
25720 //width: this.meterWidth + 'px'
25724 cls: 'roo-password-meter-text'
25730 if (this.hideTrigger) {
25731 this.trigger.setDisplayed(false);
25733 this.setSize(this.width || '', this.height || '');
25736 onDestroy: function ()
25738 if (this.trigger) {
25739 this.trigger.removeAllListeners();
25740 this.trigger.remove();
25743 this.wrap.remove();
25745 Roo.bootstrap.form.TriggerField.superclass.onDestroy.call(this);
25748 checkStrength: function ()
25750 var pwd = this.inputEl().getValue();
25751 if (pwd == this._lastPwd) {
25756 if (this.ClientSideStrongPassword(pwd)) {
25758 } else if (this.ClientSideMediumPassword(pwd)) {
25760 } else if (this.ClientSideWeakPassword(pwd)) {
25766 Roo.log('strength1: ' + strength);
25768 //var pm = this.trigger.child('div/div/div').dom;
25769 var pm = this.trigger.child('div/div');
25770 pm.removeClass(this.meterClass);
25771 pm.addClass(this.meterClass[strength]);
25774 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
25776 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
25778 this._lastPwd = pwd;
25782 Roo.bootstrap.form.SecurePass.superclass.reset.call(this);
25784 this._lastPwd = '';
25786 var pm = this.trigger.child('div/div');
25787 pm.removeClass(this.meterClass);
25788 pm.addClass('roo-password-meter-grey');
25791 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
25794 this.inputEl().dom.type='password';
25797 validateValue: function (value)
25799 if (!Roo.bootstrap.form.SecurePass.superclass.validateValue.call(this, value)) {
25802 if (value.length == 0) {
25803 if (this.allowBlank) {
25804 this.clearInvalid();
25808 this.markInvalid(this.errors.PwdEmpty);
25809 this.errorMsg = this.errors.PwdEmpty;
25817 if (!value.match(/[\x21-\x7e]+/)) {
25818 this.markInvalid(this.errors.PwdBadChar);
25819 this.errorMsg = this.errors.PwdBadChar;
25822 if (value.length < 6) {
25823 this.markInvalid(this.errors.PwdShort);
25824 this.errorMsg = this.errors.PwdShort;
25827 if (value.length > 16) {
25828 this.markInvalid(this.errors.PwdLong);
25829 this.errorMsg = this.errors.PwdLong;
25833 if (this.ClientSideStrongPassword(value)) {
25835 } else if (this.ClientSideMediumPassword(value)) {
25837 } else if (this.ClientSideWeakPassword(value)) {
25844 if (strength < 2) {
25845 //this.markInvalid(this.errors.TooWeak);
25846 this.errorMsg = this.errors.TooWeak;
25851 console.log('strength2: ' + strength);
25853 //var pm = this.trigger.child('div/div/div').dom;
25855 var pm = this.trigger.child('div/div');
25856 pm.removeClass(this.meterClass);
25857 pm.addClass(this.meterClass[strength]);
25859 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
25861 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
25863 this.errorMsg = '';
25867 CharacterSetChecks: function (type)
25870 this.fResult = false;
25873 isctype: function (character, type)
25876 case this.kCapitalLetter:
25877 if (character >= 'A' && character <= 'Z') {
25882 case this.kSmallLetter:
25883 if (character >= 'a' && character <= 'z') {
25889 if (character >= '0' && character <= '9') {
25894 case this.kPunctuation:
25895 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
25906 IsLongEnough: function (pwd, size)
25908 return !(pwd == null || isNaN(size) || pwd.length < size);
25911 SpansEnoughCharacterSets: function (word, nb)
25913 if (!this.IsLongEnough(word, nb))
25918 var characterSetChecks = new Array(
25919 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
25920 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
25923 for (var index = 0; index < word.length; ++index) {
25924 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
25925 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
25926 characterSetChecks[nCharSet].fResult = true;
25933 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
25934 if (characterSetChecks[nCharSet].fResult) {
25939 if (nCharSets < nb) {
25945 ClientSideStrongPassword: function (pwd)
25947 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
25950 ClientSideMediumPassword: function (pwd)
25952 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
25955 ClientSideWeakPassword: function (pwd)
25957 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
25960 })//<script type="text/javascript">
25963 * Based Ext JS Library 1.1.1
25964 * Copyright(c) 2006-2007, Ext JS, LLC.
25970 * @class Roo.HtmlEditorCore
25971 * @extends Roo.Component
25972 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
25974 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
25977 Roo.HtmlEditorCore = function(config){
25980 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
25985 * @event initialize
25986 * Fires when the editor is fully initialized (including the iframe)
25987 * @param {Roo.HtmlEditorCore} this
25992 * Fires when the editor is first receives the focus. Any insertion must wait
25993 * until after this event.
25994 * @param {Roo.HtmlEditorCore} this
25998 * @event beforesync
25999 * Fires before the textarea is updated with content from the editor iframe. Return false
26000 * to cancel the sync.
26001 * @param {Roo.HtmlEditorCore} this
26002 * @param {String} html
26006 * @event beforepush
26007 * Fires before the iframe editor is updated with content from the textarea. Return false
26008 * to cancel the push.
26009 * @param {Roo.HtmlEditorCore} this
26010 * @param {String} html
26015 * Fires when the textarea is updated with content from the editor iframe.
26016 * @param {Roo.HtmlEditorCore} this
26017 * @param {String} html
26022 * Fires when the iframe editor is updated with content from the textarea.
26023 * @param {Roo.HtmlEditorCore} this
26024 * @param {String} html
26029 * @event editorevent
26030 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
26031 * @param {Roo.HtmlEditorCore} this
26037 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
26039 // defaults : white / black...
26040 this.applyBlacklists();
26047 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
26051 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
26057 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
26062 * @cfg {Number} height (in pixels)
26066 * @cfg {Number} width (in pixels)
26071 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
26074 stylesheets: false,
26077 * @cfg {boolean} allowComments - default false - allow comments in HTML source - by default they are stripped - if you are editing email you may need this.
26079 allowComments: false,
26083 // private properties
26084 validationEvent : false,
26086 initialized : false,
26088 sourceEditMode : false,
26089 onFocus : Roo.emptyFn,
26091 hideMode:'offsets',
26095 // blacklist + whitelisted elements..
26102 * Protected method that will not generally be called directly. It
26103 * is called when the editor initializes the iframe with HTML contents. Override this method if you
26104 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
26106 getDocMarkup : function(){
26110 // inherit styels from page...??
26111 if (this.stylesheets === false) {
26113 Roo.get(document.head).select('style').each(function(node) {
26114 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
26117 Roo.get(document.head).select('link').each(function(node) {
26118 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
26121 } else if (!this.stylesheets.length) {
26123 st = '<style type="text/css">' +
26124 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
26127 for (var i in this.stylesheets) {
26128 st += '<link rel="stylesheet" href="' + this.stylesheets[i] +'" type="text/css">';
26133 st += '<style type="text/css">' +
26134 'IMG { cursor: pointer } ' +
26137 var cls = 'roo-htmleditor-body';
26139 if(this.bodyCls.length){
26140 cls += ' ' + this.bodyCls;
26143 return '<html><head>' + st +
26144 //<style type="text/css">' +
26145 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
26147 ' </head><body contenteditable="true" data-enable-grammerly="true" class="' + cls + '"></body></html>';
26151 onRender : function(ct, position)
26154 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
26155 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
26158 this.el.dom.style.border = '0 none';
26159 this.el.dom.setAttribute('tabIndex', -1);
26160 this.el.addClass('x-hidden hide');
26164 if(Roo.isIE){ // fix IE 1px bogus margin
26165 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
26169 this.frameId = Roo.id();
26173 var iframe = this.owner.wrap.createChild({
26175 cls: 'form-control', // bootstrap..
26177 name: this.frameId,
26178 frameBorder : 'no',
26179 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
26184 this.iframe = iframe.dom;
26186 this.assignDocWin();
26188 this.doc.designMode = 'on';
26191 this.doc.write(this.getDocMarkup());
26195 var task = { // must defer to wait for browser to be ready
26197 //console.log("run task?" + this.doc.readyState);
26198 this.assignDocWin();
26199 if(this.doc.body || this.doc.readyState == 'complete'){
26201 this.doc.designMode="on";
26205 Roo.TaskMgr.stop(task);
26206 this.initEditor.defer(10, this);
26213 Roo.TaskMgr.start(task);
26218 onResize : function(w, h)
26220 Roo.log('resize: ' +w + ',' + h );
26221 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
26225 if(typeof w == 'number'){
26227 this.iframe.style.width = w + 'px';
26229 if(typeof h == 'number'){
26231 this.iframe.style.height = h + 'px';
26233 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
26240 * Toggles the editor between standard and source edit mode.
26241 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
26243 toggleSourceEdit : function(sourceEditMode){
26245 this.sourceEditMode = sourceEditMode === true;
26247 if(this.sourceEditMode){
26249 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
26252 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
26253 //this.iframe.className = '';
26256 //this.setSize(this.owner.wrap.getSize());
26257 //this.fireEvent('editmodechange', this, this.sourceEditMode);
26264 * Protected method that will not generally be called directly. If you need/want
26265 * custom HTML cleanup, this is the method you should override.
26266 * @param {String} html The HTML to be cleaned
26267 * return {String} The cleaned HTML
26269 cleanHtml : function(html){
26270 html = String(html);
26271 if(html.length > 5){
26272 if(Roo.isSafari){ // strip safari nonsense
26273 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
26276 if(html == ' '){
26283 * HTML Editor -> Textarea
26284 * Protected method that will not generally be called directly. Syncs the contents
26285 * of the editor iframe with the textarea.
26287 syncValue : function(){
26288 if(this.initialized){
26289 var bd = (this.doc.body || this.doc.documentElement);
26290 //this.cleanUpPaste(); -- this is done else where and causes havoc..
26291 var html = bd.innerHTML;
26293 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
26294 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
26296 html = '<div style="'+m[0]+'">' + html + '</div>';
26299 html = this.cleanHtml(html);
26300 // fix up the special chars.. normaly like back quotes in word...
26301 // however we do not want to do this with chinese..
26302 html = html.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[\u0080-\uFFFF]/g, function(match) {
26304 var cc = match.charCodeAt();
26306 // Get the character value, handling surrogate pairs
26307 if (match.length == 2) {
26308 // It's a surrogate pair, calculate the Unicode code point
26309 var high = match.charCodeAt(0) - 0xD800;
26310 var low = match.charCodeAt(1) - 0xDC00;
26311 cc = (high * 0x400) + low + 0x10000;
26313 (cc >= 0x4E00 && cc < 0xA000 ) ||
26314 (cc >= 0x3400 && cc < 0x4E00 ) ||
26315 (cc >= 0xf900 && cc < 0xfb00 )
26320 // No, use a numeric entity. Here we brazenly (and possibly mistakenly)
26321 return "&#" + cc + ";";
26328 if(this.owner.fireEvent('beforesync', this, html) !== false){
26329 this.el.dom.value = html;
26330 this.owner.fireEvent('sync', this, html);
26336 * Protected method that will not generally be called directly. Pushes the value of the textarea
26337 * into the iframe editor.
26339 pushValue : function(){
26340 if(this.initialized){
26341 var v = this.el.dom.value.trim();
26343 // if(v.length < 1){
26347 if(this.owner.fireEvent('beforepush', this, v) !== false){
26348 var d = (this.doc.body || this.doc.documentElement);
26350 this.cleanUpPaste();
26351 this.el.dom.value = d.innerHTML;
26352 this.owner.fireEvent('push', this, v);
26358 deferFocus : function(){
26359 this.focus.defer(10, this);
26363 focus : function(){
26364 if(this.win && !this.sourceEditMode){
26371 assignDocWin: function()
26373 var iframe = this.iframe;
26376 this.doc = iframe.contentWindow.document;
26377 this.win = iframe.contentWindow;
26379 // if (!Roo.get(this.frameId)) {
26382 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
26383 // this.win = Roo.get(this.frameId).dom.contentWindow;
26385 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
26389 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
26390 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
26395 initEditor : function(){
26396 //console.log("INIT EDITOR");
26397 this.assignDocWin();
26401 this.doc.designMode="on";
26403 this.doc.write(this.getDocMarkup());
26406 var dbody = (this.doc.body || this.doc.documentElement);
26407 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
26408 // this copies styles from the containing element into thsi one..
26409 // not sure why we need all of this..
26410 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
26412 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
26413 //ss['background-attachment'] = 'fixed'; // w3c
26414 dbody.bgProperties = 'fixed'; // ie
26415 //Roo.DomHelper.applyStyles(dbody, ss);
26416 Roo.EventManager.on(this.doc, {
26417 //'mousedown': this.onEditorEvent,
26418 'mouseup': this.onEditorEvent,
26419 'dblclick': this.onEditorEvent,
26420 'click': this.onEditorEvent,
26421 'keyup': this.onEditorEvent,
26426 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
26428 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
26429 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
26431 this.initialized = true;
26433 this.owner.fireEvent('initialize', this);
26438 onDestroy : function(){
26444 //for (var i =0; i < this.toolbars.length;i++) {
26445 // // fixme - ask toolbars for heights?
26446 // this.toolbars[i].onDestroy();
26449 //this.wrap.dom.innerHTML = '';
26450 //this.wrap.remove();
26455 onFirstFocus : function(){
26457 this.assignDocWin();
26460 this.activated = true;
26463 if(Roo.isGecko){ // prevent silly gecko errors
26465 var s = this.win.getSelection();
26466 if(!s.focusNode || s.focusNode.nodeType != 3){
26467 var r = s.getRangeAt(0);
26468 r.selectNodeContents((this.doc.body || this.doc.documentElement));
26473 this.execCmd('useCSS', true);
26474 this.execCmd('styleWithCSS', false);
26477 this.owner.fireEvent('activate', this);
26481 adjustFont: function(btn){
26482 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
26483 //if(Roo.isSafari){ // safari
26486 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
26487 if(Roo.isSafari){ // safari
26488 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
26489 v = (v < 10) ? 10 : v;
26490 v = (v > 48) ? 48 : v;
26491 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
26496 v = Math.max(1, v+adjust);
26498 this.execCmd('FontSize', v );
26501 onEditorEvent : function(e)
26503 this.owner.fireEvent('editorevent', this, e);
26504 // this.updateToolbar();
26505 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
26508 insertTag : function(tg)
26510 // could be a bit smarter... -> wrap the current selected tRoo..
26511 if (tg.toLowerCase() == 'span' ||
26512 tg.toLowerCase() == 'code' ||
26513 tg.toLowerCase() == 'sup' ||
26514 tg.toLowerCase() == 'sub'
26517 range = this.createRange(this.getSelection());
26518 var wrappingNode = this.doc.createElement(tg.toLowerCase());
26519 wrappingNode.appendChild(range.extractContents());
26520 range.insertNode(wrappingNode);
26527 this.execCmd("formatblock", tg);
26531 insertText : function(txt)
26535 var range = this.createRange();
26536 range.deleteContents();
26537 //alert(Sender.getAttribute('label'));
26539 range.insertNode(this.doc.createTextNode(txt));
26545 * Executes a Midas editor command on the editor document and performs necessary focus and
26546 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
26547 * @param {String} cmd The Midas command
26548 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
26550 relayCmd : function(cmd, value){
26552 this.execCmd(cmd, value);
26553 this.owner.fireEvent('editorevent', this);
26554 //this.updateToolbar();
26555 this.owner.deferFocus();
26559 * Executes a Midas editor command directly on the editor document.
26560 * For visual commands, you should use {@link #relayCmd} instead.
26561 * <b>This should only be called after the editor is initialized.</b>
26562 * @param {String} cmd The Midas command
26563 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
26565 execCmd : function(cmd, value){
26566 this.doc.execCommand(cmd, false, value === undefined ? null : value);
26573 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
26575 * @param {String} text | dom node..
26577 insertAtCursor : function(text)
26580 if(!this.activated){
26586 var r = this.doc.selection.createRange();
26597 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
26601 // from jquery ui (MIT licenced)
26603 var win = this.win;
26605 if (win.getSelection && win.getSelection().getRangeAt) {
26606 range = win.getSelection().getRangeAt(0);
26607 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
26608 range.insertNode(node);
26609 } else if (win.document.selection && win.document.selection.createRange) {
26610 // no firefox support
26611 var txt = typeof(text) == 'string' ? text : text.outerHTML;
26612 win.document.selection.createRange().pasteHTML(txt);
26614 // no firefox support
26615 var txt = typeof(text) == 'string' ? text : text.outerHTML;
26616 this.execCmd('InsertHTML', txt);
26625 mozKeyPress : function(e){
26627 var c = e.getCharCode(), cmd;
26630 c = String.fromCharCode(c).toLowerCase();
26644 this.cleanUpPaste.defer(100, this);
26652 e.preventDefault();
26660 fixKeys : function(){ // load time branching for fastest keydown performance
26662 return function(e){
26663 var k = e.getKey(), r;
26666 r = this.doc.selection.createRange();
26669 r.pasteHTML('    ');
26676 r = this.doc.selection.createRange();
26678 var target = r.parentElement();
26679 if(!target || target.tagName.toLowerCase() != 'li'){
26681 r.pasteHTML('<br />');
26687 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
26688 this.cleanUpPaste.defer(100, this);
26694 }else if(Roo.isOpera){
26695 return function(e){
26696 var k = e.getKey();
26700 this.execCmd('InsertHTML','    ');
26703 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
26704 this.cleanUpPaste.defer(100, this);
26709 }else if(Roo.isSafari){
26710 return function(e){
26711 var k = e.getKey();
26715 this.execCmd('InsertText','\t');
26719 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
26720 this.cleanUpPaste.defer(100, this);
26728 getAllAncestors: function()
26730 var p = this.getSelectedNode();
26733 a.push(p); // push blank onto stack..
26734 p = this.getParentElement();
26738 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
26742 a.push(this.doc.body);
26746 lastSelNode : false,
26749 getSelection : function()
26751 this.assignDocWin();
26752 return Roo.isIE ? this.doc.selection : this.win.getSelection();
26755 getSelectedNode: function()
26757 // this may only work on Gecko!!!
26759 // should we cache this!!!!
26764 var range = this.createRange(this.getSelection()).cloneRange();
26767 var parent = range.parentElement();
26769 var testRange = range.duplicate();
26770 testRange.moveToElementText(parent);
26771 if (testRange.inRange(range)) {
26774 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
26777 parent = parent.parentElement;
26782 // is ancestor a text element.
26783 var ac = range.commonAncestorContainer;
26784 if (ac.nodeType == 3) {
26785 ac = ac.parentNode;
26788 var ar = ac.childNodes;
26791 var other_nodes = [];
26792 var has_other_nodes = false;
26793 for (var i=0;i<ar.length;i++) {
26794 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
26797 // fullly contained node.
26799 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
26804 // probably selected..
26805 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
26806 other_nodes.push(ar[i]);
26810 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
26815 has_other_nodes = true;
26817 if (!nodes.length && other_nodes.length) {
26818 nodes= other_nodes;
26820 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
26826 createRange: function(sel)
26828 // this has strange effects when using with
26829 // top toolbar - not sure if it's a great idea.
26830 //this.editor.contentWindow.focus();
26831 if (typeof sel != "undefined") {
26833 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
26835 return this.doc.createRange();
26838 return this.doc.createRange();
26841 getParentElement: function()
26844 this.assignDocWin();
26845 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
26847 var range = this.createRange(sel);
26850 var p = range.commonAncestorContainer;
26851 while (p.nodeType == 3) { // text node
26862 * Range intersection.. the hard stuff...
26866 * [ -- selected range --- ]
26870 * if end is before start or hits it. fail.
26871 * if start is after end or hits it fail.
26873 * if either hits (but other is outside. - then it's not
26879 // @see http://www.thismuchiknow.co.uk/?p=64.
26880 rangeIntersectsNode : function(range, node)
26882 var nodeRange = node.ownerDocument.createRange();
26884 nodeRange.selectNode(node);
26886 nodeRange.selectNodeContents(node);
26889 var rangeStartRange = range.cloneRange();
26890 rangeStartRange.collapse(true);
26892 var rangeEndRange = range.cloneRange();
26893 rangeEndRange.collapse(false);
26895 var nodeStartRange = nodeRange.cloneRange();
26896 nodeStartRange.collapse(true);
26898 var nodeEndRange = nodeRange.cloneRange();
26899 nodeEndRange.collapse(false);
26901 return rangeStartRange.compareBoundaryPoints(
26902 Range.START_TO_START, nodeEndRange) == -1 &&
26903 rangeEndRange.compareBoundaryPoints(
26904 Range.START_TO_START, nodeStartRange) == 1;
26908 rangeCompareNode : function(range, node)
26910 var nodeRange = node.ownerDocument.createRange();
26912 nodeRange.selectNode(node);
26914 nodeRange.selectNodeContents(node);
26918 range.collapse(true);
26920 nodeRange.collapse(true);
26922 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
26923 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
26925 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
26927 var nodeIsBefore = ss == 1;
26928 var nodeIsAfter = ee == -1;
26930 if (nodeIsBefore && nodeIsAfter) {
26933 if (!nodeIsBefore && nodeIsAfter) {
26934 return 1; //right trailed.
26937 if (nodeIsBefore && !nodeIsAfter) {
26938 return 2; // left trailed.
26944 // private? - in a new class?
26945 cleanUpPaste : function()
26947 // cleans up the whole document..
26948 Roo.log('cleanuppaste');
26950 this.cleanUpChildren(this.doc.body);
26951 var clean = this.cleanWordChars(this.doc.body.innerHTML);
26952 if (clean != this.doc.body.innerHTML) {
26953 this.doc.body.innerHTML = clean;
26958 cleanWordChars : function(input) {// change the chars to hex code
26959 var he = Roo.HtmlEditorCore;
26961 var output = input;
26962 Roo.each(he.swapCodes, function(sw) {
26963 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
26965 output = output.replace(swapper, sw[1]);
26972 cleanUpChildren : function (n)
26974 if (!n.childNodes.length) {
26977 for (var i = n.childNodes.length-1; i > -1 ; i--) {
26978 this.cleanUpChild(n.childNodes[i]);
26985 cleanUpChild : function (node)
26988 //console.log(node);
26989 if (node.nodeName == "#text") {
26990 // clean up silly Windows -- stuff?
26993 if (node.nodeName == "#comment") {
26994 if (!this.allowComments) {
26995 node.parentNode.removeChild(node);
26997 // clean up silly Windows -- stuff?
27000 var lcname = node.tagName.toLowerCase();
27001 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
27002 // whitelist of tags..
27004 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
27006 node.parentNode.removeChild(node);
27011 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
27013 // spans with no attributes - just remove them..
27014 if ((!node.attributes || !node.attributes.length) && lcname == 'span') {
27015 remove_keep_children = true;
27018 // remove <a name=....> as rendering on yahoo mailer is borked with this.
27019 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
27021 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
27022 // remove_keep_children = true;
27025 if (remove_keep_children) {
27026 this.cleanUpChildren(node);
27027 // inserts everything just before this node...
27028 while (node.childNodes.length) {
27029 var cn = node.childNodes[0];
27030 node.removeChild(cn);
27031 node.parentNode.insertBefore(cn, node);
27033 node.parentNode.removeChild(node);
27037 if (!node.attributes || !node.attributes.length) {
27042 this.cleanUpChildren(node);
27046 function cleanAttr(n,v)
27049 if (v.match(/^\./) || v.match(/^\//)) {
27052 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/) || v.match(/^ftp:/)) {
27055 if (v.match(/^#/)) {
27058 if (v.match(/^\{/)) { // allow template editing.
27061 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
27062 node.removeAttribute(n);
27066 var cwhite = this.cwhite;
27067 var cblack = this.cblack;
27069 function cleanStyle(n,v)
27071 if (v.match(/expression/)) { //XSS?? should we even bother..
27072 node.removeAttribute(n);
27076 var parts = v.split(/;/);
27079 Roo.each(parts, function(p) {
27080 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
27084 var l = p.split(':').shift().replace(/\s+/g,'');
27085 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
27087 if ( cwhite.length && cblack.indexOf(l) > -1) {
27088 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
27089 //node.removeAttribute(n);
27093 // only allow 'c whitelisted system attributes'
27094 if ( cwhite.length && cwhite.indexOf(l) < 0) {
27095 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
27096 //node.removeAttribute(n);
27106 if (clean.length) {
27107 node.setAttribute(n, clean.join(';'));
27109 node.removeAttribute(n);
27115 for (var i = node.attributes.length-1; i > -1 ; i--) {
27116 var a = node.attributes[i];
27119 if (a.name.toLowerCase().substr(0,2)=='on') {
27120 node.removeAttribute(a.name);
27123 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
27124 node.removeAttribute(a.name);
27127 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
27128 cleanAttr(a.name,a.value); // fixme..
27131 if (a.name == 'style') {
27132 cleanStyle(a.name,a.value);
27135 /// clean up MS crap..
27136 // tecnically this should be a list of valid class'es..
27139 if (a.name == 'class') {
27140 if (a.value.match(/^Mso/)) {
27141 node.removeAttribute('class');
27144 if (a.value.match(/^body$/)) {
27145 node.removeAttribute('class');
27156 this.cleanUpChildren(node);
27162 * Clean up MS wordisms...
27164 cleanWord : function(node)
27167 this.cleanWord(this.doc.body);
27172 node.nodeName == 'SPAN' &&
27173 !node.hasAttributes() &&
27174 node.childNodes.length == 1 &&
27175 node.firstChild.nodeName == "#text"
27177 var textNode = node.firstChild;
27178 node.removeChild(textNode);
27179 if (node.getAttribute('lang') != 'zh-CN') { // do not space pad on chinese characters..
27180 node.parentNode.insertBefore(node.ownerDocument.createTextNode(" "), node);
27182 node.parentNode.insertBefore(textNode, node);
27183 if (node.getAttribute('lang') != 'zh-CN') { // do not space pad on chinese characters..
27184 node.parentNode.insertBefore(node.ownerDocument.createTextNode(" ") , node);
27186 node.parentNode.removeChild(node);
27189 if (node.nodeName == "#text") {
27190 // clean up silly Windows -- stuff?
27193 if (node.nodeName == "#comment") {
27194 node.parentNode.removeChild(node);
27195 // clean up silly Windows -- stuff?
27199 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
27200 node.parentNode.removeChild(node);
27203 //Roo.log(node.tagName);
27204 // remove - but keep children..
27205 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|v:|font)/)) {
27206 //Roo.log('-- removed');
27207 while (node.childNodes.length) {
27208 var cn = node.childNodes[0];
27209 node.removeChild(cn);
27210 node.parentNode.insertBefore(cn, node);
27211 // move node to parent - and clean it..
27212 this.cleanWord(cn);
27214 node.parentNode.removeChild(node);
27215 /// no need to iterate chidlren = it's got none..
27216 //this.iterateChildren(node, this.cleanWord);
27220 if (node.className.length) {
27222 var cn = node.className.split(/\W+/);
27224 Roo.each(cn, function(cls) {
27225 if (cls.match(/Mso[a-zA-Z]+/)) {
27230 node.className = cna.length ? cna.join(' ') : '';
27232 node.removeAttribute("class");
27236 if (node.hasAttribute("lang")) {
27237 node.removeAttribute("lang");
27240 if (node.hasAttribute("style")) {
27242 var styles = node.getAttribute("style").split(";");
27244 Roo.each(styles, function(s) {
27245 if (!s.match(/:/)) {
27248 var kv = s.split(":");
27249 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
27252 // what ever is left... we allow.
27255 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
27256 if (!nstyle.length) {
27257 node.removeAttribute('style');
27260 this.iterateChildren(node, this.cleanWord);
27266 * iterateChildren of a Node, calling fn each time, using this as the scole..
27267 * @param {DomNode} node node to iterate children of.
27268 * @param {Function} fn method of this class to call on each item.
27270 iterateChildren : function(node, fn)
27272 if (!node.childNodes.length) {
27275 for (var i = node.childNodes.length-1; i > -1 ; i--) {
27276 fn.call(this, node.childNodes[i])
27282 * cleanTableWidths.
27284 * Quite often pasting from word etc.. results in tables with column and widths.
27285 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
27288 cleanTableWidths : function(node)
27293 this.cleanTableWidths(this.doc.body);
27298 if (node.nodeName == "#text" || node.nodeName == "#comment") {
27301 Roo.log(node.tagName);
27302 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
27303 this.iterateChildren(node, this.cleanTableWidths);
27306 if (node.hasAttribute('width')) {
27307 node.removeAttribute('width');
27311 if (node.hasAttribute("style")) {
27314 var styles = node.getAttribute("style").split(";");
27316 Roo.each(styles, function(s) {
27317 if (!s.match(/:/)) {
27320 var kv = s.split(":");
27321 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
27324 // what ever is left... we allow.
27327 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
27328 if (!nstyle.length) {
27329 node.removeAttribute('style');
27333 this.iterateChildren(node, this.cleanTableWidths);
27341 domToHTML : function(currentElement, depth, nopadtext) {
27343 depth = depth || 0;
27344 nopadtext = nopadtext || false;
27346 if (!currentElement) {
27347 return this.domToHTML(this.doc.body);
27350 //Roo.log(currentElement);
27352 var allText = false;
27353 var nodeName = currentElement.nodeName;
27354 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
27356 if (nodeName == '#text') {
27358 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
27363 if (nodeName != 'BODY') {
27366 // Prints the node tagName, such as <A>, <IMG>, etc
27369 for(i = 0; i < currentElement.attributes.length;i++) {
27371 var aname = currentElement.attributes.item(i).name;
27372 if (!currentElement.attributes.item(i).value.length) {
27375 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
27378 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
27387 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
27390 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
27395 // Traverse the tree
27397 var currentElementChild = currentElement.childNodes.item(i);
27398 var allText = true;
27399 var innerHTML = '';
27401 while (currentElementChild) {
27402 // Formatting code (indent the tree so it looks nice on the screen)
27403 var nopad = nopadtext;
27404 if (lastnode == 'SPAN') {
27408 if (currentElementChild.nodeName == '#text') {
27409 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
27410 toadd = nopadtext ? toadd : toadd.trim();
27411 if (!nopad && toadd.length > 80) {
27412 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
27414 innerHTML += toadd;
27417 currentElementChild = currentElement.childNodes.item(i);
27423 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
27425 // Recursively traverse the tree structure of the child node
27426 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
27427 lastnode = currentElementChild.nodeName;
27429 currentElementChild=currentElement.childNodes.item(i);
27435 // The remaining code is mostly for formatting the tree
27436 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
27441 ret+= "</"+tagName+">";
27447 applyBlacklists : function()
27449 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
27450 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
27454 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
27455 if (b.indexOf(tag) > -1) {
27458 this.white.push(tag);
27462 Roo.each(w, function(tag) {
27463 if (b.indexOf(tag) > -1) {
27466 if (this.white.indexOf(tag) > -1) {
27469 this.white.push(tag);
27474 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
27475 if (w.indexOf(tag) > -1) {
27478 this.black.push(tag);
27482 Roo.each(b, function(tag) {
27483 if (w.indexOf(tag) > -1) {
27486 if (this.black.indexOf(tag) > -1) {
27489 this.black.push(tag);
27494 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
27495 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
27499 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
27500 if (b.indexOf(tag) > -1) {
27503 this.cwhite.push(tag);
27507 Roo.each(w, function(tag) {
27508 if (b.indexOf(tag) > -1) {
27511 if (this.cwhite.indexOf(tag) > -1) {
27514 this.cwhite.push(tag);
27519 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
27520 if (w.indexOf(tag) > -1) {
27523 this.cblack.push(tag);
27527 Roo.each(b, function(tag) {
27528 if (w.indexOf(tag) > -1) {
27531 if (this.cblack.indexOf(tag) > -1) {
27534 this.cblack.push(tag);
27539 setStylesheets : function(stylesheets)
27541 if(typeof(stylesheets) == 'string'){
27542 Roo.get(this.iframe.contentDocument.head).createChild({
27544 rel : 'stylesheet',
27553 Roo.each(stylesheets, function(s) {
27558 Roo.get(_this.iframe.contentDocument.head).createChild({
27560 rel : 'stylesheet',
27569 removeStylesheets : function()
27573 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
27578 setStyle : function(style)
27580 Roo.get(this.iframe.contentDocument.head).createChild({
27589 // hide stuff that is not compatible
27603 * @event specialkey
27607 * @cfg {String} fieldClass @hide
27610 * @cfg {String} focusClass @hide
27613 * @cfg {String} autoCreate @hide
27616 * @cfg {String} inputType @hide
27619 * @cfg {String} invalidClass @hide
27622 * @cfg {String} invalidText @hide
27625 * @cfg {String} msgFx @hide
27628 * @cfg {String} validateOnBlur @hide
27632 Roo.HtmlEditorCore.white = [
27633 'area', 'br', 'img', 'input', 'hr', 'wbr',
27635 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
27636 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
27637 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
27638 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
27639 'table', 'ul', 'xmp',
27641 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
27644 'dir', 'menu', 'ol', 'ul', 'dl',
27650 Roo.HtmlEditorCore.black = [
27651 // 'embed', 'object', // enable - backend responsiblity to clean thiese
27653 'base', 'basefont', 'bgsound', 'blink', 'body',
27654 'frame', 'frameset', 'head', 'html', 'ilayer',
27655 'iframe', 'layer', 'link', 'meta', 'object',
27656 'script', 'style' ,'title', 'xml' // clean later..
27658 Roo.HtmlEditorCore.clean = [
27659 'script', 'style', 'title', 'xml'
27661 Roo.HtmlEditorCore.remove = [
27666 Roo.HtmlEditorCore.ablack = [
27670 Roo.HtmlEditorCore.aclean = [
27671 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
27675 Roo.HtmlEditorCore.pwhite= [
27676 'http', 'https', 'mailto'
27679 // white listed style attributes.
27680 Roo.HtmlEditorCore.cwhite= [
27681 // 'text-align', /// default is to allow most things..
27687 // black listed style attributes.
27688 Roo.HtmlEditorCore.cblack= [
27689 // 'font-size' -- this can be set by the project
27693 Roo.HtmlEditorCore.swapCodes =[
27694 [ 8211, "–" ],
27695 [ 8212, "—" ],
27712 * @class Roo.bootstrap.form.HtmlEditor
27713 * @extends Roo.bootstrap.form.TextArea
27714 * Bootstrap HtmlEditor class
27717 * Create a new HtmlEditor
27718 * @param {Object} config The config object
27721 Roo.bootstrap.form.HtmlEditor = function(config){
27722 Roo.bootstrap.form.HtmlEditor.superclass.constructor.call(this, config);
27723 if (!this.toolbars) {
27724 this.toolbars = [];
27727 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
27730 * @event initialize
27731 * Fires when the editor is fully initialized (including the iframe)
27732 * @param {HtmlEditor} this
27737 * Fires when the editor is first receives the focus. Any insertion must wait
27738 * until after this event.
27739 * @param {HtmlEditor} this
27743 * @event beforesync
27744 * Fires before the textarea is updated with content from the editor iframe. Return false
27745 * to cancel the sync.
27746 * @param {HtmlEditor} this
27747 * @param {String} html
27751 * @event beforepush
27752 * Fires before the iframe editor is updated with content from the textarea. Return false
27753 * to cancel the push.
27754 * @param {HtmlEditor} this
27755 * @param {String} html
27760 * Fires when the textarea is updated with content from the editor iframe.
27761 * @param {HtmlEditor} this
27762 * @param {String} html
27767 * Fires when the iframe editor is updated with content from the textarea.
27768 * @param {HtmlEditor} this
27769 * @param {String} html
27773 * @event editmodechange
27774 * Fires when the editor switches edit modes
27775 * @param {HtmlEditor} this
27776 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
27778 editmodechange: true,
27780 * @event editorevent
27781 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
27782 * @param {HtmlEditor} this
27786 * @event firstfocus
27787 * Fires when on first focus - needed by toolbars..
27788 * @param {HtmlEditor} this
27793 * Auto save the htmlEditor value as a file into Events
27794 * @param {HtmlEditor} this
27798 * @event savedpreview
27799 * preview the saved version of htmlEditor
27800 * @param {HtmlEditor} this
27807 Roo.extend(Roo.bootstrap.form.HtmlEditor, Roo.bootstrap.form.TextArea, {
27811 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
27816 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
27821 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
27826 * @cfg {Number} height (in pixels)
27830 * @cfg {Number} width (in pixels)
27835 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
27838 stylesheets: false,
27843 // private properties
27844 validationEvent : false,
27846 initialized : false,
27849 onFocus : Roo.emptyFn,
27851 hideMode:'offsets',
27853 tbContainer : false,
27857 toolbarContainer :function() {
27858 return this.wrap.select('.x-html-editor-tb',true).first();
27862 * Protected method that will not generally be called directly. It
27863 * is called when the editor creates its toolbar. Override this method if you need to
27864 * add custom toolbar buttons.
27865 * @param {HtmlEditor} editor
27867 createToolbar : function(){
27868 Roo.log('renewing');
27869 Roo.log("create toolbars");
27871 this.toolbars = [ new Roo.bootstrap.form.HtmlEditorToolbarStandard({editor: this} ) ];
27872 this.toolbars[0].render(this.toolbarContainer());
27876 // if (!editor.toolbars || !editor.toolbars.length) {
27877 // editor.toolbars = [ new Roo.bootstrap.form.HtmlEditorToolbarStandard() ]; // can be empty?
27880 // for (var i =0 ; i < editor.toolbars.length;i++) {
27881 // editor.toolbars[i] = Roo.factory(
27882 // typeof(editor.toolbars[i]) == 'string' ?
27883 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
27884 // Roo.bootstrap.form.HtmlEditor);
27885 // editor.toolbars[i].init(editor);
27891 onRender : function(ct, position)
27893 // Roo.log("Call onRender: " + this.xtype);
27895 Roo.bootstrap.form.HtmlEditor.superclass.onRender.call(this, ct, position);
27897 this.wrap = this.inputEl().wrap({
27898 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
27901 this.editorcore.onRender(ct, position);
27903 if (this.resizable) {
27904 this.resizeEl = new Roo.Resizable(this.wrap, {
27908 minHeight : this.height,
27909 height: this.height,
27910 handles : this.resizable,
27913 resize : function(r, w, h) {
27914 _t.onResize(w,h); // -something
27920 this.createToolbar(this);
27923 if(!this.width && this.resizable){
27924 this.setSize(this.wrap.getSize());
27926 if (this.resizeEl) {
27927 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
27928 // should trigger onReize..
27934 onResize : function(w, h)
27936 Roo.log('resize: ' +w + ',' + h );
27937 Roo.bootstrap.form.HtmlEditor.superclass.onResize.apply(this, arguments);
27941 if(this.inputEl() ){
27942 if(typeof w == 'number'){
27943 var aw = w - this.wrap.getFrameWidth('lr');
27944 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
27947 if(typeof h == 'number'){
27948 var tbh = -11; // fixme it needs to tool bar size!
27949 for (var i =0; i < this.toolbars.length;i++) {
27950 // fixme - ask toolbars for heights?
27951 tbh += this.toolbars[i].el.getHeight();
27952 //if (this.toolbars[i].footer) {
27953 // tbh += this.toolbars[i].footer.el.getHeight();
27961 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
27962 ah -= 5; // knock a few pixes off for look..
27963 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
27967 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
27968 this.editorcore.onResize(ew,eh);
27973 * Toggles the editor between standard and source edit mode.
27974 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
27976 toggleSourceEdit : function(sourceEditMode)
27978 this.editorcore.toggleSourceEdit(sourceEditMode);
27980 if(this.editorcore.sourceEditMode){
27981 Roo.log('editor - showing textarea');
27984 // Roo.log(this.syncValue());
27986 this.inputEl().removeClass(['hide', 'x-hidden']);
27987 this.inputEl().dom.removeAttribute('tabIndex');
27988 this.inputEl().focus();
27990 Roo.log('editor - hiding textarea');
27992 // Roo.log(this.pushValue());
27995 this.inputEl().addClass(['hide', 'x-hidden']);
27996 this.inputEl().dom.setAttribute('tabIndex', -1);
27997 //this.deferFocus();
28000 if(this.resizable){
28001 this.setSize(this.wrap.getSize());
28004 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
28007 // private (for BoxComponent)
28008 adjustSize : Roo.BoxComponent.prototype.adjustSize,
28010 // private (for BoxComponent)
28011 getResizeEl : function(){
28015 // private (for BoxComponent)
28016 getPositionEl : function(){
28021 initEvents : function(){
28022 this.originalValue = this.getValue();
28026 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
28029 // markInvalid : Roo.emptyFn,
28031 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
28034 // clearInvalid : Roo.emptyFn,
28036 setValue : function(v){
28037 Roo.bootstrap.form.HtmlEditor.superclass.setValue.call(this, v);
28038 this.editorcore.pushValue();
28043 deferFocus : function(){
28044 this.focus.defer(10, this);
28048 focus : function(){
28049 this.editorcore.focus();
28055 onDestroy : function(){
28061 for (var i =0; i < this.toolbars.length;i++) {
28062 // fixme - ask toolbars for heights?
28063 this.toolbars[i].onDestroy();
28066 this.wrap.dom.innerHTML = '';
28067 this.wrap.remove();
28072 onFirstFocus : function(){
28073 //Roo.log("onFirstFocus");
28074 this.editorcore.onFirstFocus();
28075 for (var i =0; i < this.toolbars.length;i++) {
28076 this.toolbars[i].onFirstFocus();
28082 syncValue : function()
28084 this.editorcore.syncValue();
28087 pushValue : function()
28089 this.editorcore.pushValue();
28093 // hide stuff that is not compatible
28107 * @event specialkey
28111 * @cfg {String} fieldClass @hide
28114 * @cfg {String} focusClass @hide
28117 * @cfg {String} autoCreate @hide
28120 * @cfg {String} inputType @hide
28124 * @cfg {String} invalidText @hide
28127 * @cfg {String} msgFx @hide
28130 * @cfg {String} validateOnBlur @hide
28139 Roo.namespace('Roo.bootstrap.form.HtmlEditor');
28141 * @class Roo.bootstrap.form.HtmlEditorToolbarStandard
28142 * @parent Roo.bootstrap.form.HtmlEditor
28143 * @extends Roo.bootstrap.nav.Simplebar
28149 new Roo.bootstrap.form.HtmlEditor({
28152 new Roo.bootstrap.form.HtmlEditorToolbarStandard({
28153 disable : { fonts: 1 , format: 1, ..., ... , ...],
28159 * @cfg {Object} disable List of elements to disable..
28160 * @cfg {Array} btns List of additional buttons.
28164 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
28167 Roo.bootstrap.form.HtmlEditorToolbarStandard = function(config)
28170 Roo.apply(this, config);
28172 // default disabled, based on 'good practice'..
28173 this.disable = this.disable || {};
28174 Roo.applyIf(this.disable, {
28177 specialElements : true
28179 Roo.bootstrap.form.HtmlEditorToolbarStandard.superclass.constructor.call(this, config);
28181 this.editor = config.editor;
28182 this.editorcore = config.editor.editorcore;
28184 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
28186 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
28187 // dont call parent... till later.
28189 Roo.extend(Roo.bootstrap.form.HtmlEditorToolbarStandard, Roo.bootstrap.nav.Simplebar, {
28194 editorcore : false,
28199 "h1","h2","h3","h4","h5","h6",
28201 "abbr", "acronym", "address", "cite", "samp", "var",
28205 onRender : function(ct, position)
28207 // Roo.log("Call onRender: " + this.xtype);
28209 Roo.bootstrap.form.HtmlEditorToolbarStandard.superclass.onRender.call(this, ct, position);
28211 this.el.dom.style.marginBottom = '0';
28213 var editorcore = this.editorcore;
28214 var editor= this.editor;
28217 var btn = function(id,cmd , toggle, handler, html){
28219 var event = toggle ? 'toggle' : 'click';
28224 xns: Roo.bootstrap,
28228 enableToggle:toggle !== false,
28230 pressed : toggle ? false : null,
28233 a.listeners[toggle ? 'toggle' : 'click'] = function() {
28234 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
28240 // var cb_box = function...
28245 xns: Roo.bootstrap,
28250 xns: Roo.bootstrap,
28254 Roo.each(this.formats, function(f) {
28255 style.menu.items.push({
28257 xns: Roo.bootstrap,
28258 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
28263 editorcore.insertTag(this.tagname);
28270 children.push(style);
28272 btn('bold',false,true);
28273 btn('italic',false,true);
28274 btn('align-left', 'justifyleft',true);
28275 btn('align-center', 'justifycenter',true);
28276 btn('align-right' , 'justifyright',true);
28277 btn('link', false, false, function(btn) {
28278 //Roo.log("create link?");
28279 var url = prompt(this.createLinkText, this.defaultLinkValue);
28280 if(url && url != 'http:/'+'/'){
28281 this.editorcore.relayCmd('createlink', url);
28284 btn('list','insertunorderedlist',true);
28285 btn('pencil', false,true, function(btn){
28287 this.toggleSourceEdit(btn.pressed);
28290 if (this.editor.btns.length > 0) {
28291 for (var i = 0; i<this.editor.btns.length; i++) {
28292 children.push(this.editor.btns[i]);
28300 xns: Roo.bootstrap,
28305 xns: Roo.bootstrap,
28310 cog.menu.items.push({
28312 xns: Roo.bootstrap,
28313 html : Clean styles,
28318 editorcore.insertTag(this.tagname);
28327 this.xtype = 'NavSimplebar';
28329 for(var i=0;i< children.length;i++) {
28331 this.buttons.add(this.addxtypeChild(children[i]));
28335 editor.on('editorevent', this.updateToolbar, this);
28337 onBtnClick : function(id)
28339 this.editorcore.relayCmd(id);
28340 this.editorcore.focus();
28344 * Protected method that will not generally be called directly. It triggers
28345 * a toolbar update by reading the markup state of the current selection in the editor.
28347 updateToolbar: function(){
28349 if(!this.editorcore.activated){
28350 this.editor.onFirstFocus(); // is this neeed?
28354 var btns = this.buttons;
28355 var doc = this.editorcore.doc;
28356 btns.get('bold').setActive(doc.queryCommandState('bold'));
28357 btns.get('italic').setActive(doc.queryCommandState('italic'));
28358 //btns.get('underline').setActive(doc.queryCommandState('underline'));
28360 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
28361 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
28362 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
28364 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
28365 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
28368 var ans = this.editorcore.getAllAncestors();
28369 if (this.formatCombo) {
28372 var store = this.formatCombo.store;
28373 this.formatCombo.setValue("");
28374 for (var i =0; i < ans.length;i++) {
28375 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
28377 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
28385 // hides menus... - so this cant be on a menu...
28386 Roo.bootstrap.MenuMgr.hideAll();
28388 Roo.bootstrap.menu.Manager.hideAll();
28389 //this.editorsyncValue();
28391 onFirstFocus: function() {
28392 this.buttons.each(function(item){
28396 toggleSourceEdit : function(sourceEditMode){
28399 if(sourceEditMode){
28400 Roo.log("disabling buttons");
28401 this.buttons.each( function(item){
28402 if(item.cmd != 'pencil'){
28408 Roo.log("enabling buttons");
28409 if(this.editorcore.initialized){
28410 this.buttons.each( function(item){
28416 Roo.log("calling toggole on editor");
28417 // tell the editor that it's been pressed..
28418 this.editor.toggleSourceEdit(sourceEditMode);
28432 * @class Roo.bootstrap.form.Markdown
28433 * @extends Roo.bootstrap.form.TextArea
28434 * Bootstrap Showdown editable area
28435 * @cfg {string} content
28438 * Create a new Showdown
28441 Roo.bootstrap.form.Markdown = function(config){
28442 Roo.bootstrap.form.Markdown.superclass.constructor.call(this, config);
28446 Roo.extend(Roo.bootstrap.form.Markdown, Roo.bootstrap.form.TextArea, {
28450 initEvents : function()
28453 Roo.bootstrap.form.TextArea.prototype.initEvents.call(this);
28454 this.markdownEl = this.el.createChild({
28455 cls : 'roo-markdown-area'
28457 this.inputEl().addClass('d-none');
28458 if (this.getValue() == '') {
28459 this.markdownEl.dom.innerHTML = String.format('<span class="roo-placeholder">{0}</span>', this.placeholder || '');
28462 this.markdownEl.dom.innerHTML = Roo.Markdown.toHtml(Roo.util.Format.htmlEncode(this.getValue()));
28464 this.markdownEl.on('click', this.toggleTextEdit, this);
28465 this.on('blur', this.toggleTextEdit, this);
28466 this.on('specialkey', this.resizeTextArea, this);
28469 toggleTextEdit : function()
28471 var sh = this.markdownEl.getHeight();
28472 this.inputEl().addClass('d-none');
28473 this.markdownEl.addClass('d-none');
28474 if (!this.editing) {
28476 this.inputEl().setHeight(Math.min(500, Math.max(sh,(this.getValue().split("\n").length+1) * 30)));
28477 this.inputEl().removeClass('d-none');
28478 this.inputEl().focus();
28479 this.editing = true;
28482 // show showdown...
28483 this.updateMarkdown();
28484 this.markdownEl.removeClass('d-none');
28485 this.editing = false;
28488 updateMarkdown : function()
28490 if (this.getValue() == '') {
28491 this.markdownEl.dom.innerHTML = String.format('<span class="roo-placeholder">{0}</span>', this.placeholder || '');
28495 this.markdownEl.dom.innerHTML = Roo.Markdown.toHtml(Roo.util.Format.htmlEncode(this.getValue()));
28498 resizeTextArea: function () {
28501 Roo.log([sh, this.getValue().split("\n").length * 30]);
28502 this.inputEl().setHeight(Math.min(500, Math.max(sh, (this.getValue().split("\n").length +1) * 30)));
28504 setValue : function(val)
28506 Roo.bootstrap.form.TextArea.prototype.setValue.call(this,val);
28507 if (!this.editing) {
28508 this.updateMarkdown();
28514 if (!this.editing) {
28515 this.toggleTextEdit();
28523 * Ext JS Library 1.1.1
28524 * Copyright(c) 2006-2007, Ext JS, LLC.
28526 * Originally Released Under LGPL - original licence link has changed is not relivant.
28529 * <script type="text/javascript">
28533 * @class Roo.bootstrap.PagingToolbar
28534 * @extends Roo.bootstrap.nav.Simplebar
28535 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
28537 * Create a new PagingToolbar
28538 * @param {Object} config The config object
28539 * @param {Roo.data.Store} store
28541 Roo.bootstrap.PagingToolbar = function(config)
28543 // old args format still supported... - xtype is prefered..
28544 // created from xtype...
28546 this.ds = config.dataSource;
28548 if (config.store && !this.ds) {
28549 this.store= Roo.factory(config.store, Roo.data);
28550 this.ds = this.store;
28551 this.ds.xmodule = this.xmodule || false;
28554 this.toolbarItems = [];
28555 if (config.items) {
28556 this.toolbarItems = config.items;
28559 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
28564 this.bind(this.ds);
28567 if (Roo.bootstrap.version == 4) {
28568 this.navgroup = new Roo.bootstrap.ButtonGroup({ cls: 'pagination' });
28570 this.navgroup = new Roo.bootstrap.nav.Group({ cls: 'pagination' });
28575 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.nav.Simplebar, {
28577 * @cfg {Roo.bootstrap.Button} buttons[]
28578 * Buttons for the toolbar
28581 * @cfg {Roo.data.Store} store
28582 * The underlying data store providing the paged data
28585 * @cfg {String/HTMLElement/Element} container
28586 * container The id or element that will contain the toolbar
28589 * @cfg {Boolean} displayInfo
28590 * True to display the displayMsg (defaults to false)
28593 * @cfg {Number} pageSize
28594 * The number of records to display per page (defaults to 20)
28598 * @cfg {String} displayMsg
28599 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
28601 displayMsg : 'Displaying {0} - {1} of {2}',
28603 * @cfg {String} emptyMsg
28604 * The message to display when no records are found (defaults to "No data to display")
28606 emptyMsg : 'No data to display',
28608 * Customizable piece of the default paging text (defaults to "Page")
28611 beforePageText : "Page",
28613 * Customizable piece of the default paging text (defaults to "of %0")
28616 afterPageText : "of {0}",
28618 * Customizable piece of the default paging text (defaults to "First Page")
28621 firstText : "First Page",
28623 * Customizable piece of the default paging text (defaults to "Previous Page")
28626 prevText : "Previous Page",
28628 * Customizable piece of the default paging text (defaults to "Next Page")
28631 nextText : "Next Page",
28633 * Customizable piece of the default paging text (defaults to "Last Page")
28636 lastText : "Last Page",
28638 * Customizable piece of the default paging text (defaults to "Refresh")
28641 refreshText : "Refresh",
28645 onRender : function(ct, position)
28647 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
28648 this.navgroup.parentId = this.id;
28649 this.navgroup.onRender(this.el, null);
28650 // add the buttons to the navgroup
28652 if(this.displayInfo){
28653 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
28654 this.displayEl = this.el.select('.x-paging-info', true).first();
28655 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
28656 // this.displayEl = navel.el.select('span',true).first();
28662 Roo.each(_this.buttons, function(e){ // this might need to use render????
28663 Roo.factory(e).render(_this.el);
28667 Roo.each(_this.toolbarItems, function(e) {
28668 _this.navgroup.addItem(e);
28672 this.first = this.navgroup.addItem({
28673 tooltip: this.firstText,
28674 cls: "prev btn-outline-secondary",
28675 html : ' <i class="fa fa-step-backward"></i>',
28677 preventDefault: true,
28678 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
28681 this.prev = this.navgroup.addItem({
28682 tooltip: this.prevText,
28683 cls: "prev btn-outline-secondary",
28684 html : ' <i class="fa fa-backward"></i>',
28686 preventDefault: true,
28687 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
28689 //this.addSeparator();
28692 var field = this.navgroup.addItem( {
28694 cls : 'x-paging-position btn-outline-secondary',
28696 html : this.beforePageText +
28697 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
28698 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
28701 this.field = field.el.select('input', true).first();
28702 this.field.on("keydown", this.onPagingKeydown, this);
28703 this.field.on("focus", function(){this.dom.select();});
28706 this.afterTextEl = field.el.select('.x-paging-after',true).first();
28707 //this.field.setHeight(18);
28708 //this.addSeparator();
28709 this.next = this.navgroup.addItem({
28710 tooltip: this.nextText,
28711 cls: "next btn-outline-secondary",
28712 html : ' <i class="fa fa-forward"></i>',
28714 preventDefault: true,
28715 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
28717 this.last = this.navgroup.addItem({
28718 tooltip: this.lastText,
28719 html : ' <i class="fa fa-step-forward"></i>',
28720 cls: "next btn-outline-secondary",
28722 preventDefault: true,
28723 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
28725 //this.addSeparator();
28726 this.loading = this.navgroup.addItem({
28727 tooltip: this.refreshText,
28728 cls: "btn-outline-secondary",
28729 html : ' <i class="fa fa-refresh"></i>',
28730 preventDefault: true,
28731 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
28737 updateInfo : function(){
28738 if(this.displayEl){
28739 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
28740 var msg = count == 0 ?
28744 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
28746 this.displayEl.update(msg);
28751 onLoad : function(ds, r, o)
28753 this.cursor = o.params && o.params.start ? o.params.start : 0;
28755 var d = this.getPageData(),
28760 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
28761 this.field.dom.value = ap;
28762 this.first.setDisabled(ap == 1);
28763 this.prev.setDisabled(ap == 1);
28764 this.next.setDisabled(ap == ps);
28765 this.last.setDisabled(ap == ps);
28766 this.loading.enable();
28771 getPageData : function(){
28772 var total = this.ds.getTotalCount();
28775 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
28776 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
28781 onLoadError : function(){
28782 this.loading.enable();
28786 onPagingKeydown : function(e){
28787 var k = e.getKey();
28788 var d = this.getPageData();
28790 var v = this.field.dom.value, pageNum;
28791 if(!v || isNaN(pageNum = parseInt(v, 10))){
28792 this.field.dom.value = d.activePage;
28795 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
28796 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
28799 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))
28801 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
28802 this.field.dom.value = pageNum;
28803 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
28806 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
28808 var v = this.field.dom.value, pageNum;
28809 var increment = (e.shiftKey) ? 10 : 1;
28810 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
28813 if(!v || isNaN(pageNum = parseInt(v, 10))) {
28814 this.field.dom.value = d.activePage;
28817 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
28819 this.field.dom.value = parseInt(v, 10) + increment;
28820 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
28821 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
28828 beforeLoad : function(){
28830 this.loading.disable();
28835 onClick : function(which){
28844 ds.load({params:{start: 0, limit: this.pageSize}});
28847 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
28850 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
28853 var total = ds.getTotalCount();
28854 var extra = total % this.pageSize;
28855 var lastStart = extra ? (total - extra) : total-this.pageSize;
28856 ds.load({params:{start: lastStart, limit: this.pageSize}});
28859 ds.load({params:{start: this.cursor, limit: this.pageSize}});
28865 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
28866 * @param {Roo.data.Store} store The data store to unbind
28868 unbind : function(ds){
28869 ds.un("beforeload", this.beforeLoad, this);
28870 ds.un("load", this.onLoad, this);
28871 ds.un("loadexception", this.onLoadError, this);
28872 ds.un("remove", this.updateInfo, this);
28873 ds.un("add", this.updateInfo, this);
28874 this.ds = undefined;
28878 * Binds the paging toolbar to the specified {@link Roo.data.Store}
28879 * @param {Roo.data.Store} store The data store to bind
28881 bind : function(ds){
28882 ds.on("beforeload", this.beforeLoad, this);
28883 ds.on("load", this.onLoad, this);
28884 ds.on("loadexception", this.onLoadError, this);
28885 ds.on("remove", this.updateInfo, this);
28886 ds.on("add", this.updateInfo, this);
28897 * @class Roo.bootstrap.MessageBar
28898 * @extends Roo.bootstrap.Component
28899 * Bootstrap MessageBar class
28900 * @cfg {String} html contents of the MessageBar
28901 * @cfg {String} weight (info | success | warning | danger) default info
28902 * @cfg {String} beforeClass insert the bar before the given class
28903 * @cfg {Boolean} closable (true | false) default false
28904 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
28907 * Create a new Element
28908 * @param {Object} config The config object
28911 Roo.bootstrap.MessageBar = function(config){
28912 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
28915 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
28921 beforeClass: 'bootstrap-sticky-wrap',
28923 getAutoCreate : function(){
28927 cls: 'alert alert-dismissable alert-' + this.weight,
28932 html: this.html || ''
28938 cfg.cls += ' alert-messages-fixed';
28952 onRender : function(ct, position)
28954 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
28957 var cfg = Roo.apply({}, this.getAutoCreate());
28961 cfg.cls += ' ' + this.cls;
28964 cfg.style = this.style;
28966 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
28968 this.el.setVisibilityMode(Roo.Element.DISPLAY);
28971 this.el.select('>button.close').on('click', this.hide, this);
28977 if (!this.rendered) {
28983 this.fireEvent('show', this);
28989 if (!this.rendered) {
28995 this.fireEvent('hide', this);
28998 update : function()
29000 // var e = this.el.dom.firstChild;
29002 // if(this.closable){
29003 // e = e.nextSibling;
29006 // e.data = this.html || '';
29008 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
29024 * @class Roo.bootstrap.Graph
29025 * @extends Roo.bootstrap.Component
29026 * Bootstrap Graph class
29030 @cfg {String} graphtype bar | vbar | pie
29031 @cfg {number} g_x coodinator | centre x (pie)
29032 @cfg {number} g_y coodinator | centre y (pie)
29033 @cfg {number} g_r radius (pie)
29034 @cfg {number} g_height height of the chart (respected by all elements in the set)
29035 @cfg {number} g_width width of the chart (respected by all elements in the set)
29036 @cfg {Object} title The title of the chart
29039 -opts (object) options for the chart
29041 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
29042 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
29044 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.
29045 o stacked (boolean) whether or not to tread values as in a stacked bar chart
29047 o stretch (boolean)
29049 -opts (object) options for the pie
29052 o startAngle (number)
29053 o endAngle (number)
29057 * Create a new Input
29058 * @param {Object} config The config object
29061 Roo.bootstrap.Graph = function(config){
29062 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
29068 * The img click event for the img.
29069 * @param {Roo.EventObject} e
29075 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
29086 //g_colors: this.colors,
29093 getAutoCreate : function(){
29104 onRender : function(ct,position){
29107 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
29109 if (typeof(Raphael) == 'undefined') {
29110 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
29114 this.raphael = Raphael(this.el.dom);
29116 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
29117 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
29118 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
29119 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
29121 r.text(160, 10, "Single Series Chart").attr(txtattr);
29122 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
29123 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
29124 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
29126 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
29127 r.barchart(330, 10, 300, 220, data1);
29128 r.barchart(10, 250, 300, 220, data2, {stacked: true});
29129 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
29132 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
29133 // r.barchart(30, 30, 560, 250, xdata, {
29134 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
29135 // axis : "0 0 1 1",
29136 // axisxlabels : xdata
29137 // //yvalues : cols,
29140 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
29142 // this.load(null,xdata,{
29143 // axis : "0 0 1 1",
29144 // axisxlabels : xdata
29149 load : function(graphtype,xdata,opts)
29151 this.raphael.clear();
29153 graphtype = this.graphtype;
29158 var r = this.raphael,
29159 fin = function () {
29160 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
29162 fout = function () {
29163 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
29165 pfin = function() {
29166 this.sector.stop();
29167 this.sector.scale(1.1, 1.1, this.cx, this.cy);
29170 this.label[0].stop();
29171 this.label[0].attr({ r: 7.5 });
29172 this.label[1].attr({ "font-weight": 800 });
29175 pfout = function() {
29176 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
29179 this.label[0].animate({ r: 5 }, 500, "bounce");
29180 this.label[1].attr({ "font-weight": 400 });
29186 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
29189 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
29192 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
29193 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
29195 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
29202 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
29207 setTitle: function(o)
29212 initEvents: function() {
29215 this.el.on('click', this.onClick, this);
29219 onClick : function(e)
29221 Roo.log('img onclick');
29222 this.fireEvent('click', this, e);
29234 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
29237 * @class Roo.bootstrap.dash.NumberBox
29238 * @extends Roo.bootstrap.Component
29239 * Bootstrap NumberBox class
29240 * @cfg {String} headline Box headline
29241 * @cfg {String} content Box content
29242 * @cfg {String} icon Box icon
29243 * @cfg {String} footer Footer text
29244 * @cfg {String} fhref Footer href
29247 * Create a new NumberBox
29248 * @param {Object} config The config object
29252 Roo.bootstrap.dash.NumberBox = function(config){
29253 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
29257 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
29266 getAutoCreate : function(){
29270 cls : 'small-box ',
29278 cls : 'roo-headline',
29279 html : this.headline
29283 cls : 'roo-content',
29284 html : this.content
29298 cls : 'ion ' + this.icon
29307 cls : 'small-box-footer',
29308 href : this.fhref || '#',
29312 cfg.cn.push(footer);
29319 onRender : function(ct,position){
29320 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
29327 setHeadline: function (value)
29329 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
29332 setFooter: function (value, href)
29334 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
29337 this.el.select('a.small-box-footer',true).first().attr('href', href);
29342 setContent: function (value)
29344 this.el.select('.roo-content',true).first().dom.innerHTML = value;
29347 initEvents: function()
29361 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
29364 * @class Roo.bootstrap.dash.TabBox
29365 * @extends Roo.bootstrap.Component
29366 * @children Roo.bootstrap.dash.TabPane
29367 * Bootstrap TabBox class
29368 * @cfg {String} title Title of the TabBox
29369 * @cfg {String} icon Icon of the TabBox
29370 * @cfg {Boolean} showtabs (true|false) show the tabs default true
29371 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
29374 * Create a new TabBox
29375 * @param {Object} config The config object
29379 Roo.bootstrap.dash.TabBox = function(config){
29380 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
29385 * When a pane is added
29386 * @param {Roo.bootstrap.dash.TabPane} pane
29390 * @event activatepane
29391 * When a pane is activated
29392 * @param {Roo.bootstrap.dash.TabPane} pane
29394 "activatepane" : true
29402 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
29407 tabScrollable : false,
29409 getChildContainer : function()
29411 return this.el.select('.tab-content', true).first();
29414 getAutoCreate : function(){
29418 cls: 'pull-left header',
29426 cls: 'fa ' + this.icon
29432 cls: 'nav nav-tabs pull-right',
29438 if(this.tabScrollable){
29445 cls: 'nav nav-tabs pull-right',
29456 cls: 'nav-tabs-custom',
29461 cls: 'tab-content no-padding',
29469 initEvents : function()
29471 //Roo.log('add add pane handler');
29472 this.on('addpane', this.onAddPane, this);
29475 * Updates the box title
29476 * @param {String} html to set the title to.
29478 setTitle : function(value)
29480 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
29482 onAddPane : function(pane)
29484 this.panes.push(pane);
29485 //Roo.log('addpane');
29487 // tabs are rendere left to right..
29488 if(!this.showtabs){
29492 var ctr = this.el.select('.nav-tabs', true).first();
29495 var existing = ctr.select('.nav-tab',true);
29496 var qty = existing.getCount();;
29499 var tab = ctr.createChild({
29501 cls : 'nav-tab' + (qty ? '' : ' active'),
29509 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
29512 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
29514 pane.el.addClass('active');
29519 onTabClick : function(ev,un,ob,pane)
29521 //Roo.log('tab - prev default');
29522 ev.preventDefault();
29525 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
29526 pane.tab.addClass('active');
29527 //Roo.log(pane.title);
29528 this.getChildContainer().select('.tab-pane',true).removeClass('active');
29529 // technically we should have a deactivate event.. but maybe add later.
29530 // and it should not de-activate the selected tab...
29531 this.fireEvent('activatepane', pane);
29532 pane.el.addClass('active');
29533 pane.fireEvent('activate');
29538 getActivePane : function()
29541 Roo.each(this.panes, function(p) {
29542 if(p.el.hasClass('active')){
29563 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
29565 * @class Roo.bootstrap.TabPane
29566 * @extends Roo.bootstrap.Component
29567 * @children Roo.bootstrap.Graph Roo.bootstrap.Column
29568 * Bootstrap TabPane class
29569 * @cfg {Boolean} active (false | true) Default false
29570 * @cfg {String} title title of panel
29574 * Create a new TabPane
29575 * @param {Object} config The config object
29578 Roo.bootstrap.dash.TabPane = function(config){
29579 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
29585 * When a pane is activated
29586 * @param {Roo.bootstrap.dash.TabPane} pane
29593 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
29598 // the tabBox that this is attached to.
29601 getAutoCreate : function()
29609 cfg.cls += ' active';
29614 initEvents : function()
29616 //Roo.log('trigger add pane handler');
29617 this.parent().fireEvent('addpane', this)
29621 * Updates the tab title
29622 * @param {String} html to set the title to.
29624 setTitle: function(str)
29630 this.tab.select('a', true).first().dom.innerHTML = str;
29649 * @class Roo.bootstrap.Tooltip
29650 * Bootstrap Tooltip class
29651 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
29652 * to determine which dom element triggers the tooltip.
29654 * It needs to add support for additional attributes like tooltip-position
29657 * Create a new Toolti
29658 * @param {Object} config The config object
29661 Roo.bootstrap.Tooltip = function(config){
29662 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
29664 this.alignment = Roo.bootstrap.Tooltip.alignment;
29666 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
29667 this.alignment = config.alignment;
29672 Roo.apply(Roo.bootstrap.Tooltip, {
29674 * @function init initialize tooltip monitoring.
29678 currentTip : false,
29679 currentRegion : false,
29685 Roo.get(document).on('mouseover', this.enter ,this);
29686 Roo.get(document).on('mouseout', this.leave, this);
29689 this.currentTip = new Roo.bootstrap.Tooltip();
29692 enter : function(ev)
29694 var dom = ev.getTarget();
29696 //Roo.log(['enter',dom]);
29697 var el = Roo.fly(dom);
29698 if (this.currentEl) {
29700 //Roo.log(this.currentEl);
29701 //Roo.log(this.currentEl.contains(dom));
29702 if (this.currentEl == el) {
29705 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
29711 if (this.currentTip.el) {
29712 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
29716 if(!el || el.dom == document){
29722 if (!el.attr('tooltip')) {
29723 pel = el.findParent("[tooltip]");
29725 bindEl = Roo.get(pel);
29731 // you can not look for children, as if el is the body.. then everythign is the child..
29732 if (!pel && !el.attr('tooltip')) { //
29733 if (!el.select("[tooltip]").elements.length) {
29736 // is the mouse over this child...?
29737 bindEl = el.select("[tooltip]").first();
29738 var xy = ev.getXY();
29739 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
29740 //Roo.log("not in region.");
29743 //Roo.log("child element over..");
29746 this.currentEl = el;
29747 this.currentTip.bind(bindEl);
29748 this.currentRegion = Roo.lib.Region.getRegion(dom);
29749 this.currentTip.enter();
29752 leave : function(ev)
29754 var dom = ev.getTarget();
29755 //Roo.log(['leave',dom]);
29756 if (!this.currentEl) {
29761 if (dom != this.currentEl.dom) {
29764 var xy = ev.getXY();
29765 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
29768 // only activate leave if mouse cursor is outside... bounding box..
29773 if (this.currentTip) {
29774 this.currentTip.leave();
29776 //Roo.log('clear currentEl');
29777 this.currentEl = false;
29782 'left' : ['r-l', [-2,0], 'right'],
29783 'right' : ['l-r', [2,0], 'left'],
29784 'bottom' : ['t-b', [0,2], 'top'],
29785 'top' : [ 'b-t', [0,-2], 'bottom']
29791 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
29796 delay : null, // can be { show : 300 , hide: 500}
29800 hoverState : null, //???
29802 placement : 'bottom',
29806 getAutoCreate : function(){
29813 cls : 'tooltip-arrow arrow'
29816 cls : 'tooltip-inner'
29823 bind : function(el)
29828 initEvents : function()
29830 this.arrowEl = this.el.select('.arrow', true).first();
29831 this.innerEl = this.el.select('.tooltip-inner', true).first();
29834 enter : function () {
29836 if (this.timeout != null) {
29837 clearTimeout(this.timeout);
29840 this.hoverState = 'in';
29841 //Roo.log("enter - show");
29842 if (!this.delay || !this.delay.show) {
29847 this.timeout = setTimeout(function () {
29848 if (_t.hoverState == 'in') {
29851 }, this.delay.show);
29855 clearTimeout(this.timeout);
29857 this.hoverState = 'out';
29858 if (!this.delay || !this.delay.hide) {
29864 this.timeout = setTimeout(function () {
29865 //Roo.log("leave - timeout");
29867 if (_t.hoverState == 'out') {
29869 Roo.bootstrap.Tooltip.currentEl = false;
29874 show : function (msg)
29877 this.render(document.body);
29880 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
29882 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
29884 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
29886 this.el.removeClass(['fade','top','bottom', 'left', 'right','in',
29887 'bs-tooltip-top','bs-tooltip-bottom', 'bs-tooltip-left', 'bs-tooltip-right']);
29889 var placement = typeof this.placement == 'function' ?
29890 this.placement.call(this, this.el, on_el) :
29893 var autoToken = /\s?auto?\s?/i;
29894 var autoPlace = autoToken.test(placement);
29896 placement = placement.replace(autoToken, '') || 'top';
29900 //this.el.setXY([0,0]);
29902 //this.el.dom.style.display='block';
29904 //this.el.appendTo(on_el);
29906 var p = this.getPosition();
29907 var box = this.el.getBox();
29913 var align = this.alignment[placement];
29915 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
29917 if(placement == 'top' || placement == 'bottom'){
29919 placement = 'right';
29922 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
29923 placement = 'left';
29926 var scroll = Roo.select('body', true).first().getScroll();
29928 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
29932 align = this.alignment[placement];
29934 this.arrowEl.setLeft((this.innerEl.getWidth()/2) - 5);
29938 var elems = document.getElementsByTagName('div');
29939 var highest = Number.MIN_SAFE_INTEGER || -(Math.pow(2, 53) - 1);
29940 for (var i = 0; i < elems.length; i++) {
29941 var zindex = Number.parseInt(
29942 document.defaultView.getComputedStyle(elems[i], null).getPropertyValue("z-index"),
29945 if (zindex > highest) {
29952 this.el.dom.style.zIndex = highest;
29954 this.el.alignTo(this.bindEl, align[0],align[1]);
29955 //var arrow = this.el.select('.arrow',true).first();
29956 //arrow.set(align[2],
29958 this.el.addClass(placement);
29959 this.el.addClass("bs-tooltip-"+ placement);
29961 this.el.addClass('in fade show');
29963 this.hoverState = null;
29965 if (this.el.hasClass('fade')) {
29980 //this.el.setXY([0,0]);
29981 this.el.removeClass(['show', 'in']);
29997 * @class Roo.bootstrap.LocationPicker
29998 * @extends Roo.bootstrap.Component
29999 * Bootstrap LocationPicker class
30000 * @cfg {Number} latitude Position when init default 0
30001 * @cfg {Number} longitude Position when init default 0
30002 * @cfg {Number} zoom default 15
30003 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
30004 * @cfg {Boolean} mapTypeControl default false
30005 * @cfg {Boolean} disableDoubleClickZoom default false
30006 * @cfg {Boolean} scrollwheel default true
30007 * @cfg {Boolean} streetViewControl default false
30008 * @cfg {Number} radius default 0
30009 * @cfg {String} locationName
30010 * @cfg {Boolean} draggable default true
30011 * @cfg {Boolean} enableAutocomplete default false
30012 * @cfg {Boolean} enableReverseGeocode default true
30013 * @cfg {String} markerTitle
30016 * Create a new LocationPicker
30017 * @param {Object} config The config object
30021 Roo.bootstrap.LocationPicker = function(config){
30023 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
30028 * Fires when the picker initialized.
30029 * @param {Roo.bootstrap.LocationPicker} this
30030 * @param {Google Location} location
30034 * @event positionchanged
30035 * Fires when the picker position changed.
30036 * @param {Roo.bootstrap.LocationPicker} this
30037 * @param {Google Location} location
30039 positionchanged : true,
30042 * Fires when the map resize.
30043 * @param {Roo.bootstrap.LocationPicker} this
30048 * Fires when the map show.
30049 * @param {Roo.bootstrap.LocationPicker} this
30054 * Fires when the map hide.
30055 * @param {Roo.bootstrap.LocationPicker} this
30060 * Fires when click the map.
30061 * @param {Roo.bootstrap.LocationPicker} this
30062 * @param {Map event} e
30066 * @event mapRightClick
30067 * Fires when right click the map.
30068 * @param {Roo.bootstrap.LocationPicker} this
30069 * @param {Map event} e
30071 mapRightClick : true,
30073 * @event markerClick
30074 * Fires when click the marker.
30075 * @param {Roo.bootstrap.LocationPicker} this
30076 * @param {Map event} e
30078 markerClick : true,
30080 * @event markerRightClick
30081 * Fires when right click the marker.
30082 * @param {Roo.bootstrap.LocationPicker} this
30083 * @param {Map event} e
30085 markerRightClick : true,
30087 * @event OverlayViewDraw
30088 * Fires when OverlayView Draw
30089 * @param {Roo.bootstrap.LocationPicker} this
30091 OverlayViewDraw : true,
30093 * @event OverlayViewOnAdd
30094 * Fires when OverlayView Draw
30095 * @param {Roo.bootstrap.LocationPicker} this
30097 OverlayViewOnAdd : true,
30099 * @event OverlayViewOnRemove
30100 * Fires when OverlayView Draw
30101 * @param {Roo.bootstrap.LocationPicker} this
30103 OverlayViewOnRemove : true,
30105 * @event OverlayViewShow
30106 * Fires when OverlayView Draw
30107 * @param {Roo.bootstrap.LocationPicker} this
30108 * @param {Pixel} cpx
30110 OverlayViewShow : true,
30112 * @event OverlayViewHide
30113 * Fires when OverlayView Draw
30114 * @param {Roo.bootstrap.LocationPicker} this
30116 OverlayViewHide : true,
30118 * @event loadexception
30119 * Fires when load google lib failed.
30120 * @param {Roo.bootstrap.LocationPicker} this
30122 loadexception : true
30127 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
30129 gMapContext: false,
30135 mapTypeControl: false,
30136 disableDoubleClickZoom: false,
30138 streetViewControl: false,
30142 enableAutocomplete: false,
30143 enableReverseGeocode: true,
30146 getAutoCreate: function()
30151 cls: 'roo-location-picker'
30157 initEvents: function(ct, position)
30159 if(!this.el.getWidth() || this.isApplied()){
30163 this.el.setVisibilityMode(Roo.Element.DISPLAY);
30168 initial: function()
30170 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
30171 this.fireEvent('loadexception', this);
30175 if(!this.mapTypeId){
30176 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
30179 this.gMapContext = this.GMapContext();
30181 this.initOverlayView();
30183 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
30187 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
30188 _this.setPosition(_this.gMapContext.marker.position);
30191 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
30192 _this.fireEvent('mapClick', this, event);
30196 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
30197 _this.fireEvent('mapRightClick', this, event);
30201 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
30202 _this.fireEvent('markerClick', this, event);
30206 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
30207 _this.fireEvent('markerRightClick', this, event);
30211 this.setPosition(this.gMapContext.location);
30213 this.fireEvent('initial', this, this.gMapContext.location);
30216 initOverlayView: function()
30220 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
30224 _this.fireEvent('OverlayViewDraw', _this);
30229 _this.fireEvent('OverlayViewOnAdd', _this);
30232 onRemove: function()
30234 _this.fireEvent('OverlayViewOnRemove', _this);
30237 show: function(cpx)
30239 _this.fireEvent('OverlayViewShow', _this, cpx);
30244 _this.fireEvent('OverlayViewHide', _this);
30250 fromLatLngToContainerPixel: function(event)
30252 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
30255 isApplied: function()
30257 return this.getGmapContext() == false ? false : true;
30260 getGmapContext: function()
30262 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
30265 GMapContext: function()
30267 var position = new google.maps.LatLng(this.latitude, this.longitude);
30269 var _map = new google.maps.Map(this.el.dom, {
30272 mapTypeId: this.mapTypeId,
30273 mapTypeControl: this.mapTypeControl,
30274 disableDoubleClickZoom: this.disableDoubleClickZoom,
30275 scrollwheel: this.scrollwheel,
30276 streetViewControl: this.streetViewControl,
30277 locationName: this.locationName,
30278 draggable: this.draggable,
30279 enableAutocomplete: this.enableAutocomplete,
30280 enableReverseGeocode: this.enableReverseGeocode
30283 var _marker = new google.maps.Marker({
30284 position: position,
30286 title: this.markerTitle,
30287 draggable: this.draggable
30294 location: position,
30295 radius: this.radius,
30296 locationName: this.locationName,
30297 addressComponents: {
30298 formatted_address: null,
30299 addressLine1: null,
30300 addressLine2: null,
30302 streetNumber: null,
30306 stateOrProvince: null
30309 domContainer: this.el.dom,
30310 geodecoder: new google.maps.Geocoder()
30314 drawCircle: function(center, radius, options)
30316 if (this.gMapContext.circle != null) {
30317 this.gMapContext.circle.setMap(null);
30321 options = Roo.apply({}, options, {
30322 strokeColor: "#0000FF",
30323 strokeOpacity: .35,
30325 fillColor: "#0000FF",
30329 options.map = this.gMapContext.map;
30330 options.radius = radius;
30331 options.center = center;
30332 this.gMapContext.circle = new google.maps.Circle(options);
30333 return this.gMapContext.circle;
30339 setPosition: function(location)
30341 this.gMapContext.location = location;
30342 this.gMapContext.marker.setPosition(location);
30343 this.gMapContext.map.panTo(location);
30344 this.drawCircle(location, this.gMapContext.radius, {});
30348 if (this.gMapContext.settings.enableReverseGeocode) {
30349 this.gMapContext.geodecoder.geocode({
30350 latLng: this.gMapContext.location
30351 }, function(results, status) {
30353 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
30354 _this.gMapContext.locationName = results[0].formatted_address;
30355 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
30357 _this.fireEvent('positionchanged', this, location);
30364 this.fireEvent('positionchanged', this, location);
30369 google.maps.event.trigger(this.gMapContext.map, "resize");
30371 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
30373 this.fireEvent('resize', this);
30376 setPositionByLatLng: function(latitude, longitude)
30378 this.setPosition(new google.maps.LatLng(latitude, longitude));
30381 getCurrentPosition: function()
30384 latitude: this.gMapContext.location.lat(),
30385 longitude: this.gMapContext.location.lng()
30389 getAddressName: function()
30391 return this.gMapContext.locationName;
30394 getAddressComponents: function()
30396 return this.gMapContext.addressComponents;
30399 address_component_from_google_geocode: function(address_components)
30403 for (var i = 0; i < address_components.length; i++) {
30404 var component = address_components[i];
30405 if (component.types.indexOf("postal_code") >= 0) {
30406 result.postalCode = component.short_name;
30407 } else if (component.types.indexOf("street_number") >= 0) {
30408 result.streetNumber = component.short_name;
30409 } else if (component.types.indexOf("route") >= 0) {
30410 result.streetName = component.short_name;
30411 } else if (component.types.indexOf("neighborhood") >= 0) {
30412 result.city = component.short_name;
30413 } else if (component.types.indexOf("locality") >= 0) {
30414 result.city = component.short_name;
30415 } else if (component.types.indexOf("sublocality") >= 0) {
30416 result.district = component.short_name;
30417 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
30418 result.stateOrProvince = component.short_name;
30419 } else if (component.types.indexOf("country") >= 0) {
30420 result.country = component.short_name;
30424 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
30425 result.addressLine2 = "";
30429 setZoomLevel: function(zoom)
30431 this.gMapContext.map.setZoom(zoom);
30444 this.fireEvent('show', this);
30455 this.fireEvent('hide', this);
30460 Roo.apply(Roo.bootstrap.LocationPicker, {
30462 OverlayView : function(map, options)
30464 options = options || {};
30471 * @class Roo.bootstrap.Alert
30472 * @extends Roo.bootstrap.Component
30473 * Bootstrap Alert class - shows an alert area box
30475 * <div class="alert alert-danger" role="alert"><span class="fa fa-exclamation-triangle"></span><span class="sr-only">Error:</span>
30476 Enter a valid email address
30479 * @cfg {String} title The title of alert
30480 * @cfg {String} html The content of alert
30481 * @cfg {String} weight (success|info|warning|danger) Weight of the message
30482 * @cfg {String} fa font-awesomeicon
30483 * @cfg {Number} seconds default:-1 Number of seconds until it disapears (-1 means never.)
30484 * @cfg {Boolean} close true to show a x closer
30488 * Create a new alert
30489 * @param {Object} config The config object
30493 Roo.bootstrap.Alert = function(config){
30494 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
30498 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
30504 faicon: false, // BC
30508 getAutoCreate : function()
30520 style : this.close ? '' : 'display:none'
30524 cls : 'roo-alert-icon'
30529 cls : 'roo-alert-title',
30534 cls : 'roo-alert-text',
30541 cfg.cn[0].cls += ' fa ' + this.faicon;
30544 cfg.cn[0].cls += ' fa ' + this.fa;
30548 cfg.cls += ' alert-' + this.weight;
30554 initEvents: function()
30556 this.el.setVisibilityMode(Roo.Element.DISPLAY);
30557 this.titleEl = this.el.select('.roo-alert-title',true).first();
30558 this.iconEl = this.el.select('.roo-alert-icon',true).first();
30559 this.htmlEl = this.el.select('.roo-alert-text',true).first();
30560 if (this.seconds > 0) {
30561 this.hide.defer(this.seconds, this);
30565 * Set the Title Message HTML
30566 * @param {String} html
30568 setTitle : function(str)
30570 this.titleEl.dom.innerHTML = str;
30574 * Set the Body Message HTML
30575 * @param {String} html
30577 setHtml : function(str)
30579 this.htmlEl.dom.innerHTML = str;
30582 * Set the Weight of the alert
30583 * @param {String} (success|info|warning|danger) weight
30586 setWeight : function(weight)
30589 this.el.removeClass('alert-' + this.weight);
30592 this.weight = weight;
30594 this.el.addClass('alert-' + this.weight);
30597 * Set the Icon of the alert
30598 * @param {String} see fontawsome names (name without the 'fa-' bit)
30600 setIcon : function(icon)
30603 this.alertEl.removeClass(['fa', 'fa-' + this.faicon]);
30606 this.faicon = icon;
30608 this.alertEl.addClass(['fa', 'fa-' + this.faicon]);
30633 * @class Roo.bootstrap.UploadCropbox
30634 * @extends Roo.bootstrap.Component
30635 * Bootstrap UploadCropbox class
30636 * @cfg {String} emptyText show when image has been loaded
30637 * @cfg {String} rotateNotify show when image too small to rotate
30638 * @cfg {Number} errorTimeout default 3000
30639 * @cfg {Number} minWidth default 300
30640 * @cfg {Number} minHeight default 300
30641 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
30642 * @cfg {Boolean} isDocument (true|false) default false
30643 * @cfg {String} url action url
30644 * @cfg {String} paramName default 'imageUpload'
30645 * @cfg {String} method default POST
30646 * @cfg {Boolean} loadMask (true|false) default true
30647 * @cfg {Boolean} loadingText default 'Loading...'
30650 * Create a new UploadCropbox
30651 * @param {Object} config The config object
30654 Roo.bootstrap.UploadCropbox = function(config){
30655 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
30659 * @event beforeselectfile
30660 * Fire before select file
30661 * @param {Roo.bootstrap.UploadCropbox} this
30663 "beforeselectfile" : true,
30666 * Fire after initEvent
30667 * @param {Roo.bootstrap.UploadCropbox} this
30672 * Fire after initEvent
30673 * @param {Roo.bootstrap.UploadCropbox} this
30674 * @param {String} data
30679 * Fire when preparing the file data
30680 * @param {Roo.bootstrap.UploadCropbox} this
30681 * @param {Object} file
30686 * Fire when get exception
30687 * @param {Roo.bootstrap.UploadCropbox} this
30688 * @param {XMLHttpRequest} xhr
30690 "exception" : true,
30692 * @event beforeloadcanvas
30693 * Fire before load the canvas
30694 * @param {Roo.bootstrap.UploadCropbox} this
30695 * @param {String} src
30697 "beforeloadcanvas" : true,
30700 * Fire when trash image
30701 * @param {Roo.bootstrap.UploadCropbox} this
30706 * Fire when download the image
30707 * @param {Roo.bootstrap.UploadCropbox} this
30711 * @event footerbuttonclick
30712 * Fire when footerbuttonclick
30713 * @param {Roo.bootstrap.UploadCropbox} this
30714 * @param {String} type
30716 "footerbuttonclick" : true,
30720 * @param {Roo.bootstrap.UploadCropbox} this
30725 * Fire when rotate the image
30726 * @param {Roo.bootstrap.UploadCropbox} this
30727 * @param {String} pos
30732 * Fire when inspect the file
30733 * @param {Roo.bootstrap.UploadCropbox} this
30734 * @param {Object} file
30739 * Fire when xhr upload the file
30740 * @param {Roo.bootstrap.UploadCropbox} this
30741 * @param {Object} data
30746 * Fire when arrange the file data
30747 * @param {Roo.bootstrap.UploadCropbox} this
30748 * @param {Object} formData
30753 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
30756 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
30758 emptyText : 'Click to upload image',
30759 rotateNotify : 'Image is too small to rotate',
30760 errorTimeout : 3000,
30774 cropType : 'image/jpeg',
30776 canvasLoaded : false,
30777 isDocument : false,
30779 paramName : 'imageUpload',
30781 loadingText : 'Loading...',
30784 getAutoCreate : function()
30788 cls : 'roo-upload-cropbox',
30792 cls : 'roo-upload-cropbox-selector',
30797 cls : 'roo-upload-cropbox-body',
30798 style : 'cursor:pointer',
30802 cls : 'roo-upload-cropbox-preview'
30806 cls : 'roo-upload-cropbox-thumb'
30810 cls : 'roo-upload-cropbox-empty-notify',
30811 html : this.emptyText
30815 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
30816 html : this.rotateNotify
30822 cls : 'roo-upload-cropbox-footer',
30825 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
30835 onRender : function(ct, position)
30837 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
30839 if (this.buttons.length) {
30841 Roo.each(this.buttons, function(bb) {
30843 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
30845 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
30851 this.maskEl = this.el;
30855 initEvents : function()
30857 this.urlAPI = (window.createObjectURL && window) ||
30858 (window.URL && URL.revokeObjectURL && URL) ||
30859 (window.webkitURL && webkitURL);
30861 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
30862 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30864 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
30865 this.selectorEl.hide();
30867 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
30868 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30870 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
30871 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30872 this.thumbEl.hide();
30874 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
30875 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30877 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
30878 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30879 this.errorEl.hide();
30881 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
30882 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30883 this.footerEl.hide();
30885 this.setThumbBoxSize();
30891 this.fireEvent('initial', this);
30898 window.addEventListener("resize", function() { _this.resize(); } );
30900 this.bodyEl.on('click', this.beforeSelectFile, this);
30903 this.bodyEl.on('touchstart', this.onTouchStart, this);
30904 this.bodyEl.on('touchmove', this.onTouchMove, this);
30905 this.bodyEl.on('touchend', this.onTouchEnd, this);
30909 this.bodyEl.on('mousedown', this.onMouseDown, this);
30910 this.bodyEl.on('mousemove', this.onMouseMove, this);
30911 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
30912 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
30913 Roo.get(document).on('mouseup', this.onMouseUp, this);
30916 this.selectorEl.on('change', this.onFileSelected, this);
30922 this.baseScale = 1;
30924 this.baseRotate = 1;
30925 this.dragable = false;
30926 this.pinching = false;
30929 this.cropData = false;
30930 this.notifyEl.dom.innerHTML = this.emptyText;
30932 this.selectorEl.dom.value = '';
30936 resize : function()
30938 if(this.fireEvent('resize', this) != false){
30939 this.setThumbBoxPosition();
30940 this.setCanvasPosition();
30944 onFooterButtonClick : function(e, el, o, type)
30947 case 'rotate-left' :
30948 this.onRotateLeft(e);
30950 case 'rotate-right' :
30951 this.onRotateRight(e);
30954 this.beforeSelectFile(e);
30969 this.fireEvent('footerbuttonclick', this, type);
30972 beforeSelectFile : function(e)
30974 e.preventDefault();
30976 if(this.fireEvent('beforeselectfile', this) != false){
30977 this.selectorEl.dom.click();
30981 onFileSelected : function(e)
30983 e.preventDefault();
30985 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
30989 var file = this.selectorEl.dom.files[0];
30991 if(this.fireEvent('inspect', this, file) != false){
30992 this.prepare(file);
30997 trash : function(e)
30999 this.fireEvent('trash', this);
31002 download : function(e)
31004 this.fireEvent('download', this);
31007 loadCanvas : function(src)
31009 if(this.fireEvent('beforeloadcanvas', this, src) != false){
31013 this.imageEl = document.createElement('img');
31017 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
31019 this.imageEl.src = src;
31023 onLoadCanvas : function()
31025 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
31026 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
31028 this.bodyEl.un('click', this.beforeSelectFile, this);
31030 this.notifyEl.hide();
31031 this.thumbEl.show();
31032 this.footerEl.show();
31034 this.baseRotateLevel();
31036 if(this.isDocument){
31037 this.setThumbBoxSize();
31040 this.setThumbBoxPosition();
31042 this.baseScaleLevel();
31048 this.canvasLoaded = true;
31051 this.maskEl.unmask();
31056 setCanvasPosition : function()
31058 if(!this.canvasEl){
31062 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
31063 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
31065 this.previewEl.setLeft(pw);
31066 this.previewEl.setTop(ph);
31070 onMouseDown : function(e)
31074 this.dragable = true;
31075 this.pinching = false;
31077 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
31078 this.dragable = false;
31082 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
31083 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
31087 onMouseMove : function(e)
31091 if(!this.canvasLoaded){
31095 if (!this.dragable){
31099 var minX = Math.ceil(this.thumbEl.getLeft(true));
31100 var minY = Math.ceil(this.thumbEl.getTop(true));
31102 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
31103 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
31105 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
31106 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
31108 x = x - this.mouseX;
31109 y = y - this.mouseY;
31111 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
31112 var bgY = Math.ceil(y + this.previewEl.getTop(true));
31114 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
31115 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
31117 this.previewEl.setLeft(bgX);
31118 this.previewEl.setTop(bgY);
31120 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
31121 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
31124 onMouseUp : function(e)
31128 this.dragable = false;
31131 onMouseWheel : function(e)
31135 this.startScale = this.scale;
31137 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
31139 if(!this.zoomable()){
31140 this.scale = this.startScale;
31149 zoomable : function()
31151 var minScale = this.thumbEl.getWidth() / this.minWidth;
31153 if(this.minWidth < this.minHeight){
31154 minScale = this.thumbEl.getHeight() / this.minHeight;
31157 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
31158 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
31162 (this.rotate == 0 || this.rotate == 180) &&
31164 width > this.imageEl.OriginWidth ||
31165 height > this.imageEl.OriginHeight ||
31166 (width < this.minWidth && height < this.minHeight)
31174 (this.rotate == 90 || this.rotate == 270) &&
31176 width > this.imageEl.OriginWidth ||
31177 height > this.imageEl.OriginHeight ||
31178 (width < this.minHeight && height < this.minWidth)
31185 !this.isDocument &&
31186 (this.rotate == 0 || this.rotate == 180) &&
31188 width < this.minWidth ||
31189 width > this.imageEl.OriginWidth ||
31190 height < this.minHeight ||
31191 height > this.imageEl.OriginHeight
31198 !this.isDocument &&
31199 (this.rotate == 90 || this.rotate == 270) &&
31201 width < this.minHeight ||
31202 width > this.imageEl.OriginWidth ||
31203 height < this.minWidth ||
31204 height > this.imageEl.OriginHeight
31214 onRotateLeft : function(e)
31216 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
31218 var minScale = this.thumbEl.getWidth() / this.minWidth;
31220 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
31221 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
31223 this.startScale = this.scale;
31225 while (this.getScaleLevel() < minScale){
31227 this.scale = this.scale + 1;
31229 if(!this.zoomable()){
31234 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
31235 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
31240 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
31247 this.scale = this.startScale;
31249 this.onRotateFail();
31254 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
31256 if(this.isDocument){
31257 this.setThumbBoxSize();
31258 this.setThumbBoxPosition();
31259 this.setCanvasPosition();
31264 this.fireEvent('rotate', this, 'left');
31268 onRotateRight : function(e)
31270 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
31272 var minScale = this.thumbEl.getWidth() / this.minWidth;
31274 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
31275 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
31277 this.startScale = this.scale;
31279 while (this.getScaleLevel() < minScale){
31281 this.scale = this.scale + 1;
31283 if(!this.zoomable()){
31288 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
31289 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
31294 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
31301 this.scale = this.startScale;
31303 this.onRotateFail();
31308 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
31310 if(this.isDocument){
31311 this.setThumbBoxSize();
31312 this.setThumbBoxPosition();
31313 this.setCanvasPosition();
31318 this.fireEvent('rotate', this, 'right');
31321 onRotateFail : function()
31323 this.errorEl.show(true);
31327 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
31332 this.previewEl.dom.innerHTML = '';
31334 var canvasEl = document.createElement("canvas");
31336 var contextEl = canvasEl.getContext("2d");
31338 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
31339 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
31340 var center = this.imageEl.OriginWidth / 2;
31342 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
31343 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
31344 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
31345 center = this.imageEl.OriginHeight / 2;
31348 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
31350 contextEl.translate(center, center);
31351 contextEl.rotate(this.rotate * Math.PI / 180);
31353 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
31355 this.canvasEl = document.createElement("canvas");
31357 this.contextEl = this.canvasEl.getContext("2d");
31359 switch (this.rotate) {
31362 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
31363 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
31365 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
31370 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
31371 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
31373 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
31374 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);
31378 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
31383 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
31384 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
31386 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
31387 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);
31391 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);
31396 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
31397 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
31399 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
31400 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
31404 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);
31411 this.previewEl.appendChild(this.canvasEl);
31413 this.setCanvasPosition();
31418 if(!this.canvasLoaded){
31422 var imageCanvas = document.createElement("canvas");
31424 var imageContext = imageCanvas.getContext("2d");
31426 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
31427 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
31429 var center = imageCanvas.width / 2;
31431 imageContext.translate(center, center);
31433 imageContext.rotate(this.rotate * Math.PI / 180);
31435 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
31437 var canvas = document.createElement("canvas");
31439 var context = canvas.getContext("2d");
31441 canvas.width = this.minWidth;
31442 canvas.height = this.minHeight;
31444 switch (this.rotate) {
31447 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
31448 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
31450 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
31451 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
31453 var targetWidth = this.minWidth - 2 * x;
31454 var targetHeight = this.minHeight - 2 * y;
31458 if((x == 0 && y == 0) || (x == 0 && y > 0)){
31459 scale = targetWidth / width;
31462 if(x > 0 && y == 0){
31463 scale = targetHeight / height;
31466 if(x > 0 && y > 0){
31467 scale = targetWidth / width;
31469 if(width < height){
31470 scale = targetHeight / height;
31474 context.scale(scale, scale);
31476 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
31477 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
31479 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
31480 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
31482 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
31487 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
31488 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
31490 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
31491 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
31493 var targetWidth = this.minWidth - 2 * x;
31494 var targetHeight = this.minHeight - 2 * y;
31498 if((x == 0 && y == 0) || (x == 0 && y > 0)){
31499 scale = targetWidth / width;
31502 if(x > 0 && y == 0){
31503 scale = targetHeight / height;
31506 if(x > 0 && y > 0){
31507 scale = targetWidth / width;
31509 if(width < height){
31510 scale = targetHeight / height;
31514 context.scale(scale, scale);
31516 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
31517 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
31519 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
31520 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
31522 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
31524 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
31529 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
31530 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
31532 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
31533 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
31535 var targetWidth = this.minWidth - 2 * x;
31536 var targetHeight = this.minHeight - 2 * y;
31540 if((x == 0 && y == 0) || (x == 0 && y > 0)){
31541 scale = targetWidth / width;
31544 if(x > 0 && y == 0){
31545 scale = targetHeight / height;
31548 if(x > 0 && y > 0){
31549 scale = targetWidth / width;
31551 if(width < height){
31552 scale = targetHeight / height;
31556 context.scale(scale, scale);
31558 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
31559 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
31561 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
31562 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
31564 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
31565 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
31567 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
31572 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
31573 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
31575 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
31576 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
31578 var targetWidth = this.minWidth - 2 * x;
31579 var targetHeight = this.minHeight - 2 * y;
31583 if((x == 0 && y == 0) || (x == 0 && y > 0)){
31584 scale = targetWidth / width;
31587 if(x > 0 && y == 0){
31588 scale = targetHeight / height;
31591 if(x > 0 && y > 0){
31592 scale = targetWidth / width;
31594 if(width < height){
31595 scale = targetHeight / height;
31599 context.scale(scale, scale);
31601 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
31602 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
31604 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
31605 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
31607 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
31609 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
31616 this.cropData = canvas.toDataURL(this.cropType);
31618 if(this.fireEvent('crop', this, this.cropData) !== false){
31619 this.process(this.file, this.cropData);
31626 setThumbBoxSize : function()
31630 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
31631 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
31632 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
31634 this.minWidth = width;
31635 this.minHeight = height;
31637 if(this.rotate == 90 || this.rotate == 270){
31638 this.minWidth = height;
31639 this.minHeight = width;
31644 width = Math.ceil(this.minWidth * height / this.minHeight);
31646 if(this.minWidth > this.minHeight){
31648 height = Math.ceil(this.minHeight * width / this.minWidth);
31651 this.thumbEl.setStyle({
31652 width : width + 'px',
31653 height : height + 'px'
31660 setThumbBoxPosition : function()
31662 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
31663 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
31665 this.thumbEl.setLeft(x);
31666 this.thumbEl.setTop(y);
31670 baseRotateLevel : function()
31672 this.baseRotate = 1;
31675 typeof(this.exif) != 'undefined' &&
31676 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
31677 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
31679 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
31682 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
31686 baseScaleLevel : function()
31690 if(this.isDocument){
31692 if(this.baseRotate == 6 || this.baseRotate == 8){
31694 height = this.thumbEl.getHeight();
31695 this.baseScale = height / this.imageEl.OriginWidth;
31697 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
31698 width = this.thumbEl.getWidth();
31699 this.baseScale = width / this.imageEl.OriginHeight;
31705 height = this.thumbEl.getHeight();
31706 this.baseScale = height / this.imageEl.OriginHeight;
31708 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
31709 width = this.thumbEl.getWidth();
31710 this.baseScale = width / this.imageEl.OriginWidth;
31716 if(this.baseRotate == 6 || this.baseRotate == 8){
31718 width = this.thumbEl.getHeight();
31719 this.baseScale = width / this.imageEl.OriginHeight;
31721 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
31722 height = this.thumbEl.getWidth();
31723 this.baseScale = height / this.imageEl.OriginHeight;
31726 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
31727 height = this.thumbEl.getWidth();
31728 this.baseScale = height / this.imageEl.OriginHeight;
31730 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
31731 width = this.thumbEl.getHeight();
31732 this.baseScale = width / this.imageEl.OriginWidth;
31739 width = this.thumbEl.getWidth();
31740 this.baseScale = width / this.imageEl.OriginWidth;
31742 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
31743 height = this.thumbEl.getHeight();
31744 this.baseScale = height / this.imageEl.OriginHeight;
31747 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
31749 height = this.thumbEl.getHeight();
31750 this.baseScale = height / this.imageEl.OriginHeight;
31752 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
31753 width = this.thumbEl.getWidth();
31754 this.baseScale = width / this.imageEl.OriginWidth;
31762 getScaleLevel : function()
31764 return this.baseScale * Math.pow(1.1, this.scale);
31767 onTouchStart : function(e)
31769 if(!this.canvasLoaded){
31770 this.beforeSelectFile(e);
31774 var touches = e.browserEvent.touches;
31780 if(touches.length == 1){
31781 this.onMouseDown(e);
31785 if(touches.length != 2){
31791 for(var i = 0, finger; finger = touches[i]; i++){
31792 coords.push(finger.pageX, finger.pageY);
31795 var x = Math.pow(coords[0] - coords[2], 2);
31796 var y = Math.pow(coords[1] - coords[3], 2);
31798 this.startDistance = Math.sqrt(x + y);
31800 this.startScale = this.scale;
31802 this.pinching = true;
31803 this.dragable = false;
31807 onTouchMove : function(e)
31809 if(!this.pinching && !this.dragable){
31813 var touches = e.browserEvent.touches;
31820 this.onMouseMove(e);
31826 for(var i = 0, finger; finger = touches[i]; i++){
31827 coords.push(finger.pageX, finger.pageY);
31830 var x = Math.pow(coords[0] - coords[2], 2);
31831 var y = Math.pow(coords[1] - coords[3], 2);
31833 this.endDistance = Math.sqrt(x + y);
31835 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
31837 if(!this.zoomable()){
31838 this.scale = this.startScale;
31846 onTouchEnd : function(e)
31848 this.pinching = false;
31849 this.dragable = false;
31853 process : function(file, crop)
31856 this.maskEl.mask(this.loadingText);
31859 this.xhr = new XMLHttpRequest();
31861 file.xhr = this.xhr;
31863 this.xhr.open(this.method, this.url, true);
31866 "Accept": "application/json",
31867 "Cache-Control": "no-cache",
31868 "X-Requested-With": "XMLHttpRequest"
31871 for (var headerName in headers) {
31872 var headerValue = headers[headerName];
31874 this.xhr.setRequestHeader(headerName, headerValue);
31880 this.xhr.onload = function()
31882 _this.xhrOnLoad(_this.xhr);
31885 this.xhr.onerror = function()
31887 _this.xhrOnError(_this.xhr);
31890 var formData = new FormData();
31892 formData.append('returnHTML', 'NO');
31895 formData.append('crop', crop);
31898 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
31899 formData.append(this.paramName, file, file.name);
31902 if(typeof(file.filename) != 'undefined'){
31903 formData.append('filename', file.filename);
31906 if(typeof(file.mimetype) != 'undefined'){
31907 formData.append('mimetype', file.mimetype);
31910 if(this.fireEvent('arrange', this, formData) != false){
31911 this.xhr.send(formData);
31915 xhrOnLoad : function(xhr)
31918 this.maskEl.unmask();
31921 if (xhr.readyState !== 4) {
31922 this.fireEvent('exception', this, xhr);
31926 var response = Roo.decode(xhr.responseText);
31928 if(!response.success){
31929 this.fireEvent('exception', this, xhr);
31933 var response = Roo.decode(xhr.responseText);
31935 this.fireEvent('upload', this, response);
31939 xhrOnError : function()
31942 this.maskEl.unmask();
31945 Roo.log('xhr on error');
31947 var response = Roo.decode(xhr.responseText);
31953 prepare : function(file)
31956 this.maskEl.mask(this.loadingText);
31962 if(typeof(file) === 'string'){
31963 this.loadCanvas(file);
31967 if(!file || !this.urlAPI){
31972 this.cropType = file.type;
31976 if(this.fireEvent('prepare', this, this.file) != false){
31978 var reader = new FileReader();
31980 reader.onload = function (e) {
31981 if (e.target.error) {
31982 Roo.log(e.target.error);
31986 var buffer = e.target.result,
31987 dataView = new DataView(buffer),
31989 maxOffset = dataView.byteLength - 4,
31993 if (dataView.getUint16(0) === 0xffd8) {
31994 while (offset < maxOffset) {
31995 markerBytes = dataView.getUint16(offset);
31997 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
31998 markerLength = dataView.getUint16(offset + 2) + 2;
31999 if (offset + markerLength > dataView.byteLength) {
32000 Roo.log('Invalid meta data: Invalid segment size.');
32004 if(markerBytes == 0xffe1){
32005 _this.parseExifData(
32012 offset += markerLength;
32022 var url = _this.urlAPI.createObjectURL(_this.file);
32024 _this.loadCanvas(url);
32029 reader.readAsArrayBuffer(this.file);
32035 parseExifData : function(dataView, offset, length)
32037 var tiffOffset = offset + 10,
32041 if (dataView.getUint32(offset + 4) !== 0x45786966) {
32042 // No Exif data, might be XMP data instead
32046 // Check for the ASCII code for "Exif" (0x45786966):
32047 if (dataView.getUint32(offset + 4) !== 0x45786966) {
32048 // No Exif data, might be XMP data instead
32051 if (tiffOffset + 8 > dataView.byteLength) {
32052 Roo.log('Invalid Exif data: Invalid segment size.');
32055 // Check for the two null bytes:
32056 if (dataView.getUint16(offset + 8) !== 0x0000) {
32057 Roo.log('Invalid Exif data: Missing byte alignment offset.');
32060 // Check the byte alignment:
32061 switch (dataView.getUint16(tiffOffset)) {
32063 littleEndian = true;
32066 littleEndian = false;
32069 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
32072 // Check for the TIFF tag marker (0x002A):
32073 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
32074 Roo.log('Invalid Exif data: Missing TIFF marker.');
32077 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
32078 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
32080 this.parseExifTags(
32083 tiffOffset + dirOffset,
32088 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
32093 if (dirOffset + 6 > dataView.byteLength) {
32094 Roo.log('Invalid Exif data: Invalid directory offset.');
32097 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
32098 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
32099 if (dirEndOffset + 4 > dataView.byteLength) {
32100 Roo.log('Invalid Exif data: Invalid directory size.');
32103 for (i = 0; i < tagsNumber; i += 1) {
32107 dirOffset + 2 + 12 * i, // tag offset
32111 // Return the offset to the next directory:
32112 return dataView.getUint32(dirEndOffset, littleEndian);
32115 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
32117 var tag = dataView.getUint16(offset, littleEndian);
32119 this.exif[tag] = this.getExifValue(
32123 dataView.getUint16(offset + 2, littleEndian), // tag type
32124 dataView.getUint32(offset + 4, littleEndian), // tag length
32129 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
32131 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
32140 Roo.log('Invalid Exif data: Invalid tag type.');
32144 tagSize = tagType.size * length;
32145 // Determine if the value is contained in the dataOffset bytes,
32146 // or if the value at the dataOffset is a pointer to the actual data:
32147 dataOffset = tagSize > 4 ?
32148 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
32149 if (dataOffset + tagSize > dataView.byteLength) {
32150 Roo.log('Invalid Exif data: Invalid data offset.');
32153 if (length === 1) {
32154 return tagType.getValue(dataView, dataOffset, littleEndian);
32157 for (i = 0; i < length; i += 1) {
32158 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
32161 if (tagType.ascii) {
32163 // Concatenate the chars:
32164 for (i = 0; i < values.length; i += 1) {
32166 // Ignore the terminating NULL byte(s):
32167 if (c === '\u0000') {
32179 Roo.apply(Roo.bootstrap.UploadCropbox, {
32181 'Orientation': 0x0112
32185 1: 0, //'top-left',
32187 3: 180, //'bottom-right',
32188 // 4: 'bottom-left',
32190 6: 90, //'right-top',
32191 // 7: 'right-bottom',
32192 8: 270 //'left-bottom'
32196 // byte, 8-bit unsigned int:
32198 getValue: function (dataView, dataOffset) {
32199 return dataView.getUint8(dataOffset);
32203 // ascii, 8-bit byte:
32205 getValue: function (dataView, dataOffset) {
32206 return String.fromCharCode(dataView.getUint8(dataOffset));
32211 // short, 16 bit int:
32213 getValue: function (dataView, dataOffset, littleEndian) {
32214 return dataView.getUint16(dataOffset, littleEndian);
32218 // long, 32 bit int:
32220 getValue: function (dataView, dataOffset, littleEndian) {
32221 return dataView.getUint32(dataOffset, littleEndian);
32225 // rational = two long values, first is numerator, second is denominator:
32227 getValue: function (dataView, dataOffset, littleEndian) {
32228 return dataView.getUint32(dataOffset, littleEndian) /
32229 dataView.getUint32(dataOffset + 4, littleEndian);
32233 // slong, 32 bit signed int:
32235 getValue: function (dataView, dataOffset, littleEndian) {
32236 return dataView.getInt32(dataOffset, littleEndian);
32240 // srational, two slongs, first is numerator, second is denominator:
32242 getValue: function (dataView, dataOffset, littleEndian) {
32243 return dataView.getInt32(dataOffset, littleEndian) /
32244 dataView.getInt32(dataOffset + 4, littleEndian);
32254 cls : 'btn-group roo-upload-cropbox-rotate-left',
32255 action : 'rotate-left',
32259 cls : 'btn btn-default',
32260 html : '<i class="fa fa-undo"></i>'
32266 cls : 'btn-group roo-upload-cropbox-picture',
32267 action : 'picture',
32271 cls : 'btn btn-default',
32272 html : '<i class="fa fa-picture-o"></i>'
32278 cls : 'btn-group roo-upload-cropbox-rotate-right',
32279 action : 'rotate-right',
32283 cls : 'btn btn-default',
32284 html : '<i class="fa fa-repeat"></i>'
32292 cls : 'btn-group roo-upload-cropbox-rotate-left',
32293 action : 'rotate-left',
32297 cls : 'btn btn-default',
32298 html : '<i class="fa fa-undo"></i>'
32304 cls : 'btn-group roo-upload-cropbox-download',
32305 action : 'download',
32309 cls : 'btn btn-default',
32310 html : '<i class="fa fa-download"></i>'
32316 cls : 'btn-group roo-upload-cropbox-crop',
32321 cls : 'btn btn-default',
32322 html : '<i class="fa fa-crop"></i>'
32328 cls : 'btn-group roo-upload-cropbox-trash',
32333 cls : 'btn btn-default',
32334 html : '<i class="fa fa-trash"></i>'
32340 cls : 'btn-group roo-upload-cropbox-rotate-right',
32341 action : 'rotate-right',
32345 cls : 'btn btn-default',
32346 html : '<i class="fa fa-repeat"></i>'
32354 cls : 'btn-group roo-upload-cropbox-rotate-left',
32355 action : 'rotate-left',
32359 cls : 'btn btn-default',
32360 html : '<i class="fa fa-undo"></i>'
32366 cls : 'btn-group roo-upload-cropbox-rotate-right',
32367 action : 'rotate-right',
32371 cls : 'btn btn-default',
32372 html : '<i class="fa fa-repeat"></i>'
32385 * @class Roo.bootstrap.DocumentManager
32386 * @extends Roo.bootstrap.Component
32387 * Bootstrap DocumentManager class
32388 * @cfg {String} paramName default 'imageUpload'
32389 * @cfg {String} toolTipName default 'filename'
32390 * @cfg {String} method default POST
32391 * @cfg {String} url action url
32392 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
32393 * @cfg {Boolean} multiple multiple upload default true
32394 * @cfg {Number} thumbSize default 300
32395 * @cfg {String} fieldLabel
32396 * @cfg {Number} labelWidth default 4
32397 * @cfg {String} labelAlign (left|top) default left
32398 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
32399 * @cfg {Number} labellg set the width of label (1-12)
32400 * @cfg {Number} labelmd set the width of label (1-12)
32401 * @cfg {Number} labelsm set the width of label (1-12)
32402 * @cfg {Number} labelxs set the width of label (1-12)
32405 * Create a new DocumentManager
32406 * @param {Object} config The config object
32409 Roo.bootstrap.DocumentManager = function(config){
32410 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
32413 this.delegates = [];
32418 * Fire when initial the DocumentManager
32419 * @param {Roo.bootstrap.DocumentManager} this
32424 * inspect selected file
32425 * @param {Roo.bootstrap.DocumentManager} this
32426 * @param {File} file
32431 * Fire when xhr load exception
32432 * @param {Roo.bootstrap.DocumentManager} this
32433 * @param {XMLHttpRequest} xhr
32435 "exception" : true,
32437 * @event afterupload
32438 * Fire when xhr load exception
32439 * @param {Roo.bootstrap.DocumentManager} this
32440 * @param {XMLHttpRequest} xhr
32442 "afterupload" : true,
32445 * prepare the form data
32446 * @param {Roo.bootstrap.DocumentManager} this
32447 * @param {Object} formData
32452 * Fire when remove the file
32453 * @param {Roo.bootstrap.DocumentManager} this
32454 * @param {Object} file
32459 * Fire after refresh the file
32460 * @param {Roo.bootstrap.DocumentManager} this
32465 * Fire after click the image
32466 * @param {Roo.bootstrap.DocumentManager} this
32467 * @param {Object} file
32472 * Fire when upload a image and editable set to true
32473 * @param {Roo.bootstrap.DocumentManager} this
32474 * @param {Object} file
32478 * @event beforeselectfile
32479 * Fire before select file
32480 * @param {Roo.bootstrap.DocumentManager} this
32482 "beforeselectfile" : true,
32485 * Fire before process file
32486 * @param {Roo.bootstrap.DocumentManager} this
32487 * @param {Object} file
32491 * @event previewrendered
32492 * Fire when preview rendered
32493 * @param {Roo.bootstrap.DocumentManager} this
32494 * @param {Object} file
32496 "previewrendered" : true,
32499 "previewResize" : true
32504 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
32513 paramName : 'imageUpload',
32514 toolTipName : 'filename',
32517 labelAlign : 'left',
32527 getAutoCreate : function()
32529 var managerWidget = {
32531 cls : 'roo-document-manager',
32535 cls : 'roo-document-manager-selector',
32540 cls : 'roo-document-manager-uploader',
32544 cls : 'roo-document-manager-upload-btn',
32545 html : '<i class="fa fa-plus"></i>'
32556 cls : 'column col-md-12',
32561 if(this.fieldLabel.length){
32566 cls : 'column col-md-12',
32567 html : this.fieldLabel
32571 cls : 'column col-md-12',
32576 if(this.labelAlign == 'left'){
32581 html : this.fieldLabel
32590 if(this.labelWidth > 12){
32591 content[0].style = "width: " + this.labelWidth + 'px';
32594 if(this.labelWidth < 13 && this.labelmd == 0){
32595 this.labelmd = this.labelWidth;
32598 if(this.labellg > 0){
32599 content[0].cls += ' col-lg-' + this.labellg;
32600 content[1].cls += ' col-lg-' + (12 - this.labellg);
32603 if(this.labelmd > 0){
32604 content[0].cls += ' col-md-' + this.labelmd;
32605 content[1].cls += ' col-md-' + (12 - this.labelmd);
32608 if(this.labelsm > 0){
32609 content[0].cls += ' col-sm-' + this.labelsm;
32610 content[1].cls += ' col-sm-' + (12 - this.labelsm);
32613 if(this.labelxs > 0){
32614 content[0].cls += ' col-xs-' + this.labelxs;
32615 content[1].cls += ' col-xs-' + (12 - this.labelxs);
32623 cls : 'row clearfix',
32631 initEvents : function()
32633 this.managerEl = this.el.select('.roo-document-manager', true).first();
32634 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
32636 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
32637 this.selectorEl.hide();
32640 this.selectorEl.attr('multiple', 'multiple');
32643 this.selectorEl.on('change', this.onFileSelected, this);
32645 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
32646 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
32648 this.uploader.on('click', this.onUploaderClick, this);
32650 this.renderProgressDialog();
32654 window.addEventListener("resize", function() { _this.refresh(); } );
32656 this.fireEvent('initial', this);
32659 renderProgressDialog : function()
32663 this.progressDialog = new Roo.bootstrap.Modal({
32664 cls : 'roo-document-manager-progress-dialog',
32665 allow_close : false,
32676 btnclick : function() {
32677 _this.uploadCancel();
32683 this.progressDialog.render(Roo.get(document.body));
32685 this.progress = new Roo.bootstrap.Progress({
32686 cls : 'roo-document-manager-progress',
32691 this.progress.render(this.progressDialog.getChildContainer());
32693 this.progressBar = new Roo.bootstrap.ProgressBar({
32694 cls : 'roo-document-manager-progress-bar',
32697 aria_valuemax : 12,
32701 this.progressBar.render(this.progress.getChildContainer());
32704 onUploaderClick : function(e)
32706 e.preventDefault();
32708 if(this.fireEvent('beforeselectfile', this) != false){
32709 this.selectorEl.dom.click();
32714 onFileSelected : function(e)
32716 e.preventDefault();
32718 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
32722 Roo.each(this.selectorEl.dom.files, function(file){
32723 if(this.fireEvent('inspect', this, file) != false){
32724 this.files.push(file);
32734 this.selectorEl.dom.value = '';
32736 if(!this.files || !this.files.length){
32740 if(this.boxes > 0 && this.files.length > this.boxes){
32741 this.files = this.files.slice(0, this.boxes);
32744 this.uploader.show();
32746 if(this.boxes > 0 && this.files.length > this.boxes - 1){
32747 this.uploader.hide();
32756 Roo.each(this.files, function(file){
32758 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
32759 var f = this.renderPreview(file);
32764 if(file.type.indexOf('image') != -1){
32765 this.delegates.push(
32767 _this.process(file);
32768 }).createDelegate(this)
32776 _this.process(file);
32777 }).createDelegate(this)
32782 this.files = files;
32784 this.delegates = this.delegates.concat(docs);
32786 if(!this.delegates.length){
32791 this.progressBar.aria_valuemax = this.delegates.length;
32798 arrange : function()
32800 if(!this.delegates.length){
32801 this.progressDialog.hide();
32806 var delegate = this.delegates.shift();
32808 this.progressDialog.show();
32810 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
32812 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
32817 refresh : function()
32819 this.uploader.show();
32821 if(this.boxes > 0 && this.files.length > this.boxes - 1){
32822 this.uploader.hide();
32825 Roo.isTouch ? this.closable(false) : this.closable(true);
32827 this.fireEvent('refresh', this);
32830 onRemove : function(e, el, o)
32832 e.preventDefault();
32834 this.fireEvent('remove', this, o);
32838 remove : function(o)
32842 Roo.each(this.files, function(file){
32843 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
32852 this.files = files;
32859 Roo.each(this.files, function(file){
32864 file.target.remove();
32873 onClick : function(e, el, o)
32875 e.preventDefault();
32877 this.fireEvent('click', this, o);
32881 closable : function(closable)
32883 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
32885 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
32897 xhrOnLoad : function(xhr)
32899 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
32903 if (xhr.readyState !== 4) {
32905 this.fireEvent('exception', this, xhr);
32909 var response = Roo.decode(xhr.responseText);
32911 if(!response.success){
32913 this.fireEvent('exception', this, xhr);
32917 var file = this.renderPreview(response.data);
32919 this.files.push(file);
32923 this.fireEvent('afterupload', this, xhr);
32927 xhrOnError : function(xhr)
32929 Roo.log('xhr on error');
32931 var response = Roo.decode(xhr.responseText);
32938 process : function(file)
32940 if(this.fireEvent('process', this, file) !== false){
32941 if(this.editable && file.type.indexOf('image') != -1){
32942 this.fireEvent('edit', this, file);
32946 this.uploadStart(file, false);
32953 uploadStart : function(file, crop)
32955 this.xhr = new XMLHttpRequest();
32957 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
32962 file.xhr = this.xhr;
32964 this.managerEl.createChild({
32966 cls : 'roo-document-manager-loading',
32970 tooltip : file.name,
32971 cls : 'roo-document-manager-thumb',
32972 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
32978 this.xhr.open(this.method, this.url, true);
32981 "Accept": "application/json",
32982 "Cache-Control": "no-cache",
32983 "X-Requested-With": "XMLHttpRequest"
32986 for (var headerName in headers) {
32987 var headerValue = headers[headerName];
32989 this.xhr.setRequestHeader(headerName, headerValue);
32995 this.xhr.onload = function()
32997 _this.xhrOnLoad(_this.xhr);
33000 this.xhr.onerror = function()
33002 _this.xhrOnError(_this.xhr);
33005 var formData = new FormData();
33007 formData.append('returnHTML', 'NO');
33010 formData.append('crop', crop);
33013 formData.append(this.paramName, file, file.name);
33020 if(this.fireEvent('prepare', this, formData, options) != false){
33022 if(options.manually){
33026 this.xhr.send(formData);
33030 this.uploadCancel();
33033 uploadCancel : function()
33039 this.delegates = [];
33041 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
33048 renderPreview : function(file)
33050 if(typeof(file.target) != 'undefined' && file.target){
33054 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
33056 var previewEl = this.managerEl.createChild({
33058 cls : 'roo-document-manager-preview',
33062 tooltip : file[this.toolTipName],
33063 cls : 'roo-document-manager-thumb',
33064 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
33069 html : '<i class="fa fa-times-circle"></i>'
33074 var close = previewEl.select('button.close', true).first();
33076 close.on('click', this.onRemove, this, file);
33078 file.target = previewEl;
33080 var image = previewEl.select('img', true).first();
33084 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
33086 image.on('click', this.onClick, this, file);
33088 this.fireEvent('previewrendered', this, file);
33094 onPreviewLoad : function(file, image)
33096 if(typeof(file.target) == 'undefined' || !file.target){
33100 var width = image.dom.naturalWidth || image.dom.width;
33101 var height = image.dom.naturalHeight || image.dom.height;
33103 if(!this.previewResize) {
33107 if(width > height){
33108 file.target.addClass('wide');
33112 file.target.addClass('tall');
33117 uploadFromSource : function(file, crop)
33119 this.xhr = new XMLHttpRequest();
33121 this.managerEl.createChild({
33123 cls : 'roo-document-manager-loading',
33127 tooltip : file.name,
33128 cls : 'roo-document-manager-thumb',
33129 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
33135 this.xhr.open(this.method, this.url, true);
33138 "Accept": "application/json",
33139 "Cache-Control": "no-cache",
33140 "X-Requested-With": "XMLHttpRequest"
33143 for (var headerName in headers) {
33144 var headerValue = headers[headerName];
33146 this.xhr.setRequestHeader(headerName, headerValue);
33152 this.xhr.onload = function()
33154 _this.xhrOnLoad(_this.xhr);
33157 this.xhr.onerror = function()
33159 _this.xhrOnError(_this.xhr);
33162 var formData = new FormData();
33164 formData.append('returnHTML', 'NO');
33166 formData.append('crop', crop);
33168 if(typeof(file.filename) != 'undefined'){
33169 formData.append('filename', file.filename);
33172 if(typeof(file.mimetype) != 'undefined'){
33173 formData.append('mimetype', file.mimetype);
33178 if(this.fireEvent('prepare', this, formData) != false){
33179 this.xhr.send(formData);
33189 * @class Roo.bootstrap.DocumentViewer
33190 * @extends Roo.bootstrap.Component
33191 * Bootstrap DocumentViewer class
33192 * @cfg {Boolean} showDownload (true|false) show download button (default true)
33193 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
33196 * Create a new DocumentViewer
33197 * @param {Object} config The config object
33200 Roo.bootstrap.DocumentViewer = function(config){
33201 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
33206 * Fire after initEvent
33207 * @param {Roo.bootstrap.DocumentViewer} this
33213 * @param {Roo.bootstrap.DocumentViewer} this
33218 * Fire after download button
33219 * @param {Roo.bootstrap.DocumentViewer} this
33224 * Fire after trash button
33225 * @param {Roo.bootstrap.DocumentViewer} this
33232 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
33234 showDownload : true,
33238 getAutoCreate : function()
33242 cls : 'roo-document-viewer',
33246 cls : 'roo-document-viewer-body',
33250 cls : 'roo-document-viewer-thumb',
33254 cls : 'roo-document-viewer-image'
33262 cls : 'roo-document-viewer-footer',
33265 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
33269 cls : 'btn-group roo-document-viewer-download',
33273 cls : 'btn btn-default',
33274 html : '<i class="fa fa-download"></i>'
33280 cls : 'btn-group roo-document-viewer-trash',
33284 cls : 'btn btn-default',
33285 html : '<i class="fa fa-trash"></i>'
33298 initEvents : function()
33300 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
33301 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
33303 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
33304 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
33306 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
33307 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
33309 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
33310 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
33312 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
33313 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
33315 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
33316 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
33318 this.bodyEl.on('click', this.onClick, this);
33319 this.downloadBtn.on('click', this.onDownload, this);
33320 this.trashBtn.on('click', this.onTrash, this);
33322 this.downloadBtn.hide();
33323 this.trashBtn.hide();
33325 if(this.showDownload){
33326 this.downloadBtn.show();
33329 if(this.showTrash){
33330 this.trashBtn.show();
33333 if(!this.showDownload && !this.showTrash) {
33334 this.footerEl.hide();
33339 initial : function()
33341 this.fireEvent('initial', this);
33345 onClick : function(e)
33347 e.preventDefault();
33349 this.fireEvent('click', this);
33352 onDownload : function(e)
33354 e.preventDefault();
33356 this.fireEvent('download', this);
33359 onTrash : function(e)
33361 e.preventDefault();
33363 this.fireEvent('trash', this);
33375 * @class Roo.bootstrap.form.FieldLabel
33376 * @extends Roo.bootstrap.Component
33377 * Bootstrap FieldLabel class
33378 * @cfg {String} html contents of the element
33379 * @cfg {String} tag tag of the element default label
33380 * @cfg {String} cls class of the element
33381 * @cfg {String} target label target
33382 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
33383 * @cfg {String} invalidClass DEPRICATED - BS4 uses is-invalid
33384 * @cfg {String} validClass DEPRICATED - BS4 uses is-valid
33385 * @cfg {String} iconTooltip default "This field is required"
33386 * @cfg {String} indicatorpos (left|right) default left
33389 * Create a new FieldLabel
33390 * @param {Object} config The config object
33393 Roo.bootstrap.form.FieldLabel = function(config){
33394 Roo.bootstrap.Element.superclass.constructor.call(this, config);
33399 * Fires after the field has been marked as invalid.
33400 * @param {Roo.form.FieldLabel} this
33401 * @param {String} msg The validation message
33406 * Fires after the field has been validated with no errors.
33407 * @param {Roo.form.FieldLabel} this
33413 Roo.extend(Roo.bootstrap.form.FieldLabel, Roo.bootstrap.Component, {
33420 invalidClass : 'has-warning',
33421 validClass : 'has-success',
33422 iconTooltip : 'This field is required',
33423 indicatorpos : 'left',
33425 getAutoCreate : function(){
33428 if (!this.allowBlank) {
33434 cls : 'roo-bootstrap-field-label ' + this.cls,
33439 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star ' + cls,
33440 tooltip : this.iconTooltip
33449 if(this.indicatorpos == 'right'){
33452 cls : 'roo-bootstrap-field-label ' + this.cls,
33461 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star '+ cls,
33462 tooltip : this.iconTooltip
33471 initEvents: function()
33473 Roo.bootstrap.Element.superclass.initEvents.call(this);
33475 this.indicator = this.indicatorEl();
33477 if(this.indicator){
33478 this.indicator.removeClass('visible');
33479 this.indicator.addClass('invisible');
33482 Roo.bootstrap.form.FieldLabel.register(this);
33485 indicatorEl : function()
33487 var indicator = this.el.select('i.roo-required-indicator',true).first();
33498 * Mark this field as valid
33500 markValid : function()
33502 if(this.indicator){
33503 this.indicator.removeClass('visible');
33504 this.indicator.addClass('invisible');
33506 if (Roo.bootstrap.version == 3) {
33507 this.el.removeClass(this.invalidClass);
33508 this.el.addClass(this.validClass);
33510 this.el.removeClass('is-invalid');
33511 this.el.addClass('is-valid');
33515 this.fireEvent('valid', this);
33519 * Mark this field as invalid
33520 * @param {String} msg The validation message
33522 markInvalid : function(msg)
33524 if(this.indicator){
33525 this.indicator.removeClass('invisible');
33526 this.indicator.addClass('visible');
33528 if (Roo.bootstrap.version == 3) {
33529 this.el.removeClass(this.validClass);
33530 this.el.addClass(this.invalidClass);
33532 this.el.removeClass('is-valid');
33533 this.el.addClass('is-invalid');
33537 this.fireEvent('invalid', this, msg);
33543 Roo.apply(Roo.bootstrap.form.FieldLabel, {
33548 * register a FieldLabel Group
33549 * @param {Roo.bootstrap.form.FieldLabel} the FieldLabel to add
33551 register : function(label)
33553 if(this.groups.hasOwnProperty(label.target)){
33557 this.groups[label.target] = label;
33561 * fetch a FieldLabel Group based on the target
33562 * @param {string} target
33563 * @returns {Roo.bootstrap.form.FieldLabel} the CheckBox group
33565 get: function(target) {
33566 if (typeof(this.groups[target]) == 'undefined') {
33570 return this.groups[target] ;
33579 * page DateSplitField.
33585 * @class Roo.bootstrap.form.DateSplitField
33586 * @extends Roo.bootstrap.Component
33587 * Bootstrap DateSplitField class
33588 * @cfg {string} fieldLabel - the label associated
33589 * @cfg {Number} labelWidth set the width of label (0-12)
33590 * @cfg {String} labelAlign (top|left)
33591 * @cfg {Boolean} dayAllowBlank (true|false) default false
33592 * @cfg {Boolean} monthAllowBlank (true|false) default false
33593 * @cfg {Boolean} yearAllowBlank (true|false) default false
33594 * @cfg {string} dayPlaceholder
33595 * @cfg {string} monthPlaceholder
33596 * @cfg {string} yearPlaceholder
33597 * @cfg {string} dayFormat default 'd'
33598 * @cfg {string} monthFormat default 'm'
33599 * @cfg {string} yearFormat default 'Y'
33600 * @cfg {Number} labellg set the width of label (1-12)
33601 * @cfg {Number} labelmd set the width of label (1-12)
33602 * @cfg {Number} labelsm set the width of label (1-12)
33603 * @cfg {Number} labelxs set the width of label (1-12)
33607 * Create a new DateSplitField
33608 * @param {Object} config The config object
33611 Roo.bootstrap.form.DateSplitField = function(config){
33612 Roo.bootstrap.form.DateSplitField.superclass.constructor.call(this, config);
33618 * getting the data of years
33619 * @param {Roo.bootstrap.form.DateSplitField} this
33620 * @param {Object} years
33625 * getting the data of days
33626 * @param {Roo.bootstrap.form.DateSplitField} this
33627 * @param {Object} days
33632 * Fires after the field has been marked as invalid.
33633 * @param {Roo.form.Field} this
33634 * @param {String} msg The validation message
33639 * Fires after the field has been validated with no errors.
33640 * @param {Roo.form.Field} this
33646 Roo.extend(Roo.bootstrap.form.DateSplitField, Roo.bootstrap.Component, {
33649 labelAlign : 'top',
33651 dayAllowBlank : false,
33652 monthAllowBlank : false,
33653 yearAllowBlank : false,
33654 dayPlaceholder : '',
33655 monthPlaceholder : '',
33656 yearPlaceholder : '',
33660 isFormField : true,
33666 getAutoCreate : function()
33670 cls : 'row roo-date-split-field-group',
33675 cls : 'form-hidden-field roo-date-split-field-group-value',
33681 var labelCls = 'col-md-12';
33682 var contentCls = 'col-md-4';
33684 if(this.fieldLabel){
33688 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
33692 html : this.fieldLabel
33697 if(this.labelAlign == 'left'){
33699 if(this.labelWidth > 12){
33700 label.style = "width: " + this.labelWidth + 'px';
33703 if(this.labelWidth < 13 && this.labelmd == 0){
33704 this.labelmd = this.labelWidth;
33707 if(this.labellg > 0){
33708 labelCls = ' col-lg-' + this.labellg;
33709 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
33712 if(this.labelmd > 0){
33713 labelCls = ' col-md-' + this.labelmd;
33714 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
33717 if(this.labelsm > 0){
33718 labelCls = ' col-sm-' + this.labelsm;
33719 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
33722 if(this.labelxs > 0){
33723 labelCls = ' col-xs-' + this.labelxs;
33724 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
33728 label.cls += ' ' + labelCls;
33730 cfg.cn.push(label);
33733 Roo.each(['day', 'month', 'year'], function(t){
33736 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
33743 inputEl: function ()
33745 return this.el.select('.roo-date-split-field-group-value', true).first();
33748 onRender : function(ct, position)
33752 Roo.bootstrap.DateSplitFiel.superclass.onRender.call(this, ct, position);
33754 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
33756 this.dayField = new Roo.bootstrap.form.ComboBox({
33757 allowBlank : this.dayAllowBlank,
33758 alwaysQuery : true,
33759 displayField : 'value',
33762 forceSelection : true,
33764 placeholder : this.dayPlaceholder,
33765 selectOnFocus : true,
33766 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
33767 triggerAction : 'all',
33769 valueField : 'value',
33770 store : new Roo.data.SimpleStore({
33771 data : (function() {
33773 _this.fireEvent('days', _this, days);
33776 fields : [ 'value' ]
33779 select : function (_self, record, index)
33781 _this.setValue(_this.getValue());
33786 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
33788 this.monthField = new Roo.bootstrap.form.MonthField({
33789 after : '<i class=\"fa fa-calendar\"></i>',
33790 allowBlank : this.monthAllowBlank,
33791 placeholder : this.monthPlaceholder,
33794 render : function (_self)
33796 this.el.select('span.input-group-addon', true).first().on('click', function(e){
33797 e.preventDefault();
33801 select : function (_self, oldvalue, newvalue)
33803 _this.setValue(_this.getValue());
33808 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
33810 this.yearField = new Roo.bootstrap.form.ComboBox({
33811 allowBlank : this.yearAllowBlank,
33812 alwaysQuery : true,
33813 displayField : 'value',
33816 forceSelection : true,
33818 placeholder : this.yearPlaceholder,
33819 selectOnFocus : true,
33820 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
33821 triggerAction : 'all',
33823 valueField : 'value',
33824 store : new Roo.data.SimpleStore({
33825 data : (function() {
33827 _this.fireEvent('years', _this, years);
33830 fields : [ 'value' ]
33833 select : function (_self, record, index)
33835 _this.setValue(_this.getValue());
33840 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
33843 setValue : function(v, format)
33845 this.inputEl.dom.value = v;
33847 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
33849 var d = Date.parseDate(v, f);
33856 this.setDay(d.format(this.dayFormat));
33857 this.setMonth(d.format(this.monthFormat));
33858 this.setYear(d.format(this.yearFormat));
33865 setDay : function(v)
33867 this.dayField.setValue(v);
33868 this.inputEl.dom.value = this.getValue();
33873 setMonth : function(v)
33875 this.monthField.setValue(v, true);
33876 this.inputEl.dom.value = this.getValue();
33881 setYear : function(v)
33883 this.yearField.setValue(v);
33884 this.inputEl.dom.value = this.getValue();
33889 getDay : function()
33891 return this.dayField.getValue();
33894 getMonth : function()
33896 return this.monthField.getValue();
33899 getYear : function()
33901 return this.yearField.getValue();
33904 getValue : function()
33906 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
33908 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
33918 this.inputEl.dom.value = '';
33923 validate : function()
33925 var d = this.dayField.validate();
33926 var m = this.monthField.validate();
33927 var y = this.yearField.validate();
33932 (!this.dayAllowBlank && !d) ||
33933 (!this.monthAllowBlank && !m) ||
33934 (!this.yearAllowBlank && !y)
33939 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
33948 this.markInvalid();
33953 markValid : function()
33956 var label = this.el.select('label', true).first();
33957 var icon = this.el.select('i.fa-star', true).first();
33963 this.fireEvent('valid', this);
33967 * Mark this field as invalid
33968 * @param {String} msg The validation message
33970 markInvalid : function(msg)
33973 var label = this.el.select('label', true).first();
33974 var icon = this.el.select('i.fa-star', true).first();
33976 if(label && !icon){
33977 this.el.select('.roo-date-split-field-label', true).createChild({
33979 cls : 'text-danger fa fa-lg fa-star',
33980 tooltip : 'This field is required',
33981 style : 'margin-right:5px;'
33985 this.fireEvent('invalid', this, msg);
33988 clearInvalid : function()
33990 var label = this.el.select('label', true).first();
33991 var icon = this.el.select('i.fa-star', true).first();
33997 this.fireEvent('valid', this);
34000 getName: function()
34010 * @class Roo.bootstrap.LayoutMasonry
34011 * @extends Roo.bootstrap.Component
34012 * @children Roo.bootstrap.Element Roo.bootstrap.Img Roo.bootstrap.MasonryBrick
34013 * Bootstrap Layout Masonry class
34016 * http://masonry.desandro.com
34018 * The idea is to render all the bricks based on vertical width...
34020 * The original code extends 'outlayer' - we might need to use that....
34023 * Create a new Element
34024 * @param {Object} config The config object
34027 Roo.bootstrap.LayoutMasonry = function(config){
34029 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
34033 Roo.bootstrap.LayoutMasonry.register(this);
34039 * Fire after layout the items
34040 * @param {Roo.bootstrap.LayoutMasonry} this
34041 * @param {Roo.EventObject} e
34048 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
34051 * @cfg {Boolean} isLayoutInstant = no animation?
34053 isLayoutInstant : false, // needed?
34056 * @cfg {Number} boxWidth width of the columns
34061 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
34066 * @cfg {Number} padWidth padding below box..
34071 * @cfg {Number} gutter gutter width..
34076 * @cfg {Number} maxCols maximum number of columns
34082 * @cfg {Boolean} isAutoInitial defalut true
34084 isAutoInitial : true,
34089 * @cfg {Boolean} isHorizontal defalut false
34091 isHorizontal : false,
34093 currentSize : null,
34099 bricks: null, //CompositeElement
34103 _isLayoutInited : false,
34105 // isAlternative : false, // only use for vertical layout...
34108 * @cfg {Number} alternativePadWidth padding below box..
34110 alternativePadWidth : 50,
34112 selectedBrick : [],
34114 getAutoCreate : function(){
34116 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
34120 cls: 'blog-masonary-wrapper ' + this.cls,
34122 cls : 'mas-boxes masonary'
34129 getChildContainer: function( )
34131 if (this.boxesEl) {
34132 return this.boxesEl;
34135 this.boxesEl = this.el.select('.mas-boxes').first();
34137 return this.boxesEl;
34141 initEvents : function()
34145 if(this.isAutoInitial){
34146 Roo.log('hook children rendered');
34147 this.on('childrenrendered', function() {
34148 Roo.log('children rendered');
34154 initial : function()
34156 this.selectedBrick = [];
34158 this.currentSize = this.el.getBox(true);
34160 Roo.EventManager.onWindowResize(this.resize, this);
34162 if(!this.isAutoInitial){
34170 //this.layout.defer(500,this);
34174 resize : function()
34176 var cs = this.el.getBox(true);
34179 this.currentSize.width == cs.width &&
34180 this.currentSize.x == cs.x &&
34181 this.currentSize.height == cs.height &&
34182 this.currentSize.y == cs.y
34184 Roo.log("no change in with or X or Y");
34188 this.currentSize = cs;
34194 layout : function()
34196 this._resetLayout();
34198 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
34200 this.layoutItems( isInstant );
34202 this._isLayoutInited = true;
34204 this.fireEvent('layout', this);
34208 _resetLayout : function()
34210 if(this.isHorizontal){
34211 this.horizontalMeasureColumns();
34215 this.verticalMeasureColumns();
34219 verticalMeasureColumns : function()
34221 this.getContainerWidth();
34223 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
34224 // this.colWidth = Math.floor(this.containerWidth * 0.8);
34228 var boxWidth = this.boxWidth + this.padWidth;
34230 if(this.containerWidth < this.boxWidth){
34231 boxWidth = this.containerWidth
34234 var containerWidth = this.containerWidth;
34236 var cols = Math.floor(containerWidth / boxWidth);
34238 this.cols = Math.max( cols, 1 );
34240 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
34242 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
34244 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
34246 this.colWidth = boxWidth + avail - this.padWidth;
34248 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
34249 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
34252 horizontalMeasureColumns : function()
34254 this.getContainerWidth();
34256 var boxWidth = this.boxWidth;
34258 if(this.containerWidth < boxWidth){
34259 boxWidth = this.containerWidth;
34262 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
34264 this.el.setHeight(boxWidth);
34268 getContainerWidth : function()
34270 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
34273 layoutItems : function( isInstant )
34275 Roo.log(this.bricks);
34277 var items = Roo.apply([], this.bricks);
34279 if(this.isHorizontal){
34280 this._horizontalLayoutItems( items , isInstant );
34284 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
34285 // this._verticalAlternativeLayoutItems( items , isInstant );
34289 this._verticalLayoutItems( items , isInstant );
34293 _verticalLayoutItems : function ( items , isInstant)
34295 if ( !items || !items.length ) {
34300 ['xs', 'xs', 'xs', 'tall'],
34301 ['xs', 'xs', 'tall'],
34302 ['xs', 'xs', 'sm'],
34303 ['xs', 'xs', 'xs'],
34309 ['sm', 'xs', 'xs'],
34313 ['tall', 'xs', 'xs', 'xs'],
34314 ['tall', 'xs', 'xs'],
34326 Roo.each(items, function(item, k){
34328 switch (item.size) {
34329 // these layouts take up a full box,
34340 boxes.push([item]);
34363 var filterPattern = function(box, length)
34371 var pattern = box.slice(0, length);
34375 Roo.each(pattern, function(i){
34376 format.push(i.size);
34379 Roo.each(standard, function(s){
34381 if(String(s) != String(format)){
34390 if(!match && length == 1){
34395 filterPattern(box, length - 1);
34399 queue.push(pattern);
34401 box = box.slice(length, box.length);
34403 filterPattern(box, 4);
34409 Roo.each(boxes, function(box, k){
34415 if(box.length == 1){
34420 filterPattern(box, 4);
34424 this._processVerticalLayoutQueue( queue, isInstant );
34428 // _verticalAlternativeLayoutItems : function( items , isInstant )
34430 // if ( !items || !items.length ) {
34434 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
34438 _horizontalLayoutItems : function ( items , isInstant)
34440 if ( !items || !items.length || items.length < 3) {
34446 var eItems = items.slice(0, 3);
34448 items = items.slice(3, items.length);
34451 ['xs', 'xs', 'xs', 'wide'],
34452 ['xs', 'xs', 'wide'],
34453 ['xs', 'xs', 'sm'],
34454 ['xs', 'xs', 'xs'],
34460 ['sm', 'xs', 'xs'],
34464 ['wide', 'xs', 'xs', 'xs'],
34465 ['wide', 'xs', 'xs'],
34478 Roo.each(items, function(item, k){
34480 switch (item.size) {
34491 boxes.push([item]);
34515 var filterPattern = function(box, length)
34523 var pattern = box.slice(0, length);
34527 Roo.each(pattern, function(i){
34528 format.push(i.size);
34531 Roo.each(standard, function(s){
34533 if(String(s) != String(format)){
34542 if(!match && length == 1){
34547 filterPattern(box, length - 1);
34551 queue.push(pattern);
34553 box = box.slice(length, box.length);
34555 filterPattern(box, 4);
34561 Roo.each(boxes, function(box, k){
34567 if(box.length == 1){
34572 filterPattern(box, 4);
34579 var pos = this.el.getBox(true);
34583 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
34585 var hit_end = false;
34587 Roo.each(queue, function(box){
34591 Roo.each(box, function(b){
34593 b.el.setVisibilityMode(Roo.Element.DISPLAY);
34603 Roo.each(box, function(b){
34605 b.el.setVisibilityMode(Roo.Element.DISPLAY);
34608 mx = Math.max(mx, b.x);
34612 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
34616 Roo.each(box, function(b){
34618 b.el.setVisibilityMode(Roo.Element.DISPLAY);
34632 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
34635 /** Sets position of item in DOM
34636 * @param {Element} item
34637 * @param {Number} x - horizontal position
34638 * @param {Number} y - vertical position
34639 * @param {Boolean} isInstant - disables transitions
34641 _processVerticalLayoutQueue : function( queue, isInstant )
34643 var pos = this.el.getBox(true);
34648 for (var i = 0; i < this.cols; i++){
34652 Roo.each(queue, function(box, k){
34654 var col = k % this.cols;
34656 Roo.each(box, function(b,kk){
34658 b.el.position('absolute');
34660 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
34661 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
34663 if(b.size == 'md-left' || b.size == 'md-right'){
34664 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
34665 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
34668 b.el.setWidth(width);
34669 b.el.setHeight(height);
34671 b.el.select('iframe',true).setSize(width,height);
34675 for (var i = 0; i < this.cols; i++){
34677 if(maxY[i] < maxY[col]){
34682 col = Math.min(col, i);
34686 x = pos.x + col * (this.colWidth + this.padWidth);
34690 var positions = [];
34692 switch (box.length){
34694 positions = this.getVerticalOneBoxColPositions(x, y, box);
34697 positions = this.getVerticalTwoBoxColPositions(x, y, box);
34700 positions = this.getVerticalThreeBoxColPositions(x, y, box);
34703 positions = this.getVerticalFourBoxColPositions(x, y, box);
34709 Roo.each(box, function(b,kk){
34711 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
34713 var sz = b.el.getSize();
34715 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
34723 for (var i = 0; i < this.cols; i++){
34724 mY = Math.max(mY, maxY[i]);
34727 this.el.setHeight(mY - pos.y);
34731 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
34733 // var pos = this.el.getBox(true);
34736 // var maxX = pos.right;
34738 // var maxHeight = 0;
34740 // Roo.each(items, function(item, k){
34744 // item.el.position('absolute');
34746 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
34748 // item.el.setWidth(width);
34750 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
34752 // item.el.setHeight(height);
34755 // item.el.setXY([x, y], isInstant ? false : true);
34757 // item.el.setXY([maxX - width, y], isInstant ? false : true);
34760 // y = y + height + this.alternativePadWidth;
34762 // maxHeight = maxHeight + height + this.alternativePadWidth;
34766 // this.el.setHeight(maxHeight);
34770 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
34772 var pos = this.el.getBox(true);
34777 var maxX = pos.right;
34779 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
34781 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
34783 Roo.each(queue, function(box, k){
34785 Roo.each(box, function(b, kk){
34787 b.el.position('absolute');
34789 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
34790 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
34792 if(b.size == 'md-left' || b.size == 'md-right'){
34793 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
34794 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
34797 b.el.setWidth(width);
34798 b.el.setHeight(height);
34806 var positions = [];
34808 switch (box.length){
34810 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
34813 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
34816 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
34819 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
34825 Roo.each(box, function(b,kk){
34827 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
34829 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
34837 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
34839 Roo.each(eItems, function(b,k){
34841 b.size = (k == 0) ? 'sm' : 'xs';
34842 b.x = (k == 0) ? 2 : 1;
34843 b.y = (k == 0) ? 2 : 1;
34845 b.el.position('absolute');
34847 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
34849 b.el.setWidth(width);
34851 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
34853 b.el.setHeight(height);
34857 var positions = [];
34860 x : maxX - this.unitWidth * 2 - this.gutter,
34865 x : maxX - this.unitWidth,
34866 y : minY + (this.unitWidth + this.gutter) * 2
34870 x : maxX - this.unitWidth * 3 - this.gutter * 2,
34874 Roo.each(eItems, function(b,k){
34876 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
34882 getVerticalOneBoxColPositions : function(x, y, box)
34886 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
34888 if(box[0].size == 'md-left'){
34892 if(box[0].size == 'md-right'){
34897 x : x + (this.unitWidth + this.gutter) * rand,
34904 getVerticalTwoBoxColPositions : function(x, y, box)
34908 if(box[0].size == 'xs'){
34912 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
34916 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
34930 x : x + (this.unitWidth + this.gutter) * 2,
34931 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
34938 getVerticalThreeBoxColPositions : function(x, y, box)
34942 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
34950 x : x + (this.unitWidth + this.gutter) * 1,
34955 x : x + (this.unitWidth + this.gutter) * 2,
34963 if(box[0].size == 'xs' && box[1].size == 'xs'){
34972 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
34976 x : x + (this.unitWidth + this.gutter) * 1,
34990 x : x + (this.unitWidth + this.gutter) * 2,
34995 x : x + (this.unitWidth + this.gutter) * 2,
34996 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
35003 getVerticalFourBoxColPositions : function(x, y, box)
35007 if(box[0].size == 'xs'){
35016 y : y + (this.unitHeight + this.gutter) * 1
35021 y : y + (this.unitHeight + this.gutter) * 2
35025 x : x + (this.unitWidth + this.gutter) * 1,
35039 x : x + (this.unitWidth + this.gutter) * 2,
35044 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
35045 y : y + (this.unitHeight + this.gutter) * 1
35049 x : x + (this.unitWidth + this.gutter) * 2,
35050 y : y + (this.unitWidth + this.gutter) * 2
35057 getHorizontalOneBoxColPositions : function(maxX, minY, box)
35061 if(box[0].size == 'md-left'){
35063 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
35070 if(box[0].size == 'md-right'){
35072 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
35073 y : minY + (this.unitWidth + this.gutter) * 1
35079 var rand = Math.floor(Math.random() * (4 - box[0].y));
35082 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35083 y : minY + (this.unitWidth + this.gutter) * rand
35090 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
35094 if(box[0].size == 'xs'){
35097 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35102 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35103 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
35111 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35116 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35117 y : minY + (this.unitWidth + this.gutter) * 2
35124 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
35128 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
35131 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35136 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35137 y : minY + (this.unitWidth + this.gutter) * 1
35141 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
35142 y : minY + (this.unitWidth + this.gutter) * 2
35149 if(box[0].size == 'xs' && box[1].size == 'xs'){
35152 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35157 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35162 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
35163 y : minY + (this.unitWidth + this.gutter) * 1
35171 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35176 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35177 y : minY + (this.unitWidth + this.gutter) * 2
35181 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
35182 y : minY + (this.unitWidth + this.gutter) * 2
35189 getHorizontalFourBoxColPositions : function(maxX, minY, box)
35193 if(box[0].size == 'xs'){
35196 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35201 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35206 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),
35211 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
35212 y : minY + (this.unitWidth + this.gutter) * 1
35220 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35225 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35226 y : minY + (this.unitWidth + this.gutter) * 2
35230 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
35231 y : minY + (this.unitWidth + this.gutter) * 2
35235 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),
35236 y : minY + (this.unitWidth + this.gutter) * 2
35244 * remove a Masonry Brick
35245 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
35247 removeBrick : function(brick_id)
35253 for (var i = 0; i<this.bricks.length; i++) {
35254 if (this.bricks[i].id == brick_id) {
35255 this.bricks.splice(i,1);
35256 this.el.dom.removeChild(Roo.get(brick_id).dom);
35263 * adds a Masonry Brick
35264 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
35266 addBrick : function(cfg)
35268 var cn = new Roo.bootstrap.MasonryBrick(cfg);
35269 //this.register(cn);
35270 cn.parentId = this.id;
35271 cn.render(this.el);
35276 * register a Masonry Brick
35277 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
35280 register : function(brick)
35282 this.bricks.push(brick);
35283 brick.masonryId = this.id;
35287 * clear all the Masonry Brick
35289 clearAll : function()
35292 //this.getChildContainer().dom.innerHTML = "";
35293 this.el.dom.innerHTML = '';
35296 getSelected : function()
35298 if (!this.selectedBrick) {
35302 return this.selectedBrick;
35306 Roo.apply(Roo.bootstrap.LayoutMasonry, {
35310 * register a Masonry Layout
35311 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
35314 register : function(layout)
35316 this.groups[layout.id] = layout;
35319 * fetch a Masonry Layout based on the masonry layout ID
35320 * @param {string} the masonry layout to add
35321 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
35324 get: function(layout_id) {
35325 if (typeof(this.groups[layout_id]) == 'undefined') {
35328 return this.groups[layout_id] ;
35340 * http://masonry.desandro.com
35342 * The idea is to render all the bricks based on vertical width...
35344 * The original code extends 'outlayer' - we might need to use that....
35350 * @class Roo.bootstrap.LayoutMasonryAuto
35351 * @extends Roo.bootstrap.Component
35352 * Bootstrap Layout Masonry class
35355 * Create a new Element
35356 * @param {Object} config The config object
35359 Roo.bootstrap.LayoutMasonryAuto = function(config){
35360 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
35363 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
35366 * @cfg {Boolean} isFitWidth - resize the width..
35368 isFitWidth : false, // options..
35370 * @cfg {Boolean} isOriginLeft = left align?
35372 isOriginLeft : true,
35374 * @cfg {Boolean} isOriginTop = top align?
35376 isOriginTop : false,
35378 * @cfg {Boolean} isLayoutInstant = no animation?
35380 isLayoutInstant : false, // needed?
35382 * @cfg {Boolean} isResizingContainer = not sure if this is used..
35384 isResizingContainer : true,
35386 * @cfg {Number} columnWidth width of the columns
35392 * @cfg {Number} maxCols maximum number of columns
35397 * @cfg {Number} padHeight padding below box..
35403 * @cfg {Boolean} isAutoInitial defalut true
35406 isAutoInitial : true,
35412 initialColumnWidth : 0,
35413 currentSize : null,
35415 colYs : null, // array.
35422 bricks: null, //CompositeElement
35423 cols : 0, // array?
35424 // element : null, // wrapped now this.el
35425 _isLayoutInited : null,
35428 getAutoCreate : function(){
35432 cls: 'blog-masonary-wrapper ' + this.cls,
35434 cls : 'mas-boxes masonary'
35441 getChildContainer: function( )
35443 if (this.boxesEl) {
35444 return this.boxesEl;
35447 this.boxesEl = this.el.select('.mas-boxes').first();
35449 return this.boxesEl;
35453 initEvents : function()
35457 if(this.isAutoInitial){
35458 Roo.log('hook children rendered');
35459 this.on('childrenrendered', function() {
35460 Roo.log('children rendered');
35467 initial : function()
35469 this.reloadItems();
35471 this.currentSize = this.el.getBox(true);
35473 /// was window resize... - let's see if this works..
35474 Roo.EventManager.onWindowResize(this.resize, this);
35476 if(!this.isAutoInitial){
35481 this.layout.defer(500,this);
35484 reloadItems: function()
35486 this.bricks = this.el.select('.masonry-brick', true);
35488 this.bricks.each(function(b) {
35489 //Roo.log(b.getSize());
35490 if (!b.attr('originalwidth')) {
35491 b.attr('originalwidth', b.getSize().width);
35496 Roo.log(this.bricks.elements.length);
35499 resize : function()
35502 var cs = this.el.getBox(true);
35504 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
35505 Roo.log("no change in with or X");
35508 this.currentSize = cs;
35512 layout : function()
35515 this._resetLayout();
35516 //this._manageStamps();
35518 // don't animate first layout
35519 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
35520 this.layoutItems( isInstant );
35522 // flag for initalized
35523 this._isLayoutInited = true;
35526 layoutItems : function( isInstant )
35528 //var items = this._getItemsForLayout( this.items );
35529 // original code supports filtering layout items.. we just ignore it..
35531 this._layoutItems( this.bricks , isInstant );
35533 this._postLayout();
35535 _layoutItems : function ( items , isInstant)
35537 //this.fireEvent( 'layout', this, items );
35540 if ( !items || !items.elements.length ) {
35541 // no items, emit event with empty array
35546 items.each(function(item) {
35547 Roo.log("layout item");
35549 // get x/y object from method
35550 var position = this._getItemLayoutPosition( item );
35552 position.item = item;
35553 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
35554 queue.push( position );
35557 this._processLayoutQueue( queue );
35559 /** Sets position of item in DOM
35560 * @param {Element} item
35561 * @param {Number} x - horizontal position
35562 * @param {Number} y - vertical position
35563 * @param {Boolean} isInstant - disables transitions
35565 _processLayoutQueue : function( queue )
35567 for ( var i=0, len = queue.length; i < len; i++ ) {
35568 var obj = queue[i];
35569 obj.item.position('absolute');
35570 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
35576 * Any logic you want to do after each layout,
35577 * i.e. size the container
35579 _postLayout : function()
35581 this.resizeContainer();
35584 resizeContainer : function()
35586 if ( !this.isResizingContainer ) {
35589 var size = this._getContainerSize();
35591 this.el.setSize(size.width,size.height);
35592 this.boxesEl.setSize(size.width,size.height);
35598 _resetLayout : function()
35600 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
35601 this.colWidth = this.el.getWidth();
35602 //this.gutter = this.el.getWidth();
35604 this.measureColumns();
35610 this.colYs.push( 0 );
35616 measureColumns : function()
35618 this.getContainerWidth();
35619 // if columnWidth is 0, default to outerWidth of first item
35620 if ( !this.columnWidth ) {
35621 var firstItem = this.bricks.first();
35622 Roo.log(firstItem);
35623 this.columnWidth = this.containerWidth;
35624 if (firstItem && firstItem.attr('originalwidth') ) {
35625 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
35627 // columnWidth fall back to item of first element
35628 Roo.log("set column width?");
35629 this.initialColumnWidth = this.columnWidth ;
35631 // if first elem has no width, default to size of container
35636 if (this.initialColumnWidth) {
35637 this.columnWidth = this.initialColumnWidth;
35642 // column width is fixed at the top - however if container width get's smaller we should
35645 // this bit calcs how man columns..
35647 var columnWidth = this.columnWidth += this.gutter;
35649 // calculate columns
35650 var containerWidth = this.containerWidth + this.gutter;
35652 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
35653 // fix rounding errors, typically with gutters
35654 var excess = columnWidth - containerWidth % columnWidth;
35657 // if overshoot is less than a pixel, round up, otherwise floor it
35658 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
35659 cols = Math[ mathMethod ]( cols );
35660 this.cols = Math.max( cols, 1 );
35661 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
35663 // padding positioning..
35664 var totalColWidth = this.cols * this.columnWidth;
35665 var padavail = this.containerWidth - totalColWidth;
35666 // so for 2 columns - we need 3 'pads'
35668 var padNeeded = (1+this.cols) * this.padWidth;
35670 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
35672 this.columnWidth += padExtra
35673 //this.padWidth = Math.floor(padavail / ( this.cols));
35675 // adjust colum width so that padding is fixed??
35677 // we have 3 columns ... total = width * 3
35678 // we have X left over... that should be used by
35680 //if (this.expandC) {
35688 getContainerWidth : function()
35690 /* // container is parent if fit width
35691 var container = this.isFitWidth ? this.element.parentNode : this.element;
35692 // check that this.size and size are there
35693 // IE8 triggers resize on body size change, so they might not be
35695 var size = getSize( container ); //FIXME
35696 this.containerWidth = size && size.innerWidth; //FIXME
35699 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
35703 _getItemLayoutPosition : function( item ) // what is item?
35705 // we resize the item to our columnWidth..
35707 item.setWidth(this.columnWidth);
35708 item.autoBoxAdjust = false;
35710 var sz = item.getSize();
35712 // how many columns does this brick span
35713 var remainder = this.containerWidth % this.columnWidth;
35715 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
35716 // round if off by 1 pixel, otherwise use ceil
35717 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
35718 colSpan = Math.min( colSpan, this.cols );
35720 // normally this should be '1' as we dont' currently allow multi width columns..
35722 var colGroup = this._getColGroup( colSpan );
35723 // get the minimum Y value from the columns
35724 var minimumY = Math.min.apply( Math, colGroup );
35725 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
35727 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
35729 // position the brick
35731 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
35732 y: this.currentSize.y + minimumY + this.padHeight
35736 // apply setHeight to necessary columns
35737 var setHeight = minimumY + sz.height + this.padHeight;
35738 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
35740 var setSpan = this.cols + 1 - colGroup.length;
35741 for ( var i = 0; i < setSpan; i++ ) {
35742 this.colYs[ shortColIndex + i ] = setHeight ;
35749 * @param {Number} colSpan - number of columns the element spans
35750 * @returns {Array} colGroup
35752 _getColGroup : function( colSpan )
35754 if ( colSpan < 2 ) {
35755 // if brick spans only one column, use all the column Ys
35760 // how many different places could this brick fit horizontally
35761 var groupCount = this.cols + 1 - colSpan;
35762 // for each group potential horizontal position
35763 for ( var i = 0; i < groupCount; i++ ) {
35764 // make an array of colY values for that one group
35765 var groupColYs = this.colYs.slice( i, i + colSpan );
35766 // and get the max value of the array
35767 colGroup[i] = Math.max.apply( Math, groupColYs );
35772 _manageStamp : function( stamp )
35774 var stampSize = stamp.getSize();
35775 var offset = stamp.getBox();
35776 // get the columns that this stamp affects
35777 var firstX = this.isOriginLeft ? offset.x : offset.right;
35778 var lastX = firstX + stampSize.width;
35779 var firstCol = Math.floor( firstX / this.columnWidth );
35780 firstCol = Math.max( 0, firstCol );
35782 var lastCol = Math.floor( lastX / this.columnWidth );
35783 // lastCol should not go over if multiple of columnWidth #425
35784 lastCol -= lastX % this.columnWidth ? 0 : 1;
35785 lastCol = Math.min( this.cols - 1, lastCol );
35787 // set colYs to bottom of the stamp
35788 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
35791 for ( var i = firstCol; i <= lastCol; i++ ) {
35792 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
35797 _getContainerSize : function()
35799 this.maxY = Math.max.apply( Math, this.colYs );
35804 if ( this.isFitWidth ) {
35805 size.width = this._getContainerFitWidth();
35811 _getContainerFitWidth : function()
35813 var unusedCols = 0;
35814 // count unused columns
35817 if ( this.colYs[i] !== 0 ) {
35822 // fit container to columns that have been used
35823 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
35826 needsResizeLayout : function()
35828 var previousWidth = this.containerWidth;
35829 this.getContainerWidth();
35830 return previousWidth !== this.containerWidth;
35845 * @class Roo.bootstrap.MasonryBrick
35846 * @extends Roo.bootstrap.Component
35847 * Bootstrap MasonryBrick class
35850 * Create a new MasonryBrick
35851 * @param {Object} config The config object
35854 Roo.bootstrap.MasonryBrick = function(config){
35856 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
35858 Roo.bootstrap.MasonryBrick.register(this);
35864 * When a MasonryBrick is clcik
35865 * @param {Roo.bootstrap.MasonryBrick} this
35866 * @param {Roo.EventObject} e
35872 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
35875 * @cfg {String} title
35879 * @cfg {String} html
35883 * @cfg {String} bgimage
35887 * @cfg {String} videourl
35891 * @cfg {String} cls
35895 * @cfg {String} href
35899 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
35904 * @cfg {String} placetitle (center|bottom)
35909 * @cfg {Boolean} isFitContainer defalut true
35911 isFitContainer : true,
35914 * @cfg {Boolean} preventDefault defalut false
35916 preventDefault : false,
35919 * @cfg {Boolean} inverse defalut false
35921 maskInverse : false,
35923 getAutoCreate : function()
35925 if(!this.isFitContainer){
35926 return this.getSplitAutoCreate();
35929 var cls = 'masonry-brick masonry-brick-full';
35931 if(this.href.length){
35932 cls += ' masonry-brick-link';
35935 if(this.bgimage.length){
35936 cls += ' masonry-brick-image';
35939 if(this.maskInverse){
35940 cls += ' mask-inverse';
35943 if(!this.html.length && !this.maskInverse && !this.videourl.length){
35944 cls += ' enable-mask';
35948 cls += ' masonry-' + this.size + '-brick';
35951 if(this.placetitle.length){
35953 switch (this.placetitle) {
35955 cls += ' masonry-center-title';
35958 cls += ' masonry-bottom-title';
35965 if(!this.html.length && !this.bgimage.length){
35966 cls += ' masonry-center-title';
35969 if(!this.html.length && this.bgimage.length){
35970 cls += ' masonry-bottom-title';
35975 cls += ' ' + this.cls;
35979 tag: (this.href.length) ? 'a' : 'div',
35984 cls: 'masonry-brick-mask'
35988 cls: 'masonry-brick-paragraph',
35994 if(this.href.length){
35995 cfg.href = this.href;
35998 var cn = cfg.cn[1].cn;
36000 if(this.title.length){
36003 cls: 'masonry-brick-title',
36008 if(this.html.length){
36011 cls: 'masonry-brick-text',
36016 if (!this.title.length && !this.html.length) {
36017 cfg.cn[1].cls += ' hide';
36020 if(this.bgimage.length){
36023 cls: 'masonry-brick-image-view',
36028 if(this.videourl.length){
36029 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
36030 // youtube support only?
36033 cls: 'masonry-brick-image-view',
36036 allowfullscreen : true
36044 getSplitAutoCreate : function()
36046 var cls = 'masonry-brick masonry-brick-split';
36048 if(this.href.length){
36049 cls += ' masonry-brick-link';
36052 if(this.bgimage.length){
36053 cls += ' masonry-brick-image';
36057 cls += ' masonry-' + this.size + '-brick';
36060 switch (this.placetitle) {
36062 cls += ' masonry-center-title';
36065 cls += ' masonry-bottom-title';
36068 if(!this.bgimage.length){
36069 cls += ' masonry-center-title';
36072 if(this.bgimage.length){
36073 cls += ' masonry-bottom-title';
36079 cls += ' ' + this.cls;
36083 tag: (this.href.length) ? 'a' : 'div',
36088 cls: 'masonry-brick-split-head',
36092 cls: 'masonry-brick-paragraph',
36099 cls: 'masonry-brick-split-body',
36105 if(this.href.length){
36106 cfg.href = this.href;
36109 if(this.title.length){
36110 cfg.cn[0].cn[0].cn.push({
36112 cls: 'masonry-brick-title',
36117 if(this.html.length){
36118 cfg.cn[1].cn.push({
36120 cls: 'masonry-brick-text',
36125 if(this.bgimage.length){
36126 cfg.cn[0].cn.push({
36128 cls: 'masonry-brick-image-view',
36133 if(this.videourl.length){
36134 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
36135 // youtube support only?
36136 cfg.cn[0].cn.cn.push({
36138 cls: 'masonry-brick-image-view',
36141 allowfullscreen : true
36148 initEvents: function()
36150 switch (this.size) {
36183 this.el.on('touchstart', this.onTouchStart, this);
36184 this.el.on('touchmove', this.onTouchMove, this);
36185 this.el.on('touchend', this.onTouchEnd, this);
36186 this.el.on('contextmenu', this.onContextMenu, this);
36188 this.el.on('mouseenter' ,this.enter, this);
36189 this.el.on('mouseleave', this.leave, this);
36190 this.el.on('click', this.onClick, this);
36193 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
36194 this.parent().bricks.push(this);
36199 onClick: function(e, el)
36201 var time = this.endTimer - this.startTimer;
36202 // Roo.log(e.preventDefault());
36205 e.preventDefault();
36210 if(!this.preventDefault){
36214 e.preventDefault();
36216 if (this.activeClass != '') {
36217 this.selectBrick();
36220 this.fireEvent('click', this, e);
36223 enter: function(e, el)
36225 e.preventDefault();
36227 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
36231 if(this.bgimage.length && this.html.length){
36232 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
36236 leave: function(e, el)
36238 e.preventDefault();
36240 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
36244 if(this.bgimage.length && this.html.length){
36245 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
36249 onTouchStart: function(e, el)
36251 // e.preventDefault();
36253 this.touchmoved = false;
36255 if(!this.isFitContainer){
36259 if(!this.bgimage.length || !this.html.length){
36263 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
36265 this.timer = new Date().getTime();
36269 onTouchMove: function(e, el)
36271 this.touchmoved = true;
36274 onContextMenu : function(e,el)
36276 e.preventDefault();
36277 e.stopPropagation();
36281 onTouchEnd: function(e, el)
36283 // e.preventDefault();
36285 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
36292 if(!this.bgimage.length || !this.html.length){
36294 if(this.href.length){
36295 window.location.href = this.href;
36301 if(!this.isFitContainer){
36305 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
36307 window.location.href = this.href;
36310 //selection on single brick only
36311 selectBrick : function() {
36313 if (!this.parentId) {
36317 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
36318 var index = m.selectedBrick.indexOf(this.id);
36321 m.selectedBrick.splice(index,1);
36322 this.el.removeClass(this.activeClass);
36326 for(var i = 0; i < m.selectedBrick.length; i++) {
36327 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
36328 b.el.removeClass(b.activeClass);
36331 m.selectedBrick = [];
36333 m.selectedBrick.push(this.id);
36334 this.el.addClass(this.activeClass);
36338 isSelected : function(){
36339 return this.el.hasClass(this.activeClass);
36344 Roo.apply(Roo.bootstrap.MasonryBrick, {
36347 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
36349 * register a Masonry Brick
36350 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
36353 register : function(brick)
36355 //this.groups[brick.id] = brick;
36356 this.groups.add(brick.id, brick);
36359 * fetch a masonry brick based on the masonry brick ID
36360 * @param {string} the masonry brick to add
36361 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
36364 get: function(brick_id)
36366 // if (typeof(this.groups[brick_id]) == 'undefined') {
36369 // return this.groups[brick_id] ;
36371 if(this.groups.key(brick_id)) {
36372 return this.groups.key(brick_id);
36390 * @class Roo.bootstrap.Brick
36391 * @extends Roo.bootstrap.Component
36392 * Bootstrap Brick class
36395 * Create a new Brick
36396 * @param {Object} config The config object
36399 Roo.bootstrap.Brick = function(config){
36400 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
36406 * When a Brick is click
36407 * @param {Roo.bootstrap.Brick} this
36408 * @param {Roo.EventObject} e
36414 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
36417 * @cfg {String} title
36421 * @cfg {String} html
36425 * @cfg {String} bgimage
36429 * @cfg {String} cls
36433 * @cfg {String} href
36437 * @cfg {String} video
36441 * @cfg {Boolean} square
36445 getAutoCreate : function()
36447 var cls = 'roo-brick';
36449 if(this.href.length){
36450 cls += ' roo-brick-link';
36453 if(this.bgimage.length){
36454 cls += ' roo-brick-image';
36457 if(!this.html.length && !this.bgimage.length){
36458 cls += ' roo-brick-center-title';
36461 if(!this.html.length && this.bgimage.length){
36462 cls += ' roo-brick-bottom-title';
36466 cls += ' ' + this.cls;
36470 tag: (this.href.length) ? 'a' : 'div',
36475 cls: 'roo-brick-paragraph',
36481 if(this.href.length){
36482 cfg.href = this.href;
36485 var cn = cfg.cn[0].cn;
36487 if(this.title.length){
36490 cls: 'roo-brick-title',
36495 if(this.html.length){
36498 cls: 'roo-brick-text',
36505 if(this.bgimage.length){
36508 cls: 'roo-brick-image-view',
36516 initEvents: function()
36518 if(this.title.length || this.html.length){
36519 this.el.on('mouseenter' ,this.enter, this);
36520 this.el.on('mouseleave', this.leave, this);
36523 Roo.EventManager.onWindowResize(this.resize, this);
36525 if(this.bgimage.length){
36526 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
36527 this.imageEl.on('load', this.onImageLoad, this);
36534 onImageLoad : function()
36539 resize : function()
36541 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
36543 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
36545 if(this.bgimage.length){
36546 var image = this.el.select('.roo-brick-image-view', true).first();
36548 image.setWidth(paragraph.getWidth());
36551 image.setHeight(paragraph.getWidth());
36554 this.el.setHeight(image.getHeight());
36555 paragraph.setHeight(image.getHeight());
36561 enter: function(e, el)
36563 e.preventDefault();
36565 if(this.bgimage.length){
36566 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
36567 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
36571 leave: function(e, el)
36573 e.preventDefault();
36575 if(this.bgimage.length){
36576 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
36577 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
36592 * @class Roo.bootstrap.form.NumberField
36593 * @extends Roo.bootstrap.form.Input
36594 * Bootstrap NumberField class
36600 * Create a new NumberField
36601 * @param {Object} config The config object
36604 Roo.bootstrap.form.NumberField = function(config){
36605 Roo.bootstrap.form.NumberField.superclass.constructor.call(this, config);
36608 Roo.extend(Roo.bootstrap.form.NumberField, Roo.bootstrap.form.Input, {
36611 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
36613 allowDecimals : true,
36615 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
36617 decimalSeparator : ".",
36619 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
36621 decimalPrecision : 2,
36623 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
36625 allowNegative : true,
36628 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
36632 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
36634 minValue : Number.NEGATIVE_INFINITY,
36636 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
36638 maxValue : Number.MAX_VALUE,
36640 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
36642 minText : "The minimum value for this field is {0}",
36644 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
36646 maxText : "The maximum value for this field is {0}",
36648 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
36649 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
36651 nanText : "{0} is not a valid number",
36653 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
36655 thousandsDelimiter : false,
36657 * @cfg {String} valueAlign alignment of value
36659 valueAlign : "left",
36661 getAutoCreate : function()
36663 var hiddenInput = {
36667 cls: 'hidden-number-input'
36671 hiddenInput.name = this.name;
36676 var cfg = Roo.bootstrap.form.NumberField.superclass.getAutoCreate.call(this);
36678 this.name = hiddenInput.name;
36680 if(cfg.cn.length > 0) {
36681 cfg.cn.push(hiddenInput);
36688 initEvents : function()
36690 Roo.bootstrap.form.NumberField.superclass.initEvents.call(this);
36692 var allowed = "0123456789";
36694 if(this.allowDecimals){
36695 allowed += this.decimalSeparator;
36698 if(this.allowNegative){
36702 if(this.thousandsDelimiter) {
36706 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
36708 var keyPress = function(e){
36710 var k = e.getKey();
36712 var c = e.getCharCode();
36715 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
36716 allowed.indexOf(String.fromCharCode(c)) === -1
36722 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
36726 if(allowed.indexOf(String.fromCharCode(c)) === -1){
36731 this.el.on("keypress", keyPress, this);
36734 validateValue : function(value)
36737 if(!Roo.bootstrap.form.NumberField.superclass.validateValue.call(this, value)){
36741 var num = this.parseValue(value);
36744 this.markInvalid(String.format(this.nanText, value));
36748 if(num < this.minValue){
36749 this.markInvalid(String.format(this.minText, this.minValue));
36753 if(num > this.maxValue){
36754 this.markInvalid(String.format(this.maxText, this.maxValue));
36761 getValue : function()
36763 var v = this.hiddenEl().getValue();
36765 return this.fixPrecision(this.parseValue(v));
36768 parseValue : function(value)
36770 if(this.thousandsDelimiter) {
36772 r = new RegExp(",", "g");
36773 value = value.replace(r, "");
36776 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
36777 return isNaN(value) ? '' : value;
36780 fixPrecision : function(value)
36782 if(this.thousandsDelimiter) {
36784 r = new RegExp(",", "g");
36785 value = value.replace(r, "");
36788 var nan = isNaN(value);
36790 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
36791 return nan ? '' : value;
36793 return parseFloat(value).toFixed(this.decimalPrecision);
36796 setValue : function(v)
36798 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
36804 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
36806 this.inputEl().dom.value = (v == '') ? '' :
36807 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
36809 if(!this.allowZero && v === '0') {
36810 this.hiddenEl().dom.value = '';
36811 this.inputEl().dom.value = '';
36818 decimalPrecisionFcn : function(v)
36820 return Math.floor(v);
36823 beforeBlur : function()
36825 var v = this.parseValue(this.getRawValue());
36827 if(v || v === 0 || v === ''){
36832 hiddenEl : function()
36834 return this.el.select('input.hidden-number-input',true).first();
36846 * @class Roo.bootstrap.DocumentSlider
36847 * @extends Roo.bootstrap.Component
36848 * Bootstrap DocumentSlider class
36851 * Create a new DocumentViewer
36852 * @param {Object} config The config object
36855 Roo.bootstrap.DocumentSlider = function(config){
36856 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
36863 * Fire after initEvent
36864 * @param {Roo.bootstrap.DocumentSlider} this
36869 * Fire after update
36870 * @param {Roo.bootstrap.DocumentSlider} this
36876 * @param {Roo.bootstrap.DocumentSlider} this
36882 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
36888 getAutoCreate : function()
36892 cls : 'roo-document-slider',
36896 cls : 'roo-document-slider-header',
36900 cls : 'roo-document-slider-header-title'
36906 cls : 'roo-document-slider-body',
36910 cls : 'roo-document-slider-prev',
36914 cls : 'fa fa-chevron-left'
36920 cls : 'roo-document-slider-thumb',
36924 cls : 'roo-document-slider-image'
36930 cls : 'roo-document-slider-next',
36934 cls : 'fa fa-chevron-right'
36946 initEvents : function()
36948 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
36949 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
36951 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
36952 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
36954 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
36955 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
36957 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
36958 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
36960 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
36961 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
36963 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
36964 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
36966 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
36967 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
36969 this.thumbEl.on('click', this.onClick, this);
36971 this.prevIndicator.on('click', this.prev, this);
36973 this.nextIndicator.on('click', this.next, this);
36977 initial : function()
36979 if(this.files.length){
36980 this.indicator = 1;
36984 this.fireEvent('initial', this);
36987 update : function()
36989 this.imageEl.attr('src', this.files[this.indicator - 1]);
36991 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
36993 this.prevIndicator.show();
36995 if(this.indicator == 1){
36996 this.prevIndicator.hide();
36999 this.nextIndicator.show();
37001 if(this.indicator == this.files.length){
37002 this.nextIndicator.hide();
37005 this.thumbEl.scrollTo('top');
37007 this.fireEvent('update', this);
37010 onClick : function(e)
37012 e.preventDefault();
37014 this.fireEvent('click', this);
37019 e.preventDefault();
37021 this.indicator = Math.max(1, this.indicator - 1);
37028 e.preventDefault();
37030 this.indicator = Math.min(this.files.length, this.indicator + 1);
37044 * @class Roo.bootstrap.form.RadioSet
37045 * @extends Roo.bootstrap.form.Input
37046 * @children Roo.bootstrap.form.Radio
37047 * Bootstrap RadioSet class
37048 * @cfg {String} indicatorpos (left|right) default left
37049 * @cfg {Boolean} inline (true|false) inline the element (default true)
37050 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
37052 * Create a new RadioSet
37053 * @param {Object} config The config object
37056 Roo.bootstrap.form.RadioSet = function(config){
37058 Roo.bootstrap.form.RadioSet.superclass.constructor.call(this, config);
37062 Roo.bootstrap.form.RadioSet.register(this);
37067 * Fires when the element is checked or unchecked.
37068 * @param {Roo.bootstrap.form.RadioSet} this This radio
37069 * @param {Roo.bootstrap.form.Radio} item The checked item
37074 * Fires when the element is click.
37075 * @param {Roo.bootstrap.form.RadioSet} this This radio set
37076 * @param {Roo.bootstrap.form.Radio} item The checked item
37077 * @param {Roo.EventObject} e The event object
37084 Roo.extend(Roo.bootstrap.form.RadioSet, Roo.bootstrap.form.Input, {
37092 indicatorpos : 'left',
37094 getAutoCreate : function()
37098 cls : 'roo-radio-set-label',
37102 html : this.fieldLabel
37106 if (Roo.bootstrap.version == 3) {
37109 if(this.indicatorpos == 'left'){
37112 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
37113 tooltip : 'This field is required'
37118 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
37119 tooltip : 'This field is required'
37125 cls : 'roo-radio-set-items'
37128 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
37130 if (align === 'left' && this.fieldLabel.length) {
37133 cls : "roo-radio-set-right",
37139 if(this.labelWidth > 12){
37140 label.style = "width: " + this.labelWidth + 'px';
37143 if(this.labelWidth < 13 && this.labelmd == 0){
37144 this.labelmd = this.labelWidth;
37147 if(this.labellg > 0){
37148 label.cls += ' col-lg-' + this.labellg;
37149 items.cls += ' col-lg-' + (12 - this.labellg);
37152 if(this.labelmd > 0){
37153 label.cls += ' col-md-' + this.labelmd;
37154 items.cls += ' col-md-' + (12 - this.labelmd);
37157 if(this.labelsm > 0){
37158 label.cls += ' col-sm-' + this.labelsm;
37159 items.cls += ' col-sm-' + (12 - this.labelsm);
37162 if(this.labelxs > 0){
37163 label.cls += ' col-xs-' + this.labelxs;
37164 items.cls += ' col-xs-' + (12 - this.labelxs);
37170 cls : 'roo-radio-set',
37174 cls : 'roo-radio-set-input',
37177 value : this.value ? this.value : ''
37184 if(this.weight.length){
37185 cfg.cls += ' roo-radio-' + this.weight;
37189 cfg.cls += ' roo-radio-set-inline';
37193 ['xs','sm','md','lg'].map(function(size){
37194 if (settings[size]) {
37195 cfg.cls += ' col-' + size + '-' + settings[size];
37203 initEvents : function()
37205 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
37206 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
37208 if(!this.fieldLabel.length){
37209 this.labelEl.hide();
37212 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
37213 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
37215 this.indicator = this.indicatorEl();
37217 if(this.indicator){
37218 this.indicator.addClass('invisible');
37221 this.originalValue = this.getValue();
37225 inputEl: function ()
37227 return this.el.select('.roo-radio-set-input', true).first();
37230 getChildContainer : function()
37232 return this.itemsEl;
37235 register : function(item)
37237 this.radioes.push(item);
37241 validate : function()
37243 if(this.getVisibilityEl().hasClass('hidden')){
37249 Roo.each(this.radioes, function(i){
37258 if(this.allowBlank) {
37262 if(this.disabled || valid){
37267 this.markInvalid();
37272 markValid : function()
37274 if(this.labelEl.isVisible(true) && this.indicatorEl()){
37275 this.indicatorEl().removeClass('visible');
37276 this.indicatorEl().addClass('invisible');
37280 if (Roo.bootstrap.version == 3) {
37281 this.el.removeClass([this.invalidClass, this.validClass]);
37282 this.el.addClass(this.validClass);
37284 this.el.removeClass(['is-invalid','is-valid']);
37285 this.el.addClass(['is-valid']);
37287 this.fireEvent('valid', this);
37290 markInvalid : function(msg)
37292 if(this.allowBlank || this.disabled){
37296 if(this.labelEl.isVisible(true) && this.indicatorEl()){
37297 this.indicatorEl().removeClass('invisible');
37298 this.indicatorEl().addClass('visible');
37300 if (Roo.bootstrap.version == 3) {
37301 this.el.removeClass([this.invalidClass, this.validClass]);
37302 this.el.addClass(this.invalidClass);
37304 this.el.removeClass(['is-invalid','is-valid']);
37305 this.el.addClass(['is-invalid']);
37308 this.fireEvent('invalid', this, msg);
37312 setValue : function(v, suppressEvent)
37314 if(this.value === v){
37321 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
37324 Roo.each(this.radioes, function(i){
37326 i.el.removeClass('checked');
37329 Roo.each(this.radioes, function(i){
37331 if(i.value === v || i.value.toString() === v.toString()){
37333 i.el.addClass('checked');
37335 if(suppressEvent !== true){
37336 this.fireEvent('check', this, i);
37347 clearInvalid : function(){
37349 if(!this.el || this.preventMark){
37353 this.el.removeClass([this.invalidClass]);
37355 this.fireEvent('valid', this);
37360 Roo.apply(Roo.bootstrap.form.RadioSet, {
37364 register : function(set)
37366 this.groups[set.name] = set;
37369 get: function(name)
37371 if (typeof(this.groups[name]) == 'undefined') {
37375 return this.groups[name] ;
37381 * Ext JS Library 1.1.1
37382 * Copyright(c) 2006-2007, Ext JS, LLC.
37384 * Originally Released Under LGPL - original licence link has changed is not relivant.
37387 * <script type="text/javascript">
37392 * @class Roo.bootstrap.SplitBar
37393 * @extends Roo.util.Observable
37394 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
37398 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
37399 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
37400 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
37401 split.minSize = 100;
37402 split.maxSize = 600;
37403 split.animate = true;
37404 split.on('moved', splitterMoved);
37407 * Create a new SplitBar
37408 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
37409 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
37410 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
37411 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
37412 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
37413 position of the SplitBar).
37415 Roo.bootstrap.SplitBar = function(cfg){
37420 // dragElement : elm
37421 // resizingElement: el,
37423 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
37424 // placement : Roo.bootstrap.SplitBar.LEFT ,
37425 // existingProxy ???
37428 this.el = Roo.get(cfg.dragElement, true);
37429 this.el.dom.unselectable = "on";
37431 this.resizingEl = Roo.get(cfg.resizingElement, true);
37435 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
37436 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
37439 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
37442 * The minimum size of the resizing element. (Defaults to 0)
37448 * The maximum size of the resizing element. (Defaults to 2000)
37451 this.maxSize = 2000;
37454 * Whether to animate the transition to the new size
37457 this.animate = false;
37460 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
37463 this.useShim = false;
37468 if(!cfg.existingProxy){
37470 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
37472 this.proxy = Roo.get(cfg.existingProxy).dom;
37475 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
37478 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
37481 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
37484 this.dragSpecs = {};
37487 * @private The adapter to use to positon and resize elements
37489 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
37490 this.adapter.init(this);
37492 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
37494 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
37495 this.el.addClass("roo-splitbar-h");
37498 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
37499 this.el.addClass("roo-splitbar-v");
37505 * Fires when the splitter is moved (alias for {@link #event-moved})
37506 * @param {Roo.bootstrap.SplitBar} this
37507 * @param {Number} newSize the new width or height
37512 * Fires when the splitter is moved
37513 * @param {Roo.bootstrap.SplitBar} this
37514 * @param {Number} newSize the new width or height
37518 * @event beforeresize
37519 * Fires before the splitter is dragged
37520 * @param {Roo.bootstrap.SplitBar} this
37522 "beforeresize" : true,
37524 "beforeapply" : true
37527 Roo.util.Observable.call(this);
37530 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
37531 onStartProxyDrag : function(x, y){
37532 this.fireEvent("beforeresize", this);
37534 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
37536 o.enableDisplayMode("block");
37537 // all splitbars share the same overlay
37538 Roo.bootstrap.SplitBar.prototype.overlay = o;
37540 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
37541 this.overlay.show();
37542 Roo.get(this.proxy).setDisplayed("block");
37543 var size = this.adapter.getElementSize(this);
37544 this.activeMinSize = this.getMinimumSize();;
37545 this.activeMaxSize = this.getMaximumSize();;
37546 var c1 = size - this.activeMinSize;
37547 var c2 = Math.max(this.activeMaxSize - size, 0);
37548 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
37549 this.dd.resetConstraints();
37550 this.dd.setXConstraint(
37551 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
37552 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
37554 this.dd.setYConstraint(0, 0);
37556 this.dd.resetConstraints();
37557 this.dd.setXConstraint(0, 0);
37558 this.dd.setYConstraint(
37559 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
37560 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
37563 this.dragSpecs.startSize = size;
37564 this.dragSpecs.startPoint = [x, y];
37565 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
37569 * @private Called after the drag operation by the DDProxy
37571 onEndProxyDrag : function(e){
37572 Roo.get(this.proxy).setDisplayed(false);
37573 var endPoint = Roo.lib.Event.getXY(e);
37575 this.overlay.hide();
37578 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
37579 newSize = this.dragSpecs.startSize +
37580 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
37581 endPoint[0] - this.dragSpecs.startPoint[0] :
37582 this.dragSpecs.startPoint[0] - endPoint[0]
37585 newSize = this.dragSpecs.startSize +
37586 (this.placement == Roo.bootstrap.SplitBar.TOP ?
37587 endPoint[1] - this.dragSpecs.startPoint[1] :
37588 this.dragSpecs.startPoint[1] - endPoint[1]
37591 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
37592 if(newSize != this.dragSpecs.startSize){
37593 if(this.fireEvent('beforeapply', this, newSize) !== false){
37594 this.adapter.setElementSize(this, newSize);
37595 this.fireEvent("moved", this, newSize);
37596 this.fireEvent("resize", this, newSize);
37602 * Get the adapter this SplitBar uses
37603 * @return The adapter object
37605 getAdapter : function(){
37606 return this.adapter;
37610 * Set the adapter this SplitBar uses
37611 * @param {Object} adapter A SplitBar adapter object
37613 setAdapter : function(adapter){
37614 this.adapter = adapter;
37615 this.adapter.init(this);
37619 * Gets the minimum size for the resizing element
37620 * @return {Number} The minimum size
37622 getMinimumSize : function(){
37623 return this.minSize;
37627 * Sets the minimum size for the resizing element
37628 * @param {Number} minSize The minimum size
37630 setMinimumSize : function(minSize){
37631 this.minSize = minSize;
37635 * Gets the maximum size for the resizing element
37636 * @return {Number} The maximum size
37638 getMaximumSize : function(){
37639 return this.maxSize;
37643 * Sets the maximum size for the resizing element
37644 * @param {Number} maxSize The maximum size
37646 setMaximumSize : function(maxSize){
37647 this.maxSize = maxSize;
37651 * Sets the initialize size for the resizing element
37652 * @param {Number} size The initial size
37654 setCurrentSize : function(size){
37655 var oldAnimate = this.animate;
37656 this.animate = false;
37657 this.adapter.setElementSize(this, size);
37658 this.animate = oldAnimate;
37662 * Destroy this splitbar.
37663 * @param {Boolean} removeEl True to remove the element
37665 destroy : function(removeEl){
37667 this.shim.remove();
37670 this.proxy.parentNode.removeChild(this.proxy);
37678 * @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.
37680 Roo.bootstrap.SplitBar.createProxy = function(dir){
37681 var proxy = new Roo.Element(document.createElement("div"));
37682 proxy.unselectable();
37683 var cls = 'roo-splitbar-proxy';
37684 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
37685 document.body.appendChild(proxy.dom);
37690 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
37691 * Default Adapter. It assumes the splitter and resizing element are not positioned
37692 * elements and only gets/sets the width of the element. Generally used for table based layouts.
37694 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
37697 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
37698 // do nothing for now
37699 init : function(s){
37703 * Called before drag operations to get the current size of the resizing element.
37704 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
37706 getElementSize : function(s){
37707 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
37708 return s.resizingEl.getWidth();
37710 return s.resizingEl.getHeight();
37715 * Called after drag operations to set the size of the resizing element.
37716 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
37717 * @param {Number} newSize The new size to set
37718 * @param {Function} onComplete A function to be invoked when resizing is complete
37720 setElementSize : function(s, newSize, onComplete){
37721 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
37723 s.resizingEl.setWidth(newSize);
37725 onComplete(s, newSize);
37728 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
37733 s.resizingEl.setHeight(newSize);
37735 onComplete(s, newSize);
37738 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
37745 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
37746 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
37747 * Adapter that moves the splitter element to align with the resized sizing element.
37748 * Used with an absolute positioned SplitBar.
37749 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
37750 * document.body, make sure you assign an id to the body element.
37752 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
37753 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
37754 this.container = Roo.get(container);
37757 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
37758 init : function(s){
37759 this.basic.init(s);
37762 getElementSize : function(s){
37763 return this.basic.getElementSize(s);
37766 setElementSize : function(s, newSize, onComplete){
37767 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
37770 moveSplitter : function(s){
37771 var yes = Roo.bootstrap.SplitBar;
37772 switch(s.placement){
37774 s.el.setX(s.resizingEl.getRight());
37777 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
37780 s.el.setY(s.resizingEl.getBottom());
37783 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
37790 * Orientation constant - Create a vertical SplitBar
37794 Roo.bootstrap.SplitBar.VERTICAL = 1;
37797 * Orientation constant - Create a horizontal SplitBar
37801 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
37804 * Placement constant - The resizing element is to the left of the splitter element
37808 Roo.bootstrap.SplitBar.LEFT = 1;
37811 * Placement constant - The resizing element is to the right of the splitter element
37815 Roo.bootstrap.SplitBar.RIGHT = 2;
37818 * Placement constant - The resizing element is positioned above the splitter element
37822 Roo.bootstrap.SplitBar.TOP = 3;
37825 * Placement constant - The resizing element is positioned under splitter element
37829 Roo.bootstrap.SplitBar.BOTTOM = 4;
37832 * Ext JS Library 1.1.1
37833 * Copyright(c) 2006-2007, Ext JS, LLC.
37835 * Originally Released Under LGPL - original licence link has changed is not relivant.
37838 * <script type="text/javascript">
37842 * @class Roo.bootstrap.layout.Manager
37843 * @extends Roo.bootstrap.Component
37845 * Base class for layout managers.
37847 Roo.bootstrap.layout.Manager = function(config)
37849 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
37855 /** false to disable window resize monitoring @type Boolean */
37856 this.monitorWindowResize = true;
37861 * Fires when a layout is performed.
37862 * @param {Roo.LayoutManager} this
37866 * @event regionresized
37867 * Fires when the user resizes a region.
37868 * @param {Roo.LayoutRegion} region The resized region
37869 * @param {Number} newSize The new size (width for east/west, height for north/south)
37871 "regionresized" : true,
37873 * @event regioncollapsed
37874 * Fires when a region is collapsed.
37875 * @param {Roo.LayoutRegion} region The collapsed region
37877 "regioncollapsed" : true,
37879 * @event regionexpanded
37880 * Fires when a region is expanded.
37881 * @param {Roo.LayoutRegion} region The expanded region
37883 "regionexpanded" : true
37885 this.updating = false;
37888 this.el = Roo.get(config.el);
37894 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
37899 monitorWindowResize : true,
37905 onRender : function(ct, position)
37908 this.el = Roo.get(ct);
37911 //this.fireEvent('render',this);
37915 initEvents: function()
37919 // ie scrollbar fix
37920 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
37921 document.body.scroll = "no";
37922 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
37923 this.el.position('relative');
37925 this.id = this.el.id;
37926 this.el.addClass("roo-layout-container");
37927 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
37928 if(this.el.dom != document.body ) {
37929 this.el.on('resize', this.layout,this);
37930 this.el.on('show', this.layout,this);
37936 * Returns true if this layout is currently being updated
37937 * @return {Boolean}
37939 isUpdating : function(){
37940 return this.updating;
37944 * Suspend the LayoutManager from doing auto-layouts while
37945 * making multiple add or remove calls
37947 beginUpdate : function(){
37948 this.updating = true;
37952 * Restore auto-layouts and optionally disable the manager from performing a layout
37953 * @param {Boolean} noLayout true to disable a layout update
37955 endUpdate : function(noLayout){
37956 this.updating = false;
37962 layout: function(){
37966 onRegionResized : function(region, newSize){
37967 this.fireEvent("regionresized", region, newSize);
37971 onRegionCollapsed : function(region){
37972 this.fireEvent("regioncollapsed", region);
37975 onRegionExpanded : function(region){
37976 this.fireEvent("regionexpanded", region);
37980 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
37981 * performs box-model adjustments.
37982 * @return {Object} The size as an object {width: (the width), height: (the height)}
37984 getViewSize : function()
37987 if(this.el.dom != document.body){
37988 size = this.el.getSize();
37990 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
37992 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
37993 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
37998 * Returns the Element this layout is bound to.
37999 * @return {Roo.Element}
38001 getEl : function(){
38006 * Returns the specified region.
38007 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
38008 * @return {Roo.LayoutRegion}
38010 getRegion : function(target){
38011 return this.regions[target.toLowerCase()];
38014 onWindowResize : function(){
38015 if(this.monitorWindowResize){
38022 * Ext JS Library 1.1.1
38023 * Copyright(c) 2006-2007, Ext JS, LLC.
38025 * Originally Released Under LGPL - original licence link has changed is not relivant.
38028 * <script type="text/javascript">
38031 * @class Roo.bootstrap.layout.Border
38032 * @extends Roo.bootstrap.layout.Manager
38033 * @children Roo.bootstrap.panel.Content Roo.bootstrap.panel.Nest Roo.bootstrap.panel.Grid
38034 * @parent builder Roo.bootstrap.panel.Nest Roo.bootstrap.panel.Nest Roo.bootstrap.Modal
38035 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
38036 * please see: examples/bootstrap/nested.html<br><br>
38038 <b>The container the layout is rendered into can be either the body element or any other element.
38039 If it is not the body element, the container needs to either be an absolute positioned element,
38040 or you will need to add "position:relative" to the css of the container. You will also need to specify
38041 the container size if it is not the body element.</b>
38044 * Create a new Border
38045 * @param {Object} config Configuration options
38047 Roo.bootstrap.layout.Border = function(config){
38048 config = config || {};
38049 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
38053 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
38054 if(config[region]){
38055 config[region].region = region;
38056 this.addRegion(config[region]);
38062 Roo.bootstrap.layout.Border.regions = ["center", "north","south","east","west"];
38064 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
38067 * @cfg {Roo.bootstrap.layout.Region} center region to go in center
38070 * @cfg {Roo.bootstrap.layout.Region} west region to go in west
38073 * @cfg {Roo.bootstrap.layout.Region} east region to go in east
38076 * @cfg {Roo.bootstrap.layout.Region} south region to go in south
38079 * @cfg {Roo.bootstrap.layout.Region} north region to go in north
38085 parent : false, // this might point to a 'nest' or a ???
38088 * Creates and adds a new region if it doesn't already exist.
38089 * @param {String} target The target region key (north, south, east, west or center).
38090 * @param {Object} config The regions config object
38091 * @return {BorderLayoutRegion} The new region
38093 addRegion : function(config)
38095 if(!this.regions[config.region]){
38096 var r = this.factory(config);
38097 this.bindRegion(r);
38099 return this.regions[config.region];
38103 bindRegion : function(r){
38104 this.regions[r.config.region] = r;
38106 r.on("visibilitychange", this.layout, this);
38107 r.on("paneladded", this.layout, this);
38108 r.on("panelremoved", this.layout, this);
38109 r.on("invalidated", this.layout, this);
38110 r.on("resized", this.onRegionResized, this);
38111 r.on("collapsed", this.onRegionCollapsed, this);
38112 r.on("expanded", this.onRegionExpanded, this);
38116 * Performs a layout update.
38118 layout : function()
38120 if(this.updating) {
38124 // render all the rebions if they have not been done alreayd?
38125 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
38126 if(this.regions[region] && !this.regions[region].bodyEl){
38127 this.regions[region].onRender(this.el)
38131 var size = this.getViewSize();
38132 var w = size.width;
38133 var h = size.height;
38138 //var x = 0, y = 0;
38140 var rs = this.regions;
38141 var north = rs["north"];
38142 var south = rs["south"];
38143 var west = rs["west"];
38144 var east = rs["east"];
38145 var center = rs["center"];
38146 //if(this.hideOnLayout){ // not supported anymore
38147 //c.el.setStyle("display", "none");
38149 if(north && north.isVisible()){
38150 var b = north.getBox();
38151 var m = north.getMargins();
38152 b.width = w - (m.left+m.right);
38155 centerY = b.height + b.y + m.bottom;
38156 centerH -= centerY;
38157 north.updateBox(this.safeBox(b));
38159 if(south && south.isVisible()){
38160 var b = south.getBox();
38161 var m = south.getMargins();
38162 b.width = w - (m.left+m.right);
38164 var totalHeight = (b.height + m.top + m.bottom);
38165 b.y = h - totalHeight + m.top;
38166 centerH -= totalHeight;
38167 south.updateBox(this.safeBox(b));
38169 if(west && west.isVisible()){
38170 var b = west.getBox();
38171 var m = west.getMargins();
38172 b.height = centerH - (m.top+m.bottom);
38174 b.y = centerY + m.top;
38175 var totalWidth = (b.width + m.left + m.right);
38176 centerX += totalWidth;
38177 centerW -= totalWidth;
38178 west.updateBox(this.safeBox(b));
38180 if(east && east.isVisible()){
38181 var b = east.getBox();
38182 var m = east.getMargins();
38183 b.height = centerH - (m.top+m.bottom);
38184 var totalWidth = (b.width + m.left + m.right);
38185 b.x = w - totalWidth + m.left;
38186 b.y = centerY + m.top;
38187 centerW -= totalWidth;
38188 east.updateBox(this.safeBox(b));
38191 var m = center.getMargins();
38193 x: centerX + m.left,
38194 y: centerY + m.top,
38195 width: centerW - (m.left+m.right),
38196 height: centerH - (m.top+m.bottom)
38198 //if(this.hideOnLayout){
38199 //center.el.setStyle("display", "block");
38201 center.updateBox(this.safeBox(centerBox));
38204 this.fireEvent("layout", this);
38208 safeBox : function(box){
38209 box.width = Math.max(0, box.width);
38210 box.height = Math.max(0, box.height);
38215 * Adds a ContentPanel (or subclass) to this layout.
38216 * @param {String} target The target region key (north, south, east, west or center).
38217 * @param {Roo.ContentPanel} panel The panel to add
38218 * @return {Roo.ContentPanel} The added panel
38220 add : function(target, panel){
38222 target = target.toLowerCase();
38223 return this.regions[target].add(panel);
38227 * Remove a ContentPanel (or subclass) to this layout.
38228 * @param {String} target The target region key (north, south, east, west or center).
38229 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
38230 * @return {Roo.ContentPanel} The removed panel
38232 remove : function(target, panel){
38233 target = target.toLowerCase();
38234 return this.regions[target].remove(panel);
38238 * Searches all regions for a panel with the specified id
38239 * @param {String} panelId
38240 * @return {Roo.ContentPanel} The panel or null if it wasn't found
38242 findPanel : function(panelId){
38243 var rs = this.regions;
38244 for(var target in rs){
38245 if(typeof rs[target] != "function"){
38246 var p = rs[target].getPanel(panelId);
38256 * Searches all regions for a panel with the specified id and activates (shows) it.
38257 * @param {String/ContentPanel} panelId The panels id or the panel itself
38258 * @return {Roo.ContentPanel} The shown panel or null
38260 showPanel : function(panelId) {
38261 var rs = this.regions;
38262 for(var target in rs){
38263 var r = rs[target];
38264 if(typeof r != "function"){
38265 if(r.hasPanel(panelId)){
38266 return r.showPanel(panelId);
38274 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
38275 * @param {Roo.state.Provider} provider (optional) An alternate state provider
38278 restoreState : function(provider){
38280 provider = Roo.state.Manager;
38282 var sm = new Roo.LayoutStateManager();
38283 sm.init(this, provider);
38289 * Adds a xtype elements to the layout.
38293 xtype : 'ContentPanel',
38300 xtype : 'NestedLayoutPanel',
38306 items : [ ... list of content panels or nested layout panels.. ]
38310 * @param {Object} cfg Xtype definition of item to add.
38312 addxtype : function(cfg)
38314 // basically accepts a pannel...
38315 // can accept a layout region..!?!?
38316 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
38319 // theory? children can only be panels??
38321 //if (!cfg.xtype.match(/Panel$/)) {
38326 if (typeof(cfg.region) == 'undefined') {
38327 Roo.log("Failed to add Panel, region was not set");
38331 var region = cfg.region;
38337 xitems = cfg.items;
38342 if ( region == 'center') {
38343 Roo.log("Center: " + cfg.title);
38349 case 'Content': // ContentPanel (el, cfg)
38350 case 'Scroll': // ContentPanel (el, cfg)
38352 cfg.autoCreate = cfg.autoCreate || true;
38353 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
38355 // var el = this.el.createChild();
38356 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
38359 this.add(region, ret);
38363 case 'TreePanel': // our new panel!
38364 cfg.el = this.el.createChild();
38365 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
38366 this.add(region, ret);
38371 // create a new Layout (which is a Border Layout...
38373 var clayout = cfg.layout;
38374 clayout.el = this.el.createChild();
38375 clayout.items = clayout.items || [];
38379 // replace this exitems with the clayout ones..
38380 xitems = clayout.items;
38382 // force background off if it's in center...
38383 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
38384 cfg.background = false;
38386 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
38389 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
38390 //console.log('adding nested layout panel ' + cfg.toSource());
38391 this.add(region, ret);
38392 nb = {}; /// find first...
38397 // needs grid and region
38399 //var el = this.getRegion(region).el.createChild();
38401 *var el = this.el.createChild();
38402 // create the grid first...
38403 cfg.grid.container = el;
38404 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
38407 if (region == 'center' && this.active ) {
38408 cfg.background = false;
38411 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
38413 this.add(region, ret);
38415 if (cfg.background) {
38416 // render grid on panel activation (if panel background)
38417 ret.on('activate', function(gp) {
38418 if (!gp.grid.rendered) {
38419 // gp.grid.render(el);
38423 // cfg.grid.render(el);
38429 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
38430 // it was the old xcomponent building that caused this before.
38431 // espeically if border is the top element in the tree.
38441 if (typeof(Roo[cfg.xtype]) != 'undefined') {
38443 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
38444 this.add(region, ret);
38448 throw "Can not add '" + cfg.xtype + "' to Border";
38454 this.beginUpdate();
38458 Roo.each(xitems, function(i) {
38459 region = nb && i.region ? i.region : false;
38461 var add = ret.addxtype(i);
38464 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
38465 if (!i.background) {
38466 abn[region] = nb[region] ;
38473 // make the last non-background panel active..
38474 //if (nb) { Roo.log(abn); }
38477 for(var r in abn) {
38478 region = this.getRegion(r);
38480 // tried using nb[r], but it does not work..
38482 region.showPanel(abn[r]);
38493 factory : function(cfg)
38496 var validRegions = Roo.bootstrap.layout.Border.regions;
38498 var target = cfg.region;
38501 var r = Roo.bootstrap.layout;
38505 return new r.North(cfg);
38507 return new r.South(cfg);
38509 return new r.East(cfg);
38511 return new r.West(cfg);
38513 return new r.Center(cfg);
38515 throw 'Layout region "'+target+'" not supported.';
38522 * Ext JS Library 1.1.1
38523 * Copyright(c) 2006-2007, Ext JS, LLC.
38525 * Originally Released Under LGPL - original licence link has changed is not relivant.
38528 * <script type="text/javascript">
38532 * @class Roo.bootstrap.layout.Basic
38533 * @extends Roo.util.Observable
38534 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
38535 * and does not have a titlebar, tabs or any other features. All it does is size and position
38536 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
38537 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
38538 * @cfg {string} region the region that it inhabits..
38539 * @cfg {bool} skipConfig skip config?
38543 Roo.bootstrap.layout.Basic = function(config){
38545 this.mgr = config.mgr;
38547 this.position = config.region;
38549 var skipConfig = config.skipConfig;
38553 * @scope Roo.BasicLayoutRegion
38557 * @event beforeremove
38558 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
38559 * @param {Roo.LayoutRegion} this
38560 * @param {Roo.ContentPanel} panel The panel
38561 * @param {Object} e The cancel event object
38563 "beforeremove" : true,
38565 * @event invalidated
38566 * Fires when the layout for this region is changed.
38567 * @param {Roo.LayoutRegion} this
38569 "invalidated" : true,
38571 * @event visibilitychange
38572 * Fires when this region is shown or hidden
38573 * @param {Roo.LayoutRegion} this
38574 * @param {Boolean} visibility true or false
38576 "visibilitychange" : true,
38578 * @event paneladded
38579 * Fires when a panel is added.
38580 * @param {Roo.LayoutRegion} this
38581 * @param {Roo.ContentPanel} panel The panel
38583 "paneladded" : true,
38585 * @event panelremoved
38586 * Fires when a panel is removed.
38587 * @param {Roo.LayoutRegion} this
38588 * @param {Roo.ContentPanel} panel The panel
38590 "panelremoved" : true,
38592 * @event beforecollapse
38593 * Fires when this region before collapse.
38594 * @param {Roo.LayoutRegion} this
38596 "beforecollapse" : true,
38599 * Fires when this region is collapsed.
38600 * @param {Roo.LayoutRegion} this
38602 "collapsed" : true,
38605 * Fires when this region is expanded.
38606 * @param {Roo.LayoutRegion} this
38611 * Fires when this region is slid into view.
38612 * @param {Roo.LayoutRegion} this
38614 "slideshow" : true,
38617 * Fires when this region slides out of view.
38618 * @param {Roo.LayoutRegion} this
38620 "slidehide" : true,
38622 * @event panelactivated
38623 * Fires when a panel is activated.
38624 * @param {Roo.LayoutRegion} this
38625 * @param {Roo.ContentPanel} panel The activated panel
38627 "panelactivated" : true,
38630 * Fires when the user resizes this region.
38631 * @param {Roo.LayoutRegion} this
38632 * @param {Number} newSize The new size (width for east/west, height for north/south)
38636 /** A collection of panels in this region. @type Roo.util.MixedCollection */
38637 this.panels = new Roo.util.MixedCollection();
38638 this.panels.getKey = this.getPanelId.createDelegate(this);
38640 this.activePanel = null;
38641 // ensure listeners are added...
38643 if (config.listeners || config.events) {
38644 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
38645 listeners : config.listeners || {},
38646 events : config.events || {}
38650 if(skipConfig !== true){
38651 this.applyConfig(config);
38655 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
38657 getPanelId : function(p){
38661 applyConfig : function(config){
38662 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
38663 this.config = config;
38668 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
38669 * the width, for horizontal (north, south) the height.
38670 * @param {Number} newSize The new width or height
38672 resizeTo : function(newSize){
38673 var el = this.el ? this.el :
38674 (this.activePanel ? this.activePanel.getEl() : null);
38676 switch(this.position){
38679 el.setWidth(newSize);
38680 this.fireEvent("resized", this, newSize);
38684 el.setHeight(newSize);
38685 this.fireEvent("resized", this, newSize);
38691 getBox : function(){
38692 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
38695 getMargins : function(){
38696 return this.margins;
38699 updateBox : function(box){
38701 var el = this.activePanel.getEl();
38702 el.dom.style.left = box.x + "px";
38703 el.dom.style.top = box.y + "px";
38704 this.activePanel.setSize(box.width, box.height);
38708 * Returns the container element for this region.
38709 * @return {Roo.Element}
38711 getEl : function(){
38712 return this.activePanel;
38716 * Returns true if this region is currently visible.
38717 * @return {Boolean}
38719 isVisible : function(){
38720 return this.activePanel ? true : false;
38723 setActivePanel : function(panel){
38724 panel = this.getPanel(panel);
38725 if(this.activePanel && this.activePanel != panel){
38726 this.activePanel.setActiveState(false);
38727 this.activePanel.getEl().setLeftTop(-10000,-10000);
38729 this.activePanel = panel;
38730 panel.setActiveState(true);
38732 panel.setSize(this.box.width, this.box.height);
38734 this.fireEvent("panelactivated", this, panel);
38735 this.fireEvent("invalidated");
38739 * Show the specified panel.
38740 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
38741 * @return {Roo.ContentPanel} The shown panel or null
38743 showPanel : function(panel){
38744 panel = this.getPanel(panel);
38746 this.setActivePanel(panel);
38752 * Get the active panel for this region.
38753 * @return {Roo.ContentPanel} The active panel or null
38755 getActivePanel : function(){
38756 return this.activePanel;
38760 * Add the passed ContentPanel(s)
38761 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
38762 * @return {Roo.ContentPanel} The panel added (if only one was added)
38764 add : function(panel){
38765 if(arguments.length > 1){
38766 for(var i = 0, len = arguments.length; i < len; i++) {
38767 this.add(arguments[i]);
38771 if(this.hasPanel(panel)){
38772 this.showPanel(panel);
38775 var el = panel.getEl();
38776 if(el.dom.parentNode != this.mgr.el.dom){
38777 this.mgr.el.dom.appendChild(el.dom);
38779 if(panel.setRegion){
38780 panel.setRegion(this);
38782 this.panels.add(panel);
38783 el.setStyle("position", "absolute");
38784 if(!panel.background){
38785 this.setActivePanel(panel);
38786 if(this.config.initialSize && this.panels.getCount()==1){
38787 this.resizeTo(this.config.initialSize);
38790 this.fireEvent("paneladded", this, panel);
38795 * Returns true if the panel is in this region.
38796 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
38797 * @return {Boolean}
38799 hasPanel : function(panel){
38800 if(typeof panel == "object"){ // must be panel obj
38801 panel = panel.getId();
38803 return this.getPanel(panel) ? true : false;
38807 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
38808 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
38809 * @param {Boolean} preservePanel Overrides the config preservePanel option
38810 * @return {Roo.ContentPanel} The panel that was removed
38812 remove : function(panel, preservePanel){
38813 panel = this.getPanel(panel);
38818 this.fireEvent("beforeremove", this, panel, e);
38819 if(e.cancel === true){
38822 var panelId = panel.getId();
38823 this.panels.removeKey(panelId);
38828 * Returns the panel specified or null if it's not in this region.
38829 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
38830 * @return {Roo.ContentPanel}
38832 getPanel : function(id){
38833 if(typeof id == "object"){ // must be panel obj
38836 return this.panels.get(id);
38840 * Returns this regions position (north/south/east/west/center).
38843 getPosition: function(){
38844 return this.position;
38848 * Ext JS Library 1.1.1
38849 * Copyright(c) 2006-2007, Ext JS, LLC.
38851 * Originally Released Under LGPL - original licence link has changed is not relivant.
38854 * <script type="text/javascript">
38858 * @class Roo.bootstrap.layout.Region
38859 * @extends Roo.bootstrap.layout.Basic
38860 * This class represents a region in a layout manager.
38862 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
38863 * @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})
38864 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
38865 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
38866 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
38867 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
38868 * @cfg {String} title The title for the region (overrides panel titles)
38869 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
38870 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
38871 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
38872 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
38873 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
38874 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
38875 * the space available, similar to FireFox 1.5 tabs (defaults to false)
38876 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
38877 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
38878 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
38880 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
38881 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
38882 * @cfg {Boolean} disableTabTips True to disable tab tooltips
38883 * @cfg {Number} width For East/West panels
38884 * @cfg {Number} height For North/South panels
38885 * @cfg {Boolean} split To show the splitter
38886 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
38888 * @cfg {string} cls Extra CSS classes to add to region
38890 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
38891 * @cfg {string} region the region that it inhabits..
38894 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
38895 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
38897 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
38898 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
38899 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
38901 Roo.bootstrap.layout.Region = function(config)
38903 this.applyConfig(config);
38905 var mgr = config.mgr;
38906 var pos = config.region;
38907 config.skipConfig = true;
38908 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
38911 this.onRender(mgr.el);
38914 this.visible = true;
38915 this.collapsed = false;
38916 this.unrendered_panels = [];
38919 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
38921 position: '', // set by wrapper (eg. north/south etc..)
38922 unrendered_panels : null, // unrendered panels.
38924 tabPosition : false,
38926 mgr: false, // points to 'Border'
38929 createBody : function(){
38930 /** This region's body element
38931 * @type Roo.Element */
38932 this.bodyEl = this.el.createChild({
38934 cls: "roo-layout-panel-body tab-content" // bootstrap added...
38938 onRender: function(ctr, pos)
38940 var dh = Roo.DomHelper;
38941 /** This region's container element
38942 * @type Roo.Element */
38943 this.el = dh.append(ctr.dom, {
38945 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
38947 /** This region's title element
38948 * @type Roo.Element */
38950 this.titleEl = dh.append(this.el.dom, {
38952 unselectable: "on",
38953 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
38955 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
38956 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
38960 this.titleEl.enableDisplayMode();
38961 /** This region's title text element
38962 * @type HTMLElement */
38963 this.titleTextEl = this.titleEl.dom.firstChild;
38964 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
38966 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
38967 this.closeBtn.enableDisplayMode();
38968 this.closeBtn.on("click", this.closeClicked, this);
38969 this.closeBtn.hide();
38971 this.createBody(this.config);
38972 if(this.config.hideWhenEmpty){
38974 this.on("paneladded", this.validateVisibility, this);
38975 this.on("panelremoved", this.validateVisibility, this);
38977 if(this.autoScroll){
38978 this.bodyEl.setStyle("overflow", "auto");
38980 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
38982 //if(c.titlebar !== false){
38983 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
38984 this.titleEl.hide();
38986 this.titleEl.show();
38987 if(this.config.title){
38988 this.titleTextEl.innerHTML = this.config.title;
38992 if(this.config.collapsed){
38993 this.collapse(true);
38995 if(this.config.hidden){
38999 if (this.unrendered_panels && this.unrendered_panels.length) {
39000 for (var i =0;i< this.unrendered_panels.length; i++) {
39001 this.add(this.unrendered_panels[i]);
39003 this.unrendered_panels = null;
39009 applyConfig : function(c)
39012 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
39013 var dh = Roo.DomHelper;
39014 if(c.titlebar !== false){
39015 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
39016 this.collapseBtn.on("click", this.collapse, this);
39017 this.collapseBtn.enableDisplayMode();
39019 if(c.showPin === true || this.showPin){
39020 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
39021 this.stickBtn.enableDisplayMode();
39022 this.stickBtn.on("click", this.expand, this);
39023 this.stickBtn.hide();
39028 /** This region's collapsed element
39029 * @type Roo.Element */
39032 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
39033 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
39036 if(c.floatable !== false){
39037 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
39038 this.collapsedEl.on("click", this.collapseClick, this);
39041 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
39042 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
39043 id: "message", unselectable: "on", style:{"float":"left"}});
39044 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
39046 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
39047 this.expandBtn.on("click", this.expand, this);
39051 if(this.collapseBtn){
39052 this.collapseBtn.setVisible(c.collapsible == true);
39055 this.cmargins = c.cmargins || this.cmargins ||
39056 (this.position == "west" || this.position == "east" ?
39057 {top: 0, left: 2, right:2, bottom: 0} :
39058 {top: 2, left: 0, right:0, bottom: 2});
39060 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
39063 this.tabPosition = [ 'top','bottom', 'west'].indexOf(c.tabPosition) > -1 ? c.tabPosition : "top";
39065 this.autoScroll = c.autoScroll || false;
39070 this.duration = c.duration || .30;
39071 this.slideDuration = c.slideDuration || .45;
39076 * Returns true if this region is currently visible.
39077 * @return {Boolean}
39079 isVisible : function(){
39080 return this.visible;
39084 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
39085 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
39087 //setCollapsedTitle : function(title){
39088 // title = title || " ";
39089 // if(this.collapsedTitleTextEl){
39090 // this.collapsedTitleTextEl.innerHTML = title;
39094 getBox : function(){
39096 // if(!this.collapsed){
39097 b = this.el.getBox(false, true);
39099 // b = this.collapsedEl.getBox(false, true);
39104 getMargins : function(){
39105 return this.margins;
39106 //return this.collapsed ? this.cmargins : this.margins;
39109 highlight : function(){
39110 this.el.addClass("x-layout-panel-dragover");
39113 unhighlight : function(){
39114 this.el.removeClass("x-layout-panel-dragover");
39117 updateBox : function(box)
39119 if (!this.bodyEl) {
39120 return; // not rendered yet..
39124 if(!this.collapsed){
39125 this.el.dom.style.left = box.x + "px";
39126 this.el.dom.style.top = box.y + "px";
39127 this.updateBody(box.width, box.height);
39129 this.collapsedEl.dom.style.left = box.x + "px";
39130 this.collapsedEl.dom.style.top = box.y + "px";
39131 this.collapsedEl.setSize(box.width, box.height);
39134 this.tabs.autoSizeTabs();
39138 updateBody : function(w, h)
39141 this.el.setWidth(w);
39142 w -= this.el.getBorderWidth("rl");
39143 if(this.config.adjustments){
39144 w += this.config.adjustments[0];
39147 if(h !== null && h > 0){
39148 this.el.setHeight(h);
39149 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
39150 h -= this.el.getBorderWidth("tb");
39151 if(this.config.adjustments){
39152 h += this.config.adjustments[1];
39154 this.bodyEl.setHeight(h);
39156 h = this.tabs.syncHeight(h);
39159 if(this.panelSize){
39160 w = w !== null ? w : this.panelSize.width;
39161 h = h !== null ? h : this.panelSize.height;
39163 if(this.activePanel){
39164 var el = this.activePanel.getEl();
39165 w = w !== null ? w : el.getWidth();
39166 h = h !== null ? h : el.getHeight();
39167 this.panelSize = {width: w, height: h};
39168 this.activePanel.setSize(w, h);
39170 if(Roo.isIE && this.tabs){
39171 this.tabs.el.repaint();
39176 * Returns the container element for this region.
39177 * @return {Roo.Element}
39179 getEl : function(){
39184 * Hides this region.
39187 //if(!this.collapsed){
39188 this.el.dom.style.left = "-2000px";
39191 // this.collapsedEl.dom.style.left = "-2000px";
39192 // this.collapsedEl.hide();
39194 this.visible = false;
39195 this.fireEvent("visibilitychange", this, false);
39199 * Shows this region if it was previously hidden.
39202 //if(!this.collapsed){
39205 // this.collapsedEl.show();
39207 this.visible = true;
39208 this.fireEvent("visibilitychange", this, true);
39211 closeClicked : function(){
39212 if(this.activePanel){
39213 this.remove(this.activePanel);
39217 collapseClick : function(e){
39219 e.stopPropagation();
39222 e.stopPropagation();
39228 * Collapses this region.
39229 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
39232 collapse : function(skipAnim, skipCheck = false){
39233 if(this.collapsed) {
39237 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
39239 this.collapsed = true;
39241 this.split.el.hide();
39243 if(this.config.animate && skipAnim !== true){
39244 this.fireEvent("invalidated", this);
39245 this.animateCollapse();
39247 this.el.setLocation(-20000,-20000);
39249 this.collapsedEl.show();
39250 this.fireEvent("collapsed", this);
39251 this.fireEvent("invalidated", this);
39257 animateCollapse : function(){
39262 * Expands this region if it was previously collapsed.
39263 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
39264 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
39267 expand : function(e, skipAnim){
39269 e.stopPropagation();
39271 if(!this.collapsed || this.el.hasActiveFx()) {
39275 this.afterSlideIn();
39278 this.collapsed = false;
39279 if(this.config.animate && skipAnim !== true){
39280 this.animateExpand();
39284 this.split.el.show();
39286 this.collapsedEl.setLocation(-2000,-2000);
39287 this.collapsedEl.hide();
39288 this.fireEvent("invalidated", this);
39289 this.fireEvent("expanded", this);
39293 animateExpand : function(){
39297 initTabs : function()
39299 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
39301 var ts = new Roo.bootstrap.panel.Tabs({
39302 el: this.bodyEl.dom,
39304 tabPosition: this.tabPosition ? this.tabPosition : 'top',
39305 disableTooltips: this.config.disableTabTips,
39306 toolbar : this.config.toolbar
39309 if(this.config.hideTabs){
39310 ts.stripWrap.setDisplayed(false);
39313 ts.resizeTabs = this.config.resizeTabs === true;
39314 ts.minTabWidth = this.config.minTabWidth || 40;
39315 ts.maxTabWidth = this.config.maxTabWidth || 250;
39316 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
39317 ts.monitorResize = false;
39318 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
39319 ts.bodyEl.addClass('roo-layout-tabs-body');
39320 this.panels.each(this.initPanelAsTab, this);
39323 initPanelAsTab : function(panel){
39324 var ti = this.tabs.addTab(
39328 this.config.closeOnTab && panel.isClosable(),
39331 if(panel.tabTip !== undefined){
39332 ti.setTooltip(panel.tabTip);
39334 ti.on("activate", function(){
39335 this.setActivePanel(panel);
39338 if(this.config.closeOnTab){
39339 ti.on("beforeclose", function(t, e){
39341 this.remove(panel);
39345 panel.tabItem = ti;
39350 updatePanelTitle : function(panel, title)
39352 if(this.activePanel == panel){
39353 this.updateTitle(title);
39356 var ti = this.tabs.getTab(panel.getEl().id);
39358 if(panel.tabTip !== undefined){
39359 ti.setTooltip(panel.tabTip);
39364 updateTitle : function(title){
39365 if(this.titleTextEl && !this.config.title){
39366 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
39370 setActivePanel : function(panel)
39372 panel = this.getPanel(panel);
39373 if(this.activePanel && this.activePanel != panel){
39374 if(this.activePanel.setActiveState(false) === false){
39378 this.activePanel = panel;
39379 panel.setActiveState(true);
39380 if(this.panelSize){
39381 panel.setSize(this.panelSize.width, this.panelSize.height);
39384 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
39386 this.updateTitle(panel.getTitle());
39388 this.fireEvent("invalidated", this);
39390 this.fireEvent("panelactivated", this, panel);
39394 * Shows the specified panel.
39395 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
39396 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
39398 showPanel : function(panel)
39400 panel = this.getPanel(panel);
39403 var tab = this.tabs.getTab(panel.getEl().id);
39404 if(tab.isHidden()){
39405 this.tabs.unhideTab(tab.id);
39409 this.setActivePanel(panel);
39416 * Get the active panel for this region.
39417 * @return {Roo.ContentPanel} The active panel or null
39419 getActivePanel : function(){
39420 return this.activePanel;
39423 validateVisibility : function(){
39424 if(this.panels.getCount() < 1){
39425 this.updateTitle(" ");
39426 this.closeBtn.hide();
39429 if(!this.isVisible()){
39436 * Adds the passed ContentPanel(s) to this region.
39437 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
39438 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
39440 add : function(panel)
39442 if(arguments.length > 1){
39443 for(var i = 0, len = arguments.length; i < len; i++) {
39444 this.add(arguments[i]);
39449 // if we have not been rendered yet, then we can not really do much of this..
39450 if (!this.bodyEl) {
39451 this.unrendered_panels.push(panel);
39458 if(this.hasPanel(panel)){
39459 this.showPanel(panel);
39462 panel.setRegion(this);
39463 this.panels.add(panel);
39464 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
39465 // sinle panel - no tab...?? would it not be better to render it with the tabs,
39466 // and hide them... ???
39467 this.bodyEl.dom.appendChild(panel.getEl().dom);
39468 if(panel.background !== true){
39469 this.setActivePanel(panel);
39471 this.fireEvent("paneladded", this, panel);
39478 this.initPanelAsTab(panel);
39482 if(panel.background !== true){
39483 this.tabs.activate(panel.getEl().id);
39485 this.fireEvent("paneladded", this, panel);
39490 * Hides the tab for the specified panel.
39491 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
39493 hidePanel : function(panel){
39494 if(this.tabs && (panel = this.getPanel(panel))){
39495 this.tabs.hideTab(panel.getEl().id);
39500 * Unhides the tab for a previously hidden panel.
39501 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
39503 unhidePanel : function(panel){
39504 if(this.tabs && (panel = this.getPanel(panel))){
39505 this.tabs.unhideTab(panel.getEl().id);
39509 clearPanels : function(){
39510 while(this.panels.getCount() > 0){
39511 this.remove(this.panels.first());
39516 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
39517 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
39518 * @param {Boolean} preservePanel Overrides the config preservePanel option
39519 * @return {Roo.ContentPanel} The panel that was removed
39521 remove : function(panel, preservePanel)
39523 panel = this.getPanel(panel);
39528 this.fireEvent("beforeremove", this, panel, e);
39529 if(e.cancel === true){
39532 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
39533 var panelId = panel.getId();
39534 this.panels.removeKey(panelId);
39536 document.body.appendChild(panel.getEl().dom);
39539 this.tabs.removeTab(panel.getEl().id);
39540 }else if (!preservePanel){
39541 this.bodyEl.dom.removeChild(panel.getEl().dom);
39543 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
39544 var p = this.panels.first();
39545 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
39546 tempEl.appendChild(p.getEl().dom);
39547 this.bodyEl.update("");
39548 this.bodyEl.dom.appendChild(p.getEl().dom);
39550 this.updateTitle(p.getTitle());
39552 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
39553 this.setActivePanel(p);
39555 panel.setRegion(null);
39556 if(this.activePanel == panel){
39557 this.activePanel = null;
39559 if(this.config.autoDestroy !== false && preservePanel !== true){
39560 try{panel.destroy();}catch(e){}
39562 this.fireEvent("panelremoved", this, panel);
39567 * Returns the TabPanel component used by this region
39568 * @return {Roo.TabPanel}
39570 getTabs : function(){
39574 createTool : function(parentEl, className){
39575 var btn = Roo.DomHelper.append(parentEl, {
39577 cls: "x-layout-tools-button",
39580 cls: "roo-layout-tools-button-inner " + className,
39584 btn.addClassOnOver("roo-layout-tools-button-over");
39589 * Ext JS Library 1.1.1
39590 * Copyright(c) 2006-2007, Ext JS, LLC.
39592 * Originally Released Under LGPL - original licence link has changed is not relivant.
39595 * <script type="text/javascript">
39601 * @class Roo.SplitLayoutRegion
39602 * @extends Roo.LayoutRegion
39603 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
39605 Roo.bootstrap.layout.Split = function(config){
39606 this.cursor = config.cursor;
39607 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
39610 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
39612 splitTip : "Drag to resize.",
39613 collapsibleSplitTip : "Drag to resize. Double click to hide.",
39614 useSplitTips : false,
39616 applyConfig : function(config){
39617 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
39620 onRender : function(ctr,pos) {
39622 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
39623 if(!this.config.split){
39628 var splitEl = Roo.DomHelper.append(ctr.dom, {
39630 id: this.el.id + "-split",
39631 cls: "roo-layout-split roo-layout-split-"+this.position,
39634 /** The SplitBar for this region
39635 * @type Roo.SplitBar */
39636 // does not exist yet...
39637 Roo.log([this.position, this.orientation]);
39639 this.split = new Roo.bootstrap.SplitBar({
39640 dragElement : splitEl,
39641 resizingElement: this.el,
39642 orientation : this.orientation
39645 this.split.on("moved", this.onSplitMove, this);
39646 this.split.useShim = this.config.useShim === true;
39647 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
39648 if(this.useSplitTips){
39649 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
39651 //if(config.collapsible){
39652 // this.split.el.on("dblclick", this.collapse, this);
39655 if(typeof this.config.minSize != "undefined"){
39656 this.split.minSize = this.config.minSize;
39658 if(typeof this.config.maxSize != "undefined"){
39659 this.split.maxSize = this.config.maxSize;
39661 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
39662 this.hideSplitter();
39667 getHMaxSize : function(){
39668 var cmax = this.config.maxSize || 10000;
39669 var center = this.mgr.getRegion("center");
39670 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
39673 getVMaxSize : function(){
39674 var cmax = this.config.maxSize || 10000;
39675 var center = this.mgr.getRegion("center");
39676 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
39679 onSplitMove : function(split, newSize){
39680 this.fireEvent("resized", this, newSize);
39684 * Returns the {@link Roo.SplitBar} for this region.
39685 * @return {Roo.SplitBar}
39687 getSplitBar : function(){
39692 this.hideSplitter();
39693 Roo.bootstrap.layout.Split.superclass.hide.call(this);
39696 hideSplitter : function(){
39698 this.split.el.setLocation(-2000,-2000);
39699 this.split.el.hide();
39705 this.split.el.show();
39707 Roo.bootstrap.layout.Split.superclass.show.call(this);
39710 beforeSlide: function(){
39711 if(Roo.isGecko){// firefox overflow auto bug workaround
39712 this.bodyEl.clip();
39714 this.tabs.bodyEl.clip();
39716 if(this.activePanel){
39717 this.activePanel.getEl().clip();
39719 if(this.activePanel.beforeSlide){
39720 this.activePanel.beforeSlide();
39726 afterSlide : function(){
39727 if(Roo.isGecko){// firefox overflow auto bug workaround
39728 this.bodyEl.unclip();
39730 this.tabs.bodyEl.unclip();
39732 if(this.activePanel){
39733 this.activePanel.getEl().unclip();
39734 if(this.activePanel.afterSlide){
39735 this.activePanel.afterSlide();
39741 initAutoHide : function(){
39742 if(this.autoHide !== false){
39743 if(!this.autoHideHd){
39744 var st = new Roo.util.DelayedTask(this.slideIn, this);
39745 this.autoHideHd = {
39746 "mouseout": function(e){
39747 if(!e.within(this.el, true)){
39751 "mouseover" : function(e){
39757 this.el.on(this.autoHideHd);
39761 clearAutoHide : function(){
39762 if(this.autoHide !== false){
39763 this.el.un("mouseout", this.autoHideHd.mouseout);
39764 this.el.un("mouseover", this.autoHideHd.mouseover);
39768 clearMonitor : function(){
39769 Roo.get(document).un("click", this.slideInIf, this);
39772 // these names are backwards but not changed for compat
39773 slideOut : function(){
39774 if(this.isSlid || this.el.hasActiveFx()){
39777 this.isSlid = true;
39778 if(this.collapseBtn){
39779 this.collapseBtn.hide();
39781 this.closeBtnState = this.closeBtn.getStyle('display');
39782 this.closeBtn.hide();
39784 this.stickBtn.show();
39787 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
39788 this.beforeSlide();
39789 this.el.setStyle("z-index", 10001);
39790 this.el.slideIn(this.getSlideAnchor(), {
39791 callback: function(){
39793 this.initAutoHide();
39794 Roo.get(document).on("click", this.slideInIf, this);
39795 this.fireEvent("slideshow", this);
39802 afterSlideIn : function(){
39803 this.clearAutoHide();
39804 this.isSlid = false;
39805 this.clearMonitor();
39806 this.el.setStyle("z-index", "");
39807 if(this.collapseBtn){
39808 this.collapseBtn.show();
39810 this.closeBtn.setStyle('display', this.closeBtnState);
39812 this.stickBtn.hide();
39814 this.fireEvent("slidehide", this);
39817 slideIn : function(cb){
39818 if(!this.isSlid || this.el.hasActiveFx()){
39822 this.isSlid = false;
39823 this.beforeSlide();
39824 this.el.slideOut(this.getSlideAnchor(), {
39825 callback: function(){
39826 this.el.setLeftTop(-10000, -10000);
39828 this.afterSlideIn();
39836 slideInIf : function(e){
39837 if(!e.within(this.el)){
39842 animateCollapse : function(){
39843 this.beforeSlide();
39844 this.el.setStyle("z-index", 20000);
39845 var anchor = this.getSlideAnchor();
39846 this.el.slideOut(anchor, {
39847 callback : function(){
39848 this.el.setStyle("z-index", "");
39849 this.collapsedEl.slideIn(anchor, {duration:.3});
39851 this.el.setLocation(-10000,-10000);
39853 this.fireEvent("collapsed", this);
39860 animateExpand : function(){
39861 this.beforeSlide();
39862 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
39863 this.el.setStyle("z-index", 20000);
39864 this.collapsedEl.hide({
39867 this.el.slideIn(this.getSlideAnchor(), {
39868 callback : function(){
39869 this.el.setStyle("z-index", "");
39872 this.split.el.show();
39874 this.fireEvent("invalidated", this);
39875 this.fireEvent("expanded", this);
39903 getAnchor : function(){
39904 return this.anchors[this.position];
39907 getCollapseAnchor : function(){
39908 return this.canchors[this.position];
39911 getSlideAnchor : function(){
39912 return this.sanchors[this.position];
39915 getAlignAdj : function(){
39916 var cm = this.cmargins;
39917 switch(this.position){
39933 getExpandAdj : function(){
39934 var c = this.collapsedEl, cm = this.cmargins;
39935 switch(this.position){
39937 return [-(cm.right+c.getWidth()+cm.left), 0];
39940 return [cm.right+c.getWidth()+cm.left, 0];
39943 return [0, -(cm.top+cm.bottom+c.getHeight())];
39946 return [0, cm.top+cm.bottom+c.getHeight()];
39952 * Ext JS Library 1.1.1
39953 * Copyright(c) 2006-2007, Ext JS, LLC.
39955 * Originally Released Under LGPL - original licence link has changed is not relivant.
39958 * <script type="text/javascript">
39961 * These classes are private internal classes
39963 Roo.bootstrap.layout.Center = function(config){
39964 config.region = "center";
39965 Roo.bootstrap.layout.Region.call(this, config);
39966 this.visible = true;
39967 this.minWidth = config.minWidth || 20;
39968 this.minHeight = config.minHeight || 20;
39971 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
39973 // center panel can't be hidden
39977 // center panel can't be hidden
39980 getMinWidth: function(){
39981 return this.minWidth;
39984 getMinHeight: function(){
39985 return this.minHeight;
39999 Roo.bootstrap.layout.North = function(config)
40001 config.region = 'north';
40002 config.cursor = 'n-resize';
40004 Roo.bootstrap.layout.Split.call(this, config);
40008 this.split.placement = Roo.bootstrap.SplitBar.TOP;
40009 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
40010 this.split.el.addClass("roo-layout-split-v");
40012 //var size = config.initialSize || config.height;
40013 //if(this.el && typeof size != "undefined"){
40014 // this.el.setHeight(size);
40017 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
40019 orientation: Roo.bootstrap.SplitBar.VERTICAL,
40022 onRender : function(ctr, pos)
40024 Roo.bootstrap.layout.Split.prototype.onRender.call(this, ctr, pos);
40025 var size = this.config.initialSize || this.config.height;
40026 if(this.el && typeof size != "undefined"){
40027 this.el.setHeight(size);
40032 getBox : function(){
40033 if(this.collapsed){
40034 return this.collapsedEl.getBox();
40036 var box = this.el.getBox();
40038 box.height += this.split.el.getHeight();
40043 updateBox : function(box){
40044 if(this.split && !this.collapsed){
40045 box.height -= this.split.el.getHeight();
40046 this.split.el.setLeft(box.x);
40047 this.split.el.setTop(box.y+box.height);
40048 this.split.el.setWidth(box.width);
40050 if(this.collapsed){
40051 this.updateBody(box.width, null);
40053 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
40061 Roo.bootstrap.layout.South = function(config){
40062 config.region = 'south';
40063 config.cursor = 's-resize';
40064 Roo.bootstrap.layout.Split.call(this, config);
40066 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
40067 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
40068 this.split.el.addClass("roo-layout-split-v");
40073 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
40074 orientation: Roo.bootstrap.SplitBar.VERTICAL,
40076 onRender : function(ctr, pos)
40078 Roo.bootstrap.layout.Split.prototype.onRender.call(this, ctr, pos);
40079 var size = this.config.initialSize || this.config.height;
40080 if(this.el && typeof size != "undefined"){
40081 this.el.setHeight(size);
40086 getBox : function(){
40087 if(this.collapsed){
40088 return this.collapsedEl.getBox();
40090 var box = this.el.getBox();
40092 var sh = this.split.el.getHeight();
40099 updateBox : function(box){
40100 if(this.split && !this.collapsed){
40101 var sh = this.split.el.getHeight();
40104 this.split.el.setLeft(box.x);
40105 this.split.el.setTop(box.y-sh);
40106 this.split.el.setWidth(box.width);
40108 if(this.collapsed){
40109 this.updateBody(box.width, null);
40111 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
40115 Roo.bootstrap.layout.East = function(config){
40116 config.region = "east";
40117 config.cursor = "e-resize";
40118 Roo.bootstrap.layout.Split.call(this, config);
40120 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
40121 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
40122 this.split.el.addClass("roo-layout-split-h");
40126 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
40127 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
40129 onRender : function(ctr, pos)
40131 Roo.bootstrap.layout.Split.prototype.onRender.call(this, ctr, pos);
40132 var size = this.config.initialSize || this.config.width;
40133 if(this.el && typeof size != "undefined"){
40134 this.el.setWidth(size);
40139 getBox : function(){
40140 if(this.collapsed){
40141 return this.collapsedEl.getBox();
40143 var box = this.el.getBox();
40145 var sw = this.split.el.getWidth();
40152 updateBox : function(box){
40153 if(this.split && !this.collapsed){
40154 var sw = this.split.el.getWidth();
40156 this.split.el.setLeft(box.x);
40157 this.split.el.setTop(box.y);
40158 this.split.el.setHeight(box.height);
40161 if(this.collapsed){
40162 this.updateBody(null, box.height);
40164 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
40168 Roo.bootstrap.layout.West = function(config){
40169 config.region = "west";
40170 config.cursor = "w-resize";
40172 Roo.bootstrap.layout.Split.call(this, config);
40174 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
40175 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
40176 this.split.el.addClass("roo-layout-split-h");
40180 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
40181 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
40183 onRender: function(ctr, pos)
40185 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
40186 var size = this.config.initialSize || this.config.width;
40187 if(typeof size != "undefined"){
40188 this.el.setWidth(size);
40192 getBox : function(){
40193 if(this.collapsed){
40194 return this.collapsedEl.getBox();
40196 var box = this.el.getBox();
40197 if (box.width == 0) {
40198 box.width = this.config.width; // kludge?
40201 box.width += this.split.el.getWidth();
40206 updateBox : function(box){
40207 if(this.split && !this.collapsed){
40208 var sw = this.split.el.getWidth();
40210 this.split.el.setLeft(box.x+box.width);
40211 this.split.el.setTop(box.y);
40212 this.split.el.setHeight(box.height);
40214 if(this.collapsed){
40215 this.updateBody(null, box.height);
40217 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
40221 * Ext JS Library 1.1.1
40222 * Copyright(c) 2006-2007, Ext JS, LLC.
40224 * Originally Released Under LGPL - original licence link has changed is not relivant.
40227 * <script type="text/javascript">
40230 * @class Roo.bootstrap.paenl.Content
40231 * @extends Roo.util.Observable
40232 * @children Roo.bootstrap.Component
40233 * @parent builder Roo.bootstrap.layout.Border
40234 * A basic ContentPanel element. - a panel that contain any content (eg. forms etc.)
40235 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
40236 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
40237 * @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
40238 * @cfg {Boolean} closable True if the panel can be closed/removed
40239 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
40240 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
40241 * @cfg {Toolbar} toolbar A toolbar for this panel
40242 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
40243 * @cfg {String} title The title for this panel
40244 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
40245 * @cfg {String} url Calls {@link #setUrl} with this value
40246 * @cfg {String} region [required] (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
40247 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
40248 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
40249 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
40250 * @cfg {Boolean} iframe contents are an iframe - makes showing remote sources/CSS feasible..
40251 * @cfg {Boolean} badges render the badges
40252 * @cfg {String} cls extra classes to use
40253 * @cfg {String} background (primary|secondary|success|info|warning|danger|light|dark)
40256 * Create a new ContentPanel.
40257 * @param {String/Object} config A string to set only the title or a config object
40260 Roo.bootstrap.panel.Content = function( config){
40262 this.tpl = config.tpl || false;
40264 var el = config.el;
40265 var content = config.content;
40267 if(config.autoCreate){ // xtype is available if this is called from factory
40270 this.el = Roo.get(el);
40271 if(!this.el && config && config.autoCreate){
40272 if(typeof config.autoCreate == "object"){
40273 if(!config.autoCreate.id){
40274 config.autoCreate.id = config.id||el;
40276 this.el = Roo.DomHelper.append(document.body,
40277 config.autoCreate, true);
40281 cls: (config.cls || '') +
40282 (config.background ? ' bg-' + config.background : '') +
40283 " roo-layout-inactive-content",
40286 if (config.iframe) {
40290 style : 'border: 0px',
40291 src : 'about:blank'
40297 elcfg.html = config.html;
40301 this.el = Roo.DomHelper.append(document.body, elcfg , true);
40302 if (config.iframe) {
40303 this.iframeEl = this.el.select('iframe',true).first();
40308 this.closable = false;
40309 this.loaded = false;
40310 this.active = false;
40313 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
40315 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
40317 this.wrapEl = this.el; //this.el.wrap();
40319 if (config.toolbar.items) {
40320 ti = config.toolbar.items ;
40321 delete config.toolbar.items ;
40325 this.toolbar.render(this.wrapEl, 'before');
40326 for(var i =0;i < ti.length;i++) {
40327 // Roo.log(['add child', items[i]]);
40328 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
40330 this.toolbar.items = nitems;
40331 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
40332 delete config.toolbar;
40336 // xtype created footer. - not sure if will work as we normally have to render first..
40337 if (this.footer && !this.footer.el && this.footer.xtype) {
40338 if (!this.wrapEl) {
40339 this.wrapEl = this.el.wrap();
40342 this.footer.container = this.wrapEl.createChild();
40344 this.footer = Roo.factory(this.footer, Roo);
40349 if(typeof config == "string"){
40350 this.title = config;
40352 Roo.apply(this, config);
40356 this.resizeEl = Roo.get(this.resizeEl, true);
40358 this.resizeEl = this.el;
40360 // handle view.xtype
40368 * Fires when this panel is activated.
40369 * @param {Roo.ContentPanel} this
40373 * @event deactivate
40374 * Fires when this panel is activated.
40375 * @param {Roo.ContentPanel} this
40377 "deactivate" : true,
40381 * Fires when this panel is resized if fitToFrame is true.
40382 * @param {Roo.ContentPanel} this
40383 * @param {Number} width The width after any component adjustments
40384 * @param {Number} height The height after any component adjustments
40390 * Fires when this tab is created
40391 * @param {Roo.ContentPanel} this
40397 * Fires when this content is scrolled
40398 * @param {Roo.ContentPanel} this
40399 * @param {Event} scrollEvent
40410 if(this.autoScroll && !this.iframe){
40411 this.resizeEl.setStyle("overflow", "auto");
40412 this.resizeEl.on('scroll', this.onScroll, this);
40414 // fix randome scrolling
40415 //this.el.on('scroll', function() {
40416 // Roo.log('fix random scolling');
40417 // this.scrollTo('top',0);
40420 content = content || this.content;
40422 this.setContent(content);
40424 if(config && config.url){
40425 this.setUrl(this.url, this.params, this.loadOnce);
40430 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
40432 if (this.view && typeof(this.view.xtype) != 'undefined') {
40433 this.view.el = this.el.appendChild(document.createElement("div"));
40434 this.view = Roo.factory(this.view);
40435 this.view.render && this.view.render(false, '');
40439 this.fireEvent('render', this);
40442 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
40452 /* Resize Element - use this to work out scroll etc. */
40455 setRegion : function(region){
40456 this.region = region;
40457 this.setActiveClass(region && !this.background);
40461 setActiveClass: function(state)
40464 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
40465 this.el.setStyle('position','relative');
40467 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
40468 this.el.setStyle('position', 'absolute');
40473 * Returns the toolbar for this Panel if one was configured.
40474 * @return {Roo.Toolbar}
40476 getToolbar : function(){
40477 return this.toolbar;
40480 setActiveState : function(active)
40482 this.active = active;
40483 this.setActiveClass(active);
40485 if(this.fireEvent("deactivate", this) === false){
40490 this.fireEvent("activate", this);
40494 * Updates this panel's element (not for iframe)
40495 * @param {String} content The new content
40496 * @param {Boolean} loadScripts (optional) true to look for and process scripts
40498 setContent : function(content, loadScripts){
40503 this.el.update(content, loadScripts);
40506 ignoreResize : function(w, h)
40508 return false; // always resize?
40509 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
40512 this.lastSize = {width: w, height: h};
40517 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
40518 * @return {Roo.UpdateManager} The UpdateManager
40520 getUpdateManager : function(){
40524 return this.el.getUpdateManager();
40527 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
40528 * Does not work with IFRAME contents
40529 * @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:
40532 url: "your-url.php",
40533 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
40534 callback: yourFunction,
40535 scope: yourObject, //(optional scope)
40538 text: "Loading...",
40544 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
40545 * 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.
40546 * @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}
40547 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
40548 * @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.
40549 * @return {Roo.ContentPanel} this
40557 var um = this.el.getUpdateManager();
40558 um.update.apply(um, arguments);
40564 * 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.
40565 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
40566 * @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)
40567 * @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)
40568 * @return {Roo.UpdateManager|Boolean} The UpdateManager or false if IFRAME
40570 setUrl : function(url, params, loadOnce){
40572 this.iframeEl.dom.src = url;
40576 if(this.refreshDelegate){
40577 this.removeListener("activate", this.refreshDelegate);
40579 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
40580 this.on("activate", this.refreshDelegate);
40581 return this.el.getUpdateManager();
40584 _handleRefresh : function(url, params, loadOnce){
40585 if(!loadOnce || !this.loaded){
40586 var updater = this.el.getUpdateManager();
40587 updater.update(url, params, this._setLoaded.createDelegate(this));
40591 _setLoaded : function(){
40592 this.loaded = true;
40596 * Returns this panel's id
40599 getId : function(){
40604 * Returns this panel's element - used by regiosn to add.
40605 * @return {Roo.Element}
40607 getEl : function(){
40608 return this.wrapEl || this.el;
40613 adjustForComponents : function(width, height)
40615 //Roo.log('adjustForComponents ');
40616 if(this.resizeEl != this.el){
40617 width -= this.el.getFrameWidth('lr');
40618 height -= this.el.getFrameWidth('tb');
40621 var te = this.toolbar.getEl();
40622 te.setWidth(width);
40623 height -= te.getHeight();
40626 var te = this.footer.getEl();
40627 te.setWidth(width);
40628 height -= te.getHeight();
40632 if(this.adjustments){
40633 width += this.adjustments[0];
40634 height += this.adjustments[1];
40636 return {"width": width, "height": height};
40639 setSize : function(width, height){
40640 if(this.fitToFrame && !this.ignoreResize(width, height)){
40641 if(this.fitContainer && this.resizeEl != this.el){
40642 this.el.setSize(width, height);
40644 var size = this.adjustForComponents(width, height);
40646 this.iframeEl.setSize(width,height);
40649 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
40650 this.fireEvent('resize', this, size.width, size.height);
40657 * Returns this panel's title
40660 getTitle : function(){
40662 if (typeof(this.title) != 'object') {
40667 for (var k in this.title) {
40668 if (!this.title.hasOwnProperty(k)) {
40672 if (k.indexOf('-') >= 0) {
40673 var s = k.split('-');
40674 for (var i = 0; i<s.length; i++) {
40675 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
40678 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
40685 * Set this panel's title
40686 * @param {String} title
40688 setTitle : function(title){
40689 this.title = title;
40691 this.region.updatePanelTitle(this, title);
40696 * Returns true is this panel was configured to be closable
40697 * @return {Boolean}
40699 isClosable : function(){
40700 return this.closable;
40703 beforeSlide : function(){
40705 this.resizeEl.clip();
40708 afterSlide : function(){
40710 this.resizeEl.unclip();
40714 * Force a content refresh from the URL specified in the {@link #setUrl} method.
40715 * Will fail silently if the {@link #setUrl} method has not been called.
40716 * This does not activate the panel, just updates its content.
40718 refresh : function(){
40719 if(this.refreshDelegate){
40720 this.loaded = false;
40721 this.refreshDelegate();
40726 * Destroys this panel
40728 destroy : function(){
40729 this.el.removeAllListeners();
40730 var tempEl = document.createElement("span");
40731 tempEl.appendChild(this.el.dom);
40732 tempEl.innerHTML = "";
40738 * form - if the content panel contains a form - this is a reference to it.
40739 * @type {Roo.form.Form}
40743 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
40744 * This contains a reference to it.
40750 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
40760 * @param {Object} cfg Xtype definition of item to add.
40764 getChildContainer: function () {
40765 return this.getEl();
40769 onScroll : function(e)
40771 this.fireEvent('scroll', this, e);
40776 var ret = new Roo.factory(cfg);
40781 if (cfg.xtype.match(/^Form$/)) {
40784 //if (this.footer) {
40785 // el = this.footer.container.insertSibling(false, 'before');
40787 el = this.el.createChild();
40790 this.form = new Roo.form.Form(cfg);
40793 if ( this.form.allItems.length) {
40794 this.form.render(el.dom);
40798 // should only have one of theses..
40799 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
40800 // views.. should not be just added - used named prop 'view''
40802 cfg.el = this.el.appendChild(document.createElement("div"));
40805 var ret = new Roo.factory(cfg);
40807 ret.render && ret.render(false, ''); // render blank..
40817 * @class Roo.bootstrap.panel.Grid
40818 * @extends Roo.bootstrap.panel.Content
40820 * Create a new GridPanel.
40821 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
40822 * @cfg {Roo.bootstrap.nav.Simplebar} toolbar the toolbar at the top of the grid.
40823 * @param {Object} config A the config object
40829 Roo.bootstrap.panel.Grid = function(config)
40833 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
40834 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
40836 config.el = this.wrapper;
40837 //this.el = this.wrapper;
40839 if (config.container) {
40840 // ctor'ed from a Border/panel.grid
40843 this.wrapper.setStyle("overflow", "hidden");
40844 this.wrapper.addClass('roo-grid-container');
40849 if(config.toolbar){
40850 var tool_el = this.wrapper.createChild();
40851 this.toolbar = Roo.factory(config.toolbar);
40853 if (config.toolbar.items) {
40854 ti = config.toolbar.items ;
40855 delete config.toolbar.items ;
40859 this.toolbar.render(tool_el);
40860 for(var i =0;i < ti.length;i++) {
40861 // Roo.log(['add child', items[i]]);
40862 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
40864 this.toolbar.items = nitems;
40866 delete config.toolbar;
40869 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
40870 config.grid.scrollBody = true;;
40871 config.grid.monitorWindowResize = false; // turn off autosizing
40872 config.grid.autoHeight = false;
40873 config.grid.autoWidth = false;
40875 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
40877 if (config.background) {
40878 // render grid on panel activation (if panel background)
40879 this.on('activate', function(gp) {
40880 if (!gp.grid.rendered) {
40881 gp.grid.render(this.wrapper);
40882 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
40887 this.grid.render(this.wrapper);
40888 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
40891 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
40892 // ??? needed ??? config.el = this.wrapper;
40897 // xtype created footer. - not sure if will work as we normally have to render first..
40898 if (this.footer && !this.footer.el && this.footer.xtype) {
40900 var ctr = this.grid.getView().getFooterPanel(true);
40901 this.footer.dataSource = this.grid.dataSource;
40902 this.footer = Roo.factory(this.footer, Roo);
40903 this.footer.render(ctr);
40913 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content,
40916 is_resizing : false,
40918 getId : function(){
40919 return this.grid.id;
40923 * Returns the grid for this panel
40924 * @return {Roo.bootstrap.Table}
40926 getGrid : function(){
40930 setSize : function(width, height)
40932 if (this.is_resizing) {
40936 this.is_resizing = true;
40937 if(!this.ignoreResize(width, height)){
40938 var grid = this.grid;
40939 var size = this.adjustForComponents(width, height);
40940 // tfoot is not a footer?
40943 var gridel = grid.getGridEl();
40944 gridel.setSize(size.width, size.height);
40946 var tbd = grid.getGridEl().select('tbody', true).first();
40947 var thd = grid.getGridEl().select('thead',true).first();
40948 var tbf= grid.getGridEl().select('tfoot', true).first();
40951 size.height -= tbf.getHeight();
40954 size.height -= thd.getHeight();
40957 tbd.setSize(size.width, size.height );
40958 // this is for the account management tab -seems to work there.
40959 var thd = grid.getGridEl().select('thead',true).first();
40961 // tbd.setSize(size.width, size.height - thd.getHeight());
40966 this.is_resizing = false;
40971 beforeSlide : function(){
40972 this.grid.getView().scroller.clip();
40975 afterSlide : function(){
40976 this.grid.getView().scroller.unclip();
40979 destroy : function(){
40980 this.grid.destroy();
40982 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
40987 * @class Roo.bootstrap.panel.Nest
40988 * @extends Roo.bootstrap.panel.Content
40990 * Create a new Panel, that can contain a layout.Border.
40993 * @param {String/Object} config A string to set only the title or a config object
40995 Roo.bootstrap.panel.Nest = function(config)
40997 // construct with only one argument..
40998 /* FIXME - implement nicer consturctors
40999 if (layout.layout) {
41001 layout = config.layout;
41002 delete config.layout;
41004 if (layout.xtype && !layout.getEl) {
41005 // then layout needs constructing..
41006 layout = Roo.factory(layout, Roo);
41010 config.el = config.layout.getEl();
41012 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
41014 config.layout.monitorWindowResize = false; // turn off autosizing
41015 this.layout = config.layout;
41016 this.layout.getEl().addClass("roo-layout-nested-layout");
41017 this.layout.parent = this;
41024 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
41026 * @cfg {Roo.BorderLayout} layout The layout for this panel
41030 setSize : function(width, height){
41031 if(!this.ignoreResize(width, height)){
41032 var size = this.adjustForComponents(width, height);
41033 var el = this.layout.getEl();
41034 if (size.height < 1) {
41035 el.setWidth(size.width);
41037 el.setSize(size.width, size.height);
41039 var touch = el.dom.offsetWidth;
41040 this.layout.layout();
41041 // ie requires a double layout on the first pass
41042 if(Roo.isIE && !this.initialized){
41043 this.initialized = true;
41044 this.layout.layout();
41049 // activate all subpanels if not currently active..
41051 setActiveState : function(active){
41052 this.active = active;
41053 this.setActiveClass(active);
41056 this.fireEvent("deactivate", this);
41060 this.fireEvent("activate", this);
41061 // not sure if this should happen before or after..
41062 if (!this.layout) {
41063 return; // should not happen..
41066 for (var r in this.layout.regions) {
41067 reg = this.layout.getRegion(r);
41068 if (reg.getActivePanel()) {
41069 //reg.showPanel(reg.getActivePanel()); // force it to activate..
41070 reg.setActivePanel(reg.getActivePanel());
41073 if (!reg.panels.length) {
41076 reg.showPanel(reg.getPanel(0));
41085 * Returns the nested BorderLayout for this panel
41086 * @return {Roo.BorderLayout}
41088 getLayout : function(){
41089 return this.layout;
41093 * Adds a xtype elements to the layout of the nested panel
41097 xtype : 'ContentPanel',
41104 xtype : 'NestedLayoutPanel',
41110 items : [ ... list of content panels or nested layout panels.. ]
41114 * @param {Object} cfg Xtype definition of item to add.
41116 addxtype : function(cfg) {
41117 return this.layout.addxtype(cfg);
41122 * Ext JS Library 1.1.1
41123 * Copyright(c) 2006-2007, Ext JS, LLC.
41125 * Originally Released Under LGPL - original licence link has changed is not relivant.
41128 * <script type="text/javascript">
41131 * @class Roo.TabPanel
41132 * @extends Roo.util.Observable
41133 * A lightweight tab container.
41137 // basic tabs 1, built from existing content
41138 var tabs = new Roo.TabPanel("tabs1");
41139 tabs.addTab("script", "View Script");
41140 tabs.addTab("markup", "View Markup");
41141 tabs.activate("script");
41143 // more advanced tabs, built from javascript
41144 var jtabs = new Roo.TabPanel("jtabs");
41145 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
41147 // set up the UpdateManager
41148 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
41149 var updater = tab2.getUpdateManager();
41150 updater.setDefaultUrl("ajax1.htm");
41151 tab2.on('activate', updater.refresh, updater, true);
41153 // Use setUrl for Ajax loading
41154 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
41155 tab3.setUrl("ajax2.htm", null, true);
41158 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
41161 jtabs.activate("jtabs-1");
41164 * Create a new TabPanel.
41165 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
41166 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
41168 Roo.bootstrap.panel.Tabs = function(config){
41170 * The container element for this TabPanel.
41171 * @type Roo.Element
41173 this.el = Roo.get(config.el);
41176 if(typeof config == "boolean"){
41177 this.tabPosition = config ? "bottom" : "top";
41179 Roo.apply(this, config);
41183 if(this.tabPosition == "bottom"){
41184 // if tabs are at the bottom = create the body first.
41185 this.bodyEl = Roo.get(this.createBody(this.el.dom));
41186 this.el.addClass("roo-tabs-bottom");
41188 // next create the tabs holders
41190 if (this.tabPosition == "west"){
41192 var reg = this.region; // fake it..
41194 if (!reg.mgr.parent) {
41197 reg = reg.mgr.parent.region;
41199 Roo.log("got nest?");
41201 if (reg.mgr.getRegion('west')) {
41202 var ctrdom = reg.mgr.getRegion('west').bodyEl.dom;
41203 this.stripWrap = Roo.get(this.createStrip(ctrdom ), true);
41204 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
41205 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
41206 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
41214 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
41215 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
41216 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
41217 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
41222 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
41225 // finally - if tabs are at the top, then create the body last..
41226 if(this.tabPosition != "bottom"){
41227 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
41228 * @type Roo.Element
41230 this.bodyEl = Roo.get(this.createBody(this.el.dom));
41231 this.el.addClass("roo-tabs-top");
41235 this.bodyEl.setStyle("position", "relative");
41237 this.active = null;
41238 this.activateDelegate = this.activate.createDelegate(this);
41243 * Fires when the active tab changes
41244 * @param {Roo.TabPanel} this
41245 * @param {Roo.TabPanelItem} activePanel The new active tab
41249 * @event beforetabchange
41250 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
41251 * @param {Roo.TabPanel} this
41252 * @param {Object} e Set cancel to true on this object to cancel the tab change
41253 * @param {Roo.TabPanelItem} tab The tab being changed to
41255 "beforetabchange" : true
41258 Roo.EventManager.onWindowResize(this.onResize, this);
41259 this.cpad = this.el.getPadding("lr");
41260 this.hiddenCount = 0;
41263 // toolbar on the tabbar support...
41264 if (this.toolbar) {
41265 alert("no toolbar support yet");
41266 this.toolbar = false;
41268 var tcfg = this.toolbar;
41269 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
41270 this.toolbar = new Roo.Toolbar(tcfg);
41271 if (Roo.isSafari) {
41272 var tbl = tcfg.container.child('table', true);
41273 tbl.setAttribute('width', '100%');
41281 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
41284 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
41286 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
41288 tabPosition : "top",
41290 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
41292 currentTabWidth : 0,
41294 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
41298 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
41302 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
41304 preferredTabWidth : 175,
41306 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
41308 resizeTabs : false,
41310 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
41312 monitorResize : true,
41314 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
41316 toolbar : false, // set by caller..
41318 region : false, /// set by caller
41320 disableTooltips : true, // not used yet...
41323 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
41324 * @param {String} id The id of the div to use <b>or create</b>
41325 * @param {String} text The text for the tab
41326 * @param {String} content (optional) Content to put in the TabPanelItem body
41327 * @param {Boolean} closable (optional) True to create a close icon on the tab
41328 * @return {Roo.TabPanelItem} The created TabPanelItem
41330 addTab : function(id, text, content, closable, tpl)
41332 var item = new Roo.bootstrap.panel.TabItem({
41336 closable : closable,
41339 this.addTabItem(item);
41341 item.setContent(content);
41347 * Returns the {@link Roo.TabPanelItem} with the specified id/index
41348 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
41349 * @return {Roo.TabPanelItem}
41351 getTab : function(id){
41352 return this.items[id];
41356 * Hides the {@link Roo.TabPanelItem} with the specified id/index
41357 * @param {String/Number} id The id or index of the TabPanelItem to hide.
41359 hideTab : function(id){
41360 var t = this.items[id];
41363 this.hiddenCount++;
41364 this.autoSizeTabs();
41369 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
41370 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
41372 unhideTab : function(id){
41373 var t = this.items[id];
41375 t.setHidden(false);
41376 this.hiddenCount--;
41377 this.autoSizeTabs();
41382 * Adds an existing {@link Roo.TabPanelItem}.
41383 * @param {Roo.TabPanelItem} item The TabPanelItem to add
41385 addTabItem : function(item)
41387 this.items[item.id] = item;
41388 this.items.push(item);
41389 this.autoSizeTabs();
41390 // if(this.resizeTabs){
41391 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
41392 // this.autoSizeTabs();
41394 // item.autoSize();
41399 * Removes a {@link Roo.TabPanelItem}.
41400 * @param {String/Number} id The id or index of the TabPanelItem to remove.
41402 removeTab : function(id){
41403 var items = this.items;
41404 var tab = items[id];
41405 if(!tab) { return; }
41406 var index = items.indexOf(tab);
41407 if(this.active == tab && items.length > 1){
41408 var newTab = this.getNextAvailable(index);
41413 this.stripEl.dom.removeChild(tab.pnode.dom);
41414 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
41415 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
41417 items.splice(index, 1);
41418 delete this.items[tab.id];
41419 tab.fireEvent("close", tab);
41420 tab.purgeListeners();
41421 this.autoSizeTabs();
41424 getNextAvailable : function(start){
41425 var items = this.items;
41427 // look for a next tab that will slide over to
41428 // replace the one being removed
41429 while(index < items.length){
41430 var item = items[++index];
41431 if(item && !item.isHidden()){
41435 // if one isn't found select the previous tab (on the left)
41438 var item = items[--index];
41439 if(item && !item.isHidden()){
41447 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
41448 * @param {String/Number} id The id or index of the TabPanelItem to disable.
41450 disableTab : function(id){
41451 var tab = this.items[id];
41452 if(tab && this.active != tab){
41458 * Enables a {@link Roo.TabPanelItem} that is disabled.
41459 * @param {String/Number} id The id or index of the TabPanelItem to enable.
41461 enableTab : function(id){
41462 var tab = this.items[id];
41467 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
41468 * @param {String/Number} id The id or index of the TabPanelItem to activate.
41469 * @return {Roo.TabPanelItem} The TabPanelItem.
41471 activate : function(id)
41473 //Roo.log('activite:' + id);
41475 var tab = this.items[id];
41479 if(tab == this.active || tab.disabled){
41483 this.fireEvent("beforetabchange", this, e, tab);
41484 if(e.cancel !== true && !tab.disabled){
41486 this.active.hide();
41488 this.active = this.items[id];
41489 this.active.show();
41490 this.fireEvent("tabchange", this, this.active);
41496 * Gets the active {@link Roo.TabPanelItem}.
41497 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
41499 getActiveTab : function(){
41500 return this.active;
41504 * Updates the tab body element to fit the height of the container element
41505 * for overflow scrolling
41506 * @param {Number} targetHeight (optional) Override the starting height from the elements height
41508 syncHeight : function(targetHeight){
41509 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
41510 var bm = this.bodyEl.getMargins();
41511 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
41512 this.bodyEl.setHeight(newHeight);
41516 onResize : function(){
41517 if(this.monitorResize){
41518 this.autoSizeTabs();
41523 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
41525 beginUpdate : function(){
41526 this.updating = true;
41530 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
41532 endUpdate : function(){
41533 this.updating = false;
41534 this.autoSizeTabs();
41538 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
41540 autoSizeTabs : function()
41542 var count = this.items.length;
41543 var vcount = count - this.hiddenCount;
41546 this.stripEl.hide();
41548 this.stripEl.show();
41551 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
41556 var w = Math.max(this.el.getWidth() - this.cpad, 10);
41557 var availWidth = Math.floor(w / vcount);
41558 var b = this.stripBody;
41559 if(b.getWidth() > w){
41560 var tabs = this.items;
41561 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
41562 if(availWidth < this.minTabWidth){
41563 /*if(!this.sleft){ // incomplete scrolling code
41564 this.createScrollButtons();
41567 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
41570 if(this.currentTabWidth < this.preferredTabWidth){
41571 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
41577 * Returns the number of tabs in this TabPanel.
41580 getCount : function(){
41581 return this.items.length;
41585 * Resizes all the tabs to the passed width
41586 * @param {Number} The new width
41588 setTabWidth : function(width){
41589 this.currentTabWidth = width;
41590 for(var i = 0, len = this.items.length; i < len; i++) {
41591 if(!this.items[i].isHidden()) {
41592 this.items[i].setWidth(width);
41598 * Destroys this TabPanel
41599 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
41601 destroy : function(removeEl){
41602 Roo.EventManager.removeResizeListener(this.onResize, this);
41603 for(var i = 0, len = this.items.length; i < len; i++){
41604 this.items[i].purgeListeners();
41606 if(removeEl === true){
41607 this.el.update("");
41612 createStrip : function(container)
41614 var strip = document.createElement("nav");
41615 strip.className = Roo.bootstrap.version == 4 ?
41616 "navbar-light bg-light" :
41617 "navbar navbar-default"; //"x-tabs-wrap";
41618 container.appendChild(strip);
41622 createStripList : function(strip)
41624 // div wrapper for retard IE
41625 // returns the "tr" element.
41626 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
41627 //'<div class="x-tabs-strip-wrap">'+
41628 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
41629 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
41630 return strip.firstChild; //.firstChild.firstChild.firstChild;
41632 createBody : function(container)
41634 var body = document.createElement("div");
41635 Roo.id(body, "tab-body");
41636 //Roo.fly(body).addClass("x-tabs-body");
41637 Roo.fly(body).addClass("tab-content");
41638 container.appendChild(body);
41641 createItemBody :function(bodyEl, id){
41642 var body = Roo.getDom(id);
41644 body = document.createElement("div");
41647 //Roo.fly(body).addClass("x-tabs-item-body");
41648 Roo.fly(body).addClass("tab-pane");
41649 bodyEl.insertBefore(body, bodyEl.firstChild);
41653 createStripElements : function(stripEl, text, closable, tpl)
41655 var td = document.createElement("li"); // was td..
41656 td.className = 'nav-item';
41658 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
41661 stripEl.appendChild(td);
41663 td.className = "x-tabs-closable";
41664 if(!this.closeTpl){
41665 this.closeTpl = new Roo.Template(
41666 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
41667 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
41668 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
41671 var el = this.closeTpl.overwrite(td, {"text": text});
41672 var close = el.getElementsByTagName("div")[0];
41673 var inner = el.getElementsByTagName("em")[0];
41674 return {"el": el, "close": close, "inner": inner};
41677 // not sure what this is..
41678 // if(!this.tabTpl){
41679 //this.tabTpl = new Roo.Template(
41680 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
41681 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
41683 // this.tabTpl = new Roo.Template(
41684 // '<a href="#">' +
41685 // '<span unselectable="on"' +
41686 // (this.disableTooltips ? '' : ' title="{text}"') +
41687 // ' >{text}</span></a>'
41693 var template = tpl || this.tabTpl || false;
41696 template = new Roo.Template(
41697 Roo.bootstrap.version == 4 ?
41699 '<a class="nav-link" href="#" unselectable="on"' +
41700 (this.disableTooltips ? '' : ' title="{text}"') +
41703 '<a class="nav-link" href="#">' +
41704 '<span unselectable="on"' +
41705 (this.disableTooltips ? '' : ' title="{text}"') +
41706 ' >{text}</span></a>'
41711 switch (typeof(template)) {
41715 template = new Roo.Template(template);
41721 var el = template.overwrite(td, {"text": text});
41723 var inner = el.getElementsByTagName("span")[0];
41725 return {"el": el, "inner": inner};
41733 * @class Roo.TabPanelItem
41734 * @extends Roo.util.Observable
41735 * Represents an individual item (tab plus body) in a TabPanel.
41736 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
41737 * @param {String} id The id of this TabPanelItem
41738 * @param {String} text The text for the tab of this TabPanelItem
41739 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
41741 Roo.bootstrap.panel.TabItem = function(config){
41743 * The {@link Roo.TabPanel} this TabPanelItem belongs to
41744 * @type Roo.TabPanel
41746 this.tabPanel = config.panel;
41748 * The id for this TabPanelItem
41751 this.id = config.id;
41753 this.disabled = false;
41755 this.text = config.text;
41757 this.loaded = false;
41758 this.closable = config.closable;
41761 * The body element for this TabPanelItem.
41762 * @type Roo.Element
41764 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
41765 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
41766 this.bodyEl.setStyle("display", "block");
41767 this.bodyEl.setStyle("zoom", "1");
41768 //this.hideAction();
41770 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
41772 this.el = Roo.get(els.el);
41773 this.inner = Roo.get(els.inner, true);
41774 this.textEl = Roo.bootstrap.version == 4 ?
41775 this.el : Roo.get(this.el.dom.firstChild, true);
41777 this.pnode = this.linode = Roo.get(els.el.parentNode, true);
41778 this.status_node = Roo.bootstrap.version == 4 ? this.el : this.linode;
41781 // this.el.on("mousedown", this.onTabMouseDown, this);
41782 this.el.on("click", this.onTabClick, this);
41784 if(config.closable){
41785 var c = Roo.get(els.close, true);
41786 c.dom.title = this.closeText;
41787 c.addClassOnOver("close-over");
41788 c.on("click", this.closeClick, this);
41794 * Fires when this tab becomes the active tab.
41795 * @param {Roo.TabPanel} tabPanel The parent TabPanel
41796 * @param {Roo.TabPanelItem} this
41800 * @event beforeclose
41801 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
41802 * @param {Roo.TabPanelItem} this
41803 * @param {Object} e Set cancel to true on this object to cancel the close.
41805 "beforeclose": true,
41808 * Fires when this tab is closed.
41809 * @param {Roo.TabPanelItem} this
41813 * @event deactivate
41814 * Fires when this tab is no longer the active tab.
41815 * @param {Roo.TabPanel} tabPanel The parent TabPanel
41816 * @param {Roo.TabPanelItem} this
41818 "deactivate" : true
41820 this.hidden = false;
41822 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
41825 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
41827 purgeListeners : function(){
41828 Roo.util.Observable.prototype.purgeListeners.call(this);
41829 this.el.removeAllListeners();
41832 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
41835 this.status_node.addClass("active");
41838 this.tabPanel.stripWrap.repaint();
41840 this.fireEvent("activate", this.tabPanel, this);
41844 * Returns true if this tab is the active tab.
41845 * @return {Boolean}
41847 isActive : function(){
41848 return this.tabPanel.getActiveTab() == this;
41852 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
41855 this.status_node.removeClass("active");
41857 this.fireEvent("deactivate", this.tabPanel, this);
41860 hideAction : function(){
41861 this.bodyEl.hide();
41862 this.bodyEl.setStyle("position", "absolute");
41863 this.bodyEl.setLeft("-20000px");
41864 this.bodyEl.setTop("-20000px");
41867 showAction : function(){
41868 this.bodyEl.setStyle("position", "relative");
41869 this.bodyEl.setTop("");
41870 this.bodyEl.setLeft("");
41871 this.bodyEl.show();
41875 * Set the tooltip for the tab.
41876 * @param {String} tooltip The tab's tooltip
41878 setTooltip : function(text){
41879 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
41880 this.textEl.dom.qtip = text;
41881 this.textEl.dom.removeAttribute('title');
41883 this.textEl.dom.title = text;
41887 onTabClick : function(e){
41888 e.preventDefault();
41889 this.tabPanel.activate(this.id);
41892 onTabMouseDown : function(e){
41893 e.preventDefault();
41894 this.tabPanel.activate(this.id);
41897 getWidth : function(){
41898 return this.inner.getWidth();
41901 setWidth : function(width){
41902 var iwidth = width - this.linode.getPadding("lr");
41903 this.inner.setWidth(iwidth);
41904 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
41905 this.linode.setWidth(width);
41909 * Show or hide the tab
41910 * @param {Boolean} hidden True to hide or false to show.
41912 setHidden : function(hidden){
41913 this.hidden = hidden;
41914 this.linode.setStyle("display", hidden ? "none" : "");
41918 * Returns true if this tab is "hidden"
41919 * @return {Boolean}
41921 isHidden : function(){
41922 return this.hidden;
41926 * Returns the text for this tab
41929 getText : function(){
41933 autoSize : function(){
41934 //this.el.beginMeasure();
41935 this.textEl.setWidth(1);
41937 * #2804 [new] Tabs in Roojs
41938 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
41940 //this.setWidth(this.textEl.dom.scrollWidth+this.linode.getPadding("lr")+this.inner.getPadding("lr") + 2);
41941 //this.el.endMeasure();
41945 * Sets the text for the tab (Note: this also sets the tooltip text)
41946 * @param {String} text The tab's text and tooltip
41948 setText : function(text){
41950 this.textEl.update(text);
41951 this.setTooltip(text);
41952 //if(!this.tabPanel.resizeTabs){
41953 // this.autoSize();
41957 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
41959 activate : function(){
41960 this.tabPanel.activate(this.id);
41964 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
41966 disable : function(){
41967 if(this.tabPanel.active != this){
41968 this.disabled = true;
41969 this.status_node.addClass("disabled");
41974 * Enables this TabPanelItem if it was previously disabled.
41976 enable : function(){
41977 this.disabled = false;
41978 this.status_node.removeClass("disabled");
41982 * Sets the content for this TabPanelItem.
41983 * @param {String} content The content
41984 * @param {Boolean} loadScripts true to look for and load scripts
41986 setContent : function(content, loadScripts){
41987 this.bodyEl.update(content, loadScripts);
41991 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
41992 * @return {Roo.UpdateManager} The UpdateManager
41994 getUpdateManager : function(){
41995 return this.bodyEl.getUpdateManager();
41999 * Set a URL to be used to load the content for this TabPanelItem.
42000 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
42001 * @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)
42002 * @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)
42003 * @return {Roo.UpdateManager} The UpdateManager
42005 setUrl : function(url, params, loadOnce){
42006 if(this.refreshDelegate){
42007 this.un('activate', this.refreshDelegate);
42009 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
42010 this.on("activate", this.refreshDelegate);
42011 return this.bodyEl.getUpdateManager();
42015 _handleRefresh : function(url, params, loadOnce){
42016 if(!loadOnce || !this.loaded){
42017 var updater = this.bodyEl.getUpdateManager();
42018 updater.update(url, params, this._setLoaded.createDelegate(this));
42023 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
42024 * Will fail silently if the setUrl method has not been called.
42025 * This does not activate the panel, just updates its content.
42027 refresh : function(){
42028 if(this.refreshDelegate){
42029 this.loaded = false;
42030 this.refreshDelegate();
42035 _setLoaded : function(){
42036 this.loaded = true;
42040 closeClick : function(e){
42043 this.fireEvent("beforeclose", this, o);
42044 if(o.cancel !== true){
42045 this.tabPanel.removeTab(this.id);
42049 * The text displayed in the tooltip for the close icon.
42052 closeText : "Close this tab"
42055 * This script refer to:
42056 * Title: International Telephone Input
42057 * Author: Jack O'Connor
42058 * Code version: v12.1.12
42059 * Availability: https://github.com/jackocnr/intl-tel-input.git
42062 Roo.bootstrap.form.PhoneInputData = function() {
42065 "Afghanistan (افغانستان)",
42070 "Albania (Shqipëri)",
42075 "Algeria (الجزائر)",
42100 "Antigua and Barbuda",
42110 "Armenia (Հայաստան)",
42126 "Austria (Österreich)",
42131 "Azerbaijan (Azərbaycan)",
42141 "Bahrain (البحرين)",
42146 "Bangladesh (বাংলাদেশ)",
42156 "Belarus (Беларусь)",
42161 "Belgium (België)",
42191 "Bosnia and Herzegovina (Босна и Херцеговина)",
42206 "British Indian Ocean Territory",
42211 "British Virgin Islands",
42221 "Bulgaria (България)",
42231 "Burundi (Uburundi)",
42236 "Cambodia (កម្ពុជា)",
42241 "Cameroon (Cameroun)",
42250 ["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"]
42253 "Cape Verde (Kabu Verdi)",
42258 "Caribbean Netherlands",
42269 "Central African Republic (République centrafricaine)",
42289 "Christmas Island",
42295 "Cocos (Keeling) Islands",
42306 "Comoros (جزر القمر)",
42311 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
42316 "Congo (Republic) (Congo-Brazzaville)",
42336 "Croatia (Hrvatska)",
42357 "Czech Republic (Česká republika)",
42362 "Denmark (Danmark)",
42377 "Dominican Republic (República Dominicana)",
42381 ["809", "829", "849"]
42399 "Equatorial Guinea (Guinea Ecuatorial)",
42419 "Falkland Islands (Islas Malvinas)",
42424 "Faroe Islands (Føroyar)",
42445 "French Guiana (Guyane française)",
42450 "French Polynesia (Polynésie française)",
42465 "Georgia (საქართველო)",
42470 "Germany (Deutschland)",
42490 "Greenland (Kalaallit Nunaat)",
42527 "Guinea-Bissau (Guiné Bissau)",
42552 "Hungary (Magyarország)",
42557 "Iceland (Ísland)",
42577 "Iraq (العراق)",
42593 "Israel (ישראל)",
42620 "Jordan (الأردن)",
42625 "Kazakhstan (Казахстан)",
42646 "Kuwait (الكويت)",
42651 "Kyrgyzstan (Кыргызстан)",
42661 "Latvia (Latvija)",
42666 "Lebanon (لبنان)",
42681 "Libya (ليبيا)",
42691 "Lithuania (Lietuva)",
42706 "Macedonia (FYROM) (Македонија)",
42711 "Madagascar (Madagasikara)",
42741 "Marshall Islands",
42751 "Mauritania (موريتانيا)",
42756 "Mauritius (Moris)",
42777 "Moldova (Republica Moldova)",
42787 "Mongolia (Монгол)",
42792 "Montenegro (Crna Gora)",
42802 "Morocco (المغرب)",
42808 "Mozambique (Moçambique)",
42813 "Myanmar (Burma) (မြန်မာ)",
42818 "Namibia (Namibië)",
42833 "Netherlands (Nederland)",
42838 "New Caledonia (Nouvelle-Calédonie)",
42873 "North Korea (조선 민주주의 인민 공화국)",
42878 "Northern Mariana Islands",
42894 "Pakistan (پاکستان)",
42904 "Palestine (فلسطين)",
42914 "Papua New Guinea",
42956 "Réunion (La Réunion)",
42962 "Romania (România)",
42978 "Saint Barthélemy",
42989 "Saint Kitts and Nevis",
42999 "Saint Martin (Saint-Martin (partie française))",
43005 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
43010 "Saint Vincent and the Grenadines",
43025 "São Tomé and Príncipe (São Tomé e Príncipe)",
43030 "Saudi Arabia (المملكة العربية السعودية)",
43035 "Senegal (Sénégal)",
43065 "Slovakia (Slovensko)",
43070 "Slovenia (Slovenija)",
43080 "Somalia (Soomaaliya)",
43090 "South Korea (대한민국)",
43095 "South Sudan (جنوب السودان)",
43105 "Sri Lanka (ශ්රී ලංකාව)",
43110 "Sudan (السودان)",
43120 "Svalbard and Jan Mayen",
43131 "Sweden (Sverige)",
43136 "Switzerland (Schweiz)",
43141 "Syria (سوريا)",
43186 "Trinidad and Tobago",
43191 "Tunisia (تونس)",
43196 "Turkey (Türkiye)",
43206 "Turks and Caicos Islands",
43216 "U.S. Virgin Islands",
43226 "Ukraine (Україна)",
43231 "United Arab Emirates (الإمارات العربية المتحدة)",
43253 "Uzbekistan (Oʻzbekiston)",
43263 "Vatican City (Città del Vaticano)",
43274 "Vietnam (Việt Nam)",
43279 "Wallis and Futuna (Wallis-et-Futuna)",
43284 "Western Sahara (الصحراء الغربية)",
43290 "Yemen (اليمن)",
43314 * This script refer to:
43315 * Title: International Telephone Input
43316 * Author: Jack O'Connor
43317 * Code version: v12.1.12
43318 * Availability: https://github.com/jackocnr/intl-tel-input.git
43322 * @class Roo.bootstrap.form.PhoneInput
43323 * @extends Roo.bootstrap.form.TriggerField
43324 * An input with International dial-code selection
43326 * @cfg {String} defaultDialCode default '+852'
43327 * @cfg {Array} preferedCountries default []
43330 * Create a new PhoneInput.
43331 * @param {Object} config Configuration options
43334 Roo.bootstrap.form.PhoneInput = function(config) {
43335 Roo.bootstrap.form.PhoneInput.superclass.constructor.call(this, config);
43338 Roo.extend(Roo.bootstrap.form.PhoneInput, Roo.bootstrap.form.TriggerField, {
43340 * @cfg {Roo.data.Store} store [required] The data store to which this combo is bound (defaults to undefined)
43342 listWidth: undefined,
43344 selectedClass: 'active',
43346 invalidClass : "has-warning",
43348 validClass: 'has-success',
43350 allowed: '0123456789',
43355 * @cfg {String} defaultDialCode The default dial code when initializing the input
43357 defaultDialCode: '+852',
43360 * @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
43362 preferedCountries: false,
43364 getAutoCreate : function()
43366 var data = Roo.bootstrap.form.PhoneInputData();
43367 var align = this.labelAlign || this.parentLabelAlign();
43370 this.allCountries = [];
43371 this.dialCodeMapping = [];
43373 for (var i = 0; i < data.length; i++) {
43375 this.allCountries[i] = {
43379 priority: c[3] || 0,
43380 areaCodes: c[4] || null
43382 this.dialCodeMapping[c[2]] = {
43385 priority: c[3] || 0,
43386 areaCodes: c[4] || null
43398 // type: 'number', -- do not use number - we get the flaky up/down arrows.
43399 maxlength: this.max_length,
43400 cls : 'form-control tel-input',
43401 autocomplete: 'new-password'
43404 var hiddenInput = {
43407 cls: 'hidden-tel-input'
43411 hiddenInput.name = this.name;
43414 if (this.disabled) {
43415 input.disabled = true;
43418 var flag_container = {
43435 cls: this.hasFeedback ? 'has-feedback' : '',
43441 cls: 'dial-code-holder',
43448 cls: 'roo-select2-container input-group',
43455 if (this.fieldLabel.length) {
43458 tooltip: 'This field is required'
43464 cls: 'control-label',
43470 html: this.fieldLabel
43473 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
43479 if(this.indicatorpos == 'right') {
43480 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
43487 if(align == 'left') {
43495 if(this.labelWidth > 12){
43496 label.style = "width: " + this.labelWidth + 'px';
43498 if(this.labelWidth < 13 && this.labelmd == 0){
43499 this.labelmd = this.labelWidth;
43501 if(this.labellg > 0){
43502 label.cls += ' col-lg-' + this.labellg;
43503 input.cls += ' col-lg-' + (12 - this.labellg);
43505 if(this.labelmd > 0){
43506 label.cls += ' col-md-' + this.labelmd;
43507 container.cls += ' col-md-' + (12 - this.labelmd);
43509 if(this.labelsm > 0){
43510 label.cls += ' col-sm-' + this.labelsm;
43511 container.cls += ' col-sm-' + (12 - this.labelsm);
43513 if(this.labelxs > 0){
43514 label.cls += ' col-xs-' + this.labelxs;
43515 container.cls += ' col-xs-' + (12 - this.labelxs);
43525 var settings = this;
43527 ['xs','sm','md','lg'].map(function(size){
43528 if (settings[size]) {
43529 cfg.cls += ' col-' + size + '-' + settings[size];
43533 this.store = new Roo.data.Store({
43534 proxy : new Roo.data.MemoryProxy({}),
43535 reader : new Roo.data.JsonReader({
43546 'name' : 'dialCode',
43550 'name' : 'priority',
43554 'name' : 'areaCodes',
43561 if(!this.preferedCountries) {
43562 this.preferedCountries = [
43569 var p = this.preferedCountries.reverse();
43572 for (var i = 0; i < p.length; i++) {
43573 for (var j = 0; j < this.allCountries.length; j++) {
43574 if(this.allCountries[j].iso2 == p[i]) {
43575 var t = this.allCountries[j];
43576 this.allCountries.splice(j,1);
43577 this.allCountries.unshift(t);
43583 this.store.proxy.data = {
43585 data: this.allCountries
43591 initEvents : function()
43594 Roo.bootstrap.form.PhoneInput.superclass.initEvents.call(this);
43596 this.indicator = this.indicatorEl();
43597 this.flag = this.flagEl();
43598 this.dialCodeHolder = this.dialCodeHolderEl();
43600 this.trigger = this.el.select('div.flag-box',true).first();
43601 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
43606 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
43607 _this.list.setWidth(lw);
43610 this.list.on('mouseover', this.onViewOver, this);
43611 this.list.on('mousemove', this.onViewMove, this);
43612 this.inputEl().on("keyup", this.onKeyUp, this);
43613 this.inputEl().on("keypress", this.onKeyPress, this);
43615 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
43617 this.view = new Roo.View(this.list, this.tpl, {
43618 singleSelect:true, store: this.store, selectedClass: this.selectedClass
43621 this.view.on('click', this.onViewClick, this);
43622 this.setValue(this.defaultDialCode);
43625 onTriggerClick : function(e)
43627 Roo.log('trigger click');
43632 if(this.isExpanded()){
43634 this.hasFocus = false;
43636 this.store.load({});
43637 this.hasFocus = true;
43642 isExpanded : function()
43644 return this.list.isVisible();
43647 collapse : function()
43649 if(!this.isExpanded()){
43653 Roo.get(document).un('mousedown', this.collapseIf, this);
43654 Roo.get(document).un('mousewheel', this.collapseIf, this);
43655 this.fireEvent('collapse', this);
43659 expand : function()
43663 if(this.isExpanded() || !this.hasFocus){
43667 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
43668 this.list.setWidth(lw);
43671 this.restrictHeight();
43673 Roo.get(document).on('mousedown', this.collapseIf, this);
43674 Roo.get(document).on('mousewheel', this.collapseIf, this);
43676 this.fireEvent('expand', this);
43679 restrictHeight : function()
43681 this.list.alignTo(this.inputEl(), this.listAlign);
43682 this.list.alignTo(this.inputEl(), this.listAlign);
43685 onViewOver : function(e, t)
43687 if(this.inKeyMode){
43690 var item = this.view.findItemFromChild(t);
43693 var index = this.view.indexOf(item);
43694 this.select(index, false);
43699 onViewClick : function(view, doFocus, el, e)
43701 var index = this.view.getSelectedIndexes()[0];
43703 var r = this.store.getAt(index);
43706 this.onSelect(r, index);
43708 if(doFocus !== false && !this.blockFocus){
43709 this.inputEl().focus();
43713 onViewMove : function(e, t)
43715 this.inKeyMode = false;
43718 select : function(index, scrollIntoView)
43720 this.selectedIndex = index;
43721 this.view.select(index);
43722 if(scrollIntoView !== false){
43723 var el = this.view.getNode(index);
43725 this.list.scrollChildIntoView(el, false);
43730 createList : function()
43732 this.list = Roo.get(document.body).createChild({
43734 cls: 'typeahead typeahead-long dropdown-menu tel-list',
43735 style: 'display:none'
43738 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
43741 collapseIf : function(e)
43743 var in_combo = e.within(this.el);
43744 var in_list = e.within(this.list);
43745 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
43747 if (in_combo || in_list || is_list) {
43753 onSelect : function(record, index)
43755 if(this.fireEvent('beforeselect', this, record, index) !== false){
43757 this.setFlagClass(record.data.iso2);
43758 this.setDialCode(record.data.dialCode);
43759 this.hasFocus = false;
43761 this.fireEvent('select', this, record, index);
43765 flagEl : function()
43767 var flag = this.el.select('div.flag',true).first();
43774 dialCodeHolderEl : function()
43776 var d = this.el.select('input.dial-code-holder',true).first();
43783 setDialCode : function(v)
43785 this.dialCodeHolder.dom.value = '+'+v;
43788 setFlagClass : function(n)
43790 this.flag.dom.className = 'flag '+n;
43793 getValue : function()
43795 var v = this.inputEl().getValue();
43796 if(this.dialCodeHolder) {
43797 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
43802 setValue : function(v)
43804 var d = this.getDialCode(v);
43806 //invalid dial code
43807 if(v.length == 0 || !d || d.length == 0) {
43809 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
43810 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
43816 this.setFlagClass(this.dialCodeMapping[d].iso2);
43817 this.setDialCode(d);
43818 this.inputEl().dom.value = v.replace('+'+d,'');
43819 this.hiddenEl().dom.value = this.getValue();
43824 getDialCode : function(v)
43828 if (v.length == 0) {
43829 return this.dialCodeHolder.dom.value;
43833 if (v.charAt(0) != "+") {
43836 var numericChars = "";
43837 for (var i = 1; i < v.length; i++) {
43838 var c = v.charAt(i);
43841 if (this.dialCodeMapping[numericChars]) {
43842 dialCode = v.substr(1, i);
43844 if (numericChars.length == 4) {
43854 this.setValue(this.defaultDialCode);
43858 hiddenEl : function()
43860 return this.el.select('input.hidden-tel-input',true).first();
43863 // after setting val
43864 onKeyUp : function(e){
43865 this.setValue(this.getValue());
43868 onKeyPress : function(e){
43869 if(this.allowed.indexOf(String.fromCharCode(e.getCharCode())) === -1){
43876 * @class Roo.bootstrap.form.MoneyField
43877 * @extends Roo.bootstrap.form.ComboBox
43878 * Bootstrap MoneyField class
43881 * Create a new MoneyField.
43882 * @param {Object} config Configuration options
43885 Roo.bootstrap.form.MoneyField = function(config) {
43887 Roo.bootstrap.form.MoneyField.superclass.constructor.call(this, config);
43891 Roo.extend(Roo.bootstrap.form.MoneyField, Roo.bootstrap.form.ComboBox, {
43894 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
43896 allowDecimals : true,
43898 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
43900 decimalSeparator : ".",
43902 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
43904 decimalPrecision : 0,
43906 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
43908 allowNegative : true,
43910 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
43914 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
43916 minValue : Number.NEGATIVE_INFINITY,
43918 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
43920 maxValue : Number.MAX_VALUE,
43922 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
43924 minText : "The minimum value for this field is {0}",
43926 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
43928 maxText : "The maximum value for this field is {0}",
43930 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
43931 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
43933 nanText : "{0} is not a valid number",
43935 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
43939 * @cfg {String} defaults currency of the MoneyField
43940 * value should be in lkey
43942 defaultCurrency : false,
43944 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
43946 thousandsDelimiter : false,
43948 * @cfg {Number} max_length Maximum input field length allowed (defaults to Number.MAX_VALUE)
43957 * @cfg {Roo.data.Store} store Store to lookup currency??
43961 getAutoCreate : function()
43963 var align = this.labelAlign || this.parentLabelAlign();
43975 cls : 'form-control roo-money-amount-input',
43976 autocomplete: 'new-password'
43979 var hiddenInput = {
43983 cls: 'hidden-number-input'
43986 if(this.max_length) {
43987 input.maxlength = this.max_length;
43991 hiddenInput.name = this.name;
43994 if (this.disabled) {
43995 input.disabled = true;
43998 var clg = 12 - this.inputlg;
43999 var cmd = 12 - this.inputmd;
44000 var csm = 12 - this.inputsm;
44001 var cxs = 12 - this.inputxs;
44005 cls : 'row roo-money-field',
44009 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
44013 cls: 'roo-select2-container input-group',
44017 cls : 'form-control roo-money-currency-input',
44018 autocomplete: 'new-password',
44020 name : this.currencyName
44024 cls : 'input-group-addon',
44038 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
44042 cls: this.hasFeedback ? 'has-feedback' : '',
44053 if (this.fieldLabel.length) {
44056 tooltip: 'This field is required'
44062 cls: 'control-label',
44068 html: this.fieldLabel
44071 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
44077 if(this.indicatorpos == 'right') {
44078 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
44085 if(align == 'left') {
44093 if(this.labelWidth > 12){
44094 label.style = "width: " + this.labelWidth + 'px';
44096 if(this.labelWidth < 13 && this.labelmd == 0){
44097 this.labelmd = this.labelWidth;
44099 if(this.labellg > 0){
44100 label.cls += ' col-lg-' + this.labellg;
44101 input.cls += ' col-lg-' + (12 - this.labellg);
44103 if(this.labelmd > 0){
44104 label.cls += ' col-md-' + this.labelmd;
44105 container.cls += ' col-md-' + (12 - this.labelmd);
44107 if(this.labelsm > 0){
44108 label.cls += ' col-sm-' + this.labelsm;
44109 container.cls += ' col-sm-' + (12 - this.labelsm);
44111 if(this.labelxs > 0){
44112 label.cls += ' col-xs-' + this.labelxs;
44113 container.cls += ' col-xs-' + (12 - this.labelxs);
44124 var settings = this;
44126 ['xs','sm','md','lg'].map(function(size){
44127 if (settings[size]) {
44128 cfg.cls += ' col-' + size + '-' + settings[size];
44135 initEvents : function()
44137 this.indicator = this.indicatorEl();
44139 this.initCurrencyEvent();
44141 this.initNumberEvent();
44144 initCurrencyEvent : function()
44147 throw "can not find store for combo";
44150 this.store = Roo.factory(this.store, Roo.data);
44151 this.store.parent = this;
44155 this.triggerEl = this.el.select('.input-group-addon', true).first();
44157 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
44162 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
44163 _this.list.setWidth(lw);
44166 this.list.on('mouseover', this.onViewOver, this);
44167 this.list.on('mousemove', this.onViewMove, this);
44168 this.list.on('scroll', this.onViewScroll, this);
44171 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
44174 this.view = new Roo.View(this.list, this.tpl, {
44175 singleSelect:true, store: this.store, selectedClass: this.selectedClass
44178 this.view.on('click', this.onViewClick, this);
44180 this.store.on('beforeload', this.onBeforeLoad, this);
44181 this.store.on('load', this.onLoad, this);
44182 this.store.on('loadexception', this.onLoadException, this);
44184 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
44185 "up" : function(e){
44186 this.inKeyMode = true;
44190 "down" : function(e){
44191 if(!this.isExpanded()){
44192 this.onTriggerClick();
44194 this.inKeyMode = true;
44199 "enter" : function(e){
44202 if(this.fireEvent("specialkey", this, e)){
44203 this.onViewClick(false);
44209 "esc" : function(e){
44213 "tab" : function(e){
44216 if(this.fireEvent("specialkey", this, e)){
44217 this.onViewClick(false);
44225 doRelay : function(foo, bar, hname){
44226 if(hname == 'down' || this.scope.isExpanded()){
44227 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
44235 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
44239 initNumberEvent : function(e)
44241 this.inputEl().on("keydown" , this.fireKey, this);
44242 this.inputEl().on("focus", this.onFocus, this);
44243 this.inputEl().on("blur", this.onBlur, this);
44245 this.inputEl().relayEvent('keyup', this);
44247 if(this.indicator){
44248 this.indicator.addClass('invisible');
44251 this.originalValue = this.getValue();
44253 if(this.validationEvent == 'keyup'){
44254 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
44255 this.inputEl().on('keyup', this.filterValidation, this);
44257 else if(this.validationEvent !== false){
44258 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
44261 if(this.selectOnFocus){
44262 this.on("focus", this.preFocus, this);
44265 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
44266 this.inputEl().on("keypress", this.filterKeys, this);
44268 this.inputEl().relayEvent('keypress', this);
44271 var allowed = "0123456789";
44273 if(this.allowDecimals){
44274 allowed += this.decimalSeparator;
44277 if(this.allowNegative){
44281 if(this.thousandsDelimiter) {
44285 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
44287 var keyPress = function(e){
44289 var k = e.getKey();
44291 var c = e.getCharCode();
44294 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
44295 allowed.indexOf(String.fromCharCode(c)) === -1
44301 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
44305 if(allowed.indexOf(String.fromCharCode(c)) === -1){
44310 this.inputEl().on("keypress", keyPress, this);
44314 onTriggerClick : function(e)
44321 this.loadNext = false;
44323 if(this.isExpanded()){
44328 this.hasFocus = true;
44330 if(this.triggerAction == 'all') {
44331 this.doQuery(this.allQuery, true);
44335 this.doQuery(this.getRawValue());
44338 getCurrency : function()
44340 var v = this.currencyEl().getValue();
44345 restrictHeight : function()
44347 this.list.alignTo(this.currencyEl(), this.listAlign);
44348 this.list.alignTo(this.currencyEl(), this.listAlign);
44351 onViewClick : function(view, doFocus, el, e)
44353 var index = this.view.getSelectedIndexes()[0];
44355 var r = this.store.getAt(index);
44358 this.onSelect(r, index);
44362 onSelect : function(record, index){
44364 if(this.fireEvent('beforeselect', this, record, index) !== false){
44366 this.setFromCurrencyData(index > -1 ? record.data : false);
44370 this.fireEvent('select', this, record, index);
44374 setFromCurrencyData : function(o)
44378 this.lastCurrency = o;
44380 if (this.currencyField) {
44381 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
44383 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
44386 this.lastSelectionText = currency;
44388 //setting default currency
44389 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
44390 this.setCurrency(this.defaultCurrency);
44394 this.setCurrency(currency);
44397 setFromData : function(o)
44401 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
44403 this.setFromCurrencyData(c);
44408 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
44410 Roo.log('no value set for '+ (this.name ? this.name : this.id));
44413 this.setValue(value);
44417 setCurrency : function(v)
44419 this.currencyValue = v;
44422 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
44427 setValue : function(v)
44429 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
44435 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
44437 this.inputEl().dom.value = (v == '') ? '' :
44438 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
44440 if(!this.allowZero && v === '0') {
44441 this.hiddenEl().dom.value = '';
44442 this.inputEl().dom.value = '';
44449 getRawValue : function()
44451 var v = this.inputEl().getValue();
44456 getValue : function()
44458 return this.fixPrecision(this.parseValue(this.getRawValue()));
44461 parseValue : function(value)
44463 if(this.thousandsDelimiter) {
44465 r = new RegExp(",", "g");
44466 value = value.replace(r, "");
44469 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
44470 return isNaN(value) ? '' : value;
44474 fixPrecision : function(value)
44476 if(this.thousandsDelimiter) {
44478 r = new RegExp(",", "g");
44479 value = value.replace(r, "");
44482 var nan = isNaN(value);
44484 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
44485 return nan ? '' : value;
44487 return parseFloat(value).toFixed(this.decimalPrecision);
44490 decimalPrecisionFcn : function(v)
44492 return Math.floor(v);
44495 validateValue : function(value)
44497 if(!Roo.bootstrap.form.MoneyField.superclass.validateValue.call(this, value)){
44501 var num = this.parseValue(value);
44504 this.markInvalid(String.format(this.nanText, value));
44508 if(num < this.minValue){
44509 this.markInvalid(String.format(this.minText, this.minValue));
44513 if(num > this.maxValue){
44514 this.markInvalid(String.format(this.maxText, this.maxValue));
44521 validate : function()
44523 if(this.disabled || this.allowBlank){
44528 var currency = this.getCurrency();
44530 if(this.validateValue(this.getRawValue()) && currency.length){
44535 this.markInvalid();
44539 getName: function()
44544 beforeBlur : function()
44550 var v = this.parseValue(this.getRawValue());
44557 onBlur : function()
44561 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
44562 //this.el.removeClass(this.focusClass);
44565 this.hasFocus = false;
44567 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
44571 var v = this.getValue();
44573 if(String(v) !== String(this.startValue)){
44574 this.fireEvent('change', this, v, this.startValue);
44577 this.fireEvent("blur", this);
44580 inputEl : function()
44582 return this.el.select('.roo-money-amount-input', true).first();
44585 currencyEl : function()
44587 return this.el.select('.roo-money-currency-input', true).first();
44590 hiddenEl : function()
44592 return this.el.select('input.hidden-number-input',true).first();
44596 * @class Roo.bootstrap.BezierSignature
44597 * @extends Roo.bootstrap.Component
44598 * Bootstrap BezierSignature class
44599 * This script refer to:
44600 * Title: Signature Pad
44602 * Availability: https://github.com/szimek/signature_pad
44605 * Create a new BezierSignature
44606 * @param {Object} config The config object
44609 Roo.bootstrap.BezierSignature = function(config){
44610 Roo.bootstrap.BezierSignature.superclass.constructor.call(this, config);
44616 Roo.extend(Roo.bootstrap.BezierSignature, Roo.bootstrap.Component,
44623 mouse_btn_down: true,
44626 * @cfg {int} canvas height
44628 canvas_height: '200px',
44631 * @cfg {float|function} Radius of a single dot.
44636 * @cfg {float} Minimum width of a line. Defaults to 0.5.
44641 * @cfg {float} Maximum width of a line. Defaults to 2.5.
44646 * @cfg {integer} Draw the next point at most once per every x milliseconds. Set it to 0 to turn off throttling. Defaults to 16.
44651 * @cfg {integer} Add the next point only if the previous one is farther than x pixels. Defaults to 5.
44656 * @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.
44658 bg_color: 'rgba(0, 0, 0, 0)',
44661 * @cfg {string} Color used to draw the lines. Can be any color format accepted by context.fillStyle. Defaults to "black".
44663 dot_color: 'black',
44666 * @cfg {float} Weight used to modify new velocity based on the previous velocity. Defaults to 0.7.
44668 velocity_filter_weight: 0.7,
44671 * @cfg {function} Callback when stroke begin.
44676 * @cfg {function} Callback when stroke end.
44680 getAutoCreate : function()
44682 var cls = 'roo-signature column';
44685 cls += ' ' + this.cls;
44695 for(var i = 0; i < col_sizes.length; i++) {
44696 if(this[col_sizes[i]]) {
44697 cls += " col-"+col_sizes[i]+"-"+this[col_sizes[i]];
44707 cls: 'roo-signature-body',
44711 cls: 'roo-signature-body-canvas',
44712 height: this.canvas_height,
44713 width: this.canvas_width
44720 style: 'display: none'
44728 initEvents: function()
44730 Roo.bootstrap.BezierSignature.superclass.initEvents.call(this);
44732 var canvas = this.canvasEl();
44734 // mouse && touch event swapping...
44735 canvas.dom.style.touchAction = 'none';
44736 canvas.dom.style.msTouchAction = 'none';
44738 this.mouse_btn_down = false;
44739 canvas.on('mousedown', this._handleMouseDown, this);
44740 canvas.on('mousemove', this._handleMouseMove, this);
44741 Roo.select('html').first().on('mouseup', this._handleMouseUp, this);
44743 if (window.PointerEvent) {
44744 canvas.on('pointerdown', this._handleMouseDown, this);
44745 canvas.on('pointermove', this._handleMouseMove, this);
44746 Roo.select('html').first().on('pointerup', this._handleMouseUp, this);
44749 if ('ontouchstart' in window) {
44750 canvas.on('touchstart', this._handleTouchStart, this);
44751 canvas.on('touchmove', this._handleTouchMove, this);
44752 canvas.on('touchend', this._handleTouchEnd, this);
44755 Roo.EventManager.onWindowResize(this.resize, this, true);
44757 // file input event
44758 this.fileEl().on('change', this.uploadImage, this);
44765 resize: function(){
44767 var canvas = this.canvasEl().dom;
44768 var ctx = this.canvasElCtx();
44769 var img_data = false;
44771 if(canvas.width > 0) {
44772 var img_data = ctx.getImageData(0, 0, canvas.width, canvas.height);
44774 // setting canvas width will clean img data
44777 var style = window.getComputedStyle ?
44778 getComputedStyle(this.el.dom, null) : this.el.dom.currentStyle;
44780 var padding_left = parseInt(style.paddingLeft) || 0;
44781 var padding_right = parseInt(style.paddingRight) || 0;
44783 canvas.width = this.el.dom.clientWidth - padding_left - padding_right;
44786 ctx.putImageData(img_data, 0, 0);
44790 _handleMouseDown: function(e)
44792 if (e.browserEvent.which === 1) {
44793 this.mouse_btn_down = true;
44794 this.strokeBegin(e);
44798 _handleMouseMove: function (e)
44800 if (this.mouse_btn_down) {
44801 this.strokeMoveUpdate(e);
44805 _handleMouseUp: function (e)
44807 if (e.browserEvent.which === 1 && this.mouse_btn_down) {
44808 this.mouse_btn_down = false;
44813 _handleTouchStart: function (e) {
44815 e.preventDefault();
44816 if (e.browserEvent.targetTouches.length === 1) {
44817 // var touch = e.browserEvent.changedTouches[0];
44818 // this.strokeBegin(touch);
44820 this.strokeBegin(e); // assume e catching the correct xy...
44824 _handleTouchMove: function (e) {
44825 e.preventDefault();
44826 // var touch = event.targetTouches[0];
44827 // _this._strokeMoveUpdate(touch);
44828 this.strokeMoveUpdate(e);
44831 _handleTouchEnd: function (e) {
44832 var wasCanvasTouched = e.target === this.canvasEl().dom;
44833 if (wasCanvasTouched) {
44834 e.preventDefault();
44835 // var touch = event.changedTouches[0];
44836 // _this._strokeEnd(touch);
44841 reset: function () {
44842 this._lastPoints = [];
44843 this._lastVelocity = 0;
44844 this._lastWidth = (this.min_width + this.max_width) / 2;
44845 this.canvasElCtx().fillStyle = this.dot_color;
44848 strokeMoveUpdate: function(e)
44850 this.strokeUpdate(e);
44852 if (this.throttle) {
44853 this.throttleStroke(this.strokeUpdate, this.throttle);
44856 this.strokeUpdate(e);
44860 strokeBegin: function(e)
44862 var newPointGroup = {
44863 color: this.dot_color,
44867 if (typeof this.onBegin === 'function') {
44871 this.curve_data.push(newPointGroup);
44873 this.strokeUpdate(e);
44876 strokeUpdate: function(e)
44878 var rect = this.canvasEl().dom.getBoundingClientRect();
44879 var point = new this.Point(e.xy[0] - rect.left, e.xy[1] - rect.top, new Date().getTime());
44880 var lastPointGroup = this.curve_data[this.curve_data.length - 1];
44881 var lastPoints = lastPointGroup.points;
44882 var lastPoint = lastPoints.length > 0 && lastPoints[lastPoints.length - 1];
44883 var isLastPointTooClose = lastPoint
44884 ? point.distanceTo(lastPoint) <= this.min_distance
44886 var color = lastPointGroup.color;
44887 if (!lastPoint || !(lastPoint && isLastPointTooClose)) {
44888 var curve = this.addPoint(point);
44890 this.drawDot({color: color, point: point});
44893 this.drawCurve({color: color, curve: curve});
44903 strokeEnd: function(e)
44905 this.strokeUpdate(e);
44906 if (typeof this.onEnd === 'function') {
44911 addPoint: function (point) {
44912 var _lastPoints = this._lastPoints;
44913 _lastPoints.push(point);
44914 if (_lastPoints.length > 2) {
44915 if (_lastPoints.length === 3) {
44916 _lastPoints.unshift(_lastPoints[0]);
44918 var widths = this.calculateCurveWidths(_lastPoints[1], _lastPoints[2]);
44919 var curve = this.Bezier.fromPoints(_lastPoints, widths, this);
44920 _lastPoints.shift();
44926 calculateCurveWidths: function (startPoint, endPoint) {
44927 var velocity = this.velocity_filter_weight * endPoint.velocityFrom(startPoint) +
44928 (1 - this.velocity_filter_weight) * this._lastVelocity;
44930 var newWidth = Math.max(this.max_width / (velocity + 1), this.min_width);
44933 start: this._lastWidth
44936 this._lastVelocity = velocity;
44937 this._lastWidth = newWidth;
44941 drawDot: function (_a) {
44942 var color = _a.color, point = _a.point;
44943 var ctx = this.canvasElCtx();
44944 var width = typeof this.dot_size === 'function' ? this.dot_size() : this.dot_size;
44946 this.drawCurveSegment(point.x, point.y, width);
44948 ctx.fillStyle = color;
44952 drawCurve: function (_a) {
44953 var color = _a.color, curve = _a.curve;
44954 var ctx = this.canvasElCtx();
44955 var widthDelta = curve.endWidth - curve.startWidth;
44956 var drawSteps = Math.floor(curve.length()) * 2;
44958 ctx.fillStyle = color;
44959 for (var i = 0; i < drawSteps; i += 1) {
44960 var t = i / drawSteps;
44966 var x = uuu * curve.startPoint.x;
44967 x += 3 * uu * t * curve.control1.x;
44968 x += 3 * u * tt * curve.control2.x;
44969 x += ttt * curve.endPoint.x;
44970 var y = uuu * curve.startPoint.y;
44971 y += 3 * uu * t * curve.control1.y;
44972 y += 3 * u * tt * curve.control2.y;
44973 y += ttt * curve.endPoint.y;
44974 var width = curve.startWidth + ttt * widthDelta;
44975 this.drawCurveSegment(x, y, width);
44981 drawCurveSegment: function (x, y, width) {
44982 var ctx = this.canvasElCtx();
44984 ctx.arc(x, y, width, 0, 2 * Math.PI, false);
44985 this.is_empty = false;
44990 var ctx = this.canvasElCtx();
44991 var canvas = this.canvasEl().dom;
44992 ctx.fillStyle = this.bg_color;
44993 ctx.clearRect(0, 0, canvas.width, canvas.height);
44994 ctx.fillRect(0, 0, canvas.width, canvas.height);
44995 this.curve_data = [];
44997 this.is_empty = true;
45002 return this.el.select('input',true).first();
45005 canvasEl: function()
45007 return this.el.select('canvas',true).first();
45010 canvasElCtx: function()
45012 return this.el.select('canvas',true).first().dom.getContext('2d');
45015 getImage: function(type)
45017 if(this.is_empty) {
45022 return this.canvasEl().dom.toDataURL('image/'+type, 1);
45025 drawFromImage: function(img_src)
45027 var img = new Image();
45029 img.onload = function(){
45030 this.canvasElCtx().drawImage(img, 0, 0);
45035 this.is_empty = false;
45038 selectImage: function()
45040 this.fileEl().dom.click();
45043 uploadImage: function(e)
45045 var reader = new FileReader();
45047 reader.onload = function(e){
45048 var img = new Image();
45049 img.onload = function(){
45051 this.canvasElCtx().drawImage(img, 0, 0);
45053 img.src = e.target.result;
45056 reader.readAsDataURL(e.target.files[0]);
45059 // Bezier Point Constructor
45060 Point: (function () {
45061 function Point(x, y, time) {
45064 this.time = time || Date.now();
45066 Point.prototype.distanceTo = function (start) {
45067 return Math.sqrt(Math.pow(this.x - start.x, 2) + Math.pow(this.y - start.y, 2));
45069 Point.prototype.equals = function (other) {
45070 return this.x === other.x && this.y === other.y && this.time === other.time;
45072 Point.prototype.velocityFrom = function (start) {
45073 return this.time !== start.time
45074 ? this.distanceTo(start) / (this.time - start.time)
45081 // Bezier Constructor
45082 Bezier: (function () {
45083 function Bezier(startPoint, control2, control1, endPoint, startWidth, endWidth) {
45084 this.startPoint = startPoint;
45085 this.control2 = control2;
45086 this.control1 = control1;
45087 this.endPoint = endPoint;
45088 this.startWidth = startWidth;
45089 this.endWidth = endWidth;
45091 Bezier.fromPoints = function (points, widths, scope) {
45092 var c2 = this.calculateControlPoints(points[0], points[1], points[2], scope).c2;
45093 var c3 = this.calculateControlPoints(points[1], points[2], points[3], scope).c1;
45094 return new Bezier(points[1], c2, c3, points[2], widths.start, widths.end);
45096 Bezier.calculateControlPoints = function (s1, s2, s3, scope) {
45097 var dx1 = s1.x - s2.x;
45098 var dy1 = s1.y - s2.y;
45099 var dx2 = s2.x - s3.x;
45100 var dy2 = s2.y - s3.y;
45101 var m1 = { x: (s1.x + s2.x) / 2.0, y: (s1.y + s2.y) / 2.0 };
45102 var m2 = { x: (s2.x + s3.x) / 2.0, y: (s2.y + s3.y) / 2.0 };
45103 var l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
45104 var l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
45105 var dxm = m1.x - m2.x;
45106 var dym = m1.y - m2.y;
45107 var k = l2 / (l1 + l2);
45108 var cm = { x: m2.x + dxm * k, y: m2.y + dym * k };
45109 var tx = s2.x - cm.x;
45110 var ty = s2.y - cm.y;
45112 c1: new scope.Point(m1.x + tx, m1.y + ty),
45113 c2: new scope.Point(m2.x + tx, m2.y + ty)
45116 Bezier.prototype.length = function () {
45121 for (var i = 0; i <= steps; i += 1) {
45123 var cx = this.point(t, this.startPoint.x, this.control1.x, this.control2.x, this.endPoint.x);
45124 var cy = this.point(t, this.startPoint.y, this.control1.y, this.control2.y, this.endPoint.y);
45126 var xdiff = cx - px;
45127 var ydiff = cy - py;
45128 length += Math.sqrt(xdiff * xdiff + ydiff * ydiff);
45135 Bezier.prototype.point = function (t, start, c1, c2, end) {
45136 return (start * (1.0 - t) * (1.0 - t) * (1.0 - t))
45137 + (3.0 * c1 * (1.0 - t) * (1.0 - t) * t)
45138 + (3.0 * c2 * (1.0 - t) * t * t)
45139 + (end * t * t * t);
45144 throttleStroke: function(fn, wait) {
45145 if (wait === void 0) { wait = 250; }
45147 var timeout = null;
45151 var later = function () {
45152 previous = Date.now();
45154 result = fn.apply(storedContext, storedArgs);
45156 storedContext = null;
45160 return function wrapper() {
45162 for (var _i = 0; _i < arguments.length; _i++) {
45163 args[_i] = arguments[_i];
45165 var now = Date.now();
45166 var remaining = wait - (now - previous);
45167 storedContext = this;
45169 if (remaining <= 0 || remaining > wait) {
45171 clearTimeout(timeout);
45175 result = fn.apply(storedContext, storedArgs);
45177 storedContext = null;
45181 else if (!timeout) {
45182 timeout = window.setTimeout(later, remaining);
45192 // old names for form elements
45193 Roo.bootstrap.Form = Roo.bootstrap.form.Form;
45194 Roo.bootstrap.Input = Roo.bootstrap.form.Input;
45195 Roo.bootstrap.TextArea = Roo.bootstrap.form.TextArea;
45196 Roo.bootstrap.TriggerField = Roo.bootstrap.form.TriggerField;
45197 Roo.bootstrap.ComboBox = Roo.bootstrap.form.ComboBox;
45198 Roo.bootstrap.DateField = Roo.bootstrap.form.DateField;
45199 Roo.bootstrap.TimeField = Roo.bootstrap.form.TimeField;
45200 Roo.bootstrap.MonthField = Roo.bootstrap.form.MonthField;
45201 Roo.bootstrap.CheckBox = Roo.bootstrap.form.CheckBox;
45202 Roo.bootstrap.Radio = Roo.bootstrap.form.Radio;
45203 Roo.bootstrap.RadioSet = Roo.bootstrap.form.RadioSet;
45204 Roo.bootstrap.SecurePass = Roo.bootstrap.form.SecurePass;
45205 Roo.bootstrap.FieldLabel = Roo.bootstrap.form.FieldLabel;
45206 Roo.bootstrap.DateSplitField= Roo.bootstrap.form.DateSplitField;
45207 Roo.bootstrap.NumberField = Roo.bootstrap.form.NumberField;
45208 Roo.bootstrap.PhoneInput = Roo.bootstrap.form.PhoneInput;
45209 Roo.bootstrap.PhoneInputData= Roo.bootstrap.form.PhoneInputData;
45210 Roo.bootstrap.MoneyField = Roo.bootstrap.form.MoneyField;
45211 Roo.bootstrap.HtmlEditor = Roo.bootstrap.form.HtmlEditor;
45212 Roo.bootstrap.HtmlEditor.ToolbarStandard = Roo.bootstrap.form.HtmlEditorToolbarStandard;
45213 Roo.bootstrap.Markdown = Roo.bootstrap.form.Markdown;
45214 Roo.bootstrap.CardUploader = Roo.bootstrap.form.CardUploader;// depricated.
45215 Roo.bootstrap.Navbar = Roo.bootstrap.nav.Bar;
45216 Roo.bootstrap.NavGroup = Roo.bootstrap.nav.Group;
45217 Roo.bootstrap.NavHeaderbar = Roo.bootstrap.nav.Headerbar;
45218 Roo.bootstrap.NavItem = Roo.bootstrap.nav.Item;
45220 Roo.bootstrap.NavProgressBar = Roo.bootstrap.nav.ProgressBar;
45221 Roo.bootstrap.NavProgressBarItem = Roo.bootstrap.nav.ProgressBarItem;
45223 Roo.bootstrap.NavSidebar = Roo.bootstrap.nav.Sidebar;
45224 Roo.bootstrap.NavSidebarItem = Roo.bootstrap.nav.SidebarItem;
45226 Roo.bootstrap.NavSimplebar = Roo.bootstrap.nav.Simplebar;// deprciated
45227 Roo.bootstrap.Menu = Roo.bootstrap.menu.Menu;
45228 Roo.bootstrap.MenuItem = Roo.bootstrap.menu.Item;
45229 Roo.bootstrap.MenuSeparator = Roo.bootstrap.menu.Separator