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 * @children Roo.bootstrap.Component
1974 * Bootstrap Card class
1977 * possible... may not be implemented..
1978 * @cfg {String} header_image src url of image.
1979 * @cfg {String|Object} header
1980 * @cfg {Number} header_size (0|1|2|3|4|5) H1 or H2 etc.. 0 indicates default
1981 * @cfg {Number} header_weight (primary|secondary|success|info|warning|danger|light|dark)
1983 * @cfg {String} title
1984 * @cfg {String} subtitle
1985 * @cfg {String|Boolean} html -- html contents - or just use children.. use false to hide it..
1986 * @cfg {String} footer
1988 * @cfg {String} weight (primary|warning|info|danger|secondary|success|light|dark)
1990 * @cfg {String} margin (0|1|2|3|4|5|auto)
1991 * @cfg {String} margin_top (0|1|2|3|4|5|auto)
1992 * @cfg {String} margin_bottom (0|1|2|3|4|5|auto)
1993 * @cfg {String} margin_left (0|1|2|3|4|5|auto)
1994 * @cfg {String} margin_right (0|1|2|3|4|5|auto)
1995 * @cfg {String} margin_x (0|1|2|3|4|5|auto)
1996 * @cfg {String} margin_y (0|1|2|3|4|5|auto)
1998 * @cfg {String} padding (0|1|2|3|4|5)
1999 * @cfg {String} padding_top (0|1|2|3|4|5)next_to_card
2000 * @cfg {String} padding_bottom (0|1|2|3|4|5)
2001 * @cfg {String} padding_left (0|1|2|3|4|5)
2002 * @cfg {String} padding_right (0|1|2|3|4|5)
2003 * @cfg {String} padding_x (0|1|2|3|4|5)
2004 * @cfg {String} padding_y (0|1|2|3|4|5)
2006 * @cfg {String} display (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
2007 * @cfg {String} display_xs (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
2008 * @cfg {String} display_sm (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
2009 * @cfg {String} display_lg (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
2010 * @cfg {String} display_xl (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
2012 * @config {Boolean} dragable if this card can be dragged.
2013 * @config {String} drag_group group for drag
2014 * @config {Boolean} dropable if this card can recieve other cards being dropped onto it..
2015 * @config {String} drop_group group for drag
2017 * @config {Boolean} collapsable can the body be collapsed.
2018 * @config {Boolean} collapsed is the body collapsed when rendered...
2019 * @config {Boolean} rotateable can the body be rotated by clicking on it..
2020 * @config {Boolean} rotated is the body rotated when rendered...
2023 * Create a new Container
2024 * @param {Object} config The config object
2027 Roo.bootstrap.Card = function(config){
2028 Roo.bootstrap.Card.superclass.constructor.call(this, config);
2034 * When a element a card is dropped
2035 * @param {Roo.bootstrap.Card} this
2038 * @param {Roo.bootstrap.Card} move_card the card being dropped?
2039 * @param {String} position 'above' or 'below'
2040 * @param {Roo.bootstrap.Card} next_to_card What card position is relative to of 'false' for empty list.
2046 * When a element a card is rotate
2047 * @param {Roo.bootstrap.Card} this
2048 * @param {Roo.Element} n the node being dropped?
2049 * @param {Boolean} rotate status
2054 * When a card element is dragged over ready to drop (return false to block dropable)
2055 * @param {Roo.bootstrap.Card} this
2056 * @param {Object} data from dragdrop
2064 Roo.extend(Roo.bootstrap.Card, Roo.bootstrap.Component, {
2069 margin: '', /// may be better in component?
2099 collapsable : false,
2108 childContainer : false,
2109 dropEl : false, /// the dom placeholde element that indicates drop location.
2110 containerEl: false, // body container
2111 bodyEl: false, // card-body
2112 headerContainerEl : false, //
2114 header_imageEl : false,
2117 layoutCls : function()
2121 Roo.log(this.margin_bottom.length);
2122 ['', 'top', 'bottom', 'left', 'right', 'x', 'y' ].forEach(function(v) {
2123 // in theory these can do margin_top : ml-xs-3 ??? but we don't support that yet
2125 if (('' + t['margin' + (v.length ? '_' : '') + v]).length) {
2126 cls += ' m' + (v.length ? v[0] : '') + '-' + t['margin' + (v.length ? '_' : '') + v];
2128 if (('' + t['padding' + (v.length ? '_' : '') + v]).length) {
2129 cls += ' p' + (v.length ? v[0] : '') + '-' + t['padding' + (v.length ? '_' : '') + v];
2133 ['', 'xs', 'sm', 'lg', 'xl'].forEach(function(v) {
2134 if (('' + t['display' + (v.length ? '_' : '') + v]).length) {
2135 cls += ' d' + (v.length ? '-' : '') + v + '-' + t['display' + (v.length ? '_' : '') + v]
2139 // more generic support?
2147 // Roo.log("Call onRender: " + this.xtype);
2148 /* We are looking at something like this.
2150 <img src="..." class="card-img-top" alt="...">
2151 <div class="card-body">
2152 <h5 class="card-title">Card title</h5>
2153 <h6 class="card-subtitle mb-2 text-muted">Card subtitle</h6>
2155 >> this bit is really the body...
2156 <div> << we will ad dthis in hopefully it will not break shit.
2158 ** card text does not actually have any styling...
2160 <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>
2163 <a href="#" class="card-link">Card link</a>
2166 <div class="card-footer">
2167 <small class="text-muted">Last updated 3 mins ago</small>
2171 getAutoCreate : function(){
2179 if (this.weight.length && this.weight != 'light') {
2180 cfg.cls += ' text-white';
2182 cfg.cls += ' text-dark'; // need as it's nested..
2184 if (this.weight.length) {
2185 cfg.cls += ' bg-' + this.weight;
2188 cfg.cls += ' ' + this.layoutCls();
2191 var hdr_ctr = false;
2192 if (this.header.length) {
2194 tag : this.header_size > 0 ? 'h' + this.header_size : 'div',
2195 cls : 'card-header ' + (this.header_weight ? 'bg-' + this.header_weight : ''),
2203 cls : 'card-header d-none ' + (this.header_weight ? 'bg-' + this.header_weight : ''),
2209 if (this.collapsable) {
2212 cls : 'd-block user-select-none',
2216 cls : 'roo-collapse-toggle fa fa-chevron-down float-right ' + (this.collapsed ? 'collapsed' : '')
2221 hdr.cn.push(hdr_ctr);
2226 cls: 'roo-card-header-ctr' + ( this.header.length ? '' : ' d-none'),
2231 if (this.header_image.length) {
2234 cls : 'card-img-top',
2235 src: this.header_image // escape?
2240 cls : 'card-img-top d-none'
2246 cls : 'card-body' + (this.html === false ? ' d-none' : ''),
2250 if (this.collapsable || this.rotateable) {
2253 cls : 'roo-collapsable collapse ' + (this.collapsed || this.rotated ? '' : 'show'),
2260 if (this.title.length) {
2264 src: this.title // escape?
2268 if (this.subtitle.length) {
2272 src: this.subtitle // escape?
2278 cls : 'roo-card-body-ctr'
2281 if (this.html.length) {
2287 // fixme ? handle objects?
2289 if (this.footer.length) {
2292 cls : 'card-footer ' + (this.rotated ? 'd-none' : ''),
2297 cfg.cn.push({cls : 'card-footer d-none'});
2306 getCardHeader : function()
2308 var ret = this.el.select('.card-header',true).first();
2309 if (ret.hasClass('d-none')) {
2310 ret.removeClass('d-none');
2315 getCardFooter : function()
2317 var ret = this.el.select('.card-footer',true).first();
2318 if (ret.hasClass('d-none')) {
2319 ret.removeClass('d-none');
2324 getCardImageTop : function()
2326 var ret = this.header_imageEl;
2327 if (ret.hasClass('d-none')) {
2328 ret.removeClass('d-none');
2334 getChildContainer : function()
2340 return this.el.select('.roo-card-body-ctr',true).first();
2343 initEvents: function()
2345 this.bodyEl = this.el.select('.card-body',true).first();
2346 this.containerEl = this.getChildContainer();
2348 this.dragZone = new Roo.dd.DragZone(this.getEl(), {
2349 containerScroll: true,
2350 ddGroup: this.drag_group || 'default_card_drag_group'
2352 this.dragZone.getDragData = this.getDragData.createDelegate(this);
2354 if (this.dropable) {
2355 this.dropZone = new Roo.dd.DropZone(this.el.select('.card-body',true).first() , {
2356 containerScroll: true,
2357 ddGroup: this.drop_group || 'default_card_drag_group'
2359 this.dropZone.getTargetFromEvent = this.getTargetFromEvent.createDelegate(this);
2360 this.dropZone.onNodeEnter = this.onNodeEnter.createDelegate(this);
2361 this.dropZone.onNodeOver = this.onNodeOver.createDelegate(this);
2362 this.dropZone.onNodeOut = this.onNodeOut.createDelegate(this);
2363 this.dropZone.onNodeDrop = this.onNodeDrop.createDelegate(this);
2366 if (this.collapsable) {
2367 this.el.select('.card-header',true).on('click', this.onToggleCollapse, this);
2369 if (this.rotateable) {
2370 this.el.select('.card-header',true).on('click', this.onToggleRotate, this);
2372 this.collapsableEl = this.el.select('.roo-collapsable',true).first();
2374 this.footerEl = this.el.select('.card-footer',true).first();
2375 this.collapsableToggleEl = this.el.select('.roo-collapse-toggle',true).first();
2376 this.headerContainerEl = this.el.select('.roo-card-header-ctr',true).first();
2377 this.headerEl = this.el.select('.card-header',true).first();
2380 this.el.addClass('roo-card-rotated');
2381 this.fireEvent('rotate', this, true);
2383 this.header_imageEl = this.el.select('.card-img-top',true).first();
2384 this.header_imageEl.on('load', this.onHeaderImageLoad, this );
2387 getDragData : function(e)
2389 var target = this.getEl();
2391 //this.handleSelection(e);
2396 nodes: this.getEl(),
2401 dragData.ddel = target.dom ; // the div element
2402 Roo.log(target.getWidth( ));
2403 dragData.ddel.style.width = target.getWidth() + 'px';
2410 * Part of the Roo.dd.DropZone interface. If no target node is found, the
2411 * whole Element becomes the target, and this causes the drop gesture to append.
2413 * Returns an object:
2416 position : 'below' or 'above'
2417 card : relateive to card OBJECT (or true for no cards listed)
2418 items_n : relative to nth item in list
2419 card_n : relative to nth card in list
2424 getTargetFromEvent : function(e, dragged_card_el)
2426 var target = e.getTarget();
2427 while ((target !== null) && (target.parentNode != this.containerEl.dom)) {
2428 target = target.parentNode;
2439 //Roo.log([ 'target' , target ? target.id : '--nothing--']);
2440 // see if target is one of the 'cards'...
2443 //Roo.log(this.items.length);
2446 var last_card_n = 0;
2448 for (var i = 0;i< this.items.length;i++) {
2450 if (!this.items[i].el.hasClass('card')) {
2453 pos = this.getDropPoint(e, this.items[i].el.dom);
2455 cards_len = ret.cards.length;
2456 //Roo.log(this.items[i].el.dom.id);
2457 ret.cards.push(this.items[i]);
2459 if (ret.card_n < 0 && pos == 'above') {
2460 ret.position = cards_len > 0 ? 'below' : pos;
2461 ret.items_n = i > 0 ? i - 1 : 0;
2462 ret.card_n = cards_len > 0 ? cards_len - 1 : 0;
2463 ret.card = ret.cards[ret.card_n];
2466 if (!ret.cards.length) {
2468 ret.position = 'below';
2472 // could not find a card.. stick it at the end..
2473 if (ret.card_n < 0) {
2474 ret.card_n = last_card_n;
2475 ret.card = ret.cards[last_card_n];
2476 ret.items_n = this.items.indexOf(ret.cards[last_card_n]);
2477 ret.position = 'below';
2480 if (this.items[ret.items_n].el == dragged_card_el) {
2484 if (ret.position == 'below') {
2485 var card_after = ret.card_n+1 == ret.cards.length ? false : ret.cards[ret.card_n+1];
2487 if (card_after && card_after.el == dragged_card_el) {
2494 var card_before = ret.card_n > 0 ? ret.cards[ret.card_n-1] : false;
2496 if (card_before && card_before.el == dragged_card_el) {
2503 onNodeEnter : function(n, dd, e, data){
2506 onNodeOver : function(n, dd, e, data)
2509 var target_info = this.getTargetFromEvent(e,data.source.el);
2510 if (target_info === false) {
2511 this.dropPlaceHolder('hide');
2514 Roo.log(['getTargetFromEvent', target_info ]);
2517 if (this.fireEvent('cardover', this, [ data ]) === false) {
2521 this.dropPlaceHolder('show', target_info,data);
2525 onNodeOut : function(n, dd, e, data){
2526 this.dropPlaceHolder('hide');
2529 onNodeDrop : function(n, dd, e, data)
2532 // call drop - return false if
2534 // this could actually fail - if the Network drops..
2535 // we will ignore this at present..- client should probably reload
2536 // the whole set of cards if stuff like that fails.
2539 var info = this.getTargetFromEvent(e,data.source.el);
2540 if (info === false) {
2543 this.dropPlaceHolder('hide');
2547 this.acceptCard(data.source, info.position, info.card, info.items_n);
2551 firstChildCard : function()
2553 for (var i = 0;i< this.items.length;i++) {
2555 if (!this.items[i].el.hasClass('card')) {
2558 return this.items[i];
2560 return this.items.length ? this.items[this.items.length-1] : false; // don't try and put stuff after the cards...
2565 * - card.acceptCard(move_card, info.position, info.card, info.items_n);
2567 acceptCard : function(move_card, position, next_to_card )
2569 if (this.fireEvent("drop", this, move_card, position, next_to_card) === false) {
2573 var to_items_n = next_to_card ? this.items.indexOf(next_to_card) : 0;
2575 move_card.parent().removeCard(move_card);
2578 var dom = move_card.el.dom;
2579 dom.style.width = ''; // clear with - which is set by drag.
2581 if (next_to_card !== false && next_to_card !== true && next_to_card.el.dom.parentNode) {
2582 var cardel = next_to_card.el.dom;
2584 if (position == 'above' ) {
2585 cardel.parentNode.insertBefore(dom, cardel);
2586 } else if (cardel.nextSibling) {
2587 cardel.parentNode.insertBefore(dom,cardel.nextSibling);
2589 cardel.parentNode.append(dom);
2592 // card container???
2593 this.containerEl.dom.append(dom);
2596 //FIXME HANDLE card = true
2598 // add this to the correct place in items.
2600 // remove Card from items.
2603 if (this.items.length) {
2605 //Roo.log([info.items_n, info.position, this.items.length]);
2606 for (var i =0; i < this.items.length; i++) {
2607 if (i == to_items_n && position == 'above') {
2608 nitems.push(move_card);
2610 nitems.push(this.items[i]);
2611 if (i == to_items_n && position == 'below') {
2612 nitems.push(move_card);
2615 this.items = nitems;
2616 Roo.log(this.items);
2618 this.items.push(move_card);
2621 move_card.parentId = this.id;
2627 removeCard : function(c)
2629 this.items = this.items.filter(function(e) { return e != c });
2632 dom.parentNode.removeChild(dom);
2633 dom.style.width = ''; // clear with - which is set by drag.
2638 /** Decide whether to drop above or below a View node. */
2639 getDropPoint : function(e, n, dd)
2644 if (n == this.containerEl.dom) {
2647 var t = Roo.lib.Dom.getY(n), b = t + n.offsetHeight;
2648 var c = t + (b - t) / 2;
2649 var y = Roo.lib.Event.getPageY(e);
2656 onToggleCollapse : function(e)
2658 if (this.collapsed) {
2659 this.el.select('.roo-collapse-toggle').removeClass('collapsed');
2660 this.collapsableEl.addClass('show');
2661 this.collapsed = false;
2664 this.el.select('.roo-collapse-toggle').addClass('collapsed');
2665 this.collapsableEl.removeClass('show');
2666 this.collapsed = true;
2671 onToggleRotate : function(e)
2673 this.collapsableEl.removeClass('show');
2674 this.footerEl.removeClass('d-none');
2675 this.el.removeClass('roo-card-rotated');
2676 this.el.removeClass('d-none');
2679 this.collapsableEl.addClass('show');
2680 this.rotated = false;
2681 this.fireEvent('rotate', this, this.rotated);
2684 this.el.addClass('roo-card-rotated');
2685 this.footerEl.addClass('d-none');
2686 this.el.select('.roo-collapsable').removeClass('show');
2688 this.rotated = true;
2689 this.fireEvent('rotate', this, this.rotated);
2693 dropPlaceHolder: function (action, info, data)
2695 if (this.dropEl === false) {
2696 this.dropEl = Roo.DomHelper.append(this.containerEl, {
2700 this.dropEl.removeClass(['d-none', 'd-block']);
2701 if (action == 'hide') {
2703 this.dropEl.addClass('d-none');
2706 // FIXME - info.card == true!!!
2707 this.dropEl.dom.parentNode.removeChild(this.dropEl.dom);
2709 if (info.card !== true) {
2710 var cardel = info.card.el.dom;
2712 if (info.position == 'above') {
2713 cardel.parentNode.insertBefore(this.dropEl.dom, cardel);
2714 } else if (cardel.nextSibling) {
2715 cardel.parentNode.insertBefore(this.dropEl.dom,cardel.nextSibling);
2717 cardel.parentNode.append(this.dropEl.dom);
2720 // card container???
2721 this.containerEl.dom.append(this.dropEl.dom);
2724 this.dropEl.addClass('d-block roo-card-dropzone');
2726 this.dropEl.setHeight( Roo.get(data.ddel).getHeight() );
2733 setHeaderText: function(html)
2736 if (this.headerContainerEl) {
2737 this.headerContainerEl.dom.innerHTML = html;
2740 onHeaderImageLoad : function(ev, he)
2742 if (!this.header_image_fit_square) {
2746 var hw = he.naturalHeight / he.naturalWidth;
2749 //var w = he.dom.naturalWidth;
2752 he.style.position = 'relative';
2754 var nw = (ww * (1/hw));
2755 Roo.get(he).setSize( ww * (1/hw), ww);
2756 he.style.left = ((ww - nw)/ 2) + 'px';
2757 he.style.position = 'relative';
2768 * Card header - holder for the card header elements.
2773 * @class Roo.bootstrap.CardHeader
2774 * @extends Roo.bootstrap.Element
2775 * Bootstrap CardHeader class
2777 * Create a new Card Header - that you can embed children into
2778 * @param {Object} config The config object
2781 Roo.bootstrap.CardHeader = function(config){
2782 Roo.bootstrap.CardHeader.superclass.constructor.call(this, config);
2785 Roo.extend(Roo.bootstrap.CardHeader, Roo.bootstrap.Element, {
2788 container_method : 'getCardHeader'
2801 * Card footer - holder for the card footer elements.
2806 * @class Roo.bootstrap.CardFooter
2807 * @extends Roo.bootstrap.Element
2808 * Bootstrap CardFooter class
2810 * Create a new Card Footer - that you can embed children into
2811 * @param {Object} config The config object
2814 Roo.bootstrap.CardFooter = function(config){
2815 Roo.bootstrap.CardFooter.superclass.constructor.call(this, config);
2818 Roo.extend(Roo.bootstrap.CardFooter, Roo.bootstrap.Element, {
2821 container_method : 'getCardFooter'
2834 * Card header - holder for the card header elements.
2839 * @class Roo.bootstrap.CardImageTop
2840 * @extends Roo.bootstrap.Element
2841 * Bootstrap CardImageTop class
2843 * Create a new Card Image Top container
2844 * @param {Object} config The config object
2847 Roo.bootstrap.CardImageTop = function(config){
2848 Roo.bootstrap.CardImageTop.superclass.constructor.call(this, config);
2851 Roo.extend(Roo.bootstrap.CardImageTop, Roo.bootstrap.Element, {
2854 container_method : 'getCardImageTop'
2869 * @class Roo.bootstrap.ButtonUploader
2870 * @extends Roo.bootstrap.Button
2871 * Bootstrap Button Uploader class - it's a button which when you add files to it
2874 * @cfg {Number} errorTimeout default 3000
2875 * @cfg {Array} images an array of ?? Img objects ??? when loading existing files..
2876 * @cfg {Array} html The button text.
2877 * @cfg {Boolean} multiple (default true) Should the upload allow multiple files to be uploaded.
2880 * Create a new CardUploader
2881 * @param {Object} config The config object
2884 Roo.bootstrap.ButtonUploader = function(config){
2888 Roo.bootstrap.ButtonUploader.superclass.constructor.call(this, config);
2894 * @event beforeselect
2895 * When button is pressed, before show upload files dialog is shown
2896 * @param {Roo.bootstrap.UploaderButton} this
2899 'beforeselect' : true,
2901 * @event fired when files have been selected,
2902 * When a the download link is clicked
2903 * @param {Roo.bootstrap.UploaderButton} this
2904 * @param {Array} Array of files that have been uploaded
2911 Roo.extend(Roo.bootstrap.ButtonUploader, Roo.bootstrap.Button, {
2914 errorTimeout : 3000,
2918 fileCollection : false,
2923 getAutoCreate : function()
2928 cls : 'd-none roo-card-upload-selector'
2931 if (this.multiple) {
2932 im.multiple = 'multiple';
2938 Roo.bootstrap.Button.prototype.getAutoCreate.call(this),
2948 initEvents : function()
2951 Roo.bootstrap.Button.prototype.initEvents.call(this);
2957 this.urlAPI = (window.createObjectURL && window) ||
2958 (window.URL && URL.revokeObjectURL && URL) ||
2959 (window.webkitURL && webkitURL);
2964 this.selectorEl = this.el.select('.roo-card-upload-selector', true).first();
2966 this.selectorEl.on('change', this.onFileSelected, this);
2973 onClick : function(e)
2977 if ( this.fireEvent('beforeselect', this) === false) {
2981 this.selectorEl.dom.click();
2985 onFileSelected : function(e)
2989 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
2992 var files = Array.prototype.slice.call(this.selectorEl.dom.files);
2993 this.selectorEl.dom.value = '';// hopefully reset..
2995 this.fireEvent('uploaded', this, files );
3003 * addCard - add an Attachment to the uploader
3004 * @param data - the data about the image to upload
3008 title : "Title of file",
3009 is_uploaded : false,
3010 src : "http://.....",
3011 srcfile : { the File upload object },
3012 mimetype : file.type,
3015 .. any other data...
3040 * @class Roo.bootstrap.Img
3041 * @extends Roo.bootstrap.Component
3042 * Bootstrap Img class
3043 * @cfg {Boolean} imgResponsive false | true
3044 * @cfg {String} border rounded | circle | thumbnail
3045 * @cfg {String} src image source
3046 * @cfg {String} alt image alternative text
3047 * @cfg {String} href a tag href
3048 * @cfg {String} target (_self|_blank|_parent|_top)target for a href.
3049 * @cfg {String} xsUrl xs image source
3050 * @cfg {String} smUrl sm image source
3051 * @cfg {String} mdUrl md image source
3052 * @cfg {String} lgUrl lg image source
3053 * @cfg {Boolean} backgroundContain (use style background and contain image in content)
3056 * Create a new Input
3057 * @param {Object} config The config object
3060 Roo.bootstrap.Img = function(config){
3061 Roo.bootstrap.Img.superclass.constructor.call(this, config);
3067 * The img click event for the img.
3068 * @param {Roo.EventObject} e
3073 * The when any image loads
3074 * @param {Roo.EventObject} e
3080 Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, {
3082 imgResponsive: true,
3091 backgroundContain : false,
3093 getAutoCreate : function()
3095 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
3096 return this.createSingleImg();
3101 cls: 'roo-image-responsive-group',
3106 Roo.each(['xs', 'sm', 'md', 'lg'], function(size){
3108 if(!_this[size + 'Url']){
3114 cls: (_this.imgResponsive) ? 'img-responsive' : '',
3115 html: _this.html || cfg.html,
3116 src: _this[size + 'Url']
3119 img.cls += ' roo-image-responsive-' + size;
3121 var s = ['xs', 'sm', 'md', 'lg'];
3123 s.splice(s.indexOf(size), 1);
3125 Roo.each(s, function(ss){
3126 img.cls += ' hidden-' + ss;
3129 if (['rounded','circle','thumbnail'].indexOf(_this.border)>-1) {
3130 cfg.cls += ' img-' + _this.border;
3134 cfg.alt = _this.alt;
3147 a.target = _this.target;
3151 cfg.cn.push((_this.href) ? a : img);
3158 createSingleImg : function()
3162 cls: (this.imgResponsive) ? 'img-responsive' : '',
3164 src : Roo.BLANK_IMAGE_URL // just incase src get's set to undefined?!?
3167 if (this.backgroundContain) {
3168 cfg.cls += ' background-contain';
3171 cfg.html = this.html || cfg.html;
3173 if (this.backgroundContain) {
3174 cfg.style="background-image: url(" + this.src + ')';
3176 cfg.src = this.src || cfg.src;
3179 if (['rounded','circle','thumbnail'].indexOf(this.border)>-1) {
3180 cfg.cls += ' img-' + this.border;
3197 a.target = this.target;
3202 return (this.href) ? a : cfg;
3205 initEvents: function()
3208 this.el.on('click', this.onClick, this);
3210 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
3211 this.el.on('load', this.onImageLoad, this);
3213 // not sure if this works.. not tested
3214 this.el.select('img', true).on('load', this.onImageLoad, this);
3219 onClick : function(e)
3221 Roo.log('img onclick');
3222 this.fireEvent('click', this, e);
3224 onImageLoad: function(e)
3226 Roo.log('img load');
3227 this.fireEvent('load', this, e);
3231 * Sets the url of the image - used to update it
3232 * @param {String} url the url of the image
3235 setSrc : function(url)
3239 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
3240 if (this.backgroundContain) {
3241 this.el.dom.style.backgroundImage = 'url(' + url + ')';
3243 this.el.dom.src = url;
3248 this.el.select('img', true).first().dom.src = url;
3264 * @class Roo.bootstrap.Link
3265 * @extends Roo.bootstrap.Component
3266 * Bootstrap Link Class
3267 * @cfg {String} alt image alternative text
3268 * @cfg {String} href a tag href
3269 * @cfg {String} target (_self|_blank|_parent|_top) target for a href.
3270 * @cfg {String} html the content of the link.
3271 * @cfg {String} anchor name for the anchor link
3272 * @cfg {String} fa - favicon
3274 * @cfg {Boolean} preventDefault (true | false) default false
3278 * Create a new Input
3279 * @param {Object} config The config object
3282 Roo.bootstrap.Link = function(config){
3283 Roo.bootstrap.Link.superclass.constructor.call(this, config);
3289 * The img click event for the img.
3290 * @param {Roo.EventObject} e
3296 Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component, {
3300 preventDefault: false,
3306 getAutoCreate : function()
3308 var html = this.html || '';
3310 if (this.fa !== false) {
3311 html = '<i class="fa fa-' + this.fa + '"></i>';
3316 // anchor's do not require html/href...
3317 if (this.anchor === false) {
3319 cfg.href = this.href || '#';
3321 cfg.name = this.anchor;
3322 if (this.html !== false || this.fa !== false) {
3325 if (this.href !== false) {
3326 cfg.href = this.href;
3330 if(this.alt !== false){
3335 if(this.target !== false) {
3336 cfg.target = this.target;
3342 initEvents: function() {
3344 if(!this.href || this.preventDefault){
3345 this.el.on('click', this.onClick, this);
3349 onClick : function(e)
3351 if(this.preventDefault){
3354 //Roo.log('img onclick');
3355 this.fireEvent('click', this, e);
3368 * @class Roo.bootstrap.Header
3369 * @extends Roo.bootstrap.Component
3370 * Bootstrap Header class
3371 * @cfg {String} html content of header
3372 * @cfg {Number} level (1|2|3|4|5|6) default 1
3375 * Create a new Header
3376 * @param {Object} config The config object
3380 Roo.bootstrap.Header = function(config){
3381 Roo.bootstrap.Header.superclass.constructor.call(this, config);
3384 Roo.extend(Roo.bootstrap.Header, Roo.bootstrap.Component, {
3392 getAutoCreate : function(){
3397 tag: 'h' + (1 *this.level),
3398 html: this.html || ''
3410 * Ext JS Library 1.1.1
3411 * Copyright(c) 2006-2007, Ext JS, LLC.
3413 * Originally Released Under LGPL - original licence link has changed is not relivant.
3416 * <script type="text/javascript">
3420 * @class Roo.bootstrap.MenuMgr
3421 * Provides a common registry of all menu items on a page so that they can be easily accessed by id.
3424 Roo.bootstrap.MenuMgr = function(){
3425 var menus, active, groups = {}, attached = false, lastShow = new Date();
3427 // private - called when first menu is created
3430 active = new Roo.util.MixedCollection();
3431 Roo.get(document).addKeyListener(27, function(){
3432 if(active.length > 0){
3440 if(active && active.length > 0){
3441 var c = active.clone();
3451 if(active.length < 1){
3452 Roo.get(document).un("mouseup", onMouseDown);
3460 var last = active.last();
3461 lastShow = new Date();
3464 Roo.get(document).on("mouseup", onMouseDown);
3469 //m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
3470 m.parentMenu.activeChild = m;
3471 }else if(last && last.isVisible()){
3472 //m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
3477 function onBeforeHide(m){
3479 m.activeChild.hide();
3481 if(m.autoHideTimer){
3482 clearTimeout(m.autoHideTimer);
3483 delete m.autoHideTimer;
3488 function onBeforeShow(m){
3489 var pm = m.parentMenu;
3490 if(!pm && !m.allowOtherMenus){
3492 }else if(pm && pm.activeChild && active != m){
3493 pm.activeChild.hide();
3497 // private this should really trigger on mouseup..
3498 function onMouseDown(e){
3499 Roo.log("on Mouse Up");
3501 if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".dropdown-menu") && !e.getTarget('.user-menu')){
3502 Roo.log("MenuManager hideAll");
3511 function onBeforeCheck(mi, state){
3513 var g = groups[mi.group];
3514 for(var i = 0, l = g.length; i < l; i++){
3516 g[i].setChecked(false);
3525 * Hides all menus that are currently visible
3527 hideAll : function(){
3532 register : function(menu){
3536 menus[menu.id] = menu;
3537 menu.on("beforehide", onBeforeHide);
3538 menu.on("hide", onHide);
3539 menu.on("beforeshow", onBeforeShow);
3540 menu.on("show", onShow);
3542 if(g && menu.events["checkchange"]){
3546 groups[g].push(menu);
3547 menu.on("checkchange", onCheck);
3552 * Returns a {@link Roo.menu.Menu} object
3553 * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will
3554 * be used to generate and return a new Menu instance.
3556 get : function(menu){
3557 if(typeof menu == "string"){ // menu id
3559 }else if(menu.events){ // menu instance
3562 /*else if(typeof menu.length == 'number'){ // array of menu items?
3563 return new Roo.bootstrap.Menu({items:menu});
3564 }else{ // otherwise, must be a config
3565 return new Roo.bootstrap.Menu(menu);
3572 unregister : function(menu){
3573 delete menus[menu.id];
3574 menu.un("beforehide", onBeforeHide);
3575 menu.un("hide", onHide);
3576 menu.un("beforeshow", onBeforeShow);
3577 menu.un("show", onShow);
3579 if(g && menu.events["checkchange"]){
3580 groups[g].remove(menu);
3581 menu.un("checkchange", onCheck);
3586 registerCheckable : function(menuItem){
3587 var g = menuItem.group;
3592 groups[g].push(menuItem);
3593 menuItem.on("beforecheckchange", onBeforeCheck);
3598 unregisterCheckable : function(menuItem){
3599 var g = menuItem.group;
3601 groups[g].remove(menuItem);
3602 menuItem.un("beforecheckchange", onBeforeCheck);
3614 * @class Roo.bootstrap.Menu
3615 * @extends Roo.bootstrap.Component
3616 * Bootstrap Menu class - container for MenuItems
3617 * @cfg {String} type (dropdown|treeview|submenu) type of menu
3618 * @cfg {bool} hidden if the menu should be hidden when rendered.
3619 * @cfg {bool} stopEvent (true|false) Stop event after trigger press (default true)
3620 * @cfg {bool} isLink (true|false) the menu has link disable auto expand and collaspe (default false)
3621 * @cfg {bool} hideTrigger (true|false) default false - hide the carret for trigger.
3622 * @cfg {String} align default tl-bl? == below - how the menu should be aligned.
3626 * @param {Object} config The config object
3630 Roo.bootstrap.Menu = function(config){
3632 if (config.type == 'treeview') {
3633 // normally menu's are drawn attached to the document to handle layering etc..
3634 // however treeview (used by the docs menu is drawn into the parent element)
3635 this.container_method = 'getChildContainer';
3638 Roo.bootstrap.Menu.superclass.constructor.call(this, config);
3639 if (this.registerMenu && this.type != 'treeview') {
3640 Roo.bootstrap.MenuMgr.register(this);
3647 * Fires before this menu is displayed (return false to block)
3648 * @param {Roo.menu.Menu} this
3653 * Fires before this menu is hidden (return false to block)
3654 * @param {Roo.menu.Menu} this
3659 * Fires after this menu is displayed
3660 * @param {Roo.menu.Menu} this
3665 * Fires after this menu is hidden
3666 * @param {Roo.menu.Menu} this
3671 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
3672 * @param {Roo.menu.Menu} this
3673 * @param {Roo.menu.Item} menuItem The menu item that was clicked
3674 * @param {Roo.EventObject} e
3679 * Fires when the mouse is hovering over this menu
3680 * @param {Roo.menu.Menu} this
3681 * @param {Roo.EventObject} e
3682 * @param {Roo.menu.Item} menuItem The menu item that was clicked
3687 * Fires when the mouse exits this menu
3688 * @param {Roo.menu.Menu} this
3689 * @param {Roo.EventObject} e
3690 * @param {Roo.menu.Item} menuItem The menu item that was clicked
3695 * Fires when a menu item contained in this menu is clicked
3696 * @param {Roo.menu.BaseItem} baseItem The BaseItem that was clicked
3697 * @param {Roo.EventObject} e
3701 this.menuitems = new Roo.util.MixedCollection(false, function(o) { return o.el.id; });
3704 Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, {
3708 triggerEl : false, // is this set by component builder? -- it should really be fetched from parent()???
3711 * @cfg {Boolean} registerMenu True (default) - means that clicking on screen etc. hides it.
3713 registerMenu : true,
3715 menuItems :false, // stores the menu items..
3725 container_method : 'getDocumentBody', // so the menu is rendered on the body and zIndex works.
3727 hideTrigger : false,
3732 getChildContainer : function() {
3736 getAutoCreate : function(){
3738 //if (['right'].indexOf(this.align)!==-1) {
3739 // cfg.cn[1].cls += ' pull-right'
3744 cls : 'dropdown-menu shadow' ,
3745 style : 'z-index:1000'
3749 if (this.type === 'submenu') {
3750 cfg.cls = 'submenu active';
3752 if (this.type === 'treeview') {
3753 cfg.cls = 'treeview-menu';
3758 initEvents : function() {
3760 // Roo.log("ADD event");
3761 // Roo.log(this.triggerEl.dom);
3762 if (this.triggerEl) {
3764 this.triggerEl.on('click', this.onTriggerClick, this);
3766 this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this);
3768 if (!this.hideTrigger) {
3769 if (this.triggerEl.hasClass('nav-item') && this.triggerEl.select('.nav-link',true).length) {
3770 // dropdown toggle on the 'a' in BS4?
3771 this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle');
3773 this.triggerEl.addClass('dropdown-toggle');
3779 this.el.on('touchstart' , this.onTouch, this);
3781 this.el.on('click' , this.onClick, this);
3783 this.el.on("mouseover", this.onMouseOver, this);
3784 this.el.on("mouseout", this.onMouseOut, this);
3788 findTargetItem : function(e)
3790 var t = e.getTarget(".dropdown-menu-item", this.el, true);
3794 //Roo.log(t); Roo.log(t.id);
3796 //Roo.log(this.menuitems);
3797 return this.menuitems.get(t.id);
3799 //return this.items.get(t.menuItemId);
3805 onTouch : function(e)
3807 Roo.log("menu.onTouch");
3808 //e.stopEvent(); this make the user popdown broken
3812 onClick : function(e)
3814 Roo.log("menu.onClick");
3816 var t = this.findTargetItem(e);
3817 if(!t || t.isContainer){
3822 if (Roo.isTouch && e.type == 'touchstart' && t.menu && !t.disabled) {
3823 if(t == this.activeItem && t.shouldDeactivate(e)){
3824 this.activeItem.deactivate();
3825 delete this.activeItem;
3829 this.setActiveItem(t, true);
3837 Roo.log('pass click event');
3841 this.fireEvent("click", this, t, e);
3845 if(!t.href.length || t.href == '#'){
3846 (function() { _this.hide(); }).defer(100);
3851 onMouseOver : function(e){
3852 var t = this.findTargetItem(e);
3855 // if(t.canActivate && !t.disabled){
3856 // this.setActiveItem(t, true);
3860 this.fireEvent("mouseover", this, e, t);
3862 isVisible : function(){
3863 return !this.hidden;
3865 onMouseOut : function(e){
3866 var t = this.findTargetItem(e);
3869 // if(t == this.activeItem && t.shouldDeactivate(e)){
3870 // this.activeItem.deactivate();
3871 // delete this.activeItem;
3874 this.fireEvent("mouseout", this, e, t);
3879 * Displays this menu relative to another element
3880 * @param {String/HTMLElement/Roo.Element} element The element to align to
3881 * @param {String} position (optional) The {@link Roo.Element#alignTo} anchor position to use in aligning to
3882 * the element (defaults to this.defaultAlign)
3883 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
3885 show : function(el, pos, parentMenu)
3887 if (false === this.fireEvent("beforeshow", this)) {
3888 Roo.log("show canceled");
3891 this.parentMenu = parentMenu;
3895 this.el.addClass('show'); // show otherwise we do not know how big we are..
3897 var xy = this.el.getAlignToXY(el, pos);
3899 // bl-tl << left align below
3900 // tl-bl << left align
3902 if(this.el.getWidth() + xy[0] >= Roo.lib.Dom.getViewWidth()){
3903 // if it goes to far to the right.. -> align left.
3904 xy = this.el.getAlignToXY(el, this.align.replace('/l/g', 'r'))
3907 // was left align - go right?
3908 xy = this.el.getAlignToXY(el, this.align.replace('/r/g', 'l'))
3911 // goes down the bottom
3912 if(this.el.getHeight() + xy[1] >= Roo.lib.Dom.getViewHeight() ||
3914 var a = this.align.replace('?', '').split('-');
3915 xy = this.el.getAlignToXY(el, a[1] + '-' + a[0] + '?')
3919 this.showAt( xy , parentMenu, false);
3922 * Displays this menu at a specific xy position
3923 * @param {Array} xyPosition Contains X & Y [x, y] values for the position at which to show the menu (coordinates are page-based)
3924 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
3926 showAt : function(xy, parentMenu, /* private: */_e){
3927 this.parentMenu = parentMenu;
3932 this.fireEvent("beforeshow", this);
3933 //xy = this.el.adjustForConstraints(xy);
3937 this.hideMenuItems();
3938 this.hidden = false;
3939 if (this.triggerEl) {
3940 this.triggerEl.addClass('open');
3943 this.el.addClass('show');
3947 // reassign x when hitting right
3949 // reassign y when hitting bottom
3951 // but the list may align on trigger left or trigger top... should it be a properity?
3953 if(this.el.getStyle('top') != 'auto' && this.el.getStyle('top').slice(-1) != "%"){
3958 this.fireEvent("show", this);
3964 this.doFocus.defer(50, this);
3968 doFocus : function(){
3970 this.focusEl.focus();
3975 * Hides this menu and optionally all parent menus
3976 * @param {Boolean} deep (optional) True to hide all parent menus recursively, if any (defaults to false)
3978 hide : function(deep)
3980 if (false === this.fireEvent("beforehide", this)) {
3981 Roo.log("hide canceled");
3984 this.hideMenuItems();
3985 if(this.el && this.isVisible()){
3987 if(this.activeItem){
3988 this.activeItem.deactivate();
3989 this.activeItem = null;
3991 if (this.triggerEl) {
3992 this.triggerEl.removeClass('open');
3995 this.el.removeClass('show');
3997 this.fireEvent("hide", this);
3999 if(deep === true && this.parentMenu){
4000 this.parentMenu.hide(true);
4004 onTriggerClick : function(e)
4006 Roo.log('trigger click');
4008 var target = e.getTarget();
4010 Roo.log(target.nodeName.toLowerCase());
4012 if(target.nodeName.toLowerCase() === 'i'){
4018 onTriggerPress : function(e)
4020 Roo.log('trigger press');
4021 //Roo.log(e.getTarget());
4022 // Roo.log(this.triggerEl.dom);
4024 // trigger only occurs on normal menu's -- if it's a treeview or dropdown... do not hide/show..
4025 var pel = Roo.get(e.getTarget());
4026 if (pel.findParent('.dropdown-menu') || pel.findParent('.treeview-menu') ) {
4027 Roo.log('is treeview or dropdown?');
4031 if(e.getTarget().nodeName.toLowerCase() !== 'i' && this.isLink){
4035 if (this.isVisible()) {
4041 this.show(this.triggerEl, this.align, false);
4044 if(this.stopEvent || e.getTarget().nodeName.toLowerCase() === 'i'){
4051 hideMenuItems : function()
4053 Roo.log("hide Menu Items");
4058 this.el.select('.open',true).each(function(aa) {
4060 aa.removeClass('open');
4064 addxtypeChild : function (tree, cntr) {
4065 var comp= Roo.bootstrap.Menu.superclass.addxtypeChild.call(this, tree, cntr);
4067 this.menuitems.add(comp);
4079 this.getEl().dom.innerHTML = '';
4080 this.menuitems.clear();
4094 * @class Roo.bootstrap.MenuItem
4095 * @extends Roo.bootstrap.Component
4096 * Bootstrap MenuItem class
4097 * @cfg {String} html the menu label
4098 * @cfg {String} href the link
4099 * @cfg {Boolean} preventDefault do not trigger A href on clicks (default false).
4100 * @cfg {Boolean} isContainer is it a container - just returns a drop down item..
4101 * @cfg {Boolean} active used on sidebars to highlight active itesm
4102 * @cfg {String} fa favicon to show on left of menu item.
4103 * @cfg {Roo.bootsrap.Menu} menu the child menu.
4107 * Create a new MenuItem
4108 * @param {Object} config The config object
4112 Roo.bootstrap.MenuItem = function(config){
4113 Roo.bootstrap.MenuItem.superclass.constructor.call(this, config);
4118 * The raw click event for the entire grid.
4119 * @param {Roo.bootstrap.MenuItem} this
4120 * @param {Roo.EventObject} e
4126 Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component, {
4130 preventDefault: false,
4131 isContainer : false,
4135 getAutoCreate : function(){
4137 if(this.isContainer){
4140 cls: 'dropdown-menu-item '
4150 cls : 'dropdown-item',
4155 if (this.fa !== false) {
4158 cls : 'fa fa-' + this.fa
4167 cls: 'dropdown-menu-item',
4170 if (this.parent().type == 'treeview') {
4171 cfg.cls = 'treeview-menu';
4174 cfg.cls += ' active';
4179 anc.href = this.href || cfg.cn[0].href ;
4180 ctag.html = this.html || cfg.cn[0].html ;
4184 initEvents: function()
4186 if (this.parent().type == 'treeview') {
4187 this.el.select('a').on('click', this.onClick, this);
4191 this.menu.parentType = this.xtype;
4192 this.menu.triggerEl = this.el;
4193 this.menu = this.addxtype(Roo.apply({}, this.menu));
4197 onClick : function(e)
4199 Roo.log('item on click ');
4201 if(this.preventDefault){
4204 //this.parent().hideMenuItems();
4206 this.fireEvent('click', this, e);
4225 * @class Roo.bootstrap.MenuSeparator
4226 * @extends Roo.bootstrap.Component
4227 * Bootstrap MenuSeparator class
4230 * Create a new MenuItem
4231 * @param {Object} config The config object
4235 Roo.bootstrap.MenuSeparator = function(config){
4236 Roo.bootstrap.MenuSeparator.superclass.constructor.call(this, config);
4239 Roo.extend(Roo.bootstrap.MenuSeparator, Roo.bootstrap.Component, {
4241 getAutoCreate : function(){
4260 * @class Roo.bootstrap.Modal
4261 * @extends Roo.bootstrap.Component
4264 * @children Roo.bootstrap.Component
4265 * Bootstrap Modal class
4266 * @cfg {String} title Title of dialog
4267 * @cfg {String} html - the body of the dialog (for simple ones) - you can also use template..
4268 * @cfg {Roo.Template} tmpl - a template with variables. to use it, add a handler in show:method adn
4269 * @cfg {Boolean} specificTitle default false
4270 * @cfg {Array} buttons Array of buttons or standard button set..
4271 * @cfg {String} buttonPosition (left|right|center) default right (DEPRICATED) - use mr-auto on buttons to put them on the left
4272 * @cfg {Boolean} animate default true
4273 * @cfg {Boolean} allow_close default true
4274 * @cfg {Boolean} fitwindow default false
4275 * @cfg {Boolean} bodyOverflow should the body element have overflow auto added default false
4276 * @cfg {Number} width fixed width - usefull for chrome extension only really.
4277 * @cfg {Number} height fixed height - usefull for chrome extension only really.
4278 * @cfg {String} size (sm|lg|xl) default empty
4279 * @cfg {Number} max_width set the max width of modal
4280 * @cfg {Boolean} editableTitle can the title be edited
4285 * Create a new Modal Dialog
4286 * @param {Object} config The config object
4289 Roo.bootstrap.Modal = function(config){
4290 Roo.bootstrap.Modal.superclass.constructor.call(this, config);
4295 * The raw btnclick event for the button
4296 * @param {Roo.EventObject} e
4301 * Fire when dialog resize
4302 * @param {Roo.bootstrap.Modal} this
4303 * @param {Roo.EventObject} e
4307 * @event titlechanged
4308 * Fire when the editable title has been changed
4309 * @param {Roo.bootstrap.Modal} this
4310 * @param {Roo.EventObject} value
4312 "titlechanged" : true
4315 this.buttons = this.buttons || [];
4318 this.tmpl = Roo.factory(this.tmpl);
4323 Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, {
4325 title : 'test dialog',
4335 specificTitle: false,
4337 buttonPosition: 'right',
4359 editableTitle : false,
4361 onRender : function(ct, position)
4363 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
4366 var cfg = Roo.apply({}, this.getAutoCreate());
4369 // cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
4371 //if (!cfg.name.length) {
4375 cfg.cls += ' ' + this.cls;
4378 cfg.style = this.style;
4380 this.el = Roo.get(document.body).createChild(cfg, position);
4382 //var type = this.el.dom.type;
4385 if(this.tabIndex !== undefined){
4386 this.el.dom.setAttribute('tabIndex', this.tabIndex);
4389 this.dialogEl = this.el.select('.modal-dialog',true).first();
4390 this.bodyEl = this.el.select('.modal-body',true).first();
4391 this.closeEl = this.el.select('.modal-header .close', true).first();
4392 this.headerEl = this.el.select('.modal-header',true).first();
4393 this.titleEl = this.el.select('.modal-title',true).first();
4394 this.footerEl = this.el.select('.modal-footer',true).first();
4396 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
4398 //this.el.addClass("x-dlg-modal");
4400 if (this.buttons.length) {
4401 Roo.each(this.buttons, function(bb) {
4402 var b = Roo.apply({}, bb);
4403 b.xns = b.xns || Roo.bootstrap;
4404 b.xtype = b.xtype || 'Button';
4405 if (typeof(b.listeners) == 'undefined') {
4406 b.listeners = { click : this.onButtonClick.createDelegate(this) };
4409 var btn = Roo.factory(b);
4411 btn.render(this.getButtonContainer());
4415 // render the children.
4418 if(typeof(this.items) != 'undefined'){
4419 var items = this.items;
4422 for(var i =0;i < items.length;i++) {
4423 nitems.push(this.addxtype(Roo.apply({}, items[i])));
4427 this.items = nitems;
4429 // where are these used - they used to be body/close/footer
4433 //this.el.addClass([this.fieldClass, this.cls]);
4437 getAutoCreate : function()
4439 // we will default to modal-body-overflow - might need to remove or make optional later.
4441 cls : 'modal-body ' + (this.bodyOverflow ? 'overflow-auto' : ''),
4442 html : this.html || ''
4447 cls : 'modal-title',
4451 if(this.specificTitle){ // WTF is this?
4456 if (this.allow_close && Roo.bootstrap.version == 3) {
4466 if (this.editableTitle) {
4468 cls: 'form-control roo-editable-title d-none',
4474 if (this.allow_close && Roo.bootstrap.version == 4) {
4484 if(this.size.length){
4485 size = 'modal-' + this.size;
4488 var footer = Roo.bootstrap.version == 3 ?
4490 cls : 'modal-footer',
4494 cls: 'btn-' + this.buttonPosition
4499 { // BS4 uses mr-auto on left buttons....
4500 cls : 'modal-footer'
4511 cls: "modal-dialog " + size,
4514 cls : "modal-content",
4517 cls : 'modal-header',
4532 modal.cls += ' fade';
4538 getChildContainer : function() {
4543 getButtonContainer : function() {
4545 return Roo.bootstrap.version == 4 ?
4546 this.el.select('.modal-footer',true).first()
4547 : this.el.select('.modal-footer div',true).first();
4550 initEvents : function()
4552 if (this.allow_close) {
4553 this.closeEl.on('click', this.hide, this);
4555 Roo.EventManager.onWindowResize(this.resize, this, true);
4556 if (this.editableTitle) {
4557 this.headerEditEl = this.headerEl.select('.form-control',true).first();
4558 this.headerEl.on('click', function() { this.toggleHeaderInput(true) } , this);
4559 this.headerEditEl.on('keyup', function(e) {
4560 if([ e.RETURN , e.TAB , e.ESC ].indexOf(e.keyCode) > -1) {
4561 this.toggleHeaderInput(false)
4564 this.headerEditEl.on('blur', function(e) {
4565 this.toggleHeaderInput(false)
4574 this.maskEl.setSize(
4575 Roo.lib.Dom.getViewWidth(true),
4576 Roo.lib.Dom.getViewHeight(true)
4579 if (this.fitwindow) {
4581 this.dialogEl.setStyle( { 'max-width' : '100%' });
4583 this.width || Roo.lib.Dom.getViewportWidth(true) - 30,
4584 this.height || Roo.lib.Dom.getViewportHeight(true) // catering margin-top 30 margin-bottom 30
4589 if(this.max_width !== 0) {
4591 var w = Math.min(this.max_width, Roo.lib.Dom.getViewportWidth(true) - 30);
4594 this.setSize(w, this.height);
4598 if(this.max_height) {
4599 this.setSize(w,Math.min(
4601 Roo.lib.Dom.getViewportHeight(true) - 60
4607 if(!this.fit_content) {
4608 this.setSize(w, Roo.lib.Dom.getViewportHeight(true) - 60);
4612 this.setSize(w, Math.min(
4614 this.headerEl.getHeight() +
4615 this.footerEl.getHeight() +
4616 this.getChildHeight(this.bodyEl.dom.childNodes),
4617 Roo.lib.Dom.getViewportHeight(true) - 60)
4623 setSize : function(w,h)
4634 if (!this.rendered) {
4637 this.toggleHeaderInput(false);
4638 //this.el.setStyle('display', 'block');
4639 this.el.removeClass('hideing');
4640 this.el.dom.style.display='block';
4642 Roo.get(document.body).addClass('modal-open');
4644 if(this.animate){ // element has 'fade' - so stuff happens after .3s ?- not sure why the delay?
4647 this.el.addClass('show');
4648 this.el.addClass('in');
4651 this.el.addClass('show');
4652 this.el.addClass('in');
4655 // not sure how we can show data in here..
4657 // this.getChildContainer().dom.innerHTML = this.tmpl.applyTemplate(this);
4660 Roo.get(document.body).addClass("x-body-masked");
4662 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
4663 this.maskEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
4664 this.maskEl.dom.style.display = 'block';
4665 this.maskEl.addClass('show');
4670 this.fireEvent('show', this);
4672 // set zindex here - otherwise it appears to be ignored...
4673 this.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
4676 this.items.forEach( function(e) {
4677 e.layout ? e.layout() : false;
4685 if(this.fireEvent("beforehide", this) !== false){
4687 this.maskEl.removeClass('show');
4689 this.maskEl.dom.style.display = '';
4690 Roo.get(document.body).removeClass("x-body-masked");
4691 this.el.removeClass('in');
4692 this.el.select('.modal-dialog', true).first().setStyle('transform','');
4694 if(this.animate){ // why
4695 this.el.addClass('hideing');
4696 this.el.removeClass('show');
4698 if (!this.el.hasClass('hideing')) {
4699 return; // it's been shown again...
4702 this.el.dom.style.display='';
4704 Roo.get(document.body).removeClass('modal-open');
4705 this.el.removeClass('hideing');
4709 this.el.removeClass('show');
4710 this.el.dom.style.display='';
4711 Roo.get(document.body).removeClass('modal-open');
4714 this.fireEvent('hide', this);
4717 isVisible : function()
4720 return this.el.hasClass('show') && !this.el.hasClass('hideing');
4724 addButton : function(str, cb)
4728 var b = Roo.apply({}, { html : str } );
4729 b.xns = b.xns || Roo.bootstrap;
4730 b.xtype = b.xtype || 'Button';
4731 if (typeof(b.listeners) == 'undefined') {
4732 b.listeners = { click : cb.createDelegate(this) };
4735 var btn = Roo.factory(b);
4737 btn.render(this.getButtonContainer());
4743 setDefaultButton : function(btn)
4745 //this.el.select('.modal-footer').()
4748 resizeTo: function(w,h)
4750 this.dialogEl.setWidth(w);
4752 var diff = this.headerEl.getHeight() + this.footerEl.getHeight() + 60; // dialog margin-bottom: 30
4754 this.bodyEl.setHeight(h - diff);
4756 this.fireEvent('resize', this);
4759 setContentSize : function(w, h)
4763 onButtonClick: function(btn,e)
4766 this.fireEvent('btnclick', btn.name, e);
4769 * Set the title of the Dialog
4770 * @param {String} str new Title
4772 setTitle: function(str) {
4773 this.titleEl.dom.innerHTML = str;
4777 * Set the body of the Dialog
4778 * @param {String} str new Title
4780 setBody: function(str) {
4781 this.bodyEl.dom.innerHTML = str;
4784 * Set the body of the Dialog using the template
4785 * @param {Obj} data - apply this data to the template and replace the body contents.
4787 applyBody: function(obj)
4790 Roo.log("Error - using apply Body without a template");
4793 this.tmpl.overwrite(this.bodyEl, obj);
4796 getChildHeight : function(child_nodes)
4800 child_nodes.length == 0
4805 var child_height = 0;
4807 for(var i = 0; i < child_nodes.length; i++) {
4810 * for modal with tabs...
4811 if(child_nodes[i].classList.contains('roo-layout-panel')) {
4813 var layout_childs = child_nodes[i].childNodes;
4815 for(var j = 0; j < layout_childs.length; j++) {
4817 if(layout_childs[j].classList.contains('roo-layout-panel-body')) {
4819 var layout_body_childs = layout_childs[j].childNodes;
4821 for(var k = 0; k < layout_body_childs.length; k++) {
4823 if(layout_body_childs[k].classList.contains('navbar')) {
4824 child_height += layout_body_childs[k].offsetHeight;
4828 if(layout_body_childs[k].classList.contains('roo-layout-tabs-body')) {
4830 var layout_body_tab_childs = layout_body_childs[k].childNodes;
4832 for(var m = 0; m < layout_body_tab_childs.length; m++) {
4834 if(layout_body_tab_childs[m].classList.contains('roo-layout-active-content')) {
4835 child_height += this.getChildHeight(layout_body_tab_childs[m].childNodes);
4850 child_height += child_nodes[i].offsetHeight;
4851 // Roo.log(child_nodes[i].offsetHeight);
4854 return child_height;
4856 toggleHeaderInput : function(is_edit)
4858 if (!this.editableTitle) {
4859 return; // not editable.
4861 if (is_edit && this.is_header_editing) {
4862 return; // already editing..
4866 this.headerEditEl.dom.value = this.title;
4867 this.headerEditEl.removeClass('d-none');
4868 this.headerEditEl.dom.focus();
4869 this.titleEl.addClass('d-none');
4871 this.is_header_editing = true;
4874 // flip back to not editing.
4875 this.title = this.headerEditEl.dom.value;
4876 this.headerEditEl.addClass('d-none');
4877 this.titleEl.removeClass('d-none');
4878 this.titleEl.dom.innerHTML = String.format('{0}', this.title);
4879 this.is_header_editing = false;
4880 this.fireEvent('titlechanged', this, this.title);
4889 Roo.apply(Roo.bootstrap.Modal, {
4891 * Button config that displays a single OK button
4900 * Button config that displays Yes and No buttons
4916 * Button config that displays OK and Cancel buttons
4931 * Button config that displays Yes, No and Cancel buttons
4956 * messagebox - can be used as a replace
4960 * @class Roo.MessageBox
4961 * Utility class for generating different styles of message boxes. The alias Roo.Msg can also be used.
4965 Roo.Msg.alert('Status', 'Changes saved successfully.');
4967 // Prompt for user data:
4968 Roo.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
4970 // process text value...
4974 // Show a dialog using config options:
4976 title:'Save Changes?',
4977 msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',
4978 buttons: Roo.Msg.YESNOCANCEL,
4985 Roo.bootstrap.MessageBox = function(){
4986 var dlg, opt, mask, waitTimer;
4987 var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp;
4988 var buttons, activeTextEl, bwidth;
4992 var handleButton = function(button){
4994 Roo.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
4998 var handleHide = function(){
5000 dlg.el.removeClass(opt.cls);
5003 // Roo.TaskMgr.stop(waitTimer);
5004 // waitTimer = null;
5009 var updateButtons = function(b){
5012 buttons["ok"].hide();
5013 buttons["cancel"].hide();
5014 buttons["yes"].hide();
5015 buttons["no"].hide();
5016 dlg.footerEl.hide();
5020 dlg.footerEl.show();
5021 for(var k in buttons){
5022 if(typeof buttons[k] != "function"){
5025 buttons[k].setText(typeof b[k] == "string" ? b[k] : Roo.bootstrap.MessageBox.buttonText[k]);
5026 width += buttons[k].el.getWidth()+15;
5036 var handleEsc = function(d, k, e){
5037 if(opt && opt.closable !== false){
5047 * Returns a reference to the underlying {@link Roo.BasicDialog} element
5048 * @return {Roo.BasicDialog} The BasicDialog element
5050 getDialog : function(){
5052 dlg = new Roo.bootstrap.Modal( {
5055 //constraintoviewport:false,
5057 //collapsible : false,
5062 //buttonAlign:"center",
5063 closeClick : function(){
5064 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
5067 handleButton("cancel");
5072 dlg.on("hide", handleHide);
5074 //dlg.addKeyListener(27, handleEsc);
5076 this.buttons = buttons;
5077 var bt = this.buttonText;
5078 buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
5079 buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
5080 buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
5081 buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
5083 bodyEl = dlg.bodyEl.createChild({
5085 html:'<span class="roo-mb-text"></span><br /><input type="text" class="roo-mb-input" />' +
5086 '<textarea class="roo-mb-textarea"></textarea>' +
5087 '<div class="roo-mb-progress-wrap"><div class="roo-mb-progress"><div class="roo-mb-progress-bar"> </div></div></div>'
5089 msgEl = bodyEl.dom.firstChild;
5090 textboxEl = Roo.get(bodyEl.dom.childNodes[2]);
5091 textboxEl.enableDisplayMode();
5092 textboxEl.addKeyListener([10,13], function(){
5093 if(dlg.isVisible() && opt && opt.buttons){
5096 }else if(opt.buttons.yes){
5097 handleButton("yes");
5101 textareaEl = Roo.get(bodyEl.dom.childNodes[3]);
5102 textareaEl.enableDisplayMode();
5103 progressEl = Roo.get(bodyEl.dom.childNodes[4]);
5104 progressEl.enableDisplayMode();
5106 // This is supposed to be the progessElement.. but I think it's controlling the height of everything..
5107 var pf = progressEl.dom.firstChild;
5109 pp = Roo.get(pf.firstChild);
5110 pp.setHeight(pf.offsetHeight);
5118 * Updates the message box body text
5119 * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
5120 * the XHTML-compliant non-breaking space character '&#160;')
5121 * @return {Roo.MessageBox} This message box
5123 updateText : function(text)
5125 if(!dlg.isVisible() && !opt.width){
5126 dlg.dialogEl.setStyle({ 'max-width' : this.maxWidth});
5127 // dlg.resizeTo(this.maxWidth, 100); // forcing the height breaks long alerts()
5129 msgEl.innerHTML = text || ' ';
5131 var cw = Math.max(msgEl.offsetWidth, msgEl.parentNode.scrollWidth);
5132 //Roo.log("guesed size: " + JSON.stringify([cw,msgEl.offsetWidth, msgEl.parentNode.scrollWidth]));
5134 Math.min(opt.width || cw , this.maxWidth),
5135 Math.max(opt.minWidth || this.minWidth, bwidth)
5138 activeTextEl.setWidth(w);
5140 if(dlg.isVisible()){
5141 dlg.fixedcenter = false;
5143 // to big, make it scroll. = But as usual stupid IE does not support
5146 if ( bodyEl.getHeight() > (Roo.lib.Dom.getViewHeight() - 100)) {
5147 bodyEl.setHeight ( Roo.lib.Dom.getViewHeight() - 100 );
5148 bodyEl.dom.style.overflowY = 'auto' + ( Roo.isIE ? '' : ' !important');
5150 bodyEl.dom.style.height = '';
5151 bodyEl.dom.style.overflowY = '';
5154 bodyEl.dom.style.get = 'auto' + ( Roo.isIE ? '' : ' !important');
5156 bodyEl.dom.style.overflowX = '';
5159 dlg.setContentSize(w, bodyEl.getHeight());
5160 if(dlg.isVisible()){
5161 dlg.fixedcenter = true;
5167 * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
5168 * initiated via {@link Roo.MessageBox#progress} or by calling {@link Roo.MessageBox#show} with progress: true.
5169 * @param {Number} value Any number between 0 and 1 (e.g., .5)
5170 * @param {String} text (optional) If defined, the message box's body text is replaced with the specified string (defaults to undefined)
5171 * @return {Roo.MessageBox} This message box
5173 updateProgress : function(value, text){
5175 this.updateText(text);
5178 if (pp) { // weird bug on my firefox - for some reason this is not defined
5179 pp.setWidth(Math.floor(value*progressEl.dom.firstChild.offsetWidth));
5180 pp.setHeight(Math.floor(progressEl.dom.firstChild.offsetHeight));
5186 * Returns true if the message box is currently displayed
5187 * @return {Boolean} True if the message box is visible, else false
5189 isVisible : function(){
5190 return dlg && dlg.isVisible();
5194 * Hides the message box if it is displayed
5197 if(this.isVisible()){
5203 * Displays a new message box, or reinitializes an existing message box, based on the config options
5204 * passed in. All functions (e.g. prompt, alert, etc) on MessageBox call this function internally.
5205 * The following config object properties are supported:
5207 Property Type Description
5208 ---------- --------------- ------------------------------------------------------------------------------------
5209 animEl String/Element An id or Element from which the message box should animate as it opens and
5210 closes (defaults to undefined)
5211 buttons Object/Boolean A button config object (e.g., Roo.MessageBox.OKCANCEL or {ok:'Foo',
5212 cancel:'Bar'}), or false to not show any buttons (defaults to false)
5213 closable Boolean False to hide the top-right close button (defaults to true). Note that
5214 progress and wait dialogs will ignore this property and always hide the
5215 close button as they can only be closed programmatically.
5216 cls String A custom CSS class to apply to the message box element
5217 defaultTextHeight Number The default height in pixels of the message box's multiline textarea if
5218 displayed (defaults to 75)
5219 fn Function A callback function to execute after closing the dialog. The arguments to the
5220 function will be btn (the name of the button that was clicked, if applicable,
5221 e.g. "ok"), and text (the value of the active text field, if applicable).
5222 Progress and wait dialogs will ignore this option since they do not respond to
5223 user actions and can only be closed programmatically, so any required function
5224 should be called by the same code after it closes the dialog.
5225 icon String A CSS class that provides a background image to be used as an icon for
5226 the dialog (e.g., Roo.MessageBox.WARNING or 'custom-class', defaults to '')
5227 maxWidth Number The maximum width in pixels of the message box (defaults to 600)
5228 minWidth Number The minimum width in pixels of the message box (defaults to 100)
5229 modal Boolean False to allow user interaction with the page while the message box is
5230 displayed (defaults to true)
5231 msg String A string that will replace the existing message box body text (defaults
5232 to the XHTML-compliant non-breaking space character ' ')
5233 multiline Boolean True to prompt the user to enter multi-line text (defaults to false)
5234 progress Boolean True to display a progress bar (defaults to false)
5235 progressText String The text to display inside the progress bar if progress = true (defaults to '')
5236 prompt Boolean True to prompt the user to enter single-line text (defaults to false)
5237 proxyDrag Boolean True to display a lightweight proxy while dragging (defaults to false)
5238 title String The title text
5239 value String The string value to set into the active textbox element if displayed
5240 wait Boolean True to display a progress bar (defaults to false)
5241 width Number The width of the dialog in pixels
5248 msg: 'Please enter your address:',
5250 buttons: Roo.MessageBox.OKCANCEL,
5253 animEl: 'addAddressBtn'
5256 * @param {Object} config Configuration options
5257 * @return {Roo.MessageBox} This message box
5259 show : function(options)
5262 // this causes nightmares if you show one dialog after another
5263 // especially on callbacks..
5265 if(this.isVisible()){
5268 Roo.log("[Roo.Messagebox] Show called while message displayed:" );
5269 Roo.log("Old Dialog Message:" + msgEl.innerHTML );
5270 Roo.log("New Dialog Message:" + options.msg )
5271 //this.alert("ERROR", "Multiple dialogs where displayed at the same time");
5272 //throw "Roo.MessageBox ERROR : Multiple dialogs where displayed at the same time";
5275 var d = this.getDialog();
5277 d.setTitle(opt.title || " ");
5278 d.closeEl.setDisplayed(opt.closable !== false);
5279 activeTextEl = textboxEl;
5280 opt.prompt = opt.prompt || (opt.multiline ? true : false);
5285 textareaEl.setHeight(typeof opt.multiline == "number" ?
5286 opt.multiline : this.defaultTextHeight);
5287 activeTextEl = textareaEl;
5296 progressEl.setDisplayed(opt.progress === true);
5298 d.animate = false; // do not animate progress, as it may not have finished animating before we close it..
5300 this.updateProgress(0);
5301 activeTextEl.dom.value = opt.value || "";
5303 dlg.setDefaultButton(activeTextEl);
5305 var bs = opt.buttons;
5309 }else if(bs && bs.yes){
5310 db = buttons["yes"];
5312 dlg.setDefaultButton(db);
5314 bwidth = updateButtons(opt.buttons);
5315 this.updateText(opt.msg);
5317 d.el.addClass(opt.cls);
5319 d.proxyDrag = opt.proxyDrag === true;
5320 d.modal = opt.modal !== false;
5321 d.mask = opt.modal !== false ? mask : false;
5323 // force it to the end of the z-index stack so it gets a cursor in FF
5324 document.body.appendChild(dlg.el.dom);
5325 d.animateTarget = null;
5326 d.show(options.animEl);
5332 * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
5333 * the user. You are responsible for updating the progress bar as needed via {@link Roo.MessageBox#updateProgress}
5334 * and closing the message box when the process is complete.
5335 * @param {String} title The title bar text
5336 * @param {String} msg The message box body text
5337 * @return {Roo.MessageBox} This message box
5339 progress : function(title, msg){
5346 minWidth: this.minProgressWidth,
5353 * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
5354 * If a callback function is passed it will be called after the user clicks the button, and the
5355 * id of the button that was clicked will be passed as the only parameter to the callback
5356 * (could also be the top-right close button).
5357 * @param {String} title The title bar text
5358 * @param {String} msg The message box body text
5359 * @param {Function} fn (optional) The callback function invoked after the message box is closed
5360 * @param {Object} scope (optional) The scope of the callback function
5361 * @return {Roo.MessageBox} This message box
5363 alert : function(title, msg, fn, scope)
5378 * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
5379 * interaction while waiting for a long-running process to complete that does not have defined intervals.
5380 * You are responsible for closing the message box when the process is complete.
5381 * @param {String} msg The message box body text
5382 * @param {String} title (optional) The title bar text
5383 * @return {Roo.MessageBox} This message box
5385 wait : function(msg, title){
5396 waitTimer = Roo.TaskMgr.start({
5398 Roo.MessageBox.updateProgress(((((i+20)%20)+1)*5)*.01);
5406 * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
5407 * If a callback function is passed it will be called after the user clicks either button, and the id of the
5408 * button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
5409 * @param {String} title The title bar text
5410 * @param {String} msg The message box body text
5411 * @param {Function} fn (optional) The callback function invoked after the message box is closed
5412 * @param {Object} scope (optional) The scope of the callback function
5413 * @return {Roo.MessageBox} This message box
5415 confirm : function(title, msg, fn, scope){
5419 buttons: this.YESNO,
5428 * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to
5429 * JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function
5430 * is passed it will be called after the user clicks either button, and the id of the button that was clicked
5431 * (could also be the top-right close button) and the text that was entered will be passed as the two
5432 * parameters to the callback.
5433 * @param {String} title The title bar text
5434 * @param {String} msg The message box body text
5435 * @param {Function} fn (optional) The callback function invoked after the message box is closed
5436 * @param {Object} scope (optional) The scope of the callback function
5437 * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
5438 * property, or the height in pixels to create the textbox (defaults to false / single-line)
5439 * @return {Roo.MessageBox} This message box
5441 prompt : function(title, msg, fn, scope, multiline){
5445 buttons: this.OKCANCEL,
5450 multiline: multiline,
5457 * Button config that displays a single OK button
5462 * Button config that displays Yes and No buttons
5465 YESNO : {yes:true, no:true},
5467 * Button config that displays OK and Cancel buttons
5470 OKCANCEL : {ok:true, cancel:true},
5472 * Button config that displays Yes, No and Cancel buttons
5475 YESNOCANCEL : {yes:true, no:true, cancel:true},
5478 * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
5481 defaultTextHeight : 75,
5483 * The maximum width in pixels of the message box (defaults to 600)
5488 * The minimum width in pixels of the message box (defaults to 100)
5493 * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
5494 * for setting a different minimum width than text-only dialogs may need (defaults to 250)
5497 minProgressWidth : 250,
5499 * An object containing the default button text strings that can be overriden for localized language support.
5500 * Supported properties are: ok, cancel, yes and no.
5501 * Customize the default text like so: Roo.MessageBox.buttonText.yes = "S?";
5514 * Shorthand for {@link Roo.MessageBox}
5516 Roo.MessageBox = Roo.MessageBox || Roo.bootstrap.MessageBox;
5517 Roo.Msg = Roo.Msg || Roo.MessageBox;
5526 * @class Roo.bootstrap.Navbar
5527 * @extends Roo.bootstrap.Component
5528 * Bootstrap Navbar class
5531 * Create a new Navbar
5532 * @param {Object} config The config object
5536 Roo.bootstrap.Navbar = function(config){
5537 Roo.bootstrap.Navbar.superclass.constructor.call(this, config);
5541 * @event beforetoggle
5542 * Fire before toggle the menu
5543 * @param {Roo.EventObject} e
5545 "beforetoggle" : true
5549 Roo.extend(Roo.bootstrap.Navbar, Roo.bootstrap.Component, {
5558 getAutoCreate : function(){
5561 throw { message : "nav bar is now a abstract base class - use NavSimplebar / NavHeaderbar / NavSidebar etc..."};
5565 initEvents :function ()
5567 //Roo.log(this.el.select('.navbar-toggle',true));
5568 this.el.select('.navbar-toggle',true).on('click', this.onToggle , this);
5575 this.maskEl = Roo.DomHelper.append(this.el, mark, true);
5577 var size = this.el.getSize();
5578 this.maskEl.setSize(size.width, size.height);
5579 this.maskEl.enableDisplayMode("block");
5588 getChildContainer : function()
5590 if (this.el && this.el.select('.collapse').getCount()) {
5591 return this.el.select('.collapse',true).first();
5606 onToggle : function()
5609 if(this.fireEvent('beforetoggle', this) === false){
5612 var ce = this.el.select('.navbar-collapse',true).first();
5614 if (!ce.hasClass('show')) {
5624 * Expand the navbar pulldown
5626 expand : function ()
5629 var ce = this.el.select('.navbar-collapse',true).first();
5630 if (ce.hasClass('collapsing')) {
5633 ce.dom.style.height = '';
5635 ce.addClass('in'); // old...
5636 ce.removeClass('collapse');
5637 ce.addClass('show');
5638 var h = ce.getHeight();
5640 ce.removeClass('show');
5641 // at this point we should be able to see it..
5642 ce.addClass('collapsing');
5644 ce.setHeight(0); // resize it ...
5645 ce.on('transitionend', function() {
5646 //Roo.log('done transition');
5647 ce.removeClass('collapsing');
5648 ce.addClass('show');
5649 ce.removeClass('collapse');
5651 ce.dom.style.height = '';
5652 }, this, { single: true} );
5654 ce.dom.scrollTop = 0;
5657 * Collapse the navbar pulldown
5659 collapse : function()
5661 var ce = this.el.select('.navbar-collapse',true).first();
5663 if (ce.hasClass('collapsing') || ce.hasClass('collapse') ) {
5664 // it's collapsed or collapsing..
5667 ce.removeClass('in'); // old...
5668 ce.setHeight(ce.getHeight());
5669 ce.removeClass('show');
5670 ce.addClass('collapsing');
5672 ce.on('transitionend', function() {
5673 ce.dom.style.height = '';
5674 ce.removeClass('collapsing');
5675 ce.addClass('collapse');
5676 }, this, { single: true} );
5696 * @class Roo.bootstrap.NavSimplebar
5697 * @extends Roo.bootstrap.Navbar
5698 * Bootstrap Sidebar class
5700 * @cfg {Boolean} inverse is inverted color
5702 * @cfg {String} type (nav | pills | tabs)
5703 * @cfg {Boolean} arrangement stacked | justified
5704 * @cfg {String} align (left | right) alignment
5706 * @cfg {Boolean} main (true|false) main nav bar? default false
5707 * @cfg {Boolean} loadMask (true|false) loadMask on the bar
5709 * @cfg {String} tag (header|footer|nav|div) default is nav
5711 * @cfg {String} weight (light|primary|secondary|success|danger|warning|info|dark|white) default is light.
5715 * Create a new Sidebar
5716 * @param {Object} config The config object
5720 Roo.bootstrap.NavSimplebar = function(config){
5721 Roo.bootstrap.NavSimplebar.superclass.constructor.call(this, config);
5724 Roo.extend(Roo.bootstrap.NavSimplebar, Roo.bootstrap.Navbar, {
5740 getAutoCreate : function(){
5744 tag : this.tag || 'div',
5745 cls : 'navbar roo-navbar-simple' //navbar-expand-lg ??
5747 if (['light','white'].indexOf(this.weight) > -1) {
5748 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
5750 cfg.cls += ' bg-' + this.weight;
5753 cfg.cls += ' navbar-inverse';
5757 // i'm not actually sure these are really used - normally we add a navGroup to a navbar
5759 if (Roo.bootstrap.version == 4 && this.xtype == 'NavSimplebar') {
5768 cls: 'nav nav-' + this.xtype,
5774 this.type = this.type || 'nav';
5775 if (['tabs','pills'].indexOf(this.type) != -1) {
5776 cfg.cn[0].cls += ' nav-' + this.type
5780 if (this.type!=='nav') {
5781 Roo.log('nav type must be nav/tabs/pills')
5783 cfg.cn[0].cls += ' navbar-nav'
5789 if (['stacked','justified'].indexOf(this.arrangement) != -1) {
5790 cfg.cn[0].cls += ' nav-' + this.arrangement;
5794 if (this.align === 'right') {
5795 cfg.cn[0].cls += ' navbar-right';
5820 * navbar-expand-md fixed-top
5824 * @class Roo.bootstrap.NavHeaderbar
5825 * @extends Roo.bootstrap.NavSimplebar
5826 * Bootstrap Sidebar class
5828 * @cfg {String} brand what is brand
5829 * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
5830 * @cfg {String} brand_href href of the brand
5831 * @cfg {Boolean} srButton generate the (screen reader / mobile) sr-only button default true
5832 * @cfg {Boolean} autohide a top nav bar header that hides on scroll.
5833 * @cfg {Boolean} desktopCenter should the header be centered on desktop using a container class
5834 * @cfg {Roo.bootstrap.Row} mobilerow - a row to display on mobile only..
5837 * Create a new Sidebar
5838 * @param {Object} config The config object
5842 Roo.bootstrap.NavHeaderbar = function(config){
5843 Roo.bootstrap.NavHeaderbar.superclass.constructor.call(this, config);
5847 Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar, {
5854 desktopCenter : false,
5857 getAutoCreate : function(){
5860 tag: this.nav || 'nav',
5861 cls: 'navbar navbar-expand-md',
5867 if (this.desktopCenter) {
5868 cn.push({cls : 'container', cn : []});
5876 cls: 'navbar-toggle navbar-toggler',
5877 'data-toggle': 'collapse',
5882 html: 'Toggle navigation'
5886 cls: 'icon-bar navbar-toggler-icon'
5899 cn.push( Roo.bootstrap.version == 4 ? btn : {
5901 cls: 'navbar-header',
5910 cls: Roo.bootstrap.version == 4 ? 'nav flex-row roo-navbar-collapse collapse navbar-collapse' : 'collapse navbar-collapse roo-navbar-collapse',
5914 cfg.cls += this.inverse ? ' navbar-inverse navbar-dark bg-dark' : ' navbar-default';
5916 if (['light','white'].indexOf(this.weight) > -1) {
5917 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
5919 cfg.cls += ' bg-' + this.weight;
5922 if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
5923 cfg.cls += ' navbar-' + this.position + ' ' + this.position ;
5925 // tag can override this..
5927 cfg.tag = this.tag || (this.position == 'fixed-bottom' ? 'footer' : 'header');
5930 if (this.brand !== '') {
5931 var cp = Roo.bootstrap.version == 4 ? cn : cn[0].cn;
5932 cp.unshift({ // changed from push ?? BS4 needs it at the start? - does this break or exsiting?
5934 href: this.brand_href ? this.brand_href : '#',
5935 cls: 'navbar-brand',
5943 cfg.cls += ' main-nav';
5951 getHeaderChildContainer : function()
5953 if (this.srButton && this.el.select('.navbar-header').getCount()) {
5954 return this.el.select('.navbar-header',true).first();
5957 return this.getChildContainer();
5960 getChildContainer : function()
5963 return this.el.select('.roo-navbar-collapse',true).first();
5968 initEvents : function()
5970 Roo.bootstrap.NavHeaderbar.superclass.initEvents.call(this);
5972 if (this.autohide) {
5977 Roo.get(document).on('scroll',function(e) {
5978 var ns = Roo.get(document).getScroll().top;
5979 var os = prevScroll;
5983 ft.removeClass('slideDown');
5984 ft.addClass('slideUp');
5987 ft.removeClass('slideUp');
5988 ft.addClass('slideDown');
6009 * @class Roo.bootstrap.NavSidebar
6010 * @extends Roo.bootstrap.Navbar
6011 * Bootstrap Sidebar class
6014 * Create a new Sidebar
6015 * @param {Object} config The config object
6019 Roo.bootstrap.NavSidebar = function(config){
6020 Roo.bootstrap.NavSidebar.superclass.constructor.call(this, config);
6023 Roo.extend(Roo.bootstrap.NavSidebar, Roo.bootstrap.Navbar, {
6025 sidebar : true, // used by Navbar Item and NavbarGroup at present...
6027 getAutoCreate : function(){
6032 cls: 'sidebar sidebar-nav'
6054 * @class Roo.bootstrap.NavGroup
6055 * @extends Roo.bootstrap.Component
6056 * Bootstrap NavGroup class
6057 * @cfg {String} align (left|right)
6058 * @cfg {Boolean} inverse
6059 * @cfg {String} type (nav|pills|tab) default nav
6060 * @cfg {String} navId - reference Id for navbar.
6061 * @cfg {Boolean} pilltype default true (turn to off to disable active toggle)
6064 * Create a new nav group
6065 * @param {Object} config The config object
6068 Roo.bootstrap.NavGroup = function(config){
6069 Roo.bootstrap.NavGroup.superclass.constructor.call(this, config);
6072 Roo.bootstrap.NavGroup.register(this);
6076 * Fires when the active item changes
6077 * @param {Roo.bootstrap.NavGroup} this
6078 * @param {Roo.bootstrap.Navbar.Item} selected The item selected
6079 * @param {Roo.bootstrap.Navbar.Item} prev The previously selected item
6086 Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, {
6098 getAutoCreate : function()
6100 var cfg = Roo.apply({}, Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));
6106 if (Roo.bootstrap.version == 4) {
6107 if (['tabs','pills'].indexOf(this.type) != -1) {
6108 cfg.cls += ' nav-' + this.type;
6110 // trying to remove so header bar can right align top?
6111 if (this.parent() && this.parent().xtype != 'NavHeaderbar') {
6112 // do not use on header bar...
6113 cfg.cls += ' navbar-nav';
6118 if (['tabs','pills'].indexOf(this.type) != -1) {
6119 cfg.cls += ' nav-' + this.type
6121 if (this.type !== 'nav') {
6122 Roo.log('nav type must be nav/tabs/pills')
6124 cfg.cls += ' navbar-nav'
6128 if (this.parent() && this.parent().sidebar) {
6131 cls: 'dashboard-menu sidebar-menu'
6137 if (this.form === true) {
6140 cls: 'navbar-form form-inline'
6142 //nav navbar-right ml-md-auto
6143 if (this.align === 'right') {
6144 cfg.cls += ' navbar-right ml-md-auto';
6146 cfg.cls += ' navbar-left';
6150 if (this.align === 'right') {
6151 cfg.cls += ' navbar-right ml-md-auto';
6153 cfg.cls += ' mr-auto';
6157 cfg.cls += ' navbar-inverse';
6165 * sets the active Navigation item
6166 * @param {Roo.bootstrap.NavItem} the new current navitem
6168 setActiveItem : function(item)
6171 Roo.each(this.navItems, function(v){
6176 v.setActive(false, true);
6183 item.setActive(true, true);
6184 this.fireEvent('changed', this, item, prev);
6189 * gets the active Navigation item
6190 * @return {Roo.bootstrap.NavItem} the current navitem
6192 getActive : function()
6196 Roo.each(this.navItems, function(v){
6207 indexOfNav : function()
6211 Roo.each(this.navItems, function(v,i){
6222 * adds a Navigation item
6223 * @param {Roo.bootstrap.NavItem} the navitem to add
6225 addItem : function(cfg)
6227 if (this.form && Roo.bootstrap.version == 4) {
6230 var cn = new Roo.bootstrap.NavItem(cfg);
6232 cn.parentId = this.id;
6233 cn.onRender(this.el, null);
6237 * register a Navigation item
6238 * @param {Roo.bootstrap.NavItem} the navitem to add
6240 register : function(item)
6242 this.navItems.push( item);
6243 item.navId = this.navId;
6248 * clear all the Navigation item
6251 clearAll : function()
6254 this.el.dom.innerHTML = '';
6257 getNavItem: function(tabId)
6260 Roo.each(this.navItems, function(e) {
6261 if (e.tabId == tabId) {
6271 setActiveNext : function()
6273 var i = this.indexOfNav(this.getActive());
6274 if (i > this.navItems.length) {
6277 this.setActiveItem(this.navItems[i+1]);
6279 setActivePrev : function()
6281 var i = this.indexOfNav(this.getActive());
6285 this.setActiveItem(this.navItems[i-1]);
6287 clearWasActive : function(except) {
6288 Roo.each(this.navItems, function(e) {
6289 if (e.tabId != except.tabId && e.was_active) {
6290 e.was_active = false;
6297 getWasActive : function ()
6300 Roo.each(this.navItems, function(e) {
6315 Roo.apply(Roo.bootstrap.NavGroup, {
6319 * register a Navigation Group
6320 * @param {Roo.bootstrap.NavGroup} the navgroup to add
6322 register : function(navgrp)
6324 this.groups[navgrp.navId] = navgrp;
6328 * fetch a Navigation Group based on the navigation ID
6329 * @param {string} the navgroup to add
6330 * @returns {Roo.bootstrap.NavGroup} the navgroup
6332 get: function(navId) {
6333 if (typeof(this.groups[navId]) == 'undefined') {
6335 //this.register(new Roo.bootstrap.NavGroup({ navId : navId }));
6337 return this.groups[navId] ;
6352 * @class Roo.bootstrap.NavItem
6353 * @extends Roo.bootstrap.Component
6354 * Bootstrap Navbar.NavItem class
6355 * @cfg {String} href link to
6356 * @cfg {String} button_weight (default|primary|secondary|success|info|warning|danger|link|light|dark) default none
6357 * @cfg {Boolean} button_outline show and outlined button
6358 * @cfg {String} html content of button
6359 * @cfg {String} badge text inside badge
6360 * @cfg {String} badgecls (bg-green|bg-red|bg-yellow)the extra classes for the badge
6361 * @cfg {String} glyphicon DEPRICATED - use fa
6362 * @cfg {String} icon DEPRICATED - use fa
6363 * @cfg {String} fa - Fontawsome icon name (can add stuff to it like fa-2x)
6364 * @cfg {Boolean} active Is item active
6365 * @cfg {Boolean} disabled Is item disabled
6366 * @cfg {String} linkcls Link Class
6367 * @cfg {Boolean} preventDefault (true | false) default false
6368 * @cfg {String} tabId the tab that this item activates.
6369 * @cfg {String} tagtype (a|span) render as a href or span?
6370 * @cfg {Boolean} animateRef (true|false) link to element default false
6373 * Create a new Navbar Item
6374 * @param {Object} config The config object
6376 Roo.bootstrap.NavItem = function(config){
6377 Roo.bootstrap.NavItem.superclass.constructor.call(this, config);
6382 * The raw click event for the entire grid.
6383 * @param {Roo.EventObject} e
6388 * Fires when the active item active state changes
6389 * @param {Roo.bootstrap.NavItem} this
6390 * @param {boolean} state the new state
6396 * Fires when scroll to element
6397 * @param {Roo.bootstrap.NavItem} this
6398 * @param {Object} options
6399 * @param {Roo.EventObject} e
6407 Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, {
6416 preventDefault : false,
6424 button_outline : false,
6428 getAutoCreate : function(){
6435 cfg.cls = typeof(cfg.cls) == 'undefined' ? '' : cfg.cls;
6438 cfg.cls += ' active' ;
6440 if (this.disabled) {
6441 cfg.cls += ' disabled';
6445 if (this.button_weight.length) {
6446 cfg.tag = this.href ? 'a' : 'button';
6447 cfg.html = this.html || '';
6448 cfg.cls += ' btn btn' + (this.button_outline ? '-outline' : '') + '-' + this.button_weight;
6450 cfg.href = this.href;
6453 cfg.html = '<i class="fa fas fa-'+this.fa+'"></i> <span class="nav-html">' + this.html + '</span>';
6455 cfg.cls += " nav-html";
6458 // menu .. should add dropdown-menu class - so no need for carat..
6460 if (this.badge !== '') {
6462 cfg.html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
6467 if (this.href || this.html || this.glyphicon || this.icon || this.fa) {
6471 href : this.href || "#",
6472 html: this.html || '',
6476 if (this.tagtype == 'a') {
6477 cfg.cn[0].cls = 'nav-link' + (this.active ? ' active' : '') + ' ' + this.linkcls;
6481 cfg.cn[0].html = '<i class="'+this.icon+'"></i> <span class="nav-html">' + cfg.cn[0].html + '</span>';
6482 } else if (this.fa) {
6483 cfg.cn[0].html = '<i class="fa fas fa-'+this.fa+'"></i> <span class="nav-html">' + cfg.cn[0].html + '</span>';
6484 } else if(this.glyphicon) {
6485 cfg.cn[0].html = '<span class="glyphicon glyphicon-' + this.glyphicon + '"></span> ' + cfg.cn[0].html;
6487 cfg.cn[0].cls += " nav-html";
6491 cfg.cn[0].html += " <span class='caret'></span>";
6495 if (this.badge !== '') {
6496 cfg.cn[0].html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
6504 onRender : function(ct, position)
6506 // Roo.log("Call onRender: " + this.xtype);
6507 if (Roo.bootstrap.version == 4 && ct.dom.type != 'ul') {
6511 var ret = Roo.bootstrap.NavItem.superclass.onRender.call(this, ct, position);
6512 this.navLink = this.el.select('.nav-link',true).first();
6513 this.htmlEl = this.el.hasClass('nav-html') ? this.el : this.el.select('.nav-html',true).first();
6518 initEvents: function()
6520 if (typeof (this.menu) != 'undefined') {
6521 this.menu.parentType = this.xtype;
6522 this.menu.triggerEl = this.el;
6523 this.menu = this.addxtype(Roo.apply({}, this.menu));
6526 this.el.on('click', this.onClick, this);
6528 //if(this.tagtype == 'span'){
6529 // this.el.select('span',true).on('click', this.onClick, this);
6532 // at this point parent should be available..
6533 this.parent().register(this);
6536 onClick : function(e)
6538 if (e.getTarget('.dropdown-menu-item')) {
6539 // did you click on a menu itemm.... - then don't trigger onclick..
6544 this.preventDefault ||
6547 Roo.log("NavItem - prevent Default?");
6551 if (this.disabled) {
6555 var tg = Roo.bootstrap.TabGroup.get(this.navId);
6556 if (tg && tg.transition) {
6557 Roo.log("waiting for the transitionend");
6563 //Roo.log("fire event clicked");
6564 if(this.fireEvent('click', this, e) === false){
6568 if(this.tagtype == 'span'){
6572 //Roo.log(this.href);
6573 var ael = this.el.select('a',true).first();
6576 if(ael && this.animateRef && this.href.indexOf('#') > -1){
6577 //Roo.log(["test:",ael.dom.href.split("#")[0], document.location.toString().split("#")[0]]);
6578 if (ael.dom.href.split("#")[0] != document.location.toString().split("#")[0]) {
6579 return; // ignore... - it's a 'hash' to another page.
6581 Roo.log("NavItem - prevent Default?");
6583 this.scrollToElement(e);
6587 var p = this.parent();
6589 if (['tabs','pills'].indexOf(p.type)!==-1 && p.pilltype) {
6590 if (typeof(p.setActiveItem) !== 'undefined') {
6591 p.setActiveItem(this);
6595 // if parent is a navbarheader....- and link is probably a '#' page ref.. then remove the expanded menu.
6596 if (p.parentType == 'NavHeaderbar' && !this.menu) {
6597 // remove the collapsed menu expand...
6598 p.parent().el.select('.roo-navbar-collapse',true).removeClass('in');
6602 isActive: function () {
6605 setActive : function(state, fire, is_was_active)
6607 if (this.active && !state && this.navId) {
6608 this.was_active = true;
6609 var nv = Roo.bootstrap.NavGroup.get(this.navId);
6611 nv.clearWasActive(this);
6615 this.active = state;
6618 this.el.removeClass('active');
6619 this.navLink ? this.navLink.removeClass('active') : false;
6620 } else if (!this.el.hasClass('active')) {
6622 this.el.addClass('active');
6623 if (Roo.bootstrap.version == 4 && this.navLink ) {
6624 this.navLink.addClass('active');
6629 this.fireEvent('changed', this, state);
6632 // show a panel if it's registered and related..
6634 if (!this.navId || !this.tabId || !state || is_was_active) {
6638 var tg = Roo.bootstrap.TabGroup.get(this.navId);
6642 var pan = tg.getPanelByName(this.tabId);
6646 // if we can not flip to new panel - go back to old nav highlight..
6647 if (false == tg.showPanel(pan)) {
6648 var nv = Roo.bootstrap.NavGroup.get(this.navId);
6650 var onav = nv.getWasActive();
6652 onav.setActive(true, false, true);
6661 // this should not be here...
6662 setDisabled : function(state)
6664 this.disabled = state;
6666 this.el.removeClass('disabled');
6667 } else if (!this.el.hasClass('disabled')) {
6668 this.el.addClass('disabled');
6674 * Fetch the element to display the tooltip on.
6675 * @return {Roo.Element} defaults to this.el
6677 tooltipEl : function()
6679 return this.el; //this.tagtype == 'a' ? this.el : this.el.select('' + this.tagtype + '', true).first();
6682 scrollToElement : function(e)
6684 var c = document.body;
6687 * Firefox / IE places the overflow at the html level, unless specifically styled to behave differently.
6689 if(Roo.isFirefox || Roo.isIE || Roo.isIE11){
6690 c = document.documentElement;
6693 var target = Roo.get(c).select('a[name=' + this.href.split('#')[1] +']', true).first();
6699 var o = target.calcOffsetsTo(c);
6706 this.fireEvent('scrollto', this, options, e);
6708 Roo.get(c).scrollTo('top', options.value, true);
6713 * Set the HTML (text content) of the item
6714 * @param {string} html content for the nav item
6716 setHtml : function(html)
6719 this.htmlEl.dom.innerHTML = html;
6731 * <span> icon </span>
6732 * <span> text </span>
6733 * <span>badge </span>
6737 * @class Roo.bootstrap.NavSidebarItem
6738 * @extends Roo.bootstrap.NavItem
6739 * Bootstrap Navbar.NavSidebarItem class
6740 * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
6741 * {Boolean} open is the menu open
6742 * {Boolean} buttonView use button as the tigger el rather that a (default false)
6743 * {String} buttonWeight (default|primary|success|info|warning|danger)the extra classes for the button
6744 * {String} buttonSize (sm|md|lg)the extra classes for the button
6745 * {Boolean} showArrow show arrow next to the text (default true)
6747 * Create a new Navbar Button
6748 * @param {Object} config The config object
6750 Roo.bootstrap.NavSidebarItem = function(config){
6751 Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this, config);
6756 * The raw click event for the entire grid.
6757 * @param {Roo.EventObject} e
6762 * Fires when the active item active state changes
6763 * @param {Roo.bootstrap.NavSidebarItem} this
6764 * @param {boolean} state the new state
6772 Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem, {
6774 badgeWeight : 'default',
6780 buttonWeight : 'default',
6786 getAutoCreate : function(){
6791 href : this.href || '#',
6797 if(this.buttonView){
6800 href : this.href || '#',
6801 cls: 'btn btn-' + this.buttonWeight + ' btn-' + this.buttonSize + 'roo-button-dropdown-toggle',
6814 cfg.cls += ' active';
6817 if (this.disabled) {
6818 cfg.cls += ' disabled';
6821 cfg.cls += ' open x-open';
6824 if (this.glyphicon || this.icon) {
6825 var c = this.glyphicon ? ('glyphicon glyphicon-'+this.glyphicon) : this.icon;
6826 a.cn.push({ tag : 'i', cls : c }) ;
6829 if(!this.buttonView){
6832 html : this.html || ''
6839 if (this.badge !== '') {
6840 a.cn.push({ tag: 'span', cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge });
6846 a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
6849 a.cls += ' dropdown-toggle treeview' ;
6855 initEvents : function()
6857 if (typeof (this.menu) != 'undefined') {
6858 this.menu.parentType = this.xtype;
6859 this.menu.triggerEl = this.el;
6860 this.menu = this.addxtype(Roo.apply({}, this.menu));
6863 this.el.on('click', this.onClick, this);
6865 if(this.badge !== ''){
6866 this.badgeEl = this.el.select('.badge', true).first().setVisibilityMode(Roo.Element.DISPLAY);
6871 onClick : function(e)
6878 if(this.preventDefault){
6882 this.fireEvent('click', this, e);
6885 disable : function()
6887 this.setDisabled(true);
6892 this.setDisabled(false);
6895 setDisabled : function(state)
6897 if(this.disabled == state){
6901 this.disabled = state;
6904 this.el.addClass('disabled');
6908 this.el.removeClass('disabled');
6913 setActive : function(state)
6915 if(this.active == state){
6919 this.active = state;
6922 this.el.addClass('active');
6926 this.el.removeClass('active');
6931 isActive: function ()
6936 setBadge : function(str)
6942 this.badgeEl.dom.innerHTML = str;
6957 Roo.namespace('Roo.bootstrap.breadcrumb');
6961 * @class Roo.bootstrap.breadcrumb.Nav
6962 * @extends Roo.bootstrap.Component
6963 * Bootstrap Breadcrumb Nav Class
6965 * @children Roo.bootstrap.breadcrumb.Item
6968 * Create a new breadcrumb.Nav
6969 * @param {Object} config The config object
6973 Roo.bootstrap.breadcrumb.Nav = function(config){
6974 Roo.bootstrap.breadcrumb.Nav.superclass.constructor.call(this, config);
6979 Roo.extend(Roo.bootstrap.breadcrumb.Nav, Roo.bootstrap.Component, {
6981 getAutoCreate : function()
6998 initEvents: function()
7000 this.olEl = this.el.select('ol',true).first();
7002 getChildContainer : function()
7018 * @class Roo.bootstrap.breadcrumb.Nav
7019 * @extends Roo.bootstrap.Component
7020 * Bootstrap Breadcrumb Nav Class
7022 * @children Roo.bootstrap.breadcrumb.Component
7023 * @cfg {String} html the content of the link.
7024 * @cfg {String} href where it links to if '#' is used the link will be handled by onClick.
7025 * @cfg {Boolean} active is it active
7029 * Create a new breadcrumb.Nav
7030 * @param {Object} config The config object
7033 Roo.bootstrap.breadcrumb.Item = function(config){
7034 Roo.bootstrap.breadcrumb.Item.superclass.constructor.call(this, config);
7039 * The img click event for the img.
7040 * @param {Roo.EventObject} e
7047 Roo.extend(Roo.bootstrap.breadcrumb.Item, Roo.bootstrap.Component, {
7052 getAutoCreate : function()
7057 cls : 'breadcrumb-item' + (this.active ? ' active' : '')
7059 if (this.href !== false) {
7066 cfg.html = this.html;
7072 initEvents: function()
7075 this.el.select('a', true).first().on('click',this.onClick, this)
7079 onClick : function(e)
7082 this.fireEvent('click',this, e);
7095 * @class Roo.bootstrap.Row
7096 * @extends Roo.bootstrap.Component
7097 * Bootstrap Row class (contains columns...)
7101 * @param {Object} config The config object
7104 Roo.bootstrap.Row = function(config){
7105 Roo.bootstrap.Row.superclass.constructor.call(this, config);
7108 Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component, {
7110 getAutoCreate : function(){
7129 * @class Roo.bootstrap.Pagination
7130 * @extends Roo.bootstrap.Component
7131 * Bootstrap Pagination class
7132 * @cfg {String} size xs | sm | md | lg
7133 * @cfg {Boolean} inverse false | true
7136 * Create a new Pagination
7137 * @param {Object} config The config object
7140 Roo.bootstrap.Pagination = function(config){
7141 Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
7144 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component, {
7150 getAutoCreate : function(){
7156 cfg.cls += ' inverse';
7162 cfg.cls += " " + this.cls;
7180 * @class Roo.bootstrap.PaginationItem
7181 * @extends Roo.bootstrap.Component
7182 * Bootstrap PaginationItem class
7183 * @cfg {String} html text
7184 * @cfg {String} href the link
7185 * @cfg {Boolean} preventDefault (true | false) default true
7186 * @cfg {Boolean} active (true | false) default false
7187 * @cfg {Boolean} disabled default false
7191 * Create a new PaginationItem
7192 * @param {Object} config The config object
7196 Roo.bootstrap.PaginationItem = function(config){
7197 Roo.bootstrap.PaginationItem.superclass.constructor.call(this, config);
7202 * The raw click event for the entire grid.
7203 * @param {Roo.EventObject} e
7209 Roo.extend(Roo.bootstrap.PaginationItem, Roo.bootstrap.Component, {
7213 preventDefault: true,
7218 getAutoCreate : function(){
7224 href : this.href ? this.href : '#',
7225 html : this.html ? this.html : ''
7235 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' disabled' : 'disabled';
7239 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' active' : 'active';
7245 initEvents: function() {
7247 this.el.on('click', this.onClick, this);
7250 onClick : function(e)
7252 Roo.log('PaginationItem on click ');
7253 if(this.preventDefault){
7261 this.fireEvent('click', this, e);
7277 * @class Roo.bootstrap.Slider
7278 * @extends Roo.bootstrap.Component
7279 * Bootstrap Slider class
7282 * Create a new Slider
7283 * @param {Object} config The config object
7286 Roo.bootstrap.Slider = function(config){
7287 Roo.bootstrap.Slider.superclass.constructor.call(this, config);
7290 Roo.extend(Roo.bootstrap.Slider, Roo.bootstrap.Component, {
7292 getAutoCreate : function(){
7296 cls: 'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',
7300 cls: 'ui-slider-handle ui-state-default ui-corner-all'
7312 * Ext JS Library 1.1.1
7313 * Copyright(c) 2006-2007, Ext JS, LLC.
7315 * Originally Released Under LGPL - original licence link has changed is not relivant.
7318 * <script type="text/javascript">
7321 * @extends Roo.dd.DDProxy
7322 * @class Roo.grid.SplitDragZone
7323 * Support for Column Header resizing
7325 * @param {Object} config
7328 // This is a support class used internally by the Grid components
7329 Roo.grid.SplitDragZone = function(grid, hd, hd2){
7331 this.view = grid.getView();
7332 this.proxy = this.view.resizeProxy;
7333 Roo.grid.SplitDragZone.superclass.constructor.call(
7336 "gridSplitters" + this.grid.getGridEl().id, // SGROUP
7338 dragElId : Roo.id(this.proxy.dom),
7343 this.setHandleElId(Roo.id(hd));
7344 if (hd2 !== false) {
7345 this.setOuterHandleElId(Roo.id(hd2));
7348 this.scroll = false;
7350 Roo.extend(Roo.grid.SplitDragZone, Roo.dd.DDProxy, {
7351 fly: Roo.Element.fly,
7353 b4StartDrag : function(x, y){
7354 this.view.headersDisabled = true;
7355 var h = this.view.mainWrap ? this.view.mainWrap.getHeight() : (
7356 this.view.headEl.getHeight() + this.view.bodyEl.getHeight()
7358 this.proxy.setHeight(h);
7360 // for old system colWidth really stored the actual width?
7361 // in bootstrap we tried using xs/ms/etc.. to do % sizing?
7362 // which in reality did not work.. - it worked only for fixed sizes
7363 // for resizable we need to use actual sizes.
7364 var w = this.cm.getColumnWidth(this.cellIndex);
7365 if (!this.view.mainWrap) {
7367 w = this.view.getHeaderIndex(this.cellIndex).getWidth();
7372 // this was w-this.grid.minColumnWidth;
7373 // doesnt really make sense? - w = thie curren width or the rendered one?
7374 var minw = Math.max(w-this.grid.minColumnWidth, 0);
7375 this.resetConstraints();
7376 this.setXConstraint(minw, 1000);
7377 this.setYConstraint(0, 0);
7378 this.minX = x - minw;
7379 this.maxX = x + 1000;
7381 if (!this.view.mainWrap) { // this is Bootstrap code..
7382 this.getDragEl().style.display='block';
7385 Roo.dd.DDProxy.prototype.b4StartDrag.call(this, x, y);
7389 handleMouseDown : function(e){
7390 ev = Roo.EventObject.setEvent(e);
7391 var t = this.fly(ev.getTarget());
7392 if(t.hasClass("x-grid-split")){
7393 this.cellIndex = this.view.getCellIndex(t.dom);
7395 this.cm = this.grid.colModel;
7396 if(this.cm.isResizable(this.cellIndex) && !this.cm.isFixed(this.cellIndex)){
7397 Roo.grid.SplitDragZone.superclass.handleMouseDown.apply(this, arguments);
7402 endDrag : function(e){
7403 this.view.headersDisabled = false;
7404 var endX = Math.max(this.minX, Roo.lib.Event.getPageX(e));
7405 var diff = endX - this.startPos;
7407 var w = this.cm.getColumnWidth(this.cellIndex);
7408 if (!this.view.mainWrap) {
7411 this.view.onColumnSplitterMoved(this.cellIndex, w+diff);
7414 autoOffset : function(){
7419 * Ext JS Library 1.1.1
7420 * Copyright(c) 2006-2007, Ext JS, LLC.
7422 * Originally Released Under LGPL - original licence link has changed is not relivant.
7425 * <script type="text/javascript">
7429 * @class Roo.grid.AbstractSelectionModel
7430 * @extends Roo.util.Observable
7432 * Abstract base class for grid SelectionModels. It provides the interface that should be
7433 * implemented by descendant classes. This class should not be directly instantiated.
7436 Roo.grid.AbstractSelectionModel = function(){
7437 this.locked = false;
7438 Roo.grid.AbstractSelectionModel.superclass.constructor.call(this);
7441 Roo.extend(Roo.grid.AbstractSelectionModel, Roo.util.Observable, {
7442 /** @ignore Called by the grid automatically. Do not call directly. */
7443 init : function(grid){
7449 * Locks the selections.
7456 * Unlocks the selections.
7458 unlock : function(){
7459 this.locked = false;
7463 * Returns true if the selections are locked.
7466 isLocked : function(){
7471 * Ext JS Library 1.1.1
7472 * Copyright(c) 2006-2007, Ext JS, LLC.
7474 * Originally Released Under LGPL - original licence link has changed is not relivant.
7477 * <script type="text/javascript">
7480 * @extends Roo.grid.AbstractSelectionModel
7481 * @class Roo.grid.RowSelectionModel
7482 * The default SelectionModel used by {@link Roo.grid.Grid}.
7483 * It supports multiple selections and keyboard selection/navigation.
7485 * @param {Object} config
7487 Roo.grid.RowSelectionModel = function(config){
7488 Roo.apply(this, config);
7489 this.selections = new Roo.util.MixedCollection(false, function(o){
7494 this.lastActive = false;
7498 * @event selectionchange
7499 * Fires when the selection changes
7500 * @param {SelectionModel} this
7502 "selectionchange" : true,
7504 * @event afterselectionchange
7505 * Fires after the selection changes (eg. by key press or clicking)
7506 * @param {SelectionModel} this
7508 "afterselectionchange" : true,
7510 * @event beforerowselect
7511 * Fires when a row is selected being selected, return false to cancel.
7512 * @param {SelectionModel} this
7513 * @param {Number} rowIndex The selected index
7514 * @param {Boolean} keepExisting False if other selections will be cleared
7516 "beforerowselect" : true,
7519 * Fires when a row is selected.
7520 * @param {SelectionModel} this
7521 * @param {Number} rowIndex The selected index
7522 * @param {Roo.data.Record} r The record
7526 * @event rowdeselect
7527 * Fires when a row is deselected.
7528 * @param {SelectionModel} this
7529 * @param {Number} rowIndex The selected index
7531 "rowdeselect" : true
7533 Roo.grid.RowSelectionModel.superclass.constructor.call(this);
7534 this.locked = false;
7537 Roo.extend(Roo.grid.RowSelectionModel, Roo.grid.AbstractSelectionModel, {
7539 * @cfg {Boolean} singleSelect
7540 * True to allow selection of only one row at a time (defaults to false)
7542 singleSelect : false,
7545 initEvents : function(){
7547 if(!this.grid.enableDragDrop && !this.grid.enableDrag){
7548 this.grid.on("mousedown", this.handleMouseDown, this);
7549 }else{ // allow click to work like normal
7550 this.grid.on("rowclick", this.handleDragableRowClick, this);
7552 // bootstrap does not have a view..
7553 var view = this.grid.view ? this.grid.view : this.grid;
7554 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
7557 this.selectPrevious(e.shiftKey);
7558 }else if(this.last !== false && this.lastActive !== false){
7559 var last = this.last;
7560 this.selectRange(this.last, this.lastActive-1);
7561 view.focusRow(this.lastActive);
7566 this.selectFirstRow();
7568 this.fireEvent("afterselectionchange", this);
7570 "down" : function(e){
7572 this.selectNext(e.shiftKey);
7573 }else if(this.last !== false && this.lastActive !== false){
7574 var last = this.last;
7575 this.selectRange(this.last, this.lastActive+1);
7576 view.focusRow(this.lastActive);
7581 this.selectFirstRow();
7583 this.fireEvent("afterselectionchange", this);
7589 view.on("refresh", this.onRefresh, this);
7590 view.on("rowupdated", this.onRowUpdated, this);
7591 view.on("rowremoved", this.onRemove, this);
7595 onRefresh : function(){
7596 var ds = this.grid.ds, i, v = this.grid.view;
7597 var s = this.selections;
7599 if((i = ds.indexOfId(r.id)) != -1){
7601 s.add(ds.getAt(i)); // updating the selection relate data
7609 onRemove : function(v, index, r){
7610 this.selections.remove(r);
7614 onRowUpdated : function(v, index, r){
7615 if(this.isSelected(r)){
7616 v.onRowSelect(index);
7622 * @param {Array} records The records to select
7623 * @param {Boolean} keepExisting (optional) True to keep existing selections
7625 selectRecords : function(records, keepExisting){
7627 this.clearSelections();
7629 var ds = this.grid.ds;
7630 for(var i = 0, len = records.length; i < len; i++){
7631 this.selectRow(ds.indexOf(records[i]), true);
7636 * Gets the number of selected rows.
7639 getCount : function(){
7640 return this.selections.length;
7644 * Selects the first row in the grid.
7646 selectFirstRow : function(){
7651 * Select the last row.
7652 * @param {Boolean} keepExisting (optional) True to keep existing selections
7654 selectLastRow : function(keepExisting){
7655 this.selectRow(this.grid.ds.getCount() - 1, keepExisting);
7659 * Selects the row immediately following the last selected row.
7660 * @param {Boolean} keepExisting (optional) True to keep existing selections
7662 selectNext : function(keepExisting){
7663 if(this.last !== false && (this.last+1) < this.grid.ds.getCount()){
7664 this.selectRow(this.last+1, keepExisting);
7665 var view = this.grid.view ? this.grid.view : this.grid;
7666 view.focusRow(this.last);
7671 * Selects the row that precedes the last selected row.
7672 * @param {Boolean} keepExisting (optional) True to keep existing selections
7674 selectPrevious : function(keepExisting){
7676 this.selectRow(this.last-1, keepExisting);
7677 var view = this.grid.view ? this.grid.view : this.grid;
7678 view.focusRow(this.last);
7683 * Returns the selected records
7684 * @return {Array} Array of selected records
7686 getSelections : function(){
7687 return [].concat(this.selections.items);
7691 * Returns the first selected record.
7694 getSelected : function(){
7695 return this.selections.itemAt(0);
7700 * Clears all selections.
7702 clearSelections : function(fast){
7707 var ds = this.grid.ds;
7708 var s = this.selections;
7710 this.deselectRow(ds.indexOfId(r.id));
7714 this.selections.clear();
7723 selectAll : function(){
7727 this.selections.clear();
7728 for(var i = 0, len = this.grid.ds.getCount(); i < len; i++){
7729 this.selectRow(i, true);
7734 * Returns True if there is a selection.
7737 hasSelection : function(){
7738 return this.selections.length > 0;
7742 * Returns True if the specified row is selected.
7743 * @param {Number/Record} record The record or index of the record to check
7746 isSelected : function(index){
7747 var r = typeof index == "number" ? this.grid.ds.getAt(index) : index;
7748 return (r && this.selections.key(r.id) ? true : false);
7752 * Returns True if the specified record id is selected.
7753 * @param {String} id The id of record to check
7756 isIdSelected : function(id){
7757 return (this.selections.key(id) ? true : false);
7761 handleMouseDown : function(e, t)
7763 var view = this.grid.view ? this.grid.view : this.grid;
7765 if(this.isLocked() || (rowIndex = view.findRowIndex(t)) === false){
7768 if(e.shiftKey && this.last !== false){
7769 var last = this.last;
7770 this.selectRange(last, rowIndex, e.ctrlKey);
7771 this.last = last; // reset the last
7772 view.focusRow(rowIndex);
7774 var isSelected = this.isSelected(rowIndex);
7775 if(e.button !== 0 && isSelected){
7776 view.focusRow(rowIndex);
7777 }else if(e.ctrlKey && isSelected){
7778 this.deselectRow(rowIndex);
7779 }else if(!isSelected){
7780 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
7781 view.focusRow(rowIndex);
7784 this.fireEvent("afterselectionchange", this);
7787 handleDragableRowClick : function(grid, rowIndex, e)
7789 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
7790 this.selectRow(rowIndex, false);
7791 var view = this.grid.view ? this.grid.view : this.grid;
7792 view.focusRow(rowIndex);
7793 this.fireEvent("afterselectionchange", this);
7798 * Selects multiple rows.
7799 * @param {Array} rows Array of the indexes of the row to select
7800 * @param {Boolean} keepExisting (optional) True to keep existing selections
7802 selectRows : function(rows, keepExisting){
7804 this.clearSelections();
7806 for(var i = 0, len = rows.length; i < len; i++){
7807 this.selectRow(rows[i], true);
7812 * Selects a range of rows. All rows in between startRow and endRow are also selected.
7813 * @param {Number} startRow The index of the first row in the range
7814 * @param {Number} endRow The index of the last row in the range
7815 * @param {Boolean} keepExisting (optional) True to retain existing selections
7817 selectRange : function(startRow, endRow, keepExisting){
7822 this.clearSelections();
7824 if(startRow <= endRow){
7825 for(var i = startRow; i <= endRow; i++){
7826 this.selectRow(i, true);
7829 for(var i = startRow; i >= endRow; i--){
7830 this.selectRow(i, true);
7836 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
7837 * @param {Number} startRow The index of the first row in the range
7838 * @param {Number} endRow The index of the last row in the range
7840 deselectRange : function(startRow, endRow, preventViewNotify){
7844 for(var i = startRow; i <= endRow; i++){
7845 this.deselectRow(i, preventViewNotify);
7851 * @param {Number} row The index of the row to select
7852 * @param {Boolean} keepExisting (optional) True to keep existing selections
7854 selectRow : function(index, keepExisting, preventViewNotify){
7855 if(this.locked || (index < 0 || index >= this.grid.ds.getCount())) {
7858 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
7859 if(!keepExisting || this.singleSelect){
7860 this.clearSelections();
7862 var r = this.grid.ds.getAt(index);
7863 this.selections.add(r);
7864 this.last = this.lastActive = index;
7865 if(!preventViewNotify){
7866 var view = this.grid.view ? this.grid.view : this.grid;
7867 view.onRowSelect(index);
7869 this.fireEvent("rowselect", this, index, r);
7870 this.fireEvent("selectionchange", this);
7876 * @param {Number} row The index of the row to deselect
7878 deselectRow : function(index, preventViewNotify){
7882 if(this.last == index){
7885 if(this.lastActive == index){
7886 this.lastActive = false;
7888 var r = this.grid.ds.getAt(index);
7889 this.selections.remove(r);
7890 if(!preventViewNotify){
7891 var view = this.grid.view ? this.grid.view : this.grid;
7892 view.onRowDeselect(index);
7894 this.fireEvent("rowdeselect", this, index);
7895 this.fireEvent("selectionchange", this);
7899 restoreLast : function(){
7901 this.last = this._last;
7906 acceptsNav : function(row, col, cm){
7907 return !cm.isHidden(col) && cm.isCellEditable(col, row);
7911 onEditorKey : function(field, e){
7912 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
7917 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
7919 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
7921 }else if(k == e.ENTER && !e.ctrlKey){
7925 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
7927 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
7929 }else if(k == e.ESC){
7933 g.startEditing(newCell[0], newCell[1]);
7938 * Ext JS Library 1.1.1
7939 * Copyright(c) 2006-2007, Ext JS, LLC.
7941 * Originally Released Under LGPL - original licence link has changed is not relivant.
7944 * <script type="text/javascript">
7949 * @class Roo.grid.ColumnModel
7950 * @extends Roo.util.Observable
7951 * This is the default implementation of a ColumnModel used by the Grid. It defines
7952 * the columns in the grid.
7955 var colModel = new Roo.grid.ColumnModel([
7956 {header: "Ticker", width: 60, sortable: true, locked: true},
7957 {header: "Company Name", width: 150, sortable: true},
7958 {header: "Market Cap.", width: 100, sortable: true},
7959 {header: "$ Sales", width: 100, sortable: true, renderer: money},
7960 {header: "Employees", width: 100, sortable: true, resizable: false}
7965 * The config options listed for this class are options which may appear in each
7966 * individual column definition.
7967 * <br/>RooJS Fix - column id's are not sequential but use Roo.id() - fixes bugs with layouts.
7969 * @param {Object} config An Array of column config objects. See this class's
7970 * config objects for details.
7972 Roo.grid.ColumnModel = function(config){
7974 * The config passed into the constructor
7976 this.config = []; //config;
7979 // if no id, create one
7980 // if the column does not have a dataIndex mapping,
7981 // map it to the order it is in the config
7982 for(var i = 0, len = config.length; i < len; i++){
7983 this.addColumn(config[i]);
7988 * The width of columns which have no width specified (defaults to 100)
7991 this.defaultWidth = 100;
7994 * Default sortable of columns which have no sortable specified (defaults to false)
7997 this.defaultSortable = false;
8001 * @event widthchange
8002 * Fires when the width of a column changes.
8003 * @param {ColumnModel} this
8004 * @param {Number} columnIndex The column index
8005 * @param {Number} newWidth The new width
8007 "widthchange": true,
8009 * @event headerchange
8010 * Fires when the text of a header changes.
8011 * @param {ColumnModel} this
8012 * @param {Number} columnIndex The column index
8013 * @param {Number} newText The new header text
8015 "headerchange": true,
8017 * @event hiddenchange
8018 * Fires when a column is hidden or "unhidden".
8019 * @param {ColumnModel} this
8020 * @param {Number} columnIndex The column index
8021 * @param {Boolean} hidden true if hidden, false otherwise
8023 "hiddenchange": true,
8025 * @event columnmoved
8026 * Fires when a column is moved.
8027 * @param {ColumnModel} this
8028 * @param {Number} oldIndex
8029 * @param {Number} newIndex
8031 "columnmoved" : true,
8033 * @event columlockchange
8034 * Fires when a column's locked state is changed
8035 * @param {ColumnModel} this
8036 * @param {Number} colIndex
8037 * @param {Boolean} locked true if locked
8039 "columnlockchange" : true
8041 Roo.grid.ColumnModel.superclass.constructor.call(this);
8043 Roo.extend(Roo.grid.ColumnModel, Roo.util.Observable, {
8045 * @cfg {String} header The header text to display in the Grid view.
8048 * @cfg {String} xsHeader Header at Bootsrap Extra Small width (default for all)
8051 * @cfg {String} smHeader Header at Bootsrap Small width
8054 * @cfg {String} mdHeader Header at Bootsrap Medium width
8057 * @cfg {String} lgHeader Header at Bootsrap Large width
8060 * @cfg {String} xlHeader Header at Bootsrap extra Large width
8063 * @cfg {String} dataIndex (Optional) The name of the field in the grid's {@link Roo.data.Store}'s
8064 * {@link Roo.data.Record} definition from which to draw the column's value. If not
8065 * specified, the column's index is used as an index into the Record's data Array.
8068 * @cfg {Number} width (Optional) The initial width in pixels of the column. Using this
8069 * instead of {@link Roo.grid.Grid#autoSizeColumns} is more efficient.
8072 * @cfg {Boolean} sortable (Optional) True if sorting is to be allowed on this column.
8073 * Defaults to the value of the {@link #defaultSortable} property.
8074 * Whether local/remote sorting is used is specified in {@link Roo.data.Store#remoteSort}.
8077 * @cfg {Boolean} locked (Optional) True to lock the column in place while scrolling the Grid. Defaults to false.
8080 * @cfg {Boolean} fixed (Optional) True if the column width cannot be changed. Defaults to false.
8083 * @cfg {Boolean} resizable (Optional) False to disable column resizing. Defaults to true.
8086 * @cfg {Boolean} hidden (Optional) True to hide the column. Defaults to false.
8089 * @cfg {Function} renderer (Optional) A function used to generate HTML markup for a cell
8090 * given the cell's data value. See {@link #setRenderer}. If not specified, the
8091 * default renderer returns the escaped data value. If an object is returned (bootstrap only)
8092 * then it is treated as a Roo Component object instance, and it is rendered after the initial row is rendered
8095 * @cfg {Roo.grid.GridEditor} editor (Optional) For grid editors - returns the grid editor
8098 * @cfg {String} align (Optional) Set the CSS text-align property of the column. Defaults to undefined.
8101 * @cfg {String} valign (Optional) Set the CSS vertical-align property of the column (eg. middle, top, bottom etc). Defaults to undefined.
8104 * @cfg {String} cursor (Optional)
8107 * @cfg {String} tooltip (Optional)
8110 * @cfg {Number} xs (Optional) can be '0' for hidden at this size (number less than 12)
8113 * @cfg {Number} sm (Optional) can be '0' for hidden at this size (number less than 12)
8116 * @cfg {Number} md (Optional) can be '0' for hidden at this size (number less than 12)
8119 * @cfg {Number} lg (Optional) can be '0' for hidden at this size (number less than 12)
8122 * @cfg {Number} xl (Optional) can be '0' for hidden at this size (number less than 12)
8125 * Returns the id of the column at the specified index.
8126 * @param {Number} index The column index
8127 * @return {String} the id
8129 getColumnId : function(index){
8130 return this.config[index].id;
8134 * Returns the column for a specified id.
8135 * @param {String} id The column id
8136 * @return {Object} the column
8138 getColumnById : function(id){
8139 return this.lookup[id];
8144 * Returns the column Object for a specified dataIndex.
8145 * @param {String} dataIndex The column dataIndex
8146 * @return {Object|Boolean} the column or false if not found
8148 getColumnByDataIndex: function(dataIndex){
8149 var index = this.findColumnIndex(dataIndex);
8150 return index > -1 ? this.config[index] : false;
8154 * Returns the index for a specified column id.
8155 * @param {String} id The column id
8156 * @return {Number} the index, or -1 if not found
8158 getIndexById : function(id){
8159 for(var i = 0, len = this.config.length; i < len; i++){
8160 if(this.config[i].id == id){
8168 * Returns the index for a specified column dataIndex.
8169 * @param {String} dataIndex The column dataIndex
8170 * @return {Number} the index, or -1 if not found
8173 findColumnIndex : function(dataIndex){
8174 for(var i = 0, len = this.config.length; i < len; i++){
8175 if(this.config[i].dataIndex == dataIndex){
8183 moveColumn : function(oldIndex, newIndex){
8184 var c = this.config[oldIndex];
8185 this.config.splice(oldIndex, 1);
8186 this.config.splice(newIndex, 0, c);
8187 this.dataMap = null;
8188 this.fireEvent("columnmoved", this, oldIndex, newIndex);
8191 isLocked : function(colIndex){
8192 return this.config[colIndex].locked === true;
8195 setLocked : function(colIndex, value, suppressEvent){
8196 if(this.isLocked(colIndex) == value){
8199 this.config[colIndex].locked = value;
8201 this.fireEvent("columnlockchange", this, colIndex, value);
8205 getTotalLockedWidth : function(){
8207 for(var i = 0; i < this.config.length; i++){
8208 if(this.isLocked(i) && !this.isHidden(i)){
8209 this.totalWidth += this.getColumnWidth(i);
8215 getLockedCount : function(){
8216 for(var i = 0, len = this.config.length; i < len; i++){
8217 if(!this.isLocked(i)){
8222 return this.config.length;
8226 * Returns the number of columns.
8229 getColumnCount : function(visibleOnly){
8230 if(visibleOnly === true){
8232 for(var i = 0, len = this.config.length; i < len; i++){
8233 if(!this.isHidden(i)){
8239 return this.config.length;
8243 * Returns the column configs that return true by the passed function that is called with (columnConfig, index)
8244 * @param {Function} fn
8245 * @param {Object} scope (optional)
8246 * @return {Array} result
8248 getColumnsBy : function(fn, scope){
8250 for(var i = 0, len = this.config.length; i < len; i++){
8251 var c = this.config[i];
8252 if(fn.call(scope||this, c, i) === true){
8260 * Returns true if the specified column is sortable.
8261 * @param {Number} col The column index
8264 isSortable : function(col){
8265 if(typeof this.config[col].sortable == "undefined"){
8266 return this.defaultSortable;
8268 return this.config[col].sortable;
8272 * Returns the rendering (formatting) function defined for the column.
8273 * @param {Number} col The column index.
8274 * @return {Function} The function used to render the cell. See {@link #setRenderer}.
8276 getRenderer : function(col){
8277 if(!this.config[col].renderer){
8278 return Roo.grid.ColumnModel.defaultRenderer;
8280 return this.config[col].renderer;
8284 * Sets the rendering (formatting) function for a column.
8285 * @param {Number} col The column index
8286 * @param {Function} fn The function to use to process the cell's raw data
8287 * to return HTML markup for the grid view. The render function is called with
8288 * the following parameters:<ul>
8289 * <li>Data value.</li>
8290 * <li>Cell metadata. An object in which you may set the following attributes:<ul>
8291 * <li>css A CSS style string to apply to the table cell.</li>
8292 * <li>attr An HTML attribute definition string to apply to the data container element <i>within</i> the table cell.</li></ul>
8293 * <li>The {@link Roo.data.Record} from which the data was extracted.</li>
8294 * <li>Row index</li>
8295 * <li>Column index</li>
8296 * <li>The {@link Roo.data.Store} object from which the Record was extracted</li></ul>
8298 setRenderer : function(col, fn){
8299 this.config[col].renderer = fn;
8303 * Returns the width for the specified column.
8304 * @param {Number} col The column index
8305 * @param (optional) {String} gridSize bootstrap width size.
8308 getColumnWidth : function(col, gridSize)
8310 var cfg = this.config[col];
8312 if (typeof(gridSize) == 'undefined') {
8313 return cfg.width * 1 || this.defaultWidth;
8315 if (gridSize === false) { // if we set it..
8316 return cfg.width || false;
8318 var sizes = ['xl', 'lg', 'md', 'sm', 'xs'];
8320 for(var i = sizes.indexOf(gridSize); i < sizes.length; i++) {
8321 if (typeof(cfg[ sizes[i] ] ) == 'undefined') {
8324 return cfg[ sizes[i] ];
8331 * Sets the width for a column.
8332 * @param {Number} col The column index
8333 * @param {Number} width The new width
8335 setColumnWidth : function(col, width, suppressEvent){
8336 this.config[col].width = width;
8337 this.totalWidth = null;
8339 this.fireEvent("widthchange", this, col, width);
8344 * Returns the total width of all columns.
8345 * @param {Boolean} includeHidden True to include hidden column widths
8348 getTotalWidth : function(includeHidden){
8349 if(!this.totalWidth){
8350 this.totalWidth = 0;
8351 for(var i = 0, len = this.config.length; i < len; i++){
8352 if(includeHidden || !this.isHidden(i)){
8353 this.totalWidth += this.getColumnWidth(i);
8357 return this.totalWidth;
8361 * Returns the header for the specified column.
8362 * @param {Number} col The column index
8365 getColumnHeader : function(col){
8366 return this.config[col].header;
8370 * Sets the header for a column.
8371 * @param {Number} col The column index
8372 * @param {String} header The new header
8374 setColumnHeader : function(col, header){
8375 this.config[col].header = header;
8376 this.fireEvent("headerchange", this, col, header);
8380 * Returns the tooltip for the specified column.
8381 * @param {Number} col The column index
8384 getColumnTooltip : function(col){
8385 return this.config[col].tooltip;
8388 * Sets the tooltip for a column.
8389 * @param {Number} col The column index
8390 * @param {String} tooltip The new tooltip
8392 setColumnTooltip : function(col, tooltip){
8393 this.config[col].tooltip = tooltip;
8397 * Returns the dataIndex for the specified column.
8398 * @param {Number} col The column index
8401 getDataIndex : function(col){
8402 return this.config[col].dataIndex;
8406 * Sets the dataIndex for a column.
8407 * @param {Number} col The column index
8408 * @param {Number} dataIndex The new dataIndex
8410 setDataIndex : function(col, dataIndex){
8411 this.config[col].dataIndex = dataIndex;
8417 * Returns true if the cell is editable.
8418 * @param {Number} colIndex The column index
8419 * @param {Number} rowIndex The row index - this is nto actually used..?
8422 isCellEditable : function(colIndex, rowIndex){
8423 return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
8427 * Returns the editor defined for the cell/column.
8428 * return false or null to disable editing.
8429 * @param {Number} colIndex The column index
8430 * @param {Number} rowIndex The row index
8433 getCellEditor : function(colIndex, rowIndex){
8434 return this.config[colIndex].editor;
8438 * Sets if a column is editable.
8439 * @param {Number} col The column index
8440 * @param {Boolean} editable True if the column is editable
8442 setEditable : function(col, editable){
8443 this.config[col].editable = editable;
8448 * Returns true if the column is hidden.
8449 * @param {Number} colIndex The column index
8452 isHidden : function(colIndex){
8453 return this.config[colIndex].hidden;
8458 * Returns true if the column width cannot be changed
8460 isFixed : function(colIndex){
8461 return this.config[colIndex].fixed;
8465 * Returns true if the column can be resized
8468 isResizable : function(colIndex){
8469 return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
8472 * Sets if a column is hidden.
8473 * @param {Number} colIndex The column index
8474 * @param {Boolean} hidden True if the column is hidden
8476 setHidden : function(colIndex, hidden){
8477 this.config[colIndex].hidden = hidden;
8478 this.totalWidth = null;
8479 this.fireEvent("hiddenchange", this, colIndex, hidden);
8483 * Sets the editor for a column.
8484 * @param {Number} col The column index
8485 * @param {Object} editor The editor object
8487 setEditor : function(col, editor){
8488 this.config[col].editor = editor;
8491 * Add a column (experimental...) - defaults to adding to the end..
8492 * @param {Object} config
8494 addColumn : function(c)
8497 var i = this.config.length;
8500 if(typeof c.dataIndex == "undefined"){
8503 if(typeof c.renderer == "string"){
8504 c.renderer = Roo.util.Format[c.renderer];
8506 if(typeof c.id == "undefined"){
8509 if(c.editor && c.editor.xtype){
8510 c.editor = Roo.factory(c.editor, Roo.grid);
8512 if(c.editor && c.editor.isFormField){
8513 c.editor = new Roo.grid.GridEditor(c.editor);
8515 this.lookup[c.id] = c;
8520 Roo.grid.ColumnModel.defaultRenderer = function(value)
8522 if(typeof value == "object") {
8525 if(typeof value == "string" && value.length < 1){
8529 return String.format("{0}", value);
8532 // Alias for backwards compatibility
8533 Roo.grid.DefaultColumnModel = Roo.grid.ColumnModel;
8536 * Ext JS Library 1.1.1
8537 * Copyright(c) 2006-2007, Ext JS, LLC.
8539 * Originally Released Under LGPL - original licence link has changed is not relivant.
8542 * <script type="text/javascript">
8546 * @class Roo.LoadMask
8547 * A simple utility class for generically masking elements while loading data. If the element being masked has
8548 * an underlying {@link Roo.data.Store}, the masking will be automatically synchronized with the store's loading
8549 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
8550 * element's UpdateManager load indicator and will be destroyed after the initial load.
8552 * Create a new LoadMask
8553 * @param {String/HTMLElement/Roo.Element} el The element or DOM node, or its id
8554 * @param {Object} config The config object
8556 Roo.LoadMask = function(el, config){
8557 this.el = Roo.get(el);
8558 Roo.apply(this, config);
8560 this.store.on('beforeload', this.onBeforeLoad, this);
8561 this.store.on('load', this.onLoad, this);
8562 this.store.on('loadexception', this.onLoadException, this);
8563 this.removeMask = false;
8565 var um = this.el.getUpdateManager();
8566 um.showLoadIndicator = false; // disable the default indicator
8567 um.on('beforeupdate', this.onBeforeLoad, this);
8568 um.on('update', this.onLoad, this);
8569 um.on('failure', this.onLoad, this);
8570 this.removeMask = true;
8574 Roo.LoadMask.prototype = {
8576 * @cfg {Boolean} removeMask
8577 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
8578 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
8583 * The text to display in a centered loading message box (defaults to 'Loading...')
8587 * @cfg {String} msgCls
8588 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
8590 msgCls : 'x-mask-loading',
8593 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
8599 * Disables the mask to prevent it from being displayed
8601 disable : function(){
8602 this.disabled = true;
8606 * Enables the mask so that it can be displayed
8608 enable : function(){
8609 this.disabled = false;
8612 onLoadException : function()
8616 if (typeof(arguments[3]) != 'undefined') {
8617 Roo.MessageBox.alert("Error loading",arguments[3]);
8621 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
8622 Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
8629 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
8634 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
8638 onBeforeLoad : function(){
8640 (function() { this.el.mask(this.msg, this.msgCls); }).defer(50, this);
8645 destroy : function(){
8647 this.store.un('beforeload', this.onBeforeLoad, this);
8648 this.store.un('load', this.onLoad, this);
8649 this.store.un('loadexception', this.onLoadException, this);
8651 var um = this.el.getUpdateManager();
8652 um.un('beforeupdate', this.onBeforeLoad, this);
8653 um.un('update', this.onLoad, this);
8654 um.un('failure', this.onLoad, this);
8658 * @class Roo.bootstrap.Table
8660 * @extends Roo.bootstrap.Component
8661 * Bootstrap Table class. This class represents the primary interface of a component based grid control.
8662 * Similar to Roo.grid.Grid
8664 var table = Roo.factory({
8666 xns : Roo.bootstrap,
8667 autoSizeColumns: true,
8674 sortInfo : { direction : 'ASC', field: 'name' },
8676 xtype : 'HttpProxy',
8679 url : 'https://example.com/some.data.url.json'
8682 xtype : 'JsonReader',
8684 fields : [ 'id', 'name', whatever' ],
8691 xtype : 'ColumnModel',
8695 dataIndex : 'is_in_group',
8698 renderer : function(v, x , r) {
8700 return String.format("{0}", v)
8706 xtype : 'RowSelectionModel',
8707 xns : Roo.bootstrap.Table
8708 // you can add listeners to catch selection change here....
8714 grid.render(Roo.get("some-div"));
8717 Currently the Table uses multiple headers to try and handle XL / Medium etc... styling
8722 * @cfg {Roo.grid.AbstractSelectionModel} sm The selection model to use (cell selection is not supported yet)
8723 * @cfg {Roo.data.Store} store The data store to use
8724 * @cfg {Roo.grid.ColumnModel} cm[] A column for th grid.
8726 * @cfg {String} cls table class
8729 * @cfg {boolean} striped Should the rows be alternative striped
8730 * @cfg {boolean} bordered Add borders to the table
8731 * @cfg {boolean} hover Add hover highlighting
8732 * @cfg {boolean} condensed Format condensed
8733 * @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,
8734 * also adds table-responsive (see bootstrap docs for details)
8735 * @cfg {Boolean} loadMask (true|false) default false
8736 * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
8737 * @cfg {Boolean} headerShow (true|false) generate thead, default true
8738 * @cfg {Boolean} rowSelection (true|false) default false
8739 * @cfg {Boolean} cellSelection (true|false) default false
8740 * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header
8741 * @cfg {Roo.bootstrap.PagingToolbar} footer a paging toolbar
8742 * @cfg {Boolean} lazyLoad auto load data while scrolling to the end (default false)
8743 * @cfg {Boolean} auto_hide_footer auto hide footer if only one page (default false)
8744 * @cfg {Boolean} enableColumnResize default true if columns can be resized (drag/drop)
8745 * @cfg {Number} minColumnWidth default 50 pixels minimum column width
8748 * Create a new Table
8749 * @param {Object} config The config object
8752 Roo.bootstrap.Table = function(config)
8754 Roo.bootstrap.Table.superclass.constructor.call(this, config);
8757 this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
8758 this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
8759 this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
8760 this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
8762 this.view = this; // compat with grid.
8764 this.sm = this.sm || {xtype: 'RowSelectionModel'};
8766 this.sm.grid = this;
8767 this.selModel = Roo.factory(this.sm, Roo.grid);
8768 this.sm = this.selModel;
8769 this.sm.xmodule = this.xmodule || false;
8772 if (this.cm && typeof(this.cm.config) == 'undefined') {
8773 this.colModel = new Roo.grid.ColumnModel(this.cm);
8774 this.cm = this.colModel;
8775 this.cm.xmodule = this.xmodule || false;
8778 this.store= Roo.factory(this.store, Roo.data);
8779 this.ds = this.store;
8780 this.ds.xmodule = this.xmodule || false;
8783 if (this.footer && this.store) {
8784 this.footer.dataSource = this.ds;
8785 this.footer = Roo.factory(this.footer);
8792 * Fires when a cell is clicked
8793 * @param {Roo.bootstrap.Table} this
8794 * @param {Roo.Element} el
8795 * @param {Number} rowIndex
8796 * @param {Number} columnIndex
8797 * @param {Roo.EventObject} e
8801 * @event celldblclick
8802 * Fires when a cell is double clicked
8803 * @param {Roo.bootstrap.Table} this
8804 * @param {Roo.Element} el
8805 * @param {Number} rowIndex
8806 * @param {Number} columnIndex
8807 * @param {Roo.EventObject} e
8809 "celldblclick" : true,
8812 * Fires when a row is clicked
8813 * @param {Roo.bootstrap.Table} this
8814 * @param {Roo.Element} el
8815 * @param {Number} rowIndex
8816 * @param {Roo.EventObject} e
8820 * @event rowdblclick
8821 * Fires when a row is double clicked
8822 * @param {Roo.bootstrap.Table} this
8823 * @param {Roo.Element} el
8824 * @param {Number} rowIndex
8825 * @param {Roo.EventObject} e
8827 "rowdblclick" : true,
8830 * Fires when a mouseover occur
8831 * @param {Roo.bootstrap.Table} this
8832 * @param {Roo.Element} el
8833 * @param {Number} rowIndex
8834 * @param {Number} columnIndex
8835 * @param {Roo.EventObject} e
8840 * Fires when a mouseout occur
8841 * @param {Roo.bootstrap.Table} this
8842 * @param {Roo.Element} el
8843 * @param {Number} rowIndex
8844 * @param {Number} columnIndex
8845 * @param {Roo.EventObject} e
8850 * Fires when a row is rendered, so you can change add a style to it.
8851 * @param {Roo.bootstrap.Table} this
8852 * @param {Object} rowcfg contains record rowIndex colIndex and rowClass - set rowClass to add a style.
8856 * @event rowsrendered
8857 * Fires when all the rows have been rendered
8858 * @param {Roo.bootstrap.Table} this
8860 'rowsrendered' : true,
8862 * @event contextmenu
8863 * The raw contextmenu event for the entire grid.
8864 * @param {Roo.EventObject} e
8866 "contextmenu" : true,
8868 * @event rowcontextmenu
8869 * Fires when a row is right clicked
8870 * @param {Roo.bootstrap.Table} this
8871 * @param {Number} rowIndex
8872 * @param {Roo.EventObject} e
8874 "rowcontextmenu" : true,
8876 * @event cellcontextmenu
8877 * Fires when a cell is right clicked
8878 * @param {Roo.bootstrap.Table} this
8879 * @param {Number} rowIndex
8880 * @param {Number} cellIndex
8881 * @param {Roo.EventObject} e
8883 "cellcontextmenu" : true,
8885 * @event headercontextmenu
8886 * Fires when a header is right clicked
8887 * @param {Roo.bootstrap.Table} this
8888 * @param {Number} columnIndex
8889 * @param {Roo.EventObject} e
8891 "headercontextmenu" : true,
8894 * The raw mousedown event for the entire grid.
8895 * @param {Roo.EventObject} e
8902 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
8918 enableColumnResize: true,
8920 rowSelection : false,
8921 cellSelection : false,
8924 minColumnWidth : 50,
8926 // Roo.Element - the tbody
8927 bodyEl: false, // <tbody> Roo.Element - thead element
8928 headEl: false, // <thead> Roo.Element - thead element
8929 resizeProxy : false, // proxy element for dragging?
8933 container: false, // used by gridpanel...
8939 auto_hide_footer : false,
8941 view: false, // actually points to this..
8943 getAutoCreate : function()
8945 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
8952 // this get's auto added by panel.Grid
8953 if (this.scrollBody) {
8954 cfg.cls += ' table-body-fixed';
8957 cfg.cls += ' table-striped';
8961 cfg.cls += ' table-hover';
8963 if (this.bordered) {
8964 cfg.cls += ' table-bordered';
8966 if (this.condensed) {
8967 cfg.cls += ' table-condensed';
8970 if (this.responsive) {
8971 cfg.cls += ' table-responsive';
8975 cfg.cls+= ' ' +this.cls;
8981 cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
8984 if(this.store || this.cm){
8985 if(this.headerShow){
8986 cfg.cn.push(this.renderHeader());
8989 cfg.cn.push(this.renderBody());
8991 if(this.footerShow){
8992 cfg.cn.push(this.renderFooter());
8994 // where does this come from?
8995 //cfg.cls+= ' TableGrid';
8998 return { cn : [ cfg ] };
9001 initEvents : function()
9003 if(!this.store || !this.cm){
9006 if (this.selModel) {
9007 this.selModel.initEvents();
9011 //Roo.log('initEvents with ds!!!!');
9013 this.bodyEl = this.el.select('tbody', true).first();
9014 this.headEl = this.el.select('thead', true).first();
9015 this.mainFoot = this.el.select('tfoot', true).first();
9020 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
9021 e.on('click', this.sort, this);
9025 // why is this done????? = it breaks dialogs??
9026 //this.parent().el.setStyle('position', 'relative');
9030 this.footer.parentId = this.id;
9031 this.footer.onRender(this.el.select('tfoot tr td').first(), null);
9034 this.el.select('tfoot tr td').first().addClass('hide');
9039 this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
9042 this.store.on('load', this.onLoad, this);
9043 this.store.on('beforeload', this.onBeforeLoad, this);
9044 this.store.on('update', this.onUpdate, this);
9045 this.store.on('add', this.onAdd, this);
9046 this.store.on("clear", this.clear, this);
9048 this.el.on("contextmenu", this.onContextMenu, this);
9051 this.cm.on("headerchange", this.onHeaderChange, this);
9052 this.cm.on("hiddenchange", this.onHiddenChange, this, arguments);
9054 //?? does bodyEl get replaced on render?
9055 this.bodyEl.on("click", this.onClick, this);
9056 this.bodyEl.on("dblclick", this.onDblClick, this);
9057 this.bodyEl.on('scroll', this.onBodyScroll, this);
9059 // guessing mainbody will work - this relays usually caught by selmodel at present.
9060 this.relayEvents(this.bodyEl, ["mousedown","mouseup","mouseover","mouseout","keypress"]);
9063 this.resizeProxy = Roo.get(document.body).createChild({ cls:"x-grid-resize-proxy", html: ' ' });
9066 if(this.headEl && this.enableColumnResize !== false && Roo.grid.SplitDragZone){
9067 new Roo.grid.SplitDragZone(this, this.headEl.dom, false); // not sure what 'lockedHd is for this implementation..)
9072 // Compatibility with grid - we implement all the view features at present.
9073 getView : function()
9078 initCSS : function()
9082 var cm = this.cm, styles = [];
9083 this.CSS.removeStyleSheet(this.id + '-cssrules');
9084 var headHeight = this.headEl ? this.headEl.dom.clientHeight : 0;
9085 // we can honour xs/sm/md/xl as widths...
9086 // we first have to decide what widht we are currently at...
9087 var sz = Roo.getGridSize();
9091 var cols = []; // visable cols.
9093 for(var i = 0, len = cm.getColumnCount(); i < len; i++) {
9094 var w = cm.getColumnWidth(i, false);
9096 cols.push( { rel : false, abs : 0 });
9100 cols.push( { rel : false, abs : w });
9102 last = i; // not really..
9105 var w = cm.getColumnWidth(i, sz);
9110 cols.push( { rel : w, abs : false });
9113 var avail = this.bodyEl.dom.clientWidth - total_abs;
9115 var unitWidth = Math.floor(avail / total);
9116 var rem = avail - (unitWidth * total);
9118 var hidden, width, pos = 0 , splithide , left;
9119 for(var i = 0, len = cm.getColumnCount(); i < len; i++) {
9121 hidden = 'display:none;';
9123 width = 'width:0px;';
9125 if(!cm.isHidden(i)){
9129 // we can honour xs/sm/md/xl ?
9130 var w = cols[i].rel == false ? cols[i].abs : (cols[i].rel * unitWidth);
9132 hidden = 'display:none;';
9134 // width should return a small number...
9136 w+=rem; // add the remaining with..
9139 left = "left:" + (pos -4) + "px;";
9140 width = "width:" + w+ "px;";
9143 if (this.responsive) {
9146 hidden = cm.isHidden(i) ? 'display:none;' : '';
9147 splithide = 'display: none;';
9150 styles.push( '#' , this.id , ' .x-col-' , i, " {", cm.config[i].css, width, hidden, "}\n" );
9153 splithide = 'display:none;';
9156 styles.push('#' , this.id , ' .x-hcol-' , i, " { ", width, hidden," }\n",
9157 '#' , this.id , ' .x-grid-split-' , i, " { ", left, splithide,'height:', (headHeight - 4), "px;}\n"
9162 //Roo.log(styles.join(''));
9163 this.CSS.createStyleSheet( styles.join(''), this.id + '-cssrules');
9169 onContextMenu : function(e, t)
9171 this.processEvent("contextmenu", e);
9174 processEvent : function(name, e)
9176 if (name != 'touchstart' ) {
9177 this.fireEvent(name, e);
9180 var t = e.getTarget();
9182 var cell = Roo.get(t);
9188 if(cell.findParent('tfoot', false, true)){
9192 if(cell.findParent('thead', false, true)){
9194 if(e.getTarget().nodeName.toLowerCase() != 'th'){
9195 cell = Roo.get(t).findParent('th', false, true);
9197 Roo.log("failed to find th in thead?");
9198 Roo.log(e.getTarget());
9203 var cellIndex = cell.dom.cellIndex;
9205 var ename = name == 'touchstart' ? 'click' : name;
9206 this.fireEvent("header" + ename, this, cellIndex, e);
9211 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9212 cell = Roo.get(t).findParent('td', false, true);
9214 Roo.log("failed to find th in tbody?");
9215 Roo.log(e.getTarget());
9220 var row = cell.findParent('tr', false, true);
9221 var cellIndex = cell.dom.cellIndex;
9222 var rowIndex = row.dom.rowIndex - 1;
9226 this.fireEvent("row" + name, this, rowIndex, e);
9230 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
9236 onMouseover : function(e, el)
9238 var cell = Roo.get(el);
9244 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9245 cell = cell.findParent('td', false, true);
9248 var row = cell.findParent('tr', false, true);
9249 var cellIndex = cell.dom.cellIndex;
9250 var rowIndex = row.dom.rowIndex - 1; // start from 0
9252 this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
9256 onMouseout : function(e, el)
9258 var cell = Roo.get(el);
9264 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9265 cell = cell.findParent('td', false, true);
9268 var row = cell.findParent('tr', false, true);
9269 var cellIndex = cell.dom.cellIndex;
9270 var rowIndex = row.dom.rowIndex - 1; // start from 0
9272 this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
9276 onClick : function(e, el)
9278 var cell = Roo.get(el);
9280 if(!cell || (!this.cellSelection && !this.rowSelection)){
9284 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9285 cell = cell.findParent('td', false, true);
9288 if(!cell || typeof(cell) == 'undefined'){
9292 var row = cell.findParent('tr', false, true);
9294 if(!row || typeof(row) == 'undefined'){
9298 var cellIndex = cell.dom.cellIndex;
9299 var rowIndex = this.getRowIndex(row);
9301 // why??? - should these not be based on SelectionModel?
9302 //if(this.cellSelection){
9303 this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
9306 //if(this.rowSelection){
9307 this.fireEvent('rowclick', this, row, rowIndex, e);
9312 onDblClick : function(e,el)
9314 var cell = Roo.get(el);
9316 if(!cell || (!this.cellSelection && !this.rowSelection)){
9320 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9321 cell = cell.findParent('td', false, true);
9324 if(!cell || typeof(cell) == 'undefined'){
9328 var row = cell.findParent('tr', false, true);
9330 if(!row || typeof(row) == 'undefined'){
9334 var cellIndex = cell.dom.cellIndex;
9335 var rowIndex = this.getRowIndex(row);
9337 if(this.cellSelection){
9338 this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
9341 if(this.rowSelection){
9342 this.fireEvent('rowdblclick', this, row, rowIndex, e);
9345 findRowIndex : function(el)
9347 var cell = Roo.get(el);
9351 var row = cell.findParent('tr', false, true);
9353 if(!row || typeof(row) == 'undefined'){
9356 return this.getRowIndex(row);
9358 sort : function(e,el)
9360 var col = Roo.get(el);
9362 if(!col.hasClass('sortable')){
9366 var sort = col.attr('sort');
9369 if(col.select('i', true).first().hasClass('fa-arrow-up')){
9373 this.store.sortInfo = {field : sort, direction : dir};
9376 Roo.log("calling footer first");
9377 this.footer.onClick('first');
9380 this.store.load({ params : { start : 0 } });
9384 renderHeader : function()
9392 this.totalWidth = 0;
9394 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
9396 var config = cm.config[i];
9400 cls : 'x-hcol-' + i,
9403 html: cm.getColumnHeader(i)
9406 var tooltip = cm.getColumnTooltip(i);
9408 c.tooltip = tooltip;
9414 if(typeof(config.sortable) != 'undefined' && config.sortable){
9415 c.cls += ' sortable';
9416 c.html = '<i class="fa"></i>' + c.html;
9419 // could use BS4 hidden-..-down
9421 if(typeof(config.lgHeader) != 'undefined'){
9422 hh += '<span class="hidden-xs hidden-sm hidden-md ">' + config.lgHeader + '</span>';
9425 if(typeof(config.mdHeader) != 'undefined'){
9426 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
9429 if(typeof(config.smHeader) != 'undefined'){
9430 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
9433 if(typeof(config.xsHeader) != 'undefined'){
9434 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
9441 if(typeof(config.tooltip) != 'undefined'){
9442 c.tooltip = config.tooltip;
9445 if(typeof(config.colspan) != 'undefined'){
9446 c.colspan = config.colspan;
9449 // hidden is handled by CSS now
9451 if(typeof(config.dataIndex) != 'undefined'){
9452 c.sort = config.dataIndex;
9457 if(typeof(config.align) != 'undefined' && config.align.length){
9458 c.style += ' text-align:' + config.align + ';';
9461 /* width is done in CSS
9462 *if(typeof(config.width) != 'undefined'){
9463 c.style += ' width:' + config.width + 'px;';
9464 this.totalWidth += config.width;
9466 this.totalWidth += 100; // assume minimum of 100 per column?
9470 if(typeof(config.cls) != 'undefined'){
9471 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
9473 // this is the bit that doesnt reall work at all...
9475 if (this.responsive) {
9478 ['xs','sm','md','lg'].map(function(size){
9480 if(typeof(config[size]) == 'undefined'){
9484 if (!config[size]) { // 0 = hidden
9485 // BS 4 '0' is treated as hide that column and below.
9486 c.cls += ' hidden-' + size + ' hidden' + size + '-down';
9490 c.cls += ' col-' + size + '-' + config[size] + (
9491 size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
9499 c.html +=' <span class="x-grid-split x-grid-split-' + i + '"></span>';
9510 renderBody : function()
9520 colspan : this.cm.getColumnCount()
9530 renderFooter : function()
9540 colspan : this.cm.getColumnCount()
9554 // Roo.log('ds onload');
9559 var ds = this.store;
9561 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
9562 e.select('i', true).removeClass(['fa-arrow-up', 'fa-arrow-down']);
9563 if (_this.store.sortInfo) {
9565 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
9566 e.select('i', true).addClass(['fa-arrow-up']);
9569 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
9570 e.select('i', true).addClass(['fa-arrow-down']);
9575 var tbody = this.bodyEl;
9577 if(ds.getCount() > 0){
9578 ds.data.each(function(d,rowIndex){
9579 var row = this.renderRow(cm, ds, rowIndex);
9581 tbody.createChild(row);
9585 if(row.cellObjects.length){
9586 Roo.each(row.cellObjects, function(r){
9587 _this.renderCellObject(r);
9594 var tfoot = this.el.select('tfoot', true).first();
9596 if(this.footerShow && this.auto_hide_footer && this.mainFoot){
9598 this.mainFoot.setVisibilityMode(Roo.Element.DISPLAY).hide();
9600 var total = this.ds.getTotalCount();
9602 if(this.footer.pageSize < total){
9603 this.mainFoot.show();
9607 Roo.each(this.el.select('tbody td', true).elements, function(e){
9608 e.on('mouseover', _this.onMouseover, _this);
9611 Roo.each(this.el.select('tbody td', true).elements, function(e){
9612 e.on('mouseout', _this.onMouseout, _this);
9614 this.fireEvent('rowsrendered', this);
9618 this.initCSS(); /// resize cols
9624 onUpdate : function(ds,record)
9626 this.refreshRow(record);
9630 onRemove : function(ds, record, index, isUpdate){
9631 if(isUpdate !== true){
9632 this.fireEvent("beforerowremoved", this, index, record);
9634 var bt = this.bodyEl.dom;
9636 var rows = this.el.select('tbody > tr', true).elements;
9638 if(typeof(rows[index]) != 'undefined'){
9639 bt.removeChild(rows[index].dom);
9642 // if(bt.rows[index]){
9643 // bt.removeChild(bt.rows[index]);
9646 if(isUpdate !== true){
9647 //this.stripeRows(index);
9648 //this.syncRowHeights(index, index);
9650 this.fireEvent("rowremoved", this, index, record);
9654 onAdd : function(ds, records, rowIndex)
9656 //Roo.log('on Add called');
9657 // - note this does not handle multiple adding very well..
9658 var bt = this.bodyEl.dom;
9659 for (var i =0 ; i < records.length;i++) {
9660 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
9661 //Roo.log(records[i]);
9662 //Roo.log(this.store.getAt(rowIndex+i));
9663 this.insertRow(this.store, rowIndex + i, false);
9670 refreshRow : function(record){
9671 var ds = this.store, index;
9672 if(typeof record == 'number'){
9674 record = ds.getAt(index);
9676 index = ds.indexOf(record);
9678 return; // should not happen - but seems to
9681 this.insertRow(ds, index, true);
9683 this.onRemove(ds, record, index+1, true);
9685 //this.syncRowHeights(index, index);
9687 this.fireEvent("rowupdated", this, index, record);
9689 // private - called by RowSelection
9690 onRowSelect : function(rowIndex){
9691 var row = this.getRowDom(rowIndex);
9692 row.addClass(['bg-info','info']);
9694 // private - called by RowSelection
9695 onRowDeselect : function(rowIndex)
9700 var row = this.getRowDom(rowIndex);
9701 row.removeClass(['bg-info','info']);
9704 * Focuses the specified row.
9705 * @param {Number} row The row index
9707 focusRow : function(row)
9709 //Roo.log('GridView.focusRow');
9710 var x = this.bodyEl.dom.scrollLeft;
9711 this.focusCell(row, 0, false);
9712 this.bodyEl.dom.scrollLeft = x;
9716 * Focuses the specified cell.
9717 * @param {Number} row The row index
9718 * @param {Number} col The column index
9719 * @param {Boolean} hscroll false to disable horizontal scrolling
9721 focusCell : function(row, col, hscroll)
9723 //Roo.log('GridView.focusCell');
9724 var el = this.ensureVisible(row, col, hscroll);
9725 // not sure what focusEL achives = it's a <a> pos relative
9726 //this.focusEl.alignTo(el, "tl-tl");
9728 // this.focusEl.focus();
9730 // this.focusEl.focus.defer(1, this.focusEl);
9735 * Scrolls the specified cell into view
9736 * @param {Number} row The row index
9737 * @param {Number} col The column index
9738 * @param {Boolean} hscroll false to disable horizontal scrolling
9740 ensureVisible : function(row, col, hscroll)
9742 //Roo.log('GridView.ensureVisible,' + row + ',' + col);
9743 //return null; //disable for testing.
9744 if(typeof row != "number"){
9747 if(row < 0 && row >= this.ds.getCount()){
9750 col = (col !== undefined ? col : 0);
9752 while(cm.isHidden(col)){
9756 var el = this.getCellDom(row, col);
9760 var c = this.bodyEl.dom;
9762 var ctop = parseInt(el.offsetTop, 10);
9763 var cleft = parseInt(el.offsetLeft, 10);
9764 var cbot = ctop + el.offsetHeight;
9765 var cright = cleft + el.offsetWidth;
9767 //var ch = c.clientHeight - this.mainHd.dom.offsetHeight;
9768 var ch = 0; //?? header is not withing the area?
9769 var stop = parseInt(c.scrollTop, 10);
9770 var sleft = parseInt(c.scrollLeft, 10);
9771 var sbot = stop + ch;
9772 var sright = sleft + c.clientWidth;
9774 Roo.log('GridView.ensureVisible:' +
9776 ' c.clientHeight:' + c.clientHeight +
9777 ' this.mainHd.dom.offsetHeight:' + this.mainHd.dom.offsetHeight +
9786 //Roo.log("set scrolltop to ctop DISABLE?");
9787 }else if(cbot > sbot){
9788 //Roo.log("set scrolltop to cbot-ch");
9789 c.scrollTop = cbot-ch;
9792 if(hscroll !== false){
9794 c.scrollLeft = cleft;
9795 }else if(cright > sright){
9796 c.scrollLeft = cright-c.clientWidth;
9804 insertRow : function(dm, rowIndex, isUpdate){
9807 this.fireEvent("beforerowsinserted", this, rowIndex);
9809 //var s = this.getScrollState();
9810 var row = this.renderRow(this.cm, this.store, rowIndex);
9811 // insert before rowIndex..
9812 var e = this.bodyEl.createChild(row,this.getRowDom(rowIndex));
9816 if(row.cellObjects.length){
9817 Roo.each(row.cellObjects, function(r){
9818 _this.renderCellObject(r);
9823 this.fireEvent("rowsinserted", this, rowIndex);
9824 //this.syncRowHeights(firstRow, lastRow);
9825 //this.stripeRows(firstRow);
9832 getRowDom : function(rowIndex)
9834 var rows = this.el.select('tbody > tr', true).elements;
9836 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
9839 getCellDom : function(rowIndex, colIndex)
9841 var row = this.getRowDom(rowIndex);
9842 if (row === false) {
9845 var cols = row.select('td', true).elements;
9846 return (typeof(cols[colIndex]) == 'undefined') ? false : cols[colIndex];
9850 // returns the object tree for a tr..
9853 renderRow : function(cm, ds, rowIndex)
9855 var d = ds.getAt(rowIndex);
9859 cls : 'x-row-' + rowIndex,
9863 var cellObjects = [];
9865 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
9866 var config = cm.config[i];
9868 var renderer = cm.getRenderer(i);
9872 if(typeof(renderer) !== 'undefined'){
9873 value = renderer(d.data[cm.getDataIndex(i)], false, d);
9875 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
9876 // and are rendered into the cells after the row is rendered - using the id for the element.
9878 if(typeof(value) === 'object'){
9888 rowIndex : rowIndex,
9893 this.fireEvent('rowclass', this, rowcfg);
9897 // this might end up displaying HTML?
9898 // this is too messy... - better to only do it on columsn you know are going to be too long
9899 //tooltip : (typeof(value) === 'object') ? '' : value,
9900 cls : rowcfg.rowClass + ' x-col-' + i,
9902 html: (typeof(value) === 'object') ? '' : value
9909 if(typeof(config.colspan) != 'undefined'){
9910 td.colspan = config.colspan;
9915 if(typeof(config.align) != 'undefined' && config.align.length){
9916 td.style += ' text-align:' + config.align + ';';
9918 if(typeof(config.valign) != 'undefined' && config.valign.length){
9919 td.style += ' vertical-align:' + config.valign + ';';
9922 if(typeof(config.width) != 'undefined'){
9923 td.style += ' width:' + config.width + 'px;';
9927 if(typeof(config.cursor) != 'undefined'){
9928 td.style += ' cursor:' + config.cursor + ';';
9931 if(typeof(config.cls) != 'undefined'){
9932 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
9934 if (this.responsive) {
9935 ['xs','sm','md','lg'].map(function(size){
9937 if(typeof(config[size]) == 'undefined'){
9943 if (!config[size]) { // 0 = hidden
9944 // BS 4 '0' is treated as hide that column and below.
9945 td.cls += ' hidden-' + size + ' hidden' + size + '-down';
9949 td.cls += ' col-' + size + '-' + config[size] + (
9950 size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
9960 row.cellObjects = cellObjects;
9968 onBeforeLoad : function()
9977 this.el.select('tbody', true).first().dom.innerHTML = '';
9980 * Show or hide a row.
9981 * @param {Number} rowIndex to show or hide
9982 * @param {Boolean} state hide
9984 setRowVisibility : function(rowIndex, state)
9986 var bt = this.bodyEl.dom;
9988 var rows = this.el.select('tbody > tr', true).elements;
9990 if(typeof(rows[rowIndex]) == 'undefined'){
9993 rows[rowIndex][ state ? 'removeClass' : 'addClass']('d-none');
9998 getSelectionModel : function(){
10000 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
10002 return this.selModel;
10005 * Render the Roo.bootstrap object from renderder
10007 renderCellObject : function(r)
10011 r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
10013 var t = r.cfg.render(r.container);
10016 Roo.each(r.cfg.cn, function(c){
10018 container: t.getChildContainer(),
10021 _this.renderCellObject(child);
10026 * get the Row Index from a dom element.
10027 * @param {Roo.Element} row The row to look for
10028 * @returns {Number} the row
10030 getRowIndex : function(row)
10034 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
10045 * get the header TH element for columnIndex
10046 * @param {Number} columnIndex
10047 * @returns {Roo.Element}
10049 getHeaderIndex: function(colIndex)
10051 var cols = this.headEl.select('th', true).elements;
10052 return cols[colIndex];
10055 * get the Column Index from a dom element. (using regex on x-hcol-{colid})
10056 * @param {domElement} cell to look for
10057 * @returns {Number} the column
10059 getCellIndex : function(cell)
10061 var id = String(cell.className).match(Roo.bootstrap.Table.cellRE);
10063 return parseInt(id[1], 10);
10068 * Returns the grid's underlying element = used by panel.Grid
10069 * @return {Element} The element
10071 getGridEl : function(){
10075 * Forces a resize - used by panel.Grid
10076 * @return {Element} The element
10078 autoSize : function()
10080 //var ctr = Roo.get(this.container.dom.parentElement);
10081 var ctr = Roo.get(this.el.dom);
10083 var thd = this.getGridEl().select('thead',true).first();
10084 var tbd = this.getGridEl().select('tbody', true).first();
10085 var tfd = this.getGridEl().select('tfoot', true).first();
10087 var cw = ctr.getWidth();
10088 this.getGridEl().select('tfoot tr, tfoot td',true).setWidth(cw);
10092 tbd.setWidth(ctr.getWidth());
10093 // if the body has a max height - and then scrolls - we should perhaps set up the height here
10094 // this needs fixing for various usage - currently only hydra job advers I think..
10096 // ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
10098 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
10101 cw = Math.max(cw, this.totalWidth);
10102 this.getGridEl().select('tbody tr',true).setWidth(cw);
10105 // resize 'expandable coloumn?
10107 return; // we doe not have a view in this design..
10110 onBodyScroll: function()
10112 //Roo.log("body scrolled');" + this.bodyEl.dom.scrollLeft);
10114 this.headEl.setStyle({
10115 'position' : 'relative',
10116 'left': (-1* this.bodyEl.dom.scrollLeft) + 'px'
10122 var scrollHeight = this.bodyEl.dom.scrollHeight;
10124 var scrollTop = Math.ceil(this.bodyEl.getScroll().top);
10126 var height = this.bodyEl.getHeight();
10128 if(scrollHeight - height == scrollTop) {
10130 var total = this.ds.getTotalCount();
10132 if(this.footer.cursor + this.footer.pageSize < total){
10134 this.footer.ds.load({
10136 start : this.footer.cursor + this.footer.pageSize,
10137 limit : this.footer.pageSize
10146 onColumnSplitterMoved : function(i, diff)
10148 this.userResized = true;
10150 var cm = this.colModel;
10152 var w = this.getHeaderIndex(i).getWidth() + diff;
10155 cm.setColumnWidth(i, w, true);
10157 //var cid = cm.getColumnId(i); << not used in this version?
10158 /* Roo.log(['#' + this.id + ' .x-col-' + i, "width", w + "px"]);
10160 this.CSS.updateRule( '#' + this.id + ' .x-col-' + i, "width", w + "px");
10161 this.CSS.updateRule('#' + this.id + ' .x-hcol-' + i, "width", w + "px");
10162 this.CSS.updateRule('#' + this.id + ' .x-grid-split-' + i, "left", w + "px");
10164 //this.updateSplitters();
10165 //this.layout(); << ??
10166 this.fireEvent("columnresize", i, w);
10168 onHeaderChange : function()
10170 var header = this.renderHeader();
10171 var table = this.el.select('table', true).first();
10173 this.headEl.remove();
10174 this.headEl = table.createChild(header, this.bodyEl, false);
10176 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
10177 e.on('click', this.sort, this);
10180 if(this.enableColumnResize !== false && Roo.grid.SplitDragZone){
10181 new Roo.grid.SplitDragZone(this, this.headEl.dom, false); // not sure what 'lockedHd is for this implementation..)
10186 onHiddenChange : function(colModel, colIndex, hidden)
10189 this.cm.setHidden()
10190 var thSelector = '#' + this.id + ' .x-hcol-' + colIndex;
10191 var tdSelector = '#' + this.id + ' .x-col-' + colIndex;
10193 this.CSS.updateRule(thSelector, "display", "");
10194 this.CSS.updateRule(tdSelector, "display", "");
10197 this.CSS.updateRule(thSelector, "display", "none");
10198 this.CSS.updateRule(tdSelector, "display", "none");
10201 // onload calls initCSS()
10202 this.onHeaderChange();
10206 setColumnWidth: function(col_index, width)
10208 // width = "md-2 xs-2..."
10209 if(!this.colModel.config[col_index]) {
10213 var w = width.split(" ");
10215 var rows = this.el.dom.getElementsByClassName("x-col-"+col_index);
10217 var h_row = this.el.dom.getElementsByClassName("x-hcol-"+col_index);
10220 for(var j = 0; j < w.length; j++) {
10226 var size_cls = w[j].split("-");
10228 if(!Number.isInteger(size_cls[1] * 1)) {
10232 if(!this.colModel.config[col_index][size_cls[0]]) {
10236 if(!h_row[0].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
10240 h_row[0].classList.replace(
10241 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
10242 "col-"+size_cls[0]+"-"+size_cls[1]
10245 for(var i = 0; i < rows.length; i++) {
10247 var size_cls = w[j].split("-");
10249 if(!Number.isInteger(size_cls[1] * 1)) {
10253 if(!this.colModel.config[col_index][size_cls[0]]) {
10257 if(!rows[i].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
10261 rows[i].classList.replace(
10262 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
10263 "col-"+size_cls[0]+"-"+size_cls[1]
10267 this.colModel.config[col_index][size_cls[0]] = size_cls[1];
10272 // currently only used to find the split on drag..
10273 Roo.bootstrap.Table.cellRE = /(?:.*?)x-grid-(?:hd|cell|split)-([\d]+)(?:.*?)/;
10278 Roo.bootstrap.Table.AbstractSelectionModel = Roo.grid.AbstractSelectionModel;
10279 Roo.bootstrap.Table.RowSelectionModel = Roo.grid.RowSelectionModel;
10288 * @class Roo.bootstrap.TableCell
10289 * @extends Roo.bootstrap.Component
10290 * Bootstrap TableCell class
10291 * @cfg {String} html cell contain text
10292 * @cfg {String} cls cell class
10293 * @cfg {String} tag cell tag (td|th) default td
10294 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
10295 * @cfg {String} align Aligns the content in a cell
10296 * @cfg {String} axis Categorizes cells
10297 * @cfg {String} bgcolor Specifies the background color of a cell
10298 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
10299 * @cfg {Number} colspan Specifies the number of columns a cell should span
10300 * @cfg {String} headers Specifies one or more header cells a cell is related to
10301 * @cfg {Number} height Sets the height of a cell
10302 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
10303 * @cfg {Number} rowspan Sets the number of rows a cell should span
10304 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
10305 * @cfg {String} valign Vertical aligns the content in a cell
10306 * @cfg {Number} width Specifies the width of a cell
10309 * Create a new TableCell
10310 * @param {Object} config The config object
10313 Roo.bootstrap.TableCell = function(config){
10314 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
10317 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
10337 getAutoCreate : function(){
10338 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
10345 cfg.tag = this.tag;
10358 cfg.align=this.align
10363 if (this.bgcolor) {
10364 cfg.bgcolor=this.bgcolor
10366 if (this.charoff) {
10367 cfg.charoff=this.charoff
10369 if (this.colspan) {
10370 cfg.colspan=this.colspan
10372 if (this.headers) {
10373 cfg.headers=this.headers
10376 cfg.height=this.height
10379 cfg.nowrap=this.nowrap
10381 if (this.rowspan) {
10382 cfg.rowspan=this.rowspan
10385 cfg.scope=this.scope
10388 cfg.valign=this.valign
10391 cfg.width=this.width
10410 * @class Roo.bootstrap.TableRow
10411 * @extends Roo.bootstrap.Component
10412 * Bootstrap TableRow class
10413 * @cfg {String} cls row class
10414 * @cfg {String} align Aligns the content in a table row
10415 * @cfg {String} bgcolor Specifies a background color for a table row
10416 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
10417 * @cfg {String} valign Vertical aligns the content in a table row
10420 * Create a new TableRow
10421 * @param {Object} config The config object
10424 Roo.bootstrap.TableRow = function(config){
10425 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
10428 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
10436 getAutoCreate : function(){
10437 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
10444 cfg.cls = this.cls;
10447 cfg.align = this.align;
10450 cfg.bgcolor = this.bgcolor;
10453 cfg.charoff = this.charoff;
10456 cfg.valign = this.valign;
10474 * @class Roo.bootstrap.TableBody
10475 * @extends Roo.bootstrap.Component
10476 * Bootstrap TableBody class
10477 * @cfg {String} cls element class
10478 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
10479 * @cfg {String} align Aligns the content inside the element
10480 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
10481 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
10484 * Create a new TableBody
10485 * @param {Object} config The config object
10488 Roo.bootstrap.TableBody = function(config){
10489 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
10492 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
10500 getAutoCreate : function(){
10501 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
10511 cfg.tag = this.tag;
10515 cfg.align = this.align;
10518 cfg.charoff = this.charoff;
10521 cfg.valign = this.valign;
10528 // initEvents : function()
10531 // if(!this.store){
10535 // this.store = Roo.factory(this.store, Roo.data);
10536 // this.store.on('load', this.onLoad, this);
10538 // this.store.load();
10542 // onLoad: function ()
10544 // this.fireEvent('load', this);
10554 * Ext JS Library 1.1.1
10555 * Copyright(c) 2006-2007, Ext JS, LLC.
10557 * Originally Released Under LGPL - original licence link has changed is not relivant.
10560 * <script type="text/javascript">
10563 // as we use this in bootstrap.
10564 Roo.namespace('Roo.form');
10566 * @class Roo.form.Action
10567 * Internal Class used to handle form actions
10569 * @param {Roo.form.BasicForm} el The form element or its id
10570 * @param {Object} config Configuration options
10575 // define the action interface
10576 Roo.form.Action = function(form, options){
10578 this.options = options || {};
10581 * Client Validation Failed
10584 Roo.form.Action.CLIENT_INVALID = 'client';
10586 * Server Validation Failed
10589 Roo.form.Action.SERVER_INVALID = 'server';
10591 * Connect to Server Failed
10594 Roo.form.Action.CONNECT_FAILURE = 'connect';
10596 * Reading Data from Server Failed
10599 Roo.form.Action.LOAD_FAILURE = 'load';
10601 Roo.form.Action.prototype = {
10603 failureType : undefined,
10604 response : undefined,
10605 result : undefined,
10607 // interface method
10608 run : function(options){
10612 // interface method
10613 success : function(response){
10617 // interface method
10618 handleResponse : function(response){
10622 // default connection failure
10623 failure : function(response){
10625 this.response = response;
10626 this.failureType = Roo.form.Action.CONNECT_FAILURE;
10627 this.form.afterAction(this, false);
10630 processResponse : function(response){
10631 this.response = response;
10632 if(!response.responseText){
10635 this.result = this.handleResponse(response);
10636 return this.result;
10639 // utility functions used internally
10640 getUrl : function(appendParams){
10641 var url = this.options.url || this.form.url || this.form.el.dom.action;
10643 var p = this.getParams();
10645 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
10651 getMethod : function(){
10652 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
10655 getParams : function(){
10656 var bp = this.form.baseParams;
10657 var p = this.options.params;
10659 if(typeof p == "object"){
10660 p = Roo.urlEncode(Roo.applyIf(p, bp));
10661 }else if(typeof p == 'string' && bp){
10662 p += '&' + Roo.urlEncode(bp);
10665 p = Roo.urlEncode(bp);
10670 createCallback : function(){
10672 success: this.success,
10673 failure: this.failure,
10675 timeout: (this.form.timeout*1000),
10676 upload: this.form.fileUpload ? this.success : undefined
10681 Roo.form.Action.Submit = function(form, options){
10682 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
10685 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
10688 haveProgress : false,
10689 uploadComplete : false,
10691 // uploadProgress indicator.
10692 uploadProgress : function()
10694 if (!this.form.progressUrl) {
10698 if (!this.haveProgress) {
10699 Roo.MessageBox.progress("Uploading", "Uploading");
10701 if (this.uploadComplete) {
10702 Roo.MessageBox.hide();
10706 this.haveProgress = true;
10708 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
10710 var c = new Roo.data.Connection();
10712 url : this.form.progressUrl,
10717 success : function(req){
10718 //console.log(data);
10722 rdata = Roo.decode(req.responseText)
10724 Roo.log("Invalid data from server..");
10728 if (!rdata || !rdata.success) {
10730 Roo.MessageBox.alert(Roo.encode(rdata));
10733 var data = rdata.data;
10735 if (this.uploadComplete) {
10736 Roo.MessageBox.hide();
10741 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
10742 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
10745 this.uploadProgress.defer(2000,this);
10748 failure: function(data) {
10749 Roo.log('progress url failed ');
10760 // run get Values on the form, so it syncs any secondary forms.
10761 this.form.getValues();
10763 var o = this.options;
10764 var method = this.getMethod();
10765 var isPost = method == 'POST';
10766 if(o.clientValidation === false || this.form.isValid()){
10768 if (this.form.progressUrl) {
10769 this.form.findField('UPLOAD_IDENTIFIER').setValue(
10770 (new Date() * 1) + '' + Math.random());
10775 Roo.Ajax.request(Roo.apply(this.createCallback(), {
10776 form:this.form.el.dom,
10777 url:this.getUrl(!isPost),
10779 params:isPost ? this.getParams() : null,
10780 isUpload: this.form.fileUpload,
10781 formData : this.form.formData
10784 this.uploadProgress();
10786 }else if (o.clientValidation !== false){ // client validation failed
10787 this.failureType = Roo.form.Action.CLIENT_INVALID;
10788 this.form.afterAction(this, false);
10792 success : function(response)
10794 this.uploadComplete= true;
10795 if (this.haveProgress) {
10796 Roo.MessageBox.hide();
10800 var result = this.processResponse(response);
10801 if(result === true || result.success){
10802 this.form.afterAction(this, true);
10806 this.form.markInvalid(result.errors);
10807 this.failureType = Roo.form.Action.SERVER_INVALID;
10809 this.form.afterAction(this, false);
10811 failure : function(response)
10813 this.uploadComplete= true;
10814 if (this.haveProgress) {
10815 Roo.MessageBox.hide();
10818 this.response = response;
10819 this.failureType = Roo.form.Action.CONNECT_FAILURE;
10820 this.form.afterAction(this, false);
10823 handleResponse : function(response){
10824 if(this.form.errorReader){
10825 var rs = this.form.errorReader.read(response);
10828 for(var i = 0, len = rs.records.length; i < len; i++) {
10829 var r = rs.records[i];
10830 errors[i] = r.data;
10833 if(errors.length < 1){
10837 success : rs.success,
10843 ret = Roo.decode(response.responseText);
10847 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
10857 Roo.form.Action.Load = function(form, options){
10858 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
10859 this.reader = this.form.reader;
10862 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
10867 Roo.Ajax.request(Roo.apply(
10868 this.createCallback(), {
10869 method:this.getMethod(),
10870 url:this.getUrl(false),
10871 params:this.getParams()
10875 success : function(response){
10877 var result = this.processResponse(response);
10878 if(result === true || !result.success || !result.data){
10879 this.failureType = Roo.form.Action.LOAD_FAILURE;
10880 this.form.afterAction(this, false);
10883 this.form.clearInvalid();
10884 this.form.setValues(result.data);
10885 this.form.afterAction(this, true);
10888 handleResponse : function(response){
10889 if(this.form.reader){
10890 var rs = this.form.reader.read(response);
10891 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
10893 success : rs.success,
10897 return Roo.decode(response.responseText);
10901 Roo.form.Action.ACTION_TYPES = {
10902 'load' : Roo.form.Action.Load,
10903 'submit' : Roo.form.Action.Submit
10912 * @class Roo.bootstrap.Form
10913 * @extends Roo.bootstrap.Component
10914 * Bootstrap Form class
10915 * @cfg {String} method GET | POST (default POST)
10916 * @cfg {String} labelAlign top | left (default top)
10917 * @cfg {String} align left | right - for navbars
10918 * @cfg {Boolean} loadMask load mask when submit (default true)
10922 * Create a new Form
10923 * @param {Object} config The config object
10927 Roo.bootstrap.Form = function(config){
10929 Roo.bootstrap.Form.superclass.constructor.call(this, config);
10931 Roo.bootstrap.Form.popover.apply();
10935 * @event clientvalidation
10936 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
10937 * @param {Form} this
10938 * @param {Boolean} valid true if the form has passed client-side validation
10940 clientvalidation: true,
10942 * @event beforeaction
10943 * Fires before any action is performed. Return false to cancel the action.
10944 * @param {Form} this
10945 * @param {Action} action The action to be performed
10947 beforeaction: true,
10949 * @event actionfailed
10950 * Fires when an action fails.
10951 * @param {Form} this
10952 * @param {Action} action The action that failed
10954 actionfailed : true,
10956 * @event actioncomplete
10957 * Fires when an action is completed.
10958 * @param {Form} this
10959 * @param {Action} action The action that completed
10961 actioncomplete : true
10965 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
10968 * @cfg {String} method
10969 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
10973 * @cfg {String} url
10974 * The URL to use for form actions if one isn't supplied in the action options.
10977 * @cfg {Boolean} fileUpload
10978 * Set to true if this form is a file upload.
10982 * @cfg {Object} baseParams
10983 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
10987 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
10991 * @cfg {Sting} align (left|right) for navbar forms
10996 activeAction : null,
10999 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
11000 * element by passing it or its id or mask the form itself by passing in true.
11003 waitMsgTarget : false,
11008 * @cfg {Boolean} errorMask (true|false) default false
11013 * @cfg {Number} maskOffset Default 100
11018 * @cfg {Boolean} maskBody
11022 getAutoCreate : function(){
11026 method : this.method || 'POST',
11027 id : this.id || Roo.id(),
11030 if (this.parent().xtype.match(/^Nav/)) {
11031 cfg.cls = 'navbar-form form-inline navbar-' + this.align;
11035 if (this.labelAlign == 'left' ) {
11036 cfg.cls += ' form-horizontal';
11042 initEvents : function()
11044 this.el.on('submit', this.onSubmit, this);
11045 // this was added as random key presses on the form where triggering form submit.
11046 this.el.on('keypress', function(e) {
11047 if (e.getCharCode() != 13) {
11050 // we might need to allow it for textareas.. and some other items.
11051 // check e.getTarget().
11053 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
11057 Roo.log("keypress blocked");
11059 e.preventDefault();
11065 onSubmit : function(e){
11070 * Returns true if client-side validation on the form is successful.
11073 isValid : function(){
11074 var items = this.getItems();
11076 var target = false;
11078 items.each(function(f){
11084 Roo.log('invalid field: ' + f.name);
11088 if(!target && f.el.isVisible(true)){
11094 if(this.errorMask && !valid){
11095 Roo.bootstrap.Form.popover.mask(this, target);
11102 * Returns true if any fields in this form have changed since their original load.
11105 isDirty : function(){
11107 var items = this.getItems();
11108 items.each(function(f){
11118 * Performs a predefined action (submit or load) or custom actions you define on this form.
11119 * @param {String} actionName The name of the action type
11120 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
11121 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
11122 * accept other config options):
11124 Property Type Description
11125 ---------------- --------------- ----------------------------------------------------------------------------------
11126 url String The url for the action (defaults to the form's url)
11127 method String The form method to use (defaults to the form's method, or POST if not defined)
11128 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
11129 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
11130 validate the form on the client (defaults to false)
11132 * @return {BasicForm} this
11134 doAction : function(action, options){
11135 if(typeof action == 'string'){
11136 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
11138 if(this.fireEvent('beforeaction', this, action) !== false){
11139 this.beforeAction(action);
11140 action.run.defer(100, action);
11146 beforeAction : function(action){
11147 var o = action.options;
11152 Roo.get(document.body).mask(o.waitMsg || "Sending", 'x-mask-loading')
11154 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
11157 // not really supported yet.. ??
11159 //if(this.waitMsgTarget === true){
11160 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
11161 //}else if(this.waitMsgTarget){
11162 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
11163 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
11165 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
11171 afterAction : function(action, success){
11172 this.activeAction = null;
11173 var o = action.options;
11178 Roo.get(document.body).unmask();
11184 //if(this.waitMsgTarget === true){
11185 // this.el.unmask();
11186 //}else if(this.waitMsgTarget){
11187 // this.waitMsgTarget.unmask();
11189 // Roo.MessageBox.updateProgress(1);
11190 // Roo.MessageBox.hide();
11197 Roo.callback(o.success, o.scope, [this, action]);
11198 this.fireEvent('actioncomplete', this, action);
11202 // failure condition..
11203 // we have a scenario where updates need confirming.
11204 // eg. if a locking scenario exists..
11205 // we look for { errors : { needs_confirm : true }} in the response.
11207 (typeof(action.result) != 'undefined') &&
11208 (typeof(action.result.errors) != 'undefined') &&
11209 (typeof(action.result.errors.needs_confirm) != 'undefined')
11212 Roo.log("not supported yet");
11215 Roo.MessageBox.confirm(
11216 "Change requires confirmation",
11217 action.result.errorMsg,
11222 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
11232 Roo.callback(o.failure, o.scope, [this, action]);
11233 // show an error message if no failed handler is set..
11234 if (!this.hasListener('actionfailed')) {
11235 Roo.log("need to add dialog support");
11237 Roo.MessageBox.alert("Error",
11238 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
11239 action.result.errorMsg :
11240 "Saving Failed, please check your entries or try again"
11245 this.fireEvent('actionfailed', this, action);
11250 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
11251 * @param {String} id The value to search for
11254 findField : function(id){
11255 var items = this.getItems();
11256 var field = items.get(id);
11258 items.each(function(f){
11259 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
11266 return field || null;
11269 * Mark fields in this form invalid in bulk.
11270 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
11271 * @return {BasicForm} this
11273 markInvalid : function(errors){
11274 if(errors instanceof Array){
11275 for(var i = 0, len = errors.length; i < len; i++){
11276 var fieldError = errors[i];
11277 var f = this.findField(fieldError.id);
11279 f.markInvalid(fieldError.msg);
11285 if(typeof errors[id] != 'function' && (field = this.findField(id))){
11286 field.markInvalid(errors[id]);
11290 //Roo.each(this.childForms || [], function (f) {
11291 // f.markInvalid(errors);
11298 * Set values for fields in this form in bulk.
11299 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
11300 * @return {BasicForm} this
11302 setValues : function(values){
11303 if(values instanceof Array){ // array of objects
11304 for(var i = 0, len = values.length; i < len; i++){
11306 var f = this.findField(v.id);
11308 f.setValue(v.value);
11309 if(this.trackResetOnLoad){
11310 f.originalValue = f.getValue();
11314 }else{ // object hash
11317 if(typeof values[id] != 'function' && (field = this.findField(id))){
11319 if (field.setFromData &&
11320 field.valueField &&
11321 field.displayField &&
11322 // combos' with local stores can
11323 // be queried via setValue()
11324 // to set their value..
11325 (field.store && !field.store.isLocal)
11329 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
11330 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
11331 field.setFromData(sd);
11333 } else if(field.setFromData && (field.store && !field.store.isLocal)) {
11335 field.setFromData(values);
11338 field.setValue(values[id]);
11342 if(this.trackResetOnLoad){
11343 field.originalValue = field.getValue();
11349 //Roo.each(this.childForms || [], function (f) {
11350 // f.setValues(values);
11357 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
11358 * they are returned as an array.
11359 * @param {Boolean} asString
11362 getValues : function(asString){
11363 //if (this.childForms) {
11364 // copy values from the child forms
11365 // Roo.each(this.childForms, function (f) {
11366 // this.setValues(f.getValues());
11372 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
11373 if(asString === true){
11376 return Roo.urlDecode(fs);
11380 * Returns the fields in this form as an object with key/value pairs.
11381 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
11384 getFieldValues : function(with_hidden)
11386 var items = this.getItems();
11388 items.each(function(f){
11390 if (!f.getName()) {
11394 var v = f.getValue();
11396 if (f.inputType =='radio') {
11397 if (typeof(ret[f.getName()]) == 'undefined') {
11398 ret[f.getName()] = ''; // empty..
11401 if (!f.el.dom.checked) {
11405 v = f.el.dom.value;
11409 if(f.xtype == 'MoneyField'){
11410 ret[f.currencyName] = f.getCurrency();
11413 // not sure if this supported any more..
11414 if ((typeof(v) == 'object') && f.getRawValue) {
11415 v = f.getRawValue() ; // dates..
11417 // combo boxes where name != hiddenName...
11418 if (f.name !== false && f.name != '' && f.name != f.getName()) {
11419 ret[f.name] = f.getRawValue();
11421 ret[f.getName()] = v;
11428 * Clears all invalid messages in this form.
11429 * @return {BasicForm} this
11431 clearInvalid : function(){
11432 var items = this.getItems();
11434 items.each(function(f){
11442 * Resets this form.
11443 * @return {BasicForm} this
11445 reset : function(){
11446 var items = this.getItems();
11447 items.each(function(f){
11451 Roo.each(this.childForms || [], function (f) {
11459 getItems : function()
11461 var r=new Roo.util.MixedCollection(false, function(o){
11462 return o.id || (o.id = Roo.id());
11464 var iter = function(el) {
11471 Roo.each(el.items,function(e) {
11480 hideFields : function(items)
11482 Roo.each(items, function(i){
11484 var f = this.findField(i);
11495 showFields : function(items)
11497 Roo.each(items, function(i){
11499 var f = this.findField(i);
11512 Roo.apply(Roo.bootstrap.Form, {
11528 intervalID : false,
11534 if(this.isApplied){
11539 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
11540 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
11541 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
11542 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
11545 this.maskEl.top.enableDisplayMode("block");
11546 this.maskEl.left.enableDisplayMode("block");
11547 this.maskEl.bottom.enableDisplayMode("block");
11548 this.maskEl.right.enableDisplayMode("block");
11550 this.toolTip = new Roo.bootstrap.Tooltip({
11551 cls : 'roo-form-error-popover',
11553 'left' : ['r-l', [-2,0], 'right'],
11554 'right' : ['l-r', [2,0], 'left'],
11555 'bottom' : ['tl-bl', [0,2], 'top'],
11556 'top' : [ 'bl-tl', [0,-2], 'bottom']
11560 this.toolTip.render(Roo.get(document.body));
11562 this.toolTip.el.enableDisplayMode("block");
11564 Roo.get(document.body).on('click', function(){
11568 Roo.get(document.body).on('touchstart', function(){
11572 this.isApplied = true
11575 mask : function(form, target)
11579 this.target = target;
11581 if(!this.form.errorMask || !target.el){
11585 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
11587 Roo.log(scrollable);
11589 var ot = this.target.el.calcOffsetsTo(scrollable);
11591 var scrollTo = ot[1] - this.form.maskOffset;
11593 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
11595 scrollable.scrollTo('top', scrollTo);
11597 var box = this.target.el.getBox();
11599 var zIndex = Roo.bootstrap.Modal.zIndex++;
11602 this.maskEl.top.setStyle('position', 'absolute');
11603 this.maskEl.top.setStyle('z-index', zIndex);
11604 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
11605 this.maskEl.top.setLeft(0);
11606 this.maskEl.top.setTop(0);
11607 this.maskEl.top.show();
11609 this.maskEl.left.setStyle('position', 'absolute');
11610 this.maskEl.left.setStyle('z-index', zIndex);
11611 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
11612 this.maskEl.left.setLeft(0);
11613 this.maskEl.left.setTop(box.y - this.padding);
11614 this.maskEl.left.show();
11616 this.maskEl.bottom.setStyle('position', 'absolute');
11617 this.maskEl.bottom.setStyle('z-index', zIndex);
11618 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
11619 this.maskEl.bottom.setLeft(0);
11620 this.maskEl.bottom.setTop(box.bottom + this.padding);
11621 this.maskEl.bottom.show();
11623 this.maskEl.right.setStyle('position', 'absolute');
11624 this.maskEl.right.setStyle('z-index', zIndex);
11625 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
11626 this.maskEl.right.setLeft(box.right + this.padding);
11627 this.maskEl.right.setTop(box.y - this.padding);
11628 this.maskEl.right.show();
11630 this.toolTip.bindEl = this.target.el;
11632 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
11634 var tip = this.target.blankText;
11636 if(this.target.getValue() !== '' ) {
11638 if (this.target.invalidText.length) {
11639 tip = this.target.invalidText;
11640 } else if (this.target.regexText.length){
11641 tip = this.target.regexText;
11645 this.toolTip.show(tip);
11647 this.intervalID = window.setInterval(function() {
11648 Roo.bootstrap.Form.popover.unmask();
11651 window.onwheel = function(){ return false;};
11653 (function(){ this.isMasked = true; }).defer(500, this);
11657 unmask : function()
11659 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
11663 this.maskEl.top.setStyle('position', 'absolute');
11664 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
11665 this.maskEl.top.hide();
11667 this.maskEl.left.setStyle('position', 'absolute');
11668 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
11669 this.maskEl.left.hide();
11671 this.maskEl.bottom.setStyle('position', 'absolute');
11672 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
11673 this.maskEl.bottom.hide();
11675 this.maskEl.right.setStyle('position', 'absolute');
11676 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
11677 this.maskEl.right.hide();
11679 this.toolTip.hide();
11681 this.toolTip.el.hide();
11683 window.onwheel = function(){ return true;};
11685 if(this.intervalID){
11686 window.clearInterval(this.intervalID);
11687 this.intervalID = false;
11690 this.isMasked = false;
11700 * Ext JS Library 1.1.1
11701 * Copyright(c) 2006-2007, Ext JS, LLC.
11703 * Originally Released Under LGPL - original licence link has changed is not relivant.
11706 * <script type="text/javascript">
11709 * @class Roo.form.VTypes
11710 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
11713 Roo.form.VTypes = function(){
11714 // closure these in so they are only created once.
11715 var alpha = /^[a-zA-Z_]+$/;
11716 var alphanum = /^[a-zA-Z0-9_]+$/;
11717 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
11718 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
11720 // All these messages and functions are configurable
11723 * The function used to validate email addresses
11724 * @param {String} value The email address
11726 'email' : function(v){
11727 return email.test(v);
11730 * The error text to display when the email validation function returns false
11733 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
11735 * The keystroke filter mask to be applied on email input
11738 'emailMask' : /[a-z0-9_\.\-@]/i,
11741 * The function used to validate URLs
11742 * @param {String} value The URL
11744 'url' : function(v){
11745 return url.test(v);
11748 * The error text to display when the url validation function returns false
11751 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
11754 * The function used to validate alpha values
11755 * @param {String} value The value
11757 'alpha' : function(v){
11758 return alpha.test(v);
11761 * The error text to display when the alpha validation function returns false
11764 'alphaText' : 'This field should only contain letters and _',
11766 * The keystroke filter mask to be applied on alpha input
11769 'alphaMask' : /[a-z_]/i,
11772 * The function used to validate alphanumeric values
11773 * @param {String} value The value
11775 'alphanum' : function(v){
11776 return alphanum.test(v);
11779 * The error text to display when the alphanumeric validation function returns false
11782 'alphanumText' : 'This field should only contain letters, numbers and _',
11784 * The keystroke filter mask to be applied on alphanumeric input
11787 'alphanumMask' : /[a-z0-9_]/i
11797 * @class Roo.bootstrap.Input
11798 * @extends Roo.bootstrap.Component
11799 * Bootstrap Input class
11800 * @cfg {Boolean} disabled is it disabled
11801 * @cfg {String} (button|checkbox|email|file|hidden|image|number|password|radio|range|reset|search|submit|text) inputType
11802 * @cfg {String} name name of the input
11803 * @cfg {string} fieldLabel - the label associated
11804 * @cfg {string} placeholder - placeholder to put in text.
11805 * @cfg {string} before - input group add on before
11806 * @cfg {string} after - input group add on after
11807 * @cfg {string} size - (lg|sm) or leave empty..
11808 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
11809 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
11810 * @cfg {Number} md colspan out of 12 for computer-sized screens
11811 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
11812 * @cfg {string} value default value of the input
11813 * @cfg {Number} labelWidth set the width of label
11814 * @cfg {Number} labellg set the width of label (1-12)
11815 * @cfg {Number} labelmd set the width of label (1-12)
11816 * @cfg {Number} labelsm set the width of label (1-12)
11817 * @cfg {Number} labelxs set the width of label (1-12)
11818 * @cfg {String} labelAlign (top|left)
11819 * @cfg {Boolean} readOnly Specifies that the field should be read-only
11820 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
11821 * @cfg {String} indicatorpos (left|right) default left
11822 * @cfg {String} capture (user|camera) use for file input only. (default empty)
11823 * @cfg {String} accept (image|video|audio) use for file input only. (default empty)
11824 * @cfg {Boolean} preventMark Do not show tick or cross if error/success
11826 * @cfg {String} align (left|center|right) Default left
11827 * @cfg {Boolean} forceFeedback (true|false) Default false
11830 * Create a new Input
11831 * @param {Object} config The config object
11834 Roo.bootstrap.Input = function(config){
11836 Roo.bootstrap.Input.superclass.constructor.call(this, config);
11841 * Fires when this field receives input focus.
11842 * @param {Roo.form.Field} this
11847 * Fires when this field loses input focus.
11848 * @param {Roo.form.Field} this
11852 * @event specialkey
11853 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
11854 * {@link Roo.EventObject#getKey} to determine which key was pressed.
11855 * @param {Roo.form.Field} this
11856 * @param {Roo.EventObject} e The event object
11861 * Fires just before the field blurs if the field value has changed.
11862 * @param {Roo.form.Field} this
11863 * @param {Mixed} newValue The new value
11864 * @param {Mixed} oldValue The original value
11869 * Fires after the field has been marked as invalid.
11870 * @param {Roo.form.Field} this
11871 * @param {String} msg The validation message
11876 * Fires after the field has been validated with no errors.
11877 * @param {Roo.form.Field} this
11882 * Fires after the key up
11883 * @param {Roo.form.Field} this
11884 * @param {Roo.EventObject} e The event Object
11889 * Fires after the user pastes into input
11890 * @param {Roo.form.Field} this
11891 * @param {Roo.EventObject} e The event Object
11897 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
11899 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
11900 automatic validation (defaults to "keyup").
11902 validationEvent : "keyup",
11904 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
11906 validateOnBlur : true,
11908 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
11910 validationDelay : 250,
11912 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
11914 focusClass : "x-form-focus", // not needed???
11918 * @cfg {String} invalidClass DEPRICATED - code uses BS4 - is-valid / is-invalid
11920 invalidClass : "has-warning",
11923 * @cfg {String} validClass DEPRICATED - code uses BS4 - is-valid / is-invalid
11925 validClass : "has-success",
11928 * @cfg {Boolean} hasFeedback (true|false) default true
11930 hasFeedback : true,
11933 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
11935 invalidFeedbackClass : "glyphicon-warning-sign",
11938 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
11940 validFeedbackClass : "glyphicon-ok",
11943 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
11945 selectOnFocus : false,
11948 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
11952 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
11957 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
11959 disableKeyFilter : false,
11962 * @cfg {Boolean} disabled True to disable the field (defaults to false).
11966 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
11970 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
11972 blankText : "Please complete this mandatory field",
11975 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
11979 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
11981 maxLength : Number.MAX_VALUE,
11983 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
11985 minLengthText : "The minimum length for this field is {0}",
11987 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
11989 maxLengthText : "The maximum length for this field is {0}",
11993 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
11994 * If available, this function will be called only after the basic validators all return true, and will be passed the
11995 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
11999 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
12000 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
12001 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
12005 * @cfg {String} regexText -- Depricated - use Invalid Text
12010 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
12016 autocomplete: false,
12020 inputType : 'text',
12023 placeholder: false,
12028 preventMark: false,
12029 isFormField : true,
12032 labelAlign : false,
12035 formatedValue : false,
12036 forceFeedback : false,
12038 indicatorpos : 'left',
12048 parentLabelAlign : function()
12051 while (parent.parent()) {
12052 parent = parent.parent();
12053 if (typeof(parent.labelAlign) !='undefined') {
12054 return parent.labelAlign;
12061 getAutoCreate : function()
12063 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
12069 if(this.inputType != 'hidden'){
12070 cfg.cls = 'form-group' //input-group
12076 type : this.inputType,
12077 value : this.value,
12078 cls : 'form-control',
12079 placeholder : this.placeholder || '',
12080 autocomplete : this.autocomplete || 'new-password'
12082 if (this.inputType == 'file') {
12083 input.style = 'overflow:hidden'; // why not in CSS?
12086 if(this.capture.length){
12087 input.capture = this.capture;
12090 if(this.accept.length){
12091 input.accept = this.accept + "/*";
12095 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
12098 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
12099 input.maxLength = this.maxLength;
12102 if (this.disabled) {
12103 input.disabled=true;
12106 if (this.readOnly) {
12107 input.readonly=true;
12111 input.name = this.name;
12115 input.cls += ' input-' + this.size;
12119 ['xs','sm','md','lg'].map(function(size){
12120 if (settings[size]) {
12121 cfg.cls += ' col-' + size + '-' + settings[size];
12125 var inputblock = input;
12129 cls: 'glyphicon form-control-feedback'
12132 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
12135 cls : 'has-feedback',
12143 if (this.before || this.after) {
12146 cls : 'input-group',
12150 if (this.before && typeof(this.before) == 'string') {
12152 inputblock.cn.push({
12154 cls : 'roo-input-before input-group-addon input-group-prepend input-group-text',
12158 if (this.before && typeof(this.before) == 'object') {
12159 this.before = Roo.factory(this.before);
12161 inputblock.cn.push({
12163 cls : 'roo-input-before input-group-prepend input-group-' +
12164 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
12168 inputblock.cn.push(input);
12170 if (this.after && typeof(this.after) == 'string') {
12171 inputblock.cn.push({
12173 cls : 'roo-input-after input-group-append input-group-text input-group-addon',
12177 if (this.after && typeof(this.after) == 'object') {
12178 this.after = Roo.factory(this.after);
12180 inputblock.cn.push({
12182 cls : 'roo-input-after input-group-append input-group-' +
12183 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
12187 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
12188 inputblock.cls += ' has-feedback';
12189 inputblock.cn.push(feedback);
12194 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
12195 tooltip : 'This field is required'
12197 if (this.allowBlank ) {
12198 indicator.style = this.allowBlank ? ' display:none' : '';
12200 if (align ==='left' && this.fieldLabel.length) {
12202 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
12209 cls : 'control-label col-form-label',
12210 html : this.fieldLabel
12221 var labelCfg = cfg.cn[1];
12222 var contentCfg = cfg.cn[2];
12224 if(this.indicatorpos == 'right'){
12229 cls : 'control-label col-form-label',
12233 html : this.fieldLabel
12247 labelCfg = cfg.cn[0];
12248 contentCfg = cfg.cn[1];
12252 if(this.labelWidth > 12){
12253 labelCfg.style = "width: " + this.labelWidth + 'px';
12256 if(this.labelWidth < 13 && this.labelmd == 0){
12257 this.labellg = this.labellg > 0 ? this.labellg : this.labelWidth;
12260 if(this.labellg > 0){
12261 labelCfg.cls += ' col-lg-' + this.labellg;
12262 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
12265 if(this.labelmd > 0){
12266 labelCfg.cls += ' col-md-' + this.labelmd;
12267 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
12270 if(this.labelsm > 0){
12271 labelCfg.cls += ' col-sm-' + this.labelsm;
12272 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
12275 if(this.labelxs > 0){
12276 labelCfg.cls += ' col-xs-' + this.labelxs;
12277 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
12281 } else if ( this.fieldLabel.length) {
12288 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
12289 tooltip : 'This field is required',
12290 style : this.allowBlank ? ' display:none' : ''
12294 //cls : 'input-group-addon',
12295 html : this.fieldLabel
12303 if(this.indicatorpos == 'right'){
12308 //cls : 'input-group-addon',
12309 html : this.fieldLabel
12314 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
12315 tooltip : 'This field is required',
12316 style : this.allowBlank ? ' display:none' : ''
12336 if (this.parentType === 'Navbar' && this.parent().bar) {
12337 cfg.cls += ' navbar-form';
12340 if (this.parentType === 'NavGroup' && !(Roo.bootstrap.version == 4 && this.parent().form)) {
12341 // on BS4 we do this only if not form
12342 cfg.cls += ' navbar-form';
12350 * return the real input element.
12352 inputEl: function ()
12354 return this.el.select('input.form-control',true).first();
12357 tooltipEl : function()
12359 return this.inputEl();
12362 indicatorEl : function()
12364 if (Roo.bootstrap.version == 4) {
12365 return false; // not enabled in v4 yet.
12368 var indicator = this.el.select('i.roo-required-indicator',true).first();
12378 setDisabled : function(v)
12380 var i = this.inputEl().dom;
12382 i.removeAttribute('disabled');
12386 i.setAttribute('disabled','true');
12388 initEvents : function()
12391 this.inputEl().on("keydown" , this.fireKey, this);
12392 this.inputEl().on("focus", this.onFocus, this);
12393 this.inputEl().on("blur", this.onBlur, this);
12395 this.inputEl().relayEvent('keyup', this);
12396 this.inputEl().relayEvent('paste', this);
12398 this.indicator = this.indicatorEl();
12400 if(this.indicator){
12401 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible'); // changed from invisible??? -
12404 // reference to original value for reset
12405 this.originalValue = this.getValue();
12406 //Roo.form.TextField.superclass.initEvents.call(this);
12407 if(this.validationEvent == 'keyup'){
12408 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
12409 this.inputEl().on('keyup', this.filterValidation, this);
12411 else if(this.validationEvent !== false){
12412 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
12415 if(this.selectOnFocus){
12416 this.on("focus", this.preFocus, this);
12419 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
12420 this.inputEl().on("keypress", this.filterKeys, this);
12422 this.inputEl().relayEvent('keypress', this);
12425 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
12426 this.el.on("click", this.autoSize, this);
12429 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
12430 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
12433 if (typeof(this.before) == 'object') {
12434 this.before.render(this.el.select('.roo-input-before',true).first());
12436 if (typeof(this.after) == 'object') {
12437 this.after.render(this.el.select('.roo-input-after',true).first());
12440 this.inputEl().on('change', this.onChange, this);
12443 filterValidation : function(e){
12444 if(!e.isNavKeyPress()){
12445 this.validationTask.delay(this.validationDelay);
12449 * Validates the field value
12450 * @return {Boolean} True if the value is valid, else false
12452 validate : function(){
12453 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
12454 if(this.disabled || this.validateValue(this.getRawValue())){
12459 this.markInvalid();
12465 * Validates a value according to the field's validation rules and marks the field as invalid
12466 * if the validation fails
12467 * @param {Mixed} value The value to validate
12468 * @return {Boolean} True if the value is valid, else false
12470 validateValue : function(value)
12472 if(this.getVisibilityEl().hasClass('hidden')){
12476 if(value.length < 1) { // if it's blank
12477 if(this.allowBlank){
12483 if(value.length < this.minLength){
12486 if(value.length > this.maxLength){
12490 var vt = Roo.form.VTypes;
12491 if(!vt[this.vtype](value, this)){
12495 if(typeof this.validator == "function"){
12496 var msg = this.validator(value);
12500 if (typeof(msg) == 'string') {
12501 this.invalidText = msg;
12505 if(this.regex && !this.regex.test(value)){
12513 fireKey : function(e){
12514 //Roo.log('field ' + e.getKey());
12515 if(e.isNavKeyPress()){
12516 this.fireEvent("specialkey", this, e);
12519 focus : function (selectText){
12521 this.inputEl().focus();
12522 if(selectText === true){
12523 this.inputEl().dom.select();
12529 onFocus : function(){
12530 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
12531 // this.el.addClass(this.focusClass);
12533 if(!this.hasFocus){
12534 this.hasFocus = true;
12535 this.startValue = this.getValue();
12536 this.fireEvent("focus", this);
12540 beforeBlur : Roo.emptyFn,
12544 onBlur : function(){
12546 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
12547 //this.el.removeClass(this.focusClass);
12549 this.hasFocus = false;
12550 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
12553 var v = this.getValue();
12554 if(String(v) !== String(this.startValue)){
12555 this.fireEvent('change', this, v, this.startValue);
12557 this.fireEvent("blur", this);
12560 onChange : function(e)
12562 var v = this.getValue();
12563 if(String(v) !== String(this.startValue)){
12564 this.fireEvent('change', this, v, this.startValue);
12570 * Resets the current field value to the originally loaded value and clears any validation messages
12572 reset : function(){
12573 this.setValue(this.originalValue);
12577 * Returns the name of the field
12578 * @return {Mixed} name The name field
12580 getName: function(){
12584 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
12585 * @return {Mixed} value The field value
12587 getValue : function(){
12589 var v = this.inputEl().getValue();
12594 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
12595 * @return {Mixed} value The field value
12597 getRawValue : function(){
12598 var v = this.inputEl().getValue();
12604 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
12605 * @param {Mixed} value The value to set
12607 setRawValue : function(v){
12608 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
12611 selectText : function(start, end){
12612 var v = this.getRawValue();
12614 start = start === undefined ? 0 : start;
12615 end = end === undefined ? v.length : end;
12616 var d = this.inputEl().dom;
12617 if(d.setSelectionRange){
12618 d.setSelectionRange(start, end);
12619 }else if(d.createTextRange){
12620 var range = d.createTextRange();
12621 range.moveStart("character", start);
12622 range.moveEnd("character", v.length-end);
12629 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
12630 * @param {Mixed} value The value to set
12632 setValue : function(v){
12635 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
12641 processValue : function(value){
12642 if(this.stripCharsRe){
12643 var newValue = value.replace(this.stripCharsRe, '');
12644 if(newValue !== value){
12645 this.setRawValue(newValue);
12652 preFocus : function(){
12654 if(this.selectOnFocus){
12655 this.inputEl().dom.select();
12658 filterKeys : function(e){
12659 var k = e.getKey();
12660 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
12663 var c = e.getCharCode(), cc = String.fromCharCode(c);
12664 if(Roo.isIE && (e.isSpecialKey() || !cc)){
12667 if(!this.maskRe.test(cc)){
12672 * Clear any invalid styles/messages for this field
12674 clearInvalid : function(){
12676 if(!this.el || this.preventMark){ // not rendered
12681 this.el.removeClass([this.invalidClass, 'is-invalid']);
12683 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
12685 var feedback = this.el.select('.form-control-feedback', true).first();
12688 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
12693 if(this.indicator){
12694 this.indicator.removeClass('visible');
12695 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
12698 this.fireEvent('valid', this);
12702 * Mark this field as valid
12704 markValid : function()
12706 if(!this.el || this.preventMark){ // not rendered...
12710 this.el.removeClass([this.invalidClass, this.validClass]);
12711 this.inputEl().removeClass(['is-valid', 'is-invalid']);
12713 var feedback = this.el.select('.form-control-feedback', true).first();
12716 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
12719 if(this.indicator){
12720 this.indicator.removeClass('visible');
12721 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
12729 if(this.allowBlank && !this.getRawValue().length){
12732 if (Roo.bootstrap.version == 3) {
12733 this.el.addClass(this.validClass);
12735 this.inputEl().addClass('is-valid');
12738 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
12740 var feedback = this.el.select('.form-control-feedback', true).first();
12743 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
12744 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
12749 this.fireEvent('valid', this);
12753 * Mark this field as invalid
12754 * @param {String} msg The validation message
12756 markInvalid : function(msg)
12758 if(!this.el || this.preventMark){ // not rendered
12762 this.el.removeClass([this.invalidClass, this.validClass]);
12763 this.inputEl().removeClass(['is-valid', 'is-invalid']);
12765 var feedback = this.el.select('.form-control-feedback', true).first();
12768 this.el.select('.form-control-feedback', true).first().removeClass(
12769 [this.invalidFeedbackClass, this.validFeedbackClass]);
12776 if(this.allowBlank && !this.getRawValue().length){
12780 if(this.indicator){
12781 this.indicator.removeClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
12782 this.indicator.addClass('visible');
12784 if (Roo.bootstrap.version == 3) {
12785 this.el.addClass(this.invalidClass);
12787 this.inputEl().addClass('is-invalid');
12792 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
12794 var feedback = this.el.select('.form-control-feedback', true).first();
12797 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
12799 if(this.getValue().length || this.forceFeedback){
12800 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
12807 this.fireEvent('invalid', this, msg);
12810 SafariOnKeyDown : function(event)
12812 // this is a workaround for a password hang bug on chrome/ webkit.
12813 if (this.inputEl().dom.type != 'password') {
12817 var isSelectAll = false;
12819 if(this.inputEl().dom.selectionEnd > 0){
12820 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
12822 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
12823 event.preventDefault();
12828 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
12830 event.preventDefault();
12831 // this is very hacky as keydown always get's upper case.
12833 var cc = String.fromCharCode(event.getCharCode());
12834 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
12838 adjustWidth : function(tag, w){
12839 tag = tag.toLowerCase();
12840 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
12841 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
12842 if(tag == 'input'){
12845 if(tag == 'textarea'){
12848 }else if(Roo.isOpera){
12849 if(tag == 'input'){
12852 if(tag == 'textarea'){
12860 setFieldLabel : function(v)
12862 if(!this.rendered){
12866 if(this.indicatorEl()){
12867 var ar = this.el.select('label > span',true);
12869 if (ar.elements.length) {
12870 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
12871 this.fieldLabel = v;
12875 var br = this.el.select('label',true);
12877 if(br.elements.length) {
12878 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
12879 this.fieldLabel = v;
12883 Roo.log('Cannot Found any of label > span || label in input');
12887 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
12888 this.fieldLabel = v;
12903 * @class Roo.bootstrap.TextArea
12904 * @extends Roo.bootstrap.Input
12905 * Bootstrap TextArea class
12906 * @cfg {Number} cols Specifies the visible width of a text area
12907 * @cfg {Number} rows Specifies the visible number of lines in a text area
12908 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
12909 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
12910 * @cfg {string} html text
12913 * Create a new TextArea
12914 * @param {Object} config The config object
12917 Roo.bootstrap.TextArea = function(config){
12918 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
12922 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
12932 getAutoCreate : function(){
12934 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
12940 if(this.inputType != 'hidden'){
12941 cfg.cls = 'form-group' //input-group
12949 value : this.value || '',
12950 html: this.html || '',
12951 cls : 'form-control',
12952 placeholder : this.placeholder || ''
12956 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
12957 input.maxLength = this.maxLength;
12961 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
12965 input.cols = this.cols;
12968 if (this.readOnly) {
12969 input.readonly = true;
12973 input.name = this.name;
12977 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
12981 ['xs','sm','md','lg'].map(function(size){
12982 if (settings[size]) {
12983 cfg.cls += ' col-' + size + '-' + settings[size];
12987 var inputblock = input;
12989 if(this.hasFeedback && !this.allowBlank){
12993 cls: 'glyphicon form-control-feedback'
12997 cls : 'has-feedback',
13006 if (this.before || this.after) {
13009 cls : 'input-group',
13013 inputblock.cn.push({
13015 cls : 'input-group-addon',
13020 inputblock.cn.push(input);
13022 if(this.hasFeedback && !this.allowBlank){
13023 inputblock.cls += ' has-feedback';
13024 inputblock.cn.push(feedback);
13028 inputblock.cn.push({
13030 cls : 'input-group-addon',
13037 if (align ==='left' && this.fieldLabel.length) {
13042 cls : 'control-label',
13043 html : this.fieldLabel
13054 if(this.labelWidth > 12){
13055 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
13058 if(this.labelWidth < 13 && this.labelmd == 0){
13059 this.labelmd = this.labelWidth;
13062 if(this.labellg > 0){
13063 cfg.cn[0].cls += ' col-lg-' + this.labellg;
13064 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
13067 if(this.labelmd > 0){
13068 cfg.cn[0].cls += ' col-md-' + this.labelmd;
13069 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
13072 if(this.labelsm > 0){
13073 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
13074 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
13077 if(this.labelxs > 0){
13078 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
13079 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
13082 } else if ( this.fieldLabel.length) {
13087 //cls : 'input-group-addon',
13088 html : this.fieldLabel
13106 if (this.disabled) {
13107 input.disabled=true;
13114 * return the real textarea element.
13116 inputEl: function ()
13118 return this.el.select('textarea.form-control',true).first();
13122 * Clear any invalid styles/messages for this field
13124 clearInvalid : function()
13127 if(!this.el || this.preventMark){ // not rendered
13131 var label = this.el.select('label', true).first();
13132 var icon = this.el.select('i.fa-star', true).first();
13137 this.el.removeClass( this.validClass);
13138 this.inputEl().removeClass('is-invalid');
13140 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
13142 var feedback = this.el.select('.form-control-feedback', true).first();
13145 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
13150 this.fireEvent('valid', this);
13154 * Mark this field as valid
13156 markValid : function()
13158 if(!this.el || this.preventMark){ // not rendered
13162 this.el.removeClass([this.invalidClass, this.validClass]);
13163 this.inputEl().removeClass(['is-valid', 'is-invalid']);
13165 var feedback = this.el.select('.form-control-feedback', true).first();
13168 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13171 if(this.disabled || this.allowBlank){
13175 var label = this.el.select('label', true).first();
13176 var icon = this.el.select('i.fa-star', true).first();
13181 if (Roo.bootstrap.version == 3) {
13182 this.el.addClass(this.validClass);
13184 this.inputEl().addClass('is-valid');
13188 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
13190 var feedback = this.el.select('.form-control-feedback', true).first();
13193 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13194 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
13199 this.fireEvent('valid', this);
13203 * Mark this field as invalid
13204 * @param {String} msg The validation message
13206 markInvalid : function(msg)
13208 if(!this.el || this.preventMark){ // not rendered
13212 this.el.removeClass([this.invalidClass, this.validClass]);
13213 this.inputEl().removeClass(['is-valid', 'is-invalid']);
13215 var feedback = this.el.select('.form-control-feedback', true).first();
13218 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13221 if(this.disabled || this.allowBlank){
13225 var label = this.el.select('label', true).first();
13226 var icon = this.el.select('i.fa-star', true).first();
13228 if(!this.getValue().length && label && !icon){
13229 this.el.createChild({
13231 cls : 'text-danger fa fa-lg fa-star',
13232 tooltip : 'This field is required',
13233 style : 'margin-right:5px;'
13237 if (Roo.bootstrap.version == 3) {
13238 this.el.addClass(this.invalidClass);
13240 this.inputEl().addClass('is-invalid');
13243 // fixme ... this may be depricated need to test..
13244 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
13246 var feedback = this.el.select('.form-control-feedback', true).first();
13249 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13251 if(this.getValue().length || this.forceFeedback){
13252 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
13259 this.fireEvent('invalid', this, msg);
13267 * trigger field - base class for combo..
13272 * @class Roo.bootstrap.TriggerField
13273 * @extends Roo.bootstrap.Input
13274 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
13275 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
13276 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
13277 * for which you can provide a custom implementation. For example:
13279 var trigger = new Roo.bootstrap.TriggerField();
13280 trigger.onTriggerClick = myTriggerFn;
13281 trigger.applyTo('my-field');
13284 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
13285 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
13286 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
13287 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
13288 * @cfg {String} caret (search|calendar) BS3 only - carat fa name
13291 * Create a new TriggerField.
13292 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
13293 * to the base TextField)
13295 Roo.bootstrap.TriggerField = function(config){
13296 this.mimicing = false;
13297 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
13300 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
13302 * @cfg {String} triggerClass A CSS class to apply to the trigger
13305 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
13310 * @cfg {Boolean} removable (true|false) special filter default false
13314 /** @cfg {Boolean} grow @hide */
13315 /** @cfg {Number} growMin @hide */
13316 /** @cfg {Number} growMax @hide */
13322 autoSize: Roo.emptyFn,
13326 deferHeight : true,
13329 actionMode : 'wrap',
13334 getAutoCreate : function(){
13336 var align = this.labelAlign || this.parentLabelAlign();
13341 cls: 'form-group' //input-group
13348 type : this.inputType,
13349 cls : 'form-control',
13350 autocomplete: 'new-password',
13351 placeholder : this.placeholder || ''
13355 input.name = this.name;
13358 input.cls += ' input-' + this.size;
13361 if (this.disabled) {
13362 input.disabled=true;
13365 var inputblock = input;
13367 if(this.hasFeedback && !this.allowBlank){
13371 cls: 'glyphicon form-control-feedback'
13374 if(this.removable && !this.editable ){
13376 cls : 'has-feedback',
13382 cls : 'roo-combo-removable-btn close'
13389 cls : 'has-feedback',
13398 if(this.removable && !this.editable ){
13400 cls : 'roo-removable',
13406 cls : 'roo-combo-removable-btn close'
13413 if (this.before || this.after) {
13416 cls : 'input-group',
13420 inputblock.cn.push({
13422 cls : 'input-group-addon input-group-prepend input-group-text',
13427 inputblock.cn.push(input);
13429 if(this.hasFeedback && !this.allowBlank){
13430 inputblock.cls += ' has-feedback';
13431 inputblock.cn.push(feedback);
13435 inputblock.cn.push({
13437 cls : 'input-group-addon input-group-append input-group-text',
13446 var ibwrap = inputblock;
13451 cls: 'roo-select2-choices',
13455 cls: 'roo-select2-search-field',
13467 cls: 'roo-select2-container input-group',
13472 cls: 'form-hidden-field'
13478 if(!this.multiple && this.showToggleBtn){
13484 if (this.caret != false) {
13487 cls: 'fa fa-' + this.caret
13494 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
13496 Roo.bootstrap.version == 3 ? caret : '',
13499 cls: 'combobox-clear',
13513 combobox.cls += ' roo-select2-container-multi';
13517 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
13518 tooltip : 'This field is required'
13520 if (Roo.bootstrap.version == 4) {
13523 style : 'display:none'
13528 if (align ==='left' && this.fieldLabel.length) {
13530 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
13537 cls : 'control-label',
13538 html : this.fieldLabel
13550 var labelCfg = cfg.cn[1];
13551 var contentCfg = cfg.cn[2];
13553 if(this.indicatorpos == 'right'){
13558 cls : 'control-label',
13562 html : this.fieldLabel
13576 labelCfg = cfg.cn[0];
13577 contentCfg = cfg.cn[1];
13580 if(this.labelWidth > 12){
13581 labelCfg.style = "width: " + this.labelWidth + 'px';
13584 if(this.labelWidth < 13 && this.labelmd == 0){
13585 this.labelmd = this.labelWidth;
13588 if(this.labellg > 0){
13589 labelCfg.cls += ' col-lg-' + this.labellg;
13590 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
13593 if(this.labelmd > 0){
13594 labelCfg.cls += ' col-md-' + this.labelmd;
13595 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
13598 if(this.labelsm > 0){
13599 labelCfg.cls += ' col-sm-' + this.labelsm;
13600 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
13603 if(this.labelxs > 0){
13604 labelCfg.cls += ' col-xs-' + this.labelxs;
13605 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
13608 } else if ( this.fieldLabel.length) {
13609 // Roo.log(" label");
13614 //cls : 'input-group-addon',
13615 html : this.fieldLabel
13623 if(this.indicatorpos == 'right'){
13631 html : this.fieldLabel
13645 // Roo.log(" no label && no align");
13652 ['xs','sm','md','lg'].map(function(size){
13653 if (settings[size]) {
13654 cfg.cls += ' col-' + size + '-' + settings[size];
13665 onResize : function(w, h){
13666 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
13667 // if(typeof w == 'number'){
13668 // var x = w - this.trigger.getWidth();
13669 // this.inputEl().setWidth(this.adjustWidth('input', x));
13670 // this.trigger.setStyle('left', x+'px');
13675 adjustSize : Roo.BoxComponent.prototype.adjustSize,
13678 getResizeEl : function(){
13679 return this.inputEl();
13683 getPositionEl : function(){
13684 return this.inputEl();
13688 alignErrorIcon : function(){
13689 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
13693 initEvents : function(){
13697 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
13698 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
13699 if(!this.multiple && this.showToggleBtn){
13700 this.trigger = this.el.select('span.dropdown-toggle',true).first();
13701 if(this.hideTrigger){
13702 this.trigger.setDisplayed(false);
13704 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
13708 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
13711 if(this.removable && !this.editable && !this.tickable){
13712 var close = this.closeTriggerEl();
13715 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
13716 close.on('click', this.removeBtnClick, this, close);
13720 //this.trigger.addClassOnOver('x-form-trigger-over');
13721 //this.trigger.addClassOnClick('x-form-trigger-click');
13724 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
13728 closeTriggerEl : function()
13730 var close = this.el.select('.roo-combo-removable-btn', true).first();
13731 return close ? close : false;
13734 removeBtnClick : function(e, h, el)
13736 e.preventDefault();
13738 if(this.fireEvent("remove", this) !== false){
13740 this.fireEvent("afterremove", this)
13744 createList : function()
13746 this.list = Roo.get(document.body).createChild({
13747 tag: Roo.bootstrap.version == 4 ? 'div' : 'ul',
13748 cls: 'typeahead typeahead-long dropdown-menu shadow',
13749 style: 'display:none'
13752 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
13757 initTrigger : function(){
13762 onDestroy : function(){
13764 this.trigger.removeAllListeners();
13765 // this.trigger.remove();
13768 // this.wrap.remove();
13770 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
13774 onFocus : function(){
13775 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
13777 if(!this.mimicing){
13778 this.wrap.addClass('x-trigger-wrap-focus');
13779 this.mimicing = true;
13780 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
13781 if(this.monitorTab){
13782 this.el.on("keydown", this.checkTab, this);
13789 checkTab : function(e){
13790 if(e.getKey() == e.TAB){
13791 this.triggerBlur();
13796 onBlur : function(){
13801 mimicBlur : function(e, t){
13803 if(!this.wrap.contains(t) && this.validateBlur()){
13804 this.triggerBlur();
13810 triggerBlur : function(){
13811 this.mimicing = false;
13812 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
13813 if(this.monitorTab){
13814 this.el.un("keydown", this.checkTab, this);
13816 //this.wrap.removeClass('x-trigger-wrap-focus');
13817 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
13821 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
13822 validateBlur : function(e, t){
13827 onDisable : function(){
13828 this.inputEl().dom.disabled = true;
13829 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
13831 // this.wrap.addClass('x-item-disabled');
13836 onEnable : function(){
13837 this.inputEl().dom.disabled = false;
13838 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
13840 // this.el.removeClass('x-item-disabled');
13845 onShow : function(){
13846 var ae = this.getActionEl();
13849 ae.dom.style.display = '';
13850 ae.dom.style.visibility = 'visible';
13856 onHide : function(){
13857 var ae = this.getActionEl();
13858 ae.dom.style.display = 'none';
13862 * The function that should handle the trigger's click event. This method does nothing by default until overridden
13863 * by an implementing function.
13865 * @param {EventObject} e
13867 onTriggerClick : Roo.emptyFn
13875 * @class Roo.bootstrap.CardUploader
13876 * @extends Roo.bootstrap.Button
13877 * Bootstrap Card Uploader class - it's a button which when you add files to it, adds cards below with preview and the name...
13878 * @cfg {Number} errorTimeout default 3000
13879 * @cfg {Array} images an array of ?? Img objects ??? when loading existing files..
13880 * @cfg {Array} html The button text.
13884 * Create a new CardUploader
13885 * @param {Object} config The config object
13888 Roo.bootstrap.CardUploader = function(config){
13892 Roo.bootstrap.CardUploader.superclass.constructor.call(this, config);
13895 this.fileCollection = new Roo.util.MixedCollection(false,function(r) {
13903 * When a image is clicked on - and needs to display a slideshow or similar..
13904 * @param {Roo.bootstrap.Card} this
13905 * @param {Object} The image information data
13911 * When a the download link is clicked
13912 * @param {Roo.bootstrap.Card} this
13913 * @param {Object} The image information data contains
13920 Roo.extend(Roo.bootstrap.CardUploader, Roo.bootstrap.Input, {
13923 errorTimeout : 3000,
13927 fileCollection : false,
13930 getAutoCreate : function()
13934 cls :'form-group' ,
13939 //cls : 'input-group-addon',
13940 html : this.fieldLabel
13948 value : this.value,
13949 cls : 'd-none form-control'
13954 multiple : 'multiple',
13956 cls : 'd-none roo-card-upload-selector'
13960 cls : 'roo-card-uploader-button-container w-100 mb-2'
13963 cls : 'card-columns roo-card-uploader-container'
13973 getChildContainer : function() /// what children are added to.
13975 return this.containerEl;
13978 getButtonContainer : function() /// what children are added to.
13980 return this.el.select(".roo-card-uploader-button-container").first();
13983 initEvents : function()
13986 Roo.bootstrap.Input.prototype.initEvents.call(this);
13990 xns: Roo.bootstrap,
13993 container_method : 'getButtonContainer' ,
13994 html : this.html, // fix changable?
13997 'click' : function(btn, e) {
14006 this.urlAPI = (window.createObjectURL && window) ||
14007 (window.URL && URL.revokeObjectURL && URL) ||
14008 (window.webkitURL && webkitURL);
14013 this.selectorEl = this.el.select('.roo-card-upload-selector', true).first();
14015 this.selectorEl.on('change', this.onFileSelected, this);
14018 this.images.forEach(function(img) {
14021 this.images = false;
14023 this.containerEl = this.el.select('.roo-card-uploader-container', true).first();
14029 onClick : function(e)
14031 e.preventDefault();
14033 this.selectorEl.dom.click();
14037 onFileSelected : function(e)
14039 e.preventDefault();
14041 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
14045 Roo.each(this.selectorEl.dom.files, function(file){
14046 this.addFile(file);
14055 addFile : function(file)
14058 if(typeof(file) === 'string'){
14059 throw "Add file by name?"; // should not happen
14063 if(!file || !this.urlAPI){
14073 var url = _this.urlAPI.createObjectURL( file);
14076 id : Roo.bootstrap.CardUploader.ID--,
14077 is_uploaded : false,
14081 mimetype : file.type,
14089 * addCard - add an Attachment to the uploader
14090 * @param data - the data about the image to upload
14094 title : "Title of file",
14095 is_uploaded : false,
14096 src : "http://.....",
14097 srcfile : { the File upload object },
14098 mimetype : file.type,
14101 .. any other data...
14107 addCard : function (data)
14109 // hidden input element?
14110 // if the file is not an image...
14111 //then we need to use something other that and header_image
14116 xns : Roo.bootstrap,
14117 xtype : 'CardFooter',
14120 xns : Roo.bootstrap,
14126 xns : Roo.bootstrap,
14128 html : String.format("<small>{0}</small>", data.title),
14129 cls : 'col-10 text-left',
14134 click : function() {
14136 t.fireEvent( "download", t, data );
14142 xns : Roo.bootstrap,
14144 style: 'max-height: 28px; ',
14150 click : function() {
14151 t.removeCard(data.id)
14163 var cn = this.addxtype(
14166 xns : Roo.bootstrap,
14169 header : !data.mimetype.match(/image/) && !data.preview ? "Document": false,
14170 header_image : data.mimetype.match(/image/) ? data.src : data.preview,
14171 header_image_fit_square: true, // fixme - we probably need to use the 'Img' element to do stuff like this.
14176 initEvents : function() {
14177 Roo.bootstrap.Card.prototype.initEvents.call(this);
14179 this.imgEl = this.el.select('.card-img-top').first();
14181 this.imgEl.on('click', function() { t.fireEvent( "preview", t, data ); }, this);
14182 this.imgEl.set({ 'pointer' : 'cursor' });
14185 this.getCardFooter().addClass('p-1');
14192 // dont' really need ot update items.
14193 // this.items.push(cn);
14194 this.fileCollection.add(cn);
14196 if (!data.srcfile) {
14197 this.updateInput();
14202 var reader = new FileReader();
14203 reader.addEventListener("load", function() {
14204 data.srcdata = reader.result;
14207 reader.readAsDataURL(data.srcfile);
14212 removeCard : function(id)
14215 var card = this.fileCollection.get(id);
14216 card.data.is_deleted = 1;
14217 card.data.src = ''; /// delete the source - so it reduces size of not uploaded images etc.
14218 //this.fileCollection.remove(card);
14219 //this.items = this.items.filter(function(e) { return e != card });
14220 // dont' really need ot update items.
14221 card.el.dom.parentNode.removeChild(card.el.dom);
14222 this.updateInput();
14228 this.fileCollection.each(function(card) {
14229 if (card.el.dom && card.el.dom.parentNode) {
14230 card.el.dom.parentNode.removeChild(card.el.dom);
14233 this.fileCollection.clear();
14234 this.updateInput();
14237 updateInput : function()
14240 this.fileCollection.each(function(e) {
14244 this.inputEl().dom.value = JSON.stringify(data);
14254 Roo.bootstrap.CardUploader.ID = -1;/*
14256 * Ext JS Library 1.1.1
14257 * Copyright(c) 2006-2007, Ext JS, LLC.
14259 * Originally Released Under LGPL - original licence link has changed is not relivant.
14262 * <script type="text/javascript">
14267 * @class Roo.data.SortTypes
14269 * Defines the default sorting (casting?) comparison functions used when sorting data.
14271 Roo.data.SortTypes = {
14273 * Default sort that does nothing
14274 * @param {Mixed} s The value being converted
14275 * @return {Mixed} The comparison value
14277 none : function(s){
14282 * The regular expression used to strip tags
14286 stripTagsRE : /<\/?[^>]+>/gi,
14289 * Strips all HTML tags to sort on text only
14290 * @param {Mixed} s The value being converted
14291 * @return {String} The comparison value
14293 asText : function(s){
14294 return String(s).replace(this.stripTagsRE, "");
14298 * Strips all HTML tags to sort on text only - Case insensitive
14299 * @param {Mixed} s The value being converted
14300 * @return {String} The comparison value
14302 asUCText : function(s){
14303 return String(s).toUpperCase().replace(this.stripTagsRE, "");
14307 * Case insensitive string
14308 * @param {Mixed} s The value being converted
14309 * @return {String} The comparison value
14311 asUCString : function(s) {
14312 return String(s).toUpperCase();
14317 * @param {Mixed} s The value being converted
14318 * @return {Number} The comparison value
14320 asDate : function(s) {
14324 if(s instanceof Date){
14325 return s.getTime();
14327 return Date.parse(String(s));
14332 * @param {Mixed} s The value being converted
14333 * @return {Float} The comparison value
14335 asFloat : function(s) {
14336 var val = parseFloat(String(s).replace(/,/g, ""));
14345 * @param {Mixed} s The value being converted
14346 * @return {Number} The comparison value
14348 asInt : function(s) {
14349 var val = parseInt(String(s).replace(/,/g, ""));
14357 * Ext JS Library 1.1.1
14358 * Copyright(c) 2006-2007, Ext JS, LLC.
14360 * Originally Released Under LGPL - original licence link has changed is not relivant.
14363 * <script type="text/javascript">
14367 * @class Roo.data.Record
14368 * Instances of this class encapsulate both record <em>definition</em> information, and record
14369 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
14370 * to access Records cached in an {@link Roo.data.Store} object.<br>
14372 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
14373 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
14376 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
14378 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
14379 * {@link #create}. The parameters are the same.
14380 * @param {Array} data An associative Array of data values keyed by the field name.
14381 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
14382 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
14383 * not specified an integer id is generated.
14385 Roo.data.Record = function(data, id){
14386 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
14391 * Generate a constructor for a specific record layout.
14392 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
14393 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
14394 * Each field definition object may contain the following properties: <ul>
14395 * <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,
14396 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
14397 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
14398 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
14399 * is being used, then this is a string containing the javascript expression to reference the data relative to
14400 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
14401 * to the data item relative to the record element. If the mapping expression is the same as the field name,
14402 * this may be omitted.</p></li>
14403 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
14404 * <ul><li>auto (Default, implies no conversion)</li>
14409 * <li>date</li></ul></p></li>
14410 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
14411 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
14412 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
14413 * by the Reader into an object that will be stored in the Record. It is passed the
14414 * following parameters:<ul>
14415 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
14417 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
14419 * <br>usage:<br><pre><code>
14420 var TopicRecord = Roo.data.Record.create(
14421 {name: 'title', mapping: 'topic_title'},
14422 {name: 'author', mapping: 'username'},
14423 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
14424 {name: 'lastPost', mapping: 'post_time', type: 'date'},
14425 {name: 'lastPoster', mapping: 'user2'},
14426 {name: 'excerpt', mapping: 'post_text'}
14429 var myNewRecord = new TopicRecord({
14430 title: 'Do my job please',
14433 lastPost: new Date(),
14434 lastPoster: 'Animal',
14435 excerpt: 'No way dude!'
14437 myStore.add(myNewRecord);
14442 Roo.data.Record.create = function(o){
14443 var f = function(){
14444 f.superclass.constructor.apply(this, arguments);
14446 Roo.extend(f, Roo.data.Record);
14447 var p = f.prototype;
14448 p.fields = new Roo.util.MixedCollection(false, function(field){
14451 for(var i = 0, len = o.length; i < len; i++){
14452 p.fields.add(new Roo.data.Field(o[i]));
14454 f.getField = function(name){
14455 return p.fields.get(name);
14460 Roo.data.Record.AUTO_ID = 1000;
14461 Roo.data.Record.EDIT = 'edit';
14462 Roo.data.Record.REJECT = 'reject';
14463 Roo.data.Record.COMMIT = 'commit';
14465 Roo.data.Record.prototype = {
14467 * Readonly flag - true if this record has been modified.
14476 join : function(store){
14477 this.store = store;
14481 * Set the named field to the specified value.
14482 * @param {String} name The name of the field to set.
14483 * @param {Object} value The value to set the field to.
14485 set : function(name, value){
14486 if(this.data[name] == value){
14490 if(!this.modified){
14491 this.modified = {};
14493 if(typeof this.modified[name] == 'undefined'){
14494 this.modified[name] = this.data[name];
14496 this.data[name] = value;
14497 if(!this.editing && this.store){
14498 this.store.afterEdit(this);
14503 * Get the value of the named field.
14504 * @param {String} name The name of the field to get the value of.
14505 * @return {Object} The value of the field.
14507 get : function(name){
14508 return this.data[name];
14512 beginEdit : function(){
14513 this.editing = true;
14514 this.modified = {};
14518 cancelEdit : function(){
14519 this.editing = false;
14520 delete this.modified;
14524 endEdit : function(){
14525 this.editing = false;
14526 if(this.dirty && this.store){
14527 this.store.afterEdit(this);
14532 * Usually called by the {@link Roo.data.Store} which owns the Record.
14533 * Rejects all changes made to the Record since either creation, or the last commit operation.
14534 * Modified fields are reverted to their original values.
14536 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
14537 * of reject operations.
14539 reject : function(){
14540 var m = this.modified;
14542 if(typeof m[n] != "function"){
14543 this.data[n] = m[n];
14546 this.dirty = false;
14547 delete this.modified;
14548 this.editing = false;
14550 this.store.afterReject(this);
14555 * Usually called by the {@link Roo.data.Store} which owns the Record.
14556 * Commits all changes made to the Record since either creation, or the last commit operation.
14558 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
14559 * of commit operations.
14561 commit : function(){
14562 this.dirty = false;
14563 delete this.modified;
14564 this.editing = false;
14566 this.store.afterCommit(this);
14571 hasError : function(){
14572 return this.error != null;
14576 clearError : function(){
14581 * Creates a copy of this record.
14582 * @param {String} id (optional) A new record id if you don't want to use this record's id
14585 copy : function(newId) {
14586 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
14590 * Ext JS Library 1.1.1
14591 * Copyright(c) 2006-2007, Ext JS, LLC.
14593 * Originally Released Under LGPL - original licence link has changed is not relivant.
14596 * <script type="text/javascript">
14602 * @class Roo.data.Store
14603 * @extends Roo.util.Observable
14604 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
14605 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
14607 * 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
14608 * has no knowledge of the format of the data returned by the Proxy.<br>
14610 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
14611 * instances from the data object. These records are cached and made available through accessor functions.
14613 * Creates a new Store.
14614 * @param {Object} config A config object containing the objects needed for the Store to access data,
14615 * and read the data into Records.
14617 Roo.data.Store = function(config){
14618 this.data = new Roo.util.MixedCollection(false);
14619 this.data.getKey = function(o){
14622 this.baseParams = {};
14624 this.paramNames = {
14629 "multisort" : "_multisort"
14632 if(config && config.data){
14633 this.inlineData = config.data;
14634 delete config.data;
14637 Roo.apply(this, config);
14639 if(this.reader){ // reader passed
14640 this.reader = Roo.factory(this.reader, Roo.data);
14641 this.reader.xmodule = this.xmodule || false;
14642 if(!this.recordType){
14643 this.recordType = this.reader.recordType;
14645 if(this.reader.onMetaChange){
14646 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
14650 if(this.recordType){
14651 this.fields = this.recordType.prototype.fields;
14653 this.modified = [];
14657 * @event datachanged
14658 * Fires when the data cache has changed, and a widget which is using this Store
14659 * as a Record cache should refresh its view.
14660 * @param {Store} this
14662 datachanged : true,
14664 * @event metachange
14665 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
14666 * @param {Store} this
14667 * @param {Object} meta The JSON metadata
14672 * Fires when Records have been added to the Store
14673 * @param {Store} this
14674 * @param {Roo.data.Record[]} records The array of Records added
14675 * @param {Number} index The index at which the record(s) were added
14680 * Fires when a Record has been removed from the Store
14681 * @param {Store} this
14682 * @param {Roo.data.Record} record The Record that was removed
14683 * @param {Number} index The index at which the record was removed
14688 * Fires when a Record has been updated
14689 * @param {Store} this
14690 * @param {Roo.data.Record} record The Record that was updated
14691 * @param {String} operation The update operation being performed. Value may be one of:
14693 Roo.data.Record.EDIT
14694 Roo.data.Record.REJECT
14695 Roo.data.Record.COMMIT
14701 * Fires when the data cache has been cleared.
14702 * @param {Store} this
14706 * @event beforeload
14707 * Fires before a request is made for a new data object. If the beforeload handler returns false
14708 * the load action will be canceled.
14709 * @param {Store} this
14710 * @param {Object} options The loading options that were specified (see {@link #load} for details)
14714 * @event beforeloadadd
14715 * Fires after a new set of Records has been loaded.
14716 * @param {Store} this
14717 * @param {Roo.data.Record[]} records The Records that were loaded
14718 * @param {Object} options The loading options that were specified (see {@link #load} for details)
14720 beforeloadadd : true,
14723 * Fires after a new set of Records has been loaded, before they are added to the store.
14724 * @param {Store} this
14725 * @param {Roo.data.Record[]} records The Records that were loaded
14726 * @param {Object} options The loading options that were specified (see {@link #load} for details)
14727 * @params {Object} return from reader
14731 * @event loadexception
14732 * Fires if an exception occurs in the Proxy during loading.
14733 * Called with the signature of the Proxy's "loadexception" event.
14734 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
14737 * @param {Object} return from JsonData.reader() - success, totalRecords, records
14738 * @param {Object} load options
14739 * @param {Object} jsonData from your request (normally this contains the Exception)
14741 loadexception : true
14745 this.proxy = Roo.factory(this.proxy, Roo.data);
14746 this.proxy.xmodule = this.xmodule || false;
14747 this.relayEvents(this.proxy, ["loadexception"]);
14749 this.sortToggle = {};
14750 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
14752 Roo.data.Store.superclass.constructor.call(this);
14754 if(this.inlineData){
14755 this.loadData(this.inlineData);
14756 delete this.inlineData;
14760 Roo.extend(Roo.data.Store, Roo.util.Observable, {
14762 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
14763 * without a remote query - used by combo/forms at present.
14767 * @cfg {Roo.data.DataProxy} proxy [required] The Proxy object which provides access to a data object.
14770 * @cfg {Array} data Inline data to be loaded when the store is initialized.
14773 * @cfg {Roo.data.DataReader} reader [required] The Reader object which processes the data object and returns
14774 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
14777 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
14778 * on any HTTP request
14781 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
14784 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
14788 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
14789 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
14791 remoteSort : false,
14794 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
14795 * loaded or when a record is removed. (defaults to false).
14797 pruneModifiedRecords : false,
14800 lastOptions : null,
14803 * Add Records to the Store and fires the add event.
14804 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
14806 add : function(records){
14807 records = [].concat(records);
14808 for(var i = 0, len = records.length; i < len; i++){
14809 records[i].join(this);
14811 var index = this.data.length;
14812 this.data.addAll(records);
14813 this.fireEvent("add", this, records, index);
14817 * Remove a Record from the Store and fires the remove event.
14818 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
14820 remove : function(record){
14821 var index = this.data.indexOf(record);
14822 this.data.removeAt(index);
14824 if(this.pruneModifiedRecords){
14825 this.modified.remove(record);
14827 this.fireEvent("remove", this, record, index);
14831 * Remove all Records from the Store and fires the clear event.
14833 removeAll : function(){
14835 if(this.pruneModifiedRecords){
14836 this.modified = [];
14838 this.fireEvent("clear", this);
14842 * Inserts Records to the Store at the given index and fires the add event.
14843 * @param {Number} index The start index at which to insert the passed Records.
14844 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
14846 insert : function(index, records){
14847 records = [].concat(records);
14848 for(var i = 0, len = records.length; i < len; i++){
14849 this.data.insert(index, records[i]);
14850 records[i].join(this);
14852 this.fireEvent("add", this, records, index);
14856 * Get the index within the cache of the passed Record.
14857 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
14858 * @return {Number} The index of the passed Record. Returns -1 if not found.
14860 indexOf : function(record){
14861 return this.data.indexOf(record);
14865 * Get the index within the cache of the Record with the passed id.
14866 * @param {String} id The id of the Record to find.
14867 * @return {Number} The index of the Record. Returns -1 if not found.
14869 indexOfId : function(id){
14870 return this.data.indexOfKey(id);
14874 * Get the Record with the specified id.
14875 * @param {String} id The id of the Record to find.
14876 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
14878 getById : function(id){
14879 return this.data.key(id);
14883 * Get the Record at the specified index.
14884 * @param {Number} index The index of the Record to find.
14885 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
14887 getAt : function(index){
14888 return this.data.itemAt(index);
14892 * Returns a range of Records between specified indices.
14893 * @param {Number} startIndex (optional) The starting index (defaults to 0)
14894 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
14895 * @return {Roo.data.Record[]} An array of Records
14897 getRange : function(start, end){
14898 return this.data.getRange(start, end);
14902 storeOptions : function(o){
14903 o = Roo.apply({}, o);
14906 this.lastOptions = o;
14910 * Loads the Record cache from the configured Proxy using the configured Reader.
14912 * If using remote paging, then the first load call must specify the <em>start</em>
14913 * and <em>limit</em> properties in the options.params property to establish the initial
14914 * position within the dataset, and the number of Records to cache on each read from the Proxy.
14916 * <strong>It is important to note that for remote data sources, loading is asynchronous,
14917 * and this call will return before the new data has been loaded. Perform any post-processing
14918 * in a callback function, or in a "load" event handler.</strong>
14920 * @param {Object} options An object containing properties which control loading options:<ul>
14921 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
14922 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
14923 * passed the following arguments:<ul>
14924 * <li>r : Roo.data.Record[]</li>
14925 * <li>options: Options object from the load call</li>
14926 * <li>success: Boolean success indicator</li></ul></li>
14927 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
14928 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
14931 load : function(options){
14932 options = options || {};
14933 if(this.fireEvent("beforeload", this, options) !== false){
14934 this.storeOptions(options);
14935 var p = Roo.apply(options.params || {}, this.baseParams);
14936 // if meta was not loaded from remote source.. try requesting it.
14937 if (!this.reader.metaFromRemote) {
14938 p._requestMeta = 1;
14940 if(this.sortInfo && this.remoteSort){
14941 var pn = this.paramNames;
14942 p[pn["sort"]] = this.sortInfo.field;
14943 p[pn["dir"]] = this.sortInfo.direction;
14945 if (this.multiSort) {
14946 var pn = this.paramNames;
14947 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
14950 this.proxy.load(p, this.reader, this.loadRecords, this, options);
14955 * Reloads the Record cache from the configured Proxy using the configured Reader and
14956 * the options from the last load operation performed.
14957 * @param {Object} options (optional) An object containing properties which may override the options
14958 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
14959 * the most recently used options are reused).
14961 reload : function(options){
14962 this.load(Roo.applyIf(options||{}, this.lastOptions));
14966 // Called as a callback by the Reader during a load operation.
14967 loadRecords : function(o, options, success){
14968 if(!o || success === false){
14969 if(success !== false){
14970 this.fireEvent("load", this, [], options, o);
14972 if(options.callback){
14973 options.callback.call(options.scope || this, [], options, false);
14977 // if data returned failure - throw an exception.
14978 if (o.success === false) {
14979 // show a message if no listener is registered.
14980 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
14981 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
14983 // loadmask wil be hooked into this..
14984 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
14987 var r = o.records, t = o.totalRecords || r.length;
14989 this.fireEvent("beforeloadadd", this, r, options, o);
14991 if(!options || options.add !== true){
14992 if(this.pruneModifiedRecords){
14993 this.modified = [];
14995 for(var i = 0, len = r.length; i < len; i++){
14999 this.data = this.snapshot;
15000 delete this.snapshot;
15003 this.data.addAll(r);
15004 this.totalLength = t;
15006 this.fireEvent("datachanged", this);
15008 this.totalLength = Math.max(t, this.data.length+r.length);
15012 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
15014 var e = new Roo.data.Record({});
15016 e.set(this.parent.displayField, this.parent.emptyTitle);
15017 e.set(this.parent.valueField, '');
15022 this.fireEvent("load", this, r, options, o);
15023 if(options.callback){
15024 options.callback.call(options.scope || this, r, options, true);
15030 * Loads data from a passed data block. A Reader which understands the format of the data
15031 * must have been configured in the constructor.
15032 * @param {Object} data The data block from which to read the Records. The format of the data expected
15033 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
15034 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
15036 loadData : function(o, append){
15037 var r = this.reader.readRecords(o);
15038 this.loadRecords(r, {add: append}, true);
15042 * using 'cn' the nested child reader read the child array into it's child stores.
15043 * @param {Object} rec The record with a 'children array
15045 loadDataFromChildren : function(rec)
15047 this.loadData(this.reader.toLoadData(rec));
15052 * Gets the number of cached records.
15054 * <em>If using paging, this may not be the total size of the dataset. If the data object
15055 * used by the Reader contains the dataset size, then the getTotalCount() function returns
15056 * the data set size</em>
15058 getCount : function(){
15059 return this.data.length || 0;
15063 * Gets the total number of records in the dataset as returned by the server.
15065 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
15066 * the dataset size</em>
15068 getTotalCount : function(){
15069 return this.totalLength || 0;
15073 * Returns the sort state of the Store as an object with two properties:
15075 field {String} The name of the field by which the Records are sorted
15076 direction {String} The sort order, "ASC" or "DESC"
15079 getSortState : function(){
15080 return this.sortInfo;
15084 applySort : function(){
15085 if(this.sortInfo && !this.remoteSort){
15086 var s = this.sortInfo, f = s.field;
15087 var st = this.fields.get(f).sortType;
15088 var fn = function(r1, r2){
15089 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
15090 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
15092 this.data.sort(s.direction, fn);
15093 if(this.snapshot && this.snapshot != this.data){
15094 this.snapshot.sort(s.direction, fn);
15100 * Sets the default sort column and order to be used by the next load operation.
15101 * @param {String} fieldName The name of the field to sort by.
15102 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
15104 setDefaultSort : function(field, dir){
15105 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
15109 * Sort the Records.
15110 * If remote sorting is used, the sort is performed on the server, and the cache is
15111 * reloaded. If local sorting is used, the cache is sorted internally.
15112 * @param {String} fieldName The name of the field to sort by.
15113 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
15115 sort : function(fieldName, dir){
15116 var f = this.fields.get(fieldName);
15118 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
15120 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
15121 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
15126 this.sortToggle[f.name] = dir;
15127 this.sortInfo = {field: f.name, direction: dir};
15128 if(!this.remoteSort){
15130 this.fireEvent("datachanged", this);
15132 this.load(this.lastOptions);
15137 * Calls the specified function for each of the Records in the cache.
15138 * @param {Function} fn The function to call. The Record is passed as the first parameter.
15139 * Returning <em>false</em> aborts and exits the iteration.
15140 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
15142 each : function(fn, scope){
15143 this.data.each(fn, scope);
15147 * Gets all records modified since the last commit. Modified records are persisted across load operations
15148 * (e.g., during paging).
15149 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
15151 getModifiedRecords : function(){
15152 return this.modified;
15156 createFilterFn : function(property, value, anyMatch){
15157 if(!value.exec){ // not a regex
15158 value = String(value);
15159 if(value.length == 0){
15162 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
15164 return function(r){
15165 return value.test(r.data[property]);
15170 * Sums the value of <i>property</i> for each record between start and end and returns the result.
15171 * @param {String} property A field on your records
15172 * @param {Number} start The record index to start at (defaults to 0)
15173 * @param {Number} end The last record index to include (defaults to length - 1)
15174 * @return {Number} The sum
15176 sum : function(property, start, end){
15177 var rs = this.data.items, v = 0;
15178 start = start || 0;
15179 end = (end || end === 0) ? end : rs.length-1;
15181 for(var i = start; i <= end; i++){
15182 v += (rs[i].data[property] || 0);
15188 * Filter the records by a specified property.
15189 * @param {String} field A field on your records
15190 * @param {String/RegExp} value Either a string that the field
15191 * should start with or a RegExp to test against the field
15192 * @param {Boolean} anyMatch True to match any part not just the beginning
15194 filter : function(property, value, anyMatch){
15195 var fn = this.createFilterFn(property, value, anyMatch);
15196 return fn ? this.filterBy(fn) : this.clearFilter();
15200 * Filter by a function. The specified function will be called with each
15201 * record in this data source. If the function returns true the record is included,
15202 * otherwise it is filtered.
15203 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
15204 * @param {Object} scope (optional) The scope of the function (defaults to this)
15206 filterBy : function(fn, scope){
15207 this.snapshot = this.snapshot || this.data;
15208 this.data = this.queryBy(fn, scope||this);
15209 this.fireEvent("datachanged", this);
15213 * Query the records by a specified property.
15214 * @param {String} field A field on your records
15215 * @param {String/RegExp} value Either a string that the field
15216 * should start with or a RegExp to test against the field
15217 * @param {Boolean} anyMatch True to match any part not just the beginning
15218 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
15220 query : function(property, value, anyMatch){
15221 var fn = this.createFilterFn(property, value, anyMatch);
15222 return fn ? this.queryBy(fn) : this.data.clone();
15226 * Query by a function. The specified function will be called with each
15227 * record in this data source. If the function returns true the record is included
15229 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
15230 * @param {Object} scope (optional) The scope of the function (defaults to this)
15231 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
15233 queryBy : function(fn, scope){
15234 var data = this.snapshot || this.data;
15235 return data.filterBy(fn, scope||this);
15239 * Collects unique values for a particular dataIndex from this store.
15240 * @param {String} dataIndex The property to collect
15241 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
15242 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
15243 * @return {Array} An array of the unique values
15245 collect : function(dataIndex, allowNull, bypassFilter){
15246 var d = (bypassFilter === true && this.snapshot) ?
15247 this.snapshot.items : this.data.items;
15248 var v, sv, r = [], l = {};
15249 for(var i = 0, len = d.length; i < len; i++){
15250 v = d[i].data[dataIndex];
15252 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
15261 * Revert to a view of the Record cache with no filtering applied.
15262 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
15264 clearFilter : function(suppressEvent){
15265 if(this.snapshot && this.snapshot != this.data){
15266 this.data = this.snapshot;
15267 delete this.snapshot;
15268 if(suppressEvent !== true){
15269 this.fireEvent("datachanged", this);
15275 afterEdit : function(record){
15276 if(this.modified.indexOf(record) == -1){
15277 this.modified.push(record);
15279 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
15283 afterReject : function(record){
15284 this.modified.remove(record);
15285 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
15289 afterCommit : function(record){
15290 this.modified.remove(record);
15291 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
15295 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
15296 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
15298 commitChanges : function(){
15299 var m = this.modified.slice(0);
15300 this.modified = [];
15301 for(var i = 0, len = m.length; i < len; i++){
15307 * Cancel outstanding changes on all changed records.
15309 rejectChanges : function(){
15310 var m = this.modified.slice(0);
15311 this.modified = [];
15312 for(var i = 0, len = m.length; i < len; i++){
15317 onMetaChange : function(meta, rtype, o){
15318 this.recordType = rtype;
15319 this.fields = rtype.prototype.fields;
15320 delete this.snapshot;
15321 this.sortInfo = meta.sortInfo || this.sortInfo;
15322 this.modified = [];
15323 this.fireEvent('metachange', this, this.reader.meta);
15326 moveIndex : function(data, type)
15328 var index = this.indexOf(data);
15330 var newIndex = index + type;
15334 this.insert(newIndex, data);
15339 * Ext JS Library 1.1.1
15340 * Copyright(c) 2006-2007, Ext JS, LLC.
15342 * Originally Released Under LGPL - original licence link has changed is not relivant.
15345 * <script type="text/javascript">
15349 * @class Roo.data.SimpleStore
15350 * @extends Roo.data.Store
15351 * Small helper class to make creating Stores from Array data easier.
15352 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
15353 * @cfg {Array} fields An array of field definition objects, or field name strings.
15354 * @cfg {Object} an existing reader (eg. copied from another store)
15355 * @cfg {Array} data The multi-dimensional array of data
15356 * @cfg {Roo.data.DataProxy} proxy [not-required]
15357 * @cfg {Roo.data.Reader} reader [not-required]
15359 * @param {Object} config
15361 Roo.data.SimpleStore = function(config)
15363 Roo.data.SimpleStore.superclass.constructor.call(this, {
15365 reader: typeof(config.reader) != 'undefined' ? config.reader : new Roo.data.ArrayReader({
15368 Roo.data.Record.create(config.fields)
15370 proxy : new Roo.data.MemoryProxy(config.data)
15374 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
15376 * Ext JS Library 1.1.1
15377 * Copyright(c) 2006-2007, Ext JS, LLC.
15379 * Originally Released Under LGPL - original licence link has changed is not relivant.
15382 * <script type="text/javascript">
15387 * @extends Roo.data.Store
15388 * @class Roo.data.JsonStore
15389 * Small helper class to make creating Stores for JSON data easier. <br/>
15391 var store = new Roo.data.JsonStore({
15392 url: 'get-images.php',
15394 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
15397 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
15398 * JsonReader and HttpProxy (unless inline data is provided).</b>
15399 * @cfg {Array} fields An array of field definition objects, or field name strings.
15401 * @param {Object} config
15403 Roo.data.JsonStore = function(c){
15404 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
15405 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
15406 reader: new Roo.data.JsonReader(c, c.fields)
15409 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
15411 * Ext JS Library 1.1.1
15412 * Copyright(c) 2006-2007, Ext JS, LLC.
15414 * Originally Released Under LGPL - original licence link has changed is not relivant.
15417 * <script type="text/javascript">
15421 Roo.data.Field = function(config){
15422 if(typeof config == "string"){
15423 config = {name: config};
15425 Roo.apply(this, config);
15428 this.type = "auto";
15431 var st = Roo.data.SortTypes;
15432 // named sortTypes are supported, here we look them up
15433 if(typeof this.sortType == "string"){
15434 this.sortType = st[this.sortType];
15437 // set default sortType for strings and dates
15438 if(!this.sortType){
15441 this.sortType = st.asUCString;
15444 this.sortType = st.asDate;
15447 this.sortType = st.none;
15452 var stripRe = /[\$,%]/g;
15454 // prebuilt conversion function for this field, instead of
15455 // switching every time we're reading a value
15457 var cv, dateFormat = this.dateFormat;
15462 cv = function(v){ return v; };
15465 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
15469 return v !== undefined && v !== null && v !== '' ?
15470 parseInt(String(v).replace(stripRe, ""), 10) : '';
15475 return v !== undefined && v !== null && v !== '' ?
15476 parseFloat(String(v).replace(stripRe, ""), 10) : '';
15481 cv = function(v){ return v === true || v === "true" || v == 1; };
15488 if(v instanceof Date){
15492 if(dateFormat == "timestamp"){
15493 return new Date(v*1000);
15495 return Date.parseDate(v, dateFormat);
15497 var parsed = Date.parse(v);
15498 return parsed ? new Date(parsed) : null;
15507 Roo.data.Field.prototype = {
15515 * Ext JS Library 1.1.1
15516 * Copyright(c) 2006-2007, Ext JS, LLC.
15518 * Originally Released Under LGPL - original licence link has changed is not relivant.
15521 * <script type="text/javascript">
15524 // Base class for reading structured data from a data source. This class is intended to be
15525 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
15528 * @class Roo.data.DataReader
15530 * Base class for reading structured data from a data source. This class is intended to be
15531 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
15534 Roo.data.DataReader = function(meta, recordType){
15538 this.recordType = recordType instanceof Array ?
15539 Roo.data.Record.create(recordType) : recordType;
15542 Roo.data.DataReader.prototype = {
15545 readerType : 'Data',
15547 * Create an empty record
15548 * @param {Object} data (optional) - overlay some values
15549 * @return {Roo.data.Record} record created.
15551 newRow : function(d) {
15553 this.recordType.prototype.fields.each(function(c) {
15555 case 'int' : da[c.name] = 0; break;
15556 case 'date' : da[c.name] = new Date(); break;
15557 case 'float' : da[c.name] = 0.0; break;
15558 case 'boolean' : da[c.name] = false; break;
15559 default : da[c.name] = ""; break;
15563 return new this.recordType(Roo.apply(da, d));
15569 * Ext JS Library 1.1.1
15570 * Copyright(c) 2006-2007, Ext JS, LLC.
15572 * Originally Released Under LGPL - original licence link has changed is not relivant.
15575 * <script type="text/javascript">
15579 * @class Roo.data.DataProxy
15580 * @extends Roo.data.Observable
15582 * This class is an abstract base class for implementations which provide retrieval of
15583 * unformatted data objects.<br>
15585 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
15586 * (of the appropriate type which knows how to parse the data object) to provide a block of
15587 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
15589 * Custom implementations must implement the load method as described in
15590 * {@link Roo.data.HttpProxy#load}.
15592 Roo.data.DataProxy = function(){
15595 * @event beforeload
15596 * Fires before a network request is made to retrieve a data object.
15597 * @param {Object} This DataProxy object.
15598 * @param {Object} params The params parameter to the load function.
15603 * Fires before the load method's callback is called.
15604 * @param {Object} This DataProxy object.
15605 * @param {Object} o The data object.
15606 * @param {Object} arg The callback argument object passed to the load function.
15610 * @event loadexception
15611 * Fires if an Exception occurs during data retrieval.
15612 * @param {Object} This DataProxy object.
15613 * @param {Object} o The data object.
15614 * @param {Object} arg The callback argument object passed to the load function.
15615 * @param {Object} e The Exception.
15617 loadexception : true
15619 Roo.data.DataProxy.superclass.constructor.call(this);
15622 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
15625 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
15629 * Ext JS Library 1.1.1
15630 * Copyright(c) 2006-2007, Ext JS, LLC.
15632 * Originally Released Under LGPL - original licence link has changed is not relivant.
15635 * <script type="text/javascript">
15638 * @class Roo.data.MemoryProxy
15639 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
15640 * to the Reader when its load method is called.
15642 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
15644 Roo.data.MemoryProxy = function(data){
15648 Roo.data.MemoryProxy.superclass.constructor.call(this);
15652 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
15655 * Load data from the requested source (in this case an in-memory
15656 * data object passed to the constructor), read the data object into
15657 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
15658 * process that block using the passed callback.
15659 * @param {Object} params This parameter is not used by the MemoryProxy class.
15660 * @param {Roo.data.DataReader} reader The Reader object which converts the data
15661 * object into a block of Roo.data.Records.
15662 * @param {Function} callback The function into which to pass the block of Roo.data.records.
15663 * The function must be passed <ul>
15664 * <li>The Record block object</li>
15665 * <li>The "arg" argument from the load function</li>
15666 * <li>A boolean success indicator</li>
15668 * @param {Object} scope The scope in which to call the callback
15669 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
15671 load : function(params, reader, callback, scope, arg){
15672 params = params || {};
15675 result = reader.readRecords(params.data ? params.data :this.data);
15677 this.fireEvent("loadexception", this, arg, null, e);
15678 callback.call(scope, null, arg, false);
15681 callback.call(scope, result, arg, true);
15685 update : function(params, records){
15690 * Ext JS Library 1.1.1
15691 * Copyright(c) 2006-2007, Ext JS, LLC.
15693 * Originally Released Under LGPL - original licence link has changed is not relivant.
15696 * <script type="text/javascript">
15699 * @class Roo.data.HttpProxy
15700 * @extends Roo.data.DataProxy
15701 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
15702 * configured to reference a certain URL.<br><br>
15704 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
15705 * from which the running page was served.<br><br>
15707 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
15709 * Be aware that to enable the browser to parse an XML document, the server must set
15710 * the Content-Type header in the HTTP response to "text/xml".
15712 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
15713 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
15714 * will be used to make the request.
15716 Roo.data.HttpProxy = function(conn){
15717 Roo.data.HttpProxy.superclass.constructor.call(this);
15718 // is conn a conn config or a real conn?
15720 this.useAjax = !conn || !conn.events;
15724 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
15725 // thse are take from connection...
15728 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
15731 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
15732 * extra parameters to each request made by this object. (defaults to undefined)
15735 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
15736 * to each request made by this object. (defaults to undefined)
15739 * @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)
15742 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
15745 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
15751 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
15755 * Return the {@link Roo.data.Connection} object being used by this Proxy.
15756 * @return {Connection} The Connection object. This object may be used to subscribe to events on
15757 * a finer-grained basis than the DataProxy events.
15759 getConnection : function(){
15760 return this.useAjax ? Roo.Ajax : this.conn;
15764 * Load data from the configured {@link Roo.data.Connection}, read the data object into
15765 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
15766 * process that block using the passed callback.
15767 * @param {Object} params An object containing properties which are to be used as HTTP parameters
15768 * for the request to the remote server.
15769 * @param {Roo.data.DataReader} reader The Reader object which converts the data
15770 * object into a block of Roo.data.Records.
15771 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
15772 * The function must be passed <ul>
15773 * <li>The Record block object</li>
15774 * <li>The "arg" argument from the load function</li>
15775 * <li>A boolean success indicator</li>
15777 * @param {Object} scope The scope in which to call the callback
15778 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
15780 load : function(params, reader, callback, scope, arg){
15781 if(this.fireEvent("beforeload", this, params) !== false){
15783 params : params || {},
15785 callback : callback,
15790 callback : this.loadResponse,
15794 Roo.applyIf(o, this.conn);
15795 if(this.activeRequest){
15796 Roo.Ajax.abort(this.activeRequest);
15798 this.activeRequest = Roo.Ajax.request(o);
15800 this.conn.request(o);
15803 callback.call(scope||this, null, arg, false);
15808 loadResponse : function(o, success, response){
15809 delete this.activeRequest;
15811 this.fireEvent("loadexception", this, o, response);
15812 o.request.callback.call(o.request.scope, null, o.request.arg, false);
15817 result = o.reader.read(response);
15819 this.fireEvent("loadexception", this, o, response, e);
15820 o.request.callback.call(o.request.scope, null, o.request.arg, false);
15824 this.fireEvent("load", this, o, o.request.arg);
15825 o.request.callback.call(o.request.scope, result, o.request.arg, true);
15829 update : function(dataSet){
15834 updateResponse : function(dataSet){
15839 * Ext JS Library 1.1.1
15840 * Copyright(c) 2006-2007, Ext JS, LLC.
15842 * Originally Released Under LGPL - original licence link has changed is not relivant.
15845 * <script type="text/javascript">
15849 * @class Roo.data.ScriptTagProxy
15850 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
15851 * other than the originating domain of the running page.<br><br>
15853 * <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
15854 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
15856 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
15857 * source code that is used as the source inside a <script> tag.<br><br>
15859 * In order for the browser to process the returned data, the server must wrap the data object
15860 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
15861 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
15862 * depending on whether the callback name was passed:
15865 boolean scriptTag = false;
15866 String cb = request.getParameter("callback");
15869 response.setContentType("text/javascript");
15871 response.setContentType("application/x-json");
15873 Writer out = response.getWriter();
15875 out.write(cb + "(");
15877 out.print(dataBlock.toJsonString());
15884 * @param {Object} config A configuration object.
15886 Roo.data.ScriptTagProxy = function(config){
15887 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
15888 Roo.apply(this, config);
15889 this.head = document.getElementsByTagName("head")[0];
15892 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
15894 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
15896 * @cfg {String} url The URL from which to request the data object.
15899 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
15903 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
15904 * the server the name of the callback function set up by the load call to process the returned data object.
15905 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
15906 * javascript output which calls this named function passing the data object as its only parameter.
15908 callbackParam : "callback",
15910 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
15911 * name to the request.
15916 * Load data from the configured URL, read the data object into
15917 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
15918 * process that block using the passed callback.
15919 * @param {Object} params An object containing properties which are to be used as HTTP parameters
15920 * for the request to the remote server.
15921 * @param {Roo.data.DataReader} reader The Reader object which converts the data
15922 * object into a block of Roo.data.Records.
15923 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
15924 * The function must be passed <ul>
15925 * <li>The Record block object</li>
15926 * <li>The "arg" argument from the load function</li>
15927 * <li>A boolean success indicator</li>
15929 * @param {Object} scope The scope in which to call the callback
15930 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
15932 load : function(params, reader, callback, scope, arg){
15933 if(this.fireEvent("beforeload", this, params) !== false){
15935 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
15937 var url = this.url;
15938 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
15940 url += "&_dc=" + (new Date().getTime());
15942 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
15945 cb : "stcCallback"+transId,
15946 scriptId : "stcScript"+transId,
15950 callback : callback,
15956 window[trans.cb] = function(o){
15957 conn.handleResponse(o, trans);
15960 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
15962 if(this.autoAbort !== false){
15966 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
15968 var script = document.createElement("script");
15969 script.setAttribute("src", url);
15970 script.setAttribute("type", "text/javascript");
15971 script.setAttribute("id", trans.scriptId);
15972 this.head.appendChild(script);
15974 this.trans = trans;
15976 callback.call(scope||this, null, arg, false);
15981 isLoading : function(){
15982 return this.trans ? true : false;
15986 * Abort the current server request.
15988 abort : function(){
15989 if(this.isLoading()){
15990 this.destroyTrans(this.trans);
15995 destroyTrans : function(trans, isLoaded){
15996 this.head.removeChild(document.getElementById(trans.scriptId));
15997 clearTimeout(trans.timeoutId);
15999 window[trans.cb] = undefined;
16001 delete window[trans.cb];
16004 // if hasn't been loaded, wait for load to remove it to prevent script error
16005 window[trans.cb] = function(){
16006 window[trans.cb] = undefined;
16008 delete window[trans.cb];
16015 handleResponse : function(o, trans){
16016 this.trans = false;
16017 this.destroyTrans(trans, true);
16020 result = trans.reader.readRecords(o);
16022 this.fireEvent("loadexception", this, o, trans.arg, e);
16023 trans.callback.call(trans.scope||window, null, trans.arg, false);
16026 this.fireEvent("load", this, o, trans.arg);
16027 trans.callback.call(trans.scope||window, result, trans.arg, true);
16031 handleFailure : function(trans){
16032 this.trans = false;
16033 this.destroyTrans(trans, false);
16034 this.fireEvent("loadexception", this, null, trans.arg);
16035 trans.callback.call(trans.scope||window, null, trans.arg, false);
16039 * Ext JS Library 1.1.1
16040 * Copyright(c) 2006-2007, Ext JS, LLC.
16042 * Originally Released Under LGPL - original licence link has changed is not relivant.
16045 * <script type="text/javascript">
16049 * @class Roo.data.JsonReader
16050 * @extends Roo.data.DataReader
16051 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
16052 * based on mappings in a provided Roo.data.Record constructor.
16054 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
16055 * in the reply previously.
16060 var RecordDef = Roo.data.Record.create([
16061 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
16062 {name: 'occupation'} // This field will use "occupation" as the mapping.
16064 var myReader = new Roo.data.JsonReader({
16065 totalProperty: "results", // The property which contains the total dataset size (optional)
16066 root: "rows", // The property which contains an Array of row objects
16067 id: "id" // The property within each row object that provides an ID for the record (optional)
16071 * This would consume a JSON file like this:
16073 { 'results': 2, 'rows': [
16074 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
16075 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
16078 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
16079 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
16080 * paged from the remote server.
16081 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
16082 * @cfg {String} root name of the property which contains the Array of row objects.
16083 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
16084 * @cfg {Array} fields Array of field definition objects
16086 * Create a new JsonReader
16087 * @param {Object} meta Metadata configuration options
16088 * @param {Object} recordType Either an Array of field definition objects,
16089 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
16091 Roo.data.JsonReader = function(meta, recordType){
16094 // set some defaults:
16095 Roo.applyIf(meta, {
16096 totalProperty: 'total',
16097 successProperty : 'success',
16102 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
16104 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
16106 readerType : 'Json',
16109 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
16110 * Used by Store query builder to append _requestMeta to params.
16113 metaFromRemote : false,
16115 * This method is only used by a DataProxy which has retrieved data from a remote server.
16116 * @param {Object} response The XHR object which contains the JSON data in its responseText.
16117 * @return {Object} data A data block which is used by an Roo.data.Store object as
16118 * a cache of Roo.data.Records.
16120 read : function(response){
16121 var json = response.responseText;
16123 var o = /* eval:var:o */ eval("("+json+")");
16125 throw {message: "JsonReader.read: Json object not found"};
16131 this.metaFromRemote = true;
16132 this.meta = o.metaData;
16133 this.recordType = Roo.data.Record.create(o.metaData.fields);
16134 this.onMetaChange(this.meta, this.recordType, o);
16136 return this.readRecords(o);
16139 // private function a store will implement
16140 onMetaChange : function(meta, recordType, o){
16147 simpleAccess: function(obj, subsc) {
16154 getJsonAccessor: function(){
16156 return function(expr) {
16158 return(re.test(expr))
16159 ? new Function("obj", "return obj." + expr)
16164 return Roo.emptyFn;
16169 * Create a data block containing Roo.data.Records from an XML document.
16170 * @param {Object} o An object which contains an Array of row objects in the property specified
16171 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
16172 * which contains the total size of the dataset.
16173 * @return {Object} data A data block which is used by an Roo.data.Store object as
16174 * a cache of Roo.data.Records.
16176 readRecords : function(o){
16178 * After any data loads, the raw JSON data is available for further custom processing.
16182 var s = this.meta, Record = this.recordType,
16183 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
16185 // Generate extraction functions for the totalProperty, the root, the id, and for each field
16187 if(s.totalProperty) {
16188 this.getTotal = this.getJsonAccessor(s.totalProperty);
16190 if(s.successProperty) {
16191 this.getSuccess = this.getJsonAccessor(s.successProperty);
16193 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
16195 var g = this.getJsonAccessor(s.id);
16196 this.getId = function(rec) {
16198 return (r === undefined || r === "") ? null : r;
16201 this.getId = function(){return null;};
16204 for(var jj = 0; jj < fl; jj++){
16206 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
16207 this.ef[jj] = this.getJsonAccessor(map);
16211 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
16212 if(s.totalProperty){
16213 var vt = parseInt(this.getTotal(o), 10);
16218 if(s.successProperty){
16219 var vs = this.getSuccess(o);
16220 if(vs === false || vs === 'false'){
16225 for(var i = 0; i < c; i++){
16228 var id = this.getId(n);
16229 for(var j = 0; j < fl; j++){
16231 var v = this.ef[j](n);
16233 Roo.log('missing convert for ' + f.name);
16237 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
16239 var record = new Record(values, id);
16241 records[i] = record;
16247 totalRecords : totalRecords
16250 // used when loading children.. @see loadDataFromChildren
16251 toLoadData: function(rec)
16253 // expect rec just to be an array.. eg [a,b,c, [...] << cn ]
16254 var data = typeof(rec.data.cn) == 'undefined' ? [] : rec.data.cn;
16255 return { data : data, total : data.length };
16260 * Ext JS Library 1.1.1
16261 * Copyright(c) 2006-2007, Ext JS, LLC.
16263 * Originally Released Under LGPL - original licence link has changed is not relivant.
16266 * <script type="text/javascript">
16270 * @class Roo.data.ArrayReader
16271 * @extends Roo.data.DataReader
16272 * Data reader class to create an Array of Roo.data.Record objects from an Array.
16273 * Each element of that Array represents a row of data fields. The
16274 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
16275 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
16279 var RecordDef = Roo.data.Record.create([
16280 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
16281 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
16283 var myReader = new Roo.data.ArrayReader({
16284 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
16288 * This would consume an Array like this:
16290 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
16294 * Create a new JsonReader
16295 * @param {Object} meta Metadata configuration options.
16296 * @param {Object|Array} recordType Either an Array of field definition objects
16298 * @cfg {Array} fields Array of field definition objects
16299 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
16300 * as specified to {@link Roo.data.Record#create},
16301 * or an {@link Roo.data.Record} object
16304 * created using {@link Roo.data.Record#create}.
16306 Roo.data.ArrayReader = function(meta, recordType)
16308 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType||meta.fields);
16311 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
16314 * Create a data block containing Roo.data.Records from an XML document.
16315 * @param {Object} o An Array of row objects which represents the dataset.
16316 * @return {Object} A data block which is used by an {@link Roo.data.Store} object as
16317 * a cache of Roo.data.Records.
16319 readRecords : function(o)
16321 var sid = this.meta ? this.meta.id : null;
16322 var recordType = this.recordType, fields = recordType.prototype.fields;
16325 for(var i = 0; i < root.length; i++){
16328 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
16329 for(var j = 0, jlen = fields.length; j < jlen; j++){
16330 var f = fields.items[j];
16331 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
16332 var v = n[k] !== undefined ? n[k] : f.defaultValue;
16334 values[f.name] = v;
16336 var record = new recordType(values, id);
16338 records[records.length] = record;
16342 totalRecords : records.length
16345 // used when loading children.. @see loadDataFromChildren
16346 toLoadData: function(rec)
16348 // expect rec just to be an array.. eg [a,b,c, [...] << cn ]
16349 return typeof(rec.data.cn) == 'undefined' ? [] : rec.data.cn;
16360 * @class Roo.bootstrap.ComboBox
16361 * @extends Roo.bootstrap.TriggerField
16362 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
16363 * @cfg {Boolean} append (true|false) default false
16364 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
16365 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
16366 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
16367 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
16368 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
16369 * @cfg {Boolean} animate default true
16370 * @cfg {Boolean} emptyResultText only for touch device
16371 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
16372 * @cfg {String} emptyTitle default ''
16373 * @cfg {Number} width fixed with? experimental
16375 * Create a new ComboBox.
16376 * @param {Object} config Configuration options
16378 Roo.bootstrap.ComboBox = function(config){
16379 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
16383 * Fires when the dropdown list is expanded
16384 * @param {Roo.bootstrap.ComboBox} combo This combo box
16389 * Fires when the dropdown list is collapsed
16390 * @param {Roo.bootstrap.ComboBox} combo This combo box
16394 * @event beforeselect
16395 * Fires before a list item is selected. Return false to cancel the selection.
16396 * @param {Roo.bootstrap.ComboBox} combo This combo box
16397 * @param {Roo.data.Record} record The data record returned from the underlying store
16398 * @param {Number} index The index of the selected item in the dropdown list
16400 'beforeselect' : true,
16403 * Fires when a list item is selected
16404 * @param {Roo.bootstrap.ComboBox} combo This combo box
16405 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
16406 * @param {Number} index The index of the selected item in the dropdown list
16410 * @event beforequery
16411 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
16412 * The event object passed has these properties:
16413 * @param {Roo.bootstrap.ComboBox} combo This combo box
16414 * @param {String} query The query
16415 * @param {Boolean} forceAll true to force "all" query
16416 * @param {Boolean} cancel true to cancel the query
16417 * @param {Object} e The query event object
16419 'beforequery': true,
16422 * Fires when the 'add' icon is pressed (add a listener to enable add button)
16423 * @param {Roo.bootstrap.ComboBox} combo This combo box
16428 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
16429 * @param {Roo.bootstrap.ComboBox} combo This combo box
16430 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
16435 * Fires when the remove value from the combobox array
16436 * @param {Roo.bootstrap.ComboBox} combo This combo box
16440 * @event afterremove
16441 * Fires when the remove value from the combobox array
16442 * @param {Roo.bootstrap.ComboBox} combo This combo box
16444 'afterremove' : true,
16446 * @event specialfilter
16447 * Fires when specialfilter
16448 * @param {Roo.bootstrap.ComboBox} combo This combo box
16450 'specialfilter' : true,
16453 * Fires when tick the element
16454 * @param {Roo.bootstrap.ComboBox} combo This combo box
16458 * @event touchviewdisplay
16459 * Fires when touch view require special display (default is using displayField)
16460 * @param {Roo.bootstrap.ComboBox} combo This combo box
16461 * @param {Object} cfg set html .
16463 'touchviewdisplay' : true
16468 this.tickItems = [];
16470 this.selectedIndex = -1;
16471 if(this.mode == 'local'){
16472 if(config.queryDelay === undefined){
16473 this.queryDelay = 10;
16475 if(config.minChars === undefined){
16481 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
16484 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
16485 * rendering into an Roo.Editor, defaults to false)
16488 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
16489 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
16492 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
16495 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
16496 * the dropdown list (defaults to undefined, with no header element)
16500 * @cfg {String/Roo.Template} tpl The template to use to render the output default is '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>'
16504 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
16506 listWidth: undefined,
16508 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
16509 * mode = 'remote' or 'text' if mode = 'local')
16511 displayField: undefined,
16514 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
16515 * mode = 'remote' or 'value' if mode = 'local').
16516 * Note: use of a valueField requires the user make a selection
16517 * in order for a value to be mapped.
16519 valueField: undefined,
16521 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
16526 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
16527 * field's data value (defaults to the underlying DOM element's name)
16529 hiddenName: undefined,
16531 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
16535 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
16537 selectedClass: 'active',
16540 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
16544 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
16545 * anchor positions (defaults to 'tl-bl')
16547 listAlign: 'tl-bl?',
16549 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
16553 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
16554 * query specified by the allQuery config option (defaults to 'query')
16556 triggerAction: 'query',
16558 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
16559 * (defaults to 4, does not apply if editable = false)
16563 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
16564 * delay (typeAheadDelay) if it matches a known value (defaults to false)
16568 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
16569 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
16573 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
16574 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
16578 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
16579 * when editable = true (defaults to false)
16581 selectOnFocus:false,
16583 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
16585 queryParam: 'query',
16587 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
16588 * when mode = 'remote' (defaults to 'Loading...')
16590 loadingText: 'Loading...',
16592 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
16596 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
16600 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
16601 * traditional select (defaults to true)
16605 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
16609 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
16613 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
16614 * listWidth has a higher value)
16618 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
16619 * allow the user to set arbitrary text into the field (defaults to false)
16621 forceSelection:false,
16623 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
16624 * if typeAhead = true (defaults to 250)
16626 typeAheadDelay : 250,
16628 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
16629 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
16631 valueNotFoundText : undefined,
16633 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
16635 blockFocus : false,
16638 * @cfg {Boolean} disableClear Disable showing of clear button.
16640 disableClear : false,
16642 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
16644 alwaysQuery : false,
16647 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
16652 * @cfg {String} invalidClass DEPRICATED - uses BS4 is-valid now
16654 invalidClass : "has-warning",
16657 * @cfg {String} validClass DEPRICATED - uses BS4 is-valid now
16659 validClass : "has-success",
16662 * @cfg {Boolean} specialFilter (true|false) special filter default false
16664 specialFilter : false,
16667 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
16669 mobileTouchView : true,
16672 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
16674 useNativeIOS : false,
16677 * @cfg {Boolean} mobile_restrict_height (true|false) restrict height for touch view
16679 mobile_restrict_height : false,
16681 ios_options : false,
16693 btnPosition : 'right',
16694 triggerList : true,
16695 showToggleBtn : true,
16697 emptyResultText: 'Empty',
16698 triggerText : 'Select',
16702 // element that contains real text value.. (when hidden is used..)
16704 getAutoCreate : function()
16709 * Render classic select for iso
16712 if(Roo.isIOS && this.useNativeIOS){
16713 cfg = this.getAutoCreateNativeIOS();
16721 if(Roo.isTouch && this.mobileTouchView){
16722 cfg = this.getAutoCreateTouchView();
16729 if(!this.tickable){
16730 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
16735 * ComboBox with tickable selections
16738 var align = this.labelAlign || this.parentLabelAlign();
16741 cls : 'form-group roo-combobox-tickable' //input-group
16744 var btn_text_select = '';
16745 var btn_text_done = '';
16746 var btn_text_cancel = '';
16748 if (this.btn_text_show) {
16749 btn_text_select = 'Select';
16750 btn_text_done = 'Done';
16751 btn_text_cancel = 'Cancel';
16756 cls : 'tickable-buttons',
16761 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
16762 //html : this.triggerText
16763 html: btn_text_select
16769 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
16771 html: btn_text_done
16777 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
16779 html: btn_text_cancel
16785 buttons.cn.unshift({
16787 cls: 'roo-select2-search-field-input'
16793 Roo.each(buttons.cn, function(c){
16795 c.cls += ' btn-' + _this.size;
16798 if (_this.disabled) {
16805 style : 'display: contents',
16810 cls: 'form-hidden-field'
16814 cls: 'roo-select2-choices',
16818 cls: 'roo-select2-search-field',
16829 cls: 'roo-select2-container input-group roo-select2-container-multi',
16835 // cls: 'typeahead typeahead-long dropdown-menu',
16836 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
16841 if(this.hasFeedback && !this.allowBlank){
16845 cls: 'glyphicon form-control-feedback'
16848 combobox.cn.push(feedback);
16855 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
16856 tooltip : 'This field is required'
16858 if (Roo.bootstrap.version == 4) {
16861 style : 'display:none'
16864 if (align ==='left' && this.fieldLabel.length) {
16866 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
16873 cls : 'control-label col-form-label',
16874 html : this.fieldLabel
16886 var labelCfg = cfg.cn[1];
16887 var contentCfg = cfg.cn[2];
16890 if(this.indicatorpos == 'right'){
16896 cls : 'control-label col-form-label',
16900 html : this.fieldLabel
16916 labelCfg = cfg.cn[0];
16917 contentCfg = cfg.cn[1];
16921 if(this.labelWidth > 12){
16922 labelCfg.style = "width: " + this.labelWidth + 'px';
16924 if(this.width * 1 > 0){
16925 contentCfg.style = "width: " + this.width + 'px';
16927 if(this.labelWidth < 13 && this.labelmd == 0){
16928 this.labelmd = this.labelWidth;
16931 if(this.labellg > 0){
16932 labelCfg.cls += ' col-lg-' + this.labellg;
16933 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
16936 if(this.labelmd > 0){
16937 labelCfg.cls += ' col-md-' + this.labelmd;
16938 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
16941 if(this.labelsm > 0){
16942 labelCfg.cls += ' col-sm-' + this.labelsm;
16943 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
16946 if(this.labelxs > 0){
16947 labelCfg.cls += ' col-xs-' + this.labelxs;
16948 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
16952 } else if ( this.fieldLabel.length) {
16953 // Roo.log(" label");
16958 //cls : 'input-group-addon',
16959 html : this.fieldLabel
16964 if(this.indicatorpos == 'right'){
16968 //cls : 'input-group-addon',
16969 html : this.fieldLabel
16979 // Roo.log(" no label && no align");
16986 ['xs','sm','md','lg'].map(function(size){
16987 if (settings[size]) {
16988 cfg.cls += ' col-' + size + '-' + settings[size];
16996 _initEventsCalled : false,
16999 initEvents: function()
17001 if (this._initEventsCalled) { // as we call render... prevent looping...
17004 this._initEventsCalled = true;
17007 throw "can not find store for combo";
17010 this.indicator = this.indicatorEl();
17012 this.store = Roo.factory(this.store, Roo.data);
17013 this.store.parent = this;
17015 // if we are building from html. then this element is so complex, that we can not really
17016 // use the rendered HTML.
17017 // so we have to trash and replace the previous code.
17018 if (Roo.XComponent.build_from_html) {
17019 // remove this element....
17020 var e = this.el.dom, k=0;
17021 while (e ) { e = e.previousSibling; ++k;}
17026 this.rendered = false;
17028 this.render(this.parent().getChildContainer(true), k);
17031 if(Roo.isIOS && this.useNativeIOS){
17032 this.initIOSView();
17040 if(Roo.isTouch && this.mobileTouchView){
17041 this.initTouchView();
17046 this.initTickableEvents();
17050 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
17052 if(this.hiddenName){
17054 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
17056 this.hiddenField.dom.value =
17057 this.hiddenValue !== undefined ? this.hiddenValue :
17058 this.value !== undefined ? this.value : '';
17060 // prevent input submission
17061 this.el.dom.removeAttribute('name');
17062 this.hiddenField.dom.setAttribute('name', this.hiddenName);
17067 // this.el.dom.setAttribute('autocomplete', 'off');
17070 var cls = 'x-combo-list';
17072 //this.list = new Roo.Layer({
17073 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
17079 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
17080 _this.list.setWidth(lw);
17083 this.list.on('mouseover', this.onViewOver, this);
17084 this.list.on('mousemove', this.onViewMove, this);
17085 this.list.on('scroll', this.onViewScroll, this);
17088 this.list.swallowEvent('mousewheel');
17089 this.assetHeight = 0;
17092 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
17093 this.assetHeight += this.header.getHeight();
17096 this.innerList = this.list.createChild({cls:cls+'-inner'});
17097 this.innerList.on('mouseover', this.onViewOver, this);
17098 this.innerList.on('mousemove', this.onViewMove, this);
17099 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
17101 if(this.allowBlank && !this.pageSize && !this.disableClear){
17102 this.footer = this.list.createChild({cls:cls+'-ft'});
17103 this.pageTb = new Roo.Toolbar(this.footer);
17107 this.footer = this.list.createChild({cls:cls+'-ft'});
17108 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
17109 {pageSize: this.pageSize});
17113 if (this.pageTb && this.allowBlank && !this.disableClear) {
17115 this.pageTb.add(new Roo.Toolbar.Fill(), {
17116 cls: 'x-btn-icon x-btn-clear',
17118 handler: function()
17121 _this.clearValue();
17122 _this.onSelect(false, -1);
17127 this.assetHeight += this.footer.getHeight();
17132 this.tpl = Roo.bootstrap.version == 4 ?
17133 '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>' : // 4 does not need <li> and it get's really confisued.
17134 '<li><a class="dropdown-item" href="#">{' + this.displayField + '}</a></li>';
17137 this.view = new Roo.View(this.list, this.tpl, {
17138 singleSelect:true, store: this.store, selectedClass: this.selectedClass
17140 //this.view.wrapEl.setDisplayed(false);
17141 this.view.on('click', this.onViewClick, this);
17144 this.store.on('beforeload', this.onBeforeLoad, this);
17145 this.store.on('load', this.onLoad, this);
17146 this.store.on('loadexception', this.onLoadException, this);
17148 if(this.resizable){
17149 this.resizer = new Roo.Resizable(this.list, {
17150 pinned:true, handles:'se'
17152 this.resizer.on('resize', function(r, w, h){
17153 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
17154 this.listWidth = w;
17155 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
17156 this.restrictHeight();
17158 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
17161 if(!this.editable){
17162 this.editable = true;
17163 this.setEditable(false);
17168 if (typeof(this.events.add.listeners) != 'undefined') {
17170 this.addicon = this.wrap.createChild(
17171 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
17173 this.addicon.on('click', function(e) {
17174 this.fireEvent('add', this);
17177 if (typeof(this.events.edit.listeners) != 'undefined') {
17179 this.editicon = this.wrap.createChild(
17180 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
17181 if (this.addicon) {
17182 this.editicon.setStyle('margin-left', '40px');
17184 this.editicon.on('click', function(e) {
17186 // we fire even if inothing is selected..
17187 this.fireEvent('edit', this, this.lastData );
17193 this.keyNav = new Roo.KeyNav(this.inputEl(), {
17194 "up" : function(e){
17195 this.inKeyMode = true;
17199 "down" : function(e){
17200 if(!this.isExpanded()){
17201 this.onTriggerClick();
17203 this.inKeyMode = true;
17208 "enter" : function(e){
17209 // this.onViewClick();
17213 if(this.fireEvent("specialkey", this, e)){
17214 this.onViewClick(false);
17220 "esc" : function(e){
17224 "tab" : function(e){
17227 if(this.fireEvent("specialkey", this, e)){
17228 this.onViewClick(false);
17236 doRelay : function(foo, bar, hname){
17237 if(hname == 'down' || this.scope.isExpanded()){
17238 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
17247 this.queryDelay = Math.max(this.queryDelay || 10,
17248 this.mode == 'local' ? 10 : 250);
17251 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
17253 if(this.typeAhead){
17254 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
17256 if(this.editable !== false){
17257 this.inputEl().on("keyup", this.onKeyUp, this);
17259 if(this.forceSelection){
17260 this.inputEl().on('blur', this.doForce, this);
17264 this.choices = this.el.select('ul.roo-select2-choices', true).first();
17265 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
17269 initTickableEvents: function()
17273 if(this.hiddenName){
17275 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
17277 this.hiddenField.dom.value =
17278 this.hiddenValue !== undefined ? this.hiddenValue :
17279 this.value !== undefined ? this.value : '';
17281 // prevent input submission
17282 this.el.dom.removeAttribute('name');
17283 this.hiddenField.dom.setAttribute('name', this.hiddenName);
17288 // this.list = this.el.select('ul.dropdown-menu',true).first();
17290 this.choices = this.el.select('ul.roo-select2-choices', true).first();
17291 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
17292 if(this.triggerList){
17293 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
17296 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
17297 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
17299 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
17300 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
17302 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
17303 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
17305 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
17306 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
17307 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
17310 this.cancelBtn.hide();
17315 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
17316 _this.list.setWidth(lw);
17319 this.list.on('mouseover', this.onViewOver, this);
17320 this.list.on('mousemove', this.onViewMove, this);
17322 this.list.on('scroll', this.onViewScroll, this);
17325 this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}"' +
17326 'type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
17329 this.view = new Roo.View(this.list, this.tpl, {
17334 selectedClass: this.selectedClass
17337 //this.view.wrapEl.setDisplayed(false);
17338 this.view.on('click', this.onViewClick, this);
17342 this.store.on('beforeload', this.onBeforeLoad, this);
17343 this.store.on('load', this.onLoad, this);
17344 this.store.on('loadexception', this.onLoadException, this);
17347 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
17348 "up" : function(e){
17349 this.inKeyMode = true;
17353 "down" : function(e){
17354 this.inKeyMode = true;
17358 "enter" : function(e){
17359 if(this.fireEvent("specialkey", this, e)){
17360 this.onViewClick(false);
17366 "esc" : function(e){
17367 this.onTickableFooterButtonClick(e, false, false);
17370 "tab" : function(e){
17371 this.fireEvent("specialkey", this, e);
17373 this.onTickableFooterButtonClick(e, false, false);
17380 doRelay : function(e, fn, key){
17381 if(this.scope.isExpanded()){
17382 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
17391 this.queryDelay = Math.max(this.queryDelay || 10,
17392 this.mode == 'local' ? 10 : 250);
17395 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
17397 if(this.typeAhead){
17398 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
17401 if(this.editable !== false){
17402 this.tickableInputEl().on("keyup", this.onKeyUp, this);
17405 this.indicator = this.indicatorEl();
17407 if(this.indicator){
17408 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
17409 this.indicator.hide();
17414 onDestroy : function(){
17416 this.view.setStore(null);
17417 this.view.el.removeAllListeners();
17418 this.view.el.remove();
17419 this.view.purgeListeners();
17422 this.list.dom.innerHTML = '';
17426 this.store.un('beforeload', this.onBeforeLoad, this);
17427 this.store.un('load', this.onLoad, this);
17428 this.store.un('loadexception', this.onLoadException, this);
17430 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
17434 fireKey : function(e){
17435 if(e.isNavKeyPress() && !this.list.isVisible()){
17436 this.fireEvent("specialkey", this, e);
17441 onResize: function(w, h)
17445 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
17447 // if(typeof w != 'number'){
17448 // // we do not handle it!?!?
17451 // var tw = this.trigger.getWidth();
17452 // // tw += this.addicon ? this.addicon.getWidth() : 0;
17453 // // tw += this.editicon ? this.editicon.getWidth() : 0;
17455 // this.inputEl().setWidth( this.adjustWidth('input', x));
17457 // //this.trigger.setStyle('left', x+'px');
17459 // if(this.list && this.listWidth === undefined){
17460 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
17461 // this.list.setWidth(lw);
17462 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
17470 * Allow or prevent the user from directly editing the field text. If false is passed,
17471 * the user will only be able to select from the items defined in the dropdown list. This method
17472 * is the runtime equivalent of setting the 'editable' config option at config time.
17473 * @param {Boolean} value True to allow the user to directly edit the field text
17475 setEditable : function(value){
17476 if(value == this.editable){
17479 this.editable = value;
17481 this.inputEl().dom.setAttribute('readOnly', true);
17482 this.inputEl().on('mousedown', this.onTriggerClick, this);
17483 this.inputEl().addClass('x-combo-noedit');
17485 this.inputEl().dom.removeAttribute('readOnly');
17486 this.inputEl().un('mousedown', this.onTriggerClick, this);
17487 this.inputEl().removeClass('x-combo-noedit');
17493 onBeforeLoad : function(combo,opts){
17494 if(!this.hasFocus){
17498 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
17500 this.restrictHeight();
17501 this.selectedIndex = -1;
17505 onLoad : function(){
17507 this.hasQuery = false;
17509 if(!this.hasFocus){
17513 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
17514 this.loading.hide();
17517 if(this.store.getCount() > 0){
17520 this.restrictHeight();
17521 if(this.lastQuery == this.allQuery){
17522 if(this.editable && !this.tickable){
17523 this.inputEl().dom.select();
17527 !this.selectByValue(this.value, true) &&
17530 !this.store.lastOptions ||
17531 typeof(this.store.lastOptions.add) == 'undefined' ||
17532 this.store.lastOptions.add != true
17535 this.select(0, true);
17538 if(this.autoFocus){
17541 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
17542 this.taTask.delay(this.typeAheadDelay);
17546 this.onEmptyResults();
17552 onLoadException : function()
17554 this.hasQuery = false;
17556 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
17557 this.loading.hide();
17560 if(this.tickable && this.editable){
17565 // only causes errors at present
17566 //Roo.log(this.store.reader.jsonData);
17567 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
17569 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
17575 onTypeAhead : function(){
17576 if(this.store.getCount() > 0){
17577 var r = this.store.getAt(0);
17578 var newValue = r.data[this.displayField];
17579 var len = newValue.length;
17580 var selStart = this.getRawValue().length;
17582 if(selStart != len){
17583 this.setRawValue(newValue);
17584 this.selectText(selStart, newValue.length);
17590 onSelect : function(record, index){
17592 if(this.fireEvent('beforeselect', this, record, index) !== false){
17594 this.setFromData(index > -1 ? record.data : false);
17597 this.fireEvent('select', this, record, index);
17602 * Returns the currently selected field value or empty string if no value is set.
17603 * @return {String} value The selected value
17605 getValue : function()
17607 if(Roo.isIOS && this.useNativeIOS){
17608 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
17612 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
17615 if(this.valueField){
17616 return typeof this.value != 'undefined' ? this.value : '';
17618 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
17622 getRawValue : function()
17624 if(Roo.isIOS && this.useNativeIOS){
17625 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
17628 var v = this.inputEl().getValue();
17634 * Clears any text/value currently set in the field
17636 clearValue : function(){
17638 if(this.hiddenField){
17639 this.hiddenField.dom.value = '';
17642 this.setRawValue('');
17643 this.lastSelectionText = '';
17644 this.lastData = false;
17646 var close = this.closeTriggerEl();
17657 * Sets the specified value into the field. If the value finds a match, the corresponding record text
17658 * will be displayed in the field. If the value does not match the data value of an existing item,
17659 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
17660 * Otherwise the field will be blank (although the value will still be set).
17661 * @param {String} value The value to match
17663 setValue : function(v)
17665 if(Roo.isIOS && this.useNativeIOS){
17666 this.setIOSValue(v);
17676 if(this.valueField){
17677 var r = this.findRecord(this.valueField, v);
17679 text = r.data[this.displayField];
17680 }else if(this.valueNotFoundText !== undefined){
17681 text = this.valueNotFoundText;
17684 this.lastSelectionText = text;
17685 if(this.hiddenField){
17686 this.hiddenField.dom.value = v;
17688 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
17691 var close = this.closeTriggerEl();
17694 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
17700 * @property {Object} the last set data for the element
17705 * Sets the value of the field based on a object which is related to the record format for the store.
17706 * @param {Object} value the value to set as. or false on reset?
17708 setFromData : function(o){
17715 var dv = ''; // display value
17716 var vv = ''; // value value..
17718 if (this.displayField) {
17719 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
17721 // this is an error condition!!!
17722 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
17725 if(this.valueField){
17726 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
17729 var close = this.closeTriggerEl();
17732 if(dv.length || vv * 1 > 0){
17734 this.blockFocus=true;
17740 if(this.hiddenField){
17741 this.hiddenField.dom.value = vv;
17743 this.lastSelectionText = dv;
17744 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
17748 // no hidden field.. - we store the value in 'value', but still display
17749 // display field!!!!
17750 this.lastSelectionText = dv;
17751 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
17758 reset : function(){
17759 // overridden so that last data is reset..
17766 this.setValue(this.originalValue);
17767 //this.clearInvalid();
17768 this.lastData = false;
17770 this.view.clearSelections();
17776 findRecord : function(prop, value){
17778 if(this.store.getCount() > 0){
17779 this.store.each(function(r){
17780 if(r.data[prop] == value){
17790 getName: function()
17792 // returns hidden if it's set..
17793 if (!this.rendered) {return ''};
17794 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
17798 onViewMove : function(e, t){
17799 this.inKeyMode = false;
17803 onViewOver : function(e, t){
17804 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
17807 var item = this.view.findItemFromChild(t);
17810 var index = this.view.indexOf(item);
17811 this.select(index, false);
17816 onViewClick : function(view, doFocus, el, e)
17818 var index = this.view.getSelectedIndexes()[0];
17820 var r = this.store.getAt(index);
17824 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
17831 Roo.each(this.tickItems, function(v,k){
17833 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
17835 _this.tickItems.splice(k, 1);
17837 if(typeof(e) == 'undefined' && view == false){
17838 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
17850 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
17851 this.tickItems.push(r.data);
17854 if(typeof(e) == 'undefined' && view == false){
17855 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
17862 this.onSelect(r, index);
17864 if(doFocus !== false && !this.blockFocus){
17865 this.inputEl().focus();
17870 restrictHeight : function(){
17871 //this.innerList.dom.style.height = '';
17872 //var inner = this.innerList.dom;
17873 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
17874 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
17875 //this.list.beginUpdate();
17876 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
17877 this.list.alignTo(this.inputEl(), this.listAlign);
17878 this.list.alignTo(this.inputEl(), this.listAlign);
17879 //this.list.endUpdate();
17883 onEmptyResults : function(){
17885 if(this.tickable && this.editable){
17886 this.hasFocus = false;
17887 this.restrictHeight();
17895 * Returns true if the dropdown list is expanded, else false.
17897 isExpanded : function(){
17898 return this.list.isVisible();
17902 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
17903 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
17904 * @param {String} value The data value of the item to select
17905 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
17906 * selected item if it is not currently in view (defaults to true)
17907 * @return {Boolean} True if the value matched an item in the list, else false
17909 selectByValue : function(v, scrollIntoView){
17910 if(v !== undefined && v !== null){
17911 var r = this.findRecord(this.valueField || this.displayField, v);
17913 this.select(this.store.indexOf(r), scrollIntoView);
17921 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
17922 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
17923 * @param {Number} index The zero-based index of the list item to select
17924 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
17925 * selected item if it is not currently in view (defaults to true)
17927 select : function(index, scrollIntoView){
17928 this.selectedIndex = index;
17929 this.view.select(index);
17930 if(scrollIntoView !== false){
17931 var el = this.view.getNode(index);
17933 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
17936 this.list.scrollChildIntoView(el, false);
17942 selectNext : function(){
17943 var ct = this.store.getCount();
17945 if(this.selectedIndex == -1){
17947 }else if(this.selectedIndex < ct-1){
17948 this.select(this.selectedIndex+1);
17954 selectPrev : function(){
17955 var ct = this.store.getCount();
17957 if(this.selectedIndex == -1){
17959 }else if(this.selectedIndex != 0){
17960 this.select(this.selectedIndex-1);
17966 onKeyUp : function(e){
17967 if(this.editable !== false && !e.isSpecialKey()){
17968 this.lastKey = e.getKey();
17969 this.dqTask.delay(this.queryDelay);
17974 validateBlur : function(){
17975 return !this.list || !this.list.isVisible();
17979 initQuery : function(){
17981 var v = this.getRawValue();
17983 if(this.tickable && this.editable){
17984 v = this.tickableInputEl().getValue();
17991 doForce : function(){
17992 if(this.inputEl().dom.value.length > 0){
17993 this.inputEl().dom.value =
17994 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
18000 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
18001 * query allowing the query action to be canceled if needed.
18002 * @param {String} query The SQL query to execute
18003 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
18004 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
18005 * saved in the current store (defaults to false)
18007 doQuery : function(q, forceAll){
18009 if(q === undefined || q === null){
18014 forceAll: forceAll,
18018 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
18023 forceAll = qe.forceAll;
18024 if(forceAll === true || (q.length >= this.minChars)){
18026 this.hasQuery = true;
18028 if(this.lastQuery != q || this.alwaysQuery){
18029 this.lastQuery = q;
18030 if(this.mode == 'local'){
18031 this.selectedIndex = -1;
18033 this.store.clearFilter();
18036 if(this.specialFilter){
18037 this.fireEvent('specialfilter', this);
18042 this.store.filter(this.displayField, q);
18045 this.store.fireEvent("datachanged", this.store);
18052 this.store.baseParams[this.queryParam] = q;
18054 var options = {params : this.getParams(q)};
18057 options.add = true;
18058 options.params.start = this.page * this.pageSize;
18061 this.store.load(options);
18064 * this code will make the page width larger, at the beginning, the list not align correctly,
18065 * we should expand the list on onLoad
18066 * so command out it
18071 this.selectedIndex = -1;
18076 this.loadNext = false;
18080 getParams : function(q){
18082 //p[this.queryParam] = q;
18086 p.limit = this.pageSize;
18092 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
18094 collapse : function(){
18095 if(!this.isExpanded()){
18101 this.hasFocus = false;
18105 this.cancelBtn.hide();
18106 this.trigger.show();
18109 this.tickableInputEl().dom.value = '';
18110 this.tickableInputEl().blur();
18115 Roo.get(document).un('mousedown', this.collapseIf, this);
18116 Roo.get(document).un('mousewheel', this.collapseIf, this);
18117 if (!this.editable) {
18118 Roo.get(document).un('keydown', this.listKeyPress, this);
18120 this.fireEvent('collapse', this);
18126 collapseIf : function(e){
18127 var in_combo = e.within(this.el);
18128 var in_list = e.within(this.list);
18129 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
18131 if (in_combo || in_list || is_list) {
18132 //e.stopPropagation();
18137 this.onTickableFooterButtonClick(e, false, false);
18145 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
18147 expand : function(){
18149 if(this.isExpanded() || !this.hasFocus){
18153 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
18154 this.list.setWidth(lw);
18160 this.restrictHeight();
18164 this.tickItems = Roo.apply([], this.item);
18167 this.cancelBtn.show();
18168 this.trigger.hide();
18171 this.tickableInputEl().focus();
18176 Roo.get(document).on('mousedown', this.collapseIf, this);
18177 Roo.get(document).on('mousewheel', this.collapseIf, this);
18178 if (!this.editable) {
18179 Roo.get(document).on('keydown', this.listKeyPress, this);
18182 this.fireEvent('expand', this);
18186 // Implements the default empty TriggerField.onTriggerClick function
18187 onTriggerClick : function(e)
18189 Roo.log('trigger click');
18191 if(this.disabled || !this.triggerList){
18196 this.loadNext = false;
18198 if(this.isExpanded()){
18200 if (!this.blockFocus) {
18201 this.inputEl().focus();
18205 this.hasFocus = true;
18206 if(this.triggerAction == 'all') {
18207 this.doQuery(this.allQuery, true);
18209 this.doQuery(this.getRawValue());
18211 if (!this.blockFocus) {
18212 this.inputEl().focus();
18217 onTickableTriggerClick : function(e)
18224 this.loadNext = false;
18225 this.hasFocus = true;
18227 if(this.triggerAction == 'all') {
18228 this.doQuery(this.allQuery, true);
18230 this.doQuery(this.getRawValue());
18234 onSearchFieldClick : function(e)
18236 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
18237 this.onTickableFooterButtonClick(e, false, false);
18241 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
18246 this.loadNext = false;
18247 this.hasFocus = true;
18249 if(this.triggerAction == 'all') {
18250 this.doQuery(this.allQuery, true);
18252 this.doQuery(this.getRawValue());
18256 listKeyPress : function(e)
18258 //Roo.log('listkeypress');
18259 // scroll to first matching element based on key pres..
18260 if (e.isSpecialKey()) {
18263 var k = String.fromCharCode(e.getKey()).toUpperCase();
18266 var csel = this.view.getSelectedNodes();
18267 var cselitem = false;
18269 var ix = this.view.indexOf(csel[0]);
18270 cselitem = this.store.getAt(ix);
18271 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
18277 this.store.each(function(v) {
18279 // start at existing selection.
18280 if (cselitem.id == v.id) {
18286 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
18287 match = this.store.indexOf(v);
18293 if (match === false) {
18294 return true; // no more action?
18297 this.view.select(match);
18298 var sn = Roo.get(this.view.getSelectedNodes()[0]);
18299 sn.scrollIntoView(sn.dom.parentNode, false);
18302 onViewScroll : function(e, t){
18304 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){
18308 this.hasQuery = true;
18310 this.loading = this.list.select('.loading', true).first();
18312 if(this.loading === null){
18313 this.list.createChild({
18315 cls: 'loading roo-select2-more-results roo-select2-active',
18316 html: 'Loading more results...'
18319 this.loading = this.list.select('.loading', true).first();
18321 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
18323 this.loading.hide();
18326 this.loading.show();
18331 this.loadNext = true;
18333 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
18338 addItem : function(o)
18340 var dv = ''; // display value
18342 if (this.displayField) {
18343 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
18345 // this is an error condition!!!
18346 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
18353 var choice = this.choices.createChild({
18355 cls: 'roo-select2-search-choice',
18364 cls: 'roo-select2-search-choice-close fa fa-times',
18369 }, this.searchField);
18371 var close = choice.select('a.roo-select2-search-choice-close', true).first();
18373 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
18381 this.inputEl().dom.value = '';
18386 onRemoveItem : function(e, _self, o)
18388 e.preventDefault();
18390 this.lastItem = Roo.apply([], this.item);
18392 var index = this.item.indexOf(o.data) * 1;
18395 Roo.log('not this item?!');
18399 this.item.splice(index, 1);
18404 this.fireEvent('remove', this, e);
18410 syncValue : function()
18412 if(!this.item.length){
18419 Roo.each(this.item, function(i){
18420 if(_this.valueField){
18421 value.push(i[_this.valueField]);
18428 this.value = value.join(',');
18430 if(this.hiddenField){
18431 this.hiddenField.dom.value = this.value;
18434 this.store.fireEvent("datachanged", this.store);
18439 clearItem : function()
18441 if(!this.multiple){
18447 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
18455 if(this.tickable && !Roo.isTouch){
18456 this.view.refresh();
18460 inputEl: function ()
18462 if(Roo.isIOS && this.useNativeIOS){
18463 return this.el.select('select.roo-ios-select', true).first();
18466 if(Roo.isTouch && this.mobileTouchView){
18467 return this.el.select('input.form-control',true).first();
18471 return this.searchField;
18474 return this.el.select('input.form-control',true).first();
18477 onTickableFooterButtonClick : function(e, btn, el)
18479 e.preventDefault();
18481 this.lastItem = Roo.apply([], this.item);
18483 if(btn && btn.name == 'cancel'){
18484 this.tickItems = Roo.apply([], this.item);
18493 Roo.each(this.tickItems, function(o){
18501 validate : function()
18503 if(this.getVisibilityEl().hasClass('hidden')){
18507 var v = this.getRawValue();
18510 v = this.getValue();
18513 if(this.disabled || this.allowBlank || v.length){
18518 this.markInvalid();
18522 tickableInputEl : function()
18524 if(!this.tickable || !this.editable){
18525 return this.inputEl();
18528 return this.inputEl().select('.roo-select2-search-field-input', true).first();
18532 getAutoCreateTouchView : function()
18537 cls: 'form-group' //input-group
18543 type : this.inputType,
18544 cls : 'form-control x-combo-noedit',
18545 autocomplete: 'new-password',
18546 placeholder : this.placeholder || '',
18551 input.name = this.name;
18555 input.cls += ' input-' + this.size;
18558 if (this.disabled) {
18559 input.disabled = true;
18563 cls : 'roo-combobox-wrap',
18570 inputblock.cls += ' input-group';
18572 inputblock.cn.unshift({
18574 cls : 'input-group-addon input-group-prepend input-group-text',
18579 if(this.removable && !this.multiple){
18580 inputblock.cls += ' roo-removable';
18582 inputblock.cn.push({
18585 cls : 'roo-combo-removable-btn close'
18589 if(this.hasFeedback && !this.allowBlank){
18591 inputblock.cls += ' has-feedback';
18593 inputblock.cn.push({
18595 cls: 'glyphicon form-control-feedback'
18602 inputblock.cls += (this.before) ? '' : ' input-group';
18604 inputblock.cn.push({
18606 cls : 'input-group-addon input-group-append input-group-text',
18612 var ibwrap = inputblock;
18617 cls: 'roo-select2-choices',
18621 cls: 'roo-select2-search-field',
18634 cls: 'roo-select2-container input-group roo-touchview-combobox ',
18639 cls: 'form-hidden-field'
18645 if(!this.multiple && this.showToggleBtn){
18651 if (this.caret != false) {
18654 cls: 'fa fa-' + this.caret
18661 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
18663 Roo.bootstrap.version == 3 ? caret : '',
18666 cls: 'combobox-clear',
18680 combobox.cls += ' roo-select2-container-multi';
18683 var required = this.allowBlank ? {
18685 style: 'display: none'
18688 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
18689 tooltip : 'This field is required'
18692 var align = this.labelAlign || this.parentLabelAlign();
18694 if (align ==='left' && this.fieldLabel.length) {
18700 cls : 'control-label col-form-label',
18701 html : this.fieldLabel
18705 cls : 'roo-combobox-wrap ',
18712 var labelCfg = cfg.cn[1];
18713 var contentCfg = cfg.cn[2];
18716 if(this.indicatorpos == 'right'){
18721 cls : 'control-label col-form-label',
18725 html : this.fieldLabel
18731 cls : "roo-combobox-wrap ",
18739 labelCfg = cfg.cn[0];
18740 contentCfg = cfg.cn[1];
18745 if(this.labelWidth > 12){
18746 labelCfg.style = "width: " + this.labelWidth + 'px';
18749 if(this.labelWidth < 13 && this.labelmd == 0){
18750 this.labelmd = this.labelWidth;
18753 if(this.labellg > 0){
18754 labelCfg.cls += ' col-lg-' + this.labellg;
18755 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
18758 if(this.labelmd > 0){
18759 labelCfg.cls += ' col-md-' + this.labelmd;
18760 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
18763 if(this.labelsm > 0){
18764 labelCfg.cls += ' col-sm-' + this.labelsm;
18765 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
18768 if(this.labelxs > 0){
18769 labelCfg.cls += ' col-xs-' + this.labelxs;
18770 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
18774 } else if ( this.fieldLabel.length) {
18779 cls : 'control-label',
18780 html : this.fieldLabel
18791 if(this.indicatorpos == 'right'){
18795 cls : 'control-label',
18796 html : this.fieldLabel,
18814 var settings = this;
18816 ['xs','sm','md','lg'].map(function(size){
18817 if (settings[size]) {
18818 cfg.cls += ' col-' + size + '-' + settings[size];
18825 initTouchView : function()
18827 this.renderTouchView();
18829 this.touchViewEl.on('scroll', function(){
18830 this.el.dom.scrollTop = 0;
18833 this.originalValue = this.getValue();
18835 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
18837 this.inputEl().on("click", this.showTouchView, this);
18838 if (this.triggerEl) {
18839 this.triggerEl.on("click", this.showTouchView, this);
18843 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
18844 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
18846 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
18848 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
18849 this.store.on('load', this.onTouchViewLoad, this);
18850 this.store.on('loadexception', this.onTouchViewLoadException, this);
18852 if(this.hiddenName){
18854 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
18856 this.hiddenField.dom.value =
18857 this.hiddenValue !== undefined ? this.hiddenValue :
18858 this.value !== undefined ? this.value : '';
18860 this.el.dom.removeAttribute('name');
18861 this.hiddenField.dom.setAttribute('name', this.hiddenName);
18865 this.choices = this.el.select('ul.roo-select2-choices', true).first();
18866 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
18869 if(this.removable && !this.multiple){
18870 var close = this.closeTriggerEl();
18872 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
18873 close.on('click', this.removeBtnClick, this, close);
18877 * fix the bug in Safari iOS8
18879 this.inputEl().on("focus", function(e){
18880 document.activeElement.blur();
18883 this._touchViewMask = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
18890 renderTouchView : function()
18892 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
18893 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18895 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
18896 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18898 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
18899 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18900 this.touchViewBodyEl.setStyle('overflow', 'auto');
18902 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
18903 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18905 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
18906 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18910 showTouchView : function()
18916 this.touchViewHeaderEl.hide();
18918 if(this.modalTitle.length){
18919 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
18920 this.touchViewHeaderEl.show();
18923 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
18924 this.touchViewEl.show();
18926 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
18928 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
18929 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
18931 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
18933 if(this.modalTitle.length){
18934 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
18937 this.touchViewBodyEl.setHeight(bodyHeight);
18941 (function(){ _this.touchViewEl.addClass(['in','show']); }).defer(50);
18943 this.touchViewEl.addClass(['in','show']);
18946 if(this._touchViewMask){
18947 Roo.get(document.body).addClass("x-body-masked");
18948 this._touchViewMask.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
18949 this._touchViewMask.setStyle('z-index', 10000);
18950 this._touchViewMask.addClass('show');
18953 this.doTouchViewQuery();
18957 hideTouchView : function()
18959 this.touchViewEl.removeClass(['in','show']);
18963 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
18965 this.touchViewEl.setStyle('display', 'none');
18968 if(this._touchViewMask){
18969 this._touchViewMask.removeClass('show');
18970 Roo.get(document.body).removeClass("x-body-masked");
18974 setTouchViewValue : function()
18981 Roo.each(this.tickItems, function(o){
18986 this.hideTouchView();
18989 doTouchViewQuery : function()
18998 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
19002 if(!this.alwaysQuery || this.mode == 'local'){
19003 this.onTouchViewLoad();
19010 onTouchViewBeforeLoad : function(combo,opts)
19016 onTouchViewLoad : function()
19018 if(this.store.getCount() < 1){
19019 this.onTouchViewEmptyResults();
19023 this.clearTouchView();
19025 var rawValue = this.getRawValue();
19027 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
19029 this.tickItems = [];
19031 this.store.data.each(function(d, rowIndex){
19032 var row = this.touchViewListGroup.createChild(template);
19034 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
19035 row.addClass(d.data.cls);
19038 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
19041 html : d.data[this.displayField]
19044 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
19045 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
19048 row.removeClass('selected');
19049 if(!this.multiple && this.valueField &&
19050 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
19053 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
19054 row.addClass('selected');
19057 if(this.multiple && this.valueField &&
19058 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
19062 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
19063 this.tickItems.push(d.data);
19066 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
19070 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
19072 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
19074 if(this.modalTitle.length){
19075 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
19078 var listHeight = this.touchViewListGroup.getHeight() + this.touchViewBodyEl.getPadding('tb') * 2;
19080 if(this.mobile_restrict_height && listHeight < bodyHeight){
19081 this.touchViewBodyEl.setHeight(listHeight);
19086 if(firstChecked && listHeight > bodyHeight){
19087 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
19092 onTouchViewLoadException : function()
19094 this.hideTouchView();
19097 onTouchViewEmptyResults : function()
19099 this.clearTouchView();
19101 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
19103 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
19107 clearTouchView : function()
19109 this.touchViewListGroup.dom.innerHTML = '';
19112 onTouchViewClick : function(e, el, o)
19114 e.preventDefault();
19117 var rowIndex = o.rowIndex;
19119 var r = this.store.getAt(rowIndex);
19121 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
19123 if(!this.multiple){
19124 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
19125 c.dom.removeAttribute('checked');
19128 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
19130 this.setFromData(r.data);
19132 var close = this.closeTriggerEl();
19138 this.hideTouchView();
19140 this.fireEvent('select', this, r, rowIndex);
19145 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
19146 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
19147 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
19151 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
19152 this.addItem(r.data);
19153 this.tickItems.push(r.data);
19157 getAutoCreateNativeIOS : function()
19160 cls: 'form-group' //input-group,
19165 cls : 'roo-ios-select'
19169 combobox.name = this.name;
19172 if (this.disabled) {
19173 combobox.disabled = true;
19176 var settings = this;
19178 ['xs','sm','md','lg'].map(function(size){
19179 if (settings[size]) {
19180 cfg.cls += ' col-' + size + '-' + settings[size];
19190 initIOSView : function()
19192 this.store.on('load', this.onIOSViewLoad, this);
19197 onIOSViewLoad : function()
19199 if(this.store.getCount() < 1){
19203 this.clearIOSView();
19205 if(this.allowBlank) {
19207 var default_text = '-- SELECT --';
19209 if(this.placeholder.length){
19210 default_text = this.placeholder;
19213 if(this.emptyTitle.length){
19214 default_text += ' - ' + this.emptyTitle + ' -';
19217 var opt = this.inputEl().createChild({
19220 html : default_text
19224 o[this.valueField] = 0;
19225 o[this.displayField] = default_text;
19227 this.ios_options.push({
19234 this.store.data.each(function(d, rowIndex){
19238 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
19239 html = d.data[this.displayField];
19244 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
19245 value = d.data[this.valueField];
19254 if(this.value == d.data[this.valueField]){
19255 option['selected'] = true;
19258 var opt = this.inputEl().createChild(option);
19260 this.ios_options.push({
19267 this.inputEl().on('change', function(){
19268 this.fireEvent('select', this);
19273 clearIOSView: function()
19275 this.inputEl().dom.innerHTML = '';
19277 this.ios_options = [];
19280 setIOSValue: function(v)
19284 if(!this.ios_options){
19288 Roo.each(this.ios_options, function(opts){
19290 opts.el.dom.removeAttribute('selected');
19292 if(opts.data[this.valueField] != v){
19296 opts.el.dom.setAttribute('selected', true);
19302 * @cfg {Boolean} grow
19306 * @cfg {Number} growMin
19310 * @cfg {Number} growMax
19319 Roo.apply(Roo.bootstrap.ComboBox, {
19323 cls: 'modal-header',
19345 cls: 'list-group-item',
19349 cls: 'roo-combobox-list-group-item-value'
19353 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
19367 listItemCheckbox : {
19369 cls: 'list-group-item',
19373 cls: 'roo-combobox-list-group-item-value'
19377 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
19393 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
19398 cls: 'modal-footer',
19406 cls: 'col-xs-6 text-left',
19409 cls: 'btn btn-danger roo-touch-view-cancel',
19415 cls: 'col-xs-6 text-right',
19418 cls: 'btn btn-success roo-touch-view-ok',
19429 Roo.apply(Roo.bootstrap.ComboBox, {
19431 touchViewTemplate : {
19433 cls: 'modal fade roo-combobox-touch-view',
19437 cls: 'modal-dialog',
19438 style : 'position:fixed', // we have to fix position....
19442 cls: 'modal-content',
19444 Roo.bootstrap.ComboBox.header,
19445 Roo.bootstrap.ComboBox.body,
19446 Roo.bootstrap.ComboBox.footer
19455 * Ext JS Library 1.1.1
19456 * Copyright(c) 2006-2007, Ext JS, LLC.
19458 * Originally Released Under LGPL - original licence link has changed is not relivant.
19461 * <script type="text/javascript">
19466 * @extends Roo.util.Observable
19467 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
19468 * This class also supports single and multi selection modes. <br>
19469 * Create a data model bound view:
19471 var store = new Roo.data.Store(...);
19473 var view = new Roo.View({
19475 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
19477 singleSelect: true,
19478 selectedClass: "ydataview-selected",
19482 // listen for node click?
19483 view.on("click", function(vw, index, node, e){
19484 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
19488 dataModel.load("foobar.xml");
19490 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
19492 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
19493 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
19495 * Note: old style constructor is still suported (container, template, config)
19498 * Create a new View
19499 * @param {Object} config The config object
19502 Roo.View = function(config, depreciated_tpl, depreciated_config){
19504 this.parent = false;
19506 if (typeof(depreciated_tpl) == 'undefined') {
19507 // new way.. - universal constructor.
19508 Roo.apply(this, config);
19509 this.el = Roo.get(this.el);
19512 this.el = Roo.get(config);
19513 this.tpl = depreciated_tpl;
19514 Roo.apply(this, depreciated_config);
19516 this.wrapEl = this.el.wrap().wrap();
19517 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
19520 if(typeof(this.tpl) == "string"){
19521 this.tpl = new Roo.Template(this.tpl);
19523 // support xtype ctors..
19524 this.tpl = new Roo.factory(this.tpl, Roo);
19528 this.tpl.compile();
19533 * @event beforeclick
19534 * Fires before a click is processed. Returns false to cancel the default action.
19535 * @param {Roo.View} this
19536 * @param {Number} index The index of the target node
19537 * @param {HTMLElement} node The target node
19538 * @param {Roo.EventObject} e The raw event object
19540 "beforeclick" : true,
19543 * Fires when a template node is clicked.
19544 * @param {Roo.View} this
19545 * @param {Number} index The index of the target node
19546 * @param {HTMLElement} node The target node
19547 * @param {Roo.EventObject} e The raw event object
19552 * Fires when a template node is double clicked.
19553 * @param {Roo.View} this
19554 * @param {Number} index The index of the target node
19555 * @param {HTMLElement} node The target node
19556 * @param {Roo.EventObject} e The raw event object
19560 * @event contextmenu
19561 * Fires when a template node is right clicked.
19562 * @param {Roo.View} this
19563 * @param {Number} index The index of the target node
19564 * @param {HTMLElement} node The target node
19565 * @param {Roo.EventObject} e The raw event object
19567 "contextmenu" : true,
19569 * @event selectionchange
19570 * Fires when the selected nodes change.
19571 * @param {Roo.View} this
19572 * @param {Array} selections Array of the selected nodes
19574 "selectionchange" : true,
19577 * @event beforeselect
19578 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
19579 * @param {Roo.View} this
19580 * @param {HTMLElement} node The node to be selected
19581 * @param {Array} selections Array of currently selected nodes
19583 "beforeselect" : true,
19585 * @event preparedata
19586 * Fires on every row to render, to allow you to change the data.
19587 * @param {Roo.View} this
19588 * @param {Object} data to be rendered (change this)
19590 "preparedata" : true
19598 "click": this.onClick,
19599 "dblclick": this.onDblClick,
19600 "contextmenu": this.onContextMenu,
19604 this.selections = [];
19606 this.cmp = new Roo.CompositeElementLite([]);
19608 this.store = Roo.factory(this.store, Roo.data);
19609 this.setStore(this.store, true);
19612 if ( this.footer && this.footer.xtype) {
19614 var fctr = this.wrapEl.appendChild(document.createElement("div"));
19616 this.footer.dataSource = this.store;
19617 this.footer.container = fctr;
19618 this.footer = Roo.factory(this.footer, Roo);
19619 fctr.insertFirst(this.el);
19621 // this is a bit insane - as the paging toolbar seems to detach the el..
19622 // dom.parentNode.parentNode.parentNode
19623 // they get detached?
19627 Roo.View.superclass.constructor.call(this);
19632 Roo.extend(Roo.View, Roo.util.Observable, {
19635 * @cfg {Roo.data.Store} store Data store to load data from.
19640 * @cfg {String|Roo.Element} el The container element.
19645 * @cfg {String|Roo.Template} tpl The template used by this View
19649 * @cfg {String} dataName the named area of the template to use as the data area
19650 * Works with domtemplates roo-name="name"
19654 * @cfg {String} selectedClass The css class to add to selected nodes
19656 selectedClass : "x-view-selected",
19658 * @cfg {String} emptyText The empty text to show when nothing is loaded.
19663 * @cfg {String} text to display on mask (default Loading)
19667 * @cfg {Boolean} multiSelect Allow multiple selection
19669 multiSelect : false,
19671 * @cfg {Boolean} singleSelect Allow single selection
19673 singleSelect: false,
19676 * @cfg {Boolean} toggleSelect - selecting
19678 toggleSelect : false,
19681 * @cfg {Boolean} tickable - selecting
19686 * Returns the element this view is bound to.
19687 * @return {Roo.Element}
19689 getEl : function(){
19690 return this.wrapEl;
19696 * Refreshes the view. - called by datachanged on the store. - do not call directly.
19698 refresh : function(){
19699 //Roo.log('refresh');
19702 // if we are using something like 'domtemplate', then
19703 // the what gets used is:
19704 // t.applySubtemplate(NAME, data, wrapping data..)
19705 // the outer template then get' applied with
19706 // the store 'extra data'
19707 // and the body get's added to the
19708 // roo-name="data" node?
19709 // <span class='roo-tpl-{name}'></span> ?????
19713 this.clearSelections();
19714 this.el.update("");
19716 var records = this.store.getRange();
19717 if(records.length < 1) {
19719 // is this valid?? = should it render a template??
19721 this.el.update(this.emptyText);
19725 if (this.dataName) {
19726 this.el.update(t.apply(this.store.meta)); //????
19727 el = this.el.child('.roo-tpl-' + this.dataName);
19730 for(var i = 0, len = records.length; i < len; i++){
19731 var data = this.prepareData(records[i].data, i, records[i]);
19732 this.fireEvent("preparedata", this, data, i, records[i]);
19734 var d = Roo.apply({}, data);
19737 Roo.apply(d, {'roo-id' : Roo.id()});
19741 Roo.each(this.parent.item, function(item){
19742 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
19745 Roo.apply(d, {'roo-data-checked' : 'checked'});
19749 html[html.length] = Roo.util.Format.trim(
19751 t.applySubtemplate(this.dataName, d, this.store.meta) :
19758 el.update(html.join(""));
19759 this.nodes = el.dom.childNodes;
19760 this.updateIndexes(0);
19765 * Function to override to reformat the data that is sent to
19766 * the template for each node.
19767 * DEPRICATED - use the preparedata event handler.
19768 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
19769 * a JSON object for an UpdateManager bound view).
19771 prepareData : function(data, index, record)
19773 this.fireEvent("preparedata", this, data, index, record);
19777 onUpdate : function(ds, record){
19778 // Roo.log('on update');
19779 this.clearSelections();
19780 var index = this.store.indexOf(record);
19781 var n = this.nodes[index];
19782 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
19783 n.parentNode.removeChild(n);
19784 this.updateIndexes(index, index);
19790 onAdd : function(ds, records, index)
19792 //Roo.log(['on Add', ds, records, index] );
19793 this.clearSelections();
19794 if(this.nodes.length == 0){
19798 var n = this.nodes[index];
19799 for(var i = 0, len = records.length; i < len; i++){
19800 var d = this.prepareData(records[i].data, i, records[i]);
19802 this.tpl.insertBefore(n, d);
19805 this.tpl.append(this.el, d);
19808 this.updateIndexes(index);
19811 onRemove : function(ds, record, index){
19812 // Roo.log('onRemove');
19813 this.clearSelections();
19814 var el = this.dataName ?
19815 this.el.child('.roo-tpl-' + this.dataName) :
19818 el.dom.removeChild(this.nodes[index]);
19819 this.updateIndexes(index);
19823 * Refresh an individual node.
19824 * @param {Number} index
19826 refreshNode : function(index){
19827 this.onUpdate(this.store, this.store.getAt(index));
19830 updateIndexes : function(startIndex, endIndex){
19831 var ns = this.nodes;
19832 startIndex = startIndex || 0;
19833 endIndex = endIndex || ns.length - 1;
19834 for(var i = startIndex; i <= endIndex; i++){
19835 ns[i].nodeIndex = i;
19840 * Changes the data store this view uses and refresh the view.
19841 * @param {Store} store
19843 setStore : function(store, initial){
19844 if(!initial && this.store){
19845 this.store.un("datachanged", this.refresh);
19846 this.store.un("add", this.onAdd);
19847 this.store.un("remove", this.onRemove);
19848 this.store.un("update", this.onUpdate);
19849 this.store.un("clear", this.refresh);
19850 this.store.un("beforeload", this.onBeforeLoad);
19851 this.store.un("load", this.onLoad);
19852 this.store.un("loadexception", this.onLoad);
19856 store.on("datachanged", this.refresh, this);
19857 store.on("add", this.onAdd, this);
19858 store.on("remove", this.onRemove, this);
19859 store.on("update", this.onUpdate, this);
19860 store.on("clear", this.refresh, this);
19861 store.on("beforeload", this.onBeforeLoad, this);
19862 store.on("load", this.onLoad, this);
19863 store.on("loadexception", this.onLoad, this);
19871 * onbeforeLoad - masks the loading area.
19874 onBeforeLoad : function(store,opts)
19876 //Roo.log('onBeforeLoad');
19878 this.el.update("");
19880 this.el.mask(this.mask ? this.mask : "Loading" );
19882 onLoad : function ()
19889 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
19890 * @param {HTMLElement} node
19891 * @return {HTMLElement} The template node
19893 findItemFromChild : function(node){
19894 var el = this.dataName ?
19895 this.el.child('.roo-tpl-' + this.dataName,true) :
19898 if(!node || node.parentNode == el){
19901 var p = node.parentNode;
19902 while(p && p != el){
19903 if(p.parentNode == el){
19912 onClick : function(e){
19913 var item = this.findItemFromChild(e.getTarget());
19915 var index = this.indexOf(item);
19916 if(this.onItemClick(item, index, e) !== false){
19917 this.fireEvent("click", this, index, item, e);
19920 this.clearSelections();
19925 onContextMenu : function(e){
19926 var item = this.findItemFromChild(e.getTarget());
19928 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
19933 onDblClick : function(e){
19934 var item = this.findItemFromChild(e.getTarget());
19936 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
19940 onItemClick : function(item, index, e)
19942 if(this.fireEvent("beforeclick", this, index, item, e) === false){
19945 if (this.toggleSelect) {
19946 var m = this.isSelected(item) ? 'unselect' : 'select';
19949 _t[m](item, true, false);
19952 if(this.multiSelect || this.singleSelect){
19953 if(this.multiSelect && e.shiftKey && this.lastSelection){
19954 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
19956 this.select(item, this.multiSelect && e.ctrlKey);
19957 this.lastSelection = item;
19960 if(!this.tickable){
19961 e.preventDefault();
19969 * Get the number of selected nodes.
19972 getSelectionCount : function(){
19973 return this.selections.length;
19977 * Get the currently selected nodes.
19978 * @return {Array} An array of HTMLElements
19980 getSelectedNodes : function(){
19981 return this.selections;
19985 * Get the indexes of the selected nodes.
19988 getSelectedIndexes : function(){
19989 var indexes = [], s = this.selections;
19990 for(var i = 0, len = s.length; i < len; i++){
19991 indexes.push(s[i].nodeIndex);
19997 * Clear all selections
19998 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
20000 clearSelections : function(suppressEvent){
20001 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
20002 this.cmp.elements = this.selections;
20003 this.cmp.removeClass(this.selectedClass);
20004 this.selections = [];
20005 if(!suppressEvent){
20006 this.fireEvent("selectionchange", this, this.selections);
20012 * Returns true if the passed node is selected
20013 * @param {HTMLElement/Number} node The node or node index
20014 * @return {Boolean}
20016 isSelected : function(node){
20017 var s = this.selections;
20021 node = this.getNode(node);
20022 return s.indexOf(node) !== -1;
20027 * @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
20028 * @param {Boolean} keepExisting (optional) true to keep existing selections
20029 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
20031 select : function(nodeInfo, keepExisting, suppressEvent){
20032 if(nodeInfo instanceof Array){
20034 this.clearSelections(true);
20036 for(var i = 0, len = nodeInfo.length; i < len; i++){
20037 this.select(nodeInfo[i], true, true);
20041 var node = this.getNode(nodeInfo);
20042 if(!node || this.isSelected(node)){
20043 return; // already selected.
20046 this.clearSelections(true);
20049 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
20050 Roo.fly(node).addClass(this.selectedClass);
20051 this.selections.push(node);
20052 if(!suppressEvent){
20053 this.fireEvent("selectionchange", this, this.selections);
20061 * @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
20062 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
20063 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
20065 unselect : function(nodeInfo, keepExisting, suppressEvent)
20067 if(nodeInfo instanceof Array){
20068 Roo.each(this.selections, function(s) {
20069 this.unselect(s, nodeInfo);
20073 var node = this.getNode(nodeInfo);
20074 if(!node || !this.isSelected(node)){
20075 //Roo.log("not selected");
20076 return; // not selected.
20080 Roo.each(this.selections, function(s) {
20082 Roo.fly(node).removeClass(this.selectedClass);
20089 this.selections= ns;
20090 this.fireEvent("selectionchange", this, this.selections);
20094 * Gets a template node.
20095 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
20096 * @return {HTMLElement} The node or null if it wasn't found
20098 getNode : function(nodeInfo){
20099 if(typeof nodeInfo == "string"){
20100 return document.getElementById(nodeInfo);
20101 }else if(typeof nodeInfo == "number"){
20102 return this.nodes[nodeInfo];
20108 * Gets a range template nodes.
20109 * @param {Number} startIndex
20110 * @param {Number} endIndex
20111 * @return {Array} An array of nodes
20113 getNodes : function(start, end){
20114 var ns = this.nodes;
20115 start = start || 0;
20116 end = typeof end == "undefined" ? ns.length - 1 : end;
20119 for(var i = start; i <= end; i++){
20123 for(var i = start; i >= end; i--){
20131 * Finds the index of the passed node
20132 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
20133 * @return {Number} The index of the node or -1
20135 indexOf : function(node){
20136 node = this.getNode(node);
20137 if(typeof node.nodeIndex == "number"){
20138 return node.nodeIndex;
20140 var ns = this.nodes;
20141 for(var i = 0, len = ns.length; i < len; i++){
20152 * based on jquery fullcalendar
20156 Roo.bootstrap = Roo.bootstrap || {};
20158 * @class Roo.bootstrap.Calendar
20159 * @extends Roo.bootstrap.Component
20160 * Bootstrap Calendar class
20161 * @cfg {Boolean} loadMask (true|false) default false
20162 * @cfg {Object} header generate the user specific header of the calendar, default false
20165 * Create a new Container
20166 * @param {Object} config The config object
20171 Roo.bootstrap.Calendar = function(config){
20172 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
20176 * Fires when a date is selected
20177 * @param {DatePicker} this
20178 * @param {Date} date The selected date
20182 * @event monthchange
20183 * Fires when the displayed month changes
20184 * @param {DatePicker} this
20185 * @param {Date} date The selected month
20187 'monthchange': true,
20189 * @event evententer
20190 * Fires when mouse over an event
20191 * @param {Calendar} this
20192 * @param {event} Event
20194 'evententer': true,
20196 * @event eventleave
20197 * Fires when the mouse leaves an
20198 * @param {Calendar} this
20201 'eventleave': true,
20203 * @event eventclick
20204 * Fires when the mouse click an
20205 * @param {Calendar} this
20214 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
20217 * @cfg {Roo.data.Store} store
20218 * The data source for the calendar
20222 * @cfg {Number} startDay
20223 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
20231 getAutoCreate : function(){
20234 var fc_button = function(name, corner, style, content ) {
20235 return Roo.apply({},{
20237 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
20239 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
20242 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
20253 style : 'width:100%',
20260 cls : 'fc-header-left',
20262 fc_button('prev', 'left', 'arrow', '‹' ),
20263 fc_button('next', 'right', 'arrow', '›' ),
20264 { tag: 'span', cls: 'fc-header-space' },
20265 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
20273 cls : 'fc-header-center',
20277 cls: 'fc-header-title',
20280 html : 'month / year'
20288 cls : 'fc-header-right',
20290 /* fc_button('month', 'left', '', 'month' ),
20291 fc_button('week', '', '', 'week' ),
20292 fc_button('day', 'right', '', 'day' )
20304 header = this.header;
20307 var cal_heads = function() {
20309 // fixme - handle this.
20311 for (var i =0; i < Date.dayNames.length; i++) {
20312 var d = Date.dayNames[i];
20315 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
20316 html : d.substring(0,3)
20320 ret[0].cls += ' fc-first';
20321 ret[6].cls += ' fc-last';
20324 var cal_cell = function(n) {
20327 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
20332 cls: 'fc-day-number',
20336 cls: 'fc-day-content',
20340 style: 'position: relative;' // height: 17px;
20352 var cal_rows = function() {
20355 for (var r = 0; r < 6; r++) {
20362 for (var i =0; i < Date.dayNames.length; i++) {
20363 var d = Date.dayNames[i];
20364 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
20367 row.cn[0].cls+=' fc-first';
20368 row.cn[0].cn[0].style = 'min-height:90px';
20369 row.cn[6].cls+=' fc-last';
20373 ret[0].cls += ' fc-first';
20374 ret[4].cls += ' fc-prev-last';
20375 ret[5].cls += ' fc-last';
20382 cls: 'fc-border-separate',
20383 style : 'width:100%',
20391 cls : 'fc-first fc-last',
20409 cls : 'fc-content',
20410 style : "position: relative;",
20413 cls : 'fc-view fc-view-month fc-grid',
20414 style : 'position: relative',
20415 unselectable : 'on',
20418 cls : 'fc-event-container',
20419 style : 'position:absolute;z-index:8;top:0;left:0;'
20437 initEvents : function()
20440 throw "can not find store for calendar";
20446 style: "text-align:center",
20450 style: "background-color:white;width:50%;margin:250 auto",
20454 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
20465 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
20467 var size = this.el.select('.fc-content', true).first().getSize();
20468 this.maskEl.setSize(size.width, size.height);
20469 this.maskEl.enableDisplayMode("block");
20470 if(!this.loadMask){
20471 this.maskEl.hide();
20474 this.store = Roo.factory(this.store, Roo.data);
20475 this.store.on('load', this.onLoad, this);
20476 this.store.on('beforeload', this.onBeforeLoad, this);
20480 this.cells = this.el.select('.fc-day',true);
20481 //Roo.log(this.cells);
20482 this.textNodes = this.el.query('.fc-day-number');
20483 this.cells.addClassOnOver('fc-state-hover');
20485 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
20486 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
20487 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
20488 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
20490 this.on('monthchange', this.onMonthChange, this);
20492 this.update(new Date().clearTime());
20495 resize : function() {
20496 var sz = this.el.getSize();
20498 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
20499 this.el.select('.fc-day-content div',true).setHeight(34);
20504 showPrevMonth : function(e){
20505 this.update(this.activeDate.add("mo", -1));
20507 showToday : function(e){
20508 this.update(new Date().clearTime());
20511 showNextMonth : function(e){
20512 this.update(this.activeDate.add("mo", 1));
20516 showPrevYear : function(){
20517 this.update(this.activeDate.add("y", -1));
20521 showNextYear : function(){
20522 this.update(this.activeDate.add("y", 1));
20527 update : function(date)
20529 var vd = this.activeDate;
20530 this.activeDate = date;
20531 // if(vd && this.el){
20532 // var t = date.getTime();
20533 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
20534 // Roo.log('using add remove');
20536 // this.fireEvent('monthchange', this, date);
20538 // this.cells.removeClass("fc-state-highlight");
20539 // this.cells.each(function(c){
20540 // if(c.dateValue == t){
20541 // c.addClass("fc-state-highlight");
20542 // setTimeout(function(){
20543 // try{c.dom.firstChild.focus();}catch(e){}
20553 var days = date.getDaysInMonth();
20555 var firstOfMonth = date.getFirstDateOfMonth();
20556 var startingPos = firstOfMonth.getDay()-this.startDay;
20558 if(startingPos < this.startDay){
20562 var pm = date.add(Date.MONTH, -1);
20563 var prevStart = pm.getDaysInMonth()-startingPos;
20565 this.cells = this.el.select('.fc-day',true);
20566 this.textNodes = this.el.query('.fc-day-number');
20567 this.cells.addClassOnOver('fc-state-hover');
20569 var cells = this.cells.elements;
20570 var textEls = this.textNodes;
20572 Roo.each(cells, function(cell){
20573 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
20576 days += startingPos;
20578 // convert everything to numbers so it's fast
20579 var day = 86400000;
20580 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
20583 //Roo.log(prevStart);
20585 var today = new Date().clearTime().getTime();
20586 var sel = date.clearTime().getTime();
20587 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
20588 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
20589 var ddMatch = this.disabledDatesRE;
20590 var ddText = this.disabledDatesText;
20591 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
20592 var ddaysText = this.disabledDaysText;
20593 var format = this.format;
20595 var setCellClass = function(cal, cell){
20599 //Roo.log('set Cell Class');
20601 var t = d.getTime();
20605 cell.dateValue = t;
20607 cell.className += " fc-today";
20608 cell.className += " fc-state-highlight";
20609 cell.title = cal.todayText;
20612 // disable highlight in other month..
20613 //cell.className += " fc-state-highlight";
20618 cell.className = " fc-state-disabled";
20619 cell.title = cal.minText;
20623 cell.className = " fc-state-disabled";
20624 cell.title = cal.maxText;
20628 if(ddays.indexOf(d.getDay()) != -1){
20629 cell.title = ddaysText;
20630 cell.className = " fc-state-disabled";
20633 if(ddMatch && format){
20634 var fvalue = d.dateFormat(format);
20635 if(ddMatch.test(fvalue)){
20636 cell.title = ddText.replace("%0", fvalue);
20637 cell.className = " fc-state-disabled";
20641 if (!cell.initialClassName) {
20642 cell.initialClassName = cell.dom.className;
20645 cell.dom.className = cell.initialClassName + ' ' + cell.className;
20650 for(; i < startingPos; i++) {
20651 textEls[i].innerHTML = (++prevStart);
20652 d.setDate(d.getDate()+1);
20654 cells[i].className = "fc-past fc-other-month";
20655 setCellClass(this, cells[i]);
20660 for(; i < days; i++){
20661 intDay = i - startingPos + 1;
20662 textEls[i].innerHTML = (intDay);
20663 d.setDate(d.getDate()+1);
20665 cells[i].className = ''; // "x-date-active";
20666 setCellClass(this, cells[i]);
20670 for(; i < 42; i++) {
20671 textEls[i].innerHTML = (++extraDays);
20672 d.setDate(d.getDate()+1);
20674 cells[i].className = "fc-future fc-other-month";
20675 setCellClass(this, cells[i]);
20678 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
20680 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
20682 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
20683 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
20685 if(totalRows != 6){
20686 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
20687 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
20690 this.fireEvent('monthchange', this, date);
20694 if(!this.internalRender){
20695 var main = this.el.dom.firstChild;
20696 var w = main.offsetWidth;
20697 this.el.setWidth(w + this.el.getBorderWidth("lr"));
20698 Roo.fly(main).setWidth(w);
20699 this.internalRender = true;
20700 // opera does not respect the auto grow header center column
20701 // then, after it gets a width opera refuses to recalculate
20702 // without a second pass
20703 if(Roo.isOpera && !this.secondPass){
20704 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
20705 this.secondPass = true;
20706 this.update.defer(10, this, [date]);
20713 findCell : function(dt) {
20714 dt = dt.clearTime().getTime();
20716 this.cells.each(function(c){
20717 //Roo.log("check " +c.dateValue + '?=' + dt);
20718 if(c.dateValue == dt){
20728 findCells : function(ev) {
20729 var s = ev.start.clone().clearTime().getTime();
20731 var e= ev.end.clone().clearTime().getTime();
20734 this.cells.each(function(c){
20735 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
20737 if(c.dateValue > e){
20740 if(c.dateValue < s){
20749 // findBestRow: function(cells)
20753 // for (var i =0 ; i < cells.length;i++) {
20754 // ret = Math.max(cells[i].rows || 0,ret);
20761 addItem : function(ev)
20763 // look for vertical location slot in
20764 var cells = this.findCells(ev);
20766 // ev.row = this.findBestRow(cells);
20768 // work out the location.
20772 for(var i =0; i < cells.length; i++) {
20774 cells[i].row = cells[0].row;
20777 cells[i].row = cells[i].row + 1;
20787 if (crow.start.getY() == cells[i].getY()) {
20789 crow.end = cells[i];
20806 cells[0].events.push(ev);
20808 this.calevents.push(ev);
20811 clearEvents: function() {
20813 if(!this.calevents){
20817 Roo.each(this.cells.elements, function(c){
20823 Roo.each(this.calevents, function(e) {
20824 Roo.each(e.els, function(el) {
20825 el.un('mouseenter' ,this.onEventEnter, this);
20826 el.un('mouseleave' ,this.onEventLeave, this);
20831 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
20837 renderEvents: function()
20841 this.cells.each(function(c) {
20850 if(c.row != c.events.length){
20851 r = 4 - (4 - (c.row - c.events.length));
20854 c.events = ev.slice(0, r);
20855 c.more = ev.slice(r);
20857 if(c.more.length && c.more.length == 1){
20858 c.events.push(c.more.pop());
20861 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
20865 this.cells.each(function(c) {
20867 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
20870 for (var e = 0; e < c.events.length; e++){
20871 var ev = c.events[e];
20872 var rows = ev.rows;
20874 for(var i = 0; i < rows.length; i++) {
20876 // how many rows should it span..
20879 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
20880 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
20882 unselectable : "on",
20885 cls: 'fc-event-inner',
20889 // cls: 'fc-event-time',
20890 // html : cells.length > 1 ? '' : ev.time
20894 cls: 'fc-event-title',
20895 html : String.format('{0}', ev.title)
20902 cls: 'ui-resizable-handle ui-resizable-e',
20903 html : '  '
20910 cfg.cls += ' fc-event-start';
20912 if ((i+1) == rows.length) {
20913 cfg.cls += ' fc-event-end';
20916 var ctr = _this.el.select('.fc-event-container',true).first();
20917 var cg = ctr.createChild(cfg);
20919 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
20920 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
20922 var r = (c.more.length) ? 1 : 0;
20923 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
20924 cg.setWidth(ebox.right - sbox.x -2);
20926 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
20927 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
20928 cg.on('click', _this.onEventClick, _this, ev);
20939 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
20940 style : 'position: absolute',
20941 unselectable : "on",
20944 cls: 'fc-event-inner',
20948 cls: 'fc-event-title',
20956 cls: 'ui-resizable-handle ui-resizable-e',
20957 html : '  '
20963 var ctr = _this.el.select('.fc-event-container',true).first();
20964 var cg = ctr.createChild(cfg);
20966 var sbox = c.select('.fc-day-content',true).first().getBox();
20967 var ebox = c.select('.fc-day-content',true).first().getBox();
20969 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
20970 cg.setWidth(ebox.right - sbox.x -2);
20972 cg.on('click', _this.onMoreEventClick, _this, c.more);
20982 onEventEnter: function (e, el,event,d) {
20983 this.fireEvent('evententer', this, el, event);
20986 onEventLeave: function (e, el,event,d) {
20987 this.fireEvent('eventleave', this, el, event);
20990 onEventClick: function (e, el,event,d) {
20991 this.fireEvent('eventclick', this, el, event);
20994 onMonthChange: function () {
20998 onMoreEventClick: function(e, el, more)
21002 this.calpopover.placement = 'right';
21003 this.calpopover.setTitle('More');
21005 this.calpopover.setContent('');
21007 var ctr = this.calpopover.el.select('.popover-content', true).first();
21009 Roo.each(more, function(m){
21011 cls : 'fc-event-hori fc-event-draggable',
21014 var cg = ctr.createChild(cfg);
21016 cg.on('click', _this.onEventClick, _this, m);
21019 this.calpopover.show(el);
21024 onLoad: function ()
21026 this.calevents = [];
21029 if(this.store.getCount() > 0){
21030 this.store.data.each(function(d){
21033 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
21034 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
21035 time : d.data.start_time,
21036 title : d.data.title,
21037 description : d.data.description,
21038 venue : d.data.venue
21043 this.renderEvents();
21045 if(this.calevents.length && this.loadMask){
21046 this.maskEl.hide();
21050 onBeforeLoad: function()
21052 this.clearEvents();
21054 this.maskEl.show();
21068 * @class Roo.bootstrap.Popover
21069 * @extends Roo.bootstrap.Component
21071 * Bootstrap Popover class
21072 * @cfg {String} html contents of the popover (or false to use children..)
21073 * @cfg {String} title of popover (or false to hide)
21074 * @cfg {String|function} (right|top|bottom|left|auto) placement how it is placed
21075 * @cfg {String} trigger click || hover (or false to trigger manually)
21076 * @cfg {Boolean} modal - popovers that are modal will mask the screen, and must be closed with another event.
21077 * @cfg {String|Boolean|Roo.Element} add click hander to trigger show over what element
21078 * - if false and it has a 'parent' then it will be automatically added to that element
21079 * - if string - Roo.get will be called
21080 * @cfg {Number} delay - delay before showing
21083 * Create a new Popover
21084 * @param {Object} config The config object
21087 Roo.bootstrap.Popover = function(config){
21088 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
21094 * After the popover show
21096 * @param {Roo.bootstrap.Popover} this
21101 * After the popover hide
21103 * @param {Roo.bootstrap.Popover} this
21109 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
21114 placement : 'right',
21115 trigger : 'hover', // hover
21121 can_build_overlaid : false,
21123 maskEl : false, // the mask element
21126 alignEl : false, // when show is called with an element - this get's stored.
21128 getChildContainer : function()
21130 return this.contentEl;
21133 getPopoverHeader : function()
21135 this.title = true; // flag not to hide it..
21136 this.headerEl.addClass('p-0');
21137 return this.headerEl
21141 getAutoCreate : function(){
21144 cls : 'popover roo-dynamic shadow roo-popover' + (this.modal ? '-modal' : ''),
21145 style: 'display:block',
21151 cls : 'popover-inner ',
21155 cls: 'popover-title popover-header',
21156 html : this.title === false ? '' : this.title
21159 cls : 'popover-content popover-body ' + (this.cls || ''),
21160 html : this.html || ''
21171 * @param {string} the title
21173 setTitle: function(str)
21177 this.headerEl.dom.innerHTML = str;
21182 * @param {string} the body content
21184 setContent: function(str)
21187 if (this.contentEl) {
21188 this.contentEl.dom.innerHTML = str;
21192 // as it get's added to the bottom of the page.
21193 onRender : function(ct, position)
21195 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
21200 var cfg = Roo.apply({}, this.getAutoCreate());
21204 cfg.cls += ' ' + this.cls;
21207 cfg.style = this.style;
21209 //Roo.log("adding to ");
21210 this.el = Roo.get(document.body).createChild(cfg, position);
21211 // Roo.log(this.el);
21214 this.contentEl = this.el.select('.popover-content',true).first();
21215 this.headerEl = this.el.select('.popover-title',true).first();
21218 if(typeof(this.items) != 'undefined'){
21219 var items = this.items;
21222 for(var i =0;i < items.length;i++) {
21223 nitems.push(this.addxtype(Roo.apply({}, items[i])));
21227 this.items = nitems;
21229 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
21230 Roo.EventManager.onWindowResize(this.resizeMask, this, true);
21237 resizeMask : function()
21239 this.maskEl.setSize(
21240 Roo.lib.Dom.getViewWidth(true),
21241 Roo.lib.Dom.getViewHeight(true)
21245 initEvents : function()
21249 Roo.bootstrap.Popover.register(this);
21252 this.arrowEl = this.el.select('.arrow',true).first();
21253 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY); // probably not needed as it's default in BS4
21254 this.el.enableDisplayMode('block');
21258 if (this.over === false && !this.parent()) {
21261 if (this.triggers === false) {
21266 var on_el = (this.over == 'parent' || this.over === false) ? this.parent().el : Roo.get(this.over);
21267 var triggers = this.trigger ? this.trigger.split(' ') : [];
21268 Roo.each(triggers, function(trigger) {
21270 if (trigger == 'click') {
21271 on_el.on('click', this.toggle, this);
21272 } else if (trigger != 'manual') {
21273 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
21274 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
21276 on_el.on(eventIn ,this.enter, this);
21277 on_el.on(eventOut, this.leave, this);
21287 toggle : function () {
21288 this.hoverState == 'in' ? this.leave() : this.enter();
21291 enter : function () {
21293 clearTimeout(this.timeout);
21295 this.hoverState = 'in';
21297 if (!this.delay || !this.delay.show) {
21302 this.timeout = setTimeout(function () {
21303 if (_t.hoverState == 'in') {
21306 }, this.delay.show)
21309 leave : function() {
21310 clearTimeout(this.timeout);
21312 this.hoverState = 'out';
21314 if (!this.delay || !this.delay.hide) {
21319 this.timeout = setTimeout(function () {
21320 if (_t.hoverState == 'out') {
21323 }, this.delay.hide)
21327 * @param {Roo.Element|string|Boolean} - element to align and point to. (set align to [ pos, offset ])
21328 * @param {string} (left|right|top|bottom) position
21330 show : function (on_el, placement)
21332 this.placement = typeof(placement) == 'undefined' ? this.placement : placement;
21333 on_el = on_el || false; // default to false
21336 if (this.parent() && (this.over == 'parent' || (this.over === false))) {
21337 on_el = this.parent().el;
21338 } else if (this.over) {
21339 on_el = Roo.get(this.over);
21344 this.alignEl = Roo.get( on_el );
21347 this.render(document.body);
21353 if (this.title === false) {
21354 this.headerEl.hide();
21359 this.el.dom.style.display = 'block';
21362 if (this.alignEl) {
21363 this.updatePosition(this.placement, true);
21366 // this is usually just done by the builder = to show the popoup in the middle of the scren.
21367 var es = this.el.getSize();
21368 var x = Roo.lib.Dom.getViewWidth()/2;
21369 var y = Roo.lib.Dom.getViewHeight()/2;
21370 this.el.setXY([ x-(es.width/2), y-(es.height/2)] );
21375 //var arrow = this.el.select('.arrow',true).first();
21376 //arrow.set(align[2],
21378 this.el.addClass('in');
21382 this.hoverState = 'in';
21385 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
21386 this.maskEl.setStyle('z-index', Roo.bootstrap.Popover.zIndex++);
21387 this.maskEl.dom.style.display = 'block';
21388 this.maskEl.addClass('show');
21390 this.el.setStyle('z-index', Roo.bootstrap.Popover.zIndex++);
21392 this.fireEvent('show', this);
21396 * fire this manually after loading a grid in the table for example
21397 * @param {string} (left|right|top|bottom) where to try and put it (use false to use the last one)
21398 * @param {Boolean} try and move it if we cant get right position.
21400 updatePosition : function(placement, try_move)
21402 // allow for calling with no parameters
21403 placement = placement ? placement : this.placement;
21404 try_move = typeof(try_move) == 'undefined' ? true : try_move;
21406 this.el.removeClass([
21407 'fade','top','bottom', 'left', 'right','in',
21408 'bs-popover-top','bs-popover-bottom', 'bs-popover-left', 'bs-popover-right'
21410 this.el.addClass(placement + ' bs-popover-' + placement);
21412 if (!this.alignEl ) {
21416 switch (placement) {
21418 var exact = this.el.getAlignToXY(this.alignEl, 'tl-tr', [10,0]);
21419 var offset = this.el.getAlignToXY(this.alignEl, 'tl-tr?',[10,0]);
21420 if (!try_move || exact.equals(offset) || exact[0] == offset[0] ) {
21421 //normal display... or moved up/down.
21422 this.el.setXY(offset);
21423 var xy = this.alignEl.getAnchorXY('tr', false);
21425 this.arrowEl.setXY(xy);
21428 // continue through...
21429 return this.updatePosition('left', false);
21433 var exact = this.el.getAlignToXY(this.alignEl, 'tr-tl', [-10,0]);
21434 var offset = this.el.getAlignToXY(this.alignEl, 'tr-tl?',[-10,0]);
21435 if (!try_move || exact.equals(offset) || exact[0] == offset[0] ) {
21436 //normal display... or moved up/down.
21437 this.el.setXY(offset);
21438 var xy = this.alignEl.getAnchorXY('tl', false);
21439 xy[0]-=10;xy[1]+=5; // << fix me
21440 this.arrowEl.setXY(xy);
21444 return this.updatePosition('right', false);
21447 var exact = this.el.getAlignToXY(this.alignEl, 'b-t', [0,-10]);
21448 var offset = this.el.getAlignToXY(this.alignEl, 'b-t?',[0,-10]);
21449 if (!try_move || exact.equals(offset) || exact[1] == offset[1] ) {
21450 //normal display... or moved up/down.
21451 this.el.setXY(offset);
21452 var xy = this.alignEl.getAnchorXY('t', false);
21453 xy[1]-=10; // << fix me
21454 this.arrowEl.setXY(xy);
21458 return this.updatePosition('bottom', false);
21461 var exact = this.el.getAlignToXY(this.alignEl, 't-b', [0,10]);
21462 var offset = this.el.getAlignToXY(this.alignEl, 't-b?',[0,10]);
21463 if (!try_move || exact.equals(offset) || exact[1] == offset[1] ) {
21464 //normal display... or moved up/down.
21465 this.el.setXY(offset);
21466 var xy = this.alignEl.getAnchorXY('b', false);
21467 xy[1]+=2; // << fix me
21468 this.arrowEl.setXY(xy);
21472 return this.updatePosition('top', false);
21483 this.el.setXY([0,0]);
21484 this.el.removeClass('in');
21486 this.hoverState = null;
21487 this.maskEl.hide(); // always..
21488 this.fireEvent('hide', this);
21494 Roo.apply(Roo.bootstrap.Popover, {
21497 'left' : ['r-l', [-10,0], 'left bs-popover-left'],
21498 'right' : ['l-br', [10,0], 'right bs-popover-right'],
21499 'bottom' : ['t-b', [0,10], 'top bs-popover-top'],
21500 'top' : [ 'b-t', [0,-10], 'bottom bs-popover-bottom']
21505 clickHander : false,
21509 onMouseDown : function(e)
21511 if (this.popups.length && !e.getTarget(".roo-popover")) {
21512 /// what is nothing is showing..
21521 register : function(popup)
21523 if (!Roo.bootstrap.Popover.clickHandler) {
21524 Roo.bootstrap.Popover.clickHandler = Roo.get(document).on("mousedown", Roo.bootstrap.Popover.onMouseDown, Roo.bootstrap.Popover);
21526 // hide other popups.
21527 popup.on('show', Roo.bootstrap.Popover.onShow, popup);
21528 popup.on('hide', Roo.bootstrap.Popover.onHide, popup);
21529 this.hideAll(); //<< why?
21530 //this.popups.push(popup);
21532 hideAll : function()
21534 this.popups.forEach(function(p) {
21538 onShow : function() {
21539 Roo.bootstrap.Popover.popups.push(this);
21541 onHide : function() {
21542 Roo.bootstrap.Popover.popups.remove(this);
21548 * Card header - holder for the card header elements.
21553 * @class Roo.bootstrap.PopoverNav
21554 * @extends Roo.bootstrap.NavGroup
21555 * Bootstrap Popover header navigation class
21557 * Create a new Popover Header Navigation
21558 * @param {Object} config The config object
21561 Roo.bootstrap.PopoverNav = function(config){
21562 Roo.bootstrap.PopoverNav.superclass.constructor.call(this, config);
21565 Roo.extend(Roo.bootstrap.PopoverNav, Roo.bootstrap.NavSimplebar, {
21568 container_method : 'getPopoverHeader'
21586 * @class Roo.bootstrap.Progress
21587 * @extends Roo.bootstrap.Component
21588 * Bootstrap Progress class
21589 * @cfg {Boolean} striped striped of the progress bar
21590 * @cfg {Boolean} active animated of the progress bar
21594 * Create a new Progress
21595 * @param {Object} config The config object
21598 Roo.bootstrap.Progress = function(config){
21599 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
21602 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
21607 getAutoCreate : function(){
21615 cfg.cls += ' progress-striped';
21619 cfg.cls += ' active';
21638 * @class Roo.bootstrap.ProgressBar
21639 * @extends Roo.bootstrap.Component
21640 * Bootstrap ProgressBar class
21641 * @cfg {Number} aria_valuenow aria-value now
21642 * @cfg {Number} aria_valuemin aria-value min
21643 * @cfg {Number} aria_valuemax aria-value max
21644 * @cfg {String} label label for the progress bar
21645 * @cfg {String} panel (success | info | warning | danger )
21646 * @cfg {String} role role of the progress bar
21647 * @cfg {String} sr_only text
21651 * Create a new ProgressBar
21652 * @param {Object} config The config object
21655 Roo.bootstrap.ProgressBar = function(config){
21656 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
21659 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
21663 aria_valuemax : 100,
21669 getAutoCreate : function()
21674 cls: 'progress-bar',
21675 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
21687 cfg.role = this.role;
21690 if(this.aria_valuenow){
21691 cfg['aria-valuenow'] = this.aria_valuenow;
21694 if(this.aria_valuemin){
21695 cfg['aria-valuemin'] = this.aria_valuemin;
21698 if(this.aria_valuemax){
21699 cfg['aria-valuemax'] = this.aria_valuemax;
21702 if(this.label && !this.sr_only){
21703 cfg.html = this.label;
21707 cfg.cls += ' progress-bar-' + this.panel;
21713 update : function(aria_valuenow)
21715 this.aria_valuenow = aria_valuenow;
21717 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
21732 * @class Roo.bootstrap.TabGroup
21733 * @extends Roo.bootstrap.Column
21734 * Bootstrap Column class
21735 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
21736 * @cfg {Boolean} carousel true to make the group behave like a carousel
21737 * @cfg {Boolean} bullets show bullets for the panels
21738 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
21739 * @cfg {Number} timer auto slide timer .. default 0 millisecond
21740 * @cfg {Boolean} showarrow (true|false) show arrow default true
21743 * Create a new TabGroup
21744 * @param {Object} config The config object
21747 Roo.bootstrap.TabGroup = function(config){
21748 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
21750 this.navId = Roo.id();
21753 Roo.bootstrap.TabGroup.register(this);
21757 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
21760 transition : false,
21765 slideOnTouch : false,
21768 getAutoCreate : function()
21770 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
21772 cfg.cls += ' tab-content';
21774 if (this.carousel) {
21775 cfg.cls += ' carousel slide';
21778 cls : 'carousel-inner',
21782 if(this.bullets && !Roo.isTouch){
21785 cls : 'carousel-bullets',
21789 if(this.bullets_cls){
21790 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
21797 cfg.cn[0].cn.push(bullets);
21800 if(this.showarrow){
21801 cfg.cn[0].cn.push({
21803 class : 'carousel-arrow',
21807 class : 'carousel-prev',
21811 class : 'fa fa-chevron-left'
21817 class : 'carousel-next',
21821 class : 'fa fa-chevron-right'
21834 initEvents: function()
21836 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
21837 // this.el.on("touchstart", this.onTouchStart, this);
21840 if(this.autoslide){
21843 this.slideFn = window.setInterval(function() {
21844 _this.showPanelNext();
21848 if(this.showarrow){
21849 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
21850 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
21856 // onTouchStart : function(e, el, o)
21858 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
21862 // this.showPanelNext();
21866 getChildContainer : function()
21868 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
21872 * register a Navigation item
21873 * @param {Roo.bootstrap.NavItem} the navitem to add
21875 register : function(item)
21877 this.tabs.push( item);
21878 item.navId = this.navId; // not really needed..
21883 getActivePanel : function()
21886 Roo.each(this.tabs, function(t) {
21896 getPanelByName : function(n)
21899 Roo.each(this.tabs, function(t) {
21900 if (t.tabId == n) {
21908 indexOfPanel : function(p)
21911 Roo.each(this.tabs, function(t,i) {
21912 if (t.tabId == p.tabId) {
21921 * show a specific panel
21922 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
21923 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
21925 showPanel : function (pan)
21927 if(this.transition || typeof(pan) == 'undefined'){
21928 Roo.log("waiting for the transitionend");
21932 if (typeof(pan) == 'number') {
21933 pan = this.tabs[pan];
21936 if (typeof(pan) == 'string') {
21937 pan = this.getPanelByName(pan);
21940 var cur = this.getActivePanel();
21943 Roo.log('pan or acitve pan is undefined');
21947 if (pan.tabId == this.getActivePanel().tabId) {
21951 if (false === cur.fireEvent('beforedeactivate')) {
21955 if(this.bullets > 0 && !Roo.isTouch){
21956 this.setActiveBullet(this.indexOfPanel(pan));
21959 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
21961 //class="carousel-item carousel-item-next carousel-item-left"
21963 this.transition = true;
21964 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
21965 var lr = dir == 'next' ? 'left' : 'right';
21966 pan.el.addClass(dir); // or prev
21967 pan.el.addClass('carousel-item-' + dir); // or prev
21968 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
21969 cur.el.addClass(lr); // or right
21970 pan.el.addClass(lr);
21971 cur.el.addClass('carousel-item-' +lr); // or right
21972 pan.el.addClass('carousel-item-' +lr);
21976 cur.el.on('transitionend', function() {
21977 Roo.log("trans end?");
21979 pan.el.removeClass([lr,dir, 'carousel-item-' + lr, 'carousel-item-' + dir]);
21980 pan.setActive(true);
21982 cur.el.removeClass([lr, 'carousel-item-' + lr]);
21983 cur.setActive(false);
21985 _this.transition = false;
21987 }, this, { single: true } );
21992 cur.setActive(false);
21993 pan.setActive(true);
21998 showPanelNext : function()
22000 var i = this.indexOfPanel(this.getActivePanel());
22002 if (i >= this.tabs.length - 1 && !this.autoslide) {
22006 if (i >= this.tabs.length - 1 && this.autoslide) {
22010 this.showPanel(this.tabs[i+1]);
22013 showPanelPrev : function()
22015 var i = this.indexOfPanel(this.getActivePanel());
22017 if (i < 1 && !this.autoslide) {
22021 if (i < 1 && this.autoslide) {
22022 i = this.tabs.length;
22025 this.showPanel(this.tabs[i-1]);
22029 addBullet: function()
22031 if(!this.bullets || Roo.isTouch){
22034 var ctr = this.el.select('.carousel-bullets',true).first();
22035 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
22036 var bullet = ctr.createChild({
22037 cls : 'bullet bullet-' + i
22038 },ctr.dom.lastChild);
22043 bullet.on('click', (function(e, el, o, ii, t){
22045 e.preventDefault();
22047 this.showPanel(ii);
22049 if(this.autoslide && this.slideFn){
22050 clearInterval(this.slideFn);
22051 this.slideFn = window.setInterval(function() {
22052 _this.showPanelNext();
22056 }).createDelegate(this, [i, bullet], true));
22061 setActiveBullet : function(i)
22067 Roo.each(this.el.select('.bullet', true).elements, function(el){
22068 el.removeClass('selected');
22071 var bullet = this.el.select('.bullet-' + i, true).first();
22077 bullet.addClass('selected');
22088 Roo.apply(Roo.bootstrap.TabGroup, {
22092 * register a Navigation Group
22093 * @param {Roo.bootstrap.NavGroup} the navgroup to add
22095 register : function(navgrp)
22097 this.groups[navgrp.navId] = navgrp;
22101 * fetch a Navigation Group based on the navigation ID
22102 * if one does not exist , it will get created.
22103 * @param {string} the navgroup to add
22104 * @returns {Roo.bootstrap.NavGroup} the navgroup
22106 get: function(navId) {
22107 if (typeof(this.groups[navId]) == 'undefined') {
22108 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
22110 return this.groups[navId] ;
22125 * @class Roo.bootstrap.TabPanel
22126 * @extends Roo.bootstrap.Component
22127 * Bootstrap TabPanel class
22128 * @cfg {Boolean} active panel active
22129 * @cfg {String} html panel content
22130 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
22131 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
22132 * @cfg {String} href click to link..
22133 * @cfg {Boolean} touchSlide if swiping slides tab to next panel (default off)
22137 * Create a new TabPanel
22138 * @param {Object} config The config object
22141 Roo.bootstrap.TabPanel = function(config){
22142 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
22146 * Fires when the active status changes
22147 * @param {Roo.bootstrap.TabPanel} this
22148 * @param {Boolean} state the new state
22153 * @event beforedeactivate
22154 * Fires before a tab is de-activated - can be used to do validation on a form.
22155 * @param {Roo.bootstrap.TabPanel} this
22156 * @return {Boolean} false if there is an error
22159 'beforedeactivate': true
22162 this.tabId = this.tabId || Roo.id();
22166 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
22173 touchSlide : false,
22174 getAutoCreate : function(){
22179 // item is needed for carousel - not sure if it has any effect otherwise
22180 cls: 'carousel-item tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
22181 html: this.html || ''
22185 cfg.cls += ' active';
22189 cfg.tabId = this.tabId;
22197 initEvents: function()
22199 var p = this.parent();
22201 this.navId = this.navId || p.navId;
22203 if (typeof(this.navId) != 'undefined') {
22204 // not really needed.. but just in case.. parent should be a NavGroup.
22205 var tg = Roo.bootstrap.TabGroup.get(this.navId);
22209 var i = tg.tabs.length - 1;
22211 if(this.active && tg.bullets > 0 && i < tg.bullets){
22212 tg.setActiveBullet(i);
22216 this.el.on('click', this.onClick, this);
22218 if(Roo.isTouch && this.touchSlide){
22219 this.el.on("touchstart", this.onTouchStart, this);
22220 this.el.on("touchmove", this.onTouchMove, this);
22221 this.el.on("touchend", this.onTouchEnd, this);
22226 onRender : function(ct, position)
22228 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
22231 setActive : function(state)
22233 Roo.log("panel - set active " + this.tabId + "=" + state);
22235 this.active = state;
22237 this.el.removeClass('active');
22239 } else if (!this.el.hasClass('active')) {
22240 this.el.addClass('active');
22243 this.fireEvent('changed', this, state);
22246 onClick : function(e)
22248 e.preventDefault();
22250 if(!this.href.length){
22254 window.location.href = this.href;
22263 onTouchStart : function(e)
22265 this.swiping = false;
22267 this.startX = e.browserEvent.touches[0].clientX;
22268 this.startY = e.browserEvent.touches[0].clientY;
22271 onTouchMove : function(e)
22273 this.swiping = true;
22275 this.endX = e.browserEvent.touches[0].clientX;
22276 this.endY = e.browserEvent.touches[0].clientY;
22279 onTouchEnd : function(e)
22286 var tabGroup = this.parent();
22288 if(this.endX > this.startX){ // swiping right
22289 tabGroup.showPanelPrev();
22293 if(this.startX > this.endX){ // swiping left
22294 tabGroup.showPanelNext();
22313 * @class Roo.bootstrap.DateField
22314 * @extends Roo.bootstrap.Input
22315 * Bootstrap DateField class
22316 * @cfg {Number} weekStart default 0
22317 * @cfg {String} viewMode default empty, (months|years)
22318 * @cfg {String} minViewMode default empty, (months|years)
22319 * @cfg {Number} startDate default -Infinity
22320 * @cfg {Number} endDate default Infinity
22321 * @cfg {Boolean} todayHighlight default false
22322 * @cfg {Boolean} todayBtn default false
22323 * @cfg {Boolean} calendarWeeks default false
22324 * @cfg {Object} daysOfWeekDisabled default empty
22325 * @cfg {Boolean} singleMode default false (true | false)
22327 * @cfg {Boolean} keyboardNavigation default true
22328 * @cfg {String} language default en
22331 * Create a new DateField
22332 * @param {Object} config The config object
22335 Roo.bootstrap.DateField = function(config){
22336 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
22340 * Fires when this field show.
22341 * @param {Roo.bootstrap.DateField} this
22342 * @param {Mixed} date The date value
22347 * Fires when this field hide.
22348 * @param {Roo.bootstrap.DateField} this
22349 * @param {Mixed} date The date value
22354 * Fires when select a date.
22355 * @param {Roo.bootstrap.DateField} this
22356 * @param {Mixed} date The date value
22360 * @event beforeselect
22361 * Fires when before select a date.
22362 * @param {Roo.bootstrap.DateField} this
22363 * @param {Mixed} date The date value
22365 beforeselect : true
22369 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
22372 * @cfg {String} format
22373 * The default date format string which can be overriden for localization support. The format must be
22374 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
22378 * @cfg {String} altFormats
22379 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
22380 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
22382 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
22390 todayHighlight : false,
22396 keyboardNavigation: true,
22398 calendarWeeks: false,
22400 startDate: -Infinity,
22404 daysOfWeekDisabled: [],
22408 singleMode : false,
22410 UTCDate: function()
22412 return new Date(Date.UTC.apply(Date, arguments));
22415 UTCToday: function()
22417 var today = new Date();
22418 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
22421 getDate: function() {
22422 var d = this.getUTCDate();
22423 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
22426 getUTCDate: function() {
22430 setDate: function(d) {
22431 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
22434 setUTCDate: function(d) {
22436 this.setValue(this.formatDate(this.date));
22439 onRender: function(ct, position)
22442 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
22444 this.language = this.language || 'en';
22445 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
22446 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
22448 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
22449 this.format = this.format || 'm/d/y';
22450 this.isInline = false;
22451 this.isInput = true;
22452 this.component = this.el.select('.add-on', true).first() || false;
22453 this.component = (this.component && this.component.length === 0) ? false : this.component;
22454 this.hasInput = this.component && this.inputEl().length;
22456 if (typeof(this.minViewMode === 'string')) {
22457 switch (this.minViewMode) {
22459 this.minViewMode = 1;
22462 this.minViewMode = 2;
22465 this.minViewMode = 0;
22470 if (typeof(this.viewMode === 'string')) {
22471 switch (this.viewMode) {
22484 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
22486 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
22488 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
22490 this.picker().on('mousedown', this.onMousedown, this);
22491 this.picker().on('click', this.onClick, this);
22493 this.picker().addClass('datepicker-dropdown');
22495 this.startViewMode = this.viewMode;
22497 if(this.singleMode){
22498 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
22499 v.setVisibilityMode(Roo.Element.DISPLAY);
22503 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
22504 v.setStyle('width', '189px');
22508 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
22509 if(!this.calendarWeeks){
22514 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
22515 v.attr('colspan', function(i, val){
22516 return parseInt(val) + 1;
22521 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
22523 this.setStartDate(this.startDate);
22524 this.setEndDate(this.endDate);
22526 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
22533 if(this.isInline) {
22538 picker : function()
22540 return this.pickerEl;
22541 // return this.el.select('.datepicker', true).first();
22544 fillDow: function()
22546 var dowCnt = this.weekStart;
22555 if(this.calendarWeeks){
22563 while (dowCnt < this.weekStart + 7) {
22567 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
22571 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
22574 fillMonths: function()
22577 var months = this.picker().select('>.datepicker-months td', true).first();
22579 months.dom.innerHTML = '';
22585 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
22588 months.createChild(month);
22595 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;
22597 if (this.date < this.startDate) {
22598 this.viewDate = new Date(this.startDate);
22599 } else if (this.date > this.endDate) {
22600 this.viewDate = new Date(this.endDate);
22602 this.viewDate = new Date(this.date);
22610 var d = new Date(this.viewDate),
22611 year = d.getUTCFullYear(),
22612 month = d.getUTCMonth(),
22613 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
22614 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
22615 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
22616 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
22617 currentDate = this.date && this.date.valueOf(),
22618 today = this.UTCToday();
22620 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
22622 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
22624 // this.picker.select('>tfoot th.today').
22625 // .text(dates[this.language].today)
22626 // .toggle(this.todayBtn !== false);
22628 this.updateNavArrows();
22631 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
22633 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
22635 prevMonth.setUTCDate(day);
22637 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
22639 var nextMonth = new Date(prevMonth);
22641 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
22643 nextMonth = nextMonth.valueOf();
22645 var fillMonths = false;
22647 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
22649 while(prevMonth.valueOf() <= nextMonth) {
22652 if (prevMonth.getUTCDay() === this.weekStart) {
22654 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
22662 if(this.calendarWeeks){
22663 // ISO 8601: First week contains first thursday.
22664 // ISO also states week starts on Monday, but we can be more abstract here.
22666 // Start of current week: based on weekstart/current date
22667 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
22668 // Thursday of this week
22669 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
22670 // First Thursday of year, year from thursday
22671 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
22672 // Calendar week: ms between thursdays, div ms per day, div 7 days
22673 calWeek = (th - yth) / 864e5 / 7 + 1;
22675 fillMonths.cn.push({
22683 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
22685 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
22688 if (this.todayHighlight &&
22689 prevMonth.getUTCFullYear() == today.getFullYear() &&
22690 prevMonth.getUTCMonth() == today.getMonth() &&
22691 prevMonth.getUTCDate() == today.getDate()) {
22692 clsName += ' today';
22695 if (currentDate && prevMonth.valueOf() === currentDate) {
22696 clsName += ' active';
22699 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
22700 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
22701 clsName += ' disabled';
22704 fillMonths.cn.push({
22706 cls: 'day ' + clsName,
22707 html: prevMonth.getDate()
22710 prevMonth.setDate(prevMonth.getDate()+1);
22713 var currentYear = this.date && this.date.getUTCFullYear();
22714 var currentMonth = this.date && this.date.getUTCMonth();
22716 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
22718 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
22719 v.removeClass('active');
22721 if(currentYear === year && k === currentMonth){
22722 v.addClass('active');
22725 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
22726 v.addClass('disabled');
22732 year = parseInt(year/10, 10) * 10;
22734 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
22736 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
22739 for (var i = -1; i < 11; i++) {
22740 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
22742 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
22750 showMode: function(dir)
22753 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
22756 Roo.each(this.picker().select('>div',true).elements, function(v){
22757 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
22760 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
22765 if(this.isInline) {
22769 this.picker().removeClass(['bottom', 'top']);
22771 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
22773 * place to the top of element!
22777 this.picker().addClass('top');
22778 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
22783 this.picker().addClass('bottom');
22785 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
22788 parseDate : function(value)
22790 if(!value || value instanceof Date){
22793 var v = Date.parseDate(value, this.format);
22794 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
22795 v = Date.parseDate(value, 'Y-m-d');
22797 if(!v && this.altFormats){
22798 if(!this.altFormatsArray){
22799 this.altFormatsArray = this.altFormats.split("|");
22801 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
22802 v = Date.parseDate(value, this.altFormatsArray[i]);
22808 formatDate : function(date, fmt)
22810 return (!date || !(date instanceof Date)) ?
22811 date : date.dateFormat(fmt || this.format);
22814 onFocus : function()
22816 Roo.bootstrap.DateField.superclass.onFocus.call(this);
22820 onBlur : function()
22822 Roo.bootstrap.DateField.superclass.onBlur.call(this);
22824 var d = this.inputEl().getValue();
22831 showPopup : function()
22833 this.picker().show();
22837 this.fireEvent('showpopup', this, this.date);
22840 hidePopup : function()
22842 if(this.isInline) {
22845 this.picker().hide();
22846 this.viewMode = this.startViewMode;
22849 this.fireEvent('hidepopup', this, this.date);
22853 onMousedown: function(e)
22855 e.stopPropagation();
22856 e.preventDefault();
22861 Roo.bootstrap.DateField.superclass.keyup.call(this);
22865 setValue: function(v)
22867 if(this.fireEvent('beforeselect', this, v) !== false){
22868 var d = new Date(this.parseDate(v) ).clearTime();
22870 if(isNaN(d.getTime())){
22871 this.date = this.viewDate = '';
22872 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
22876 v = this.formatDate(d);
22878 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
22880 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
22884 this.fireEvent('select', this, this.date);
22888 getValue: function()
22890 return this.formatDate(this.date);
22893 fireKey: function(e)
22895 if (!this.picker().isVisible()){
22896 if (e.keyCode == 27) { // allow escape to hide and re-show picker
22902 var dateChanged = false,
22904 newDate, newViewDate;
22909 e.preventDefault();
22913 if (!this.keyboardNavigation) {
22916 dir = e.keyCode == 37 ? -1 : 1;
22919 newDate = this.moveYear(this.date, dir);
22920 newViewDate = this.moveYear(this.viewDate, dir);
22921 } else if (e.shiftKey){
22922 newDate = this.moveMonth(this.date, dir);
22923 newViewDate = this.moveMonth(this.viewDate, dir);
22925 newDate = new Date(this.date);
22926 newDate.setUTCDate(this.date.getUTCDate() + dir);
22927 newViewDate = new Date(this.viewDate);
22928 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
22930 if (this.dateWithinRange(newDate)){
22931 this.date = newDate;
22932 this.viewDate = newViewDate;
22933 this.setValue(this.formatDate(this.date));
22935 e.preventDefault();
22936 dateChanged = true;
22941 if (!this.keyboardNavigation) {
22944 dir = e.keyCode == 38 ? -1 : 1;
22946 newDate = this.moveYear(this.date, dir);
22947 newViewDate = this.moveYear(this.viewDate, dir);
22948 } else if (e.shiftKey){
22949 newDate = this.moveMonth(this.date, dir);
22950 newViewDate = this.moveMonth(this.viewDate, dir);
22952 newDate = new Date(this.date);
22953 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
22954 newViewDate = new Date(this.viewDate);
22955 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
22957 if (this.dateWithinRange(newDate)){
22958 this.date = newDate;
22959 this.viewDate = newViewDate;
22960 this.setValue(this.formatDate(this.date));
22962 e.preventDefault();
22963 dateChanged = true;
22967 this.setValue(this.formatDate(this.date));
22969 e.preventDefault();
22972 this.setValue(this.formatDate(this.date));
22986 onClick: function(e)
22988 e.stopPropagation();
22989 e.preventDefault();
22991 var target = e.getTarget();
22993 if(target.nodeName.toLowerCase() === 'i'){
22994 target = Roo.get(target).dom.parentNode;
22997 var nodeName = target.nodeName;
22998 var className = target.className;
22999 var html = target.innerHTML;
23000 //Roo.log(nodeName);
23002 switch(nodeName.toLowerCase()) {
23004 switch(className) {
23010 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
23011 switch(this.viewMode){
23013 this.viewDate = this.moveMonth(this.viewDate, dir);
23017 this.viewDate = this.moveYear(this.viewDate, dir);
23023 var date = new Date();
23024 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
23026 this.setValue(this.formatDate(this.date));
23033 if (className.indexOf('disabled') < 0) {
23034 if (!this.viewDate) {
23035 this.viewDate = new Date();
23037 this.viewDate.setUTCDate(1);
23038 if (className.indexOf('month') > -1) {
23039 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
23041 var year = parseInt(html, 10) || 0;
23042 this.viewDate.setUTCFullYear(year);
23046 if(this.singleMode){
23047 this.setValue(this.formatDate(this.viewDate));
23058 //Roo.log(className);
23059 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
23060 var day = parseInt(html, 10) || 1;
23061 var year = (this.viewDate || new Date()).getUTCFullYear(),
23062 month = (this.viewDate || new Date()).getUTCMonth();
23064 if (className.indexOf('old') > -1) {
23071 } else if (className.indexOf('new') > -1) {
23079 //Roo.log([year,month,day]);
23080 this.date = this.UTCDate(year, month, day,0,0,0,0);
23081 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
23083 //Roo.log(this.formatDate(this.date));
23084 this.setValue(this.formatDate(this.date));
23091 setStartDate: function(startDate)
23093 this.startDate = startDate || -Infinity;
23094 if (this.startDate !== -Infinity) {
23095 this.startDate = this.parseDate(this.startDate);
23098 this.updateNavArrows();
23101 setEndDate: function(endDate)
23103 this.endDate = endDate || Infinity;
23104 if (this.endDate !== Infinity) {
23105 this.endDate = this.parseDate(this.endDate);
23108 this.updateNavArrows();
23111 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
23113 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
23114 if (typeof(this.daysOfWeekDisabled) !== 'object') {
23115 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
23117 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
23118 return parseInt(d, 10);
23121 this.updateNavArrows();
23124 updateNavArrows: function()
23126 if(this.singleMode){
23130 var d = new Date(this.viewDate),
23131 year = d.getUTCFullYear(),
23132 month = d.getUTCMonth();
23134 Roo.each(this.picker().select('.prev', true).elements, function(v){
23136 switch (this.viewMode) {
23139 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
23145 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
23152 Roo.each(this.picker().select('.next', true).elements, function(v){
23154 switch (this.viewMode) {
23157 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
23163 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
23171 moveMonth: function(date, dir)
23176 var new_date = new Date(date.valueOf()),
23177 day = new_date.getUTCDate(),
23178 month = new_date.getUTCMonth(),
23179 mag = Math.abs(dir),
23181 dir = dir > 0 ? 1 : -1;
23184 // If going back one month, make sure month is not current month
23185 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
23187 return new_date.getUTCMonth() == month;
23189 // If going forward one month, make sure month is as expected
23190 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
23192 return new_date.getUTCMonth() != new_month;
23194 new_month = month + dir;
23195 new_date.setUTCMonth(new_month);
23196 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
23197 if (new_month < 0 || new_month > 11) {
23198 new_month = (new_month + 12) % 12;
23201 // For magnitudes >1, move one month at a time...
23202 for (var i=0; i<mag; i++) {
23203 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
23204 new_date = this.moveMonth(new_date, dir);
23206 // ...then reset the day, keeping it in the new month
23207 new_month = new_date.getUTCMonth();
23208 new_date.setUTCDate(day);
23210 return new_month != new_date.getUTCMonth();
23213 // Common date-resetting loop -- if date is beyond end of month, make it
23216 new_date.setUTCDate(--day);
23217 new_date.setUTCMonth(new_month);
23222 moveYear: function(date, dir)
23224 return this.moveMonth(date, dir*12);
23227 dateWithinRange: function(date)
23229 return date >= this.startDate && date <= this.endDate;
23235 this.picker().remove();
23238 validateValue : function(value)
23240 if(this.getVisibilityEl().hasClass('hidden')){
23244 if(value.length < 1) {
23245 if(this.allowBlank){
23251 if(value.length < this.minLength){
23254 if(value.length > this.maxLength){
23258 var vt = Roo.form.VTypes;
23259 if(!vt[this.vtype](value, this)){
23263 if(typeof this.validator == "function"){
23264 var msg = this.validator(value);
23270 if(this.regex && !this.regex.test(value)){
23274 if(typeof(this.parseDate(value)) == 'undefined'){
23278 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
23282 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
23292 this.date = this.viewDate = '';
23294 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
23299 Roo.apply(Roo.bootstrap.DateField, {
23310 html: '<i class="fa fa-arrow-left"/>'
23320 html: '<i class="fa fa-arrow-right"/>'
23362 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
23363 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
23364 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
23365 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
23366 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
23379 navFnc: 'FullYear',
23384 navFnc: 'FullYear',
23389 Roo.apply(Roo.bootstrap.DateField, {
23393 cls: 'datepicker dropdown-menu roo-dynamic shadow',
23397 cls: 'datepicker-days',
23401 cls: 'table-condensed',
23403 Roo.bootstrap.DateField.head,
23407 Roo.bootstrap.DateField.footer
23414 cls: 'datepicker-months',
23418 cls: 'table-condensed',
23420 Roo.bootstrap.DateField.head,
23421 Roo.bootstrap.DateField.content,
23422 Roo.bootstrap.DateField.footer
23429 cls: 'datepicker-years',
23433 cls: 'table-condensed',
23435 Roo.bootstrap.DateField.head,
23436 Roo.bootstrap.DateField.content,
23437 Roo.bootstrap.DateField.footer
23456 * @class Roo.bootstrap.TimeField
23457 * @extends Roo.bootstrap.Input
23458 * Bootstrap DateField class
23462 * Create a new TimeField
23463 * @param {Object} config The config object
23466 Roo.bootstrap.TimeField = function(config){
23467 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
23471 * Fires when this field show.
23472 * @param {Roo.bootstrap.DateField} thisthis
23473 * @param {Mixed} date The date value
23478 * Fires when this field hide.
23479 * @param {Roo.bootstrap.DateField} this
23480 * @param {Mixed} date The date value
23485 * Fires when select a date.
23486 * @param {Roo.bootstrap.DateField} this
23487 * @param {Mixed} date The date value
23493 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
23496 * @cfg {String} format
23497 * The default time format string which can be overriden for localization support. The format must be
23498 * valid according to {@link Date#parseDate} (defaults to 'H:i').
23502 getAutoCreate : function()
23504 this.after = '<i class="fa far fa-clock"></i>';
23505 return Roo.bootstrap.TimeField.superclass.getAutoCreate.call(this);
23509 onRender: function(ct, position)
23512 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
23514 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.TimeField.template);
23516 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
23518 this.pop = this.picker().select('>.datepicker-time',true).first();
23519 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
23521 this.picker().on('mousedown', this.onMousedown, this);
23522 this.picker().on('click', this.onClick, this);
23524 this.picker().addClass('datepicker-dropdown');
23529 this.pop.select('.hours-up', true).first().on('click', this.onIncrementHours, this);
23530 this.pop.select('.hours-down', true).first().on('click', this.onDecrementHours, this);
23531 this.pop.select('.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
23532 this.pop.select('.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
23533 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
23534 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
23538 fireKey: function(e){
23539 if (!this.picker().isVisible()){
23540 if (e.keyCode == 27) { // allow escape to hide and re-show picker
23546 e.preventDefault();
23554 this.onTogglePeriod();
23557 this.onIncrementMinutes();
23560 this.onDecrementMinutes();
23569 onClick: function(e) {
23570 e.stopPropagation();
23571 e.preventDefault();
23574 picker : function()
23576 return this.pickerEl;
23579 fillTime: function()
23581 var time = this.pop.select('tbody', true).first();
23583 time.dom.innerHTML = '';
23598 cls: 'hours-up fa fas fa-chevron-up'
23618 cls: 'minutes-up fa fas fa-chevron-up'
23639 cls: 'timepicker-hour',
23654 cls: 'timepicker-minute',
23669 cls: 'btn btn-primary period',
23691 cls: 'hours-down fa fas fa-chevron-down'
23711 cls: 'minutes-down fa fas fa-chevron-down'
23729 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
23736 var hours = this.time.getHours();
23737 var minutes = this.time.getMinutes();
23750 hours = hours - 12;
23754 hours = '0' + hours;
23758 minutes = '0' + minutes;
23761 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
23762 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
23763 this.pop.select('button', true).first().dom.innerHTML = period;
23769 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
23771 var cls = ['bottom'];
23773 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
23780 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
23784 //this.picker().setXY(20000,20000);
23785 this.picker().addClass(cls.join('-'));
23789 Roo.each(cls, function(c){
23794 _this.picker().alignTo(_this.inputEl(), "tr-br", [0, 10], false);
23795 //_this.picker().setTop(_this.inputEl().getHeight());
23799 _this.picker().alignTo(_this.inputEl(), "br-tr", [0, 10], false);
23801 //_this.picker().setTop(0 - _this.picker().getHeight());
23806 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
23810 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
23818 onFocus : function()
23820 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
23824 onBlur : function()
23826 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
23832 this.picker().show();
23837 this.fireEvent('show', this, this.date);
23842 this.picker().hide();
23845 this.fireEvent('hide', this, this.date);
23848 setTime : function()
23851 this.setValue(this.time.format(this.format));
23853 this.fireEvent('select', this, this.date);
23858 onMousedown: function(e){
23859 e.stopPropagation();
23860 e.preventDefault();
23863 onIncrementHours: function()
23865 Roo.log('onIncrementHours');
23866 this.time = this.time.add(Date.HOUR, 1);
23871 onDecrementHours: function()
23873 Roo.log('onDecrementHours');
23874 this.time = this.time.add(Date.HOUR, -1);
23878 onIncrementMinutes: function()
23880 Roo.log('onIncrementMinutes');
23881 this.time = this.time.add(Date.MINUTE, 1);
23885 onDecrementMinutes: function()
23887 Roo.log('onDecrementMinutes');
23888 this.time = this.time.add(Date.MINUTE, -1);
23892 onTogglePeriod: function()
23894 Roo.log('onTogglePeriod');
23895 this.time = this.time.add(Date.HOUR, 12);
23903 Roo.apply(Roo.bootstrap.TimeField, {
23907 cls: 'datepicker dropdown-menu',
23911 cls: 'datepicker-time',
23915 cls: 'table-condensed',
23944 cls: 'btn btn-info ok',
23972 * @class Roo.bootstrap.MonthField
23973 * @extends Roo.bootstrap.Input
23974 * Bootstrap MonthField class
23976 * @cfg {String} language default en
23979 * Create a new MonthField
23980 * @param {Object} config The config object
23983 Roo.bootstrap.MonthField = function(config){
23984 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
23989 * Fires when this field show.
23990 * @param {Roo.bootstrap.MonthField} this
23991 * @param {Mixed} date The date value
23996 * Fires when this field hide.
23997 * @param {Roo.bootstrap.MonthField} this
23998 * @param {Mixed} date The date value
24003 * Fires when select a date.
24004 * @param {Roo.bootstrap.MonthField} this
24005 * @param {String} oldvalue The old value
24006 * @param {String} newvalue The new value
24012 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
24014 onRender: function(ct, position)
24017 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
24019 this.language = this.language || 'en';
24020 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
24021 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
24023 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
24024 this.isInline = false;
24025 this.isInput = true;
24026 this.component = this.el.select('.add-on', true).first() || false;
24027 this.component = (this.component && this.component.length === 0) ? false : this.component;
24028 this.hasInput = this.component && this.inputEL().length;
24030 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
24032 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
24034 this.picker().on('mousedown', this.onMousedown, this);
24035 this.picker().on('click', this.onClick, this);
24037 this.picker().addClass('datepicker-dropdown');
24039 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
24040 v.setStyle('width', '189px');
24047 if(this.isInline) {
24053 setValue: function(v, suppressEvent)
24055 var o = this.getValue();
24057 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
24061 if(suppressEvent !== true){
24062 this.fireEvent('select', this, o, v);
24067 getValue: function()
24072 onClick: function(e)
24074 e.stopPropagation();
24075 e.preventDefault();
24077 var target = e.getTarget();
24079 if(target.nodeName.toLowerCase() === 'i'){
24080 target = Roo.get(target).dom.parentNode;
24083 var nodeName = target.nodeName;
24084 var className = target.className;
24085 var html = target.innerHTML;
24087 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
24091 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
24093 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
24099 picker : function()
24101 return this.pickerEl;
24104 fillMonths: function()
24107 var months = this.picker().select('>.datepicker-months td', true).first();
24109 months.dom.innerHTML = '';
24115 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
24118 months.createChild(month);
24127 if(typeof(this.vIndex) == 'undefined' && this.value.length){
24128 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
24131 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
24132 e.removeClass('active');
24134 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
24135 e.addClass('active');
24142 if(this.isInline) {
24146 this.picker().removeClass(['bottom', 'top']);
24148 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
24150 * place to the top of element!
24154 this.picker().addClass('top');
24155 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
24160 this.picker().addClass('bottom');
24162 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
24165 onFocus : function()
24167 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
24171 onBlur : function()
24173 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
24175 var d = this.inputEl().getValue();
24184 this.picker().show();
24185 this.picker().select('>.datepicker-months', true).first().show();
24189 this.fireEvent('show', this, this.date);
24194 if(this.isInline) {
24197 this.picker().hide();
24198 this.fireEvent('hide', this, this.date);
24202 onMousedown: function(e)
24204 e.stopPropagation();
24205 e.preventDefault();
24210 Roo.bootstrap.MonthField.superclass.keyup.call(this);
24214 fireKey: function(e)
24216 if (!this.picker().isVisible()){
24217 if (e.keyCode == 27) {// allow escape to hide and re-show picker
24228 e.preventDefault();
24232 dir = e.keyCode == 37 ? -1 : 1;
24234 this.vIndex = this.vIndex + dir;
24236 if(this.vIndex < 0){
24240 if(this.vIndex > 11){
24244 if(isNaN(this.vIndex)){
24248 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
24254 dir = e.keyCode == 38 ? -1 : 1;
24256 this.vIndex = this.vIndex + dir * 4;
24258 if(this.vIndex < 0){
24262 if(this.vIndex > 11){
24266 if(isNaN(this.vIndex)){
24270 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
24275 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
24276 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
24280 e.preventDefault();
24283 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
24284 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
24300 this.picker().remove();
24305 Roo.apply(Roo.bootstrap.MonthField, {
24324 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
24325 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
24330 Roo.apply(Roo.bootstrap.MonthField, {
24334 cls: 'datepicker dropdown-menu roo-dynamic',
24338 cls: 'datepicker-months',
24342 cls: 'table-condensed',
24344 Roo.bootstrap.DateField.content
24364 * @class Roo.bootstrap.CheckBox
24365 * @extends Roo.bootstrap.Input
24366 * Bootstrap CheckBox class
24368 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
24369 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
24370 * @cfg {String} boxLabel The text that appears beside the checkbox
24371 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
24372 * @cfg {Boolean} checked initnal the element
24373 * @cfg {Boolean} inline inline the element (default false)
24374 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
24375 * @cfg {String} tooltip label tooltip
24378 * Create a new CheckBox
24379 * @param {Object} config The config object
24382 Roo.bootstrap.CheckBox = function(config){
24383 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
24388 * Fires when the element is checked or unchecked.
24389 * @param {Roo.bootstrap.CheckBox} this This input
24390 * @param {Boolean} checked The new checked value
24395 * Fires when the element is click.
24396 * @param {Roo.bootstrap.CheckBox} this This input
24403 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
24405 inputType: 'checkbox',
24414 // checkbox success does not make any sense really..
24419 getAutoCreate : function()
24421 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
24427 cfg.cls = 'form-group form-check ' + this.inputType; //input-group
24430 cfg.cls += ' ' + this.inputType + '-inline form-check-inline';
24436 type : this.inputType,
24437 value : this.inputValue,
24438 cls : 'roo-' + this.inputType, //'form-box',
24439 placeholder : this.placeholder || ''
24443 if(this.inputType != 'radio'){
24447 cls : 'roo-hidden-value',
24448 value : this.checked ? this.inputValue : this.valueOff
24453 if (this.weight) { // Validity check?
24454 cfg.cls += " " + this.inputType + "-" + this.weight;
24457 if (this.disabled) {
24458 input.disabled=true;
24462 input.checked = this.checked;
24467 input.name = this.name;
24469 if(this.inputType != 'radio'){
24470 hidden.name = this.name;
24471 input.name = '_hidden_' + this.name;
24476 input.cls += ' input-' + this.size;
24481 ['xs','sm','md','lg'].map(function(size){
24482 if (settings[size]) {
24483 cfg.cls += ' col-' + size + '-' + settings[size];
24487 var inputblock = input;
24489 if (this.before || this.after) {
24492 cls : 'input-group',
24497 inputblock.cn.push({
24499 cls : 'input-group-addon',
24504 inputblock.cn.push(input);
24506 if(this.inputType != 'radio'){
24507 inputblock.cn.push(hidden);
24511 inputblock.cn.push({
24513 cls : 'input-group-addon',
24519 var boxLabelCfg = false;
24525 //'for': id, // box label is handled by onclick - so no for...
24527 html: this.boxLabel
24530 boxLabelCfg.tooltip = this.tooltip;
24536 if (align ==='left' && this.fieldLabel.length) {
24537 // Roo.log("left and has label");
24542 cls : 'control-label',
24543 html : this.fieldLabel
24554 cfg.cn[1].cn.push(boxLabelCfg);
24557 if(this.labelWidth > 12){
24558 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
24561 if(this.labelWidth < 13 && this.labelmd == 0){
24562 this.labelmd = this.labelWidth;
24565 if(this.labellg > 0){
24566 cfg.cn[0].cls += ' col-lg-' + this.labellg;
24567 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
24570 if(this.labelmd > 0){
24571 cfg.cn[0].cls += ' col-md-' + this.labelmd;
24572 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
24575 if(this.labelsm > 0){
24576 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
24577 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
24580 if(this.labelxs > 0){
24581 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
24582 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
24585 } else if ( this.fieldLabel.length) {
24586 // Roo.log(" label");
24590 tag: this.boxLabel ? 'span' : 'label',
24592 cls: 'control-label box-input-label',
24593 //cls : 'input-group-addon',
24594 html : this.fieldLabel
24601 cfg.cn.push(boxLabelCfg);
24606 // Roo.log(" no label && no align");
24607 cfg.cn = [ inputblock ] ;
24609 cfg.cn.push(boxLabelCfg);
24617 if(this.inputType != 'radio'){
24618 cfg.cn.push(hidden);
24626 * return the real input element.
24628 inputEl: function ()
24630 return this.el.select('input.roo-' + this.inputType,true).first();
24632 hiddenEl: function ()
24634 return this.el.select('input.roo-hidden-value',true).first();
24637 labelEl: function()
24639 return this.el.select('label.control-label',true).first();
24641 /* depricated... */
24645 return this.labelEl();
24648 boxLabelEl: function()
24650 return this.el.select('label.box-label',true).first();
24653 initEvents : function()
24655 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
24657 this.inputEl().on('click', this.onClick, this);
24659 if (this.boxLabel) {
24660 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
24663 this.startValue = this.getValue();
24666 Roo.bootstrap.CheckBox.register(this);
24670 onClick : function(e)
24672 if(this.fireEvent('click', this, e) !== false){
24673 this.setChecked(!this.checked);
24678 setChecked : function(state,suppressEvent)
24680 this.startValue = this.getValue();
24682 if(this.inputType == 'radio'){
24684 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
24685 e.dom.checked = false;
24688 this.inputEl().dom.checked = true;
24690 this.inputEl().dom.value = this.inputValue;
24692 if(suppressEvent !== true){
24693 this.fireEvent('check', this, true);
24701 this.checked = state;
24703 this.inputEl().dom.checked = state;
24706 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
24708 if(suppressEvent !== true){
24709 this.fireEvent('check', this, state);
24715 getValue : function()
24717 if(this.inputType == 'radio'){
24718 return this.getGroupValue();
24721 return this.hiddenEl().dom.value;
24725 getGroupValue : function()
24727 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
24731 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
24734 setValue : function(v,suppressEvent)
24736 if(this.inputType == 'radio'){
24737 this.setGroupValue(v, suppressEvent);
24741 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
24746 setGroupValue : function(v, suppressEvent)
24748 this.startValue = this.getValue();
24750 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
24751 e.dom.checked = false;
24753 if(e.dom.value == v){
24754 e.dom.checked = true;
24758 if(suppressEvent !== true){
24759 this.fireEvent('check', this, true);
24767 validate : function()
24769 if(this.getVisibilityEl().hasClass('hidden')){
24775 (this.inputType == 'radio' && this.validateRadio()) ||
24776 (this.inputType == 'checkbox' && this.validateCheckbox())
24782 this.markInvalid();
24786 validateRadio : function()
24788 if(this.getVisibilityEl().hasClass('hidden')){
24792 if(this.allowBlank){
24798 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
24799 if(!e.dom.checked){
24811 validateCheckbox : function()
24814 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
24815 //return (this.getValue() == this.inputValue) ? true : false;
24818 var group = Roo.bootstrap.CheckBox.get(this.groupId);
24826 for(var i in group){
24827 if(group[i].el.isVisible(true)){
24835 for(var i in group){
24840 r = (group[i].getValue() == group[i].inputValue) ? true : false;
24847 * Mark this field as valid
24849 markValid : function()
24853 this.fireEvent('valid', this);
24855 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
24858 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
24865 if(this.inputType == 'radio'){
24866 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
24867 var fg = e.findParent('.form-group', false, true);
24868 if (Roo.bootstrap.version == 3) {
24869 fg.removeClass([_this.invalidClass, _this.validClass]);
24870 fg.addClass(_this.validClass);
24872 fg.removeClass(['is-valid', 'is-invalid']);
24873 fg.addClass('is-valid');
24881 var fg = this.el.findParent('.form-group', false, true);
24882 if (Roo.bootstrap.version == 3) {
24883 fg.removeClass([this.invalidClass, this.validClass]);
24884 fg.addClass(this.validClass);
24886 fg.removeClass(['is-valid', 'is-invalid']);
24887 fg.addClass('is-valid');
24892 var group = Roo.bootstrap.CheckBox.get(this.groupId);
24898 for(var i in group){
24899 var fg = group[i].el.findParent('.form-group', false, true);
24900 if (Roo.bootstrap.version == 3) {
24901 fg.removeClass([this.invalidClass, this.validClass]);
24902 fg.addClass(this.validClass);
24904 fg.removeClass(['is-valid', 'is-invalid']);
24905 fg.addClass('is-valid');
24911 * Mark this field as invalid
24912 * @param {String} msg The validation message
24914 markInvalid : function(msg)
24916 if(this.allowBlank){
24922 this.fireEvent('invalid', this, msg);
24924 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
24927 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
24931 label.markInvalid();
24934 if(this.inputType == 'radio'){
24936 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
24937 var fg = e.findParent('.form-group', false, true);
24938 if (Roo.bootstrap.version == 3) {
24939 fg.removeClass([_this.invalidClass, _this.validClass]);
24940 fg.addClass(_this.invalidClass);
24942 fg.removeClass(['is-invalid', 'is-valid']);
24943 fg.addClass('is-invalid');
24951 var fg = this.el.findParent('.form-group', false, true);
24952 if (Roo.bootstrap.version == 3) {
24953 fg.removeClass([_this.invalidClass, _this.validClass]);
24954 fg.addClass(_this.invalidClass);
24956 fg.removeClass(['is-invalid', 'is-valid']);
24957 fg.addClass('is-invalid');
24962 var group = Roo.bootstrap.CheckBox.get(this.groupId);
24968 for(var i in group){
24969 var fg = group[i].el.findParent('.form-group', false, true);
24970 if (Roo.bootstrap.version == 3) {
24971 fg.removeClass([_this.invalidClass, _this.validClass]);
24972 fg.addClass(_this.invalidClass);
24974 fg.removeClass(['is-invalid', 'is-valid']);
24975 fg.addClass('is-invalid');
24981 clearInvalid : function()
24983 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
24985 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
24987 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
24989 if (label && label.iconEl) {
24990 label.iconEl.removeClass([ label.validClass, label.invalidClass ]);
24991 label.iconEl.removeClass(['is-invalid', 'is-valid']);
24995 disable : function()
24997 if(this.inputType != 'radio'){
24998 Roo.bootstrap.CheckBox.superclass.disable.call(this);
25005 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
25006 _this.getActionEl().addClass(this.disabledClass);
25007 e.dom.disabled = true;
25011 this.disabled = true;
25012 this.fireEvent("disable", this);
25016 enable : function()
25018 if(this.inputType != 'radio'){
25019 Roo.bootstrap.CheckBox.superclass.enable.call(this);
25026 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
25027 _this.getActionEl().removeClass(this.disabledClass);
25028 e.dom.disabled = false;
25032 this.disabled = false;
25033 this.fireEvent("enable", this);
25037 setBoxLabel : function(v)
25042 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
25048 Roo.apply(Roo.bootstrap.CheckBox, {
25053 * register a CheckBox Group
25054 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
25056 register : function(checkbox)
25058 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
25059 this.groups[checkbox.groupId] = {};
25062 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
25066 this.groups[checkbox.groupId][checkbox.name] = checkbox;
25070 * fetch a CheckBox Group based on the group ID
25071 * @param {string} the group ID
25072 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
25074 get: function(groupId) {
25075 if (typeof(this.groups[groupId]) == 'undefined') {
25079 return this.groups[groupId] ;
25092 * @class Roo.bootstrap.Radio
25093 * @extends Roo.bootstrap.Component
25094 * Bootstrap Radio class
25095 * @cfg {String} boxLabel - the label associated
25096 * @cfg {String} value - the value of radio
25099 * Create a new Radio
25100 * @param {Object} config The config object
25102 Roo.bootstrap.Radio = function(config){
25103 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
25107 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
25113 getAutoCreate : function()
25117 cls : 'form-group radio',
25122 html : this.boxLabel
25130 initEvents : function()
25132 this.parent().register(this);
25134 this.el.on('click', this.onClick, this);
25138 onClick : function(e)
25140 if(this.parent().fireEvent('click', this.parent(), this, e) !== false){
25141 this.setChecked(true);
25145 setChecked : function(state, suppressEvent)
25147 this.parent().setValue(this.value, suppressEvent);
25151 setBoxLabel : function(v)
25156 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
25171 * @class Roo.bootstrap.SecurePass
25172 * @extends Roo.bootstrap.Input
25173 * Bootstrap SecurePass class
25177 * Create a new SecurePass
25178 * @param {Object} config The config object
25181 Roo.bootstrap.SecurePass = function (config) {
25182 // these go here, so the translation tool can replace them..
25184 PwdEmpty: "Please type a password, and then retype it to confirm.",
25185 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
25186 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
25187 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
25188 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
25189 FNInPwd: "Your password can't contain your first name. Please type a different password.",
25190 LNInPwd: "Your password can't contain your last name. Please type a different password.",
25191 TooWeak: "Your password is Too Weak."
25193 this.meterLabel = "Password strength:";
25194 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
25195 this.meterClass = [
25196 "roo-password-meter-tooweak",
25197 "roo-password-meter-weak",
25198 "roo-password-meter-medium",
25199 "roo-password-meter-strong",
25200 "roo-password-meter-grey"
25205 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
25208 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
25210 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
25212 * PwdEmpty: "Please type a password, and then retype it to confirm.",
25213 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
25214 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
25215 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
25216 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
25217 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
25218 * LNInPwd: "Your password can't contain your last name. Please type a different password."
25228 * @cfg {String/Object} Label for the strength meter (defaults to
25229 * 'Password strength:')
25234 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
25235 * ['Weak', 'Medium', 'Strong'])
25238 pwdStrengths: false,
25251 initEvents: function ()
25253 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
25255 if (this.el.is('input[type=password]') && Roo.isSafari) {
25256 this.el.on('keydown', this.SafariOnKeyDown, this);
25259 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
25262 onRender: function (ct, position)
25264 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
25265 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
25266 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
25268 this.trigger.createChild({
25273 cls: 'roo-password-meter-grey col-xs-12',
25276 //width: this.meterWidth + 'px'
25280 cls: 'roo-password-meter-text'
25286 if (this.hideTrigger) {
25287 this.trigger.setDisplayed(false);
25289 this.setSize(this.width || '', this.height || '');
25292 onDestroy: function ()
25294 if (this.trigger) {
25295 this.trigger.removeAllListeners();
25296 this.trigger.remove();
25299 this.wrap.remove();
25301 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
25304 checkStrength: function ()
25306 var pwd = this.inputEl().getValue();
25307 if (pwd == this._lastPwd) {
25312 if (this.ClientSideStrongPassword(pwd)) {
25314 } else if (this.ClientSideMediumPassword(pwd)) {
25316 } else if (this.ClientSideWeakPassword(pwd)) {
25322 Roo.log('strength1: ' + strength);
25324 //var pm = this.trigger.child('div/div/div').dom;
25325 var pm = this.trigger.child('div/div');
25326 pm.removeClass(this.meterClass);
25327 pm.addClass(this.meterClass[strength]);
25330 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
25332 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
25334 this._lastPwd = pwd;
25338 Roo.bootstrap.SecurePass.superclass.reset.call(this);
25340 this._lastPwd = '';
25342 var pm = this.trigger.child('div/div');
25343 pm.removeClass(this.meterClass);
25344 pm.addClass('roo-password-meter-grey');
25347 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
25350 this.inputEl().dom.type='password';
25353 validateValue: function (value)
25355 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
25358 if (value.length == 0) {
25359 if (this.allowBlank) {
25360 this.clearInvalid();
25364 this.markInvalid(this.errors.PwdEmpty);
25365 this.errorMsg = this.errors.PwdEmpty;
25373 if (!value.match(/[\x21-\x7e]+/)) {
25374 this.markInvalid(this.errors.PwdBadChar);
25375 this.errorMsg = this.errors.PwdBadChar;
25378 if (value.length < 6) {
25379 this.markInvalid(this.errors.PwdShort);
25380 this.errorMsg = this.errors.PwdShort;
25383 if (value.length > 16) {
25384 this.markInvalid(this.errors.PwdLong);
25385 this.errorMsg = this.errors.PwdLong;
25389 if (this.ClientSideStrongPassword(value)) {
25391 } else if (this.ClientSideMediumPassword(value)) {
25393 } else if (this.ClientSideWeakPassword(value)) {
25400 if (strength < 2) {
25401 //this.markInvalid(this.errors.TooWeak);
25402 this.errorMsg = this.errors.TooWeak;
25407 console.log('strength2: ' + strength);
25409 //var pm = this.trigger.child('div/div/div').dom;
25411 var pm = this.trigger.child('div/div');
25412 pm.removeClass(this.meterClass);
25413 pm.addClass(this.meterClass[strength]);
25415 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
25417 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
25419 this.errorMsg = '';
25423 CharacterSetChecks: function (type)
25426 this.fResult = false;
25429 isctype: function (character, type)
25432 case this.kCapitalLetter:
25433 if (character >= 'A' && character <= 'Z') {
25438 case this.kSmallLetter:
25439 if (character >= 'a' && character <= 'z') {
25445 if (character >= '0' && character <= '9') {
25450 case this.kPunctuation:
25451 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
25462 IsLongEnough: function (pwd, size)
25464 return !(pwd == null || isNaN(size) || pwd.length < size);
25467 SpansEnoughCharacterSets: function (word, nb)
25469 if (!this.IsLongEnough(word, nb))
25474 var characterSetChecks = new Array(
25475 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
25476 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
25479 for (var index = 0; index < word.length; ++index) {
25480 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
25481 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
25482 characterSetChecks[nCharSet].fResult = true;
25489 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
25490 if (characterSetChecks[nCharSet].fResult) {
25495 if (nCharSets < nb) {
25501 ClientSideStrongPassword: function (pwd)
25503 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
25506 ClientSideMediumPassword: function (pwd)
25508 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
25511 ClientSideWeakPassword: function (pwd)
25513 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
25516 })//<script type="text/javascript">
25519 * Based Ext JS Library 1.1.1
25520 * Copyright(c) 2006-2007, Ext JS, LLC.
25526 * @class Roo.HtmlEditorCore
25527 * @extends Roo.Component
25528 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
25530 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
25533 Roo.HtmlEditorCore = function(config){
25536 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
25541 * @event initialize
25542 * Fires when the editor is fully initialized (including the iframe)
25543 * @param {Roo.HtmlEditorCore} this
25548 * Fires when the editor is first receives the focus. Any insertion must wait
25549 * until after this event.
25550 * @param {Roo.HtmlEditorCore} this
25554 * @event beforesync
25555 * Fires before the textarea is updated with content from the editor iframe. Return false
25556 * to cancel the sync.
25557 * @param {Roo.HtmlEditorCore} this
25558 * @param {String} html
25562 * @event beforepush
25563 * Fires before the iframe editor is updated with content from the textarea. Return false
25564 * to cancel the push.
25565 * @param {Roo.HtmlEditorCore} this
25566 * @param {String} html
25571 * Fires when the textarea is updated with content from the editor iframe.
25572 * @param {Roo.HtmlEditorCore} this
25573 * @param {String} html
25578 * Fires when the iframe editor is updated with content from the textarea.
25579 * @param {Roo.HtmlEditorCore} this
25580 * @param {String} html
25585 * @event editorevent
25586 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
25587 * @param {Roo.HtmlEditorCore} this
25593 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
25595 // defaults : white / black...
25596 this.applyBlacklists();
25603 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
25607 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
25613 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
25618 * @cfg {Number} height (in pixels)
25622 * @cfg {Number} width (in pixels)
25627 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
25630 stylesheets: false,
25633 * @cfg {boolean} allowComments - default false - allow comments in HTML source - by default they are stripped - if you are editing email you may need this.
25635 allowComments: false,
25639 // private properties
25640 validationEvent : false,
25642 initialized : false,
25644 sourceEditMode : false,
25645 onFocus : Roo.emptyFn,
25647 hideMode:'offsets',
25651 // blacklist + whitelisted elements..
25658 * Protected method that will not generally be called directly. It
25659 * is called when the editor initializes the iframe with HTML contents. Override this method if you
25660 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
25662 getDocMarkup : function(){
25666 // inherit styels from page...??
25667 if (this.stylesheets === false) {
25669 Roo.get(document.head).select('style').each(function(node) {
25670 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
25673 Roo.get(document.head).select('link').each(function(node) {
25674 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
25677 } else if (!this.stylesheets.length) {
25679 st = '<style type="text/css">' +
25680 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
25683 for (var i in this.stylesheets) {
25684 st += '<link rel="stylesheet" href="' + this.stylesheets[i] +'" type="text/css">';
25689 st += '<style type="text/css">' +
25690 'IMG { cursor: pointer } ' +
25693 var cls = 'roo-htmleditor-body';
25695 if(this.bodyCls.length){
25696 cls += ' ' + this.bodyCls;
25699 return '<html><head>' + st +
25700 //<style type="text/css">' +
25701 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
25703 ' </head><body contenteditable="true" data-enable-grammerly="true" class="' + cls + '"></body></html>';
25707 onRender : function(ct, position)
25710 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
25711 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
25714 this.el.dom.style.border = '0 none';
25715 this.el.dom.setAttribute('tabIndex', -1);
25716 this.el.addClass('x-hidden hide');
25720 if(Roo.isIE){ // fix IE 1px bogus margin
25721 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
25725 this.frameId = Roo.id();
25729 var iframe = this.owner.wrap.createChild({
25731 cls: 'form-control', // bootstrap..
25733 name: this.frameId,
25734 frameBorder : 'no',
25735 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
25740 this.iframe = iframe.dom;
25742 this.assignDocWin();
25744 this.doc.designMode = 'on';
25747 this.doc.write(this.getDocMarkup());
25751 var task = { // must defer to wait for browser to be ready
25753 //console.log("run task?" + this.doc.readyState);
25754 this.assignDocWin();
25755 if(this.doc.body || this.doc.readyState == 'complete'){
25757 this.doc.designMode="on";
25761 Roo.TaskMgr.stop(task);
25762 this.initEditor.defer(10, this);
25769 Roo.TaskMgr.start(task);
25774 onResize : function(w, h)
25776 Roo.log('resize: ' +w + ',' + h );
25777 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
25781 if(typeof w == 'number'){
25783 this.iframe.style.width = w + 'px';
25785 if(typeof h == 'number'){
25787 this.iframe.style.height = h + 'px';
25789 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
25796 * Toggles the editor between standard and source edit mode.
25797 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
25799 toggleSourceEdit : function(sourceEditMode){
25801 this.sourceEditMode = sourceEditMode === true;
25803 if(this.sourceEditMode){
25805 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
25808 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
25809 //this.iframe.className = '';
25812 //this.setSize(this.owner.wrap.getSize());
25813 //this.fireEvent('editmodechange', this, this.sourceEditMode);
25820 * Protected method that will not generally be called directly. If you need/want
25821 * custom HTML cleanup, this is the method you should override.
25822 * @param {String} html The HTML to be cleaned
25823 * return {String} The cleaned HTML
25825 cleanHtml : function(html){
25826 html = String(html);
25827 if(html.length > 5){
25828 if(Roo.isSafari){ // strip safari nonsense
25829 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
25832 if(html == ' '){
25839 * HTML Editor -> Textarea
25840 * Protected method that will not generally be called directly. Syncs the contents
25841 * of the editor iframe with the textarea.
25843 syncValue : function(){
25844 if(this.initialized){
25845 var bd = (this.doc.body || this.doc.documentElement);
25846 //this.cleanUpPaste(); -- this is done else where and causes havoc..
25847 var html = bd.innerHTML;
25849 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
25850 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
25852 html = '<div style="'+m[0]+'">' + html + '</div>';
25855 html = this.cleanHtml(html);
25856 // fix up the special chars.. normaly like back quotes in word...
25857 // however we do not want to do this with chinese..
25858 html = html.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[\u0080-\uFFFF]/g, function(match) {
25860 var cc = match.charCodeAt();
25862 // Get the character value, handling surrogate pairs
25863 if (match.length == 2) {
25864 // It's a surrogate pair, calculate the Unicode code point
25865 var high = match.charCodeAt(0) - 0xD800;
25866 var low = match.charCodeAt(1) - 0xDC00;
25867 cc = (high * 0x400) + low + 0x10000;
25869 (cc >= 0x4E00 && cc < 0xA000 ) ||
25870 (cc >= 0x3400 && cc < 0x4E00 ) ||
25871 (cc >= 0xf900 && cc < 0xfb00 )
25876 // No, use a numeric entity. Here we brazenly (and possibly mistakenly)
25877 return "&#" + cc + ";";
25884 if(this.owner.fireEvent('beforesync', this, html) !== false){
25885 this.el.dom.value = html;
25886 this.owner.fireEvent('sync', this, html);
25892 * Protected method that will not generally be called directly. Pushes the value of the textarea
25893 * into the iframe editor.
25895 pushValue : function(){
25896 if(this.initialized){
25897 var v = this.el.dom.value.trim();
25899 // if(v.length < 1){
25903 if(this.owner.fireEvent('beforepush', this, v) !== false){
25904 var d = (this.doc.body || this.doc.documentElement);
25906 this.cleanUpPaste();
25907 this.el.dom.value = d.innerHTML;
25908 this.owner.fireEvent('push', this, v);
25914 deferFocus : function(){
25915 this.focus.defer(10, this);
25919 focus : function(){
25920 if(this.win && !this.sourceEditMode){
25927 assignDocWin: function()
25929 var iframe = this.iframe;
25932 this.doc = iframe.contentWindow.document;
25933 this.win = iframe.contentWindow;
25935 // if (!Roo.get(this.frameId)) {
25938 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
25939 // this.win = Roo.get(this.frameId).dom.contentWindow;
25941 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
25945 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
25946 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
25951 initEditor : function(){
25952 //console.log("INIT EDITOR");
25953 this.assignDocWin();
25957 this.doc.designMode="on";
25959 this.doc.write(this.getDocMarkup());
25962 var dbody = (this.doc.body || this.doc.documentElement);
25963 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
25964 // this copies styles from the containing element into thsi one..
25965 // not sure why we need all of this..
25966 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
25968 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
25969 //ss['background-attachment'] = 'fixed'; // w3c
25970 dbody.bgProperties = 'fixed'; // ie
25971 //Roo.DomHelper.applyStyles(dbody, ss);
25972 Roo.EventManager.on(this.doc, {
25973 //'mousedown': this.onEditorEvent,
25974 'mouseup': this.onEditorEvent,
25975 'dblclick': this.onEditorEvent,
25976 'click': this.onEditorEvent,
25977 'keyup': this.onEditorEvent,
25982 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
25984 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
25985 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
25987 this.initialized = true;
25989 this.owner.fireEvent('initialize', this);
25994 onDestroy : function(){
26000 //for (var i =0; i < this.toolbars.length;i++) {
26001 // // fixme - ask toolbars for heights?
26002 // this.toolbars[i].onDestroy();
26005 //this.wrap.dom.innerHTML = '';
26006 //this.wrap.remove();
26011 onFirstFocus : function(){
26013 this.assignDocWin();
26016 this.activated = true;
26019 if(Roo.isGecko){ // prevent silly gecko errors
26021 var s = this.win.getSelection();
26022 if(!s.focusNode || s.focusNode.nodeType != 3){
26023 var r = s.getRangeAt(0);
26024 r.selectNodeContents((this.doc.body || this.doc.documentElement));
26029 this.execCmd('useCSS', true);
26030 this.execCmd('styleWithCSS', false);
26033 this.owner.fireEvent('activate', this);
26037 adjustFont: function(btn){
26038 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
26039 //if(Roo.isSafari){ // safari
26042 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
26043 if(Roo.isSafari){ // safari
26044 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
26045 v = (v < 10) ? 10 : v;
26046 v = (v > 48) ? 48 : v;
26047 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
26052 v = Math.max(1, v+adjust);
26054 this.execCmd('FontSize', v );
26057 onEditorEvent : function(e)
26059 this.owner.fireEvent('editorevent', this, e);
26060 // this.updateToolbar();
26061 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
26064 insertTag : function(tg)
26066 // could be a bit smarter... -> wrap the current selected tRoo..
26067 if (tg.toLowerCase() == 'span' ||
26068 tg.toLowerCase() == 'code' ||
26069 tg.toLowerCase() == 'sup' ||
26070 tg.toLowerCase() == 'sub'
26073 range = this.createRange(this.getSelection());
26074 var wrappingNode = this.doc.createElement(tg.toLowerCase());
26075 wrappingNode.appendChild(range.extractContents());
26076 range.insertNode(wrappingNode);
26083 this.execCmd("formatblock", tg);
26087 insertText : function(txt)
26091 var range = this.createRange();
26092 range.deleteContents();
26093 //alert(Sender.getAttribute('label'));
26095 range.insertNode(this.doc.createTextNode(txt));
26101 * Executes a Midas editor command on the editor document and performs necessary focus and
26102 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
26103 * @param {String} cmd The Midas command
26104 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
26106 relayCmd : function(cmd, value){
26108 this.execCmd(cmd, value);
26109 this.owner.fireEvent('editorevent', this);
26110 //this.updateToolbar();
26111 this.owner.deferFocus();
26115 * Executes a Midas editor command directly on the editor document.
26116 * For visual commands, you should use {@link #relayCmd} instead.
26117 * <b>This should only be called after the editor is initialized.</b>
26118 * @param {String} cmd The Midas command
26119 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
26121 execCmd : function(cmd, value){
26122 this.doc.execCommand(cmd, false, value === undefined ? null : value);
26129 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
26131 * @param {String} text | dom node..
26133 insertAtCursor : function(text)
26136 if(!this.activated){
26142 var r = this.doc.selection.createRange();
26153 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
26157 // from jquery ui (MIT licenced)
26159 var win = this.win;
26161 if (win.getSelection && win.getSelection().getRangeAt) {
26162 range = win.getSelection().getRangeAt(0);
26163 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
26164 range.insertNode(node);
26165 } else if (win.document.selection && win.document.selection.createRange) {
26166 // no firefox support
26167 var txt = typeof(text) == 'string' ? text : text.outerHTML;
26168 win.document.selection.createRange().pasteHTML(txt);
26170 // no firefox support
26171 var txt = typeof(text) == 'string' ? text : text.outerHTML;
26172 this.execCmd('InsertHTML', txt);
26181 mozKeyPress : function(e){
26183 var c = e.getCharCode(), cmd;
26186 c = String.fromCharCode(c).toLowerCase();
26200 this.cleanUpPaste.defer(100, this);
26208 e.preventDefault();
26216 fixKeys : function(){ // load time branching for fastest keydown performance
26218 return function(e){
26219 var k = e.getKey(), r;
26222 r = this.doc.selection.createRange();
26225 r.pasteHTML('    ');
26232 r = this.doc.selection.createRange();
26234 var target = r.parentElement();
26235 if(!target || target.tagName.toLowerCase() != 'li'){
26237 r.pasteHTML('<br />');
26243 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
26244 this.cleanUpPaste.defer(100, this);
26250 }else if(Roo.isOpera){
26251 return function(e){
26252 var k = e.getKey();
26256 this.execCmd('InsertHTML','    ');
26259 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
26260 this.cleanUpPaste.defer(100, this);
26265 }else if(Roo.isSafari){
26266 return function(e){
26267 var k = e.getKey();
26271 this.execCmd('InsertText','\t');
26275 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
26276 this.cleanUpPaste.defer(100, this);
26284 getAllAncestors: function()
26286 var p = this.getSelectedNode();
26289 a.push(p); // push blank onto stack..
26290 p = this.getParentElement();
26294 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
26298 a.push(this.doc.body);
26302 lastSelNode : false,
26305 getSelection : function()
26307 this.assignDocWin();
26308 return Roo.isIE ? this.doc.selection : this.win.getSelection();
26311 getSelectedNode: function()
26313 // this may only work on Gecko!!!
26315 // should we cache this!!!!
26320 var range = this.createRange(this.getSelection()).cloneRange();
26323 var parent = range.parentElement();
26325 var testRange = range.duplicate();
26326 testRange.moveToElementText(parent);
26327 if (testRange.inRange(range)) {
26330 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
26333 parent = parent.parentElement;
26338 // is ancestor a text element.
26339 var ac = range.commonAncestorContainer;
26340 if (ac.nodeType == 3) {
26341 ac = ac.parentNode;
26344 var ar = ac.childNodes;
26347 var other_nodes = [];
26348 var has_other_nodes = false;
26349 for (var i=0;i<ar.length;i++) {
26350 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
26353 // fullly contained node.
26355 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
26360 // probably selected..
26361 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
26362 other_nodes.push(ar[i]);
26366 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
26371 has_other_nodes = true;
26373 if (!nodes.length && other_nodes.length) {
26374 nodes= other_nodes;
26376 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
26382 createRange: function(sel)
26384 // this has strange effects when using with
26385 // top toolbar - not sure if it's a great idea.
26386 //this.editor.contentWindow.focus();
26387 if (typeof sel != "undefined") {
26389 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
26391 return this.doc.createRange();
26394 return this.doc.createRange();
26397 getParentElement: function()
26400 this.assignDocWin();
26401 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
26403 var range = this.createRange(sel);
26406 var p = range.commonAncestorContainer;
26407 while (p.nodeType == 3) { // text node
26418 * Range intersection.. the hard stuff...
26422 * [ -- selected range --- ]
26426 * if end is before start or hits it. fail.
26427 * if start is after end or hits it fail.
26429 * if either hits (but other is outside. - then it's not
26435 // @see http://www.thismuchiknow.co.uk/?p=64.
26436 rangeIntersectsNode : function(range, node)
26438 var nodeRange = node.ownerDocument.createRange();
26440 nodeRange.selectNode(node);
26442 nodeRange.selectNodeContents(node);
26445 var rangeStartRange = range.cloneRange();
26446 rangeStartRange.collapse(true);
26448 var rangeEndRange = range.cloneRange();
26449 rangeEndRange.collapse(false);
26451 var nodeStartRange = nodeRange.cloneRange();
26452 nodeStartRange.collapse(true);
26454 var nodeEndRange = nodeRange.cloneRange();
26455 nodeEndRange.collapse(false);
26457 return rangeStartRange.compareBoundaryPoints(
26458 Range.START_TO_START, nodeEndRange) == -1 &&
26459 rangeEndRange.compareBoundaryPoints(
26460 Range.START_TO_START, nodeStartRange) == 1;
26464 rangeCompareNode : function(range, node)
26466 var nodeRange = node.ownerDocument.createRange();
26468 nodeRange.selectNode(node);
26470 nodeRange.selectNodeContents(node);
26474 range.collapse(true);
26476 nodeRange.collapse(true);
26478 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
26479 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
26481 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
26483 var nodeIsBefore = ss == 1;
26484 var nodeIsAfter = ee == -1;
26486 if (nodeIsBefore && nodeIsAfter) {
26489 if (!nodeIsBefore && nodeIsAfter) {
26490 return 1; //right trailed.
26493 if (nodeIsBefore && !nodeIsAfter) {
26494 return 2; // left trailed.
26500 // private? - in a new class?
26501 cleanUpPaste : function()
26503 // cleans up the whole document..
26504 Roo.log('cleanuppaste');
26506 this.cleanUpChildren(this.doc.body);
26507 var clean = this.cleanWordChars(this.doc.body.innerHTML);
26508 if (clean != this.doc.body.innerHTML) {
26509 this.doc.body.innerHTML = clean;
26514 cleanWordChars : function(input) {// change the chars to hex code
26515 var he = Roo.HtmlEditorCore;
26517 var output = input;
26518 Roo.each(he.swapCodes, function(sw) {
26519 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
26521 output = output.replace(swapper, sw[1]);
26528 cleanUpChildren : function (n)
26530 if (!n.childNodes.length) {
26533 for (var i = n.childNodes.length-1; i > -1 ; i--) {
26534 this.cleanUpChild(n.childNodes[i]);
26541 cleanUpChild : function (node)
26544 //console.log(node);
26545 if (node.nodeName == "#text") {
26546 // clean up silly Windows -- stuff?
26549 if (node.nodeName == "#comment") {
26550 if (!this.allowComments) {
26551 node.parentNode.removeChild(node);
26553 // clean up silly Windows -- stuff?
26556 var lcname = node.tagName.toLowerCase();
26557 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
26558 // whitelist of tags..
26560 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
26562 node.parentNode.removeChild(node);
26567 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
26569 // spans with no attributes - just remove them..
26570 if ((!node.attributes || !node.attributes.length) && lcname == 'span') {
26571 remove_keep_children = true;
26574 // remove <a name=....> as rendering on yahoo mailer is borked with this.
26575 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
26577 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
26578 // remove_keep_children = true;
26581 if (remove_keep_children) {
26582 this.cleanUpChildren(node);
26583 // inserts everything just before this node...
26584 while (node.childNodes.length) {
26585 var cn = node.childNodes[0];
26586 node.removeChild(cn);
26587 node.parentNode.insertBefore(cn, node);
26589 node.parentNode.removeChild(node);
26593 if (!node.attributes || !node.attributes.length) {
26598 this.cleanUpChildren(node);
26602 function cleanAttr(n,v)
26605 if (v.match(/^\./) || v.match(/^\//)) {
26608 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/) || v.match(/^ftp:/)) {
26611 if (v.match(/^#/)) {
26614 if (v.match(/^\{/)) { // allow template editing.
26617 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
26618 node.removeAttribute(n);
26622 var cwhite = this.cwhite;
26623 var cblack = this.cblack;
26625 function cleanStyle(n,v)
26627 if (v.match(/expression/)) { //XSS?? should we even bother..
26628 node.removeAttribute(n);
26632 var parts = v.split(/;/);
26635 Roo.each(parts, function(p) {
26636 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
26640 var l = p.split(':').shift().replace(/\s+/g,'');
26641 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
26643 if ( cwhite.length && cblack.indexOf(l) > -1) {
26644 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
26645 //node.removeAttribute(n);
26649 // only allow 'c whitelisted system attributes'
26650 if ( cwhite.length && cwhite.indexOf(l) < 0) {
26651 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
26652 //node.removeAttribute(n);
26662 if (clean.length) {
26663 node.setAttribute(n, clean.join(';'));
26665 node.removeAttribute(n);
26671 for (var i = node.attributes.length-1; i > -1 ; i--) {
26672 var a = node.attributes[i];
26675 if (a.name.toLowerCase().substr(0,2)=='on') {
26676 node.removeAttribute(a.name);
26679 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
26680 node.removeAttribute(a.name);
26683 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
26684 cleanAttr(a.name,a.value); // fixme..
26687 if (a.name == 'style') {
26688 cleanStyle(a.name,a.value);
26691 /// clean up MS crap..
26692 // tecnically this should be a list of valid class'es..
26695 if (a.name == 'class') {
26696 if (a.value.match(/^Mso/)) {
26697 node.removeAttribute('class');
26700 if (a.value.match(/^body$/)) {
26701 node.removeAttribute('class');
26712 this.cleanUpChildren(node);
26718 * Clean up MS wordisms...
26720 cleanWord : function(node)
26723 this.cleanWord(this.doc.body);
26728 node.nodeName == 'SPAN' &&
26729 !node.hasAttributes() &&
26730 node.childNodes.length == 1 &&
26731 node.firstChild.nodeName == "#text"
26733 var textNode = node.firstChild;
26734 node.removeChild(textNode);
26735 if (node.getAttribute('lang') != 'zh-CN') { // do not space pad on chinese characters..
26736 node.parentNode.insertBefore(node.ownerDocument.createTextNode(" "), node);
26738 node.parentNode.insertBefore(textNode, node);
26739 if (node.getAttribute('lang') != 'zh-CN') { // do not space pad on chinese characters..
26740 node.parentNode.insertBefore(node.ownerDocument.createTextNode(" ") , node);
26742 node.parentNode.removeChild(node);
26745 if (node.nodeName == "#text") {
26746 // clean up silly Windows -- stuff?
26749 if (node.nodeName == "#comment") {
26750 node.parentNode.removeChild(node);
26751 // clean up silly Windows -- stuff?
26755 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
26756 node.parentNode.removeChild(node);
26759 //Roo.log(node.tagName);
26760 // remove - but keep children..
26761 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|v:|font)/)) {
26762 //Roo.log('-- removed');
26763 while (node.childNodes.length) {
26764 var cn = node.childNodes[0];
26765 node.removeChild(cn);
26766 node.parentNode.insertBefore(cn, node);
26767 // move node to parent - and clean it..
26768 this.cleanWord(cn);
26770 node.parentNode.removeChild(node);
26771 /// no need to iterate chidlren = it's got none..
26772 //this.iterateChildren(node, this.cleanWord);
26776 if (node.className.length) {
26778 var cn = node.className.split(/\W+/);
26780 Roo.each(cn, function(cls) {
26781 if (cls.match(/Mso[a-zA-Z]+/)) {
26786 node.className = cna.length ? cna.join(' ') : '';
26788 node.removeAttribute("class");
26792 if (node.hasAttribute("lang")) {
26793 node.removeAttribute("lang");
26796 if (node.hasAttribute("style")) {
26798 var styles = node.getAttribute("style").split(";");
26800 Roo.each(styles, function(s) {
26801 if (!s.match(/:/)) {
26804 var kv = s.split(":");
26805 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
26808 // what ever is left... we allow.
26811 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
26812 if (!nstyle.length) {
26813 node.removeAttribute('style');
26816 this.iterateChildren(node, this.cleanWord);
26822 * iterateChildren of a Node, calling fn each time, using this as the scole..
26823 * @param {DomNode} node node to iterate children of.
26824 * @param {Function} fn method of this class to call on each item.
26826 iterateChildren : function(node, fn)
26828 if (!node.childNodes.length) {
26831 for (var i = node.childNodes.length-1; i > -1 ; i--) {
26832 fn.call(this, node.childNodes[i])
26838 * cleanTableWidths.
26840 * Quite often pasting from word etc.. results in tables with column and widths.
26841 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
26844 cleanTableWidths : function(node)
26849 this.cleanTableWidths(this.doc.body);
26854 if (node.nodeName == "#text" || node.nodeName == "#comment") {
26857 Roo.log(node.tagName);
26858 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
26859 this.iterateChildren(node, this.cleanTableWidths);
26862 if (node.hasAttribute('width')) {
26863 node.removeAttribute('width');
26867 if (node.hasAttribute("style")) {
26870 var styles = node.getAttribute("style").split(";");
26872 Roo.each(styles, function(s) {
26873 if (!s.match(/:/)) {
26876 var kv = s.split(":");
26877 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
26880 // what ever is left... we allow.
26883 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
26884 if (!nstyle.length) {
26885 node.removeAttribute('style');
26889 this.iterateChildren(node, this.cleanTableWidths);
26897 domToHTML : function(currentElement, depth, nopadtext) {
26899 depth = depth || 0;
26900 nopadtext = nopadtext || false;
26902 if (!currentElement) {
26903 return this.domToHTML(this.doc.body);
26906 //Roo.log(currentElement);
26908 var allText = false;
26909 var nodeName = currentElement.nodeName;
26910 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
26912 if (nodeName == '#text') {
26914 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
26919 if (nodeName != 'BODY') {
26922 // Prints the node tagName, such as <A>, <IMG>, etc
26925 for(i = 0; i < currentElement.attributes.length;i++) {
26927 var aname = currentElement.attributes.item(i).name;
26928 if (!currentElement.attributes.item(i).value.length) {
26931 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
26934 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
26943 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
26946 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
26951 // Traverse the tree
26953 var currentElementChild = currentElement.childNodes.item(i);
26954 var allText = true;
26955 var innerHTML = '';
26957 while (currentElementChild) {
26958 // Formatting code (indent the tree so it looks nice on the screen)
26959 var nopad = nopadtext;
26960 if (lastnode == 'SPAN') {
26964 if (currentElementChild.nodeName == '#text') {
26965 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
26966 toadd = nopadtext ? toadd : toadd.trim();
26967 if (!nopad && toadd.length > 80) {
26968 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
26970 innerHTML += toadd;
26973 currentElementChild = currentElement.childNodes.item(i);
26979 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
26981 // Recursively traverse the tree structure of the child node
26982 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
26983 lastnode = currentElementChild.nodeName;
26985 currentElementChild=currentElement.childNodes.item(i);
26991 // The remaining code is mostly for formatting the tree
26992 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
26997 ret+= "</"+tagName+">";
27003 applyBlacklists : function()
27005 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
27006 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
27010 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
27011 if (b.indexOf(tag) > -1) {
27014 this.white.push(tag);
27018 Roo.each(w, function(tag) {
27019 if (b.indexOf(tag) > -1) {
27022 if (this.white.indexOf(tag) > -1) {
27025 this.white.push(tag);
27030 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
27031 if (w.indexOf(tag) > -1) {
27034 this.black.push(tag);
27038 Roo.each(b, function(tag) {
27039 if (w.indexOf(tag) > -1) {
27042 if (this.black.indexOf(tag) > -1) {
27045 this.black.push(tag);
27050 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
27051 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
27055 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
27056 if (b.indexOf(tag) > -1) {
27059 this.cwhite.push(tag);
27063 Roo.each(w, function(tag) {
27064 if (b.indexOf(tag) > -1) {
27067 if (this.cwhite.indexOf(tag) > -1) {
27070 this.cwhite.push(tag);
27075 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
27076 if (w.indexOf(tag) > -1) {
27079 this.cblack.push(tag);
27083 Roo.each(b, function(tag) {
27084 if (w.indexOf(tag) > -1) {
27087 if (this.cblack.indexOf(tag) > -1) {
27090 this.cblack.push(tag);
27095 setStylesheets : function(stylesheets)
27097 if(typeof(stylesheets) == 'string'){
27098 Roo.get(this.iframe.contentDocument.head).createChild({
27100 rel : 'stylesheet',
27109 Roo.each(stylesheets, function(s) {
27114 Roo.get(_this.iframe.contentDocument.head).createChild({
27116 rel : 'stylesheet',
27125 removeStylesheets : function()
27129 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
27134 setStyle : function(style)
27136 Roo.get(this.iframe.contentDocument.head).createChild({
27145 // hide stuff that is not compatible
27159 * @event specialkey
27163 * @cfg {String} fieldClass @hide
27166 * @cfg {String} focusClass @hide
27169 * @cfg {String} autoCreate @hide
27172 * @cfg {String} inputType @hide
27175 * @cfg {String} invalidClass @hide
27178 * @cfg {String} invalidText @hide
27181 * @cfg {String} msgFx @hide
27184 * @cfg {String} validateOnBlur @hide
27188 Roo.HtmlEditorCore.white = [
27189 'area', 'br', 'img', 'input', 'hr', 'wbr',
27191 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
27192 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
27193 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
27194 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
27195 'table', 'ul', 'xmp',
27197 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
27200 'dir', 'menu', 'ol', 'ul', 'dl',
27206 Roo.HtmlEditorCore.black = [
27207 // 'embed', 'object', // enable - backend responsiblity to clean thiese
27209 'base', 'basefont', 'bgsound', 'blink', 'body',
27210 'frame', 'frameset', 'head', 'html', 'ilayer',
27211 'iframe', 'layer', 'link', 'meta', 'object',
27212 'script', 'style' ,'title', 'xml' // clean later..
27214 Roo.HtmlEditorCore.clean = [
27215 'script', 'style', 'title', 'xml'
27217 Roo.HtmlEditorCore.remove = [
27222 Roo.HtmlEditorCore.ablack = [
27226 Roo.HtmlEditorCore.aclean = [
27227 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
27231 Roo.HtmlEditorCore.pwhite= [
27232 'http', 'https', 'mailto'
27235 // white listed style attributes.
27236 Roo.HtmlEditorCore.cwhite= [
27237 // 'text-align', /// default is to allow most things..
27243 // black listed style attributes.
27244 Roo.HtmlEditorCore.cblack= [
27245 // 'font-size' -- this can be set by the project
27249 Roo.HtmlEditorCore.swapCodes =[
27250 [ 8211, "–" ],
27251 [ 8212, "—" ],
27268 * @class Roo.bootstrap.HtmlEditor
27269 * @extends Roo.bootstrap.TextArea
27270 * Bootstrap HtmlEditor class
27273 * Create a new HtmlEditor
27274 * @param {Object} config The config object
27277 Roo.bootstrap.HtmlEditor = function(config){
27278 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
27279 if (!this.toolbars) {
27280 this.toolbars = [];
27283 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
27286 * @event initialize
27287 * Fires when the editor is fully initialized (including the iframe)
27288 * @param {HtmlEditor} this
27293 * Fires when the editor is first receives the focus. Any insertion must wait
27294 * until after this event.
27295 * @param {HtmlEditor} this
27299 * @event beforesync
27300 * Fires before the textarea is updated with content from the editor iframe. Return false
27301 * to cancel the sync.
27302 * @param {HtmlEditor} this
27303 * @param {String} html
27307 * @event beforepush
27308 * Fires before the iframe editor is updated with content from the textarea. Return false
27309 * to cancel the push.
27310 * @param {HtmlEditor} this
27311 * @param {String} html
27316 * Fires when the textarea is updated with content from the editor iframe.
27317 * @param {HtmlEditor} this
27318 * @param {String} html
27323 * Fires when the iframe editor is updated with content from the textarea.
27324 * @param {HtmlEditor} this
27325 * @param {String} html
27329 * @event editmodechange
27330 * Fires when the editor switches edit modes
27331 * @param {HtmlEditor} this
27332 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
27334 editmodechange: true,
27336 * @event editorevent
27337 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
27338 * @param {HtmlEditor} this
27342 * @event firstfocus
27343 * Fires when on first focus - needed by toolbars..
27344 * @param {HtmlEditor} this
27349 * Auto save the htmlEditor value as a file into Events
27350 * @param {HtmlEditor} this
27354 * @event savedpreview
27355 * preview the saved version of htmlEditor
27356 * @param {HtmlEditor} this
27363 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
27367 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
27372 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
27377 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
27382 * @cfg {Number} height (in pixels)
27386 * @cfg {Number} width (in pixels)
27391 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
27394 stylesheets: false,
27399 // private properties
27400 validationEvent : false,
27402 initialized : false,
27405 onFocus : Roo.emptyFn,
27407 hideMode:'offsets',
27409 tbContainer : false,
27413 toolbarContainer :function() {
27414 return this.wrap.select('.x-html-editor-tb',true).first();
27418 * Protected method that will not generally be called directly. It
27419 * is called when the editor creates its toolbar. Override this method if you need to
27420 * add custom toolbar buttons.
27421 * @param {HtmlEditor} editor
27423 createToolbar : function(){
27424 Roo.log('renewing');
27425 Roo.log("create toolbars");
27427 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
27428 this.toolbars[0].render(this.toolbarContainer());
27432 // if (!editor.toolbars || !editor.toolbars.length) {
27433 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
27436 // for (var i =0 ; i < editor.toolbars.length;i++) {
27437 // editor.toolbars[i] = Roo.factory(
27438 // typeof(editor.toolbars[i]) == 'string' ?
27439 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
27440 // Roo.bootstrap.HtmlEditor);
27441 // editor.toolbars[i].init(editor);
27447 onRender : function(ct, position)
27449 // Roo.log("Call onRender: " + this.xtype);
27451 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
27453 this.wrap = this.inputEl().wrap({
27454 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
27457 this.editorcore.onRender(ct, position);
27459 if (this.resizable) {
27460 this.resizeEl = new Roo.Resizable(this.wrap, {
27464 minHeight : this.height,
27465 height: this.height,
27466 handles : this.resizable,
27469 resize : function(r, w, h) {
27470 _t.onResize(w,h); // -something
27476 this.createToolbar(this);
27479 if(!this.width && this.resizable){
27480 this.setSize(this.wrap.getSize());
27482 if (this.resizeEl) {
27483 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
27484 // should trigger onReize..
27490 onResize : function(w, h)
27492 Roo.log('resize: ' +w + ',' + h );
27493 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
27497 if(this.inputEl() ){
27498 if(typeof w == 'number'){
27499 var aw = w - this.wrap.getFrameWidth('lr');
27500 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
27503 if(typeof h == 'number'){
27504 var tbh = -11; // fixme it needs to tool bar size!
27505 for (var i =0; i < this.toolbars.length;i++) {
27506 // fixme - ask toolbars for heights?
27507 tbh += this.toolbars[i].el.getHeight();
27508 //if (this.toolbars[i].footer) {
27509 // tbh += this.toolbars[i].footer.el.getHeight();
27517 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
27518 ah -= 5; // knock a few pixes off for look..
27519 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
27523 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
27524 this.editorcore.onResize(ew,eh);
27529 * Toggles the editor between standard and source edit mode.
27530 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
27532 toggleSourceEdit : function(sourceEditMode)
27534 this.editorcore.toggleSourceEdit(sourceEditMode);
27536 if(this.editorcore.sourceEditMode){
27537 Roo.log('editor - showing textarea');
27540 // Roo.log(this.syncValue());
27542 this.inputEl().removeClass(['hide', 'x-hidden']);
27543 this.inputEl().dom.removeAttribute('tabIndex');
27544 this.inputEl().focus();
27546 Roo.log('editor - hiding textarea');
27548 // Roo.log(this.pushValue());
27551 this.inputEl().addClass(['hide', 'x-hidden']);
27552 this.inputEl().dom.setAttribute('tabIndex', -1);
27553 //this.deferFocus();
27556 if(this.resizable){
27557 this.setSize(this.wrap.getSize());
27560 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
27563 // private (for BoxComponent)
27564 adjustSize : Roo.BoxComponent.prototype.adjustSize,
27566 // private (for BoxComponent)
27567 getResizeEl : function(){
27571 // private (for BoxComponent)
27572 getPositionEl : function(){
27577 initEvents : function(){
27578 this.originalValue = this.getValue();
27582 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
27585 // markInvalid : Roo.emptyFn,
27587 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
27590 // clearInvalid : Roo.emptyFn,
27592 setValue : function(v){
27593 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
27594 this.editorcore.pushValue();
27599 deferFocus : function(){
27600 this.focus.defer(10, this);
27604 focus : function(){
27605 this.editorcore.focus();
27611 onDestroy : function(){
27617 for (var i =0; i < this.toolbars.length;i++) {
27618 // fixme - ask toolbars for heights?
27619 this.toolbars[i].onDestroy();
27622 this.wrap.dom.innerHTML = '';
27623 this.wrap.remove();
27628 onFirstFocus : function(){
27629 //Roo.log("onFirstFocus");
27630 this.editorcore.onFirstFocus();
27631 for (var i =0; i < this.toolbars.length;i++) {
27632 this.toolbars[i].onFirstFocus();
27638 syncValue : function()
27640 this.editorcore.syncValue();
27643 pushValue : function()
27645 this.editorcore.pushValue();
27649 // hide stuff that is not compatible
27663 * @event specialkey
27667 * @cfg {String} fieldClass @hide
27670 * @cfg {String} focusClass @hide
27673 * @cfg {String} autoCreate @hide
27676 * @cfg {String} inputType @hide
27680 * @cfg {String} invalidText @hide
27683 * @cfg {String} msgFx @hide
27686 * @cfg {String} validateOnBlur @hide
27695 Roo.namespace('Roo.bootstrap.htmleditor');
27697 * @class Roo.bootstrap.HtmlEditorToolbar1
27703 new Roo.bootstrap.HtmlEditor({
27706 new Roo.bootstrap.HtmlEditorToolbar1({
27707 disable : { fonts: 1 , format: 1, ..., ... , ...],
27713 * @cfg {Object} disable List of elements to disable..
27714 * @cfg {Array} btns List of additional buttons.
27718 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
27721 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
27724 Roo.apply(this, config);
27726 // default disabled, based on 'good practice'..
27727 this.disable = this.disable || {};
27728 Roo.applyIf(this.disable, {
27731 specialElements : true
27733 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
27735 this.editor = config.editor;
27736 this.editorcore = config.editor.editorcore;
27738 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
27740 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
27741 // dont call parent... till later.
27743 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
27748 editorcore : false,
27753 "h1","h2","h3","h4","h5","h6",
27755 "abbr", "acronym", "address", "cite", "samp", "var",
27759 onRender : function(ct, position)
27761 // Roo.log("Call onRender: " + this.xtype);
27763 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
27765 this.el.dom.style.marginBottom = '0';
27767 var editorcore = this.editorcore;
27768 var editor= this.editor;
27771 var btn = function(id,cmd , toggle, handler, html){
27773 var event = toggle ? 'toggle' : 'click';
27778 xns: Roo.bootstrap,
27782 enableToggle:toggle !== false,
27784 pressed : toggle ? false : null,
27787 a.listeners[toggle ? 'toggle' : 'click'] = function() {
27788 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
27794 // var cb_box = function...
27799 xns: Roo.bootstrap,
27804 xns: Roo.bootstrap,
27808 Roo.each(this.formats, function(f) {
27809 style.menu.items.push({
27811 xns: Roo.bootstrap,
27812 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
27817 editorcore.insertTag(this.tagname);
27824 children.push(style);
27826 btn('bold',false,true);
27827 btn('italic',false,true);
27828 btn('align-left', 'justifyleft',true);
27829 btn('align-center', 'justifycenter',true);
27830 btn('align-right' , 'justifyright',true);
27831 btn('link', false, false, function(btn) {
27832 //Roo.log("create link?");
27833 var url = prompt(this.createLinkText, this.defaultLinkValue);
27834 if(url && url != 'http:/'+'/'){
27835 this.editorcore.relayCmd('createlink', url);
27838 btn('list','insertunorderedlist',true);
27839 btn('pencil', false,true, function(btn){
27841 this.toggleSourceEdit(btn.pressed);
27844 if (this.editor.btns.length > 0) {
27845 for (var i = 0; i<this.editor.btns.length; i++) {
27846 children.push(this.editor.btns[i]);
27854 xns: Roo.bootstrap,
27859 xns: Roo.bootstrap,
27864 cog.menu.items.push({
27866 xns: Roo.bootstrap,
27867 html : Clean styles,
27872 editorcore.insertTag(this.tagname);
27881 this.xtype = 'NavSimplebar';
27883 for(var i=0;i< children.length;i++) {
27885 this.buttons.add(this.addxtypeChild(children[i]));
27889 editor.on('editorevent', this.updateToolbar, this);
27891 onBtnClick : function(id)
27893 this.editorcore.relayCmd(id);
27894 this.editorcore.focus();
27898 * Protected method that will not generally be called directly. It triggers
27899 * a toolbar update by reading the markup state of the current selection in the editor.
27901 updateToolbar: function(){
27903 if(!this.editorcore.activated){
27904 this.editor.onFirstFocus(); // is this neeed?
27908 var btns = this.buttons;
27909 var doc = this.editorcore.doc;
27910 btns.get('bold').setActive(doc.queryCommandState('bold'));
27911 btns.get('italic').setActive(doc.queryCommandState('italic'));
27912 //btns.get('underline').setActive(doc.queryCommandState('underline'));
27914 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
27915 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
27916 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
27918 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
27919 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
27922 var ans = this.editorcore.getAllAncestors();
27923 if (this.formatCombo) {
27926 var store = this.formatCombo.store;
27927 this.formatCombo.setValue("");
27928 for (var i =0; i < ans.length;i++) {
27929 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
27931 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
27939 // hides menus... - so this cant be on a menu...
27940 Roo.bootstrap.MenuMgr.hideAll();
27942 Roo.bootstrap.MenuMgr.hideAll();
27943 //this.editorsyncValue();
27945 onFirstFocus: function() {
27946 this.buttons.each(function(item){
27950 toggleSourceEdit : function(sourceEditMode){
27953 if(sourceEditMode){
27954 Roo.log("disabling buttons");
27955 this.buttons.each( function(item){
27956 if(item.cmd != 'pencil'){
27962 Roo.log("enabling buttons");
27963 if(this.editorcore.initialized){
27964 this.buttons.each( function(item){
27970 Roo.log("calling toggole on editor");
27971 // tell the editor that it's been pressed..
27972 this.editor.toggleSourceEdit(sourceEditMode);
27986 * @class Roo.bootstrap.Markdown
27987 * @extends Roo.bootstrap.TextArea
27988 * Bootstrap Showdown editable area
27989 * @cfg {string} content
27992 * Create a new Showdown
27995 Roo.bootstrap.Markdown = function(config){
27996 Roo.bootstrap.Markdown.superclass.constructor.call(this, config);
28000 Roo.extend(Roo.bootstrap.Markdown, Roo.bootstrap.TextArea, {
28004 initEvents : function()
28007 Roo.bootstrap.TextArea.prototype.initEvents.call(this);
28008 this.markdownEl = this.el.createChild({
28009 cls : 'roo-markdown-area'
28011 this.inputEl().addClass('d-none');
28012 if (this.getValue() == '') {
28013 this.markdownEl.dom.innerHTML = String.format('<span class="roo-placeholder">{0}</span>', this.placeholder || '');
28016 this.markdownEl.dom.innerHTML = Roo.Markdown.toHtml(Roo.util.Format.htmlEncode(this.getValue()));
28018 this.markdownEl.on('click', this.toggleTextEdit, this);
28019 this.on('blur', this.toggleTextEdit, this);
28020 this.on('specialkey', this.resizeTextArea, this);
28023 toggleTextEdit : function()
28025 var sh = this.markdownEl.getHeight();
28026 this.inputEl().addClass('d-none');
28027 this.markdownEl.addClass('d-none');
28028 if (!this.editing) {
28030 this.inputEl().setHeight(Math.min(500, Math.max(sh,(this.getValue().split("\n").length+1) * 30)));
28031 this.inputEl().removeClass('d-none');
28032 this.inputEl().focus();
28033 this.editing = true;
28036 // show showdown...
28037 this.updateMarkdown();
28038 this.markdownEl.removeClass('d-none');
28039 this.editing = false;
28042 updateMarkdown : function()
28044 if (this.getValue() == '') {
28045 this.markdownEl.dom.innerHTML = String.format('<span class="roo-placeholder">{0}</span>', this.placeholder || '');
28049 this.markdownEl.dom.innerHTML = Roo.Markdown.toHtml(Roo.util.Format.htmlEncode(this.getValue()));
28052 resizeTextArea: function () {
28055 Roo.log([sh, this.getValue().split("\n").length * 30]);
28056 this.inputEl().setHeight(Math.min(500, Math.max(sh, (this.getValue().split("\n").length +1) * 30)));
28058 setValue : function(val)
28060 Roo.bootstrap.TextArea.prototype.setValue.call(this,val);
28061 if (!this.editing) {
28062 this.updateMarkdown();
28068 if (!this.editing) {
28069 this.toggleTextEdit();
28077 * Ext JS Library 1.1.1
28078 * Copyright(c) 2006-2007, Ext JS, LLC.
28080 * Originally Released Under LGPL - original licence link has changed is not relivant.
28083 * <script type="text/javascript">
28087 * @class Roo.bootstrap.PagingToolbar
28088 * @extends Roo.bootstrap.NavSimplebar
28089 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
28091 * Create a new PagingToolbar
28092 * @param {Object} config The config object
28093 * @param {Roo.data.Store} store
28095 Roo.bootstrap.PagingToolbar = function(config)
28097 // old args format still supported... - xtype is prefered..
28098 // created from xtype...
28100 this.ds = config.dataSource;
28102 if (config.store && !this.ds) {
28103 this.store= Roo.factory(config.store, Roo.data);
28104 this.ds = this.store;
28105 this.ds.xmodule = this.xmodule || false;
28108 this.toolbarItems = [];
28109 if (config.items) {
28110 this.toolbarItems = config.items;
28113 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
28118 this.bind(this.ds);
28121 if (Roo.bootstrap.version == 4) {
28122 this.navgroup = new Roo.bootstrap.ButtonGroup({ cls: 'pagination' });
28124 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
28129 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
28131 * @cfg {Roo.data.Store} dataSource
28132 * The underlying data store providing the paged data
28135 * @cfg {String/HTMLElement/Element} container
28136 * container The id or element that will contain the toolbar
28139 * @cfg {Boolean} displayInfo
28140 * True to display the displayMsg (defaults to false)
28143 * @cfg {Number} pageSize
28144 * The number of records to display per page (defaults to 20)
28148 * @cfg {String} displayMsg
28149 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
28151 displayMsg : 'Displaying {0} - {1} of {2}',
28153 * @cfg {String} emptyMsg
28154 * The message to display when no records are found (defaults to "No data to display")
28156 emptyMsg : 'No data to display',
28158 * Customizable piece of the default paging text (defaults to "Page")
28161 beforePageText : "Page",
28163 * Customizable piece of the default paging text (defaults to "of %0")
28166 afterPageText : "of {0}",
28168 * Customizable piece of the default paging text (defaults to "First Page")
28171 firstText : "First Page",
28173 * Customizable piece of the default paging text (defaults to "Previous Page")
28176 prevText : "Previous Page",
28178 * Customizable piece of the default paging text (defaults to "Next Page")
28181 nextText : "Next Page",
28183 * Customizable piece of the default paging text (defaults to "Last Page")
28186 lastText : "Last Page",
28188 * Customizable piece of the default paging text (defaults to "Refresh")
28191 refreshText : "Refresh",
28195 onRender : function(ct, position)
28197 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
28198 this.navgroup.parentId = this.id;
28199 this.navgroup.onRender(this.el, null);
28200 // add the buttons to the navgroup
28202 if(this.displayInfo){
28203 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
28204 this.displayEl = this.el.select('.x-paging-info', true).first();
28205 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
28206 // this.displayEl = navel.el.select('span',true).first();
28212 Roo.each(_this.buttons, function(e){ // this might need to use render????
28213 Roo.factory(e).render(_this.el);
28217 Roo.each(_this.toolbarItems, function(e) {
28218 _this.navgroup.addItem(e);
28222 this.first = this.navgroup.addItem({
28223 tooltip: this.firstText,
28224 cls: "prev btn-outline-secondary",
28225 html : ' <i class="fa fa-step-backward"></i>',
28227 preventDefault: true,
28228 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
28231 this.prev = this.navgroup.addItem({
28232 tooltip: this.prevText,
28233 cls: "prev btn-outline-secondary",
28234 html : ' <i class="fa fa-backward"></i>',
28236 preventDefault: true,
28237 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
28239 //this.addSeparator();
28242 var field = this.navgroup.addItem( {
28244 cls : 'x-paging-position btn-outline-secondary',
28246 html : this.beforePageText +
28247 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
28248 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
28251 this.field = field.el.select('input', true).first();
28252 this.field.on("keydown", this.onPagingKeydown, this);
28253 this.field.on("focus", function(){this.dom.select();});
28256 this.afterTextEl = field.el.select('.x-paging-after',true).first();
28257 //this.field.setHeight(18);
28258 //this.addSeparator();
28259 this.next = this.navgroup.addItem({
28260 tooltip: this.nextText,
28261 cls: "next btn-outline-secondary",
28262 html : ' <i class="fa fa-forward"></i>',
28264 preventDefault: true,
28265 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
28267 this.last = this.navgroup.addItem({
28268 tooltip: this.lastText,
28269 html : ' <i class="fa fa-step-forward"></i>',
28270 cls: "next btn-outline-secondary",
28272 preventDefault: true,
28273 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
28275 //this.addSeparator();
28276 this.loading = this.navgroup.addItem({
28277 tooltip: this.refreshText,
28278 cls: "btn-outline-secondary",
28279 html : ' <i class="fa fa-refresh"></i>',
28280 preventDefault: true,
28281 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
28287 updateInfo : function(){
28288 if(this.displayEl){
28289 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
28290 var msg = count == 0 ?
28294 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
28296 this.displayEl.update(msg);
28301 onLoad : function(ds, r, o)
28303 this.cursor = o.params && o.params.start ? o.params.start : 0;
28305 var d = this.getPageData(),
28310 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
28311 this.field.dom.value = ap;
28312 this.first.setDisabled(ap == 1);
28313 this.prev.setDisabled(ap == 1);
28314 this.next.setDisabled(ap == ps);
28315 this.last.setDisabled(ap == ps);
28316 this.loading.enable();
28321 getPageData : function(){
28322 var total = this.ds.getTotalCount();
28325 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
28326 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
28331 onLoadError : function(){
28332 this.loading.enable();
28336 onPagingKeydown : function(e){
28337 var k = e.getKey();
28338 var d = this.getPageData();
28340 var v = this.field.dom.value, pageNum;
28341 if(!v || isNaN(pageNum = parseInt(v, 10))){
28342 this.field.dom.value = d.activePage;
28345 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
28346 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
28349 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))
28351 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
28352 this.field.dom.value = pageNum;
28353 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
28356 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
28358 var v = this.field.dom.value, pageNum;
28359 var increment = (e.shiftKey) ? 10 : 1;
28360 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
28363 if(!v || isNaN(pageNum = parseInt(v, 10))) {
28364 this.field.dom.value = d.activePage;
28367 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
28369 this.field.dom.value = parseInt(v, 10) + increment;
28370 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
28371 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
28378 beforeLoad : function(){
28380 this.loading.disable();
28385 onClick : function(which){
28394 ds.load({params:{start: 0, limit: this.pageSize}});
28397 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
28400 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
28403 var total = ds.getTotalCount();
28404 var extra = total % this.pageSize;
28405 var lastStart = extra ? (total - extra) : total-this.pageSize;
28406 ds.load({params:{start: lastStart, limit: this.pageSize}});
28409 ds.load({params:{start: this.cursor, limit: this.pageSize}});
28415 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
28416 * @param {Roo.data.Store} store The data store to unbind
28418 unbind : function(ds){
28419 ds.un("beforeload", this.beforeLoad, this);
28420 ds.un("load", this.onLoad, this);
28421 ds.un("loadexception", this.onLoadError, this);
28422 ds.un("remove", this.updateInfo, this);
28423 ds.un("add", this.updateInfo, this);
28424 this.ds = undefined;
28428 * Binds the paging toolbar to the specified {@link Roo.data.Store}
28429 * @param {Roo.data.Store} store The data store to bind
28431 bind : function(ds){
28432 ds.on("beforeload", this.beforeLoad, this);
28433 ds.on("load", this.onLoad, this);
28434 ds.on("loadexception", this.onLoadError, this);
28435 ds.on("remove", this.updateInfo, this);
28436 ds.on("add", this.updateInfo, this);
28447 * @class Roo.bootstrap.MessageBar
28448 * @extends Roo.bootstrap.Component
28449 * Bootstrap MessageBar class
28450 * @cfg {String} html contents of the MessageBar
28451 * @cfg {String} weight (info | success | warning | danger) default info
28452 * @cfg {String} beforeClass insert the bar before the given class
28453 * @cfg {Boolean} closable (true | false) default false
28454 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
28457 * Create a new Element
28458 * @param {Object} config The config object
28461 Roo.bootstrap.MessageBar = function(config){
28462 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
28465 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
28471 beforeClass: 'bootstrap-sticky-wrap',
28473 getAutoCreate : function(){
28477 cls: 'alert alert-dismissable alert-' + this.weight,
28482 html: this.html || ''
28488 cfg.cls += ' alert-messages-fixed';
28502 onRender : function(ct, position)
28504 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
28507 var cfg = Roo.apply({}, this.getAutoCreate());
28511 cfg.cls += ' ' + this.cls;
28514 cfg.style = this.style;
28516 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
28518 this.el.setVisibilityMode(Roo.Element.DISPLAY);
28521 this.el.select('>button.close').on('click', this.hide, this);
28527 if (!this.rendered) {
28533 this.fireEvent('show', this);
28539 if (!this.rendered) {
28545 this.fireEvent('hide', this);
28548 update : function()
28550 // var e = this.el.dom.firstChild;
28552 // if(this.closable){
28553 // e = e.nextSibling;
28556 // e.data = this.html || '';
28558 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
28574 * @class Roo.bootstrap.Graph
28575 * @extends Roo.bootstrap.Component
28576 * Bootstrap Graph class
28580 @cfg {String} graphtype bar | vbar | pie
28581 @cfg {number} g_x coodinator | centre x (pie)
28582 @cfg {number} g_y coodinator | centre y (pie)
28583 @cfg {number} g_r radius (pie)
28584 @cfg {number} g_height height of the chart (respected by all elements in the set)
28585 @cfg {number} g_width width of the chart (respected by all elements in the set)
28586 @cfg {Object} title The title of the chart
28589 -opts (object) options for the chart
28591 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
28592 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
28594 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.
28595 o stacked (boolean) whether or not to tread values as in a stacked bar chart
28597 o stretch (boolean)
28599 -opts (object) options for the pie
28602 o startAngle (number)
28603 o endAngle (number)
28607 * Create a new Input
28608 * @param {Object} config The config object
28611 Roo.bootstrap.Graph = function(config){
28612 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
28618 * The img click event for the img.
28619 * @param {Roo.EventObject} e
28625 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
28636 //g_colors: this.colors,
28643 getAutoCreate : function(){
28654 onRender : function(ct,position){
28657 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
28659 if (typeof(Raphael) == 'undefined') {
28660 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
28664 this.raphael = Raphael(this.el.dom);
28666 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
28667 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
28668 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
28669 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
28671 r.text(160, 10, "Single Series Chart").attr(txtattr);
28672 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
28673 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
28674 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
28676 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
28677 r.barchart(330, 10, 300, 220, data1);
28678 r.barchart(10, 250, 300, 220, data2, {stacked: true});
28679 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
28682 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
28683 // r.barchart(30, 30, 560, 250, xdata, {
28684 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
28685 // axis : "0 0 1 1",
28686 // axisxlabels : xdata
28687 // //yvalues : cols,
28690 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
28692 // this.load(null,xdata,{
28693 // axis : "0 0 1 1",
28694 // axisxlabels : xdata
28699 load : function(graphtype,xdata,opts)
28701 this.raphael.clear();
28703 graphtype = this.graphtype;
28708 var r = this.raphael,
28709 fin = function () {
28710 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
28712 fout = function () {
28713 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
28715 pfin = function() {
28716 this.sector.stop();
28717 this.sector.scale(1.1, 1.1, this.cx, this.cy);
28720 this.label[0].stop();
28721 this.label[0].attr({ r: 7.5 });
28722 this.label[1].attr({ "font-weight": 800 });
28725 pfout = function() {
28726 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
28729 this.label[0].animate({ r: 5 }, 500, "bounce");
28730 this.label[1].attr({ "font-weight": 400 });
28736 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
28739 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
28742 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
28743 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
28745 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
28752 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
28757 setTitle: function(o)
28762 initEvents: function() {
28765 this.el.on('click', this.onClick, this);
28769 onClick : function(e)
28771 Roo.log('img onclick');
28772 this.fireEvent('click', this, e);
28784 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
28787 * @class Roo.bootstrap.dash.NumberBox
28788 * @extends Roo.bootstrap.Component
28789 * Bootstrap NumberBox class
28790 * @cfg {String} headline Box headline
28791 * @cfg {String} content Box content
28792 * @cfg {String} icon Box icon
28793 * @cfg {String} footer Footer text
28794 * @cfg {String} fhref Footer href
28797 * Create a new NumberBox
28798 * @param {Object} config The config object
28802 Roo.bootstrap.dash.NumberBox = function(config){
28803 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
28807 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
28816 getAutoCreate : function(){
28820 cls : 'small-box ',
28828 cls : 'roo-headline',
28829 html : this.headline
28833 cls : 'roo-content',
28834 html : this.content
28848 cls : 'ion ' + this.icon
28857 cls : 'small-box-footer',
28858 href : this.fhref || '#',
28862 cfg.cn.push(footer);
28869 onRender : function(ct,position){
28870 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
28877 setHeadline: function (value)
28879 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
28882 setFooter: function (value, href)
28884 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
28887 this.el.select('a.small-box-footer',true).first().attr('href', href);
28892 setContent: function (value)
28894 this.el.select('.roo-content',true).first().dom.innerHTML = value;
28897 initEvents: function()
28911 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
28914 * @class Roo.bootstrap.dash.TabBox
28915 * @extends Roo.bootstrap.Component
28916 * Bootstrap TabBox class
28917 * @cfg {String} title Title of the TabBox
28918 * @cfg {String} icon Icon of the TabBox
28919 * @cfg {Boolean} showtabs (true|false) show the tabs default true
28920 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
28923 * Create a new TabBox
28924 * @param {Object} config The config object
28928 Roo.bootstrap.dash.TabBox = function(config){
28929 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
28934 * When a pane is added
28935 * @param {Roo.bootstrap.dash.TabPane} pane
28939 * @event activatepane
28940 * When a pane is activated
28941 * @param {Roo.bootstrap.dash.TabPane} pane
28943 "activatepane" : true
28951 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
28956 tabScrollable : false,
28958 getChildContainer : function()
28960 return this.el.select('.tab-content', true).first();
28963 getAutoCreate : function(){
28967 cls: 'pull-left header',
28975 cls: 'fa ' + this.icon
28981 cls: 'nav nav-tabs pull-right',
28987 if(this.tabScrollable){
28994 cls: 'nav nav-tabs pull-right',
29005 cls: 'nav-tabs-custom',
29010 cls: 'tab-content no-padding',
29018 initEvents : function()
29020 //Roo.log('add add pane handler');
29021 this.on('addpane', this.onAddPane, this);
29024 * Updates the box title
29025 * @param {String} html to set the title to.
29027 setTitle : function(value)
29029 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
29031 onAddPane : function(pane)
29033 this.panes.push(pane);
29034 //Roo.log('addpane');
29036 // tabs are rendere left to right..
29037 if(!this.showtabs){
29041 var ctr = this.el.select('.nav-tabs', true).first();
29044 var existing = ctr.select('.nav-tab',true);
29045 var qty = existing.getCount();;
29048 var tab = ctr.createChild({
29050 cls : 'nav-tab' + (qty ? '' : ' active'),
29058 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
29061 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
29063 pane.el.addClass('active');
29068 onTabClick : function(ev,un,ob,pane)
29070 //Roo.log('tab - prev default');
29071 ev.preventDefault();
29074 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
29075 pane.tab.addClass('active');
29076 //Roo.log(pane.title);
29077 this.getChildContainer().select('.tab-pane',true).removeClass('active');
29078 // technically we should have a deactivate event.. but maybe add later.
29079 // and it should not de-activate the selected tab...
29080 this.fireEvent('activatepane', pane);
29081 pane.el.addClass('active');
29082 pane.fireEvent('activate');
29087 getActivePane : function()
29090 Roo.each(this.panes, function(p) {
29091 if(p.el.hasClass('active')){
29112 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
29114 * @class Roo.bootstrap.TabPane
29115 * @extends Roo.bootstrap.Component
29116 * Bootstrap TabPane class
29117 * @cfg {Boolean} active (false | true) Default false
29118 * @cfg {String} title title of panel
29122 * Create a new TabPane
29123 * @param {Object} config The config object
29126 Roo.bootstrap.dash.TabPane = function(config){
29127 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
29133 * When a pane is activated
29134 * @param {Roo.bootstrap.dash.TabPane} pane
29141 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
29146 // the tabBox that this is attached to.
29149 getAutoCreate : function()
29157 cfg.cls += ' active';
29162 initEvents : function()
29164 //Roo.log('trigger add pane handler');
29165 this.parent().fireEvent('addpane', this)
29169 * Updates the tab title
29170 * @param {String} html to set the title to.
29172 setTitle: function(str)
29178 this.tab.select('a', true).first().dom.innerHTML = str;
29195 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
29198 * @class Roo.bootstrap.menu.Menu
29199 * @extends Roo.bootstrap.Component
29200 * Bootstrap Menu class - container for Menu
29201 * @cfg {String} html Text of the menu
29202 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
29203 * @cfg {String} icon Font awesome icon
29204 * @cfg {String} pos Menu align to (top | bottom) default bottom
29208 * Create a new Menu
29209 * @param {Object} config The config object
29213 Roo.bootstrap.menu.Menu = function(config){
29214 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
29218 * @event beforeshow
29219 * Fires before this menu is displayed
29220 * @param {Roo.bootstrap.menu.Menu} this
29224 * @event beforehide
29225 * Fires before this menu is hidden
29226 * @param {Roo.bootstrap.menu.Menu} this
29231 * Fires after this menu is displayed
29232 * @param {Roo.bootstrap.menu.Menu} this
29237 * Fires after this menu is hidden
29238 * @param {Roo.bootstrap.menu.Menu} this
29243 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
29244 * @param {Roo.bootstrap.menu.Menu} this
29245 * @param {Roo.EventObject} e
29252 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
29256 weight : 'default',
29261 getChildContainer : function() {
29262 if(this.isSubMenu){
29266 return this.el.select('ul.dropdown-menu', true).first();
29269 getAutoCreate : function()
29274 cls : 'roo-menu-text',
29282 cls : 'fa ' + this.icon
29293 cls : 'dropdown-button btn btn-' + this.weight,
29298 cls : 'dropdown-toggle btn btn-' + this.weight,
29308 cls : 'dropdown-menu'
29314 if(this.pos == 'top'){
29315 cfg.cls += ' dropup';
29318 if(this.isSubMenu){
29321 cls : 'dropdown-menu'
29328 onRender : function(ct, position)
29330 this.isSubMenu = ct.hasClass('dropdown-submenu');
29332 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
29335 initEvents : function()
29337 if(this.isSubMenu){
29341 this.hidden = true;
29343 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
29344 this.triggerEl.on('click', this.onTriggerPress, this);
29346 this.buttonEl = this.el.select('button.dropdown-button', true).first();
29347 this.buttonEl.on('click', this.onClick, this);
29353 if(this.isSubMenu){
29357 return this.el.select('ul.dropdown-menu', true).first();
29360 onClick : function(e)
29362 this.fireEvent("click", this, e);
29365 onTriggerPress : function(e)
29367 if (this.isVisible()) {
29374 isVisible : function(){
29375 return !this.hidden;
29380 this.fireEvent("beforeshow", this);
29382 this.hidden = false;
29383 this.el.addClass('open');
29385 Roo.get(document).on("mouseup", this.onMouseUp, this);
29387 this.fireEvent("show", this);
29394 this.fireEvent("beforehide", this);
29396 this.hidden = true;
29397 this.el.removeClass('open');
29399 Roo.get(document).un("mouseup", this.onMouseUp);
29401 this.fireEvent("hide", this);
29404 onMouseUp : function()
29418 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
29421 * @class Roo.bootstrap.menu.Item
29422 * @extends Roo.bootstrap.Component
29423 * Bootstrap MenuItem class
29424 * @cfg {Boolean} submenu (true | false) default false
29425 * @cfg {String} html text of the item
29426 * @cfg {String} href the link
29427 * @cfg {Boolean} disable (true | false) default false
29428 * @cfg {Boolean} preventDefault (true | false) default true
29429 * @cfg {String} icon Font awesome icon
29430 * @cfg {String} pos Submenu align to (left | right) default right
29434 * Create a new Item
29435 * @param {Object} config The config object
29439 Roo.bootstrap.menu.Item = function(config){
29440 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
29444 * Fires when the mouse is hovering over this menu
29445 * @param {Roo.bootstrap.menu.Item} this
29446 * @param {Roo.EventObject} e
29451 * Fires when the mouse exits this menu
29452 * @param {Roo.bootstrap.menu.Item} this
29453 * @param {Roo.EventObject} e
29459 * The raw click event for the entire grid.
29460 * @param {Roo.EventObject} e
29466 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
29471 preventDefault: true,
29476 getAutoCreate : function()
29481 cls : 'roo-menu-item-text',
29489 cls : 'fa ' + this.icon
29498 href : this.href || '#',
29505 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
29509 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
29511 if(this.pos == 'left'){
29512 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
29519 initEvents : function()
29521 this.el.on('mouseover', this.onMouseOver, this);
29522 this.el.on('mouseout', this.onMouseOut, this);
29524 this.el.select('a', true).first().on('click', this.onClick, this);
29528 onClick : function(e)
29530 if(this.preventDefault){
29531 e.preventDefault();
29534 this.fireEvent("click", this, e);
29537 onMouseOver : function(e)
29539 if(this.submenu && this.pos == 'left'){
29540 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
29543 this.fireEvent("mouseover", this, e);
29546 onMouseOut : function(e)
29548 this.fireEvent("mouseout", this, e);
29560 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
29563 * @class Roo.bootstrap.menu.Separator
29564 * @extends Roo.bootstrap.Component
29565 * Bootstrap Separator class
29568 * Create a new Separator
29569 * @param {Object} config The config object
29573 Roo.bootstrap.menu.Separator = function(config){
29574 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
29577 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
29579 getAutoCreate : function(){
29582 cls: 'dropdown-divider divider'
29600 * @class Roo.bootstrap.Tooltip
29601 * Bootstrap Tooltip class
29602 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
29603 * to determine which dom element triggers the tooltip.
29605 * It needs to add support for additional attributes like tooltip-position
29608 * Create a new Toolti
29609 * @param {Object} config The config object
29612 Roo.bootstrap.Tooltip = function(config){
29613 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
29615 this.alignment = Roo.bootstrap.Tooltip.alignment;
29617 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
29618 this.alignment = config.alignment;
29623 Roo.apply(Roo.bootstrap.Tooltip, {
29625 * @function init initialize tooltip monitoring.
29629 currentTip : false,
29630 currentRegion : false,
29636 Roo.get(document).on('mouseover', this.enter ,this);
29637 Roo.get(document).on('mouseout', this.leave, this);
29640 this.currentTip = new Roo.bootstrap.Tooltip();
29643 enter : function(ev)
29645 var dom = ev.getTarget();
29647 //Roo.log(['enter',dom]);
29648 var el = Roo.fly(dom);
29649 if (this.currentEl) {
29651 //Roo.log(this.currentEl);
29652 //Roo.log(this.currentEl.contains(dom));
29653 if (this.currentEl == el) {
29656 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
29662 if (this.currentTip.el) {
29663 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
29667 if(!el || el.dom == document){
29673 if (!el.attr('tooltip')) {
29674 pel = el.findParent("[tooltip]");
29676 bindEl = Roo.get(pel);
29682 // you can not look for children, as if el is the body.. then everythign is the child..
29683 if (!pel && !el.attr('tooltip')) { //
29684 if (!el.select("[tooltip]").elements.length) {
29687 // is the mouse over this child...?
29688 bindEl = el.select("[tooltip]").first();
29689 var xy = ev.getXY();
29690 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
29691 //Roo.log("not in region.");
29694 //Roo.log("child element over..");
29697 this.currentEl = el;
29698 this.currentTip.bind(bindEl);
29699 this.currentRegion = Roo.lib.Region.getRegion(dom);
29700 this.currentTip.enter();
29703 leave : function(ev)
29705 var dom = ev.getTarget();
29706 //Roo.log(['leave',dom]);
29707 if (!this.currentEl) {
29712 if (dom != this.currentEl.dom) {
29715 var xy = ev.getXY();
29716 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
29719 // only activate leave if mouse cursor is outside... bounding box..
29724 if (this.currentTip) {
29725 this.currentTip.leave();
29727 //Roo.log('clear currentEl');
29728 this.currentEl = false;
29733 'left' : ['r-l', [-2,0], 'right'],
29734 'right' : ['l-r', [2,0], 'left'],
29735 'bottom' : ['t-b', [0,2], 'top'],
29736 'top' : [ 'b-t', [0,-2], 'bottom']
29742 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
29747 delay : null, // can be { show : 300 , hide: 500}
29751 hoverState : null, //???
29753 placement : 'bottom',
29757 getAutoCreate : function(){
29764 cls : 'tooltip-arrow arrow'
29767 cls : 'tooltip-inner'
29774 bind : function(el)
29779 initEvents : function()
29781 this.arrowEl = this.el.select('.arrow', true).first();
29782 this.innerEl = this.el.select('.tooltip-inner', true).first();
29785 enter : function () {
29787 if (this.timeout != null) {
29788 clearTimeout(this.timeout);
29791 this.hoverState = 'in';
29792 //Roo.log("enter - show");
29793 if (!this.delay || !this.delay.show) {
29798 this.timeout = setTimeout(function () {
29799 if (_t.hoverState == 'in') {
29802 }, this.delay.show);
29806 clearTimeout(this.timeout);
29808 this.hoverState = 'out';
29809 if (!this.delay || !this.delay.hide) {
29815 this.timeout = setTimeout(function () {
29816 //Roo.log("leave - timeout");
29818 if (_t.hoverState == 'out') {
29820 Roo.bootstrap.Tooltip.currentEl = false;
29825 show : function (msg)
29828 this.render(document.body);
29831 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
29833 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
29835 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
29837 this.el.removeClass(['fade','top','bottom', 'left', 'right','in',
29838 'bs-tooltip-top','bs-tooltip-bottom', 'bs-tooltip-left', 'bs-tooltip-right']);
29840 var placement = typeof this.placement == 'function' ?
29841 this.placement.call(this, this.el, on_el) :
29844 var autoToken = /\s?auto?\s?/i;
29845 var autoPlace = autoToken.test(placement);
29847 placement = placement.replace(autoToken, '') || 'top';
29851 //this.el.setXY([0,0]);
29853 //this.el.dom.style.display='block';
29855 //this.el.appendTo(on_el);
29857 var p = this.getPosition();
29858 var box = this.el.getBox();
29864 var align = this.alignment[placement];
29866 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
29868 if(placement == 'top' || placement == 'bottom'){
29870 placement = 'right';
29873 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
29874 placement = 'left';
29877 var scroll = Roo.select('body', true).first().getScroll();
29879 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
29883 align = this.alignment[placement];
29885 this.arrowEl.setLeft((this.innerEl.getWidth()/2) - 5);
29889 var elems = document.getElementsByTagName('div');
29890 var highest = Number.MIN_SAFE_INTEGER || -(Math.pow(2, 53) - 1);
29891 for (var i = 0; i < elems.length; i++) {
29892 var zindex = Number.parseInt(
29893 document.defaultView.getComputedStyle(elems[i], null).getPropertyValue("z-index"),
29896 if (zindex > highest) {
29903 this.el.dom.style.zIndex = highest;
29905 this.el.alignTo(this.bindEl, align[0],align[1]);
29906 //var arrow = this.el.select('.arrow',true).first();
29907 //arrow.set(align[2],
29909 this.el.addClass(placement);
29910 this.el.addClass("bs-tooltip-"+ placement);
29912 this.el.addClass('in fade show');
29914 this.hoverState = null;
29916 if (this.el.hasClass('fade')) {
29931 //this.el.setXY([0,0]);
29932 this.el.removeClass(['show', 'in']);
29948 * @class Roo.bootstrap.LocationPicker
29949 * @extends Roo.bootstrap.Component
29950 * Bootstrap LocationPicker class
29951 * @cfg {Number} latitude Position when init default 0
29952 * @cfg {Number} longitude Position when init default 0
29953 * @cfg {Number} zoom default 15
29954 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
29955 * @cfg {Boolean} mapTypeControl default false
29956 * @cfg {Boolean} disableDoubleClickZoom default false
29957 * @cfg {Boolean} scrollwheel default true
29958 * @cfg {Boolean} streetViewControl default false
29959 * @cfg {Number} radius default 0
29960 * @cfg {String} locationName
29961 * @cfg {Boolean} draggable default true
29962 * @cfg {Boolean} enableAutocomplete default false
29963 * @cfg {Boolean} enableReverseGeocode default true
29964 * @cfg {String} markerTitle
29967 * Create a new LocationPicker
29968 * @param {Object} config The config object
29972 Roo.bootstrap.LocationPicker = function(config){
29974 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
29979 * Fires when the picker initialized.
29980 * @param {Roo.bootstrap.LocationPicker} this
29981 * @param {Google Location} location
29985 * @event positionchanged
29986 * Fires when the picker position changed.
29987 * @param {Roo.bootstrap.LocationPicker} this
29988 * @param {Google Location} location
29990 positionchanged : true,
29993 * Fires when the map resize.
29994 * @param {Roo.bootstrap.LocationPicker} this
29999 * Fires when the map show.
30000 * @param {Roo.bootstrap.LocationPicker} this
30005 * Fires when the map hide.
30006 * @param {Roo.bootstrap.LocationPicker} this
30011 * Fires when click the map.
30012 * @param {Roo.bootstrap.LocationPicker} this
30013 * @param {Map event} e
30017 * @event mapRightClick
30018 * Fires when right click the map.
30019 * @param {Roo.bootstrap.LocationPicker} this
30020 * @param {Map event} e
30022 mapRightClick : true,
30024 * @event markerClick
30025 * Fires when click the marker.
30026 * @param {Roo.bootstrap.LocationPicker} this
30027 * @param {Map event} e
30029 markerClick : true,
30031 * @event markerRightClick
30032 * Fires when right click the marker.
30033 * @param {Roo.bootstrap.LocationPicker} this
30034 * @param {Map event} e
30036 markerRightClick : true,
30038 * @event OverlayViewDraw
30039 * Fires when OverlayView Draw
30040 * @param {Roo.bootstrap.LocationPicker} this
30042 OverlayViewDraw : true,
30044 * @event OverlayViewOnAdd
30045 * Fires when OverlayView Draw
30046 * @param {Roo.bootstrap.LocationPicker} this
30048 OverlayViewOnAdd : true,
30050 * @event OverlayViewOnRemove
30051 * Fires when OverlayView Draw
30052 * @param {Roo.bootstrap.LocationPicker} this
30054 OverlayViewOnRemove : true,
30056 * @event OverlayViewShow
30057 * Fires when OverlayView Draw
30058 * @param {Roo.bootstrap.LocationPicker} this
30059 * @param {Pixel} cpx
30061 OverlayViewShow : true,
30063 * @event OverlayViewHide
30064 * Fires when OverlayView Draw
30065 * @param {Roo.bootstrap.LocationPicker} this
30067 OverlayViewHide : true,
30069 * @event loadexception
30070 * Fires when load google lib failed.
30071 * @param {Roo.bootstrap.LocationPicker} this
30073 loadexception : true
30078 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
30080 gMapContext: false,
30086 mapTypeControl: false,
30087 disableDoubleClickZoom: false,
30089 streetViewControl: false,
30093 enableAutocomplete: false,
30094 enableReverseGeocode: true,
30097 getAutoCreate: function()
30102 cls: 'roo-location-picker'
30108 initEvents: function(ct, position)
30110 if(!this.el.getWidth() || this.isApplied()){
30114 this.el.setVisibilityMode(Roo.Element.DISPLAY);
30119 initial: function()
30121 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
30122 this.fireEvent('loadexception', this);
30126 if(!this.mapTypeId){
30127 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
30130 this.gMapContext = this.GMapContext();
30132 this.initOverlayView();
30134 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
30138 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
30139 _this.setPosition(_this.gMapContext.marker.position);
30142 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
30143 _this.fireEvent('mapClick', this, event);
30147 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
30148 _this.fireEvent('mapRightClick', this, event);
30152 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
30153 _this.fireEvent('markerClick', this, event);
30157 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
30158 _this.fireEvent('markerRightClick', this, event);
30162 this.setPosition(this.gMapContext.location);
30164 this.fireEvent('initial', this, this.gMapContext.location);
30167 initOverlayView: function()
30171 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
30175 _this.fireEvent('OverlayViewDraw', _this);
30180 _this.fireEvent('OverlayViewOnAdd', _this);
30183 onRemove: function()
30185 _this.fireEvent('OverlayViewOnRemove', _this);
30188 show: function(cpx)
30190 _this.fireEvent('OverlayViewShow', _this, cpx);
30195 _this.fireEvent('OverlayViewHide', _this);
30201 fromLatLngToContainerPixel: function(event)
30203 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
30206 isApplied: function()
30208 return this.getGmapContext() == false ? false : true;
30211 getGmapContext: function()
30213 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
30216 GMapContext: function()
30218 var position = new google.maps.LatLng(this.latitude, this.longitude);
30220 var _map = new google.maps.Map(this.el.dom, {
30223 mapTypeId: this.mapTypeId,
30224 mapTypeControl: this.mapTypeControl,
30225 disableDoubleClickZoom: this.disableDoubleClickZoom,
30226 scrollwheel: this.scrollwheel,
30227 streetViewControl: this.streetViewControl,
30228 locationName: this.locationName,
30229 draggable: this.draggable,
30230 enableAutocomplete: this.enableAutocomplete,
30231 enableReverseGeocode: this.enableReverseGeocode
30234 var _marker = new google.maps.Marker({
30235 position: position,
30237 title: this.markerTitle,
30238 draggable: this.draggable
30245 location: position,
30246 radius: this.radius,
30247 locationName: this.locationName,
30248 addressComponents: {
30249 formatted_address: null,
30250 addressLine1: null,
30251 addressLine2: null,
30253 streetNumber: null,
30257 stateOrProvince: null
30260 domContainer: this.el.dom,
30261 geodecoder: new google.maps.Geocoder()
30265 drawCircle: function(center, radius, options)
30267 if (this.gMapContext.circle != null) {
30268 this.gMapContext.circle.setMap(null);
30272 options = Roo.apply({}, options, {
30273 strokeColor: "#0000FF",
30274 strokeOpacity: .35,
30276 fillColor: "#0000FF",
30280 options.map = this.gMapContext.map;
30281 options.radius = radius;
30282 options.center = center;
30283 this.gMapContext.circle = new google.maps.Circle(options);
30284 return this.gMapContext.circle;
30290 setPosition: function(location)
30292 this.gMapContext.location = location;
30293 this.gMapContext.marker.setPosition(location);
30294 this.gMapContext.map.panTo(location);
30295 this.drawCircle(location, this.gMapContext.radius, {});
30299 if (this.gMapContext.settings.enableReverseGeocode) {
30300 this.gMapContext.geodecoder.geocode({
30301 latLng: this.gMapContext.location
30302 }, function(results, status) {
30304 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
30305 _this.gMapContext.locationName = results[0].formatted_address;
30306 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
30308 _this.fireEvent('positionchanged', this, location);
30315 this.fireEvent('positionchanged', this, location);
30320 google.maps.event.trigger(this.gMapContext.map, "resize");
30322 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
30324 this.fireEvent('resize', this);
30327 setPositionByLatLng: function(latitude, longitude)
30329 this.setPosition(new google.maps.LatLng(latitude, longitude));
30332 getCurrentPosition: function()
30335 latitude: this.gMapContext.location.lat(),
30336 longitude: this.gMapContext.location.lng()
30340 getAddressName: function()
30342 return this.gMapContext.locationName;
30345 getAddressComponents: function()
30347 return this.gMapContext.addressComponents;
30350 address_component_from_google_geocode: function(address_components)
30354 for (var i = 0; i < address_components.length; i++) {
30355 var component = address_components[i];
30356 if (component.types.indexOf("postal_code") >= 0) {
30357 result.postalCode = component.short_name;
30358 } else if (component.types.indexOf("street_number") >= 0) {
30359 result.streetNumber = component.short_name;
30360 } else if (component.types.indexOf("route") >= 0) {
30361 result.streetName = component.short_name;
30362 } else if (component.types.indexOf("neighborhood") >= 0) {
30363 result.city = component.short_name;
30364 } else if (component.types.indexOf("locality") >= 0) {
30365 result.city = component.short_name;
30366 } else if (component.types.indexOf("sublocality") >= 0) {
30367 result.district = component.short_name;
30368 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
30369 result.stateOrProvince = component.short_name;
30370 } else if (component.types.indexOf("country") >= 0) {
30371 result.country = component.short_name;
30375 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
30376 result.addressLine2 = "";
30380 setZoomLevel: function(zoom)
30382 this.gMapContext.map.setZoom(zoom);
30395 this.fireEvent('show', this);
30406 this.fireEvent('hide', this);
30411 Roo.apply(Roo.bootstrap.LocationPicker, {
30413 OverlayView : function(map, options)
30415 options = options || {};
30422 * @class Roo.bootstrap.Alert
30423 * @extends Roo.bootstrap.Component
30424 * Bootstrap Alert class - shows an alert area box
30426 * <div class="alert alert-danger" role="alert"><span class="fa fa-exclamation-triangle"></span><span class="sr-only">Error:</span>
30427 Enter a valid email address
30430 * @cfg {String} title The title of alert
30431 * @cfg {String} html The content of alert
30432 * @cfg {String} weight (success|info|warning|danger) Weight of the message
30433 * @cfg {String} fa font-awesomeicon
30434 * @cfg {Number} seconds default:-1 Number of seconds until it disapears (-1 means never.)
30435 * @cfg {Boolean} close true to show a x closer
30439 * Create a new alert
30440 * @param {Object} config The config object
30444 Roo.bootstrap.Alert = function(config){
30445 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
30449 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
30455 faicon: false, // BC
30459 getAutoCreate : function()
30471 style : this.close ? '' : 'display:none'
30475 cls : 'roo-alert-icon'
30480 cls : 'roo-alert-title',
30485 cls : 'roo-alert-text',
30492 cfg.cn[0].cls += ' fa ' + this.faicon;
30495 cfg.cn[0].cls += ' fa ' + this.fa;
30499 cfg.cls += ' alert-' + this.weight;
30505 initEvents: function()
30507 this.el.setVisibilityMode(Roo.Element.DISPLAY);
30508 this.titleEl = this.el.select('.roo-alert-title',true).first();
30509 this.iconEl = this.el.select('.roo-alert-icon',true).first();
30510 this.htmlEl = this.el.select('.roo-alert-text',true).first();
30511 if (this.seconds > 0) {
30512 this.hide.defer(this.seconds, this);
30516 * Set the Title Message HTML
30517 * @param {String} html
30519 setTitle : function(str)
30521 this.titleEl.dom.innerHTML = str;
30525 * Set the Body Message HTML
30526 * @param {String} html
30528 setHtml : function(str)
30530 this.htmlEl.dom.innerHTML = str;
30533 * Set the Weight of the alert
30534 * @param {String} (success|info|warning|danger) weight
30537 setWeight : function(weight)
30540 this.el.removeClass('alert-' + this.weight);
30543 this.weight = weight;
30545 this.el.addClass('alert-' + this.weight);
30548 * Set the Icon of the alert
30549 * @param {String} see fontawsome names (name without the 'fa-' bit)
30551 setIcon : function(icon)
30554 this.alertEl.removeClass(['fa', 'fa-' + this.faicon]);
30557 this.faicon = icon;
30559 this.alertEl.addClass(['fa', 'fa-' + this.faicon]);
30584 * @class Roo.bootstrap.UploadCropbox
30585 * @extends Roo.bootstrap.Component
30586 * Bootstrap UploadCropbox class
30587 * @cfg {String} emptyText show when image has been loaded
30588 * @cfg {String} rotateNotify show when image too small to rotate
30589 * @cfg {Number} errorTimeout default 3000
30590 * @cfg {Number} minWidth default 300
30591 * @cfg {Number} minHeight default 300
30592 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
30593 * @cfg {Boolean} isDocument (true|false) default false
30594 * @cfg {String} url action url
30595 * @cfg {String} paramName default 'imageUpload'
30596 * @cfg {String} method default POST
30597 * @cfg {Boolean} loadMask (true|false) default true
30598 * @cfg {Boolean} loadingText default 'Loading...'
30601 * Create a new UploadCropbox
30602 * @param {Object} config The config object
30605 Roo.bootstrap.UploadCropbox = function(config){
30606 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
30610 * @event beforeselectfile
30611 * Fire before select file
30612 * @param {Roo.bootstrap.UploadCropbox} this
30614 "beforeselectfile" : true,
30617 * Fire after initEvent
30618 * @param {Roo.bootstrap.UploadCropbox} this
30623 * Fire after initEvent
30624 * @param {Roo.bootstrap.UploadCropbox} this
30625 * @param {String} data
30630 * Fire when preparing the file data
30631 * @param {Roo.bootstrap.UploadCropbox} this
30632 * @param {Object} file
30637 * Fire when get exception
30638 * @param {Roo.bootstrap.UploadCropbox} this
30639 * @param {XMLHttpRequest} xhr
30641 "exception" : true,
30643 * @event beforeloadcanvas
30644 * Fire before load the canvas
30645 * @param {Roo.bootstrap.UploadCropbox} this
30646 * @param {String} src
30648 "beforeloadcanvas" : true,
30651 * Fire when trash image
30652 * @param {Roo.bootstrap.UploadCropbox} this
30657 * Fire when download the image
30658 * @param {Roo.bootstrap.UploadCropbox} this
30662 * @event footerbuttonclick
30663 * Fire when footerbuttonclick
30664 * @param {Roo.bootstrap.UploadCropbox} this
30665 * @param {String} type
30667 "footerbuttonclick" : true,
30671 * @param {Roo.bootstrap.UploadCropbox} this
30676 * Fire when rotate the image
30677 * @param {Roo.bootstrap.UploadCropbox} this
30678 * @param {String} pos
30683 * Fire when inspect the file
30684 * @param {Roo.bootstrap.UploadCropbox} this
30685 * @param {Object} file
30690 * Fire when xhr upload the file
30691 * @param {Roo.bootstrap.UploadCropbox} this
30692 * @param {Object} data
30697 * Fire when arrange the file data
30698 * @param {Roo.bootstrap.UploadCropbox} this
30699 * @param {Object} formData
30704 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
30707 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
30709 emptyText : 'Click to upload image',
30710 rotateNotify : 'Image is too small to rotate',
30711 errorTimeout : 3000,
30725 cropType : 'image/jpeg',
30727 canvasLoaded : false,
30728 isDocument : false,
30730 paramName : 'imageUpload',
30732 loadingText : 'Loading...',
30735 getAutoCreate : function()
30739 cls : 'roo-upload-cropbox',
30743 cls : 'roo-upload-cropbox-selector',
30748 cls : 'roo-upload-cropbox-body',
30749 style : 'cursor:pointer',
30753 cls : 'roo-upload-cropbox-preview'
30757 cls : 'roo-upload-cropbox-thumb'
30761 cls : 'roo-upload-cropbox-empty-notify',
30762 html : this.emptyText
30766 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
30767 html : this.rotateNotify
30773 cls : 'roo-upload-cropbox-footer',
30776 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
30786 onRender : function(ct, position)
30788 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
30790 if (this.buttons.length) {
30792 Roo.each(this.buttons, function(bb) {
30794 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
30796 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
30802 this.maskEl = this.el;
30806 initEvents : function()
30808 this.urlAPI = (window.createObjectURL && window) ||
30809 (window.URL && URL.revokeObjectURL && URL) ||
30810 (window.webkitURL && webkitURL);
30812 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
30813 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30815 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
30816 this.selectorEl.hide();
30818 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
30819 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30821 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
30822 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30823 this.thumbEl.hide();
30825 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
30826 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30828 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
30829 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30830 this.errorEl.hide();
30832 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
30833 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30834 this.footerEl.hide();
30836 this.setThumbBoxSize();
30842 this.fireEvent('initial', this);
30849 window.addEventListener("resize", function() { _this.resize(); } );
30851 this.bodyEl.on('click', this.beforeSelectFile, this);
30854 this.bodyEl.on('touchstart', this.onTouchStart, this);
30855 this.bodyEl.on('touchmove', this.onTouchMove, this);
30856 this.bodyEl.on('touchend', this.onTouchEnd, this);
30860 this.bodyEl.on('mousedown', this.onMouseDown, this);
30861 this.bodyEl.on('mousemove', this.onMouseMove, this);
30862 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
30863 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
30864 Roo.get(document).on('mouseup', this.onMouseUp, this);
30867 this.selectorEl.on('change', this.onFileSelected, this);
30873 this.baseScale = 1;
30875 this.baseRotate = 1;
30876 this.dragable = false;
30877 this.pinching = false;
30880 this.cropData = false;
30881 this.notifyEl.dom.innerHTML = this.emptyText;
30883 this.selectorEl.dom.value = '';
30887 resize : function()
30889 if(this.fireEvent('resize', this) != false){
30890 this.setThumbBoxPosition();
30891 this.setCanvasPosition();
30895 onFooterButtonClick : function(e, el, o, type)
30898 case 'rotate-left' :
30899 this.onRotateLeft(e);
30901 case 'rotate-right' :
30902 this.onRotateRight(e);
30905 this.beforeSelectFile(e);
30920 this.fireEvent('footerbuttonclick', this, type);
30923 beforeSelectFile : function(e)
30925 e.preventDefault();
30927 if(this.fireEvent('beforeselectfile', this) != false){
30928 this.selectorEl.dom.click();
30932 onFileSelected : function(e)
30934 e.preventDefault();
30936 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
30940 var file = this.selectorEl.dom.files[0];
30942 if(this.fireEvent('inspect', this, file) != false){
30943 this.prepare(file);
30948 trash : function(e)
30950 this.fireEvent('trash', this);
30953 download : function(e)
30955 this.fireEvent('download', this);
30958 loadCanvas : function(src)
30960 if(this.fireEvent('beforeloadcanvas', this, src) != false){
30964 this.imageEl = document.createElement('img');
30968 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
30970 this.imageEl.src = src;
30974 onLoadCanvas : function()
30976 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
30977 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
30979 this.bodyEl.un('click', this.beforeSelectFile, this);
30981 this.notifyEl.hide();
30982 this.thumbEl.show();
30983 this.footerEl.show();
30985 this.baseRotateLevel();
30987 if(this.isDocument){
30988 this.setThumbBoxSize();
30991 this.setThumbBoxPosition();
30993 this.baseScaleLevel();
30999 this.canvasLoaded = true;
31002 this.maskEl.unmask();
31007 setCanvasPosition : function()
31009 if(!this.canvasEl){
31013 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
31014 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
31016 this.previewEl.setLeft(pw);
31017 this.previewEl.setTop(ph);
31021 onMouseDown : function(e)
31025 this.dragable = true;
31026 this.pinching = false;
31028 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
31029 this.dragable = false;
31033 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
31034 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
31038 onMouseMove : function(e)
31042 if(!this.canvasLoaded){
31046 if (!this.dragable){
31050 var minX = Math.ceil(this.thumbEl.getLeft(true));
31051 var minY = Math.ceil(this.thumbEl.getTop(true));
31053 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
31054 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
31056 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
31057 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
31059 x = x - this.mouseX;
31060 y = y - this.mouseY;
31062 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
31063 var bgY = Math.ceil(y + this.previewEl.getTop(true));
31065 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
31066 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
31068 this.previewEl.setLeft(bgX);
31069 this.previewEl.setTop(bgY);
31071 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
31072 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
31075 onMouseUp : function(e)
31079 this.dragable = false;
31082 onMouseWheel : function(e)
31086 this.startScale = this.scale;
31088 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
31090 if(!this.zoomable()){
31091 this.scale = this.startScale;
31100 zoomable : function()
31102 var minScale = this.thumbEl.getWidth() / this.minWidth;
31104 if(this.minWidth < this.minHeight){
31105 minScale = this.thumbEl.getHeight() / this.minHeight;
31108 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
31109 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
31113 (this.rotate == 0 || this.rotate == 180) &&
31115 width > this.imageEl.OriginWidth ||
31116 height > this.imageEl.OriginHeight ||
31117 (width < this.minWidth && height < this.minHeight)
31125 (this.rotate == 90 || this.rotate == 270) &&
31127 width > this.imageEl.OriginWidth ||
31128 height > this.imageEl.OriginHeight ||
31129 (width < this.minHeight && height < this.minWidth)
31136 !this.isDocument &&
31137 (this.rotate == 0 || this.rotate == 180) &&
31139 width < this.minWidth ||
31140 width > this.imageEl.OriginWidth ||
31141 height < this.minHeight ||
31142 height > this.imageEl.OriginHeight
31149 !this.isDocument &&
31150 (this.rotate == 90 || this.rotate == 270) &&
31152 width < this.minHeight ||
31153 width > this.imageEl.OriginWidth ||
31154 height < this.minWidth ||
31155 height > this.imageEl.OriginHeight
31165 onRotateLeft : function(e)
31167 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
31169 var minScale = this.thumbEl.getWidth() / this.minWidth;
31171 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
31172 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
31174 this.startScale = this.scale;
31176 while (this.getScaleLevel() < minScale){
31178 this.scale = this.scale + 1;
31180 if(!this.zoomable()){
31185 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
31186 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
31191 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
31198 this.scale = this.startScale;
31200 this.onRotateFail();
31205 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
31207 if(this.isDocument){
31208 this.setThumbBoxSize();
31209 this.setThumbBoxPosition();
31210 this.setCanvasPosition();
31215 this.fireEvent('rotate', this, 'left');
31219 onRotateRight : function(e)
31221 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
31223 var minScale = this.thumbEl.getWidth() / this.minWidth;
31225 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
31226 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
31228 this.startScale = this.scale;
31230 while (this.getScaleLevel() < minScale){
31232 this.scale = this.scale + 1;
31234 if(!this.zoomable()){
31239 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
31240 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
31245 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
31252 this.scale = this.startScale;
31254 this.onRotateFail();
31259 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
31261 if(this.isDocument){
31262 this.setThumbBoxSize();
31263 this.setThumbBoxPosition();
31264 this.setCanvasPosition();
31269 this.fireEvent('rotate', this, 'right');
31272 onRotateFail : function()
31274 this.errorEl.show(true);
31278 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
31283 this.previewEl.dom.innerHTML = '';
31285 var canvasEl = document.createElement("canvas");
31287 var contextEl = canvasEl.getContext("2d");
31289 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
31290 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
31291 var center = this.imageEl.OriginWidth / 2;
31293 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
31294 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
31295 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
31296 center = this.imageEl.OriginHeight / 2;
31299 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
31301 contextEl.translate(center, center);
31302 contextEl.rotate(this.rotate * Math.PI / 180);
31304 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
31306 this.canvasEl = document.createElement("canvas");
31308 this.contextEl = this.canvasEl.getContext("2d");
31310 switch (this.rotate) {
31313 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
31314 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
31316 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
31321 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
31322 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
31324 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
31325 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);
31329 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
31334 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
31335 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
31337 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
31338 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);
31342 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);
31347 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
31348 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
31350 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
31351 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
31355 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);
31362 this.previewEl.appendChild(this.canvasEl);
31364 this.setCanvasPosition();
31369 if(!this.canvasLoaded){
31373 var imageCanvas = document.createElement("canvas");
31375 var imageContext = imageCanvas.getContext("2d");
31377 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
31378 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
31380 var center = imageCanvas.width / 2;
31382 imageContext.translate(center, center);
31384 imageContext.rotate(this.rotate * Math.PI / 180);
31386 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
31388 var canvas = document.createElement("canvas");
31390 var context = canvas.getContext("2d");
31392 canvas.width = this.minWidth;
31393 canvas.height = this.minHeight;
31395 switch (this.rotate) {
31398 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
31399 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
31401 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
31402 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
31404 var targetWidth = this.minWidth - 2 * x;
31405 var targetHeight = this.minHeight - 2 * y;
31409 if((x == 0 && y == 0) || (x == 0 && y > 0)){
31410 scale = targetWidth / width;
31413 if(x > 0 && y == 0){
31414 scale = targetHeight / height;
31417 if(x > 0 && y > 0){
31418 scale = targetWidth / width;
31420 if(width < height){
31421 scale = targetHeight / height;
31425 context.scale(scale, scale);
31427 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
31428 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
31430 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
31431 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
31433 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
31438 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
31439 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
31441 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
31442 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
31444 var targetWidth = this.minWidth - 2 * x;
31445 var targetHeight = this.minHeight - 2 * y;
31449 if((x == 0 && y == 0) || (x == 0 && y > 0)){
31450 scale = targetWidth / width;
31453 if(x > 0 && y == 0){
31454 scale = targetHeight / height;
31457 if(x > 0 && y > 0){
31458 scale = targetWidth / width;
31460 if(width < height){
31461 scale = targetHeight / height;
31465 context.scale(scale, scale);
31467 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
31468 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
31470 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
31471 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
31473 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
31475 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
31480 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
31481 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
31483 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
31484 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
31486 var targetWidth = this.minWidth - 2 * x;
31487 var targetHeight = this.minHeight - 2 * y;
31491 if((x == 0 && y == 0) || (x == 0 && y > 0)){
31492 scale = targetWidth / width;
31495 if(x > 0 && y == 0){
31496 scale = targetHeight / height;
31499 if(x > 0 && y > 0){
31500 scale = targetWidth / width;
31502 if(width < height){
31503 scale = targetHeight / height;
31507 context.scale(scale, scale);
31509 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
31510 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
31512 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
31513 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
31515 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
31516 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
31518 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
31523 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
31524 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
31526 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
31527 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
31529 var targetWidth = this.minWidth - 2 * x;
31530 var targetHeight = this.minHeight - 2 * y;
31534 if((x == 0 && y == 0) || (x == 0 && y > 0)){
31535 scale = targetWidth / width;
31538 if(x > 0 && y == 0){
31539 scale = targetHeight / height;
31542 if(x > 0 && y > 0){
31543 scale = targetWidth / width;
31545 if(width < height){
31546 scale = targetHeight / height;
31550 context.scale(scale, scale);
31552 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
31553 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
31555 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
31556 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
31558 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
31560 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
31567 this.cropData = canvas.toDataURL(this.cropType);
31569 if(this.fireEvent('crop', this, this.cropData) !== false){
31570 this.process(this.file, this.cropData);
31577 setThumbBoxSize : function()
31581 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
31582 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
31583 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
31585 this.minWidth = width;
31586 this.minHeight = height;
31588 if(this.rotate == 90 || this.rotate == 270){
31589 this.minWidth = height;
31590 this.minHeight = width;
31595 width = Math.ceil(this.minWidth * height / this.minHeight);
31597 if(this.minWidth > this.minHeight){
31599 height = Math.ceil(this.minHeight * width / this.minWidth);
31602 this.thumbEl.setStyle({
31603 width : width + 'px',
31604 height : height + 'px'
31611 setThumbBoxPosition : function()
31613 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
31614 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
31616 this.thumbEl.setLeft(x);
31617 this.thumbEl.setTop(y);
31621 baseRotateLevel : function()
31623 this.baseRotate = 1;
31626 typeof(this.exif) != 'undefined' &&
31627 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
31628 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
31630 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
31633 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
31637 baseScaleLevel : function()
31641 if(this.isDocument){
31643 if(this.baseRotate == 6 || this.baseRotate == 8){
31645 height = this.thumbEl.getHeight();
31646 this.baseScale = height / this.imageEl.OriginWidth;
31648 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
31649 width = this.thumbEl.getWidth();
31650 this.baseScale = width / this.imageEl.OriginHeight;
31656 height = this.thumbEl.getHeight();
31657 this.baseScale = height / this.imageEl.OriginHeight;
31659 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
31660 width = this.thumbEl.getWidth();
31661 this.baseScale = width / this.imageEl.OriginWidth;
31667 if(this.baseRotate == 6 || this.baseRotate == 8){
31669 width = this.thumbEl.getHeight();
31670 this.baseScale = width / this.imageEl.OriginHeight;
31672 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
31673 height = this.thumbEl.getWidth();
31674 this.baseScale = height / this.imageEl.OriginHeight;
31677 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
31678 height = this.thumbEl.getWidth();
31679 this.baseScale = height / this.imageEl.OriginHeight;
31681 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
31682 width = this.thumbEl.getHeight();
31683 this.baseScale = width / this.imageEl.OriginWidth;
31690 width = this.thumbEl.getWidth();
31691 this.baseScale = width / this.imageEl.OriginWidth;
31693 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
31694 height = this.thumbEl.getHeight();
31695 this.baseScale = height / this.imageEl.OriginHeight;
31698 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
31700 height = this.thumbEl.getHeight();
31701 this.baseScale = height / this.imageEl.OriginHeight;
31703 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
31704 width = this.thumbEl.getWidth();
31705 this.baseScale = width / this.imageEl.OriginWidth;
31713 getScaleLevel : function()
31715 return this.baseScale * Math.pow(1.1, this.scale);
31718 onTouchStart : function(e)
31720 if(!this.canvasLoaded){
31721 this.beforeSelectFile(e);
31725 var touches = e.browserEvent.touches;
31731 if(touches.length == 1){
31732 this.onMouseDown(e);
31736 if(touches.length != 2){
31742 for(var i = 0, finger; finger = touches[i]; i++){
31743 coords.push(finger.pageX, finger.pageY);
31746 var x = Math.pow(coords[0] - coords[2], 2);
31747 var y = Math.pow(coords[1] - coords[3], 2);
31749 this.startDistance = Math.sqrt(x + y);
31751 this.startScale = this.scale;
31753 this.pinching = true;
31754 this.dragable = false;
31758 onTouchMove : function(e)
31760 if(!this.pinching && !this.dragable){
31764 var touches = e.browserEvent.touches;
31771 this.onMouseMove(e);
31777 for(var i = 0, finger; finger = touches[i]; i++){
31778 coords.push(finger.pageX, finger.pageY);
31781 var x = Math.pow(coords[0] - coords[2], 2);
31782 var y = Math.pow(coords[1] - coords[3], 2);
31784 this.endDistance = Math.sqrt(x + y);
31786 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
31788 if(!this.zoomable()){
31789 this.scale = this.startScale;
31797 onTouchEnd : function(e)
31799 this.pinching = false;
31800 this.dragable = false;
31804 process : function(file, crop)
31807 this.maskEl.mask(this.loadingText);
31810 this.xhr = new XMLHttpRequest();
31812 file.xhr = this.xhr;
31814 this.xhr.open(this.method, this.url, true);
31817 "Accept": "application/json",
31818 "Cache-Control": "no-cache",
31819 "X-Requested-With": "XMLHttpRequest"
31822 for (var headerName in headers) {
31823 var headerValue = headers[headerName];
31825 this.xhr.setRequestHeader(headerName, headerValue);
31831 this.xhr.onload = function()
31833 _this.xhrOnLoad(_this.xhr);
31836 this.xhr.onerror = function()
31838 _this.xhrOnError(_this.xhr);
31841 var formData = new FormData();
31843 formData.append('returnHTML', 'NO');
31846 formData.append('crop', crop);
31849 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
31850 formData.append(this.paramName, file, file.name);
31853 if(typeof(file.filename) != 'undefined'){
31854 formData.append('filename', file.filename);
31857 if(typeof(file.mimetype) != 'undefined'){
31858 formData.append('mimetype', file.mimetype);
31861 if(this.fireEvent('arrange', this, formData) != false){
31862 this.xhr.send(formData);
31866 xhrOnLoad : function(xhr)
31869 this.maskEl.unmask();
31872 if (xhr.readyState !== 4) {
31873 this.fireEvent('exception', this, xhr);
31877 var response = Roo.decode(xhr.responseText);
31879 if(!response.success){
31880 this.fireEvent('exception', this, xhr);
31884 var response = Roo.decode(xhr.responseText);
31886 this.fireEvent('upload', this, response);
31890 xhrOnError : function()
31893 this.maskEl.unmask();
31896 Roo.log('xhr on error');
31898 var response = Roo.decode(xhr.responseText);
31904 prepare : function(file)
31907 this.maskEl.mask(this.loadingText);
31913 if(typeof(file) === 'string'){
31914 this.loadCanvas(file);
31918 if(!file || !this.urlAPI){
31923 this.cropType = file.type;
31927 if(this.fireEvent('prepare', this, this.file) != false){
31929 var reader = new FileReader();
31931 reader.onload = function (e) {
31932 if (e.target.error) {
31933 Roo.log(e.target.error);
31937 var buffer = e.target.result,
31938 dataView = new DataView(buffer),
31940 maxOffset = dataView.byteLength - 4,
31944 if (dataView.getUint16(0) === 0xffd8) {
31945 while (offset < maxOffset) {
31946 markerBytes = dataView.getUint16(offset);
31948 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
31949 markerLength = dataView.getUint16(offset + 2) + 2;
31950 if (offset + markerLength > dataView.byteLength) {
31951 Roo.log('Invalid meta data: Invalid segment size.');
31955 if(markerBytes == 0xffe1){
31956 _this.parseExifData(
31963 offset += markerLength;
31973 var url = _this.urlAPI.createObjectURL(_this.file);
31975 _this.loadCanvas(url);
31980 reader.readAsArrayBuffer(this.file);
31986 parseExifData : function(dataView, offset, length)
31988 var tiffOffset = offset + 10,
31992 if (dataView.getUint32(offset + 4) !== 0x45786966) {
31993 // No Exif data, might be XMP data instead
31997 // Check for the ASCII code for "Exif" (0x45786966):
31998 if (dataView.getUint32(offset + 4) !== 0x45786966) {
31999 // No Exif data, might be XMP data instead
32002 if (tiffOffset + 8 > dataView.byteLength) {
32003 Roo.log('Invalid Exif data: Invalid segment size.');
32006 // Check for the two null bytes:
32007 if (dataView.getUint16(offset + 8) !== 0x0000) {
32008 Roo.log('Invalid Exif data: Missing byte alignment offset.');
32011 // Check the byte alignment:
32012 switch (dataView.getUint16(tiffOffset)) {
32014 littleEndian = true;
32017 littleEndian = false;
32020 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
32023 // Check for the TIFF tag marker (0x002A):
32024 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
32025 Roo.log('Invalid Exif data: Missing TIFF marker.');
32028 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
32029 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
32031 this.parseExifTags(
32034 tiffOffset + dirOffset,
32039 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
32044 if (dirOffset + 6 > dataView.byteLength) {
32045 Roo.log('Invalid Exif data: Invalid directory offset.');
32048 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
32049 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
32050 if (dirEndOffset + 4 > dataView.byteLength) {
32051 Roo.log('Invalid Exif data: Invalid directory size.');
32054 for (i = 0; i < tagsNumber; i += 1) {
32058 dirOffset + 2 + 12 * i, // tag offset
32062 // Return the offset to the next directory:
32063 return dataView.getUint32(dirEndOffset, littleEndian);
32066 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
32068 var tag = dataView.getUint16(offset, littleEndian);
32070 this.exif[tag] = this.getExifValue(
32074 dataView.getUint16(offset + 2, littleEndian), // tag type
32075 dataView.getUint32(offset + 4, littleEndian), // tag length
32080 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
32082 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
32091 Roo.log('Invalid Exif data: Invalid tag type.');
32095 tagSize = tagType.size * length;
32096 // Determine if the value is contained in the dataOffset bytes,
32097 // or if the value at the dataOffset is a pointer to the actual data:
32098 dataOffset = tagSize > 4 ?
32099 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
32100 if (dataOffset + tagSize > dataView.byteLength) {
32101 Roo.log('Invalid Exif data: Invalid data offset.');
32104 if (length === 1) {
32105 return tagType.getValue(dataView, dataOffset, littleEndian);
32108 for (i = 0; i < length; i += 1) {
32109 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
32112 if (tagType.ascii) {
32114 // Concatenate the chars:
32115 for (i = 0; i < values.length; i += 1) {
32117 // Ignore the terminating NULL byte(s):
32118 if (c === '\u0000') {
32130 Roo.apply(Roo.bootstrap.UploadCropbox, {
32132 'Orientation': 0x0112
32136 1: 0, //'top-left',
32138 3: 180, //'bottom-right',
32139 // 4: 'bottom-left',
32141 6: 90, //'right-top',
32142 // 7: 'right-bottom',
32143 8: 270 //'left-bottom'
32147 // byte, 8-bit unsigned int:
32149 getValue: function (dataView, dataOffset) {
32150 return dataView.getUint8(dataOffset);
32154 // ascii, 8-bit byte:
32156 getValue: function (dataView, dataOffset) {
32157 return String.fromCharCode(dataView.getUint8(dataOffset));
32162 // short, 16 bit int:
32164 getValue: function (dataView, dataOffset, littleEndian) {
32165 return dataView.getUint16(dataOffset, littleEndian);
32169 // long, 32 bit int:
32171 getValue: function (dataView, dataOffset, littleEndian) {
32172 return dataView.getUint32(dataOffset, littleEndian);
32176 // rational = two long values, first is numerator, second is denominator:
32178 getValue: function (dataView, dataOffset, littleEndian) {
32179 return dataView.getUint32(dataOffset, littleEndian) /
32180 dataView.getUint32(dataOffset + 4, littleEndian);
32184 // slong, 32 bit signed int:
32186 getValue: function (dataView, dataOffset, littleEndian) {
32187 return dataView.getInt32(dataOffset, littleEndian);
32191 // srational, two slongs, first is numerator, second is denominator:
32193 getValue: function (dataView, dataOffset, littleEndian) {
32194 return dataView.getInt32(dataOffset, littleEndian) /
32195 dataView.getInt32(dataOffset + 4, littleEndian);
32205 cls : 'btn-group roo-upload-cropbox-rotate-left',
32206 action : 'rotate-left',
32210 cls : 'btn btn-default',
32211 html : '<i class="fa fa-undo"></i>'
32217 cls : 'btn-group roo-upload-cropbox-picture',
32218 action : 'picture',
32222 cls : 'btn btn-default',
32223 html : '<i class="fa fa-picture-o"></i>'
32229 cls : 'btn-group roo-upload-cropbox-rotate-right',
32230 action : 'rotate-right',
32234 cls : 'btn btn-default',
32235 html : '<i class="fa fa-repeat"></i>'
32243 cls : 'btn-group roo-upload-cropbox-rotate-left',
32244 action : 'rotate-left',
32248 cls : 'btn btn-default',
32249 html : '<i class="fa fa-undo"></i>'
32255 cls : 'btn-group roo-upload-cropbox-download',
32256 action : 'download',
32260 cls : 'btn btn-default',
32261 html : '<i class="fa fa-download"></i>'
32267 cls : 'btn-group roo-upload-cropbox-crop',
32272 cls : 'btn btn-default',
32273 html : '<i class="fa fa-crop"></i>'
32279 cls : 'btn-group roo-upload-cropbox-trash',
32284 cls : 'btn btn-default',
32285 html : '<i class="fa fa-trash"></i>'
32291 cls : 'btn-group roo-upload-cropbox-rotate-right',
32292 action : 'rotate-right',
32296 cls : 'btn btn-default',
32297 html : '<i class="fa fa-repeat"></i>'
32305 cls : 'btn-group roo-upload-cropbox-rotate-left',
32306 action : 'rotate-left',
32310 cls : 'btn btn-default',
32311 html : '<i class="fa fa-undo"></i>'
32317 cls : 'btn-group roo-upload-cropbox-rotate-right',
32318 action : 'rotate-right',
32322 cls : 'btn btn-default',
32323 html : '<i class="fa fa-repeat"></i>'
32336 * @class Roo.bootstrap.DocumentManager
32337 * @extends Roo.bootstrap.Component
32338 * Bootstrap DocumentManager class
32339 * @cfg {String} paramName default 'imageUpload'
32340 * @cfg {String} toolTipName default 'filename'
32341 * @cfg {String} method default POST
32342 * @cfg {String} url action url
32343 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
32344 * @cfg {Boolean} multiple multiple upload default true
32345 * @cfg {Number} thumbSize default 300
32346 * @cfg {String} fieldLabel
32347 * @cfg {Number} labelWidth default 4
32348 * @cfg {String} labelAlign (left|top) default left
32349 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
32350 * @cfg {Number} labellg set the width of label (1-12)
32351 * @cfg {Number} labelmd set the width of label (1-12)
32352 * @cfg {Number} labelsm set the width of label (1-12)
32353 * @cfg {Number} labelxs set the width of label (1-12)
32356 * Create a new DocumentManager
32357 * @param {Object} config The config object
32360 Roo.bootstrap.DocumentManager = function(config){
32361 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
32364 this.delegates = [];
32369 * Fire when initial the DocumentManager
32370 * @param {Roo.bootstrap.DocumentManager} this
32375 * inspect selected file
32376 * @param {Roo.bootstrap.DocumentManager} this
32377 * @param {File} file
32382 * Fire when xhr load exception
32383 * @param {Roo.bootstrap.DocumentManager} this
32384 * @param {XMLHttpRequest} xhr
32386 "exception" : true,
32388 * @event afterupload
32389 * Fire when xhr load exception
32390 * @param {Roo.bootstrap.DocumentManager} this
32391 * @param {XMLHttpRequest} xhr
32393 "afterupload" : true,
32396 * prepare the form data
32397 * @param {Roo.bootstrap.DocumentManager} this
32398 * @param {Object} formData
32403 * Fire when remove the file
32404 * @param {Roo.bootstrap.DocumentManager} this
32405 * @param {Object} file
32410 * Fire after refresh the file
32411 * @param {Roo.bootstrap.DocumentManager} this
32416 * Fire after click the image
32417 * @param {Roo.bootstrap.DocumentManager} this
32418 * @param {Object} file
32423 * Fire when upload a image and editable set to true
32424 * @param {Roo.bootstrap.DocumentManager} this
32425 * @param {Object} file
32429 * @event beforeselectfile
32430 * Fire before select file
32431 * @param {Roo.bootstrap.DocumentManager} this
32433 "beforeselectfile" : true,
32436 * Fire before process file
32437 * @param {Roo.bootstrap.DocumentManager} this
32438 * @param {Object} file
32442 * @event previewrendered
32443 * Fire when preview rendered
32444 * @param {Roo.bootstrap.DocumentManager} this
32445 * @param {Object} file
32447 "previewrendered" : true,
32450 "previewResize" : true
32455 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
32464 paramName : 'imageUpload',
32465 toolTipName : 'filename',
32468 labelAlign : 'left',
32478 getAutoCreate : function()
32480 var managerWidget = {
32482 cls : 'roo-document-manager',
32486 cls : 'roo-document-manager-selector',
32491 cls : 'roo-document-manager-uploader',
32495 cls : 'roo-document-manager-upload-btn',
32496 html : '<i class="fa fa-plus"></i>'
32507 cls : 'column col-md-12',
32512 if(this.fieldLabel.length){
32517 cls : 'column col-md-12',
32518 html : this.fieldLabel
32522 cls : 'column col-md-12',
32527 if(this.labelAlign == 'left'){
32532 html : this.fieldLabel
32541 if(this.labelWidth > 12){
32542 content[0].style = "width: " + this.labelWidth + 'px';
32545 if(this.labelWidth < 13 && this.labelmd == 0){
32546 this.labelmd = this.labelWidth;
32549 if(this.labellg > 0){
32550 content[0].cls += ' col-lg-' + this.labellg;
32551 content[1].cls += ' col-lg-' + (12 - this.labellg);
32554 if(this.labelmd > 0){
32555 content[0].cls += ' col-md-' + this.labelmd;
32556 content[1].cls += ' col-md-' + (12 - this.labelmd);
32559 if(this.labelsm > 0){
32560 content[0].cls += ' col-sm-' + this.labelsm;
32561 content[1].cls += ' col-sm-' + (12 - this.labelsm);
32564 if(this.labelxs > 0){
32565 content[0].cls += ' col-xs-' + this.labelxs;
32566 content[1].cls += ' col-xs-' + (12 - this.labelxs);
32574 cls : 'row clearfix',
32582 initEvents : function()
32584 this.managerEl = this.el.select('.roo-document-manager', true).first();
32585 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
32587 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
32588 this.selectorEl.hide();
32591 this.selectorEl.attr('multiple', 'multiple');
32594 this.selectorEl.on('change', this.onFileSelected, this);
32596 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
32597 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
32599 this.uploader.on('click', this.onUploaderClick, this);
32601 this.renderProgressDialog();
32605 window.addEventListener("resize", function() { _this.refresh(); } );
32607 this.fireEvent('initial', this);
32610 renderProgressDialog : function()
32614 this.progressDialog = new Roo.bootstrap.Modal({
32615 cls : 'roo-document-manager-progress-dialog',
32616 allow_close : false,
32627 btnclick : function() {
32628 _this.uploadCancel();
32634 this.progressDialog.render(Roo.get(document.body));
32636 this.progress = new Roo.bootstrap.Progress({
32637 cls : 'roo-document-manager-progress',
32642 this.progress.render(this.progressDialog.getChildContainer());
32644 this.progressBar = new Roo.bootstrap.ProgressBar({
32645 cls : 'roo-document-manager-progress-bar',
32648 aria_valuemax : 12,
32652 this.progressBar.render(this.progress.getChildContainer());
32655 onUploaderClick : function(e)
32657 e.preventDefault();
32659 if(this.fireEvent('beforeselectfile', this) != false){
32660 this.selectorEl.dom.click();
32665 onFileSelected : function(e)
32667 e.preventDefault();
32669 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
32673 Roo.each(this.selectorEl.dom.files, function(file){
32674 if(this.fireEvent('inspect', this, file) != false){
32675 this.files.push(file);
32685 this.selectorEl.dom.value = '';
32687 if(!this.files || !this.files.length){
32691 if(this.boxes > 0 && this.files.length > this.boxes){
32692 this.files = this.files.slice(0, this.boxes);
32695 this.uploader.show();
32697 if(this.boxes > 0 && this.files.length > this.boxes - 1){
32698 this.uploader.hide();
32707 Roo.each(this.files, function(file){
32709 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
32710 var f = this.renderPreview(file);
32715 if(file.type.indexOf('image') != -1){
32716 this.delegates.push(
32718 _this.process(file);
32719 }).createDelegate(this)
32727 _this.process(file);
32728 }).createDelegate(this)
32733 this.files = files;
32735 this.delegates = this.delegates.concat(docs);
32737 if(!this.delegates.length){
32742 this.progressBar.aria_valuemax = this.delegates.length;
32749 arrange : function()
32751 if(!this.delegates.length){
32752 this.progressDialog.hide();
32757 var delegate = this.delegates.shift();
32759 this.progressDialog.show();
32761 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
32763 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
32768 refresh : function()
32770 this.uploader.show();
32772 if(this.boxes > 0 && this.files.length > this.boxes - 1){
32773 this.uploader.hide();
32776 Roo.isTouch ? this.closable(false) : this.closable(true);
32778 this.fireEvent('refresh', this);
32781 onRemove : function(e, el, o)
32783 e.preventDefault();
32785 this.fireEvent('remove', this, o);
32789 remove : function(o)
32793 Roo.each(this.files, function(file){
32794 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
32803 this.files = files;
32810 Roo.each(this.files, function(file){
32815 file.target.remove();
32824 onClick : function(e, el, o)
32826 e.preventDefault();
32828 this.fireEvent('click', this, o);
32832 closable : function(closable)
32834 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
32836 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
32848 xhrOnLoad : function(xhr)
32850 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
32854 if (xhr.readyState !== 4) {
32856 this.fireEvent('exception', this, xhr);
32860 var response = Roo.decode(xhr.responseText);
32862 if(!response.success){
32864 this.fireEvent('exception', this, xhr);
32868 var file = this.renderPreview(response.data);
32870 this.files.push(file);
32874 this.fireEvent('afterupload', this, xhr);
32878 xhrOnError : function(xhr)
32880 Roo.log('xhr on error');
32882 var response = Roo.decode(xhr.responseText);
32889 process : function(file)
32891 if(this.fireEvent('process', this, file) !== false){
32892 if(this.editable && file.type.indexOf('image') != -1){
32893 this.fireEvent('edit', this, file);
32897 this.uploadStart(file, false);
32904 uploadStart : function(file, crop)
32906 this.xhr = new XMLHttpRequest();
32908 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
32913 file.xhr = this.xhr;
32915 this.managerEl.createChild({
32917 cls : 'roo-document-manager-loading',
32921 tooltip : file.name,
32922 cls : 'roo-document-manager-thumb',
32923 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
32929 this.xhr.open(this.method, this.url, true);
32932 "Accept": "application/json",
32933 "Cache-Control": "no-cache",
32934 "X-Requested-With": "XMLHttpRequest"
32937 for (var headerName in headers) {
32938 var headerValue = headers[headerName];
32940 this.xhr.setRequestHeader(headerName, headerValue);
32946 this.xhr.onload = function()
32948 _this.xhrOnLoad(_this.xhr);
32951 this.xhr.onerror = function()
32953 _this.xhrOnError(_this.xhr);
32956 var formData = new FormData();
32958 formData.append('returnHTML', 'NO');
32961 formData.append('crop', crop);
32964 formData.append(this.paramName, file, file.name);
32971 if(this.fireEvent('prepare', this, formData, options) != false){
32973 if(options.manually){
32977 this.xhr.send(formData);
32981 this.uploadCancel();
32984 uploadCancel : function()
32990 this.delegates = [];
32992 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
32999 renderPreview : function(file)
33001 if(typeof(file.target) != 'undefined' && file.target){
33005 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
33007 var previewEl = this.managerEl.createChild({
33009 cls : 'roo-document-manager-preview',
33013 tooltip : file[this.toolTipName],
33014 cls : 'roo-document-manager-thumb',
33015 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
33020 html : '<i class="fa fa-times-circle"></i>'
33025 var close = previewEl.select('button.close', true).first();
33027 close.on('click', this.onRemove, this, file);
33029 file.target = previewEl;
33031 var image = previewEl.select('img', true).first();
33035 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
33037 image.on('click', this.onClick, this, file);
33039 this.fireEvent('previewrendered', this, file);
33045 onPreviewLoad : function(file, image)
33047 if(typeof(file.target) == 'undefined' || !file.target){
33051 var width = image.dom.naturalWidth || image.dom.width;
33052 var height = image.dom.naturalHeight || image.dom.height;
33054 if(!this.previewResize) {
33058 if(width > height){
33059 file.target.addClass('wide');
33063 file.target.addClass('tall');
33068 uploadFromSource : function(file, crop)
33070 this.xhr = new XMLHttpRequest();
33072 this.managerEl.createChild({
33074 cls : 'roo-document-manager-loading',
33078 tooltip : file.name,
33079 cls : 'roo-document-manager-thumb',
33080 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
33086 this.xhr.open(this.method, this.url, true);
33089 "Accept": "application/json",
33090 "Cache-Control": "no-cache",
33091 "X-Requested-With": "XMLHttpRequest"
33094 for (var headerName in headers) {
33095 var headerValue = headers[headerName];
33097 this.xhr.setRequestHeader(headerName, headerValue);
33103 this.xhr.onload = function()
33105 _this.xhrOnLoad(_this.xhr);
33108 this.xhr.onerror = function()
33110 _this.xhrOnError(_this.xhr);
33113 var formData = new FormData();
33115 formData.append('returnHTML', 'NO');
33117 formData.append('crop', crop);
33119 if(typeof(file.filename) != 'undefined'){
33120 formData.append('filename', file.filename);
33123 if(typeof(file.mimetype) != 'undefined'){
33124 formData.append('mimetype', file.mimetype);
33129 if(this.fireEvent('prepare', this, formData) != false){
33130 this.xhr.send(formData);
33140 * @class Roo.bootstrap.DocumentViewer
33141 * @extends Roo.bootstrap.Component
33142 * Bootstrap DocumentViewer class
33143 * @cfg {Boolean} showDownload (true|false) show download button (default true)
33144 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
33147 * Create a new DocumentViewer
33148 * @param {Object} config The config object
33151 Roo.bootstrap.DocumentViewer = function(config){
33152 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
33157 * Fire after initEvent
33158 * @param {Roo.bootstrap.DocumentViewer} this
33164 * @param {Roo.bootstrap.DocumentViewer} this
33169 * Fire after download button
33170 * @param {Roo.bootstrap.DocumentViewer} this
33175 * Fire after trash button
33176 * @param {Roo.bootstrap.DocumentViewer} this
33183 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
33185 showDownload : true,
33189 getAutoCreate : function()
33193 cls : 'roo-document-viewer',
33197 cls : 'roo-document-viewer-body',
33201 cls : 'roo-document-viewer-thumb',
33205 cls : 'roo-document-viewer-image'
33213 cls : 'roo-document-viewer-footer',
33216 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
33220 cls : 'btn-group roo-document-viewer-download',
33224 cls : 'btn btn-default',
33225 html : '<i class="fa fa-download"></i>'
33231 cls : 'btn-group roo-document-viewer-trash',
33235 cls : 'btn btn-default',
33236 html : '<i class="fa fa-trash"></i>'
33249 initEvents : function()
33251 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
33252 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
33254 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
33255 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
33257 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
33258 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
33260 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
33261 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
33263 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
33264 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
33266 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
33267 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
33269 this.bodyEl.on('click', this.onClick, this);
33270 this.downloadBtn.on('click', this.onDownload, this);
33271 this.trashBtn.on('click', this.onTrash, this);
33273 this.downloadBtn.hide();
33274 this.trashBtn.hide();
33276 if(this.showDownload){
33277 this.downloadBtn.show();
33280 if(this.showTrash){
33281 this.trashBtn.show();
33284 if(!this.showDownload && !this.showTrash) {
33285 this.footerEl.hide();
33290 initial : function()
33292 this.fireEvent('initial', this);
33296 onClick : function(e)
33298 e.preventDefault();
33300 this.fireEvent('click', this);
33303 onDownload : function(e)
33305 e.preventDefault();
33307 this.fireEvent('download', this);
33310 onTrash : function(e)
33312 e.preventDefault();
33314 this.fireEvent('trash', this);
33326 * @class Roo.bootstrap.NavProgressBar
33327 * @extends Roo.bootstrap.Component
33328 * Bootstrap NavProgressBar class
33331 * Create a new nav progress bar
33332 * @param {Object} config The config object
33335 Roo.bootstrap.NavProgressBar = function(config){
33336 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
33338 this.bullets = this.bullets || [];
33340 // Roo.bootstrap.NavProgressBar.register(this);
33344 * Fires when the active item changes
33345 * @param {Roo.bootstrap.NavProgressBar} this
33346 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
33347 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
33354 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
33359 getAutoCreate : function()
33361 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
33365 cls : 'roo-navigation-bar-group',
33369 cls : 'roo-navigation-top-bar'
33373 cls : 'roo-navigation-bullets-bar',
33377 cls : 'roo-navigation-bar'
33384 cls : 'roo-navigation-bottom-bar'
33394 initEvents: function()
33399 onRender : function(ct, position)
33401 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
33403 if(this.bullets.length){
33404 Roo.each(this.bullets, function(b){
33413 addItem : function(cfg)
33415 var item = new Roo.bootstrap.NavProgressItem(cfg);
33417 item.parentId = this.id;
33418 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
33421 var top = new Roo.bootstrap.Element({
33423 cls : 'roo-navigation-bar-text'
33426 var bottom = new Roo.bootstrap.Element({
33428 cls : 'roo-navigation-bar-text'
33431 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
33432 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
33434 var topText = new Roo.bootstrap.Element({
33436 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
33439 var bottomText = new Roo.bootstrap.Element({
33441 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
33444 topText.onRender(top.el, null);
33445 bottomText.onRender(bottom.el, null);
33448 item.bottomEl = bottom;
33451 this.barItems.push(item);
33456 getActive : function()
33458 var active = false;
33460 Roo.each(this.barItems, function(v){
33462 if (!v.isActive()) {
33474 setActiveItem : function(item)
33478 Roo.each(this.barItems, function(v){
33479 if (v.rid == item.rid) {
33483 if (v.isActive()) {
33484 v.setActive(false);
33489 item.setActive(true);
33491 this.fireEvent('changed', this, item, prev);
33494 getBarItem: function(rid)
33498 Roo.each(this.barItems, function(e) {
33499 if (e.rid != rid) {
33510 indexOfItem : function(item)
33514 Roo.each(this.barItems, function(v, i){
33516 if (v.rid != item.rid) {
33527 setActiveNext : function()
33529 var i = this.indexOfItem(this.getActive());
33531 if (i > this.barItems.length) {
33535 this.setActiveItem(this.barItems[i+1]);
33538 setActivePrev : function()
33540 var i = this.indexOfItem(this.getActive());
33546 this.setActiveItem(this.barItems[i-1]);
33549 format : function()
33551 if(!this.barItems.length){
33555 var width = 100 / this.barItems.length;
33557 Roo.each(this.barItems, function(i){
33558 i.el.setStyle('width', width + '%');
33559 i.topEl.el.setStyle('width', width + '%');
33560 i.bottomEl.el.setStyle('width', width + '%');
33569 * Nav Progress Item
33574 * @class Roo.bootstrap.NavProgressItem
33575 * @extends Roo.bootstrap.Component
33576 * Bootstrap NavProgressItem class
33577 * @cfg {String} rid the reference id
33578 * @cfg {Boolean} active (true|false) Is item active default false
33579 * @cfg {Boolean} disabled (true|false) Is item active default false
33580 * @cfg {String} html
33581 * @cfg {String} position (top|bottom) text position default bottom
33582 * @cfg {String} icon show icon instead of number
33585 * Create a new NavProgressItem
33586 * @param {Object} config The config object
33588 Roo.bootstrap.NavProgressItem = function(config){
33589 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
33594 * The raw click event for the entire grid.
33595 * @param {Roo.bootstrap.NavProgressItem} this
33596 * @param {Roo.EventObject} e
33603 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
33609 position : 'bottom',
33612 getAutoCreate : function()
33614 var iconCls = 'roo-navigation-bar-item-icon';
33616 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
33620 cls: 'roo-navigation-bar-item',
33630 cfg.cls += ' active';
33633 cfg.cls += ' disabled';
33639 disable : function()
33641 this.setDisabled(true);
33644 enable : function()
33646 this.setDisabled(false);
33649 initEvents: function()
33651 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
33653 this.iconEl.on('click', this.onClick, this);
33656 onClick : function(e)
33658 e.preventDefault();
33664 if(this.fireEvent('click', this, e) === false){
33668 this.parent().setActiveItem(this);
33671 isActive: function ()
33673 return this.active;
33676 setActive : function(state)
33678 if(this.active == state){
33682 this.active = state;
33685 this.el.addClass('active');
33689 this.el.removeClass('active');
33694 setDisabled : function(state)
33696 if(this.disabled == state){
33700 this.disabled = state;
33703 this.el.addClass('disabled');
33707 this.el.removeClass('disabled');
33710 tooltipEl : function()
33712 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
33725 * @class Roo.bootstrap.FieldLabel
33726 * @extends Roo.bootstrap.Component
33727 * Bootstrap FieldLabel class
33728 * @cfg {String} html contents of the element
33729 * @cfg {String} tag tag of the element default label
33730 * @cfg {String} cls class of the element
33731 * @cfg {String} target label target
33732 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
33733 * @cfg {String} invalidClass DEPRICATED - BS4 uses is-invalid
33734 * @cfg {String} validClass DEPRICATED - BS4 uses is-valid
33735 * @cfg {String} iconTooltip default "This field is required"
33736 * @cfg {String} indicatorpos (left|right) default left
33739 * Create a new FieldLabel
33740 * @param {Object} config The config object
33743 Roo.bootstrap.FieldLabel = function(config){
33744 Roo.bootstrap.Element.superclass.constructor.call(this, config);
33749 * Fires after the field has been marked as invalid.
33750 * @param {Roo.form.FieldLabel} this
33751 * @param {String} msg The validation message
33756 * Fires after the field has been validated with no errors.
33757 * @param {Roo.form.FieldLabel} this
33763 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
33770 invalidClass : 'has-warning',
33771 validClass : 'has-success',
33772 iconTooltip : 'This field is required',
33773 indicatorpos : 'left',
33775 getAutoCreate : function(){
33778 if (!this.allowBlank) {
33784 cls : 'roo-bootstrap-field-label ' + this.cls,
33789 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star ' + cls,
33790 tooltip : this.iconTooltip
33799 if(this.indicatorpos == 'right'){
33802 cls : 'roo-bootstrap-field-label ' + this.cls,
33811 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star '+ cls,
33812 tooltip : this.iconTooltip
33821 initEvents: function()
33823 Roo.bootstrap.Element.superclass.initEvents.call(this);
33825 this.indicator = this.indicatorEl();
33827 if(this.indicator){
33828 this.indicator.removeClass('visible');
33829 this.indicator.addClass('invisible');
33832 Roo.bootstrap.FieldLabel.register(this);
33835 indicatorEl : function()
33837 var indicator = this.el.select('i.roo-required-indicator',true).first();
33848 * Mark this field as valid
33850 markValid : function()
33852 if(this.indicator){
33853 this.indicator.removeClass('visible');
33854 this.indicator.addClass('invisible');
33856 if (Roo.bootstrap.version == 3) {
33857 this.el.removeClass(this.invalidClass);
33858 this.el.addClass(this.validClass);
33860 this.el.removeClass('is-invalid');
33861 this.el.addClass('is-valid');
33865 this.fireEvent('valid', this);
33869 * Mark this field as invalid
33870 * @param {String} msg The validation message
33872 markInvalid : function(msg)
33874 if(this.indicator){
33875 this.indicator.removeClass('invisible');
33876 this.indicator.addClass('visible');
33878 if (Roo.bootstrap.version == 3) {
33879 this.el.removeClass(this.validClass);
33880 this.el.addClass(this.invalidClass);
33882 this.el.removeClass('is-valid');
33883 this.el.addClass('is-invalid');
33887 this.fireEvent('invalid', this, msg);
33893 Roo.apply(Roo.bootstrap.FieldLabel, {
33898 * register a FieldLabel Group
33899 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
33901 register : function(label)
33903 if(this.groups.hasOwnProperty(label.target)){
33907 this.groups[label.target] = label;
33911 * fetch a FieldLabel Group based on the target
33912 * @param {string} target
33913 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
33915 get: function(target) {
33916 if (typeof(this.groups[target]) == 'undefined') {
33920 return this.groups[target] ;
33929 * page DateSplitField.
33935 * @class Roo.bootstrap.DateSplitField
33936 * @extends Roo.bootstrap.Component
33937 * Bootstrap DateSplitField class
33938 * @cfg {string} fieldLabel - the label associated
33939 * @cfg {Number} labelWidth set the width of label (0-12)
33940 * @cfg {String} labelAlign (top|left)
33941 * @cfg {Boolean} dayAllowBlank (true|false) default false
33942 * @cfg {Boolean} monthAllowBlank (true|false) default false
33943 * @cfg {Boolean} yearAllowBlank (true|false) default false
33944 * @cfg {string} dayPlaceholder
33945 * @cfg {string} monthPlaceholder
33946 * @cfg {string} yearPlaceholder
33947 * @cfg {string} dayFormat default 'd'
33948 * @cfg {string} monthFormat default 'm'
33949 * @cfg {string} yearFormat default 'Y'
33950 * @cfg {Number} labellg set the width of label (1-12)
33951 * @cfg {Number} labelmd set the width of label (1-12)
33952 * @cfg {Number} labelsm set the width of label (1-12)
33953 * @cfg {Number} labelxs set the width of label (1-12)
33957 * Create a new DateSplitField
33958 * @param {Object} config The config object
33961 Roo.bootstrap.DateSplitField = function(config){
33962 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
33968 * getting the data of years
33969 * @param {Roo.bootstrap.DateSplitField} this
33970 * @param {Object} years
33975 * getting the data of days
33976 * @param {Roo.bootstrap.DateSplitField} this
33977 * @param {Object} days
33982 * Fires after the field has been marked as invalid.
33983 * @param {Roo.form.Field} this
33984 * @param {String} msg The validation message
33989 * Fires after the field has been validated with no errors.
33990 * @param {Roo.form.Field} this
33996 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
33999 labelAlign : 'top',
34001 dayAllowBlank : false,
34002 monthAllowBlank : false,
34003 yearAllowBlank : false,
34004 dayPlaceholder : '',
34005 monthPlaceholder : '',
34006 yearPlaceholder : '',
34010 isFormField : true,
34016 getAutoCreate : function()
34020 cls : 'row roo-date-split-field-group',
34025 cls : 'form-hidden-field roo-date-split-field-group-value',
34031 var labelCls = 'col-md-12';
34032 var contentCls = 'col-md-4';
34034 if(this.fieldLabel){
34038 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
34042 html : this.fieldLabel
34047 if(this.labelAlign == 'left'){
34049 if(this.labelWidth > 12){
34050 label.style = "width: " + this.labelWidth + 'px';
34053 if(this.labelWidth < 13 && this.labelmd == 0){
34054 this.labelmd = this.labelWidth;
34057 if(this.labellg > 0){
34058 labelCls = ' col-lg-' + this.labellg;
34059 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
34062 if(this.labelmd > 0){
34063 labelCls = ' col-md-' + this.labelmd;
34064 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
34067 if(this.labelsm > 0){
34068 labelCls = ' col-sm-' + this.labelsm;
34069 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
34072 if(this.labelxs > 0){
34073 labelCls = ' col-xs-' + this.labelxs;
34074 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
34078 label.cls += ' ' + labelCls;
34080 cfg.cn.push(label);
34083 Roo.each(['day', 'month', 'year'], function(t){
34086 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
34093 inputEl: function ()
34095 return this.el.select('.roo-date-split-field-group-value', true).first();
34098 onRender : function(ct, position)
34102 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
34104 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
34106 this.dayField = new Roo.bootstrap.ComboBox({
34107 allowBlank : this.dayAllowBlank,
34108 alwaysQuery : true,
34109 displayField : 'value',
34112 forceSelection : true,
34114 placeholder : this.dayPlaceholder,
34115 selectOnFocus : true,
34116 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
34117 triggerAction : 'all',
34119 valueField : 'value',
34120 store : new Roo.data.SimpleStore({
34121 data : (function() {
34123 _this.fireEvent('days', _this, days);
34126 fields : [ 'value' ]
34129 select : function (_self, record, index)
34131 _this.setValue(_this.getValue());
34136 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
34138 this.monthField = new Roo.bootstrap.MonthField({
34139 after : '<i class=\"fa fa-calendar\"></i>',
34140 allowBlank : this.monthAllowBlank,
34141 placeholder : this.monthPlaceholder,
34144 render : function (_self)
34146 this.el.select('span.input-group-addon', true).first().on('click', function(e){
34147 e.preventDefault();
34151 select : function (_self, oldvalue, newvalue)
34153 _this.setValue(_this.getValue());
34158 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
34160 this.yearField = new Roo.bootstrap.ComboBox({
34161 allowBlank : this.yearAllowBlank,
34162 alwaysQuery : true,
34163 displayField : 'value',
34166 forceSelection : true,
34168 placeholder : this.yearPlaceholder,
34169 selectOnFocus : true,
34170 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
34171 triggerAction : 'all',
34173 valueField : 'value',
34174 store : new Roo.data.SimpleStore({
34175 data : (function() {
34177 _this.fireEvent('years', _this, years);
34180 fields : [ 'value' ]
34183 select : function (_self, record, index)
34185 _this.setValue(_this.getValue());
34190 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
34193 setValue : function(v, format)
34195 this.inputEl.dom.value = v;
34197 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
34199 var d = Date.parseDate(v, f);
34206 this.setDay(d.format(this.dayFormat));
34207 this.setMonth(d.format(this.monthFormat));
34208 this.setYear(d.format(this.yearFormat));
34215 setDay : function(v)
34217 this.dayField.setValue(v);
34218 this.inputEl.dom.value = this.getValue();
34223 setMonth : function(v)
34225 this.monthField.setValue(v, true);
34226 this.inputEl.dom.value = this.getValue();
34231 setYear : function(v)
34233 this.yearField.setValue(v);
34234 this.inputEl.dom.value = this.getValue();
34239 getDay : function()
34241 return this.dayField.getValue();
34244 getMonth : function()
34246 return this.monthField.getValue();
34249 getYear : function()
34251 return this.yearField.getValue();
34254 getValue : function()
34256 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
34258 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
34268 this.inputEl.dom.value = '';
34273 validate : function()
34275 var d = this.dayField.validate();
34276 var m = this.monthField.validate();
34277 var y = this.yearField.validate();
34282 (!this.dayAllowBlank && !d) ||
34283 (!this.monthAllowBlank && !m) ||
34284 (!this.yearAllowBlank && !y)
34289 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
34298 this.markInvalid();
34303 markValid : function()
34306 var label = this.el.select('label', true).first();
34307 var icon = this.el.select('i.fa-star', true).first();
34313 this.fireEvent('valid', this);
34317 * Mark this field as invalid
34318 * @param {String} msg The validation message
34320 markInvalid : function(msg)
34323 var label = this.el.select('label', true).first();
34324 var icon = this.el.select('i.fa-star', true).first();
34326 if(label && !icon){
34327 this.el.select('.roo-date-split-field-label', true).createChild({
34329 cls : 'text-danger fa fa-lg fa-star',
34330 tooltip : 'This field is required',
34331 style : 'margin-right:5px;'
34335 this.fireEvent('invalid', this, msg);
34338 clearInvalid : function()
34340 var label = this.el.select('label', true).first();
34341 var icon = this.el.select('i.fa-star', true).first();
34347 this.fireEvent('valid', this);
34350 getName: function()
34360 * http://masonry.desandro.com
34362 * The idea is to render all the bricks based on vertical width...
34364 * The original code extends 'outlayer' - we might need to use that....
34370 * @class Roo.bootstrap.LayoutMasonry
34371 * @extends Roo.bootstrap.Component
34372 * Bootstrap Layout Masonry class
34375 * Create a new Element
34376 * @param {Object} config The config object
34379 Roo.bootstrap.LayoutMasonry = function(config){
34381 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
34385 Roo.bootstrap.LayoutMasonry.register(this);
34391 * Fire after layout the items
34392 * @param {Roo.bootstrap.LayoutMasonry} this
34393 * @param {Roo.EventObject} e
34400 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
34403 * @cfg {Boolean} isLayoutInstant = no animation?
34405 isLayoutInstant : false, // needed?
34408 * @cfg {Number} boxWidth width of the columns
34413 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
34418 * @cfg {Number} padWidth padding below box..
34423 * @cfg {Number} gutter gutter width..
34428 * @cfg {Number} maxCols maximum number of columns
34434 * @cfg {Boolean} isAutoInitial defalut true
34436 isAutoInitial : true,
34441 * @cfg {Boolean} isHorizontal defalut false
34443 isHorizontal : false,
34445 currentSize : null,
34451 bricks: null, //CompositeElement
34455 _isLayoutInited : false,
34457 // isAlternative : false, // only use for vertical layout...
34460 * @cfg {Number} alternativePadWidth padding below box..
34462 alternativePadWidth : 50,
34464 selectedBrick : [],
34466 getAutoCreate : function(){
34468 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
34472 cls: 'blog-masonary-wrapper ' + this.cls,
34474 cls : 'mas-boxes masonary'
34481 getChildContainer: function( )
34483 if (this.boxesEl) {
34484 return this.boxesEl;
34487 this.boxesEl = this.el.select('.mas-boxes').first();
34489 return this.boxesEl;
34493 initEvents : function()
34497 if(this.isAutoInitial){
34498 Roo.log('hook children rendered');
34499 this.on('childrenrendered', function() {
34500 Roo.log('children rendered');
34506 initial : function()
34508 this.selectedBrick = [];
34510 this.currentSize = this.el.getBox(true);
34512 Roo.EventManager.onWindowResize(this.resize, this);
34514 if(!this.isAutoInitial){
34522 //this.layout.defer(500,this);
34526 resize : function()
34528 var cs = this.el.getBox(true);
34531 this.currentSize.width == cs.width &&
34532 this.currentSize.x == cs.x &&
34533 this.currentSize.height == cs.height &&
34534 this.currentSize.y == cs.y
34536 Roo.log("no change in with or X or Y");
34540 this.currentSize = cs;
34546 layout : function()
34548 this._resetLayout();
34550 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
34552 this.layoutItems( isInstant );
34554 this._isLayoutInited = true;
34556 this.fireEvent('layout', this);
34560 _resetLayout : function()
34562 if(this.isHorizontal){
34563 this.horizontalMeasureColumns();
34567 this.verticalMeasureColumns();
34571 verticalMeasureColumns : function()
34573 this.getContainerWidth();
34575 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
34576 // this.colWidth = Math.floor(this.containerWidth * 0.8);
34580 var boxWidth = this.boxWidth + this.padWidth;
34582 if(this.containerWidth < this.boxWidth){
34583 boxWidth = this.containerWidth
34586 var containerWidth = this.containerWidth;
34588 var cols = Math.floor(containerWidth / boxWidth);
34590 this.cols = Math.max( cols, 1 );
34592 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
34594 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
34596 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
34598 this.colWidth = boxWidth + avail - this.padWidth;
34600 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
34601 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
34604 horizontalMeasureColumns : function()
34606 this.getContainerWidth();
34608 var boxWidth = this.boxWidth;
34610 if(this.containerWidth < boxWidth){
34611 boxWidth = this.containerWidth;
34614 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
34616 this.el.setHeight(boxWidth);
34620 getContainerWidth : function()
34622 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
34625 layoutItems : function( isInstant )
34627 Roo.log(this.bricks);
34629 var items = Roo.apply([], this.bricks);
34631 if(this.isHorizontal){
34632 this._horizontalLayoutItems( items , isInstant );
34636 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
34637 // this._verticalAlternativeLayoutItems( items , isInstant );
34641 this._verticalLayoutItems( items , isInstant );
34645 _verticalLayoutItems : function ( items , isInstant)
34647 if ( !items || !items.length ) {
34652 ['xs', 'xs', 'xs', 'tall'],
34653 ['xs', 'xs', 'tall'],
34654 ['xs', 'xs', 'sm'],
34655 ['xs', 'xs', 'xs'],
34661 ['sm', 'xs', 'xs'],
34665 ['tall', 'xs', 'xs', 'xs'],
34666 ['tall', 'xs', 'xs'],
34678 Roo.each(items, function(item, k){
34680 switch (item.size) {
34681 // these layouts take up a full box,
34692 boxes.push([item]);
34715 var filterPattern = function(box, length)
34723 var pattern = box.slice(0, length);
34727 Roo.each(pattern, function(i){
34728 format.push(i.size);
34731 Roo.each(standard, function(s){
34733 if(String(s) != String(format)){
34742 if(!match && length == 1){
34747 filterPattern(box, length - 1);
34751 queue.push(pattern);
34753 box = box.slice(length, box.length);
34755 filterPattern(box, 4);
34761 Roo.each(boxes, function(box, k){
34767 if(box.length == 1){
34772 filterPattern(box, 4);
34776 this._processVerticalLayoutQueue( queue, isInstant );
34780 // _verticalAlternativeLayoutItems : function( items , isInstant )
34782 // if ( !items || !items.length ) {
34786 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
34790 _horizontalLayoutItems : function ( items , isInstant)
34792 if ( !items || !items.length || items.length < 3) {
34798 var eItems = items.slice(0, 3);
34800 items = items.slice(3, items.length);
34803 ['xs', 'xs', 'xs', 'wide'],
34804 ['xs', 'xs', 'wide'],
34805 ['xs', 'xs', 'sm'],
34806 ['xs', 'xs', 'xs'],
34812 ['sm', 'xs', 'xs'],
34816 ['wide', 'xs', 'xs', 'xs'],
34817 ['wide', 'xs', 'xs'],
34830 Roo.each(items, function(item, k){
34832 switch (item.size) {
34843 boxes.push([item]);
34867 var filterPattern = function(box, length)
34875 var pattern = box.slice(0, length);
34879 Roo.each(pattern, function(i){
34880 format.push(i.size);
34883 Roo.each(standard, function(s){
34885 if(String(s) != String(format)){
34894 if(!match && length == 1){
34899 filterPattern(box, length - 1);
34903 queue.push(pattern);
34905 box = box.slice(length, box.length);
34907 filterPattern(box, 4);
34913 Roo.each(boxes, function(box, k){
34919 if(box.length == 1){
34924 filterPattern(box, 4);
34931 var pos = this.el.getBox(true);
34935 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
34937 var hit_end = false;
34939 Roo.each(queue, function(box){
34943 Roo.each(box, function(b){
34945 b.el.setVisibilityMode(Roo.Element.DISPLAY);
34955 Roo.each(box, function(b){
34957 b.el.setVisibilityMode(Roo.Element.DISPLAY);
34960 mx = Math.max(mx, b.x);
34964 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
34968 Roo.each(box, function(b){
34970 b.el.setVisibilityMode(Roo.Element.DISPLAY);
34984 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
34987 /** Sets position of item in DOM
34988 * @param {Element} item
34989 * @param {Number} x - horizontal position
34990 * @param {Number} y - vertical position
34991 * @param {Boolean} isInstant - disables transitions
34993 _processVerticalLayoutQueue : function( queue, isInstant )
34995 var pos = this.el.getBox(true);
35000 for (var i = 0; i < this.cols; i++){
35004 Roo.each(queue, function(box, k){
35006 var col = k % this.cols;
35008 Roo.each(box, function(b,kk){
35010 b.el.position('absolute');
35012 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
35013 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
35015 if(b.size == 'md-left' || b.size == 'md-right'){
35016 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
35017 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
35020 b.el.setWidth(width);
35021 b.el.setHeight(height);
35023 b.el.select('iframe',true).setSize(width,height);
35027 for (var i = 0; i < this.cols; i++){
35029 if(maxY[i] < maxY[col]){
35034 col = Math.min(col, i);
35038 x = pos.x + col * (this.colWidth + this.padWidth);
35042 var positions = [];
35044 switch (box.length){
35046 positions = this.getVerticalOneBoxColPositions(x, y, box);
35049 positions = this.getVerticalTwoBoxColPositions(x, y, box);
35052 positions = this.getVerticalThreeBoxColPositions(x, y, box);
35055 positions = this.getVerticalFourBoxColPositions(x, y, box);
35061 Roo.each(box, function(b,kk){
35063 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
35065 var sz = b.el.getSize();
35067 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
35075 for (var i = 0; i < this.cols; i++){
35076 mY = Math.max(mY, maxY[i]);
35079 this.el.setHeight(mY - pos.y);
35083 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
35085 // var pos = this.el.getBox(true);
35088 // var maxX = pos.right;
35090 // var maxHeight = 0;
35092 // Roo.each(items, function(item, k){
35096 // item.el.position('absolute');
35098 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
35100 // item.el.setWidth(width);
35102 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
35104 // item.el.setHeight(height);
35107 // item.el.setXY([x, y], isInstant ? false : true);
35109 // item.el.setXY([maxX - width, y], isInstant ? false : true);
35112 // y = y + height + this.alternativePadWidth;
35114 // maxHeight = maxHeight + height + this.alternativePadWidth;
35118 // this.el.setHeight(maxHeight);
35122 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
35124 var pos = this.el.getBox(true);
35129 var maxX = pos.right;
35131 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
35133 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
35135 Roo.each(queue, function(box, k){
35137 Roo.each(box, function(b, kk){
35139 b.el.position('absolute');
35141 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
35142 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
35144 if(b.size == 'md-left' || b.size == 'md-right'){
35145 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
35146 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
35149 b.el.setWidth(width);
35150 b.el.setHeight(height);
35158 var positions = [];
35160 switch (box.length){
35162 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
35165 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
35168 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
35171 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
35177 Roo.each(box, function(b,kk){
35179 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
35181 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
35189 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
35191 Roo.each(eItems, function(b,k){
35193 b.size = (k == 0) ? 'sm' : 'xs';
35194 b.x = (k == 0) ? 2 : 1;
35195 b.y = (k == 0) ? 2 : 1;
35197 b.el.position('absolute');
35199 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
35201 b.el.setWidth(width);
35203 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
35205 b.el.setHeight(height);
35209 var positions = [];
35212 x : maxX - this.unitWidth * 2 - this.gutter,
35217 x : maxX - this.unitWidth,
35218 y : minY + (this.unitWidth + this.gutter) * 2
35222 x : maxX - this.unitWidth * 3 - this.gutter * 2,
35226 Roo.each(eItems, function(b,k){
35228 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
35234 getVerticalOneBoxColPositions : function(x, y, box)
35238 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
35240 if(box[0].size == 'md-left'){
35244 if(box[0].size == 'md-right'){
35249 x : x + (this.unitWidth + this.gutter) * rand,
35256 getVerticalTwoBoxColPositions : function(x, y, box)
35260 if(box[0].size == 'xs'){
35264 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
35268 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
35282 x : x + (this.unitWidth + this.gutter) * 2,
35283 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
35290 getVerticalThreeBoxColPositions : function(x, y, box)
35294 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
35302 x : x + (this.unitWidth + this.gutter) * 1,
35307 x : x + (this.unitWidth + this.gutter) * 2,
35315 if(box[0].size == 'xs' && box[1].size == 'xs'){
35324 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
35328 x : x + (this.unitWidth + this.gutter) * 1,
35342 x : x + (this.unitWidth + this.gutter) * 2,
35347 x : x + (this.unitWidth + this.gutter) * 2,
35348 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
35355 getVerticalFourBoxColPositions : function(x, y, box)
35359 if(box[0].size == 'xs'){
35368 y : y + (this.unitHeight + this.gutter) * 1
35373 y : y + (this.unitHeight + this.gutter) * 2
35377 x : x + (this.unitWidth + this.gutter) * 1,
35391 x : x + (this.unitWidth + this.gutter) * 2,
35396 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
35397 y : y + (this.unitHeight + this.gutter) * 1
35401 x : x + (this.unitWidth + this.gutter) * 2,
35402 y : y + (this.unitWidth + this.gutter) * 2
35409 getHorizontalOneBoxColPositions : function(maxX, minY, box)
35413 if(box[0].size == 'md-left'){
35415 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
35422 if(box[0].size == 'md-right'){
35424 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
35425 y : minY + (this.unitWidth + this.gutter) * 1
35431 var rand = Math.floor(Math.random() * (4 - box[0].y));
35434 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35435 y : minY + (this.unitWidth + this.gutter) * rand
35442 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
35446 if(box[0].size == 'xs'){
35449 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35454 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35455 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
35463 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35468 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35469 y : minY + (this.unitWidth + this.gutter) * 2
35476 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
35480 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
35483 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35488 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35489 y : minY + (this.unitWidth + this.gutter) * 1
35493 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
35494 y : minY + (this.unitWidth + this.gutter) * 2
35501 if(box[0].size == 'xs' && box[1].size == 'xs'){
35504 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35509 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35514 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
35515 y : minY + (this.unitWidth + this.gutter) * 1
35523 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35528 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35529 y : minY + (this.unitWidth + this.gutter) * 2
35533 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
35534 y : minY + (this.unitWidth + this.gutter) * 2
35541 getHorizontalFourBoxColPositions : function(maxX, minY, box)
35545 if(box[0].size == 'xs'){
35548 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35553 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35558 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),
35563 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
35564 y : minY + (this.unitWidth + this.gutter) * 1
35572 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35577 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35578 y : minY + (this.unitWidth + this.gutter) * 2
35582 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
35583 y : minY + (this.unitWidth + this.gutter) * 2
35587 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),
35588 y : minY + (this.unitWidth + this.gutter) * 2
35596 * remove a Masonry Brick
35597 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
35599 removeBrick : function(brick_id)
35605 for (var i = 0; i<this.bricks.length; i++) {
35606 if (this.bricks[i].id == brick_id) {
35607 this.bricks.splice(i,1);
35608 this.el.dom.removeChild(Roo.get(brick_id).dom);
35615 * adds a Masonry Brick
35616 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
35618 addBrick : function(cfg)
35620 var cn = new Roo.bootstrap.MasonryBrick(cfg);
35621 //this.register(cn);
35622 cn.parentId = this.id;
35623 cn.render(this.el);
35628 * register a Masonry Brick
35629 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
35632 register : function(brick)
35634 this.bricks.push(brick);
35635 brick.masonryId = this.id;
35639 * clear all the Masonry Brick
35641 clearAll : function()
35644 //this.getChildContainer().dom.innerHTML = "";
35645 this.el.dom.innerHTML = '';
35648 getSelected : function()
35650 if (!this.selectedBrick) {
35654 return this.selectedBrick;
35658 Roo.apply(Roo.bootstrap.LayoutMasonry, {
35662 * register a Masonry Layout
35663 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
35666 register : function(layout)
35668 this.groups[layout.id] = layout;
35671 * fetch a Masonry Layout based on the masonry layout ID
35672 * @param {string} the masonry layout to add
35673 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
35676 get: function(layout_id) {
35677 if (typeof(this.groups[layout_id]) == 'undefined') {
35680 return this.groups[layout_id] ;
35692 * http://masonry.desandro.com
35694 * The idea is to render all the bricks based on vertical width...
35696 * The original code extends 'outlayer' - we might need to use that....
35702 * @class Roo.bootstrap.LayoutMasonryAuto
35703 * @extends Roo.bootstrap.Component
35704 * Bootstrap Layout Masonry class
35707 * Create a new Element
35708 * @param {Object} config The config object
35711 Roo.bootstrap.LayoutMasonryAuto = function(config){
35712 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
35715 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
35718 * @cfg {Boolean} isFitWidth - resize the width..
35720 isFitWidth : false, // options..
35722 * @cfg {Boolean} isOriginLeft = left align?
35724 isOriginLeft : true,
35726 * @cfg {Boolean} isOriginTop = top align?
35728 isOriginTop : false,
35730 * @cfg {Boolean} isLayoutInstant = no animation?
35732 isLayoutInstant : false, // needed?
35734 * @cfg {Boolean} isResizingContainer = not sure if this is used..
35736 isResizingContainer : true,
35738 * @cfg {Number} columnWidth width of the columns
35744 * @cfg {Number} maxCols maximum number of columns
35749 * @cfg {Number} padHeight padding below box..
35755 * @cfg {Boolean} isAutoInitial defalut true
35758 isAutoInitial : true,
35764 initialColumnWidth : 0,
35765 currentSize : null,
35767 colYs : null, // array.
35774 bricks: null, //CompositeElement
35775 cols : 0, // array?
35776 // element : null, // wrapped now this.el
35777 _isLayoutInited : null,
35780 getAutoCreate : function(){
35784 cls: 'blog-masonary-wrapper ' + this.cls,
35786 cls : 'mas-boxes masonary'
35793 getChildContainer: function( )
35795 if (this.boxesEl) {
35796 return this.boxesEl;
35799 this.boxesEl = this.el.select('.mas-boxes').first();
35801 return this.boxesEl;
35805 initEvents : function()
35809 if(this.isAutoInitial){
35810 Roo.log('hook children rendered');
35811 this.on('childrenrendered', function() {
35812 Roo.log('children rendered');
35819 initial : function()
35821 this.reloadItems();
35823 this.currentSize = this.el.getBox(true);
35825 /// was window resize... - let's see if this works..
35826 Roo.EventManager.onWindowResize(this.resize, this);
35828 if(!this.isAutoInitial){
35833 this.layout.defer(500,this);
35836 reloadItems: function()
35838 this.bricks = this.el.select('.masonry-brick', true);
35840 this.bricks.each(function(b) {
35841 //Roo.log(b.getSize());
35842 if (!b.attr('originalwidth')) {
35843 b.attr('originalwidth', b.getSize().width);
35848 Roo.log(this.bricks.elements.length);
35851 resize : function()
35854 var cs = this.el.getBox(true);
35856 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
35857 Roo.log("no change in with or X");
35860 this.currentSize = cs;
35864 layout : function()
35867 this._resetLayout();
35868 //this._manageStamps();
35870 // don't animate first layout
35871 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
35872 this.layoutItems( isInstant );
35874 // flag for initalized
35875 this._isLayoutInited = true;
35878 layoutItems : function( isInstant )
35880 //var items = this._getItemsForLayout( this.items );
35881 // original code supports filtering layout items.. we just ignore it..
35883 this._layoutItems( this.bricks , isInstant );
35885 this._postLayout();
35887 _layoutItems : function ( items , isInstant)
35889 //this.fireEvent( 'layout', this, items );
35892 if ( !items || !items.elements.length ) {
35893 // no items, emit event with empty array
35898 items.each(function(item) {
35899 Roo.log("layout item");
35901 // get x/y object from method
35902 var position = this._getItemLayoutPosition( item );
35904 position.item = item;
35905 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
35906 queue.push( position );
35909 this._processLayoutQueue( queue );
35911 /** Sets position of item in DOM
35912 * @param {Element} item
35913 * @param {Number} x - horizontal position
35914 * @param {Number} y - vertical position
35915 * @param {Boolean} isInstant - disables transitions
35917 _processLayoutQueue : function( queue )
35919 for ( var i=0, len = queue.length; i < len; i++ ) {
35920 var obj = queue[i];
35921 obj.item.position('absolute');
35922 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
35928 * Any logic you want to do after each layout,
35929 * i.e. size the container
35931 _postLayout : function()
35933 this.resizeContainer();
35936 resizeContainer : function()
35938 if ( !this.isResizingContainer ) {
35941 var size = this._getContainerSize();
35943 this.el.setSize(size.width,size.height);
35944 this.boxesEl.setSize(size.width,size.height);
35950 _resetLayout : function()
35952 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
35953 this.colWidth = this.el.getWidth();
35954 //this.gutter = this.el.getWidth();
35956 this.measureColumns();
35962 this.colYs.push( 0 );
35968 measureColumns : function()
35970 this.getContainerWidth();
35971 // if columnWidth is 0, default to outerWidth of first item
35972 if ( !this.columnWidth ) {
35973 var firstItem = this.bricks.first();
35974 Roo.log(firstItem);
35975 this.columnWidth = this.containerWidth;
35976 if (firstItem && firstItem.attr('originalwidth') ) {
35977 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
35979 // columnWidth fall back to item of first element
35980 Roo.log("set column width?");
35981 this.initialColumnWidth = this.columnWidth ;
35983 // if first elem has no width, default to size of container
35988 if (this.initialColumnWidth) {
35989 this.columnWidth = this.initialColumnWidth;
35994 // column width is fixed at the top - however if container width get's smaller we should
35997 // this bit calcs how man columns..
35999 var columnWidth = this.columnWidth += this.gutter;
36001 // calculate columns
36002 var containerWidth = this.containerWidth + this.gutter;
36004 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
36005 // fix rounding errors, typically with gutters
36006 var excess = columnWidth - containerWidth % columnWidth;
36009 // if overshoot is less than a pixel, round up, otherwise floor it
36010 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
36011 cols = Math[ mathMethod ]( cols );
36012 this.cols = Math.max( cols, 1 );
36013 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
36015 // padding positioning..
36016 var totalColWidth = this.cols * this.columnWidth;
36017 var padavail = this.containerWidth - totalColWidth;
36018 // so for 2 columns - we need 3 'pads'
36020 var padNeeded = (1+this.cols) * this.padWidth;
36022 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
36024 this.columnWidth += padExtra
36025 //this.padWidth = Math.floor(padavail / ( this.cols));
36027 // adjust colum width so that padding is fixed??
36029 // we have 3 columns ... total = width * 3
36030 // we have X left over... that should be used by
36032 //if (this.expandC) {
36040 getContainerWidth : function()
36042 /* // container is parent if fit width
36043 var container = this.isFitWidth ? this.element.parentNode : this.element;
36044 // check that this.size and size are there
36045 // IE8 triggers resize on body size change, so they might not be
36047 var size = getSize( container ); //FIXME
36048 this.containerWidth = size && size.innerWidth; //FIXME
36051 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
36055 _getItemLayoutPosition : function( item ) // what is item?
36057 // we resize the item to our columnWidth..
36059 item.setWidth(this.columnWidth);
36060 item.autoBoxAdjust = false;
36062 var sz = item.getSize();
36064 // how many columns does this brick span
36065 var remainder = this.containerWidth % this.columnWidth;
36067 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
36068 // round if off by 1 pixel, otherwise use ceil
36069 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
36070 colSpan = Math.min( colSpan, this.cols );
36072 // normally this should be '1' as we dont' currently allow multi width columns..
36074 var colGroup = this._getColGroup( colSpan );
36075 // get the minimum Y value from the columns
36076 var minimumY = Math.min.apply( Math, colGroup );
36077 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
36079 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
36081 // position the brick
36083 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
36084 y: this.currentSize.y + minimumY + this.padHeight
36088 // apply setHeight to necessary columns
36089 var setHeight = minimumY + sz.height + this.padHeight;
36090 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
36092 var setSpan = this.cols + 1 - colGroup.length;
36093 for ( var i = 0; i < setSpan; i++ ) {
36094 this.colYs[ shortColIndex + i ] = setHeight ;
36101 * @param {Number} colSpan - number of columns the element spans
36102 * @returns {Array} colGroup
36104 _getColGroup : function( colSpan )
36106 if ( colSpan < 2 ) {
36107 // if brick spans only one column, use all the column Ys
36112 // how many different places could this brick fit horizontally
36113 var groupCount = this.cols + 1 - colSpan;
36114 // for each group potential horizontal position
36115 for ( var i = 0; i < groupCount; i++ ) {
36116 // make an array of colY values for that one group
36117 var groupColYs = this.colYs.slice( i, i + colSpan );
36118 // and get the max value of the array
36119 colGroup[i] = Math.max.apply( Math, groupColYs );
36124 _manageStamp : function( stamp )
36126 var stampSize = stamp.getSize();
36127 var offset = stamp.getBox();
36128 // get the columns that this stamp affects
36129 var firstX = this.isOriginLeft ? offset.x : offset.right;
36130 var lastX = firstX + stampSize.width;
36131 var firstCol = Math.floor( firstX / this.columnWidth );
36132 firstCol = Math.max( 0, firstCol );
36134 var lastCol = Math.floor( lastX / this.columnWidth );
36135 // lastCol should not go over if multiple of columnWidth #425
36136 lastCol -= lastX % this.columnWidth ? 0 : 1;
36137 lastCol = Math.min( this.cols - 1, lastCol );
36139 // set colYs to bottom of the stamp
36140 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
36143 for ( var i = firstCol; i <= lastCol; i++ ) {
36144 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
36149 _getContainerSize : function()
36151 this.maxY = Math.max.apply( Math, this.colYs );
36156 if ( this.isFitWidth ) {
36157 size.width = this._getContainerFitWidth();
36163 _getContainerFitWidth : function()
36165 var unusedCols = 0;
36166 // count unused columns
36169 if ( this.colYs[i] !== 0 ) {
36174 // fit container to columns that have been used
36175 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
36178 needsResizeLayout : function()
36180 var previousWidth = this.containerWidth;
36181 this.getContainerWidth();
36182 return previousWidth !== this.containerWidth;
36197 * @class Roo.bootstrap.MasonryBrick
36198 * @extends Roo.bootstrap.Component
36199 * Bootstrap MasonryBrick class
36202 * Create a new MasonryBrick
36203 * @param {Object} config The config object
36206 Roo.bootstrap.MasonryBrick = function(config){
36208 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
36210 Roo.bootstrap.MasonryBrick.register(this);
36216 * When a MasonryBrick is clcik
36217 * @param {Roo.bootstrap.MasonryBrick} this
36218 * @param {Roo.EventObject} e
36224 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
36227 * @cfg {String} title
36231 * @cfg {String} html
36235 * @cfg {String} bgimage
36239 * @cfg {String} videourl
36243 * @cfg {String} cls
36247 * @cfg {String} href
36251 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
36256 * @cfg {String} placetitle (center|bottom)
36261 * @cfg {Boolean} isFitContainer defalut true
36263 isFitContainer : true,
36266 * @cfg {Boolean} preventDefault defalut false
36268 preventDefault : false,
36271 * @cfg {Boolean} inverse defalut false
36273 maskInverse : false,
36275 getAutoCreate : function()
36277 if(!this.isFitContainer){
36278 return this.getSplitAutoCreate();
36281 var cls = 'masonry-brick masonry-brick-full';
36283 if(this.href.length){
36284 cls += ' masonry-brick-link';
36287 if(this.bgimage.length){
36288 cls += ' masonry-brick-image';
36291 if(this.maskInverse){
36292 cls += ' mask-inverse';
36295 if(!this.html.length && !this.maskInverse && !this.videourl.length){
36296 cls += ' enable-mask';
36300 cls += ' masonry-' + this.size + '-brick';
36303 if(this.placetitle.length){
36305 switch (this.placetitle) {
36307 cls += ' masonry-center-title';
36310 cls += ' masonry-bottom-title';
36317 if(!this.html.length && !this.bgimage.length){
36318 cls += ' masonry-center-title';
36321 if(!this.html.length && this.bgimage.length){
36322 cls += ' masonry-bottom-title';
36327 cls += ' ' + this.cls;
36331 tag: (this.href.length) ? 'a' : 'div',
36336 cls: 'masonry-brick-mask'
36340 cls: 'masonry-brick-paragraph',
36346 if(this.href.length){
36347 cfg.href = this.href;
36350 var cn = cfg.cn[1].cn;
36352 if(this.title.length){
36355 cls: 'masonry-brick-title',
36360 if(this.html.length){
36363 cls: 'masonry-brick-text',
36368 if (!this.title.length && !this.html.length) {
36369 cfg.cn[1].cls += ' hide';
36372 if(this.bgimage.length){
36375 cls: 'masonry-brick-image-view',
36380 if(this.videourl.length){
36381 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
36382 // youtube support only?
36385 cls: 'masonry-brick-image-view',
36388 allowfullscreen : true
36396 getSplitAutoCreate : function()
36398 var cls = 'masonry-brick masonry-brick-split';
36400 if(this.href.length){
36401 cls += ' masonry-brick-link';
36404 if(this.bgimage.length){
36405 cls += ' masonry-brick-image';
36409 cls += ' masonry-' + this.size + '-brick';
36412 switch (this.placetitle) {
36414 cls += ' masonry-center-title';
36417 cls += ' masonry-bottom-title';
36420 if(!this.bgimage.length){
36421 cls += ' masonry-center-title';
36424 if(this.bgimage.length){
36425 cls += ' masonry-bottom-title';
36431 cls += ' ' + this.cls;
36435 tag: (this.href.length) ? 'a' : 'div',
36440 cls: 'masonry-brick-split-head',
36444 cls: 'masonry-brick-paragraph',
36451 cls: 'masonry-brick-split-body',
36457 if(this.href.length){
36458 cfg.href = this.href;
36461 if(this.title.length){
36462 cfg.cn[0].cn[0].cn.push({
36464 cls: 'masonry-brick-title',
36469 if(this.html.length){
36470 cfg.cn[1].cn.push({
36472 cls: 'masonry-brick-text',
36477 if(this.bgimage.length){
36478 cfg.cn[0].cn.push({
36480 cls: 'masonry-brick-image-view',
36485 if(this.videourl.length){
36486 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
36487 // youtube support only?
36488 cfg.cn[0].cn.cn.push({
36490 cls: 'masonry-brick-image-view',
36493 allowfullscreen : true
36500 initEvents: function()
36502 switch (this.size) {
36535 this.el.on('touchstart', this.onTouchStart, this);
36536 this.el.on('touchmove', this.onTouchMove, this);
36537 this.el.on('touchend', this.onTouchEnd, this);
36538 this.el.on('contextmenu', this.onContextMenu, this);
36540 this.el.on('mouseenter' ,this.enter, this);
36541 this.el.on('mouseleave', this.leave, this);
36542 this.el.on('click', this.onClick, this);
36545 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
36546 this.parent().bricks.push(this);
36551 onClick: function(e, el)
36553 var time = this.endTimer - this.startTimer;
36554 // Roo.log(e.preventDefault());
36557 e.preventDefault();
36562 if(!this.preventDefault){
36566 e.preventDefault();
36568 if (this.activeClass != '') {
36569 this.selectBrick();
36572 this.fireEvent('click', this, e);
36575 enter: function(e, el)
36577 e.preventDefault();
36579 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
36583 if(this.bgimage.length && this.html.length){
36584 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
36588 leave: function(e, el)
36590 e.preventDefault();
36592 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
36596 if(this.bgimage.length && this.html.length){
36597 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
36601 onTouchStart: function(e, el)
36603 // e.preventDefault();
36605 this.touchmoved = false;
36607 if(!this.isFitContainer){
36611 if(!this.bgimage.length || !this.html.length){
36615 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
36617 this.timer = new Date().getTime();
36621 onTouchMove: function(e, el)
36623 this.touchmoved = true;
36626 onContextMenu : function(e,el)
36628 e.preventDefault();
36629 e.stopPropagation();
36633 onTouchEnd: function(e, el)
36635 // e.preventDefault();
36637 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
36644 if(!this.bgimage.length || !this.html.length){
36646 if(this.href.length){
36647 window.location.href = this.href;
36653 if(!this.isFitContainer){
36657 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
36659 window.location.href = this.href;
36662 //selection on single brick only
36663 selectBrick : function() {
36665 if (!this.parentId) {
36669 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
36670 var index = m.selectedBrick.indexOf(this.id);
36673 m.selectedBrick.splice(index,1);
36674 this.el.removeClass(this.activeClass);
36678 for(var i = 0; i < m.selectedBrick.length; i++) {
36679 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
36680 b.el.removeClass(b.activeClass);
36683 m.selectedBrick = [];
36685 m.selectedBrick.push(this.id);
36686 this.el.addClass(this.activeClass);
36690 isSelected : function(){
36691 return this.el.hasClass(this.activeClass);
36696 Roo.apply(Roo.bootstrap.MasonryBrick, {
36699 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
36701 * register a Masonry Brick
36702 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
36705 register : function(brick)
36707 //this.groups[brick.id] = brick;
36708 this.groups.add(brick.id, brick);
36711 * fetch a masonry brick based on the masonry brick ID
36712 * @param {string} the masonry brick to add
36713 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
36716 get: function(brick_id)
36718 // if (typeof(this.groups[brick_id]) == 'undefined') {
36721 // return this.groups[brick_id] ;
36723 if(this.groups.key(brick_id)) {
36724 return this.groups.key(brick_id);
36742 * @class Roo.bootstrap.Brick
36743 * @extends Roo.bootstrap.Component
36744 * Bootstrap Brick class
36747 * Create a new Brick
36748 * @param {Object} config The config object
36751 Roo.bootstrap.Brick = function(config){
36752 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
36758 * When a Brick is click
36759 * @param {Roo.bootstrap.Brick} this
36760 * @param {Roo.EventObject} e
36766 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
36769 * @cfg {String} title
36773 * @cfg {String} html
36777 * @cfg {String} bgimage
36781 * @cfg {String} cls
36785 * @cfg {String} href
36789 * @cfg {String} video
36793 * @cfg {Boolean} square
36797 getAutoCreate : function()
36799 var cls = 'roo-brick';
36801 if(this.href.length){
36802 cls += ' roo-brick-link';
36805 if(this.bgimage.length){
36806 cls += ' roo-brick-image';
36809 if(!this.html.length && !this.bgimage.length){
36810 cls += ' roo-brick-center-title';
36813 if(!this.html.length && this.bgimage.length){
36814 cls += ' roo-brick-bottom-title';
36818 cls += ' ' + this.cls;
36822 tag: (this.href.length) ? 'a' : 'div',
36827 cls: 'roo-brick-paragraph',
36833 if(this.href.length){
36834 cfg.href = this.href;
36837 var cn = cfg.cn[0].cn;
36839 if(this.title.length){
36842 cls: 'roo-brick-title',
36847 if(this.html.length){
36850 cls: 'roo-brick-text',
36857 if(this.bgimage.length){
36860 cls: 'roo-brick-image-view',
36868 initEvents: function()
36870 if(this.title.length || this.html.length){
36871 this.el.on('mouseenter' ,this.enter, this);
36872 this.el.on('mouseleave', this.leave, this);
36875 Roo.EventManager.onWindowResize(this.resize, this);
36877 if(this.bgimage.length){
36878 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
36879 this.imageEl.on('load', this.onImageLoad, this);
36886 onImageLoad : function()
36891 resize : function()
36893 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
36895 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
36897 if(this.bgimage.length){
36898 var image = this.el.select('.roo-brick-image-view', true).first();
36900 image.setWidth(paragraph.getWidth());
36903 image.setHeight(paragraph.getWidth());
36906 this.el.setHeight(image.getHeight());
36907 paragraph.setHeight(image.getHeight());
36913 enter: function(e, el)
36915 e.preventDefault();
36917 if(this.bgimage.length){
36918 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
36919 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
36923 leave: function(e, el)
36925 e.preventDefault();
36927 if(this.bgimage.length){
36928 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
36929 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
36944 * @class Roo.bootstrap.NumberField
36945 * @extends Roo.bootstrap.Input
36946 * Bootstrap NumberField class
36952 * Create a new NumberField
36953 * @param {Object} config The config object
36956 Roo.bootstrap.NumberField = function(config){
36957 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
36960 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
36963 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
36965 allowDecimals : true,
36967 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
36969 decimalSeparator : ".",
36971 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
36973 decimalPrecision : 2,
36975 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
36977 allowNegative : true,
36980 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
36984 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
36986 minValue : Number.NEGATIVE_INFINITY,
36988 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
36990 maxValue : Number.MAX_VALUE,
36992 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
36994 minText : "The minimum value for this field is {0}",
36996 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
36998 maxText : "The maximum value for this field is {0}",
37000 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
37001 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
37003 nanText : "{0} is not a valid number",
37005 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
37007 thousandsDelimiter : false,
37009 * @cfg {String} valueAlign alignment of value
37011 valueAlign : "left",
37013 getAutoCreate : function()
37015 var hiddenInput = {
37019 cls: 'hidden-number-input'
37023 hiddenInput.name = this.name;
37028 var cfg = Roo.bootstrap.NumberField.superclass.getAutoCreate.call(this);
37030 this.name = hiddenInput.name;
37032 if(cfg.cn.length > 0) {
37033 cfg.cn.push(hiddenInput);
37040 initEvents : function()
37042 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
37044 var allowed = "0123456789";
37046 if(this.allowDecimals){
37047 allowed += this.decimalSeparator;
37050 if(this.allowNegative){
37054 if(this.thousandsDelimiter) {
37058 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
37060 var keyPress = function(e){
37062 var k = e.getKey();
37064 var c = e.getCharCode();
37067 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
37068 allowed.indexOf(String.fromCharCode(c)) === -1
37074 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
37078 if(allowed.indexOf(String.fromCharCode(c)) === -1){
37083 this.el.on("keypress", keyPress, this);
37086 validateValue : function(value)
37089 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
37093 var num = this.parseValue(value);
37096 this.markInvalid(String.format(this.nanText, value));
37100 if(num < this.minValue){
37101 this.markInvalid(String.format(this.minText, this.minValue));
37105 if(num > this.maxValue){
37106 this.markInvalid(String.format(this.maxText, this.maxValue));
37113 getValue : function()
37115 var v = this.hiddenEl().getValue();
37117 return this.fixPrecision(this.parseValue(v));
37120 parseValue : function(value)
37122 if(this.thousandsDelimiter) {
37124 r = new RegExp(",", "g");
37125 value = value.replace(r, "");
37128 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
37129 return isNaN(value) ? '' : value;
37132 fixPrecision : function(value)
37134 if(this.thousandsDelimiter) {
37136 r = new RegExp(",", "g");
37137 value = value.replace(r, "");
37140 var nan = isNaN(value);
37142 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
37143 return nan ? '' : value;
37145 return parseFloat(value).toFixed(this.decimalPrecision);
37148 setValue : function(v)
37150 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
37156 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
37158 this.inputEl().dom.value = (v == '') ? '' :
37159 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
37161 if(!this.allowZero && v === '0') {
37162 this.hiddenEl().dom.value = '';
37163 this.inputEl().dom.value = '';
37170 decimalPrecisionFcn : function(v)
37172 return Math.floor(v);
37175 beforeBlur : function()
37177 var v = this.parseValue(this.getRawValue());
37179 if(v || v === 0 || v === ''){
37184 hiddenEl : function()
37186 return this.el.select('input.hidden-number-input',true).first();
37198 * @class Roo.bootstrap.DocumentSlider
37199 * @extends Roo.bootstrap.Component
37200 * Bootstrap DocumentSlider class
37203 * Create a new DocumentViewer
37204 * @param {Object} config The config object
37207 Roo.bootstrap.DocumentSlider = function(config){
37208 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
37215 * Fire after initEvent
37216 * @param {Roo.bootstrap.DocumentSlider} this
37221 * Fire after update
37222 * @param {Roo.bootstrap.DocumentSlider} this
37228 * @param {Roo.bootstrap.DocumentSlider} this
37234 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
37240 getAutoCreate : function()
37244 cls : 'roo-document-slider',
37248 cls : 'roo-document-slider-header',
37252 cls : 'roo-document-slider-header-title'
37258 cls : 'roo-document-slider-body',
37262 cls : 'roo-document-slider-prev',
37266 cls : 'fa fa-chevron-left'
37272 cls : 'roo-document-slider-thumb',
37276 cls : 'roo-document-slider-image'
37282 cls : 'roo-document-slider-next',
37286 cls : 'fa fa-chevron-right'
37298 initEvents : function()
37300 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
37301 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
37303 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
37304 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
37306 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
37307 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
37309 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
37310 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
37312 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
37313 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
37315 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
37316 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
37318 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
37319 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
37321 this.thumbEl.on('click', this.onClick, this);
37323 this.prevIndicator.on('click', this.prev, this);
37325 this.nextIndicator.on('click', this.next, this);
37329 initial : function()
37331 if(this.files.length){
37332 this.indicator = 1;
37336 this.fireEvent('initial', this);
37339 update : function()
37341 this.imageEl.attr('src', this.files[this.indicator - 1]);
37343 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
37345 this.prevIndicator.show();
37347 if(this.indicator == 1){
37348 this.prevIndicator.hide();
37351 this.nextIndicator.show();
37353 if(this.indicator == this.files.length){
37354 this.nextIndicator.hide();
37357 this.thumbEl.scrollTo('top');
37359 this.fireEvent('update', this);
37362 onClick : function(e)
37364 e.preventDefault();
37366 this.fireEvent('click', this);
37371 e.preventDefault();
37373 this.indicator = Math.max(1, this.indicator - 1);
37380 e.preventDefault();
37382 this.indicator = Math.min(this.files.length, this.indicator + 1);
37396 * @class Roo.bootstrap.RadioSet
37397 * @extends Roo.bootstrap.Input
37398 * Bootstrap RadioSet class
37399 * @cfg {String} indicatorpos (left|right) default left
37400 * @cfg {Boolean} inline (true|false) inline the element (default true)
37401 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
37403 * Create a new RadioSet
37404 * @param {Object} config The config object
37407 Roo.bootstrap.RadioSet = function(config){
37409 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
37413 Roo.bootstrap.RadioSet.register(this);
37418 * Fires when the element is checked or unchecked.
37419 * @param {Roo.bootstrap.RadioSet} this This radio
37420 * @param {Roo.bootstrap.Radio} item The checked item
37425 * Fires when the element is click.
37426 * @param {Roo.bootstrap.RadioSet} this This radio set
37427 * @param {Roo.bootstrap.Radio} item The checked item
37428 * @param {Roo.EventObject} e The event object
37435 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
37443 indicatorpos : 'left',
37445 getAutoCreate : function()
37449 cls : 'roo-radio-set-label',
37453 html : this.fieldLabel
37457 if (Roo.bootstrap.version == 3) {
37460 if(this.indicatorpos == 'left'){
37463 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
37464 tooltip : 'This field is required'
37469 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
37470 tooltip : 'This field is required'
37476 cls : 'roo-radio-set-items'
37479 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
37481 if (align === 'left' && this.fieldLabel.length) {
37484 cls : "roo-radio-set-right",
37490 if(this.labelWidth > 12){
37491 label.style = "width: " + this.labelWidth + 'px';
37494 if(this.labelWidth < 13 && this.labelmd == 0){
37495 this.labelmd = this.labelWidth;
37498 if(this.labellg > 0){
37499 label.cls += ' col-lg-' + this.labellg;
37500 items.cls += ' col-lg-' + (12 - this.labellg);
37503 if(this.labelmd > 0){
37504 label.cls += ' col-md-' + this.labelmd;
37505 items.cls += ' col-md-' + (12 - this.labelmd);
37508 if(this.labelsm > 0){
37509 label.cls += ' col-sm-' + this.labelsm;
37510 items.cls += ' col-sm-' + (12 - this.labelsm);
37513 if(this.labelxs > 0){
37514 label.cls += ' col-xs-' + this.labelxs;
37515 items.cls += ' col-xs-' + (12 - this.labelxs);
37521 cls : 'roo-radio-set',
37525 cls : 'roo-radio-set-input',
37528 value : this.value ? this.value : ''
37535 if(this.weight.length){
37536 cfg.cls += ' roo-radio-' + this.weight;
37540 cfg.cls += ' roo-radio-set-inline';
37544 ['xs','sm','md','lg'].map(function(size){
37545 if (settings[size]) {
37546 cfg.cls += ' col-' + size + '-' + settings[size];
37554 initEvents : function()
37556 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
37557 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
37559 if(!this.fieldLabel.length){
37560 this.labelEl.hide();
37563 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
37564 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
37566 this.indicator = this.indicatorEl();
37568 if(this.indicator){
37569 this.indicator.addClass('invisible');
37572 this.originalValue = this.getValue();
37576 inputEl: function ()
37578 return this.el.select('.roo-radio-set-input', true).first();
37581 getChildContainer : function()
37583 return this.itemsEl;
37586 register : function(item)
37588 this.radioes.push(item);
37592 validate : function()
37594 if(this.getVisibilityEl().hasClass('hidden')){
37600 Roo.each(this.radioes, function(i){
37609 if(this.allowBlank) {
37613 if(this.disabled || valid){
37618 this.markInvalid();
37623 markValid : function()
37625 if(this.labelEl.isVisible(true) && this.indicatorEl()){
37626 this.indicatorEl().removeClass('visible');
37627 this.indicatorEl().addClass('invisible');
37631 if (Roo.bootstrap.version == 3) {
37632 this.el.removeClass([this.invalidClass, this.validClass]);
37633 this.el.addClass(this.validClass);
37635 this.el.removeClass(['is-invalid','is-valid']);
37636 this.el.addClass(['is-valid']);
37638 this.fireEvent('valid', this);
37641 markInvalid : function(msg)
37643 if(this.allowBlank || this.disabled){
37647 if(this.labelEl.isVisible(true) && this.indicatorEl()){
37648 this.indicatorEl().removeClass('invisible');
37649 this.indicatorEl().addClass('visible');
37651 if (Roo.bootstrap.version == 3) {
37652 this.el.removeClass([this.invalidClass, this.validClass]);
37653 this.el.addClass(this.invalidClass);
37655 this.el.removeClass(['is-invalid','is-valid']);
37656 this.el.addClass(['is-invalid']);
37659 this.fireEvent('invalid', this, msg);
37663 setValue : function(v, suppressEvent)
37665 if(this.value === v){
37672 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
37675 Roo.each(this.radioes, function(i){
37677 i.el.removeClass('checked');
37680 Roo.each(this.radioes, function(i){
37682 if(i.value === v || i.value.toString() === v.toString()){
37684 i.el.addClass('checked');
37686 if(suppressEvent !== true){
37687 this.fireEvent('check', this, i);
37698 clearInvalid : function(){
37700 if(!this.el || this.preventMark){
37704 this.el.removeClass([this.invalidClass]);
37706 this.fireEvent('valid', this);
37711 Roo.apply(Roo.bootstrap.RadioSet, {
37715 register : function(set)
37717 this.groups[set.name] = set;
37720 get: function(name)
37722 if (typeof(this.groups[name]) == 'undefined') {
37726 return this.groups[name] ;
37732 * Ext JS Library 1.1.1
37733 * Copyright(c) 2006-2007, Ext JS, LLC.
37735 * Originally Released Under LGPL - original licence link has changed is not relivant.
37738 * <script type="text/javascript">
37743 * @class Roo.bootstrap.SplitBar
37744 * @extends Roo.util.Observable
37745 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
37749 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
37750 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
37751 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
37752 split.minSize = 100;
37753 split.maxSize = 600;
37754 split.animate = true;
37755 split.on('moved', splitterMoved);
37758 * Create a new SplitBar
37759 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
37760 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
37761 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
37762 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
37763 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
37764 position of the SplitBar).
37766 Roo.bootstrap.SplitBar = function(cfg){
37771 // dragElement : elm
37772 // resizingElement: el,
37774 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
37775 // placement : Roo.bootstrap.SplitBar.LEFT ,
37776 // existingProxy ???
37779 this.el = Roo.get(cfg.dragElement, true);
37780 this.el.dom.unselectable = "on";
37782 this.resizingEl = Roo.get(cfg.resizingElement, true);
37786 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
37787 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
37790 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
37793 * The minimum size of the resizing element. (Defaults to 0)
37799 * The maximum size of the resizing element. (Defaults to 2000)
37802 this.maxSize = 2000;
37805 * Whether to animate the transition to the new size
37808 this.animate = false;
37811 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
37814 this.useShim = false;
37819 if(!cfg.existingProxy){
37821 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
37823 this.proxy = Roo.get(cfg.existingProxy).dom;
37826 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
37829 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
37832 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
37835 this.dragSpecs = {};
37838 * @private The adapter to use to positon and resize elements
37840 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
37841 this.adapter.init(this);
37843 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
37845 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
37846 this.el.addClass("roo-splitbar-h");
37849 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
37850 this.el.addClass("roo-splitbar-v");
37856 * Fires when the splitter is moved (alias for {@link #event-moved})
37857 * @param {Roo.bootstrap.SplitBar} this
37858 * @param {Number} newSize the new width or height
37863 * Fires when the splitter is moved
37864 * @param {Roo.bootstrap.SplitBar} this
37865 * @param {Number} newSize the new width or height
37869 * @event beforeresize
37870 * Fires before the splitter is dragged
37871 * @param {Roo.bootstrap.SplitBar} this
37873 "beforeresize" : true,
37875 "beforeapply" : true
37878 Roo.util.Observable.call(this);
37881 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
37882 onStartProxyDrag : function(x, y){
37883 this.fireEvent("beforeresize", this);
37885 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
37887 o.enableDisplayMode("block");
37888 // all splitbars share the same overlay
37889 Roo.bootstrap.SplitBar.prototype.overlay = o;
37891 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
37892 this.overlay.show();
37893 Roo.get(this.proxy).setDisplayed("block");
37894 var size = this.adapter.getElementSize(this);
37895 this.activeMinSize = this.getMinimumSize();;
37896 this.activeMaxSize = this.getMaximumSize();;
37897 var c1 = size - this.activeMinSize;
37898 var c2 = Math.max(this.activeMaxSize - size, 0);
37899 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
37900 this.dd.resetConstraints();
37901 this.dd.setXConstraint(
37902 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
37903 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
37905 this.dd.setYConstraint(0, 0);
37907 this.dd.resetConstraints();
37908 this.dd.setXConstraint(0, 0);
37909 this.dd.setYConstraint(
37910 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
37911 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
37914 this.dragSpecs.startSize = size;
37915 this.dragSpecs.startPoint = [x, y];
37916 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
37920 * @private Called after the drag operation by the DDProxy
37922 onEndProxyDrag : function(e){
37923 Roo.get(this.proxy).setDisplayed(false);
37924 var endPoint = Roo.lib.Event.getXY(e);
37926 this.overlay.hide();
37929 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
37930 newSize = this.dragSpecs.startSize +
37931 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
37932 endPoint[0] - this.dragSpecs.startPoint[0] :
37933 this.dragSpecs.startPoint[0] - endPoint[0]
37936 newSize = this.dragSpecs.startSize +
37937 (this.placement == Roo.bootstrap.SplitBar.TOP ?
37938 endPoint[1] - this.dragSpecs.startPoint[1] :
37939 this.dragSpecs.startPoint[1] - endPoint[1]
37942 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
37943 if(newSize != this.dragSpecs.startSize){
37944 if(this.fireEvent('beforeapply', this, newSize) !== false){
37945 this.adapter.setElementSize(this, newSize);
37946 this.fireEvent("moved", this, newSize);
37947 this.fireEvent("resize", this, newSize);
37953 * Get the adapter this SplitBar uses
37954 * @return The adapter object
37956 getAdapter : function(){
37957 return this.adapter;
37961 * Set the adapter this SplitBar uses
37962 * @param {Object} adapter A SplitBar adapter object
37964 setAdapter : function(adapter){
37965 this.adapter = adapter;
37966 this.adapter.init(this);
37970 * Gets the minimum size for the resizing element
37971 * @return {Number} The minimum size
37973 getMinimumSize : function(){
37974 return this.minSize;
37978 * Sets the minimum size for the resizing element
37979 * @param {Number} minSize The minimum size
37981 setMinimumSize : function(minSize){
37982 this.minSize = minSize;
37986 * Gets the maximum size for the resizing element
37987 * @return {Number} The maximum size
37989 getMaximumSize : function(){
37990 return this.maxSize;
37994 * Sets the maximum size for the resizing element
37995 * @param {Number} maxSize The maximum size
37997 setMaximumSize : function(maxSize){
37998 this.maxSize = maxSize;
38002 * Sets the initialize size for the resizing element
38003 * @param {Number} size The initial size
38005 setCurrentSize : function(size){
38006 var oldAnimate = this.animate;
38007 this.animate = false;
38008 this.adapter.setElementSize(this, size);
38009 this.animate = oldAnimate;
38013 * Destroy this splitbar.
38014 * @param {Boolean} removeEl True to remove the element
38016 destroy : function(removeEl){
38018 this.shim.remove();
38021 this.proxy.parentNode.removeChild(this.proxy);
38029 * @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.
38031 Roo.bootstrap.SplitBar.createProxy = function(dir){
38032 var proxy = new Roo.Element(document.createElement("div"));
38033 proxy.unselectable();
38034 var cls = 'roo-splitbar-proxy';
38035 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
38036 document.body.appendChild(proxy.dom);
38041 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
38042 * Default Adapter. It assumes the splitter and resizing element are not positioned
38043 * elements and only gets/sets the width of the element. Generally used for table based layouts.
38045 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
38048 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
38049 // do nothing for now
38050 init : function(s){
38054 * Called before drag operations to get the current size of the resizing element.
38055 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
38057 getElementSize : function(s){
38058 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
38059 return s.resizingEl.getWidth();
38061 return s.resizingEl.getHeight();
38066 * Called after drag operations to set the size of the resizing element.
38067 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
38068 * @param {Number} newSize The new size to set
38069 * @param {Function} onComplete A function to be invoked when resizing is complete
38071 setElementSize : function(s, newSize, onComplete){
38072 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
38074 s.resizingEl.setWidth(newSize);
38076 onComplete(s, newSize);
38079 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
38084 s.resizingEl.setHeight(newSize);
38086 onComplete(s, newSize);
38089 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
38096 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
38097 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
38098 * Adapter that moves the splitter element to align with the resized sizing element.
38099 * Used with an absolute positioned SplitBar.
38100 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
38101 * document.body, make sure you assign an id to the body element.
38103 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
38104 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
38105 this.container = Roo.get(container);
38108 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
38109 init : function(s){
38110 this.basic.init(s);
38113 getElementSize : function(s){
38114 return this.basic.getElementSize(s);
38117 setElementSize : function(s, newSize, onComplete){
38118 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
38121 moveSplitter : function(s){
38122 var yes = Roo.bootstrap.SplitBar;
38123 switch(s.placement){
38125 s.el.setX(s.resizingEl.getRight());
38128 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
38131 s.el.setY(s.resizingEl.getBottom());
38134 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
38141 * Orientation constant - Create a vertical SplitBar
38145 Roo.bootstrap.SplitBar.VERTICAL = 1;
38148 * Orientation constant - Create a horizontal SplitBar
38152 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
38155 * Placement constant - The resizing element is to the left of the splitter element
38159 Roo.bootstrap.SplitBar.LEFT = 1;
38162 * Placement constant - The resizing element is to the right of the splitter element
38166 Roo.bootstrap.SplitBar.RIGHT = 2;
38169 * Placement constant - The resizing element is positioned above the splitter element
38173 Roo.bootstrap.SplitBar.TOP = 3;
38176 * Placement constant - The resizing element is positioned under splitter element
38180 Roo.bootstrap.SplitBar.BOTTOM = 4;
38181 Roo.namespace("Roo.bootstrap.layout");/*
38183 * Ext JS Library 1.1.1
38184 * Copyright(c) 2006-2007, Ext JS, LLC.
38186 * Originally Released Under LGPL - original licence link has changed is not relivant.
38189 * <script type="text/javascript">
38193 * @class Roo.bootstrap.layout.Manager
38194 * @extends Roo.bootstrap.Component
38195 * Base class for layout managers.
38197 Roo.bootstrap.layout.Manager = function(config)
38199 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
38205 /** false to disable window resize monitoring @type Boolean */
38206 this.monitorWindowResize = true;
38211 * Fires when a layout is performed.
38212 * @param {Roo.LayoutManager} this
38216 * @event regionresized
38217 * Fires when the user resizes a region.
38218 * @param {Roo.LayoutRegion} region The resized region
38219 * @param {Number} newSize The new size (width for east/west, height for north/south)
38221 "regionresized" : true,
38223 * @event regioncollapsed
38224 * Fires when a region is collapsed.
38225 * @param {Roo.LayoutRegion} region The collapsed region
38227 "regioncollapsed" : true,
38229 * @event regionexpanded
38230 * Fires when a region is expanded.
38231 * @param {Roo.LayoutRegion} region The expanded region
38233 "regionexpanded" : true
38235 this.updating = false;
38238 this.el = Roo.get(config.el);
38244 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
38249 monitorWindowResize : true,
38255 onRender : function(ct, position)
38258 this.el = Roo.get(ct);
38261 //this.fireEvent('render',this);
38265 initEvents: function()
38269 // ie scrollbar fix
38270 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
38271 document.body.scroll = "no";
38272 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
38273 this.el.position('relative');
38275 this.id = this.el.id;
38276 this.el.addClass("roo-layout-container");
38277 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
38278 if(this.el.dom != document.body ) {
38279 this.el.on('resize', this.layout,this);
38280 this.el.on('show', this.layout,this);
38286 * Returns true if this layout is currently being updated
38287 * @return {Boolean}
38289 isUpdating : function(){
38290 return this.updating;
38294 * Suspend the LayoutManager from doing auto-layouts while
38295 * making multiple add or remove calls
38297 beginUpdate : function(){
38298 this.updating = true;
38302 * Restore auto-layouts and optionally disable the manager from performing a layout
38303 * @param {Boolean} noLayout true to disable a layout update
38305 endUpdate : function(noLayout){
38306 this.updating = false;
38312 layout: function(){
38316 onRegionResized : function(region, newSize){
38317 this.fireEvent("regionresized", region, newSize);
38321 onRegionCollapsed : function(region){
38322 this.fireEvent("regioncollapsed", region);
38325 onRegionExpanded : function(region){
38326 this.fireEvent("regionexpanded", region);
38330 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
38331 * performs box-model adjustments.
38332 * @return {Object} The size as an object {width: (the width), height: (the height)}
38334 getViewSize : function()
38337 if(this.el.dom != document.body){
38338 size = this.el.getSize();
38340 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
38342 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
38343 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
38348 * Returns the Element this layout is bound to.
38349 * @return {Roo.Element}
38351 getEl : function(){
38356 * Returns the specified region.
38357 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
38358 * @return {Roo.LayoutRegion}
38360 getRegion : function(target){
38361 return this.regions[target.toLowerCase()];
38364 onWindowResize : function(){
38365 if(this.monitorWindowResize){
38372 * Ext JS Library 1.1.1
38373 * Copyright(c) 2006-2007, Ext JS, LLC.
38375 * Originally Released Under LGPL - original licence link has changed is not relivant.
38378 * <script type="text/javascript">
38381 * @class Roo.bootstrap.layout.Border
38382 * @extends Roo.bootstrap.layout.Manager
38384 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
38385 * please see: examples/bootstrap/nested.html<br><br>
38387 <b>The container the layout is rendered into can be either the body element or any other element.
38388 If it is not the body element, the container needs to either be an absolute positioned element,
38389 or you will need to add "position:relative" to the css of the container. You will also need to specify
38390 the container size if it is not the body element.</b>
38393 * Create a new Border
38394 * @param {Object} config Configuration options
38396 Roo.bootstrap.layout.Border = function(config){
38397 config = config || {};
38398 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
38402 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
38403 if(config[region]){
38404 config[region].region = region;
38405 this.addRegion(config[region]);
38411 Roo.bootstrap.layout.Border.regions = ["center", "north","south","east","west"];
38413 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
38415 parent : false, // this might point to a 'nest' or a ???
38418 * Creates and adds a new region if it doesn't already exist.
38419 * @param {String} target The target region key (north, south, east, west or center).
38420 * @param {Object} config The regions config object
38421 * @return {BorderLayoutRegion} The new region
38423 addRegion : function(config)
38425 if(!this.regions[config.region]){
38426 var r = this.factory(config);
38427 this.bindRegion(r);
38429 return this.regions[config.region];
38433 bindRegion : function(r){
38434 this.regions[r.config.region] = r;
38436 r.on("visibilitychange", this.layout, this);
38437 r.on("paneladded", this.layout, this);
38438 r.on("panelremoved", this.layout, this);
38439 r.on("invalidated", this.layout, this);
38440 r.on("resized", this.onRegionResized, this);
38441 r.on("collapsed", this.onRegionCollapsed, this);
38442 r.on("expanded", this.onRegionExpanded, this);
38446 * Performs a layout update.
38448 layout : function()
38450 if(this.updating) {
38454 // render all the rebions if they have not been done alreayd?
38455 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
38456 if(this.regions[region] && !this.regions[region].bodyEl){
38457 this.regions[region].onRender(this.el)
38461 var size = this.getViewSize();
38462 var w = size.width;
38463 var h = size.height;
38468 //var x = 0, y = 0;
38470 var rs = this.regions;
38471 var north = rs["north"];
38472 var south = rs["south"];
38473 var west = rs["west"];
38474 var east = rs["east"];
38475 var center = rs["center"];
38476 //if(this.hideOnLayout){ // not supported anymore
38477 //c.el.setStyle("display", "none");
38479 if(north && north.isVisible()){
38480 var b = north.getBox();
38481 var m = north.getMargins();
38482 b.width = w - (m.left+m.right);
38485 centerY = b.height + b.y + m.bottom;
38486 centerH -= centerY;
38487 north.updateBox(this.safeBox(b));
38489 if(south && south.isVisible()){
38490 var b = south.getBox();
38491 var m = south.getMargins();
38492 b.width = w - (m.left+m.right);
38494 var totalHeight = (b.height + m.top + m.bottom);
38495 b.y = h - totalHeight + m.top;
38496 centerH -= totalHeight;
38497 south.updateBox(this.safeBox(b));
38499 if(west && west.isVisible()){
38500 var b = west.getBox();
38501 var m = west.getMargins();
38502 b.height = centerH - (m.top+m.bottom);
38504 b.y = centerY + m.top;
38505 var totalWidth = (b.width + m.left + m.right);
38506 centerX += totalWidth;
38507 centerW -= totalWidth;
38508 west.updateBox(this.safeBox(b));
38510 if(east && east.isVisible()){
38511 var b = east.getBox();
38512 var m = east.getMargins();
38513 b.height = centerH - (m.top+m.bottom);
38514 var totalWidth = (b.width + m.left + m.right);
38515 b.x = w - totalWidth + m.left;
38516 b.y = centerY + m.top;
38517 centerW -= totalWidth;
38518 east.updateBox(this.safeBox(b));
38521 var m = center.getMargins();
38523 x: centerX + m.left,
38524 y: centerY + m.top,
38525 width: centerW - (m.left+m.right),
38526 height: centerH - (m.top+m.bottom)
38528 //if(this.hideOnLayout){
38529 //center.el.setStyle("display", "block");
38531 center.updateBox(this.safeBox(centerBox));
38534 this.fireEvent("layout", this);
38538 safeBox : function(box){
38539 box.width = Math.max(0, box.width);
38540 box.height = Math.max(0, box.height);
38545 * Adds a ContentPanel (or subclass) to this layout.
38546 * @param {String} target The target region key (north, south, east, west or center).
38547 * @param {Roo.ContentPanel} panel The panel to add
38548 * @return {Roo.ContentPanel} The added panel
38550 add : function(target, panel){
38552 target = target.toLowerCase();
38553 return this.regions[target].add(panel);
38557 * Remove a ContentPanel (or subclass) to this layout.
38558 * @param {String} target The target region key (north, south, east, west or center).
38559 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
38560 * @return {Roo.ContentPanel} The removed panel
38562 remove : function(target, panel){
38563 target = target.toLowerCase();
38564 return this.regions[target].remove(panel);
38568 * Searches all regions for a panel with the specified id
38569 * @param {String} panelId
38570 * @return {Roo.ContentPanel} The panel or null if it wasn't found
38572 findPanel : function(panelId){
38573 var rs = this.regions;
38574 for(var target in rs){
38575 if(typeof rs[target] != "function"){
38576 var p = rs[target].getPanel(panelId);
38586 * Searches all regions for a panel with the specified id and activates (shows) it.
38587 * @param {String/ContentPanel} panelId The panels id or the panel itself
38588 * @return {Roo.ContentPanel} The shown panel or null
38590 showPanel : function(panelId) {
38591 var rs = this.regions;
38592 for(var target in rs){
38593 var r = rs[target];
38594 if(typeof r != "function"){
38595 if(r.hasPanel(panelId)){
38596 return r.showPanel(panelId);
38604 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
38605 * @param {Roo.state.Provider} provider (optional) An alternate state provider
38608 restoreState : function(provider){
38610 provider = Roo.state.Manager;
38612 var sm = new Roo.LayoutStateManager();
38613 sm.init(this, provider);
38619 * Adds a xtype elements to the layout.
38623 xtype : 'ContentPanel',
38630 xtype : 'NestedLayoutPanel',
38636 items : [ ... list of content panels or nested layout panels.. ]
38640 * @param {Object} cfg Xtype definition of item to add.
38642 addxtype : function(cfg)
38644 // basically accepts a pannel...
38645 // can accept a layout region..!?!?
38646 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
38649 // theory? children can only be panels??
38651 //if (!cfg.xtype.match(/Panel$/)) {
38656 if (typeof(cfg.region) == 'undefined') {
38657 Roo.log("Failed to add Panel, region was not set");
38661 var region = cfg.region;
38667 xitems = cfg.items;
38672 if ( region == 'center') {
38673 Roo.log("Center: " + cfg.title);
38679 case 'Content': // ContentPanel (el, cfg)
38680 case 'Scroll': // ContentPanel (el, cfg)
38682 cfg.autoCreate = cfg.autoCreate || true;
38683 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
38685 // var el = this.el.createChild();
38686 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
38689 this.add(region, ret);
38693 case 'TreePanel': // our new panel!
38694 cfg.el = this.el.createChild();
38695 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
38696 this.add(region, ret);
38701 // create a new Layout (which is a Border Layout...
38703 var clayout = cfg.layout;
38704 clayout.el = this.el.createChild();
38705 clayout.items = clayout.items || [];
38709 // replace this exitems with the clayout ones..
38710 xitems = clayout.items;
38712 // force background off if it's in center...
38713 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
38714 cfg.background = false;
38716 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
38719 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
38720 //console.log('adding nested layout panel ' + cfg.toSource());
38721 this.add(region, ret);
38722 nb = {}; /// find first...
38727 // needs grid and region
38729 //var el = this.getRegion(region).el.createChild();
38731 *var el = this.el.createChild();
38732 // create the grid first...
38733 cfg.grid.container = el;
38734 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
38737 if (region == 'center' && this.active ) {
38738 cfg.background = false;
38741 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
38743 this.add(region, ret);
38745 if (cfg.background) {
38746 // render grid on panel activation (if panel background)
38747 ret.on('activate', function(gp) {
38748 if (!gp.grid.rendered) {
38749 // gp.grid.render(el);
38753 // cfg.grid.render(el);
38759 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
38760 // it was the old xcomponent building that caused this before.
38761 // espeically if border is the top element in the tree.
38771 if (typeof(Roo[cfg.xtype]) != 'undefined') {
38773 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
38774 this.add(region, ret);
38778 throw "Can not add '" + cfg.xtype + "' to Border";
38784 this.beginUpdate();
38788 Roo.each(xitems, function(i) {
38789 region = nb && i.region ? i.region : false;
38791 var add = ret.addxtype(i);
38794 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
38795 if (!i.background) {
38796 abn[region] = nb[region] ;
38803 // make the last non-background panel active..
38804 //if (nb) { Roo.log(abn); }
38807 for(var r in abn) {
38808 region = this.getRegion(r);
38810 // tried using nb[r], but it does not work..
38812 region.showPanel(abn[r]);
38823 factory : function(cfg)
38826 var validRegions = Roo.bootstrap.layout.Border.regions;
38828 var target = cfg.region;
38831 var r = Roo.bootstrap.layout;
38835 return new r.North(cfg);
38837 return new r.South(cfg);
38839 return new r.East(cfg);
38841 return new r.West(cfg);
38843 return new r.Center(cfg);
38845 throw 'Layout region "'+target+'" not supported.';
38852 * Ext JS Library 1.1.1
38853 * Copyright(c) 2006-2007, Ext JS, LLC.
38855 * Originally Released Under LGPL - original licence link has changed is not relivant.
38858 * <script type="text/javascript">
38862 * @class Roo.bootstrap.layout.Basic
38863 * @extends Roo.util.Observable
38864 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
38865 * and does not have a titlebar, tabs or any other features. All it does is size and position
38866 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
38867 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
38868 * @cfg {string} region the region that it inhabits..
38869 * @cfg {bool} skipConfig skip config?
38873 Roo.bootstrap.layout.Basic = function(config){
38875 this.mgr = config.mgr;
38877 this.position = config.region;
38879 var skipConfig = config.skipConfig;
38883 * @scope Roo.BasicLayoutRegion
38887 * @event beforeremove
38888 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
38889 * @param {Roo.LayoutRegion} this
38890 * @param {Roo.ContentPanel} panel The panel
38891 * @param {Object} e The cancel event object
38893 "beforeremove" : true,
38895 * @event invalidated
38896 * Fires when the layout for this region is changed.
38897 * @param {Roo.LayoutRegion} this
38899 "invalidated" : true,
38901 * @event visibilitychange
38902 * Fires when this region is shown or hidden
38903 * @param {Roo.LayoutRegion} this
38904 * @param {Boolean} visibility true or false
38906 "visibilitychange" : true,
38908 * @event paneladded
38909 * Fires when a panel is added.
38910 * @param {Roo.LayoutRegion} this
38911 * @param {Roo.ContentPanel} panel The panel
38913 "paneladded" : true,
38915 * @event panelremoved
38916 * Fires when a panel is removed.
38917 * @param {Roo.LayoutRegion} this
38918 * @param {Roo.ContentPanel} panel The panel
38920 "panelremoved" : true,
38922 * @event beforecollapse
38923 * Fires when this region before collapse.
38924 * @param {Roo.LayoutRegion} this
38926 "beforecollapse" : true,
38929 * Fires when this region is collapsed.
38930 * @param {Roo.LayoutRegion} this
38932 "collapsed" : true,
38935 * Fires when this region is expanded.
38936 * @param {Roo.LayoutRegion} this
38941 * Fires when this region is slid into view.
38942 * @param {Roo.LayoutRegion} this
38944 "slideshow" : true,
38947 * Fires when this region slides out of view.
38948 * @param {Roo.LayoutRegion} this
38950 "slidehide" : true,
38952 * @event panelactivated
38953 * Fires when a panel is activated.
38954 * @param {Roo.LayoutRegion} this
38955 * @param {Roo.ContentPanel} panel The activated panel
38957 "panelactivated" : true,
38960 * Fires when the user resizes this region.
38961 * @param {Roo.LayoutRegion} this
38962 * @param {Number} newSize The new size (width for east/west, height for north/south)
38966 /** A collection of panels in this region. @type Roo.util.MixedCollection */
38967 this.panels = new Roo.util.MixedCollection();
38968 this.panels.getKey = this.getPanelId.createDelegate(this);
38970 this.activePanel = null;
38971 // ensure listeners are added...
38973 if (config.listeners || config.events) {
38974 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
38975 listeners : config.listeners || {},
38976 events : config.events || {}
38980 if(skipConfig !== true){
38981 this.applyConfig(config);
38985 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
38987 getPanelId : function(p){
38991 applyConfig : function(config){
38992 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
38993 this.config = config;
38998 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
38999 * the width, for horizontal (north, south) the height.
39000 * @param {Number} newSize The new width or height
39002 resizeTo : function(newSize){
39003 var el = this.el ? this.el :
39004 (this.activePanel ? this.activePanel.getEl() : null);
39006 switch(this.position){
39009 el.setWidth(newSize);
39010 this.fireEvent("resized", this, newSize);
39014 el.setHeight(newSize);
39015 this.fireEvent("resized", this, newSize);
39021 getBox : function(){
39022 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
39025 getMargins : function(){
39026 return this.margins;
39029 updateBox : function(box){
39031 var el = this.activePanel.getEl();
39032 el.dom.style.left = box.x + "px";
39033 el.dom.style.top = box.y + "px";
39034 this.activePanel.setSize(box.width, box.height);
39038 * Returns the container element for this region.
39039 * @return {Roo.Element}
39041 getEl : function(){
39042 return this.activePanel;
39046 * Returns true if this region is currently visible.
39047 * @return {Boolean}
39049 isVisible : function(){
39050 return this.activePanel ? true : false;
39053 setActivePanel : function(panel){
39054 panel = this.getPanel(panel);
39055 if(this.activePanel && this.activePanel != panel){
39056 this.activePanel.setActiveState(false);
39057 this.activePanel.getEl().setLeftTop(-10000,-10000);
39059 this.activePanel = panel;
39060 panel.setActiveState(true);
39062 panel.setSize(this.box.width, this.box.height);
39064 this.fireEvent("panelactivated", this, panel);
39065 this.fireEvent("invalidated");
39069 * Show the specified panel.
39070 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
39071 * @return {Roo.ContentPanel} The shown panel or null
39073 showPanel : function(panel){
39074 panel = this.getPanel(panel);
39076 this.setActivePanel(panel);
39082 * Get the active panel for this region.
39083 * @return {Roo.ContentPanel} The active panel or null
39085 getActivePanel : function(){
39086 return this.activePanel;
39090 * Add the passed ContentPanel(s)
39091 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
39092 * @return {Roo.ContentPanel} The panel added (if only one was added)
39094 add : function(panel){
39095 if(arguments.length > 1){
39096 for(var i = 0, len = arguments.length; i < len; i++) {
39097 this.add(arguments[i]);
39101 if(this.hasPanel(panel)){
39102 this.showPanel(panel);
39105 var el = panel.getEl();
39106 if(el.dom.parentNode != this.mgr.el.dom){
39107 this.mgr.el.dom.appendChild(el.dom);
39109 if(panel.setRegion){
39110 panel.setRegion(this);
39112 this.panels.add(panel);
39113 el.setStyle("position", "absolute");
39114 if(!panel.background){
39115 this.setActivePanel(panel);
39116 if(this.config.initialSize && this.panels.getCount()==1){
39117 this.resizeTo(this.config.initialSize);
39120 this.fireEvent("paneladded", this, panel);
39125 * Returns true if the panel is in this region.
39126 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
39127 * @return {Boolean}
39129 hasPanel : function(panel){
39130 if(typeof panel == "object"){ // must be panel obj
39131 panel = panel.getId();
39133 return this.getPanel(panel) ? true : false;
39137 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
39138 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
39139 * @param {Boolean} preservePanel Overrides the config preservePanel option
39140 * @return {Roo.ContentPanel} The panel that was removed
39142 remove : function(panel, preservePanel){
39143 panel = this.getPanel(panel);
39148 this.fireEvent("beforeremove", this, panel, e);
39149 if(e.cancel === true){
39152 var panelId = panel.getId();
39153 this.panels.removeKey(panelId);
39158 * Returns the panel specified or null if it's not in this region.
39159 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
39160 * @return {Roo.ContentPanel}
39162 getPanel : function(id){
39163 if(typeof id == "object"){ // must be panel obj
39166 return this.panels.get(id);
39170 * Returns this regions position (north/south/east/west/center).
39173 getPosition: function(){
39174 return this.position;
39178 * Ext JS Library 1.1.1
39179 * Copyright(c) 2006-2007, Ext JS, LLC.
39181 * Originally Released Under LGPL - original licence link has changed is not relivant.
39184 * <script type="text/javascript">
39188 * @class Roo.bootstrap.layout.Region
39189 * @extends Roo.bootstrap.layout.Basic
39190 * This class represents a region in a layout manager.
39192 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
39193 * @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})
39194 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
39195 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
39196 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
39197 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
39198 * @cfg {String} title The title for the region (overrides panel titles)
39199 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
39200 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
39201 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
39202 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
39203 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
39204 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
39205 * the space available, similar to FireFox 1.5 tabs (defaults to false)
39206 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
39207 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
39208 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
39210 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
39211 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
39212 * @cfg {Boolean} disableTabTips True to disable tab tooltips
39213 * @cfg {Number} width For East/West panels
39214 * @cfg {Number} height For North/South panels
39215 * @cfg {Boolean} split To show the splitter
39216 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
39218 * @cfg {string} cls Extra CSS classes to add to region
39220 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
39221 * @cfg {string} region the region that it inhabits..
39224 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
39225 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
39227 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
39228 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
39229 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
39231 Roo.bootstrap.layout.Region = function(config)
39233 this.applyConfig(config);
39235 var mgr = config.mgr;
39236 var pos = config.region;
39237 config.skipConfig = true;
39238 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
39241 this.onRender(mgr.el);
39244 this.visible = true;
39245 this.collapsed = false;
39246 this.unrendered_panels = [];
39249 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
39251 position: '', // set by wrapper (eg. north/south etc..)
39252 unrendered_panels : null, // unrendered panels.
39254 tabPosition : false,
39256 mgr: false, // points to 'Border'
39259 createBody : function(){
39260 /** This region's body element
39261 * @type Roo.Element */
39262 this.bodyEl = this.el.createChild({
39264 cls: "roo-layout-panel-body tab-content" // bootstrap added...
39268 onRender: function(ctr, pos)
39270 var dh = Roo.DomHelper;
39271 /** This region's container element
39272 * @type Roo.Element */
39273 this.el = dh.append(ctr.dom, {
39275 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
39277 /** This region's title element
39278 * @type Roo.Element */
39280 this.titleEl = dh.append(this.el.dom, {
39282 unselectable: "on",
39283 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
39285 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
39286 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
39290 this.titleEl.enableDisplayMode();
39291 /** This region's title text element
39292 * @type HTMLElement */
39293 this.titleTextEl = this.titleEl.dom.firstChild;
39294 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
39296 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
39297 this.closeBtn.enableDisplayMode();
39298 this.closeBtn.on("click", this.closeClicked, this);
39299 this.closeBtn.hide();
39301 this.createBody(this.config);
39302 if(this.config.hideWhenEmpty){
39304 this.on("paneladded", this.validateVisibility, this);
39305 this.on("panelremoved", this.validateVisibility, this);
39307 if(this.autoScroll){
39308 this.bodyEl.setStyle("overflow", "auto");
39310 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
39312 //if(c.titlebar !== false){
39313 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
39314 this.titleEl.hide();
39316 this.titleEl.show();
39317 if(this.config.title){
39318 this.titleTextEl.innerHTML = this.config.title;
39322 if(this.config.collapsed){
39323 this.collapse(true);
39325 if(this.config.hidden){
39329 if (this.unrendered_panels && this.unrendered_panels.length) {
39330 for (var i =0;i< this.unrendered_panels.length; i++) {
39331 this.add(this.unrendered_panels[i]);
39333 this.unrendered_panels = null;
39339 applyConfig : function(c)
39342 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
39343 var dh = Roo.DomHelper;
39344 if(c.titlebar !== false){
39345 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
39346 this.collapseBtn.on("click", this.collapse, this);
39347 this.collapseBtn.enableDisplayMode();
39349 if(c.showPin === true || this.showPin){
39350 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
39351 this.stickBtn.enableDisplayMode();
39352 this.stickBtn.on("click", this.expand, this);
39353 this.stickBtn.hide();
39358 /** This region's collapsed element
39359 * @type Roo.Element */
39362 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
39363 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
39366 if(c.floatable !== false){
39367 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
39368 this.collapsedEl.on("click", this.collapseClick, this);
39371 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
39372 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
39373 id: "message", unselectable: "on", style:{"float":"left"}});
39374 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
39376 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
39377 this.expandBtn.on("click", this.expand, this);
39381 if(this.collapseBtn){
39382 this.collapseBtn.setVisible(c.collapsible == true);
39385 this.cmargins = c.cmargins || this.cmargins ||
39386 (this.position == "west" || this.position == "east" ?
39387 {top: 0, left: 2, right:2, bottom: 0} :
39388 {top: 2, left: 0, right:0, bottom: 2});
39390 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
39393 this.tabPosition = [ 'top','bottom', 'west'].indexOf(c.tabPosition) > -1 ? c.tabPosition : "top";
39395 this.autoScroll = c.autoScroll || false;
39400 this.duration = c.duration || .30;
39401 this.slideDuration = c.slideDuration || .45;
39406 * Returns true if this region is currently visible.
39407 * @return {Boolean}
39409 isVisible : function(){
39410 return this.visible;
39414 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
39415 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
39417 //setCollapsedTitle : function(title){
39418 // title = title || " ";
39419 // if(this.collapsedTitleTextEl){
39420 // this.collapsedTitleTextEl.innerHTML = title;
39424 getBox : function(){
39426 // if(!this.collapsed){
39427 b = this.el.getBox(false, true);
39429 // b = this.collapsedEl.getBox(false, true);
39434 getMargins : function(){
39435 return this.margins;
39436 //return this.collapsed ? this.cmargins : this.margins;
39439 highlight : function(){
39440 this.el.addClass("x-layout-panel-dragover");
39443 unhighlight : function(){
39444 this.el.removeClass("x-layout-panel-dragover");
39447 updateBox : function(box)
39449 if (!this.bodyEl) {
39450 return; // not rendered yet..
39454 if(!this.collapsed){
39455 this.el.dom.style.left = box.x + "px";
39456 this.el.dom.style.top = box.y + "px";
39457 this.updateBody(box.width, box.height);
39459 this.collapsedEl.dom.style.left = box.x + "px";
39460 this.collapsedEl.dom.style.top = box.y + "px";
39461 this.collapsedEl.setSize(box.width, box.height);
39464 this.tabs.autoSizeTabs();
39468 updateBody : function(w, h)
39471 this.el.setWidth(w);
39472 w -= this.el.getBorderWidth("rl");
39473 if(this.config.adjustments){
39474 w += this.config.adjustments[0];
39477 if(h !== null && h > 0){
39478 this.el.setHeight(h);
39479 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
39480 h -= this.el.getBorderWidth("tb");
39481 if(this.config.adjustments){
39482 h += this.config.adjustments[1];
39484 this.bodyEl.setHeight(h);
39486 h = this.tabs.syncHeight(h);
39489 if(this.panelSize){
39490 w = w !== null ? w : this.panelSize.width;
39491 h = h !== null ? h : this.panelSize.height;
39493 if(this.activePanel){
39494 var el = this.activePanel.getEl();
39495 w = w !== null ? w : el.getWidth();
39496 h = h !== null ? h : el.getHeight();
39497 this.panelSize = {width: w, height: h};
39498 this.activePanel.setSize(w, h);
39500 if(Roo.isIE && this.tabs){
39501 this.tabs.el.repaint();
39506 * Returns the container element for this region.
39507 * @return {Roo.Element}
39509 getEl : function(){
39514 * Hides this region.
39517 //if(!this.collapsed){
39518 this.el.dom.style.left = "-2000px";
39521 // this.collapsedEl.dom.style.left = "-2000px";
39522 // this.collapsedEl.hide();
39524 this.visible = false;
39525 this.fireEvent("visibilitychange", this, false);
39529 * Shows this region if it was previously hidden.
39532 //if(!this.collapsed){
39535 // this.collapsedEl.show();
39537 this.visible = true;
39538 this.fireEvent("visibilitychange", this, true);
39541 closeClicked : function(){
39542 if(this.activePanel){
39543 this.remove(this.activePanel);
39547 collapseClick : function(e){
39549 e.stopPropagation();
39552 e.stopPropagation();
39558 * Collapses this region.
39559 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
39562 collapse : function(skipAnim, skipCheck = false){
39563 if(this.collapsed) {
39567 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
39569 this.collapsed = true;
39571 this.split.el.hide();
39573 if(this.config.animate && skipAnim !== true){
39574 this.fireEvent("invalidated", this);
39575 this.animateCollapse();
39577 this.el.setLocation(-20000,-20000);
39579 this.collapsedEl.show();
39580 this.fireEvent("collapsed", this);
39581 this.fireEvent("invalidated", this);
39587 animateCollapse : function(){
39592 * Expands this region if it was previously collapsed.
39593 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
39594 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
39597 expand : function(e, skipAnim){
39599 e.stopPropagation();
39601 if(!this.collapsed || this.el.hasActiveFx()) {
39605 this.afterSlideIn();
39608 this.collapsed = false;
39609 if(this.config.animate && skipAnim !== true){
39610 this.animateExpand();
39614 this.split.el.show();
39616 this.collapsedEl.setLocation(-2000,-2000);
39617 this.collapsedEl.hide();
39618 this.fireEvent("invalidated", this);
39619 this.fireEvent("expanded", this);
39623 animateExpand : function(){
39627 initTabs : function()
39629 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
39631 var ts = new Roo.bootstrap.panel.Tabs({
39632 el: this.bodyEl.dom,
39634 tabPosition: this.tabPosition ? this.tabPosition : 'top',
39635 disableTooltips: this.config.disableTabTips,
39636 toolbar : this.config.toolbar
39639 if(this.config.hideTabs){
39640 ts.stripWrap.setDisplayed(false);
39643 ts.resizeTabs = this.config.resizeTabs === true;
39644 ts.minTabWidth = this.config.minTabWidth || 40;
39645 ts.maxTabWidth = this.config.maxTabWidth || 250;
39646 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
39647 ts.monitorResize = false;
39648 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
39649 ts.bodyEl.addClass('roo-layout-tabs-body');
39650 this.panels.each(this.initPanelAsTab, this);
39653 initPanelAsTab : function(panel){
39654 var ti = this.tabs.addTab(
39658 this.config.closeOnTab && panel.isClosable(),
39661 if(panel.tabTip !== undefined){
39662 ti.setTooltip(panel.tabTip);
39664 ti.on("activate", function(){
39665 this.setActivePanel(panel);
39668 if(this.config.closeOnTab){
39669 ti.on("beforeclose", function(t, e){
39671 this.remove(panel);
39675 panel.tabItem = ti;
39680 updatePanelTitle : function(panel, title)
39682 if(this.activePanel == panel){
39683 this.updateTitle(title);
39686 var ti = this.tabs.getTab(panel.getEl().id);
39688 if(panel.tabTip !== undefined){
39689 ti.setTooltip(panel.tabTip);
39694 updateTitle : function(title){
39695 if(this.titleTextEl && !this.config.title){
39696 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
39700 setActivePanel : function(panel)
39702 panel = this.getPanel(panel);
39703 if(this.activePanel && this.activePanel != panel){
39704 if(this.activePanel.setActiveState(false) === false){
39708 this.activePanel = panel;
39709 panel.setActiveState(true);
39710 if(this.panelSize){
39711 panel.setSize(this.panelSize.width, this.panelSize.height);
39714 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
39716 this.updateTitle(panel.getTitle());
39718 this.fireEvent("invalidated", this);
39720 this.fireEvent("panelactivated", this, panel);
39724 * Shows the specified panel.
39725 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
39726 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
39728 showPanel : function(panel)
39730 panel = this.getPanel(panel);
39733 var tab = this.tabs.getTab(panel.getEl().id);
39734 if(tab.isHidden()){
39735 this.tabs.unhideTab(tab.id);
39739 this.setActivePanel(panel);
39746 * Get the active panel for this region.
39747 * @return {Roo.ContentPanel} The active panel or null
39749 getActivePanel : function(){
39750 return this.activePanel;
39753 validateVisibility : function(){
39754 if(this.panels.getCount() < 1){
39755 this.updateTitle(" ");
39756 this.closeBtn.hide();
39759 if(!this.isVisible()){
39766 * Adds the passed ContentPanel(s) to this region.
39767 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
39768 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
39770 add : function(panel)
39772 if(arguments.length > 1){
39773 for(var i = 0, len = arguments.length; i < len; i++) {
39774 this.add(arguments[i]);
39779 // if we have not been rendered yet, then we can not really do much of this..
39780 if (!this.bodyEl) {
39781 this.unrendered_panels.push(panel);
39788 if(this.hasPanel(panel)){
39789 this.showPanel(panel);
39792 panel.setRegion(this);
39793 this.panels.add(panel);
39794 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
39795 // sinle panel - no tab...?? would it not be better to render it with the tabs,
39796 // and hide them... ???
39797 this.bodyEl.dom.appendChild(panel.getEl().dom);
39798 if(panel.background !== true){
39799 this.setActivePanel(panel);
39801 this.fireEvent("paneladded", this, panel);
39808 this.initPanelAsTab(panel);
39812 if(panel.background !== true){
39813 this.tabs.activate(panel.getEl().id);
39815 this.fireEvent("paneladded", this, panel);
39820 * Hides the tab for the specified panel.
39821 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
39823 hidePanel : function(panel){
39824 if(this.tabs && (panel = this.getPanel(panel))){
39825 this.tabs.hideTab(panel.getEl().id);
39830 * Unhides the tab for a previously hidden panel.
39831 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
39833 unhidePanel : function(panel){
39834 if(this.tabs && (panel = this.getPanel(panel))){
39835 this.tabs.unhideTab(panel.getEl().id);
39839 clearPanels : function(){
39840 while(this.panels.getCount() > 0){
39841 this.remove(this.panels.first());
39846 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
39847 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
39848 * @param {Boolean} preservePanel Overrides the config preservePanel option
39849 * @return {Roo.ContentPanel} The panel that was removed
39851 remove : function(panel, preservePanel)
39853 panel = this.getPanel(panel);
39858 this.fireEvent("beforeremove", this, panel, e);
39859 if(e.cancel === true){
39862 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
39863 var panelId = panel.getId();
39864 this.panels.removeKey(panelId);
39866 document.body.appendChild(panel.getEl().dom);
39869 this.tabs.removeTab(panel.getEl().id);
39870 }else if (!preservePanel){
39871 this.bodyEl.dom.removeChild(panel.getEl().dom);
39873 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
39874 var p = this.panels.first();
39875 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
39876 tempEl.appendChild(p.getEl().dom);
39877 this.bodyEl.update("");
39878 this.bodyEl.dom.appendChild(p.getEl().dom);
39880 this.updateTitle(p.getTitle());
39882 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
39883 this.setActivePanel(p);
39885 panel.setRegion(null);
39886 if(this.activePanel == panel){
39887 this.activePanel = null;
39889 if(this.config.autoDestroy !== false && preservePanel !== true){
39890 try{panel.destroy();}catch(e){}
39892 this.fireEvent("panelremoved", this, panel);
39897 * Returns the TabPanel component used by this region
39898 * @return {Roo.TabPanel}
39900 getTabs : function(){
39904 createTool : function(parentEl, className){
39905 var btn = Roo.DomHelper.append(parentEl, {
39907 cls: "x-layout-tools-button",
39910 cls: "roo-layout-tools-button-inner " + className,
39914 btn.addClassOnOver("roo-layout-tools-button-over");
39919 * Ext JS Library 1.1.1
39920 * Copyright(c) 2006-2007, Ext JS, LLC.
39922 * Originally Released Under LGPL - original licence link has changed is not relivant.
39925 * <script type="text/javascript">
39931 * @class Roo.SplitLayoutRegion
39932 * @extends Roo.LayoutRegion
39933 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
39935 Roo.bootstrap.layout.Split = function(config){
39936 this.cursor = config.cursor;
39937 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
39940 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
39942 splitTip : "Drag to resize.",
39943 collapsibleSplitTip : "Drag to resize. Double click to hide.",
39944 useSplitTips : false,
39946 applyConfig : function(config){
39947 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
39950 onRender : function(ctr,pos) {
39952 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
39953 if(!this.config.split){
39958 var splitEl = Roo.DomHelper.append(ctr.dom, {
39960 id: this.el.id + "-split",
39961 cls: "roo-layout-split roo-layout-split-"+this.position,
39964 /** The SplitBar for this region
39965 * @type Roo.SplitBar */
39966 // does not exist yet...
39967 Roo.log([this.position, this.orientation]);
39969 this.split = new Roo.bootstrap.SplitBar({
39970 dragElement : splitEl,
39971 resizingElement: this.el,
39972 orientation : this.orientation
39975 this.split.on("moved", this.onSplitMove, this);
39976 this.split.useShim = this.config.useShim === true;
39977 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
39978 if(this.useSplitTips){
39979 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
39981 //if(config.collapsible){
39982 // this.split.el.on("dblclick", this.collapse, this);
39985 if(typeof this.config.minSize != "undefined"){
39986 this.split.minSize = this.config.minSize;
39988 if(typeof this.config.maxSize != "undefined"){
39989 this.split.maxSize = this.config.maxSize;
39991 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
39992 this.hideSplitter();
39997 getHMaxSize : function(){
39998 var cmax = this.config.maxSize || 10000;
39999 var center = this.mgr.getRegion("center");
40000 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
40003 getVMaxSize : function(){
40004 var cmax = this.config.maxSize || 10000;
40005 var center = this.mgr.getRegion("center");
40006 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
40009 onSplitMove : function(split, newSize){
40010 this.fireEvent("resized", this, newSize);
40014 * Returns the {@link Roo.SplitBar} for this region.
40015 * @return {Roo.SplitBar}
40017 getSplitBar : function(){
40022 this.hideSplitter();
40023 Roo.bootstrap.layout.Split.superclass.hide.call(this);
40026 hideSplitter : function(){
40028 this.split.el.setLocation(-2000,-2000);
40029 this.split.el.hide();
40035 this.split.el.show();
40037 Roo.bootstrap.layout.Split.superclass.show.call(this);
40040 beforeSlide: function(){
40041 if(Roo.isGecko){// firefox overflow auto bug workaround
40042 this.bodyEl.clip();
40044 this.tabs.bodyEl.clip();
40046 if(this.activePanel){
40047 this.activePanel.getEl().clip();
40049 if(this.activePanel.beforeSlide){
40050 this.activePanel.beforeSlide();
40056 afterSlide : function(){
40057 if(Roo.isGecko){// firefox overflow auto bug workaround
40058 this.bodyEl.unclip();
40060 this.tabs.bodyEl.unclip();
40062 if(this.activePanel){
40063 this.activePanel.getEl().unclip();
40064 if(this.activePanel.afterSlide){
40065 this.activePanel.afterSlide();
40071 initAutoHide : function(){
40072 if(this.autoHide !== false){
40073 if(!this.autoHideHd){
40074 var st = new Roo.util.DelayedTask(this.slideIn, this);
40075 this.autoHideHd = {
40076 "mouseout": function(e){
40077 if(!e.within(this.el, true)){
40081 "mouseover" : function(e){
40087 this.el.on(this.autoHideHd);
40091 clearAutoHide : function(){
40092 if(this.autoHide !== false){
40093 this.el.un("mouseout", this.autoHideHd.mouseout);
40094 this.el.un("mouseover", this.autoHideHd.mouseover);
40098 clearMonitor : function(){
40099 Roo.get(document).un("click", this.slideInIf, this);
40102 // these names are backwards but not changed for compat
40103 slideOut : function(){
40104 if(this.isSlid || this.el.hasActiveFx()){
40107 this.isSlid = true;
40108 if(this.collapseBtn){
40109 this.collapseBtn.hide();
40111 this.closeBtnState = this.closeBtn.getStyle('display');
40112 this.closeBtn.hide();
40114 this.stickBtn.show();
40117 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
40118 this.beforeSlide();
40119 this.el.setStyle("z-index", 10001);
40120 this.el.slideIn(this.getSlideAnchor(), {
40121 callback: function(){
40123 this.initAutoHide();
40124 Roo.get(document).on("click", this.slideInIf, this);
40125 this.fireEvent("slideshow", this);
40132 afterSlideIn : function(){
40133 this.clearAutoHide();
40134 this.isSlid = false;
40135 this.clearMonitor();
40136 this.el.setStyle("z-index", "");
40137 if(this.collapseBtn){
40138 this.collapseBtn.show();
40140 this.closeBtn.setStyle('display', this.closeBtnState);
40142 this.stickBtn.hide();
40144 this.fireEvent("slidehide", this);
40147 slideIn : function(cb){
40148 if(!this.isSlid || this.el.hasActiveFx()){
40152 this.isSlid = false;
40153 this.beforeSlide();
40154 this.el.slideOut(this.getSlideAnchor(), {
40155 callback: function(){
40156 this.el.setLeftTop(-10000, -10000);
40158 this.afterSlideIn();
40166 slideInIf : function(e){
40167 if(!e.within(this.el)){
40172 animateCollapse : function(){
40173 this.beforeSlide();
40174 this.el.setStyle("z-index", 20000);
40175 var anchor = this.getSlideAnchor();
40176 this.el.slideOut(anchor, {
40177 callback : function(){
40178 this.el.setStyle("z-index", "");
40179 this.collapsedEl.slideIn(anchor, {duration:.3});
40181 this.el.setLocation(-10000,-10000);
40183 this.fireEvent("collapsed", this);
40190 animateExpand : function(){
40191 this.beforeSlide();
40192 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
40193 this.el.setStyle("z-index", 20000);
40194 this.collapsedEl.hide({
40197 this.el.slideIn(this.getSlideAnchor(), {
40198 callback : function(){
40199 this.el.setStyle("z-index", "");
40202 this.split.el.show();
40204 this.fireEvent("invalidated", this);
40205 this.fireEvent("expanded", this);
40233 getAnchor : function(){
40234 return this.anchors[this.position];
40237 getCollapseAnchor : function(){
40238 return this.canchors[this.position];
40241 getSlideAnchor : function(){
40242 return this.sanchors[this.position];
40245 getAlignAdj : function(){
40246 var cm = this.cmargins;
40247 switch(this.position){
40263 getExpandAdj : function(){
40264 var c = this.collapsedEl, cm = this.cmargins;
40265 switch(this.position){
40267 return [-(cm.right+c.getWidth()+cm.left), 0];
40270 return [cm.right+c.getWidth()+cm.left, 0];
40273 return [0, -(cm.top+cm.bottom+c.getHeight())];
40276 return [0, cm.top+cm.bottom+c.getHeight()];
40282 * Ext JS Library 1.1.1
40283 * Copyright(c) 2006-2007, Ext JS, LLC.
40285 * Originally Released Under LGPL - original licence link has changed is not relivant.
40288 * <script type="text/javascript">
40291 * These classes are private internal classes
40293 Roo.bootstrap.layout.Center = function(config){
40294 config.region = "center";
40295 Roo.bootstrap.layout.Region.call(this, config);
40296 this.visible = true;
40297 this.minWidth = config.minWidth || 20;
40298 this.minHeight = config.minHeight || 20;
40301 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
40303 // center panel can't be hidden
40307 // center panel can't be hidden
40310 getMinWidth: function(){
40311 return this.minWidth;
40314 getMinHeight: function(){
40315 return this.minHeight;
40329 Roo.bootstrap.layout.North = function(config)
40331 config.region = 'north';
40332 config.cursor = 'n-resize';
40334 Roo.bootstrap.layout.Split.call(this, config);
40338 this.split.placement = Roo.bootstrap.SplitBar.TOP;
40339 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
40340 this.split.el.addClass("roo-layout-split-v");
40342 //var size = config.initialSize || config.height;
40343 //if(this.el && typeof size != "undefined"){
40344 // this.el.setHeight(size);
40347 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
40349 orientation: Roo.bootstrap.SplitBar.VERTICAL,
40352 onRender : function(ctr, pos)
40354 Roo.bootstrap.layout.Split.prototype.onRender.call(this, ctr, pos);
40355 var size = this.config.initialSize || this.config.height;
40356 if(this.el && typeof size != "undefined"){
40357 this.el.setHeight(size);
40362 getBox : function(){
40363 if(this.collapsed){
40364 return this.collapsedEl.getBox();
40366 var box = this.el.getBox();
40368 box.height += this.split.el.getHeight();
40373 updateBox : function(box){
40374 if(this.split && !this.collapsed){
40375 box.height -= this.split.el.getHeight();
40376 this.split.el.setLeft(box.x);
40377 this.split.el.setTop(box.y+box.height);
40378 this.split.el.setWidth(box.width);
40380 if(this.collapsed){
40381 this.updateBody(box.width, null);
40383 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
40391 Roo.bootstrap.layout.South = function(config){
40392 config.region = 'south';
40393 config.cursor = 's-resize';
40394 Roo.bootstrap.layout.Split.call(this, config);
40396 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
40397 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
40398 this.split.el.addClass("roo-layout-split-v");
40403 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
40404 orientation: Roo.bootstrap.SplitBar.VERTICAL,
40406 onRender : function(ctr, pos)
40408 Roo.bootstrap.layout.Split.prototype.onRender.call(this, ctr, pos);
40409 var size = this.config.initialSize || this.config.height;
40410 if(this.el && typeof size != "undefined"){
40411 this.el.setHeight(size);
40416 getBox : function(){
40417 if(this.collapsed){
40418 return this.collapsedEl.getBox();
40420 var box = this.el.getBox();
40422 var sh = this.split.el.getHeight();
40429 updateBox : function(box){
40430 if(this.split && !this.collapsed){
40431 var sh = this.split.el.getHeight();
40434 this.split.el.setLeft(box.x);
40435 this.split.el.setTop(box.y-sh);
40436 this.split.el.setWidth(box.width);
40438 if(this.collapsed){
40439 this.updateBody(box.width, null);
40441 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
40445 Roo.bootstrap.layout.East = function(config){
40446 config.region = "east";
40447 config.cursor = "e-resize";
40448 Roo.bootstrap.layout.Split.call(this, config);
40450 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
40451 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
40452 this.split.el.addClass("roo-layout-split-h");
40456 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
40457 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
40459 onRender : function(ctr, pos)
40461 Roo.bootstrap.layout.Split.prototype.onRender.call(this, ctr, pos);
40462 var size = this.config.initialSize || this.config.width;
40463 if(this.el && typeof size != "undefined"){
40464 this.el.setWidth(size);
40469 getBox : function(){
40470 if(this.collapsed){
40471 return this.collapsedEl.getBox();
40473 var box = this.el.getBox();
40475 var sw = this.split.el.getWidth();
40482 updateBox : function(box){
40483 if(this.split && !this.collapsed){
40484 var sw = this.split.el.getWidth();
40486 this.split.el.setLeft(box.x);
40487 this.split.el.setTop(box.y);
40488 this.split.el.setHeight(box.height);
40491 if(this.collapsed){
40492 this.updateBody(null, box.height);
40494 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
40498 Roo.bootstrap.layout.West = function(config){
40499 config.region = "west";
40500 config.cursor = "w-resize";
40502 Roo.bootstrap.layout.Split.call(this, config);
40504 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
40505 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
40506 this.split.el.addClass("roo-layout-split-h");
40510 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
40511 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
40513 onRender: function(ctr, pos)
40515 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
40516 var size = this.config.initialSize || this.config.width;
40517 if(typeof size != "undefined"){
40518 this.el.setWidth(size);
40522 getBox : function(){
40523 if(this.collapsed){
40524 return this.collapsedEl.getBox();
40526 var box = this.el.getBox();
40527 if (box.width == 0) {
40528 box.width = this.config.width; // kludge?
40531 box.width += this.split.el.getWidth();
40536 updateBox : function(box){
40537 if(this.split && !this.collapsed){
40538 var sw = this.split.el.getWidth();
40540 this.split.el.setLeft(box.x+box.width);
40541 this.split.el.setTop(box.y);
40542 this.split.el.setHeight(box.height);
40544 if(this.collapsed){
40545 this.updateBody(null, box.height);
40547 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
40549 });Roo.namespace("Roo.bootstrap.panel");/*
40551 * Ext JS Library 1.1.1
40552 * Copyright(c) 2006-2007, Ext JS, LLC.
40554 * Originally Released Under LGPL - original licence link has changed is not relivant.
40557 * <script type="text/javascript">
40560 * @class Roo.ContentPanel
40561 * @extends Roo.util.Observable
40563 * A basic ContentPanel element.
40564 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
40565 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
40566 * @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
40567 * @cfg {Boolean} closable True if the panel can be closed/removed
40568 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
40569 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
40570 * @cfg {Toolbar} toolbar A toolbar for this panel
40571 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
40572 * @cfg {String} title The title for this panel
40573 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
40574 * @cfg {String} url Calls {@link #setUrl} with this value
40575 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
40576 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
40577 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
40578 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
40579 * @cfg {Boolean} iframe contents are an iframe - makes showing remote sources/CSS feasible..
40580 * @cfg {Boolean} badges render the badges
40581 * @cfg {String} cls extra classes to use
40582 * @cfg {String} background (primary|secondary|success|info|warning|danger|light|dark)
40585 * Create a new ContentPanel.
40586 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
40587 * @param {String/Object} config A string to set only the title or a config object
40588 * @param {String} content (optional) Set the HTML content for this panel
40589 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
40591 Roo.bootstrap.panel.Content = function( config){
40593 this.tpl = config.tpl || false;
40595 var el = config.el;
40596 var content = config.content;
40598 if(config.autoCreate){ // xtype is available if this is called from factory
40601 this.el = Roo.get(el);
40602 if(!this.el && config && config.autoCreate){
40603 if(typeof config.autoCreate == "object"){
40604 if(!config.autoCreate.id){
40605 config.autoCreate.id = config.id||el;
40607 this.el = Roo.DomHelper.append(document.body,
40608 config.autoCreate, true);
40612 cls: (config.cls || '') +
40613 (config.background ? ' bg-' + config.background : '') +
40614 " roo-layout-inactive-content",
40617 if (config.iframe) {
40621 style : 'border: 0px',
40622 src : 'about:blank'
40628 elcfg.html = config.html;
40632 this.el = Roo.DomHelper.append(document.body, elcfg , true);
40633 if (config.iframe) {
40634 this.iframeEl = this.el.select('iframe',true).first();
40639 this.closable = false;
40640 this.loaded = false;
40641 this.active = false;
40644 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
40646 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
40648 this.wrapEl = this.el; //this.el.wrap();
40650 if (config.toolbar.items) {
40651 ti = config.toolbar.items ;
40652 delete config.toolbar.items ;
40656 this.toolbar.render(this.wrapEl, 'before');
40657 for(var i =0;i < ti.length;i++) {
40658 // Roo.log(['add child', items[i]]);
40659 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
40661 this.toolbar.items = nitems;
40662 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
40663 delete config.toolbar;
40667 // xtype created footer. - not sure if will work as we normally have to render first..
40668 if (this.footer && !this.footer.el && this.footer.xtype) {
40669 if (!this.wrapEl) {
40670 this.wrapEl = this.el.wrap();
40673 this.footer.container = this.wrapEl.createChild();
40675 this.footer = Roo.factory(this.footer, Roo);
40680 if(typeof config == "string"){
40681 this.title = config;
40683 Roo.apply(this, config);
40687 this.resizeEl = Roo.get(this.resizeEl, true);
40689 this.resizeEl = this.el;
40691 // handle view.xtype
40699 * Fires when this panel is activated.
40700 * @param {Roo.ContentPanel} this
40704 * @event deactivate
40705 * Fires when this panel is activated.
40706 * @param {Roo.ContentPanel} this
40708 "deactivate" : true,
40712 * Fires when this panel is resized if fitToFrame is true.
40713 * @param {Roo.ContentPanel} this
40714 * @param {Number} width The width after any component adjustments
40715 * @param {Number} height The height after any component adjustments
40721 * Fires when this tab is created
40722 * @param {Roo.ContentPanel} this
40728 * Fires when this content is scrolled
40729 * @param {Roo.ContentPanel} this
40730 * @param {Event} scrollEvent
40741 if(this.autoScroll && !this.iframe){
40742 this.resizeEl.setStyle("overflow", "auto");
40743 this.resizeEl.on('scroll', this.onScroll, this);
40745 // fix randome scrolling
40746 //this.el.on('scroll', function() {
40747 // Roo.log('fix random scolling');
40748 // this.scrollTo('top',0);
40751 content = content || this.content;
40753 this.setContent(content);
40755 if(config && config.url){
40756 this.setUrl(this.url, this.params, this.loadOnce);
40761 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
40763 if (this.view && typeof(this.view.xtype) != 'undefined') {
40764 this.view.el = this.el.appendChild(document.createElement("div"));
40765 this.view = Roo.factory(this.view);
40766 this.view.render && this.view.render(false, '');
40770 this.fireEvent('render', this);
40773 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
40783 /* Resize Element - use this to work out scroll etc. */
40786 setRegion : function(region){
40787 this.region = region;
40788 this.setActiveClass(region && !this.background);
40792 setActiveClass: function(state)
40795 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
40796 this.el.setStyle('position','relative');
40798 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
40799 this.el.setStyle('position', 'absolute');
40804 * Returns the toolbar for this Panel if one was configured.
40805 * @return {Roo.Toolbar}
40807 getToolbar : function(){
40808 return this.toolbar;
40811 setActiveState : function(active)
40813 this.active = active;
40814 this.setActiveClass(active);
40816 if(this.fireEvent("deactivate", this) === false){
40821 this.fireEvent("activate", this);
40825 * Updates this panel's element (not for iframe)
40826 * @param {String} content The new content
40827 * @param {Boolean} loadScripts (optional) true to look for and process scripts
40829 setContent : function(content, loadScripts){
40834 this.el.update(content, loadScripts);
40837 ignoreResize : function(w, h){
40838 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
40841 this.lastSize = {width: w, height: h};
40846 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
40847 * @return {Roo.UpdateManager} The UpdateManager
40849 getUpdateManager : function(){
40853 return this.el.getUpdateManager();
40856 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
40857 * Does not work with IFRAME contents
40858 * @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:
40861 url: "your-url.php",
40862 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
40863 callback: yourFunction,
40864 scope: yourObject, //(optional scope)
40867 text: "Loading...",
40873 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
40874 * 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.
40875 * @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}
40876 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
40877 * @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.
40878 * @return {Roo.ContentPanel} this
40886 var um = this.el.getUpdateManager();
40887 um.update.apply(um, arguments);
40893 * 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.
40894 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
40895 * @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)
40896 * @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)
40897 * @return {Roo.UpdateManager|Boolean} The UpdateManager or false if IFRAME
40899 setUrl : function(url, params, loadOnce){
40901 this.iframeEl.dom.src = url;
40905 if(this.refreshDelegate){
40906 this.removeListener("activate", this.refreshDelegate);
40908 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
40909 this.on("activate", this.refreshDelegate);
40910 return this.el.getUpdateManager();
40913 _handleRefresh : function(url, params, loadOnce){
40914 if(!loadOnce || !this.loaded){
40915 var updater = this.el.getUpdateManager();
40916 updater.update(url, params, this._setLoaded.createDelegate(this));
40920 _setLoaded : function(){
40921 this.loaded = true;
40925 * Returns this panel's id
40928 getId : function(){
40933 * Returns this panel's element - used by regiosn to add.
40934 * @return {Roo.Element}
40936 getEl : function(){
40937 return this.wrapEl || this.el;
40942 adjustForComponents : function(width, height)
40944 //Roo.log('adjustForComponents ');
40945 if(this.resizeEl != this.el){
40946 width -= this.el.getFrameWidth('lr');
40947 height -= this.el.getFrameWidth('tb');
40950 var te = this.toolbar.getEl();
40951 te.setWidth(width);
40952 height -= te.getHeight();
40955 var te = this.footer.getEl();
40956 te.setWidth(width);
40957 height -= te.getHeight();
40961 if(this.adjustments){
40962 width += this.adjustments[0];
40963 height += this.adjustments[1];
40965 return {"width": width, "height": height};
40968 setSize : function(width, height){
40969 if(this.fitToFrame && !this.ignoreResize(width, height)){
40970 if(this.fitContainer && this.resizeEl != this.el){
40971 this.el.setSize(width, height);
40973 var size = this.adjustForComponents(width, height);
40975 this.iframeEl.setSize(width,height);
40978 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
40979 this.fireEvent('resize', this, size.width, size.height);
40986 * Returns this panel's title
40989 getTitle : function(){
40991 if (typeof(this.title) != 'object') {
40996 for (var k in this.title) {
40997 if (!this.title.hasOwnProperty(k)) {
41001 if (k.indexOf('-') >= 0) {
41002 var s = k.split('-');
41003 for (var i = 0; i<s.length; i++) {
41004 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
41007 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
41014 * Set this panel's title
41015 * @param {String} title
41017 setTitle : function(title){
41018 this.title = title;
41020 this.region.updatePanelTitle(this, title);
41025 * Returns true is this panel was configured to be closable
41026 * @return {Boolean}
41028 isClosable : function(){
41029 return this.closable;
41032 beforeSlide : function(){
41034 this.resizeEl.clip();
41037 afterSlide : function(){
41039 this.resizeEl.unclip();
41043 * Force a content refresh from the URL specified in the {@link #setUrl} method.
41044 * Will fail silently if the {@link #setUrl} method has not been called.
41045 * This does not activate the panel, just updates its content.
41047 refresh : function(){
41048 if(this.refreshDelegate){
41049 this.loaded = false;
41050 this.refreshDelegate();
41055 * Destroys this panel
41057 destroy : function(){
41058 this.el.removeAllListeners();
41059 var tempEl = document.createElement("span");
41060 tempEl.appendChild(this.el.dom);
41061 tempEl.innerHTML = "";
41067 * form - if the content panel contains a form - this is a reference to it.
41068 * @type {Roo.form.Form}
41072 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
41073 * This contains a reference to it.
41079 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
41089 * @param {Object} cfg Xtype definition of item to add.
41093 getChildContainer: function () {
41094 return this.getEl();
41098 onScroll : function(e)
41100 this.fireEvent('scroll', this, e);
41105 var ret = new Roo.factory(cfg);
41110 if (cfg.xtype.match(/^Form$/)) {
41113 //if (this.footer) {
41114 // el = this.footer.container.insertSibling(false, 'before');
41116 el = this.el.createChild();
41119 this.form = new Roo.form.Form(cfg);
41122 if ( this.form.allItems.length) {
41123 this.form.render(el.dom);
41127 // should only have one of theses..
41128 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
41129 // views.. should not be just added - used named prop 'view''
41131 cfg.el = this.el.appendChild(document.createElement("div"));
41134 var ret = new Roo.factory(cfg);
41136 ret.render && ret.render(false, ''); // render blank..
41146 * @class Roo.bootstrap.panel.Grid
41147 * @extends Roo.bootstrap.panel.Content
41149 * Create a new GridPanel.
41150 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
41151 * @param {Object} config A the config object
41157 Roo.bootstrap.panel.Grid = function(config)
41161 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
41162 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
41164 config.el = this.wrapper;
41165 //this.el = this.wrapper;
41167 if (config.container) {
41168 // ctor'ed from a Border/panel.grid
41171 this.wrapper.setStyle("overflow", "hidden");
41172 this.wrapper.addClass('roo-grid-container');
41177 if(config.toolbar){
41178 var tool_el = this.wrapper.createChild();
41179 this.toolbar = Roo.factory(config.toolbar);
41181 if (config.toolbar.items) {
41182 ti = config.toolbar.items ;
41183 delete config.toolbar.items ;
41187 this.toolbar.render(tool_el);
41188 for(var i =0;i < ti.length;i++) {
41189 // Roo.log(['add child', items[i]]);
41190 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
41192 this.toolbar.items = nitems;
41194 delete config.toolbar;
41197 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
41198 config.grid.scrollBody = true;;
41199 config.grid.monitorWindowResize = false; // turn off autosizing
41200 config.grid.autoHeight = false;
41201 config.grid.autoWidth = false;
41203 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
41205 if (config.background) {
41206 // render grid on panel activation (if panel background)
41207 this.on('activate', function(gp) {
41208 if (!gp.grid.rendered) {
41209 gp.grid.render(this.wrapper);
41210 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
41215 this.grid.render(this.wrapper);
41216 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
41219 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
41220 // ??? needed ??? config.el = this.wrapper;
41225 // xtype created footer. - not sure if will work as we normally have to render first..
41226 if (this.footer && !this.footer.el && this.footer.xtype) {
41228 var ctr = this.grid.getView().getFooterPanel(true);
41229 this.footer.dataSource = this.grid.dataSource;
41230 this.footer = Roo.factory(this.footer, Roo);
41231 this.footer.render(ctr);
41241 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
41242 getId : function(){
41243 return this.grid.id;
41247 * Returns the grid for this panel
41248 * @return {Roo.bootstrap.Table}
41250 getGrid : function(){
41254 setSize : function(width, height){
41255 if(!this.ignoreResize(width, height)){
41256 var grid = this.grid;
41257 var size = this.adjustForComponents(width, height);
41258 // tfoot is not a footer?
41261 var gridel = grid.getGridEl();
41262 gridel.setSize(size.width, size.height);
41264 var tbd = grid.getGridEl().select('tbody', true).first();
41265 var thd = grid.getGridEl().select('thead',true).first();
41266 var tbf= grid.getGridEl().select('tfoot', true).first();
41269 size.height -= tbf.getHeight();
41272 size.height -= thd.getHeight();
41275 tbd.setSize(size.width, size.height );
41276 // this is for the account management tab -seems to work there.
41277 var thd = grid.getGridEl().select('thead',true).first();
41279 // tbd.setSize(size.width, size.height - thd.getHeight());
41288 beforeSlide : function(){
41289 this.grid.getView().scroller.clip();
41292 afterSlide : function(){
41293 this.grid.getView().scroller.unclip();
41296 destroy : function(){
41297 this.grid.destroy();
41299 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
41304 * @class Roo.bootstrap.panel.Nest
41305 * @extends Roo.bootstrap.panel.Content
41307 * Create a new Panel, that can contain a layout.Border.
41310 * @param {Roo.BorderLayout} layout The layout for this panel
41311 * @param {String/Object} config A string to set only the title or a config object
41313 Roo.bootstrap.panel.Nest = function(config)
41315 // construct with only one argument..
41316 /* FIXME - implement nicer consturctors
41317 if (layout.layout) {
41319 layout = config.layout;
41320 delete config.layout;
41322 if (layout.xtype && !layout.getEl) {
41323 // then layout needs constructing..
41324 layout = Roo.factory(layout, Roo);
41328 config.el = config.layout.getEl();
41330 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
41332 config.layout.monitorWindowResize = false; // turn off autosizing
41333 this.layout = config.layout;
41334 this.layout.getEl().addClass("roo-layout-nested-layout");
41335 this.layout.parent = this;
41342 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
41344 setSize : function(width, height){
41345 if(!this.ignoreResize(width, height)){
41346 var size = this.adjustForComponents(width, height);
41347 var el = this.layout.getEl();
41348 if (size.height < 1) {
41349 el.setWidth(size.width);
41351 el.setSize(size.width, size.height);
41353 var touch = el.dom.offsetWidth;
41354 this.layout.layout();
41355 // ie requires a double layout on the first pass
41356 if(Roo.isIE && !this.initialized){
41357 this.initialized = true;
41358 this.layout.layout();
41363 // activate all subpanels if not currently active..
41365 setActiveState : function(active){
41366 this.active = active;
41367 this.setActiveClass(active);
41370 this.fireEvent("deactivate", this);
41374 this.fireEvent("activate", this);
41375 // not sure if this should happen before or after..
41376 if (!this.layout) {
41377 return; // should not happen..
41380 for (var r in this.layout.regions) {
41381 reg = this.layout.getRegion(r);
41382 if (reg.getActivePanel()) {
41383 //reg.showPanel(reg.getActivePanel()); // force it to activate..
41384 reg.setActivePanel(reg.getActivePanel());
41387 if (!reg.panels.length) {
41390 reg.showPanel(reg.getPanel(0));
41399 * Returns the nested BorderLayout for this panel
41400 * @return {Roo.BorderLayout}
41402 getLayout : function(){
41403 return this.layout;
41407 * Adds a xtype elements to the layout of the nested panel
41411 xtype : 'ContentPanel',
41418 xtype : 'NestedLayoutPanel',
41424 items : [ ... list of content panels or nested layout panels.. ]
41428 * @param {Object} cfg Xtype definition of item to add.
41430 addxtype : function(cfg) {
41431 return this.layout.addxtype(cfg);
41436 * Ext JS Library 1.1.1
41437 * Copyright(c) 2006-2007, Ext JS, LLC.
41439 * Originally Released Under LGPL - original licence link has changed is not relivant.
41442 * <script type="text/javascript">
41445 * @class Roo.TabPanel
41446 * @extends Roo.util.Observable
41447 * A lightweight tab container.
41451 // basic tabs 1, built from existing content
41452 var tabs = new Roo.TabPanel("tabs1");
41453 tabs.addTab("script", "View Script");
41454 tabs.addTab("markup", "View Markup");
41455 tabs.activate("script");
41457 // more advanced tabs, built from javascript
41458 var jtabs = new Roo.TabPanel("jtabs");
41459 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
41461 // set up the UpdateManager
41462 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
41463 var updater = tab2.getUpdateManager();
41464 updater.setDefaultUrl("ajax1.htm");
41465 tab2.on('activate', updater.refresh, updater, true);
41467 // Use setUrl for Ajax loading
41468 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
41469 tab3.setUrl("ajax2.htm", null, true);
41472 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
41475 jtabs.activate("jtabs-1");
41478 * Create a new TabPanel.
41479 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
41480 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
41482 Roo.bootstrap.panel.Tabs = function(config){
41484 * The container element for this TabPanel.
41485 * @type Roo.Element
41487 this.el = Roo.get(config.el);
41490 if(typeof config == "boolean"){
41491 this.tabPosition = config ? "bottom" : "top";
41493 Roo.apply(this, config);
41497 if(this.tabPosition == "bottom"){
41498 // if tabs are at the bottom = create the body first.
41499 this.bodyEl = Roo.get(this.createBody(this.el.dom));
41500 this.el.addClass("roo-tabs-bottom");
41502 // next create the tabs holders
41504 if (this.tabPosition == "west"){
41506 var reg = this.region; // fake it..
41508 if (!reg.mgr.parent) {
41511 reg = reg.mgr.parent.region;
41513 Roo.log("got nest?");
41515 if (reg.mgr.getRegion('west')) {
41516 var ctrdom = reg.mgr.getRegion('west').bodyEl.dom;
41517 this.stripWrap = Roo.get(this.createStrip(ctrdom ), true);
41518 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
41519 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
41520 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
41528 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
41529 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
41530 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
41531 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
41536 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
41539 // finally - if tabs are at the top, then create the body last..
41540 if(this.tabPosition != "bottom"){
41541 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
41542 * @type Roo.Element
41544 this.bodyEl = Roo.get(this.createBody(this.el.dom));
41545 this.el.addClass("roo-tabs-top");
41549 this.bodyEl.setStyle("position", "relative");
41551 this.active = null;
41552 this.activateDelegate = this.activate.createDelegate(this);
41557 * Fires when the active tab changes
41558 * @param {Roo.TabPanel} this
41559 * @param {Roo.TabPanelItem} activePanel The new active tab
41563 * @event beforetabchange
41564 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
41565 * @param {Roo.TabPanel} this
41566 * @param {Object} e Set cancel to true on this object to cancel the tab change
41567 * @param {Roo.TabPanelItem} tab The tab being changed to
41569 "beforetabchange" : true
41572 Roo.EventManager.onWindowResize(this.onResize, this);
41573 this.cpad = this.el.getPadding("lr");
41574 this.hiddenCount = 0;
41577 // toolbar on the tabbar support...
41578 if (this.toolbar) {
41579 alert("no toolbar support yet");
41580 this.toolbar = false;
41582 var tcfg = this.toolbar;
41583 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
41584 this.toolbar = new Roo.Toolbar(tcfg);
41585 if (Roo.isSafari) {
41586 var tbl = tcfg.container.child('table', true);
41587 tbl.setAttribute('width', '100%');
41595 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
41598 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
41600 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
41602 tabPosition : "top",
41604 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
41606 currentTabWidth : 0,
41608 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
41612 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
41616 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
41618 preferredTabWidth : 175,
41620 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
41622 resizeTabs : false,
41624 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
41626 monitorResize : true,
41628 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
41630 toolbar : false, // set by caller..
41632 region : false, /// set by caller
41634 disableTooltips : true, // not used yet...
41637 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
41638 * @param {String} id The id of the div to use <b>or create</b>
41639 * @param {String} text The text for the tab
41640 * @param {String} content (optional) Content to put in the TabPanelItem body
41641 * @param {Boolean} closable (optional) True to create a close icon on the tab
41642 * @return {Roo.TabPanelItem} The created TabPanelItem
41644 addTab : function(id, text, content, closable, tpl)
41646 var item = new Roo.bootstrap.panel.TabItem({
41650 closable : closable,
41653 this.addTabItem(item);
41655 item.setContent(content);
41661 * Returns the {@link Roo.TabPanelItem} with the specified id/index
41662 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
41663 * @return {Roo.TabPanelItem}
41665 getTab : function(id){
41666 return this.items[id];
41670 * Hides the {@link Roo.TabPanelItem} with the specified id/index
41671 * @param {String/Number} id The id or index of the TabPanelItem to hide.
41673 hideTab : function(id){
41674 var t = this.items[id];
41677 this.hiddenCount++;
41678 this.autoSizeTabs();
41683 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
41684 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
41686 unhideTab : function(id){
41687 var t = this.items[id];
41689 t.setHidden(false);
41690 this.hiddenCount--;
41691 this.autoSizeTabs();
41696 * Adds an existing {@link Roo.TabPanelItem}.
41697 * @param {Roo.TabPanelItem} item The TabPanelItem to add
41699 addTabItem : function(item)
41701 this.items[item.id] = item;
41702 this.items.push(item);
41703 this.autoSizeTabs();
41704 // if(this.resizeTabs){
41705 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
41706 // this.autoSizeTabs();
41708 // item.autoSize();
41713 * Removes a {@link Roo.TabPanelItem}.
41714 * @param {String/Number} id The id or index of the TabPanelItem to remove.
41716 removeTab : function(id){
41717 var items = this.items;
41718 var tab = items[id];
41719 if(!tab) { return; }
41720 var index = items.indexOf(tab);
41721 if(this.active == tab && items.length > 1){
41722 var newTab = this.getNextAvailable(index);
41727 this.stripEl.dom.removeChild(tab.pnode.dom);
41728 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
41729 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
41731 items.splice(index, 1);
41732 delete this.items[tab.id];
41733 tab.fireEvent("close", tab);
41734 tab.purgeListeners();
41735 this.autoSizeTabs();
41738 getNextAvailable : function(start){
41739 var items = this.items;
41741 // look for a next tab that will slide over to
41742 // replace the one being removed
41743 while(index < items.length){
41744 var item = items[++index];
41745 if(item && !item.isHidden()){
41749 // if one isn't found select the previous tab (on the left)
41752 var item = items[--index];
41753 if(item && !item.isHidden()){
41761 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
41762 * @param {String/Number} id The id or index of the TabPanelItem to disable.
41764 disableTab : function(id){
41765 var tab = this.items[id];
41766 if(tab && this.active != tab){
41772 * Enables a {@link Roo.TabPanelItem} that is disabled.
41773 * @param {String/Number} id The id or index of the TabPanelItem to enable.
41775 enableTab : function(id){
41776 var tab = this.items[id];
41781 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
41782 * @param {String/Number} id The id or index of the TabPanelItem to activate.
41783 * @return {Roo.TabPanelItem} The TabPanelItem.
41785 activate : function(id)
41787 //Roo.log('activite:' + id);
41789 var tab = this.items[id];
41793 if(tab == this.active || tab.disabled){
41797 this.fireEvent("beforetabchange", this, e, tab);
41798 if(e.cancel !== true && !tab.disabled){
41800 this.active.hide();
41802 this.active = this.items[id];
41803 this.active.show();
41804 this.fireEvent("tabchange", this, this.active);
41810 * Gets the active {@link Roo.TabPanelItem}.
41811 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
41813 getActiveTab : function(){
41814 return this.active;
41818 * Updates the tab body element to fit the height of the container element
41819 * for overflow scrolling
41820 * @param {Number} targetHeight (optional) Override the starting height from the elements height
41822 syncHeight : function(targetHeight){
41823 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
41824 var bm = this.bodyEl.getMargins();
41825 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
41826 this.bodyEl.setHeight(newHeight);
41830 onResize : function(){
41831 if(this.monitorResize){
41832 this.autoSizeTabs();
41837 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
41839 beginUpdate : function(){
41840 this.updating = true;
41844 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
41846 endUpdate : function(){
41847 this.updating = false;
41848 this.autoSizeTabs();
41852 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
41854 autoSizeTabs : function()
41856 var count = this.items.length;
41857 var vcount = count - this.hiddenCount;
41860 this.stripEl.hide();
41862 this.stripEl.show();
41865 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
41870 var w = Math.max(this.el.getWidth() - this.cpad, 10);
41871 var availWidth = Math.floor(w / vcount);
41872 var b = this.stripBody;
41873 if(b.getWidth() > w){
41874 var tabs = this.items;
41875 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
41876 if(availWidth < this.minTabWidth){
41877 /*if(!this.sleft){ // incomplete scrolling code
41878 this.createScrollButtons();
41881 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
41884 if(this.currentTabWidth < this.preferredTabWidth){
41885 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
41891 * Returns the number of tabs in this TabPanel.
41894 getCount : function(){
41895 return this.items.length;
41899 * Resizes all the tabs to the passed width
41900 * @param {Number} The new width
41902 setTabWidth : function(width){
41903 this.currentTabWidth = width;
41904 for(var i = 0, len = this.items.length; i < len; i++) {
41905 if(!this.items[i].isHidden()) {
41906 this.items[i].setWidth(width);
41912 * Destroys this TabPanel
41913 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
41915 destroy : function(removeEl){
41916 Roo.EventManager.removeResizeListener(this.onResize, this);
41917 for(var i = 0, len = this.items.length; i < len; i++){
41918 this.items[i].purgeListeners();
41920 if(removeEl === true){
41921 this.el.update("");
41926 createStrip : function(container)
41928 var strip = document.createElement("nav");
41929 strip.className = Roo.bootstrap.version == 4 ?
41930 "navbar-light bg-light" :
41931 "navbar navbar-default"; //"x-tabs-wrap";
41932 container.appendChild(strip);
41936 createStripList : function(strip)
41938 // div wrapper for retard IE
41939 // returns the "tr" element.
41940 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
41941 //'<div class="x-tabs-strip-wrap">'+
41942 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
41943 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
41944 return strip.firstChild; //.firstChild.firstChild.firstChild;
41946 createBody : function(container)
41948 var body = document.createElement("div");
41949 Roo.id(body, "tab-body");
41950 //Roo.fly(body).addClass("x-tabs-body");
41951 Roo.fly(body).addClass("tab-content");
41952 container.appendChild(body);
41955 createItemBody :function(bodyEl, id){
41956 var body = Roo.getDom(id);
41958 body = document.createElement("div");
41961 //Roo.fly(body).addClass("x-tabs-item-body");
41962 Roo.fly(body).addClass("tab-pane");
41963 bodyEl.insertBefore(body, bodyEl.firstChild);
41967 createStripElements : function(stripEl, text, closable, tpl)
41969 var td = document.createElement("li"); // was td..
41970 td.className = 'nav-item';
41972 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
41975 stripEl.appendChild(td);
41977 td.className = "x-tabs-closable";
41978 if(!this.closeTpl){
41979 this.closeTpl = new Roo.Template(
41980 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
41981 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
41982 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
41985 var el = this.closeTpl.overwrite(td, {"text": text});
41986 var close = el.getElementsByTagName("div")[0];
41987 var inner = el.getElementsByTagName("em")[0];
41988 return {"el": el, "close": close, "inner": inner};
41991 // not sure what this is..
41992 // if(!this.tabTpl){
41993 //this.tabTpl = new Roo.Template(
41994 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
41995 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
41997 // this.tabTpl = new Roo.Template(
41998 // '<a href="#">' +
41999 // '<span unselectable="on"' +
42000 // (this.disableTooltips ? '' : ' title="{text}"') +
42001 // ' >{text}</span></a>'
42007 var template = tpl || this.tabTpl || false;
42010 template = new Roo.Template(
42011 Roo.bootstrap.version == 4 ?
42013 '<a class="nav-link" href="#" unselectable="on"' +
42014 (this.disableTooltips ? '' : ' title="{text}"') +
42017 '<a class="nav-link" href="#">' +
42018 '<span unselectable="on"' +
42019 (this.disableTooltips ? '' : ' title="{text}"') +
42020 ' >{text}</span></a>'
42025 switch (typeof(template)) {
42029 template = new Roo.Template(template);
42035 var el = template.overwrite(td, {"text": text});
42037 var inner = el.getElementsByTagName("span")[0];
42039 return {"el": el, "inner": inner};
42047 * @class Roo.TabPanelItem
42048 * @extends Roo.util.Observable
42049 * Represents an individual item (tab plus body) in a TabPanel.
42050 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
42051 * @param {String} id The id of this TabPanelItem
42052 * @param {String} text The text for the tab of this TabPanelItem
42053 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
42055 Roo.bootstrap.panel.TabItem = function(config){
42057 * The {@link Roo.TabPanel} this TabPanelItem belongs to
42058 * @type Roo.TabPanel
42060 this.tabPanel = config.panel;
42062 * The id for this TabPanelItem
42065 this.id = config.id;
42067 this.disabled = false;
42069 this.text = config.text;
42071 this.loaded = false;
42072 this.closable = config.closable;
42075 * The body element for this TabPanelItem.
42076 * @type Roo.Element
42078 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
42079 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
42080 this.bodyEl.setStyle("display", "block");
42081 this.bodyEl.setStyle("zoom", "1");
42082 //this.hideAction();
42084 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
42086 this.el = Roo.get(els.el);
42087 this.inner = Roo.get(els.inner, true);
42088 this.textEl = Roo.bootstrap.version == 4 ?
42089 this.el : Roo.get(this.el.dom.firstChild, true);
42091 this.pnode = this.linode = Roo.get(els.el.parentNode, true);
42092 this.status_node = Roo.bootstrap.version == 4 ? this.el : this.linode;
42095 // this.el.on("mousedown", this.onTabMouseDown, this);
42096 this.el.on("click", this.onTabClick, this);
42098 if(config.closable){
42099 var c = Roo.get(els.close, true);
42100 c.dom.title = this.closeText;
42101 c.addClassOnOver("close-over");
42102 c.on("click", this.closeClick, this);
42108 * Fires when this tab becomes the active tab.
42109 * @param {Roo.TabPanel} tabPanel The parent TabPanel
42110 * @param {Roo.TabPanelItem} this
42114 * @event beforeclose
42115 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
42116 * @param {Roo.TabPanelItem} this
42117 * @param {Object} e Set cancel to true on this object to cancel the close.
42119 "beforeclose": true,
42122 * Fires when this tab is closed.
42123 * @param {Roo.TabPanelItem} this
42127 * @event deactivate
42128 * Fires when this tab is no longer the active tab.
42129 * @param {Roo.TabPanel} tabPanel The parent TabPanel
42130 * @param {Roo.TabPanelItem} this
42132 "deactivate" : true
42134 this.hidden = false;
42136 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
42139 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
42141 purgeListeners : function(){
42142 Roo.util.Observable.prototype.purgeListeners.call(this);
42143 this.el.removeAllListeners();
42146 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
42149 this.status_node.addClass("active");
42152 this.tabPanel.stripWrap.repaint();
42154 this.fireEvent("activate", this.tabPanel, this);
42158 * Returns true if this tab is the active tab.
42159 * @return {Boolean}
42161 isActive : function(){
42162 return this.tabPanel.getActiveTab() == this;
42166 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
42169 this.status_node.removeClass("active");
42171 this.fireEvent("deactivate", this.tabPanel, this);
42174 hideAction : function(){
42175 this.bodyEl.hide();
42176 this.bodyEl.setStyle("position", "absolute");
42177 this.bodyEl.setLeft("-20000px");
42178 this.bodyEl.setTop("-20000px");
42181 showAction : function(){
42182 this.bodyEl.setStyle("position", "relative");
42183 this.bodyEl.setTop("");
42184 this.bodyEl.setLeft("");
42185 this.bodyEl.show();
42189 * Set the tooltip for the tab.
42190 * @param {String} tooltip The tab's tooltip
42192 setTooltip : function(text){
42193 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
42194 this.textEl.dom.qtip = text;
42195 this.textEl.dom.removeAttribute('title');
42197 this.textEl.dom.title = text;
42201 onTabClick : function(e){
42202 e.preventDefault();
42203 this.tabPanel.activate(this.id);
42206 onTabMouseDown : function(e){
42207 e.preventDefault();
42208 this.tabPanel.activate(this.id);
42211 getWidth : function(){
42212 return this.inner.getWidth();
42215 setWidth : function(width){
42216 var iwidth = width - this.linode.getPadding("lr");
42217 this.inner.setWidth(iwidth);
42218 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
42219 this.linode.setWidth(width);
42223 * Show or hide the tab
42224 * @param {Boolean} hidden True to hide or false to show.
42226 setHidden : function(hidden){
42227 this.hidden = hidden;
42228 this.linode.setStyle("display", hidden ? "none" : "");
42232 * Returns true if this tab is "hidden"
42233 * @return {Boolean}
42235 isHidden : function(){
42236 return this.hidden;
42240 * Returns the text for this tab
42243 getText : function(){
42247 autoSize : function(){
42248 //this.el.beginMeasure();
42249 this.textEl.setWidth(1);
42251 * #2804 [new] Tabs in Roojs
42252 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
42254 //this.setWidth(this.textEl.dom.scrollWidth+this.linode.getPadding("lr")+this.inner.getPadding("lr") + 2);
42255 //this.el.endMeasure();
42259 * Sets the text for the tab (Note: this also sets the tooltip text)
42260 * @param {String} text The tab's text and tooltip
42262 setText : function(text){
42264 this.textEl.update(text);
42265 this.setTooltip(text);
42266 //if(!this.tabPanel.resizeTabs){
42267 // this.autoSize();
42271 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
42273 activate : function(){
42274 this.tabPanel.activate(this.id);
42278 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
42280 disable : function(){
42281 if(this.tabPanel.active != this){
42282 this.disabled = true;
42283 this.status_node.addClass("disabled");
42288 * Enables this TabPanelItem if it was previously disabled.
42290 enable : function(){
42291 this.disabled = false;
42292 this.status_node.removeClass("disabled");
42296 * Sets the content for this TabPanelItem.
42297 * @param {String} content The content
42298 * @param {Boolean} loadScripts true to look for and load scripts
42300 setContent : function(content, loadScripts){
42301 this.bodyEl.update(content, loadScripts);
42305 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
42306 * @return {Roo.UpdateManager} The UpdateManager
42308 getUpdateManager : function(){
42309 return this.bodyEl.getUpdateManager();
42313 * Set a URL to be used to load the content for this TabPanelItem.
42314 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
42315 * @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)
42316 * @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)
42317 * @return {Roo.UpdateManager} The UpdateManager
42319 setUrl : function(url, params, loadOnce){
42320 if(this.refreshDelegate){
42321 this.un('activate', this.refreshDelegate);
42323 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
42324 this.on("activate", this.refreshDelegate);
42325 return this.bodyEl.getUpdateManager();
42329 _handleRefresh : function(url, params, loadOnce){
42330 if(!loadOnce || !this.loaded){
42331 var updater = this.bodyEl.getUpdateManager();
42332 updater.update(url, params, this._setLoaded.createDelegate(this));
42337 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
42338 * Will fail silently if the setUrl method has not been called.
42339 * This does not activate the panel, just updates its content.
42341 refresh : function(){
42342 if(this.refreshDelegate){
42343 this.loaded = false;
42344 this.refreshDelegate();
42349 _setLoaded : function(){
42350 this.loaded = true;
42354 closeClick : function(e){
42357 this.fireEvent("beforeclose", this, o);
42358 if(o.cancel !== true){
42359 this.tabPanel.removeTab(this.id);
42363 * The text displayed in the tooltip for the close icon.
42366 closeText : "Close this tab"
42369 * This script refer to:
42370 * Title: International Telephone Input
42371 * Author: Jack O'Connor
42372 * Code version: v12.1.12
42373 * Availability: https://github.com/jackocnr/intl-tel-input.git
42376 Roo.bootstrap.PhoneInputData = function() {
42379 "Afghanistan (افغانستان)",
42384 "Albania (Shqipëri)",
42389 "Algeria (الجزائر)",
42414 "Antigua and Barbuda",
42424 "Armenia (Հայաստան)",
42440 "Austria (Österreich)",
42445 "Azerbaijan (Azərbaycan)",
42455 "Bahrain (البحرين)",
42460 "Bangladesh (বাংলাদেশ)",
42470 "Belarus (Беларусь)",
42475 "Belgium (België)",
42505 "Bosnia and Herzegovina (Босна и Херцеговина)",
42520 "British Indian Ocean Territory",
42525 "British Virgin Islands",
42535 "Bulgaria (България)",
42545 "Burundi (Uburundi)",
42550 "Cambodia (កម្ពុជា)",
42555 "Cameroon (Cameroun)",
42564 ["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"]
42567 "Cape Verde (Kabu Verdi)",
42572 "Caribbean Netherlands",
42583 "Central African Republic (République centrafricaine)",
42603 "Christmas Island",
42609 "Cocos (Keeling) Islands",
42620 "Comoros (جزر القمر)",
42625 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
42630 "Congo (Republic) (Congo-Brazzaville)",
42650 "Croatia (Hrvatska)",
42671 "Czech Republic (Česká republika)",
42676 "Denmark (Danmark)",
42691 "Dominican Republic (República Dominicana)",
42695 ["809", "829", "849"]
42713 "Equatorial Guinea (Guinea Ecuatorial)",
42733 "Falkland Islands (Islas Malvinas)",
42738 "Faroe Islands (Føroyar)",
42759 "French Guiana (Guyane française)",
42764 "French Polynesia (Polynésie française)",
42779 "Georgia (საქართველო)",
42784 "Germany (Deutschland)",
42804 "Greenland (Kalaallit Nunaat)",
42841 "Guinea-Bissau (Guiné Bissau)",
42866 "Hungary (Magyarország)",
42871 "Iceland (Ísland)",
42891 "Iraq (العراق)",
42907 "Israel (ישראל)",
42934 "Jordan (الأردن)",
42939 "Kazakhstan (Казахстан)",
42960 "Kuwait (الكويت)",
42965 "Kyrgyzstan (Кыргызстан)",
42975 "Latvia (Latvija)",
42980 "Lebanon (لبنان)",
42995 "Libya (ليبيا)",
43005 "Lithuania (Lietuva)",
43020 "Macedonia (FYROM) (Македонија)",
43025 "Madagascar (Madagasikara)",
43055 "Marshall Islands",
43065 "Mauritania (موريتانيا)",
43070 "Mauritius (Moris)",
43091 "Moldova (Republica Moldova)",
43101 "Mongolia (Монгол)",
43106 "Montenegro (Crna Gora)",
43116 "Morocco (المغرب)",
43122 "Mozambique (Moçambique)",
43127 "Myanmar (Burma) (မြန်မာ)",
43132 "Namibia (Namibië)",
43147 "Netherlands (Nederland)",
43152 "New Caledonia (Nouvelle-Calédonie)",
43187 "North Korea (조선 민주주의 인민 공화국)",
43192 "Northern Mariana Islands",
43208 "Pakistan (پاکستان)",
43218 "Palestine (فلسطين)",
43228 "Papua New Guinea",
43270 "Réunion (La Réunion)",
43276 "Romania (România)",
43292 "Saint Barthélemy",
43303 "Saint Kitts and Nevis",
43313 "Saint Martin (Saint-Martin (partie française))",
43319 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
43324 "Saint Vincent and the Grenadines",
43339 "São Tomé and Príncipe (São Tomé e Príncipe)",
43344 "Saudi Arabia (المملكة العربية السعودية)",
43349 "Senegal (Sénégal)",
43379 "Slovakia (Slovensko)",
43384 "Slovenia (Slovenija)",
43394 "Somalia (Soomaaliya)",
43404 "South Korea (대한민국)",
43409 "South Sudan (جنوب السودان)",
43419 "Sri Lanka (ශ්රී ලංකාව)",
43424 "Sudan (السودان)",
43434 "Svalbard and Jan Mayen",
43445 "Sweden (Sverige)",
43450 "Switzerland (Schweiz)",
43455 "Syria (سوريا)",
43500 "Trinidad and Tobago",
43505 "Tunisia (تونس)",
43510 "Turkey (Türkiye)",
43520 "Turks and Caicos Islands",
43530 "U.S. Virgin Islands",
43540 "Ukraine (Україна)",
43545 "United Arab Emirates (الإمارات العربية المتحدة)",
43567 "Uzbekistan (Oʻzbekiston)",
43577 "Vatican City (Città del Vaticano)",
43588 "Vietnam (Việt Nam)",
43593 "Wallis and Futuna (Wallis-et-Futuna)",
43598 "Western Sahara (الصحراء الغربية)",
43604 "Yemen (اليمن)",
43628 * This script refer to:
43629 * Title: International Telephone Input
43630 * Author: Jack O'Connor
43631 * Code version: v12.1.12
43632 * Availability: https://github.com/jackocnr/intl-tel-input.git
43636 * @class Roo.bootstrap.PhoneInput
43637 * @extends Roo.bootstrap.TriggerField
43638 * An input with International dial-code selection
43640 * @cfg {String} defaultDialCode default '+852'
43641 * @cfg {Array} preferedCountries default []
43644 * Create a new PhoneInput.
43645 * @param {Object} config Configuration options
43648 Roo.bootstrap.PhoneInput = function(config) {
43649 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
43652 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
43654 * @cfg {Roo.data.Store} store [required] The data store to which this combo is bound (defaults to undefined)
43656 listWidth: undefined,
43658 selectedClass: 'active',
43660 invalidClass : "has-warning",
43662 validClass: 'has-success',
43664 allowed: '0123456789',
43669 * @cfg {String} defaultDialCode The default dial code when initializing the input
43671 defaultDialCode: '+852',
43674 * @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
43676 preferedCountries: false,
43678 getAutoCreate : function()
43680 var data = Roo.bootstrap.PhoneInputData();
43681 var align = this.labelAlign || this.parentLabelAlign();
43684 this.allCountries = [];
43685 this.dialCodeMapping = [];
43687 for (var i = 0; i < data.length; i++) {
43689 this.allCountries[i] = {
43693 priority: c[3] || 0,
43694 areaCodes: c[4] || null
43696 this.dialCodeMapping[c[2]] = {
43699 priority: c[3] || 0,
43700 areaCodes: c[4] || null
43712 // type: 'number', -- do not use number - we get the flaky up/down arrows.
43713 maxlength: this.max_length,
43714 cls : 'form-control tel-input',
43715 autocomplete: 'new-password'
43718 var hiddenInput = {
43721 cls: 'hidden-tel-input'
43725 hiddenInput.name = this.name;
43728 if (this.disabled) {
43729 input.disabled = true;
43732 var flag_container = {
43749 cls: this.hasFeedback ? 'has-feedback' : '',
43755 cls: 'dial-code-holder',
43762 cls: 'roo-select2-container input-group',
43769 if (this.fieldLabel.length) {
43772 tooltip: 'This field is required'
43778 cls: 'control-label',
43784 html: this.fieldLabel
43787 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
43793 if(this.indicatorpos == 'right') {
43794 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
43801 if(align == 'left') {
43809 if(this.labelWidth > 12){
43810 label.style = "width: " + this.labelWidth + 'px';
43812 if(this.labelWidth < 13 && this.labelmd == 0){
43813 this.labelmd = this.labelWidth;
43815 if(this.labellg > 0){
43816 label.cls += ' col-lg-' + this.labellg;
43817 input.cls += ' col-lg-' + (12 - this.labellg);
43819 if(this.labelmd > 0){
43820 label.cls += ' col-md-' + this.labelmd;
43821 container.cls += ' col-md-' + (12 - this.labelmd);
43823 if(this.labelsm > 0){
43824 label.cls += ' col-sm-' + this.labelsm;
43825 container.cls += ' col-sm-' + (12 - this.labelsm);
43827 if(this.labelxs > 0){
43828 label.cls += ' col-xs-' + this.labelxs;
43829 container.cls += ' col-xs-' + (12 - this.labelxs);
43839 var settings = this;
43841 ['xs','sm','md','lg'].map(function(size){
43842 if (settings[size]) {
43843 cfg.cls += ' col-' + size + '-' + settings[size];
43847 this.store = new Roo.data.Store({
43848 proxy : new Roo.data.MemoryProxy({}),
43849 reader : new Roo.data.JsonReader({
43860 'name' : 'dialCode',
43864 'name' : 'priority',
43868 'name' : 'areaCodes',
43875 if(!this.preferedCountries) {
43876 this.preferedCountries = [
43883 var p = this.preferedCountries.reverse();
43886 for (var i = 0; i < p.length; i++) {
43887 for (var j = 0; j < this.allCountries.length; j++) {
43888 if(this.allCountries[j].iso2 == p[i]) {
43889 var t = this.allCountries[j];
43890 this.allCountries.splice(j,1);
43891 this.allCountries.unshift(t);
43897 this.store.proxy.data = {
43899 data: this.allCountries
43905 initEvents : function()
43908 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
43910 this.indicator = this.indicatorEl();
43911 this.flag = this.flagEl();
43912 this.dialCodeHolder = this.dialCodeHolderEl();
43914 this.trigger = this.el.select('div.flag-box',true).first();
43915 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
43920 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
43921 _this.list.setWidth(lw);
43924 this.list.on('mouseover', this.onViewOver, this);
43925 this.list.on('mousemove', this.onViewMove, this);
43926 this.inputEl().on("keyup", this.onKeyUp, this);
43927 this.inputEl().on("keypress", this.onKeyPress, this);
43929 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
43931 this.view = new Roo.View(this.list, this.tpl, {
43932 singleSelect:true, store: this.store, selectedClass: this.selectedClass
43935 this.view.on('click', this.onViewClick, this);
43936 this.setValue(this.defaultDialCode);
43939 onTriggerClick : function(e)
43941 Roo.log('trigger click');
43946 if(this.isExpanded()){
43948 this.hasFocus = false;
43950 this.store.load({});
43951 this.hasFocus = true;
43956 isExpanded : function()
43958 return this.list.isVisible();
43961 collapse : function()
43963 if(!this.isExpanded()){
43967 Roo.get(document).un('mousedown', this.collapseIf, this);
43968 Roo.get(document).un('mousewheel', this.collapseIf, this);
43969 this.fireEvent('collapse', this);
43973 expand : function()
43977 if(this.isExpanded() || !this.hasFocus){
43981 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
43982 this.list.setWidth(lw);
43985 this.restrictHeight();
43987 Roo.get(document).on('mousedown', this.collapseIf, this);
43988 Roo.get(document).on('mousewheel', this.collapseIf, this);
43990 this.fireEvent('expand', this);
43993 restrictHeight : function()
43995 this.list.alignTo(this.inputEl(), this.listAlign);
43996 this.list.alignTo(this.inputEl(), this.listAlign);
43999 onViewOver : function(e, t)
44001 if(this.inKeyMode){
44004 var item = this.view.findItemFromChild(t);
44007 var index = this.view.indexOf(item);
44008 this.select(index, false);
44013 onViewClick : function(view, doFocus, el, e)
44015 var index = this.view.getSelectedIndexes()[0];
44017 var r = this.store.getAt(index);
44020 this.onSelect(r, index);
44022 if(doFocus !== false && !this.blockFocus){
44023 this.inputEl().focus();
44027 onViewMove : function(e, t)
44029 this.inKeyMode = false;
44032 select : function(index, scrollIntoView)
44034 this.selectedIndex = index;
44035 this.view.select(index);
44036 if(scrollIntoView !== false){
44037 var el = this.view.getNode(index);
44039 this.list.scrollChildIntoView(el, false);
44044 createList : function()
44046 this.list = Roo.get(document.body).createChild({
44048 cls: 'typeahead typeahead-long dropdown-menu tel-list',
44049 style: 'display:none'
44052 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
44055 collapseIf : function(e)
44057 var in_combo = e.within(this.el);
44058 var in_list = e.within(this.list);
44059 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
44061 if (in_combo || in_list || is_list) {
44067 onSelect : function(record, index)
44069 if(this.fireEvent('beforeselect', this, record, index) !== false){
44071 this.setFlagClass(record.data.iso2);
44072 this.setDialCode(record.data.dialCode);
44073 this.hasFocus = false;
44075 this.fireEvent('select', this, record, index);
44079 flagEl : function()
44081 var flag = this.el.select('div.flag',true).first();
44088 dialCodeHolderEl : function()
44090 var d = this.el.select('input.dial-code-holder',true).first();
44097 setDialCode : function(v)
44099 this.dialCodeHolder.dom.value = '+'+v;
44102 setFlagClass : function(n)
44104 this.flag.dom.className = 'flag '+n;
44107 getValue : function()
44109 var v = this.inputEl().getValue();
44110 if(this.dialCodeHolder) {
44111 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
44116 setValue : function(v)
44118 var d = this.getDialCode(v);
44120 //invalid dial code
44121 if(v.length == 0 || !d || d.length == 0) {
44123 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
44124 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
44130 this.setFlagClass(this.dialCodeMapping[d].iso2);
44131 this.setDialCode(d);
44132 this.inputEl().dom.value = v.replace('+'+d,'');
44133 this.hiddenEl().dom.value = this.getValue();
44138 getDialCode : function(v)
44142 if (v.length == 0) {
44143 return this.dialCodeHolder.dom.value;
44147 if (v.charAt(0) != "+") {
44150 var numericChars = "";
44151 for (var i = 1; i < v.length; i++) {
44152 var c = v.charAt(i);
44155 if (this.dialCodeMapping[numericChars]) {
44156 dialCode = v.substr(1, i);
44158 if (numericChars.length == 4) {
44168 this.setValue(this.defaultDialCode);
44172 hiddenEl : function()
44174 return this.el.select('input.hidden-tel-input',true).first();
44177 // after setting val
44178 onKeyUp : function(e){
44179 this.setValue(this.getValue());
44182 onKeyPress : function(e){
44183 if(this.allowed.indexOf(String.fromCharCode(e.getCharCode())) === -1){
44190 * @class Roo.bootstrap.MoneyField
44191 * @extends Roo.bootstrap.ComboBox
44192 * Bootstrap MoneyField class
44195 * Create a new MoneyField.
44196 * @param {Object} config Configuration options
44199 Roo.bootstrap.MoneyField = function(config) {
44201 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
44205 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
44208 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
44210 allowDecimals : true,
44212 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
44214 decimalSeparator : ".",
44216 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
44218 decimalPrecision : 0,
44220 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
44222 allowNegative : true,
44224 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
44228 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
44230 minValue : Number.NEGATIVE_INFINITY,
44232 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
44234 maxValue : Number.MAX_VALUE,
44236 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
44238 minText : "The minimum value for this field is {0}",
44240 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
44242 maxText : "The maximum value for this field is {0}",
44244 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
44245 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
44247 nanText : "{0} is not a valid number",
44249 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
44253 * @cfg {String} defaults currency of the MoneyField
44254 * value should be in lkey
44256 defaultCurrency : false,
44258 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
44260 thousandsDelimiter : false,
44262 * @cfg {Number} max_length Maximum input field length allowed (defaults to Number.MAX_VALUE)
44273 getAutoCreate : function()
44275 var align = this.labelAlign || this.parentLabelAlign();
44287 cls : 'form-control roo-money-amount-input',
44288 autocomplete: 'new-password'
44291 var hiddenInput = {
44295 cls: 'hidden-number-input'
44298 if(this.max_length) {
44299 input.maxlength = this.max_length;
44303 hiddenInput.name = this.name;
44306 if (this.disabled) {
44307 input.disabled = true;
44310 var clg = 12 - this.inputlg;
44311 var cmd = 12 - this.inputmd;
44312 var csm = 12 - this.inputsm;
44313 var cxs = 12 - this.inputxs;
44317 cls : 'row roo-money-field',
44321 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
44325 cls: 'roo-select2-container input-group',
44329 cls : 'form-control roo-money-currency-input',
44330 autocomplete: 'new-password',
44332 name : this.currencyName
44336 cls : 'input-group-addon',
44350 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
44354 cls: this.hasFeedback ? 'has-feedback' : '',
44365 if (this.fieldLabel.length) {
44368 tooltip: 'This field is required'
44374 cls: 'control-label',
44380 html: this.fieldLabel
44383 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
44389 if(this.indicatorpos == 'right') {
44390 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
44397 if(align == 'left') {
44405 if(this.labelWidth > 12){
44406 label.style = "width: " + this.labelWidth + 'px';
44408 if(this.labelWidth < 13 && this.labelmd == 0){
44409 this.labelmd = this.labelWidth;
44411 if(this.labellg > 0){
44412 label.cls += ' col-lg-' + this.labellg;
44413 input.cls += ' col-lg-' + (12 - this.labellg);
44415 if(this.labelmd > 0){
44416 label.cls += ' col-md-' + this.labelmd;
44417 container.cls += ' col-md-' + (12 - this.labelmd);
44419 if(this.labelsm > 0){
44420 label.cls += ' col-sm-' + this.labelsm;
44421 container.cls += ' col-sm-' + (12 - this.labelsm);
44423 if(this.labelxs > 0){
44424 label.cls += ' col-xs-' + this.labelxs;
44425 container.cls += ' col-xs-' + (12 - this.labelxs);
44436 var settings = this;
44438 ['xs','sm','md','lg'].map(function(size){
44439 if (settings[size]) {
44440 cfg.cls += ' col-' + size + '-' + settings[size];
44447 initEvents : function()
44449 this.indicator = this.indicatorEl();
44451 this.initCurrencyEvent();
44453 this.initNumberEvent();
44456 initCurrencyEvent : function()
44459 throw "can not find store for combo";
44462 this.store = Roo.factory(this.store, Roo.data);
44463 this.store.parent = this;
44467 this.triggerEl = this.el.select('.input-group-addon', true).first();
44469 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
44474 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
44475 _this.list.setWidth(lw);
44478 this.list.on('mouseover', this.onViewOver, this);
44479 this.list.on('mousemove', this.onViewMove, this);
44480 this.list.on('scroll', this.onViewScroll, this);
44483 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
44486 this.view = new Roo.View(this.list, this.tpl, {
44487 singleSelect:true, store: this.store, selectedClass: this.selectedClass
44490 this.view.on('click', this.onViewClick, this);
44492 this.store.on('beforeload', this.onBeforeLoad, this);
44493 this.store.on('load', this.onLoad, this);
44494 this.store.on('loadexception', this.onLoadException, this);
44496 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
44497 "up" : function(e){
44498 this.inKeyMode = true;
44502 "down" : function(e){
44503 if(!this.isExpanded()){
44504 this.onTriggerClick();
44506 this.inKeyMode = true;
44511 "enter" : function(e){
44514 if(this.fireEvent("specialkey", this, e)){
44515 this.onViewClick(false);
44521 "esc" : function(e){
44525 "tab" : function(e){
44528 if(this.fireEvent("specialkey", this, e)){
44529 this.onViewClick(false);
44537 doRelay : function(foo, bar, hname){
44538 if(hname == 'down' || this.scope.isExpanded()){
44539 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
44547 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
44551 initNumberEvent : function(e)
44553 this.inputEl().on("keydown" , this.fireKey, this);
44554 this.inputEl().on("focus", this.onFocus, this);
44555 this.inputEl().on("blur", this.onBlur, this);
44557 this.inputEl().relayEvent('keyup', this);
44559 if(this.indicator){
44560 this.indicator.addClass('invisible');
44563 this.originalValue = this.getValue();
44565 if(this.validationEvent == 'keyup'){
44566 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
44567 this.inputEl().on('keyup', this.filterValidation, this);
44569 else if(this.validationEvent !== false){
44570 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
44573 if(this.selectOnFocus){
44574 this.on("focus", this.preFocus, this);
44577 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
44578 this.inputEl().on("keypress", this.filterKeys, this);
44580 this.inputEl().relayEvent('keypress', this);
44583 var allowed = "0123456789";
44585 if(this.allowDecimals){
44586 allowed += this.decimalSeparator;
44589 if(this.allowNegative){
44593 if(this.thousandsDelimiter) {
44597 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
44599 var keyPress = function(e){
44601 var k = e.getKey();
44603 var c = e.getCharCode();
44606 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
44607 allowed.indexOf(String.fromCharCode(c)) === -1
44613 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
44617 if(allowed.indexOf(String.fromCharCode(c)) === -1){
44622 this.inputEl().on("keypress", keyPress, this);
44626 onTriggerClick : function(e)
44633 this.loadNext = false;
44635 if(this.isExpanded()){
44640 this.hasFocus = true;
44642 if(this.triggerAction == 'all') {
44643 this.doQuery(this.allQuery, true);
44647 this.doQuery(this.getRawValue());
44650 getCurrency : function()
44652 var v = this.currencyEl().getValue();
44657 restrictHeight : function()
44659 this.list.alignTo(this.currencyEl(), this.listAlign);
44660 this.list.alignTo(this.currencyEl(), this.listAlign);
44663 onViewClick : function(view, doFocus, el, e)
44665 var index = this.view.getSelectedIndexes()[0];
44667 var r = this.store.getAt(index);
44670 this.onSelect(r, index);
44674 onSelect : function(record, index){
44676 if(this.fireEvent('beforeselect', this, record, index) !== false){
44678 this.setFromCurrencyData(index > -1 ? record.data : false);
44682 this.fireEvent('select', this, record, index);
44686 setFromCurrencyData : function(o)
44690 this.lastCurrency = o;
44692 if (this.currencyField) {
44693 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
44695 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
44698 this.lastSelectionText = currency;
44700 //setting default currency
44701 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
44702 this.setCurrency(this.defaultCurrency);
44706 this.setCurrency(currency);
44709 setFromData : function(o)
44713 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
44715 this.setFromCurrencyData(c);
44720 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
44722 Roo.log('no value set for '+ (this.name ? this.name : this.id));
44725 this.setValue(value);
44729 setCurrency : function(v)
44731 this.currencyValue = v;
44734 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
44739 setValue : function(v)
44741 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
44747 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
44749 this.inputEl().dom.value = (v == '') ? '' :
44750 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
44752 if(!this.allowZero && v === '0') {
44753 this.hiddenEl().dom.value = '';
44754 this.inputEl().dom.value = '';
44761 getRawValue : function()
44763 var v = this.inputEl().getValue();
44768 getValue : function()
44770 return this.fixPrecision(this.parseValue(this.getRawValue()));
44773 parseValue : function(value)
44775 if(this.thousandsDelimiter) {
44777 r = new RegExp(",", "g");
44778 value = value.replace(r, "");
44781 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
44782 return isNaN(value) ? '' : value;
44786 fixPrecision : function(value)
44788 if(this.thousandsDelimiter) {
44790 r = new RegExp(",", "g");
44791 value = value.replace(r, "");
44794 var nan = isNaN(value);
44796 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
44797 return nan ? '' : value;
44799 return parseFloat(value).toFixed(this.decimalPrecision);
44802 decimalPrecisionFcn : function(v)
44804 return Math.floor(v);
44807 validateValue : function(value)
44809 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
44813 var num = this.parseValue(value);
44816 this.markInvalid(String.format(this.nanText, value));
44820 if(num < this.minValue){
44821 this.markInvalid(String.format(this.minText, this.minValue));
44825 if(num > this.maxValue){
44826 this.markInvalid(String.format(this.maxText, this.maxValue));
44833 validate : function()
44835 if(this.disabled || this.allowBlank){
44840 var currency = this.getCurrency();
44842 if(this.validateValue(this.getRawValue()) && currency.length){
44847 this.markInvalid();
44851 getName: function()
44856 beforeBlur : function()
44862 var v = this.parseValue(this.getRawValue());
44869 onBlur : function()
44873 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
44874 //this.el.removeClass(this.focusClass);
44877 this.hasFocus = false;
44879 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
44883 var v = this.getValue();
44885 if(String(v) !== String(this.startValue)){
44886 this.fireEvent('change', this, v, this.startValue);
44889 this.fireEvent("blur", this);
44892 inputEl : function()
44894 return this.el.select('.roo-money-amount-input', true).first();
44897 currencyEl : function()
44899 return this.el.select('.roo-money-currency-input', true).first();
44902 hiddenEl : function()
44904 return this.el.select('input.hidden-number-input',true).first();
44908 * @class Roo.bootstrap.BezierSignature
44909 * @extends Roo.bootstrap.Component
44910 * Bootstrap BezierSignature class
44911 * This script refer to:
44912 * Title: Signature Pad
44914 * Availability: https://github.com/szimek/signature_pad
44917 * Create a new BezierSignature
44918 * @param {Object} config The config object
44921 Roo.bootstrap.BezierSignature = function(config){
44922 Roo.bootstrap.BezierSignature.superclass.constructor.call(this, config);
44928 Roo.extend(Roo.bootstrap.BezierSignature, Roo.bootstrap.Component,
44935 mouse_btn_down: true,
44938 * @cfg {int} canvas height
44940 canvas_height: '200px',
44943 * @cfg {float|function} Radius of a single dot.
44948 * @cfg {float} Minimum width of a line. Defaults to 0.5.
44953 * @cfg {float} Maximum width of a line. Defaults to 2.5.
44958 * @cfg {integer} Draw the next point at most once per every x milliseconds. Set it to 0 to turn off throttling. Defaults to 16.
44963 * @cfg {integer} Add the next point only if the previous one is farther than x pixels. Defaults to 5.
44968 * @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.
44970 bg_color: 'rgba(0, 0, 0, 0)',
44973 * @cfg {string} Color used to draw the lines. Can be any color format accepted by context.fillStyle. Defaults to "black".
44975 dot_color: 'black',
44978 * @cfg {float} Weight used to modify new velocity based on the previous velocity. Defaults to 0.7.
44980 velocity_filter_weight: 0.7,
44983 * @cfg {function} Callback when stroke begin.
44988 * @cfg {function} Callback when stroke end.
44992 getAutoCreate : function()
44994 var cls = 'roo-signature column';
44997 cls += ' ' + this.cls;
45007 for(var i = 0; i < col_sizes.length; i++) {
45008 if(this[col_sizes[i]]) {
45009 cls += " col-"+col_sizes[i]+"-"+this[col_sizes[i]];
45019 cls: 'roo-signature-body',
45023 cls: 'roo-signature-body-canvas',
45024 height: this.canvas_height,
45025 width: this.canvas_width
45032 style: 'display: none'
45040 initEvents: function()
45042 Roo.bootstrap.BezierSignature.superclass.initEvents.call(this);
45044 var canvas = this.canvasEl();
45046 // mouse && touch event swapping...
45047 canvas.dom.style.touchAction = 'none';
45048 canvas.dom.style.msTouchAction = 'none';
45050 this.mouse_btn_down = false;
45051 canvas.on('mousedown', this._handleMouseDown, this);
45052 canvas.on('mousemove', this._handleMouseMove, this);
45053 Roo.select('html').first().on('mouseup', this._handleMouseUp, this);
45055 if (window.PointerEvent) {
45056 canvas.on('pointerdown', this._handleMouseDown, this);
45057 canvas.on('pointermove', this._handleMouseMove, this);
45058 Roo.select('html').first().on('pointerup', this._handleMouseUp, this);
45061 if ('ontouchstart' in window) {
45062 canvas.on('touchstart', this._handleTouchStart, this);
45063 canvas.on('touchmove', this._handleTouchMove, this);
45064 canvas.on('touchend', this._handleTouchEnd, this);
45067 Roo.EventManager.onWindowResize(this.resize, this, true);
45069 // file input event
45070 this.fileEl().on('change', this.uploadImage, this);
45077 resize: function(){
45079 var canvas = this.canvasEl().dom;
45080 var ctx = this.canvasElCtx();
45081 var img_data = false;
45083 if(canvas.width > 0) {
45084 var img_data = ctx.getImageData(0, 0, canvas.width, canvas.height);
45086 // setting canvas width will clean img data
45089 var style = window.getComputedStyle ?
45090 getComputedStyle(this.el.dom, null) : this.el.dom.currentStyle;
45092 var padding_left = parseInt(style.paddingLeft) || 0;
45093 var padding_right = parseInt(style.paddingRight) || 0;
45095 canvas.width = this.el.dom.clientWidth - padding_left - padding_right;
45098 ctx.putImageData(img_data, 0, 0);
45102 _handleMouseDown: function(e)
45104 if (e.browserEvent.which === 1) {
45105 this.mouse_btn_down = true;
45106 this.strokeBegin(e);
45110 _handleMouseMove: function (e)
45112 if (this.mouse_btn_down) {
45113 this.strokeMoveUpdate(e);
45117 _handleMouseUp: function (e)
45119 if (e.browserEvent.which === 1 && this.mouse_btn_down) {
45120 this.mouse_btn_down = false;
45125 _handleTouchStart: function (e) {
45127 e.preventDefault();
45128 if (e.browserEvent.targetTouches.length === 1) {
45129 // var touch = e.browserEvent.changedTouches[0];
45130 // this.strokeBegin(touch);
45132 this.strokeBegin(e); // assume e catching the correct xy...
45136 _handleTouchMove: function (e) {
45137 e.preventDefault();
45138 // var touch = event.targetTouches[0];
45139 // _this._strokeMoveUpdate(touch);
45140 this.strokeMoveUpdate(e);
45143 _handleTouchEnd: function (e) {
45144 var wasCanvasTouched = e.target === this.canvasEl().dom;
45145 if (wasCanvasTouched) {
45146 e.preventDefault();
45147 // var touch = event.changedTouches[0];
45148 // _this._strokeEnd(touch);
45153 reset: function () {
45154 this._lastPoints = [];
45155 this._lastVelocity = 0;
45156 this._lastWidth = (this.min_width + this.max_width) / 2;
45157 this.canvasElCtx().fillStyle = this.dot_color;
45160 strokeMoveUpdate: function(e)
45162 this.strokeUpdate(e);
45164 if (this.throttle) {
45165 this.throttleStroke(this.strokeUpdate, this.throttle);
45168 this.strokeUpdate(e);
45172 strokeBegin: function(e)
45174 var newPointGroup = {
45175 color: this.dot_color,
45179 if (typeof this.onBegin === 'function') {
45183 this.curve_data.push(newPointGroup);
45185 this.strokeUpdate(e);
45188 strokeUpdate: function(e)
45190 var rect = this.canvasEl().dom.getBoundingClientRect();
45191 var point = new this.Point(e.xy[0] - rect.left, e.xy[1] - rect.top, new Date().getTime());
45192 var lastPointGroup = this.curve_data[this.curve_data.length - 1];
45193 var lastPoints = lastPointGroup.points;
45194 var lastPoint = lastPoints.length > 0 && lastPoints[lastPoints.length - 1];
45195 var isLastPointTooClose = lastPoint
45196 ? point.distanceTo(lastPoint) <= this.min_distance
45198 var color = lastPointGroup.color;
45199 if (!lastPoint || !(lastPoint && isLastPointTooClose)) {
45200 var curve = this.addPoint(point);
45202 this.drawDot({color: color, point: point});
45205 this.drawCurve({color: color, curve: curve});
45215 strokeEnd: function(e)
45217 this.strokeUpdate(e);
45218 if (typeof this.onEnd === 'function') {
45223 addPoint: function (point) {
45224 var _lastPoints = this._lastPoints;
45225 _lastPoints.push(point);
45226 if (_lastPoints.length > 2) {
45227 if (_lastPoints.length === 3) {
45228 _lastPoints.unshift(_lastPoints[0]);
45230 var widths = this.calculateCurveWidths(_lastPoints[1], _lastPoints[2]);
45231 var curve = this.Bezier.fromPoints(_lastPoints, widths, this);
45232 _lastPoints.shift();
45238 calculateCurveWidths: function (startPoint, endPoint) {
45239 var velocity = this.velocity_filter_weight * endPoint.velocityFrom(startPoint) +
45240 (1 - this.velocity_filter_weight) * this._lastVelocity;
45242 var newWidth = Math.max(this.max_width / (velocity + 1), this.min_width);
45245 start: this._lastWidth
45248 this._lastVelocity = velocity;
45249 this._lastWidth = newWidth;
45253 drawDot: function (_a) {
45254 var color = _a.color, point = _a.point;
45255 var ctx = this.canvasElCtx();
45256 var width = typeof this.dot_size === 'function' ? this.dot_size() : this.dot_size;
45258 this.drawCurveSegment(point.x, point.y, width);
45260 ctx.fillStyle = color;
45264 drawCurve: function (_a) {
45265 var color = _a.color, curve = _a.curve;
45266 var ctx = this.canvasElCtx();
45267 var widthDelta = curve.endWidth - curve.startWidth;
45268 var drawSteps = Math.floor(curve.length()) * 2;
45270 ctx.fillStyle = color;
45271 for (var i = 0; i < drawSteps; i += 1) {
45272 var t = i / drawSteps;
45278 var x = uuu * curve.startPoint.x;
45279 x += 3 * uu * t * curve.control1.x;
45280 x += 3 * u * tt * curve.control2.x;
45281 x += ttt * curve.endPoint.x;
45282 var y = uuu * curve.startPoint.y;
45283 y += 3 * uu * t * curve.control1.y;
45284 y += 3 * u * tt * curve.control2.y;
45285 y += ttt * curve.endPoint.y;
45286 var width = curve.startWidth + ttt * widthDelta;
45287 this.drawCurveSegment(x, y, width);
45293 drawCurveSegment: function (x, y, width) {
45294 var ctx = this.canvasElCtx();
45296 ctx.arc(x, y, width, 0, 2 * Math.PI, false);
45297 this.is_empty = false;
45302 var ctx = this.canvasElCtx();
45303 var canvas = this.canvasEl().dom;
45304 ctx.fillStyle = this.bg_color;
45305 ctx.clearRect(0, 0, canvas.width, canvas.height);
45306 ctx.fillRect(0, 0, canvas.width, canvas.height);
45307 this.curve_data = [];
45309 this.is_empty = true;
45314 return this.el.select('input',true).first();
45317 canvasEl: function()
45319 return this.el.select('canvas',true).first();
45322 canvasElCtx: function()
45324 return this.el.select('canvas',true).first().dom.getContext('2d');
45327 getImage: function(type)
45329 if(this.is_empty) {
45334 return this.canvasEl().dom.toDataURL('image/'+type, 1);
45337 drawFromImage: function(img_src)
45339 var img = new Image();
45341 img.onload = function(){
45342 this.canvasElCtx().drawImage(img, 0, 0);
45347 this.is_empty = false;
45350 selectImage: function()
45352 this.fileEl().dom.click();
45355 uploadImage: function(e)
45357 var reader = new FileReader();
45359 reader.onload = function(e){
45360 var img = new Image();
45361 img.onload = function(){
45363 this.canvasElCtx().drawImage(img, 0, 0);
45365 img.src = e.target.result;
45368 reader.readAsDataURL(e.target.files[0]);
45371 // Bezier Point Constructor
45372 Point: (function () {
45373 function Point(x, y, time) {
45376 this.time = time || Date.now();
45378 Point.prototype.distanceTo = function (start) {
45379 return Math.sqrt(Math.pow(this.x - start.x, 2) + Math.pow(this.y - start.y, 2));
45381 Point.prototype.equals = function (other) {
45382 return this.x === other.x && this.y === other.y && this.time === other.time;
45384 Point.prototype.velocityFrom = function (start) {
45385 return this.time !== start.time
45386 ? this.distanceTo(start) / (this.time - start.time)
45393 // Bezier Constructor
45394 Bezier: (function () {
45395 function Bezier(startPoint, control2, control1, endPoint, startWidth, endWidth) {
45396 this.startPoint = startPoint;
45397 this.control2 = control2;
45398 this.control1 = control1;
45399 this.endPoint = endPoint;
45400 this.startWidth = startWidth;
45401 this.endWidth = endWidth;
45403 Bezier.fromPoints = function (points, widths, scope) {
45404 var c2 = this.calculateControlPoints(points[0], points[1], points[2], scope).c2;
45405 var c3 = this.calculateControlPoints(points[1], points[2], points[3], scope).c1;
45406 return new Bezier(points[1], c2, c3, points[2], widths.start, widths.end);
45408 Bezier.calculateControlPoints = function (s1, s2, s3, scope) {
45409 var dx1 = s1.x - s2.x;
45410 var dy1 = s1.y - s2.y;
45411 var dx2 = s2.x - s3.x;
45412 var dy2 = s2.y - s3.y;
45413 var m1 = { x: (s1.x + s2.x) / 2.0, y: (s1.y + s2.y) / 2.0 };
45414 var m2 = { x: (s2.x + s3.x) / 2.0, y: (s2.y + s3.y) / 2.0 };
45415 var l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
45416 var l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
45417 var dxm = m1.x - m2.x;
45418 var dym = m1.y - m2.y;
45419 var k = l2 / (l1 + l2);
45420 var cm = { x: m2.x + dxm * k, y: m2.y + dym * k };
45421 var tx = s2.x - cm.x;
45422 var ty = s2.y - cm.y;
45424 c1: new scope.Point(m1.x + tx, m1.y + ty),
45425 c2: new scope.Point(m2.x + tx, m2.y + ty)
45428 Bezier.prototype.length = function () {
45433 for (var i = 0; i <= steps; i += 1) {
45435 var cx = this.point(t, this.startPoint.x, this.control1.x, this.control2.x, this.endPoint.x);
45436 var cy = this.point(t, this.startPoint.y, this.control1.y, this.control2.y, this.endPoint.y);
45438 var xdiff = cx - px;
45439 var ydiff = cy - py;
45440 length += Math.sqrt(xdiff * xdiff + ydiff * ydiff);
45447 Bezier.prototype.point = function (t, start, c1, c2, end) {
45448 return (start * (1.0 - t) * (1.0 - t) * (1.0 - t))
45449 + (3.0 * c1 * (1.0 - t) * (1.0 - t) * t)
45450 + (3.0 * c2 * (1.0 - t) * t * t)
45451 + (end * t * t * t);
45456 throttleStroke: function(fn, wait) {
45457 if (wait === void 0) { wait = 250; }
45459 var timeout = null;
45463 var later = function () {
45464 previous = Date.now();
45466 result = fn.apply(storedContext, storedArgs);
45468 storedContext = null;
45472 return function wrapper() {
45474 for (var _i = 0; _i < arguments.length; _i++) {
45475 args[_i] = arguments[_i];
45477 var now = Date.now();
45478 var remaining = wait - (now - previous);
45479 storedContext = this;
45481 if (remaining <= 0 || remaining > wait) {
45483 clearTimeout(timeout);
45487 result = fn.apply(storedContext, storedArgs);
45489 storedContext = null;
45493 else if (!timeout) {
45494 timeout = window.setTimeout(later, remaining);