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;
19 * Ext JS Library 1.1.1
20 * Copyright(c) 2006-2007, Ext JS, LLC.
22 * Originally Released Under LGPL - original licence link has changed is not relivant.
25 * <script type="text/javascript">
31 * Simple class that can provide a shadow effect for any element. Note that the element MUST be absolutely positioned,
32 * and the shadow does not provide any shimming. This should be used only in simple cases -- for more advanced
33 * functionality that can also provide the same shadow effect, see the {@link Roo.Layer} class.
36 * @param {Object} config The config object
38 Roo.Shadow = function(config){
39 Roo.apply(this, config);
40 if(typeof this.mode != "string"){
41 this.mode = this.defaultMode;
43 var o = this.offset, a = {h: 0};
44 var rad = Math.floor(this.offset/2);
45 switch(this.mode.toLowerCase()){ // all this hideous nonsense calculates the various offsets for shadows
51 a.l -= this.offset + rad;
52 a.t -= this.offset + rad;
63 a.l -= (this.offset - rad);
64 a.t -= this.offset + rad;
66 a.w -= (this.offset - rad)*2;
77 a.l -= (this.offset - rad);
78 a.t -= (this.offset - rad);
80 a.w -= (this.offset + rad + 1);
81 a.h -= (this.offset + rad);
90 Roo.Shadow.prototype = {
93 * The shadow display mode. Supports the following options:<br />
94 * sides: Shadow displays on both sides and bottom only<br />
95 * frame: Shadow displays equally on all four sides<br />
96 * drop: Traditional bottom-right drop shadow (default)
100 * @cfg {String} offset
101 * The number of pixels to offset the shadow from the element (defaults to 4)
109 * Displays the shadow under the target element
110 * @param {String/HTMLElement/Element} targetEl The id or element under which the shadow should display
112 show : function(target){
113 target = Roo.get(target);
115 this.el = Roo.Shadow.Pool.pull();
116 if(this.el.dom.nextSibling != target.dom){
117 this.el.insertBefore(target);
120 this.el.setStyle("z-index", this.zIndex || parseInt(target.getStyle("z-index"), 10)-1);
122 this.el.dom.style.filter="progid:DXImageTransform.Microsoft.alpha(opacity=50) progid:DXImageTransform.Microsoft.Blur(pixelradius="+(this.offset)+")";
125 target.getLeft(true),
130 this.el.dom.style.display = "block";
134 * Returns true if the shadow is visible, else false
136 isVisible : function(){
137 return this.el ? true : false;
141 * Direct alignment when values are already available. Show must be called at least once before
142 * calling this method to ensure it is initialized.
143 * @param {Number} left The target element left position
144 * @param {Number} top The target element top position
145 * @param {Number} width The target element width
146 * @param {Number} height The target element height
148 realign : function(l, t, w, h){
152 var a = this.adjusts, d = this.el.dom, s = d.style;
154 s.left = (l+a.l)+"px";
155 s.top = (t+a.t)+"px";
156 var sw = (w+a.w), sh = (h+a.h), sws = sw +"px", shs = sh + "px";
158 if(s.width != sws || s.height != shs){
162 var cn = d.childNodes;
163 var sww = Math.max(0, (sw-12))+"px";
164 cn[0].childNodes[1].style.width = sww;
165 cn[1].childNodes[1].style.width = sww;
166 cn[2].childNodes[1].style.width = sww;
167 cn[1].style.height = Math.max(0, (sh-12))+"px";
177 this.el.dom.style.display = "none";
178 Roo.Shadow.Pool.push(this.el);
184 * Adjust the z-index of this shadow
185 * @param {Number} zindex The new z-index
187 setZIndex : function(z){
190 this.el.setStyle("z-index", z);
195 // Private utility class that manages the internal Shadow cache
196 Roo.Shadow.Pool = function(){
198 var markup = Roo.isIE ?
199 '<div class="x-ie-shadow"></div>' :
200 '<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>';
205 sh = Roo.get(Roo.DomHelper.insertHtml("beforeBegin", document.body.firstChild, markup));
206 sh.autoBoxAdjust = false;
218 * base class for bootstrap elements.
222 Roo.bootstrap = Roo.bootstrap || {};
224 * @class Roo.bootstrap.Component
225 * @extends Roo.Component
227 * @children Roo.bootstrap.Component
228 * Bootstrap Component base class
229 * @cfg {String} cls css class
230 * @cfg {String} style any extra css
231 * @cfg {Object} xattr extra attributes to add to 'element' (used by builder to store stuff.)
232 * @cfg {Boolean} can_build_overlaid True if element can be rebuild from a HTML page
233 * @cfg {string} dataId cutomer id
234 * @cfg {string} name Specifies name attribute
235 * @cfg {string} tooltip Text for the tooltip
236 * @cfg {string} container_method method to fetch parents container element (used by NavHeaderbar - getHeaderChildContainer)
237 * @cfg {string|object} visibilityEl (el|parent) What element to use for visibility (@see getVisibilityEl())
240 * Do not use directly - it does not do anything..
241 * @param {Object} config The config object
246 Roo.bootstrap.Component = function(config){
247 Roo.bootstrap.Component.superclass.constructor.call(this, config);
251 * @event childrenrendered
252 * Fires when the children have been rendered..
253 * @param {Roo.bootstrap.Component} this
255 "childrenrendered" : true
264 Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent, {
267 allowDomMove : false, // to stop relocations in parent onRender...
277 * Initialize Events for the element
279 initEvents : function() { },
285 can_build_overlaid : true,
287 container_method : false,
294 // returns the parent component..
295 return Roo.ComponentMgr.get(this.parentId)
301 onRender : function(ct, position)
303 // Roo.log("Call onRender: " + this.xtype);
305 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
308 if (this.el.attr('xtype')) {
309 this.el.attr('xtypex', this.el.attr('xtype'));
310 this.el.dom.removeAttribute('xtype');
320 var cfg = Roo.apply({}, this.getAutoCreate());
322 cfg.id = this.id || Roo.id();
324 // fill in the extra attributes
325 if (this.xattr && typeof(this.xattr) =='object') {
326 for (var i in this.xattr) {
327 cfg[i] = this.xattr[i];
332 cfg.dataId = this.dataId;
336 cfg.cls = (typeof(cfg.cls) == 'undefined' ? this.cls : cfg.cls) + ' ' + this.cls;
339 if (this.style) { // fixme needs to support more complex style data.
340 cfg.style = (typeof(cfg.style) == 'undefined' ? this.style : cfg.style) + '; ' + this.style;
344 cfg.name = this.name;
347 this.el = ct.createChild(cfg, position);
350 this.tooltipEl().attr('tooltip', this.tooltip);
353 if(this.tabIndex !== undefined){
354 this.el.dom.setAttribute('tabIndex', this.tabIndex);
361 * Fetch the element to add children to
362 * @return {Roo.Element} defaults to this.el
364 getChildContainer : function()
368 getDocumentBody : function() // used by menus - as they are attached to the body so zIndexes work
370 return Roo.get(document.body);
374 * Fetch the element to display the tooltip on.
375 * @return {Roo.Element} defaults to this.el
377 tooltipEl : function()
382 addxtype : function(tree,cntr)
386 cn = Roo.factory(tree);
387 //Roo.log(['addxtype', cn]);
389 cn.parentType = this.xtype; //??
390 cn.parentId = this.id;
392 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
393 if (typeof(cn.container_method) == 'string') {
394 cntr = cn.container_method;
398 var has_flexy_each = (typeof(tree['flexy:foreach']) != 'undefined');
400 var has_flexy_if = (typeof(tree['flexy:if']) != 'undefined');
402 var build_from_html = Roo.XComponent.build_from_html;
404 var is_body = (tree.xtype == 'Body') ;
406 var page_has_body = (Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body');
408 var self_cntr_el = Roo.get(this[cntr](false));
410 // do not try and build conditional elements
411 if ((has_flexy_each || has_flexy_if || this.can_build_overlaid == false ) && build_from_html) {
415 if (!has_flexy_each || !build_from_html || is_body || !page_has_body) {
416 if(!has_flexy_if || typeof(tree.name) == 'undefined' || !build_from_html || is_body || !page_has_body){
417 return this.addxtypeChild(tree,cntr, is_body);
420 var echild =self_cntr_el ? self_cntr_el.child('>*[name=' + tree.name + ']') : false;
423 return this.addxtypeChild(Roo.apply({}, tree),cntr);
426 Roo.log('skipping render');
432 if (!build_from_html) {
436 // this i think handles overlaying multiple children of the same type
437 // with the sam eelement.. - which might be buggy..
439 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
445 if (echild && echild.attr('xtype').split('.').pop() != cn.xtype) {
449 ret = this.addxtypeChild(Roo.apply({}, tree),cntr);
456 addxtypeChild : function (tree, cntr, is_body)
458 Roo.debug && Roo.log('addxtypeChild:' + cntr);
460 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
463 var has_flexy = (typeof(tree['flexy:if']) != 'undefined') ||
464 (typeof(tree['flexy:foreach']) != 'undefined');
468 skip_children = false;
469 // render the element if it's not BODY.
472 // if parent was disabled, then do not try and create the children..
473 if(!this[cntr](true)){
478 cn = Roo.factory(tree);
480 cn.parentType = this.xtype; //??
481 cn.parentId = this.id;
483 var build_from_html = Roo.XComponent.build_from_html;
486 // does the container contain child eleemnts with 'xtype' attributes.
487 // that match this xtype..
488 // note - when we render we create these as well..
489 // so we should check to see if body has xtype set.
490 if (build_from_html && Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body') {
492 var self_cntr_el = Roo.get(this[cntr](false));
493 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
495 //Roo.log(Roo.XComponent.build_from_html);
496 //Roo.log("got echild:");
499 // there is a scenario where some of the child elements are flexy:if (and all of the same type)
500 // and are not displayed -this causes this to use up the wrong element when matching.
501 // at present the only work around for this is to nest flexy:if elements in another element that is always rendered.
504 if (echild && echild.attr('xtype').split('.').pop() == cn.xtype) {
505 // Roo.log("found child for " + this.xtype +": " + echild.attr('xtype') );
511 //echild.dom.removeAttribute('xtype');
513 Roo.debug && Roo.log("MISSING " + cn.xtype + " on child of " + (this.el ? this.el.attr('xbuilderid') : 'no parent'));
514 Roo.debug && Roo.log(self_cntr_el);
515 Roo.debug && Roo.log(echild);
516 Roo.debug && Roo.log(cn);
522 // if object has flexy:if - then it may or may not be rendered.
523 if (build_from_html && has_flexy && !cn.el && cn.can_build_overlaid) {
524 // skip a flexy if element.
525 Roo.debug && Roo.log('skipping render');
526 Roo.debug && Roo.log(tree);
528 Roo.debug && Roo.log('skipping all children');
529 skip_children = true;
534 // actually if flexy:foreach is found, we really want to create
535 // multiple copies here...
537 //Roo.log(this[cntr]());
538 // some elements do not have render methods.. like the layouts...
540 if(this[cntr](true) === false){
545 cn.render && cn.render(this[cntr](true));
548 // then add the element..
555 if (typeof (tree.menu) != 'undefined') {
556 tree.menu.parentType = cn.xtype;
557 tree.menu.triggerEl = cn.el;
558 nitems.push(cn.addxtype(Roo.apply({}, tree.menu)));
562 if (!tree.items || !tree.items.length) {
564 //Roo.log(["no children", this]);
569 var items = tree.items;
572 //Roo.log(items.length);
574 if (!skip_children) {
575 for(var i =0;i < items.length;i++) {
576 // Roo.log(['add child', items[i]]);
577 nitems.push(cn.addxtype(Roo.apply({}, items[i])));
583 //Roo.log("fire childrenrendered");
585 cn.fireEvent('childrenrendered', this);
591 * Set the element that will be used to show or hide
593 setVisibilityEl : function(el)
595 this.visibilityEl = el;
599 * Get the element that will be used to show or hide
601 getVisibilityEl : function()
603 if (typeof(this.visibilityEl) == 'object') {
604 return this.visibilityEl;
607 if (typeof(this.visibilityEl) == 'string') {
608 return this.visibilityEl == 'parent' ? this.parent().getEl() : this.getEl();
615 * Show a component - removes 'hidden' class
619 if(!this.getVisibilityEl()){
623 this.getVisibilityEl().removeClass(['hidden','d-none']);
625 this.fireEvent('show', this);
630 * Hide a component - adds 'hidden' class
634 if(!this.getVisibilityEl()){
638 this.getVisibilityEl().addClass(['hidden','d-none']);
640 this.fireEvent('hide', this);
653 * @class Roo.bootstrap.Element
654 * @extends Roo.bootstrap.Component
655 * @children Roo.bootstrap.Component
656 * Bootstrap Element class (basically a DIV used to make random stuff )
658 * @cfg {String} html contents of the element
659 * @cfg {String} tag tag of the element
660 * @cfg {String} cls class of the element
661 * @cfg {Boolean} preventDefault (true|false) default false
662 * @cfg {Boolean} clickable (true|false) default false
663 * @cfg {String} role default blank - set to button to force cursor pointer
667 * Create a new Element
668 * @param {Object} config The config object
671 Roo.bootstrap.Element = function(config){
672 Roo.bootstrap.Element.superclass.constructor.call(this, config);
678 * When a element is chick
679 * @param {Roo.bootstrap.Element} this
680 * @param {Roo.EventObject} e
688 Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, {
693 preventDefault: false,
698 getAutoCreate : function(){
702 // cls: this.cls, double assign in parent class Component.js :: onRender
705 if (this.role !== false) {
706 cfg.role = this.role;
712 initEvents: function()
714 Roo.bootstrap.Element.superclass.initEvents.call(this);
717 this.el.on('click', this.onClick, this);
723 onClick : function(e)
725 if(this.preventDefault){
729 this.fireEvent('click', this, e); // why was this double click before?
737 getValue : function()
739 return this.el.dom.innerHTML;
742 setValue : function(value)
744 this.el.dom.innerHTML = value;
759 * @class Roo.bootstrap.DropTarget
760 * @extends Roo.bootstrap.Element
761 * Bootstrap DropTarget class
763 * @cfg {string} name dropable name
766 * Create a new Dropable Area
767 * @param {Object} config The config object
770 Roo.bootstrap.DropTarget = function(config){
771 Roo.bootstrap.DropTarget.superclass.constructor.call(this, config);
777 * When a element is chick
778 * @param {Roo.bootstrap.Element} this
779 * @param {Roo.EventObject} e
785 Roo.extend(Roo.bootstrap.DropTarget, Roo.bootstrap.Element, {
788 getAutoCreate : function(){
793 initEvents: function()
795 Roo.bootstrap.DropTarget.superclass.initEvents.call(this);
796 this.dropZone = new Roo.dd.DropTarget(this.getEl(), {
799 drop : this.dragDrop.createDelegate(this),
800 enter : this.dragEnter.createDelegate(this),
801 out : this.dragOut.createDelegate(this),
802 over : this.dragOver.createDelegate(this)
806 this.dropZone.DDM.useCache = false // so data gets refreshed when we resize stuff
809 dragDrop : function(source,e,data)
811 // user has to decide how to impliment this.
814 //this.fireEvent('drop', this, source, e ,data);
818 dragEnter : function(n, dd, e, data)
820 // probably want to resize the element to match the dropped element..
822 this.originalSize = this.el.getSize();
823 this.el.setSize( n.el.getSize());
824 this.dropZone.DDM.refreshCache(this.name);
825 Roo.log([n, dd, e, data]);
828 dragOut : function(value)
830 // resize back to normal
832 this.el.setSize(this.originalSize);
833 this.dropZone.resetConstraints();
836 dragOver : function()
853 * @class Roo.bootstrap.Body
854 * @extends Roo.bootstrap.Component
856 * @children Roo.bootstrap.Component
858 * Bootstrap Body class
862 * @param {Object} config The config object
865 Roo.bootstrap.Body = function(config){
867 config = config || {};
869 Roo.bootstrap.Body.superclass.constructor.call(this, config);
870 this.el = Roo.get(config.el ? config.el : document.body );
871 if (this.cls && this.cls.length) {
872 Roo.get(document.body).addClass(this.cls);
876 Roo.extend(Roo.bootstrap.Body, Roo.bootstrap.Component, {
878 is_body : true,// just to make sure it's constructed?
883 onRender : function(ct, position)
885 /* Roo.log("Roo.bootstrap.Body - onRender");
886 if (this.cls && this.cls.length) {
887 Roo.get(document.body).addClass(this.cls);
906 * @class Roo.bootstrap.ButtonGroup
907 * @extends Roo.bootstrap.Component
908 * Bootstrap ButtonGroup class
909 * @cfg {String} size lg | sm | xs (default empty normal)
910 * @cfg {String} align vertical | justified (default none)
911 * @cfg {String} direction up | down (default down)
912 * @cfg {Boolean} toolbar false | true
913 * @cfg {Boolean} btn true | false
918 * @param {Object} config The config object
921 Roo.bootstrap.ButtonGroup = function(config){
922 Roo.bootstrap.ButtonGroup.superclass.constructor.call(this, config);
925 Roo.extend(Roo.bootstrap.ButtonGroup, Roo.bootstrap.Component, {
933 getAutoCreate : function(){
939 cfg.html = this.html || cfg.html;
950 if (['vertical','justified'].indexOf(this.align)!==-1) {
951 cfg.cls = 'btn-group-' + this.align;
953 if (this.align == 'justified') {
954 console.log(this.items);
958 if (['lg','sm','xs'].indexOf(this.size)!==-1) {
959 cfg.cls += ' btn-group-' + this.size;
962 if (this.direction == 'up') {
963 cfg.cls += ' dropup' ;
969 * Add a button to the group (similar to NavItem API.)
971 addItem : function(cfg)
973 var cn = new Roo.bootstrap.Button(cfg);
975 cn.parentId = this.id;
976 cn.onRender(this.el, null);
990 * @class Roo.bootstrap.Button
991 * @extends Roo.bootstrap.Component
992 * Bootstrap Button class
993 * @cfg {String} html The button content
994 * @cfg {String} weight (default|primary|secondary|success|info|warning|danger|link|light|dark) default
995 * @cfg {String} badge_weight (default|primary|secondary|success|info|warning|danger|link|light|dark) default (same as button)
996 * @cfg {Boolean} outline default false (except for weight=default which emulates old behaveiour with an outline)
997 * @cfg {String} size (lg|sm|xs)
998 * @cfg {String} tag (a|input|submit)
999 * @cfg {String} href empty or href
1000 * @cfg {Boolean} disabled default false;
1001 * @cfg {Boolean} isClose default false;
1002 * @cfg {String} glyphicon depricated - use fa
1003 * @cfg {String} fa fontawesome icon - eg. 'comment' - without the fa/fas etc..
1004 * @cfg {String} badge text for badge
1005 * @cfg {String} theme (default|glow)
1006 * @cfg {Boolean} inverse dark themed version
1007 * @cfg {Boolean} toggle is it a slidy toggle button
1008 * @cfg {Boolean} pressed default null - if the button ahs active state
1009 * @cfg {String} ontext text for on slidy toggle state
1010 * @cfg {String} offtext text for off slidy toggle state
1011 * @cfg {Boolean} preventDefault default true (stop click event triggering the URL if it's a link.)
1012 * @cfg {Boolean} removeClass remove the standard class..
1013 * @cfg {String} target (_self|_blank|_parent|_top|other) target for a href.
1014 * @cfg {Boolean} grpup if parent is a btn group - then it turns it into a toogleGroup.
1017 * Create a new button
1018 * @param {Object} config The config object
1022 Roo.bootstrap.Button = function(config){
1023 Roo.bootstrap.Button.superclass.constructor.call(this, config);
1029 * When a button is pressed
1030 * @param {Roo.bootstrap.Button} btn
1031 * @param {Roo.EventObject} e
1036 * When a button is double clicked
1037 * @param {Roo.bootstrap.Button} btn
1038 * @param {Roo.EventObject} e
1043 * After the button has been toggles
1044 * @param {Roo.bootstrap.Button} btn
1045 * @param {Roo.EventObject} e
1046 * @param {boolean} pressed (also available as button.pressed)
1052 Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, {
1073 preventDefault: true,
1082 getAutoCreate : function(){
1090 if (['a', 'button', 'input', 'submit'].indexOf(this.tag) < 0) {
1091 throw "Invalid value for tag: " + this.tag + ". must be a, button, input or submit.";
1092 this.tag = 'button';
1096 cfg.html = '<span class="roo-button-text">' + (this.html || cfg.html) + '</span>';
1098 if (this.toggle == true) {
1101 cls: 'slider-frame roo-button',
1105 'data-on-text':'ON',
1106 'data-off-text':'OFF',
1107 cls: 'slider-button',
1112 // why are we validating the weights?
1113 if (Roo.bootstrap.Button.weights.indexOf(this.weight) > -1) {
1114 cfg.cls += ' ' + this.weight;
1121 cfg.cls += ' close';
1123 cfg["aria-hidden"] = true;
1125 cfg.html = "×";
1131 if (this.theme==='default') {
1132 cfg.cls = 'btn roo-button';
1134 //if (this.parentType != 'Navbar') {
1135 this.weight = this.weight.length ? this.weight : 'default';
1137 if (Roo.bootstrap.Button.weights.indexOf(this.weight) > -1) {
1139 var outline = this.outline || this.weight == 'default' ? 'outline-' : '';
1140 var weight = this.weight == 'default' ? 'secondary' : this.weight;
1141 cfg.cls += ' btn-' + outline + weight;
1142 if (this.weight == 'default') {
1144 cfg.cls += ' btn-' + this.weight;
1147 } else if (this.theme==='glow') {
1150 cfg.cls = 'btn-glow roo-button';
1152 if (Roo.bootstrap.Button.weights.indexOf(this.weight) > -1) {
1154 cfg.cls += ' ' + this.weight;
1160 this.cls += ' inverse';
1164 if (this.active || this.pressed === true) {
1165 cfg.cls += ' active';
1168 if (this.disabled) {
1169 cfg.disabled = 'disabled';
1173 Roo.log('changing to ul' );
1175 this.glyphicon = 'caret';
1176 if (Roo.bootstrap.version == 4) {
1177 this.fa = 'caret-down';
1182 cfg.cls += this.size.length ? (' btn-' + this.size) : '';
1184 //gsRoo.log(this.parentType);
1185 if (this.parentType === 'Navbar' && !this.parent().bar) {
1186 Roo.log('changing to li?');
1195 href : this.href || '#'
1198 cfg.cn[0].html = this.html + ' <span class="caret"></span>';
1199 cfg.cls += ' dropdown';
1206 cfg.cls += this.parentType === 'Navbar' ? ' navbar-btn' : '';
1208 if (this.glyphicon) {
1209 cfg.html = ' ' + cfg.html;
1214 cls: 'glyphicon glyphicon-' + this.glyphicon
1219 cfg.html = ' ' + cfg.html;
1224 cls: 'fa fas fa-' + this.fa
1234 // cfg.cls='btn roo-button';
1238 var value = cfg.html;
1243 cls: 'glyphicon glyphicon-' + this.glyphicon,
1250 cls: 'fa fas fa-' + this.fa,
1255 var bw = this.badge_weight.length ? this.badge_weight :
1256 (this.weight.length ? this.weight : 'secondary');
1257 bw = bw == 'default' ? 'secondary' : bw;
1263 cls: 'badge badge-' + bw,
1272 cfg.cls += ' dropdown';
1273 cfg.html = typeof(cfg.html) != 'undefined' ?
1274 cfg.html + ' <span class="caret"></span>' : '<span class="caret"></span>';
1277 if (cfg.tag !== 'a' && this.href !== '') {
1278 throw "Tag must be a to set href.";
1279 } else if (this.href.length > 0) {
1280 cfg.href = this.href;
1283 if(this.removeClass){
1288 cfg.target = this.target;
1293 initEvents: function() {
1294 // Roo.log('init events?');
1295 // Roo.log(this.el.dom);
1298 if (typeof (this.menu) != 'undefined') {
1299 this.menu.parentType = this.xtype;
1300 this.menu.triggerEl = this.el;
1301 this.addxtype(Roo.apply({}, this.menu));
1305 if (this.el.hasClass('roo-button')) {
1306 this.el.on('click', this.onClick, this);
1307 this.el.on('dblclick', this.onDblClick, this);
1309 this.el.select('.roo-button').on('click', this.onClick, this);
1310 this.el.select('.roo-button').on('dblclick', this.onDblClick, this);
1314 if(this.removeClass){
1315 this.el.on('click', this.onClick, this);
1318 if (this.group === true) {
1319 if (this.pressed === false || this.pressed === true) {
1322 this.pressed = false;
1323 this.setActive(this.pressed);
1328 this.el.enableDisplayMode();
1331 onClick : function(e)
1333 if (this.disabled) {
1337 Roo.log('button on click ');
1338 if(this.preventDefault){
1347 this.setActive(true);
1348 var pi = this.parent().items;
1349 for (var i = 0;i < pi.length;i++) {
1350 if (this == pi[i]) {
1353 if (pi[i].el.hasClass('roo-button')) {
1354 pi[i].setActive(false);
1357 this.fireEvent('click', this, e);
1361 if (this.pressed === true || this.pressed === false) {
1362 this.toggleActive(e);
1366 this.fireEvent('click', this, e);
1368 onDblClick: function(e)
1370 if (this.disabled) {
1373 if(this.preventDefault){
1376 this.fireEvent('dblclick', this, e);
1379 * Enables this button
1383 this.disabled = false;
1384 this.el.removeClass('disabled');
1385 this.el.dom.removeAttribute("disabled");
1389 * Disable this button
1391 disable : function()
1393 this.disabled = true;
1394 this.el.addClass('disabled');
1395 this.el.attr("disabled", "disabled")
1398 * sets the active state on/off,
1399 * @param {Boolean} state (optional) Force a particular state
1401 setActive : function(v) {
1403 this.el[v ? 'addClass' : 'removeClass']('active');
1407 * toggles the current active state
1409 toggleActive : function(e)
1411 this.setActive(!this.pressed); // this modifies pressed...
1412 this.fireEvent('toggle', this, e, this.pressed);
1415 * get the current active state
1416 * @return {boolean} true if it's active
1418 isActive : function()
1420 return this.el.hasClass('active');
1423 * set the text of the first selected button
1425 setText : function(str)
1427 this.el.select('.roo-button-text',true).first().dom.innerHTML = str;
1430 * get the text of the first selected button
1432 getText : function()
1434 return this.el.select('.roo-button-text',true).first().dom.innerHTML;
1437 setWeight : function(str)
1439 this.el.removeClass(Roo.bootstrap.Button.weights.map(function(w) { return 'btn-' + w; } ) );
1440 this.el.removeClass(Roo.bootstrap.Button.weights.map(function(w) { return 'btn-outline-' + w; } ) );
1442 var outline = this.outline ? 'outline-' : '';
1443 if (str == 'default') {
1444 this.el.addClass('btn-default btn-outline-secondary');
1447 this.el.addClass('btn-' + outline + str);
1452 // fixme - this is probably generic bootstrap - should go in some kind of enum file.. - like sizes.
1454 Roo.bootstrap.Button.weights = [
1474 * @class Roo.bootstrap.Column
1475 * @extends Roo.bootstrap.Component
1476 * @children Roo.bootstrap.Component
1477 * Bootstrap Column class
1478 * @cfg {Number} xs colspan out of 12 for mobile-sized screens or 0 for hidden
1479 * @cfg {Number} sm colspan out of 12 for tablet-sized screens or 0 for hidden
1480 * @cfg {Number} md colspan out of 12 for computer-sized screens or 0 for hidden
1481 * @cfg {Number} lg colspan out of 12 for large computer-sized screens or 0 for hidden
1482 * @cfg {Number} xsoff colspan offset out of 12 for mobile-sized screens or 0 for hidden
1483 * @cfg {Number} smoff colspan offset out of 12 for tablet-sized screens or 0 for hidden
1484 * @cfg {Number} mdoff colspan offset out of 12 for computer-sized screens or 0 for hidden
1485 * @cfg {Number} lgoff colspan offset out of 12 for large computer-sized screens or 0 for hidden
1488 * @cfg {Boolean} hidden (true|false) hide the element
1489 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1490 * @cfg {String} fa (ban|check|...) font awesome icon
1491 * @cfg {Number} fasize (1|2|....) font awsome size
1493 * @cfg {String} icon (info-sign|check|...) glyphicon name
1495 * @cfg {String} html content of column.
1498 * Create a new Column
1499 * @param {Object} config The config object
1502 Roo.bootstrap.Column = function(config){
1503 Roo.bootstrap.Column.superclass.constructor.call(this, config);
1506 Roo.extend(Roo.bootstrap.Column, Roo.bootstrap.Component, {
1524 getAutoCreate : function(){
1525 var cfg = Roo.apply({}, Roo.bootstrap.Column.superclass.getAutoCreate.call(this));
1533 var sizes = ['xs','sm','md','lg'];
1534 sizes.map(function(size ,ix){
1535 //Roo.log( size + ':' + settings[size]);
1537 if (settings[size+'off'] !== false) {
1538 cfg.cls += ' col-' + size + '-offset-' + settings[size+'off'] ;
1541 if (settings[size] === false) {
1545 if (!settings[size]) { // 0 = hidden
1546 cfg.cls += ' hidden-' + size + ' hidden-' + size + '-down';
1548 for (var i = ix; i > -1; i--) {
1549 cfg.cls += ' d-' + sizes[i] + '-none';
1555 cfg.cls += ' col-' + size + '-' + settings[size] + (
1556 size == 'xs' ? (' col-' + settings[size] ) : '' // bs4 col-{num} replaces col-xs
1562 cfg.cls += ' hidden';
1565 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1566 cfg.cls +=' alert alert-' + this.alert;
1570 if (this.html.length) {
1571 cfg.html = this.html;
1575 if (this.fasize > 1) {
1576 fasize = ' fa-' + this.fasize + 'x';
1578 cfg.html = '<i class="fa fa-'+this.fa + fasize + '"></i>' + (cfg.html || '');
1583 cfg.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + (cfg.html || '');
1602 * @class Roo.bootstrap.Container
1603 * @extends Roo.bootstrap.Component
1605 * @children Roo.bootstrap.Component
1606 * Bootstrap Container class
1607 * @cfg {Boolean} jumbotron is it a jumbotron element
1608 * @cfg {String} html content of element
1609 * @cfg {String} well (lg|sm|md) a well, large, small or medium.
1610 * @cfg {String} panel (default|primary|success|info|warning|danger) render as panel - type - primary/success.....
1611 * @cfg {String} header content of header (for panel)
1612 * @cfg {String} footer content of footer (for panel)
1613 * @cfg {String} sticky (footer|wrap|push) block to use as footer or body- needs css-bootstrap/sticky-footer.css
1614 * @cfg {String} tag (header|aside|section) type of HTML tag.
1615 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1616 * @cfg {String} fa font awesome icon
1617 * @cfg {String} icon (info-sign|check|...) glyphicon name
1618 * @cfg {Boolean} hidden (true|false) hide the element
1619 * @cfg {Boolean} expandable (true|false) default false
1620 * @cfg {Boolean} expanded (true|false) default true
1621 * @cfg {String} rheader contet on the right of header
1622 * @cfg {Boolean} clickable (true|false) default false
1626 * Create a new Container
1627 * @param {Object} config The config object
1630 Roo.bootstrap.Container = function(config){
1631 Roo.bootstrap.Container.superclass.constructor.call(this, config);
1637 * After the panel has been expand
1639 * @param {Roo.bootstrap.Container} this
1644 * After the panel has been collapsed
1646 * @param {Roo.bootstrap.Container} this
1651 * When a element is chick
1652 * @param {Roo.bootstrap.Container} this
1653 * @param {Roo.EventObject} e
1659 Roo.extend(Roo.bootstrap.Container, Roo.bootstrap.Component, {
1677 getChildContainer : function() {
1683 if (this.panel.length) {
1684 return this.el.select('.panel-body',true).first();
1691 getAutoCreate : function(){
1694 tag : this.tag || 'div',
1698 if (this.jumbotron) {
1699 cfg.cls = 'jumbotron';
1704 // - this is applied by the parent..
1706 // cfg.cls = this.cls + '';
1709 if (this.sticky.length) {
1711 var bd = Roo.get(document.body);
1712 if (!bd.hasClass('bootstrap-sticky')) {
1713 bd.addClass('bootstrap-sticky');
1714 Roo.select('html',true).setStyle('height', '100%');
1717 cfg.cls += 'bootstrap-sticky-' + this.sticky;
1721 if (this.well.length) {
1722 switch (this.well) {
1725 cfg.cls +=' well well-' +this.well;
1734 cfg.cls += ' hidden';
1738 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1739 cfg.cls +=' alert alert-' + this.alert;
1744 if (this.panel.length) {
1745 cfg.cls += ' panel panel-' + this.panel;
1747 if (this.header.length) {
1751 if(this.expandable){
1753 cfg.cls = cfg.cls + ' expandable';
1757 cls: (this.expanded ? 'fa fa-minus' : 'fa fa-plus')
1765 cls : 'panel-title',
1766 html : (this.expandable ? ' ' : '') + this.header
1770 cls: 'panel-header-right',
1776 cls : 'panel-heading',
1777 style : this.expandable ? 'cursor: pointer' : '',
1785 cls : 'panel-body' + (this.expanded ? '' : ' hide'),
1790 if (this.footer.length) {
1792 cls : 'panel-footer',
1801 body.html = this.html || cfg.html;
1802 // prefix with the icons..
1804 body.html = '<i class="fa fa-'+this.fa + '"></i>' + body.html ;
1807 body.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + body.html ;
1812 if ((!this.cls || !this.cls.length) && (!cfg.cls || !cfg.cls.length)) {
1813 cfg.cls = 'container';
1819 initEvents: function()
1821 if(this.expandable){
1822 var headerEl = this.headerEl();
1825 headerEl.on('click', this.onToggleClick, this);
1830 this.el.on('click', this.onClick, this);
1835 onToggleClick : function()
1837 var headerEl = this.headerEl();
1853 if(this.fireEvent('expand', this)) {
1855 this.expanded = true;
1857 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).show();
1859 this.el.select('.panel-body',true).first().removeClass('hide');
1861 var toggleEl = this.toggleEl();
1867 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-minus']);
1872 collapse : function()
1874 if(this.fireEvent('collapse', this)) {
1876 this.expanded = false;
1878 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).hide();
1879 this.el.select('.panel-body',true).first().addClass('hide');
1881 var toggleEl = this.toggleEl();
1887 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-plus']);
1891 toggleEl : function()
1893 if(!this.el || !this.panel.length || !this.header.length || !this.expandable){
1897 return this.el.select('.panel-heading .fa',true).first();
1900 headerEl : function()
1902 if(!this.el || !this.panel.length || !this.header.length){
1906 return this.el.select('.panel-heading',true).first()
1911 if(!this.el || !this.panel.length){
1915 return this.el.select('.panel-body',true).first()
1918 titleEl : function()
1920 if(!this.el || !this.panel.length || !this.header.length){
1924 return this.el.select('.panel-title',true).first();
1927 setTitle : function(v)
1929 var titleEl = this.titleEl();
1935 titleEl.dom.innerHTML = v;
1938 getTitle : function()
1941 var titleEl = this.titleEl();
1947 return titleEl.dom.innerHTML;
1950 setRightTitle : function(v)
1952 var t = this.el.select('.panel-header-right',true).first();
1958 t.dom.innerHTML = v;
1961 onClick : function(e)
1965 this.fireEvent('click', this, e);
1972 * This is BS4's Card element.. - similar to our containers probably..
1976 * @class Roo.bootstrap.Card
1977 * @extends Roo.bootstrap.Component
1978 * @children Roo.bootstrap.Component
1979 * Bootstrap Card class
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 * Bootstrap CardHeader class
2782 * Create a new Card Header - that you can embed children into
2783 * @param {Object} config The config object
2786 Roo.bootstrap.CardHeader = function(config){
2787 Roo.bootstrap.CardHeader.superclass.constructor.call(this, config);
2790 Roo.extend(Roo.bootstrap.CardHeader, Roo.bootstrap.Element, {
2793 container_method : 'getCardHeader'
2806 * Card footer - holder for the card footer elements.
2811 * @class Roo.bootstrap.CardFooter
2812 * @extends Roo.bootstrap.Element
2813 * Bootstrap CardFooter class
2815 * Create a new Card Footer - that you can embed children into
2816 * @param {Object} config The config object
2819 Roo.bootstrap.CardFooter = function(config){
2820 Roo.bootstrap.CardFooter.superclass.constructor.call(this, config);
2823 Roo.extend(Roo.bootstrap.CardFooter, Roo.bootstrap.Element, {
2826 container_method : 'getCardFooter'
2839 * Card header - holder for the card header elements.
2844 * @class Roo.bootstrap.CardImageTop
2845 * @extends Roo.bootstrap.Element
2846 * Bootstrap CardImageTop class
2848 * Create a new Card Image Top container
2849 * @param {Object} config The config object
2852 Roo.bootstrap.CardImageTop = function(config){
2853 Roo.bootstrap.CardImageTop.superclass.constructor.call(this, config);
2856 Roo.extend(Roo.bootstrap.CardImageTop, Roo.bootstrap.Element, {
2859 container_method : 'getCardImageTop'
2874 * @class Roo.bootstrap.ButtonUploader
2875 * @extends Roo.bootstrap.Button
2876 * Bootstrap Button Uploader class - it's a button which when you add files to it
2879 * @cfg {Number} errorTimeout default 3000
2880 * @cfg {Array} images an array of ?? Img objects ??? when loading existing files..
2881 * @cfg {Array} html The button text.
2882 * @cfg {Boolean} multiple (default true) Should the upload allow multiple files to be uploaded.
2885 * Create a new CardUploader
2886 * @param {Object} config The config object
2889 Roo.bootstrap.ButtonUploader = function(config){
2893 Roo.bootstrap.ButtonUploader.superclass.constructor.call(this, config);
2899 * @event beforeselect
2900 * When button is pressed, before show upload files dialog is shown
2901 * @param {Roo.bootstrap.UploaderButton} this
2904 'beforeselect' : true,
2906 * @event fired when files have been selected,
2907 * When a the download link is clicked
2908 * @param {Roo.bootstrap.UploaderButton} this
2909 * @param {Array} Array of files that have been uploaded
2916 Roo.extend(Roo.bootstrap.ButtonUploader, Roo.bootstrap.Button, {
2919 errorTimeout : 3000,
2923 fileCollection : false,
2928 getAutoCreate : function()
2933 cls : 'd-none roo-card-upload-selector'
2936 if (this.multiple) {
2937 im.multiple = 'multiple';
2943 Roo.bootstrap.Button.prototype.getAutoCreate.call(this),
2953 initEvents : function()
2956 Roo.bootstrap.Button.prototype.initEvents.call(this);
2962 this.urlAPI = (window.createObjectURL && window) ||
2963 (window.URL && URL.revokeObjectURL && URL) ||
2964 (window.webkitURL && webkitURL);
2969 this.selectorEl = this.el.select('.roo-card-upload-selector', true).first();
2971 this.selectorEl.on('change', this.onFileSelected, this);
2978 onClick : function(e)
2982 if ( this.fireEvent('beforeselect', this) === false) {
2986 this.selectorEl.dom.click();
2990 onFileSelected : function(e)
2994 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
2997 var files = Array.prototype.slice.call(this.selectorEl.dom.files);
2998 this.selectorEl.dom.value = '';// hopefully reset..
3000 this.fireEvent('uploaded', this, files );
3008 * addCard - add an Attachment to the uploader
3009 * @param data - the data about the image to upload
3013 title : "Title of file",
3014 is_uploaded : false,
3015 src : "http://.....",
3016 srcfile : { the File upload object },
3017 mimetype : file.type,
3020 .. any other data...
3045 * @class Roo.bootstrap.Img
3046 * @extends Roo.bootstrap.Component
3047 * Bootstrap Img class
3048 * @cfg {Boolean} imgResponsive false | true
3049 * @cfg {String} border rounded | circle | thumbnail
3050 * @cfg {String} src image source
3051 * @cfg {String} alt image alternative text
3052 * @cfg {String} href a tag href
3053 * @cfg {String} target (_self|_blank|_parent|_top)target for a href.
3054 * @cfg {String} xsUrl xs image source
3055 * @cfg {String} smUrl sm image source
3056 * @cfg {String} mdUrl md image source
3057 * @cfg {String} lgUrl lg image source
3058 * @cfg {Boolean} backgroundContain (use style background and contain image in content)
3061 * Create a new Input
3062 * @param {Object} config The config object
3065 Roo.bootstrap.Img = function(config){
3066 Roo.bootstrap.Img.superclass.constructor.call(this, config);
3072 * The img click event for the img.
3073 * @param {Roo.EventObject} e
3078 * The when any image loads
3079 * @param {Roo.EventObject} e
3085 Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, {
3087 imgResponsive: true,
3096 backgroundContain : false,
3098 getAutoCreate : function()
3100 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
3101 return this.createSingleImg();
3106 cls: 'roo-image-responsive-group',
3111 Roo.each(['xs', 'sm', 'md', 'lg'], function(size){
3113 if(!_this[size + 'Url']){
3119 cls: (_this.imgResponsive) ? 'img-responsive' : '',
3120 html: _this.html || cfg.html,
3121 src: _this[size + 'Url']
3124 img.cls += ' roo-image-responsive-' + size;
3126 var s = ['xs', 'sm', 'md', 'lg'];
3128 s.splice(s.indexOf(size), 1);
3130 Roo.each(s, function(ss){
3131 img.cls += ' hidden-' + ss;
3134 if (['rounded','circle','thumbnail'].indexOf(_this.border)>-1) {
3135 cfg.cls += ' img-' + _this.border;
3139 cfg.alt = _this.alt;
3152 a.target = _this.target;
3156 cfg.cn.push((_this.href) ? a : img);
3163 createSingleImg : function()
3167 cls: (this.imgResponsive) ? 'img-responsive' : '',
3169 src : Roo.BLANK_IMAGE_URL // just incase src get's set to undefined?!?
3172 if (this.backgroundContain) {
3173 cfg.cls += ' background-contain';
3176 cfg.html = this.html || cfg.html;
3178 if (this.backgroundContain) {
3179 cfg.style="background-image: url(" + this.src + ')';
3181 cfg.src = this.src || cfg.src;
3184 if (['rounded','circle','thumbnail'].indexOf(this.border)>-1) {
3185 cfg.cls += ' img-' + this.border;
3202 a.target = this.target;
3207 return (this.href) ? a : cfg;
3210 initEvents: function()
3213 this.el.on('click', this.onClick, this);
3215 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
3216 this.el.on('load', this.onImageLoad, this);
3218 // not sure if this works.. not tested
3219 this.el.select('img', true).on('load', this.onImageLoad, this);
3224 onClick : function(e)
3226 Roo.log('img onclick');
3227 this.fireEvent('click', this, e);
3229 onImageLoad: function(e)
3231 Roo.log('img load');
3232 this.fireEvent('load', this, e);
3236 * Sets the url of the image - used to update it
3237 * @param {String} url the url of the image
3240 setSrc : function(url)
3244 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
3245 if (this.backgroundContain) {
3246 this.el.dom.style.backgroundImage = 'url(' + url + ')';
3248 this.el.dom.src = url;
3253 this.el.select('img', true).first().dom.src = url;
3269 * @class Roo.bootstrap.Link
3270 * @extends Roo.bootstrap.Component
3271 * Bootstrap Link Class
3272 * @cfg {String} alt image alternative text
3273 * @cfg {String} href a tag href
3274 * @cfg {String} target (_self|_blank|_parent|_top) target for a href.
3275 * @cfg {String} html the content of the link.
3276 * @cfg {String} anchor name for the anchor link
3277 * @cfg {String} fa - favicon
3279 * @cfg {Boolean} preventDefault (true | false) default false
3283 * Create a new Input
3284 * @param {Object} config The config object
3287 Roo.bootstrap.Link = function(config){
3288 Roo.bootstrap.Link.superclass.constructor.call(this, config);
3294 * The img click event for the img.
3295 * @param {Roo.EventObject} e
3301 Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component, {
3305 preventDefault: false,
3311 getAutoCreate : function()
3313 var html = this.html || '';
3315 if (this.fa !== false) {
3316 html = '<i class="fa fa-' + this.fa + '"></i>';
3321 // anchor's do not require html/href...
3322 if (this.anchor === false) {
3324 cfg.href = this.href || '#';
3326 cfg.name = this.anchor;
3327 if (this.html !== false || this.fa !== false) {
3330 if (this.href !== false) {
3331 cfg.href = this.href;
3335 if(this.alt !== false){
3340 if(this.target !== false) {
3341 cfg.target = this.target;
3347 initEvents: function() {
3349 if(!this.href || this.preventDefault){
3350 this.el.on('click', this.onClick, this);
3354 onClick : function(e)
3356 if(this.preventDefault){
3359 //Roo.log('img onclick');
3360 this.fireEvent('click', this, e);
3373 * @class Roo.bootstrap.Header
3374 * @extends Roo.bootstrap.Component
3375 * Bootstrap Header class
3376 * @cfg {String} html content of header
3377 * @cfg {Number} level (1|2|3|4|5|6) default 1
3380 * Create a new Header
3381 * @param {Object} config The config object
3385 Roo.bootstrap.Header = function(config){
3386 Roo.bootstrap.Header.superclass.constructor.call(this, config);
3389 Roo.extend(Roo.bootstrap.Header, Roo.bootstrap.Component, {
3397 getAutoCreate : function(){
3402 tag: 'h' + (1 *this.level),
3403 html: this.html || ''
3415 * Ext JS Library 1.1.1
3416 * Copyright(c) 2006-2007, Ext JS, LLC.
3418 * Originally Released Under LGPL - original licence link has changed is not relivant.
3421 * <script type="text/javascript">
3425 * @class Roo.bootstrap.MenuMgr
3426 * Provides a common registry of all menu items on a page so that they can be easily accessed by id.
3429 Roo.bootstrap.MenuMgr = function(){
3430 var menus, active, groups = {}, attached = false, lastShow = new Date();
3432 // private - called when first menu is created
3435 active = new Roo.util.MixedCollection();
3436 Roo.get(document).addKeyListener(27, function(){
3437 if(active.length > 0){
3445 if(active && active.length > 0){
3446 var c = active.clone();
3456 if(active.length < 1){
3457 Roo.get(document).un("mouseup", onMouseDown);
3465 var last = active.last();
3466 lastShow = new Date();
3469 Roo.get(document).on("mouseup", onMouseDown);
3474 //m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
3475 m.parentMenu.activeChild = m;
3476 }else if(last && last.isVisible()){
3477 //m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
3482 function onBeforeHide(m){
3484 m.activeChild.hide();
3486 if(m.autoHideTimer){
3487 clearTimeout(m.autoHideTimer);
3488 delete m.autoHideTimer;
3493 function onBeforeShow(m){
3494 var pm = m.parentMenu;
3495 if(!pm && !m.allowOtherMenus){
3497 }else if(pm && pm.activeChild && active != m){
3498 pm.activeChild.hide();
3502 // private this should really trigger on mouseup..
3503 function onMouseDown(e){
3504 Roo.log("on Mouse Up");
3506 if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".dropdown-menu") && !e.getTarget('.user-menu')){
3507 Roo.log("MenuManager hideAll");
3516 function onBeforeCheck(mi, state){
3518 var g = groups[mi.group];
3519 for(var i = 0, l = g.length; i < l; i++){
3521 g[i].setChecked(false);
3530 * Hides all menus that are currently visible
3532 hideAll : function(){
3537 register : function(menu){
3541 menus[menu.id] = menu;
3542 menu.on("beforehide", onBeforeHide);
3543 menu.on("hide", onHide);
3544 menu.on("beforeshow", onBeforeShow);
3545 menu.on("show", onShow);
3547 if(g && menu.events["checkchange"]){
3551 groups[g].push(menu);
3552 menu.on("checkchange", onCheck);
3557 * Returns a {@link Roo.menu.Menu} object
3558 * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will
3559 * be used to generate and return a new Menu instance.
3561 get : function(menu){
3562 if(typeof menu == "string"){ // menu id
3564 }else if(menu.events){ // menu instance
3567 /*else if(typeof menu.length == 'number'){ // array of menu items?
3568 return new Roo.bootstrap.Menu({items:menu});
3569 }else{ // otherwise, must be a config
3570 return new Roo.bootstrap.Menu(menu);
3577 unregister : function(menu){
3578 delete menus[menu.id];
3579 menu.un("beforehide", onBeforeHide);
3580 menu.un("hide", onHide);
3581 menu.un("beforeshow", onBeforeShow);
3582 menu.un("show", onShow);
3584 if(g && menu.events["checkchange"]){
3585 groups[g].remove(menu);
3586 menu.un("checkchange", onCheck);
3591 registerCheckable : function(menuItem){
3592 var g = menuItem.group;
3597 groups[g].push(menuItem);
3598 menuItem.on("beforecheckchange", onBeforeCheck);
3603 unregisterCheckable : function(menuItem){
3604 var g = menuItem.group;
3606 groups[g].remove(menuItem);
3607 menuItem.un("beforecheckchange", onBeforeCheck);
3619 * @class Roo.bootstrap.Menu
3620 * @extends Roo.bootstrap.Component
3621 * Bootstrap Menu class - container for MenuItems
3622 * @cfg {String} type (dropdown|treeview|submenu) type of menu
3623 * @cfg {bool} hidden if the menu should be hidden when rendered.
3624 * @cfg {bool} stopEvent (true|false) Stop event after trigger press (default true)
3625 * @cfg {bool} isLink (true|false) the menu has link disable auto expand and collaspe (default false)
3626 * @cfg {bool} hideTrigger (true|false) default false - hide the carret for trigger.
3627 * @cfg {String} align default tl-bl? == below - how the menu should be aligned.
3631 * @param {Object} config The config object
3635 Roo.bootstrap.Menu = function(config){
3637 if (config.type == 'treeview') {
3638 // normally menu's are drawn attached to the document to handle layering etc..
3639 // however treeview (used by the docs menu is drawn into the parent element)
3640 this.container_method = 'getChildContainer';
3643 Roo.bootstrap.Menu.superclass.constructor.call(this, config);
3644 if (this.registerMenu && this.type != 'treeview') {
3645 Roo.bootstrap.MenuMgr.register(this);
3652 * Fires before this menu is displayed (return false to block)
3653 * @param {Roo.menu.Menu} this
3658 * Fires before this menu is hidden (return false to block)
3659 * @param {Roo.menu.Menu} this
3664 * Fires after this menu is displayed
3665 * @param {Roo.menu.Menu} this
3670 * Fires after this menu is hidden
3671 * @param {Roo.menu.Menu} this
3676 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
3677 * @param {Roo.menu.Menu} this
3678 * @param {Roo.menu.Item} menuItem The menu item that was clicked
3679 * @param {Roo.EventObject} e
3684 * Fires when the mouse is hovering over this menu
3685 * @param {Roo.menu.Menu} this
3686 * @param {Roo.EventObject} e
3687 * @param {Roo.menu.Item} menuItem The menu item that was clicked
3692 * Fires when the mouse exits this menu
3693 * @param {Roo.menu.Menu} this
3694 * @param {Roo.EventObject} e
3695 * @param {Roo.menu.Item} menuItem The menu item that was clicked
3700 * Fires when a menu item contained in this menu is clicked
3701 * @param {Roo.menu.BaseItem} baseItem The BaseItem that was clicked
3702 * @param {Roo.EventObject} e
3706 this.menuitems = new Roo.util.MixedCollection(false, function(o) { return o.el.id; });
3709 Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, {
3713 triggerEl : false, // is this set by component builder? -- it should really be fetched from parent()???
3716 * @cfg {Boolean} registerMenu True (default) - means that clicking on screen etc. hides it.
3718 registerMenu : true,
3720 menuItems :false, // stores the menu items..
3730 container_method : 'getDocumentBody', // so the menu is rendered on the body and zIndex works.
3732 hideTrigger : false,
3737 getChildContainer : function() {
3741 getAutoCreate : function(){
3743 //if (['right'].indexOf(this.align)!==-1) {
3744 // cfg.cn[1].cls += ' pull-right'
3749 cls : 'dropdown-menu shadow' ,
3750 style : 'z-index:1000'
3754 if (this.type === 'submenu') {
3755 cfg.cls = 'submenu active';
3757 if (this.type === 'treeview') {
3758 cfg.cls = 'treeview-menu';
3763 initEvents : function() {
3765 // Roo.log("ADD event");
3766 // Roo.log(this.triggerEl.dom);
3767 if (this.triggerEl) {
3769 this.triggerEl.on('click', this.onTriggerClick, this);
3771 this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this);
3773 if (!this.hideTrigger) {
3774 if (this.triggerEl.hasClass('nav-item') && this.triggerEl.select('.nav-link',true).length) {
3775 // dropdown toggle on the 'a' in BS4?
3776 this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle');
3778 this.triggerEl.addClass('dropdown-toggle');
3784 this.el.on('touchstart' , this.onTouch, this);
3786 this.el.on('click' , this.onClick, this);
3788 this.el.on("mouseover", this.onMouseOver, this);
3789 this.el.on("mouseout", this.onMouseOut, this);
3793 findTargetItem : function(e)
3795 var t = e.getTarget(".dropdown-menu-item", this.el, true);
3799 //Roo.log(t); Roo.log(t.id);
3801 //Roo.log(this.menuitems);
3802 return this.menuitems.get(t.id);
3804 //return this.items.get(t.menuItemId);
3810 onTouch : function(e)
3812 Roo.log("menu.onTouch");
3813 //e.stopEvent(); this make the user popdown broken
3817 onClick : function(e)
3819 Roo.log("menu.onClick");
3821 var t = this.findTargetItem(e);
3822 if(!t || t.isContainer){
3827 if (Roo.isTouch && e.type == 'touchstart' && t.menu && !t.disabled) {
3828 if(t == this.activeItem && t.shouldDeactivate(e)){
3829 this.activeItem.deactivate();
3830 delete this.activeItem;
3834 this.setActiveItem(t, true);
3842 Roo.log('pass click event');
3846 this.fireEvent("click", this, t, e);
3850 if(!t.href.length || t.href == '#'){
3851 (function() { _this.hide(); }).defer(100);
3856 onMouseOver : function(e){
3857 var t = this.findTargetItem(e);
3860 // if(t.canActivate && !t.disabled){
3861 // this.setActiveItem(t, true);
3865 this.fireEvent("mouseover", this, e, t);
3867 isVisible : function(){
3868 return !this.hidden;
3870 onMouseOut : function(e){
3871 var t = this.findTargetItem(e);
3874 // if(t == this.activeItem && t.shouldDeactivate(e)){
3875 // this.activeItem.deactivate();
3876 // delete this.activeItem;
3879 this.fireEvent("mouseout", this, e, t);
3884 * Displays this menu relative to another element
3885 * @param {String/HTMLElement/Roo.Element} element The element to align to
3886 * @param {String} position (optional) The {@link Roo.Element#alignTo} anchor position to use in aligning to
3887 * the element (defaults to this.defaultAlign)
3888 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
3890 show : function(el, pos, parentMenu)
3892 if (false === this.fireEvent("beforeshow", this)) {
3893 Roo.log("show canceled");
3896 this.parentMenu = parentMenu;
3900 this.el.addClass('show'); // show otherwise we do not know how big we are..
3902 var xy = this.el.getAlignToXY(el, pos);
3904 // bl-tl << left align below
3905 // tl-bl << left align
3907 if(this.el.getWidth() + xy[0] >= Roo.lib.Dom.getViewWidth()){
3908 // if it goes to far to the right.. -> align left.
3909 xy = this.el.getAlignToXY(el, this.align.replace('/l/g', 'r'))
3912 // was left align - go right?
3913 xy = this.el.getAlignToXY(el, this.align.replace('/r/g', 'l'))
3916 // goes down the bottom
3917 if(this.el.getHeight() + xy[1] >= Roo.lib.Dom.getViewHeight() ||
3919 var a = this.align.replace('?', '').split('-');
3920 xy = this.el.getAlignToXY(el, a[1] + '-' + a[0] + '?')
3924 this.showAt( xy , parentMenu, false);
3927 * Displays this menu at a specific xy position
3928 * @param {Array} xyPosition Contains X & Y [x, y] values for the position at which to show the menu (coordinates are page-based)
3929 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
3931 showAt : function(xy, parentMenu, /* private: */_e){
3932 this.parentMenu = parentMenu;
3937 this.fireEvent("beforeshow", this);
3938 //xy = this.el.adjustForConstraints(xy);
3942 this.hideMenuItems();
3943 this.hidden = false;
3944 if (this.triggerEl) {
3945 this.triggerEl.addClass('open');
3948 this.el.addClass('show');
3952 // reassign x when hitting right
3954 // reassign y when hitting bottom
3956 // but the list may align on trigger left or trigger top... should it be a properity?
3958 if(this.el.getStyle('top') != 'auto' && this.el.getStyle('top').slice(-1) != "%"){
3963 this.fireEvent("show", this);
3969 this.doFocus.defer(50, this);
3973 doFocus : function(){
3975 this.focusEl.focus();
3980 * Hides this menu and optionally all parent menus
3981 * @param {Boolean} deep (optional) True to hide all parent menus recursively, if any (defaults to false)
3983 hide : function(deep)
3985 if (false === this.fireEvent("beforehide", this)) {
3986 Roo.log("hide canceled");
3989 this.hideMenuItems();
3990 if(this.el && this.isVisible()){
3992 if(this.activeItem){
3993 this.activeItem.deactivate();
3994 this.activeItem = null;
3996 if (this.triggerEl) {
3997 this.triggerEl.removeClass('open');
4000 this.el.removeClass('show');
4002 this.fireEvent("hide", this);
4004 if(deep === true && this.parentMenu){
4005 this.parentMenu.hide(true);
4009 onTriggerClick : function(e)
4011 Roo.log('trigger click');
4013 var target = e.getTarget();
4015 Roo.log(target.nodeName.toLowerCase());
4017 if(target.nodeName.toLowerCase() === 'i'){
4023 onTriggerPress : function(e)
4025 Roo.log('trigger press');
4026 //Roo.log(e.getTarget());
4027 // Roo.log(this.triggerEl.dom);
4029 // trigger only occurs on normal menu's -- if it's a treeview or dropdown... do not hide/show..
4030 var pel = Roo.get(e.getTarget());
4031 if (pel.findParent('.dropdown-menu') || pel.findParent('.treeview-menu') ) {
4032 Roo.log('is treeview or dropdown?');
4036 if(e.getTarget().nodeName.toLowerCase() !== 'i' && this.isLink){
4040 if (this.isVisible()) {
4046 this.show(this.triggerEl, this.align, false);
4049 if(this.stopEvent || e.getTarget().nodeName.toLowerCase() === 'i'){
4056 hideMenuItems : function()
4058 Roo.log("hide Menu Items");
4063 this.el.select('.open',true).each(function(aa) {
4065 aa.removeClass('open');
4069 addxtypeChild : function (tree, cntr) {
4070 var comp= Roo.bootstrap.Menu.superclass.addxtypeChild.call(this, tree, cntr);
4072 this.menuitems.add(comp);
4084 this.getEl().dom.innerHTML = '';
4085 this.menuitems.clear();
4099 * @class Roo.bootstrap.MenuItem
4100 * @extends Roo.bootstrap.Component
4101 * Bootstrap MenuItem class
4102 * @cfg {String} html the menu label
4103 * @cfg {String} href the link
4104 * @cfg {Boolean} preventDefault do not trigger A href on clicks (default false).
4105 * @cfg {Boolean} isContainer is it a container - just returns a drop down item..
4106 * @cfg {Boolean} active used on sidebars to highlight active itesm
4107 * @cfg {String} fa favicon to show on left of menu item.
4108 * @cfg {Roo.bootsrap.Menu} menu the child menu.
4112 * Create a new MenuItem
4113 * @param {Object} config The config object
4117 Roo.bootstrap.MenuItem = function(config){
4118 Roo.bootstrap.MenuItem.superclass.constructor.call(this, config);
4123 * The raw click event for the entire grid.
4124 * @param {Roo.bootstrap.MenuItem} this
4125 * @param {Roo.EventObject} e
4131 Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component, {
4135 preventDefault: false,
4136 isContainer : false,
4140 getAutoCreate : function(){
4142 if(this.isContainer){
4145 cls: 'dropdown-menu-item '
4155 cls : 'dropdown-item',
4160 if (this.fa !== false) {
4163 cls : 'fa fa-' + this.fa
4172 cls: 'dropdown-menu-item',
4175 if (this.parent().type == 'treeview') {
4176 cfg.cls = 'treeview-menu';
4179 cfg.cls += ' active';
4184 anc.href = this.href || cfg.cn[0].href ;
4185 ctag.html = this.html || cfg.cn[0].html ;
4189 initEvents: function()
4191 if (this.parent().type == 'treeview') {
4192 this.el.select('a').on('click', this.onClick, this);
4196 this.menu.parentType = this.xtype;
4197 this.menu.triggerEl = this.el;
4198 this.menu = this.addxtype(Roo.apply({}, this.menu));
4202 onClick : function(e)
4204 Roo.log('item on click ');
4206 if(this.preventDefault){
4209 //this.parent().hideMenuItems();
4211 this.fireEvent('click', this, e);
4230 * @class Roo.bootstrap.MenuSeparator
4231 * @extends Roo.bootstrap.Component
4232 * Bootstrap MenuSeparator class
4235 * Create a new MenuItem
4236 * @param {Object} config The config object
4240 Roo.bootstrap.MenuSeparator = function(config){
4241 Roo.bootstrap.MenuSeparator.superclass.constructor.call(this, config);
4244 Roo.extend(Roo.bootstrap.MenuSeparator, Roo.bootstrap.Component, {
4246 getAutoCreate : function(){
4265 * @class Roo.bootstrap.Modal
4266 * @extends Roo.bootstrap.Component
4269 * @children Roo.bootstrap.Component
4270 * Bootstrap Modal class
4271 * @cfg {String} title Title of dialog
4272 * @cfg {String} html - the body of the dialog (for simple ones) - you can also use template..
4273 * @cfg {Roo.Template} tmpl - a template with variables. to use it, add a handler in show:method adn
4274 * @cfg {Boolean} specificTitle default false
4275 * @cfg {Array} buttons Array of buttons or standard button set..
4276 * @cfg {String} buttonPosition (left|right|center) default right (DEPRICATED) - use mr-auto on buttons to put them on the left
4277 * @cfg {Boolean} animate default true
4278 * @cfg {Boolean} allow_close default true
4279 * @cfg {Boolean} fitwindow default false
4280 * @cfg {Boolean} bodyOverflow should the body element have overflow auto added default false
4281 * @cfg {Number} width fixed width - usefull for chrome extension only really.
4282 * @cfg {Number} height fixed height - usefull for chrome extension only really.
4283 * @cfg {String} size (sm|lg|xl) default empty
4284 * @cfg {Number} max_width set the max width of modal
4285 * @cfg {Boolean} editableTitle can the title be edited
4290 * Create a new Modal Dialog
4291 * @param {Object} config The config object
4294 Roo.bootstrap.Modal = function(config){
4295 Roo.bootstrap.Modal.superclass.constructor.call(this, config);
4300 * The raw btnclick event for the button
4301 * @param {Roo.EventObject} e
4306 * Fire when dialog resize
4307 * @param {Roo.bootstrap.Modal} this
4308 * @param {Roo.EventObject} e
4312 * @event titlechanged
4313 * Fire when the editable title has been changed
4314 * @param {Roo.bootstrap.Modal} this
4315 * @param {Roo.EventObject} value
4317 "titlechanged" : true
4320 this.buttons = this.buttons || [];
4323 this.tmpl = Roo.factory(this.tmpl);
4328 Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, {
4330 title : 'test dialog',
4340 specificTitle: false,
4342 buttonPosition: 'right',
4364 editableTitle : false,
4366 onRender : function(ct, position)
4368 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
4371 var cfg = Roo.apply({}, this.getAutoCreate());
4374 // cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
4376 //if (!cfg.name.length) {
4380 cfg.cls += ' ' + this.cls;
4383 cfg.style = this.style;
4385 this.el = Roo.get(document.body).createChild(cfg, position);
4387 //var type = this.el.dom.type;
4390 if(this.tabIndex !== undefined){
4391 this.el.dom.setAttribute('tabIndex', this.tabIndex);
4394 this.dialogEl = this.el.select('.modal-dialog',true).first();
4395 this.bodyEl = this.el.select('.modal-body',true).first();
4396 this.closeEl = this.el.select('.modal-header .close', true).first();
4397 this.headerEl = this.el.select('.modal-header',true).first();
4398 this.titleEl = this.el.select('.modal-title',true).first();
4399 this.footerEl = this.el.select('.modal-footer',true).first();
4401 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
4403 //this.el.addClass("x-dlg-modal");
4405 if (this.buttons.length) {
4406 Roo.each(this.buttons, function(bb) {
4407 var b = Roo.apply({}, bb);
4408 b.xns = b.xns || Roo.bootstrap;
4409 b.xtype = b.xtype || 'Button';
4410 if (typeof(b.listeners) == 'undefined') {
4411 b.listeners = { click : this.onButtonClick.createDelegate(this) };
4414 var btn = Roo.factory(b);
4416 btn.render(this.getButtonContainer());
4420 // render the children.
4423 if(typeof(this.items) != 'undefined'){
4424 var items = this.items;
4427 for(var i =0;i < items.length;i++) {
4428 nitems.push(this.addxtype(Roo.apply({}, items[i])));
4432 this.items = nitems;
4434 // where are these used - they used to be body/close/footer
4438 //this.el.addClass([this.fieldClass, this.cls]);
4442 getAutoCreate : function()
4444 // we will default to modal-body-overflow - might need to remove or make optional later.
4446 cls : 'modal-body ' + (this.bodyOverflow ? 'overflow-auto' : ''),
4447 html : this.html || ''
4452 cls : 'modal-title',
4456 if(this.specificTitle){ // WTF is this?
4461 if (this.allow_close && Roo.bootstrap.version == 3) {
4471 if (this.editableTitle) {
4473 cls: 'form-control roo-editable-title d-none',
4479 if (this.allow_close && Roo.bootstrap.version == 4) {
4489 if(this.size.length){
4490 size = 'modal-' + this.size;
4493 var footer = Roo.bootstrap.version == 3 ?
4495 cls : 'modal-footer',
4499 cls: 'btn-' + this.buttonPosition
4504 { // BS4 uses mr-auto on left buttons....
4505 cls : 'modal-footer'
4516 cls: "modal-dialog " + size,
4519 cls : "modal-content",
4522 cls : 'modal-header',
4537 modal.cls += ' fade';
4543 getChildContainer : function() {
4548 getButtonContainer : function() {
4550 return Roo.bootstrap.version == 4 ?
4551 this.el.select('.modal-footer',true).first()
4552 : this.el.select('.modal-footer div',true).first();
4555 initEvents : function()
4557 if (this.allow_close) {
4558 this.closeEl.on('click', this.hide, this);
4560 Roo.EventManager.onWindowResize(this.resize, this, true);
4561 if (this.editableTitle) {
4562 this.headerEditEl = this.headerEl.select('.form-control',true).first();
4563 this.headerEl.on('click', function() { this.toggleHeaderInput(true) } , this);
4564 this.headerEditEl.on('keyup', function(e) {
4565 if([ e.RETURN , e.TAB , e.ESC ].indexOf(e.keyCode) > -1) {
4566 this.toggleHeaderInput(false)
4569 this.headerEditEl.on('blur', function(e) {
4570 this.toggleHeaderInput(false)
4579 this.maskEl.setSize(
4580 Roo.lib.Dom.getViewWidth(true),
4581 Roo.lib.Dom.getViewHeight(true)
4584 if (this.fitwindow) {
4586 this.dialogEl.setStyle( { 'max-width' : '100%' });
4588 this.width || Roo.lib.Dom.getViewportWidth(true) - 30,
4589 this.height || Roo.lib.Dom.getViewportHeight(true) // catering margin-top 30 margin-bottom 30
4594 if(this.max_width !== 0) {
4596 var w = Math.min(this.max_width, Roo.lib.Dom.getViewportWidth(true) - 30);
4599 this.setSize(w, this.height);
4603 if(this.max_height) {
4604 this.setSize(w,Math.min(
4606 Roo.lib.Dom.getViewportHeight(true) - 60
4612 if(!this.fit_content) {
4613 this.setSize(w, Roo.lib.Dom.getViewportHeight(true) - 60);
4617 this.setSize(w, Math.min(
4619 this.headerEl.getHeight() +
4620 this.footerEl.getHeight() +
4621 this.getChildHeight(this.bodyEl.dom.childNodes),
4622 Roo.lib.Dom.getViewportHeight(true) - 60)
4628 setSize : function(w,h)
4639 if (!this.rendered) {
4642 this.toggleHeaderInput(false);
4643 //this.el.setStyle('display', 'block');
4644 this.el.removeClass('hideing');
4645 this.el.dom.style.display='block';
4647 Roo.get(document.body).addClass('modal-open');
4649 if(this.animate){ // element has 'fade' - so stuff happens after .3s ?- not sure why the delay?
4652 this.el.addClass('show');
4653 this.el.addClass('in');
4656 this.el.addClass('show');
4657 this.el.addClass('in');
4660 // not sure how we can show data in here..
4662 // this.getChildContainer().dom.innerHTML = this.tmpl.applyTemplate(this);
4665 Roo.get(document.body).addClass("x-body-masked");
4667 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
4668 this.maskEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
4669 this.maskEl.dom.style.display = 'block';
4670 this.maskEl.addClass('show');
4675 this.fireEvent('show', this);
4677 // set zindex here - otherwise it appears to be ignored...
4678 this.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
4681 this.items.forEach( function(e) {
4682 e.layout ? e.layout() : false;
4690 if(this.fireEvent("beforehide", this) !== false){
4692 this.maskEl.removeClass('show');
4694 this.maskEl.dom.style.display = '';
4695 Roo.get(document.body).removeClass("x-body-masked");
4696 this.el.removeClass('in');
4697 this.el.select('.modal-dialog', true).first().setStyle('transform','');
4699 if(this.animate){ // why
4700 this.el.addClass('hideing');
4701 this.el.removeClass('show');
4703 if (!this.el.hasClass('hideing')) {
4704 return; // it's been shown again...
4707 this.el.dom.style.display='';
4709 Roo.get(document.body).removeClass('modal-open');
4710 this.el.removeClass('hideing');
4714 this.el.removeClass('show');
4715 this.el.dom.style.display='';
4716 Roo.get(document.body).removeClass('modal-open');
4719 this.fireEvent('hide', this);
4722 isVisible : function()
4725 return this.el.hasClass('show') && !this.el.hasClass('hideing');
4729 addButton : function(str, cb)
4733 var b = Roo.apply({}, { html : str } );
4734 b.xns = b.xns || Roo.bootstrap;
4735 b.xtype = b.xtype || 'Button';
4736 if (typeof(b.listeners) == 'undefined') {
4737 b.listeners = { click : cb.createDelegate(this) };
4740 var btn = Roo.factory(b);
4742 btn.render(this.getButtonContainer());
4748 setDefaultButton : function(btn)
4750 //this.el.select('.modal-footer').()
4753 resizeTo: function(w,h)
4755 this.dialogEl.setWidth(w);
4757 var diff = this.headerEl.getHeight() + this.footerEl.getHeight() + 60; // dialog margin-bottom: 30
4759 this.bodyEl.setHeight(h - diff);
4761 this.fireEvent('resize', this);
4764 setContentSize : function(w, h)
4768 onButtonClick: function(btn,e)
4771 this.fireEvent('btnclick', btn.name, e);
4774 * Set the title of the Dialog
4775 * @param {String} str new Title
4777 setTitle: function(str) {
4778 this.titleEl.dom.innerHTML = str;
4782 * Set the body of the Dialog
4783 * @param {String} str new Title
4785 setBody: function(str) {
4786 this.bodyEl.dom.innerHTML = str;
4789 * Set the body of the Dialog using the template
4790 * @param {Obj} data - apply this data to the template and replace the body contents.
4792 applyBody: function(obj)
4795 Roo.log("Error - using apply Body without a template");
4798 this.tmpl.overwrite(this.bodyEl, obj);
4801 getChildHeight : function(child_nodes)
4805 child_nodes.length == 0
4810 var child_height = 0;
4812 for(var i = 0; i < child_nodes.length; i++) {
4815 * for modal with tabs...
4816 if(child_nodes[i].classList.contains('roo-layout-panel')) {
4818 var layout_childs = child_nodes[i].childNodes;
4820 for(var j = 0; j < layout_childs.length; j++) {
4822 if(layout_childs[j].classList.contains('roo-layout-panel-body')) {
4824 var layout_body_childs = layout_childs[j].childNodes;
4826 for(var k = 0; k < layout_body_childs.length; k++) {
4828 if(layout_body_childs[k].classList.contains('navbar')) {
4829 child_height += layout_body_childs[k].offsetHeight;
4833 if(layout_body_childs[k].classList.contains('roo-layout-tabs-body')) {
4835 var layout_body_tab_childs = layout_body_childs[k].childNodes;
4837 for(var m = 0; m < layout_body_tab_childs.length; m++) {
4839 if(layout_body_tab_childs[m].classList.contains('roo-layout-active-content')) {
4840 child_height += this.getChildHeight(layout_body_tab_childs[m].childNodes);
4855 child_height += child_nodes[i].offsetHeight;
4856 // Roo.log(child_nodes[i].offsetHeight);
4859 return child_height;
4861 toggleHeaderInput : function(is_edit)
4863 if (!this.editableTitle) {
4864 return; // not editable.
4866 if (is_edit && this.is_header_editing) {
4867 return; // already editing..
4871 this.headerEditEl.dom.value = this.title;
4872 this.headerEditEl.removeClass('d-none');
4873 this.headerEditEl.dom.focus();
4874 this.titleEl.addClass('d-none');
4876 this.is_header_editing = true;
4879 // flip back to not editing.
4880 this.title = this.headerEditEl.dom.value;
4881 this.headerEditEl.addClass('d-none');
4882 this.titleEl.removeClass('d-none');
4883 this.titleEl.dom.innerHTML = String.format('{0}', this.title);
4884 this.is_header_editing = false;
4885 this.fireEvent('titlechanged', this, this.title);
4894 Roo.apply(Roo.bootstrap.Modal, {
4896 * Button config that displays a single OK button
4905 * Button config that displays Yes and No buttons
4921 * Button config that displays OK and Cancel buttons
4936 * Button config that displays Yes, No and Cancel buttons
4961 * messagebox - can be used as a replace
4965 * @class Roo.MessageBox
4966 * Utility class for generating different styles of message boxes. The alias Roo.Msg can also be used.
4970 Roo.Msg.alert('Status', 'Changes saved successfully.');
4972 // Prompt for user data:
4973 Roo.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
4975 // process text value...
4979 // Show a dialog using config options:
4981 title:'Save Changes?',
4982 msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',
4983 buttons: Roo.Msg.YESNOCANCEL,
4990 Roo.bootstrap.MessageBox = function(){
4991 var dlg, opt, mask, waitTimer;
4992 var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp;
4993 var buttons, activeTextEl, bwidth;
4997 var handleButton = function(button){
4999 Roo.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
5003 var handleHide = function(){
5005 dlg.el.removeClass(opt.cls);
5008 // Roo.TaskMgr.stop(waitTimer);
5009 // waitTimer = null;
5014 var updateButtons = function(b){
5017 buttons["ok"].hide();
5018 buttons["cancel"].hide();
5019 buttons["yes"].hide();
5020 buttons["no"].hide();
5021 dlg.footerEl.hide();
5025 dlg.footerEl.show();
5026 for(var k in buttons){
5027 if(typeof buttons[k] != "function"){
5030 buttons[k].setText(typeof b[k] == "string" ? b[k] : Roo.bootstrap.MessageBox.buttonText[k]);
5031 width += buttons[k].el.getWidth()+15;
5041 var handleEsc = function(d, k, e){
5042 if(opt && opt.closable !== false){
5052 * Returns a reference to the underlying {@link Roo.BasicDialog} element
5053 * @return {Roo.BasicDialog} The BasicDialog element
5055 getDialog : function(){
5057 dlg = new Roo.bootstrap.Modal( {
5060 //constraintoviewport:false,
5062 //collapsible : false,
5067 //buttonAlign:"center",
5068 closeClick : function(){
5069 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
5072 handleButton("cancel");
5077 dlg.on("hide", handleHide);
5079 //dlg.addKeyListener(27, handleEsc);
5081 this.buttons = buttons;
5082 var bt = this.buttonText;
5083 buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
5084 buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
5085 buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
5086 buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
5088 bodyEl = dlg.bodyEl.createChild({
5090 html:'<span class="roo-mb-text"></span><br /><input type="text" class="roo-mb-input" />' +
5091 '<textarea class="roo-mb-textarea"></textarea>' +
5092 '<div class="roo-mb-progress-wrap"><div class="roo-mb-progress"><div class="roo-mb-progress-bar"> </div></div></div>'
5094 msgEl = bodyEl.dom.firstChild;
5095 textboxEl = Roo.get(bodyEl.dom.childNodes[2]);
5096 textboxEl.enableDisplayMode();
5097 textboxEl.addKeyListener([10,13], function(){
5098 if(dlg.isVisible() && opt && opt.buttons){
5101 }else if(opt.buttons.yes){
5102 handleButton("yes");
5106 textareaEl = Roo.get(bodyEl.dom.childNodes[3]);
5107 textareaEl.enableDisplayMode();
5108 progressEl = Roo.get(bodyEl.dom.childNodes[4]);
5109 progressEl.enableDisplayMode();
5111 // This is supposed to be the progessElement.. but I think it's controlling the height of everything..
5112 var pf = progressEl.dom.firstChild;
5114 pp = Roo.get(pf.firstChild);
5115 pp.setHeight(pf.offsetHeight);
5123 * Updates the message box body text
5124 * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
5125 * the XHTML-compliant non-breaking space character '&#160;')
5126 * @return {Roo.MessageBox} This message box
5128 updateText : function(text)
5130 if(!dlg.isVisible() && !opt.width){
5131 dlg.dialogEl.setStyle({ 'max-width' : this.maxWidth});
5132 // dlg.resizeTo(this.maxWidth, 100); // forcing the height breaks long alerts()
5134 msgEl.innerHTML = text || ' ';
5136 var cw = Math.max(msgEl.offsetWidth, msgEl.parentNode.scrollWidth);
5137 //Roo.log("guesed size: " + JSON.stringify([cw,msgEl.offsetWidth, msgEl.parentNode.scrollWidth]));
5139 Math.min(opt.width || cw , this.maxWidth),
5140 Math.max(opt.minWidth || this.minWidth, bwidth)
5143 activeTextEl.setWidth(w);
5145 if(dlg.isVisible()){
5146 dlg.fixedcenter = false;
5148 // to big, make it scroll. = But as usual stupid IE does not support
5151 if ( bodyEl.getHeight() > (Roo.lib.Dom.getViewHeight() - 100)) {
5152 bodyEl.setHeight ( Roo.lib.Dom.getViewHeight() - 100 );
5153 bodyEl.dom.style.overflowY = 'auto' + ( Roo.isIE ? '' : ' !important');
5155 bodyEl.dom.style.height = '';
5156 bodyEl.dom.style.overflowY = '';
5159 bodyEl.dom.style.get = 'auto' + ( Roo.isIE ? '' : ' !important');
5161 bodyEl.dom.style.overflowX = '';
5164 dlg.setContentSize(w, bodyEl.getHeight());
5165 if(dlg.isVisible()){
5166 dlg.fixedcenter = true;
5172 * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
5173 * initiated via {@link Roo.MessageBox#progress} or by calling {@link Roo.MessageBox#show} with progress: true.
5174 * @param {Number} value Any number between 0 and 1 (e.g., .5)
5175 * @param {String} text (optional) If defined, the message box's body text is replaced with the specified string (defaults to undefined)
5176 * @return {Roo.MessageBox} This message box
5178 updateProgress : function(value, text){
5180 this.updateText(text);
5183 if (pp) { // weird bug on my firefox - for some reason this is not defined
5184 pp.setWidth(Math.floor(value*progressEl.dom.firstChild.offsetWidth));
5185 pp.setHeight(Math.floor(progressEl.dom.firstChild.offsetHeight));
5191 * Returns true if the message box is currently displayed
5192 * @return {Boolean} True if the message box is visible, else false
5194 isVisible : function(){
5195 return dlg && dlg.isVisible();
5199 * Hides the message box if it is displayed
5202 if(this.isVisible()){
5208 * Displays a new message box, or reinitializes an existing message box, based on the config options
5209 * passed in. All functions (e.g. prompt, alert, etc) on MessageBox call this function internally.
5210 * The following config object properties are supported:
5212 Property Type Description
5213 ---------- --------------- ------------------------------------------------------------------------------------
5214 animEl String/Element An id or Element from which the message box should animate as it opens and
5215 closes (defaults to undefined)
5216 buttons Object/Boolean A button config object (e.g., Roo.MessageBox.OKCANCEL or {ok:'Foo',
5217 cancel:'Bar'}), or false to not show any buttons (defaults to false)
5218 closable Boolean False to hide the top-right close button (defaults to true). Note that
5219 progress and wait dialogs will ignore this property and always hide the
5220 close button as they can only be closed programmatically.
5221 cls String A custom CSS class to apply to the message box element
5222 defaultTextHeight Number The default height in pixels of the message box's multiline textarea if
5223 displayed (defaults to 75)
5224 fn Function A callback function to execute after closing the dialog. The arguments to the
5225 function will be btn (the name of the button that was clicked, if applicable,
5226 e.g. "ok"), and text (the value of the active text field, if applicable).
5227 Progress and wait dialogs will ignore this option since they do not respond to
5228 user actions and can only be closed programmatically, so any required function
5229 should be called by the same code after it closes the dialog.
5230 icon String A CSS class that provides a background image to be used as an icon for
5231 the dialog (e.g., Roo.MessageBox.WARNING or 'custom-class', defaults to '')
5232 maxWidth Number The maximum width in pixels of the message box (defaults to 600)
5233 minWidth Number The minimum width in pixels of the message box (defaults to 100)
5234 modal Boolean False to allow user interaction with the page while the message box is
5235 displayed (defaults to true)
5236 msg String A string that will replace the existing message box body text (defaults
5237 to the XHTML-compliant non-breaking space character ' ')
5238 multiline Boolean True to prompt the user to enter multi-line text (defaults to false)
5239 progress Boolean True to display a progress bar (defaults to false)
5240 progressText String The text to display inside the progress bar if progress = true (defaults to '')
5241 prompt Boolean True to prompt the user to enter single-line text (defaults to false)
5242 proxyDrag Boolean True to display a lightweight proxy while dragging (defaults to false)
5243 title String The title text
5244 value String The string value to set into the active textbox element if displayed
5245 wait Boolean True to display a progress bar (defaults to false)
5246 width Number The width of the dialog in pixels
5253 msg: 'Please enter your address:',
5255 buttons: Roo.MessageBox.OKCANCEL,
5258 animEl: 'addAddressBtn'
5261 * @param {Object} config Configuration options
5262 * @return {Roo.MessageBox} This message box
5264 show : function(options)
5267 // this causes nightmares if you show one dialog after another
5268 // especially on callbacks..
5270 if(this.isVisible()){
5273 Roo.log("[Roo.Messagebox] Show called while message displayed:" );
5274 Roo.log("Old Dialog Message:" + msgEl.innerHTML );
5275 Roo.log("New Dialog Message:" + options.msg )
5276 //this.alert("ERROR", "Multiple dialogs where displayed at the same time");
5277 //throw "Roo.MessageBox ERROR : Multiple dialogs where displayed at the same time";
5280 var d = this.getDialog();
5282 d.setTitle(opt.title || " ");
5283 d.closeEl.setDisplayed(opt.closable !== false);
5284 activeTextEl = textboxEl;
5285 opt.prompt = opt.prompt || (opt.multiline ? true : false);
5290 textareaEl.setHeight(typeof opt.multiline == "number" ?
5291 opt.multiline : this.defaultTextHeight);
5292 activeTextEl = textareaEl;
5301 progressEl.setDisplayed(opt.progress === true);
5303 d.animate = false; // do not animate progress, as it may not have finished animating before we close it..
5305 this.updateProgress(0);
5306 activeTextEl.dom.value = opt.value || "";
5308 dlg.setDefaultButton(activeTextEl);
5310 var bs = opt.buttons;
5314 }else if(bs && bs.yes){
5315 db = buttons["yes"];
5317 dlg.setDefaultButton(db);
5319 bwidth = updateButtons(opt.buttons);
5320 this.updateText(opt.msg);
5322 d.el.addClass(opt.cls);
5324 d.proxyDrag = opt.proxyDrag === true;
5325 d.modal = opt.modal !== false;
5326 d.mask = opt.modal !== false ? mask : false;
5328 // force it to the end of the z-index stack so it gets a cursor in FF
5329 document.body.appendChild(dlg.el.dom);
5330 d.animateTarget = null;
5331 d.show(options.animEl);
5337 * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
5338 * the user. You are responsible for updating the progress bar as needed via {@link Roo.MessageBox#updateProgress}
5339 * and closing the message box when the process is complete.
5340 * @param {String} title The title bar text
5341 * @param {String} msg The message box body text
5342 * @return {Roo.MessageBox} This message box
5344 progress : function(title, msg){
5351 minWidth: this.minProgressWidth,
5358 * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
5359 * If a callback function is passed it will be called after the user clicks the button, and the
5360 * id of the button that was clicked will be passed as the only parameter to the callback
5361 * (could also be the top-right close button).
5362 * @param {String} title The title bar text
5363 * @param {String} msg The message box body text
5364 * @param {Function} fn (optional) The callback function invoked after the message box is closed
5365 * @param {Object} scope (optional) The scope of the callback function
5366 * @return {Roo.MessageBox} This message box
5368 alert : function(title, msg, fn, scope)
5383 * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
5384 * interaction while waiting for a long-running process to complete that does not have defined intervals.
5385 * You are responsible for closing the message box when the process is complete.
5386 * @param {String} msg The message box body text
5387 * @param {String} title (optional) The title bar text
5388 * @return {Roo.MessageBox} This message box
5390 wait : function(msg, title){
5401 waitTimer = Roo.TaskMgr.start({
5403 Roo.MessageBox.updateProgress(((((i+20)%20)+1)*5)*.01);
5411 * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
5412 * If a callback function is passed it will be called after the user clicks either button, and the id of the
5413 * button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
5414 * @param {String} title The title bar text
5415 * @param {String} msg The message box body text
5416 * @param {Function} fn (optional) The callback function invoked after the message box is closed
5417 * @param {Object} scope (optional) The scope of the callback function
5418 * @return {Roo.MessageBox} This message box
5420 confirm : function(title, msg, fn, scope){
5424 buttons: this.YESNO,
5433 * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to
5434 * JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function
5435 * is passed it will be called after the user clicks either button, and the id of the button that was clicked
5436 * (could also be the top-right close button) and the text that was entered will be passed as the two
5437 * parameters to the callback.
5438 * @param {String} title The title bar text
5439 * @param {String} msg The message box body text
5440 * @param {Function} fn (optional) The callback function invoked after the message box is closed
5441 * @param {Object} scope (optional) The scope of the callback function
5442 * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
5443 * property, or the height in pixels to create the textbox (defaults to false / single-line)
5444 * @return {Roo.MessageBox} This message box
5446 prompt : function(title, msg, fn, scope, multiline){
5450 buttons: this.OKCANCEL,
5455 multiline: multiline,
5462 * Button config that displays a single OK button
5467 * Button config that displays Yes and No buttons
5470 YESNO : {yes:true, no:true},
5472 * Button config that displays OK and Cancel buttons
5475 OKCANCEL : {ok:true, cancel:true},
5477 * Button config that displays Yes, No and Cancel buttons
5480 YESNOCANCEL : {yes:true, no:true, cancel:true},
5483 * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
5486 defaultTextHeight : 75,
5488 * The maximum width in pixels of the message box (defaults to 600)
5493 * The minimum width in pixels of the message box (defaults to 100)
5498 * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
5499 * for setting a different minimum width than text-only dialogs may need (defaults to 250)
5502 minProgressWidth : 250,
5504 * An object containing the default button text strings that can be overriden for localized language support.
5505 * Supported properties are: ok, cancel, yes and no.
5506 * Customize the default text like so: Roo.MessageBox.buttonText.yes = "S?";
5519 * Shorthand for {@link Roo.MessageBox}
5521 Roo.MessageBox = Roo.MessageBox || Roo.bootstrap.MessageBox;
5522 Roo.Msg = Roo.Msg || Roo.MessageBox;
5531 * @class Roo.bootstrap.Navbar
5532 * @extends Roo.bootstrap.Component
5533 * Bootstrap Navbar class
5536 * Create a new Navbar
5537 * @param {Object} config The config object
5541 Roo.bootstrap.Navbar = function(config){
5542 Roo.bootstrap.Navbar.superclass.constructor.call(this, config);
5546 * @event beforetoggle
5547 * Fire before toggle the menu
5548 * @param {Roo.EventObject} e
5550 "beforetoggle" : true
5554 Roo.extend(Roo.bootstrap.Navbar, Roo.bootstrap.Component, {
5563 getAutoCreate : function(){
5566 throw { message : "nav bar is now a abstract base class - use NavSimplebar / NavHeaderbar / NavSidebar etc..."};
5570 initEvents :function ()
5572 //Roo.log(this.el.select('.navbar-toggle',true));
5573 this.el.select('.navbar-toggle',true).on('click', this.onToggle , this);
5580 this.maskEl = Roo.DomHelper.append(this.el, mark, true);
5582 var size = this.el.getSize();
5583 this.maskEl.setSize(size.width, size.height);
5584 this.maskEl.enableDisplayMode("block");
5593 getChildContainer : function()
5595 if (this.el && this.el.select('.collapse').getCount()) {
5596 return this.el.select('.collapse',true).first();
5611 onToggle : function()
5614 if(this.fireEvent('beforetoggle', this) === false){
5617 var ce = this.el.select('.navbar-collapse',true).first();
5619 if (!ce.hasClass('show')) {
5629 * Expand the navbar pulldown
5631 expand : function ()
5634 var ce = this.el.select('.navbar-collapse',true).first();
5635 if (ce.hasClass('collapsing')) {
5638 ce.dom.style.height = '';
5640 ce.addClass('in'); // old...
5641 ce.removeClass('collapse');
5642 ce.addClass('show');
5643 var h = ce.getHeight();
5645 ce.removeClass('show');
5646 // at this point we should be able to see it..
5647 ce.addClass('collapsing');
5649 ce.setHeight(0); // resize it ...
5650 ce.on('transitionend', function() {
5651 //Roo.log('done transition');
5652 ce.removeClass('collapsing');
5653 ce.addClass('show');
5654 ce.removeClass('collapse');
5656 ce.dom.style.height = '';
5657 }, this, { single: true} );
5659 ce.dom.scrollTop = 0;
5662 * Collapse the navbar pulldown
5664 collapse : function()
5666 var ce = this.el.select('.navbar-collapse',true).first();
5668 if (ce.hasClass('collapsing') || ce.hasClass('collapse') ) {
5669 // it's collapsed or collapsing..
5672 ce.removeClass('in'); // old...
5673 ce.setHeight(ce.getHeight());
5674 ce.removeClass('show');
5675 ce.addClass('collapsing');
5677 ce.on('transitionend', function() {
5678 ce.dom.style.height = '';
5679 ce.removeClass('collapsing');
5680 ce.addClass('collapse');
5681 }, this, { single: true} );
5701 * @class Roo.bootstrap.NavSimplebar
5702 * @extends Roo.bootstrap.Navbar
5703 * Bootstrap Sidebar class
5705 * @cfg {Boolean} inverse is inverted color
5707 * @cfg {String} type (nav | pills | tabs)
5708 * @cfg {Boolean} arrangement stacked | justified
5709 * @cfg {String} align (left | right) alignment
5711 * @cfg {Boolean} main (true|false) main nav bar? default false
5712 * @cfg {Boolean} loadMask (true|false) loadMask on the bar
5714 * @cfg {String} tag (header|footer|nav|div) default is nav
5716 * @cfg {String} weight (light|primary|secondary|success|danger|warning|info|dark|white) default is light.
5720 * Create a new Sidebar
5721 * @param {Object} config The config object
5725 Roo.bootstrap.NavSimplebar = function(config){
5726 Roo.bootstrap.NavSimplebar.superclass.constructor.call(this, config);
5729 Roo.extend(Roo.bootstrap.NavSimplebar, Roo.bootstrap.Navbar, {
5745 getAutoCreate : function(){
5749 tag : this.tag || 'div',
5750 cls : 'navbar roo-navbar-simple' //navbar-expand-lg ??
5752 if (['light','white'].indexOf(this.weight) > -1) {
5753 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
5755 cfg.cls += ' bg-' + this.weight;
5758 cfg.cls += ' navbar-inverse';
5762 // i'm not actually sure these are really used - normally we add a navGroup to a navbar
5764 if (Roo.bootstrap.version == 4 && this.xtype == 'NavSimplebar') {
5773 cls: 'nav nav-' + this.xtype,
5779 this.type = this.type || 'nav';
5780 if (['tabs','pills'].indexOf(this.type) != -1) {
5781 cfg.cn[0].cls += ' nav-' + this.type
5785 if (this.type!=='nav') {
5786 Roo.log('nav type must be nav/tabs/pills')
5788 cfg.cn[0].cls += ' navbar-nav'
5794 if (['stacked','justified'].indexOf(this.arrangement) != -1) {
5795 cfg.cn[0].cls += ' nav-' + this.arrangement;
5799 if (this.align === 'right') {
5800 cfg.cn[0].cls += ' navbar-right';
5825 * navbar-expand-md fixed-top
5829 * @class Roo.bootstrap.NavHeaderbar
5830 * @extends Roo.bootstrap.NavSimplebar
5831 * Bootstrap Sidebar class
5833 * @cfg {String} brand what is brand
5834 * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
5835 * @cfg {String} brand_href href of the brand
5836 * @cfg {Boolean} srButton generate the (screen reader / mobile) sr-only button default true
5837 * @cfg {Boolean} autohide a top nav bar header that hides on scroll.
5838 * @cfg {Boolean} desktopCenter should the header be centered on desktop using a container class
5839 * @cfg {Roo.bootstrap.Row} mobilerow - a row to display on mobile only..
5842 * Create a new Sidebar
5843 * @param {Object} config The config object
5847 Roo.bootstrap.NavHeaderbar = function(config){
5848 Roo.bootstrap.NavHeaderbar.superclass.constructor.call(this, config);
5852 Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar, {
5859 desktopCenter : false,
5862 getAutoCreate : function(){
5865 tag: this.nav || 'nav',
5866 cls: 'navbar navbar-expand-md',
5872 if (this.desktopCenter) {
5873 cn.push({cls : 'container', cn : []});
5881 cls: 'navbar-toggle navbar-toggler',
5882 'data-toggle': 'collapse',
5887 html: 'Toggle navigation'
5891 cls: 'icon-bar navbar-toggler-icon'
5904 cn.push( Roo.bootstrap.version == 4 ? btn : {
5906 cls: 'navbar-header',
5915 cls: Roo.bootstrap.version == 4 ? 'nav flex-row roo-navbar-collapse collapse navbar-collapse' : 'collapse navbar-collapse roo-navbar-collapse',
5919 cfg.cls += this.inverse ? ' navbar-inverse navbar-dark bg-dark' : ' navbar-default';
5921 if (['light','white'].indexOf(this.weight) > -1) {
5922 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
5924 cfg.cls += ' bg-' + this.weight;
5927 if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
5928 cfg.cls += ' navbar-' + this.position + ' ' + this.position ;
5930 // tag can override this..
5932 cfg.tag = this.tag || (this.position == 'fixed-bottom' ? 'footer' : 'header');
5935 if (this.brand !== '') {
5936 var cp = Roo.bootstrap.version == 4 ? cn : cn[0].cn;
5937 cp.unshift({ // changed from push ?? BS4 needs it at the start? - does this break or exsiting?
5939 href: this.brand_href ? this.brand_href : '#',
5940 cls: 'navbar-brand',
5948 cfg.cls += ' main-nav';
5956 getHeaderChildContainer : function()
5958 if (this.srButton && this.el.select('.navbar-header').getCount()) {
5959 return this.el.select('.navbar-header',true).first();
5962 return this.getChildContainer();
5965 getChildContainer : function()
5968 return this.el.select('.roo-navbar-collapse',true).first();
5973 initEvents : function()
5975 Roo.bootstrap.NavHeaderbar.superclass.initEvents.call(this);
5977 if (this.autohide) {
5982 Roo.get(document).on('scroll',function(e) {
5983 var ns = Roo.get(document).getScroll().top;
5984 var os = prevScroll;
5988 ft.removeClass('slideDown');
5989 ft.addClass('slideUp');
5992 ft.removeClass('slideUp');
5993 ft.addClass('slideDown');
6014 * @class Roo.bootstrap.NavSidebar
6015 * @extends Roo.bootstrap.Navbar
6016 * Bootstrap Sidebar class
6019 * Create a new Sidebar
6020 * @param {Object} config The config object
6024 Roo.bootstrap.NavSidebar = function(config){
6025 Roo.bootstrap.NavSidebar.superclass.constructor.call(this, config);
6028 Roo.extend(Roo.bootstrap.NavSidebar, Roo.bootstrap.Navbar, {
6030 sidebar : true, // used by Navbar Item and NavbarGroup at present...
6032 getAutoCreate : function(){
6037 cls: 'sidebar sidebar-nav'
6059 * @class Roo.bootstrap.NavGroup
6060 * @extends Roo.bootstrap.Component
6061 * Bootstrap NavGroup class
6062 * @cfg {String} align (left|right)
6063 * @cfg {Boolean} inverse
6064 * @cfg {String} type (nav|pills|tab) default nav
6065 * @cfg {String} navId - reference Id for navbar.
6066 * @cfg {Boolean} pilltype default true (turn to off to disable active toggle)
6069 * Create a new nav group
6070 * @param {Object} config The config object
6073 Roo.bootstrap.NavGroup = function(config){
6074 Roo.bootstrap.NavGroup.superclass.constructor.call(this, config);
6077 Roo.bootstrap.NavGroup.register(this);
6081 * Fires when the active item changes
6082 * @param {Roo.bootstrap.NavGroup} this
6083 * @param {Roo.bootstrap.Navbar.Item} selected The item selected
6084 * @param {Roo.bootstrap.Navbar.Item} prev The previously selected item
6091 Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, {
6103 getAutoCreate : function()
6105 var cfg = Roo.apply({}, Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));
6111 if (Roo.bootstrap.version == 4) {
6112 if (['tabs','pills'].indexOf(this.type) != -1) {
6113 cfg.cls += ' nav-' + this.type;
6115 // trying to remove so header bar can right align top?
6116 if (this.parent() && this.parent().xtype != 'NavHeaderbar') {
6117 // do not use on header bar...
6118 cfg.cls += ' navbar-nav';
6123 if (['tabs','pills'].indexOf(this.type) != -1) {
6124 cfg.cls += ' nav-' + this.type
6126 if (this.type !== 'nav') {
6127 Roo.log('nav type must be nav/tabs/pills')
6129 cfg.cls += ' navbar-nav'
6133 if (this.parent() && this.parent().sidebar) {
6136 cls: 'dashboard-menu sidebar-menu'
6142 if (this.form === true) {
6145 cls: 'navbar-form form-inline'
6147 //nav navbar-right ml-md-auto
6148 if (this.align === 'right') {
6149 cfg.cls += ' navbar-right ml-md-auto';
6151 cfg.cls += ' navbar-left';
6155 if (this.align === 'right') {
6156 cfg.cls += ' navbar-right ml-md-auto';
6158 cfg.cls += ' mr-auto';
6162 cfg.cls += ' navbar-inverse';
6170 * sets the active Navigation item
6171 * @param {Roo.bootstrap.NavItem} the new current navitem
6173 setActiveItem : function(item)
6176 Roo.each(this.navItems, function(v){
6181 v.setActive(false, true);
6188 item.setActive(true, true);
6189 this.fireEvent('changed', this, item, prev);
6194 * gets the active Navigation item
6195 * @return {Roo.bootstrap.NavItem} the current navitem
6197 getActive : function()
6201 Roo.each(this.navItems, function(v){
6212 indexOfNav : function()
6216 Roo.each(this.navItems, function(v,i){
6227 * adds a Navigation item
6228 * @param {Roo.bootstrap.NavItem} the navitem to add
6230 addItem : function(cfg)
6232 if (this.form && Roo.bootstrap.version == 4) {
6235 var cn = new Roo.bootstrap.NavItem(cfg);
6237 cn.parentId = this.id;
6238 cn.onRender(this.el, null);
6242 * register a Navigation item
6243 * @param {Roo.bootstrap.NavItem} the navitem to add
6245 register : function(item)
6247 this.navItems.push( item);
6248 item.navId = this.navId;
6253 * clear all the Navigation item
6256 clearAll : function()
6259 this.el.dom.innerHTML = '';
6262 getNavItem: function(tabId)
6265 Roo.each(this.navItems, function(e) {
6266 if (e.tabId == tabId) {
6276 setActiveNext : function()
6278 var i = this.indexOfNav(this.getActive());
6279 if (i > this.navItems.length) {
6282 this.setActiveItem(this.navItems[i+1]);
6284 setActivePrev : function()
6286 var i = this.indexOfNav(this.getActive());
6290 this.setActiveItem(this.navItems[i-1]);
6292 clearWasActive : function(except) {
6293 Roo.each(this.navItems, function(e) {
6294 if (e.tabId != except.tabId && e.was_active) {
6295 e.was_active = false;
6302 getWasActive : function ()
6305 Roo.each(this.navItems, function(e) {
6320 Roo.apply(Roo.bootstrap.NavGroup, {
6324 * register a Navigation Group
6325 * @param {Roo.bootstrap.NavGroup} the navgroup to add
6327 register : function(navgrp)
6329 this.groups[navgrp.navId] = navgrp;
6333 * fetch a Navigation Group based on the navigation ID
6334 * @param {string} the navgroup to add
6335 * @returns {Roo.bootstrap.NavGroup} the navgroup
6337 get: function(navId) {
6338 if (typeof(this.groups[navId]) == 'undefined') {
6340 //this.register(new Roo.bootstrap.NavGroup({ navId : navId }));
6342 return this.groups[navId] ;
6357 * @class Roo.bootstrap.NavItem
6358 * @extends Roo.bootstrap.Component
6359 * Bootstrap Navbar.NavItem class
6360 * @cfg {String} href link to
6361 * @cfg {String} button_weight (default|primary|secondary|success|info|warning|danger|link|light|dark) default none
6362 * @cfg {Boolean} button_outline show and outlined button
6363 * @cfg {String} html content of button
6364 * @cfg {String} badge text inside badge
6365 * @cfg {String} badgecls (bg-green|bg-red|bg-yellow)the extra classes for the badge
6366 * @cfg {String} glyphicon DEPRICATED - use fa
6367 * @cfg {String} icon DEPRICATED - use fa
6368 * @cfg {String} fa - Fontawsome icon name (can add stuff to it like fa-2x)
6369 * @cfg {Boolean} active Is item active
6370 * @cfg {Boolean} disabled Is item disabled
6371 * @cfg {String} linkcls Link Class
6372 * @cfg {Boolean} preventDefault (true | false) default false
6373 * @cfg {String} tabId the tab that this item activates.
6374 * @cfg {String} tagtype (a|span) render as a href or span?
6375 * @cfg {Boolean} animateRef (true|false) link to element default false
6378 * Create a new Navbar Item
6379 * @param {Object} config The config object
6381 Roo.bootstrap.NavItem = function(config){
6382 Roo.bootstrap.NavItem.superclass.constructor.call(this, config);
6387 * The raw click event for the entire grid.
6388 * @param {Roo.EventObject} e
6393 * Fires when the active item active state changes
6394 * @param {Roo.bootstrap.NavItem} this
6395 * @param {boolean} state the new state
6401 * Fires when scroll to element
6402 * @param {Roo.bootstrap.NavItem} this
6403 * @param {Object} options
6404 * @param {Roo.EventObject} e
6412 Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, {
6421 preventDefault : false,
6429 button_outline : false,
6433 getAutoCreate : function(){
6440 cfg.cls = typeof(cfg.cls) == 'undefined' ? '' : cfg.cls;
6443 cfg.cls += ' active' ;
6445 if (this.disabled) {
6446 cfg.cls += ' disabled';
6450 if (this.button_weight.length) {
6451 cfg.tag = this.href ? 'a' : 'button';
6452 cfg.html = this.html || '';
6453 cfg.cls += ' btn btn' + (this.button_outline ? '-outline' : '') + '-' + this.button_weight;
6455 cfg.href = this.href;
6458 cfg.html = '<i class="fa fas fa-'+this.fa+'"></i> <span class="nav-html">' + this.html + '</span>';
6460 cfg.cls += " nav-html";
6463 // menu .. should add dropdown-menu class - so no need for carat..
6465 if (this.badge !== '') {
6467 cfg.html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
6472 if (this.href || this.html || this.glyphicon || this.icon || this.fa) {
6476 href : this.href || "#",
6477 html: this.html || '',
6481 if (this.tagtype == 'a') {
6482 cfg.cn[0].cls = 'nav-link' + (this.active ? ' active' : '') + ' ' + this.linkcls;
6486 cfg.cn[0].html = '<i class="'+this.icon+'"></i> <span class="nav-html">' + cfg.cn[0].html + '</span>';
6487 } else if (this.fa) {
6488 cfg.cn[0].html = '<i class="fa fas fa-'+this.fa+'"></i> <span class="nav-html">' + cfg.cn[0].html + '</span>';
6489 } else if(this.glyphicon) {
6490 cfg.cn[0].html = '<span class="glyphicon glyphicon-' + this.glyphicon + '"></span> ' + cfg.cn[0].html;
6492 cfg.cn[0].cls += " nav-html";
6496 cfg.cn[0].html += " <span class='caret'></span>";
6500 if (this.badge !== '') {
6501 cfg.cn[0].html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
6509 onRender : function(ct, position)
6511 // Roo.log("Call onRender: " + this.xtype);
6512 if (Roo.bootstrap.version == 4 && ct.dom.type != 'ul') {
6516 var ret = Roo.bootstrap.NavItem.superclass.onRender.call(this, ct, position);
6517 this.navLink = this.el.select('.nav-link',true).first();
6518 this.htmlEl = this.el.hasClass('nav-html') ? this.el : this.el.select('.nav-html',true).first();
6523 initEvents: function()
6525 if (typeof (this.menu) != 'undefined') {
6526 this.menu.parentType = this.xtype;
6527 this.menu.triggerEl = this.el;
6528 this.menu = this.addxtype(Roo.apply({}, this.menu));
6531 this.el.on('click', this.onClick, this);
6533 //if(this.tagtype == 'span'){
6534 // this.el.select('span',true).on('click', this.onClick, this);
6537 // at this point parent should be available..
6538 this.parent().register(this);
6541 onClick : function(e)
6543 if (e.getTarget('.dropdown-menu-item')) {
6544 // did you click on a menu itemm.... - then don't trigger onclick..
6549 this.preventDefault ||
6552 Roo.log("NavItem - prevent Default?");
6556 if (this.disabled) {
6560 var tg = Roo.bootstrap.TabGroup.get(this.navId);
6561 if (tg && tg.transition) {
6562 Roo.log("waiting for the transitionend");
6568 //Roo.log("fire event clicked");
6569 if(this.fireEvent('click', this, e) === false){
6573 if(this.tagtype == 'span'){
6577 //Roo.log(this.href);
6578 var ael = this.el.select('a',true).first();
6581 if(ael && this.animateRef && this.href.indexOf('#') > -1){
6582 //Roo.log(["test:",ael.dom.href.split("#")[0], document.location.toString().split("#")[0]]);
6583 if (ael.dom.href.split("#")[0] != document.location.toString().split("#")[0]) {
6584 return; // ignore... - it's a 'hash' to another page.
6586 Roo.log("NavItem - prevent Default?");
6588 this.scrollToElement(e);
6592 var p = this.parent();
6594 if (['tabs','pills'].indexOf(p.type)!==-1 && p.pilltype) {
6595 if (typeof(p.setActiveItem) !== 'undefined') {
6596 p.setActiveItem(this);
6600 // if parent is a navbarheader....- and link is probably a '#' page ref.. then remove the expanded menu.
6601 if (p.parentType == 'NavHeaderbar' && !this.menu) {
6602 // remove the collapsed menu expand...
6603 p.parent().el.select('.roo-navbar-collapse',true).removeClass('in');
6607 isActive: function () {
6610 setActive : function(state, fire, is_was_active)
6612 if (this.active && !state && this.navId) {
6613 this.was_active = true;
6614 var nv = Roo.bootstrap.NavGroup.get(this.navId);
6616 nv.clearWasActive(this);
6620 this.active = state;
6623 this.el.removeClass('active');
6624 this.navLink ? this.navLink.removeClass('active') : false;
6625 } else if (!this.el.hasClass('active')) {
6627 this.el.addClass('active');
6628 if (Roo.bootstrap.version == 4 && this.navLink ) {
6629 this.navLink.addClass('active');
6634 this.fireEvent('changed', this, state);
6637 // show a panel if it's registered and related..
6639 if (!this.navId || !this.tabId || !state || is_was_active) {
6643 var tg = Roo.bootstrap.TabGroup.get(this.navId);
6647 var pan = tg.getPanelByName(this.tabId);
6651 // if we can not flip to new panel - go back to old nav highlight..
6652 if (false == tg.showPanel(pan)) {
6653 var nv = Roo.bootstrap.NavGroup.get(this.navId);
6655 var onav = nv.getWasActive();
6657 onav.setActive(true, false, true);
6666 // this should not be here...
6667 setDisabled : function(state)
6669 this.disabled = state;
6671 this.el.removeClass('disabled');
6672 } else if (!this.el.hasClass('disabled')) {
6673 this.el.addClass('disabled');
6679 * Fetch the element to display the tooltip on.
6680 * @return {Roo.Element} defaults to this.el
6682 tooltipEl : function()
6684 return this.el; //this.tagtype == 'a' ? this.el : this.el.select('' + this.tagtype + '', true).first();
6687 scrollToElement : function(e)
6689 var c = document.body;
6692 * Firefox / IE places the overflow at the html level, unless specifically styled to behave differently.
6694 if(Roo.isFirefox || Roo.isIE || Roo.isIE11){
6695 c = document.documentElement;
6698 var target = Roo.get(c).select('a[name=' + this.href.split('#')[1] +']', true).first();
6704 var o = target.calcOffsetsTo(c);
6711 this.fireEvent('scrollto', this, options, e);
6713 Roo.get(c).scrollTo('top', options.value, true);
6718 * Set the HTML (text content) of the item
6719 * @param {string} html content for the nav item
6721 setHtml : function(html)
6724 this.htmlEl.dom.innerHTML = html;
6736 * <span> icon </span>
6737 * <span> text </span>
6738 * <span>badge </span>
6742 * @class Roo.bootstrap.NavSidebarItem
6743 * @extends Roo.bootstrap.NavItem
6744 * Bootstrap Navbar.NavSidebarItem class
6745 * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
6746 * {Boolean} open is the menu open
6747 * {Boolean} buttonView use button as the tigger el rather that a (default false)
6748 * {String} buttonWeight (default|primary|success|info|warning|danger)the extra classes for the button
6749 * {String} buttonSize (sm|md|lg)the extra classes for the button
6750 * {Boolean} showArrow show arrow next to the text (default true)
6752 * Create a new Navbar Button
6753 * @param {Object} config The config object
6755 Roo.bootstrap.NavSidebarItem = function(config){
6756 Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this, config);
6761 * The raw click event for the entire grid.
6762 * @param {Roo.EventObject} e
6767 * Fires when the active item active state changes
6768 * @param {Roo.bootstrap.NavSidebarItem} this
6769 * @param {boolean} state the new state
6777 Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem, {
6779 badgeWeight : 'default',
6785 buttonWeight : 'default',
6791 getAutoCreate : function(){
6796 href : this.href || '#',
6802 if(this.buttonView){
6805 href : this.href || '#',
6806 cls: 'btn btn-' + this.buttonWeight + ' btn-' + this.buttonSize + 'roo-button-dropdown-toggle',
6819 cfg.cls += ' active';
6822 if (this.disabled) {
6823 cfg.cls += ' disabled';
6826 cfg.cls += ' open x-open';
6829 if (this.glyphicon || this.icon) {
6830 var c = this.glyphicon ? ('glyphicon glyphicon-'+this.glyphicon) : this.icon;
6831 a.cn.push({ tag : 'i', cls : c }) ;
6834 if(!this.buttonView){
6837 html : this.html || ''
6844 if (this.badge !== '') {
6845 a.cn.push({ tag: 'span', cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge });
6851 a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
6854 a.cls += ' dropdown-toggle treeview' ;
6860 initEvents : function()
6862 if (typeof (this.menu) != 'undefined') {
6863 this.menu.parentType = this.xtype;
6864 this.menu.triggerEl = this.el;
6865 this.menu = this.addxtype(Roo.apply({}, this.menu));
6868 this.el.on('click', this.onClick, this);
6870 if(this.badge !== ''){
6871 this.badgeEl = this.el.select('.badge', true).first().setVisibilityMode(Roo.Element.DISPLAY);
6876 onClick : function(e)
6883 if(this.preventDefault){
6887 this.fireEvent('click', this, e);
6890 disable : function()
6892 this.setDisabled(true);
6897 this.setDisabled(false);
6900 setDisabled : function(state)
6902 if(this.disabled == state){
6906 this.disabled = state;
6909 this.el.addClass('disabled');
6913 this.el.removeClass('disabled');
6918 setActive : function(state)
6920 if(this.active == state){
6924 this.active = state;
6927 this.el.addClass('active');
6931 this.el.removeClass('active');
6936 isActive: function ()
6941 setBadge : function(str)
6947 this.badgeEl.dom.innerHTML = str;
6962 Roo.namespace('Roo.bootstrap.breadcrumb');
6966 * @class Roo.bootstrap.breadcrumb.Nav
6967 * @extends Roo.bootstrap.Component
6968 * Bootstrap Breadcrumb Nav Class
6970 * @children Roo.bootstrap.breadcrumb.Item
6973 * Create a new breadcrumb.Nav
6974 * @param {Object} config The config object
6978 Roo.bootstrap.breadcrumb.Nav = function(config){
6979 Roo.bootstrap.breadcrumb.Nav.superclass.constructor.call(this, config);
6984 Roo.extend(Roo.bootstrap.breadcrumb.Nav, Roo.bootstrap.Component, {
6986 getAutoCreate : function()
7003 initEvents: function()
7005 this.olEl = this.el.select('ol',true).first();
7007 getChildContainer : function()
7023 * @class Roo.bootstrap.breadcrumb.Nav
7024 * @extends Roo.bootstrap.Component
7025 * Bootstrap Breadcrumb Nav Class
7027 * @children Roo.bootstrap.breadcrumb.Component
7028 * @cfg {String} html the content of the link.
7029 * @cfg {String} href where it links to if '#' is used the link will be handled by onClick.
7030 * @cfg {Boolean} active is it active
7034 * Create a new breadcrumb.Nav
7035 * @param {Object} config The config object
7038 Roo.bootstrap.breadcrumb.Item = function(config){
7039 Roo.bootstrap.breadcrumb.Item.superclass.constructor.call(this, config);
7044 * The img click event for the img.
7045 * @param {Roo.EventObject} e
7052 Roo.extend(Roo.bootstrap.breadcrumb.Item, Roo.bootstrap.Component, {
7057 getAutoCreate : function()
7062 cls : 'breadcrumb-item' + (this.active ? ' active' : '')
7064 if (this.href !== false) {
7071 cfg.html = this.html;
7077 initEvents: function()
7080 this.el.select('a', true).first().on('click',this.onClick, this)
7084 onClick : function(e)
7087 this.fireEvent('click',this, e);
7100 * @class Roo.bootstrap.Row
7101 * @extends Roo.bootstrap.Component
7102 * @children Roo.bootstrap.Component
7103 * Bootstrap Row class (contains columns...)
7107 * @param {Object} config The config object
7110 Roo.bootstrap.Row = function(config){
7111 Roo.bootstrap.Row.superclass.constructor.call(this, config);
7114 Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component, {
7116 getAutoCreate : function(){
7135 * @class Roo.bootstrap.Pagination
7136 * @extends Roo.bootstrap.Component
7137 * Bootstrap Pagination class
7138 * @cfg {String} size xs | sm | md | lg
7139 * @cfg {Boolean} inverse false | true
7142 * Create a new Pagination
7143 * @param {Object} config The config object
7146 Roo.bootstrap.Pagination = function(config){
7147 Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
7150 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component, {
7156 getAutoCreate : function(){
7162 cfg.cls += ' inverse';
7168 cfg.cls += " " + this.cls;
7186 * @class Roo.bootstrap.PaginationItem
7187 * @extends Roo.bootstrap.Component
7188 * Bootstrap PaginationItem class
7189 * @cfg {String} html text
7190 * @cfg {String} href the link
7191 * @cfg {Boolean} preventDefault (true | false) default true
7192 * @cfg {Boolean} active (true | false) default false
7193 * @cfg {Boolean} disabled default false
7197 * Create a new PaginationItem
7198 * @param {Object} config The config object
7202 Roo.bootstrap.PaginationItem = function(config){
7203 Roo.bootstrap.PaginationItem.superclass.constructor.call(this, config);
7208 * The raw click event for the entire grid.
7209 * @param {Roo.EventObject} e
7215 Roo.extend(Roo.bootstrap.PaginationItem, Roo.bootstrap.Component, {
7219 preventDefault: true,
7224 getAutoCreate : function(){
7230 href : this.href ? this.href : '#',
7231 html : this.html ? this.html : ''
7241 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' disabled' : 'disabled';
7245 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' active' : 'active';
7251 initEvents: function() {
7253 this.el.on('click', this.onClick, this);
7256 onClick : function(e)
7258 Roo.log('PaginationItem on click ');
7259 if(this.preventDefault){
7267 this.fireEvent('click', this, e);
7283 * @class Roo.bootstrap.Slider
7284 * @extends Roo.bootstrap.Component
7285 * Bootstrap Slider class
7288 * Create a new Slider
7289 * @param {Object} config The config object
7292 Roo.bootstrap.Slider = function(config){
7293 Roo.bootstrap.Slider.superclass.constructor.call(this, config);
7296 Roo.extend(Roo.bootstrap.Slider, Roo.bootstrap.Component, {
7298 getAutoCreate : function(){
7302 cls: 'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',
7306 cls: 'ui-slider-handle ui-state-default ui-corner-all'
7318 * Ext JS Library 1.1.1
7319 * Copyright(c) 2006-2007, Ext JS, LLC.
7321 * Originally Released Under LGPL - original licence link has changed is not relivant.
7324 * <script type="text/javascript">
7327 * @extends Roo.dd.DDProxy
7328 * @class Roo.grid.SplitDragZone
7329 * Support for Column Header resizing
7331 * @param {Object} config
7334 // This is a support class used internally by the Grid components
7335 Roo.grid.SplitDragZone = function(grid, hd, hd2){
7337 this.view = grid.getView();
7338 this.proxy = this.view.resizeProxy;
7339 Roo.grid.SplitDragZone.superclass.constructor.call(
7342 "gridSplitters" + this.grid.getGridEl().id, // SGROUP
7344 dragElId : Roo.id(this.proxy.dom),
7349 this.setHandleElId(Roo.id(hd));
7350 if (hd2 !== false) {
7351 this.setOuterHandleElId(Roo.id(hd2));
7354 this.scroll = false;
7356 Roo.extend(Roo.grid.SplitDragZone, Roo.dd.DDProxy, {
7357 fly: Roo.Element.fly,
7359 b4StartDrag : function(x, y){
7360 this.view.headersDisabled = true;
7361 var h = this.view.mainWrap ? this.view.mainWrap.getHeight() : (
7362 this.view.headEl.getHeight() + this.view.bodyEl.getHeight()
7364 this.proxy.setHeight(h);
7366 // for old system colWidth really stored the actual width?
7367 // in bootstrap we tried using xs/ms/etc.. to do % sizing?
7368 // which in reality did not work.. - it worked only for fixed sizes
7369 // for resizable we need to use actual sizes.
7370 var w = this.cm.getColumnWidth(this.cellIndex);
7371 if (!this.view.mainWrap) {
7373 w = this.view.getHeaderIndex(this.cellIndex).getWidth();
7378 // this was w-this.grid.minColumnWidth;
7379 // doesnt really make sense? - w = thie curren width or the rendered one?
7380 var minw = Math.max(w-this.grid.minColumnWidth, 0);
7381 this.resetConstraints();
7382 this.setXConstraint(minw, 1000);
7383 this.setYConstraint(0, 0);
7384 this.minX = x - minw;
7385 this.maxX = x + 1000;
7387 if (!this.view.mainWrap) { // this is Bootstrap code..
7388 this.getDragEl().style.display='block';
7391 Roo.dd.DDProxy.prototype.b4StartDrag.call(this, x, y);
7395 handleMouseDown : function(e){
7396 ev = Roo.EventObject.setEvent(e);
7397 var t = this.fly(ev.getTarget());
7398 if(t.hasClass("x-grid-split")){
7399 this.cellIndex = this.view.getCellIndex(t.dom);
7401 this.cm = this.grid.colModel;
7402 if(this.cm.isResizable(this.cellIndex) && !this.cm.isFixed(this.cellIndex)){
7403 Roo.grid.SplitDragZone.superclass.handleMouseDown.apply(this, arguments);
7408 endDrag : function(e){
7409 this.view.headersDisabled = false;
7410 var endX = Math.max(this.minX, Roo.lib.Event.getPageX(e));
7411 var diff = endX - this.startPos;
7413 var w = this.cm.getColumnWidth(this.cellIndex);
7414 if (!this.view.mainWrap) {
7417 this.view.onColumnSplitterMoved(this.cellIndex, w+diff);
7420 autoOffset : function(){
7425 * Ext JS Library 1.1.1
7426 * Copyright(c) 2006-2007, Ext JS, LLC.
7428 * Originally Released Under LGPL - original licence link has changed is not relivant.
7431 * <script type="text/javascript">
7435 * @class Roo.grid.AbstractSelectionModel
7436 * @extends Roo.util.Observable
7438 * Abstract base class for grid SelectionModels. It provides the interface that should be
7439 * implemented by descendant classes. This class should not be directly instantiated.
7442 Roo.grid.AbstractSelectionModel = function(){
7443 this.locked = false;
7444 Roo.grid.AbstractSelectionModel.superclass.constructor.call(this);
7447 Roo.extend(Roo.grid.AbstractSelectionModel, Roo.util.Observable, {
7448 /** @ignore Called by the grid automatically. Do not call directly. */
7449 init : function(grid){
7455 * Locks the selections.
7462 * Unlocks the selections.
7464 unlock : function(){
7465 this.locked = false;
7469 * Returns true if the selections are locked.
7472 isLocked : function(){
7477 * Ext JS Library 1.1.1
7478 * Copyright(c) 2006-2007, Ext JS, LLC.
7480 * Originally Released Under LGPL - original licence link has changed is not relivant.
7483 * <script type="text/javascript">
7486 * @extends Roo.grid.AbstractSelectionModel
7487 * @class Roo.grid.RowSelectionModel
7488 * The default SelectionModel used by {@link Roo.grid.Grid}.
7489 * It supports multiple selections and keyboard selection/navigation.
7491 * @param {Object} config
7493 Roo.grid.RowSelectionModel = function(config){
7494 Roo.apply(this, config);
7495 this.selections = new Roo.util.MixedCollection(false, function(o){
7500 this.lastActive = false;
7504 * @event selectionchange
7505 * Fires when the selection changes
7506 * @param {SelectionModel} this
7508 "selectionchange" : true,
7510 * @event afterselectionchange
7511 * Fires after the selection changes (eg. by key press or clicking)
7512 * @param {SelectionModel} this
7514 "afterselectionchange" : true,
7516 * @event beforerowselect
7517 * Fires when a row is selected being selected, return false to cancel.
7518 * @param {SelectionModel} this
7519 * @param {Number} rowIndex The selected index
7520 * @param {Boolean} keepExisting False if other selections will be cleared
7522 "beforerowselect" : true,
7525 * Fires when a row is selected.
7526 * @param {SelectionModel} this
7527 * @param {Number} rowIndex The selected index
7528 * @param {Roo.data.Record} r The record
7532 * @event rowdeselect
7533 * Fires when a row is deselected.
7534 * @param {SelectionModel} this
7535 * @param {Number} rowIndex The selected index
7537 "rowdeselect" : true
7539 Roo.grid.RowSelectionModel.superclass.constructor.call(this);
7540 this.locked = false;
7543 Roo.extend(Roo.grid.RowSelectionModel, Roo.grid.AbstractSelectionModel, {
7545 * @cfg {Boolean} singleSelect
7546 * True to allow selection of only one row at a time (defaults to false)
7548 singleSelect : false,
7551 initEvents : function(){
7553 if(!this.grid.enableDragDrop && !this.grid.enableDrag){
7554 this.grid.on("mousedown", this.handleMouseDown, this);
7555 }else{ // allow click to work like normal
7556 this.grid.on("rowclick", this.handleDragableRowClick, this);
7558 // bootstrap does not have a view..
7559 var view = this.grid.view ? this.grid.view : this.grid;
7560 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
7563 this.selectPrevious(e.shiftKey);
7564 }else if(this.last !== false && this.lastActive !== false){
7565 var last = this.last;
7566 this.selectRange(this.last, this.lastActive-1);
7567 view.focusRow(this.lastActive);
7572 this.selectFirstRow();
7574 this.fireEvent("afterselectionchange", this);
7576 "down" : function(e){
7578 this.selectNext(e.shiftKey);
7579 }else if(this.last !== false && this.lastActive !== false){
7580 var last = this.last;
7581 this.selectRange(this.last, this.lastActive+1);
7582 view.focusRow(this.lastActive);
7587 this.selectFirstRow();
7589 this.fireEvent("afterselectionchange", this);
7595 view.on("refresh", this.onRefresh, this);
7596 view.on("rowupdated", this.onRowUpdated, this);
7597 view.on("rowremoved", this.onRemove, this);
7601 onRefresh : function(){
7602 var ds = this.grid.ds, i, v = this.grid.view;
7603 var s = this.selections;
7605 if((i = ds.indexOfId(r.id)) != -1){
7607 s.add(ds.getAt(i)); // updating the selection relate data
7615 onRemove : function(v, index, r){
7616 this.selections.remove(r);
7620 onRowUpdated : function(v, index, r){
7621 if(this.isSelected(r)){
7622 v.onRowSelect(index);
7628 * @param {Array} records The records to select
7629 * @param {Boolean} keepExisting (optional) True to keep existing selections
7631 selectRecords : function(records, keepExisting){
7633 this.clearSelections();
7635 var ds = this.grid.ds;
7636 for(var i = 0, len = records.length; i < len; i++){
7637 this.selectRow(ds.indexOf(records[i]), true);
7642 * Gets the number of selected rows.
7645 getCount : function(){
7646 return this.selections.length;
7650 * Selects the first row in the grid.
7652 selectFirstRow : function(){
7657 * Select the last row.
7658 * @param {Boolean} keepExisting (optional) True to keep existing selections
7660 selectLastRow : function(keepExisting){
7661 this.selectRow(this.grid.ds.getCount() - 1, keepExisting);
7665 * Selects the row immediately following the last selected row.
7666 * @param {Boolean} keepExisting (optional) True to keep existing selections
7668 selectNext : function(keepExisting){
7669 if(this.last !== false && (this.last+1) < this.grid.ds.getCount()){
7670 this.selectRow(this.last+1, keepExisting);
7671 var view = this.grid.view ? this.grid.view : this.grid;
7672 view.focusRow(this.last);
7677 * Selects the row that precedes the last selected row.
7678 * @param {Boolean} keepExisting (optional) True to keep existing selections
7680 selectPrevious : function(keepExisting){
7682 this.selectRow(this.last-1, keepExisting);
7683 var view = this.grid.view ? this.grid.view : this.grid;
7684 view.focusRow(this.last);
7689 * Returns the selected records
7690 * @return {Array} Array of selected records
7692 getSelections : function(){
7693 return [].concat(this.selections.items);
7697 * Returns the first selected record.
7700 getSelected : function(){
7701 return this.selections.itemAt(0);
7706 * Clears all selections.
7708 clearSelections : function(fast){
7713 var ds = this.grid.ds;
7714 var s = this.selections;
7716 this.deselectRow(ds.indexOfId(r.id));
7720 this.selections.clear();
7729 selectAll : function(){
7733 this.selections.clear();
7734 for(var i = 0, len = this.grid.ds.getCount(); i < len; i++){
7735 this.selectRow(i, true);
7740 * Returns True if there is a selection.
7743 hasSelection : function(){
7744 return this.selections.length > 0;
7748 * Returns True if the specified row is selected.
7749 * @param {Number/Record} record The record or index of the record to check
7752 isSelected : function(index){
7753 var r = typeof index == "number" ? this.grid.ds.getAt(index) : index;
7754 return (r && this.selections.key(r.id) ? true : false);
7758 * Returns True if the specified record id is selected.
7759 * @param {String} id The id of record to check
7762 isIdSelected : function(id){
7763 return (this.selections.key(id) ? true : false);
7767 handleMouseDown : function(e, t)
7769 var view = this.grid.view ? this.grid.view : this.grid;
7771 if(this.isLocked() || (rowIndex = view.findRowIndex(t)) === false){
7774 if(e.shiftKey && this.last !== false){
7775 var last = this.last;
7776 this.selectRange(last, rowIndex, e.ctrlKey);
7777 this.last = last; // reset the last
7778 view.focusRow(rowIndex);
7780 var isSelected = this.isSelected(rowIndex);
7781 if(e.button !== 0 && isSelected){
7782 view.focusRow(rowIndex);
7783 }else if(e.ctrlKey && isSelected){
7784 this.deselectRow(rowIndex);
7785 }else if(!isSelected){
7786 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
7787 view.focusRow(rowIndex);
7790 this.fireEvent("afterselectionchange", this);
7793 handleDragableRowClick : function(grid, rowIndex, e)
7795 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
7796 this.selectRow(rowIndex, false);
7797 var view = this.grid.view ? this.grid.view : this.grid;
7798 view.focusRow(rowIndex);
7799 this.fireEvent("afterselectionchange", this);
7804 * Selects multiple rows.
7805 * @param {Array} rows Array of the indexes of the row to select
7806 * @param {Boolean} keepExisting (optional) True to keep existing selections
7808 selectRows : function(rows, keepExisting){
7810 this.clearSelections();
7812 for(var i = 0, len = rows.length; i < len; i++){
7813 this.selectRow(rows[i], true);
7818 * Selects a range of rows. All rows in between startRow and endRow are also selected.
7819 * @param {Number} startRow The index of the first row in the range
7820 * @param {Number} endRow The index of the last row in the range
7821 * @param {Boolean} keepExisting (optional) True to retain existing selections
7823 selectRange : function(startRow, endRow, keepExisting){
7828 this.clearSelections();
7830 if(startRow <= endRow){
7831 for(var i = startRow; i <= endRow; i++){
7832 this.selectRow(i, true);
7835 for(var i = startRow; i >= endRow; i--){
7836 this.selectRow(i, true);
7842 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
7843 * @param {Number} startRow The index of the first row in the range
7844 * @param {Number} endRow The index of the last row in the range
7846 deselectRange : function(startRow, endRow, preventViewNotify){
7850 for(var i = startRow; i <= endRow; i++){
7851 this.deselectRow(i, preventViewNotify);
7857 * @param {Number} row The index of the row to select
7858 * @param {Boolean} keepExisting (optional) True to keep existing selections
7860 selectRow : function(index, keepExisting, preventViewNotify){
7861 if(this.locked || (index < 0 || index >= this.grid.ds.getCount())) {
7864 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
7865 if(!keepExisting || this.singleSelect){
7866 this.clearSelections();
7868 var r = this.grid.ds.getAt(index);
7869 this.selections.add(r);
7870 this.last = this.lastActive = index;
7871 if(!preventViewNotify){
7872 var view = this.grid.view ? this.grid.view : this.grid;
7873 view.onRowSelect(index);
7875 this.fireEvent("rowselect", this, index, r);
7876 this.fireEvent("selectionchange", this);
7882 * @param {Number} row The index of the row to deselect
7884 deselectRow : function(index, preventViewNotify){
7888 if(this.last == index){
7891 if(this.lastActive == index){
7892 this.lastActive = false;
7894 var r = this.grid.ds.getAt(index);
7895 this.selections.remove(r);
7896 if(!preventViewNotify){
7897 var view = this.grid.view ? this.grid.view : this.grid;
7898 view.onRowDeselect(index);
7900 this.fireEvent("rowdeselect", this, index);
7901 this.fireEvent("selectionchange", this);
7905 restoreLast : function(){
7907 this.last = this._last;
7912 acceptsNav : function(row, col, cm){
7913 return !cm.isHidden(col) && cm.isCellEditable(col, row);
7917 onEditorKey : function(field, e){
7918 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
7923 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
7925 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
7927 }else if(k == e.ENTER && !e.ctrlKey){
7931 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
7933 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
7935 }else if(k == e.ESC){
7939 g.startEditing(newCell[0], newCell[1]);
7944 * Ext JS Library 1.1.1
7945 * Copyright(c) 2006-2007, Ext JS, LLC.
7947 * Originally Released Under LGPL - original licence link has changed is not relivant.
7950 * <script type="text/javascript">
7955 * @class Roo.grid.ColumnModel
7956 * @extends Roo.util.Observable
7957 * This is the default implementation of a ColumnModel used by the Grid. It defines
7958 * the columns in the grid.
7961 var colModel = new Roo.grid.ColumnModel([
7962 {header: "Ticker", width: 60, sortable: true, locked: true},
7963 {header: "Company Name", width: 150, sortable: true},
7964 {header: "Market Cap.", width: 100, sortable: true},
7965 {header: "$ Sales", width: 100, sortable: true, renderer: money},
7966 {header: "Employees", width: 100, sortable: true, resizable: false}
7971 * The config options listed for this class are options which may appear in each
7972 * individual column definition.
7973 * <br/>RooJS Fix - column id's are not sequential but use Roo.id() - fixes bugs with layouts.
7975 * @param {Object} config An Array of column config objects. See this class's
7976 * config objects for details.
7978 Roo.grid.ColumnModel = function(config){
7980 * The config passed into the constructor
7982 this.config = []; //config;
7985 // if no id, create one
7986 // if the column does not have a dataIndex mapping,
7987 // map it to the order it is in the config
7988 for(var i = 0, len = config.length; i < len; i++){
7989 this.addColumn(config[i]);
7994 * The width of columns which have no width specified (defaults to 100)
7997 this.defaultWidth = 100;
8000 * Default sortable of columns which have no sortable specified (defaults to false)
8003 this.defaultSortable = false;
8007 * @event widthchange
8008 * Fires when the width of a column changes.
8009 * @param {ColumnModel} this
8010 * @param {Number} columnIndex The column index
8011 * @param {Number} newWidth The new width
8013 "widthchange": true,
8015 * @event headerchange
8016 * Fires when the text of a header changes.
8017 * @param {ColumnModel} this
8018 * @param {Number} columnIndex The column index
8019 * @param {Number} newText The new header text
8021 "headerchange": true,
8023 * @event hiddenchange
8024 * Fires when a column is hidden or "unhidden".
8025 * @param {ColumnModel} this
8026 * @param {Number} columnIndex The column index
8027 * @param {Boolean} hidden true if hidden, false otherwise
8029 "hiddenchange": true,
8031 * @event columnmoved
8032 * Fires when a column is moved.
8033 * @param {ColumnModel} this
8034 * @param {Number} oldIndex
8035 * @param {Number} newIndex
8037 "columnmoved" : true,
8039 * @event columlockchange
8040 * Fires when a column's locked state is changed
8041 * @param {ColumnModel} this
8042 * @param {Number} colIndex
8043 * @param {Boolean} locked true if locked
8045 "columnlockchange" : true
8047 Roo.grid.ColumnModel.superclass.constructor.call(this);
8049 Roo.extend(Roo.grid.ColumnModel, Roo.util.Observable, {
8051 * @cfg {String} header The header text to display in the Grid view.
8054 * @cfg {String} xsHeader Header at Bootsrap Extra Small width (default for all)
8057 * @cfg {String} smHeader Header at Bootsrap Small width
8060 * @cfg {String} mdHeader Header at Bootsrap Medium width
8063 * @cfg {String} lgHeader Header at Bootsrap Large width
8066 * @cfg {String} xlHeader Header at Bootsrap extra Large width
8069 * @cfg {String} dataIndex (Optional) The name of the field in the grid's {@link Roo.data.Store}'s
8070 * {@link Roo.data.Record} definition from which to draw the column's value. If not
8071 * specified, the column's index is used as an index into the Record's data Array.
8074 * @cfg {Number} width (Optional) The initial width in pixels of the column. Using this
8075 * instead of {@link Roo.grid.Grid#autoSizeColumns} is more efficient.
8078 * @cfg {Boolean} sortable (Optional) True if sorting is to be allowed on this column.
8079 * Defaults to the value of the {@link #defaultSortable} property.
8080 * Whether local/remote sorting is used is specified in {@link Roo.data.Store#remoteSort}.
8083 * @cfg {Boolean} locked (Optional) True to lock the column in place while scrolling the Grid. Defaults to false.
8086 * @cfg {Boolean} fixed (Optional) True if the column width cannot be changed. Defaults to false.
8089 * @cfg {Boolean} resizable (Optional) False to disable column resizing. Defaults to true.
8092 * @cfg {Boolean} hidden (Optional) True to hide the column. Defaults to false.
8095 * @cfg {Function} renderer (Optional) A function used to generate HTML markup for a cell
8096 * given the cell's data value. See {@link #setRenderer}. If not specified, the
8097 * default renderer returns the escaped data value. If an object is returned (bootstrap only)
8098 * then it is treated as a Roo Component object instance, and it is rendered after the initial row is rendered
8101 * @cfg {Roo.grid.GridEditor} editor (Optional) For grid editors - returns the grid editor
8104 * @cfg {String} align (Optional) Set the CSS text-align property of the column. Defaults to undefined.
8107 * @cfg {String} valign (Optional) Set the CSS vertical-align property of the column (eg. middle, top, bottom etc). Defaults to undefined.
8110 * @cfg {String} cursor (Optional)
8113 * @cfg {String} tooltip (Optional)
8116 * @cfg {Number} xs (Optional) can be '0' for hidden at this size (number less than 12)
8119 * @cfg {Number} sm (Optional) can be '0' for hidden at this size (number less than 12)
8122 * @cfg {Number} md (Optional) can be '0' for hidden at this size (number less than 12)
8125 * @cfg {Number} lg (Optional) can be '0' for hidden at this size (number less than 12)
8128 * @cfg {Number} xl (Optional) can be '0' for hidden at this size (number less than 12)
8131 * Returns the id of the column at the specified index.
8132 * @param {Number} index The column index
8133 * @return {String} the id
8135 getColumnId : function(index){
8136 return this.config[index].id;
8140 * Returns the column for a specified id.
8141 * @param {String} id The column id
8142 * @return {Object} the column
8144 getColumnById : function(id){
8145 return this.lookup[id];
8150 * Returns the column Object for a specified dataIndex.
8151 * @param {String} dataIndex The column dataIndex
8152 * @return {Object|Boolean} the column or false if not found
8154 getColumnByDataIndex: function(dataIndex){
8155 var index = this.findColumnIndex(dataIndex);
8156 return index > -1 ? this.config[index] : false;
8160 * Returns the index for a specified column id.
8161 * @param {String} id The column id
8162 * @return {Number} the index, or -1 if not found
8164 getIndexById : function(id){
8165 for(var i = 0, len = this.config.length; i < len; i++){
8166 if(this.config[i].id == id){
8174 * Returns the index for a specified column dataIndex.
8175 * @param {String} dataIndex The column dataIndex
8176 * @return {Number} the index, or -1 if not found
8179 findColumnIndex : function(dataIndex){
8180 for(var i = 0, len = this.config.length; i < len; i++){
8181 if(this.config[i].dataIndex == dataIndex){
8189 moveColumn : function(oldIndex, newIndex){
8190 var c = this.config[oldIndex];
8191 this.config.splice(oldIndex, 1);
8192 this.config.splice(newIndex, 0, c);
8193 this.dataMap = null;
8194 this.fireEvent("columnmoved", this, oldIndex, newIndex);
8197 isLocked : function(colIndex){
8198 return this.config[colIndex].locked === true;
8201 setLocked : function(colIndex, value, suppressEvent){
8202 if(this.isLocked(colIndex) == value){
8205 this.config[colIndex].locked = value;
8207 this.fireEvent("columnlockchange", this, colIndex, value);
8211 getTotalLockedWidth : function(){
8213 for(var i = 0; i < this.config.length; i++){
8214 if(this.isLocked(i) && !this.isHidden(i)){
8215 this.totalWidth += this.getColumnWidth(i);
8221 getLockedCount : function(){
8222 for(var i = 0, len = this.config.length; i < len; i++){
8223 if(!this.isLocked(i)){
8228 return this.config.length;
8232 * Returns the number of columns.
8235 getColumnCount : function(visibleOnly){
8236 if(visibleOnly === true){
8238 for(var i = 0, len = this.config.length; i < len; i++){
8239 if(!this.isHidden(i)){
8245 return this.config.length;
8249 * Returns the column configs that return true by the passed function that is called with (columnConfig, index)
8250 * @param {Function} fn
8251 * @param {Object} scope (optional)
8252 * @return {Array} result
8254 getColumnsBy : function(fn, scope){
8256 for(var i = 0, len = this.config.length; i < len; i++){
8257 var c = this.config[i];
8258 if(fn.call(scope||this, c, i) === true){
8266 * Returns true if the specified column is sortable.
8267 * @param {Number} col The column index
8270 isSortable : function(col){
8271 if(typeof this.config[col].sortable == "undefined"){
8272 return this.defaultSortable;
8274 return this.config[col].sortable;
8278 * Returns the rendering (formatting) function defined for the column.
8279 * @param {Number} col The column index.
8280 * @return {Function} The function used to render the cell. See {@link #setRenderer}.
8282 getRenderer : function(col){
8283 if(!this.config[col].renderer){
8284 return Roo.grid.ColumnModel.defaultRenderer;
8286 return this.config[col].renderer;
8290 * Sets the rendering (formatting) function for a column.
8291 * @param {Number} col The column index
8292 * @param {Function} fn The function to use to process the cell's raw data
8293 * to return HTML markup for the grid view. The render function is called with
8294 * the following parameters:<ul>
8295 * <li>Data value.</li>
8296 * <li>Cell metadata. An object in which you may set the following attributes:<ul>
8297 * <li>css A CSS style string to apply to the table cell.</li>
8298 * <li>attr An HTML attribute definition string to apply to the data container element <i>within</i> the table cell.</li></ul>
8299 * <li>The {@link Roo.data.Record} from which the data was extracted.</li>
8300 * <li>Row index</li>
8301 * <li>Column index</li>
8302 * <li>The {@link Roo.data.Store} object from which the Record was extracted</li></ul>
8304 setRenderer : function(col, fn){
8305 this.config[col].renderer = fn;
8309 * Returns the width for the specified column.
8310 * @param {Number} col The column index
8311 * @param (optional) {String} gridSize bootstrap width size.
8314 getColumnWidth : function(col, gridSize)
8316 var cfg = this.config[col];
8318 if (typeof(gridSize) == 'undefined') {
8319 return cfg.width * 1 || this.defaultWidth;
8321 if (gridSize === false) { // if we set it..
8322 return cfg.width || false;
8324 var sizes = ['xl', 'lg', 'md', 'sm', 'xs'];
8326 for(var i = sizes.indexOf(gridSize); i < sizes.length; i++) {
8327 if (typeof(cfg[ sizes[i] ] ) == 'undefined') {
8330 return cfg[ sizes[i] ];
8337 * Sets the width for a column.
8338 * @param {Number} col The column index
8339 * @param {Number} width The new width
8341 setColumnWidth : function(col, width, suppressEvent){
8342 this.config[col].width = width;
8343 this.totalWidth = null;
8345 this.fireEvent("widthchange", this, col, width);
8350 * Returns the total width of all columns.
8351 * @param {Boolean} includeHidden True to include hidden column widths
8354 getTotalWidth : function(includeHidden){
8355 if(!this.totalWidth){
8356 this.totalWidth = 0;
8357 for(var i = 0, len = this.config.length; i < len; i++){
8358 if(includeHidden || !this.isHidden(i)){
8359 this.totalWidth += this.getColumnWidth(i);
8363 return this.totalWidth;
8367 * Returns the header for the specified column.
8368 * @param {Number} col The column index
8371 getColumnHeader : function(col){
8372 return this.config[col].header;
8376 * Sets the header for a column.
8377 * @param {Number} col The column index
8378 * @param {String} header The new header
8380 setColumnHeader : function(col, header){
8381 this.config[col].header = header;
8382 this.fireEvent("headerchange", this, col, header);
8386 * Returns the tooltip for the specified column.
8387 * @param {Number} col The column index
8390 getColumnTooltip : function(col){
8391 return this.config[col].tooltip;
8394 * Sets the tooltip for a column.
8395 * @param {Number} col The column index
8396 * @param {String} tooltip The new tooltip
8398 setColumnTooltip : function(col, tooltip){
8399 this.config[col].tooltip = tooltip;
8403 * Returns the dataIndex for the specified column.
8404 * @param {Number} col The column index
8407 getDataIndex : function(col){
8408 return this.config[col].dataIndex;
8412 * Sets the dataIndex for a column.
8413 * @param {Number} col The column index
8414 * @param {Number} dataIndex The new dataIndex
8416 setDataIndex : function(col, dataIndex){
8417 this.config[col].dataIndex = dataIndex;
8423 * Returns true if the cell is editable.
8424 * @param {Number} colIndex The column index
8425 * @param {Number} rowIndex The row index - this is nto actually used..?
8428 isCellEditable : function(colIndex, rowIndex){
8429 return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
8433 * Returns the editor defined for the cell/column.
8434 * return false or null to disable editing.
8435 * @param {Number} colIndex The column index
8436 * @param {Number} rowIndex The row index
8439 getCellEditor : function(colIndex, rowIndex){
8440 return this.config[colIndex].editor;
8444 * Sets if a column is editable.
8445 * @param {Number} col The column index
8446 * @param {Boolean} editable True if the column is editable
8448 setEditable : function(col, editable){
8449 this.config[col].editable = editable;
8454 * Returns true if the column is hidden.
8455 * @param {Number} colIndex The column index
8458 isHidden : function(colIndex){
8459 return this.config[colIndex].hidden;
8464 * Returns true if the column width cannot be changed
8466 isFixed : function(colIndex){
8467 return this.config[colIndex].fixed;
8471 * Returns true if the column can be resized
8474 isResizable : function(colIndex){
8475 return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
8478 * Sets if a column is hidden.
8479 * @param {Number} colIndex The column index
8480 * @param {Boolean} hidden True if the column is hidden
8482 setHidden : function(colIndex, hidden){
8483 this.config[colIndex].hidden = hidden;
8484 this.totalWidth = null;
8485 this.fireEvent("hiddenchange", this, colIndex, hidden);
8489 * Sets the editor for a column.
8490 * @param {Number} col The column index
8491 * @param {Object} editor The editor object
8493 setEditor : function(col, editor){
8494 this.config[col].editor = editor;
8497 * Add a column (experimental...) - defaults to adding to the end..
8498 * @param {Object} config
8500 addColumn : function(c)
8503 var i = this.config.length;
8506 if(typeof c.dataIndex == "undefined"){
8509 if(typeof c.renderer == "string"){
8510 c.renderer = Roo.util.Format[c.renderer];
8512 if(typeof c.id == "undefined"){
8515 if(c.editor && c.editor.xtype){
8516 c.editor = Roo.factory(c.editor, Roo.grid);
8518 if(c.editor && c.editor.isFormField){
8519 c.editor = new Roo.grid.GridEditor(c.editor);
8521 this.lookup[c.id] = c;
8526 Roo.grid.ColumnModel.defaultRenderer = function(value)
8528 if(typeof value == "object") {
8531 if(typeof value == "string" && value.length < 1){
8535 return String.format("{0}", value);
8538 // Alias for backwards compatibility
8539 Roo.grid.DefaultColumnModel = Roo.grid.ColumnModel;
8542 * Ext JS Library 1.1.1
8543 * Copyright(c) 2006-2007, Ext JS, LLC.
8545 * Originally Released Under LGPL - original licence link has changed is not relivant.
8548 * <script type="text/javascript">
8552 * @class Roo.LoadMask
8553 * A simple utility class for generically masking elements while loading data. If the element being masked has
8554 * an underlying {@link Roo.data.Store}, the masking will be automatically synchronized with the store's loading
8555 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
8556 * element's UpdateManager load indicator and will be destroyed after the initial load.
8558 * Create a new LoadMask
8559 * @param {String/HTMLElement/Roo.Element} el The element or DOM node, or its id
8560 * @param {Object} config The config object
8562 Roo.LoadMask = function(el, config){
8563 this.el = Roo.get(el);
8564 Roo.apply(this, config);
8566 this.store.on('beforeload', this.onBeforeLoad, this);
8567 this.store.on('load', this.onLoad, this);
8568 this.store.on('loadexception', this.onLoadException, this);
8569 this.removeMask = false;
8571 var um = this.el.getUpdateManager();
8572 um.showLoadIndicator = false; // disable the default indicator
8573 um.on('beforeupdate', this.onBeforeLoad, this);
8574 um.on('update', this.onLoad, this);
8575 um.on('failure', this.onLoad, this);
8576 this.removeMask = true;
8580 Roo.LoadMask.prototype = {
8582 * @cfg {Boolean} removeMask
8583 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
8584 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
8589 * The text to display in a centered loading message box (defaults to 'Loading...')
8593 * @cfg {String} msgCls
8594 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
8596 msgCls : 'x-mask-loading',
8599 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
8605 * Disables the mask to prevent it from being displayed
8607 disable : function(){
8608 this.disabled = true;
8612 * Enables the mask so that it can be displayed
8614 enable : function(){
8615 this.disabled = false;
8618 onLoadException : function()
8622 if (typeof(arguments[3]) != 'undefined') {
8623 Roo.MessageBox.alert("Error loading",arguments[3]);
8627 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
8628 Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
8635 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
8640 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
8644 onBeforeLoad : function(){
8646 (function() { this.el.mask(this.msg, this.msgCls); }).defer(50, this);
8651 destroy : function(){
8653 this.store.un('beforeload', this.onBeforeLoad, this);
8654 this.store.un('load', this.onLoad, this);
8655 this.store.un('loadexception', this.onLoadException, this);
8657 var um = this.el.getUpdateManager();
8658 um.un('beforeupdate', this.onBeforeLoad, this);
8659 um.un('update', this.onLoad, this);
8660 um.un('failure', this.onLoad, this);
8664 * @class Roo.bootstrap.Table
8666 * @extends Roo.bootstrap.Component
8667 * Bootstrap Table class. This class represents the primary interface of a component based grid control.
8668 * Similar to Roo.grid.Grid
8670 var table = Roo.factory({
8672 xns : Roo.bootstrap,
8673 autoSizeColumns: true,
8680 sortInfo : { direction : 'ASC', field: 'name' },
8682 xtype : 'HttpProxy',
8685 url : 'https://example.com/some.data.url.json'
8688 xtype : 'JsonReader',
8690 fields : [ 'id', 'name', whatever' ],
8697 xtype : 'ColumnModel',
8701 dataIndex : 'is_in_group',
8704 renderer : function(v, x , r) {
8706 return String.format("{0}", v)
8712 xtype : 'RowSelectionModel',
8713 xns : Roo.bootstrap.Table
8714 // you can add listeners to catch selection change here....
8720 grid.render(Roo.get("some-div"));
8723 Currently the Table uses multiple headers to try and handle XL / Medium etc... styling
8728 * @cfg {Roo.grid.AbstractSelectionModel} sm The selection model to use (cell selection is not supported yet)
8729 * @cfg {Roo.data.Store} store The data store to use
8730 * @cfg {Roo.grid.ColumnModel} cm[] A column for th grid.
8732 * @cfg {String} cls table class
8735 * @cfg {boolean} striped Should the rows be alternative striped
8736 * @cfg {boolean} bordered Add borders to the table
8737 * @cfg {boolean} hover Add hover highlighting
8738 * @cfg {boolean} condensed Format condensed
8739 * @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,
8740 * also adds table-responsive (see bootstrap docs for details)
8741 * @cfg {Boolean} loadMask (true|false) default false
8742 * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
8743 * @cfg {Boolean} headerShow (true|false) generate thead, default true
8744 * @cfg {Boolean} rowSelection (true|false) default false
8745 * @cfg {Boolean} cellSelection (true|false) default false
8746 * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header
8747 * @cfg {Roo.bootstrap.PagingToolbar} footer a paging toolbar
8748 * @cfg {Boolean} lazyLoad auto load data while scrolling to the end (default false)
8749 * @cfg {Boolean} auto_hide_footer auto hide footer if only one page (default false)
8750 * @cfg {Boolean} enableColumnResize default true if columns can be resized (drag/drop)
8751 * @cfg {Number} minColumnWidth default 50 pixels minimum column width
8754 * Create a new Table
8755 * @param {Object} config The config object
8758 Roo.bootstrap.Table = function(config)
8760 Roo.bootstrap.Table.superclass.constructor.call(this, config);
8763 this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
8764 this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
8765 this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
8766 this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
8768 this.view = this; // compat with grid.
8770 this.sm = this.sm || {xtype: 'RowSelectionModel'};
8772 this.sm.grid = this;
8773 this.selModel = Roo.factory(this.sm, Roo.grid);
8774 this.sm = this.selModel;
8775 this.sm.xmodule = this.xmodule || false;
8778 if (this.cm && typeof(this.cm.config) == 'undefined') {
8779 this.colModel = new Roo.grid.ColumnModel(this.cm);
8780 this.cm = this.colModel;
8781 this.cm.xmodule = this.xmodule || false;
8784 this.store= Roo.factory(this.store, Roo.data);
8785 this.ds = this.store;
8786 this.ds.xmodule = this.xmodule || false;
8789 if (this.footer && this.store) {
8790 this.footer.dataSource = this.ds;
8791 this.footer = Roo.factory(this.footer);
8798 * Fires when a cell is clicked
8799 * @param {Roo.bootstrap.Table} this
8800 * @param {Roo.Element} el
8801 * @param {Number} rowIndex
8802 * @param {Number} columnIndex
8803 * @param {Roo.EventObject} e
8807 * @event celldblclick
8808 * Fires when a cell is double clicked
8809 * @param {Roo.bootstrap.Table} this
8810 * @param {Roo.Element} el
8811 * @param {Number} rowIndex
8812 * @param {Number} columnIndex
8813 * @param {Roo.EventObject} e
8815 "celldblclick" : true,
8818 * Fires when a row is clicked
8819 * @param {Roo.bootstrap.Table} this
8820 * @param {Roo.Element} el
8821 * @param {Number} rowIndex
8822 * @param {Roo.EventObject} e
8826 * @event rowdblclick
8827 * Fires when a row is double clicked
8828 * @param {Roo.bootstrap.Table} this
8829 * @param {Roo.Element} el
8830 * @param {Number} rowIndex
8831 * @param {Roo.EventObject} e
8833 "rowdblclick" : true,
8836 * Fires when a mouseover occur
8837 * @param {Roo.bootstrap.Table} this
8838 * @param {Roo.Element} el
8839 * @param {Number} rowIndex
8840 * @param {Number} columnIndex
8841 * @param {Roo.EventObject} e
8846 * Fires when a mouseout occur
8847 * @param {Roo.bootstrap.Table} this
8848 * @param {Roo.Element} el
8849 * @param {Number} rowIndex
8850 * @param {Number} columnIndex
8851 * @param {Roo.EventObject} e
8856 * Fires when a row is rendered, so you can change add a style to it.
8857 * @param {Roo.bootstrap.Table} this
8858 * @param {Object} rowcfg contains record rowIndex colIndex and rowClass - set rowClass to add a style.
8862 * @event rowsrendered
8863 * Fires when all the rows have been rendered
8864 * @param {Roo.bootstrap.Table} this
8866 'rowsrendered' : true,
8868 * @event contextmenu
8869 * The raw contextmenu event for the entire grid.
8870 * @param {Roo.EventObject} e
8872 "contextmenu" : true,
8874 * @event rowcontextmenu
8875 * Fires when a row is right clicked
8876 * @param {Roo.bootstrap.Table} this
8877 * @param {Number} rowIndex
8878 * @param {Roo.EventObject} e
8880 "rowcontextmenu" : true,
8882 * @event cellcontextmenu
8883 * Fires when a cell is right clicked
8884 * @param {Roo.bootstrap.Table} this
8885 * @param {Number} rowIndex
8886 * @param {Number} cellIndex
8887 * @param {Roo.EventObject} e
8889 "cellcontextmenu" : true,
8891 * @event headercontextmenu
8892 * Fires when a header is right clicked
8893 * @param {Roo.bootstrap.Table} this
8894 * @param {Number} columnIndex
8895 * @param {Roo.EventObject} e
8897 "headercontextmenu" : true,
8900 * The raw mousedown event for the entire grid.
8901 * @param {Roo.EventObject} e
8908 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
8924 enableColumnResize: true,
8926 rowSelection : false,
8927 cellSelection : false,
8930 minColumnWidth : 50,
8932 // Roo.Element - the tbody
8933 bodyEl: false, // <tbody> Roo.Element - thead element
8934 headEl: false, // <thead> Roo.Element - thead element
8935 resizeProxy : false, // proxy element for dragging?
8939 container: false, // used by gridpanel...
8945 auto_hide_footer : false,
8947 view: false, // actually points to this..
8949 getAutoCreate : function()
8951 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
8958 // this get's auto added by panel.Grid
8959 if (this.scrollBody) {
8960 cfg.cls += ' table-body-fixed';
8963 cfg.cls += ' table-striped';
8967 cfg.cls += ' table-hover';
8969 if (this.bordered) {
8970 cfg.cls += ' table-bordered';
8972 if (this.condensed) {
8973 cfg.cls += ' table-condensed';
8976 if (this.responsive) {
8977 cfg.cls += ' table-responsive';
8981 cfg.cls+= ' ' +this.cls;
8987 cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
8990 if(this.store || this.cm){
8991 if(this.headerShow){
8992 cfg.cn.push(this.renderHeader());
8995 cfg.cn.push(this.renderBody());
8997 if(this.footerShow){
8998 cfg.cn.push(this.renderFooter());
9000 // where does this come from?
9001 //cfg.cls+= ' TableGrid';
9004 return { cn : [ cfg ] };
9007 initEvents : function()
9009 if(!this.store || !this.cm){
9012 if (this.selModel) {
9013 this.selModel.initEvents();
9017 //Roo.log('initEvents with ds!!!!');
9019 this.bodyEl = this.el.select('tbody', true).first();
9020 this.headEl = this.el.select('thead', true).first();
9021 this.mainFoot = this.el.select('tfoot', true).first();
9026 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
9027 e.on('click', this.sort, this);
9031 // why is this done????? = it breaks dialogs??
9032 //this.parent().el.setStyle('position', 'relative');
9036 this.footer.parentId = this.id;
9037 this.footer.onRender(this.el.select('tfoot tr td').first(), null);
9040 this.el.select('tfoot tr td').first().addClass('hide');
9045 this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
9048 this.store.on('load', this.onLoad, this);
9049 this.store.on('beforeload', this.onBeforeLoad, this);
9050 this.store.on('update', this.onUpdate, this);
9051 this.store.on('add', this.onAdd, this);
9052 this.store.on("clear", this.clear, this);
9054 this.el.on("contextmenu", this.onContextMenu, this);
9057 this.cm.on("headerchange", this.onHeaderChange, this);
9058 this.cm.on("hiddenchange", this.onHiddenChange, this, arguments);
9060 //?? does bodyEl get replaced on render?
9061 this.bodyEl.on("click", this.onClick, this);
9062 this.bodyEl.on("dblclick", this.onDblClick, this);
9063 this.bodyEl.on('scroll', this.onBodyScroll, this);
9065 // guessing mainbody will work - this relays usually caught by selmodel at present.
9066 this.relayEvents(this.bodyEl, ["mousedown","mouseup","mouseover","mouseout","keypress"]);
9069 this.resizeProxy = Roo.get(document.body).createChild({ cls:"x-grid-resize-proxy", html: ' ' });
9072 if(this.headEl && this.enableColumnResize !== false && Roo.grid.SplitDragZone){
9073 new Roo.grid.SplitDragZone(this, this.headEl.dom, false); // not sure what 'lockedHd is for this implementation..)
9078 // Compatibility with grid - we implement all the view features at present.
9079 getView : function()
9084 initCSS : function()
9088 var cm = this.cm, styles = [];
9089 this.CSS.removeStyleSheet(this.id + '-cssrules');
9090 var headHeight = this.headEl ? this.headEl.dom.clientHeight : 0;
9091 // we can honour xs/sm/md/xl as widths...
9092 // we first have to decide what widht we are currently at...
9093 var sz = Roo.getGridSize();
9097 var cols = []; // visable cols.
9099 for(var i = 0, len = cm.getColumnCount(); i < len; i++) {
9100 var w = cm.getColumnWidth(i, false);
9102 cols.push( { rel : false, abs : 0 });
9106 cols.push( { rel : false, abs : w });
9108 last = i; // not really..
9111 var w = cm.getColumnWidth(i, sz);
9116 cols.push( { rel : w, abs : false });
9119 var avail = this.bodyEl.dom.clientWidth - total_abs;
9121 var unitWidth = Math.floor(avail / total);
9122 var rem = avail - (unitWidth * total);
9124 var hidden, width, pos = 0 , splithide , left;
9125 for(var i = 0, len = cm.getColumnCount(); i < len; i++) {
9127 hidden = 'display:none;';
9129 width = 'width:0px;';
9131 if(!cm.isHidden(i)){
9135 // we can honour xs/sm/md/xl ?
9136 var w = cols[i].rel == false ? cols[i].abs : (cols[i].rel * unitWidth);
9138 hidden = 'display:none;';
9140 // width should return a small number...
9142 w+=rem; // add the remaining with..
9145 left = "left:" + (pos -4) + "px;";
9146 width = "width:" + w+ "px;";
9149 if (this.responsive) {
9152 hidden = cm.isHidden(i) ? 'display:none;' : '';
9153 splithide = 'display: none;';
9156 styles.push( '#' , this.id , ' .x-col-' , i, " {", cm.config[i].css, width, hidden, "}\n" );
9159 splithide = 'display:none;';
9162 styles.push('#' , this.id , ' .x-hcol-' , i, " { ", width, hidden," }\n",
9163 '#' , this.id , ' .x-grid-split-' , i, " { ", left, splithide,'height:', (headHeight - 4), "px;}\n"
9168 //Roo.log(styles.join(''));
9169 this.CSS.createStyleSheet( styles.join(''), this.id + '-cssrules');
9175 onContextMenu : function(e, t)
9177 this.processEvent("contextmenu", e);
9180 processEvent : function(name, e)
9182 if (name != 'touchstart' ) {
9183 this.fireEvent(name, e);
9186 var t = e.getTarget();
9188 var cell = Roo.get(t);
9194 if(cell.findParent('tfoot', false, true)){
9198 if(cell.findParent('thead', false, true)){
9200 if(e.getTarget().nodeName.toLowerCase() != 'th'){
9201 cell = Roo.get(t).findParent('th', false, true);
9203 Roo.log("failed to find th in thead?");
9204 Roo.log(e.getTarget());
9209 var cellIndex = cell.dom.cellIndex;
9211 var ename = name == 'touchstart' ? 'click' : name;
9212 this.fireEvent("header" + ename, this, cellIndex, e);
9217 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9218 cell = Roo.get(t).findParent('td', false, true);
9220 Roo.log("failed to find th in tbody?");
9221 Roo.log(e.getTarget());
9226 var row = cell.findParent('tr', false, true);
9227 var cellIndex = cell.dom.cellIndex;
9228 var rowIndex = row.dom.rowIndex - 1;
9232 this.fireEvent("row" + name, this, rowIndex, e);
9236 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
9242 onMouseover : function(e, el)
9244 var cell = Roo.get(el);
9250 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9251 cell = cell.findParent('td', false, true);
9254 var row = cell.findParent('tr', false, true);
9255 var cellIndex = cell.dom.cellIndex;
9256 var rowIndex = row.dom.rowIndex - 1; // start from 0
9258 this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
9262 onMouseout : function(e, el)
9264 var cell = Roo.get(el);
9270 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9271 cell = cell.findParent('td', false, true);
9274 var row = cell.findParent('tr', false, true);
9275 var cellIndex = cell.dom.cellIndex;
9276 var rowIndex = row.dom.rowIndex - 1; // start from 0
9278 this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
9282 onClick : function(e, el)
9284 var cell = Roo.get(el);
9286 if(!cell || (!this.cellSelection && !this.rowSelection)){
9290 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9291 cell = cell.findParent('td', false, true);
9294 if(!cell || typeof(cell) == 'undefined'){
9298 var row = cell.findParent('tr', false, true);
9300 if(!row || typeof(row) == 'undefined'){
9304 var cellIndex = cell.dom.cellIndex;
9305 var rowIndex = this.getRowIndex(row);
9307 // why??? - should these not be based on SelectionModel?
9308 //if(this.cellSelection){
9309 this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
9312 //if(this.rowSelection){
9313 this.fireEvent('rowclick', this, row, rowIndex, e);
9318 onDblClick : function(e,el)
9320 var cell = Roo.get(el);
9322 if(!cell || (!this.cellSelection && !this.rowSelection)){
9326 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9327 cell = cell.findParent('td', false, true);
9330 if(!cell || typeof(cell) == 'undefined'){
9334 var row = cell.findParent('tr', false, true);
9336 if(!row || typeof(row) == 'undefined'){
9340 var cellIndex = cell.dom.cellIndex;
9341 var rowIndex = this.getRowIndex(row);
9343 if(this.cellSelection){
9344 this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
9347 if(this.rowSelection){
9348 this.fireEvent('rowdblclick', this, row, rowIndex, e);
9351 findRowIndex : function(el)
9353 var cell = Roo.get(el);
9357 var row = cell.findParent('tr', false, true);
9359 if(!row || typeof(row) == 'undefined'){
9362 return this.getRowIndex(row);
9364 sort : function(e,el)
9366 var col = Roo.get(el);
9368 if(!col.hasClass('sortable')){
9372 var sort = col.attr('sort');
9375 if(col.select('i', true).first().hasClass('fa-arrow-up')){
9379 this.store.sortInfo = {field : sort, direction : dir};
9382 Roo.log("calling footer first");
9383 this.footer.onClick('first');
9386 this.store.load({ params : { start : 0 } });
9390 renderHeader : function()
9398 this.totalWidth = 0;
9400 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
9402 var config = cm.config[i];
9406 cls : 'x-hcol-' + i,
9409 html: cm.getColumnHeader(i)
9412 var tooltip = cm.getColumnTooltip(i);
9414 c.tooltip = tooltip;
9420 if(typeof(config.sortable) != 'undefined' && config.sortable){
9421 c.cls += ' sortable';
9422 c.html = '<i class="fa"></i>' + c.html;
9425 // could use BS4 hidden-..-down
9427 if(typeof(config.lgHeader) != 'undefined'){
9428 hh += '<span class="hidden-xs hidden-sm hidden-md ">' + config.lgHeader + '</span>';
9431 if(typeof(config.mdHeader) != 'undefined'){
9432 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
9435 if(typeof(config.smHeader) != 'undefined'){
9436 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
9439 if(typeof(config.xsHeader) != 'undefined'){
9440 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
9447 if(typeof(config.tooltip) != 'undefined'){
9448 c.tooltip = config.tooltip;
9451 if(typeof(config.colspan) != 'undefined'){
9452 c.colspan = config.colspan;
9455 // hidden is handled by CSS now
9457 if(typeof(config.dataIndex) != 'undefined'){
9458 c.sort = config.dataIndex;
9463 if(typeof(config.align) != 'undefined' && config.align.length){
9464 c.style += ' text-align:' + config.align + ';';
9467 /* width is done in CSS
9468 *if(typeof(config.width) != 'undefined'){
9469 c.style += ' width:' + config.width + 'px;';
9470 this.totalWidth += config.width;
9472 this.totalWidth += 100; // assume minimum of 100 per column?
9476 if(typeof(config.cls) != 'undefined'){
9477 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
9479 // this is the bit that doesnt reall work at all...
9481 if (this.responsive) {
9484 ['xs','sm','md','lg'].map(function(size){
9486 if(typeof(config[size]) == 'undefined'){
9490 if (!config[size]) { // 0 = hidden
9491 // BS 4 '0' is treated as hide that column and below.
9492 c.cls += ' hidden-' + size + ' hidden' + size + '-down';
9496 c.cls += ' col-' + size + '-' + config[size] + (
9497 size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
9505 c.html +=' <span class="x-grid-split x-grid-split-' + i + '"></span>';
9516 renderBody : function()
9526 colspan : this.cm.getColumnCount()
9536 renderFooter : function()
9546 colspan : this.cm.getColumnCount()
9560 // Roo.log('ds onload');
9565 var ds = this.store;
9567 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
9568 e.select('i', true).removeClass(['fa-arrow-up', 'fa-arrow-down']);
9569 if (_this.store.sortInfo) {
9571 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
9572 e.select('i', true).addClass(['fa-arrow-up']);
9575 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
9576 e.select('i', true).addClass(['fa-arrow-down']);
9581 var tbody = this.bodyEl;
9583 if(ds.getCount() > 0){
9584 ds.data.each(function(d,rowIndex){
9585 var row = this.renderRow(cm, ds, rowIndex);
9587 tbody.createChild(row);
9591 if(row.cellObjects.length){
9592 Roo.each(row.cellObjects, function(r){
9593 _this.renderCellObject(r);
9600 var tfoot = this.el.select('tfoot', true).first();
9602 if(this.footerShow && this.auto_hide_footer && this.mainFoot){
9604 this.mainFoot.setVisibilityMode(Roo.Element.DISPLAY).hide();
9606 var total = this.ds.getTotalCount();
9608 if(this.footer.pageSize < total){
9609 this.mainFoot.show();
9613 Roo.each(this.el.select('tbody td', true).elements, function(e){
9614 e.on('mouseover', _this.onMouseover, _this);
9617 Roo.each(this.el.select('tbody td', true).elements, function(e){
9618 e.on('mouseout', _this.onMouseout, _this);
9620 this.fireEvent('rowsrendered', this);
9624 this.initCSS(); /// resize cols
9630 onUpdate : function(ds,record)
9632 this.refreshRow(record);
9636 onRemove : function(ds, record, index, isUpdate){
9637 if(isUpdate !== true){
9638 this.fireEvent("beforerowremoved", this, index, record);
9640 var bt = this.bodyEl.dom;
9642 var rows = this.el.select('tbody > tr', true).elements;
9644 if(typeof(rows[index]) != 'undefined'){
9645 bt.removeChild(rows[index].dom);
9648 // if(bt.rows[index]){
9649 // bt.removeChild(bt.rows[index]);
9652 if(isUpdate !== true){
9653 //this.stripeRows(index);
9654 //this.syncRowHeights(index, index);
9656 this.fireEvent("rowremoved", this, index, record);
9660 onAdd : function(ds, records, rowIndex)
9662 //Roo.log('on Add called');
9663 // - note this does not handle multiple adding very well..
9664 var bt = this.bodyEl.dom;
9665 for (var i =0 ; i < records.length;i++) {
9666 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
9667 //Roo.log(records[i]);
9668 //Roo.log(this.store.getAt(rowIndex+i));
9669 this.insertRow(this.store, rowIndex + i, false);
9676 refreshRow : function(record){
9677 var ds = this.store, index;
9678 if(typeof record == 'number'){
9680 record = ds.getAt(index);
9682 index = ds.indexOf(record);
9684 return; // should not happen - but seems to
9687 this.insertRow(ds, index, true);
9689 this.onRemove(ds, record, index+1, true);
9691 //this.syncRowHeights(index, index);
9693 this.fireEvent("rowupdated", this, index, record);
9695 // private - called by RowSelection
9696 onRowSelect : function(rowIndex){
9697 var row = this.getRowDom(rowIndex);
9698 row.addClass(['bg-info','info']);
9700 // private - called by RowSelection
9701 onRowDeselect : function(rowIndex)
9706 var row = this.getRowDom(rowIndex);
9707 row.removeClass(['bg-info','info']);
9710 * Focuses the specified row.
9711 * @param {Number} row The row index
9713 focusRow : function(row)
9715 //Roo.log('GridView.focusRow');
9716 var x = this.bodyEl.dom.scrollLeft;
9717 this.focusCell(row, 0, false);
9718 this.bodyEl.dom.scrollLeft = x;
9722 * Focuses the specified cell.
9723 * @param {Number} row The row index
9724 * @param {Number} col The column index
9725 * @param {Boolean} hscroll false to disable horizontal scrolling
9727 focusCell : function(row, col, hscroll)
9729 //Roo.log('GridView.focusCell');
9730 var el = this.ensureVisible(row, col, hscroll);
9731 // not sure what focusEL achives = it's a <a> pos relative
9732 //this.focusEl.alignTo(el, "tl-tl");
9734 // this.focusEl.focus();
9736 // this.focusEl.focus.defer(1, this.focusEl);
9741 * Scrolls the specified cell into view
9742 * @param {Number} row The row index
9743 * @param {Number} col The column index
9744 * @param {Boolean} hscroll false to disable horizontal scrolling
9746 ensureVisible : function(row, col, hscroll)
9748 //Roo.log('GridView.ensureVisible,' + row + ',' + col);
9749 //return null; //disable for testing.
9750 if(typeof row != "number"){
9753 if(row < 0 && row >= this.ds.getCount()){
9756 col = (col !== undefined ? col : 0);
9758 while(cm.isHidden(col)){
9762 var el = this.getCellDom(row, col);
9766 var c = this.bodyEl.dom;
9768 var ctop = parseInt(el.offsetTop, 10);
9769 var cleft = parseInt(el.offsetLeft, 10);
9770 var cbot = ctop + el.offsetHeight;
9771 var cright = cleft + el.offsetWidth;
9773 //var ch = c.clientHeight - this.mainHd.dom.offsetHeight;
9774 var ch = 0; //?? header is not withing the area?
9775 var stop = parseInt(c.scrollTop, 10);
9776 var sleft = parseInt(c.scrollLeft, 10);
9777 var sbot = stop + ch;
9778 var sright = sleft + c.clientWidth;
9780 Roo.log('GridView.ensureVisible:' +
9782 ' c.clientHeight:' + c.clientHeight +
9783 ' this.mainHd.dom.offsetHeight:' + this.mainHd.dom.offsetHeight +
9792 //Roo.log("set scrolltop to ctop DISABLE?");
9793 }else if(cbot > sbot){
9794 //Roo.log("set scrolltop to cbot-ch");
9795 c.scrollTop = cbot-ch;
9798 if(hscroll !== false){
9800 c.scrollLeft = cleft;
9801 }else if(cright > sright){
9802 c.scrollLeft = cright-c.clientWidth;
9810 insertRow : function(dm, rowIndex, isUpdate){
9813 this.fireEvent("beforerowsinserted", this, rowIndex);
9815 //var s = this.getScrollState();
9816 var row = this.renderRow(this.cm, this.store, rowIndex);
9817 // insert before rowIndex..
9818 var e = this.bodyEl.createChild(row,this.getRowDom(rowIndex));
9822 if(row.cellObjects.length){
9823 Roo.each(row.cellObjects, function(r){
9824 _this.renderCellObject(r);
9829 this.fireEvent("rowsinserted", this, rowIndex);
9830 //this.syncRowHeights(firstRow, lastRow);
9831 //this.stripeRows(firstRow);
9838 getRowDom : function(rowIndex)
9840 var rows = this.el.select('tbody > tr', true).elements;
9842 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
9845 getCellDom : function(rowIndex, colIndex)
9847 var row = this.getRowDom(rowIndex);
9848 if (row === false) {
9851 var cols = row.select('td', true).elements;
9852 return (typeof(cols[colIndex]) == 'undefined') ? false : cols[colIndex];
9856 // returns the object tree for a tr..
9859 renderRow : function(cm, ds, rowIndex)
9861 var d = ds.getAt(rowIndex);
9865 cls : 'x-row-' + rowIndex,
9869 var cellObjects = [];
9871 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
9872 var config = cm.config[i];
9874 var renderer = cm.getRenderer(i);
9878 if(typeof(renderer) !== 'undefined'){
9879 value = renderer(d.data[cm.getDataIndex(i)], false, d);
9881 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
9882 // and are rendered into the cells after the row is rendered - using the id for the element.
9884 if(typeof(value) === 'object'){
9894 rowIndex : rowIndex,
9899 this.fireEvent('rowclass', this, rowcfg);
9903 // this might end up displaying HTML?
9904 // this is too messy... - better to only do it on columsn you know are going to be too long
9905 //tooltip : (typeof(value) === 'object') ? '' : value,
9906 cls : rowcfg.rowClass + ' x-col-' + i,
9908 html: (typeof(value) === 'object') ? '' : value
9915 if(typeof(config.colspan) != 'undefined'){
9916 td.colspan = config.colspan;
9921 if(typeof(config.align) != 'undefined' && config.align.length){
9922 td.style += ' text-align:' + config.align + ';';
9924 if(typeof(config.valign) != 'undefined' && config.valign.length){
9925 td.style += ' vertical-align:' + config.valign + ';';
9928 if(typeof(config.width) != 'undefined'){
9929 td.style += ' width:' + config.width + 'px;';
9933 if(typeof(config.cursor) != 'undefined'){
9934 td.style += ' cursor:' + config.cursor + ';';
9937 if(typeof(config.cls) != 'undefined'){
9938 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
9940 if (this.responsive) {
9941 ['xs','sm','md','lg'].map(function(size){
9943 if(typeof(config[size]) == 'undefined'){
9949 if (!config[size]) { // 0 = hidden
9950 // BS 4 '0' is treated as hide that column and below.
9951 td.cls += ' hidden-' + size + ' hidden' + size + '-down';
9955 td.cls += ' col-' + size + '-' + config[size] + (
9956 size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
9966 row.cellObjects = cellObjects;
9974 onBeforeLoad : function()
9983 this.el.select('tbody', true).first().dom.innerHTML = '';
9986 * Show or hide a row.
9987 * @param {Number} rowIndex to show or hide
9988 * @param {Boolean} state hide
9990 setRowVisibility : function(rowIndex, state)
9992 var bt = this.bodyEl.dom;
9994 var rows = this.el.select('tbody > tr', true).elements;
9996 if(typeof(rows[rowIndex]) == 'undefined'){
9999 rows[rowIndex][ state ? 'removeClass' : 'addClass']('d-none');
10004 getSelectionModel : function(){
10005 if(!this.selModel){
10006 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
10008 return this.selModel;
10011 * Render the Roo.bootstrap object from renderder
10013 renderCellObject : function(r)
10017 r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
10019 var t = r.cfg.render(r.container);
10022 Roo.each(r.cfg.cn, function(c){
10024 container: t.getChildContainer(),
10027 _this.renderCellObject(child);
10032 * get the Row Index from a dom element.
10033 * @param {Roo.Element} row The row to look for
10034 * @returns {Number} the row
10036 getRowIndex : function(row)
10040 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
10051 * get the header TH element for columnIndex
10052 * @param {Number} columnIndex
10053 * @returns {Roo.Element}
10055 getHeaderIndex: function(colIndex)
10057 var cols = this.headEl.select('th', true).elements;
10058 return cols[colIndex];
10061 * get the Column Index from a dom element. (using regex on x-hcol-{colid})
10062 * @param {domElement} cell to look for
10063 * @returns {Number} the column
10065 getCellIndex : function(cell)
10067 var id = String(cell.className).match(Roo.bootstrap.Table.cellRE);
10069 return parseInt(id[1], 10);
10074 * Returns the grid's underlying element = used by panel.Grid
10075 * @return {Element} The element
10077 getGridEl : function(){
10081 * Forces a resize - used by panel.Grid
10082 * @return {Element} The element
10084 autoSize : function()
10086 //var ctr = Roo.get(this.container.dom.parentElement);
10087 var ctr = Roo.get(this.el.dom);
10089 var thd = this.getGridEl().select('thead',true).first();
10090 var tbd = this.getGridEl().select('tbody', true).first();
10091 var tfd = this.getGridEl().select('tfoot', true).first();
10093 var cw = ctr.getWidth();
10094 this.getGridEl().select('tfoot tr, tfoot td',true).setWidth(cw);
10098 tbd.setWidth(ctr.getWidth());
10099 // if the body has a max height - and then scrolls - we should perhaps set up the height here
10100 // this needs fixing for various usage - currently only hydra job advers I think..
10102 // ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
10104 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
10107 cw = Math.max(cw, this.totalWidth);
10108 this.getGridEl().select('tbody tr',true).setWidth(cw);
10111 // resize 'expandable coloumn?
10113 return; // we doe not have a view in this design..
10116 onBodyScroll: function()
10118 //Roo.log("body scrolled');" + this.bodyEl.dom.scrollLeft);
10120 this.headEl.setStyle({
10121 'position' : 'relative',
10122 'left': (-1* this.bodyEl.dom.scrollLeft) + 'px'
10128 var scrollHeight = this.bodyEl.dom.scrollHeight;
10130 var scrollTop = Math.ceil(this.bodyEl.getScroll().top);
10132 var height = this.bodyEl.getHeight();
10134 if(scrollHeight - height == scrollTop) {
10136 var total = this.ds.getTotalCount();
10138 if(this.footer.cursor + this.footer.pageSize < total){
10140 this.footer.ds.load({
10142 start : this.footer.cursor + this.footer.pageSize,
10143 limit : this.footer.pageSize
10152 onColumnSplitterMoved : function(i, diff)
10154 this.userResized = true;
10156 var cm = this.colModel;
10158 var w = this.getHeaderIndex(i).getWidth() + diff;
10161 cm.setColumnWidth(i, w, true);
10163 //var cid = cm.getColumnId(i); << not used in this version?
10164 /* Roo.log(['#' + this.id + ' .x-col-' + i, "width", w + "px"]);
10166 this.CSS.updateRule( '#' + this.id + ' .x-col-' + i, "width", w + "px");
10167 this.CSS.updateRule('#' + this.id + ' .x-hcol-' + i, "width", w + "px");
10168 this.CSS.updateRule('#' + this.id + ' .x-grid-split-' + i, "left", w + "px");
10170 //this.updateSplitters();
10171 //this.layout(); << ??
10172 this.fireEvent("columnresize", i, w);
10174 onHeaderChange : function()
10176 var header = this.renderHeader();
10177 var table = this.el.select('table', true).first();
10179 this.headEl.remove();
10180 this.headEl = table.createChild(header, this.bodyEl, false);
10182 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
10183 e.on('click', this.sort, this);
10186 if(this.enableColumnResize !== false && Roo.grid.SplitDragZone){
10187 new Roo.grid.SplitDragZone(this, this.headEl.dom, false); // not sure what 'lockedHd is for this implementation..)
10192 onHiddenChange : function(colModel, colIndex, hidden)
10195 this.cm.setHidden()
10196 var thSelector = '#' + this.id + ' .x-hcol-' + colIndex;
10197 var tdSelector = '#' + this.id + ' .x-col-' + colIndex;
10199 this.CSS.updateRule(thSelector, "display", "");
10200 this.CSS.updateRule(tdSelector, "display", "");
10203 this.CSS.updateRule(thSelector, "display", "none");
10204 this.CSS.updateRule(tdSelector, "display", "none");
10207 // onload calls initCSS()
10208 this.onHeaderChange();
10212 setColumnWidth: function(col_index, width)
10214 // width = "md-2 xs-2..."
10215 if(!this.colModel.config[col_index]) {
10219 var w = width.split(" ");
10221 var rows = this.el.dom.getElementsByClassName("x-col-"+col_index);
10223 var h_row = this.el.dom.getElementsByClassName("x-hcol-"+col_index);
10226 for(var j = 0; j < w.length; j++) {
10232 var size_cls = w[j].split("-");
10234 if(!Number.isInteger(size_cls[1] * 1)) {
10238 if(!this.colModel.config[col_index][size_cls[0]]) {
10242 if(!h_row[0].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
10246 h_row[0].classList.replace(
10247 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
10248 "col-"+size_cls[0]+"-"+size_cls[1]
10251 for(var i = 0; i < rows.length; i++) {
10253 var size_cls = w[j].split("-");
10255 if(!Number.isInteger(size_cls[1] * 1)) {
10259 if(!this.colModel.config[col_index][size_cls[0]]) {
10263 if(!rows[i].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
10267 rows[i].classList.replace(
10268 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
10269 "col-"+size_cls[0]+"-"+size_cls[1]
10273 this.colModel.config[col_index][size_cls[0]] = size_cls[1];
10278 // currently only used to find the split on drag..
10279 Roo.bootstrap.Table.cellRE = /(?:.*?)x-grid-(?:hd|cell|split)-([\d]+)(?:.*?)/;
10284 Roo.bootstrap.Table.AbstractSelectionModel = Roo.grid.AbstractSelectionModel;
10285 Roo.bootstrap.Table.RowSelectionModel = Roo.grid.RowSelectionModel;
10294 * @class Roo.bootstrap.TableCell
10295 * @extends Roo.bootstrap.Component
10296 * Bootstrap TableCell class
10297 * @cfg {String} html cell contain text
10298 * @cfg {String} cls cell class
10299 * @cfg {String} tag cell tag (td|th) default td
10300 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
10301 * @cfg {String} align Aligns the content in a cell
10302 * @cfg {String} axis Categorizes cells
10303 * @cfg {String} bgcolor Specifies the background color of a cell
10304 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
10305 * @cfg {Number} colspan Specifies the number of columns a cell should span
10306 * @cfg {String} headers Specifies one or more header cells a cell is related to
10307 * @cfg {Number} height Sets the height of a cell
10308 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
10309 * @cfg {Number} rowspan Sets the number of rows a cell should span
10310 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
10311 * @cfg {String} valign Vertical aligns the content in a cell
10312 * @cfg {Number} width Specifies the width of a cell
10315 * Create a new TableCell
10316 * @param {Object} config The config object
10319 Roo.bootstrap.TableCell = function(config){
10320 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
10323 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
10343 getAutoCreate : function(){
10344 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
10351 cfg.tag = this.tag;
10364 cfg.align=this.align
10369 if (this.bgcolor) {
10370 cfg.bgcolor=this.bgcolor
10372 if (this.charoff) {
10373 cfg.charoff=this.charoff
10375 if (this.colspan) {
10376 cfg.colspan=this.colspan
10378 if (this.headers) {
10379 cfg.headers=this.headers
10382 cfg.height=this.height
10385 cfg.nowrap=this.nowrap
10387 if (this.rowspan) {
10388 cfg.rowspan=this.rowspan
10391 cfg.scope=this.scope
10394 cfg.valign=this.valign
10397 cfg.width=this.width
10416 * @class Roo.bootstrap.TableRow
10417 * @extends Roo.bootstrap.Component
10418 * Bootstrap TableRow class
10419 * @cfg {String} cls row class
10420 * @cfg {String} align Aligns the content in a table row
10421 * @cfg {String} bgcolor Specifies a background color for a table row
10422 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
10423 * @cfg {String} valign Vertical aligns the content in a table row
10426 * Create a new TableRow
10427 * @param {Object} config The config object
10430 Roo.bootstrap.TableRow = function(config){
10431 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
10434 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
10442 getAutoCreate : function(){
10443 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
10450 cfg.cls = this.cls;
10453 cfg.align = this.align;
10456 cfg.bgcolor = this.bgcolor;
10459 cfg.charoff = this.charoff;
10462 cfg.valign = this.valign;
10480 * @class Roo.bootstrap.TableBody
10481 * @extends Roo.bootstrap.Component
10482 * Bootstrap TableBody class
10483 * @cfg {String} cls element class
10484 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
10485 * @cfg {String} align Aligns the content inside the element
10486 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
10487 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
10490 * Create a new TableBody
10491 * @param {Object} config The config object
10494 Roo.bootstrap.TableBody = function(config){
10495 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
10498 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
10506 getAutoCreate : function(){
10507 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
10517 cfg.tag = this.tag;
10521 cfg.align = this.align;
10524 cfg.charoff = this.charoff;
10527 cfg.valign = this.valign;
10534 // initEvents : function()
10537 // if(!this.store){
10541 // this.store = Roo.factory(this.store, Roo.data);
10542 // this.store.on('load', this.onLoad, this);
10544 // this.store.load();
10548 // onLoad: function ()
10550 // this.fireEvent('load', this);
10560 * Ext JS Library 1.1.1
10561 * Copyright(c) 2006-2007, Ext JS, LLC.
10563 * Originally Released Under LGPL - original licence link has changed is not relivant.
10566 * <script type="text/javascript">
10569 // as we use this in bootstrap.
10570 Roo.namespace('Roo.form');
10572 * @class Roo.form.Action
10573 * Internal Class used to handle form actions
10575 * @param {Roo.form.BasicForm} el The form element or its id
10576 * @param {Object} config Configuration options
10581 // define the action interface
10582 Roo.form.Action = function(form, options){
10584 this.options = options || {};
10587 * Client Validation Failed
10590 Roo.form.Action.CLIENT_INVALID = 'client';
10592 * Server Validation Failed
10595 Roo.form.Action.SERVER_INVALID = 'server';
10597 * Connect to Server Failed
10600 Roo.form.Action.CONNECT_FAILURE = 'connect';
10602 * Reading Data from Server Failed
10605 Roo.form.Action.LOAD_FAILURE = 'load';
10607 Roo.form.Action.prototype = {
10609 failureType : undefined,
10610 response : undefined,
10611 result : undefined,
10613 // interface method
10614 run : function(options){
10618 // interface method
10619 success : function(response){
10623 // interface method
10624 handleResponse : function(response){
10628 // default connection failure
10629 failure : function(response){
10631 this.response = response;
10632 this.failureType = Roo.form.Action.CONNECT_FAILURE;
10633 this.form.afterAction(this, false);
10636 processResponse : function(response){
10637 this.response = response;
10638 if(!response.responseText){
10641 this.result = this.handleResponse(response);
10642 return this.result;
10645 // utility functions used internally
10646 getUrl : function(appendParams){
10647 var url = this.options.url || this.form.url || this.form.el.dom.action;
10649 var p = this.getParams();
10651 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
10657 getMethod : function(){
10658 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
10661 getParams : function(){
10662 var bp = this.form.baseParams;
10663 var p = this.options.params;
10665 if(typeof p == "object"){
10666 p = Roo.urlEncode(Roo.applyIf(p, bp));
10667 }else if(typeof p == 'string' && bp){
10668 p += '&' + Roo.urlEncode(bp);
10671 p = Roo.urlEncode(bp);
10676 createCallback : function(){
10678 success: this.success,
10679 failure: this.failure,
10681 timeout: (this.form.timeout*1000),
10682 upload: this.form.fileUpload ? this.success : undefined
10687 Roo.form.Action.Submit = function(form, options){
10688 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
10691 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
10694 haveProgress : false,
10695 uploadComplete : false,
10697 // uploadProgress indicator.
10698 uploadProgress : function()
10700 if (!this.form.progressUrl) {
10704 if (!this.haveProgress) {
10705 Roo.MessageBox.progress("Uploading", "Uploading");
10707 if (this.uploadComplete) {
10708 Roo.MessageBox.hide();
10712 this.haveProgress = true;
10714 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
10716 var c = new Roo.data.Connection();
10718 url : this.form.progressUrl,
10723 success : function(req){
10724 //console.log(data);
10728 rdata = Roo.decode(req.responseText)
10730 Roo.log("Invalid data from server..");
10734 if (!rdata || !rdata.success) {
10736 Roo.MessageBox.alert(Roo.encode(rdata));
10739 var data = rdata.data;
10741 if (this.uploadComplete) {
10742 Roo.MessageBox.hide();
10747 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
10748 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
10751 this.uploadProgress.defer(2000,this);
10754 failure: function(data) {
10755 Roo.log('progress url failed ');
10766 // run get Values on the form, so it syncs any secondary forms.
10767 this.form.getValues();
10769 var o = this.options;
10770 var method = this.getMethod();
10771 var isPost = method == 'POST';
10772 if(o.clientValidation === false || this.form.isValid()){
10774 if (this.form.progressUrl) {
10775 this.form.findField('UPLOAD_IDENTIFIER').setValue(
10776 (new Date() * 1) + '' + Math.random());
10781 Roo.Ajax.request(Roo.apply(this.createCallback(), {
10782 form:this.form.el.dom,
10783 url:this.getUrl(!isPost),
10785 params:isPost ? this.getParams() : null,
10786 isUpload: this.form.fileUpload,
10787 formData : this.form.formData
10790 this.uploadProgress();
10792 }else if (o.clientValidation !== false){ // client validation failed
10793 this.failureType = Roo.form.Action.CLIENT_INVALID;
10794 this.form.afterAction(this, false);
10798 success : function(response)
10800 this.uploadComplete= true;
10801 if (this.haveProgress) {
10802 Roo.MessageBox.hide();
10806 var result = this.processResponse(response);
10807 if(result === true || result.success){
10808 this.form.afterAction(this, true);
10812 this.form.markInvalid(result.errors);
10813 this.failureType = Roo.form.Action.SERVER_INVALID;
10815 this.form.afterAction(this, false);
10817 failure : function(response)
10819 this.uploadComplete= true;
10820 if (this.haveProgress) {
10821 Roo.MessageBox.hide();
10824 this.response = response;
10825 this.failureType = Roo.form.Action.CONNECT_FAILURE;
10826 this.form.afterAction(this, false);
10829 handleResponse : function(response){
10830 if(this.form.errorReader){
10831 var rs = this.form.errorReader.read(response);
10834 for(var i = 0, len = rs.records.length; i < len; i++) {
10835 var r = rs.records[i];
10836 errors[i] = r.data;
10839 if(errors.length < 1){
10843 success : rs.success,
10849 ret = Roo.decode(response.responseText);
10853 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
10863 Roo.form.Action.Load = function(form, options){
10864 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
10865 this.reader = this.form.reader;
10868 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
10873 Roo.Ajax.request(Roo.apply(
10874 this.createCallback(), {
10875 method:this.getMethod(),
10876 url:this.getUrl(false),
10877 params:this.getParams()
10881 success : function(response){
10883 var result = this.processResponse(response);
10884 if(result === true || !result.success || !result.data){
10885 this.failureType = Roo.form.Action.LOAD_FAILURE;
10886 this.form.afterAction(this, false);
10889 this.form.clearInvalid();
10890 this.form.setValues(result.data);
10891 this.form.afterAction(this, true);
10894 handleResponse : function(response){
10895 if(this.form.reader){
10896 var rs = this.form.reader.read(response);
10897 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
10899 success : rs.success,
10903 return Roo.decode(response.responseText);
10907 Roo.form.Action.ACTION_TYPES = {
10908 'load' : Roo.form.Action.Load,
10909 'submit' : Roo.form.Action.Submit
10918 * @class Roo.bootstrap.Form
10919 * @extends Roo.bootstrap.Component
10920 * @children Roo.bootstrap.Component
10921 * Bootstrap Form class
10922 * @cfg {String} method GET | POST (default POST)
10923 * @cfg {String} labelAlign top | left (default top)
10924 * @cfg {String} align left | right - for navbars
10925 * @cfg {Boolean} loadMask load mask when submit (default true)
10929 * Create a new Form
10930 * @param {Object} config The config object
10934 Roo.bootstrap.Form = function(config){
10936 Roo.bootstrap.Form.superclass.constructor.call(this, config);
10938 Roo.bootstrap.Form.popover.apply();
10942 * @event clientvalidation
10943 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
10944 * @param {Form} this
10945 * @param {Boolean} valid true if the form has passed client-side validation
10947 clientvalidation: true,
10949 * @event beforeaction
10950 * Fires before any action is performed. Return false to cancel the action.
10951 * @param {Form} this
10952 * @param {Action} action The action to be performed
10954 beforeaction: true,
10956 * @event actionfailed
10957 * Fires when an action fails.
10958 * @param {Form} this
10959 * @param {Action} action The action that failed
10961 actionfailed : true,
10963 * @event actioncomplete
10964 * Fires when an action is completed.
10965 * @param {Form} this
10966 * @param {Action} action The action that completed
10968 actioncomplete : true
10972 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
10975 * @cfg {String} method
10976 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
10980 * @cfg {String} url
10981 * The URL to use for form actions if one isn't supplied in the action options.
10984 * @cfg {Boolean} fileUpload
10985 * Set to true if this form is a file upload.
10989 * @cfg {Object} baseParams
10990 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
10994 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
10998 * @cfg {Sting} align (left|right) for navbar forms
11003 activeAction : null,
11006 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
11007 * element by passing it or its id or mask the form itself by passing in true.
11010 waitMsgTarget : false,
11015 * @cfg {Boolean} errorMask (true|false) default false
11020 * @cfg {Number} maskOffset Default 100
11025 * @cfg {Boolean} maskBody
11029 getAutoCreate : function(){
11033 method : this.method || 'POST',
11034 id : this.id || Roo.id(),
11037 if (this.parent().xtype.match(/^Nav/)) {
11038 cfg.cls = 'navbar-form form-inline navbar-' + this.align;
11042 if (this.labelAlign == 'left' ) {
11043 cfg.cls += ' form-horizontal';
11049 initEvents : function()
11051 this.el.on('submit', this.onSubmit, this);
11052 // this was added as random key presses on the form where triggering form submit.
11053 this.el.on('keypress', function(e) {
11054 if (e.getCharCode() != 13) {
11057 // we might need to allow it for textareas.. and some other items.
11058 // check e.getTarget().
11060 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
11064 Roo.log("keypress blocked");
11066 e.preventDefault();
11072 onSubmit : function(e){
11077 * Returns true if client-side validation on the form is successful.
11080 isValid : function(){
11081 var items = this.getItems();
11083 var target = false;
11085 items.each(function(f){
11091 Roo.log('invalid field: ' + f.name);
11095 if(!target && f.el.isVisible(true)){
11101 if(this.errorMask && !valid){
11102 Roo.bootstrap.Form.popover.mask(this, target);
11109 * Returns true if any fields in this form have changed since their original load.
11112 isDirty : function(){
11114 var items = this.getItems();
11115 items.each(function(f){
11125 * Performs a predefined action (submit or load) or custom actions you define on this form.
11126 * @param {String} actionName The name of the action type
11127 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
11128 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
11129 * accept other config options):
11131 Property Type Description
11132 ---------------- --------------- ----------------------------------------------------------------------------------
11133 url String The url for the action (defaults to the form's url)
11134 method String The form method to use (defaults to the form's method, or POST if not defined)
11135 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
11136 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
11137 validate the form on the client (defaults to false)
11139 * @return {BasicForm} this
11141 doAction : function(action, options){
11142 if(typeof action == 'string'){
11143 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
11145 if(this.fireEvent('beforeaction', this, action) !== false){
11146 this.beforeAction(action);
11147 action.run.defer(100, action);
11153 beforeAction : function(action){
11154 var o = action.options;
11159 Roo.get(document.body).mask(o.waitMsg || "Sending", 'x-mask-loading')
11161 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
11164 // not really supported yet.. ??
11166 //if(this.waitMsgTarget === true){
11167 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
11168 //}else if(this.waitMsgTarget){
11169 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
11170 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
11172 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
11178 afterAction : function(action, success){
11179 this.activeAction = null;
11180 var o = action.options;
11185 Roo.get(document.body).unmask();
11191 //if(this.waitMsgTarget === true){
11192 // this.el.unmask();
11193 //}else if(this.waitMsgTarget){
11194 // this.waitMsgTarget.unmask();
11196 // Roo.MessageBox.updateProgress(1);
11197 // Roo.MessageBox.hide();
11204 Roo.callback(o.success, o.scope, [this, action]);
11205 this.fireEvent('actioncomplete', this, action);
11209 // failure condition..
11210 // we have a scenario where updates need confirming.
11211 // eg. if a locking scenario exists..
11212 // we look for { errors : { needs_confirm : true }} in the response.
11214 (typeof(action.result) != 'undefined') &&
11215 (typeof(action.result.errors) != 'undefined') &&
11216 (typeof(action.result.errors.needs_confirm) != 'undefined')
11219 Roo.log("not supported yet");
11222 Roo.MessageBox.confirm(
11223 "Change requires confirmation",
11224 action.result.errorMsg,
11229 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
11239 Roo.callback(o.failure, o.scope, [this, action]);
11240 // show an error message if no failed handler is set..
11241 if (!this.hasListener('actionfailed')) {
11242 Roo.log("need to add dialog support");
11244 Roo.MessageBox.alert("Error",
11245 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
11246 action.result.errorMsg :
11247 "Saving Failed, please check your entries or try again"
11252 this.fireEvent('actionfailed', this, action);
11257 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
11258 * @param {String} id The value to search for
11261 findField : function(id){
11262 var items = this.getItems();
11263 var field = items.get(id);
11265 items.each(function(f){
11266 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
11273 return field || null;
11276 * Mark fields in this form invalid in bulk.
11277 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
11278 * @return {BasicForm} this
11280 markInvalid : function(errors){
11281 if(errors instanceof Array){
11282 for(var i = 0, len = errors.length; i < len; i++){
11283 var fieldError = errors[i];
11284 var f = this.findField(fieldError.id);
11286 f.markInvalid(fieldError.msg);
11292 if(typeof errors[id] != 'function' && (field = this.findField(id))){
11293 field.markInvalid(errors[id]);
11297 //Roo.each(this.childForms || [], function (f) {
11298 // f.markInvalid(errors);
11305 * Set values for fields in this form in bulk.
11306 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
11307 * @return {BasicForm} this
11309 setValues : function(values){
11310 if(values instanceof Array){ // array of objects
11311 for(var i = 0, len = values.length; i < len; i++){
11313 var f = this.findField(v.id);
11315 f.setValue(v.value);
11316 if(this.trackResetOnLoad){
11317 f.originalValue = f.getValue();
11321 }else{ // object hash
11324 if(typeof values[id] != 'function' && (field = this.findField(id))){
11326 if (field.setFromData &&
11327 field.valueField &&
11328 field.displayField &&
11329 // combos' with local stores can
11330 // be queried via setValue()
11331 // to set their value..
11332 (field.store && !field.store.isLocal)
11336 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
11337 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
11338 field.setFromData(sd);
11340 } else if(field.setFromData && (field.store && !field.store.isLocal)) {
11342 field.setFromData(values);
11345 field.setValue(values[id]);
11349 if(this.trackResetOnLoad){
11350 field.originalValue = field.getValue();
11356 //Roo.each(this.childForms || [], function (f) {
11357 // f.setValues(values);
11364 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
11365 * they are returned as an array.
11366 * @param {Boolean} asString
11369 getValues : function(asString){
11370 //if (this.childForms) {
11371 // copy values from the child forms
11372 // Roo.each(this.childForms, function (f) {
11373 // this.setValues(f.getValues());
11379 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
11380 if(asString === true){
11383 return Roo.urlDecode(fs);
11387 * Returns the fields in this form as an object with key/value pairs.
11388 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
11391 getFieldValues : function(with_hidden)
11393 var items = this.getItems();
11395 items.each(function(f){
11397 if (!f.getName()) {
11401 var v = f.getValue();
11403 if (f.inputType =='radio') {
11404 if (typeof(ret[f.getName()]) == 'undefined') {
11405 ret[f.getName()] = ''; // empty..
11408 if (!f.el.dom.checked) {
11412 v = f.el.dom.value;
11416 if(f.xtype == 'MoneyField'){
11417 ret[f.currencyName] = f.getCurrency();
11420 // not sure if this supported any more..
11421 if ((typeof(v) == 'object') && f.getRawValue) {
11422 v = f.getRawValue() ; // dates..
11424 // combo boxes where name != hiddenName...
11425 if (f.name !== false && f.name != '' && f.name != f.getName()) {
11426 ret[f.name] = f.getRawValue();
11428 ret[f.getName()] = v;
11435 * Clears all invalid messages in this form.
11436 * @return {BasicForm} this
11438 clearInvalid : function(){
11439 var items = this.getItems();
11441 items.each(function(f){
11449 * Resets this form.
11450 * @return {BasicForm} this
11452 reset : function(){
11453 var items = this.getItems();
11454 items.each(function(f){
11458 Roo.each(this.childForms || [], function (f) {
11466 getItems : function()
11468 var r=new Roo.util.MixedCollection(false, function(o){
11469 return o.id || (o.id = Roo.id());
11471 var iter = function(el) {
11478 Roo.each(el.items,function(e) {
11487 hideFields : function(items)
11489 Roo.each(items, function(i){
11491 var f = this.findField(i);
11502 showFields : function(items)
11504 Roo.each(items, function(i){
11506 var f = this.findField(i);
11519 Roo.apply(Roo.bootstrap.Form, {
11535 intervalID : false,
11541 if(this.isApplied){
11546 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
11547 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
11548 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
11549 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
11552 this.maskEl.top.enableDisplayMode("block");
11553 this.maskEl.left.enableDisplayMode("block");
11554 this.maskEl.bottom.enableDisplayMode("block");
11555 this.maskEl.right.enableDisplayMode("block");
11557 this.toolTip = new Roo.bootstrap.Tooltip({
11558 cls : 'roo-form-error-popover',
11560 'left' : ['r-l', [-2,0], 'right'],
11561 'right' : ['l-r', [2,0], 'left'],
11562 'bottom' : ['tl-bl', [0,2], 'top'],
11563 'top' : [ 'bl-tl', [0,-2], 'bottom']
11567 this.toolTip.render(Roo.get(document.body));
11569 this.toolTip.el.enableDisplayMode("block");
11571 Roo.get(document.body).on('click', function(){
11575 Roo.get(document.body).on('touchstart', function(){
11579 this.isApplied = true
11582 mask : function(form, target)
11586 this.target = target;
11588 if(!this.form.errorMask || !target.el){
11592 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
11594 Roo.log(scrollable);
11596 var ot = this.target.el.calcOffsetsTo(scrollable);
11598 var scrollTo = ot[1] - this.form.maskOffset;
11600 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
11602 scrollable.scrollTo('top', scrollTo);
11604 var box = this.target.el.getBox();
11606 var zIndex = Roo.bootstrap.Modal.zIndex++;
11609 this.maskEl.top.setStyle('position', 'absolute');
11610 this.maskEl.top.setStyle('z-index', zIndex);
11611 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
11612 this.maskEl.top.setLeft(0);
11613 this.maskEl.top.setTop(0);
11614 this.maskEl.top.show();
11616 this.maskEl.left.setStyle('position', 'absolute');
11617 this.maskEl.left.setStyle('z-index', zIndex);
11618 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
11619 this.maskEl.left.setLeft(0);
11620 this.maskEl.left.setTop(box.y - this.padding);
11621 this.maskEl.left.show();
11623 this.maskEl.bottom.setStyle('position', 'absolute');
11624 this.maskEl.bottom.setStyle('z-index', zIndex);
11625 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
11626 this.maskEl.bottom.setLeft(0);
11627 this.maskEl.bottom.setTop(box.bottom + this.padding);
11628 this.maskEl.bottom.show();
11630 this.maskEl.right.setStyle('position', 'absolute');
11631 this.maskEl.right.setStyle('z-index', zIndex);
11632 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
11633 this.maskEl.right.setLeft(box.right + this.padding);
11634 this.maskEl.right.setTop(box.y - this.padding);
11635 this.maskEl.right.show();
11637 this.toolTip.bindEl = this.target.el;
11639 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
11641 var tip = this.target.blankText;
11643 if(this.target.getValue() !== '' ) {
11645 if (this.target.invalidText.length) {
11646 tip = this.target.invalidText;
11647 } else if (this.target.regexText.length){
11648 tip = this.target.regexText;
11652 this.toolTip.show(tip);
11654 this.intervalID = window.setInterval(function() {
11655 Roo.bootstrap.Form.popover.unmask();
11658 window.onwheel = function(){ return false;};
11660 (function(){ this.isMasked = true; }).defer(500, this);
11664 unmask : function()
11666 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
11670 this.maskEl.top.setStyle('position', 'absolute');
11671 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
11672 this.maskEl.top.hide();
11674 this.maskEl.left.setStyle('position', 'absolute');
11675 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
11676 this.maskEl.left.hide();
11678 this.maskEl.bottom.setStyle('position', 'absolute');
11679 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
11680 this.maskEl.bottom.hide();
11682 this.maskEl.right.setStyle('position', 'absolute');
11683 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
11684 this.maskEl.right.hide();
11686 this.toolTip.hide();
11688 this.toolTip.el.hide();
11690 window.onwheel = function(){ return true;};
11692 if(this.intervalID){
11693 window.clearInterval(this.intervalID);
11694 this.intervalID = false;
11697 this.isMasked = false;
11707 * Ext JS Library 1.1.1
11708 * Copyright(c) 2006-2007, Ext JS, LLC.
11710 * Originally Released Under LGPL - original licence link has changed is not relivant.
11713 * <script type="text/javascript">
11716 * @class Roo.form.VTypes
11717 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
11720 Roo.form.VTypes = function(){
11721 // closure these in so they are only created once.
11722 var alpha = /^[a-zA-Z_]+$/;
11723 var alphanum = /^[a-zA-Z0-9_]+$/;
11724 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
11725 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
11727 // All these messages and functions are configurable
11730 * The function used to validate email addresses
11731 * @param {String} value The email address
11733 'email' : function(v){
11734 return email.test(v);
11737 * The error text to display when the email validation function returns false
11740 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
11742 * The keystroke filter mask to be applied on email input
11745 'emailMask' : /[a-z0-9_\.\-@]/i,
11748 * The function used to validate URLs
11749 * @param {String} value The URL
11751 'url' : function(v){
11752 return url.test(v);
11755 * The error text to display when the url validation function returns false
11758 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
11761 * The function used to validate alpha values
11762 * @param {String} value The value
11764 'alpha' : function(v){
11765 return alpha.test(v);
11768 * The error text to display when the alpha validation function returns false
11771 'alphaText' : 'This field should only contain letters and _',
11773 * The keystroke filter mask to be applied on alpha input
11776 'alphaMask' : /[a-z_]/i,
11779 * The function used to validate alphanumeric values
11780 * @param {String} value The value
11782 'alphanum' : function(v){
11783 return alphanum.test(v);
11786 * The error text to display when the alphanumeric validation function returns false
11789 'alphanumText' : 'This field should only contain letters, numbers and _',
11791 * The keystroke filter mask to be applied on alphanumeric input
11794 'alphanumMask' : /[a-z0-9_]/i
11804 * @class Roo.bootstrap.Input
11805 * @extends Roo.bootstrap.Component
11806 * Bootstrap Input class
11807 * @cfg {Boolean} disabled is it disabled
11808 * @cfg {String} (button|checkbox|email|file|hidden|image|number|password|radio|range|reset|search|submit|text) inputType
11809 * @cfg {String} name name of the input
11810 * @cfg {string} fieldLabel - the label associated
11811 * @cfg {string} placeholder - placeholder to put in text.
11812 * @cfg {string} before - input group add on before
11813 * @cfg {string} after - input group add on after
11814 * @cfg {string} size - (lg|sm) or leave empty..
11815 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
11816 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
11817 * @cfg {Number} md colspan out of 12 for computer-sized screens
11818 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
11819 * @cfg {string} value default value of the input
11820 * @cfg {Number} labelWidth set the width of label
11821 * @cfg {Number} labellg set the width of label (1-12)
11822 * @cfg {Number} labelmd set the width of label (1-12)
11823 * @cfg {Number} labelsm set the width of label (1-12)
11824 * @cfg {Number} labelxs set the width of label (1-12)
11825 * @cfg {String} labelAlign (top|left)
11826 * @cfg {Boolean} readOnly Specifies that the field should be read-only
11827 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
11828 * @cfg {String} indicatorpos (left|right) default left
11829 * @cfg {String} capture (user|camera) use for file input only. (default empty)
11830 * @cfg {String} accept (image|video|audio) use for file input only. (default empty)
11831 * @cfg {Boolean} preventMark Do not show tick or cross if error/success
11833 * @cfg {String} align (left|center|right) Default left
11834 * @cfg {Boolean} forceFeedback (true|false) Default false
11837 * Create a new Input
11838 * @param {Object} config The config object
11841 Roo.bootstrap.Input = function(config){
11843 Roo.bootstrap.Input.superclass.constructor.call(this, config);
11848 * Fires when this field receives input focus.
11849 * @param {Roo.form.Field} this
11854 * Fires when this field loses input focus.
11855 * @param {Roo.form.Field} this
11859 * @event specialkey
11860 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
11861 * {@link Roo.EventObject#getKey} to determine which key was pressed.
11862 * @param {Roo.form.Field} this
11863 * @param {Roo.EventObject} e The event object
11868 * Fires just before the field blurs if the field value has changed.
11869 * @param {Roo.form.Field} this
11870 * @param {Mixed} newValue The new value
11871 * @param {Mixed} oldValue The original value
11876 * Fires after the field has been marked as invalid.
11877 * @param {Roo.form.Field} this
11878 * @param {String} msg The validation message
11883 * Fires after the field has been validated with no errors.
11884 * @param {Roo.form.Field} this
11889 * Fires after the key up
11890 * @param {Roo.form.Field} this
11891 * @param {Roo.EventObject} e The event Object
11896 * Fires after the user pastes into input
11897 * @param {Roo.form.Field} this
11898 * @param {Roo.EventObject} e The event Object
11904 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
11906 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
11907 automatic validation (defaults to "keyup").
11909 validationEvent : "keyup",
11911 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
11913 validateOnBlur : true,
11915 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
11917 validationDelay : 250,
11919 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
11921 focusClass : "x-form-focus", // not needed???
11925 * @cfg {String} invalidClass DEPRICATED - code uses BS4 - is-valid / is-invalid
11927 invalidClass : "has-warning",
11930 * @cfg {String} validClass DEPRICATED - code uses BS4 - is-valid / is-invalid
11932 validClass : "has-success",
11935 * @cfg {Boolean} hasFeedback (true|false) default true
11937 hasFeedback : true,
11940 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
11942 invalidFeedbackClass : "glyphicon-warning-sign",
11945 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
11947 validFeedbackClass : "glyphicon-ok",
11950 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
11952 selectOnFocus : false,
11955 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
11959 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
11964 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
11966 disableKeyFilter : false,
11969 * @cfg {Boolean} disabled True to disable the field (defaults to false).
11973 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
11977 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
11979 blankText : "Please complete this mandatory field",
11982 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
11986 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
11988 maxLength : Number.MAX_VALUE,
11990 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
11992 minLengthText : "The minimum length for this field is {0}",
11994 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
11996 maxLengthText : "The maximum length for this field is {0}",
12000 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
12001 * If available, this function will be called only after the basic validators all return true, and will be passed the
12002 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
12006 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
12007 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
12008 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
12012 * @cfg {String} regexText -- Depricated - use Invalid Text
12017 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
12023 autocomplete: false,
12027 inputType : 'text',
12030 placeholder: false,
12035 preventMark: false,
12036 isFormField : true,
12039 labelAlign : false,
12042 formatedValue : false,
12043 forceFeedback : false,
12045 indicatorpos : 'left',
12055 parentLabelAlign : function()
12058 while (parent.parent()) {
12059 parent = parent.parent();
12060 if (typeof(parent.labelAlign) !='undefined') {
12061 return parent.labelAlign;
12068 getAutoCreate : function()
12070 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
12076 if(this.inputType != 'hidden'){
12077 cfg.cls = 'form-group' //input-group
12083 type : this.inputType,
12084 value : this.value,
12085 cls : 'form-control',
12086 placeholder : this.placeholder || '',
12087 autocomplete : this.autocomplete || 'new-password'
12089 if (this.inputType == 'file') {
12090 input.style = 'overflow:hidden'; // why not in CSS?
12093 if(this.capture.length){
12094 input.capture = this.capture;
12097 if(this.accept.length){
12098 input.accept = this.accept + "/*";
12102 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
12105 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
12106 input.maxLength = this.maxLength;
12109 if (this.disabled) {
12110 input.disabled=true;
12113 if (this.readOnly) {
12114 input.readonly=true;
12118 input.name = this.name;
12122 input.cls += ' input-' + this.size;
12126 ['xs','sm','md','lg'].map(function(size){
12127 if (settings[size]) {
12128 cfg.cls += ' col-' + size + '-' + settings[size];
12132 var inputblock = input;
12136 cls: 'glyphicon form-control-feedback'
12139 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
12142 cls : 'has-feedback',
12150 if (this.before || this.after) {
12153 cls : 'input-group',
12157 if (this.before && typeof(this.before) == 'string') {
12159 inputblock.cn.push({
12161 cls : 'roo-input-before input-group-addon input-group-prepend input-group-text',
12165 if (this.before && typeof(this.before) == 'object') {
12166 this.before = Roo.factory(this.before);
12168 inputblock.cn.push({
12170 cls : 'roo-input-before input-group-prepend input-group-' +
12171 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
12175 inputblock.cn.push(input);
12177 if (this.after && typeof(this.after) == 'string') {
12178 inputblock.cn.push({
12180 cls : 'roo-input-after input-group-append input-group-text input-group-addon',
12184 if (this.after && typeof(this.after) == 'object') {
12185 this.after = Roo.factory(this.after);
12187 inputblock.cn.push({
12189 cls : 'roo-input-after input-group-append input-group-' +
12190 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
12194 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
12195 inputblock.cls += ' has-feedback';
12196 inputblock.cn.push(feedback);
12201 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
12202 tooltip : 'This field is required'
12204 if (this.allowBlank ) {
12205 indicator.style = this.allowBlank ? ' display:none' : '';
12207 if (align ==='left' && this.fieldLabel.length) {
12209 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
12216 cls : 'control-label col-form-label',
12217 html : this.fieldLabel
12228 var labelCfg = cfg.cn[1];
12229 var contentCfg = cfg.cn[2];
12231 if(this.indicatorpos == 'right'){
12236 cls : 'control-label col-form-label',
12240 html : this.fieldLabel
12254 labelCfg = cfg.cn[0];
12255 contentCfg = cfg.cn[1];
12259 if(this.labelWidth > 12){
12260 labelCfg.style = "width: " + this.labelWidth + 'px';
12263 if(this.labelWidth < 13 && this.labelmd == 0){
12264 this.labellg = this.labellg > 0 ? this.labellg : this.labelWidth;
12267 if(this.labellg > 0){
12268 labelCfg.cls += ' col-lg-' + this.labellg;
12269 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
12272 if(this.labelmd > 0){
12273 labelCfg.cls += ' col-md-' + this.labelmd;
12274 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
12277 if(this.labelsm > 0){
12278 labelCfg.cls += ' col-sm-' + this.labelsm;
12279 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
12282 if(this.labelxs > 0){
12283 labelCfg.cls += ' col-xs-' + this.labelxs;
12284 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
12288 } else if ( this.fieldLabel.length) {
12295 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
12296 tooltip : 'This field is required',
12297 style : this.allowBlank ? ' display:none' : ''
12301 //cls : 'input-group-addon',
12302 html : this.fieldLabel
12310 if(this.indicatorpos == 'right'){
12315 //cls : 'input-group-addon',
12316 html : this.fieldLabel
12321 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
12322 tooltip : 'This field is required',
12323 style : this.allowBlank ? ' display:none' : ''
12343 if (this.parentType === 'Navbar' && this.parent().bar) {
12344 cfg.cls += ' navbar-form';
12347 if (this.parentType === 'NavGroup' && !(Roo.bootstrap.version == 4 && this.parent().form)) {
12348 // on BS4 we do this only if not form
12349 cfg.cls += ' navbar-form';
12357 * return the real input element.
12359 inputEl: function ()
12361 return this.el.select('input.form-control',true).first();
12364 tooltipEl : function()
12366 return this.inputEl();
12369 indicatorEl : function()
12371 if (Roo.bootstrap.version == 4) {
12372 return false; // not enabled in v4 yet.
12375 var indicator = this.el.select('i.roo-required-indicator',true).first();
12385 setDisabled : function(v)
12387 var i = this.inputEl().dom;
12389 i.removeAttribute('disabled');
12393 i.setAttribute('disabled','true');
12395 initEvents : function()
12398 this.inputEl().on("keydown" , this.fireKey, this);
12399 this.inputEl().on("focus", this.onFocus, this);
12400 this.inputEl().on("blur", this.onBlur, this);
12402 this.inputEl().relayEvent('keyup', this);
12403 this.inputEl().relayEvent('paste', this);
12405 this.indicator = this.indicatorEl();
12407 if(this.indicator){
12408 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible'); // changed from invisible??? -
12411 // reference to original value for reset
12412 this.originalValue = this.getValue();
12413 //Roo.form.TextField.superclass.initEvents.call(this);
12414 if(this.validationEvent == 'keyup'){
12415 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
12416 this.inputEl().on('keyup', this.filterValidation, this);
12418 else if(this.validationEvent !== false){
12419 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
12422 if(this.selectOnFocus){
12423 this.on("focus", this.preFocus, this);
12426 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
12427 this.inputEl().on("keypress", this.filterKeys, this);
12429 this.inputEl().relayEvent('keypress', this);
12432 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
12433 this.el.on("click", this.autoSize, this);
12436 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
12437 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
12440 if (typeof(this.before) == 'object') {
12441 this.before.render(this.el.select('.roo-input-before',true).first());
12443 if (typeof(this.after) == 'object') {
12444 this.after.render(this.el.select('.roo-input-after',true).first());
12447 this.inputEl().on('change', this.onChange, this);
12450 filterValidation : function(e){
12451 if(!e.isNavKeyPress()){
12452 this.validationTask.delay(this.validationDelay);
12456 * Validates the field value
12457 * @return {Boolean} True if the value is valid, else false
12459 validate : function(){
12460 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
12461 if(this.disabled || this.validateValue(this.getRawValue())){
12466 this.markInvalid();
12472 * Validates a value according to the field's validation rules and marks the field as invalid
12473 * if the validation fails
12474 * @param {Mixed} value The value to validate
12475 * @return {Boolean} True if the value is valid, else false
12477 validateValue : function(value)
12479 if(this.getVisibilityEl().hasClass('hidden')){
12483 if(value.length < 1) { // if it's blank
12484 if(this.allowBlank){
12490 if(value.length < this.minLength){
12493 if(value.length > this.maxLength){
12497 var vt = Roo.form.VTypes;
12498 if(!vt[this.vtype](value, this)){
12502 if(typeof this.validator == "function"){
12503 var msg = this.validator(value);
12507 if (typeof(msg) == 'string') {
12508 this.invalidText = msg;
12512 if(this.regex && !this.regex.test(value)){
12520 fireKey : function(e){
12521 //Roo.log('field ' + e.getKey());
12522 if(e.isNavKeyPress()){
12523 this.fireEvent("specialkey", this, e);
12526 focus : function (selectText){
12528 this.inputEl().focus();
12529 if(selectText === true){
12530 this.inputEl().dom.select();
12536 onFocus : function(){
12537 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
12538 // this.el.addClass(this.focusClass);
12540 if(!this.hasFocus){
12541 this.hasFocus = true;
12542 this.startValue = this.getValue();
12543 this.fireEvent("focus", this);
12547 beforeBlur : Roo.emptyFn,
12551 onBlur : function(){
12553 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
12554 //this.el.removeClass(this.focusClass);
12556 this.hasFocus = false;
12557 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
12560 var v = this.getValue();
12561 if(String(v) !== String(this.startValue)){
12562 this.fireEvent('change', this, v, this.startValue);
12564 this.fireEvent("blur", this);
12567 onChange : function(e)
12569 var v = this.getValue();
12570 if(String(v) !== String(this.startValue)){
12571 this.fireEvent('change', this, v, this.startValue);
12577 * Resets the current field value to the originally loaded value and clears any validation messages
12579 reset : function(){
12580 this.setValue(this.originalValue);
12584 * Returns the name of the field
12585 * @return {Mixed} name The name field
12587 getName: function(){
12591 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
12592 * @return {Mixed} value The field value
12594 getValue : function(){
12596 var v = this.inputEl().getValue();
12601 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
12602 * @return {Mixed} value The field value
12604 getRawValue : function(){
12605 var v = this.inputEl().getValue();
12611 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
12612 * @param {Mixed} value The value to set
12614 setRawValue : function(v){
12615 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
12618 selectText : function(start, end){
12619 var v = this.getRawValue();
12621 start = start === undefined ? 0 : start;
12622 end = end === undefined ? v.length : end;
12623 var d = this.inputEl().dom;
12624 if(d.setSelectionRange){
12625 d.setSelectionRange(start, end);
12626 }else if(d.createTextRange){
12627 var range = d.createTextRange();
12628 range.moveStart("character", start);
12629 range.moveEnd("character", v.length-end);
12636 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
12637 * @param {Mixed} value The value to set
12639 setValue : function(v){
12642 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
12648 processValue : function(value){
12649 if(this.stripCharsRe){
12650 var newValue = value.replace(this.stripCharsRe, '');
12651 if(newValue !== value){
12652 this.setRawValue(newValue);
12659 preFocus : function(){
12661 if(this.selectOnFocus){
12662 this.inputEl().dom.select();
12665 filterKeys : function(e){
12666 var k = e.getKey();
12667 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
12670 var c = e.getCharCode(), cc = String.fromCharCode(c);
12671 if(Roo.isIE && (e.isSpecialKey() || !cc)){
12674 if(!this.maskRe.test(cc)){
12679 * Clear any invalid styles/messages for this field
12681 clearInvalid : function(){
12683 if(!this.el || this.preventMark){ // not rendered
12688 this.el.removeClass([this.invalidClass, 'is-invalid']);
12690 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
12692 var feedback = this.el.select('.form-control-feedback', true).first();
12695 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
12700 if(this.indicator){
12701 this.indicator.removeClass('visible');
12702 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
12705 this.fireEvent('valid', this);
12709 * Mark this field as valid
12711 markValid : function()
12713 if(!this.el || this.preventMark){ // not rendered...
12717 this.el.removeClass([this.invalidClass, this.validClass]);
12718 this.inputEl().removeClass(['is-valid', 'is-invalid']);
12720 var feedback = this.el.select('.form-control-feedback', true).first();
12723 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
12726 if(this.indicator){
12727 this.indicator.removeClass('visible');
12728 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
12736 if(this.allowBlank && !this.getRawValue().length){
12739 if (Roo.bootstrap.version == 3) {
12740 this.el.addClass(this.validClass);
12742 this.inputEl().addClass('is-valid');
12745 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
12747 var feedback = this.el.select('.form-control-feedback', true).first();
12750 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
12751 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
12756 this.fireEvent('valid', this);
12760 * Mark this field as invalid
12761 * @param {String} msg The validation message
12763 markInvalid : function(msg)
12765 if(!this.el || this.preventMark){ // not rendered
12769 this.el.removeClass([this.invalidClass, this.validClass]);
12770 this.inputEl().removeClass(['is-valid', 'is-invalid']);
12772 var feedback = this.el.select('.form-control-feedback', true).first();
12775 this.el.select('.form-control-feedback', true).first().removeClass(
12776 [this.invalidFeedbackClass, this.validFeedbackClass]);
12783 if(this.allowBlank && !this.getRawValue().length){
12787 if(this.indicator){
12788 this.indicator.removeClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
12789 this.indicator.addClass('visible');
12791 if (Roo.bootstrap.version == 3) {
12792 this.el.addClass(this.invalidClass);
12794 this.inputEl().addClass('is-invalid');
12799 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
12801 var feedback = this.el.select('.form-control-feedback', true).first();
12804 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
12806 if(this.getValue().length || this.forceFeedback){
12807 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
12814 this.fireEvent('invalid', this, msg);
12817 SafariOnKeyDown : function(event)
12819 // this is a workaround for a password hang bug on chrome/ webkit.
12820 if (this.inputEl().dom.type != 'password') {
12824 var isSelectAll = false;
12826 if(this.inputEl().dom.selectionEnd > 0){
12827 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
12829 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
12830 event.preventDefault();
12835 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
12837 event.preventDefault();
12838 // this is very hacky as keydown always get's upper case.
12840 var cc = String.fromCharCode(event.getCharCode());
12841 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
12845 adjustWidth : function(tag, w){
12846 tag = tag.toLowerCase();
12847 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
12848 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
12849 if(tag == 'input'){
12852 if(tag == 'textarea'){
12855 }else if(Roo.isOpera){
12856 if(tag == 'input'){
12859 if(tag == 'textarea'){
12867 setFieldLabel : function(v)
12869 if(!this.rendered){
12873 if(this.indicatorEl()){
12874 var ar = this.el.select('label > span',true);
12876 if (ar.elements.length) {
12877 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
12878 this.fieldLabel = v;
12882 var br = this.el.select('label',true);
12884 if(br.elements.length) {
12885 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
12886 this.fieldLabel = v;
12890 Roo.log('Cannot Found any of label > span || label in input');
12894 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
12895 this.fieldLabel = v;
12910 * @class Roo.bootstrap.TextArea
12911 * @extends Roo.bootstrap.Input
12912 * Bootstrap TextArea class
12913 * @cfg {Number} cols Specifies the visible width of a text area
12914 * @cfg {Number} rows Specifies the visible number of lines in a text area
12915 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
12916 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
12917 * @cfg {string} html text
12920 * Create a new TextArea
12921 * @param {Object} config The config object
12924 Roo.bootstrap.TextArea = function(config){
12925 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
12929 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
12939 getAutoCreate : function(){
12941 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
12947 if(this.inputType != 'hidden'){
12948 cfg.cls = 'form-group' //input-group
12956 value : this.value || '',
12957 html: this.html || '',
12958 cls : 'form-control',
12959 placeholder : this.placeholder || ''
12963 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
12964 input.maxLength = this.maxLength;
12968 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
12972 input.cols = this.cols;
12975 if (this.readOnly) {
12976 input.readonly = true;
12980 input.name = this.name;
12984 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
12988 ['xs','sm','md','lg'].map(function(size){
12989 if (settings[size]) {
12990 cfg.cls += ' col-' + size + '-' + settings[size];
12994 var inputblock = input;
12996 if(this.hasFeedback && !this.allowBlank){
13000 cls: 'glyphicon form-control-feedback'
13004 cls : 'has-feedback',
13013 if (this.before || this.after) {
13016 cls : 'input-group',
13020 inputblock.cn.push({
13022 cls : 'input-group-addon',
13027 inputblock.cn.push(input);
13029 if(this.hasFeedback && !this.allowBlank){
13030 inputblock.cls += ' has-feedback';
13031 inputblock.cn.push(feedback);
13035 inputblock.cn.push({
13037 cls : 'input-group-addon',
13044 if (align ==='left' && this.fieldLabel.length) {
13049 cls : 'control-label',
13050 html : this.fieldLabel
13061 if(this.labelWidth > 12){
13062 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
13065 if(this.labelWidth < 13 && this.labelmd == 0){
13066 this.labelmd = this.labelWidth;
13069 if(this.labellg > 0){
13070 cfg.cn[0].cls += ' col-lg-' + this.labellg;
13071 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
13074 if(this.labelmd > 0){
13075 cfg.cn[0].cls += ' col-md-' + this.labelmd;
13076 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
13079 if(this.labelsm > 0){
13080 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
13081 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
13084 if(this.labelxs > 0){
13085 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
13086 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
13089 } else if ( this.fieldLabel.length) {
13094 //cls : 'input-group-addon',
13095 html : this.fieldLabel
13113 if (this.disabled) {
13114 input.disabled=true;
13121 * return the real textarea element.
13123 inputEl: function ()
13125 return this.el.select('textarea.form-control',true).first();
13129 * Clear any invalid styles/messages for this field
13131 clearInvalid : function()
13134 if(!this.el || this.preventMark){ // not rendered
13138 var label = this.el.select('label', true).first();
13139 var icon = this.el.select('i.fa-star', true).first();
13144 this.el.removeClass( this.validClass);
13145 this.inputEl().removeClass('is-invalid');
13147 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
13149 var feedback = this.el.select('.form-control-feedback', true).first();
13152 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
13157 this.fireEvent('valid', this);
13161 * Mark this field as valid
13163 markValid : function()
13165 if(!this.el || this.preventMark){ // not rendered
13169 this.el.removeClass([this.invalidClass, this.validClass]);
13170 this.inputEl().removeClass(['is-valid', 'is-invalid']);
13172 var feedback = this.el.select('.form-control-feedback', true).first();
13175 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13178 if(this.disabled || this.allowBlank){
13182 var label = this.el.select('label', true).first();
13183 var icon = this.el.select('i.fa-star', true).first();
13188 if (Roo.bootstrap.version == 3) {
13189 this.el.addClass(this.validClass);
13191 this.inputEl().addClass('is-valid');
13195 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
13197 var feedback = this.el.select('.form-control-feedback', true).first();
13200 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13201 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
13206 this.fireEvent('valid', this);
13210 * Mark this field as invalid
13211 * @param {String} msg The validation message
13213 markInvalid : function(msg)
13215 if(!this.el || this.preventMark){ // not rendered
13219 this.el.removeClass([this.invalidClass, this.validClass]);
13220 this.inputEl().removeClass(['is-valid', 'is-invalid']);
13222 var feedback = this.el.select('.form-control-feedback', true).first();
13225 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13228 if(this.disabled || this.allowBlank){
13232 var label = this.el.select('label', true).first();
13233 var icon = this.el.select('i.fa-star', true).first();
13235 if(!this.getValue().length && label && !icon){
13236 this.el.createChild({
13238 cls : 'text-danger fa fa-lg fa-star',
13239 tooltip : 'This field is required',
13240 style : 'margin-right:5px;'
13244 if (Roo.bootstrap.version == 3) {
13245 this.el.addClass(this.invalidClass);
13247 this.inputEl().addClass('is-invalid');
13250 // fixme ... this may be depricated need to test..
13251 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
13253 var feedback = this.el.select('.form-control-feedback', true).first();
13256 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13258 if(this.getValue().length || this.forceFeedback){
13259 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
13266 this.fireEvent('invalid', this, msg);
13274 * trigger field - base class for combo..
13279 * @class Roo.bootstrap.TriggerField
13280 * @extends Roo.bootstrap.Input
13281 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
13282 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
13283 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
13284 * for which you can provide a custom implementation. For example:
13286 var trigger = new Roo.bootstrap.TriggerField();
13287 trigger.onTriggerClick = myTriggerFn;
13288 trigger.applyTo('my-field');
13291 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
13292 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
13293 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
13294 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
13295 * @cfg {String} caret (search|calendar) BS3 only - carat fa name
13298 * Create a new TriggerField.
13299 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
13300 * to the base TextField)
13302 Roo.bootstrap.TriggerField = function(config){
13303 this.mimicing = false;
13304 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
13307 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
13309 * @cfg {String} triggerClass A CSS class to apply to the trigger
13312 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
13317 * @cfg {Boolean} removable (true|false) special filter default false
13321 /** @cfg {Boolean} grow @hide */
13322 /** @cfg {Number} growMin @hide */
13323 /** @cfg {Number} growMax @hide */
13329 autoSize: Roo.emptyFn,
13333 deferHeight : true,
13336 actionMode : 'wrap',
13341 getAutoCreate : function(){
13343 var align = this.labelAlign || this.parentLabelAlign();
13348 cls: 'form-group' //input-group
13355 type : this.inputType,
13356 cls : 'form-control',
13357 autocomplete: 'new-password',
13358 placeholder : this.placeholder || ''
13362 input.name = this.name;
13365 input.cls += ' input-' + this.size;
13368 if (this.disabled) {
13369 input.disabled=true;
13372 var inputblock = input;
13374 if(this.hasFeedback && !this.allowBlank){
13378 cls: 'glyphicon form-control-feedback'
13381 if(this.removable && !this.editable ){
13383 cls : 'has-feedback',
13389 cls : 'roo-combo-removable-btn close'
13396 cls : 'has-feedback',
13405 if(this.removable && !this.editable ){
13407 cls : 'roo-removable',
13413 cls : 'roo-combo-removable-btn close'
13420 if (this.before || this.after) {
13423 cls : 'input-group',
13427 inputblock.cn.push({
13429 cls : 'input-group-addon input-group-prepend input-group-text',
13434 inputblock.cn.push(input);
13436 if(this.hasFeedback && !this.allowBlank){
13437 inputblock.cls += ' has-feedback';
13438 inputblock.cn.push(feedback);
13442 inputblock.cn.push({
13444 cls : 'input-group-addon input-group-append input-group-text',
13453 var ibwrap = inputblock;
13458 cls: 'roo-select2-choices',
13462 cls: 'roo-select2-search-field',
13474 cls: 'roo-select2-container input-group',
13479 cls: 'form-hidden-field'
13485 if(!this.multiple && this.showToggleBtn){
13491 if (this.caret != false) {
13494 cls: 'fa fa-' + this.caret
13501 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
13503 Roo.bootstrap.version == 3 ? caret : '',
13506 cls: 'combobox-clear',
13520 combobox.cls += ' roo-select2-container-multi';
13524 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
13525 tooltip : 'This field is required'
13527 if (Roo.bootstrap.version == 4) {
13530 style : 'display:none'
13535 if (align ==='left' && this.fieldLabel.length) {
13537 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
13544 cls : 'control-label',
13545 html : this.fieldLabel
13557 var labelCfg = cfg.cn[1];
13558 var contentCfg = cfg.cn[2];
13560 if(this.indicatorpos == 'right'){
13565 cls : 'control-label',
13569 html : this.fieldLabel
13583 labelCfg = cfg.cn[0];
13584 contentCfg = cfg.cn[1];
13587 if(this.labelWidth > 12){
13588 labelCfg.style = "width: " + this.labelWidth + 'px';
13591 if(this.labelWidth < 13 && this.labelmd == 0){
13592 this.labelmd = this.labelWidth;
13595 if(this.labellg > 0){
13596 labelCfg.cls += ' col-lg-' + this.labellg;
13597 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
13600 if(this.labelmd > 0){
13601 labelCfg.cls += ' col-md-' + this.labelmd;
13602 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
13605 if(this.labelsm > 0){
13606 labelCfg.cls += ' col-sm-' + this.labelsm;
13607 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
13610 if(this.labelxs > 0){
13611 labelCfg.cls += ' col-xs-' + this.labelxs;
13612 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
13615 } else if ( this.fieldLabel.length) {
13616 // Roo.log(" label");
13621 //cls : 'input-group-addon',
13622 html : this.fieldLabel
13630 if(this.indicatorpos == 'right'){
13638 html : this.fieldLabel
13652 // Roo.log(" no label && no align");
13659 ['xs','sm','md','lg'].map(function(size){
13660 if (settings[size]) {
13661 cfg.cls += ' col-' + size + '-' + settings[size];
13672 onResize : function(w, h){
13673 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
13674 // if(typeof w == 'number'){
13675 // var x = w - this.trigger.getWidth();
13676 // this.inputEl().setWidth(this.adjustWidth('input', x));
13677 // this.trigger.setStyle('left', x+'px');
13682 adjustSize : Roo.BoxComponent.prototype.adjustSize,
13685 getResizeEl : function(){
13686 return this.inputEl();
13690 getPositionEl : function(){
13691 return this.inputEl();
13695 alignErrorIcon : function(){
13696 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
13700 initEvents : function(){
13704 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
13705 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
13706 if(!this.multiple && this.showToggleBtn){
13707 this.trigger = this.el.select('span.dropdown-toggle',true).first();
13708 if(this.hideTrigger){
13709 this.trigger.setDisplayed(false);
13711 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
13715 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
13718 if(this.removable && !this.editable && !this.tickable){
13719 var close = this.closeTriggerEl();
13722 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
13723 close.on('click', this.removeBtnClick, this, close);
13727 //this.trigger.addClassOnOver('x-form-trigger-over');
13728 //this.trigger.addClassOnClick('x-form-trigger-click');
13731 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
13735 closeTriggerEl : function()
13737 var close = this.el.select('.roo-combo-removable-btn', true).first();
13738 return close ? close : false;
13741 removeBtnClick : function(e, h, el)
13743 e.preventDefault();
13745 if(this.fireEvent("remove", this) !== false){
13747 this.fireEvent("afterremove", this)
13751 createList : function()
13753 this.list = Roo.get(document.body).createChild({
13754 tag: Roo.bootstrap.version == 4 ? 'div' : 'ul',
13755 cls: 'typeahead typeahead-long dropdown-menu shadow',
13756 style: 'display:none'
13759 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
13764 initTrigger : function(){
13769 onDestroy : function(){
13771 this.trigger.removeAllListeners();
13772 // this.trigger.remove();
13775 // this.wrap.remove();
13777 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
13781 onFocus : function(){
13782 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
13784 if(!this.mimicing){
13785 this.wrap.addClass('x-trigger-wrap-focus');
13786 this.mimicing = true;
13787 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
13788 if(this.monitorTab){
13789 this.el.on("keydown", this.checkTab, this);
13796 checkTab : function(e){
13797 if(e.getKey() == e.TAB){
13798 this.triggerBlur();
13803 onBlur : function(){
13808 mimicBlur : function(e, t){
13810 if(!this.wrap.contains(t) && this.validateBlur()){
13811 this.triggerBlur();
13817 triggerBlur : function(){
13818 this.mimicing = false;
13819 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
13820 if(this.monitorTab){
13821 this.el.un("keydown", this.checkTab, this);
13823 //this.wrap.removeClass('x-trigger-wrap-focus');
13824 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
13828 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
13829 validateBlur : function(e, t){
13834 onDisable : function(){
13835 this.inputEl().dom.disabled = true;
13836 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
13838 // this.wrap.addClass('x-item-disabled');
13843 onEnable : function(){
13844 this.inputEl().dom.disabled = false;
13845 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
13847 // this.el.removeClass('x-item-disabled');
13852 onShow : function(){
13853 var ae = this.getActionEl();
13856 ae.dom.style.display = '';
13857 ae.dom.style.visibility = 'visible';
13863 onHide : function(){
13864 var ae = this.getActionEl();
13865 ae.dom.style.display = 'none';
13869 * The function that should handle the trigger's click event. This method does nothing by default until overridden
13870 * by an implementing function.
13872 * @param {EventObject} e
13874 onTriggerClick : Roo.emptyFn
13882 * @class Roo.bootstrap.CardUploader
13883 * @extends Roo.bootstrap.Button
13884 * Bootstrap Card Uploader class - it's a button which when you add files to it, adds cards below with preview and the name...
13885 * @cfg {Number} errorTimeout default 3000
13886 * @cfg {Array} images an array of ?? Img objects ??? when loading existing files..
13887 * @cfg {Array} html The button text.
13891 * Create a new CardUploader
13892 * @param {Object} config The config object
13895 Roo.bootstrap.CardUploader = function(config){
13899 Roo.bootstrap.CardUploader.superclass.constructor.call(this, config);
13902 this.fileCollection = new Roo.util.MixedCollection(false,function(r) {
13910 * When a image is clicked on - and needs to display a slideshow or similar..
13911 * @param {Roo.bootstrap.Card} this
13912 * @param {Object} The image information data
13918 * When a the download link is clicked
13919 * @param {Roo.bootstrap.Card} this
13920 * @param {Object} The image information data contains
13927 Roo.extend(Roo.bootstrap.CardUploader, Roo.bootstrap.Input, {
13930 errorTimeout : 3000,
13934 fileCollection : false,
13937 getAutoCreate : function()
13941 cls :'form-group' ,
13946 //cls : 'input-group-addon',
13947 html : this.fieldLabel
13955 value : this.value,
13956 cls : 'd-none form-control'
13961 multiple : 'multiple',
13963 cls : 'd-none roo-card-upload-selector'
13967 cls : 'roo-card-uploader-button-container w-100 mb-2'
13970 cls : 'card-columns roo-card-uploader-container'
13980 getChildContainer : function() /// what children are added to.
13982 return this.containerEl;
13985 getButtonContainer : function() /// what children are added to.
13987 return this.el.select(".roo-card-uploader-button-container").first();
13990 initEvents : function()
13993 Roo.bootstrap.Input.prototype.initEvents.call(this);
13997 xns: Roo.bootstrap,
14000 container_method : 'getButtonContainer' ,
14001 html : this.html, // fix changable?
14004 'click' : function(btn, e) {
14013 this.urlAPI = (window.createObjectURL && window) ||
14014 (window.URL && URL.revokeObjectURL && URL) ||
14015 (window.webkitURL && webkitURL);
14020 this.selectorEl = this.el.select('.roo-card-upload-selector', true).first();
14022 this.selectorEl.on('change', this.onFileSelected, this);
14025 this.images.forEach(function(img) {
14028 this.images = false;
14030 this.containerEl = this.el.select('.roo-card-uploader-container', true).first();
14036 onClick : function(e)
14038 e.preventDefault();
14040 this.selectorEl.dom.click();
14044 onFileSelected : function(e)
14046 e.preventDefault();
14048 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
14052 Roo.each(this.selectorEl.dom.files, function(file){
14053 this.addFile(file);
14062 addFile : function(file)
14065 if(typeof(file) === 'string'){
14066 throw "Add file by name?"; // should not happen
14070 if(!file || !this.urlAPI){
14080 var url = _this.urlAPI.createObjectURL( file);
14083 id : Roo.bootstrap.CardUploader.ID--,
14084 is_uploaded : false,
14088 mimetype : file.type,
14096 * addCard - add an Attachment to the uploader
14097 * @param data - the data about the image to upload
14101 title : "Title of file",
14102 is_uploaded : false,
14103 src : "http://.....",
14104 srcfile : { the File upload object },
14105 mimetype : file.type,
14108 .. any other data...
14114 addCard : function (data)
14116 // hidden input element?
14117 // if the file is not an image...
14118 //then we need to use something other that and header_image
14123 xns : Roo.bootstrap,
14124 xtype : 'CardFooter',
14127 xns : Roo.bootstrap,
14133 xns : Roo.bootstrap,
14135 html : String.format("<small>{0}</small>", data.title),
14136 cls : 'col-10 text-left',
14141 click : function() {
14143 t.fireEvent( "download", t, data );
14149 xns : Roo.bootstrap,
14151 style: 'max-height: 28px; ',
14157 click : function() {
14158 t.removeCard(data.id)
14170 var cn = this.addxtype(
14173 xns : Roo.bootstrap,
14176 header : !data.mimetype.match(/image/) && !data.preview ? "Document": false,
14177 header_image : data.mimetype.match(/image/) ? data.src : data.preview,
14178 header_image_fit_square: true, // fixme - we probably need to use the 'Img' element to do stuff like this.
14183 initEvents : function() {
14184 Roo.bootstrap.Card.prototype.initEvents.call(this);
14186 this.imgEl = this.el.select('.card-img-top').first();
14188 this.imgEl.on('click', function() { t.fireEvent( "preview", t, data ); }, this);
14189 this.imgEl.set({ 'pointer' : 'cursor' });
14192 this.getCardFooter().addClass('p-1');
14199 // dont' really need ot update items.
14200 // this.items.push(cn);
14201 this.fileCollection.add(cn);
14203 if (!data.srcfile) {
14204 this.updateInput();
14209 var reader = new FileReader();
14210 reader.addEventListener("load", function() {
14211 data.srcdata = reader.result;
14214 reader.readAsDataURL(data.srcfile);
14219 removeCard : function(id)
14222 var card = this.fileCollection.get(id);
14223 card.data.is_deleted = 1;
14224 card.data.src = ''; /// delete the source - so it reduces size of not uploaded images etc.
14225 //this.fileCollection.remove(card);
14226 //this.items = this.items.filter(function(e) { return e != card });
14227 // dont' really need ot update items.
14228 card.el.dom.parentNode.removeChild(card.el.dom);
14229 this.updateInput();
14235 this.fileCollection.each(function(card) {
14236 if (card.el.dom && card.el.dom.parentNode) {
14237 card.el.dom.parentNode.removeChild(card.el.dom);
14240 this.fileCollection.clear();
14241 this.updateInput();
14244 updateInput : function()
14247 this.fileCollection.each(function(e) {
14251 this.inputEl().dom.value = JSON.stringify(data);
14261 Roo.bootstrap.CardUploader.ID = -1;/*
14263 * Ext JS Library 1.1.1
14264 * Copyright(c) 2006-2007, Ext JS, LLC.
14266 * Originally Released Under LGPL - original licence link has changed is not relivant.
14269 * <script type="text/javascript">
14274 * @class Roo.data.SortTypes
14276 * Defines the default sorting (casting?) comparison functions used when sorting data.
14278 Roo.data.SortTypes = {
14280 * Default sort that does nothing
14281 * @param {Mixed} s The value being converted
14282 * @return {Mixed} The comparison value
14284 none : function(s){
14289 * The regular expression used to strip tags
14293 stripTagsRE : /<\/?[^>]+>/gi,
14296 * Strips all HTML tags to sort on text only
14297 * @param {Mixed} s The value being converted
14298 * @return {String} The comparison value
14300 asText : function(s){
14301 return String(s).replace(this.stripTagsRE, "");
14305 * Strips all HTML tags to sort on text only - Case insensitive
14306 * @param {Mixed} s The value being converted
14307 * @return {String} The comparison value
14309 asUCText : function(s){
14310 return String(s).toUpperCase().replace(this.stripTagsRE, "");
14314 * Case insensitive string
14315 * @param {Mixed} s The value being converted
14316 * @return {String} The comparison value
14318 asUCString : function(s) {
14319 return String(s).toUpperCase();
14324 * @param {Mixed} s The value being converted
14325 * @return {Number} The comparison value
14327 asDate : function(s) {
14331 if(s instanceof Date){
14332 return s.getTime();
14334 return Date.parse(String(s));
14339 * @param {Mixed} s The value being converted
14340 * @return {Float} The comparison value
14342 asFloat : function(s) {
14343 var val = parseFloat(String(s).replace(/,/g, ""));
14352 * @param {Mixed} s The value being converted
14353 * @return {Number} The comparison value
14355 asInt : function(s) {
14356 var val = parseInt(String(s).replace(/,/g, ""));
14364 * Ext JS Library 1.1.1
14365 * Copyright(c) 2006-2007, Ext JS, LLC.
14367 * Originally Released Under LGPL - original licence link has changed is not relivant.
14370 * <script type="text/javascript">
14374 * @class Roo.data.Record
14375 * Instances of this class encapsulate both record <em>definition</em> information, and record
14376 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
14377 * to access Records cached in an {@link Roo.data.Store} object.<br>
14379 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
14380 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
14383 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
14385 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
14386 * {@link #create}. The parameters are the same.
14387 * @param {Array} data An associative Array of data values keyed by the field name.
14388 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
14389 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
14390 * not specified an integer id is generated.
14392 Roo.data.Record = function(data, id){
14393 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
14398 * Generate a constructor for a specific record layout.
14399 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
14400 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
14401 * Each field definition object may contain the following properties: <ul>
14402 * <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,
14403 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
14404 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
14405 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
14406 * is being used, then this is a string containing the javascript expression to reference the data relative to
14407 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
14408 * to the data item relative to the record element. If the mapping expression is the same as the field name,
14409 * this may be omitted.</p></li>
14410 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
14411 * <ul><li>auto (Default, implies no conversion)</li>
14416 * <li>date</li></ul></p></li>
14417 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
14418 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
14419 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
14420 * by the Reader into an object that will be stored in the Record. It is passed the
14421 * following parameters:<ul>
14422 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
14424 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
14426 * <br>usage:<br><pre><code>
14427 var TopicRecord = Roo.data.Record.create(
14428 {name: 'title', mapping: 'topic_title'},
14429 {name: 'author', mapping: 'username'},
14430 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
14431 {name: 'lastPost', mapping: 'post_time', type: 'date'},
14432 {name: 'lastPoster', mapping: 'user2'},
14433 {name: 'excerpt', mapping: 'post_text'}
14436 var myNewRecord = new TopicRecord({
14437 title: 'Do my job please',
14440 lastPost: new Date(),
14441 lastPoster: 'Animal',
14442 excerpt: 'No way dude!'
14444 myStore.add(myNewRecord);
14449 Roo.data.Record.create = function(o){
14450 var f = function(){
14451 f.superclass.constructor.apply(this, arguments);
14453 Roo.extend(f, Roo.data.Record);
14454 var p = f.prototype;
14455 p.fields = new Roo.util.MixedCollection(false, function(field){
14458 for(var i = 0, len = o.length; i < len; i++){
14459 p.fields.add(new Roo.data.Field(o[i]));
14461 f.getField = function(name){
14462 return p.fields.get(name);
14467 Roo.data.Record.AUTO_ID = 1000;
14468 Roo.data.Record.EDIT = 'edit';
14469 Roo.data.Record.REJECT = 'reject';
14470 Roo.data.Record.COMMIT = 'commit';
14472 Roo.data.Record.prototype = {
14474 * Readonly flag - true if this record has been modified.
14483 join : function(store){
14484 this.store = store;
14488 * Set the named field to the specified value.
14489 * @param {String} name The name of the field to set.
14490 * @param {Object} value The value to set the field to.
14492 set : function(name, value){
14493 if(this.data[name] == value){
14497 if(!this.modified){
14498 this.modified = {};
14500 if(typeof this.modified[name] == 'undefined'){
14501 this.modified[name] = this.data[name];
14503 this.data[name] = value;
14504 if(!this.editing && this.store){
14505 this.store.afterEdit(this);
14510 * Get the value of the named field.
14511 * @param {String} name The name of the field to get the value of.
14512 * @return {Object} The value of the field.
14514 get : function(name){
14515 return this.data[name];
14519 beginEdit : function(){
14520 this.editing = true;
14521 this.modified = {};
14525 cancelEdit : function(){
14526 this.editing = false;
14527 delete this.modified;
14531 endEdit : function(){
14532 this.editing = false;
14533 if(this.dirty && this.store){
14534 this.store.afterEdit(this);
14539 * Usually called by the {@link Roo.data.Store} which owns the Record.
14540 * Rejects all changes made to the Record since either creation, or the last commit operation.
14541 * Modified fields are reverted to their original values.
14543 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
14544 * of reject operations.
14546 reject : function(){
14547 var m = this.modified;
14549 if(typeof m[n] != "function"){
14550 this.data[n] = m[n];
14553 this.dirty = false;
14554 delete this.modified;
14555 this.editing = false;
14557 this.store.afterReject(this);
14562 * Usually called by the {@link Roo.data.Store} which owns the Record.
14563 * Commits all changes made to the Record since either creation, or the last commit operation.
14565 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
14566 * of commit operations.
14568 commit : function(){
14569 this.dirty = false;
14570 delete this.modified;
14571 this.editing = false;
14573 this.store.afterCommit(this);
14578 hasError : function(){
14579 return this.error != null;
14583 clearError : function(){
14588 * Creates a copy of this record.
14589 * @param {String} id (optional) A new record id if you don't want to use this record's id
14592 copy : function(newId) {
14593 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
14597 * Ext JS Library 1.1.1
14598 * Copyright(c) 2006-2007, Ext JS, LLC.
14600 * Originally Released Under LGPL - original licence link has changed is not relivant.
14603 * <script type="text/javascript">
14609 * @class Roo.data.Store
14610 * @extends Roo.util.Observable
14611 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
14612 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
14614 * 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
14615 * has no knowledge of the format of the data returned by the Proxy.<br>
14617 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
14618 * instances from the data object. These records are cached and made available through accessor functions.
14620 * Creates a new Store.
14621 * @param {Object} config A config object containing the objects needed for the Store to access data,
14622 * and read the data into Records.
14624 Roo.data.Store = function(config){
14625 this.data = new Roo.util.MixedCollection(false);
14626 this.data.getKey = function(o){
14629 this.baseParams = {};
14631 this.paramNames = {
14636 "multisort" : "_multisort"
14639 if(config && config.data){
14640 this.inlineData = config.data;
14641 delete config.data;
14644 Roo.apply(this, config);
14646 if(this.reader){ // reader passed
14647 this.reader = Roo.factory(this.reader, Roo.data);
14648 this.reader.xmodule = this.xmodule || false;
14649 if(!this.recordType){
14650 this.recordType = this.reader.recordType;
14652 if(this.reader.onMetaChange){
14653 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
14657 if(this.recordType){
14658 this.fields = this.recordType.prototype.fields;
14660 this.modified = [];
14664 * @event datachanged
14665 * Fires when the data cache has changed, and a widget which is using this Store
14666 * as a Record cache should refresh its view.
14667 * @param {Store} this
14669 datachanged : true,
14671 * @event metachange
14672 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
14673 * @param {Store} this
14674 * @param {Object} meta The JSON metadata
14679 * Fires when Records have been added to the Store
14680 * @param {Store} this
14681 * @param {Roo.data.Record[]} records The array of Records added
14682 * @param {Number} index The index at which the record(s) were added
14687 * Fires when a Record has been removed from the Store
14688 * @param {Store} this
14689 * @param {Roo.data.Record} record The Record that was removed
14690 * @param {Number} index The index at which the record was removed
14695 * Fires when a Record has been updated
14696 * @param {Store} this
14697 * @param {Roo.data.Record} record The Record that was updated
14698 * @param {String} operation The update operation being performed. Value may be one of:
14700 Roo.data.Record.EDIT
14701 Roo.data.Record.REJECT
14702 Roo.data.Record.COMMIT
14708 * Fires when the data cache has been cleared.
14709 * @param {Store} this
14713 * @event beforeload
14714 * Fires before a request is made for a new data object. If the beforeload handler returns false
14715 * the load action will be canceled.
14716 * @param {Store} this
14717 * @param {Object} options The loading options that were specified (see {@link #load} for details)
14721 * @event beforeloadadd
14722 * Fires after a new set of Records has been loaded.
14723 * @param {Store} this
14724 * @param {Roo.data.Record[]} records The Records that were loaded
14725 * @param {Object} options The loading options that were specified (see {@link #load} for details)
14727 beforeloadadd : true,
14730 * Fires after a new set of Records has been loaded, before they are added to the store.
14731 * @param {Store} this
14732 * @param {Roo.data.Record[]} records The Records that were loaded
14733 * @param {Object} options The loading options that were specified (see {@link #load} for details)
14734 * @params {Object} return from reader
14738 * @event loadexception
14739 * Fires if an exception occurs in the Proxy during loading.
14740 * Called with the signature of the Proxy's "loadexception" event.
14741 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
14744 * @param {Object} return from JsonData.reader() - success, totalRecords, records
14745 * @param {Object} load options
14746 * @param {Object} jsonData from your request (normally this contains the Exception)
14748 loadexception : true
14752 this.proxy = Roo.factory(this.proxy, Roo.data);
14753 this.proxy.xmodule = this.xmodule || false;
14754 this.relayEvents(this.proxy, ["loadexception"]);
14756 this.sortToggle = {};
14757 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
14759 Roo.data.Store.superclass.constructor.call(this);
14761 if(this.inlineData){
14762 this.loadData(this.inlineData);
14763 delete this.inlineData;
14767 Roo.extend(Roo.data.Store, Roo.util.Observable, {
14769 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
14770 * without a remote query - used by combo/forms at present.
14774 * @cfg {Roo.data.DataProxy} proxy [required] The Proxy object which provides access to a data object.
14777 * @cfg {Array} data Inline data to be loaded when the store is initialized.
14780 * @cfg {Roo.data.DataReader} reader [required] The Reader object which processes the data object and returns
14781 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
14784 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
14785 * on any HTTP request
14788 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
14791 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
14795 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
14796 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
14798 remoteSort : false,
14801 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
14802 * loaded or when a record is removed. (defaults to false).
14804 pruneModifiedRecords : false,
14807 lastOptions : null,
14810 * Add Records to the Store and fires the add event.
14811 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
14813 add : function(records){
14814 records = [].concat(records);
14815 for(var i = 0, len = records.length; i < len; i++){
14816 records[i].join(this);
14818 var index = this.data.length;
14819 this.data.addAll(records);
14820 this.fireEvent("add", this, records, index);
14824 * Remove a Record from the Store and fires the remove event.
14825 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
14827 remove : function(record){
14828 var index = this.data.indexOf(record);
14829 this.data.removeAt(index);
14831 if(this.pruneModifiedRecords){
14832 this.modified.remove(record);
14834 this.fireEvent("remove", this, record, index);
14838 * Remove all Records from the Store and fires the clear event.
14840 removeAll : function(){
14842 if(this.pruneModifiedRecords){
14843 this.modified = [];
14845 this.fireEvent("clear", this);
14849 * Inserts Records to the Store at the given index and fires the add event.
14850 * @param {Number} index The start index at which to insert the passed Records.
14851 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
14853 insert : function(index, records){
14854 records = [].concat(records);
14855 for(var i = 0, len = records.length; i < len; i++){
14856 this.data.insert(index, records[i]);
14857 records[i].join(this);
14859 this.fireEvent("add", this, records, index);
14863 * Get the index within the cache of the passed Record.
14864 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
14865 * @return {Number} The index of the passed Record. Returns -1 if not found.
14867 indexOf : function(record){
14868 return this.data.indexOf(record);
14872 * Get the index within the cache of the Record with the passed id.
14873 * @param {String} id The id of the Record to find.
14874 * @return {Number} The index of the Record. Returns -1 if not found.
14876 indexOfId : function(id){
14877 return this.data.indexOfKey(id);
14881 * Get the Record with the specified id.
14882 * @param {String} id The id of the Record to find.
14883 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
14885 getById : function(id){
14886 return this.data.key(id);
14890 * Get the Record at the specified index.
14891 * @param {Number} index The index of the Record to find.
14892 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
14894 getAt : function(index){
14895 return this.data.itemAt(index);
14899 * Returns a range of Records between specified indices.
14900 * @param {Number} startIndex (optional) The starting index (defaults to 0)
14901 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
14902 * @return {Roo.data.Record[]} An array of Records
14904 getRange : function(start, end){
14905 return this.data.getRange(start, end);
14909 storeOptions : function(o){
14910 o = Roo.apply({}, o);
14913 this.lastOptions = o;
14917 * Loads the Record cache from the configured Proxy using the configured Reader.
14919 * If using remote paging, then the first load call must specify the <em>start</em>
14920 * and <em>limit</em> properties in the options.params property to establish the initial
14921 * position within the dataset, and the number of Records to cache on each read from the Proxy.
14923 * <strong>It is important to note that for remote data sources, loading is asynchronous,
14924 * and this call will return before the new data has been loaded. Perform any post-processing
14925 * in a callback function, or in a "load" event handler.</strong>
14927 * @param {Object} options An object containing properties which control loading options:<ul>
14928 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
14929 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
14930 * passed the following arguments:<ul>
14931 * <li>r : Roo.data.Record[]</li>
14932 * <li>options: Options object from the load call</li>
14933 * <li>success: Boolean success indicator</li></ul></li>
14934 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
14935 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
14938 load : function(options){
14939 options = options || {};
14940 if(this.fireEvent("beforeload", this, options) !== false){
14941 this.storeOptions(options);
14942 var p = Roo.apply(options.params || {}, this.baseParams);
14943 // if meta was not loaded from remote source.. try requesting it.
14944 if (!this.reader.metaFromRemote) {
14945 p._requestMeta = 1;
14947 if(this.sortInfo && this.remoteSort){
14948 var pn = this.paramNames;
14949 p[pn["sort"]] = this.sortInfo.field;
14950 p[pn["dir"]] = this.sortInfo.direction;
14952 if (this.multiSort) {
14953 var pn = this.paramNames;
14954 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
14957 this.proxy.load(p, this.reader, this.loadRecords, this, options);
14962 * Reloads the Record cache from the configured Proxy using the configured Reader and
14963 * the options from the last load operation performed.
14964 * @param {Object} options (optional) An object containing properties which may override the options
14965 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
14966 * the most recently used options are reused).
14968 reload : function(options){
14969 this.load(Roo.applyIf(options||{}, this.lastOptions));
14973 // Called as a callback by the Reader during a load operation.
14974 loadRecords : function(o, options, success){
14975 if(!o || success === false){
14976 if(success !== false){
14977 this.fireEvent("load", this, [], options, o);
14979 if(options.callback){
14980 options.callback.call(options.scope || this, [], options, false);
14984 // if data returned failure - throw an exception.
14985 if (o.success === false) {
14986 // show a message if no listener is registered.
14987 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
14988 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
14990 // loadmask wil be hooked into this..
14991 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
14994 var r = o.records, t = o.totalRecords || r.length;
14996 this.fireEvent("beforeloadadd", this, r, options, o);
14998 if(!options || options.add !== true){
14999 if(this.pruneModifiedRecords){
15000 this.modified = [];
15002 for(var i = 0, len = r.length; i < len; i++){
15006 this.data = this.snapshot;
15007 delete this.snapshot;
15010 this.data.addAll(r);
15011 this.totalLength = t;
15013 this.fireEvent("datachanged", this);
15015 this.totalLength = Math.max(t, this.data.length+r.length);
15019 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
15021 var e = new Roo.data.Record({});
15023 e.set(this.parent.displayField, this.parent.emptyTitle);
15024 e.set(this.parent.valueField, '');
15029 this.fireEvent("load", this, r, options, o);
15030 if(options.callback){
15031 options.callback.call(options.scope || this, r, options, true);
15037 * Loads data from a passed data block. A Reader which understands the format of the data
15038 * must have been configured in the constructor.
15039 * @param {Object} data The data block from which to read the Records. The format of the data expected
15040 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
15041 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
15043 loadData : function(o, append){
15044 var r = this.reader.readRecords(o);
15045 this.loadRecords(r, {add: append}, true);
15049 * using 'cn' the nested child reader read the child array into it's child stores.
15050 * @param {Object} rec The record with a 'children array
15052 loadDataFromChildren : function(rec)
15054 this.loadData(this.reader.toLoadData(rec));
15059 * Gets the number of cached records.
15061 * <em>If using paging, this may not be the total size of the dataset. If the data object
15062 * used by the Reader contains the dataset size, then the getTotalCount() function returns
15063 * the data set size</em>
15065 getCount : function(){
15066 return this.data.length || 0;
15070 * Gets the total number of records in the dataset as returned by the server.
15072 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
15073 * the dataset size</em>
15075 getTotalCount : function(){
15076 return this.totalLength || 0;
15080 * Returns the sort state of the Store as an object with two properties:
15082 field {String} The name of the field by which the Records are sorted
15083 direction {String} The sort order, "ASC" or "DESC"
15086 getSortState : function(){
15087 return this.sortInfo;
15091 applySort : function(){
15092 if(this.sortInfo && !this.remoteSort){
15093 var s = this.sortInfo, f = s.field;
15094 var st = this.fields.get(f).sortType;
15095 var fn = function(r1, r2){
15096 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
15097 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
15099 this.data.sort(s.direction, fn);
15100 if(this.snapshot && this.snapshot != this.data){
15101 this.snapshot.sort(s.direction, fn);
15107 * Sets the default sort column and order to be used by the next load operation.
15108 * @param {String} fieldName The name of the field to sort by.
15109 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
15111 setDefaultSort : function(field, dir){
15112 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
15116 * Sort the Records.
15117 * If remote sorting is used, the sort is performed on the server, and the cache is
15118 * reloaded. If local sorting is used, the cache is sorted internally.
15119 * @param {String} fieldName The name of the field to sort by.
15120 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
15122 sort : function(fieldName, dir){
15123 var f = this.fields.get(fieldName);
15125 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
15127 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
15128 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
15133 this.sortToggle[f.name] = dir;
15134 this.sortInfo = {field: f.name, direction: dir};
15135 if(!this.remoteSort){
15137 this.fireEvent("datachanged", this);
15139 this.load(this.lastOptions);
15144 * Calls the specified function for each of the Records in the cache.
15145 * @param {Function} fn The function to call. The Record is passed as the first parameter.
15146 * Returning <em>false</em> aborts and exits the iteration.
15147 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
15149 each : function(fn, scope){
15150 this.data.each(fn, scope);
15154 * Gets all records modified since the last commit. Modified records are persisted across load operations
15155 * (e.g., during paging).
15156 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
15158 getModifiedRecords : function(){
15159 return this.modified;
15163 createFilterFn : function(property, value, anyMatch){
15164 if(!value.exec){ // not a regex
15165 value = String(value);
15166 if(value.length == 0){
15169 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
15171 return function(r){
15172 return value.test(r.data[property]);
15177 * Sums the value of <i>property</i> for each record between start and end and returns the result.
15178 * @param {String} property A field on your records
15179 * @param {Number} start The record index to start at (defaults to 0)
15180 * @param {Number} end The last record index to include (defaults to length - 1)
15181 * @return {Number} The sum
15183 sum : function(property, start, end){
15184 var rs = this.data.items, v = 0;
15185 start = start || 0;
15186 end = (end || end === 0) ? end : rs.length-1;
15188 for(var i = start; i <= end; i++){
15189 v += (rs[i].data[property] || 0);
15195 * Filter the records by a specified property.
15196 * @param {String} field A field on your records
15197 * @param {String/RegExp} value Either a string that the field
15198 * should start with or a RegExp to test against the field
15199 * @param {Boolean} anyMatch True to match any part not just the beginning
15201 filter : function(property, value, anyMatch){
15202 var fn = this.createFilterFn(property, value, anyMatch);
15203 return fn ? this.filterBy(fn) : this.clearFilter();
15207 * Filter by a function. The specified function will be called with each
15208 * record in this data source. If the function returns true the record is included,
15209 * otherwise it is filtered.
15210 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
15211 * @param {Object} scope (optional) The scope of the function (defaults to this)
15213 filterBy : function(fn, scope){
15214 this.snapshot = this.snapshot || this.data;
15215 this.data = this.queryBy(fn, scope||this);
15216 this.fireEvent("datachanged", this);
15220 * Query the records by a specified property.
15221 * @param {String} field A field on your records
15222 * @param {String/RegExp} value Either a string that the field
15223 * should start with or a RegExp to test against the field
15224 * @param {Boolean} anyMatch True to match any part not just the beginning
15225 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
15227 query : function(property, value, anyMatch){
15228 var fn = this.createFilterFn(property, value, anyMatch);
15229 return fn ? this.queryBy(fn) : this.data.clone();
15233 * Query by a function. The specified function will be called with each
15234 * record in this data source. If the function returns true the record is included
15236 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
15237 * @param {Object} scope (optional) The scope of the function (defaults to this)
15238 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
15240 queryBy : function(fn, scope){
15241 var data = this.snapshot || this.data;
15242 return data.filterBy(fn, scope||this);
15246 * Collects unique values for a particular dataIndex from this store.
15247 * @param {String} dataIndex The property to collect
15248 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
15249 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
15250 * @return {Array} An array of the unique values
15252 collect : function(dataIndex, allowNull, bypassFilter){
15253 var d = (bypassFilter === true && this.snapshot) ?
15254 this.snapshot.items : this.data.items;
15255 var v, sv, r = [], l = {};
15256 for(var i = 0, len = d.length; i < len; i++){
15257 v = d[i].data[dataIndex];
15259 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
15268 * Revert to a view of the Record cache with no filtering applied.
15269 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
15271 clearFilter : function(suppressEvent){
15272 if(this.snapshot && this.snapshot != this.data){
15273 this.data = this.snapshot;
15274 delete this.snapshot;
15275 if(suppressEvent !== true){
15276 this.fireEvent("datachanged", this);
15282 afterEdit : function(record){
15283 if(this.modified.indexOf(record) == -1){
15284 this.modified.push(record);
15286 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
15290 afterReject : function(record){
15291 this.modified.remove(record);
15292 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
15296 afterCommit : function(record){
15297 this.modified.remove(record);
15298 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
15302 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
15303 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
15305 commitChanges : function(){
15306 var m = this.modified.slice(0);
15307 this.modified = [];
15308 for(var i = 0, len = m.length; i < len; i++){
15314 * Cancel outstanding changes on all changed records.
15316 rejectChanges : function(){
15317 var m = this.modified.slice(0);
15318 this.modified = [];
15319 for(var i = 0, len = m.length; i < len; i++){
15324 onMetaChange : function(meta, rtype, o){
15325 this.recordType = rtype;
15326 this.fields = rtype.prototype.fields;
15327 delete this.snapshot;
15328 this.sortInfo = meta.sortInfo || this.sortInfo;
15329 this.modified = [];
15330 this.fireEvent('metachange', this, this.reader.meta);
15333 moveIndex : function(data, type)
15335 var index = this.indexOf(data);
15337 var newIndex = index + type;
15341 this.insert(newIndex, data);
15346 * Ext JS Library 1.1.1
15347 * Copyright(c) 2006-2007, Ext JS, LLC.
15349 * Originally Released Under LGPL - original licence link has changed is not relivant.
15352 * <script type="text/javascript">
15356 * @class Roo.data.SimpleStore
15357 * @extends Roo.data.Store
15358 * Small helper class to make creating Stores from Array data easier.
15359 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
15360 * @cfg {Array} fields An array of field definition objects, or field name strings.
15361 * @cfg {Object} an existing reader (eg. copied from another store)
15362 * @cfg {Array} data The multi-dimensional array of data
15363 * @cfg {Roo.data.DataProxy} proxy [not-required]
15364 * @cfg {Roo.data.Reader} reader [not-required]
15366 * @param {Object} config
15368 Roo.data.SimpleStore = function(config)
15370 Roo.data.SimpleStore.superclass.constructor.call(this, {
15372 reader: typeof(config.reader) != 'undefined' ? config.reader : new Roo.data.ArrayReader({
15375 Roo.data.Record.create(config.fields)
15377 proxy : new Roo.data.MemoryProxy(config.data)
15381 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
15383 * Ext JS Library 1.1.1
15384 * Copyright(c) 2006-2007, Ext JS, LLC.
15386 * Originally Released Under LGPL - original licence link has changed is not relivant.
15389 * <script type="text/javascript">
15394 * @extends Roo.data.Store
15395 * @class Roo.data.JsonStore
15396 * Small helper class to make creating Stores for JSON data easier. <br/>
15398 var store = new Roo.data.JsonStore({
15399 url: 'get-images.php',
15401 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
15404 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
15405 * JsonReader and HttpProxy (unless inline data is provided).</b>
15406 * @cfg {Array} fields An array of field definition objects, or field name strings.
15408 * @param {Object} config
15410 Roo.data.JsonStore = function(c){
15411 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
15412 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
15413 reader: new Roo.data.JsonReader(c, c.fields)
15416 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
15418 * Ext JS Library 1.1.1
15419 * Copyright(c) 2006-2007, Ext JS, LLC.
15421 * Originally Released Under LGPL - original licence link has changed is not relivant.
15424 * <script type="text/javascript">
15428 Roo.data.Field = function(config){
15429 if(typeof config == "string"){
15430 config = {name: config};
15432 Roo.apply(this, config);
15435 this.type = "auto";
15438 var st = Roo.data.SortTypes;
15439 // named sortTypes are supported, here we look them up
15440 if(typeof this.sortType == "string"){
15441 this.sortType = st[this.sortType];
15444 // set default sortType for strings and dates
15445 if(!this.sortType){
15448 this.sortType = st.asUCString;
15451 this.sortType = st.asDate;
15454 this.sortType = st.none;
15459 var stripRe = /[\$,%]/g;
15461 // prebuilt conversion function for this field, instead of
15462 // switching every time we're reading a value
15464 var cv, dateFormat = this.dateFormat;
15469 cv = function(v){ return v; };
15472 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
15476 return v !== undefined && v !== null && v !== '' ?
15477 parseInt(String(v).replace(stripRe, ""), 10) : '';
15482 return v !== undefined && v !== null && v !== '' ?
15483 parseFloat(String(v).replace(stripRe, ""), 10) : '';
15488 cv = function(v){ return v === true || v === "true" || v == 1; };
15495 if(v instanceof Date){
15499 if(dateFormat == "timestamp"){
15500 return new Date(v*1000);
15502 return Date.parseDate(v, dateFormat);
15504 var parsed = Date.parse(v);
15505 return parsed ? new Date(parsed) : null;
15514 Roo.data.Field.prototype = {
15522 * Ext JS Library 1.1.1
15523 * Copyright(c) 2006-2007, Ext JS, LLC.
15525 * Originally Released Under LGPL - original licence link has changed is not relivant.
15528 * <script type="text/javascript">
15531 // Base class for reading structured data from a data source. This class is intended to be
15532 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
15535 * @class Roo.data.DataReader
15537 * Base class for reading structured data from a data source. This class is intended to be
15538 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
15541 Roo.data.DataReader = function(meta, recordType){
15545 this.recordType = recordType instanceof Array ?
15546 Roo.data.Record.create(recordType) : recordType;
15549 Roo.data.DataReader.prototype = {
15552 readerType : 'Data',
15554 * Create an empty record
15555 * @param {Object} data (optional) - overlay some values
15556 * @return {Roo.data.Record} record created.
15558 newRow : function(d) {
15560 this.recordType.prototype.fields.each(function(c) {
15562 case 'int' : da[c.name] = 0; break;
15563 case 'date' : da[c.name] = new Date(); break;
15564 case 'float' : da[c.name] = 0.0; break;
15565 case 'boolean' : da[c.name] = false; break;
15566 default : da[c.name] = ""; break;
15570 return new this.recordType(Roo.apply(da, d));
15576 * Ext JS Library 1.1.1
15577 * Copyright(c) 2006-2007, Ext JS, LLC.
15579 * Originally Released Under LGPL - original licence link has changed is not relivant.
15582 * <script type="text/javascript">
15586 * @class Roo.data.DataProxy
15587 * @extends Roo.data.Observable
15589 * This class is an abstract base class for implementations which provide retrieval of
15590 * unformatted data objects.<br>
15592 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
15593 * (of the appropriate type which knows how to parse the data object) to provide a block of
15594 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
15596 * Custom implementations must implement the load method as described in
15597 * {@link Roo.data.HttpProxy#load}.
15599 Roo.data.DataProxy = function(){
15602 * @event beforeload
15603 * Fires before a network request is made to retrieve a data object.
15604 * @param {Object} This DataProxy object.
15605 * @param {Object} params The params parameter to the load function.
15610 * Fires before the load method's callback is called.
15611 * @param {Object} This DataProxy object.
15612 * @param {Object} o The data object.
15613 * @param {Object} arg The callback argument object passed to the load function.
15617 * @event loadexception
15618 * Fires if an Exception occurs during data retrieval.
15619 * @param {Object} This DataProxy object.
15620 * @param {Object} o The data object.
15621 * @param {Object} arg The callback argument object passed to the load function.
15622 * @param {Object} e The Exception.
15624 loadexception : true
15626 Roo.data.DataProxy.superclass.constructor.call(this);
15629 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
15632 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
15636 * Ext JS Library 1.1.1
15637 * Copyright(c) 2006-2007, Ext JS, LLC.
15639 * Originally Released Under LGPL - original licence link has changed is not relivant.
15642 * <script type="text/javascript">
15645 * @class Roo.data.MemoryProxy
15646 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
15647 * to the Reader when its load method is called.
15649 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
15651 Roo.data.MemoryProxy = function(data){
15655 Roo.data.MemoryProxy.superclass.constructor.call(this);
15659 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
15662 * Load data from the requested source (in this case an in-memory
15663 * data object passed to the constructor), read the data object into
15664 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
15665 * process that block using the passed callback.
15666 * @param {Object} params This parameter is not used by the MemoryProxy class.
15667 * @param {Roo.data.DataReader} reader The Reader object which converts the data
15668 * object into a block of Roo.data.Records.
15669 * @param {Function} callback The function into which to pass the block of Roo.data.records.
15670 * The function must be passed <ul>
15671 * <li>The Record block object</li>
15672 * <li>The "arg" argument from the load function</li>
15673 * <li>A boolean success indicator</li>
15675 * @param {Object} scope The scope in which to call the callback
15676 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
15678 load : function(params, reader, callback, scope, arg){
15679 params = params || {};
15682 result = reader.readRecords(params.data ? params.data :this.data);
15684 this.fireEvent("loadexception", this, arg, null, e);
15685 callback.call(scope, null, arg, false);
15688 callback.call(scope, result, arg, true);
15692 update : function(params, records){
15697 * Ext JS Library 1.1.1
15698 * Copyright(c) 2006-2007, Ext JS, LLC.
15700 * Originally Released Under LGPL - original licence link has changed is not relivant.
15703 * <script type="text/javascript">
15706 * @class Roo.data.HttpProxy
15707 * @extends Roo.data.DataProxy
15708 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
15709 * configured to reference a certain URL.<br><br>
15711 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
15712 * from which the running page was served.<br><br>
15714 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
15716 * Be aware that to enable the browser to parse an XML document, the server must set
15717 * the Content-Type header in the HTTP response to "text/xml".
15719 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
15720 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
15721 * will be used to make the request.
15723 Roo.data.HttpProxy = function(conn){
15724 Roo.data.HttpProxy.superclass.constructor.call(this);
15725 // is conn a conn config or a real conn?
15727 this.useAjax = !conn || !conn.events;
15731 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
15732 // thse are take from connection...
15735 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
15738 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
15739 * extra parameters to each request made by this object. (defaults to undefined)
15742 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
15743 * to each request made by this object. (defaults to undefined)
15746 * @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)
15749 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
15752 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
15758 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
15762 * Return the {@link Roo.data.Connection} object being used by this Proxy.
15763 * @return {Connection} The Connection object. This object may be used to subscribe to events on
15764 * a finer-grained basis than the DataProxy events.
15766 getConnection : function(){
15767 return this.useAjax ? Roo.Ajax : this.conn;
15771 * Load data from the configured {@link Roo.data.Connection}, read the data object into
15772 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
15773 * process that block using the passed callback.
15774 * @param {Object} params An object containing properties which are to be used as HTTP parameters
15775 * for the request to the remote server.
15776 * @param {Roo.data.DataReader} reader The Reader object which converts the data
15777 * object into a block of Roo.data.Records.
15778 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
15779 * The function must be passed <ul>
15780 * <li>The Record block object</li>
15781 * <li>The "arg" argument from the load function</li>
15782 * <li>A boolean success indicator</li>
15784 * @param {Object} scope The scope in which to call the callback
15785 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
15787 load : function(params, reader, callback, scope, arg){
15788 if(this.fireEvent("beforeload", this, params) !== false){
15790 params : params || {},
15792 callback : callback,
15797 callback : this.loadResponse,
15801 Roo.applyIf(o, this.conn);
15802 if(this.activeRequest){
15803 Roo.Ajax.abort(this.activeRequest);
15805 this.activeRequest = Roo.Ajax.request(o);
15807 this.conn.request(o);
15810 callback.call(scope||this, null, arg, false);
15815 loadResponse : function(o, success, response){
15816 delete this.activeRequest;
15818 this.fireEvent("loadexception", this, o, response);
15819 o.request.callback.call(o.request.scope, null, o.request.arg, false);
15824 result = o.reader.read(response);
15826 this.fireEvent("loadexception", this, o, response, e);
15827 o.request.callback.call(o.request.scope, null, o.request.arg, false);
15831 this.fireEvent("load", this, o, o.request.arg);
15832 o.request.callback.call(o.request.scope, result, o.request.arg, true);
15836 update : function(dataSet){
15841 updateResponse : function(dataSet){
15846 * Ext JS Library 1.1.1
15847 * Copyright(c) 2006-2007, Ext JS, LLC.
15849 * Originally Released Under LGPL - original licence link has changed is not relivant.
15852 * <script type="text/javascript">
15856 * @class Roo.data.ScriptTagProxy
15857 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
15858 * other than the originating domain of the running page.<br><br>
15860 * <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
15861 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
15863 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
15864 * source code that is used as the source inside a <script> tag.<br><br>
15866 * In order for the browser to process the returned data, the server must wrap the data object
15867 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
15868 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
15869 * depending on whether the callback name was passed:
15872 boolean scriptTag = false;
15873 String cb = request.getParameter("callback");
15876 response.setContentType("text/javascript");
15878 response.setContentType("application/x-json");
15880 Writer out = response.getWriter();
15882 out.write(cb + "(");
15884 out.print(dataBlock.toJsonString());
15891 * @param {Object} config A configuration object.
15893 Roo.data.ScriptTagProxy = function(config){
15894 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
15895 Roo.apply(this, config);
15896 this.head = document.getElementsByTagName("head")[0];
15899 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
15901 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
15903 * @cfg {String} url The URL from which to request the data object.
15906 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
15910 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
15911 * the server the name of the callback function set up by the load call to process the returned data object.
15912 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
15913 * javascript output which calls this named function passing the data object as its only parameter.
15915 callbackParam : "callback",
15917 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
15918 * name to the request.
15923 * Load data from the configured URL, read the data object into
15924 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
15925 * process that block using the passed callback.
15926 * @param {Object} params An object containing properties which are to be used as HTTP parameters
15927 * for the request to the remote server.
15928 * @param {Roo.data.DataReader} reader The Reader object which converts the data
15929 * object into a block of Roo.data.Records.
15930 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
15931 * The function must be passed <ul>
15932 * <li>The Record block object</li>
15933 * <li>The "arg" argument from the load function</li>
15934 * <li>A boolean success indicator</li>
15936 * @param {Object} scope The scope in which to call the callback
15937 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
15939 load : function(params, reader, callback, scope, arg){
15940 if(this.fireEvent("beforeload", this, params) !== false){
15942 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
15944 var url = this.url;
15945 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
15947 url += "&_dc=" + (new Date().getTime());
15949 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
15952 cb : "stcCallback"+transId,
15953 scriptId : "stcScript"+transId,
15957 callback : callback,
15963 window[trans.cb] = function(o){
15964 conn.handleResponse(o, trans);
15967 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
15969 if(this.autoAbort !== false){
15973 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
15975 var script = document.createElement("script");
15976 script.setAttribute("src", url);
15977 script.setAttribute("type", "text/javascript");
15978 script.setAttribute("id", trans.scriptId);
15979 this.head.appendChild(script);
15981 this.trans = trans;
15983 callback.call(scope||this, null, arg, false);
15988 isLoading : function(){
15989 return this.trans ? true : false;
15993 * Abort the current server request.
15995 abort : function(){
15996 if(this.isLoading()){
15997 this.destroyTrans(this.trans);
16002 destroyTrans : function(trans, isLoaded){
16003 this.head.removeChild(document.getElementById(trans.scriptId));
16004 clearTimeout(trans.timeoutId);
16006 window[trans.cb] = undefined;
16008 delete window[trans.cb];
16011 // if hasn't been loaded, wait for load to remove it to prevent script error
16012 window[trans.cb] = function(){
16013 window[trans.cb] = undefined;
16015 delete window[trans.cb];
16022 handleResponse : function(o, trans){
16023 this.trans = false;
16024 this.destroyTrans(trans, true);
16027 result = trans.reader.readRecords(o);
16029 this.fireEvent("loadexception", this, o, trans.arg, e);
16030 trans.callback.call(trans.scope||window, null, trans.arg, false);
16033 this.fireEvent("load", this, o, trans.arg);
16034 trans.callback.call(trans.scope||window, result, trans.arg, true);
16038 handleFailure : function(trans){
16039 this.trans = false;
16040 this.destroyTrans(trans, false);
16041 this.fireEvent("loadexception", this, null, trans.arg);
16042 trans.callback.call(trans.scope||window, null, trans.arg, false);
16046 * Ext JS Library 1.1.1
16047 * Copyright(c) 2006-2007, Ext JS, LLC.
16049 * Originally Released Under LGPL - original licence link has changed is not relivant.
16052 * <script type="text/javascript">
16056 * @class Roo.data.JsonReader
16057 * @extends Roo.data.DataReader
16058 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
16059 * based on mappings in a provided Roo.data.Record constructor.
16061 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
16062 * in the reply previously.
16067 var RecordDef = Roo.data.Record.create([
16068 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
16069 {name: 'occupation'} // This field will use "occupation" as the mapping.
16071 var myReader = new Roo.data.JsonReader({
16072 totalProperty: "results", // The property which contains the total dataset size (optional)
16073 root: "rows", // The property which contains an Array of row objects
16074 id: "id" // The property within each row object that provides an ID for the record (optional)
16078 * This would consume a JSON file like this:
16080 { 'results': 2, 'rows': [
16081 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
16082 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
16085 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
16086 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
16087 * paged from the remote server.
16088 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
16089 * @cfg {String} root name of the property which contains the Array of row objects.
16090 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
16091 * @cfg {Array} fields Array of field definition objects
16093 * Create a new JsonReader
16094 * @param {Object} meta Metadata configuration options
16095 * @param {Object} recordType Either an Array of field definition objects,
16096 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
16098 Roo.data.JsonReader = function(meta, recordType){
16101 // set some defaults:
16102 Roo.applyIf(meta, {
16103 totalProperty: 'total',
16104 successProperty : 'success',
16109 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
16111 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
16113 readerType : 'Json',
16116 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
16117 * Used by Store query builder to append _requestMeta to params.
16120 metaFromRemote : false,
16122 * This method is only used by a DataProxy which has retrieved data from a remote server.
16123 * @param {Object} response The XHR object which contains the JSON data in its responseText.
16124 * @return {Object} data A data block which is used by an Roo.data.Store object as
16125 * a cache of Roo.data.Records.
16127 read : function(response){
16128 var json = response.responseText;
16130 var o = /* eval:var:o */ eval("("+json+")");
16132 throw {message: "JsonReader.read: Json object not found"};
16138 this.metaFromRemote = true;
16139 this.meta = o.metaData;
16140 this.recordType = Roo.data.Record.create(o.metaData.fields);
16141 this.onMetaChange(this.meta, this.recordType, o);
16143 return this.readRecords(o);
16146 // private function a store will implement
16147 onMetaChange : function(meta, recordType, o){
16154 simpleAccess: function(obj, subsc) {
16161 getJsonAccessor: function(){
16163 return function(expr) {
16165 return(re.test(expr))
16166 ? new Function("obj", "return obj." + expr)
16171 return Roo.emptyFn;
16176 * Create a data block containing Roo.data.Records from an XML document.
16177 * @param {Object} o An object which contains an Array of row objects in the property specified
16178 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
16179 * which contains the total size of the dataset.
16180 * @return {Object} data A data block which is used by an Roo.data.Store object as
16181 * a cache of Roo.data.Records.
16183 readRecords : function(o){
16185 * After any data loads, the raw JSON data is available for further custom processing.
16189 var s = this.meta, Record = this.recordType,
16190 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
16192 // Generate extraction functions for the totalProperty, the root, the id, and for each field
16194 if(s.totalProperty) {
16195 this.getTotal = this.getJsonAccessor(s.totalProperty);
16197 if(s.successProperty) {
16198 this.getSuccess = this.getJsonAccessor(s.successProperty);
16200 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
16202 var g = this.getJsonAccessor(s.id);
16203 this.getId = function(rec) {
16205 return (r === undefined || r === "") ? null : r;
16208 this.getId = function(){return null;};
16211 for(var jj = 0; jj < fl; jj++){
16213 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
16214 this.ef[jj] = this.getJsonAccessor(map);
16218 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
16219 if(s.totalProperty){
16220 var vt = parseInt(this.getTotal(o), 10);
16225 if(s.successProperty){
16226 var vs = this.getSuccess(o);
16227 if(vs === false || vs === 'false'){
16232 for(var i = 0; i < c; i++){
16235 var id = this.getId(n);
16236 for(var j = 0; j < fl; j++){
16238 var v = this.ef[j](n);
16240 Roo.log('missing convert for ' + f.name);
16244 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
16246 var record = new Record(values, id);
16248 records[i] = record;
16254 totalRecords : totalRecords
16257 // used when loading children.. @see loadDataFromChildren
16258 toLoadData: function(rec)
16260 // expect rec just to be an array.. eg [a,b,c, [...] << cn ]
16261 var data = typeof(rec.data.cn) == 'undefined' ? [] : rec.data.cn;
16262 return { data : data, total : data.length };
16267 * Ext JS Library 1.1.1
16268 * Copyright(c) 2006-2007, Ext JS, LLC.
16270 * Originally Released Under LGPL - original licence link has changed is not relivant.
16273 * <script type="text/javascript">
16277 * @class Roo.data.ArrayReader
16278 * @extends Roo.data.DataReader
16279 * Data reader class to create an Array of Roo.data.Record objects from an Array.
16280 * Each element of that Array represents a row of data fields. The
16281 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
16282 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
16286 var RecordDef = Roo.data.Record.create([
16287 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
16288 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
16290 var myReader = new Roo.data.ArrayReader({
16291 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
16295 * This would consume an Array like this:
16297 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
16301 * Create a new JsonReader
16302 * @param {Object} meta Metadata configuration options.
16303 * @param {Object|Array} recordType Either an Array of field definition objects
16305 * @cfg {Array} fields Array of field definition objects
16306 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
16307 * as specified to {@link Roo.data.Record#create},
16308 * or an {@link Roo.data.Record} object
16311 * created using {@link Roo.data.Record#create}.
16313 Roo.data.ArrayReader = function(meta, recordType)
16315 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType||meta.fields);
16318 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
16321 * Create a data block containing Roo.data.Records from an XML document.
16322 * @param {Object} o An Array of row objects which represents the dataset.
16323 * @return {Object} A data block which is used by an {@link Roo.data.Store} object as
16324 * a cache of Roo.data.Records.
16326 readRecords : function(o)
16328 var sid = this.meta ? this.meta.id : null;
16329 var recordType = this.recordType, fields = recordType.prototype.fields;
16332 for(var i = 0; i < root.length; i++){
16335 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
16336 for(var j = 0, jlen = fields.length; j < jlen; j++){
16337 var f = fields.items[j];
16338 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
16339 var v = n[k] !== undefined ? n[k] : f.defaultValue;
16341 values[f.name] = v;
16343 var record = new recordType(values, id);
16345 records[records.length] = record;
16349 totalRecords : records.length
16352 // used when loading children.. @see loadDataFromChildren
16353 toLoadData: function(rec)
16355 // expect rec just to be an array.. eg [a,b,c, [...] << cn ]
16356 return typeof(rec.data.cn) == 'undefined' ? [] : rec.data.cn;
16367 * @class Roo.bootstrap.ComboBox
16368 * @extends Roo.bootstrap.TriggerField
16369 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
16370 * @cfg {Boolean} append (true|false) default false
16371 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
16372 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
16373 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
16374 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
16375 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
16376 * @cfg {Boolean} animate default true
16377 * @cfg {Boolean} emptyResultText only for touch device
16378 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
16379 * @cfg {String} emptyTitle default ''
16380 * @cfg {Number} width fixed with? experimental
16382 * Create a new ComboBox.
16383 * @param {Object} config Configuration options
16385 Roo.bootstrap.ComboBox = function(config){
16386 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
16390 * Fires when the dropdown list is expanded
16391 * @param {Roo.bootstrap.ComboBox} combo This combo box
16396 * Fires when the dropdown list is collapsed
16397 * @param {Roo.bootstrap.ComboBox} combo This combo box
16401 * @event beforeselect
16402 * Fires before a list item is selected. Return false to cancel the selection.
16403 * @param {Roo.bootstrap.ComboBox} combo This combo box
16404 * @param {Roo.data.Record} record The data record returned from the underlying store
16405 * @param {Number} index The index of the selected item in the dropdown list
16407 'beforeselect' : true,
16410 * Fires when a list item is selected
16411 * @param {Roo.bootstrap.ComboBox} combo This combo box
16412 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
16413 * @param {Number} index The index of the selected item in the dropdown list
16417 * @event beforequery
16418 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
16419 * The event object passed has these properties:
16420 * @param {Roo.bootstrap.ComboBox} combo This combo box
16421 * @param {String} query The query
16422 * @param {Boolean} forceAll true to force "all" query
16423 * @param {Boolean} cancel true to cancel the query
16424 * @param {Object} e The query event object
16426 'beforequery': true,
16429 * Fires when the 'add' icon is pressed (add a listener to enable add button)
16430 * @param {Roo.bootstrap.ComboBox} combo This combo box
16435 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
16436 * @param {Roo.bootstrap.ComboBox} combo This combo box
16437 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
16442 * Fires when the remove value from the combobox array
16443 * @param {Roo.bootstrap.ComboBox} combo This combo box
16447 * @event afterremove
16448 * Fires when the remove value from the combobox array
16449 * @param {Roo.bootstrap.ComboBox} combo This combo box
16451 'afterremove' : true,
16453 * @event specialfilter
16454 * Fires when specialfilter
16455 * @param {Roo.bootstrap.ComboBox} combo This combo box
16457 'specialfilter' : true,
16460 * Fires when tick the element
16461 * @param {Roo.bootstrap.ComboBox} combo This combo box
16465 * @event touchviewdisplay
16466 * Fires when touch view require special display (default is using displayField)
16467 * @param {Roo.bootstrap.ComboBox} combo This combo box
16468 * @param {Object} cfg set html .
16470 'touchviewdisplay' : true
16475 this.tickItems = [];
16477 this.selectedIndex = -1;
16478 if(this.mode == 'local'){
16479 if(config.queryDelay === undefined){
16480 this.queryDelay = 10;
16482 if(config.minChars === undefined){
16488 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
16491 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
16492 * rendering into an Roo.Editor, defaults to false)
16495 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
16496 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
16499 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
16502 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
16503 * the dropdown list (defaults to undefined, with no header element)
16507 * @cfg {String/Roo.Template} tpl The template to use to render the output default is '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>'
16511 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
16513 listWidth: undefined,
16515 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
16516 * mode = 'remote' or 'text' if mode = 'local')
16518 displayField: undefined,
16521 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
16522 * mode = 'remote' or 'value' if mode = 'local').
16523 * Note: use of a valueField requires the user make a selection
16524 * in order for a value to be mapped.
16526 valueField: undefined,
16528 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
16533 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
16534 * field's data value (defaults to the underlying DOM element's name)
16536 hiddenName: undefined,
16538 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
16542 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
16544 selectedClass: 'active',
16547 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
16551 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
16552 * anchor positions (defaults to 'tl-bl')
16554 listAlign: 'tl-bl?',
16556 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
16560 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
16561 * query specified by the allQuery config option (defaults to 'query')
16563 triggerAction: 'query',
16565 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
16566 * (defaults to 4, does not apply if editable = false)
16570 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
16571 * delay (typeAheadDelay) if it matches a known value (defaults to false)
16575 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
16576 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
16580 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
16581 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
16585 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
16586 * when editable = true (defaults to false)
16588 selectOnFocus:false,
16590 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
16592 queryParam: 'query',
16594 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
16595 * when mode = 'remote' (defaults to 'Loading...')
16597 loadingText: 'Loading...',
16599 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
16603 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
16607 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
16608 * traditional select (defaults to true)
16612 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
16616 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
16620 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
16621 * listWidth has a higher value)
16625 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
16626 * allow the user to set arbitrary text into the field (defaults to false)
16628 forceSelection:false,
16630 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
16631 * if typeAhead = true (defaults to 250)
16633 typeAheadDelay : 250,
16635 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
16636 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
16638 valueNotFoundText : undefined,
16640 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
16642 blockFocus : false,
16645 * @cfg {Boolean} disableClear Disable showing of clear button.
16647 disableClear : false,
16649 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
16651 alwaysQuery : false,
16654 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
16659 * @cfg {String} invalidClass DEPRICATED - uses BS4 is-valid now
16661 invalidClass : "has-warning",
16664 * @cfg {String} validClass DEPRICATED - uses BS4 is-valid now
16666 validClass : "has-success",
16669 * @cfg {Boolean} specialFilter (true|false) special filter default false
16671 specialFilter : false,
16674 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
16676 mobileTouchView : true,
16679 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
16681 useNativeIOS : false,
16684 * @cfg {Boolean} mobile_restrict_height (true|false) restrict height for touch view
16686 mobile_restrict_height : false,
16688 ios_options : false,
16700 btnPosition : 'right',
16701 triggerList : true,
16702 showToggleBtn : true,
16704 emptyResultText: 'Empty',
16705 triggerText : 'Select',
16709 // element that contains real text value.. (when hidden is used..)
16711 getAutoCreate : function()
16716 * Render classic select for iso
16719 if(Roo.isIOS && this.useNativeIOS){
16720 cfg = this.getAutoCreateNativeIOS();
16728 if(Roo.isTouch && this.mobileTouchView){
16729 cfg = this.getAutoCreateTouchView();
16736 if(!this.tickable){
16737 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
16742 * ComboBox with tickable selections
16745 var align = this.labelAlign || this.parentLabelAlign();
16748 cls : 'form-group roo-combobox-tickable' //input-group
16751 var btn_text_select = '';
16752 var btn_text_done = '';
16753 var btn_text_cancel = '';
16755 if (this.btn_text_show) {
16756 btn_text_select = 'Select';
16757 btn_text_done = 'Done';
16758 btn_text_cancel = 'Cancel';
16763 cls : 'tickable-buttons',
16768 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
16769 //html : this.triggerText
16770 html: btn_text_select
16776 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
16778 html: btn_text_done
16784 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
16786 html: btn_text_cancel
16792 buttons.cn.unshift({
16794 cls: 'roo-select2-search-field-input'
16800 Roo.each(buttons.cn, function(c){
16802 c.cls += ' btn-' + _this.size;
16805 if (_this.disabled) {
16812 style : 'display: contents',
16817 cls: 'form-hidden-field'
16821 cls: 'roo-select2-choices',
16825 cls: 'roo-select2-search-field',
16836 cls: 'roo-select2-container input-group roo-select2-container-multi',
16842 // cls: 'typeahead typeahead-long dropdown-menu',
16843 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
16848 if(this.hasFeedback && !this.allowBlank){
16852 cls: 'glyphicon form-control-feedback'
16855 combobox.cn.push(feedback);
16862 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
16863 tooltip : 'This field is required'
16865 if (Roo.bootstrap.version == 4) {
16868 style : 'display:none'
16871 if (align ==='left' && this.fieldLabel.length) {
16873 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
16880 cls : 'control-label col-form-label',
16881 html : this.fieldLabel
16893 var labelCfg = cfg.cn[1];
16894 var contentCfg = cfg.cn[2];
16897 if(this.indicatorpos == 'right'){
16903 cls : 'control-label col-form-label',
16907 html : this.fieldLabel
16923 labelCfg = cfg.cn[0];
16924 contentCfg = cfg.cn[1];
16928 if(this.labelWidth > 12){
16929 labelCfg.style = "width: " + this.labelWidth + 'px';
16931 if(this.width * 1 > 0){
16932 contentCfg.style = "width: " + this.width + 'px';
16934 if(this.labelWidth < 13 && this.labelmd == 0){
16935 this.labelmd = this.labelWidth;
16938 if(this.labellg > 0){
16939 labelCfg.cls += ' col-lg-' + this.labellg;
16940 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
16943 if(this.labelmd > 0){
16944 labelCfg.cls += ' col-md-' + this.labelmd;
16945 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
16948 if(this.labelsm > 0){
16949 labelCfg.cls += ' col-sm-' + this.labelsm;
16950 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
16953 if(this.labelxs > 0){
16954 labelCfg.cls += ' col-xs-' + this.labelxs;
16955 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
16959 } else if ( this.fieldLabel.length) {
16960 // Roo.log(" label");
16965 //cls : 'input-group-addon',
16966 html : this.fieldLabel
16971 if(this.indicatorpos == 'right'){
16975 //cls : 'input-group-addon',
16976 html : this.fieldLabel
16986 // Roo.log(" no label && no align");
16993 ['xs','sm','md','lg'].map(function(size){
16994 if (settings[size]) {
16995 cfg.cls += ' col-' + size + '-' + settings[size];
17003 _initEventsCalled : false,
17006 initEvents: function()
17008 if (this._initEventsCalled) { // as we call render... prevent looping...
17011 this._initEventsCalled = true;
17014 throw "can not find store for combo";
17017 this.indicator = this.indicatorEl();
17019 this.store = Roo.factory(this.store, Roo.data);
17020 this.store.parent = this;
17022 // if we are building from html. then this element is so complex, that we can not really
17023 // use the rendered HTML.
17024 // so we have to trash and replace the previous code.
17025 if (Roo.XComponent.build_from_html) {
17026 // remove this element....
17027 var e = this.el.dom, k=0;
17028 while (e ) { e = e.previousSibling; ++k;}
17033 this.rendered = false;
17035 this.render(this.parent().getChildContainer(true), k);
17038 if(Roo.isIOS && this.useNativeIOS){
17039 this.initIOSView();
17047 if(Roo.isTouch && this.mobileTouchView){
17048 this.initTouchView();
17053 this.initTickableEvents();
17057 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
17059 if(this.hiddenName){
17061 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
17063 this.hiddenField.dom.value =
17064 this.hiddenValue !== undefined ? this.hiddenValue :
17065 this.value !== undefined ? this.value : '';
17067 // prevent input submission
17068 this.el.dom.removeAttribute('name');
17069 this.hiddenField.dom.setAttribute('name', this.hiddenName);
17074 // this.el.dom.setAttribute('autocomplete', 'off');
17077 var cls = 'x-combo-list';
17079 //this.list = new Roo.Layer({
17080 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
17086 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
17087 _this.list.setWidth(lw);
17090 this.list.on('mouseover', this.onViewOver, this);
17091 this.list.on('mousemove', this.onViewMove, this);
17092 this.list.on('scroll', this.onViewScroll, this);
17095 this.list.swallowEvent('mousewheel');
17096 this.assetHeight = 0;
17099 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
17100 this.assetHeight += this.header.getHeight();
17103 this.innerList = this.list.createChild({cls:cls+'-inner'});
17104 this.innerList.on('mouseover', this.onViewOver, this);
17105 this.innerList.on('mousemove', this.onViewMove, this);
17106 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
17108 if(this.allowBlank && !this.pageSize && !this.disableClear){
17109 this.footer = this.list.createChild({cls:cls+'-ft'});
17110 this.pageTb = new Roo.Toolbar(this.footer);
17114 this.footer = this.list.createChild({cls:cls+'-ft'});
17115 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
17116 {pageSize: this.pageSize});
17120 if (this.pageTb && this.allowBlank && !this.disableClear) {
17122 this.pageTb.add(new Roo.Toolbar.Fill(), {
17123 cls: 'x-btn-icon x-btn-clear',
17125 handler: function()
17128 _this.clearValue();
17129 _this.onSelect(false, -1);
17134 this.assetHeight += this.footer.getHeight();
17139 this.tpl = Roo.bootstrap.version == 4 ?
17140 '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>' : // 4 does not need <li> and it get's really confisued.
17141 '<li><a class="dropdown-item" href="#">{' + this.displayField + '}</a></li>';
17144 this.view = new Roo.View(this.list, this.tpl, {
17145 singleSelect:true, store: this.store, selectedClass: this.selectedClass
17147 //this.view.wrapEl.setDisplayed(false);
17148 this.view.on('click', this.onViewClick, this);
17151 this.store.on('beforeload', this.onBeforeLoad, this);
17152 this.store.on('load', this.onLoad, this);
17153 this.store.on('loadexception', this.onLoadException, this);
17155 if(this.resizable){
17156 this.resizer = new Roo.Resizable(this.list, {
17157 pinned:true, handles:'se'
17159 this.resizer.on('resize', function(r, w, h){
17160 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
17161 this.listWidth = w;
17162 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
17163 this.restrictHeight();
17165 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
17168 if(!this.editable){
17169 this.editable = true;
17170 this.setEditable(false);
17175 if (typeof(this.events.add.listeners) != 'undefined') {
17177 this.addicon = this.wrap.createChild(
17178 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
17180 this.addicon.on('click', function(e) {
17181 this.fireEvent('add', this);
17184 if (typeof(this.events.edit.listeners) != 'undefined') {
17186 this.editicon = this.wrap.createChild(
17187 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
17188 if (this.addicon) {
17189 this.editicon.setStyle('margin-left', '40px');
17191 this.editicon.on('click', function(e) {
17193 // we fire even if inothing is selected..
17194 this.fireEvent('edit', this, this.lastData );
17200 this.keyNav = new Roo.KeyNav(this.inputEl(), {
17201 "up" : function(e){
17202 this.inKeyMode = true;
17206 "down" : function(e){
17207 if(!this.isExpanded()){
17208 this.onTriggerClick();
17210 this.inKeyMode = true;
17215 "enter" : function(e){
17216 // this.onViewClick();
17220 if(this.fireEvent("specialkey", this, e)){
17221 this.onViewClick(false);
17227 "esc" : function(e){
17231 "tab" : function(e){
17234 if(this.fireEvent("specialkey", this, e)){
17235 this.onViewClick(false);
17243 doRelay : function(foo, bar, hname){
17244 if(hname == 'down' || this.scope.isExpanded()){
17245 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
17254 this.queryDelay = Math.max(this.queryDelay || 10,
17255 this.mode == 'local' ? 10 : 250);
17258 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
17260 if(this.typeAhead){
17261 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
17263 if(this.editable !== false){
17264 this.inputEl().on("keyup", this.onKeyUp, this);
17266 if(this.forceSelection){
17267 this.inputEl().on('blur', this.doForce, this);
17271 this.choices = this.el.select('ul.roo-select2-choices', true).first();
17272 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
17276 initTickableEvents: function()
17280 if(this.hiddenName){
17282 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
17284 this.hiddenField.dom.value =
17285 this.hiddenValue !== undefined ? this.hiddenValue :
17286 this.value !== undefined ? this.value : '';
17288 // prevent input submission
17289 this.el.dom.removeAttribute('name');
17290 this.hiddenField.dom.setAttribute('name', this.hiddenName);
17295 // this.list = this.el.select('ul.dropdown-menu',true).first();
17297 this.choices = this.el.select('ul.roo-select2-choices', true).first();
17298 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
17299 if(this.triggerList){
17300 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
17303 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
17304 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
17306 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
17307 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
17309 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
17310 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
17312 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
17313 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
17314 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
17317 this.cancelBtn.hide();
17322 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
17323 _this.list.setWidth(lw);
17326 this.list.on('mouseover', this.onViewOver, this);
17327 this.list.on('mousemove', this.onViewMove, this);
17329 this.list.on('scroll', this.onViewScroll, this);
17332 this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}"' +
17333 'type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
17336 this.view = new Roo.View(this.list, this.tpl, {
17341 selectedClass: this.selectedClass
17344 //this.view.wrapEl.setDisplayed(false);
17345 this.view.on('click', this.onViewClick, this);
17349 this.store.on('beforeload', this.onBeforeLoad, this);
17350 this.store.on('load', this.onLoad, this);
17351 this.store.on('loadexception', this.onLoadException, this);
17354 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
17355 "up" : function(e){
17356 this.inKeyMode = true;
17360 "down" : function(e){
17361 this.inKeyMode = true;
17365 "enter" : function(e){
17366 if(this.fireEvent("specialkey", this, e)){
17367 this.onViewClick(false);
17373 "esc" : function(e){
17374 this.onTickableFooterButtonClick(e, false, false);
17377 "tab" : function(e){
17378 this.fireEvent("specialkey", this, e);
17380 this.onTickableFooterButtonClick(e, false, false);
17387 doRelay : function(e, fn, key){
17388 if(this.scope.isExpanded()){
17389 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
17398 this.queryDelay = Math.max(this.queryDelay || 10,
17399 this.mode == 'local' ? 10 : 250);
17402 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
17404 if(this.typeAhead){
17405 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
17408 if(this.editable !== false){
17409 this.tickableInputEl().on("keyup", this.onKeyUp, this);
17412 this.indicator = this.indicatorEl();
17414 if(this.indicator){
17415 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
17416 this.indicator.hide();
17421 onDestroy : function(){
17423 this.view.setStore(null);
17424 this.view.el.removeAllListeners();
17425 this.view.el.remove();
17426 this.view.purgeListeners();
17429 this.list.dom.innerHTML = '';
17433 this.store.un('beforeload', this.onBeforeLoad, this);
17434 this.store.un('load', this.onLoad, this);
17435 this.store.un('loadexception', this.onLoadException, this);
17437 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
17441 fireKey : function(e){
17442 if(e.isNavKeyPress() && !this.list.isVisible()){
17443 this.fireEvent("specialkey", this, e);
17448 onResize: function(w, h)
17452 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
17454 // if(typeof w != 'number'){
17455 // // we do not handle it!?!?
17458 // var tw = this.trigger.getWidth();
17459 // // tw += this.addicon ? this.addicon.getWidth() : 0;
17460 // // tw += this.editicon ? this.editicon.getWidth() : 0;
17462 // this.inputEl().setWidth( this.adjustWidth('input', x));
17464 // //this.trigger.setStyle('left', x+'px');
17466 // if(this.list && this.listWidth === undefined){
17467 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
17468 // this.list.setWidth(lw);
17469 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
17477 * Allow or prevent the user from directly editing the field text. If false is passed,
17478 * the user will only be able to select from the items defined in the dropdown list. This method
17479 * is the runtime equivalent of setting the 'editable' config option at config time.
17480 * @param {Boolean} value True to allow the user to directly edit the field text
17482 setEditable : function(value){
17483 if(value == this.editable){
17486 this.editable = value;
17488 this.inputEl().dom.setAttribute('readOnly', true);
17489 this.inputEl().on('mousedown', this.onTriggerClick, this);
17490 this.inputEl().addClass('x-combo-noedit');
17492 this.inputEl().dom.removeAttribute('readOnly');
17493 this.inputEl().un('mousedown', this.onTriggerClick, this);
17494 this.inputEl().removeClass('x-combo-noedit');
17500 onBeforeLoad : function(combo,opts){
17501 if(!this.hasFocus){
17505 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
17507 this.restrictHeight();
17508 this.selectedIndex = -1;
17512 onLoad : function(){
17514 this.hasQuery = false;
17516 if(!this.hasFocus){
17520 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
17521 this.loading.hide();
17524 if(this.store.getCount() > 0){
17527 this.restrictHeight();
17528 if(this.lastQuery == this.allQuery){
17529 if(this.editable && !this.tickable){
17530 this.inputEl().dom.select();
17534 !this.selectByValue(this.value, true) &&
17537 !this.store.lastOptions ||
17538 typeof(this.store.lastOptions.add) == 'undefined' ||
17539 this.store.lastOptions.add != true
17542 this.select(0, true);
17545 if(this.autoFocus){
17548 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
17549 this.taTask.delay(this.typeAheadDelay);
17553 this.onEmptyResults();
17559 onLoadException : function()
17561 this.hasQuery = false;
17563 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
17564 this.loading.hide();
17567 if(this.tickable && this.editable){
17572 // only causes errors at present
17573 //Roo.log(this.store.reader.jsonData);
17574 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
17576 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
17582 onTypeAhead : function(){
17583 if(this.store.getCount() > 0){
17584 var r = this.store.getAt(0);
17585 var newValue = r.data[this.displayField];
17586 var len = newValue.length;
17587 var selStart = this.getRawValue().length;
17589 if(selStart != len){
17590 this.setRawValue(newValue);
17591 this.selectText(selStart, newValue.length);
17597 onSelect : function(record, index){
17599 if(this.fireEvent('beforeselect', this, record, index) !== false){
17601 this.setFromData(index > -1 ? record.data : false);
17604 this.fireEvent('select', this, record, index);
17609 * Returns the currently selected field value or empty string if no value is set.
17610 * @return {String} value The selected value
17612 getValue : function()
17614 if(Roo.isIOS && this.useNativeIOS){
17615 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
17619 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
17622 if(this.valueField){
17623 return typeof this.value != 'undefined' ? this.value : '';
17625 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
17629 getRawValue : function()
17631 if(Roo.isIOS && this.useNativeIOS){
17632 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
17635 var v = this.inputEl().getValue();
17641 * Clears any text/value currently set in the field
17643 clearValue : function(){
17645 if(this.hiddenField){
17646 this.hiddenField.dom.value = '';
17649 this.setRawValue('');
17650 this.lastSelectionText = '';
17651 this.lastData = false;
17653 var close = this.closeTriggerEl();
17664 * Sets the specified value into the field. If the value finds a match, the corresponding record text
17665 * will be displayed in the field. If the value does not match the data value of an existing item,
17666 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
17667 * Otherwise the field will be blank (although the value will still be set).
17668 * @param {String} value The value to match
17670 setValue : function(v)
17672 if(Roo.isIOS && this.useNativeIOS){
17673 this.setIOSValue(v);
17683 if(this.valueField){
17684 var r = this.findRecord(this.valueField, v);
17686 text = r.data[this.displayField];
17687 }else if(this.valueNotFoundText !== undefined){
17688 text = this.valueNotFoundText;
17691 this.lastSelectionText = text;
17692 if(this.hiddenField){
17693 this.hiddenField.dom.value = v;
17695 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
17698 var close = this.closeTriggerEl();
17701 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
17707 * @property {Object} the last set data for the element
17712 * Sets the value of the field based on a object which is related to the record format for the store.
17713 * @param {Object} value the value to set as. or false on reset?
17715 setFromData : function(o){
17722 var dv = ''; // display value
17723 var vv = ''; // value value..
17725 if (this.displayField) {
17726 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
17728 // this is an error condition!!!
17729 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
17732 if(this.valueField){
17733 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
17736 var close = this.closeTriggerEl();
17739 if(dv.length || vv * 1 > 0){
17741 this.blockFocus=true;
17747 if(this.hiddenField){
17748 this.hiddenField.dom.value = vv;
17750 this.lastSelectionText = dv;
17751 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
17755 // no hidden field.. - we store the value in 'value', but still display
17756 // display field!!!!
17757 this.lastSelectionText = dv;
17758 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
17765 reset : function(){
17766 // overridden so that last data is reset..
17773 this.setValue(this.originalValue);
17774 //this.clearInvalid();
17775 this.lastData = false;
17777 this.view.clearSelections();
17783 findRecord : function(prop, value){
17785 if(this.store.getCount() > 0){
17786 this.store.each(function(r){
17787 if(r.data[prop] == value){
17797 getName: function()
17799 // returns hidden if it's set..
17800 if (!this.rendered) {return ''};
17801 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
17805 onViewMove : function(e, t){
17806 this.inKeyMode = false;
17810 onViewOver : function(e, t){
17811 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
17814 var item = this.view.findItemFromChild(t);
17817 var index = this.view.indexOf(item);
17818 this.select(index, false);
17823 onViewClick : function(view, doFocus, el, e)
17825 var index = this.view.getSelectedIndexes()[0];
17827 var r = this.store.getAt(index);
17831 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
17838 Roo.each(this.tickItems, function(v,k){
17840 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
17842 _this.tickItems.splice(k, 1);
17844 if(typeof(e) == 'undefined' && view == false){
17845 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
17857 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
17858 this.tickItems.push(r.data);
17861 if(typeof(e) == 'undefined' && view == false){
17862 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
17869 this.onSelect(r, index);
17871 if(doFocus !== false && !this.blockFocus){
17872 this.inputEl().focus();
17877 restrictHeight : function(){
17878 //this.innerList.dom.style.height = '';
17879 //var inner = this.innerList.dom;
17880 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
17881 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
17882 //this.list.beginUpdate();
17883 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
17884 this.list.alignTo(this.inputEl(), this.listAlign);
17885 this.list.alignTo(this.inputEl(), this.listAlign);
17886 //this.list.endUpdate();
17890 onEmptyResults : function(){
17892 if(this.tickable && this.editable){
17893 this.hasFocus = false;
17894 this.restrictHeight();
17902 * Returns true if the dropdown list is expanded, else false.
17904 isExpanded : function(){
17905 return this.list.isVisible();
17909 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
17910 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
17911 * @param {String} value The data value of the item to select
17912 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
17913 * selected item if it is not currently in view (defaults to true)
17914 * @return {Boolean} True if the value matched an item in the list, else false
17916 selectByValue : function(v, scrollIntoView){
17917 if(v !== undefined && v !== null){
17918 var r = this.findRecord(this.valueField || this.displayField, v);
17920 this.select(this.store.indexOf(r), scrollIntoView);
17928 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
17929 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
17930 * @param {Number} index The zero-based index of the list item to select
17931 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
17932 * selected item if it is not currently in view (defaults to true)
17934 select : function(index, scrollIntoView){
17935 this.selectedIndex = index;
17936 this.view.select(index);
17937 if(scrollIntoView !== false){
17938 var el = this.view.getNode(index);
17940 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
17943 this.list.scrollChildIntoView(el, false);
17949 selectNext : function(){
17950 var ct = this.store.getCount();
17952 if(this.selectedIndex == -1){
17954 }else if(this.selectedIndex < ct-1){
17955 this.select(this.selectedIndex+1);
17961 selectPrev : function(){
17962 var ct = this.store.getCount();
17964 if(this.selectedIndex == -1){
17966 }else if(this.selectedIndex != 0){
17967 this.select(this.selectedIndex-1);
17973 onKeyUp : function(e){
17974 if(this.editable !== false && !e.isSpecialKey()){
17975 this.lastKey = e.getKey();
17976 this.dqTask.delay(this.queryDelay);
17981 validateBlur : function(){
17982 return !this.list || !this.list.isVisible();
17986 initQuery : function(){
17988 var v = this.getRawValue();
17990 if(this.tickable && this.editable){
17991 v = this.tickableInputEl().getValue();
17998 doForce : function(){
17999 if(this.inputEl().dom.value.length > 0){
18000 this.inputEl().dom.value =
18001 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
18007 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
18008 * query allowing the query action to be canceled if needed.
18009 * @param {String} query The SQL query to execute
18010 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
18011 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
18012 * saved in the current store (defaults to false)
18014 doQuery : function(q, forceAll){
18016 if(q === undefined || q === null){
18021 forceAll: forceAll,
18025 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
18030 forceAll = qe.forceAll;
18031 if(forceAll === true || (q.length >= this.minChars)){
18033 this.hasQuery = true;
18035 if(this.lastQuery != q || this.alwaysQuery){
18036 this.lastQuery = q;
18037 if(this.mode == 'local'){
18038 this.selectedIndex = -1;
18040 this.store.clearFilter();
18043 if(this.specialFilter){
18044 this.fireEvent('specialfilter', this);
18049 this.store.filter(this.displayField, q);
18052 this.store.fireEvent("datachanged", this.store);
18059 this.store.baseParams[this.queryParam] = q;
18061 var options = {params : this.getParams(q)};
18064 options.add = true;
18065 options.params.start = this.page * this.pageSize;
18068 this.store.load(options);
18071 * this code will make the page width larger, at the beginning, the list not align correctly,
18072 * we should expand the list on onLoad
18073 * so command out it
18078 this.selectedIndex = -1;
18083 this.loadNext = false;
18087 getParams : function(q){
18089 //p[this.queryParam] = q;
18093 p.limit = this.pageSize;
18099 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
18101 collapse : function(){
18102 if(!this.isExpanded()){
18108 this.hasFocus = false;
18112 this.cancelBtn.hide();
18113 this.trigger.show();
18116 this.tickableInputEl().dom.value = '';
18117 this.tickableInputEl().blur();
18122 Roo.get(document).un('mousedown', this.collapseIf, this);
18123 Roo.get(document).un('mousewheel', this.collapseIf, this);
18124 if (!this.editable) {
18125 Roo.get(document).un('keydown', this.listKeyPress, this);
18127 this.fireEvent('collapse', this);
18133 collapseIf : function(e){
18134 var in_combo = e.within(this.el);
18135 var in_list = e.within(this.list);
18136 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
18138 if (in_combo || in_list || is_list) {
18139 //e.stopPropagation();
18144 this.onTickableFooterButtonClick(e, false, false);
18152 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
18154 expand : function(){
18156 if(this.isExpanded() || !this.hasFocus){
18160 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
18161 this.list.setWidth(lw);
18167 this.restrictHeight();
18171 this.tickItems = Roo.apply([], this.item);
18174 this.cancelBtn.show();
18175 this.trigger.hide();
18178 this.tickableInputEl().focus();
18183 Roo.get(document).on('mousedown', this.collapseIf, this);
18184 Roo.get(document).on('mousewheel', this.collapseIf, this);
18185 if (!this.editable) {
18186 Roo.get(document).on('keydown', this.listKeyPress, this);
18189 this.fireEvent('expand', this);
18193 // Implements the default empty TriggerField.onTriggerClick function
18194 onTriggerClick : function(e)
18196 Roo.log('trigger click');
18198 if(this.disabled || !this.triggerList){
18203 this.loadNext = false;
18205 if(this.isExpanded()){
18207 if (!this.blockFocus) {
18208 this.inputEl().focus();
18212 this.hasFocus = true;
18213 if(this.triggerAction == 'all') {
18214 this.doQuery(this.allQuery, true);
18216 this.doQuery(this.getRawValue());
18218 if (!this.blockFocus) {
18219 this.inputEl().focus();
18224 onTickableTriggerClick : function(e)
18231 this.loadNext = false;
18232 this.hasFocus = true;
18234 if(this.triggerAction == 'all') {
18235 this.doQuery(this.allQuery, true);
18237 this.doQuery(this.getRawValue());
18241 onSearchFieldClick : function(e)
18243 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
18244 this.onTickableFooterButtonClick(e, false, false);
18248 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
18253 this.loadNext = false;
18254 this.hasFocus = true;
18256 if(this.triggerAction == 'all') {
18257 this.doQuery(this.allQuery, true);
18259 this.doQuery(this.getRawValue());
18263 listKeyPress : function(e)
18265 //Roo.log('listkeypress');
18266 // scroll to first matching element based on key pres..
18267 if (e.isSpecialKey()) {
18270 var k = String.fromCharCode(e.getKey()).toUpperCase();
18273 var csel = this.view.getSelectedNodes();
18274 var cselitem = false;
18276 var ix = this.view.indexOf(csel[0]);
18277 cselitem = this.store.getAt(ix);
18278 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
18284 this.store.each(function(v) {
18286 // start at existing selection.
18287 if (cselitem.id == v.id) {
18293 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
18294 match = this.store.indexOf(v);
18300 if (match === false) {
18301 return true; // no more action?
18304 this.view.select(match);
18305 var sn = Roo.get(this.view.getSelectedNodes()[0]);
18306 sn.scrollIntoView(sn.dom.parentNode, false);
18309 onViewScroll : function(e, t){
18311 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){
18315 this.hasQuery = true;
18317 this.loading = this.list.select('.loading', true).first();
18319 if(this.loading === null){
18320 this.list.createChild({
18322 cls: 'loading roo-select2-more-results roo-select2-active',
18323 html: 'Loading more results...'
18326 this.loading = this.list.select('.loading', true).first();
18328 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
18330 this.loading.hide();
18333 this.loading.show();
18338 this.loadNext = true;
18340 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
18345 addItem : function(o)
18347 var dv = ''; // display value
18349 if (this.displayField) {
18350 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
18352 // this is an error condition!!!
18353 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
18360 var choice = this.choices.createChild({
18362 cls: 'roo-select2-search-choice',
18371 cls: 'roo-select2-search-choice-close fa fa-times',
18376 }, this.searchField);
18378 var close = choice.select('a.roo-select2-search-choice-close', true).first();
18380 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
18388 this.inputEl().dom.value = '';
18393 onRemoveItem : function(e, _self, o)
18395 e.preventDefault();
18397 this.lastItem = Roo.apply([], this.item);
18399 var index = this.item.indexOf(o.data) * 1;
18402 Roo.log('not this item?!');
18406 this.item.splice(index, 1);
18411 this.fireEvent('remove', this, e);
18417 syncValue : function()
18419 if(!this.item.length){
18426 Roo.each(this.item, function(i){
18427 if(_this.valueField){
18428 value.push(i[_this.valueField]);
18435 this.value = value.join(',');
18437 if(this.hiddenField){
18438 this.hiddenField.dom.value = this.value;
18441 this.store.fireEvent("datachanged", this.store);
18446 clearItem : function()
18448 if(!this.multiple){
18454 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
18462 if(this.tickable && !Roo.isTouch){
18463 this.view.refresh();
18467 inputEl: function ()
18469 if(Roo.isIOS && this.useNativeIOS){
18470 return this.el.select('select.roo-ios-select', true).first();
18473 if(Roo.isTouch && this.mobileTouchView){
18474 return this.el.select('input.form-control',true).first();
18478 return this.searchField;
18481 return this.el.select('input.form-control',true).first();
18484 onTickableFooterButtonClick : function(e, btn, el)
18486 e.preventDefault();
18488 this.lastItem = Roo.apply([], this.item);
18490 if(btn && btn.name == 'cancel'){
18491 this.tickItems = Roo.apply([], this.item);
18500 Roo.each(this.tickItems, function(o){
18508 validate : function()
18510 if(this.getVisibilityEl().hasClass('hidden')){
18514 var v = this.getRawValue();
18517 v = this.getValue();
18520 if(this.disabled || this.allowBlank || v.length){
18525 this.markInvalid();
18529 tickableInputEl : function()
18531 if(!this.tickable || !this.editable){
18532 return this.inputEl();
18535 return this.inputEl().select('.roo-select2-search-field-input', true).first();
18539 getAutoCreateTouchView : function()
18544 cls: 'form-group' //input-group
18550 type : this.inputType,
18551 cls : 'form-control x-combo-noedit',
18552 autocomplete: 'new-password',
18553 placeholder : this.placeholder || '',
18558 input.name = this.name;
18562 input.cls += ' input-' + this.size;
18565 if (this.disabled) {
18566 input.disabled = true;
18570 cls : 'roo-combobox-wrap',
18577 inputblock.cls += ' input-group';
18579 inputblock.cn.unshift({
18581 cls : 'input-group-addon input-group-prepend input-group-text',
18586 if(this.removable && !this.multiple){
18587 inputblock.cls += ' roo-removable';
18589 inputblock.cn.push({
18592 cls : 'roo-combo-removable-btn close'
18596 if(this.hasFeedback && !this.allowBlank){
18598 inputblock.cls += ' has-feedback';
18600 inputblock.cn.push({
18602 cls: 'glyphicon form-control-feedback'
18609 inputblock.cls += (this.before) ? '' : ' input-group';
18611 inputblock.cn.push({
18613 cls : 'input-group-addon input-group-append input-group-text',
18619 var ibwrap = inputblock;
18624 cls: 'roo-select2-choices',
18628 cls: 'roo-select2-search-field',
18641 cls: 'roo-select2-container input-group roo-touchview-combobox ',
18646 cls: 'form-hidden-field'
18652 if(!this.multiple && this.showToggleBtn){
18658 if (this.caret != false) {
18661 cls: 'fa fa-' + this.caret
18668 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
18670 Roo.bootstrap.version == 3 ? caret : '',
18673 cls: 'combobox-clear',
18687 combobox.cls += ' roo-select2-container-multi';
18690 var required = this.allowBlank ? {
18692 style: 'display: none'
18695 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
18696 tooltip : 'This field is required'
18699 var align = this.labelAlign || this.parentLabelAlign();
18701 if (align ==='left' && this.fieldLabel.length) {
18707 cls : 'control-label col-form-label',
18708 html : this.fieldLabel
18712 cls : 'roo-combobox-wrap ',
18719 var labelCfg = cfg.cn[1];
18720 var contentCfg = cfg.cn[2];
18723 if(this.indicatorpos == 'right'){
18728 cls : 'control-label col-form-label',
18732 html : this.fieldLabel
18738 cls : "roo-combobox-wrap ",
18746 labelCfg = cfg.cn[0];
18747 contentCfg = cfg.cn[1];
18752 if(this.labelWidth > 12){
18753 labelCfg.style = "width: " + this.labelWidth + 'px';
18756 if(this.labelWidth < 13 && this.labelmd == 0){
18757 this.labelmd = this.labelWidth;
18760 if(this.labellg > 0){
18761 labelCfg.cls += ' col-lg-' + this.labellg;
18762 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
18765 if(this.labelmd > 0){
18766 labelCfg.cls += ' col-md-' + this.labelmd;
18767 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
18770 if(this.labelsm > 0){
18771 labelCfg.cls += ' col-sm-' + this.labelsm;
18772 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
18775 if(this.labelxs > 0){
18776 labelCfg.cls += ' col-xs-' + this.labelxs;
18777 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
18781 } else if ( this.fieldLabel.length) {
18786 cls : 'control-label',
18787 html : this.fieldLabel
18798 if(this.indicatorpos == 'right'){
18802 cls : 'control-label',
18803 html : this.fieldLabel,
18821 var settings = this;
18823 ['xs','sm','md','lg'].map(function(size){
18824 if (settings[size]) {
18825 cfg.cls += ' col-' + size + '-' + settings[size];
18832 initTouchView : function()
18834 this.renderTouchView();
18836 this.touchViewEl.on('scroll', function(){
18837 this.el.dom.scrollTop = 0;
18840 this.originalValue = this.getValue();
18842 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
18844 this.inputEl().on("click", this.showTouchView, this);
18845 if (this.triggerEl) {
18846 this.triggerEl.on("click", this.showTouchView, this);
18850 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
18851 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
18853 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
18855 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
18856 this.store.on('load', this.onTouchViewLoad, this);
18857 this.store.on('loadexception', this.onTouchViewLoadException, this);
18859 if(this.hiddenName){
18861 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
18863 this.hiddenField.dom.value =
18864 this.hiddenValue !== undefined ? this.hiddenValue :
18865 this.value !== undefined ? this.value : '';
18867 this.el.dom.removeAttribute('name');
18868 this.hiddenField.dom.setAttribute('name', this.hiddenName);
18872 this.choices = this.el.select('ul.roo-select2-choices', true).first();
18873 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
18876 if(this.removable && !this.multiple){
18877 var close = this.closeTriggerEl();
18879 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
18880 close.on('click', this.removeBtnClick, this, close);
18884 * fix the bug in Safari iOS8
18886 this.inputEl().on("focus", function(e){
18887 document.activeElement.blur();
18890 this._touchViewMask = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
18897 renderTouchView : function()
18899 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
18900 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18902 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
18903 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18905 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
18906 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18907 this.touchViewBodyEl.setStyle('overflow', 'auto');
18909 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
18910 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18912 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
18913 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18917 showTouchView : function()
18923 this.touchViewHeaderEl.hide();
18925 if(this.modalTitle.length){
18926 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
18927 this.touchViewHeaderEl.show();
18930 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
18931 this.touchViewEl.show();
18933 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
18935 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
18936 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
18938 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
18940 if(this.modalTitle.length){
18941 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
18944 this.touchViewBodyEl.setHeight(bodyHeight);
18948 (function(){ _this.touchViewEl.addClass(['in','show']); }).defer(50);
18950 this.touchViewEl.addClass(['in','show']);
18953 if(this._touchViewMask){
18954 Roo.get(document.body).addClass("x-body-masked");
18955 this._touchViewMask.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
18956 this._touchViewMask.setStyle('z-index', 10000);
18957 this._touchViewMask.addClass('show');
18960 this.doTouchViewQuery();
18964 hideTouchView : function()
18966 this.touchViewEl.removeClass(['in','show']);
18970 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
18972 this.touchViewEl.setStyle('display', 'none');
18975 if(this._touchViewMask){
18976 this._touchViewMask.removeClass('show');
18977 Roo.get(document.body).removeClass("x-body-masked");
18981 setTouchViewValue : function()
18988 Roo.each(this.tickItems, function(o){
18993 this.hideTouchView();
18996 doTouchViewQuery : function()
19005 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
19009 if(!this.alwaysQuery || this.mode == 'local'){
19010 this.onTouchViewLoad();
19017 onTouchViewBeforeLoad : function(combo,opts)
19023 onTouchViewLoad : function()
19025 if(this.store.getCount() < 1){
19026 this.onTouchViewEmptyResults();
19030 this.clearTouchView();
19032 var rawValue = this.getRawValue();
19034 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
19036 this.tickItems = [];
19038 this.store.data.each(function(d, rowIndex){
19039 var row = this.touchViewListGroup.createChild(template);
19041 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
19042 row.addClass(d.data.cls);
19045 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
19048 html : d.data[this.displayField]
19051 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
19052 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
19055 row.removeClass('selected');
19056 if(!this.multiple && this.valueField &&
19057 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
19060 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
19061 row.addClass('selected');
19064 if(this.multiple && this.valueField &&
19065 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
19069 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
19070 this.tickItems.push(d.data);
19073 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
19077 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
19079 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
19081 if(this.modalTitle.length){
19082 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
19085 var listHeight = this.touchViewListGroup.getHeight() + this.touchViewBodyEl.getPadding('tb') * 2;
19087 if(this.mobile_restrict_height && listHeight < bodyHeight){
19088 this.touchViewBodyEl.setHeight(listHeight);
19093 if(firstChecked && listHeight > bodyHeight){
19094 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
19099 onTouchViewLoadException : function()
19101 this.hideTouchView();
19104 onTouchViewEmptyResults : function()
19106 this.clearTouchView();
19108 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
19110 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
19114 clearTouchView : function()
19116 this.touchViewListGroup.dom.innerHTML = '';
19119 onTouchViewClick : function(e, el, o)
19121 e.preventDefault();
19124 var rowIndex = o.rowIndex;
19126 var r = this.store.getAt(rowIndex);
19128 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
19130 if(!this.multiple){
19131 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
19132 c.dom.removeAttribute('checked');
19135 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
19137 this.setFromData(r.data);
19139 var close = this.closeTriggerEl();
19145 this.hideTouchView();
19147 this.fireEvent('select', this, r, rowIndex);
19152 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
19153 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
19154 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
19158 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
19159 this.addItem(r.data);
19160 this.tickItems.push(r.data);
19164 getAutoCreateNativeIOS : function()
19167 cls: 'form-group' //input-group,
19172 cls : 'roo-ios-select'
19176 combobox.name = this.name;
19179 if (this.disabled) {
19180 combobox.disabled = true;
19183 var settings = this;
19185 ['xs','sm','md','lg'].map(function(size){
19186 if (settings[size]) {
19187 cfg.cls += ' col-' + size + '-' + settings[size];
19197 initIOSView : function()
19199 this.store.on('load', this.onIOSViewLoad, this);
19204 onIOSViewLoad : function()
19206 if(this.store.getCount() < 1){
19210 this.clearIOSView();
19212 if(this.allowBlank) {
19214 var default_text = '-- SELECT --';
19216 if(this.placeholder.length){
19217 default_text = this.placeholder;
19220 if(this.emptyTitle.length){
19221 default_text += ' - ' + this.emptyTitle + ' -';
19224 var opt = this.inputEl().createChild({
19227 html : default_text
19231 o[this.valueField] = 0;
19232 o[this.displayField] = default_text;
19234 this.ios_options.push({
19241 this.store.data.each(function(d, rowIndex){
19245 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
19246 html = d.data[this.displayField];
19251 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
19252 value = d.data[this.valueField];
19261 if(this.value == d.data[this.valueField]){
19262 option['selected'] = true;
19265 var opt = this.inputEl().createChild(option);
19267 this.ios_options.push({
19274 this.inputEl().on('change', function(){
19275 this.fireEvent('select', this);
19280 clearIOSView: function()
19282 this.inputEl().dom.innerHTML = '';
19284 this.ios_options = [];
19287 setIOSValue: function(v)
19291 if(!this.ios_options){
19295 Roo.each(this.ios_options, function(opts){
19297 opts.el.dom.removeAttribute('selected');
19299 if(opts.data[this.valueField] != v){
19303 opts.el.dom.setAttribute('selected', true);
19309 * @cfg {Boolean} grow
19313 * @cfg {Number} growMin
19317 * @cfg {Number} growMax
19326 Roo.apply(Roo.bootstrap.ComboBox, {
19330 cls: 'modal-header',
19352 cls: 'list-group-item',
19356 cls: 'roo-combobox-list-group-item-value'
19360 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
19374 listItemCheckbox : {
19376 cls: 'list-group-item',
19380 cls: 'roo-combobox-list-group-item-value'
19384 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
19400 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
19405 cls: 'modal-footer',
19413 cls: 'col-xs-6 text-left',
19416 cls: 'btn btn-danger roo-touch-view-cancel',
19422 cls: 'col-xs-6 text-right',
19425 cls: 'btn btn-success roo-touch-view-ok',
19436 Roo.apply(Roo.bootstrap.ComboBox, {
19438 touchViewTemplate : {
19440 cls: 'modal fade roo-combobox-touch-view',
19444 cls: 'modal-dialog',
19445 style : 'position:fixed', // we have to fix position....
19449 cls: 'modal-content',
19451 Roo.bootstrap.ComboBox.header,
19452 Roo.bootstrap.ComboBox.body,
19453 Roo.bootstrap.ComboBox.footer
19462 * Ext JS Library 1.1.1
19463 * Copyright(c) 2006-2007, Ext JS, LLC.
19465 * Originally Released Under LGPL - original licence link has changed is not relivant.
19468 * <script type="text/javascript">
19473 * @extends Roo.util.Observable
19474 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
19475 * This class also supports single and multi selection modes. <br>
19476 * Create a data model bound view:
19478 var store = new Roo.data.Store(...);
19480 var view = new Roo.View({
19482 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
19484 singleSelect: true,
19485 selectedClass: "ydataview-selected",
19489 // listen for node click?
19490 view.on("click", function(vw, index, node, e){
19491 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
19495 dataModel.load("foobar.xml");
19497 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
19499 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
19500 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
19502 * Note: old style constructor is still suported (container, template, config)
19505 * Create a new View
19506 * @param {Object} config The config object
19509 Roo.View = function(config, depreciated_tpl, depreciated_config){
19511 this.parent = false;
19513 if (typeof(depreciated_tpl) == 'undefined') {
19514 // new way.. - universal constructor.
19515 Roo.apply(this, config);
19516 this.el = Roo.get(this.el);
19519 this.el = Roo.get(config);
19520 this.tpl = depreciated_tpl;
19521 Roo.apply(this, depreciated_config);
19523 this.wrapEl = this.el.wrap().wrap();
19524 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
19527 if(typeof(this.tpl) == "string"){
19528 this.tpl = new Roo.Template(this.tpl);
19530 // support xtype ctors..
19531 this.tpl = new Roo.factory(this.tpl, Roo);
19535 this.tpl.compile();
19540 * @event beforeclick
19541 * Fires before a click is processed. Returns false to cancel the default action.
19542 * @param {Roo.View} this
19543 * @param {Number} index The index of the target node
19544 * @param {HTMLElement} node The target node
19545 * @param {Roo.EventObject} e The raw event object
19547 "beforeclick" : true,
19550 * Fires when a template node is clicked.
19551 * @param {Roo.View} this
19552 * @param {Number} index The index of the target node
19553 * @param {HTMLElement} node The target node
19554 * @param {Roo.EventObject} e The raw event object
19559 * Fires when a template node is double clicked.
19560 * @param {Roo.View} this
19561 * @param {Number} index The index of the target node
19562 * @param {HTMLElement} node The target node
19563 * @param {Roo.EventObject} e The raw event object
19567 * @event contextmenu
19568 * Fires when a template node is right clicked.
19569 * @param {Roo.View} this
19570 * @param {Number} index The index of the target node
19571 * @param {HTMLElement} node The target node
19572 * @param {Roo.EventObject} e The raw event object
19574 "contextmenu" : true,
19576 * @event selectionchange
19577 * Fires when the selected nodes change.
19578 * @param {Roo.View} this
19579 * @param {Array} selections Array of the selected nodes
19581 "selectionchange" : true,
19584 * @event beforeselect
19585 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
19586 * @param {Roo.View} this
19587 * @param {HTMLElement} node The node to be selected
19588 * @param {Array} selections Array of currently selected nodes
19590 "beforeselect" : true,
19592 * @event preparedata
19593 * Fires on every row to render, to allow you to change the data.
19594 * @param {Roo.View} this
19595 * @param {Object} data to be rendered (change this)
19597 "preparedata" : true
19605 "click": this.onClick,
19606 "dblclick": this.onDblClick,
19607 "contextmenu": this.onContextMenu,
19611 this.selections = [];
19613 this.cmp = new Roo.CompositeElementLite([]);
19615 this.store = Roo.factory(this.store, Roo.data);
19616 this.setStore(this.store, true);
19619 if ( this.footer && this.footer.xtype) {
19621 var fctr = this.wrapEl.appendChild(document.createElement("div"));
19623 this.footer.dataSource = this.store;
19624 this.footer.container = fctr;
19625 this.footer = Roo.factory(this.footer, Roo);
19626 fctr.insertFirst(this.el);
19628 // this is a bit insane - as the paging toolbar seems to detach the el..
19629 // dom.parentNode.parentNode.parentNode
19630 // they get detached?
19634 Roo.View.superclass.constructor.call(this);
19639 Roo.extend(Roo.View, Roo.util.Observable, {
19642 * @cfg {Roo.data.Store} store Data store to load data from.
19647 * @cfg {String|Roo.Element} el The container element.
19652 * @cfg {String|Roo.Template} tpl The template used by this View
19656 * @cfg {String} dataName the named area of the template to use as the data area
19657 * Works with domtemplates roo-name="name"
19661 * @cfg {String} selectedClass The css class to add to selected nodes
19663 selectedClass : "x-view-selected",
19665 * @cfg {String} emptyText The empty text to show when nothing is loaded.
19670 * @cfg {String} text to display on mask (default Loading)
19674 * @cfg {Boolean} multiSelect Allow multiple selection
19676 multiSelect : false,
19678 * @cfg {Boolean} singleSelect Allow single selection
19680 singleSelect: false,
19683 * @cfg {Boolean} toggleSelect - selecting
19685 toggleSelect : false,
19688 * @cfg {Boolean} tickable - selecting
19693 * Returns the element this view is bound to.
19694 * @return {Roo.Element}
19696 getEl : function(){
19697 return this.wrapEl;
19703 * Refreshes the view. - called by datachanged on the store. - do not call directly.
19705 refresh : function(){
19706 //Roo.log('refresh');
19709 // if we are using something like 'domtemplate', then
19710 // the what gets used is:
19711 // t.applySubtemplate(NAME, data, wrapping data..)
19712 // the outer template then get' applied with
19713 // the store 'extra data'
19714 // and the body get's added to the
19715 // roo-name="data" node?
19716 // <span class='roo-tpl-{name}'></span> ?????
19720 this.clearSelections();
19721 this.el.update("");
19723 var records = this.store.getRange();
19724 if(records.length < 1) {
19726 // is this valid?? = should it render a template??
19728 this.el.update(this.emptyText);
19732 if (this.dataName) {
19733 this.el.update(t.apply(this.store.meta)); //????
19734 el = this.el.child('.roo-tpl-' + this.dataName);
19737 for(var i = 0, len = records.length; i < len; i++){
19738 var data = this.prepareData(records[i].data, i, records[i]);
19739 this.fireEvent("preparedata", this, data, i, records[i]);
19741 var d = Roo.apply({}, data);
19744 Roo.apply(d, {'roo-id' : Roo.id()});
19748 Roo.each(this.parent.item, function(item){
19749 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
19752 Roo.apply(d, {'roo-data-checked' : 'checked'});
19756 html[html.length] = Roo.util.Format.trim(
19758 t.applySubtemplate(this.dataName, d, this.store.meta) :
19765 el.update(html.join(""));
19766 this.nodes = el.dom.childNodes;
19767 this.updateIndexes(0);
19772 * Function to override to reformat the data that is sent to
19773 * the template for each node.
19774 * DEPRICATED - use the preparedata event handler.
19775 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
19776 * a JSON object for an UpdateManager bound view).
19778 prepareData : function(data, index, record)
19780 this.fireEvent("preparedata", this, data, index, record);
19784 onUpdate : function(ds, record){
19785 // Roo.log('on update');
19786 this.clearSelections();
19787 var index = this.store.indexOf(record);
19788 var n = this.nodes[index];
19789 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
19790 n.parentNode.removeChild(n);
19791 this.updateIndexes(index, index);
19797 onAdd : function(ds, records, index)
19799 //Roo.log(['on Add', ds, records, index] );
19800 this.clearSelections();
19801 if(this.nodes.length == 0){
19805 var n = this.nodes[index];
19806 for(var i = 0, len = records.length; i < len; i++){
19807 var d = this.prepareData(records[i].data, i, records[i]);
19809 this.tpl.insertBefore(n, d);
19812 this.tpl.append(this.el, d);
19815 this.updateIndexes(index);
19818 onRemove : function(ds, record, index){
19819 // Roo.log('onRemove');
19820 this.clearSelections();
19821 var el = this.dataName ?
19822 this.el.child('.roo-tpl-' + this.dataName) :
19825 el.dom.removeChild(this.nodes[index]);
19826 this.updateIndexes(index);
19830 * Refresh an individual node.
19831 * @param {Number} index
19833 refreshNode : function(index){
19834 this.onUpdate(this.store, this.store.getAt(index));
19837 updateIndexes : function(startIndex, endIndex){
19838 var ns = this.nodes;
19839 startIndex = startIndex || 0;
19840 endIndex = endIndex || ns.length - 1;
19841 for(var i = startIndex; i <= endIndex; i++){
19842 ns[i].nodeIndex = i;
19847 * Changes the data store this view uses and refresh the view.
19848 * @param {Store} store
19850 setStore : function(store, initial){
19851 if(!initial && this.store){
19852 this.store.un("datachanged", this.refresh);
19853 this.store.un("add", this.onAdd);
19854 this.store.un("remove", this.onRemove);
19855 this.store.un("update", this.onUpdate);
19856 this.store.un("clear", this.refresh);
19857 this.store.un("beforeload", this.onBeforeLoad);
19858 this.store.un("load", this.onLoad);
19859 this.store.un("loadexception", this.onLoad);
19863 store.on("datachanged", this.refresh, this);
19864 store.on("add", this.onAdd, this);
19865 store.on("remove", this.onRemove, this);
19866 store.on("update", this.onUpdate, this);
19867 store.on("clear", this.refresh, this);
19868 store.on("beforeload", this.onBeforeLoad, this);
19869 store.on("load", this.onLoad, this);
19870 store.on("loadexception", this.onLoad, this);
19878 * onbeforeLoad - masks the loading area.
19881 onBeforeLoad : function(store,opts)
19883 //Roo.log('onBeforeLoad');
19885 this.el.update("");
19887 this.el.mask(this.mask ? this.mask : "Loading" );
19889 onLoad : function ()
19896 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
19897 * @param {HTMLElement} node
19898 * @return {HTMLElement} The template node
19900 findItemFromChild : function(node){
19901 var el = this.dataName ?
19902 this.el.child('.roo-tpl-' + this.dataName,true) :
19905 if(!node || node.parentNode == el){
19908 var p = node.parentNode;
19909 while(p && p != el){
19910 if(p.parentNode == el){
19919 onClick : function(e){
19920 var item = this.findItemFromChild(e.getTarget());
19922 var index = this.indexOf(item);
19923 if(this.onItemClick(item, index, e) !== false){
19924 this.fireEvent("click", this, index, item, e);
19927 this.clearSelections();
19932 onContextMenu : function(e){
19933 var item = this.findItemFromChild(e.getTarget());
19935 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
19940 onDblClick : function(e){
19941 var item = this.findItemFromChild(e.getTarget());
19943 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
19947 onItemClick : function(item, index, e)
19949 if(this.fireEvent("beforeclick", this, index, item, e) === false){
19952 if (this.toggleSelect) {
19953 var m = this.isSelected(item) ? 'unselect' : 'select';
19956 _t[m](item, true, false);
19959 if(this.multiSelect || this.singleSelect){
19960 if(this.multiSelect && e.shiftKey && this.lastSelection){
19961 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
19963 this.select(item, this.multiSelect && e.ctrlKey);
19964 this.lastSelection = item;
19967 if(!this.tickable){
19968 e.preventDefault();
19976 * Get the number of selected nodes.
19979 getSelectionCount : function(){
19980 return this.selections.length;
19984 * Get the currently selected nodes.
19985 * @return {Array} An array of HTMLElements
19987 getSelectedNodes : function(){
19988 return this.selections;
19992 * Get the indexes of the selected nodes.
19995 getSelectedIndexes : function(){
19996 var indexes = [], s = this.selections;
19997 for(var i = 0, len = s.length; i < len; i++){
19998 indexes.push(s[i].nodeIndex);
20004 * Clear all selections
20005 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
20007 clearSelections : function(suppressEvent){
20008 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
20009 this.cmp.elements = this.selections;
20010 this.cmp.removeClass(this.selectedClass);
20011 this.selections = [];
20012 if(!suppressEvent){
20013 this.fireEvent("selectionchange", this, this.selections);
20019 * Returns true if the passed node is selected
20020 * @param {HTMLElement/Number} node The node or node index
20021 * @return {Boolean}
20023 isSelected : function(node){
20024 var s = this.selections;
20028 node = this.getNode(node);
20029 return s.indexOf(node) !== -1;
20034 * @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
20035 * @param {Boolean} keepExisting (optional) true to keep existing selections
20036 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
20038 select : function(nodeInfo, keepExisting, suppressEvent){
20039 if(nodeInfo instanceof Array){
20041 this.clearSelections(true);
20043 for(var i = 0, len = nodeInfo.length; i < len; i++){
20044 this.select(nodeInfo[i], true, true);
20048 var node = this.getNode(nodeInfo);
20049 if(!node || this.isSelected(node)){
20050 return; // already selected.
20053 this.clearSelections(true);
20056 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
20057 Roo.fly(node).addClass(this.selectedClass);
20058 this.selections.push(node);
20059 if(!suppressEvent){
20060 this.fireEvent("selectionchange", this, this.selections);
20068 * @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
20069 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
20070 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
20072 unselect : function(nodeInfo, keepExisting, suppressEvent)
20074 if(nodeInfo instanceof Array){
20075 Roo.each(this.selections, function(s) {
20076 this.unselect(s, nodeInfo);
20080 var node = this.getNode(nodeInfo);
20081 if(!node || !this.isSelected(node)){
20082 //Roo.log("not selected");
20083 return; // not selected.
20087 Roo.each(this.selections, function(s) {
20089 Roo.fly(node).removeClass(this.selectedClass);
20096 this.selections= ns;
20097 this.fireEvent("selectionchange", this, this.selections);
20101 * Gets a template node.
20102 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
20103 * @return {HTMLElement} The node or null if it wasn't found
20105 getNode : function(nodeInfo){
20106 if(typeof nodeInfo == "string"){
20107 return document.getElementById(nodeInfo);
20108 }else if(typeof nodeInfo == "number"){
20109 return this.nodes[nodeInfo];
20115 * Gets a range template nodes.
20116 * @param {Number} startIndex
20117 * @param {Number} endIndex
20118 * @return {Array} An array of nodes
20120 getNodes : function(start, end){
20121 var ns = this.nodes;
20122 start = start || 0;
20123 end = typeof end == "undefined" ? ns.length - 1 : end;
20126 for(var i = start; i <= end; i++){
20130 for(var i = start; i >= end; i--){
20138 * Finds the index of the passed node
20139 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
20140 * @return {Number} The index of the node or -1
20142 indexOf : function(node){
20143 node = this.getNode(node);
20144 if(typeof node.nodeIndex == "number"){
20145 return node.nodeIndex;
20147 var ns = this.nodes;
20148 for(var i = 0, len = ns.length; i < len; i++){
20159 * based on jquery fullcalendar
20163 Roo.bootstrap = Roo.bootstrap || {};
20165 * @class Roo.bootstrap.Calendar
20166 * @extends Roo.bootstrap.Component
20167 * Bootstrap Calendar class
20168 * @cfg {Boolean} loadMask (true|false) default false
20169 * @cfg {Object} header generate the user specific header of the calendar, default false
20172 * Create a new Container
20173 * @param {Object} config The config object
20178 Roo.bootstrap.Calendar = function(config){
20179 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
20183 * Fires when a date is selected
20184 * @param {DatePicker} this
20185 * @param {Date} date The selected date
20189 * @event monthchange
20190 * Fires when the displayed month changes
20191 * @param {DatePicker} this
20192 * @param {Date} date The selected month
20194 'monthchange': true,
20196 * @event evententer
20197 * Fires when mouse over an event
20198 * @param {Calendar} this
20199 * @param {event} Event
20201 'evententer': true,
20203 * @event eventleave
20204 * Fires when the mouse leaves an
20205 * @param {Calendar} this
20208 'eventleave': true,
20210 * @event eventclick
20211 * Fires when the mouse click an
20212 * @param {Calendar} this
20221 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
20224 * @cfg {Roo.data.Store} store
20225 * The data source for the calendar
20229 * @cfg {Number} startDay
20230 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
20238 getAutoCreate : function(){
20241 var fc_button = function(name, corner, style, content ) {
20242 return Roo.apply({},{
20244 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
20246 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
20249 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
20260 style : 'width:100%',
20267 cls : 'fc-header-left',
20269 fc_button('prev', 'left', 'arrow', '‹' ),
20270 fc_button('next', 'right', 'arrow', '›' ),
20271 { tag: 'span', cls: 'fc-header-space' },
20272 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
20280 cls : 'fc-header-center',
20284 cls: 'fc-header-title',
20287 html : 'month / year'
20295 cls : 'fc-header-right',
20297 /* fc_button('month', 'left', '', 'month' ),
20298 fc_button('week', '', '', 'week' ),
20299 fc_button('day', 'right', '', 'day' )
20311 header = this.header;
20314 var cal_heads = function() {
20316 // fixme - handle this.
20318 for (var i =0; i < Date.dayNames.length; i++) {
20319 var d = Date.dayNames[i];
20322 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
20323 html : d.substring(0,3)
20327 ret[0].cls += ' fc-first';
20328 ret[6].cls += ' fc-last';
20331 var cal_cell = function(n) {
20334 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
20339 cls: 'fc-day-number',
20343 cls: 'fc-day-content',
20347 style: 'position: relative;' // height: 17px;
20359 var cal_rows = function() {
20362 for (var r = 0; r < 6; r++) {
20369 for (var i =0; i < Date.dayNames.length; i++) {
20370 var d = Date.dayNames[i];
20371 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
20374 row.cn[0].cls+=' fc-first';
20375 row.cn[0].cn[0].style = 'min-height:90px';
20376 row.cn[6].cls+=' fc-last';
20380 ret[0].cls += ' fc-first';
20381 ret[4].cls += ' fc-prev-last';
20382 ret[5].cls += ' fc-last';
20389 cls: 'fc-border-separate',
20390 style : 'width:100%',
20398 cls : 'fc-first fc-last',
20416 cls : 'fc-content',
20417 style : "position: relative;",
20420 cls : 'fc-view fc-view-month fc-grid',
20421 style : 'position: relative',
20422 unselectable : 'on',
20425 cls : 'fc-event-container',
20426 style : 'position:absolute;z-index:8;top:0;left:0;'
20444 initEvents : function()
20447 throw "can not find store for calendar";
20453 style: "text-align:center",
20457 style: "background-color:white;width:50%;margin:250 auto",
20461 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
20472 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
20474 var size = this.el.select('.fc-content', true).first().getSize();
20475 this.maskEl.setSize(size.width, size.height);
20476 this.maskEl.enableDisplayMode("block");
20477 if(!this.loadMask){
20478 this.maskEl.hide();
20481 this.store = Roo.factory(this.store, Roo.data);
20482 this.store.on('load', this.onLoad, this);
20483 this.store.on('beforeload', this.onBeforeLoad, this);
20487 this.cells = this.el.select('.fc-day',true);
20488 //Roo.log(this.cells);
20489 this.textNodes = this.el.query('.fc-day-number');
20490 this.cells.addClassOnOver('fc-state-hover');
20492 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
20493 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
20494 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
20495 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
20497 this.on('monthchange', this.onMonthChange, this);
20499 this.update(new Date().clearTime());
20502 resize : function() {
20503 var sz = this.el.getSize();
20505 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
20506 this.el.select('.fc-day-content div',true).setHeight(34);
20511 showPrevMonth : function(e){
20512 this.update(this.activeDate.add("mo", -1));
20514 showToday : function(e){
20515 this.update(new Date().clearTime());
20518 showNextMonth : function(e){
20519 this.update(this.activeDate.add("mo", 1));
20523 showPrevYear : function(){
20524 this.update(this.activeDate.add("y", -1));
20528 showNextYear : function(){
20529 this.update(this.activeDate.add("y", 1));
20534 update : function(date)
20536 var vd = this.activeDate;
20537 this.activeDate = date;
20538 // if(vd && this.el){
20539 // var t = date.getTime();
20540 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
20541 // Roo.log('using add remove');
20543 // this.fireEvent('monthchange', this, date);
20545 // this.cells.removeClass("fc-state-highlight");
20546 // this.cells.each(function(c){
20547 // if(c.dateValue == t){
20548 // c.addClass("fc-state-highlight");
20549 // setTimeout(function(){
20550 // try{c.dom.firstChild.focus();}catch(e){}
20560 var days = date.getDaysInMonth();
20562 var firstOfMonth = date.getFirstDateOfMonth();
20563 var startingPos = firstOfMonth.getDay()-this.startDay;
20565 if(startingPos < this.startDay){
20569 var pm = date.add(Date.MONTH, -1);
20570 var prevStart = pm.getDaysInMonth()-startingPos;
20572 this.cells = this.el.select('.fc-day',true);
20573 this.textNodes = this.el.query('.fc-day-number');
20574 this.cells.addClassOnOver('fc-state-hover');
20576 var cells = this.cells.elements;
20577 var textEls = this.textNodes;
20579 Roo.each(cells, function(cell){
20580 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
20583 days += startingPos;
20585 // convert everything to numbers so it's fast
20586 var day = 86400000;
20587 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
20590 //Roo.log(prevStart);
20592 var today = new Date().clearTime().getTime();
20593 var sel = date.clearTime().getTime();
20594 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
20595 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
20596 var ddMatch = this.disabledDatesRE;
20597 var ddText = this.disabledDatesText;
20598 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
20599 var ddaysText = this.disabledDaysText;
20600 var format = this.format;
20602 var setCellClass = function(cal, cell){
20606 //Roo.log('set Cell Class');
20608 var t = d.getTime();
20612 cell.dateValue = t;
20614 cell.className += " fc-today";
20615 cell.className += " fc-state-highlight";
20616 cell.title = cal.todayText;
20619 // disable highlight in other month..
20620 //cell.className += " fc-state-highlight";
20625 cell.className = " fc-state-disabled";
20626 cell.title = cal.minText;
20630 cell.className = " fc-state-disabled";
20631 cell.title = cal.maxText;
20635 if(ddays.indexOf(d.getDay()) != -1){
20636 cell.title = ddaysText;
20637 cell.className = " fc-state-disabled";
20640 if(ddMatch && format){
20641 var fvalue = d.dateFormat(format);
20642 if(ddMatch.test(fvalue)){
20643 cell.title = ddText.replace("%0", fvalue);
20644 cell.className = " fc-state-disabled";
20648 if (!cell.initialClassName) {
20649 cell.initialClassName = cell.dom.className;
20652 cell.dom.className = cell.initialClassName + ' ' + cell.className;
20657 for(; i < startingPos; i++) {
20658 textEls[i].innerHTML = (++prevStart);
20659 d.setDate(d.getDate()+1);
20661 cells[i].className = "fc-past fc-other-month";
20662 setCellClass(this, cells[i]);
20667 for(; i < days; i++){
20668 intDay = i - startingPos + 1;
20669 textEls[i].innerHTML = (intDay);
20670 d.setDate(d.getDate()+1);
20672 cells[i].className = ''; // "x-date-active";
20673 setCellClass(this, cells[i]);
20677 for(; i < 42; i++) {
20678 textEls[i].innerHTML = (++extraDays);
20679 d.setDate(d.getDate()+1);
20681 cells[i].className = "fc-future fc-other-month";
20682 setCellClass(this, cells[i]);
20685 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
20687 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
20689 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
20690 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
20692 if(totalRows != 6){
20693 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
20694 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
20697 this.fireEvent('monthchange', this, date);
20701 if(!this.internalRender){
20702 var main = this.el.dom.firstChild;
20703 var w = main.offsetWidth;
20704 this.el.setWidth(w + this.el.getBorderWidth("lr"));
20705 Roo.fly(main).setWidth(w);
20706 this.internalRender = true;
20707 // opera does not respect the auto grow header center column
20708 // then, after it gets a width opera refuses to recalculate
20709 // without a second pass
20710 if(Roo.isOpera && !this.secondPass){
20711 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
20712 this.secondPass = true;
20713 this.update.defer(10, this, [date]);
20720 findCell : function(dt) {
20721 dt = dt.clearTime().getTime();
20723 this.cells.each(function(c){
20724 //Roo.log("check " +c.dateValue + '?=' + dt);
20725 if(c.dateValue == dt){
20735 findCells : function(ev) {
20736 var s = ev.start.clone().clearTime().getTime();
20738 var e= ev.end.clone().clearTime().getTime();
20741 this.cells.each(function(c){
20742 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
20744 if(c.dateValue > e){
20747 if(c.dateValue < s){
20756 // findBestRow: function(cells)
20760 // for (var i =0 ; i < cells.length;i++) {
20761 // ret = Math.max(cells[i].rows || 0,ret);
20768 addItem : function(ev)
20770 // look for vertical location slot in
20771 var cells = this.findCells(ev);
20773 // ev.row = this.findBestRow(cells);
20775 // work out the location.
20779 for(var i =0; i < cells.length; i++) {
20781 cells[i].row = cells[0].row;
20784 cells[i].row = cells[i].row + 1;
20794 if (crow.start.getY() == cells[i].getY()) {
20796 crow.end = cells[i];
20813 cells[0].events.push(ev);
20815 this.calevents.push(ev);
20818 clearEvents: function() {
20820 if(!this.calevents){
20824 Roo.each(this.cells.elements, function(c){
20830 Roo.each(this.calevents, function(e) {
20831 Roo.each(e.els, function(el) {
20832 el.un('mouseenter' ,this.onEventEnter, this);
20833 el.un('mouseleave' ,this.onEventLeave, this);
20838 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
20844 renderEvents: function()
20848 this.cells.each(function(c) {
20857 if(c.row != c.events.length){
20858 r = 4 - (4 - (c.row - c.events.length));
20861 c.events = ev.slice(0, r);
20862 c.more = ev.slice(r);
20864 if(c.more.length && c.more.length == 1){
20865 c.events.push(c.more.pop());
20868 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
20872 this.cells.each(function(c) {
20874 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
20877 for (var e = 0; e < c.events.length; e++){
20878 var ev = c.events[e];
20879 var rows = ev.rows;
20881 for(var i = 0; i < rows.length; i++) {
20883 // how many rows should it span..
20886 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
20887 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
20889 unselectable : "on",
20892 cls: 'fc-event-inner',
20896 // cls: 'fc-event-time',
20897 // html : cells.length > 1 ? '' : ev.time
20901 cls: 'fc-event-title',
20902 html : String.format('{0}', ev.title)
20909 cls: 'ui-resizable-handle ui-resizable-e',
20910 html : '  '
20917 cfg.cls += ' fc-event-start';
20919 if ((i+1) == rows.length) {
20920 cfg.cls += ' fc-event-end';
20923 var ctr = _this.el.select('.fc-event-container',true).first();
20924 var cg = ctr.createChild(cfg);
20926 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
20927 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
20929 var r = (c.more.length) ? 1 : 0;
20930 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
20931 cg.setWidth(ebox.right - sbox.x -2);
20933 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
20934 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
20935 cg.on('click', _this.onEventClick, _this, ev);
20946 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
20947 style : 'position: absolute',
20948 unselectable : "on",
20951 cls: 'fc-event-inner',
20955 cls: 'fc-event-title',
20963 cls: 'ui-resizable-handle ui-resizable-e',
20964 html : '  '
20970 var ctr = _this.el.select('.fc-event-container',true).first();
20971 var cg = ctr.createChild(cfg);
20973 var sbox = c.select('.fc-day-content',true).first().getBox();
20974 var ebox = c.select('.fc-day-content',true).first().getBox();
20976 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
20977 cg.setWidth(ebox.right - sbox.x -2);
20979 cg.on('click', _this.onMoreEventClick, _this, c.more);
20989 onEventEnter: function (e, el,event,d) {
20990 this.fireEvent('evententer', this, el, event);
20993 onEventLeave: function (e, el,event,d) {
20994 this.fireEvent('eventleave', this, el, event);
20997 onEventClick: function (e, el,event,d) {
20998 this.fireEvent('eventclick', this, el, event);
21001 onMonthChange: function () {
21005 onMoreEventClick: function(e, el, more)
21009 this.calpopover.placement = 'right';
21010 this.calpopover.setTitle('More');
21012 this.calpopover.setContent('');
21014 var ctr = this.calpopover.el.select('.popover-content', true).first();
21016 Roo.each(more, function(m){
21018 cls : 'fc-event-hori fc-event-draggable',
21021 var cg = ctr.createChild(cfg);
21023 cg.on('click', _this.onEventClick, _this, m);
21026 this.calpopover.show(el);
21031 onLoad: function ()
21033 this.calevents = [];
21036 if(this.store.getCount() > 0){
21037 this.store.data.each(function(d){
21040 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
21041 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
21042 time : d.data.start_time,
21043 title : d.data.title,
21044 description : d.data.description,
21045 venue : d.data.venue
21050 this.renderEvents();
21052 if(this.calevents.length && this.loadMask){
21053 this.maskEl.hide();
21057 onBeforeLoad: function()
21059 this.clearEvents();
21061 this.maskEl.show();
21075 * @class Roo.bootstrap.Popover
21076 * @extends Roo.bootstrap.Component
21078 * Bootstrap Popover class
21079 * @cfg {String} html contents of the popover (or false to use children..)
21080 * @cfg {String} title of popover (or false to hide)
21081 * @cfg {String|function} (right|top|bottom|left|auto) placement how it is placed
21082 * @cfg {String} trigger click || hover (or false to trigger manually)
21083 * @cfg {Boolean} modal - popovers that are modal will mask the screen, and must be closed with another event.
21084 * @cfg {String|Boolean|Roo.Element} add click hander to trigger show over what element
21085 * - if false and it has a 'parent' then it will be automatically added to that element
21086 * - if string - Roo.get will be called
21087 * @cfg {Number} delay - delay before showing
21090 * Create a new Popover
21091 * @param {Object} config The config object
21094 Roo.bootstrap.Popover = function(config){
21095 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
21101 * After the popover show
21103 * @param {Roo.bootstrap.Popover} this
21108 * After the popover hide
21110 * @param {Roo.bootstrap.Popover} this
21116 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
21121 placement : 'right',
21122 trigger : 'hover', // hover
21128 can_build_overlaid : false,
21130 maskEl : false, // the mask element
21133 alignEl : false, // when show is called with an element - this get's stored.
21135 getChildContainer : function()
21137 return this.contentEl;
21140 getPopoverHeader : function()
21142 this.title = true; // flag not to hide it..
21143 this.headerEl.addClass('p-0');
21144 return this.headerEl
21148 getAutoCreate : function(){
21151 cls : 'popover roo-dynamic shadow roo-popover' + (this.modal ? '-modal' : ''),
21152 style: 'display:block',
21158 cls : 'popover-inner ',
21162 cls: 'popover-title popover-header',
21163 html : this.title === false ? '' : this.title
21166 cls : 'popover-content popover-body ' + (this.cls || ''),
21167 html : this.html || ''
21178 * @param {string} the title
21180 setTitle: function(str)
21184 this.headerEl.dom.innerHTML = str;
21189 * @param {string} the body content
21191 setContent: function(str)
21194 if (this.contentEl) {
21195 this.contentEl.dom.innerHTML = str;
21199 // as it get's added to the bottom of the page.
21200 onRender : function(ct, position)
21202 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
21207 var cfg = Roo.apply({}, this.getAutoCreate());
21211 cfg.cls += ' ' + this.cls;
21214 cfg.style = this.style;
21216 //Roo.log("adding to ");
21217 this.el = Roo.get(document.body).createChild(cfg, position);
21218 // Roo.log(this.el);
21221 this.contentEl = this.el.select('.popover-content',true).first();
21222 this.headerEl = this.el.select('.popover-title',true).first();
21225 if(typeof(this.items) != 'undefined'){
21226 var items = this.items;
21229 for(var i =0;i < items.length;i++) {
21230 nitems.push(this.addxtype(Roo.apply({}, items[i])));
21234 this.items = nitems;
21236 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
21237 Roo.EventManager.onWindowResize(this.resizeMask, this, true);
21244 resizeMask : function()
21246 this.maskEl.setSize(
21247 Roo.lib.Dom.getViewWidth(true),
21248 Roo.lib.Dom.getViewHeight(true)
21252 initEvents : function()
21256 Roo.bootstrap.Popover.register(this);
21259 this.arrowEl = this.el.select('.arrow',true).first();
21260 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY); // probably not needed as it's default in BS4
21261 this.el.enableDisplayMode('block');
21265 if (this.over === false && !this.parent()) {
21268 if (this.triggers === false) {
21273 var on_el = (this.over == 'parent' || this.over === false) ? this.parent().el : Roo.get(this.over);
21274 var triggers = this.trigger ? this.trigger.split(' ') : [];
21275 Roo.each(triggers, function(trigger) {
21277 if (trigger == 'click') {
21278 on_el.on('click', this.toggle, this);
21279 } else if (trigger != 'manual') {
21280 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
21281 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
21283 on_el.on(eventIn ,this.enter, this);
21284 on_el.on(eventOut, this.leave, this);
21294 toggle : function () {
21295 this.hoverState == 'in' ? this.leave() : this.enter();
21298 enter : function () {
21300 clearTimeout(this.timeout);
21302 this.hoverState = 'in';
21304 if (!this.delay || !this.delay.show) {
21309 this.timeout = setTimeout(function () {
21310 if (_t.hoverState == 'in') {
21313 }, this.delay.show)
21316 leave : function() {
21317 clearTimeout(this.timeout);
21319 this.hoverState = 'out';
21321 if (!this.delay || !this.delay.hide) {
21326 this.timeout = setTimeout(function () {
21327 if (_t.hoverState == 'out') {
21330 }, this.delay.hide)
21334 * @param {Roo.Element|string|Boolean} - element to align and point to. (set align to [ pos, offset ])
21335 * @param {string} (left|right|top|bottom) position
21337 show : function (on_el, placement)
21339 this.placement = typeof(placement) == 'undefined' ? this.placement : placement;
21340 on_el = on_el || false; // default to false
21343 if (this.parent() && (this.over == 'parent' || (this.over === false))) {
21344 on_el = this.parent().el;
21345 } else if (this.over) {
21346 on_el = Roo.get(this.over);
21351 this.alignEl = Roo.get( on_el );
21354 this.render(document.body);
21360 if (this.title === false) {
21361 this.headerEl.hide();
21366 this.el.dom.style.display = 'block';
21369 if (this.alignEl) {
21370 this.updatePosition(this.placement, true);
21373 // this is usually just done by the builder = to show the popoup in the middle of the scren.
21374 var es = this.el.getSize();
21375 var x = Roo.lib.Dom.getViewWidth()/2;
21376 var y = Roo.lib.Dom.getViewHeight()/2;
21377 this.el.setXY([ x-(es.width/2), y-(es.height/2)] );
21382 //var arrow = this.el.select('.arrow',true).first();
21383 //arrow.set(align[2],
21385 this.el.addClass('in');
21389 this.hoverState = 'in';
21392 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
21393 this.maskEl.setStyle('z-index', Roo.bootstrap.Popover.zIndex++);
21394 this.maskEl.dom.style.display = 'block';
21395 this.maskEl.addClass('show');
21397 this.el.setStyle('z-index', Roo.bootstrap.Popover.zIndex++);
21399 this.fireEvent('show', this);
21403 * fire this manually after loading a grid in the table for example
21404 * @param {string} (left|right|top|bottom) where to try and put it (use false to use the last one)
21405 * @param {Boolean} try and move it if we cant get right position.
21407 updatePosition : function(placement, try_move)
21409 // allow for calling with no parameters
21410 placement = placement ? placement : this.placement;
21411 try_move = typeof(try_move) == 'undefined' ? true : try_move;
21413 this.el.removeClass([
21414 'fade','top','bottom', 'left', 'right','in',
21415 'bs-popover-top','bs-popover-bottom', 'bs-popover-left', 'bs-popover-right'
21417 this.el.addClass(placement + ' bs-popover-' + placement);
21419 if (!this.alignEl ) {
21423 switch (placement) {
21425 var exact = this.el.getAlignToXY(this.alignEl, 'tl-tr', [10,0]);
21426 var offset = this.el.getAlignToXY(this.alignEl, 'tl-tr?',[10,0]);
21427 if (!try_move || exact.equals(offset) || exact[0] == offset[0] ) {
21428 //normal display... or moved up/down.
21429 this.el.setXY(offset);
21430 var xy = this.alignEl.getAnchorXY('tr', false);
21432 this.arrowEl.setXY(xy);
21435 // continue through...
21436 return this.updatePosition('left', false);
21440 var exact = this.el.getAlignToXY(this.alignEl, 'tr-tl', [-10,0]);
21441 var offset = this.el.getAlignToXY(this.alignEl, 'tr-tl?',[-10,0]);
21442 if (!try_move || exact.equals(offset) || exact[0] == offset[0] ) {
21443 //normal display... or moved up/down.
21444 this.el.setXY(offset);
21445 var xy = this.alignEl.getAnchorXY('tl', false);
21446 xy[0]-=10;xy[1]+=5; // << fix me
21447 this.arrowEl.setXY(xy);
21451 return this.updatePosition('right', false);
21454 var exact = this.el.getAlignToXY(this.alignEl, 'b-t', [0,-10]);
21455 var offset = this.el.getAlignToXY(this.alignEl, 'b-t?',[0,-10]);
21456 if (!try_move || exact.equals(offset) || exact[1] == offset[1] ) {
21457 //normal display... or moved up/down.
21458 this.el.setXY(offset);
21459 var xy = this.alignEl.getAnchorXY('t', false);
21460 xy[1]-=10; // << fix me
21461 this.arrowEl.setXY(xy);
21465 return this.updatePosition('bottom', false);
21468 var exact = this.el.getAlignToXY(this.alignEl, 't-b', [0,10]);
21469 var offset = this.el.getAlignToXY(this.alignEl, 't-b?',[0,10]);
21470 if (!try_move || exact.equals(offset) || exact[1] == offset[1] ) {
21471 //normal display... or moved up/down.
21472 this.el.setXY(offset);
21473 var xy = this.alignEl.getAnchorXY('b', false);
21474 xy[1]+=2; // << fix me
21475 this.arrowEl.setXY(xy);
21479 return this.updatePosition('top', false);
21490 this.el.setXY([0,0]);
21491 this.el.removeClass('in');
21493 this.hoverState = null;
21494 this.maskEl.hide(); // always..
21495 this.fireEvent('hide', this);
21501 Roo.apply(Roo.bootstrap.Popover, {
21504 'left' : ['r-l', [-10,0], 'left bs-popover-left'],
21505 'right' : ['l-br', [10,0], 'right bs-popover-right'],
21506 'bottom' : ['t-b', [0,10], 'top bs-popover-top'],
21507 'top' : [ 'b-t', [0,-10], 'bottom bs-popover-bottom']
21512 clickHander : false,
21516 onMouseDown : function(e)
21518 if (this.popups.length && !e.getTarget(".roo-popover")) {
21519 /// what is nothing is showing..
21528 register : function(popup)
21530 if (!Roo.bootstrap.Popover.clickHandler) {
21531 Roo.bootstrap.Popover.clickHandler = Roo.get(document).on("mousedown", Roo.bootstrap.Popover.onMouseDown, Roo.bootstrap.Popover);
21533 // hide other popups.
21534 popup.on('show', Roo.bootstrap.Popover.onShow, popup);
21535 popup.on('hide', Roo.bootstrap.Popover.onHide, popup);
21536 this.hideAll(); //<< why?
21537 //this.popups.push(popup);
21539 hideAll : function()
21541 this.popups.forEach(function(p) {
21545 onShow : function() {
21546 Roo.bootstrap.Popover.popups.push(this);
21548 onHide : function() {
21549 Roo.bootstrap.Popover.popups.remove(this);
21555 * Card header - holder for the card header elements.
21560 * @class Roo.bootstrap.PopoverNav
21561 * @extends Roo.bootstrap.NavGroup
21562 * Bootstrap Popover header navigation class
21564 * Create a new Popover Header Navigation
21565 * @param {Object} config The config object
21568 Roo.bootstrap.PopoverNav = function(config){
21569 Roo.bootstrap.PopoverNav.superclass.constructor.call(this, config);
21572 Roo.extend(Roo.bootstrap.PopoverNav, Roo.bootstrap.NavSimplebar, {
21575 container_method : 'getPopoverHeader'
21593 * @class Roo.bootstrap.Progress
21594 * @extends Roo.bootstrap.Component
21595 * Bootstrap Progress class
21596 * @cfg {Boolean} striped striped of the progress bar
21597 * @cfg {Boolean} active animated of the progress bar
21601 * Create a new Progress
21602 * @param {Object} config The config object
21605 Roo.bootstrap.Progress = function(config){
21606 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
21609 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
21614 getAutoCreate : function(){
21622 cfg.cls += ' progress-striped';
21626 cfg.cls += ' active';
21645 * @class Roo.bootstrap.ProgressBar
21646 * @extends Roo.bootstrap.Component
21647 * Bootstrap ProgressBar class
21648 * @cfg {Number} aria_valuenow aria-value now
21649 * @cfg {Number} aria_valuemin aria-value min
21650 * @cfg {Number} aria_valuemax aria-value max
21651 * @cfg {String} label label for the progress bar
21652 * @cfg {String} panel (success | info | warning | danger )
21653 * @cfg {String} role role of the progress bar
21654 * @cfg {String} sr_only text
21658 * Create a new ProgressBar
21659 * @param {Object} config The config object
21662 Roo.bootstrap.ProgressBar = function(config){
21663 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
21666 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
21670 aria_valuemax : 100,
21676 getAutoCreate : function()
21681 cls: 'progress-bar',
21682 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
21694 cfg.role = this.role;
21697 if(this.aria_valuenow){
21698 cfg['aria-valuenow'] = this.aria_valuenow;
21701 if(this.aria_valuemin){
21702 cfg['aria-valuemin'] = this.aria_valuemin;
21705 if(this.aria_valuemax){
21706 cfg['aria-valuemax'] = this.aria_valuemax;
21709 if(this.label && !this.sr_only){
21710 cfg.html = this.label;
21714 cfg.cls += ' progress-bar-' + this.panel;
21720 update : function(aria_valuenow)
21722 this.aria_valuenow = aria_valuenow;
21724 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
21739 * @class Roo.bootstrap.TabGroup
21740 * @extends Roo.bootstrap.Column
21741 * Bootstrap Column class
21742 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
21743 * @cfg {Boolean} carousel true to make the group behave like a carousel
21744 * @cfg {Boolean} bullets show bullets for the panels
21745 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
21746 * @cfg {Number} timer auto slide timer .. default 0 millisecond
21747 * @cfg {Boolean} showarrow (true|false) show arrow default true
21750 * Create a new TabGroup
21751 * @param {Object} config The config object
21754 Roo.bootstrap.TabGroup = function(config){
21755 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
21757 this.navId = Roo.id();
21760 Roo.bootstrap.TabGroup.register(this);
21764 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
21767 transition : false,
21772 slideOnTouch : false,
21775 getAutoCreate : function()
21777 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
21779 cfg.cls += ' tab-content';
21781 if (this.carousel) {
21782 cfg.cls += ' carousel slide';
21785 cls : 'carousel-inner',
21789 if(this.bullets && !Roo.isTouch){
21792 cls : 'carousel-bullets',
21796 if(this.bullets_cls){
21797 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
21804 cfg.cn[0].cn.push(bullets);
21807 if(this.showarrow){
21808 cfg.cn[0].cn.push({
21810 class : 'carousel-arrow',
21814 class : 'carousel-prev',
21818 class : 'fa fa-chevron-left'
21824 class : 'carousel-next',
21828 class : 'fa fa-chevron-right'
21841 initEvents: function()
21843 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
21844 // this.el.on("touchstart", this.onTouchStart, this);
21847 if(this.autoslide){
21850 this.slideFn = window.setInterval(function() {
21851 _this.showPanelNext();
21855 if(this.showarrow){
21856 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
21857 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
21863 // onTouchStart : function(e, el, o)
21865 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
21869 // this.showPanelNext();
21873 getChildContainer : function()
21875 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
21879 * register a Navigation item
21880 * @param {Roo.bootstrap.NavItem} the navitem to add
21882 register : function(item)
21884 this.tabs.push( item);
21885 item.navId = this.navId; // not really needed..
21890 getActivePanel : function()
21893 Roo.each(this.tabs, function(t) {
21903 getPanelByName : function(n)
21906 Roo.each(this.tabs, function(t) {
21907 if (t.tabId == n) {
21915 indexOfPanel : function(p)
21918 Roo.each(this.tabs, function(t,i) {
21919 if (t.tabId == p.tabId) {
21928 * show a specific panel
21929 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
21930 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
21932 showPanel : function (pan)
21934 if(this.transition || typeof(pan) == 'undefined'){
21935 Roo.log("waiting for the transitionend");
21939 if (typeof(pan) == 'number') {
21940 pan = this.tabs[pan];
21943 if (typeof(pan) == 'string') {
21944 pan = this.getPanelByName(pan);
21947 var cur = this.getActivePanel();
21950 Roo.log('pan or acitve pan is undefined');
21954 if (pan.tabId == this.getActivePanel().tabId) {
21958 if (false === cur.fireEvent('beforedeactivate')) {
21962 if(this.bullets > 0 && !Roo.isTouch){
21963 this.setActiveBullet(this.indexOfPanel(pan));
21966 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
21968 //class="carousel-item carousel-item-next carousel-item-left"
21970 this.transition = true;
21971 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
21972 var lr = dir == 'next' ? 'left' : 'right';
21973 pan.el.addClass(dir); // or prev
21974 pan.el.addClass('carousel-item-' + dir); // or prev
21975 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
21976 cur.el.addClass(lr); // or right
21977 pan.el.addClass(lr);
21978 cur.el.addClass('carousel-item-' +lr); // or right
21979 pan.el.addClass('carousel-item-' +lr);
21983 cur.el.on('transitionend', function() {
21984 Roo.log("trans end?");
21986 pan.el.removeClass([lr,dir, 'carousel-item-' + lr, 'carousel-item-' + dir]);
21987 pan.setActive(true);
21989 cur.el.removeClass([lr, 'carousel-item-' + lr]);
21990 cur.setActive(false);
21992 _this.transition = false;
21994 }, this, { single: true } );
21999 cur.setActive(false);
22000 pan.setActive(true);
22005 showPanelNext : function()
22007 var i = this.indexOfPanel(this.getActivePanel());
22009 if (i >= this.tabs.length - 1 && !this.autoslide) {
22013 if (i >= this.tabs.length - 1 && this.autoslide) {
22017 this.showPanel(this.tabs[i+1]);
22020 showPanelPrev : function()
22022 var i = this.indexOfPanel(this.getActivePanel());
22024 if (i < 1 && !this.autoslide) {
22028 if (i < 1 && this.autoslide) {
22029 i = this.tabs.length;
22032 this.showPanel(this.tabs[i-1]);
22036 addBullet: function()
22038 if(!this.bullets || Roo.isTouch){
22041 var ctr = this.el.select('.carousel-bullets',true).first();
22042 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
22043 var bullet = ctr.createChild({
22044 cls : 'bullet bullet-' + i
22045 },ctr.dom.lastChild);
22050 bullet.on('click', (function(e, el, o, ii, t){
22052 e.preventDefault();
22054 this.showPanel(ii);
22056 if(this.autoslide && this.slideFn){
22057 clearInterval(this.slideFn);
22058 this.slideFn = window.setInterval(function() {
22059 _this.showPanelNext();
22063 }).createDelegate(this, [i, bullet], true));
22068 setActiveBullet : function(i)
22074 Roo.each(this.el.select('.bullet', true).elements, function(el){
22075 el.removeClass('selected');
22078 var bullet = this.el.select('.bullet-' + i, true).first();
22084 bullet.addClass('selected');
22095 Roo.apply(Roo.bootstrap.TabGroup, {
22099 * register a Navigation Group
22100 * @param {Roo.bootstrap.NavGroup} the navgroup to add
22102 register : function(navgrp)
22104 this.groups[navgrp.navId] = navgrp;
22108 * fetch a Navigation Group based on the navigation ID
22109 * if one does not exist , it will get created.
22110 * @param {string} the navgroup to add
22111 * @returns {Roo.bootstrap.NavGroup} the navgroup
22113 get: function(navId) {
22114 if (typeof(this.groups[navId]) == 'undefined') {
22115 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
22117 return this.groups[navId] ;
22132 * @class Roo.bootstrap.TabPanel
22133 * @extends Roo.bootstrap.Component
22134 * @children Roo.bootstrap.Component
22135 * Bootstrap TabPanel class
22136 * @cfg {Boolean} active panel active
22137 * @cfg {String} html panel content
22138 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
22139 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
22140 * @cfg {String} href click to link..
22141 * @cfg {Boolean} touchSlide if swiping slides tab to next panel (default off)
22145 * Create a new TabPanel
22146 * @param {Object} config The config object
22149 Roo.bootstrap.TabPanel = function(config){
22150 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
22154 * Fires when the active status changes
22155 * @param {Roo.bootstrap.TabPanel} this
22156 * @param {Boolean} state the new state
22161 * @event beforedeactivate
22162 * Fires before a tab is de-activated - can be used to do validation on a form.
22163 * @param {Roo.bootstrap.TabPanel} this
22164 * @return {Boolean} false if there is an error
22167 'beforedeactivate': true
22170 this.tabId = this.tabId || Roo.id();
22174 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
22181 touchSlide : false,
22182 getAutoCreate : function(){
22187 // item is needed for carousel - not sure if it has any effect otherwise
22188 cls: 'carousel-item tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
22189 html: this.html || ''
22193 cfg.cls += ' active';
22197 cfg.tabId = this.tabId;
22205 initEvents: function()
22207 var p = this.parent();
22209 this.navId = this.navId || p.navId;
22211 if (typeof(this.navId) != 'undefined') {
22212 // not really needed.. but just in case.. parent should be a NavGroup.
22213 var tg = Roo.bootstrap.TabGroup.get(this.navId);
22217 var i = tg.tabs.length - 1;
22219 if(this.active && tg.bullets > 0 && i < tg.bullets){
22220 tg.setActiveBullet(i);
22224 this.el.on('click', this.onClick, this);
22226 if(Roo.isTouch && this.touchSlide){
22227 this.el.on("touchstart", this.onTouchStart, this);
22228 this.el.on("touchmove", this.onTouchMove, this);
22229 this.el.on("touchend", this.onTouchEnd, this);
22234 onRender : function(ct, position)
22236 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
22239 setActive : function(state)
22241 Roo.log("panel - set active " + this.tabId + "=" + state);
22243 this.active = state;
22245 this.el.removeClass('active');
22247 } else if (!this.el.hasClass('active')) {
22248 this.el.addClass('active');
22251 this.fireEvent('changed', this, state);
22254 onClick : function(e)
22256 e.preventDefault();
22258 if(!this.href.length){
22262 window.location.href = this.href;
22271 onTouchStart : function(e)
22273 this.swiping = false;
22275 this.startX = e.browserEvent.touches[0].clientX;
22276 this.startY = e.browserEvent.touches[0].clientY;
22279 onTouchMove : function(e)
22281 this.swiping = true;
22283 this.endX = e.browserEvent.touches[0].clientX;
22284 this.endY = e.browserEvent.touches[0].clientY;
22287 onTouchEnd : function(e)
22294 var tabGroup = this.parent();
22296 if(this.endX > this.startX){ // swiping right
22297 tabGroup.showPanelPrev();
22301 if(this.startX > this.endX){ // swiping left
22302 tabGroup.showPanelNext();
22321 * @class Roo.bootstrap.DateField
22322 * @extends Roo.bootstrap.Input
22323 * Bootstrap DateField class
22324 * @cfg {Number} weekStart default 0
22325 * @cfg {String} viewMode default empty, (months|years)
22326 * @cfg {String} minViewMode default empty, (months|years)
22327 * @cfg {Number} startDate default -Infinity
22328 * @cfg {Number} endDate default Infinity
22329 * @cfg {Boolean} todayHighlight default false
22330 * @cfg {Boolean} todayBtn default false
22331 * @cfg {Boolean} calendarWeeks default false
22332 * @cfg {Object} daysOfWeekDisabled default empty
22333 * @cfg {Boolean} singleMode default false (true | false)
22335 * @cfg {Boolean} keyboardNavigation default true
22336 * @cfg {String} language default en
22339 * Create a new DateField
22340 * @param {Object} config The config object
22343 Roo.bootstrap.DateField = function(config){
22344 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
22348 * Fires when this field show.
22349 * @param {Roo.bootstrap.DateField} this
22350 * @param {Mixed} date The date value
22355 * Fires when this field hide.
22356 * @param {Roo.bootstrap.DateField} this
22357 * @param {Mixed} date The date value
22362 * Fires when select a date.
22363 * @param {Roo.bootstrap.DateField} this
22364 * @param {Mixed} date The date value
22368 * @event beforeselect
22369 * Fires when before select a date.
22370 * @param {Roo.bootstrap.DateField} this
22371 * @param {Mixed} date The date value
22373 beforeselect : true
22377 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
22380 * @cfg {String} format
22381 * The default date format string which can be overriden for localization support. The format must be
22382 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
22386 * @cfg {String} altFormats
22387 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
22388 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
22390 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
22398 todayHighlight : false,
22404 keyboardNavigation: true,
22406 calendarWeeks: false,
22408 startDate: -Infinity,
22412 daysOfWeekDisabled: [],
22416 singleMode : false,
22418 UTCDate: function()
22420 return new Date(Date.UTC.apply(Date, arguments));
22423 UTCToday: function()
22425 var today = new Date();
22426 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
22429 getDate: function() {
22430 var d = this.getUTCDate();
22431 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
22434 getUTCDate: function() {
22438 setDate: function(d) {
22439 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
22442 setUTCDate: function(d) {
22444 this.setValue(this.formatDate(this.date));
22447 onRender: function(ct, position)
22450 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
22452 this.language = this.language || 'en';
22453 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
22454 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
22456 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
22457 this.format = this.format || 'm/d/y';
22458 this.isInline = false;
22459 this.isInput = true;
22460 this.component = this.el.select('.add-on', true).first() || false;
22461 this.component = (this.component && this.component.length === 0) ? false : this.component;
22462 this.hasInput = this.component && this.inputEl().length;
22464 if (typeof(this.minViewMode === 'string')) {
22465 switch (this.minViewMode) {
22467 this.minViewMode = 1;
22470 this.minViewMode = 2;
22473 this.minViewMode = 0;
22478 if (typeof(this.viewMode === 'string')) {
22479 switch (this.viewMode) {
22492 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
22494 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
22496 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
22498 this.picker().on('mousedown', this.onMousedown, this);
22499 this.picker().on('click', this.onClick, this);
22501 this.picker().addClass('datepicker-dropdown');
22503 this.startViewMode = this.viewMode;
22505 if(this.singleMode){
22506 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
22507 v.setVisibilityMode(Roo.Element.DISPLAY);
22511 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
22512 v.setStyle('width', '189px');
22516 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
22517 if(!this.calendarWeeks){
22522 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
22523 v.attr('colspan', function(i, val){
22524 return parseInt(val) + 1;
22529 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
22531 this.setStartDate(this.startDate);
22532 this.setEndDate(this.endDate);
22534 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
22541 if(this.isInline) {
22546 picker : function()
22548 return this.pickerEl;
22549 // return this.el.select('.datepicker', true).first();
22552 fillDow: function()
22554 var dowCnt = this.weekStart;
22563 if(this.calendarWeeks){
22571 while (dowCnt < this.weekStart + 7) {
22575 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
22579 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
22582 fillMonths: function()
22585 var months = this.picker().select('>.datepicker-months td', true).first();
22587 months.dom.innerHTML = '';
22593 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
22596 months.createChild(month);
22603 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;
22605 if (this.date < this.startDate) {
22606 this.viewDate = new Date(this.startDate);
22607 } else if (this.date > this.endDate) {
22608 this.viewDate = new Date(this.endDate);
22610 this.viewDate = new Date(this.date);
22618 var d = new Date(this.viewDate),
22619 year = d.getUTCFullYear(),
22620 month = d.getUTCMonth(),
22621 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
22622 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
22623 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
22624 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
22625 currentDate = this.date && this.date.valueOf(),
22626 today = this.UTCToday();
22628 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
22630 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
22632 // this.picker.select('>tfoot th.today').
22633 // .text(dates[this.language].today)
22634 // .toggle(this.todayBtn !== false);
22636 this.updateNavArrows();
22639 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
22641 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
22643 prevMonth.setUTCDate(day);
22645 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
22647 var nextMonth = new Date(prevMonth);
22649 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
22651 nextMonth = nextMonth.valueOf();
22653 var fillMonths = false;
22655 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
22657 while(prevMonth.valueOf() <= nextMonth) {
22660 if (prevMonth.getUTCDay() === this.weekStart) {
22662 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
22670 if(this.calendarWeeks){
22671 // ISO 8601: First week contains first thursday.
22672 // ISO also states week starts on Monday, but we can be more abstract here.
22674 // Start of current week: based on weekstart/current date
22675 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
22676 // Thursday of this week
22677 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
22678 // First Thursday of year, year from thursday
22679 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
22680 // Calendar week: ms between thursdays, div ms per day, div 7 days
22681 calWeek = (th - yth) / 864e5 / 7 + 1;
22683 fillMonths.cn.push({
22691 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
22693 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
22696 if (this.todayHighlight &&
22697 prevMonth.getUTCFullYear() == today.getFullYear() &&
22698 prevMonth.getUTCMonth() == today.getMonth() &&
22699 prevMonth.getUTCDate() == today.getDate()) {
22700 clsName += ' today';
22703 if (currentDate && prevMonth.valueOf() === currentDate) {
22704 clsName += ' active';
22707 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
22708 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
22709 clsName += ' disabled';
22712 fillMonths.cn.push({
22714 cls: 'day ' + clsName,
22715 html: prevMonth.getDate()
22718 prevMonth.setDate(prevMonth.getDate()+1);
22721 var currentYear = this.date && this.date.getUTCFullYear();
22722 var currentMonth = this.date && this.date.getUTCMonth();
22724 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
22726 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
22727 v.removeClass('active');
22729 if(currentYear === year && k === currentMonth){
22730 v.addClass('active');
22733 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
22734 v.addClass('disabled');
22740 year = parseInt(year/10, 10) * 10;
22742 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
22744 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
22747 for (var i = -1; i < 11; i++) {
22748 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
22750 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
22758 showMode: function(dir)
22761 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
22764 Roo.each(this.picker().select('>div',true).elements, function(v){
22765 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
22768 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
22773 if(this.isInline) {
22777 this.picker().removeClass(['bottom', 'top']);
22779 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
22781 * place to the top of element!
22785 this.picker().addClass('top');
22786 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
22791 this.picker().addClass('bottom');
22793 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
22796 parseDate : function(value)
22798 if(!value || value instanceof Date){
22801 var v = Date.parseDate(value, this.format);
22802 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
22803 v = Date.parseDate(value, 'Y-m-d');
22805 if(!v && this.altFormats){
22806 if(!this.altFormatsArray){
22807 this.altFormatsArray = this.altFormats.split("|");
22809 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
22810 v = Date.parseDate(value, this.altFormatsArray[i]);
22816 formatDate : function(date, fmt)
22818 return (!date || !(date instanceof Date)) ?
22819 date : date.dateFormat(fmt || this.format);
22822 onFocus : function()
22824 Roo.bootstrap.DateField.superclass.onFocus.call(this);
22828 onBlur : function()
22830 Roo.bootstrap.DateField.superclass.onBlur.call(this);
22832 var d = this.inputEl().getValue();
22839 showPopup : function()
22841 this.picker().show();
22845 this.fireEvent('showpopup', this, this.date);
22848 hidePopup : function()
22850 if(this.isInline) {
22853 this.picker().hide();
22854 this.viewMode = this.startViewMode;
22857 this.fireEvent('hidepopup', this, this.date);
22861 onMousedown: function(e)
22863 e.stopPropagation();
22864 e.preventDefault();
22869 Roo.bootstrap.DateField.superclass.keyup.call(this);
22873 setValue: function(v)
22875 if(this.fireEvent('beforeselect', this, v) !== false){
22876 var d = new Date(this.parseDate(v) ).clearTime();
22878 if(isNaN(d.getTime())){
22879 this.date = this.viewDate = '';
22880 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
22884 v = this.formatDate(d);
22886 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
22888 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
22892 this.fireEvent('select', this, this.date);
22896 getValue: function()
22898 return this.formatDate(this.date);
22901 fireKey: function(e)
22903 if (!this.picker().isVisible()){
22904 if (e.keyCode == 27) { // allow escape to hide and re-show picker
22910 var dateChanged = false,
22912 newDate, newViewDate;
22917 e.preventDefault();
22921 if (!this.keyboardNavigation) {
22924 dir = e.keyCode == 37 ? -1 : 1;
22927 newDate = this.moveYear(this.date, dir);
22928 newViewDate = this.moveYear(this.viewDate, dir);
22929 } else if (e.shiftKey){
22930 newDate = this.moveMonth(this.date, dir);
22931 newViewDate = this.moveMonth(this.viewDate, dir);
22933 newDate = new Date(this.date);
22934 newDate.setUTCDate(this.date.getUTCDate() + dir);
22935 newViewDate = new Date(this.viewDate);
22936 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
22938 if (this.dateWithinRange(newDate)){
22939 this.date = newDate;
22940 this.viewDate = newViewDate;
22941 this.setValue(this.formatDate(this.date));
22943 e.preventDefault();
22944 dateChanged = true;
22949 if (!this.keyboardNavigation) {
22952 dir = e.keyCode == 38 ? -1 : 1;
22954 newDate = this.moveYear(this.date, dir);
22955 newViewDate = this.moveYear(this.viewDate, dir);
22956 } else if (e.shiftKey){
22957 newDate = this.moveMonth(this.date, dir);
22958 newViewDate = this.moveMonth(this.viewDate, dir);
22960 newDate = new Date(this.date);
22961 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
22962 newViewDate = new Date(this.viewDate);
22963 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
22965 if (this.dateWithinRange(newDate)){
22966 this.date = newDate;
22967 this.viewDate = newViewDate;
22968 this.setValue(this.formatDate(this.date));
22970 e.preventDefault();
22971 dateChanged = true;
22975 this.setValue(this.formatDate(this.date));
22977 e.preventDefault();
22980 this.setValue(this.formatDate(this.date));
22994 onClick: function(e)
22996 e.stopPropagation();
22997 e.preventDefault();
22999 var target = e.getTarget();
23001 if(target.nodeName.toLowerCase() === 'i'){
23002 target = Roo.get(target).dom.parentNode;
23005 var nodeName = target.nodeName;
23006 var className = target.className;
23007 var html = target.innerHTML;
23008 //Roo.log(nodeName);
23010 switch(nodeName.toLowerCase()) {
23012 switch(className) {
23018 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
23019 switch(this.viewMode){
23021 this.viewDate = this.moveMonth(this.viewDate, dir);
23025 this.viewDate = this.moveYear(this.viewDate, dir);
23031 var date = new Date();
23032 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
23034 this.setValue(this.formatDate(this.date));
23041 if (className.indexOf('disabled') < 0) {
23042 if (!this.viewDate) {
23043 this.viewDate = new Date();
23045 this.viewDate.setUTCDate(1);
23046 if (className.indexOf('month') > -1) {
23047 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
23049 var year = parseInt(html, 10) || 0;
23050 this.viewDate.setUTCFullYear(year);
23054 if(this.singleMode){
23055 this.setValue(this.formatDate(this.viewDate));
23066 //Roo.log(className);
23067 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
23068 var day = parseInt(html, 10) || 1;
23069 var year = (this.viewDate || new Date()).getUTCFullYear(),
23070 month = (this.viewDate || new Date()).getUTCMonth();
23072 if (className.indexOf('old') > -1) {
23079 } else if (className.indexOf('new') > -1) {
23087 //Roo.log([year,month,day]);
23088 this.date = this.UTCDate(year, month, day,0,0,0,0);
23089 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
23091 //Roo.log(this.formatDate(this.date));
23092 this.setValue(this.formatDate(this.date));
23099 setStartDate: function(startDate)
23101 this.startDate = startDate || -Infinity;
23102 if (this.startDate !== -Infinity) {
23103 this.startDate = this.parseDate(this.startDate);
23106 this.updateNavArrows();
23109 setEndDate: function(endDate)
23111 this.endDate = endDate || Infinity;
23112 if (this.endDate !== Infinity) {
23113 this.endDate = this.parseDate(this.endDate);
23116 this.updateNavArrows();
23119 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
23121 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
23122 if (typeof(this.daysOfWeekDisabled) !== 'object') {
23123 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
23125 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
23126 return parseInt(d, 10);
23129 this.updateNavArrows();
23132 updateNavArrows: function()
23134 if(this.singleMode){
23138 var d = new Date(this.viewDate),
23139 year = d.getUTCFullYear(),
23140 month = d.getUTCMonth();
23142 Roo.each(this.picker().select('.prev', true).elements, function(v){
23144 switch (this.viewMode) {
23147 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
23153 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
23160 Roo.each(this.picker().select('.next', true).elements, function(v){
23162 switch (this.viewMode) {
23165 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
23171 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
23179 moveMonth: function(date, dir)
23184 var new_date = new Date(date.valueOf()),
23185 day = new_date.getUTCDate(),
23186 month = new_date.getUTCMonth(),
23187 mag = Math.abs(dir),
23189 dir = dir > 0 ? 1 : -1;
23192 // If going back one month, make sure month is not current month
23193 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
23195 return new_date.getUTCMonth() == month;
23197 // If going forward one month, make sure month is as expected
23198 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
23200 return new_date.getUTCMonth() != new_month;
23202 new_month = month + dir;
23203 new_date.setUTCMonth(new_month);
23204 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
23205 if (new_month < 0 || new_month > 11) {
23206 new_month = (new_month + 12) % 12;
23209 // For magnitudes >1, move one month at a time...
23210 for (var i=0; i<mag; i++) {
23211 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
23212 new_date = this.moveMonth(new_date, dir);
23214 // ...then reset the day, keeping it in the new month
23215 new_month = new_date.getUTCMonth();
23216 new_date.setUTCDate(day);
23218 return new_month != new_date.getUTCMonth();
23221 // Common date-resetting loop -- if date is beyond end of month, make it
23224 new_date.setUTCDate(--day);
23225 new_date.setUTCMonth(new_month);
23230 moveYear: function(date, dir)
23232 return this.moveMonth(date, dir*12);
23235 dateWithinRange: function(date)
23237 return date >= this.startDate && date <= this.endDate;
23243 this.picker().remove();
23246 validateValue : function(value)
23248 if(this.getVisibilityEl().hasClass('hidden')){
23252 if(value.length < 1) {
23253 if(this.allowBlank){
23259 if(value.length < this.minLength){
23262 if(value.length > this.maxLength){
23266 var vt = Roo.form.VTypes;
23267 if(!vt[this.vtype](value, this)){
23271 if(typeof this.validator == "function"){
23272 var msg = this.validator(value);
23278 if(this.regex && !this.regex.test(value)){
23282 if(typeof(this.parseDate(value)) == 'undefined'){
23286 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
23290 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
23300 this.date = this.viewDate = '';
23302 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
23307 Roo.apply(Roo.bootstrap.DateField, {
23318 html: '<i class="fa fa-arrow-left"/>'
23328 html: '<i class="fa fa-arrow-right"/>'
23370 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
23371 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
23372 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
23373 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
23374 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
23387 navFnc: 'FullYear',
23392 navFnc: 'FullYear',
23397 Roo.apply(Roo.bootstrap.DateField, {
23401 cls: 'datepicker dropdown-menu roo-dynamic shadow',
23405 cls: 'datepicker-days',
23409 cls: 'table-condensed',
23411 Roo.bootstrap.DateField.head,
23415 Roo.bootstrap.DateField.footer
23422 cls: 'datepicker-months',
23426 cls: 'table-condensed',
23428 Roo.bootstrap.DateField.head,
23429 Roo.bootstrap.DateField.content,
23430 Roo.bootstrap.DateField.footer
23437 cls: 'datepicker-years',
23441 cls: 'table-condensed',
23443 Roo.bootstrap.DateField.head,
23444 Roo.bootstrap.DateField.content,
23445 Roo.bootstrap.DateField.footer
23464 * @class Roo.bootstrap.TimeField
23465 * @extends Roo.bootstrap.Input
23466 * Bootstrap DateField class
23470 * Create a new TimeField
23471 * @param {Object} config The config object
23474 Roo.bootstrap.TimeField = function(config){
23475 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
23479 * Fires when this field show.
23480 * @param {Roo.bootstrap.DateField} thisthis
23481 * @param {Mixed} date The date value
23486 * Fires when this field hide.
23487 * @param {Roo.bootstrap.DateField} this
23488 * @param {Mixed} date The date value
23493 * Fires when select a date.
23494 * @param {Roo.bootstrap.DateField} this
23495 * @param {Mixed} date The date value
23501 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
23504 * @cfg {String} format
23505 * The default time format string which can be overriden for localization support. The format must be
23506 * valid according to {@link Date#parseDate} (defaults to 'H:i').
23510 getAutoCreate : function()
23512 this.after = '<i class="fa far fa-clock"></i>';
23513 return Roo.bootstrap.TimeField.superclass.getAutoCreate.call(this);
23517 onRender: function(ct, position)
23520 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
23522 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.TimeField.template);
23524 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
23526 this.pop = this.picker().select('>.datepicker-time',true).first();
23527 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
23529 this.picker().on('mousedown', this.onMousedown, this);
23530 this.picker().on('click', this.onClick, this);
23532 this.picker().addClass('datepicker-dropdown');
23537 this.pop.select('.hours-up', true).first().on('click', this.onIncrementHours, this);
23538 this.pop.select('.hours-down', true).first().on('click', this.onDecrementHours, this);
23539 this.pop.select('.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
23540 this.pop.select('.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
23541 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
23542 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
23546 fireKey: function(e){
23547 if (!this.picker().isVisible()){
23548 if (e.keyCode == 27) { // allow escape to hide and re-show picker
23554 e.preventDefault();
23562 this.onTogglePeriod();
23565 this.onIncrementMinutes();
23568 this.onDecrementMinutes();
23577 onClick: function(e) {
23578 e.stopPropagation();
23579 e.preventDefault();
23582 picker : function()
23584 return this.pickerEl;
23587 fillTime: function()
23589 var time = this.pop.select('tbody', true).first();
23591 time.dom.innerHTML = '';
23606 cls: 'hours-up fa fas fa-chevron-up'
23626 cls: 'minutes-up fa fas fa-chevron-up'
23647 cls: 'timepicker-hour',
23662 cls: 'timepicker-minute',
23677 cls: 'btn btn-primary period',
23699 cls: 'hours-down fa fas fa-chevron-down'
23719 cls: 'minutes-down fa fas fa-chevron-down'
23737 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
23744 var hours = this.time.getHours();
23745 var minutes = this.time.getMinutes();
23758 hours = hours - 12;
23762 hours = '0' + hours;
23766 minutes = '0' + minutes;
23769 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
23770 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
23771 this.pop.select('button', true).first().dom.innerHTML = period;
23777 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
23779 var cls = ['bottom'];
23781 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
23788 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
23792 //this.picker().setXY(20000,20000);
23793 this.picker().addClass(cls.join('-'));
23797 Roo.each(cls, function(c){
23802 _this.picker().alignTo(_this.inputEl(), "tr-br", [0, 10], false);
23803 //_this.picker().setTop(_this.inputEl().getHeight());
23807 _this.picker().alignTo(_this.inputEl(), "br-tr", [0, 10], false);
23809 //_this.picker().setTop(0 - _this.picker().getHeight());
23814 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
23818 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
23826 onFocus : function()
23828 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
23832 onBlur : function()
23834 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
23840 this.picker().show();
23845 this.fireEvent('show', this, this.date);
23850 this.picker().hide();
23853 this.fireEvent('hide', this, this.date);
23856 setTime : function()
23859 this.setValue(this.time.format(this.format));
23861 this.fireEvent('select', this, this.date);
23866 onMousedown: function(e){
23867 e.stopPropagation();
23868 e.preventDefault();
23871 onIncrementHours: function()
23873 Roo.log('onIncrementHours');
23874 this.time = this.time.add(Date.HOUR, 1);
23879 onDecrementHours: function()
23881 Roo.log('onDecrementHours');
23882 this.time = this.time.add(Date.HOUR, -1);
23886 onIncrementMinutes: function()
23888 Roo.log('onIncrementMinutes');
23889 this.time = this.time.add(Date.MINUTE, 1);
23893 onDecrementMinutes: function()
23895 Roo.log('onDecrementMinutes');
23896 this.time = this.time.add(Date.MINUTE, -1);
23900 onTogglePeriod: function()
23902 Roo.log('onTogglePeriod');
23903 this.time = this.time.add(Date.HOUR, 12);
23911 Roo.apply(Roo.bootstrap.TimeField, {
23915 cls: 'datepicker dropdown-menu',
23919 cls: 'datepicker-time',
23923 cls: 'table-condensed',
23952 cls: 'btn btn-info ok',
23980 * @class Roo.bootstrap.MonthField
23981 * @extends Roo.bootstrap.Input
23982 * Bootstrap MonthField class
23984 * @cfg {String} language default en
23987 * Create a new MonthField
23988 * @param {Object} config The config object
23991 Roo.bootstrap.MonthField = function(config){
23992 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
23997 * Fires when this field show.
23998 * @param {Roo.bootstrap.MonthField} this
23999 * @param {Mixed} date The date value
24004 * Fires when this field hide.
24005 * @param {Roo.bootstrap.MonthField} this
24006 * @param {Mixed} date The date value
24011 * Fires when select a date.
24012 * @param {Roo.bootstrap.MonthField} this
24013 * @param {String} oldvalue The old value
24014 * @param {String} newvalue The new value
24020 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
24022 onRender: function(ct, position)
24025 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
24027 this.language = this.language || 'en';
24028 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
24029 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
24031 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
24032 this.isInline = false;
24033 this.isInput = true;
24034 this.component = this.el.select('.add-on', true).first() || false;
24035 this.component = (this.component && this.component.length === 0) ? false : this.component;
24036 this.hasInput = this.component && this.inputEL().length;
24038 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
24040 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
24042 this.picker().on('mousedown', this.onMousedown, this);
24043 this.picker().on('click', this.onClick, this);
24045 this.picker().addClass('datepicker-dropdown');
24047 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
24048 v.setStyle('width', '189px');
24055 if(this.isInline) {
24061 setValue: function(v, suppressEvent)
24063 var o = this.getValue();
24065 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
24069 if(suppressEvent !== true){
24070 this.fireEvent('select', this, o, v);
24075 getValue: function()
24080 onClick: function(e)
24082 e.stopPropagation();
24083 e.preventDefault();
24085 var target = e.getTarget();
24087 if(target.nodeName.toLowerCase() === 'i'){
24088 target = Roo.get(target).dom.parentNode;
24091 var nodeName = target.nodeName;
24092 var className = target.className;
24093 var html = target.innerHTML;
24095 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
24099 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
24101 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
24107 picker : function()
24109 return this.pickerEl;
24112 fillMonths: function()
24115 var months = this.picker().select('>.datepicker-months td', true).first();
24117 months.dom.innerHTML = '';
24123 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
24126 months.createChild(month);
24135 if(typeof(this.vIndex) == 'undefined' && this.value.length){
24136 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
24139 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
24140 e.removeClass('active');
24142 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
24143 e.addClass('active');
24150 if(this.isInline) {
24154 this.picker().removeClass(['bottom', 'top']);
24156 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
24158 * place to the top of element!
24162 this.picker().addClass('top');
24163 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
24168 this.picker().addClass('bottom');
24170 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
24173 onFocus : function()
24175 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
24179 onBlur : function()
24181 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
24183 var d = this.inputEl().getValue();
24192 this.picker().show();
24193 this.picker().select('>.datepicker-months', true).first().show();
24197 this.fireEvent('show', this, this.date);
24202 if(this.isInline) {
24205 this.picker().hide();
24206 this.fireEvent('hide', this, this.date);
24210 onMousedown: function(e)
24212 e.stopPropagation();
24213 e.preventDefault();
24218 Roo.bootstrap.MonthField.superclass.keyup.call(this);
24222 fireKey: function(e)
24224 if (!this.picker().isVisible()){
24225 if (e.keyCode == 27) {// allow escape to hide and re-show picker
24236 e.preventDefault();
24240 dir = e.keyCode == 37 ? -1 : 1;
24242 this.vIndex = this.vIndex + dir;
24244 if(this.vIndex < 0){
24248 if(this.vIndex > 11){
24252 if(isNaN(this.vIndex)){
24256 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
24262 dir = e.keyCode == 38 ? -1 : 1;
24264 this.vIndex = this.vIndex + dir * 4;
24266 if(this.vIndex < 0){
24270 if(this.vIndex > 11){
24274 if(isNaN(this.vIndex)){
24278 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
24283 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
24284 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
24288 e.preventDefault();
24291 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
24292 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
24308 this.picker().remove();
24313 Roo.apply(Roo.bootstrap.MonthField, {
24332 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
24333 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
24338 Roo.apply(Roo.bootstrap.MonthField, {
24342 cls: 'datepicker dropdown-menu roo-dynamic',
24346 cls: 'datepicker-months',
24350 cls: 'table-condensed',
24352 Roo.bootstrap.DateField.content
24372 * @class Roo.bootstrap.CheckBox
24373 * @extends Roo.bootstrap.Input
24374 * Bootstrap CheckBox class
24376 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
24377 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
24378 * @cfg {String} boxLabel The text that appears beside the checkbox
24379 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
24380 * @cfg {Boolean} checked initnal the element
24381 * @cfg {Boolean} inline inline the element (default false)
24382 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
24383 * @cfg {String} tooltip label tooltip
24386 * Create a new CheckBox
24387 * @param {Object} config The config object
24390 Roo.bootstrap.CheckBox = function(config){
24391 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
24396 * Fires when the element is checked or unchecked.
24397 * @param {Roo.bootstrap.CheckBox} this This input
24398 * @param {Boolean} checked The new checked value
24403 * Fires when the element is click.
24404 * @param {Roo.bootstrap.CheckBox} this This input
24411 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
24413 inputType: 'checkbox',
24422 // checkbox success does not make any sense really..
24427 getAutoCreate : function()
24429 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
24435 cfg.cls = 'form-group form-check ' + this.inputType; //input-group
24438 cfg.cls += ' ' + this.inputType + '-inline form-check-inline';
24444 type : this.inputType,
24445 value : this.inputValue,
24446 cls : 'roo-' + this.inputType, //'form-box',
24447 placeholder : this.placeholder || ''
24451 if(this.inputType != 'radio'){
24455 cls : 'roo-hidden-value',
24456 value : this.checked ? this.inputValue : this.valueOff
24461 if (this.weight) { // Validity check?
24462 cfg.cls += " " + this.inputType + "-" + this.weight;
24465 if (this.disabled) {
24466 input.disabled=true;
24470 input.checked = this.checked;
24475 input.name = this.name;
24477 if(this.inputType != 'radio'){
24478 hidden.name = this.name;
24479 input.name = '_hidden_' + this.name;
24484 input.cls += ' input-' + this.size;
24489 ['xs','sm','md','lg'].map(function(size){
24490 if (settings[size]) {
24491 cfg.cls += ' col-' + size + '-' + settings[size];
24495 var inputblock = input;
24497 if (this.before || this.after) {
24500 cls : 'input-group',
24505 inputblock.cn.push({
24507 cls : 'input-group-addon',
24512 inputblock.cn.push(input);
24514 if(this.inputType != 'radio'){
24515 inputblock.cn.push(hidden);
24519 inputblock.cn.push({
24521 cls : 'input-group-addon',
24527 var boxLabelCfg = false;
24533 //'for': id, // box label is handled by onclick - so no for...
24535 html: this.boxLabel
24538 boxLabelCfg.tooltip = this.tooltip;
24544 if (align ==='left' && this.fieldLabel.length) {
24545 // Roo.log("left and has label");
24550 cls : 'control-label',
24551 html : this.fieldLabel
24562 cfg.cn[1].cn.push(boxLabelCfg);
24565 if(this.labelWidth > 12){
24566 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
24569 if(this.labelWidth < 13 && this.labelmd == 0){
24570 this.labelmd = this.labelWidth;
24573 if(this.labellg > 0){
24574 cfg.cn[0].cls += ' col-lg-' + this.labellg;
24575 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
24578 if(this.labelmd > 0){
24579 cfg.cn[0].cls += ' col-md-' + this.labelmd;
24580 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
24583 if(this.labelsm > 0){
24584 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
24585 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
24588 if(this.labelxs > 0){
24589 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
24590 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
24593 } else if ( this.fieldLabel.length) {
24594 // Roo.log(" label");
24598 tag: this.boxLabel ? 'span' : 'label',
24600 cls: 'control-label box-input-label',
24601 //cls : 'input-group-addon',
24602 html : this.fieldLabel
24609 cfg.cn.push(boxLabelCfg);
24614 // Roo.log(" no label && no align");
24615 cfg.cn = [ inputblock ] ;
24617 cfg.cn.push(boxLabelCfg);
24625 if(this.inputType != 'radio'){
24626 cfg.cn.push(hidden);
24634 * return the real input element.
24636 inputEl: function ()
24638 return this.el.select('input.roo-' + this.inputType,true).first();
24640 hiddenEl: function ()
24642 return this.el.select('input.roo-hidden-value',true).first();
24645 labelEl: function()
24647 return this.el.select('label.control-label',true).first();
24649 /* depricated... */
24653 return this.labelEl();
24656 boxLabelEl: function()
24658 return this.el.select('label.box-label',true).first();
24661 initEvents : function()
24663 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
24665 this.inputEl().on('click', this.onClick, this);
24667 if (this.boxLabel) {
24668 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
24671 this.startValue = this.getValue();
24674 Roo.bootstrap.CheckBox.register(this);
24678 onClick : function(e)
24680 if(this.fireEvent('click', this, e) !== false){
24681 this.setChecked(!this.checked);
24686 setChecked : function(state,suppressEvent)
24688 this.startValue = this.getValue();
24690 if(this.inputType == 'radio'){
24692 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
24693 e.dom.checked = false;
24696 this.inputEl().dom.checked = true;
24698 this.inputEl().dom.value = this.inputValue;
24700 if(suppressEvent !== true){
24701 this.fireEvent('check', this, true);
24709 this.checked = state;
24711 this.inputEl().dom.checked = state;
24714 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
24716 if(suppressEvent !== true){
24717 this.fireEvent('check', this, state);
24723 getValue : function()
24725 if(this.inputType == 'radio'){
24726 return this.getGroupValue();
24729 return this.hiddenEl().dom.value;
24733 getGroupValue : function()
24735 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
24739 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
24742 setValue : function(v,suppressEvent)
24744 if(this.inputType == 'radio'){
24745 this.setGroupValue(v, suppressEvent);
24749 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
24754 setGroupValue : function(v, suppressEvent)
24756 this.startValue = this.getValue();
24758 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
24759 e.dom.checked = false;
24761 if(e.dom.value == v){
24762 e.dom.checked = true;
24766 if(suppressEvent !== true){
24767 this.fireEvent('check', this, true);
24775 validate : function()
24777 if(this.getVisibilityEl().hasClass('hidden')){
24783 (this.inputType == 'radio' && this.validateRadio()) ||
24784 (this.inputType == 'checkbox' && this.validateCheckbox())
24790 this.markInvalid();
24794 validateRadio : function()
24796 if(this.getVisibilityEl().hasClass('hidden')){
24800 if(this.allowBlank){
24806 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
24807 if(!e.dom.checked){
24819 validateCheckbox : function()
24822 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
24823 //return (this.getValue() == this.inputValue) ? true : false;
24826 var group = Roo.bootstrap.CheckBox.get(this.groupId);
24834 for(var i in group){
24835 if(group[i].el.isVisible(true)){
24843 for(var i in group){
24848 r = (group[i].getValue() == group[i].inputValue) ? true : false;
24855 * Mark this field as valid
24857 markValid : function()
24861 this.fireEvent('valid', this);
24863 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
24866 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
24873 if(this.inputType == 'radio'){
24874 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
24875 var fg = e.findParent('.form-group', false, true);
24876 if (Roo.bootstrap.version == 3) {
24877 fg.removeClass([_this.invalidClass, _this.validClass]);
24878 fg.addClass(_this.validClass);
24880 fg.removeClass(['is-valid', 'is-invalid']);
24881 fg.addClass('is-valid');
24889 var fg = this.el.findParent('.form-group', false, true);
24890 if (Roo.bootstrap.version == 3) {
24891 fg.removeClass([this.invalidClass, this.validClass]);
24892 fg.addClass(this.validClass);
24894 fg.removeClass(['is-valid', 'is-invalid']);
24895 fg.addClass('is-valid');
24900 var group = Roo.bootstrap.CheckBox.get(this.groupId);
24906 for(var i in group){
24907 var fg = group[i].el.findParent('.form-group', false, true);
24908 if (Roo.bootstrap.version == 3) {
24909 fg.removeClass([this.invalidClass, this.validClass]);
24910 fg.addClass(this.validClass);
24912 fg.removeClass(['is-valid', 'is-invalid']);
24913 fg.addClass('is-valid');
24919 * Mark this field as invalid
24920 * @param {String} msg The validation message
24922 markInvalid : function(msg)
24924 if(this.allowBlank){
24930 this.fireEvent('invalid', this, msg);
24932 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
24935 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
24939 label.markInvalid();
24942 if(this.inputType == 'radio'){
24944 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
24945 var fg = e.findParent('.form-group', false, true);
24946 if (Roo.bootstrap.version == 3) {
24947 fg.removeClass([_this.invalidClass, _this.validClass]);
24948 fg.addClass(_this.invalidClass);
24950 fg.removeClass(['is-invalid', 'is-valid']);
24951 fg.addClass('is-invalid');
24959 var fg = this.el.findParent('.form-group', false, true);
24960 if (Roo.bootstrap.version == 3) {
24961 fg.removeClass([_this.invalidClass, _this.validClass]);
24962 fg.addClass(_this.invalidClass);
24964 fg.removeClass(['is-invalid', 'is-valid']);
24965 fg.addClass('is-invalid');
24970 var group = Roo.bootstrap.CheckBox.get(this.groupId);
24976 for(var i in group){
24977 var fg = group[i].el.findParent('.form-group', false, true);
24978 if (Roo.bootstrap.version == 3) {
24979 fg.removeClass([_this.invalidClass, _this.validClass]);
24980 fg.addClass(_this.invalidClass);
24982 fg.removeClass(['is-invalid', 'is-valid']);
24983 fg.addClass('is-invalid');
24989 clearInvalid : function()
24991 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
24993 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
24995 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
24997 if (label && label.iconEl) {
24998 label.iconEl.removeClass([ label.validClass, label.invalidClass ]);
24999 label.iconEl.removeClass(['is-invalid', 'is-valid']);
25003 disable : function()
25005 if(this.inputType != 'radio'){
25006 Roo.bootstrap.CheckBox.superclass.disable.call(this);
25013 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
25014 _this.getActionEl().addClass(this.disabledClass);
25015 e.dom.disabled = true;
25019 this.disabled = true;
25020 this.fireEvent("disable", this);
25024 enable : function()
25026 if(this.inputType != 'radio'){
25027 Roo.bootstrap.CheckBox.superclass.enable.call(this);
25034 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
25035 _this.getActionEl().removeClass(this.disabledClass);
25036 e.dom.disabled = false;
25040 this.disabled = false;
25041 this.fireEvent("enable", this);
25045 setBoxLabel : function(v)
25050 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
25056 Roo.apply(Roo.bootstrap.CheckBox, {
25061 * register a CheckBox Group
25062 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
25064 register : function(checkbox)
25066 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
25067 this.groups[checkbox.groupId] = {};
25070 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
25074 this.groups[checkbox.groupId][checkbox.name] = checkbox;
25078 * fetch a CheckBox Group based on the group ID
25079 * @param {string} the group ID
25080 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
25082 get: function(groupId) {
25083 if (typeof(this.groups[groupId]) == 'undefined') {
25087 return this.groups[groupId] ;
25100 * @class Roo.bootstrap.Radio
25101 * @extends Roo.bootstrap.Component
25102 * Bootstrap Radio class
25103 * @cfg {String} boxLabel - the label associated
25104 * @cfg {String} value - the value of radio
25107 * Create a new Radio
25108 * @param {Object} config The config object
25110 Roo.bootstrap.Radio = function(config){
25111 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
25115 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
25121 getAutoCreate : function()
25125 cls : 'form-group radio',
25130 html : this.boxLabel
25138 initEvents : function()
25140 this.parent().register(this);
25142 this.el.on('click', this.onClick, this);
25146 onClick : function(e)
25148 if(this.parent().fireEvent('click', this.parent(), this, e) !== false){
25149 this.setChecked(true);
25153 setChecked : function(state, suppressEvent)
25155 this.parent().setValue(this.value, suppressEvent);
25159 setBoxLabel : function(v)
25164 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
25179 * @class Roo.bootstrap.SecurePass
25180 * @extends Roo.bootstrap.Input
25181 * Bootstrap SecurePass class
25185 * Create a new SecurePass
25186 * @param {Object} config The config object
25189 Roo.bootstrap.SecurePass = function (config) {
25190 // these go here, so the translation tool can replace them..
25192 PwdEmpty: "Please type a password, and then retype it to confirm.",
25193 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
25194 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
25195 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
25196 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
25197 FNInPwd: "Your password can't contain your first name. Please type a different password.",
25198 LNInPwd: "Your password can't contain your last name. Please type a different password.",
25199 TooWeak: "Your password is Too Weak."
25201 this.meterLabel = "Password strength:";
25202 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
25203 this.meterClass = [
25204 "roo-password-meter-tooweak",
25205 "roo-password-meter-weak",
25206 "roo-password-meter-medium",
25207 "roo-password-meter-strong",
25208 "roo-password-meter-grey"
25213 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
25216 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
25218 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
25220 * PwdEmpty: "Please type a password, and then retype it to confirm.",
25221 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
25222 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
25223 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
25224 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
25225 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
25226 * LNInPwd: "Your password can't contain your last name. Please type a different password."
25236 * @cfg {String/Object} Label for the strength meter (defaults to
25237 * 'Password strength:')
25242 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
25243 * ['Weak', 'Medium', 'Strong'])
25246 pwdStrengths: false,
25259 initEvents: function ()
25261 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
25263 if (this.el.is('input[type=password]') && Roo.isSafari) {
25264 this.el.on('keydown', this.SafariOnKeyDown, this);
25267 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
25270 onRender: function (ct, position)
25272 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
25273 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
25274 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
25276 this.trigger.createChild({
25281 cls: 'roo-password-meter-grey col-xs-12',
25284 //width: this.meterWidth + 'px'
25288 cls: 'roo-password-meter-text'
25294 if (this.hideTrigger) {
25295 this.trigger.setDisplayed(false);
25297 this.setSize(this.width || '', this.height || '');
25300 onDestroy: function ()
25302 if (this.trigger) {
25303 this.trigger.removeAllListeners();
25304 this.trigger.remove();
25307 this.wrap.remove();
25309 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
25312 checkStrength: function ()
25314 var pwd = this.inputEl().getValue();
25315 if (pwd == this._lastPwd) {
25320 if (this.ClientSideStrongPassword(pwd)) {
25322 } else if (this.ClientSideMediumPassword(pwd)) {
25324 } else if (this.ClientSideWeakPassword(pwd)) {
25330 Roo.log('strength1: ' + strength);
25332 //var pm = this.trigger.child('div/div/div').dom;
25333 var pm = this.trigger.child('div/div');
25334 pm.removeClass(this.meterClass);
25335 pm.addClass(this.meterClass[strength]);
25338 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
25340 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
25342 this._lastPwd = pwd;
25346 Roo.bootstrap.SecurePass.superclass.reset.call(this);
25348 this._lastPwd = '';
25350 var pm = this.trigger.child('div/div');
25351 pm.removeClass(this.meterClass);
25352 pm.addClass('roo-password-meter-grey');
25355 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
25358 this.inputEl().dom.type='password';
25361 validateValue: function (value)
25363 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
25366 if (value.length == 0) {
25367 if (this.allowBlank) {
25368 this.clearInvalid();
25372 this.markInvalid(this.errors.PwdEmpty);
25373 this.errorMsg = this.errors.PwdEmpty;
25381 if (!value.match(/[\x21-\x7e]+/)) {
25382 this.markInvalid(this.errors.PwdBadChar);
25383 this.errorMsg = this.errors.PwdBadChar;
25386 if (value.length < 6) {
25387 this.markInvalid(this.errors.PwdShort);
25388 this.errorMsg = this.errors.PwdShort;
25391 if (value.length > 16) {
25392 this.markInvalid(this.errors.PwdLong);
25393 this.errorMsg = this.errors.PwdLong;
25397 if (this.ClientSideStrongPassword(value)) {
25399 } else if (this.ClientSideMediumPassword(value)) {
25401 } else if (this.ClientSideWeakPassword(value)) {
25408 if (strength < 2) {
25409 //this.markInvalid(this.errors.TooWeak);
25410 this.errorMsg = this.errors.TooWeak;
25415 console.log('strength2: ' + strength);
25417 //var pm = this.trigger.child('div/div/div').dom;
25419 var pm = this.trigger.child('div/div');
25420 pm.removeClass(this.meterClass);
25421 pm.addClass(this.meterClass[strength]);
25423 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
25425 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
25427 this.errorMsg = '';
25431 CharacterSetChecks: function (type)
25434 this.fResult = false;
25437 isctype: function (character, type)
25440 case this.kCapitalLetter:
25441 if (character >= 'A' && character <= 'Z') {
25446 case this.kSmallLetter:
25447 if (character >= 'a' && character <= 'z') {
25453 if (character >= '0' && character <= '9') {
25458 case this.kPunctuation:
25459 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
25470 IsLongEnough: function (pwd, size)
25472 return !(pwd == null || isNaN(size) || pwd.length < size);
25475 SpansEnoughCharacterSets: function (word, nb)
25477 if (!this.IsLongEnough(word, nb))
25482 var characterSetChecks = new Array(
25483 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
25484 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
25487 for (var index = 0; index < word.length; ++index) {
25488 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
25489 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
25490 characterSetChecks[nCharSet].fResult = true;
25497 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
25498 if (characterSetChecks[nCharSet].fResult) {
25503 if (nCharSets < nb) {
25509 ClientSideStrongPassword: function (pwd)
25511 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
25514 ClientSideMediumPassword: function (pwd)
25516 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
25519 ClientSideWeakPassword: function (pwd)
25521 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
25524 })//<script type="text/javascript">
25527 * Based Ext JS Library 1.1.1
25528 * Copyright(c) 2006-2007, Ext JS, LLC.
25534 * @class Roo.HtmlEditorCore
25535 * @extends Roo.Component
25536 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
25538 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
25541 Roo.HtmlEditorCore = function(config){
25544 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
25549 * @event initialize
25550 * Fires when the editor is fully initialized (including the iframe)
25551 * @param {Roo.HtmlEditorCore} this
25556 * Fires when the editor is first receives the focus. Any insertion must wait
25557 * until after this event.
25558 * @param {Roo.HtmlEditorCore} this
25562 * @event beforesync
25563 * Fires before the textarea is updated with content from the editor iframe. Return false
25564 * to cancel the sync.
25565 * @param {Roo.HtmlEditorCore} this
25566 * @param {String} html
25570 * @event beforepush
25571 * Fires before the iframe editor is updated with content from the textarea. Return false
25572 * to cancel the push.
25573 * @param {Roo.HtmlEditorCore} this
25574 * @param {String} html
25579 * Fires when the textarea is updated with content from the editor iframe.
25580 * @param {Roo.HtmlEditorCore} this
25581 * @param {String} html
25586 * Fires when the iframe editor is updated with content from the textarea.
25587 * @param {Roo.HtmlEditorCore} this
25588 * @param {String} html
25593 * @event editorevent
25594 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
25595 * @param {Roo.HtmlEditorCore} this
25601 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
25603 // defaults : white / black...
25604 this.applyBlacklists();
25611 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
25615 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
25621 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
25626 * @cfg {Number} height (in pixels)
25630 * @cfg {Number} width (in pixels)
25635 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
25638 stylesheets: false,
25641 * @cfg {boolean} allowComments - default false - allow comments in HTML source - by default they are stripped - if you are editing email you may need this.
25643 allowComments: false,
25647 // private properties
25648 validationEvent : false,
25650 initialized : false,
25652 sourceEditMode : false,
25653 onFocus : Roo.emptyFn,
25655 hideMode:'offsets',
25659 // blacklist + whitelisted elements..
25666 * Protected method that will not generally be called directly. It
25667 * is called when the editor initializes the iframe with HTML contents. Override this method if you
25668 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
25670 getDocMarkup : function(){
25674 // inherit styels from page...??
25675 if (this.stylesheets === false) {
25677 Roo.get(document.head).select('style').each(function(node) {
25678 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
25681 Roo.get(document.head).select('link').each(function(node) {
25682 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
25685 } else if (!this.stylesheets.length) {
25687 st = '<style type="text/css">' +
25688 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
25691 for (var i in this.stylesheets) {
25692 st += '<link rel="stylesheet" href="' + this.stylesheets[i] +'" type="text/css">';
25697 st += '<style type="text/css">' +
25698 'IMG { cursor: pointer } ' +
25701 var cls = 'roo-htmleditor-body';
25703 if(this.bodyCls.length){
25704 cls += ' ' + this.bodyCls;
25707 return '<html><head>' + st +
25708 //<style type="text/css">' +
25709 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
25711 ' </head><body contenteditable="true" data-enable-grammerly="true" class="' + cls + '"></body></html>';
25715 onRender : function(ct, position)
25718 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
25719 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
25722 this.el.dom.style.border = '0 none';
25723 this.el.dom.setAttribute('tabIndex', -1);
25724 this.el.addClass('x-hidden hide');
25728 if(Roo.isIE){ // fix IE 1px bogus margin
25729 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
25733 this.frameId = Roo.id();
25737 var iframe = this.owner.wrap.createChild({
25739 cls: 'form-control', // bootstrap..
25741 name: this.frameId,
25742 frameBorder : 'no',
25743 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
25748 this.iframe = iframe.dom;
25750 this.assignDocWin();
25752 this.doc.designMode = 'on';
25755 this.doc.write(this.getDocMarkup());
25759 var task = { // must defer to wait for browser to be ready
25761 //console.log("run task?" + this.doc.readyState);
25762 this.assignDocWin();
25763 if(this.doc.body || this.doc.readyState == 'complete'){
25765 this.doc.designMode="on";
25769 Roo.TaskMgr.stop(task);
25770 this.initEditor.defer(10, this);
25777 Roo.TaskMgr.start(task);
25782 onResize : function(w, h)
25784 Roo.log('resize: ' +w + ',' + h );
25785 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
25789 if(typeof w == 'number'){
25791 this.iframe.style.width = w + 'px';
25793 if(typeof h == 'number'){
25795 this.iframe.style.height = h + 'px';
25797 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
25804 * Toggles the editor between standard and source edit mode.
25805 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
25807 toggleSourceEdit : function(sourceEditMode){
25809 this.sourceEditMode = sourceEditMode === true;
25811 if(this.sourceEditMode){
25813 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
25816 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
25817 //this.iframe.className = '';
25820 //this.setSize(this.owner.wrap.getSize());
25821 //this.fireEvent('editmodechange', this, this.sourceEditMode);
25828 * Protected method that will not generally be called directly. If you need/want
25829 * custom HTML cleanup, this is the method you should override.
25830 * @param {String} html The HTML to be cleaned
25831 * return {String} The cleaned HTML
25833 cleanHtml : function(html){
25834 html = String(html);
25835 if(html.length > 5){
25836 if(Roo.isSafari){ // strip safari nonsense
25837 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
25840 if(html == ' '){
25847 * HTML Editor -> Textarea
25848 * Protected method that will not generally be called directly. Syncs the contents
25849 * of the editor iframe with the textarea.
25851 syncValue : function(){
25852 if(this.initialized){
25853 var bd = (this.doc.body || this.doc.documentElement);
25854 //this.cleanUpPaste(); -- this is done else where and causes havoc..
25855 var html = bd.innerHTML;
25857 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
25858 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
25860 html = '<div style="'+m[0]+'">' + html + '</div>';
25863 html = this.cleanHtml(html);
25864 // fix up the special chars.. normaly like back quotes in word...
25865 // however we do not want to do this with chinese..
25866 html = html.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[\u0080-\uFFFF]/g, function(match) {
25868 var cc = match.charCodeAt();
25870 // Get the character value, handling surrogate pairs
25871 if (match.length == 2) {
25872 // It's a surrogate pair, calculate the Unicode code point
25873 var high = match.charCodeAt(0) - 0xD800;
25874 var low = match.charCodeAt(1) - 0xDC00;
25875 cc = (high * 0x400) + low + 0x10000;
25877 (cc >= 0x4E00 && cc < 0xA000 ) ||
25878 (cc >= 0x3400 && cc < 0x4E00 ) ||
25879 (cc >= 0xf900 && cc < 0xfb00 )
25884 // No, use a numeric entity. Here we brazenly (and possibly mistakenly)
25885 return "&#" + cc + ";";
25892 if(this.owner.fireEvent('beforesync', this, html) !== false){
25893 this.el.dom.value = html;
25894 this.owner.fireEvent('sync', this, html);
25900 * Protected method that will not generally be called directly. Pushes the value of the textarea
25901 * into the iframe editor.
25903 pushValue : function(){
25904 if(this.initialized){
25905 var v = this.el.dom.value.trim();
25907 // if(v.length < 1){
25911 if(this.owner.fireEvent('beforepush', this, v) !== false){
25912 var d = (this.doc.body || this.doc.documentElement);
25914 this.cleanUpPaste();
25915 this.el.dom.value = d.innerHTML;
25916 this.owner.fireEvent('push', this, v);
25922 deferFocus : function(){
25923 this.focus.defer(10, this);
25927 focus : function(){
25928 if(this.win && !this.sourceEditMode){
25935 assignDocWin: function()
25937 var iframe = this.iframe;
25940 this.doc = iframe.contentWindow.document;
25941 this.win = iframe.contentWindow;
25943 // if (!Roo.get(this.frameId)) {
25946 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
25947 // this.win = Roo.get(this.frameId).dom.contentWindow;
25949 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
25953 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
25954 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
25959 initEditor : function(){
25960 //console.log("INIT EDITOR");
25961 this.assignDocWin();
25965 this.doc.designMode="on";
25967 this.doc.write(this.getDocMarkup());
25970 var dbody = (this.doc.body || this.doc.documentElement);
25971 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
25972 // this copies styles from the containing element into thsi one..
25973 // not sure why we need all of this..
25974 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
25976 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
25977 //ss['background-attachment'] = 'fixed'; // w3c
25978 dbody.bgProperties = 'fixed'; // ie
25979 //Roo.DomHelper.applyStyles(dbody, ss);
25980 Roo.EventManager.on(this.doc, {
25981 //'mousedown': this.onEditorEvent,
25982 'mouseup': this.onEditorEvent,
25983 'dblclick': this.onEditorEvent,
25984 'click': this.onEditorEvent,
25985 'keyup': this.onEditorEvent,
25990 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
25992 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
25993 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
25995 this.initialized = true;
25997 this.owner.fireEvent('initialize', this);
26002 onDestroy : function(){
26008 //for (var i =0; i < this.toolbars.length;i++) {
26009 // // fixme - ask toolbars for heights?
26010 // this.toolbars[i].onDestroy();
26013 //this.wrap.dom.innerHTML = '';
26014 //this.wrap.remove();
26019 onFirstFocus : function(){
26021 this.assignDocWin();
26024 this.activated = true;
26027 if(Roo.isGecko){ // prevent silly gecko errors
26029 var s = this.win.getSelection();
26030 if(!s.focusNode || s.focusNode.nodeType != 3){
26031 var r = s.getRangeAt(0);
26032 r.selectNodeContents((this.doc.body || this.doc.documentElement));
26037 this.execCmd('useCSS', true);
26038 this.execCmd('styleWithCSS', false);
26041 this.owner.fireEvent('activate', this);
26045 adjustFont: function(btn){
26046 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
26047 //if(Roo.isSafari){ // safari
26050 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
26051 if(Roo.isSafari){ // safari
26052 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
26053 v = (v < 10) ? 10 : v;
26054 v = (v > 48) ? 48 : v;
26055 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
26060 v = Math.max(1, v+adjust);
26062 this.execCmd('FontSize', v );
26065 onEditorEvent : function(e)
26067 this.owner.fireEvent('editorevent', this, e);
26068 // this.updateToolbar();
26069 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
26072 insertTag : function(tg)
26074 // could be a bit smarter... -> wrap the current selected tRoo..
26075 if (tg.toLowerCase() == 'span' ||
26076 tg.toLowerCase() == 'code' ||
26077 tg.toLowerCase() == 'sup' ||
26078 tg.toLowerCase() == 'sub'
26081 range = this.createRange(this.getSelection());
26082 var wrappingNode = this.doc.createElement(tg.toLowerCase());
26083 wrappingNode.appendChild(range.extractContents());
26084 range.insertNode(wrappingNode);
26091 this.execCmd("formatblock", tg);
26095 insertText : function(txt)
26099 var range = this.createRange();
26100 range.deleteContents();
26101 //alert(Sender.getAttribute('label'));
26103 range.insertNode(this.doc.createTextNode(txt));
26109 * Executes a Midas editor command on the editor document and performs necessary focus and
26110 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
26111 * @param {String} cmd The Midas command
26112 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
26114 relayCmd : function(cmd, value){
26116 this.execCmd(cmd, value);
26117 this.owner.fireEvent('editorevent', this);
26118 //this.updateToolbar();
26119 this.owner.deferFocus();
26123 * Executes a Midas editor command directly on the editor document.
26124 * For visual commands, you should use {@link #relayCmd} instead.
26125 * <b>This should only be called after the editor is initialized.</b>
26126 * @param {String} cmd The Midas command
26127 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
26129 execCmd : function(cmd, value){
26130 this.doc.execCommand(cmd, false, value === undefined ? null : value);
26137 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
26139 * @param {String} text | dom node..
26141 insertAtCursor : function(text)
26144 if(!this.activated){
26150 var r = this.doc.selection.createRange();
26161 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
26165 // from jquery ui (MIT licenced)
26167 var win = this.win;
26169 if (win.getSelection && win.getSelection().getRangeAt) {
26170 range = win.getSelection().getRangeAt(0);
26171 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
26172 range.insertNode(node);
26173 } else if (win.document.selection && win.document.selection.createRange) {
26174 // no firefox support
26175 var txt = typeof(text) == 'string' ? text : text.outerHTML;
26176 win.document.selection.createRange().pasteHTML(txt);
26178 // no firefox support
26179 var txt = typeof(text) == 'string' ? text : text.outerHTML;
26180 this.execCmd('InsertHTML', txt);
26189 mozKeyPress : function(e){
26191 var c = e.getCharCode(), cmd;
26194 c = String.fromCharCode(c).toLowerCase();
26208 this.cleanUpPaste.defer(100, this);
26216 e.preventDefault();
26224 fixKeys : function(){ // load time branching for fastest keydown performance
26226 return function(e){
26227 var k = e.getKey(), r;
26230 r = this.doc.selection.createRange();
26233 r.pasteHTML('    ');
26240 r = this.doc.selection.createRange();
26242 var target = r.parentElement();
26243 if(!target || target.tagName.toLowerCase() != 'li'){
26245 r.pasteHTML('<br />');
26251 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
26252 this.cleanUpPaste.defer(100, this);
26258 }else if(Roo.isOpera){
26259 return function(e){
26260 var k = e.getKey();
26264 this.execCmd('InsertHTML','    ');
26267 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
26268 this.cleanUpPaste.defer(100, this);
26273 }else if(Roo.isSafari){
26274 return function(e){
26275 var k = e.getKey();
26279 this.execCmd('InsertText','\t');
26283 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
26284 this.cleanUpPaste.defer(100, this);
26292 getAllAncestors: function()
26294 var p = this.getSelectedNode();
26297 a.push(p); // push blank onto stack..
26298 p = this.getParentElement();
26302 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
26306 a.push(this.doc.body);
26310 lastSelNode : false,
26313 getSelection : function()
26315 this.assignDocWin();
26316 return Roo.isIE ? this.doc.selection : this.win.getSelection();
26319 getSelectedNode: function()
26321 // this may only work on Gecko!!!
26323 // should we cache this!!!!
26328 var range = this.createRange(this.getSelection()).cloneRange();
26331 var parent = range.parentElement();
26333 var testRange = range.duplicate();
26334 testRange.moveToElementText(parent);
26335 if (testRange.inRange(range)) {
26338 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
26341 parent = parent.parentElement;
26346 // is ancestor a text element.
26347 var ac = range.commonAncestorContainer;
26348 if (ac.nodeType == 3) {
26349 ac = ac.parentNode;
26352 var ar = ac.childNodes;
26355 var other_nodes = [];
26356 var has_other_nodes = false;
26357 for (var i=0;i<ar.length;i++) {
26358 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
26361 // fullly contained node.
26363 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
26368 // probably selected..
26369 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
26370 other_nodes.push(ar[i]);
26374 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
26379 has_other_nodes = true;
26381 if (!nodes.length && other_nodes.length) {
26382 nodes= other_nodes;
26384 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
26390 createRange: function(sel)
26392 // this has strange effects when using with
26393 // top toolbar - not sure if it's a great idea.
26394 //this.editor.contentWindow.focus();
26395 if (typeof sel != "undefined") {
26397 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
26399 return this.doc.createRange();
26402 return this.doc.createRange();
26405 getParentElement: function()
26408 this.assignDocWin();
26409 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
26411 var range = this.createRange(sel);
26414 var p = range.commonAncestorContainer;
26415 while (p.nodeType == 3) { // text node
26426 * Range intersection.. the hard stuff...
26430 * [ -- selected range --- ]
26434 * if end is before start or hits it. fail.
26435 * if start is after end or hits it fail.
26437 * if either hits (but other is outside. - then it's not
26443 // @see http://www.thismuchiknow.co.uk/?p=64.
26444 rangeIntersectsNode : function(range, node)
26446 var nodeRange = node.ownerDocument.createRange();
26448 nodeRange.selectNode(node);
26450 nodeRange.selectNodeContents(node);
26453 var rangeStartRange = range.cloneRange();
26454 rangeStartRange.collapse(true);
26456 var rangeEndRange = range.cloneRange();
26457 rangeEndRange.collapse(false);
26459 var nodeStartRange = nodeRange.cloneRange();
26460 nodeStartRange.collapse(true);
26462 var nodeEndRange = nodeRange.cloneRange();
26463 nodeEndRange.collapse(false);
26465 return rangeStartRange.compareBoundaryPoints(
26466 Range.START_TO_START, nodeEndRange) == -1 &&
26467 rangeEndRange.compareBoundaryPoints(
26468 Range.START_TO_START, nodeStartRange) == 1;
26472 rangeCompareNode : function(range, node)
26474 var nodeRange = node.ownerDocument.createRange();
26476 nodeRange.selectNode(node);
26478 nodeRange.selectNodeContents(node);
26482 range.collapse(true);
26484 nodeRange.collapse(true);
26486 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
26487 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
26489 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
26491 var nodeIsBefore = ss == 1;
26492 var nodeIsAfter = ee == -1;
26494 if (nodeIsBefore && nodeIsAfter) {
26497 if (!nodeIsBefore && nodeIsAfter) {
26498 return 1; //right trailed.
26501 if (nodeIsBefore && !nodeIsAfter) {
26502 return 2; // left trailed.
26508 // private? - in a new class?
26509 cleanUpPaste : function()
26511 // cleans up the whole document..
26512 Roo.log('cleanuppaste');
26514 this.cleanUpChildren(this.doc.body);
26515 var clean = this.cleanWordChars(this.doc.body.innerHTML);
26516 if (clean != this.doc.body.innerHTML) {
26517 this.doc.body.innerHTML = clean;
26522 cleanWordChars : function(input) {// change the chars to hex code
26523 var he = Roo.HtmlEditorCore;
26525 var output = input;
26526 Roo.each(he.swapCodes, function(sw) {
26527 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
26529 output = output.replace(swapper, sw[1]);
26536 cleanUpChildren : function (n)
26538 if (!n.childNodes.length) {
26541 for (var i = n.childNodes.length-1; i > -1 ; i--) {
26542 this.cleanUpChild(n.childNodes[i]);
26549 cleanUpChild : function (node)
26552 //console.log(node);
26553 if (node.nodeName == "#text") {
26554 // clean up silly Windows -- stuff?
26557 if (node.nodeName == "#comment") {
26558 if (!this.allowComments) {
26559 node.parentNode.removeChild(node);
26561 // clean up silly Windows -- stuff?
26564 var lcname = node.tagName.toLowerCase();
26565 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
26566 // whitelist of tags..
26568 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
26570 node.parentNode.removeChild(node);
26575 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
26577 // spans with no attributes - just remove them..
26578 if ((!node.attributes || !node.attributes.length) && lcname == 'span') {
26579 remove_keep_children = true;
26582 // remove <a name=....> as rendering on yahoo mailer is borked with this.
26583 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
26585 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
26586 // remove_keep_children = true;
26589 if (remove_keep_children) {
26590 this.cleanUpChildren(node);
26591 // inserts everything just before this node...
26592 while (node.childNodes.length) {
26593 var cn = node.childNodes[0];
26594 node.removeChild(cn);
26595 node.parentNode.insertBefore(cn, node);
26597 node.parentNode.removeChild(node);
26601 if (!node.attributes || !node.attributes.length) {
26606 this.cleanUpChildren(node);
26610 function cleanAttr(n,v)
26613 if (v.match(/^\./) || v.match(/^\//)) {
26616 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/) || v.match(/^ftp:/)) {
26619 if (v.match(/^#/)) {
26622 if (v.match(/^\{/)) { // allow template editing.
26625 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
26626 node.removeAttribute(n);
26630 var cwhite = this.cwhite;
26631 var cblack = this.cblack;
26633 function cleanStyle(n,v)
26635 if (v.match(/expression/)) { //XSS?? should we even bother..
26636 node.removeAttribute(n);
26640 var parts = v.split(/;/);
26643 Roo.each(parts, function(p) {
26644 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
26648 var l = p.split(':').shift().replace(/\s+/g,'');
26649 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
26651 if ( cwhite.length && cblack.indexOf(l) > -1) {
26652 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
26653 //node.removeAttribute(n);
26657 // only allow 'c whitelisted system attributes'
26658 if ( cwhite.length && cwhite.indexOf(l) < 0) {
26659 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
26660 //node.removeAttribute(n);
26670 if (clean.length) {
26671 node.setAttribute(n, clean.join(';'));
26673 node.removeAttribute(n);
26679 for (var i = node.attributes.length-1; i > -1 ; i--) {
26680 var a = node.attributes[i];
26683 if (a.name.toLowerCase().substr(0,2)=='on') {
26684 node.removeAttribute(a.name);
26687 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
26688 node.removeAttribute(a.name);
26691 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
26692 cleanAttr(a.name,a.value); // fixme..
26695 if (a.name == 'style') {
26696 cleanStyle(a.name,a.value);
26699 /// clean up MS crap..
26700 // tecnically this should be a list of valid class'es..
26703 if (a.name == 'class') {
26704 if (a.value.match(/^Mso/)) {
26705 node.removeAttribute('class');
26708 if (a.value.match(/^body$/)) {
26709 node.removeAttribute('class');
26720 this.cleanUpChildren(node);
26726 * Clean up MS wordisms...
26728 cleanWord : function(node)
26731 this.cleanWord(this.doc.body);
26736 node.nodeName == 'SPAN' &&
26737 !node.hasAttributes() &&
26738 node.childNodes.length == 1 &&
26739 node.firstChild.nodeName == "#text"
26741 var textNode = node.firstChild;
26742 node.removeChild(textNode);
26743 if (node.getAttribute('lang') != 'zh-CN') { // do not space pad on chinese characters..
26744 node.parentNode.insertBefore(node.ownerDocument.createTextNode(" "), node);
26746 node.parentNode.insertBefore(textNode, node);
26747 if (node.getAttribute('lang') != 'zh-CN') { // do not space pad on chinese characters..
26748 node.parentNode.insertBefore(node.ownerDocument.createTextNode(" ") , node);
26750 node.parentNode.removeChild(node);
26753 if (node.nodeName == "#text") {
26754 // clean up silly Windows -- stuff?
26757 if (node.nodeName == "#comment") {
26758 node.parentNode.removeChild(node);
26759 // clean up silly Windows -- stuff?
26763 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
26764 node.parentNode.removeChild(node);
26767 //Roo.log(node.tagName);
26768 // remove - but keep children..
26769 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|v:|font)/)) {
26770 //Roo.log('-- removed');
26771 while (node.childNodes.length) {
26772 var cn = node.childNodes[0];
26773 node.removeChild(cn);
26774 node.parentNode.insertBefore(cn, node);
26775 // move node to parent - and clean it..
26776 this.cleanWord(cn);
26778 node.parentNode.removeChild(node);
26779 /// no need to iterate chidlren = it's got none..
26780 //this.iterateChildren(node, this.cleanWord);
26784 if (node.className.length) {
26786 var cn = node.className.split(/\W+/);
26788 Roo.each(cn, function(cls) {
26789 if (cls.match(/Mso[a-zA-Z]+/)) {
26794 node.className = cna.length ? cna.join(' ') : '';
26796 node.removeAttribute("class");
26800 if (node.hasAttribute("lang")) {
26801 node.removeAttribute("lang");
26804 if (node.hasAttribute("style")) {
26806 var styles = node.getAttribute("style").split(";");
26808 Roo.each(styles, function(s) {
26809 if (!s.match(/:/)) {
26812 var kv = s.split(":");
26813 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
26816 // what ever is left... we allow.
26819 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
26820 if (!nstyle.length) {
26821 node.removeAttribute('style');
26824 this.iterateChildren(node, this.cleanWord);
26830 * iterateChildren of a Node, calling fn each time, using this as the scole..
26831 * @param {DomNode} node node to iterate children of.
26832 * @param {Function} fn method of this class to call on each item.
26834 iterateChildren : function(node, fn)
26836 if (!node.childNodes.length) {
26839 for (var i = node.childNodes.length-1; i > -1 ; i--) {
26840 fn.call(this, node.childNodes[i])
26846 * cleanTableWidths.
26848 * Quite often pasting from word etc.. results in tables with column and widths.
26849 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
26852 cleanTableWidths : function(node)
26857 this.cleanTableWidths(this.doc.body);
26862 if (node.nodeName == "#text" || node.nodeName == "#comment") {
26865 Roo.log(node.tagName);
26866 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
26867 this.iterateChildren(node, this.cleanTableWidths);
26870 if (node.hasAttribute('width')) {
26871 node.removeAttribute('width');
26875 if (node.hasAttribute("style")) {
26878 var styles = node.getAttribute("style").split(";");
26880 Roo.each(styles, function(s) {
26881 if (!s.match(/:/)) {
26884 var kv = s.split(":");
26885 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
26888 // what ever is left... we allow.
26891 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
26892 if (!nstyle.length) {
26893 node.removeAttribute('style');
26897 this.iterateChildren(node, this.cleanTableWidths);
26905 domToHTML : function(currentElement, depth, nopadtext) {
26907 depth = depth || 0;
26908 nopadtext = nopadtext || false;
26910 if (!currentElement) {
26911 return this.domToHTML(this.doc.body);
26914 //Roo.log(currentElement);
26916 var allText = false;
26917 var nodeName = currentElement.nodeName;
26918 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
26920 if (nodeName == '#text') {
26922 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
26927 if (nodeName != 'BODY') {
26930 // Prints the node tagName, such as <A>, <IMG>, etc
26933 for(i = 0; i < currentElement.attributes.length;i++) {
26935 var aname = currentElement.attributes.item(i).name;
26936 if (!currentElement.attributes.item(i).value.length) {
26939 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
26942 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
26951 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
26954 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
26959 // Traverse the tree
26961 var currentElementChild = currentElement.childNodes.item(i);
26962 var allText = true;
26963 var innerHTML = '';
26965 while (currentElementChild) {
26966 // Formatting code (indent the tree so it looks nice on the screen)
26967 var nopad = nopadtext;
26968 if (lastnode == 'SPAN') {
26972 if (currentElementChild.nodeName == '#text') {
26973 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
26974 toadd = nopadtext ? toadd : toadd.trim();
26975 if (!nopad && toadd.length > 80) {
26976 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
26978 innerHTML += toadd;
26981 currentElementChild = currentElement.childNodes.item(i);
26987 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
26989 // Recursively traverse the tree structure of the child node
26990 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
26991 lastnode = currentElementChild.nodeName;
26993 currentElementChild=currentElement.childNodes.item(i);
26999 // The remaining code is mostly for formatting the tree
27000 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
27005 ret+= "</"+tagName+">";
27011 applyBlacklists : function()
27013 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
27014 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
27018 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
27019 if (b.indexOf(tag) > -1) {
27022 this.white.push(tag);
27026 Roo.each(w, function(tag) {
27027 if (b.indexOf(tag) > -1) {
27030 if (this.white.indexOf(tag) > -1) {
27033 this.white.push(tag);
27038 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
27039 if (w.indexOf(tag) > -1) {
27042 this.black.push(tag);
27046 Roo.each(b, function(tag) {
27047 if (w.indexOf(tag) > -1) {
27050 if (this.black.indexOf(tag) > -1) {
27053 this.black.push(tag);
27058 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
27059 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
27063 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
27064 if (b.indexOf(tag) > -1) {
27067 this.cwhite.push(tag);
27071 Roo.each(w, function(tag) {
27072 if (b.indexOf(tag) > -1) {
27075 if (this.cwhite.indexOf(tag) > -1) {
27078 this.cwhite.push(tag);
27083 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
27084 if (w.indexOf(tag) > -1) {
27087 this.cblack.push(tag);
27091 Roo.each(b, function(tag) {
27092 if (w.indexOf(tag) > -1) {
27095 if (this.cblack.indexOf(tag) > -1) {
27098 this.cblack.push(tag);
27103 setStylesheets : function(stylesheets)
27105 if(typeof(stylesheets) == 'string'){
27106 Roo.get(this.iframe.contentDocument.head).createChild({
27108 rel : 'stylesheet',
27117 Roo.each(stylesheets, function(s) {
27122 Roo.get(_this.iframe.contentDocument.head).createChild({
27124 rel : 'stylesheet',
27133 removeStylesheets : function()
27137 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
27142 setStyle : function(style)
27144 Roo.get(this.iframe.contentDocument.head).createChild({
27153 // hide stuff that is not compatible
27167 * @event specialkey
27171 * @cfg {String} fieldClass @hide
27174 * @cfg {String} focusClass @hide
27177 * @cfg {String} autoCreate @hide
27180 * @cfg {String} inputType @hide
27183 * @cfg {String} invalidClass @hide
27186 * @cfg {String} invalidText @hide
27189 * @cfg {String} msgFx @hide
27192 * @cfg {String} validateOnBlur @hide
27196 Roo.HtmlEditorCore.white = [
27197 'area', 'br', 'img', 'input', 'hr', 'wbr',
27199 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
27200 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
27201 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
27202 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
27203 'table', 'ul', 'xmp',
27205 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
27208 'dir', 'menu', 'ol', 'ul', 'dl',
27214 Roo.HtmlEditorCore.black = [
27215 // 'embed', 'object', // enable - backend responsiblity to clean thiese
27217 'base', 'basefont', 'bgsound', 'blink', 'body',
27218 'frame', 'frameset', 'head', 'html', 'ilayer',
27219 'iframe', 'layer', 'link', 'meta', 'object',
27220 'script', 'style' ,'title', 'xml' // clean later..
27222 Roo.HtmlEditorCore.clean = [
27223 'script', 'style', 'title', 'xml'
27225 Roo.HtmlEditorCore.remove = [
27230 Roo.HtmlEditorCore.ablack = [
27234 Roo.HtmlEditorCore.aclean = [
27235 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
27239 Roo.HtmlEditorCore.pwhite= [
27240 'http', 'https', 'mailto'
27243 // white listed style attributes.
27244 Roo.HtmlEditorCore.cwhite= [
27245 // 'text-align', /// default is to allow most things..
27251 // black listed style attributes.
27252 Roo.HtmlEditorCore.cblack= [
27253 // 'font-size' -- this can be set by the project
27257 Roo.HtmlEditorCore.swapCodes =[
27258 [ 8211, "–" ],
27259 [ 8212, "—" ],
27276 * @class Roo.bootstrap.HtmlEditor
27277 * @extends Roo.bootstrap.TextArea
27278 * Bootstrap HtmlEditor class
27281 * Create a new HtmlEditor
27282 * @param {Object} config The config object
27285 Roo.bootstrap.HtmlEditor = function(config){
27286 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
27287 if (!this.toolbars) {
27288 this.toolbars = [];
27291 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
27294 * @event initialize
27295 * Fires when the editor is fully initialized (including the iframe)
27296 * @param {HtmlEditor} this
27301 * Fires when the editor is first receives the focus. Any insertion must wait
27302 * until after this event.
27303 * @param {HtmlEditor} this
27307 * @event beforesync
27308 * Fires before the textarea is updated with content from the editor iframe. Return false
27309 * to cancel the sync.
27310 * @param {HtmlEditor} this
27311 * @param {String} html
27315 * @event beforepush
27316 * Fires before the iframe editor is updated with content from the textarea. Return false
27317 * to cancel the push.
27318 * @param {HtmlEditor} this
27319 * @param {String} html
27324 * Fires when the textarea is updated with content from the editor iframe.
27325 * @param {HtmlEditor} this
27326 * @param {String} html
27331 * Fires when the iframe editor is updated with content from the textarea.
27332 * @param {HtmlEditor} this
27333 * @param {String} html
27337 * @event editmodechange
27338 * Fires when the editor switches edit modes
27339 * @param {HtmlEditor} this
27340 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
27342 editmodechange: true,
27344 * @event editorevent
27345 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
27346 * @param {HtmlEditor} this
27350 * @event firstfocus
27351 * Fires when on first focus - needed by toolbars..
27352 * @param {HtmlEditor} this
27357 * Auto save the htmlEditor value as a file into Events
27358 * @param {HtmlEditor} this
27362 * @event savedpreview
27363 * preview the saved version of htmlEditor
27364 * @param {HtmlEditor} this
27371 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
27375 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
27380 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
27385 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
27390 * @cfg {Number} height (in pixels)
27394 * @cfg {Number} width (in pixels)
27399 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
27402 stylesheets: false,
27407 // private properties
27408 validationEvent : false,
27410 initialized : false,
27413 onFocus : Roo.emptyFn,
27415 hideMode:'offsets',
27417 tbContainer : false,
27421 toolbarContainer :function() {
27422 return this.wrap.select('.x-html-editor-tb',true).first();
27426 * Protected method that will not generally be called directly. It
27427 * is called when the editor creates its toolbar. Override this method if you need to
27428 * add custom toolbar buttons.
27429 * @param {HtmlEditor} editor
27431 createToolbar : function(){
27432 Roo.log('renewing');
27433 Roo.log("create toolbars");
27435 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
27436 this.toolbars[0].render(this.toolbarContainer());
27440 // if (!editor.toolbars || !editor.toolbars.length) {
27441 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
27444 // for (var i =0 ; i < editor.toolbars.length;i++) {
27445 // editor.toolbars[i] = Roo.factory(
27446 // typeof(editor.toolbars[i]) == 'string' ?
27447 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
27448 // Roo.bootstrap.HtmlEditor);
27449 // editor.toolbars[i].init(editor);
27455 onRender : function(ct, position)
27457 // Roo.log("Call onRender: " + this.xtype);
27459 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
27461 this.wrap = this.inputEl().wrap({
27462 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
27465 this.editorcore.onRender(ct, position);
27467 if (this.resizable) {
27468 this.resizeEl = new Roo.Resizable(this.wrap, {
27472 minHeight : this.height,
27473 height: this.height,
27474 handles : this.resizable,
27477 resize : function(r, w, h) {
27478 _t.onResize(w,h); // -something
27484 this.createToolbar(this);
27487 if(!this.width && this.resizable){
27488 this.setSize(this.wrap.getSize());
27490 if (this.resizeEl) {
27491 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
27492 // should trigger onReize..
27498 onResize : function(w, h)
27500 Roo.log('resize: ' +w + ',' + h );
27501 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
27505 if(this.inputEl() ){
27506 if(typeof w == 'number'){
27507 var aw = w - this.wrap.getFrameWidth('lr');
27508 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
27511 if(typeof h == 'number'){
27512 var tbh = -11; // fixme it needs to tool bar size!
27513 for (var i =0; i < this.toolbars.length;i++) {
27514 // fixme - ask toolbars for heights?
27515 tbh += this.toolbars[i].el.getHeight();
27516 //if (this.toolbars[i].footer) {
27517 // tbh += this.toolbars[i].footer.el.getHeight();
27525 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
27526 ah -= 5; // knock a few pixes off for look..
27527 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
27531 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
27532 this.editorcore.onResize(ew,eh);
27537 * Toggles the editor between standard and source edit mode.
27538 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
27540 toggleSourceEdit : function(sourceEditMode)
27542 this.editorcore.toggleSourceEdit(sourceEditMode);
27544 if(this.editorcore.sourceEditMode){
27545 Roo.log('editor - showing textarea');
27548 // Roo.log(this.syncValue());
27550 this.inputEl().removeClass(['hide', 'x-hidden']);
27551 this.inputEl().dom.removeAttribute('tabIndex');
27552 this.inputEl().focus();
27554 Roo.log('editor - hiding textarea');
27556 // Roo.log(this.pushValue());
27559 this.inputEl().addClass(['hide', 'x-hidden']);
27560 this.inputEl().dom.setAttribute('tabIndex', -1);
27561 //this.deferFocus();
27564 if(this.resizable){
27565 this.setSize(this.wrap.getSize());
27568 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
27571 // private (for BoxComponent)
27572 adjustSize : Roo.BoxComponent.prototype.adjustSize,
27574 // private (for BoxComponent)
27575 getResizeEl : function(){
27579 // private (for BoxComponent)
27580 getPositionEl : function(){
27585 initEvents : function(){
27586 this.originalValue = this.getValue();
27590 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
27593 // markInvalid : Roo.emptyFn,
27595 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
27598 // clearInvalid : Roo.emptyFn,
27600 setValue : function(v){
27601 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
27602 this.editorcore.pushValue();
27607 deferFocus : function(){
27608 this.focus.defer(10, this);
27612 focus : function(){
27613 this.editorcore.focus();
27619 onDestroy : function(){
27625 for (var i =0; i < this.toolbars.length;i++) {
27626 // fixme - ask toolbars for heights?
27627 this.toolbars[i].onDestroy();
27630 this.wrap.dom.innerHTML = '';
27631 this.wrap.remove();
27636 onFirstFocus : function(){
27637 //Roo.log("onFirstFocus");
27638 this.editorcore.onFirstFocus();
27639 for (var i =0; i < this.toolbars.length;i++) {
27640 this.toolbars[i].onFirstFocus();
27646 syncValue : function()
27648 this.editorcore.syncValue();
27651 pushValue : function()
27653 this.editorcore.pushValue();
27657 // hide stuff that is not compatible
27671 * @event specialkey
27675 * @cfg {String} fieldClass @hide
27678 * @cfg {String} focusClass @hide
27681 * @cfg {String} autoCreate @hide
27684 * @cfg {String} inputType @hide
27688 * @cfg {String} invalidText @hide
27691 * @cfg {String} msgFx @hide
27694 * @cfg {String} validateOnBlur @hide
27703 Roo.namespace('Roo.bootstrap.htmleditor');
27705 * @class Roo.bootstrap.HtmlEditorToolbar1
27711 new Roo.bootstrap.HtmlEditor({
27714 new Roo.bootstrap.HtmlEditorToolbar1({
27715 disable : { fonts: 1 , format: 1, ..., ... , ...],
27721 * @cfg {Object} disable List of elements to disable..
27722 * @cfg {Array} btns List of additional buttons.
27726 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
27729 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
27732 Roo.apply(this, config);
27734 // default disabled, based on 'good practice'..
27735 this.disable = this.disable || {};
27736 Roo.applyIf(this.disable, {
27739 specialElements : true
27741 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
27743 this.editor = config.editor;
27744 this.editorcore = config.editor.editorcore;
27746 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
27748 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
27749 // dont call parent... till later.
27751 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
27756 editorcore : false,
27761 "h1","h2","h3","h4","h5","h6",
27763 "abbr", "acronym", "address", "cite", "samp", "var",
27767 onRender : function(ct, position)
27769 // Roo.log("Call onRender: " + this.xtype);
27771 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
27773 this.el.dom.style.marginBottom = '0';
27775 var editorcore = this.editorcore;
27776 var editor= this.editor;
27779 var btn = function(id,cmd , toggle, handler, html){
27781 var event = toggle ? 'toggle' : 'click';
27786 xns: Roo.bootstrap,
27790 enableToggle:toggle !== false,
27792 pressed : toggle ? false : null,
27795 a.listeners[toggle ? 'toggle' : 'click'] = function() {
27796 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
27802 // var cb_box = function...
27807 xns: Roo.bootstrap,
27812 xns: Roo.bootstrap,
27816 Roo.each(this.formats, function(f) {
27817 style.menu.items.push({
27819 xns: Roo.bootstrap,
27820 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
27825 editorcore.insertTag(this.tagname);
27832 children.push(style);
27834 btn('bold',false,true);
27835 btn('italic',false,true);
27836 btn('align-left', 'justifyleft',true);
27837 btn('align-center', 'justifycenter',true);
27838 btn('align-right' , 'justifyright',true);
27839 btn('link', false, false, function(btn) {
27840 //Roo.log("create link?");
27841 var url = prompt(this.createLinkText, this.defaultLinkValue);
27842 if(url && url != 'http:/'+'/'){
27843 this.editorcore.relayCmd('createlink', url);
27846 btn('list','insertunorderedlist',true);
27847 btn('pencil', false,true, function(btn){
27849 this.toggleSourceEdit(btn.pressed);
27852 if (this.editor.btns.length > 0) {
27853 for (var i = 0; i<this.editor.btns.length; i++) {
27854 children.push(this.editor.btns[i]);
27862 xns: Roo.bootstrap,
27867 xns: Roo.bootstrap,
27872 cog.menu.items.push({
27874 xns: Roo.bootstrap,
27875 html : Clean styles,
27880 editorcore.insertTag(this.tagname);
27889 this.xtype = 'NavSimplebar';
27891 for(var i=0;i< children.length;i++) {
27893 this.buttons.add(this.addxtypeChild(children[i]));
27897 editor.on('editorevent', this.updateToolbar, this);
27899 onBtnClick : function(id)
27901 this.editorcore.relayCmd(id);
27902 this.editorcore.focus();
27906 * Protected method that will not generally be called directly. It triggers
27907 * a toolbar update by reading the markup state of the current selection in the editor.
27909 updateToolbar: function(){
27911 if(!this.editorcore.activated){
27912 this.editor.onFirstFocus(); // is this neeed?
27916 var btns = this.buttons;
27917 var doc = this.editorcore.doc;
27918 btns.get('bold').setActive(doc.queryCommandState('bold'));
27919 btns.get('italic').setActive(doc.queryCommandState('italic'));
27920 //btns.get('underline').setActive(doc.queryCommandState('underline'));
27922 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
27923 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
27924 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
27926 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
27927 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
27930 var ans = this.editorcore.getAllAncestors();
27931 if (this.formatCombo) {
27934 var store = this.formatCombo.store;
27935 this.formatCombo.setValue("");
27936 for (var i =0; i < ans.length;i++) {
27937 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
27939 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
27947 // hides menus... - so this cant be on a menu...
27948 Roo.bootstrap.MenuMgr.hideAll();
27950 Roo.bootstrap.MenuMgr.hideAll();
27951 //this.editorsyncValue();
27953 onFirstFocus: function() {
27954 this.buttons.each(function(item){
27958 toggleSourceEdit : function(sourceEditMode){
27961 if(sourceEditMode){
27962 Roo.log("disabling buttons");
27963 this.buttons.each( function(item){
27964 if(item.cmd != 'pencil'){
27970 Roo.log("enabling buttons");
27971 if(this.editorcore.initialized){
27972 this.buttons.each( function(item){
27978 Roo.log("calling toggole on editor");
27979 // tell the editor that it's been pressed..
27980 this.editor.toggleSourceEdit(sourceEditMode);
27994 * @class Roo.bootstrap.Markdown
27995 * @extends Roo.bootstrap.TextArea
27996 * Bootstrap Showdown editable area
27997 * @cfg {string} content
28000 * Create a new Showdown
28003 Roo.bootstrap.Markdown = function(config){
28004 Roo.bootstrap.Markdown.superclass.constructor.call(this, config);
28008 Roo.extend(Roo.bootstrap.Markdown, Roo.bootstrap.TextArea, {
28012 initEvents : function()
28015 Roo.bootstrap.TextArea.prototype.initEvents.call(this);
28016 this.markdownEl = this.el.createChild({
28017 cls : 'roo-markdown-area'
28019 this.inputEl().addClass('d-none');
28020 if (this.getValue() == '') {
28021 this.markdownEl.dom.innerHTML = String.format('<span class="roo-placeholder">{0}</span>', this.placeholder || '');
28024 this.markdownEl.dom.innerHTML = Roo.Markdown.toHtml(Roo.util.Format.htmlEncode(this.getValue()));
28026 this.markdownEl.on('click', this.toggleTextEdit, this);
28027 this.on('blur', this.toggleTextEdit, this);
28028 this.on('specialkey', this.resizeTextArea, this);
28031 toggleTextEdit : function()
28033 var sh = this.markdownEl.getHeight();
28034 this.inputEl().addClass('d-none');
28035 this.markdownEl.addClass('d-none');
28036 if (!this.editing) {
28038 this.inputEl().setHeight(Math.min(500, Math.max(sh,(this.getValue().split("\n").length+1) * 30)));
28039 this.inputEl().removeClass('d-none');
28040 this.inputEl().focus();
28041 this.editing = true;
28044 // show showdown...
28045 this.updateMarkdown();
28046 this.markdownEl.removeClass('d-none');
28047 this.editing = false;
28050 updateMarkdown : function()
28052 if (this.getValue() == '') {
28053 this.markdownEl.dom.innerHTML = String.format('<span class="roo-placeholder">{0}</span>', this.placeholder || '');
28057 this.markdownEl.dom.innerHTML = Roo.Markdown.toHtml(Roo.util.Format.htmlEncode(this.getValue()));
28060 resizeTextArea: function () {
28063 Roo.log([sh, this.getValue().split("\n").length * 30]);
28064 this.inputEl().setHeight(Math.min(500, Math.max(sh, (this.getValue().split("\n").length +1) * 30)));
28066 setValue : function(val)
28068 Roo.bootstrap.TextArea.prototype.setValue.call(this,val);
28069 if (!this.editing) {
28070 this.updateMarkdown();
28076 if (!this.editing) {
28077 this.toggleTextEdit();
28085 * Ext JS Library 1.1.1
28086 * Copyright(c) 2006-2007, Ext JS, LLC.
28088 * Originally Released Under LGPL - original licence link has changed is not relivant.
28091 * <script type="text/javascript">
28095 * @class Roo.bootstrap.PagingToolbar
28096 * @extends Roo.bootstrap.NavSimplebar
28097 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
28099 * Create a new PagingToolbar
28100 * @param {Object} config The config object
28101 * @param {Roo.data.Store} store
28103 Roo.bootstrap.PagingToolbar = function(config)
28105 // old args format still supported... - xtype is prefered..
28106 // created from xtype...
28108 this.ds = config.dataSource;
28110 if (config.store && !this.ds) {
28111 this.store= Roo.factory(config.store, Roo.data);
28112 this.ds = this.store;
28113 this.ds.xmodule = this.xmodule || false;
28116 this.toolbarItems = [];
28117 if (config.items) {
28118 this.toolbarItems = config.items;
28121 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
28126 this.bind(this.ds);
28129 if (Roo.bootstrap.version == 4) {
28130 this.navgroup = new Roo.bootstrap.ButtonGroup({ cls: 'pagination' });
28132 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
28137 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
28139 * @cfg {Roo.data.Store} dataSource
28140 * The underlying data store providing the paged data
28143 * @cfg {String/HTMLElement/Element} container
28144 * container The id or element that will contain the toolbar
28147 * @cfg {Boolean} displayInfo
28148 * True to display the displayMsg (defaults to false)
28151 * @cfg {Number} pageSize
28152 * The number of records to display per page (defaults to 20)
28156 * @cfg {String} displayMsg
28157 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
28159 displayMsg : 'Displaying {0} - {1} of {2}',
28161 * @cfg {String} emptyMsg
28162 * The message to display when no records are found (defaults to "No data to display")
28164 emptyMsg : 'No data to display',
28166 * Customizable piece of the default paging text (defaults to "Page")
28169 beforePageText : "Page",
28171 * Customizable piece of the default paging text (defaults to "of %0")
28174 afterPageText : "of {0}",
28176 * Customizable piece of the default paging text (defaults to "First Page")
28179 firstText : "First Page",
28181 * Customizable piece of the default paging text (defaults to "Previous Page")
28184 prevText : "Previous Page",
28186 * Customizable piece of the default paging text (defaults to "Next Page")
28189 nextText : "Next Page",
28191 * Customizable piece of the default paging text (defaults to "Last Page")
28194 lastText : "Last Page",
28196 * Customizable piece of the default paging text (defaults to "Refresh")
28199 refreshText : "Refresh",
28203 onRender : function(ct, position)
28205 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
28206 this.navgroup.parentId = this.id;
28207 this.navgroup.onRender(this.el, null);
28208 // add the buttons to the navgroup
28210 if(this.displayInfo){
28211 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
28212 this.displayEl = this.el.select('.x-paging-info', true).first();
28213 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
28214 // this.displayEl = navel.el.select('span',true).first();
28220 Roo.each(_this.buttons, function(e){ // this might need to use render????
28221 Roo.factory(e).render(_this.el);
28225 Roo.each(_this.toolbarItems, function(e) {
28226 _this.navgroup.addItem(e);
28230 this.first = this.navgroup.addItem({
28231 tooltip: this.firstText,
28232 cls: "prev btn-outline-secondary",
28233 html : ' <i class="fa fa-step-backward"></i>',
28235 preventDefault: true,
28236 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
28239 this.prev = this.navgroup.addItem({
28240 tooltip: this.prevText,
28241 cls: "prev btn-outline-secondary",
28242 html : ' <i class="fa fa-backward"></i>',
28244 preventDefault: true,
28245 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
28247 //this.addSeparator();
28250 var field = this.navgroup.addItem( {
28252 cls : 'x-paging-position btn-outline-secondary',
28254 html : this.beforePageText +
28255 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
28256 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
28259 this.field = field.el.select('input', true).first();
28260 this.field.on("keydown", this.onPagingKeydown, this);
28261 this.field.on("focus", function(){this.dom.select();});
28264 this.afterTextEl = field.el.select('.x-paging-after',true).first();
28265 //this.field.setHeight(18);
28266 //this.addSeparator();
28267 this.next = this.navgroup.addItem({
28268 tooltip: this.nextText,
28269 cls: "next btn-outline-secondary",
28270 html : ' <i class="fa fa-forward"></i>',
28272 preventDefault: true,
28273 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
28275 this.last = this.navgroup.addItem({
28276 tooltip: this.lastText,
28277 html : ' <i class="fa fa-step-forward"></i>',
28278 cls: "next btn-outline-secondary",
28280 preventDefault: true,
28281 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
28283 //this.addSeparator();
28284 this.loading = this.navgroup.addItem({
28285 tooltip: this.refreshText,
28286 cls: "btn-outline-secondary",
28287 html : ' <i class="fa fa-refresh"></i>',
28288 preventDefault: true,
28289 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
28295 updateInfo : function(){
28296 if(this.displayEl){
28297 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
28298 var msg = count == 0 ?
28302 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
28304 this.displayEl.update(msg);
28309 onLoad : function(ds, r, o)
28311 this.cursor = o.params && o.params.start ? o.params.start : 0;
28313 var d = this.getPageData(),
28318 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
28319 this.field.dom.value = ap;
28320 this.first.setDisabled(ap == 1);
28321 this.prev.setDisabled(ap == 1);
28322 this.next.setDisabled(ap == ps);
28323 this.last.setDisabled(ap == ps);
28324 this.loading.enable();
28329 getPageData : function(){
28330 var total = this.ds.getTotalCount();
28333 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
28334 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
28339 onLoadError : function(){
28340 this.loading.enable();
28344 onPagingKeydown : function(e){
28345 var k = e.getKey();
28346 var d = this.getPageData();
28348 var v = this.field.dom.value, pageNum;
28349 if(!v || isNaN(pageNum = parseInt(v, 10))){
28350 this.field.dom.value = d.activePage;
28353 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
28354 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
28357 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))
28359 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
28360 this.field.dom.value = pageNum;
28361 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
28364 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
28366 var v = this.field.dom.value, pageNum;
28367 var increment = (e.shiftKey) ? 10 : 1;
28368 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
28371 if(!v || isNaN(pageNum = parseInt(v, 10))) {
28372 this.field.dom.value = d.activePage;
28375 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
28377 this.field.dom.value = parseInt(v, 10) + increment;
28378 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
28379 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
28386 beforeLoad : function(){
28388 this.loading.disable();
28393 onClick : function(which){
28402 ds.load({params:{start: 0, limit: this.pageSize}});
28405 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
28408 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
28411 var total = ds.getTotalCount();
28412 var extra = total % this.pageSize;
28413 var lastStart = extra ? (total - extra) : total-this.pageSize;
28414 ds.load({params:{start: lastStart, limit: this.pageSize}});
28417 ds.load({params:{start: this.cursor, limit: this.pageSize}});
28423 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
28424 * @param {Roo.data.Store} store The data store to unbind
28426 unbind : function(ds){
28427 ds.un("beforeload", this.beforeLoad, this);
28428 ds.un("load", this.onLoad, this);
28429 ds.un("loadexception", this.onLoadError, this);
28430 ds.un("remove", this.updateInfo, this);
28431 ds.un("add", this.updateInfo, this);
28432 this.ds = undefined;
28436 * Binds the paging toolbar to the specified {@link Roo.data.Store}
28437 * @param {Roo.data.Store} store The data store to bind
28439 bind : function(ds){
28440 ds.on("beforeload", this.beforeLoad, this);
28441 ds.on("load", this.onLoad, this);
28442 ds.on("loadexception", this.onLoadError, this);
28443 ds.on("remove", this.updateInfo, this);
28444 ds.on("add", this.updateInfo, this);
28455 * @class Roo.bootstrap.MessageBar
28456 * @extends Roo.bootstrap.Component
28457 * Bootstrap MessageBar class
28458 * @cfg {String} html contents of the MessageBar
28459 * @cfg {String} weight (info | success | warning | danger) default info
28460 * @cfg {String} beforeClass insert the bar before the given class
28461 * @cfg {Boolean} closable (true | false) default false
28462 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
28465 * Create a new Element
28466 * @param {Object} config The config object
28469 Roo.bootstrap.MessageBar = function(config){
28470 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
28473 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
28479 beforeClass: 'bootstrap-sticky-wrap',
28481 getAutoCreate : function(){
28485 cls: 'alert alert-dismissable alert-' + this.weight,
28490 html: this.html || ''
28496 cfg.cls += ' alert-messages-fixed';
28510 onRender : function(ct, position)
28512 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
28515 var cfg = Roo.apply({}, this.getAutoCreate());
28519 cfg.cls += ' ' + this.cls;
28522 cfg.style = this.style;
28524 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
28526 this.el.setVisibilityMode(Roo.Element.DISPLAY);
28529 this.el.select('>button.close').on('click', this.hide, this);
28535 if (!this.rendered) {
28541 this.fireEvent('show', this);
28547 if (!this.rendered) {
28553 this.fireEvent('hide', this);
28556 update : function()
28558 // var e = this.el.dom.firstChild;
28560 // if(this.closable){
28561 // e = e.nextSibling;
28564 // e.data = this.html || '';
28566 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
28582 * @class Roo.bootstrap.Graph
28583 * @extends Roo.bootstrap.Component
28584 * Bootstrap Graph class
28588 @cfg {String} graphtype bar | vbar | pie
28589 @cfg {number} g_x coodinator | centre x (pie)
28590 @cfg {number} g_y coodinator | centre y (pie)
28591 @cfg {number} g_r radius (pie)
28592 @cfg {number} g_height height of the chart (respected by all elements in the set)
28593 @cfg {number} g_width width of the chart (respected by all elements in the set)
28594 @cfg {Object} title The title of the chart
28597 -opts (object) options for the chart
28599 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
28600 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
28602 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.
28603 o stacked (boolean) whether or not to tread values as in a stacked bar chart
28605 o stretch (boolean)
28607 -opts (object) options for the pie
28610 o startAngle (number)
28611 o endAngle (number)
28615 * Create a new Input
28616 * @param {Object} config The config object
28619 Roo.bootstrap.Graph = function(config){
28620 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
28626 * The img click event for the img.
28627 * @param {Roo.EventObject} e
28633 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
28644 //g_colors: this.colors,
28651 getAutoCreate : function(){
28662 onRender : function(ct,position){
28665 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
28667 if (typeof(Raphael) == 'undefined') {
28668 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
28672 this.raphael = Raphael(this.el.dom);
28674 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
28675 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
28676 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
28677 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
28679 r.text(160, 10, "Single Series Chart").attr(txtattr);
28680 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
28681 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
28682 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
28684 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
28685 r.barchart(330, 10, 300, 220, data1);
28686 r.barchart(10, 250, 300, 220, data2, {stacked: true});
28687 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
28690 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
28691 // r.barchart(30, 30, 560, 250, xdata, {
28692 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
28693 // axis : "0 0 1 1",
28694 // axisxlabels : xdata
28695 // //yvalues : cols,
28698 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
28700 // this.load(null,xdata,{
28701 // axis : "0 0 1 1",
28702 // axisxlabels : xdata
28707 load : function(graphtype,xdata,opts)
28709 this.raphael.clear();
28711 graphtype = this.graphtype;
28716 var r = this.raphael,
28717 fin = function () {
28718 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
28720 fout = function () {
28721 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
28723 pfin = function() {
28724 this.sector.stop();
28725 this.sector.scale(1.1, 1.1, this.cx, this.cy);
28728 this.label[0].stop();
28729 this.label[0].attr({ r: 7.5 });
28730 this.label[1].attr({ "font-weight": 800 });
28733 pfout = function() {
28734 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
28737 this.label[0].animate({ r: 5 }, 500, "bounce");
28738 this.label[1].attr({ "font-weight": 400 });
28744 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
28747 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
28750 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
28751 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
28753 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
28760 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
28765 setTitle: function(o)
28770 initEvents: function() {
28773 this.el.on('click', this.onClick, this);
28777 onClick : function(e)
28779 Roo.log('img onclick');
28780 this.fireEvent('click', this, e);
28792 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
28795 * @class Roo.bootstrap.dash.NumberBox
28796 * @extends Roo.bootstrap.Component
28797 * Bootstrap NumberBox class
28798 * @cfg {String} headline Box headline
28799 * @cfg {String} content Box content
28800 * @cfg {String} icon Box icon
28801 * @cfg {String} footer Footer text
28802 * @cfg {String} fhref Footer href
28805 * Create a new NumberBox
28806 * @param {Object} config The config object
28810 Roo.bootstrap.dash.NumberBox = function(config){
28811 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
28815 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
28824 getAutoCreate : function(){
28828 cls : 'small-box ',
28836 cls : 'roo-headline',
28837 html : this.headline
28841 cls : 'roo-content',
28842 html : this.content
28856 cls : 'ion ' + this.icon
28865 cls : 'small-box-footer',
28866 href : this.fhref || '#',
28870 cfg.cn.push(footer);
28877 onRender : function(ct,position){
28878 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
28885 setHeadline: function (value)
28887 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
28890 setFooter: function (value, href)
28892 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
28895 this.el.select('a.small-box-footer',true).first().attr('href', href);
28900 setContent: function (value)
28902 this.el.select('.roo-content',true).first().dom.innerHTML = value;
28905 initEvents: function()
28919 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
28922 * @class Roo.bootstrap.dash.TabBox
28923 * @extends Roo.bootstrap.Component
28924 * Bootstrap TabBox class
28925 * @cfg {String} title Title of the TabBox
28926 * @cfg {String} icon Icon of the TabBox
28927 * @cfg {Boolean} showtabs (true|false) show the tabs default true
28928 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
28931 * Create a new TabBox
28932 * @param {Object} config The config object
28936 Roo.bootstrap.dash.TabBox = function(config){
28937 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
28942 * When a pane is added
28943 * @param {Roo.bootstrap.dash.TabPane} pane
28947 * @event activatepane
28948 * When a pane is activated
28949 * @param {Roo.bootstrap.dash.TabPane} pane
28951 "activatepane" : true
28959 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
28964 tabScrollable : false,
28966 getChildContainer : function()
28968 return this.el.select('.tab-content', true).first();
28971 getAutoCreate : function(){
28975 cls: 'pull-left header',
28983 cls: 'fa ' + this.icon
28989 cls: 'nav nav-tabs pull-right',
28995 if(this.tabScrollable){
29002 cls: 'nav nav-tabs pull-right',
29013 cls: 'nav-tabs-custom',
29018 cls: 'tab-content no-padding',
29026 initEvents : function()
29028 //Roo.log('add add pane handler');
29029 this.on('addpane', this.onAddPane, this);
29032 * Updates the box title
29033 * @param {String} html to set the title to.
29035 setTitle : function(value)
29037 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
29039 onAddPane : function(pane)
29041 this.panes.push(pane);
29042 //Roo.log('addpane');
29044 // tabs are rendere left to right..
29045 if(!this.showtabs){
29049 var ctr = this.el.select('.nav-tabs', true).first();
29052 var existing = ctr.select('.nav-tab',true);
29053 var qty = existing.getCount();;
29056 var tab = ctr.createChild({
29058 cls : 'nav-tab' + (qty ? '' : ' active'),
29066 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
29069 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
29071 pane.el.addClass('active');
29076 onTabClick : function(ev,un,ob,pane)
29078 //Roo.log('tab - prev default');
29079 ev.preventDefault();
29082 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
29083 pane.tab.addClass('active');
29084 //Roo.log(pane.title);
29085 this.getChildContainer().select('.tab-pane',true).removeClass('active');
29086 // technically we should have a deactivate event.. but maybe add later.
29087 // and it should not de-activate the selected tab...
29088 this.fireEvent('activatepane', pane);
29089 pane.el.addClass('active');
29090 pane.fireEvent('activate');
29095 getActivePane : function()
29098 Roo.each(this.panes, function(p) {
29099 if(p.el.hasClass('active')){
29120 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
29122 * @class Roo.bootstrap.TabPane
29123 * @extends Roo.bootstrap.Component
29124 * Bootstrap TabPane class
29125 * @cfg {Boolean} active (false | true) Default false
29126 * @cfg {String} title title of panel
29130 * Create a new TabPane
29131 * @param {Object} config The config object
29134 Roo.bootstrap.dash.TabPane = function(config){
29135 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
29141 * When a pane is activated
29142 * @param {Roo.bootstrap.dash.TabPane} pane
29149 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
29154 // the tabBox that this is attached to.
29157 getAutoCreate : function()
29165 cfg.cls += ' active';
29170 initEvents : function()
29172 //Roo.log('trigger add pane handler');
29173 this.parent().fireEvent('addpane', this)
29177 * Updates the tab title
29178 * @param {String} html to set the title to.
29180 setTitle: function(str)
29186 this.tab.select('a', true).first().dom.innerHTML = str;
29203 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
29206 * @class Roo.bootstrap.menu.Menu
29207 * @extends Roo.bootstrap.Component
29208 * Bootstrap Menu class - container for Menu
29209 * @cfg {String} html Text of the menu
29210 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
29211 * @cfg {String} icon Font awesome icon
29212 * @cfg {String} pos Menu align to (top | bottom) default bottom
29216 * Create a new Menu
29217 * @param {Object} config The config object
29221 Roo.bootstrap.menu.Menu = function(config){
29222 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
29226 * @event beforeshow
29227 * Fires before this menu is displayed
29228 * @param {Roo.bootstrap.menu.Menu} this
29232 * @event beforehide
29233 * Fires before this menu is hidden
29234 * @param {Roo.bootstrap.menu.Menu} this
29239 * Fires after this menu is displayed
29240 * @param {Roo.bootstrap.menu.Menu} this
29245 * Fires after this menu is hidden
29246 * @param {Roo.bootstrap.menu.Menu} this
29251 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
29252 * @param {Roo.bootstrap.menu.Menu} this
29253 * @param {Roo.EventObject} e
29260 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
29264 weight : 'default',
29269 getChildContainer : function() {
29270 if(this.isSubMenu){
29274 return this.el.select('ul.dropdown-menu', true).first();
29277 getAutoCreate : function()
29282 cls : 'roo-menu-text',
29290 cls : 'fa ' + this.icon
29301 cls : 'dropdown-button btn btn-' + this.weight,
29306 cls : 'dropdown-toggle btn btn-' + this.weight,
29316 cls : 'dropdown-menu'
29322 if(this.pos == 'top'){
29323 cfg.cls += ' dropup';
29326 if(this.isSubMenu){
29329 cls : 'dropdown-menu'
29336 onRender : function(ct, position)
29338 this.isSubMenu = ct.hasClass('dropdown-submenu');
29340 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
29343 initEvents : function()
29345 if(this.isSubMenu){
29349 this.hidden = true;
29351 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
29352 this.triggerEl.on('click', this.onTriggerPress, this);
29354 this.buttonEl = this.el.select('button.dropdown-button', true).first();
29355 this.buttonEl.on('click', this.onClick, this);
29361 if(this.isSubMenu){
29365 return this.el.select('ul.dropdown-menu', true).first();
29368 onClick : function(e)
29370 this.fireEvent("click", this, e);
29373 onTriggerPress : function(e)
29375 if (this.isVisible()) {
29382 isVisible : function(){
29383 return !this.hidden;
29388 this.fireEvent("beforeshow", this);
29390 this.hidden = false;
29391 this.el.addClass('open');
29393 Roo.get(document).on("mouseup", this.onMouseUp, this);
29395 this.fireEvent("show", this);
29402 this.fireEvent("beforehide", this);
29404 this.hidden = true;
29405 this.el.removeClass('open');
29407 Roo.get(document).un("mouseup", this.onMouseUp);
29409 this.fireEvent("hide", this);
29412 onMouseUp : function()
29426 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
29429 * @class Roo.bootstrap.menu.Item
29430 * @extends Roo.bootstrap.Component
29431 * Bootstrap MenuItem class
29432 * @cfg {Boolean} submenu (true | false) default false
29433 * @cfg {String} html text of the item
29434 * @cfg {String} href the link
29435 * @cfg {Boolean} disable (true | false) default false
29436 * @cfg {Boolean} preventDefault (true | false) default true
29437 * @cfg {String} icon Font awesome icon
29438 * @cfg {String} pos Submenu align to (left | right) default right
29442 * Create a new Item
29443 * @param {Object} config The config object
29447 Roo.bootstrap.menu.Item = function(config){
29448 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
29452 * Fires when the mouse is hovering over this menu
29453 * @param {Roo.bootstrap.menu.Item} this
29454 * @param {Roo.EventObject} e
29459 * Fires when the mouse exits this menu
29460 * @param {Roo.bootstrap.menu.Item} this
29461 * @param {Roo.EventObject} e
29467 * The raw click event for the entire grid.
29468 * @param {Roo.EventObject} e
29474 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
29479 preventDefault: true,
29484 getAutoCreate : function()
29489 cls : 'roo-menu-item-text',
29497 cls : 'fa ' + this.icon
29506 href : this.href || '#',
29513 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
29517 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
29519 if(this.pos == 'left'){
29520 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
29527 initEvents : function()
29529 this.el.on('mouseover', this.onMouseOver, this);
29530 this.el.on('mouseout', this.onMouseOut, this);
29532 this.el.select('a', true).first().on('click', this.onClick, this);
29536 onClick : function(e)
29538 if(this.preventDefault){
29539 e.preventDefault();
29542 this.fireEvent("click", this, e);
29545 onMouseOver : function(e)
29547 if(this.submenu && this.pos == 'left'){
29548 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
29551 this.fireEvent("mouseover", this, e);
29554 onMouseOut : function(e)
29556 this.fireEvent("mouseout", this, e);
29568 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
29571 * @class Roo.bootstrap.menu.Separator
29572 * @extends Roo.bootstrap.Component
29573 * Bootstrap Separator class
29576 * Create a new Separator
29577 * @param {Object} config The config object
29581 Roo.bootstrap.menu.Separator = function(config){
29582 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
29585 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
29587 getAutoCreate : function(){
29590 cls: 'dropdown-divider divider'
29608 * @class Roo.bootstrap.Tooltip
29609 * Bootstrap Tooltip class
29610 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
29611 * to determine which dom element triggers the tooltip.
29613 * It needs to add support for additional attributes like tooltip-position
29616 * Create a new Toolti
29617 * @param {Object} config The config object
29620 Roo.bootstrap.Tooltip = function(config){
29621 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
29623 this.alignment = Roo.bootstrap.Tooltip.alignment;
29625 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
29626 this.alignment = config.alignment;
29631 Roo.apply(Roo.bootstrap.Tooltip, {
29633 * @function init initialize tooltip monitoring.
29637 currentTip : false,
29638 currentRegion : false,
29644 Roo.get(document).on('mouseover', this.enter ,this);
29645 Roo.get(document).on('mouseout', this.leave, this);
29648 this.currentTip = new Roo.bootstrap.Tooltip();
29651 enter : function(ev)
29653 var dom = ev.getTarget();
29655 //Roo.log(['enter',dom]);
29656 var el = Roo.fly(dom);
29657 if (this.currentEl) {
29659 //Roo.log(this.currentEl);
29660 //Roo.log(this.currentEl.contains(dom));
29661 if (this.currentEl == el) {
29664 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
29670 if (this.currentTip.el) {
29671 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
29675 if(!el || el.dom == document){
29681 if (!el.attr('tooltip')) {
29682 pel = el.findParent("[tooltip]");
29684 bindEl = Roo.get(pel);
29690 // you can not look for children, as if el is the body.. then everythign is the child..
29691 if (!pel && !el.attr('tooltip')) { //
29692 if (!el.select("[tooltip]").elements.length) {
29695 // is the mouse over this child...?
29696 bindEl = el.select("[tooltip]").first();
29697 var xy = ev.getXY();
29698 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
29699 //Roo.log("not in region.");
29702 //Roo.log("child element over..");
29705 this.currentEl = el;
29706 this.currentTip.bind(bindEl);
29707 this.currentRegion = Roo.lib.Region.getRegion(dom);
29708 this.currentTip.enter();
29711 leave : function(ev)
29713 var dom = ev.getTarget();
29714 //Roo.log(['leave',dom]);
29715 if (!this.currentEl) {
29720 if (dom != this.currentEl.dom) {
29723 var xy = ev.getXY();
29724 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
29727 // only activate leave if mouse cursor is outside... bounding box..
29732 if (this.currentTip) {
29733 this.currentTip.leave();
29735 //Roo.log('clear currentEl');
29736 this.currentEl = false;
29741 'left' : ['r-l', [-2,0], 'right'],
29742 'right' : ['l-r', [2,0], 'left'],
29743 'bottom' : ['t-b', [0,2], 'top'],
29744 'top' : [ 'b-t', [0,-2], 'bottom']
29750 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
29755 delay : null, // can be { show : 300 , hide: 500}
29759 hoverState : null, //???
29761 placement : 'bottom',
29765 getAutoCreate : function(){
29772 cls : 'tooltip-arrow arrow'
29775 cls : 'tooltip-inner'
29782 bind : function(el)
29787 initEvents : function()
29789 this.arrowEl = this.el.select('.arrow', true).first();
29790 this.innerEl = this.el.select('.tooltip-inner', true).first();
29793 enter : function () {
29795 if (this.timeout != null) {
29796 clearTimeout(this.timeout);
29799 this.hoverState = 'in';
29800 //Roo.log("enter - show");
29801 if (!this.delay || !this.delay.show) {
29806 this.timeout = setTimeout(function () {
29807 if (_t.hoverState == 'in') {
29810 }, this.delay.show);
29814 clearTimeout(this.timeout);
29816 this.hoverState = 'out';
29817 if (!this.delay || !this.delay.hide) {
29823 this.timeout = setTimeout(function () {
29824 //Roo.log("leave - timeout");
29826 if (_t.hoverState == 'out') {
29828 Roo.bootstrap.Tooltip.currentEl = false;
29833 show : function (msg)
29836 this.render(document.body);
29839 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
29841 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
29843 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
29845 this.el.removeClass(['fade','top','bottom', 'left', 'right','in',
29846 'bs-tooltip-top','bs-tooltip-bottom', 'bs-tooltip-left', 'bs-tooltip-right']);
29848 var placement = typeof this.placement == 'function' ?
29849 this.placement.call(this, this.el, on_el) :
29852 var autoToken = /\s?auto?\s?/i;
29853 var autoPlace = autoToken.test(placement);
29855 placement = placement.replace(autoToken, '') || 'top';
29859 //this.el.setXY([0,0]);
29861 //this.el.dom.style.display='block';
29863 //this.el.appendTo(on_el);
29865 var p = this.getPosition();
29866 var box = this.el.getBox();
29872 var align = this.alignment[placement];
29874 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
29876 if(placement == 'top' || placement == 'bottom'){
29878 placement = 'right';
29881 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
29882 placement = 'left';
29885 var scroll = Roo.select('body', true).first().getScroll();
29887 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
29891 align = this.alignment[placement];
29893 this.arrowEl.setLeft((this.innerEl.getWidth()/2) - 5);
29897 var elems = document.getElementsByTagName('div');
29898 var highest = Number.MIN_SAFE_INTEGER || -(Math.pow(2, 53) - 1);
29899 for (var i = 0; i < elems.length; i++) {
29900 var zindex = Number.parseInt(
29901 document.defaultView.getComputedStyle(elems[i], null).getPropertyValue("z-index"),
29904 if (zindex > highest) {
29911 this.el.dom.style.zIndex = highest;
29913 this.el.alignTo(this.bindEl, align[0],align[1]);
29914 //var arrow = this.el.select('.arrow',true).first();
29915 //arrow.set(align[2],
29917 this.el.addClass(placement);
29918 this.el.addClass("bs-tooltip-"+ placement);
29920 this.el.addClass('in fade show');
29922 this.hoverState = null;
29924 if (this.el.hasClass('fade')) {
29939 //this.el.setXY([0,0]);
29940 this.el.removeClass(['show', 'in']);
29956 * @class Roo.bootstrap.LocationPicker
29957 * @extends Roo.bootstrap.Component
29958 * Bootstrap LocationPicker class
29959 * @cfg {Number} latitude Position when init default 0
29960 * @cfg {Number} longitude Position when init default 0
29961 * @cfg {Number} zoom default 15
29962 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
29963 * @cfg {Boolean} mapTypeControl default false
29964 * @cfg {Boolean} disableDoubleClickZoom default false
29965 * @cfg {Boolean} scrollwheel default true
29966 * @cfg {Boolean} streetViewControl default false
29967 * @cfg {Number} radius default 0
29968 * @cfg {String} locationName
29969 * @cfg {Boolean} draggable default true
29970 * @cfg {Boolean} enableAutocomplete default false
29971 * @cfg {Boolean} enableReverseGeocode default true
29972 * @cfg {String} markerTitle
29975 * Create a new LocationPicker
29976 * @param {Object} config The config object
29980 Roo.bootstrap.LocationPicker = function(config){
29982 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
29987 * Fires when the picker initialized.
29988 * @param {Roo.bootstrap.LocationPicker} this
29989 * @param {Google Location} location
29993 * @event positionchanged
29994 * Fires when the picker position changed.
29995 * @param {Roo.bootstrap.LocationPicker} this
29996 * @param {Google Location} location
29998 positionchanged : true,
30001 * Fires when the map resize.
30002 * @param {Roo.bootstrap.LocationPicker} this
30007 * Fires when the map show.
30008 * @param {Roo.bootstrap.LocationPicker} this
30013 * Fires when the map hide.
30014 * @param {Roo.bootstrap.LocationPicker} this
30019 * Fires when click the map.
30020 * @param {Roo.bootstrap.LocationPicker} this
30021 * @param {Map event} e
30025 * @event mapRightClick
30026 * Fires when right click the map.
30027 * @param {Roo.bootstrap.LocationPicker} this
30028 * @param {Map event} e
30030 mapRightClick : true,
30032 * @event markerClick
30033 * Fires when click the marker.
30034 * @param {Roo.bootstrap.LocationPicker} this
30035 * @param {Map event} e
30037 markerClick : true,
30039 * @event markerRightClick
30040 * Fires when right click the marker.
30041 * @param {Roo.bootstrap.LocationPicker} this
30042 * @param {Map event} e
30044 markerRightClick : true,
30046 * @event OverlayViewDraw
30047 * Fires when OverlayView Draw
30048 * @param {Roo.bootstrap.LocationPicker} this
30050 OverlayViewDraw : true,
30052 * @event OverlayViewOnAdd
30053 * Fires when OverlayView Draw
30054 * @param {Roo.bootstrap.LocationPicker} this
30056 OverlayViewOnAdd : true,
30058 * @event OverlayViewOnRemove
30059 * Fires when OverlayView Draw
30060 * @param {Roo.bootstrap.LocationPicker} this
30062 OverlayViewOnRemove : true,
30064 * @event OverlayViewShow
30065 * Fires when OverlayView Draw
30066 * @param {Roo.bootstrap.LocationPicker} this
30067 * @param {Pixel} cpx
30069 OverlayViewShow : true,
30071 * @event OverlayViewHide
30072 * Fires when OverlayView Draw
30073 * @param {Roo.bootstrap.LocationPicker} this
30075 OverlayViewHide : true,
30077 * @event loadexception
30078 * Fires when load google lib failed.
30079 * @param {Roo.bootstrap.LocationPicker} this
30081 loadexception : true
30086 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
30088 gMapContext: false,
30094 mapTypeControl: false,
30095 disableDoubleClickZoom: false,
30097 streetViewControl: false,
30101 enableAutocomplete: false,
30102 enableReverseGeocode: true,
30105 getAutoCreate: function()
30110 cls: 'roo-location-picker'
30116 initEvents: function(ct, position)
30118 if(!this.el.getWidth() || this.isApplied()){
30122 this.el.setVisibilityMode(Roo.Element.DISPLAY);
30127 initial: function()
30129 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
30130 this.fireEvent('loadexception', this);
30134 if(!this.mapTypeId){
30135 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
30138 this.gMapContext = this.GMapContext();
30140 this.initOverlayView();
30142 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
30146 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
30147 _this.setPosition(_this.gMapContext.marker.position);
30150 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
30151 _this.fireEvent('mapClick', this, event);
30155 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
30156 _this.fireEvent('mapRightClick', this, event);
30160 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
30161 _this.fireEvent('markerClick', this, event);
30165 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
30166 _this.fireEvent('markerRightClick', this, event);
30170 this.setPosition(this.gMapContext.location);
30172 this.fireEvent('initial', this, this.gMapContext.location);
30175 initOverlayView: function()
30179 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
30183 _this.fireEvent('OverlayViewDraw', _this);
30188 _this.fireEvent('OverlayViewOnAdd', _this);
30191 onRemove: function()
30193 _this.fireEvent('OverlayViewOnRemove', _this);
30196 show: function(cpx)
30198 _this.fireEvent('OverlayViewShow', _this, cpx);
30203 _this.fireEvent('OverlayViewHide', _this);
30209 fromLatLngToContainerPixel: function(event)
30211 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
30214 isApplied: function()
30216 return this.getGmapContext() == false ? false : true;
30219 getGmapContext: function()
30221 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
30224 GMapContext: function()
30226 var position = new google.maps.LatLng(this.latitude, this.longitude);
30228 var _map = new google.maps.Map(this.el.dom, {
30231 mapTypeId: this.mapTypeId,
30232 mapTypeControl: this.mapTypeControl,
30233 disableDoubleClickZoom: this.disableDoubleClickZoom,
30234 scrollwheel: this.scrollwheel,
30235 streetViewControl: this.streetViewControl,
30236 locationName: this.locationName,
30237 draggable: this.draggable,
30238 enableAutocomplete: this.enableAutocomplete,
30239 enableReverseGeocode: this.enableReverseGeocode
30242 var _marker = new google.maps.Marker({
30243 position: position,
30245 title: this.markerTitle,
30246 draggable: this.draggable
30253 location: position,
30254 radius: this.radius,
30255 locationName: this.locationName,
30256 addressComponents: {
30257 formatted_address: null,
30258 addressLine1: null,
30259 addressLine2: null,
30261 streetNumber: null,
30265 stateOrProvince: null
30268 domContainer: this.el.dom,
30269 geodecoder: new google.maps.Geocoder()
30273 drawCircle: function(center, radius, options)
30275 if (this.gMapContext.circle != null) {
30276 this.gMapContext.circle.setMap(null);
30280 options = Roo.apply({}, options, {
30281 strokeColor: "#0000FF",
30282 strokeOpacity: .35,
30284 fillColor: "#0000FF",
30288 options.map = this.gMapContext.map;
30289 options.radius = radius;
30290 options.center = center;
30291 this.gMapContext.circle = new google.maps.Circle(options);
30292 return this.gMapContext.circle;
30298 setPosition: function(location)
30300 this.gMapContext.location = location;
30301 this.gMapContext.marker.setPosition(location);
30302 this.gMapContext.map.panTo(location);
30303 this.drawCircle(location, this.gMapContext.radius, {});
30307 if (this.gMapContext.settings.enableReverseGeocode) {
30308 this.gMapContext.geodecoder.geocode({
30309 latLng: this.gMapContext.location
30310 }, function(results, status) {
30312 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
30313 _this.gMapContext.locationName = results[0].formatted_address;
30314 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
30316 _this.fireEvent('positionchanged', this, location);
30323 this.fireEvent('positionchanged', this, location);
30328 google.maps.event.trigger(this.gMapContext.map, "resize");
30330 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
30332 this.fireEvent('resize', this);
30335 setPositionByLatLng: function(latitude, longitude)
30337 this.setPosition(new google.maps.LatLng(latitude, longitude));
30340 getCurrentPosition: function()
30343 latitude: this.gMapContext.location.lat(),
30344 longitude: this.gMapContext.location.lng()
30348 getAddressName: function()
30350 return this.gMapContext.locationName;
30353 getAddressComponents: function()
30355 return this.gMapContext.addressComponents;
30358 address_component_from_google_geocode: function(address_components)
30362 for (var i = 0; i < address_components.length; i++) {
30363 var component = address_components[i];
30364 if (component.types.indexOf("postal_code") >= 0) {
30365 result.postalCode = component.short_name;
30366 } else if (component.types.indexOf("street_number") >= 0) {
30367 result.streetNumber = component.short_name;
30368 } else if (component.types.indexOf("route") >= 0) {
30369 result.streetName = component.short_name;
30370 } else if (component.types.indexOf("neighborhood") >= 0) {
30371 result.city = component.short_name;
30372 } else if (component.types.indexOf("locality") >= 0) {
30373 result.city = component.short_name;
30374 } else if (component.types.indexOf("sublocality") >= 0) {
30375 result.district = component.short_name;
30376 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
30377 result.stateOrProvince = component.short_name;
30378 } else if (component.types.indexOf("country") >= 0) {
30379 result.country = component.short_name;
30383 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
30384 result.addressLine2 = "";
30388 setZoomLevel: function(zoom)
30390 this.gMapContext.map.setZoom(zoom);
30403 this.fireEvent('show', this);
30414 this.fireEvent('hide', this);
30419 Roo.apply(Roo.bootstrap.LocationPicker, {
30421 OverlayView : function(map, options)
30423 options = options || {};
30430 * @class Roo.bootstrap.Alert
30431 * @extends Roo.bootstrap.Component
30432 * Bootstrap Alert class - shows an alert area box
30434 * <div class="alert alert-danger" role="alert"><span class="fa fa-exclamation-triangle"></span><span class="sr-only">Error:</span>
30435 Enter a valid email address
30438 * @cfg {String} title The title of alert
30439 * @cfg {String} html The content of alert
30440 * @cfg {String} weight (success|info|warning|danger) Weight of the message
30441 * @cfg {String} fa font-awesomeicon
30442 * @cfg {Number} seconds default:-1 Number of seconds until it disapears (-1 means never.)
30443 * @cfg {Boolean} close true to show a x closer
30447 * Create a new alert
30448 * @param {Object} config The config object
30452 Roo.bootstrap.Alert = function(config){
30453 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
30457 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
30463 faicon: false, // BC
30467 getAutoCreate : function()
30479 style : this.close ? '' : 'display:none'
30483 cls : 'roo-alert-icon'
30488 cls : 'roo-alert-title',
30493 cls : 'roo-alert-text',
30500 cfg.cn[0].cls += ' fa ' + this.faicon;
30503 cfg.cn[0].cls += ' fa ' + this.fa;
30507 cfg.cls += ' alert-' + this.weight;
30513 initEvents: function()
30515 this.el.setVisibilityMode(Roo.Element.DISPLAY);
30516 this.titleEl = this.el.select('.roo-alert-title',true).first();
30517 this.iconEl = this.el.select('.roo-alert-icon',true).first();
30518 this.htmlEl = this.el.select('.roo-alert-text',true).first();
30519 if (this.seconds > 0) {
30520 this.hide.defer(this.seconds, this);
30524 * Set the Title Message HTML
30525 * @param {String} html
30527 setTitle : function(str)
30529 this.titleEl.dom.innerHTML = str;
30533 * Set the Body Message HTML
30534 * @param {String} html
30536 setHtml : function(str)
30538 this.htmlEl.dom.innerHTML = str;
30541 * Set the Weight of the alert
30542 * @param {String} (success|info|warning|danger) weight
30545 setWeight : function(weight)
30548 this.el.removeClass('alert-' + this.weight);
30551 this.weight = weight;
30553 this.el.addClass('alert-' + this.weight);
30556 * Set the Icon of the alert
30557 * @param {String} see fontawsome names (name without the 'fa-' bit)
30559 setIcon : function(icon)
30562 this.alertEl.removeClass(['fa', 'fa-' + this.faicon]);
30565 this.faicon = icon;
30567 this.alertEl.addClass(['fa', 'fa-' + this.faicon]);
30592 * @class Roo.bootstrap.UploadCropbox
30593 * @extends Roo.bootstrap.Component
30594 * Bootstrap UploadCropbox class
30595 * @cfg {String} emptyText show when image has been loaded
30596 * @cfg {String} rotateNotify show when image too small to rotate
30597 * @cfg {Number} errorTimeout default 3000
30598 * @cfg {Number} minWidth default 300
30599 * @cfg {Number} minHeight default 300
30600 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
30601 * @cfg {Boolean} isDocument (true|false) default false
30602 * @cfg {String} url action url
30603 * @cfg {String} paramName default 'imageUpload'
30604 * @cfg {String} method default POST
30605 * @cfg {Boolean} loadMask (true|false) default true
30606 * @cfg {Boolean} loadingText default 'Loading...'
30609 * Create a new UploadCropbox
30610 * @param {Object} config The config object
30613 Roo.bootstrap.UploadCropbox = function(config){
30614 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
30618 * @event beforeselectfile
30619 * Fire before select file
30620 * @param {Roo.bootstrap.UploadCropbox} this
30622 "beforeselectfile" : true,
30625 * Fire after initEvent
30626 * @param {Roo.bootstrap.UploadCropbox} this
30631 * Fire after initEvent
30632 * @param {Roo.bootstrap.UploadCropbox} this
30633 * @param {String} data
30638 * Fire when preparing the file data
30639 * @param {Roo.bootstrap.UploadCropbox} this
30640 * @param {Object} file
30645 * Fire when get exception
30646 * @param {Roo.bootstrap.UploadCropbox} this
30647 * @param {XMLHttpRequest} xhr
30649 "exception" : true,
30651 * @event beforeloadcanvas
30652 * Fire before load the canvas
30653 * @param {Roo.bootstrap.UploadCropbox} this
30654 * @param {String} src
30656 "beforeloadcanvas" : true,
30659 * Fire when trash image
30660 * @param {Roo.bootstrap.UploadCropbox} this
30665 * Fire when download the image
30666 * @param {Roo.bootstrap.UploadCropbox} this
30670 * @event footerbuttonclick
30671 * Fire when footerbuttonclick
30672 * @param {Roo.bootstrap.UploadCropbox} this
30673 * @param {String} type
30675 "footerbuttonclick" : true,
30679 * @param {Roo.bootstrap.UploadCropbox} this
30684 * Fire when rotate the image
30685 * @param {Roo.bootstrap.UploadCropbox} this
30686 * @param {String} pos
30691 * Fire when inspect the file
30692 * @param {Roo.bootstrap.UploadCropbox} this
30693 * @param {Object} file
30698 * Fire when xhr upload the file
30699 * @param {Roo.bootstrap.UploadCropbox} this
30700 * @param {Object} data
30705 * Fire when arrange the file data
30706 * @param {Roo.bootstrap.UploadCropbox} this
30707 * @param {Object} formData
30712 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
30715 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
30717 emptyText : 'Click to upload image',
30718 rotateNotify : 'Image is too small to rotate',
30719 errorTimeout : 3000,
30733 cropType : 'image/jpeg',
30735 canvasLoaded : false,
30736 isDocument : false,
30738 paramName : 'imageUpload',
30740 loadingText : 'Loading...',
30743 getAutoCreate : function()
30747 cls : 'roo-upload-cropbox',
30751 cls : 'roo-upload-cropbox-selector',
30756 cls : 'roo-upload-cropbox-body',
30757 style : 'cursor:pointer',
30761 cls : 'roo-upload-cropbox-preview'
30765 cls : 'roo-upload-cropbox-thumb'
30769 cls : 'roo-upload-cropbox-empty-notify',
30770 html : this.emptyText
30774 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
30775 html : this.rotateNotify
30781 cls : 'roo-upload-cropbox-footer',
30784 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
30794 onRender : function(ct, position)
30796 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
30798 if (this.buttons.length) {
30800 Roo.each(this.buttons, function(bb) {
30802 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
30804 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
30810 this.maskEl = this.el;
30814 initEvents : function()
30816 this.urlAPI = (window.createObjectURL && window) ||
30817 (window.URL && URL.revokeObjectURL && URL) ||
30818 (window.webkitURL && webkitURL);
30820 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
30821 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30823 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
30824 this.selectorEl.hide();
30826 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
30827 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30829 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
30830 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30831 this.thumbEl.hide();
30833 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
30834 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30836 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
30837 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30838 this.errorEl.hide();
30840 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
30841 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30842 this.footerEl.hide();
30844 this.setThumbBoxSize();
30850 this.fireEvent('initial', this);
30857 window.addEventListener("resize", function() { _this.resize(); } );
30859 this.bodyEl.on('click', this.beforeSelectFile, this);
30862 this.bodyEl.on('touchstart', this.onTouchStart, this);
30863 this.bodyEl.on('touchmove', this.onTouchMove, this);
30864 this.bodyEl.on('touchend', this.onTouchEnd, this);
30868 this.bodyEl.on('mousedown', this.onMouseDown, this);
30869 this.bodyEl.on('mousemove', this.onMouseMove, this);
30870 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
30871 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
30872 Roo.get(document).on('mouseup', this.onMouseUp, this);
30875 this.selectorEl.on('change', this.onFileSelected, this);
30881 this.baseScale = 1;
30883 this.baseRotate = 1;
30884 this.dragable = false;
30885 this.pinching = false;
30888 this.cropData = false;
30889 this.notifyEl.dom.innerHTML = this.emptyText;
30891 this.selectorEl.dom.value = '';
30895 resize : function()
30897 if(this.fireEvent('resize', this) != false){
30898 this.setThumbBoxPosition();
30899 this.setCanvasPosition();
30903 onFooterButtonClick : function(e, el, o, type)
30906 case 'rotate-left' :
30907 this.onRotateLeft(e);
30909 case 'rotate-right' :
30910 this.onRotateRight(e);
30913 this.beforeSelectFile(e);
30928 this.fireEvent('footerbuttonclick', this, type);
30931 beforeSelectFile : function(e)
30933 e.preventDefault();
30935 if(this.fireEvent('beforeselectfile', this) != false){
30936 this.selectorEl.dom.click();
30940 onFileSelected : function(e)
30942 e.preventDefault();
30944 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
30948 var file = this.selectorEl.dom.files[0];
30950 if(this.fireEvent('inspect', this, file) != false){
30951 this.prepare(file);
30956 trash : function(e)
30958 this.fireEvent('trash', this);
30961 download : function(e)
30963 this.fireEvent('download', this);
30966 loadCanvas : function(src)
30968 if(this.fireEvent('beforeloadcanvas', this, src) != false){
30972 this.imageEl = document.createElement('img');
30976 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
30978 this.imageEl.src = src;
30982 onLoadCanvas : function()
30984 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
30985 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
30987 this.bodyEl.un('click', this.beforeSelectFile, this);
30989 this.notifyEl.hide();
30990 this.thumbEl.show();
30991 this.footerEl.show();
30993 this.baseRotateLevel();
30995 if(this.isDocument){
30996 this.setThumbBoxSize();
30999 this.setThumbBoxPosition();
31001 this.baseScaleLevel();
31007 this.canvasLoaded = true;
31010 this.maskEl.unmask();
31015 setCanvasPosition : function()
31017 if(!this.canvasEl){
31021 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
31022 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
31024 this.previewEl.setLeft(pw);
31025 this.previewEl.setTop(ph);
31029 onMouseDown : function(e)
31033 this.dragable = true;
31034 this.pinching = false;
31036 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
31037 this.dragable = false;
31041 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
31042 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
31046 onMouseMove : function(e)
31050 if(!this.canvasLoaded){
31054 if (!this.dragable){
31058 var minX = Math.ceil(this.thumbEl.getLeft(true));
31059 var minY = Math.ceil(this.thumbEl.getTop(true));
31061 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
31062 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
31064 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
31065 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
31067 x = x - this.mouseX;
31068 y = y - this.mouseY;
31070 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
31071 var bgY = Math.ceil(y + this.previewEl.getTop(true));
31073 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
31074 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
31076 this.previewEl.setLeft(bgX);
31077 this.previewEl.setTop(bgY);
31079 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
31080 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
31083 onMouseUp : function(e)
31087 this.dragable = false;
31090 onMouseWheel : function(e)
31094 this.startScale = this.scale;
31096 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
31098 if(!this.zoomable()){
31099 this.scale = this.startScale;
31108 zoomable : function()
31110 var minScale = this.thumbEl.getWidth() / this.minWidth;
31112 if(this.minWidth < this.minHeight){
31113 minScale = this.thumbEl.getHeight() / this.minHeight;
31116 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
31117 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
31121 (this.rotate == 0 || this.rotate == 180) &&
31123 width > this.imageEl.OriginWidth ||
31124 height > this.imageEl.OriginHeight ||
31125 (width < this.minWidth && height < this.minHeight)
31133 (this.rotate == 90 || this.rotate == 270) &&
31135 width > this.imageEl.OriginWidth ||
31136 height > this.imageEl.OriginHeight ||
31137 (width < this.minHeight && height < this.minWidth)
31144 !this.isDocument &&
31145 (this.rotate == 0 || this.rotate == 180) &&
31147 width < this.minWidth ||
31148 width > this.imageEl.OriginWidth ||
31149 height < this.minHeight ||
31150 height > this.imageEl.OriginHeight
31157 !this.isDocument &&
31158 (this.rotate == 90 || this.rotate == 270) &&
31160 width < this.minHeight ||
31161 width > this.imageEl.OriginWidth ||
31162 height < this.minWidth ||
31163 height > this.imageEl.OriginHeight
31173 onRotateLeft : function(e)
31175 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
31177 var minScale = this.thumbEl.getWidth() / this.minWidth;
31179 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
31180 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
31182 this.startScale = this.scale;
31184 while (this.getScaleLevel() < minScale){
31186 this.scale = this.scale + 1;
31188 if(!this.zoomable()){
31193 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
31194 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
31199 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
31206 this.scale = this.startScale;
31208 this.onRotateFail();
31213 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
31215 if(this.isDocument){
31216 this.setThumbBoxSize();
31217 this.setThumbBoxPosition();
31218 this.setCanvasPosition();
31223 this.fireEvent('rotate', this, 'left');
31227 onRotateRight : function(e)
31229 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
31231 var minScale = this.thumbEl.getWidth() / this.minWidth;
31233 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
31234 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
31236 this.startScale = this.scale;
31238 while (this.getScaleLevel() < minScale){
31240 this.scale = this.scale + 1;
31242 if(!this.zoomable()){
31247 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
31248 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
31253 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
31260 this.scale = this.startScale;
31262 this.onRotateFail();
31267 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
31269 if(this.isDocument){
31270 this.setThumbBoxSize();
31271 this.setThumbBoxPosition();
31272 this.setCanvasPosition();
31277 this.fireEvent('rotate', this, 'right');
31280 onRotateFail : function()
31282 this.errorEl.show(true);
31286 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
31291 this.previewEl.dom.innerHTML = '';
31293 var canvasEl = document.createElement("canvas");
31295 var contextEl = canvasEl.getContext("2d");
31297 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
31298 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
31299 var center = this.imageEl.OriginWidth / 2;
31301 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
31302 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
31303 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
31304 center = this.imageEl.OriginHeight / 2;
31307 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
31309 contextEl.translate(center, center);
31310 contextEl.rotate(this.rotate * Math.PI / 180);
31312 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
31314 this.canvasEl = document.createElement("canvas");
31316 this.contextEl = this.canvasEl.getContext("2d");
31318 switch (this.rotate) {
31321 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
31322 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
31324 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
31329 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
31330 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
31332 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
31333 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);
31337 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
31342 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
31343 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
31345 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
31346 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);
31350 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);
31355 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
31356 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
31358 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
31359 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
31363 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);
31370 this.previewEl.appendChild(this.canvasEl);
31372 this.setCanvasPosition();
31377 if(!this.canvasLoaded){
31381 var imageCanvas = document.createElement("canvas");
31383 var imageContext = imageCanvas.getContext("2d");
31385 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
31386 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
31388 var center = imageCanvas.width / 2;
31390 imageContext.translate(center, center);
31392 imageContext.rotate(this.rotate * Math.PI / 180);
31394 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
31396 var canvas = document.createElement("canvas");
31398 var context = canvas.getContext("2d");
31400 canvas.width = this.minWidth;
31401 canvas.height = this.minHeight;
31403 switch (this.rotate) {
31406 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
31407 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
31409 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
31410 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
31412 var targetWidth = this.minWidth - 2 * x;
31413 var targetHeight = this.minHeight - 2 * y;
31417 if((x == 0 && y == 0) || (x == 0 && y > 0)){
31418 scale = targetWidth / width;
31421 if(x > 0 && y == 0){
31422 scale = targetHeight / height;
31425 if(x > 0 && y > 0){
31426 scale = targetWidth / width;
31428 if(width < height){
31429 scale = targetHeight / height;
31433 context.scale(scale, scale);
31435 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
31436 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
31438 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
31439 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
31441 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
31446 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
31447 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
31449 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
31450 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
31452 var targetWidth = this.minWidth - 2 * x;
31453 var targetHeight = this.minHeight - 2 * y;
31457 if((x == 0 && y == 0) || (x == 0 && y > 0)){
31458 scale = targetWidth / width;
31461 if(x > 0 && y == 0){
31462 scale = targetHeight / height;
31465 if(x > 0 && y > 0){
31466 scale = targetWidth / width;
31468 if(width < height){
31469 scale = targetHeight / height;
31473 context.scale(scale, scale);
31475 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
31476 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
31478 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
31479 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
31481 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
31483 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
31488 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
31489 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
31491 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
31492 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
31494 var targetWidth = this.minWidth - 2 * x;
31495 var targetHeight = this.minHeight - 2 * y;
31499 if((x == 0 && y == 0) || (x == 0 && y > 0)){
31500 scale = targetWidth / width;
31503 if(x > 0 && y == 0){
31504 scale = targetHeight / height;
31507 if(x > 0 && y > 0){
31508 scale = targetWidth / width;
31510 if(width < height){
31511 scale = targetHeight / height;
31515 context.scale(scale, scale);
31517 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
31518 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
31520 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
31521 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
31523 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
31524 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
31526 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
31531 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
31532 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
31534 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
31535 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
31537 var targetWidth = this.minWidth - 2 * x;
31538 var targetHeight = this.minHeight - 2 * y;
31542 if((x == 0 && y == 0) || (x == 0 && y > 0)){
31543 scale = targetWidth / width;
31546 if(x > 0 && y == 0){
31547 scale = targetHeight / height;
31550 if(x > 0 && y > 0){
31551 scale = targetWidth / width;
31553 if(width < height){
31554 scale = targetHeight / height;
31558 context.scale(scale, scale);
31560 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
31561 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
31563 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
31564 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
31566 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
31568 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
31575 this.cropData = canvas.toDataURL(this.cropType);
31577 if(this.fireEvent('crop', this, this.cropData) !== false){
31578 this.process(this.file, this.cropData);
31585 setThumbBoxSize : function()
31589 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
31590 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
31591 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
31593 this.minWidth = width;
31594 this.minHeight = height;
31596 if(this.rotate == 90 || this.rotate == 270){
31597 this.minWidth = height;
31598 this.minHeight = width;
31603 width = Math.ceil(this.minWidth * height / this.minHeight);
31605 if(this.minWidth > this.minHeight){
31607 height = Math.ceil(this.minHeight * width / this.minWidth);
31610 this.thumbEl.setStyle({
31611 width : width + 'px',
31612 height : height + 'px'
31619 setThumbBoxPosition : function()
31621 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
31622 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
31624 this.thumbEl.setLeft(x);
31625 this.thumbEl.setTop(y);
31629 baseRotateLevel : function()
31631 this.baseRotate = 1;
31634 typeof(this.exif) != 'undefined' &&
31635 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
31636 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
31638 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
31641 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
31645 baseScaleLevel : function()
31649 if(this.isDocument){
31651 if(this.baseRotate == 6 || this.baseRotate == 8){
31653 height = this.thumbEl.getHeight();
31654 this.baseScale = height / this.imageEl.OriginWidth;
31656 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
31657 width = this.thumbEl.getWidth();
31658 this.baseScale = width / this.imageEl.OriginHeight;
31664 height = this.thumbEl.getHeight();
31665 this.baseScale = height / this.imageEl.OriginHeight;
31667 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
31668 width = this.thumbEl.getWidth();
31669 this.baseScale = width / this.imageEl.OriginWidth;
31675 if(this.baseRotate == 6 || this.baseRotate == 8){
31677 width = this.thumbEl.getHeight();
31678 this.baseScale = width / this.imageEl.OriginHeight;
31680 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
31681 height = this.thumbEl.getWidth();
31682 this.baseScale = height / this.imageEl.OriginHeight;
31685 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
31686 height = this.thumbEl.getWidth();
31687 this.baseScale = height / this.imageEl.OriginHeight;
31689 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
31690 width = this.thumbEl.getHeight();
31691 this.baseScale = width / this.imageEl.OriginWidth;
31698 width = this.thumbEl.getWidth();
31699 this.baseScale = width / this.imageEl.OriginWidth;
31701 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
31702 height = this.thumbEl.getHeight();
31703 this.baseScale = height / this.imageEl.OriginHeight;
31706 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
31708 height = this.thumbEl.getHeight();
31709 this.baseScale = height / this.imageEl.OriginHeight;
31711 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
31712 width = this.thumbEl.getWidth();
31713 this.baseScale = width / this.imageEl.OriginWidth;
31721 getScaleLevel : function()
31723 return this.baseScale * Math.pow(1.1, this.scale);
31726 onTouchStart : function(e)
31728 if(!this.canvasLoaded){
31729 this.beforeSelectFile(e);
31733 var touches = e.browserEvent.touches;
31739 if(touches.length == 1){
31740 this.onMouseDown(e);
31744 if(touches.length != 2){
31750 for(var i = 0, finger; finger = touches[i]; i++){
31751 coords.push(finger.pageX, finger.pageY);
31754 var x = Math.pow(coords[0] - coords[2], 2);
31755 var y = Math.pow(coords[1] - coords[3], 2);
31757 this.startDistance = Math.sqrt(x + y);
31759 this.startScale = this.scale;
31761 this.pinching = true;
31762 this.dragable = false;
31766 onTouchMove : function(e)
31768 if(!this.pinching && !this.dragable){
31772 var touches = e.browserEvent.touches;
31779 this.onMouseMove(e);
31785 for(var i = 0, finger; finger = touches[i]; i++){
31786 coords.push(finger.pageX, finger.pageY);
31789 var x = Math.pow(coords[0] - coords[2], 2);
31790 var y = Math.pow(coords[1] - coords[3], 2);
31792 this.endDistance = Math.sqrt(x + y);
31794 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
31796 if(!this.zoomable()){
31797 this.scale = this.startScale;
31805 onTouchEnd : function(e)
31807 this.pinching = false;
31808 this.dragable = false;
31812 process : function(file, crop)
31815 this.maskEl.mask(this.loadingText);
31818 this.xhr = new XMLHttpRequest();
31820 file.xhr = this.xhr;
31822 this.xhr.open(this.method, this.url, true);
31825 "Accept": "application/json",
31826 "Cache-Control": "no-cache",
31827 "X-Requested-With": "XMLHttpRequest"
31830 for (var headerName in headers) {
31831 var headerValue = headers[headerName];
31833 this.xhr.setRequestHeader(headerName, headerValue);
31839 this.xhr.onload = function()
31841 _this.xhrOnLoad(_this.xhr);
31844 this.xhr.onerror = function()
31846 _this.xhrOnError(_this.xhr);
31849 var formData = new FormData();
31851 formData.append('returnHTML', 'NO');
31854 formData.append('crop', crop);
31857 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
31858 formData.append(this.paramName, file, file.name);
31861 if(typeof(file.filename) != 'undefined'){
31862 formData.append('filename', file.filename);
31865 if(typeof(file.mimetype) != 'undefined'){
31866 formData.append('mimetype', file.mimetype);
31869 if(this.fireEvent('arrange', this, formData) != false){
31870 this.xhr.send(formData);
31874 xhrOnLoad : function(xhr)
31877 this.maskEl.unmask();
31880 if (xhr.readyState !== 4) {
31881 this.fireEvent('exception', this, xhr);
31885 var response = Roo.decode(xhr.responseText);
31887 if(!response.success){
31888 this.fireEvent('exception', this, xhr);
31892 var response = Roo.decode(xhr.responseText);
31894 this.fireEvent('upload', this, response);
31898 xhrOnError : function()
31901 this.maskEl.unmask();
31904 Roo.log('xhr on error');
31906 var response = Roo.decode(xhr.responseText);
31912 prepare : function(file)
31915 this.maskEl.mask(this.loadingText);
31921 if(typeof(file) === 'string'){
31922 this.loadCanvas(file);
31926 if(!file || !this.urlAPI){
31931 this.cropType = file.type;
31935 if(this.fireEvent('prepare', this, this.file) != false){
31937 var reader = new FileReader();
31939 reader.onload = function (e) {
31940 if (e.target.error) {
31941 Roo.log(e.target.error);
31945 var buffer = e.target.result,
31946 dataView = new DataView(buffer),
31948 maxOffset = dataView.byteLength - 4,
31952 if (dataView.getUint16(0) === 0xffd8) {
31953 while (offset < maxOffset) {
31954 markerBytes = dataView.getUint16(offset);
31956 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
31957 markerLength = dataView.getUint16(offset + 2) + 2;
31958 if (offset + markerLength > dataView.byteLength) {
31959 Roo.log('Invalid meta data: Invalid segment size.');
31963 if(markerBytes == 0xffe1){
31964 _this.parseExifData(
31971 offset += markerLength;
31981 var url = _this.urlAPI.createObjectURL(_this.file);
31983 _this.loadCanvas(url);
31988 reader.readAsArrayBuffer(this.file);
31994 parseExifData : function(dataView, offset, length)
31996 var tiffOffset = offset + 10,
32000 if (dataView.getUint32(offset + 4) !== 0x45786966) {
32001 // No Exif data, might be XMP data instead
32005 // Check for the ASCII code for "Exif" (0x45786966):
32006 if (dataView.getUint32(offset + 4) !== 0x45786966) {
32007 // No Exif data, might be XMP data instead
32010 if (tiffOffset + 8 > dataView.byteLength) {
32011 Roo.log('Invalid Exif data: Invalid segment size.');
32014 // Check for the two null bytes:
32015 if (dataView.getUint16(offset + 8) !== 0x0000) {
32016 Roo.log('Invalid Exif data: Missing byte alignment offset.');
32019 // Check the byte alignment:
32020 switch (dataView.getUint16(tiffOffset)) {
32022 littleEndian = true;
32025 littleEndian = false;
32028 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
32031 // Check for the TIFF tag marker (0x002A):
32032 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
32033 Roo.log('Invalid Exif data: Missing TIFF marker.');
32036 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
32037 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
32039 this.parseExifTags(
32042 tiffOffset + dirOffset,
32047 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
32052 if (dirOffset + 6 > dataView.byteLength) {
32053 Roo.log('Invalid Exif data: Invalid directory offset.');
32056 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
32057 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
32058 if (dirEndOffset + 4 > dataView.byteLength) {
32059 Roo.log('Invalid Exif data: Invalid directory size.');
32062 for (i = 0; i < tagsNumber; i += 1) {
32066 dirOffset + 2 + 12 * i, // tag offset
32070 // Return the offset to the next directory:
32071 return dataView.getUint32(dirEndOffset, littleEndian);
32074 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
32076 var tag = dataView.getUint16(offset, littleEndian);
32078 this.exif[tag] = this.getExifValue(
32082 dataView.getUint16(offset + 2, littleEndian), // tag type
32083 dataView.getUint32(offset + 4, littleEndian), // tag length
32088 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
32090 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
32099 Roo.log('Invalid Exif data: Invalid tag type.');
32103 tagSize = tagType.size * length;
32104 // Determine if the value is contained in the dataOffset bytes,
32105 // or if the value at the dataOffset is a pointer to the actual data:
32106 dataOffset = tagSize > 4 ?
32107 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
32108 if (dataOffset + tagSize > dataView.byteLength) {
32109 Roo.log('Invalid Exif data: Invalid data offset.');
32112 if (length === 1) {
32113 return tagType.getValue(dataView, dataOffset, littleEndian);
32116 for (i = 0; i < length; i += 1) {
32117 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
32120 if (tagType.ascii) {
32122 // Concatenate the chars:
32123 for (i = 0; i < values.length; i += 1) {
32125 // Ignore the terminating NULL byte(s):
32126 if (c === '\u0000') {
32138 Roo.apply(Roo.bootstrap.UploadCropbox, {
32140 'Orientation': 0x0112
32144 1: 0, //'top-left',
32146 3: 180, //'bottom-right',
32147 // 4: 'bottom-left',
32149 6: 90, //'right-top',
32150 // 7: 'right-bottom',
32151 8: 270 //'left-bottom'
32155 // byte, 8-bit unsigned int:
32157 getValue: function (dataView, dataOffset) {
32158 return dataView.getUint8(dataOffset);
32162 // ascii, 8-bit byte:
32164 getValue: function (dataView, dataOffset) {
32165 return String.fromCharCode(dataView.getUint8(dataOffset));
32170 // short, 16 bit int:
32172 getValue: function (dataView, dataOffset, littleEndian) {
32173 return dataView.getUint16(dataOffset, littleEndian);
32177 // long, 32 bit int:
32179 getValue: function (dataView, dataOffset, littleEndian) {
32180 return dataView.getUint32(dataOffset, littleEndian);
32184 // rational = two long values, first is numerator, second is denominator:
32186 getValue: function (dataView, dataOffset, littleEndian) {
32187 return dataView.getUint32(dataOffset, littleEndian) /
32188 dataView.getUint32(dataOffset + 4, littleEndian);
32192 // slong, 32 bit signed int:
32194 getValue: function (dataView, dataOffset, littleEndian) {
32195 return dataView.getInt32(dataOffset, littleEndian);
32199 // srational, two slongs, first is numerator, second is denominator:
32201 getValue: function (dataView, dataOffset, littleEndian) {
32202 return dataView.getInt32(dataOffset, littleEndian) /
32203 dataView.getInt32(dataOffset + 4, littleEndian);
32213 cls : 'btn-group roo-upload-cropbox-rotate-left',
32214 action : 'rotate-left',
32218 cls : 'btn btn-default',
32219 html : '<i class="fa fa-undo"></i>'
32225 cls : 'btn-group roo-upload-cropbox-picture',
32226 action : 'picture',
32230 cls : 'btn btn-default',
32231 html : '<i class="fa fa-picture-o"></i>'
32237 cls : 'btn-group roo-upload-cropbox-rotate-right',
32238 action : 'rotate-right',
32242 cls : 'btn btn-default',
32243 html : '<i class="fa fa-repeat"></i>'
32251 cls : 'btn-group roo-upload-cropbox-rotate-left',
32252 action : 'rotate-left',
32256 cls : 'btn btn-default',
32257 html : '<i class="fa fa-undo"></i>'
32263 cls : 'btn-group roo-upload-cropbox-download',
32264 action : 'download',
32268 cls : 'btn btn-default',
32269 html : '<i class="fa fa-download"></i>'
32275 cls : 'btn-group roo-upload-cropbox-crop',
32280 cls : 'btn btn-default',
32281 html : '<i class="fa fa-crop"></i>'
32287 cls : 'btn-group roo-upload-cropbox-trash',
32292 cls : 'btn btn-default',
32293 html : '<i class="fa fa-trash"></i>'
32299 cls : 'btn-group roo-upload-cropbox-rotate-right',
32300 action : 'rotate-right',
32304 cls : 'btn btn-default',
32305 html : '<i class="fa fa-repeat"></i>'
32313 cls : 'btn-group roo-upload-cropbox-rotate-left',
32314 action : 'rotate-left',
32318 cls : 'btn btn-default',
32319 html : '<i class="fa fa-undo"></i>'
32325 cls : 'btn-group roo-upload-cropbox-rotate-right',
32326 action : 'rotate-right',
32330 cls : 'btn btn-default',
32331 html : '<i class="fa fa-repeat"></i>'
32344 * @class Roo.bootstrap.DocumentManager
32345 * @extends Roo.bootstrap.Component
32346 * Bootstrap DocumentManager class
32347 * @cfg {String} paramName default 'imageUpload'
32348 * @cfg {String} toolTipName default 'filename'
32349 * @cfg {String} method default POST
32350 * @cfg {String} url action url
32351 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
32352 * @cfg {Boolean} multiple multiple upload default true
32353 * @cfg {Number} thumbSize default 300
32354 * @cfg {String} fieldLabel
32355 * @cfg {Number} labelWidth default 4
32356 * @cfg {String} labelAlign (left|top) default left
32357 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
32358 * @cfg {Number} labellg set the width of label (1-12)
32359 * @cfg {Number} labelmd set the width of label (1-12)
32360 * @cfg {Number} labelsm set the width of label (1-12)
32361 * @cfg {Number} labelxs set the width of label (1-12)
32364 * Create a new DocumentManager
32365 * @param {Object} config The config object
32368 Roo.bootstrap.DocumentManager = function(config){
32369 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
32372 this.delegates = [];
32377 * Fire when initial the DocumentManager
32378 * @param {Roo.bootstrap.DocumentManager} this
32383 * inspect selected file
32384 * @param {Roo.bootstrap.DocumentManager} this
32385 * @param {File} file
32390 * Fire when xhr load exception
32391 * @param {Roo.bootstrap.DocumentManager} this
32392 * @param {XMLHttpRequest} xhr
32394 "exception" : true,
32396 * @event afterupload
32397 * Fire when xhr load exception
32398 * @param {Roo.bootstrap.DocumentManager} this
32399 * @param {XMLHttpRequest} xhr
32401 "afterupload" : true,
32404 * prepare the form data
32405 * @param {Roo.bootstrap.DocumentManager} this
32406 * @param {Object} formData
32411 * Fire when remove the file
32412 * @param {Roo.bootstrap.DocumentManager} this
32413 * @param {Object} file
32418 * Fire after refresh the file
32419 * @param {Roo.bootstrap.DocumentManager} this
32424 * Fire after click the image
32425 * @param {Roo.bootstrap.DocumentManager} this
32426 * @param {Object} file
32431 * Fire when upload a image and editable set to true
32432 * @param {Roo.bootstrap.DocumentManager} this
32433 * @param {Object} file
32437 * @event beforeselectfile
32438 * Fire before select file
32439 * @param {Roo.bootstrap.DocumentManager} this
32441 "beforeselectfile" : true,
32444 * Fire before process file
32445 * @param {Roo.bootstrap.DocumentManager} this
32446 * @param {Object} file
32450 * @event previewrendered
32451 * Fire when preview rendered
32452 * @param {Roo.bootstrap.DocumentManager} this
32453 * @param {Object} file
32455 "previewrendered" : true,
32458 "previewResize" : true
32463 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
32472 paramName : 'imageUpload',
32473 toolTipName : 'filename',
32476 labelAlign : 'left',
32486 getAutoCreate : function()
32488 var managerWidget = {
32490 cls : 'roo-document-manager',
32494 cls : 'roo-document-manager-selector',
32499 cls : 'roo-document-manager-uploader',
32503 cls : 'roo-document-manager-upload-btn',
32504 html : '<i class="fa fa-plus"></i>'
32515 cls : 'column col-md-12',
32520 if(this.fieldLabel.length){
32525 cls : 'column col-md-12',
32526 html : this.fieldLabel
32530 cls : 'column col-md-12',
32535 if(this.labelAlign == 'left'){
32540 html : this.fieldLabel
32549 if(this.labelWidth > 12){
32550 content[0].style = "width: " + this.labelWidth + 'px';
32553 if(this.labelWidth < 13 && this.labelmd == 0){
32554 this.labelmd = this.labelWidth;
32557 if(this.labellg > 0){
32558 content[0].cls += ' col-lg-' + this.labellg;
32559 content[1].cls += ' col-lg-' + (12 - this.labellg);
32562 if(this.labelmd > 0){
32563 content[0].cls += ' col-md-' + this.labelmd;
32564 content[1].cls += ' col-md-' + (12 - this.labelmd);
32567 if(this.labelsm > 0){
32568 content[0].cls += ' col-sm-' + this.labelsm;
32569 content[1].cls += ' col-sm-' + (12 - this.labelsm);
32572 if(this.labelxs > 0){
32573 content[0].cls += ' col-xs-' + this.labelxs;
32574 content[1].cls += ' col-xs-' + (12 - this.labelxs);
32582 cls : 'row clearfix',
32590 initEvents : function()
32592 this.managerEl = this.el.select('.roo-document-manager', true).first();
32593 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
32595 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
32596 this.selectorEl.hide();
32599 this.selectorEl.attr('multiple', 'multiple');
32602 this.selectorEl.on('change', this.onFileSelected, this);
32604 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
32605 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
32607 this.uploader.on('click', this.onUploaderClick, this);
32609 this.renderProgressDialog();
32613 window.addEventListener("resize", function() { _this.refresh(); } );
32615 this.fireEvent('initial', this);
32618 renderProgressDialog : function()
32622 this.progressDialog = new Roo.bootstrap.Modal({
32623 cls : 'roo-document-manager-progress-dialog',
32624 allow_close : false,
32635 btnclick : function() {
32636 _this.uploadCancel();
32642 this.progressDialog.render(Roo.get(document.body));
32644 this.progress = new Roo.bootstrap.Progress({
32645 cls : 'roo-document-manager-progress',
32650 this.progress.render(this.progressDialog.getChildContainer());
32652 this.progressBar = new Roo.bootstrap.ProgressBar({
32653 cls : 'roo-document-manager-progress-bar',
32656 aria_valuemax : 12,
32660 this.progressBar.render(this.progress.getChildContainer());
32663 onUploaderClick : function(e)
32665 e.preventDefault();
32667 if(this.fireEvent('beforeselectfile', this) != false){
32668 this.selectorEl.dom.click();
32673 onFileSelected : function(e)
32675 e.preventDefault();
32677 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
32681 Roo.each(this.selectorEl.dom.files, function(file){
32682 if(this.fireEvent('inspect', this, file) != false){
32683 this.files.push(file);
32693 this.selectorEl.dom.value = '';
32695 if(!this.files || !this.files.length){
32699 if(this.boxes > 0 && this.files.length > this.boxes){
32700 this.files = this.files.slice(0, this.boxes);
32703 this.uploader.show();
32705 if(this.boxes > 0 && this.files.length > this.boxes - 1){
32706 this.uploader.hide();
32715 Roo.each(this.files, function(file){
32717 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
32718 var f = this.renderPreview(file);
32723 if(file.type.indexOf('image') != -1){
32724 this.delegates.push(
32726 _this.process(file);
32727 }).createDelegate(this)
32735 _this.process(file);
32736 }).createDelegate(this)
32741 this.files = files;
32743 this.delegates = this.delegates.concat(docs);
32745 if(!this.delegates.length){
32750 this.progressBar.aria_valuemax = this.delegates.length;
32757 arrange : function()
32759 if(!this.delegates.length){
32760 this.progressDialog.hide();
32765 var delegate = this.delegates.shift();
32767 this.progressDialog.show();
32769 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
32771 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
32776 refresh : function()
32778 this.uploader.show();
32780 if(this.boxes > 0 && this.files.length > this.boxes - 1){
32781 this.uploader.hide();
32784 Roo.isTouch ? this.closable(false) : this.closable(true);
32786 this.fireEvent('refresh', this);
32789 onRemove : function(e, el, o)
32791 e.preventDefault();
32793 this.fireEvent('remove', this, o);
32797 remove : function(o)
32801 Roo.each(this.files, function(file){
32802 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
32811 this.files = files;
32818 Roo.each(this.files, function(file){
32823 file.target.remove();
32832 onClick : function(e, el, o)
32834 e.preventDefault();
32836 this.fireEvent('click', this, o);
32840 closable : function(closable)
32842 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
32844 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
32856 xhrOnLoad : function(xhr)
32858 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
32862 if (xhr.readyState !== 4) {
32864 this.fireEvent('exception', this, xhr);
32868 var response = Roo.decode(xhr.responseText);
32870 if(!response.success){
32872 this.fireEvent('exception', this, xhr);
32876 var file = this.renderPreview(response.data);
32878 this.files.push(file);
32882 this.fireEvent('afterupload', this, xhr);
32886 xhrOnError : function(xhr)
32888 Roo.log('xhr on error');
32890 var response = Roo.decode(xhr.responseText);
32897 process : function(file)
32899 if(this.fireEvent('process', this, file) !== false){
32900 if(this.editable && file.type.indexOf('image') != -1){
32901 this.fireEvent('edit', this, file);
32905 this.uploadStart(file, false);
32912 uploadStart : function(file, crop)
32914 this.xhr = new XMLHttpRequest();
32916 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
32921 file.xhr = this.xhr;
32923 this.managerEl.createChild({
32925 cls : 'roo-document-manager-loading',
32929 tooltip : file.name,
32930 cls : 'roo-document-manager-thumb',
32931 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
32937 this.xhr.open(this.method, this.url, true);
32940 "Accept": "application/json",
32941 "Cache-Control": "no-cache",
32942 "X-Requested-With": "XMLHttpRequest"
32945 for (var headerName in headers) {
32946 var headerValue = headers[headerName];
32948 this.xhr.setRequestHeader(headerName, headerValue);
32954 this.xhr.onload = function()
32956 _this.xhrOnLoad(_this.xhr);
32959 this.xhr.onerror = function()
32961 _this.xhrOnError(_this.xhr);
32964 var formData = new FormData();
32966 formData.append('returnHTML', 'NO');
32969 formData.append('crop', crop);
32972 formData.append(this.paramName, file, file.name);
32979 if(this.fireEvent('prepare', this, formData, options) != false){
32981 if(options.manually){
32985 this.xhr.send(formData);
32989 this.uploadCancel();
32992 uploadCancel : function()
32998 this.delegates = [];
33000 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
33007 renderPreview : function(file)
33009 if(typeof(file.target) != 'undefined' && file.target){
33013 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
33015 var previewEl = this.managerEl.createChild({
33017 cls : 'roo-document-manager-preview',
33021 tooltip : file[this.toolTipName],
33022 cls : 'roo-document-manager-thumb',
33023 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
33028 html : '<i class="fa fa-times-circle"></i>'
33033 var close = previewEl.select('button.close', true).first();
33035 close.on('click', this.onRemove, this, file);
33037 file.target = previewEl;
33039 var image = previewEl.select('img', true).first();
33043 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
33045 image.on('click', this.onClick, this, file);
33047 this.fireEvent('previewrendered', this, file);
33053 onPreviewLoad : function(file, image)
33055 if(typeof(file.target) == 'undefined' || !file.target){
33059 var width = image.dom.naturalWidth || image.dom.width;
33060 var height = image.dom.naturalHeight || image.dom.height;
33062 if(!this.previewResize) {
33066 if(width > height){
33067 file.target.addClass('wide');
33071 file.target.addClass('tall');
33076 uploadFromSource : function(file, crop)
33078 this.xhr = new XMLHttpRequest();
33080 this.managerEl.createChild({
33082 cls : 'roo-document-manager-loading',
33086 tooltip : file.name,
33087 cls : 'roo-document-manager-thumb',
33088 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
33094 this.xhr.open(this.method, this.url, true);
33097 "Accept": "application/json",
33098 "Cache-Control": "no-cache",
33099 "X-Requested-With": "XMLHttpRequest"
33102 for (var headerName in headers) {
33103 var headerValue = headers[headerName];
33105 this.xhr.setRequestHeader(headerName, headerValue);
33111 this.xhr.onload = function()
33113 _this.xhrOnLoad(_this.xhr);
33116 this.xhr.onerror = function()
33118 _this.xhrOnError(_this.xhr);
33121 var formData = new FormData();
33123 formData.append('returnHTML', 'NO');
33125 formData.append('crop', crop);
33127 if(typeof(file.filename) != 'undefined'){
33128 formData.append('filename', file.filename);
33131 if(typeof(file.mimetype) != 'undefined'){
33132 formData.append('mimetype', file.mimetype);
33137 if(this.fireEvent('prepare', this, formData) != false){
33138 this.xhr.send(formData);
33148 * @class Roo.bootstrap.DocumentViewer
33149 * @extends Roo.bootstrap.Component
33150 * Bootstrap DocumentViewer class
33151 * @cfg {Boolean} showDownload (true|false) show download button (default true)
33152 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
33155 * Create a new DocumentViewer
33156 * @param {Object} config The config object
33159 Roo.bootstrap.DocumentViewer = function(config){
33160 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
33165 * Fire after initEvent
33166 * @param {Roo.bootstrap.DocumentViewer} this
33172 * @param {Roo.bootstrap.DocumentViewer} this
33177 * Fire after download button
33178 * @param {Roo.bootstrap.DocumentViewer} this
33183 * Fire after trash button
33184 * @param {Roo.bootstrap.DocumentViewer} this
33191 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
33193 showDownload : true,
33197 getAutoCreate : function()
33201 cls : 'roo-document-viewer',
33205 cls : 'roo-document-viewer-body',
33209 cls : 'roo-document-viewer-thumb',
33213 cls : 'roo-document-viewer-image'
33221 cls : 'roo-document-viewer-footer',
33224 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
33228 cls : 'btn-group roo-document-viewer-download',
33232 cls : 'btn btn-default',
33233 html : '<i class="fa fa-download"></i>'
33239 cls : 'btn-group roo-document-viewer-trash',
33243 cls : 'btn btn-default',
33244 html : '<i class="fa fa-trash"></i>'
33257 initEvents : function()
33259 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
33260 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
33262 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
33263 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
33265 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
33266 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
33268 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
33269 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
33271 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
33272 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
33274 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
33275 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
33277 this.bodyEl.on('click', this.onClick, this);
33278 this.downloadBtn.on('click', this.onDownload, this);
33279 this.trashBtn.on('click', this.onTrash, this);
33281 this.downloadBtn.hide();
33282 this.trashBtn.hide();
33284 if(this.showDownload){
33285 this.downloadBtn.show();
33288 if(this.showTrash){
33289 this.trashBtn.show();
33292 if(!this.showDownload && !this.showTrash) {
33293 this.footerEl.hide();
33298 initial : function()
33300 this.fireEvent('initial', this);
33304 onClick : function(e)
33306 e.preventDefault();
33308 this.fireEvent('click', this);
33311 onDownload : function(e)
33313 e.preventDefault();
33315 this.fireEvent('download', this);
33318 onTrash : function(e)
33320 e.preventDefault();
33322 this.fireEvent('trash', this);
33334 * @class Roo.bootstrap.NavProgressBar
33335 * @extends Roo.bootstrap.Component
33336 * Bootstrap NavProgressBar class
33339 * Create a new nav progress bar
33340 * @param {Object} config The config object
33343 Roo.bootstrap.NavProgressBar = function(config){
33344 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
33346 this.bullets = this.bullets || [];
33348 // Roo.bootstrap.NavProgressBar.register(this);
33352 * Fires when the active item changes
33353 * @param {Roo.bootstrap.NavProgressBar} this
33354 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
33355 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
33362 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
33367 getAutoCreate : function()
33369 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
33373 cls : 'roo-navigation-bar-group',
33377 cls : 'roo-navigation-top-bar'
33381 cls : 'roo-navigation-bullets-bar',
33385 cls : 'roo-navigation-bar'
33392 cls : 'roo-navigation-bottom-bar'
33402 initEvents: function()
33407 onRender : function(ct, position)
33409 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
33411 if(this.bullets.length){
33412 Roo.each(this.bullets, function(b){
33421 addItem : function(cfg)
33423 var item = new Roo.bootstrap.NavProgressItem(cfg);
33425 item.parentId = this.id;
33426 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
33429 var top = new Roo.bootstrap.Element({
33431 cls : 'roo-navigation-bar-text'
33434 var bottom = new Roo.bootstrap.Element({
33436 cls : 'roo-navigation-bar-text'
33439 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
33440 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
33442 var topText = new Roo.bootstrap.Element({
33444 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
33447 var bottomText = new Roo.bootstrap.Element({
33449 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
33452 topText.onRender(top.el, null);
33453 bottomText.onRender(bottom.el, null);
33456 item.bottomEl = bottom;
33459 this.barItems.push(item);
33464 getActive : function()
33466 var active = false;
33468 Roo.each(this.barItems, function(v){
33470 if (!v.isActive()) {
33482 setActiveItem : function(item)
33486 Roo.each(this.barItems, function(v){
33487 if (v.rid == item.rid) {
33491 if (v.isActive()) {
33492 v.setActive(false);
33497 item.setActive(true);
33499 this.fireEvent('changed', this, item, prev);
33502 getBarItem: function(rid)
33506 Roo.each(this.barItems, function(e) {
33507 if (e.rid != rid) {
33518 indexOfItem : function(item)
33522 Roo.each(this.barItems, function(v, i){
33524 if (v.rid != item.rid) {
33535 setActiveNext : function()
33537 var i = this.indexOfItem(this.getActive());
33539 if (i > this.barItems.length) {
33543 this.setActiveItem(this.barItems[i+1]);
33546 setActivePrev : function()
33548 var i = this.indexOfItem(this.getActive());
33554 this.setActiveItem(this.barItems[i-1]);
33557 format : function()
33559 if(!this.barItems.length){
33563 var width = 100 / this.barItems.length;
33565 Roo.each(this.barItems, function(i){
33566 i.el.setStyle('width', width + '%');
33567 i.topEl.el.setStyle('width', width + '%');
33568 i.bottomEl.el.setStyle('width', width + '%');
33577 * Nav Progress Item
33582 * @class Roo.bootstrap.NavProgressItem
33583 * @extends Roo.bootstrap.Component
33584 * Bootstrap NavProgressItem class
33585 * @cfg {String} rid the reference id
33586 * @cfg {Boolean} active (true|false) Is item active default false
33587 * @cfg {Boolean} disabled (true|false) Is item active default false
33588 * @cfg {String} html
33589 * @cfg {String} position (top|bottom) text position default bottom
33590 * @cfg {String} icon show icon instead of number
33593 * Create a new NavProgressItem
33594 * @param {Object} config The config object
33596 Roo.bootstrap.NavProgressItem = function(config){
33597 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
33602 * The raw click event for the entire grid.
33603 * @param {Roo.bootstrap.NavProgressItem} this
33604 * @param {Roo.EventObject} e
33611 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
33617 position : 'bottom',
33620 getAutoCreate : function()
33622 var iconCls = 'roo-navigation-bar-item-icon';
33624 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
33628 cls: 'roo-navigation-bar-item',
33638 cfg.cls += ' active';
33641 cfg.cls += ' disabled';
33647 disable : function()
33649 this.setDisabled(true);
33652 enable : function()
33654 this.setDisabled(false);
33657 initEvents: function()
33659 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
33661 this.iconEl.on('click', this.onClick, this);
33664 onClick : function(e)
33666 e.preventDefault();
33672 if(this.fireEvent('click', this, e) === false){
33676 this.parent().setActiveItem(this);
33679 isActive: function ()
33681 return this.active;
33684 setActive : function(state)
33686 if(this.active == state){
33690 this.active = state;
33693 this.el.addClass('active');
33697 this.el.removeClass('active');
33702 setDisabled : function(state)
33704 if(this.disabled == state){
33708 this.disabled = state;
33711 this.el.addClass('disabled');
33715 this.el.removeClass('disabled');
33718 tooltipEl : function()
33720 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
33733 * @class Roo.bootstrap.FieldLabel
33734 * @extends Roo.bootstrap.Component
33735 * Bootstrap FieldLabel class
33736 * @cfg {String} html contents of the element
33737 * @cfg {String} tag tag of the element default label
33738 * @cfg {String} cls class of the element
33739 * @cfg {String} target label target
33740 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
33741 * @cfg {String} invalidClass DEPRICATED - BS4 uses is-invalid
33742 * @cfg {String} validClass DEPRICATED - BS4 uses is-valid
33743 * @cfg {String} iconTooltip default "This field is required"
33744 * @cfg {String} indicatorpos (left|right) default left
33747 * Create a new FieldLabel
33748 * @param {Object} config The config object
33751 Roo.bootstrap.FieldLabel = function(config){
33752 Roo.bootstrap.Element.superclass.constructor.call(this, config);
33757 * Fires after the field has been marked as invalid.
33758 * @param {Roo.form.FieldLabel} this
33759 * @param {String} msg The validation message
33764 * Fires after the field has been validated with no errors.
33765 * @param {Roo.form.FieldLabel} this
33771 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
33778 invalidClass : 'has-warning',
33779 validClass : 'has-success',
33780 iconTooltip : 'This field is required',
33781 indicatorpos : 'left',
33783 getAutoCreate : function(){
33786 if (!this.allowBlank) {
33792 cls : 'roo-bootstrap-field-label ' + this.cls,
33797 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star ' + cls,
33798 tooltip : this.iconTooltip
33807 if(this.indicatorpos == 'right'){
33810 cls : 'roo-bootstrap-field-label ' + this.cls,
33819 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star '+ cls,
33820 tooltip : this.iconTooltip
33829 initEvents: function()
33831 Roo.bootstrap.Element.superclass.initEvents.call(this);
33833 this.indicator = this.indicatorEl();
33835 if(this.indicator){
33836 this.indicator.removeClass('visible');
33837 this.indicator.addClass('invisible');
33840 Roo.bootstrap.FieldLabel.register(this);
33843 indicatorEl : function()
33845 var indicator = this.el.select('i.roo-required-indicator',true).first();
33856 * Mark this field as valid
33858 markValid : function()
33860 if(this.indicator){
33861 this.indicator.removeClass('visible');
33862 this.indicator.addClass('invisible');
33864 if (Roo.bootstrap.version == 3) {
33865 this.el.removeClass(this.invalidClass);
33866 this.el.addClass(this.validClass);
33868 this.el.removeClass('is-invalid');
33869 this.el.addClass('is-valid');
33873 this.fireEvent('valid', this);
33877 * Mark this field as invalid
33878 * @param {String} msg The validation message
33880 markInvalid : function(msg)
33882 if(this.indicator){
33883 this.indicator.removeClass('invisible');
33884 this.indicator.addClass('visible');
33886 if (Roo.bootstrap.version == 3) {
33887 this.el.removeClass(this.validClass);
33888 this.el.addClass(this.invalidClass);
33890 this.el.removeClass('is-valid');
33891 this.el.addClass('is-invalid');
33895 this.fireEvent('invalid', this, msg);
33901 Roo.apply(Roo.bootstrap.FieldLabel, {
33906 * register a FieldLabel Group
33907 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
33909 register : function(label)
33911 if(this.groups.hasOwnProperty(label.target)){
33915 this.groups[label.target] = label;
33919 * fetch a FieldLabel Group based on the target
33920 * @param {string} target
33921 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
33923 get: function(target) {
33924 if (typeof(this.groups[target]) == 'undefined') {
33928 return this.groups[target] ;
33937 * page DateSplitField.
33943 * @class Roo.bootstrap.DateSplitField
33944 * @extends Roo.bootstrap.Component
33945 * Bootstrap DateSplitField class
33946 * @cfg {string} fieldLabel - the label associated
33947 * @cfg {Number} labelWidth set the width of label (0-12)
33948 * @cfg {String} labelAlign (top|left)
33949 * @cfg {Boolean} dayAllowBlank (true|false) default false
33950 * @cfg {Boolean} monthAllowBlank (true|false) default false
33951 * @cfg {Boolean} yearAllowBlank (true|false) default false
33952 * @cfg {string} dayPlaceholder
33953 * @cfg {string} monthPlaceholder
33954 * @cfg {string} yearPlaceholder
33955 * @cfg {string} dayFormat default 'd'
33956 * @cfg {string} monthFormat default 'm'
33957 * @cfg {string} yearFormat default 'Y'
33958 * @cfg {Number} labellg set the width of label (1-12)
33959 * @cfg {Number} labelmd set the width of label (1-12)
33960 * @cfg {Number} labelsm set the width of label (1-12)
33961 * @cfg {Number} labelxs set the width of label (1-12)
33965 * Create a new DateSplitField
33966 * @param {Object} config The config object
33969 Roo.bootstrap.DateSplitField = function(config){
33970 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
33976 * getting the data of years
33977 * @param {Roo.bootstrap.DateSplitField} this
33978 * @param {Object} years
33983 * getting the data of days
33984 * @param {Roo.bootstrap.DateSplitField} this
33985 * @param {Object} days
33990 * Fires after the field has been marked as invalid.
33991 * @param {Roo.form.Field} this
33992 * @param {String} msg The validation message
33997 * Fires after the field has been validated with no errors.
33998 * @param {Roo.form.Field} this
34004 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
34007 labelAlign : 'top',
34009 dayAllowBlank : false,
34010 monthAllowBlank : false,
34011 yearAllowBlank : false,
34012 dayPlaceholder : '',
34013 monthPlaceholder : '',
34014 yearPlaceholder : '',
34018 isFormField : true,
34024 getAutoCreate : function()
34028 cls : 'row roo-date-split-field-group',
34033 cls : 'form-hidden-field roo-date-split-field-group-value',
34039 var labelCls = 'col-md-12';
34040 var contentCls = 'col-md-4';
34042 if(this.fieldLabel){
34046 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
34050 html : this.fieldLabel
34055 if(this.labelAlign == 'left'){
34057 if(this.labelWidth > 12){
34058 label.style = "width: " + this.labelWidth + 'px';
34061 if(this.labelWidth < 13 && this.labelmd == 0){
34062 this.labelmd = this.labelWidth;
34065 if(this.labellg > 0){
34066 labelCls = ' col-lg-' + this.labellg;
34067 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
34070 if(this.labelmd > 0){
34071 labelCls = ' col-md-' + this.labelmd;
34072 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
34075 if(this.labelsm > 0){
34076 labelCls = ' col-sm-' + this.labelsm;
34077 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
34080 if(this.labelxs > 0){
34081 labelCls = ' col-xs-' + this.labelxs;
34082 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
34086 label.cls += ' ' + labelCls;
34088 cfg.cn.push(label);
34091 Roo.each(['day', 'month', 'year'], function(t){
34094 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
34101 inputEl: function ()
34103 return this.el.select('.roo-date-split-field-group-value', true).first();
34106 onRender : function(ct, position)
34110 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
34112 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
34114 this.dayField = new Roo.bootstrap.ComboBox({
34115 allowBlank : this.dayAllowBlank,
34116 alwaysQuery : true,
34117 displayField : 'value',
34120 forceSelection : true,
34122 placeholder : this.dayPlaceholder,
34123 selectOnFocus : true,
34124 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
34125 triggerAction : 'all',
34127 valueField : 'value',
34128 store : new Roo.data.SimpleStore({
34129 data : (function() {
34131 _this.fireEvent('days', _this, days);
34134 fields : [ 'value' ]
34137 select : function (_self, record, index)
34139 _this.setValue(_this.getValue());
34144 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
34146 this.monthField = new Roo.bootstrap.MonthField({
34147 after : '<i class=\"fa fa-calendar\"></i>',
34148 allowBlank : this.monthAllowBlank,
34149 placeholder : this.monthPlaceholder,
34152 render : function (_self)
34154 this.el.select('span.input-group-addon', true).first().on('click', function(e){
34155 e.preventDefault();
34159 select : function (_self, oldvalue, newvalue)
34161 _this.setValue(_this.getValue());
34166 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
34168 this.yearField = new Roo.bootstrap.ComboBox({
34169 allowBlank : this.yearAllowBlank,
34170 alwaysQuery : true,
34171 displayField : 'value',
34174 forceSelection : true,
34176 placeholder : this.yearPlaceholder,
34177 selectOnFocus : true,
34178 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
34179 triggerAction : 'all',
34181 valueField : 'value',
34182 store : new Roo.data.SimpleStore({
34183 data : (function() {
34185 _this.fireEvent('years', _this, years);
34188 fields : [ 'value' ]
34191 select : function (_self, record, index)
34193 _this.setValue(_this.getValue());
34198 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
34201 setValue : function(v, format)
34203 this.inputEl.dom.value = v;
34205 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
34207 var d = Date.parseDate(v, f);
34214 this.setDay(d.format(this.dayFormat));
34215 this.setMonth(d.format(this.monthFormat));
34216 this.setYear(d.format(this.yearFormat));
34223 setDay : function(v)
34225 this.dayField.setValue(v);
34226 this.inputEl.dom.value = this.getValue();
34231 setMonth : function(v)
34233 this.monthField.setValue(v, true);
34234 this.inputEl.dom.value = this.getValue();
34239 setYear : function(v)
34241 this.yearField.setValue(v);
34242 this.inputEl.dom.value = this.getValue();
34247 getDay : function()
34249 return this.dayField.getValue();
34252 getMonth : function()
34254 return this.monthField.getValue();
34257 getYear : function()
34259 return this.yearField.getValue();
34262 getValue : function()
34264 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
34266 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
34276 this.inputEl.dom.value = '';
34281 validate : function()
34283 var d = this.dayField.validate();
34284 var m = this.monthField.validate();
34285 var y = this.yearField.validate();
34290 (!this.dayAllowBlank && !d) ||
34291 (!this.monthAllowBlank && !m) ||
34292 (!this.yearAllowBlank && !y)
34297 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
34306 this.markInvalid();
34311 markValid : function()
34314 var label = this.el.select('label', true).first();
34315 var icon = this.el.select('i.fa-star', true).first();
34321 this.fireEvent('valid', this);
34325 * Mark this field as invalid
34326 * @param {String} msg The validation message
34328 markInvalid : function(msg)
34331 var label = this.el.select('label', true).first();
34332 var icon = this.el.select('i.fa-star', true).first();
34334 if(label && !icon){
34335 this.el.select('.roo-date-split-field-label', true).createChild({
34337 cls : 'text-danger fa fa-lg fa-star',
34338 tooltip : 'This field is required',
34339 style : 'margin-right:5px;'
34343 this.fireEvent('invalid', this, msg);
34346 clearInvalid : function()
34348 var label = this.el.select('label', true).first();
34349 var icon = this.el.select('i.fa-star', true).first();
34355 this.fireEvent('valid', this);
34358 getName: function()
34368 * http://masonry.desandro.com
34370 * The idea is to render all the bricks based on vertical width...
34372 * The original code extends 'outlayer' - we might need to use that....
34378 * @class Roo.bootstrap.LayoutMasonry
34379 * @extends Roo.bootstrap.Component
34380 * Bootstrap Layout Masonry class
34383 * Create a new Element
34384 * @param {Object} config The config object
34387 Roo.bootstrap.LayoutMasonry = function(config){
34389 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
34393 Roo.bootstrap.LayoutMasonry.register(this);
34399 * Fire after layout the items
34400 * @param {Roo.bootstrap.LayoutMasonry} this
34401 * @param {Roo.EventObject} e
34408 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
34411 * @cfg {Boolean} isLayoutInstant = no animation?
34413 isLayoutInstant : false, // needed?
34416 * @cfg {Number} boxWidth width of the columns
34421 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
34426 * @cfg {Number} padWidth padding below box..
34431 * @cfg {Number} gutter gutter width..
34436 * @cfg {Number} maxCols maximum number of columns
34442 * @cfg {Boolean} isAutoInitial defalut true
34444 isAutoInitial : true,
34449 * @cfg {Boolean} isHorizontal defalut false
34451 isHorizontal : false,
34453 currentSize : null,
34459 bricks: null, //CompositeElement
34463 _isLayoutInited : false,
34465 // isAlternative : false, // only use for vertical layout...
34468 * @cfg {Number} alternativePadWidth padding below box..
34470 alternativePadWidth : 50,
34472 selectedBrick : [],
34474 getAutoCreate : function(){
34476 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
34480 cls: 'blog-masonary-wrapper ' + this.cls,
34482 cls : 'mas-boxes masonary'
34489 getChildContainer: function( )
34491 if (this.boxesEl) {
34492 return this.boxesEl;
34495 this.boxesEl = this.el.select('.mas-boxes').first();
34497 return this.boxesEl;
34501 initEvents : function()
34505 if(this.isAutoInitial){
34506 Roo.log('hook children rendered');
34507 this.on('childrenrendered', function() {
34508 Roo.log('children rendered');
34514 initial : function()
34516 this.selectedBrick = [];
34518 this.currentSize = this.el.getBox(true);
34520 Roo.EventManager.onWindowResize(this.resize, this);
34522 if(!this.isAutoInitial){
34530 //this.layout.defer(500,this);
34534 resize : function()
34536 var cs = this.el.getBox(true);
34539 this.currentSize.width == cs.width &&
34540 this.currentSize.x == cs.x &&
34541 this.currentSize.height == cs.height &&
34542 this.currentSize.y == cs.y
34544 Roo.log("no change in with or X or Y");
34548 this.currentSize = cs;
34554 layout : function()
34556 this._resetLayout();
34558 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
34560 this.layoutItems( isInstant );
34562 this._isLayoutInited = true;
34564 this.fireEvent('layout', this);
34568 _resetLayout : function()
34570 if(this.isHorizontal){
34571 this.horizontalMeasureColumns();
34575 this.verticalMeasureColumns();
34579 verticalMeasureColumns : function()
34581 this.getContainerWidth();
34583 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
34584 // this.colWidth = Math.floor(this.containerWidth * 0.8);
34588 var boxWidth = this.boxWidth + this.padWidth;
34590 if(this.containerWidth < this.boxWidth){
34591 boxWidth = this.containerWidth
34594 var containerWidth = this.containerWidth;
34596 var cols = Math.floor(containerWidth / boxWidth);
34598 this.cols = Math.max( cols, 1 );
34600 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
34602 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
34604 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
34606 this.colWidth = boxWidth + avail - this.padWidth;
34608 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
34609 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
34612 horizontalMeasureColumns : function()
34614 this.getContainerWidth();
34616 var boxWidth = this.boxWidth;
34618 if(this.containerWidth < boxWidth){
34619 boxWidth = this.containerWidth;
34622 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
34624 this.el.setHeight(boxWidth);
34628 getContainerWidth : function()
34630 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
34633 layoutItems : function( isInstant )
34635 Roo.log(this.bricks);
34637 var items = Roo.apply([], this.bricks);
34639 if(this.isHorizontal){
34640 this._horizontalLayoutItems( items , isInstant );
34644 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
34645 // this._verticalAlternativeLayoutItems( items , isInstant );
34649 this._verticalLayoutItems( items , isInstant );
34653 _verticalLayoutItems : function ( items , isInstant)
34655 if ( !items || !items.length ) {
34660 ['xs', 'xs', 'xs', 'tall'],
34661 ['xs', 'xs', 'tall'],
34662 ['xs', 'xs', 'sm'],
34663 ['xs', 'xs', 'xs'],
34669 ['sm', 'xs', 'xs'],
34673 ['tall', 'xs', 'xs', 'xs'],
34674 ['tall', 'xs', 'xs'],
34686 Roo.each(items, function(item, k){
34688 switch (item.size) {
34689 // these layouts take up a full box,
34700 boxes.push([item]);
34723 var filterPattern = function(box, length)
34731 var pattern = box.slice(0, length);
34735 Roo.each(pattern, function(i){
34736 format.push(i.size);
34739 Roo.each(standard, function(s){
34741 if(String(s) != String(format)){
34750 if(!match && length == 1){
34755 filterPattern(box, length - 1);
34759 queue.push(pattern);
34761 box = box.slice(length, box.length);
34763 filterPattern(box, 4);
34769 Roo.each(boxes, function(box, k){
34775 if(box.length == 1){
34780 filterPattern(box, 4);
34784 this._processVerticalLayoutQueue( queue, isInstant );
34788 // _verticalAlternativeLayoutItems : function( items , isInstant )
34790 // if ( !items || !items.length ) {
34794 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
34798 _horizontalLayoutItems : function ( items , isInstant)
34800 if ( !items || !items.length || items.length < 3) {
34806 var eItems = items.slice(0, 3);
34808 items = items.slice(3, items.length);
34811 ['xs', 'xs', 'xs', 'wide'],
34812 ['xs', 'xs', 'wide'],
34813 ['xs', 'xs', 'sm'],
34814 ['xs', 'xs', 'xs'],
34820 ['sm', 'xs', 'xs'],
34824 ['wide', 'xs', 'xs', 'xs'],
34825 ['wide', 'xs', 'xs'],
34838 Roo.each(items, function(item, k){
34840 switch (item.size) {
34851 boxes.push([item]);
34875 var filterPattern = function(box, length)
34883 var pattern = box.slice(0, length);
34887 Roo.each(pattern, function(i){
34888 format.push(i.size);
34891 Roo.each(standard, function(s){
34893 if(String(s) != String(format)){
34902 if(!match && length == 1){
34907 filterPattern(box, length - 1);
34911 queue.push(pattern);
34913 box = box.slice(length, box.length);
34915 filterPattern(box, 4);
34921 Roo.each(boxes, function(box, k){
34927 if(box.length == 1){
34932 filterPattern(box, 4);
34939 var pos = this.el.getBox(true);
34943 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
34945 var hit_end = false;
34947 Roo.each(queue, function(box){
34951 Roo.each(box, function(b){
34953 b.el.setVisibilityMode(Roo.Element.DISPLAY);
34963 Roo.each(box, function(b){
34965 b.el.setVisibilityMode(Roo.Element.DISPLAY);
34968 mx = Math.max(mx, b.x);
34972 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
34976 Roo.each(box, function(b){
34978 b.el.setVisibilityMode(Roo.Element.DISPLAY);
34992 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
34995 /** Sets position of item in DOM
34996 * @param {Element} item
34997 * @param {Number} x - horizontal position
34998 * @param {Number} y - vertical position
34999 * @param {Boolean} isInstant - disables transitions
35001 _processVerticalLayoutQueue : function( queue, isInstant )
35003 var pos = this.el.getBox(true);
35008 for (var i = 0; i < this.cols; i++){
35012 Roo.each(queue, function(box, k){
35014 var col = k % this.cols;
35016 Roo.each(box, function(b,kk){
35018 b.el.position('absolute');
35020 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
35021 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
35023 if(b.size == 'md-left' || b.size == 'md-right'){
35024 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
35025 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
35028 b.el.setWidth(width);
35029 b.el.setHeight(height);
35031 b.el.select('iframe',true).setSize(width,height);
35035 for (var i = 0; i < this.cols; i++){
35037 if(maxY[i] < maxY[col]){
35042 col = Math.min(col, i);
35046 x = pos.x + col * (this.colWidth + this.padWidth);
35050 var positions = [];
35052 switch (box.length){
35054 positions = this.getVerticalOneBoxColPositions(x, y, box);
35057 positions = this.getVerticalTwoBoxColPositions(x, y, box);
35060 positions = this.getVerticalThreeBoxColPositions(x, y, box);
35063 positions = this.getVerticalFourBoxColPositions(x, y, box);
35069 Roo.each(box, function(b,kk){
35071 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
35073 var sz = b.el.getSize();
35075 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
35083 for (var i = 0; i < this.cols; i++){
35084 mY = Math.max(mY, maxY[i]);
35087 this.el.setHeight(mY - pos.y);
35091 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
35093 // var pos = this.el.getBox(true);
35096 // var maxX = pos.right;
35098 // var maxHeight = 0;
35100 // Roo.each(items, function(item, k){
35104 // item.el.position('absolute');
35106 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
35108 // item.el.setWidth(width);
35110 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
35112 // item.el.setHeight(height);
35115 // item.el.setXY([x, y], isInstant ? false : true);
35117 // item.el.setXY([maxX - width, y], isInstant ? false : true);
35120 // y = y + height + this.alternativePadWidth;
35122 // maxHeight = maxHeight + height + this.alternativePadWidth;
35126 // this.el.setHeight(maxHeight);
35130 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
35132 var pos = this.el.getBox(true);
35137 var maxX = pos.right;
35139 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
35141 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
35143 Roo.each(queue, function(box, k){
35145 Roo.each(box, function(b, kk){
35147 b.el.position('absolute');
35149 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
35150 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
35152 if(b.size == 'md-left' || b.size == 'md-right'){
35153 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
35154 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
35157 b.el.setWidth(width);
35158 b.el.setHeight(height);
35166 var positions = [];
35168 switch (box.length){
35170 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
35173 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
35176 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
35179 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
35185 Roo.each(box, function(b,kk){
35187 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
35189 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
35197 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
35199 Roo.each(eItems, function(b,k){
35201 b.size = (k == 0) ? 'sm' : 'xs';
35202 b.x = (k == 0) ? 2 : 1;
35203 b.y = (k == 0) ? 2 : 1;
35205 b.el.position('absolute');
35207 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
35209 b.el.setWidth(width);
35211 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
35213 b.el.setHeight(height);
35217 var positions = [];
35220 x : maxX - this.unitWidth * 2 - this.gutter,
35225 x : maxX - this.unitWidth,
35226 y : minY + (this.unitWidth + this.gutter) * 2
35230 x : maxX - this.unitWidth * 3 - this.gutter * 2,
35234 Roo.each(eItems, function(b,k){
35236 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
35242 getVerticalOneBoxColPositions : function(x, y, box)
35246 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
35248 if(box[0].size == 'md-left'){
35252 if(box[0].size == 'md-right'){
35257 x : x + (this.unitWidth + this.gutter) * rand,
35264 getVerticalTwoBoxColPositions : function(x, y, box)
35268 if(box[0].size == 'xs'){
35272 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
35276 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
35290 x : x + (this.unitWidth + this.gutter) * 2,
35291 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
35298 getVerticalThreeBoxColPositions : function(x, y, box)
35302 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
35310 x : x + (this.unitWidth + this.gutter) * 1,
35315 x : x + (this.unitWidth + this.gutter) * 2,
35323 if(box[0].size == 'xs' && box[1].size == 'xs'){
35332 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
35336 x : x + (this.unitWidth + this.gutter) * 1,
35350 x : x + (this.unitWidth + this.gutter) * 2,
35355 x : x + (this.unitWidth + this.gutter) * 2,
35356 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
35363 getVerticalFourBoxColPositions : function(x, y, box)
35367 if(box[0].size == 'xs'){
35376 y : y + (this.unitHeight + this.gutter) * 1
35381 y : y + (this.unitHeight + this.gutter) * 2
35385 x : x + (this.unitWidth + this.gutter) * 1,
35399 x : x + (this.unitWidth + this.gutter) * 2,
35404 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
35405 y : y + (this.unitHeight + this.gutter) * 1
35409 x : x + (this.unitWidth + this.gutter) * 2,
35410 y : y + (this.unitWidth + this.gutter) * 2
35417 getHorizontalOneBoxColPositions : function(maxX, minY, box)
35421 if(box[0].size == 'md-left'){
35423 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
35430 if(box[0].size == 'md-right'){
35432 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
35433 y : minY + (this.unitWidth + this.gutter) * 1
35439 var rand = Math.floor(Math.random() * (4 - box[0].y));
35442 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35443 y : minY + (this.unitWidth + this.gutter) * rand
35450 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
35454 if(box[0].size == 'xs'){
35457 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35462 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35463 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
35471 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35476 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35477 y : minY + (this.unitWidth + this.gutter) * 2
35484 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
35488 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
35491 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35496 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35497 y : minY + (this.unitWidth + this.gutter) * 1
35501 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
35502 y : minY + (this.unitWidth + this.gutter) * 2
35509 if(box[0].size == 'xs' && box[1].size == 'xs'){
35512 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35517 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35522 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
35523 y : minY + (this.unitWidth + this.gutter) * 1
35531 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35536 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35537 y : minY + (this.unitWidth + this.gutter) * 2
35541 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
35542 y : minY + (this.unitWidth + this.gutter) * 2
35549 getHorizontalFourBoxColPositions : function(maxX, minY, box)
35553 if(box[0].size == 'xs'){
35556 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35561 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35566 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),
35571 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
35572 y : minY + (this.unitWidth + this.gutter) * 1
35580 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35585 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35586 y : minY + (this.unitWidth + this.gutter) * 2
35590 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
35591 y : minY + (this.unitWidth + this.gutter) * 2
35595 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),
35596 y : minY + (this.unitWidth + this.gutter) * 2
35604 * remove a Masonry Brick
35605 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
35607 removeBrick : function(brick_id)
35613 for (var i = 0; i<this.bricks.length; i++) {
35614 if (this.bricks[i].id == brick_id) {
35615 this.bricks.splice(i,1);
35616 this.el.dom.removeChild(Roo.get(brick_id).dom);
35623 * adds a Masonry Brick
35624 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
35626 addBrick : function(cfg)
35628 var cn = new Roo.bootstrap.MasonryBrick(cfg);
35629 //this.register(cn);
35630 cn.parentId = this.id;
35631 cn.render(this.el);
35636 * register a Masonry Brick
35637 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
35640 register : function(brick)
35642 this.bricks.push(brick);
35643 brick.masonryId = this.id;
35647 * clear all the Masonry Brick
35649 clearAll : function()
35652 //this.getChildContainer().dom.innerHTML = "";
35653 this.el.dom.innerHTML = '';
35656 getSelected : function()
35658 if (!this.selectedBrick) {
35662 return this.selectedBrick;
35666 Roo.apply(Roo.bootstrap.LayoutMasonry, {
35670 * register a Masonry Layout
35671 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
35674 register : function(layout)
35676 this.groups[layout.id] = layout;
35679 * fetch a Masonry Layout based on the masonry layout ID
35680 * @param {string} the masonry layout to add
35681 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
35684 get: function(layout_id) {
35685 if (typeof(this.groups[layout_id]) == 'undefined') {
35688 return this.groups[layout_id] ;
35700 * http://masonry.desandro.com
35702 * The idea is to render all the bricks based on vertical width...
35704 * The original code extends 'outlayer' - we might need to use that....
35710 * @class Roo.bootstrap.LayoutMasonryAuto
35711 * @extends Roo.bootstrap.Component
35712 * Bootstrap Layout Masonry class
35715 * Create a new Element
35716 * @param {Object} config The config object
35719 Roo.bootstrap.LayoutMasonryAuto = function(config){
35720 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
35723 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
35726 * @cfg {Boolean} isFitWidth - resize the width..
35728 isFitWidth : false, // options..
35730 * @cfg {Boolean} isOriginLeft = left align?
35732 isOriginLeft : true,
35734 * @cfg {Boolean} isOriginTop = top align?
35736 isOriginTop : false,
35738 * @cfg {Boolean} isLayoutInstant = no animation?
35740 isLayoutInstant : false, // needed?
35742 * @cfg {Boolean} isResizingContainer = not sure if this is used..
35744 isResizingContainer : true,
35746 * @cfg {Number} columnWidth width of the columns
35752 * @cfg {Number} maxCols maximum number of columns
35757 * @cfg {Number} padHeight padding below box..
35763 * @cfg {Boolean} isAutoInitial defalut true
35766 isAutoInitial : true,
35772 initialColumnWidth : 0,
35773 currentSize : null,
35775 colYs : null, // array.
35782 bricks: null, //CompositeElement
35783 cols : 0, // array?
35784 // element : null, // wrapped now this.el
35785 _isLayoutInited : null,
35788 getAutoCreate : function(){
35792 cls: 'blog-masonary-wrapper ' + this.cls,
35794 cls : 'mas-boxes masonary'
35801 getChildContainer: function( )
35803 if (this.boxesEl) {
35804 return this.boxesEl;
35807 this.boxesEl = this.el.select('.mas-boxes').first();
35809 return this.boxesEl;
35813 initEvents : function()
35817 if(this.isAutoInitial){
35818 Roo.log('hook children rendered');
35819 this.on('childrenrendered', function() {
35820 Roo.log('children rendered');
35827 initial : function()
35829 this.reloadItems();
35831 this.currentSize = this.el.getBox(true);
35833 /// was window resize... - let's see if this works..
35834 Roo.EventManager.onWindowResize(this.resize, this);
35836 if(!this.isAutoInitial){
35841 this.layout.defer(500,this);
35844 reloadItems: function()
35846 this.bricks = this.el.select('.masonry-brick', true);
35848 this.bricks.each(function(b) {
35849 //Roo.log(b.getSize());
35850 if (!b.attr('originalwidth')) {
35851 b.attr('originalwidth', b.getSize().width);
35856 Roo.log(this.bricks.elements.length);
35859 resize : function()
35862 var cs = this.el.getBox(true);
35864 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
35865 Roo.log("no change in with or X");
35868 this.currentSize = cs;
35872 layout : function()
35875 this._resetLayout();
35876 //this._manageStamps();
35878 // don't animate first layout
35879 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
35880 this.layoutItems( isInstant );
35882 // flag for initalized
35883 this._isLayoutInited = true;
35886 layoutItems : function( isInstant )
35888 //var items = this._getItemsForLayout( this.items );
35889 // original code supports filtering layout items.. we just ignore it..
35891 this._layoutItems( this.bricks , isInstant );
35893 this._postLayout();
35895 _layoutItems : function ( items , isInstant)
35897 //this.fireEvent( 'layout', this, items );
35900 if ( !items || !items.elements.length ) {
35901 // no items, emit event with empty array
35906 items.each(function(item) {
35907 Roo.log("layout item");
35909 // get x/y object from method
35910 var position = this._getItemLayoutPosition( item );
35912 position.item = item;
35913 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
35914 queue.push( position );
35917 this._processLayoutQueue( queue );
35919 /** Sets position of item in DOM
35920 * @param {Element} item
35921 * @param {Number} x - horizontal position
35922 * @param {Number} y - vertical position
35923 * @param {Boolean} isInstant - disables transitions
35925 _processLayoutQueue : function( queue )
35927 for ( var i=0, len = queue.length; i < len; i++ ) {
35928 var obj = queue[i];
35929 obj.item.position('absolute');
35930 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
35936 * Any logic you want to do after each layout,
35937 * i.e. size the container
35939 _postLayout : function()
35941 this.resizeContainer();
35944 resizeContainer : function()
35946 if ( !this.isResizingContainer ) {
35949 var size = this._getContainerSize();
35951 this.el.setSize(size.width,size.height);
35952 this.boxesEl.setSize(size.width,size.height);
35958 _resetLayout : function()
35960 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
35961 this.colWidth = this.el.getWidth();
35962 //this.gutter = this.el.getWidth();
35964 this.measureColumns();
35970 this.colYs.push( 0 );
35976 measureColumns : function()
35978 this.getContainerWidth();
35979 // if columnWidth is 0, default to outerWidth of first item
35980 if ( !this.columnWidth ) {
35981 var firstItem = this.bricks.first();
35982 Roo.log(firstItem);
35983 this.columnWidth = this.containerWidth;
35984 if (firstItem && firstItem.attr('originalwidth') ) {
35985 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
35987 // columnWidth fall back to item of first element
35988 Roo.log("set column width?");
35989 this.initialColumnWidth = this.columnWidth ;
35991 // if first elem has no width, default to size of container
35996 if (this.initialColumnWidth) {
35997 this.columnWidth = this.initialColumnWidth;
36002 // column width is fixed at the top - however if container width get's smaller we should
36005 // this bit calcs how man columns..
36007 var columnWidth = this.columnWidth += this.gutter;
36009 // calculate columns
36010 var containerWidth = this.containerWidth + this.gutter;
36012 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
36013 // fix rounding errors, typically with gutters
36014 var excess = columnWidth - containerWidth % columnWidth;
36017 // if overshoot is less than a pixel, round up, otherwise floor it
36018 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
36019 cols = Math[ mathMethod ]( cols );
36020 this.cols = Math.max( cols, 1 );
36021 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
36023 // padding positioning..
36024 var totalColWidth = this.cols * this.columnWidth;
36025 var padavail = this.containerWidth - totalColWidth;
36026 // so for 2 columns - we need 3 'pads'
36028 var padNeeded = (1+this.cols) * this.padWidth;
36030 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
36032 this.columnWidth += padExtra
36033 //this.padWidth = Math.floor(padavail / ( this.cols));
36035 // adjust colum width so that padding is fixed??
36037 // we have 3 columns ... total = width * 3
36038 // we have X left over... that should be used by
36040 //if (this.expandC) {
36048 getContainerWidth : function()
36050 /* // container is parent if fit width
36051 var container = this.isFitWidth ? this.element.parentNode : this.element;
36052 // check that this.size and size are there
36053 // IE8 triggers resize on body size change, so they might not be
36055 var size = getSize( container ); //FIXME
36056 this.containerWidth = size && size.innerWidth; //FIXME
36059 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
36063 _getItemLayoutPosition : function( item ) // what is item?
36065 // we resize the item to our columnWidth..
36067 item.setWidth(this.columnWidth);
36068 item.autoBoxAdjust = false;
36070 var sz = item.getSize();
36072 // how many columns does this brick span
36073 var remainder = this.containerWidth % this.columnWidth;
36075 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
36076 // round if off by 1 pixel, otherwise use ceil
36077 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
36078 colSpan = Math.min( colSpan, this.cols );
36080 // normally this should be '1' as we dont' currently allow multi width columns..
36082 var colGroup = this._getColGroup( colSpan );
36083 // get the minimum Y value from the columns
36084 var minimumY = Math.min.apply( Math, colGroup );
36085 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
36087 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
36089 // position the brick
36091 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
36092 y: this.currentSize.y + minimumY + this.padHeight
36096 // apply setHeight to necessary columns
36097 var setHeight = minimumY + sz.height + this.padHeight;
36098 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
36100 var setSpan = this.cols + 1 - colGroup.length;
36101 for ( var i = 0; i < setSpan; i++ ) {
36102 this.colYs[ shortColIndex + i ] = setHeight ;
36109 * @param {Number} colSpan - number of columns the element spans
36110 * @returns {Array} colGroup
36112 _getColGroup : function( colSpan )
36114 if ( colSpan < 2 ) {
36115 // if brick spans only one column, use all the column Ys
36120 // how many different places could this brick fit horizontally
36121 var groupCount = this.cols + 1 - colSpan;
36122 // for each group potential horizontal position
36123 for ( var i = 0; i < groupCount; i++ ) {
36124 // make an array of colY values for that one group
36125 var groupColYs = this.colYs.slice( i, i + colSpan );
36126 // and get the max value of the array
36127 colGroup[i] = Math.max.apply( Math, groupColYs );
36132 _manageStamp : function( stamp )
36134 var stampSize = stamp.getSize();
36135 var offset = stamp.getBox();
36136 // get the columns that this stamp affects
36137 var firstX = this.isOriginLeft ? offset.x : offset.right;
36138 var lastX = firstX + stampSize.width;
36139 var firstCol = Math.floor( firstX / this.columnWidth );
36140 firstCol = Math.max( 0, firstCol );
36142 var lastCol = Math.floor( lastX / this.columnWidth );
36143 // lastCol should not go over if multiple of columnWidth #425
36144 lastCol -= lastX % this.columnWidth ? 0 : 1;
36145 lastCol = Math.min( this.cols - 1, lastCol );
36147 // set colYs to bottom of the stamp
36148 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
36151 for ( var i = firstCol; i <= lastCol; i++ ) {
36152 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
36157 _getContainerSize : function()
36159 this.maxY = Math.max.apply( Math, this.colYs );
36164 if ( this.isFitWidth ) {
36165 size.width = this._getContainerFitWidth();
36171 _getContainerFitWidth : function()
36173 var unusedCols = 0;
36174 // count unused columns
36177 if ( this.colYs[i] !== 0 ) {
36182 // fit container to columns that have been used
36183 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
36186 needsResizeLayout : function()
36188 var previousWidth = this.containerWidth;
36189 this.getContainerWidth();
36190 return previousWidth !== this.containerWidth;
36205 * @class Roo.bootstrap.MasonryBrick
36206 * @extends Roo.bootstrap.Component
36207 * Bootstrap MasonryBrick class
36210 * Create a new MasonryBrick
36211 * @param {Object} config The config object
36214 Roo.bootstrap.MasonryBrick = function(config){
36216 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
36218 Roo.bootstrap.MasonryBrick.register(this);
36224 * When a MasonryBrick is clcik
36225 * @param {Roo.bootstrap.MasonryBrick} this
36226 * @param {Roo.EventObject} e
36232 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
36235 * @cfg {String} title
36239 * @cfg {String} html
36243 * @cfg {String} bgimage
36247 * @cfg {String} videourl
36251 * @cfg {String} cls
36255 * @cfg {String} href
36259 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
36264 * @cfg {String} placetitle (center|bottom)
36269 * @cfg {Boolean} isFitContainer defalut true
36271 isFitContainer : true,
36274 * @cfg {Boolean} preventDefault defalut false
36276 preventDefault : false,
36279 * @cfg {Boolean} inverse defalut false
36281 maskInverse : false,
36283 getAutoCreate : function()
36285 if(!this.isFitContainer){
36286 return this.getSplitAutoCreate();
36289 var cls = 'masonry-brick masonry-brick-full';
36291 if(this.href.length){
36292 cls += ' masonry-brick-link';
36295 if(this.bgimage.length){
36296 cls += ' masonry-brick-image';
36299 if(this.maskInverse){
36300 cls += ' mask-inverse';
36303 if(!this.html.length && !this.maskInverse && !this.videourl.length){
36304 cls += ' enable-mask';
36308 cls += ' masonry-' + this.size + '-brick';
36311 if(this.placetitle.length){
36313 switch (this.placetitle) {
36315 cls += ' masonry-center-title';
36318 cls += ' masonry-bottom-title';
36325 if(!this.html.length && !this.bgimage.length){
36326 cls += ' masonry-center-title';
36329 if(!this.html.length && this.bgimage.length){
36330 cls += ' masonry-bottom-title';
36335 cls += ' ' + this.cls;
36339 tag: (this.href.length) ? 'a' : 'div',
36344 cls: 'masonry-brick-mask'
36348 cls: 'masonry-brick-paragraph',
36354 if(this.href.length){
36355 cfg.href = this.href;
36358 var cn = cfg.cn[1].cn;
36360 if(this.title.length){
36363 cls: 'masonry-brick-title',
36368 if(this.html.length){
36371 cls: 'masonry-brick-text',
36376 if (!this.title.length && !this.html.length) {
36377 cfg.cn[1].cls += ' hide';
36380 if(this.bgimage.length){
36383 cls: 'masonry-brick-image-view',
36388 if(this.videourl.length){
36389 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
36390 // youtube support only?
36393 cls: 'masonry-brick-image-view',
36396 allowfullscreen : true
36404 getSplitAutoCreate : function()
36406 var cls = 'masonry-brick masonry-brick-split';
36408 if(this.href.length){
36409 cls += ' masonry-brick-link';
36412 if(this.bgimage.length){
36413 cls += ' masonry-brick-image';
36417 cls += ' masonry-' + this.size + '-brick';
36420 switch (this.placetitle) {
36422 cls += ' masonry-center-title';
36425 cls += ' masonry-bottom-title';
36428 if(!this.bgimage.length){
36429 cls += ' masonry-center-title';
36432 if(this.bgimage.length){
36433 cls += ' masonry-bottom-title';
36439 cls += ' ' + this.cls;
36443 tag: (this.href.length) ? 'a' : 'div',
36448 cls: 'masonry-brick-split-head',
36452 cls: 'masonry-brick-paragraph',
36459 cls: 'masonry-brick-split-body',
36465 if(this.href.length){
36466 cfg.href = this.href;
36469 if(this.title.length){
36470 cfg.cn[0].cn[0].cn.push({
36472 cls: 'masonry-brick-title',
36477 if(this.html.length){
36478 cfg.cn[1].cn.push({
36480 cls: 'masonry-brick-text',
36485 if(this.bgimage.length){
36486 cfg.cn[0].cn.push({
36488 cls: 'masonry-brick-image-view',
36493 if(this.videourl.length){
36494 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
36495 // youtube support only?
36496 cfg.cn[0].cn.cn.push({
36498 cls: 'masonry-brick-image-view',
36501 allowfullscreen : true
36508 initEvents: function()
36510 switch (this.size) {
36543 this.el.on('touchstart', this.onTouchStart, this);
36544 this.el.on('touchmove', this.onTouchMove, this);
36545 this.el.on('touchend', this.onTouchEnd, this);
36546 this.el.on('contextmenu', this.onContextMenu, this);
36548 this.el.on('mouseenter' ,this.enter, this);
36549 this.el.on('mouseleave', this.leave, this);
36550 this.el.on('click', this.onClick, this);
36553 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
36554 this.parent().bricks.push(this);
36559 onClick: function(e, el)
36561 var time = this.endTimer - this.startTimer;
36562 // Roo.log(e.preventDefault());
36565 e.preventDefault();
36570 if(!this.preventDefault){
36574 e.preventDefault();
36576 if (this.activeClass != '') {
36577 this.selectBrick();
36580 this.fireEvent('click', this, e);
36583 enter: function(e, el)
36585 e.preventDefault();
36587 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
36591 if(this.bgimage.length && this.html.length){
36592 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
36596 leave: function(e, el)
36598 e.preventDefault();
36600 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
36604 if(this.bgimage.length && this.html.length){
36605 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
36609 onTouchStart: function(e, el)
36611 // e.preventDefault();
36613 this.touchmoved = false;
36615 if(!this.isFitContainer){
36619 if(!this.bgimage.length || !this.html.length){
36623 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
36625 this.timer = new Date().getTime();
36629 onTouchMove: function(e, el)
36631 this.touchmoved = true;
36634 onContextMenu : function(e,el)
36636 e.preventDefault();
36637 e.stopPropagation();
36641 onTouchEnd: function(e, el)
36643 // e.preventDefault();
36645 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
36652 if(!this.bgimage.length || !this.html.length){
36654 if(this.href.length){
36655 window.location.href = this.href;
36661 if(!this.isFitContainer){
36665 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
36667 window.location.href = this.href;
36670 //selection on single brick only
36671 selectBrick : function() {
36673 if (!this.parentId) {
36677 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
36678 var index = m.selectedBrick.indexOf(this.id);
36681 m.selectedBrick.splice(index,1);
36682 this.el.removeClass(this.activeClass);
36686 for(var i = 0; i < m.selectedBrick.length; i++) {
36687 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
36688 b.el.removeClass(b.activeClass);
36691 m.selectedBrick = [];
36693 m.selectedBrick.push(this.id);
36694 this.el.addClass(this.activeClass);
36698 isSelected : function(){
36699 return this.el.hasClass(this.activeClass);
36704 Roo.apply(Roo.bootstrap.MasonryBrick, {
36707 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
36709 * register a Masonry Brick
36710 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
36713 register : function(brick)
36715 //this.groups[brick.id] = brick;
36716 this.groups.add(brick.id, brick);
36719 * fetch a masonry brick based on the masonry brick ID
36720 * @param {string} the masonry brick to add
36721 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
36724 get: function(brick_id)
36726 // if (typeof(this.groups[brick_id]) == 'undefined') {
36729 // return this.groups[brick_id] ;
36731 if(this.groups.key(brick_id)) {
36732 return this.groups.key(brick_id);
36750 * @class Roo.bootstrap.Brick
36751 * @extends Roo.bootstrap.Component
36752 * Bootstrap Brick class
36755 * Create a new Brick
36756 * @param {Object} config The config object
36759 Roo.bootstrap.Brick = function(config){
36760 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
36766 * When a Brick is click
36767 * @param {Roo.bootstrap.Brick} this
36768 * @param {Roo.EventObject} e
36774 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
36777 * @cfg {String} title
36781 * @cfg {String} html
36785 * @cfg {String} bgimage
36789 * @cfg {String} cls
36793 * @cfg {String} href
36797 * @cfg {String} video
36801 * @cfg {Boolean} square
36805 getAutoCreate : function()
36807 var cls = 'roo-brick';
36809 if(this.href.length){
36810 cls += ' roo-brick-link';
36813 if(this.bgimage.length){
36814 cls += ' roo-brick-image';
36817 if(!this.html.length && !this.bgimage.length){
36818 cls += ' roo-brick-center-title';
36821 if(!this.html.length && this.bgimage.length){
36822 cls += ' roo-brick-bottom-title';
36826 cls += ' ' + this.cls;
36830 tag: (this.href.length) ? 'a' : 'div',
36835 cls: 'roo-brick-paragraph',
36841 if(this.href.length){
36842 cfg.href = this.href;
36845 var cn = cfg.cn[0].cn;
36847 if(this.title.length){
36850 cls: 'roo-brick-title',
36855 if(this.html.length){
36858 cls: 'roo-brick-text',
36865 if(this.bgimage.length){
36868 cls: 'roo-brick-image-view',
36876 initEvents: function()
36878 if(this.title.length || this.html.length){
36879 this.el.on('mouseenter' ,this.enter, this);
36880 this.el.on('mouseleave', this.leave, this);
36883 Roo.EventManager.onWindowResize(this.resize, this);
36885 if(this.bgimage.length){
36886 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
36887 this.imageEl.on('load', this.onImageLoad, this);
36894 onImageLoad : function()
36899 resize : function()
36901 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
36903 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
36905 if(this.bgimage.length){
36906 var image = this.el.select('.roo-brick-image-view', true).first();
36908 image.setWidth(paragraph.getWidth());
36911 image.setHeight(paragraph.getWidth());
36914 this.el.setHeight(image.getHeight());
36915 paragraph.setHeight(image.getHeight());
36921 enter: function(e, el)
36923 e.preventDefault();
36925 if(this.bgimage.length){
36926 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
36927 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
36931 leave: function(e, el)
36933 e.preventDefault();
36935 if(this.bgimage.length){
36936 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
36937 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
36952 * @class Roo.bootstrap.NumberField
36953 * @extends Roo.bootstrap.Input
36954 * Bootstrap NumberField class
36960 * Create a new NumberField
36961 * @param {Object} config The config object
36964 Roo.bootstrap.NumberField = function(config){
36965 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
36968 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
36971 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
36973 allowDecimals : true,
36975 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
36977 decimalSeparator : ".",
36979 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
36981 decimalPrecision : 2,
36983 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
36985 allowNegative : true,
36988 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
36992 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
36994 minValue : Number.NEGATIVE_INFINITY,
36996 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
36998 maxValue : Number.MAX_VALUE,
37000 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
37002 minText : "The minimum value for this field is {0}",
37004 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
37006 maxText : "The maximum value for this field is {0}",
37008 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
37009 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
37011 nanText : "{0} is not a valid number",
37013 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
37015 thousandsDelimiter : false,
37017 * @cfg {String} valueAlign alignment of value
37019 valueAlign : "left",
37021 getAutoCreate : function()
37023 var hiddenInput = {
37027 cls: 'hidden-number-input'
37031 hiddenInput.name = this.name;
37036 var cfg = Roo.bootstrap.NumberField.superclass.getAutoCreate.call(this);
37038 this.name = hiddenInput.name;
37040 if(cfg.cn.length > 0) {
37041 cfg.cn.push(hiddenInput);
37048 initEvents : function()
37050 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
37052 var allowed = "0123456789";
37054 if(this.allowDecimals){
37055 allowed += this.decimalSeparator;
37058 if(this.allowNegative){
37062 if(this.thousandsDelimiter) {
37066 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
37068 var keyPress = function(e){
37070 var k = e.getKey();
37072 var c = e.getCharCode();
37075 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
37076 allowed.indexOf(String.fromCharCode(c)) === -1
37082 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
37086 if(allowed.indexOf(String.fromCharCode(c)) === -1){
37091 this.el.on("keypress", keyPress, this);
37094 validateValue : function(value)
37097 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
37101 var num = this.parseValue(value);
37104 this.markInvalid(String.format(this.nanText, value));
37108 if(num < this.minValue){
37109 this.markInvalid(String.format(this.minText, this.minValue));
37113 if(num > this.maxValue){
37114 this.markInvalid(String.format(this.maxText, this.maxValue));
37121 getValue : function()
37123 var v = this.hiddenEl().getValue();
37125 return this.fixPrecision(this.parseValue(v));
37128 parseValue : function(value)
37130 if(this.thousandsDelimiter) {
37132 r = new RegExp(",", "g");
37133 value = value.replace(r, "");
37136 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
37137 return isNaN(value) ? '' : value;
37140 fixPrecision : function(value)
37142 if(this.thousandsDelimiter) {
37144 r = new RegExp(",", "g");
37145 value = value.replace(r, "");
37148 var nan = isNaN(value);
37150 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
37151 return nan ? '' : value;
37153 return parseFloat(value).toFixed(this.decimalPrecision);
37156 setValue : function(v)
37158 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
37164 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
37166 this.inputEl().dom.value = (v == '') ? '' :
37167 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
37169 if(!this.allowZero && v === '0') {
37170 this.hiddenEl().dom.value = '';
37171 this.inputEl().dom.value = '';
37178 decimalPrecisionFcn : function(v)
37180 return Math.floor(v);
37183 beforeBlur : function()
37185 var v = this.parseValue(this.getRawValue());
37187 if(v || v === 0 || v === ''){
37192 hiddenEl : function()
37194 return this.el.select('input.hidden-number-input',true).first();
37206 * @class Roo.bootstrap.DocumentSlider
37207 * @extends Roo.bootstrap.Component
37208 * Bootstrap DocumentSlider class
37211 * Create a new DocumentViewer
37212 * @param {Object} config The config object
37215 Roo.bootstrap.DocumentSlider = function(config){
37216 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
37223 * Fire after initEvent
37224 * @param {Roo.bootstrap.DocumentSlider} this
37229 * Fire after update
37230 * @param {Roo.bootstrap.DocumentSlider} this
37236 * @param {Roo.bootstrap.DocumentSlider} this
37242 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
37248 getAutoCreate : function()
37252 cls : 'roo-document-slider',
37256 cls : 'roo-document-slider-header',
37260 cls : 'roo-document-slider-header-title'
37266 cls : 'roo-document-slider-body',
37270 cls : 'roo-document-slider-prev',
37274 cls : 'fa fa-chevron-left'
37280 cls : 'roo-document-slider-thumb',
37284 cls : 'roo-document-slider-image'
37290 cls : 'roo-document-slider-next',
37294 cls : 'fa fa-chevron-right'
37306 initEvents : function()
37308 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
37309 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
37311 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
37312 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
37314 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
37315 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
37317 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
37318 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
37320 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
37321 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
37323 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
37324 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
37326 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
37327 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
37329 this.thumbEl.on('click', this.onClick, this);
37331 this.prevIndicator.on('click', this.prev, this);
37333 this.nextIndicator.on('click', this.next, this);
37337 initial : function()
37339 if(this.files.length){
37340 this.indicator = 1;
37344 this.fireEvent('initial', this);
37347 update : function()
37349 this.imageEl.attr('src', this.files[this.indicator - 1]);
37351 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
37353 this.prevIndicator.show();
37355 if(this.indicator == 1){
37356 this.prevIndicator.hide();
37359 this.nextIndicator.show();
37361 if(this.indicator == this.files.length){
37362 this.nextIndicator.hide();
37365 this.thumbEl.scrollTo('top');
37367 this.fireEvent('update', this);
37370 onClick : function(e)
37372 e.preventDefault();
37374 this.fireEvent('click', this);
37379 e.preventDefault();
37381 this.indicator = Math.max(1, this.indicator - 1);
37388 e.preventDefault();
37390 this.indicator = Math.min(this.files.length, this.indicator + 1);
37404 * @class Roo.bootstrap.RadioSet
37405 * @extends Roo.bootstrap.Input
37406 * Bootstrap RadioSet class
37407 * @cfg {String} indicatorpos (left|right) default left
37408 * @cfg {Boolean} inline (true|false) inline the element (default true)
37409 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
37411 * Create a new RadioSet
37412 * @param {Object} config The config object
37415 Roo.bootstrap.RadioSet = function(config){
37417 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
37421 Roo.bootstrap.RadioSet.register(this);
37426 * Fires when the element is checked or unchecked.
37427 * @param {Roo.bootstrap.RadioSet} this This radio
37428 * @param {Roo.bootstrap.Radio} item The checked item
37433 * Fires when the element is click.
37434 * @param {Roo.bootstrap.RadioSet} this This radio set
37435 * @param {Roo.bootstrap.Radio} item The checked item
37436 * @param {Roo.EventObject} e The event object
37443 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
37451 indicatorpos : 'left',
37453 getAutoCreate : function()
37457 cls : 'roo-radio-set-label',
37461 html : this.fieldLabel
37465 if (Roo.bootstrap.version == 3) {
37468 if(this.indicatorpos == 'left'){
37471 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
37472 tooltip : 'This field is required'
37477 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
37478 tooltip : 'This field is required'
37484 cls : 'roo-radio-set-items'
37487 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
37489 if (align === 'left' && this.fieldLabel.length) {
37492 cls : "roo-radio-set-right",
37498 if(this.labelWidth > 12){
37499 label.style = "width: " + this.labelWidth + 'px';
37502 if(this.labelWidth < 13 && this.labelmd == 0){
37503 this.labelmd = this.labelWidth;
37506 if(this.labellg > 0){
37507 label.cls += ' col-lg-' + this.labellg;
37508 items.cls += ' col-lg-' + (12 - this.labellg);
37511 if(this.labelmd > 0){
37512 label.cls += ' col-md-' + this.labelmd;
37513 items.cls += ' col-md-' + (12 - this.labelmd);
37516 if(this.labelsm > 0){
37517 label.cls += ' col-sm-' + this.labelsm;
37518 items.cls += ' col-sm-' + (12 - this.labelsm);
37521 if(this.labelxs > 0){
37522 label.cls += ' col-xs-' + this.labelxs;
37523 items.cls += ' col-xs-' + (12 - this.labelxs);
37529 cls : 'roo-radio-set',
37533 cls : 'roo-radio-set-input',
37536 value : this.value ? this.value : ''
37543 if(this.weight.length){
37544 cfg.cls += ' roo-radio-' + this.weight;
37548 cfg.cls += ' roo-radio-set-inline';
37552 ['xs','sm','md','lg'].map(function(size){
37553 if (settings[size]) {
37554 cfg.cls += ' col-' + size + '-' + settings[size];
37562 initEvents : function()
37564 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
37565 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
37567 if(!this.fieldLabel.length){
37568 this.labelEl.hide();
37571 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
37572 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
37574 this.indicator = this.indicatorEl();
37576 if(this.indicator){
37577 this.indicator.addClass('invisible');
37580 this.originalValue = this.getValue();
37584 inputEl: function ()
37586 return this.el.select('.roo-radio-set-input', true).first();
37589 getChildContainer : function()
37591 return this.itemsEl;
37594 register : function(item)
37596 this.radioes.push(item);
37600 validate : function()
37602 if(this.getVisibilityEl().hasClass('hidden')){
37608 Roo.each(this.radioes, function(i){
37617 if(this.allowBlank) {
37621 if(this.disabled || valid){
37626 this.markInvalid();
37631 markValid : function()
37633 if(this.labelEl.isVisible(true) && this.indicatorEl()){
37634 this.indicatorEl().removeClass('visible');
37635 this.indicatorEl().addClass('invisible');
37639 if (Roo.bootstrap.version == 3) {
37640 this.el.removeClass([this.invalidClass, this.validClass]);
37641 this.el.addClass(this.validClass);
37643 this.el.removeClass(['is-invalid','is-valid']);
37644 this.el.addClass(['is-valid']);
37646 this.fireEvent('valid', this);
37649 markInvalid : function(msg)
37651 if(this.allowBlank || this.disabled){
37655 if(this.labelEl.isVisible(true) && this.indicatorEl()){
37656 this.indicatorEl().removeClass('invisible');
37657 this.indicatorEl().addClass('visible');
37659 if (Roo.bootstrap.version == 3) {
37660 this.el.removeClass([this.invalidClass, this.validClass]);
37661 this.el.addClass(this.invalidClass);
37663 this.el.removeClass(['is-invalid','is-valid']);
37664 this.el.addClass(['is-invalid']);
37667 this.fireEvent('invalid', this, msg);
37671 setValue : function(v, suppressEvent)
37673 if(this.value === v){
37680 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
37683 Roo.each(this.radioes, function(i){
37685 i.el.removeClass('checked');
37688 Roo.each(this.radioes, function(i){
37690 if(i.value === v || i.value.toString() === v.toString()){
37692 i.el.addClass('checked');
37694 if(suppressEvent !== true){
37695 this.fireEvent('check', this, i);
37706 clearInvalid : function(){
37708 if(!this.el || this.preventMark){
37712 this.el.removeClass([this.invalidClass]);
37714 this.fireEvent('valid', this);
37719 Roo.apply(Roo.bootstrap.RadioSet, {
37723 register : function(set)
37725 this.groups[set.name] = set;
37728 get: function(name)
37730 if (typeof(this.groups[name]) == 'undefined') {
37734 return this.groups[name] ;
37740 * Ext JS Library 1.1.1
37741 * Copyright(c) 2006-2007, Ext JS, LLC.
37743 * Originally Released Under LGPL - original licence link has changed is not relivant.
37746 * <script type="text/javascript">
37751 * @class Roo.bootstrap.SplitBar
37752 * @extends Roo.util.Observable
37753 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
37757 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
37758 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
37759 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
37760 split.minSize = 100;
37761 split.maxSize = 600;
37762 split.animate = true;
37763 split.on('moved', splitterMoved);
37766 * Create a new SplitBar
37767 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
37768 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
37769 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
37770 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
37771 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
37772 position of the SplitBar).
37774 Roo.bootstrap.SplitBar = function(cfg){
37779 // dragElement : elm
37780 // resizingElement: el,
37782 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
37783 // placement : Roo.bootstrap.SplitBar.LEFT ,
37784 // existingProxy ???
37787 this.el = Roo.get(cfg.dragElement, true);
37788 this.el.dom.unselectable = "on";
37790 this.resizingEl = Roo.get(cfg.resizingElement, true);
37794 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
37795 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
37798 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
37801 * The minimum size of the resizing element. (Defaults to 0)
37807 * The maximum size of the resizing element. (Defaults to 2000)
37810 this.maxSize = 2000;
37813 * Whether to animate the transition to the new size
37816 this.animate = false;
37819 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
37822 this.useShim = false;
37827 if(!cfg.existingProxy){
37829 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
37831 this.proxy = Roo.get(cfg.existingProxy).dom;
37834 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
37837 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
37840 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
37843 this.dragSpecs = {};
37846 * @private The adapter to use to positon and resize elements
37848 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
37849 this.adapter.init(this);
37851 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
37853 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
37854 this.el.addClass("roo-splitbar-h");
37857 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
37858 this.el.addClass("roo-splitbar-v");
37864 * Fires when the splitter is moved (alias for {@link #event-moved})
37865 * @param {Roo.bootstrap.SplitBar} this
37866 * @param {Number} newSize the new width or height
37871 * Fires when the splitter is moved
37872 * @param {Roo.bootstrap.SplitBar} this
37873 * @param {Number} newSize the new width or height
37877 * @event beforeresize
37878 * Fires before the splitter is dragged
37879 * @param {Roo.bootstrap.SplitBar} this
37881 "beforeresize" : true,
37883 "beforeapply" : true
37886 Roo.util.Observable.call(this);
37889 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
37890 onStartProxyDrag : function(x, y){
37891 this.fireEvent("beforeresize", this);
37893 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
37895 o.enableDisplayMode("block");
37896 // all splitbars share the same overlay
37897 Roo.bootstrap.SplitBar.prototype.overlay = o;
37899 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
37900 this.overlay.show();
37901 Roo.get(this.proxy).setDisplayed("block");
37902 var size = this.adapter.getElementSize(this);
37903 this.activeMinSize = this.getMinimumSize();;
37904 this.activeMaxSize = this.getMaximumSize();;
37905 var c1 = size - this.activeMinSize;
37906 var c2 = Math.max(this.activeMaxSize - size, 0);
37907 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
37908 this.dd.resetConstraints();
37909 this.dd.setXConstraint(
37910 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
37911 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
37913 this.dd.setYConstraint(0, 0);
37915 this.dd.resetConstraints();
37916 this.dd.setXConstraint(0, 0);
37917 this.dd.setYConstraint(
37918 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
37919 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
37922 this.dragSpecs.startSize = size;
37923 this.dragSpecs.startPoint = [x, y];
37924 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
37928 * @private Called after the drag operation by the DDProxy
37930 onEndProxyDrag : function(e){
37931 Roo.get(this.proxy).setDisplayed(false);
37932 var endPoint = Roo.lib.Event.getXY(e);
37934 this.overlay.hide();
37937 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
37938 newSize = this.dragSpecs.startSize +
37939 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
37940 endPoint[0] - this.dragSpecs.startPoint[0] :
37941 this.dragSpecs.startPoint[0] - endPoint[0]
37944 newSize = this.dragSpecs.startSize +
37945 (this.placement == Roo.bootstrap.SplitBar.TOP ?
37946 endPoint[1] - this.dragSpecs.startPoint[1] :
37947 this.dragSpecs.startPoint[1] - endPoint[1]
37950 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
37951 if(newSize != this.dragSpecs.startSize){
37952 if(this.fireEvent('beforeapply', this, newSize) !== false){
37953 this.adapter.setElementSize(this, newSize);
37954 this.fireEvent("moved", this, newSize);
37955 this.fireEvent("resize", this, newSize);
37961 * Get the adapter this SplitBar uses
37962 * @return The adapter object
37964 getAdapter : function(){
37965 return this.adapter;
37969 * Set the adapter this SplitBar uses
37970 * @param {Object} adapter A SplitBar adapter object
37972 setAdapter : function(adapter){
37973 this.adapter = adapter;
37974 this.adapter.init(this);
37978 * Gets the minimum size for the resizing element
37979 * @return {Number} The minimum size
37981 getMinimumSize : function(){
37982 return this.minSize;
37986 * Sets the minimum size for the resizing element
37987 * @param {Number} minSize The minimum size
37989 setMinimumSize : function(minSize){
37990 this.minSize = minSize;
37994 * Gets the maximum size for the resizing element
37995 * @return {Number} The maximum size
37997 getMaximumSize : function(){
37998 return this.maxSize;
38002 * Sets the maximum size for the resizing element
38003 * @param {Number} maxSize The maximum size
38005 setMaximumSize : function(maxSize){
38006 this.maxSize = maxSize;
38010 * Sets the initialize size for the resizing element
38011 * @param {Number} size The initial size
38013 setCurrentSize : function(size){
38014 var oldAnimate = this.animate;
38015 this.animate = false;
38016 this.adapter.setElementSize(this, size);
38017 this.animate = oldAnimate;
38021 * Destroy this splitbar.
38022 * @param {Boolean} removeEl True to remove the element
38024 destroy : function(removeEl){
38026 this.shim.remove();
38029 this.proxy.parentNode.removeChild(this.proxy);
38037 * @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.
38039 Roo.bootstrap.SplitBar.createProxy = function(dir){
38040 var proxy = new Roo.Element(document.createElement("div"));
38041 proxy.unselectable();
38042 var cls = 'roo-splitbar-proxy';
38043 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
38044 document.body.appendChild(proxy.dom);
38049 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
38050 * Default Adapter. It assumes the splitter and resizing element are not positioned
38051 * elements and only gets/sets the width of the element. Generally used for table based layouts.
38053 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
38056 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
38057 // do nothing for now
38058 init : function(s){
38062 * Called before drag operations to get the current size of the resizing element.
38063 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
38065 getElementSize : function(s){
38066 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
38067 return s.resizingEl.getWidth();
38069 return s.resizingEl.getHeight();
38074 * Called after drag operations to set the size of the resizing element.
38075 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
38076 * @param {Number} newSize The new size to set
38077 * @param {Function} onComplete A function to be invoked when resizing is complete
38079 setElementSize : function(s, newSize, onComplete){
38080 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
38082 s.resizingEl.setWidth(newSize);
38084 onComplete(s, newSize);
38087 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
38092 s.resizingEl.setHeight(newSize);
38094 onComplete(s, newSize);
38097 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
38104 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
38105 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
38106 * Adapter that moves the splitter element to align with the resized sizing element.
38107 * Used with an absolute positioned SplitBar.
38108 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
38109 * document.body, make sure you assign an id to the body element.
38111 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
38112 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
38113 this.container = Roo.get(container);
38116 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
38117 init : function(s){
38118 this.basic.init(s);
38121 getElementSize : function(s){
38122 return this.basic.getElementSize(s);
38125 setElementSize : function(s, newSize, onComplete){
38126 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
38129 moveSplitter : function(s){
38130 var yes = Roo.bootstrap.SplitBar;
38131 switch(s.placement){
38133 s.el.setX(s.resizingEl.getRight());
38136 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
38139 s.el.setY(s.resizingEl.getBottom());
38142 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
38149 * Orientation constant - Create a vertical SplitBar
38153 Roo.bootstrap.SplitBar.VERTICAL = 1;
38156 * Orientation constant - Create a horizontal SplitBar
38160 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
38163 * Placement constant - The resizing element is to the left of the splitter element
38167 Roo.bootstrap.SplitBar.LEFT = 1;
38170 * Placement constant - The resizing element is to the right of the splitter element
38174 Roo.bootstrap.SplitBar.RIGHT = 2;
38177 * Placement constant - The resizing element is positioned above the splitter element
38181 Roo.bootstrap.SplitBar.TOP = 3;
38184 * Placement constant - The resizing element is positioned under splitter element
38188 Roo.bootstrap.SplitBar.BOTTOM = 4;
38189 Roo.namespace("Roo.bootstrap.layout");/*
38191 * Ext JS Library 1.1.1
38192 * Copyright(c) 2006-2007, Ext JS, LLC.
38194 * Originally Released Under LGPL - original licence link has changed is not relivant.
38197 * <script type="text/javascript">
38201 * @class Roo.bootstrap.layout.Manager
38202 * @extends Roo.bootstrap.Component
38203 * Base class for layout managers.
38205 Roo.bootstrap.layout.Manager = function(config)
38207 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
38213 /** false to disable window resize monitoring @type Boolean */
38214 this.monitorWindowResize = true;
38219 * Fires when a layout is performed.
38220 * @param {Roo.LayoutManager} this
38224 * @event regionresized
38225 * Fires when the user resizes a region.
38226 * @param {Roo.LayoutRegion} region The resized region
38227 * @param {Number} newSize The new size (width for east/west, height for north/south)
38229 "regionresized" : true,
38231 * @event regioncollapsed
38232 * Fires when a region is collapsed.
38233 * @param {Roo.LayoutRegion} region The collapsed region
38235 "regioncollapsed" : true,
38237 * @event regionexpanded
38238 * Fires when a region is expanded.
38239 * @param {Roo.LayoutRegion} region The expanded region
38241 "regionexpanded" : true
38243 this.updating = false;
38246 this.el = Roo.get(config.el);
38252 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
38257 monitorWindowResize : true,
38263 onRender : function(ct, position)
38266 this.el = Roo.get(ct);
38269 //this.fireEvent('render',this);
38273 initEvents: function()
38277 // ie scrollbar fix
38278 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
38279 document.body.scroll = "no";
38280 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
38281 this.el.position('relative');
38283 this.id = this.el.id;
38284 this.el.addClass("roo-layout-container");
38285 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
38286 if(this.el.dom != document.body ) {
38287 this.el.on('resize', this.layout,this);
38288 this.el.on('show', this.layout,this);
38294 * Returns true if this layout is currently being updated
38295 * @return {Boolean}
38297 isUpdating : function(){
38298 return this.updating;
38302 * Suspend the LayoutManager from doing auto-layouts while
38303 * making multiple add or remove calls
38305 beginUpdate : function(){
38306 this.updating = true;
38310 * Restore auto-layouts and optionally disable the manager from performing a layout
38311 * @param {Boolean} noLayout true to disable a layout update
38313 endUpdate : function(noLayout){
38314 this.updating = false;
38320 layout: function(){
38324 onRegionResized : function(region, newSize){
38325 this.fireEvent("regionresized", region, newSize);
38329 onRegionCollapsed : function(region){
38330 this.fireEvent("regioncollapsed", region);
38333 onRegionExpanded : function(region){
38334 this.fireEvent("regionexpanded", region);
38338 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
38339 * performs box-model adjustments.
38340 * @return {Object} The size as an object {width: (the width), height: (the height)}
38342 getViewSize : function()
38345 if(this.el.dom != document.body){
38346 size = this.el.getSize();
38348 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
38350 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
38351 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
38356 * Returns the Element this layout is bound to.
38357 * @return {Roo.Element}
38359 getEl : function(){
38364 * Returns the specified region.
38365 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
38366 * @return {Roo.LayoutRegion}
38368 getRegion : function(target){
38369 return this.regions[target.toLowerCase()];
38372 onWindowResize : function(){
38373 if(this.monitorWindowResize){
38380 * Ext JS Library 1.1.1
38381 * Copyright(c) 2006-2007, Ext JS, LLC.
38383 * Originally Released Under LGPL - original licence link has changed is not relivant.
38386 * <script type="text/javascript">
38389 * @class Roo.bootstrap.layout.Border
38390 * @extends Roo.bootstrap.layout.Manager
38392 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
38393 * please see: examples/bootstrap/nested.html<br><br>
38395 <b>The container the layout is rendered into can be either the body element or any other element.
38396 If it is not the body element, the container needs to either be an absolute positioned element,
38397 or you will need to add "position:relative" to the css of the container. You will also need to specify
38398 the container size if it is not the body element.</b>
38401 * Create a new Border
38402 * @param {Object} config Configuration options
38404 Roo.bootstrap.layout.Border = function(config){
38405 config = config || {};
38406 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
38410 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
38411 if(config[region]){
38412 config[region].region = region;
38413 this.addRegion(config[region]);
38419 Roo.bootstrap.layout.Border.regions = ["center", "north","south","east","west"];
38421 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
38423 parent : false, // this might point to a 'nest' or a ???
38426 * Creates and adds a new region if it doesn't already exist.
38427 * @param {String} target The target region key (north, south, east, west or center).
38428 * @param {Object} config The regions config object
38429 * @return {BorderLayoutRegion} The new region
38431 addRegion : function(config)
38433 if(!this.regions[config.region]){
38434 var r = this.factory(config);
38435 this.bindRegion(r);
38437 return this.regions[config.region];
38441 bindRegion : function(r){
38442 this.regions[r.config.region] = r;
38444 r.on("visibilitychange", this.layout, this);
38445 r.on("paneladded", this.layout, this);
38446 r.on("panelremoved", this.layout, this);
38447 r.on("invalidated", this.layout, this);
38448 r.on("resized", this.onRegionResized, this);
38449 r.on("collapsed", this.onRegionCollapsed, this);
38450 r.on("expanded", this.onRegionExpanded, this);
38454 * Performs a layout update.
38456 layout : function()
38458 if(this.updating) {
38462 // render all the rebions if they have not been done alreayd?
38463 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
38464 if(this.regions[region] && !this.regions[region].bodyEl){
38465 this.regions[region].onRender(this.el)
38469 var size = this.getViewSize();
38470 var w = size.width;
38471 var h = size.height;
38476 //var x = 0, y = 0;
38478 var rs = this.regions;
38479 var north = rs["north"];
38480 var south = rs["south"];
38481 var west = rs["west"];
38482 var east = rs["east"];
38483 var center = rs["center"];
38484 //if(this.hideOnLayout){ // not supported anymore
38485 //c.el.setStyle("display", "none");
38487 if(north && north.isVisible()){
38488 var b = north.getBox();
38489 var m = north.getMargins();
38490 b.width = w - (m.left+m.right);
38493 centerY = b.height + b.y + m.bottom;
38494 centerH -= centerY;
38495 north.updateBox(this.safeBox(b));
38497 if(south && south.isVisible()){
38498 var b = south.getBox();
38499 var m = south.getMargins();
38500 b.width = w - (m.left+m.right);
38502 var totalHeight = (b.height + m.top + m.bottom);
38503 b.y = h - totalHeight + m.top;
38504 centerH -= totalHeight;
38505 south.updateBox(this.safeBox(b));
38507 if(west && west.isVisible()){
38508 var b = west.getBox();
38509 var m = west.getMargins();
38510 b.height = centerH - (m.top+m.bottom);
38512 b.y = centerY + m.top;
38513 var totalWidth = (b.width + m.left + m.right);
38514 centerX += totalWidth;
38515 centerW -= totalWidth;
38516 west.updateBox(this.safeBox(b));
38518 if(east && east.isVisible()){
38519 var b = east.getBox();
38520 var m = east.getMargins();
38521 b.height = centerH - (m.top+m.bottom);
38522 var totalWidth = (b.width + m.left + m.right);
38523 b.x = w - totalWidth + m.left;
38524 b.y = centerY + m.top;
38525 centerW -= totalWidth;
38526 east.updateBox(this.safeBox(b));
38529 var m = center.getMargins();
38531 x: centerX + m.left,
38532 y: centerY + m.top,
38533 width: centerW - (m.left+m.right),
38534 height: centerH - (m.top+m.bottom)
38536 //if(this.hideOnLayout){
38537 //center.el.setStyle("display", "block");
38539 center.updateBox(this.safeBox(centerBox));
38542 this.fireEvent("layout", this);
38546 safeBox : function(box){
38547 box.width = Math.max(0, box.width);
38548 box.height = Math.max(0, box.height);
38553 * Adds a ContentPanel (or subclass) to this layout.
38554 * @param {String} target The target region key (north, south, east, west or center).
38555 * @param {Roo.ContentPanel} panel The panel to add
38556 * @return {Roo.ContentPanel} The added panel
38558 add : function(target, panel){
38560 target = target.toLowerCase();
38561 return this.regions[target].add(panel);
38565 * Remove a ContentPanel (or subclass) to this layout.
38566 * @param {String} target The target region key (north, south, east, west or center).
38567 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
38568 * @return {Roo.ContentPanel} The removed panel
38570 remove : function(target, panel){
38571 target = target.toLowerCase();
38572 return this.regions[target].remove(panel);
38576 * Searches all regions for a panel with the specified id
38577 * @param {String} panelId
38578 * @return {Roo.ContentPanel} The panel or null if it wasn't found
38580 findPanel : function(panelId){
38581 var rs = this.regions;
38582 for(var target in rs){
38583 if(typeof rs[target] != "function"){
38584 var p = rs[target].getPanel(panelId);
38594 * Searches all regions for a panel with the specified id and activates (shows) it.
38595 * @param {String/ContentPanel} panelId The panels id or the panel itself
38596 * @return {Roo.ContentPanel} The shown panel or null
38598 showPanel : function(panelId) {
38599 var rs = this.regions;
38600 for(var target in rs){
38601 var r = rs[target];
38602 if(typeof r != "function"){
38603 if(r.hasPanel(panelId)){
38604 return r.showPanel(panelId);
38612 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
38613 * @param {Roo.state.Provider} provider (optional) An alternate state provider
38616 restoreState : function(provider){
38618 provider = Roo.state.Manager;
38620 var sm = new Roo.LayoutStateManager();
38621 sm.init(this, provider);
38627 * Adds a xtype elements to the layout.
38631 xtype : 'ContentPanel',
38638 xtype : 'NestedLayoutPanel',
38644 items : [ ... list of content panels or nested layout panels.. ]
38648 * @param {Object} cfg Xtype definition of item to add.
38650 addxtype : function(cfg)
38652 // basically accepts a pannel...
38653 // can accept a layout region..!?!?
38654 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
38657 // theory? children can only be panels??
38659 //if (!cfg.xtype.match(/Panel$/)) {
38664 if (typeof(cfg.region) == 'undefined') {
38665 Roo.log("Failed to add Panel, region was not set");
38669 var region = cfg.region;
38675 xitems = cfg.items;
38680 if ( region == 'center') {
38681 Roo.log("Center: " + cfg.title);
38687 case 'Content': // ContentPanel (el, cfg)
38688 case 'Scroll': // ContentPanel (el, cfg)
38690 cfg.autoCreate = cfg.autoCreate || true;
38691 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
38693 // var el = this.el.createChild();
38694 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
38697 this.add(region, ret);
38701 case 'TreePanel': // our new panel!
38702 cfg.el = this.el.createChild();
38703 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
38704 this.add(region, ret);
38709 // create a new Layout (which is a Border Layout...
38711 var clayout = cfg.layout;
38712 clayout.el = this.el.createChild();
38713 clayout.items = clayout.items || [];
38717 // replace this exitems with the clayout ones..
38718 xitems = clayout.items;
38720 // force background off if it's in center...
38721 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
38722 cfg.background = false;
38724 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
38727 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
38728 //console.log('adding nested layout panel ' + cfg.toSource());
38729 this.add(region, ret);
38730 nb = {}; /// find first...
38735 // needs grid and region
38737 //var el = this.getRegion(region).el.createChild();
38739 *var el = this.el.createChild();
38740 // create the grid first...
38741 cfg.grid.container = el;
38742 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
38745 if (region == 'center' && this.active ) {
38746 cfg.background = false;
38749 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
38751 this.add(region, ret);
38753 if (cfg.background) {
38754 // render grid on panel activation (if panel background)
38755 ret.on('activate', function(gp) {
38756 if (!gp.grid.rendered) {
38757 // gp.grid.render(el);
38761 // cfg.grid.render(el);
38767 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
38768 // it was the old xcomponent building that caused this before.
38769 // espeically if border is the top element in the tree.
38779 if (typeof(Roo[cfg.xtype]) != 'undefined') {
38781 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
38782 this.add(region, ret);
38786 throw "Can not add '" + cfg.xtype + "' to Border";
38792 this.beginUpdate();
38796 Roo.each(xitems, function(i) {
38797 region = nb && i.region ? i.region : false;
38799 var add = ret.addxtype(i);
38802 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
38803 if (!i.background) {
38804 abn[region] = nb[region] ;
38811 // make the last non-background panel active..
38812 //if (nb) { Roo.log(abn); }
38815 for(var r in abn) {
38816 region = this.getRegion(r);
38818 // tried using nb[r], but it does not work..
38820 region.showPanel(abn[r]);
38831 factory : function(cfg)
38834 var validRegions = Roo.bootstrap.layout.Border.regions;
38836 var target = cfg.region;
38839 var r = Roo.bootstrap.layout;
38843 return new r.North(cfg);
38845 return new r.South(cfg);
38847 return new r.East(cfg);
38849 return new r.West(cfg);
38851 return new r.Center(cfg);
38853 throw 'Layout region "'+target+'" not supported.';
38860 * Ext JS Library 1.1.1
38861 * Copyright(c) 2006-2007, Ext JS, LLC.
38863 * Originally Released Under LGPL - original licence link has changed is not relivant.
38866 * <script type="text/javascript">
38870 * @class Roo.bootstrap.layout.Basic
38871 * @extends Roo.util.Observable
38872 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
38873 * and does not have a titlebar, tabs or any other features. All it does is size and position
38874 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
38875 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
38876 * @cfg {string} region the region that it inhabits..
38877 * @cfg {bool} skipConfig skip config?
38881 Roo.bootstrap.layout.Basic = function(config){
38883 this.mgr = config.mgr;
38885 this.position = config.region;
38887 var skipConfig = config.skipConfig;
38891 * @scope Roo.BasicLayoutRegion
38895 * @event beforeremove
38896 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
38897 * @param {Roo.LayoutRegion} this
38898 * @param {Roo.ContentPanel} panel The panel
38899 * @param {Object} e The cancel event object
38901 "beforeremove" : true,
38903 * @event invalidated
38904 * Fires when the layout for this region is changed.
38905 * @param {Roo.LayoutRegion} this
38907 "invalidated" : true,
38909 * @event visibilitychange
38910 * Fires when this region is shown or hidden
38911 * @param {Roo.LayoutRegion} this
38912 * @param {Boolean} visibility true or false
38914 "visibilitychange" : true,
38916 * @event paneladded
38917 * Fires when a panel is added.
38918 * @param {Roo.LayoutRegion} this
38919 * @param {Roo.ContentPanel} panel The panel
38921 "paneladded" : true,
38923 * @event panelremoved
38924 * Fires when a panel is removed.
38925 * @param {Roo.LayoutRegion} this
38926 * @param {Roo.ContentPanel} panel The panel
38928 "panelremoved" : true,
38930 * @event beforecollapse
38931 * Fires when this region before collapse.
38932 * @param {Roo.LayoutRegion} this
38934 "beforecollapse" : true,
38937 * Fires when this region is collapsed.
38938 * @param {Roo.LayoutRegion} this
38940 "collapsed" : true,
38943 * Fires when this region is expanded.
38944 * @param {Roo.LayoutRegion} this
38949 * Fires when this region is slid into view.
38950 * @param {Roo.LayoutRegion} this
38952 "slideshow" : true,
38955 * Fires when this region slides out of view.
38956 * @param {Roo.LayoutRegion} this
38958 "slidehide" : true,
38960 * @event panelactivated
38961 * Fires when a panel is activated.
38962 * @param {Roo.LayoutRegion} this
38963 * @param {Roo.ContentPanel} panel The activated panel
38965 "panelactivated" : true,
38968 * Fires when the user resizes this region.
38969 * @param {Roo.LayoutRegion} this
38970 * @param {Number} newSize The new size (width for east/west, height for north/south)
38974 /** A collection of panels in this region. @type Roo.util.MixedCollection */
38975 this.panels = new Roo.util.MixedCollection();
38976 this.panels.getKey = this.getPanelId.createDelegate(this);
38978 this.activePanel = null;
38979 // ensure listeners are added...
38981 if (config.listeners || config.events) {
38982 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
38983 listeners : config.listeners || {},
38984 events : config.events || {}
38988 if(skipConfig !== true){
38989 this.applyConfig(config);
38993 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
38995 getPanelId : function(p){
38999 applyConfig : function(config){
39000 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
39001 this.config = config;
39006 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
39007 * the width, for horizontal (north, south) the height.
39008 * @param {Number} newSize The new width or height
39010 resizeTo : function(newSize){
39011 var el = this.el ? this.el :
39012 (this.activePanel ? this.activePanel.getEl() : null);
39014 switch(this.position){
39017 el.setWidth(newSize);
39018 this.fireEvent("resized", this, newSize);
39022 el.setHeight(newSize);
39023 this.fireEvent("resized", this, newSize);
39029 getBox : function(){
39030 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
39033 getMargins : function(){
39034 return this.margins;
39037 updateBox : function(box){
39039 var el = this.activePanel.getEl();
39040 el.dom.style.left = box.x + "px";
39041 el.dom.style.top = box.y + "px";
39042 this.activePanel.setSize(box.width, box.height);
39046 * Returns the container element for this region.
39047 * @return {Roo.Element}
39049 getEl : function(){
39050 return this.activePanel;
39054 * Returns true if this region is currently visible.
39055 * @return {Boolean}
39057 isVisible : function(){
39058 return this.activePanel ? true : false;
39061 setActivePanel : function(panel){
39062 panel = this.getPanel(panel);
39063 if(this.activePanel && this.activePanel != panel){
39064 this.activePanel.setActiveState(false);
39065 this.activePanel.getEl().setLeftTop(-10000,-10000);
39067 this.activePanel = panel;
39068 panel.setActiveState(true);
39070 panel.setSize(this.box.width, this.box.height);
39072 this.fireEvent("panelactivated", this, panel);
39073 this.fireEvent("invalidated");
39077 * Show the specified panel.
39078 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
39079 * @return {Roo.ContentPanel} The shown panel or null
39081 showPanel : function(panel){
39082 panel = this.getPanel(panel);
39084 this.setActivePanel(panel);
39090 * Get the active panel for this region.
39091 * @return {Roo.ContentPanel} The active panel or null
39093 getActivePanel : function(){
39094 return this.activePanel;
39098 * Add the passed ContentPanel(s)
39099 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
39100 * @return {Roo.ContentPanel} The panel added (if only one was added)
39102 add : function(panel){
39103 if(arguments.length > 1){
39104 for(var i = 0, len = arguments.length; i < len; i++) {
39105 this.add(arguments[i]);
39109 if(this.hasPanel(panel)){
39110 this.showPanel(panel);
39113 var el = panel.getEl();
39114 if(el.dom.parentNode != this.mgr.el.dom){
39115 this.mgr.el.dom.appendChild(el.dom);
39117 if(panel.setRegion){
39118 panel.setRegion(this);
39120 this.panels.add(panel);
39121 el.setStyle("position", "absolute");
39122 if(!panel.background){
39123 this.setActivePanel(panel);
39124 if(this.config.initialSize && this.panels.getCount()==1){
39125 this.resizeTo(this.config.initialSize);
39128 this.fireEvent("paneladded", this, panel);
39133 * Returns true if the panel is in this region.
39134 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
39135 * @return {Boolean}
39137 hasPanel : function(panel){
39138 if(typeof panel == "object"){ // must be panel obj
39139 panel = panel.getId();
39141 return this.getPanel(panel) ? true : false;
39145 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
39146 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
39147 * @param {Boolean} preservePanel Overrides the config preservePanel option
39148 * @return {Roo.ContentPanel} The panel that was removed
39150 remove : function(panel, preservePanel){
39151 panel = this.getPanel(panel);
39156 this.fireEvent("beforeremove", this, panel, e);
39157 if(e.cancel === true){
39160 var panelId = panel.getId();
39161 this.panels.removeKey(panelId);
39166 * Returns the panel specified or null if it's not in this region.
39167 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
39168 * @return {Roo.ContentPanel}
39170 getPanel : function(id){
39171 if(typeof id == "object"){ // must be panel obj
39174 return this.panels.get(id);
39178 * Returns this regions position (north/south/east/west/center).
39181 getPosition: function(){
39182 return this.position;
39186 * Ext JS Library 1.1.1
39187 * Copyright(c) 2006-2007, Ext JS, LLC.
39189 * Originally Released Under LGPL - original licence link has changed is not relivant.
39192 * <script type="text/javascript">
39196 * @class Roo.bootstrap.layout.Region
39197 * @extends Roo.bootstrap.layout.Basic
39198 * This class represents a region in a layout manager.
39200 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
39201 * @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})
39202 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
39203 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
39204 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
39205 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
39206 * @cfg {String} title The title for the region (overrides panel titles)
39207 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
39208 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
39209 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
39210 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
39211 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
39212 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
39213 * the space available, similar to FireFox 1.5 tabs (defaults to false)
39214 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
39215 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
39216 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
39218 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
39219 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
39220 * @cfg {Boolean} disableTabTips True to disable tab tooltips
39221 * @cfg {Number} width For East/West panels
39222 * @cfg {Number} height For North/South panels
39223 * @cfg {Boolean} split To show the splitter
39224 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
39226 * @cfg {string} cls Extra CSS classes to add to region
39228 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
39229 * @cfg {string} region the region that it inhabits..
39232 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
39233 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
39235 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
39236 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
39237 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
39239 Roo.bootstrap.layout.Region = function(config)
39241 this.applyConfig(config);
39243 var mgr = config.mgr;
39244 var pos = config.region;
39245 config.skipConfig = true;
39246 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
39249 this.onRender(mgr.el);
39252 this.visible = true;
39253 this.collapsed = false;
39254 this.unrendered_panels = [];
39257 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
39259 position: '', // set by wrapper (eg. north/south etc..)
39260 unrendered_panels : null, // unrendered panels.
39262 tabPosition : false,
39264 mgr: false, // points to 'Border'
39267 createBody : function(){
39268 /** This region's body element
39269 * @type Roo.Element */
39270 this.bodyEl = this.el.createChild({
39272 cls: "roo-layout-panel-body tab-content" // bootstrap added...
39276 onRender: function(ctr, pos)
39278 var dh = Roo.DomHelper;
39279 /** This region's container element
39280 * @type Roo.Element */
39281 this.el = dh.append(ctr.dom, {
39283 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
39285 /** This region's title element
39286 * @type Roo.Element */
39288 this.titleEl = dh.append(this.el.dom, {
39290 unselectable: "on",
39291 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
39293 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
39294 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
39298 this.titleEl.enableDisplayMode();
39299 /** This region's title text element
39300 * @type HTMLElement */
39301 this.titleTextEl = this.titleEl.dom.firstChild;
39302 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
39304 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
39305 this.closeBtn.enableDisplayMode();
39306 this.closeBtn.on("click", this.closeClicked, this);
39307 this.closeBtn.hide();
39309 this.createBody(this.config);
39310 if(this.config.hideWhenEmpty){
39312 this.on("paneladded", this.validateVisibility, this);
39313 this.on("panelremoved", this.validateVisibility, this);
39315 if(this.autoScroll){
39316 this.bodyEl.setStyle("overflow", "auto");
39318 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
39320 //if(c.titlebar !== false){
39321 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
39322 this.titleEl.hide();
39324 this.titleEl.show();
39325 if(this.config.title){
39326 this.titleTextEl.innerHTML = this.config.title;
39330 if(this.config.collapsed){
39331 this.collapse(true);
39333 if(this.config.hidden){
39337 if (this.unrendered_panels && this.unrendered_panels.length) {
39338 for (var i =0;i< this.unrendered_panels.length; i++) {
39339 this.add(this.unrendered_panels[i]);
39341 this.unrendered_panels = null;
39347 applyConfig : function(c)
39350 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
39351 var dh = Roo.DomHelper;
39352 if(c.titlebar !== false){
39353 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
39354 this.collapseBtn.on("click", this.collapse, this);
39355 this.collapseBtn.enableDisplayMode();
39357 if(c.showPin === true || this.showPin){
39358 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
39359 this.stickBtn.enableDisplayMode();
39360 this.stickBtn.on("click", this.expand, this);
39361 this.stickBtn.hide();
39366 /** This region's collapsed element
39367 * @type Roo.Element */
39370 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
39371 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
39374 if(c.floatable !== false){
39375 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
39376 this.collapsedEl.on("click", this.collapseClick, this);
39379 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
39380 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
39381 id: "message", unselectable: "on", style:{"float":"left"}});
39382 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
39384 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
39385 this.expandBtn.on("click", this.expand, this);
39389 if(this.collapseBtn){
39390 this.collapseBtn.setVisible(c.collapsible == true);
39393 this.cmargins = c.cmargins || this.cmargins ||
39394 (this.position == "west" || this.position == "east" ?
39395 {top: 0, left: 2, right:2, bottom: 0} :
39396 {top: 2, left: 0, right:0, bottom: 2});
39398 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
39401 this.tabPosition = [ 'top','bottom', 'west'].indexOf(c.tabPosition) > -1 ? c.tabPosition : "top";
39403 this.autoScroll = c.autoScroll || false;
39408 this.duration = c.duration || .30;
39409 this.slideDuration = c.slideDuration || .45;
39414 * Returns true if this region is currently visible.
39415 * @return {Boolean}
39417 isVisible : function(){
39418 return this.visible;
39422 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
39423 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
39425 //setCollapsedTitle : function(title){
39426 // title = title || " ";
39427 // if(this.collapsedTitleTextEl){
39428 // this.collapsedTitleTextEl.innerHTML = title;
39432 getBox : function(){
39434 // if(!this.collapsed){
39435 b = this.el.getBox(false, true);
39437 // b = this.collapsedEl.getBox(false, true);
39442 getMargins : function(){
39443 return this.margins;
39444 //return this.collapsed ? this.cmargins : this.margins;
39447 highlight : function(){
39448 this.el.addClass("x-layout-panel-dragover");
39451 unhighlight : function(){
39452 this.el.removeClass("x-layout-panel-dragover");
39455 updateBox : function(box)
39457 if (!this.bodyEl) {
39458 return; // not rendered yet..
39462 if(!this.collapsed){
39463 this.el.dom.style.left = box.x + "px";
39464 this.el.dom.style.top = box.y + "px";
39465 this.updateBody(box.width, box.height);
39467 this.collapsedEl.dom.style.left = box.x + "px";
39468 this.collapsedEl.dom.style.top = box.y + "px";
39469 this.collapsedEl.setSize(box.width, box.height);
39472 this.tabs.autoSizeTabs();
39476 updateBody : function(w, h)
39479 this.el.setWidth(w);
39480 w -= this.el.getBorderWidth("rl");
39481 if(this.config.adjustments){
39482 w += this.config.adjustments[0];
39485 if(h !== null && h > 0){
39486 this.el.setHeight(h);
39487 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
39488 h -= this.el.getBorderWidth("tb");
39489 if(this.config.adjustments){
39490 h += this.config.adjustments[1];
39492 this.bodyEl.setHeight(h);
39494 h = this.tabs.syncHeight(h);
39497 if(this.panelSize){
39498 w = w !== null ? w : this.panelSize.width;
39499 h = h !== null ? h : this.panelSize.height;
39501 if(this.activePanel){
39502 var el = this.activePanel.getEl();
39503 w = w !== null ? w : el.getWidth();
39504 h = h !== null ? h : el.getHeight();
39505 this.panelSize = {width: w, height: h};
39506 this.activePanel.setSize(w, h);
39508 if(Roo.isIE && this.tabs){
39509 this.tabs.el.repaint();
39514 * Returns the container element for this region.
39515 * @return {Roo.Element}
39517 getEl : function(){
39522 * Hides this region.
39525 //if(!this.collapsed){
39526 this.el.dom.style.left = "-2000px";
39529 // this.collapsedEl.dom.style.left = "-2000px";
39530 // this.collapsedEl.hide();
39532 this.visible = false;
39533 this.fireEvent("visibilitychange", this, false);
39537 * Shows this region if it was previously hidden.
39540 //if(!this.collapsed){
39543 // this.collapsedEl.show();
39545 this.visible = true;
39546 this.fireEvent("visibilitychange", this, true);
39549 closeClicked : function(){
39550 if(this.activePanel){
39551 this.remove(this.activePanel);
39555 collapseClick : function(e){
39557 e.stopPropagation();
39560 e.stopPropagation();
39566 * Collapses this region.
39567 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
39570 collapse : function(skipAnim, skipCheck = false){
39571 if(this.collapsed) {
39575 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
39577 this.collapsed = true;
39579 this.split.el.hide();
39581 if(this.config.animate && skipAnim !== true){
39582 this.fireEvent("invalidated", this);
39583 this.animateCollapse();
39585 this.el.setLocation(-20000,-20000);
39587 this.collapsedEl.show();
39588 this.fireEvent("collapsed", this);
39589 this.fireEvent("invalidated", this);
39595 animateCollapse : function(){
39600 * Expands this region if it was previously collapsed.
39601 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
39602 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
39605 expand : function(e, skipAnim){
39607 e.stopPropagation();
39609 if(!this.collapsed || this.el.hasActiveFx()) {
39613 this.afterSlideIn();
39616 this.collapsed = false;
39617 if(this.config.animate && skipAnim !== true){
39618 this.animateExpand();
39622 this.split.el.show();
39624 this.collapsedEl.setLocation(-2000,-2000);
39625 this.collapsedEl.hide();
39626 this.fireEvent("invalidated", this);
39627 this.fireEvent("expanded", this);
39631 animateExpand : function(){
39635 initTabs : function()
39637 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
39639 var ts = new Roo.bootstrap.panel.Tabs({
39640 el: this.bodyEl.dom,
39642 tabPosition: this.tabPosition ? this.tabPosition : 'top',
39643 disableTooltips: this.config.disableTabTips,
39644 toolbar : this.config.toolbar
39647 if(this.config.hideTabs){
39648 ts.stripWrap.setDisplayed(false);
39651 ts.resizeTabs = this.config.resizeTabs === true;
39652 ts.minTabWidth = this.config.minTabWidth || 40;
39653 ts.maxTabWidth = this.config.maxTabWidth || 250;
39654 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
39655 ts.monitorResize = false;
39656 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
39657 ts.bodyEl.addClass('roo-layout-tabs-body');
39658 this.panels.each(this.initPanelAsTab, this);
39661 initPanelAsTab : function(panel){
39662 var ti = this.tabs.addTab(
39666 this.config.closeOnTab && panel.isClosable(),
39669 if(panel.tabTip !== undefined){
39670 ti.setTooltip(panel.tabTip);
39672 ti.on("activate", function(){
39673 this.setActivePanel(panel);
39676 if(this.config.closeOnTab){
39677 ti.on("beforeclose", function(t, e){
39679 this.remove(panel);
39683 panel.tabItem = ti;
39688 updatePanelTitle : function(panel, title)
39690 if(this.activePanel == panel){
39691 this.updateTitle(title);
39694 var ti = this.tabs.getTab(panel.getEl().id);
39696 if(panel.tabTip !== undefined){
39697 ti.setTooltip(panel.tabTip);
39702 updateTitle : function(title){
39703 if(this.titleTextEl && !this.config.title){
39704 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
39708 setActivePanel : function(panel)
39710 panel = this.getPanel(panel);
39711 if(this.activePanel && this.activePanel != panel){
39712 if(this.activePanel.setActiveState(false) === false){
39716 this.activePanel = panel;
39717 panel.setActiveState(true);
39718 if(this.panelSize){
39719 panel.setSize(this.panelSize.width, this.panelSize.height);
39722 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
39724 this.updateTitle(panel.getTitle());
39726 this.fireEvent("invalidated", this);
39728 this.fireEvent("panelactivated", this, panel);
39732 * Shows the specified panel.
39733 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
39734 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
39736 showPanel : function(panel)
39738 panel = this.getPanel(panel);
39741 var tab = this.tabs.getTab(panel.getEl().id);
39742 if(tab.isHidden()){
39743 this.tabs.unhideTab(tab.id);
39747 this.setActivePanel(panel);
39754 * Get the active panel for this region.
39755 * @return {Roo.ContentPanel} The active panel or null
39757 getActivePanel : function(){
39758 return this.activePanel;
39761 validateVisibility : function(){
39762 if(this.panels.getCount() < 1){
39763 this.updateTitle(" ");
39764 this.closeBtn.hide();
39767 if(!this.isVisible()){
39774 * Adds the passed ContentPanel(s) to this region.
39775 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
39776 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
39778 add : function(panel)
39780 if(arguments.length > 1){
39781 for(var i = 0, len = arguments.length; i < len; i++) {
39782 this.add(arguments[i]);
39787 // if we have not been rendered yet, then we can not really do much of this..
39788 if (!this.bodyEl) {
39789 this.unrendered_panels.push(panel);
39796 if(this.hasPanel(panel)){
39797 this.showPanel(panel);
39800 panel.setRegion(this);
39801 this.panels.add(panel);
39802 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
39803 // sinle panel - no tab...?? would it not be better to render it with the tabs,
39804 // and hide them... ???
39805 this.bodyEl.dom.appendChild(panel.getEl().dom);
39806 if(panel.background !== true){
39807 this.setActivePanel(panel);
39809 this.fireEvent("paneladded", this, panel);
39816 this.initPanelAsTab(panel);
39820 if(panel.background !== true){
39821 this.tabs.activate(panel.getEl().id);
39823 this.fireEvent("paneladded", this, panel);
39828 * Hides the tab for the specified panel.
39829 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
39831 hidePanel : function(panel){
39832 if(this.tabs && (panel = this.getPanel(panel))){
39833 this.tabs.hideTab(panel.getEl().id);
39838 * Unhides the tab for a previously hidden panel.
39839 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
39841 unhidePanel : function(panel){
39842 if(this.tabs && (panel = this.getPanel(panel))){
39843 this.tabs.unhideTab(panel.getEl().id);
39847 clearPanels : function(){
39848 while(this.panels.getCount() > 0){
39849 this.remove(this.panels.first());
39854 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
39855 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
39856 * @param {Boolean} preservePanel Overrides the config preservePanel option
39857 * @return {Roo.ContentPanel} The panel that was removed
39859 remove : function(panel, preservePanel)
39861 panel = this.getPanel(panel);
39866 this.fireEvent("beforeremove", this, panel, e);
39867 if(e.cancel === true){
39870 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
39871 var panelId = panel.getId();
39872 this.panels.removeKey(panelId);
39874 document.body.appendChild(panel.getEl().dom);
39877 this.tabs.removeTab(panel.getEl().id);
39878 }else if (!preservePanel){
39879 this.bodyEl.dom.removeChild(panel.getEl().dom);
39881 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
39882 var p = this.panels.first();
39883 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
39884 tempEl.appendChild(p.getEl().dom);
39885 this.bodyEl.update("");
39886 this.bodyEl.dom.appendChild(p.getEl().dom);
39888 this.updateTitle(p.getTitle());
39890 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
39891 this.setActivePanel(p);
39893 panel.setRegion(null);
39894 if(this.activePanel == panel){
39895 this.activePanel = null;
39897 if(this.config.autoDestroy !== false && preservePanel !== true){
39898 try{panel.destroy();}catch(e){}
39900 this.fireEvent("panelremoved", this, panel);
39905 * Returns the TabPanel component used by this region
39906 * @return {Roo.TabPanel}
39908 getTabs : function(){
39912 createTool : function(parentEl, className){
39913 var btn = Roo.DomHelper.append(parentEl, {
39915 cls: "x-layout-tools-button",
39918 cls: "roo-layout-tools-button-inner " + className,
39922 btn.addClassOnOver("roo-layout-tools-button-over");
39927 * Ext JS Library 1.1.1
39928 * Copyright(c) 2006-2007, Ext JS, LLC.
39930 * Originally Released Under LGPL - original licence link has changed is not relivant.
39933 * <script type="text/javascript">
39939 * @class Roo.SplitLayoutRegion
39940 * @extends Roo.LayoutRegion
39941 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
39943 Roo.bootstrap.layout.Split = function(config){
39944 this.cursor = config.cursor;
39945 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
39948 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
39950 splitTip : "Drag to resize.",
39951 collapsibleSplitTip : "Drag to resize. Double click to hide.",
39952 useSplitTips : false,
39954 applyConfig : function(config){
39955 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
39958 onRender : function(ctr,pos) {
39960 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
39961 if(!this.config.split){
39966 var splitEl = Roo.DomHelper.append(ctr.dom, {
39968 id: this.el.id + "-split",
39969 cls: "roo-layout-split roo-layout-split-"+this.position,
39972 /** The SplitBar for this region
39973 * @type Roo.SplitBar */
39974 // does not exist yet...
39975 Roo.log([this.position, this.orientation]);
39977 this.split = new Roo.bootstrap.SplitBar({
39978 dragElement : splitEl,
39979 resizingElement: this.el,
39980 orientation : this.orientation
39983 this.split.on("moved", this.onSplitMove, this);
39984 this.split.useShim = this.config.useShim === true;
39985 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
39986 if(this.useSplitTips){
39987 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
39989 //if(config.collapsible){
39990 // this.split.el.on("dblclick", this.collapse, this);
39993 if(typeof this.config.minSize != "undefined"){
39994 this.split.minSize = this.config.minSize;
39996 if(typeof this.config.maxSize != "undefined"){
39997 this.split.maxSize = this.config.maxSize;
39999 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
40000 this.hideSplitter();
40005 getHMaxSize : function(){
40006 var cmax = this.config.maxSize || 10000;
40007 var center = this.mgr.getRegion("center");
40008 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
40011 getVMaxSize : function(){
40012 var cmax = this.config.maxSize || 10000;
40013 var center = this.mgr.getRegion("center");
40014 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
40017 onSplitMove : function(split, newSize){
40018 this.fireEvent("resized", this, newSize);
40022 * Returns the {@link Roo.SplitBar} for this region.
40023 * @return {Roo.SplitBar}
40025 getSplitBar : function(){
40030 this.hideSplitter();
40031 Roo.bootstrap.layout.Split.superclass.hide.call(this);
40034 hideSplitter : function(){
40036 this.split.el.setLocation(-2000,-2000);
40037 this.split.el.hide();
40043 this.split.el.show();
40045 Roo.bootstrap.layout.Split.superclass.show.call(this);
40048 beforeSlide: function(){
40049 if(Roo.isGecko){// firefox overflow auto bug workaround
40050 this.bodyEl.clip();
40052 this.tabs.bodyEl.clip();
40054 if(this.activePanel){
40055 this.activePanel.getEl().clip();
40057 if(this.activePanel.beforeSlide){
40058 this.activePanel.beforeSlide();
40064 afterSlide : function(){
40065 if(Roo.isGecko){// firefox overflow auto bug workaround
40066 this.bodyEl.unclip();
40068 this.tabs.bodyEl.unclip();
40070 if(this.activePanel){
40071 this.activePanel.getEl().unclip();
40072 if(this.activePanel.afterSlide){
40073 this.activePanel.afterSlide();
40079 initAutoHide : function(){
40080 if(this.autoHide !== false){
40081 if(!this.autoHideHd){
40082 var st = new Roo.util.DelayedTask(this.slideIn, this);
40083 this.autoHideHd = {
40084 "mouseout": function(e){
40085 if(!e.within(this.el, true)){
40089 "mouseover" : function(e){
40095 this.el.on(this.autoHideHd);
40099 clearAutoHide : function(){
40100 if(this.autoHide !== false){
40101 this.el.un("mouseout", this.autoHideHd.mouseout);
40102 this.el.un("mouseover", this.autoHideHd.mouseover);
40106 clearMonitor : function(){
40107 Roo.get(document).un("click", this.slideInIf, this);
40110 // these names are backwards but not changed for compat
40111 slideOut : function(){
40112 if(this.isSlid || this.el.hasActiveFx()){
40115 this.isSlid = true;
40116 if(this.collapseBtn){
40117 this.collapseBtn.hide();
40119 this.closeBtnState = this.closeBtn.getStyle('display');
40120 this.closeBtn.hide();
40122 this.stickBtn.show();
40125 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
40126 this.beforeSlide();
40127 this.el.setStyle("z-index", 10001);
40128 this.el.slideIn(this.getSlideAnchor(), {
40129 callback: function(){
40131 this.initAutoHide();
40132 Roo.get(document).on("click", this.slideInIf, this);
40133 this.fireEvent("slideshow", this);
40140 afterSlideIn : function(){
40141 this.clearAutoHide();
40142 this.isSlid = false;
40143 this.clearMonitor();
40144 this.el.setStyle("z-index", "");
40145 if(this.collapseBtn){
40146 this.collapseBtn.show();
40148 this.closeBtn.setStyle('display', this.closeBtnState);
40150 this.stickBtn.hide();
40152 this.fireEvent("slidehide", this);
40155 slideIn : function(cb){
40156 if(!this.isSlid || this.el.hasActiveFx()){
40160 this.isSlid = false;
40161 this.beforeSlide();
40162 this.el.slideOut(this.getSlideAnchor(), {
40163 callback: function(){
40164 this.el.setLeftTop(-10000, -10000);
40166 this.afterSlideIn();
40174 slideInIf : function(e){
40175 if(!e.within(this.el)){
40180 animateCollapse : function(){
40181 this.beforeSlide();
40182 this.el.setStyle("z-index", 20000);
40183 var anchor = this.getSlideAnchor();
40184 this.el.slideOut(anchor, {
40185 callback : function(){
40186 this.el.setStyle("z-index", "");
40187 this.collapsedEl.slideIn(anchor, {duration:.3});
40189 this.el.setLocation(-10000,-10000);
40191 this.fireEvent("collapsed", this);
40198 animateExpand : function(){
40199 this.beforeSlide();
40200 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
40201 this.el.setStyle("z-index", 20000);
40202 this.collapsedEl.hide({
40205 this.el.slideIn(this.getSlideAnchor(), {
40206 callback : function(){
40207 this.el.setStyle("z-index", "");
40210 this.split.el.show();
40212 this.fireEvent("invalidated", this);
40213 this.fireEvent("expanded", this);
40241 getAnchor : function(){
40242 return this.anchors[this.position];
40245 getCollapseAnchor : function(){
40246 return this.canchors[this.position];
40249 getSlideAnchor : function(){
40250 return this.sanchors[this.position];
40253 getAlignAdj : function(){
40254 var cm = this.cmargins;
40255 switch(this.position){
40271 getExpandAdj : function(){
40272 var c = this.collapsedEl, cm = this.cmargins;
40273 switch(this.position){
40275 return [-(cm.right+c.getWidth()+cm.left), 0];
40278 return [cm.right+c.getWidth()+cm.left, 0];
40281 return [0, -(cm.top+cm.bottom+c.getHeight())];
40284 return [0, cm.top+cm.bottom+c.getHeight()];
40290 * Ext JS Library 1.1.1
40291 * Copyright(c) 2006-2007, Ext JS, LLC.
40293 * Originally Released Under LGPL - original licence link has changed is not relivant.
40296 * <script type="text/javascript">
40299 * These classes are private internal classes
40301 Roo.bootstrap.layout.Center = function(config){
40302 config.region = "center";
40303 Roo.bootstrap.layout.Region.call(this, config);
40304 this.visible = true;
40305 this.minWidth = config.minWidth || 20;
40306 this.minHeight = config.minHeight || 20;
40309 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
40311 // center panel can't be hidden
40315 // center panel can't be hidden
40318 getMinWidth: function(){
40319 return this.minWidth;
40322 getMinHeight: function(){
40323 return this.minHeight;
40337 Roo.bootstrap.layout.North = function(config)
40339 config.region = 'north';
40340 config.cursor = 'n-resize';
40342 Roo.bootstrap.layout.Split.call(this, config);
40346 this.split.placement = Roo.bootstrap.SplitBar.TOP;
40347 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
40348 this.split.el.addClass("roo-layout-split-v");
40350 //var size = config.initialSize || config.height;
40351 //if(this.el && typeof size != "undefined"){
40352 // this.el.setHeight(size);
40355 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
40357 orientation: Roo.bootstrap.SplitBar.VERTICAL,
40360 onRender : function(ctr, pos)
40362 Roo.bootstrap.layout.Split.prototype.onRender.call(this, ctr, pos);
40363 var size = this.config.initialSize || this.config.height;
40364 if(this.el && typeof size != "undefined"){
40365 this.el.setHeight(size);
40370 getBox : function(){
40371 if(this.collapsed){
40372 return this.collapsedEl.getBox();
40374 var box = this.el.getBox();
40376 box.height += this.split.el.getHeight();
40381 updateBox : function(box){
40382 if(this.split && !this.collapsed){
40383 box.height -= this.split.el.getHeight();
40384 this.split.el.setLeft(box.x);
40385 this.split.el.setTop(box.y+box.height);
40386 this.split.el.setWidth(box.width);
40388 if(this.collapsed){
40389 this.updateBody(box.width, null);
40391 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
40399 Roo.bootstrap.layout.South = function(config){
40400 config.region = 'south';
40401 config.cursor = 's-resize';
40402 Roo.bootstrap.layout.Split.call(this, config);
40404 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
40405 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
40406 this.split.el.addClass("roo-layout-split-v");
40411 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
40412 orientation: Roo.bootstrap.SplitBar.VERTICAL,
40414 onRender : function(ctr, pos)
40416 Roo.bootstrap.layout.Split.prototype.onRender.call(this, ctr, pos);
40417 var size = this.config.initialSize || this.config.height;
40418 if(this.el && typeof size != "undefined"){
40419 this.el.setHeight(size);
40424 getBox : function(){
40425 if(this.collapsed){
40426 return this.collapsedEl.getBox();
40428 var box = this.el.getBox();
40430 var sh = this.split.el.getHeight();
40437 updateBox : function(box){
40438 if(this.split && !this.collapsed){
40439 var sh = this.split.el.getHeight();
40442 this.split.el.setLeft(box.x);
40443 this.split.el.setTop(box.y-sh);
40444 this.split.el.setWidth(box.width);
40446 if(this.collapsed){
40447 this.updateBody(box.width, null);
40449 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
40453 Roo.bootstrap.layout.East = function(config){
40454 config.region = "east";
40455 config.cursor = "e-resize";
40456 Roo.bootstrap.layout.Split.call(this, config);
40458 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
40459 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
40460 this.split.el.addClass("roo-layout-split-h");
40464 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
40465 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
40467 onRender : function(ctr, pos)
40469 Roo.bootstrap.layout.Split.prototype.onRender.call(this, ctr, pos);
40470 var size = this.config.initialSize || this.config.width;
40471 if(this.el && typeof size != "undefined"){
40472 this.el.setWidth(size);
40477 getBox : function(){
40478 if(this.collapsed){
40479 return this.collapsedEl.getBox();
40481 var box = this.el.getBox();
40483 var sw = this.split.el.getWidth();
40490 updateBox : function(box){
40491 if(this.split && !this.collapsed){
40492 var sw = this.split.el.getWidth();
40494 this.split.el.setLeft(box.x);
40495 this.split.el.setTop(box.y);
40496 this.split.el.setHeight(box.height);
40499 if(this.collapsed){
40500 this.updateBody(null, box.height);
40502 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
40506 Roo.bootstrap.layout.West = function(config){
40507 config.region = "west";
40508 config.cursor = "w-resize";
40510 Roo.bootstrap.layout.Split.call(this, config);
40512 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
40513 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
40514 this.split.el.addClass("roo-layout-split-h");
40518 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
40519 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
40521 onRender: function(ctr, pos)
40523 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
40524 var size = this.config.initialSize || this.config.width;
40525 if(typeof size != "undefined"){
40526 this.el.setWidth(size);
40530 getBox : function(){
40531 if(this.collapsed){
40532 return this.collapsedEl.getBox();
40534 var box = this.el.getBox();
40535 if (box.width == 0) {
40536 box.width = this.config.width; // kludge?
40539 box.width += this.split.el.getWidth();
40544 updateBox : function(box){
40545 if(this.split && !this.collapsed){
40546 var sw = this.split.el.getWidth();
40548 this.split.el.setLeft(box.x+box.width);
40549 this.split.el.setTop(box.y);
40550 this.split.el.setHeight(box.height);
40552 if(this.collapsed){
40553 this.updateBody(null, box.height);
40555 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
40557 });Roo.namespace("Roo.bootstrap.panel");/*
40559 * Ext JS Library 1.1.1
40560 * Copyright(c) 2006-2007, Ext JS, LLC.
40562 * Originally Released Under LGPL - original licence link has changed is not relivant.
40565 * <script type="text/javascript">
40568 * @class Roo.ContentPanel
40569 * @extends Roo.util.Observable
40571 * A basic ContentPanel element.
40572 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
40573 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
40574 * @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
40575 * @cfg {Boolean} closable True if the panel can be closed/removed
40576 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
40577 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
40578 * @cfg {Toolbar} toolbar A toolbar for this panel
40579 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
40580 * @cfg {String} title The title for this panel
40581 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
40582 * @cfg {String} url Calls {@link #setUrl} with this value
40583 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
40584 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
40585 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
40586 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
40587 * @cfg {Boolean} iframe contents are an iframe - makes showing remote sources/CSS feasible..
40588 * @cfg {Boolean} badges render the badges
40589 * @cfg {String} cls extra classes to use
40590 * @cfg {String} background (primary|secondary|success|info|warning|danger|light|dark)
40593 * Create a new ContentPanel.
40594 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
40595 * @param {String/Object} config A string to set only the title or a config object
40596 * @param {String} content (optional) Set the HTML content for this panel
40597 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
40599 Roo.bootstrap.panel.Content = function( config){
40601 this.tpl = config.tpl || false;
40603 var el = config.el;
40604 var content = config.content;
40606 if(config.autoCreate){ // xtype is available if this is called from factory
40609 this.el = Roo.get(el);
40610 if(!this.el && config && config.autoCreate){
40611 if(typeof config.autoCreate == "object"){
40612 if(!config.autoCreate.id){
40613 config.autoCreate.id = config.id||el;
40615 this.el = Roo.DomHelper.append(document.body,
40616 config.autoCreate, true);
40620 cls: (config.cls || '') +
40621 (config.background ? ' bg-' + config.background : '') +
40622 " roo-layout-inactive-content",
40625 if (config.iframe) {
40629 style : 'border: 0px',
40630 src : 'about:blank'
40636 elcfg.html = config.html;
40640 this.el = Roo.DomHelper.append(document.body, elcfg , true);
40641 if (config.iframe) {
40642 this.iframeEl = this.el.select('iframe',true).first();
40647 this.closable = false;
40648 this.loaded = false;
40649 this.active = false;
40652 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
40654 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
40656 this.wrapEl = this.el; //this.el.wrap();
40658 if (config.toolbar.items) {
40659 ti = config.toolbar.items ;
40660 delete config.toolbar.items ;
40664 this.toolbar.render(this.wrapEl, 'before');
40665 for(var i =0;i < ti.length;i++) {
40666 // Roo.log(['add child', items[i]]);
40667 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
40669 this.toolbar.items = nitems;
40670 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
40671 delete config.toolbar;
40675 // xtype created footer. - not sure if will work as we normally have to render first..
40676 if (this.footer && !this.footer.el && this.footer.xtype) {
40677 if (!this.wrapEl) {
40678 this.wrapEl = this.el.wrap();
40681 this.footer.container = this.wrapEl.createChild();
40683 this.footer = Roo.factory(this.footer, Roo);
40688 if(typeof config == "string"){
40689 this.title = config;
40691 Roo.apply(this, config);
40695 this.resizeEl = Roo.get(this.resizeEl, true);
40697 this.resizeEl = this.el;
40699 // handle view.xtype
40707 * Fires when this panel is activated.
40708 * @param {Roo.ContentPanel} this
40712 * @event deactivate
40713 * Fires when this panel is activated.
40714 * @param {Roo.ContentPanel} this
40716 "deactivate" : true,
40720 * Fires when this panel is resized if fitToFrame is true.
40721 * @param {Roo.ContentPanel} this
40722 * @param {Number} width The width after any component adjustments
40723 * @param {Number} height The height after any component adjustments
40729 * Fires when this tab is created
40730 * @param {Roo.ContentPanel} this
40736 * Fires when this content is scrolled
40737 * @param {Roo.ContentPanel} this
40738 * @param {Event} scrollEvent
40749 if(this.autoScroll && !this.iframe){
40750 this.resizeEl.setStyle("overflow", "auto");
40751 this.resizeEl.on('scroll', this.onScroll, this);
40753 // fix randome scrolling
40754 //this.el.on('scroll', function() {
40755 // Roo.log('fix random scolling');
40756 // this.scrollTo('top',0);
40759 content = content || this.content;
40761 this.setContent(content);
40763 if(config && config.url){
40764 this.setUrl(this.url, this.params, this.loadOnce);
40769 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
40771 if (this.view && typeof(this.view.xtype) != 'undefined') {
40772 this.view.el = this.el.appendChild(document.createElement("div"));
40773 this.view = Roo.factory(this.view);
40774 this.view.render && this.view.render(false, '');
40778 this.fireEvent('render', this);
40781 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
40791 /* Resize Element - use this to work out scroll etc. */
40794 setRegion : function(region){
40795 this.region = region;
40796 this.setActiveClass(region && !this.background);
40800 setActiveClass: function(state)
40803 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
40804 this.el.setStyle('position','relative');
40806 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
40807 this.el.setStyle('position', 'absolute');
40812 * Returns the toolbar for this Panel if one was configured.
40813 * @return {Roo.Toolbar}
40815 getToolbar : function(){
40816 return this.toolbar;
40819 setActiveState : function(active)
40821 this.active = active;
40822 this.setActiveClass(active);
40824 if(this.fireEvent("deactivate", this) === false){
40829 this.fireEvent("activate", this);
40833 * Updates this panel's element (not for iframe)
40834 * @param {String} content The new content
40835 * @param {Boolean} loadScripts (optional) true to look for and process scripts
40837 setContent : function(content, loadScripts){
40842 this.el.update(content, loadScripts);
40845 ignoreResize : function(w, h){
40846 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
40849 this.lastSize = {width: w, height: h};
40854 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
40855 * @return {Roo.UpdateManager} The UpdateManager
40857 getUpdateManager : function(){
40861 return this.el.getUpdateManager();
40864 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
40865 * Does not work with IFRAME contents
40866 * @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:
40869 url: "your-url.php",
40870 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
40871 callback: yourFunction,
40872 scope: yourObject, //(optional scope)
40875 text: "Loading...",
40881 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
40882 * 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.
40883 * @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}
40884 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
40885 * @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.
40886 * @return {Roo.ContentPanel} this
40894 var um = this.el.getUpdateManager();
40895 um.update.apply(um, arguments);
40901 * 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.
40902 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
40903 * @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)
40904 * @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)
40905 * @return {Roo.UpdateManager|Boolean} The UpdateManager or false if IFRAME
40907 setUrl : function(url, params, loadOnce){
40909 this.iframeEl.dom.src = url;
40913 if(this.refreshDelegate){
40914 this.removeListener("activate", this.refreshDelegate);
40916 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
40917 this.on("activate", this.refreshDelegate);
40918 return this.el.getUpdateManager();
40921 _handleRefresh : function(url, params, loadOnce){
40922 if(!loadOnce || !this.loaded){
40923 var updater = this.el.getUpdateManager();
40924 updater.update(url, params, this._setLoaded.createDelegate(this));
40928 _setLoaded : function(){
40929 this.loaded = true;
40933 * Returns this panel's id
40936 getId : function(){
40941 * Returns this panel's element - used by regiosn to add.
40942 * @return {Roo.Element}
40944 getEl : function(){
40945 return this.wrapEl || this.el;
40950 adjustForComponents : function(width, height)
40952 //Roo.log('adjustForComponents ');
40953 if(this.resizeEl != this.el){
40954 width -= this.el.getFrameWidth('lr');
40955 height -= this.el.getFrameWidth('tb');
40958 var te = this.toolbar.getEl();
40959 te.setWidth(width);
40960 height -= te.getHeight();
40963 var te = this.footer.getEl();
40964 te.setWidth(width);
40965 height -= te.getHeight();
40969 if(this.adjustments){
40970 width += this.adjustments[0];
40971 height += this.adjustments[1];
40973 return {"width": width, "height": height};
40976 setSize : function(width, height){
40977 if(this.fitToFrame && !this.ignoreResize(width, height)){
40978 if(this.fitContainer && this.resizeEl != this.el){
40979 this.el.setSize(width, height);
40981 var size = this.adjustForComponents(width, height);
40983 this.iframeEl.setSize(width,height);
40986 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
40987 this.fireEvent('resize', this, size.width, size.height);
40994 * Returns this panel's title
40997 getTitle : function(){
40999 if (typeof(this.title) != 'object') {
41004 for (var k in this.title) {
41005 if (!this.title.hasOwnProperty(k)) {
41009 if (k.indexOf('-') >= 0) {
41010 var s = k.split('-');
41011 for (var i = 0; i<s.length; i++) {
41012 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
41015 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
41022 * Set this panel's title
41023 * @param {String} title
41025 setTitle : function(title){
41026 this.title = title;
41028 this.region.updatePanelTitle(this, title);
41033 * Returns true is this panel was configured to be closable
41034 * @return {Boolean}
41036 isClosable : function(){
41037 return this.closable;
41040 beforeSlide : function(){
41042 this.resizeEl.clip();
41045 afterSlide : function(){
41047 this.resizeEl.unclip();
41051 * Force a content refresh from the URL specified in the {@link #setUrl} method.
41052 * Will fail silently if the {@link #setUrl} method has not been called.
41053 * This does not activate the panel, just updates its content.
41055 refresh : function(){
41056 if(this.refreshDelegate){
41057 this.loaded = false;
41058 this.refreshDelegate();
41063 * Destroys this panel
41065 destroy : function(){
41066 this.el.removeAllListeners();
41067 var tempEl = document.createElement("span");
41068 tempEl.appendChild(this.el.dom);
41069 tempEl.innerHTML = "";
41075 * form - if the content panel contains a form - this is a reference to it.
41076 * @type {Roo.form.Form}
41080 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
41081 * This contains a reference to it.
41087 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
41097 * @param {Object} cfg Xtype definition of item to add.
41101 getChildContainer: function () {
41102 return this.getEl();
41106 onScroll : function(e)
41108 this.fireEvent('scroll', this, e);
41113 var ret = new Roo.factory(cfg);
41118 if (cfg.xtype.match(/^Form$/)) {
41121 //if (this.footer) {
41122 // el = this.footer.container.insertSibling(false, 'before');
41124 el = this.el.createChild();
41127 this.form = new Roo.form.Form(cfg);
41130 if ( this.form.allItems.length) {
41131 this.form.render(el.dom);
41135 // should only have one of theses..
41136 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
41137 // views.. should not be just added - used named prop 'view''
41139 cfg.el = this.el.appendChild(document.createElement("div"));
41142 var ret = new Roo.factory(cfg);
41144 ret.render && ret.render(false, ''); // render blank..
41154 * @class Roo.bootstrap.panel.Grid
41155 * @extends Roo.bootstrap.panel.Content
41157 * Create a new GridPanel.
41158 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
41159 * @param {Object} config A the config object
41165 Roo.bootstrap.panel.Grid = function(config)
41169 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
41170 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
41172 config.el = this.wrapper;
41173 //this.el = this.wrapper;
41175 if (config.container) {
41176 // ctor'ed from a Border/panel.grid
41179 this.wrapper.setStyle("overflow", "hidden");
41180 this.wrapper.addClass('roo-grid-container');
41185 if(config.toolbar){
41186 var tool_el = this.wrapper.createChild();
41187 this.toolbar = Roo.factory(config.toolbar);
41189 if (config.toolbar.items) {
41190 ti = config.toolbar.items ;
41191 delete config.toolbar.items ;
41195 this.toolbar.render(tool_el);
41196 for(var i =0;i < ti.length;i++) {
41197 // Roo.log(['add child', items[i]]);
41198 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
41200 this.toolbar.items = nitems;
41202 delete config.toolbar;
41205 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
41206 config.grid.scrollBody = true;;
41207 config.grid.monitorWindowResize = false; // turn off autosizing
41208 config.grid.autoHeight = false;
41209 config.grid.autoWidth = false;
41211 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
41213 if (config.background) {
41214 // render grid on panel activation (if panel background)
41215 this.on('activate', function(gp) {
41216 if (!gp.grid.rendered) {
41217 gp.grid.render(this.wrapper);
41218 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
41223 this.grid.render(this.wrapper);
41224 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
41227 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
41228 // ??? needed ??? config.el = this.wrapper;
41233 // xtype created footer. - not sure if will work as we normally have to render first..
41234 if (this.footer && !this.footer.el && this.footer.xtype) {
41236 var ctr = this.grid.getView().getFooterPanel(true);
41237 this.footer.dataSource = this.grid.dataSource;
41238 this.footer = Roo.factory(this.footer, Roo);
41239 this.footer.render(ctr);
41249 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
41250 getId : function(){
41251 return this.grid.id;
41255 * Returns the grid for this panel
41256 * @return {Roo.bootstrap.Table}
41258 getGrid : function(){
41262 setSize : function(width, height){
41263 if(!this.ignoreResize(width, height)){
41264 var grid = this.grid;
41265 var size = this.adjustForComponents(width, height);
41266 // tfoot is not a footer?
41269 var gridel = grid.getGridEl();
41270 gridel.setSize(size.width, size.height);
41272 var tbd = grid.getGridEl().select('tbody', true).first();
41273 var thd = grid.getGridEl().select('thead',true).first();
41274 var tbf= grid.getGridEl().select('tfoot', true).first();
41277 size.height -= tbf.getHeight();
41280 size.height -= thd.getHeight();
41283 tbd.setSize(size.width, size.height );
41284 // this is for the account management tab -seems to work there.
41285 var thd = grid.getGridEl().select('thead',true).first();
41287 // tbd.setSize(size.width, size.height - thd.getHeight());
41296 beforeSlide : function(){
41297 this.grid.getView().scroller.clip();
41300 afterSlide : function(){
41301 this.grid.getView().scroller.unclip();
41304 destroy : function(){
41305 this.grid.destroy();
41307 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
41312 * @class Roo.bootstrap.panel.Nest
41313 * @extends Roo.bootstrap.panel.Content
41315 * Create a new Panel, that can contain a layout.Border.
41318 * @param {Roo.BorderLayout} layout The layout for this panel
41319 * @param {String/Object} config A string to set only the title or a config object
41321 Roo.bootstrap.panel.Nest = function(config)
41323 // construct with only one argument..
41324 /* FIXME - implement nicer consturctors
41325 if (layout.layout) {
41327 layout = config.layout;
41328 delete config.layout;
41330 if (layout.xtype && !layout.getEl) {
41331 // then layout needs constructing..
41332 layout = Roo.factory(layout, Roo);
41336 config.el = config.layout.getEl();
41338 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
41340 config.layout.monitorWindowResize = false; // turn off autosizing
41341 this.layout = config.layout;
41342 this.layout.getEl().addClass("roo-layout-nested-layout");
41343 this.layout.parent = this;
41350 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
41352 setSize : function(width, height){
41353 if(!this.ignoreResize(width, height)){
41354 var size = this.adjustForComponents(width, height);
41355 var el = this.layout.getEl();
41356 if (size.height < 1) {
41357 el.setWidth(size.width);
41359 el.setSize(size.width, size.height);
41361 var touch = el.dom.offsetWidth;
41362 this.layout.layout();
41363 // ie requires a double layout on the first pass
41364 if(Roo.isIE && !this.initialized){
41365 this.initialized = true;
41366 this.layout.layout();
41371 // activate all subpanels if not currently active..
41373 setActiveState : function(active){
41374 this.active = active;
41375 this.setActiveClass(active);
41378 this.fireEvent("deactivate", this);
41382 this.fireEvent("activate", this);
41383 // not sure if this should happen before or after..
41384 if (!this.layout) {
41385 return; // should not happen..
41388 for (var r in this.layout.regions) {
41389 reg = this.layout.getRegion(r);
41390 if (reg.getActivePanel()) {
41391 //reg.showPanel(reg.getActivePanel()); // force it to activate..
41392 reg.setActivePanel(reg.getActivePanel());
41395 if (!reg.panels.length) {
41398 reg.showPanel(reg.getPanel(0));
41407 * Returns the nested BorderLayout for this panel
41408 * @return {Roo.BorderLayout}
41410 getLayout : function(){
41411 return this.layout;
41415 * Adds a xtype elements to the layout of the nested panel
41419 xtype : 'ContentPanel',
41426 xtype : 'NestedLayoutPanel',
41432 items : [ ... list of content panels or nested layout panels.. ]
41436 * @param {Object} cfg Xtype definition of item to add.
41438 addxtype : function(cfg) {
41439 return this.layout.addxtype(cfg);
41444 * Ext JS Library 1.1.1
41445 * Copyright(c) 2006-2007, Ext JS, LLC.
41447 * Originally Released Under LGPL - original licence link has changed is not relivant.
41450 * <script type="text/javascript">
41453 * @class Roo.TabPanel
41454 * @extends Roo.util.Observable
41455 * A lightweight tab container.
41459 // basic tabs 1, built from existing content
41460 var tabs = new Roo.TabPanel("tabs1");
41461 tabs.addTab("script", "View Script");
41462 tabs.addTab("markup", "View Markup");
41463 tabs.activate("script");
41465 // more advanced tabs, built from javascript
41466 var jtabs = new Roo.TabPanel("jtabs");
41467 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
41469 // set up the UpdateManager
41470 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
41471 var updater = tab2.getUpdateManager();
41472 updater.setDefaultUrl("ajax1.htm");
41473 tab2.on('activate', updater.refresh, updater, true);
41475 // Use setUrl for Ajax loading
41476 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
41477 tab3.setUrl("ajax2.htm", null, true);
41480 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
41483 jtabs.activate("jtabs-1");
41486 * Create a new TabPanel.
41487 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
41488 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
41490 Roo.bootstrap.panel.Tabs = function(config){
41492 * The container element for this TabPanel.
41493 * @type Roo.Element
41495 this.el = Roo.get(config.el);
41498 if(typeof config == "boolean"){
41499 this.tabPosition = config ? "bottom" : "top";
41501 Roo.apply(this, config);
41505 if(this.tabPosition == "bottom"){
41506 // if tabs are at the bottom = create the body first.
41507 this.bodyEl = Roo.get(this.createBody(this.el.dom));
41508 this.el.addClass("roo-tabs-bottom");
41510 // next create the tabs holders
41512 if (this.tabPosition == "west"){
41514 var reg = this.region; // fake it..
41516 if (!reg.mgr.parent) {
41519 reg = reg.mgr.parent.region;
41521 Roo.log("got nest?");
41523 if (reg.mgr.getRegion('west')) {
41524 var ctrdom = reg.mgr.getRegion('west').bodyEl.dom;
41525 this.stripWrap = Roo.get(this.createStrip(ctrdom ), true);
41526 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
41527 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
41528 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
41536 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
41537 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
41538 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
41539 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
41544 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
41547 // finally - if tabs are at the top, then create the body last..
41548 if(this.tabPosition != "bottom"){
41549 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
41550 * @type Roo.Element
41552 this.bodyEl = Roo.get(this.createBody(this.el.dom));
41553 this.el.addClass("roo-tabs-top");
41557 this.bodyEl.setStyle("position", "relative");
41559 this.active = null;
41560 this.activateDelegate = this.activate.createDelegate(this);
41565 * Fires when the active tab changes
41566 * @param {Roo.TabPanel} this
41567 * @param {Roo.TabPanelItem} activePanel The new active tab
41571 * @event beforetabchange
41572 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
41573 * @param {Roo.TabPanel} this
41574 * @param {Object} e Set cancel to true on this object to cancel the tab change
41575 * @param {Roo.TabPanelItem} tab The tab being changed to
41577 "beforetabchange" : true
41580 Roo.EventManager.onWindowResize(this.onResize, this);
41581 this.cpad = this.el.getPadding("lr");
41582 this.hiddenCount = 0;
41585 // toolbar on the tabbar support...
41586 if (this.toolbar) {
41587 alert("no toolbar support yet");
41588 this.toolbar = false;
41590 var tcfg = this.toolbar;
41591 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
41592 this.toolbar = new Roo.Toolbar(tcfg);
41593 if (Roo.isSafari) {
41594 var tbl = tcfg.container.child('table', true);
41595 tbl.setAttribute('width', '100%');
41603 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
41606 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
41608 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
41610 tabPosition : "top",
41612 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
41614 currentTabWidth : 0,
41616 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
41620 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
41624 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
41626 preferredTabWidth : 175,
41628 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
41630 resizeTabs : false,
41632 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
41634 monitorResize : true,
41636 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
41638 toolbar : false, // set by caller..
41640 region : false, /// set by caller
41642 disableTooltips : true, // not used yet...
41645 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
41646 * @param {String} id The id of the div to use <b>or create</b>
41647 * @param {String} text The text for the tab
41648 * @param {String} content (optional) Content to put in the TabPanelItem body
41649 * @param {Boolean} closable (optional) True to create a close icon on the tab
41650 * @return {Roo.TabPanelItem} The created TabPanelItem
41652 addTab : function(id, text, content, closable, tpl)
41654 var item = new Roo.bootstrap.panel.TabItem({
41658 closable : closable,
41661 this.addTabItem(item);
41663 item.setContent(content);
41669 * Returns the {@link Roo.TabPanelItem} with the specified id/index
41670 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
41671 * @return {Roo.TabPanelItem}
41673 getTab : function(id){
41674 return this.items[id];
41678 * Hides the {@link Roo.TabPanelItem} with the specified id/index
41679 * @param {String/Number} id The id or index of the TabPanelItem to hide.
41681 hideTab : function(id){
41682 var t = this.items[id];
41685 this.hiddenCount++;
41686 this.autoSizeTabs();
41691 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
41692 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
41694 unhideTab : function(id){
41695 var t = this.items[id];
41697 t.setHidden(false);
41698 this.hiddenCount--;
41699 this.autoSizeTabs();
41704 * Adds an existing {@link Roo.TabPanelItem}.
41705 * @param {Roo.TabPanelItem} item The TabPanelItem to add
41707 addTabItem : function(item)
41709 this.items[item.id] = item;
41710 this.items.push(item);
41711 this.autoSizeTabs();
41712 // if(this.resizeTabs){
41713 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
41714 // this.autoSizeTabs();
41716 // item.autoSize();
41721 * Removes a {@link Roo.TabPanelItem}.
41722 * @param {String/Number} id The id or index of the TabPanelItem to remove.
41724 removeTab : function(id){
41725 var items = this.items;
41726 var tab = items[id];
41727 if(!tab) { return; }
41728 var index = items.indexOf(tab);
41729 if(this.active == tab && items.length > 1){
41730 var newTab = this.getNextAvailable(index);
41735 this.stripEl.dom.removeChild(tab.pnode.dom);
41736 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
41737 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
41739 items.splice(index, 1);
41740 delete this.items[tab.id];
41741 tab.fireEvent("close", tab);
41742 tab.purgeListeners();
41743 this.autoSizeTabs();
41746 getNextAvailable : function(start){
41747 var items = this.items;
41749 // look for a next tab that will slide over to
41750 // replace the one being removed
41751 while(index < items.length){
41752 var item = items[++index];
41753 if(item && !item.isHidden()){
41757 // if one isn't found select the previous tab (on the left)
41760 var item = items[--index];
41761 if(item && !item.isHidden()){
41769 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
41770 * @param {String/Number} id The id or index of the TabPanelItem to disable.
41772 disableTab : function(id){
41773 var tab = this.items[id];
41774 if(tab && this.active != tab){
41780 * Enables a {@link Roo.TabPanelItem} that is disabled.
41781 * @param {String/Number} id The id or index of the TabPanelItem to enable.
41783 enableTab : function(id){
41784 var tab = this.items[id];
41789 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
41790 * @param {String/Number} id The id or index of the TabPanelItem to activate.
41791 * @return {Roo.TabPanelItem} The TabPanelItem.
41793 activate : function(id)
41795 //Roo.log('activite:' + id);
41797 var tab = this.items[id];
41801 if(tab == this.active || tab.disabled){
41805 this.fireEvent("beforetabchange", this, e, tab);
41806 if(e.cancel !== true && !tab.disabled){
41808 this.active.hide();
41810 this.active = this.items[id];
41811 this.active.show();
41812 this.fireEvent("tabchange", this, this.active);
41818 * Gets the active {@link Roo.TabPanelItem}.
41819 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
41821 getActiveTab : function(){
41822 return this.active;
41826 * Updates the tab body element to fit the height of the container element
41827 * for overflow scrolling
41828 * @param {Number} targetHeight (optional) Override the starting height from the elements height
41830 syncHeight : function(targetHeight){
41831 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
41832 var bm = this.bodyEl.getMargins();
41833 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
41834 this.bodyEl.setHeight(newHeight);
41838 onResize : function(){
41839 if(this.monitorResize){
41840 this.autoSizeTabs();
41845 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
41847 beginUpdate : function(){
41848 this.updating = true;
41852 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
41854 endUpdate : function(){
41855 this.updating = false;
41856 this.autoSizeTabs();
41860 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
41862 autoSizeTabs : function()
41864 var count = this.items.length;
41865 var vcount = count - this.hiddenCount;
41868 this.stripEl.hide();
41870 this.stripEl.show();
41873 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
41878 var w = Math.max(this.el.getWidth() - this.cpad, 10);
41879 var availWidth = Math.floor(w / vcount);
41880 var b = this.stripBody;
41881 if(b.getWidth() > w){
41882 var tabs = this.items;
41883 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
41884 if(availWidth < this.minTabWidth){
41885 /*if(!this.sleft){ // incomplete scrolling code
41886 this.createScrollButtons();
41889 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
41892 if(this.currentTabWidth < this.preferredTabWidth){
41893 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
41899 * Returns the number of tabs in this TabPanel.
41902 getCount : function(){
41903 return this.items.length;
41907 * Resizes all the tabs to the passed width
41908 * @param {Number} The new width
41910 setTabWidth : function(width){
41911 this.currentTabWidth = width;
41912 for(var i = 0, len = this.items.length; i < len; i++) {
41913 if(!this.items[i].isHidden()) {
41914 this.items[i].setWidth(width);
41920 * Destroys this TabPanel
41921 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
41923 destroy : function(removeEl){
41924 Roo.EventManager.removeResizeListener(this.onResize, this);
41925 for(var i = 0, len = this.items.length; i < len; i++){
41926 this.items[i].purgeListeners();
41928 if(removeEl === true){
41929 this.el.update("");
41934 createStrip : function(container)
41936 var strip = document.createElement("nav");
41937 strip.className = Roo.bootstrap.version == 4 ?
41938 "navbar-light bg-light" :
41939 "navbar navbar-default"; //"x-tabs-wrap";
41940 container.appendChild(strip);
41944 createStripList : function(strip)
41946 // div wrapper for retard IE
41947 // returns the "tr" element.
41948 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
41949 //'<div class="x-tabs-strip-wrap">'+
41950 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
41951 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
41952 return strip.firstChild; //.firstChild.firstChild.firstChild;
41954 createBody : function(container)
41956 var body = document.createElement("div");
41957 Roo.id(body, "tab-body");
41958 //Roo.fly(body).addClass("x-tabs-body");
41959 Roo.fly(body).addClass("tab-content");
41960 container.appendChild(body);
41963 createItemBody :function(bodyEl, id){
41964 var body = Roo.getDom(id);
41966 body = document.createElement("div");
41969 //Roo.fly(body).addClass("x-tabs-item-body");
41970 Roo.fly(body).addClass("tab-pane");
41971 bodyEl.insertBefore(body, bodyEl.firstChild);
41975 createStripElements : function(stripEl, text, closable, tpl)
41977 var td = document.createElement("li"); // was td..
41978 td.className = 'nav-item';
41980 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
41983 stripEl.appendChild(td);
41985 td.className = "x-tabs-closable";
41986 if(!this.closeTpl){
41987 this.closeTpl = new Roo.Template(
41988 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
41989 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
41990 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
41993 var el = this.closeTpl.overwrite(td, {"text": text});
41994 var close = el.getElementsByTagName("div")[0];
41995 var inner = el.getElementsByTagName("em")[0];
41996 return {"el": el, "close": close, "inner": inner};
41999 // not sure what this is..
42000 // if(!this.tabTpl){
42001 //this.tabTpl = new Roo.Template(
42002 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
42003 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
42005 // this.tabTpl = new Roo.Template(
42006 // '<a href="#">' +
42007 // '<span unselectable="on"' +
42008 // (this.disableTooltips ? '' : ' title="{text}"') +
42009 // ' >{text}</span></a>'
42015 var template = tpl || this.tabTpl || false;
42018 template = new Roo.Template(
42019 Roo.bootstrap.version == 4 ?
42021 '<a class="nav-link" href="#" unselectable="on"' +
42022 (this.disableTooltips ? '' : ' title="{text}"') +
42025 '<a class="nav-link" href="#">' +
42026 '<span unselectable="on"' +
42027 (this.disableTooltips ? '' : ' title="{text}"') +
42028 ' >{text}</span></a>'
42033 switch (typeof(template)) {
42037 template = new Roo.Template(template);
42043 var el = template.overwrite(td, {"text": text});
42045 var inner = el.getElementsByTagName("span")[0];
42047 return {"el": el, "inner": inner};
42055 * @class Roo.TabPanelItem
42056 * @extends Roo.util.Observable
42057 * Represents an individual item (tab plus body) in a TabPanel.
42058 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
42059 * @param {String} id The id of this TabPanelItem
42060 * @param {String} text The text for the tab of this TabPanelItem
42061 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
42063 Roo.bootstrap.panel.TabItem = function(config){
42065 * The {@link Roo.TabPanel} this TabPanelItem belongs to
42066 * @type Roo.TabPanel
42068 this.tabPanel = config.panel;
42070 * The id for this TabPanelItem
42073 this.id = config.id;
42075 this.disabled = false;
42077 this.text = config.text;
42079 this.loaded = false;
42080 this.closable = config.closable;
42083 * The body element for this TabPanelItem.
42084 * @type Roo.Element
42086 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
42087 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
42088 this.bodyEl.setStyle("display", "block");
42089 this.bodyEl.setStyle("zoom", "1");
42090 //this.hideAction();
42092 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
42094 this.el = Roo.get(els.el);
42095 this.inner = Roo.get(els.inner, true);
42096 this.textEl = Roo.bootstrap.version == 4 ?
42097 this.el : Roo.get(this.el.dom.firstChild, true);
42099 this.pnode = this.linode = Roo.get(els.el.parentNode, true);
42100 this.status_node = Roo.bootstrap.version == 4 ? this.el : this.linode;
42103 // this.el.on("mousedown", this.onTabMouseDown, this);
42104 this.el.on("click", this.onTabClick, this);
42106 if(config.closable){
42107 var c = Roo.get(els.close, true);
42108 c.dom.title = this.closeText;
42109 c.addClassOnOver("close-over");
42110 c.on("click", this.closeClick, this);
42116 * Fires when this tab becomes the active tab.
42117 * @param {Roo.TabPanel} tabPanel The parent TabPanel
42118 * @param {Roo.TabPanelItem} this
42122 * @event beforeclose
42123 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
42124 * @param {Roo.TabPanelItem} this
42125 * @param {Object} e Set cancel to true on this object to cancel the close.
42127 "beforeclose": true,
42130 * Fires when this tab is closed.
42131 * @param {Roo.TabPanelItem} this
42135 * @event deactivate
42136 * Fires when this tab is no longer the active tab.
42137 * @param {Roo.TabPanel} tabPanel The parent TabPanel
42138 * @param {Roo.TabPanelItem} this
42140 "deactivate" : true
42142 this.hidden = false;
42144 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
42147 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
42149 purgeListeners : function(){
42150 Roo.util.Observable.prototype.purgeListeners.call(this);
42151 this.el.removeAllListeners();
42154 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
42157 this.status_node.addClass("active");
42160 this.tabPanel.stripWrap.repaint();
42162 this.fireEvent("activate", this.tabPanel, this);
42166 * Returns true if this tab is the active tab.
42167 * @return {Boolean}
42169 isActive : function(){
42170 return this.tabPanel.getActiveTab() == this;
42174 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
42177 this.status_node.removeClass("active");
42179 this.fireEvent("deactivate", this.tabPanel, this);
42182 hideAction : function(){
42183 this.bodyEl.hide();
42184 this.bodyEl.setStyle("position", "absolute");
42185 this.bodyEl.setLeft("-20000px");
42186 this.bodyEl.setTop("-20000px");
42189 showAction : function(){
42190 this.bodyEl.setStyle("position", "relative");
42191 this.bodyEl.setTop("");
42192 this.bodyEl.setLeft("");
42193 this.bodyEl.show();
42197 * Set the tooltip for the tab.
42198 * @param {String} tooltip The tab's tooltip
42200 setTooltip : function(text){
42201 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
42202 this.textEl.dom.qtip = text;
42203 this.textEl.dom.removeAttribute('title');
42205 this.textEl.dom.title = text;
42209 onTabClick : function(e){
42210 e.preventDefault();
42211 this.tabPanel.activate(this.id);
42214 onTabMouseDown : function(e){
42215 e.preventDefault();
42216 this.tabPanel.activate(this.id);
42219 getWidth : function(){
42220 return this.inner.getWidth();
42223 setWidth : function(width){
42224 var iwidth = width - this.linode.getPadding("lr");
42225 this.inner.setWidth(iwidth);
42226 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
42227 this.linode.setWidth(width);
42231 * Show or hide the tab
42232 * @param {Boolean} hidden True to hide or false to show.
42234 setHidden : function(hidden){
42235 this.hidden = hidden;
42236 this.linode.setStyle("display", hidden ? "none" : "");
42240 * Returns true if this tab is "hidden"
42241 * @return {Boolean}
42243 isHidden : function(){
42244 return this.hidden;
42248 * Returns the text for this tab
42251 getText : function(){
42255 autoSize : function(){
42256 //this.el.beginMeasure();
42257 this.textEl.setWidth(1);
42259 * #2804 [new] Tabs in Roojs
42260 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
42262 //this.setWidth(this.textEl.dom.scrollWidth+this.linode.getPadding("lr")+this.inner.getPadding("lr") + 2);
42263 //this.el.endMeasure();
42267 * Sets the text for the tab (Note: this also sets the tooltip text)
42268 * @param {String} text The tab's text and tooltip
42270 setText : function(text){
42272 this.textEl.update(text);
42273 this.setTooltip(text);
42274 //if(!this.tabPanel.resizeTabs){
42275 // this.autoSize();
42279 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
42281 activate : function(){
42282 this.tabPanel.activate(this.id);
42286 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
42288 disable : function(){
42289 if(this.tabPanel.active != this){
42290 this.disabled = true;
42291 this.status_node.addClass("disabled");
42296 * Enables this TabPanelItem if it was previously disabled.
42298 enable : function(){
42299 this.disabled = false;
42300 this.status_node.removeClass("disabled");
42304 * Sets the content for this TabPanelItem.
42305 * @param {String} content The content
42306 * @param {Boolean} loadScripts true to look for and load scripts
42308 setContent : function(content, loadScripts){
42309 this.bodyEl.update(content, loadScripts);
42313 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
42314 * @return {Roo.UpdateManager} The UpdateManager
42316 getUpdateManager : function(){
42317 return this.bodyEl.getUpdateManager();
42321 * Set a URL to be used to load the content for this TabPanelItem.
42322 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
42323 * @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)
42324 * @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)
42325 * @return {Roo.UpdateManager} The UpdateManager
42327 setUrl : function(url, params, loadOnce){
42328 if(this.refreshDelegate){
42329 this.un('activate', this.refreshDelegate);
42331 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
42332 this.on("activate", this.refreshDelegate);
42333 return this.bodyEl.getUpdateManager();
42337 _handleRefresh : function(url, params, loadOnce){
42338 if(!loadOnce || !this.loaded){
42339 var updater = this.bodyEl.getUpdateManager();
42340 updater.update(url, params, this._setLoaded.createDelegate(this));
42345 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
42346 * Will fail silently if the setUrl method has not been called.
42347 * This does not activate the panel, just updates its content.
42349 refresh : function(){
42350 if(this.refreshDelegate){
42351 this.loaded = false;
42352 this.refreshDelegate();
42357 _setLoaded : function(){
42358 this.loaded = true;
42362 closeClick : function(e){
42365 this.fireEvent("beforeclose", this, o);
42366 if(o.cancel !== true){
42367 this.tabPanel.removeTab(this.id);
42371 * The text displayed in the tooltip for the close icon.
42374 closeText : "Close this tab"
42377 * This script refer to:
42378 * Title: International Telephone Input
42379 * Author: Jack O'Connor
42380 * Code version: v12.1.12
42381 * Availability: https://github.com/jackocnr/intl-tel-input.git
42384 Roo.bootstrap.PhoneInputData = function() {
42387 "Afghanistan (افغانستان)",
42392 "Albania (Shqipëri)",
42397 "Algeria (الجزائر)",
42422 "Antigua and Barbuda",
42432 "Armenia (Հայաստան)",
42448 "Austria (Österreich)",
42453 "Azerbaijan (Azərbaycan)",
42463 "Bahrain (البحرين)",
42468 "Bangladesh (বাংলাদেশ)",
42478 "Belarus (Беларусь)",
42483 "Belgium (België)",
42513 "Bosnia and Herzegovina (Босна и Херцеговина)",
42528 "British Indian Ocean Territory",
42533 "British Virgin Islands",
42543 "Bulgaria (България)",
42553 "Burundi (Uburundi)",
42558 "Cambodia (កម្ពុជា)",
42563 "Cameroon (Cameroun)",
42572 ["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"]
42575 "Cape Verde (Kabu Verdi)",
42580 "Caribbean Netherlands",
42591 "Central African Republic (République centrafricaine)",
42611 "Christmas Island",
42617 "Cocos (Keeling) Islands",
42628 "Comoros (جزر القمر)",
42633 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
42638 "Congo (Republic) (Congo-Brazzaville)",
42658 "Croatia (Hrvatska)",
42679 "Czech Republic (Česká republika)",
42684 "Denmark (Danmark)",
42699 "Dominican Republic (República Dominicana)",
42703 ["809", "829", "849"]
42721 "Equatorial Guinea (Guinea Ecuatorial)",
42741 "Falkland Islands (Islas Malvinas)",
42746 "Faroe Islands (Føroyar)",
42767 "French Guiana (Guyane française)",
42772 "French Polynesia (Polynésie française)",
42787 "Georgia (საქართველო)",
42792 "Germany (Deutschland)",
42812 "Greenland (Kalaallit Nunaat)",
42849 "Guinea-Bissau (Guiné Bissau)",
42874 "Hungary (Magyarország)",
42879 "Iceland (Ísland)",
42899 "Iraq (العراق)",
42915 "Israel (ישראל)",
42942 "Jordan (الأردن)",
42947 "Kazakhstan (Казахстан)",
42968 "Kuwait (الكويت)",
42973 "Kyrgyzstan (Кыргызстан)",
42983 "Latvia (Latvija)",
42988 "Lebanon (لبنان)",
43003 "Libya (ليبيا)",
43013 "Lithuania (Lietuva)",
43028 "Macedonia (FYROM) (Македонија)",
43033 "Madagascar (Madagasikara)",
43063 "Marshall Islands",
43073 "Mauritania (موريتانيا)",
43078 "Mauritius (Moris)",
43099 "Moldova (Republica Moldova)",
43109 "Mongolia (Монгол)",
43114 "Montenegro (Crna Gora)",
43124 "Morocco (المغرب)",
43130 "Mozambique (Moçambique)",
43135 "Myanmar (Burma) (မြန်မာ)",
43140 "Namibia (Namibië)",
43155 "Netherlands (Nederland)",
43160 "New Caledonia (Nouvelle-Calédonie)",
43195 "North Korea (조선 민주주의 인민 공화국)",
43200 "Northern Mariana Islands",
43216 "Pakistan (پاکستان)",
43226 "Palestine (فلسطين)",
43236 "Papua New Guinea",
43278 "Réunion (La Réunion)",
43284 "Romania (România)",
43300 "Saint Barthélemy",
43311 "Saint Kitts and Nevis",
43321 "Saint Martin (Saint-Martin (partie française))",
43327 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
43332 "Saint Vincent and the Grenadines",
43347 "São Tomé and Príncipe (São Tomé e Príncipe)",
43352 "Saudi Arabia (المملكة العربية السعودية)",
43357 "Senegal (Sénégal)",
43387 "Slovakia (Slovensko)",
43392 "Slovenia (Slovenija)",
43402 "Somalia (Soomaaliya)",
43412 "South Korea (대한민국)",
43417 "South Sudan (جنوب السودان)",
43427 "Sri Lanka (ශ්රී ලංකාව)",
43432 "Sudan (السودان)",
43442 "Svalbard and Jan Mayen",
43453 "Sweden (Sverige)",
43458 "Switzerland (Schweiz)",
43463 "Syria (سوريا)",
43508 "Trinidad and Tobago",
43513 "Tunisia (تونس)",
43518 "Turkey (Türkiye)",
43528 "Turks and Caicos Islands",
43538 "U.S. Virgin Islands",
43548 "Ukraine (Україна)",
43553 "United Arab Emirates (الإمارات العربية المتحدة)",
43575 "Uzbekistan (Oʻzbekiston)",
43585 "Vatican City (Città del Vaticano)",
43596 "Vietnam (Việt Nam)",
43601 "Wallis and Futuna (Wallis-et-Futuna)",
43606 "Western Sahara (الصحراء الغربية)",
43612 "Yemen (اليمن)",
43636 * This script refer to:
43637 * Title: International Telephone Input
43638 * Author: Jack O'Connor
43639 * Code version: v12.1.12
43640 * Availability: https://github.com/jackocnr/intl-tel-input.git
43644 * @class Roo.bootstrap.PhoneInput
43645 * @extends Roo.bootstrap.TriggerField
43646 * An input with International dial-code selection
43648 * @cfg {String} defaultDialCode default '+852'
43649 * @cfg {Array} preferedCountries default []
43652 * Create a new PhoneInput.
43653 * @param {Object} config Configuration options
43656 Roo.bootstrap.PhoneInput = function(config) {
43657 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
43660 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
43662 * @cfg {Roo.data.Store} store [required] The data store to which this combo is bound (defaults to undefined)
43664 listWidth: undefined,
43666 selectedClass: 'active',
43668 invalidClass : "has-warning",
43670 validClass: 'has-success',
43672 allowed: '0123456789',
43677 * @cfg {String} defaultDialCode The default dial code when initializing the input
43679 defaultDialCode: '+852',
43682 * @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
43684 preferedCountries: false,
43686 getAutoCreate : function()
43688 var data = Roo.bootstrap.PhoneInputData();
43689 var align = this.labelAlign || this.parentLabelAlign();
43692 this.allCountries = [];
43693 this.dialCodeMapping = [];
43695 for (var i = 0; i < data.length; i++) {
43697 this.allCountries[i] = {
43701 priority: c[3] || 0,
43702 areaCodes: c[4] || null
43704 this.dialCodeMapping[c[2]] = {
43707 priority: c[3] || 0,
43708 areaCodes: c[4] || null
43720 // type: 'number', -- do not use number - we get the flaky up/down arrows.
43721 maxlength: this.max_length,
43722 cls : 'form-control tel-input',
43723 autocomplete: 'new-password'
43726 var hiddenInput = {
43729 cls: 'hidden-tel-input'
43733 hiddenInput.name = this.name;
43736 if (this.disabled) {
43737 input.disabled = true;
43740 var flag_container = {
43757 cls: this.hasFeedback ? 'has-feedback' : '',
43763 cls: 'dial-code-holder',
43770 cls: 'roo-select2-container input-group',
43777 if (this.fieldLabel.length) {
43780 tooltip: 'This field is required'
43786 cls: 'control-label',
43792 html: this.fieldLabel
43795 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
43801 if(this.indicatorpos == 'right') {
43802 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
43809 if(align == 'left') {
43817 if(this.labelWidth > 12){
43818 label.style = "width: " + this.labelWidth + 'px';
43820 if(this.labelWidth < 13 && this.labelmd == 0){
43821 this.labelmd = this.labelWidth;
43823 if(this.labellg > 0){
43824 label.cls += ' col-lg-' + this.labellg;
43825 input.cls += ' col-lg-' + (12 - this.labellg);
43827 if(this.labelmd > 0){
43828 label.cls += ' col-md-' + this.labelmd;
43829 container.cls += ' col-md-' + (12 - this.labelmd);
43831 if(this.labelsm > 0){
43832 label.cls += ' col-sm-' + this.labelsm;
43833 container.cls += ' col-sm-' + (12 - this.labelsm);
43835 if(this.labelxs > 0){
43836 label.cls += ' col-xs-' + this.labelxs;
43837 container.cls += ' col-xs-' + (12 - this.labelxs);
43847 var settings = this;
43849 ['xs','sm','md','lg'].map(function(size){
43850 if (settings[size]) {
43851 cfg.cls += ' col-' + size + '-' + settings[size];
43855 this.store = new Roo.data.Store({
43856 proxy : new Roo.data.MemoryProxy({}),
43857 reader : new Roo.data.JsonReader({
43868 'name' : 'dialCode',
43872 'name' : 'priority',
43876 'name' : 'areaCodes',
43883 if(!this.preferedCountries) {
43884 this.preferedCountries = [
43891 var p = this.preferedCountries.reverse();
43894 for (var i = 0; i < p.length; i++) {
43895 for (var j = 0; j < this.allCountries.length; j++) {
43896 if(this.allCountries[j].iso2 == p[i]) {
43897 var t = this.allCountries[j];
43898 this.allCountries.splice(j,1);
43899 this.allCountries.unshift(t);
43905 this.store.proxy.data = {
43907 data: this.allCountries
43913 initEvents : function()
43916 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
43918 this.indicator = this.indicatorEl();
43919 this.flag = this.flagEl();
43920 this.dialCodeHolder = this.dialCodeHolderEl();
43922 this.trigger = this.el.select('div.flag-box',true).first();
43923 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
43928 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
43929 _this.list.setWidth(lw);
43932 this.list.on('mouseover', this.onViewOver, this);
43933 this.list.on('mousemove', this.onViewMove, this);
43934 this.inputEl().on("keyup", this.onKeyUp, this);
43935 this.inputEl().on("keypress", this.onKeyPress, this);
43937 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
43939 this.view = new Roo.View(this.list, this.tpl, {
43940 singleSelect:true, store: this.store, selectedClass: this.selectedClass
43943 this.view.on('click', this.onViewClick, this);
43944 this.setValue(this.defaultDialCode);
43947 onTriggerClick : function(e)
43949 Roo.log('trigger click');
43954 if(this.isExpanded()){
43956 this.hasFocus = false;
43958 this.store.load({});
43959 this.hasFocus = true;
43964 isExpanded : function()
43966 return this.list.isVisible();
43969 collapse : function()
43971 if(!this.isExpanded()){
43975 Roo.get(document).un('mousedown', this.collapseIf, this);
43976 Roo.get(document).un('mousewheel', this.collapseIf, this);
43977 this.fireEvent('collapse', this);
43981 expand : function()
43985 if(this.isExpanded() || !this.hasFocus){
43989 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
43990 this.list.setWidth(lw);
43993 this.restrictHeight();
43995 Roo.get(document).on('mousedown', this.collapseIf, this);
43996 Roo.get(document).on('mousewheel', this.collapseIf, this);
43998 this.fireEvent('expand', this);
44001 restrictHeight : function()
44003 this.list.alignTo(this.inputEl(), this.listAlign);
44004 this.list.alignTo(this.inputEl(), this.listAlign);
44007 onViewOver : function(e, t)
44009 if(this.inKeyMode){
44012 var item = this.view.findItemFromChild(t);
44015 var index = this.view.indexOf(item);
44016 this.select(index, false);
44021 onViewClick : function(view, doFocus, el, e)
44023 var index = this.view.getSelectedIndexes()[0];
44025 var r = this.store.getAt(index);
44028 this.onSelect(r, index);
44030 if(doFocus !== false && !this.blockFocus){
44031 this.inputEl().focus();
44035 onViewMove : function(e, t)
44037 this.inKeyMode = false;
44040 select : function(index, scrollIntoView)
44042 this.selectedIndex = index;
44043 this.view.select(index);
44044 if(scrollIntoView !== false){
44045 var el = this.view.getNode(index);
44047 this.list.scrollChildIntoView(el, false);
44052 createList : function()
44054 this.list = Roo.get(document.body).createChild({
44056 cls: 'typeahead typeahead-long dropdown-menu tel-list',
44057 style: 'display:none'
44060 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
44063 collapseIf : function(e)
44065 var in_combo = e.within(this.el);
44066 var in_list = e.within(this.list);
44067 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
44069 if (in_combo || in_list || is_list) {
44075 onSelect : function(record, index)
44077 if(this.fireEvent('beforeselect', this, record, index) !== false){
44079 this.setFlagClass(record.data.iso2);
44080 this.setDialCode(record.data.dialCode);
44081 this.hasFocus = false;
44083 this.fireEvent('select', this, record, index);
44087 flagEl : function()
44089 var flag = this.el.select('div.flag',true).first();
44096 dialCodeHolderEl : function()
44098 var d = this.el.select('input.dial-code-holder',true).first();
44105 setDialCode : function(v)
44107 this.dialCodeHolder.dom.value = '+'+v;
44110 setFlagClass : function(n)
44112 this.flag.dom.className = 'flag '+n;
44115 getValue : function()
44117 var v = this.inputEl().getValue();
44118 if(this.dialCodeHolder) {
44119 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
44124 setValue : function(v)
44126 var d = this.getDialCode(v);
44128 //invalid dial code
44129 if(v.length == 0 || !d || d.length == 0) {
44131 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
44132 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
44138 this.setFlagClass(this.dialCodeMapping[d].iso2);
44139 this.setDialCode(d);
44140 this.inputEl().dom.value = v.replace('+'+d,'');
44141 this.hiddenEl().dom.value = this.getValue();
44146 getDialCode : function(v)
44150 if (v.length == 0) {
44151 return this.dialCodeHolder.dom.value;
44155 if (v.charAt(0) != "+") {
44158 var numericChars = "";
44159 for (var i = 1; i < v.length; i++) {
44160 var c = v.charAt(i);
44163 if (this.dialCodeMapping[numericChars]) {
44164 dialCode = v.substr(1, i);
44166 if (numericChars.length == 4) {
44176 this.setValue(this.defaultDialCode);
44180 hiddenEl : function()
44182 return this.el.select('input.hidden-tel-input',true).first();
44185 // after setting val
44186 onKeyUp : function(e){
44187 this.setValue(this.getValue());
44190 onKeyPress : function(e){
44191 if(this.allowed.indexOf(String.fromCharCode(e.getCharCode())) === -1){
44198 * @class Roo.bootstrap.MoneyField
44199 * @extends Roo.bootstrap.ComboBox
44200 * Bootstrap MoneyField class
44203 * Create a new MoneyField.
44204 * @param {Object} config Configuration options
44207 Roo.bootstrap.MoneyField = function(config) {
44209 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
44213 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
44216 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
44218 allowDecimals : true,
44220 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
44222 decimalSeparator : ".",
44224 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
44226 decimalPrecision : 0,
44228 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
44230 allowNegative : true,
44232 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
44236 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
44238 minValue : Number.NEGATIVE_INFINITY,
44240 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
44242 maxValue : Number.MAX_VALUE,
44244 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
44246 minText : "The minimum value for this field is {0}",
44248 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
44250 maxText : "The maximum value for this field is {0}",
44252 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
44253 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
44255 nanText : "{0} is not a valid number",
44257 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
44261 * @cfg {String} defaults currency of the MoneyField
44262 * value should be in lkey
44264 defaultCurrency : false,
44266 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
44268 thousandsDelimiter : false,
44270 * @cfg {Number} max_length Maximum input field length allowed (defaults to Number.MAX_VALUE)
44281 getAutoCreate : function()
44283 var align = this.labelAlign || this.parentLabelAlign();
44295 cls : 'form-control roo-money-amount-input',
44296 autocomplete: 'new-password'
44299 var hiddenInput = {
44303 cls: 'hidden-number-input'
44306 if(this.max_length) {
44307 input.maxlength = this.max_length;
44311 hiddenInput.name = this.name;
44314 if (this.disabled) {
44315 input.disabled = true;
44318 var clg = 12 - this.inputlg;
44319 var cmd = 12 - this.inputmd;
44320 var csm = 12 - this.inputsm;
44321 var cxs = 12 - this.inputxs;
44325 cls : 'row roo-money-field',
44329 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
44333 cls: 'roo-select2-container input-group',
44337 cls : 'form-control roo-money-currency-input',
44338 autocomplete: 'new-password',
44340 name : this.currencyName
44344 cls : 'input-group-addon',
44358 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
44362 cls: this.hasFeedback ? 'has-feedback' : '',
44373 if (this.fieldLabel.length) {
44376 tooltip: 'This field is required'
44382 cls: 'control-label',
44388 html: this.fieldLabel
44391 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
44397 if(this.indicatorpos == 'right') {
44398 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
44405 if(align == 'left') {
44413 if(this.labelWidth > 12){
44414 label.style = "width: " + this.labelWidth + 'px';
44416 if(this.labelWidth < 13 && this.labelmd == 0){
44417 this.labelmd = this.labelWidth;
44419 if(this.labellg > 0){
44420 label.cls += ' col-lg-' + this.labellg;
44421 input.cls += ' col-lg-' + (12 - this.labellg);
44423 if(this.labelmd > 0){
44424 label.cls += ' col-md-' + this.labelmd;
44425 container.cls += ' col-md-' + (12 - this.labelmd);
44427 if(this.labelsm > 0){
44428 label.cls += ' col-sm-' + this.labelsm;
44429 container.cls += ' col-sm-' + (12 - this.labelsm);
44431 if(this.labelxs > 0){
44432 label.cls += ' col-xs-' + this.labelxs;
44433 container.cls += ' col-xs-' + (12 - this.labelxs);
44444 var settings = this;
44446 ['xs','sm','md','lg'].map(function(size){
44447 if (settings[size]) {
44448 cfg.cls += ' col-' + size + '-' + settings[size];
44455 initEvents : function()
44457 this.indicator = this.indicatorEl();
44459 this.initCurrencyEvent();
44461 this.initNumberEvent();
44464 initCurrencyEvent : function()
44467 throw "can not find store for combo";
44470 this.store = Roo.factory(this.store, Roo.data);
44471 this.store.parent = this;
44475 this.triggerEl = this.el.select('.input-group-addon', true).first();
44477 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
44482 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
44483 _this.list.setWidth(lw);
44486 this.list.on('mouseover', this.onViewOver, this);
44487 this.list.on('mousemove', this.onViewMove, this);
44488 this.list.on('scroll', this.onViewScroll, this);
44491 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
44494 this.view = new Roo.View(this.list, this.tpl, {
44495 singleSelect:true, store: this.store, selectedClass: this.selectedClass
44498 this.view.on('click', this.onViewClick, this);
44500 this.store.on('beforeload', this.onBeforeLoad, this);
44501 this.store.on('load', this.onLoad, this);
44502 this.store.on('loadexception', this.onLoadException, this);
44504 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
44505 "up" : function(e){
44506 this.inKeyMode = true;
44510 "down" : function(e){
44511 if(!this.isExpanded()){
44512 this.onTriggerClick();
44514 this.inKeyMode = true;
44519 "enter" : function(e){
44522 if(this.fireEvent("specialkey", this, e)){
44523 this.onViewClick(false);
44529 "esc" : function(e){
44533 "tab" : function(e){
44536 if(this.fireEvent("specialkey", this, e)){
44537 this.onViewClick(false);
44545 doRelay : function(foo, bar, hname){
44546 if(hname == 'down' || this.scope.isExpanded()){
44547 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
44555 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
44559 initNumberEvent : function(e)
44561 this.inputEl().on("keydown" , this.fireKey, this);
44562 this.inputEl().on("focus", this.onFocus, this);
44563 this.inputEl().on("blur", this.onBlur, this);
44565 this.inputEl().relayEvent('keyup', this);
44567 if(this.indicator){
44568 this.indicator.addClass('invisible');
44571 this.originalValue = this.getValue();
44573 if(this.validationEvent == 'keyup'){
44574 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
44575 this.inputEl().on('keyup', this.filterValidation, this);
44577 else if(this.validationEvent !== false){
44578 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
44581 if(this.selectOnFocus){
44582 this.on("focus", this.preFocus, this);
44585 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
44586 this.inputEl().on("keypress", this.filterKeys, this);
44588 this.inputEl().relayEvent('keypress', this);
44591 var allowed = "0123456789";
44593 if(this.allowDecimals){
44594 allowed += this.decimalSeparator;
44597 if(this.allowNegative){
44601 if(this.thousandsDelimiter) {
44605 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
44607 var keyPress = function(e){
44609 var k = e.getKey();
44611 var c = e.getCharCode();
44614 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
44615 allowed.indexOf(String.fromCharCode(c)) === -1
44621 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
44625 if(allowed.indexOf(String.fromCharCode(c)) === -1){
44630 this.inputEl().on("keypress", keyPress, this);
44634 onTriggerClick : function(e)
44641 this.loadNext = false;
44643 if(this.isExpanded()){
44648 this.hasFocus = true;
44650 if(this.triggerAction == 'all') {
44651 this.doQuery(this.allQuery, true);
44655 this.doQuery(this.getRawValue());
44658 getCurrency : function()
44660 var v = this.currencyEl().getValue();
44665 restrictHeight : function()
44667 this.list.alignTo(this.currencyEl(), this.listAlign);
44668 this.list.alignTo(this.currencyEl(), this.listAlign);
44671 onViewClick : function(view, doFocus, el, e)
44673 var index = this.view.getSelectedIndexes()[0];
44675 var r = this.store.getAt(index);
44678 this.onSelect(r, index);
44682 onSelect : function(record, index){
44684 if(this.fireEvent('beforeselect', this, record, index) !== false){
44686 this.setFromCurrencyData(index > -1 ? record.data : false);
44690 this.fireEvent('select', this, record, index);
44694 setFromCurrencyData : function(o)
44698 this.lastCurrency = o;
44700 if (this.currencyField) {
44701 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
44703 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
44706 this.lastSelectionText = currency;
44708 //setting default currency
44709 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
44710 this.setCurrency(this.defaultCurrency);
44714 this.setCurrency(currency);
44717 setFromData : function(o)
44721 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
44723 this.setFromCurrencyData(c);
44728 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
44730 Roo.log('no value set for '+ (this.name ? this.name : this.id));
44733 this.setValue(value);
44737 setCurrency : function(v)
44739 this.currencyValue = v;
44742 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
44747 setValue : function(v)
44749 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
44755 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
44757 this.inputEl().dom.value = (v == '') ? '' :
44758 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
44760 if(!this.allowZero && v === '0') {
44761 this.hiddenEl().dom.value = '';
44762 this.inputEl().dom.value = '';
44769 getRawValue : function()
44771 var v = this.inputEl().getValue();
44776 getValue : function()
44778 return this.fixPrecision(this.parseValue(this.getRawValue()));
44781 parseValue : function(value)
44783 if(this.thousandsDelimiter) {
44785 r = new RegExp(",", "g");
44786 value = value.replace(r, "");
44789 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
44790 return isNaN(value) ? '' : value;
44794 fixPrecision : function(value)
44796 if(this.thousandsDelimiter) {
44798 r = new RegExp(",", "g");
44799 value = value.replace(r, "");
44802 var nan = isNaN(value);
44804 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
44805 return nan ? '' : value;
44807 return parseFloat(value).toFixed(this.decimalPrecision);
44810 decimalPrecisionFcn : function(v)
44812 return Math.floor(v);
44815 validateValue : function(value)
44817 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
44821 var num = this.parseValue(value);
44824 this.markInvalid(String.format(this.nanText, value));
44828 if(num < this.minValue){
44829 this.markInvalid(String.format(this.minText, this.minValue));
44833 if(num > this.maxValue){
44834 this.markInvalid(String.format(this.maxText, this.maxValue));
44841 validate : function()
44843 if(this.disabled || this.allowBlank){
44848 var currency = this.getCurrency();
44850 if(this.validateValue(this.getRawValue()) && currency.length){
44855 this.markInvalid();
44859 getName: function()
44864 beforeBlur : function()
44870 var v = this.parseValue(this.getRawValue());
44877 onBlur : function()
44881 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
44882 //this.el.removeClass(this.focusClass);
44885 this.hasFocus = false;
44887 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
44891 var v = this.getValue();
44893 if(String(v) !== String(this.startValue)){
44894 this.fireEvent('change', this, v, this.startValue);
44897 this.fireEvent("blur", this);
44900 inputEl : function()
44902 return this.el.select('.roo-money-amount-input', true).first();
44905 currencyEl : function()
44907 return this.el.select('.roo-money-currency-input', true).first();
44910 hiddenEl : function()
44912 return this.el.select('input.hidden-number-input',true).first();
44916 * @class Roo.bootstrap.BezierSignature
44917 * @extends Roo.bootstrap.Component
44918 * Bootstrap BezierSignature class
44919 * This script refer to:
44920 * Title: Signature Pad
44922 * Availability: https://github.com/szimek/signature_pad
44925 * Create a new BezierSignature
44926 * @param {Object} config The config object
44929 Roo.bootstrap.BezierSignature = function(config){
44930 Roo.bootstrap.BezierSignature.superclass.constructor.call(this, config);
44936 Roo.extend(Roo.bootstrap.BezierSignature, Roo.bootstrap.Component,
44943 mouse_btn_down: true,
44946 * @cfg {int} canvas height
44948 canvas_height: '200px',
44951 * @cfg {float|function} Radius of a single dot.
44956 * @cfg {float} Minimum width of a line. Defaults to 0.5.
44961 * @cfg {float} Maximum width of a line. Defaults to 2.5.
44966 * @cfg {integer} Draw the next point at most once per every x milliseconds. Set it to 0 to turn off throttling. Defaults to 16.
44971 * @cfg {integer} Add the next point only if the previous one is farther than x pixels. Defaults to 5.
44976 * @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.
44978 bg_color: 'rgba(0, 0, 0, 0)',
44981 * @cfg {string} Color used to draw the lines. Can be any color format accepted by context.fillStyle. Defaults to "black".
44983 dot_color: 'black',
44986 * @cfg {float} Weight used to modify new velocity based on the previous velocity. Defaults to 0.7.
44988 velocity_filter_weight: 0.7,
44991 * @cfg {function} Callback when stroke begin.
44996 * @cfg {function} Callback when stroke end.
45000 getAutoCreate : function()
45002 var cls = 'roo-signature column';
45005 cls += ' ' + this.cls;
45015 for(var i = 0; i < col_sizes.length; i++) {
45016 if(this[col_sizes[i]]) {
45017 cls += " col-"+col_sizes[i]+"-"+this[col_sizes[i]];
45027 cls: 'roo-signature-body',
45031 cls: 'roo-signature-body-canvas',
45032 height: this.canvas_height,
45033 width: this.canvas_width
45040 style: 'display: none'
45048 initEvents: function()
45050 Roo.bootstrap.BezierSignature.superclass.initEvents.call(this);
45052 var canvas = this.canvasEl();
45054 // mouse && touch event swapping...
45055 canvas.dom.style.touchAction = 'none';
45056 canvas.dom.style.msTouchAction = 'none';
45058 this.mouse_btn_down = false;
45059 canvas.on('mousedown', this._handleMouseDown, this);
45060 canvas.on('mousemove', this._handleMouseMove, this);
45061 Roo.select('html').first().on('mouseup', this._handleMouseUp, this);
45063 if (window.PointerEvent) {
45064 canvas.on('pointerdown', this._handleMouseDown, this);
45065 canvas.on('pointermove', this._handleMouseMove, this);
45066 Roo.select('html').first().on('pointerup', this._handleMouseUp, this);
45069 if ('ontouchstart' in window) {
45070 canvas.on('touchstart', this._handleTouchStart, this);
45071 canvas.on('touchmove', this._handleTouchMove, this);
45072 canvas.on('touchend', this._handleTouchEnd, this);
45075 Roo.EventManager.onWindowResize(this.resize, this, true);
45077 // file input event
45078 this.fileEl().on('change', this.uploadImage, this);
45085 resize: function(){
45087 var canvas = this.canvasEl().dom;
45088 var ctx = this.canvasElCtx();
45089 var img_data = false;
45091 if(canvas.width > 0) {
45092 var img_data = ctx.getImageData(0, 0, canvas.width, canvas.height);
45094 // setting canvas width will clean img data
45097 var style = window.getComputedStyle ?
45098 getComputedStyle(this.el.dom, null) : this.el.dom.currentStyle;
45100 var padding_left = parseInt(style.paddingLeft) || 0;
45101 var padding_right = parseInt(style.paddingRight) || 0;
45103 canvas.width = this.el.dom.clientWidth - padding_left - padding_right;
45106 ctx.putImageData(img_data, 0, 0);
45110 _handleMouseDown: function(e)
45112 if (e.browserEvent.which === 1) {
45113 this.mouse_btn_down = true;
45114 this.strokeBegin(e);
45118 _handleMouseMove: function (e)
45120 if (this.mouse_btn_down) {
45121 this.strokeMoveUpdate(e);
45125 _handleMouseUp: function (e)
45127 if (e.browserEvent.which === 1 && this.mouse_btn_down) {
45128 this.mouse_btn_down = false;
45133 _handleTouchStart: function (e) {
45135 e.preventDefault();
45136 if (e.browserEvent.targetTouches.length === 1) {
45137 // var touch = e.browserEvent.changedTouches[0];
45138 // this.strokeBegin(touch);
45140 this.strokeBegin(e); // assume e catching the correct xy...
45144 _handleTouchMove: function (e) {
45145 e.preventDefault();
45146 // var touch = event.targetTouches[0];
45147 // _this._strokeMoveUpdate(touch);
45148 this.strokeMoveUpdate(e);
45151 _handleTouchEnd: function (e) {
45152 var wasCanvasTouched = e.target === this.canvasEl().dom;
45153 if (wasCanvasTouched) {
45154 e.preventDefault();
45155 // var touch = event.changedTouches[0];
45156 // _this._strokeEnd(touch);
45161 reset: function () {
45162 this._lastPoints = [];
45163 this._lastVelocity = 0;
45164 this._lastWidth = (this.min_width + this.max_width) / 2;
45165 this.canvasElCtx().fillStyle = this.dot_color;
45168 strokeMoveUpdate: function(e)
45170 this.strokeUpdate(e);
45172 if (this.throttle) {
45173 this.throttleStroke(this.strokeUpdate, this.throttle);
45176 this.strokeUpdate(e);
45180 strokeBegin: function(e)
45182 var newPointGroup = {
45183 color: this.dot_color,
45187 if (typeof this.onBegin === 'function') {
45191 this.curve_data.push(newPointGroup);
45193 this.strokeUpdate(e);
45196 strokeUpdate: function(e)
45198 var rect = this.canvasEl().dom.getBoundingClientRect();
45199 var point = new this.Point(e.xy[0] - rect.left, e.xy[1] - rect.top, new Date().getTime());
45200 var lastPointGroup = this.curve_data[this.curve_data.length - 1];
45201 var lastPoints = lastPointGroup.points;
45202 var lastPoint = lastPoints.length > 0 && lastPoints[lastPoints.length - 1];
45203 var isLastPointTooClose = lastPoint
45204 ? point.distanceTo(lastPoint) <= this.min_distance
45206 var color = lastPointGroup.color;
45207 if (!lastPoint || !(lastPoint && isLastPointTooClose)) {
45208 var curve = this.addPoint(point);
45210 this.drawDot({color: color, point: point});
45213 this.drawCurve({color: color, curve: curve});
45223 strokeEnd: function(e)
45225 this.strokeUpdate(e);
45226 if (typeof this.onEnd === 'function') {
45231 addPoint: function (point) {
45232 var _lastPoints = this._lastPoints;
45233 _lastPoints.push(point);
45234 if (_lastPoints.length > 2) {
45235 if (_lastPoints.length === 3) {
45236 _lastPoints.unshift(_lastPoints[0]);
45238 var widths = this.calculateCurveWidths(_lastPoints[1], _lastPoints[2]);
45239 var curve = this.Bezier.fromPoints(_lastPoints, widths, this);
45240 _lastPoints.shift();
45246 calculateCurveWidths: function (startPoint, endPoint) {
45247 var velocity = this.velocity_filter_weight * endPoint.velocityFrom(startPoint) +
45248 (1 - this.velocity_filter_weight) * this._lastVelocity;
45250 var newWidth = Math.max(this.max_width / (velocity + 1), this.min_width);
45253 start: this._lastWidth
45256 this._lastVelocity = velocity;
45257 this._lastWidth = newWidth;
45261 drawDot: function (_a) {
45262 var color = _a.color, point = _a.point;
45263 var ctx = this.canvasElCtx();
45264 var width = typeof this.dot_size === 'function' ? this.dot_size() : this.dot_size;
45266 this.drawCurveSegment(point.x, point.y, width);
45268 ctx.fillStyle = color;
45272 drawCurve: function (_a) {
45273 var color = _a.color, curve = _a.curve;
45274 var ctx = this.canvasElCtx();
45275 var widthDelta = curve.endWidth - curve.startWidth;
45276 var drawSteps = Math.floor(curve.length()) * 2;
45278 ctx.fillStyle = color;
45279 for (var i = 0; i < drawSteps; i += 1) {
45280 var t = i / drawSteps;
45286 var x = uuu * curve.startPoint.x;
45287 x += 3 * uu * t * curve.control1.x;
45288 x += 3 * u * tt * curve.control2.x;
45289 x += ttt * curve.endPoint.x;
45290 var y = uuu * curve.startPoint.y;
45291 y += 3 * uu * t * curve.control1.y;
45292 y += 3 * u * tt * curve.control2.y;
45293 y += ttt * curve.endPoint.y;
45294 var width = curve.startWidth + ttt * widthDelta;
45295 this.drawCurveSegment(x, y, width);
45301 drawCurveSegment: function (x, y, width) {
45302 var ctx = this.canvasElCtx();
45304 ctx.arc(x, y, width, 0, 2 * Math.PI, false);
45305 this.is_empty = false;
45310 var ctx = this.canvasElCtx();
45311 var canvas = this.canvasEl().dom;
45312 ctx.fillStyle = this.bg_color;
45313 ctx.clearRect(0, 0, canvas.width, canvas.height);
45314 ctx.fillRect(0, 0, canvas.width, canvas.height);
45315 this.curve_data = [];
45317 this.is_empty = true;
45322 return this.el.select('input',true).first();
45325 canvasEl: function()
45327 return this.el.select('canvas',true).first();
45330 canvasElCtx: function()
45332 return this.el.select('canvas',true).first().dom.getContext('2d');
45335 getImage: function(type)
45337 if(this.is_empty) {
45342 return this.canvasEl().dom.toDataURL('image/'+type, 1);
45345 drawFromImage: function(img_src)
45347 var img = new Image();
45349 img.onload = function(){
45350 this.canvasElCtx().drawImage(img, 0, 0);
45355 this.is_empty = false;
45358 selectImage: function()
45360 this.fileEl().dom.click();
45363 uploadImage: function(e)
45365 var reader = new FileReader();
45367 reader.onload = function(e){
45368 var img = new Image();
45369 img.onload = function(){
45371 this.canvasElCtx().drawImage(img, 0, 0);
45373 img.src = e.target.result;
45376 reader.readAsDataURL(e.target.files[0]);
45379 // Bezier Point Constructor
45380 Point: (function () {
45381 function Point(x, y, time) {
45384 this.time = time || Date.now();
45386 Point.prototype.distanceTo = function (start) {
45387 return Math.sqrt(Math.pow(this.x - start.x, 2) + Math.pow(this.y - start.y, 2));
45389 Point.prototype.equals = function (other) {
45390 return this.x === other.x && this.y === other.y && this.time === other.time;
45392 Point.prototype.velocityFrom = function (start) {
45393 return this.time !== start.time
45394 ? this.distanceTo(start) / (this.time - start.time)
45401 // Bezier Constructor
45402 Bezier: (function () {
45403 function Bezier(startPoint, control2, control1, endPoint, startWidth, endWidth) {
45404 this.startPoint = startPoint;
45405 this.control2 = control2;
45406 this.control1 = control1;
45407 this.endPoint = endPoint;
45408 this.startWidth = startWidth;
45409 this.endWidth = endWidth;
45411 Bezier.fromPoints = function (points, widths, scope) {
45412 var c2 = this.calculateControlPoints(points[0], points[1], points[2], scope).c2;
45413 var c3 = this.calculateControlPoints(points[1], points[2], points[3], scope).c1;
45414 return new Bezier(points[1], c2, c3, points[2], widths.start, widths.end);
45416 Bezier.calculateControlPoints = function (s1, s2, s3, scope) {
45417 var dx1 = s1.x - s2.x;
45418 var dy1 = s1.y - s2.y;
45419 var dx2 = s2.x - s3.x;
45420 var dy2 = s2.y - s3.y;
45421 var m1 = { x: (s1.x + s2.x) / 2.0, y: (s1.y + s2.y) / 2.0 };
45422 var m2 = { x: (s2.x + s3.x) / 2.0, y: (s2.y + s3.y) / 2.0 };
45423 var l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
45424 var l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
45425 var dxm = m1.x - m2.x;
45426 var dym = m1.y - m2.y;
45427 var k = l2 / (l1 + l2);
45428 var cm = { x: m2.x + dxm * k, y: m2.y + dym * k };
45429 var tx = s2.x - cm.x;
45430 var ty = s2.y - cm.y;
45432 c1: new scope.Point(m1.x + tx, m1.y + ty),
45433 c2: new scope.Point(m2.x + tx, m2.y + ty)
45436 Bezier.prototype.length = function () {
45441 for (var i = 0; i <= steps; i += 1) {
45443 var cx = this.point(t, this.startPoint.x, this.control1.x, this.control2.x, this.endPoint.x);
45444 var cy = this.point(t, this.startPoint.y, this.control1.y, this.control2.y, this.endPoint.y);
45446 var xdiff = cx - px;
45447 var ydiff = cy - py;
45448 length += Math.sqrt(xdiff * xdiff + ydiff * ydiff);
45455 Bezier.prototype.point = function (t, start, c1, c2, end) {
45456 return (start * (1.0 - t) * (1.0 - t) * (1.0 - t))
45457 + (3.0 * c1 * (1.0 - t) * (1.0 - t) * t)
45458 + (3.0 * c2 * (1.0 - t) * t * t)
45459 + (end * t * t * t);
45464 throttleStroke: function(fn, wait) {
45465 if (wait === void 0) { wait = 250; }
45467 var timeout = null;
45471 var later = function () {
45472 previous = Date.now();
45474 result = fn.apply(storedContext, storedArgs);
45476 storedContext = null;
45480 return function wrapper() {
45482 for (var _i = 0; _i < arguments.length; _i++) {
45483 args[_i] = arguments[_i];
45485 var now = Date.now();
45486 var remaining = wait - (now - previous);
45487 storedContext = this;
45489 if (remaining <= 0 || remaining > wait) {
45491 clearTimeout(timeout);
45495 result = fn.apply(storedContext, storedArgs);
45497 storedContext = null;
45501 else if (!timeout) {
45502 timeout = window.setTimeout(later, remaining);