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
226 * Bootstrap Component base class
227 * @cfg {String} cls css class
228 * @cfg {String} style any extra css
229 * @cfg {Object} xattr extra attributes to add to 'element' (used by builder to store stuff.)
230 * @cfg {Boolean} can_build_overlaid True if element can be rebuild from a HTML page
231 * @cfg {string} dataId cutomer id
232 * @cfg {string} name Specifies name attribute
233 * @cfg {string} tooltip Text for the tooltip
234 * @cfg {string} container_method method to fetch parents container element (used by NavHeaderbar - getHeaderChildContainer)
235 * @cfg {string|object} visibilityEl (el|parent) What element to use for visibility (@see getVisibilityEl())
238 * Do not use directly - it does not do anything..
239 * @param {Object} config The config object
244 Roo.bootstrap.Component = function(config){
245 Roo.bootstrap.Component.superclass.constructor.call(this, config);
249 * @event childrenrendered
250 * Fires when the children have been rendered..
251 * @param {Roo.bootstrap.Component} this
253 "childrenrendered" : true
262 Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent, {
265 allowDomMove : false, // to stop relocations in parent onRender...
275 * Initialize Events for the element
277 initEvents : function() { },
283 can_build_overlaid : true,
285 container_method : false,
292 // returns the parent component..
293 return Roo.ComponentMgr.get(this.parentId)
299 onRender : function(ct, position)
301 // Roo.log("Call onRender: " + this.xtype);
303 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
306 if (this.el.attr('xtype')) {
307 this.el.attr('xtypex', this.el.attr('xtype'));
308 this.el.dom.removeAttribute('xtype');
318 var cfg = Roo.apply({}, this.getAutoCreate());
320 cfg.id = this.id || Roo.id();
322 // fill in the extra attributes
323 if (this.xattr && typeof(this.xattr) =='object') {
324 for (var i in this.xattr) {
325 cfg[i] = this.xattr[i];
330 cfg.dataId = this.dataId;
334 cfg.cls = (typeof(cfg.cls) == 'undefined' ? this.cls : cfg.cls) + ' ' + this.cls;
337 if (this.style) { // fixme needs to support more complex style data.
338 cfg.style = (typeof(cfg.style) == 'undefined' ? this.style : cfg.style) + '; ' + this.style;
342 cfg.name = this.name;
345 this.el = ct.createChild(cfg, position);
348 this.tooltipEl().attr('tooltip', this.tooltip);
351 if(this.tabIndex !== undefined){
352 this.el.dom.setAttribute('tabIndex', this.tabIndex);
359 * Fetch the element to add children to
360 * @return {Roo.Element} defaults to this.el
362 getChildContainer : function()
366 getDocumentBody : function() // used by menus - as they are attached to the body so zIndexes work
368 return Roo.get(document.body);
372 * Fetch the element to display the tooltip on.
373 * @return {Roo.Element} defaults to this.el
375 tooltipEl : function()
380 addxtype : function(tree,cntr)
384 cn = Roo.factory(tree);
385 //Roo.log(['addxtype', cn]);
387 cn.parentType = this.xtype; //??
388 cn.parentId = this.id;
390 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
391 if (typeof(cn.container_method) == 'string') {
392 cntr = cn.container_method;
396 var has_flexy_each = (typeof(tree['flexy:foreach']) != 'undefined');
398 var has_flexy_if = (typeof(tree['flexy:if']) != 'undefined');
400 var build_from_html = Roo.XComponent.build_from_html;
402 var is_body = (tree.xtype == 'Body') ;
404 var page_has_body = (Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body');
406 var self_cntr_el = Roo.get(this[cntr](false));
408 // do not try and build conditional elements
409 if ((has_flexy_each || has_flexy_if || this.can_build_overlaid == false ) && build_from_html) {
413 if (!has_flexy_each || !build_from_html || is_body || !page_has_body) {
414 if(!has_flexy_if || typeof(tree.name) == 'undefined' || !build_from_html || is_body || !page_has_body){
415 return this.addxtypeChild(tree,cntr, is_body);
418 var echild =self_cntr_el ? self_cntr_el.child('>*[name=' + tree.name + ']') : false;
421 return this.addxtypeChild(Roo.apply({}, tree),cntr);
424 Roo.log('skipping render');
430 if (!build_from_html) {
434 // this i think handles overlaying multiple children of the same type
435 // with the sam eelement.. - which might be buggy..
437 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
443 if (echild && echild.attr('xtype').split('.').pop() != cn.xtype) {
447 ret = this.addxtypeChild(Roo.apply({}, tree),cntr);
454 addxtypeChild : function (tree, cntr, is_body)
456 Roo.debug && Roo.log('addxtypeChild:' + cntr);
458 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
461 var has_flexy = (typeof(tree['flexy:if']) != 'undefined') ||
462 (typeof(tree['flexy:foreach']) != 'undefined');
466 skip_children = false;
467 // render the element if it's not BODY.
470 // if parent was disabled, then do not try and create the children..
471 if(!this[cntr](true)){
476 cn = Roo.factory(tree);
478 cn.parentType = this.xtype; //??
479 cn.parentId = this.id;
481 var build_from_html = Roo.XComponent.build_from_html;
484 // does the container contain child eleemnts with 'xtype' attributes.
485 // that match this xtype..
486 // note - when we render we create these as well..
487 // so we should check to see if body has xtype set.
488 if (build_from_html && Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body') {
490 var self_cntr_el = Roo.get(this[cntr](false));
491 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
493 //Roo.log(Roo.XComponent.build_from_html);
494 //Roo.log("got echild:");
497 // there is a scenario where some of the child elements are flexy:if (and all of the same type)
498 // and are not displayed -this causes this to use up the wrong element when matching.
499 // at present the only work around for this is to nest flexy:if elements in another element that is always rendered.
502 if (echild && echild.attr('xtype').split('.').pop() == cn.xtype) {
503 // Roo.log("found child for " + this.xtype +": " + echild.attr('xtype') );
509 //echild.dom.removeAttribute('xtype');
511 Roo.debug && Roo.log("MISSING " + cn.xtype + " on child of " + (this.el ? this.el.attr('xbuilderid') : 'no parent'));
512 Roo.debug && Roo.log(self_cntr_el);
513 Roo.debug && Roo.log(echild);
514 Roo.debug && Roo.log(cn);
520 // if object has flexy:if - then it may or may not be rendered.
521 if (build_from_html && has_flexy && !cn.el && cn.can_build_overlaid) {
522 // skip a flexy if element.
523 Roo.debug && Roo.log('skipping render');
524 Roo.debug && Roo.log(tree);
526 Roo.debug && Roo.log('skipping all children');
527 skip_children = true;
532 // actually if flexy:foreach is found, we really want to create
533 // multiple copies here...
535 //Roo.log(this[cntr]());
536 // some elements do not have render methods.. like the layouts...
538 if(this[cntr](true) === false){
543 cn.render && cn.render(this[cntr](true));
546 // then add the element..
553 if (typeof (tree.menu) != 'undefined') {
554 tree.menu.parentType = cn.xtype;
555 tree.menu.triggerEl = cn.el;
556 nitems.push(cn.addxtype(Roo.apply({}, tree.menu)));
560 if (!tree.items || !tree.items.length) {
562 //Roo.log(["no children", this]);
567 var items = tree.items;
570 //Roo.log(items.length);
572 if (!skip_children) {
573 for(var i =0;i < items.length;i++) {
574 // Roo.log(['add child', items[i]]);
575 nitems.push(cn.addxtype(Roo.apply({}, items[i])));
581 //Roo.log("fire childrenrendered");
583 cn.fireEvent('childrenrendered', this);
589 * Set the element that will be used to show or hide
591 setVisibilityEl : function(el)
593 this.visibilityEl = el;
597 * Get the element that will be used to show or hide
599 getVisibilityEl : function()
601 if (typeof(this.visibilityEl) == 'object') {
602 return this.visibilityEl;
605 if (typeof(this.visibilityEl) == 'string') {
606 return this.visibilityEl == 'parent' ? this.parent().getEl() : this.getEl();
613 * Show a component - removes 'hidden' class
617 if(!this.getVisibilityEl()){
621 this.getVisibilityEl().removeClass(['hidden','d-none']);
623 this.fireEvent('show', this);
628 * Hide a component - adds 'hidden' class
632 if(!this.getVisibilityEl()){
636 this.getVisibilityEl().addClass(['hidden','d-none']);
638 this.fireEvent('hide', this);
651 * @class Roo.bootstrap.Element
652 * @extends Roo.bootstrap.Component
653 * Bootstrap Element class
654 * @cfg {String} html contents of the element
655 * @cfg {String} tag tag of the element
656 * @cfg {String} cls class of the element
657 * @cfg {Boolean} preventDefault (true|false) default false
658 * @cfg {Boolean} clickable (true|false) default false
659 * @cfg {String} role default blank - set to button to force cursor pointer
663 * Create a new Element
664 * @param {Object} config The config object
667 Roo.bootstrap.Element = function(config){
668 Roo.bootstrap.Element.superclass.constructor.call(this, config);
674 * When a element is chick
675 * @param {Roo.bootstrap.Element} this
676 * @param {Roo.EventObject} e
684 Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, {
689 preventDefault: false,
694 getAutoCreate : function(){
698 // cls: this.cls, double assign in parent class Component.js :: onRender
701 if (this.role !== false) {
702 cfg.role = this.role;
708 initEvents: function()
710 Roo.bootstrap.Element.superclass.initEvents.call(this);
713 this.el.on('click', this.onClick, this);
719 onClick : function(e)
721 if(this.preventDefault){
725 this.fireEvent('click', this, e); // why was this double click before?
733 getValue : function()
735 return this.el.dom.innerHTML;
738 setValue : function(value)
740 this.el.dom.innerHTML = value;
755 * @class Roo.bootstrap.DropTarget
756 * @extends Roo.bootstrap.Element
757 * Bootstrap DropTarget class
759 * @cfg {string} name dropable name
762 * Create a new Dropable Area
763 * @param {Object} config The config object
766 Roo.bootstrap.DropTarget = function(config){
767 Roo.bootstrap.DropTarget.superclass.constructor.call(this, config);
773 * When a element is chick
774 * @param {Roo.bootstrap.Element} this
775 * @param {Roo.EventObject} e
781 Roo.extend(Roo.bootstrap.DropTarget, Roo.bootstrap.Element, {
784 getAutoCreate : function(){
789 initEvents: function()
791 Roo.bootstrap.DropTarget.superclass.initEvents.call(this);
792 this.dropZone = new Roo.dd.DropTarget(this.getEl(), {
795 drop : this.dragDrop.createDelegate(this),
796 enter : this.dragEnter.createDelegate(this),
797 out : this.dragOut.createDelegate(this),
798 over : this.dragOver.createDelegate(this)
802 this.dropZone.DDM.useCache = false // so data gets refreshed when we resize stuff
805 dragDrop : function(source,e,data)
807 // user has to decide how to impliment this.
810 //this.fireEvent('drop', this, source, e ,data);
814 dragEnter : function(n, dd, e, data)
816 // probably want to resize the element to match the dropped element..
818 this.originalSize = this.el.getSize();
819 this.el.setSize( n.el.getSize());
820 this.dropZone.DDM.refreshCache(this.name);
821 Roo.log([n, dd, e, data]);
824 dragOut : function(value)
826 // resize back to normal
828 this.el.setSize(this.originalSize);
829 this.dropZone.resetConstraints();
832 dragOver : function()
849 * @class Roo.bootstrap.Body
850 * @extends Roo.bootstrap.Component
852 * @children Roo.bootstrap.Component
854 * Bootstrap Body class
858 * @param {Object} config The config object
861 Roo.bootstrap.Body = function(config){
863 config = config || {};
865 Roo.bootstrap.Body.superclass.constructor.call(this, config);
866 this.el = Roo.get(config.el ? config.el : document.body );
867 if (this.cls && this.cls.length) {
868 Roo.get(document.body).addClass(this.cls);
872 Roo.extend(Roo.bootstrap.Body, Roo.bootstrap.Component, {
874 is_body : true,// just to make sure it's constructed?
879 onRender : function(ct, position)
881 /* Roo.log("Roo.bootstrap.Body - onRender");
882 if (this.cls && this.cls.length) {
883 Roo.get(document.body).addClass(this.cls);
902 * @class Roo.bootstrap.ButtonGroup
903 * @extends Roo.bootstrap.Component
904 * Bootstrap ButtonGroup class
905 * @cfg {String} size lg | sm | xs (default empty normal)
906 * @cfg {String} align vertical | justified (default none)
907 * @cfg {String} direction up | down (default down)
908 * @cfg {Boolean} toolbar false | true
909 * @cfg {Boolean} btn true | false
914 * @param {Object} config The config object
917 Roo.bootstrap.ButtonGroup = function(config){
918 Roo.bootstrap.ButtonGroup.superclass.constructor.call(this, config);
921 Roo.extend(Roo.bootstrap.ButtonGroup, Roo.bootstrap.Component, {
929 getAutoCreate : function(){
935 cfg.html = this.html || cfg.html;
946 if (['vertical','justified'].indexOf(this.align)!==-1) {
947 cfg.cls = 'btn-group-' + this.align;
949 if (this.align == 'justified') {
950 console.log(this.items);
954 if (['lg','sm','xs'].indexOf(this.size)!==-1) {
955 cfg.cls += ' btn-group-' + this.size;
958 if (this.direction == 'up') {
959 cfg.cls += ' dropup' ;
965 * Add a button to the group (similar to NavItem API.)
967 addItem : function(cfg)
969 var cn = new Roo.bootstrap.Button(cfg);
971 cn.parentId = this.id;
972 cn.onRender(this.el, null);
986 * @class Roo.bootstrap.Button
987 * @extends Roo.bootstrap.Component
988 * Bootstrap Button class
989 * @cfg {String} html The button content
990 * @cfg {String} weight (default|primary|secondary|success|info|warning|danger|link|light|dark) default
991 * @cfg {String} badge_weight (default|primary|secondary|success|info|warning|danger|link|light|dark) default (same as button)
992 * @cfg {Boolean} outline default false (except for weight=default which emulates old behaveiour with an outline)
993 * @cfg {String} size (lg|sm|xs)
994 * @cfg {String} tag (a|input|submit)
995 * @cfg {String} href empty or href
996 * @cfg {Boolean} disabled default false;
997 * @cfg {Boolean} isClose default false;
998 * @cfg {String} glyphicon depricated - use fa
999 * @cfg {String} fa fontawesome icon - eg. 'comment' - without the fa/fas etc..
1000 * @cfg {String} badge text for badge
1001 * @cfg {String} theme (default|glow)
1002 * @cfg {Boolean} inverse dark themed version
1003 * @cfg {Boolean} toggle is it a slidy toggle button
1004 * @cfg {Boolean} pressed default null - if the button ahs active state
1005 * @cfg {String} ontext text for on slidy toggle state
1006 * @cfg {String} offtext text for off slidy toggle state
1007 * @cfg {Boolean} preventDefault default true (stop click event triggering the URL if it's a link.)
1008 * @cfg {Boolean} removeClass remove the standard class..
1009 * @cfg {String} target (_self|_blank|_parent|_top|other) target for a href.
1010 * @cfg {Boolean} grpup if parent is a btn group - then it turns it into a toogleGroup.
1013 * Create a new button
1014 * @param {Object} config The config object
1018 Roo.bootstrap.Button = function(config){
1019 Roo.bootstrap.Button.superclass.constructor.call(this, config);
1025 * When a button is pressed
1026 * @param {Roo.bootstrap.Button} btn
1027 * @param {Roo.EventObject} e
1032 * When a button is double clicked
1033 * @param {Roo.bootstrap.Button} btn
1034 * @param {Roo.EventObject} e
1039 * After the button has been toggles
1040 * @param {Roo.bootstrap.Button} btn
1041 * @param {Roo.EventObject} e
1042 * @param {boolean} pressed (also available as button.pressed)
1048 Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, {
1069 preventDefault: true,
1078 getAutoCreate : function(){
1086 if (['a', 'button', 'input', 'submit'].indexOf(this.tag) < 0) {
1087 throw "Invalid value for tag: " + this.tag + ". must be a, button, input or submit.";
1088 this.tag = 'button';
1092 cfg.html = '<span class="roo-button-text">' + (this.html || cfg.html) + '</span>';
1094 if (this.toggle == true) {
1097 cls: 'slider-frame roo-button',
1101 'data-on-text':'ON',
1102 'data-off-text':'OFF',
1103 cls: 'slider-button',
1108 // why are we validating the weights?
1109 if (Roo.bootstrap.Button.weights.indexOf(this.weight) > -1) {
1110 cfg.cls += ' ' + this.weight;
1117 cfg.cls += ' close';
1119 cfg["aria-hidden"] = true;
1121 cfg.html = "×";
1127 if (this.theme==='default') {
1128 cfg.cls = 'btn roo-button';
1130 //if (this.parentType != 'Navbar') {
1131 this.weight = this.weight.length ? this.weight : 'default';
1133 if (Roo.bootstrap.Button.weights.indexOf(this.weight) > -1) {
1135 var outline = this.outline || this.weight == 'default' ? 'outline-' : '';
1136 var weight = this.weight == 'default' ? 'secondary' : this.weight;
1137 cfg.cls += ' btn-' + outline + weight;
1138 if (this.weight == 'default') {
1140 cfg.cls += ' btn-' + this.weight;
1143 } else if (this.theme==='glow') {
1146 cfg.cls = 'btn-glow roo-button';
1148 if (Roo.bootstrap.Button.weights.indexOf(this.weight) > -1) {
1150 cfg.cls += ' ' + this.weight;
1156 this.cls += ' inverse';
1160 if (this.active || this.pressed === true) {
1161 cfg.cls += ' active';
1164 if (this.disabled) {
1165 cfg.disabled = 'disabled';
1169 Roo.log('changing to ul' );
1171 this.glyphicon = 'caret';
1172 if (Roo.bootstrap.version == 4) {
1173 this.fa = 'caret-down';
1178 cfg.cls += this.size.length ? (' btn-' + this.size) : '';
1180 //gsRoo.log(this.parentType);
1181 if (this.parentType === 'Navbar' && !this.parent().bar) {
1182 Roo.log('changing to li?');
1191 href : this.href || '#'
1194 cfg.cn[0].html = this.html + ' <span class="caret"></span>';
1195 cfg.cls += ' dropdown';
1202 cfg.cls += this.parentType === 'Navbar' ? ' navbar-btn' : '';
1204 if (this.glyphicon) {
1205 cfg.html = ' ' + cfg.html;
1210 cls: 'glyphicon glyphicon-' + this.glyphicon
1215 cfg.html = ' ' + cfg.html;
1220 cls: 'fa fas fa-' + this.fa
1230 // cfg.cls='btn roo-button';
1234 var value = cfg.html;
1239 cls: 'glyphicon glyphicon-' + this.glyphicon,
1246 cls: 'fa fas fa-' + this.fa,
1251 var bw = this.badge_weight.length ? this.badge_weight :
1252 (this.weight.length ? this.weight : 'secondary');
1253 bw = bw == 'default' ? 'secondary' : bw;
1259 cls: 'badge badge-' + bw,
1268 cfg.cls += ' dropdown';
1269 cfg.html = typeof(cfg.html) != 'undefined' ?
1270 cfg.html + ' <span class="caret"></span>' : '<span class="caret"></span>';
1273 if (cfg.tag !== 'a' && this.href !== '') {
1274 throw "Tag must be a to set href.";
1275 } else if (this.href.length > 0) {
1276 cfg.href = this.href;
1279 if(this.removeClass){
1284 cfg.target = this.target;
1289 initEvents: function() {
1290 // Roo.log('init events?');
1291 // Roo.log(this.el.dom);
1294 if (typeof (this.menu) != 'undefined') {
1295 this.menu.parentType = this.xtype;
1296 this.menu.triggerEl = this.el;
1297 this.addxtype(Roo.apply({}, this.menu));
1301 if (this.el.hasClass('roo-button')) {
1302 this.el.on('click', this.onClick, this);
1303 this.el.on('dblclick', this.onDblClick, this);
1305 this.el.select('.roo-button').on('click', this.onClick, this);
1306 this.el.select('.roo-button').on('dblclick', this.onDblClick, this);
1310 if(this.removeClass){
1311 this.el.on('click', this.onClick, this);
1314 if (this.group === true) {
1315 if (this.pressed === false || this.pressed === true) {
1318 this.pressed = false;
1319 this.setActive(this.pressed);
1324 this.el.enableDisplayMode();
1327 onClick : function(e)
1329 if (this.disabled) {
1333 Roo.log('button on click ');
1334 if(this.preventDefault){
1343 this.setActive(true);
1344 var pi = this.parent().items;
1345 for (var i = 0;i < pi.length;i++) {
1346 if (this == pi[i]) {
1349 if (pi[i].el.hasClass('roo-button')) {
1350 pi[i].setActive(false);
1353 this.fireEvent('click', this, e);
1357 if (this.pressed === true || this.pressed === false) {
1358 this.toggleActive(e);
1362 this.fireEvent('click', this, e);
1364 onDblClick: function(e)
1366 if (this.disabled) {
1369 if(this.preventDefault){
1372 this.fireEvent('dblclick', this, e);
1375 * Enables this button
1379 this.disabled = false;
1380 this.el.removeClass('disabled');
1381 this.el.dom.removeAttribute("disabled");
1385 * Disable this button
1387 disable : function()
1389 this.disabled = true;
1390 this.el.addClass('disabled');
1391 this.el.attr("disabled", "disabled")
1394 * sets the active state on/off,
1395 * @param {Boolean} state (optional) Force a particular state
1397 setActive : function(v) {
1399 this.el[v ? 'addClass' : 'removeClass']('active');
1403 * toggles the current active state
1405 toggleActive : function(e)
1407 this.setActive(!this.pressed); // this modifies pressed...
1408 this.fireEvent('toggle', this, e, this.pressed);
1411 * get the current active state
1412 * @return {boolean} true if it's active
1414 isActive : function()
1416 return this.el.hasClass('active');
1419 * set the text of the first selected button
1421 setText : function(str)
1423 this.el.select('.roo-button-text',true).first().dom.innerHTML = str;
1426 * get the text of the first selected button
1428 getText : function()
1430 return this.el.select('.roo-button-text',true).first().dom.innerHTML;
1433 setWeight : function(str)
1435 this.el.removeClass(Roo.bootstrap.Button.weights.map(function(w) { return 'btn-' + w; } ) );
1436 this.el.removeClass(Roo.bootstrap.Button.weights.map(function(w) { return 'btn-outline-' + w; } ) );
1438 var outline = this.outline ? 'outline-' : '';
1439 if (str == 'default') {
1440 this.el.addClass('btn-default btn-outline-secondary');
1443 this.el.addClass('btn-' + outline + str);
1448 // fixme - this is probably generic bootstrap - should go in some kind of enum file.. - like sizes.
1450 Roo.bootstrap.Button.weights = [
1470 * @class Roo.bootstrap.Column
1471 * @extends Roo.bootstrap.Component
1472 * Bootstrap Column class
1473 * @cfg {Number} xs colspan out of 12 for mobile-sized screens or 0 for hidden
1474 * @cfg {Number} sm colspan out of 12 for tablet-sized screens or 0 for hidden
1475 * @cfg {Number} md colspan out of 12 for computer-sized screens or 0 for hidden
1476 * @cfg {Number} lg colspan out of 12 for large computer-sized screens or 0 for hidden
1477 * @cfg {Number} xsoff colspan offset out of 12 for mobile-sized screens or 0 for hidden
1478 * @cfg {Number} smoff colspan offset out of 12 for tablet-sized screens or 0 for hidden
1479 * @cfg {Number} mdoff colspan offset out of 12 for computer-sized screens or 0 for hidden
1480 * @cfg {Number} lgoff colspan offset out of 12 for large computer-sized screens or 0 for hidden
1483 * @cfg {Boolean} hidden (true|false) hide the element
1484 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1485 * @cfg {String} fa (ban|check|...) font awesome icon
1486 * @cfg {Number} fasize (1|2|....) font awsome size
1488 * @cfg {String} icon (info-sign|check|...) glyphicon name
1490 * @cfg {String} html content of column.
1493 * Create a new Column
1494 * @param {Object} config The config object
1497 Roo.bootstrap.Column = function(config){
1498 Roo.bootstrap.Column.superclass.constructor.call(this, config);
1501 Roo.extend(Roo.bootstrap.Column, Roo.bootstrap.Component, {
1519 getAutoCreate : function(){
1520 var cfg = Roo.apply({}, Roo.bootstrap.Column.superclass.getAutoCreate.call(this));
1528 var sizes = ['xs','sm','md','lg'];
1529 sizes.map(function(size ,ix){
1530 //Roo.log( size + ':' + settings[size]);
1532 if (settings[size+'off'] !== false) {
1533 cfg.cls += ' col-' + size + '-offset-' + settings[size+'off'] ;
1536 if (settings[size] === false) {
1540 if (!settings[size]) { // 0 = hidden
1541 cfg.cls += ' hidden-' + size + ' hidden-' + size + '-down';
1543 for (var i = ix; i > -1; i--) {
1544 cfg.cls += ' d-' + sizes[i] + '-none';
1550 cfg.cls += ' col-' + size + '-' + settings[size] + (
1551 size == 'xs' ? (' col-' + settings[size] ) : '' // bs4 col-{num} replaces col-xs
1557 cfg.cls += ' hidden';
1560 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1561 cfg.cls +=' alert alert-' + this.alert;
1565 if (this.html.length) {
1566 cfg.html = this.html;
1570 if (this.fasize > 1) {
1571 fasize = ' fa-' + this.fasize + 'x';
1573 cfg.html = '<i class="fa fa-'+this.fa + fasize + '"></i>' + (cfg.html || '');
1578 cfg.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + (cfg.html || '');
1597 * @class Roo.bootstrap.Container
1598 * @extends Roo.bootstrap.Component
1600 * @children Roo.bootstrap.Component
1601 * Bootstrap Container class
1602 * @cfg {Boolean} jumbotron is it a jumbotron element
1603 * @cfg {String} html content of element
1604 * @cfg {String} well (lg|sm|md) a well, large, small or medium.
1605 * @cfg {String} panel (default|primary|success|info|warning|danger) render as panel - type - primary/success.....
1606 * @cfg {String} header content of header (for panel)
1607 * @cfg {String} footer content of footer (for panel)
1608 * @cfg {String} sticky (footer|wrap|push) block to use as footer or body- needs css-bootstrap/sticky-footer.css
1609 * @cfg {String} tag (header|aside|section) type of HTML tag.
1610 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1611 * @cfg {String} fa font awesome icon
1612 * @cfg {String} icon (info-sign|check|...) glyphicon name
1613 * @cfg {Boolean} hidden (true|false) hide the element
1614 * @cfg {Boolean} expandable (true|false) default false
1615 * @cfg {Boolean} expanded (true|false) default true
1616 * @cfg {String} rheader contet on the right of header
1617 * @cfg {Boolean} clickable (true|false) default false
1621 * Create a new Container
1622 * @param {Object} config The config object
1625 Roo.bootstrap.Container = function(config){
1626 Roo.bootstrap.Container.superclass.constructor.call(this, config);
1632 * After the panel has been expand
1634 * @param {Roo.bootstrap.Container} this
1639 * After the panel has been collapsed
1641 * @param {Roo.bootstrap.Container} this
1646 * When a element is chick
1647 * @param {Roo.bootstrap.Container} this
1648 * @param {Roo.EventObject} e
1654 Roo.extend(Roo.bootstrap.Container, Roo.bootstrap.Component, {
1672 getChildContainer : function() {
1678 if (this.panel.length) {
1679 return this.el.select('.panel-body',true).first();
1686 getAutoCreate : function(){
1689 tag : this.tag || 'div',
1693 if (this.jumbotron) {
1694 cfg.cls = 'jumbotron';
1699 // - this is applied by the parent..
1701 // cfg.cls = this.cls + '';
1704 if (this.sticky.length) {
1706 var bd = Roo.get(document.body);
1707 if (!bd.hasClass('bootstrap-sticky')) {
1708 bd.addClass('bootstrap-sticky');
1709 Roo.select('html',true).setStyle('height', '100%');
1712 cfg.cls += 'bootstrap-sticky-' + this.sticky;
1716 if (this.well.length) {
1717 switch (this.well) {
1720 cfg.cls +=' well well-' +this.well;
1729 cfg.cls += ' hidden';
1733 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1734 cfg.cls +=' alert alert-' + this.alert;
1739 if (this.panel.length) {
1740 cfg.cls += ' panel panel-' + this.panel;
1742 if (this.header.length) {
1746 if(this.expandable){
1748 cfg.cls = cfg.cls + ' expandable';
1752 cls: (this.expanded ? 'fa fa-minus' : 'fa fa-plus')
1760 cls : 'panel-title',
1761 html : (this.expandable ? ' ' : '') + this.header
1765 cls: 'panel-header-right',
1771 cls : 'panel-heading',
1772 style : this.expandable ? 'cursor: pointer' : '',
1780 cls : 'panel-body' + (this.expanded ? '' : ' hide'),
1785 if (this.footer.length) {
1787 cls : 'panel-footer',
1796 body.html = this.html || cfg.html;
1797 // prefix with the icons..
1799 body.html = '<i class="fa fa-'+this.fa + '"></i>' + body.html ;
1802 body.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + body.html ;
1807 if ((!this.cls || !this.cls.length) && (!cfg.cls || !cfg.cls.length)) {
1808 cfg.cls = 'container';
1814 initEvents: function()
1816 if(this.expandable){
1817 var headerEl = this.headerEl();
1820 headerEl.on('click', this.onToggleClick, this);
1825 this.el.on('click', this.onClick, this);
1830 onToggleClick : function()
1832 var headerEl = this.headerEl();
1848 if(this.fireEvent('expand', this)) {
1850 this.expanded = true;
1852 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).show();
1854 this.el.select('.panel-body',true).first().removeClass('hide');
1856 var toggleEl = this.toggleEl();
1862 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-minus']);
1867 collapse : function()
1869 if(this.fireEvent('collapse', this)) {
1871 this.expanded = false;
1873 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).hide();
1874 this.el.select('.panel-body',true).first().addClass('hide');
1876 var toggleEl = this.toggleEl();
1882 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-plus']);
1886 toggleEl : function()
1888 if(!this.el || !this.panel.length || !this.header.length || !this.expandable){
1892 return this.el.select('.panel-heading .fa',true).first();
1895 headerEl : function()
1897 if(!this.el || !this.panel.length || !this.header.length){
1901 return this.el.select('.panel-heading',true).first()
1906 if(!this.el || !this.panel.length){
1910 return this.el.select('.panel-body',true).first()
1913 titleEl : function()
1915 if(!this.el || !this.panel.length || !this.header.length){
1919 return this.el.select('.panel-title',true).first();
1922 setTitle : function(v)
1924 var titleEl = this.titleEl();
1930 titleEl.dom.innerHTML = v;
1933 getTitle : function()
1936 var titleEl = this.titleEl();
1942 return titleEl.dom.innerHTML;
1945 setRightTitle : function(v)
1947 var t = this.el.select('.panel-header-right',true).first();
1953 t.dom.innerHTML = v;
1956 onClick : function(e)
1960 this.fireEvent('click', this, e);
1967 * This is BS4's Card element.. - similar to our containers probably..
1971 * @class Roo.bootstrap.Card
1972 * @extends Roo.bootstrap.Component
1973 * Bootstrap Card class
1976 * possible... may not be implemented..
1977 * @cfg {String} header_image src url of image.
1978 * @cfg {String|Object} header
1979 * @cfg {Number} header_size (0|1|2|3|4|5) H1 or H2 etc.. 0 indicates default
1980 * @cfg {Number} header_weight (primary|secondary|success|info|warning|danger|light|dark)
1982 * @cfg {String} title
1983 * @cfg {String} subtitle
1984 * @cfg {String|Boolean} html -- html contents - or just use children.. use false to hide it..
1985 * @cfg {String} footer
1987 * @cfg {String} weight (primary|warning|info|danger|secondary|success|light|dark)
1989 * @cfg {String} margin (0|1|2|3|4|5|auto)
1990 * @cfg {String} margin_top (0|1|2|3|4|5|auto)
1991 * @cfg {String} margin_bottom (0|1|2|3|4|5|auto)
1992 * @cfg {String} margin_left (0|1|2|3|4|5|auto)
1993 * @cfg {String} margin_right (0|1|2|3|4|5|auto)
1994 * @cfg {String} margin_x (0|1|2|3|4|5|auto)
1995 * @cfg {String} margin_y (0|1|2|3|4|5|auto)
1997 * @cfg {String} padding (0|1|2|3|4|5)
1998 * @cfg {String} padding_top (0|1|2|3|4|5)next_to_card
1999 * @cfg {String} padding_bottom (0|1|2|3|4|5)
2000 * @cfg {String} padding_left (0|1|2|3|4|5)
2001 * @cfg {String} padding_right (0|1|2|3|4|5)
2002 * @cfg {String} padding_x (0|1|2|3|4|5)
2003 * @cfg {String} padding_y (0|1|2|3|4|5)
2005 * @cfg {String} display (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
2006 * @cfg {String} display_xs (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
2007 * @cfg {String} display_sm (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
2008 * @cfg {String} display_lg (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
2009 * @cfg {String} display_xl (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
2011 * @config {Boolean} dragable if this card can be dragged.
2012 * @config {String} drag_group group for drag
2013 * @config {Boolean} dropable if this card can recieve other cards being dropped onto it..
2014 * @config {String} drop_group group for drag
2016 * @config {Boolean} collapsable can the body be collapsed.
2017 * @config {Boolean} collapsed is the body collapsed when rendered...
2018 * @config {Boolean} rotateable can the body be rotated by clicking on it..
2019 * @config {Boolean} rotated is the body rotated when rendered...
2022 * Create a new Container
2023 * @param {Object} config The config object
2026 Roo.bootstrap.Card = function(config){
2027 Roo.bootstrap.Card.superclass.constructor.call(this, config);
2033 * When a element a card is dropped
2034 * @param {Roo.bootstrap.Card} this
2037 * @param {Roo.bootstrap.Card} move_card the card being dropped?
2038 * @param {String} position 'above' or 'below'
2039 * @param {Roo.bootstrap.Card} next_to_card What card position is relative to of 'false' for empty list.
2045 * When a element a card is rotate
2046 * @param {Roo.bootstrap.Card} this
2047 * @param {Roo.Element} n the node being dropped?
2048 * @param {Boolean} rotate status
2053 * When a card element is dragged over ready to drop (return false to block dropable)
2054 * @param {Roo.bootstrap.Card} this
2055 * @param {Object} data from dragdrop
2063 Roo.extend(Roo.bootstrap.Card, Roo.bootstrap.Component, {
2068 margin: '', /// may be better in component?
2098 collapsable : false,
2107 childContainer : false,
2108 dropEl : false, /// the dom placeholde element that indicates drop location.
2109 containerEl: false, // body container
2110 bodyEl: false, // card-body
2111 headerContainerEl : false, //
2113 header_imageEl : false,
2116 layoutCls : function()
2120 Roo.log(this.margin_bottom.length);
2121 ['', 'top', 'bottom', 'left', 'right', 'x', 'y' ].forEach(function(v) {
2122 // in theory these can do margin_top : ml-xs-3 ??? but we don't support that yet
2124 if (('' + t['margin' + (v.length ? '_' : '') + v]).length) {
2125 cls += ' m' + (v.length ? v[0] : '') + '-' + t['margin' + (v.length ? '_' : '') + v];
2127 if (('' + t['padding' + (v.length ? '_' : '') + v]).length) {
2128 cls += ' p' + (v.length ? v[0] : '') + '-' + t['padding' + (v.length ? '_' : '') + v];
2132 ['', 'xs', 'sm', 'lg', 'xl'].forEach(function(v) {
2133 if (('' + t['display' + (v.length ? '_' : '') + v]).length) {
2134 cls += ' d' + (v.length ? '-' : '') + v + '-' + t['display' + (v.length ? '_' : '') + v]
2138 // more generic support?
2146 // Roo.log("Call onRender: " + this.xtype);
2147 /* We are looking at something like this.
2149 <img src="..." class="card-img-top" alt="...">
2150 <div class="card-body">
2151 <h5 class="card-title">Card title</h5>
2152 <h6 class="card-subtitle mb-2 text-muted">Card subtitle</h6>
2154 >> this bit is really the body...
2155 <div> << we will ad dthis in hopefully it will not break shit.
2157 ** card text does not actually have any styling...
2159 <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>
2162 <a href="#" class="card-link">Card link</a>
2165 <div class="card-footer">
2166 <small class="text-muted">Last updated 3 mins ago</small>
2170 getAutoCreate : function(){
2178 if (this.weight.length && this.weight != 'light') {
2179 cfg.cls += ' text-white';
2181 cfg.cls += ' text-dark'; // need as it's nested..
2183 if (this.weight.length) {
2184 cfg.cls += ' bg-' + this.weight;
2187 cfg.cls += ' ' + this.layoutCls();
2190 var hdr_ctr = false;
2191 if (this.header.length) {
2193 tag : this.header_size > 0 ? 'h' + this.header_size : 'div',
2194 cls : 'card-header ' + (this.header_weight ? 'bg-' + this.header_weight : ''),
2202 cls : 'card-header d-none ' + (this.header_weight ? 'bg-' + this.header_weight : ''),
2208 if (this.collapsable) {
2211 cls : 'd-block user-select-none',
2215 cls : 'roo-collapse-toggle fa fa-chevron-down float-right ' + (this.collapsed ? 'collapsed' : '')
2220 hdr.cn.push(hdr_ctr);
2225 cls: 'roo-card-header-ctr' + ( this.header.length ? '' : ' d-none'),
2230 if (this.header_image.length) {
2233 cls : 'card-img-top',
2234 src: this.header_image // escape?
2239 cls : 'card-img-top d-none'
2245 cls : 'card-body' + (this.html === false ? ' d-none' : ''),
2249 if (this.collapsable || this.rotateable) {
2252 cls : 'roo-collapsable collapse ' + (this.collapsed || this.rotated ? '' : 'show'),
2259 if (this.title.length) {
2263 src: this.title // escape?
2267 if (this.subtitle.length) {
2271 src: this.subtitle // escape?
2277 cls : 'roo-card-body-ctr'
2280 if (this.html.length) {
2286 // fixme ? handle objects?
2288 if (this.footer.length) {
2291 cls : 'card-footer ' + (this.rotated ? 'd-none' : ''),
2296 cfg.cn.push({cls : 'card-footer d-none'});
2305 getCardHeader : function()
2307 var ret = this.el.select('.card-header',true).first();
2308 if (ret.hasClass('d-none')) {
2309 ret.removeClass('d-none');
2314 getCardFooter : function()
2316 var ret = this.el.select('.card-footer',true).first();
2317 if (ret.hasClass('d-none')) {
2318 ret.removeClass('d-none');
2323 getCardImageTop : function()
2325 var ret = this.header_imageEl;
2326 if (ret.hasClass('d-none')) {
2327 ret.removeClass('d-none');
2333 getChildContainer : function()
2339 return this.el.select('.roo-card-body-ctr',true).first();
2342 initEvents: function()
2344 this.bodyEl = this.el.select('.card-body',true).first();
2345 this.containerEl = this.getChildContainer();
2347 this.dragZone = new Roo.dd.DragZone(this.getEl(), {
2348 containerScroll: true,
2349 ddGroup: this.drag_group || 'default_card_drag_group'
2351 this.dragZone.getDragData = this.getDragData.createDelegate(this);
2353 if (this.dropable) {
2354 this.dropZone = new Roo.dd.DropZone(this.el.select('.card-body',true).first() , {
2355 containerScroll: true,
2356 ddGroup: this.drop_group || 'default_card_drag_group'
2358 this.dropZone.getTargetFromEvent = this.getTargetFromEvent.createDelegate(this);
2359 this.dropZone.onNodeEnter = this.onNodeEnter.createDelegate(this);
2360 this.dropZone.onNodeOver = this.onNodeOver.createDelegate(this);
2361 this.dropZone.onNodeOut = this.onNodeOut.createDelegate(this);
2362 this.dropZone.onNodeDrop = this.onNodeDrop.createDelegate(this);
2365 if (this.collapsable) {
2366 this.el.select('.card-header',true).on('click', this.onToggleCollapse, this);
2368 if (this.rotateable) {
2369 this.el.select('.card-header',true).on('click', this.onToggleRotate, this);
2371 this.collapsableEl = this.el.select('.roo-collapsable',true).first();
2373 this.footerEl = this.el.select('.card-footer',true).first();
2374 this.collapsableToggleEl = this.el.select('.roo-collapse-toggle',true).first();
2375 this.headerContainerEl = this.el.select('.roo-card-header-ctr',true).first();
2376 this.headerEl = this.el.select('.card-header',true).first();
2379 this.el.addClass('roo-card-rotated');
2380 this.fireEvent('rotate', this, true);
2382 this.header_imageEl = this.el.select('.card-img-top',true).first();
2383 this.header_imageEl.on('load', this.onHeaderImageLoad, this );
2386 getDragData : function(e)
2388 var target = this.getEl();
2390 //this.handleSelection(e);
2395 nodes: this.getEl(),
2400 dragData.ddel = target.dom ; // the div element
2401 Roo.log(target.getWidth( ));
2402 dragData.ddel.style.width = target.getWidth() + 'px';
2409 * Part of the Roo.dd.DropZone interface. If no target node is found, the
2410 * whole Element becomes the target, and this causes the drop gesture to append.
2412 * Returns an object:
2415 position : 'below' or 'above'
2416 card : relateive to card OBJECT (or true for no cards listed)
2417 items_n : relative to nth item in list
2418 card_n : relative to nth card in list
2423 getTargetFromEvent : function(e, dragged_card_el)
2425 var target = e.getTarget();
2426 while ((target !== null) && (target.parentNode != this.containerEl.dom)) {
2427 target = target.parentNode;
2438 //Roo.log([ 'target' , target ? target.id : '--nothing--']);
2439 // see if target is one of the 'cards'...
2442 //Roo.log(this.items.length);
2445 var last_card_n = 0;
2447 for (var i = 0;i< this.items.length;i++) {
2449 if (!this.items[i].el.hasClass('card')) {
2452 pos = this.getDropPoint(e, this.items[i].el.dom);
2454 cards_len = ret.cards.length;
2455 //Roo.log(this.items[i].el.dom.id);
2456 ret.cards.push(this.items[i]);
2458 if (ret.card_n < 0 && pos == 'above') {
2459 ret.position = cards_len > 0 ? 'below' : pos;
2460 ret.items_n = i > 0 ? i - 1 : 0;
2461 ret.card_n = cards_len > 0 ? cards_len - 1 : 0;
2462 ret.card = ret.cards[ret.card_n];
2465 if (!ret.cards.length) {
2467 ret.position = 'below';
2471 // could not find a card.. stick it at the end..
2472 if (ret.card_n < 0) {
2473 ret.card_n = last_card_n;
2474 ret.card = ret.cards[last_card_n];
2475 ret.items_n = this.items.indexOf(ret.cards[last_card_n]);
2476 ret.position = 'below';
2479 if (this.items[ret.items_n].el == dragged_card_el) {
2483 if (ret.position == 'below') {
2484 var card_after = ret.card_n+1 == ret.cards.length ? false : ret.cards[ret.card_n+1];
2486 if (card_after && card_after.el == dragged_card_el) {
2493 var card_before = ret.card_n > 0 ? ret.cards[ret.card_n-1] : false;
2495 if (card_before && card_before.el == dragged_card_el) {
2502 onNodeEnter : function(n, dd, e, data){
2505 onNodeOver : function(n, dd, e, data)
2508 var target_info = this.getTargetFromEvent(e,data.source.el);
2509 if (target_info === false) {
2510 this.dropPlaceHolder('hide');
2513 Roo.log(['getTargetFromEvent', target_info ]);
2516 if (this.fireEvent('cardover', this, [ data ]) === false) {
2520 this.dropPlaceHolder('show', target_info,data);
2524 onNodeOut : function(n, dd, e, data){
2525 this.dropPlaceHolder('hide');
2528 onNodeDrop : function(n, dd, e, data)
2531 // call drop - return false if
2533 // this could actually fail - if the Network drops..
2534 // we will ignore this at present..- client should probably reload
2535 // the whole set of cards if stuff like that fails.
2538 var info = this.getTargetFromEvent(e,data.source.el);
2539 if (info === false) {
2542 this.dropPlaceHolder('hide');
2546 this.acceptCard(data.source, info.position, info.card, info.items_n);
2550 firstChildCard : function()
2552 for (var i = 0;i< this.items.length;i++) {
2554 if (!this.items[i].el.hasClass('card')) {
2557 return this.items[i];
2559 return this.items.length ? this.items[this.items.length-1] : false; // don't try and put stuff after the cards...
2564 * - card.acceptCard(move_card, info.position, info.card, info.items_n);
2566 acceptCard : function(move_card, position, next_to_card )
2568 if (this.fireEvent("drop", this, move_card, position, next_to_card) === false) {
2572 var to_items_n = next_to_card ? this.items.indexOf(next_to_card) : 0;
2574 move_card.parent().removeCard(move_card);
2577 var dom = move_card.el.dom;
2578 dom.style.width = ''; // clear with - which is set by drag.
2580 if (next_to_card !== false && next_to_card !== true && next_to_card.el.dom.parentNode) {
2581 var cardel = next_to_card.el.dom;
2583 if (position == 'above' ) {
2584 cardel.parentNode.insertBefore(dom, cardel);
2585 } else if (cardel.nextSibling) {
2586 cardel.parentNode.insertBefore(dom,cardel.nextSibling);
2588 cardel.parentNode.append(dom);
2591 // card container???
2592 this.containerEl.dom.append(dom);
2595 //FIXME HANDLE card = true
2597 // add this to the correct place in items.
2599 // remove Card from items.
2602 if (this.items.length) {
2604 //Roo.log([info.items_n, info.position, this.items.length]);
2605 for (var i =0; i < this.items.length; i++) {
2606 if (i == to_items_n && position == 'above') {
2607 nitems.push(move_card);
2609 nitems.push(this.items[i]);
2610 if (i == to_items_n && position == 'below') {
2611 nitems.push(move_card);
2614 this.items = nitems;
2615 Roo.log(this.items);
2617 this.items.push(move_card);
2620 move_card.parentId = this.id;
2626 removeCard : function(c)
2628 this.items = this.items.filter(function(e) { return e != c });
2631 dom.parentNode.removeChild(dom);
2632 dom.style.width = ''; // clear with - which is set by drag.
2637 /** Decide whether to drop above or below a View node. */
2638 getDropPoint : function(e, n, dd)
2643 if (n == this.containerEl.dom) {
2646 var t = Roo.lib.Dom.getY(n), b = t + n.offsetHeight;
2647 var c = t + (b - t) / 2;
2648 var y = Roo.lib.Event.getPageY(e);
2655 onToggleCollapse : function(e)
2657 if (this.collapsed) {
2658 this.el.select('.roo-collapse-toggle').removeClass('collapsed');
2659 this.collapsableEl.addClass('show');
2660 this.collapsed = false;
2663 this.el.select('.roo-collapse-toggle').addClass('collapsed');
2664 this.collapsableEl.removeClass('show');
2665 this.collapsed = true;
2670 onToggleRotate : function(e)
2672 this.collapsableEl.removeClass('show');
2673 this.footerEl.removeClass('d-none');
2674 this.el.removeClass('roo-card-rotated');
2675 this.el.removeClass('d-none');
2678 this.collapsableEl.addClass('show');
2679 this.rotated = false;
2680 this.fireEvent('rotate', this, this.rotated);
2683 this.el.addClass('roo-card-rotated');
2684 this.footerEl.addClass('d-none');
2685 this.el.select('.roo-collapsable').removeClass('show');
2687 this.rotated = true;
2688 this.fireEvent('rotate', this, this.rotated);
2692 dropPlaceHolder: function (action, info, data)
2694 if (this.dropEl === false) {
2695 this.dropEl = Roo.DomHelper.append(this.containerEl, {
2699 this.dropEl.removeClass(['d-none', 'd-block']);
2700 if (action == 'hide') {
2702 this.dropEl.addClass('d-none');
2705 // FIXME - info.card == true!!!
2706 this.dropEl.dom.parentNode.removeChild(this.dropEl.dom);
2708 if (info.card !== true) {
2709 var cardel = info.card.el.dom;
2711 if (info.position == 'above') {
2712 cardel.parentNode.insertBefore(this.dropEl.dom, cardel);
2713 } else if (cardel.nextSibling) {
2714 cardel.parentNode.insertBefore(this.dropEl.dom,cardel.nextSibling);
2716 cardel.parentNode.append(this.dropEl.dom);
2719 // card container???
2720 this.containerEl.dom.append(this.dropEl.dom);
2723 this.dropEl.addClass('d-block roo-card-dropzone');
2725 this.dropEl.setHeight( Roo.get(data.ddel).getHeight() );
2732 setHeaderText: function(html)
2735 if (this.headerContainerEl) {
2736 this.headerContainerEl.dom.innerHTML = html;
2739 onHeaderImageLoad : function(ev, he)
2741 if (!this.header_image_fit_square) {
2745 var hw = he.naturalHeight / he.naturalWidth;
2748 //var w = he.dom.naturalWidth;
2751 he.style.position = 'relative';
2753 var nw = (ww * (1/hw));
2754 Roo.get(he).setSize( ww * (1/hw), ww);
2755 he.style.left = ((ww - nw)/ 2) + 'px';
2756 he.style.position = 'relative';
2767 * Card header - holder for the card header elements.
2772 * @class Roo.bootstrap.CardHeader
2773 * @extends Roo.bootstrap.Element
2774 * Bootstrap CardHeader class
2776 * Create a new Card Header - that you can embed children into
2777 * @param {Object} config The config object
2780 Roo.bootstrap.CardHeader = function(config){
2781 Roo.bootstrap.CardHeader.superclass.constructor.call(this, config);
2784 Roo.extend(Roo.bootstrap.CardHeader, Roo.bootstrap.Element, {
2787 container_method : 'getCardHeader'
2800 * Card footer - holder for the card footer elements.
2805 * @class Roo.bootstrap.CardFooter
2806 * @extends Roo.bootstrap.Element
2807 * Bootstrap CardFooter class
2809 * Create a new Card Footer - that you can embed children into
2810 * @param {Object} config The config object
2813 Roo.bootstrap.CardFooter = function(config){
2814 Roo.bootstrap.CardFooter.superclass.constructor.call(this, config);
2817 Roo.extend(Roo.bootstrap.CardFooter, Roo.bootstrap.Element, {
2820 container_method : 'getCardFooter'
2833 * Card header - holder for the card header elements.
2838 * @class Roo.bootstrap.CardImageTop
2839 * @extends Roo.bootstrap.Element
2840 * Bootstrap CardImageTop class
2842 * Create a new Card Image Top container
2843 * @param {Object} config The config object
2846 Roo.bootstrap.CardImageTop = function(config){
2847 Roo.bootstrap.CardImageTop.superclass.constructor.call(this, config);
2850 Roo.extend(Roo.bootstrap.CardImageTop, Roo.bootstrap.Element, {
2853 container_method : 'getCardImageTop'
2868 * @class Roo.bootstrap.ButtonUploader
2869 * @extends Roo.bootstrap.Button
2870 * Bootstrap Button Uploader class - it's a button which when you add files to it
2873 * @cfg {Number} errorTimeout default 3000
2874 * @cfg {Array} images an array of ?? Img objects ??? when loading existing files..
2875 * @cfg {Array} html The button text.
2876 * @cfg {Boolean} multiple (default true) Should the upload allow multiple files to be uploaded.
2879 * Create a new CardUploader
2880 * @param {Object} config The config object
2883 Roo.bootstrap.ButtonUploader = function(config){
2887 Roo.bootstrap.ButtonUploader.superclass.constructor.call(this, config);
2893 * @event beforeselect
2894 * When button is pressed, before show upload files dialog is shown
2895 * @param {Roo.bootstrap.UploaderButton} this
2898 'beforeselect' : true,
2900 * @event fired when files have been selected,
2901 * When a the download link is clicked
2902 * @param {Roo.bootstrap.UploaderButton} this
2903 * @param {Array} Array of files that have been uploaded
2910 Roo.extend(Roo.bootstrap.ButtonUploader, Roo.bootstrap.Button, {
2913 errorTimeout : 3000,
2917 fileCollection : false,
2922 getAutoCreate : function()
2927 cls : 'd-none roo-card-upload-selector'
2930 if (this.multiple) {
2931 im.multiple = 'multiple';
2937 Roo.bootstrap.Button.prototype.getAutoCreate.call(this),
2947 initEvents : function()
2950 Roo.bootstrap.Button.prototype.initEvents.call(this);
2956 this.urlAPI = (window.createObjectURL && window) ||
2957 (window.URL && URL.revokeObjectURL && URL) ||
2958 (window.webkitURL && webkitURL);
2963 this.selectorEl = this.el.select('.roo-card-upload-selector', true).first();
2965 this.selectorEl.on('change', this.onFileSelected, this);
2972 onClick : function(e)
2976 if ( this.fireEvent('beforeselect', this) === false) {
2980 this.selectorEl.dom.click();
2984 onFileSelected : function(e)
2988 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
2991 var files = Array.prototype.slice.call(this.selectorEl.dom.files);
2992 this.selectorEl.dom.value = '';// hopefully reset..
2994 this.fireEvent('uploaded', this, files );
3002 * addCard - add an Attachment to the uploader
3003 * @param data - the data about the image to upload
3007 title : "Title of file",
3008 is_uploaded : false,
3009 src : "http://.....",
3010 srcfile : { the File upload object },
3011 mimetype : file.type,
3014 .. any other data...
3039 * @class Roo.bootstrap.Img
3040 * @extends Roo.bootstrap.Component
3041 * Bootstrap Img class
3042 * @cfg {Boolean} imgResponsive false | true
3043 * @cfg {String} border rounded | circle | thumbnail
3044 * @cfg {String} src image source
3045 * @cfg {String} alt image alternative text
3046 * @cfg {String} href a tag href
3047 * @cfg {String} target (_self|_blank|_parent|_top)target for a href.
3048 * @cfg {String} xsUrl xs image source
3049 * @cfg {String} smUrl sm image source
3050 * @cfg {String} mdUrl md image source
3051 * @cfg {String} lgUrl lg image source
3052 * @cfg {Boolean} backgroundContain (use style background and contain image in content)
3055 * Create a new Input
3056 * @param {Object} config The config object
3059 Roo.bootstrap.Img = function(config){
3060 Roo.bootstrap.Img.superclass.constructor.call(this, config);
3066 * The img click event for the img.
3067 * @param {Roo.EventObject} e
3072 * The when any image loads
3073 * @param {Roo.EventObject} e
3079 Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, {
3081 imgResponsive: true,
3090 backgroundContain : false,
3092 getAutoCreate : function()
3094 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
3095 return this.createSingleImg();
3100 cls: 'roo-image-responsive-group',
3105 Roo.each(['xs', 'sm', 'md', 'lg'], function(size){
3107 if(!_this[size + 'Url']){
3113 cls: (_this.imgResponsive) ? 'img-responsive' : '',
3114 html: _this.html || cfg.html,
3115 src: _this[size + 'Url']
3118 img.cls += ' roo-image-responsive-' + size;
3120 var s = ['xs', 'sm', 'md', 'lg'];
3122 s.splice(s.indexOf(size), 1);
3124 Roo.each(s, function(ss){
3125 img.cls += ' hidden-' + ss;
3128 if (['rounded','circle','thumbnail'].indexOf(_this.border)>-1) {
3129 cfg.cls += ' img-' + _this.border;
3133 cfg.alt = _this.alt;
3146 a.target = _this.target;
3150 cfg.cn.push((_this.href) ? a : img);
3157 createSingleImg : function()
3161 cls: (this.imgResponsive) ? 'img-responsive' : '',
3163 src : Roo.BLANK_IMAGE_URL // just incase src get's set to undefined?!?
3166 if (this.backgroundContain) {
3167 cfg.cls += ' background-contain';
3170 cfg.html = this.html || cfg.html;
3172 if (this.backgroundContain) {
3173 cfg.style="background-image: url(" + this.src + ')';
3175 cfg.src = this.src || cfg.src;
3178 if (['rounded','circle','thumbnail'].indexOf(this.border)>-1) {
3179 cfg.cls += ' img-' + this.border;
3196 a.target = this.target;
3201 return (this.href) ? a : cfg;
3204 initEvents: function()
3207 this.el.on('click', this.onClick, this);
3209 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
3210 this.el.on('load', this.onImageLoad, this);
3212 // not sure if this works.. not tested
3213 this.el.select('img', true).on('load', this.onImageLoad, this);
3218 onClick : function(e)
3220 Roo.log('img onclick');
3221 this.fireEvent('click', this, e);
3223 onImageLoad: function(e)
3225 Roo.log('img load');
3226 this.fireEvent('load', this, e);
3230 * Sets the url of the image - used to update it
3231 * @param {String} url the url of the image
3234 setSrc : function(url)
3238 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
3239 if (this.backgroundContain) {
3240 this.el.dom.style.backgroundImage = 'url(' + url + ')';
3242 this.el.dom.src = url;
3247 this.el.select('img', true).first().dom.src = url;
3263 * @class Roo.bootstrap.Link
3264 * @extends Roo.bootstrap.Component
3265 * Bootstrap Link Class
3266 * @cfg {String} alt image alternative text
3267 * @cfg {String} href a tag href
3268 * @cfg {String} target (_self|_blank|_parent|_top) target for a href.
3269 * @cfg {String} html the content of the link.
3270 * @cfg {String} anchor name for the anchor link
3271 * @cfg {String} fa - favicon
3273 * @cfg {Boolean} preventDefault (true | false) default false
3277 * Create a new Input
3278 * @param {Object} config The config object
3281 Roo.bootstrap.Link = function(config){
3282 Roo.bootstrap.Link.superclass.constructor.call(this, config);
3288 * The img click event for the img.
3289 * @param {Roo.EventObject} e
3295 Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component, {
3299 preventDefault: false,
3305 getAutoCreate : function()
3307 var html = this.html || '';
3309 if (this.fa !== false) {
3310 html = '<i class="fa fa-' + this.fa + '"></i>';
3315 // anchor's do not require html/href...
3316 if (this.anchor === false) {
3318 cfg.href = this.href || '#';
3320 cfg.name = this.anchor;
3321 if (this.html !== false || this.fa !== false) {
3324 if (this.href !== false) {
3325 cfg.href = this.href;
3329 if(this.alt !== false){
3334 if(this.target !== false) {
3335 cfg.target = this.target;
3341 initEvents: function() {
3343 if(!this.href || this.preventDefault){
3344 this.el.on('click', this.onClick, this);
3348 onClick : function(e)
3350 if(this.preventDefault){
3353 //Roo.log('img onclick');
3354 this.fireEvent('click', this, e);
3367 * @class Roo.bootstrap.Header
3368 * @extends Roo.bootstrap.Component
3369 * Bootstrap Header class
3370 * @cfg {String} html content of header
3371 * @cfg {Number} level (1|2|3|4|5|6) default 1
3374 * Create a new Header
3375 * @param {Object} config The config object
3379 Roo.bootstrap.Header = function(config){
3380 Roo.bootstrap.Header.superclass.constructor.call(this, config);
3383 Roo.extend(Roo.bootstrap.Header, Roo.bootstrap.Component, {
3391 getAutoCreate : function(){
3396 tag: 'h' + (1 *this.level),
3397 html: this.html || ''
3409 * Ext JS Library 1.1.1
3410 * Copyright(c) 2006-2007, Ext JS, LLC.
3412 * Originally Released Under LGPL - original licence link has changed is not relivant.
3415 * <script type="text/javascript">
3419 * @class Roo.bootstrap.MenuMgr
3420 * Provides a common registry of all menu items on a page so that they can be easily accessed by id.
3423 Roo.bootstrap.MenuMgr = function(){
3424 var menus, active, groups = {}, attached = false, lastShow = new Date();
3426 // private - called when first menu is created
3429 active = new Roo.util.MixedCollection();
3430 Roo.get(document).addKeyListener(27, function(){
3431 if(active.length > 0){
3439 if(active && active.length > 0){
3440 var c = active.clone();
3450 if(active.length < 1){
3451 Roo.get(document).un("mouseup", onMouseDown);
3459 var last = active.last();
3460 lastShow = new Date();
3463 Roo.get(document).on("mouseup", onMouseDown);
3468 //m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
3469 m.parentMenu.activeChild = m;
3470 }else if(last && last.isVisible()){
3471 //m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
3476 function onBeforeHide(m){
3478 m.activeChild.hide();
3480 if(m.autoHideTimer){
3481 clearTimeout(m.autoHideTimer);
3482 delete m.autoHideTimer;
3487 function onBeforeShow(m){
3488 var pm = m.parentMenu;
3489 if(!pm && !m.allowOtherMenus){
3491 }else if(pm && pm.activeChild && active != m){
3492 pm.activeChild.hide();
3496 // private this should really trigger on mouseup..
3497 function onMouseDown(e){
3498 Roo.log("on Mouse Up");
3500 if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".dropdown-menu") && !e.getTarget('.user-menu')){
3501 Roo.log("MenuManager hideAll");
3510 function onBeforeCheck(mi, state){
3512 var g = groups[mi.group];
3513 for(var i = 0, l = g.length; i < l; i++){
3515 g[i].setChecked(false);
3524 * Hides all menus that are currently visible
3526 hideAll : function(){
3531 register : function(menu){
3535 menus[menu.id] = menu;
3536 menu.on("beforehide", onBeforeHide);
3537 menu.on("hide", onHide);
3538 menu.on("beforeshow", onBeforeShow);
3539 menu.on("show", onShow);
3541 if(g && menu.events["checkchange"]){
3545 groups[g].push(menu);
3546 menu.on("checkchange", onCheck);
3551 * Returns a {@link Roo.menu.Menu} object
3552 * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will
3553 * be used to generate and return a new Menu instance.
3555 get : function(menu){
3556 if(typeof menu == "string"){ // menu id
3558 }else if(menu.events){ // menu instance
3561 /*else if(typeof menu.length == 'number'){ // array of menu items?
3562 return new Roo.bootstrap.Menu({items:menu});
3563 }else{ // otherwise, must be a config
3564 return new Roo.bootstrap.Menu(menu);
3571 unregister : function(menu){
3572 delete menus[menu.id];
3573 menu.un("beforehide", onBeforeHide);
3574 menu.un("hide", onHide);
3575 menu.un("beforeshow", onBeforeShow);
3576 menu.un("show", onShow);
3578 if(g && menu.events["checkchange"]){
3579 groups[g].remove(menu);
3580 menu.un("checkchange", onCheck);
3585 registerCheckable : function(menuItem){
3586 var g = menuItem.group;
3591 groups[g].push(menuItem);
3592 menuItem.on("beforecheckchange", onBeforeCheck);
3597 unregisterCheckable : function(menuItem){
3598 var g = menuItem.group;
3600 groups[g].remove(menuItem);
3601 menuItem.un("beforecheckchange", onBeforeCheck);
3613 * @class Roo.bootstrap.Menu
3614 * @extends Roo.bootstrap.Component
3615 * Bootstrap Menu class - container for MenuItems
3616 * @cfg {String} type (dropdown|treeview|submenu) type of menu
3617 * @cfg {bool} hidden if the menu should be hidden when rendered.
3618 * @cfg {bool} stopEvent (true|false) Stop event after trigger press (default true)
3619 * @cfg {bool} isLink (true|false) the menu has link disable auto expand and collaspe (default false)
3620 * @cfg {bool} hideTrigger (true|false) default false - hide the carret for trigger.
3621 * @cfg {String} align default tl-bl? == below - how the menu should be aligned.
3625 * @param {Object} config The config object
3629 Roo.bootstrap.Menu = function(config){
3631 if (config.type == 'treeview') {
3632 // normally menu's are drawn attached to the document to handle layering etc..
3633 // however treeview (used by the docs menu is drawn into the parent element)
3634 this.container_method = 'getChildContainer';
3637 Roo.bootstrap.Menu.superclass.constructor.call(this, config);
3638 if (this.registerMenu && this.type != 'treeview') {
3639 Roo.bootstrap.MenuMgr.register(this);
3646 * Fires before this menu is displayed (return false to block)
3647 * @param {Roo.menu.Menu} this
3652 * Fires before this menu is hidden (return false to block)
3653 * @param {Roo.menu.Menu} this
3658 * Fires after this menu is displayed
3659 * @param {Roo.menu.Menu} this
3664 * Fires after this menu is hidden
3665 * @param {Roo.menu.Menu} this
3670 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
3671 * @param {Roo.menu.Menu} this
3672 * @param {Roo.menu.Item} menuItem The menu item that was clicked
3673 * @param {Roo.EventObject} e
3678 * Fires when the mouse is hovering over this menu
3679 * @param {Roo.menu.Menu} this
3680 * @param {Roo.EventObject} e
3681 * @param {Roo.menu.Item} menuItem The menu item that was clicked
3686 * Fires when the mouse exits this menu
3687 * @param {Roo.menu.Menu} this
3688 * @param {Roo.EventObject} e
3689 * @param {Roo.menu.Item} menuItem The menu item that was clicked
3694 * Fires when a menu item contained in this menu is clicked
3695 * @param {Roo.menu.BaseItem} baseItem The BaseItem that was clicked
3696 * @param {Roo.EventObject} e
3700 this.menuitems = new Roo.util.MixedCollection(false, function(o) { return o.el.id; });
3703 Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, {
3707 triggerEl : false, // is this set by component builder? -- it should really be fetched from parent()???
3710 * @cfg {Boolean} registerMenu True (default) - means that clicking on screen etc. hides it.
3712 registerMenu : true,
3714 menuItems :false, // stores the menu items..
3724 container_method : 'getDocumentBody', // so the menu is rendered on the body and zIndex works.
3726 hideTrigger : false,
3731 getChildContainer : function() {
3735 getAutoCreate : function(){
3737 //if (['right'].indexOf(this.align)!==-1) {
3738 // cfg.cn[1].cls += ' pull-right'
3743 cls : 'dropdown-menu shadow' ,
3744 style : 'z-index:1000'
3748 if (this.type === 'submenu') {
3749 cfg.cls = 'submenu active';
3751 if (this.type === 'treeview') {
3752 cfg.cls = 'treeview-menu';
3757 initEvents : function() {
3759 // Roo.log("ADD event");
3760 // Roo.log(this.triggerEl.dom);
3761 if (this.triggerEl) {
3763 this.triggerEl.on('click', this.onTriggerClick, this);
3765 this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this);
3767 if (!this.hideTrigger) {
3768 if (this.triggerEl.hasClass('nav-item') && this.triggerEl.select('.nav-link',true).length) {
3769 // dropdown toggle on the 'a' in BS4?
3770 this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle');
3772 this.triggerEl.addClass('dropdown-toggle');
3778 this.el.on('touchstart' , this.onTouch, this);
3780 this.el.on('click' , this.onClick, this);
3782 this.el.on("mouseover", this.onMouseOver, this);
3783 this.el.on("mouseout", this.onMouseOut, this);
3787 findTargetItem : function(e)
3789 var t = e.getTarget(".dropdown-menu-item", this.el, true);
3793 //Roo.log(t); Roo.log(t.id);
3795 //Roo.log(this.menuitems);
3796 return this.menuitems.get(t.id);
3798 //return this.items.get(t.menuItemId);
3804 onTouch : function(e)
3806 Roo.log("menu.onTouch");
3807 //e.stopEvent(); this make the user popdown broken
3811 onClick : function(e)
3813 Roo.log("menu.onClick");
3815 var t = this.findTargetItem(e);
3816 if(!t || t.isContainer){
3821 if (Roo.isTouch && e.type == 'touchstart' && t.menu && !t.disabled) {
3822 if(t == this.activeItem && t.shouldDeactivate(e)){
3823 this.activeItem.deactivate();
3824 delete this.activeItem;
3828 this.setActiveItem(t, true);
3836 Roo.log('pass click event');
3840 this.fireEvent("click", this, t, e);
3844 if(!t.href.length || t.href == '#'){
3845 (function() { _this.hide(); }).defer(100);
3850 onMouseOver : function(e){
3851 var t = this.findTargetItem(e);
3854 // if(t.canActivate && !t.disabled){
3855 // this.setActiveItem(t, true);
3859 this.fireEvent("mouseover", this, e, t);
3861 isVisible : function(){
3862 return !this.hidden;
3864 onMouseOut : function(e){
3865 var t = this.findTargetItem(e);
3868 // if(t == this.activeItem && t.shouldDeactivate(e)){
3869 // this.activeItem.deactivate();
3870 // delete this.activeItem;
3873 this.fireEvent("mouseout", this, e, t);
3878 * Displays this menu relative to another element
3879 * @param {String/HTMLElement/Roo.Element} element The element to align to
3880 * @param {String} position (optional) The {@link Roo.Element#alignTo} anchor position to use in aligning to
3881 * the element (defaults to this.defaultAlign)
3882 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
3884 show : function(el, pos, parentMenu)
3886 if (false === this.fireEvent("beforeshow", this)) {
3887 Roo.log("show canceled");
3890 this.parentMenu = parentMenu;
3894 this.el.addClass('show'); // show otherwise we do not know how big we are..
3896 var xy = this.el.getAlignToXY(el, pos);
3898 // bl-tl << left align below
3899 // tl-bl << left align
3901 if(this.el.getWidth() + xy[0] >= Roo.lib.Dom.getViewWidth()){
3902 // if it goes to far to the right.. -> align left.
3903 xy = this.el.getAlignToXY(el, this.align.replace('/l/g', 'r'))
3906 // was left align - go right?
3907 xy = this.el.getAlignToXY(el, this.align.replace('/r/g', 'l'))
3910 // goes down the bottom
3911 if(this.el.getHeight() + xy[1] >= Roo.lib.Dom.getViewHeight() ||
3913 var a = this.align.replace('?', '').split('-');
3914 xy = this.el.getAlignToXY(el, a[1] + '-' + a[0] + '?')
3918 this.showAt( xy , parentMenu, false);
3921 * Displays this menu at a specific xy position
3922 * @param {Array} xyPosition Contains X & Y [x, y] values for the position at which to show the menu (coordinates are page-based)
3923 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
3925 showAt : function(xy, parentMenu, /* private: */_e){
3926 this.parentMenu = parentMenu;
3931 this.fireEvent("beforeshow", this);
3932 //xy = this.el.adjustForConstraints(xy);
3936 this.hideMenuItems();
3937 this.hidden = false;
3938 if (this.triggerEl) {
3939 this.triggerEl.addClass('open');
3942 this.el.addClass('show');
3946 // reassign x when hitting right
3948 // reassign y when hitting bottom
3950 // but the list may align on trigger left or trigger top... should it be a properity?
3952 if(this.el.getStyle('top') != 'auto' && this.el.getStyle('top').slice(-1) != "%"){
3957 this.fireEvent("show", this);
3963 this.doFocus.defer(50, this);
3967 doFocus : function(){
3969 this.focusEl.focus();
3974 * Hides this menu and optionally all parent menus
3975 * @param {Boolean} deep (optional) True to hide all parent menus recursively, if any (defaults to false)
3977 hide : function(deep)
3979 if (false === this.fireEvent("beforehide", this)) {
3980 Roo.log("hide canceled");
3983 this.hideMenuItems();
3984 if(this.el && this.isVisible()){
3986 if(this.activeItem){
3987 this.activeItem.deactivate();
3988 this.activeItem = null;
3990 if (this.triggerEl) {
3991 this.triggerEl.removeClass('open');
3994 this.el.removeClass('show');
3996 this.fireEvent("hide", this);
3998 if(deep === true && this.parentMenu){
3999 this.parentMenu.hide(true);
4003 onTriggerClick : function(e)
4005 Roo.log('trigger click');
4007 var target = e.getTarget();
4009 Roo.log(target.nodeName.toLowerCase());
4011 if(target.nodeName.toLowerCase() === 'i'){
4017 onTriggerPress : function(e)
4019 Roo.log('trigger press');
4020 //Roo.log(e.getTarget());
4021 // Roo.log(this.triggerEl.dom);
4023 // trigger only occurs on normal menu's -- if it's a treeview or dropdown... do not hide/show..
4024 var pel = Roo.get(e.getTarget());
4025 if (pel.findParent('.dropdown-menu') || pel.findParent('.treeview-menu') ) {
4026 Roo.log('is treeview or dropdown?');
4030 if(e.getTarget().nodeName.toLowerCase() !== 'i' && this.isLink){
4034 if (this.isVisible()) {
4040 this.show(this.triggerEl, this.align, false);
4043 if(this.stopEvent || e.getTarget().nodeName.toLowerCase() === 'i'){
4050 hideMenuItems : function()
4052 Roo.log("hide Menu Items");
4057 this.el.select('.open',true).each(function(aa) {
4059 aa.removeClass('open');
4063 addxtypeChild : function (tree, cntr) {
4064 var comp= Roo.bootstrap.Menu.superclass.addxtypeChild.call(this, tree, cntr);
4066 this.menuitems.add(comp);
4078 this.getEl().dom.innerHTML = '';
4079 this.menuitems.clear();
4093 * @class Roo.bootstrap.MenuItem
4094 * @extends Roo.bootstrap.Component
4095 * Bootstrap MenuItem class
4096 * @cfg {String} html the menu label
4097 * @cfg {String} href the link
4098 * @cfg {Boolean} preventDefault do not trigger A href on clicks (default false).
4099 * @cfg {Boolean} isContainer is it a container - just returns a drop down item..
4100 * @cfg {Boolean} active used on sidebars to highlight active itesm
4101 * @cfg {String} fa favicon to show on left of menu item.
4102 * @cfg {Roo.bootsrap.Menu} menu the child menu.
4106 * Create a new MenuItem
4107 * @param {Object} config The config object
4111 Roo.bootstrap.MenuItem = function(config){
4112 Roo.bootstrap.MenuItem.superclass.constructor.call(this, config);
4117 * The raw click event for the entire grid.
4118 * @param {Roo.bootstrap.MenuItem} this
4119 * @param {Roo.EventObject} e
4125 Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component, {
4129 preventDefault: false,
4130 isContainer : false,
4134 getAutoCreate : function(){
4136 if(this.isContainer){
4139 cls: 'dropdown-menu-item '
4149 cls : 'dropdown-item',
4154 if (this.fa !== false) {
4157 cls : 'fa fa-' + this.fa
4166 cls: 'dropdown-menu-item',
4169 if (this.parent().type == 'treeview') {
4170 cfg.cls = 'treeview-menu';
4173 cfg.cls += ' active';
4178 anc.href = this.href || cfg.cn[0].href ;
4179 ctag.html = this.html || cfg.cn[0].html ;
4183 initEvents: function()
4185 if (this.parent().type == 'treeview') {
4186 this.el.select('a').on('click', this.onClick, this);
4190 this.menu.parentType = this.xtype;
4191 this.menu.triggerEl = this.el;
4192 this.menu = this.addxtype(Roo.apply({}, this.menu));
4196 onClick : function(e)
4198 Roo.log('item on click ');
4200 if(this.preventDefault){
4203 //this.parent().hideMenuItems();
4205 this.fireEvent('click', this, e);
4224 * @class Roo.bootstrap.MenuSeparator
4225 * @extends Roo.bootstrap.Component
4226 * Bootstrap MenuSeparator class
4229 * Create a new MenuItem
4230 * @param {Object} config The config object
4234 Roo.bootstrap.MenuSeparator = function(config){
4235 Roo.bootstrap.MenuSeparator.superclass.constructor.call(this, config);
4238 Roo.extend(Roo.bootstrap.MenuSeparator, Roo.bootstrap.Component, {
4240 getAutoCreate : function(){
4259 * @class Roo.bootstrap.Modal
4260 * @extends Roo.bootstrap.Component
4263 * Bootstrap Modal class
4264 * @cfg {String} title Title of dialog
4265 * @cfg {String} html - the body of the dialog (for simple ones) - you can also use template..
4266 * @cfg {Roo.Template} tmpl - a template with variables. to use it, add a handler in show:method adn
4267 * @cfg {Boolean} specificTitle default false
4268 * @cfg {Array} buttons Array of buttons or standard button set..
4269 * @cfg {String} buttonPosition (left|right|center) default right (DEPRICATED) - use mr-auto on buttons to put them on the left
4270 * @cfg {Boolean} animate default true
4271 * @cfg {Boolean} allow_close default true
4272 * @cfg {Boolean} fitwindow default false
4273 * @cfg {Boolean} bodyOverflow should the body element have overflow auto added default false
4274 * @cfg {Number} width fixed width - usefull for chrome extension only really.
4275 * @cfg {Number} height fixed height - usefull for chrome extension only really.
4276 * @cfg {String} size (sm|lg|xl) default empty
4277 * @cfg {Number} max_width set the max width of modal
4278 * @cfg {Boolean} editableTitle can the title be edited
4283 * Create a new Modal Dialog
4284 * @param {Object} config The config object
4287 Roo.bootstrap.Modal = function(config){
4288 Roo.bootstrap.Modal.superclass.constructor.call(this, config);
4293 * The raw btnclick event for the button
4294 * @param {Roo.EventObject} e
4299 * Fire when dialog resize
4300 * @param {Roo.bootstrap.Modal} this
4301 * @param {Roo.EventObject} e
4305 * @event titlechanged
4306 * Fire when the editable title has been changed
4307 * @param {Roo.bootstrap.Modal} this
4308 * @param {Roo.EventObject} value
4310 "titlechanged" : true
4313 this.buttons = this.buttons || [];
4316 this.tmpl = Roo.factory(this.tmpl);
4321 Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, {
4323 title : 'test dialog',
4333 specificTitle: false,
4335 buttonPosition: 'right',
4357 editableTitle : false,
4359 onRender : function(ct, position)
4361 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
4364 var cfg = Roo.apply({}, this.getAutoCreate());
4367 // cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
4369 //if (!cfg.name.length) {
4373 cfg.cls += ' ' + this.cls;
4376 cfg.style = this.style;
4378 this.el = Roo.get(document.body).createChild(cfg, position);
4380 //var type = this.el.dom.type;
4383 if(this.tabIndex !== undefined){
4384 this.el.dom.setAttribute('tabIndex', this.tabIndex);
4387 this.dialogEl = this.el.select('.modal-dialog',true).first();
4388 this.bodyEl = this.el.select('.modal-body',true).first();
4389 this.closeEl = this.el.select('.modal-header .close', true).first();
4390 this.headerEl = this.el.select('.modal-header',true).first();
4391 this.titleEl = this.el.select('.modal-title',true).first();
4392 this.footerEl = this.el.select('.modal-footer',true).first();
4394 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
4396 //this.el.addClass("x-dlg-modal");
4398 if (this.buttons.length) {
4399 Roo.each(this.buttons, function(bb) {
4400 var b = Roo.apply({}, bb);
4401 b.xns = b.xns || Roo.bootstrap;
4402 b.xtype = b.xtype || 'Button';
4403 if (typeof(b.listeners) == 'undefined') {
4404 b.listeners = { click : this.onButtonClick.createDelegate(this) };
4407 var btn = Roo.factory(b);
4409 btn.render(this.getButtonContainer());
4413 // render the children.
4416 if(typeof(this.items) != 'undefined'){
4417 var items = this.items;
4420 for(var i =0;i < items.length;i++) {
4421 nitems.push(this.addxtype(Roo.apply({}, items[i])));
4425 this.items = nitems;
4427 // where are these used - they used to be body/close/footer
4431 //this.el.addClass([this.fieldClass, this.cls]);
4435 getAutoCreate : function()
4437 // we will default to modal-body-overflow - might need to remove or make optional later.
4439 cls : 'modal-body ' + (this.bodyOverflow ? 'overflow-auto' : ''),
4440 html : this.html || ''
4445 cls : 'modal-title',
4449 if(this.specificTitle){ // WTF is this?
4454 if (this.allow_close && Roo.bootstrap.version == 3) {
4464 if (this.editableTitle) {
4466 cls: 'form-control roo-editable-title d-none',
4472 if (this.allow_close && Roo.bootstrap.version == 4) {
4482 if(this.size.length){
4483 size = 'modal-' + this.size;
4486 var footer = Roo.bootstrap.version == 3 ?
4488 cls : 'modal-footer',
4492 cls: 'btn-' + this.buttonPosition
4497 { // BS4 uses mr-auto on left buttons....
4498 cls : 'modal-footer'
4509 cls: "modal-dialog " + size,
4512 cls : "modal-content",
4515 cls : 'modal-header',
4530 modal.cls += ' fade';
4536 getChildContainer : function() {
4541 getButtonContainer : function() {
4543 return Roo.bootstrap.version == 4 ?
4544 this.el.select('.modal-footer',true).first()
4545 : this.el.select('.modal-footer div',true).first();
4548 initEvents : function()
4550 if (this.allow_close) {
4551 this.closeEl.on('click', this.hide, this);
4553 Roo.EventManager.onWindowResize(this.resize, this, true);
4554 if (this.editableTitle) {
4555 this.headerEditEl = this.headerEl.select('.form-control',true).first();
4556 this.headerEl.on('click', function() { this.toggleHeaderInput(true) } , this);
4557 this.headerEditEl.on('keyup', function(e) {
4558 if([ e.RETURN , e.TAB , e.ESC ].indexOf(e.keyCode) > -1) {
4559 this.toggleHeaderInput(false)
4562 this.headerEditEl.on('blur', function(e) {
4563 this.toggleHeaderInput(false)
4572 this.maskEl.setSize(
4573 Roo.lib.Dom.getViewWidth(true),
4574 Roo.lib.Dom.getViewHeight(true)
4577 if (this.fitwindow) {
4579 this.dialogEl.setStyle( { 'max-width' : '100%' });
4581 this.width || Roo.lib.Dom.getViewportWidth(true) - 30,
4582 this.height || Roo.lib.Dom.getViewportHeight(true) // catering margin-top 30 margin-bottom 30
4587 if(this.max_width !== 0) {
4589 var w = Math.min(this.max_width, Roo.lib.Dom.getViewportWidth(true) - 30);
4592 this.setSize(w, this.height);
4596 if(this.max_height) {
4597 this.setSize(w,Math.min(
4599 Roo.lib.Dom.getViewportHeight(true) - 60
4605 if(!this.fit_content) {
4606 this.setSize(w, Roo.lib.Dom.getViewportHeight(true) - 60);
4610 this.setSize(w, Math.min(
4612 this.headerEl.getHeight() +
4613 this.footerEl.getHeight() +
4614 this.getChildHeight(this.bodyEl.dom.childNodes),
4615 Roo.lib.Dom.getViewportHeight(true) - 60)
4621 setSize : function(w,h)
4632 if (!this.rendered) {
4635 this.toggleHeaderInput(false);
4636 //this.el.setStyle('display', 'block');
4637 this.el.removeClass('hideing');
4638 this.el.dom.style.display='block';
4640 Roo.get(document.body).addClass('modal-open');
4642 if(this.animate){ // element has 'fade' - so stuff happens after .3s ?- not sure why the delay?
4645 this.el.addClass('show');
4646 this.el.addClass('in');
4649 this.el.addClass('show');
4650 this.el.addClass('in');
4653 // not sure how we can show data in here..
4655 // this.getChildContainer().dom.innerHTML = this.tmpl.applyTemplate(this);
4658 Roo.get(document.body).addClass("x-body-masked");
4660 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
4661 this.maskEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
4662 this.maskEl.dom.style.display = 'block';
4663 this.maskEl.addClass('show');
4668 this.fireEvent('show', this);
4670 // set zindex here - otherwise it appears to be ignored...
4671 this.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
4674 this.items.forEach( function(e) {
4675 e.layout ? e.layout() : false;
4683 if(this.fireEvent("beforehide", this) !== false){
4685 this.maskEl.removeClass('show');
4687 this.maskEl.dom.style.display = '';
4688 Roo.get(document.body).removeClass("x-body-masked");
4689 this.el.removeClass('in');
4690 this.el.select('.modal-dialog', true).first().setStyle('transform','');
4692 if(this.animate){ // why
4693 this.el.addClass('hideing');
4694 this.el.removeClass('show');
4696 if (!this.el.hasClass('hideing')) {
4697 return; // it's been shown again...
4700 this.el.dom.style.display='';
4702 Roo.get(document.body).removeClass('modal-open');
4703 this.el.removeClass('hideing');
4707 this.el.removeClass('show');
4708 this.el.dom.style.display='';
4709 Roo.get(document.body).removeClass('modal-open');
4712 this.fireEvent('hide', this);
4715 isVisible : function()
4718 return this.el.hasClass('show') && !this.el.hasClass('hideing');
4722 addButton : function(str, cb)
4726 var b = Roo.apply({}, { html : str } );
4727 b.xns = b.xns || Roo.bootstrap;
4728 b.xtype = b.xtype || 'Button';
4729 if (typeof(b.listeners) == 'undefined') {
4730 b.listeners = { click : cb.createDelegate(this) };
4733 var btn = Roo.factory(b);
4735 btn.render(this.getButtonContainer());
4741 setDefaultButton : function(btn)
4743 //this.el.select('.modal-footer').()
4746 resizeTo: function(w,h)
4748 this.dialogEl.setWidth(w);
4750 var diff = this.headerEl.getHeight() + this.footerEl.getHeight() + 60; // dialog margin-bottom: 30
4752 this.bodyEl.setHeight(h - diff);
4754 this.fireEvent('resize', this);
4757 setContentSize : function(w, h)
4761 onButtonClick: function(btn,e)
4764 this.fireEvent('btnclick', btn.name, e);
4767 * Set the title of the Dialog
4768 * @param {String} str new Title
4770 setTitle: function(str) {
4771 this.titleEl.dom.innerHTML = str;
4775 * Set the body of the Dialog
4776 * @param {String} str new Title
4778 setBody: function(str) {
4779 this.bodyEl.dom.innerHTML = str;
4782 * Set the body of the Dialog using the template
4783 * @param {Obj} data - apply this data to the template and replace the body contents.
4785 applyBody: function(obj)
4788 Roo.log("Error - using apply Body without a template");
4791 this.tmpl.overwrite(this.bodyEl, obj);
4794 getChildHeight : function(child_nodes)
4798 child_nodes.length == 0
4803 var child_height = 0;
4805 for(var i = 0; i < child_nodes.length; i++) {
4808 * for modal with tabs...
4809 if(child_nodes[i].classList.contains('roo-layout-panel')) {
4811 var layout_childs = child_nodes[i].childNodes;
4813 for(var j = 0; j < layout_childs.length; j++) {
4815 if(layout_childs[j].classList.contains('roo-layout-panel-body')) {
4817 var layout_body_childs = layout_childs[j].childNodes;
4819 for(var k = 0; k < layout_body_childs.length; k++) {
4821 if(layout_body_childs[k].classList.contains('navbar')) {
4822 child_height += layout_body_childs[k].offsetHeight;
4826 if(layout_body_childs[k].classList.contains('roo-layout-tabs-body')) {
4828 var layout_body_tab_childs = layout_body_childs[k].childNodes;
4830 for(var m = 0; m < layout_body_tab_childs.length; m++) {
4832 if(layout_body_tab_childs[m].classList.contains('roo-layout-active-content')) {
4833 child_height += this.getChildHeight(layout_body_tab_childs[m].childNodes);
4848 child_height += child_nodes[i].offsetHeight;
4849 // Roo.log(child_nodes[i].offsetHeight);
4852 return child_height;
4854 toggleHeaderInput : function(is_edit)
4856 if (!this.editableTitle) {
4857 return; // not editable.
4859 if (is_edit && this.is_header_editing) {
4860 return; // already editing..
4864 this.headerEditEl.dom.value = this.title;
4865 this.headerEditEl.removeClass('d-none');
4866 this.headerEditEl.dom.focus();
4867 this.titleEl.addClass('d-none');
4869 this.is_header_editing = true;
4872 // flip back to not editing.
4873 this.title = this.headerEditEl.dom.value;
4874 this.headerEditEl.addClass('d-none');
4875 this.titleEl.removeClass('d-none');
4876 this.titleEl.dom.innerHTML = String.format('{0}', this.title);
4877 this.is_header_editing = false;
4878 this.fireEvent('titlechanged', this, this.title);
4887 Roo.apply(Roo.bootstrap.Modal, {
4889 * Button config that displays a single OK button
4898 * Button config that displays Yes and No buttons
4914 * Button config that displays OK and Cancel buttons
4929 * Button config that displays Yes, No and Cancel buttons
4954 * messagebox - can be used as a replace
4958 * @class Roo.MessageBox
4959 * Utility class for generating different styles of message boxes. The alias Roo.Msg can also be used.
4963 Roo.Msg.alert('Status', 'Changes saved successfully.');
4965 // Prompt for user data:
4966 Roo.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
4968 // process text value...
4972 // Show a dialog using config options:
4974 title:'Save Changes?',
4975 msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',
4976 buttons: Roo.Msg.YESNOCANCEL,
4983 Roo.bootstrap.MessageBox = function(){
4984 var dlg, opt, mask, waitTimer;
4985 var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp;
4986 var buttons, activeTextEl, bwidth;
4990 var handleButton = function(button){
4992 Roo.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
4996 var handleHide = function(){
4998 dlg.el.removeClass(opt.cls);
5001 // Roo.TaskMgr.stop(waitTimer);
5002 // waitTimer = null;
5007 var updateButtons = function(b){
5010 buttons["ok"].hide();
5011 buttons["cancel"].hide();
5012 buttons["yes"].hide();
5013 buttons["no"].hide();
5014 dlg.footerEl.hide();
5018 dlg.footerEl.show();
5019 for(var k in buttons){
5020 if(typeof buttons[k] != "function"){
5023 buttons[k].setText(typeof b[k] == "string" ? b[k] : Roo.bootstrap.MessageBox.buttonText[k]);
5024 width += buttons[k].el.getWidth()+15;
5034 var handleEsc = function(d, k, e){
5035 if(opt && opt.closable !== false){
5045 * Returns a reference to the underlying {@link Roo.BasicDialog} element
5046 * @return {Roo.BasicDialog} The BasicDialog element
5048 getDialog : function(){
5050 dlg = new Roo.bootstrap.Modal( {
5053 //constraintoviewport:false,
5055 //collapsible : false,
5060 //buttonAlign:"center",
5061 closeClick : function(){
5062 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
5065 handleButton("cancel");
5070 dlg.on("hide", handleHide);
5072 //dlg.addKeyListener(27, handleEsc);
5074 this.buttons = buttons;
5075 var bt = this.buttonText;
5076 buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
5077 buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
5078 buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
5079 buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
5081 bodyEl = dlg.bodyEl.createChild({
5083 html:'<span class="roo-mb-text"></span><br /><input type="text" class="roo-mb-input" />' +
5084 '<textarea class="roo-mb-textarea"></textarea>' +
5085 '<div class="roo-mb-progress-wrap"><div class="roo-mb-progress"><div class="roo-mb-progress-bar"> </div></div></div>'
5087 msgEl = bodyEl.dom.firstChild;
5088 textboxEl = Roo.get(bodyEl.dom.childNodes[2]);
5089 textboxEl.enableDisplayMode();
5090 textboxEl.addKeyListener([10,13], function(){
5091 if(dlg.isVisible() && opt && opt.buttons){
5094 }else if(opt.buttons.yes){
5095 handleButton("yes");
5099 textareaEl = Roo.get(bodyEl.dom.childNodes[3]);
5100 textareaEl.enableDisplayMode();
5101 progressEl = Roo.get(bodyEl.dom.childNodes[4]);
5102 progressEl.enableDisplayMode();
5104 // This is supposed to be the progessElement.. but I think it's controlling the height of everything..
5105 var pf = progressEl.dom.firstChild;
5107 pp = Roo.get(pf.firstChild);
5108 pp.setHeight(pf.offsetHeight);
5116 * Updates the message box body text
5117 * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
5118 * the XHTML-compliant non-breaking space character '&#160;')
5119 * @return {Roo.MessageBox} This message box
5121 updateText : function(text)
5123 if(!dlg.isVisible() && !opt.width){
5124 dlg.dialogEl.setStyle({ 'max-width' : this.maxWidth});
5125 // dlg.resizeTo(this.maxWidth, 100); // forcing the height breaks long alerts()
5127 msgEl.innerHTML = text || ' ';
5129 var cw = Math.max(msgEl.offsetWidth, msgEl.parentNode.scrollWidth);
5130 //Roo.log("guesed size: " + JSON.stringify([cw,msgEl.offsetWidth, msgEl.parentNode.scrollWidth]));
5132 Math.min(opt.width || cw , this.maxWidth),
5133 Math.max(opt.minWidth || this.minWidth, bwidth)
5136 activeTextEl.setWidth(w);
5138 if(dlg.isVisible()){
5139 dlg.fixedcenter = false;
5141 // to big, make it scroll. = But as usual stupid IE does not support
5144 if ( bodyEl.getHeight() > (Roo.lib.Dom.getViewHeight() - 100)) {
5145 bodyEl.setHeight ( Roo.lib.Dom.getViewHeight() - 100 );
5146 bodyEl.dom.style.overflowY = 'auto' + ( Roo.isIE ? '' : ' !important');
5148 bodyEl.dom.style.height = '';
5149 bodyEl.dom.style.overflowY = '';
5152 bodyEl.dom.style.get = 'auto' + ( Roo.isIE ? '' : ' !important');
5154 bodyEl.dom.style.overflowX = '';
5157 dlg.setContentSize(w, bodyEl.getHeight());
5158 if(dlg.isVisible()){
5159 dlg.fixedcenter = true;
5165 * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
5166 * initiated via {@link Roo.MessageBox#progress} or by calling {@link Roo.MessageBox#show} with progress: true.
5167 * @param {Number} value Any number between 0 and 1 (e.g., .5)
5168 * @param {String} text (optional) If defined, the message box's body text is replaced with the specified string (defaults to undefined)
5169 * @return {Roo.MessageBox} This message box
5171 updateProgress : function(value, text){
5173 this.updateText(text);
5176 if (pp) { // weird bug on my firefox - for some reason this is not defined
5177 pp.setWidth(Math.floor(value*progressEl.dom.firstChild.offsetWidth));
5178 pp.setHeight(Math.floor(progressEl.dom.firstChild.offsetHeight));
5184 * Returns true if the message box is currently displayed
5185 * @return {Boolean} True if the message box is visible, else false
5187 isVisible : function(){
5188 return dlg && dlg.isVisible();
5192 * Hides the message box if it is displayed
5195 if(this.isVisible()){
5201 * Displays a new message box, or reinitializes an existing message box, based on the config options
5202 * passed in. All functions (e.g. prompt, alert, etc) on MessageBox call this function internally.
5203 * The following config object properties are supported:
5205 Property Type Description
5206 ---------- --------------- ------------------------------------------------------------------------------------
5207 animEl String/Element An id or Element from which the message box should animate as it opens and
5208 closes (defaults to undefined)
5209 buttons Object/Boolean A button config object (e.g., Roo.MessageBox.OKCANCEL or {ok:'Foo',
5210 cancel:'Bar'}), or false to not show any buttons (defaults to false)
5211 closable Boolean False to hide the top-right close button (defaults to true). Note that
5212 progress and wait dialogs will ignore this property and always hide the
5213 close button as they can only be closed programmatically.
5214 cls String A custom CSS class to apply to the message box element
5215 defaultTextHeight Number The default height in pixels of the message box's multiline textarea if
5216 displayed (defaults to 75)
5217 fn Function A callback function to execute after closing the dialog. The arguments to the
5218 function will be btn (the name of the button that was clicked, if applicable,
5219 e.g. "ok"), and text (the value of the active text field, if applicable).
5220 Progress and wait dialogs will ignore this option since they do not respond to
5221 user actions and can only be closed programmatically, so any required function
5222 should be called by the same code after it closes the dialog.
5223 icon String A CSS class that provides a background image to be used as an icon for
5224 the dialog (e.g., Roo.MessageBox.WARNING or 'custom-class', defaults to '')
5225 maxWidth Number The maximum width in pixels of the message box (defaults to 600)
5226 minWidth Number The minimum width in pixels of the message box (defaults to 100)
5227 modal Boolean False to allow user interaction with the page while the message box is
5228 displayed (defaults to true)
5229 msg String A string that will replace the existing message box body text (defaults
5230 to the XHTML-compliant non-breaking space character ' ')
5231 multiline Boolean True to prompt the user to enter multi-line text (defaults to false)
5232 progress Boolean True to display a progress bar (defaults to false)
5233 progressText String The text to display inside the progress bar if progress = true (defaults to '')
5234 prompt Boolean True to prompt the user to enter single-line text (defaults to false)
5235 proxyDrag Boolean True to display a lightweight proxy while dragging (defaults to false)
5236 title String The title text
5237 value String The string value to set into the active textbox element if displayed
5238 wait Boolean True to display a progress bar (defaults to false)
5239 width Number The width of the dialog in pixels
5246 msg: 'Please enter your address:',
5248 buttons: Roo.MessageBox.OKCANCEL,
5251 animEl: 'addAddressBtn'
5254 * @param {Object} config Configuration options
5255 * @return {Roo.MessageBox} This message box
5257 show : function(options)
5260 // this causes nightmares if you show one dialog after another
5261 // especially on callbacks..
5263 if(this.isVisible()){
5266 Roo.log("[Roo.Messagebox] Show called while message displayed:" );
5267 Roo.log("Old Dialog Message:" + msgEl.innerHTML );
5268 Roo.log("New Dialog Message:" + options.msg )
5269 //this.alert("ERROR", "Multiple dialogs where displayed at the same time");
5270 //throw "Roo.MessageBox ERROR : Multiple dialogs where displayed at the same time";
5273 var d = this.getDialog();
5275 d.setTitle(opt.title || " ");
5276 d.closeEl.setDisplayed(opt.closable !== false);
5277 activeTextEl = textboxEl;
5278 opt.prompt = opt.prompt || (opt.multiline ? true : false);
5283 textareaEl.setHeight(typeof opt.multiline == "number" ?
5284 opt.multiline : this.defaultTextHeight);
5285 activeTextEl = textareaEl;
5294 progressEl.setDisplayed(opt.progress === true);
5296 d.animate = false; // do not animate progress, as it may not have finished animating before we close it..
5298 this.updateProgress(0);
5299 activeTextEl.dom.value = opt.value || "";
5301 dlg.setDefaultButton(activeTextEl);
5303 var bs = opt.buttons;
5307 }else if(bs && bs.yes){
5308 db = buttons["yes"];
5310 dlg.setDefaultButton(db);
5312 bwidth = updateButtons(opt.buttons);
5313 this.updateText(opt.msg);
5315 d.el.addClass(opt.cls);
5317 d.proxyDrag = opt.proxyDrag === true;
5318 d.modal = opt.modal !== false;
5319 d.mask = opt.modal !== false ? mask : false;
5321 // force it to the end of the z-index stack so it gets a cursor in FF
5322 document.body.appendChild(dlg.el.dom);
5323 d.animateTarget = null;
5324 d.show(options.animEl);
5330 * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
5331 * the user. You are responsible for updating the progress bar as needed via {@link Roo.MessageBox#updateProgress}
5332 * and closing the message box when the process is complete.
5333 * @param {String} title The title bar text
5334 * @param {String} msg The message box body text
5335 * @return {Roo.MessageBox} This message box
5337 progress : function(title, msg){
5344 minWidth: this.minProgressWidth,
5351 * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
5352 * If a callback function is passed it will be called after the user clicks the button, and the
5353 * id of the button that was clicked will be passed as the only parameter to the callback
5354 * (could also be the top-right close button).
5355 * @param {String} title The title bar text
5356 * @param {String} msg The message box body text
5357 * @param {Function} fn (optional) The callback function invoked after the message box is closed
5358 * @param {Object} scope (optional) The scope of the callback function
5359 * @return {Roo.MessageBox} This message box
5361 alert : function(title, msg, fn, scope)
5376 * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
5377 * interaction while waiting for a long-running process to complete that does not have defined intervals.
5378 * You are responsible for closing the message box when the process is complete.
5379 * @param {String} msg The message box body text
5380 * @param {String} title (optional) The title bar text
5381 * @return {Roo.MessageBox} This message box
5383 wait : function(msg, title){
5394 waitTimer = Roo.TaskMgr.start({
5396 Roo.MessageBox.updateProgress(((((i+20)%20)+1)*5)*.01);
5404 * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
5405 * If a callback function is passed it will be called after the user clicks either button, and the id of the
5406 * button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
5407 * @param {String} title The title bar text
5408 * @param {String} msg The message box body text
5409 * @param {Function} fn (optional) The callback function invoked after the message box is closed
5410 * @param {Object} scope (optional) The scope of the callback function
5411 * @return {Roo.MessageBox} This message box
5413 confirm : function(title, msg, fn, scope){
5417 buttons: this.YESNO,
5426 * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to
5427 * JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function
5428 * is passed it will be called after the user clicks either button, and the id of the button that was clicked
5429 * (could also be the top-right close button) and the text that was entered will be passed as the two
5430 * parameters to the callback.
5431 * @param {String} title The title bar text
5432 * @param {String} msg The message box body text
5433 * @param {Function} fn (optional) The callback function invoked after the message box is closed
5434 * @param {Object} scope (optional) The scope of the callback function
5435 * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
5436 * property, or the height in pixels to create the textbox (defaults to false / single-line)
5437 * @return {Roo.MessageBox} This message box
5439 prompt : function(title, msg, fn, scope, multiline){
5443 buttons: this.OKCANCEL,
5448 multiline: multiline,
5455 * Button config that displays a single OK button
5460 * Button config that displays Yes and No buttons
5463 YESNO : {yes:true, no:true},
5465 * Button config that displays OK and Cancel buttons
5468 OKCANCEL : {ok:true, cancel:true},
5470 * Button config that displays Yes, No and Cancel buttons
5473 YESNOCANCEL : {yes:true, no:true, cancel:true},
5476 * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
5479 defaultTextHeight : 75,
5481 * The maximum width in pixels of the message box (defaults to 600)
5486 * The minimum width in pixels of the message box (defaults to 100)
5491 * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
5492 * for setting a different minimum width than text-only dialogs may need (defaults to 250)
5495 minProgressWidth : 250,
5497 * An object containing the default button text strings that can be overriden for localized language support.
5498 * Supported properties are: ok, cancel, yes and no.
5499 * Customize the default text like so: Roo.MessageBox.buttonText.yes = "S?";
5512 * Shorthand for {@link Roo.MessageBox}
5514 Roo.MessageBox = Roo.MessageBox || Roo.bootstrap.MessageBox;
5515 Roo.Msg = Roo.Msg || Roo.MessageBox;
5524 * @class Roo.bootstrap.Navbar
5525 * @extends Roo.bootstrap.Component
5526 * Bootstrap Navbar class
5529 * Create a new Navbar
5530 * @param {Object} config The config object
5534 Roo.bootstrap.Navbar = function(config){
5535 Roo.bootstrap.Navbar.superclass.constructor.call(this, config);
5539 * @event beforetoggle
5540 * Fire before toggle the menu
5541 * @param {Roo.EventObject} e
5543 "beforetoggle" : true
5547 Roo.extend(Roo.bootstrap.Navbar, Roo.bootstrap.Component, {
5556 getAutoCreate : function(){
5559 throw { message : "nav bar is now a abstract base class - use NavSimplebar / NavHeaderbar / NavSidebar etc..."};
5563 initEvents :function ()
5565 //Roo.log(this.el.select('.navbar-toggle',true));
5566 this.el.select('.navbar-toggle',true).on('click', this.onToggle , this);
5573 this.maskEl = Roo.DomHelper.append(this.el, mark, true);
5575 var size = this.el.getSize();
5576 this.maskEl.setSize(size.width, size.height);
5577 this.maskEl.enableDisplayMode("block");
5586 getChildContainer : function()
5588 if (this.el && this.el.select('.collapse').getCount()) {
5589 return this.el.select('.collapse',true).first();
5604 onToggle : function()
5607 if(this.fireEvent('beforetoggle', this) === false){
5610 var ce = this.el.select('.navbar-collapse',true).first();
5612 if (!ce.hasClass('show')) {
5622 * Expand the navbar pulldown
5624 expand : function ()
5627 var ce = this.el.select('.navbar-collapse',true).first();
5628 if (ce.hasClass('collapsing')) {
5631 ce.dom.style.height = '';
5633 ce.addClass('in'); // old...
5634 ce.removeClass('collapse');
5635 ce.addClass('show');
5636 var h = ce.getHeight();
5638 ce.removeClass('show');
5639 // at this point we should be able to see it..
5640 ce.addClass('collapsing');
5642 ce.setHeight(0); // resize it ...
5643 ce.on('transitionend', function() {
5644 //Roo.log('done transition');
5645 ce.removeClass('collapsing');
5646 ce.addClass('show');
5647 ce.removeClass('collapse');
5649 ce.dom.style.height = '';
5650 }, this, { single: true} );
5652 ce.dom.scrollTop = 0;
5655 * Collapse the navbar pulldown
5657 collapse : function()
5659 var ce = this.el.select('.navbar-collapse',true).first();
5661 if (ce.hasClass('collapsing') || ce.hasClass('collapse') ) {
5662 // it's collapsed or collapsing..
5665 ce.removeClass('in'); // old...
5666 ce.setHeight(ce.getHeight());
5667 ce.removeClass('show');
5668 ce.addClass('collapsing');
5670 ce.on('transitionend', function() {
5671 ce.dom.style.height = '';
5672 ce.removeClass('collapsing');
5673 ce.addClass('collapse');
5674 }, this, { single: true} );
5694 * @class Roo.bootstrap.NavSimplebar
5695 * @extends Roo.bootstrap.Navbar
5696 * Bootstrap Sidebar class
5698 * @cfg {Boolean} inverse is inverted color
5700 * @cfg {String} type (nav | pills | tabs)
5701 * @cfg {Boolean} arrangement stacked | justified
5702 * @cfg {String} align (left | right) alignment
5704 * @cfg {Boolean} main (true|false) main nav bar? default false
5705 * @cfg {Boolean} loadMask (true|false) loadMask on the bar
5707 * @cfg {String} tag (header|footer|nav|div) default is nav
5709 * @cfg {String} weight (light|primary|secondary|success|danger|warning|info|dark|white) default is light.
5713 * Create a new Sidebar
5714 * @param {Object} config The config object
5718 Roo.bootstrap.NavSimplebar = function(config){
5719 Roo.bootstrap.NavSimplebar.superclass.constructor.call(this, config);
5722 Roo.extend(Roo.bootstrap.NavSimplebar, Roo.bootstrap.Navbar, {
5738 getAutoCreate : function(){
5742 tag : this.tag || 'div',
5743 cls : 'navbar roo-navbar-simple' //navbar-expand-lg ??
5745 if (['light','white'].indexOf(this.weight) > -1) {
5746 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
5748 cfg.cls += ' bg-' + this.weight;
5751 cfg.cls += ' navbar-inverse';
5755 // i'm not actually sure these are really used - normally we add a navGroup to a navbar
5757 if (Roo.bootstrap.version == 4 && this.xtype == 'NavSimplebar') {
5766 cls: 'nav nav-' + this.xtype,
5772 this.type = this.type || 'nav';
5773 if (['tabs','pills'].indexOf(this.type) != -1) {
5774 cfg.cn[0].cls += ' nav-' + this.type
5778 if (this.type!=='nav') {
5779 Roo.log('nav type must be nav/tabs/pills')
5781 cfg.cn[0].cls += ' navbar-nav'
5787 if (['stacked','justified'].indexOf(this.arrangement) != -1) {
5788 cfg.cn[0].cls += ' nav-' + this.arrangement;
5792 if (this.align === 'right') {
5793 cfg.cn[0].cls += ' navbar-right';
5818 * navbar-expand-md fixed-top
5822 * @class Roo.bootstrap.NavHeaderbar
5823 * @extends Roo.bootstrap.NavSimplebar
5824 * Bootstrap Sidebar class
5826 * @cfg {String} brand what is brand
5827 * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
5828 * @cfg {String} brand_href href of the brand
5829 * @cfg {Boolean} srButton generate the (screen reader / mobile) sr-only button default true
5830 * @cfg {Boolean} autohide a top nav bar header that hides on scroll.
5831 * @cfg {Boolean} desktopCenter should the header be centered on desktop using a container class
5832 * @cfg {Roo.bootstrap.Row} mobilerow - a row to display on mobile only..
5835 * Create a new Sidebar
5836 * @param {Object} config The config object
5840 Roo.bootstrap.NavHeaderbar = function(config){
5841 Roo.bootstrap.NavHeaderbar.superclass.constructor.call(this, config);
5845 Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar, {
5852 desktopCenter : false,
5855 getAutoCreate : function(){
5858 tag: this.nav || 'nav',
5859 cls: 'navbar navbar-expand-md',
5865 if (this.desktopCenter) {
5866 cn.push({cls : 'container', cn : []});
5874 cls: 'navbar-toggle navbar-toggler',
5875 'data-toggle': 'collapse',
5880 html: 'Toggle navigation'
5884 cls: 'icon-bar navbar-toggler-icon'
5897 cn.push( Roo.bootstrap.version == 4 ? btn : {
5899 cls: 'navbar-header',
5908 cls: Roo.bootstrap.version == 4 ? 'nav flex-row roo-navbar-collapse collapse navbar-collapse' : 'collapse navbar-collapse roo-navbar-collapse',
5912 cfg.cls += this.inverse ? ' navbar-inverse navbar-dark bg-dark' : ' navbar-default';
5914 if (['light','white'].indexOf(this.weight) > -1) {
5915 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
5917 cfg.cls += ' bg-' + this.weight;
5920 if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
5921 cfg.cls += ' navbar-' + this.position + ' ' + this.position ;
5923 // tag can override this..
5925 cfg.tag = this.tag || (this.position == 'fixed-bottom' ? 'footer' : 'header');
5928 if (this.brand !== '') {
5929 var cp = Roo.bootstrap.version == 4 ? cn : cn[0].cn;
5930 cp.unshift({ // changed from push ?? BS4 needs it at the start? - does this break or exsiting?
5932 href: this.brand_href ? this.brand_href : '#',
5933 cls: 'navbar-brand',
5941 cfg.cls += ' main-nav';
5949 getHeaderChildContainer : function()
5951 if (this.srButton && this.el.select('.navbar-header').getCount()) {
5952 return this.el.select('.navbar-header',true).first();
5955 return this.getChildContainer();
5958 getChildContainer : function()
5961 return this.el.select('.roo-navbar-collapse',true).first();
5966 initEvents : function()
5968 Roo.bootstrap.NavHeaderbar.superclass.initEvents.call(this);
5970 if (this.autohide) {
5975 Roo.get(document).on('scroll',function(e) {
5976 var ns = Roo.get(document).getScroll().top;
5977 var os = prevScroll;
5981 ft.removeClass('slideDown');
5982 ft.addClass('slideUp');
5985 ft.removeClass('slideUp');
5986 ft.addClass('slideDown');
6007 * @class Roo.bootstrap.NavSidebar
6008 * @extends Roo.bootstrap.Navbar
6009 * Bootstrap Sidebar class
6012 * Create a new Sidebar
6013 * @param {Object} config The config object
6017 Roo.bootstrap.NavSidebar = function(config){
6018 Roo.bootstrap.NavSidebar.superclass.constructor.call(this, config);
6021 Roo.extend(Roo.bootstrap.NavSidebar, Roo.bootstrap.Navbar, {
6023 sidebar : true, // used by Navbar Item and NavbarGroup at present...
6025 getAutoCreate : function(){
6030 cls: 'sidebar sidebar-nav'
6052 * @class Roo.bootstrap.NavGroup
6053 * @extends Roo.bootstrap.Component
6054 * Bootstrap NavGroup class
6055 * @cfg {String} align (left|right)
6056 * @cfg {Boolean} inverse
6057 * @cfg {String} type (nav|pills|tab) default nav
6058 * @cfg {String} navId - reference Id for navbar.
6059 * @cfg {Boolean} pilltype default true (turn to off to disable active toggle)
6062 * Create a new nav group
6063 * @param {Object} config The config object
6066 Roo.bootstrap.NavGroup = function(config){
6067 Roo.bootstrap.NavGroup.superclass.constructor.call(this, config);
6070 Roo.bootstrap.NavGroup.register(this);
6074 * Fires when the active item changes
6075 * @param {Roo.bootstrap.NavGroup} this
6076 * @param {Roo.bootstrap.Navbar.Item} selected The item selected
6077 * @param {Roo.bootstrap.Navbar.Item} prev The previously selected item
6084 Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, {
6096 getAutoCreate : function()
6098 var cfg = Roo.apply({}, Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));
6104 if (Roo.bootstrap.version == 4) {
6105 if (['tabs','pills'].indexOf(this.type) != -1) {
6106 cfg.cls += ' nav-' + this.type;
6108 // trying to remove so header bar can right align top?
6109 if (this.parent() && this.parent().xtype != 'NavHeaderbar') {
6110 // do not use on header bar...
6111 cfg.cls += ' navbar-nav';
6116 if (['tabs','pills'].indexOf(this.type) != -1) {
6117 cfg.cls += ' nav-' + this.type
6119 if (this.type !== 'nav') {
6120 Roo.log('nav type must be nav/tabs/pills')
6122 cfg.cls += ' navbar-nav'
6126 if (this.parent() && this.parent().sidebar) {
6129 cls: 'dashboard-menu sidebar-menu'
6135 if (this.form === true) {
6138 cls: 'navbar-form form-inline'
6140 //nav navbar-right ml-md-auto
6141 if (this.align === 'right') {
6142 cfg.cls += ' navbar-right ml-md-auto';
6144 cfg.cls += ' navbar-left';
6148 if (this.align === 'right') {
6149 cfg.cls += ' navbar-right ml-md-auto';
6151 cfg.cls += ' mr-auto';
6155 cfg.cls += ' navbar-inverse';
6163 * sets the active Navigation item
6164 * @param {Roo.bootstrap.NavItem} the new current navitem
6166 setActiveItem : function(item)
6169 Roo.each(this.navItems, function(v){
6174 v.setActive(false, true);
6181 item.setActive(true, true);
6182 this.fireEvent('changed', this, item, prev);
6187 * gets the active Navigation item
6188 * @return {Roo.bootstrap.NavItem} the current navitem
6190 getActive : function()
6194 Roo.each(this.navItems, function(v){
6205 indexOfNav : function()
6209 Roo.each(this.navItems, function(v,i){
6220 * adds a Navigation item
6221 * @param {Roo.bootstrap.NavItem} the navitem to add
6223 addItem : function(cfg)
6225 if (this.form && Roo.bootstrap.version == 4) {
6228 var cn = new Roo.bootstrap.NavItem(cfg);
6230 cn.parentId = this.id;
6231 cn.onRender(this.el, null);
6235 * register a Navigation item
6236 * @param {Roo.bootstrap.NavItem} the navitem to add
6238 register : function(item)
6240 this.navItems.push( item);
6241 item.navId = this.navId;
6246 * clear all the Navigation item
6249 clearAll : function()
6252 this.el.dom.innerHTML = '';
6255 getNavItem: function(tabId)
6258 Roo.each(this.navItems, function(e) {
6259 if (e.tabId == tabId) {
6269 setActiveNext : function()
6271 var i = this.indexOfNav(this.getActive());
6272 if (i > this.navItems.length) {
6275 this.setActiveItem(this.navItems[i+1]);
6277 setActivePrev : function()
6279 var i = this.indexOfNav(this.getActive());
6283 this.setActiveItem(this.navItems[i-1]);
6285 clearWasActive : function(except) {
6286 Roo.each(this.navItems, function(e) {
6287 if (e.tabId != except.tabId && e.was_active) {
6288 e.was_active = false;
6295 getWasActive : function ()
6298 Roo.each(this.navItems, function(e) {
6313 Roo.apply(Roo.bootstrap.NavGroup, {
6317 * register a Navigation Group
6318 * @param {Roo.bootstrap.NavGroup} the navgroup to add
6320 register : function(navgrp)
6322 this.groups[navgrp.navId] = navgrp;
6326 * fetch a Navigation Group based on the navigation ID
6327 * @param {string} the navgroup to add
6328 * @returns {Roo.bootstrap.NavGroup} the navgroup
6330 get: function(navId) {
6331 if (typeof(this.groups[navId]) == 'undefined') {
6333 //this.register(new Roo.bootstrap.NavGroup({ navId : navId }));
6335 return this.groups[navId] ;
6350 * @class Roo.bootstrap.NavItem
6351 * @extends Roo.bootstrap.Component
6352 * Bootstrap Navbar.NavItem class
6353 * @cfg {String} href link to
6354 * @cfg {String} button_weight (default|primary|secondary|success|info|warning|danger|link|light|dark) default none
6355 * @cfg {Boolean} button_outline show and outlined button
6356 * @cfg {String} html content of button
6357 * @cfg {String} badge text inside badge
6358 * @cfg {String} badgecls (bg-green|bg-red|bg-yellow)the extra classes for the badge
6359 * @cfg {String} glyphicon DEPRICATED - use fa
6360 * @cfg {String} icon DEPRICATED - use fa
6361 * @cfg {String} fa - Fontawsome icon name (can add stuff to it like fa-2x)
6362 * @cfg {Boolean} active Is item active
6363 * @cfg {Boolean} disabled Is item disabled
6364 * @cfg {String} linkcls Link Class
6365 * @cfg {Boolean} preventDefault (true | false) default false
6366 * @cfg {String} tabId the tab that this item activates.
6367 * @cfg {String} tagtype (a|span) render as a href or span?
6368 * @cfg {Boolean} animateRef (true|false) link to element default false
6371 * Create a new Navbar Item
6372 * @param {Object} config The config object
6374 Roo.bootstrap.NavItem = function(config){
6375 Roo.bootstrap.NavItem.superclass.constructor.call(this, config);
6380 * The raw click event for the entire grid.
6381 * @param {Roo.EventObject} e
6386 * Fires when the active item active state changes
6387 * @param {Roo.bootstrap.NavItem} this
6388 * @param {boolean} state the new state
6394 * Fires when scroll to element
6395 * @param {Roo.bootstrap.NavItem} this
6396 * @param {Object} options
6397 * @param {Roo.EventObject} e
6405 Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, {
6414 preventDefault : false,
6422 button_outline : false,
6426 getAutoCreate : function(){
6433 cfg.cls = typeof(cfg.cls) == 'undefined' ? '' : cfg.cls;
6436 cfg.cls += ' active' ;
6438 if (this.disabled) {
6439 cfg.cls += ' disabled';
6443 if (this.button_weight.length) {
6444 cfg.tag = this.href ? 'a' : 'button';
6445 cfg.html = this.html || '';
6446 cfg.cls += ' btn btn' + (this.button_outline ? '-outline' : '') + '-' + this.button_weight;
6448 cfg.href = this.href;
6451 cfg.html = '<i class="fa fas fa-'+this.fa+'"></i> <span class="nav-html">' + this.html + '</span>';
6453 cfg.cls += " nav-html";
6456 // menu .. should add dropdown-menu class - so no need for carat..
6458 if (this.badge !== '') {
6460 cfg.html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
6465 if (this.href || this.html || this.glyphicon || this.icon || this.fa) {
6469 href : this.href || "#",
6470 html: this.html || '',
6474 if (this.tagtype == 'a') {
6475 cfg.cn[0].cls = 'nav-link' + (this.active ? ' active' : '') + ' ' + this.linkcls;
6479 cfg.cn[0].html = '<i class="'+this.icon+'"></i> <span class="nav-html">' + cfg.cn[0].html + '</span>';
6480 } else if (this.fa) {
6481 cfg.cn[0].html = '<i class="fa fas fa-'+this.fa+'"></i> <span class="nav-html">' + cfg.cn[0].html + '</span>';
6482 } else if(this.glyphicon) {
6483 cfg.cn[0].html = '<span class="glyphicon glyphicon-' + this.glyphicon + '"></span> ' + cfg.cn[0].html;
6485 cfg.cn[0].cls += " nav-html";
6489 cfg.cn[0].html += " <span class='caret'></span>";
6493 if (this.badge !== '') {
6494 cfg.cn[0].html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
6502 onRender : function(ct, position)
6504 // Roo.log("Call onRender: " + this.xtype);
6505 if (Roo.bootstrap.version == 4 && ct.dom.type != 'ul') {
6509 var ret = Roo.bootstrap.NavItem.superclass.onRender.call(this, ct, position);
6510 this.navLink = this.el.select('.nav-link',true).first();
6511 this.htmlEl = this.el.hasClass('nav-html') ? this.el : this.el.select('.nav-html',true).first();
6516 initEvents: function()
6518 if (typeof (this.menu) != 'undefined') {
6519 this.menu.parentType = this.xtype;
6520 this.menu.triggerEl = this.el;
6521 this.menu = this.addxtype(Roo.apply({}, this.menu));
6524 this.el.on('click', this.onClick, this);
6526 //if(this.tagtype == 'span'){
6527 // this.el.select('span',true).on('click', this.onClick, this);
6530 // at this point parent should be available..
6531 this.parent().register(this);
6534 onClick : function(e)
6536 if (e.getTarget('.dropdown-menu-item')) {
6537 // did you click on a menu itemm.... - then don't trigger onclick..
6542 this.preventDefault ||
6545 Roo.log("NavItem - prevent Default?");
6549 if (this.disabled) {
6553 var tg = Roo.bootstrap.TabGroup.get(this.navId);
6554 if (tg && tg.transition) {
6555 Roo.log("waiting for the transitionend");
6561 //Roo.log("fire event clicked");
6562 if(this.fireEvent('click', this, e) === false){
6566 if(this.tagtype == 'span'){
6570 //Roo.log(this.href);
6571 var ael = this.el.select('a',true).first();
6574 if(ael && this.animateRef && this.href.indexOf('#') > -1){
6575 //Roo.log(["test:",ael.dom.href.split("#")[0], document.location.toString().split("#")[0]]);
6576 if (ael.dom.href.split("#")[0] != document.location.toString().split("#")[0]) {
6577 return; // ignore... - it's a 'hash' to another page.
6579 Roo.log("NavItem - prevent Default?");
6581 this.scrollToElement(e);
6585 var p = this.parent();
6587 if (['tabs','pills'].indexOf(p.type)!==-1 && p.pilltype) {
6588 if (typeof(p.setActiveItem) !== 'undefined') {
6589 p.setActiveItem(this);
6593 // if parent is a navbarheader....- and link is probably a '#' page ref.. then remove the expanded menu.
6594 if (p.parentType == 'NavHeaderbar' && !this.menu) {
6595 // remove the collapsed menu expand...
6596 p.parent().el.select('.roo-navbar-collapse',true).removeClass('in');
6600 isActive: function () {
6603 setActive : function(state, fire, is_was_active)
6605 if (this.active && !state && this.navId) {
6606 this.was_active = true;
6607 var nv = Roo.bootstrap.NavGroup.get(this.navId);
6609 nv.clearWasActive(this);
6613 this.active = state;
6616 this.el.removeClass('active');
6617 this.navLink ? this.navLink.removeClass('active') : false;
6618 } else if (!this.el.hasClass('active')) {
6620 this.el.addClass('active');
6621 if (Roo.bootstrap.version == 4 && this.navLink ) {
6622 this.navLink.addClass('active');
6627 this.fireEvent('changed', this, state);
6630 // show a panel if it's registered and related..
6632 if (!this.navId || !this.tabId || !state || is_was_active) {
6636 var tg = Roo.bootstrap.TabGroup.get(this.navId);
6640 var pan = tg.getPanelByName(this.tabId);
6644 // if we can not flip to new panel - go back to old nav highlight..
6645 if (false == tg.showPanel(pan)) {
6646 var nv = Roo.bootstrap.NavGroup.get(this.navId);
6648 var onav = nv.getWasActive();
6650 onav.setActive(true, false, true);
6659 // this should not be here...
6660 setDisabled : function(state)
6662 this.disabled = state;
6664 this.el.removeClass('disabled');
6665 } else if (!this.el.hasClass('disabled')) {
6666 this.el.addClass('disabled');
6672 * Fetch the element to display the tooltip on.
6673 * @return {Roo.Element} defaults to this.el
6675 tooltipEl : function()
6677 return this.el; //this.tagtype == 'a' ? this.el : this.el.select('' + this.tagtype + '', true).first();
6680 scrollToElement : function(e)
6682 var c = document.body;
6685 * Firefox / IE places the overflow at the html level, unless specifically styled to behave differently.
6687 if(Roo.isFirefox || Roo.isIE || Roo.isIE11){
6688 c = document.documentElement;
6691 var target = Roo.get(c).select('a[name=' + this.href.split('#')[1] +']', true).first();
6697 var o = target.calcOffsetsTo(c);
6704 this.fireEvent('scrollto', this, options, e);
6706 Roo.get(c).scrollTo('top', options.value, true);
6711 * Set the HTML (text content) of the item
6712 * @param {string} html content for the nav item
6714 setHtml : function(html)
6717 this.htmlEl.dom.innerHTML = html;
6729 * <span> icon </span>
6730 * <span> text </span>
6731 * <span>badge </span>
6735 * @class Roo.bootstrap.NavSidebarItem
6736 * @extends Roo.bootstrap.NavItem
6737 * Bootstrap Navbar.NavSidebarItem class
6738 * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
6739 * {Boolean} open is the menu open
6740 * {Boolean} buttonView use button as the tigger el rather that a (default false)
6741 * {String} buttonWeight (default|primary|success|info|warning|danger)the extra classes for the button
6742 * {String} buttonSize (sm|md|lg)the extra classes for the button
6743 * {Boolean} showArrow show arrow next to the text (default true)
6745 * Create a new Navbar Button
6746 * @param {Object} config The config object
6748 Roo.bootstrap.NavSidebarItem = function(config){
6749 Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this, config);
6754 * The raw click event for the entire grid.
6755 * @param {Roo.EventObject} e
6760 * Fires when the active item active state changes
6761 * @param {Roo.bootstrap.NavSidebarItem} this
6762 * @param {boolean} state the new state
6770 Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem, {
6772 badgeWeight : 'default',
6778 buttonWeight : 'default',
6784 getAutoCreate : function(){
6789 href : this.href || '#',
6795 if(this.buttonView){
6798 href : this.href || '#',
6799 cls: 'btn btn-' + this.buttonWeight + ' btn-' + this.buttonSize + 'roo-button-dropdown-toggle',
6812 cfg.cls += ' active';
6815 if (this.disabled) {
6816 cfg.cls += ' disabled';
6819 cfg.cls += ' open x-open';
6822 if (this.glyphicon || this.icon) {
6823 var c = this.glyphicon ? ('glyphicon glyphicon-'+this.glyphicon) : this.icon;
6824 a.cn.push({ tag : 'i', cls : c }) ;
6827 if(!this.buttonView){
6830 html : this.html || ''
6837 if (this.badge !== '') {
6838 a.cn.push({ tag: 'span', cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge });
6844 a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
6847 a.cls += ' dropdown-toggle treeview' ;
6853 initEvents : function()
6855 if (typeof (this.menu) != 'undefined') {
6856 this.menu.parentType = this.xtype;
6857 this.menu.triggerEl = this.el;
6858 this.menu = this.addxtype(Roo.apply({}, this.menu));
6861 this.el.on('click', this.onClick, this);
6863 if(this.badge !== ''){
6864 this.badgeEl = this.el.select('.badge', true).first().setVisibilityMode(Roo.Element.DISPLAY);
6869 onClick : function(e)
6876 if(this.preventDefault){
6880 this.fireEvent('click', this, e);
6883 disable : function()
6885 this.setDisabled(true);
6890 this.setDisabled(false);
6893 setDisabled : function(state)
6895 if(this.disabled == state){
6899 this.disabled = state;
6902 this.el.addClass('disabled');
6906 this.el.removeClass('disabled');
6911 setActive : function(state)
6913 if(this.active == state){
6917 this.active = state;
6920 this.el.addClass('active');
6924 this.el.removeClass('active');
6929 isActive: function ()
6934 setBadge : function(str)
6940 this.badgeEl.dom.innerHTML = str;
6955 Roo.namespace('Roo.bootstrap.breadcrumb');
6959 * @class Roo.bootstrap.breadcrumb.Nav
6960 * @extends Roo.bootstrap.Component
6961 * Bootstrap Breadcrumb Nav Class
6963 * @children Roo.bootstrap.breadcrumb.Item
6966 * Create a new breadcrumb.Nav
6967 * @param {Object} config The config object
6971 Roo.bootstrap.breadcrumb.Nav = function(config){
6972 Roo.bootstrap.breadcrumb.Nav.superclass.constructor.call(this, config);
6977 Roo.extend(Roo.bootstrap.breadcrumb.Nav, Roo.bootstrap.Component, {
6979 getAutoCreate : function()
6996 initEvents: function()
6998 this.olEl = this.el.select('ol',true).first();
7000 getChildContainer : function()
7016 * @class Roo.bootstrap.breadcrumb.Nav
7017 * @extends Roo.bootstrap.Component
7018 * Bootstrap Breadcrumb Nav Class
7020 * @children Roo.bootstrap.breadcrumb.Component
7021 * @cfg {String} html the content of the link.
7022 * @cfg {String} href where it links to if '#' is used the link will be handled by onClick.
7023 * @cfg {Boolean} active is it active
7027 * Create a new breadcrumb.Nav
7028 * @param {Object} config The config object
7031 Roo.bootstrap.breadcrumb.Item = function(config){
7032 Roo.bootstrap.breadcrumb.Item.superclass.constructor.call(this, config);
7037 * The img click event for the img.
7038 * @param {Roo.EventObject} e
7045 Roo.extend(Roo.bootstrap.breadcrumb.Item, Roo.bootstrap.Component, {
7050 getAutoCreate : function()
7055 cls : 'breadcrumb-item' + (this.active ? ' active' : '')
7057 if (this.href !== false) {
7064 cfg.html = this.html;
7070 initEvents: function()
7073 this.el.select('a', true).first().on('click',this.onClick, this)
7077 onClick : function(e)
7080 this.fireEvent('click',this, e);
7093 * @class Roo.bootstrap.Row
7094 * @extends Roo.bootstrap.Component
7095 * Bootstrap Row class (contains columns...)
7099 * @param {Object} config The config object
7102 Roo.bootstrap.Row = function(config){
7103 Roo.bootstrap.Row.superclass.constructor.call(this, config);
7106 Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component, {
7108 getAutoCreate : function(){
7127 * @class Roo.bootstrap.Pagination
7128 * @extends Roo.bootstrap.Component
7129 * Bootstrap Pagination class
7130 * @cfg {String} size xs | sm | md | lg
7131 * @cfg {Boolean} inverse false | true
7134 * Create a new Pagination
7135 * @param {Object} config The config object
7138 Roo.bootstrap.Pagination = function(config){
7139 Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
7142 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component, {
7148 getAutoCreate : function(){
7154 cfg.cls += ' inverse';
7160 cfg.cls += " " + this.cls;
7178 * @class Roo.bootstrap.PaginationItem
7179 * @extends Roo.bootstrap.Component
7180 * Bootstrap PaginationItem class
7181 * @cfg {String} html text
7182 * @cfg {String} href the link
7183 * @cfg {Boolean} preventDefault (true | false) default true
7184 * @cfg {Boolean} active (true | false) default false
7185 * @cfg {Boolean} disabled default false
7189 * Create a new PaginationItem
7190 * @param {Object} config The config object
7194 Roo.bootstrap.PaginationItem = function(config){
7195 Roo.bootstrap.PaginationItem.superclass.constructor.call(this, config);
7200 * The raw click event for the entire grid.
7201 * @param {Roo.EventObject} e
7207 Roo.extend(Roo.bootstrap.PaginationItem, Roo.bootstrap.Component, {
7211 preventDefault: true,
7216 getAutoCreate : function(){
7222 href : this.href ? this.href : '#',
7223 html : this.html ? this.html : ''
7233 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' disabled' : 'disabled';
7237 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' active' : 'active';
7243 initEvents: function() {
7245 this.el.on('click', this.onClick, this);
7248 onClick : function(e)
7250 Roo.log('PaginationItem on click ');
7251 if(this.preventDefault){
7259 this.fireEvent('click', this, e);
7275 * @class Roo.bootstrap.Slider
7276 * @extends Roo.bootstrap.Component
7277 * Bootstrap Slider class
7280 * Create a new Slider
7281 * @param {Object} config The config object
7284 Roo.bootstrap.Slider = function(config){
7285 Roo.bootstrap.Slider.superclass.constructor.call(this, config);
7288 Roo.extend(Roo.bootstrap.Slider, Roo.bootstrap.Component, {
7290 getAutoCreate : function(){
7294 cls: 'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',
7298 cls: 'ui-slider-handle ui-state-default ui-corner-all'
7310 * Ext JS Library 1.1.1
7311 * Copyright(c) 2006-2007, Ext JS, LLC.
7313 * Originally Released Under LGPL - original licence link has changed is not relivant.
7316 * <script type="text/javascript">
7319 * @extends Roo.dd.DDProxy
7320 * @class Roo.grid.SplitDragZone
7321 * Support for Column Header resizing
7323 * @param {Object} config
7326 // This is a support class used internally by the Grid components
7327 Roo.grid.SplitDragZone = function(grid, hd, hd2){
7329 this.view = grid.getView();
7330 this.proxy = this.view.resizeProxy;
7331 Roo.grid.SplitDragZone.superclass.constructor.call(
7334 "gridSplitters" + this.grid.getGridEl().id, // SGROUP
7336 dragElId : Roo.id(this.proxy.dom),
7341 this.setHandleElId(Roo.id(hd));
7342 if (hd2 !== false) {
7343 this.setOuterHandleElId(Roo.id(hd2));
7346 this.scroll = false;
7348 Roo.extend(Roo.grid.SplitDragZone, Roo.dd.DDProxy, {
7349 fly: Roo.Element.fly,
7351 b4StartDrag : function(x, y){
7352 this.view.headersDisabled = true;
7353 var h = this.view.mainWrap ? this.view.mainWrap.getHeight() : (
7354 this.view.headEl.getHeight() + this.view.bodyEl.getHeight()
7356 this.proxy.setHeight(h);
7358 // for old system colWidth really stored the actual width?
7359 // in bootstrap we tried using xs/ms/etc.. to do % sizing?
7360 // which in reality did not work.. - it worked only for fixed sizes
7361 // for resizable we need to use actual sizes.
7362 var w = this.cm.getColumnWidth(this.cellIndex);
7363 if (!this.view.mainWrap) {
7365 w = this.view.getHeaderIndex(this.cellIndex).getWidth();
7370 // this was w-this.grid.minColumnWidth;
7371 // doesnt really make sense? - w = thie curren width or the rendered one?
7372 var minw = Math.max(w-this.grid.minColumnWidth, 0);
7373 this.resetConstraints();
7374 this.setXConstraint(minw, 1000);
7375 this.setYConstraint(0, 0);
7376 this.minX = x - minw;
7377 this.maxX = x + 1000;
7379 if (!this.view.mainWrap) { // this is Bootstrap code..
7380 this.getDragEl().style.display='block';
7383 Roo.dd.DDProxy.prototype.b4StartDrag.call(this, x, y);
7387 handleMouseDown : function(e){
7388 ev = Roo.EventObject.setEvent(e);
7389 var t = this.fly(ev.getTarget());
7390 if(t.hasClass("x-grid-split")){
7391 this.cellIndex = this.view.getCellIndex(t.dom);
7393 this.cm = this.grid.colModel;
7394 if(this.cm.isResizable(this.cellIndex) && !this.cm.isFixed(this.cellIndex)){
7395 Roo.grid.SplitDragZone.superclass.handleMouseDown.apply(this, arguments);
7400 endDrag : function(e){
7401 this.view.headersDisabled = false;
7402 var endX = Math.max(this.minX, Roo.lib.Event.getPageX(e));
7403 var diff = endX - this.startPos;
7405 var w = this.cm.getColumnWidth(this.cellIndex);
7406 if (!this.view.mainWrap) {
7409 this.view.onColumnSplitterMoved(this.cellIndex, w+diff);
7412 autoOffset : function(){
7417 * Ext JS Library 1.1.1
7418 * Copyright(c) 2006-2007, Ext JS, LLC.
7420 * Originally Released Under LGPL - original licence link has changed is not relivant.
7423 * <script type="text/javascript">
7427 * @class Roo.grid.AbstractSelectionModel
7428 * @extends Roo.util.Observable
7430 * Abstract base class for grid SelectionModels. It provides the interface that should be
7431 * implemented by descendant classes. This class should not be directly instantiated.
7434 Roo.grid.AbstractSelectionModel = function(){
7435 this.locked = false;
7436 Roo.grid.AbstractSelectionModel.superclass.constructor.call(this);
7439 Roo.extend(Roo.grid.AbstractSelectionModel, Roo.util.Observable, {
7440 /** @ignore Called by the grid automatically. Do not call directly. */
7441 init : function(grid){
7447 * Locks the selections.
7454 * Unlocks the selections.
7456 unlock : function(){
7457 this.locked = false;
7461 * Returns true if the selections are locked.
7464 isLocked : function(){
7469 * Ext JS Library 1.1.1
7470 * Copyright(c) 2006-2007, Ext JS, LLC.
7472 * Originally Released Under LGPL - original licence link has changed is not relivant.
7475 * <script type="text/javascript">
7478 * @extends Roo.grid.AbstractSelectionModel
7479 * @class Roo.grid.RowSelectionModel
7480 * The default SelectionModel used by {@link Roo.grid.Grid}.
7481 * It supports multiple selections and keyboard selection/navigation.
7483 * @param {Object} config
7485 Roo.grid.RowSelectionModel = function(config){
7486 Roo.apply(this, config);
7487 this.selections = new Roo.util.MixedCollection(false, function(o){
7492 this.lastActive = false;
7496 * @event selectionchange
7497 * Fires when the selection changes
7498 * @param {SelectionModel} this
7500 "selectionchange" : true,
7502 * @event afterselectionchange
7503 * Fires after the selection changes (eg. by key press or clicking)
7504 * @param {SelectionModel} this
7506 "afterselectionchange" : true,
7508 * @event beforerowselect
7509 * Fires when a row is selected being selected, return false to cancel.
7510 * @param {SelectionModel} this
7511 * @param {Number} rowIndex The selected index
7512 * @param {Boolean} keepExisting False if other selections will be cleared
7514 "beforerowselect" : true,
7517 * Fires when a row is selected.
7518 * @param {SelectionModel} this
7519 * @param {Number} rowIndex The selected index
7520 * @param {Roo.data.Record} r The record
7524 * @event rowdeselect
7525 * Fires when a row is deselected.
7526 * @param {SelectionModel} this
7527 * @param {Number} rowIndex The selected index
7529 "rowdeselect" : true
7531 Roo.grid.RowSelectionModel.superclass.constructor.call(this);
7532 this.locked = false;
7535 Roo.extend(Roo.grid.RowSelectionModel, Roo.grid.AbstractSelectionModel, {
7537 * @cfg {Boolean} singleSelect
7538 * True to allow selection of only one row at a time (defaults to false)
7540 singleSelect : false,
7543 initEvents : function(){
7545 if(!this.grid.enableDragDrop && !this.grid.enableDrag){
7546 this.grid.on("mousedown", this.handleMouseDown, this);
7547 }else{ // allow click to work like normal
7548 this.grid.on("rowclick", this.handleDragableRowClick, this);
7550 // bootstrap does not have a view..
7551 var view = this.grid.view ? this.grid.view : this.grid;
7552 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
7555 this.selectPrevious(e.shiftKey);
7556 }else if(this.last !== false && this.lastActive !== false){
7557 var last = this.last;
7558 this.selectRange(this.last, this.lastActive-1);
7559 view.focusRow(this.lastActive);
7564 this.selectFirstRow();
7566 this.fireEvent("afterselectionchange", this);
7568 "down" : function(e){
7570 this.selectNext(e.shiftKey);
7571 }else if(this.last !== false && this.lastActive !== false){
7572 var last = this.last;
7573 this.selectRange(this.last, this.lastActive+1);
7574 view.focusRow(this.lastActive);
7579 this.selectFirstRow();
7581 this.fireEvent("afterselectionchange", this);
7587 view.on("refresh", this.onRefresh, this);
7588 view.on("rowupdated", this.onRowUpdated, this);
7589 view.on("rowremoved", this.onRemove, this);
7593 onRefresh : function(){
7594 var ds = this.grid.ds, i, v = this.grid.view;
7595 var s = this.selections;
7597 if((i = ds.indexOfId(r.id)) != -1){
7599 s.add(ds.getAt(i)); // updating the selection relate data
7607 onRemove : function(v, index, r){
7608 this.selections.remove(r);
7612 onRowUpdated : function(v, index, r){
7613 if(this.isSelected(r)){
7614 v.onRowSelect(index);
7620 * @param {Array} records The records to select
7621 * @param {Boolean} keepExisting (optional) True to keep existing selections
7623 selectRecords : function(records, keepExisting){
7625 this.clearSelections();
7627 var ds = this.grid.ds;
7628 for(var i = 0, len = records.length; i < len; i++){
7629 this.selectRow(ds.indexOf(records[i]), true);
7634 * Gets the number of selected rows.
7637 getCount : function(){
7638 return this.selections.length;
7642 * Selects the first row in the grid.
7644 selectFirstRow : function(){
7649 * Select the last row.
7650 * @param {Boolean} keepExisting (optional) True to keep existing selections
7652 selectLastRow : function(keepExisting){
7653 this.selectRow(this.grid.ds.getCount() - 1, keepExisting);
7657 * Selects the row immediately following the last selected row.
7658 * @param {Boolean} keepExisting (optional) True to keep existing selections
7660 selectNext : function(keepExisting){
7661 if(this.last !== false && (this.last+1) < this.grid.ds.getCount()){
7662 this.selectRow(this.last+1, keepExisting);
7663 var view = this.grid.view ? this.grid.view : this.grid;
7664 view.focusRow(this.last);
7669 * Selects the row that precedes the last selected row.
7670 * @param {Boolean} keepExisting (optional) True to keep existing selections
7672 selectPrevious : function(keepExisting){
7674 this.selectRow(this.last-1, keepExisting);
7675 var view = this.grid.view ? this.grid.view : this.grid;
7676 view.focusRow(this.last);
7681 * Returns the selected records
7682 * @return {Array} Array of selected records
7684 getSelections : function(){
7685 return [].concat(this.selections.items);
7689 * Returns the first selected record.
7692 getSelected : function(){
7693 return this.selections.itemAt(0);
7698 * Clears all selections.
7700 clearSelections : function(fast){
7705 var ds = this.grid.ds;
7706 var s = this.selections;
7708 this.deselectRow(ds.indexOfId(r.id));
7712 this.selections.clear();
7721 selectAll : function(){
7725 this.selections.clear();
7726 for(var i = 0, len = this.grid.ds.getCount(); i < len; i++){
7727 this.selectRow(i, true);
7732 * Returns True if there is a selection.
7735 hasSelection : function(){
7736 return this.selections.length > 0;
7740 * Returns True if the specified row is selected.
7741 * @param {Number/Record} record The record or index of the record to check
7744 isSelected : function(index){
7745 var r = typeof index == "number" ? this.grid.ds.getAt(index) : index;
7746 return (r && this.selections.key(r.id) ? true : false);
7750 * Returns True if the specified record id is selected.
7751 * @param {String} id The id of record to check
7754 isIdSelected : function(id){
7755 return (this.selections.key(id) ? true : false);
7759 handleMouseDown : function(e, t)
7761 var view = this.grid.view ? this.grid.view : this.grid;
7763 if(this.isLocked() || (rowIndex = view.findRowIndex(t)) === false){
7766 if(e.shiftKey && this.last !== false){
7767 var last = this.last;
7768 this.selectRange(last, rowIndex, e.ctrlKey);
7769 this.last = last; // reset the last
7770 view.focusRow(rowIndex);
7772 var isSelected = this.isSelected(rowIndex);
7773 if(e.button !== 0 && isSelected){
7774 view.focusRow(rowIndex);
7775 }else if(e.ctrlKey && isSelected){
7776 this.deselectRow(rowIndex);
7777 }else if(!isSelected){
7778 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
7779 view.focusRow(rowIndex);
7782 this.fireEvent("afterselectionchange", this);
7785 handleDragableRowClick : function(grid, rowIndex, e)
7787 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
7788 this.selectRow(rowIndex, false);
7789 var view = this.grid.view ? this.grid.view : this.grid;
7790 view.focusRow(rowIndex);
7791 this.fireEvent("afterselectionchange", this);
7796 * Selects multiple rows.
7797 * @param {Array} rows Array of the indexes of the row to select
7798 * @param {Boolean} keepExisting (optional) True to keep existing selections
7800 selectRows : function(rows, keepExisting){
7802 this.clearSelections();
7804 for(var i = 0, len = rows.length; i < len; i++){
7805 this.selectRow(rows[i], true);
7810 * Selects a range of rows. All rows in between startRow and endRow are also selected.
7811 * @param {Number} startRow The index of the first row in the range
7812 * @param {Number} endRow The index of the last row in the range
7813 * @param {Boolean} keepExisting (optional) True to retain existing selections
7815 selectRange : function(startRow, endRow, keepExisting){
7820 this.clearSelections();
7822 if(startRow <= endRow){
7823 for(var i = startRow; i <= endRow; i++){
7824 this.selectRow(i, true);
7827 for(var i = startRow; i >= endRow; i--){
7828 this.selectRow(i, true);
7834 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
7835 * @param {Number} startRow The index of the first row in the range
7836 * @param {Number} endRow The index of the last row in the range
7838 deselectRange : function(startRow, endRow, preventViewNotify){
7842 for(var i = startRow; i <= endRow; i++){
7843 this.deselectRow(i, preventViewNotify);
7849 * @param {Number} row The index of the row to select
7850 * @param {Boolean} keepExisting (optional) True to keep existing selections
7852 selectRow : function(index, keepExisting, preventViewNotify){
7853 if(this.locked || (index < 0 || index >= this.grid.ds.getCount())) {
7856 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
7857 if(!keepExisting || this.singleSelect){
7858 this.clearSelections();
7860 var r = this.grid.ds.getAt(index);
7861 this.selections.add(r);
7862 this.last = this.lastActive = index;
7863 if(!preventViewNotify){
7864 var view = this.grid.view ? this.grid.view : this.grid;
7865 view.onRowSelect(index);
7867 this.fireEvent("rowselect", this, index, r);
7868 this.fireEvent("selectionchange", this);
7874 * @param {Number} row The index of the row to deselect
7876 deselectRow : function(index, preventViewNotify){
7880 if(this.last == index){
7883 if(this.lastActive == index){
7884 this.lastActive = false;
7886 var r = this.grid.ds.getAt(index);
7887 this.selections.remove(r);
7888 if(!preventViewNotify){
7889 var view = this.grid.view ? this.grid.view : this.grid;
7890 view.onRowDeselect(index);
7892 this.fireEvent("rowdeselect", this, index);
7893 this.fireEvent("selectionchange", this);
7897 restoreLast : function(){
7899 this.last = this._last;
7904 acceptsNav : function(row, col, cm){
7905 return !cm.isHidden(col) && cm.isCellEditable(col, row);
7909 onEditorKey : function(field, e){
7910 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
7915 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
7917 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
7919 }else if(k == e.ENTER && !e.ctrlKey){
7923 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
7925 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
7927 }else if(k == e.ESC){
7931 g.startEditing(newCell[0], newCell[1]);
7936 * Ext JS Library 1.1.1
7937 * Copyright(c) 2006-2007, Ext JS, LLC.
7939 * Originally Released Under LGPL - original licence link has changed is not relivant.
7942 * <script type="text/javascript">
7947 * @class Roo.grid.ColumnModel
7948 * @extends Roo.util.Observable
7949 * This is the default implementation of a ColumnModel used by the Grid. It defines
7950 * the columns in the grid.
7953 var colModel = new Roo.grid.ColumnModel([
7954 {header: "Ticker", width: 60, sortable: true, locked: true},
7955 {header: "Company Name", width: 150, sortable: true},
7956 {header: "Market Cap.", width: 100, sortable: true},
7957 {header: "$ Sales", width: 100, sortable: true, renderer: money},
7958 {header: "Employees", width: 100, sortable: true, resizable: false}
7963 * The config options listed for this class are options which may appear in each
7964 * individual column definition.
7965 * <br/>RooJS Fix - column id's are not sequential but use Roo.id() - fixes bugs with layouts.
7967 * @param {Object} config An Array of column config objects. See this class's
7968 * config objects for details.
7970 Roo.grid.ColumnModel = function(config){
7972 * The config passed into the constructor
7974 this.config = []; //config;
7977 // if no id, create one
7978 // if the column does not have a dataIndex mapping,
7979 // map it to the order it is in the config
7980 for(var i = 0, len = config.length; i < len; i++){
7981 this.addColumn(config[i]);
7986 * The width of columns which have no width specified (defaults to 100)
7989 this.defaultWidth = 100;
7992 * Default sortable of columns which have no sortable specified (defaults to false)
7995 this.defaultSortable = false;
7999 * @event widthchange
8000 * Fires when the width of a column changes.
8001 * @param {ColumnModel} this
8002 * @param {Number} columnIndex The column index
8003 * @param {Number} newWidth The new width
8005 "widthchange": true,
8007 * @event headerchange
8008 * Fires when the text of a header changes.
8009 * @param {ColumnModel} this
8010 * @param {Number} columnIndex The column index
8011 * @param {Number} newText The new header text
8013 "headerchange": true,
8015 * @event hiddenchange
8016 * Fires when a column is hidden or "unhidden".
8017 * @param {ColumnModel} this
8018 * @param {Number} columnIndex The column index
8019 * @param {Boolean} hidden true if hidden, false otherwise
8021 "hiddenchange": true,
8023 * @event columnmoved
8024 * Fires when a column is moved.
8025 * @param {ColumnModel} this
8026 * @param {Number} oldIndex
8027 * @param {Number} newIndex
8029 "columnmoved" : true,
8031 * @event columlockchange
8032 * Fires when a column's locked state is changed
8033 * @param {ColumnModel} this
8034 * @param {Number} colIndex
8035 * @param {Boolean} locked true if locked
8037 "columnlockchange" : true
8039 Roo.grid.ColumnModel.superclass.constructor.call(this);
8041 Roo.extend(Roo.grid.ColumnModel, Roo.util.Observable, {
8043 * @cfg {String} header The header text to display in the Grid view.
8046 * @cfg {String} xsHeader Header at Bootsrap Extra Small width (default for all)
8049 * @cfg {String} smHeader Header at Bootsrap Small width
8052 * @cfg {String} mdHeader Header at Bootsrap Medium width
8055 * @cfg {String} lgHeader Header at Bootsrap Large width
8058 * @cfg {String} xlHeader Header at Bootsrap extra Large width
8061 * @cfg {String} dataIndex (Optional) The name of the field in the grid's {@link Roo.data.Store}'s
8062 * {@link Roo.data.Record} definition from which to draw the column's value. If not
8063 * specified, the column's index is used as an index into the Record's data Array.
8066 * @cfg {Number} width (Optional) The initial width in pixels of the column. Using this
8067 * instead of {@link Roo.grid.Grid#autoSizeColumns} is more efficient.
8070 * @cfg {Boolean} sortable (Optional) True if sorting is to be allowed on this column.
8071 * Defaults to the value of the {@link #defaultSortable} property.
8072 * Whether local/remote sorting is used is specified in {@link Roo.data.Store#remoteSort}.
8075 * @cfg {Boolean} locked (Optional) True to lock the column in place while scrolling the Grid. Defaults to false.
8078 * @cfg {Boolean} fixed (Optional) True if the column width cannot be changed. Defaults to false.
8081 * @cfg {Boolean} resizable (Optional) False to disable column resizing. Defaults to true.
8084 * @cfg {Boolean} hidden (Optional) True to hide the column. Defaults to false.
8087 * @cfg {Function} renderer (Optional) A function used to generate HTML markup for a cell
8088 * given the cell's data value. See {@link #setRenderer}. If not specified, the
8089 * default renderer returns the escaped data value. If an object is returned (bootstrap only)
8090 * then it is treated as a Roo Component object instance, and it is rendered after the initial row is rendered
8093 * @cfg {Roo.grid.GridEditor} editor (Optional) For grid editors - returns the grid editor
8096 * @cfg {String} align (Optional) Set the CSS text-align property of the column. Defaults to undefined.
8099 * @cfg {String} valign (Optional) Set the CSS vertical-align property of the column (eg. middle, top, bottom etc). Defaults to undefined.
8102 * @cfg {String} cursor (Optional)
8105 * @cfg {String} tooltip (Optional)
8108 * @cfg {Number} xs (Optional) can be '0' for hidden at this size (number less than 12)
8111 * @cfg {Number} sm (Optional) can be '0' for hidden at this size (number less than 12)
8114 * @cfg {Number} md (Optional) can be '0' for hidden at this size (number less than 12)
8117 * @cfg {Number} lg (Optional) can be '0' for hidden at this size (number less than 12)
8120 * @cfg {Number} xl (Optional) can be '0' for hidden at this size (number less than 12)
8123 * Returns the id of the column at the specified index.
8124 * @param {Number} index The column index
8125 * @return {String} the id
8127 getColumnId : function(index){
8128 return this.config[index].id;
8132 * Returns the column for a specified id.
8133 * @param {String} id The column id
8134 * @return {Object} the column
8136 getColumnById : function(id){
8137 return this.lookup[id];
8142 * Returns the column Object for a specified dataIndex.
8143 * @param {String} dataIndex The column dataIndex
8144 * @return {Object|Boolean} the column or false if not found
8146 getColumnByDataIndex: function(dataIndex){
8147 var index = this.findColumnIndex(dataIndex);
8148 return index > -1 ? this.config[index] : false;
8152 * Returns the index for a specified column id.
8153 * @param {String} id The column id
8154 * @return {Number} the index, or -1 if not found
8156 getIndexById : function(id){
8157 for(var i = 0, len = this.config.length; i < len; i++){
8158 if(this.config[i].id == id){
8166 * Returns the index for a specified column dataIndex.
8167 * @param {String} dataIndex The column dataIndex
8168 * @return {Number} the index, or -1 if not found
8171 findColumnIndex : function(dataIndex){
8172 for(var i = 0, len = this.config.length; i < len; i++){
8173 if(this.config[i].dataIndex == dataIndex){
8181 moveColumn : function(oldIndex, newIndex){
8182 var c = this.config[oldIndex];
8183 this.config.splice(oldIndex, 1);
8184 this.config.splice(newIndex, 0, c);
8185 this.dataMap = null;
8186 this.fireEvent("columnmoved", this, oldIndex, newIndex);
8189 isLocked : function(colIndex){
8190 return this.config[colIndex].locked === true;
8193 setLocked : function(colIndex, value, suppressEvent){
8194 if(this.isLocked(colIndex) == value){
8197 this.config[colIndex].locked = value;
8199 this.fireEvent("columnlockchange", this, colIndex, value);
8203 getTotalLockedWidth : function(){
8205 for(var i = 0; i < this.config.length; i++){
8206 if(this.isLocked(i) && !this.isHidden(i)){
8207 this.totalWidth += this.getColumnWidth(i);
8213 getLockedCount : function(){
8214 for(var i = 0, len = this.config.length; i < len; i++){
8215 if(!this.isLocked(i)){
8220 return this.config.length;
8224 * Returns the number of columns.
8227 getColumnCount : function(visibleOnly){
8228 if(visibleOnly === true){
8230 for(var i = 0, len = this.config.length; i < len; i++){
8231 if(!this.isHidden(i)){
8237 return this.config.length;
8241 * Returns the column configs that return true by the passed function that is called with (columnConfig, index)
8242 * @param {Function} fn
8243 * @param {Object} scope (optional)
8244 * @return {Array} result
8246 getColumnsBy : function(fn, scope){
8248 for(var i = 0, len = this.config.length; i < len; i++){
8249 var c = this.config[i];
8250 if(fn.call(scope||this, c, i) === true){
8258 * Returns true if the specified column is sortable.
8259 * @param {Number} col The column index
8262 isSortable : function(col){
8263 if(typeof this.config[col].sortable == "undefined"){
8264 return this.defaultSortable;
8266 return this.config[col].sortable;
8270 * Returns the rendering (formatting) function defined for the column.
8271 * @param {Number} col The column index.
8272 * @return {Function} The function used to render the cell. See {@link #setRenderer}.
8274 getRenderer : function(col){
8275 if(!this.config[col].renderer){
8276 return Roo.grid.ColumnModel.defaultRenderer;
8278 return this.config[col].renderer;
8282 * Sets the rendering (formatting) function for a column.
8283 * @param {Number} col The column index
8284 * @param {Function} fn The function to use to process the cell's raw data
8285 * to return HTML markup for the grid view. The render function is called with
8286 * the following parameters:<ul>
8287 * <li>Data value.</li>
8288 * <li>Cell metadata. An object in which you may set the following attributes:<ul>
8289 * <li>css A CSS style string to apply to the table cell.</li>
8290 * <li>attr An HTML attribute definition string to apply to the data container element <i>within</i> the table cell.</li></ul>
8291 * <li>The {@link Roo.data.Record} from which the data was extracted.</li>
8292 * <li>Row index</li>
8293 * <li>Column index</li>
8294 * <li>The {@link Roo.data.Store} object from which the Record was extracted</li></ul>
8296 setRenderer : function(col, fn){
8297 this.config[col].renderer = fn;
8301 * Returns the width for the specified column.
8302 * @param {Number} col The column index
8303 * @param (optional) {String} gridSize bootstrap width size.
8306 getColumnWidth : function(col, gridSize)
8308 var cfg = this.config[col];
8310 if (typeof(gridSize) == 'undefined') {
8311 return cfg.width * 1 || this.defaultWidth;
8313 if (gridSize === false) { // if we set it..
8314 return cfg.width || false;
8316 var sizes = ['xl', 'lg', 'md', 'sm', 'xs'];
8318 for(var i = sizes.indexOf(gridSize); i < sizes.length; i++) {
8319 if (typeof(cfg[ sizes[i] ] ) == 'undefined') {
8322 return cfg[ sizes[i] ];
8329 * Sets the width for a column.
8330 * @param {Number} col The column index
8331 * @param {Number} width The new width
8333 setColumnWidth : function(col, width, suppressEvent){
8334 this.config[col].width = width;
8335 this.totalWidth = null;
8337 this.fireEvent("widthchange", this, col, width);
8342 * Returns the total width of all columns.
8343 * @param {Boolean} includeHidden True to include hidden column widths
8346 getTotalWidth : function(includeHidden){
8347 if(!this.totalWidth){
8348 this.totalWidth = 0;
8349 for(var i = 0, len = this.config.length; i < len; i++){
8350 if(includeHidden || !this.isHidden(i)){
8351 this.totalWidth += this.getColumnWidth(i);
8355 return this.totalWidth;
8359 * Returns the header for the specified column.
8360 * @param {Number} col The column index
8363 getColumnHeader : function(col){
8364 return this.config[col].header;
8368 * Sets the header for a column.
8369 * @param {Number} col The column index
8370 * @param {String} header The new header
8372 setColumnHeader : function(col, header){
8373 this.config[col].header = header;
8374 this.fireEvent("headerchange", this, col, header);
8378 * Returns the tooltip for the specified column.
8379 * @param {Number} col The column index
8382 getColumnTooltip : function(col){
8383 return this.config[col].tooltip;
8386 * Sets the tooltip for a column.
8387 * @param {Number} col The column index
8388 * @param {String} tooltip The new tooltip
8390 setColumnTooltip : function(col, tooltip){
8391 this.config[col].tooltip = tooltip;
8395 * Returns the dataIndex for the specified column.
8396 * @param {Number} col The column index
8399 getDataIndex : function(col){
8400 return this.config[col].dataIndex;
8404 * Sets the dataIndex for a column.
8405 * @param {Number} col The column index
8406 * @param {Number} dataIndex The new dataIndex
8408 setDataIndex : function(col, dataIndex){
8409 this.config[col].dataIndex = dataIndex;
8415 * Returns true if the cell is editable.
8416 * @param {Number} colIndex The column index
8417 * @param {Number} rowIndex The row index - this is nto actually used..?
8420 isCellEditable : function(colIndex, rowIndex){
8421 return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
8425 * Returns the editor defined for the cell/column.
8426 * return false or null to disable editing.
8427 * @param {Number} colIndex The column index
8428 * @param {Number} rowIndex The row index
8431 getCellEditor : function(colIndex, rowIndex){
8432 return this.config[colIndex].editor;
8436 * Sets if a column is editable.
8437 * @param {Number} col The column index
8438 * @param {Boolean} editable True if the column is editable
8440 setEditable : function(col, editable){
8441 this.config[col].editable = editable;
8446 * Returns true if the column is hidden.
8447 * @param {Number} colIndex The column index
8450 isHidden : function(colIndex){
8451 return this.config[colIndex].hidden;
8456 * Returns true if the column width cannot be changed
8458 isFixed : function(colIndex){
8459 return this.config[colIndex].fixed;
8463 * Returns true if the column can be resized
8466 isResizable : function(colIndex){
8467 return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
8470 * Sets if a column is hidden.
8471 * @param {Number} colIndex The column index
8472 * @param {Boolean} hidden True if the column is hidden
8474 setHidden : function(colIndex, hidden){
8475 this.config[colIndex].hidden = hidden;
8476 this.totalWidth = null;
8477 this.fireEvent("hiddenchange", this, colIndex, hidden);
8481 * Sets the editor for a column.
8482 * @param {Number} col The column index
8483 * @param {Object} editor The editor object
8485 setEditor : function(col, editor){
8486 this.config[col].editor = editor;
8489 * Add a column (experimental...) - defaults to adding to the end..
8490 * @param {Object} config
8492 addColumn : function(c)
8495 var i = this.config.length;
8498 if(typeof c.dataIndex == "undefined"){
8501 if(typeof c.renderer == "string"){
8502 c.renderer = Roo.util.Format[c.renderer];
8504 if(typeof c.id == "undefined"){
8507 if(c.editor && c.editor.xtype){
8508 c.editor = Roo.factory(c.editor, Roo.grid);
8510 if(c.editor && c.editor.isFormField){
8511 c.editor = new Roo.grid.GridEditor(c.editor);
8513 this.lookup[c.id] = c;
8518 Roo.grid.ColumnModel.defaultRenderer = function(value)
8520 if(typeof value == "object") {
8523 if(typeof value == "string" && value.length < 1){
8527 return String.format("{0}", value);
8530 // Alias for backwards compatibility
8531 Roo.grid.DefaultColumnModel = Roo.grid.ColumnModel;
8534 * Ext JS Library 1.1.1
8535 * Copyright(c) 2006-2007, Ext JS, LLC.
8537 * Originally Released Under LGPL - original licence link has changed is not relivant.
8540 * <script type="text/javascript">
8544 * @class Roo.LoadMask
8545 * A simple utility class for generically masking elements while loading data. If the element being masked has
8546 * an underlying {@link Roo.data.Store}, the masking will be automatically synchronized with the store's loading
8547 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
8548 * element's UpdateManager load indicator and will be destroyed after the initial load.
8550 * Create a new LoadMask
8551 * @param {String/HTMLElement/Roo.Element} el The element or DOM node, or its id
8552 * @param {Object} config The config object
8554 Roo.LoadMask = function(el, config){
8555 this.el = Roo.get(el);
8556 Roo.apply(this, config);
8558 this.store.on('beforeload', this.onBeforeLoad, this);
8559 this.store.on('load', this.onLoad, this);
8560 this.store.on('loadexception', this.onLoadException, this);
8561 this.removeMask = false;
8563 var um = this.el.getUpdateManager();
8564 um.showLoadIndicator = false; // disable the default indicator
8565 um.on('beforeupdate', this.onBeforeLoad, this);
8566 um.on('update', this.onLoad, this);
8567 um.on('failure', this.onLoad, this);
8568 this.removeMask = true;
8572 Roo.LoadMask.prototype = {
8574 * @cfg {Boolean} removeMask
8575 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
8576 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
8581 * The text to display in a centered loading message box (defaults to 'Loading...')
8585 * @cfg {String} msgCls
8586 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
8588 msgCls : 'x-mask-loading',
8591 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
8597 * Disables the mask to prevent it from being displayed
8599 disable : function(){
8600 this.disabled = true;
8604 * Enables the mask so that it can be displayed
8606 enable : function(){
8607 this.disabled = false;
8610 onLoadException : function()
8614 if (typeof(arguments[3]) != 'undefined') {
8615 Roo.MessageBox.alert("Error loading",arguments[3]);
8619 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
8620 Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
8627 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
8632 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
8636 onBeforeLoad : function(){
8638 (function() { this.el.mask(this.msg, this.msgCls); }).defer(50, this);
8643 destroy : function(){
8645 this.store.un('beforeload', this.onBeforeLoad, this);
8646 this.store.un('load', this.onLoad, this);
8647 this.store.un('loadexception', this.onLoadException, this);
8649 var um = this.el.getUpdateManager();
8650 um.un('beforeupdate', this.onBeforeLoad, this);
8651 um.un('update', this.onLoad, this);
8652 um.un('failure', this.onLoad, this);
8656 * @class Roo.bootstrap.Table
8658 * @extends Roo.bootstrap.Component
8659 * Bootstrap Table class. This class represents the primary interface of a component based grid control.
8660 * Similar to Roo.grid.Grid
8662 var table = Roo.factory({
8664 xns : Roo.bootstrap,
8665 autoSizeColumns: true,
8672 sortInfo : { direction : 'ASC', field: 'name' },
8674 xtype : 'HttpProxy',
8677 url : 'https://example.com/some.data.url.json'
8680 xtype : 'JsonReader',
8682 fields : [ 'id', 'name', whatever' ],
8689 xtype : 'ColumnModel',
8693 dataIndex : 'is_in_group',
8696 renderer : function(v, x , r) {
8698 return String.format("{0}", v)
8704 xtype : 'RowSelectionModel',
8705 xns : Roo.bootstrap.Table
8706 // you can add listeners to catch selection change here....
8712 grid.render(Roo.get("some-div"));
8715 Currently the Table uses multiple headers to try and handle XL / Medium etc... styling
8720 * @cfg {Roo.grid.AbstractSelectionModel} sm The selection model to use (cell selection is not supported yet)
8721 * @cfg {Roo.data.Store} store The data store to use
8722 * @cfg {Roo.grid.ColumnModel} cm[] A column for th grid.
8724 * @cfg {String} cls table class
8727 * @cfg {boolean} striped Should the rows be alternative striped
8728 * @cfg {boolean} bordered Add borders to the table
8729 * @cfg {boolean} hover Add hover highlighting
8730 * @cfg {boolean} condensed Format condensed
8731 * @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,
8732 * also adds table-responsive (see bootstrap docs for details)
8733 * @cfg {Boolean} loadMask (true|false) default false
8734 * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
8735 * @cfg {Boolean} headerShow (true|false) generate thead, default true
8736 * @cfg {Boolean} rowSelection (true|false) default false
8737 * @cfg {Boolean} cellSelection (true|false) default false
8738 * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header
8739 * @cfg {Roo.bootstrap.PagingToolbar} footer a paging toolbar
8740 * @cfg {Boolean} lazyLoad auto load data while scrolling to the end (default false)
8741 * @cfg {Boolean} auto_hide_footer auto hide footer if only one page (default false)
8742 * @cfg {Boolean} enableColumnResize default true if columns can be resized (drag/drop)
8743 * @cfg {Number} minColumnWidth default 50 pixels minimum column width
8746 * Create a new Table
8747 * @param {Object} config The config object
8750 Roo.bootstrap.Table = function(config)
8752 Roo.bootstrap.Table.superclass.constructor.call(this, config);
8755 this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
8756 this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
8757 this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
8758 this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
8760 this.view = this; // compat with grid.
8762 this.sm = this.sm || {xtype: 'RowSelectionModel'};
8764 this.sm.grid = this;
8765 this.selModel = Roo.factory(this.sm, Roo.grid);
8766 this.sm = this.selModel;
8767 this.sm.xmodule = this.xmodule || false;
8770 if (this.cm && typeof(this.cm.config) == 'undefined') {
8771 this.colModel = new Roo.grid.ColumnModel(this.cm);
8772 this.cm = this.colModel;
8773 this.cm.xmodule = this.xmodule || false;
8776 this.store= Roo.factory(this.store, Roo.data);
8777 this.ds = this.store;
8778 this.ds.xmodule = this.xmodule || false;
8781 if (this.footer && this.store) {
8782 this.footer.dataSource = this.ds;
8783 this.footer = Roo.factory(this.footer);
8790 * Fires when a cell is clicked
8791 * @param {Roo.bootstrap.Table} this
8792 * @param {Roo.Element} el
8793 * @param {Number} rowIndex
8794 * @param {Number} columnIndex
8795 * @param {Roo.EventObject} e
8799 * @event celldblclick
8800 * Fires when a cell is double clicked
8801 * @param {Roo.bootstrap.Table} this
8802 * @param {Roo.Element} el
8803 * @param {Number} rowIndex
8804 * @param {Number} columnIndex
8805 * @param {Roo.EventObject} e
8807 "celldblclick" : true,
8810 * Fires when a row is clicked
8811 * @param {Roo.bootstrap.Table} this
8812 * @param {Roo.Element} el
8813 * @param {Number} rowIndex
8814 * @param {Roo.EventObject} e
8818 * @event rowdblclick
8819 * Fires when a row is double clicked
8820 * @param {Roo.bootstrap.Table} this
8821 * @param {Roo.Element} el
8822 * @param {Number} rowIndex
8823 * @param {Roo.EventObject} e
8825 "rowdblclick" : true,
8828 * Fires when a mouseover occur
8829 * @param {Roo.bootstrap.Table} this
8830 * @param {Roo.Element} el
8831 * @param {Number} rowIndex
8832 * @param {Number} columnIndex
8833 * @param {Roo.EventObject} e
8838 * Fires when a mouseout occur
8839 * @param {Roo.bootstrap.Table} this
8840 * @param {Roo.Element} el
8841 * @param {Number} rowIndex
8842 * @param {Number} columnIndex
8843 * @param {Roo.EventObject} e
8848 * Fires when a row is rendered, so you can change add a style to it.
8849 * @param {Roo.bootstrap.Table} this
8850 * @param {Object} rowcfg contains record rowIndex colIndex and rowClass - set rowClass to add a style.
8854 * @event rowsrendered
8855 * Fires when all the rows have been rendered
8856 * @param {Roo.bootstrap.Table} this
8858 'rowsrendered' : true,
8860 * @event contextmenu
8861 * The raw contextmenu event for the entire grid.
8862 * @param {Roo.EventObject} e
8864 "contextmenu" : true,
8866 * @event rowcontextmenu
8867 * Fires when a row is right clicked
8868 * @param {Roo.bootstrap.Table} this
8869 * @param {Number} rowIndex
8870 * @param {Roo.EventObject} e
8872 "rowcontextmenu" : true,
8874 * @event cellcontextmenu
8875 * Fires when a cell is right clicked
8876 * @param {Roo.bootstrap.Table} this
8877 * @param {Number} rowIndex
8878 * @param {Number} cellIndex
8879 * @param {Roo.EventObject} e
8881 "cellcontextmenu" : true,
8883 * @event headercontextmenu
8884 * Fires when a header is right clicked
8885 * @param {Roo.bootstrap.Table} this
8886 * @param {Number} columnIndex
8887 * @param {Roo.EventObject} e
8889 "headercontextmenu" : true,
8892 * The raw mousedown event for the entire grid.
8893 * @param {Roo.EventObject} e
8900 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
8916 enableColumnResize: true,
8918 rowSelection : false,
8919 cellSelection : false,
8922 minColumnWidth : 50,
8924 // Roo.Element - the tbody
8925 bodyEl: false, // <tbody> Roo.Element - thead element
8926 headEl: false, // <thead> Roo.Element - thead element
8927 resizeProxy : false, // proxy element for dragging?
8931 container: false, // used by gridpanel...
8937 auto_hide_footer : false,
8939 view: false, // actually points to this..
8941 getAutoCreate : function()
8943 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
8950 // this get's auto added by panel.Grid
8951 if (this.scrollBody) {
8952 cfg.cls += ' table-body-fixed';
8955 cfg.cls += ' table-striped';
8959 cfg.cls += ' table-hover';
8961 if (this.bordered) {
8962 cfg.cls += ' table-bordered';
8964 if (this.condensed) {
8965 cfg.cls += ' table-condensed';
8968 if (this.responsive) {
8969 cfg.cls += ' table-responsive';
8973 cfg.cls+= ' ' +this.cls;
8979 cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
8982 if(this.store || this.cm){
8983 if(this.headerShow){
8984 cfg.cn.push(this.renderHeader());
8987 cfg.cn.push(this.renderBody());
8989 if(this.footerShow){
8990 cfg.cn.push(this.renderFooter());
8992 // where does this come from?
8993 //cfg.cls+= ' TableGrid';
8996 return { cn : [ cfg ] };
8999 initEvents : function()
9001 if(!this.store || !this.cm){
9004 if (this.selModel) {
9005 this.selModel.initEvents();
9009 //Roo.log('initEvents with ds!!!!');
9011 this.bodyEl = this.el.select('tbody', true).first();
9012 this.headEl = this.el.select('thead', true).first();
9013 this.mainFoot = this.el.select('tfoot', true).first();
9018 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
9019 e.on('click', this.sort, this);
9023 // why is this done????? = it breaks dialogs??
9024 //this.parent().el.setStyle('position', 'relative');
9028 this.footer.parentId = this.id;
9029 this.footer.onRender(this.el.select('tfoot tr td').first(), null);
9032 this.el.select('tfoot tr td').first().addClass('hide');
9037 this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
9040 this.store.on('load', this.onLoad, this);
9041 this.store.on('beforeload', this.onBeforeLoad, this);
9042 this.store.on('update', this.onUpdate, this);
9043 this.store.on('add', this.onAdd, this);
9044 this.store.on("clear", this.clear, this);
9046 this.el.on("contextmenu", this.onContextMenu, this);
9049 this.cm.on("headerchange", this.onHeaderChange, this);
9050 this.cm.on("hiddenchange", this.onHiddenChange, this, arguments);
9052 //?? does bodyEl get replaced on render?
9053 this.bodyEl.on("click", this.onClick, this);
9054 this.bodyEl.on("dblclick", this.onDblClick, this);
9055 this.bodyEl.on('scroll', this.onBodyScroll, this);
9057 // guessing mainbody will work - this relays usually caught by selmodel at present.
9058 this.relayEvents(this.bodyEl, ["mousedown","mouseup","mouseover","mouseout","keypress"]);
9061 this.resizeProxy = Roo.get(document.body).createChild({ cls:"x-grid-resize-proxy", html: ' ' });
9064 if(this.headEl && this.enableColumnResize !== false && Roo.grid.SplitDragZone){
9065 new Roo.grid.SplitDragZone(this, this.headEl.dom, false); // not sure what 'lockedHd is for this implementation..)
9070 // Compatibility with grid - we implement all the view features at present.
9071 getView : function()
9076 initCSS : function()
9080 var cm = this.cm, styles = [];
9081 this.CSS.removeStyleSheet(this.id + '-cssrules');
9082 var headHeight = this.headEl ? this.headEl.dom.clientHeight : 0;
9083 // we can honour xs/sm/md/xl as widths...
9084 // we first have to decide what widht we are currently at...
9085 var sz = Roo.getGridSize();
9089 var cols = []; // visable cols.
9091 for(var i = 0, len = cm.getColumnCount(); i < len; i++) {
9092 var w = cm.getColumnWidth(i, false);
9094 cols.push( { rel : false, abs : 0 });
9098 cols.push( { rel : false, abs : w });
9100 last = i; // not really..
9103 var w = cm.getColumnWidth(i, sz);
9108 cols.push( { rel : w, abs : false });
9111 var avail = this.bodyEl.dom.clientWidth - total_abs;
9113 var unitWidth = Math.floor(avail / total);
9114 var rem = avail - (unitWidth * total);
9116 var hidden, width, pos = 0 , splithide , left;
9117 for(var i = 0, len = cm.getColumnCount(); i < len; i++) {
9119 hidden = 'display:none;';
9121 width = 'width:0px;';
9123 if(!cm.isHidden(i)){
9127 // we can honour xs/sm/md/xl ?
9128 var w = cols[i].rel == false ? cols[i].abs : (cols[i].rel * unitWidth);
9130 hidden = 'display:none;';
9132 // width should return a small number...
9134 w+=rem; // add the remaining with..
9137 left = "left:" + (pos -4) + "px;";
9138 width = "width:" + w+ "px;";
9141 if (this.responsive) {
9144 hidden = cm.isHidden(i) ? 'display:none;' : '';
9145 splithide = 'display: none;';
9148 styles.push( '#' , this.id , ' .x-col-' , i, " {", cm.config[i].css, width, hidden, "}\n" );
9151 splithide = 'display:none;';
9154 styles.push('#' , this.id , ' .x-hcol-' , i, " { ", width, hidden," }\n",
9155 '#' , this.id , ' .x-grid-split-' , i, " { ", left, splithide,'height:', (headHeight - 4), "px;}\n"
9160 //Roo.log(styles.join(''));
9161 this.CSS.createStyleSheet( styles.join(''), this.id + '-cssrules');
9167 onContextMenu : function(e, t)
9169 this.processEvent("contextmenu", e);
9172 processEvent : function(name, e)
9174 if (name != 'touchstart' ) {
9175 this.fireEvent(name, e);
9178 var t = e.getTarget();
9180 var cell = Roo.get(t);
9186 if(cell.findParent('tfoot', false, true)){
9190 if(cell.findParent('thead', false, true)){
9192 if(e.getTarget().nodeName.toLowerCase() != 'th'){
9193 cell = Roo.get(t).findParent('th', false, true);
9195 Roo.log("failed to find th in thead?");
9196 Roo.log(e.getTarget());
9201 var cellIndex = cell.dom.cellIndex;
9203 var ename = name == 'touchstart' ? 'click' : name;
9204 this.fireEvent("header" + ename, this, cellIndex, e);
9209 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9210 cell = Roo.get(t).findParent('td', false, true);
9212 Roo.log("failed to find th in tbody?");
9213 Roo.log(e.getTarget());
9218 var row = cell.findParent('tr', false, true);
9219 var cellIndex = cell.dom.cellIndex;
9220 var rowIndex = row.dom.rowIndex - 1;
9224 this.fireEvent("row" + name, this, rowIndex, e);
9228 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
9234 onMouseover : function(e, el)
9236 var cell = Roo.get(el);
9242 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9243 cell = cell.findParent('td', false, true);
9246 var row = cell.findParent('tr', false, true);
9247 var cellIndex = cell.dom.cellIndex;
9248 var rowIndex = row.dom.rowIndex - 1; // start from 0
9250 this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
9254 onMouseout : function(e, el)
9256 var cell = Roo.get(el);
9262 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9263 cell = cell.findParent('td', false, true);
9266 var row = cell.findParent('tr', false, true);
9267 var cellIndex = cell.dom.cellIndex;
9268 var rowIndex = row.dom.rowIndex - 1; // start from 0
9270 this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
9274 onClick : function(e, el)
9276 var cell = Roo.get(el);
9278 if(!cell || (!this.cellSelection && !this.rowSelection)){
9282 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9283 cell = cell.findParent('td', false, true);
9286 if(!cell || typeof(cell) == 'undefined'){
9290 var row = cell.findParent('tr', false, true);
9292 if(!row || typeof(row) == 'undefined'){
9296 var cellIndex = cell.dom.cellIndex;
9297 var rowIndex = this.getRowIndex(row);
9299 // why??? - should these not be based on SelectionModel?
9300 //if(this.cellSelection){
9301 this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
9304 //if(this.rowSelection){
9305 this.fireEvent('rowclick', this, row, rowIndex, e);
9310 onDblClick : function(e,el)
9312 var cell = Roo.get(el);
9314 if(!cell || (!this.cellSelection && !this.rowSelection)){
9318 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9319 cell = cell.findParent('td', false, true);
9322 if(!cell || typeof(cell) == 'undefined'){
9326 var row = cell.findParent('tr', false, true);
9328 if(!row || typeof(row) == 'undefined'){
9332 var cellIndex = cell.dom.cellIndex;
9333 var rowIndex = this.getRowIndex(row);
9335 if(this.cellSelection){
9336 this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
9339 if(this.rowSelection){
9340 this.fireEvent('rowdblclick', this, row, rowIndex, e);
9343 findRowIndex : function(el)
9345 var cell = Roo.get(el);
9349 var row = cell.findParent('tr', false, true);
9351 if(!row || typeof(row) == 'undefined'){
9354 return this.getRowIndex(row);
9356 sort : function(e,el)
9358 var col = Roo.get(el);
9360 if(!col.hasClass('sortable')){
9364 var sort = col.attr('sort');
9367 if(col.select('i', true).first().hasClass('fa-arrow-up')){
9371 this.store.sortInfo = {field : sort, direction : dir};
9374 Roo.log("calling footer first");
9375 this.footer.onClick('first');
9378 this.store.load({ params : { start : 0 } });
9382 renderHeader : function()
9390 this.totalWidth = 0;
9392 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
9394 var config = cm.config[i];
9398 cls : 'x-hcol-' + i,
9401 html: cm.getColumnHeader(i)
9404 var tooltip = cm.getColumnTooltip(i);
9406 c.tooltip = tooltip;
9412 if(typeof(config.sortable) != 'undefined' && config.sortable){
9413 c.cls += ' sortable';
9414 c.html = '<i class="fa"></i>' + c.html;
9417 // could use BS4 hidden-..-down
9419 if(typeof(config.lgHeader) != 'undefined'){
9420 hh += '<span class="hidden-xs hidden-sm hidden-md ">' + config.lgHeader + '</span>';
9423 if(typeof(config.mdHeader) != 'undefined'){
9424 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
9427 if(typeof(config.smHeader) != 'undefined'){
9428 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
9431 if(typeof(config.xsHeader) != 'undefined'){
9432 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
9439 if(typeof(config.tooltip) != 'undefined'){
9440 c.tooltip = config.tooltip;
9443 if(typeof(config.colspan) != 'undefined'){
9444 c.colspan = config.colspan;
9447 // hidden is handled by CSS now
9449 if(typeof(config.dataIndex) != 'undefined'){
9450 c.sort = config.dataIndex;
9455 if(typeof(config.align) != 'undefined' && config.align.length){
9456 c.style += ' text-align:' + config.align + ';';
9459 /* width is done in CSS
9460 *if(typeof(config.width) != 'undefined'){
9461 c.style += ' width:' + config.width + 'px;';
9462 this.totalWidth += config.width;
9464 this.totalWidth += 100; // assume minimum of 100 per column?
9468 if(typeof(config.cls) != 'undefined'){
9469 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
9471 // this is the bit that doesnt reall work at all...
9473 if (this.responsive) {
9476 ['xs','sm','md','lg'].map(function(size){
9478 if(typeof(config[size]) == 'undefined'){
9482 if (!config[size]) { // 0 = hidden
9483 // BS 4 '0' is treated as hide that column and below.
9484 c.cls += ' hidden-' + size + ' hidden' + size + '-down';
9488 c.cls += ' col-' + size + '-' + config[size] + (
9489 size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
9497 c.html +=' <span class="x-grid-split x-grid-split-' + i + '"></span>';
9508 renderBody : function()
9518 colspan : this.cm.getColumnCount()
9528 renderFooter : function()
9538 colspan : this.cm.getColumnCount()
9552 // Roo.log('ds onload');
9557 var ds = this.store;
9559 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
9560 e.select('i', true).removeClass(['fa-arrow-up', 'fa-arrow-down']);
9561 if (_this.store.sortInfo) {
9563 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
9564 e.select('i', true).addClass(['fa-arrow-up']);
9567 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
9568 e.select('i', true).addClass(['fa-arrow-down']);
9573 var tbody = this.bodyEl;
9575 if(ds.getCount() > 0){
9576 ds.data.each(function(d,rowIndex){
9577 var row = this.renderRow(cm, ds, rowIndex);
9579 tbody.createChild(row);
9583 if(row.cellObjects.length){
9584 Roo.each(row.cellObjects, function(r){
9585 _this.renderCellObject(r);
9592 var tfoot = this.el.select('tfoot', true).first();
9594 if(this.footerShow && this.auto_hide_footer && this.mainFoot){
9596 this.mainFoot.setVisibilityMode(Roo.Element.DISPLAY).hide();
9598 var total = this.ds.getTotalCount();
9600 if(this.footer.pageSize < total){
9601 this.mainFoot.show();
9605 Roo.each(this.el.select('tbody td', true).elements, function(e){
9606 e.on('mouseover', _this.onMouseover, _this);
9609 Roo.each(this.el.select('tbody td', true).elements, function(e){
9610 e.on('mouseout', _this.onMouseout, _this);
9612 this.fireEvent('rowsrendered', this);
9616 this.initCSS(); /// resize cols
9622 onUpdate : function(ds,record)
9624 this.refreshRow(record);
9628 onRemove : function(ds, record, index, isUpdate){
9629 if(isUpdate !== true){
9630 this.fireEvent("beforerowremoved", this, index, record);
9632 var bt = this.bodyEl.dom;
9634 var rows = this.el.select('tbody > tr', true).elements;
9636 if(typeof(rows[index]) != 'undefined'){
9637 bt.removeChild(rows[index].dom);
9640 // if(bt.rows[index]){
9641 // bt.removeChild(bt.rows[index]);
9644 if(isUpdate !== true){
9645 //this.stripeRows(index);
9646 //this.syncRowHeights(index, index);
9648 this.fireEvent("rowremoved", this, index, record);
9652 onAdd : function(ds, records, rowIndex)
9654 //Roo.log('on Add called');
9655 // - note this does not handle multiple adding very well..
9656 var bt = this.bodyEl.dom;
9657 for (var i =0 ; i < records.length;i++) {
9658 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
9659 //Roo.log(records[i]);
9660 //Roo.log(this.store.getAt(rowIndex+i));
9661 this.insertRow(this.store, rowIndex + i, false);
9668 refreshRow : function(record){
9669 var ds = this.store, index;
9670 if(typeof record == 'number'){
9672 record = ds.getAt(index);
9674 index = ds.indexOf(record);
9676 return; // should not happen - but seems to
9679 this.insertRow(ds, index, true);
9681 this.onRemove(ds, record, index+1, true);
9683 //this.syncRowHeights(index, index);
9685 this.fireEvent("rowupdated", this, index, record);
9687 // private - called by RowSelection
9688 onRowSelect : function(rowIndex){
9689 var row = this.getRowDom(rowIndex);
9690 row.addClass(['bg-info','info']);
9692 // private - called by RowSelection
9693 onRowDeselect : function(rowIndex)
9698 var row = this.getRowDom(rowIndex);
9699 row.removeClass(['bg-info','info']);
9702 * Focuses the specified row.
9703 * @param {Number} row The row index
9705 focusRow : function(row)
9707 //Roo.log('GridView.focusRow');
9708 var x = this.bodyEl.dom.scrollLeft;
9709 this.focusCell(row, 0, false);
9710 this.bodyEl.dom.scrollLeft = x;
9714 * Focuses the specified cell.
9715 * @param {Number} row The row index
9716 * @param {Number} col The column index
9717 * @param {Boolean} hscroll false to disable horizontal scrolling
9719 focusCell : function(row, col, hscroll)
9721 //Roo.log('GridView.focusCell');
9722 var el = this.ensureVisible(row, col, hscroll);
9723 // not sure what focusEL achives = it's a <a> pos relative
9724 //this.focusEl.alignTo(el, "tl-tl");
9726 // this.focusEl.focus();
9728 // this.focusEl.focus.defer(1, this.focusEl);
9733 * Scrolls the specified cell into view
9734 * @param {Number} row The row index
9735 * @param {Number} col The column index
9736 * @param {Boolean} hscroll false to disable horizontal scrolling
9738 ensureVisible : function(row, col, hscroll)
9740 //Roo.log('GridView.ensureVisible,' + row + ',' + col);
9741 //return null; //disable for testing.
9742 if(typeof row != "number"){
9745 if(row < 0 && row >= this.ds.getCount()){
9748 col = (col !== undefined ? col : 0);
9750 while(cm.isHidden(col)){
9754 var el = this.getCellDom(row, col);
9758 var c = this.bodyEl.dom;
9760 var ctop = parseInt(el.offsetTop, 10);
9761 var cleft = parseInt(el.offsetLeft, 10);
9762 var cbot = ctop + el.offsetHeight;
9763 var cright = cleft + el.offsetWidth;
9765 //var ch = c.clientHeight - this.mainHd.dom.offsetHeight;
9766 var ch = 0; //?? header is not withing the area?
9767 var stop = parseInt(c.scrollTop, 10);
9768 var sleft = parseInt(c.scrollLeft, 10);
9769 var sbot = stop + ch;
9770 var sright = sleft + c.clientWidth;
9772 Roo.log('GridView.ensureVisible:' +
9774 ' c.clientHeight:' + c.clientHeight +
9775 ' this.mainHd.dom.offsetHeight:' + this.mainHd.dom.offsetHeight +
9784 //Roo.log("set scrolltop to ctop DISABLE?");
9785 }else if(cbot > sbot){
9786 //Roo.log("set scrolltop to cbot-ch");
9787 c.scrollTop = cbot-ch;
9790 if(hscroll !== false){
9792 c.scrollLeft = cleft;
9793 }else if(cright > sright){
9794 c.scrollLeft = cright-c.clientWidth;
9802 insertRow : function(dm, rowIndex, isUpdate){
9805 this.fireEvent("beforerowsinserted", this, rowIndex);
9807 //var s = this.getScrollState();
9808 var row = this.renderRow(this.cm, this.store, rowIndex);
9809 // insert before rowIndex..
9810 var e = this.bodyEl.createChild(row,this.getRowDom(rowIndex));
9814 if(row.cellObjects.length){
9815 Roo.each(row.cellObjects, function(r){
9816 _this.renderCellObject(r);
9821 this.fireEvent("rowsinserted", this, rowIndex);
9822 //this.syncRowHeights(firstRow, lastRow);
9823 //this.stripeRows(firstRow);
9830 getRowDom : function(rowIndex)
9832 var rows = this.el.select('tbody > tr', true).elements;
9834 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
9837 getCellDom : function(rowIndex, colIndex)
9839 var row = this.getRowDom(rowIndex);
9840 if (row === false) {
9843 var cols = row.select('td', true).elements;
9844 return (typeof(cols[colIndex]) == 'undefined') ? false : cols[colIndex];
9848 // returns the object tree for a tr..
9851 renderRow : function(cm, ds, rowIndex)
9853 var d = ds.getAt(rowIndex);
9857 cls : 'x-row-' + rowIndex,
9861 var cellObjects = [];
9863 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
9864 var config = cm.config[i];
9866 var renderer = cm.getRenderer(i);
9870 if(typeof(renderer) !== 'undefined'){
9871 value = renderer(d.data[cm.getDataIndex(i)], false, d);
9873 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
9874 // and are rendered into the cells after the row is rendered - using the id for the element.
9876 if(typeof(value) === 'object'){
9886 rowIndex : rowIndex,
9891 this.fireEvent('rowclass', this, rowcfg);
9895 // this might end up displaying HTML?
9896 // this is too messy... - better to only do it on columsn you know are going to be too long
9897 //tooltip : (typeof(value) === 'object') ? '' : value,
9898 cls : rowcfg.rowClass + ' x-col-' + i,
9900 html: (typeof(value) === 'object') ? '' : value
9907 if(typeof(config.colspan) != 'undefined'){
9908 td.colspan = config.colspan;
9913 if(typeof(config.align) != 'undefined' && config.align.length){
9914 td.style += ' text-align:' + config.align + ';';
9916 if(typeof(config.valign) != 'undefined' && config.valign.length){
9917 td.style += ' vertical-align:' + config.valign + ';';
9920 if(typeof(config.width) != 'undefined'){
9921 td.style += ' width:' + config.width + 'px;';
9925 if(typeof(config.cursor) != 'undefined'){
9926 td.style += ' cursor:' + config.cursor + ';';
9929 if(typeof(config.cls) != 'undefined'){
9930 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
9932 if (this.responsive) {
9933 ['xs','sm','md','lg'].map(function(size){
9935 if(typeof(config[size]) == 'undefined'){
9941 if (!config[size]) { // 0 = hidden
9942 // BS 4 '0' is treated as hide that column and below.
9943 td.cls += ' hidden-' + size + ' hidden' + size + '-down';
9947 td.cls += ' col-' + size + '-' + config[size] + (
9948 size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
9958 row.cellObjects = cellObjects;
9966 onBeforeLoad : function()
9975 this.el.select('tbody', true).first().dom.innerHTML = '';
9978 * Show or hide a row.
9979 * @param {Number} rowIndex to show or hide
9980 * @param {Boolean} state hide
9982 setRowVisibility : function(rowIndex, state)
9984 var bt = this.bodyEl.dom;
9986 var rows = this.el.select('tbody > tr', true).elements;
9988 if(typeof(rows[rowIndex]) == 'undefined'){
9991 rows[rowIndex][ state ? 'removeClass' : 'addClass']('d-none');
9996 getSelectionModel : function(){
9998 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
10000 return this.selModel;
10003 * Render the Roo.bootstrap object from renderder
10005 renderCellObject : function(r)
10009 r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
10011 var t = r.cfg.render(r.container);
10014 Roo.each(r.cfg.cn, function(c){
10016 container: t.getChildContainer(),
10019 _this.renderCellObject(child);
10024 * get the Row Index from a dom element.
10025 * @param {Roo.Element} row The row to look for
10026 * @returns {Number} the row
10028 getRowIndex : function(row)
10032 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
10043 * get the header TH element for columnIndex
10044 * @param {Number} columnIndex
10045 * @returns {Roo.Element}
10047 getHeaderIndex: function(colIndex)
10049 var cols = this.headEl.select('th', true).elements;
10050 return cols[colIndex];
10053 * get the Column Index from a dom element. (using regex on x-hcol-{colid})
10054 * @param {domElement} cell to look for
10055 * @returns {Number} the column
10057 getCellIndex : function(cell)
10059 var id = String(cell.className).match(Roo.bootstrap.Table.cellRE);
10061 return parseInt(id[1], 10);
10066 * Returns the grid's underlying element = used by panel.Grid
10067 * @return {Element} The element
10069 getGridEl : function(){
10073 * Forces a resize - used by panel.Grid
10074 * @return {Element} The element
10076 autoSize : function()
10078 //var ctr = Roo.get(this.container.dom.parentElement);
10079 var ctr = Roo.get(this.el.dom);
10081 var thd = this.getGridEl().select('thead',true).first();
10082 var tbd = this.getGridEl().select('tbody', true).first();
10083 var tfd = this.getGridEl().select('tfoot', true).first();
10085 var cw = ctr.getWidth();
10086 this.getGridEl().select('tfoot tr, tfoot td',true).setWidth(cw);
10090 tbd.setWidth(ctr.getWidth());
10091 // if the body has a max height - and then scrolls - we should perhaps set up the height here
10092 // this needs fixing for various usage - currently only hydra job advers I think..
10094 // ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
10096 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
10099 cw = Math.max(cw, this.totalWidth);
10100 this.getGridEl().select('tbody tr',true).setWidth(cw);
10103 // resize 'expandable coloumn?
10105 return; // we doe not have a view in this design..
10108 onBodyScroll: function()
10110 //Roo.log("body scrolled');" + this.bodyEl.dom.scrollLeft);
10112 this.headEl.setStyle({
10113 'position' : 'relative',
10114 'left': (-1* this.bodyEl.dom.scrollLeft) + 'px'
10120 var scrollHeight = this.bodyEl.dom.scrollHeight;
10122 var scrollTop = Math.ceil(this.bodyEl.getScroll().top);
10124 var height = this.bodyEl.getHeight();
10126 if(scrollHeight - height == scrollTop) {
10128 var total = this.ds.getTotalCount();
10130 if(this.footer.cursor + this.footer.pageSize < total){
10132 this.footer.ds.load({
10134 start : this.footer.cursor + this.footer.pageSize,
10135 limit : this.footer.pageSize
10144 onColumnSplitterMoved : function(i, diff)
10146 this.userResized = true;
10148 var cm = this.colModel;
10150 var w = this.getHeaderIndex(i).getWidth() + diff;
10153 cm.setColumnWidth(i, w, true);
10155 //var cid = cm.getColumnId(i); << not used in this version?
10156 /* Roo.log(['#' + this.id + ' .x-col-' + i, "width", w + "px"]);
10158 this.CSS.updateRule( '#' + this.id + ' .x-col-' + i, "width", w + "px");
10159 this.CSS.updateRule('#' + this.id + ' .x-hcol-' + i, "width", w + "px");
10160 this.CSS.updateRule('#' + this.id + ' .x-grid-split-' + i, "left", w + "px");
10162 //this.updateSplitters();
10163 //this.layout(); << ??
10164 this.fireEvent("columnresize", i, w);
10166 onHeaderChange : function()
10168 var header = this.renderHeader();
10169 var table = this.el.select('table', true).first();
10171 this.headEl.remove();
10172 this.headEl = table.createChild(header, this.bodyEl, false);
10174 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
10175 e.on('click', this.sort, this);
10178 if(this.enableColumnResize !== false && Roo.grid.SplitDragZone){
10179 new Roo.grid.SplitDragZone(this, this.headEl.dom, false); // not sure what 'lockedHd is for this implementation..)
10184 onHiddenChange : function(colModel, colIndex, hidden)
10187 this.cm.setHidden()
10188 var thSelector = '#' + this.id + ' .x-hcol-' + colIndex;
10189 var tdSelector = '#' + this.id + ' .x-col-' + colIndex;
10191 this.CSS.updateRule(thSelector, "display", "");
10192 this.CSS.updateRule(tdSelector, "display", "");
10195 this.CSS.updateRule(thSelector, "display", "none");
10196 this.CSS.updateRule(tdSelector, "display", "none");
10199 // onload calls initCSS()
10200 this.onHeaderChange();
10204 setColumnWidth: function(col_index, width)
10206 // width = "md-2 xs-2..."
10207 if(!this.colModel.config[col_index]) {
10211 var w = width.split(" ");
10213 var rows = this.el.dom.getElementsByClassName("x-col-"+col_index);
10215 var h_row = this.el.dom.getElementsByClassName("x-hcol-"+col_index);
10218 for(var j = 0; j < w.length; j++) {
10224 var size_cls = w[j].split("-");
10226 if(!Number.isInteger(size_cls[1] * 1)) {
10230 if(!this.colModel.config[col_index][size_cls[0]]) {
10234 if(!h_row[0].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
10238 h_row[0].classList.replace(
10239 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
10240 "col-"+size_cls[0]+"-"+size_cls[1]
10243 for(var i = 0; i < rows.length; i++) {
10245 var size_cls = w[j].split("-");
10247 if(!Number.isInteger(size_cls[1] * 1)) {
10251 if(!this.colModel.config[col_index][size_cls[0]]) {
10255 if(!rows[i].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
10259 rows[i].classList.replace(
10260 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
10261 "col-"+size_cls[0]+"-"+size_cls[1]
10265 this.colModel.config[col_index][size_cls[0]] = size_cls[1];
10270 // currently only used to find the split on drag..
10271 Roo.bootstrap.Table.cellRE = /(?:.*?)x-grid-(?:hd|cell|split)-([\d]+)(?:.*?)/;
10276 Roo.bootstrap.Table.AbstractSelectionModel = Roo.grid.AbstractSelectionModel;
10277 Roo.bootstrap.Table.RowSelectionModel = Roo.grid.RowSelectionModel;
10286 * @class Roo.bootstrap.TableCell
10287 * @extends Roo.bootstrap.Component
10288 * Bootstrap TableCell class
10289 * @cfg {String} html cell contain text
10290 * @cfg {String} cls cell class
10291 * @cfg {String} tag cell tag (td|th) default td
10292 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
10293 * @cfg {String} align Aligns the content in a cell
10294 * @cfg {String} axis Categorizes cells
10295 * @cfg {String} bgcolor Specifies the background color of a cell
10296 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
10297 * @cfg {Number} colspan Specifies the number of columns a cell should span
10298 * @cfg {String} headers Specifies one or more header cells a cell is related to
10299 * @cfg {Number} height Sets the height of a cell
10300 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
10301 * @cfg {Number} rowspan Sets the number of rows a cell should span
10302 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
10303 * @cfg {String} valign Vertical aligns the content in a cell
10304 * @cfg {Number} width Specifies the width of a cell
10307 * Create a new TableCell
10308 * @param {Object} config The config object
10311 Roo.bootstrap.TableCell = function(config){
10312 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
10315 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
10335 getAutoCreate : function(){
10336 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
10343 cfg.tag = this.tag;
10356 cfg.align=this.align
10361 if (this.bgcolor) {
10362 cfg.bgcolor=this.bgcolor
10364 if (this.charoff) {
10365 cfg.charoff=this.charoff
10367 if (this.colspan) {
10368 cfg.colspan=this.colspan
10370 if (this.headers) {
10371 cfg.headers=this.headers
10374 cfg.height=this.height
10377 cfg.nowrap=this.nowrap
10379 if (this.rowspan) {
10380 cfg.rowspan=this.rowspan
10383 cfg.scope=this.scope
10386 cfg.valign=this.valign
10389 cfg.width=this.width
10408 * @class Roo.bootstrap.TableRow
10409 * @extends Roo.bootstrap.Component
10410 * Bootstrap TableRow class
10411 * @cfg {String} cls row class
10412 * @cfg {String} align Aligns the content in a table row
10413 * @cfg {String} bgcolor Specifies a background color for a table row
10414 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
10415 * @cfg {String} valign Vertical aligns the content in a table row
10418 * Create a new TableRow
10419 * @param {Object} config The config object
10422 Roo.bootstrap.TableRow = function(config){
10423 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
10426 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
10434 getAutoCreate : function(){
10435 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
10442 cfg.cls = this.cls;
10445 cfg.align = this.align;
10448 cfg.bgcolor = this.bgcolor;
10451 cfg.charoff = this.charoff;
10454 cfg.valign = this.valign;
10472 * @class Roo.bootstrap.TableBody
10473 * @extends Roo.bootstrap.Component
10474 * Bootstrap TableBody class
10475 * @cfg {String} cls element class
10476 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
10477 * @cfg {String} align Aligns the content inside the element
10478 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
10479 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
10482 * Create a new TableBody
10483 * @param {Object} config The config object
10486 Roo.bootstrap.TableBody = function(config){
10487 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
10490 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
10498 getAutoCreate : function(){
10499 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
10509 cfg.tag = this.tag;
10513 cfg.align = this.align;
10516 cfg.charoff = this.charoff;
10519 cfg.valign = this.valign;
10526 // initEvents : function()
10529 // if(!this.store){
10533 // this.store = Roo.factory(this.store, Roo.data);
10534 // this.store.on('load', this.onLoad, this);
10536 // this.store.load();
10540 // onLoad: function ()
10542 // this.fireEvent('load', this);
10552 * Ext JS Library 1.1.1
10553 * Copyright(c) 2006-2007, Ext JS, LLC.
10555 * Originally Released Under LGPL - original licence link has changed is not relivant.
10558 * <script type="text/javascript">
10561 // as we use this in bootstrap.
10562 Roo.namespace('Roo.form');
10564 * @class Roo.form.Action
10565 * Internal Class used to handle form actions
10567 * @param {Roo.form.BasicForm} el The form element or its id
10568 * @param {Object} config Configuration options
10573 // define the action interface
10574 Roo.form.Action = function(form, options){
10576 this.options = options || {};
10579 * Client Validation Failed
10582 Roo.form.Action.CLIENT_INVALID = 'client';
10584 * Server Validation Failed
10587 Roo.form.Action.SERVER_INVALID = 'server';
10589 * Connect to Server Failed
10592 Roo.form.Action.CONNECT_FAILURE = 'connect';
10594 * Reading Data from Server Failed
10597 Roo.form.Action.LOAD_FAILURE = 'load';
10599 Roo.form.Action.prototype = {
10601 failureType : undefined,
10602 response : undefined,
10603 result : undefined,
10605 // interface method
10606 run : function(options){
10610 // interface method
10611 success : function(response){
10615 // interface method
10616 handleResponse : function(response){
10620 // default connection failure
10621 failure : function(response){
10623 this.response = response;
10624 this.failureType = Roo.form.Action.CONNECT_FAILURE;
10625 this.form.afterAction(this, false);
10628 processResponse : function(response){
10629 this.response = response;
10630 if(!response.responseText){
10633 this.result = this.handleResponse(response);
10634 return this.result;
10637 // utility functions used internally
10638 getUrl : function(appendParams){
10639 var url = this.options.url || this.form.url || this.form.el.dom.action;
10641 var p = this.getParams();
10643 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
10649 getMethod : function(){
10650 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
10653 getParams : function(){
10654 var bp = this.form.baseParams;
10655 var p = this.options.params;
10657 if(typeof p == "object"){
10658 p = Roo.urlEncode(Roo.applyIf(p, bp));
10659 }else if(typeof p == 'string' && bp){
10660 p += '&' + Roo.urlEncode(bp);
10663 p = Roo.urlEncode(bp);
10668 createCallback : function(){
10670 success: this.success,
10671 failure: this.failure,
10673 timeout: (this.form.timeout*1000),
10674 upload: this.form.fileUpload ? this.success : undefined
10679 Roo.form.Action.Submit = function(form, options){
10680 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
10683 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
10686 haveProgress : false,
10687 uploadComplete : false,
10689 // uploadProgress indicator.
10690 uploadProgress : function()
10692 if (!this.form.progressUrl) {
10696 if (!this.haveProgress) {
10697 Roo.MessageBox.progress("Uploading", "Uploading");
10699 if (this.uploadComplete) {
10700 Roo.MessageBox.hide();
10704 this.haveProgress = true;
10706 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
10708 var c = new Roo.data.Connection();
10710 url : this.form.progressUrl,
10715 success : function(req){
10716 //console.log(data);
10720 rdata = Roo.decode(req.responseText)
10722 Roo.log("Invalid data from server..");
10726 if (!rdata || !rdata.success) {
10728 Roo.MessageBox.alert(Roo.encode(rdata));
10731 var data = rdata.data;
10733 if (this.uploadComplete) {
10734 Roo.MessageBox.hide();
10739 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
10740 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
10743 this.uploadProgress.defer(2000,this);
10746 failure: function(data) {
10747 Roo.log('progress url failed ');
10758 // run get Values on the form, so it syncs any secondary forms.
10759 this.form.getValues();
10761 var o = this.options;
10762 var method = this.getMethod();
10763 var isPost = method == 'POST';
10764 if(o.clientValidation === false || this.form.isValid()){
10766 if (this.form.progressUrl) {
10767 this.form.findField('UPLOAD_IDENTIFIER').setValue(
10768 (new Date() * 1) + '' + Math.random());
10773 Roo.Ajax.request(Roo.apply(this.createCallback(), {
10774 form:this.form.el.dom,
10775 url:this.getUrl(!isPost),
10777 params:isPost ? this.getParams() : null,
10778 isUpload: this.form.fileUpload,
10779 formData : this.form.formData
10782 this.uploadProgress();
10784 }else if (o.clientValidation !== false){ // client validation failed
10785 this.failureType = Roo.form.Action.CLIENT_INVALID;
10786 this.form.afterAction(this, false);
10790 success : function(response)
10792 this.uploadComplete= true;
10793 if (this.haveProgress) {
10794 Roo.MessageBox.hide();
10798 var result = this.processResponse(response);
10799 if(result === true || result.success){
10800 this.form.afterAction(this, true);
10804 this.form.markInvalid(result.errors);
10805 this.failureType = Roo.form.Action.SERVER_INVALID;
10807 this.form.afterAction(this, false);
10809 failure : function(response)
10811 this.uploadComplete= true;
10812 if (this.haveProgress) {
10813 Roo.MessageBox.hide();
10816 this.response = response;
10817 this.failureType = Roo.form.Action.CONNECT_FAILURE;
10818 this.form.afterAction(this, false);
10821 handleResponse : function(response){
10822 if(this.form.errorReader){
10823 var rs = this.form.errorReader.read(response);
10826 for(var i = 0, len = rs.records.length; i < len; i++) {
10827 var r = rs.records[i];
10828 errors[i] = r.data;
10831 if(errors.length < 1){
10835 success : rs.success,
10841 ret = Roo.decode(response.responseText);
10845 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
10855 Roo.form.Action.Load = function(form, options){
10856 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
10857 this.reader = this.form.reader;
10860 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
10865 Roo.Ajax.request(Roo.apply(
10866 this.createCallback(), {
10867 method:this.getMethod(),
10868 url:this.getUrl(false),
10869 params:this.getParams()
10873 success : function(response){
10875 var result = this.processResponse(response);
10876 if(result === true || !result.success || !result.data){
10877 this.failureType = Roo.form.Action.LOAD_FAILURE;
10878 this.form.afterAction(this, false);
10881 this.form.clearInvalid();
10882 this.form.setValues(result.data);
10883 this.form.afterAction(this, true);
10886 handleResponse : function(response){
10887 if(this.form.reader){
10888 var rs = this.form.reader.read(response);
10889 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
10891 success : rs.success,
10895 return Roo.decode(response.responseText);
10899 Roo.form.Action.ACTION_TYPES = {
10900 'load' : Roo.form.Action.Load,
10901 'submit' : Roo.form.Action.Submit
10910 * @class Roo.bootstrap.Form
10911 * @extends Roo.bootstrap.Component
10912 * Bootstrap Form class
10913 * @cfg {String} method GET | POST (default POST)
10914 * @cfg {String} labelAlign top | left (default top)
10915 * @cfg {String} align left | right - for navbars
10916 * @cfg {Boolean} loadMask load mask when submit (default true)
10920 * Create a new Form
10921 * @param {Object} config The config object
10925 Roo.bootstrap.Form = function(config){
10927 Roo.bootstrap.Form.superclass.constructor.call(this, config);
10929 Roo.bootstrap.Form.popover.apply();
10933 * @event clientvalidation
10934 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
10935 * @param {Form} this
10936 * @param {Boolean} valid true if the form has passed client-side validation
10938 clientvalidation: true,
10940 * @event beforeaction
10941 * Fires before any action is performed. Return false to cancel the action.
10942 * @param {Form} this
10943 * @param {Action} action The action to be performed
10945 beforeaction: true,
10947 * @event actionfailed
10948 * Fires when an action fails.
10949 * @param {Form} this
10950 * @param {Action} action The action that failed
10952 actionfailed : true,
10954 * @event actioncomplete
10955 * Fires when an action is completed.
10956 * @param {Form} this
10957 * @param {Action} action The action that completed
10959 actioncomplete : true
10963 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
10966 * @cfg {String} method
10967 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
10971 * @cfg {String} url
10972 * The URL to use for form actions if one isn't supplied in the action options.
10975 * @cfg {Boolean} fileUpload
10976 * Set to true if this form is a file upload.
10980 * @cfg {Object} baseParams
10981 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
10985 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
10989 * @cfg {Sting} align (left|right) for navbar forms
10994 activeAction : null,
10997 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
10998 * element by passing it or its id or mask the form itself by passing in true.
11001 waitMsgTarget : false,
11006 * @cfg {Boolean} errorMask (true|false) default false
11011 * @cfg {Number} maskOffset Default 100
11016 * @cfg {Boolean} maskBody
11020 getAutoCreate : function(){
11024 method : this.method || 'POST',
11025 id : this.id || Roo.id(),
11028 if (this.parent().xtype.match(/^Nav/)) {
11029 cfg.cls = 'navbar-form form-inline navbar-' + this.align;
11033 if (this.labelAlign == 'left' ) {
11034 cfg.cls += ' form-horizontal';
11040 initEvents : function()
11042 this.el.on('submit', this.onSubmit, this);
11043 // this was added as random key presses on the form where triggering form submit.
11044 this.el.on('keypress', function(e) {
11045 if (e.getCharCode() != 13) {
11048 // we might need to allow it for textareas.. and some other items.
11049 // check e.getTarget().
11051 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
11055 Roo.log("keypress blocked");
11057 e.preventDefault();
11063 onSubmit : function(e){
11068 * Returns true if client-side validation on the form is successful.
11071 isValid : function(){
11072 var items = this.getItems();
11074 var target = false;
11076 items.each(function(f){
11082 Roo.log('invalid field: ' + f.name);
11086 if(!target && f.el.isVisible(true)){
11092 if(this.errorMask && !valid){
11093 Roo.bootstrap.Form.popover.mask(this, target);
11100 * Returns true if any fields in this form have changed since their original load.
11103 isDirty : function(){
11105 var items = this.getItems();
11106 items.each(function(f){
11116 * Performs a predefined action (submit or load) or custom actions you define on this form.
11117 * @param {String} actionName The name of the action type
11118 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
11119 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
11120 * accept other config options):
11122 Property Type Description
11123 ---------------- --------------- ----------------------------------------------------------------------------------
11124 url String The url for the action (defaults to the form's url)
11125 method String The form method to use (defaults to the form's method, or POST if not defined)
11126 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
11127 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
11128 validate the form on the client (defaults to false)
11130 * @return {BasicForm} this
11132 doAction : function(action, options){
11133 if(typeof action == 'string'){
11134 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
11136 if(this.fireEvent('beforeaction', this, action) !== false){
11137 this.beforeAction(action);
11138 action.run.defer(100, action);
11144 beforeAction : function(action){
11145 var o = action.options;
11150 Roo.get(document.body).mask(o.waitMsg || "Sending", 'x-mask-loading')
11152 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
11155 // not really supported yet.. ??
11157 //if(this.waitMsgTarget === true){
11158 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
11159 //}else if(this.waitMsgTarget){
11160 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
11161 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
11163 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
11169 afterAction : function(action, success){
11170 this.activeAction = null;
11171 var o = action.options;
11176 Roo.get(document.body).unmask();
11182 //if(this.waitMsgTarget === true){
11183 // this.el.unmask();
11184 //}else if(this.waitMsgTarget){
11185 // this.waitMsgTarget.unmask();
11187 // Roo.MessageBox.updateProgress(1);
11188 // Roo.MessageBox.hide();
11195 Roo.callback(o.success, o.scope, [this, action]);
11196 this.fireEvent('actioncomplete', this, action);
11200 // failure condition..
11201 // we have a scenario where updates need confirming.
11202 // eg. if a locking scenario exists..
11203 // we look for { errors : { needs_confirm : true }} in the response.
11205 (typeof(action.result) != 'undefined') &&
11206 (typeof(action.result.errors) != 'undefined') &&
11207 (typeof(action.result.errors.needs_confirm) != 'undefined')
11210 Roo.log("not supported yet");
11213 Roo.MessageBox.confirm(
11214 "Change requires confirmation",
11215 action.result.errorMsg,
11220 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
11230 Roo.callback(o.failure, o.scope, [this, action]);
11231 // show an error message if no failed handler is set..
11232 if (!this.hasListener('actionfailed')) {
11233 Roo.log("need to add dialog support");
11235 Roo.MessageBox.alert("Error",
11236 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
11237 action.result.errorMsg :
11238 "Saving Failed, please check your entries or try again"
11243 this.fireEvent('actionfailed', this, action);
11248 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
11249 * @param {String} id The value to search for
11252 findField : function(id){
11253 var items = this.getItems();
11254 var field = items.get(id);
11256 items.each(function(f){
11257 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
11264 return field || null;
11267 * Mark fields in this form invalid in bulk.
11268 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
11269 * @return {BasicForm} this
11271 markInvalid : function(errors){
11272 if(errors instanceof Array){
11273 for(var i = 0, len = errors.length; i < len; i++){
11274 var fieldError = errors[i];
11275 var f = this.findField(fieldError.id);
11277 f.markInvalid(fieldError.msg);
11283 if(typeof errors[id] != 'function' && (field = this.findField(id))){
11284 field.markInvalid(errors[id]);
11288 //Roo.each(this.childForms || [], function (f) {
11289 // f.markInvalid(errors);
11296 * Set values for fields in this form in bulk.
11297 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
11298 * @return {BasicForm} this
11300 setValues : function(values){
11301 if(values instanceof Array){ // array of objects
11302 for(var i = 0, len = values.length; i < len; i++){
11304 var f = this.findField(v.id);
11306 f.setValue(v.value);
11307 if(this.trackResetOnLoad){
11308 f.originalValue = f.getValue();
11312 }else{ // object hash
11315 if(typeof values[id] != 'function' && (field = this.findField(id))){
11317 if (field.setFromData &&
11318 field.valueField &&
11319 field.displayField &&
11320 // combos' with local stores can
11321 // be queried via setValue()
11322 // to set their value..
11323 (field.store && !field.store.isLocal)
11327 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
11328 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
11329 field.setFromData(sd);
11331 } else if(field.setFromData && (field.store && !field.store.isLocal)) {
11333 field.setFromData(values);
11336 field.setValue(values[id]);
11340 if(this.trackResetOnLoad){
11341 field.originalValue = field.getValue();
11347 //Roo.each(this.childForms || [], function (f) {
11348 // f.setValues(values);
11355 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
11356 * they are returned as an array.
11357 * @param {Boolean} asString
11360 getValues : function(asString){
11361 //if (this.childForms) {
11362 // copy values from the child forms
11363 // Roo.each(this.childForms, function (f) {
11364 // this.setValues(f.getValues());
11370 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
11371 if(asString === true){
11374 return Roo.urlDecode(fs);
11378 * Returns the fields in this form as an object with key/value pairs.
11379 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
11382 getFieldValues : function(with_hidden)
11384 var items = this.getItems();
11386 items.each(function(f){
11388 if (!f.getName()) {
11392 var v = f.getValue();
11394 if (f.inputType =='radio') {
11395 if (typeof(ret[f.getName()]) == 'undefined') {
11396 ret[f.getName()] = ''; // empty..
11399 if (!f.el.dom.checked) {
11403 v = f.el.dom.value;
11407 if(f.xtype == 'MoneyField'){
11408 ret[f.currencyName] = f.getCurrency();
11411 // not sure if this supported any more..
11412 if ((typeof(v) == 'object') && f.getRawValue) {
11413 v = f.getRawValue() ; // dates..
11415 // combo boxes where name != hiddenName...
11416 if (f.name !== false && f.name != '' && f.name != f.getName()) {
11417 ret[f.name] = f.getRawValue();
11419 ret[f.getName()] = v;
11426 * Clears all invalid messages in this form.
11427 * @return {BasicForm} this
11429 clearInvalid : function(){
11430 var items = this.getItems();
11432 items.each(function(f){
11440 * Resets this form.
11441 * @return {BasicForm} this
11443 reset : function(){
11444 var items = this.getItems();
11445 items.each(function(f){
11449 Roo.each(this.childForms || [], function (f) {
11457 getItems : function()
11459 var r=new Roo.util.MixedCollection(false, function(o){
11460 return o.id || (o.id = Roo.id());
11462 var iter = function(el) {
11469 Roo.each(el.items,function(e) {
11478 hideFields : function(items)
11480 Roo.each(items, function(i){
11482 var f = this.findField(i);
11493 showFields : function(items)
11495 Roo.each(items, function(i){
11497 var f = this.findField(i);
11510 Roo.apply(Roo.bootstrap.Form, {
11526 intervalID : false,
11532 if(this.isApplied){
11537 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
11538 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
11539 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
11540 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
11543 this.maskEl.top.enableDisplayMode("block");
11544 this.maskEl.left.enableDisplayMode("block");
11545 this.maskEl.bottom.enableDisplayMode("block");
11546 this.maskEl.right.enableDisplayMode("block");
11548 this.toolTip = new Roo.bootstrap.Tooltip({
11549 cls : 'roo-form-error-popover',
11551 'left' : ['r-l', [-2,0], 'right'],
11552 'right' : ['l-r', [2,0], 'left'],
11553 'bottom' : ['tl-bl', [0,2], 'top'],
11554 'top' : [ 'bl-tl', [0,-2], 'bottom']
11558 this.toolTip.render(Roo.get(document.body));
11560 this.toolTip.el.enableDisplayMode("block");
11562 Roo.get(document.body).on('click', function(){
11566 Roo.get(document.body).on('touchstart', function(){
11570 this.isApplied = true
11573 mask : function(form, target)
11577 this.target = target;
11579 if(!this.form.errorMask || !target.el){
11583 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
11585 Roo.log(scrollable);
11587 var ot = this.target.el.calcOffsetsTo(scrollable);
11589 var scrollTo = ot[1] - this.form.maskOffset;
11591 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
11593 scrollable.scrollTo('top', scrollTo);
11595 var box = this.target.el.getBox();
11597 var zIndex = Roo.bootstrap.Modal.zIndex++;
11600 this.maskEl.top.setStyle('position', 'absolute');
11601 this.maskEl.top.setStyle('z-index', zIndex);
11602 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
11603 this.maskEl.top.setLeft(0);
11604 this.maskEl.top.setTop(0);
11605 this.maskEl.top.show();
11607 this.maskEl.left.setStyle('position', 'absolute');
11608 this.maskEl.left.setStyle('z-index', zIndex);
11609 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
11610 this.maskEl.left.setLeft(0);
11611 this.maskEl.left.setTop(box.y - this.padding);
11612 this.maskEl.left.show();
11614 this.maskEl.bottom.setStyle('position', 'absolute');
11615 this.maskEl.bottom.setStyle('z-index', zIndex);
11616 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
11617 this.maskEl.bottom.setLeft(0);
11618 this.maskEl.bottom.setTop(box.bottom + this.padding);
11619 this.maskEl.bottom.show();
11621 this.maskEl.right.setStyle('position', 'absolute');
11622 this.maskEl.right.setStyle('z-index', zIndex);
11623 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
11624 this.maskEl.right.setLeft(box.right + this.padding);
11625 this.maskEl.right.setTop(box.y - this.padding);
11626 this.maskEl.right.show();
11628 this.toolTip.bindEl = this.target.el;
11630 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
11632 var tip = this.target.blankText;
11634 if(this.target.getValue() !== '' ) {
11636 if (this.target.invalidText.length) {
11637 tip = this.target.invalidText;
11638 } else if (this.target.regexText.length){
11639 tip = this.target.regexText;
11643 this.toolTip.show(tip);
11645 this.intervalID = window.setInterval(function() {
11646 Roo.bootstrap.Form.popover.unmask();
11649 window.onwheel = function(){ return false;};
11651 (function(){ this.isMasked = true; }).defer(500, this);
11655 unmask : function()
11657 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
11661 this.maskEl.top.setStyle('position', 'absolute');
11662 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
11663 this.maskEl.top.hide();
11665 this.maskEl.left.setStyle('position', 'absolute');
11666 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
11667 this.maskEl.left.hide();
11669 this.maskEl.bottom.setStyle('position', 'absolute');
11670 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
11671 this.maskEl.bottom.hide();
11673 this.maskEl.right.setStyle('position', 'absolute');
11674 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
11675 this.maskEl.right.hide();
11677 this.toolTip.hide();
11679 this.toolTip.el.hide();
11681 window.onwheel = function(){ return true;};
11683 if(this.intervalID){
11684 window.clearInterval(this.intervalID);
11685 this.intervalID = false;
11688 this.isMasked = false;
11698 * Ext JS Library 1.1.1
11699 * Copyright(c) 2006-2007, Ext JS, LLC.
11701 * Originally Released Under LGPL - original licence link has changed is not relivant.
11704 * <script type="text/javascript">
11707 * @class Roo.form.VTypes
11708 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
11711 Roo.form.VTypes = function(){
11712 // closure these in so they are only created once.
11713 var alpha = /^[a-zA-Z_]+$/;
11714 var alphanum = /^[a-zA-Z0-9_]+$/;
11715 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
11716 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
11718 // All these messages and functions are configurable
11721 * The function used to validate email addresses
11722 * @param {String} value The email address
11724 'email' : function(v){
11725 return email.test(v);
11728 * The error text to display when the email validation function returns false
11731 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
11733 * The keystroke filter mask to be applied on email input
11736 'emailMask' : /[a-z0-9_\.\-@]/i,
11739 * The function used to validate URLs
11740 * @param {String} value The URL
11742 'url' : function(v){
11743 return url.test(v);
11746 * The error text to display when the url validation function returns false
11749 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
11752 * The function used to validate alpha values
11753 * @param {String} value The value
11755 'alpha' : function(v){
11756 return alpha.test(v);
11759 * The error text to display when the alpha validation function returns false
11762 'alphaText' : 'This field should only contain letters and _',
11764 * The keystroke filter mask to be applied on alpha input
11767 'alphaMask' : /[a-z_]/i,
11770 * The function used to validate alphanumeric values
11771 * @param {String} value The value
11773 'alphanum' : function(v){
11774 return alphanum.test(v);
11777 * The error text to display when the alphanumeric validation function returns false
11780 'alphanumText' : 'This field should only contain letters, numbers and _',
11782 * The keystroke filter mask to be applied on alphanumeric input
11785 'alphanumMask' : /[a-z0-9_]/i
11795 * @class Roo.bootstrap.Input
11796 * @extends Roo.bootstrap.Component
11797 * Bootstrap Input class
11798 * @cfg {Boolean} disabled is it disabled
11799 * @cfg {String} (button|checkbox|email|file|hidden|image|number|password|radio|range|reset|search|submit|text) inputType
11800 * @cfg {String} name name of the input
11801 * @cfg {string} fieldLabel - the label associated
11802 * @cfg {string} placeholder - placeholder to put in text.
11803 * @cfg {string} before - input group add on before
11804 * @cfg {string} after - input group add on after
11805 * @cfg {string} size - (lg|sm) or leave empty..
11806 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
11807 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
11808 * @cfg {Number} md colspan out of 12 for computer-sized screens
11809 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
11810 * @cfg {string} value default value of the input
11811 * @cfg {Number} labelWidth set the width of label
11812 * @cfg {Number} labellg set the width of label (1-12)
11813 * @cfg {Number} labelmd set the width of label (1-12)
11814 * @cfg {Number} labelsm set the width of label (1-12)
11815 * @cfg {Number} labelxs set the width of label (1-12)
11816 * @cfg {String} labelAlign (top|left)
11817 * @cfg {Boolean} readOnly Specifies that the field should be read-only
11818 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
11819 * @cfg {String} indicatorpos (left|right) default left
11820 * @cfg {String} capture (user|camera) use for file input only. (default empty)
11821 * @cfg {String} accept (image|video|audio) use for file input only. (default empty)
11822 * @cfg {Boolean} preventMark Do not show tick or cross if error/success
11824 * @cfg {String} align (left|center|right) Default left
11825 * @cfg {Boolean} forceFeedback (true|false) Default false
11828 * Create a new Input
11829 * @param {Object} config The config object
11832 Roo.bootstrap.Input = function(config){
11834 Roo.bootstrap.Input.superclass.constructor.call(this, config);
11839 * Fires when this field receives input focus.
11840 * @param {Roo.form.Field} this
11845 * Fires when this field loses input focus.
11846 * @param {Roo.form.Field} this
11850 * @event specialkey
11851 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
11852 * {@link Roo.EventObject#getKey} to determine which key was pressed.
11853 * @param {Roo.form.Field} this
11854 * @param {Roo.EventObject} e The event object
11859 * Fires just before the field blurs if the field value has changed.
11860 * @param {Roo.form.Field} this
11861 * @param {Mixed} newValue The new value
11862 * @param {Mixed} oldValue The original value
11867 * Fires after the field has been marked as invalid.
11868 * @param {Roo.form.Field} this
11869 * @param {String} msg The validation message
11874 * Fires after the field has been validated with no errors.
11875 * @param {Roo.form.Field} this
11880 * Fires after the key up
11881 * @param {Roo.form.Field} this
11882 * @param {Roo.EventObject} e The event Object
11887 * Fires after the user pastes into input
11888 * @param {Roo.form.Field} this
11889 * @param {Roo.EventObject} e The event Object
11895 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
11897 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
11898 automatic validation (defaults to "keyup").
11900 validationEvent : "keyup",
11902 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
11904 validateOnBlur : true,
11906 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
11908 validationDelay : 250,
11910 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
11912 focusClass : "x-form-focus", // not needed???
11916 * @cfg {String} invalidClass DEPRICATED - code uses BS4 - is-valid / is-invalid
11918 invalidClass : "has-warning",
11921 * @cfg {String} validClass DEPRICATED - code uses BS4 - is-valid / is-invalid
11923 validClass : "has-success",
11926 * @cfg {Boolean} hasFeedback (true|false) default true
11928 hasFeedback : true,
11931 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
11933 invalidFeedbackClass : "glyphicon-warning-sign",
11936 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
11938 validFeedbackClass : "glyphicon-ok",
11941 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
11943 selectOnFocus : false,
11946 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
11950 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
11955 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
11957 disableKeyFilter : false,
11960 * @cfg {Boolean} disabled True to disable the field (defaults to false).
11964 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
11968 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
11970 blankText : "Please complete this mandatory field",
11973 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
11977 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
11979 maxLength : Number.MAX_VALUE,
11981 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
11983 minLengthText : "The minimum length for this field is {0}",
11985 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
11987 maxLengthText : "The maximum length for this field is {0}",
11991 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
11992 * If available, this function will be called only after the basic validators all return true, and will be passed the
11993 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
11997 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
11998 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
11999 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
12003 * @cfg {String} regexText -- Depricated - use Invalid Text
12008 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
12014 autocomplete: false,
12018 inputType : 'text',
12021 placeholder: false,
12026 preventMark: false,
12027 isFormField : true,
12030 labelAlign : false,
12033 formatedValue : false,
12034 forceFeedback : false,
12036 indicatorpos : 'left',
12046 parentLabelAlign : function()
12049 while (parent.parent()) {
12050 parent = parent.parent();
12051 if (typeof(parent.labelAlign) !='undefined') {
12052 return parent.labelAlign;
12059 getAutoCreate : function()
12061 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
12067 if(this.inputType != 'hidden'){
12068 cfg.cls = 'form-group' //input-group
12074 type : this.inputType,
12075 value : this.value,
12076 cls : 'form-control',
12077 placeholder : this.placeholder || '',
12078 autocomplete : this.autocomplete || 'new-password'
12080 if (this.inputType == 'file') {
12081 input.style = 'overflow:hidden'; // why not in CSS?
12084 if(this.capture.length){
12085 input.capture = this.capture;
12088 if(this.accept.length){
12089 input.accept = this.accept + "/*";
12093 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
12096 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
12097 input.maxLength = this.maxLength;
12100 if (this.disabled) {
12101 input.disabled=true;
12104 if (this.readOnly) {
12105 input.readonly=true;
12109 input.name = this.name;
12113 input.cls += ' input-' + this.size;
12117 ['xs','sm','md','lg'].map(function(size){
12118 if (settings[size]) {
12119 cfg.cls += ' col-' + size + '-' + settings[size];
12123 var inputblock = input;
12127 cls: 'glyphicon form-control-feedback'
12130 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
12133 cls : 'has-feedback',
12141 if (this.before || this.after) {
12144 cls : 'input-group',
12148 if (this.before && typeof(this.before) == 'string') {
12150 inputblock.cn.push({
12152 cls : 'roo-input-before input-group-addon input-group-prepend input-group-text',
12156 if (this.before && typeof(this.before) == 'object') {
12157 this.before = Roo.factory(this.before);
12159 inputblock.cn.push({
12161 cls : 'roo-input-before input-group-prepend input-group-' +
12162 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
12166 inputblock.cn.push(input);
12168 if (this.after && typeof(this.after) == 'string') {
12169 inputblock.cn.push({
12171 cls : 'roo-input-after input-group-append input-group-text input-group-addon',
12175 if (this.after && typeof(this.after) == 'object') {
12176 this.after = Roo.factory(this.after);
12178 inputblock.cn.push({
12180 cls : 'roo-input-after input-group-append input-group-' +
12181 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
12185 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
12186 inputblock.cls += ' has-feedback';
12187 inputblock.cn.push(feedback);
12192 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
12193 tooltip : 'This field is required'
12195 if (this.allowBlank ) {
12196 indicator.style = this.allowBlank ? ' display:none' : '';
12198 if (align ==='left' && this.fieldLabel.length) {
12200 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
12207 cls : 'control-label col-form-label',
12208 html : this.fieldLabel
12219 var labelCfg = cfg.cn[1];
12220 var contentCfg = cfg.cn[2];
12222 if(this.indicatorpos == 'right'){
12227 cls : 'control-label col-form-label',
12231 html : this.fieldLabel
12245 labelCfg = cfg.cn[0];
12246 contentCfg = cfg.cn[1];
12250 if(this.labelWidth > 12){
12251 labelCfg.style = "width: " + this.labelWidth + 'px';
12254 if(this.labelWidth < 13 && this.labelmd == 0){
12255 this.labellg = this.labellg > 0 ? this.labellg : this.labelWidth;
12258 if(this.labellg > 0){
12259 labelCfg.cls += ' col-lg-' + this.labellg;
12260 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
12263 if(this.labelmd > 0){
12264 labelCfg.cls += ' col-md-' + this.labelmd;
12265 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
12268 if(this.labelsm > 0){
12269 labelCfg.cls += ' col-sm-' + this.labelsm;
12270 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
12273 if(this.labelxs > 0){
12274 labelCfg.cls += ' col-xs-' + this.labelxs;
12275 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
12279 } else if ( this.fieldLabel.length) {
12286 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
12287 tooltip : 'This field is required',
12288 style : this.allowBlank ? ' display:none' : ''
12292 //cls : 'input-group-addon',
12293 html : this.fieldLabel
12301 if(this.indicatorpos == 'right'){
12306 //cls : 'input-group-addon',
12307 html : this.fieldLabel
12312 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
12313 tooltip : 'This field is required',
12314 style : this.allowBlank ? ' display:none' : ''
12334 if (this.parentType === 'Navbar' && this.parent().bar) {
12335 cfg.cls += ' navbar-form';
12338 if (this.parentType === 'NavGroup' && !(Roo.bootstrap.version == 4 && this.parent().form)) {
12339 // on BS4 we do this only if not form
12340 cfg.cls += ' navbar-form';
12348 * return the real input element.
12350 inputEl: function ()
12352 return this.el.select('input.form-control',true).first();
12355 tooltipEl : function()
12357 return this.inputEl();
12360 indicatorEl : function()
12362 if (Roo.bootstrap.version == 4) {
12363 return false; // not enabled in v4 yet.
12366 var indicator = this.el.select('i.roo-required-indicator',true).first();
12376 setDisabled : function(v)
12378 var i = this.inputEl().dom;
12380 i.removeAttribute('disabled');
12384 i.setAttribute('disabled','true');
12386 initEvents : function()
12389 this.inputEl().on("keydown" , this.fireKey, this);
12390 this.inputEl().on("focus", this.onFocus, this);
12391 this.inputEl().on("blur", this.onBlur, this);
12393 this.inputEl().relayEvent('keyup', this);
12394 this.inputEl().relayEvent('paste', this);
12396 this.indicator = this.indicatorEl();
12398 if(this.indicator){
12399 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible'); // changed from invisible??? -
12402 // reference to original value for reset
12403 this.originalValue = this.getValue();
12404 //Roo.form.TextField.superclass.initEvents.call(this);
12405 if(this.validationEvent == 'keyup'){
12406 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
12407 this.inputEl().on('keyup', this.filterValidation, this);
12409 else if(this.validationEvent !== false){
12410 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
12413 if(this.selectOnFocus){
12414 this.on("focus", this.preFocus, this);
12417 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
12418 this.inputEl().on("keypress", this.filterKeys, this);
12420 this.inputEl().relayEvent('keypress', this);
12423 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
12424 this.el.on("click", this.autoSize, this);
12427 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
12428 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
12431 if (typeof(this.before) == 'object') {
12432 this.before.render(this.el.select('.roo-input-before',true).first());
12434 if (typeof(this.after) == 'object') {
12435 this.after.render(this.el.select('.roo-input-after',true).first());
12438 this.inputEl().on('change', this.onChange, this);
12441 filterValidation : function(e){
12442 if(!e.isNavKeyPress()){
12443 this.validationTask.delay(this.validationDelay);
12447 * Validates the field value
12448 * @return {Boolean} True if the value is valid, else false
12450 validate : function(){
12451 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
12452 if(this.disabled || this.validateValue(this.getRawValue())){
12457 this.markInvalid();
12463 * Validates a value according to the field's validation rules and marks the field as invalid
12464 * if the validation fails
12465 * @param {Mixed} value The value to validate
12466 * @return {Boolean} True if the value is valid, else false
12468 validateValue : function(value)
12470 if(this.getVisibilityEl().hasClass('hidden')){
12474 if(value.length < 1) { // if it's blank
12475 if(this.allowBlank){
12481 if(value.length < this.minLength){
12484 if(value.length > this.maxLength){
12488 var vt = Roo.form.VTypes;
12489 if(!vt[this.vtype](value, this)){
12493 if(typeof this.validator == "function"){
12494 var msg = this.validator(value);
12498 if (typeof(msg) == 'string') {
12499 this.invalidText = msg;
12503 if(this.regex && !this.regex.test(value)){
12511 fireKey : function(e){
12512 //Roo.log('field ' + e.getKey());
12513 if(e.isNavKeyPress()){
12514 this.fireEvent("specialkey", this, e);
12517 focus : function (selectText){
12519 this.inputEl().focus();
12520 if(selectText === true){
12521 this.inputEl().dom.select();
12527 onFocus : function(){
12528 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
12529 // this.el.addClass(this.focusClass);
12531 if(!this.hasFocus){
12532 this.hasFocus = true;
12533 this.startValue = this.getValue();
12534 this.fireEvent("focus", this);
12538 beforeBlur : Roo.emptyFn,
12542 onBlur : function(){
12544 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
12545 //this.el.removeClass(this.focusClass);
12547 this.hasFocus = false;
12548 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
12551 var v = this.getValue();
12552 if(String(v) !== String(this.startValue)){
12553 this.fireEvent('change', this, v, this.startValue);
12555 this.fireEvent("blur", this);
12558 onChange : function(e)
12560 var v = this.getValue();
12561 if(String(v) !== String(this.startValue)){
12562 this.fireEvent('change', this, v, this.startValue);
12568 * Resets the current field value to the originally loaded value and clears any validation messages
12570 reset : function(){
12571 this.setValue(this.originalValue);
12575 * Returns the name of the field
12576 * @return {Mixed} name The name field
12578 getName: function(){
12582 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
12583 * @return {Mixed} value The field value
12585 getValue : function(){
12587 var v = this.inputEl().getValue();
12592 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
12593 * @return {Mixed} value The field value
12595 getRawValue : function(){
12596 var v = this.inputEl().getValue();
12602 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
12603 * @param {Mixed} value The value to set
12605 setRawValue : function(v){
12606 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
12609 selectText : function(start, end){
12610 var v = this.getRawValue();
12612 start = start === undefined ? 0 : start;
12613 end = end === undefined ? v.length : end;
12614 var d = this.inputEl().dom;
12615 if(d.setSelectionRange){
12616 d.setSelectionRange(start, end);
12617 }else if(d.createTextRange){
12618 var range = d.createTextRange();
12619 range.moveStart("character", start);
12620 range.moveEnd("character", v.length-end);
12627 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
12628 * @param {Mixed} value The value to set
12630 setValue : function(v){
12633 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
12639 processValue : function(value){
12640 if(this.stripCharsRe){
12641 var newValue = value.replace(this.stripCharsRe, '');
12642 if(newValue !== value){
12643 this.setRawValue(newValue);
12650 preFocus : function(){
12652 if(this.selectOnFocus){
12653 this.inputEl().dom.select();
12656 filterKeys : function(e){
12657 var k = e.getKey();
12658 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
12661 var c = e.getCharCode(), cc = String.fromCharCode(c);
12662 if(Roo.isIE && (e.isSpecialKey() || !cc)){
12665 if(!this.maskRe.test(cc)){
12670 * Clear any invalid styles/messages for this field
12672 clearInvalid : function(){
12674 if(!this.el || this.preventMark){ // not rendered
12679 this.el.removeClass([this.invalidClass, 'is-invalid']);
12681 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
12683 var feedback = this.el.select('.form-control-feedback', true).first();
12686 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
12691 if(this.indicator){
12692 this.indicator.removeClass('visible');
12693 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
12696 this.fireEvent('valid', this);
12700 * Mark this field as valid
12702 markValid : function()
12704 if(!this.el || this.preventMark){ // not rendered...
12708 this.el.removeClass([this.invalidClass, this.validClass]);
12709 this.inputEl().removeClass(['is-valid', 'is-invalid']);
12711 var feedback = this.el.select('.form-control-feedback', true).first();
12714 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
12717 if(this.indicator){
12718 this.indicator.removeClass('visible');
12719 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
12727 if(this.allowBlank && !this.getRawValue().length){
12730 if (Roo.bootstrap.version == 3) {
12731 this.el.addClass(this.validClass);
12733 this.inputEl().addClass('is-valid');
12736 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
12738 var feedback = this.el.select('.form-control-feedback', true).first();
12741 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
12742 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
12747 this.fireEvent('valid', this);
12751 * Mark this field as invalid
12752 * @param {String} msg The validation message
12754 markInvalid : function(msg)
12756 if(!this.el || this.preventMark){ // not rendered
12760 this.el.removeClass([this.invalidClass, this.validClass]);
12761 this.inputEl().removeClass(['is-valid', 'is-invalid']);
12763 var feedback = this.el.select('.form-control-feedback', true).first();
12766 this.el.select('.form-control-feedback', true).first().removeClass(
12767 [this.invalidFeedbackClass, this.validFeedbackClass]);
12774 if(this.allowBlank && !this.getRawValue().length){
12778 if(this.indicator){
12779 this.indicator.removeClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
12780 this.indicator.addClass('visible');
12782 if (Roo.bootstrap.version == 3) {
12783 this.el.addClass(this.invalidClass);
12785 this.inputEl().addClass('is-invalid');
12790 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
12792 var feedback = this.el.select('.form-control-feedback', true).first();
12795 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
12797 if(this.getValue().length || this.forceFeedback){
12798 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
12805 this.fireEvent('invalid', this, msg);
12808 SafariOnKeyDown : function(event)
12810 // this is a workaround for a password hang bug on chrome/ webkit.
12811 if (this.inputEl().dom.type != 'password') {
12815 var isSelectAll = false;
12817 if(this.inputEl().dom.selectionEnd > 0){
12818 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
12820 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
12821 event.preventDefault();
12826 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
12828 event.preventDefault();
12829 // this is very hacky as keydown always get's upper case.
12831 var cc = String.fromCharCode(event.getCharCode());
12832 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
12836 adjustWidth : function(tag, w){
12837 tag = tag.toLowerCase();
12838 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
12839 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
12840 if(tag == 'input'){
12843 if(tag == 'textarea'){
12846 }else if(Roo.isOpera){
12847 if(tag == 'input'){
12850 if(tag == 'textarea'){
12858 setFieldLabel : function(v)
12860 if(!this.rendered){
12864 if(this.indicatorEl()){
12865 var ar = this.el.select('label > span',true);
12867 if (ar.elements.length) {
12868 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
12869 this.fieldLabel = v;
12873 var br = this.el.select('label',true);
12875 if(br.elements.length) {
12876 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
12877 this.fieldLabel = v;
12881 Roo.log('Cannot Found any of label > span || label in input');
12885 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
12886 this.fieldLabel = v;
12901 * @class Roo.bootstrap.TextArea
12902 * @extends Roo.bootstrap.Input
12903 * Bootstrap TextArea class
12904 * @cfg {Number} cols Specifies the visible width of a text area
12905 * @cfg {Number} rows Specifies the visible number of lines in a text area
12906 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
12907 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
12908 * @cfg {string} html text
12911 * Create a new TextArea
12912 * @param {Object} config The config object
12915 Roo.bootstrap.TextArea = function(config){
12916 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
12920 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
12930 getAutoCreate : function(){
12932 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
12938 if(this.inputType != 'hidden'){
12939 cfg.cls = 'form-group' //input-group
12947 value : this.value || '',
12948 html: this.html || '',
12949 cls : 'form-control',
12950 placeholder : this.placeholder || ''
12954 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
12955 input.maxLength = this.maxLength;
12959 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
12963 input.cols = this.cols;
12966 if (this.readOnly) {
12967 input.readonly = true;
12971 input.name = this.name;
12975 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
12979 ['xs','sm','md','lg'].map(function(size){
12980 if (settings[size]) {
12981 cfg.cls += ' col-' + size + '-' + settings[size];
12985 var inputblock = input;
12987 if(this.hasFeedback && !this.allowBlank){
12991 cls: 'glyphicon form-control-feedback'
12995 cls : 'has-feedback',
13004 if (this.before || this.after) {
13007 cls : 'input-group',
13011 inputblock.cn.push({
13013 cls : 'input-group-addon',
13018 inputblock.cn.push(input);
13020 if(this.hasFeedback && !this.allowBlank){
13021 inputblock.cls += ' has-feedback';
13022 inputblock.cn.push(feedback);
13026 inputblock.cn.push({
13028 cls : 'input-group-addon',
13035 if (align ==='left' && this.fieldLabel.length) {
13040 cls : 'control-label',
13041 html : this.fieldLabel
13052 if(this.labelWidth > 12){
13053 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
13056 if(this.labelWidth < 13 && this.labelmd == 0){
13057 this.labelmd = this.labelWidth;
13060 if(this.labellg > 0){
13061 cfg.cn[0].cls += ' col-lg-' + this.labellg;
13062 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
13065 if(this.labelmd > 0){
13066 cfg.cn[0].cls += ' col-md-' + this.labelmd;
13067 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
13070 if(this.labelsm > 0){
13071 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
13072 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
13075 if(this.labelxs > 0){
13076 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
13077 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
13080 } else if ( this.fieldLabel.length) {
13085 //cls : 'input-group-addon',
13086 html : this.fieldLabel
13104 if (this.disabled) {
13105 input.disabled=true;
13112 * return the real textarea element.
13114 inputEl: function ()
13116 return this.el.select('textarea.form-control',true).first();
13120 * Clear any invalid styles/messages for this field
13122 clearInvalid : function()
13125 if(!this.el || this.preventMark){ // not rendered
13129 var label = this.el.select('label', true).first();
13130 var icon = this.el.select('i.fa-star', true).first();
13135 this.el.removeClass( this.validClass);
13136 this.inputEl().removeClass('is-invalid');
13138 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
13140 var feedback = this.el.select('.form-control-feedback', true).first();
13143 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
13148 this.fireEvent('valid', this);
13152 * Mark this field as valid
13154 markValid : function()
13156 if(!this.el || this.preventMark){ // not rendered
13160 this.el.removeClass([this.invalidClass, this.validClass]);
13161 this.inputEl().removeClass(['is-valid', 'is-invalid']);
13163 var feedback = this.el.select('.form-control-feedback', true).first();
13166 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13169 if(this.disabled || this.allowBlank){
13173 var label = this.el.select('label', true).first();
13174 var icon = this.el.select('i.fa-star', true).first();
13179 if (Roo.bootstrap.version == 3) {
13180 this.el.addClass(this.validClass);
13182 this.inputEl().addClass('is-valid');
13186 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
13188 var feedback = this.el.select('.form-control-feedback', true).first();
13191 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13192 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
13197 this.fireEvent('valid', this);
13201 * Mark this field as invalid
13202 * @param {String} msg The validation message
13204 markInvalid : function(msg)
13206 if(!this.el || this.preventMark){ // not rendered
13210 this.el.removeClass([this.invalidClass, this.validClass]);
13211 this.inputEl().removeClass(['is-valid', 'is-invalid']);
13213 var feedback = this.el.select('.form-control-feedback', true).first();
13216 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13219 if(this.disabled || this.allowBlank){
13223 var label = this.el.select('label', true).first();
13224 var icon = this.el.select('i.fa-star', true).first();
13226 if(!this.getValue().length && label && !icon){
13227 this.el.createChild({
13229 cls : 'text-danger fa fa-lg fa-star',
13230 tooltip : 'This field is required',
13231 style : 'margin-right:5px;'
13235 if (Roo.bootstrap.version == 3) {
13236 this.el.addClass(this.invalidClass);
13238 this.inputEl().addClass('is-invalid');
13241 // fixme ... this may be depricated need to test..
13242 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
13244 var feedback = this.el.select('.form-control-feedback', true).first();
13247 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13249 if(this.getValue().length || this.forceFeedback){
13250 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
13257 this.fireEvent('invalid', this, msg);
13265 * trigger field - base class for combo..
13270 * @class Roo.bootstrap.TriggerField
13271 * @extends Roo.bootstrap.Input
13272 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
13273 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
13274 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
13275 * for which you can provide a custom implementation. For example:
13277 var trigger = new Roo.bootstrap.TriggerField();
13278 trigger.onTriggerClick = myTriggerFn;
13279 trigger.applyTo('my-field');
13282 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
13283 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
13284 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
13285 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
13286 * @cfg {String} caret (search|calendar) BS3 only - carat fa name
13289 * Create a new TriggerField.
13290 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
13291 * to the base TextField)
13293 Roo.bootstrap.TriggerField = function(config){
13294 this.mimicing = false;
13295 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
13298 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
13300 * @cfg {String} triggerClass A CSS class to apply to the trigger
13303 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
13308 * @cfg {Boolean} removable (true|false) special filter default false
13312 /** @cfg {Boolean} grow @hide */
13313 /** @cfg {Number} growMin @hide */
13314 /** @cfg {Number} growMax @hide */
13320 autoSize: Roo.emptyFn,
13324 deferHeight : true,
13327 actionMode : 'wrap',
13332 getAutoCreate : function(){
13334 var align = this.labelAlign || this.parentLabelAlign();
13339 cls: 'form-group' //input-group
13346 type : this.inputType,
13347 cls : 'form-control',
13348 autocomplete: 'new-password',
13349 placeholder : this.placeholder || ''
13353 input.name = this.name;
13356 input.cls += ' input-' + this.size;
13359 if (this.disabled) {
13360 input.disabled=true;
13363 var inputblock = input;
13365 if(this.hasFeedback && !this.allowBlank){
13369 cls: 'glyphicon form-control-feedback'
13372 if(this.removable && !this.editable ){
13374 cls : 'has-feedback',
13380 cls : 'roo-combo-removable-btn close'
13387 cls : 'has-feedback',
13396 if(this.removable && !this.editable ){
13398 cls : 'roo-removable',
13404 cls : 'roo-combo-removable-btn close'
13411 if (this.before || this.after) {
13414 cls : 'input-group',
13418 inputblock.cn.push({
13420 cls : 'input-group-addon input-group-prepend input-group-text',
13425 inputblock.cn.push(input);
13427 if(this.hasFeedback && !this.allowBlank){
13428 inputblock.cls += ' has-feedback';
13429 inputblock.cn.push(feedback);
13433 inputblock.cn.push({
13435 cls : 'input-group-addon input-group-append input-group-text',
13444 var ibwrap = inputblock;
13449 cls: 'roo-select2-choices',
13453 cls: 'roo-select2-search-field',
13465 cls: 'roo-select2-container input-group',
13470 cls: 'form-hidden-field'
13476 if(!this.multiple && this.showToggleBtn){
13482 if (this.caret != false) {
13485 cls: 'fa fa-' + this.caret
13492 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
13494 Roo.bootstrap.version == 3 ? caret : '',
13497 cls: 'combobox-clear',
13511 combobox.cls += ' roo-select2-container-multi';
13515 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
13516 tooltip : 'This field is required'
13518 if (Roo.bootstrap.version == 4) {
13521 style : 'display:none'
13526 if (align ==='left' && this.fieldLabel.length) {
13528 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
13535 cls : 'control-label',
13536 html : this.fieldLabel
13548 var labelCfg = cfg.cn[1];
13549 var contentCfg = cfg.cn[2];
13551 if(this.indicatorpos == 'right'){
13556 cls : 'control-label',
13560 html : this.fieldLabel
13574 labelCfg = cfg.cn[0];
13575 contentCfg = cfg.cn[1];
13578 if(this.labelWidth > 12){
13579 labelCfg.style = "width: " + this.labelWidth + 'px';
13582 if(this.labelWidth < 13 && this.labelmd == 0){
13583 this.labelmd = this.labelWidth;
13586 if(this.labellg > 0){
13587 labelCfg.cls += ' col-lg-' + this.labellg;
13588 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
13591 if(this.labelmd > 0){
13592 labelCfg.cls += ' col-md-' + this.labelmd;
13593 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
13596 if(this.labelsm > 0){
13597 labelCfg.cls += ' col-sm-' + this.labelsm;
13598 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
13601 if(this.labelxs > 0){
13602 labelCfg.cls += ' col-xs-' + this.labelxs;
13603 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
13606 } else if ( this.fieldLabel.length) {
13607 // Roo.log(" label");
13612 //cls : 'input-group-addon',
13613 html : this.fieldLabel
13621 if(this.indicatorpos == 'right'){
13629 html : this.fieldLabel
13643 // Roo.log(" no label && no align");
13650 ['xs','sm','md','lg'].map(function(size){
13651 if (settings[size]) {
13652 cfg.cls += ' col-' + size + '-' + settings[size];
13663 onResize : function(w, h){
13664 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
13665 // if(typeof w == 'number'){
13666 // var x = w - this.trigger.getWidth();
13667 // this.inputEl().setWidth(this.adjustWidth('input', x));
13668 // this.trigger.setStyle('left', x+'px');
13673 adjustSize : Roo.BoxComponent.prototype.adjustSize,
13676 getResizeEl : function(){
13677 return this.inputEl();
13681 getPositionEl : function(){
13682 return this.inputEl();
13686 alignErrorIcon : function(){
13687 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
13691 initEvents : function(){
13695 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
13696 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
13697 if(!this.multiple && this.showToggleBtn){
13698 this.trigger = this.el.select('span.dropdown-toggle',true).first();
13699 if(this.hideTrigger){
13700 this.trigger.setDisplayed(false);
13702 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
13706 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
13709 if(this.removable && !this.editable && !this.tickable){
13710 var close = this.closeTriggerEl();
13713 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
13714 close.on('click', this.removeBtnClick, this, close);
13718 //this.trigger.addClassOnOver('x-form-trigger-over');
13719 //this.trigger.addClassOnClick('x-form-trigger-click');
13722 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
13726 closeTriggerEl : function()
13728 var close = this.el.select('.roo-combo-removable-btn', true).first();
13729 return close ? close : false;
13732 removeBtnClick : function(e, h, el)
13734 e.preventDefault();
13736 if(this.fireEvent("remove", this) !== false){
13738 this.fireEvent("afterremove", this)
13742 createList : function()
13744 this.list = Roo.get(document.body).createChild({
13745 tag: Roo.bootstrap.version == 4 ? 'div' : 'ul',
13746 cls: 'typeahead typeahead-long dropdown-menu shadow',
13747 style: 'display:none'
13750 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
13755 initTrigger : function(){
13760 onDestroy : function(){
13762 this.trigger.removeAllListeners();
13763 // this.trigger.remove();
13766 // this.wrap.remove();
13768 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
13772 onFocus : function(){
13773 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
13775 if(!this.mimicing){
13776 this.wrap.addClass('x-trigger-wrap-focus');
13777 this.mimicing = true;
13778 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
13779 if(this.monitorTab){
13780 this.el.on("keydown", this.checkTab, this);
13787 checkTab : function(e){
13788 if(e.getKey() == e.TAB){
13789 this.triggerBlur();
13794 onBlur : function(){
13799 mimicBlur : function(e, t){
13801 if(!this.wrap.contains(t) && this.validateBlur()){
13802 this.triggerBlur();
13808 triggerBlur : function(){
13809 this.mimicing = false;
13810 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
13811 if(this.monitorTab){
13812 this.el.un("keydown", this.checkTab, this);
13814 //this.wrap.removeClass('x-trigger-wrap-focus');
13815 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
13819 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
13820 validateBlur : function(e, t){
13825 onDisable : function(){
13826 this.inputEl().dom.disabled = true;
13827 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
13829 // this.wrap.addClass('x-item-disabled');
13834 onEnable : function(){
13835 this.inputEl().dom.disabled = false;
13836 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
13838 // this.el.removeClass('x-item-disabled');
13843 onShow : function(){
13844 var ae = this.getActionEl();
13847 ae.dom.style.display = '';
13848 ae.dom.style.visibility = 'visible';
13854 onHide : function(){
13855 var ae = this.getActionEl();
13856 ae.dom.style.display = 'none';
13860 * The function that should handle the trigger's click event. This method does nothing by default until overridden
13861 * by an implementing function.
13863 * @param {EventObject} e
13865 onTriggerClick : Roo.emptyFn
13873 * @class Roo.bootstrap.CardUploader
13874 * @extends Roo.bootstrap.Button
13875 * Bootstrap Card Uploader class - it's a button which when you add files to it, adds cards below with preview and the name...
13876 * @cfg {Number} errorTimeout default 3000
13877 * @cfg {Array} images an array of ?? Img objects ??? when loading existing files..
13878 * @cfg {Array} html The button text.
13882 * Create a new CardUploader
13883 * @param {Object} config The config object
13886 Roo.bootstrap.CardUploader = function(config){
13890 Roo.bootstrap.CardUploader.superclass.constructor.call(this, config);
13893 this.fileCollection = new Roo.util.MixedCollection(false,function(r) {
13901 * When a image is clicked on - and needs to display a slideshow or similar..
13902 * @param {Roo.bootstrap.Card} this
13903 * @param {Object} The image information data
13909 * When a the download link is clicked
13910 * @param {Roo.bootstrap.Card} this
13911 * @param {Object} The image information data contains
13918 Roo.extend(Roo.bootstrap.CardUploader, Roo.bootstrap.Input, {
13921 errorTimeout : 3000,
13925 fileCollection : false,
13928 getAutoCreate : function()
13932 cls :'form-group' ,
13937 //cls : 'input-group-addon',
13938 html : this.fieldLabel
13946 value : this.value,
13947 cls : 'd-none form-control'
13952 multiple : 'multiple',
13954 cls : 'd-none roo-card-upload-selector'
13958 cls : 'roo-card-uploader-button-container w-100 mb-2'
13961 cls : 'card-columns roo-card-uploader-container'
13971 getChildContainer : function() /// what children are added to.
13973 return this.containerEl;
13976 getButtonContainer : function() /// what children are added to.
13978 return this.el.select(".roo-card-uploader-button-container").first();
13981 initEvents : function()
13984 Roo.bootstrap.Input.prototype.initEvents.call(this);
13988 xns: Roo.bootstrap,
13991 container_method : 'getButtonContainer' ,
13992 html : this.html, // fix changable?
13995 'click' : function(btn, e) {
14004 this.urlAPI = (window.createObjectURL && window) ||
14005 (window.URL && URL.revokeObjectURL && URL) ||
14006 (window.webkitURL && webkitURL);
14011 this.selectorEl = this.el.select('.roo-card-upload-selector', true).first();
14013 this.selectorEl.on('change', this.onFileSelected, this);
14016 this.images.forEach(function(img) {
14019 this.images = false;
14021 this.containerEl = this.el.select('.roo-card-uploader-container', true).first();
14027 onClick : function(e)
14029 e.preventDefault();
14031 this.selectorEl.dom.click();
14035 onFileSelected : function(e)
14037 e.preventDefault();
14039 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
14043 Roo.each(this.selectorEl.dom.files, function(file){
14044 this.addFile(file);
14053 addFile : function(file)
14056 if(typeof(file) === 'string'){
14057 throw "Add file by name?"; // should not happen
14061 if(!file || !this.urlAPI){
14071 var url = _this.urlAPI.createObjectURL( file);
14074 id : Roo.bootstrap.CardUploader.ID--,
14075 is_uploaded : false,
14079 mimetype : file.type,
14087 * addCard - add an Attachment to the uploader
14088 * @param data - the data about the image to upload
14092 title : "Title of file",
14093 is_uploaded : false,
14094 src : "http://.....",
14095 srcfile : { the File upload object },
14096 mimetype : file.type,
14099 .. any other data...
14105 addCard : function (data)
14107 // hidden input element?
14108 // if the file is not an image...
14109 //then we need to use something other that and header_image
14114 xns : Roo.bootstrap,
14115 xtype : 'CardFooter',
14118 xns : Roo.bootstrap,
14124 xns : Roo.bootstrap,
14126 html : String.format("<small>{0}</small>", data.title),
14127 cls : 'col-10 text-left',
14132 click : function() {
14134 t.fireEvent( "download", t, data );
14140 xns : Roo.bootstrap,
14142 style: 'max-height: 28px; ',
14148 click : function() {
14149 t.removeCard(data.id)
14161 var cn = this.addxtype(
14164 xns : Roo.bootstrap,
14167 header : !data.mimetype.match(/image/) && !data.preview ? "Document": false,
14168 header_image : data.mimetype.match(/image/) ? data.src : data.preview,
14169 header_image_fit_square: true, // fixme - we probably need to use the 'Img' element to do stuff like this.
14174 initEvents : function() {
14175 Roo.bootstrap.Card.prototype.initEvents.call(this);
14177 this.imgEl = this.el.select('.card-img-top').first();
14179 this.imgEl.on('click', function() { t.fireEvent( "preview", t, data ); }, this);
14180 this.imgEl.set({ 'pointer' : 'cursor' });
14183 this.getCardFooter().addClass('p-1');
14190 // dont' really need ot update items.
14191 // this.items.push(cn);
14192 this.fileCollection.add(cn);
14194 if (!data.srcfile) {
14195 this.updateInput();
14200 var reader = new FileReader();
14201 reader.addEventListener("load", function() {
14202 data.srcdata = reader.result;
14205 reader.readAsDataURL(data.srcfile);
14210 removeCard : function(id)
14213 var card = this.fileCollection.get(id);
14214 card.data.is_deleted = 1;
14215 card.data.src = ''; /// delete the source - so it reduces size of not uploaded images etc.
14216 //this.fileCollection.remove(card);
14217 //this.items = this.items.filter(function(e) { return e != card });
14218 // dont' really need ot update items.
14219 card.el.dom.parentNode.removeChild(card.el.dom);
14220 this.updateInput();
14226 this.fileCollection.each(function(card) {
14227 if (card.el.dom && card.el.dom.parentNode) {
14228 card.el.dom.parentNode.removeChild(card.el.dom);
14231 this.fileCollection.clear();
14232 this.updateInput();
14235 updateInput : function()
14238 this.fileCollection.each(function(e) {
14242 this.inputEl().dom.value = JSON.stringify(data);
14252 Roo.bootstrap.CardUploader.ID = -1;/*
14254 * Ext JS Library 1.1.1
14255 * Copyright(c) 2006-2007, Ext JS, LLC.
14257 * Originally Released Under LGPL - original licence link has changed is not relivant.
14260 * <script type="text/javascript">
14265 * @class Roo.data.SortTypes
14267 * Defines the default sorting (casting?) comparison functions used when sorting data.
14269 Roo.data.SortTypes = {
14271 * Default sort that does nothing
14272 * @param {Mixed} s The value being converted
14273 * @return {Mixed} The comparison value
14275 none : function(s){
14280 * The regular expression used to strip tags
14284 stripTagsRE : /<\/?[^>]+>/gi,
14287 * Strips all HTML tags to sort on text only
14288 * @param {Mixed} s The value being converted
14289 * @return {String} The comparison value
14291 asText : function(s){
14292 return String(s).replace(this.stripTagsRE, "");
14296 * Strips all HTML tags to sort on text only - Case insensitive
14297 * @param {Mixed} s The value being converted
14298 * @return {String} The comparison value
14300 asUCText : function(s){
14301 return String(s).toUpperCase().replace(this.stripTagsRE, "");
14305 * Case insensitive string
14306 * @param {Mixed} s The value being converted
14307 * @return {String} The comparison value
14309 asUCString : function(s) {
14310 return String(s).toUpperCase();
14315 * @param {Mixed} s The value being converted
14316 * @return {Number} The comparison value
14318 asDate : function(s) {
14322 if(s instanceof Date){
14323 return s.getTime();
14325 return Date.parse(String(s));
14330 * @param {Mixed} s The value being converted
14331 * @return {Float} The comparison value
14333 asFloat : function(s) {
14334 var val = parseFloat(String(s).replace(/,/g, ""));
14343 * @param {Mixed} s The value being converted
14344 * @return {Number} The comparison value
14346 asInt : function(s) {
14347 var val = parseInt(String(s).replace(/,/g, ""));
14355 * Ext JS Library 1.1.1
14356 * Copyright(c) 2006-2007, Ext JS, LLC.
14358 * Originally Released Under LGPL - original licence link has changed is not relivant.
14361 * <script type="text/javascript">
14365 * @class Roo.data.Record
14366 * Instances of this class encapsulate both record <em>definition</em> information, and record
14367 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
14368 * to access Records cached in an {@link Roo.data.Store} object.<br>
14370 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
14371 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
14374 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
14376 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
14377 * {@link #create}. The parameters are the same.
14378 * @param {Array} data An associative Array of data values keyed by the field name.
14379 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
14380 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
14381 * not specified an integer id is generated.
14383 Roo.data.Record = function(data, id){
14384 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
14389 * Generate a constructor for a specific record layout.
14390 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
14391 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
14392 * Each field definition object may contain the following properties: <ul>
14393 * <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,
14394 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
14395 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
14396 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
14397 * is being used, then this is a string containing the javascript expression to reference the data relative to
14398 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
14399 * to the data item relative to the record element. If the mapping expression is the same as the field name,
14400 * this may be omitted.</p></li>
14401 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
14402 * <ul><li>auto (Default, implies no conversion)</li>
14407 * <li>date</li></ul></p></li>
14408 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
14409 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
14410 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
14411 * by the Reader into an object that will be stored in the Record. It is passed the
14412 * following parameters:<ul>
14413 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
14415 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
14417 * <br>usage:<br><pre><code>
14418 var TopicRecord = Roo.data.Record.create(
14419 {name: 'title', mapping: 'topic_title'},
14420 {name: 'author', mapping: 'username'},
14421 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
14422 {name: 'lastPost', mapping: 'post_time', type: 'date'},
14423 {name: 'lastPoster', mapping: 'user2'},
14424 {name: 'excerpt', mapping: 'post_text'}
14427 var myNewRecord = new TopicRecord({
14428 title: 'Do my job please',
14431 lastPost: new Date(),
14432 lastPoster: 'Animal',
14433 excerpt: 'No way dude!'
14435 myStore.add(myNewRecord);
14440 Roo.data.Record.create = function(o){
14441 var f = function(){
14442 f.superclass.constructor.apply(this, arguments);
14444 Roo.extend(f, Roo.data.Record);
14445 var p = f.prototype;
14446 p.fields = new Roo.util.MixedCollection(false, function(field){
14449 for(var i = 0, len = o.length; i < len; i++){
14450 p.fields.add(new Roo.data.Field(o[i]));
14452 f.getField = function(name){
14453 return p.fields.get(name);
14458 Roo.data.Record.AUTO_ID = 1000;
14459 Roo.data.Record.EDIT = 'edit';
14460 Roo.data.Record.REJECT = 'reject';
14461 Roo.data.Record.COMMIT = 'commit';
14463 Roo.data.Record.prototype = {
14465 * Readonly flag - true if this record has been modified.
14474 join : function(store){
14475 this.store = store;
14479 * Set the named field to the specified value.
14480 * @param {String} name The name of the field to set.
14481 * @param {Object} value The value to set the field to.
14483 set : function(name, value){
14484 if(this.data[name] == value){
14488 if(!this.modified){
14489 this.modified = {};
14491 if(typeof this.modified[name] == 'undefined'){
14492 this.modified[name] = this.data[name];
14494 this.data[name] = value;
14495 if(!this.editing && this.store){
14496 this.store.afterEdit(this);
14501 * Get the value of the named field.
14502 * @param {String} name The name of the field to get the value of.
14503 * @return {Object} The value of the field.
14505 get : function(name){
14506 return this.data[name];
14510 beginEdit : function(){
14511 this.editing = true;
14512 this.modified = {};
14516 cancelEdit : function(){
14517 this.editing = false;
14518 delete this.modified;
14522 endEdit : function(){
14523 this.editing = false;
14524 if(this.dirty && this.store){
14525 this.store.afterEdit(this);
14530 * Usually called by the {@link Roo.data.Store} which owns the Record.
14531 * Rejects all changes made to the Record since either creation, or the last commit operation.
14532 * Modified fields are reverted to their original values.
14534 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
14535 * of reject operations.
14537 reject : function(){
14538 var m = this.modified;
14540 if(typeof m[n] != "function"){
14541 this.data[n] = m[n];
14544 this.dirty = false;
14545 delete this.modified;
14546 this.editing = false;
14548 this.store.afterReject(this);
14553 * Usually called by the {@link Roo.data.Store} which owns the Record.
14554 * Commits all changes made to the Record since either creation, or the last commit operation.
14556 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
14557 * of commit operations.
14559 commit : function(){
14560 this.dirty = false;
14561 delete this.modified;
14562 this.editing = false;
14564 this.store.afterCommit(this);
14569 hasError : function(){
14570 return this.error != null;
14574 clearError : function(){
14579 * Creates a copy of this record.
14580 * @param {String} id (optional) A new record id if you don't want to use this record's id
14583 copy : function(newId) {
14584 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
14588 * Ext JS Library 1.1.1
14589 * Copyright(c) 2006-2007, Ext JS, LLC.
14591 * Originally Released Under LGPL - original licence link has changed is not relivant.
14594 * <script type="text/javascript">
14600 * @class Roo.data.Store
14601 * @extends Roo.util.Observable
14602 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
14603 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
14605 * 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
14606 * has no knowledge of the format of the data returned by the Proxy.<br>
14608 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
14609 * instances from the data object. These records are cached and made available through accessor functions.
14611 * Creates a new Store.
14612 * @param {Object} config A config object containing the objects needed for the Store to access data,
14613 * and read the data into Records.
14615 Roo.data.Store = function(config){
14616 this.data = new Roo.util.MixedCollection(false);
14617 this.data.getKey = function(o){
14620 this.baseParams = {};
14622 this.paramNames = {
14627 "multisort" : "_multisort"
14630 if(config && config.data){
14631 this.inlineData = config.data;
14632 delete config.data;
14635 Roo.apply(this, config);
14637 if(this.reader){ // reader passed
14638 this.reader = Roo.factory(this.reader, Roo.data);
14639 this.reader.xmodule = this.xmodule || false;
14640 if(!this.recordType){
14641 this.recordType = this.reader.recordType;
14643 if(this.reader.onMetaChange){
14644 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
14648 if(this.recordType){
14649 this.fields = this.recordType.prototype.fields;
14651 this.modified = [];
14655 * @event datachanged
14656 * Fires when the data cache has changed, and a widget which is using this Store
14657 * as a Record cache should refresh its view.
14658 * @param {Store} this
14660 datachanged : true,
14662 * @event metachange
14663 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
14664 * @param {Store} this
14665 * @param {Object} meta The JSON metadata
14670 * Fires when Records have been added to the Store
14671 * @param {Store} this
14672 * @param {Roo.data.Record[]} records The array of Records added
14673 * @param {Number} index The index at which the record(s) were added
14678 * Fires when a Record has been removed from the Store
14679 * @param {Store} this
14680 * @param {Roo.data.Record} record The Record that was removed
14681 * @param {Number} index The index at which the record was removed
14686 * Fires when a Record has been updated
14687 * @param {Store} this
14688 * @param {Roo.data.Record} record The Record that was updated
14689 * @param {String} operation The update operation being performed. Value may be one of:
14691 Roo.data.Record.EDIT
14692 Roo.data.Record.REJECT
14693 Roo.data.Record.COMMIT
14699 * Fires when the data cache has been cleared.
14700 * @param {Store} this
14704 * @event beforeload
14705 * Fires before a request is made for a new data object. If the beforeload handler returns false
14706 * the load action will be canceled.
14707 * @param {Store} this
14708 * @param {Object} options The loading options that were specified (see {@link #load} for details)
14712 * @event beforeloadadd
14713 * Fires after a new set of Records has been loaded.
14714 * @param {Store} this
14715 * @param {Roo.data.Record[]} records The Records that were loaded
14716 * @param {Object} options The loading options that were specified (see {@link #load} for details)
14718 beforeloadadd : true,
14721 * Fires after a new set of Records has been loaded, before they are added to the store.
14722 * @param {Store} this
14723 * @param {Roo.data.Record[]} records The Records that were loaded
14724 * @param {Object} options The loading options that were specified (see {@link #load} for details)
14725 * @params {Object} return from reader
14729 * @event loadexception
14730 * Fires if an exception occurs in the Proxy during loading.
14731 * Called with the signature of the Proxy's "loadexception" event.
14732 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
14735 * @param {Object} return from JsonData.reader() - success, totalRecords, records
14736 * @param {Object} load options
14737 * @param {Object} jsonData from your request (normally this contains the Exception)
14739 loadexception : true
14743 this.proxy = Roo.factory(this.proxy, Roo.data);
14744 this.proxy.xmodule = this.xmodule || false;
14745 this.relayEvents(this.proxy, ["loadexception"]);
14747 this.sortToggle = {};
14748 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
14750 Roo.data.Store.superclass.constructor.call(this);
14752 if(this.inlineData){
14753 this.loadData(this.inlineData);
14754 delete this.inlineData;
14758 Roo.extend(Roo.data.Store, Roo.util.Observable, {
14760 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
14761 * without a remote query - used by combo/forms at present.
14765 * @cfg {Roo.data.DataProxy} proxy [required] The Proxy object which provides access to a data object.
14768 * @cfg {Array} data Inline data to be loaded when the store is initialized.
14771 * @cfg {Roo.data.DataReader} reader [required] The Reader object which processes the data object and returns
14772 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
14775 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
14776 * on any HTTP request
14779 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
14782 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
14786 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
14787 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
14789 remoteSort : false,
14792 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
14793 * loaded or when a record is removed. (defaults to false).
14795 pruneModifiedRecords : false,
14798 lastOptions : null,
14801 * Add Records to the Store and fires the add event.
14802 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
14804 add : function(records){
14805 records = [].concat(records);
14806 for(var i = 0, len = records.length; i < len; i++){
14807 records[i].join(this);
14809 var index = this.data.length;
14810 this.data.addAll(records);
14811 this.fireEvent("add", this, records, index);
14815 * Remove a Record from the Store and fires the remove event.
14816 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
14818 remove : function(record){
14819 var index = this.data.indexOf(record);
14820 this.data.removeAt(index);
14822 if(this.pruneModifiedRecords){
14823 this.modified.remove(record);
14825 this.fireEvent("remove", this, record, index);
14829 * Remove all Records from the Store and fires the clear event.
14831 removeAll : function(){
14833 if(this.pruneModifiedRecords){
14834 this.modified = [];
14836 this.fireEvent("clear", this);
14840 * Inserts Records to the Store at the given index and fires the add event.
14841 * @param {Number} index The start index at which to insert the passed Records.
14842 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
14844 insert : function(index, records){
14845 records = [].concat(records);
14846 for(var i = 0, len = records.length; i < len; i++){
14847 this.data.insert(index, records[i]);
14848 records[i].join(this);
14850 this.fireEvent("add", this, records, index);
14854 * Get the index within the cache of the passed Record.
14855 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
14856 * @return {Number} The index of the passed Record. Returns -1 if not found.
14858 indexOf : function(record){
14859 return this.data.indexOf(record);
14863 * Get the index within the cache of the Record with the passed id.
14864 * @param {String} id The id of the Record to find.
14865 * @return {Number} The index of the Record. Returns -1 if not found.
14867 indexOfId : function(id){
14868 return this.data.indexOfKey(id);
14872 * Get the Record with the specified id.
14873 * @param {String} id The id of the Record to find.
14874 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
14876 getById : function(id){
14877 return this.data.key(id);
14881 * Get the Record at the specified index.
14882 * @param {Number} index The index of the Record to find.
14883 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
14885 getAt : function(index){
14886 return this.data.itemAt(index);
14890 * Returns a range of Records between specified indices.
14891 * @param {Number} startIndex (optional) The starting index (defaults to 0)
14892 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
14893 * @return {Roo.data.Record[]} An array of Records
14895 getRange : function(start, end){
14896 return this.data.getRange(start, end);
14900 storeOptions : function(o){
14901 o = Roo.apply({}, o);
14904 this.lastOptions = o;
14908 * Loads the Record cache from the configured Proxy using the configured Reader.
14910 * If using remote paging, then the first load call must specify the <em>start</em>
14911 * and <em>limit</em> properties in the options.params property to establish the initial
14912 * position within the dataset, and the number of Records to cache on each read from the Proxy.
14914 * <strong>It is important to note that for remote data sources, loading is asynchronous,
14915 * and this call will return before the new data has been loaded. Perform any post-processing
14916 * in a callback function, or in a "load" event handler.</strong>
14918 * @param {Object} options An object containing properties which control loading options:<ul>
14919 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
14920 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
14921 * passed the following arguments:<ul>
14922 * <li>r : Roo.data.Record[]</li>
14923 * <li>options: Options object from the load call</li>
14924 * <li>success: Boolean success indicator</li></ul></li>
14925 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
14926 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
14929 load : function(options){
14930 options = options || {};
14931 if(this.fireEvent("beforeload", this, options) !== false){
14932 this.storeOptions(options);
14933 var p = Roo.apply(options.params || {}, this.baseParams);
14934 // if meta was not loaded from remote source.. try requesting it.
14935 if (!this.reader.metaFromRemote) {
14936 p._requestMeta = 1;
14938 if(this.sortInfo && this.remoteSort){
14939 var pn = this.paramNames;
14940 p[pn["sort"]] = this.sortInfo.field;
14941 p[pn["dir"]] = this.sortInfo.direction;
14943 if (this.multiSort) {
14944 var pn = this.paramNames;
14945 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
14948 this.proxy.load(p, this.reader, this.loadRecords, this, options);
14953 * Reloads the Record cache from the configured Proxy using the configured Reader and
14954 * the options from the last load operation performed.
14955 * @param {Object} options (optional) An object containing properties which may override the options
14956 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
14957 * the most recently used options are reused).
14959 reload : function(options){
14960 this.load(Roo.applyIf(options||{}, this.lastOptions));
14964 // Called as a callback by the Reader during a load operation.
14965 loadRecords : function(o, options, success){
14966 if(!o || success === false){
14967 if(success !== false){
14968 this.fireEvent("load", this, [], options, o);
14970 if(options.callback){
14971 options.callback.call(options.scope || this, [], options, false);
14975 // if data returned failure - throw an exception.
14976 if (o.success === false) {
14977 // show a message if no listener is registered.
14978 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
14979 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
14981 // loadmask wil be hooked into this..
14982 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
14985 var r = o.records, t = o.totalRecords || r.length;
14987 this.fireEvent("beforeloadadd", this, r, options, o);
14989 if(!options || options.add !== true){
14990 if(this.pruneModifiedRecords){
14991 this.modified = [];
14993 for(var i = 0, len = r.length; i < len; i++){
14997 this.data = this.snapshot;
14998 delete this.snapshot;
15001 this.data.addAll(r);
15002 this.totalLength = t;
15004 this.fireEvent("datachanged", this);
15006 this.totalLength = Math.max(t, this.data.length+r.length);
15010 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
15012 var e = new Roo.data.Record({});
15014 e.set(this.parent.displayField, this.parent.emptyTitle);
15015 e.set(this.parent.valueField, '');
15020 this.fireEvent("load", this, r, options, o);
15021 if(options.callback){
15022 options.callback.call(options.scope || this, r, options, true);
15028 * Loads data from a passed data block. A Reader which understands the format of the data
15029 * must have been configured in the constructor.
15030 * @param {Object} data The data block from which to read the Records. The format of the data expected
15031 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
15032 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
15034 loadData : function(o, append){
15035 var r = this.reader.readRecords(o);
15036 this.loadRecords(r, {add: append}, true);
15040 * using 'cn' the nested child reader read the child array into it's child stores.
15041 * @param {Object} rec The record with a 'children array
15043 loadDataFromChildren : function(rec)
15045 this.loadData(this.reader.toLoadData(rec));
15050 * Gets the number of cached records.
15052 * <em>If using paging, this may not be the total size of the dataset. If the data object
15053 * used by the Reader contains the dataset size, then the getTotalCount() function returns
15054 * the data set size</em>
15056 getCount : function(){
15057 return this.data.length || 0;
15061 * Gets the total number of records in the dataset as returned by the server.
15063 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
15064 * the dataset size</em>
15066 getTotalCount : function(){
15067 return this.totalLength || 0;
15071 * Returns the sort state of the Store as an object with two properties:
15073 field {String} The name of the field by which the Records are sorted
15074 direction {String} The sort order, "ASC" or "DESC"
15077 getSortState : function(){
15078 return this.sortInfo;
15082 applySort : function(){
15083 if(this.sortInfo && !this.remoteSort){
15084 var s = this.sortInfo, f = s.field;
15085 var st = this.fields.get(f).sortType;
15086 var fn = function(r1, r2){
15087 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
15088 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
15090 this.data.sort(s.direction, fn);
15091 if(this.snapshot && this.snapshot != this.data){
15092 this.snapshot.sort(s.direction, fn);
15098 * Sets the default sort column and order to be used by the next load operation.
15099 * @param {String} fieldName The name of the field to sort by.
15100 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
15102 setDefaultSort : function(field, dir){
15103 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
15107 * Sort the Records.
15108 * If remote sorting is used, the sort is performed on the server, and the cache is
15109 * reloaded. If local sorting is used, the cache is sorted internally.
15110 * @param {String} fieldName The name of the field to sort by.
15111 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
15113 sort : function(fieldName, dir){
15114 var f = this.fields.get(fieldName);
15116 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
15118 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
15119 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
15124 this.sortToggle[f.name] = dir;
15125 this.sortInfo = {field: f.name, direction: dir};
15126 if(!this.remoteSort){
15128 this.fireEvent("datachanged", this);
15130 this.load(this.lastOptions);
15135 * Calls the specified function for each of the Records in the cache.
15136 * @param {Function} fn The function to call. The Record is passed as the first parameter.
15137 * Returning <em>false</em> aborts and exits the iteration.
15138 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
15140 each : function(fn, scope){
15141 this.data.each(fn, scope);
15145 * Gets all records modified since the last commit. Modified records are persisted across load operations
15146 * (e.g., during paging).
15147 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
15149 getModifiedRecords : function(){
15150 return this.modified;
15154 createFilterFn : function(property, value, anyMatch){
15155 if(!value.exec){ // not a regex
15156 value = String(value);
15157 if(value.length == 0){
15160 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
15162 return function(r){
15163 return value.test(r.data[property]);
15168 * Sums the value of <i>property</i> for each record between start and end and returns the result.
15169 * @param {String} property A field on your records
15170 * @param {Number} start The record index to start at (defaults to 0)
15171 * @param {Number} end The last record index to include (defaults to length - 1)
15172 * @return {Number} The sum
15174 sum : function(property, start, end){
15175 var rs = this.data.items, v = 0;
15176 start = start || 0;
15177 end = (end || end === 0) ? end : rs.length-1;
15179 for(var i = start; i <= end; i++){
15180 v += (rs[i].data[property] || 0);
15186 * Filter the records by a specified property.
15187 * @param {String} field A field on your records
15188 * @param {String/RegExp} value Either a string that the field
15189 * should start with or a RegExp to test against the field
15190 * @param {Boolean} anyMatch True to match any part not just the beginning
15192 filter : function(property, value, anyMatch){
15193 var fn = this.createFilterFn(property, value, anyMatch);
15194 return fn ? this.filterBy(fn) : this.clearFilter();
15198 * Filter by a function. The specified function will be called with each
15199 * record in this data source. If the function returns true the record is included,
15200 * otherwise it is filtered.
15201 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
15202 * @param {Object} scope (optional) The scope of the function (defaults to this)
15204 filterBy : function(fn, scope){
15205 this.snapshot = this.snapshot || this.data;
15206 this.data = this.queryBy(fn, scope||this);
15207 this.fireEvent("datachanged", this);
15211 * Query the records by a specified property.
15212 * @param {String} field A field on your records
15213 * @param {String/RegExp} value Either a string that the field
15214 * should start with or a RegExp to test against the field
15215 * @param {Boolean} anyMatch True to match any part not just the beginning
15216 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
15218 query : function(property, value, anyMatch){
15219 var fn = this.createFilterFn(property, value, anyMatch);
15220 return fn ? this.queryBy(fn) : this.data.clone();
15224 * Query by a function. The specified function will be called with each
15225 * record in this data source. If the function returns true the record is included
15227 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
15228 * @param {Object} scope (optional) The scope of the function (defaults to this)
15229 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
15231 queryBy : function(fn, scope){
15232 var data = this.snapshot || this.data;
15233 return data.filterBy(fn, scope||this);
15237 * Collects unique values for a particular dataIndex from this store.
15238 * @param {String} dataIndex The property to collect
15239 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
15240 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
15241 * @return {Array} An array of the unique values
15243 collect : function(dataIndex, allowNull, bypassFilter){
15244 var d = (bypassFilter === true && this.snapshot) ?
15245 this.snapshot.items : this.data.items;
15246 var v, sv, r = [], l = {};
15247 for(var i = 0, len = d.length; i < len; i++){
15248 v = d[i].data[dataIndex];
15250 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
15259 * Revert to a view of the Record cache with no filtering applied.
15260 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
15262 clearFilter : function(suppressEvent){
15263 if(this.snapshot && this.snapshot != this.data){
15264 this.data = this.snapshot;
15265 delete this.snapshot;
15266 if(suppressEvent !== true){
15267 this.fireEvent("datachanged", this);
15273 afterEdit : function(record){
15274 if(this.modified.indexOf(record) == -1){
15275 this.modified.push(record);
15277 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
15281 afterReject : function(record){
15282 this.modified.remove(record);
15283 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
15287 afterCommit : function(record){
15288 this.modified.remove(record);
15289 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
15293 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
15294 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
15296 commitChanges : function(){
15297 var m = this.modified.slice(0);
15298 this.modified = [];
15299 for(var i = 0, len = m.length; i < len; i++){
15305 * Cancel outstanding changes on all changed records.
15307 rejectChanges : function(){
15308 var m = this.modified.slice(0);
15309 this.modified = [];
15310 for(var i = 0, len = m.length; i < len; i++){
15315 onMetaChange : function(meta, rtype, o){
15316 this.recordType = rtype;
15317 this.fields = rtype.prototype.fields;
15318 delete this.snapshot;
15319 this.sortInfo = meta.sortInfo || this.sortInfo;
15320 this.modified = [];
15321 this.fireEvent('metachange', this, this.reader.meta);
15324 moveIndex : function(data, type)
15326 var index = this.indexOf(data);
15328 var newIndex = index + type;
15332 this.insert(newIndex, data);
15337 * Ext JS Library 1.1.1
15338 * Copyright(c) 2006-2007, Ext JS, LLC.
15340 * Originally Released Under LGPL - original licence link has changed is not relivant.
15343 * <script type="text/javascript">
15347 * @class Roo.data.SimpleStore
15348 * @extends Roo.data.Store
15349 * Small helper class to make creating Stores from Array data easier.
15350 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
15351 * @cfg {Array} fields An array of field definition objects, or field name strings.
15352 * @cfg {Object} an existing reader (eg. copied from another store)
15353 * @cfg {Array} data The multi-dimensional array of data
15354 * @cfg {Roo.data.DataProxy} proxy [not-required]
15355 * @cfg {Roo.data.Reader} reader [not-required]
15357 * @param {Object} config
15359 Roo.data.SimpleStore = function(config)
15361 Roo.data.SimpleStore.superclass.constructor.call(this, {
15363 reader: typeof(config.reader) != 'undefined' ? config.reader : new Roo.data.ArrayReader({
15366 Roo.data.Record.create(config.fields)
15368 proxy : new Roo.data.MemoryProxy(config.data)
15372 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
15374 * Ext JS Library 1.1.1
15375 * Copyright(c) 2006-2007, Ext JS, LLC.
15377 * Originally Released Under LGPL - original licence link has changed is not relivant.
15380 * <script type="text/javascript">
15385 * @extends Roo.data.Store
15386 * @class Roo.data.JsonStore
15387 * Small helper class to make creating Stores for JSON data easier. <br/>
15389 var store = new Roo.data.JsonStore({
15390 url: 'get-images.php',
15392 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
15395 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
15396 * JsonReader and HttpProxy (unless inline data is provided).</b>
15397 * @cfg {Array} fields An array of field definition objects, or field name strings.
15399 * @param {Object} config
15401 Roo.data.JsonStore = function(c){
15402 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
15403 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
15404 reader: new Roo.data.JsonReader(c, c.fields)
15407 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
15409 * Ext JS Library 1.1.1
15410 * Copyright(c) 2006-2007, Ext JS, LLC.
15412 * Originally Released Under LGPL - original licence link has changed is not relivant.
15415 * <script type="text/javascript">
15419 Roo.data.Field = function(config){
15420 if(typeof config == "string"){
15421 config = {name: config};
15423 Roo.apply(this, config);
15426 this.type = "auto";
15429 var st = Roo.data.SortTypes;
15430 // named sortTypes are supported, here we look them up
15431 if(typeof this.sortType == "string"){
15432 this.sortType = st[this.sortType];
15435 // set default sortType for strings and dates
15436 if(!this.sortType){
15439 this.sortType = st.asUCString;
15442 this.sortType = st.asDate;
15445 this.sortType = st.none;
15450 var stripRe = /[\$,%]/g;
15452 // prebuilt conversion function for this field, instead of
15453 // switching every time we're reading a value
15455 var cv, dateFormat = this.dateFormat;
15460 cv = function(v){ return v; };
15463 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
15467 return v !== undefined && v !== null && v !== '' ?
15468 parseInt(String(v).replace(stripRe, ""), 10) : '';
15473 return v !== undefined && v !== null && v !== '' ?
15474 parseFloat(String(v).replace(stripRe, ""), 10) : '';
15479 cv = function(v){ return v === true || v === "true" || v == 1; };
15486 if(v instanceof Date){
15490 if(dateFormat == "timestamp"){
15491 return new Date(v*1000);
15493 return Date.parseDate(v, dateFormat);
15495 var parsed = Date.parse(v);
15496 return parsed ? new Date(parsed) : null;
15505 Roo.data.Field.prototype = {
15513 * Ext JS Library 1.1.1
15514 * Copyright(c) 2006-2007, Ext JS, LLC.
15516 * Originally Released Under LGPL - original licence link has changed is not relivant.
15519 * <script type="text/javascript">
15522 // Base class for reading structured data from a data source. This class is intended to be
15523 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
15526 * @class Roo.data.DataReader
15528 * Base class for reading structured data from a data source. This class is intended to be
15529 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
15532 Roo.data.DataReader = function(meta, recordType){
15536 this.recordType = recordType instanceof Array ?
15537 Roo.data.Record.create(recordType) : recordType;
15540 Roo.data.DataReader.prototype = {
15543 readerType : 'Data',
15545 * Create an empty record
15546 * @param {Object} data (optional) - overlay some values
15547 * @return {Roo.data.Record} record created.
15549 newRow : function(d) {
15551 this.recordType.prototype.fields.each(function(c) {
15553 case 'int' : da[c.name] = 0; break;
15554 case 'date' : da[c.name] = new Date(); break;
15555 case 'float' : da[c.name] = 0.0; break;
15556 case 'boolean' : da[c.name] = false; break;
15557 default : da[c.name] = ""; break;
15561 return new this.recordType(Roo.apply(da, d));
15567 * Ext JS Library 1.1.1
15568 * Copyright(c) 2006-2007, Ext JS, LLC.
15570 * Originally Released Under LGPL - original licence link has changed is not relivant.
15573 * <script type="text/javascript">
15577 * @class Roo.data.DataProxy
15578 * @extends Roo.data.Observable
15580 * This class is an abstract base class for implementations which provide retrieval of
15581 * unformatted data objects.<br>
15583 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
15584 * (of the appropriate type which knows how to parse the data object) to provide a block of
15585 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
15587 * Custom implementations must implement the load method as described in
15588 * {@link Roo.data.HttpProxy#load}.
15590 Roo.data.DataProxy = function(){
15593 * @event beforeload
15594 * Fires before a network request is made to retrieve a data object.
15595 * @param {Object} This DataProxy object.
15596 * @param {Object} params The params parameter to the load function.
15601 * Fires before the load method's callback is called.
15602 * @param {Object} This DataProxy object.
15603 * @param {Object} o The data object.
15604 * @param {Object} arg The callback argument object passed to the load function.
15608 * @event loadexception
15609 * Fires if an Exception occurs during data retrieval.
15610 * @param {Object} This DataProxy object.
15611 * @param {Object} o The data object.
15612 * @param {Object} arg The callback argument object passed to the load function.
15613 * @param {Object} e The Exception.
15615 loadexception : true
15617 Roo.data.DataProxy.superclass.constructor.call(this);
15620 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
15623 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
15627 * Ext JS Library 1.1.1
15628 * Copyright(c) 2006-2007, Ext JS, LLC.
15630 * Originally Released Under LGPL - original licence link has changed is not relivant.
15633 * <script type="text/javascript">
15636 * @class Roo.data.MemoryProxy
15637 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
15638 * to the Reader when its load method is called.
15640 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
15642 Roo.data.MemoryProxy = function(data){
15646 Roo.data.MemoryProxy.superclass.constructor.call(this);
15650 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
15653 * Load data from the requested source (in this case an in-memory
15654 * data object passed to the constructor), read the data object into
15655 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
15656 * process that block using the passed callback.
15657 * @param {Object} params This parameter is not used by the MemoryProxy class.
15658 * @param {Roo.data.DataReader} reader The Reader object which converts the data
15659 * object into a block of Roo.data.Records.
15660 * @param {Function} callback The function into which to pass the block of Roo.data.records.
15661 * The function must be passed <ul>
15662 * <li>The Record block object</li>
15663 * <li>The "arg" argument from the load function</li>
15664 * <li>A boolean success indicator</li>
15666 * @param {Object} scope The scope in which to call the callback
15667 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
15669 load : function(params, reader, callback, scope, arg){
15670 params = params || {};
15673 result = reader.readRecords(params.data ? params.data :this.data);
15675 this.fireEvent("loadexception", this, arg, null, e);
15676 callback.call(scope, null, arg, false);
15679 callback.call(scope, result, arg, true);
15683 update : function(params, records){
15688 * Ext JS Library 1.1.1
15689 * Copyright(c) 2006-2007, Ext JS, LLC.
15691 * Originally Released Under LGPL - original licence link has changed is not relivant.
15694 * <script type="text/javascript">
15697 * @class Roo.data.HttpProxy
15698 * @extends Roo.data.DataProxy
15699 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
15700 * configured to reference a certain URL.<br><br>
15702 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
15703 * from which the running page was served.<br><br>
15705 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
15707 * Be aware that to enable the browser to parse an XML document, the server must set
15708 * the Content-Type header in the HTTP response to "text/xml".
15710 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
15711 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
15712 * will be used to make the request.
15714 Roo.data.HttpProxy = function(conn){
15715 Roo.data.HttpProxy.superclass.constructor.call(this);
15716 // is conn a conn config or a real conn?
15718 this.useAjax = !conn || !conn.events;
15722 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
15723 // thse are take from connection...
15726 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
15729 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
15730 * extra parameters to each request made by this object. (defaults to undefined)
15733 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
15734 * to each request made by this object. (defaults to undefined)
15737 * @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)
15740 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
15743 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
15749 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
15753 * Return the {@link Roo.data.Connection} object being used by this Proxy.
15754 * @return {Connection} The Connection object. This object may be used to subscribe to events on
15755 * a finer-grained basis than the DataProxy events.
15757 getConnection : function(){
15758 return this.useAjax ? Roo.Ajax : this.conn;
15762 * Load data from the configured {@link Roo.data.Connection}, read the data object into
15763 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
15764 * process that block using the passed callback.
15765 * @param {Object} params An object containing properties which are to be used as HTTP parameters
15766 * for the request to the remote server.
15767 * @param {Roo.data.DataReader} reader The Reader object which converts the data
15768 * object into a block of Roo.data.Records.
15769 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
15770 * The function must be passed <ul>
15771 * <li>The Record block object</li>
15772 * <li>The "arg" argument from the load function</li>
15773 * <li>A boolean success indicator</li>
15775 * @param {Object} scope The scope in which to call the callback
15776 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
15778 load : function(params, reader, callback, scope, arg){
15779 if(this.fireEvent("beforeload", this, params) !== false){
15781 params : params || {},
15783 callback : callback,
15788 callback : this.loadResponse,
15792 Roo.applyIf(o, this.conn);
15793 if(this.activeRequest){
15794 Roo.Ajax.abort(this.activeRequest);
15796 this.activeRequest = Roo.Ajax.request(o);
15798 this.conn.request(o);
15801 callback.call(scope||this, null, arg, false);
15806 loadResponse : function(o, success, response){
15807 delete this.activeRequest;
15809 this.fireEvent("loadexception", this, o, response);
15810 o.request.callback.call(o.request.scope, null, o.request.arg, false);
15815 result = o.reader.read(response);
15817 this.fireEvent("loadexception", this, o, response, e);
15818 o.request.callback.call(o.request.scope, null, o.request.arg, false);
15822 this.fireEvent("load", this, o, o.request.arg);
15823 o.request.callback.call(o.request.scope, result, o.request.arg, true);
15827 update : function(dataSet){
15832 updateResponse : function(dataSet){
15837 * Ext JS Library 1.1.1
15838 * Copyright(c) 2006-2007, Ext JS, LLC.
15840 * Originally Released Under LGPL - original licence link has changed is not relivant.
15843 * <script type="text/javascript">
15847 * @class Roo.data.ScriptTagProxy
15848 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
15849 * other than the originating domain of the running page.<br><br>
15851 * <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
15852 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
15854 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
15855 * source code that is used as the source inside a <script> tag.<br><br>
15857 * In order for the browser to process the returned data, the server must wrap the data object
15858 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
15859 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
15860 * depending on whether the callback name was passed:
15863 boolean scriptTag = false;
15864 String cb = request.getParameter("callback");
15867 response.setContentType("text/javascript");
15869 response.setContentType("application/x-json");
15871 Writer out = response.getWriter();
15873 out.write(cb + "(");
15875 out.print(dataBlock.toJsonString());
15882 * @param {Object} config A configuration object.
15884 Roo.data.ScriptTagProxy = function(config){
15885 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
15886 Roo.apply(this, config);
15887 this.head = document.getElementsByTagName("head")[0];
15890 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
15892 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
15894 * @cfg {String} url The URL from which to request the data object.
15897 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
15901 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
15902 * the server the name of the callback function set up by the load call to process the returned data object.
15903 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
15904 * javascript output which calls this named function passing the data object as its only parameter.
15906 callbackParam : "callback",
15908 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
15909 * name to the request.
15914 * Load data from the configured URL, read the data object into
15915 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
15916 * process that block using the passed callback.
15917 * @param {Object} params An object containing properties which are to be used as HTTP parameters
15918 * for the request to the remote server.
15919 * @param {Roo.data.DataReader} reader The Reader object which converts the data
15920 * object into a block of Roo.data.Records.
15921 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
15922 * The function must be passed <ul>
15923 * <li>The Record block object</li>
15924 * <li>The "arg" argument from the load function</li>
15925 * <li>A boolean success indicator</li>
15927 * @param {Object} scope The scope in which to call the callback
15928 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
15930 load : function(params, reader, callback, scope, arg){
15931 if(this.fireEvent("beforeload", this, params) !== false){
15933 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
15935 var url = this.url;
15936 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
15938 url += "&_dc=" + (new Date().getTime());
15940 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
15943 cb : "stcCallback"+transId,
15944 scriptId : "stcScript"+transId,
15948 callback : callback,
15954 window[trans.cb] = function(o){
15955 conn.handleResponse(o, trans);
15958 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
15960 if(this.autoAbort !== false){
15964 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
15966 var script = document.createElement("script");
15967 script.setAttribute("src", url);
15968 script.setAttribute("type", "text/javascript");
15969 script.setAttribute("id", trans.scriptId);
15970 this.head.appendChild(script);
15972 this.trans = trans;
15974 callback.call(scope||this, null, arg, false);
15979 isLoading : function(){
15980 return this.trans ? true : false;
15984 * Abort the current server request.
15986 abort : function(){
15987 if(this.isLoading()){
15988 this.destroyTrans(this.trans);
15993 destroyTrans : function(trans, isLoaded){
15994 this.head.removeChild(document.getElementById(trans.scriptId));
15995 clearTimeout(trans.timeoutId);
15997 window[trans.cb] = undefined;
15999 delete window[trans.cb];
16002 // if hasn't been loaded, wait for load to remove it to prevent script error
16003 window[trans.cb] = function(){
16004 window[trans.cb] = undefined;
16006 delete window[trans.cb];
16013 handleResponse : function(o, trans){
16014 this.trans = false;
16015 this.destroyTrans(trans, true);
16018 result = trans.reader.readRecords(o);
16020 this.fireEvent("loadexception", this, o, trans.arg, e);
16021 trans.callback.call(trans.scope||window, null, trans.arg, false);
16024 this.fireEvent("load", this, o, trans.arg);
16025 trans.callback.call(trans.scope||window, result, trans.arg, true);
16029 handleFailure : function(trans){
16030 this.trans = false;
16031 this.destroyTrans(trans, false);
16032 this.fireEvent("loadexception", this, null, trans.arg);
16033 trans.callback.call(trans.scope||window, null, trans.arg, false);
16037 * Ext JS Library 1.1.1
16038 * Copyright(c) 2006-2007, Ext JS, LLC.
16040 * Originally Released Under LGPL - original licence link has changed is not relivant.
16043 * <script type="text/javascript">
16047 * @class Roo.data.JsonReader
16048 * @extends Roo.data.DataReader
16049 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
16050 * based on mappings in a provided Roo.data.Record constructor.
16052 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
16053 * in the reply previously.
16058 var RecordDef = Roo.data.Record.create([
16059 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
16060 {name: 'occupation'} // This field will use "occupation" as the mapping.
16062 var myReader = new Roo.data.JsonReader({
16063 totalProperty: "results", // The property which contains the total dataset size (optional)
16064 root: "rows", // The property which contains an Array of row objects
16065 id: "id" // The property within each row object that provides an ID for the record (optional)
16069 * This would consume a JSON file like this:
16071 { 'results': 2, 'rows': [
16072 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
16073 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
16076 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
16077 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
16078 * paged from the remote server.
16079 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
16080 * @cfg {String} root name of the property which contains the Array of row objects.
16081 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
16082 * @cfg {Array} fields Array of field definition objects
16084 * Create a new JsonReader
16085 * @param {Object} meta Metadata configuration options
16086 * @param {Object} recordType Either an Array of field definition objects,
16087 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
16089 Roo.data.JsonReader = function(meta, recordType){
16092 // set some defaults:
16093 Roo.applyIf(meta, {
16094 totalProperty: 'total',
16095 successProperty : 'success',
16100 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
16102 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
16104 readerType : 'Json',
16107 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
16108 * Used by Store query builder to append _requestMeta to params.
16111 metaFromRemote : false,
16113 * This method is only used by a DataProxy which has retrieved data from a remote server.
16114 * @param {Object} response The XHR object which contains the JSON data in its responseText.
16115 * @return {Object} data A data block which is used by an Roo.data.Store object as
16116 * a cache of Roo.data.Records.
16118 read : function(response){
16119 var json = response.responseText;
16121 var o = /* eval:var:o */ eval("("+json+")");
16123 throw {message: "JsonReader.read: Json object not found"};
16129 this.metaFromRemote = true;
16130 this.meta = o.metaData;
16131 this.recordType = Roo.data.Record.create(o.metaData.fields);
16132 this.onMetaChange(this.meta, this.recordType, o);
16134 return this.readRecords(o);
16137 // private function a store will implement
16138 onMetaChange : function(meta, recordType, o){
16145 simpleAccess: function(obj, subsc) {
16152 getJsonAccessor: function(){
16154 return function(expr) {
16156 return(re.test(expr))
16157 ? new Function("obj", "return obj." + expr)
16162 return Roo.emptyFn;
16167 * Create a data block containing Roo.data.Records from an XML document.
16168 * @param {Object} o An object which contains an Array of row objects in the property specified
16169 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
16170 * which contains the total size of the dataset.
16171 * @return {Object} data A data block which is used by an Roo.data.Store object as
16172 * a cache of Roo.data.Records.
16174 readRecords : function(o){
16176 * After any data loads, the raw JSON data is available for further custom processing.
16180 var s = this.meta, Record = this.recordType,
16181 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
16183 // Generate extraction functions for the totalProperty, the root, the id, and for each field
16185 if(s.totalProperty) {
16186 this.getTotal = this.getJsonAccessor(s.totalProperty);
16188 if(s.successProperty) {
16189 this.getSuccess = this.getJsonAccessor(s.successProperty);
16191 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
16193 var g = this.getJsonAccessor(s.id);
16194 this.getId = function(rec) {
16196 return (r === undefined || r === "") ? null : r;
16199 this.getId = function(){return null;};
16202 for(var jj = 0; jj < fl; jj++){
16204 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
16205 this.ef[jj] = this.getJsonAccessor(map);
16209 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
16210 if(s.totalProperty){
16211 var vt = parseInt(this.getTotal(o), 10);
16216 if(s.successProperty){
16217 var vs = this.getSuccess(o);
16218 if(vs === false || vs === 'false'){
16223 for(var i = 0; i < c; i++){
16226 var id = this.getId(n);
16227 for(var j = 0; j < fl; j++){
16229 var v = this.ef[j](n);
16231 Roo.log('missing convert for ' + f.name);
16235 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
16237 var record = new Record(values, id);
16239 records[i] = record;
16245 totalRecords : totalRecords
16248 // used when loading children.. @see loadDataFromChildren
16249 toLoadData: function(rec)
16251 // expect rec just to be an array.. eg [a,b,c, [...] << cn ]
16252 var data = typeof(rec.data.cn) == 'undefined' ? [] : rec.data.cn;
16253 return { data : data, total : data.length };
16258 * Ext JS Library 1.1.1
16259 * Copyright(c) 2006-2007, Ext JS, LLC.
16261 * Originally Released Under LGPL - original licence link has changed is not relivant.
16264 * <script type="text/javascript">
16268 * @class Roo.data.ArrayReader
16269 * @extends Roo.data.DataReader
16270 * Data reader class to create an Array of Roo.data.Record objects from an Array.
16271 * Each element of that Array represents a row of data fields. The
16272 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
16273 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
16277 var RecordDef = Roo.data.Record.create([
16278 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
16279 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
16281 var myReader = new Roo.data.ArrayReader({
16282 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
16286 * This would consume an Array like this:
16288 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
16292 * Create a new JsonReader
16293 * @param {Object} meta Metadata configuration options.
16294 * @param {Object|Array} recordType Either an Array of field definition objects
16296 * @cfg {Array} fields Array of field definition objects
16297 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
16298 * as specified to {@link Roo.data.Record#create},
16299 * or an {@link Roo.data.Record} object
16302 * created using {@link Roo.data.Record#create}.
16304 Roo.data.ArrayReader = function(meta, recordType)
16306 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType||meta.fields);
16309 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
16312 * Create a data block containing Roo.data.Records from an XML document.
16313 * @param {Object} o An Array of row objects which represents the dataset.
16314 * @return {Object} A data block which is used by an {@link Roo.data.Store} object as
16315 * a cache of Roo.data.Records.
16317 readRecords : function(o)
16319 var sid = this.meta ? this.meta.id : null;
16320 var recordType = this.recordType, fields = recordType.prototype.fields;
16323 for(var i = 0; i < root.length; i++){
16326 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
16327 for(var j = 0, jlen = fields.length; j < jlen; j++){
16328 var f = fields.items[j];
16329 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
16330 var v = n[k] !== undefined ? n[k] : f.defaultValue;
16332 values[f.name] = v;
16334 var record = new recordType(values, id);
16336 records[records.length] = record;
16340 totalRecords : records.length
16343 // used when loading children.. @see loadDataFromChildren
16344 toLoadData: function(rec)
16346 // expect rec just to be an array.. eg [a,b,c, [...] << cn ]
16347 return typeof(rec.data.cn) == 'undefined' ? [] : rec.data.cn;
16358 * @class Roo.bootstrap.ComboBox
16359 * @extends Roo.bootstrap.TriggerField
16360 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
16361 * @cfg {Boolean} append (true|false) default false
16362 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
16363 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
16364 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
16365 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
16366 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
16367 * @cfg {Boolean} animate default true
16368 * @cfg {Boolean} emptyResultText only for touch device
16369 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
16370 * @cfg {String} emptyTitle default ''
16371 * @cfg {Number} width fixed with? experimental
16373 * Create a new ComboBox.
16374 * @param {Object} config Configuration options
16376 Roo.bootstrap.ComboBox = function(config){
16377 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
16381 * Fires when the dropdown list is expanded
16382 * @param {Roo.bootstrap.ComboBox} combo This combo box
16387 * Fires when the dropdown list is collapsed
16388 * @param {Roo.bootstrap.ComboBox} combo This combo box
16392 * @event beforeselect
16393 * Fires before a list item is selected. Return false to cancel the selection.
16394 * @param {Roo.bootstrap.ComboBox} combo This combo box
16395 * @param {Roo.data.Record} record The data record returned from the underlying store
16396 * @param {Number} index The index of the selected item in the dropdown list
16398 'beforeselect' : true,
16401 * Fires when a list item is selected
16402 * @param {Roo.bootstrap.ComboBox} combo This combo box
16403 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
16404 * @param {Number} index The index of the selected item in the dropdown list
16408 * @event beforequery
16409 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
16410 * The event object passed has these properties:
16411 * @param {Roo.bootstrap.ComboBox} combo This combo box
16412 * @param {String} query The query
16413 * @param {Boolean} forceAll true to force "all" query
16414 * @param {Boolean} cancel true to cancel the query
16415 * @param {Object} e The query event object
16417 'beforequery': true,
16420 * Fires when the 'add' icon is pressed (add a listener to enable add button)
16421 * @param {Roo.bootstrap.ComboBox} combo This combo box
16426 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
16427 * @param {Roo.bootstrap.ComboBox} combo This combo box
16428 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
16433 * Fires when the remove value from the combobox array
16434 * @param {Roo.bootstrap.ComboBox} combo This combo box
16438 * @event afterremove
16439 * Fires when the remove value from the combobox array
16440 * @param {Roo.bootstrap.ComboBox} combo This combo box
16442 'afterremove' : true,
16444 * @event specialfilter
16445 * Fires when specialfilter
16446 * @param {Roo.bootstrap.ComboBox} combo This combo box
16448 'specialfilter' : true,
16451 * Fires when tick the element
16452 * @param {Roo.bootstrap.ComboBox} combo This combo box
16456 * @event touchviewdisplay
16457 * Fires when touch view require special display (default is using displayField)
16458 * @param {Roo.bootstrap.ComboBox} combo This combo box
16459 * @param {Object} cfg set html .
16461 'touchviewdisplay' : true
16466 this.tickItems = [];
16468 this.selectedIndex = -1;
16469 if(this.mode == 'local'){
16470 if(config.queryDelay === undefined){
16471 this.queryDelay = 10;
16473 if(config.minChars === undefined){
16479 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
16482 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
16483 * rendering into an Roo.Editor, defaults to false)
16486 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
16487 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
16490 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
16493 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
16494 * the dropdown list (defaults to undefined, with no header element)
16498 * @cfg {String/Roo.Template} tpl The template to use to render the output default is '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>'
16502 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
16504 listWidth: undefined,
16506 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
16507 * mode = 'remote' or 'text' if mode = 'local')
16509 displayField: undefined,
16512 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
16513 * mode = 'remote' or 'value' if mode = 'local').
16514 * Note: use of a valueField requires the user make a selection
16515 * in order for a value to be mapped.
16517 valueField: undefined,
16519 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
16524 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
16525 * field's data value (defaults to the underlying DOM element's name)
16527 hiddenName: undefined,
16529 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
16533 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
16535 selectedClass: 'active',
16538 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
16542 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
16543 * anchor positions (defaults to 'tl-bl')
16545 listAlign: 'tl-bl?',
16547 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
16551 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
16552 * query specified by the allQuery config option (defaults to 'query')
16554 triggerAction: 'query',
16556 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
16557 * (defaults to 4, does not apply if editable = false)
16561 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
16562 * delay (typeAheadDelay) if it matches a known value (defaults to false)
16566 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
16567 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
16571 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
16572 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
16576 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
16577 * when editable = true (defaults to false)
16579 selectOnFocus:false,
16581 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
16583 queryParam: 'query',
16585 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
16586 * when mode = 'remote' (defaults to 'Loading...')
16588 loadingText: 'Loading...',
16590 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
16594 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
16598 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
16599 * traditional select (defaults to true)
16603 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
16607 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
16611 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
16612 * listWidth has a higher value)
16616 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
16617 * allow the user to set arbitrary text into the field (defaults to false)
16619 forceSelection:false,
16621 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
16622 * if typeAhead = true (defaults to 250)
16624 typeAheadDelay : 250,
16626 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
16627 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
16629 valueNotFoundText : undefined,
16631 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
16633 blockFocus : false,
16636 * @cfg {Boolean} disableClear Disable showing of clear button.
16638 disableClear : false,
16640 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
16642 alwaysQuery : false,
16645 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
16650 * @cfg {String} invalidClass DEPRICATED - uses BS4 is-valid now
16652 invalidClass : "has-warning",
16655 * @cfg {String} validClass DEPRICATED - uses BS4 is-valid now
16657 validClass : "has-success",
16660 * @cfg {Boolean} specialFilter (true|false) special filter default false
16662 specialFilter : false,
16665 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
16667 mobileTouchView : true,
16670 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
16672 useNativeIOS : false,
16675 * @cfg {Boolean} mobile_restrict_height (true|false) restrict height for touch view
16677 mobile_restrict_height : false,
16679 ios_options : false,
16691 btnPosition : 'right',
16692 triggerList : true,
16693 showToggleBtn : true,
16695 emptyResultText: 'Empty',
16696 triggerText : 'Select',
16700 // element that contains real text value.. (when hidden is used..)
16702 getAutoCreate : function()
16707 * Render classic select for iso
16710 if(Roo.isIOS && this.useNativeIOS){
16711 cfg = this.getAutoCreateNativeIOS();
16719 if(Roo.isTouch && this.mobileTouchView){
16720 cfg = this.getAutoCreateTouchView();
16727 if(!this.tickable){
16728 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
16733 * ComboBox with tickable selections
16736 var align = this.labelAlign || this.parentLabelAlign();
16739 cls : 'form-group roo-combobox-tickable' //input-group
16742 var btn_text_select = '';
16743 var btn_text_done = '';
16744 var btn_text_cancel = '';
16746 if (this.btn_text_show) {
16747 btn_text_select = 'Select';
16748 btn_text_done = 'Done';
16749 btn_text_cancel = 'Cancel';
16754 cls : 'tickable-buttons',
16759 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
16760 //html : this.triggerText
16761 html: btn_text_select
16767 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
16769 html: btn_text_done
16775 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
16777 html: btn_text_cancel
16783 buttons.cn.unshift({
16785 cls: 'roo-select2-search-field-input'
16791 Roo.each(buttons.cn, function(c){
16793 c.cls += ' btn-' + _this.size;
16796 if (_this.disabled) {
16803 style : 'display: contents',
16808 cls: 'form-hidden-field'
16812 cls: 'roo-select2-choices',
16816 cls: 'roo-select2-search-field',
16827 cls: 'roo-select2-container input-group roo-select2-container-multi',
16833 // cls: 'typeahead typeahead-long dropdown-menu',
16834 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
16839 if(this.hasFeedback && !this.allowBlank){
16843 cls: 'glyphicon form-control-feedback'
16846 combobox.cn.push(feedback);
16853 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
16854 tooltip : 'This field is required'
16856 if (Roo.bootstrap.version == 4) {
16859 style : 'display:none'
16862 if (align ==='left' && this.fieldLabel.length) {
16864 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
16871 cls : 'control-label col-form-label',
16872 html : this.fieldLabel
16884 var labelCfg = cfg.cn[1];
16885 var contentCfg = cfg.cn[2];
16888 if(this.indicatorpos == 'right'){
16894 cls : 'control-label col-form-label',
16898 html : this.fieldLabel
16914 labelCfg = cfg.cn[0];
16915 contentCfg = cfg.cn[1];
16919 if(this.labelWidth > 12){
16920 labelCfg.style = "width: " + this.labelWidth + 'px';
16922 if(this.width * 1 > 0){
16923 contentCfg.style = "width: " + this.width + 'px';
16925 if(this.labelWidth < 13 && this.labelmd == 0){
16926 this.labelmd = this.labelWidth;
16929 if(this.labellg > 0){
16930 labelCfg.cls += ' col-lg-' + this.labellg;
16931 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
16934 if(this.labelmd > 0){
16935 labelCfg.cls += ' col-md-' + this.labelmd;
16936 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
16939 if(this.labelsm > 0){
16940 labelCfg.cls += ' col-sm-' + this.labelsm;
16941 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
16944 if(this.labelxs > 0){
16945 labelCfg.cls += ' col-xs-' + this.labelxs;
16946 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
16950 } else if ( this.fieldLabel.length) {
16951 // Roo.log(" label");
16956 //cls : 'input-group-addon',
16957 html : this.fieldLabel
16962 if(this.indicatorpos == 'right'){
16966 //cls : 'input-group-addon',
16967 html : this.fieldLabel
16977 // Roo.log(" no label && no align");
16984 ['xs','sm','md','lg'].map(function(size){
16985 if (settings[size]) {
16986 cfg.cls += ' col-' + size + '-' + settings[size];
16994 _initEventsCalled : false,
16997 initEvents: function()
16999 if (this._initEventsCalled) { // as we call render... prevent looping...
17002 this._initEventsCalled = true;
17005 throw "can not find store for combo";
17008 this.indicator = this.indicatorEl();
17010 this.store = Roo.factory(this.store, Roo.data);
17011 this.store.parent = this;
17013 // if we are building from html. then this element is so complex, that we can not really
17014 // use the rendered HTML.
17015 // so we have to trash and replace the previous code.
17016 if (Roo.XComponent.build_from_html) {
17017 // remove this element....
17018 var e = this.el.dom, k=0;
17019 while (e ) { e = e.previousSibling; ++k;}
17024 this.rendered = false;
17026 this.render(this.parent().getChildContainer(true), k);
17029 if(Roo.isIOS && this.useNativeIOS){
17030 this.initIOSView();
17038 if(Roo.isTouch && this.mobileTouchView){
17039 this.initTouchView();
17044 this.initTickableEvents();
17048 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
17050 if(this.hiddenName){
17052 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
17054 this.hiddenField.dom.value =
17055 this.hiddenValue !== undefined ? this.hiddenValue :
17056 this.value !== undefined ? this.value : '';
17058 // prevent input submission
17059 this.el.dom.removeAttribute('name');
17060 this.hiddenField.dom.setAttribute('name', this.hiddenName);
17065 // this.el.dom.setAttribute('autocomplete', 'off');
17068 var cls = 'x-combo-list';
17070 //this.list = new Roo.Layer({
17071 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
17077 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
17078 _this.list.setWidth(lw);
17081 this.list.on('mouseover', this.onViewOver, this);
17082 this.list.on('mousemove', this.onViewMove, this);
17083 this.list.on('scroll', this.onViewScroll, this);
17086 this.list.swallowEvent('mousewheel');
17087 this.assetHeight = 0;
17090 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
17091 this.assetHeight += this.header.getHeight();
17094 this.innerList = this.list.createChild({cls:cls+'-inner'});
17095 this.innerList.on('mouseover', this.onViewOver, this);
17096 this.innerList.on('mousemove', this.onViewMove, this);
17097 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
17099 if(this.allowBlank && !this.pageSize && !this.disableClear){
17100 this.footer = this.list.createChild({cls:cls+'-ft'});
17101 this.pageTb = new Roo.Toolbar(this.footer);
17105 this.footer = this.list.createChild({cls:cls+'-ft'});
17106 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
17107 {pageSize: this.pageSize});
17111 if (this.pageTb && this.allowBlank && !this.disableClear) {
17113 this.pageTb.add(new Roo.Toolbar.Fill(), {
17114 cls: 'x-btn-icon x-btn-clear',
17116 handler: function()
17119 _this.clearValue();
17120 _this.onSelect(false, -1);
17125 this.assetHeight += this.footer.getHeight();
17130 this.tpl = Roo.bootstrap.version == 4 ?
17131 '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>' : // 4 does not need <li> and it get's really confisued.
17132 '<li><a class="dropdown-item" href="#">{' + this.displayField + '}</a></li>';
17135 this.view = new Roo.View(this.list, this.tpl, {
17136 singleSelect:true, store: this.store, selectedClass: this.selectedClass
17138 //this.view.wrapEl.setDisplayed(false);
17139 this.view.on('click', this.onViewClick, this);
17142 this.store.on('beforeload', this.onBeforeLoad, this);
17143 this.store.on('load', this.onLoad, this);
17144 this.store.on('loadexception', this.onLoadException, this);
17146 if(this.resizable){
17147 this.resizer = new Roo.Resizable(this.list, {
17148 pinned:true, handles:'se'
17150 this.resizer.on('resize', function(r, w, h){
17151 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
17152 this.listWidth = w;
17153 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
17154 this.restrictHeight();
17156 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
17159 if(!this.editable){
17160 this.editable = true;
17161 this.setEditable(false);
17166 if (typeof(this.events.add.listeners) != 'undefined') {
17168 this.addicon = this.wrap.createChild(
17169 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
17171 this.addicon.on('click', function(e) {
17172 this.fireEvent('add', this);
17175 if (typeof(this.events.edit.listeners) != 'undefined') {
17177 this.editicon = this.wrap.createChild(
17178 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
17179 if (this.addicon) {
17180 this.editicon.setStyle('margin-left', '40px');
17182 this.editicon.on('click', function(e) {
17184 // we fire even if inothing is selected..
17185 this.fireEvent('edit', this, this.lastData );
17191 this.keyNav = new Roo.KeyNav(this.inputEl(), {
17192 "up" : function(e){
17193 this.inKeyMode = true;
17197 "down" : function(e){
17198 if(!this.isExpanded()){
17199 this.onTriggerClick();
17201 this.inKeyMode = true;
17206 "enter" : function(e){
17207 // this.onViewClick();
17211 if(this.fireEvent("specialkey", this, e)){
17212 this.onViewClick(false);
17218 "esc" : function(e){
17222 "tab" : function(e){
17225 if(this.fireEvent("specialkey", this, e)){
17226 this.onViewClick(false);
17234 doRelay : function(foo, bar, hname){
17235 if(hname == 'down' || this.scope.isExpanded()){
17236 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
17245 this.queryDelay = Math.max(this.queryDelay || 10,
17246 this.mode == 'local' ? 10 : 250);
17249 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
17251 if(this.typeAhead){
17252 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
17254 if(this.editable !== false){
17255 this.inputEl().on("keyup", this.onKeyUp, this);
17257 if(this.forceSelection){
17258 this.inputEl().on('blur', this.doForce, this);
17262 this.choices = this.el.select('ul.roo-select2-choices', true).first();
17263 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
17267 initTickableEvents: function()
17271 if(this.hiddenName){
17273 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
17275 this.hiddenField.dom.value =
17276 this.hiddenValue !== undefined ? this.hiddenValue :
17277 this.value !== undefined ? this.value : '';
17279 // prevent input submission
17280 this.el.dom.removeAttribute('name');
17281 this.hiddenField.dom.setAttribute('name', this.hiddenName);
17286 // this.list = this.el.select('ul.dropdown-menu',true).first();
17288 this.choices = this.el.select('ul.roo-select2-choices', true).first();
17289 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
17290 if(this.triggerList){
17291 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
17294 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
17295 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
17297 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
17298 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
17300 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
17301 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
17303 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
17304 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
17305 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
17308 this.cancelBtn.hide();
17313 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
17314 _this.list.setWidth(lw);
17317 this.list.on('mouseover', this.onViewOver, this);
17318 this.list.on('mousemove', this.onViewMove, this);
17320 this.list.on('scroll', this.onViewScroll, this);
17323 this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}"' +
17324 'type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
17327 this.view = new Roo.View(this.list, this.tpl, {
17332 selectedClass: this.selectedClass
17335 //this.view.wrapEl.setDisplayed(false);
17336 this.view.on('click', this.onViewClick, this);
17340 this.store.on('beforeload', this.onBeforeLoad, this);
17341 this.store.on('load', this.onLoad, this);
17342 this.store.on('loadexception', this.onLoadException, this);
17345 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
17346 "up" : function(e){
17347 this.inKeyMode = true;
17351 "down" : function(e){
17352 this.inKeyMode = true;
17356 "enter" : function(e){
17357 if(this.fireEvent("specialkey", this, e)){
17358 this.onViewClick(false);
17364 "esc" : function(e){
17365 this.onTickableFooterButtonClick(e, false, false);
17368 "tab" : function(e){
17369 this.fireEvent("specialkey", this, e);
17371 this.onTickableFooterButtonClick(e, false, false);
17378 doRelay : function(e, fn, key){
17379 if(this.scope.isExpanded()){
17380 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
17389 this.queryDelay = Math.max(this.queryDelay || 10,
17390 this.mode == 'local' ? 10 : 250);
17393 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
17395 if(this.typeAhead){
17396 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
17399 if(this.editable !== false){
17400 this.tickableInputEl().on("keyup", this.onKeyUp, this);
17403 this.indicator = this.indicatorEl();
17405 if(this.indicator){
17406 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
17407 this.indicator.hide();
17412 onDestroy : function(){
17414 this.view.setStore(null);
17415 this.view.el.removeAllListeners();
17416 this.view.el.remove();
17417 this.view.purgeListeners();
17420 this.list.dom.innerHTML = '';
17424 this.store.un('beforeload', this.onBeforeLoad, this);
17425 this.store.un('load', this.onLoad, this);
17426 this.store.un('loadexception', this.onLoadException, this);
17428 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
17432 fireKey : function(e){
17433 if(e.isNavKeyPress() && !this.list.isVisible()){
17434 this.fireEvent("specialkey", this, e);
17439 onResize: function(w, h)
17443 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
17445 // if(typeof w != 'number'){
17446 // // we do not handle it!?!?
17449 // var tw = this.trigger.getWidth();
17450 // // tw += this.addicon ? this.addicon.getWidth() : 0;
17451 // // tw += this.editicon ? this.editicon.getWidth() : 0;
17453 // this.inputEl().setWidth( this.adjustWidth('input', x));
17455 // //this.trigger.setStyle('left', x+'px');
17457 // if(this.list && this.listWidth === undefined){
17458 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
17459 // this.list.setWidth(lw);
17460 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
17468 * Allow or prevent the user from directly editing the field text. If false is passed,
17469 * the user will only be able to select from the items defined in the dropdown list. This method
17470 * is the runtime equivalent of setting the 'editable' config option at config time.
17471 * @param {Boolean} value True to allow the user to directly edit the field text
17473 setEditable : function(value){
17474 if(value == this.editable){
17477 this.editable = value;
17479 this.inputEl().dom.setAttribute('readOnly', true);
17480 this.inputEl().on('mousedown', this.onTriggerClick, this);
17481 this.inputEl().addClass('x-combo-noedit');
17483 this.inputEl().dom.removeAttribute('readOnly');
17484 this.inputEl().un('mousedown', this.onTriggerClick, this);
17485 this.inputEl().removeClass('x-combo-noedit');
17491 onBeforeLoad : function(combo,opts){
17492 if(!this.hasFocus){
17496 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
17498 this.restrictHeight();
17499 this.selectedIndex = -1;
17503 onLoad : function(){
17505 this.hasQuery = false;
17507 if(!this.hasFocus){
17511 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
17512 this.loading.hide();
17515 if(this.store.getCount() > 0){
17518 this.restrictHeight();
17519 if(this.lastQuery == this.allQuery){
17520 if(this.editable && !this.tickable){
17521 this.inputEl().dom.select();
17525 !this.selectByValue(this.value, true) &&
17528 !this.store.lastOptions ||
17529 typeof(this.store.lastOptions.add) == 'undefined' ||
17530 this.store.lastOptions.add != true
17533 this.select(0, true);
17536 if(this.autoFocus){
17539 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
17540 this.taTask.delay(this.typeAheadDelay);
17544 this.onEmptyResults();
17550 onLoadException : function()
17552 this.hasQuery = false;
17554 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
17555 this.loading.hide();
17558 if(this.tickable && this.editable){
17563 // only causes errors at present
17564 //Roo.log(this.store.reader.jsonData);
17565 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
17567 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
17573 onTypeAhead : function(){
17574 if(this.store.getCount() > 0){
17575 var r = this.store.getAt(0);
17576 var newValue = r.data[this.displayField];
17577 var len = newValue.length;
17578 var selStart = this.getRawValue().length;
17580 if(selStart != len){
17581 this.setRawValue(newValue);
17582 this.selectText(selStart, newValue.length);
17588 onSelect : function(record, index){
17590 if(this.fireEvent('beforeselect', this, record, index) !== false){
17592 this.setFromData(index > -1 ? record.data : false);
17595 this.fireEvent('select', this, record, index);
17600 * Returns the currently selected field value or empty string if no value is set.
17601 * @return {String} value The selected value
17603 getValue : function()
17605 if(Roo.isIOS && this.useNativeIOS){
17606 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
17610 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
17613 if(this.valueField){
17614 return typeof this.value != 'undefined' ? this.value : '';
17616 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
17620 getRawValue : function()
17622 if(Roo.isIOS && this.useNativeIOS){
17623 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
17626 var v = this.inputEl().getValue();
17632 * Clears any text/value currently set in the field
17634 clearValue : function(){
17636 if(this.hiddenField){
17637 this.hiddenField.dom.value = '';
17640 this.setRawValue('');
17641 this.lastSelectionText = '';
17642 this.lastData = false;
17644 var close = this.closeTriggerEl();
17655 * Sets the specified value into the field. If the value finds a match, the corresponding record text
17656 * will be displayed in the field. If the value does not match the data value of an existing item,
17657 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
17658 * Otherwise the field will be blank (although the value will still be set).
17659 * @param {String} value The value to match
17661 setValue : function(v)
17663 if(Roo.isIOS && this.useNativeIOS){
17664 this.setIOSValue(v);
17674 if(this.valueField){
17675 var r = this.findRecord(this.valueField, v);
17677 text = r.data[this.displayField];
17678 }else if(this.valueNotFoundText !== undefined){
17679 text = this.valueNotFoundText;
17682 this.lastSelectionText = text;
17683 if(this.hiddenField){
17684 this.hiddenField.dom.value = v;
17686 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
17689 var close = this.closeTriggerEl();
17692 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
17698 * @property {Object} the last set data for the element
17703 * Sets the value of the field based on a object which is related to the record format for the store.
17704 * @param {Object} value the value to set as. or false on reset?
17706 setFromData : function(o){
17713 var dv = ''; // display value
17714 var vv = ''; // value value..
17716 if (this.displayField) {
17717 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
17719 // this is an error condition!!!
17720 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
17723 if(this.valueField){
17724 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
17727 var close = this.closeTriggerEl();
17730 if(dv.length || vv * 1 > 0){
17732 this.blockFocus=true;
17738 if(this.hiddenField){
17739 this.hiddenField.dom.value = vv;
17741 this.lastSelectionText = dv;
17742 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
17746 // no hidden field.. - we store the value in 'value', but still display
17747 // display field!!!!
17748 this.lastSelectionText = dv;
17749 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
17756 reset : function(){
17757 // overridden so that last data is reset..
17764 this.setValue(this.originalValue);
17765 //this.clearInvalid();
17766 this.lastData = false;
17768 this.view.clearSelections();
17774 findRecord : function(prop, value){
17776 if(this.store.getCount() > 0){
17777 this.store.each(function(r){
17778 if(r.data[prop] == value){
17788 getName: function()
17790 // returns hidden if it's set..
17791 if (!this.rendered) {return ''};
17792 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
17796 onViewMove : function(e, t){
17797 this.inKeyMode = false;
17801 onViewOver : function(e, t){
17802 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
17805 var item = this.view.findItemFromChild(t);
17808 var index = this.view.indexOf(item);
17809 this.select(index, false);
17814 onViewClick : function(view, doFocus, el, e)
17816 var index = this.view.getSelectedIndexes()[0];
17818 var r = this.store.getAt(index);
17822 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
17829 Roo.each(this.tickItems, function(v,k){
17831 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
17833 _this.tickItems.splice(k, 1);
17835 if(typeof(e) == 'undefined' && view == false){
17836 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
17848 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
17849 this.tickItems.push(r.data);
17852 if(typeof(e) == 'undefined' && view == false){
17853 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
17860 this.onSelect(r, index);
17862 if(doFocus !== false && !this.blockFocus){
17863 this.inputEl().focus();
17868 restrictHeight : function(){
17869 //this.innerList.dom.style.height = '';
17870 //var inner = this.innerList.dom;
17871 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
17872 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
17873 //this.list.beginUpdate();
17874 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
17875 this.list.alignTo(this.inputEl(), this.listAlign);
17876 this.list.alignTo(this.inputEl(), this.listAlign);
17877 //this.list.endUpdate();
17881 onEmptyResults : function(){
17883 if(this.tickable && this.editable){
17884 this.hasFocus = false;
17885 this.restrictHeight();
17893 * Returns true if the dropdown list is expanded, else false.
17895 isExpanded : function(){
17896 return this.list.isVisible();
17900 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
17901 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
17902 * @param {String} value The data value of the item to select
17903 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
17904 * selected item if it is not currently in view (defaults to true)
17905 * @return {Boolean} True if the value matched an item in the list, else false
17907 selectByValue : function(v, scrollIntoView){
17908 if(v !== undefined && v !== null){
17909 var r = this.findRecord(this.valueField || this.displayField, v);
17911 this.select(this.store.indexOf(r), scrollIntoView);
17919 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
17920 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
17921 * @param {Number} index The zero-based index of the list item to select
17922 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
17923 * selected item if it is not currently in view (defaults to true)
17925 select : function(index, scrollIntoView){
17926 this.selectedIndex = index;
17927 this.view.select(index);
17928 if(scrollIntoView !== false){
17929 var el = this.view.getNode(index);
17931 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
17934 this.list.scrollChildIntoView(el, false);
17940 selectNext : function(){
17941 var ct = this.store.getCount();
17943 if(this.selectedIndex == -1){
17945 }else if(this.selectedIndex < ct-1){
17946 this.select(this.selectedIndex+1);
17952 selectPrev : function(){
17953 var ct = this.store.getCount();
17955 if(this.selectedIndex == -1){
17957 }else if(this.selectedIndex != 0){
17958 this.select(this.selectedIndex-1);
17964 onKeyUp : function(e){
17965 if(this.editable !== false && !e.isSpecialKey()){
17966 this.lastKey = e.getKey();
17967 this.dqTask.delay(this.queryDelay);
17972 validateBlur : function(){
17973 return !this.list || !this.list.isVisible();
17977 initQuery : function(){
17979 var v = this.getRawValue();
17981 if(this.tickable && this.editable){
17982 v = this.tickableInputEl().getValue();
17989 doForce : function(){
17990 if(this.inputEl().dom.value.length > 0){
17991 this.inputEl().dom.value =
17992 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
17998 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
17999 * query allowing the query action to be canceled if needed.
18000 * @param {String} query The SQL query to execute
18001 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
18002 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
18003 * saved in the current store (defaults to false)
18005 doQuery : function(q, forceAll){
18007 if(q === undefined || q === null){
18012 forceAll: forceAll,
18016 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
18021 forceAll = qe.forceAll;
18022 if(forceAll === true || (q.length >= this.minChars)){
18024 this.hasQuery = true;
18026 if(this.lastQuery != q || this.alwaysQuery){
18027 this.lastQuery = q;
18028 if(this.mode == 'local'){
18029 this.selectedIndex = -1;
18031 this.store.clearFilter();
18034 if(this.specialFilter){
18035 this.fireEvent('specialfilter', this);
18040 this.store.filter(this.displayField, q);
18043 this.store.fireEvent("datachanged", this.store);
18050 this.store.baseParams[this.queryParam] = q;
18052 var options = {params : this.getParams(q)};
18055 options.add = true;
18056 options.params.start = this.page * this.pageSize;
18059 this.store.load(options);
18062 * this code will make the page width larger, at the beginning, the list not align correctly,
18063 * we should expand the list on onLoad
18064 * so command out it
18069 this.selectedIndex = -1;
18074 this.loadNext = false;
18078 getParams : function(q){
18080 //p[this.queryParam] = q;
18084 p.limit = this.pageSize;
18090 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
18092 collapse : function(){
18093 if(!this.isExpanded()){
18099 this.hasFocus = false;
18103 this.cancelBtn.hide();
18104 this.trigger.show();
18107 this.tickableInputEl().dom.value = '';
18108 this.tickableInputEl().blur();
18113 Roo.get(document).un('mousedown', this.collapseIf, this);
18114 Roo.get(document).un('mousewheel', this.collapseIf, this);
18115 if (!this.editable) {
18116 Roo.get(document).un('keydown', this.listKeyPress, this);
18118 this.fireEvent('collapse', this);
18124 collapseIf : function(e){
18125 var in_combo = e.within(this.el);
18126 var in_list = e.within(this.list);
18127 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
18129 if (in_combo || in_list || is_list) {
18130 //e.stopPropagation();
18135 this.onTickableFooterButtonClick(e, false, false);
18143 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
18145 expand : function(){
18147 if(this.isExpanded() || !this.hasFocus){
18151 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
18152 this.list.setWidth(lw);
18158 this.restrictHeight();
18162 this.tickItems = Roo.apply([], this.item);
18165 this.cancelBtn.show();
18166 this.trigger.hide();
18169 this.tickableInputEl().focus();
18174 Roo.get(document).on('mousedown', this.collapseIf, this);
18175 Roo.get(document).on('mousewheel', this.collapseIf, this);
18176 if (!this.editable) {
18177 Roo.get(document).on('keydown', this.listKeyPress, this);
18180 this.fireEvent('expand', this);
18184 // Implements the default empty TriggerField.onTriggerClick function
18185 onTriggerClick : function(e)
18187 Roo.log('trigger click');
18189 if(this.disabled || !this.triggerList){
18194 this.loadNext = false;
18196 if(this.isExpanded()){
18198 if (!this.blockFocus) {
18199 this.inputEl().focus();
18203 this.hasFocus = true;
18204 if(this.triggerAction == 'all') {
18205 this.doQuery(this.allQuery, true);
18207 this.doQuery(this.getRawValue());
18209 if (!this.blockFocus) {
18210 this.inputEl().focus();
18215 onTickableTriggerClick : function(e)
18222 this.loadNext = false;
18223 this.hasFocus = true;
18225 if(this.triggerAction == 'all') {
18226 this.doQuery(this.allQuery, true);
18228 this.doQuery(this.getRawValue());
18232 onSearchFieldClick : function(e)
18234 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
18235 this.onTickableFooterButtonClick(e, false, false);
18239 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
18244 this.loadNext = false;
18245 this.hasFocus = true;
18247 if(this.triggerAction == 'all') {
18248 this.doQuery(this.allQuery, true);
18250 this.doQuery(this.getRawValue());
18254 listKeyPress : function(e)
18256 //Roo.log('listkeypress');
18257 // scroll to first matching element based on key pres..
18258 if (e.isSpecialKey()) {
18261 var k = String.fromCharCode(e.getKey()).toUpperCase();
18264 var csel = this.view.getSelectedNodes();
18265 var cselitem = false;
18267 var ix = this.view.indexOf(csel[0]);
18268 cselitem = this.store.getAt(ix);
18269 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
18275 this.store.each(function(v) {
18277 // start at existing selection.
18278 if (cselitem.id == v.id) {
18284 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
18285 match = this.store.indexOf(v);
18291 if (match === false) {
18292 return true; // no more action?
18295 this.view.select(match);
18296 var sn = Roo.get(this.view.getSelectedNodes()[0]);
18297 sn.scrollIntoView(sn.dom.parentNode, false);
18300 onViewScroll : function(e, t){
18302 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){
18306 this.hasQuery = true;
18308 this.loading = this.list.select('.loading', true).first();
18310 if(this.loading === null){
18311 this.list.createChild({
18313 cls: 'loading roo-select2-more-results roo-select2-active',
18314 html: 'Loading more results...'
18317 this.loading = this.list.select('.loading', true).first();
18319 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
18321 this.loading.hide();
18324 this.loading.show();
18329 this.loadNext = true;
18331 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
18336 addItem : function(o)
18338 var dv = ''; // display value
18340 if (this.displayField) {
18341 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
18343 // this is an error condition!!!
18344 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
18351 var choice = this.choices.createChild({
18353 cls: 'roo-select2-search-choice',
18362 cls: 'roo-select2-search-choice-close fa fa-times',
18367 }, this.searchField);
18369 var close = choice.select('a.roo-select2-search-choice-close', true).first();
18371 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
18379 this.inputEl().dom.value = '';
18384 onRemoveItem : function(e, _self, o)
18386 e.preventDefault();
18388 this.lastItem = Roo.apply([], this.item);
18390 var index = this.item.indexOf(o.data) * 1;
18393 Roo.log('not this item?!');
18397 this.item.splice(index, 1);
18402 this.fireEvent('remove', this, e);
18408 syncValue : function()
18410 if(!this.item.length){
18417 Roo.each(this.item, function(i){
18418 if(_this.valueField){
18419 value.push(i[_this.valueField]);
18426 this.value = value.join(',');
18428 if(this.hiddenField){
18429 this.hiddenField.dom.value = this.value;
18432 this.store.fireEvent("datachanged", this.store);
18437 clearItem : function()
18439 if(!this.multiple){
18445 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
18453 if(this.tickable && !Roo.isTouch){
18454 this.view.refresh();
18458 inputEl: function ()
18460 if(Roo.isIOS && this.useNativeIOS){
18461 return this.el.select('select.roo-ios-select', true).first();
18464 if(Roo.isTouch && this.mobileTouchView){
18465 return this.el.select('input.form-control',true).first();
18469 return this.searchField;
18472 return this.el.select('input.form-control',true).first();
18475 onTickableFooterButtonClick : function(e, btn, el)
18477 e.preventDefault();
18479 this.lastItem = Roo.apply([], this.item);
18481 if(btn && btn.name == 'cancel'){
18482 this.tickItems = Roo.apply([], this.item);
18491 Roo.each(this.tickItems, function(o){
18499 validate : function()
18501 if(this.getVisibilityEl().hasClass('hidden')){
18505 var v = this.getRawValue();
18508 v = this.getValue();
18511 if(this.disabled || this.allowBlank || v.length){
18516 this.markInvalid();
18520 tickableInputEl : function()
18522 if(!this.tickable || !this.editable){
18523 return this.inputEl();
18526 return this.inputEl().select('.roo-select2-search-field-input', true).first();
18530 getAutoCreateTouchView : function()
18535 cls: 'form-group' //input-group
18541 type : this.inputType,
18542 cls : 'form-control x-combo-noedit',
18543 autocomplete: 'new-password',
18544 placeholder : this.placeholder || '',
18549 input.name = this.name;
18553 input.cls += ' input-' + this.size;
18556 if (this.disabled) {
18557 input.disabled = true;
18561 cls : 'roo-combobox-wrap',
18568 inputblock.cls += ' input-group';
18570 inputblock.cn.unshift({
18572 cls : 'input-group-addon input-group-prepend input-group-text',
18577 if(this.removable && !this.multiple){
18578 inputblock.cls += ' roo-removable';
18580 inputblock.cn.push({
18583 cls : 'roo-combo-removable-btn close'
18587 if(this.hasFeedback && !this.allowBlank){
18589 inputblock.cls += ' has-feedback';
18591 inputblock.cn.push({
18593 cls: 'glyphicon form-control-feedback'
18600 inputblock.cls += (this.before) ? '' : ' input-group';
18602 inputblock.cn.push({
18604 cls : 'input-group-addon input-group-append input-group-text',
18610 var ibwrap = inputblock;
18615 cls: 'roo-select2-choices',
18619 cls: 'roo-select2-search-field',
18632 cls: 'roo-select2-container input-group roo-touchview-combobox ',
18637 cls: 'form-hidden-field'
18643 if(!this.multiple && this.showToggleBtn){
18649 if (this.caret != false) {
18652 cls: 'fa fa-' + this.caret
18659 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
18661 Roo.bootstrap.version == 3 ? caret : '',
18664 cls: 'combobox-clear',
18678 combobox.cls += ' roo-select2-container-multi';
18681 var required = this.allowBlank ? {
18683 style: 'display: none'
18686 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
18687 tooltip : 'This field is required'
18690 var align = this.labelAlign || this.parentLabelAlign();
18692 if (align ==='left' && this.fieldLabel.length) {
18698 cls : 'control-label col-form-label',
18699 html : this.fieldLabel
18703 cls : 'roo-combobox-wrap ',
18710 var labelCfg = cfg.cn[1];
18711 var contentCfg = cfg.cn[2];
18714 if(this.indicatorpos == 'right'){
18719 cls : 'control-label col-form-label',
18723 html : this.fieldLabel
18729 cls : "roo-combobox-wrap ",
18737 labelCfg = cfg.cn[0];
18738 contentCfg = cfg.cn[1];
18743 if(this.labelWidth > 12){
18744 labelCfg.style = "width: " + this.labelWidth + 'px';
18747 if(this.labelWidth < 13 && this.labelmd == 0){
18748 this.labelmd = this.labelWidth;
18751 if(this.labellg > 0){
18752 labelCfg.cls += ' col-lg-' + this.labellg;
18753 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
18756 if(this.labelmd > 0){
18757 labelCfg.cls += ' col-md-' + this.labelmd;
18758 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
18761 if(this.labelsm > 0){
18762 labelCfg.cls += ' col-sm-' + this.labelsm;
18763 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
18766 if(this.labelxs > 0){
18767 labelCfg.cls += ' col-xs-' + this.labelxs;
18768 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
18772 } else if ( this.fieldLabel.length) {
18777 cls : 'control-label',
18778 html : this.fieldLabel
18789 if(this.indicatorpos == 'right'){
18793 cls : 'control-label',
18794 html : this.fieldLabel,
18812 var settings = this;
18814 ['xs','sm','md','lg'].map(function(size){
18815 if (settings[size]) {
18816 cfg.cls += ' col-' + size + '-' + settings[size];
18823 initTouchView : function()
18825 this.renderTouchView();
18827 this.touchViewEl.on('scroll', function(){
18828 this.el.dom.scrollTop = 0;
18831 this.originalValue = this.getValue();
18833 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
18835 this.inputEl().on("click", this.showTouchView, this);
18836 if (this.triggerEl) {
18837 this.triggerEl.on("click", this.showTouchView, this);
18841 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
18842 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
18844 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
18846 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
18847 this.store.on('load', this.onTouchViewLoad, this);
18848 this.store.on('loadexception', this.onTouchViewLoadException, this);
18850 if(this.hiddenName){
18852 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
18854 this.hiddenField.dom.value =
18855 this.hiddenValue !== undefined ? this.hiddenValue :
18856 this.value !== undefined ? this.value : '';
18858 this.el.dom.removeAttribute('name');
18859 this.hiddenField.dom.setAttribute('name', this.hiddenName);
18863 this.choices = this.el.select('ul.roo-select2-choices', true).first();
18864 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
18867 if(this.removable && !this.multiple){
18868 var close = this.closeTriggerEl();
18870 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
18871 close.on('click', this.removeBtnClick, this, close);
18875 * fix the bug in Safari iOS8
18877 this.inputEl().on("focus", function(e){
18878 document.activeElement.blur();
18881 this._touchViewMask = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
18888 renderTouchView : function()
18890 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
18891 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18893 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
18894 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18896 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
18897 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18898 this.touchViewBodyEl.setStyle('overflow', 'auto');
18900 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
18901 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18903 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
18904 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18908 showTouchView : function()
18914 this.touchViewHeaderEl.hide();
18916 if(this.modalTitle.length){
18917 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
18918 this.touchViewHeaderEl.show();
18921 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
18922 this.touchViewEl.show();
18924 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
18926 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
18927 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
18929 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
18931 if(this.modalTitle.length){
18932 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
18935 this.touchViewBodyEl.setHeight(bodyHeight);
18939 (function(){ _this.touchViewEl.addClass(['in','show']); }).defer(50);
18941 this.touchViewEl.addClass(['in','show']);
18944 if(this._touchViewMask){
18945 Roo.get(document.body).addClass("x-body-masked");
18946 this._touchViewMask.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
18947 this._touchViewMask.setStyle('z-index', 10000);
18948 this._touchViewMask.addClass('show');
18951 this.doTouchViewQuery();
18955 hideTouchView : function()
18957 this.touchViewEl.removeClass(['in','show']);
18961 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
18963 this.touchViewEl.setStyle('display', 'none');
18966 if(this._touchViewMask){
18967 this._touchViewMask.removeClass('show');
18968 Roo.get(document.body).removeClass("x-body-masked");
18972 setTouchViewValue : function()
18979 Roo.each(this.tickItems, function(o){
18984 this.hideTouchView();
18987 doTouchViewQuery : function()
18996 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
19000 if(!this.alwaysQuery || this.mode == 'local'){
19001 this.onTouchViewLoad();
19008 onTouchViewBeforeLoad : function(combo,opts)
19014 onTouchViewLoad : function()
19016 if(this.store.getCount() < 1){
19017 this.onTouchViewEmptyResults();
19021 this.clearTouchView();
19023 var rawValue = this.getRawValue();
19025 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
19027 this.tickItems = [];
19029 this.store.data.each(function(d, rowIndex){
19030 var row = this.touchViewListGroup.createChild(template);
19032 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
19033 row.addClass(d.data.cls);
19036 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
19039 html : d.data[this.displayField]
19042 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
19043 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
19046 row.removeClass('selected');
19047 if(!this.multiple && this.valueField &&
19048 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
19051 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
19052 row.addClass('selected');
19055 if(this.multiple && this.valueField &&
19056 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
19060 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
19061 this.tickItems.push(d.data);
19064 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
19068 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
19070 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
19072 if(this.modalTitle.length){
19073 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
19076 var listHeight = this.touchViewListGroup.getHeight() + this.touchViewBodyEl.getPadding('tb') * 2;
19078 if(this.mobile_restrict_height && listHeight < bodyHeight){
19079 this.touchViewBodyEl.setHeight(listHeight);
19084 if(firstChecked && listHeight > bodyHeight){
19085 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
19090 onTouchViewLoadException : function()
19092 this.hideTouchView();
19095 onTouchViewEmptyResults : function()
19097 this.clearTouchView();
19099 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
19101 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
19105 clearTouchView : function()
19107 this.touchViewListGroup.dom.innerHTML = '';
19110 onTouchViewClick : function(e, el, o)
19112 e.preventDefault();
19115 var rowIndex = o.rowIndex;
19117 var r = this.store.getAt(rowIndex);
19119 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
19121 if(!this.multiple){
19122 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
19123 c.dom.removeAttribute('checked');
19126 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
19128 this.setFromData(r.data);
19130 var close = this.closeTriggerEl();
19136 this.hideTouchView();
19138 this.fireEvent('select', this, r, rowIndex);
19143 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
19144 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
19145 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
19149 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
19150 this.addItem(r.data);
19151 this.tickItems.push(r.data);
19155 getAutoCreateNativeIOS : function()
19158 cls: 'form-group' //input-group,
19163 cls : 'roo-ios-select'
19167 combobox.name = this.name;
19170 if (this.disabled) {
19171 combobox.disabled = true;
19174 var settings = this;
19176 ['xs','sm','md','lg'].map(function(size){
19177 if (settings[size]) {
19178 cfg.cls += ' col-' + size + '-' + settings[size];
19188 initIOSView : function()
19190 this.store.on('load', this.onIOSViewLoad, this);
19195 onIOSViewLoad : function()
19197 if(this.store.getCount() < 1){
19201 this.clearIOSView();
19203 if(this.allowBlank) {
19205 var default_text = '-- SELECT --';
19207 if(this.placeholder.length){
19208 default_text = this.placeholder;
19211 if(this.emptyTitle.length){
19212 default_text += ' - ' + this.emptyTitle + ' -';
19215 var opt = this.inputEl().createChild({
19218 html : default_text
19222 o[this.valueField] = 0;
19223 o[this.displayField] = default_text;
19225 this.ios_options.push({
19232 this.store.data.each(function(d, rowIndex){
19236 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
19237 html = d.data[this.displayField];
19242 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
19243 value = d.data[this.valueField];
19252 if(this.value == d.data[this.valueField]){
19253 option['selected'] = true;
19256 var opt = this.inputEl().createChild(option);
19258 this.ios_options.push({
19265 this.inputEl().on('change', function(){
19266 this.fireEvent('select', this);
19271 clearIOSView: function()
19273 this.inputEl().dom.innerHTML = '';
19275 this.ios_options = [];
19278 setIOSValue: function(v)
19282 if(!this.ios_options){
19286 Roo.each(this.ios_options, function(opts){
19288 opts.el.dom.removeAttribute('selected');
19290 if(opts.data[this.valueField] != v){
19294 opts.el.dom.setAttribute('selected', true);
19300 * @cfg {Boolean} grow
19304 * @cfg {Number} growMin
19308 * @cfg {Number} growMax
19317 Roo.apply(Roo.bootstrap.ComboBox, {
19321 cls: 'modal-header',
19343 cls: 'list-group-item',
19347 cls: 'roo-combobox-list-group-item-value'
19351 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
19365 listItemCheckbox : {
19367 cls: 'list-group-item',
19371 cls: 'roo-combobox-list-group-item-value'
19375 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
19391 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
19396 cls: 'modal-footer',
19404 cls: 'col-xs-6 text-left',
19407 cls: 'btn btn-danger roo-touch-view-cancel',
19413 cls: 'col-xs-6 text-right',
19416 cls: 'btn btn-success roo-touch-view-ok',
19427 Roo.apply(Roo.bootstrap.ComboBox, {
19429 touchViewTemplate : {
19431 cls: 'modal fade roo-combobox-touch-view',
19435 cls: 'modal-dialog',
19436 style : 'position:fixed', // we have to fix position....
19440 cls: 'modal-content',
19442 Roo.bootstrap.ComboBox.header,
19443 Roo.bootstrap.ComboBox.body,
19444 Roo.bootstrap.ComboBox.footer
19453 * Ext JS Library 1.1.1
19454 * Copyright(c) 2006-2007, Ext JS, LLC.
19456 * Originally Released Under LGPL - original licence link has changed is not relivant.
19459 * <script type="text/javascript">
19464 * @extends Roo.util.Observable
19465 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
19466 * This class also supports single and multi selection modes. <br>
19467 * Create a data model bound view:
19469 var store = new Roo.data.Store(...);
19471 var view = new Roo.View({
19473 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
19475 singleSelect: true,
19476 selectedClass: "ydataview-selected",
19480 // listen for node click?
19481 view.on("click", function(vw, index, node, e){
19482 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
19486 dataModel.load("foobar.xml");
19488 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
19490 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
19491 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
19493 * Note: old style constructor is still suported (container, template, config)
19496 * Create a new View
19497 * @param {Object} config The config object
19500 Roo.View = function(config, depreciated_tpl, depreciated_config){
19502 this.parent = false;
19504 if (typeof(depreciated_tpl) == 'undefined') {
19505 // new way.. - universal constructor.
19506 Roo.apply(this, config);
19507 this.el = Roo.get(this.el);
19510 this.el = Roo.get(config);
19511 this.tpl = depreciated_tpl;
19512 Roo.apply(this, depreciated_config);
19514 this.wrapEl = this.el.wrap().wrap();
19515 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
19518 if(typeof(this.tpl) == "string"){
19519 this.tpl = new Roo.Template(this.tpl);
19521 // support xtype ctors..
19522 this.tpl = new Roo.factory(this.tpl, Roo);
19526 this.tpl.compile();
19531 * @event beforeclick
19532 * Fires before a click is processed. Returns false to cancel the default action.
19533 * @param {Roo.View} this
19534 * @param {Number} index The index of the target node
19535 * @param {HTMLElement} node The target node
19536 * @param {Roo.EventObject} e The raw event object
19538 "beforeclick" : true,
19541 * Fires when a template node is clicked.
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
19550 * Fires when a template node is double 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
19558 * @event contextmenu
19559 * Fires when a template node is right 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
19565 "contextmenu" : true,
19567 * @event selectionchange
19568 * Fires when the selected nodes change.
19569 * @param {Roo.View} this
19570 * @param {Array} selections Array of the selected nodes
19572 "selectionchange" : true,
19575 * @event beforeselect
19576 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
19577 * @param {Roo.View} this
19578 * @param {HTMLElement} node The node to be selected
19579 * @param {Array} selections Array of currently selected nodes
19581 "beforeselect" : true,
19583 * @event preparedata
19584 * Fires on every row to render, to allow you to change the data.
19585 * @param {Roo.View} this
19586 * @param {Object} data to be rendered (change this)
19588 "preparedata" : true
19596 "click": this.onClick,
19597 "dblclick": this.onDblClick,
19598 "contextmenu": this.onContextMenu,
19602 this.selections = [];
19604 this.cmp = new Roo.CompositeElementLite([]);
19606 this.store = Roo.factory(this.store, Roo.data);
19607 this.setStore(this.store, true);
19610 if ( this.footer && this.footer.xtype) {
19612 var fctr = this.wrapEl.appendChild(document.createElement("div"));
19614 this.footer.dataSource = this.store;
19615 this.footer.container = fctr;
19616 this.footer = Roo.factory(this.footer, Roo);
19617 fctr.insertFirst(this.el);
19619 // this is a bit insane - as the paging toolbar seems to detach the el..
19620 // dom.parentNode.parentNode.parentNode
19621 // they get detached?
19625 Roo.View.superclass.constructor.call(this);
19630 Roo.extend(Roo.View, Roo.util.Observable, {
19633 * @cfg {Roo.data.Store} store Data store to load data from.
19638 * @cfg {String|Roo.Element} el The container element.
19643 * @cfg {String|Roo.Template} tpl The template used by this View
19647 * @cfg {String} dataName the named area of the template to use as the data area
19648 * Works with domtemplates roo-name="name"
19652 * @cfg {String} selectedClass The css class to add to selected nodes
19654 selectedClass : "x-view-selected",
19656 * @cfg {String} emptyText The empty text to show when nothing is loaded.
19661 * @cfg {String} text to display on mask (default Loading)
19665 * @cfg {Boolean} multiSelect Allow multiple selection
19667 multiSelect : false,
19669 * @cfg {Boolean} singleSelect Allow single selection
19671 singleSelect: false,
19674 * @cfg {Boolean} toggleSelect - selecting
19676 toggleSelect : false,
19679 * @cfg {Boolean} tickable - selecting
19684 * Returns the element this view is bound to.
19685 * @return {Roo.Element}
19687 getEl : function(){
19688 return this.wrapEl;
19694 * Refreshes the view. - called by datachanged on the store. - do not call directly.
19696 refresh : function(){
19697 //Roo.log('refresh');
19700 // if we are using something like 'domtemplate', then
19701 // the what gets used is:
19702 // t.applySubtemplate(NAME, data, wrapping data..)
19703 // the outer template then get' applied with
19704 // the store 'extra data'
19705 // and the body get's added to the
19706 // roo-name="data" node?
19707 // <span class='roo-tpl-{name}'></span> ?????
19711 this.clearSelections();
19712 this.el.update("");
19714 var records = this.store.getRange();
19715 if(records.length < 1) {
19717 // is this valid?? = should it render a template??
19719 this.el.update(this.emptyText);
19723 if (this.dataName) {
19724 this.el.update(t.apply(this.store.meta)); //????
19725 el = this.el.child('.roo-tpl-' + this.dataName);
19728 for(var i = 0, len = records.length; i < len; i++){
19729 var data = this.prepareData(records[i].data, i, records[i]);
19730 this.fireEvent("preparedata", this, data, i, records[i]);
19732 var d = Roo.apply({}, data);
19735 Roo.apply(d, {'roo-id' : Roo.id()});
19739 Roo.each(this.parent.item, function(item){
19740 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
19743 Roo.apply(d, {'roo-data-checked' : 'checked'});
19747 html[html.length] = Roo.util.Format.trim(
19749 t.applySubtemplate(this.dataName, d, this.store.meta) :
19756 el.update(html.join(""));
19757 this.nodes = el.dom.childNodes;
19758 this.updateIndexes(0);
19763 * Function to override to reformat the data that is sent to
19764 * the template for each node.
19765 * DEPRICATED - use the preparedata event handler.
19766 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
19767 * a JSON object for an UpdateManager bound view).
19769 prepareData : function(data, index, record)
19771 this.fireEvent("preparedata", this, data, index, record);
19775 onUpdate : function(ds, record){
19776 // Roo.log('on update');
19777 this.clearSelections();
19778 var index = this.store.indexOf(record);
19779 var n = this.nodes[index];
19780 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
19781 n.parentNode.removeChild(n);
19782 this.updateIndexes(index, index);
19788 onAdd : function(ds, records, index)
19790 //Roo.log(['on Add', ds, records, index] );
19791 this.clearSelections();
19792 if(this.nodes.length == 0){
19796 var n = this.nodes[index];
19797 for(var i = 0, len = records.length; i < len; i++){
19798 var d = this.prepareData(records[i].data, i, records[i]);
19800 this.tpl.insertBefore(n, d);
19803 this.tpl.append(this.el, d);
19806 this.updateIndexes(index);
19809 onRemove : function(ds, record, index){
19810 // Roo.log('onRemove');
19811 this.clearSelections();
19812 var el = this.dataName ?
19813 this.el.child('.roo-tpl-' + this.dataName) :
19816 el.dom.removeChild(this.nodes[index]);
19817 this.updateIndexes(index);
19821 * Refresh an individual node.
19822 * @param {Number} index
19824 refreshNode : function(index){
19825 this.onUpdate(this.store, this.store.getAt(index));
19828 updateIndexes : function(startIndex, endIndex){
19829 var ns = this.nodes;
19830 startIndex = startIndex || 0;
19831 endIndex = endIndex || ns.length - 1;
19832 for(var i = startIndex; i <= endIndex; i++){
19833 ns[i].nodeIndex = i;
19838 * Changes the data store this view uses and refresh the view.
19839 * @param {Store} store
19841 setStore : function(store, initial){
19842 if(!initial && this.store){
19843 this.store.un("datachanged", this.refresh);
19844 this.store.un("add", this.onAdd);
19845 this.store.un("remove", this.onRemove);
19846 this.store.un("update", this.onUpdate);
19847 this.store.un("clear", this.refresh);
19848 this.store.un("beforeload", this.onBeforeLoad);
19849 this.store.un("load", this.onLoad);
19850 this.store.un("loadexception", this.onLoad);
19854 store.on("datachanged", this.refresh, this);
19855 store.on("add", this.onAdd, this);
19856 store.on("remove", this.onRemove, this);
19857 store.on("update", this.onUpdate, this);
19858 store.on("clear", this.refresh, this);
19859 store.on("beforeload", this.onBeforeLoad, this);
19860 store.on("load", this.onLoad, this);
19861 store.on("loadexception", this.onLoad, this);
19869 * onbeforeLoad - masks the loading area.
19872 onBeforeLoad : function(store,opts)
19874 //Roo.log('onBeforeLoad');
19876 this.el.update("");
19878 this.el.mask(this.mask ? this.mask : "Loading" );
19880 onLoad : function ()
19887 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
19888 * @param {HTMLElement} node
19889 * @return {HTMLElement} The template node
19891 findItemFromChild : function(node){
19892 var el = this.dataName ?
19893 this.el.child('.roo-tpl-' + this.dataName,true) :
19896 if(!node || node.parentNode == el){
19899 var p = node.parentNode;
19900 while(p && p != el){
19901 if(p.parentNode == el){
19910 onClick : function(e){
19911 var item = this.findItemFromChild(e.getTarget());
19913 var index = this.indexOf(item);
19914 if(this.onItemClick(item, index, e) !== false){
19915 this.fireEvent("click", this, index, item, e);
19918 this.clearSelections();
19923 onContextMenu : function(e){
19924 var item = this.findItemFromChild(e.getTarget());
19926 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
19931 onDblClick : function(e){
19932 var item = this.findItemFromChild(e.getTarget());
19934 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
19938 onItemClick : function(item, index, e)
19940 if(this.fireEvent("beforeclick", this, index, item, e) === false){
19943 if (this.toggleSelect) {
19944 var m = this.isSelected(item) ? 'unselect' : 'select';
19947 _t[m](item, true, false);
19950 if(this.multiSelect || this.singleSelect){
19951 if(this.multiSelect && e.shiftKey && this.lastSelection){
19952 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
19954 this.select(item, this.multiSelect && e.ctrlKey);
19955 this.lastSelection = item;
19958 if(!this.tickable){
19959 e.preventDefault();
19967 * Get the number of selected nodes.
19970 getSelectionCount : function(){
19971 return this.selections.length;
19975 * Get the currently selected nodes.
19976 * @return {Array} An array of HTMLElements
19978 getSelectedNodes : function(){
19979 return this.selections;
19983 * Get the indexes of the selected nodes.
19986 getSelectedIndexes : function(){
19987 var indexes = [], s = this.selections;
19988 for(var i = 0, len = s.length; i < len; i++){
19989 indexes.push(s[i].nodeIndex);
19995 * Clear all selections
19996 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
19998 clearSelections : function(suppressEvent){
19999 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
20000 this.cmp.elements = this.selections;
20001 this.cmp.removeClass(this.selectedClass);
20002 this.selections = [];
20003 if(!suppressEvent){
20004 this.fireEvent("selectionchange", this, this.selections);
20010 * Returns true if the passed node is selected
20011 * @param {HTMLElement/Number} node The node or node index
20012 * @return {Boolean}
20014 isSelected : function(node){
20015 var s = this.selections;
20019 node = this.getNode(node);
20020 return s.indexOf(node) !== -1;
20025 * @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
20026 * @param {Boolean} keepExisting (optional) true to keep existing selections
20027 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
20029 select : function(nodeInfo, keepExisting, suppressEvent){
20030 if(nodeInfo instanceof Array){
20032 this.clearSelections(true);
20034 for(var i = 0, len = nodeInfo.length; i < len; i++){
20035 this.select(nodeInfo[i], true, true);
20039 var node = this.getNode(nodeInfo);
20040 if(!node || this.isSelected(node)){
20041 return; // already selected.
20044 this.clearSelections(true);
20047 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
20048 Roo.fly(node).addClass(this.selectedClass);
20049 this.selections.push(node);
20050 if(!suppressEvent){
20051 this.fireEvent("selectionchange", this, this.selections);
20059 * @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
20060 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
20061 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
20063 unselect : function(nodeInfo, keepExisting, suppressEvent)
20065 if(nodeInfo instanceof Array){
20066 Roo.each(this.selections, function(s) {
20067 this.unselect(s, nodeInfo);
20071 var node = this.getNode(nodeInfo);
20072 if(!node || !this.isSelected(node)){
20073 //Roo.log("not selected");
20074 return; // not selected.
20078 Roo.each(this.selections, function(s) {
20080 Roo.fly(node).removeClass(this.selectedClass);
20087 this.selections= ns;
20088 this.fireEvent("selectionchange", this, this.selections);
20092 * Gets a template node.
20093 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
20094 * @return {HTMLElement} The node or null if it wasn't found
20096 getNode : function(nodeInfo){
20097 if(typeof nodeInfo == "string"){
20098 return document.getElementById(nodeInfo);
20099 }else if(typeof nodeInfo == "number"){
20100 return this.nodes[nodeInfo];
20106 * Gets a range template nodes.
20107 * @param {Number} startIndex
20108 * @param {Number} endIndex
20109 * @return {Array} An array of nodes
20111 getNodes : function(start, end){
20112 var ns = this.nodes;
20113 start = start || 0;
20114 end = typeof end == "undefined" ? ns.length - 1 : end;
20117 for(var i = start; i <= end; i++){
20121 for(var i = start; i >= end; i--){
20129 * Finds the index of the passed node
20130 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
20131 * @return {Number} The index of the node or -1
20133 indexOf : function(node){
20134 node = this.getNode(node);
20135 if(typeof node.nodeIndex == "number"){
20136 return node.nodeIndex;
20138 var ns = this.nodes;
20139 for(var i = 0, len = ns.length; i < len; i++){
20150 * based on jquery fullcalendar
20154 Roo.bootstrap = Roo.bootstrap || {};
20156 * @class Roo.bootstrap.Calendar
20157 * @extends Roo.bootstrap.Component
20158 * Bootstrap Calendar class
20159 * @cfg {Boolean} loadMask (true|false) default false
20160 * @cfg {Object} header generate the user specific header of the calendar, default false
20163 * Create a new Container
20164 * @param {Object} config The config object
20169 Roo.bootstrap.Calendar = function(config){
20170 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
20174 * Fires when a date is selected
20175 * @param {DatePicker} this
20176 * @param {Date} date The selected date
20180 * @event monthchange
20181 * Fires when the displayed month changes
20182 * @param {DatePicker} this
20183 * @param {Date} date The selected month
20185 'monthchange': true,
20187 * @event evententer
20188 * Fires when mouse over an event
20189 * @param {Calendar} this
20190 * @param {event} Event
20192 'evententer': true,
20194 * @event eventleave
20195 * Fires when the mouse leaves an
20196 * @param {Calendar} this
20199 'eventleave': true,
20201 * @event eventclick
20202 * Fires when the mouse click an
20203 * @param {Calendar} this
20212 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
20215 * @cfg {Roo.data.Store} store
20216 * The data source for the calendar
20220 * @cfg {Number} startDay
20221 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
20229 getAutoCreate : function(){
20232 var fc_button = function(name, corner, style, content ) {
20233 return Roo.apply({},{
20235 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
20237 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
20240 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
20251 style : 'width:100%',
20258 cls : 'fc-header-left',
20260 fc_button('prev', 'left', 'arrow', '‹' ),
20261 fc_button('next', 'right', 'arrow', '›' ),
20262 { tag: 'span', cls: 'fc-header-space' },
20263 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
20271 cls : 'fc-header-center',
20275 cls: 'fc-header-title',
20278 html : 'month / year'
20286 cls : 'fc-header-right',
20288 /* fc_button('month', 'left', '', 'month' ),
20289 fc_button('week', '', '', 'week' ),
20290 fc_button('day', 'right', '', 'day' )
20302 header = this.header;
20305 var cal_heads = function() {
20307 // fixme - handle this.
20309 for (var i =0; i < Date.dayNames.length; i++) {
20310 var d = Date.dayNames[i];
20313 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
20314 html : d.substring(0,3)
20318 ret[0].cls += ' fc-first';
20319 ret[6].cls += ' fc-last';
20322 var cal_cell = function(n) {
20325 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
20330 cls: 'fc-day-number',
20334 cls: 'fc-day-content',
20338 style: 'position: relative;' // height: 17px;
20350 var cal_rows = function() {
20353 for (var r = 0; r < 6; r++) {
20360 for (var i =0; i < Date.dayNames.length; i++) {
20361 var d = Date.dayNames[i];
20362 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
20365 row.cn[0].cls+=' fc-first';
20366 row.cn[0].cn[0].style = 'min-height:90px';
20367 row.cn[6].cls+=' fc-last';
20371 ret[0].cls += ' fc-first';
20372 ret[4].cls += ' fc-prev-last';
20373 ret[5].cls += ' fc-last';
20380 cls: 'fc-border-separate',
20381 style : 'width:100%',
20389 cls : 'fc-first fc-last',
20407 cls : 'fc-content',
20408 style : "position: relative;",
20411 cls : 'fc-view fc-view-month fc-grid',
20412 style : 'position: relative',
20413 unselectable : 'on',
20416 cls : 'fc-event-container',
20417 style : 'position:absolute;z-index:8;top:0;left:0;'
20435 initEvents : function()
20438 throw "can not find store for calendar";
20444 style: "text-align:center",
20448 style: "background-color:white;width:50%;margin:250 auto",
20452 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
20463 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
20465 var size = this.el.select('.fc-content', true).first().getSize();
20466 this.maskEl.setSize(size.width, size.height);
20467 this.maskEl.enableDisplayMode("block");
20468 if(!this.loadMask){
20469 this.maskEl.hide();
20472 this.store = Roo.factory(this.store, Roo.data);
20473 this.store.on('load', this.onLoad, this);
20474 this.store.on('beforeload', this.onBeforeLoad, this);
20478 this.cells = this.el.select('.fc-day',true);
20479 //Roo.log(this.cells);
20480 this.textNodes = this.el.query('.fc-day-number');
20481 this.cells.addClassOnOver('fc-state-hover');
20483 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
20484 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
20485 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
20486 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
20488 this.on('monthchange', this.onMonthChange, this);
20490 this.update(new Date().clearTime());
20493 resize : function() {
20494 var sz = this.el.getSize();
20496 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
20497 this.el.select('.fc-day-content div',true).setHeight(34);
20502 showPrevMonth : function(e){
20503 this.update(this.activeDate.add("mo", -1));
20505 showToday : function(e){
20506 this.update(new Date().clearTime());
20509 showNextMonth : function(e){
20510 this.update(this.activeDate.add("mo", 1));
20514 showPrevYear : function(){
20515 this.update(this.activeDate.add("y", -1));
20519 showNextYear : function(){
20520 this.update(this.activeDate.add("y", 1));
20525 update : function(date)
20527 var vd = this.activeDate;
20528 this.activeDate = date;
20529 // if(vd && this.el){
20530 // var t = date.getTime();
20531 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
20532 // Roo.log('using add remove');
20534 // this.fireEvent('monthchange', this, date);
20536 // this.cells.removeClass("fc-state-highlight");
20537 // this.cells.each(function(c){
20538 // if(c.dateValue == t){
20539 // c.addClass("fc-state-highlight");
20540 // setTimeout(function(){
20541 // try{c.dom.firstChild.focus();}catch(e){}
20551 var days = date.getDaysInMonth();
20553 var firstOfMonth = date.getFirstDateOfMonth();
20554 var startingPos = firstOfMonth.getDay()-this.startDay;
20556 if(startingPos < this.startDay){
20560 var pm = date.add(Date.MONTH, -1);
20561 var prevStart = pm.getDaysInMonth()-startingPos;
20563 this.cells = this.el.select('.fc-day',true);
20564 this.textNodes = this.el.query('.fc-day-number');
20565 this.cells.addClassOnOver('fc-state-hover');
20567 var cells = this.cells.elements;
20568 var textEls = this.textNodes;
20570 Roo.each(cells, function(cell){
20571 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
20574 days += startingPos;
20576 // convert everything to numbers so it's fast
20577 var day = 86400000;
20578 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
20581 //Roo.log(prevStart);
20583 var today = new Date().clearTime().getTime();
20584 var sel = date.clearTime().getTime();
20585 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
20586 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
20587 var ddMatch = this.disabledDatesRE;
20588 var ddText = this.disabledDatesText;
20589 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
20590 var ddaysText = this.disabledDaysText;
20591 var format = this.format;
20593 var setCellClass = function(cal, cell){
20597 //Roo.log('set Cell Class');
20599 var t = d.getTime();
20603 cell.dateValue = t;
20605 cell.className += " fc-today";
20606 cell.className += " fc-state-highlight";
20607 cell.title = cal.todayText;
20610 // disable highlight in other month..
20611 //cell.className += " fc-state-highlight";
20616 cell.className = " fc-state-disabled";
20617 cell.title = cal.minText;
20621 cell.className = " fc-state-disabled";
20622 cell.title = cal.maxText;
20626 if(ddays.indexOf(d.getDay()) != -1){
20627 cell.title = ddaysText;
20628 cell.className = " fc-state-disabled";
20631 if(ddMatch && format){
20632 var fvalue = d.dateFormat(format);
20633 if(ddMatch.test(fvalue)){
20634 cell.title = ddText.replace("%0", fvalue);
20635 cell.className = " fc-state-disabled";
20639 if (!cell.initialClassName) {
20640 cell.initialClassName = cell.dom.className;
20643 cell.dom.className = cell.initialClassName + ' ' + cell.className;
20648 for(; i < startingPos; i++) {
20649 textEls[i].innerHTML = (++prevStart);
20650 d.setDate(d.getDate()+1);
20652 cells[i].className = "fc-past fc-other-month";
20653 setCellClass(this, cells[i]);
20658 for(; i < days; i++){
20659 intDay = i - startingPos + 1;
20660 textEls[i].innerHTML = (intDay);
20661 d.setDate(d.getDate()+1);
20663 cells[i].className = ''; // "x-date-active";
20664 setCellClass(this, cells[i]);
20668 for(; i < 42; i++) {
20669 textEls[i].innerHTML = (++extraDays);
20670 d.setDate(d.getDate()+1);
20672 cells[i].className = "fc-future fc-other-month";
20673 setCellClass(this, cells[i]);
20676 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
20678 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
20680 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
20681 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
20683 if(totalRows != 6){
20684 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
20685 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
20688 this.fireEvent('monthchange', this, date);
20692 if(!this.internalRender){
20693 var main = this.el.dom.firstChild;
20694 var w = main.offsetWidth;
20695 this.el.setWidth(w + this.el.getBorderWidth("lr"));
20696 Roo.fly(main).setWidth(w);
20697 this.internalRender = true;
20698 // opera does not respect the auto grow header center column
20699 // then, after it gets a width opera refuses to recalculate
20700 // without a second pass
20701 if(Roo.isOpera && !this.secondPass){
20702 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
20703 this.secondPass = true;
20704 this.update.defer(10, this, [date]);
20711 findCell : function(dt) {
20712 dt = dt.clearTime().getTime();
20714 this.cells.each(function(c){
20715 //Roo.log("check " +c.dateValue + '?=' + dt);
20716 if(c.dateValue == dt){
20726 findCells : function(ev) {
20727 var s = ev.start.clone().clearTime().getTime();
20729 var e= ev.end.clone().clearTime().getTime();
20732 this.cells.each(function(c){
20733 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
20735 if(c.dateValue > e){
20738 if(c.dateValue < s){
20747 // findBestRow: function(cells)
20751 // for (var i =0 ; i < cells.length;i++) {
20752 // ret = Math.max(cells[i].rows || 0,ret);
20759 addItem : function(ev)
20761 // look for vertical location slot in
20762 var cells = this.findCells(ev);
20764 // ev.row = this.findBestRow(cells);
20766 // work out the location.
20770 for(var i =0; i < cells.length; i++) {
20772 cells[i].row = cells[0].row;
20775 cells[i].row = cells[i].row + 1;
20785 if (crow.start.getY() == cells[i].getY()) {
20787 crow.end = cells[i];
20804 cells[0].events.push(ev);
20806 this.calevents.push(ev);
20809 clearEvents: function() {
20811 if(!this.calevents){
20815 Roo.each(this.cells.elements, function(c){
20821 Roo.each(this.calevents, function(e) {
20822 Roo.each(e.els, function(el) {
20823 el.un('mouseenter' ,this.onEventEnter, this);
20824 el.un('mouseleave' ,this.onEventLeave, this);
20829 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
20835 renderEvents: function()
20839 this.cells.each(function(c) {
20848 if(c.row != c.events.length){
20849 r = 4 - (4 - (c.row - c.events.length));
20852 c.events = ev.slice(0, r);
20853 c.more = ev.slice(r);
20855 if(c.more.length && c.more.length == 1){
20856 c.events.push(c.more.pop());
20859 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
20863 this.cells.each(function(c) {
20865 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
20868 for (var e = 0; e < c.events.length; e++){
20869 var ev = c.events[e];
20870 var rows = ev.rows;
20872 for(var i = 0; i < rows.length; i++) {
20874 // how many rows should it span..
20877 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
20878 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
20880 unselectable : "on",
20883 cls: 'fc-event-inner',
20887 // cls: 'fc-event-time',
20888 // html : cells.length > 1 ? '' : ev.time
20892 cls: 'fc-event-title',
20893 html : String.format('{0}', ev.title)
20900 cls: 'ui-resizable-handle ui-resizable-e',
20901 html : '  '
20908 cfg.cls += ' fc-event-start';
20910 if ((i+1) == rows.length) {
20911 cfg.cls += ' fc-event-end';
20914 var ctr = _this.el.select('.fc-event-container',true).first();
20915 var cg = ctr.createChild(cfg);
20917 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
20918 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
20920 var r = (c.more.length) ? 1 : 0;
20921 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
20922 cg.setWidth(ebox.right - sbox.x -2);
20924 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
20925 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
20926 cg.on('click', _this.onEventClick, _this, ev);
20937 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
20938 style : 'position: absolute',
20939 unselectable : "on",
20942 cls: 'fc-event-inner',
20946 cls: 'fc-event-title',
20954 cls: 'ui-resizable-handle ui-resizable-e',
20955 html : '  '
20961 var ctr = _this.el.select('.fc-event-container',true).first();
20962 var cg = ctr.createChild(cfg);
20964 var sbox = c.select('.fc-day-content',true).first().getBox();
20965 var ebox = c.select('.fc-day-content',true).first().getBox();
20967 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
20968 cg.setWidth(ebox.right - sbox.x -2);
20970 cg.on('click', _this.onMoreEventClick, _this, c.more);
20980 onEventEnter: function (e, el,event,d) {
20981 this.fireEvent('evententer', this, el, event);
20984 onEventLeave: function (e, el,event,d) {
20985 this.fireEvent('eventleave', this, el, event);
20988 onEventClick: function (e, el,event,d) {
20989 this.fireEvent('eventclick', this, el, event);
20992 onMonthChange: function () {
20996 onMoreEventClick: function(e, el, more)
21000 this.calpopover.placement = 'right';
21001 this.calpopover.setTitle('More');
21003 this.calpopover.setContent('');
21005 var ctr = this.calpopover.el.select('.popover-content', true).first();
21007 Roo.each(more, function(m){
21009 cls : 'fc-event-hori fc-event-draggable',
21012 var cg = ctr.createChild(cfg);
21014 cg.on('click', _this.onEventClick, _this, m);
21017 this.calpopover.show(el);
21022 onLoad: function ()
21024 this.calevents = [];
21027 if(this.store.getCount() > 0){
21028 this.store.data.each(function(d){
21031 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
21032 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
21033 time : d.data.start_time,
21034 title : d.data.title,
21035 description : d.data.description,
21036 venue : d.data.venue
21041 this.renderEvents();
21043 if(this.calevents.length && this.loadMask){
21044 this.maskEl.hide();
21048 onBeforeLoad: function()
21050 this.clearEvents();
21052 this.maskEl.show();
21066 * @class Roo.bootstrap.Popover
21067 * @extends Roo.bootstrap.Component
21069 * Bootstrap Popover class
21070 * @cfg {String} html contents of the popover (or false to use children..)
21071 * @cfg {String} title of popover (or false to hide)
21072 * @cfg {String|function} (right|top|bottom|left|auto) placement how it is placed
21073 * @cfg {String} trigger click || hover (or false to trigger manually)
21074 * @cfg {Boolean} modal - popovers that are modal will mask the screen, and must be closed with another event.
21075 * @cfg {String|Boolean|Roo.Element} add click hander to trigger show over what element
21076 * - if false and it has a 'parent' then it will be automatically added to that element
21077 * - if string - Roo.get will be called
21078 * @cfg {Number} delay - delay before showing
21081 * Create a new Popover
21082 * @param {Object} config The config object
21085 Roo.bootstrap.Popover = function(config){
21086 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
21092 * After the popover show
21094 * @param {Roo.bootstrap.Popover} this
21099 * After the popover hide
21101 * @param {Roo.bootstrap.Popover} this
21107 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
21112 placement : 'right',
21113 trigger : 'hover', // hover
21119 can_build_overlaid : false,
21121 maskEl : false, // the mask element
21124 alignEl : false, // when show is called with an element - this get's stored.
21126 getChildContainer : function()
21128 return this.contentEl;
21131 getPopoverHeader : function()
21133 this.title = true; // flag not to hide it..
21134 this.headerEl.addClass('p-0');
21135 return this.headerEl
21139 getAutoCreate : function(){
21142 cls : 'popover roo-dynamic shadow roo-popover' + (this.modal ? '-modal' : ''),
21143 style: 'display:block',
21149 cls : 'popover-inner ',
21153 cls: 'popover-title popover-header',
21154 html : this.title === false ? '' : this.title
21157 cls : 'popover-content popover-body ' + (this.cls || ''),
21158 html : this.html || ''
21169 * @param {string} the title
21171 setTitle: function(str)
21175 this.headerEl.dom.innerHTML = str;
21180 * @param {string} the body content
21182 setContent: function(str)
21185 if (this.contentEl) {
21186 this.contentEl.dom.innerHTML = str;
21190 // as it get's added to the bottom of the page.
21191 onRender : function(ct, position)
21193 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
21198 var cfg = Roo.apply({}, this.getAutoCreate());
21202 cfg.cls += ' ' + this.cls;
21205 cfg.style = this.style;
21207 //Roo.log("adding to ");
21208 this.el = Roo.get(document.body).createChild(cfg, position);
21209 // Roo.log(this.el);
21212 this.contentEl = this.el.select('.popover-content',true).first();
21213 this.headerEl = this.el.select('.popover-title',true).first();
21216 if(typeof(this.items) != 'undefined'){
21217 var items = this.items;
21220 for(var i =0;i < items.length;i++) {
21221 nitems.push(this.addxtype(Roo.apply({}, items[i])));
21225 this.items = nitems;
21227 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
21228 Roo.EventManager.onWindowResize(this.resizeMask, this, true);
21235 resizeMask : function()
21237 this.maskEl.setSize(
21238 Roo.lib.Dom.getViewWidth(true),
21239 Roo.lib.Dom.getViewHeight(true)
21243 initEvents : function()
21247 Roo.bootstrap.Popover.register(this);
21250 this.arrowEl = this.el.select('.arrow',true).first();
21251 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY); // probably not needed as it's default in BS4
21252 this.el.enableDisplayMode('block');
21256 if (this.over === false && !this.parent()) {
21259 if (this.triggers === false) {
21264 var on_el = (this.over == 'parent' || this.over === false) ? this.parent().el : Roo.get(this.over);
21265 var triggers = this.trigger ? this.trigger.split(' ') : [];
21266 Roo.each(triggers, function(trigger) {
21268 if (trigger == 'click') {
21269 on_el.on('click', this.toggle, this);
21270 } else if (trigger != 'manual') {
21271 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
21272 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
21274 on_el.on(eventIn ,this.enter, this);
21275 on_el.on(eventOut, this.leave, this);
21285 toggle : function () {
21286 this.hoverState == 'in' ? this.leave() : this.enter();
21289 enter : function () {
21291 clearTimeout(this.timeout);
21293 this.hoverState = 'in';
21295 if (!this.delay || !this.delay.show) {
21300 this.timeout = setTimeout(function () {
21301 if (_t.hoverState == 'in') {
21304 }, this.delay.show)
21307 leave : function() {
21308 clearTimeout(this.timeout);
21310 this.hoverState = 'out';
21312 if (!this.delay || !this.delay.hide) {
21317 this.timeout = setTimeout(function () {
21318 if (_t.hoverState == 'out') {
21321 }, this.delay.hide)
21325 * @param {Roo.Element|string|Boolean} - element to align and point to. (set align to [ pos, offset ])
21326 * @param {string} (left|right|top|bottom) position
21328 show : function (on_el, placement)
21330 this.placement = typeof(placement) == 'undefined' ? this.placement : placement;
21331 on_el = on_el || false; // default to false
21334 if (this.parent() && (this.over == 'parent' || (this.over === false))) {
21335 on_el = this.parent().el;
21336 } else if (this.over) {
21337 on_el = Roo.get(this.over);
21342 this.alignEl = Roo.get( on_el );
21345 this.render(document.body);
21351 if (this.title === false) {
21352 this.headerEl.hide();
21357 this.el.dom.style.display = 'block';
21360 if (this.alignEl) {
21361 this.updatePosition(this.placement, true);
21364 // this is usually just done by the builder = to show the popoup in the middle of the scren.
21365 var es = this.el.getSize();
21366 var x = Roo.lib.Dom.getViewWidth()/2;
21367 var y = Roo.lib.Dom.getViewHeight()/2;
21368 this.el.setXY([ x-(es.width/2), y-(es.height/2)] );
21373 //var arrow = this.el.select('.arrow',true).first();
21374 //arrow.set(align[2],
21376 this.el.addClass('in');
21380 this.hoverState = 'in';
21383 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
21384 this.maskEl.setStyle('z-index', Roo.bootstrap.Popover.zIndex++);
21385 this.maskEl.dom.style.display = 'block';
21386 this.maskEl.addClass('show');
21388 this.el.setStyle('z-index', Roo.bootstrap.Popover.zIndex++);
21390 this.fireEvent('show', this);
21394 * fire this manually after loading a grid in the table for example
21395 * @param {string} (left|right|top|bottom) where to try and put it (use false to use the last one)
21396 * @param {Boolean} try and move it if we cant get right position.
21398 updatePosition : function(placement, try_move)
21400 // allow for calling with no parameters
21401 placement = placement ? placement : this.placement;
21402 try_move = typeof(try_move) == 'undefined' ? true : try_move;
21404 this.el.removeClass([
21405 'fade','top','bottom', 'left', 'right','in',
21406 'bs-popover-top','bs-popover-bottom', 'bs-popover-left', 'bs-popover-right'
21408 this.el.addClass(placement + ' bs-popover-' + placement);
21410 if (!this.alignEl ) {
21414 switch (placement) {
21416 var exact = this.el.getAlignToXY(this.alignEl, 'tl-tr', [10,0]);
21417 var offset = this.el.getAlignToXY(this.alignEl, 'tl-tr?',[10,0]);
21418 if (!try_move || exact.equals(offset) || exact[0] == offset[0] ) {
21419 //normal display... or moved up/down.
21420 this.el.setXY(offset);
21421 var xy = this.alignEl.getAnchorXY('tr', false);
21423 this.arrowEl.setXY(xy);
21426 // continue through...
21427 return this.updatePosition('left', false);
21431 var exact = this.el.getAlignToXY(this.alignEl, 'tr-tl', [-10,0]);
21432 var offset = this.el.getAlignToXY(this.alignEl, 'tr-tl?',[-10,0]);
21433 if (!try_move || exact.equals(offset) || exact[0] == offset[0] ) {
21434 //normal display... or moved up/down.
21435 this.el.setXY(offset);
21436 var xy = this.alignEl.getAnchorXY('tl', false);
21437 xy[0]-=10;xy[1]+=5; // << fix me
21438 this.arrowEl.setXY(xy);
21442 return this.updatePosition('right', false);
21445 var exact = this.el.getAlignToXY(this.alignEl, 'b-t', [0,-10]);
21446 var offset = this.el.getAlignToXY(this.alignEl, 'b-t?',[0,-10]);
21447 if (!try_move || exact.equals(offset) || exact[1] == offset[1] ) {
21448 //normal display... or moved up/down.
21449 this.el.setXY(offset);
21450 var xy = this.alignEl.getAnchorXY('t', false);
21451 xy[1]-=10; // << fix me
21452 this.arrowEl.setXY(xy);
21456 return this.updatePosition('bottom', false);
21459 var exact = this.el.getAlignToXY(this.alignEl, 't-b', [0,10]);
21460 var offset = this.el.getAlignToXY(this.alignEl, 't-b?',[0,10]);
21461 if (!try_move || exact.equals(offset) || exact[1] == offset[1] ) {
21462 //normal display... or moved up/down.
21463 this.el.setXY(offset);
21464 var xy = this.alignEl.getAnchorXY('b', false);
21465 xy[1]+=2; // << fix me
21466 this.arrowEl.setXY(xy);
21470 return this.updatePosition('top', false);
21481 this.el.setXY([0,0]);
21482 this.el.removeClass('in');
21484 this.hoverState = null;
21485 this.maskEl.hide(); // always..
21486 this.fireEvent('hide', this);
21492 Roo.apply(Roo.bootstrap.Popover, {
21495 'left' : ['r-l', [-10,0], 'left bs-popover-left'],
21496 'right' : ['l-br', [10,0], 'right bs-popover-right'],
21497 'bottom' : ['t-b', [0,10], 'top bs-popover-top'],
21498 'top' : [ 'b-t', [0,-10], 'bottom bs-popover-bottom']
21503 clickHander : false,
21507 onMouseDown : function(e)
21509 if (this.popups.length && !e.getTarget(".roo-popover")) {
21510 /// what is nothing is showing..
21519 register : function(popup)
21521 if (!Roo.bootstrap.Popover.clickHandler) {
21522 Roo.bootstrap.Popover.clickHandler = Roo.get(document).on("mousedown", Roo.bootstrap.Popover.onMouseDown, Roo.bootstrap.Popover);
21524 // hide other popups.
21525 popup.on('show', Roo.bootstrap.Popover.onShow, popup);
21526 popup.on('hide', Roo.bootstrap.Popover.onHide, popup);
21527 this.hideAll(); //<< why?
21528 //this.popups.push(popup);
21530 hideAll : function()
21532 this.popups.forEach(function(p) {
21536 onShow : function() {
21537 Roo.bootstrap.Popover.popups.push(this);
21539 onHide : function() {
21540 Roo.bootstrap.Popover.popups.remove(this);
21546 * Card header - holder for the card header elements.
21551 * @class Roo.bootstrap.PopoverNav
21552 * @extends Roo.bootstrap.NavGroup
21553 * Bootstrap Popover header navigation class
21555 * Create a new Popover Header Navigation
21556 * @param {Object} config The config object
21559 Roo.bootstrap.PopoverNav = function(config){
21560 Roo.bootstrap.PopoverNav.superclass.constructor.call(this, config);
21563 Roo.extend(Roo.bootstrap.PopoverNav, Roo.bootstrap.NavSimplebar, {
21566 container_method : 'getPopoverHeader'
21584 * @class Roo.bootstrap.Progress
21585 * @extends Roo.bootstrap.Component
21586 * Bootstrap Progress class
21587 * @cfg {Boolean} striped striped of the progress bar
21588 * @cfg {Boolean} active animated of the progress bar
21592 * Create a new Progress
21593 * @param {Object} config The config object
21596 Roo.bootstrap.Progress = function(config){
21597 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
21600 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
21605 getAutoCreate : function(){
21613 cfg.cls += ' progress-striped';
21617 cfg.cls += ' active';
21636 * @class Roo.bootstrap.ProgressBar
21637 * @extends Roo.bootstrap.Component
21638 * Bootstrap ProgressBar class
21639 * @cfg {Number} aria_valuenow aria-value now
21640 * @cfg {Number} aria_valuemin aria-value min
21641 * @cfg {Number} aria_valuemax aria-value max
21642 * @cfg {String} label label for the progress bar
21643 * @cfg {String} panel (success | info | warning | danger )
21644 * @cfg {String} role role of the progress bar
21645 * @cfg {String} sr_only text
21649 * Create a new ProgressBar
21650 * @param {Object} config The config object
21653 Roo.bootstrap.ProgressBar = function(config){
21654 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
21657 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
21661 aria_valuemax : 100,
21667 getAutoCreate : function()
21672 cls: 'progress-bar',
21673 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
21685 cfg.role = this.role;
21688 if(this.aria_valuenow){
21689 cfg['aria-valuenow'] = this.aria_valuenow;
21692 if(this.aria_valuemin){
21693 cfg['aria-valuemin'] = this.aria_valuemin;
21696 if(this.aria_valuemax){
21697 cfg['aria-valuemax'] = this.aria_valuemax;
21700 if(this.label && !this.sr_only){
21701 cfg.html = this.label;
21705 cfg.cls += ' progress-bar-' + this.panel;
21711 update : function(aria_valuenow)
21713 this.aria_valuenow = aria_valuenow;
21715 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
21730 * @class Roo.bootstrap.TabGroup
21731 * @extends Roo.bootstrap.Column
21732 * Bootstrap Column class
21733 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
21734 * @cfg {Boolean} carousel true to make the group behave like a carousel
21735 * @cfg {Boolean} bullets show bullets for the panels
21736 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
21737 * @cfg {Number} timer auto slide timer .. default 0 millisecond
21738 * @cfg {Boolean} showarrow (true|false) show arrow default true
21741 * Create a new TabGroup
21742 * @param {Object} config The config object
21745 Roo.bootstrap.TabGroup = function(config){
21746 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
21748 this.navId = Roo.id();
21751 Roo.bootstrap.TabGroup.register(this);
21755 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
21758 transition : false,
21763 slideOnTouch : false,
21766 getAutoCreate : function()
21768 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
21770 cfg.cls += ' tab-content';
21772 if (this.carousel) {
21773 cfg.cls += ' carousel slide';
21776 cls : 'carousel-inner',
21780 if(this.bullets && !Roo.isTouch){
21783 cls : 'carousel-bullets',
21787 if(this.bullets_cls){
21788 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
21795 cfg.cn[0].cn.push(bullets);
21798 if(this.showarrow){
21799 cfg.cn[0].cn.push({
21801 class : 'carousel-arrow',
21805 class : 'carousel-prev',
21809 class : 'fa fa-chevron-left'
21815 class : 'carousel-next',
21819 class : 'fa fa-chevron-right'
21832 initEvents: function()
21834 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
21835 // this.el.on("touchstart", this.onTouchStart, this);
21838 if(this.autoslide){
21841 this.slideFn = window.setInterval(function() {
21842 _this.showPanelNext();
21846 if(this.showarrow){
21847 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
21848 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
21854 // onTouchStart : function(e, el, o)
21856 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
21860 // this.showPanelNext();
21864 getChildContainer : function()
21866 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
21870 * register a Navigation item
21871 * @param {Roo.bootstrap.NavItem} the navitem to add
21873 register : function(item)
21875 this.tabs.push( item);
21876 item.navId = this.navId; // not really needed..
21881 getActivePanel : function()
21884 Roo.each(this.tabs, function(t) {
21894 getPanelByName : function(n)
21897 Roo.each(this.tabs, function(t) {
21898 if (t.tabId == n) {
21906 indexOfPanel : function(p)
21909 Roo.each(this.tabs, function(t,i) {
21910 if (t.tabId == p.tabId) {
21919 * show a specific panel
21920 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
21921 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
21923 showPanel : function (pan)
21925 if(this.transition || typeof(pan) == 'undefined'){
21926 Roo.log("waiting for the transitionend");
21930 if (typeof(pan) == 'number') {
21931 pan = this.tabs[pan];
21934 if (typeof(pan) == 'string') {
21935 pan = this.getPanelByName(pan);
21938 var cur = this.getActivePanel();
21941 Roo.log('pan or acitve pan is undefined');
21945 if (pan.tabId == this.getActivePanel().tabId) {
21949 if (false === cur.fireEvent('beforedeactivate')) {
21953 if(this.bullets > 0 && !Roo.isTouch){
21954 this.setActiveBullet(this.indexOfPanel(pan));
21957 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
21959 //class="carousel-item carousel-item-next carousel-item-left"
21961 this.transition = true;
21962 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
21963 var lr = dir == 'next' ? 'left' : 'right';
21964 pan.el.addClass(dir); // or prev
21965 pan.el.addClass('carousel-item-' + dir); // or prev
21966 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
21967 cur.el.addClass(lr); // or right
21968 pan.el.addClass(lr);
21969 cur.el.addClass('carousel-item-' +lr); // or right
21970 pan.el.addClass('carousel-item-' +lr);
21974 cur.el.on('transitionend', function() {
21975 Roo.log("trans end?");
21977 pan.el.removeClass([lr,dir, 'carousel-item-' + lr, 'carousel-item-' + dir]);
21978 pan.setActive(true);
21980 cur.el.removeClass([lr, 'carousel-item-' + lr]);
21981 cur.setActive(false);
21983 _this.transition = false;
21985 }, this, { single: true } );
21990 cur.setActive(false);
21991 pan.setActive(true);
21996 showPanelNext : function()
21998 var i = this.indexOfPanel(this.getActivePanel());
22000 if (i >= this.tabs.length - 1 && !this.autoslide) {
22004 if (i >= this.tabs.length - 1 && this.autoslide) {
22008 this.showPanel(this.tabs[i+1]);
22011 showPanelPrev : function()
22013 var i = this.indexOfPanel(this.getActivePanel());
22015 if (i < 1 && !this.autoslide) {
22019 if (i < 1 && this.autoslide) {
22020 i = this.tabs.length;
22023 this.showPanel(this.tabs[i-1]);
22027 addBullet: function()
22029 if(!this.bullets || Roo.isTouch){
22032 var ctr = this.el.select('.carousel-bullets',true).first();
22033 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
22034 var bullet = ctr.createChild({
22035 cls : 'bullet bullet-' + i
22036 },ctr.dom.lastChild);
22041 bullet.on('click', (function(e, el, o, ii, t){
22043 e.preventDefault();
22045 this.showPanel(ii);
22047 if(this.autoslide && this.slideFn){
22048 clearInterval(this.slideFn);
22049 this.slideFn = window.setInterval(function() {
22050 _this.showPanelNext();
22054 }).createDelegate(this, [i, bullet], true));
22059 setActiveBullet : function(i)
22065 Roo.each(this.el.select('.bullet', true).elements, function(el){
22066 el.removeClass('selected');
22069 var bullet = this.el.select('.bullet-' + i, true).first();
22075 bullet.addClass('selected');
22086 Roo.apply(Roo.bootstrap.TabGroup, {
22090 * register a Navigation Group
22091 * @param {Roo.bootstrap.NavGroup} the navgroup to add
22093 register : function(navgrp)
22095 this.groups[navgrp.navId] = navgrp;
22099 * fetch a Navigation Group based on the navigation ID
22100 * if one does not exist , it will get created.
22101 * @param {string} the navgroup to add
22102 * @returns {Roo.bootstrap.NavGroup} the navgroup
22104 get: function(navId) {
22105 if (typeof(this.groups[navId]) == 'undefined') {
22106 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
22108 return this.groups[navId] ;
22123 * @class Roo.bootstrap.TabPanel
22124 * @extends Roo.bootstrap.Component
22125 * Bootstrap TabPanel class
22126 * @cfg {Boolean} active panel active
22127 * @cfg {String} html panel content
22128 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
22129 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
22130 * @cfg {String} href click to link..
22131 * @cfg {Boolean} touchSlide if swiping slides tab to next panel (default off)
22135 * Create a new TabPanel
22136 * @param {Object} config The config object
22139 Roo.bootstrap.TabPanel = function(config){
22140 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
22144 * Fires when the active status changes
22145 * @param {Roo.bootstrap.TabPanel} this
22146 * @param {Boolean} state the new state
22151 * @event beforedeactivate
22152 * Fires before a tab is de-activated - can be used to do validation on a form.
22153 * @param {Roo.bootstrap.TabPanel} this
22154 * @return {Boolean} false if there is an error
22157 'beforedeactivate': true
22160 this.tabId = this.tabId || Roo.id();
22164 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
22171 touchSlide : false,
22172 getAutoCreate : function(){
22177 // item is needed for carousel - not sure if it has any effect otherwise
22178 cls: 'carousel-item tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
22179 html: this.html || ''
22183 cfg.cls += ' active';
22187 cfg.tabId = this.tabId;
22195 initEvents: function()
22197 var p = this.parent();
22199 this.navId = this.navId || p.navId;
22201 if (typeof(this.navId) != 'undefined') {
22202 // not really needed.. but just in case.. parent should be a NavGroup.
22203 var tg = Roo.bootstrap.TabGroup.get(this.navId);
22207 var i = tg.tabs.length - 1;
22209 if(this.active && tg.bullets > 0 && i < tg.bullets){
22210 tg.setActiveBullet(i);
22214 this.el.on('click', this.onClick, this);
22216 if(Roo.isTouch && this.touchSlide){
22217 this.el.on("touchstart", this.onTouchStart, this);
22218 this.el.on("touchmove", this.onTouchMove, this);
22219 this.el.on("touchend", this.onTouchEnd, this);
22224 onRender : function(ct, position)
22226 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
22229 setActive : function(state)
22231 Roo.log("panel - set active " + this.tabId + "=" + state);
22233 this.active = state;
22235 this.el.removeClass('active');
22237 } else if (!this.el.hasClass('active')) {
22238 this.el.addClass('active');
22241 this.fireEvent('changed', this, state);
22244 onClick : function(e)
22246 e.preventDefault();
22248 if(!this.href.length){
22252 window.location.href = this.href;
22261 onTouchStart : function(e)
22263 this.swiping = false;
22265 this.startX = e.browserEvent.touches[0].clientX;
22266 this.startY = e.browserEvent.touches[0].clientY;
22269 onTouchMove : function(e)
22271 this.swiping = true;
22273 this.endX = e.browserEvent.touches[0].clientX;
22274 this.endY = e.browserEvent.touches[0].clientY;
22277 onTouchEnd : function(e)
22284 var tabGroup = this.parent();
22286 if(this.endX > this.startX){ // swiping right
22287 tabGroup.showPanelPrev();
22291 if(this.startX > this.endX){ // swiping left
22292 tabGroup.showPanelNext();
22311 * @class Roo.bootstrap.DateField
22312 * @extends Roo.bootstrap.Input
22313 * Bootstrap DateField class
22314 * @cfg {Number} weekStart default 0
22315 * @cfg {String} viewMode default empty, (months|years)
22316 * @cfg {String} minViewMode default empty, (months|years)
22317 * @cfg {Number} startDate default -Infinity
22318 * @cfg {Number} endDate default Infinity
22319 * @cfg {Boolean} todayHighlight default false
22320 * @cfg {Boolean} todayBtn default false
22321 * @cfg {Boolean} calendarWeeks default false
22322 * @cfg {Object} daysOfWeekDisabled default empty
22323 * @cfg {Boolean} singleMode default false (true | false)
22325 * @cfg {Boolean} keyboardNavigation default true
22326 * @cfg {String} language default en
22329 * Create a new DateField
22330 * @param {Object} config The config object
22333 Roo.bootstrap.DateField = function(config){
22334 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
22338 * Fires when this field show.
22339 * @param {Roo.bootstrap.DateField} this
22340 * @param {Mixed} date The date value
22345 * Fires when this field hide.
22346 * @param {Roo.bootstrap.DateField} this
22347 * @param {Mixed} date The date value
22352 * Fires when select a date.
22353 * @param {Roo.bootstrap.DateField} this
22354 * @param {Mixed} date The date value
22358 * @event beforeselect
22359 * Fires when before select a date.
22360 * @param {Roo.bootstrap.DateField} this
22361 * @param {Mixed} date The date value
22363 beforeselect : true
22367 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
22370 * @cfg {String} format
22371 * The default date format string which can be overriden for localization support. The format must be
22372 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
22376 * @cfg {String} altFormats
22377 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
22378 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
22380 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
22388 todayHighlight : false,
22394 keyboardNavigation: true,
22396 calendarWeeks: false,
22398 startDate: -Infinity,
22402 daysOfWeekDisabled: [],
22406 singleMode : false,
22408 UTCDate: function()
22410 return new Date(Date.UTC.apply(Date, arguments));
22413 UTCToday: function()
22415 var today = new Date();
22416 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
22419 getDate: function() {
22420 var d = this.getUTCDate();
22421 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
22424 getUTCDate: function() {
22428 setDate: function(d) {
22429 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
22432 setUTCDate: function(d) {
22434 this.setValue(this.formatDate(this.date));
22437 onRender: function(ct, position)
22440 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
22442 this.language = this.language || 'en';
22443 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
22444 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
22446 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
22447 this.format = this.format || 'm/d/y';
22448 this.isInline = false;
22449 this.isInput = true;
22450 this.component = this.el.select('.add-on', true).first() || false;
22451 this.component = (this.component && this.component.length === 0) ? false : this.component;
22452 this.hasInput = this.component && this.inputEl().length;
22454 if (typeof(this.minViewMode === 'string')) {
22455 switch (this.minViewMode) {
22457 this.minViewMode = 1;
22460 this.minViewMode = 2;
22463 this.minViewMode = 0;
22468 if (typeof(this.viewMode === 'string')) {
22469 switch (this.viewMode) {
22482 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
22484 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
22486 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
22488 this.picker().on('mousedown', this.onMousedown, this);
22489 this.picker().on('click', this.onClick, this);
22491 this.picker().addClass('datepicker-dropdown');
22493 this.startViewMode = this.viewMode;
22495 if(this.singleMode){
22496 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
22497 v.setVisibilityMode(Roo.Element.DISPLAY);
22501 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
22502 v.setStyle('width', '189px');
22506 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
22507 if(!this.calendarWeeks){
22512 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
22513 v.attr('colspan', function(i, val){
22514 return parseInt(val) + 1;
22519 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
22521 this.setStartDate(this.startDate);
22522 this.setEndDate(this.endDate);
22524 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
22531 if(this.isInline) {
22536 picker : function()
22538 return this.pickerEl;
22539 // return this.el.select('.datepicker', true).first();
22542 fillDow: function()
22544 var dowCnt = this.weekStart;
22553 if(this.calendarWeeks){
22561 while (dowCnt < this.weekStart + 7) {
22565 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
22569 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
22572 fillMonths: function()
22575 var months = this.picker().select('>.datepicker-months td', true).first();
22577 months.dom.innerHTML = '';
22583 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
22586 months.createChild(month);
22593 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;
22595 if (this.date < this.startDate) {
22596 this.viewDate = new Date(this.startDate);
22597 } else if (this.date > this.endDate) {
22598 this.viewDate = new Date(this.endDate);
22600 this.viewDate = new Date(this.date);
22608 var d = new Date(this.viewDate),
22609 year = d.getUTCFullYear(),
22610 month = d.getUTCMonth(),
22611 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
22612 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
22613 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
22614 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
22615 currentDate = this.date && this.date.valueOf(),
22616 today = this.UTCToday();
22618 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
22620 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
22622 // this.picker.select('>tfoot th.today').
22623 // .text(dates[this.language].today)
22624 // .toggle(this.todayBtn !== false);
22626 this.updateNavArrows();
22629 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
22631 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
22633 prevMonth.setUTCDate(day);
22635 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
22637 var nextMonth = new Date(prevMonth);
22639 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
22641 nextMonth = nextMonth.valueOf();
22643 var fillMonths = false;
22645 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
22647 while(prevMonth.valueOf() <= nextMonth) {
22650 if (prevMonth.getUTCDay() === this.weekStart) {
22652 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
22660 if(this.calendarWeeks){
22661 // ISO 8601: First week contains first thursday.
22662 // ISO also states week starts on Monday, but we can be more abstract here.
22664 // Start of current week: based on weekstart/current date
22665 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
22666 // Thursday of this week
22667 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
22668 // First Thursday of year, year from thursday
22669 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
22670 // Calendar week: ms between thursdays, div ms per day, div 7 days
22671 calWeek = (th - yth) / 864e5 / 7 + 1;
22673 fillMonths.cn.push({
22681 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
22683 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
22686 if (this.todayHighlight &&
22687 prevMonth.getUTCFullYear() == today.getFullYear() &&
22688 prevMonth.getUTCMonth() == today.getMonth() &&
22689 prevMonth.getUTCDate() == today.getDate()) {
22690 clsName += ' today';
22693 if (currentDate && prevMonth.valueOf() === currentDate) {
22694 clsName += ' active';
22697 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
22698 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
22699 clsName += ' disabled';
22702 fillMonths.cn.push({
22704 cls: 'day ' + clsName,
22705 html: prevMonth.getDate()
22708 prevMonth.setDate(prevMonth.getDate()+1);
22711 var currentYear = this.date && this.date.getUTCFullYear();
22712 var currentMonth = this.date && this.date.getUTCMonth();
22714 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
22716 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
22717 v.removeClass('active');
22719 if(currentYear === year && k === currentMonth){
22720 v.addClass('active');
22723 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
22724 v.addClass('disabled');
22730 year = parseInt(year/10, 10) * 10;
22732 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
22734 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
22737 for (var i = -1; i < 11; i++) {
22738 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
22740 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
22748 showMode: function(dir)
22751 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
22754 Roo.each(this.picker().select('>div',true).elements, function(v){
22755 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
22758 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
22763 if(this.isInline) {
22767 this.picker().removeClass(['bottom', 'top']);
22769 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
22771 * place to the top of element!
22775 this.picker().addClass('top');
22776 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
22781 this.picker().addClass('bottom');
22783 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
22786 parseDate : function(value)
22788 if(!value || value instanceof Date){
22791 var v = Date.parseDate(value, this.format);
22792 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
22793 v = Date.parseDate(value, 'Y-m-d');
22795 if(!v && this.altFormats){
22796 if(!this.altFormatsArray){
22797 this.altFormatsArray = this.altFormats.split("|");
22799 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
22800 v = Date.parseDate(value, this.altFormatsArray[i]);
22806 formatDate : function(date, fmt)
22808 return (!date || !(date instanceof Date)) ?
22809 date : date.dateFormat(fmt || this.format);
22812 onFocus : function()
22814 Roo.bootstrap.DateField.superclass.onFocus.call(this);
22818 onBlur : function()
22820 Roo.bootstrap.DateField.superclass.onBlur.call(this);
22822 var d = this.inputEl().getValue();
22829 showPopup : function()
22831 this.picker().show();
22835 this.fireEvent('showpopup', this, this.date);
22838 hidePopup : function()
22840 if(this.isInline) {
22843 this.picker().hide();
22844 this.viewMode = this.startViewMode;
22847 this.fireEvent('hidepopup', this, this.date);
22851 onMousedown: function(e)
22853 e.stopPropagation();
22854 e.preventDefault();
22859 Roo.bootstrap.DateField.superclass.keyup.call(this);
22863 setValue: function(v)
22865 if(this.fireEvent('beforeselect', this, v) !== false){
22866 var d = new Date(this.parseDate(v) ).clearTime();
22868 if(isNaN(d.getTime())){
22869 this.date = this.viewDate = '';
22870 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
22874 v = this.formatDate(d);
22876 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
22878 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
22882 this.fireEvent('select', this, this.date);
22886 getValue: function()
22888 return this.formatDate(this.date);
22891 fireKey: function(e)
22893 if (!this.picker().isVisible()){
22894 if (e.keyCode == 27) { // allow escape to hide and re-show picker
22900 var dateChanged = false,
22902 newDate, newViewDate;
22907 e.preventDefault();
22911 if (!this.keyboardNavigation) {
22914 dir = e.keyCode == 37 ? -1 : 1;
22917 newDate = this.moveYear(this.date, dir);
22918 newViewDate = this.moveYear(this.viewDate, dir);
22919 } else if (e.shiftKey){
22920 newDate = this.moveMonth(this.date, dir);
22921 newViewDate = this.moveMonth(this.viewDate, dir);
22923 newDate = new Date(this.date);
22924 newDate.setUTCDate(this.date.getUTCDate() + dir);
22925 newViewDate = new Date(this.viewDate);
22926 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
22928 if (this.dateWithinRange(newDate)){
22929 this.date = newDate;
22930 this.viewDate = newViewDate;
22931 this.setValue(this.formatDate(this.date));
22933 e.preventDefault();
22934 dateChanged = true;
22939 if (!this.keyboardNavigation) {
22942 dir = e.keyCode == 38 ? -1 : 1;
22944 newDate = this.moveYear(this.date, dir);
22945 newViewDate = this.moveYear(this.viewDate, dir);
22946 } else if (e.shiftKey){
22947 newDate = this.moveMonth(this.date, dir);
22948 newViewDate = this.moveMonth(this.viewDate, dir);
22950 newDate = new Date(this.date);
22951 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
22952 newViewDate = new Date(this.viewDate);
22953 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
22955 if (this.dateWithinRange(newDate)){
22956 this.date = newDate;
22957 this.viewDate = newViewDate;
22958 this.setValue(this.formatDate(this.date));
22960 e.preventDefault();
22961 dateChanged = true;
22965 this.setValue(this.formatDate(this.date));
22967 e.preventDefault();
22970 this.setValue(this.formatDate(this.date));
22984 onClick: function(e)
22986 e.stopPropagation();
22987 e.preventDefault();
22989 var target = e.getTarget();
22991 if(target.nodeName.toLowerCase() === 'i'){
22992 target = Roo.get(target).dom.parentNode;
22995 var nodeName = target.nodeName;
22996 var className = target.className;
22997 var html = target.innerHTML;
22998 //Roo.log(nodeName);
23000 switch(nodeName.toLowerCase()) {
23002 switch(className) {
23008 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
23009 switch(this.viewMode){
23011 this.viewDate = this.moveMonth(this.viewDate, dir);
23015 this.viewDate = this.moveYear(this.viewDate, dir);
23021 var date = new Date();
23022 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
23024 this.setValue(this.formatDate(this.date));
23031 if (className.indexOf('disabled') < 0) {
23032 if (!this.viewDate) {
23033 this.viewDate = new Date();
23035 this.viewDate.setUTCDate(1);
23036 if (className.indexOf('month') > -1) {
23037 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
23039 var year = parseInt(html, 10) || 0;
23040 this.viewDate.setUTCFullYear(year);
23044 if(this.singleMode){
23045 this.setValue(this.formatDate(this.viewDate));
23056 //Roo.log(className);
23057 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
23058 var day = parseInt(html, 10) || 1;
23059 var year = (this.viewDate || new Date()).getUTCFullYear(),
23060 month = (this.viewDate || new Date()).getUTCMonth();
23062 if (className.indexOf('old') > -1) {
23069 } else if (className.indexOf('new') > -1) {
23077 //Roo.log([year,month,day]);
23078 this.date = this.UTCDate(year, month, day,0,0,0,0);
23079 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
23081 //Roo.log(this.formatDate(this.date));
23082 this.setValue(this.formatDate(this.date));
23089 setStartDate: function(startDate)
23091 this.startDate = startDate || -Infinity;
23092 if (this.startDate !== -Infinity) {
23093 this.startDate = this.parseDate(this.startDate);
23096 this.updateNavArrows();
23099 setEndDate: function(endDate)
23101 this.endDate = endDate || Infinity;
23102 if (this.endDate !== Infinity) {
23103 this.endDate = this.parseDate(this.endDate);
23106 this.updateNavArrows();
23109 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
23111 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
23112 if (typeof(this.daysOfWeekDisabled) !== 'object') {
23113 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
23115 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
23116 return parseInt(d, 10);
23119 this.updateNavArrows();
23122 updateNavArrows: function()
23124 if(this.singleMode){
23128 var d = new Date(this.viewDate),
23129 year = d.getUTCFullYear(),
23130 month = d.getUTCMonth();
23132 Roo.each(this.picker().select('.prev', true).elements, function(v){
23134 switch (this.viewMode) {
23137 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
23143 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
23150 Roo.each(this.picker().select('.next', true).elements, function(v){
23152 switch (this.viewMode) {
23155 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
23161 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
23169 moveMonth: function(date, dir)
23174 var new_date = new Date(date.valueOf()),
23175 day = new_date.getUTCDate(),
23176 month = new_date.getUTCMonth(),
23177 mag = Math.abs(dir),
23179 dir = dir > 0 ? 1 : -1;
23182 // If going back one month, make sure month is not current month
23183 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
23185 return new_date.getUTCMonth() == month;
23187 // If going forward one month, make sure month is as expected
23188 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
23190 return new_date.getUTCMonth() != new_month;
23192 new_month = month + dir;
23193 new_date.setUTCMonth(new_month);
23194 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
23195 if (new_month < 0 || new_month > 11) {
23196 new_month = (new_month + 12) % 12;
23199 // For magnitudes >1, move one month at a time...
23200 for (var i=0; i<mag; i++) {
23201 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
23202 new_date = this.moveMonth(new_date, dir);
23204 // ...then reset the day, keeping it in the new month
23205 new_month = new_date.getUTCMonth();
23206 new_date.setUTCDate(day);
23208 return new_month != new_date.getUTCMonth();
23211 // Common date-resetting loop -- if date is beyond end of month, make it
23214 new_date.setUTCDate(--day);
23215 new_date.setUTCMonth(new_month);
23220 moveYear: function(date, dir)
23222 return this.moveMonth(date, dir*12);
23225 dateWithinRange: function(date)
23227 return date >= this.startDate && date <= this.endDate;
23233 this.picker().remove();
23236 validateValue : function(value)
23238 if(this.getVisibilityEl().hasClass('hidden')){
23242 if(value.length < 1) {
23243 if(this.allowBlank){
23249 if(value.length < this.minLength){
23252 if(value.length > this.maxLength){
23256 var vt = Roo.form.VTypes;
23257 if(!vt[this.vtype](value, this)){
23261 if(typeof this.validator == "function"){
23262 var msg = this.validator(value);
23268 if(this.regex && !this.regex.test(value)){
23272 if(typeof(this.parseDate(value)) == 'undefined'){
23276 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
23280 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
23290 this.date = this.viewDate = '';
23292 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
23297 Roo.apply(Roo.bootstrap.DateField, {
23308 html: '<i class="fa fa-arrow-left"/>'
23318 html: '<i class="fa fa-arrow-right"/>'
23360 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
23361 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
23362 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
23363 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
23364 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
23377 navFnc: 'FullYear',
23382 navFnc: 'FullYear',
23387 Roo.apply(Roo.bootstrap.DateField, {
23391 cls: 'datepicker dropdown-menu roo-dynamic shadow',
23395 cls: 'datepicker-days',
23399 cls: 'table-condensed',
23401 Roo.bootstrap.DateField.head,
23405 Roo.bootstrap.DateField.footer
23412 cls: 'datepicker-months',
23416 cls: 'table-condensed',
23418 Roo.bootstrap.DateField.head,
23419 Roo.bootstrap.DateField.content,
23420 Roo.bootstrap.DateField.footer
23427 cls: 'datepicker-years',
23431 cls: 'table-condensed',
23433 Roo.bootstrap.DateField.head,
23434 Roo.bootstrap.DateField.content,
23435 Roo.bootstrap.DateField.footer
23454 * @class Roo.bootstrap.TimeField
23455 * @extends Roo.bootstrap.Input
23456 * Bootstrap DateField class
23460 * Create a new TimeField
23461 * @param {Object} config The config object
23464 Roo.bootstrap.TimeField = function(config){
23465 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
23469 * Fires when this field show.
23470 * @param {Roo.bootstrap.DateField} thisthis
23471 * @param {Mixed} date The date value
23476 * Fires when this field hide.
23477 * @param {Roo.bootstrap.DateField} this
23478 * @param {Mixed} date The date value
23483 * Fires when select a date.
23484 * @param {Roo.bootstrap.DateField} this
23485 * @param {Mixed} date The date value
23491 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
23494 * @cfg {String} format
23495 * The default time format string which can be overriden for localization support. The format must be
23496 * valid according to {@link Date#parseDate} (defaults to 'H:i').
23500 getAutoCreate : function()
23502 this.after = '<i class="fa far fa-clock"></i>';
23503 return Roo.bootstrap.TimeField.superclass.getAutoCreate.call(this);
23507 onRender: function(ct, position)
23510 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
23512 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.TimeField.template);
23514 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
23516 this.pop = this.picker().select('>.datepicker-time',true).first();
23517 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
23519 this.picker().on('mousedown', this.onMousedown, this);
23520 this.picker().on('click', this.onClick, this);
23522 this.picker().addClass('datepicker-dropdown');
23527 this.pop.select('.hours-up', true).first().on('click', this.onIncrementHours, this);
23528 this.pop.select('.hours-down', true).first().on('click', this.onDecrementHours, this);
23529 this.pop.select('.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
23530 this.pop.select('.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
23531 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
23532 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
23536 fireKey: function(e){
23537 if (!this.picker().isVisible()){
23538 if (e.keyCode == 27) { // allow escape to hide and re-show picker
23544 e.preventDefault();
23552 this.onTogglePeriod();
23555 this.onIncrementMinutes();
23558 this.onDecrementMinutes();
23567 onClick: function(e) {
23568 e.stopPropagation();
23569 e.preventDefault();
23572 picker : function()
23574 return this.pickerEl;
23577 fillTime: function()
23579 var time = this.pop.select('tbody', true).first();
23581 time.dom.innerHTML = '';
23596 cls: 'hours-up fa fas fa-chevron-up'
23616 cls: 'minutes-up fa fas fa-chevron-up'
23637 cls: 'timepicker-hour',
23652 cls: 'timepicker-minute',
23667 cls: 'btn btn-primary period',
23689 cls: 'hours-down fa fas fa-chevron-down'
23709 cls: 'minutes-down fa fas fa-chevron-down'
23727 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
23734 var hours = this.time.getHours();
23735 var minutes = this.time.getMinutes();
23748 hours = hours - 12;
23752 hours = '0' + hours;
23756 minutes = '0' + minutes;
23759 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
23760 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
23761 this.pop.select('button', true).first().dom.innerHTML = period;
23767 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
23769 var cls = ['bottom'];
23771 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
23778 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
23782 //this.picker().setXY(20000,20000);
23783 this.picker().addClass(cls.join('-'));
23787 Roo.each(cls, function(c){
23792 _this.picker().alignTo(_this.inputEl(), "tr-br", [0, 10], false);
23793 //_this.picker().setTop(_this.inputEl().getHeight());
23797 _this.picker().alignTo(_this.inputEl(), "br-tr", [0, 10], false);
23799 //_this.picker().setTop(0 - _this.picker().getHeight());
23804 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
23808 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
23816 onFocus : function()
23818 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
23822 onBlur : function()
23824 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
23830 this.picker().show();
23835 this.fireEvent('show', this, this.date);
23840 this.picker().hide();
23843 this.fireEvent('hide', this, this.date);
23846 setTime : function()
23849 this.setValue(this.time.format(this.format));
23851 this.fireEvent('select', this, this.date);
23856 onMousedown: function(e){
23857 e.stopPropagation();
23858 e.preventDefault();
23861 onIncrementHours: function()
23863 Roo.log('onIncrementHours');
23864 this.time = this.time.add(Date.HOUR, 1);
23869 onDecrementHours: function()
23871 Roo.log('onDecrementHours');
23872 this.time = this.time.add(Date.HOUR, -1);
23876 onIncrementMinutes: function()
23878 Roo.log('onIncrementMinutes');
23879 this.time = this.time.add(Date.MINUTE, 1);
23883 onDecrementMinutes: function()
23885 Roo.log('onDecrementMinutes');
23886 this.time = this.time.add(Date.MINUTE, -1);
23890 onTogglePeriod: function()
23892 Roo.log('onTogglePeriod');
23893 this.time = this.time.add(Date.HOUR, 12);
23901 Roo.apply(Roo.bootstrap.TimeField, {
23905 cls: 'datepicker dropdown-menu',
23909 cls: 'datepicker-time',
23913 cls: 'table-condensed',
23942 cls: 'btn btn-info ok',
23970 * @class Roo.bootstrap.MonthField
23971 * @extends Roo.bootstrap.Input
23972 * Bootstrap MonthField class
23974 * @cfg {String} language default en
23977 * Create a new MonthField
23978 * @param {Object} config The config object
23981 Roo.bootstrap.MonthField = function(config){
23982 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
23987 * Fires when this field show.
23988 * @param {Roo.bootstrap.MonthField} this
23989 * @param {Mixed} date The date value
23994 * Fires when this field hide.
23995 * @param {Roo.bootstrap.MonthField} this
23996 * @param {Mixed} date The date value
24001 * Fires when select a date.
24002 * @param {Roo.bootstrap.MonthField} this
24003 * @param {String} oldvalue The old value
24004 * @param {String} newvalue The new value
24010 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
24012 onRender: function(ct, position)
24015 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
24017 this.language = this.language || 'en';
24018 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
24019 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
24021 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
24022 this.isInline = false;
24023 this.isInput = true;
24024 this.component = this.el.select('.add-on', true).first() || false;
24025 this.component = (this.component && this.component.length === 0) ? false : this.component;
24026 this.hasInput = this.component && this.inputEL().length;
24028 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
24030 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
24032 this.picker().on('mousedown', this.onMousedown, this);
24033 this.picker().on('click', this.onClick, this);
24035 this.picker().addClass('datepicker-dropdown');
24037 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
24038 v.setStyle('width', '189px');
24045 if(this.isInline) {
24051 setValue: function(v, suppressEvent)
24053 var o = this.getValue();
24055 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
24059 if(suppressEvent !== true){
24060 this.fireEvent('select', this, o, v);
24065 getValue: function()
24070 onClick: function(e)
24072 e.stopPropagation();
24073 e.preventDefault();
24075 var target = e.getTarget();
24077 if(target.nodeName.toLowerCase() === 'i'){
24078 target = Roo.get(target).dom.parentNode;
24081 var nodeName = target.nodeName;
24082 var className = target.className;
24083 var html = target.innerHTML;
24085 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
24089 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
24091 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
24097 picker : function()
24099 return this.pickerEl;
24102 fillMonths: function()
24105 var months = this.picker().select('>.datepicker-months td', true).first();
24107 months.dom.innerHTML = '';
24113 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
24116 months.createChild(month);
24125 if(typeof(this.vIndex) == 'undefined' && this.value.length){
24126 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
24129 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
24130 e.removeClass('active');
24132 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
24133 e.addClass('active');
24140 if(this.isInline) {
24144 this.picker().removeClass(['bottom', 'top']);
24146 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
24148 * place to the top of element!
24152 this.picker().addClass('top');
24153 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
24158 this.picker().addClass('bottom');
24160 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
24163 onFocus : function()
24165 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
24169 onBlur : function()
24171 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
24173 var d = this.inputEl().getValue();
24182 this.picker().show();
24183 this.picker().select('>.datepicker-months', true).first().show();
24187 this.fireEvent('show', this, this.date);
24192 if(this.isInline) {
24195 this.picker().hide();
24196 this.fireEvent('hide', this, this.date);
24200 onMousedown: function(e)
24202 e.stopPropagation();
24203 e.preventDefault();
24208 Roo.bootstrap.MonthField.superclass.keyup.call(this);
24212 fireKey: function(e)
24214 if (!this.picker().isVisible()){
24215 if (e.keyCode == 27) {// allow escape to hide and re-show picker
24226 e.preventDefault();
24230 dir = e.keyCode == 37 ? -1 : 1;
24232 this.vIndex = this.vIndex + dir;
24234 if(this.vIndex < 0){
24238 if(this.vIndex > 11){
24242 if(isNaN(this.vIndex)){
24246 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
24252 dir = e.keyCode == 38 ? -1 : 1;
24254 this.vIndex = this.vIndex + dir * 4;
24256 if(this.vIndex < 0){
24260 if(this.vIndex > 11){
24264 if(isNaN(this.vIndex)){
24268 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
24273 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
24274 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
24278 e.preventDefault();
24281 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
24282 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
24298 this.picker().remove();
24303 Roo.apply(Roo.bootstrap.MonthField, {
24322 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
24323 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
24328 Roo.apply(Roo.bootstrap.MonthField, {
24332 cls: 'datepicker dropdown-menu roo-dynamic',
24336 cls: 'datepicker-months',
24340 cls: 'table-condensed',
24342 Roo.bootstrap.DateField.content
24362 * @class Roo.bootstrap.CheckBox
24363 * @extends Roo.bootstrap.Input
24364 * Bootstrap CheckBox class
24366 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
24367 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
24368 * @cfg {String} boxLabel The text that appears beside the checkbox
24369 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
24370 * @cfg {Boolean} checked initnal the element
24371 * @cfg {Boolean} inline inline the element (default false)
24372 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
24373 * @cfg {String} tooltip label tooltip
24376 * Create a new CheckBox
24377 * @param {Object} config The config object
24380 Roo.bootstrap.CheckBox = function(config){
24381 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
24386 * Fires when the element is checked or unchecked.
24387 * @param {Roo.bootstrap.CheckBox} this This input
24388 * @param {Boolean} checked The new checked value
24393 * Fires when the element is click.
24394 * @param {Roo.bootstrap.CheckBox} this This input
24401 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
24403 inputType: 'checkbox',
24412 // checkbox success does not make any sense really..
24417 getAutoCreate : function()
24419 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
24425 cfg.cls = 'form-group form-check ' + this.inputType; //input-group
24428 cfg.cls += ' ' + this.inputType + '-inline form-check-inline';
24434 type : this.inputType,
24435 value : this.inputValue,
24436 cls : 'roo-' + this.inputType, //'form-box',
24437 placeholder : this.placeholder || ''
24441 if(this.inputType != 'radio'){
24445 cls : 'roo-hidden-value',
24446 value : this.checked ? this.inputValue : this.valueOff
24451 if (this.weight) { // Validity check?
24452 cfg.cls += " " + this.inputType + "-" + this.weight;
24455 if (this.disabled) {
24456 input.disabled=true;
24460 input.checked = this.checked;
24465 input.name = this.name;
24467 if(this.inputType != 'radio'){
24468 hidden.name = this.name;
24469 input.name = '_hidden_' + this.name;
24474 input.cls += ' input-' + this.size;
24479 ['xs','sm','md','lg'].map(function(size){
24480 if (settings[size]) {
24481 cfg.cls += ' col-' + size + '-' + settings[size];
24485 var inputblock = input;
24487 if (this.before || this.after) {
24490 cls : 'input-group',
24495 inputblock.cn.push({
24497 cls : 'input-group-addon',
24502 inputblock.cn.push(input);
24504 if(this.inputType != 'radio'){
24505 inputblock.cn.push(hidden);
24509 inputblock.cn.push({
24511 cls : 'input-group-addon',
24517 var boxLabelCfg = false;
24523 //'for': id, // box label is handled by onclick - so no for...
24525 html: this.boxLabel
24528 boxLabelCfg.tooltip = this.tooltip;
24534 if (align ==='left' && this.fieldLabel.length) {
24535 // Roo.log("left and has label");
24540 cls : 'control-label',
24541 html : this.fieldLabel
24552 cfg.cn[1].cn.push(boxLabelCfg);
24555 if(this.labelWidth > 12){
24556 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
24559 if(this.labelWidth < 13 && this.labelmd == 0){
24560 this.labelmd = this.labelWidth;
24563 if(this.labellg > 0){
24564 cfg.cn[0].cls += ' col-lg-' + this.labellg;
24565 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
24568 if(this.labelmd > 0){
24569 cfg.cn[0].cls += ' col-md-' + this.labelmd;
24570 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
24573 if(this.labelsm > 0){
24574 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
24575 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
24578 if(this.labelxs > 0){
24579 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
24580 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
24583 } else if ( this.fieldLabel.length) {
24584 // Roo.log(" label");
24588 tag: this.boxLabel ? 'span' : 'label',
24590 cls: 'control-label box-input-label',
24591 //cls : 'input-group-addon',
24592 html : this.fieldLabel
24599 cfg.cn.push(boxLabelCfg);
24604 // Roo.log(" no label && no align");
24605 cfg.cn = [ inputblock ] ;
24607 cfg.cn.push(boxLabelCfg);
24615 if(this.inputType != 'radio'){
24616 cfg.cn.push(hidden);
24624 * return the real input element.
24626 inputEl: function ()
24628 return this.el.select('input.roo-' + this.inputType,true).first();
24630 hiddenEl: function ()
24632 return this.el.select('input.roo-hidden-value',true).first();
24635 labelEl: function()
24637 return this.el.select('label.control-label',true).first();
24639 /* depricated... */
24643 return this.labelEl();
24646 boxLabelEl: function()
24648 return this.el.select('label.box-label',true).first();
24651 initEvents : function()
24653 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
24655 this.inputEl().on('click', this.onClick, this);
24657 if (this.boxLabel) {
24658 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
24661 this.startValue = this.getValue();
24664 Roo.bootstrap.CheckBox.register(this);
24668 onClick : function(e)
24670 if(this.fireEvent('click', this, e) !== false){
24671 this.setChecked(!this.checked);
24676 setChecked : function(state,suppressEvent)
24678 this.startValue = this.getValue();
24680 if(this.inputType == 'radio'){
24682 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
24683 e.dom.checked = false;
24686 this.inputEl().dom.checked = true;
24688 this.inputEl().dom.value = this.inputValue;
24690 if(suppressEvent !== true){
24691 this.fireEvent('check', this, true);
24699 this.checked = state;
24701 this.inputEl().dom.checked = state;
24704 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
24706 if(suppressEvent !== true){
24707 this.fireEvent('check', this, state);
24713 getValue : function()
24715 if(this.inputType == 'radio'){
24716 return this.getGroupValue();
24719 return this.hiddenEl().dom.value;
24723 getGroupValue : function()
24725 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
24729 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
24732 setValue : function(v,suppressEvent)
24734 if(this.inputType == 'radio'){
24735 this.setGroupValue(v, suppressEvent);
24739 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
24744 setGroupValue : function(v, suppressEvent)
24746 this.startValue = this.getValue();
24748 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
24749 e.dom.checked = false;
24751 if(e.dom.value == v){
24752 e.dom.checked = true;
24756 if(suppressEvent !== true){
24757 this.fireEvent('check', this, true);
24765 validate : function()
24767 if(this.getVisibilityEl().hasClass('hidden')){
24773 (this.inputType == 'radio' && this.validateRadio()) ||
24774 (this.inputType == 'checkbox' && this.validateCheckbox())
24780 this.markInvalid();
24784 validateRadio : function()
24786 if(this.getVisibilityEl().hasClass('hidden')){
24790 if(this.allowBlank){
24796 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
24797 if(!e.dom.checked){
24809 validateCheckbox : function()
24812 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
24813 //return (this.getValue() == this.inputValue) ? true : false;
24816 var group = Roo.bootstrap.CheckBox.get(this.groupId);
24824 for(var i in group){
24825 if(group[i].el.isVisible(true)){
24833 for(var i in group){
24838 r = (group[i].getValue() == group[i].inputValue) ? true : false;
24845 * Mark this field as valid
24847 markValid : function()
24851 this.fireEvent('valid', this);
24853 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
24856 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
24863 if(this.inputType == 'radio'){
24864 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
24865 var fg = e.findParent('.form-group', false, true);
24866 if (Roo.bootstrap.version == 3) {
24867 fg.removeClass([_this.invalidClass, _this.validClass]);
24868 fg.addClass(_this.validClass);
24870 fg.removeClass(['is-valid', 'is-invalid']);
24871 fg.addClass('is-valid');
24879 var fg = this.el.findParent('.form-group', false, true);
24880 if (Roo.bootstrap.version == 3) {
24881 fg.removeClass([this.invalidClass, this.validClass]);
24882 fg.addClass(this.validClass);
24884 fg.removeClass(['is-valid', 'is-invalid']);
24885 fg.addClass('is-valid');
24890 var group = Roo.bootstrap.CheckBox.get(this.groupId);
24896 for(var i in group){
24897 var fg = group[i].el.findParent('.form-group', false, true);
24898 if (Roo.bootstrap.version == 3) {
24899 fg.removeClass([this.invalidClass, this.validClass]);
24900 fg.addClass(this.validClass);
24902 fg.removeClass(['is-valid', 'is-invalid']);
24903 fg.addClass('is-valid');
24909 * Mark this field as invalid
24910 * @param {String} msg The validation message
24912 markInvalid : function(msg)
24914 if(this.allowBlank){
24920 this.fireEvent('invalid', this, msg);
24922 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
24925 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
24929 label.markInvalid();
24932 if(this.inputType == 'radio'){
24934 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
24935 var fg = e.findParent('.form-group', false, true);
24936 if (Roo.bootstrap.version == 3) {
24937 fg.removeClass([_this.invalidClass, _this.validClass]);
24938 fg.addClass(_this.invalidClass);
24940 fg.removeClass(['is-invalid', 'is-valid']);
24941 fg.addClass('is-invalid');
24949 var fg = this.el.findParent('.form-group', false, true);
24950 if (Roo.bootstrap.version == 3) {
24951 fg.removeClass([_this.invalidClass, _this.validClass]);
24952 fg.addClass(_this.invalidClass);
24954 fg.removeClass(['is-invalid', 'is-valid']);
24955 fg.addClass('is-invalid');
24960 var group = Roo.bootstrap.CheckBox.get(this.groupId);
24966 for(var i in group){
24967 var fg = group[i].el.findParent('.form-group', false, true);
24968 if (Roo.bootstrap.version == 3) {
24969 fg.removeClass([_this.invalidClass, _this.validClass]);
24970 fg.addClass(_this.invalidClass);
24972 fg.removeClass(['is-invalid', 'is-valid']);
24973 fg.addClass('is-invalid');
24979 clearInvalid : function()
24981 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
24983 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
24985 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
24987 if (label && label.iconEl) {
24988 label.iconEl.removeClass([ label.validClass, label.invalidClass ]);
24989 label.iconEl.removeClass(['is-invalid', 'is-valid']);
24993 disable : function()
24995 if(this.inputType != 'radio'){
24996 Roo.bootstrap.CheckBox.superclass.disable.call(this);
25003 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
25004 _this.getActionEl().addClass(this.disabledClass);
25005 e.dom.disabled = true;
25009 this.disabled = true;
25010 this.fireEvent("disable", this);
25014 enable : function()
25016 if(this.inputType != 'radio'){
25017 Roo.bootstrap.CheckBox.superclass.enable.call(this);
25024 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
25025 _this.getActionEl().removeClass(this.disabledClass);
25026 e.dom.disabled = false;
25030 this.disabled = false;
25031 this.fireEvent("enable", this);
25035 setBoxLabel : function(v)
25040 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
25046 Roo.apply(Roo.bootstrap.CheckBox, {
25051 * register a CheckBox Group
25052 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
25054 register : function(checkbox)
25056 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
25057 this.groups[checkbox.groupId] = {};
25060 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
25064 this.groups[checkbox.groupId][checkbox.name] = checkbox;
25068 * fetch a CheckBox Group based on the group ID
25069 * @param {string} the group ID
25070 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
25072 get: function(groupId) {
25073 if (typeof(this.groups[groupId]) == 'undefined') {
25077 return this.groups[groupId] ;
25090 * @class Roo.bootstrap.Radio
25091 * @extends Roo.bootstrap.Component
25092 * Bootstrap Radio class
25093 * @cfg {String} boxLabel - the label associated
25094 * @cfg {String} value - the value of radio
25097 * Create a new Radio
25098 * @param {Object} config The config object
25100 Roo.bootstrap.Radio = function(config){
25101 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
25105 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
25111 getAutoCreate : function()
25115 cls : 'form-group radio',
25120 html : this.boxLabel
25128 initEvents : function()
25130 this.parent().register(this);
25132 this.el.on('click', this.onClick, this);
25136 onClick : function(e)
25138 if(this.parent().fireEvent('click', this.parent(), this, e) !== false){
25139 this.setChecked(true);
25143 setChecked : function(state, suppressEvent)
25145 this.parent().setValue(this.value, suppressEvent);
25149 setBoxLabel : function(v)
25154 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
25169 * @class Roo.bootstrap.SecurePass
25170 * @extends Roo.bootstrap.Input
25171 * Bootstrap SecurePass class
25175 * Create a new SecurePass
25176 * @param {Object} config The config object
25179 Roo.bootstrap.SecurePass = function (config) {
25180 // these go here, so the translation tool can replace them..
25182 PwdEmpty: "Please type a password, and then retype it to confirm.",
25183 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
25184 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
25185 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
25186 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
25187 FNInPwd: "Your password can't contain your first name. Please type a different password.",
25188 LNInPwd: "Your password can't contain your last name. Please type a different password.",
25189 TooWeak: "Your password is Too Weak."
25191 this.meterLabel = "Password strength:";
25192 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
25193 this.meterClass = [
25194 "roo-password-meter-tooweak",
25195 "roo-password-meter-weak",
25196 "roo-password-meter-medium",
25197 "roo-password-meter-strong",
25198 "roo-password-meter-grey"
25203 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
25206 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
25208 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
25210 * PwdEmpty: "Please type a password, and then retype it to confirm.",
25211 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
25212 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
25213 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
25214 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
25215 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
25216 * LNInPwd: "Your password can't contain your last name. Please type a different password."
25226 * @cfg {String/Object} Label for the strength meter (defaults to
25227 * 'Password strength:')
25232 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
25233 * ['Weak', 'Medium', 'Strong'])
25236 pwdStrengths: false,
25249 initEvents: function ()
25251 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
25253 if (this.el.is('input[type=password]') && Roo.isSafari) {
25254 this.el.on('keydown', this.SafariOnKeyDown, this);
25257 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
25260 onRender: function (ct, position)
25262 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
25263 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
25264 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
25266 this.trigger.createChild({
25271 cls: 'roo-password-meter-grey col-xs-12',
25274 //width: this.meterWidth + 'px'
25278 cls: 'roo-password-meter-text'
25284 if (this.hideTrigger) {
25285 this.trigger.setDisplayed(false);
25287 this.setSize(this.width || '', this.height || '');
25290 onDestroy: function ()
25292 if (this.trigger) {
25293 this.trigger.removeAllListeners();
25294 this.trigger.remove();
25297 this.wrap.remove();
25299 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
25302 checkStrength: function ()
25304 var pwd = this.inputEl().getValue();
25305 if (pwd == this._lastPwd) {
25310 if (this.ClientSideStrongPassword(pwd)) {
25312 } else if (this.ClientSideMediumPassword(pwd)) {
25314 } else if (this.ClientSideWeakPassword(pwd)) {
25320 Roo.log('strength1: ' + strength);
25322 //var pm = this.trigger.child('div/div/div').dom;
25323 var pm = this.trigger.child('div/div');
25324 pm.removeClass(this.meterClass);
25325 pm.addClass(this.meterClass[strength]);
25328 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
25330 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
25332 this._lastPwd = pwd;
25336 Roo.bootstrap.SecurePass.superclass.reset.call(this);
25338 this._lastPwd = '';
25340 var pm = this.trigger.child('div/div');
25341 pm.removeClass(this.meterClass);
25342 pm.addClass('roo-password-meter-grey');
25345 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
25348 this.inputEl().dom.type='password';
25351 validateValue: function (value)
25353 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
25356 if (value.length == 0) {
25357 if (this.allowBlank) {
25358 this.clearInvalid();
25362 this.markInvalid(this.errors.PwdEmpty);
25363 this.errorMsg = this.errors.PwdEmpty;
25371 if (!value.match(/[\x21-\x7e]+/)) {
25372 this.markInvalid(this.errors.PwdBadChar);
25373 this.errorMsg = this.errors.PwdBadChar;
25376 if (value.length < 6) {
25377 this.markInvalid(this.errors.PwdShort);
25378 this.errorMsg = this.errors.PwdShort;
25381 if (value.length > 16) {
25382 this.markInvalid(this.errors.PwdLong);
25383 this.errorMsg = this.errors.PwdLong;
25387 if (this.ClientSideStrongPassword(value)) {
25389 } else if (this.ClientSideMediumPassword(value)) {
25391 } else if (this.ClientSideWeakPassword(value)) {
25398 if (strength < 2) {
25399 //this.markInvalid(this.errors.TooWeak);
25400 this.errorMsg = this.errors.TooWeak;
25405 console.log('strength2: ' + strength);
25407 //var pm = this.trigger.child('div/div/div').dom;
25409 var pm = this.trigger.child('div/div');
25410 pm.removeClass(this.meterClass);
25411 pm.addClass(this.meterClass[strength]);
25413 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
25415 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
25417 this.errorMsg = '';
25421 CharacterSetChecks: function (type)
25424 this.fResult = false;
25427 isctype: function (character, type)
25430 case this.kCapitalLetter:
25431 if (character >= 'A' && character <= 'Z') {
25436 case this.kSmallLetter:
25437 if (character >= 'a' && character <= 'z') {
25443 if (character >= '0' && character <= '9') {
25448 case this.kPunctuation:
25449 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
25460 IsLongEnough: function (pwd, size)
25462 return !(pwd == null || isNaN(size) || pwd.length < size);
25465 SpansEnoughCharacterSets: function (word, nb)
25467 if (!this.IsLongEnough(word, nb))
25472 var characterSetChecks = new Array(
25473 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
25474 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
25477 for (var index = 0; index < word.length; ++index) {
25478 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
25479 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
25480 characterSetChecks[nCharSet].fResult = true;
25487 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
25488 if (characterSetChecks[nCharSet].fResult) {
25493 if (nCharSets < nb) {
25499 ClientSideStrongPassword: function (pwd)
25501 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
25504 ClientSideMediumPassword: function (pwd)
25506 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
25509 ClientSideWeakPassword: function (pwd)
25511 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
25514 })//<script type="text/javascript">
25517 * Based Ext JS Library 1.1.1
25518 * Copyright(c) 2006-2007, Ext JS, LLC.
25524 * @class Roo.HtmlEditorCore
25525 * @extends Roo.Component
25526 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
25528 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
25531 Roo.HtmlEditorCore = function(config){
25534 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
25539 * @event initialize
25540 * Fires when the editor is fully initialized (including the iframe)
25541 * @param {Roo.HtmlEditorCore} this
25546 * Fires when the editor is first receives the focus. Any insertion must wait
25547 * until after this event.
25548 * @param {Roo.HtmlEditorCore} this
25552 * @event beforesync
25553 * Fires before the textarea is updated with content from the editor iframe. Return false
25554 * to cancel the sync.
25555 * @param {Roo.HtmlEditorCore} this
25556 * @param {String} html
25560 * @event beforepush
25561 * Fires before the iframe editor is updated with content from the textarea. Return false
25562 * to cancel the push.
25563 * @param {Roo.HtmlEditorCore} this
25564 * @param {String} html
25569 * Fires when the textarea is updated with content from the editor iframe.
25570 * @param {Roo.HtmlEditorCore} this
25571 * @param {String} html
25576 * Fires when the iframe editor is updated with content from the textarea.
25577 * @param {Roo.HtmlEditorCore} this
25578 * @param {String} html
25583 * @event editorevent
25584 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
25585 * @param {Roo.HtmlEditorCore} this
25591 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
25593 // defaults : white / black...
25594 this.applyBlacklists();
25601 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
25605 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
25611 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
25616 * @cfg {Number} height (in pixels)
25620 * @cfg {Number} width (in pixels)
25625 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
25628 stylesheets: false,
25631 * @cfg {boolean} allowComments - default false - allow comments in HTML source - by default they are stripped - if you are editing email you may need this.
25633 allowComments: false,
25637 // private properties
25638 validationEvent : false,
25640 initialized : false,
25642 sourceEditMode : false,
25643 onFocus : Roo.emptyFn,
25645 hideMode:'offsets',
25649 // blacklist + whitelisted elements..
25656 * Protected method that will not generally be called directly. It
25657 * is called when the editor initializes the iframe with HTML contents. Override this method if you
25658 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
25660 getDocMarkup : function(){
25664 // inherit styels from page...??
25665 if (this.stylesheets === false) {
25667 Roo.get(document.head).select('style').each(function(node) {
25668 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
25671 Roo.get(document.head).select('link').each(function(node) {
25672 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
25675 } else if (!this.stylesheets.length) {
25677 st = '<style type="text/css">' +
25678 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
25681 for (var i in this.stylesheets) {
25682 st += '<link rel="stylesheet" href="' + this.stylesheets[i] +'" type="text/css">';
25687 st += '<style type="text/css">' +
25688 'IMG { cursor: pointer } ' +
25691 var cls = 'roo-htmleditor-body';
25693 if(this.bodyCls.length){
25694 cls += ' ' + this.bodyCls;
25697 return '<html><head>' + st +
25698 //<style type="text/css">' +
25699 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
25701 ' </head><body contenteditable="true" data-enable-grammerly="true" class="' + cls + '"></body></html>';
25705 onRender : function(ct, position)
25708 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
25709 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
25712 this.el.dom.style.border = '0 none';
25713 this.el.dom.setAttribute('tabIndex', -1);
25714 this.el.addClass('x-hidden hide');
25718 if(Roo.isIE){ // fix IE 1px bogus margin
25719 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
25723 this.frameId = Roo.id();
25727 var iframe = this.owner.wrap.createChild({
25729 cls: 'form-control', // bootstrap..
25731 name: this.frameId,
25732 frameBorder : 'no',
25733 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
25738 this.iframe = iframe.dom;
25740 this.assignDocWin();
25742 this.doc.designMode = 'on';
25745 this.doc.write(this.getDocMarkup());
25749 var task = { // must defer to wait for browser to be ready
25751 //console.log("run task?" + this.doc.readyState);
25752 this.assignDocWin();
25753 if(this.doc.body || this.doc.readyState == 'complete'){
25755 this.doc.designMode="on";
25759 Roo.TaskMgr.stop(task);
25760 this.initEditor.defer(10, this);
25767 Roo.TaskMgr.start(task);
25772 onResize : function(w, h)
25774 Roo.log('resize: ' +w + ',' + h );
25775 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
25779 if(typeof w == 'number'){
25781 this.iframe.style.width = w + 'px';
25783 if(typeof h == 'number'){
25785 this.iframe.style.height = h + 'px';
25787 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
25794 * Toggles the editor between standard and source edit mode.
25795 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
25797 toggleSourceEdit : function(sourceEditMode){
25799 this.sourceEditMode = sourceEditMode === true;
25801 if(this.sourceEditMode){
25803 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
25806 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
25807 //this.iframe.className = '';
25810 //this.setSize(this.owner.wrap.getSize());
25811 //this.fireEvent('editmodechange', this, this.sourceEditMode);
25818 * Protected method that will not generally be called directly. If you need/want
25819 * custom HTML cleanup, this is the method you should override.
25820 * @param {String} html The HTML to be cleaned
25821 * return {String} The cleaned HTML
25823 cleanHtml : function(html){
25824 html = String(html);
25825 if(html.length > 5){
25826 if(Roo.isSafari){ // strip safari nonsense
25827 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
25830 if(html == ' '){
25837 * HTML Editor -> Textarea
25838 * Protected method that will not generally be called directly. Syncs the contents
25839 * of the editor iframe with the textarea.
25841 syncValue : function(){
25842 if(this.initialized){
25843 var bd = (this.doc.body || this.doc.documentElement);
25844 //this.cleanUpPaste(); -- this is done else where and causes havoc..
25845 var html = bd.innerHTML;
25847 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
25848 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
25850 html = '<div style="'+m[0]+'">' + html + '</div>';
25853 html = this.cleanHtml(html);
25854 // fix up the special chars.. normaly like back quotes in word...
25855 // however we do not want to do this with chinese..
25856 html = html.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[\u0080-\uFFFF]/g, function(match) {
25858 var cc = match.charCodeAt();
25860 // Get the character value, handling surrogate pairs
25861 if (match.length == 2) {
25862 // It's a surrogate pair, calculate the Unicode code point
25863 var high = match.charCodeAt(0) - 0xD800;
25864 var low = match.charCodeAt(1) - 0xDC00;
25865 cc = (high * 0x400) + low + 0x10000;
25867 (cc >= 0x4E00 && cc < 0xA000 ) ||
25868 (cc >= 0x3400 && cc < 0x4E00 ) ||
25869 (cc >= 0xf900 && cc < 0xfb00 )
25874 // No, use a numeric entity. Here we brazenly (and possibly mistakenly)
25875 return "&#" + cc + ";";
25882 if(this.owner.fireEvent('beforesync', this, html) !== false){
25883 this.el.dom.value = html;
25884 this.owner.fireEvent('sync', this, html);
25890 * Protected method that will not generally be called directly. Pushes the value of the textarea
25891 * into the iframe editor.
25893 pushValue : function(){
25894 if(this.initialized){
25895 var v = this.el.dom.value.trim();
25897 // if(v.length < 1){
25901 if(this.owner.fireEvent('beforepush', this, v) !== false){
25902 var d = (this.doc.body || this.doc.documentElement);
25904 this.cleanUpPaste();
25905 this.el.dom.value = d.innerHTML;
25906 this.owner.fireEvent('push', this, v);
25912 deferFocus : function(){
25913 this.focus.defer(10, this);
25917 focus : function(){
25918 if(this.win && !this.sourceEditMode){
25925 assignDocWin: function()
25927 var iframe = this.iframe;
25930 this.doc = iframe.contentWindow.document;
25931 this.win = iframe.contentWindow;
25933 // if (!Roo.get(this.frameId)) {
25936 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
25937 // this.win = Roo.get(this.frameId).dom.contentWindow;
25939 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
25943 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
25944 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
25949 initEditor : function(){
25950 //console.log("INIT EDITOR");
25951 this.assignDocWin();
25955 this.doc.designMode="on";
25957 this.doc.write(this.getDocMarkup());
25960 var dbody = (this.doc.body || this.doc.documentElement);
25961 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
25962 // this copies styles from the containing element into thsi one..
25963 // not sure why we need all of this..
25964 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
25966 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
25967 //ss['background-attachment'] = 'fixed'; // w3c
25968 dbody.bgProperties = 'fixed'; // ie
25969 //Roo.DomHelper.applyStyles(dbody, ss);
25970 Roo.EventManager.on(this.doc, {
25971 //'mousedown': this.onEditorEvent,
25972 'mouseup': this.onEditorEvent,
25973 'dblclick': this.onEditorEvent,
25974 'click': this.onEditorEvent,
25975 'keyup': this.onEditorEvent,
25980 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
25982 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
25983 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
25985 this.initialized = true;
25987 this.owner.fireEvent('initialize', this);
25992 onDestroy : function(){
25998 //for (var i =0; i < this.toolbars.length;i++) {
25999 // // fixme - ask toolbars for heights?
26000 // this.toolbars[i].onDestroy();
26003 //this.wrap.dom.innerHTML = '';
26004 //this.wrap.remove();
26009 onFirstFocus : function(){
26011 this.assignDocWin();
26014 this.activated = true;
26017 if(Roo.isGecko){ // prevent silly gecko errors
26019 var s = this.win.getSelection();
26020 if(!s.focusNode || s.focusNode.nodeType != 3){
26021 var r = s.getRangeAt(0);
26022 r.selectNodeContents((this.doc.body || this.doc.documentElement));
26027 this.execCmd('useCSS', true);
26028 this.execCmd('styleWithCSS', false);
26031 this.owner.fireEvent('activate', this);
26035 adjustFont: function(btn){
26036 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
26037 //if(Roo.isSafari){ // safari
26040 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
26041 if(Roo.isSafari){ // safari
26042 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
26043 v = (v < 10) ? 10 : v;
26044 v = (v > 48) ? 48 : v;
26045 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
26050 v = Math.max(1, v+adjust);
26052 this.execCmd('FontSize', v );
26055 onEditorEvent : function(e)
26057 this.owner.fireEvent('editorevent', this, e);
26058 // this.updateToolbar();
26059 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
26062 insertTag : function(tg)
26064 // could be a bit smarter... -> wrap the current selected tRoo..
26065 if (tg.toLowerCase() == 'span' ||
26066 tg.toLowerCase() == 'code' ||
26067 tg.toLowerCase() == 'sup' ||
26068 tg.toLowerCase() == 'sub'
26071 range = this.createRange(this.getSelection());
26072 var wrappingNode = this.doc.createElement(tg.toLowerCase());
26073 wrappingNode.appendChild(range.extractContents());
26074 range.insertNode(wrappingNode);
26081 this.execCmd("formatblock", tg);
26085 insertText : function(txt)
26089 var range = this.createRange();
26090 range.deleteContents();
26091 //alert(Sender.getAttribute('label'));
26093 range.insertNode(this.doc.createTextNode(txt));
26099 * Executes a Midas editor command on the editor document and performs necessary focus and
26100 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
26101 * @param {String} cmd The Midas command
26102 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
26104 relayCmd : function(cmd, value){
26106 this.execCmd(cmd, value);
26107 this.owner.fireEvent('editorevent', this);
26108 //this.updateToolbar();
26109 this.owner.deferFocus();
26113 * Executes a Midas editor command directly on the editor document.
26114 * For visual commands, you should use {@link #relayCmd} instead.
26115 * <b>This should only be called after the editor is initialized.</b>
26116 * @param {String} cmd The Midas command
26117 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
26119 execCmd : function(cmd, value){
26120 this.doc.execCommand(cmd, false, value === undefined ? null : value);
26127 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
26129 * @param {String} text | dom node..
26131 insertAtCursor : function(text)
26134 if(!this.activated){
26140 var r = this.doc.selection.createRange();
26151 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
26155 // from jquery ui (MIT licenced)
26157 var win = this.win;
26159 if (win.getSelection && win.getSelection().getRangeAt) {
26160 range = win.getSelection().getRangeAt(0);
26161 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
26162 range.insertNode(node);
26163 } else if (win.document.selection && win.document.selection.createRange) {
26164 // no firefox support
26165 var txt = typeof(text) == 'string' ? text : text.outerHTML;
26166 win.document.selection.createRange().pasteHTML(txt);
26168 // no firefox support
26169 var txt = typeof(text) == 'string' ? text : text.outerHTML;
26170 this.execCmd('InsertHTML', txt);
26179 mozKeyPress : function(e){
26181 var c = e.getCharCode(), cmd;
26184 c = String.fromCharCode(c).toLowerCase();
26198 this.cleanUpPaste.defer(100, this);
26206 e.preventDefault();
26214 fixKeys : function(){ // load time branching for fastest keydown performance
26216 return function(e){
26217 var k = e.getKey(), r;
26220 r = this.doc.selection.createRange();
26223 r.pasteHTML('    ');
26230 r = this.doc.selection.createRange();
26232 var target = r.parentElement();
26233 if(!target || target.tagName.toLowerCase() != 'li'){
26235 r.pasteHTML('<br />');
26241 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
26242 this.cleanUpPaste.defer(100, this);
26248 }else if(Roo.isOpera){
26249 return function(e){
26250 var k = e.getKey();
26254 this.execCmd('InsertHTML','    ');
26257 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
26258 this.cleanUpPaste.defer(100, this);
26263 }else if(Roo.isSafari){
26264 return function(e){
26265 var k = e.getKey();
26269 this.execCmd('InsertText','\t');
26273 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
26274 this.cleanUpPaste.defer(100, this);
26282 getAllAncestors: function()
26284 var p = this.getSelectedNode();
26287 a.push(p); // push blank onto stack..
26288 p = this.getParentElement();
26292 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
26296 a.push(this.doc.body);
26300 lastSelNode : false,
26303 getSelection : function()
26305 this.assignDocWin();
26306 return Roo.isIE ? this.doc.selection : this.win.getSelection();
26309 getSelectedNode: function()
26311 // this may only work on Gecko!!!
26313 // should we cache this!!!!
26318 var range = this.createRange(this.getSelection()).cloneRange();
26321 var parent = range.parentElement();
26323 var testRange = range.duplicate();
26324 testRange.moveToElementText(parent);
26325 if (testRange.inRange(range)) {
26328 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
26331 parent = parent.parentElement;
26336 // is ancestor a text element.
26337 var ac = range.commonAncestorContainer;
26338 if (ac.nodeType == 3) {
26339 ac = ac.parentNode;
26342 var ar = ac.childNodes;
26345 var other_nodes = [];
26346 var has_other_nodes = false;
26347 for (var i=0;i<ar.length;i++) {
26348 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
26351 // fullly contained node.
26353 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
26358 // probably selected..
26359 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
26360 other_nodes.push(ar[i]);
26364 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
26369 has_other_nodes = true;
26371 if (!nodes.length && other_nodes.length) {
26372 nodes= other_nodes;
26374 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
26380 createRange: function(sel)
26382 // this has strange effects when using with
26383 // top toolbar - not sure if it's a great idea.
26384 //this.editor.contentWindow.focus();
26385 if (typeof sel != "undefined") {
26387 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
26389 return this.doc.createRange();
26392 return this.doc.createRange();
26395 getParentElement: function()
26398 this.assignDocWin();
26399 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
26401 var range = this.createRange(sel);
26404 var p = range.commonAncestorContainer;
26405 while (p.nodeType == 3) { // text node
26416 * Range intersection.. the hard stuff...
26420 * [ -- selected range --- ]
26424 * if end is before start or hits it. fail.
26425 * if start is after end or hits it fail.
26427 * if either hits (but other is outside. - then it's not
26433 // @see http://www.thismuchiknow.co.uk/?p=64.
26434 rangeIntersectsNode : function(range, node)
26436 var nodeRange = node.ownerDocument.createRange();
26438 nodeRange.selectNode(node);
26440 nodeRange.selectNodeContents(node);
26443 var rangeStartRange = range.cloneRange();
26444 rangeStartRange.collapse(true);
26446 var rangeEndRange = range.cloneRange();
26447 rangeEndRange.collapse(false);
26449 var nodeStartRange = nodeRange.cloneRange();
26450 nodeStartRange.collapse(true);
26452 var nodeEndRange = nodeRange.cloneRange();
26453 nodeEndRange.collapse(false);
26455 return rangeStartRange.compareBoundaryPoints(
26456 Range.START_TO_START, nodeEndRange) == -1 &&
26457 rangeEndRange.compareBoundaryPoints(
26458 Range.START_TO_START, nodeStartRange) == 1;
26462 rangeCompareNode : function(range, node)
26464 var nodeRange = node.ownerDocument.createRange();
26466 nodeRange.selectNode(node);
26468 nodeRange.selectNodeContents(node);
26472 range.collapse(true);
26474 nodeRange.collapse(true);
26476 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
26477 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
26479 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
26481 var nodeIsBefore = ss == 1;
26482 var nodeIsAfter = ee == -1;
26484 if (nodeIsBefore && nodeIsAfter) {
26487 if (!nodeIsBefore && nodeIsAfter) {
26488 return 1; //right trailed.
26491 if (nodeIsBefore && !nodeIsAfter) {
26492 return 2; // left trailed.
26498 // private? - in a new class?
26499 cleanUpPaste : function()
26501 // cleans up the whole document..
26502 Roo.log('cleanuppaste');
26504 this.cleanUpChildren(this.doc.body);
26505 var clean = this.cleanWordChars(this.doc.body.innerHTML);
26506 if (clean != this.doc.body.innerHTML) {
26507 this.doc.body.innerHTML = clean;
26512 cleanWordChars : function(input) {// change the chars to hex code
26513 var he = Roo.HtmlEditorCore;
26515 var output = input;
26516 Roo.each(he.swapCodes, function(sw) {
26517 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
26519 output = output.replace(swapper, sw[1]);
26526 cleanUpChildren : function (n)
26528 if (!n.childNodes.length) {
26531 for (var i = n.childNodes.length-1; i > -1 ; i--) {
26532 this.cleanUpChild(n.childNodes[i]);
26539 cleanUpChild : function (node)
26542 //console.log(node);
26543 if (node.nodeName == "#text") {
26544 // clean up silly Windows -- stuff?
26547 if (node.nodeName == "#comment") {
26548 if (!this.allowComments) {
26549 node.parentNode.removeChild(node);
26551 // clean up silly Windows -- stuff?
26554 var lcname = node.tagName.toLowerCase();
26555 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
26556 // whitelist of tags..
26558 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
26560 node.parentNode.removeChild(node);
26565 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
26567 // spans with no attributes - just remove them..
26568 if ((!node.attributes || !node.attributes.length) && lcname == 'span') {
26569 remove_keep_children = true;
26572 // remove <a name=....> as rendering on yahoo mailer is borked with this.
26573 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
26575 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
26576 // remove_keep_children = true;
26579 if (remove_keep_children) {
26580 this.cleanUpChildren(node);
26581 // inserts everything just before this node...
26582 while (node.childNodes.length) {
26583 var cn = node.childNodes[0];
26584 node.removeChild(cn);
26585 node.parentNode.insertBefore(cn, node);
26587 node.parentNode.removeChild(node);
26591 if (!node.attributes || !node.attributes.length) {
26596 this.cleanUpChildren(node);
26600 function cleanAttr(n,v)
26603 if (v.match(/^\./) || v.match(/^\//)) {
26606 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/) || v.match(/^ftp:/)) {
26609 if (v.match(/^#/)) {
26612 if (v.match(/^\{/)) { // allow template editing.
26615 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
26616 node.removeAttribute(n);
26620 var cwhite = this.cwhite;
26621 var cblack = this.cblack;
26623 function cleanStyle(n,v)
26625 if (v.match(/expression/)) { //XSS?? should we even bother..
26626 node.removeAttribute(n);
26630 var parts = v.split(/;/);
26633 Roo.each(parts, function(p) {
26634 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
26638 var l = p.split(':').shift().replace(/\s+/g,'');
26639 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
26641 if ( cwhite.length && cblack.indexOf(l) > -1) {
26642 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
26643 //node.removeAttribute(n);
26647 // only allow 'c whitelisted system attributes'
26648 if ( cwhite.length && cwhite.indexOf(l) < 0) {
26649 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
26650 //node.removeAttribute(n);
26660 if (clean.length) {
26661 node.setAttribute(n, clean.join(';'));
26663 node.removeAttribute(n);
26669 for (var i = node.attributes.length-1; i > -1 ; i--) {
26670 var a = node.attributes[i];
26673 if (a.name.toLowerCase().substr(0,2)=='on') {
26674 node.removeAttribute(a.name);
26677 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
26678 node.removeAttribute(a.name);
26681 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
26682 cleanAttr(a.name,a.value); // fixme..
26685 if (a.name == 'style') {
26686 cleanStyle(a.name,a.value);
26689 /// clean up MS crap..
26690 // tecnically this should be a list of valid class'es..
26693 if (a.name == 'class') {
26694 if (a.value.match(/^Mso/)) {
26695 node.removeAttribute('class');
26698 if (a.value.match(/^body$/)) {
26699 node.removeAttribute('class');
26710 this.cleanUpChildren(node);
26716 * Clean up MS wordisms...
26718 cleanWord : function(node)
26721 this.cleanWord(this.doc.body);
26726 node.nodeName == 'SPAN' &&
26727 !node.hasAttributes() &&
26728 node.childNodes.length == 1 &&
26729 node.firstChild.nodeName == "#text"
26731 var textNode = node.firstChild;
26732 node.removeChild(textNode);
26733 if (node.getAttribute('lang') != 'zh-CN') { // do not space pad on chinese characters..
26734 node.parentNode.insertBefore(node.ownerDocument.createTextNode(" "), node);
26736 node.parentNode.insertBefore(textNode, node);
26737 if (node.getAttribute('lang') != 'zh-CN') { // do not space pad on chinese characters..
26738 node.parentNode.insertBefore(node.ownerDocument.createTextNode(" ") , node);
26740 node.parentNode.removeChild(node);
26743 if (node.nodeName == "#text") {
26744 // clean up silly Windows -- stuff?
26747 if (node.nodeName == "#comment") {
26748 node.parentNode.removeChild(node);
26749 // clean up silly Windows -- stuff?
26753 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
26754 node.parentNode.removeChild(node);
26757 //Roo.log(node.tagName);
26758 // remove - but keep children..
26759 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|v:|font)/)) {
26760 //Roo.log('-- removed');
26761 while (node.childNodes.length) {
26762 var cn = node.childNodes[0];
26763 node.removeChild(cn);
26764 node.parentNode.insertBefore(cn, node);
26765 // move node to parent - and clean it..
26766 this.cleanWord(cn);
26768 node.parentNode.removeChild(node);
26769 /// no need to iterate chidlren = it's got none..
26770 //this.iterateChildren(node, this.cleanWord);
26774 if (node.className.length) {
26776 var cn = node.className.split(/\W+/);
26778 Roo.each(cn, function(cls) {
26779 if (cls.match(/Mso[a-zA-Z]+/)) {
26784 node.className = cna.length ? cna.join(' ') : '';
26786 node.removeAttribute("class");
26790 if (node.hasAttribute("lang")) {
26791 node.removeAttribute("lang");
26794 if (node.hasAttribute("style")) {
26796 var styles = node.getAttribute("style").split(";");
26798 Roo.each(styles, function(s) {
26799 if (!s.match(/:/)) {
26802 var kv = s.split(":");
26803 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
26806 // what ever is left... we allow.
26809 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
26810 if (!nstyle.length) {
26811 node.removeAttribute('style');
26814 this.iterateChildren(node, this.cleanWord);
26820 * iterateChildren of a Node, calling fn each time, using this as the scole..
26821 * @param {DomNode} node node to iterate children of.
26822 * @param {Function} fn method of this class to call on each item.
26824 iterateChildren : function(node, fn)
26826 if (!node.childNodes.length) {
26829 for (var i = node.childNodes.length-1; i > -1 ; i--) {
26830 fn.call(this, node.childNodes[i])
26836 * cleanTableWidths.
26838 * Quite often pasting from word etc.. results in tables with column and widths.
26839 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
26842 cleanTableWidths : function(node)
26847 this.cleanTableWidths(this.doc.body);
26852 if (node.nodeName == "#text" || node.nodeName == "#comment") {
26855 Roo.log(node.tagName);
26856 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
26857 this.iterateChildren(node, this.cleanTableWidths);
26860 if (node.hasAttribute('width')) {
26861 node.removeAttribute('width');
26865 if (node.hasAttribute("style")) {
26868 var styles = node.getAttribute("style").split(";");
26870 Roo.each(styles, function(s) {
26871 if (!s.match(/:/)) {
26874 var kv = s.split(":");
26875 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
26878 // what ever is left... we allow.
26881 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
26882 if (!nstyle.length) {
26883 node.removeAttribute('style');
26887 this.iterateChildren(node, this.cleanTableWidths);
26895 domToHTML : function(currentElement, depth, nopadtext) {
26897 depth = depth || 0;
26898 nopadtext = nopadtext || false;
26900 if (!currentElement) {
26901 return this.domToHTML(this.doc.body);
26904 //Roo.log(currentElement);
26906 var allText = false;
26907 var nodeName = currentElement.nodeName;
26908 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
26910 if (nodeName == '#text') {
26912 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
26917 if (nodeName != 'BODY') {
26920 // Prints the node tagName, such as <A>, <IMG>, etc
26923 for(i = 0; i < currentElement.attributes.length;i++) {
26925 var aname = currentElement.attributes.item(i).name;
26926 if (!currentElement.attributes.item(i).value.length) {
26929 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
26932 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
26941 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
26944 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
26949 // Traverse the tree
26951 var currentElementChild = currentElement.childNodes.item(i);
26952 var allText = true;
26953 var innerHTML = '';
26955 while (currentElementChild) {
26956 // Formatting code (indent the tree so it looks nice on the screen)
26957 var nopad = nopadtext;
26958 if (lastnode == 'SPAN') {
26962 if (currentElementChild.nodeName == '#text') {
26963 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
26964 toadd = nopadtext ? toadd : toadd.trim();
26965 if (!nopad && toadd.length > 80) {
26966 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
26968 innerHTML += toadd;
26971 currentElementChild = currentElement.childNodes.item(i);
26977 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
26979 // Recursively traverse the tree structure of the child node
26980 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
26981 lastnode = currentElementChild.nodeName;
26983 currentElementChild=currentElement.childNodes.item(i);
26989 // The remaining code is mostly for formatting the tree
26990 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
26995 ret+= "</"+tagName+">";
27001 applyBlacklists : function()
27003 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
27004 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
27008 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
27009 if (b.indexOf(tag) > -1) {
27012 this.white.push(tag);
27016 Roo.each(w, function(tag) {
27017 if (b.indexOf(tag) > -1) {
27020 if (this.white.indexOf(tag) > -1) {
27023 this.white.push(tag);
27028 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
27029 if (w.indexOf(tag) > -1) {
27032 this.black.push(tag);
27036 Roo.each(b, function(tag) {
27037 if (w.indexOf(tag) > -1) {
27040 if (this.black.indexOf(tag) > -1) {
27043 this.black.push(tag);
27048 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
27049 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
27053 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
27054 if (b.indexOf(tag) > -1) {
27057 this.cwhite.push(tag);
27061 Roo.each(w, function(tag) {
27062 if (b.indexOf(tag) > -1) {
27065 if (this.cwhite.indexOf(tag) > -1) {
27068 this.cwhite.push(tag);
27073 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
27074 if (w.indexOf(tag) > -1) {
27077 this.cblack.push(tag);
27081 Roo.each(b, function(tag) {
27082 if (w.indexOf(tag) > -1) {
27085 if (this.cblack.indexOf(tag) > -1) {
27088 this.cblack.push(tag);
27093 setStylesheets : function(stylesheets)
27095 if(typeof(stylesheets) == 'string'){
27096 Roo.get(this.iframe.contentDocument.head).createChild({
27098 rel : 'stylesheet',
27107 Roo.each(stylesheets, function(s) {
27112 Roo.get(_this.iframe.contentDocument.head).createChild({
27114 rel : 'stylesheet',
27123 removeStylesheets : function()
27127 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
27132 setStyle : function(style)
27134 Roo.get(this.iframe.contentDocument.head).createChild({
27143 // hide stuff that is not compatible
27157 * @event specialkey
27161 * @cfg {String} fieldClass @hide
27164 * @cfg {String} focusClass @hide
27167 * @cfg {String} autoCreate @hide
27170 * @cfg {String} inputType @hide
27173 * @cfg {String} invalidClass @hide
27176 * @cfg {String} invalidText @hide
27179 * @cfg {String} msgFx @hide
27182 * @cfg {String} validateOnBlur @hide
27186 Roo.HtmlEditorCore.white = [
27187 'area', 'br', 'img', 'input', 'hr', 'wbr',
27189 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
27190 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
27191 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
27192 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
27193 'table', 'ul', 'xmp',
27195 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
27198 'dir', 'menu', 'ol', 'ul', 'dl',
27204 Roo.HtmlEditorCore.black = [
27205 // 'embed', 'object', // enable - backend responsiblity to clean thiese
27207 'base', 'basefont', 'bgsound', 'blink', 'body',
27208 'frame', 'frameset', 'head', 'html', 'ilayer',
27209 'iframe', 'layer', 'link', 'meta', 'object',
27210 'script', 'style' ,'title', 'xml' // clean later..
27212 Roo.HtmlEditorCore.clean = [
27213 'script', 'style', 'title', 'xml'
27215 Roo.HtmlEditorCore.remove = [
27220 Roo.HtmlEditorCore.ablack = [
27224 Roo.HtmlEditorCore.aclean = [
27225 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
27229 Roo.HtmlEditorCore.pwhite= [
27230 'http', 'https', 'mailto'
27233 // white listed style attributes.
27234 Roo.HtmlEditorCore.cwhite= [
27235 // 'text-align', /// default is to allow most things..
27241 // black listed style attributes.
27242 Roo.HtmlEditorCore.cblack= [
27243 // 'font-size' -- this can be set by the project
27247 Roo.HtmlEditorCore.swapCodes =[
27248 [ 8211, "–" ],
27249 [ 8212, "—" ],
27266 * @class Roo.bootstrap.HtmlEditor
27267 * @extends Roo.bootstrap.TextArea
27268 * Bootstrap HtmlEditor class
27271 * Create a new HtmlEditor
27272 * @param {Object} config The config object
27275 Roo.bootstrap.HtmlEditor = function(config){
27276 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
27277 if (!this.toolbars) {
27278 this.toolbars = [];
27281 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
27284 * @event initialize
27285 * Fires when the editor is fully initialized (including the iframe)
27286 * @param {HtmlEditor} this
27291 * Fires when the editor is first receives the focus. Any insertion must wait
27292 * until after this event.
27293 * @param {HtmlEditor} this
27297 * @event beforesync
27298 * Fires before the textarea is updated with content from the editor iframe. Return false
27299 * to cancel the sync.
27300 * @param {HtmlEditor} this
27301 * @param {String} html
27305 * @event beforepush
27306 * Fires before the iframe editor is updated with content from the textarea. Return false
27307 * to cancel the push.
27308 * @param {HtmlEditor} this
27309 * @param {String} html
27314 * Fires when the textarea is updated with content from the editor iframe.
27315 * @param {HtmlEditor} this
27316 * @param {String} html
27321 * Fires when the iframe editor is updated with content from the textarea.
27322 * @param {HtmlEditor} this
27323 * @param {String} html
27327 * @event editmodechange
27328 * Fires when the editor switches edit modes
27329 * @param {HtmlEditor} this
27330 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
27332 editmodechange: true,
27334 * @event editorevent
27335 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
27336 * @param {HtmlEditor} this
27340 * @event firstfocus
27341 * Fires when on first focus - needed by toolbars..
27342 * @param {HtmlEditor} this
27347 * Auto save the htmlEditor value as a file into Events
27348 * @param {HtmlEditor} this
27352 * @event savedpreview
27353 * preview the saved version of htmlEditor
27354 * @param {HtmlEditor} this
27361 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
27365 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
27370 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
27375 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
27380 * @cfg {Number} height (in pixels)
27384 * @cfg {Number} width (in pixels)
27389 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
27392 stylesheets: false,
27397 // private properties
27398 validationEvent : false,
27400 initialized : false,
27403 onFocus : Roo.emptyFn,
27405 hideMode:'offsets',
27407 tbContainer : false,
27411 toolbarContainer :function() {
27412 return this.wrap.select('.x-html-editor-tb',true).first();
27416 * Protected method that will not generally be called directly. It
27417 * is called when the editor creates its toolbar. Override this method if you need to
27418 * add custom toolbar buttons.
27419 * @param {HtmlEditor} editor
27421 createToolbar : function(){
27422 Roo.log('renewing');
27423 Roo.log("create toolbars");
27425 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
27426 this.toolbars[0].render(this.toolbarContainer());
27430 // if (!editor.toolbars || !editor.toolbars.length) {
27431 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
27434 // for (var i =0 ; i < editor.toolbars.length;i++) {
27435 // editor.toolbars[i] = Roo.factory(
27436 // typeof(editor.toolbars[i]) == 'string' ?
27437 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
27438 // Roo.bootstrap.HtmlEditor);
27439 // editor.toolbars[i].init(editor);
27445 onRender : function(ct, position)
27447 // Roo.log("Call onRender: " + this.xtype);
27449 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
27451 this.wrap = this.inputEl().wrap({
27452 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
27455 this.editorcore.onRender(ct, position);
27457 if (this.resizable) {
27458 this.resizeEl = new Roo.Resizable(this.wrap, {
27462 minHeight : this.height,
27463 height: this.height,
27464 handles : this.resizable,
27467 resize : function(r, w, h) {
27468 _t.onResize(w,h); // -something
27474 this.createToolbar(this);
27477 if(!this.width && this.resizable){
27478 this.setSize(this.wrap.getSize());
27480 if (this.resizeEl) {
27481 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
27482 // should trigger onReize..
27488 onResize : function(w, h)
27490 Roo.log('resize: ' +w + ',' + h );
27491 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
27495 if(this.inputEl() ){
27496 if(typeof w == 'number'){
27497 var aw = w - this.wrap.getFrameWidth('lr');
27498 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
27501 if(typeof h == 'number'){
27502 var tbh = -11; // fixme it needs to tool bar size!
27503 for (var i =0; i < this.toolbars.length;i++) {
27504 // fixme - ask toolbars for heights?
27505 tbh += this.toolbars[i].el.getHeight();
27506 //if (this.toolbars[i].footer) {
27507 // tbh += this.toolbars[i].footer.el.getHeight();
27515 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
27516 ah -= 5; // knock a few pixes off for look..
27517 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
27521 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
27522 this.editorcore.onResize(ew,eh);
27527 * Toggles the editor between standard and source edit mode.
27528 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
27530 toggleSourceEdit : function(sourceEditMode)
27532 this.editorcore.toggleSourceEdit(sourceEditMode);
27534 if(this.editorcore.sourceEditMode){
27535 Roo.log('editor - showing textarea');
27538 // Roo.log(this.syncValue());
27540 this.inputEl().removeClass(['hide', 'x-hidden']);
27541 this.inputEl().dom.removeAttribute('tabIndex');
27542 this.inputEl().focus();
27544 Roo.log('editor - hiding textarea');
27546 // Roo.log(this.pushValue());
27549 this.inputEl().addClass(['hide', 'x-hidden']);
27550 this.inputEl().dom.setAttribute('tabIndex', -1);
27551 //this.deferFocus();
27554 if(this.resizable){
27555 this.setSize(this.wrap.getSize());
27558 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
27561 // private (for BoxComponent)
27562 adjustSize : Roo.BoxComponent.prototype.adjustSize,
27564 // private (for BoxComponent)
27565 getResizeEl : function(){
27569 // private (for BoxComponent)
27570 getPositionEl : function(){
27575 initEvents : function(){
27576 this.originalValue = this.getValue();
27580 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
27583 // markInvalid : Roo.emptyFn,
27585 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
27588 // clearInvalid : Roo.emptyFn,
27590 setValue : function(v){
27591 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
27592 this.editorcore.pushValue();
27597 deferFocus : function(){
27598 this.focus.defer(10, this);
27602 focus : function(){
27603 this.editorcore.focus();
27609 onDestroy : function(){
27615 for (var i =0; i < this.toolbars.length;i++) {
27616 // fixme - ask toolbars for heights?
27617 this.toolbars[i].onDestroy();
27620 this.wrap.dom.innerHTML = '';
27621 this.wrap.remove();
27626 onFirstFocus : function(){
27627 //Roo.log("onFirstFocus");
27628 this.editorcore.onFirstFocus();
27629 for (var i =0; i < this.toolbars.length;i++) {
27630 this.toolbars[i].onFirstFocus();
27636 syncValue : function()
27638 this.editorcore.syncValue();
27641 pushValue : function()
27643 this.editorcore.pushValue();
27647 // hide stuff that is not compatible
27661 * @event specialkey
27665 * @cfg {String} fieldClass @hide
27668 * @cfg {String} focusClass @hide
27671 * @cfg {String} autoCreate @hide
27674 * @cfg {String} inputType @hide
27678 * @cfg {String} invalidText @hide
27681 * @cfg {String} msgFx @hide
27684 * @cfg {String} validateOnBlur @hide
27693 Roo.namespace('Roo.bootstrap.htmleditor');
27695 * @class Roo.bootstrap.HtmlEditorToolbar1
27701 new Roo.bootstrap.HtmlEditor({
27704 new Roo.bootstrap.HtmlEditorToolbar1({
27705 disable : { fonts: 1 , format: 1, ..., ... , ...],
27711 * @cfg {Object} disable List of elements to disable..
27712 * @cfg {Array} btns List of additional buttons.
27716 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
27719 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
27722 Roo.apply(this, config);
27724 // default disabled, based on 'good practice'..
27725 this.disable = this.disable || {};
27726 Roo.applyIf(this.disable, {
27729 specialElements : true
27731 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
27733 this.editor = config.editor;
27734 this.editorcore = config.editor.editorcore;
27736 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
27738 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
27739 // dont call parent... till later.
27741 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
27746 editorcore : false,
27751 "h1","h2","h3","h4","h5","h6",
27753 "abbr", "acronym", "address", "cite", "samp", "var",
27757 onRender : function(ct, position)
27759 // Roo.log("Call onRender: " + this.xtype);
27761 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
27763 this.el.dom.style.marginBottom = '0';
27765 var editorcore = this.editorcore;
27766 var editor= this.editor;
27769 var btn = function(id,cmd , toggle, handler, html){
27771 var event = toggle ? 'toggle' : 'click';
27776 xns: Roo.bootstrap,
27780 enableToggle:toggle !== false,
27782 pressed : toggle ? false : null,
27785 a.listeners[toggle ? 'toggle' : 'click'] = function() {
27786 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
27792 // var cb_box = function...
27797 xns: Roo.bootstrap,
27802 xns: Roo.bootstrap,
27806 Roo.each(this.formats, function(f) {
27807 style.menu.items.push({
27809 xns: Roo.bootstrap,
27810 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
27815 editorcore.insertTag(this.tagname);
27822 children.push(style);
27824 btn('bold',false,true);
27825 btn('italic',false,true);
27826 btn('align-left', 'justifyleft',true);
27827 btn('align-center', 'justifycenter',true);
27828 btn('align-right' , 'justifyright',true);
27829 btn('link', false, false, function(btn) {
27830 //Roo.log("create link?");
27831 var url = prompt(this.createLinkText, this.defaultLinkValue);
27832 if(url && url != 'http:/'+'/'){
27833 this.editorcore.relayCmd('createlink', url);
27836 btn('list','insertunorderedlist',true);
27837 btn('pencil', false,true, function(btn){
27839 this.toggleSourceEdit(btn.pressed);
27842 if (this.editor.btns.length > 0) {
27843 for (var i = 0; i<this.editor.btns.length; i++) {
27844 children.push(this.editor.btns[i]);
27852 xns: Roo.bootstrap,
27857 xns: Roo.bootstrap,
27862 cog.menu.items.push({
27864 xns: Roo.bootstrap,
27865 html : Clean styles,
27870 editorcore.insertTag(this.tagname);
27879 this.xtype = 'NavSimplebar';
27881 for(var i=0;i< children.length;i++) {
27883 this.buttons.add(this.addxtypeChild(children[i]));
27887 editor.on('editorevent', this.updateToolbar, this);
27889 onBtnClick : function(id)
27891 this.editorcore.relayCmd(id);
27892 this.editorcore.focus();
27896 * Protected method that will not generally be called directly. It triggers
27897 * a toolbar update by reading the markup state of the current selection in the editor.
27899 updateToolbar: function(){
27901 if(!this.editorcore.activated){
27902 this.editor.onFirstFocus(); // is this neeed?
27906 var btns = this.buttons;
27907 var doc = this.editorcore.doc;
27908 btns.get('bold').setActive(doc.queryCommandState('bold'));
27909 btns.get('italic').setActive(doc.queryCommandState('italic'));
27910 //btns.get('underline').setActive(doc.queryCommandState('underline'));
27912 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
27913 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
27914 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
27916 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
27917 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
27920 var ans = this.editorcore.getAllAncestors();
27921 if (this.formatCombo) {
27924 var store = this.formatCombo.store;
27925 this.formatCombo.setValue("");
27926 for (var i =0; i < ans.length;i++) {
27927 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
27929 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
27937 // hides menus... - so this cant be on a menu...
27938 Roo.bootstrap.MenuMgr.hideAll();
27940 Roo.bootstrap.MenuMgr.hideAll();
27941 //this.editorsyncValue();
27943 onFirstFocus: function() {
27944 this.buttons.each(function(item){
27948 toggleSourceEdit : function(sourceEditMode){
27951 if(sourceEditMode){
27952 Roo.log("disabling buttons");
27953 this.buttons.each( function(item){
27954 if(item.cmd != 'pencil'){
27960 Roo.log("enabling buttons");
27961 if(this.editorcore.initialized){
27962 this.buttons.each( function(item){
27968 Roo.log("calling toggole on editor");
27969 // tell the editor that it's been pressed..
27970 this.editor.toggleSourceEdit(sourceEditMode);
27984 * @class Roo.bootstrap.Markdown
27985 * @extends Roo.bootstrap.TextArea
27986 * Bootstrap Showdown editable area
27987 * @cfg {string} content
27990 * Create a new Showdown
27993 Roo.bootstrap.Markdown = function(config){
27994 Roo.bootstrap.Markdown.superclass.constructor.call(this, config);
27998 Roo.extend(Roo.bootstrap.Markdown, Roo.bootstrap.TextArea, {
28002 initEvents : function()
28005 Roo.bootstrap.TextArea.prototype.initEvents.call(this);
28006 this.markdownEl = this.el.createChild({
28007 cls : 'roo-markdown-area'
28009 this.inputEl().addClass('d-none');
28010 if (this.getValue() == '') {
28011 this.markdownEl.dom.innerHTML = String.format('<span class="roo-placeholder">{0}</span>', this.placeholder || '');
28014 this.markdownEl.dom.innerHTML = Roo.Markdown.toHtml(Roo.util.Format.htmlEncode(this.getValue()));
28016 this.markdownEl.on('click', this.toggleTextEdit, this);
28017 this.on('blur', this.toggleTextEdit, this);
28018 this.on('specialkey', this.resizeTextArea, this);
28021 toggleTextEdit : function()
28023 var sh = this.markdownEl.getHeight();
28024 this.inputEl().addClass('d-none');
28025 this.markdownEl.addClass('d-none');
28026 if (!this.editing) {
28028 this.inputEl().setHeight(Math.min(500, Math.max(sh,(this.getValue().split("\n").length+1) * 30)));
28029 this.inputEl().removeClass('d-none');
28030 this.inputEl().focus();
28031 this.editing = true;
28034 // show showdown...
28035 this.updateMarkdown();
28036 this.markdownEl.removeClass('d-none');
28037 this.editing = false;
28040 updateMarkdown : function()
28042 if (this.getValue() == '') {
28043 this.markdownEl.dom.innerHTML = String.format('<span class="roo-placeholder">{0}</span>', this.placeholder || '');
28047 this.markdownEl.dom.innerHTML = Roo.Markdown.toHtml(Roo.util.Format.htmlEncode(this.getValue()));
28050 resizeTextArea: function () {
28053 Roo.log([sh, this.getValue().split("\n").length * 30]);
28054 this.inputEl().setHeight(Math.min(500, Math.max(sh, (this.getValue().split("\n").length +1) * 30)));
28056 setValue : function(val)
28058 Roo.bootstrap.TextArea.prototype.setValue.call(this,val);
28059 if (!this.editing) {
28060 this.updateMarkdown();
28066 if (!this.editing) {
28067 this.toggleTextEdit();
28075 * Ext JS Library 1.1.1
28076 * Copyright(c) 2006-2007, Ext JS, LLC.
28078 * Originally Released Under LGPL - original licence link has changed is not relivant.
28081 * <script type="text/javascript">
28085 * @class Roo.bootstrap.PagingToolbar
28086 * @extends Roo.bootstrap.NavSimplebar
28087 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
28089 * Create a new PagingToolbar
28090 * @param {Object} config The config object
28091 * @param {Roo.data.Store} store
28093 Roo.bootstrap.PagingToolbar = function(config)
28095 // old args format still supported... - xtype is prefered..
28096 // created from xtype...
28098 this.ds = config.dataSource;
28100 if (config.store && !this.ds) {
28101 this.store= Roo.factory(config.store, Roo.data);
28102 this.ds = this.store;
28103 this.ds.xmodule = this.xmodule || false;
28106 this.toolbarItems = [];
28107 if (config.items) {
28108 this.toolbarItems = config.items;
28111 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
28116 this.bind(this.ds);
28119 if (Roo.bootstrap.version == 4) {
28120 this.navgroup = new Roo.bootstrap.ButtonGroup({ cls: 'pagination' });
28122 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
28127 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
28129 * @cfg {Roo.data.Store} dataSource
28130 * The underlying data store providing the paged data
28133 * @cfg {String/HTMLElement/Element} container
28134 * container The id or element that will contain the toolbar
28137 * @cfg {Boolean} displayInfo
28138 * True to display the displayMsg (defaults to false)
28141 * @cfg {Number} pageSize
28142 * The number of records to display per page (defaults to 20)
28146 * @cfg {String} displayMsg
28147 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
28149 displayMsg : 'Displaying {0} - {1} of {2}',
28151 * @cfg {String} emptyMsg
28152 * The message to display when no records are found (defaults to "No data to display")
28154 emptyMsg : 'No data to display',
28156 * Customizable piece of the default paging text (defaults to "Page")
28159 beforePageText : "Page",
28161 * Customizable piece of the default paging text (defaults to "of %0")
28164 afterPageText : "of {0}",
28166 * Customizable piece of the default paging text (defaults to "First Page")
28169 firstText : "First Page",
28171 * Customizable piece of the default paging text (defaults to "Previous Page")
28174 prevText : "Previous Page",
28176 * Customizable piece of the default paging text (defaults to "Next Page")
28179 nextText : "Next Page",
28181 * Customizable piece of the default paging text (defaults to "Last Page")
28184 lastText : "Last Page",
28186 * Customizable piece of the default paging text (defaults to "Refresh")
28189 refreshText : "Refresh",
28193 onRender : function(ct, position)
28195 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
28196 this.navgroup.parentId = this.id;
28197 this.navgroup.onRender(this.el, null);
28198 // add the buttons to the navgroup
28200 if(this.displayInfo){
28201 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
28202 this.displayEl = this.el.select('.x-paging-info', true).first();
28203 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
28204 // this.displayEl = navel.el.select('span',true).first();
28210 Roo.each(_this.buttons, function(e){ // this might need to use render????
28211 Roo.factory(e).render(_this.el);
28215 Roo.each(_this.toolbarItems, function(e) {
28216 _this.navgroup.addItem(e);
28220 this.first = this.navgroup.addItem({
28221 tooltip: this.firstText,
28222 cls: "prev btn-outline-secondary",
28223 html : ' <i class="fa fa-step-backward"></i>',
28225 preventDefault: true,
28226 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
28229 this.prev = this.navgroup.addItem({
28230 tooltip: this.prevText,
28231 cls: "prev btn-outline-secondary",
28232 html : ' <i class="fa fa-backward"></i>',
28234 preventDefault: true,
28235 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
28237 //this.addSeparator();
28240 var field = this.navgroup.addItem( {
28242 cls : 'x-paging-position btn-outline-secondary',
28244 html : this.beforePageText +
28245 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
28246 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
28249 this.field = field.el.select('input', true).first();
28250 this.field.on("keydown", this.onPagingKeydown, this);
28251 this.field.on("focus", function(){this.dom.select();});
28254 this.afterTextEl = field.el.select('.x-paging-after',true).first();
28255 //this.field.setHeight(18);
28256 //this.addSeparator();
28257 this.next = this.navgroup.addItem({
28258 tooltip: this.nextText,
28259 cls: "next btn-outline-secondary",
28260 html : ' <i class="fa fa-forward"></i>',
28262 preventDefault: true,
28263 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
28265 this.last = this.navgroup.addItem({
28266 tooltip: this.lastText,
28267 html : ' <i class="fa fa-step-forward"></i>',
28268 cls: "next btn-outline-secondary",
28270 preventDefault: true,
28271 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
28273 //this.addSeparator();
28274 this.loading = this.navgroup.addItem({
28275 tooltip: this.refreshText,
28276 cls: "btn-outline-secondary",
28277 html : ' <i class="fa fa-refresh"></i>',
28278 preventDefault: true,
28279 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
28285 updateInfo : function(){
28286 if(this.displayEl){
28287 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
28288 var msg = count == 0 ?
28292 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
28294 this.displayEl.update(msg);
28299 onLoad : function(ds, r, o)
28301 this.cursor = o.params && o.params.start ? o.params.start : 0;
28303 var d = this.getPageData(),
28308 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
28309 this.field.dom.value = ap;
28310 this.first.setDisabled(ap == 1);
28311 this.prev.setDisabled(ap == 1);
28312 this.next.setDisabled(ap == ps);
28313 this.last.setDisabled(ap == ps);
28314 this.loading.enable();
28319 getPageData : function(){
28320 var total = this.ds.getTotalCount();
28323 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
28324 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
28329 onLoadError : function(){
28330 this.loading.enable();
28334 onPagingKeydown : function(e){
28335 var k = e.getKey();
28336 var d = this.getPageData();
28338 var v = this.field.dom.value, pageNum;
28339 if(!v || isNaN(pageNum = parseInt(v, 10))){
28340 this.field.dom.value = d.activePage;
28343 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
28344 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
28347 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))
28349 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
28350 this.field.dom.value = pageNum;
28351 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
28354 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
28356 var v = this.field.dom.value, pageNum;
28357 var increment = (e.shiftKey) ? 10 : 1;
28358 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
28361 if(!v || isNaN(pageNum = parseInt(v, 10))) {
28362 this.field.dom.value = d.activePage;
28365 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
28367 this.field.dom.value = parseInt(v, 10) + increment;
28368 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
28369 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
28376 beforeLoad : function(){
28378 this.loading.disable();
28383 onClick : function(which){
28392 ds.load({params:{start: 0, limit: this.pageSize}});
28395 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
28398 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
28401 var total = ds.getTotalCount();
28402 var extra = total % this.pageSize;
28403 var lastStart = extra ? (total - extra) : total-this.pageSize;
28404 ds.load({params:{start: lastStart, limit: this.pageSize}});
28407 ds.load({params:{start: this.cursor, limit: this.pageSize}});
28413 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
28414 * @param {Roo.data.Store} store The data store to unbind
28416 unbind : function(ds){
28417 ds.un("beforeload", this.beforeLoad, this);
28418 ds.un("load", this.onLoad, this);
28419 ds.un("loadexception", this.onLoadError, this);
28420 ds.un("remove", this.updateInfo, this);
28421 ds.un("add", this.updateInfo, this);
28422 this.ds = undefined;
28426 * Binds the paging toolbar to the specified {@link Roo.data.Store}
28427 * @param {Roo.data.Store} store The data store to bind
28429 bind : function(ds){
28430 ds.on("beforeload", this.beforeLoad, this);
28431 ds.on("load", this.onLoad, this);
28432 ds.on("loadexception", this.onLoadError, this);
28433 ds.on("remove", this.updateInfo, this);
28434 ds.on("add", this.updateInfo, this);
28445 * @class Roo.bootstrap.MessageBar
28446 * @extends Roo.bootstrap.Component
28447 * Bootstrap MessageBar class
28448 * @cfg {String} html contents of the MessageBar
28449 * @cfg {String} weight (info | success | warning | danger) default info
28450 * @cfg {String} beforeClass insert the bar before the given class
28451 * @cfg {Boolean} closable (true | false) default false
28452 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
28455 * Create a new Element
28456 * @param {Object} config The config object
28459 Roo.bootstrap.MessageBar = function(config){
28460 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
28463 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
28469 beforeClass: 'bootstrap-sticky-wrap',
28471 getAutoCreate : function(){
28475 cls: 'alert alert-dismissable alert-' + this.weight,
28480 html: this.html || ''
28486 cfg.cls += ' alert-messages-fixed';
28500 onRender : function(ct, position)
28502 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
28505 var cfg = Roo.apply({}, this.getAutoCreate());
28509 cfg.cls += ' ' + this.cls;
28512 cfg.style = this.style;
28514 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
28516 this.el.setVisibilityMode(Roo.Element.DISPLAY);
28519 this.el.select('>button.close').on('click', this.hide, this);
28525 if (!this.rendered) {
28531 this.fireEvent('show', this);
28537 if (!this.rendered) {
28543 this.fireEvent('hide', this);
28546 update : function()
28548 // var e = this.el.dom.firstChild;
28550 // if(this.closable){
28551 // e = e.nextSibling;
28554 // e.data = this.html || '';
28556 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
28572 * @class Roo.bootstrap.Graph
28573 * @extends Roo.bootstrap.Component
28574 * Bootstrap Graph class
28578 @cfg {String} graphtype bar | vbar | pie
28579 @cfg {number} g_x coodinator | centre x (pie)
28580 @cfg {number} g_y coodinator | centre y (pie)
28581 @cfg {number} g_r radius (pie)
28582 @cfg {number} g_height height of the chart (respected by all elements in the set)
28583 @cfg {number} g_width width of the chart (respected by all elements in the set)
28584 @cfg {Object} title The title of the chart
28587 -opts (object) options for the chart
28589 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
28590 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
28592 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.
28593 o stacked (boolean) whether or not to tread values as in a stacked bar chart
28595 o stretch (boolean)
28597 -opts (object) options for the pie
28600 o startAngle (number)
28601 o endAngle (number)
28605 * Create a new Input
28606 * @param {Object} config The config object
28609 Roo.bootstrap.Graph = function(config){
28610 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
28616 * The img click event for the img.
28617 * @param {Roo.EventObject} e
28623 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
28634 //g_colors: this.colors,
28641 getAutoCreate : function(){
28652 onRender : function(ct,position){
28655 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
28657 if (typeof(Raphael) == 'undefined') {
28658 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
28662 this.raphael = Raphael(this.el.dom);
28664 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
28665 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
28666 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
28667 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
28669 r.text(160, 10, "Single Series Chart").attr(txtattr);
28670 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
28671 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
28672 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
28674 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
28675 r.barchart(330, 10, 300, 220, data1);
28676 r.barchart(10, 250, 300, 220, data2, {stacked: true});
28677 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
28680 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
28681 // r.barchart(30, 30, 560, 250, xdata, {
28682 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
28683 // axis : "0 0 1 1",
28684 // axisxlabels : xdata
28685 // //yvalues : cols,
28688 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
28690 // this.load(null,xdata,{
28691 // axis : "0 0 1 1",
28692 // axisxlabels : xdata
28697 load : function(graphtype,xdata,opts)
28699 this.raphael.clear();
28701 graphtype = this.graphtype;
28706 var r = this.raphael,
28707 fin = function () {
28708 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
28710 fout = function () {
28711 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
28713 pfin = function() {
28714 this.sector.stop();
28715 this.sector.scale(1.1, 1.1, this.cx, this.cy);
28718 this.label[0].stop();
28719 this.label[0].attr({ r: 7.5 });
28720 this.label[1].attr({ "font-weight": 800 });
28723 pfout = function() {
28724 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
28727 this.label[0].animate({ r: 5 }, 500, "bounce");
28728 this.label[1].attr({ "font-weight": 400 });
28734 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
28737 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
28740 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
28741 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
28743 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
28750 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
28755 setTitle: function(o)
28760 initEvents: function() {
28763 this.el.on('click', this.onClick, this);
28767 onClick : function(e)
28769 Roo.log('img onclick');
28770 this.fireEvent('click', this, e);
28782 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
28785 * @class Roo.bootstrap.dash.NumberBox
28786 * @extends Roo.bootstrap.Component
28787 * Bootstrap NumberBox class
28788 * @cfg {String} headline Box headline
28789 * @cfg {String} content Box content
28790 * @cfg {String} icon Box icon
28791 * @cfg {String} footer Footer text
28792 * @cfg {String} fhref Footer href
28795 * Create a new NumberBox
28796 * @param {Object} config The config object
28800 Roo.bootstrap.dash.NumberBox = function(config){
28801 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
28805 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
28814 getAutoCreate : function(){
28818 cls : 'small-box ',
28826 cls : 'roo-headline',
28827 html : this.headline
28831 cls : 'roo-content',
28832 html : this.content
28846 cls : 'ion ' + this.icon
28855 cls : 'small-box-footer',
28856 href : this.fhref || '#',
28860 cfg.cn.push(footer);
28867 onRender : function(ct,position){
28868 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
28875 setHeadline: function (value)
28877 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
28880 setFooter: function (value, href)
28882 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
28885 this.el.select('a.small-box-footer',true).first().attr('href', href);
28890 setContent: function (value)
28892 this.el.select('.roo-content',true).first().dom.innerHTML = value;
28895 initEvents: function()
28909 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
28912 * @class Roo.bootstrap.dash.TabBox
28913 * @extends Roo.bootstrap.Component
28914 * Bootstrap TabBox class
28915 * @cfg {String} title Title of the TabBox
28916 * @cfg {String} icon Icon of the TabBox
28917 * @cfg {Boolean} showtabs (true|false) show the tabs default true
28918 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
28921 * Create a new TabBox
28922 * @param {Object} config The config object
28926 Roo.bootstrap.dash.TabBox = function(config){
28927 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
28932 * When a pane is added
28933 * @param {Roo.bootstrap.dash.TabPane} pane
28937 * @event activatepane
28938 * When a pane is activated
28939 * @param {Roo.bootstrap.dash.TabPane} pane
28941 "activatepane" : true
28949 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
28954 tabScrollable : false,
28956 getChildContainer : function()
28958 return this.el.select('.tab-content', true).first();
28961 getAutoCreate : function(){
28965 cls: 'pull-left header',
28973 cls: 'fa ' + this.icon
28979 cls: 'nav nav-tabs pull-right',
28985 if(this.tabScrollable){
28992 cls: 'nav nav-tabs pull-right',
29003 cls: 'nav-tabs-custom',
29008 cls: 'tab-content no-padding',
29016 initEvents : function()
29018 //Roo.log('add add pane handler');
29019 this.on('addpane', this.onAddPane, this);
29022 * Updates the box title
29023 * @param {String} html to set the title to.
29025 setTitle : function(value)
29027 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
29029 onAddPane : function(pane)
29031 this.panes.push(pane);
29032 //Roo.log('addpane');
29034 // tabs are rendere left to right..
29035 if(!this.showtabs){
29039 var ctr = this.el.select('.nav-tabs', true).first();
29042 var existing = ctr.select('.nav-tab',true);
29043 var qty = existing.getCount();;
29046 var tab = ctr.createChild({
29048 cls : 'nav-tab' + (qty ? '' : ' active'),
29056 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
29059 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
29061 pane.el.addClass('active');
29066 onTabClick : function(ev,un,ob,pane)
29068 //Roo.log('tab - prev default');
29069 ev.preventDefault();
29072 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
29073 pane.tab.addClass('active');
29074 //Roo.log(pane.title);
29075 this.getChildContainer().select('.tab-pane',true).removeClass('active');
29076 // technically we should have a deactivate event.. but maybe add later.
29077 // and it should not de-activate the selected tab...
29078 this.fireEvent('activatepane', pane);
29079 pane.el.addClass('active');
29080 pane.fireEvent('activate');
29085 getActivePane : function()
29088 Roo.each(this.panes, function(p) {
29089 if(p.el.hasClass('active')){
29110 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
29112 * @class Roo.bootstrap.TabPane
29113 * @extends Roo.bootstrap.Component
29114 * Bootstrap TabPane class
29115 * @cfg {Boolean} active (false | true) Default false
29116 * @cfg {String} title title of panel
29120 * Create a new TabPane
29121 * @param {Object} config The config object
29124 Roo.bootstrap.dash.TabPane = function(config){
29125 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
29131 * When a pane is activated
29132 * @param {Roo.bootstrap.dash.TabPane} pane
29139 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
29144 // the tabBox that this is attached to.
29147 getAutoCreate : function()
29155 cfg.cls += ' active';
29160 initEvents : function()
29162 //Roo.log('trigger add pane handler');
29163 this.parent().fireEvent('addpane', this)
29167 * Updates the tab title
29168 * @param {String} html to set the title to.
29170 setTitle: function(str)
29176 this.tab.select('a', true).first().dom.innerHTML = str;
29193 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
29196 * @class Roo.bootstrap.menu.Menu
29197 * @extends Roo.bootstrap.Component
29198 * Bootstrap Menu class - container for Menu
29199 * @cfg {String} html Text of the menu
29200 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
29201 * @cfg {String} icon Font awesome icon
29202 * @cfg {String} pos Menu align to (top | bottom) default bottom
29206 * Create a new Menu
29207 * @param {Object} config The config object
29211 Roo.bootstrap.menu.Menu = function(config){
29212 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
29216 * @event beforeshow
29217 * Fires before this menu is displayed
29218 * @param {Roo.bootstrap.menu.Menu} this
29222 * @event beforehide
29223 * Fires before this menu is hidden
29224 * @param {Roo.bootstrap.menu.Menu} this
29229 * Fires after this menu is displayed
29230 * @param {Roo.bootstrap.menu.Menu} this
29235 * Fires after this menu is hidden
29236 * @param {Roo.bootstrap.menu.Menu} this
29241 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
29242 * @param {Roo.bootstrap.menu.Menu} this
29243 * @param {Roo.EventObject} e
29250 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
29254 weight : 'default',
29259 getChildContainer : function() {
29260 if(this.isSubMenu){
29264 return this.el.select('ul.dropdown-menu', true).first();
29267 getAutoCreate : function()
29272 cls : 'roo-menu-text',
29280 cls : 'fa ' + this.icon
29291 cls : 'dropdown-button btn btn-' + this.weight,
29296 cls : 'dropdown-toggle btn btn-' + this.weight,
29306 cls : 'dropdown-menu'
29312 if(this.pos == 'top'){
29313 cfg.cls += ' dropup';
29316 if(this.isSubMenu){
29319 cls : 'dropdown-menu'
29326 onRender : function(ct, position)
29328 this.isSubMenu = ct.hasClass('dropdown-submenu');
29330 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
29333 initEvents : function()
29335 if(this.isSubMenu){
29339 this.hidden = true;
29341 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
29342 this.triggerEl.on('click', this.onTriggerPress, this);
29344 this.buttonEl = this.el.select('button.dropdown-button', true).first();
29345 this.buttonEl.on('click', this.onClick, this);
29351 if(this.isSubMenu){
29355 return this.el.select('ul.dropdown-menu', true).first();
29358 onClick : function(e)
29360 this.fireEvent("click", this, e);
29363 onTriggerPress : function(e)
29365 if (this.isVisible()) {
29372 isVisible : function(){
29373 return !this.hidden;
29378 this.fireEvent("beforeshow", this);
29380 this.hidden = false;
29381 this.el.addClass('open');
29383 Roo.get(document).on("mouseup", this.onMouseUp, this);
29385 this.fireEvent("show", this);
29392 this.fireEvent("beforehide", this);
29394 this.hidden = true;
29395 this.el.removeClass('open');
29397 Roo.get(document).un("mouseup", this.onMouseUp);
29399 this.fireEvent("hide", this);
29402 onMouseUp : function()
29416 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
29419 * @class Roo.bootstrap.menu.Item
29420 * @extends Roo.bootstrap.Component
29421 * Bootstrap MenuItem class
29422 * @cfg {Boolean} submenu (true | false) default false
29423 * @cfg {String} html text of the item
29424 * @cfg {String} href the link
29425 * @cfg {Boolean} disable (true | false) default false
29426 * @cfg {Boolean} preventDefault (true | false) default true
29427 * @cfg {String} icon Font awesome icon
29428 * @cfg {String} pos Submenu align to (left | right) default right
29432 * Create a new Item
29433 * @param {Object} config The config object
29437 Roo.bootstrap.menu.Item = function(config){
29438 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
29442 * Fires when the mouse is hovering over this menu
29443 * @param {Roo.bootstrap.menu.Item} this
29444 * @param {Roo.EventObject} e
29449 * Fires when the mouse exits this menu
29450 * @param {Roo.bootstrap.menu.Item} this
29451 * @param {Roo.EventObject} e
29457 * The raw click event for the entire grid.
29458 * @param {Roo.EventObject} e
29464 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
29469 preventDefault: true,
29474 getAutoCreate : function()
29479 cls : 'roo-menu-item-text',
29487 cls : 'fa ' + this.icon
29496 href : this.href || '#',
29503 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
29507 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
29509 if(this.pos == 'left'){
29510 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
29517 initEvents : function()
29519 this.el.on('mouseover', this.onMouseOver, this);
29520 this.el.on('mouseout', this.onMouseOut, this);
29522 this.el.select('a', true).first().on('click', this.onClick, this);
29526 onClick : function(e)
29528 if(this.preventDefault){
29529 e.preventDefault();
29532 this.fireEvent("click", this, e);
29535 onMouseOver : function(e)
29537 if(this.submenu && this.pos == 'left'){
29538 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
29541 this.fireEvent("mouseover", this, e);
29544 onMouseOut : function(e)
29546 this.fireEvent("mouseout", this, e);
29558 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
29561 * @class Roo.bootstrap.menu.Separator
29562 * @extends Roo.bootstrap.Component
29563 * Bootstrap Separator class
29566 * Create a new Separator
29567 * @param {Object} config The config object
29571 Roo.bootstrap.menu.Separator = function(config){
29572 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
29575 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
29577 getAutoCreate : function(){
29580 cls: 'dropdown-divider divider'
29598 * @class Roo.bootstrap.Tooltip
29599 * Bootstrap Tooltip class
29600 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
29601 * to determine which dom element triggers the tooltip.
29603 * It needs to add support for additional attributes like tooltip-position
29606 * Create a new Toolti
29607 * @param {Object} config The config object
29610 Roo.bootstrap.Tooltip = function(config){
29611 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
29613 this.alignment = Roo.bootstrap.Tooltip.alignment;
29615 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
29616 this.alignment = config.alignment;
29621 Roo.apply(Roo.bootstrap.Tooltip, {
29623 * @function init initialize tooltip monitoring.
29627 currentTip : false,
29628 currentRegion : false,
29634 Roo.get(document).on('mouseover', this.enter ,this);
29635 Roo.get(document).on('mouseout', this.leave, this);
29638 this.currentTip = new Roo.bootstrap.Tooltip();
29641 enter : function(ev)
29643 var dom = ev.getTarget();
29645 //Roo.log(['enter',dom]);
29646 var el = Roo.fly(dom);
29647 if (this.currentEl) {
29649 //Roo.log(this.currentEl);
29650 //Roo.log(this.currentEl.contains(dom));
29651 if (this.currentEl == el) {
29654 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
29660 if (this.currentTip.el) {
29661 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
29665 if(!el || el.dom == document){
29671 if (!el.attr('tooltip')) {
29672 pel = el.findParent("[tooltip]");
29674 bindEl = Roo.get(pel);
29680 // you can not look for children, as if el is the body.. then everythign is the child..
29681 if (!pel && !el.attr('tooltip')) { //
29682 if (!el.select("[tooltip]").elements.length) {
29685 // is the mouse over this child...?
29686 bindEl = el.select("[tooltip]").first();
29687 var xy = ev.getXY();
29688 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
29689 //Roo.log("not in region.");
29692 //Roo.log("child element over..");
29695 this.currentEl = el;
29696 this.currentTip.bind(bindEl);
29697 this.currentRegion = Roo.lib.Region.getRegion(dom);
29698 this.currentTip.enter();
29701 leave : function(ev)
29703 var dom = ev.getTarget();
29704 //Roo.log(['leave',dom]);
29705 if (!this.currentEl) {
29710 if (dom != this.currentEl.dom) {
29713 var xy = ev.getXY();
29714 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
29717 // only activate leave if mouse cursor is outside... bounding box..
29722 if (this.currentTip) {
29723 this.currentTip.leave();
29725 //Roo.log('clear currentEl');
29726 this.currentEl = false;
29731 'left' : ['r-l', [-2,0], 'right'],
29732 'right' : ['l-r', [2,0], 'left'],
29733 'bottom' : ['t-b', [0,2], 'top'],
29734 'top' : [ 'b-t', [0,-2], 'bottom']
29740 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
29745 delay : null, // can be { show : 300 , hide: 500}
29749 hoverState : null, //???
29751 placement : 'bottom',
29755 getAutoCreate : function(){
29762 cls : 'tooltip-arrow arrow'
29765 cls : 'tooltip-inner'
29772 bind : function(el)
29777 initEvents : function()
29779 this.arrowEl = this.el.select('.arrow', true).first();
29780 this.innerEl = this.el.select('.tooltip-inner', true).first();
29783 enter : function () {
29785 if (this.timeout != null) {
29786 clearTimeout(this.timeout);
29789 this.hoverState = 'in';
29790 //Roo.log("enter - show");
29791 if (!this.delay || !this.delay.show) {
29796 this.timeout = setTimeout(function () {
29797 if (_t.hoverState == 'in') {
29800 }, this.delay.show);
29804 clearTimeout(this.timeout);
29806 this.hoverState = 'out';
29807 if (!this.delay || !this.delay.hide) {
29813 this.timeout = setTimeout(function () {
29814 //Roo.log("leave - timeout");
29816 if (_t.hoverState == 'out') {
29818 Roo.bootstrap.Tooltip.currentEl = false;
29823 show : function (msg)
29826 this.render(document.body);
29829 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
29831 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
29833 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
29835 this.el.removeClass(['fade','top','bottom', 'left', 'right','in',
29836 'bs-tooltip-top','bs-tooltip-bottom', 'bs-tooltip-left', 'bs-tooltip-right']);
29838 var placement = typeof this.placement == 'function' ?
29839 this.placement.call(this, this.el, on_el) :
29842 var autoToken = /\s?auto?\s?/i;
29843 var autoPlace = autoToken.test(placement);
29845 placement = placement.replace(autoToken, '') || 'top';
29849 //this.el.setXY([0,0]);
29851 //this.el.dom.style.display='block';
29853 //this.el.appendTo(on_el);
29855 var p = this.getPosition();
29856 var box = this.el.getBox();
29862 var align = this.alignment[placement];
29864 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
29866 if(placement == 'top' || placement == 'bottom'){
29868 placement = 'right';
29871 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
29872 placement = 'left';
29875 var scroll = Roo.select('body', true).first().getScroll();
29877 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
29881 align = this.alignment[placement];
29883 this.arrowEl.setLeft((this.innerEl.getWidth()/2) - 5);
29887 var elems = document.getElementsByTagName('div');
29888 var highest = Number.MIN_SAFE_INTEGER || -(Math.pow(2, 53) - 1);
29889 for (var i = 0; i < elems.length; i++) {
29890 var zindex = Number.parseInt(
29891 document.defaultView.getComputedStyle(elems[i], null).getPropertyValue("z-index"),
29894 if (zindex > highest) {
29901 this.el.dom.style.zIndex = highest;
29903 this.el.alignTo(this.bindEl, align[0],align[1]);
29904 //var arrow = this.el.select('.arrow',true).first();
29905 //arrow.set(align[2],
29907 this.el.addClass(placement);
29908 this.el.addClass("bs-tooltip-"+ placement);
29910 this.el.addClass('in fade show');
29912 this.hoverState = null;
29914 if (this.el.hasClass('fade')) {
29929 //this.el.setXY([0,0]);
29930 this.el.removeClass(['show', 'in']);
29946 * @class Roo.bootstrap.LocationPicker
29947 * @extends Roo.bootstrap.Component
29948 * Bootstrap LocationPicker class
29949 * @cfg {Number} latitude Position when init default 0
29950 * @cfg {Number} longitude Position when init default 0
29951 * @cfg {Number} zoom default 15
29952 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
29953 * @cfg {Boolean} mapTypeControl default false
29954 * @cfg {Boolean} disableDoubleClickZoom default false
29955 * @cfg {Boolean} scrollwheel default true
29956 * @cfg {Boolean} streetViewControl default false
29957 * @cfg {Number} radius default 0
29958 * @cfg {String} locationName
29959 * @cfg {Boolean} draggable default true
29960 * @cfg {Boolean} enableAutocomplete default false
29961 * @cfg {Boolean} enableReverseGeocode default true
29962 * @cfg {String} markerTitle
29965 * Create a new LocationPicker
29966 * @param {Object} config The config object
29970 Roo.bootstrap.LocationPicker = function(config){
29972 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
29977 * Fires when the picker initialized.
29978 * @param {Roo.bootstrap.LocationPicker} this
29979 * @param {Google Location} location
29983 * @event positionchanged
29984 * Fires when the picker position changed.
29985 * @param {Roo.bootstrap.LocationPicker} this
29986 * @param {Google Location} location
29988 positionchanged : true,
29991 * Fires when the map resize.
29992 * @param {Roo.bootstrap.LocationPicker} this
29997 * Fires when the map show.
29998 * @param {Roo.bootstrap.LocationPicker} this
30003 * Fires when the map hide.
30004 * @param {Roo.bootstrap.LocationPicker} this
30009 * Fires when click the map.
30010 * @param {Roo.bootstrap.LocationPicker} this
30011 * @param {Map event} e
30015 * @event mapRightClick
30016 * Fires when right click the map.
30017 * @param {Roo.bootstrap.LocationPicker} this
30018 * @param {Map event} e
30020 mapRightClick : true,
30022 * @event markerClick
30023 * Fires when click the marker.
30024 * @param {Roo.bootstrap.LocationPicker} this
30025 * @param {Map event} e
30027 markerClick : true,
30029 * @event markerRightClick
30030 * Fires when right click the marker.
30031 * @param {Roo.bootstrap.LocationPicker} this
30032 * @param {Map event} e
30034 markerRightClick : true,
30036 * @event OverlayViewDraw
30037 * Fires when OverlayView Draw
30038 * @param {Roo.bootstrap.LocationPicker} this
30040 OverlayViewDraw : true,
30042 * @event OverlayViewOnAdd
30043 * Fires when OverlayView Draw
30044 * @param {Roo.bootstrap.LocationPicker} this
30046 OverlayViewOnAdd : true,
30048 * @event OverlayViewOnRemove
30049 * Fires when OverlayView Draw
30050 * @param {Roo.bootstrap.LocationPicker} this
30052 OverlayViewOnRemove : true,
30054 * @event OverlayViewShow
30055 * Fires when OverlayView Draw
30056 * @param {Roo.bootstrap.LocationPicker} this
30057 * @param {Pixel} cpx
30059 OverlayViewShow : true,
30061 * @event OverlayViewHide
30062 * Fires when OverlayView Draw
30063 * @param {Roo.bootstrap.LocationPicker} this
30065 OverlayViewHide : true,
30067 * @event loadexception
30068 * Fires when load google lib failed.
30069 * @param {Roo.bootstrap.LocationPicker} this
30071 loadexception : true
30076 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
30078 gMapContext: false,
30084 mapTypeControl: false,
30085 disableDoubleClickZoom: false,
30087 streetViewControl: false,
30091 enableAutocomplete: false,
30092 enableReverseGeocode: true,
30095 getAutoCreate: function()
30100 cls: 'roo-location-picker'
30106 initEvents: function(ct, position)
30108 if(!this.el.getWidth() || this.isApplied()){
30112 this.el.setVisibilityMode(Roo.Element.DISPLAY);
30117 initial: function()
30119 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
30120 this.fireEvent('loadexception', this);
30124 if(!this.mapTypeId){
30125 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
30128 this.gMapContext = this.GMapContext();
30130 this.initOverlayView();
30132 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
30136 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
30137 _this.setPosition(_this.gMapContext.marker.position);
30140 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
30141 _this.fireEvent('mapClick', this, event);
30145 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
30146 _this.fireEvent('mapRightClick', this, event);
30150 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
30151 _this.fireEvent('markerClick', this, event);
30155 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
30156 _this.fireEvent('markerRightClick', this, event);
30160 this.setPosition(this.gMapContext.location);
30162 this.fireEvent('initial', this, this.gMapContext.location);
30165 initOverlayView: function()
30169 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
30173 _this.fireEvent('OverlayViewDraw', _this);
30178 _this.fireEvent('OverlayViewOnAdd', _this);
30181 onRemove: function()
30183 _this.fireEvent('OverlayViewOnRemove', _this);
30186 show: function(cpx)
30188 _this.fireEvent('OverlayViewShow', _this, cpx);
30193 _this.fireEvent('OverlayViewHide', _this);
30199 fromLatLngToContainerPixel: function(event)
30201 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
30204 isApplied: function()
30206 return this.getGmapContext() == false ? false : true;
30209 getGmapContext: function()
30211 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
30214 GMapContext: function()
30216 var position = new google.maps.LatLng(this.latitude, this.longitude);
30218 var _map = new google.maps.Map(this.el.dom, {
30221 mapTypeId: this.mapTypeId,
30222 mapTypeControl: this.mapTypeControl,
30223 disableDoubleClickZoom: this.disableDoubleClickZoom,
30224 scrollwheel: this.scrollwheel,
30225 streetViewControl: this.streetViewControl,
30226 locationName: this.locationName,
30227 draggable: this.draggable,
30228 enableAutocomplete: this.enableAutocomplete,
30229 enableReverseGeocode: this.enableReverseGeocode
30232 var _marker = new google.maps.Marker({
30233 position: position,
30235 title: this.markerTitle,
30236 draggable: this.draggable
30243 location: position,
30244 radius: this.radius,
30245 locationName: this.locationName,
30246 addressComponents: {
30247 formatted_address: null,
30248 addressLine1: null,
30249 addressLine2: null,
30251 streetNumber: null,
30255 stateOrProvince: null
30258 domContainer: this.el.dom,
30259 geodecoder: new google.maps.Geocoder()
30263 drawCircle: function(center, radius, options)
30265 if (this.gMapContext.circle != null) {
30266 this.gMapContext.circle.setMap(null);
30270 options = Roo.apply({}, options, {
30271 strokeColor: "#0000FF",
30272 strokeOpacity: .35,
30274 fillColor: "#0000FF",
30278 options.map = this.gMapContext.map;
30279 options.radius = radius;
30280 options.center = center;
30281 this.gMapContext.circle = new google.maps.Circle(options);
30282 return this.gMapContext.circle;
30288 setPosition: function(location)
30290 this.gMapContext.location = location;
30291 this.gMapContext.marker.setPosition(location);
30292 this.gMapContext.map.panTo(location);
30293 this.drawCircle(location, this.gMapContext.radius, {});
30297 if (this.gMapContext.settings.enableReverseGeocode) {
30298 this.gMapContext.geodecoder.geocode({
30299 latLng: this.gMapContext.location
30300 }, function(results, status) {
30302 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
30303 _this.gMapContext.locationName = results[0].formatted_address;
30304 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
30306 _this.fireEvent('positionchanged', this, location);
30313 this.fireEvent('positionchanged', this, location);
30318 google.maps.event.trigger(this.gMapContext.map, "resize");
30320 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
30322 this.fireEvent('resize', this);
30325 setPositionByLatLng: function(latitude, longitude)
30327 this.setPosition(new google.maps.LatLng(latitude, longitude));
30330 getCurrentPosition: function()
30333 latitude: this.gMapContext.location.lat(),
30334 longitude: this.gMapContext.location.lng()
30338 getAddressName: function()
30340 return this.gMapContext.locationName;
30343 getAddressComponents: function()
30345 return this.gMapContext.addressComponents;
30348 address_component_from_google_geocode: function(address_components)
30352 for (var i = 0; i < address_components.length; i++) {
30353 var component = address_components[i];
30354 if (component.types.indexOf("postal_code") >= 0) {
30355 result.postalCode = component.short_name;
30356 } else if (component.types.indexOf("street_number") >= 0) {
30357 result.streetNumber = component.short_name;
30358 } else if (component.types.indexOf("route") >= 0) {
30359 result.streetName = component.short_name;
30360 } else if (component.types.indexOf("neighborhood") >= 0) {
30361 result.city = component.short_name;
30362 } else if (component.types.indexOf("locality") >= 0) {
30363 result.city = component.short_name;
30364 } else if (component.types.indexOf("sublocality") >= 0) {
30365 result.district = component.short_name;
30366 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
30367 result.stateOrProvince = component.short_name;
30368 } else if (component.types.indexOf("country") >= 0) {
30369 result.country = component.short_name;
30373 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
30374 result.addressLine2 = "";
30378 setZoomLevel: function(zoom)
30380 this.gMapContext.map.setZoom(zoom);
30393 this.fireEvent('show', this);
30404 this.fireEvent('hide', this);
30409 Roo.apply(Roo.bootstrap.LocationPicker, {
30411 OverlayView : function(map, options)
30413 options = options || {};
30420 * @class Roo.bootstrap.Alert
30421 * @extends Roo.bootstrap.Component
30422 * Bootstrap Alert class - shows an alert area box
30424 * <div class="alert alert-danger" role="alert"><span class="fa fa-exclamation-triangle"></span><span class="sr-only">Error:</span>
30425 Enter a valid email address
30428 * @cfg {String} title The title of alert
30429 * @cfg {String} html The content of alert
30430 * @cfg {String} weight (success|info|warning|danger) Weight of the message
30431 * @cfg {String} fa font-awesomeicon
30432 * @cfg {Number} seconds default:-1 Number of seconds until it disapears (-1 means never.)
30433 * @cfg {Boolean} close true to show a x closer
30437 * Create a new alert
30438 * @param {Object} config The config object
30442 Roo.bootstrap.Alert = function(config){
30443 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
30447 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
30453 faicon: false, // BC
30457 getAutoCreate : function()
30469 style : this.close ? '' : 'display:none'
30473 cls : 'roo-alert-icon'
30478 cls : 'roo-alert-title',
30483 cls : 'roo-alert-text',
30490 cfg.cn[0].cls += ' fa ' + this.faicon;
30493 cfg.cn[0].cls += ' fa ' + this.fa;
30497 cfg.cls += ' alert-' + this.weight;
30503 initEvents: function()
30505 this.el.setVisibilityMode(Roo.Element.DISPLAY);
30506 this.titleEl = this.el.select('.roo-alert-title',true).first();
30507 this.iconEl = this.el.select('.roo-alert-icon',true).first();
30508 this.htmlEl = this.el.select('.roo-alert-text',true).first();
30509 if (this.seconds > 0) {
30510 this.hide.defer(this.seconds, this);
30514 * Set the Title Message HTML
30515 * @param {String} html
30517 setTitle : function(str)
30519 this.titleEl.dom.innerHTML = str;
30523 * Set the Body Message HTML
30524 * @param {String} html
30526 setHtml : function(str)
30528 this.htmlEl.dom.innerHTML = str;
30531 * Set the Weight of the alert
30532 * @param {String} (success|info|warning|danger) weight
30535 setWeight : function(weight)
30538 this.el.removeClass('alert-' + this.weight);
30541 this.weight = weight;
30543 this.el.addClass('alert-' + this.weight);
30546 * Set the Icon of the alert
30547 * @param {String} see fontawsome names (name without the 'fa-' bit)
30549 setIcon : function(icon)
30552 this.alertEl.removeClass(['fa', 'fa-' + this.faicon]);
30555 this.faicon = icon;
30557 this.alertEl.addClass(['fa', 'fa-' + this.faicon]);
30582 * @class Roo.bootstrap.UploadCropbox
30583 * @extends Roo.bootstrap.Component
30584 * Bootstrap UploadCropbox class
30585 * @cfg {String} emptyText show when image has been loaded
30586 * @cfg {String} rotateNotify show when image too small to rotate
30587 * @cfg {Number} errorTimeout default 3000
30588 * @cfg {Number} minWidth default 300
30589 * @cfg {Number} minHeight default 300
30590 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
30591 * @cfg {Boolean} isDocument (true|false) default false
30592 * @cfg {String} url action url
30593 * @cfg {String} paramName default 'imageUpload'
30594 * @cfg {String} method default POST
30595 * @cfg {Boolean} loadMask (true|false) default true
30596 * @cfg {Boolean} loadingText default 'Loading...'
30599 * Create a new UploadCropbox
30600 * @param {Object} config The config object
30603 Roo.bootstrap.UploadCropbox = function(config){
30604 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
30608 * @event beforeselectfile
30609 * Fire before select file
30610 * @param {Roo.bootstrap.UploadCropbox} this
30612 "beforeselectfile" : true,
30615 * Fire after initEvent
30616 * @param {Roo.bootstrap.UploadCropbox} this
30621 * Fire after initEvent
30622 * @param {Roo.bootstrap.UploadCropbox} this
30623 * @param {String} data
30628 * Fire when preparing the file data
30629 * @param {Roo.bootstrap.UploadCropbox} this
30630 * @param {Object} file
30635 * Fire when get exception
30636 * @param {Roo.bootstrap.UploadCropbox} this
30637 * @param {XMLHttpRequest} xhr
30639 "exception" : true,
30641 * @event beforeloadcanvas
30642 * Fire before load the canvas
30643 * @param {Roo.bootstrap.UploadCropbox} this
30644 * @param {String} src
30646 "beforeloadcanvas" : true,
30649 * Fire when trash image
30650 * @param {Roo.bootstrap.UploadCropbox} this
30655 * Fire when download the image
30656 * @param {Roo.bootstrap.UploadCropbox} this
30660 * @event footerbuttonclick
30661 * Fire when footerbuttonclick
30662 * @param {Roo.bootstrap.UploadCropbox} this
30663 * @param {String} type
30665 "footerbuttonclick" : true,
30669 * @param {Roo.bootstrap.UploadCropbox} this
30674 * Fire when rotate the image
30675 * @param {Roo.bootstrap.UploadCropbox} this
30676 * @param {String} pos
30681 * Fire when inspect the file
30682 * @param {Roo.bootstrap.UploadCropbox} this
30683 * @param {Object} file
30688 * Fire when xhr upload the file
30689 * @param {Roo.bootstrap.UploadCropbox} this
30690 * @param {Object} data
30695 * Fire when arrange the file data
30696 * @param {Roo.bootstrap.UploadCropbox} this
30697 * @param {Object} formData
30702 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
30705 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
30707 emptyText : 'Click to upload image',
30708 rotateNotify : 'Image is too small to rotate',
30709 errorTimeout : 3000,
30723 cropType : 'image/jpeg',
30725 canvasLoaded : false,
30726 isDocument : false,
30728 paramName : 'imageUpload',
30730 loadingText : 'Loading...',
30733 getAutoCreate : function()
30737 cls : 'roo-upload-cropbox',
30741 cls : 'roo-upload-cropbox-selector',
30746 cls : 'roo-upload-cropbox-body',
30747 style : 'cursor:pointer',
30751 cls : 'roo-upload-cropbox-preview'
30755 cls : 'roo-upload-cropbox-thumb'
30759 cls : 'roo-upload-cropbox-empty-notify',
30760 html : this.emptyText
30764 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
30765 html : this.rotateNotify
30771 cls : 'roo-upload-cropbox-footer',
30774 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
30784 onRender : function(ct, position)
30786 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
30788 if (this.buttons.length) {
30790 Roo.each(this.buttons, function(bb) {
30792 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
30794 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
30800 this.maskEl = this.el;
30804 initEvents : function()
30806 this.urlAPI = (window.createObjectURL && window) ||
30807 (window.URL && URL.revokeObjectURL && URL) ||
30808 (window.webkitURL && webkitURL);
30810 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
30811 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30813 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
30814 this.selectorEl.hide();
30816 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
30817 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30819 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
30820 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30821 this.thumbEl.hide();
30823 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
30824 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30826 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
30827 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30828 this.errorEl.hide();
30830 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
30831 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30832 this.footerEl.hide();
30834 this.setThumbBoxSize();
30840 this.fireEvent('initial', this);
30847 window.addEventListener("resize", function() { _this.resize(); } );
30849 this.bodyEl.on('click', this.beforeSelectFile, this);
30852 this.bodyEl.on('touchstart', this.onTouchStart, this);
30853 this.bodyEl.on('touchmove', this.onTouchMove, this);
30854 this.bodyEl.on('touchend', this.onTouchEnd, this);
30858 this.bodyEl.on('mousedown', this.onMouseDown, this);
30859 this.bodyEl.on('mousemove', this.onMouseMove, this);
30860 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
30861 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
30862 Roo.get(document).on('mouseup', this.onMouseUp, this);
30865 this.selectorEl.on('change', this.onFileSelected, this);
30871 this.baseScale = 1;
30873 this.baseRotate = 1;
30874 this.dragable = false;
30875 this.pinching = false;
30878 this.cropData = false;
30879 this.notifyEl.dom.innerHTML = this.emptyText;
30881 this.selectorEl.dom.value = '';
30885 resize : function()
30887 if(this.fireEvent('resize', this) != false){
30888 this.setThumbBoxPosition();
30889 this.setCanvasPosition();
30893 onFooterButtonClick : function(e, el, o, type)
30896 case 'rotate-left' :
30897 this.onRotateLeft(e);
30899 case 'rotate-right' :
30900 this.onRotateRight(e);
30903 this.beforeSelectFile(e);
30918 this.fireEvent('footerbuttonclick', this, type);
30921 beforeSelectFile : function(e)
30923 e.preventDefault();
30925 if(this.fireEvent('beforeselectfile', this) != false){
30926 this.selectorEl.dom.click();
30930 onFileSelected : function(e)
30932 e.preventDefault();
30934 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
30938 var file = this.selectorEl.dom.files[0];
30940 if(this.fireEvent('inspect', this, file) != false){
30941 this.prepare(file);
30946 trash : function(e)
30948 this.fireEvent('trash', this);
30951 download : function(e)
30953 this.fireEvent('download', this);
30956 loadCanvas : function(src)
30958 if(this.fireEvent('beforeloadcanvas', this, src) != false){
30962 this.imageEl = document.createElement('img');
30966 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
30968 this.imageEl.src = src;
30972 onLoadCanvas : function()
30974 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
30975 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
30977 this.bodyEl.un('click', this.beforeSelectFile, this);
30979 this.notifyEl.hide();
30980 this.thumbEl.show();
30981 this.footerEl.show();
30983 this.baseRotateLevel();
30985 if(this.isDocument){
30986 this.setThumbBoxSize();
30989 this.setThumbBoxPosition();
30991 this.baseScaleLevel();
30997 this.canvasLoaded = true;
31000 this.maskEl.unmask();
31005 setCanvasPosition : function()
31007 if(!this.canvasEl){
31011 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
31012 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
31014 this.previewEl.setLeft(pw);
31015 this.previewEl.setTop(ph);
31019 onMouseDown : function(e)
31023 this.dragable = true;
31024 this.pinching = false;
31026 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
31027 this.dragable = false;
31031 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
31032 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
31036 onMouseMove : function(e)
31040 if(!this.canvasLoaded){
31044 if (!this.dragable){
31048 var minX = Math.ceil(this.thumbEl.getLeft(true));
31049 var minY = Math.ceil(this.thumbEl.getTop(true));
31051 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
31052 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
31054 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
31055 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
31057 x = x - this.mouseX;
31058 y = y - this.mouseY;
31060 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
31061 var bgY = Math.ceil(y + this.previewEl.getTop(true));
31063 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
31064 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
31066 this.previewEl.setLeft(bgX);
31067 this.previewEl.setTop(bgY);
31069 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
31070 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
31073 onMouseUp : function(e)
31077 this.dragable = false;
31080 onMouseWheel : function(e)
31084 this.startScale = this.scale;
31086 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
31088 if(!this.zoomable()){
31089 this.scale = this.startScale;
31098 zoomable : function()
31100 var minScale = this.thumbEl.getWidth() / this.minWidth;
31102 if(this.minWidth < this.minHeight){
31103 minScale = this.thumbEl.getHeight() / this.minHeight;
31106 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
31107 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
31111 (this.rotate == 0 || this.rotate == 180) &&
31113 width > this.imageEl.OriginWidth ||
31114 height > this.imageEl.OriginHeight ||
31115 (width < this.minWidth && height < this.minHeight)
31123 (this.rotate == 90 || this.rotate == 270) &&
31125 width > this.imageEl.OriginWidth ||
31126 height > this.imageEl.OriginHeight ||
31127 (width < this.minHeight && height < this.minWidth)
31134 !this.isDocument &&
31135 (this.rotate == 0 || this.rotate == 180) &&
31137 width < this.minWidth ||
31138 width > this.imageEl.OriginWidth ||
31139 height < this.minHeight ||
31140 height > this.imageEl.OriginHeight
31147 !this.isDocument &&
31148 (this.rotate == 90 || this.rotate == 270) &&
31150 width < this.minHeight ||
31151 width > this.imageEl.OriginWidth ||
31152 height < this.minWidth ||
31153 height > this.imageEl.OriginHeight
31163 onRotateLeft : function(e)
31165 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
31167 var minScale = this.thumbEl.getWidth() / this.minWidth;
31169 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
31170 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
31172 this.startScale = this.scale;
31174 while (this.getScaleLevel() < minScale){
31176 this.scale = this.scale + 1;
31178 if(!this.zoomable()){
31183 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
31184 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
31189 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
31196 this.scale = this.startScale;
31198 this.onRotateFail();
31203 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
31205 if(this.isDocument){
31206 this.setThumbBoxSize();
31207 this.setThumbBoxPosition();
31208 this.setCanvasPosition();
31213 this.fireEvent('rotate', this, 'left');
31217 onRotateRight : function(e)
31219 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
31221 var minScale = this.thumbEl.getWidth() / this.minWidth;
31223 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
31224 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
31226 this.startScale = this.scale;
31228 while (this.getScaleLevel() < minScale){
31230 this.scale = this.scale + 1;
31232 if(!this.zoomable()){
31237 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
31238 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
31243 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
31250 this.scale = this.startScale;
31252 this.onRotateFail();
31257 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
31259 if(this.isDocument){
31260 this.setThumbBoxSize();
31261 this.setThumbBoxPosition();
31262 this.setCanvasPosition();
31267 this.fireEvent('rotate', this, 'right');
31270 onRotateFail : function()
31272 this.errorEl.show(true);
31276 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
31281 this.previewEl.dom.innerHTML = '';
31283 var canvasEl = document.createElement("canvas");
31285 var contextEl = canvasEl.getContext("2d");
31287 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
31288 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
31289 var center = this.imageEl.OriginWidth / 2;
31291 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
31292 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
31293 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
31294 center = this.imageEl.OriginHeight / 2;
31297 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
31299 contextEl.translate(center, center);
31300 contextEl.rotate(this.rotate * Math.PI / 180);
31302 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
31304 this.canvasEl = document.createElement("canvas");
31306 this.contextEl = this.canvasEl.getContext("2d");
31308 switch (this.rotate) {
31311 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
31312 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
31314 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
31319 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
31320 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
31322 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
31323 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);
31327 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
31332 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
31333 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
31335 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
31336 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);
31340 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);
31345 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
31346 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
31348 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
31349 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
31353 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);
31360 this.previewEl.appendChild(this.canvasEl);
31362 this.setCanvasPosition();
31367 if(!this.canvasLoaded){
31371 var imageCanvas = document.createElement("canvas");
31373 var imageContext = imageCanvas.getContext("2d");
31375 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
31376 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
31378 var center = imageCanvas.width / 2;
31380 imageContext.translate(center, center);
31382 imageContext.rotate(this.rotate * Math.PI / 180);
31384 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
31386 var canvas = document.createElement("canvas");
31388 var context = canvas.getContext("2d");
31390 canvas.width = this.minWidth;
31391 canvas.height = this.minHeight;
31393 switch (this.rotate) {
31396 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
31397 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
31399 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
31400 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
31402 var targetWidth = this.minWidth - 2 * x;
31403 var targetHeight = this.minHeight - 2 * y;
31407 if((x == 0 && y == 0) || (x == 0 && y > 0)){
31408 scale = targetWidth / width;
31411 if(x > 0 && y == 0){
31412 scale = targetHeight / height;
31415 if(x > 0 && y > 0){
31416 scale = targetWidth / width;
31418 if(width < height){
31419 scale = targetHeight / height;
31423 context.scale(scale, scale);
31425 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
31426 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
31428 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
31429 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
31431 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
31436 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
31437 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
31439 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
31440 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
31442 var targetWidth = this.minWidth - 2 * x;
31443 var targetHeight = this.minHeight - 2 * y;
31447 if((x == 0 && y == 0) || (x == 0 && y > 0)){
31448 scale = targetWidth / width;
31451 if(x > 0 && y == 0){
31452 scale = targetHeight / height;
31455 if(x > 0 && y > 0){
31456 scale = targetWidth / width;
31458 if(width < height){
31459 scale = targetHeight / height;
31463 context.scale(scale, scale);
31465 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
31466 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
31468 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
31469 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
31471 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
31473 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
31478 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
31479 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
31481 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
31482 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
31484 var targetWidth = this.minWidth - 2 * x;
31485 var targetHeight = this.minHeight - 2 * y;
31489 if((x == 0 && y == 0) || (x == 0 && y > 0)){
31490 scale = targetWidth / width;
31493 if(x > 0 && y == 0){
31494 scale = targetHeight / height;
31497 if(x > 0 && y > 0){
31498 scale = targetWidth / width;
31500 if(width < height){
31501 scale = targetHeight / height;
31505 context.scale(scale, scale);
31507 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
31508 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
31510 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
31511 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
31513 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
31514 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
31516 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
31521 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
31522 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
31524 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
31525 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
31527 var targetWidth = this.minWidth - 2 * x;
31528 var targetHeight = this.minHeight - 2 * y;
31532 if((x == 0 && y == 0) || (x == 0 && y > 0)){
31533 scale = targetWidth / width;
31536 if(x > 0 && y == 0){
31537 scale = targetHeight / height;
31540 if(x > 0 && y > 0){
31541 scale = targetWidth / width;
31543 if(width < height){
31544 scale = targetHeight / height;
31548 context.scale(scale, scale);
31550 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
31551 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
31553 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
31554 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
31556 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
31558 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
31565 this.cropData = canvas.toDataURL(this.cropType);
31567 if(this.fireEvent('crop', this, this.cropData) !== false){
31568 this.process(this.file, this.cropData);
31575 setThumbBoxSize : function()
31579 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
31580 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
31581 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
31583 this.minWidth = width;
31584 this.minHeight = height;
31586 if(this.rotate == 90 || this.rotate == 270){
31587 this.minWidth = height;
31588 this.minHeight = width;
31593 width = Math.ceil(this.minWidth * height / this.minHeight);
31595 if(this.minWidth > this.minHeight){
31597 height = Math.ceil(this.minHeight * width / this.minWidth);
31600 this.thumbEl.setStyle({
31601 width : width + 'px',
31602 height : height + 'px'
31609 setThumbBoxPosition : function()
31611 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
31612 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
31614 this.thumbEl.setLeft(x);
31615 this.thumbEl.setTop(y);
31619 baseRotateLevel : function()
31621 this.baseRotate = 1;
31624 typeof(this.exif) != 'undefined' &&
31625 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
31626 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
31628 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
31631 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
31635 baseScaleLevel : function()
31639 if(this.isDocument){
31641 if(this.baseRotate == 6 || this.baseRotate == 8){
31643 height = this.thumbEl.getHeight();
31644 this.baseScale = height / this.imageEl.OriginWidth;
31646 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
31647 width = this.thumbEl.getWidth();
31648 this.baseScale = width / this.imageEl.OriginHeight;
31654 height = this.thumbEl.getHeight();
31655 this.baseScale = height / this.imageEl.OriginHeight;
31657 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
31658 width = this.thumbEl.getWidth();
31659 this.baseScale = width / this.imageEl.OriginWidth;
31665 if(this.baseRotate == 6 || this.baseRotate == 8){
31667 width = this.thumbEl.getHeight();
31668 this.baseScale = width / this.imageEl.OriginHeight;
31670 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
31671 height = this.thumbEl.getWidth();
31672 this.baseScale = height / this.imageEl.OriginHeight;
31675 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
31676 height = this.thumbEl.getWidth();
31677 this.baseScale = height / this.imageEl.OriginHeight;
31679 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
31680 width = this.thumbEl.getHeight();
31681 this.baseScale = width / this.imageEl.OriginWidth;
31688 width = this.thumbEl.getWidth();
31689 this.baseScale = width / this.imageEl.OriginWidth;
31691 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
31692 height = this.thumbEl.getHeight();
31693 this.baseScale = height / this.imageEl.OriginHeight;
31696 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
31698 height = this.thumbEl.getHeight();
31699 this.baseScale = height / this.imageEl.OriginHeight;
31701 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
31702 width = this.thumbEl.getWidth();
31703 this.baseScale = width / this.imageEl.OriginWidth;
31711 getScaleLevel : function()
31713 return this.baseScale * Math.pow(1.1, this.scale);
31716 onTouchStart : function(e)
31718 if(!this.canvasLoaded){
31719 this.beforeSelectFile(e);
31723 var touches = e.browserEvent.touches;
31729 if(touches.length == 1){
31730 this.onMouseDown(e);
31734 if(touches.length != 2){
31740 for(var i = 0, finger; finger = touches[i]; i++){
31741 coords.push(finger.pageX, finger.pageY);
31744 var x = Math.pow(coords[0] - coords[2], 2);
31745 var y = Math.pow(coords[1] - coords[3], 2);
31747 this.startDistance = Math.sqrt(x + y);
31749 this.startScale = this.scale;
31751 this.pinching = true;
31752 this.dragable = false;
31756 onTouchMove : function(e)
31758 if(!this.pinching && !this.dragable){
31762 var touches = e.browserEvent.touches;
31769 this.onMouseMove(e);
31775 for(var i = 0, finger; finger = touches[i]; i++){
31776 coords.push(finger.pageX, finger.pageY);
31779 var x = Math.pow(coords[0] - coords[2], 2);
31780 var y = Math.pow(coords[1] - coords[3], 2);
31782 this.endDistance = Math.sqrt(x + y);
31784 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
31786 if(!this.zoomable()){
31787 this.scale = this.startScale;
31795 onTouchEnd : function(e)
31797 this.pinching = false;
31798 this.dragable = false;
31802 process : function(file, crop)
31805 this.maskEl.mask(this.loadingText);
31808 this.xhr = new XMLHttpRequest();
31810 file.xhr = this.xhr;
31812 this.xhr.open(this.method, this.url, true);
31815 "Accept": "application/json",
31816 "Cache-Control": "no-cache",
31817 "X-Requested-With": "XMLHttpRequest"
31820 for (var headerName in headers) {
31821 var headerValue = headers[headerName];
31823 this.xhr.setRequestHeader(headerName, headerValue);
31829 this.xhr.onload = function()
31831 _this.xhrOnLoad(_this.xhr);
31834 this.xhr.onerror = function()
31836 _this.xhrOnError(_this.xhr);
31839 var formData = new FormData();
31841 formData.append('returnHTML', 'NO');
31844 formData.append('crop', crop);
31847 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
31848 formData.append(this.paramName, file, file.name);
31851 if(typeof(file.filename) != 'undefined'){
31852 formData.append('filename', file.filename);
31855 if(typeof(file.mimetype) != 'undefined'){
31856 formData.append('mimetype', file.mimetype);
31859 if(this.fireEvent('arrange', this, formData) != false){
31860 this.xhr.send(formData);
31864 xhrOnLoad : function(xhr)
31867 this.maskEl.unmask();
31870 if (xhr.readyState !== 4) {
31871 this.fireEvent('exception', this, xhr);
31875 var response = Roo.decode(xhr.responseText);
31877 if(!response.success){
31878 this.fireEvent('exception', this, xhr);
31882 var response = Roo.decode(xhr.responseText);
31884 this.fireEvent('upload', this, response);
31888 xhrOnError : function()
31891 this.maskEl.unmask();
31894 Roo.log('xhr on error');
31896 var response = Roo.decode(xhr.responseText);
31902 prepare : function(file)
31905 this.maskEl.mask(this.loadingText);
31911 if(typeof(file) === 'string'){
31912 this.loadCanvas(file);
31916 if(!file || !this.urlAPI){
31921 this.cropType = file.type;
31925 if(this.fireEvent('prepare', this, this.file) != false){
31927 var reader = new FileReader();
31929 reader.onload = function (e) {
31930 if (e.target.error) {
31931 Roo.log(e.target.error);
31935 var buffer = e.target.result,
31936 dataView = new DataView(buffer),
31938 maxOffset = dataView.byteLength - 4,
31942 if (dataView.getUint16(0) === 0xffd8) {
31943 while (offset < maxOffset) {
31944 markerBytes = dataView.getUint16(offset);
31946 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
31947 markerLength = dataView.getUint16(offset + 2) + 2;
31948 if (offset + markerLength > dataView.byteLength) {
31949 Roo.log('Invalid meta data: Invalid segment size.');
31953 if(markerBytes == 0xffe1){
31954 _this.parseExifData(
31961 offset += markerLength;
31971 var url = _this.urlAPI.createObjectURL(_this.file);
31973 _this.loadCanvas(url);
31978 reader.readAsArrayBuffer(this.file);
31984 parseExifData : function(dataView, offset, length)
31986 var tiffOffset = offset + 10,
31990 if (dataView.getUint32(offset + 4) !== 0x45786966) {
31991 // No Exif data, might be XMP data instead
31995 // Check for the ASCII code for "Exif" (0x45786966):
31996 if (dataView.getUint32(offset + 4) !== 0x45786966) {
31997 // No Exif data, might be XMP data instead
32000 if (tiffOffset + 8 > dataView.byteLength) {
32001 Roo.log('Invalid Exif data: Invalid segment size.');
32004 // Check for the two null bytes:
32005 if (dataView.getUint16(offset + 8) !== 0x0000) {
32006 Roo.log('Invalid Exif data: Missing byte alignment offset.');
32009 // Check the byte alignment:
32010 switch (dataView.getUint16(tiffOffset)) {
32012 littleEndian = true;
32015 littleEndian = false;
32018 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
32021 // Check for the TIFF tag marker (0x002A):
32022 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
32023 Roo.log('Invalid Exif data: Missing TIFF marker.');
32026 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
32027 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
32029 this.parseExifTags(
32032 tiffOffset + dirOffset,
32037 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
32042 if (dirOffset + 6 > dataView.byteLength) {
32043 Roo.log('Invalid Exif data: Invalid directory offset.');
32046 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
32047 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
32048 if (dirEndOffset + 4 > dataView.byteLength) {
32049 Roo.log('Invalid Exif data: Invalid directory size.');
32052 for (i = 0; i < tagsNumber; i += 1) {
32056 dirOffset + 2 + 12 * i, // tag offset
32060 // Return the offset to the next directory:
32061 return dataView.getUint32(dirEndOffset, littleEndian);
32064 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
32066 var tag = dataView.getUint16(offset, littleEndian);
32068 this.exif[tag] = this.getExifValue(
32072 dataView.getUint16(offset + 2, littleEndian), // tag type
32073 dataView.getUint32(offset + 4, littleEndian), // tag length
32078 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
32080 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
32089 Roo.log('Invalid Exif data: Invalid tag type.');
32093 tagSize = tagType.size * length;
32094 // Determine if the value is contained in the dataOffset bytes,
32095 // or if the value at the dataOffset is a pointer to the actual data:
32096 dataOffset = tagSize > 4 ?
32097 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
32098 if (dataOffset + tagSize > dataView.byteLength) {
32099 Roo.log('Invalid Exif data: Invalid data offset.');
32102 if (length === 1) {
32103 return tagType.getValue(dataView, dataOffset, littleEndian);
32106 for (i = 0; i < length; i += 1) {
32107 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
32110 if (tagType.ascii) {
32112 // Concatenate the chars:
32113 for (i = 0; i < values.length; i += 1) {
32115 // Ignore the terminating NULL byte(s):
32116 if (c === '\u0000') {
32128 Roo.apply(Roo.bootstrap.UploadCropbox, {
32130 'Orientation': 0x0112
32134 1: 0, //'top-left',
32136 3: 180, //'bottom-right',
32137 // 4: 'bottom-left',
32139 6: 90, //'right-top',
32140 // 7: 'right-bottom',
32141 8: 270 //'left-bottom'
32145 // byte, 8-bit unsigned int:
32147 getValue: function (dataView, dataOffset) {
32148 return dataView.getUint8(dataOffset);
32152 // ascii, 8-bit byte:
32154 getValue: function (dataView, dataOffset) {
32155 return String.fromCharCode(dataView.getUint8(dataOffset));
32160 // short, 16 bit int:
32162 getValue: function (dataView, dataOffset, littleEndian) {
32163 return dataView.getUint16(dataOffset, littleEndian);
32167 // long, 32 bit int:
32169 getValue: function (dataView, dataOffset, littleEndian) {
32170 return dataView.getUint32(dataOffset, littleEndian);
32174 // rational = two long values, first is numerator, second is denominator:
32176 getValue: function (dataView, dataOffset, littleEndian) {
32177 return dataView.getUint32(dataOffset, littleEndian) /
32178 dataView.getUint32(dataOffset + 4, littleEndian);
32182 // slong, 32 bit signed int:
32184 getValue: function (dataView, dataOffset, littleEndian) {
32185 return dataView.getInt32(dataOffset, littleEndian);
32189 // srational, two slongs, first is numerator, second is denominator:
32191 getValue: function (dataView, dataOffset, littleEndian) {
32192 return dataView.getInt32(dataOffset, littleEndian) /
32193 dataView.getInt32(dataOffset + 4, littleEndian);
32203 cls : 'btn-group roo-upload-cropbox-rotate-left',
32204 action : 'rotate-left',
32208 cls : 'btn btn-default',
32209 html : '<i class="fa fa-undo"></i>'
32215 cls : 'btn-group roo-upload-cropbox-picture',
32216 action : 'picture',
32220 cls : 'btn btn-default',
32221 html : '<i class="fa fa-picture-o"></i>'
32227 cls : 'btn-group roo-upload-cropbox-rotate-right',
32228 action : 'rotate-right',
32232 cls : 'btn btn-default',
32233 html : '<i class="fa fa-repeat"></i>'
32241 cls : 'btn-group roo-upload-cropbox-rotate-left',
32242 action : 'rotate-left',
32246 cls : 'btn btn-default',
32247 html : '<i class="fa fa-undo"></i>'
32253 cls : 'btn-group roo-upload-cropbox-download',
32254 action : 'download',
32258 cls : 'btn btn-default',
32259 html : '<i class="fa fa-download"></i>'
32265 cls : 'btn-group roo-upload-cropbox-crop',
32270 cls : 'btn btn-default',
32271 html : '<i class="fa fa-crop"></i>'
32277 cls : 'btn-group roo-upload-cropbox-trash',
32282 cls : 'btn btn-default',
32283 html : '<i class="fa fa-trash"></i>'
32289 cls : 'btn-group roo-upload-cropbox-rotate-right',
32290 action : 'rotate-right',
32294 cls : 'btn btn-default',
32295 html : '<i class="fa fa-repeat"></i>'
32303 cls : 'btn-group roo-upload-cropbox-rotate-left',
32304 action : 'rotate-left',
32308 cls : 'btn btn-default',
32309 html : '<i class="fa fa-undo"></i>'
32315 cls : 'btn-group roo-upload-cropbox-rotate-right',
32316 action : 'rotate-right',
32320 cls : 'btn btn-default',
32321 html : '<i class="fa fa-repeat"></i>'
32334 * @class Roo.bootstrap.DocumentManager
32335 * @extends Roo.bootstrap.Component
32336 * Bootstrap DocumentManager class
32337 * @cfg {String} paramName default 'imageUpload'
32338 * @cfg {String} toolTipName default 'filename'
32339 * @cfg {String} method default POST
32340 * @cfg {String} url action url
32341 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
32342 * @cfg {Boolean} multiple multiple upload default true
32343 * @cfg {Number} thumbSize default 300
32344 * @cfg {String} fieldLabel
32345 * @cfg {Number} labelWidth default 4
32346 * @cfg {String} labelAlign (left|top) default left
32347 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
32348 * @cfg {Number} labellg set the width of label (1-12)
32349 * @cfg {Number} labelmd set the width of label (1-12)
32350 * @cfg {Number} labelsm set the width of label (1-12)
32351 * @cfg {Number} labelxs set the width of label (1-12)
32354 * Create a new DocumentManager
32355 * @param {Object} config The config object
32358 Roo.bootstrap.DocumentManager = function(config){
32359 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
32362 this.delegates = [];
32367 * Fire when initial the DocumentManager
32368 * @param {Roo.bootstrap.DocumentManager} this
32373 * inspect selected file
32374 * @param {Roo.bootstrap.DocumentManager} this
32375 * @param {File} file
32380 * Fire when xhr load exception
32381 * @param {Roo.bootstrap.DocumentManager} this
32382 * @param {XMLHttpRequest} xhr
32384 "exception" : true,
32386 * @event afterupload
32387 * Fire when xhr load exception
32388 * @param {Roo.bootstrap.DocumentManager} this
32389 * @param {XMLHttpRequest} xhr
32391 "afterupload" : true,
32394 * prepare the form data
32395 * @param {Roo.bootstrap.DocumentManager} this
32396 * @param {Object} formData
32401 * Fire when remove the file
32402 * @param {Roo.bootstrap.DocumentManager} this
32403 * @param {Object} file
32408 * Fire after refresh the file
32409 * @param {Roo.bootstrap.DocumentManager} this
32414 * Fire after click the image
32415 * @param {Roo.bootstrap.DocumentManager} this
32416 * @param {Object} file
32421 * Fire when upload a image and editable set to true
32422 * @param {Roo.bootstrap.DocumentManager} this
32423 * @param {Object} file
32427 * @event beforeselectfile
32428 * Fire before select file
32429 * @param {Roo.bootstrap.DocumentManager} this
32431 "beforeselectfile" : true,
32434 * Fire before process file
32435 * @param {Roo.bootstrap.DocumentManager} this
32436 * @param {Object} file
32440 * @event previewrendered
32441 * Fire when preview rendered
32442 * @param {Roo.bootstrap.DocumentManager} this
32443 * @param {Object} file
32445 "previewrendered" : true,
32448 "previewResize" : true
32453 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
32462 paramName : 'imageUpload',
32463 toolTipName : 'filename',
32466 labelAlign : 'left',
32476 getAutoCreate : function()
32478 var managerWidget = {
32480 cls : 'roo-document-manager',
32484 cls : 'roo-document-manager-selector',
32489 cls : 'roo-document-manager-uploader',
32493 cls : 'roo-document-manager-upload-btn',
32494 html : '<i class="fa fa-plus"></i>'
32505 cls : 'column col-md-12',
32510 if(this.fieldLabel.length){
32515 cls : 'column col-md-12',
32516 html : this.fieldLabel
32520 cls : 'column col-md-12',
32525 if(this.labelAlign == 'left'){
32530 html : this.fieldLabel
32539 if(this.labelWidth > 12){
32540 content[0].style = "width: " + this.labelWidth + 'px';
32543 if(this.labelWidth < 13 && this.labelmd == 0){
32544 this.labelmd = this.labelWidth;
32547 if(this.labellg > 0){
32548 content[0].cls += ' col-lg-' + this.labellg;
32549 content[1].cls += ' col-lg-' + (12 - this.labellg);
32552 if(this.labelmd > 0){
32553 content[0].cls += ' col-md-' + this.labelmd;
32554 content[1].cls += ' col-md-' + (12 - this.labelmd);
32557 if(this.labelsm > 0){
32558 content[0].cls += ' col-sm-' + this.labelsm;
32559 content[1].cls += ' col-sm-' + (12 - this.labelsm);
32562 if(this.labelxs > 0){
32563 content[0].cls += ' col-xs-' + this.labelxs;
32564 content[1].cls += ' col-xs-' + (12 - this.labelxs);
32572 cls : 'row clearfix',
32580 initEvents : function()
32582 this.managerEl = this.el.select('.roo-document-manager', true).first();
32583 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
32585 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
32586 this.selectorEl.hide();
32589 this.selectorEl.attr('multiple', 'multiple');
32592 this.selectorEl.on('change', this.onFileSelected, this);
32594 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
32595 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
32597 this.uploader.on('click', this.onUploaderClick, this);
32599 this.renderProgressDialog();
32603 window.addEventListener("resize", function() { _this.refresh(); } );
32605 this.fireEvent('initial', this);
32608 renderProgressDialog : function()
32612 this.progressDialog = new Roo.bootstrap.Modal({
32613 cls : 'roo-document-manager-progress-dialog',
32614 allow_close : false,
32625 btnclick : function() {
32626 _this.uploadCancel();
32632 this.progressDialog.render(Roo.get(document.body));
32634 this.progress = new Roo.bootstrap.Progress({
32635 cls : 'roo-document-manager-progress',
32640 this.progress.render(this.progressDialog.getChildContainer());
32642 this.progressBar = new Roo.bootstrap.ProgressBar({
32643 cls : 'roo-document-manager-progress-bar',
32646 aria_valuemax : 12,
32650 this.progressBar.render(this.progress.getChildContainer());
32653 onUploaderClick : function(e)
32655 e.preventDefault();
32657 if(this.fireEvent('beforeselectfile', this) != false){
32658 this.selectorEl.dom.click();
32663 onFileSelected : function(e)
32665 e.preventDefault();
32667 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
32671 Roo.each(this.selectorEl.dom.files, function(file){
32672 if(this.fireEvent('inspect', this, file) != false){
32673 this.files.push(file);
32683 this.selectorEl.dom.value = '';
32685 if(!this.files || !this.files.length){
32689 if(this.boxes > 0 && this.files.length > this.boxes){
32690 this.files = this.files.slice(0, this.boxes);
32693 this.uploader.show();
32695 if(this.boxes > 0 && this.files.length > this.boxes - 1){
32696 this.uploader.hide();
32705 Roo.each(this.files, function(file){
32707 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
32708 var f = this.renderPreview(file);
32713 if(file.type.indexOf('image') != -1){
32714 this.delegates.push(
32716 _this.process(file);
32717 }).createDelegate(this)
32725 _this.process(file);
32726 }).createDelegate(this)
32731 this.files = files;
32733 this.delegates = this.delegates.concat(docs);
32735 if(!this.delegates.length){
32740 this.progressBar.aria_valuemax = this.delegates.length;
32747 arrange : function()
32749 if(!this.delegates.length){
32750 this.progressDialog.hide();
32755 var delegate = this.delegates.shift();
32757 this.progressDialog.show();
32759 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
32761 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
32766 refresh : function()
32768 this.uploader.show();
32770 if(this.boxes > 0 && this.files.length > this.boxes - 1){
32771 this.uploader.hide();
32774 Roo.isTouch ? this.closable(false) : this.closable(true);
32776 this.fireEvent('refresh', this);
32779 onRemove : function(e, el, o)
32781 e.preventDefault();
32783 this.fireEvent('remove', this, o);
32787 remove : function(o)
32791 Roo.each(this.files, function(file){
32792 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
32801 this.files = files;
32808 Roo.each(this.files, function(file){
32813 file.target.remove();
32822 onClick : function(e, el, o)
32824 e.preventDefault();
32826 this.fireEvent('click', this, o);
32830 closable : function(closable)
32832 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
32834 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
32846 xhrOnLoad : function(xhr)
32848 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
32852 if (xhr.readyState !== 4) {
32854 this.fireEvent('exception', this, xhr);
32858 var response = Roo.decode(xhr.responseText);
32860 if(!response.success){
32862 this.fireEvent('exception', this, xhr);
32866 var file = this.renderPreview(response.data);
32868 this.files.push(file);
32872 this.fireEvent('afterupload', this, xhr);
32876 xhrOnError : function(xhr)
32878 Roo.log('xhr on error');
32880 var response = Roo.decode(xhr.responseText);
32887 process : function(file)
32889 if(this.fireEvent('process', this, file) !== false){
32890 if(this.editable && file.type.indexOf('image') != -1){
32891 this.fireEvent('edit', this, file);
32895 this.uploadStart(file, false);
32902 uploadStart : function(file, crop)
32904 this.xhr = new XMLHttpRequest();
32906 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
32911 file.xhr = this.xhr;
32913 this.managerEl.createChild({
32915 cls : 'roo-document-manager-loading',
32919 tooltip : file.name,
32920 cls : 'roo-document-manager-thumb',
32921 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
32927 this.xhr.open(this.method, this.url, true);
32930 "Accept": "application/json",
32931 "Cache-Control": "no-cache",
32932 "X-Requested-With": "XMLHttpRequest"
32935 for (var headerName in headers) {
32936 var headerValue = headers[headerName];
32938 this.xhr.setRequestHeader(headerName, headerValue);
32944 this.xhr.onload = function()
32946 _this.xhrOnLoad(_this.xhr);
32949 this.xhr.onerror = function()
32951 _this.xhrOnError(_this.xhr);
32954 var formData = new FormData();
32956 formData.append('returnHTML', 'NO');
32959 formData.append('crop', crop);
32962 formData.append(this.paramName, file, file.name);
32969 if(this.fireEvent('prepare', this, formData, options) != false){
32971 if(options.manually){
32975 this.xhr.send(formData);
32979 this.uploadCancel();
32982 uploadCancel : function()
32988 this.delegates = [];
32990 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
32997 renderPreview : function(file)
32999 if(typeof(file.target) != 'undefined' && file.target){
33003 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
33005 var previewEl = this.managerEl.createChild({
33007 cls : 'roo-document-manager-preview',
33011 tooltip : file[this.toolTipName],
33012 cls : 'roo-document-manager-thumb',
33013 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
33018 html : '<i class="fa fa-times-circle"></i>'
33023 var close = previewEl.select('button.close', true).first();
33025 close.on('click', this.onRemove, this, file);
33027 file.target = previewEl;
33029 var image = previewEl.select('img', true).first();
33033 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
33035 image.on('click', this.onClick, this, file);
33037 this.fireEvent('previewrendered', this, file);
33043 onPreviewLoad : function(file, image)
33045 if(typeof(file.target) == 'undefined' || !file.target){
33049 var width = image.dom.naturalWidth || image.dom.width;
33050 var height = image.dom.naturalHeight || image.dom.height;
33052 if(!this.previewResize) {
33056 if(width > height){
33057 file.target.addClass('wide');
33061 file.target.addClass('tall');
33066 uploadFromSource : function(file, crop)
33068 this.xhr = new XMLHttpRequest();
33070 this.managerEl.createChild({
33072 cls : 'roo-document-manager-loading',
33076 tooltip : file.name,
33077 cls : 'roo-document-manager-thumb',
33078 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
33084 this.xhr.open(this.method, this.url, true);
33087 "Accept": "application/json",
33088 "Cache-Control": "no-cache",
33089 "X-Requested-With": "XMLHttpRequest"
33092 for (var headerName in headers) {
33093 var headerValue = headers[headerName];
33095 this.xhr.setRequestHeader(headerName, headerValue);
33101 this.xhr.onload = function()
33103 _this.xhrOnLoad(_this.xhr);
33106 this.xhr.onerror = function()
33108 _this.xhrOnError(_this.xhr);
33111 var formData = new FormData();
33113 formData.append('returnHTML', 'NO');
33115 formData.append('crop', crop);
33117 if(typeof(file.filename) != 'undefined'){
33118 formData.append('filename', file.filename);
33121 if(typeof(file.mimetype) != 'undefined'){
33122 formData.append('mimetype', file.mimetype);
33127 if(this.fireEvent('prepare', this, formData) != false){
33128 this.xhr.send(formData);
33138 * @class Roo.bootstrap.DocumentViewer
33139 * @extends Roo.bootstrap.Component
33140 * Bootstrap DocumentViewer class
33141 * @cfg {Boolean} showDownload (true|false) show download button (default true)
33142 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
33145 * Create a new DocumentViewer
33146 * @param {Object} config The config object
33149 Roo.bootstrap.DocumentViewer = function(config){
33150 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
33155 * Fire after initEvent
33156 * @param {Roo.bootstrap.DocumentViewer} this
33162 * @param {Roo.bootstrap.DocumentViewer} this
33167 * Fire after download button
33168 * @param {Roo.bootstrap.DocumentViewer} this
33173 * Fire after trash button
33174 * @param {Roo.bootstrap.DocumentViewer} this
33181 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
33183 showDownload : true,
33187 getAutoCreate : function()
33191 cls : 'roo-document-viewer',
33195 cls : 'roo-document-viewer-body',
33199 cls : 'roo-document-viewer-thumb',
33203 cls : 'roo-document-viewer-image'
33211 cls : 'roo-document-viewer-footer',
33214 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
33218 cls : 'btn-group roo-document-viewer-download',
33222 cls : 'btn btn-default',
33223 html : '<i class="fa fa-download"></i>'
33229 cls : 'btn-group roo-document-viewer-trash',
33233 cls : 'btn btn-default',
33234 html : '<i class="fa fa-trash"></i>'
33247 initEvents : function()
33249 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
33250 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
33252 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
33253 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
33255 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
33256 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
33258 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
33259 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
33261 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
33262 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
33264 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
33265 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
33267 this.bodyEl.on('click', this.onClick, this);
33268 this.downloadBtn.on('click', this.onDownload, this);
33269 this.trashBtn.on('click', this.onTrash, this);
33271 this.downloadBtn.hide();
33272 this.trashBtn.hide();
33274 if(this.showDownload){
33275 this.downloadBtn.show();
33278 if(this.showTrash){
33279 this.trashBtn.show();
33282 if(!this.showDownload && !this.showTrash) {
33283 this.footerEl.hide();
33288 initial : function()
33290 this.fireEvent('initial', this);
33294 onClick : function(e)
33296 e.preventDefault();
33298 this.fireEvent('click', this);
33301 onDownload : function(e)
33303 e.preventDefault();
33305 this.fireEvent('download', this);
33308 onTrash : function(e)
33310 e.preventDefault();
33312 this.fireEvent('trash', this);
33324 * @class Roo.bootstrap.NavProgressBar
33325 * @extends Roo.bootstrap.Component
33326 * Bootstrap NavProgressBar class
33329 * Create a new nav progress bar
33330 * @param {Object} config The config object
33333 Roo.bootstrap.NavProgressBar = function(config){
33334 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
33336 this.bullets = this.bullets || [];
33338 // Roo.bootstrap.NavProgressBar.register(this);
33342 * Fires when the active item changes
33343 * @param {Roo.bootstrap.NavProgressBar} this
33344 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
33345 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
33352 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
33357 getAutoCreate : function()
33359 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
33363 cls : 'roo-navigation-bar-group',
33367 cls : 'roo-navigation-top-bar'
33371 cls : 'roo-navigation-bullets-bar',
33375 cls : 'roo-navigation-bar'
33382 cls : 'roo-navigation-bottom-bar'
33392 initEvents: function()
33397 onRender : function(ct, position)
33399 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
33401 if(this.bullets.length){
33402 Roo.each(this.bullets, function(b){
33411 addItem : function(cfg)
33413 var item = new Roo.bootstrap.NavProgressItem(cfg);
33415 item.parentId = this.id;
33416 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
33419 var top = new Roo.bootstrap.Element({
33421 cls : 'roo-navigation-bar-text'
33424 var bottom = new Roo.bootstrap.Element({
33426 cls : 'roo-navigation-bar-text'
33429 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
33430 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
33432 var topText = new Roo.bootstrap.Element({
33434 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
33437 var bottomText = new Roo.bootstrap.Element({
33439 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
33442 topText.onRender(top.el, null);
33443 bottomText.onRender(bottom.el, null);
33446 item.bottomEl = bottom;
33449 this.barItems.push(item);
33454 getActive : function()
33456 var active = false;
33458 Roo.each(this.barItems, function(v){
33460 if (!v.isActive()) {
33472 setActiveItem : function(item)
33476 Roo.each(this.barItems, function(v){
33477 if (v.rid == item.rid) {
33481 if (v.isActive()) {
33482 v.setActive(false);
33487 item.setActive(true);
33489 this.fireEvent('changed', this, item, prev);
33492 getBarItem: function(rid)
33496 Roo.each(this.barItems, function(e) {
33497 if (e.rid != rid) {
33508 indexOfItem : function(item)
33512 Roo.each(this.barItems, function(v, i){
33514 if (v.rid != item.rid) {
33525 setActiveNext : function()
33527 var i = this.indexOfItem(this.getActive());
33529 if (i > this.barItems.length) {
33533 this.setActiveItem(this.barItems[i+1]);
33536 setActivePrev : function()
33538 var i = this.indexOfItem(this.getActive());
33544 this.setActiveItem(this.barItems[i-1]);
33547 format : function()
33549 if(!this.barItems.length){
33553 var width = 100 / this.barItems.length;
33555 Roo.each(this.barItems, function(i){
33556 i.el.setStyle('width', width + '%');
33557 i.topEl.el.setStyle('width', width + '%');
33558 i.bottomEl.el.setStyle('width', width + '%');
33567 * Nav Progress Item
33572 * @class Roo.bootstrap.NavProgressItem
33573 * @extends Roo.bootstrap.Component
33574 * Bootstrap NavProgressItem class
33575 * @cfg {String} rid the reference id
33576 * @cfg {Boolean} active (true|false) Is item active default false
33577 * @cfg {Boolean} disabled (true|false) Is item active default false
33578 * @cfg {String} html
33579 * @cfg {String} position (top|bottom) text position default bottom
33580 * @cfg {String} icon show icon instead of number
33583 * Create a new NavProgressItem
33584 * @param {Object} config The config object
33586 Roo.bootstrap.NavProgressItem = function(config){
33587 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
33592 * The raw click event for the entire grid.
33593 * @param {Roo.bootstrap.NavProgressItem} this
33594 * @param {Roo.EventObject} e
33601 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
33607 position : 'bottom',
33610 getAutoCreate : function()
33612 var iconCls = 'roo-navigation-bar-item-icon';
33614 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
33618 cls: 'roo-navigation-bar-item',
33628 cfg.cls += ' active';
33631 cfg.cls += ' disabled';
33637 disable : function()
33639 this.setDisabled(true);
33642 enable : function()
33644 this.setDisabled(false);
33647 initEvents: function()
33649 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
33651 this.iconEl.on('click', this.onClick, this);
33654 onClick : function(e)
33656 e.preventDefault();
33662 if(this.fireEvent('click', this, e) === false){
33666 this.parent().setActiveItem(this);
33669 isActive: function ()
33671 return this.active;
33674 setActive : function(state)
33676 if(this.active == state){
33680 this.active = state;
33683 this.el.addClass('active');
33687 this.el.removeClass('active');
33692 setDisabled : function(state)
33694 if(this.disabled == state){
33698 this.disabled = state;
33701 this.el.addClass('disabled');
33705 this.el.removeClass('disabled');
33708 tooltipEl : function()
33710 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
33723 * @class Roo.bootstrap.FieldLabel
33724 * @extends Roo.bootstrap.Component
33725 * Bootstrap FieldLabel class
33726 * @cfg {String} html contents of the element
33727 * @cfg {String} tag tag of the element default label
33728 * @cfg {String} cls class of the element
33729 * @cfg {String} target label target
33730 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
33731 * @cfg {String} invalidClass DEPRICATED - BS4 uses is-invalid
33732 * @cfg {String} validClass DEPRICATED - BS4 uses is-valid
33733 * @cfg {String} iconTooltip default "This field is required"
33734 * @cfg {String} indicatorpos (left|right) default left
33737 * Create a new FieldLabel
33738 * @param {Object} config The config object
33741 Roo.bootstrap.FieldLabel = function(config){
33742 Roo.bootstrap.Element.superclass.constructor.call(this, config);
33747 * Fires after the field has been marked as invalid.
33748 * @param {Roo.form.FieldLabel} this
33749 * @param {String} msg The validation message
33754 * Fires after the field has been validated with no errors.
33755 * @param {Roo.form.FieldLabel} this
33761 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
33768 invalidClass : 'has-warning',
33769 validClass : 'has-success',
33770 iconTooltip : 'This field is required',
33771 indicatorpos : 'left',
33773 getAutoCreate : function(){
33776 if (!this.allowBlank) {
33782 cls : 'roo-bootstrap-field-label ' + this.cls,
33787 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star ' + cls,
33788 tooltip : this.iconTooltip
33797 if(this.indicatorpos == 'right'){
33800 cls : 'roo-bootstrap-field-label ' + this.cls,
33809 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star '+ cls,
33810 tooltip : this.iconTooltip
33819 initEvents: function()
33821 Roo.bootstrap.Element.superclass.initEvents.call(this);
33823 this.indicator = this.indicatorEl();
33825 if(this.indicator){
33826 this.indicator.removeClass('visible');
33827 this.indicator.addClass('invisible');
33830 Roo.bootstrap.FieldLabel.register(this);
33833 indicatorEl : function()
33835 var indicator = this.el.select('i.roo-required-indicator',true).first();
33846 * Mark this field as valid
33848 markValid : function()
33850 if(this.indicator){
33851 this.indicator.removeClass('visible');
33852 this.indicator.addClass('invisible');
33854 if (Roo.bootstrap.version == 3) {
33855 this.el.removeClass(this.invalidClass);
33856 this.el.addClass(this.validClass);
33858 this.el.removeClass('is-invalid');
33859 this.el.addClass('is-valid');
33863 this.fireEvent('valid', this);
33867 * Mark this field as invalid
33868 * @param {String} msg The validation message
33870 markInvalid : function(msg)
33872 if(this.indicator){
33873 this.indicator.removeClass('invisible');
33874 this.indicator.addClass('visible');
33876 if (Roo.bootstrap.version == 3) {
33877 this.el.removeClass(this.validClass);
33878 this.el.addClass(this.invalidClass);
33880 this.el.removeClass('is-valid');
33881 this.el.addClass('is-invalid');
33885 this.fireEvent('invalid', this, msg);
33891 Roo.apply(Roo.bootstrap.FieldLabel, {
33896 * register a FieldLabel Group
33897 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
33899 register : function(label)
33901 if(this.groups.hasOwnProperty(label.target)){
33905 this.groups[label.target] = label;
33909 * fetch a FieldLabel Group based on the target
33910 * @param {string} target
33911 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
33913 get: function(target) {
33914 if (typeof(this.groups[target]) == 'undefined') {
33918 return this.groups[target] ;
33927 * page DateSplitField.
33933 * @class Roo.bootstrap.DateSplitField
33934 * @extends Roo.bootstrap.Component
33935 * Bootstrap DateSplitField class
33936 * @cfg {string} fieldLabel - the label associated
33937 * @cfg {Number} labelWidth set the width of label (0-12)
33938 * @cfg {String} labelAlign (top|left)
33939 * @cfg {Boolean} dayAllowBlank (true|false) default false
33940 * @cfg {Boolean} monthAllowBlank (true|false) default false
33941 * @cfg {Boolean} yearAllowBlank (true|false) default false
33942 * @cfg {string} dayPlaceholder
33943 * @cfg {string} monthPlaceholder
33944 * @cfg {string} yearPlaceholder
33945 * @cfg {string} dayFormat default 'd'
33946 * @cfg {string} monthFormat default 'm'
33947 * @cfg {string} yearFormat default 'Y'
33948 * @cfg {Number} labellg set the width of label (1-12)
33949 * @cfg {Number} labelmd set the width of label (1-12)
33950 * @cfg {Number} labelsm set the width of label (1-12)
33951 * @cfg {Number} labelxs set the width of label (1-12)
33955 * Create a new DateSplitField
33956 * @param {Object} config The config object
33959 Roo.bootstrap.DateSplitField = function(config){
33960 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
33966 * getting the data of years
33967 * @param {Roo.bootstrap.DateSplitField} this
33968 * @param {Object} years
33973 * getting the data of days
33974 * @param {Roo.bootstrap.DateSplitField} this
33975 * @param {Object} days
33980 * Fires after the field has been marked as invalid.
33981 * @param {Roo.form.Field} this
33982 * @param {String} msg The validation message
33987 * Fires after the field has been validated with no errors.
33988 * @param {Roo.form.Field} this
33994 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
33997 labelAlign : 'top',
33999 dayAllowBlank : false,
34000 monthAllowBlank : false,
34001 yearAllowBlank : false,
34002 dayPlaceholder : '',
34003 monthPlaceholder : '',
34004 yearPlaceholder : '',
34008 isFormField : true,
34014 getAutoCreate : function()
34018 cls : 'row roo-date-split-field-group',
34023 cls : 'form-hidden-field roo-date-split-field-group-value',
34029 var labelCls = 'col-md-12';
34030 var contentCls = 'col-md-4';
34032 if(this.fieldLabel){
34036 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
34040 html : this.fieldLabel
34045 if(this.labelAlign == 'left'){
34047 if(this.labelWidth > 12){
34048 label.style = "width: " + this.labelWidth + 'px';
34051 if(this.labelWidth < 13 && this.labelmd == 0){
34052 this.labelmd = this.labelWidth;
34055 if(this.labellg > 0){
34056 labelCls = ' col-lg-' + this.labellg;
34057 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
34060 if(this.labelmd > 0){
34061 labelCls = ' col-md-' + this.labelmd;
34062 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
34065 if(this.labelsm > 0){
34066 labelCls = ' col-sm-' + this.labelsm;
34067 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
34070 if(this.labelxs > 0){
34071 labelCls = ' col-xs-' + this.labelxs;
34072 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
34076 label.cls += ' ' + labelCls;
34078 cfg.cn.push(label);
34081 Roo.each(['day', 'month', 'year'], function(t){
34084 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
34091 inputEl: function ()
34093 return this.el.select('.roo-date-split-field-group-value', true).first();
34096 onRender : function(ct, position)
34100 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
34102 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
34104 this.dayField = new Roo.bootstrap.ComboBox({
34105 allowBlank : this.dayAllowBlank,
34106 alwaysQuery : true,
34107 displayField : 'value',
34110 forceSelection : true,
34112 placeholder : this.dayPlaceholder,
34113 selectOnFocus : true,
34114 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
34115 triggerAction : 'all',
34117 valueField : 'value',
34118 store : new Roo.data.SimpleStore({
34119 data : (function() {
34121 _this.fireEvent('days', _this, days);
34124 fields : [ 'value' ]
34127 select : function (_self, record, index)
34129 _this.setValue(_this.getValue());
34134 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
34136 this.monthField = new Roo.bootstrap.MonthField({
34137 after : '<i class=\"fa fa-calendar\"></i>',
34138 allowBlank : this.monthAllowBlank,
34139 placeholder : this.monthPlaceholder,
34142 render : function (_self)
34144 this.el.select('span.input-group-addon', true).first().on('click', function(e){
34145 e.preventDefault();
34149 select : function (_self, oldvalue, newvalue)
34151 _this.setValue(_this.getValue());
34156 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
34158 this.yearField = new Roo.bootstrap.ComboBox({
34159 allowBlank : this.yearAllowBlank,
34160 alwaysQuery : true,
34161 displayField : 'value',
34164 forceSelection : true,
34166 placeholder : this.yearPlaceholder,
34167 selectOnFocus : true,
34168 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
34169 triggerAction : 'all',
34171 valueField : 'value',
34172 store : new Roo.data.SimpleStore({
34173 data : (function() {
34175 _this.fireEvent('years', _this, years);
34178 fields : [ 'value' ]
34181 select : function (_self, record, index)
34183 _this.setValue(_this.getValue());
34188 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
34191 setValue : function(v, format)
34193 this.inputEl.dom.value = v;
34195 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
34197 var d = Date.parseDate(v, f);
34204 this.setDay(d.format(this.dayFormat));
34205 this.setMonth(d.format(this.monthFormat));
34206 this.setYear(d.format(this.yearFormat));
34213 setDay : function(v)
34215 this.dayField.setValue(v);
34216 this.inputEl.dom.value = this.getValue();
34221 setMonth : function(v)
34223 this.monthField.setValue(v, true);
34224 this.inputEl.dom.value = this.getValue();
34229 setYear : function(v)
34231 this.yearField.setValue(v);
34232 this.inputEl.dom.value = this.getValue();
34237 getDay : function()
34239 return this.dayField.getValue();
34242 getMonth : function()
34244 return this.monthField.getValue();
34247 getYear : function()
34249 return this.yearField.getValue();
34252 getValue : function()
34254 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
34256 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
34266 this.inputEl.dom.value = '';
34271 validate : function()
34273 var d = this.dayField.validate();
34274 var m = this.monthField.validate();
34275 var y = this.yearField.validate();
34280 (!this.dayAllowBlank && !d) ||
34281 (!this.monthAllowBlank && !m) ||
34282 (!this.yearAllowBlank && !y)
34287 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
34296 this.markInvalid();
34301 markValid : function()
34304 var label = this.el.select('label', true).first();
34305 var icon = this.el.select('i.fa-star', true).first();
34311 this.fireEvent('valid', this);
34315 * Mark this field as invalid
34316 * @param {String} msg The validation message
34318 markInvalid : function(msg)
34321 var label = this.el.select('label', true).first();
34322 var icon = this.el.select('i.fa-star', true).first();
34324 if(label && !icon){
34325 this.el.select('.roo-date-split-field-label', true).createChild({
34327 cls : 'text-danger fa fa-lg fa-star',
34328 tooltip : 'This field is required',
34329 style : 'margin-right:5px;'
34333 this.fireEvent('invalid', this, msg);
34336 clearInvalid : function()
34338 var label = this.el.select('label', true).first();
34339 var icon = this.el.select('i.fa-star', true).first();
34345 this.fireEvent('valid', this);
34348 getName: function()
34358 * http://masonry.desandro.com
34360 * The idea is to render all the bricks based on vertical width...
34362 * The original code extends 'outlayer' - we might need to use that....
34368 * @class Roo.bootstrap.LayoutMasonry
34369 * @extends Roo.bootstrap.Component
34370 * Bootstrap Layout Masonry class
34373 * Create a new Element
34374 * @param {Object} config The config object
34377 Roo.bootstrap.LayoutMasonry = function(config){
34379 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
34383 Roo.bootstrap.LayoutMasonry.register(this);
34389 * Fire after layout the items
34390 * @param {Roo.bootstrap.LayoutMasonry} this
34391 * @param {Roo.EventObject} e
34398 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
34401 * @cfg {Boolean} isLayoutInstant = no animation?
34403 isLayoutInstant : false, // needed?
34406 * @cfg {Number} boxWidth width of the columns
34411 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
34416 * @cfg {Number} padWidth padding below box..
34421 * @cfg {Number} gutter gutter width..
34426 * @cfg {Number} maxCols maximum number of columns
34432 * @cfg {Boolean} isAutoInitial defalut true
34434 isAutoInitial : true,
34439 * @cfg {Boolean} isHorizontal defalut false
34441 isHorizontal : false,
34443 currentSize : null,
34449 bricks: null, //CompositeElement
34453 _isLayoutInited : false,
34455 // isAlternative : false, // only use for vertical layout...
34458 * @cfg {Number} alternativePadWidth padding below box..
34460 alternativePadWidth : 50,
34462 selectedBrick : [],
34464 getAutoCreate : function(){
34466 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
34470 cls: 'blog-masonary-wrapper ' + this.cls,
34472 cls : 'mas-boxes masonary'
34479 getChildContainer: function( )
34481 if (this.boxesEl) {
34482 return this.boxesEl;
34485 this.boxesEl = this.el.select('.mas-boxes').first();
34487 return this.boxesEl;
34491 initEvents : function()
34495 if(this.isAutoInitial){
34496 Roo.log('hook children rendered');
34497 this.on('childrenrendered', function() {
34498 Roo.log('children rendered');
34504 initial : function()
34506 this.selectedBrick = [];
34508 this.currentSize = this.el.getBox(true);
34510 Roo.EventManager.onWindowResize(this.resize, this);
34512 if(!this.isAutoInitial){
34520 //this.layout.defer(500,this);
34524 resize : function()
34526 var cs = this.el.getBox(true);
34529 this.currentSize.width == cs.width &&
34530 this.currentSize.x == cs.x &&
34531 this.currentSize.height == cs.height &&
34532 this.currentSize.y == cs.y
34534 Roo.log("no change in with or X or Y");
34538 this.currentSize = cs;
34544 layout : function()
34546 this._resetLayout();
34548 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
34550 this.layoutItems( isInstant );
34552 this._isLayoutInited = true;
34554 this.fireEvent('layout', this);
34558 _resetLayout : function()
34560 if(this.isHorizontal){
34561 this.horizontalMeasureColumns();
34565 this.verticalMeasureColumns();
34569 verticalMeasureColumns : function()
34571 this.getContainerWidth();
34573 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
34574 // this.colWidth = Math.floor(this.containerWidth * 0.8);
34578 var boxWidth = this.boxWidth + this.padWidth;
34580 if(this.containerWidth < this.boxWidth){
34581 boxWidth = this.containerWidth
34584 var containerWidth = this.containerWidth;
34586 var cols = Math.floor(containerWidth / boxWidth);
34588 this.cols = Math.max( cols, 1 );
34590 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
34592 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
34594 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
34596 this.colWidth = boxWidth + avail - this.padWidth;
34598 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
34599 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
34602 horizontalMeasureColumns : function()
34604 this.getContainerWidth();
34606 var boxWidth = this.boxWidth;
34608 if(this.containerWidth < boxWidth){
34609 boxWidth = this.containerWidth;
34612 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
34614 this.el.setHeight(boxWidth);
34618 getContainerWidth : function()
34620 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
34623 layoutItems : function( isInstant )
34625 Roo.log(this.bricks);
34627 var items = Roo.apply([], this.bricks);
34629 if(this.isHorizontal){
34630 this._horizontalLayoutItems( items , isInstant );
34634 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
34635 // this._verticalAlternativeLayoutItems( items , isInstant );
34639 this._verticalLayoutItems( items , isInstant );
34643 _verticalLayoutItems : function ( items , isInstant)
34645 if ( !items || !items.length ) {
34650 ['xs', 'xs', 'xs', 'tall'],
34651 ['xs', 'xs', 'tall'],
34652 ['xs', 'xs', 'sm'],
34653 ['xs', 'xs', 'xs'],
34659 ['sm', 'xs', 'xs'],
34663 ['tall', 'xs', 'xs', 'xs'],
34664 ['tall', 'xs', 'xs'],
34676 Roo.each(items, function(item, k){
34678 switch (item.size) {
34679 // these layouts take up a full box,
34690 boxes.push([item]);
34713 var filterPattern = function(box, length)
34721 var pattern = box.slice(0, length);
34725 Roo.each(pattern, function(i){
34726 format.push(i.size);
34729 Roo.each(standard, function(s){
34731 if(String(s) != String(format)){
34740 if(!match && length == 1){
34745 filterPattern(box, length - 1);
34749 queue.push(pattern);
34751 box = box.slice(length, box.length);
34753 filterPattern(box, 4);
34759 Roo.each(boxes, function(box, k){
34765 if(box.length == 1){
34770 filterPattern(box, 4);
34774 this._processVerticalLayoutQueue( queue, isInstant );
34778 // _verticalAlternativeLayoutItems : function( items , isInstant )
34780 // if ( !items || !items.length ) {
34784 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
34788 _horizontalLayoutItems : function ( items , isInstant)
34790 if ( !items || !items.length || items.length < 3) {
34796 var eItems = items.slice(0, 3);
34798 items = items.slice(3, items.length);
34801 ['xs', 'xs', 'xs', 'wide'],
34802 ['xs', 'xs', 'wide'],
34803 ['xs', 'xs', 'sm'],
34804 ['xs', 'xs', 'xs'],
34810 ['sm', 'xs', 'xs'],
34814 ['wide', 'xs', 'xs', 'xs'],
34815 ['wide', 'xs', 'xs'],
34828 Roo.each(items, function(item, k){
34830 switch (item.size) {
34841 boxes.push([item]);
34865 var filterPattern = function(box, length)
34873 var pattern = box.slice(0, length);
34877 Roo.each(pattern, function(i){
34878 format.push(i.size);
34881 Roo.each(standard, function(s){
34883 if(String(s) != String(format)){
34892 if(!match && length == 1){
34897 filterPattern(box, length - 1);
34901 queue.push(pattern);
34903 box = box.slice(length, box.length);
34905 filterPattern(box, 4);
34911 Roo.each(boxes, function(box, k){
34917 if(box.length == 1){
34922 filterPattern(box, 4);
34929 var pos = this.el.getBox(true);
34933 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
34935 var hit_end = false;
34937 Roo.each(queue, function(box){
34941 Roo.each(box, function(b){
34943 b.el.setVisibilityMode(Roo.Element.DISPLAY);
34953 Roo.each(box, function(b){
34955 b.el.setVisibilityMode(Roo.Element.DISPLAY);
34958 mx = Math.max(mx, b.x);
34962 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
34966 Roo.each(box, function(b){
34968 b.el.setVisibilityMode(Roo.Element.DISPLAY);
34982 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
34985 /** Sets position of item in DOM
34986 * @param {Element} item
34987 * @param {Number} x - horizontal position
34988 * @param {Number} y - vertical position
34989 * @param {Boolean} isInstant - disables transitions
34991 _processVerticalLayoutQueue : function( queue, isInstant )
34993 var pos = this.el.getBox(true);
34998 for (var i = 0; i < this.cols; i++){
35002 Roo.each(queue, function(box, k){
35004 var col = k % this.cols;
35006 Roo.each(box, function(b,kk){
35008 b.el.position('absolute');
35010 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
35011 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
35013 if(b.size == 'md-left' || b.size == 'md-right'){
35014 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
35015 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
35018 b.el.setWidth(width);
35019 b.el.setHeight(height);
35021 b.el.select('iframe',true).setSize(width,height);
35025 for (var i = 0; i < this.cols; i++){
35027 if(maxY[i] < maxY[col]){
35032 col = Math.min(col, i);
35036 x = pos.x + col * (this.colWidth + this.padWidth);
35040 var positions = [];
35042 switch (box.length){
35044 positions = this.getVerticalOneBoxColPositions(x, y, box);
35047 positions = this.getVerticalTwoBoxColPositions(x, y, box);
35050 positions = this.getVerticalThreeBoxColPositions(x, y, box);
35053 positions = this.getVerticalFourBoxColPositions(x, y, box);
35059 Roo.each(box, function(b,kk){
35061 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
35063 var sz = b.el.getSize();
35065 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
35073 for (var i = 0; i < this.cols; i++){
35074 mY = Math.max(mY, maxY[i]);
35077 this.el.setHeight(mY - pos.y);
35081 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
35083 // var pos = this.el.getBox(true);
35086 // var maxX = pos.right;
35088 // var maxHeight = 0;
35090 // Roo.each(items, function(item, k){
35094 // item.el.position('absolute');
35096 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
35098 // item.el.setWidth(width);
35100 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
35102 // item.el.setHeight(height);
35105 // item.el.setXY([x, y], isInstant ? false : true);
35107 // item.el.setXY([maxX - width, y], isInstant ? false : true);
35110 // y = y + height + this.alternativePadWidth;
35112 // maxHeight = maxHeight + height + this.alternativePadWidth;
35116 // this.el.setHeight(maxHeight);
35120 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
35122 var pos = this.el.getBox(true);
35127 var maxX = pos.right;
35129 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
35131 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
35133 Roo.each(queue, function(box, k){
35135 Roo.each(box, function(b, kk){
35137 b.el.position('absolute');
35139 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
35140 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
35142 if(b.size == 'md-left' || b.size == 'md-right'){
35143 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
35144 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
35147 b.el.setWidth(width);
35148 b.el.setHeight(height);
35156 var positions = [];
35158 switch (box.length){
35160 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
35163 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
35166 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
35169 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
35175 Roo.each(box, function(b,kk){
35177 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
35179 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
35187 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
35189 Roo.each(eItems, function(b,k){
35191 b.size = (k == 0) ? 'sm' : 'xs';
35192 b.x = (k == 0) ? 2 : 1;
35193 b.y = (k == 0) ? 2 : 1;
35195 b.el.position('absolute');
35197 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
35199 b.el.setWidth(width);
35201 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
35203 b.el.setHeight(height);
35207 var positions = [];
35210 x : maxX - this.unitWidth * 2 - this.gutter,
35215 x : maxX - this.unitWidth,
35216 y : minY + (this.unitWidth + this.gutter) * 2
35220 x : maxX - this.unitWidth * 3 - this.gutter * 2,
35224 Roo.each(eItems, function(b,k){
35226 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
35232 getVerticalOneBoxColPositions : function(x, y, box)
35236 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
35238 if(box[0].size == 'md-left'){
35242 if(box[0].size == 'md-right'){
35247 x : x + (this.unitWidth + this.gutter) * rand,
35254 getVerticalTwoBoxColPositions : function(x, y, box)
35258 if(box[0].size == 'xs'){
35262 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
35266 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
35280 x : x + (this.unitWidth + this.gutter) * 2,
35281 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
35288 getVerticalThreeBoxColPositions : function(x, y, box)
35292 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
35300 x : x + (this.unitWidth + this.gutter) * 1,
35305 x : x + (this.unitWidth + this.gutter) * 2,
35313 if(box[0].size == 'xs' && box[1].size == 'xs'){
35322 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
35326 x : x + (this.unitWidth + this.gutter) * 1,
35340 x : x + (this.unitWidth + this.gutter) * 2,
35345 x : x + (this.unitWidth + this.gutter) * 2,
35346 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
35353 getVerticalFourBoxColPositions : function(x, y, box)
35357 if(box[0].size == 'xs'){
35366 y : y + (this.unitHeight + this.gutter) * 1
35371 y : y + (this.unitHeight + this.gutter) * 2
35375 x : x + (this.unitWidth + this.gutter) * 1,
35389 x : x + (this.unitWidth + this.gutter) * 2,
35394 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
35395 y : y + (this.unitHeight + this.gutter) * 1
35399 x : x + (this.unitWidth + this.gutter) * 2,
35400 y : y + (this.unitWidth + this.gutter) * 2
35407 getHorizontalOneBoxColPositions : function(maxX, minY, box)
35411 if(box[0].size == 'md-left'){
35413 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
35420 if(box[0].size == 'md-right'){
35422 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
35423 y : minY + (this.unitWidth + this.gutter) * 1
35429 var rand = Math.floor(Math.random() * (4 - box[0].y));
35432 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35433 y : minY + (this.unitWidth + this.gutter) * rand
35440 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
35444 if(box[0].size == 'xs'){
35447 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35452 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35453 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
35461 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35466 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35467 y : minY + (this.unitWidth + this.gutter) * 2
35474 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
35478 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
35481 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35486 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35487 y : minY + (this.unitWidth + this.gutter) * 1
35491 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
35492 y : minY + (this.unitWidth + this.gutter) * 2
35499 if(box[0].size == 'xs' && box[1].size == 'xs'){
35502 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35507 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35512 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
35513 y : minY + (this.unitWidth + this.gutter) * 1
35521 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35526 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35527 y : minY + (this.unitWidth + this.gutter) * 2
35531 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
35532 y : minY + (this.unitWidth + this.gutter) * 2
35539 getHorizontalFourBoxColPositions : function(maxX, minY, box)
35543 if(box[0].size == 'xs'){
35546 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35551 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35556 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),
35561 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
35562 y : minY + (this.unitWidth + this.gutter) * 1
35570 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35575 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35576 y : minY + (this.unitWidth + this.gutter) * 2
35580 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
35581 y : minY + (this.unitWidth + this.gutter) * 2
35585 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),
35586 y : minY + (this.unitWidth + this.gutter) * 2
35594 * remove a Masonry Brick
35595 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
35597 removeBrick : function(brick_id)
35603 for (var i = 0; i<this.bricks.length; i++) {
35604 if (this.bricks[i].id == brick_id) {
35605 this.bricks.splice(i,1);
35606 this.el.dom.removeChild(Roo.get(brick_id).dom);
35613 * adds a Masonry Brick
35614 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
35616 addBrick : function(cfg)
35618 var cn = new Roo.bootstrap.MasonryBrick(cfg);
35619 //this.register(cn);
35620 cn.parentId = this.id;
35621 cn.render(this.el);
35626 * register a Masonry Brick
35627 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
35630 register : function(brick)
35632 this.bricks.push(brick);
35633 brick.masonryId = this.id;
35637 * clear all the Masonry Brick
35639 clearAll : function()
35642 //this.getChildContainer().dom.innerHTML = "";
35643 this.el.dom.innerHTML = '';
35646 getSelected : function()
35648 if (!this.selectedBrick) {
35652 return this.selectedBrick;
35656 Roo.apply(Roo.bootstrap.LayoutMasonry, {
35660 * register a Masonry Layout
35661 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
35664 register : function(layout)
35666 this.groups[layout.id] = layout;
35669 * fetch a Masonry Layout based on the masonry layout ID
35670 * @param {string} the masonry layout to add
35671 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
35674 get: function(layout_id) {
35675 if (typeof(this.groups[layout_id]) == 'undefined') {
35678 return this.groups[layout_id] ;
35690 * http://masonry.desandro.com
35692 * The idea is to render all the bricks based on vertical width...
35694 * The original code extends 'outlayer' - we might need to use that....
35700 * @class Roo.bootstrap.LayoutMasonryAuto
35701 * @extends Roo.bootstrap.Component
35702 * Bootstrap Layout Masonry class
35705 * Create a new Element
35706 * @param {Object} config The config object
35709 Roo.bootstrap.LayoutMasonryAuto = function(config){
35710 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
35713 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
35716 * @cfg {Boolean} isFitWidth - resize the width..
35718 isFitWidth : false, // options..
35720 * @cfg {Boolean} isOriginLeft = left align?
35722 isOriginLeft : true,
35724 * @cfg {Boolean} isOriginTop = top align?
35726 isOriginTop : false,
35728 * @cfg {Boolean} isLayoutInstant = no animation?
35730 isLayoutInstant : false, // needed?
35732 * @cfg {Boolean} isResizingContainer = not sure if this is used..
35734 isResizingContainer : true,
35736 * @cfg {Number} columnWidth width of the columns
35742 * @cfg {Number} maxCols maximum number of columns
35747 * @cfg {Number} padHeight padding below box..
35753 * @cfg {Boolean} isAutoInitial defalut true
35756 isAutoInitial : true,
35762 initialColumnWidth : 0,
35763 currentSize : null,
35765 colYs : null, // array.
35772 bricks: null, //CompositeElement
35773 cols : 0, // array?
35774 // element : null, // wrapped now this.el
35775 _isLayoutInited : null,
35778 getAutoCreate : function(){
35782 cls: 'blog-masonary-wrapper ' + this.cls,
35784 cls : 'mas-boxes masonary'
35791 getChildContainer: function( )
35793 if (this.boxesEl) {
35794 return this.boxesEl;
35797 this.boxesEl = this.el.select('.mas-boxes').first();
35799 return this.boxesEl;
35803 initEvents : function()
35807 if(this.isAutoInitial){
35808 Roo.log('hook children rendered');
35809 this.on('childrenrendered', function() {
35810 Roo.log('children rendered');
35817 initial : function()
35819 this.reloadItems();
35821 this.currentSize = this.el.getBox(true);
35823 /// was window resize... - let's see if this works..
35824 Roo.EventManager.onWindowResize(this.resize, this);
35826 if(!this.isAutoInitial){
35831 this.layout.defer(500,this);
35834 reloadItems: function()
35836 this.bricks = this.el.select('.masonry-brick', true);
35838 this.bricks.each(function(b) {
35839 //Roo.log(b.getSize());
35840 if (!b.attr('originalwidth')) {
35841 b.attr('originalwidth', b.getSize().width);
35846 Roo.log(this.bricks.elements.length);
35849 resize : function()
35852 var cs = this.el.getBox(true);
35854 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
35855 Roo.log("no change in with or X");
35858 this.currentSize = cs;
35862 layout : function()
35865 this._resetLayout();
35866 //this._manageStamps();
35868 // don't animate first layout
35869 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
35870 this.layoutItems( isInstant );
35872 // flag for initalized
35873 this._isLayoutInited = true;
35876 layoutItems : function( isInstant )
35878 //var items = this._getItemsForLayout( this.items );
35879 // original code supports filtering layout items.. we just ignore it..
35881 this._layoutItems( this.bricks , isInstant );
35883 this._postLayout();
35885 _layoutItems : function ( items , isInstant)
35887 //this.fireEvent( 'layout', this, items );
35890 if ( !items || !items.elements.length ) {
35891 // no items, emit event with empty array
35896 items.each(function(item) {
35897 Roo.log("layout item");
35899 // get x/y object from method
35900 var position = this._getItemLayoutPosition( item );
35902 position.item = item;
35903 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
35904 queue.push( position );
35907 this._processLayoutQueue( queue );
35909 /** Sets position of item in DOM
35910 * @param {Element} item
35911 * @param {Number} x - horizontal position
35912 * @param {Number} y - vertical position
35913 * @param {Boolean} isInstant - disables transitions
35915 _processLayoutQueue : function( queue )
35917 for ( var i=0, len = queue.length; i < len; i++ ) {
35918 var obj = queue[i];
35919 obj.item.position('absolute');
35920 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
35926 * Any logic you want to do after each layout,
35927 * i.e. size the container
35929 _postLayout : function()
35931 this.resizeContainer();
35934 resizeContainer : function()
35936 if ( !this.isResizingContainer ) {
35939 var size = this._getContainerSize();
35941 this.el.setSize(size.width,size.height);
35942 this.boxesEl.setSize(size.width,size.height);
35948 _resetLayout : function()
35950 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
35951 this.colWidth = this.el.getWidth();
35952 //this.gutter = this.el.getWidth();
35954 this.measureColumns();
35960 this.colYs.push( 0 );
35966 measureColumns : function()
35968 this.getContainerWidth();
35969 // if columnWidth is 0, default to outerWidth of first item
35970 if ( !this.columnWidth ) {
35971 var firstItem = this.bricks.first();
35972 Roo.log(firstItem);
35973 this.columnWidth = this.containerWidth;
35974 if (firstItem && firstItem.attr('originalwidth') ) {
35975 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
35977 // columnWidth fall back to item of first element
35978 Roo.log("set column width?");
35979 this.initialColumnWidth = this.columnWidth ;
35981 // if first elem has no width, default to size of container
35986 if (this.initialColumnWidth) {
35987 this.columnWidth = this.initialColumnWidth;
35992 // column width is fixed at the top - however if container width get's smaller we should
35995 // this bit calcs how man columns..
35997 var columnWidth = this.columnWidth += this.gutter;
35999 // calculate columns
36000 var containerWidth = this.containerWidth + this.gutter;
36002 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
36003 // fix rounding errors, typically with gutters
36004 var excess = columnWidth - containerWidth % columnWidth;
36007 // if overshoot is less than a pixel, round up, otherwise floor it
36008 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
36009 cols = Math[ mathMethod ]( cols );
36010 this.cols = Math.max( cols, 1 );
36011 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
36013 // padding positioning..
36014 var totalColWidth = this.cols * this.columnWidth;
36015 var padavail = this.containerWidth - totalColWidth;
36016 // so for 2 columns - we need 3 'pads'
36018 var padNeeded = (1+this.cols) * this.padWidth;
36020 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
36022 this.columnWidth += padExtra
36023 //this.padWidth = Math.floor(padavail / ( this.cols));
36025 // adjust colum width so that padding is fixed??
36027 // we have 3 columns ... total = width * 3
36028 // we have X left over... that should be used by
36030 //if (this.expandC) {
36038 getContainerWidth : function()
36040 /* // container is parent if fit width
36041 var container = this.isFitWidth ? this.element.parentNode : this.element;
36042 // check that this.size and size are there
36043 // IE8 triggers resize on body size change, so they might not be
36045 var size = getSize( container ); //FIXME
36046 this.containerWidth = size && size.innerWidth; //FIXME
36049 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
36053 _getItemLayoutPosition : function( item ) // what is item?
36055 // we resize the item to our columnWidth..
36057 item.setWidth(this.columnWidth);
36058 item.autoBoxAdjust = false;
36060 var sz = item.getSize();
36062 // how many columns does this brick span
36063 var remainder = this.containerWidth % this.columnWidth;
36065 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
36066 // round if off by 1 pixel, otherwise use ceil
36067 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
36068 colSpan = Math.min( colSpan, this.cols );
36070 // normally this should be '1' as we dont' currently allow multi width columns..
36072 var colGroup = this._getColGroup( colSpan );
36073 // get the minimum Y value from the columns
36074 var minimumY = Math.min.apply( Math, colGroup );
36075 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
36077 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
36079 // position the brick
36081 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
36082 y: this.currentSize.y + minimumY + this.padHeight
36086 // apply setHeight to necessary columns
36087 var setHeight = minimumY + sz.height + this.padHeight;
36088 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
36090 var setSpan = this.cols + 1 - colGroup.length;
36091 for ( var i = 0; i < setSpan; i++ ) {
36092 this.colYs[ shortColIndex + i ] = setHeight ;
36099 * @param {Number} colSpan - number of columns the element spans
36100 * @returns {Array} colGroup
36102 _getColGroup : function( colSpan )
36104 if ( colSpan < 2 ) {
36105 // if brick spans only one column, use all the column Ys
36110 // how many different places could this brick fit horizontally
36111 var groupCount = this.cols + 1 - colSpan;
36112 // for each group potential horizontal position
36113 for ( var i = 0; i < groupCount; i++ ) {
36114 // make an array of colY values for that one group
36115 var groupColYs = this.colYs.slice( i, i + colSpan );
36116 // and get the max value of the array
36117 colGroup[i] = Math.max.apply( Math, groupColYs );
36122 _manageStamp : function( stamp )
36124 var stampSize = stamp.getSize();
36125 var offset = stamp.getBox();
36126 // get the columns that this stamp affects
36127 var firstX = this.isOriginLeft ? offset.x : offset.right;
36128 var lastX = firstX + stampSize.width;
36129 var firstCol = Math.floor( firstX / this.columnWidth );
36130 firstCol = Math.max( 0, firstCol );
36132 var lastCol = Math.floor( lastX / this.columnWidth );
36133 // lastCol should not go over if multiple of columnWidth #425
36134 lastCol -= lastX % this.columnWidth ? 0 : 1;
36135 lastCol = Math.min( this.cols - 1, lastCol );
36137 // set colYs to bottom of the stamp
36138 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
36141 for ( var i = firstCol; i <= lastCol; i++ ) {
36142 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
36147 _getContainerSize : function()
36149 this.maxY = Math.max.apply( Math, this.colYs );
36154 if ( this.isFitWidth ) {
36155 size.width = this._getContainerFitWidth();
36161 _getContainerFitWidth : function()
36163 var unusedCols = 0;
36164 // count unused columns
36167 if ( this.colYs[i] !== 0 ) {
36172 // fit container to columns that have been used
36173 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
36176 needsResizeLayout : function()
36178 var previousWidth = this.containerWidth;
36179 this.getContainerWidth();
36180 return previousWidth !== this.containerWidth;
36195 * @class Roo.bootstrap.MasonryBrick
36196 * @extends Roo.bootstrap.Component
36197 * Bootstrap MasonryBrick class
36200 * Create a new MasonryBrick
36201 * @param {Object} config The config object
36204 Roo.bootstrap.MasonryBrick = function(config){
36206 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
36208 Roo.bootstrap.MasonryBrick.register(this);
36214 * When a MasonryBrick is clcik
36215 * @param {Roo.bootstrap.MasonryBrick} this
36216 * @param {Roo.EventObject} e
36222 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
36225 * @cfg {String} title
36229 * @cfg {String} html
36233 * @cfg {String} bgimage
36237 * @cfg {String} videourl
36241 * @cfg {String} cls
36245 * @cfg {String} href
36249 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
36254 * @cfg {String} placetitle (center|bottom)
36259 * @cfg {Boolean} isFitContainer defalut true
36261 isFitContainer : true,
36264 * @cfg {Boolean} preventDefault defalut false
36266 preventDefault : false,
36269 * @cfg {Boolean} inverse defalut false
36271 maskInverse : false,
36273 getAutoCreate : function()
36275 if(!this.isFitContainer){
36276 return this.getSplitAutoCreate();
36279 var cls = 'masonry-brick masonry-brick-full';
36281 if(this.href.length){
36282 cls += ' masonry-brick-link';
36285 if(this.bgimage.length){
36286 cls += ' masonry-brick-image';
36289 if(this.maskInverse){
36290 cls += ' mask-inverse';
36293 if(!this.html.length && !this.maskInverse && !this.videourl.length){
36294 cls += ' enable-mask';
36298 cls += ' masonry-' + this.size + '-brick';
36301 if(this.placetitle.length){
36303 switch (this.placetitle) {
36305 cls += ' masonry-center-title';
36308 cls += ' masonry-bottom-title';
36315 if(!this.html.length && !this.bgimage.length){
36316 cls += ' masonry-center-title';
36319 if(!this.html.length && this.bgimage.length){
36320 cls += ' masonry-bottom-title';
36325 cls += ' ' + this.cls;
36329 tag: (this.href.length) ? 'a' : 'div',
36334 cls: 'masonry-brick-mask'
36338 cls: 'masonry-brick-paragraph',
36344 if(this.href.length){
36345 cfg.href = this.href;
36348 var cn = cfg.cn[1].cn;
36350 if(this.title.length){
36353 cls: 'masonry-brick-title',
36358 if(this.html.length){
36361 cls: 'masonry-brick-text',
36366 if (!this.title.length && !this.html.length) {
36367 cfg.cn[1].cls += ' hide';
36370 if(this.bgimage.length){
36373 cls: 'masonry-brick-image-view',
36378 if(this.videourl.length){
36379 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
36380 // youtube support only?
36383 cls: 'masonry-brick-image-view',
36386 allowfullscreen : true
36394 getSplitAutoCreate : function()
36396 var cls = 'masonry-brick masonry-brick-split';
36398 if(this.href.length){
36399 cls += ' masonry-brick-link';
36402 if(this.bgimage.length){
36403 cls += ' masonry-brick-image';
36407 cls += ' masonry-' + this.size + '-brick';
36410 switch (this.placetitle) {
36412 cls += ' masonry-center-title';
36415 cls += ' masonry-bottom-title';
36418 if(!this.bgimage.length){
36419 cls += ' masonry-center-title';
36422 if(this.bgimage.length){
36423 cls += ' masonry-bottom-title';
36429 cls += ' ' + this.cls;
36433 tag: (this.href.length) ? 'a' : 'div',
36438 cls: 'masonry-brick-split-head',
36442 cls: 'masonry-brick-paragraph',
36449 cls: 'masonry-brick-split-body',
36455 if(this.href.length){
36456 cfg.href = this.href;
36459 if(this.title.length){
36460 cfg.cn[0].cn[0].cn.push({
36462 cls: 'masonry-brick-title',
36467 if(this.html.length){
36468 cfg.cn[1].cn.push({
36470 cls: 'masonry-brick-text',
36475 if(this.bgimage.length){
36476 cfg.cn[0].cn.push({
36478 cls: 'masonry-brick-image-view',
36483 if(this.videourl.length){
36484 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
36485 // youtube support only?
36486 cfg.cn[0].cn.cn.push({
36488 cls: 'masonry-brick-image-view',
36491 allowfullscreen : true
36498 initEvents: function()
36500 switch (this.size) {
36533 this.el.on('touchstart', this.onTouchStart, this);
36534 this.el.on('touchmove', this.onTouchMove, this);
36535 this.el.on('touchend', this.onTouchEnd, this);
36536 this.el.on('contextmenu', this.onContextMenu, this);
36538 this.el.on('mouseenter' ,this.enter, this);
36539 this.el.on('mouseleave', this.leave, this);
36540 this.el.on('click', this.onClick, this);
36543 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
36544 this.parent().bricks.push(this);
36549 onClick: function(e, el)
36551 var time = this.endTimer - this.startTimer;
36552 // Roo.log(e.preventDefault());
36555 e.preventDefault();
36560 if(!this.preventDefault){
36564 e.preventDefault();
36566 if (this.activeClass != '') {
36567 this.selectBrick();
36570 this.fireEvent('click', this, e);
36573 enter: function(e, el)
36575 e.preventDefault();
36577 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
36581 if(this.bgimage.length && this.html.length){
36582 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
36586 leave: function(e, el)
36588 e.preventDefault();
36590 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
36594 if(this.bgimage.length && this.html.length){
36595 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
36599 onTouchStart: function(e, el)
36601 // e.preventDefault();
36603 this.touchmoved = false;
36605 if(!this.isFitContainer){
36609 if(!this.bgimage.length || !this.html.length){
36613 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
36615 this.timer = new Date().getTime();
36619 onTouchMove: function(e, el)
36621 this.touchmoved = true;
36624 onContextMenu : function(e,el)
36626 e.preventDefault();
36627 e.stopPropagation();
36631 onTouchEnd: function(e, el)
36633 // e.preventDefault();
36635 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
36642 if(!this.bgimage.length || !this.html.length){
36644 if(this.href.length){
36645 window.location.href = this.href;
36651 if(!this.isFitContainer){
36655 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
36657 window.location.href = this.href;
36660 //selection on single brick only
36661 selectBrick : function() {
36663 if (!this.parentId) {
36667 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
36668 var index = m.selectedBrick.indexOf(this.id);
36671 m.selectedBrick.splice(index,1);
36672 this.el.removeClass(this.activeClass);
36676 for(var i = 0; i < m.selectedBrick.length; i++) {
36677 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
36678 b.el.removeClass(b.activeClass);
36681 m.selectedBrick = [];
36683 m.selectedBrick.push(this.id);
36684 this.el.addClass(this.activeClass);
36688 isSelected : function(){
36689 return this.el.hasClass(this.activeClass);
36694 Roo.apply(Roo.bootstrap.MasonryBrick, {
36697 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
36699 * register a Masonry Brick
36700 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
36703 register : function(brick)
36705 //this.groups[brick.id] = brick;
36706 this.groups.add(brick.id, brick);
36709 * fetch a masonry brick based on the masonry brick ID
36710 * @param {string} the masonry brick to add
36711 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
36714 get: function(brick_id)
36716 // if (typeof(this.groups[brick_id]) == 'undefined') {
36719 // return this.groups[brick_id] ;
36721 if(this.groups.key(brick_id)) {
36722 return this.groups.key(brick_id);
36740 * @class Roo.bootstrap.Brick
36741 * @extends Roo.bootstrap.Component
36742 * Bootstrap Brick class
36745 * Create a new Brick
36746 * @param {Object} config The config object
36749 Roo.bootstrap.Brick = function(config){
36750 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
36756 * When a Brick is click
36757 * @param {Roo.bootstrap.Brick} this
36758 * @param {Roo.EventObject} e
36764 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
36767 * @cfg {String} title
36771 * @cfg {String} html
36775 * @cfg {String} bgimage
36779 * @cfg {String} cls
36783 * @cfg {String} href
36787 * @cfg {String} video
36791 * @cfg {Boolean} square
36795 getAutoCreate : function()
36797 var cls = 'roo-brick';
36799 if(this.href.length){
36800 cls += ' roo-brick-link';
36803 if(this.bgimage.length){
36804 cls += ' roo-brick-image';
36807 if(!this.html.length && !this.bgimage.length){
36808 cls += ' roo-brick-center-title';
36811 if(!this.html.length && this.bgimage.length){
36812 cls += ' roo-brick-bottom-title';
36816 cls += ' ' + this.cls;
36820 tag: (this.href.length) ? 'a' : 'div',
36825 cls: 'roo-brick-paragraph',
36831 if(this.href.length){
36832 cfg.href = this.href;
36835 var cn = cfg.cn[0].cn;
36837 if(this.title.length){
36840 cls: 'roo-brick-title',
36845 if(this.html.length){
36848 cls: 'roo-brick-text',
36855 if(this.bgimage.length){
36858 cls: 'roo-brick-image-view',
36866 initEvents: function()
36868 if(this.title.length || this.html.length){
36869 this.el.on('mouseenter' ,this.enter, this);
36870 this.el.on('mouseleave', this.leave, this);
36873 Roo.EventManager.onWindowResize(this.resize, this);
36875 if(this.bgimage.length){
36876 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
36877 this.imageEl.on('load', this.onImageLoad, this);
36884 onImageLoad : function()
36889 resize : function()
36891 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
36893 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
36895 if(this.bgimage.length){
36896 var image = this.el.select('.roo-brick-image-view', true).first();
36898 image.setWidth(paragraph.getWidth());
36901 image.setHeight(paragraph.getWidth());
36904 this.el.setHeight(image.getHeight());
36905 paragraph.setHeight(image.getHeight());
36911 enter: function(e, el)
36913 e.preventDefault();
36915 if(this.bgimage.length){
36916 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
36917 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
36921 leave: function(e, el)
36923 e.preventDefault();
36925 if(this.bgimage.length){
36926 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
36927 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
36942 * @class Roo.bootstrap.NumberField
36943 * @extends Roo.bootstrap.Input
36944 * Bootstrap NumberField class
36950 * Create a new NumberField
36951 * @param {Object} config The config object
36954 Roo.bootstrap.NumberField = function(config){
36955 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
36958 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
36961 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
36963 allowDecimals : true,
36965 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
36967 decimalSeparator : ".",
36969 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
36971 decimalPrecision : 2,
36973 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
36975 allowNegative : true,
36978 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
36982 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
36984 minValue : Number.NEGATIVE_INFINITY,
36986 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
36988 maxValue : Number.MAX_VALUE,
36990 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
36992 minText : "The minimum value for this field is {0}",
36994 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
36996 maxText : "The maximum value for this field is {0}",
36998 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
36999 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
37001 nanText : "{0} is not a valid number",
37003 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
37005 thousandsDelimiter : false,
37007 * @cfg {String} valueAlign alignment of value
37009 valueAlign : "left",
37011 getAutoCreate : function()
37013 var hiddenInput = {
37017 cls: 'hidden-number-input'
37021 hiddenInput.name = this.name;
37026 var cfg = Roo.bootstrap.NumberField.superclass.getAutoCreate.call(this);
37028 this.name = hiddenInput.name;
37030 if(cfg.cn.length > 0) {
37031 cfg.cn.push(hiddenInput);
37038 initEvents : function()
37040 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
37042 var allowed = "0123456789";
37044 if(this.allowDecimals){
37045 allowed += this.decimalSeparator;
37048 if(this.allowNegative){
37052 if(this.thousandsDelimiter) {
37056 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
37058 var keyPress = function(e){
37060 var k = e.getKey();
37062 var c = e.getCharCode();
37065 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
37066 allowed.indexOf(String.fromCharCode(c)) === -1
37072 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
37076 if(allowed.indexOf(String.fromCharCode(c)) === -1){
37081 this.el.on("keypress", keyPress, this);
37084 validateValue : function(value)
37087 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
37091 var num = this.parseValue(value);
37094 this.markInvalid(String.format(this.nanText, value));
37098 if(num < this.minValue){
37099 this.markInvalid(String.format(this.minText, this.minValue));
37103 if(num > this.maxValue){
37104 this.markInvalid(String.format(this.maxText, this.maxValue));
37111 getValue : function()
37113 var v = this.hiddenEl().getValue();
37115 return this.fixPrecision(this.parseValue(v));
37118 parseValue : function(value)
37120 if(this.thousandsDelimiter) {
37122 r = new RegExp(",", "g");
37123 value = value.replace(r, "");
37126 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
37127 return isNaN(value) ? '' : value;
37130 fixPrecision : function(value)
37132 if(this.thousandsDelimiter) {
37134 r = new RegExp(",", "g");
37135 value = value.replace(r, "");
37138 var nan = isNaN(value);
37140 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
37141 return nan ? '' : value;
37143 return parseFloat(value).toFixed(this.decimalPrecision);
37146 setValue : function(v)
37148 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
37154 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
37156 this.inputEl().dom.value = (v == '') ? '' :
37157 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
37159 if(!this.allowZero && v === '0') {
37160 this.hiddenEl().dom.value = '';
37161 this.inputEl().dom.value = '';
37168 decimalPrecisionFcn : function(v)
37170 return Math.floor(v);
37173 beforeBlur : function()
37175 var v = this.parseValue(this.getRawValue());
37177 if(v || v === 0 || v === ''){
37182 hiddenEl : function()
37184 return this.el.select('input.hidden-number-input',true).first();
37196 * @class Roo.bootstrap.DocumentSlider
37197 * @extends Roo.bootstrap.Component
37198 * Bootstrap DocumentSlider class
37201 * Create a new DocumentViewer
37202 * @param {Object} config The config object
37205 Roo.bootstrap.DocumentSlider = function(config){
37206 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
37213 * Fire after initEvent
37214 * @param {Roo.bootstrap.DocumentSlider} this
37219 * Fire after update
37220 * @param {Roo.bootstrap.DocumentSlider} this
37226 * @param {Roo.bootstrap.DocumentSlider} this
37232 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
37238 getAutoCreate : function()
37242 cls : 'roo-document-slider',
37246 cls : 'roo-document-slider-header',
37250 cls : 'roo-document-slider-header-title'
37256 cls : 'roo-document-slider-body',
37260 cls : 'roo-document-slider-prev',
37264 cls : 'fa fa-chevron-left'
37270 cls : 'roo-document-slider-thumb',
37274 cls : 'roo-document-slider-image'
37280 cls : 'roo-document-slider-next',
37284 cls : 'fa fa-chevron-right'
37296 initEvents : function()
37298 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
37299 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
37301 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
37302 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
37304 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
37305 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
37307 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
37308 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
37310 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
37311 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
37313 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
37314 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
37316 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
37317 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
37319 this.thumbEl.on('click', this.onClick, this);
37321 this.prevIndicator.on('click', this.prev, this);
37323 this.nextIndicator.on('click', this.next, this);
37327 initial : function()
37329 if(this.files.length){
37330 this.indicator = 1;
37334 this.fireEvent('initial', this);
37337 update : function()
37339 this.imageEl.attr('src', this.files[this.indicator - 1]);
37341 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
37343 this.prevIndicator.show();
37345 if(this.indicator == 1){
37346 this.prevIndicator.hide();
37349 this.nextIndicator.show();
37351 if(this.indicator == this.files.length){
37352 this.nextIndicator.hide();
37355 this.thumbEl.scrollTo('top');
37357 this.fireEvent('update', this);
37360 onClick : function(e)
37362 e.preventDefault();
37364 this.fireEvent('click', this);
37369 e.preventDefault();
37371 this.indicator = Math.max(1, this.indicator - 1);
37378 e.preventDefault();
37380 this.indicator = Math.min(this.files.length, this.indicator + 1);
37394 * @class Roo.bootstrap.RadioSet
37395 * @extends Roo.bootstrap.Input
37396 * Bootstrap RadioSet class
37397 * @cfg {String} indicatorpos (left|right) default left
37398 * @cfg {Boolean} inline (true|false) inline the element (default true)
37399 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
37401 * Create a new RadioSet
37402 * @param {Object} config The config object
37405 Roo.bootstrap.RadioSet = function(config){
37407 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
37411 Roo.bootstrap.RadioSet.register(this);
37416 * Fires when the element is checked or unchecked.
37417 * @param {Roo.bootstrap.RadioSet} this This radio
37418 * @param {Roo.bootstrap.Radio} item The checked item
37423 * Fires when the element is click.
37424 * @param {Roo.bootstrap.RadioSet} this This radio set
37425 * @param {Roo.bootstrap.Radio} item The checked item
37426 * @param {Roo.EventObject} e The event object
37433 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
37441 indicatorpos : 'left',
37443 getAutoCreate : function()
37447 cls : 'roo-radio-set-label',
37451 html : this.fieldLabel
37455 if (Roo.bootstrap.version == 3) {
37458 if(this.indicatorpos == 'left'){
37461 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
37462 tooltip : 'This field is required'
37467 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
37468 tooltip : 'This field is required'
37474 cls : 'roo-radio-set-items'
37477 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
37479 if (align === 'left' && this.fieldLabel.length) {
37482 cls : "roo-radio-set-right",
37488 if(this.labelWidth > 12){
37489 label.style = "width: " + this.labelWidth + 'px';
37492 if(this.labelWidth < 13 && this.labelmd == 0){
37493 this.labelmd = this.labelWidth;
37496 if(this.labellg > 0){
37497 label.cls += ' col-lg-' + this.labellg;
37498 items.cls += ' col-lg-' + (12 - this.labellg);
37501 if(this.labelmd > 0){
37502 label.cls += ' col-md-' + this.labelmd;
37503 items.cls += ' col-md-' + (12 - this.labelmd);
37506 if(this.labelsm > 0){
37507 label.cls += ' col-sm-' + this.labelsm;
37508 items.cls += ' col-sm-' + (12 - this.labelsm);
37511 if(this.labelxs > 0){
37512 label.cls += ' col-xs-' + this.labelxs;
37513 items.cls += ' col-xs-' + (12 - this.labelxs);
37519 cls : 'roo-radio-set',
37523 cls : 'roo-radio-set-input',
37526 value : this.value ? this.value : ''
37533 if(this.weight.length){
37534 cfg.cls += ' roo-radio-' + this.weight;
37538 cfg.cls += ' roo-radio-set-inline';
37542 ['xs','sm','md','lg'].map(function(size){
37543 if (settings[size]) {
37544 cfg.cls += ' col-' + size + '-' + settings[size];
37552 initEvents : function()
37554 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
37555 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
37557 if(!this.fieldLabel.length){
37558 this.labelEl.hide();
37561 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
37562 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
37564 this.indicator = this.indicatorEl();
37566 if(this.indicator){
37567 this.indicator.addClass('invisible');
37570 this.originalValue = this.getValue();
37574 inputEl: function ()
37576 return this.el.select('.roo-radio-set-input', true).first();
37579 getChildContainer : function()
37581 return this.itemsEl;
37584 register : function(item)
37586 this.radioes.push(item);
37590 validate : function()
37592 if(this.getVisibilityEl().hasClass('hidden')){
37598 Roo.each(this.radioes, function(i){
37607 if(this.allowBlank) {
37611 if(this.disabled || valid){
37616 this.markInvalid();
37621 markValid : function()
37623 if(this.labelEl.isVisible(true) && this.indicatorEl()){
37624 this.indicatorEl().removeClass('visible');
37625 this.indicatorEl().addClass('invisible');
37629 if (Roo.bootstrap.version == 3) {
37630 this.el.removeClass([this.invalidClass, this.validClass]);
37631 this.el.addClass(this.validClass);
37633 this.el.removeClass(['is-invalid','is-valid']);
37634 this.el.addClass(['is-valid']);
37636 this.fireEvent('valid', this);
37639 markInvalid : function(msg)
37641 if(this.allowBlank || this.disabled){
37645 if(this.labelEl.isVisible(true) && this.indicatorEl()){
37646 this.indicatorEl().removeClass('invisible');
37647 this.indicatorEl().addClass('visible');
37649 if (Roo.bootstrap.version == 3) {
37650 this.el.removeClass([this.invalidClass, this.validClass]);
37651 this.el.addClass(this.invalidClass);
37653 this.el.removeClass(['is-invalid','is-valid']);
37654 this.el.addClass(['is-invalid']);
37657 this.fireEvent('invalid', this, msg);
37661 setValue : function(v, suppressEvent)
37663 if(this.value === v){
37670 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
37673 Roo.each(this.radioes, function(i){
37675 i.el.removeClass('checked');
37678 Roo.each(this.radioes, function(i){
37680 if(i.value === v || i.value.toString() === v.toString()){
37682 i.el.addClass('checked');
37684 if(suppressEvent !== true){
37685 this.fireEvent('check', this, i);
37696 clearInvalid : function(){
37698 if(!this.el || this.preventMark){
37702 this.el.removeClass([this.invalidClass]);
37704 this.fireEvent('valid', this);
37709 Roo.apply(Roo.bootstrap.RadioSet, {
37713 register : function(set)
37715 this.groups[set.name] = set;
37718 get: function(name)
37720 if (typeof(this.groups[name]) == 'undefined') {
37724 return this.groups[name] ;
37730 * Ext JS Library 1.1.1
37731 * Copyright(c) 2006-2007, Ext JS, LLC.
37733 * Originally Released Under LGPL - original licence link has changed is not relivant.
37736 * <script type="text/javascript">
37741 * @class Roo.bootstrap.SplitBar
37742 * @extends Roo.util.Observable
37743 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
37747 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
37748 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
37749 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
37750 split.minSize = 100;
37751 split.maxSize = 600;
37752 split.animate = true;
37753 split.on('moved', splitterMoved);
37756 * Create a new SplitBar
37757 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
37758 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
37759 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
37760 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
37761 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
37762 position of the SplitBar).
37764 Roo.bootstrap.SplitBar = function(cfg){
37769 // dragElement : elm
37770 // resizingElement: el,
37772 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
37773 // placement : Roo.bootstrap.SplitBar.LEFT ,
37774 // existingProxy ???
37777 this.el = Roo.get(cfg.dragElement, true);
37778 this.el.dom.unselectable = "on";
37780 this.resizingEl = Roo.get(cfg.resizingElement, true);
37784 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
37785 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
37788 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
37791 * The minimum size of the resizing element. (Defaults to 0)
37797 * The maximum size of the resizing element. (Defaults to 2000)
37800 this.maxSize = 2000;
37803 * Whether to animate the transition to the new size
37806 this.animate = false;
37809 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
37812 this.useShim = false;
37817 if(!cfg.existingProxy){
37819 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
37821 this.proxy = Roo.get(cfg.existingProxy).dom;
37824 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
37827 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
37830 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
37833 this.dragSpecs = {};
37836 * @private The adapter to use to positon and resize elements
37838 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
37839 this.adapter.init(this);
37841 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
37843 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
37844 this.el.addClass("roo-splitbar-h");
37847 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
37848 this.el.addClass("roo-splitbar-v");
37854 * Fires when the splitter is moved (alias for {@link #event-moved})
37855 * @param {Roo.bootstrap.SplitBar} this
37856 * @param {Number} newSize the new width or height
37861 * Fires when the splitter is moved
37862 * @param {Roo.bootstrap.SplitBar} this
37863 * @param {Number} newSize the new width or height
37867 * @event beforeresize
37868 * Fires before the splitter is dragged
37869 * @param {Roo.bootstrap.SplitBar} this
37871 "beforeresize" : true,
37873 "beforeapply" : true
37876 Roo.util.Observable.call(this);
37879 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
37880 onStartProxyDrag : function(x, y){
37881 this.fireEvent("beforeresize", this);
37883 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
37885 o.enableDisplayMode("block");
37886 // all splitbars share the same overlay
37887 Roo.bootstrap.SplitBar.prototype.overlay = o;
37889 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
37890 this.overlay.show();
37891 Roo.get(this.proxy).setDisplayed("block");
37892 var size = this.adapter.getElementSize(this);
37893 this.activeMinSize = this.getMinimumSize();;
37894 this.activeMaxSize = this.getMaximumSize();;
37895 var c1 = size - this.activeMinSize;
37896 var c2 = Math.max(this.activeMaxSize - size, 0);
37897 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
37898 this.dd.resetConstraints();
37899 this.dd.setXConstraint(
37900 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
37901 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
37903 this.dd.setYConstraint(0, 0);
37905 this.dd.resetConstraints();
37906 this.dd.setXConstraint(0, 0);
37907 this.dd.setYConstraint(
37908 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
37909 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
37912 this.dragSpecs.startSize = size;
37913 this.dragSpecs.startPoint = [x, y];
37914 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
37918 * @private Called after the drag operation by the DDProxy
37920 onEndProxyDrag : function(e){
37921 Roo.get(this.proxy).setDisplayed(false);
37922 var endPoint = Roo.lib.Event.getXY(e);
37924 this.overlay.hide();
37927 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
37928 newSize = this.dragSpecs.startSize +
37929 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
37930 endPoint[0] - this.dragSpecs.startPoint[0] :
37931 this.dragSpecs.startPoint[0] - endPoint[0]
37934 newSize = this.dragSpecs.startSize +
37935 (this.placement == Roo.bootstrap.SplitBar.TOP ?
37936 endPoint[1] - this.dragSpecs.startPoint[1] :
37937 this.dragSpecs.startPoint[1] - endPoint[1]
37940 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
37941 if(newSize != this.dragSpecs.startSize){
37942 if(this.fireEvent('beforeapply', this, newSize) !== false){
37943 this.adapter.setElementSize(this, newSize);
37944 this.fireEvent("moved", this, newSize);
37945 this.fireEvent("resize", this, newSize);
37951 * Get the adapter this SplitBar uses
37952 * @return The adapter object
37954 getAdapter : function(){
37955 return this.adapter;
37959 * Set the adapter this SplitBar uses
37960 * @param {Object} adapter A SplitBar adapter object
37962 setAdapter : function(adapter){
37963 this.adapter = adapter;
37964 this.adapter.init(this);
37968 * Gets the minimum size for the resizing element
37969 * @return {Number} The minimum size
37971 getMinimumSize : function(){
37972 return this.minSize;
37976 * Sets the minimum size for the resizing element
37977 * @param {Number} minSize The minimum size
37979 setMinimumSize : function(minSize){
37980 this.minSize = minSize;
37984 * Gets the maximum size for the resizing element
37985 * @return {Number} The maximum size
37987 getMaximumSize : function(){
37988 return this.maxSize;
37992 * Sets the maximum size for the resizing element
37993 * @param {Number} maxSize The maximum size
37995 setMaximumSize : function(maxSize){
37996 this.maxSize = maxSize;
38000 * Sets the initialize size for the resizing element
38001 * @param {Number} size The initial size
38003 setCurrentSize : function(size){
38004 var oldAnimate = this.animate;
38005 this.animate = false;
38006 this.adapter.setElementSize(this, size);
38007 this.animate = oldAnimate;
38011 * Destroy this splitbar.
38012 * @param {Boolean} removeEl True to remove the element
38014 destroy : function(removeEl){
38016 this.shim.remove();
38019 this.proxy.parentNode.removeChild(this.proxy);
38027 * @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.
38029 Roo.bootstrap.SplitBar.createProxy = function(dir){
38030 var proxy = new Roo.Element(document.createElement("div"));
38031 proxy.unselectable();
38032 var cls = 'roo-splitbar-proxy';
38033 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
38034 document.body.appendChild(proxy.dom);
38039 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
38040 * Default Adapter. It assumes the splitter and resizing element are not positioned
38041 * elements and only gets/sets the width of the element. Generally used for table based layouts.
38043 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
38046 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
38047 // do nothing for now
38048 init : function(s){
38052 * Called before drag operations to get the current size of the resizing element.
38053 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
38055 getElementSize : function(s){
38056 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
38057 return s.resizingEl.getWidth();
38059 return s.resizingEl.getHeight();
38064 * Called after drag operations to set the size of the resizing element.
38065 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
38066 * @param {Number} newSize The new size to set
38067 * @param {Function} onComplete A function to be invoked when resizing is complete
38069 setElementSize : function(s, newSize, onComplete){
38070 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
38072 s.resizingEl.setWidth(newSize);
38074 onComplete(s, newSize);
38077 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
38082 s.resizingEl.setHeight(newSize);
38084 onComplete(s, newSize);
38087 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
38094 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
38095 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
38096 * Adapter that moves the splitter element to align with the resized sizing element.
38097 * Used with an absolute positioned SplitBar.
38098 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
38099 * document.body, make sure you assign an id to the body element.
38101 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
38102 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
38103 this.container = Roo.get(container);
38106 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
38107 init : function(s){
38108 this.basic.init(s);
38111 getElementSize : function(s){
38112 return this.basic.getElementSize(s);
38115 setElementSize : function(s, newSize, onComplete){
38116 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
38119 moveSplitter : function(s){
38120 var yes = Roo.bootstrap.SplitBar;
38121 switch(s.placement){
38123 s.el.setX(s.resizingEl.getRight());
38126 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
38129 s.el.setY(s.resizingEl.getBottom());
38132 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
38139 * Orientation constant - Create a vertical SplitBar
38143 Roo.bootstrap.SplitBar.VERTICAL = 1;
38146 * Orientation constant - Create a horizontal SplitBar
38150 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
38153 * Placement constant - The resizing element is to the left of the splitter element
38157 Roo.bootstrap.SplitBar.LEFT = 1;
38160 * Placement constant - The resizing element is to the right of the splitter element
38164 Roo.bootstrap.SplitBar.RIGHT = 2;
38167 * Placement constant - The resizing element is positioned above the splitter element
38171 Roo.bootstrap.SplitBar.TOP = 3;
38174 * Placement constant - The resizing element is positioned under splitter element
38178 Roo.bootstrap.SplitBar.BOTTOM = 4;
38179 Roo.namespace("Roo.bootstrap.layout");/*
38181 * Ext JS Library 1.1.1
38182 * Copyright(c) 2006-2007, Ext JS, LLC.
38184 * Originally Released Under LGPL - original licence link has changed is not relivant.
38187 * <script type="text/javascript">
38191 * @class Roo.bootstrap.layout.Manager
38192 * @extends Roo.bootstrap.Component
38193 * Base class for layout managers.
38195 Roo.bootstrap.layout.Manager = function(config)
38197 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
38203 /** false to disable window resize monitoring @type Boolean */
38204 this.monitorWindowResize = true;
38209 * Fires when a layout is performed.
38210 * @param {Roo.LayoutManager} this
38214 * @event regionresized
38215 * Fires when the user resizes a region.
38216 * @param {Roo.LayoutRegion} region The resized region
38217 * @param {Number} newSize The new size (width for east/west, height for north/south)
38219 "regionresized" : true,
38221 * @event regioncollapsed
38222 * Fires when a region is collapsed.
38223 * @param {Roo.LayoutRegion} region The collapsed region
38225 "regioncollapsed" : true,
38227 * @event regionexpanded
38228 * Fires when a region is expanded.
38229 * @param {Roo.LayoutRegion} region The expanded region
38231 "regionexpanded" : true
38233 this.updating = false;
38236 this.el = Roo.get(config.el);
38242 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
38247 monitorWindowResize : true,
38253 onRender : function(ct, position)
38256 this.el = Roo.get(ct);
38259 //this.fireEvent('render',this);
38263 initEvents: function()
38267 // ie scrollbar fix
38268 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
38269 document.body.scroll = "no";
38270 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
38271 this.el.position('relative');
38273 this.id = this.el.id;
38274 this.el.addClass("roo-layout-container");
38275 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
38276 if(this.el.dom != document.body ) {
38277 this.el.on('resize', this.layout,this);
38278 this.el.on('show', this.layout,this);
38284 * Returns true if this layout is currently being updated
38285 * @return {Boolean}
38287 isUpdating : function(){
38288 return this.updating;
38292 * Suspend the LayoutManager from doing auto-layouts while
38293 * making multiple add or remove calls
38295 beginUpdate : function(){
38296 this.updating = true;
38300 * Restore auto-layouts and optionally disable the manager from performing a layout
38301 * @param {Boolean} noLayout true to disable a layout update
38303 endUpdate : function(noLayout){
38304 this.updating = false;
38310 layout: function(){
38314 onRegionResized : function(region, newSize){
38315 this.fireEvent("regionresized", region, newSize);
38319 onRegionCollapsed : function(region){
38320 this.fireEvent("regioncollapsed", region);
38323 onRegionExpanded : function(region){
38324 this.fireEvent("regionexpanded", region);
38328 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
38329 * performs box-model adjustments.
38330 * @return {Object} The size as an object {width: (the width), height: (the height)}
38332 getViewSize : function()
38335 if(this.el.dom != document.body){
38336 size = this.el.getSize();
38338 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
38340 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
38341 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
38346 * Returns the Element this layout is bound to.
38347 * @return {Roo.Element}
38349 getEl : function(){
38354 * Returns the specified region.
38355 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
38356 * @return {Roo.LayoutRegion}
38358 getRegion : function(target){
38359 return this.regions[target.toLowerCase()];
38362 onWindowResize : function(){
38363 if(this.monitorWindowResize){
38370 * Ext JS Library 1.1.1
38371 * Copyright(c) 2006-2007, Ext JS, LLC.
38373 * Originally Released Under LGPL - original licence link has changed is not relivant.
38376 * <script type="text/javascript">
38379 * @class Roo.bootstrap.layout.Border
38380 * @extends Roo.bootstrap.layout.Manager
38382 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
38383 * please see: examples/bootstrap/nested.html<br><br>
38385 <b>The container the layout is rendered into can be either the body element or any other element.
38386 If it is not the body element, the container needs to either be an absolute positioned element,
38387 or you will need to add "position:relative" to the css of the container. You will also need to specify
38388 the container size if it is not the body element.</b>
38391 * Create a new Border
38392 * @param {Object} config Configuration options
38394 Roo.bootstrap.layout.Border = function(config){
38395 config = config || {};
38396 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
38400 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
38401 if(config[region]){
38402 config[region].region = region;
38403 this.addRegion(config[region]);
38409 Roo.bootstrap.layout.Border.regions = ["center", "north","south","east","west"];
38411 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
38413 parent : false, // this might point to a 'nest' or a ???
38416 * Creates and adds a new region if it doesn't already exist.
38417 * @param {String} target The target region key (north, south, east, west or center).
38418 * @param {Object} config The regions config object
38419 * @return {BorderLayoutRegion} The new region
38421 addRegion : function(config)
38423 if(!this.regions[config.region]){
38424 var r = this.factory(config);
38425 this.bindRegion(r);
38427 return this.regions[config.region];
38431 bindRegion : function(r){
38432 this.regions[r.config.region] = r;
38434 r.on("visibilitychange", this.layout, this);
38435 r.on("paneladded", this.layout, this);
38436 r.on("panelremoved", this.layout, this);
38437 r.on("invalidated", this.layout, this);
38438 r.on("resized", this.onRegionResized, this);
38439 r.on("collapsed", this.onRegionCollapsed, this);
38440 r.on("expanded", this.onRegionExpanded, this);
38444 * Performs a layout update.
38446 layout : function()
38448 if(this.updating) {
38452 // render all the rebions if they have not been done alreayd?
38453 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
38454 if(this.regions[region] && !this.regions[region].bodyEl){
38455 this.regions[region].onRender(this.el)
38459 var size = this.getViewSize();
38460 var w = size.width;
38461 var h = size.height;
38466 //var x = 0, y = 0;
38468 var rs = this.regions;
38469 var north = rs["north"];
38470 var south = rs["south"];
38471 var west = rs["west"];
38472 var east = rs["east"];
38473 var center = rs["center"];
38474 //if(this.hideOnLayout){ // not supported anymore
38475 //c.el.setStyle("display", "none");
38477 if(north && north.isVisible()){
38478 var b = north.getBox();
38479 var m = north.getMargins();
38480 b.width = w - (m.left+m.right);
38483 centerY = b.height + b.y + m.bottom;
38484 centerH -= centerY;
38485 north.updateBox(this.safeBox(b));
38487 if(south && south.isVisible()){
38488 var b = south.getBox();
38489 var m = south.getMargins();
38490 b.width = w - (m.left+m.right);
38492 var totalHeight = (b.height + m.top + m.bottom);
38493 b.y = h - totalHeight + m.top;
38494 centerH -= totalHeight;
38495 south.updateBox(this.safeBox(b));
38497 if(west && west.isVisible()){
38498 var b = west.getBox();
38499 var m = west.getMargins();
38500 b.height = centerH - (m.top+m.bottom);
38502 b.y = centerY + m.top;
38503 var totalWidth = (b.width + m.left + m.right);
38504 centerX += totalWidth;
38505 centerW -= totalWidth;
38506 west.updateBox(this.safeBox(b));
38508 if(east && east.isVisible()){
38509 var b = east.getBox();
38510 var m = east.getMargins();
38511 b.height = centerH - (m.top+m.bottom);
38512 var totalWidth = (b.width + m.left + m.right);
38513 b.x = w - totalWidth + m.left;
38514 b.y = centerY + m.top;
38515 centerW -= totalWidth;
38516 east.updateBox(this.safeBox(b));
38519 var m = center.getMargins();
38521 x: centerX + m.left,
38522 y: centerY + m.top,
38523 width: centerW - (m.left+m.right),
38524 height: centerH - (m.top+m.bottom)
38526 //if(this.hideOnLayout){
38527 //center.el.setStyle("display", "block");
38529 center.updateBox(this.safeBox(centerBox));
38532 this.fireEvent("layout", this);
38536 safeBox : function(box){
38537 box.width = Math.max(0, box.width);
38538 box.height = Math.max(0, box.height);
38543 * Adds a ContentPanel (or subclass) to this layout.
38544 * @param {String} target The target region key (north, south, east, west or center).
38545 * @param {Roo.ContentPanel} panel The panel to add
38546 * @return {Roo.ContentPanel} The added panel
38548 add : function(target, panel){
38550 target = target.toLowerCase();
38551 return this.regions[target].add(panel);
38555 * Remove a ContentPanel (or subclass) to this layout.
38556 * @param {String} target The target region key (north, south, east, west or center).
38557 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
38558 * @return {Roo.ContentPanel} The removed panel
38560 remove : function(target, panel){
38561 target = target.toLowerCase();
38562 return this.regions[target].remove(panel);
38566 * Searches all regions for a panel with the specified id
38567 * @param {String} panelId
38568 * @return {Roo.ContentPanel} The panel or null if it wasn't found
38570 findPanel : function(panelId){
38571 var rs = this.regions;
38572 for(var target in rs){
38573 if(typeof rs[target] != "function"){
38574 var p = rs[target].getPanel(panelId);
38584 * Searches all regions for a panel with the specified id and activates (shows) it.
38585 * @param {String/ContentPanel} panelId The panels id or the panel itself
38586 * @return {Roo.ContentPanel} The shown panel or null
38588 showPanel : function(panelId) {
38589 var rs = this.regions;
38590 for(var target in rs){
38591 var r = rs[target];
38592 if(typeof r != "function"){
38593 if(r.hasPanel(panelId)){
38594 return r.showPanel(panelId);
38602 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
38603 * @param {Roo.state.Provider} provider (optional) An alternate state provider
38606 restoreState : function(provider){
38608 provider = Roo.state.Manager;
38610 var sm = new Roo.LayoutStateManager();
38611 sm.init(this, provider);
38617 * Adds a xtype elements to the layout.
38621 xtype : 'ContentPanel',
38628 xtype : 'NestedLayoutPanel',
38634 items : [ ... list of content panels or nested layout panels.. ]
38638 * @param {Object} cfg Xtype definition of item to add.
38640 addxtype : function(cfg)
38642 // basically accepts a pannel...
38643 // can accept a layout region..!?!?
38644 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
38647 // theory? children can only be panels??
38649 //if (!cfg.xtype.match(/Panel$/)) {
38654 if (typeof(cfg.region) == 'undefined') {
38655 Roo.log("Failed to add Panel, region was not set");
38659 var region = cfg.region;
38665 xitems = cfg.items;
38670 if ( region == 'center') {
38671 Roo.log("Center: " + cfg.title);
38677 case 'Content': // ContentPanel (el, cfg)
38678 case 'Scroll': // ContentPanel (el, cfg)
38680 cfg.autoCreate = cfg.autoCreate || true;
38681 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
38683 // var el = this.el.createChild();
38684 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
38687 this.add(region, ret);
38691 case 'TreePanel': // our new panel!
38692 cfg.el = this.el.createChild();
38693 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
38694 this.add(region, ret);
38699 // create a new Layout (which is a Border Layout...
38701 var clayout = cfg.layout;
38702 clayout.el = this.el.createChild();
38703 clayout.items = clayout.items || [];
38707 // replace this exitems with the clayout ones..
38708 xitems = clayout.items;
38710 // force background off if it's in center...
38711 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
38712 cfg.background = false;
38714 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
38717 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
38718 //console.log('adding nested layout panel ' + cfg.toSource());
38719 this.add(region, ret);
38720 nb = {}; /// find first...
38725 // needs grid and region
38727 //var el = this.getRegion(region).el.createChild();
38729 *var el = this.el.createChild();
38730 // create the grid first...
38731 cfg.grid.container = el;
38732 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
38735 if (region == 'center' && this.active ) {
38736 cfg.background = false;
38739 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
38741 this.add(region, ret);
38743 if (cfg.background) {
38744 // render grid on panel activation (if panel background)
38745 ret.on('activate', function(gp) {
38746 if (!gp.grid.rendered) {
38747 // gp.grid.render(el);
38751 // cfg.grid.render(el);
38757 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
38758 // it was the old xcomponent building that caused this before.
38759 // espeically if border is the top element in the tree.
38769 if (typeof(Roo[cfg.xtype]) != 'undefined') {
38771 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
38772 this.add(region, ret);
38776 throw "Can not add '" + cfg.xtype + "' to Border";
38782 this.beginUpdate();
38786 Roo.each(xitems, function(i) {
38787 region = nb && i.region ? i.region : false;
38789 var add = ret.addxtype(i);
38792 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
38793 if (!i.background) {
38794 abn[region] = nb[region] ;
38801 // make the last non-background panel active..
38802 //if (nb) { Roo.log(abn); }
38805 for(var r in abn) {
38806 region = this.getRegion(r);
38808 // tried using nb[r], but it does not work..
38810 region.showPanel(abn[r]);
38821 factory : function(cfg)
38824 var validRegions = Roo.bootstrap.layout.Border.regions;
38826 var target = cfg.region;
38829 var r = Roo.bootstrap.layout;
38833 return new r.North(cfg);
38835 return new r.South(cfg);
38837 return new r.East(cfg);
38839 return new r.West(cfg);
38841 return new r.Center(cfg);
38843 throw 'Layout region "'+target+'" not supported.';
38850 * Ext JS Library 1.1.1
38851 * Copyright(c) 2006-2007, Ext JS, LLC.
38853 * Originally Released Under LGPL - original licence link has changed is not relivant.
38856 * <script type="text/javascript">
38860 * @class Roo.bootstrap.layout.Basic
38861 * @extends Roo.util.Observable
38862 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
38863 * and does not have a titlebar, tabs or any other features. All it does is size and position
38864 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
38865 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
38866 * @cfg {string} region the region that it inhabits..
38867 * @cfg {bool} skipConfig skip config?
38871 Roo.bootstrap.layout.Basic = function(config){
38873 this.mgr = config.mgr;
38875 this.position = config.region;
38877 var skipConfig = config.skipConfig;
38881 * @scope Roo.BasicLayoutRegion
38885 * @event beforeremove
38886 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
38887 * @param {Roo.LayoutRegion} this
38888 * @param {Roo.ContentPanel} panel The panel
38889 * @param {Object} e The cancel event object
38891 "beforeremove" : true,
38893 * @event invalidated
38894 * Fires when the layout for this region is changed.
38895 * @param {Roo.LayoutRegion} this
38897 "invalidated" : true,
38899 * @event visibilitychange
38900 * Fires when this region is shown or hidden
38901 * @param {Roo.LayoutRegion} this
38902 * @param {Boolean} visibility true or false
38904 "visibilitychange" : true,
38906 * @event paneladded
38907 * Fires when a panel is added.
38908 * @param {Roo.LayoutRegion} this
38909 * @param {Roo.ContentPanel} panel The panel
38911 "paneladded" : true,
38913 * @event panelremoved
38914 * Fires when a panel is removed.
38915 * @param {Roo.LayoutRegion} this
38916 * @param {Roo.ContentPanel} panel The panel
38918 "panelremoved" : true,
38920 * @event beforecollapse
38921 * Fires when this region before collapse.
38922 * @param {Roo.LayoutRegion} this
38924 "beforecollapse" : true,
38927 * Fires when this region is collapsed.
38928 * @param {Roo.LayoutRegion} this
38930 "collapsed" : true,
38933 * Fires when this region is expanded.
38934 * @param {Roo.LayoutRegion} this
38939 * Fires when this region is slid into view.
38940 * @param {Roo.LayoutRegion} this
38942 "slideshow" : true,
38945 * Fires when this region slides out of view.
38946 * @param {Roo.LayoutRegion} this
38948 "slidehide" : true,
38950 * @event panelactivated
38951 * Fires when a panel is activated.
38952 * @param {Roo.LayoutRegion} this
38953 * @param {Roo.ContentPanel} panel The activated panel
38955 "panelactivated" : true,
38958 * Fires when the user resizes this region.
38959 * @param {Roo.LayoutRegion} this
38960 * @param {Number} newSize The new size (width for east/west, height for north/south)
38964 /** A collection of panels in this region. @type Roo.util.MixedCollection */
38965 this.panels = new Roo.util.MixedCollection();
38966 this.panels.getKey = this.getPanelId.createDelegate(this);
38968 this.activePanel = null;
38969 // ensure listeners are added...
38971 if (config.listeners || config.events) {
38972 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
38973 listeners : config.listeners || {},
38974 events : config.events || {}
38978 if(skipConfig !== true){
38979 this.applyConfig(config);
38983 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
38985 getPanelId : function(p){
38989 applyConfig : function(config){
38990 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
38991 this.config = config;
38996 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
38997 * the width, for horizontal (north, south) the height.
38998 * @param {Number} newSize The new width or height
39000 resizeTo : function(newSize){
39001 var el = this.el ? this.el :
39002 (this.activePanel ? this.activePanel.getEl() : null);
39004 switch(this.position){
39007 el.setWidth(newSize);
39008 this.fireEvent("resized", this, newSize);
39012 el.setHeight(newSize);
39013 this.fireEvent("resized", this, newSize);
39019 getBox : function(){
39020 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
39023 getMargins : function(){
39024 return this.margins;
39027 updateBox : function(box){
39029 var el = this.activePanel.getEl();
39030 el.dom.style.left = box.x + "px";
39031 el.dom.style.top = box.y + "px";
39032 this.activePanel.setSize(box.width, box.height);
39036 * Returns the container element for this region.
39037 * @return {Roo.Element}
39039 getEl : function(){
39040 return this.activePanel;
39044 * Returns true if this region is currently visible.
39045 * @return {Boolean}
39047 isVisible : function(){
39048 return this.activePanel ? true : false;
39051 setActivePanel : function(panel){
39052 panel = this.getPanel(panel);
39053 if(this.activePanel && this.activePanel != panel){
39054 this.activePanel.setActiveState(false);
39055 this.activePanel.getEl().setLeftTop(-10000,-10000);
39057 this.activePanel = panel;
39058 panel.setActiveState(true);
39060 panel.setSize(this.box.width, this.box.height);
39062 this.fireEvent("panelactivated", this, panel);
39063 this.fireEvent("invalidated");
39067 * Show the specified panel.
39068 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
39069 * @return {Roo.ContentPanel} The shown panel or null
39071 showPanel : function(panel){
39072 panel = this.getPanel(panel);
39074 this.setActivePanel(panel);
39080 * Get the active panel for this region.
39081 * @return {Roo.ContentPanel} The active panel or null
39083 getActivePanel : function(){
39084 return this.activePanel;
39088 * Add the passed ContentPanel(s)
39089 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
39090 * @return {Roo.ContentPanel} The panel added (if only one was added)
39092 add : function(panel){
39093 if(arguments.length > 1){
39094 for(var i = 0, len = arguments.length; i < len; i++) {
39095 this.add(arguments[i]);
39099 if(this.hasPanel(panel)){
39100 this.showPanel(panel);
39103 var el = panel.getEl();
39104 if(el.dom.parentNode != this.mgr.el.dom){
39105 this.mgr.el.dom.appendChild(el.dom);
39107 if(panel.setRegion){
39108 panel.setRegion(this);
39110 this.panels.add(panel);
39111 el.setStyle("position", "absolute");
39112 if(!panel.background){
39113 this.setActivePanel(panel);
39114 if(this.config.initialSize && this.panels.getCount()==1){
39115 this.resizeTo(this.config.initialSize);
39118 this.fireEvent("paneladded", this, panel);
39123 * Returns true if the panel is in this region.
39124 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
39125 * @return {Boolean}
39127 hasPanel : function(panel){
39128 if(typeof panel == "object"){ // must be panel obj
39129 panel = panel.getId();
39131 return this.getPanel(panel) ? true : false;
39135 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
39136 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
39137 * @param {Boolean} preservePanel Overrides the config preservePanel option
39138 * @return {Roo.ContentPanel} The panel that was removed
39140 remove : function(panel, preservePanel){
39141 panel = this.getPanel(panel);
39146 this.fireEvent("beforeremove", this, panel, e);
39147 if(e.cancel === true){
39150 var panelId = panel.getId();
39151 this.panels.removeKey(panelId);
39156 * Returns the panel specified or null if it's not in this region.
39157 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
39158 * @return {Roo.ContentPanel}
39160 getPanel : function(id){
39161 if(typeof id == "object"){ // must be panel obj
39164 return this.panels.get(id);
39168 * Returns this regions position (north/south/east/west/center).
39171 getPosition: function(){
39172 return this.position;
39176 * Ext JS Library 1.1.1
39177 * Copyright(c) 2006-2007, Ext JS, LLC.
39179 * Originally Released Under LGPL - original licence link has changed is not relivant.
39182 * <script type="text/javascript">
39186 * @class Roo.bootstrap.layout.Region
39187 * @extends Roo.bootstrap.layout.Basic
39188 * This class represents a region in a layout manager.
39190 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
39191 * @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})
39192 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
39193 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
39194 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
39195 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
39196 * @cfg {String} title The title for the region (overrides panel titles)
39197 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
39198 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
39199 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
39200 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
39201 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
39202 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
39203 * the space available, similar to FireFox 1.5 tabs (defaults to false)
39204 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
39205 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
39206 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
39208 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
39209 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
39210 * @cfg {Boolean} disableTabTips True to disable tab tooltips
39211 * @cfg {Number} width For East/West panels
39212 * @cfg {Number} height For North/South panels
39213 * @cfg {Boolean} split To show the splitter
39214 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
39216 * @cfg {string} cls Extra CSS classes to add to region
39218 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
39219 * @cfg {string} region the region that it inhabits..
39222 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
39223 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
39225 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
39226 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
39227 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
39229 Roo.bootstrap.layout.Region = function(config)
39231 this.applyConfig(config);
39233 var mgr = config.mgr;
39234 var pos = config.region;
39235 config.skipConfig = true;
39236 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
39239 this.onRender(mgr.el);
39242 this.visible = true;
39243 this.collapsed = false;
39244 this.unrendered_panels = [];
39247 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
39249 position: '', // set by wrapper (eg. north/south etc..)
39250 unrendered_panels : null, // unrendered panels.
39252 tabPosition : false,
39254 mgr: false, // points to 'Border'
39257 createBody : function(){
39258 /** This region's body element
39259 * @type Roo.Element */
39260 this.bodyEl = this.el.createChild({
39262 cls: "roo-layout-panel-body tab-content" // bootstrap added...
39266 onRender: function(ctr, pos)
39268 var dh = Roo.DomHelper;
39269 /** This region's container element
39270 * @type Roo.Element */
39271 this.el = dh.append(ctr.dom, {
39273 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
39275 /** This region's title element
39276 * @type Roo.Element */
39278 this.titleEl = dh.append(this.el.dom, {
39280 unselectable: "on",
39281 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
39283 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
39284 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
39288 this.titleEl.enableDisplayMode();
39289 /** This region's title text element
39290 * @type HTMLElement */
39291 this.titleTextEl = this.titleEl.dom.firstChild;
39292 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
39294 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
39295 this.closeBtn.enableDisplayMode();
39296 this.closeBtn.on("click", this.closeClicked, this);
39297 this.closeBtn.hide();
39299 this.createBody(this.config);
39300 if(this.config.hideWhenEmpty){
39302 this.on("paneladded", this.validateVisibility, this);
39303 this.on("panelremoved", this.validateVisibility, this);
39305 if(this.autoScroll){
39306 this.bodyEl.setStyle("overflow", "auto");
39308 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
39310 //if(c.titlebar !== false){
39311 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
39312 this.titleEl.hide();
39314 this.titleEl.show();
39315 if(this.config.title){
39316 this.titleTextEl.innerHTML = this.config.title;
39320 if(this.config.collapsed){
39321 this.collapse(true);
39323 if(this.config.hidden){
39327 if (this.unrendered_panels && this.unrendered_panels.length) {
39328 for (var i =0;i< this.unrendered_panels.length; i++) {
39329 this.add(this.unrendered_panels[i]);
39331 this.unrendered_panels = null;
39337 applyConfig : function(c)
39340 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
39341 var dh = Roo.DomHelper;
39342 if(c.titlebar !== false){
39343 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
39344 this.collapseBtn.on("click", this.collapse, this);
39345 this.collapseBtn.enableDisplayMode();
39347 if(c.showPin === true || this.showPin){
39348 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
39349 this.stickBtn.enableDisplayMode();
39350 this.stickBtn.on("click", this.expand, this);
39351 this.stickBtn.hide();
39356 /** This region's collapsed element
39357 * @type Roo.Element */
39360 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
39361 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
39364 if(c.floatable !== false){
39365 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
39366 this.collapsedEl.on("click", this.collapseClick, this);
39369 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
39370 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
39371 id: "message", unselectable: "on", style:{"float":"left"}});
39372 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
39374 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
39375 this.expandBtn.on("click", this.expand, this);
39379 if(this.collapseBtn){
39380 this.collapseBtn.setVisible(c.collapsible == true);
39383 this.cmargins = c.cmargins || this.cmargins ||
39384 (this.position == "west" || this.position == "east" ?
39385 {top: 0, left: 2, right:2, bottom: 0} :
39386 {top: 2, left: 0, right:0, bottom: 2});
39388 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
39391 this.tabPosition = [ 'top','bottom', 'west'].indexOf(c.tabPosition) > -1 ? c.tabPosition : "top";
39393 this.autoScroll = c.autoScroll || false;
39398 this.duration = c.duration || .30;
39399 this.slideDuration = c.slideDuration || .45;
39404 * Returns true if this region is currently visible.
39405 * @return {Boolean}
39407 isVisible : function(){
39408 return this.visible;
39412 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
39413 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
39415 //setCollapsedTitle : function(title){
39416 // title = title || " ";
39417 // if(this.collapsedTitleTextEl){
39418 // this.collapsedTitleTextEl.innerHTML = title;
39422 getBox : function(){
39424 // if(!this.collapsed){
39425 b = this.el.getBox(false, true);
39427 // b = this.collapsedEl.getBox(false, true);
39432 getMargins : function(){
39433 return this.margins;
39434 //return this.collapsed ? this.cmargins : this.margins;
39437 highlight : function(){
39438 this.el.addClass("x-layout-panel-dragover");
39441 unhighlight : function(){
39442 this.el.removeClass("x-layout-panel-dragover");
39445 updateBox : function(box)
39447 if (!this.bodyEl) {
39448 return; // not rendered yet..
39452 if(!this.collapsed){
39453 this.el.dom.style.left = box.x + "px";
39454 this.el.dom.style.top = box.y + "px";
39455 this.updateBody(box.width, box.height);
39457 this.collapsedEl.dom.style.left = box.x + "px";
39458 this.collapsedEl.dom.style.top = box.y + "px";
39459 this.collapsedEl.setSize(box.width, box.height);
39462 this.tabs.autoSizeTabs();
39466 updateBody : function(w, h)
39469 this.el.setWidth(w);
39470 w -= this.el.getBorderWidth("rl");
39471 if(this.config.adjustments){
39472 w += this.config.adjustments[0];
39475 if(h !== null && h > 0){
39476 this.el.setHeight(h);
39477 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
39478 h -= this.el.getBorderWidth("tb");
39479 if(this.config.adjustments){
39480 h += this.config.adjustments[1];
39482 this.bodyEl.setHeight(h);
39484 h = this.tabs.syncHeight(h);
39487 if(this.panelSize){
39488 w = w !== null ? w : this.panelSize.width;
39489 h = h !== null ? h : this.panelSize.height;
39491 if(this.activePanel){
39492 var el = this.activePanel.getEl();
39493 w = w !== null ? w : el.getWidth();
39494 h = h !== null ? h : el.getHeight();
39495 this.panelSize = {width: w, height: h};
39496 this.activePanel.setSize(w, h);
39498 if(Roo.isIE && this.tabs){
39499 this.tabs.el.repaint();
39504 * Returns the container element for this region.
39505 * @return {Roo.Element}
39507 getEl : function(){
39512 * Hides this region.
39515 //if(!this.collapsed){
39516 this.el.dom.style.left = "-2000px";
39519 // this.collapsedEl.dom.style.left = "-2000px";
39520 // this.collapsedEl.hide();
39522 this.visible = false;
39523 this.fireEvent("visibilitychange", this, false);
39527 * Shows this region if it was previously hidden.
39530 //if(!this.collapsed){
39533 // this.collapsedEl.show();
39535 this.visible = true;
39536 this.fireEvent("visibilitychange", this, true);
39539 closeClicked : function(){
39540 if(this.activePanel){
39541 this.remove(this.activePanel);
39545 collapseClick : function(e){
39547 e.stopPropagation();
39550 e.stopPropagation();
39556 * Collapses this region.
39557 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
39560 collapse : function(skipAnim, skipCheck = false){
39561 if(this.collapsed) {
39565 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
39567 this.collapsed = true;
39569 this.split.el.hide();
39571 if(this.config.animate && skipAnim !== true){
39572 this.fireEvent("invalidated", this);
39573 this.animateCollapse();
39575 this.el.setLocation(-20000,-20000);
39577 this.collapsedEl.show();
39578 this.fireEvent("collapsed", this);
39579 this.fireEvent("invalidated", this);
39585 animateCollapse : function(){
39590 * Expands this region if it was previously collapsed.
39591 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
39592 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
39595 expand : function(e, skipAnim){
39597 e.stopPropagation();
39599 if(!this.collapsed || this.el.hasActiveFx()) {
39603 this.afterSlideIn();
39606 this.collapsed = false;
39607 if(this.config.animate && skipAnim !== true){
39608 this.animateExpand();
39612 this.split.el.show();
39614 this.collapsedEl.setLocation(-2000,-2000);
39615 this.collapsedEl.hide();
39616 this.fireEvent("invalidated", this);
39617 this.fireEvent("expanded", this);
39621 animateExpand : function(){
39625 initTabs : function()
39627 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
39629 var ts = new Roo.bootstrap.panel.Tabs({
39630 el: this.bodyEl.dom,
39632 tabPosition: this.tabPosition ? this.tabPosition : 'top',
39633 disableTooltips: this.config.disableTabTips,
39634 toolbar : this.config.toolbar
39637 if(this.config.hideTabs){
39638 ts.stripWrap.setDisplayed(false);
39641 ts.resizeTabs = this.config.resizeTabs === true;
39642 ts.minTabWidth = this.config.minTabWidth || 40;
39643 ts.maxTabWidth = this.config.maxTabWidth || 250;
39644 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
39645 ts.monitorResize = false;
39646 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
39647 ts.bodyEl.addClass('roo-layout-tabs-body');
39648 this.panels.each(this.initPanelAsTab, this);
39651 initPanelAsTab : function(panel){
39652 var ti = this.tabs.addTab(
39656 this.config.closeOnTab && panel.isClosable(),
39659 if(panel.tabTip !== undefined){
39660 ti.setTooltip(panel.tabTip);
39662 ti.on("activate", function(){
39663 this.setActivePanel(panel);
39666 if(this.config.closeOnTab){
39667 ti.on("beforeclose", function(t, e){
39669 this.remove(panel);
39673 panel.tabItem = ti;
39678 updatePanelTitle : function(panel, title)
39680 if(this.activePanel == panel){
39681 this.updateTitle(title);
39684 var ti = this.tabs.getTab(panel.getEl().id);
39686 if(panel.tabTip !== undefined){
39687 ti.setTooltip(panel.tabTip);
39692 updateTitle : function(title){
39693 if(this.titleTextEl && !this.config.title){
39694 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
39698 setActivePanel : function(panel)
39700 panel = this.getPanel(panel);
39701 if(this.activePanel && this.activePanel != panel){
39702 if(this.activePanel.setActiveState(false) === false){
39706 this.activePanel = panel;
39707 panel.setActiveState(true);
39708 if(this.panelSize){
39709 panel.setSize(this.panelSize.width, this.panelSize.height);
39712 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
39714 this.updateTitle(panel.getTitle());
39716 this.fireEvent("invalidated", this);
39718 this.fireEvent("panelactivated", this, panel);
39722 * Shows the specified panel.
39723 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
39724 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
39726 showPanel : function(panel)
39728 panel = this.getPanel(panel);
39731 var tab = this.tabs.getTab(panel.getEl().id);
39732 if(tab.isHidden()){
39733 this.tabs.unhideTab(tab.id);
39737 this.setActivePanel(panel);
39744 * Get the active panel for this region.
39745 * @return {Roo.ContentPanel} The active panel or null
39747 getActivePanel : function(){
39748 return this.activePanel;
39751 validateVisibility : function(){
39752 if(this.panels.getCount() < 1){
39753 this.updateTitle(" ");
39754 this.closeBtn.hide();
39757 if(!this.isVisible()){
39764 * Adds the passed ContentPanel(s) to this region.
39765 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
39766 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
39768 add : function(panel)
39770 if(arguments.length > 1){
39771 for(var i = 0, len = arguments.length; i < len; i++) {
39772 this.add(arguments[i]);
39777 // if we have not been rendered yet, then we can not really do much of this..
39778 if (!this.bodyEl) {
39779 this.unrendered_panels.push(panel);
39786 if(this.hasPanel(panel)){
39787 this.showPanel(panel);
39790 panel.setRegion(this);
39791 this.panels.add(panel);
39792 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
39793 // sinle panel - no tab...?? would it not be better to render it with the tabs,
39794 // and hide them... ???
39795 this.bodyEl.dom.appendChild(panel.getEl().dom);
39796 if(panel.background !== true){
39797 this.setActivePanel(panel);
39799 this.fireEvent("paneladded", this, panel);
39806 this.initPanelAsTab(panel);
39810 if(panel.background !== true){
39811 this.tabs.activate(panel.getEl().id);
39813 this.fireEvent("paneladded", this, panel);
39818 * Hides the tab for the specified panel.
39819 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
39821 hidePanel : function(panel){
39822 if(this.tabs && (panel = this.getPanel(panel))){
39823 this.tabs.hideTab(panel.getEl().id);
39828 * Unhides the tab for a previously hidden panel.
39829 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
39831 unhidePanel : function(panel){
39832 if(this.tabs && (panel = this.getPanel(panel))){
39833 this.tabs.unhideTab(panel.getEl().id);
39837 clearPanels : function(){
39838 while(this.panels.getCount() > 0){
39839 this.remove(this.panels.first());
39844 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
39845 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
39846 * @param {Boolean} preservePanel Overrides the config preservePanel option
39847 * @return {Roo.ContentPanel} The panel that was removed
39849 remove : function(panel, preservePanel)
39851 panel = this.getPanel(panel);
39856 this.fireEvent("beforeremove", this, panel, e);
39857 if(e.cancel === true){
39860 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
39861 var panelId = panel.getId();
39862 this.panels.removeKey(panelId);
39864 document.body.appendChild(panel.getEl().dom);
39867 this.tabs.removeTab(panel.getEl().id);
39868 }else if (!preservePanel){
39869 this.bodyEl.dom.removeChild(panel.getEl().dom);
39871 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
39872 var p = this.panels.first();
39873 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
39874 tempEl.appendChild(p.getEl().dom);
39875 this.bodyEl.update("");
39876 this.bodyEl.dom.appendChild(p.getEl().dom);
39878 this.updateTitle(p.getTitle());
39880 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
39881 this.setActivePanel(p);
39883 panel.setRegion(null);
39884 if(this.activePanel == panel){
39885 this.activePanel = null;
39887 if(this.config.autoDestroy !== false && preservePanel !== true){
39888 try{panel.destroy();}catch(e){}
39890 this.fireEvent("panelremoved", this, panel);
39895 * Returns the TabPanel component used by this region
39896 * @return {Roo.TabPanel}
39898 getTabs : function(){
39902 createTool : function(parentEl, className){
39903 var btn = Roo.DomHelper.append(parentEl, {
39905 cls: "x-layout-tools-button",
39908 cls: "roo-layout-tools-button-inner " + className,
39912 btn.addClassOnOver("roo-layout-tools-button-over");
39917 * Ext JS Library 1.1.1
39918 * Copyright(c) 2006-2007, Ext JS, LLC.
39920 * Originally Released Under LGPL - original licence link has changed is not relivant.
39923 * <script type="text/javascript">
39929 * @class Roo.SplitLayoutRegion
39930 * @extends Roo.LayoutRegion
39931 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
39933 Roo.bootstrap.layout.Split = function(config){
39934 this.cursor = config.cursor;
39935 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
39938 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
39940 splitTip : "Drag to resize.",
39941 collapsibleSplitTip : "Drag to resize. Double click to hide.",
39942 useSplitTips : false,
39944 applyConfig : function(config){
39945 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
39948 onRender : function(ctr,pos) {
39950 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
39951 if(!this.config.split){
39956 var splitEl = Roo.DomHelper.append(ctr.dom, {
39958 id: this.el.id + "-split",
39959 cls: "roo-layout-split roo-layout-split-"+this.position,
39962 /** The SplitBar for this region
39963 * @type Roo.SplitBar */
39964 // does not exist yet...
39965 Roo.log([this.position, this.orientation]);
39967 this.split = new Roo.bootstrap.SplitBar({
39968 dragElement : splitEl,
39969 resizingElement: this.el,
39970 orientation : this.orientation
39973 this.split.on("moved", this.onSplitMove, this);
39974 this.split.useShim = this.config.useShim === true;
39975 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
39976 if(this.useSplitTips){
39977 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
39979 //if(config.collapsible){
39980 // this.split.el.on("dblclick", this.collapse, this);
39983 if(typeof this.config.minSize != "undefined"){
39984 this.split.minSize = this.config.minSize;
39986 if(typeof this.config.maxSize != "undefined"){
39987 this.split.maxSize = this.config.maxSize;
39989 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
39990 this.hideSplitter();
39995 getHMaxSize : function(){
39996 var cmax = this.config.maxSize || 10000;
39997 var center = this.mgr.getRegion("center");
39998 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
40001 getVMaxSize : function(){
40002 var cmax = this.config.maxSize || 10000;
40003 var center = this.mgr.getRegion("center");
40004 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
40007 onSplitMove : function(split, newSize){
40008 this.fireEvent("resized", this, newSize);
40012 * Returns the {@link Roo.SplitBar} for this region.
40013 * @return {Roo.SplitBar}
40015 getSplitBar : function(){
40020 this.hideSplitter();
40021 Roo.bootstrap.layout.Split.superclass.hide.call(this);
40024 hideSplitter : function(){
40026 this.split.el.setLocation(-2000,-2000);
40027 this.split.el.hide();
40033 this.split.el.show();
40035 Roo.bootstrap.layout.Split.superclass.show.call(this);
40038 beforeSlide: function(){
40039 if(Roo.isGecko){// firefox overflow auto bug workaround
40040 this.bodyEl.clip();
40042 this.tabs.bodyEl.clip();
40044 if(this.activePanel){
40045 this.activePanel.getEl().clip();
40047 if(this.activePanel.beforeSlide){
40048 this.activePanel.beforeSlide();
40054 afterSlide : function(){
40055 if(Roo.isGecko){// firefox overflow auto bug workaround
40056 this.bodyEl.unclip();
40058 this.tabs.bodyEl.unclip();
40060 if(this.activePanel){
40061 this.activePanel.getEl().unclip();
40062 if(this.activePanel.afterSlide){
40063 this.activePanel.afterSlide();
40069 initAutoHide : function(){
40070 if(this.autoHide !== false){
40071 if(!this.autoHideHd){
40072 var st = new Roo.util.DelayedTask(this.slideIn, this);
40073 this.autoHideHd = {
40074 "mouseout": function(e){
40075 if(!e.within(this.el, true)){
40079 "mouseover" : function(e){
40085 this.el.on(this.autoHideHd);
40089 clearAutoHide : function(){
40090 if(this.autoHide !== false){
40091 this.el.un("mouseout", this.autoHideHd.mouseout);
40092 this.el.un("mouseover", this.autoHideHd.mouseover);
40096 clearMonitor : function(){
40097 Roo.get(document).un("click", this.slideInIf, this);
40100 // these names are backwards but not changed for compat
40101 slideOut : function(){
40102 if(this.isSlid || this.el.hasActiveFx()){
40105 this.isSlid = true;
40106 if(this.collapseBtn){
40107 this.collapseBtn.hide();
40109 this.closeBtnState = this.closeBtn.getStyle('display');
40110 this.closeBtn.hide();
40112 this.stickBtn.show();
40115 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
40116 this.beforeSlide();
40117 this.el.setStyle("z-index", 10001);
40118 this.el.slideIn(this.getSlideAnchor(), {
40119 callback: function(){
40121 this.initAutoHide();
40122 Roo.get(document).on("click", this.slideInIf, this);
40123 this.fireEvent("slideshow", this);
40130 afterSlideIn : function(){
40131 this.clearAutoHide();
40132 this.isSlid = false;
40133 this.clearMonitor();
40134 this.el.setStyle("z-index", "");
40135 if(this.collapseBtn){
40136 this.collapseBtn.show();
40138 this.closeBtn.setStyle('display', this.closeBtnState);
40140 this.stickBtn.hide();
40142 this.fireEvent("slidehide", this);
40145 slideIn : function(cb){
40146 if(!this.isSlid || this.el.hasActiveFx()){
40150 this.isSlid = false;
40151 this.beforeSlide();
40152 this.el.slideOut(this.getSlideAnchor(), {
40153 callback: function(){
40154 this.el.setLeftTop(-10000, -10000);
40156 this.afterSlideIn();
40164 slideInIf : function(e){
40165 if(!e.within(this.el)){
40170 animateCollapse : function(){
40171 this.beforeSlide();
40172 this.el.setStyle("z-index", 20000);
40173 var anchor = this.getSlideAnchor();
40174 this.el.slideOut(anchor, {
40175 callback : function(){
40176 this.el.setStyle("z-index", "");
40177 this.collapsedEl.slideIn(anchor, {duration:.3});
40179 this.el.setLocation(-10000,-10000);
40181 this.fireEvent("collapsed", this);
40188 animateExpand : function(){
40189 this.beforeSlide();
40190 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
40191 this.el.setStyle("z-index", 20000);
40192 this.collapsedEl.hide({
40195 this.el.slideIn(this.getSlideAnchor(), {
40196 callback : function(){
40197 this.el.setStyle("z-index", "");
40200 this.split.el.show();
40202 this.fireEvent("invalidated", this);
40203 this.fireEvent("expanded", this);
40231 getAnchor : function(){
40232 return this.anchors[this.position];
40235 getCollapseAnchor : function(){
40236 return this.canchors[this.position];
40239 getSlideAnchor : function(){
40240 return this.sanchors[this.position];
40243 getAlignAdj : function(){
40244 var cm = this.cmargins;
40245 switch(this.position){
40261 getExpandAdj : function(){
40262 var c = this.collapsedEl, cm = this.cmargins;
40263 switch(this.position){
40265 return [-(cm.right+c.getWidth()+cm.left), 0];
40268 return [cm.right+c.getWidth()+cm.left, 0];
40271 return [0, -(cm.top+cm.bottom+c.getHeight())];
40274 return [0, cm.top+cm.bottom+c.getHeight()];
40280 * Ext JS Library 1.1.1
40281 * Copyright(c) 2006-2007, Ext JS, LLC.
40283 * Originally Released Under LGPL - original licence link has changed is not relivant.
40286 * <script type="text/javascript">
40289 * These classes are private internal classes
40291 Roo.bootstrap.layout.Center = function(config){
40292 config.region = "center";
40293 Roo.bootstrap.layout.Region.call(this, config);
40294 this.visible = true;
40295 this.minWidth = config.minWidth || 20;
40296 this.minHeight = config.minHeight || 20;
40299 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
40301 // center panel can't be hidden
40305 // center panel can't be hidden
40308 getMinWidth: function(){
40309 return this.minWidth;
40312 getMinHeight: function(){
40313 return this.minHeight;
40327 Roo.bootstrap.layout.North = function(config)
40329 config.region = 'north';
40330 config.cursor = 'n-resize';
40332 Roo.bootstrap.layout.Split.call(this, config);
40336 this.split.placement = Roo.bootstrap.SplitBar.TOP;
40337 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
40338 this.split.el.addClass("roo-layout-split-v");
40340 //var size = config.initialSize || config.height;
40341 //if(this.el && typeof size != "undefined"){
40342 // this.el.setHeight(size);
40345 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
40347 orientation: Roo.bootstrap.SplitBar.VERTICAL,
40350 onRender : function(ctr, pos)
40352 Roo.bootstrap.layout.Split.prototype.onRender.call(this, ctr, pos);
40353 var size = this.config.initialSize || this.config.height;
40354 if(this.el && typeof size != "undefined"){
40355 this.el.setHeight(size);
40360 getBox : function(){
40361 if(this.collapsed){
40362 return this.collapsedEl.getBox();
40364 var box = this.el.getBox();
40366 box.height += this.split.el.getHeight();
40371 updateBox : function(box){
40372 if(this.split && !this.collapsed){
40373 box.height -= this.split.el.getHeight();
40374 this.split.el.setLeft(box.x);
40375 this.split.el.setTop(box.y+box.height);
40376 this.split.el.setWidth(box.width);
40378 if(this.collapsed){
40379 this.updateBody(box.width, null);
40381 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
40389 Roo.bootstrap.layout.South = function(config){
40390 config.region = 'south';
40391 config.cursor = 's-resize';
40392 Roo.bootstrap.layout.Split.call(this, config);
40394 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
40395 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
40396 this.split.el.addClass("roo-layout-split-v");
40401 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
40402 orientation: Roo.bootstrap.SplitBar.VERTICAL,
40404 onRender : function(ctr, pos)
40406 Roo.bootstrap.layout.Split.prototype.onRender.call(this, ctr, pos);
40407 var size = this.config.initialSize || this.config.height;
40408 if(this.el && typeof size != "undefined"){
40409 this.el.setHeight(size);
40414 getBox : function(){
40415 if(this.collapsed){
40416 return this.collapsedEl.getBox();
40418 var box = this.el.getBox();
40420 var sh = this.split.el.getHeight();
40427 updateBox : function(box){
40428 if(this.split && !this.collapsed){
40429 var sh = this.split.el.getHeight();
40432 this.split.el.setLeft(box.x);
40433 this.split.el.setTop(box.y-sh);
40434 this.split.el.setWidth(box.width);
40436 if(this.collapsed){
40437 this.updateBody(box.width, null);
40439 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
40443 Roo.bootstrap.layout.East = function(config){
40444 config.region = "east";
40445 config.cursor = "e-resize";
40446 Roo.bootstrap.layout.Split.call(this, config);
40448 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
40449 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
40450 this.split.el.addClass("roo-layout-split-h");
40454 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
40455 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
40457 onRender : function(ctr, pos)
40459 Roo.bootstrap.layout.Split.prototype.onRender.call(this, ctr, pos);
40460 var size = this.config.initialSize || this.config.width;
40461 if(this.el && typeof size != "undefined"){
40462 this.el.setWidth(size);
40467 getBox : function(){
40468 if(this.collapsed){
40469 return this.collapsedEl.getBox();
40471 var box = this.el.getBox();
40473 var sw = this.split.el.getWidth();
40480 updateBox : function(box){
40481 if(this.split && !this.collapsed){
40482 var sw = this.split.el.getWidth();
40484 this.split.el.setLeft(box.x);
40485 this.split.el.setTop(box.y);
40486 this.split.el.setHeight(box.height);
40489 if(this.collapsed){
40490 this.updateBody(null, box.height);
40492 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
40496 Roo.bootstrap.layout.West = function(config){
40497 config.region = "west";
40498 config.cursor = "w-resize";
40500 Roo.bootstrap.layout.Split.call(this, config);
40502 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
40503 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
40504 this.split.el.addClass("roo-layout-split-h");
40508 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
40509 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
40511 onRender: function(ctr, pos)
40513 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
40514 var size = this.config.initialSize || this.config.width;
40515 if(typeof size != "undefined"){
40516 this.el.setWidth(size);
40520 getBox : function(){
40521 if(this.collapsed){
40522 return this.collapsedEl.getBox();
40524 var box = this.el.getBox();
40525 if (box.width == 0) {
40526 box.width = this.config.width; // kludge?
40529 box.width += this.split.el.getWidth();
40534 updateBox : function(box){
40535 if(this.split && !this.collapsed){
40536 var sw = this.split.el.getWidth();
40538 this.split.el.setLeft(box.x+box.width);
40539 this.split.el.setTop(box.y);
40540 this.split.el.setHeight(box.height);
40542 if(this.collapsed){
40543 this.updateBody(null, box.height);
40545 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
40547 });Roo.namespace("Roo.bootstrap.panel");/*
40549 * Ext JS Library 1.1.1
40550 * Copyright(c) 2006-2007, Ext JS, LLC.
40552 * Originally Released Under LGPL - original licence link has changed is not relivant.
40555 * <script type="text/javascript">
40558 * @class Roo.ContentPanel
40559 * @extends Roo.util.Observable
40561 * A basic ContentPanel element.
40562 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
40563 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
40564 * @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
40565 * @cfg {Boolean} closable True if the panel can be closed/removed
40566 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
40567 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
40568 * @cfg {Toolbar} toolbar A toolbar for this panel
40569 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
40570 * @cfg {String} title The title for this panel
40571 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
40572 * @cfg {String} url Calls {@link #setUrl} with this value
40573 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
40574 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
40575 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
40576 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
40577 * @cfg {Boolean} iframe contents are an iframe - makes showing remote sources/CSS feasible..
40578 * @cfg {Boolean} badges render the badges
40579 * @cfg {String} cls extra classes to use
40580 * @cfg {String} background (primary|secondary|success|info|warning|danger|light|dark)
40583 * Create a new ContentPanel.
40584 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
40585 * @param {String/Object} config A string to set only the title or a config object
40586 * @param {String} content (optional) Set the HTML content for this panel
40587 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
40589 Roo.bootstrap.panel.Content = function( config){
40591 this.tpl = config.tpl || false;
40593 var el = config.el;
40594 var content = config.content;
40596 if(config.autoCreate){ // xtype is available if this is called from factory
40599 this.el = Roo.get(el);
40600 if(!this.el && config && config.autoCreate){
40601 if(typeof config.autoCreate == "object"){
40602 if(!config.autoCreate.id){
40603 config.autoCreate.id = config.id||el;
40605 this.el = Roo.DomHelper.append(document.body,
40606 config.autoCreate, true);
40610 cls: (config.cls || '') +
40611 (config.background ? ' bg-' + config.background : '') +
40612 " roo-layout-inactive-content",
40615 if (config.iframe) {
40619 style : 'border: 0px',
40620 src : 'about:blank'
40626 elcfg.html = config.html;
40630 this.el = Roo.DomHelper.append(document.body, elcfg , true);
40631 if (config.iframe) {
40632 this.iframeEl = this.el.select('iframe',true).first();
40637 this.closable = false;
40638 this.loaded = false;
40639 this.active = false;
40642 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
40644 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
40646 this.wrapEl = this.el; //this.el.wrap();
40648 if (config.toolbar.items) {
40649 ti = config.toolbar.items ;
40650 delete config.toolbar.items ;
40654 this.toolbar.render(this.wrapEl, 'before');
40655 for(var i =0;i < ti.length;i++) {
40656 // Roo.log(['add child', items[i]]);
40657 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
40659 this.toolbar.items = nitems;
40660 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
40661 delete config.toolbar;
40665 // xtype created footer. - not sure if will work as we normally have to render first..
40666 if (this.footer && !this.footer.el && this.footer.xtype) {
40667 if (!this.wrapEl) {
40668 this.wrapEl = this.el.wrap();
40671 this.footer.container = this.wrapEl.createChild();
40673 this.footer = Roo.factory(this.footer, Roo);
40678 if(typeof config == "string"){
40679 this.title = config;
40681 Roo.apply(this, config);
40685 this.resizeEl = Roo.get(this.resizeEl, true);
40687 this.resizeEl = this.el;
40689 // handle view.xtype
40697 * Fires when this panel is activated.
40698 * @param {Roo.ContentPanel} this
40702 * @event deactivate
40703 * Fires when this panel is activated.
40704 * @param {Roo.ContentPanel} this
40706 "deactivate" : true,
40710 * Fires when this panel is resized if fitToFrame is true.
40711 * @param {Roo.ContentPanel} this
40712 * @param {Number} width The width after any component adjustments
40713 * @param {Number} height The height after any component adjustments
40719 * Fires when this tab is created
40720 * @param {Roo.ContentPanel} this
40726 * Fires when this content is scrolled
40727 * @param {Roo.ContentPanel} this
40728 * @param {Event} scrollEvent
40739 if(this.autoScroll && !this.iframe){
40740 this.resizeEl.setStyle("overflow", "auto");
40741 this.resizeEl.on('scroll', this.onScroll, this);
40743 // fix randome scrolling
40744 //this.el.on('scroll', function() {
40745 // Roo.log('fix random scolling');
40746 // this.scrollTo('top',0);
40749 content = content || this.content;
40751 this.setContent(content);
40753 if(config && config.url){
40754 this.setUrl(this.url, this.params, this.loadOnce);
40759 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
40761 if (this.view && typeof(this.view.xtype) != 'undefined') {
40762 this.view.el = this.el.appendChild(document.createElement("div"));
40763 this.view = Roo.factory(this.view);
40764 this.view.render && this.view.render(false, '');
40768 this.fireEvent('render', this);
40771 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
40781 /* Resize Element - use this to work out scroll etc. */
40784 setRegion : function(region){
40785 this.region = region;
40786 this.setActiveClass(region && !this.background);
40790 setActiveClass: function(state)
40793 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
40794 this.el.setStyle('position','relative');
40796 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
40797 this.el.setStyle('position', 'absolute');
40802 * Returns the toolbar for this Panel if one was configured.
40803 * @return {Roo.Toolbar}
40805 getToolbar : function(){
40806 return this.toolbar;
40809 setActiveState : function(active)
40811 this.active = active;
40812 this.setActiveClass(active);
40814 if(this.fireEvent("deactivate", this) === false){
40819 this.fireEvent("activate", this);
40823 * Updates this panel's element (not for iframe)
40824 * @param {String} content The new content
40825 * @param {Boolean} loadScripts (optional) true to look for and process scripts
40827 setContent : function(content, loadScripts){
40832 this.el.update(content, loadScripts);
40835 ignoreResize : function(w, h){
40836 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
40839 this.lastSize = {width: w, height: h};
40844 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
40845 * @return {Roo.UpdateManager} The UpdateManager
40847 getUpdateManager : function(){
40851 return this.el.getUpdateManager();
40854 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
40855 * Does not work with IFRAME contents
40856 * @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:
40859 url: "your-url.php",
40860 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
40861 callback: yourFunction,
40862 scope: yourObject, //(optional scope)
40865 text: "Loading...",
40871 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
40872 * 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.
40873 * @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}
40874 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
40875 * @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.
40876 * @return {Roo.ContentPanel} this
40884 var um = this.el.getUpdateManager();
40885 um.update.apply(um, arguments);
40891 * 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.
40892 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
40893 * @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)
40894 * @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)
40895 * @return {Roo.UpdateManager|Boolean} The UpdateManager or false if IFRAME
40897 setUrl : function(url, params, loadOnce){
40899 this.iframeEl.dom.src = url;
40903 if(this.refreshDelegate){
40904 this.removeListener("activate", this.refreshDelegate);
40906 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
40907 this.on("activate", this.refreshDelegate);
40908 return this.el.getUpdateManager();
40911 _handleRefresh : function(url, params, loadOnce){
40912 if(!loadOnce || !this.loaded){
40913 var updater = this.el.getUpdateManager();
40914 updater.update(url, params, this._setLoaded.createDelegate(this));
40918 _setLoaded : function(){
40919 this.loaded = true;
40923 * Returns this panel's id
40926 getId : function(){
40931 * Returns this panel's element - used by regiosn to add.
40932 * @return {Roo.Element}
40934 getEl : function(){
40935 return this.wrapEl || this.el;
40940 adjustForComponents : function(width, height)
40942 //Roo.log('adjustForComponents ');
40943 if(this.resizeEl != this.el){
40944 width -= this.el.getFrameWidth('lr');
40945 height -= this.el.getFrameWidth('tb');
40948 var te = this.toolbar.getEl();
40949 te.setWidth(width);
40950 height -= te.getHeight();
40953 var te = this.footer.getEl();
40954 te.setWidth(width);
40955 height -= te.getHeight();
40959 if(this.adjustments){
40960 width += this.adjustments[0];
40961 height += this.adjustments[1];
40963 return {"width": width, "height": height};
40966 setSize : function(width, height){
40967 if(this.fitToFrame && !this.ignoreResize(width, height)){
40968 if(this.fitContainer && this.resizeEl != this.el){
40969 this.el.setSize(width, height);
40971 var size = this.adjustForComponents(width, height);
40973 this.iframeEl.setSize(width,height);
40976 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
40977 this.fireEvent('resize', this, size.width, size.height);
40984 * Returns this panel's title
40987 getTitle : function(){
40989 if (typeof(this.title) != 'object') {
40994 for (var k in this.title) {
40995 if (!this.title.hasOwnProperty(k)) {
40999 if (k.indexOf('-') >= 0) {
41000 var s = k.split('-');
41001 for (var i = 0; i<s.length; i++) {
41002 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
41005 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
41012 * Set this panel's title
41013 * @param {String} title
41015 setTitle : function(title){
41016 this.title = title;
41018 this.region.updatePanelTitle(this, title);
41023 * Returns true is this panel was configured to be closable
41024 * @return {Boolean}
41026 isClosable : function(){
41027 return this.closable;
41030 beforeSlide : function(){
41032 this.resizeEl.clip();
41035 afterSlide : function(){
41037 this.resizeEl.unclip();
41041 * Force a content refresh from the URL specified in the {@link #setUrl} method.
41042 * Will fail silently if the {@link #setUrl} method has not been called.
41043 * This does not activate the panel, just updates its content.
41045 refresh : function(){
41046 if(this.refreshDelegate){
41047 this.loaded = false;
41048 this.refreshDelegate();
41053 * Destroys this panel
41055 destroy : function(){
41056 this.el.removeAllListeners();
41057 var tempEl = document.createElement("span");
41058 tempEl.appendChild(this.el.dom);
41059 tempEl.innerHTML = "";
41065 * form - if the content panel contains a form - this is a reference to it.
41066 * @type {Roo.form.Form}
41070 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
41071 * This contains a reference to it.
41077 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
41087 * @param {Object} cfg Xtype definition of item to add.
41091 getChildContainer: function () {
41092 return this.getEl();
41096 onScroll : function(e)
41098 this.fireEvent('scroll', this, e);
41103 var ret = new Roo.factory(cfg);
41108 if (cfg.xtype.match(/^Form$/)) {
41111 //if (this.footer) {
41112 // el = this.footer.container.insertSibling(false, 'before');
41114 el = this.el.createChild();
41117 this.form = new Roo.form.Form(cfg);
41120 if ( this.form.allItems.length) {
41121 this.form.render(el.dom);
41125 // should only have one of theses..
41126 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
41127 // views.. should not be just added - used named prop 'view''
41129 cfg.el = this.el.appendChild(document.createElement("div"));
41132 var ret = new Roo.factory(cfg);
41134 ret.render && ret.render(false, ''); // render blank..
41144 * @class Roo.bootstrap.panel.Grid
41145 * @extends Roo.bootstrap.panel.Content
41147 * Create a new GridPanel.
41148 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
41149 * @param {Object} config A the config object
41155 Roo.bootstrap.panel.Grid = function(config)
41159 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
41160 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
41162 config.el = this.wrapper;
41163 //this.el = this.wrapper;
41165 if (config.container) {
41166 // ctor'ed from a Border/panel.grid
41169 this.wrapper.setStyle("overflow", "hidden");
41170 this.wrapper.addClass('roo-grid-container');
41175 if(config.toolbar){
41176 var tool_el = this.wrapper.createChild();
41177 this.toolbar = Roo.factory(config.toolbar);
41179 if (config.toolbar.items) {
41180 ti = config.toolbar.items ;
41181 delete config.toolbar.items ;
41185 this.toolbar.render(tool_el);
41186 for(var i =0;i < ti.length;i++) {
41187 // Roo.log(['add child', items[i]]);
41188 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
41190 this.toolbar.items = nitems;
41192 delete config.toolbar;
41195 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
41196 config.grid.scrollBody = true;;
41197 config.grid.monitorWindowResize = false; // turn off autosizing
41198 config.grid.autoHeight = false;
41199 config.grid.autoWidth = false;
41201 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
41203 if (config.background) {
41204 // render grid on panel activation (if panel background)
41205 this.on('activate', function(gp) {
41206 if (!gp.grid.rendered) {
41207 gp.grid.render(this.wrapper);
41208 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
41213 this.grid.render(this.wrapper);
41214 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
41217 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
41218 // ??? needed ??? config.el = this.wrapper;
41223 // xtype created footer. - not sure if will work as we normally have to render first..
41224 if (this.footer && !this.footer.el && this.footer.xtype) {
41226 var ctr = this.grid.getView().getFooterPanel(true);
41227 this.footer.dataSource = this.grid.dataSource;
41228 this.footer = Roo.factory(this.footer, Roo);
41229 this.footer.render(ctr);
41239 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
41240 getId : function(){
41241 return this.grid.id;
41245 * Returns the grid for this panel
41246 * @return {Roo.bootstrap.Table}
41248 getGrid : function(){
41252 setSize : function(width, height){
41253 if(!this.ignoreResize(width, height)){
41254 var grid = this.grid;
41255 var size = this.adjustForComponents(width, height);
41256 // tfoot is not a footer?
41259 var gridel = grid.getGridEl();
41260 gridel.setSize(size.width, size.height);
41262 var tbd = grid.getGridEl().select('tbody', true).first();
41263 var thd = grid.getGridEl().select('thead',true).first();
41264 var tbf= grid.getGridEl().select('tfoot', true).first();
41267 size.height -= tbf.getHeight();
41270 size.height -= thd.getHeight();
41273 tbd.setSize(size.width, size.height );
41274 // this is for the account management tab -seems to work there.
41275 var thd = grid.getGridEl().select('thead',true).first();
41277 // tbd.setSize(size.width, size.height - thd.getHeight());
41286 beforeSlide : function(){
41287 this.grid.getView().scroller.clip();
41290 afterSlide : function(){
41291 this.grid.getView().scroller.unclip();
41294 destroy : function(){
41295 this.grid.destroy();
41297 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
41302 * @class Roo.bootstrap.panel.Nest
41303 * @extends Roo.bootstrap.panel.Content
41305 * Create a new Panel, that can contain a layout.Border.
41308 * @param {Roo.BorderLayout} layout The layout for this panel
41309 * @param {String/Object} config A string to set only the title or a config object
41311 Roo.bootstrap.panel.Nest = function(config)
41313 // construct with only one argument..
41314 /* FIXME - implement nicer consturctors
41315 if (layout.layout) {
41317 layout = config.layout;
41318 delete config.layout;
41320 if (layout.xtype && !layout.getEl) {
41321 // then layout needs constructing..
41322 layout = Roo.factory(layout, Roo);
41326 config.el = config.layout.getEl();
41328 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
41330 config.layout.monitorWindowResize = false; // turn off autosizing
41331 this.layout = config.layout;
41332 this.layout.getEl().addClass("roo-layout-nested-layout");
41333 this.layout.parent = this;
41340 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
41342 setSize : function(width, height){
41343 if(!this.ignoreResize(width, height)){
41344 var size = this.adjustForComponents(width, height);
41345 var el = this.layout.getEl();
41346 if (size.height < 1) {
41347 el.setWidth(size.width);
41349 el.setSize(size.width, size.height);
41351 var touch = el.dom.offsetWidth;
41352 this.layout.layout();
41353 // ie requires a double layout on the first pass
41354 if(Roo.isIE && !this.initialized){
41355 this.initialized = true;
41356 this.layout.layout();
41361 // activate all subpanels if not currently active..
41363 setActiveState : function(active){
41364 this.active = active;
41365 this.setActiveClass(active);
41368 this.fireEvent("deactivate", this);
41372 this.fireEvent("activate", this);
41373 // not sure if this should happen before or after..
41374 if (!this.layout) {
41375 return; // should not happen..
41378 for (var r in this.layout.regions) {
41379 reg = this.layout.getRegion(r);
41380 if (reg.getActivePanel()) {
41381 //reg.showPanel(reg.getActivePanel()); // force it to activate..
41382 reg.setActivePanel(reg.getActivePanel());
41385 if (!reg.panels.length) {
41388 reg.showPanel(reg.getPanel(0));
41397 * Returns the nested BorderLayout for this panel
41398 * @return {Roo.BorderLayout}
41400 getLayout : function(){
41401 return this.layout;
41405 * Adds a xtype elements to the layout of the nested panel
41409 xtype : 'ContentPanel',
41416 xtype : 'NestedLayoutPanel',
41422 items : [ ... list of content panels or nested layout panels.. ]
41426 * @param {Object} cfg Xtype definition of item to add.
41428 addxtype : function(cfg) {
41429 return this.layout.addxtype(cfg);
41434 * Ext JS Library 1.1.1
41435 * Copyright(c) 2006-2007, Ext JS, LLC.
41437 * Originally Released Under LGPL - original licence link has changed is not relivant.
41440 * <script type="text/javascript">
41443 * @class Roo.TabPanel
41444 * @extends Roo.util.Observable
41445 * A lightweight tab container.
41449 // basic tabs 1, built from existing content
41450 var tabs = new Roo.TabPanel("tabs1");
41451 tabs.addTab("script", "View Script");
41452 tabs.addTab("markup", "View Markup");
41453 tabs.activate("script");
41455 // more advanced tabs, built from javascript
41456 var jtabs = new Roo.TabPanel("jtabs");
41457 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
41459 // set up the UpdateManager
41460 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
41461 var updater = tab2.getUpdateManager();
41462 updater.setDefaultUrl("ajax1.htm");
41463 tab2.on('activate', updater.refresh, updater, true);
41465 // Use setUrl for Ajax loading
41466 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
41467 tab3.setUrl("ajax2.htm", null, true);
41470 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
41473 jtabs.activate("jtabs-1");
41476 * Create a new TabPanel.
41477 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
41478 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
41480 Roo.bootstrap.panel.Tabs = function(config){
41482 * The container element for this TabPanel.
41483 * @type Roo.Element
41485 this.el = Roo.get(config.el);
41488 if(typeof config == "boolean"){
41489 this.tabPosition = config ? "bottom" : "top";
41491 Roo.apply(this, config);
41495 if(this.tabPosition == "bottom"){
41496 // if tabs are at the bottom = create the body first.
41497 this.bodyEl = Roo.get(this.createBody(this.el.dom));
41498 this.el.addClass("roo-tabs-bottom");
41500 // next create the tabs holders
41502 if (this.tabPosition == "west"){
41504 var reg = this.region; // fake it..
41506 if (!reg.mgr.parent) {
41509 reg = reg.mgr.parent.region;
41511 Roo.log("got nest?");
41513 if (reg.mgr.getRegion('west')) {
41514 var ctrdom = reg.mgr.getRegion('west').bodyEl.dom;
41515 this.stripWrap = Roo.get(this.createStrip(ctrdom ), true);
41516 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
41517 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
41518 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
41526 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
41527 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
41528 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
41529 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
41534 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
41537 // finally - if tabs are at the top, then create the body last..
41538 if(this.tabPosition != "bottom"){
41539 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
41540 * @type Roo.Element
41542 this.bodyEl = Roo.get(this.createBody(this.el.dom));
41543 this.el.addClass("roo-tabs-top");
41547 this.bodyEl.setStyle("position", "relative");
41549 this.active = null;
41550 this.activateDelegate = this.activate.createDelegate(this);
41555 * Fires when the active tab changes
41556 * @param {Roo.TabPanel} this
41557 * @param {Roo.TabPanelItem} activePanel The new active tab
41561 * @event beforetabchange
41562 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
41563 * @param {Roo.TabPanel} this
41564 * @param {Object} e Set cancel to true on this object to cancel the tab change
41565 * @param {Roo.TabPanelItem} tab The tab being changed to
41567 "beforetabchange" : true
41570 Roo.EventManager.onWindowResize(this.onResize, this);
41571 this.cpad = this.el.getPadding("lr");
41572 this.hiddenCount = 0;
41575 // toolbar on the tabbar support...
41576 if (this.toolbar) {
41577 alert("no toolbar support yet");
41578 this.toolbar = false;
41580 var tcfg = this.toolbar;
41581 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
41582 this.toolbar = new Roo.Toolbar(tcfg);
41583 if (Roo.isSafari) {
41584 var tbl = tcfg.container.child('table', true);
41585 tbl.setAttribute('width', '100%');
41593 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
41596 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
41598 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
41600 tabPosition : "top",
41602 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
41604 currentTabWidth : 0,
41606 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
41610 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
41614 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
41616 preferredTabWidth : 175,
41618 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
41620 resizeTabs : false,
41622 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
41624 monitorResize : true,
41626 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
41628 toolbar : false, // set by caller..
41630 region : false, /// set by caller
41632 disableTooltips : true, // not used yet...
41635 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
41636 * @param {String} id The id of the div to use <b>or create</b>
41637 * @param {String} text The text for the tab
41638 * @param {String} content (optional) Content to put in the TabPanelItem body
41639 * @param {Boolean} closable (optional) True to create a close icon on the tab
41640 * @return {Roo.TabPanelItem} The created TabPanelItem
41642 addTab : function(id, text, content, closable, tpl)
41644 var item = new Roo.bootstrap.panel.TabItem({
41648 closable : closable,
41651 this.addTabItem(item);
41653 item.setContent(content);
41659 * Returns the {@link Roo.TabPanelItem} with the specified id/index
41660 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
41661 * @return {Roo.TabPanelItem}
41663 getTab : function(id){
41664 return this.items[id];
41668 * Hides the {@link Roo.TabPanelItem} with the specified id/index
41669 * @param {String/Number} id The id or index of the TabPanelItem to hide.
41671 hideTab : function(id){
41672 var t = this.items[id];
41675 this.hiddenCount++;
41676 this.autoSizeTabs();
41681 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
41682 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
41684 unhideTab : function(id){
41685 var t = this.items[id];
41687 t.setHidden(false);
41688 this.hiddenCount--;
41689 this.autoSizeTabs();
41694 * Adds an existing {@link Roo.TabPanelItem}.
41695 * @param {Roo.TabPanelItem} item The TabPanelItem to add
41697 addTabItem : function(item)
41699 this.items[item.id] = item;
41700 this.items.push(item);
41701 this.autoSizeTabs();
41702 // if(this.resizeTabs){
41703 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
41704 // this.autoSizeTabs();
41706 // item.autoSize();
41711 * Removes a {@link Roo.TabPanelItem}.
41712 * @param {String/Number} id The id or index of the TabPanelItem to remove.
41714 removeTab : function(id){
41715 var items = this.items;
41716 var tab = items[id];
41717 if(!tab) { return; }
41718 var index = items.indexOf(tab);
41719 if(this.active == tab && items.length > 1){
41720 var newTab = this.getNextAvailable(index);
41725 this.stripEl.dom.removeChild(tab.pnode.dom);
41726 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
41727 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
41729 items.splice(index, 1);
41730 delete this.items[tab.id];
41731 tab.fireEvent("close", tab);
41732 tab.purgeListeners();
41733 this.autoSizeTabs();
41736 getNextAvailable : function(start){
41737 var items = this.items;
41739 // look for a next tab that will slide over to
41740 // replace the one being removed
41741 while(index < items.length){
41742 var item = items[++index];
41743 if(item && !item.isHidden()){
41747 // if one isn't found select the previous tab (on the left)
41750 var item = items[--index];
41751 if(item && !item.isHidden()){
41759 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
41760 * @param {String/Number} id The id or index of the TabPanelItem to disable.
41762 disableTab : function(id){
41763 var tab = this.items[id];
41764 if(tab && this.active != tab){
41770 * Enables a {@link Roo.TabPanelItem} that is disabled.
41771 * @param {String/Number} id The id or index of the TabPanelItem to enable.
41773 enableTab : function(id){
41774 var tab = this.items[id];
41779 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
41780 * @param {String/Number} id The id or index of the TabPanelItem to activate.
41781 * @return {Roo.TabPanelItem} The TabPanelItem.
41783 activate : function(id)
41785 //Roo.log('activite:' + id);
41787 var tab = this.items[id];
41791 if(tab == this.active || tab.disabled){
41795 this.fireEvent("beforetabchange", this, e, tab);
41796 if(e.cancel !== true && !tab.disabled){
41798 this.active.hide();
41800 this.active = this.items[id];
41801 this.active.show();
41802 this.fireEvent("tabchange", this, this.active);
41808 * Gets the active {@link Roo.TabPanelItem}.
41809 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
41811 getActiveTab : function(){
41812 return this.active;
41816 * Updates the tab body element to fit the height of the container element
41817 * for overflow scrolling
41818 * @param {Number} targetHeight (optional) Override the starting height from the elements height
41820 syncHeight : function(targetHeight){
41821 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
41822 var bm = this.bodyEl.getMargins();
41823 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
41824 this.bodyEl.setHeight(newHeight);
41828 onResize : function(){
41829 if(this.monitorResize){
41830 this.autoSizeTabs();
41835 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
41837 beginUpdate : function(){
41838 this.updating = true;
41842 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
41844 endUpdate : function(){
41845 this.updating = false;
41846 this.autoSizeTabs();
41850 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
41852 autoSizeTabs : function()
41854 var count = this.items.length;
41855 var vcount = count - this.hiddenCount;
41858 this.stripEl.hide();
41860 this.stripEl.show();
41863 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
41868 var w = Math.max(this.el.getWidth() - this.cpad, 10);
41869 var availWidth = Math.floor(w / vcount);
41870 var b = this.stripBody;
41871 if(b.getWidth() > w){
41872 var tabs = this.items;
41873 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
41874 if(availWidth < this.minTabWidth){
41875 /*if(!this.sleft){ // incomplete scrolling code
41876 this.createScrollButtons();
41879 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
41882 if(this.currentTabWidth < this.preferredTabWidth){
41883 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
41889 * Returns the number of tabs in this TabPanel.
41892 getCount : function(){
41893 return this.items.length;
41897 * Resizes all the tabs to the passed width
41898 * @param {Number} The new width
41900 setTabWidth : function(width){
41901 this.currentTabWidth = width;
41902 for(var i = 0, len = this.items.length; i < len; i++) {
41903 if(!this.items[i].isHidden()) {
41904 this.items[i].setWidth(width);
41910 * Destroys this TabPanel
41911 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
41913 destroy : function(removeEl){
41914 Roo.EventManager.removeResizeListener(this.onResize, this);
41915 for(var i = 0, len = this.items.length; i < len; i++){
41916 this.items[i].purgeListeners();
41918 if(removeEl === true){
41919 this.el.update("");
41924 createStrip : function(container)
41926 var strip = document.createElement("nav");
41927 strip.className = Roo.bootstrap.version == 4 ?
41928 "navbar-light bg-light" :
41929 "navbar navbar-default"; //"x-tabs-wrap";
41930 container.appendChild(strip);
41934 createStripList : function(strip)
41936 // div wrapper for retard IE
41937 // returns the "tr" element.
41938 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
41939 //'<div class="x-tabs-strip-wrap">'+
41940 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
41941 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
41942 return strip.firstChild; //.firstChild.firstChild.firstChild;
41944 createBody : function(container)
41946 var body = document.createElement("div");
41947 Roo.id(body, "tab-body");
41948 //Roo.fly(body).addClass("x-tabs-body");
41949 Roo.fly(body).addClass("tab-content");
41950 container.appendChild(body);
41953 createItemBody :function(bodyEl, id){
41954 var body = Roo.getDom(id);
41956 body = document.createElement("div");
41959 //Roo.fly(body).addClass("x-tabs-item-body");
41960 Roo.fly(body).addClass("tab-pane");
41961 bodyEl.insertBefore(body, bodyEl.firstChild);
41965 createStripElements : function(stripEl, text, closable, tpl)
41967 var td = document.createElement("li"); // was td..
41968 td.className = 'nav-item';
41970 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
41973 stripEl.appendChild(td);
41975 td.className = "x-tabs-closable";
41976 if(!this.closeTpl){
41977 this.closeTpl = new Roo.Template(
41978 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
41979 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
41980 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
41983 var el = this.closeTpl.overwrite(td, {"text": text});
41984 var close = el.getElementsByTagName("div")[0];
41985 var inner = el.getElementsByTagName("em")[0];
41986 return {"el": el, "close": close, "inner": inner};
41989 // not sure what this is..
41990 // if(!this.tabTpl){
41991 //this.tabTpl = new Roo.Template(
41992 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
41993 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
41995 // this.tabTpl = new Roo.Template(
41996 // '<a href="#">' +
41997 // '<span unselectable="on"' +
41998 // (this.disableTooltips ? '' : ' title="{text}"') +
41999 // ' >{text}</span></a>'
42005 var template = tpl || this.tabTpl || false;
42008 template = new Roo.Template(
42009 Roo.bootstrap.version == 4 ?
42011 '<a class="nav-link" href="#" unselectable="on"' +
42012 (this.disableTooltips ? '' : ' title="{text}"') +
42015 '<a class="nav-link" href="#">' +
42016 '<span unselectable="on"' +
42017 (this.disableTooltips ? '' : ' title="{text}"') +
42018 ' >{text}</span></a>'
42023 switch (typeof(template)) {
42027 template = new Roo.Template(template);
42033 var el = template.overwrite(td, {"text": text});
42035 var inner = el.getElementsByTagName("span")[0];
42037 return {"el": el, "inner": inner};
42045 * @class Roo.TabPanelItem
42046 * @extends Roo.util.Observable
42047 * Represents an individual item (tab plus body) in a TabPanel.
42048 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
42049 * @param {String} id The id of this TabPanelItem
42050 * @param {String} text The text for the tab of this TabPanelItem
42051 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
42053 Roo.bootstrap.panel.TabItem = function(config){
42055 * The {@link Roo.TabPanel} this TabPanelItem belongs to
42056 * @type Roo.TabPanel
42058 this.tabPanel = config.panel;
42060 * The id for this TabPanelItem
42063 this.id = config.id;
42065 this.disabled = false;
42067 this.text = config.text;
42069 this.loaded = false;
42070 this.closable = config.closable;
42073 * The body element for this TabPanelItem.
42074 * @type Roo.Element
42076 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
42077 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
42078 this.bodyEl.setStyle("display", "block");
42079 this.bodyEl.setStyle("zoom", "1");
42080 //this.hideAction();
42082 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
42084 this.el = Roo.get(els.el);
42085 this.inner = Roo.get(els.inner, true);
42086 this.textEl = Roo.bootstrap.version == 4 ?
42087 this.el : Roo.get(this.el.dom.firstChild, true);
42089 this.pnode = this.linode = Roo.get(els.el.parentNode, true);
42090 this.status_node = Roo.bootstrap.version == 4 ? this.el : this.linode;
42093 // this.el.on("mousedown", this.onTabMouseDown, this);
42094 this.el.on("click", this.onTabClick, this);
42096 if(config.closable){
42097 var c = Roo.get(els.close, true);
42098 c.dom.title = this.closeText;
42099 c.addClassOnOver("close-over");
42100 c.on("click", this.closeClick, this);
42106 * Fires when this tab becomes the active tab.
42107 * @param {Roo.TabPanel} tabPanel The parent TabPanel
42108 * @param {Roo.TabPanelItem} this
42112 * @event beforeclose
42113 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
42114 * @param {Roo.TabPanelItem} this
42115 * @param {Object} e Set cancel to true on this object to cancel the close.
42117 "beforeclose": true,
42120 * Fires when this tab is closed.
42121 * @param {Roo.TabPanelItem} this
42125 * @event deactivate
42126 * Fires when this tab is no longer the active tab.
42127 * @param {Roo.TabPanel} tabPanel The parent TabPanel
42128 * @param {Roo.TabPanelItem} this
42130 "deactivate" : true
42132 this.hidden = false;
42134 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
42137 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
42139 purgeListeners : function(){
42140 Roo.util.Observable.prototype.purgeListeners.call(this);
42141 this.el.removeAllListeners();
42144 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
42147 this.status_node.addClass("active");
42150 this.tabPanel.stripWrap.repaint();
42152 this.fireEvent("activate", this.tabPanel, this);
42156 * Returns true if this tab is the active tab.
42157 * @return {Boolean}
42159 isActive : function(){
42160 return this.tabPanel.getActiveTab() == this;
42164 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
42167 this.status_node.removeClass("active");
42169 this.fireEvent("deactivate", this.tabPanel, this);
42172 hideAction : function(){
42173 this.bodyEl.hide();
42174 this.bodyEl.setStyle("position", "absolute");
42175 this.bodyEl.setLeft("-20000px");
42176 this.bodyEl.setTop("-20000px");
42179 showAction : function(){
42180 this.bodyEl.setStyle("position", "relative");
42181 this.bodyEl.setTop("");
42182 this.bodyEl.setLeft("");
42183 this.bodyEl.show();
42187 * Set the tooltip for the tab.
42188 * @param {String} tooltip The tab's tooltip
42190 setTooltip : function(text){
42191 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
42192 this.textEl.dom.qtip = text;
42193 this.textEl.dom.removeAttribute('title');
42195 this.textEl.dom.title = text;
42199 onTabClick : function(e){
42200 e.preventDefault();
42201 this.tabPanel.activate(this.id);
42204 onTabMouseDown : function(e){
42205 e.preventDefault();
42206 this.tabPanel.activate(this.id);
42209 getWidth : function(){
42210 return this.inner.getWidth();
42213 setWidth : function(width){
42214 var iwidth = width - this.linode.getPadding("lr");
42215 this.inner.setWidth(iwidth);
42216 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
42217 this.linode.setWidth(width);
42221 * Show or hide the tab
42222 * @param {Boolean} hidden True to hide or false to show.
42224 setHidden : function(hidden){
42225 this.hidden = hidden;
42226 this.linode.setStyle("display", hidden ? "none" : "");
42230 * Returns true if this tab is "hidden"
42231 * @return {Boolean}
42233 isHidden : function(){
42234 return this.hidden;
42238 * Returns the text for this tab
42241 getText : function(){
42245 autoSize : function(){
42246 //this.el.beginMeasure();
42247 this.textEl.setWidth(1);
42249 * #2804 [new] Tabs in Roojs
42250 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
42252 //this.setWidth(this.textEl.dom.scrollWidth+this.linode.getPadding("lr")+this.inner.getPadding("lr") + 2);
42253 //this.el.endMeasure();
42257 * Sets the text for the tab (Note: this also sets the tooltip text)
42258 * @param {String} text The tab's text and tooltip
42260 setText : function(text){
42262 this.textEl.update(text);
42263 this.setTooltip(text);
42264 //if(!this.tabPanel.resizeTabs){
42265 // this.autoSize();
42269 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
42271 activate : function(){
42272 this.tabPanel.activate(this.id);
42276 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
42278 disable : function(){
42279 if(this.tabPanel.active != this){
42280 this.disabled = true;
42281 this.status_node.addClass("disabled");
42286 * Enables this TabPanelItem if it was previously disabled.
42288 enable : function(){
42289 this.disabled = false;
42290 this.status_node.removeClass("disabled");
42294 * Sets the content for this TabPanelItem.
42295 * @param {String} content The content
42296 * @param {Boolean} loadScripts true to look for and load scripts
42298 setContent : function(content, loadScripts){
42299 this.bodyEl.update(content, loadScripts);
42303 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
42304 * @return {Roo.UpdateManager} The UpdateManager
42306 getUpdateManager : function(){
42307 return this.bodyEl.getUpdateManager();
42311 * Set a URL to be used to load the content for this TabPanelItem.
42312 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
42313 * @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)
42314 * @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)
42315 * @return {Roo.UpdateManager} The UpdateManager
42317 setUrl : function(url, params, loadOnce){
42318 if(this.refreshDelegate){
42319 this.un('activate', this.refreshDelegate);
42321 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
42322 this.on("activate", this.refreshDelegate);
42323 return this.bodyEl.getUpdateManager();
42327 _handleRefresh : function(url, params, loadOnce){
42328 if(!loadOnce || !this.loaded){
42329 var updater = this.bodyEl.getUpdateManager();
42330 updater.update(url, params, this._setLoaded.createDelegate(this));
42335 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
42336 * Will fail silently if the setUrl method has not been called.
42337 * This does not activate the panel, just updates its content.
42339 refresh : function(){
42340 if(this.refreshDelegate){
42341 this.loaded = false;
42342 this.refreshDelegate();
42347 _setLoaded : function(){
42348 this.loaded = true;
42352 closeClick : function(e){
42355 this.fireEvent("beforeclose", this, o);
42356 if(o.cancel !== true){
42357 this.tabPanel.removeTab(this.id);
42361 * The text displayed in the tooltip for the close icon.
42364 closeText : "Close this tab"
42367 * This script refer to:
42368 * Title: International Telephone Input
42369 * Author: Jack O'Connor
42370 * Code version: v12.1.12
42371 * Availability: https://github.com/jackocnr/intl-tel-input.git
42374 Roo.bootstrap.PhoneInputData = function() {
42377 "Afghanistan (افغانستان)",
42382 "Albania (Shqipëri)",
42387 "Algeria (الجزائر)",
42412 "Antigua and Barbuda",
42422 "Armenia (Հայաստան)",
42438 "Austria (Österreich)",
42443 "Azerbaijan (Azərbaycan)",
42453 "Bahrain (البحرين)",
42458 "Bangladesh (বাংলাদেশ)",
42468 "Belarus (Беларусь)",
42473 "Belgium (België)",
42503 "Bosnia and Herzegovina (Босна и Херцеговина)",
42518 "British Indian Ocean Territory",
42523 "British Virgin Islands",
42533 "Bulgaria (България)",
42543 "Burundi (Uburundi)",
42548 "Cambodia (កម្ពុជា)",
42553 "Cameroon (Cameroun)",
42562 ["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"]
42565 "Cape Verde (Kabu Verdi)",
42570 "Caribbean Netherlands",
42581 "Central African Republic (République centrafricaine)",
42601 "Christmas Island",
42607 "Cocos (Keeling) Islands",
42618 "Comoros (جزر القمر)",
42623 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
42628 "Congo (Republic) (Congo-Brazzaville)",
42648 "Croatia (Hrvatska)",
42669 "Czech Republic (Česká republika)",
42674 "Denmark (Danmark)",
42689 "Dominican Republic (República Dominicana)",
42693 ["809", "829", "849"]
42711 "Equatorial Guinea (Guinea Ecuatorial)",
42731 "Falkland Islands (Islas Malvinas)",
42736 "Faroe Islands (Føroyar)",
42757 "French Guiana (Guyane française)",
42762 "French Polynesia (Polynésie française)",
42777 "Georgia (საქართველო)",
42782 "Germany (Deutschland)",
42802 "Greenland (Kalaallit Nunaat)",
42839 "Guinea-Bissau (Guiné Bissau)",
42864 "Hungary (Magyarország)",
42869 "Iceland (Ísland)",
42889 "Iraq (العراق)",
42905 "Israel (ישראל)",
42932 "Jordan (الأردن)",
42937 "Kazakhstan (Казахстан)",
42958 "Kuwait (الكويت)",
42963 "Kyrgyzstan (Кыргызстан)",
42973 "Latvia (Latvija)",
42978 "Lebanon (لبنان)",
42993 "Libya (ليبيا)",
43003 "Lithuania (Lietuva)",
43018 "Macedonia (FYROM) (Македонија)",
43023 "Madagascar (Madagasikara)",
43053 "Marshall Islands",
43063 "Mauritania (موريتانيا)",
43068 "Mauritius (Moris)",
43089 "Moldova (Republica Moldova)",
43099 "Mongolia (Монгол)",
43104 "Montenegro (Crna Gora)",
43114 "Morocco (المغرب)",
43120 "Mozambique (Moçambique)",
43125 "Myanmar (Burma) (မြန်မာ)",
43130 "Namibia (Namibië)",
43145 "Netherlands (Nederland)",
43150 "New Caledonia (Nouvelle-Calédonie)",
43185 "North Korea (조선 민주주의 인민 공화국)",
43190 "Northern Mariana Islands",
43206 "Pakistan (پاکستان)",
43216 "Palestine (فلسطين)",
43226 "Papua New Guinea",
43268 "Réunion (La Réunion)",
43274 "Romania (România)",
43290 "Saint Barthélemy",
43301 "Saint Kitts and Nevis",
43311 "Saint Martin (Saint-Martin (partie française))",
43317 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
43322 "Saint Vincent and the Grenadines",
43337 "São Tomé and Príncipe (São Tomé e Príncipe)",
43342 "Saudi Arabia (المملكة العربية السعودية)",
43347 "Senegal (Sénégal)",
43377 "Slovakia (Slovensko)",
43382 "Slovenia (Slovenija)",
43392 "Somalia (Soomaaliya)",
43402 "South Korea (대한민국)",
43407 "South Sudan (جنوب السودان)",
43417 "Sri Lanka (ශ්රී ලංකාව)",
43422 "Sudan (السودان)",
43432 "Svalbard and Jan Mayen",
43443 "Sweden (Sverige)",
43448 "Switzerland (Schweiz)",
43453 "Syria (سوريا)",
43498 "Trinidad and Tobago",
43503 "Tunisia (تونس)",
43508 "Turkey (Türkiye)",
43518 "Turks and Caicos Islands",
43528 "U.S. Virgin Islands",
43538 "Ukraine (Україна)",
43543 "United Arab Emirates (الإمارات العربية المتحدة)",
43565 "Uzbekistan (Oʻzbekiston)",
43575 "Vatican City (Città del Vaticano)",
43586 "Vietnam (Việt Nam)",
43591 "Wallis and Futuna (Wallis-et-Futuna)",
43596 "Western Sahara (الصحراء الغربية)",
43602 "Yemen (اليمن)",
43626 * This script refer to:
43627 * Title: International Telephone Input
43628 * Author: Jack O'Connor
43629 * Code version: v12.1.12
43630 * Availability: https://github.com/jackocnr/intl-tel-input.git
43634 * @class Roo.bootstrap.PhoneInput
43635 * @extends Roo.bootstrap.TriggerField
43636 * An input with International dial-code selection
43638 * @cfg {String} defaultDialCode default '+852'
43639 * @cfg {Array} preferedCountries default []
43642 * Create a new PhoneInput.
43643 * @param {Object} config Configuration options
43646 Roo.bootstrap.PhoneInput = function(config) {
43647 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
43650 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
43652 * @cfg {Roo.data.Store} store [required] The data store to which this combo is bound (defaults to undefined)
43654 listWidth: undefined,
43656 selectedClass: 'active',
43658 invalidClass : "has-warning",
43660 validClass: 'has-success',
43662 allowed: '0123456789',
43667 * @cfg {String} defaultDialCode The default dial code when initializing the input
43669 defaultDialCode: '+852',
43672 * @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
43674 preferedCountries: false,
43676 getAutoCreate : function()
43678 var data = Roo.bootstrap.PhoneInputData();
43679 var align = this.labelAlign || this.parentLabelAlign();
43682 this.allCountries = [];
43683 this.dialCodeMapping = [];
43685 for (var i = 0; i < data.length; i++) {
43687 this.allCountries[i] = {
43691 priority: c[3] || 0,
43692 areaCodes: c[4] || null
43694 this.dialCodeMapping[c[2]] = {
43697 priority: c[3] || 0,
43698 areaCodes: c[4] || null
43710 // type: 'number', -- do not use number - we get the flaky up/down arrows.
43711 maxlength: this.max_length,
43712 cls : 'form-control tel-input',
43713 autocomplete: 'new-password'
43716 var hiddenInput = {
43719 cls: 'hidden-tel-input'
43723 hiddenInput.name = this.name;
43726 if (this.disabled) {
43727 input.disabled = true;
43730 var flag_container = {
43747 cls: this.hasFeedback ? 'has-feedback' : '',
43753 cls: 'dial-code-holder',
43760 cls: 'roo-select2-container input-group',
43767 if (this.fieldLabel.length) {
43770 tooltip: 'This field is required'
43776 cls: 'control-label',
43782 html: this.fieldLabel
43785 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
43791 if(this.indicatorpos == 'right') {
43792 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
43799 if(align == 'left') {
43807 if(this.labelWidth > 12){
43808 label.style = "width: " + this.labelWidth + 'px';
43810 if(this.labelWidth < 13 && this.labelmd == 0){
43811 this.labelmd = this.labelWidth;
43813 if(this.labellg > 0){
43814 label.cls += ' col-lg-' + this.labellg;
43815 input.cls += ' col-lg-' + (12 - this.labellg);
43817 if(this.labelmd > 0){
43818 label.cls += ' col-md-' + this.labelmd;
43819 container.cls += ' col-md-' + (12 - this.labelmd);
43821 if(this.labelsm > 0){
43822 label.cls += ' col-sm-' + this.labelsm;
43823 container.cls += ' col-sm-' + (12 - this.labelsm);
43825 if(this.labelxs > 0){
43826 label.cls += ' col-xs-' + this.labelxs;
43827 container.cls += ' col-xs-' + (12 - this.labelxs);
43837 var settings = this;
43839 ['xs','sm','md','lg'].map(function(size){
43840 if (settings[size]) {
43841 cfg.cls += ' col-' + size + '-' + settings[size];
43845 this.store = new Roo.data.Store({
43846 proxy : new Roo.data.MemoryProxy({}),
43847 reader : new Roo.data.JsonReader({
43858 'name' : 'dialCode',
43862 'name' : 'priority',
43866 'name' : 'areaCodes',
43873 if(!this.preferedCountries) {
43874 this.preferedCountries = [
43881 var p = this.preferedCountries.reverse();
43884 for (var i = 0; i < p.length; i++) {
43885 for (var j = 0; j < this.allCountries.length; j++) {
43886 if(this.allCountries[j].iso2 == p[i]) {
43887 var t = this.allCountries[j];
43888 this.allCountries.splice(j,1);
43889 this.allCountries.unshift(t);
43895 this.store.proxy.data = {
43897 data: this.allCountries
43903 initEvents : function()
43906 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
43908 this.indicator = this.indicatorEl();
43909 this.flag = this.flagEl();
43910 this.dialCodeHolder = this.dialCodeHolderEl();
43912 this.trigger = this.el.select('div.flag-box',true).first();
43913 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
43918 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
43919 _this.list.setWidth(lw);
43922 this.list.on('mouseover', this.onViewOver, this);
43923 this.list.on('mousemove', this.onViewMove, this);
43924 this.inputEl().on("keyup", this.onKeyUp, this);
43925 this.inputEl().on("keypress", this.onKeyPress, this);
43927 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
43929 this.view = new Roo.View(this.list, this.tpl, {
43930 singleSelect:true, store: this.store, selectedClass: this.selectedClass
43933 this.view.on('click', this.onViewClick, this);
43934 this.setValue(this.defaultDialCode);
43937 onTriggerClick : function(e)
43939 Roo.log('trigger click');
43944 if(this.isExpanded()){
43946 this.hasFocus = false;
43948 this.store.load({});
43949 this.hasFocus = true;
43954 isExpanded : function()
43956 return this.list.isVisible();
43959 collapse : function()
43961 if(!this.isExpanded()){
43965 Roo.get(document).un('mousedown', this.collapseIf, this);
43966 Roo.get(document).un('mousewheel', this.collapseIf, this);
43967 this.fireEvent('collapse', this);
43971 expand : function()
43975 if(this.isExpanded() || !this.hasFocus){
43979 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
43980 this.list.setWidth(lw);
43983 this.restrictHeight();
43985 Roo.get(document).on('mousedown', this.collapseIf, this);
43986 Roo.get(document).on('mousewheel', this.collapseIf, this);
43988 this.fireEvent('expand', this);
43991 restrictHeight : function()
43993 this.list.alignTo(this.inputEl(), this.listAlign);
43994 this.list.alignTo(this.inputEl(), this.listAlign);
43997 onViewOver : function(e, t)
43999 if(this.inKeyMode){
44002 var item = this.view.findItemFromChild(t);
44005 var index = this.view.indexOf(item);
44006 this.select(index, false);
44011 onViewClick : function(view, doFocus, el, e)
44013 var index = this.view.getSelectedIndexes()[0];
44015 var r = this.store.getAt(index);
44018 this.onSelect(r, index);
44020 if(doFocus !== false && !this.blockFocus){
44021 this.inputEl().focus();
44025 onViewMove : function(e, t)
44027 this.inKeyMode = false;
44030 select : function(index, scrollIntoView)
44032 this.selectedIndex = index;
44033 this.view.select(index);
44034 if(scrollIntoView !== false){
44035 var el = this.view.getNode(index);
44037 this.list.scrollChildIntoView(el, false);
44042 createList : function()
44044 this.list = Roo.get(document.body).createChild({
44046 cls: 'typeahead typeahead-long dropdown-menu tel-list',
44047 style: 'display:none'
44050 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
44053 collapseIf : function(e)
44055 var in_combo = e.within(this.el);
44056 var in_list = e.within(this.list);
44057 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
44059 if (in_combo || in_list || is_list) {
44065 onSelect : function(record, index)
44067 if(this.fireEvent('beforeselect', this, record, index) !== false){
44069 this.setFlagClass(record.data.iso2);
44070 this.setDialCode(record.data.dialCode);
44071 this.hasFocus = false;
44073 this.fireEvent('select', this, record, index);
44077 flagEl : function()
44079 var flag = this.el.select('div.flag',true).first();
44086 dialCodeHolderEl : function()
44088 var d = this.el.select('input.dial-code-holder',true).first();
44095 setDialCode : function(v)
44097 this.dialCodeHolder.dom.value = '+'+v;
44100 setFlagClass : function(n)
44102 this.flag.dom.className = 'flag '+n;
44105 getValue : function()
44107 var v = this.inputEl().getValue();
44108 if(this.dialCodeHolder) {
44109 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
44114 setValue : function(v)
44116 var d = this.getDialCode(v);
44118 //invalid dial code
44119 if(v.length == 0 || !d || d.length == 0) {
44121 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
44122 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
44128 this.setFlagClass(this.dialCodeMapping[d].iso2);
44129 this.setDialCode(d);
44130 this.inputEl().dom.value = v.replace('+'+d,'');
44131 this.hiddenEl().dom.value = this.getValue();
44136 getDialCode : function(v)
44140 if (v.length == 0) {
44141 return this.dialCodeHolder.dom.value;
44145 if (v.charAt(0) != "+") {
44148 var numericChars = "";
44149 for (var i = 1; i < v.length; i++) {
44150 var c = v.charAt(i);
44153 if (this.dialCodeMapping[numericChars]) {
44154 dialCode = v.substr(1, i);
44156 if (numericChars.length == 4) {
44166 this.setValue(this.defaultDialCode);
44170 hiddenEl : function()
44172 return this.el.select('input.hidden-tel-input',true).first();
44175 // after setting val
44176 onKeyUp : function(e){
44177 this.setValue(this.getValue());
44180 onKeyPress : function(e){
44181 if(this.allowed.indexOf(String.fromCharCode(e.getCharCode())) === -1){
44188 * @class Roo.bootstrap.MoneyField
44189 * @extends Roo.bootstrap.ComboBox
44190 * Bootstrap MoneyField class
44193 * Create a new MoneyField.
44194 * @param {Object} config Configuration options
44197 Roo.bootstrap.MoneyField = function(config) {
44199 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
44203 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
44206 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
44208 allowDecimals : true,
44210 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
44212 decimalSeparator : ".",
44214 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
44216 decimalPrecision : 0,
44218 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
44220 allowNegative : true,
44222 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
44226 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
44228 minValue : Number.NEGATIVE_INFINITY,
44230 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
44232 maxValue : Number.MAX_VALUE,
44234 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
44236 minText : "The minimum value for this field is {0}",
44238 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
44240 maxText : "The maximum value for this field is {0}",
44242 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
44243 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
44245 nanText : "{0} is not a valid number",
44247 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
44251 * @cfg {String} defaults currency of the MoneyField
44252 * value should be in lkey
44254 defaultCurrency : false,
44256 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
44258 thousandsDelimiter : false,
44260 * @cfg {Number} max_length Maximum input field length allowed (defaults to Number.MAX_VALUE)
44271 getAutoCreate : function()
44273 var align = this.labelAlign || this.parentLabelAlign();
44285 cls : 'form-control roo-money-amount-input',
44286 autocomplete: 'new-password'
44289 var hiddenInput = {
44293 cls: 'hidden-number-input'
44296 if(this.max_length) {
44297 input.maxlength = this.max_length;
44301 hiddenInput.name = this.name;
44304 if (this.disabled) {
44305 input.disabled = true;
44308 var clg = 12 - this.inputlg;
44309 var cmd = 12 - this.inputmd;
44310 var csm = 12 - this.inputsm;
44311 var cxs = 12 - this.inputxs;
44315 cls : 'row roo-money-field',
44319 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
44323 cls: 'roo-select2-container input-group',
44327 cls : 'form-control roo-money-currency-input',
44328 autocomplete: 'new-password',
44330 name : this.currencyName
44334 cls : 'input-group-addon',
44348 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
44352 cls: this.hasFeedback ? 'has-feedback' : '',
44363 if (this.fieldLabel.length) {
44366 tooltip: 'This field is required'
44372 cls: 'control-label',
44378 html: this.fieldLabel
44381 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
44387 if(this.indicatorpos == 'right') {
44388 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
44395 if(align == 'left') {
44403 if(this.labelWidth > 12){
44404 label.style = "width: " + this.labelWidth + 'px';
44406 if(this.labelWidth < 13 && this.labelmd == 0){
44407 this.labelmd = this.labelWidth;
44409 if(this.labellg > 0){
44410 label.cls += ' col-lg-' + this.labellg;
44411 input.cls += ' col-lg-' + (12 - this.labellg);
44413 if(this.labelmd > 0){
44414 label.cls += ' col-md-' + this.labelmd;
44415 container.cls += ' col-md-' + (12 - this.labelmd);
44417 if(this.labelsm > 0){
44418 label.cls += ' col-sm-' + this.labelsm;
44419 container.cls += ' col-sm-' + (12 - this.labelsm);
44421 if(this.labelxs > 0){
44422 label.cls += ' col-xs-' + this.labelxs;
44423 container.cls += ' col-xs-' + (12 - this.labelxs);
44434 var settings = this;
44436 ['xs','sm','md','lg'].map(function(size){
44437 if (settings[size]) {
44438 cfg.cls += ' col-' + size + '-' + settings[size];
44445 initEvents : function()
44447 this.indicator = this.indicatorEl();
44449 this.initCurrencyEvent();
44451 this.initNumberEvent();
44454 initCurrencyEvent : function()
44457 throw "can not find store for combo";
44460 this.store = Roo.factory(this.store, Roo.data);
44461 this.store.parent = this;
44465 this.triggerEl = this.el.select('.input-group-addon', true).first();
44467 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
44472 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
44473 _this.list.setWidth(lw);
44476 this.list.on('mouseover', this.onViewOver, this);
44477 this.list.on('mousemove', this.onViewMove, this);
44478 this.list.on('scroll', this.onViewScroll, this);
44481 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
44484 this.view = new Roo.View(this.list, this.tpl, {
44485 singleSelect:true, store: this.store, selectedClass: this.selectedClass
44488 this.view.on('click', this.onViewClick, this);
44490 this.store.on('beforeload', this.onBeforeLoad, this);
44491 this.store.on('load', this.onLoad, this);
44492 this.store.on('loadexception', this.onLoadException, this);
44494 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
44495 "up" : function(e){
44496 this.inKeyMode = true;
44500 "down" : function(e){
44501 if(!this.isExpanded()){
44502 this.onTriggerClick();
44504 this.inKeyMode = true;
44509 "enter" : function(e){
44512 if(this.fireEvent("specialkey", this, e)){
44513 this.onViewClick(false);
44519 "esc" : function(e){
44523 "tab" : function(e){
44526 if(this.fireEvent("specialkey", this, e)){
44527 this.onViewClick(false);
44535 doRelay : function(foo, bar, hname){
44536 if(hname == 'down' || this.scope.isExpanded()){
44537 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
44545 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
44549 initNumberEvent : function(e)
44551 this.inputEl().on("keydown" , this.fireKey, this);
44552 this.inputEl().on("focus", this.onFocus, this);
44553 this.inputEl().on("blur", this.onBlur, this);
44555 this.inputEl().relayEvent('keyup', this);
44557 if(this.indicator){
44558 this.indicator.addClass('invisible');
44561 this.originalValue = this.getValue();
44563 if(this.validationEvent == 'keyup'){
44564 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
44565 this.inputEl().on('keyup', this.filterValidation, this);
44567 else if(this.validationEvent !== false){
44568 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
44571 if(this.selectOnFocus){
44572 this.on("focus", this.preFocus, this);
44575 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
44576 this.inputEl().on("keypress", this.filterKeys, this);
44578 this.inputEl().relayEvent('keypress', this);
44581 var allowed = "0123456789";
44583 if(this.allowDecimals){
44584 allowed += this.decimalSeparator;
44587 if(this.allowNegative){
44591 if(this.thousandsDelimiter) {
44595 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
44597 var keyPress = function(e){
44599 var k = e.getKey();
44601 var c = e.getCharCode();
44604 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
44605 allowed.indexOf(String.fromCharCode(c)) === -1
44611 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
44615 if(allowed.indexOf(String.fromCharCode(c)) === -1){
44620 this.inputEl().on("keypress", keyPress, this);
44624 onTriggerClick : function(e)
44631 this.loadNext = false;
44633 if(this.isExpanded()){
44638 this.hasFocus = true;
44640 if(this.triggerAction == 'all') {
44641 this.doQuery(this.allQuery, true);
44645 this.doQuery(this.getRawValue());
44648 getCurrency : function()
44650 var v = this.currencyEl().getValue();
44655 restrictHeight : function()
44657 this.list.alignTo(this.currencyEl(), this.listAlign);
44658 this.list.alignTo(this.currencyEl(), this.listAlign);
44661 onViewClick : function(view, doFocus, el, e)
44663 var index = this.view.getSelectedIndexes()[0];
44665 var r = this.store.getAt(index);
44668 this.onSelect(r, index);
44672 onSelect : function(record, index){
44674 if(this.fireEvent('beforeselect', this, record, index) !== false){
44676 this.setFromCurrencyData(index > -1 ? record.data : false);
44680 this.fireEvent('select', this, record, index);
44684 setFromCurrencyData : function(o)
44688 this.lastCurrency = o;
44690 if (this.currencyField) {
44691 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
44693 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
44696 this.lastSelectionText = currency;
44698 //setting default currency
44699 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
44700 this.setCurrency(this.defaultCurrency);
44704 this.setCurrency(currency);
44707 setFromData : function(o)
44711 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
44713 this.setFromCurrencyData(c);
44718 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
44720 Roo.log('no value set for '+ (this.name ? this.name : this.id));
44723 this.setValue(value);
44727 setCurrency : function(v)
44729 this.currencyValue = v;
44732 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
44737 setValue : function(v)
44739 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
44745 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
44747 this.inputEl().dom.value = (v == '') ? '' :
44748 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
44750 if(!this.allowZero && v === '0') {
44751 this.hiddenEl().dom.value = '';
44752 this.inputEl().dom.value = '';
44759 getRawValue : function()
44761 var v = this.inputEl().getValue();
44766 getValue : function()
44768 return this.fixPrecision(this.parseValue(this.getRawValue()));
44771 parseValue : function(value)
44773 if(this.thousandsDelimiter) {
44775 r = new RegExp(",", "g");
44776 value = value.replace(r, "");
44779 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
44780 return isNaN(value) ? '' : value;
44784 fixPrecision : function(value)
44786 if(this.thousandsDelimiter) {
44788 r = new RegExp(",", "g");
44789 value = value.replace(r, "");
44792 var nan = isNaN(value);
44794 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
44795 return nan ? '' : value;
44797 return parseFloat(value).toFixed(this.decimalPrecision);
44800 decimalPrecisionFcn : function(v)
44802 return Math.floor(v);
44805 validateValue : function(value)
44807 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
44811 var num = this.parseValue(value);
44814 this.markInvalid(String.format(this.nanText, value));
44818 if(num < this.minValue){
44819 this.markInvalid(String.format(this.minText, this.minValue));
44823 if(num > this.maxValue){
44824 this.markInvalid(String.format(this.maxText, this.maxValue));
44831 validate : function()
44833 if(this.disabled || this.allowBlank){
44838 var currency = this.getCurrency();
44840 if(this.validateValue(this.getRawValue()) && currency.length){
44845 this.markInvalid();
44849 getName: function()
44854 beforeBlur : function()
44860 var v = this.parseValue(this.getRawValue());
44867 onBlur : function()
44871 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
44872 //this.el.removeClass(this.focusClass);
44875 this.hasFocus = false;
44877 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
44881 var v = this.getValue();
44883 if(String(v) !== String(this.startValue)){
44884 this.fireEvent('change', this, v, this.startValue);
44887 this.fireEvent("blur", this);
44890 inputEl : function()
44892 return this.el.select('.roo-money-amount-input', true).first();
44895 currencyEl : function()
44897 return this.el.select('.roo-money-currency-input', true).first();
44900 hiddenEl : function()
44902 return this.el.select('input.hidden-number-input',true).first();
44906 * @class Roo.bootstrap.BezierSignature
44907 * @extends Roo.bootstrap.Component
44908 * Bootstrap BezierSignature class
44909 * This script refer to:
44910 * Title: Signature Pad
44912 * Availability: https://github.com/szimek/signature_pad
44915 * Create a new BezierSignature
44916 * @param {Object} config The config object
44919 Roo.bootstrap.BezierSignature = function(config){
44920 Roo.bootstrap.BezierSignature.superclass.constructor.call(this, config);
44926 Roo.extend(Roo.bootstrap.BezierSignature, Roo.bootstrap.Component,
44933 mouse_btn_down: true,
44936 * @cfg {int} canvas height
44938 canvas_height: '200px',
44941 * @cfg {float|function} Radius of a single dot.
44946 * @cfg {float} Minimum width of a line. Defaults to 0.5.
44951 * @cfg {float} Maximum width of a line. Defaults to 2.5.
44956 * @cfg {integer} Draw the next point at most once per every x milliseconds. Set it to 0 to turn off throttling. Defaults to 16.
44961 * @cfg {integer} Add the next point only if the previous one is farther than x pixels. Defaults to 5.
44966 * @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.
44968 bg_color: 'rgba(0, 0, 0, 0)',
44971 * @cfg {string} Color used to draw the lines. Can be any color format accepted by context.fillStyle. Defaults to "black".
44973 dot_color: 'black',
44976 * @cfg {float} Weight used to modify new velocity based on the previous velocity. Defaults to 0.7.
44978 velocity_filter_weight: 0.7,
44981 * @cfg {function} Callback when stroke begin.
44986 * @cfg {function} Callback when stroke end.
44990 getAutoCreate : function()
44992 var cls = 'roo-signature column';
44995 cls += ' ' + this.cls;
45005 for(var i = 0; i < col_sizes.length; i++) {
45006 if(this[col_sizes[i]]) {
45007 cls += " col-"+col_sizes[i]+"-"+this[col_sizes[i]];
45017 cls: 'roo-signature-body',
45021 cls: 'roo-signature-body-canvas',
45022 height: this.canvas_height,
45023 width: this.canvas_width
45030 style: 'display: none'
45038 initEvents: function()
45040 Roo.bootstrap.BezierSignature.superclass.initEvents.call(this);
45042 var canvas = this.canvasEl();
45044 // mouse && touch event swapping...
45045 canvas.dom.style.touchAction = 'none';
45046 canvas.dom.style.msTouchAction = 'none';
45048 this.mouse_btn_down = false;
45049 canvas.on('mousedown', this._handleMouseDown, this);
45050 canvas.on('mousemove', this._handleMouseMove, this);
45051 Roo.select('html').first().on('mouseup', this._handleMouseUp, this);
45053 if (window.PointerEvent) {
45054 canvas.on('pointerdown', this._handleMouseDown, this);
45055 canvas.on('pointermove', this._handleMouseMove, this);
45056 Roo.select('html').first().on('pointerup', this._handleMouseUp, this);
45059 if ('ontouchstart' in window) {
45060 canvas.on('touchstart', this._handleTouchStart, this);
45061 canvas.on('touchmove', this._handleTouchMove, this);
45062 canvas.on('touchend', this._handleTouchEnd, this);
45065 Roo.EventManager.onWindowResize(this.resize, this, true);
45067 // file input event
45068 this.fileEl().on('change', this.uploadImage, this);
45075 resize: function(){
45077 var canvas = this.canvasEl().dom;
45078 var ctx = this.canvasElCtx();
45079 var img_data = false;
45081 if(canvas.width > 0) {
45082 var img_data = ctx.getImageData(0, 0, canvas.width, canvas.height);
45084 // setting canvas width will clean img data
45087 var style = window.getComputedStyle ?
45088 getComputedStyle(this.el.dom, null) : this.el.dom.currentStyle;
45090 var padding_left = parseInt(style.paddingLeft) || 0;
45091 var padding_right = parseInt(style.paddingRight) || 0;
45093 canvas.width = this.el.dom.clientWidth - padding_left - padding_right;
45096 ctx.putImageData(img_data, 0, 0);
45100 _handleMouseDown: function(e)
45102 if (e.browserEvent.which === 1) {
45103 this.mouse_btn_down = true;
45104 this.strokeBegin(e);
45108 _handleMouseMove: function (e)
45110 if (this.mouse_btn_down) {
45111 this.strokeMoveUpdate(e);
45115 _handleMouseUp: function (e)
45117 if (e.browserEvent.which === 1 && this.mouse_btn_down) {
45118 this.mouse_btn_down = false;
45123 _handleTouchStart: function (e) {
45125 e.preventDefault();
45126 if (e.browserEvent.targetTouches.length === 1) {
45127 // var touch = e.browserEvent.changedTouches[0];
45128 // this.strokeBegin(touch);
45130 this.strokeBegin(e); // assume e catching the correct xy...
45134 _handleTouchMove: function (e) {
45135 e.preventDefault();
45136 // var touch = event.targetTouches[0];
45137 // _this._strokeMoveUpdate(touch);
45138 this.strokeMoveUpdate(e);
45141 _handleTouchEnd: function (e) {
45142 var wasCanvasTouched = e.target === this.canvasEl().dom;
45143 if (wasCanvasTouched) {
45144 e.preventDefault();
45145 // var touch = event.changedTouches[0];
45146 // _this._strokeEnd(touch);
45151 reset: function () {
45152 this._lastPoints = [];
45153 this._lastVelocity = 0;
45154 this._lastWidth = (this.min_width + this.max_width) / 2;
45155 this.canvasElCtx().fillStyle = this.dot_color;
45158 strokeMoveUpdate: function(e)
45160 this.strokeUpdate(e);
45162 if (this.throttle) {
45163 this.throttleStroke(this.strokeUpdate, this.throttle);
45166 this.strokeUpdate(e);
45170 strokeBegin: function(e)
45172 var newPointGroup = {
45173 color: this.dot_color,
45177 if (typeof this.onBegin === 'function') {
45181 this.curve_data.push(newPointGroup);
45183 this.strokeUpdate(e);
45186 strokeUpdate: function(e)
45188 var rect = this.canvasEl().dom.getBoundingClientRect();
45189 var point = new this.Point(e.xy[0] - rect.left, e.xy[1] - rect.top, new Date().getTime());
45190 var lastPointGroup = this.curve_data[this.curve_data.length - 1];
45191 var lastPoints = lastPointGroup.points;
45192 var lastPoint = lastPoints.length > 0 && lastPoints[lastPoints.length - 1];
45193 var isLastPointTooClose = lastPoint
45194 ? point.distanceTo(lastPoint) <= this.min_distance
45196 var color = lastPointGroup.color;
45197 if (!lastPoint || !(lastPoint && isLastPointTooClose)) {
45198 var curve = this.addPoint(point);
45200 this.drawDot({color: color, point: point});
45203 this.drawCurve({color: color, curve: curve});
45213 strokeEnd: function(e)
45215 this.strokeUpdate(e);
45216 if (typeof this.onEnd === 'function') {
45221 addPoint: function (point) {
45222 var _lastPoints = this._lastPoints;
45223 _lastPoints.push(point);
45224 if (_lastPoints.length > 2) {
45225 if (_lastPoints.length === 3) {
45226 _lastPoints.unshift(_lastPoints[0]);
45228 var widths = this.calculateCurveWidths(_lastPoints[1], _lastPoints[2]);
45229 var curve = this.Bezier.fromPoints(_lastPoints, widths, this);
45230 _lastPoints.shift();
45236 calculateCurveWidths: function (startPoint, endPoint) {
45237 var velocity = this.velocity_filter_weight * endPoint.velocityFrom(startPoint) +
45238 (1 - this.velocity_filter_weight) * this._lastVelocity;
45240 var newWidth = Math.max(this.max_width / (velocity + 1), this.min_width);
45243 start: this._lastWidth
45246 this._lastVelocity = velocity;
45247 this._lastWidth = newWidth;
45251 drawDot: function (_a) {
45252 var color = _a.color, point = _a.point;
45253 var ctx = this.canvasElCtx();
45254 var width = typeof this.dot_size === 'function' ? this.dot_size() : this.dot_size;
45256 this.drawCurveSegment(point.x, point.y, width);
45258 ctx.fillStyle = color;
45262 drawCurve: function (_a) {
45263 var color = _a.color, curve = _a.curve;
45264 var ctx = this.canvasElCtx();
45265 var widthDelta = curve.endWidth - curve.startWidth;
45266 var drawSteps = Math.floor(curve.length()) * 2;
45268 ctx.fillStyle = color;
45269 for (var i = 0; i < drawSteps; i += 1) {
45270 var t = i / drawSteps;
45276 var x = uuu * curve.startPoint.x;
45277 x += 3 * uu * t * curve.control1.x;
45278 x += 3 * u * tt * curve.control2.x;
45279 x += ttt * curve.endPoint.x;
45280 var y = uuu * curve.startPoint.y;
45281 y += 3 * uu * t * curve.control1.y;
45282 y += 3 * u * tt * curve.control2.y;
45283 y += ttt * curve.endPoint.y;
45284 var width = curve.startWidth + ttt * widthDelta;
45285 this.drawCurveSegment(x, y, width);
45291 drawCurveSegment: function (x, y, width) {
45292 var ctx = this.canvasElCtx();
45294 ctx.arc(x, y, width, 0, 2 * Math.PI, false);
45295 this.is_empty = false;
45300 var ctx = this.canvasElCtx();
45301 var canvas = this.canvasEl().dom;
45302 ctx.fillStyle = this.bg_color;
45303 ctx.clearRect(0, 0, canvas.width, canvas.height);
45304 ctx.fillRect(0, 0, canvas.width, canvas.height);
45305 this.curve_data = [];
45307 this.is_empty = true;
45312 return this.el.select('input',true).first();
45315 canvasEl: function()
45317 return this.el.select('canvas',true).first();
45320 canvasElCtx: function()
45322 return this.el.select('canvas',true).first().dom.getContext('2d');
45325 getImage: function(type)
45327 if(this.is_empty) {
45332 return this.canvasEl().dom.toDataURL('image/'+type, 1);
45335 drawFromImage: function(img_src)
45337 var img = new Image();
45339 img.onload = function(){
45340 this.canvasElCtx().drawImage(img, 0, 0);
45345 this.is_empty = false;
45348 selectImage: function()
45350 this.fileEl().dom.click();
45353 uploadImage: function(e)
45355 var reader = new FileReader();
45357 reader.onload = function(e){
45358 var img = new Image();
45359 img.onload = function(){
45361 this.canvasElCtx().drawImage(img, 0, 0);
45363 img.src = e.target.result;
45366 reader.readAsDataURL(e.target.files[0]);
45369 // Bezier Point Constructor
45370 Point: (function () {
45371 function Point(x, y, time) {
45374 this.time = time || Date.now();
45376 Point.prototype.distanceTo = function (start) {
45377 return Math.sqrt(Math.pow(this.x - start.x, 2) + Math.pow(this.y - start.y, 2));
45379 Point.prototype.equals = function (other) {
45380 return this.x === other.x && this.y === other.y && this.time === other.time;
45382 Point.prototype.velocityFrom = function (start) {
45383 return this.time !== start.time
45384 ? this.distanceTo(start) / (this.time - start.time)
45391 // Bezier Constructor
45392 Bezier: (function () {
45393 function Bezier(startPoint, control2, control1, endPoint, startWidth, endWidth) {
45394 this.startPoint = startPoint;
45395 this.control2 = control2;
45396 this.control1 = control1;
45397 this.endPoint = endPoint;
45398 this.startWidth = startWidth;
45399 this.endWidth = endWidth;
45401 Bezier.fromPoints = function (points, widths, scope) {
45402 var c2 = this.calculateControlPoints(points[0], points[1], points[2], scope).c2;
45403 var c3 = this.calculateControlPoints(points[1], points[2], points[3], scope).c1;
45404 return new Bezier(points[1], c2, c3, points[2], widths.start, widths.end);
45406 Bezier.calculateControlPoints = function (s1, s2, s3, scope) {
45407 var dx1 = s1.x - s2.x;
45408 var dy1 = s1.y - s2.y;
45409 var dx2 = s2.x - s3.x;
45410 var dy2 = s2.y - s3.y;
45411 var m1 = { x: (s1.x + s2.x) / 2.0, y: (s1.y + s2.y) / 2.0 };
45412 var m2 = { x: (s2.x + s3.x) / 2.0, y: (s2.y + s3.y) / 2.0 };
45413 var l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
45414 var l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
45415 var dxm = m1.x - m2.x;
45416 var dym = m1.y - m2.y;
45417 var k = l2 / (l1 + l2);
45418 var cm = { x: m2.x + dxm * k, y: m2.y + dym * k };
45419 var tx = s2.x - cm.x;
45420 var ty = s2.y - cm.y;
45422 c1: new scope.Point(m1.x + tx, m1.y + ty),
45423 c2: new scope.Point(m2.x + tx, m2.y + ty)
45426 Bezier.prototype.length = function () {
45431 for (var i = 0; i <= steps; i += 1) {
45433 var cx = this.point(t, this.startPoint.x, this.control1.x, this.control2.x, this.endPoint.x);
45434 var cy = this.point(t, this.startPoint.y, this.control1.y, this.control2.y, this.endPoint.y);
45436 var xdiff = cx - px;
45437 var ydiff = cy - py;
45438 length += Math.sqrt(xdiff * xdiff + ydiff * ydiff);
45445 Bezier.prototype.point = function (t, start, c1, c2, end) {
45446 return (start * (1.0 - t) * (1.0 - t) * (1.0 - t))
45447 + (3.0 * c1 * (1.0 - t) * (1.0 - t) * t)
45448 + (3.0 * c2 * (1.0 - t) * t * t)
45449 + (end * t * t * t);
45454 throttleStroke: function(fn, wait) {
45455 if (wait === void 0) { wait = 250; }
45457 var timeout = null;
45461 var later = function () {
45462 previous = Date.now();
45464 result = fn.apply(storedContext, storedArgs);
45466 storedContext = null;
45470 return function wrapper() {
45472 for (var _i = 0; _i < arguments.length; _i++) {
45473 args[_i] = arguments[_i];
45475 var now = Date.now();
45476 var remaining = wait - (now - previous);
45477 storedContext = this;
45479 if (remaining <= 0 || remaining > wait) {
45481 clearTimeout(timeout);
45485 result = fn.apply(storedContext, storedArgs);
45487 storedContext = null;
45491 else if (!timeout) {
45492 timeout = window.setTimeout(later, remaining);