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 * Bootstrap Body class
856 * @param {Object} config The config object
859 Roo.bootstrap.Body = function(config){
861 config = config || {};
863 Roo.bootstrap.Body.superclass.constructor.call(this, config);
864 this.el = Roo.get(config.el ? config.el : document.body );
865 if (this.cls && this.cls.length) {
866 Roo.get(document.body).addClass(this.cls);
870 Roo.extend(Roo.bootstrap.Body, Roo.bootstrap.Component, {
872 is_body : true,// just to make sure it's constructed?
877 onRender : function(ct, position)
879 /* Roo.log("Roo.bootstrap.Body - onRender");
880 if (this.cls && this.cls.length) {
881 Roo.get(document.body).addClass(this.cls);
900 * @class Roo.bootstrap.ButtonGroup
901 * @extends Roo.bootstrap.Component
902 * Bootstrap ButtonGroup class
903 * @cfg {String} size lg | sm | xs (default empty normal)
904 * @cfg {String} align vertical | justified (default none)
905 * @cfg {String} direction up | down (default down)
906 * @cfg {Boolean} toolbar false | true
907 * @cfg {Boolean} btn true | false
912 * @param {Object} config The config object
915 Roo.bootstrap.ButtonGroup = function(config){
916 Roo.bootstrap.ButtonGroup.superclass.constructor.call(this, config);
919 Roo.extend(Roo.bootstrap.ButtonGroup, Roo.bootstrap.Component, {
927 getAutoCreate : function(){
933 cfg.html = this.html || cfg.html;
944 if (['vertical','justified'].indexOf(this.align)!==-1) {
945 cfg.cls = 'btn-group-' + this.align;
947 if (this.align == 'justified') {
948 console.log(this.items);
952 if (['lg','sm','xs'].indexOf(this.size)!==-1) {
953 cfg.cls += ' btn-group-' + this.size;
956 if (this.direction == 'up') {
957 cfg.cls += ' dropup' ;
963 * Add a button to the group (similar to NavItem API.)
965 addItem : function(cfg)
967 var cn = new Roo.bootstrap.Button(cfg);
969 cn.parentId = this.id;
970 cn.onRender(this.el, null);
984 * @class Roo.bootstrap.Button
985 * @extends Roo.bootstrap.Component
986 * Bootstrap Button class
987 * @cfg {String} html The button content
988 * @cfg {String} weight (default|primary|secondary|success|info|warning|danger|link|light|dark) default
989 * @cfg {String} badge_weight (default|primary|secondary|success|info|warning|danger|link|light|dark) default (same as button)
990 * @cfg {Boolean} outline default false (except for weight=default which emulates old behaveiour with an outline)
991 * @cfg {String} size (lg|sm|xs)
992 * @cfg {String} tag (a|input|submit)
993 * @cfg {String} href empty or href
994 * @cfg {Boolean} disabled default false;
995 * @cfg {Boolean} isClose default false;
996 * @cfg {String} glyphicon depricated - use fa
997 * @cfg {String} fa fontawesome icon - eg. 'comment' - without the fa/fas etc..
998 * @cfg {String} badge text for badge
999 * @cfg {String} theme (default|glow)
1000 * @cfg {Boolean} inverse dark themed version
1001 * @cfg {Boolean} toggle is it a slidy toggle button
1002 * @cfg {Boolean} pressed default null - if the button ahs active state
1003 * @cfg {String} ontext text for on slidy toggle state
1004 * @cfg {String} offtext text for off slidy toggle state
1005 * @cfg {Boolean} preventDefault default true (stop click event triggering the URL if it's a link.)
1006 * @cfg {Boolean} removeClass remove the standard class..
1007 * @cfg {String} target (_self|_blank|_parent|_top|other) target for a href.
1008 * @cfg {Boolean} grpup if parent is a btn group - then it turns it into a toogleGroup.
1011 * Create a new button
1012 * @param {Object} config The config object
1016 Roo.bootstrap.Button = function(config){
1017 Roo.bootstrap.Button.superclass.constructor.call(this, config);
1023 * When a button is pressed
1024 * @param {Roo.bootstrap.Button} btn
1025 * @param {Roo.EventObject} e
1030 * When a button is double clicked
1031 * @param {Roo.bootstrap.Button} btn
1032 * @param {Roo.EventObject} e
1037 * After the button has been toggles
1038 * @param {Roo.bootstrap.Button} btn
1039 * @param {Roo.EventObject} e
1040 * @param {boolean} pressed (also available as button.pressed)
1046 Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, {
1067 preventDefault: true,
1076 getAutoCreate : function(){
1084 if (['a', 'button', 'input', 'submit'].indexOf(this.tag) < 0) {
1085 throw "Invalid value for tag: " + this.tag + ". must be a, button, input or submit.";
1086 this.tag = 'button';
1090 cfg.html = '<span class="roo-button-text">' + (this.html || cfg.html) + '</span>';
1092 if (this.toggle == true) {
1095 cls: 'slider-frame roo-button',
1099 'data-on-text':'ON',
1100 'data-off-text':'OFF',
1101 cls: 'slider-button',
1106 // why are we validating the weights?
1107 if (Roo.bootstrap.Button.weights.indexOf(this.weight) > -1) {
1108 cfg.cls += ' ' + this.weight;
1115 cfg.cls += ' close';
1117 cfg["aria-hidden"] = true;
1119 cfg.html = "×";
1125 if (this.theme==='default') {
1126 cfg.cls = 'btn roo-button';
1128 //if (this.parentType != 'Navbar') {
1129 this.weight = this.weight.length ? this.weight : 'default';
1131 if (Roo.bootstrap.Button.weights.indexOf(this.weight) > -1) {
1133 var outline = this.outline || this.weight == 'default' ? 'outline-' : '';
1134 var weight = this.weight == 'default' ? 'secondary' : this.weight;
1135 cfg.cls += ' btn-' + outline + weight;
1136 if (this.weight == 'default') {
1138 cfg.cls += ' btn-' + this.weight;
1141 } else if (this.theme==='glow') {
1144 cfg.cls = 'btn-glow roo-button';
1146 if (Roo.bootstrap.Button.weights.indexOf(this.weight) > -1) {
1148 cfg.cls += ' ' + this.weight;
1154 this.cls += ' inverse';
1158 if (this.active || this.pressed === true) {
1159 cfg.cls += ' active';
1162 if (this.disabled) {
1163 cfg.disabled = 'disabled';
1167 Roo.log('changing to ul' );
1169 this.glyphicon = 'caret';
1170 if (Roo.bootstrap.version == 4) {
1171 this.fa = 'caret-down';
1176 cfg.cls += this.size.length ? (' btn-' + this.size) : '';
1178 //gsRoo.log(this.parentType);
1179 if (this.parentType === 'Navbar' && !this.parent().bar) {
1180 Roo.log('changing to li?');
1189 href : this.href || '#'
1192 cfg.cn[0].html = this.html + ' <span class="caret"></span>';
1193 cfg.cls += ' dropdown';
1200 cfg.cls += this.parentType === 'Navbar' ? ' navbar-btn' : '';
1202 if (this.glyphicon) {
1203 cfg.html = ' ' + cfg.html;
1208 cls: 'glyphicon glyphicon-' + this.glyphicon
1213 cfg.html = ' ' + cfg.html;
1218 cls: 'fa fas fa-' + this.fa
1228 // cfg.cls='btn roo-button';
1232 var value = cfg.html;
1237 cls: 'glyphicon glyphicon-' + this.glyphicon,
1244 cls: 'fa fas fa-' + this.fa,
1249 var bw = this.badge_weight.length ? this.badge_weight :
1250 (this.weight.length ? this.weight : 'secondary');
1251 bw = bw == 'default' ? 'secondary' : bw;
1257 cls: 'badge badge-' + bw,
1266 cfg.cls += ' dropdown';
1267 cfg.html = typeof(cfg.html) != 'undefined' ?
1268 cfg.html + ' <span class="caret"></span>' : '<span class="caret"></span>';
1271 if (cfg.tag !== 'a' && this.href !== '') {
1272 throw "Tag must be a to set href.";
1273 } else if (this.href.length > 0) {
1274 cfg.href = this.href;
1277 if(this.removeClass){
1282 cfg.target = this.target;
1287 initEvents: function() {
1288 // Roo.log('init events?');
1289 // Roo.log(this.el.dom);
1292 if (typeof (this.menu) != 'undefined') {
1293 this.menu.parentType = this.xtype;
1294 this.menu.triggerEl = this.el;
1295 this.addxtype(Roo.apply({}, this.menu));
1299 if (this.el.hasClass('roo-button')) {
1300 this.el.on('click', this.onClick, this);
1301 this.el.on('dblclick', this.onDblClick, this);
1303 this.el.select('.roo-button').on('click', this.onClick, this);
1304 this.el.select('.roo-button').on('dblclick', this.onDblClick, this);
1308 if(this.removeClass){
1309 this.el.on('click', this.onClick, this);
1312 if (this.group === true) {
1313 if (this.pressed === false || this.pressed === true) {
1316 this.pressed = false;
1317 this.setActive(this.pressed);
1322 this.el.enableDisplayMode();
1325 onClick : function(e)
1327 if (this.disabled) {
1331 Roo.log('button on click ');
1332 if(this.preventDefault){
1341 this.setActive(true);
1342 var pi = this.parent().items;
1343 for (var i = 0;i < pi.length;i++) {
1344 if (this == pi[i]) {
1347 if (pi[i].el.hasClass('roo-button')) {
1348 pi[i].setActive(false);
1351 this.fireEvent('click', this, e);
1355 if (this.pressed === true || this.pressed === false) {
1356 this.toggleActive(e);
1360 this.fireEvent('click', this, e);
1362 onDblClick: function(e)
1364 if (this.disabled) {
1367 if(this.preventDefault){
1370 this.fireEvent('dblclick', this, e);
1373 * Enables this button
1377 this.disabled = false;
1378 this.el.removeClass('disabled');
1379 this.el.dom.removeAttribute("disabled");
1383 * Disable this button
1385 disable : function()
1387 this.disabled = true;
1388 this.el.addClass('disabled');
1389 this.el.attr("disabled", "disabled")
1392 * sets the active state on/off,
1393 * @param {Boolean} state (optional) Force a particular state
1395 setActive : function(v) {
1397 this.el[v ? 'addClass' : 'removeClass']('active');
1401 * toggles the current active state
1403 toggleActive : function(e)
1405 this.setActive(!this.pressed); // this modifies pressed...
1406 this.fireEvent('toggle', this, e, this.pressed);
1409 * get the current active state
1410 * @return {boolean} true if it's active
1412 isActive : function()
1414 return this.el.hasClass('active');
1417 * set the text of the first selected button
1419 setText : function(str)
1421 this.el.select('.roo-button-text',true).first().dom.innerHTML = str;
1424 * get the text of the first selected button
1426 getText : function()
1428 return this.el.select('.roo-button-text',true).first().dom.innerHTML;
1431 setWeight : function(str)
1433 this.el.removeClass(Roo.bootstrap.Button.weights.map(function(w) { return 'btn-' + w; } ) );
1434 this.el.removeClass(Roo.bootstrap.Button.weights.map(function(w) { return 'btn-outline-' + w; } ) );
1436 var outline = this.outline ? 'outline-' : '';
1437 if (str == 'default') {
1438 this.el.addClass('btn-default btn-outline-secondary');
1441 this.el.addClass('btn-' + outline + str);
1446 // fixme - this is probably generic bootstrap - should go in some kind of enum file.. - like sizes.
1448 Roo.bootstrap.Button.weights = [
1468 * @class Roo.bootstrap.Column
1469 * @extends Roo.bootstrap.Component
1470 * Bootstrap Column class
1471 * @cfg {Number} xs colspan out of 12 for mobile-sized screens or 0 for hidden
1472 * @cfg {Number} sm colspan out of 12 for tablet-sized screens or 0 for hidden
1473 * @cfg {Number} md colspan out of 12 for computer-sized screens or 0 for hidden
1474 * @cfg {Number} lg colspan out of 12 for large computer-sized screens or 0 for hidden
1475 * @cfg {Number} xsoff colspan offset out of 12 for mobile-sized screens or 0 for hidden
1476 * @cfg {Number} smoff colspan offset out of 12 for tablet-sized screens or 0 for hidden
1477 * @cfg {Number} mdoff colspan offset out of 12 for computer-sized screens or 0 for hidden
1478 * @cfg {Number} lgoff colspan offset out of 12 for large computer-sized screens or 0 for hidden
1481 * @cfg {Boolean} hidden (true|false) hide the element
1482 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1483 * @cfg {String} fa (ban|check|...) font awesome icon
1484 * @cfg {Number} fasize (1|2|....) font awsome size
1486 * @cfg {String} icon (info-sign|check|...) glyphicon name
1488 * @cfg {String} html content of column.
1491 * Create a new Column
1492 * @param {Object} config The config object
1495 Roo.bootstrap.Column = function(config){
1496 Roo.bootstrap.Column.superclass.constructor.call(this, config);
1499 Roo.extend(Roo.bootstrap.Column, Roo.bootstrap.Component, {
1517 getAutoCreate : function(){
1518 var cfg = Roo.apply({}, Roo.bootstrap.Column.superclass.getAutoCreate.call(this));
1526 var sizes = ['xs','sm','md','lg'];
1527 sizes.map(function(size ,ix){
1528 //Roo.log( size + ':' + settings[size]);
1530 if (settings[size+'off'] !== false) {
1531 cfg.cls += ' col-' + size + '-offset-' + settings[size+'off'] ;
1534 if (settings[size] === false) {
1538 if (!settings[size]) { // 0 = hidden
1539 cfg.cls += ' hidden-' + size + ' hidden-' + size + '-down';
1541 for (var i = ix; i > -1; i--) {
1542 cfg.cls += ' d-' + sizes[i] + '-none';
1548 cfg.cls += ' col-' + size + '-' + settings[size] + (
1549 size == 'xs' ? (' col-' + settings[size] ) : '' // bs4 col-{num} replaces col-xs
1555 cfg.cls += ' hidden';
1558 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1559 cfg.cls +=' alert alert-' + this.alert;
1563 if (this.html.length) {
1564 cfg.html = this.html;
1568 if (this.fasize > 1) {
1569 fasize = ' fa-' + this.fasize + 'x';
1571 cfg.html = '<i class="fa fa-'+this.fa + fasize + '"></i>' + (cfg.html || '');
1576 cfg.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + (cfg.html || '');
1595 * @class Roo.bootstrap.Container
1596 * @extends Roo.bootstrap.Component
1598 * Bootstrap Container class
1599 * @cfg {Boolean} jumbotron is it a jumbotron element
1600 * @cfg {String} html content of element
1601 * @cfg {String} well (lg|sm|md) a well, large, small or medium.
1602 * @cfg {String} panel (default|primary|success|info|warning|danger) render as panel - type - primary/success.....
1603 * @cfg {String} header content of header (for panel)
1604 * @cfg {String} footer content of footer (for panel)
1605 * @cfg {String} sticky (footer|wrap|push) block to use as footer or body- needs css-bootstrap/sticky-footer.css
1606 * @cfg {String} tag (header|aside|section) type of HTML tag.
1607 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1608 * @cfg {String} fa font awesome icon
1609 * @cfg {String} icon (info-sign|check|...) glyphicon name
1610 * @cfg {Boolean} hidden (true|false) hide the element
1611 * @cfg {Boolean} expandable (true|false) default false
1612 * @cfg {Boolean} expanded (true|false) default true
1613 * @cfg {String} rheader contet on the right of header
1614 * @cfg {Boolean} clickable (true|false) default false
1618 * Create a new Container
1619 * @param {Object} config The config object
1622 Roo.bootstrap.Container = function(config){
1623 Roo.bootstrap.Container.superclass.constructor.call(this, config);
1629 * After the panel has been expand
1631 * @param {Roo.bootstrap.Container} this
1636 * After the panel has been collapsed
1638 * @param {Roo.bootstrap.Container} this
1643 * When a element is chick
1644 * @param {Roo.bootstrap.Container} this
1645 * @param {Roo.EventObject} e
1651 Roo.extend(Roo.bootstrap.Container, Roo.bootstrap.Component, {
1669 getChildContainer : function() {
1675 if (this.panel.length) {
1676 return this.el.select('.panel-body',true).first();
1683 getAutoCreate : function(){
1686 tag : this.tag || 'div',
1690 if (this.jumbotron) {
1691 cfg.cls = 'jumbotron';
1696 // - this is applied by the parent..
1698 // cfg.cls = this.cls + '';
1701 if (this.sticky.length) {
1703 var bd = Roo.get(document.body);
1704 if (!bd.hasClass('bootstrap-sticky')) {
1705 bd.addClass('bootstrap-sticky');
1706 Roo.select('html',true).setStyle('height', '100%');
1709 cfg.cls += 'bootstrap-sticky-' + this.sticky;
1713 if (this.well.length) {
1714 switch (this.well) {
1717 cfg.cls +=' well well-' +this.well;
1726 cfg.cls += ' hidden';
1730 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1731 cfg.cls +=' alert alert-' + this.alert;
1736 if (this.panel.length) {
1737 cfg.cls += ' panel panel-' + this.panel;
1739 if (this.header.length) {
1743 if(this.expandable){
1745 cfg.cls = cfg.cls + ' expandable';
1749 cls: (this.expanded ? 'fa fa-minus' : 'fa fa-plus')
1757 cls : 'panel-title',
1758 html : (this.expandable ? ' ' : '') + this.header
1762 cls: 'panel-header-right',
1768 cls : 'panel-heading',
1769 style : this.expandable ? 'cursor: pointer' : '',
1777 cls : 'panel-body' + (this.expanded ? '' : ' hide'),
1782 if (this.footer.length) {
1784 cls : 'panel-footer',
1793 body.html = this.html || cfg.html;
1794 // prefix with the icons..
1796 body.html = '<i class="fa fa-'+this.fa + '"></i>' + body.html ;
1799 body.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + body.html ;
1804 if ((!this.cls || !this.cls.length) && (!cfg.cls || !cfg.cls.length)) {
1805 cfg.cls = 'container';
1811 initEvents: function()
1813 if(this.expandable){
1814 var headerEl = this.headerEl();
1817 headerEl.on('click', this.onToggleClick, this);
1822 this.el.on('click', this.onClick, this);
1827 onToggleClick : function()
1829 var headerEl = this.headerEl();
1845 if(this.fireEvent('expand', this)) {
1847 this.expanded = true;
1849 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).show();
1851 this.el.select('.panel-body',true).first().removeClass('hide');
1853 var toggleEl = this.toggleEl();
1859 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-minus']);
1864 collapse : function()
1866 if(this.fireEvent('collapse', this)) {
1868 this.expanded = false;
1870 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).hide();
1871 this.el.select('.panel-body',true).first().addClass('hide');
1873 var toggleEl = this.toggleEl();
1879 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-plus']);
1883 toggleEl : function()
1885 if(!this.el || !this.panel.length || !this.header.length || !this.expandable){
1889 return this.el.select('.panel-heading .fa',true).first();
1892 headerEl : function()
1894 if(!this.el || !this.panel.length || !this.header.length){
1898 return this.el.select('.panel-heading',true).first()
1903 if(!this.el || !this.panel.length){
1907 return this.el.select('.panel-body',true).first()
1910 titleEl : function()
1912 if(!this.el || !this.panel.length || !this.header.length){
1916 return this.el.select('.panel-title',true).first();
1919 setTitle : function(v)
1921 var titleEl = this.titleEl();
1927 titleEl.dom.innerHTML = v;
1930 getTitle : function()
1933 var titleEl = this.titleEl();
1939 return titleEl.dom.innerHTML;
1942 setRightTitle : function(v)
1944 var t = this.el.select('.panel-header-right',true).first();
1950 t.dom.innerHTML = v;
1953 onClick : function(e)
1957 this.fireEvent('click', this, e);
1964 * This is BS4's Card element.. - similar to our containers probably..
1968 * @class Roo.bootstrap.Card
1969 * @extends Roo.bootstrap.Component
1970 * Bootstrap Card class
1973 * possible... may not be implemented..
1974 * @cfg {String} header_image src url of image.
1975 * @cfg {String|Object} header
1976 * @cfg {Number} header_size (0|1|2|3|4|5) H1 or H2 etc.. 0 indicates default
1977 * @cfg {Number} header_weight (primary|secondary|success|info|warning|danger|light|dark)
1979 * @cfg {String} title
1980 * @cfg {String} subtitle
1981 * @cfg {String|Boolean} html -- html contents - or just use children.. use false to hide it..
1982 * @cfg {String} footer
1984 * @cfg {String} weight (primary|warning|info|danger|secondary|success|light|dark)
1986 * @cfg {String} margin (0|1|2|3|4|5|auto)
1987 * @cfg {String} margin_top (0|1|2|3|4|5|auto)
1988 * @cfg {String} margin_bottom (0|1|2|3|4|5|auto)
1989 * @cfg {String} margin_left (0|1|2|3|4|5|auto)
1990 * @cfg {String} margin_right (0|1|2|3|4|5|auto)
1991 * @cfg {String} margin_x (0|1|2|3|4|5|auto)
1992 * @cfg {String} margin_y (0|1|2|3|4|5|auto)
1994 * @cfg {String} padding (0|1|2|3|4|5)
1995 * @cfg {String} padding_top (0|1|2|3|4|5)next_to_card
1996 * @cfg {String} padding_bottom (0|1|2|3|4|5)
1997 * @cfg {String} padding_left (0|1|2|3|4|5)
1998 * @cfg {String} padding_right (0|1|2|3|4|5)
1999 * @cfg {String} padding_x (0|1|2|3|4|5)
2000 * @cfg {String} padding_y (0|1|2|3|4|5)
2002 * @cfg {String} display (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
2003 * @cfg {String} display_xs (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
2004 * @cfg {String} display_sm (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
2005 * @cfg {String} display_lg (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
2006 * @cfg {String} display_xl (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
2008 * @config {Boolean} dragable if this card can be dragged.
2009 * @config {String} drag_group group for drag
2010 * @config {Boolean} dropable if this card can recieve other cards being dropped onto it..
2011 * @config {String} drop_group group for drag
2013 * @config {Boolean} collapsable can the body be collapsed.
2014 * @config {Boolean} collapsed is the body collapsed when rendered...
2015 * @config {Boolean} rotateable can the body be rotated by clicking on it..
2016 * @config {Boolean} rotated is the body rotated when rendered...
2019 * Create a new Container
2020 * @param {Object} config The config object
2023 Roo.bootstrap.Card = function(config){
2024 Roo.bootstrap.Card.superclass.constructor.call(this, config);
2030 * When a element a card is dropped
2031 * @param {Roo.bootstrap.Card} this
2034 * @param {Roo.bootstrap.Card} move_card the card being dropped?
2035 * @param {String} position 'above' or 'below'
2036 * @param {Roo.bootstrap.Card} next_to_card What card position is relative to of 'false' for empty list.
2042 * When a element a card is rotate
2043 * @param {Roo.bootstrap.Card} this
2044 * @param {Roo.Element} n the node being dropped?
2045 * @param {Boolean} rotate status
2050 * When a card element is dragged over ready to drop (return false to block dropable)
2051 * @param {Roo.bootstrap.Card} this
2052 * @param {Object} data from dragdrop
2060 Roo.extend(Roo.bootstrap.Card, Roo.bootstrap.Component, {
2065 margin: '', /// may be better in component?
2095 collapsable : false,
2104 childContainer : false,
2105 dropEl : false, /// the dom placeholde element that indicates drop location.
2106 containerEl: false, // body container
2107 bodyEl: false, // card-body
2108 headerContainerEl : false, //
2110 header_imageEl : false,
2113 layoutCls : function()
2117 Roo.log(this.margin_bottom.length);
2118 ['', 'top', 'bottom', 'left', 'right', 'x', 'y' ].forEach(function(v) {
2119 // in theory these can do margin_top : ml-xs-3 ??? but we don't support that yet
2121 if (('' + t['margin' + (v.length ? '_' : '') + v]).length) {
2122 cls += ' m' + (v.length ? v[0] : '') + '-' + t['margin' + (v.length ? '_' : '') + v];
2124 if (('' + t['padding' + (v.length ? '_' : '') + v]).length) {
2125 cls += ' p' + (v.length ? v[0] : '') + '-' + t['padding' + (v.length ? '_' : '') + v];
2129 ['', 'xs', 'sm', 'lg', 'xl'].forEach(function(v) {
2130 if (('' + t['display' + (v.length ? '_' : '') + v]).length) {
2131 cls += ' d' + (v.length ? '-' : '') + v + '-' + t['display' + (v.length ? '_' : '') + v]
2135 // more generic support?
2143 // Roo.log("Call onRender: " + this.xtype);
2144 /* We are looking at something like this.
2146 <img src="..." class="card-img-top" alt="...">
2147 <div class="card-body">
2148 <h5 class="card-title">Card title</h5>
2149 <h6 class="card-subtitle mb-2 text-muted">Card subtitle</h6>
2151 >> this bit is really the body...
2152 <div> << we will ad dthis in hopefully it will not break shit.
2154 ** card text does not actually have any styling...
2156 <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>
2159 <a href="#" class="card-link">Card link</a>
2162 <div class="card-footer">
2163 <small class="text-muted">Last updated 3 mins ago</small>
2167 getAutoCreate : function(){
2175 if (this.weight.length && this.weight != 'light') {
2176 cfg.cls += ' text-white';
2178 cfg.cls += ' text-dark'; // need as it's nested..
2180 if (this.weight.length) {
2181 cfg.cls += ' bg-' + this.weight;
2184 cfg.cls += ' ' + this.layoutCls();
2187 var hdr_ctr = false;
2188 if (this.header.length) {
2190 tag : this.header_size > 0 ? 'h' + this.header_size : 'div',
2191 cls : 'card-header ' + (this.header_weight ? 'bg-' + this.header_weight : ''),
2199 cls : 'card-header d-none ' + (this.header_weight ? 'bg-' + this.header_weight : ''),
2205 if (this.collapsable) {
2208 cls : 'd-block user-select-none',
2212 cls : 'roo-collapse-toggle fa fa-chevron-down float-right ' + (this.collapsed ? 'collapsed' : '')
2217 hdr.cn.push(hdr_ctr);
2222 cls: 'roo-card-header-ctr' + ( this.header.length ? '' : ' d-none'),
2227 if (this.header_image.length) {
2230 cls : 'card-img-top',
2231 src: this.header_image // escape?
2236 cls : 'card-img-top d-none'
2242 cls : 'card-body' + (this.html === false ? ' d-none' : ''),
2246 if (this.collapsable || this.rotateable) {
2249 cls : 'roo-collapsable collapse ' + (this.collapsed || this.rotated ? '' : 'show'),
2256 if (this.title.length) {
2260 src: this.title // escape?
2264 if (this.subtitle.length) {
2268 src: this.subtitle // escape?
2274 cls : 'roo-card-body-ctr'
2277 if (this.html.length) {
2283 // fixme ? handle objects?
2285 if (this.footer.length) {
2288 cls : 'card-footer ' + (this.rotated ? 'd-none' : ''),
2293 cfg.cn.push({cls : 'card-footer d-none'});
2302 getCardHeader : function()
2304 var ret = this.el.select('.card-header',true).first();
2305 if (ret.hasClass('d-none')) {
2306 ret.removeClass('d-none');
2311 getCardFooter : function()
2313 var ret = this.el.select('.card-footer',true).first();
2314 if (ret.hasClass('d-none')) {
2315 ret.removeClass('d-none');
2320 getCardImageTop : function()
2322 var ret = this.header_imageEl;
2323 if (ret.hasClass('d-none')) {
2324 ret.removeClass('d-none');
2330 getChildContainer : function()
2336 return this.el.select('.roo-card-body-ctr',true).first();
2339 initEvents: function()
2341 this.bodyEl = this.el.select('.card-body',true).first();
2342 this.containerEl = this.getChildContainer();
2344 this.dragZone = new Roo.dd.DragZone(this.getEl(), {
2345 containerScroll: true,
2346 ddGroup: this.drag_group || 'default_card_drag_group'
2348 this.dragZone.getDragData = this.getDragData.createDelegate(this);
2350 if (this.dropable) {
2351 this.dropZone = new Roo.dd.DropZone(this.el.select('.card-body',true).first() , {
2352 containerScroll: true,
2353 ddGroup: this.drop_group || 'default_card_drag_group'
2355 this.dropZone.getTargetFromEvent = this.getTargetFromEvent.createDelegate(this);
2356 this.dropZone.onNodeEnter = this.onNodeEnter.createDelegate(this);
2357 this.dropZone.onNodeOver = this.onNodeOver.createDelegate(this);
2358 this.dropZone.onNodeOut = this.onNodeOut.createDelegate(this);
2359 this.dropZone.onNodeDrop = this.onNodeDrop.createDelegate(this);
2362 if (this.collapsable) {
2363 this.el.select('.card-header',true).on('click', this.onToggleCollapse, this);
2365 if (this.rotateable) {
2366 this.el.select('.card-header',true).on('click', this.onToggleRotate, this);
2368 this.collapsableEl = this.el.select('.roo-collapsable',true).first();
2370 this.footerEl = this.el.select('.card-footer',true).first();
2371 this.collapsableToggleEl = this.el.select('.roo-collapse-toggle',true).first();
2372 this.headerContainerEl = this.el.select('.roo-card-header-ctr',true).first();
2373 this.headerEl = this.el.select('.card-header',true).first();
2376 this.el.addClass('roo-card-rotated');
2377 this.fireEvent('rotate', this, true);
2379 this.header_imageEl = this.el.select('.card-img-top',true).first();
2380 this.header_imageEl.on('load', this.onHeaderImageLoad, this );
2383 getDragData : function(e)
2385 var target = this.getEl();
2387 //this.handleSelection(e);
2392 nodes: this.getEl(),
2397 dragData.ddel = target.dom ; // the div element
2398 Roo.log(target.getWidth( ));
2399 dragData.ddel.style.width = target.getWidth() + 'px';
2406 * Part of the Roo.dd.DropZone interface. If no target node is found, the
2407 * whole Element becomes the target, and this causes the drop gesture to append.
2409 * Returns an object:
2412 position : 'below' or 'above'
2413 card : relateive to card OBJECT (or true for no cards listed)
2414 items_n : relative to nth item in list
2415 card_n : relative to nth card in list
2420 getTargetFromEvent : function(e, dragged_card_el)
2422 var target = e.getTarget();
2423 while ((target !== null) && (target.parentNode != this.containerEl.dom)) {
2424 target = target.parentNode;
2435 //Roo.log([ 'target' , target ? target.id : '--nothing--']);
2436 // see if target is one of the 'cards'...
2439 //Roo.log(this.items.length);
2442 var last_card_n = 0;
2444 for (var i = 0;i< this.items.length;i++) {
2446 if (!this.items[i].el.hasClass('card')) {
2449 pos = this.getDropPoint(e, this.items[i].el.dom);
2451 cards_len = ret.cards.length;
2452 //Roo.log(this.items[i].el.dom.id);
2453 ret.cards.push(this.items[i]);
2455 if (ret.card_n < 0 && pos == 'above') {
2456 ret.position = cards_len > 0 ? 'below' : pos;
2457 ret.items_n = i > 0 ? i - 1 : 0;
2458 ret.card_n = cards_len > 0 ? cards_len - 1 : 0;
2459 ret.card = ret.cards[ret.card_n];
2462 if (!ret.cards.length) {
2464 ret.position = 'below';
2468 // could not find a card.. stick it at the end..
2469 if (ret.card_n < 0) {
2470 ret.card_n = last_card_n;
2471 ret.card = ret.cards[last_card_n];
2472 ret.items_n = this.items.indexOf(ret.cards[last_card_n]);
2473 ret.position = 'below';
2476 if (this.items[ret.items_n].el == dragged_card_el) {
2480 if (ret.position == 'below') {
2481 var card_after = ret.card_n+1 == ret.cards.length ? false : ret.cards[ret.card_n+1];
2483 if (card_after && card_after.el == dragged_card_el) {
2490 var card_before = ret.card_n > 0 ? ret.cards[ret.card_n-1] : false;
2492 if (card_before && card_before.el == dragged_card_el) {
2499 onNodeEnter : function(n, dd, e, data){
2502 onNodeOver : function(n, dd, e, data)
2505 var target_info = this.getTargetFromEvent(e,data.source.el);
2506 if (target_info === false) {
2507 this.dropPlaceHolder('hide');
2510 Roo.log(['getTargetFromEvent', target_info ]);
2513 if (this.fireEvent('cardover', this, [ data ]) === false) {
2517 this.dropPlaceHolder('show', target_info,data);
2521 onNodeOut : function(n, dd, e, data){
2522 this.dropPlaceHolder('hide');
2525 onNodeDrop : function(n, dd, e, data)
2528 // call drop - return false if
2530 // this could actually fail - if the Network drops..
2531 // we will ignore this at present..- client should probably reload
2532 // the whole set of cards if stuff like that fails.
2535 var info = this.getTargetFromEvent(e,data.source.el);
2536 if (info === false) {
2539 this.dropPlaceHolder('hide');
2543 this.acceptCard(data.source, info.position, info.card, info.items_n);
2547 firstChildCard : function()
2549 for (var i = 0;i< this.items.length;i++) {
2551 if (!this.items[i].el.hasClass('card')) {
2554 return this.items[i];
2556 return this.items.length ? this.items[this.items.length-1] : false; // don't try and put stuff after the cards...
2561 * - card.acceptCard(move_card, info.position, info.card, info.items_n);
2563 acceptCard : function(move_card, position, next_to_card )
2565 if (this.fireEvent("drop", this, move_card, position, next_to_card) === false) {
2569 var to_items_n = next_to_card ? this.items.indexOf(next_to_card) : 0;
2571 move_card.parent().removeCard(move_card);
2574 var dom = move_card.el.dom;
2575 dom.style.width = ''; // clear with - which is set by drag.
2577 if (next_to_card !== false && next_to_card !== true && next_to_card.el.dom.parentNode) {
2578 var cardel = next_to_card.el.dom;
2580 if (position == 'above' ) {
2581 cardel.parentNode.insertBefore(dom, cardel);
2582 } else if (cardel.nextSibling) {
2583 cardel.parentNode.insertBefore(dom,cardel.nextSibling);
2585 cardel.parentNode.append(dom);
2588 // card container???
2589 this.containerEl.dom.append(dom);
2592 //FIXME HANDLE card = true
2594 // add this to the correct place in items.
2596 // remove Card from items.
2599 if (this.items.length) {
2601 //Roo.log([info.items_n, info.position, this.items.length]);
2602 for (var i =0; i < this.items.length; i++) {
2603 if (i == to_items_n && position == 'above') {
2604 nitems.push(move_card);
2606 nitems.push(this.items[i]);
2607 if (i == to_items_n && position == 'below') {
2608 nitems.push(move_card);
2611 this.items = nitems;
2612 Roo.log(this.items);
2614 this.items.push(move_card);
2617 move_card.parentId = this.id;
2623 removeCard : function(c)
2625 this.items = this.items.filter(function(e) { return e != c });
2628 dom.parentNode.removeChild(dom);
2629 dom.style.width = ''; // clear with - which is set by drag.
2634 /** Decide whether to drop above or below a View node. */
2635 getDropPoint : function(e, n, dd)
2640 if (n == this.containerEl.dom) {
2643 var t = Roo.lib.Dom.getY(n), b = t + n.offsetHeight;
2644 var c = t + (b - t) / 2;
2645 var y = Roo.lib.Event.getPageY(e);
2652 onToggleCollapse : function(e)
2654 if (this.collapsed) {
2655 this.el.select('.roo-collapse-toggle').removeClass('collapsed');
2656 this.collapsableEl.addClass('show');
2657 this.collapsed = false;
2660 this.el.select('.roo-collapse-toggle').addClass('collapsed');
2661 this.collapsableEl.removeClass('show');
2662 this.collapsed = true;
2667 onToggleRotate : function(e)
2669 this.collapsableEl.removeClass('show');
2670 this.footerEl.removeClass('d-none');
2671 this.el.removeClass('roo-card-rotated');
2672 this.el.removeClass('d-none');
2675 this.collapsableEl.addClass('show');
2676 this.rotated = false;
2677 this.fireEvent('rotate', this, this.rotated);
2680 this.el.addClass('roo-card-rotated');
2681 this.footerEl.addClass('d-none');
2682 this.el.select('.roo-collapsable').removeClass('show');
2684 this.rotated = true;
2685 this.fireEvent('rotate', this, this.rotated);
2689 dropPlaceHolder: function (action, info, data)
2691 if (this.dropEl === false) {
2692 this.dropEl = Roo.DomHelper.append(this.containerEl, {
2696 this.dropEl.removeClass(['d-none', 'd-block']);
2697 if (action == 'hide') {
2699 this.dropEl.addClass('d-none');
2702 // FIXME - info.card == true!!!
2703 this.dropEl.dom.parentNode.removeChild(this.dropEl.dom);
2705 if (info.card !== true) {
2706 var cardel = info.card.el.dom;
2708 if (info.position == 'above') {
2709 cardel.parentNode.insertBefore(this.dropEl.dom, cardel);
2710 } else if (cardel.nextSibling) {
2711 cardel.parentNode.insertBefore(this.dropEl.dom,cardel.nextSibling);
2713 cardel.parentNode.append(this.dropEl.dom);
2716 // card container???
2717 this.containerEl.dom.append(this.dropEl.dom);
2720 this.dropEl.addClass('d-block roo-card-dropzone');
2722 this.dropEl.setHeight( Roo.get(data.ddel).getHeight() );
2729 setHeaderText: function(html)
2732 if (this.headerContainerEl) {
2733 this.headerContainerEl.dom.innerHTML = html;
2736 onHeaderImageLoad : function(ev, he)
2738 if (!this.header_image_fit_square) {
2742 var hw = he.naturalHeight / he.naturalWidth;
2745 //var w = he.dom.naturalWidth;
2748 he.style.position = 'relative';
2750 var nw = (ww * (1/hw));
2751 Roo.get(he).setSize( ww * (1/hw), ww);
2752 he.style.left = ((ww - nw)/ 2) + 'px';
2753 he.style.position = 'relative';
2764 * Card header - holder for the card header elements.
2769 * @class Roo.bootstrap.CardHeader
2770 * @extends Roo.bootstrap.Element
2771 * Bootstrap CardHeader class
2773 * Create a new Card Header - that you can embed children into
2774 * @param {Object} config The config object
2777 Roo.bootstrap.CardHeader = function(config){
2778 Roo.bootstrap.CardHeader.superclass.constructor.call(this, config);
2781 Roo.extend(Roo.bootstrap.CardHeader, Roo.bootstrap.Element, {
2784 container_method : 'getCardHeader'
2797 * Card footer - holder for the card footer elements.
2802 * @class Roo.bootstrap.CardFooter
2803 * @extends Roo.bootstrap.Element
2804 * Bootstrap CardFooter class
2806 * Create a new Card Footer - that you can embed children into
2807 * @param {Object} config The config object
2810 Roo.bootstrap.CardFooter = function(config){
2811 Roo.bootstrap.CardFooter.superclass.constructor.call(this, config);
2814 Roo.extend(Roo.bootstrap.CardFooter, Roo.bootstrap.Element, {
2817 container_method : 'getCardFooter'
2830 * Card header - holder for the card header elements.
2835 * @class Roo.bootstrap.CardImageTop
2836 * @extends Roo.bootstrap.Element
2837 * Bootstrap CardImageTop class
2839 * Create a new Card Image Top container
2840 * @param {Object} config The config object
2843 Roo.bootstrap.CardImageTop = function(config){
2844 Roo.bootstrap.CardImageTop.superclass.constructor.call(this, config);
2847 Roo.extend(Roo.bootstrap.CardImageTop, Roo.bootstrap.Element, {
2850 container_method : 'getCardImageTop'
2865 * @class Roo.bootstrap.ButtonUploader
2866 * @extends Roo.bootstrap.Button
2867 * Bootstrap Button Uploader class - it's a button which when you add files to it
2870 * @cfg {Number} errorTimeout default 3000
2871 * @cfg {Array} images an array of ?? Img objects ??? when loading existing files..
2872 * @cfg {Array} html The button text.
2873 * @cfg {Boolean} multiple (default true) Should the upload allow multiple files to be uploaded.
2876 * Create a new CardUploader
2877 * @param {Object} config The config object
2880 Roo.bootstrap.ButtonUploader = function(config){
2884 Roo.bootstrap.ButtonUploader.superclass.constructor.call(this, config);
2890 * @event beforeselect
2891 * When button is pressed, before show upload files dialog is shown
2892 * @param {Roo.bootstrap.UploaderButton} this
2895 'beforeselect' : true,
2897 * @event fired when files have been selected,
2898 * When a the download link is clicked
2899 * @param {Roo.bootstrap.UploaderButton} this
2900 * @param {Array} Array of files that have been uploaded
2907 Roo.extend(Roo.bootstrap.ButtonUploader, Roo.bootstrap.Button, {
2910 errorTimeout : 3000,
2914 fileCollection : false,
2919 getAutoCreate : function()
2924 cls : 'd-none roo-card-upload-selector'
2927 if (this.multiple) {
2928 im.multiple = 'multiple';
2934 Roo.bootstrap.Button.prototype.getAutoCreate.call(this),
2944 initEvents : function()
2947 Roo.bootstrap.Button.prototype.initEvents.call(this);
2953 this.urlAPI = (window.createObjectURL && window) ||
2954 (window.URL && URL.revokeObjectURL && URL) ||
2955 (window.webkitURL && webkitURL);
2960 this.selectorEl = this.el.select('.roo-card-upload-selector', true).first();
2962 this.selectorEl.on('change', this.onFileSelected, this);
2969 onClick : function(e)
2973 if ( this.fireEvent('beforeselect', this) === false) {
2977 this.selectorEl.dom.click();
2981 onFileSelected : function(e)
2985 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
2988 var files = Array.prototype.slice.call(this.selectorEl.dom.files);
2989 this.selectorEl.dom.value = '';// hopefully reset..
2991 this.fireEvent('uploaded', this, files );
2999 * addCard - add an Attachment to the uploader
3000 * @param data - the data about the image to upload
3004 title : "Title of file",
3005 is_uploaded : false,
3006 src : "http://.....",
3007 srcfile : { the File upload object },
3008 mimetype : file.type,
3011 .. any other data...
3036 * @class Roo.bootstrap.Img
3037 * @extends Roo.bootstrap.Component
3038 * Bootstrap Img class
3039 * @cfg {Boolean} imgResponsive false | true
3040 * @cfg {String} border rounded | circle | thumbnail
3041 * @cfg {String} src image source
3042 * @cfg {String} alt image alternative text
3043 * @cfg {String} href a tag href
3044 * @cfg {String} target (_self|_blank|_parent|_top)target for a href.
3045 * @cfg {String} xsUrl xs image source
3046 * @cfg {String} smUrl sm image source
3047 * @cfg {String} mdUrl md image source
3048 * @cfg {String} lgUrl lg image source
3049 * @cfg {Boolean} backgroundContain (use style background and contain image in content)
3052 * Create a new Input
3053 * @param {Object} config The config object
3056 Roo.bootstrap.Img = function(config){
3057 Roo.bootstrap.Img.superclass.constructor.call(this, config);
3063 * The img click event for the img.
3064 * @param {Roo.EventObject} e
3069 * The when any image loads
3070 * @param {Roo.EventObject} e
3076 Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, {
3078 imgResponsive: true,
3087 backgroundContain : false,
3089 getAutoCreate : function()
3091 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
3092 return this.createSingleImg();
3097 cls: 'roo-image-responsive-group',
3102 Roo.each(['xs', 'sm', 'md', 'lg'], function(size){
3104 if(!_this[size + 'Url']){
3110 cls: (_this.imgResponsive) ? 'img-responsive' : '',
3111 html: _this.html || cfg.html,
3112 src: _this[size + 'Url']
3115 img.cls += ' roo-image-responsive-' + size;
3117 var s = ['xs', 'sm', 'md', 'lg'];
3119 s.splice(s.indexOf(size), 1);
3121 Roo.each(s, function(ss){
3122 img.cls += ' hidden-' + ss;
3125 if (['rounded','circle','thumbnail'].indexOf(_this.border)>-1) {
3126 cfg.cls += ' img-' + _this.border;
3130 cfg.alt = _this.alt;
3143 a.target = _this.target;
3147 cfg.cn.push((_this.href) ? a : img);
3154 createSingleImg : function()
3158 cls: (this.imgResponsive) ? 'img-responsive' : '',
3160 src : Roo.BLANK_IMAGE_URL // just incase src get's set to undefined?!?
3163 if (this.backgroundContain) {
3164 cfg.cls += ' background-contain';
3167 cfg.html = this.html || cfg.html;
3169 if (this.backgroundContain) {
3170 cfg.style="background-image: url(" + this.src + ')';
3172 cfg.src = this.src || cfg.src;
3175 if (['rounded','circle','thumbnail'].indexOf(this.border)>-1) {
3176 cfg.cls += ' img-' + this.border;
3193 a.target = this.target;
3198 return (this.href) ? a : cfg;
3201 initEvents: function()
3204 this.el.on('click', this.onClick, this);
3206 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
3207 this.el.on('load', this.onImageLoad, this);
3209 // not sure if this works.. not tested
3210 this.el.select('img', true).on('load', this.onImageLoad, this);
3215 onClick : function(e)
3217 Roo.log('img onclick');
3218 this.fireEvent('click', this, e);
3220 onImageLoad: function(e)
3222 Roo.log('img load');
3223 this.fireEvent('load', this, e);
3227 * Sets the url of the image - used to update it
3228 * @param {String} url the url of the image
3231 setSrc : function(url)
3235 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
3236 if (this.backgroundContain) {
3237 this.el.dom.style.backgroundImage = 'url(' + url + ')';
3239 this.el.dom.src = url;
3244 this.el.select('img', true).first().dom.src = url;
3260 * @class Roo.bootstrap.Link
3261 * @extends Roo.bootstrap.Component
3262 * Bootstrap Link Class
3263 * @cfg {String} alt image alternative text
3264 * @cfg {String} href a tag href
3265 * @cfg {String} target (_self|_blank|_parent|_top) target for a href.
3266 * @cfg {String} html the content of the link.
3267 * @cfg {String} anchor name for the anchor link
3268 * @cfg {String} fa - favicon
3270 * @cfg {Boolean} preventDefault (true | false) default false
3274 * Create a new Input
3275 * @param {Object} config The config object
3278 Roo.bootstrap.Link = function(config){
3279 Roo.bootstrap.Link.superclass.constructor.call(this, config);
3285 * The img click event for the img.
3286 * @param {Roo.EventObject} e
3292 Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component, {
3296 preventDefault: false,
3302 getAutoCreate : function()
3304 var html = this.html || '';
3306 if (this.fa !== false) {
3307 html = '<i class="fa fa-' + this.fa + '"></i>';
3312 // anchor's do not require html/href...
3313 if (this.anchor === false) {
3315 cfg.href = this.href || '#';
3317 cfg.name = this.anchor;
3318 if (this.html !== false || this.fa !== false) {
3321 if (this.href !== false) {
3322 cfg.href = this.href;
3326 if(this.alt !== false){
3331 if(this.target !== false) {
3332 cfg.target = this.target;
3338 initEvents: function() {
3340 if(!this.href || this.preventDefault){
3341 this.el.on('click', this.onClick, this);
3345 onClick : function(e)
3347 if(this.preventDefault){
3350 //Roo.log('img onclick');
3351 this.fireEvent('click', this, e);
3364 * @class Roo.bootstrap.Header
3365 * @extends Roo.bootstrap.Component
3366 * Bootstrap Header class
3367 * @cfg {String} html content of header
3368 * @cfg {Number} level (1|2|3|4|5|6) default 1
3371 * Create a new Header
3372 * @param {Object} config The config object
3376 Roo.bootstrap.Header = function(config){
3377 Roo.bootstrap.Header.superclass.constructor.call(this, config);
3380 Roo.extend(Roo.bootstrap.Header, Roo.bootstrap.Component, {
3388 getAutoCreate : function(){
3393 tag: 'h' + (1 *this.level),
3394 html: this.html || ''
3406 * Ext JS Library 1.1.1
3407 * Copyright(c) 2006-2007, Ext JS, LLC.
3409 * Originally Released Under LGPL - original licence link has changed is not relivant.
3412 * <script type="text/javascript">
3416 * @class Roo.bootstrap.MenuMgr
3417 * Provides a common registry of all menu items on a page so that they can be easily accessed by id.
3420 Roo.bootstrap.MenuMgr = function(){
3421 var menus, active, groups = {}, attached = false, lastShow = new Date();
3423 // private - called when first menu is created
3426 active = new Roo.util.MixedCollection();
3427 Roo.get(document).addKeyListener(27, function(){
3428 if(active.length > 0){
3436 if(active && active.length > 0){
3437 var c = active.clone();
3447 if(active.length < 1){
3448 Roo.get(document).un("mouseup", onMouseDown);
3456 var last = active.last();
3457 lastShow = new Date();
3460 Roo.get(document).on("mouseup", onMouseDown);
3465 //m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
3466 m.parentMenu.activeChild = m;
3467 }else if(last && last.isVisible()){
3468 //m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
3473 function onBeforeHide(m){
3475 m.activeChild.hide();
3477 if(m.autoHideTimer){
3478 clearTimeout(m.autoHideTimer);
3479 delete m.autoHideTimer;
3484 function onBeforeShow(m){
3485 var pm = m.parentMenu;
3486 if(!pm && !m.allowOtherMenus){
3488 }else if(pm && pm.activeChild && active != m){
3489 pm.activeChild.hide();
3493 // private this should really trigger on mouseup..
3494 function onMouseDown(e){
3495 Roo.log("on Mouse Up");
3497 if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".dropdown-menu") && !e.getTarget('.user-menu')){
3498 Roo.log("MenuManager hideAll");
3507 function onBeforeCheck(mi, state){
3509 var g = groups[mi.group];
3510 for(var i = 0, l = g.length; i < l; i++){
3512 g[i].setChecked(false);
3521 * Hides all menus that are currently visible
3523 hideAll : function(){
3528 register : function(menu){
3532 menus[menu.id] = menu;
3533 menu.on("beforehide", onBeforeHide);
3534 menu.on("hide", onHide);
3535 menu.on("beforeshow", onBeforeShow);
3536 menu.on("show", onShow);
3538 if(g && menu.events["checkchange"]){
3542 groups[g].push(menu);
3543 menu.on("checkchange", onCheck);
3548 * Returns a {@link Roo.menu.Menu} object
3549 * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will
3550 * be used to generate and return a new Menu instance.
3552 get : function(menu){
3553 if(typeof menu == "string"){ // menu id
3555 }else if(menu.events){ // menu instance
3558 /*else if(typeof menu.length == 'number'){ // array of menu items?
3559 return new Roo.bootstrap.Menu({items:menu});
3560 }else{ // otherwise, must be a config
3561 return new Roo.bootstrap.Menu(menu);
3568 unregister : function(menu){
3569 delete menus[menu.id];
3570 menu.un("beforehide", onBeforeHide);
3571 menu.un("hide", onHide);
3572 menu.un("beforeshow", onBeforeShow);
3573 menu.un("show", onShow);
3575 if(g && menu.events["checkchange"]){
3576 groups[g].remove(menu);
3577 menu.un("checkchange", onCheck);
3582 registerCheckable : function(menuItem){
3583 var g = menuItem.group;
3588 groups[g].push(menuItem);
3589 menuItem.on("beforecheckchange", onBeforeCheck);
3594 unregisterCheckable : function(menuItem){
3595 var g = menuItem.group;
3597 groups[g].remove(menuItem);
3598 menuItem.un("beforecheckchange", onBeforeCheck);
3610 * @class Roo.bootstrap.Menu
3611 * @extends Roo.bootstrap.Component
3612 * Bootstrap Menu class - container for MenuItems
3613 * @cfg {String} type (dropdown|treeview|submenu) type of menu
3614 * @cfg {bool} hidden if the menu should be hidden when rendered.
3615 * @cfg {bool} stopEvent (true|false) Stop event after trigger press (default true)
3616 * @cfg {bool} isLink (true|false) the menu has link disable auto expand and collaspe (default false)
3617 * @cfg {bool} hideTrigger (true|false) default false - hide the carret for trigger.
3618 * @cfg {String} align default tl-bl? == below - how the menu should be aligned.
3622 * @param {Object} config The config object
3626 Roo.bootstrap.Menu = function(config){
3628 if (config.type == 'treeview') {
3629 // normally menu's are drawn attached to the document to handle layering etc..
3630 // however treeview (used by the docs menu is drawn into the parent element)
3631 this.container_method = 'getChildContainer';
3634 Roo.bootstrap.Menu.superclass.constructor.call(this, config);
3635 if (this.registerMenu && this.type != 'treeview') {
3636 Roo.bootstrap.MenuMgr.register(this);
3643 * Fires before this menu is displayed (return false to block)
3644 * @param {Roo.menu.Menu} this
3649 * Fires before this menu is hidden (return false to block)
3650 * @param {Roo.menu.Menu} this
3655 * Fires after this menu is displayed
3656 * @param {Roo.menu.Menu} this
3661 * Fires after this menu is hidden
3662 * @param {Roo.menu.Menu} this
3667 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
3668 * @param {Roo.menu.Menu} this
3669 * @param {Roo.menu.Item} menuItem The menu item that was clicked
3670 * @param {Roo.EventObject} e
3675 * Fires when the mouse is hovering over this menu
3676 * @param {Roo.menu.Menu} this
3677 * @param {Roo.EventObject} e
3678 * @param {Roo.menu.Item} menuItem The menu item that was clicked
3683 * Fires when the mouse exits this menu
3684 * @param {Roo.menu.Menu} this
3685 * @param {Roo.EventObject} e
3686 * @param {Roo.menu.Item} menuItem The menu item that was clicked
3691 * Fires when a menu item contained in this menu is clicked
3692 * @param {Roo.menu.BaseItem} baseItem The BaseItem that was clicked
3693 * @param {Roo.EventObject} e
3697 this.menuitems = new Roo.util.MixedCollection(false, function(o) { return o.el.id; });
3700 Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, {
3704 triggerEl : false, // is this set by component builder? -- it should really be fetched from parent()???
3707 * @cfg {Boolean} registerMenu True (default) - means that clicking on screen etc. hides it.
3709 registerMenu : true,
3711 menuItems :false, // stores the menu items..
3721 container_method : 'getDocumentBody', // so the menu is rendered on the body and zIndex works.
3723 hideTrigger : false,
3728 getChildContainer : function() {
3732 getAutoCreate : function(){
3734 //if (['right'].indexOf(this.align)!==-1) {
3735 // cfg.cn[1].cls += ' pull-right'
3740 cls : 'dropdown-menu shadow' ,
3741 style : 'z-index:1000'
3745 if (this.type === 'submenu') {
3746 cfg.cls = 'submenu active';
3748 if (this.type === 'treeview') {
3749 cfg.cls = 'treeview-menu';
3754 initEvents : function() {
3756 // Roo.log("ADD event");
3757 // Roo.log(this.triggerEl.dom);
3758 if (this.triggerEl) {
3760 this.triggerEl.on('click', this.onTriggerClick, this);
3762 this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this);
3764 if (!this.hideTrigger) {
3765 if (this.triggerEl.hasClass('nav-item') && this.triggerEl.select('.nav-link',true).length) {
3766 // dropdown toggle on the 'a' in BS4?
3767 this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle');
3769 this.triggerEl.addClass('dropdown-toggle');
3775 this.el.on('touchstart' , this.onTouch, this);
3777 this.el.on('click' , this.onClick, this);
3779 this.el.on("mouseover", this.onMouseOver, this);
3780 this.el.on("mouseout", this.onMouseOut, this);
3784 findTargetItem : function(e)
3786 var t = e.getTarget(".dropdown-menu-item", this.el, true);
3790 //Roo.log(t); Roo.log(t.id);
3792 //Roo.log(this.menuitems);
3793 return this.menuitems.get(t.id);
3795 //return this.items.get(t.menuItemId);
3801 onTouch : function(e)
3803 Roo.log("menu.onTouch");
3804 //e.stopEvent(); this make the user popdown broken
3808 onClick : function(e)
3810 Roo.log("menu.onClick");
3812 var t = this.findTargetItem(e);
3813 if(!t || t.isContainer){
3818 if (Roo.isTouch && e.type == 'touchstart' && t.menu && !t.disabled) {
3819 if(t == this.activeItem && t.shouldDeactivate(e)){
3820 this.activeItem.deactivate();
3821 delete this.activeItem;
3825 this.setActiveItem(t, true);
3833 Roo.log('pass click event');
3837 this.fireEvent("click", this, t, e);
3841 if(!t.href.length || t.href == '#'){
3842 (function() { _this.hide(); }).defer(100);
3847 onMouseOver : function(e){
3848 var t = this.findTargetItem(e);
3851 // if(t.canActivate && !t.disabled){
3852 // this.setActiveItem(t, true);
3856 this.fireEvent("mouseover", this, e, t);
3858 isVisible : function(){
3859 return !this.hidden;
3861 onMouseOut : function(e){
3862 var t = this.findTargetItem(e);
3865 // if(t == this.activeItem && t.shouldDeactivate(e)){
3866 // this.activeItem.deactivate();
3867 // delete this.activeItem;
3870 this.fireEvent("mouseout", this, e, t);
3875 * Displays this menu relative to another element
3876 * @param {String/HTMLElement/Roo.Element} element The element to align to
3877 * @param {String} position (optional) The {@link Roo.Element#alignTo} anchor position to use in aligning to
3878 * the element (defaults to this.defaultAlign)
3879 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
3881 show : function(el, pos, parentMenu)
3883 if (false === this.fireEvent("beforeshow", this)) {
3884 Roo.log("show canceled");
3887 this.parentMenu = parentMenu;
3891 this.el.addClass('show'); // show otherwise we do not know how big we are..
3893 var xy = this.el.getAlignToXY(el, pos);
3895 // bl-tl << left align below
3896 // tl-bl << left align
3898 if(this.el.getWidth() + xy[0] >= Roo.lib.Dom.getViewWidth()){
3899 // if it goes to far to the right.. -> align left.
3900 xy = this.el.getAlignToXY(el, this.align.replace('/l/g', 'r'))
3903 // was left align - go right?
3904 xy = this.el.getAlignToXY(el, this.align.replace('/r/g', 'l'))
3907 // goes down the bottom
3908 if(this.el.getHeight() + xy[1] >= Roo.lib.Dom.getViewHeight() ||
3910 var a = this.align.replace('?', '').split('-');
3911 xy = this.el.getAlignToXY(el, a[1] + '-' + a[0] + '?')
3915 this.showAt( xy , parentMenu, false);
3918 * Displays this menu at a specific xy position
3919 * @param {Array} xyPosition Contains X & Y [x, y] values for the position at which to show the menu (coordinates are page-based)
3920 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
3922 showAt : function(xy, parentMenu, /* private: */_e){
3923 this.parentMenu = parentMenu;
3928 this.fireEvent("beforeshow", this);
3929 //xy = this.el.adjustForConstraints(xy);
3933 this.hideMenuItems();
3934 this.hidden = false;
3935 if (this.triggerEl) {
3936 this.triggerEl.addClass('open');
3939 this.el.addClass('show');
3943 // reassign x when hitting right
3945 // reassign y when hitting bottom
3947 // but the list may align on trigger left or trigger top... should it be a properity?
3949 if(this.el.getStyle('top') != 'auto' && this.el.getStyle('top').slice(-1) != "%"){
3954 this.fireEvent("show", this);
3960 this.doFocus.defer(50, this);
3964 doFocus : function(){
3966 this.focusEl.focus();
3971 * Hides this menu and optionally all parent menus
3972 * @param {Boolean} deep (optional) True to hide all parent menus recursively, if any (defaults to false)
3974 hide : function(deep)
3976 if (false === this.fireEvent("beforehide", this)) {
3977 Roo.log("hide canceled");
3980 this.hideMenuItems();
3981 if(this.el && this.isVisible()){
3983 if(this.activeItem){
3984 this.activeItem.deactivate();
3985 this.activeItem = null;
3987 if (this.triggerEl) {
3988 this.triggerEl.removeClass('open');
3991 this.el.removeClass('show');
3993 this.fireEvent("hide", this);
3995 if(deep === true && this.parentMenu){
3996 this.parentMenu.hide(true);
4000 onTriggerClick : function(e)
4002 Roo.log('trigger click');
4004 var target = e.getTarget();
4006 Roo.log(target.nodeName.toLowerCase());
4008 if(target.nodeName.toLowerCase() === 'i'){
4014 onTriggerPress : function(e)
4016 Roo.log('trigger press');
4017 //Roo.log(e.getTarget());
4018 // Roo.log(this.triggerEl.dom);
4020 // trigger only occurs on normal menu's -- if it's a treeview or dropdown... do not hide/show..
4021 var pel = Roo.get(e.getTarget());
4022 if (pel.findParent('.dropdown-menu') || pel.findParent('.treeview-menu') ) {
4023 Roo.log('is treeview or dropdown?');
4027 if(e.getTarget().nodeName.toLowerCase() !== 'i' && this.isLink){
4031 if (this.isVisible()) {
4037 this.show(this.triggerEl, this.align, false);
4040 if(this.stopEvent || e.getTarget().nodeName.toLowerCase() === 'i'){
4047 hideMenuItems : function()
4049 Roo.log("hide Menu Items");
4054 this.el.select('.open',true).each(function(aa) {
4056 aa.removeClass('open');
4060 addxtypeChild : function (tree, cntr) {
4061 var comp= Roo.bootstrap.Menu.superclass.addxtypeChild.call(this, tree, cntr);
4063 this.menuitems.add(comp);
4075 this.getEl().dom.innerHTML = '';
4076 this.menuitems.clear();
4090 * @class Roo.bootstrap.MenuItem
4091 * @extends Roo.bootstrap.Component
4092 * Bootstrap MenuItem class
4093 * @cfg {String} html the menu label
4094 * @cfg {String} href the link
4095 * @cfg {Boolean} preventDefault do not trigger A href on clicks (default false).
4096 * @cfg {Boolean} isContainer is it a container - just returns a drop down item..
4097 * @cfg {Boolean} active used on sidebars to highlight active itesm
4098 * @cfg {String} fa favicon to show on left of menu item.
4099 * @cfg {Roo.bootsrap.Menu} menu the child menu.
4103 * Create a new MenuItem
4104 * @param {Object} config The config object
4108 Roo.bootstrap.MenuItem = function(config){
4109 Roo.bootstrap.MenuItem.superclass.constructor.call(this, config);
4114 * The raw click event for the entire grid.
4115 * @param {Roo.bootstrap.MenuItem} this
4116 * @param {Roo.EventObject} e
4122 Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component, {
4126 preventDefault: false,
4127 isContainer : false,
4131 getAutoCreate : function(){
4133 if(this.isContainer){
4136 cls: 'dropdown-menu-item '
4146 cls : 'dropdown-item',
4151 if (this.fa !== false) {
4154 cls : 'fa fa-' + this.fa
4163 cls: 'dropdown-menu-item',
4166 if (this.parent().type == 'treeview') {
4167 cfg.cls = 'treeview-menu';
4170 cfg.cls += ' active';
4175 anc.href = this.href || cfg.cn[0].href ;
4176 ctag.html = this.html || cfg.cn[0].html ;
4180 initEvents: function()
4182 if (this.parent().type == 'treeview') {
4183 this.el.select('a').on('click', this.onClick, this);
4187 this.menu.parentType = this.xtype;
4188 this.menu.triggerEl = this.el;
4189 this.menu = this.addxtype(Roo.apply({}, this.menu));
4193 onClick : function(e)
4195 Roo.log('item on click ');
4197 if(this.preventDefault){
4200 //this.parent().hideMenuItems();
4202 this.fireEvent('click', this, e);
4221 * @class Roo.bootstrap.MenuSeparator
4222 * @extends Roo.bootstrap.Component
4223 * Bootstrap MenuSeparator class
4226 * Create a new MenuItem
4227 * @param {Object} config The config object
4231 Roo.bootstrap.MenuSeparator = function(config){
4232 Roo.bootstrap.MenuSeparator.superclass.constructor.call(this, config);
4235 Roo.extend(Roo.bootstrap.MenuSeparator, Roo.bootstrap.Component, {
4237 getAutoCreate : function(){
4256 * @class Roo.bootstrap.Modal
4257 * @extends Roo.bootstrap.Component
4259 * Bootstrap Modal class
4260 * @cfg {String} title Title of dialog
4261 * @cfg {String} html - the body of the dialog (for simple ones) - you can also use template..
4262 * @cfg {Roo.Template} tmpl - a template with variables. to use it, add a handler in show:method adn
4263 * @cfg {Boolean} specificTitle default false
4264 * @cfg {Array} buttons Array of buttons or standard button set..
4265 * @cfg {String} buttonPosition (left|right|center) default right (DEPRICATED) - use mr-auto on buttons to put them on the left
4266 * @cfg {Boolean} animate default true
4267 * @cfg {Boolean} allow_close default true
4268 * @cfg {Boolean} fitwindow default false
4269 * @cfg {Boolean} bodyOverflow should the body element have overflow auto added default false
4270 * @cfg {Number} width fixed width - usefull for chrome extension only really.
4271 * @cfg {Number} height fixed height - usefull for chrome extension only really.
4272 * @cfg {String} size (sm|lg|xl) default empty
4273 * @cfg {Number} max_width set the max width of modal
4274 * @cfg {Boolean} editableTitle can the title be edited
4279 * Create a new Modal Dialog
4280 * @param {Object} config The config object
4283 Roo.bootstrap.Modal = function(config){
4284 Roo.bootstrap.Modal.superclass.constructor.call(this, config);
4289 * The raw btnclick event for the button
4290 * @param {Roo.EventObject} e
4295 * Fire when dialog resize
4296 * @param {Roo.bootstrap.Modal} this
4297 * @param {Roo.EventObject} e
4301 * @event titlechanged
4302 * Fire when the editable title has been changed
4303 * @param {Roo.bootstrap.Modal} this
4304 * @param {Roo.EventObject} value
4306 "titlechanged" : true
4309 this.buttons = this.buttons || [];
4312 this.tmpl = Roo.factory(this.tmpl);
4317 Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, {
4319 title : 'test dialog',
4329 specificTitle: false,
4331 buttonPosition: 'right',
4353 editableTitle : false,
4355 onRender : function(ct, position)
4357 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
4360 var cfg = Roo.apply({}, this.getAutoCreate());
4363 // cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
4365 //if (!cfg.name.length) {
4369 cfg.cls += ' ' + this.cls;
4372 cfg.style = this.style;
4374 this.el = Roo.get(document.body).createChild(cfg, position);
4376 //var type = this.el.dom.type;
4379 if(this.tabIndex !== undefined){
4380 this.el.dom.setAttribute('tabIndex', this.tabIndex);
4383 this.dialogEl = this.el.select('.modal-dialog',true).first();
4384 this.bodyEl = this.el.select('.modal-body',true).first();
4385 this.closeEl = this.el.select('.modal-header .close', true).first();
4386 this.headerEl = this.el.select('.modal-header',true).first();
4387 this.titleEl = this.el.select('.modal-title',true).first();
4388 this.footerEl = this.el.select('.modal-footer',true).first();
4390 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
4392 //this.el.addClass("x-dlg-modal");
4394 if (this.buttons.length) {
4395 Roo.each(this.buttons, function(bb) {
4396 var b = Roo.apply({}, bb);
4397 b.xns = b.xns || Roo.bootstrap;
4398 b.xtype = b.xtype || 'Button';
4399 if (typeof(b.listeners) == 'undefined') {
4400 b.listeners = { click : this.onButtonClick.createDelegate(this) };
4403 var btn = Roo.factory(b);
4405 btn.render(this.getButtonContainer());
4409 // render the children.
4412 if(typeof(this.items) != 'undefined'){
4413 var items = this.items;
4416 for(var i =0;i < items.length;i++) {
4417 nitems.push(this.addxtype(Roo.apply({}, items[i])));
4421 this.items = nitems;
4423 // where are these used - they used to be body/close/footer
4427 //this.el.addClass([this.fieldClass, this.cls]);
4431 getAutoCreate : function()
4433 // we will default to modal-body-overflow - might need to remove or make optional later.
4435 cls : 'modal-body ' + (this.bodyOverflow ? 'overflow-auto' : ''),
4436 html : this.html || ''
4441 cls : 'modal-title',
4445 if(this.specificTitle){ // WTF is this?
4450 if (this.allow_close && Roo.bootstrap.version == 3) {
4460 if (this.editableTitle) {
4462 cls: 'form-control roo-editable-title d-none',
4468 if (this.allow_close && Roo.bootstrap.version == 4) {
4478 if(this.size.length){
4479 size = 'modal-' + this.size;
4482 var footer = Roo.bootstrap.version == 3 ?
4484 cls : 'modal-footer',
4488 cls: 'btn-' + this.buttonPosition
4493 { // BS4 uses mr-auto on left buttons....
4494 cls : 'modal-footer'
4505 cls: "modal-dialog " + size,
4508 cls : "modal-content",
4511 cls : 'modal-header',
4526 modal.cls += ' fade';
4532 getChildContainer : function() {
4537 getButtonContainer : function() {
4539 return Roo.bootstrap.version == 4 ?
4540 this.el.select('.modal-footer',true).first()
4541 : this.el.select('.modal-footer div',true).first();
4544 initEvents : function()
4546 if (this.allow_close) {
4547 this.closeEl.on('click', this.hide, this);
4549 Roo.EventManager.onWindowResize(this.resize, this, true);
4550 if (this.editableTitle) {
4551 this.headerEditEl = this.headerEl.select('.form-control',true).first();
4552 this.headerEl.on('click', function() { this.toggleHeaderInput(true) } , this);
4553 this.headerEditEl.on('keyup', function(e) {
4554 if([ e.RETURN , e.TAB , e.ESC ].indexOf(e.keyCode) > -1) {
4555 this.toggleHeaderInput(false)
4558 this.headerEditEl.on('blur', function(e) {
4559 this.toggleHeaderInput(false)
4568 this.maskEl.setSize(
4569 Roo.lib.Dom.getViewWidth(true),
4570 Roo.lib.Dom.getViewHeight(true)
4573 if (this.fitwindow) {
4575 this.dialogEl.setStyle( { 'max-width' : '100%' });
4577 this.width || Roo.lib.Dom.getViewportWidth(true) - 30,
4578 this.height || Roo.lib.Dom.getViewportHeight(true) // catering margin-top 30 margin-bottom 30
4583 if(this.max_width !== 0) {
4585 var w = Math.min(this.max_width, Roo.lib.Dom.getViewportWidth(true) - 30);
4588 this.setSize(w, this.height);
4592 if(this.max_height) {
4593 this.setSize(w,Math.min(
4595 Roo.lib.Dom.getViewportHeight(true) - 60
4601 if(!this.fit_content) {
4602 this.setSize(w, Roo.lib.Dom.getViewportHeight(true) - 60);
4606 this.setSize(w, Math.min(
4608 this.headerEl.getHeight() +
4609 this.footerEl.getHeight() +
4610 this.getChildHeight(this.bodyEl.dom.childNodes),
4611 Roo.lib.Dom.getViewportHeight(true) - 60)
4617 setSize : function(w,h)
4628 if (!this.rendered) {
4631 this.toggleHeaderInput(false);
4632 //this.el.setStyle('display', 'block');
4633 this.el.removeClass('hideing');
4634 this.el.dom.style.display='block';
4636 Roo.get(document.body).addClass('modal-open');
4638 if(this.animate){ // element has 'fade' - so stuff happens after .3s ?- not sure why the delay?
4641 this.el.addClass('show');
4642 this.el.addClass('in');
4645 this.el.addClass('show');
4646 this.el.addClass('in');
4649 // not sure how we can show data in here..
4651 // this.getChildContainer().dom.innerHTML = this.tmpl.applyTemplate(this);
4654 Roo.get(document.body).addClass("x-body-masked");
4656 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
4657 this.maskEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
4658 this.maskEl.dom.style.display = 'block';
4659 this.maskEl.addClass('show');
4664 this.fireEvent('show', this);
4666 // set zindex here - otherwise it appears to be ignored...
4667 this.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
4670 this.items.forEach( function(e) {
4671 e.layout ? e.layout() : false;
4679 if(this.fireEvent("beforehide", this) !== false){
4681 this.maskEl.removeClass('show');
4683 this.maskEl.dom.style.display = '';
4684 Roo.get(document.body).removeClass("x-body-masked");
4685 this.el.removeClass('in');
4686 this.el.select('.modal-dialog', true).first().setStyle('transform','');
4688 if(this.animate){ // why
4689 this.el.addClass('hideing');
4690 this.el.removeClass('show');
4692 if (!this.el.hasClass('hideing')) {
4693 return; // it's been shown again...
4696 this.el.dom.style.display='';
4698 Roo.get(document.body).removeClass('modal-open');
4699 this.el.removeClass('hideing');
4703 this.el.removeClass('show');
4704 this.el.dom.style.display='';
4705 Roo.get(document.body).removeClass('modal-open');
4708 this.fireEvent('hide', this);
4711 isVisible : function()
4714 return this.el.hasClass('show') && !this.el.hasClass('hideing');
4718 addButton : function(str, cb)
4722 var b = Roo.apply({}, { html : str } );
4723 b.xns = b.xns || Roo.bootstrap;
4724 b.xtype = b.xtype || 'Button';
4725 if (typeof(b.listeners) == 'undefined') {
4726 b.listeners = { click : cb.createDelegate(this) };
4729 var btn = Roo.factory(b);
4731 btn.render(this.getButtonContainer());
4737 setDefaultButton : function(btn)
4739 //this.el.select('.modal-footer').()
4742 resizeTo: function(w,h)
4744 this.dialogEl.setWidth(w);
4746 var diff = this.headerEl.getHeight() + this.footerEl.getHeight() + 60; // dialog margin-bottom: 30
4748 this.bodyEl.setHeight(h - diff);
4750 this.fireEvent('resize', this);
4753 setContentSize : function(w, h)
4757 onButtonClick: function(btn,e)
4760 this.fireEvent('btnclick', btn.name, e);
4763 * Set the title of the Dialog
4764 * @param {String} str new Title
4766 setTitle: function(str) {
4767 this.titleEl.dom.innerHTML = str;
4771 * Set the body of the Dialog
4772 * @param {String} str new Title
4774 setBody: function(str) {
4775 this.bodyEl.dom.innerHTML = str;
4778 * Set the body of the Dialog using the template
4779 * @param {Obj} data - apply this data to the template and replace the body contents.
4781 applyBody: function(obj)
4784 Roo.log("Error - using apply Body without a template");
4787 this.tmpl.overwrite(this.bodyEl, obj);
4790 getChildHeight : function(child_nodes)
4794 child_nodes.length == 0
4799 var child_height = 0;
4801 for(var i = 0; i < child_nodes.length; i++) {
4804 * for modal with tabs...
4805 if(child_nodes[i].classList.contains('roo-layout-panel')) {
4807 var layout_childs = child_nodes[i].childNodes;
4809 for(var j = 0; j < layout_childs.length; j++) {
4811 if(layout_childs[j].classList.contains('roo-layout-panel-body')) {
4813 var layout_body_childs = layout_childs[j].childNodes;
4815 for(var k = 0; k < layout_body_childs.length; k++) {
4817 if(layout_body_childs[k].classList.contains('navbar')) {
4818 child_height += layout_body_childs[k].offsetHeight;
4822 if(layout_body_childs[k].classList.contains('roo-layout-tabs-body')) {
4824 var layout_body_tab_childs = layout_body_childs[k].childNodes;
4826 for(var m = 0; m < layout_body_tab_childs.length; m++) {
4828 if(layout_body_tab_childs[m].classList.contains('roo-layout-active-content')) {
4829 child_height += this.getChildHeight(layout_body_tab_childs[m].childNodes);
4844 child_height += child_nodes[i].offsetHeight;
4845 // Roo.log(child_nodes[i].offsetHeight);
4848 return child_height;
4850 toggleHeaderInput : function(is_edit)
4852 if (!this.editableTitle) {
4853 return; // not editable.
4855 if (is_edit && this.is_header_editing) {
4856 return; // already editing..
4860 this.headerEditEl.dom.value = this.title;
4861 this.headerEditEl.removeClass('d-none');
4862 this.headerEditEl.dom.focus();
4863 this.titleEl.addClass('d-none');
4865 this.is_header_editing = true;
4868 // flip back to not editing.
4869 this.title = this.headerEditEl.dom.value;
4870 this.headerEditEl.addClass('d-none');
4871 this.titleEl.removeClass('d-none');
4872 this.titleEl.dom.innerHTML = String.format('{0}', this.title);
4873 this.is_header_editing = false;
4874 this.fireEvent('titlechanged', this, this.title);
4883 Roo.apply(Roo.bootstrap.Modal, {
4885 * Button config that displays a single OK button
4894 * Button config that displays Yes and No buttons
4910 * Button config that displays OK and Cancel buttons
4925 * Button config that displays Yes, No and Cancel buttons
4950 * messagebox - can be used as a replace
4954 * @class Roo.MessageBox
4955 * Utility class for generating different styles of message boxes. The alias Roo.Msg can also be used.
4959 Roo.Msg.alert('Status', 'Changes saved successfully.');
4961 // Prompt for user data:
4962 Roo.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
4964 // process text value...
4968 // Show a dialog using config options:
4970 title:'Save Changes?',
4971 msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',
4972 buttons: Roo.Msg.YESNOCANCEL,
4979 Roo.bootstrap.MessageBox = function(){
4980 var dlg, opt, mask, waitTimer;
4981 var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp;
4982 var buttons, activeTextEl, bwidth;
4986 var handleButton = function(button){
4988 Roo.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
4992 var handleHide = function(){
4994 dlg.el.removeClass(opt.cls);
4997 // Roo.TaskMgr.stop(waitTimer);
4998 // waitTimer = null;
5003 var updateButtons = function(b){
5006 buttons["ok"].hide();
5007 buttons["cancel"].hide();
5008 buttons["yes"].hide();
5009 buttons["no"].hide();
5010 dlg.footerEl.hide();
5014 dlg.footerEl.show();
5015 for(var k in buttons){
5016 if(typeof buttons[k] != "function"){
5019 buttons[k].setText(typeof b[k] == "string" ? b[k] : Roo.bootstrap.MessageBox.buttonText[k]);
5020 width += buttons[k].el.getWidth()+15;
5030 var handleEsc = function(d, k, e){
5031 if(opt && opt.closable !== false){
5041 * Returns a reference to the underlying {@link Roo.BasicDialog} element
5042 * @return {Roo.BasicDialog} The BasicDialog element
5044 getDialog : function(){
5046 dlg = new Roo.bootstrap.Modal( {
5049 //constraintoviewport:false,
5051 //collapsible : false,
5056 //buttonAlign:"center",
5057 closeClick : function(){
5058 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
5061 handleButton("cancel");
5066 dlg.on("hide", handleHide);
5068 //dlg.addKeyListener(27, handleEsc);
5070 this.buttons = buttons;
5071 var bt = this.buttonText;
5072 buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
5073 buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
5074 buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
5075 buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
5077 bodyEl = dlg.bodyEl.createChild({
5079 html:'<span class="roo-mb-text"></span><br /><input type="text" class="roo-mb-input" />' +
5080 '<textarea class="roo-mb-textarea"></textarea>' +
5081 '<div class="roo-mb-progress-wrap"><div class="roo-mb-progress"><div class="roo-mb-progress-bar"> </div></div></div>'
5083 msgEl = bodyEl.dom.firstChild;
5084 textboxEl = Roo.get(bodyEl.dom.childNodes[2]);
5085 textboxEl.enableDisplayMode();
5086 textboxEl.addKeyListener([10,13], function(){
5087 if(dlg.isVisible() && opt && opt.buttons){
5090 }else if(opt.buttons.yes){
5091 handleButton("yes");
5095 textareaEl = Roo.get(bodyEl.dom.childNodes[3]);
5096 textareaEl.enableDisplayMode();
5097 progressEl = Roo.get(bodyEl.dom.childNodes[4]);
5098 progressEl.enableDisplayMode();
5100 // This is supposed to be the progessElement.. but I think it's controlling the height of everything..
5101 var pf = progressEl.dom.firstChild;
5103 pp = Roo.get(pf.firstChild);
5104 pp.setHeight(pf.offsetHeight);
5112 * Updates the message box body text
5113 * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
5114 * the XHTML-compliant non-breaking space character '&#160;')
5115 * @return {Roo.MessageBox} This message box
5117 updateText : function(text)
5119 if(!dlg.isVisible() && !opt.width){
5120 dlg.dialogEl.setStyle({ 'max-width' : this.maxWidth});
5121 // dlg.resizeTo(this.maxWidth, 100); // forcing the height breaks long alerts()
5123 msgEl.innerHTML = text || ' ';
5125 var cw = Math.max(msgEl.offsetWidth, msgEl.parentNode.scrollWidth);
5126 //Roo.log("guesed size: " + JSON.stringify([cw,msgEl.offsetWidth, msgEl.parentNode.scrollWidth]));
5128 Math.min(opt.width || cw , this.maxWidth),
5129 Math.max(opt.minWidth || this.minWidth, bwidth)
5132 activeTextEl.setWidth(w);
5134 if(dlg.isVisible()){
5135 dlg.fixedcenter = false;
5137 // to big, make it scroll. = But as usual stupid IE does not support
5140 if ( bodyEl.getHeight() > (Roo.lib.Dom.getViewHeight() - 100)) {
5141 bodyEl.setHeight ( Roo.lib.Dom.getViewHeight() - 100 );
5142 bodyEl.dom.style.overflowY = 'auto' + ( Roo.isIE ? '' : ' !important');
5144 bodyEl.dom.style.height = '';
5145 bodyEl.dom.style.overflowY = '';
5148 bodyEl.dom.style.get = 'auto' + ( Roo.isIE ? '' : ' !important');
5150 bodyEl.dom.style.overflowX = '';
5153 dlg.setContentSize(w, bodyEl.getHeight());
5154 if(dlg.isVisible()){
5155 dlg.fixedcenter = true;
5161 * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
5162 * initiated via {@link Roo.MessageBox#progress} or by calling {@link Roo.MessageBox#show} with progress: true.
5163 * @param {Number} value Any number between 0 and 1 (e.g., .5)
5164 * @param {String} text (optional) If defined, the message box's body text is replaced with the specified string (defaults to undefined)
5165 * @return {Roo.MessageBox} This message box
5167 updateProgress : function(value, text){
5169 this.updateText(text);
5172 if (pp) { // weird bug on my firefox - for some reason this is not defined
5173 pp.setWidth(Math.floor(value*progressEl.dom.firstChild.offsetWidth));
5174 pp.setHeight(Math.floor(progressEl.dom.firstChild.offsetHeight));
5180 * Returns true if the message box is currently displayed
5181 * @return {Boolean} True if the message box is visible, else false
5183 isVisible : function(){
5184 return dlg && dlg.isVisible();
5188 * Hides the message box if it is displayed
5191 if(this.isVisible()){
5197 * Displays a new message box, or reinitializes an existing message box, based on the config options
5198 * passed in. All functions (e.g. prompt, alert, etc) on MessageBox call this function internally.
5199 * The following config object properties are supported:
5201 Property Type Description
5202 ---------- --------------- ------------------------------------------------------------------------------------
5203 animEl String/Element An id or Element from which the message box should animate as it opens and
5204 closes (defaults to undefined)
5205 buttons Object/Boolean A button config object (e.g., Roo.MessageBox.OKCANCEL or {ok:'Foo',
5206 cancel:'Bar'}), or false to not show any buttons (defaults to false)
5207 closable Boolean False to hide the top-right close button (defaults to true). Note that
5208 progress and wait dialogs will ignore this property and always hide the
5209 close button as they can only be closed programmatically.
5210 cls String A custom CSS class to apply to the message box element
5211 defaultTextHeight Number The default height in pixels of the message box's multiline textarea if
5212 displayed (defaults to 75)
5213 fn Function A callback function to execute after closing the dialog. The arguments to the
5214 function will be btn (the name of the button that was clicked, if applicable,
5215 e.g. "ok"), and text (the value of the active text field, if applicable).
5216 Progress and wait dialogs will ignore this option since they do not respond to
5217 user actions and can only be closed programmatically, so any required function
5218 should be called by the same code after it closes the dialog.
5219 icon String A CSS class that provides a background image to be used as an icon for
5220 the dialog (e.g., Roo.MessageBox.WARNING or 'custom-class', defaults to '')
5221 maxWidth Number The maximum width in pixels of the message box (defaults to 600)
5222 minWidth Number The minimum width in pixels of the message box (defaults to 100)
5223 modal Boolean False to allow user interaction with the page while the message box is
5224 displayed (defaults to true)
5225 msg String A string that will replace the existing message box body text (defaults
5226 to the XHTML-compliant non-breaking space character ' ')
5227 multiline Boolean True to prompt the user to enter multi-line text (defaults to false)
5228 progress Boolean True to display a progress bar (defaults to false)
5229 progressText String The text to display inside the progress bar if progress = true (defaults to '')
5230 prompt Boolean True to prompt the user to enter single-line text (defaults to false)
5231 proxyDrag Boolean True to display a lightweight proxy while dragging (defaults to false)
5232 title String The title text
5233 value String The string value to set into the active textbox element if displayed
5234 wait Boolean True to display a progress bar (defaults to false)
5235 width Number The width of the dialog in pixels
5242 msg: 'Please enter your address:',
5244 buttons: Roo.MessageBox.OKCANCEL,
5247 animEl: 'addAddressBtn'
5250 * @param {Object} config Configuration options
5251 * @return {Roo.MessageBox} This message box
5253 show : function(options)
5256 // this causes nightmares if you show one dialog after another
5257 // especially on callbacks..
5259 if(this.isVisible()){
5262 Roo.log("[Roo.Messagebox] Show called while message displayed:" );
5263 Roo.log("Old Dialog Message:" + msgEl.innerHTML );
5264 Roo.log("New Dialog Message:" + options.msg )
5265 //this.alert("ERROR", "Multiple dialogs where displayed at the same time");
5266 //throw "Roo.MessageBox ERROR : Multiple dialogs where displayed at the same time";
5269 var d = this.getDialog();
5271 d.setTitle(opt.title || " ");
5272 d.closeEl.setDisplayed(opt.closable !== false);
5273 activeTextEl = textboxEl;
5274 opt.prompt = opt.prompt || (opt.multiline ? true : false);
5279 textareaEl.setHeight(typeof opt.multiline == "number" ?
5280 opt.multiline : this.defaultTextHeight);
5281 activeTextEl = textareaEl;
5290 progressEl.setDisplayed(opt.progress === true);
5292 d.animate = false; // do not animate progress, as it may not have finished animating before we close it..
5294 this.updateProgress(0);
5295 activeTextEl.dom.value = opt.value || "";
5297 dlg.setDefaultButton(activeTextEl);
5299 var bs = opt.buttons;
5303 }else if(bs && bs.yes){
5304 db = buttons["yes"];
5306 dlg.setDefaultButton(db);
5308 bwidth = updateButtons(opt.buttons);
5309 this.updateText(opt.msg);
5311 d.el.addClass(opt.cls);
5313 d.proxyDrag = opt.proxyDrag === true;
5314 d.modal = opt.modal !== false;
5315 d.mask = opt.modal !== false ? mask : false;
5317 // force it to the end of the z-index stack so it gets a cursor in FF
5318 document.body.appendChild(dlg.el.dom);
5319 d.animateTarget = null;
5320 d.show(options.animEl);
5326 * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
5327 * the user. You are responsible for updating the progress bar as needed via {@link Roo.MessageBox#updateProgress}
5328 * and closing the message box when the process is complete.
5329 * @param {String} title The title bar text
5330 * @param {String} msg The message box body text
5331 * @return {Roo.MessageBox} This message box
5333 progress : function(title, msg){
5340 minWidth: this.minProgressWidth,
5347 * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
5348 * If a callback function is passed it will be called after the user clicks the button, and the
5349 * id of the button that was clicked will be passed as the only parameter to the callback
5350 * (could also be the top-right close button).
5351 * @param {String} title The title bar text
5352 * @param {String} msg The message box body text
5353 * @param {Function} fn (optional) The callback function invoked after the message box is closed
5354 * @param {Object} scope (optional) The scope of the callback function
5355 * @return {Roo.MessageBox} This message box
5357 alert : function(title, msg, fn, scope)
5372 * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
5373 * interaction while waiting for a long-running process to complete that does not have defined intervals.
5374 * You are responsible for closing the message box when the process is complete.
5375 * @param {String} msg The message box body text
5376 * @param {String} title (optional) The title bar text
5377 * @return {Roo.MessageBox} This message box
5379 wait : function(msg, title){
5390 waitTimer = Roo.TaskMgr.start({
5392 Roo.MessageBox.updateProgress(((((i+20)%20)+1)*5)*.01);
5400 * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
5401 * If a callback function is passed it will be called after the user clicks either button, and the id of the
5402 * button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
5403 * @param {String} title The title bar text
5404 * @param {String} msg The message box body text
5405 * @param {Function} fn (optional) The callback function invoked after the message box is closed
5406 * @param {Object} scope (optional) The scope of the callback function
5407 * @return {Roo.MessageBox} This message box
5409 confirm : function(title, msg, fn, scope){
5413 buttons: this.YESNO,
5422 * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to
5423 * JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function
5424 * is passed it will be called after the user clicks either button, and the id of the button that was clicked
5425 * (could also be the top-right close button) and the text that was entered will be passed as the two
5426 * parameters to the callback.
5427 * @param {String} title The title bar text
5428 * @param {String} msg The message box body text
5429 * @param {Function} fn (optional) The callback function invoked after the message box is closed
5430 * @param {Object} scope (optional) The scope of the callback function
5431 * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
5432 * property, or the height in pixels to create the textbox (defaults to false / single-line)
5433 * @return {Roo.MessageBox} This message box
5435 prompt : function(title, msg, fn, scope, multiline){
5439 buttons: this.OKCANCEL,
5444 multiline: multiline,
5451 * Button config that displays a single OK button
5456 * Button config that displays Yes and No buttons
5459 YESNO : {yes:true, no:true},
5461 * Button config that displays OK and Cancel buttons
5464 OKCANCEL : {ok:true, cancel:true},
5466 * Button config that displays Yes, No and Cancel buttons
5469 YESNOCANCEL : {yes:true, no:true, cancel:true},
5472 * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
5475 defaultTextHeight : 75,
5477 * The maximum width in pixels of the message box (defaults to 600)
5482 * The minimum width in pixels of the message box (defaults to 100)
5487 * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
5488 * for setting a different minimum width than text-only dialogs may need (defaults to 250)
5491 minProgressWidth : 250,
5493 * An object containing the default button text strings that can be overriden for localized language support.
5494 * Supported properties are: ok, cancel, yes and no.
5495 * Customize the default text like so: Roo.MessageBox.buttonText.yes = "S?";
5508 * Shorthand for {@link Roo.MessageBox}
5510 Roo.MessageBox = Roo.MessageBox || Roo.bootstrap.MessageBox;
5511 Roo.Msg = Roo.Msg || Roo.MessageBox;
5520 * @class Roo.bootstrap.Navbar
5521 * @extends Roo.bootstrap.Component
5522 * Bootstrap Navbar class
5525 * Create a new Navbar
5526 * @param {Object} config The config object
5530 Roo.bootstrap.Navbar = function(config){
5531 Roo.bootstrap.Navbar.superclass.constructor.call(this, config);
5535 * @event beforetoggle
5536 * Fire before toggle the menu
5537 * @param {Roo.EventObject} e
5539 "beforetoggle" : true
5543 Roo.extend(Roo.bootstrap.Navbar, Roo.bootstrap.Component, {
5552 getAutoCreate : function(){
5555 throw { message : "nav bar is now a abstract base class - use NavSimplebar / NavHeaderbar / NavSidebar etc..."};
5559 initEvents :function ()
5561 //Roo.log(this.el.select('.navbar-toggle',true));
5562 this.el.select('.navbar-toggle',true).on('click', this.onToggle , this);
5569 this.maskEl = Roo.DomHelper.append(this.el, mark, true);
5571 var size = this.el.getSize();
5572 this.maskEl.setSize(size.width, size.height);
5573 this.maskEl.enableDisplayMode("block");
5582 getChildContainer : function()
5584 if (this.el && this.el.select('.collapse').getCount()) {
5585 return this.el.select('.collapse',true).first();
5600 onToggle : function()
5603 if(this.fireEvent('beforetoggle', this) === false){
5606 var ce = this.el.select('.navbar-collapse',true).first();
5608 if (!ce.hasClass('show')) {
5618 * Expand the navbar pulldown
5620 expand : function ()
5623 var ce = this.el.select('.navbar-collapse',true).first();
5624 if (ce.hasClass('collapsing')) {
5627 ce.dom.style.height = '';
5629 ce.addClass('in'); // old...
5630 ce.removeClass('collapse');
5631 ce.addClass('show');
5632 var h = ce.getHeight();
5634 ce.removeClass('show');
5635 // at this point we should be able to see it..
5636 ce.addClass('collapsing');
5638 ce.setHeight(0); // resize it ...
5639 ce.on('transitionend', function() {
5640 //Roo.log('done transition');
5641 ce.removeClass('collapsing');
5642 ce.addClass('show');
5643 ce.removeClass('collapse');
5645 ce.dom.style.height = '';
5646 }, this, { single: true} );
5648 ce.dom.scrollTop = 0;
5651 * Collapse the navbar pulldown
5653 collapse : function()
5655 var ce = this.el.select('.navbar-collapse',true).first();
5657 if (ce.hasClass('collapsing') || ce.hasClass('collapse') ) {
5658 // it's collapsed or collapsing..
5661 ce.removeClass('in'); // old...
5662 ce.setHeight(ce.getHeight());
5663 ce.removeClass('show');
5664 ce.addClass('collapsing');
5666 ce.on('transitionend', function() {
5667 ce.dom.style.height = '';
5668 ce.removeClass('collapsing');
5669 ce.addClass('collapse');
5670 }, this, { single: true} );
5690 * @class Roo.bootstrap.NavSimplebar
5691 * @extends Roo.bootstrap.Navbar
5692 * Bootstrap Sidebar class
5694 * @cfg {Boolean} inverse is inverted color
5696 * @cfg {String} type (nav | pills | tabs)
5697 * @cfg {Boolean} arrangement stacked | justified
5698 * @cfg {String} align (left | right) alignment
5700 * @cfg {Boolean} main (true|false) main nav bar? default false
5701 * @cfg {Boolean} loadMask (true|false) loadMask on the bar
5703 * @cfg {String} tag (header|footer|nav|div) default is nav
5705 * @cfg {String} weight (light|primary|secondary|success|danger|warning|info|dark|white) default is light.
5709 * Create a new Sidebar
5710 * @param {Object} config The config object
5714 Roo.bootstrap.NavSimplebar = function(config){
5715 Roo.bootstrap.NavSimplebar.superclass.constructor.call(this, config);
5718 Roo.extend(Roo.bootstrap.NavSimplebar, Roo.bootstrap.Navbar, {
5734 getAutoCreate : function(){
5738 tag : this.tag || 'div',
5739 cls : 'navbar roo-navbar-simple' //navbar-expand-lg ??
5741 if (['light','white'].indexOf(this.weight) > -1) {
5742 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
5744 cfg.cls += ' bg-' + this.weight;
5747 cfg.cls += ' navbar-inverse';
5751 // i'm not actually sure these are really used - normally we add a navGroup to a navbar
5753 if (Roo.bootstrap.version == 4 && this.xtype == 'NavSimplebar') {
5762 cls: 'nav nav-' + this.xtype,
5768 this.type = this.type || 'nav';
5769 if (['tabs','pills'].indexOf(this.type) != -1) {
5770 cfg.cn[0].cls += ' nav-' + this.type
5774 if (this.type!=='nav') {
5775 Roo.log('nav type must be nav/tabs/pills')
5777 cfg.cn[0].cls += ' navbar-nav'
5783 if (['stacked','justified'].indexOf(this.arrangement) != -1) {
5784 cfg.cn[0].cls += ' nav-' + this.arrangement;
5788 if (this.align === 'right') {
5789 cfg.cn[0].cls += ' navbar-right';
5814 * navbar-expand-md fixed-top
5818 * @class Roo.bootstrap.NavHeaderbar
5819 * @extends Roo.bootstrap.NavSimplebar
5820 * Bootstrap Sidebar class
5822 * @cfg {String} brand what is brand
5823 * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
5824 * @cfg {String} brand_href href of the brand
5825 * @cfg {Boolean} srButton generate the (screen reader / mobile) sr-only button default true
5826 * @cfg {Boolean} autohide a top nav bar header that hides on scroll.
5827 * @cfg {Boolean} desktopCenter should the header be centered on desktop using a container class
5828 * @cfg {Roo.bootstrap.Row} mobilerow - a row to display on mobile only..
5831 * Create a new Sidebar
5832 * @param {Object} config The config object
5836 Roo.bootstrap.NavHeaderbar = function(config){
5837 Roo.bootstrap.NavHeaderbar.superclass.constructor.call(this, config);
5841 Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar, {
5848 desktopCenter : false,
5851 getAutoCreate : function(){
5854 tag: this.nav || 'nav',
5855 cls: 'navbar navbar-expand-md',
5861 if (this.desktopCenter) {
5862 cn.push({cls : 'container', cn : []});
5870 cls: 'navbar-toggle navbar-toggler',
5871 'data-toggle': 'collapse',
5876 html: 'Toggle navigation'
5880 cls: 'icon-bar navbar-toggler-icon'
5893 cn.push( Roo.bootstrap.version == 4 ? btn : {
5895 cls: 'navbar-header',
5904 cls: Roo.bootstrap.version == 4 ? 'nav flex-row roo-navbar-collapse collapse navbar-collapse' : 'collapse navbar-collapse roo-navbar-collapse',
5908 cfg.cls += this.inverse ? ' navbar-inverse navbar-dark bg-dark' : ' navbar-default';
5910 if (['light','white'].indexOf(this.weight) > -1) {
5911 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
5913 cfg.cls += ' bg-' + this.weight;
5916 if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
5917 cfg.cls += ' navbar-' + this.position + ' ' + this.position ;
5919 // tag can override this..
5921 cfg.tag = this.tag || (this.position == 'fixed-bottom' ? 'footer' : 'header');
5924 if (this.brand !== '') {
5925 var cp = Roo.bootstrap.version == 4 ? cn : cn[0].cn;
5926 cp.unshift({ // changed from push ?? BS4 needs it at the start? - does this break or exsiting?
5928 href: this.brand_href ? this.brand_href : '#',
5929 cls: 'navbar-brand',
5937 cfg.cls += ' main-nav';
5945 getHeaderChildContainer : function()
5947 if (this.srButton && this.el.select('.navbar-header').getCount()) {
5948 return this.el.select('.navbar-header',true).first();
5951 return this.getChildContainer();
5954 getChildContainer : function()
5957 return this.el.select('.roo-navbar-collapse',true).first();
5962 initEvents : function()
5964 Roo.bootstrap.NavHeaderbar.superclass.initEvents.call(this);
5966 if (this.autohide) {
5971 Roo.get(document).on('scroll',function(e) {
5972 var ns = Roo.get(document).getScroll().top;
5973 var os = prevScroll;
5977 ft.removeClass('slideDown');
5978 ft.addClass('slideUp');
5981 ft.removeClass('slideUp');
5982 ft.addClass('slideDown');
6003 * @class Roo.bootstrap.NavSidebar
6004 * @extends Roo.bootstrap.Navbar
6005 * Bootstrap Sidebar class
6008 * Create a new Sidebar
6009 * @param {Object} config The config object
6013 Roo.bootstrap.NavSidebar = function(config){
6014 Roo.bootstrap.NavSidebar.superclass.constructor.call(this, config);
6017 Roo.extend(Roo.bootstrap.NavSidebar, Roo.bootstrap.Navbar, {
6019 sidebar : true, // used by Navbar Item and NavbarGroup at present...
6021 getAutoCreate : function(){
6026 cls: 'sidebar sidebar-nav'
6048 * @class Roo.bootstrap.NavGroup
6049 * @extends Roo.bootstrap.Component
6050 * Bootstrap NavGroup class
6051 * @cfg {String} align (left|right)
6052 * @cfg {Boolean} inverse
6053 * @cfg {String} type (nav|pills|tab) default nav
6054 * @cfg {String} navId - reference Id for navbar.
6055 * @cfg {Boolean} pilltype default true (turn to off to disable active toggle)
6058 * Create a new nav group
6059 * @param {Object} config The config object
6062 Roo.bootstrap.NavGroup = function(config){
6063 Roo.bootstrap.NavGroup.superclass.constructor.call(this, config);
6066 Roo.bootstrap.NavGroup.register(this);
6070 * Fires when the active item changes
6071 * @param {Roo.bootstrap.NavGroup} this
6072 * @param {Roo.bootstrap.Navbar.Item} selected The item selected
6073 * @param {Roo.bootstrap.Navbar.Item} prev The previously selected item
6080 Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, {
6092 getAutoCreate : function()
6094 var cfg = Roo.apply({}, Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));
6100 if (Roo.bootstrap.version == 4) {
6101 if (['tabs','pills'].indexOf(this.type) != -1) {
6102 cfg.cls += ' nav-' + this.type;
6104 // trying to remove so header bar can right align top?
6105 if (this.parent() && this.parent().xtype != 'NavHeaderbar') {
6106 // do not use on header bar...
6107 cfg.cls += ' navbar-nav';
6112 if (['tabs','pills'].indexOf(this.type) != -1) {
6113 cfg.cls += ' nav-' + this.type
6115 if (this.type !== 'nav') {
6116 Roo.log('nav type must be nav/tabs/pills')
6118 cfg.cls += ' navbar-nav'
6122 if (this.parent() && this.parent().sidebar) {
6125 cls: 'dashboard-menu sidebar-menu'
6131 if (this.form === true) {
6134 cls: 'navbar-form form-inline'
6136 //nav navbar-right ml-md-auto
6137 if (this.align === 'right') {
6138 cfg.cls += ' navbar-right ml-md-auto';
6140 cfg.cls += ' navbar-left';
6144 if (this.align === 'right') {
6145 cfg.cls += ' navbar-right ml-md-auto';
6147 cfg.cls += ' mr-auto';
6151 cfg.cls += ' navbar-inverse';
6159 * sets the active Navigation item
6160 * @param {Roo.bootstrap.NavItem} the new current navitem
6162 setActiveItem : function(item)
6165 Roo.each(this.navItems, function(v){
6170 v.setActive(false, true);
6177 item.setActive(true, true);
6178 this.fireEvent('changed', this, item, prev);
6183 * gets the active Navigation item
6184 * @return {Roo.bootstrap.NavItem} the current navitem
6186 getActive : function()
6190 Roo.each(this.navItems, function(v){
6201 indexOfNav : function()
6205 Roo.each(this.navItems, function(v,i){
6216 * adds a Navigation item
6217 * @param {Roo.bootstrap.NavItem} the navitem to add
6219 addItem : function(cfg)
6221 if (this.form && Roo.bootstrap.version == 4) {
6224 var cn = new Roo.bootstrap.NavItem(cfg);
6226 cn.parentId = this.id;
6227 cn.onRender(this.el, null);
6231 * register a Navigation item
6232 * @param {Roo.bootstrap.NavItem} the navitem to add
6234 register : function(item)
6236 this.navItems.push( item);
6237 item.navId = this.navId;
6242 * clear all the Navigation item
6245 clearAll : function()
6248 this.el.dom.innerHTML = '';
6251 getNavItem: function(tabId)
6254 Roo.each(this.navItems, function(e) {
6255 if (e.tabId == tabId) {
6265 setActiveNext : function()
6267 var i = this.indexOfNav(this.getActive());
6268 if (i > this.navItems.length) {
6271 this.setActiveItem(this.navItems[i+1]);
6273 setActivePrev : function()
6275 var i = this.indexOfNav(this.getActive());
6279 this.setActiveItem(this.navItems[i-1]);
6281 clearWasActive : function(except) {
6282 Roo.each(this.navItems, function(e) {
6283 if (e.tabId != except.tabId && e.was_active) {
6284 e.was_active = false;
6291 getWasActive : function ()
6294 Roo.each(this.navItems, function(e) {
6309 Roo.apply(Roo.bootstrap.NavGroup, {
6313 * register a Navigation Group
6314 * @param {Roo.bootstrap.NavGroup} the navgroup to add
6316 register : function(navgrp)
6318 this.groups[navgrp.navId] = navgrp;
6322 * fetch a Navigation Group based on the navigation ID
6323 * @param {string} the navgroup to add
6324 * @returns {Roo.bootstrap.NavGroup} the navgroup
6326 get: function(navId) {
6327 if (typeof(this.groups[navId]) == 'undefined') {
6329 //this.register(new Roo.bootstrap.NavGroup({ navId : navId }));
6331 return this.groups[navId] ;
6346 * @class Roo.bootstrap.NavItem
6347 * @extends Roo.bootstrap.Component
6348 * Bootstrap Navbar.NavItem class
6349 * @cfg {String} href link to
6350 * @cfg {String} button_weight (default|primary|secondary|success|info|warning|danger|link|light|dark) default none
6351 * @cfg {Boolean} button_outline show and outlined button
6352 * @cfg {String} html content of button
6353 * @cfg {String} badge text inside badge
6354 * @cfg {String} badgecls (bg-green|bg-red|bg-yellow)the extra classes for the badge
6355 * @cfg {String} glyphicon DEPRICATED - use fa
6356 * @cfg {String} icon DEPRICATED - use fa
6357 * @cfg {String} fa - Fontawsome icon name (can add stuff to it like fa-2x)
6358 * @cfg {Boolean} active Is item active
6359 * @cfg {Boolean} disabled Is item disabled
6360 * @cfg {String} linkcls Link Class
6361 * @cfg {Boolean} preventDefault (true | false) default false
6362 * @cfg {String} tabId the tab that this item activates.
6363 * @cfg {String} tagtype (a|span) render as a href or span?
6364 * @cfg {Boolean} animateRef (true|false) link to element default false
6367 * Create a new Navbar Item
6368 * @param {Object} config The config object
6370 Roo.bootstrap.NavItem = function(config){
6371 Roo.bootstrap.NavItem.superclass.constructor.call(this, config);
6376 * The raw click event for the entire grid.
6377 * @param {Roo.EventObject} e
6382 * Fires when the active item active state changes
6383 * @param {Roo.bootstrap.NavItem} this
6384 * @param {boolean} state the new state
6390 * Fires when scroll to element
6391 * @param {Roo.bootstrap.NavItem} this
6392 * @param {Object} options
6393 * @param {Roo.EventObject} e
6401 Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, {
6410 preventDefault : false,
6418 button_outline : false,
6422 getAutoCreate : function(){
6429 cfg.cls = typeof(cfg.cls) == 'undefined' ? '' : cfg.cls;
6432 cfg.cls += ' active' ;
6434 if (this.disabled) {
6435 cfg.cls += ' disabled';
6439 if (this.button_weight.length) {
6440 cfg.tag = this.href ? 'a' : 'button';
6441 cfg.html = this.html || '';
6442 cfg.cls += ' btn btn' + (this.button_outline ? '-outline' : '') + '-' + this.button_weight;
6444 cfg.href = this.href;
6447 cfg.html = '<i class="fa fas fa-'+this.fa+'"></i> <span class="nav-html">' + this.html + '</span>';
6449 cfg.cls += " nav-html";
6452 // menu .. should add dropdown-menu class - so no need for carat..
6454 if (this.badge !== '') {
6456 cfg.html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
6461 if (this.href || this.html || this.glyphicon || this.icon || this.fa) {
6465 href : this.href || "#",
6466 html: this.html || '',
6470 if (this.tagtype == 'a') {
6471 cfg.cn[0].cls = 'nav-link' + (this.active ? ' active' : '') + ' ' + this.linkcls;
6475 cfg.cn[0].html = '<i class="'+this.icon+'"></i> <span class="nav-html">' + cfg.cn[0].html + '</span>';
6476 } else if (this.fa) {
6477 cfg.cn[0].html = '<i class="fa fas fa-'+this.fa+'"></i> <span class="nav-html">' + cfg.cn[0].html + '</span>';
6478 } else if(this.glyphicon) {
6479 cfg.cn[0].html = '<span class="glyphicon glyphicon-' + this.glyphicon + '"></span> ' + cfg.cn[0].html;
6481 cfg.cn[0].cls += " nav-html";
6485 cfg.cn[0].html += " <span class='caret'></span>";
6489 if (this.badge !== '') {
6490 cfg.cn[0].html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
6498 onRender : function(ct, position)
6500 // Roo.log("Call onRender: " + this.xtype);
6501 if (Roo.bootstrap.version == 4 && ct.dom.type != 'ul') {
6505 var ret = Roo.bootstrap.NavItem.superclass.onRender.call(this, ct, position);
6506 this.navLink = this.el.select('.nav-link',true).first();
6507 this.htmlEl = this.el.hasClass('nav-html') ? this.el : this.el.select('.nav-html',true).first();
6512 initEvents: function()
6514 if (typeof (this.menu) != 'undefined') {
6515 this.menu.parentType = this.xtype;
6516 this.menu.triggerEl = this.el;
6517 this.menu = this.addxtype(Roo.apply({}, this.menu));
6520 this.el.on('click', this.onClick, this);
6522 //if(this.tagtype == 'span'){
6523 // this.el.select('span',true).on('click', this.onClick, this);
6526 // at this point parent should be available..
6527 this.parent().register(this);
6530 onClick : function(e)
6532 if (e.getTarget('.dropdown-menu-item')) {
6533 // did you click on a menu itemm.... - then don't trigger onclick..
6538 this.preventDefault ||
6541 Roo.log("NavItem - prevent Default?");
6545 if (this.disabled) {
6549 var tg = Roo.bootstrap.TabGroup.get(this.navId);
6550 if (tg && tg.transition) {
6551 Roo.log("waiting for the transitionend");
6557 //Roo.log("fire event clicked");
6558 if(this.fireEvent('click', this, e) === false){
6562 if(this.tagtype == 'span'){
6566 //Roo.log(this.href);
6567 var ael = this.el.select('a',true).first();
6570 if(ael && this.animateRef && this.href.indexOf('#') > -1){
6571 //Roo.log(["test:",ael.dom.href.split("#")[0], document.location.toString().split("#")[0]]);
6572 if (ael.dom.href.split("#")[0] != document.location.toString().split("#")[0]) {
6573 return; // ignore... - it's a 'hash' to another page.
6575 Roo.log("NavItem - prevent Default?");
6577 this.scrollToElement(e);
6581 var p = this.parent();
6583 if (['tabs','pills'].indexOf(p.type)!==-1 && p.pilltype) {
6584 if (typeof(p.setActiveItem) !== 'undefined') {
6585 p.setActiveItem(this);
6589 // if parent is a navbarheader....- and link is probably a '#' page ref.. then remove the expanded menu.
6590 if (p.parentType == 'NavHeaderbar' && !this.menu) {
6591 // remove the collapsed menu expand...
6592 p.parent().el.select('.roo-navbar-collapse',true).removeClass('in');
6596 isActive: function () {
6599 setActive : function(state, fire, is_was_active)
6601 if (this.active && !state && this.navId) {
6602 this.was_active = true;
6603 var nv = Roo.bootstrap.NavGroup.get(this.navId);
6605 nv.clearWasActive(this);
6609 this.active = state;
6612 this.el.removeClass('active');
6613 this.navLink ? this.navLink.removeClass('active') : false;
6614 } else if (!this.el.hasClass('active')) {
6616 this.el.addClass('active');
6617 if (Roo.bootstrap.version == 4 && this.navLink ) {
6618 this.navLink.addClass('active');
6623 this.fireEvent('changed', this, state);
6626 // show a panel if it's registered and related..
6628 if (!this.navId || !this.tabId || !state || is_was_active) {
6632 var tg = Roo.bootstrap.TabGroup.get(this.navId);
6636 var pan = tg.getPanelByName(this.tabId);
6640 // if we can not flip to new panel - go back to old nav highlight..
6641 if (false == tg.showPanel(pan)) {
6642 var nv = Roo.bootstrap.NavGroup.get(this.navId);
6644 var onav = nv.getWasActive();
6646 onav.setActive(true, false, true);
6655 // this should not be here...
6656 setDisabled : function(state)
6658 this.disabled = state;
6660 this.el.removeClass('disabled');
6661 } else if (!this.el.hasClass('disabled')) {
6662 this.el.addClass('disabled');
6668 * Fetch the element to display the tooltip on.
6669 * @return {Roo.Element} defaults to this.el
6671 tooltipEl : function()
6673 return this.el; //this.tagtype == 'a' ? this.el : this.el.select('' + this.tagtype + '', true).first();
6676 scrollToElement : function(e)
6678 var c = document.body;
6681 * Firefox / IE places the overflow at the html level, unless specifically styled to behave differently.
6683 if(Roo.isFirefox || Roo.isIE || Roo.isIE11){
6684 c = document.documentElement;
6687 var target = Roo.get(c).select('a[name=' + this.href.split('#')[1] +']', true).first();
6693 var o = target.calcOffsetsTo(c);
6700 this.fireEvent('scrollto', this, options, e);
6702 Roo.get(c).scrollTo('top', options.value, true);
6707 * Set the HTML (text content) of the item
6708 * @param {string} html content for the nav item
6710 setHtml : function(html)
6713 this.htmlEl.dom.innerHTML = html;
6725 * <span> icon </span>
6726 * <span> text </span>
6727 * <span>badge </span>
6731 * @class Roo.bootstrap.NavSidebarItem
6732 * @extends Roo.bootstrap.NavItem
6733 * Bootstrap Navbar.NavSidebarItem class
6734 * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
6735 * {Boolean} open is the menu open
6736 * {Boolean} buttonView use button as the tigger el rather that a (default false)
6737 * {String} buttonWeight (default|primary|success|info|warning|danger)the extra classes for the button
6738 * {String} buttonSize (sm|md|lg)the extra classes for the button
6739 * {Boolean} showArrow show arrow next to the text (default true)
6741 * Create a new Navbar Button
6742 * @param {Object} config The config object
6744 Roo.bootstrap.NavSidebarItem = function(config){
6745 Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this, config);
6750 * The raw click event for the entire grid.
6751 * @param {Roo.EventObject} e
6756 * Fires when the active item active state changes
6757 * @param {Roo.bootstrap.NavSidebarItem} this
6758 * @param {boolean} state the new state
6766 Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem, {
6768 badgeWeight : 'default',
6774 buttonWeight : 'default',
6780 getAutoCreate : function(){
6785 href : this.href || '#',
6791 if(this.buttonView){
6794 href : this.href || '#',
6795 cls: 'btn btn-' + this.buttonWeight + ' btn-' + this.buttonSize + 'roo-button-dropdown-toggle',
6808 cfg.cls += ' active';
6811 if (this.disabled) {
6812 cfg.cls += ' disabled';
6815 cfg.cls += ' open x-open';
6818 if (this.glyphicon || this.icon) {
6819 var c = this.glyphicon ? ('glyphicon glyphicon-'+this.glyphicon) : this.icon;
6820 a.cn.push({ tag : 'i', cls : c }) ;
6823 if(!this.buttonView){
6826 html : this.html || ''
6833 if (this.badge !== '') {
6834 a.cn.push({ tag: 'span', cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge });
6840 a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
6843 a.cls += ' dropdown-toggle treeview' ;
6849 initEvents : function()
6851 if (typeof (this.menu) != 'undefined') {
6852 this.menu.parentType = this.xtype;
6853 this.menu.triggerEl = this.el;
6854 this.menu = this.addxtype(Roo.apply({}, this.menu));
6857 this.el.on('click', this.onClick, this);
6859 if(this.badge !== ''){
6860 this.badgeEl = this.el.select('.badge', true).first().setVisibilityMode(Roo.Element.DISPLAY);
6865 onClick : function(e)
6872 if(this.preventDefault){
6876 this.fireEvent('click', this, e);
6879 disable : function()
6881 this.setDisabled(true);
6886 this.setDisabled(false);
6889 setDisabled : function(state)
6891 if(this.disabled == state){
6895 this.disabled = state;
6898 this.el.addClass('disabled');
6902 this.el.removeClass('disabled');
6907 setActive : function(state)
6909 if(this.active == state){
6913 this.active = state;
6916 this.el.addClass('active');
6920 this.el.removeClass('active');
6925 isActive: function ()
6930 setBadge : function(str)
6936 this.badgeEl.dom.innerHTML = str;
6951 Roo.namespace('Roo.bootstrap.breadcrumb');
6955 * @class Roo.bootstrap.breadcrumb.Nav
6956 * @extends Roo.bootstrap.Component
6957 * Bootstrap Breadcrumb Nav Class
6959 * @children Roo.bootstrap.breadcrumb.Item
6962 * Create a new breadcrumb.Nav
6963 * @param {Object} config The config object
6967 Roo.bootstrap.breadcrumb.Nav = function(config){
6968 Roo.bootstrap.breadcrumb.Nav.superclass.constructor.call(this, config);
6973 Roo.extend(Roo.bootstrap.breadcrumb.Nav, Roo.bootstrap.Component, {
6975 getAutoCreate : function()
6992 initEvents: function()
6994 this.olEl = this.el.select('ol',true).first();
6996 getChildContainer : function()
7012 * @class Roo.bootstrap.breadcrumb.Nav
7013 * @extends Roo.bootstrap.Component
7014 * Bootstrap Breadcrumb Nav Class
7016 * @children Roo.bootstrap.breadcrumb.Component
7017 * @cfg {String} html the content of the link.
7018 * @cfg {String} href where it links to if '#' is used the link will be handled by onClick.
7019 * @cfg {Boolean} active is it active
7023 * Create a new breadcrumb.Nav
7024 * @param {Object} config The config object
7027 Roo.bootstrap.breadcrumb.Item = function(config){
7028 Roo.bootstrap.breadcrumb.Item.superclass.constructor.call(this, config);
7033 * The img click event for the img.
7034 * @param {Roo.EventObject} e
7041 Roo.extend(Roo.bootstrap.breadcrumb.Item, Roo.bootstrap.Component, {
7046 getAutoCreate : function()
7051 cls : 'breadcrumb-item' + (this.active ? ' active' : '')
7053 if (this.href !== false) {
7060 cfg.html = this.html;
7066 initEvents: function()
7069 this.el.select('a', true).first().on('click',this.onClick, this)
7073 onClick : function(e)
7076 this.fireEvent('click',this, e);
7089 * @class Roo.bootstrap.Row
7090 * @extends Roo.bootstrap.Component
7091 * Bootstrap Row class (contains columns...)
7095 * @param {Object} config The config object
7098 Roo.bootstrap.Row = function(config){
7099 Roo.bootstrap.Row.superclass.constructor.call(this, config);
7102 Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component, {
7104 getAutoCreate : function(){
7123 * @class Roo.bootstrap.Pagination
7124 * @extends Roo.bootstrap.Component
7125 * Bootstrap Pagination class
7126 * @cfg {String} size xs | sm | md | lg
7127 * @cfg {Boolean} inverse false | true
7130 * Create a new Pagination
7131 * @param {Object} config The config object
7134 Roo.bootstrap.Pagination = function(config){
7135 Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
7138 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component, {
7144 getAutoCreate : function(){
7150 cfg.cls += ' inverse';
7156 cfg.cls += " " + this.cls;
7174 * @class Roo.bootstrap.PaginationItem
7175 * @extends Roo.bootstrap.Component
7176 * Bootstrap PaginationItem class
7177 * @cfg {String} html text
7178 * @cfg {String} href the link
7179 * @cfg {Boolean} preventDefault (true | false) default true
7180 * @cfg {Boolean} active (true | false) default false
7181 * @cfg {Boolean} disabled default false
7185 * Create a new PaginationItem
7186 * @param {Object} config The config object
7190 Roo.bootstrap.PaginationItem = function(config){
7191 Roo.bootstrap.PaginationItem.superclass.constructor.call(this, config);
7196 * The raw click event for the entire grid.
7197 * @param {Roo.EventObject} e
7203 Roo.extend(Roo.bootstrap.PaginationItem, Roo.bootstrap.Component, {
7207 preventDefault: true,
7212 getAutoCreate : function(){
7218 href : this.href ? this.href : '#',
7219 html : this.html ? this.html : ''
7229 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' disabled' : 'disabled';
7233 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' active' : 'active';
7239 initEvents: function() {
7241 this.el.on('click', this.onClick, this);
7244 onClick : function(e)
7246 Roo.log('PaginationItem on click ');
7247 if(this.preventDefault){
7255 this.fireEvent('click', this, e);
7271 * @class Roo.bootstrap.Slider
7272 * @extends Roo.bootstrap.Component
7273 * Bootstrap Slider class
7276 * Create a new Slider
7277 * @param {Object} config The config object
7280 Roo.bootstrap.Slider = function(config){
7281 Roo.bootstrap.Slider.superclass.constructor.call(this, config);
7284 Roo.extend(Roo.bootstrap.Slider, Roo.bootstrap.Component, {
7286 getAutoCreate : function(){
7290 cls: 'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',
7294 cls: 'ui-slider-handle ui-state-default ui-corner-all'
7306 * Ext JS Library 1.1.1
7307 * Copyright(c) 2006-2007, Ext JS, LLC.
7309 * Originally Released Under LGPL - original licence link has changed is not relivant.
7312 * <script type="text/javascript">
7315 * @extends Roo.dd.DDProxy
7316 * @class Roo.grid.SplitDragZone
7317 * Support for Column Header resizing
7319 * @param {Object} config
7322 // This is a support class used internally by the Grid components
7323 Roo.grid.SplitDragZone = function(grid, hd, hd2){
7325 this.view = grid.getView();
7326 this.proxy = this.view.resizeProxy;
7327 Roo.grid.SplitDragZone.superclass.constructor.call(
7330 "gridSplitters" + this.grid.getGridEl().id, // SGROUP
7332 dragElId : Roo.id(this.proxy.dom),
7337 this.setHandleElId(Roo.id(hd));
7338 if (hd2 !== false) {
7339 this.setOuterHandleElId(Roo.id(hd2));
7342 this.scroll = false;
7344 Roo.extend(Roo.grid.SplitDragZone, Roo.dd.DDProxy, {
7345 fly: Roo.Element.fly,
7347 b4StartDrag : function(x, y){
7348 this.view.headersDisabled = true;
7349 var h = this.view.mainWrap ? this.view.mainWrap.getHeight() : (
7350 this.view.headEl.getHeight() + this.view.bodyEl.getHeight()
7352 this.proxy.setHeight(h);
7354 // for old system colWidth really stored the actual width?
7355 // in bootstrap we tried using xs/ms/etc.. to do % sizing?
7356 // which in reality did not work.. - it worked only for fixed sizes
7357 // for resizable we need to use actual sizes.
7358 var w = this.cm.getColumnWidth(this.cellIndex);
7359 if (!this.view.mainWrap) {
7361 w = this.view.getHeaderIndex(this.cellIndex).getWidth();
7366 // this was w-this.grid.minColumnWidth;
7367 // doesnt really make sense? - w = thie curren width or the rendered one?
7368 var minw = Math.max(w-this.grid.minColumnWidth, 0);
7369 this.resetConstraints();
7370 this.setXConstraint(minw, 1000);
7371 this.setYConstraint(0, 0);
7372 this.minX = x - minw;
7373 this.maxX = x + 1000;
7375 if (!this.view.mainWrap) { // this is Bootstrap code..
7376 this.getDragEl().style.display='block';
7379 Roo.dd.DDProxy.prototype.b4StartDrag.call(this, x, y);
7383 handleMouseDown : function(e){
7384 ev = Roo.EventObject.setEvent(e);
7385 var t = this.fly(ev.getTarget());
7386 if(t.hasClass("x-grid-split")){
7387 this.cellIndex = this.view.getCellIndex(t.dom);
7389 this.cm = this.grid.colModel;
7390 if(this.cm.isResizable(this.cellIndex) && !this.cm.isFixed(this.cellIndex)){
7391 Roo.grid.SplitDragZone.superclass.handleMouseDown.apply(this, arguments);
7396 endDrag : function(e){
7397 this.view.headersDisabled = false;
7398 var endX = Math.max(this.minX, Roo.lib.Event.getPageX(e));
7399 var diff = endX - this.startPos;
7401 var w = this.cm.getColumnWidth(this.cellIndex);
7402 if (!this.view.mainWrap) {
7405 this.view.onColumnSplitterMoved(this.cellIndex, w+diff);
7408 autoOffset : function(){
7413 * Ext JS Library 1.1.1
7414 * Copyright(c) 2006-2007, Ext JS, LLC.
7416 * Originally Released Under LGPL - original licence link has changed is not relivant.
7419 * <script type="text/javascript">
7423 * @class Roo.grid.AbstractSelectionModel
7424 * @extends Roo.util.Observable
7426 * Abstract base class for grid SelectionModels. It provides the interface that should be
7427 * implemented by descendant classes. This class should not be directly instantiated.
7430 Roo.grid.AbstractSelectionModel = function(){
7431 this.locked = false;
7432 Roo.grid.AbstractSelectionModel.superclass.constructor.call(this);
7435 Roo.extend(Roo.grid.AbstractSelectionModel, Roo.util.Observable, {
7436 /** @ignore Called by the grid automatically. Do not call directly. */
7437 init : function(grid){
7443 * Locks the selections.
7450 * Unlocks the selections.
7452 unlock : function(){
7453 this.locked = false;
7457 * Returns true if the selections are locked.
7460 isLocked : function(){
7465 * Ext JS Library 1.1.1
7466 * Copyright(c) 2006-2007, Ext JS, LLC.
7468 * Originally Released Under LGPL - original licence link has changed is not relivant.
7471 * <script type="text/javascript">
7474 * @extends Roo.grid.AbstractSelectionModel
7475 * @class Roo.grid.RowSelectionModel
7476 * The default SelectionModel used by {@link Roo.grid.Grid}.
7477 * It supports multiple selections and keyboard selection/navigation.
7479 * @param {Object} config
7481 Roo.grid.RowSelectionModel = function(config){
7482 Roo.apply(this, config);
7483 this.selections = new Roo.util.MixedCollection(false, function(o){
7488 this.lastActive = false;
7492 * @event selectionchange
7493 * Fires when the selection changes
7494 * @param {SelectionModel} this
7496 "selectionchange" : true,
7498 * @event afterselectionchange
7499 * Fires after the selection changes (eg. by key press or clicking)
7500 * @param {SelectionModel} this
7502 "afterselectionchange" : true,
7504 * @event beforerowselect
7505 * Fires when a row is selected being selected, return false to cancel.
7506 * @param {SelectionModel} this
7507 * @param {Number} rowIndex The selected index
7508 * @param {Boolean} keepExisting False if other selections will be cleared
7510 "beforerowselect" : true,
7513 * Fires when a row is selected.
7514 * @param {SelectionModel} this
7515 * @param {Number} rowIndex The selected index
7516 * @param {Roo.data.Record} r The record
7520 * @event rowdeselect
7521 * Fires when a row is deselected.
7522 * @param {SelectionModel} this
7523 * @param {Number} rowIndex The selected index
7525 "rowdeselect" : true
7527 Roo.grid.RowSelectionModel.superclass.constructor.call(this);
7528 this.locked = false;
7531 Roo.extend(Roo.grid.RowSelectionModel, Roo.grid.AbstractSelectionModel, {
7533 * @cfg {Boolean} singleSelect
7534 * True to allow selection of only one row at a time (defaults to false)
7536 singleSelect : false,
7539 initEvents : function(){
7541 if(!this.grid.enableDragDrop && !this.grid.enableDrag){
7542 this.grid.on("mousedown", this.handleMouseDown, this);
7543 }else{ // allow click to work like normal
7544 this.grid.on("rowclick", this.handleDragableRowClick, this);
7546 // bootstrap does not have a view..
7547 var view = this.grid.view ? this.grid.view : this.grid;
7548 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
7551 this.selectPrevious(e.shiftKey);
7552 }else if(this.last !== false && this.lastActive !== false){
7553 var last = this.last;
7554 this.selectRange(this.last, this.lastActive-1);
7555 view.focusRow(this.lastActive);
7560 this.selectFirstRow();
7562 this.fireEvent("afterselectionchange", this);
7564 "down" : function(e){
7566 this.selectNext(e.shiftKey);
7567 }else if(this.last !== false && this.lastActive !== false){
7568 var last = this.last;
7569 this.selectRange(this.last, this.lastActive+1);
7570 view.focusRow(this.lastActive);
7575 this.selectFirstRow();
7577 this.fireEvent("afterselectionchange", this);
7583 view.on("refresh", this.onRefresh, this);
7584 view.on("rowupdated", this.onRowUpdated, this);
7585 view.on("rowremoved", this.onRemove, this);
7589 onRefresh : function(){
7590 var ds = this.grid.ds, i, v = this.grid.view;
7591 var s = this.selections;
7593 if((i = ds.indexOfId(r.id)) != -1){
7595 s.add(ds.getAt(i)); // updating the selection relate data
7603 onRemove : function(v, index, r){
7604 this.selections.remove(r);
7608 onRowUpdated : function(v, index, r){
7609 if(this.isSelected(r)){
7610 v.onRowSelect(index);
7616 * @param {Array} records The records to select
7617 * @param {Boolean} keepExisting (optional) True to keep existing selections
7619 selectRecords : function(records, keepExisting){
7621 this.clearSelections();
7623 var ds = this.grid.ds;
7624 for(var i = 0, len = records.length; i < len; i++){
7625 this.selectRow(ds.indexOf(records[i]), true);
7630 * Gets the number of selected rows.
7633 getCount : function(){
7634 return this.selections.length;
7638 * Selects the first row in the grid.
7640 selectFirstRow : function(){
7645 * Select the last row.
7646 * @param {Boolean} keepExisting (optional) True to keep existing selections
7648 selectLastRow : function(keepExisting){
7649 this.selectRow(this.grid.ds.getCount() - 1, keepExisting);
7653 * Selects the row immediately following the last selected row.
7654 * @param {Boolean} keepExisting (optional) True to keep existing selections
7656 selectNext : function(keepExisting){
7657 if(this.last !== false && (this.last+1) < this.grid.ds.getCount()){
7658 this.selectRow(this.last+1, keepExisting);
7659 var view = this.grid.view ? this.grid.view : this.grid;
7660 view.focusRow(this.last);
7665 * Selects the row that precedes the last selected row.
7666 * @param {Boolean} keepExisting (optional) True to keep existing selections
7668 selectPrevious : function(keepExisting){
7670 this.selectRow(this.last-1, keepExisting);
7671 var view = this.grid.view ? this.grid.view : this.grid;
7672 view.focusRow(this.last);
7677 * Returns the selected records
7678 * @return {Array} Array of selected records
7680 getSelections : function(){
7681 return [].concat(this.selections.items);
7685 * Returns the first selected record.
7688 getSelected : function(){
7689 return this.selections.itemAt(0);
7694 * Clears all selections.
7696 clearSelections : function(fast){
7701 var ds = this.grid.ds;
7702 var s = this.selections;
7704 this.deselectRow(ds.indexOfId(r.id));
7708 this.selections.clear();
7717 selectAll : function(){
7721 this.selections.clear();
7722 for(var i = 0, len = this.grid.ds.getCount(); i < len; i++){
7723 this.selectRow(i, true);
7728 * Returns True if there is a selection.
7731 hasSelection : function(){
7732 return this.selections.length > 0;
7736 * Returns True if the specified row is selected.
7737 * @param {Number/Record} record The record or index of the record to check
7740 isSelected : function(index){
7741 var r = typeof index == "number" ? this.grid.ds.getAt(index) : index;
7742 return (r && this.selections.key(r.id) ? true : false);
7746 * Returns True if the specified record id is selected.
7747 * @param {String} id The id of record to check
7750 isIdSelected : function(id){
7751 return (this.selections.key(id) ? true : false);
7755 handleMouseDown : function(e, t)
7757 var view = this.grid.view ? this.grid.view : this.grid;
7759 if(this.isLocked() || (rowIndex = view.findRowIndex(t)) === false){
7762 if(e.shiftKey && this.last !== false){
7763 var last = this.last;
7764 this.selectRange(last, rowIndex, e.ctrlKey);
7765 this.last = last; // reset the last
7766 view.focusRow(rowIndex);
7768 var isSelected = this.isSelected(rowIndex);
7769 if(e.button !== 0 && isSelected){
7770 view.focusRow(rowIndex);
7771 }else if(e.ctrlKey && isSelected){
7772 this.deselectRow(rowIndex);
7773 }else if(!isSelected){
7774 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
7775 view.focusRow(rowIndex);
7778 this.fireEvent("afterselectionchange", this);
7781 handleDragableRowClick : function(grid, rowIndex, e)
7783 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
7784 this.selectRow(rowIndex, false);
7785 var view = this.grid.view ? this.grid.view : this.grid;
7786 view.focusRow(rowIndex);
7787 this.fireEvent("afterselectionchange", this);
7792 * Selects multiple rows.
7793 * @param {Array} rows Array of the indexes of the row to select
7794 * @param {Boolean} keepExisting (optional) True to keep existing selections
7796 selectRows : function(rows, keepExisting){
7798 this.clearSelections();
7800 for(var i = 0, len = rows.length; i < len; i++){
7801 this.selectRow(rows[i], true);
7806 * Selects a range of rows. All rows in between startRow and endRow are also selected.
7807 * @param {Number} startRow The index of the first row in the range
7808 * @param {Number} endRow The index of the last row in the range
7809 * @param {Boolean} keepExisting (optional) True to retain existing selections
7811 selectRange : function(startRow, endRow, keepExisting){
7816 this.clearSelections();
7818 if(startRow <= endRow){
7819 for(var i = startRow; i <= endRow; i++){
7820 this.selectRow(i, true);
7823 for(var i = startRow; i >= endRow; i--){
7824 this.selectRow(i, true);
7830 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
7831 * @param {Number} startRow The index of the first row in the range
7832 * @param {Number} endRow The index of the last row in the range
7834 deselectRange : function(startRow, endRow, preventViewNotify){
7838 for(var i = startRow; i <= endRow; i++){
7839 this.deselectRow(i, preventViewNotify);
7845 * @param {Number} row The index of the row to select
7846 * @param {Boolean} keepExisting (optional) True to keep existing selections
7848 selectRow : function(index, keepExisting, preventViewNotify){
7849 if(this.locked || (index < 0 || index >= this.grid.ds.getCount())) {
7852 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
7853 if(!keepExisting || this.singleSelect){
7854 this.clearSelections();
7856 var r = this.grid.ds.getAt(index);
7857 this.selections.add(r);
7858 this.last = this.lastActive = index;
7859 if(!preventViewNotify){
7860 var view = this.grid.view ? this.grid.view : this.grid;
7861 view.onRowSelect(index);
7863 this.fireEvent("rowselect", this, index, r);
7864 this.fireEvent("selectionchange", this);
7870 * @param {Number} row The index of the row to deselect
7872 deselectRow : function(index, preventViewNotify){
7876 if(this.last == index){
7879 if(this.lastActive == index){
7880 this.lastActive = false;
7882 var r = this.grid.ds.getAt(index);
7883 this.selections.remove(r);
7884 if(!preventViewNotify){
7885 var view = this.grid.view ? this.grid.view : this.grid;
7886 view.onRowDeselect(index);
7888 this.fireEvent("rowdeselect", this, index);
7889 this.fireEvent("selectionchange", this);
7893 restoreLast : function(){
7895 this.last = this._last;
7900 acceptsNav : function(row, col, cm){
7901 return !cm.isHidden(col) && cm.isCellEditable(col, row);
7905 onEditorKey : function(field, e){
7906 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
7911 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
7913 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
7915 }else if(k == e.ENTER && !e.ctrlKey){
7919 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
7921 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
7923 }else if(k == e.ESC){
7927 g.startEditing(newCell[0], newCell[1]);
7932 * Ext JS Library 1.1.1
7933 * Copyright(c) 2006-2007, Ext JS, LLC.
7935 * Originally Released Under LGPL - original licence link has changed is not relivant.
7938 * <script type="text/javascript">
7943 * @class Roo.grid.ColumnModel
7944 * @extends Roo.util.Observable
7945 * This is the default implementation of a ColumnModel used by the Grid. It defines
7946 * the columns in the grid.
7949 var colModel = new Roo.grid.ColumnModel([
7950 {header: "Ticker", width: 60, sortable: true, locked: true},
7951 {header: "Company Name", width: 150, sortable: true},
7952 {header: "Market Cap.", width: 100, sortable: true},
7953 {header: "$ Sales", width: 100, sortable: true, renderer: money},
7954 {header: "Employees", width: 100, sortable: true, resizable: false}
7959 * The config options listed for this class are options which may appear in each
7960 * individual column definition.
7961 * <br/>RooJS Fix - column id's are not sequential but use Roo.id() - fixes bugs with layouts.
7963 * @param {Object} config An Array of column config objects. See this class's
7964 * config objects for details.
7966 Roo.grid.ColumnModel = function(config){
7968 * The config passed into the constructor
7970 this.config = []; //config;
7973 // if no id, create one
7974 // if the column does not have a dataIndex mapping,
7975 // map it to the order it is in the config
7976 for(var i = 0, len = config.length; i < len; i++){
7977 this.addColumn(config[i]);
7982 * The width of columns which have no width specified (defaults to 100)
7985 this.defaultWidth = 100;
7988 * Default sortable of columns which have no sortable specified (defaults to false)
7991 this.defaultSortable = false;
7995 * @event widthchange
7996 * Fires when the width of a column changes.
7997 * @param {ColumnModel} this
7998 * @param {Number} columnIndex The column index
7999 * @param {Number} newWidth The new width
8001 "widthchange": true,
8003 * @event headerchange
8004 * Fires when the text of a header changes.
8005 * @param {ColumnModel} this
8006 * @param {Number} columnIndex The column index
8007 * @param {Number} newText The new header text
8009 "headerchange": true,
8011 * @event hiddenchange
8012 * Fires when a column is hidden or "unhidden".
8013 * @param {ColumnModel} this
8014 * @param {Number} columnIndex The column index
8015 * @param {Boolean} hidden true if hidden, false otherwise
8017 "hiddenchange": true,
8019 * @event columnmoved
8020 * Fires when a column is moved.
8021 * @param {ColumnModel} this
8022 * @param {Number} oldIndex
8023 * @param {Number} newIndex
8025 "columnmoved" : true,
8027 * @event columlockchange
8028 * Fires when a column's locked state is changed
8029 * @param {ColumnModel} this
8030 * @param {Number} colIndex
8031 * @param {Boolean} locked true if locked
8033 "columnlockchange" : true
8035 Roo.grid.ColumnModel.superclass.constructor.call(this);
8037 Roo.extend(Roo.grid.ColumnModel, Roo.util.Observable, {
8039 * @cfg {String} header The header text to display in the Grid view.
8042 * @cfg {String} xsHeader Header at Bootsrap Extra Small width (default for all)
8045 * @cfg {String} smHeader Header at Bootsrap Small width
8048 * @cfg {String} mdHeader Header at Bootsrap Medium width
8051 * @cfg {String} lgHeader Header at Bootsrap Large width
8054 * @cfg {String} xlHeader Header at Bootsrap extra Large width
8057 * @cfg {String} dataIndex (Optional) The name of the field in the grid's {@link Roo.data.Store}'s
8058 * {@link Roo.data.Record} definition from which to draw the column's value. If not
8059 * specified, the column's index is used as an index into the Record's data Array.
8062 * @cfg {Number} width (Optional) The initial width in pixels of the column. Using this
8063 * instead of {@link Roo.grid.Grid#autoSizeColumns} is more efficient.
8066 * @cfg {Boolean} sortable (Optional) True if sorting is to be allowed on this column.
8067 * Defaults to the value of the {@link #defaultSortable} property.
8068 * Whether local/remote sorting is used is specified in {@link Roo.data.Store#remoteSort}.
8071 * @cfg {Boolean} locked (Optional) True to lock the column in place while scrolling the Grid. Defaults to false.
8074 * @cfg {Boolean} fixed (Optional) True if the column width cannot be changed. Defaults to false.
8077 * @cfg {Boolean} resizable (Optional) False to disable column resizing. Defaults to true.
8080 * @cfg {Boolean} hidden (Optional) True to hide the column. Defaults to false.
8083 * @cfg {Function} renderer (Optional) A function used to generate HTML markup for a cell
8084 * given the cell's data value. See {@link #setRenderer}. If not specified, the
8085 * default renderer returns the escaped data value. If an object is returned (bootstrap only)
8086 * then it is treated as a Roo Component object instance, and it is rendered after the initial row is rendered
8089 * @cfg {Roo.grid.GridEditor} editor (Optional) For grid editors - returns the grid editor
8092 * @cfg {String} align (Optional) Set the CSS text-align property of the column. Defaults to undefined.
8095 * @cfg {String} valign (Optional) Set the CSS vertical-align property of the column (eg. middle, top, bottom etc). Defaults to undefined.
8098 * @cfg {String} cursor (Optional)
8101 * @cfg {String} tooltip (Optional)
8104 * @cfg {Number} xs (Optional) can be '0' for hidden at this size (number less than 12)
8107 * @cfg {Number} sm (Optional) can be '0' for hidden at this size (number less than 12)
8110 * @cfg {Number} md (Optional) can be '0' for hidden at this size (number less than 12)
8113 * @cfg {Number} lg (Optional) can be '0' for hidden at this size (number less than 12)
8116 * @cfg {Number} xl (Optional) can be '0' for hidden at this size (number less than 12)
8119 * Returns the id of the column at the specified index.
8120 * @param {Number} index The column index
8121 * @return {String} the id
8123 getColumnId : function(index){
8124 return this.config[index].id;
8128 * Returns the column for a specified id.
8129 * @param {String} id The column id
8130 * @return {Object} the column
8132 getColumnById : function(id){
8133 return this.lookup[id];
8138 * Returns the column Object for a specified dataIndex.
8139 * @param {String} dataIndex The column dataIndex
8140 * @return {Object|Boolean} the column or false if not found
8142 getColumnByDataIndex: function(dataIndex){
8143 var index = this.findColumnIndex(dataIndex);
8144 return index > -1 ? this.config[index] : false;
8148 * Returns the index for a specified column id.
8149 * @param {String} id The column id
8150 * @return {Number} the index, or -1 if not found
8152 getIndexById : function(id){
8153 for(var i = 0, len = this.config.length; i < len; i++){
8154 if(this.config[i].id == id){
8162 * Returns the index for a specified column dataIndex.
8163 * @param {String} dataIndex The column dataIndex
8164 * @return {Number} the index, or -1 if not found
8167 findColumnIndex : function(dataIndex){
8168 for(var i = 0, len = this.config.length; i < len; i++){
8169 if(this.config[i].dataIndex == dataIndex){
8177 moveColumn : function(oldIndex, newIndex){
8178 var c = this.config[oldIndex];
8179 this.config.splice(oldIndex, 1);
8180 this.config.splice(newIndex, 0, c);
8181 this.dataMap = null;
8182 this.fireEvent("columnmoved", this, oldIndex, newIndex);
8185 isLocked : function(colIndex){
8186 return this.config[colIndex].locked === true;
8189 setLocked : function(colIndex, value, suppressEvent){
8190 if(this.isLocked(colIndex) == value){
8193 this.config[colIndex].locked = value;
8195 this.fireEvent("columnlockchange", this, colIndex, value);
8199 getTotalLockedWidth : function(){
8201 for(var i = 0; i < this.config.length; i++){
8202 if(this.isLocked(i) && !this.isHidden(i)){
8203 this.totalWidth += this.getColumnWidth(i);
8209 getLockedCount : function(){
8210 for(var i = 0, len = this.config.length; i < len; i++){
8211 if(!this.isLocked(i)){
8216 return this.config.length;
8220 * Returns the number of columns.
8223 getColumnCount : function(visibleOnly){
8224 if(visibleOnly === true){
8226 for(var i = 0, len = this.config.length; i < len; i++){
8227 if(!this.isHidden(i)){
8233 return this.config.length;
8237 * Returns the column configs that return true by the passed function that is called with (columnConfig, index)
8238 * @param {Function} fn
8239 * @param {Object} scope (optional)
8240 * @return {Array} result
8242 getColumnsBy : function(fn, scope){
8244 for(var i = 0, len = this.config.length; i < len; i++){
8245 var c = this.config[i];
8246 if(fn.call(scope||this, c, i) === true){
8254 * Returns true if the specified column is sortable.
8255 * @param {Number} col The column index
8258 isSortable : function(col){
8259 if(typeof this.config[col].sortable == "undefined"){
8260 return this.defaultSortable;
8262 return this.config[col].sortable;
8266 * Returns the rendering (formatting) function defined for the column.
8267 * @param {Number} col The column index.
8268 * @return {Function} The function used to render the cell. See {@link #setRenderer}.
8270 getRenderer : function(col){
8271 if(!this.config[col].renderer){
8272 return Roo.grid.ColumnModel.defaultRenderer;
8274 return this.config[col].renderer;
8278 * Sets the rendering (formatting) function for a column.
8279 * @param {Number} col The column index
8280 * @param {Function} fn The function to use to process the cell's raw data
8281 * to return HTML markup for the grid view. The render function is called with
8282 * the following parameters:<ul>
8283 * <li>Data value.</li>
8284 * <li>Cell metadata. An object in which you may set the following attributes:<ul>
8285 * <li>css A CSS style string to apply to the table cell.</li>
8286 * <li>attr An HTML attribute definition string to apply to the data container element <i>within</i> the table cell.</li></ul>
8287 * <li>The {@link Roo.data.Record} from which the data was extracted.</li>
8288 * <li>Row index</li>
8289 * <li>Column index</li>
8290 * <li>The {@link Roo.data.Store} object from which the Record was extracted</li></ul>
8292 setRenderer : function(col, fn){
8293 this.config[col].renderer = fn;
8297 * Returns the width for the specified column.
8298 * @param {Number} col The column index
8299 * @param (optional) {String} gridSize bootstrap width size.
8302 getColumnWidth : function(col, gridSize)
8304 var cfg = this.config[col];
8306 if (typeof(gridSize) == 'undefined') {
8307 return cfg.width * 1 || this.defaultWidth;
8309 if (gridSize === false) { // if we set it..
8310 return cfg.width || false;
8312 var sizes = ['xl', 'lg', 'md', 'sm', 'xs'];
8314 for(var i = sizes.indexOf(gridSize); i < sizes.length; i++) {
8315 if (typeof(cfg[ sizes[i] ] ) == 'undefined') {
8318 return cfg[ sizes[i] ];
8325 * Sets the width for a column.
8326 * @param {Number} col The column index
8327 * @param {Number} width The new width
8329 setColumnWidth : function(col, width, suppressEvent){
8330 this.config[col].width = width;
8331 this.totalWidth = null;
8333 this.fireEvent("widthchange", this, col, width);
8338 * Returns the total width of all columns.
8339 * @param {Boolean} includeHidden True to include hidden column widths
8342 getTotalWidth : function(includeHidden){
8343 if(!this.totalWidth){
8344 this.totalWidth = 0;
8345 for(var i = 0, len = this.config.length; i < len; i++){
8346 if(includeHidden || !this.isHidden(i)){
8347 this.totalWidth += this.getColumnWidth(i);
8351 return this.totalWidth;
8355 * Returns the header for the specified column.
8356 * @param {Number} col The column index
8359 getColumnHeader : function(col){
8360 return this.config[col].header;
8364 * Sets the header for a column.
8365 * @param {Number} col The column index
8366 * @param {String} header The new header
8368 setColumnHeader : function(col, header){
8369 this.config[col].header = header;
8370 this.fireEvent("headerchange", this, col, header);
8374 * Returns the tooltip for the specified column.
8375 * @param {Number} col The column index
8378 getColumnTooltip : function(col){
8379 return this.config[col].tooltip;
8382 * Sets the tooltip for a column.
8383 * @param {Number} col The column index
8384 * @param {String} tooltip The new tooltip
8386 setColumnTooltip : function(col, tooltip){
8387 this.config[col].tooltip = tooltip;
8391 * Returns the dataIndex for the specified column.
8392 * @param {Number} col The column index
8395 getDataIndex : function(col){
8396 return this.config[col].dataIndex;
8400 * Sets the dataIndex for a column.
8401 * @param {Number} col The column index
8402 * @param {Number} dataIndex The new dataIndex
8404 setDataIndex : function(col, dataIndex){
8405 this.config[col].dataIndex = dataIndex;
8411 * Returns true if the cell is editable.
8412 * @param {Number} colIndex The column index
8413 * @param {Number} rowIndex The row index - this is nto actually used..?
8416 isCellEditable : function(colIndex, rowIndex){
8417 return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
8421 * Returns the editor defined for the cell/column.
8422 * return false or null to disable editing.
8423 * @param {Number} colIndex The column index
8424 * @param {Number} rowIndex The row index
8427 getCellEditor : function(colIndex, rowIndex){
8428 return this.config[colIndex].editor;
8432 * Sets if a column is editable.
8433 * @param {Number} col The column index
8434 * @param {Boolean} editable True if the column is editable
8436 setEditable : function(col, editable){
8437 this.config[col].editable = editable;
8442 * Returns true if the column is hidden.
8443 * @param {Number} colIndex The column index
8446 isHidden : function(colIndex){
8447 return this.config[colIndex].hidden;
8452 * Returns true if the column width cannot be changed
8454 isFixed : function(colIndex){
8455 return this.config[colIndex].fixed;
8459 * Returns true if the column can be resized
8462 isResizable : function(colIndex){
8463 return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
8466 * Sets if a column is hidden.
8467 * @param {Number} colIndex The column index
8468 * @param {Boolean} hidden True if the column is hidden
8470 setHidden : function(colIndex, hidden){
8471 this.config[colIndex].hidden = hidden;
8472 this.totalWidth = null;
8473 this.fireEvent("hiddenchange", this, colIndex, hidden);
8477 * Sets the editor for a column.
8478 * @param {Number} col The column index
8479 * @param {Object} editor The editor object
8481 setEditor : function(col, editor){
8482 this.config[col].editor = editor;
8485 * Add a column (experimental...) - defaults to adding to the end..
8486 * @param {Object} config
8488 addColumn : function(c)
8491 var i = this.config.length;
8494 if(typeof c.dataIndex == "undefined"){
8497 if(typeof c.renderer == "string"){
8498 c.renderer = Roo.util.Format[c.renderer];
8500 if(typeof c.id == "undefined"){
8503 if(c.editor && c.editor.xtype){
8504 c.editor = Roo.factory(c.editor, Roo.grid);
8506 if(c.editor && c.editor.isFormField){
8507 c.editor = new Roo.grid.GridEditor(c.editor);
8509 this.lookup[c.id] = c;
8514 Roo.grid.ColumnModel.defaultRenderer = function(value)
8516 if(typeof value == "object") {
8519 if(typeof value == "string" && value.length < 1){
8523 return String.format("{0}", value);
8526 // Alias for backwards compatibility
8527 Roo.grid.DefaultColumnModel = Roo.grid.ColumnModel;
8530 * Ext JS Library 1.1.1
8531 * Copyright(c) 2006-2007, Ext JS, LLC.
8533 * Originally Released Under LGPL - original licence link has changed is not relivant.
8536 * <script type="text/javascript">
8540 * @class Roo.LoadMask
8541 * A simple utility class for generically masking elements while loading data. If the element being masked has
8542 * an underlying {@link Roo.data.Store}, the masking will be automatically synchronized with the store's loading
8543 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
8544 * element's UpdateManager load indicator and will be destroyed after the initial load.
8546 * Create a new LoadMask
8547 * @param {String/HTMLElement/Roo.Element} el The element or DOM node, or its id
8548 * @param {Object} config The config object
8550 Roo.LoadMask = function(el, config){
8551 this.el = Roo.get(el);
8552 Roo.apply(this, config);
8554 this.store.on('beforeload', this.onBeforeLoad, this);
8555 this.store.on('load', this.onLoad, this);
8556 this.store.on('loadexception', this.onLoadException, this);
8557 this.removeMask = false;
8559 var um = this.el.getUpdateManager();
8560 um.showLoadIndicator = false; // disable the default indicator
8561 um.on('beforeupdate', this.onBeforeLoad, this);
8562 um.on('update', this.onLoad, this);
8563 um.on('failure', this.onLoad, this);
8564 this.removeMask = true;
8568 Roo.LoadMask.prototype = {
8570 * @cfg {Boolean} removeMask
8571 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
8572 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
8577 * The text to display in a centered loading message box (defaults to 'Loading...')
8581 * @cfg {String} msgCls
8582 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
8584 msgCls : 'x-mask-loading',
8587 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
8593 * Disables the mask to prevent it from being displayed
8595 disable : function(){
8596 this.disabled = true;
8600 * Enables the mask so that it can be displayed
8602 enable : function(){
8603 this.disabled = false;
8606 onLoadException : function()
8610 if (typeof(arguments[3]) != 'undefined') {
8611 Roo.MessageBox.alert("Error loading",arguments[3]);
8615 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
8616 Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
8623 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
8628 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
8632 onBeforeLoad : function(){
8634 (function() { this.el.mask(this.msg, this.msgCls); }).defer(50, this);
8639 destroy : function(){
8641 this.store.un('beforeload', this.onBeforeLoad, this);
8642 this.store.un('load', this.onLoad, this);
8643 this.store.un('loadexception', this.onLoadException, this);
8645 var um = this.el.getUpdateManager();
8646 um.un('beforeupdate', this.onBeforeLoad, this);
8647 um.un('update', this.onLoad, this);
8648 um.un('failure', this.onLoad, this);
8652 * @class Roo.bootstrap.Table
8654 * @extends Roo.bootstrap.Component
8655 * Bootstrap Table class. This class represents the primary interface of a component based grid control.
8656 * Similar to Roo.grid.Grid
8658 var table = Roo.factory({
8660 xns : Roo.bootstrap,
8661 autoSizeColumns: true,
8668 sortInfo : { direction : 'ASC', field: 'name' },
8670 xtype : 'HttpProxy',
8673 url : 'https://example.com/some.data.url.json'
8676 xtype : 'JsonReader',
8678 fields : [ 'id', 'name', whatever' ],
8685 xtype : 'ColumnModel',
8689 dataIndex : 'is_in_group',
8692 renderer : function(v, x , r) {
8694 return String.format("{0}", v)
8700 xtype : 'RowSelectionModel',
8701 xns : Roo.bootstrap.Table
8702 // you can add listeners to catch selection change here....
8708 grid.render(Roo.get("some-div"));
8711 Currently the Table uses multiple headers to try and handle XL / Medium etc... styling
8716 * @cfg {Roo.grid.AbstractSelectionModel} sm The selection model to use (cell selection is not supported yet)
8717 * @cfg {Roo.data.Store} store The data store to use
8718 * @cfg {Roo.grid.ColumnModel} cm[] A column for th grid.
8720 * @cfg {String} cls table class
8723 * @cfg {boolean} striped Should the rows be alternative striped
8724 * @cfg {boolean} bordered Add borders to the table
8725 * @cfg {boolean} hover Add hover highlighting
8726 * @cfg {boolean} condensed Format condensed
8727 * @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,
8728 * also adds table-responsive (see bootstrap docs for details)
8729 * @cfg {Boolean} loadMask (true|false) default false
8730 * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
8731 * @cfg {Boolean} headerShow (true|false) generate thead, default true
8732 * @cfg {Boolean} rowSelection (true|false) default false
8733 * @cfg {Boolean} cellSelection (true|false) default false
8734 * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header
8735 * @cfg {Roo.bootstrap.PagingToolbar} footer a paging toolbar
8736 * @cfg {Boolean} lazyLoad auto load data while scrolling to the end (default false)
8737 * @cfg {Boolean} auto_hide_footer auto hide footer if only one page (default false)
8738 * @cfg {Boolean} enableColumnResize default true if columns can be resized (drag/drop)
8739 * @cfg {Number} minColumnWidth default 50 pixels minimum column width
8742 * Create a new Table
8743 * @param {Object} config The config object
8746 Roo.bootstrap.Table = function(config)
8748 Roo.bootstrap.Table.superclass.constructor.call(this, config);
8751 this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
8752 this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
8753 this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
8754 this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
8756 this.view = this; // compat with grid.
8758 this.sm = this.sm || {xtype: 'RowSelectionModel'};
8760 this.sm.grid = this;
8761 this.selModel = Roo.factory(this.sm, Roo.grid);
8762 this.sm = this.selModel;
8763 this.sm.xmodule = this.xmodule || false;
8766 if (this.cm && typeof(this.cm.config) == 'undefined') {
8767 this.colModel = new Roo.grid.ColumnModel(this.cm);
8768 this.cm = this.colModel;
8769 this.cm.xmodule = this.xmodule || false;
8772 this.store= Roo.factory(this.store, Roo.data);
8773 this.ds = this.store;
8774 this.ds.xmodule = this.xmodule || false;
8777 if (this.footer && this.store) {
8778 this.footer.dataSource = this.ds;
8779 this.footer = Roo.factory(this.footer);
8786 * Fires when a cell is clicked
8787 * @param {Roo.bootstrap.Table} this
8788 * @param {Roo.Element} el
8789 * @param {Number} rowIndex
8790 * @param {Number} columnIndex
8791 * @param {Roo.EventObject} e
8795 * @event celldblclick
8796 * Fires when a cell is double clicked
8797 * @param {Roo.bootstrap.Table} this
8798 * @param {Roo.Element} el
8799 * @param {Number} rowIndex
8800 * @param {Number} columnIndex
8801 * @param {Roo.EventObject} e
8803 "celldblclick" : true,
8806 * Fires when a row is clicked
8807 * @param {Roo.bootstrap.Table} this
8808 * @param {Roo.Element} el
8809 * @param {Number} rowIndex
8810 * @param {Roo.EventObject} e
8814 * @event rowdblclick
8815 * Fires when a row is double clicked
8816 * @param {Roo.bootstrap.Table} this
8817 * @param {Roo.Element} el
8818 * @param {Number} rowIndex
8819 * @param {Roo.EventObject} e
8821 "rowdblclick" : true,
8824 * Fires when a mouseover occur
8825 * @param {Roo.bootstrap.Table} this
8826 * @param {Roo.Element} el
8827 * @param {Number} rowIndex
8828 * @param {Number} columnIndex
8829 * @param {Roo.EventObject} e
8834 * Fires when a mouseout occur
8835 * @param {Roo.bootstrap.Table} this
8836 * @param {Roo.Element} el
8837 * @param {Number} rowIndex
8838 * @param {Number} columnIndex
8839 * @param {Roo.EventObject} e
8844 * Fires when a row is rendered, so you can change add a style to it.
8845 * @param {Roo.bootstrap.Table} this
8846 * @param {Object} rowcfg contains record rowIndex colIndex and rowClass - set rowClass to add a style.
8850 * @event rowsrendered
8851 * Fires when all the rows have been rendered
8852 * @param {Roo.bootstrap.Table} this
8854 'rowsrendered' : true,
8856 * @event contextmenu
8857 * The raw contextmenu event for the entire grid.
8858 * @param {Roo.EventObject} e
8860 "contextmenu" : true,
8862 * @event rowcontextmenu
8863 * Fires when a row is right clicked
8864 * @param {Roo.bootstrap.Table} this
8865 * @param {Number} rowIndex
8866 * @param {Roo.EventObject} e
8868 "rowcontextmenu" : true,
8870 * @event cellcontextmenu
8871 * Fires when a cell is right clicked
8872 * @param {Roo.bootstrap.Table} this
8873 * @param {Number} rowIndex
8874 * @param {Number} cellIndex
8875 * @param {Roo.EventObject} e
8877 "cellcontextmenu" : true,
8879 * @event headercontextmenu
8880 * Fires when a header is right clicked
8881 * @param {Roo.bootstrap.Table} this
8882 * @param {Number} columnIndex
8883 * @param {Roo.EventObject} e
8885 "headercontextmenu" : true,
8888 * The raw mousedown event for the entire grid.
8889 * @param {Roo.EventObject} e
8896 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
8912 enableColumnResize: true,
8914 rowSelection : false,
8915 cellSelection : false,
8918 minColumnWidth : 50,
8920 // Roo.Element - the tbody
8921 bodyEl: false, // <tbody> Roo.Element - thead element
8922 headEl: false, // <thead> Roo.Element - thead element
8923 resizeProxy : false, // proxy element for dragging?
8927 container: false, // used by gridpanel...
8933 auto_hide_footer : false,
8935 view: false, // actually points to this..
8937 getAutoCreate : function()
8939 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
8946 // this get's auto added by panel.Grid
8947 if (this.scrollBody) {
8948 cfg.cls += ' table-body-fixed';
8951 cfg.cls += ' table-striped';
8955 cfg.cls += ' table-hover';
8957 if (this.bordered) {
8958 cfg.cls += ' table-bordered';
8960 if (this.condensed) {
8961 cfg.cls += ' table-condensed';
8964 if (this.responsive) {
8965 cfg.cls += ' table-responsive';
8969 cfg.cls+= ' ' +this.cls;
8975 cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
8978 if(this.store || this.cm){
8979 if(this.headerShow){
8980 cfg.cn.push(this.renderHeader());
8983 cfg.cn.push(this.renderBody());
8985 if(this.footerShow){
8986 cfg.cn.push(this.renderFooter());
8988 // where does this come from?
8989 //cfg.cls+= ' TableGrid';
8992 return { cn : [ cfg ] };
8995 initEvents : function()
8997 if(!this.store || !this.cm){
9000 if (this.selModel) {
9001 this.selModel.initEvents();
9005 //Roo.log('initEvents with ds!!!!');
9007 this.bodyEl = this.el.select('tbody', true).first();
9008 this.headEl = this.el.select('thead', true).first();
9009 this.mainFoot = this.el.select('tfoot', true).first();
9014 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
9015 e.on('click', this.sort, this);
9019 // why is this done????? = it breaks dialogs??
9020 //this.parent().el.setStyle('position', 'relative');
9024 this.footer.parentId = this.id;
9025 this.footer.onRender(this.el.select('tfoot tr td').first(), null);
9028 this.el.select('tfoot tr td').first().addClass('hide');
9033 this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
9036 this.store.on('load', this.onLoad, this);
9037 this.store.on('beforeload', this.onBeforeLoad, this);
9038 this.store.on('update', this.onUpdate, this);
9039 this.store.on('add', this.onAdd, this);
9040 this.store.on("clear", this.clear, this);
9042 this.el.on("contextmenu", this.onContextMenu, this);
9045 this.cm.on("headerchange", this.onHeaderChange, this);
9046 this.cm.on("hiddenchange", this.onHiddenChange, this, arguments);
9048 //?? does bodyEl get replaced on render?
9049 this.bodyEl.on("click", this.onClick, this);
9050 this.bodyEl.on("dblclick", this.onDblClick, this);
9051 this.bodyEl.on('scroll', this.onBodyScroll, this);
9053 // guessing mainbody will work - this relays usually caught by selmodel at present.
9054 this.relayEvents(this.bodyEl, ["mousedown","mouseup","mouseover","mouseout","keypress"]);
9057 this.resizeProxy = Roo.get(document.body).createChild({ cls:"x-grid-resize-proxy", html: ' ' });
9060 if(this.headEl && this.enableColumnResize !== false && Roo.grid.SplitDragZone){
9061 new Roo.grid.SplitDragZone(this, this.headEl.dom, false); // not sure what 'lockedHd is for this implementation..)
9066 // Compatibility with grid - we implement all the view features at present.
9067 getView : function()
9072 initCSS : function()
9076 var cm = this.cm, styles = [];
9077 this.CSS.removeStyleSheet(this.id + '-cssrules');
9078 var headHeight = this.headEl ? this.headEl.dom.clientHeight : 0;
9079 // we can honour xs/sm/md/xl as widths...
9080 // we first have to decide what widht we are currently at...
9081 var sz = Roo.getGridSize();
9085 var cols = []; // visable cols.
9087 for(var i = 0, len = cm.getColumnCount(); i < len; i++) {
9088 var w = cm.getColumnWidth(i, false);
9090 cols.push( { rel : false, abs : 0 });
9094 cols.push( { rel : false, abs : w });
9096 last = i; // not really..
9099 var w = cm.getColumnWidth(i, sz);
9104 cols.push( { rel : w, abs : false });
9107 var avail = this.bodyEl.dom.clientWidth - total_abs;
9109 var unitWidth = Math.floor(avail / total);
9110 var rem = avail - (unitWidth * total);
9112 var hidden, width, pos = 0 , splithide , left;
9113 for(var i = 0, len = cm.getColumnCount(); i < len; i++) {
9115 hidden = 'display:none;';
9117 width = 'width:0px;';
9119 if(!cm.isHidden(i)){
9123 // we can honour xs/sm/md/xl ?
9124 var w = cols[i].rel == false ? cols[i].abs : (cols[i].rel * unitWidth);
9126 hidden = 'display:none;';
9128 // width should return a small number...
9130 w+=rem; // add the remaining with..
9133 left = "left:" + (pos -4) + "px;";
9134 width = "width:" + w+ "px;";
9137 if (this.responsive) {
9140 hidden = cm.isHidden(i) ? 'display:none;' : '';
9141 splithide = 'display: none;';
9144 styles.push( '#' , this.id , ' .x-col-' , i, " {", cm.config[i].css, width, hidden, "}\n" );
9147 splithide = 'display:none;';
9150 styles.push('#' , this.id , ' .x-hcol-' , i, " { ", width, hidden," }\n",
9151 '#' , this.id , ' .x-grid-split-' , i, " { ", left, splithide,'height:', (headHeight - 4), "px;}\n"
9156 //Roo.log(styles.join(''));
9157 this.CSS.createStyleSheet( styles.join(''), this.id + '-cssrules');
9163 onContextMenu : function(e, t)
9165 this.processEvent("contextmenu", e);
9168 processEvent : function(name, e)
9170 if (name != 'touchstart' ) {
9171 this.fireEvent(name, e);
9174 var t = e.getTarget();
9176 var cell = Roo.get(t);
9182 if(cell.findParent('tfoot', false, true)){
9186 if(cell.findParent('thead', false, true)){
9188 if(e.getTarget().nodeName.toLowerCase() != 'th'){
9189 cell = Roo.get(t).findParent('th', false, true);
9191 Roo.log("failed to find th in thead?");
9192 Roo.log(e.getTarget());
9197 var cellIndex = cell.dom.cellIndex;
9199 var ename = name == 'touchstart' ? 'click' : name;
9200 this.fireEvent("header" + ename, this, cellIndex, e);
9205 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9206 cell = Roo.get(t).findParent('td', false, true);
9208 Roo.log("failed to find th in tbody?");
9209 Roo.log(e.getTarget());
9214 var row = cell.findParent('tr', false, true);
9215 var cellIndex = cell.dom.cellIndex;
9216 var rowIndex = row.dom.rowIndex - 1;
9220 this.fireEvent("row" + name, this, rowIndex, e);
9224 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
9230 onMouseover : function(e, el)
9232 var cell = Roo.get(el);
9238 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9239 cell = cell.findParent('td', false, true);
9242 var row = cell.findParent('tr', false, true);
9243 var cellIndex = cell.dom.cellIndex;
9244 var rowIndex = row.dom.rowIndex - 1; // start from 0
9246 this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
9250 onMouseout : function(e, el)
9252 var cell = Roo.get(el);
9258 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9259 cell = cell.findParent('td', false, true);
9262 var row = cell.findParent('tr', false, true);
9263 var cellIndex = cell.dom.cellIndex;
9264 var rowIndex = row.dom.rowIndex - 1; // start from 0
9266 this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
9270 onClick : function(e, el)
9272 var cell = Roo.get(el);
9274 if(!cell || (!this.cellSelection && !this.rowSelection)){
9278 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9279 cell = cell.findParent('td', false, true);
9282 if(!cell || typeof(cell) == 'undefined'){
9286 var row = cell.findParent('tr', false, true);
9288 if(!row || typeof(row) == 'undefined'){
9292 var cellIndex = cell.dom.cellIndex;
9293 var rowIndex = this.getRowIndex(row);
9295 // why??? - should these not be based on SelectionModel?
9296 //if(this.cellSelection){
9297 this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
9300 //if(this.rowSelection){
9301 this.fireEvent('rowclick', this, row, rowIndex, e);
9306 onDblClick : function(e,el)
9308 var cell = Roo.get(el);
9310 if(!cell || (!this.cellSelection && !this.rowSelection)){
9314 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9315 cell = cell.findParent('td', false, true);
9318 if(!cell || typeof(cell) == 'undefined'){
9322 var row = cell.findParent('tr', false, true);
9324 if(!row || typeof(row) == 'undefined'){
9328 var cellIndex = cell.dom.cellIndex;
9329 var rowIndex = this.getRowIndex(row);
9331 if(this.cellSelection){
9332 this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
9335 if(this.rowSelection){
9336 this.fireEvent('rowdblclick', this, row, rowIndex, e);
9339 findRowIndex : function(el)
9341 var cell = Roo.get(el);
9345 var row = cell.findParent('tr', false, true);
9347 if(!row || typeof(row) == 'undefined'){
9350 return this.getRowIndex(row);
9352 sort : function(e,el)
9354 var col = Roo.get(el);
9356 if(!col.hasClass('sortable')){
9360 var sort = col.attr('sort');
9363 if(col.select('i', true).first().hasClass('fa-arrow-up')){
9367 this.store.sortInfo = {field : sort, direction : dir};
9370 Roo.log("calling footer first");
9371 this.footer.onClick('first');
9374 this.store.load({ params : { start : 0 } });
9378 renderHeader : function()
9386 this.totalWidth = 0;
9388 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
9390 var config = cm.config[i];
9394 cls : 'x-hcol-' + i,
9397 html: cm.getColumnHeader(i)
9400 var tooltip = cm.getColumnTooltip(i);
9402 c.tooltip = tooltip;
9408 if(typeof(config.sortable) != 'undefined' && config.sortable){
9409 c.cls += ' sortable';
9410 c.html = '<i class="fa"></i>' + c.html;
9413 // could use BS4 hidden-..-down
9415 if(typeof(config.lgHeader) != 'undefined'){
9416 hh += '<span class="hidden-xs hidden-sm hidden-md ">' + config.lgHeader + '</span>';
9419 if(typeof(config.mdHeader) != 'undefined'){
9420 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
9423 if(typeof(config.smHeader) != 'undefined'){
9424 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
9427 if(typeof(config.xsHeader) != 'undefined'){
9428 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
9435 if(typeof(config.tooltip) != 'undefined'){
9436 c.tooltip = config.tooltip;
9439 if(typeof(config.colspan) != 'undefined'){
9440 c.colspan = config.colspan;
9443 // hidden is handled by CSS now
9445 if(typeof(config.dataIndex) != 'undefined'){
9446 c.sort = config.dataIndex;
9451 if(typeof(config.align) != 'undefined' && config.align.length){
9452 c.style += ' text-align:' + config.align + ';';
9455 /* width is done in CSS
9456 *if(typeof(config.width) != 'undefined'){
9457 c.style += ' width:' + config.width + 'px;';
9458 this.totalWidth += config.width;
9460 this.totalWidth += 100; // assume minimum of 100 per column?
9464 if(typeof(config.cls) != 'undefined'){
9465 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
9467 // this is the bit that doesnt reall work at all...
9469 if (this.responsive) {
9472 ['xs','sm','md','lg'].map(function(size){
9474 if(typeof(config[size]) == 'undefined'){
9478 if (!config[size]) { // 0 = hidden
9479 // BS 4 '0' is treated as hide that column and below.
9480 c.cls += ' hidden-' + size + ' hidden' + size + '-down';
9484 c.cls += ' col-' + size + '-' + config[size] + (
9485 size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
9493 c.html +=' <span class="x-grid-split x-grid-split-' + i + '"></span>';
9504 renderBody : function()
9514 colspan : this.cm.getColumnCount()
9524 renderFooter : function()
9534 colspan : this.cm.getColumnCount()
9548 // Roo.log('ds onload');
9553 var ds = this.store;
9555 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
9556 e.select('i', true).removeClass(['fa-arrow-up', 'fa-arrow-down']);
9557 if (_this.store.sortInfo) {
9559 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
9560 e.select('i', true).addClass(['fa-arrow-up']);
9563 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
9564 e.select('i', true).addClass(['fa-arrow-down']);
9569 var tbody = this.bodyEl;
9571 if(ds.getCount() > 0){
9572 ds.data.each(function(d,rowIndex){
9573 var row = this.renderRow(cm, ds, rowIndex);
9575 tbody.createChild(row);
9579 if(row.cellObjects.length){
9580 Roo.each(row.cellObjects, function(r){
9581 _this.renderCellObject(r);
9588 var tfoot = this.el.select('tfoot', true).first();
9590 if(this.footerShow && this.auto_hide_footer && this.mainFoot){
9592 this.mainFoot.setVisibilityMode(Roo.Element.DISPLAY).hide();
9594 var total = this.ds.getTotalCount();
9596 if(this.footer.pageSize < total){
9597 this.mainFoot.show();
9601 Roo.each(this.el.select('tbody td', true).elements, function(e){
9602 e.on('mouseover', _this.onMouseover, _this);
9605 Roo.each(this.el.select('tbody td', true).elements, function(e){
9606 e.on('mouseout', _this.onMouseout, _this);
9608 this.fireEvent('rowsrendered', this);
9612 this.initCSS(); /// resize cols
9618 onUpdate : function(ds,record)
9620 this.refreshRow(record);
9624 onRemove : function(ds, record, index, isUpdate){
9625 if(isUpdate !== true){
9626 this.fireEvent("beforerowremoved", this, index, record);
9628 var bt = this.bodyEl.dom;
9630 var rows = this.el.select('tbody > tr', true).elements;
9632 if(typeof(rows[index]) != 'undefined'){
9633 bt.removeChild(rows[index].dom);
9636 // if(bt.rows[index]){
9637 // bt.removeChild(bt.rows[index]);
9640 if(isUpdate !== true){
9641 //this.stripeRows(index);
9642 //this.syncRowHeights(index, index);
9644 this.fireEvent("rowremoved", this, index, record);
9648 onAdd : function(ds, records, rowIndex)
9650 //Roo.log('on Add called');
9651 // - note this does not handle multiple adding very well..
9652 var bt = this.bodyEl.dom;
9653 for (var i =0 ; i < records.length;i++) {
9654 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
9655 //Roo.log(records[i]);
9656 //Roo.log(this.store.getAt(rowIndex+i));
9657 this.insertRow(this.store, rowIndex + i, false);
9664 refreshRow : function(record){
9665 var ds = this.store, index;
9666 if(typeof record == 'number'){
9668 record = ds.getAt(index);
9670 index = ds.indexOf(record);
9672 return; // should not happen - but seems to
9675 this.insertRow(ds, index, true);
9677 this.onRemove(ds, record, index+1, true);
9679 //this.syncRowHeights(index, index);
9681 this.fireEvent("rowupdated", this, index, record);
9683 // private - called by RowSelection
9684 onRowSelect : function(rowIndex){
9685 var row = this.getRowDom(rowIndex);
9686 row.addClass(['bg-info','info']);
9688 // private - called by RowSelection
9689 onRowDeselect : function(rowIndex)
9694 var row = this.getRowDom(rowIndex);
9695 row.removeClass(['bg-info','info']);
9698 * Focuses the specified row.
9699 * @param {Number} row The row index
9701 focusRow : function(row)
9703 //Roo.log('GridView.focusRow');
9704 var x = this.bodyEl.dom.scrollLeft;
9705 this.focusCell(row, 0, false);
9706 this.bodyEl.dom.scrollLeft = x;
9710 * Focuses the specified cell.
9711 * @param {Number} row The row index
9712 * @param {Number} col The column index
9713 * @param {Boolean} hscroll false to disable horizontal scrolling
9715 focusCell : function(row, col, hscroll)
9717 //Roo.log('GridView.focusCell');
9718 var el = this.ensureVisible(row, col, hscroll);
9719 // not sure what focusEL achives = it's a <a> pos relative
9720 //this.focusEl.alignTo(el, "tl-tl");
9722 // this.focusEl.focus();
9724 // this.focusEl.focus.defer(1, this.focusEl);
9729 * Scrolls the specified cell into view
9730 * @param {Number} row The row index
9731 * @param {Number} col The column index
9732 * @param {Boolean} hscroll false to disable horizontal scrolling
9734 ensureVisible : function(row, col, hscroll)
9736 //Roo.log('GridView.ensureVisible,' + row + ',' + col);
9737 //return null; //disable for testing.
9738 if(typeof row != "number"){
9741 if(row < 0 && row >= this.ds.getCount()){
9744 col = (col !== undefined ? col : 0);
9746 while(cm.isHidden(col)){
9750 var el = this.getCellDom(row, col);
9754 var c = this.bodyEl.dom;
9756 var ctop = parseInt(el.offsetTop, 10);
9757 var cleft = parseInt(el.offsetLeft, 10);
9758 var cbot = ctop + el.offsetHeight;
9759 var cright = cleft + el.offsetWidth;
9761 //var ch = c.clientHeight - this.mainHd.dom.offsetHeight;
9762 var ch = 0; //?? header is not withing the area?
9763 var stop = parseInt(c.scrollTop, 10);
9764 var sleft = parseInt(c.scrollLeft, 10);
9765 var sbot = stop + ch;
9766 var sright = sleft + c.clientWidth;
9768 Roo.log('GridView.ensureVisible:' +
9770 ' c.clientHeight:' + c.clientHeight +
9771 ' this.mainHd.dom.offsetHeight:' + this.mainHd.dom.offsetHeight +
9780 //Roo.log("set scrolltop to ctop DISABLE?");
9781 }else if(cbot > sbot){
9782 //Roo.log("set scrolltop to cbot-ch");
9783 c.scrollTop = cbot-ch;
9786 if(hscroll !== false){
9788 c.scrollLeft = cleft;
9789 }else if(cright > sright){
9790 c.scrollLeft = cright-c.clientWidth;
9798 insertRow : function(dm, rowIndex, isUpdate){
9801 this.fireEvent("beforerowsinserted", this, rowIndex);
9803 //var s = this.getScrollState();
9804 var row = this.renderRow(this.cm, this.store, rowIndex);
9805 // insert before rowIndex..
9806 var e = this.bodyEl.createChild(row,this.getRowDom(rowIndex));
9810 if(row.cellObjects.length){
9811 Roo.each(row.cellObjects, function(r){
9812 _this.renderCellObject(r);
9817 this.fireEvent("rowsinserted", this, rowIndex);
9818 //this.syncRowHeights(firstRow, lastRow);
9819 //this.stripeRows(firstRow);
9826 getRowDom : function(rowIndex)
9828 var rows = this.el.select('tbody > tr', true).elements;
9830 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
9833 getCellDom : function(rowIndex, colIndex)
9835 var row = this.getRowDom(rowIndex);
9836 if (row === false) {
9839 var cols = row.select('td', true).elements;
9840 return (typeof(cols[colIndex]) == 'undefined') ? false : cols[colIndex];
9844 // returns the object tree for a tr..
9847 renderRow : function(cm, ds, rowIndex)
9849 var d = ds.getAt(rowIndex);
9853 cls : 'x-row-' + rowIndex,
9857 var cellObjects = [];
9859 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
9860 var config = cm.config[i];
9862 var renderer = cm.getRenderer(i);
9866 if(typeof(renderer) !== 'undefined'){
9867 value = renderer(d.data[cm.getDataIndex(i)], false, d);
9869 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
9870 // and are rendered into the cells after the row is rendered - using the id for the element.
9872 if(typeof(value) === 'object'){
9882 rowIndex : rowIndex,
9887 this.fireEvent('rowclass', this, rowcfg);
9891 // this might end up displaying HTML?
9892 // this is too messy... - better to only do it on columsn you know are going to be too long
9893 //tooltip : (typeof(value) === 'object') ? '' : value,
9894 cls : rowcfg.rowClass + ' x-col-' + i,
9896 html: (typeof(value) === 'object') ? '' : value
9903 if(typeof(config.colspan) != 'undefined'){
9904 td.colspan = config.colspan;
9909 if(typeof(config.align) != 'undefined' && config.align.length){
9910 td.style += ' text-align:' + config.align + ';';
9912 if(typeof(config.valign) != 'undefined' && config.valign.length){
9913 td.style += ' vertical-align:' + config.valign + ';';
9916 if(typeof(config.width) != 'undefined'){
9917 td.style += ' width:' + config.width + 'px;';
9921 if(typeof(config.cursor) != 'undefined'){
9922 td.style += ' cursor:' + config.cursor + ';';
9925 if(typeof(config.cls) != 'undefined'){
9926 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
9928 if (this.responsive) {
9929 ['xs','sm','md','lg'].map(function(size){
9931 if(typeof(config[size]) == 'undefined'){
9937 if (!config[size]) { // 0 = hidden
9938 // BS 4 '0' is treated as hide that column and below.
9939 td.cls += ' hidden-' + size + ' hidden' + size + '-down';
9943 td.cls += ' col-' + size + '-' + config[size] + (
9944 size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
9954 row.cellObjects = cellObjects;
9962 onBeforeLoad : function()
9971 this.el.select('tbody', true).first().dom.innerHTML = '';
9974 * Show or hide a row.
9975 * @param {Number} rowIndex to show or hide
9976 * @param {Boolean} state hide
9978 setRowVisibility : function(rowIndex, state)
9980 var bt = this.bodyEl.dom;
9982 var rows = this.el.select('tbody > tr', true).elements;
9984 if(typeof(rows[rowIndex]) == 'undefined'){
9987 rows[rowIndex][ state ? 'removeClass' : 'addClass']('d-none');
9992 getSelectionModel : function(){
9994 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
9996 return this.selModel;
9999 * Render the Roo.bootstrap object from renderder
10001 renderCellObject : function(r)
10005 r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
10007 var t = r.cfg.render(r.container);
10010 Roo.each(r.cfg.cn, function(c){
10012 container: t.getChildContainer(),
10015 _this.renderCellObject(child);
10020 * get the Row Index from a dom element.
10021 * @param {Roo.Element} row The row to look for
10022 * @returns {Number} the row
10024 getRowIndex : function(row)
10028 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
10039 * get the header TH element for columnIndex
10040 * @param {Number} columnIndex
10041 * @returns {Roo.Element}
10043 getHeaderIndex: function(colIndex)
10045 var cols = this.headEl.select('th', true).elements;
10046 return cols[colIndex];
10049 * get the Column Index from a dom element. (using regex on x-hcol-{colid})
10050 * @param {domElement} cell to look for
10051 * @returns {Number} the column
10053 getCellIndex : function(cell)
10055 var id = String(cell.className).match(Roo.bootstrap.Table.cellRE);
10057 return parseInt(id[1], 10);
10062 * Returns the grid's underlying element = used by panel.Grid
10063 * @return {Element} The element
10065 getGridEl : function(){
10069 * Forces a resize - used by panel.Grid
10070 * @return {Element} The element
10072 autoSize : function()
10074 //var ctr = Roo.get(this.container.dom.parentElement);
10075 var ctr = Roo.get(this.el.dom);
10077 var thd = this.getGridEl().select('thead',true).first();
10078 var tbd = this.getGridEl().select('tbody', true).first();
10079 var tfd = this.getGridEl().select('tfoot', true).first();
10081 var cw = ctr.getWidth();
10082 this.getGridEl().select('tfoot tr, tfoot td',true).setWidth(cw);
10086 tbd.setWidth(ctr.getWidth());
10087 // if the body has a max height - and then scrolls - we should perhaps set up the height here
10088 // this needs fixing for various usage - currently only hydra job advers I think..
10090 // ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
10092 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
10095 cw = Math.max(cw, this.totalWidth);
10096 this.getGridEl().select('tbody tr',true).setWidth(cw);
10099 // resize 'expandable coloumn?
10101 return; // we doe not have a view in this design..
10104 onBodyScroll: function()
10106 //Roo.log("body scrolled');" + this.bodyEl.dom.scrollLeft);
10108 this.headEl.setStyle({
10109 'position' : 'relative',
10110 'left': (-1* this.bodyEl.dom.scrollLeft) + 'px'
10116 var scrollHeight = this.bodyEl.dom.scrollHeight;
10118 var scrollTop = Math.ceil(this.bodyEl.getScroll().top);
10120 var height = this.bodyEl.getHeight();
10122 if(scrollHeight - height == scrollTop) {
10124 var total = this.ds.getTotalCount();
10126 if(this.footer.cursor + this.footer.pageSize < total){
10128 this.footer.ds.load({
10130 start : this.footer.cursor + this.footer.pageSize,
10131 limit : this.footer.pageSize
10140 onColumnSplitterMoved : function(i, diff)
10142 this.userResized = true;
10144 var cm = this.colModel;
10146 var w = this.getHeaderIndex(i).getWidth() + diff;
10149 cm.setColumnWidth(i, w, true);
10151 //var cid = cm.getColumnId(i); << not used in this version?
10152 /* Roo.log(['#' + this.id + ' .x-col-' + i, "width", w + "px"]);
10154 this.CSS.updateRule( '#' + this.id + ' .x-col-' + i, "width", w + "px");
10155 this.CSS.updateRule('#' + this.id + ' .x-hcol-' + i, "width", w + "px");
10156 this.CSS.updateRule('#' + this.id + ' .x-grid-split-' + i, "left", w + "px");
10158 //this.updateSplitters();
10159 //this.layout(); << ??
10160 this.fireEvent("columnresize", i, w);
10162 onHeaderChange : function()
10164 var header = this.renderHeader();
10165 var table = this.el.select('table', true).first();
10167 this.headEl.remove();
10168 this.headEl = table.createChild(header, this.bodyEl, false);
10170 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
10171 e.on('click', this.sort, this);
10174 if(this.enableColumnResize !== false && Roo.grid.SplitDragZone){
10175 new Roo.grid.SplitDragZone(this, this.headEl.dom, false); // not sure what 'lockedHd is for this implementation..)
10180 onHiddenChange : function(colModel, colIndex, hidden)
10183 this.cm.setHidden()
10184 var thSelector = '#' + this.id + ' .x-hcol-' + colIndex;
10185 var tdSelector = '#' + this.id + ' .x-col-' + colIndex;
10187 this.CSS.updateRule(thSelector, "display", "");
10188 this.CSS.updateRule(tdSelector, "display", "");
10191 this.CSS.updateRule(thSelector, "display", "none");
10192 this.CSS.updateRule(tdSelector, "display", "none");
10195 // onload calls initCSS()
10196 this.onHeaderChange();
10200 setColumnWidth: function(col_index, width)
10202 // width = "md-2 xs-2..."
10203 if(!this.colModel.config[col_index]) {
10207 var w = width.split(" ");
10209 var rows = this.el.dom.getElementsByClassName("x-col-"+col_index);
10211 var h_row = this.el.dom.getElementsByClassName("x-hcol-"+col_index);
10214 for(var j = 0; j < w.length; j++) {
10220 var size_cls = w[j].split("-");
10222 if(!Number.isInteger(size_cls[1] * 1)) {
10226 if(!this.colModel.config[col_index][size_cls[0]]) {
10230 if(!h_row[0].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
10234 h_row[0].classList.replace(
10235 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
10236 "col-"+size_cls[0]+"-"+size_cls[1]
10239 for(var i = 0; i < rows.length; i++) {
10241 var size_cls = w[j].split("-");
10243 if(!Number.isInteger(size_cls[1] * 1)) {
10247 if(!this.colModel.config[col_index][size_cls[0]]) {
10251 if(!rows[i].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
10255 rows[i].classList.replace(
10256 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
10257 "col-"+size_cls[0]+"-"+size_cls[1]
10261 this.colModel.config[col_index][size_cls[0]] = size_cls[1];
10266 // currently only used to find the split on drag..
10267 Roo.bootstrap.Table.cellRE = /(?:.*?)x-grid-(?:hd|cell|split)-([\d]+)(?:.*?)/;
10272 Roo.bootstrap.Table.AbstractSelectionModel = Roo.grid.AbstractSelectionModel;
10273 Roo.bootstrap.Table.RowSelectionModel = Roo.grid.RowSelectionModel;
10282 * @class Roo.bootstrap.TableCell
10283 * @extends Roo.bootstrap.Component
10284 * Bootstrap TableCell class
10285 * @cfg {String} html cell contain text
10286 * @cfg {String} cls cell class
10287 * @cfg {String} tag cell tag (td|th) default td
10288 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
10289 * @cfg {String} align Aligns the content in a cell
10290 * @cfg {String} axis Categorizes cells
10291 * @cfg {String} bgcolor Specifies the background color of a cell
10292 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
10293 * @cfg {Number} colspan Specifies the number of columns a cell should span
10294 * @cfg {String} headers Specifies one or more header cells a cell is related to
10295 * @cfg {Number} height Sets the height of a cell
10296 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
10297 * @cfg {Number} rowspan Sets the number of rows a cell should span
10298 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
10299 * @cfg {String} valign Vertical aligns the content in a cell
10300 * @cfg {Number} width Specifies the width of a cell
10303 * Create a new TableCell
10304 * @param {Object} config The config object
10307 Roo.bootstrap.TableCell = function(config){
10308 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
10311 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
10331 getAutoCreate : function(){
10332 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
10339 cfg.tag = this.tag;
10352 cfg.align=this.align
10357 if (this.bgcolor) {
10358 cfg.bgcolor=this.bgcolor
10360 if (this.charoff) {
10361 cfg.charoff=this.charoff
10363 if (this.colspan) {
10364 cfg.colspan=this.colspan
10366 if (this.headers) {
10367 cfg.headers=this.headers
10370 cfg.height=this.height
10373 cfg.nowrap=this.nowrap
10375 if (this.rowspan) {
10376 cfg.rowspan=this.rowspan
10379 cfg.scope=this.scope
10382 cfg.valign=this.valign
10385 cfg.width=this.width
10404 * @class Roo.bootstrap.TableRow
10405 * @extends Roo.bootstrap.Component
10406 * Bootstrap TableRow class
10407 * @cfg {String} cls row class
10408 * @cfg {String} align Aligns the content in a table row
10409 * @cfg {String} bgcolor Specifies a background color for a table row
10410 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
10411 * @cfg {String} valign Vertical aligns the content in a table row
10414 * Create a new TableRow
10415 * @param {Object} config The config object
10418 Roo.bootstrap.TableRow = function(config){
10419 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
10422 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
10430 getAutoCreate : function(){
10431 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
10438 cfg.cls = this.cls;
10441 cfg.align = this.align;
10444 cfg.bgcolor = this.bgcolor;
10447 cfg.charoff = this.charoff;
10450 cfg.valign = this.valign;
10468 * @class Roo.bootstrap.TableBody
10469 * @extends Roo.bootstrap.Component
10470 * Bootstrap TableBody class
10471 * @cfg {String} cls element class
10472 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
10473 * @cfg {String} align Aligns the content inside the element
10474 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
10475 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
10478 * Create a new TableBody
10479 * @param {Object} config The config object
10482 Roo.bootstrap.TableBody = function(config){
10483 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
10486 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
10494 getAutoCreate : function(){
10495 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
10505 cfg.tag = this.tag;
10509 cfg.align = this.align;
10512 cfg.charoff = this.charoff;
10515 cfg.valign = this.valign;
10522 // initEvents : function()
10525 // if(!this.store){
10529 // this.store = Roo.factory(this.store, Roo.data);
10530 // this.store.on('load', this.onLoad, this);
10532 // this.store.load();
10536 // onLoad: function ()
10538 // this.fireEvent('load', this);
10548 * Ext JS Library 1.1.1
10549 * Copyright(c) 2006-2007, Ext JS, LLC.
10551 * Originally Released Under LGPL - original licence link has changed is not relivant.
10554 * <script type="text/javascript">
10557 // as we use this in bootstrap.
10558 Roo.namespace('Roo.form');
10560 * @class Roo.form.Action
10561 * Internal Class used to handle form actions
10563 * @param {Roo.form.BasicForm} el The form element or its id
10564 * @param {Object} config Configuration options
10569 // define the action interface
10570 Roo.form.Action = function(form, options){
10572 this.options = options || {};
10575 * Client Validation Failed
10578 Roo.form.Action.CLIENT_INVALID = 'client';
10580 * Server Validation Failed
10583 Roo.form.Action.SERVER_INVALID = 'server';
10585 * Connect to Server Failed
10588 Roo.form.Action.CONNECT_FAILURE = 'connect';
10590 * Reading Data from Server Failed
10593 Roo.form.Action.LOAD_FAILURE = 'load';
10595 Roo.form.Action.prototype = {
10597 failureType : undefined,
10598 response : undefined,
10599 result : undefined,
10601 // interface method
10602 run : function(options){
10606 // interface method
10607 success : function(response){
10611 // interface method
10612 handleResponse : function(response){
10616 // default connection failure
10617 failure : function(response){
10619 this.response = response;
10620 this.failureType = Roo.form.Action.CONNECT_FAILURE;
10621 this.form.afterAction(this, false);
10624 processResponse : function(response){
10625 this.response = response;
10626 if(!response.responseText){
10629 this.result = this.handleResponse(response);
10630 return this.result;
10633 // utility functions used internally
10634 getUrl : function(appendParams){
10635 var url = this.options.url || this.form.url || this.form.el.dom.action;
10637 var p = this.getParams();
10639 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
10645 getMethod : function(){
10646 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
10649 getParams : function(){
10650 var bp = this.form.baseParams;
10651 var p = this.options.params;
10653 if(typeof p == "object"){
10654 p = Roo.urlEncode(Roo.applyIf(p, bp));
10655 }else if(typeof p == 'string' && bp){
10656 p += '&' + Roo.urlEncode(bp);
10659 p = Roo.urlEncode(bp);
10664 createCallback : function(){
10666 success: this.success,
10667 failure: this.failure,
10669 timeout: (this.form.timeout*1000),
10670 upload: this.form.fileUpload ? this.success : undefined
10675 Roo.form.Action.Submit = function(form, options){
10676 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
10679 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
10682 haveProgress : false,
10683 uploadComplete : false,
10685 // uploadProgress indicator.
10686 uploadProgress : function()
10688 if (!this.form.progressUrl) {
10692 if (!this.haveProgress) {
10693 Roo.MessageBox.progress("Uploading", "Uploading");
10695 if (this.uploadComplete) {
10696 Roo.MessageBox.hide();
10700 this.haveProgress = true;
10702 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
10704 var c = new Roo.data.Connection();
10706 url : this.form.progressUrl,
10711 success : function(req){
10712 //console.log(data);
10716 rdata = Roo.decode(req.responseText)
10718 Roo.log("Invalid data from server..");
10722 if (!rdata || !rdata.success) {
10724 Roo.MessageBox.alert(Roo.encode(rdata));
10727 var data = rdata.data;
10729 if (this.uploadComplete) {
10730 Roo.MessageBox.hide();
10735 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
10736 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
10739 this.uploadProgress.defer(2000,this);
10742 failure: function(data) {
10743 Roo.log('progress url failed ');
10754 // run get Values on the form, so it syncs any secondary forms.
10755 this.form.getValues();
10757 var o = this.options;
10758 var method = this.getMethod();
10759 var isPost = method == 'POST';
10760 if(o.clientValidation === false || this.form.isValid()){
10762 if (this.form.progressUrl) {
10763 this.form.findField('UPLOAD_IDENTIFIER').setValue(
10764 (new Date() * 1) + '' + Math.random());
10769 Roo.Ajax.request(Roo.apply(this.createCallback(), {
10770 form:this.form.el.dom,
10771 url:this.getUrl(!isPost),
10773 params:isPost ? this.getParams() : null,
10774 isUpload: this.form.fileUpload,
10775 formData : this.form.formData
10778 this.uploadProgress();
10780 }else if (o.clientValidation !== false){ // client validation failed
10781 this.failureType = Roo.form.Action.CLIENT_INVALID;
10782 this.form.afterAction(this, false);
10786 success : function(response)
10788 this.uploadComplete= true;
10789 if (this.haveProgress) {
10790 Roo.MessageBox.hide();
10794 var result = this.processResponse(response);
10795 if(result === true || result.success){
10796 this.form.afterAction(this, true);
10800 this.form.markInvalid(result.errors);
10801 this.failureType = Roo.form.Action.SERVER_INVALID;
10803 this.form.afterAction(this, false);
10805 failure : function(response)
10807 this.uploadComplete= true;
10808 if (this.haveProgress) {
10809 Roo.MessageBox.hide();
10812 this.response = response;
10813 this.failureType = Roo.form.Action.CONNECT_FAILURE;
10814 this.form.afterAction(this, false);
10817 handleResponse : function(response){
10818 if(this.form.errorReader){
10819 var rs = this.form.errorReader.read(response);
10822 for(var i = 0, len = rs.records.length; i < len; i++) {
10823 var r = rs.records[i];
10824 errors[i] = r.data;
10827 if(errors.length < 1){
10831 success : rs.success,
10837 ret = Roo.decode(response.responseText);
10841 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
10851 Roo.form.Action.Load = function(form, options){
10852 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
10853 this.reader = this.form.reader;
10856 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
10861 Roo.Ajax.request(Roo.apply(
10862 this.createCallback(), {
10863 method:this.getMethod(),
10864 url:this.getUrl(false),
10865 params:this.getParams()
10869 success : function(response){
10871 var result = this.processResponse(response);
10872 if(result === true || !result.success || !result.data){
10873 this.failureType = Roo.form.Action.LOAD_FAILURE;
10874 this.form.afterAction(this, false);
10877 this.form.clearInvalid();
10878 this.form.setValues(result.data);
10879 this.form.afterAction(this, true);
10882 handleResponse : function(response){
10883 if(this.form.reader){
10884 var rs = this.form.reader.read(response);
10885 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
10887 success : rs.success,
10891 return Roo.decode(response.responseText);
10895 Roo.form.Action.ACTION_TYPES = {
10896 'load' : Roo.form.Action.Load,
10897 'submit' : Roo.form.Action.Submit
10906 * @class Roo.bootstrap.Form
10907 * @extends Roo.bootstrap.Component
10908 * Bootstrap Form class
10909 * @cfg {String} method GET | POST (default POST)
10910 * @cfg {String} labelAlign top | left (default top)
10911 * @cfg {String} align left | right - for navbars
10912 * @cfg {Boolean} loadMask load mask when submit (default true)
10916 * Create a new Form
10917 * @param {Object} config The config object
10921 Roo.bootstrap.Form = function(config){
10923 Roo.bootstrap.Form.superclass.constructor.call(this, config);
10925 Roo.bootstrap.Form.popover.apply();
10929 * @event clientvalidation
10930 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
10931 * @param {Form} this
10932 * @param {Boolean} valid true if the form has passed client-side validation
10934 clientvalidation: true,
10936 * @event beforeaction
10937 * Fires before any action is performed. Return false to cancel the action.
10938 * @param {Form} this
10939 * @param {Action} action The action to be performed
10941 beforeaction: true,
10943 * @event actionfailed
10944 * Fires when an action fails.
10945 * @param {Form} this
10946 * @param {Action} action The action that failed
10948 actionfailed : true,
10950 * @event actioncomplete
10951 * Fires when an action is completed.
10952 * @param {Form} this
10953 * @param {Action} action The action that completed
10955 actioncomplete : true
10959 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
10962 * @cfg {String} method
10963 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
10967 * @cfg {String} url
10968 * The URL to use for form actions if one isn't supplied in the action options.
10971 * @cfg {Boolean} fileUpload
10972 * Set to true if this form is a file upload.
10976 * @cfg {Object} baseParams
10977 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
10981 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
10985 * @cfg {Sting} align (left|right) for navbar forms
10990 activeAction : null,
10993 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
10994 * element by passing it or its id or mask the form itself by passing in true.
10997 waitMsgTarget : false,
11002 * @cfg {Boolean} errorMask (true|false) default false
11007 * @cfg {Number} maskOffset Default 100
11012 * @cfg {Boolean} maskBody
11016 getAutoCreate : function(){
11020 method : this.method || 'POST',
11021 id : this.id || Roo.id(),
11024 if (this.parent().xtype.match(/^Nav/)) {
11025 cfg.cls = 'navbar-form form-inline navbar-' + this.align;
11029 if (this.labelAlign == 'left' ) {
11030 cfg.cls += ' form-horizontal';
11036 initEvents : function()
11038 this.el.on('submit', this.onSubmit, this);
11039 // this was added as random key presses on the form where triggering form submit.
11040 this.el.on('keypress', function(e) {
11041 if (e.getCharCode() != 13) {
11044 // we might need to allow it for textareas.. and some other items.
11045 // check e.getTarget().
11047 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
11051 Roo.log("keypress blocked");
11053 e.preventDefault();
11059 onSubmit : function(e){
11064 * Returns true if client-side validation on the form is successful.
11067 isValid : function(){
11068 var items = this.getItems();
11070 var target = false;
11072 items.each(function(f){
11078 Roo.log('invalid field: ' + f.name);
11082 if(!target && f.el.isVisible(true)){
11088 if(this.errorMask && !valid){
11089 Roo.bootstrap.Form.popover.mask(this, target);
11096 * Returns true if any fields in this form have changed since their original load.
11099 isDirty : function(){
11101 var items = this.getItems();
11102 items.each(function(f){
11112 * Performs a predefined action (submit or load) or custom actions you define on this form.
11113 * @param {String} actionName The name of the action type
11114 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
11115 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
11116 * accept other config options):
11118 Property Type Description
11119 ---------------- --------------- ----------------------------------------------------------------------------------
11120 url String The url for the action (defaults to the form's url)
11121 method String The form method to use (defaults to the form's method, or POST if not defined)
11122 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
11123 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
11124 validate the form on the client (defaults to false)
11126 * @return {BasicForm} this
11128 doAction : function(action, options){
11129 if(typeof action == 'string'){
11130 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
11132 if(this.fireEvent('beforeaction', this, action) !== false){
11133 this.beforeAction(action);
11134 action.run.defer(100, action);
11140 beforeAction : function(action){
11141 var o = action.options;
11146 Roo.get(document.body).mask(o.waitMsg || "Sending", 'x-mask-loading')
11148 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
11151 // not really supported yet.. ??
11153 //if(this.waitMsgTarget === true){
11154 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
11155 //}else if(this.waitMsgTarget){
11156 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
11157 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
11159 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
11165 afterAction : function(action, success){
11166 this.activeAction = null;
11167 var o = action.options;
11172 Roo.get(document.body).unmask();
11178 //if(this.waitMsgTarget === true){
11179 // this.el.unmask();
11180 //}else if(this.waitMsgTarget){
11181 // this.waitMsgTarget.unmask();
11183 // Roo.MessageBox.updateProgress(1);
11184 // Roo.MessageBox.hide();
11191 Roo.callback(o.success, o.scope, [this, action]);
11192 this.fireEvent('actioncomplete', this, action);
11196 // failure condition..
11197 // we have a scenario where updates need confirming.
11198 // eg. if a locking scenario exists..
11199 // we look for { errors : { needs_confirm : true }} in the response.
11201 (typeof(action.result) != 'undefined') &&
11202 (typeof(action.result.errors) != 'undefined') &&
11203 (typeof(action.result.errors.needs_confirm) != 'undefined')
11206 Roo.log("not supported yet");
11209 Roo.MessageBox.confirm(
11210 "Change requires confirmation",
11211 action.result.errorMsg,
11216 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
11226 Roo.callback(o.failure, o.scope, [this, action]);
11227 // show an error message if no failed handler is set..
11228 if (!this.hasListener('actionfailed')) {
11229 Roo.log("need to add dialog support");
11231 Roo.MessageBox.alert("Error",
11232 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
11233 action.result.errorMsg :
11234 "Saving Failed, please check your entries or try again"
11239 this.fireEvent('actionfailed', this, action);
11244 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
11245 * @param {String} id The value to search for
11248 findField : function(id){
11249 var items = this.getItems();
11250 var field = items.get(id);
11252 items.each(function(f){
11253 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
11260 return field || null;
11263 * Mark fields in this form invalid in bulk.
11264 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
11265 * @return {BasicForm} this
11267 markInvalid : function(errors){
11268 if(errors instanceof Array){
11269 for(var i = 0, len = errors.length; i < len; i++){
11270 var fieldError = errors[i];
11271 var f = this.findField(fieldError.id);
11273 f.markInvalid(fieldError.msg);
11279 if(typeof errors[id] != 'function' && (field = this.findField(id))){
11280 field.markInvalid(errors[id]);
11284 //Roo.each(this.childForms || [], function (f) {
11285 // f.markInvalid(errors);
11292 * Set values for fields in this form in bulk.
11293 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
11294 * @return {BasicForm} this
11296 setValues : function(values){
11297 if(values instanceof Array){ // array of objects
11298 for(var i = 0, len = values.length; i < len; i++){
11300 var f = this.findField(v.id);
11302 f.setValue(v.value);
11303 if(this.trackResetOnLoad){
11304 f.originalValue = f.getValue();
11308 }else{ // object hash
11311 if(typeof values[id] != 'function' && (field = this.findField(id))){
11313 if (field.setFromData &&
11314 field.valueField &&
11315 field.displayField &&
11316 // combos' with local stores can
11317 // be queried via setValue()
11318 // to set their value..
11319 (field.store && !field.store.isLocal)
11323 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
11324 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
11325 field.setFromData(sd);
11327 } else if(field.setFromData && (field.store && !field.store.isLocal)) {
11329 field.setFromData(values);
11332 field.setValue(values[id]);
11336 if(this.trackResetOnLoad){
11337 field.originalValue = field.getValue();
11343 //Roo.each(this.childForms || [], function (f) {
11344 // f.setValues(values);
11351 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
11352 * they are returned as an array.
11353 * @param {Boolean} asString
11356 getValues : function(asString){
11357 //if (this.childForms) {
11358 // copy values from the child forms
11359 // Roo.each(this.childForms, function (f) {
11360 // this.setValues(f.getValues());
11366 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
11367 if(asString === true){
11370 return Roo.urlDecode(fs);
11374 * Returns the fields in this form as an object with key/value pairs.
11375 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
11378 getFieldValues : function(with_hidden)
11380 var items = this.getItems();
11382 items.each(function(f){
11384 if (!f.getName()) {
11388 var v = f.getValue();
11390 if (f.inputType =='radio') {
11391 if (typeof(ret[f.getName()]) == 'undefined') {
11392 ret[f.getName()] = ''; // empty..
11395 if (!f.el.dom.checked) {
11399 v = f.el.dom.value;
11403 if(f.xtype == 'MoneyField'){
11404 ret[f.currencyName] = f.getCurrency();
11407 // not sure if this supported any more..
11408 if ((typeof(v) == 'object') && f.getRawValue) {
11409 v = f.getRawValue() ; // dates..
11411 // combo boxes where name != hiddenName...
11412 if (f.name !== false && f.name != '' && f.name != f.getName()) {
11413 ret[f.name] = f.getRawValue();
11415 ret[f.getName()] = v;
11422 * Clears all invalid messages in this form.
11423 * @return {BasicForm} this
11425 clearInvalid : function(){
11426 var items = this.getItems();
11428 items.each(function(f){
11436 * Resets this form.
11437 * @return {BasicForm} this
11439 reset : function(){
11440 var items = this.getItems();
11441 items.each(function(f){
11445 Roo.each(this.childForms || [], function (f) {
11453 getItems : function()
11455 var r=new Roo.util.MixedCollection(false, function(o){
11456 return o.id || (o.id = Roo.id());
11458 var iter = function(el) {
11465 Roo.each(el.items,function(e) {
11474 hideFields : function(items)
11476 Roo.each(items, function(i){
11478 var f = this.findField(i);
11489 showFields : function(items)
11491 Roo.each(items, function(i){
11493 var f = this.findField(i);
11506 Roo.apply(Roo.bootstrap.Form, {
11522 intervalID : false,
11528 if(this.isApplied){
11533 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
11534 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
11535 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
11536 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
11539 this.maskEl.top.enableDisplayMode("block");
11540 this.maskEl.left.enableDisplayMode("block");
11541 this.maskEl.bottom.enableDisplayMode("block");
11542 this.maskEl.right.enableDisplayMode("block");
11544 this.toolTip = new Roo.bootstrap.Tooltip({
11545 cls : 'roo-form-error-popover',
11547 'left' : ['r-l', [-2,0], 'right'],
11548 'right' : ['l-r', [2,0], 'left'],
11549 'bottom' : ['tl-bl', [0,2], 'top'],
11550 'top' : [ 'bl-tl', [0,-2], 'bottom']
11554 this.toolTip.render(Roo.get(document.body));
11556 this.toolTip.el.enableDisplayMode("block");
11558 Roo.get(document.body).on('click', function(){
11562 Roo.get(document.body).on('touchstart', function(){
11566 this.isApplied = true
11569 mask : function(form, target)
11573 this.target = target;
11575 if(!this.form.errorMask || !target.el){
11579 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
11581 Roo.log(scrollable);
11583 var ot = this.target.el.calcOffsetsTo(scrollable);
11585 var scrollTo = ot[1] - this.form.maskOffset;
11587 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
11589 scrollable.scrollTo('top', scrollTo);
11591 var box = this.target.el.getBox();
11593 var zIndex = Roo.bootstrap.Modal.zIndex++;
11596 this.maskEl.top.setStyle('position', 'absolute');
11597 this.maskEl.top.setStyle('z-index', zIndex);
11598 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
11599 this.maskEl.top.setLeft(0);
11600 this.maskEl.top.setTop(0);
11601 this.maskEl.top.show();
11603 this.maskEl.left.setStyle('position', 'absolute');
11604 this.maskEl.left.setStyle('z-index', zIndex);
11605 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
11606 this.maskEl.left.setLeft(0);
11607 this.maskEl.left.setTop(box.y - this.padding);
11608 this.maskEl.left.show();
11610 this.maskEl.bottom.setStyle('position', 'absolute');
11611 this.maskEl.bottom.setStyle('z-index', zIndex);
11612 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
11613 this.maskEl.bottom.setLeft(0);
11614 this.maskEl.bottom.setTop(box.bottom + this.padding);
11615 this.maskEl.bottom.show();
11617 this.maskEl.right.setStyle('position', 'absolute');
11618 this.maskEl.right.setStyle('z-index', zIndex);
11619 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
11620 this.maskEl.right.setLeft(box.right + this.padding);
11621 this.maskEl.right.setTop(box.y - this.padding);
11622 this.maskEl.right.show();
11624 this.toolTip.bindEl = this.target.el;
11626 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
11628 var tip = this.target.blankText;
11630 if(this.target.getValue() !== '' ) {
11632 if (this.target.invalidText.length) {
11633 tip = this.target.invalidText;
11634 } else if (this.target.regexText.length){
11635 tip = this.target.regexText;
11639 this.toolTip.show(tip);
11641 this.intervalID = window.setInterval(function() {
11642 Roo.bootstrap.Form.popover.unmask();
11645 window.onwheel = function(){ return false;};
11647 (function(){ this.isMasked = true; }).defer(500, this);
11651 unmask : function()
11653 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
11657 this.maskEl.top.setStyle('position', 'absolute');
11658 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
11659 this.maskEl.top.hide();
11661 this.maskEl.left.setStyle('position', 'absolute');
11662 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
11663 this.maskEl.left.hide();
11665 this.maskEl.bottom.setStyle('position', 'absolute');
11666 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
11667 this.maskEl.bottom.hide();
11669 this.maskEl.right.setStyle('position', 'absolute');
11670 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
11671 this.maskEl.right.hide();
11673 this.toolTip.hide();
11675 this.toolTip.el.hide();
11677 window.onwheel = function(){ return true;};
11679 if(this.intervalID){
11680 window.clearInterval(this.intervalID);
11681 this.intervalID = false;
11684 this.isMasked = false;
11694 * Ext JS Library 1.1.1
11695 * Copyright(c) 2006-2007, Ext JS, LLC.
11697 * Originally Released Under LGPL - original licence link has changed is not relivant.
11700 * <script type="text/javascript">
11703 * @class Roo.form.VTypes
11704 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
11707 Roo.form.VTypes = function(){
11708 // closure these in so they are only created once.
11709 var alpha = /^[a-zA-Z_]+$/;
11710 var alphanum = /^[a-zA-Z0-9_]+$/;
11711 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
11712 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
11714 // All these messages and functions are configurable
11717 * The function used to validate email addresses
11718 * @param {String} value The email address
11720 'email' : function(v){
11721 return email.test(v);
11724 * The error text to display when the email validation function returns false
11727 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
11729 * The keystroke filter mask to be applied on email input
11732 'emailMask' : /[a-z0-9_\.\-@]/i,
11735 * The function used to validate URLs
11736 * @param {String} value The URL
11738 'url' : function(v){
11739 return url.test(v);
11742 * The error text to display when the url validation function returns false
11745 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
11748 * The function used to validate alpha values
11749 * @param {String} value The value
11751 'alpha' : function(v){
11752 return alpha.test(v);
11755 * The error text to display when the alpha validation function returns false
11758 'alphaText' : 'This field should only contain letters and _',
11760 * The keystroke filter mask to be applied on alpha input
11763 'alphaMask' : /[a-z_]/i,
11766 * The function used to validate alphanumeric values
11767 * @param {String} value The value
11769 'alphanum' : function(v){
11770 return alphanum.test(v);
11773 * The error text to display when the alphanumeric validation function returns false
11776 'alphanumText' : 'This field should only contain letters, numbers and _',
11778 * The keystroke filter mask to be applied on alphanumeric input
11781 'alphanumMask' : /[a-z0-9_]/i
11791 * @class Roo.bootstrap.Input
11792 * @extends Roo.bootstrap.Component
11793 * Bootstrap Input class
11794 * @cfg {Boolean} disabled is it disabled
11795 * @cfg {String} (button|checkbox|email|file|hidden|image|number|password|radio|range|reset|search|submit|text) inputType
11796 * @cfg {String} name name of the input
11797 * @cfg {string} fieldLabel - the label associated
11798 * @cfg {string} placeholder - placeholder to put in text.
11799 * @cfg {string} before - input group add on before
11800 * @cfg {string} after - input group add on after
11801 * @cfg {string} size - (lg|sm) or leave empty..
11802 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
11803 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
11804 * @cfg {Number} md colspan out of 12 for computer-sized screens
11805 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
11806 * @cfg {string} value default value of the input
11807 * @cfg {Number} labelWidth set the width of label
11808 * @cfg {Number} labellg set the width of label (1-12)
11809 * @cfg {Number} labelmd set the width of label (1-12)
11810 * @cfg {Number} labelsm set the width of label (1-12)
11811 * @cfg {Number} labelxs set the width of label (1-12)
11812 * @cfg {String} labelAlign (top|left)
11813 * @cfg {Boolean} readOnly Specifies that the field should be read-only
11814 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
11815 * @cfg {String} indicatorpos (left|right) default left
11816 * @cfg {String} capture (user|camera) use for file input only. (default empty)
11817 * @cfg {String} accept (image|video|audio) use for file input only. (default empty)
11818 * @cfg {Boolean} preventMark Do not show tick or cross if error/success
11820 * @cfg {String} align (left|center|right) Default left
11821 * @cfg {Boolean} forceFeedback (true|false) Default false
11824 * Create a new Input
11825 * @param {Object} config The config object
11828 Roo.bootstrap.Input = function(config){
11830 Roo.bootstrap.Input.superclass.constructor.call(this, config);
11835 * Fires when this field receives input focus.
11836 * @param {Roo.form.Field} this
11841 * Fires when this field loses input focus.
11842 * @param {Roo.form.Field} this
11846 * @event specialkey
11847 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
11848 * {@link Roo.EventObject#getKey} to determine which key was pressed.
11849 * @param {Roo.form.Field} this
11850 * @param {Roo.EventObject} e The event object
11855 * Fires just before the field blurs if the field value has changed.
11856 * @param {Roo.form.Field} this
11857 * @param {Mixed} newValue The new value
11858 * @param {Mixed} oldValue The original value
11863 * Fires after the field has been marked as invalid.
11864 * @param {Roo.form.Field} this
11865 * @param {String} msg The validation message
11870 * Fires after the field has been validated with no errors.
11871 * @param {Roo.form.Field} this
11876 * Fires after the key up
11877 * @param {Roo.form.Field} this
11878 * @param {Roo.EventObject} e The event Object
11883 * Fires after the user pastes into input
11884 * @param {Roo.form.Field} this
11885 * @param {Roo.EventObject} e The event Object
11891 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
11893 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
11894 automatic validation (defaults to "keyup").
11896 validationEvent : "keyup",
11898 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
11900 validateOnBlur : true,
11902 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
11904 validationDelay : 250,
11906 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
11908 focusClass : "x-form-focus", // not needed???
11912 * @cfg {String} invalidClass DEPRICATED - code uses BS4 - is-valid / is-invalid
11914 invalidClass : "has-warning",
11917 * @cfg {String} validClass DEPRICATED - code uses BS4 - is-valid / is-invalid
11919 validClass : "has-success",
11922 * @cfg {Boolean} hasFeedback (true|false) default true
11924 hasFeedback : true,
11927 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
11929 invalidFeedbackClass : "glyphicon-warning-sign",
11932 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
11934 validFeedbackClass : "glyphicon-ok",
11937 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
11939 selectOnFocus : false,
11942 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
11946 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
11951 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
11953 disableKeyFilter : false,
11956 * @cfg {Boolean} disabled True to disable the field (defaults to false).
11960 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
11964 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
11966 blankText : "Please complete this mandatory field",
11969 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
11973 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
11975 maxLength : Number.MAX_VALUE,
11977 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
11979 minLengthText : "The minimum length for this field is {0}",
11981 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
11983 maxLengthText : "The maximum length for this field is {0}",
11987 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
11988 * If available, this function will be called only after the basic validators all return true, and will be passed the
11989 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
11993 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
11994 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
11995 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
11999 * @cfg {String} regexText -- Depricated - use Invalid Text
12004 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
12010 autocomplete: false,
12014 inputType : 'text',
12017 placeholder: false,
12022 preventMark: false,
12023 isFormField : true,
12026 labelAlign : false,
12029 formatedValue : false,
12030 forceFeedback : false,
12032 indicatorpos : 'left',
12042 parentLabelAlign : function()
12045 while (parent.parent()) {
12046 parent = parent.parent();
12047 if (typeof(parent.labelAlign) !='undefined') {
12048 return parent.labelAlign;
12055 getAutoCreate : function()
12057 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
12063 if(this.inputType != 'hidden'){
12064 cfg.cls = 'form-group' //input-group
12070 type : this.inputType,
12071 value : this.value,
12072 cls : 'form-control',
12073 placeholder : this.placeholder || '',
12074 autocomplete : this.autocomplete || 'new-password'
12076 if (this.inputType == 'file') {
12077 input.style = 'overflow:hidden'; // why not in CSS?
12080 if(this.capture.length){
12081 input.capture = this.capture;
12084 if(this.accept.length){
12085 input.accept = this.accept + "/*";
12089 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
12092 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
12093 input.maxLength = this.maxLength;
12096 if (this.disabled) {
12097 input.disabled=true;
12100 if (this.readOnly) {
12101 input.readonly=true;
12105 input.name = this.name;
12109 input.cls += ' input-' + this.size;
12113 ['xs','sm','md','lg'].map(function(size){
12114 if (settings[size]) {
12115 cfg.cls += ' col-' + size + '-' + settings[size];
12119 var inputblock = input;
12123 cls: 'glyphicon form-control-feedback'
12126 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
12129 cls : 'has-feedback',
12137 if (this.before || this.after) {
12140 cls : 'input-group',
12144 if (this.before && typeof(this.before) == 'string') {
12146 inputblock.cn.push({
12148 cls : 'roo-input-before input-group-addon input-group-prepend input-group-text',
12152 if (this.before && typeof(this.before) == 'object') {
12153 this.before = Roo.factory(this.before);
12155 inputblock.cn.push({
12157 cls : 'roo-input-before input-group-prepend input-group-' +
12158 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
12162 inputblock.cn.push(input);
12164 if (this.after && typeof(this.after) == 'string') {
12165 inputblock.cn.push({
12167 cls : 'roo-input-after input-group-append input-group-text input-group-addon',
12171 if (this.after && typeof(this.after) == 'object') {
12172 this.after = Roo.factory(this.after);
12174 inputblock.cn.push({
12176 cls : 'roo-input-after input-group-append input-group-' +
12177 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
12181 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
12182 inputblock.cls += ' has-feedback';
12183 inputblock.cn.push(feedback);
12188 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
12189 tooltip : 'This field is required'
12191 if (this.allowBlank ) {
12192 indicator.style = this.allowBlank ? ' display:none' : '';
12194 if (align ==='left' && this.fieldLabel.length) {
12196 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
12203 cls : 'control-label col-form-label',
12204 html : this.fieldLabel
12215 var labelCfg = cfg.cn[1];
12216 var contentCfg = cfg.cn[2];
12218 if(this.indicatorpos == 'right'){
12223 cls : 'control-label col-form-label',
12227 html : this.fieldLabel
12241 labelCfg = cfg.cn[0];
12242 contentCfg = cfg.cn[1];
12246 if(this.labelWidth > 12){
12247 labelCfg.style = "width: " + this.labelWidth + 'px';
12250 if(this.labelWidth < 13 && this.labelmd == 0){
12251 this.labellg = this.labellg > 0 ? this.labellg : this.labelWidth;
12254 if(this.labellg > 0){
12255 labelCfg.cls += ' col-lg-' + this.labellg;
12256 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
12259 if(this.labelmd > 0){
12260 labelCfg.cls += ' col-md-' + this.labelmd;
12261 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
12264 if(this.labelsm > 0){
12265 labelCfg.cls += ' col-sm-' + this.labelsm;
12266 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
12269 if(this.labelxs > 0){
12270 labelCfg.cls += ' col-xs-' + this.labelxs;
12271 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
12275 } else if ( this.fieldLabel.length) {
12282 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
12283 tooltip : 'This field is required',
12284 style : this.allowBlank ? ' display:none' : ''
12288 //cls : 'input-group-addon',
12289 html : this.fieldLabel
12297 if(this.indicatorpos == 'right'){
12302 //cls : 'input-group-addon',
12303 html : this.fieldLabel
12308 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
12309 tooltip : 'This field is required',
12310 style : this.allowBlank ? ' display:none' : ''
12330 if (this.parentType === 'Navbar' && this.parent().bar) {
12331 cfg.cls += ' navbar-form';
12334 if (this.parentType === 'NavGroup' && !(Roo.bootstrap.version == 4 && this.parent().form)) {
12335 // on BS4 we do this only if not form
12336 cfg.cls += ' navbar-form';
12344 * return the real input element.
12346 inputEl: function ()
12348 return this.el.select('input.form-control',true).first();
12351 tooltipEl : function()
12353 return this.inputEl();
12356 indicatorEl : function()
12358 if (Roo.bootstrap.version == 4) {
12359 return false; // not enabled in v4 yet.
12362 var indicator = this.el.select('i.roo-required-indicator',true).first();
12372 setDisabled : function(v)
12374 var i = this.inputEl().dom;
12376 i.removeAttribute('disabled');
12380 i.setAttribute('disabled','true');
12382 initEvents : function()
12385 this.inputEl().on("keydown" , this.fireKey, this);
12386 this.inputEl().on("focus", this.onFocus, this);
12387 this.inputEl().on("blur", this.onBlur, this);
12389 this.inputEl().relayEvent('keyup', this);
12390 this.inputEl().relayEvent('paste', this);
12392 this.indicator = this.indicatorEl();
12394 if(this.indicator){
12395 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible'); // changed from invisible??? -
12398 // reference to original value for reset
12399 this.originalValue = this.getValue();
12400 //Roo.form.TextField.superclass.initEvents.call(this);
12401 if(this.validationEvent == 'keyup'){
12402 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
12403 this.inputEl().on('keyup', this.filterValidation, this);
12405 else if(this.validationEvent !== false){
12406 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
12409 if(this.selectOnFocus){
12410 this.on("focus", this.preFocus, this);
12413 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
12414 this.inputEl().on("keypress", this.filterKeys, this);
12416 this.inputEl().relayEvent('keypress', this);
12419 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
12420 this.el.on("click", this.autoSize, this);
12423 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
12424 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
12427 if (typeof(this.before) == 'object') {
12428 this.before.render(this.el.select('.roo-input-before',true).first());
12430 if (typeof(this.after) == 'object') {
12431 this.after.render(this.el.select('.roo-input-after',true).first());
12434 this.inputEl().on('change', this.onChange, this);
12437 filterValidation : function(e){
12438 if(!e.isNavKeyPress()){
12439 this.validationTask.delay(this.validationDelay);
12443 * Validates the field value
12444 * @return {Boolean} True if the value is valid, else false
12446 validate : function(){
12447 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
12448 if(this.disabled || this.validateValue(this.getRawValue())){
12453 this.markInvalid();
12459 * Validates a value according to the field's validation rules and marks the field as invalid
12460 * if the validation fails
12461 * @param {Mixed} value The value to validate
12462 * @return {Boolean} True if the value is valid, else false
12464 validateValue : function(value)
12466 if(this.getVisibilityEl().hasClass('hidden')){
12470 if(value.length < 1) { // if it's blank
12471 if(this.allowBlank){
12477 if(value.length < this.minLength){
12480 if(value.length > this.maxLength){
12484 var vt = Roo.form.VTypes;
12485 if(!vt[this.vtype](value, this)){
12489 if(typeof this.validator == "function"){
12490 var msg = this.validator(value);
12494 if (typeof(msg) == 'string') {
12495 this.invalidText = msg;
12499 if(this.regex && !this.regex.test(value)){
12507 fireKey : function(e){
12508 //Roo.log('field ' + e.getKey());
12509 if(e.isNavKeyPress()){
12510 this.fireEvent("specialkey", this, e);
12513 focus : function (selectText){
12515 this.inputEl().focus();
12516 if(selectText === true){
12517 this.inputEl().dom.select();
12523 onFocus : function(){
12524 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
12525 // this.el.addClass(this.focusClass);
12527 if(!this.hasFocus){
12528 this.hasFocus = true;
12529 this.startValue = this.getValue();
12530 this.fireEvent("focus", this);
12534 beforeBlur : Roo.emptyFn,
12538 onBlur : function(){
12540 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
12541 //this.el.removeClass(this.focusClass);
12543 this.hasFocus = false;
12544 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
12547 var v = this.getValue();
12548 if(String(v) !== String(this.startValue)){
12549 this.fireEvent('change', this, v, this.startValue);
12551 this.fireEvent("blur", this);
12554 onChange : function(e)
12556 var v = this.getValue();
12557 if(String(v) !== String(this.startValue)){
12558 this.fireEvent('change', this, v, this.startValue);
12564 * Resets the current field value to the originally loaded value and clears any validation messages
12566 reset : function(){
12567 this.setValue(this.originalValue);
12571 * Returns the name of the field
12572 * @return {Mixed} name The name field
12574 getName: function(){
12578 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
12579 * @return {Mixed} value The field value
12581 getValue : function(){
12583 var v = this.inputEl().getValue();
12588 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
12589 * @return {Mixed} value The field value
12591 getRawValue : function(){
12592 var v = this.inputEl().getValue();
12598 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
12599 * @param {Mixed} value The value to set
12601 setRawValue : function(v){
12602 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
12605 selectText : function(start, end){
12606 var v = this.getRawValue();
12608 start = start === undefined ? 0 : start;
12609 end = end === undefined ? v.length : end;
12610 var d = this.inputEl().dom;
12611 if(d.setSelectionRange){
12612 d.setSelectionRange(start, end);
12613 }else if(d.createTextRange){
12614 var range = d.createTextRange();
12615 range.moveStart("character", start);
12616 range.moveEnd("character", v.length-end);
12623 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
12624 * @param {Mixed} value The value to set
12626 setValue : function(v){
12629 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
12635 processValue : function(value){
12636 if(this.stripCharsRe){
12637 var newValue = value.replace(this.stripCharsRe, '');
12638 if(newValue !== value){
12639 this.setRawValue(newValue);
12646 preFocus : function(){
12648 if(this.selectOnFocus){
12649 this.inputEl().dom.select();
12652 filterKeys : function(e){
12653 var k = e.getKey();
12654 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
12657 var c = e.getCharCode(), cc = String.fromCharCode(c);
12658 if(Roo.isIE && (e.isSpecialKey() || !cc)){
12661 if(!this.maskRe.test(cc)){
12666 * Clear any invalid styles/messages for this field
12668 clearInvalid : function(){
12670 if(!this.el || this.preventMark){ // not rendered
12675 this.el.removeClass([this.invalidClass, 'is-invalid']);
12677 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
12679 var feedback = this.el.select('.form-control-feedback', true).first();
12682 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
12687 if(this.indicator){
12688 this.indicator.removeClass('visible');
12689 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
12692 this.fireEvent('valid', this);
12696 * Mark this field as valid
12698 markValid : function()
12700 if(!this.el || this.preventMark){ // not rendered...
12704 this.el.removeClass([this.invalidClass, this.validClass]);
12705 this.inputEl().removeClass(['is-valid', 'is-invalid']);
12707 var feedback = this.el.select('.form-control-feedback', true).first();
12710 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
12713 if(this.indicator){
12714 this.indicator.removeClass('visible');
12715 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
12723 if(this.allowBlank && !this.getRawValue().length){
12726 if (Roo.bootstrap.version == 3) {
12727 this.el.addClass(this.validClass);
12729 this.inputEl().addClass('is-valid');
12732 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
12734 var feedback = this.el.select('.form-control-feedback', true).first();
12737 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
12738 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
12743 this.fireEvent('valid', this);
12747 * Mark this field as invalid
12748 * @param {String} msg The validation message
12750 markInvalid : function(msg)
12752 if(!this.el || this.preventMark){ // not rendered
12756 this.el.removeClass([this.invalidClass, this.validClass]);
12757 this.inputEl().removeClass(['is-valid', 'is-invalid']);
12759 var feedback = this.el.select('.form-control-feedback', true).first();
12762 this.el.select('.form-control-feedback', true).first().removeClass(
12763 [this.invalidFeedbackClass, this.validFeedbackClass]);
12770 if(this.allowBlank && !this.getRawValue().length){
12774 if(this.indicator){
12775 this.indicator.removeClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
12776 this.indicator.addClass('visible');
12778 if (Roo.bootstrap.version == 3) {
12779 this.el.addClass(this.invalidClass);
12781 this.inputEl().addClass('is-invalid');
12786 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
12788 var feedback = this.el.select('.form-control-feedback', true).first();
12791 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
12793 if(this.getValue().length || this.forceFeedback){
12794 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
12801 this.fireEvent('invalid', this, msg);
12804 SafariOnKeyDown : function(event)
12806 // this is a workaround for a password hang bug on chrome/ webkit.
12807 if (this.inputEl().dom.type != 'password') {
12811 var isSelectAll = false;
12813 if(this.inputEl().dom.selectionEnd > 0){
12814 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
12816 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
12817 event.preventDefault();
12822 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
12824 event.preventDefault();
12825 // this is very hacky as keydown always get's upper case.
12827 var cc = String.fromCharCode(event.getCharCode());
12828 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
12832 adjustWidth : function(tag, w){
12833 tag = tag.toLowerCase();
12834 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
12835 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
12836 if(tag == 'input'){
12839 if(tag == 'textarea'){
12842 }else if(Roo.isOpera){
12843 if(tag == 'input'){
12846 if(tag == 'textarea'){
12854 setFieldLabel : function(v)
12856 if(!this.rendered){
12860 if(this.indicatorEl()){
12861 var ar = this.el.select('label > span',true);
12863 if (ar.elements.length) {
12864 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
12865 this.fieldLabel = v;
12869 var br = this.el.select('label',true);
12871 if(br.elements.length) {
12872 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
12873 this.fieldLabel = v;
12877 Roo.log('Cannot Found any of label > span || label in input');
12881 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
12882 this.fieldLabel = v;
12897 * @class Roo.bootstrap.TextArea
12898 * @extends Roo.bootstrap.Input
12899 * Bootstrap TextArea class
12900 * @cfg {Number} cols Specifies the visible width of a text area
12901 * @cfg {Number} rows Specifies the visible number of lines in a text area
12902 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
12903 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
12904 * @cfg {string} html text
12907 * Create a new TextArea
12908 * @param {Object} config The config object
12911 Roo.bootstrap.TextArea = function(config){
12912 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
12916 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
12926 getAutoCreate : function(){
12928 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
12934 if(this.inputType != 'hidden'){
12935 cfg.cls = 'form-group' //input-group
12943 value : this.value || '',
12944 html: this.html || '',
12945 cls : 'form-control',
12946 placeholder : this.placeholder || ''
12950 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
12951 input.maxLength = this.maxLength;
12955 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
12959 input.cols = this.cols;
12962 if (this.readOnly) {
12963 input.readonly = true;
12967 input.name = this.name;
12971 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
12975 ['xs','sm','md','lg'].map(function(size){
12976 if (settings[size]) {
12977 cfg.cls += ' col-' + size + '-' + settings[size];
12981 var inputblock = input;
12983 if(this.hasFeedback && !this.allowBlank){
12987 cls: 'glyphicon form-control-feedback'
12991 cls : 'has-feedback',
13000 if (this.before || this.after) {
13003 cls : 'input-group',
13007 inputblock.cn.push({
13009 cls : 'input-group-addon',
13014 inputblock.cn.push(input);
13016 if(this.hasFeedback && !this.allowBlank){
13017 inputblock.cls += ' has-feedback';
13018 inputblock.cn.push(feedback);
13022 inputblock.cn.push({
13024 cls : 'input-group-addon',
13031 if (align ==='left' && this.fieldLabel.length) {
13036 cls : 'control-label',
13037 html : this.fieldLabel
13048 if(this.labelWidth > 12){
13049 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
13052 if(this.labelWidth < 13 && this.labelmd == 0){
13053 this.labelmd = this.labelWidth;
13056 if(this.labellg > 0){
13057 cfg.cn[0].cls += ' col-lg-' + this.labellg;
13058 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
13061 if(this.labelmd > 0){
13062 cfg.cn[0].cls += ' col-md-' + this.labelmd;
13063 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
13066 if(this.labelsm > 0){
13067 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
13068 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
13071 if(this.labelxs > 0){
13072 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
13073 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
13076 } else if ( this.fieldLabel.length) {
13081 //cls : 'input-group-addon',
13082 html : this.fieldLabel
13100 if (this.disabled) {
13101 input.disabled=true;
13108 * return the real textarea element.
13110 inputEl: function ()
13112 return this.el.select('textarea.form-control',true).first();
13116 * Clear any invalid styles/messages for this field
13118 clearInvalid : function()
13121 if(!this.el || this.preventMark){ // not rendered
13125 var label = this.el.select('label', true).first();
13126 var icon = this.el.select('i.fa-star', true).first();
13131 this.el.removeClass( this.validClass);
13132 this.inputEl().removeClass('is-invalid');
13134 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
13136 var feedback = this.el.select('.form-control-feedback', true).first();
13139 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
13144 this.fireEvent('valid', this);
13148 * Mark this field as valid
13150 markValid : function()
13152 if(!this.el || this.preventMark){ // not rendered
13156 this.el.removeClass([this.invalidClass, this.validClass]);
13157 this.inputEl().removeClass(['is-valid', 'is-invalid']);
13159 var feedback = this.el.select('.form-control-feedback', true).first();
13162 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13165 if(this.disabled || this.allowBlank){
13169 var label = this.el.select('label', true).first();
13170 var icon = this.el.select('i.fa-star', true).first();
13175 if (Roo.bootstrap.version == 3) {
13176 this.el.addClass(this.validClass);
13178 this.inputEl().addClass('is-valid');
13182 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
13184 var feedback = this.el.select('.form-control-feedback', true).first();
13187 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13188 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
13193 this.fireEvent('valid', this);
13197 * Mark this field as invalid
13198 * @param {String} msg The validation message
13200 markInvalid : function(msg)
13202 if(!this.el || this.preventMark){ // not rendered
13206 this.el.removeClass([this.invalidClass, this.validClass]);
13207 this.inputEl().removeClass(['is-valid', 'is-invalid']);
13209 var feedback = this.el.select('.form-control-feedback', true).first();
13212 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13215 if(this.disabled || this.allowBlank){
13219 var label = this.el.select('label', true).first();
13220 var icon = this.el.select('i.fa-star', true).first();
13222 if(!this.getValue().length && label && !icon){
13223 this.el.createChild({
13225 cls : 'text-danger fa fa-lg fa-star',
13226 tooltip : 'This field is required',
13227 style : 'margin-right:5px;'
13231 if (Roo.bootstrap.version == 3) {
13232 this.el.addClass(this.invalidClass);
13234 this.inputEl().addClass('is-invalid');
13237 // fixme ... this may be depricated need to test..
13238 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
13240 var feedback = this.el.select('.form-control-feedback', true).first();
13243 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13245 if(this.getValue().length || this.forceFeedback){
13246 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
13253 this.fireEvent('invalid', this, msg);
13261 * trigger field - base class for combo..
13266 * @class Roo.bootstrap.TriggerField
13267 * @extends Roo.bootstrap.Input
13268 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
13269 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
13270 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
13271 * for which you can provide a custom implementation. For example:
13273 var trigger = new Roo.bootstrap.TriggerField();
13274 trigger.onTriggerClick = myTriggerFn;
13275 trigger.applyTo('my-field');
13278 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
13279 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
13280 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
13281 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
13282 * @cfg {String} caret (search|calendar) BS3 only - carat fa name
13285 * Create a new TriggerField.
13286 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
13287 * to the base TextField)
13289 Roo.bootstrap.TriggerField = function(config){
13290 this.mimicing = false;
13291 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
13294 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
13296 * @cfg {String} triggerClass A CSS class to apply to the trigger
13299 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
13304 * @cfg {Boolean} removable (true|false) special filter default false
13308 /** @cfg {Boolean} grow @hide */
13309 /** @cfg {Number} growMin @hide */
13310 /** @cfg {Number} growMax @hide */
13316 autoSize: Roo.emptyFn,
13320 deferHeight : true,
13323 actionMode : 'wrap',
13328 getAutoCreate : function(){
13330 var align = this.labelAlign || this.parentLabelAlign();
13335 cls: 'form-group' //input-group
13342 type : this.inputType,
13343 cls : 'form-control',
13344 autocomplete: 'new-password',
13345 placeholder : this.placeholder || ''
13349 input.name = this.name;
13352 input.cls += ' input-' + this.size;
13355 if (this.disabled) {
13356 input.disabled=true;
13359 var inputblock = input;
13361 if(this.hasFeedback && !this.allowBlank){
13365 cls: 'glyphicon form-control-feedback'
13368 if(this.removable && !this.editable ){
13370 cls : 'has-feedback',
13376 cls : 'roo-combo-removable-btn close'
13383 cls : 'has-feedback',
13392 if(this.removable && !this.editable ){
13394 cls : 'roo-removable',
13400 cls : 'roo-combo-removable-btn close'
13407 if (this.before || this.after) {
13410 cls : 'input-group',
13414 inputblock.cn.push({
13416 cls : 'input-group-addon input-group-prepend input-group-text',
13421 inputblock.cn.push(input);
13423 if(this.hasFeedback && !this.allowBlank){
13424 inputblock.cls += ' has-feedback';
13425 inputblock.cn.push(feedback);
13429 inputblock.cn.push({
13431 cls : 'input-group-addon input-group-append input-group-text',
13440 var ibwrap = inputblock;
13445 cls: 'roo-select2-choices',
13449 cls: 'roo-select2-search-field',
13461 cls: 'roo-select2-container input-group',
13466 cls: 'form-hidden-field'
13472 if(!this.multiple && this.showToggleBtn){
13478 if (this.caret != false) {
13481 cls: 'fa fa-' + this.caret
13488 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
13490 Roo.bootstrap.version == 3 ? caret : '',
13493 cls: 'combobox-clear',
13507 combobox.cls += ' roo-select2-container-multi';
13511 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
13512 tooltip : 'This field is required'
13514 if (Roo.bootstrap.version == 4) {
13517 style : 'display:none'
13522 if (align ==='left' && this.fieldLabel.length) {
13524 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
13531 cls : 'control-label',
13532 html : this.fieldLabel
13544 var labelCfg = cfg.cn[1];
13545 var contentCfg = cfg.cn[2];
13547 if(this.indicatorpos == 'right'){
13552 cls : 'control-label',
13556 html : this.fieldLabel
13570 labelCfg = cfg.cn[0];
13571 contentCfg = cfg.cn[1];
13574 if(this.labelWidth > 12){
13575 labelCfg.style = "width: " + this.labelWidth + 'px';
13578 if(this.labelWidth < 13 && this.labelmd == 0){
13579 this.labelmd = this.labelWidth;
13582 if(this.labellg > 0){
13583 labelCfg.cls += ' col-lg-' + this.labellg;
13584 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
13587 if(this.labelmd > 0){
13588 labelCfg.cls += ' col-md-' + this.labelmd;
13589 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
13592 if(this.labelsm > 0){
13593 labelCfg.cls += ' col-sm-' + this.labelsm;
13594 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
13597 if(this.labelxs > 0){
13598 labelCfg.cls += ' col-xs-' + this.labelxs;
13599 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
13602 } else if ( this.fieldLabel.length) {
13603 // Roo.log(" label");
13608 //cls : 'input-group-addon',
13609 html : this.fieldLabel
13617 if(this.indicatorpos == 'right'){
13625 html : this.fieldLabel
13639 // Roo.log(" no label && no align");
13646 ['xs','sm','md','lg'].map(function(size){
13647 if (settings[size]) {
13648 cfg.cls += ' col-' + size + '-' + settings[size];
13659 onResize : function(w, h){
13660 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
13661 // if(typeof w == 'number'){
13662 // var x = w - this.trigger.getWidth();
13663 // this.inputEl().setWidth(this.adjustWidth('input', x));
13664 // this.trigger.setStyle('left', x+'px');
13669 adjustSize : Roo.BoxComponent.prototype.adjustSize,
13672 getResizeEl : function(){
13673 return this.inputEl();
13677 getPositionEl : function(){
13678 return this.inputEl();
13682 alignErrorIcon : function(){
13683 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
13687 initEvents : function(){
13691 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
13692 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
13693 if(!this.multiple && this.showToggleBtn){
13694 this.trigger = this.el.select('span.dropdown-toggle',true).first();
13695 if(this.hideTrigger){
13696 this.trigger.setDisplayed(false);
13698 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
13702 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
13705 if(this.removable && !this.editable && !this.tickable){
13706 var close = this.closeTriggerEl();
13709 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
13710 close.on('click', this.removeBtnClick, this, close);
13714 //this.trigger.addClassOnOver('x-form-trigger-over');
13715 //this.trigger.addClassOnClick('x-form-trigger-click');
13718 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
13722 closeTriggerEl : function()
13724 var close = this.el.select('.roo-combo-removable-btn', true).first();
13725 return close ? close : false;
13728 removeBtnClick : function(e, h, el)
13730 e.preventDefault();
13732 if(this.fireEvent("remove", this) !== false){
13734 this.fireEvent("afterremove", this)
13738 createList : function()
13740 this.list = Roo.get(document.body).createChild({
13741 tag: Roo.bootstrap.version == 4 ? 'div' : 'ul',
13742 cls: 'typeahead typeahead-long dropdown-menu shadow',
13743 style: 'display:none'
13746 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
13751 initTrigger : function(){
13756 onDestroy : function(){
13758 this.trigger.removeAllListeners();
13759 // this.trigger.remove();
13762 // this.wrap.remove();
13764 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
13768 onFocus : function(){
13769 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
13771 if(!this.mimicing){
13772 this.wrap.addClass('x-trigger-wrap-focus');
13773 this.mimicing = true;
13774 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
13775 if(this.monitorTab){
13776 this.el.on("keydown", this.checkTab, this);
13783 checkTab : function(e){
13784 if(e.getKey() == e.TAB){
13785 this.triggerBlur();
13790 onBlur : function(){
13795 mimicBlur : function(e, t){
13797 if(!this.wrap.contains(t) && this.validateBlur()){
13798 this.triggerBlur();
13804 triggerBlur : function(){
13805 this.mimicing = false;
13806 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
13807 if(this.monitorTab){
13808 this.el.un("keydown", this.checkTab, this);
13810 //this.wrap.removeClass('x-trigger-wrap-focus');
13811 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
13815 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
13816 validateBlur : function(e, t){
13821 onDisable : function(){
13822 this.inputEl().dom.disabled = true;
13823 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
13825 // this.wrap.addClass('x-item-disabled');
13830 onEnable : function(){
13831 this.inputEl().dom.disabled = false;
13832 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
13834 // this.el.removeClass('x-item-disabled');
13839 onShow : function(){
13840 var ae = this.getActionEl();
13843 ae.dom.style.display = '';
13844 ae.dom.style.visibility = 'visible';
13850 onHide : function(){
13851 var ae = this.getActionEl();
13852 ae.dom.style.display = 'none';
13856 * The function that should handle the trigger's click event. This method does nothing by default until overridden
13857 * by an implementing function.
13859 * @param {EventObject} e
13861 onTriggerClick : Roo.emptyFn
13869 * @class Roo.bootstrap.CardUploader
13870 * @extends Roo.bootstrap.Button
13871 * Bootstrap Card Uploader class - it's a button which when you add files to it, adds cards below with preview and the name...
13872 * @cfg {Number} errorTimeout default 3000
13873 * @cfg {Array} images an array of ?? Img objects ??? when loading existing files..
13874 * @cfg {Array} html The button text.
13878 * Create a new CardUploader
13879 * @param {Object} config The config object
13882 Roo.bootstrap.CardUploader = function(config){
13886 Roo.bootstrap.CardUploader.superclass.constructor.call(this, config);
13889 this.fileCollection = new Roo.util.MixedCollection(false,function(r) {
13897 * When a image is clicked on - and needs to display a slideshow or similar..
13898 * @param {Roo.bootstrap.Card} this
13899 * @param {Object} The image information data
13905 * When a the download link is clicked
13906 * @param {Roo.bootstrap.Card} this
13907 * @param {Object} The image information data contains
13914 Roo.extend(Roo.bootstrap.CardUploader, Roo.bootstrap.Input, {
13917 errorTimeout : 3000,
13921 fileCollection : false,
13924 getAutoCreate : function()
13928 cls :'form-group' ,
13933 //cls : 'input-group-addon',
13934 html : this.fieldLabel
13942 value : this.value,
13943 cls : 'd-none form-control'
13948 multiple : 'multiple',
13950 cls : 'd-none roo-card-upload-selector'
13954 cls : 'roo-card-uploader-button-container w-100 mb-2'
13957 cls : 'card-columns roo-card-uploader-container'
13967 getChildContainer : function() /// what children are added to.
13969 return this.containerEl;
13972 getButtonContainer : function() /// what children are added to.
13974 return this.el.select(".roo-card-uploader-button-container").first();
13977 initEvents : function()
13980 Roo.bootstrap.Input.prototype.initEvents.call(this);
13984 xns: Roo.bootstrap,
13987 container_method : 'getButtonContainer' ,
13988 html : this.html, // fix changable?
13991 'click' : function(btn, e) {
14000 this.urlAPI = (window.createObjectURL && window) ||
14001 (window.URL && URL.revokeObjectURL && URL) ||
14002 (window.webkitURL && webkitURL);
14007 this.selectorEl = this.el.select('.roo-card-upload-selector', true).first();
14009 this.selectorEl.on('change', this.onFileSelected, this);
14012 this.images.forEach(function(img) {
14015 this.images = false;
14017 this.containerEl = this.el.select('.roo-card-uploader-container', true).first();
14023 onClick : function(e)
14025 e.preventDefault();
14027 this.selectorEl.dom.click();
14031 onFileSelected : function(e)
14033 e.preventDefault();
14035 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
14039 Roo.each(this.selectorEl.dom.files, function(file){
14040 this.addFile(file);
14049 addFile : function(file)
14052 if(typeof(file) === 'string'){
14053 throw "Add file by name?"; // should not happen
14057 if(!file || !this.urlAPI){
14067 var url = _this.urlAPI.createObjectURL( file);
14070 id : Roo.bootstrap.CardUploader.ID--,
14071 is_uploaded : false,
14075 mimetype : file.type,
14083 * addCard - add an Attachment to the uploader
14084 * @param data - the data about the image to upload
14088 title : "Title of file",
14089 is_uploaded : false,
14090 src : "http://.....",
14091 srcfile : { the File upload object },
14092 mimetype : file.type,
14095 .. any other data...
14101 addCard : function (data)
14103 // hidden input element?
14104 // if the file is not an image...
14105 //then we need to use something other that and header_image
14110 xns : Roo.bootstrap,
14111 xtype : 'CardFooter',
14114 xns : Roo.bootstrap,
14120 xns : Roo.bootstrap,
14122 html : String.format("<small>{0}</small>", data.title),
14123 cls : 'col-10 text-left',
14128 click : function() {
14130 t.fireEvent( "download", t, data );
14136 xns : Roo.bootstrap,
14138 style: 'max-height: 28px; ',
14144 click : function() {
14145 t.removeCard(data.id)
14157 var cn = this.addxtype(
14160 xns : Roo.bootstrap,
14163 header : !data.mimetype.match(/image/) && !data.preview ? "Document": false,
14164 header_image : data.mimetype.match(/image/) ? data.src : data.preview,
14165 header_image_fit_square: true, // fixme - we probably need to use the 'Img' element to do stuff like this.
14170 initEvents : function() {
14171 Roo.bootstrap.Card.prototype.initEvents.call(this);
14173 this.imgEl = this.el.select('.card-img-top').first();
14175 this.imgEl.on('click', function() { t.fireEvent( "preview", t, data ); }, this);
14176 this.imgEl.set({ 'pointer' : 'cursor' });
14179 this.getCardFooter().addClass('p-1');
14186 // dont' really need ot update items.
14187 // this.items.push(cn);
14188 this.fileCollection.add(cn);
14190 if (!data.srcfile) {
14191 this.updateInput();
14196 var reader = new FileReader();
14197 reader.addEventListener("load", function() {
14198 data.srcdata = reader.result;
14201 reader.readAsDataURL(data.srcfile);
14206 removeCard : function(id)
14209 var card = this.fileCollection.get(id);
14210 card.data.is_deleted = 1;
14211 card.data.src = ''; /// delete the source - so it reduces size of not uploaded images etc.
14212 //this.fileCollection.remove(card);
14213 //this.items = this.items.filter(function(e) { return e != card });
14214 // dont' really need ot update items.
14215 card.el.dom.parentNode.removeChild(card.el.dom);
14216 this.updateInput();
14222 this.fileCollection.each(function(card) {
14223 if (card.el.dom && card.el.dom.parentNode) {
14224 card.el.dom.parentNode.removeChild(card.el.dom);
14227 this.fileCollection.clear();
14228 this.updateInput();
14231 updateInput : function()
14234 this.fileCollection.each(function(e) {
14238 this.inputEl().dom.value = JSON.stringify(data);
14248 Roo.bootstrap.CardUploader.ID = -1;/*
14250 * Ext JS Library 1.1.1
14251 * Copyright(c) 2006-2007, Ext JS, LLC.
14253 * Originally Released Under LGPL - original licence link has changed is not relivant.
14256 * <script type="text/javascript">
14261 * @class Roo.data.SortTypes
14263 * Defines the default sorting (casting?) comparison functions used when sorting data.
14265 Roo.data.SortTypes = {
14267 * Default sort that does nothing
14268 * @param {Mixed} s The value being converted
14269 * @return {Mixed} The comparison value
14271 none : function(s){
14276 * The regular expression used to strip tags
14280 stripTagsRE : /<\/?[^>]+>/gi,
14283 * Strips all HTML tags to sort on text only
14284 * @param {Mixed} s The value being converted
14285 * @return {String} The comparison value
14287 asText : function(s){
14288 return String(s).replace(this.stripTagsRE, "");
14292 * Strips all HTML tags to sort on text only - Case insensitive
14293 * @param {Mixed} s The value being converted
14294 * @return {String} The comparison value
14296 asUCText : function(s){
14297 return String(s).toUpperCase().replace(this.stripTagsRE, "");
14301 * Case insensitive string
14302 * @param {Mixed} s The value being converted
14303 * @return {String} The comparison value
14305 asUCString : function(s) {
14306 return String(s).toUpperCase();
14311 * @param {Mixed} s The value being converted
14312 * @return {Number} The comparison value
14314 asDate : function(s) {
14318 if(s instanceof Date){
14319 return s.getTime();
14321 return Date.parse(String(s));
14326 * @param {Mixed} s The value being converted
14327 * @return {Float} The comparison value
14329 asFloat : function(s) {
14330 var val = parseFloat(String(s).replace(/,/g, ""));
14339 * @param {Mixed} s The value being converted
14340 * @return {Number} The comparison value
14342 asInt : function(s) {
14343 var val = parseInt(String(s).replace(/,/g, ""));
14351 * Ext JS Library 1.1.1
14352 * Copyright(c) 2006-2007, Ext JS, LLC.
14354 * Originally Released Under LGPL - original licence link has changed is not relivant.
14357 * <script type="text/javascript">
14361 * @class Roo.data.Record
14362 * Instances of this class encapsulate both record <em>definition</em> information, and record
14363 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
14364 * to access Records cached in an {@link Roo.data.Store} object.<br>
14366 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
14367 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
14370 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
14372 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
14373 * {@link #create}. The parameters are the same.
14374 * @param {Array} data An associative Array of data values keyed by the field name.
14375 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
14376 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
14377 * not specified an integer id is generated.
14379 Roo.data.Record = function(data, id){
14380 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
14385 * Generate a constructor for a specific record layout.
14386 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
14387 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
14388 * Each field definition object may contain the following properties: <ul>
14389 * <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,
14390 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
14391 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
14392 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
14393 * is being used, then this is a string containing the javascript expression to reference the data relative to
14394 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
14395 * to the data item relative to the record element. If the mapping expression is the same as the field name,
14396 * this may be omitted.</p></li>
14397 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
14398 * <ul><li>auto (Default, implies no conversion)</li>
14403 * <li>date</li></ul></p></li>
14404 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
14405 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
14406 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
14407 * by the Reader into an object that will be stored in the Record. It is passed the
14408 * following parameters:<ul>
14409 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
14411 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
14413 * <br>usage:<br><pre><code>
14414 var TopicRecord = Roo.data.Record.create(
14415 {name: 'title', mapping: 'topic_title'},
14416 {name: 'author', mapping: 'username'},
14417 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
14418 {name: 'lastPost', mapping: 'post_time', type: 'date'},
14419 {name: 'lastPoster', mapping: 'user2'},
14420 {name: 'excerpt', mapping: 'post_text'}
14423 var myNewRecord = new TopicRecord({
14424 title: 'Do my job please',
14427 lastPost: new Date(),
14428 lastPoster: 'Animal',
14429 excerpt: 'No way dude!'
14431 myStore.add(myNewRecord);
14436 Roo.data.Record.create = function(o){
14437 var f = function(){
14438 f.superclass.constructor.apply(this, arguments);
14440 Roo.extend(f, Roo.data.Record);
14441 var p = f.prototype;
14442 p.fields = new Roo.util.MixedCollection(false, function(field){
14445 for(var i = 0, len = o.length; i < len; i++){
14446 p.fields.add(new Roo.data.Field(o[i]));
14448 f.getField = function(name){
14449 return p.fields.get(name);
14454 Roo.data.Record.AUTO_ID = 1000;
14455 Roo.data.Record.EDIT = 'edit';
14456 Roo.data.Record.REJECT = 'reject';
14457 Roo.data.Record.COMMIT = 'commit';
14459 Roo.data.Record.prototype = {
14461 * Readonly flag - true if this record has been modified.
14470 join : function(store){
14471 this.store = store;
14475 * Set the named field to the specified value.
14476 * @param {String} name The name of the field to set.
14477 * @param {Object} value The value to set the field to.
14479 set : function(name, value){
14480 if(this.data[name] == value){
14484 if(!this.modified){
14485 this.modified = {};
14487 if(typeof this.modified[name] == 'undefined'){
14488 this.modified[name] = this.data[name];
14490 this.data[name] = value;
14491 if(!this.editing && this.store){
14492 this.store.afterEdit(this);
14497 * Get the value of the named field.
14498 * @param {String} name The name of the field to get the value of.
14499 * @return {Object} The value of the field.
14501 get : function(name){
14502 return this.data[name];
14506 beginEdit : function(){
14507 this.editing = true;
14508 this.modified = {};
14512 cancelEdit : function(){
14513 this.editing = false;
14514 delete this.modified;
14518 endEdit : function(){
14519 this.editing = false;
14520 if(this.dirty && this.store){
14521 this.store.afterEdit(this);
14526 * Usually called by the {@link Roo.data.Store} which owns the Record.
14527 * Rejects all changes made to the Record since either creation, or the last commit operation.
14528 * Modified fields are reverted to their original values.
14530 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
14531 * of reject operations.
14533 reject : function(){
14534 var m = this.modified;
14536 if(typeof m[n] != "function"){
14537 this.data[n] = m[n];
14540 this.dirty = false;
14541 delete this.modified;
14542 this.editing = false;
14544 this.store.afterReject(this);
14549 * Usually called by the {@link Roo.data.Store} which owns the Record.
14550 * Commits all changes made to the Record since either creation, or the last commit operation.
14552 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
14553 * of commit operations.
14555 commit : function(){
14556 this.dirty = false;
14557 delete this.modified;
14558 this.editing = false;
14560 this.store.afterCommit(this);
14565 hasError : function(){
14566 return this.error != null;
14570 clearError : function(){
14575 * Creates a copy of this record.
14576 * @param {String} id (optional) A new record id if you don't want to use this record's id
14579 copy : function(newId) {
14580 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
14584 * Ext JS Library 1.1.1
14585 * Copyright(c) 2006-2007, Ext JS, LLC.
14587 * Originally Released Under LGPL - original licence link has changed is not relivant.
14590 * <script type="text/javascript">
14596 * @class Roo.data.Store
14597 * @extends Roo.util.Observable
14598 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
14599 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
14601 * 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
14602 * has no knowledge of the format of the data returned by the Proxy.<br>
14604 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
14605 * instances from the data object. These records are cached and made available through accessor functions.
14607 * Creates a new Store.
14608 * @param {Object} config A config object containing the objects needed for the Store to access data,
14609 * and read the data into Records.
14611 Roo.data.Store = function(config){
14612 this.data = new Roo.util.MixedCollection(false);
14613 this.data.getKey = function(o){
14616 this.baseParams = {};
14618 this.paramNames = {
14623 "multisort" : "_multisort"
14626 if(config && config.data){
14627 this.inlineData = config.data;
14628 delete config.data;
14631 Roo.apply(this, config);
14633 if(this.reader){ // reader passed
14634 this.reader = Roo.factory(this.reader, Roo.data);
14635 this.reader.xmodule = this.xmodule || false;
14636 if(!this.recordType){
14637 this.recordType = this.reader.recordType;
14639 if(this.reader.onMetaChange){
14640 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
14644 if(this.recordType){
14645 this.fields = this.recordType.prototype.fields;
14647 this.modified = [];
14651 * @event datachanged
14652 * Fires when the data cache has changed, and a widget which is using this Store
14653 * as a Record cache should refresh its view.
14654 * @param {Store} this
14656 datachanged : true,
14658 * @event metachange
14659 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
14660 * @param {Store} this
14661 * @param {Object} meta The JSON metadata
14666 * Fires when Records have been added to the Store
14667 * @param {Store} this
14668 * @param {Roo.data.Record[]} records The array of Records added
14669 * @param {Number} index The index at which the record(s) were added
14674 * Fires when a Record has been removed from the Store
14675 * @param {Store} this
14676 * @param {Roo.data.Record} record The Record that was removed
14677 * @param {Number} index The index at which the record was removed
14682 * Fires when a Record has been updated
14683 * @param {Store} this
14684 * @param {Roo.data.Record} record The Record that was updated
14685 * @param {String} operation The update operation being performed. Value may be one of:
14687 Roo.data.Record.EDIT
14688 Roo.data.Record.REJECT
14689 Roo.data.Record.COMMIT
14695 * Fires when the data cache has been cleared.
14696 * @param {Store} this
14700 * @event beforeload
14701 * Fires before a request is made for a new data object. If the beforeload handler returns false
14702 * the load action will be canceled.
14703 * @param {Store} this
14704 * @param {Object} options The loading options that were specified (see {@link #load} for details)
14708 * @event beforeloadadd
14709 * Fires after a new set of Records has been loaded.
14710 * @param {Store} this
14711 * @param {Roo.data.Record[]} records The Records that were loaded
14712 * @param {Object} options The loading options that were specified (see {@link #load} for details)
14714 beforeloadadd : true,
14717 * Fires after a new set of Records has been loaded, before they are added to the store.
14718 * @param {Store} this
14719 * @param {Roo.data.Record[]} records The Records that were loaded
14720 * @param {Object} options The loading options that were specified (see {@link #load} for details)
14721 * @params {Object} return from reader
14725 * @event loadexception
14726 * Fires if an exception occurs in the Proxy during loading.
14727 * Called with the signature of the Proxy's "loadexception" event.
14728 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
14731 * @param {Object} return from JsonData.reader() - success, totalRecords, records
14732 * @param {Object} load options
14733 * @param {Object} jsonData from your request (normally this contains the Exception)
14735 loadexception : true
14739 this.proxy = Roo.factory(this.proxy, Roo.data);
14740 this.proxy.xmodule = this.xmodule || false;
14741 this.relayEvents(this.proxy, ["loadexception"]);
14743 this.sortToggle = {};
14744 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
14746 Roo.data.Store.superclass.constructor.call(this);
14748 if(this.inlineData){
14749 this.loadData(this.inlineData);
14750 delete this.inlineData;
14754 Roo.extend(Roo.data.Store, Roo.util.Observable, {
14756 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
14757 * without a remote query - used by combo/forms at present.
14761 * @cfg {Roo.data.DataProxy} proxy [required] The Proxy object which provides access to a data object.
14764 * @cfg {Array} data Inline data to be loaded when the store is initialized.
14767 * @cfg {Roo.data.DataReader} reader [required] The Reader object which processes the data object and returns
14768 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
14771 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
14772 * on any HTTP request
14775 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
14778 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
14782 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
14783 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
14785 remoteSort : false,
14788 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
14789 * loaded or when a record is removed. (defaults to false).
14791 pruneModifiedRecords : false,
14794 lastOptions : null,
14797 * Add Records to the Store and fires the add event.
14798 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
14800 add : function(records){
14801 records = [].concat(records);
14802 for(var i = 0, len = records.length; i < len; i++){
14803 records[i].join(this);
14805 var index = this.data.length;
14806 this.data.addAll(records);
14807 this.fireEvent("add", this, records, index);
14811 * Remove a Record from the Store and fires the remove event.
14812 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
14814 remove : function(record){
14815 var index = this.data.indexOf(record);
14816 this.data.removeAt(index);
14818 if(this.pruneModifiedRecords){
14819 this.modified.remove(record);
14821 this.fireEvent("remove", this, record, index);
14825 * Remove all Records from the Store and fires the clear event.
14827 removeAll : function(){
14829 if(this.pruneModifiedRecords){
14830 this.modified = [];
14832 this.fireEvent("clear", this);
14836 * Inserts Records to the Store at the given index and fires the add event.
14837 * @param {Number} index The start index at which to insert the passed Records.
14838 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
14840 insert : function(index, records){
14841 records = [].concat(records);
14842 for(var i = 0, len = records.length; i < len; i++){
14843 this.data.insert(index, records[i]);
14844 records[i].join(this);
14846 this.fireEvent("add", this, records, index);
14850 * Get the index within the cache of the passed Record.
14851 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
14852 * @return {Number} The index of the passed Record. Returns -1 if not found.
14854 indexOf : function(record){
14855 return this.data.indexOf(record);
14859 * Get the index within the cache of the Record with the passed id.
14860 * @param {String} id The id of the Record to find.
14861 * @return {Number} The index of the Record. Returns -1 if not found.
14863 indexOfId : function(id){
14864 return this.data.indexOfKey(id);
14868 * Get the Record with the specified id.
14869 * @param {String} id The id of the Record to find.
14870 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
14872 getById : function(id){
14873 return this.data.key(id);
14877 * Get the Record at the specified index.
14878 * @param {Number} index The index of the Record to find.
14879 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
14881 getAt : function(index){
14882 return this.data.itemAt(index);
14886 * Returns a range of Records between specified indices.
14887 * @param {Number} startIndex (optional) The starting index (defaults to 0)
14888 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
14889 * @return {Roo.data.Record[]} An array of Records
14891 getRange : function(start, end){
14892 return this.data.getRange(start, end);
14896 storeOptions : function(o){
14897 o = Roo.apply({}, o);
14900 this.lastOptions = o;
14904 * Loads the Record cache from the configured Proxy using the configured Reader.
14906 * If using remote paging, then the first load call must specify the <em>start</em>
14907 * and <em>limit</em> properties in the options.params property to establish the initial
14908 * position within the dataset, and the number of Records to cache on each read from the Proxy.
14910 * <strong>It is important to note that for remote data sources, loading is asynchronous,
14911 * and this call will return before the new data has been loaded. Perform any post-processing
14912 * in a callback function, or in a "load" event handler.</strong>
14914 * @param {Object} options An object containing properties which control loading options:<ul>
14915 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
14916 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
14917 * passed the following arguments:<ul>
14918 * <li>r : Roo.data.Record[]</li>
14919 * <li>options: Options object from the load call</li>
14920 * <li>success: Boolean success indicator</li></ul></li>
14921 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
14922 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
14925 load : function(options){
14926 options = options || {};
14927 if(this.fireEvent("beforeload", this, options) !== false){
14928 this.storeOptions(options);
14929 var p = Roo.apply(options.params || {}, this.baseParams);
14930 // if meta was not loaded from remote source.. try requesting it.
14931 if (!this.reader.metaFromRemote) {
14932 p._requestMeta = 1;
14934 if(this.sortInfo && this.remoteSort){
14935 var pn = this.paramNames;
14936 p[pn["sort"]] = this.sortInfo.field;
14937 p[pn["dir"]] = this.sortInfo.direction;
14939 if (this.multiSort) {
14940 var pn = this.paramNames;
14941 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
14944 this.proxy.load(p, this.reader, this.loadRecords, this, options);
14949 * Reloads the Record cache from the configured Proxy using the configured Reader and
14950 * the options from the last load operation performed.
14951 * @param {Object} options (optional) An object containing properties which may override the options
14952 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
14953 * the most recently used options are reused).
14955 reload : function(options){
14956 this.load(Roo.applyIf(options||{}, this.lastOptions));
14960 // Called as a callback by the Reader during a load operation.
14961 loadRecords : function(o, options, success){
14962 if(!o || success === false){
14963 if(success !== false){
14964 this.fireEvent("load", this, [], options, o);
14966 if(options.callback){
14967 options.callback.call(options.scope || this, [], options, false);
14971 // if data returned failure - throw an exception.
14972 if (o.success === false) {
14973 // show a message if no listener is registered.
14974 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
14975 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
14977 // loadmask wil be hooked into this..
14978 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
14981 var r = o.records, t = o.totalRecords || r.length;
14983 this.fireEvent("beforeloadadd", this, r, options, o);
14985 if(!options || options.add !== true){
14986 if(this.pruneModifiedRecords){
14987 this.modified = [];
14989 for(var i = 0, len = r.length; i < len; i++){
14993 this.data = this.snapshot;
14994 delete this.snapshot;
14997 this.data.addAll(r);
14998 this.totalLength = t;
15000 this.fireEvent("datachanged", this);
15002 this.totalLength = Math.max(t, this.data.length+r.length);
15006 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
15008 var e = new Roo.data.Record({});
15010 e.set(this.parent.displayField, this.parent.emptyTitle);
15011 e.set(this.parent.valueField, '');
15016 this.fireEvent("load", this, r, options, o);
15017 if(options.callback){
15018 options.callback.call(options.scope || this, r, options, true);
15024 * Loads data from a passed data block. A Reader which understands the format of the data
15025 * must have been configured in the constructor.
15026 * @param {Object} data The data block from which to read the Records. The format of the data expected
15027 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
15028 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
15030 loadData : function(o, append){
15031 var r = this.reader.readRecords(o);
15032 this.loadRecords(r, {add: append}, true);
15036 * using 'cn' the nested child reader read the child array into it's child stores.
15037 * @param {Object} rec The record with a 'children array
15039 loadDataFromChildren : function(rec)
15041 this.loadData(this.reader.toLoadData(rec));
15046 * Gets the number of cached records.
15048 * <em>If using paging, this may not be the total size of the dataset. If the data object
15049 * used by the Reader contains the dataset size, then the getTotalCount() function returns
15050 * the data set size</em>
15052 getCount : function(){
15053 return this.data.length || 0;
15057 * Gets the total number of records in the dataset as returned by the server.
15059 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
15060 * the dataset size</em>
15062 getTotalCount : function(){
15063 return this.totalLength || 0;
15067 * Returns the sort state of the Store as an object with two properties:
15069 field {String} The name of the field by which the Records are sorted
15070 direction {String} The sort order, "ASC" or "DESC"
15073 getSortState : function(){
15074 return this.sortInfo;
15078 applySort : function(){
15079 if(this.sortInfo && !this.remoteSort){
15080 var s = this.sortInfo, f = s.field;
15081 var st = this.fields.get(f).sortType;
15082 var fn = function(r1, r2){
15083 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
15084 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
15086 this.data.sort(s.direction, fn);
15087 if(this.snapshot && this.snapshot != this.data){
15088 this.snapshot.sort(s.direction, fn);
15094 * Sets the default sort column and order to be used by the next load operation.
15095 * @param {String} fieldName The name of the field to sort by.
15096 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
15098 setDefaultSort : function(field, dir){
15099 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
15103 * Sort the Records.
15104 * If remote sorting is used, the sort is performed on the server, and the cache is
15105 * reloaded. If local sorting is used, the cache is sorted internally.
15106 * @param {String} fieldName The name of the field to sort by.
15107 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
15109 sort : function(fieldName, dir){
15110 var f = this.fields.get(fieldName);
15112 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
15114 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
15115 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
15120 this.sortToggle[f.name] = dir;
15121 this.sortInfo = {field: f.name, direction: dir};
15122 if(!this.remoteSort){
15124 this.fireEvent("datachanged", this);
15126 this.load(this.lastOptions);
15131 * Calls the specified function for each of the Records in the cache.
15132 * @param {Function} fn The function to call. The Record is passed as the first parameter.
15133 * Returning <em>false</em> aborts and exits the iteration.
15134 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
15136 each : function(fn, scope){
15137 this.data.each(fn, scope);
15141 * Gets all records modified since the last commit. Modified records are persisted across load operations
15142 * (e.g., during paging).
15143 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
15145 getModifiedRecords : function(){
15146 return this.modified;
15150 createFilterFn : function(property, value, anyMatch){
15151 if(!value.exec){ // not a regex
15152 value = String(value);
15153 if(value.length == 0){
15156 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
15158 return function(r){
15159 return value.test(r.data[property]);
15164 * Sums the value of <i>property</i> for each record between start and end and returns the result.
15165 * @param {String} property A field on your records
15166 * @param {Number} start The record index to start at (defaults to 0)
15167 * @param {Number} end The last record index to include (defaults to length - 1)
15168 * @return {Number} The sum
15170 sum : function(property, start, end){
15171 var rs = this.data.items, v = 0;
15172 start = start || 0;
15173 end = (end || end === 0) ? end : rs.length-1;
15175 for(var i = start; i <= end; i++){
15176 v += (rs[i].data[property] || 0);
15182 * Filter the records by a specified property.
15183 * @param {String} field A field on your records
15184 * @param {String/RegExp} value Either a string that the field
15185 * should start with or a RegExp to test against the field
15186 * @param {Boolean} anyMatch True to match any part not just the beginning
15188 filter : function(property, value, anyMatch){
15189 var fn = this.createFilterFn(property, value, anyMatch);
15190 return fn ? this.filterBy(fn) : this.clearFilter();
15194 * Filter by a function. The specified function will be called with each
15195 * record in this data source. If the function returns true the record is included,
15196 * otherwise it is filtered.
15197 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
15198 * @param {Object} scope (optional) The scope of the function (defaults to this)
15200 filterBy : function(fn, scope){
15201 this.snapshot = this.snapshot || this.data;
15202 this.data = this.queryBy(fn, scope||this);
15203 this.fireEvent("datachanged", this);
15207 * Query the records by a specified property.
15208 * @param {String} field A field on your records
15209 * @param {String/RegExp} value Either a string that the field
15210 * should start with or a RegExp to test against the field
15211 * @param {Boolean} anyMatch True to match any part not just the beginning
15212 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
15214 query : function(property, value, anyMatch){
15215 var fn = this.createFilterFn(property, value, anyMatch);
15216 return fn ? this.queryBy(fn) : this.data.clone();
15220 * Query by a function. The specified function will be called with each
15221 * record in this data source. If the function returns true the record is included
15223 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
15224 * @param {Object} scope (optional) The scope of the function (defaults to this)
15225 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
15227 queryBy : function(fn, scope){
15228 var data = this.snapshot || this.data;
15229 return data.filterBy(fn, scope||this);
15233 * Collects unique values for a particular dataIndex from this store.
15234 * @param {String} dataIndex The property to collect
15235 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
15236 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
15237 * @return {Array} An array of the unique values
15239 collect : function(dataIndex, allowNull, bypassFilter){
15240 var d = (bypassFilter === true && this.snapshot) ?
15241 this.snapshot.items : this.data.items;
15242 var v, sv, r = [], l = {};
15243 for(var i = 0, len = d.length; i < len; i++){
15244 v = d[i].data[dataIndex];
15246 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
15255 * Revert to a view of the Record cache with no filtering applied.
15256 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
15258 clearFilter : function(suppressEvent){
15259 if(this.snapshot && this.snapshot != this.data){
15260 this.data = this.snapshot;
15261 delete this.snapshot;
15262 if(suppressEvent !== true){
15263 this.fireEvent("datachanged", this);
15269 afterEdit : function(record){
15270 if(this.modified.indexOf(record) == -1){
15271 this.modified.push(record);
15273 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
15277 afterReject : function(record){
15278 this.modified.remove(record);
15279 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
15283 afterCommit : function(record){
15284 this.modified.remove(record);
15285 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
15289 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
15290 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
15292 commitChanges : function(){
15293 var m = this.modified.slice(0);
15294 this.modified = [];
15295 for(var i = 0, len = m.length; i < len; i++){
15301 * Cancel outstanding changes on all changed records.
15303 rejectChanges : function(){
15304 var m = this.modified.slice(0);
15305 this.modified = [];
15306 for(var i = 0, len = m.length; i < len; i++){
15311 onMetaChange : function(meta, rtype, o){
15312 this.recordType = rtype;
15313 this.fields = rtype.prototype.fields;
15314 delete this.snapshot;
15315 this.sortInfo = meta.sortInfo || this.sortInfo;
15316 this.modified = [];
15317 this.fireEvent('metachange', this, this.reader.meta);
15320 moveIndex : function(data, type)
15322 var index = this.indexOf(data);
15324 var newIndex = index + type;
15328 this.insert(newIndex, data);
15333 * Ext JS Library 1.1.1
15334 * Copyright(c) 2006-2007, Ext JS, LLC.
15336 * Originally Released Under LGPL - original licence link has changed is not relivant.
15339 * <script type="text/javascript">
15343 * @class Roo.data.SimpleStore
15344 * @extends Roo.data.Store
15345 * Small helper class to make creating Stores from Array data easier.
15346 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
15347 * @cfg {Array} fields An array of field definition objects, or field name strings.
15348 * @cfg {Object} an existing reader (eg. copied from another store)
15349 * @cfg {Array} data The multi-dimensional array of data
15350 * @cfg {Roo.data.DataProxy} proxy [not-required]
15351 * @cfg {Roo.data.Reader} reader [not-required]
15353 * @param {Object} config
15355 Roo.data.SimpleStore = function(config)
15357 Roo.data.SimpleStore.superclass.constructor.call(this, {
15359 reader: typeof(config.reader) != 'undefined' ? config.reader : new Roo.data.ArrayReader({
15362 Roo.data.Record.create(config.fields)
15364 proxy : new Roo.data.MemoryProxy(config.data)
15368 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
15370 * Ext JS Library 1.1.1
15371 * Copyright(c) 2006-2007, Ext JS, LLC.
15373 * Originally Released Under LGPL - original licence link has changed is not relivant.
15376 * <script type="text/javascript">
15381 * @extends Roo.data.Store
15382 * @class Roo.data.JsonStore
15383 * Small helper class to make creating Stores for JSON data easier. <br/>
15385 var store = new Roo.data.JsonStore({
15386 url: 'get-images.php',
15388 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
15391 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
15392 * JsonReader and HttpProxy (unless inline data is provided).</b>
15393 * @cfg {Array} fields An array of field definition objects, or field name strings.
15395 * @param {Object} config
15397 Roo.data.JsonStore = function(c){
15398 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
15399 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
15400 reader: new Roo.data.JsonReader(c, c.fields)
15403 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
15405 * Ext JS Library 1.1.1
15406 * Copyright(c) 2006-2007, Ext JS, LLC.
15408 * Originally Released Under LGPL - original licence link has changed is not relivant.
15411 * <script type="text/javascript">
15415 Roo.data.Field = function(config){
15416 if(typeof config == "string"){
15417 config = {name: config};
15419 Roo.apply(this, config);
15422 this.type = "auto";
15425 var st = Roo.data.SortTypes;
15426 // named sortTypes are supported, here we look them up
15427 if(typeof this.sortType == "string"){
15428 this.sortType = st[this.sortType];
15431 // set default sortType for strings and dates
15432 if(!this.sortType){
15435 this.sortType = st.asUCString;
15438 this.sortType = st.asDate;
15441 this.sortType = st.none;
15446 var stripRe = /[\$,%]/g;
15448 // prebuilt conversion function for this field, instead of
15449 // switching every time we're reading a value
15451 var cv, dateFormat = this.dateFormat;
15456 cv = function(v){ return v; };
15459 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
15463 return v !== undefined && v !== null && v !== '' ?
15464 parseInt(String(v).replace(stripRe, ""), 10) : '';
15469 return v !== undefined && v !== null && v !== '' ?
15470 parseFloat(String(v).replace(stripRe, ""), 10) : '';
15475 cv = function(v){ return v === true || v === "true" || v == 1; };
15482 if(v instanceof Date){
15486 if(dateFormat == "timestamp"){
15487 return new Date(v*1000);
15489 return Date.parseDate(v, dateFormat);
15491 var parsed = Date.parse(v);
15492 return parsed ? new Date(parsed) : null;
15501 Roo.data.Field.prototype = {
15509 * Ext JS Library 1.1.1
15510 * Copyright(c) 2006-2007, Ext JS, LLC.
15512 * Originally Released Under LGPL - original licence link has changed is not relivant.
15515 * <script type="text/javascript">
15518 // Base class for reading structured data from a data source. This class is intended to be
15519 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
15522 * @class Roo.data.DataReader
15524 * Base class for reading structured data from a data source. This class is intended to be
15525 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
15528 Roo.data.DataReader = function(meta, recordType){
15532 this.recordType = recordType instanceof Array ?
15533 Roo.data.Record.create(recordType) : recordType;
15536 Roo.data.DataReader.prototype = {
15539 readerType : 'Data',
15541 * Create an empty record
15542 * @param {Object} data (optional) - overlay some values
15543 * @return {Roo.data.Record} record created.
15545 newRow : function(d) {
15547 this.recordType.prototype.fields.each(function(c) {
15549 case 'int' : da[c.name] = 0; break;
15550 case 'date' : da[c.name] = new Date(); break;
15551 case 'float' : da[c.name] = 0.0; break;
15552 case 'boolean' : da[c.name] = false; break;
15553 default : da[c.name] = ""; break;
15557 return new this.recordType(Roo.apply(da, d));
15563 * Ext JS Library 1.1.1
15564 * Copyright(c) 2006-2007, Ext JS, LLC.
15566 * Originally Released Under LGPL - original licence link has changed is not relivant.
15569 * <script type="text/javascript">
15573 * @class Roo.data.DataProxy
15574 * @extends Roo.data.Observable
15576 * This class is an abstract base class for implementations which provide retrieval of
15577 * unformatted data objects.<br>
15579 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
15580 * (of the appropriate type which knows how to parse the data object) to provide a block of
15581 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
15583 * Custom implementations must implement the load method as described in
15584 * {@link Roo.data.HttpProxy#load}.
15586 Roo.data.DataProxy = function(){
15589 * @event beforeload
15590 * Fires before a network request is made to retrieve a data object.
15591 * @param {Object} This DataProxy object.
15592 * @param {Object} params The params parameter to the load function.
15597 * Fires before the load method's callback is called.
15598 * @param {Object} This DataProxy object.
15599 * @param {Object} o The data object.
15600 * @param {Object} arg The callback argument object passed to the load function.
15604 * @event loadexception
15605 * Fires if an Exception occurs during data retrieval.
15606 * @param {Object} This DataProxy object.
15607 * @param {Object} o The data object.
15608 * @param {Object} arg The callback argument object passed to the load function.
15609 * @param {Object} e The Exception.
15611 loadexception : true
15613 Roo.data.DataProxy.superclass.constructor.call(this);
15616 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
15619 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
15623 * Ext JS Library 1.1.1
15624 * Copyright(c) 2006-2007, Ext JS, LLC.
15626 * Originally Released Under LGPL - original licence link has changed is not relivant.
15629 * <script type="text/javascript">
15632 * @class Roo.data.MemoryProxy
15633 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
15634 * to the Reader when its load method is called.
15636 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
15638 Roo.data.MemoryProxy = function(data){
15642 Roo.data.MemoryProxy.superclass.constructor.call(this);
15646 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
15649 * Load data from the requested source (in this case an in-memory
15650 * data object passed to the constructor), read the data object into
15651 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
15652 * process that block using the passed callback.
15653 * @param {Object} params This parameter is not used by the MemoryProxy class.
15654 * @param {Roo.data.DataReader} reader The Reader object which converts the data
15655 * object into a block of Roo.data.Records.
15656 * @param {Function} callback The function into which to pass the block of Roo.data.records.
15657 * The function must be passed <ul>
15658 * <li>The Record block object</li>
15659 * <li>The "arg" argument from the load function</li>
15660 * <li>A boolean success indicator</li>
15662 * @param {Object} scope The scope in which to call the callback
15663 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
15665 load : function(params, reader, callback, scope, arg){
15666 params = params || {};
15669 result = reader.readRecords(params.data ? params.data :this.data);
15671 this.fireEvent("loadexception", this, arg, null, e);
15672 callback.call(scope, null, arg, false);
15675 callback.call(scope, result, arg, true);
15679 update : function(params, records){
15684 * Ext JS Library 1.1.1
15685 * Copyright(c) 2006-2007, Ext JS, LLC.
15687 * Originally Released Under LGPL - original licence link has changed is not relivant.
15690 * <script type="text/javascript">
15693 * @class Roo.data.HttpProxy
15694 * @extends Roo.data.DataProxy
15695 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
15696 * configured to reference a certain URL.<br><br>
15698 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
15699 * from which the running page was served.<br><br>
15701 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
15703 * Be aware that to enable the browser to parse an XML document, the server must set
15704 * the Content-Type header in the HTTP response to "text/xml".
15706 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
15707 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
15708 * will be used to make the request.
15710 Roo.data.HttpProxy = function(conn){
15711 Roo.data.HttpProxy.superclass.constructor.call(this);
15712 // is conn a conn config or a real conn?
15714 this.useAjax = !conn || !conn.events;
15718 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
15719 // thse are take from connection...
15722 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
15725 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
15726 * extra parameters to each request made by this object. (defaults to undefined)
15729 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
15730 * to each request made by this object. (defaults to undefined)
15733 * @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)
15736 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
15739 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
15745 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
15749 * Return the {@link Roo.data.Connection} object being used by this Proxy.
15750 * @return {Connection} The Connection object. This object may be used to subscribe to events on
15751 * a finer-grained basis than the DataProxy events.
15753 getConnection : function(){
15754 return this.useAjax ? Roo.Ajax : this.conn;
15758 * Load data from the configured {@link Roo.data.Connection}, read the data object into
15759 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
15760 * process that block using the passed callback.
15761 * @param {Object} params An object containing properties which are to be used as HTTP parameters
15762 * for the request to the remote server.
15763 * @param {Roo.data.DataReader} reader The Reader object which converts the data
15764 * object into a block of Roo.data.Records.
15765 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
15766 * The function must be passed <ul>
15767 * <li>The Record block object</li>
15768 * <li>The "arg" argument from the load function</li>
15769 * <li>A boolean success indicator</li>
15771 * @param {Object} scope The scope in which to call the callback
15772 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
15774 load : function(params, reader, callback, scope, arg){
15775 if(this.fireEvent("beforeload", this, params) !== false){
15777 params : params || {},
15779 callback : callback,
15784 callback : this.loadResponse,
15788 Roo.applyIf(o, this.conn);
15789 if(this.activeRequest){
15790 Roo.Ajax.abort(this.activeRequest);
15792 this.activeRequest = Roo.Ajax.request(o);
15794 this.conn.request(o);
15797 callback.call(scope||this, null, arg, false);
15802 loadResponse : function(o, success, response){
15803 delete this.activeRequest;
15805 this.fireEvent("loadexception", this, o, response);
15806 o.request.callback.call(o.request.scope, null, o.request.arg, false);
15811 result = o.reader.read(response);
15813 this.fireEvent("loadexception", this, o, response, e);
15814 o.request.callback.call(o.request.scope, null, o.request.arg, false);
15818 this.fireEvent("load", this, o, o.request.arg);
15819 o.request.callback.call(o.request.scope, result, o.request.arg, true);
15823 update : function(dataSet){
15828 updateResponse : function(dataSet){
15833 * Ext JS Library 1.1.1
15834 * Copyright(c) 2006-2007, Ext JS, LLC.
15836 * Originally Released Under LGPL - original licence link has changed is not relivant.
15839 * <script type="text/javascript">
15843 * @class Roo.data.ScriptTagProxy
15844 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
15845 * other than the originating domain of the running page.<br><br>
15847 * <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
15848 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
15850 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
15851 * source code that is used as the source inside a <script> tag.<br><br>
15853 * In order for the browser to process the returned data, the server must wrap the data object
15854 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
15855 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
15856 * depending on whether the callback name was passed:
15859 boolean scriptTag = false;
15860 String cb = request.getParameter("callback");
15863 response.setContentType("text/javascript");
15865 response.setContentType("application/x-json");
15867 Writer out = response.getWriter();
15869 out.write(cb + "(");
15871 out.print(dataBlock.toJsonString());
15878 * @param {Object} config A configuration object.
15880 Roo.data.ScriptTagProxy = function(config){
15881 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
15882 Roo.apply(this, config);
15883 this.head = document.getElementsByTagName("head")[0];
15886 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
15888 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
15890 * @cfg {String} url The URL from which to request the data object.
15893 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
15897 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
15898 * the server the name of the callback function set up by the load call to process the returned data object.
15899 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
15900 * javascript output which calls this named function passing the data object as its only parameter.
15902 callbackParam : "callback",
15904 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
15905 * name to the request.
15910 * Load data from the configured URL, read the data object into
15911 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
15912 * process that block using the passed callback.
15913 * @param {Object} params An object containing properties which are to be used as HTTP parameters
15914 * for the request to the remote server.
15915 * @param {Roo.data.DataReader} reader The Reader object which converts the data
15916 * object into a block of Roo.data.Records.
15917 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
15918 * The function must be passed <ul>
15919 * <li>The Record block object</li>
15920 * <li>The "arg" argument from the load function</li>
15921 * <li>A boolean success indicator</li>
15923 * @param {Object} scope The scope in which to call the callback
15924 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
15926 load : function(params, reader, callback, scope, arg){
15927 if(this.fireEvent("beforeload", this, params) !== false){
15929 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
15931 var url = this.url;
15932 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
15934 url += "&_dc=" + (new Date().getTime());
15936 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
15939 cb : "stcCallback"+transId,
15940 scriptId : "stcScript"+transId,
15944 callback : callback,
15950 window[trans.cb] = function(o){
15951 conn.handleResponse(o, trans);
15954 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
15956 if(this.autoAbort !== false){
15960 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
15962 var script = document.createElement("script");
15963 script.setAttribute("src", url);
15964 script.setAttribute("type", "text/javascript");
15965 script.setAttribute("id", trans.scriptId);
15966 this.head.appendChild(script);
15968 this.trans = trans;
15970 callback.call(scope||this, null, arg, false);
15975 isLoading : function(){
15976 return this.trans ? true : false;
15980 * Abort the current server request.
15982 abort : function(){
15983 if(this.isLoading()){
15984 this.destroyTrans(this.trans);
15989 destroyTrans : function(trans, isLoaded){
15990 this.head.removeChild(document.getElementById(trans.scriptId));
15991 clearTimeout(trans.timeoutId);
15993 window[trans.cb] = undefined;
15995 delete window[trans.cb];
15998 // if hasn't been loaded, wait for load to remove it to prevent script error
15999 window[trans.cb] = function(){
16000 window[trans.cb] = undefined;
16002 delete window[trans.cb];
16009 handleResponse : function(o, trans){
16010 this.trans = false;
16011 this.destroyTrans(trans, true);
16014 result = trans.reader.readRecords(o);
16016 this.fireEvent("loadexception", this, o, trans.arg, e);
16017 trans.callback.call(trans.scope||window, null, trans.arg, false);
16020 this.fireEvent("load", this, o, trans.arg);
16021 trans.callback.call(trans.scope||window, result, trans.arg, true);
16025 handleFailure : function(trans){
16026 this.trans = false;
16027 this.destroyTrans(trans, false);
16028 this.fireEvent("loadexception", this, null, trans.arg);
16029 trans.callback.call(trans.scope||window, null, trans.arg, false);
16033 * Ext JS Library 1.1.1
16034 * Copyright(c) 2006-2007, Ext JS, LLC.
16036 * Originally Released Under LGPL - original licence link has changed is not relivant.
16039 * <script type="text/javascript">
16043 * @class Roo.data.JsonReader
16044 * @extends Roo.data.DataReader
16045 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
16046 * based on mappings in a provided Roo.data.Record constructor.
16048 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
16049 * in the reply previously.
16054 var RecordDef = Roo.data.Record.create([
16055 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
16056 {name: 'occupation'} // This field will use "occupation" as the mapping.
16058 var myReader = new Roo.data.JsonReader({
16059 totalProperty: "results", // The property which contains the total dataset size (optional)
16060 root: "rows", // The property which contains an Array of row objects
16061 id: "id" // The property within each row object that provides an ID for the record (optional)
16065 * This would consume a JSON file like this:
16067 { 'results': 2, 'rows': [
16068 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
16069 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
16072 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
16073 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
16074 * paged from the remote server.
16075 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
16076 * @cfg {String} root name of the property which contains the Array of row objects.
16077 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
16078 * @cfg {Array} fields Array of field definition objects
16080 * Create a new JsonReader
16081 * @param {Object} meta Metadata configuration options
16082 * @param {Object} recordType Either an Array of field definition objects,
16083 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
16085 Roo.data.JsonReader = function(meta, recordType){
16088 // set some defaults:
16089 Roo.applyIf(meta, {
16090 totalProperty: 'total',
16091 successProperty : 'success',
16096 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
16098 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
16100 readerType : 'Json',
16103 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
16104 * Used by Store query builder to append _requestMeta to params.
16107 metaFromRemote : false,
16109 * This method is only used by a DataProxy which has retrieved data from a remote server.
16110 * @param {Object} response The XHR object which contains the JSON data in its responseText.
16111 * @return {Object} data A data block which is used by an Roo.data.Store object as
16112 * a cache of Roo.data.Records.
16114 read : function(response){
16115 var json = response.responseText;
16117 var o = /* eval:var:o */ eval("("+json+")");
16119 throw {message: "JsonReader.read: Json object not found"};
16125 this.metaFromRemote = true;
16126 this.meta = o.metaData;
16127 this.recordType = Roo.data.Record.create(o.metaData.fields);
16128 this.onMetaChange(this.meta, this.recordType, o);
16130 return this.readRecords(o);
16133 // private function a store will implement
16134 onMetaChange : function(meta, recordType, o){
16141 simpleAccess: function(obj, subsc) {
16148 getJsonAccessor: function(){
16150 return function(expr) {
16152 return(re.test(expr))
16153 ? new Function("obj", "return obj." + expr)
16158 return Roo.emptyFn;
16163 * Create a data block containing Roo.data.Records from an XML document.
16164 * @param {Object} o An object which contains an Array of row objects in the property specified
16165 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
16166 * which contains the total size of the dataset.
16167 * @return {Object} data A data block which is used by an Roo.data.Store object as
16168 * a cache of Roo.data.Records.
16170 readRecords : function(o){
16172 * After any data loads, the raw JSON data is available for further custom processing.
16176 var s = this.meta, Record = this.recordType,
16177 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
16179 // Generate extraction functions for the totalProperty, the root, the id, and for each field
16181 if(s.totalProperty) {
16182 this.getTotal = this.getJsonAccessor(s.totalProperty);
16184 if(s.successProperty) {
16185 this.getSuccess = this.getJsonAccessor(s.successProperty);
16187 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
16189 var g = this.getJsonAccessor(s.id);
16190 this.getId = function(rec) {
16192 return (r === undefined || r === "") ? null : r;
16195 this.getId = function(){return null;};
16198 for(var jj = 0; jj < fl; jj++){
16200 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
16201 this.ef[jj] = this.getJsonAccessor(map);
16205 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
16206 if(s.totalProperty){
16207 var vt = parseInt(this.getTotal(o), 10);
16212 if(s.successProperty){
16213 var vs = this.getSuccess(o);
16214 if(vs === false || vs === 'false'){
16219 for(var i = 0; i < c; i++){
16222 var id = this.getId(n);
16223 for(var j = 0; j < fl; j++){
16225 var v = this.ef[j](n);
16227 Roo.log('missing convert for ' + f.name);
16231 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
16233 var record = new Record(values, id);
16235 records[i] = record;
16241 totalRecords : totalRecords
16244 // used when loading children.. @see loadDataFromChildren
16245 toLoadData: function(rec)
16247 // expect rec just to be an array.. eg [a,b,c, [...] << cn ]
16248 var data = typeof(rec.data.cn) == 'undefined' ? [] : rec.data.cn;
16249 return { data : data, total : data.length };
16254 * Ext JS Library 1.1.1
16255 * Copyright(c) 2006-2007, Ext JS, LLC.
16257 * Originally Released Under LGPL - original licence link has changed is not relivant.
16260 * <script type="text/javascript">
16264 * @class Roo.data.ArrayReader
16265 * @extends Roo.data.DataReader
16266 * Data reader class to create an Array of Roo.data.Record objects from an Array.
16267 * Each element of that Array represents a row of data fields. The
16268 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
16269 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
16273 var RecordDef = Roo.data.Record.create([
16274 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
16275 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
16277 var myReader = new Roo.data.ArrayReader({
16278 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
16282 * This would consume an Array like this:
16284 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
16288 * Create a new JsonReader
16289 * @param {Object} meta Metadata configuration options.
16290 * @param {Object|Array} recordType Either an Array of field definition objects
16292 * @cfg {Array} fields Array of field definition objects
16293 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
16294 * as specified to {@link Roo.data.Record#create},
16295 * or an {@link Roo.data.Record} object
16298 * created using {@link Roo.data.Record#create}.
16300 Roo.data.ArrayReader = function(meta, recordType)
16302 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType||meta.fields);
16305 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
16308 * Create a data block containing Roo.data.Records from an XML document.
16309 * @param {Object} o An Array of row objects which represents the dataset.
16310 * @return {Object} A data block which is used by an {@link Roo.data.Store} object as
16311 * a cache of Roo.data.Records.
16313 readRecords : function(o)
16315 var sid = this.meta ? this.meta.id : null;
16316 var recordType = this.recordType, fields = recordType.prototype.fields;
16319 for(var i = 0; i < root.length; i++){
16322 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
16323 for(var j = 0, jlen = fields.length; j < jlen; j++){
16324 var f = fields.items[j];
16325 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
16326 var v = n[k] !== undefined ? n[k] : f.defaultValue;
16328 values[f.name] = v;
16330 var record = new recordType(values, id);
16332 records[records.length] = record;
16336 totalRecords : records.length
16339 // used when loading children.. @see loadDataFromChildren
16340 toLoadData: function(rec)
16342 // expect rec just to be an array.. eg [a,b,c, [...] << cn ]
16343 return typeof(rec.data.cn) == 'undefined' ? [] : rec.data.cn;
16354 * @class Roo.bootstrap.ComboBox
16355 * @extends Roo.bootstrap.TriggerField
16356 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
16357 * @cfg {Boolean} append (true|false) default false
16358 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
16359 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
16360 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
16361 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
16362 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
16363 * @cfg {Boolean} animate default true
16364 * @cfg {Boolean} emptyResultText only for touch device
16365 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
16366 * @cfg {String} emptyTitle default ''
16367 * @cfg {Number} width fixed with? experimental
16369 * Create a new ComboBox.
16370 * @param {Object} config Configuration options
16372 Roo.bootstrap.ComboBox = function(config){
16373 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
16377 * Fires when the dropdown list is expanded
16378 * @param {Roo.bootstrap.ComboBox} combo This combo box
16383 * Fires when the dropdown list is collapsed
16384 * @param {Roo.bootstrap.ComboBox} combo This combo box
16388 * @event beforeselect
16389 * Fires before a list item is selected. Return false to cancel the selection.
16390 * @param {Roo.bootstrap.ComboBox} combo This combo box
16391 * @param {Roo.data.Record} record The data record returned from the underlying store
16392 * @param {Number} index The index of the selected item in the dropdown list
16394 'beforeselect' : true,
16397 * Fires when a list item is selected
16398 * @param {Roo.bootstrap.ComboBox} combo This combo box
16399 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
16400 * @param {Number} index The index of the selected item in the dropdown list
16404 * @event beforequery
16405 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
16406 * The event object passed has these properties:
16407 * @param {Roo.bootstrap.ComboBox} combo This combo box
16408 * @param {String} query The query
16409 * @param {Boolean} forceAll true to force "all" query
16410 * @param {Boolean} cancel true to cancel the query
16411 * @param {Object} e The query event object
16413 'beforequery': true,
16416 * Fires when the 'add' icon is pressed (add a listener to enable add button)
16417 * @param {Roo.bootstrap.ComboBox} combo This combo box
16422 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
16423 * @param {Roo.bootstrap.ComboBox} combo This combo box
16424 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
16429 * Fires when the remove value from the combobox array
16430 * @param {Roo.bootstrap.ComboBox} combo This combo box
16434 * @event afterremove
16435 * Fires when the remove value from the combobox array
16436 * @param {Roo.bootstrap.ComboBox} combo This combo box
16438 'afterremove' : true,
16440 * @event specialfilter
16441 * Fires when specialfilter
16442 * @param {Roo.bootstrap.ComboBox} combo This combo box
16444 'specialfilter' : true,
16447 * Fires when tick the element
16448 * @param {Roo.bootstrap.ComboBox} combo This combo box
16452 * @event touchviewdisplay
16453 * Fires when touch view require special display (default is using displayField)
16454 * @param {Roo.bootstrap.ComboBox} combo This combo box
16455 * @param {Object} cfg set html .
16457 'touchviewdisplay' : true
16462 this.tickItems = [];
16464 this.selectedIndex = -1;
16465 if(this.mode == 'local'){
16466 if(config.queryDelay === undefined){
16467 this.queryDelay = 10;
16469 if(config.minChars === undefined){
16475 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
16478 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
16479 * rendering into an Roo.Editor, defaults to false)
16482 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
16483 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
16486 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
16489 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
16490 * the dropdown list (defaults to undefined, with no header element)
16494 * @cfg {String/Roo.Template} tpl The template to use to render the output default is '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>'
16498 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
16500 listWidth: undefined,
16502 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
16503 * mode = 'remote' or 'text' if mode = 'local')
16505 displayField: undefined,
16508 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
16509 * mode = 'remote' or 'value' if mode = 'local').
16510 * Note: use of a valueField requires the user make a selection
16511 * in order for a value to be mapped.
16513 valueField: undefined,
16515 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
16520 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
16521 * field's data value (defaults to the underlying DOM element's name)
16523 hiddenName: undefined,
16525 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
16529 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
16531 selectedClass: 'active',
16534 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
16538 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
16539 * anchor positions (defaults to 'tl-bl')
16541 listAlign: 'tl-bl?',
16543 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
16547 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
16548 * query specified by the allQuery config option (defaults to 'query')
16550 triggerAction: 'query',
16552 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
16553 * (defaults to 4, does not apply if editable = false)
16557 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
16558 * delay (typeAheadDelay) if it matches a known value (defaults to false)
16562 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
16563 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
16567 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
16568 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
16572 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
16573 * when editable = true (defaults to false)
16575 selectOnFocus:false,
16577 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
16579 queryParam: 'query',
16581 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
16582 * when mode = 'remote' (defaults to 'Loading...')
16584 loadingText: 'Loading...',
16586 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
16590 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
16594 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
16595 * traditional select (defaults to true)
16599 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
16603 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
16607 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
16608 * listWidth has a higher value)
16612 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
16613 * allow the user to set arbitrary text into the field (defaults to false)
16615 forceSelection:false,
16617 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
16618 * if typeAhead = true (defaults to 250)
16620 typeAheadDelay : 250,
16622 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
16623 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
16625 valueNotFoundText : undefined,
16627 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
16629 blockFocus : false,
16632 * @cfg {Boolean} disableClear Disable showing of clear button.
16634 disableClear : false,
16636 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
16638 alwaysQuery : false,
16641 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
16646 * @cfg {String} invalidClass DEPRICATED - uses BS4 is-valid now
16648 invalidClass : "has-warning",
16651 * @cfg {String} validClass DEPRICATED - uses BS4 is-valid now
16653 validClass : "has-success",
16656 * @cfg {Boolean} specialFilter (true|false) special filter default false
16658 specialFilter : false,
16661 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
16663 mobileTouchView : true,
16666 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
16668 useNativeIOS : false,
16671 * @cfg {Boolean} mobile_restrict_height (true|false) restrict height for touch view
16673 mobile_restrict_height : false,
16675 ios_options : false,
16687 btnPosition : 'right',
16688 triggerList : true,
16689 showToggleBtn : true,
16691 emptyResultText: 'Empty',
16692 triggerText : 'Select',
16696 // element that contains real text value.. (when hidden is used..)
16698 getAutoCreate : function()
16703 * Render classic select for iso
16706 if(Roo.isIOS && this.useNativeIOS){
16707 cfg = this.getAutoCreateNativeIOS();
16715 if(Roo.isTouch && this.mobileTouchView){
16716 cfg = this.getAutoCreateTouchView();
16723 if(!this.tickable){
16724 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
16729 * ComboBox with tickable selections
16732 var align = this.labelAlign || this.parentLabelAlign();
16735 cls : 'form-group roo-combobox-tickable' //input-group
16738 var btn_text_select = '';
16739 var btn_text_done = '';
16740 var btn_text_cancel = '';
16742 if (this.btn_text_show) {
16743 btn_text_select = 'Select';
16744 btn_text_done = 'Done';
16745 btn_text_cancel = 'Cancel';
16750 cls : 'tickable-buttons',
16755 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
16756 //html : this.triggerText
16757 html: btn_text_select
16763 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
16765 html: btn_text_done
16771 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
16773 html: btn_text_cancel
16779 buttons.cn.unshift({
16781 cls: 'roo-select2-search-field-input'
16787 Roo.each(buttons.cn, function(c){
16789 c.cls += ' btn-' + _this.size;
16792 if (_this.disabled) {
16799 style : 'display: contents',
16804 cls: 'form-hidden-field'
16808 cls: 'roo-select2-choices',
16812 cls: 'roo-select2-search-field',
16823 cls: 'roo-select2-container input-group roo-select2-container-multi',
16829 // cls: 'typeahead typeahead-long dropdown-menu',
16830 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
16835 if(this.hasFeedback && !this.allowBlank){
16839 cls: 'glyphicon form-control-feedback'
16842 combobox.cn.push(feedback);
16849 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
16850 tooltip : 'This field is required'
16852 if (Roo.bootstrap.version == 4) {
16855 style : 'display:none'
16858 if (align ==='left' && this.fieldLabel.length) {
16860 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
16867 cls : 'control-label col-form-label',
16868 html : this.fieldLabel
16880 var labelCfg = cfg.cn[1];
16881 var contentCfg = cfg.cn[2];
16884 if(this.indicatorpos == 'right'){
16890 cls : 'control-label col-form-label',
16894 html : this.fieldLabel
16910 labelCfg = cfg.cn[0];
16911 contentCfg = cfg.cn[1];
16915 if(this.labelWidth > 12){
16916 labelCfg.style = "width: " + this.labelWidth + 'px';
16918 if(this.width * 1 > 0){
16919 contentCfg.style = "width: " + this.width + 'px';
16921 if(this.labelWidth < 13 && this.labelmd == 0){
16922 this.labelmd = this.labelWidth;
16925 if(this.labellg > 0){
16926 labelCfg.cls += ' col-lg-' + this.labellg;
16927 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
16930 if(this.labelmd > 0){
16931 labelCfg.cls += ' col-md-' + this.labelmd;
16932 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
16935 if(this.labelsm > 0){
16936 labelCfg.cls += ' col-sm-' + this.labelsm;
16937 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
16940 if(this.labelxs > 0){
16941 labelCfg.cls += ' col-xs-' + this.labelxs;
16942 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
16946 } else if ( this.fieldLabel.length) {
16947 // Roo.log(" label");
16952 //cls : 'input-group-addon',
16953 html : this.fieldLabel
16958 if(this.indicatorpos == 'right'){
16962 //cls : 'input-group-addon',
16963 html : this.fieldLabel
16973 // Roo.log(" no label && no align");
16980 ['xs','sm','md','lg'].map(function(size){
16981 if (settings[size]) {
16982 cfg.cls += ' col-' + size + '-' + settings[size];
16990 _initEventsCalled : false,
16993 initEvents: function()
16995 if (this._initEventsCalled) { // as we call render... prevent looping...
16998 this._initEventsCalled = true;
17001 throw "can not find store for combo";
17004 this.indicator = this.indicatorEl();
17006 this.store = Roo.factory(this.store, Roo.data);
17007 this.store.parent = this;
17009 // if we are building from html. then this element is so complex, that we can not really
17010 // use the rendered HTML.
17011 // so we have to trash and replace the previous code.
17012 if (Roo.XComponent.build_from_html) {
17013 // remove this element....
17014 var e = this.el.dom, k=0;
17015 while (e ) { e = e.previousSibling; ++k;}
17020 this.rendered = false;
17022 this.render(this.parent().getChildContainer(true), k);
17025 if(Roo.isIOS && this.useNativeIOS){
17026 this.initIOSView();
17034 if(Roo.isTouch && this.mobileTouchView){
17035 this.initTouchView();
17040 this.initTickableEvents();
17044 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
17046 if(this.hiddenName){
17048 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
17050 this.hiddenField.dom.value =
17051 this.hiddenValue !== undefined ? this.hiddenValue :
17052 this.value !== undefined ? this.value : '';
17054 // prevent input submission
17055 this.el.dom.removeAttribute('name');
17056 this.hiddenField.dom.setAttribute('name', this.hiddenName);
17061 // this.el.dom.setAttribute('autocomplete', 'off');
17064 var cls = 'x-combo-list';
17066 //this.list = new Roo.Layer({
17067 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
17073 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
17074 _this.list.setWidth(lw);
17077 this.list.on('mouseover', this.onViewOver, this);
17078 this.list.on('mousemove', this.onViewMove, this);
17079 this.list.on('scroll', this.onViewScroll, this);
17082 this.list.swallowEvent('mousewheel');
17083 this.assetHeight = 0;
17086 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
17087 this.assetHeight += this.header.getHeight();
17090 this.innerList = this.list.createChild({cls:cls+'-inner'});
17091 this.innerList.on('mouseover', this.onViewOver, this);
17092 this.innerList.on('mousemove', this.onViewMove, this);
17093 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
17095 if(this.allowBlank && !this.pageSize && !this.disableClear){
17096 this.footer = this.list.createChild({cls:cls+'-ft'});
17097 this.pageTb = new Roo.Toolbar(this.footer);
17101 this.footer = this.list.createChild({cls:cls+'-ft'});
17102 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
17103 {pageSize: this.pageSize});
17107 if (this.pageTb && this.allowBlank && !this.disableClear) {
17109 this.pageTb.add(new Roo.Toolbar.Fill(), {
17110 cls: 'x-btn-icon x-btn-clear',
17112 handler: function()
17115 _this.clearValue();
17116 _this.onSelect(false, -1);
17121 this.assetHeight += this.footer.getHeight();
17126 this.tpl = Roo.bootstrap.version == 4 ?
17127 '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>' : // 4 does not need <li> and it get's really confisued.
17128 '<li><a class="dropdown-item" href="#">{' + this.displayField + '}</a></li>';
17131 this.view = new Roo.View(this.list, this.tpl, {
17132 singleSelect:true, store: this.store, selectedClass: this.selectedClass
17134 //this.view.wrapEl.setDisplayed(false);
17135 this.view.on('click', this.onViewClick, this);
17138 this.store.on('beforeload', this.onBeforeLoad, this);
17139 this.store.on('load', this.onLoad, this);
17140 this.store.on('loadexception', this.onLoadException, this);
17142 if(this.resizable){
17143 this.resizer = new Roo.Resizable(this.list, {
17144 pinned:true, handles:'se'
17146 this.resizer.on('resize', function(r, w, h){
17147 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
17148 this.listWidth = w;
17149 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
17150 this.restrictHeight();
17152 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
17155 if(!this.editable){
17156 this.editable = true;
17157 this.setEditable(false);
17162 if (typeof(this.events.add.listeners) != 'undefined') {
17164 this.addicon = this.wrap.createChild(
17165 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
17167 this.addicon.on('click', function(e) {
17168 this.fireEvent('add', this);
17171 if (typeof(this.events.edit.listeners) != 'undefined') {
17173 this.editicon = this.wrap.createChild(
17174 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
17175 if (this.addicon) {
17176 this.editicon.setStyle('margin-left', '40px');
17178 this.editicon.on('click', function(e) {
17180 // we fire even if inothing is selected..
17181 this.fireEvent('edit', this, this.lastData );
17187 this.keyNav = new Roo.KeyNav(this.inputEl(), {
17188 "up" : function(e){
17189 this.inKeyMode = true;
17193 "down" : function(e){
17194 if(!this.isExpanded()){
17195 this.onTriggerClick();
17197 this.inKeyMode = true;
17202 "enter" : function(e){
17203 // this.onViewClick();
17207 if(this.fireEvent("specialkey", this, e)){
17208 this.onViewClick(false);
17214 "esc" : function(e){
17218 "tab" : function(e){
17221 if(this.fireEvent("specialkey", this, e)){
17222 this.onViewClick(false);
17230 doRelay : function(foo, bar, hname){
17231 if(hname == 'down' || this.scope.isExpanded()){
17232 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
17241 this.queryDelay = Math.max(this.queryDelay || 10,
17242 this.mode == 'local' ? 10 : 250);
17245 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
17247 if(this.typeAhead){
17248 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
17250 if(this.editable !== false){
17251 this.inputEl().on("keyup", this.onKeyUp, this);
17253 if(this.forceSelection){
17254 this.inputEl().on('blur', this.doForce, this);
17258 this.choices = this.el.select('ul.roo-select2-choices', true).first();
17259 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
17263 initTickableEvents: function()
17267 if(this.hiddenName){
17269 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
17271 this.hiddenField.dom.value =
17272 this.hiddenValue !== undefined ? this.hiddenValue :
17273 this.value !== undefined ? this.value : '';
17275 // prevent input submission
17276 this.el.dom.removeAttribute('name');
17277 this.hiddenField.dom.setAttribute('name', this.hiddenName);
17282 // this.list = this.el.select('ul.dropdown-menu',true).first();
17284 this.choices = this.el.select('ul.roo-select2-choices', true).first();
17285 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
17286 if(this.triggerList){
17287 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
17290 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
17291 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
17293 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
17294 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
17296 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
17297 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
17299 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
17300 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
17301 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
17304 this.cancelBtn.hide();
17309 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
17310 _this.list.setWidth(lw);
17313 this.list.on('mouseover', this.onViewOver, this);
17314 this.list.on('mousemove', this.onViewMove, this);
17316 this.list.on('scroll', this.onViewScroll, this);
17319 this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}"' +
17320 'type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
17323 this.view = new Roo.View(this.list, this.tpl, {
17328 selectedClass: this.selectedClass
17331 //this.view.wrapEl.setDisplayed(false);
17332 this.view.on('click', this.onViewClick, this);
17336 this.store.on('beforeload', this.onBeforeLoad, this);
17337 this.store.on('load', this.onLoad, this);
17338 this.store.on('loadexception', this.onLoadException, this);
17341 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
17342 "up" : function(e){
17343 this.inKeyMode = true;
17347 "down" : function(e){
17348 this.inKeyMode = true;
17352 "enter" : function(e){
17353 if(this.fireEvent("specialkey", this, e)){
17354 this.onViewClick(false);
17360 "esc" : function(e){
17361 this.onTickableFooterButtonClick(e, false, false);
17364 "tab" : function(e){
17365 this.fireEvent("specialkey", this, e);
17367 this.onTickableFooterButtonClick(e, false, false);
17374 doRelay : function(e, fn, key){
17375 if(this.scope.isExpanded()){
17376 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
17385 this.queryDelay = Math.max(this.queryDelay || 10,
17386 this.mode == 'local' ? 10 : 250);
17389 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
17391 if(this.typeAhead){
17392 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
17395 if(this.editable !== false){
17396 this.tickableInputEl().on("keyup", this.onKeyUp, this);
17399 this.indicator = this.indicatorEl();
17401 if(this.indicator){
17402 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
17403 this.indicator.hide();
17408 onDestroy : function(){
17410 this.view.setStore(null);
17411 this.view.el.removeAllListeners();
17412 this.view.el.remove();
17413 this.view.purgeListeners();
17416 this.list.dom.innerHTML = '';
17420 this.store.un('beforeload', this.onBeforeLoad, this);
17421 this.store.un('load', this.onLoad, this);
17422 this.store.un('loadexception', this.onLoadException, this);
17424 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
17428 fireKey : function(e){
17429 if(e.isNavKeyPress() && !this.list.isVisible()){
17430 this.fireEvent("specialkey", this, e);
17435 onResize: function(w, h)
17439 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
17441 // if(typeof w != 'number'){
17442 // // we do not handle it!?!?
17445 // var tw = this.trigger.getWidth();
17446 // // tw += this.addicon ? this.addicon.getWidth() : 0;
17447 // // tw += this.editicon ? this.editicon.getWidth() : 0;
17449 // this.inputEl().setWidth( this.adjustWidth('input', x));
17451 // //this.trigger.setStyle('left', x+'px');
17453 // if(this.list && this.listWidth === undefined){
17454 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
17455 // this.list.setWidth(lw);
17456 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
17464 * Allow or prevent the user from directly editing the field text. If false is passed,
17465 * the user will only be able to select from the items defined in the dropdown list. This method
17466 * is the runtime equivalent of setting the 'editable' config option at config time.
17467 * @param {Boolean} value True to allow the user to directly edit the field text
17469 setEditable : function(value){
17470 if(value == this.editable){
17473 this.editable = value;
17475 this.inputEl().dom.setAttribute('readOnly', true);
17476 this.inputEl().on('mousedown', this.onTriggerClick, this);
17477 this.inputEl().addClass('x-combo-noedit');
17479 this.inputEl().dom.removeAttribute('readOnly');
17480 this.inputEl().un('mousedown', this.onTriggerClick, this);
17481 this.inputEl().removeClass('x-combo-noedit');
17487 onBeforeLoad : function(combo,opts){
17488 if(!this.hasFocus){
17492 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
17494 this.restrictHeight();
17495 this.selectedIndex = -1;
17499 onLoad : function(){
17501 this.hasQuery = false;
17503 if(!this.hasFocus){
17507 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
17508 this.loading.hide();
17511 if(this.store.getCount() > 0){
17514 this.restrictHeight();
17515 if(this.lastQuery == this.allQuery){
17516 if(this.editable && !this.tickable){
17517 this.inputEl().dom.select();
17521 !this.selectByValue(this.value, true) &&
17524 !this.store.lastOptions ||
17525 typeof(this.store.lastOptions.add) == 'undefined' ||
17526 this.store.lastOptions.add != true
17529 this.select(0, true);
17532 if(this.autoFocus){
17535 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
17536 this.taTask.delay(this.typeAheadDelay);
17540 this.onEmptyResults();
17546 onLoadException : function()
17548 this.hasQuery = false;
17550 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
17551 this.loading.hide();
17554 if(this.tickable && this.editable){
17559 // only causes errors at present
17560 //Roo.log(this.store.reader.jsonData);
17561 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
17563 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
17569 onTypeAhead : function(){
17570 if(this.store.getCount() > 0){
17571 var r = this.store.getAt(0);
17572 var newValue = r.data[this.displayField];
17573 var len = newValue.length;
17574 var selStart = this.getRawValue().length;
17576 if(selStart != len){
17577 this.setRawValue(newValue);
17578 this.selectText(selStart, newValue.length);
17584 onSelect : function(record, index){
17586 if(this.fireEvent('beforeselect', this, record, index) !== false){
17588 this.setFromData(index > -1 ? record.data : false);
17591 this.fireEvent('select', this, record, index);
17596 * Returns the currently selected field value or empty string if no value is set.
17597 * @return {String} value The selected value
17599 getValue : function()
17601 if(Roo.isIOS && this.useNativeIOS){
17602 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
17606 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
17609 if(this.valueField){
17610 return typeof this.value != 'undefined' ? this.value : '';
17612 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
17616 getRawValue : function()
17618 if(Roo.isIOS && this.useNativeIOS){
17619 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
17622 var v = this.inputEl().getValue();
17628 * Clears any text/value currently set in the field
17630 clearValue : function(){
17632 if(this.hiddenField){
17633 this.hiddenField.dom.value = '';
17636 this.setRawValue('');
17637 this.lastSelectionText = '';
17638 this.lastData = false;
17640 var close = this.closeTriggerEl();
17651 * Sets the specified value into the field. If the value finds a match, the corresponding record text
17652 * will be displayed in the field. If the value does not match the data value of an existing item,
17653 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
17654 * Otherwise the field will be blank (although the value will still be set).
17655 * @param {String} value The value to match
17657 setValue : function(v)
17659 if(Roo.isIOS && this.useNativeIOS){
17660 this.setIOSValue(v);
17670 if(this.valueField){
17671 var r = this.findRecord(this.valueField, v);
17673 text = r.data[this.displayField];
17674 }else if(this.valueNotFoundText !== undefined){
17675 text = this.valueNotFoundText;
17678 this.lastSelectionText = text;
17679 if(this.hiddenField){
17680 this.hiddenField.dom.value = v;
17682 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
17685 var close = this.closeTriggerEl();
17688 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
17694 * @property {Object} the last set data for the element
17699 * Sets the value of the field based on a object which is related to the record format for the store.
17700 * @param {Object} value the value to set as. or false on reset?
17702 setFromData : function(o){
17709 var dv = ''; // display value
17710 var vv = ''; // value value..
17712 if (this.displayField) {
17713 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
17715 // this is an error condition!!!
17716 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
17719 if(this.valueField){
17720 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
17723 var close = this.closeTriggerEl();
17726 if(dv.length || vv * 1 > 0){
17728 this.blockFocus=true;
17734 if(this.hiddenField){
17735 this.hiddenField.dom.value = vv;
17737 this.lastSelectionText = dv;
17738 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
17742 // no hidden field.. - we store the value in 'value', but still display
17743 // display field!!!!
17744 this.lastSelectionText = dv;
17745 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
17752 reset : function(){
17753 // overridden so that last data is reset..
17760 this.setValue(this.originalValue);
17761 //this.clearInvalid();
17762 this.lastData = false;
17764 this.view.clearSelections();
17770 findRecord : function(prop, value){
17772 if(this.store.getCount() > 0){
17773 this.store.each(function(r){
17774 if(r.data[prop] == value){
17784 getName: function()
17786 // returns hidden if it's set..
17787 if (!this.rendered) {return ''};
17788 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
17792 onViewMove : function(e, t){
17793 this.inKeyMode = false;
17797 onViewOver : function(e, t){
17798 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
17801 var item = this.view.findItemFromChild(t);
17804 var index = this.view.indexOf(item);
17805 this.select(index, false);
17810 onViewClick : function(view, doFocus, el, e)
17812 var index = this.view.getSelectedIndexes()[0];
17814 var r = this.store.getAt(index);
17818 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
17825 Roo.each(this.tickItems, function(v,k){
17827 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
17829 _this.tickItems.splice(k, 1);
17831 if(typeof(e) == 'undefined' && view == false){
17832 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
17844 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
17845 this.tickItems.push(r.data);
17848 if(typeof(e) == 'undefined' && view == false){
17849 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
17856 this.onSelect(r, index);
17858 if(doFocus !== false && !this.blockFocus){
17859 this.inputEl().focus();
17864 restrictHeight : function(){
17865 //this.innerList.dom.style.height = '';
17866 //var inner = this.innerList.dom;
17867 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
17868 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
17869 //this.list.beginUpdate();
17870 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
17871 this.list.alignTo(this.inputEl(), this.listAlign);
17872 this.list.alignTo(this.inputEl(), this.listAlign);
17873 //this.list.endUpdate();
17877 onEmptyResults : function(){
17879 if(this.tickable && this.editable){
17880 this.hasFocus = false;
17881 this.restrictHeight();
17889 * Returns true if the dropdown list is expanded, else false.
17891 isExpanded : function(){
17892 return this.list.isVisible();
17896 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
17897 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
17898 * @param {String} value The data value of the item to select
17899 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
17900 * selected item if it is not currently in view (defaults to true)
17901 * @return {Boolean} True if the value matched an item in the list, else false
17903 selectByValue : function(v, scrollIntoView){
17904 if(v !== undefined && v !== null){
17905 var r = this.findRecord(this.valueField || this.displayField, v);
17907 this.select(this.store.indexOf(r), scrollIntoView);
17915 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
17916 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
17917 * @param {Number} index The zero-based index of the list item to select
17918 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
17919 * selected item if it is not currently in view (defaults to true)
17921 select : function(index, scrollIntoView){
17922 this.selectedIndex = index;
17923 this.view.select(index);
17924 if(scrollIntoView !== false){
17925 var el = this.view.getNode(index);
17927 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
17930 this.list.scrollChildIntoView(el, false);
17936 selectNext : function(){
17937 var ct = this.store.getCount();
17939 if(this.selectedIndex == -1){
17941 }else if(this.selectedIndex < ct-1){
17942 this.select(this.selectedIndex+1);
17948 selectPrev : function(){
17949 var ct = this.store.getCount();
17951 if(this.selectedIndex == -1){
17953 }else if(this.selectedIndex != 0){
17954 this.select(this.selectedIndex-1);
17960 onKeyUp : function(e){
17961 if(this.editable !== false && !e.isSpecialKey()){
17962 this.lastKey = e.getKey();
17963 this.dqTask.delay(this.queryDelay);
17968 validateBlur : function(){
17969 return !this.list || !this.list.isVisible();
17973 initQuery : function(){
17975 var v = this.getRawValue();
17977 if(this.tickable && this.editable){
17978 v = this.tickableInputEl().getValue();
17985 doForce : function(){
17986 if(this.inputEl().dom.value.length > 0){
17987 this.inputEl().dom.value =
17988 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
17994 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
17995 * query allowing the query action to be canceled if needed.
17996 * @param {String} query The SQL query to execute
17997 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
17998 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
17999 * saved in the current store (defaults to false)
18001 doQuery : function(q, forceAll){
18003 if(q === undefined || q === null){
18008 forceAll: forceAll,
18012 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
18017 forceAll = qe.forceAll;
18018 if(forceAll === true || (q.length >= this.minChars)){
18020 this.hasQuery = true;
18022 if(this.lastQuery != q || this.alwaysQuery){
18023 this.lastQuery = q;
18024 if(this.mode == 'local'){
18025 this.selectedIndex = -1;
18027 this.store.clearFilter();
18030 if(this.specialFilter){
18031 this.fireEvent('specialfilter', this);
18036 this.store.filter(this.displayField, q);
18039 this.store.fireEvent("datachanged", this.store);
18046 this.store.baseParams[this.queryParam] = q;
18048 var options = {params : this.getParams(q)};
18051 options.add = true;
18052 options.params.start = this.page * this.pageSize;
18055 this.store.load(options);
18058 * this code will make the page width larger, at the beginning, the list not align correctly,
18059 * we should expand the list on onLoad
18060 * so command out it
18065 this.selectedIndex = -1;
18070 this.loadNext = false;
18074 getParams : function(q){
18076 //p[this.queryParam] = q;
18080 p.limit = this.pageSize;
18086 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
18088 collapse : function(){
18089 if(!this.isExpanded()){
18095 this.hasFocus = false;
18099 this.cancelBtn.hide();
18100 this.trigger.show();
18103 this.tickableInputEl().dom.value = '';
18104 this.tickableInputEl().blur();
18109 Roo.get(document).un('mousedown', this.collapseIf, this);
18110 Roo.get(document).un('mousewheel', this.collapseIf, this);
18111 if (!this.editable) {
18112 Roo.get(document).un('keydown', this.listKeyPress, this);
18114 this.fireEvent('collapse', this);
18120 collapseIf : function(e){
18121 var in_combo = e.within(this.el);
18122 var in_list = e.within(this.list);
18123 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
18125 if (in_combo || in_list || is_list) {
18126 //e.stopPropagation();
18131 this.onTickableFooterButtonClick(e, false, false);
18139 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
18141 expand : function(){
18143 if(this.isExpanded() || !this.hasFocus){
18147 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
18148 this.list.setWidth(lw);
18154 this.restrictHeight();
18158 this.tickItems = Roo.apply([], this.item);
18161 this.cancelBtn.show();
18162 this.trigger.hide();
18165 this.tickableInputEl().focus();
18170 Roo.get(document).on('mousedown', this.collapseIf, this);
18171 Roo.get(document).on('mousewheel', this.collapseIf, this);
18172 if (!this.editable) {
18173 Roo.get(document).on('keydown', this.listKeyPress, this);
18176 this.fireEvent('expand', this);
18180 // Implements the default empty TriggerField.onTriggerClick function
18181 onTriggerClick : function(e)
18183 Roo.log('trigger click');
18185 if(this.disabled || !this.triggerList){
18190 this.loadNext = false;
18192 if(this.isExpanded()){
18194 if (!this.blockFocus) {
18195 this.inputEl().focus();
18199 this.hasFocus = true;
18200 if(this.triggerAction == 'all') {
18201 this.doQuery(this.allQuery, true);
18203 this.doQuery(this.getRawValue());
18205 if (!this.blockFocus) {
18206 this.inputEl().focus();
18211 onTickableTriggerClick : function(e)
18218 this.loadNext = false;
18219 this.hasFocus = true;
18221 if(this.triggerAction == 'all') {
18222 this.doQuery(this.allQuery, true);
18224 this.doQuery(this.getRawValue());
18228 onSearchFieldClick : function(e)
18230 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
18231 this.onTickableFooterButtonClick(e, false, false);
18235 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
18240 this.loadNext = false;
18241 this.hasFocus = true;
18243 if(this.triggerAction == 'all') {
18244 this.doQuery(this.allQuery, true);
18246 this.doQuery(this.getRawValue());
18250 listKeyPress : function(e)
18252 //Roo.log('listkeypress');
18253 // scroll to first matching element based on key pres..
18254 if (e.isSpecialKey()) {
18257 var k = String.fromCharCode(e.getKey()).toUpperCase();
18260 var csel = this.view.getSelectedNodes();
18261 var cselitem = false;
18263 var ix = this.view.indexOf(csel[0]);
18264 cselitem = this.store.getAt(ix);
18265 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
18271 this.store.each(function(v) {
18273 // start at existing selection.
18274 if (cselitem.id == v.id) {
18280 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
18281 match = this.store.indexOf(v);
18287 if (match === false) {
18288 return true; // no more action?
18291 this.view.select(match);
18292 var sn = Roo.get(this.view.getSelectedNodes()[0]);
18293 sn.scrollIntoView(sn.dom.parentNode, false);
18296 onViewScroll : function(e, t){
18298 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){
18302 this.hasQuery = true;
18304 this.loading = this.list.select('.loading', true).first();
18306 if(this.loading === null){
18307 this.list.createChild({
18309 cls: 'loading roo-select2-more-results roo-select2-active',
18310 html: 'Loading more results...'
18313 this.loading = this.list.select('.loading', true).first();
18315 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
18317 this.loading.hide();
18320 this.loading.show();
18325 this.loadNext = true;
18327 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
18332 addItem : function(o)
18334 var dv = ''; // display value
18336 if (this.displayField) {
18337 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
18339 // this is an error condition!!!
18340 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
18347 var choice = this.choices.createChild({
18349 cls: 'roo-select2-search-choice',
18358 cls: 'roo-select2-search-choice-close fa fa-times',
18363 }, this.searchField);
18365 var close = choice.select('a.roo-select2-search-choice-close', true).first();
18367 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
18375 this.inputEl().dom.value = '';
18380 onRemoveItem : function(e, _self, o)
18382 e.preventDefault();
18384 this.lastItem = Roo.apply([], this.item);
18386 var index = this.item.indexOf(o.data) * 1;
18389 Roo.log('not this item?!');
18393 this.item.splice(index, 1);
18398 this.fireEvent('remove', this, e);
18404 syncValue : function()
18406 if(!this.item.length){
18413 Roo.each(this.item, function(i){
18414 if(_this.valueField){
18415 value.push(i[_this.valueField]);
18422 this.value = value.join(',');
18424 if(this.hiddenField){
18425 this.hiddenField.dom.value = this.value;
18428 this.store.fireEvent("datachanged", this.store);
18433 clearItem : function()
18435 if(!this.multiple){
18441 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
18449 if(this.tickable && !Roo.isTouch){
18450 this.view.refresh();
18454 inputEl: function ()
18456 if(Roo.isIOS && this.useNativeIOS){
18457 return this.el.select('select.roo-ios-select', true).first();
18460 if(Roo.isTouch && this.mobileTouchView){
18461 return this.el.select('input.form-control',true).first();
18465 return this.searchField;
18468 return this.el.select('input.form-control',true).first();
18471 onTickableFooterButtonClick : function(e, btn, el)
18473 e.preventDefault();
18475 this.lastItem = Roo.apply([], this.item);
18477 if(btn && btn.name == 'cancel'){
18478 this.tickItems = Roo.apply([], this.item);
18487 Roo.each(this.tickItems, function(o){
18495 validate : function()
18497 if(this.getVisibilityEl().hasClass('hidden')){
18501 var v = this.getRawValue();
18504 v = this.getValue();
18507 if(this.disabled || this.allowBlank || v.length){
18512 this.markInvalid();
18516 tickableInputEl : function()
18518 if(!this.tickable || !this.editable){
18519 return this.inputEl();
18522 return this.inputEl().select('.roo-select2-search-field-input', true).first();
18526 getAutoCreateTouchView : function()
18531 cls: 'form-group' //input-group
18537 type : this.inputType,
18538 cls : 'form-control x-combo-noedit',
18539 autocomplete: 'new-password',
18540 placeholder : this.placeholder || '',
18545 input.name = this.name;
18549 input.cls += ' input-' + this.size;
18552 if (this.disabled) {
18553 input.disabled = true;
18557 cls : 'roo-combobox-wrap',
18564 inputblock.cls += ' input-group';
18566 inputblock.cn.unshift({
18568 cls : 'input-group-addon input-group-prepend input-group-text',
18573 if(this.removable && !this.multiple){
18574 inputblock.cls += ' roo-removable';
18576 inputblock.cn.push({
18579 cls : 'roo-combo-removable-btn close'
18583 if(this.hasFeedback && !this.allowBlank){
18585 inputblock.cls += ' has-feedback';
18587 inputblock.cn.push({
18589 cls: 'glyphicon form-control-feedback'
18596 inputblock.cls += (this.before) ? '' : ' input-group';
18598 inputblock.cn.push({
18600 cls : 'input-group-addon input-group-append input-group-text',
18606 var ibwrap = inputblock;
18611 cls: 'roo-select2-choices',
18615 cls: 'roo-select2-search-field',
18628 cls: 'roo-select2-container input-group roo-touchview-combobox ',
18633 cls: 'form-hidden-field'
18639 if(!this.multiple && this.showToggleBtn){
18645 if (this.caret != false) {
18648 cls: 'fa fa-' + this.caret
18655 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
18657 Roo.bootstrap.version == 3 ? caret : '',
18660 cls: 'combobox-clear',
18674 combobox.cls += ' roo-select2-container-multi';
18677 var required = this.allowBlank ? {
18679 style: 'display: none'
18682 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
18683 tooltip : 'This field is required'
18686 var align = this.labelAlign || this.parentLabelAlign();
18688 if (align ==='left' && this.fieldLabel.length) {
18694 cls : 'control-label col-form-label',
18695 html : this.fieldLabel
18699 cls : 'roo-combobox-wrap ',
18706 var labelCfg = cfg.cn[1];
18707 var contentCfg = cfg.cn[2];
18710 if(this.indicatorpos == 'right'){
18715 cls : 'control-label col-form-label',
18719 html : this.fieldLabel
18725 cls : "roo-combobox-wrap ",
18733 labelCfg = cfg.cn[0];
18734 contentCfg = cfg.cn[1];
18739 if(this.labelWidth > 12){
18740 labelCfg.style = "width: " + this.labelWidth + 'px';
18743 if(this.labelWidth < 13 && this.labelmd == 0){
18744 this.labelmd = this.labelWidth;
18747 if(this.labellg > 0){
18748 labelCfg.cls += ' col-lg-' + this.labellg;
18749 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
18752 if(this.labelmd > 0){
18753 labelCfg.cls += ' col-md-' + this.labelmd;
18754 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
18757 if(this.labelsm > 0){
18758 labelCfg.cls += ' col-sm-' + this.labelsm;
18759 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
18762 if(this.labelxs > 0){
18763 labelCfg.cls += ' col-xs-' + this.labelxs;
18764 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
18768 } else if ( this.fieldLabel.length) {
18773 cls : 'control-label',
18774 html : this.fieldLabel
18785 if(this.indicatorpos == 'right'){
18789 cls : 'control-label',
18790 html : this.fieldLabel,
18808 var settings = this;
18810 ['xs','sm','md','lg'].map(function(size){
18811 if (settings[size]) {
18812 cfg.cls += ' col-' + size + '-' + settings[size];
18819 initTouchView : function()
18821 this.renderTouchView();
18823 this.touchViewEl.on('scroll', function(){
18824 this.el.dom.scrollTop = 0;
18827 this.originalValue = this.getValue();
18829 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
18831 this.inputEl().on("click", this.showTouchView, this);
18832 if (this.triggerEl) {
18833 this.triggerEl.on("click", this.showTouchView, this);
18837 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
18838 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
18840 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
18842 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
18843 this.store.on('load', this.onTouchViewLoad, this);
18844 this.store.on('loadexception', this.onTouchViewLoadException, this);
18846 if(this.hiddenName){
18848 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
18850 this.hiddenField.dom.value =
18851 this.hiddenValue !== undefined ? this.hiddenValue :
18852 this.value !== undefined ? this.value : '';
18854 this.el.dom.removeAttribute('name');
18855 this.hiddenField.dom.setAttribute('name', this.hiddenName);
18859 this.choices = this.el.select('ul.roo-select2-choices', true).first();
18860 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
18863 if(this.removable && !this.multiple){
18864 var close = this.closeTriggerEl();
18866 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
18867 close.on('click', this.removeBtnClick, this, close);
18871 * fix the bug in Safari iOS8
18873 this.inputEl().on("focus", function(e){
18874 document.activeElement.blur();
18877 this._touchViewMask = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
18884 renderTouchView : function()
18886 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
18887 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18889 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
18890 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18892 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
18893 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18894 this.touchViewBodyEl.setStyle('overflow', 'auto');
18896 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
18897 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18899 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
18900 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18904 showTouchView : function()
18910 this.touchViewHeaderEl.hide();
18912 if(this.modalTitle.length){
18913 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
18914 this.touchViewHeaderEl.show();
18917 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
18918 this.touchViewEl.show();
18920 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
18922 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
18923 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
18925 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
18927 if(this.modalTitle.length){
18928 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
18931 this.touchViewBodyEl.setHeight(bodyHeight);
18935 (function(){ _this.touchViewEl.addClass(['in','show']); }).defer(50);
18937 this.touchViewEl.addClass(['in','show']);
18940 if(this._touchViewMask){
18941 Roo.get(document.body).addClass("x-body-masked");
18942 this._touchViewMask.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
18943 this._touchViewMask.setStyle('z-index', 10000);
18944 this._touchViewMask.addClass('show');
18947 this.doTouchViewQuery();
18951 hideTouchView : function()
18953 this.touchViewEl.removeClass(['in','show']);
18957 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
18959 this.touchViewEl.setStyle('display', 'none');
18962 if(this._touchViewMask){
18963 this._touchViewMask.removeClass('show');
18964 Roo.get(document.body).removeClass("x-body-masked");
18968 setTouchViewValue : function()
18975 Roo.each(this.tickItems, function(o){
18980 this.hideTouchView();
18983 doTouchViewQuery : function()
18992 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
18996 if(!this.alwaysQuery || this.mode == 'local'){
18997 this.onTouchViewLoad();
19004 onTouchViewBeforeLoad : function(combo,opts)
19010 onTouchViewLoad : function()
19012 if(this.store.getCount() < 1){
19013 this.onTouchViewEmptyResults();
19017 this.clearTouchView();
19019 var rawValue = this.getRawValue();
19021 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
19023 this.tickItems = [];
19025 this.store.data.each(function(d, rowIndex){
19026 var row = this.touchViewListGroup.createChild(template);
19028 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
19029 row.addClass(d.data.cls);
19032 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
19035 html : d.data[this.displayField]
19038 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
19039 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
19042 row.removeClass('selected');
19043 if(!this.multiple && this.valueField &&
19044 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
19047 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
19048 row.addClass('selected');
19051 if(this.multiple && this.valueField &&
19052 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
19056 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
19057 this.tickItems.push(d.data);
19060 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
19064 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
19066 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
19068 if(this.modalTitle.length){
19069 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
19072 var listHeight = this.touchViewListGroup.getHeight() + this.touchViewBodyEl.getPadding('tb') * 2;
19074 if(this.mobile_restrict_height && listHeight < bodyHeight){
19075 this.touchViewBodyEl.setHeight(listHeight);
19080 if(firstChecked && listHeight > bodyHeight){
19081 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
19086 onTouchViewLoadException : function()
19088 this.hideTouchView();
19091 onTouchViewEmptyResults : function()
19093 this.clearTouchView();
19095 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
19097 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
19101 clearTouchView : function()
19103 this.touchViewListGroup.dom.innerHTML = '';
19106 onTouchViewClick : function(e, el, o)
19108 e.preventDefault();
19111 var rowIndex = o.rowIndex;
19113 var r = this.store.getAt(rowIndex);
19115 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
19117 if(!this.multiple){
19118 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
19119 c.dom.removeAttribute('checked');
19122 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
19124 this.setFromData(r.data);
19126 var close = this.closeTriggerEl();
19132 this.hideTouchView();
19134 this.fireEvent('select', this, r, rowIndex);
19139 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
19140 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
19141 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
19145 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
19146 this.addItem(r.data);
19147 this.tickItems.push(r.data);
19151 getAutoCreateNativeIOS : function()
19154 cls: 'form-group' //input-group,
19159 cls : 'roo-ios-select'
19163 combobox.name = this.name;
19166 if (this.disabled) {
19167 combobox.disabled = true;
19170 var settings = this;
19172 ['xs','sm','md','lg'].map(function(size){
19173 if (settings[size]) {
19174 cfg.cls += ' col-' + size + '-' + settings[size];
19184 initIOSView : function()
19186 this.store.on('load', this.onIOSViewLoad, this);
19191 onIOSViewLoad : function()
19193 if(this.store.getCount() < 1){
19197 this.clearIOSView();
19199 if(this.allowBlank) {
19201 var default_text = '-- SELECT --';
19203 if(this.placeholder.length){
19204 default_text = this.placeholder;
19207 if(this.emptyTitle.length){
19208 default_text += ' - ' + this.emptyTitle + ' -';
19211 var opt = this.inputEl().createChild({
19214 html : default_text
19218 o[this.valueField] = 0;
19219 o[this.displayField] = default_text;
19221 this.ios_options.push({
19228 this.store.data.each(function(d, rowIndex){
19232 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
19233 html = d.data[this.displayField];
19238 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
19239 value = d.data[this.valueField];
19248 if(this.value == d.data[this.valueField]){
19249 option['selected'] = true;
19252 var opt = this.inputEl().createChild(option);
19254 this.ios_options.push({
19261 this.inputEl().on('change', function(){
19262 this.fireEvent('select', this);
19267 clearIOSView: function()
19269 this.inputEl().dom.innerHTML = '';
19271 this.ios_options = [];
19274 setIOSValue: function(v)
19278 if(!this.ios_options){
19282 Roo.each(this.ios_options, function(opts){
19284 opts.el.dom.removeAttribute('selected');
19286 if(opts.data[this.valueField] != v){
19290 opts.el.dom.setAttribute('selected', true);
19296 * @cfg {Boolean} grow
19300 * @cfg {Number} growMin
19304 * @cfg {Number} growMax
19313 Roo.apply(Roo.bootstrap.ComboBox, {
19317 cls: 'modal-header',
19339 cls: 'list-group-item',
19343 cls: 'roo-combobox-list-group-item-value'
19347 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
19361 listItemCheckbox : {
19363 cls: 'list-group-item',
19367 cls: 'roo-combobox-list-group-item-value'
19371 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
19387 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
19392 cls: 'modal-footer',
19400 cls: 'col-xs-6 text-left',
19403 cls: 'btn btn-danger roo-touch-view-cancel',
19409 cls: 'col-xs-6 text-right',
19412 cls: 'btn btn-success roo-touch-view-ok',
19423 Roo.apply(Roo.bootstrap.ComboBox, {
19425 touchViewTemplate : {
19427 cls: 'modal fade roo-combobox-touch-view',
19431 cls: 'modal-dialog',
19432 style : 'position:fixed', // we have to fix position....
19436 cls: 'modal-content',
19438 Roo.bootstrap.ComboBox.header,
19439 Roo.bootstrap.ComboBox.body,
19440 Roo.bootstrap.ComboBox.footer
19449 * Ext JS Library 1.1.1
19450 * Copyright(c) 2006-2007, Ext JS, LLC.
19452 * Originally Released Under LGPL - original licence link has changed is not relivant.
19455 * <script type="text/javascript">
19460 * @extends Roo.util.Observable
19461 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
19462 * This class also supports single and multi selection modes. <br>
19463 * Create a data model bound view:
19465 var store = new Roo.data.Store(...);
19467 var view = new Roo.View({
19469 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
19471 singleSelect: true,
19472 selectedClass: "ydataview-selected",
19476 // listen for node click?
19477 view.on("click", function(vw, index, node, e){
19478 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
19482 dataModel.load("foobar.xml");
19484 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
19486 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
19487 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
19489 * Note: old style constructor is still suported (container, template, config)
19492 * Create a new View
19493 * @param {Object} config The config object
19496 Roo.View = function(config, depreciated_tpl, depreciated_config){
19498 this.parent = false;
19500 if (typeof(depreciated_tpl) == 'undefined') {
19501 // new way.. - universal constructor.
19502 Roo.apply(this, config);
19503 this.el = Roo.get(this.el);
19506 this.el = Roo.get(config);
19507 this.tpl = depreciated_tpl;
19508 Roo.apply(this, depreciated_config);
19510 this.wrapEl = this.el.wrap().wrap();
19511 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
19514 if(typeof(this.tpl) == "string"){
19515 this.tpl = new Roo.Template(this.tpl);
19517 // support xtype ctors..
19518 this.tpl = new Roo.factory(this.tpl, Roo);
19522 this.tpl.compile();
19527 * @event beforeclick
19528 * Fires before a click is processed. Returns false to cancel the default action.
19529 * @param {Roo.View} this
19530 * @param {Number} index The index of the target node
19531 * @param {HTMLElement} node The target node
19532 * @param {Roo.EventObject} e The raw event object
19534 "beforeclick" : true,
19537 * Fires when a template node is clicked.
19538 * @param {Roo.View} this
19539 * @param {Number} index The index of the target node
19540 * @param {HTMLElement} node The target node
19541 * @param {Roo.EventObject} e The raw event object
19546 * Fires when a template node is double clicked.
19547 * @param {Roo.View} this
19548 * @param {Number} index The index of the target node
19549 * @param {HTMLElement} node The target node
19550 * @param {Roo.EventObject} e The raw event object
19554 * @event contextmenu
19555 * Fires when a template node is right clicked.
19556 * @param {Roo.View} this
19557 * @param {Number} index The index of the target node
19558 * @param {HTMLElement} node The target node
19559 * @param {Roo.EventObject} e The raw event object
19561 "contextmenu" : true,
19563 * @event selectionchange
19564 * Fires when the selected nodes change.
19565 * @param {Roo.View} this
19566 * @param {Array} selections Array of the selected nodes
19568 "selectionchange" : true,
19571 * @event beforeselect
19572 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
19573 * @param {Roo.View} this
19574 * @param {HTMLElement} node The node to be selected
19575 * @param {Array} selections Array of currently selected nodes
19577 "beforeselect" : true,
19579 * @event preparedata
19580 * Fires on every row to render, to allow you to change the data.
19581 * @param {Roo.View} this
19582 * @param {Object} data to be rendered (change this)
19584 "preparedata" : true
19592 "click": this.onClick,
19593 "dblclick": this.onDblClick,
19594 "contextmenu": this.onContextMenu,
19598 this.selections = [];
19600 this.cmp = new Roo.CompositeElementLite([]);
19602 this.store = Roo.factory(this.store, Roo.data);
19603 this.setStore(this.store, true);
19606 if ( this.footer && this.footer.xtype) {
19608 var fctr = this.wrapEl.appendChild(document.createElement("div"));
19610 this.footer.dataSource = this.store;
19611 this.footer.container = fctr;
19612 this.footer = Roo.factory(this.footer, Roo);
19613 fctr.insertFirst(this.el);
19615 // this is a bit insane - as the paging toolbar seems to detach the el..
19616 // dom.parentNode.parentNode.parentNode
19617 // they get detached?
19621 Roo.View.superclass.constructor.call(this);
19626 Roo.extend(Roo.View, Roo.util.Observable, {
19629 * @cfg {Roo.data.Store} store Data store to load data from.
19634 * @cfg {String|Roo.Element} el The container element.
19639 * @cfg {String|Roo.Template} tpl The template used by this View
19643 * @cfg {String} dataName the named area of the template to use as the data area
19644 * Works with domtemplates roo-name="name"
19648 * @cfg {String} selectedClass The css class to add to selected nodes
19650 selectedClass : "x-view-selected",
19652 * @cfg {String} emptyText The empty text to show when nothing is loaded.
19657 * @cfg {String} text to display on mask (default Loading)
19661 * @cfg {Boolean} multiSelect Allow multiple selection
19663 multiSelect : false,
19665 * @cfg {Boolean} singleSelect Allow single selection
19667 singleSelect: false,
19670 * @cfg {Boolean} toggleSelect - selecting
19672 toggleSelect : false,
19675 * @cfg {Boolean} tickable - selecting
19680 * Returns the element this view is bound to.
19681 * @return {Roo.Element}
19683 getEl : function(){
19684 return this.wrapEl;
19690 * Refreshes the view. - called by datachanged on the store. - do not call directly.
19692 refresh : function(){
19693 //Roo.log('refresh');
19696 // if we are using something like 'domtemplate', then
19697 // the what gets used is:
19698 // t.applySubtemplate(NAME, data, wrapping data..)
19699 // the outer template then get' applied with
19700 // the store 'extra data'
19701 // and the body get's added to the
19702 // roo-name="data" node?
19703 // <span class='roo-tpl-{name}'></span> ?????
19707 this.clearSelections();
19708 this.el.update("");
19710 var records = this.store.getRange();
19711 if(records.length < 1) {
19713 // is this valid?? = should it render a template??
19715 this.el.update(this.emptyText);
19719 if (this.dataName) {
19720 this.el.update(t.apply(this.store.meta)); //????
19721 el = this.el.child('.roo-tpl-' + this.dataName);
19724 for(var i = 0, len = records.length; i < len; i++){
19725 var data = this.prepareData(records[i].data, i, records[i]);
19726 this.fireEvent("preparedata", this, data, i, records[i]);
19728 var d = Roo.apply({}, data);
19731 Roo.apply(d, {'roo-id' : Roo.id()});
19735 Roo.each(this.parent.item, function(item){
19736 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
19739 Roo.apply(d, {'roo-data-checked' : 'checked'});
19743 html[html.length] = Roo.util.Format.trim(
19745 t.applySubtemplate(this.dataName, d, this.store.meta) :
19752 el.update(html.join(""));
19753 this.nodes = el.dom.childNodes;
19754 this.updateIndexes(0);
19759 * Function to override to reformat the data that is sent to
19760 * the template for each node.
19761 * DEPRICATED - use the preparedata event handler.
19762 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
19763 * a JSON object for an UpdateManager bound view).
19765 prepareData : function(data, index, record)
19767 this.fireEvent("preparedata", this, data, index, record);
19771 onUpdate : function(ds, record){
19772 // Roo.log('on update');
19773 this.clearSelections();
19774 var index = this.store.indexOf(record);
19775 var n = this.nodes[index];
19776 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
19777 n.parentNode.removeChild(n);
19778 this.updateIndexes(index, index);
19784 onAdd : function(ds, records, index)
19786 //Roo.log(['on Add', ds, records, index] );
19787 this.clearSelections();
19788 if(this.nodes.length == 0){
19792 var n = this.nodes[index];
19793 for(var i = 0, len = records.length; i < len; i++){
19794 var d = this.prepareData(records[i].data, i, records[i]);
19796 this.tpl.insertBefore(n, d);
19799 this.tpl.append(this.el, d);
19802 this.updateIndexes(index);
19805 onRemove : function(ds, record, index){
19806 // Roo.log('onRemove');
19807 this.clearSelections();
19808 var el = this.dataName ?
19809 this.el.child('.roo-tpl-' + this.dataName) :
19812 el.dom.removeChild(this.nodes[index]);
19813 this.updateIndexes(index);
19817 * Refresh an individual node.
19818 * @param {Number} index
19820 refreshNode : function(index){
19821 this.onUpdate(this.store, this.store.getAt(index));
19824 updateIndexes : function(startIndex, endIndex){
19825 var ns = this.nodes;
19826 startIndex = startIndex || 0;
19827 endIndex = endIndex || ns.length - 1;
19828 for(var i = startIndex; i <= endIndex; i++){
19829 ns[i].nodeIndex = i;
19834 * Changes the data store this view uses and refresh the view.
19835 * @param {Store} store
19837 setStore : function(store, initial){
19838 if(!initial && this.store){
19839 this.store.un("datachanged", this.refresh);
19840 this.store.un("add", this.onAdd);
19841 this.store.un("remove", this.onRemove);
19842 this.store.un("update", this.onUpdate);
19843 this.store.un("clear", this.refresh);
19844 this.store.un("beforeload", this.onBeforeLoad);
19845 this.store.un("load", this.onLoad);
19846 this.store.un("loadexception", this.onLoad);
19850 store.on("datachanged", this.refresh, this);
19851 store.on("add", this.onAdd, this);
19852 store.on("remove", this.onRemove, this);
19853 store.on("update", this.onUpdate, this);
19854 store.on("clear", this.refresh, this);
19855 store.on("beforeload", this.onBeforeLoad, this);
19856 store.on("load", this.onLoad, this);
19857 store.on("loadexception", this.onLoad, this);
19865 * onbeforeLoad - masks the loading area.
19868 onBeforeLoad : function(store,opts)
19870 //Roo.log('onBeforeLoad');
19872 this.el.update("");
19874 this.el.mask(this.mask ? this.mask : "Loading" );
19876 onLoad : function ()
19883 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
19884 * @param {HTMLElement} node
19885 * @return {HTMLElement} The template node
19887 findItemFromChild : function(node){
19888 var el = this.dataName ?
19889 this.el.child('.roo-tpl-' + this.dataName,true) :
19892 if(!node || node.parentNode == el){
19895 var p = node.parentNode;
19896 while(p && p != el){
19897 if(p.parentNode == el){
19906 onClick : function(e){
19907 var item = this.findItemFromChild(e.getTarget());
19909 var index = this.indexOf(item);
19910 if(this.onItemClick(item, index, e) !== false){
19911 this.fireEvent("click", this, index, item, e);
19914 this.clearSelections();
19919 onContextMenu : function(e){
19920 var item = this.findItemFromChild(e.getTarget());
19922 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
19927 onDblClick : function(e){
19928 var item = this.findItemFromChild(e.getTarget());
19930 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
19934 onItemClick : function(item, index, e)
19936 if(this.fireEvent("beforeclick", this, index, item, e) === false){
19939 if (this.toggleSelect) {
19940 var m = this.isSelected(item) ? 'unselect' : 'select';
19943 _t[m](item, true, false);
19946 if(this.multiSelect || this.singleSelect){
19947 if(this.multiSelect && e.shiftKey && this.lastSelection){
19948 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
19950 this.select(item, this.multiSelect && e.ctrlKey);
19951 this.lastSelection = item;
19954 if(!this.tickable){
19955 e.preventDefault();
19963 * Get the number of selected nodes.
19966 getSelectionCount : function(){
19967 return this.selections.length;
19971 * Get the currently selected nodes.
19972 * @return {Array} An array of HTMLElements
19974 getSelectedNodes : function(){
19975 return this.selections;
19979 * Get the indexes of the selected nodes.
19982 getSelectedIndexes : function(){
19983 var indexes = [], s = this.selections;
19984 for(var i = 0, len = s.length; i < len; i++){
19985 indexes.push(s[i].nodeIndex);
19991 * Clear all selections
19992 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
19994 clearSelections : function(suppressEvent){
19995 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
19996 this.cmp.elements = this.selections;
19997 this.cmp.removeClass(this.selectedClass);
19998 this.selections = [];
19999 if(!suppressEvent){
20000 this.fireEvent("selectionchange", this, this.selections);
20006 * Returns true if the passed node is selected
20007 * @param {HTMLElement/Number} node The node or node index
20008 * @return {Boolean}
20010 isSelected : function(node){
20011 var s = this.selections;
20015 node = this.getNode(node);
20016 return s.indexOf(node) !== -1;
20021 * @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
20022 * @param {Boolean} keepExisting (optional) true to keep existing selections
20023 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
20025 select : function(nodeInfo, keepExisting, suppressEvent){
20026 if(nodeInfo instanceof Array){
20028 this.clearSelections(true);
20030 for(var i = 0, len = nodeInfo.length; i < len; i++){
20031 this.select(nodeInfo[i], true, true);
20035 var node = this.getNode(nodeInfo);
20036 if(!node || this.isSelected(node)){
20037 return; // already selected.
20040 this.clearSelections(true);
20043 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
20044 Roo.fly(node).addClass(this.selectedClass);
20045 this.selections.push(node);
20046 if(!suppressEvent){
20047 this.fireEvent("selectionchange", this, this.selections);
20055 * @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
20056 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
20057 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
20059 unselect : function(nodeInfo, keepExisting, suppressEvent)
20061 if(nodeInfo instanceof Array){
20062 Roo.each(this.selections, function(s) {
20063 this.unselect(s, nodeInfo);
20067 var node = this.getNode(nodeInfo);
20068 if(!node || !this.isSelected(node)){
20069 //Roo.log("not selected");
20070 return; // not selected.
20074 Roo.each(this.selections, function(s) {
20076 Roo.fly(node).removeClass(this.selectedClass);
20083 this.selections= ns;
20084 this.fireEvent("selectionchange", this, this.selections);
20088 * Gets a template node.
20089 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
20090 * @return {HTMLElement} The node or null if it wasn't found
20092 getNode : function(nodeInfo){
20093 if(typeof nodeInfo == "string"){
20094 return document.getElementById(nodeInfo);
20095 }else if(typeof nodeInfo == "number"){
20096 return this.nodes[nodeInfo];
20102 * Gets a range template nodes.
20103 * @param {Number} startIndex
20104 * @param {Number} endIndex
20105 * @return {Array} An array of nodes
20107 getNodes : function(start, end){
20108 var ns = this.nodes;
20109 start = start || 0;
20110 end = typeof end == "undefined" ? ns.length - 1 : end;
20113 for(var i = start; i <= end; i++){
20117 for(var i = start; i >= end; i--){
20125 * Finds the index of the passed node
20126 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
20127 * @return {Number} The index of the node or -1
20129 indexOf : function(node){
20130 node = this.getNode(node);
20131 if(typeof node.nodeIndex == "number"){
20132 return node.nodeIndex;
20134 var ns = this.nodes;
20135 for(var i = 0, len = ns.length; i < len; i++){
20146 * based on jquery fullcalendar
20150 Roo.bootstrap = Roo.bootstrap || {};
20152 * @class Roo.bootstrap.Calendar
20153 * @extends Roo.bootstrap.Component
20154 * Bootstrap Calendar class
20155 * @cfg {Boolean} loadMask (true|false) default false
20156 * @cfg {Object} header generate the user specific header of the calendar, default false
20159 * Create a new Container
20160 * @param {Object} config The config object
20165 Roo.bootstrap.Calendar = function(config){
20166 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
20170 * Fires when a date is selected
20171 * @param {DatePicker} this
20172 * @param {Date} date The selected date
20176 * @event monthchange
20177 * Fires when the displayed month changes
20178 * @param {DatePicker} this
20179 * @param {Date} date The selected month
20181 'monthchange': true,
20183 * @event evententer
20184 * Fires when mouse over an event
20185 * @param {Calendar} this
20186 * @param {event} Event
20188 'evententer': true,
20190 * @event eventleave
20191 * Fires when the mouse leaves an
20192 * @param {Calendar} this
20195 'eventleave': true,
20197 * @event eventclick
20198 * Fires when the mouse click an
20199 * @param {Calendar} this
20208 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
20211 * @cfg {Roo.data.Store} store
20212 * The data source for the calendar
20216 * @cfg {Number} startDay
20217 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
20225 getAutoCreate : function(){
20228 var fc_button = function(name, corner, style, content ) {
20229 return Roo.apply({},{
20231 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
20233 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
20236 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
20247 style : 'width:100%',
20254 cls : 'fc-header-left',
20256 fc_button('prev', 'left', 'arrow', '‹' ),
20257 fc_button('next', 'right', 'arrow', '›' ),
20258 { tag: 'span', cls: 'fc-header-space' },
20259 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
20267 cls : 'fc-header-center',
20271 cls: 'fc-header-title',
20274 html : 'month / year'
20282 cls : 'fc-header-right',
20284 /* fc_button('month', 'left', '', 'month' ),
20285 fc_button('week', '', '', 'week' ),
20286 fc_button('day', 'right', '', 'day' )
20298 header = this.header;
20301 var cal_heads = function() {
20303 // fixme - handle this.
20305 for (var i =0; i < Date.dayNames.length; i++) {
20306 var d = Date.dayNames[i];
20309 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
20310 html : d.substring(0,3)
20314 ret[0].cls += ' fc-first';
20315 ret[6].cls += ' fc-last';
20318 var cal_cell = function(n) {
20321 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
20326 cls: 'fc-day-number',
20330 cls: 'fc-day-content',
20334 style: 'position: relative;' // height: 17px;
20346 var cal_rows = function() {
20349 for (var r = 0; r < 6; r++) {
20356 for (var i =0; i < Date.dayNames.length; i++) {
20357 var d = Date.dayNames[i];
20358 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
20361 row.cn[0].cls+=' fc-first';
20362 row.cn[0].cn[0].style = 'min-height:90px';
20363 row.cn[6].cls+=' fc-last';
20367 ret[0].cls += ' fc-first';
20368 ret[4].cls += ' fc-prev-last';
20369 ret[5].cls += ' fc-last';
20376 cls: 'fc-border-separate',
20377 style : 'width:100%',
20385 cls : 'fc-first fc-last',
20403 cls : 'fc-content',
20404 style : "position: relative;",
20407 cls : 'fc-view fc-view-month fc-grid',
20408 style : 'position: relative',
20409 unselectable : 'on',
20412 cls : 'fc-event-container',
20413 style : 'position:absolute;z-index:8;top:0;left:0;'
20431 initEvents : function()
20434 throw "can not find store for calendar";
20440 style: "text-align:center",
20444 style: "background-color:white;width:50%;margin:250 auto",
20448 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
20459 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
20461 var size = this.el.select('.fc-content', true).first().getSize();
20462 this.maskEl.setSize(size.width, size.height);
20463 this.maskEl.enableDisplayMode("block");
20464 if(!this.loadMask){
20465 this.maskEl.hide();
20468 this.store = Roo.factory(this.store, Roo.data);
20469 this.store.on('load', this.onLoad, this);
20470 this.store.on('beforeload', this.onBeforeLoad, this);
20474 this.cells = this.el.select('.fc-day',true);
20475 //Roo.log(this.cells);
20476 this.textNodes = this.el.query('.fc-day-number');
20477 this.cells.addClassOnOver('fc-state-hover');
20479 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
20480 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
20481 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
20482 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
20484 this.on('monthchange', this.onMonthChange, this);
20486 this.update(new Date().clearTime());
20489 resize : function() {
20490 var sz = this.el.getSize();
20492 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
20493 this.el.select('.fc-day-content div',true).setHeight(34);
20498 showPrevMonth : function(e){
20499 this.update(this.activeDate.add("mo", -1));
20501 showToday : function(e){
20502 this.update(new Date().clearTime());
20505 showNextMonth : function(e){
20506 this.update(this.activeDate.add("mo", 1));
20510 showPrevYear : function(){
20511 this.update(this.activeDate.add("y", -1));
20515 showNextYear : function(){
20516 this.update(this.activeDate.add("y", 1));
20521 update : function(date)
20523 var vd = this.activeDate;
20524 this.activeDate = date;
20525 // if(vd && this.el){
20526 // var t = date.getTime();
20527 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
20528 // Roo.log('using add remove');
20530 // this.fireEvent('monthchange', this, date);
20532 // this.cells.removeClass("fc-state-highlight");
20533 // this.cells.each(function(c){
20534 // if(c.dateValue == t){
20535 // c.addClass("fc-state-highlight");
20536 // setTimeout(function(){
20537 // try{c.dom.firstChild.focus();}catch(e){}
20547 var days = date.getDaysInMonth();
20549 var firstOfMonth = date.getFirstDateOfMonth();
20550 var startingPos = firstOfMonth.getDay()-this.startDay;
20552 if(startingPos < this.startDay){
20556 var pm = date.add(Date.MONTH, -1);
20557 var prevStart = pm.getDaysInMonth()-startingPos;
20559 this.cells = this.el.select('.fc-day',true);
20560 this.textNodes = this.el.query('.fc-day-number');
20561 this.cells.addClassOnOver('fc-state-hover');
20563 var cells = this.cells.elements;
20564 var textEls = this.textNodes;
20566 Roo.each(cells, function(cell){
20567 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
20570 days += startingPos;
20572 // convert everything to numbers so it's fast
20573 var day = 86400000;
20574 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
20577 //Roo.log(prevStart);
20579 var today = new Date().clearTime().getTime();
20580 var sel = date.clearTime().getTime();
20581 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
20582 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
20583 var ddMatch = this.disabledDatesRE;
20584 var ddText = this.disabledDatesText;
20585 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
20586 var ddaysText = this.disabledDaysText;
20587 var format = this.format;
20589 var setCellClass = function(cal, cell){
20593 //Roo.log('set Cell Class');
20595 var t = d.getTime();
20599 cell.dateValue = t;
20601 cell.className += " fc-today";
20602 cell.className += " fc-state-highlight";
20603 cell.title = cal.todayText;
20606 // disable highlight in other month..
20607 //cell.className += " fc-state-highlight";
20612 cell.className = " fc-state-disabled";
20613 cell.title = cal.minText;
20617 cell.className = " fc-state-disabled";
20618 cell.title = cal.maxText;
20622 if(ddays.indexOf(d.getDay()) != -1){
20623 cell.title = ddaysText;
20624 cell.className = " fc-state-disabled";
20627 if(ddMatch && format){
20628 var fvalue = d.dateFormat(format);
20629 if(ddMatch.test(fvalue)){
20630 cell.title = ddText.replace("%0", fvalue);
20631 cell.className = " fc-state-disabled";
20635 if (!cell.initialClassName) {
20636 cell.initialClassName = cell.dom.className;
20639 cell.dom.className = cell.initialClassName + ' ' + cell.className;
20644 for(; i < startingPos; i++) {
20645 textEls[i].innerHTML = (++prevStart);
20646 d.setDate(d.getDate()+1);
20648 cells[i].className = "fc-past fc-other-month";
20649 setCellClass(this, cells[i]);
20654 for(; i < days; i++){
20655 intDay = i - startingPos + 1;
20656 textEls[i].innerHTML = (intDay);
20657 d.setDate(d.getDate()+1);
20659 cells[i].className = ''; // "x-date-active";
20660 setCellClass(this, cells[i]);
20664 for(; i < 42; i++) {
20665 textEls[i].innerHTML = (++extraDays);
20666 d.setDate(d.getDate()+1);
20668 cells[i].className = "fc-future fc-other-month";
20669 setCellClass(this, cells[i]);
20672 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
20674 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
20676 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
20677 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
20679 if(totalRows != 6){
20680 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
20681 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
20684 this.fireEvent('monthchange', this, date);
20688 if(!this.internalRender){
20689 var main = this.el.dom.firstChild;
20690 var w = main.offsetWidth;
20691 this.el.setWidth(w + this.el.getBorderWidth("lr"));
20692 Roo.fly(main).setWidth(w);
20693 this.internalRender = true;
20694 // opera does not respect the auto grow header center column
20695 // then, after it gets a width opera refuses to recalculate
20696 // without a second pass
20697 if(Roo.isOpera && !this.secondPass){
20698 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
20699 this.secondPass = true;
20700 this.update.defer(10, this, [date]);
20707 findCell : function(dt) {
20708 dt = dt.clearTime().getTime();
20710 this.cells.each(function(c){
20711 //Roo.log("check " +c.dateValue + '?=' + dt);
20712 if(c.dateValue == dt){
20722 findCells : function(ev) {
20723 var s = ev.start.clone().clearTime().getTime();
20725 var e= ev.end.clone().clearTime().getTime();
20728 this.cells.each(function(c){
20729 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
20731 if(c.dateValue > e){
20734 if(c.dateValue < s){
20743 // findBestRow: function(cells)
20747 // for (var i =0 ; i < cells.length;i++) {
20748 // ret = Math.max(cells[i].rows || 0,ret);
20755 addItem : function(ev)
20757 // look for vertical location slot in
20758 var cells = this.findCells(ev);
20760 // ev.row = this.findBestRow(cells);
20762 // work out the location.
20766 for(var i =0; i < cells.length; i++) {
20768 cells[i].row = cells[0].row;
20771 cells[i].row = cells[i].row + 1;
20781 if (crow.start.getY() == cells[i].getY()) {
20783 crow.end = cells[i];
20800 cells[0].events.push(ev);
20802 this.calevents.push(ev);
20805 clearEvents: function() {
20807 if(!this.calevents){
20811 Roo.each(this.cells.elements, function(c){
20817 Roo.each(this.calevents, function(e) {
20818 Roo.each(e.els, function(el) {
20819 el.un('mouseenter' ,this.onEventEnter, this);
20820 el.un('mouseleave' ,this.onEventLeave, this);
20825 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
20831 renderEvents: function()
20835 this.cells.each(function(c) {
20844 if(c.row != c.events.length){
20845 r = 4 - (4 - (c.row - c.events.length));
20848 c.events = ev.slice(0, r);
20849 c.more = ev.slice(r);
20851 if(c.more.length && c.more.length == 1){
20852 c.events.push(c.more.pop());
20855 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
20859 this.cells.each(function(c) {
20861 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
20864 for (var e = 0; e < c.events.length; e++){
20865 var ev = c.events[e];
20866 var rows = ev.rows;
20868 for(var i = 0; i < rows.length; i++) {
20870 // how many rows should it span..
20873 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
20874 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
20876 unselectable : "on",
20879 cls: 'fc-event-inner',
20883 // cls: 'fc-event-time',
20884 // html : cells.length > 1 ? '' : ev.time
20888 cls: 'fc-event-title',
20889 html : String.format('{0}', ev.title)
20896 cls: 'ui-resizable-handle ui-resizable-e',
20897 html : '  '
20904 cfg.cls += ' fc-event-start';
20906 if ((i+1) == rows.length) {
20907 cfg.cls += ' fc-event-end';
20910 var ctr = _this.el.select('.fc-event-container',true).first();
20911 var cg = ctr.createChild(cfg);
20913 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
20914 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
20916 var r = (c.more.length) ? 1 : 0;
20917 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
20918 cg.setWidth(ebox.right - sbox.x -2);
20920 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
20921 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
20922 cg.on('click', _this.onEventClick, _this, ev);
20933 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
20934 style : 'position: absolute',
20935 unselectable : "on",
20938 cls: 'fc-event-inner',
20942 cls: 'fc-event-title',
20950 cls: 'ui-resizable-handle ui-resizable-e',
20951 html : '  '
20957 var ctr = _this.el.select('.fc-event-container',true).first();
20958 var cg = ctr.createChild(cfg);
20960 var sbox = c.select('.fc-day-content',true).first().getBox();
20961 var ebox = c.select('.fc-day-content',true).first().getBox();
20963 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
20964 cg.setWidth(ebox.right - sbox.x -2);
20966 cg.on('click', _this.onMoreEventClick, _this, c.more);
20976 onEventEnter: function (e, el,event,d) {
20977 this.fireEvent('evententer', this, el, event);
20980 onEventLeave: function (e, el,event,d) {
20981 this.fireEvent('eventleave', this, el, event);
20984 onEventClick: function (e, el,event,d) {
20985 this.fireEvent('eventclick', this, el, event);
20988 onMonthChange: function () {
20992 onMoreEventClick: function(e, el, more)
20996 this.calpopover.placement = 'right';
20997 this.calpopover.setTitle('More');
20999 this.calpopover.setContent('');
21001 var ctr = this.calpopover.el.select('.popover-content', true).first();
21003 Roo.each(more, function(m){
21005 cls : 'fc-event-hori fc-event-draggable',
21008 var cg = ctr.createChild(cfg);
21010 cg.on('click', _this.onEventClick, _this, m);
21013 this.calpopover.show(el);
21018 onLoad: function ()
21020 this.calevents = [];
21023 if(this.store.getCount() > 0){
21024 this.store.data.each(function(d){
21027 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
21028 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
21029 time : d.data.start_time,
21030 title : d.data.title,
21031 description : d.data.description,
21032 venue : d.data.venue
21037 this.renderEvents();
21039 if(this.calevents.length && this.loadMask){
21040 this.maskEl.hide();
21044 onBeforeLoad: function()
21046 this.clearEvents();
21048 this.maskEl.show();
21062 * @class Roo.bootstrap.Popover
21063 * @extends Roo.bootstrap.Component
21064 * Bootstrap Popover class
21065 * @cfg {String} html contents of the popover (or false to use children..)
21066 * @cfg {String} title of popover (or false to hide)
21067 * @cfg {String|function} (right|top|bottom|left|auto) placement how it is placed
21068 * @cfg {String} trigger click || hover (or false to trigger manually)
21069 * @cfg {Boolean} modal - popovers that are modal will mask the screen, and must be closed with another event.
21070 * @cfg {String|Boolean|Roo.Element} add click hander to trigger show over what element
21071 * - if false and it has a 'parent' then it will be automatically added to that element
21072 * - if string - Roo.get will be called
21073 * @cfg {Number} delay - delay before showing
21076 * Create a new Popover
21077 * @param {Object} config The config object
21080 Roo.bootstrap.Popover = function(config){
21081 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
21087 * After the popover show
21089 * @param {Roo.bootstrap.Popover} this
21094 * After the popover hide
21096 * @param {Roo.bootstrap.Popover} this
21102 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
21107 placement : 'right',
21108 trigger : 'hover', // hover
21114 can_build_overlaid : false,
21116 maskEl : false, // the mask element
21119 alignEl : false, // when show is called with an element - this get's stored.
21121 getChildContainer : function()
21123 return this.contentEl;
21126 getPopoverHeader : function()
21128 this.title = true; // flag not to hide it..
21129 this.headerEl.addClass('p-0');
21130 return this.headerEl
21134 getAutoCreate : function(){
21137 cls : 'popover roo-dynamic shadow roo-popover' + (this.modal ? '-modal' : ''),
21138 style: 'display:block',
21144 cls : 'popover-inner ',
21148 cls: 'popover-title popover-header',
21149 html : this.title === false ? '' : this.title
21152 cls : 'popover-content popover-body ' + (this.cls || ''),
21153 html : this.html || ''
21164 * @param {string} the title
21166 setTitle: function(str)
21170 this.headerEl.dom.innerHTML = str;
21175 * @param {string} the body content
21177 setContent: function(str)
21180 if (this.contentEl) {
21181 this.contentEl.dom.innerHTML = str;
21185 // as it get's added to the bottom of the page.
21186 onRender : function(ct, position)
21188 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
21193 var cfg = Roo.apply({}, this.getAutoCreate());
21197 cfg.cls += ' ' + this.cls;
21200 cfg.style = this.style;
21202 //Roo.log("adding to ");
21203 this.el = Roo.get(document.body).createChild(cfg, position);
21204 // Roo.log(this.el);
21207 this.contentEl = this.el.select('.popover-content',true).first();
21208 this.headerEl = this.el.select('.popover-title',true).first();
21211 if(typeof(this.items) != 'undefined'){
21212 var items = this.items;
21215 for(var i =0;i < items.length;i++) {
21216 nitems.push(this.addxtype(Roo.apply({}, items[i])));
21220 this.items = nitems;
21222 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
21223 Roo.EventManager.onWindowResize(this.resizeMask, this, true);
21230 resizeMask : function()
21232 this.maskEl.setSize(
21233 Roo.lib.Dom.getViewWidth(true),
21234 Roo.lib.Dom.getViewHeight(true)
21238 initEvents : function()
21242 Roo.bootstrap.Popover.register(this);
21245 this.arrowEl = this.el.select('.arrow',true).first();
21246 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY); // probably not needed as it's default in BS4
21247 this.el.enableDisplayMode('block');
21251 if (this.over === false && !this.parent()) {
21254 if (this.triggers === false) {
21259 var on_el = (this.over == 'parent' || this.over === false) ? this.parent().el : Roo.get(this.over);
21260 var triggers = this.trigger ? this.trigger.split(' ') : [];
21261 Roo.each(triggers, function(trigger) {
21263 if (trigger == 'click') {
21264 on_el.on('click', this.toggle, this);
21265 } else if (trigger != 'manual') {
21266 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
21267 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
21269 on_el.on(eventIn ,this.enter, this);
21270 on_el.on(eventOut, this.leave, this);
21280 toggle : function () {
21281 this.hoverState == 'in' ? this.leave() : this.enter();
21284 enter : function () {
21286 clearTimeout(this.timeout);
21288 this.hoverState = 'in';
21290 if (!this.delay || !this.delay.show) {
21295 this.timeout = setTimeout(function () {
21296 if (_t.hoverState == 'in') {
21299 }, this.delay.show)
21302 leave : function() {
21303 clearTimeout(this.timeout);
21305 this.hoverState = 'out';
21307 if (!this.delay || !this.delay.hide) {
21312 this.timeout = setTimeout(function () {
21313 if (_t.hoverState == 'out') {
21316 }, this.delay.hide)
21320 * @param {Roo.Element|string|Boolean} - element to align and point to. (set align to [ pos, offset ])
21321 * @param {string} (left|right|top|bottom) position
21323 show : function (on_el, placement)
21325 this.placement = typeof(placement) == 'undefined' ? this.placement : placement;
21326 on_el = on_el || false; // default to false
21329 if (this.parent() && (this.over == 'parent' || (this.over === false))) {
21330 on_el = this.parent().el;
21331 } else if (this.over) {
21332 on_el = Roo.get(this.over);
21337 this.alignEl = Roo.get( on_el );
21340 this.render(document.body);
21346 if (this.title === false) {
21347 this.headerEl.hide();
21352 this.el.dom.style.display = 'block';
21355 if (this.alignEl) {
21356 this.updatePosition(this.placement, true);
21359 // this is usually just done by the builder = to show the popoup in the middle of the scren.
21360 var es = this.el.getSize();
21361 var x = Roo.lib.Dom.getViewWidth()/2;
21362 var y = Roo.lib.Dom.getViewHeight()/2;
21363 this.el.setXY([ x-(es.width/2), y-(es.height/2)] );
21368 //var arrow = this.el.select('.arrow',true).first();
21369 //arrow.set(align[2],
21371 this.el.addClass('in');
21375 this.hoverState = 'in';
21378 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
21379 this.maskEl.setStyle('z-index', Roo.bootstrap.Popover.zIndex++);
21380 this.maskEl.dom.style.display = 'block';
21381 this.maskEl.addClass('show');
21383 this.el.setStyle('z-index', Roo.bootstrap.Popover.zIndex++);
21385 this.fireEvent('show', this);
21389 * fire this manually after loading a grid in the table for example
21390 * @param {string} (left|right|top|bottom) where to try and put it (use false to use the last one)
21391 * @param {Boolean} try and move it if we cant get right position.
21393 updatePosition : function(placement, try_move)
21395 // allow for calling with no parameters
21396 placement = placement ? placement : this.placement;
21397 try_move = typeof(try_move) == 'undefined' ? true : try_move;
21399 this.el.removeClass([
21400 'fade','top','bottom', 'left', 'right','in',
21401 'bs-popover-top','bs-popover-bottom', 'bs-popover-left', 'bs-popover-right'
21403 this.el.addClass(placement + ' bs-popover-' + placement);
21405 if (!this.alignEl ) {
21409 switch (placement) {
21411 var exact = this.el.getAlignToXY(this.alignEl, 'tl-tr', [10,0]);
21412 var offset = this.el.getAlignToXY(this.alignEl, 'tl-tr?',[10,0]);
21413 if (!try_move || exact.equals(offset) || exact[0] == offset[0] ) {
21414 //normal display... or moved up/down.
21415 this.el.setXY(offset);
21416 var xy = this.alignEl.getAnchorXY('tr', false);
21418 this.arrowEl.setXY(xy);
21421 // continue through...
21422 return this.updatePosition('left', false);
21426 var exact = this.el.getAlignToXY(this.alignEl, 'tr-tl', [-10,0]);
21427 var offset = this.el.getAlignToXY(this.alignEl, 'tr-tl?',[-10,0]);
21428 if (!try_move || exact.equals(offset) || exact[0] == offset[0] ) {
21429 //normal display... or moved up/down.
21430 this.el.setXY(offset);
21431 var xy = this.alignEl.getAnchorXY('tl', false);
21432 xy[0]-=10;xy[1]+=5; // << fix me
21433 this.arrowEl.setXY(xy);
21437 return this.updatePosition('right', false);
21440 var exact = this.el.getAlignToXY(this.alignEl, 'b-t', [0,-10]);
21441 var offset = this.el.getAlignToXY(this.alignEl, 'b-t?',[0,-10]);
21442 if (!try_move || exact.equals(offset) || exact[1] == offset[1] ) {
21443 //normal display... or moved up/down.
21444 this.el.setXY(offset);
21445 var xy = this.alignEl.getAnchorXY('t', false);
21446 xy[1]-=10; // << fix me
21447 this.arrowEl.setXY(xy);
21451 return this.updatePosition('bottom', false);
21454 var exact = this.el.getAlignToXY(this.alignEl, 't-b', [0,10]);
21455 var offset = this.el.getAlignToXY(this.alignEl, 't-b?',[0,10]);
21456 if (!try_move || exact.equals(offset) || exact[1] == offset[1] ) {
21457 //normal display... or moved up/down.
21458 this.el.setXY(offset);
21459 var xy = this.alignEl.getAnchorXY('b', false);
21460 xy[1]+=2; // << fix me
21461 this.arrowEl.setXY(xy);
21465 return this.updatePosition('top', false);
21476 this.el.setXY([0,0]);
21477 this.el.removeClass('in');
21479 this.hoverState = null;
21480 this.maskEl.hide(); // always..
21481 this.fireEvent('hide', this);
21487 Roo.apply(Roo.bootstrap.Popover, {
21490 'left' : ['r-l', [-10,0], 'left bs-popover-left'],
21491 'right' : ['l-br', [10,0], 'right bs-popover-right'],
21492 'bottom' : ['t-b', [0,10], 'top bs-popover-top'],
21493 'top' : [ 'b-t', [0,-10], 'bottom bs-popover-bottom']
21498 clickHander : false,
21502 onMouseDown : function(e)
21504 if (this.popups.length && !e.getTarget(".roo-popover")) {
21505 /// what is nothing is showing..
21514 register : function(popup)
21516 if (!Roo.bootstrap.Popover.clickHandler) {
21517 Roo.bootstrap.Popover.clickHandler = Roo.get(document).on("mousedown", Roo.bootstrap.Popover.onMouseDown, Roo.bootstrap.Popover);
21519 // hide other popups.
21520 popup.on('show', Roo.bootstrap.Popover.onShow, popup);
21521 popup.on('hide', Roo.bootstrap.Popover.onHide, popup);
21522 this.hideAll(); //<< why?
21523 //this.popups.push(popup);
21525 hideAll : function()
21527 this.popups.forEach(function(p) {
21531 onShow : function() {
21532 Roo.bootstrap.Popover.popups.push(this);
21534 onHide : function() {
21535 Roo.bootstrap.Popover.popups.remove(this);
21541 * Card header - holder for the card header elements.
21546 * @class Roo.bootstrap.PopoverNav
21547 * @extends Roo.bootstrap.NavGroup
21548 * Bootstrap Popover header navigation class
21550 * Create a new Popover Header Navigation
21551 * @param {Object} config The config object
21554 Roo.bootstrap.PopoverNav = function(config){
21555 Roo.bootstrap.PopoverNav.superclass.constructor.call(this, config);
21558 Roo.extend(Roo.bootstrap.PopoverNav, Roo.bootstrap.NavSimplebar, {
21561 container_method : 'getPopoverHeader'
21579 * @class Roo.bootstrap.Progress
21580 * @extends Roo.bootstrap.Component
21581 * Bootstrap Progress class
21582 * @cfg {Boolean} striped striped of the progress bar
21583 * @cfg {Boolean} active animated of the progress bar
21587 * Create a new Progress
21588 * @param {Object} config The config object
21591 Roo.bootstrap.Progress = function(config){
21592 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
21595 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
21600 getAutoCreate : function(){
21608 cfg.cls += ' progress-striped';
21612 cfg.cls += ' active';
21631 * @class Roo.bootstrap.ProgressBar
21632 * @extends Roo.bootstrap.Component
21633 * Bootstrap ProgressBar class
21634 * @cfg {Number} aria_valuenow aria-value now
21635 * @cfg {Number} aria_valuemin aria-value min
21636 * @cfg {Number} aria_valuemax aria-value max
21637 * @cfg {String} label label for the progress bar
21638 * @cfg {String} panel (success | info | warning | danger )
21639 * @cfg {String} role role of the progress bar
21640 * @cfg {String} sr_only text
21644 * Create a new ProgressBar
21645 * @param {Object} config The config object
21648 Roo.bootstrap.ProgressBar = function(config){
21649 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
21652 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
21656 aria_valuemax : 100,
21662 getAutoCreate : function()
21667 cls: 'progress-bar',
21668 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
21680 cfg.role = this.role;
21683 if(this.aria_valuenow){
21684 cfg['aria-valuenow'] = this.aria_valuenow;
21687 if(this.aria_valuemin){
21688 cfg['aria-valuemin'] = this.aria_valuemin;
21691 if(this.aria_valuemax){
21692 cfg['aria-valuemax'] = this.aria_valuemax;
21695 if(this.label && !this.sr_only){
21696 cfg.html = this.label;
21700 cfg.cls += ' progress-bar-' + this.panel;
21706 update : function(aria_valuenow)
21708 this.aria_valuenow = aria_valuenow;
21710 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
21725 * @class Roo.bootstrap.TabGroup
21726 * @extends Roo.bootstrap.Column
21727 * Bootstrap Column class
21728 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
21729 * @cfg {Boolean} carousel true to make the group behave like a carousel
21730 * @cfg {Boolean} bullets show bullets for the panels
21731 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
21732 * @cfg {Number} timer auto slide timer .. default 0 millisecond
21733 * @cfg {Boolean} showarrow (true|false) show arrow default true
21736 * Create a new TabGroup
21737 * @param {Object} config The config object
21740 Roo.bootstrap.TabGroup = function(config){
21741 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
21743 this.navId = Roo.id();
21746 Roo.bootstrap.TabGroup.register(this);
21750 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
21753 transition : false,
21758 slideOnTouch : false,
21761 getAutoCreate : function()
21763 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
21765 cfg.cls += ' tab-content';
21767 if (this.carousel) {
21768 cfg.cls += ' carousel slide';
21771 cls : 'carousel-inner',
21775 if(this.bullets && !Roo.isTouch){
21778 cls : 'carousel-bullets',
21782 if(this.bullets_cls){
21783 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
21790 cfg.cn[0].cn.push(bullets);
21793 if(this.showarrow){
21794 cfg.cn[0].cn.push({
21796 class : 'carousel-arrow',
21800 class : 'carousel-prev',
21804 class : 'fa fa-chevron-left'
21810 class : 'carousel-next',
21814 class : 'fa fa-chevron-right'
21827 initEvents: function()
21829 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
21830 // this.el.on("touchstart", this.onTouchStart, this);
21833 if(this.autoslide){
21836 this.slideFn = window.setInterval(function() {
21837 _this.showPanelNext();
21841 if(this.showarrow){
21842 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
21843 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
21849 // onTouchStart : function(e, el, o)
21851 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
21855 // this.showPanelNext();
21859 getChildContainer : function()
21861 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
21865 * register a Navigation item
21866 * @param {Roo.bootstrap.NavItem} the navitem to add
21868 register : function(item)
21870 this.tabs.push( item);
21871 item.navId = this.navId; // not really needed..
21876 getActivePanel : function()
21879 Roo.each(this.tabs, function(t) {
21889 getPanelByName : function(n)
21892 Roo.each(this.tabs, function(t) {
21893 if (t.tabId == n) {
21901 indexOfPanel : function(p)
21904 Roo.each(this.tabs, function(t,i) {
21905 if (t.tabId == p.tabId) {
21914 * show a specific panel
21915 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
21916 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
21918 showPanel : function (pan)
21920 if(this.transition || typeof(pan) == 'undefined'){
21921 Roo.log("waiting for the transitionend");
21925 if (typeof(pan) == 'number') {
21926 pan = this.tabs[pan];
21929 if (typeof(pan) == 'string') {
21930 pan = this.getPanelByName(pan);
21933 var cur = this.getActivePanel();
21936 Roo.log('pan or acitve pan is undefined');
21940 if (pan.tabId == this.getActivePanel().tabId) {
21944 if (false === cur.fireEvent('beforedeactivate')) {
21948 if(this.bullets > 0 && !Roo.isTouch){
21949 this.setActiveBullet(this.indexOfPanel(pan));
21952 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
21954 //class="carousel-item carousel-item-next carousel-item-left"
21956 this.transition = true;
21957 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
21958 var lr = dir == 'next' ? 'left' : 'right';
21959 pan.el.addClass(dir); // or prev
21960 pan.el.addClass('carousel-item-' + dir); // or prev
21961 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
21962 cur.el.addClass(lr); // or right
21963 pan.el.addClass(lr);
21964 cur.el.addClass('carousel-item-' +lr); // or right
21965 pan.el.addClass('carousel-item-' +lr);
21969 cur.el.on('transitionend', function() {
21970 Roo.log("trans end?");
21972 pan.el.removeClass([lr,dir, 'carousel-item-' + lr, 'carousel-item-' + dir]);
21973 pan.setActive(true);
21975 cur.el.removeClass([lr, 'carousel-item-' + lr]);
21976 cur.setActive(false);
21978 _this.transition = false;
21980 }, this, { single: true } );
21985 cur.setActive(false);
21986 pan.setActive(true);
21991 showPanelNext : function()
21993 var i = this.indexOfPanel(this.getActivePanel());
21995 if (i >= this.tabs.length - 1 && !this.autoslide) {
21999 if (i >= this.tabs.length - 1 && this.autoslide) {
22003 this.showPanel(this.tabs[i+1]);
22006 showPanelPrev : function()
22008 var i = this.indexOfPanel(this.getActivePanel());
22010 if (i < 1 && !this.autoslide) {
22014 if (i < 1 && this.autoslide) {
22015 i = this.tabs.length;
22018 this.showPanel(this.tabs[i-1]);
22022 addBullet: function()
22024 if(!this.bullets || Roo.isTouch){
22027 var ctr = this.el.select('.carousel-bullets',true).first();
22028 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
22029 var bullet = ctr.createChild({
22030 cls : 'bullet bullet-' + i
22031 },ctr.dom.lastChild);
22036 bullet.on('click', (function(e, el, o, ii, t){
22038 e.preventDefault();
22040 this.showPanel(ii);
22042 if(this.autoslide && this.slideFn){
22043 clearInterval(this.slideFn);
22044 this.slideFn = window.setInterval(function() {
22045 _this.showPanelNext();
22049 }).createDelegate(this, [i, bullet], true));
22054 setActiveBullet : function(i)
22060 Roo.each(this.el.select('.bullet', true).elements, function(el){
22061 el.removeClass('selected');
22064 var bullet = this.el.select('.bullet-' + i, true).first();
22070 bullet.addClass('selected');
22081 Roo.apply(Roo.bootstrap.TabGroup, {
22085 * register a Navigation Group
22086 * @param {Roo.bootstrap.NavGroup} the navgroup to add
22088 register : function(navgrp)
22090 this.groups[navgrp.navId] = navgrp;
22094 * fetch a Navigation Group based on the navigation ID
22095 * if one does not exist , it will get created.
22096 * @param {string} the navgroup to add
22097 * @returns {Roo.bootstrap.NavGroup} the navgroup
22099 get: function(navId) {
22100 if (typeof(this.groups[navId]) == 'undefined') {
22101 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
22103 return this.groups[navId] ;
22118 * @class Roo.bootstrap.TabPanel
22119 * @extends Roo.bootstrap.Component
22120 * Bootstrap TabPanel class
22121 * @cfg {Boolean} active panel active
22122 * @cfg {String} html panel content
22123 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
22124 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
22125 * @cfg {String} href click to link..
22126 * @cfg {Boolean} touchSlide if swiping slides tab to next panel (default off)
22130 * Create a new TabPanel
22131 * @param {Object} config The config object
22134 Roo.bootstrap.TabPanel = function(config){
22135 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
22139 * Fires when the active status changes
22140 * @param {Roo.bootstrap.TabPanel} this
22141 * @param {Boolean} state the new state
22146 * @event beforedeactivate
22147 * Fires before a tab is de-activated - can be used to do validation on a form.
22148 * @param {Roo.bootstrap.TabPanel} this
22149 * @return {Boolean} false if there is an error
22152 'beforedeactivate': true
22155 this.tabId = this.tabId || Roo.id();
22159 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
22166 touchSlide : false,
22167 getAutoCreate : function(){
22172 // item is needed for carousel - not sure if it has any effect otherwise
22173 cls: 'carousel-item tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
22174 html: this.html || ''
22178 cfg.cls += ' active';
22182 cfg.tabId = this.tabId;
22190 initEvents: function()
22192 var p = this.parent();
22194 this.navId = this.navId || p.navId;
22196 if (typeof(this.navId) != 'undefined') {
22197 // not really needed.. but just in case.. parent should be a NavGroup.
22198 var tg = Roo.bootstrap.TabGroup.get(this.navId);
22202 var i = tg.tabs.length - 1;
22204 if(this.active && tg.bullets > 0 && i < tg.bullets){
22205 tg.setActiveBullet(i);
22209 this.el.on('click', this.onClick, this);
22211 if(Roo.isTouch && this.touchSlide){
22212 this.el.on("touchstart", this.onTouchStart, this);
22213 this.el.on("touchmove", this.onTouchMove, this);
22214 this.el.on("touchend", this.onTouchEnd, this);
22219 onRender : function(ct, position)
22221 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
22224 setActive : function(state)
22226 Roo.log("panel - set active " + this.tabId + "=" + state);
22228 this.active = state;
22230 this.el.removeClass('active');
22232 } else if (!this.el.hasClass('active')) {
22233 this.el.addClass('active');
22236 this.fireEvent('changed', this, state);
22239 onClick : function(e)
22241 e.preventDefault();
22243 if(!this.href.length){
22247 window.location.href = this.href;
22256 onTouchStart : function(e)
22258 this.swiping = false;
22260 this.startX = e.browserEvent.touches[0].clientX;
22261 this.startY = e.browserEvent.touches[0].clientY;
22264 onTouchMove : function(e)
22266 this.swiping = true;
22268 this.endX = e.browserEvent.touches[0].clientX;
22269 this.endY = e.browserEvent.touches[0].clientY;
22272 onTouchEnd : function(e)
22279 var tabGroup = this.parent();
22281 if(this.endX > this.startX){ // swiping right
22282 tabGroup.showPanelPrev();
22286 if(this.startX > this.endX){ // swiping left
22287 tabGroup.showPanelNext();
22306 * @class Roo.bootstrap.DateField
22307 * @extends Roo.bootstrap.Input
22308 * Bootstrap DateField class
22309 * @cfg {Number} weekStart default 0
22310 * @cfg {String} viewMode default empty, (months|years)
22311 * @cfg {String} minViewMode default empty, (months|years)
22312 * @cfg {Number} startDate default -Infinity
22313 * @cfg {Number} endDate default Infinity
22314 * @cfg {Boolean} todayHighlight default false
22315 * @cfg {Boolean} todayBtn default false
22316 * @cfg {Boolean} calendarWeeks default false
22317 * @cfg {Object} daysOfWeekDisabled default empty
22318 * @cfg {Boolean} singleMode default false (true | false)
22320 * @cfg {Boolean} keyboardNavigation default true
22321 * @cfg {String} language default en
22324 * Create a new DateField
22325 * @param {Object} config The config object
22328 Roo.bootstrap.DateField = function(config){
22329 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
22333 * Fires when this field show.
22334 * @param {Roo.bootstrap.DateField} this
22335 * @param {Mixed} date The date value
22340 * Fires when this field hide.
22341 * @param {Roo.bootstrap.DateField} this
22342 * @param {Mixed} date The date value
22347 * Fires when select a date.
22348 * @param {Roo.bootstrap.DateField} this
22349 * @param {Mixed} date The date value
22353 * @event beforeselect
22354 * Fires when before select a date.
22355 * @param {Roo.bootstrap.DateField} this
22356 * @param {Mixed} date The date value
22358 beforeselect : true
22362 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
22365 * @cfg {String} format
22366 * The default date format string which can be overriden for localization support. The format must be
22367 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
22371 * @cfg {String} altFormats
22372 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
22373 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
22375 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
22383 todayHighlight : false,
22389 keyboardNavigation: true,
22391 calendarWeeks: false,
22393 startDate: -Infinity,
22397 daysOfWeekDisabled: [],
22401 singleMode : false,
22403 UTCDate: function()
22405 return new Date(Date.UTC.apply(Date, arguments));
22408 UTCToday: function()
22410 var today = new Date();
22411 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
22414 getDate: function() {
22415 var d = this.getUTCDate();
22416 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
22419 getUTCDate: function() {
22423 setDate: function(d) {
22424 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
22427 setUTCDate: function(d) {
22429 this.setValue(this.formatDate(this.date));
22432 onRender: function(ct, position)
22435 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
22437 this.language = this.language || 'en';
22438 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
22439 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
22441 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
22442 this.format = this.format || 'm/d/y';
22443 this.isInline = false;
22444 this.isInput = true;
22445 this.component = this.el.select('.add-on', true).first() || false;
22446 this.component = (this.component && this.component.length === 0) ? false : this.component;
22447 this.hasInput = this.component && this.inputEl().length;
22449 if (typeof(this.minViewMode === 'string')) {
22450 switch (this.minViewMode) {
22452 this.minViewMode = 1;
22455 this.minViewMode = 2;
22458 this.minViewMode = 0;
22463 if (typeof(this.viewMode === 'string')) {
22464 switch (this.viewMode) {
22477 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
22479 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
22481 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
22483 this.picker().on('mousedown', this.onMousedown, this);
22484 this.picker().on('click', this.onClick, this);
22486 this.picker().addClass('datepicker-dropdown');
22488 this.startViewMode = this.viewMode;
22490 if(this.singleMode){
22491 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
22492 v.setVisibilityMode(Roo.Element.DISPLAY);
22496 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
22497 v.setStyle('width', '189px');
22501 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
22502 if(!this.calendarWeeks){
22507 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
22508 v.attr('colspan', function(i, val){
22509 return parseInt(val) + 1;
22514 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
22516 this.setStartDate(this.startDate);
22517 this.setEndDate(this.endDate);
22519 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
22526 if(this.isInline) {
22531 picker : function()
22533 return this.pickerEl;
22534 // return this.el.select('.datepicker', true).first();
22537 fillDow: function()
22539 var dowCnt = this.weekStart;
22548 if(this.calendarWeeks){
22556 while (dowCnt < this.weekStart + 7) {
22560 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
22564 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
22567 fillMonths: function()
22570 var months = this.picker().select('>.datepicker-months td', true).first();
22572 months.dom.innerHTML = '';
22578 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
22581 months.createChild(month);
22588 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;
22590 if (this.date < this.startDate) {
22591 this.viewDate = new Date(this.startDate);
22592 } else if (this.date > this.endDate) {
22593 this.viewDate = new Date(this.endDate);
22595 this.viewDate = new Date(this.date);
22603 var d = new Date(this.viewDate),
22604 year = d.getUTCFullYear(),
22605 month = d.getUTCMonth(),
22606 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
22607 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
22608 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
22609 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
22610 currentDate = this.date && this.date.valueOf(),
22611 today = this.UTCToday();
22613 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
22615 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
22617 // this.picker.select('>tfoot th.today').
22618 // .text(dates[this.language].today)
22619 // .toggle(this.todayBtn !== false);
22621 this.updateNavArrows();
22624 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
22626 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
22628 prevMonth.setUTCDate(day);
22630 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
22632 var nextMonth = new Date(prevMonth);
22634 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
22636 nextMonth = nextMonth.valueOf();
22638 var fillMonths = false;
22640 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
22642 while(prevMonth.valueOf() <= nextMonth) {
22645 if (prevMonth.getUTCDay() === this.weekStart) {
22647 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
22655 if(this.calendarWeeks){
22656 // ISO 8601: First week contains first thursday.
22657 // ISO also states week starts on Monday, but we can be more abstract here.
22659 // Start of current week: based on weekstart/current date
22660 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
22661 // Thursday of this week
22662 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
22663 // First Thursday of year, year from thursday
22664 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
22665 // Calendar week: ms between thursdays, div ms per day, div 7 days
22666 calWeek = (th - yth) / 864e5 / 7 + 1;
22668 fillMonths.cn.push({
22676 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
22678 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
22681 if (this.todayHighlight &&
22682 prevMonth.getUTCFullYear() == today.getFullYear() &&
22683 prevMonth.getUTCMonth() == today.getMonth() &&
22684 prevMonth.getUTCDate() == today.getDate()) {
22685 clsName += ' today';
22688 if (currentDate && prevMonth.valueOf() === currentDate) {
22689 clsName += ' active';
22692 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
22693 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
22694 clsName += ' disabled';
22697 fillMonths.cn.push({
22699 cls: 'day ' + clsName,
22700 html: prevMonth.getDate()
22703 prevMonth.setDate(prevMonth.getDate()+1);
22706 var currentYear = this.date && this.date.getUTCFullYear();
22707 var currentMonth = this.date && this.date.getUTCMonth();
22709 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
22711 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
22712 v.removeClass('active');
22714 if(currentYear === year && k === currentMonth){
22715 v.addClass('active');
22718 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
22719 v.addClass('disabled');
22725 year = parseInt(year/10, 10) * 10;
22727 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
22729 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
22732 for (var i = -1; i < 11; i++) {
22733 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
22735 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
22743 showMode: function(dir)
22746 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
22749 Roo.each(this.picker().select('>div',true).elements, function(v){
22750 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
22753 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
22758 if(this.isInline) {
22762 this.picker().removeClass(['bottom', 'top']);
22764 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
22766 * place to the top of element!
22770 this.picker().addClass('top');
22771 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
22776 this.picker().addClass('bottom');
22778 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
22781 parseDate : function(value)
22783 if(!value || value instanceof Date){
22786 var v = Date.parseDate(value, this.format);
22787 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
22788 v = Date.parseDate(value, 'Y-m-d');
22790 if(!v && this.altFormats){
22791 if(!this.altFormatsArray){
22792 this.altFormatsArray = this.altFormats.split("|");
22794 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
22795 v = Date.parseDate(value, this.altFormatsArray[i]);
22801 formatDate : function(date, fmt)
22803 return (!date || !(date instanceof Date)) ?
22804 date : date.dateFormat(fmt || this.format);
22807 onFocus : function()
22809 Roo.bootstrap.DateField.superclass.onFocus.call(this);
22813 onBlur : function()
22815 Roo.bootstrap.DateField.superclass.onBlur.call(this);
22817 var d = this.inputEl().getValue();
22824 showPopup : function()
22826 this.picker().show();
22830 this.fireEvent('showpopup', this, this.date);
22833 hidePopup : function()
22835 if(this.isInline) {
22838 this.picker().hide();
22839 this.viewMode = this.startViewMode;
22842 this.fireEvent('hidepopup', this, this.date);
22846 onMousedown: function(e)
22848 e.stopPropagation();
22849 e.preventDefault();
22854 Roo.bootstrap.DateField.superclass.keyup.call(this);
22858 setValue: function(v)
22860 if(this.fireEvent('beforeselect', this, v) !== false){
22861 var d = new Date(this.parseDate(v) ).clearTime();
22863 if(isNaN(d.getTime())){
22864 this.date = this.viewDate = '';
22865 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
22869 v = this.formatDate(d);
22871 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
22873 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
22877 this.fireEvent('select', this, this.date);
22881 getValue: function()
22883 return this.formatDate(this.date);
22886 fireKey: function(e)
22888 if (!this.picker().isVisible()){
22889 if (e.keyCode == 27) { // allow escape to hide and re-show picker
22895 var dateChanged = false,
22897 newDate, newViewDate;
22902 e.preventDefault();
22906 if (!this.keyboardNavigation) {
22909 dir = e.keyCode == 37 ? -1 : 1;
22912 newDate = this.moveYear(this.date, dir);
22913 newViewDate = this.moveYear(this.viewDate, dir);
22914 } else if (e.shiftKey){
22915 newDate = this.moveMonth(this.date, dir);
22916 newViewDate = this.moveMonth(this.viewDate, dir);
22918 newDate = new Date(this.date);
22919 newDate.setUTCDate(this.date.getUTCDate() + dir);
22920 newViewDate = new Date(this.viewDate);
22921 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
22923 if (this.dateWithinRange(newDate)){
22924 this.date = newDate;
22925 this.viewDate = newViewDate;
22926 this.setValue(this.formatDate(this.date));
22928 e.preventDefault();
22929 dateChanged = true;
22934 if (!this.keyboardNavigation) {
22937 dir = e.keyCode == 38 ? -1 : 1;
22939 newDate = this.moveYear(this.date, dir);
22940 newViewDate = this.moveYear(this.viewDate, dir);
22941 } else if (e.shiftKey){
22942 newDate = this.moveMonth(this.date, dir);
22943 newViewDate = this.moveMonth(this.viewDate, dir);
22945 newDate = new Date(this.date);
22946 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
22947 newViewDate = new Date(this.viewDate);
22948 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
22950 if (this.dateWithinRange(newDate)){
22951 this.date = newDate;
22952 this.viewDate = newViewDate;
22953 this.setValue(this.formatDate(this.date));
22955 e.preventDefault();
22956 dateChanged = true;
22960 this.setValue(this.formatDate(this.date));
22962 e.preventDefault();
22965 this.setValue(this.formatDate(this.date));
22979 onClick: function(e)
22981 e.stopPropagation();
22982 e.preventDefault();
22984 var target = e.getTarget();
22986 if(target.nodeName.toLowerCase() === 'i'){
22987 target = Roo.get(target).dom.parentNode;
22990 var nodeName = target.nodeName;
22991 var className = target.className;
22992 var html = target.innerHTML;
22993 //Roo.log(nodeName);
22995 switch(nodeName.toLowerCase()) {
22997 switch(className) {
23003 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
23004 switch(this.viewMode){
23006 this.viewDate = this.moveMonth(this.viewDate, dir);
23010 this.viewDate = this.moveYear(this.viewDate, dir);
23016 var date = new Date();
23017 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
23019 this.setValue(this.formatDate(this.date));
23026 if (className.indexOf('disabled') < 0) {
23027 if (!this.viewDate) {
23028 this.viewDate = new Date();
23030 this.viewDate.setUTCDate(1);
23031 if (className.indexOf('month') > -1) {
23032 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
23034 var year = parseInt(html, 10) || 0;
23035 this.viewDate.setUTCFullYear(year);
23039 if(this.singleMode){
23040 this.setValue(this.formatDate(this.viewDate));
23051 //Roo.log(className);
23052 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
23053 var day = parseInt(html, 10) || 1;
23054 var year = (this.viewDate || new Date()).getUTCFullYear(),
23055 month = (this.viewDate || new Date()).getUTCMonth();
23057 if (className.indexOf('old') > -1) {
23064 } else if (className.indexOf('new') > -1) {
23072 //Roo.log([year,month,day]);
23073 this.date = this.UTCDate(year, month, day,0,0,0,0);
23074 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
23076 //Roo.log(this.formatDate(this.date));
23077 this.setValue(this.formatDate(this.date));
23084 setStartDate: function(startDate)
23086 this.startDate = startDate || -Infinity;
23087 if (this.startDate !== -Infinity) {
23088 this.startDate = this.parseDate(this.startDate);
23091 this.updateNavArrows();
23094 setEndDate: function(endDate)
23096 this.endDate = endDate || Infinity;
23097 if (this.endDate !== Infinity) {
23098 this.endDate = this.parseDate(this.endDate);
23101 this.updateNavArrows();
23104 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
23106 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
23107 if (typeof(this.daysOfWeekDisabled) !== 'object') {
23108 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
23110 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
23111 return parseInt(d, 10);
23114 this.updateNavArrows();
23117 updateNavArrows: function()
23119 if(this.singleMode){
23123 var d = new Date(this.viewDate),
23124 year = d.getUTCFullYear(),
23125 month = d.getUTCMonth();
23127 Roo.each(this.picker().select('.prev', true).elements, function(v){
23129 switch (this.viewMode) {
23132 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
23138 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
23145 Roo.each(this.picker().select('.next', true).elements, function(v){
23147 switch (this.viewMode) {
23150 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
23156 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
23164 moveMonth: function(date, dir)
23169 var new_date = new Date(date.valueOf()),
23170 day = new_date.getUTCDate(),
23171 month = new_date.getUTCMonth(),
23172 mag = Math.abs(dir),
23174 dir = dir > 0 ? 1 : -1;
23177 // If going back one month, make sure month is not current month
23178 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
23180 return new_date.getUTCMonth() == month;
23182 // If going forward one month, make sure month is as expected
23183 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
23185 return new_date.getUTCMonth() != new_month;
23187 new_month = month + dir;
23188 new_date.setUTCMonth(new_month);
23189 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
23190 if (new_month < 0 || new_month > 11) {
23191 new_month = (new_month + 12) % 12;
23194 // For magnitudes >1, move one month at a time...
23195 for (var i=0; i<mag; i++) {
23196 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
23197 new_date = this.moveMonth(new_date, dir);
23199 // ...then reset the day, keeping it in the new month
23200 new_month = new_date.getUTCMonth();
23201 new_date.setUTCDate(day);
23203 return new_month != new_date.getUTCMonth();
23206 // Common date-resetting loop -- if date is beyond end of month, make it
23209 new_date.setUTCDate(--day);
23210 new_date.setUTCMonth(new_month);
23215 moveYear: function(date, dir)
23217 return this.moveMonth(date, dir*12);
23220 dateWithinRange: function(date)
23222 return date >= this.startDate && date <= this.endDate;
23228 this.picker().remove();
23231 validateValue : function(value)
23233 if(this.getVisibilityEl().hasClass('hidden')){
23237 if(value.length < 1) {
23238 if(this.allowBlank){
23244 if(value.length < this.minLength){
23247 if(value.length > this.maxLength){
23251 var vt = Roo.form.VTypes;
23252 if(!vt[this.vtype](value, this)){
23256 if(typeof this.validator == "function"){
23257 var msg = this.validator(value);
23263 if(this.regex && !this.regex.test(value)){
23267 if(typeof(this.parseDate(value)) == 'undefined'){
23271 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
23275 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
23285 this.date = this.viewDate = '';
23287 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
23292 Roo.apply(Roo.bootstrap.DateField, {
23303 html: '<i class="fa fa-arrow-left"/>'
23313 html: '<i class="fa fa-arrow-right"/>'
23355 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
23356 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
23357 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
23358 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
23359 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
23372 navFnc: 'FullYear',
23377 navFnc: 'FullYear',
23382 Roo.apply(Roo.bootstrap.DateField, {
23386 cls: 'datepicker dropdown-menu roo-dynamic shadow',
23390 cls: 'datepicker-days',
23394 cls: 'table-condensed',
23396 Roo.bootstrap.DateField.head,
23400 Roo.bootstrap.DateField.footer
23407 cls: 'datepicker-months',
23411 cls: 'table-condensed',
23413 Roo.bootstrap.DateField.head,
23414 Roo.bootstrap.DateField.content,
23415 Roo.bootstrap.DateField.footer
23422 cls: 'datepicker-years',
23426 cls: 'table-condensed',
23428 Roo.bootstrap.DateField.head,
23429 Roo.bootstrap.DateField.content,
23430 Roo.bootstrap.DateField.footer
23449 * @class Roo.bootstrap.TimeField
23450 * @extends Roo.bootstrap.Input
23451 * Bootstrap DateField class
23455 * Create a new TimeField
23456 * @param {Object} config The config object
23459 Roo.bootstrap.TimeField = function(config){
23460 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
23464 * Fires when this field show.
23465 * @param {Roo.bootstrap.DateField} thisthis
23466 * @param {Mixed} date The date value
23471 * Fires when this field hide.
23472 * @param {Roo.bootstrap.DateField} this
23473 * @param {Mixed} date The date value
23478 * Fires when select a date.
23479 * @param {Roo.bootstrap.DateField} this
23480 * @param {Mixed} date The date value
23486 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
23489 * @cfg {String} format
23490 * The default time format string which can be overriden for localization support. The format must be
23491 * valid according to {@link Date#parseDate} (defaults to 'H:i').
23495 getAutoCreate : function()
23497 this.after = '<i class="fa far fa-clock"></i>';
23498 return Roo.bootstrap.TimeField.superclass.getAutoCreate.call(this);
23502 onRender: function(ct, position)
23505 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
23507 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.TimeField.template);
23509 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
23511 this.pop = this.picker().select('>.datepicker-time',true).first();
23512 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
23514 this.picker().on('mousedown', this.onMousedown, this);
23515 this.picker().on('click', this.onClick, this);
23517 this.picker().addClass('datepicker-dropdown');
23522 this.pop.select('.hours-up', true).first().on('click', this.onIncrementHours, this);
23523 this.pop.select('.hours-down', true).first().on('click', this.onDecrementHours, this);
23524 this.pop.select('.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
23525 this.pop.select('.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
23526 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
23527 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
23531 fireKey: function(e){
23532 if (!this.picker().isVisible()){
23533 if (e.keyCode == 27) { // allow escape to hide and re-show picker
23539 e.preventDefault();
23547 this.onTogglePeriod();
23550 this.onIncrementMinutes();
23553 this.onDecrementMinutes();
23562 onClick: function(e) {
23563 e.stopPropagation();
23564 e.preventDefault();
23567 picker : function()
23569 return this.pickerEl;
23572 fillTime: function()
23574 var time = this.pop.select('tbody', true).first();
23576 time.dom.innerHTML = '';
23591 cls: 'hours-up fa fas fa-chevron-up'
23611 cls: 'minutes-up fa fas fa-chevron-up'
23632 cls: 'timepicker-hour',
23647 cls: 'timepicker-minute',
23662 cls: 'btn btn-primary period',
23684 cls: 'hours-down fa fas fa-chevron-down'
23704 cls: 'minutes-down fa fas fa-chevron-down'
23722 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
23729 var hours = this.time.getHours();
23730 var minutes = this.time.getMinutes();
23743 hours = hours - 12;
23747 hours = '0' + hours;
23751 minutes = '0' + minutes;
23754 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
23755 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
23756 this.pop.select('button', true).first().dom.innerHTML = period;
23762 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
23764 var cls = ['bottom'];
23766 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
23773 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
23777 //this.picker().setXY(20000,20000);
23778 this.picker().addClass(cls.join('-'));
23782 Roo.each(cls, function(c){
23787 _this.picker().alignTo(_this.inputEl(), "tr-br", [0, 10], false);
23788 //_this.picker().setTop(_this.inputEl().getHeight());
23792 _this.picker().alignTo(_this.inputEl(), "br-tr", [0, 10], false);
23794 //_this.picker().setTop(0 - _this.picker().getHeight());
23799 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
23803 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
23811 onFocus : function()
23813 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
23817 onBlur : function()
23819 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
23825 this.picker().show();
23830 this.fireEvent('show', this, this.date);
23835 this.picker().hide();
23838 this.fireEvent('hide', this, this.date);
23841 setTime : function()
23844 this.setValue(this.time.format(this.format));
23846 this.fireEvent('select', this, this.date);
23851 onMousedown: function(e){
23852 e.stopPropagation();
23853 e.preventDefault();
23856 onIncrementHours: function()
23858 Roo.log('onIncrementHours');
23859 this.time = this.time.add(Date.HOUR, 1);
23864 onDecrementHours: function()
23866 Roo.log('onDecrementHours');
23867 this.time = this.time.add(Date.HOUR, -1);
23871 onIncrementMinutes: function()
23873 Roo.log('onIncrementMinutes');
23874 this.time = this.time.add(Date.MINUTE, 1);
23878 onDecrementMinutes: function()
23880 Roo.log('onDecrementMinutes');
23881 this.time = this.time.add(Date.MINUTE, -1);
23885 onTogglePeriod: function()
23887 Roo.log('onTogglePeriod');
23888 this.time = this.time.add(Date.HOUR, 12);
23896 Roo.apply(Roo.bootstrap.TimeField, {
23900 cls: 'datepicker dropdown-menu',
23904 cls: 'datepicker-time',
23908 cls: 'table-condensed',
23937 cls: 'btn btn-info ok',
23965 * @class Roo.bootstrap.MonthField
23966 * @extends Roo.bootstrap.Input
23967 * Bootstrap MonthField class
23969 * @cfg {String} language default en
23972 * Create a new MonthField
23973 * @param {Object} config The config object
23976 Roo.bootstrap.MonthField = function(config){
23977 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
23982 * Fires when this field show.
23983 * @param {Roo.bootstrap.MonthField} this
23984 * @param {Mixed} date The date value
23989 * Fires when this field hide.
23990 * @param {Roo.bootstrap.MonthField} this
23991 * @param {Mixed} date The date value
23996 * Fires when select a date.
23997 * @param {Roo.bootstrap.MonthField} this
23998 * @param {String} oldvalue The old value
23999 * @param {String} newvalue The new value
24005 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
24007 onRender: function(ct, position)
24010 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
24012 this.language = this.language || 'en';
24013 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
24014 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
24016 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
24017 this.isInline = false;
24018 this.isInput = true;
24019 this.component = this.el.select('.add-on', true).first() || false;
24020 this.component = (this.component && this.component.length === 0) ? false : this.component;
24021 this.hasInput = this.component && this.inputEL().length;
24023 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
24025 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
24027 this.picker().on('mousedown', this.onMousedown, this);
24028 this.picker().on('click', this.onClick, this);
24030 this.picker().addClass('datepicker-dropdown');
24032 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
24033 v.setStyle('width', '189px');
24040 if(this.isInline) {
24046 setValue: function(v, suppressEvent)
24048 var o = this.getValue();
24050 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
24054 if(suppressEvent !== true){
24055 this.fireEvent('select', this, o, v);
24060 getValue: function()
24065 onClick: function(e)
24067 e.stopPropagation();
24068 e.preventDefault();
24070 var target = e.getTarget();
24072 if(target.nodeName.toLowerCase() === 'i'){
24073 target = Roo.get(target).dom.parentNode;
24076 var nodeName = target.nodeName;
24077 var className = target.className;
24078 var html = target.innerHTML;
24080 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
24084 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
24086 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
24092 picker : function()
24094 return this.pickerEl;
24097 fillMonths: function()
24100 var months = this.picker().select('>.datepicker-months td', true).first();
24102 months.dom.innerHTML = '';
24108 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
24111 months.createChild(month);
24120 if(typeof(this.vIndex) == 'undefined' && this.value.length){
24121 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
24124 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
24125 e.removeClass('active');
24127 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
24128 e.addClass('active');
24135 if(this.isInline) {
24139 this.picker().removeClass(['bottom', 'top']);
24141 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
24143 * place to the top of element!
24147 this.picker().addClass('top');
24148 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
24153 this.picker().addClass('bottom');
24155 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
24158 onFocus : function()
24160 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
24164 onBlur : function()
24166 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
24168 var d = this.inputEl().getValue();
24177 this.picker().show();
24178 this.picker().select('>.datepicker-months', true).first().show();
24182 this.fireEvent('show', this, this.date);
24187 if(this.isInline) {
24190 this.picker().hide();
24191 this.fireEvent('hide', this, this.date);
24195 onMousedown: function(e)
24197 e.stopPropagation();
24198 e.preventDefault();
24203 Roo.bootstrap.MonthField.superclass.keyup.call(this);
24207 fireKey: function(e)
24209 if (!this.picker().isVisible()){
24210 if (e.keyCode == 27) {// allow escape to hide and re-show picker
24221 e.preventDefault();
24225 dir = e.keyCode == 37 ? -1 : 1;
24227 this.vIndex = this.vIndex + dir;
24229 if(this.vIndex < 0){
24233 if(this.vIndex > 11){
24237 if(isNaN(this.vIndex)){
24241 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
24247 dir = e.keyCode == 38 ? -1 : 1;
24249 this.vIndex = this.vIndex + dir * 4;
24251 if(this.vIndex < 0){
24255 if(this.vIndex > 11){
24259 if(isNaN(this.vIndex)){
24263 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
24268 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
24269 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
24273 e.preventDefault();
24276 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
24277 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
24293 this.picker().remove();
24298 Roo.apply(Roo.bootstrap.MonthField, {
24317 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
24318 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
24323 Roo.apply(Roo.bootstrap.MonthField, {
24327 cls: 'datepicker dropdown-menu roo-dynamic',
24331 cls: 'datepicker-months',
24335 cls: 'table-condensed',
24337 Roo.bootstrap.DateField.content
24357 * @class Roo.bootstrap.CheckBox
24358 * @extends Roo.bootstrap.Input
24359 * Bootstrap CheckBox class
24361 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
24362 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
24363 * @cfg {String} boxLabel The text that appears beside the checkbox
24364 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
24365 * @cfg {Boolean} checked initnal the element
24366 * @cfg {Boolean} inline inline the element (default false)
24367 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
24368 * @cfg {String} tooltip label tooltip
24371 * Create a new CheckBox
24372 * @param {Object} config The config object
24375 Roo.bootstrap.CheckBox = function(config){
24376 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
24381 * Fires when the element is checked or unchecked.
24382 * @param {Roo.bootstrap.CheckBox} this This input
24383 * @param {Boolean} checked The new checked value
24388 * Fires when the element is click.
24389 * @param {Roo.bootstrap.CheckBox} this This input
24396 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
24398 inputType: 'checkbox',
24407 // checkbox success does not make any sense really..
24412 getAutoCreate : function()
24414 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
24420 cfg.cls = 'form-group form-check ' + this.inputType; //input-group
24423 cfg.cls += ' ' + this.inputType + '-inline form-check-inline';
24429 type : this.inputType,
24430 value : this.inputValue,
24431 cls : 'roo-' + this.inputType, //'form-box',
24432 placeholder : this.placeholder || ''
24436 if(this.inputType != 'radio'){
24440 cls : 'roo-hidden-value',
24441 value : this.checked ? this.inputValue : this.valueOff
24446 if (this.weight) { // Validity check?
24447 cfg.cls += " " + this.inputType + "-" + this.weight;
24450 if (this.disabled) {
24451 input.disabled=true;
24455 input.checked = this.checked;
24460 input.name = this.name;
24462 if(this.inputType != 'radio'){
24463 hidden.name = this.name;
24464 input.name = '_hidden_' + this.name;
24469 input.cls += ' input-' + this.size;
24474 ['xs','sm','md','lg'].map(function(size){
24475 if (settings[size]) {
24476 cfg.cls += ' col-' + size + '-' + settings[size];
24480 var inputblock = input;
24482 if (this.before || this.after) {
24485 cls : 'input-group',
24490 inputblock.cn.push({
24492 cls : 'input-group-addon',
24497 inputblock.cn.push(input);
24499 if(this.inputType != 'radio'){
24500 inputblock.cn.push(hidden);
24504 inputblock.cn.push({
24506 cls : 'input-group-addon',
24512 var boxLabelCfg = false;
24518 //'for': id, // box label is handled by onclick - so no for...
24520 html: this.boxLabel
24523 boxLabelCfg.tooltip = this.tooltip;
24529 if (align ==='left' && this.fieldLabel.length) {
24530 // Roo.log("left and has label");
24535 cls : 'control-label',
24536 html : this.fieldLabel
24547 cfg.cn[1].cn.push(boxLabelCfg);
24550 if(this.labelWidth > 12){
24551 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
24554 if(this.labelWidth < 13 && this.labelmd == 0){
24555 this.labelmd = this.labelWidth;
24558 if(this.labellg > 0){
24559 cfg.cn[0].cls += ' col-lg-' + this.labellg;
24560 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
24563 if(this.labelmd > 0){
24564 cfg.cn[0].cls += ' col-md-' + this.labelmd;
24565 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
24568 if(this.labelsm > 0){
24569 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
24570 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
24573 if(this.labelxs > 0){
24574 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
24575 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
24578 } else if ( this.fieldLabel.length) {
24579 // Roo.log(" label");
24583 tag: this.boxLabel ? 'span' : 'label',
24585 cls: 'control-label box-input-label',
24586 //cls : 'input-group-addon',
24587 html : this.fieldLabel
24594 cfg.cn.push(boxLabelCfg);
24599 // Roo.log(" no label && no align");
24600 cfg.cn = [ inputblock ] ;
24602 cfg.cn.push(boxLabelCfg);
24610 if(this.inputType != 'radio'){
24611 cfg.cn.push(hidden);
24619 * return the real input element.
24621 inputEl: function ()
24623 return this.el.select('input.roo-' + this.inputType,true).first();
24625 hiddenEl: function ()
24627 return this.el.select('input.roo-hidden-value',true).first();
24630 labelEl: function()
24632 return this.el.select('label.control-label',true).first();
24634 /* depricated... */
24638 return this.labelEl();
24641 boxLabelEl: function()
24643 return this.el.select('label.box-label',true).first();
24646 initEvents : function()
24648 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
24650 this.inputEl().on('click', this.onClick, this);
24652 if (this.boxLabel) {
24653 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
24656 this.startValue = this.getValue();
24659 Roo.bootstrap.CheckBox.register(this);
24663 onClick : function(e)
24665 if(this.fireEvent('click', this, e) !== false){
24666 this.setChecked(!this.checked);
24671 setChecked : function(state,suppressEvent)
24673 this.startValue = this.getValue();
24675 if(this.inputType == 'radio'){
24677 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
24678 e.dom.checked = false;
24681 this.inputEl().dom.checked = true;
24683 this.inputEl().dom.value = this.inputValue;
24685 if(suppressEvent !== true){
24686 this.fireEvent('check', this, true);
24694 this.checked = state;
24696 this.inputEl().dom.checked = state;
24699 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
24701 if(suppressEvent !== true){
24702 this.fireEvent('check', this, state);
24708 getValue : function()
24710 if(this.inputType == 'radio'){
24711 return this.getGroupValue();
24714 return this.hiddenEl().dom.value;
24718 getGroupValue : function()
24720 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
24724 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
24727 setValue : function(v,suppressEvent)
24729 if(this.inputType == 'radio'){
24730 this.setGroupValue(v, suppressEvent);
24734 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
24739 setGroupValue : function(v, suppressEvent)
24741 this.startValue = this.getValue();
24743 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
24744 e.dom.checked = false;
24746 if(e.dom.value == v){
24747 e.dom.checked = true;
24751 if(suppressEvent !== true){
24752 this.fireEvent('check', this, true);
24760 validate : function()
24762 if(this.getVisibilityEl().hasClass('hidden')){
24768 (this.inputType == 'radio' && this.validateRadio()) ||
24769 (this.inputType == 'checkbox' && this.validateCheckbox())
24775 this.markInvalid();
24779 validateRadio : function()
24781 if(this.getVisibilityEl().hasClass('hidden')){
24785 if(this.allowBlank){
24791 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
24792 if(!e.dom.checked){
24804 validateCheckbox : function()
24807 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
24808 //return (this.getValue() == this.inputValue) ? true : false;
24811 var group = Roo.bootstrap.CheckBox.get(this.groupId);
24819 for(var i in group){
24820 if(group[i].el.isVisible(true)){
24828 for(var i in group){
24833 r = (group[i].getValue() == group[i].inputValue) ? true : false;
24840 * Mark this field as valid
24842 markValid : function()
24846 this.fireEvent('valid', this);
24848 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
24851 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
24858 if(this.inputType == 'radio'){
24859 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
24860 var fg = e.findParent('.form-group', false, true);
24861 if (Roo.bootstrap.version == 3) {
24862 fg.removeClass([_this.invalidClass, _this.validClass]);
24863 fg.addClass(_this.validClass);
24865 fg.removeClass(['is-valid', 'is-invalid']);
24866 fg.addClass('is-valid');
24874 var fg = this.el.findParent('.form-group', false, true);
24875 if (Roo.bootstrap.version == 3) {
24876 fg.removeClass([this.invalidClass, this.validClass]);
24877 fg.addClass(this.validClass);
24879 fg.removeClass(['is-valid', 'is-invalid']);
24880 fg.addClass('is-valid');
24885 var group = Roo.bootstrap.CheckBox.get(this.groupId);
24891 for(var i in group){
24892 var fg = group[i].el.findParent('.form-group', false, true);
24893 if (Roo.bootstrap.version == 3) {
24894 fg.removeClass([this.invalidClass, this.validClass]);
24895 fg.addClass(this.validClass);
24897 fg.removeClass(['is-valid', 'is-invalid']);
24898 fg.addClass('is-valid');
24904 * Mark this field as invalid
24905 * @param {String} msg The validation message
24907 markInvalid : function(msg)
24909 if(this.allowBlank){
24915 this.fireEvent('invalid', this, msg);
24917 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
24920 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
24924 label.markInvalid();
24927 if(this.inputType == 'radio'){
24929 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
24930 var fg = e.findParent('.form-group', false, true);
24931 if (Roo.bootstrap.version == 3) {
24932 fg.removeClass([_this.invalidClass, _this.validClass]);
24933 fg.addClass(_this.invalidClass);
24935 fg.removeClass(['is-invalid', 'is-valid']);
24936 fg.addClass('is-invalid');
24944 var fg = this.el.findParent('.form-group', false, true);
24945 if (Roo.bootstrap.version == 3) {
24946 fg.removeClass([_this.invalidClass, _this.validClass]);
24947 fg.addClass(_this.invalidClass);
24949 fg.removeClass(['is-invalid', 'is-valid']);
24950 fg.addClass('is-invalid');
24955 var group = Roo.bootstrap.CheckBox.get(this.groupId);
24961 for(var i in group){
24962 var fg = group[i].el.findParent('.form-group', false, true);
24963 if (Roo.bootstrap.version == 3) {
24964 fg.removeClass([_this.invalidClass, _this.validClass]);
24965 fg.addClass(_this.invalidClass);
24967 fg.removeClass(['is-invalid', 'is-valid']);
24968 fg.addClass('is-invalid');
24974 clearInvalid : function()
24976 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
24978 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
24980 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
24982 if (label && label.iconEl) {
24983 label.iconEl.removeClass([ label.validClass, label.invalidClass ]);
24984 label.iconEl.removeClass(['is-invalid', 'is-valid']);
24988 disable : function()
24990 if(this.inputType != 'radio'){
24991 Roo.bootstrap.CheckBox.superclass.disable.call(this);
24998 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
24999 _this.getActionEl().addClass(this.disabledClass);
25000 e.dom.disabled = true;
25004 this.disabled = true;
25005 this.fireEvent("disable", this);
25009 enable : function()
25011 if(this.inputType != 'radio'){
25012 Roo.bootstrap.CheckBox.superclass.enable.call(this);
25019 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
25020 _this.getActionEl().removeClass(this.disabledClass);
25021 e.dom.disabled = false;
25025 this.disabled = false;
25026 this.fireEvent("enable", this);
25030 setBoxLabel : function(v)
25035 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
25041 Roo.apply(Roo.bootstrap.CheckBox, {
25046 * register a CheckBox Group
25047 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
25049 register : function(checkbox)
25051 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
25052 this.groups[checkbox.groupId] = {};
25055 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
25059 this.groups[checkbox.groupId][checkbox.name] = checkbox;
25063 * fetch a CheckBox Group based on the group ID
25064 * @param {string} the group ID
25065 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
25067 get: function(groupId) {
25068 if (typeof(this.groups[groupId]) == 'undefined') {
25072 return this.groups[groupId] ;
25085 * @class Roo.bootstrap.Radio
25086 * @extends Roo.bootstrap.Component
25087 * Bootstrap Radio class
25088 * @cfg {String} boxLabel - the label associated
25089 * @cfg {String} value - the value of radio
25092 * Create a new Radio
25093 * @param {Object} config The config object
25095 Roo.bootstrap.Radio = function(config){
25096 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
25100 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
25106 getAutoCreate : function()
25110 cls : 'form-group radio',
25115 html : this.boxLabel
25123 initEvents : function()
25125 this.parent().register(this);
25127 this.el.on('click', this.onClick, this);
25131 onClick : function(e)
25133 if(this.parent().fireEvent('click', this.parent(), this, e) !== false){
25134 this.setChecked(true);
25138 setChecked : function(state, suppressEvent)
25140 this.parent().setValue(this.value, suppressEvent);
25144 setBoxLabel : function(v)
25149 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
25164 * @class Roo.bootstrap.SecurePass
25165 * @extends Roo.bootstrap.Input
25166 * Bootstrap SecurePass class
25170 * Create a new SecurePass
25171 * @param {Object} config The config object
25174 Roo.bootstrap.SecurePass = function (config) {
25175 // these go here, so the translation tool can replace them..
25177 PwdEmpty: "Please type a password, and then retype it to confirm.",
25178 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
25179 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
25180 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
25181 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
25182 FNInPwd: "Your password can't contain your first name. Please type a different password.",
25183 LNInPwd: "Your password can't contain your last name. Please type a different password.",
25184 TooWeak: "Your password is Too Weak."
25186 this.meterLabel = "Password strength:";
25187 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
25188 this.meterClass = [
25189 "roo-password-meter-tooweak",
25190 "roo-password-meter-weak",
25191 "roo-password-meter-medium",
25192 "roo-password-meter-strong",
25193 "roo-password-meter-grey"
25198 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
25201 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
25203 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
25205 * PwdEmpty: "Please type a password, and then retype it to confirm.",
25206 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
25207 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
25208 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
25209 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
25210 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
25211 * LNInPwd: "Your password can't contain your last name. Please type a different password."
25221 * @cfg {String/Object} Label for the strength meter (defaults to
25222 * 'Password strength:')
25227 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
25228 * ['Weak', 'Medium', 'Strong'])
25231 pwdStrengths: false,
25244 initEvents: function ()
25246 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
25248 if (this.el.is('input[type=password]') && Roo.isSafari) {
25249 this.el.on('keydown', this.SafariOnKeyDown, this);
25252 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
25255 onRender: function (ct, position)
25257 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
25258 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
25259 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
25261 this.trigger.createChild({
25266 cls: 'roo-password-meter-grey col-xs-12',
25269 //width: this.meterWidth + 'px'
25273 cls: 'roo-password-meter-text'
25279 if (this.hideTrigger) {
25280 this.trigger.setDisplayed(false);
25282 this.setSize(this.width || '', this.height || '');
25285 onDestroy: function ()
25287 if (this.trigger) {
25288 this.trigger.removeAllListeners();
25289 this.trigger.remove();
25292 this.wrap.remove();
25294 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
25297 checkStrength: function ()
25299 var pwd = this.inputEl().getValue();
25300 if (pwd == this._lastPwd) {
25305 if (this.ClientSideStrongPassword(pwd)) {
25307 } else if (this.ClientSideMediumPassword(pwd)) {
25309 } else if (this.ClientSideWeakPassword(pwd)) {
25315 Roo.log('strength1: ' + strength);
25317 //var pm = this.trigger.child('div/div/div').dom;
25318 var pm = this.trigger.child('div/div');
25319 pm.removeClass(this.meterClass);
25320 pm.addClass(this.meterClass[strength]);
25323 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
25325 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
25327 this._lastPwd = pwd;
25331 Roo.bootstrap.SecurePass.superclass.reset.call(this);
25333 this._lastPwd = '';
25335 var pm = this.trigger.child('div/div');
25336 pm.removeClass(this.meterClass);
25337 pm.addClass('roo-password-meter-grey');
25340 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
25343 this.inputEl().dom.type='password';
25346 validateValue: function (value)
25348 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
25351 if (value.length == 0) {
25352 if (this.allowBlank) {
25353 this.clearInvalid();
25357 this.markInvalid(this.errors.PwdEmpty);
25358 this.errorMsg = this.errors.PwdEmpty;
25366 if (!value.match(/[\x21-\x7e]+/)) {
25367 this.markInvalid(this.errors.PwdBadChar);
25368 this.errorMsg = this.errors.PwdBadChar;
25371 if (value.length < 6) {
25372 this.markInvalid(this.errors.PwdShort);
25373 this.errorMsg = this.errors.PwdShort;
25376 if (value.length > 16) {
25377 this.markInvalid(this.errors.PwdLong);
25378 this.errorMsg = this.errors.PwdLong;
25382 if (this.ClientSideStrongPassword(value)) {
25384 } else if (this.ClientSideMediumPassword(value)) {
25386 } else if (this.ClientSideWeakPassword(value)) {
25393 if (strength < 2) {
25394 //this.markInvalid(this.errors.TooWeak);
25395 this.errorMsg = this.errors.TooWeak;
25400 console.log('strength2: ' + strength);
25402 //var pm = this.trigger.child('div/div/div').dom;
25404 var pm = this.trigger.child('div/div');
25405 pm.removeClass(this.meterClass);
25406 pm.addClass(this.meterClass[strength]);
25408 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
25410 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
25412 this.errorMsg = '';
25416 CharacterSetChecks: function (type)
25419 this.fResult = false;
25422 isctype: function (character, type)
25425 case this.kCapitalLetter:
25426 if (character >= 'A' && character <= 'Z') {
25431 case this.kSmallLetter:
25432 if (character >= 'a' && character <= 'z') {
25438 if (character >= '0' && character <= '9') {
25443 case this.kPunctuation:
25444 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
25455 IsLongEnough: function (pwd, size)
25457 return !(pwd == null || isNaN(size) || pwd.length < size);
25460 SpansEnoughCharacterSets: function (word, nb)
25462 if (!this.IsLongEnough(word, nb))
25467 var characterSetChecks = new Array(
25468 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
25469 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
25472 for (var index = 0; index < word.length; ++index) {
25473 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
25474 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
25475 characterSetChecks[nCharSet].fResult = true;
25482 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
25483 if (characterSetChecks[nCharSet].fResult) {
25488 if (nCharSets < nb) {
25494 ClientSideStrongPassword: function (pwd)
25496 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
25499 ClientSideMediumPassword: function (pwd)
25501 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
25504 ClientSideWeakPassword: function (pwd)
25506 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
25509 })//<script type="text/javascript">
25512 * Based Ext JS Library 1.1.1
25513 * Copyright(c) 2006-2007, Ext JS, LLC.
25519 * @class Roo.HtmlEditorCore
25520 * @extends Roo.Component
25521 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
25523 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
25526 Roo.HtmlEditorCore = function(config){
25529 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
25534 * @event initialize
25535 * Fires when the editor is fully initialized (including the iframe)
25536 * @param {Roo.HtmlEditorCore} this
25541 * Fires when the editor is first receives the focus. Any insertion must wait
25542 * until after this event.
25543 * @param {Roo.HtmlEditorCore} this
25547 * @event beforesync
25548 * Fires before the textarea is updated with content from the editor iframe. Return false
25549 * to cancel the sync.
25550 * @param {Roo.HtmlEditorCore} this
25551 * @param {String} html
25555 * @event beforepush
25556 * Fires before the iframe editor is updated with content from the textarea. Return false
25557 * to cancel the push.
25558 * @param {Roo.HtmlEditorCore} this
25559 * @param {String} html
25564 * Fires when the textarea is updated with content from the editor iframe.
25565 * @param {Roo.HtmlEditorCore} this
25566 * @param {String} html
25571 * Fires when the iframe editor is updated with content from the textarea.
25572 * @param {Roo.HtmlEditorCore} this
25573 * @param {String} html
25578 * @event editorevent
25579 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
25580 * @param {Roo.HtmlEditorCore} this
25586 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
25588 // defaults : white / black...
25589 this.applyBlacklists();
25596 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
25600 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
25606 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
25611 * @cfg {Number} height (in pixels)
25615 * @cfg {Number} width (in pixels)
25620 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
25623 stylesheets: false,
25626 * @cfg {boolean} allowComments - default false - allow comments in HTML source - by default they are stripped - if you are editing email you may need this.
25628 allowComments: false,
25632 // private properties
25633 validationEvent : false,
25635 initialized : false,
25637 sourceEditMode : false,
25638 onFocus : Roo.emptyFn,
25640 hideMode:'offsets',
25644 // blacklist + whitelisted elements..
25651 * Protected method that will not generally be called directly. It
25652 * is called when the editor initializes the iframe with HTML contents. Override this method if you
25653 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
25655 getDocMarkup : function(){
25659 // inherit styels from page...??
25660 if (this.stylesheets === false) {
25662 Roo.get(document.head).select('style').each(function(node) {
25663 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
25666 Roo.get(document.head).select('link').each(function(node) {
25667 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
25670 } else if (!this.stylesheets.length) {
25672 st = '<style type="text/css">' +
25673 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
25676 for (var i in this.stylesheets) {
25677 st += '<link rel="stylesheet" href="' + this.stylesheets[i] +'" type="text/css">';
25682 st += '<style type="text/css">' +
25683 'IMG { cursor: pointer } ' +
25686 var cls = 'roo-htmleditor-body';
25688 if(this.bodyCls.length){
25689 cls += ' ' + this.bodyCls;
25692 return '<html><head>' + st +
25693 //<style type="text/css">' +
25694 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
25696 ' </head><body contenteditable="true" data-enable-grammerly="true" class="' + cls + '"></body></html>';
25700 onRender : function(ct, position)
25703 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
25704 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
25707 this.el.dom.style.border = '0 none';
25708 this.el.dom.setAttribute('tabIndex', -1);
25709 this.el.addClass('x-hidden hide');
25713 if(Roo.isIE){ // fix IE 1px bogus margin
25714 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
25718 this.frameId = Roo.id();
25722 var iframe = this.owner.wrap.createChild({
25724 cls: 'form-control', // bootstrap..
25726 name: this.frameId,
25727 frameBorder : 'no',
25728 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
25733 this.iframe = iframe.dom;
25735 this.assignDocWin();
25737 this.doc.designMode = 'on';
25740 this.doc.write(this.getDocMarkup());
25744 var task = { // must defer to wait for browser to be ready
25746 //console.log("run task?" + this.doc.readyState);
25747 this.assignDocWin();
25748 if(this.doc.body || this.doc.readyState == 'complete'){
25750 this.doc.designMode="on";
25754 Roo.TaskMgr.stop(task);
25755 this.initEditor.defer(10, this);
25762 Roo.TaskMgr.start(task);
25767 onResize : function(w, h)
25769 Roo.log('resize: ' +w + ',' + h );
25770 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
25774 if(typeof w == 'number'){
25776 this.iframe.style.width = w + 'px';
25778 if(typeof h == 'number'){
25780 this.iframe.style.height = h + 'px';
25782 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
25789 * Toggles the editor between standard and source edit mode.
25790 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
25792 toggleSourceEdit : function(sourceEditMode){
25794 this.sourceEditMode = sourceEditMode === true;
25796 if(this.sourceEditMode){
25798 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
25801 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
25802 //this.iframe.className = '';
25805 //this.setSize(this.owner.wrap.getSize());
25806 //this.fireEvent('editmodechange', this, this.sourceEditMode);
25813 * Protected method that will not generally be called directly. If you need/want
25814 * custom HTML cleanup, this is the method you should override.
25815 * @param {String} html The HTML to be cleaned
25816 * return {String} The cleaned HTML
25818 cleanHtml : function(html){
25819 html = String(html);
25820 if(html.length > 5){
25821 if(Roo.isSafari){ // strip safari nonsense
25822 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
25825 if(html == ' '){
25832 * HTML Editor -> Textarea
25833 * Protected method that will not generally be called directly. Syncs the contents
25834 * of the editor iframe with the textarea.
25836 syncValue : function(){
25837 if(this.initialized){
25838 var bd = (this.doc.body || this.doc.documentElement);
25839 //this.cleanUpPaste(); -- this is done else where and causes havoc..
25840 var html = bd.innerHTML;
25842 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
25843 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
25845 html = '<div style="'+m[0]+'">' + html + '</div>';
25848 html = this.cleanHtml(html);
25849 // fix up the special chars.. normaly like back quotes in word...
25850 // however we do not want to do this with chinese..
25851 html = html.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[\u0080-\uFFFF]/g, function(match) {
25853 var cc = match.charCodeAt();
25855 // Get the character value, handling surrogate pairs
25856 if (match.length == 2) {
25857 // It's a surrogate pair, calculate the Unicode code point
25858 var high = match.charCodeAt(0) - 0xD800;
25859 var low = match.charCodeAt(1) - 0xDC00;
25860 cc = (high * 0x400) + low + 0x10000;
25862 (cc >= 0x4E00 && cc < 0xA000 ) ||
25863 (cc >= 0x3400 && cc < 0x4E00 ) ||
25864 (cc >= 0xf900 && cc < 0xfb00 )
25869 // No, use a numeric entity. Here we brazenly (and possibly mistakenly)
25870 return "&#" + cc + ";";
25877 if(this.owner.fireEvent('beforesync', this, html) !== false){
25878 this.el.dom.value = html;
25879 this.owner.fireEvent('sync', this, html);
25885 * Protected method that will not generally be called directly. Pushes the value of the textarea
25886 * into the iframe editor.
25888 pushValue : function(){
25889 if(this.initialized){
25890 var v = this.el.dom.value.trim();
25892 // if(v.length < 1){
25896 if(this.owner.fireEvent('beforepush', this, v) !== false){
25897 var d = (this.doc.body || this.doc.documentElement);
25899 this.cleanUpPaste();
25900 this.el.dom.value = d.innerHTML;
25901 this.owner.fireEvent('push', this, v);
25907 deferFocus : function(){
25908 this.focus.defer(10, this);
25912 focus : function(){
25913 if(this.win && !this.sourceEditMode){
25920 assignDocWin: function()
25922 var iframe = this.iframe;
25925 this.doc = iframe.contentWindow.document;
25926 this.win = iframe.contentWindow;
25928 // if (!Roo.get(this.frameId)) {
25931 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
25932 // this.win = Roo.get(this.frameId).dom.contentWindow;
25934 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
25938 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
25939 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
25944 initEditor : function(){
25945 //console.log("INIT EDITOR");
25946 this.assignDocWin();
25950 this.doc.designMode="on";
25952 this.doc.write(this.getDocMarkup());
25955 var dbody = (this.doc.body || this.doc.documentElement);
25956 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
25957 // this copies styles from the containing element into thsi one..
25958 // not sure why we need all of this..
25959 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
25961 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
25962 //ss['background-attachment'] = 'fixed'; // w3c
25963 dbody.bgProperties = 'fixed'; // ie
25964 //Roo.DomHelper.applyStyles(dbody, ss);
25965 Roo.EventManager.on(this.doc, {
25966 //'mousedown': this.onEditorEvent,
25967 'mouseup': this.onEditorEvent,
25968 'dblclick': this.onEditorEvent,
25969 'click': this.onEditorEvent,
25970 'keyup': this.onEditorEvent,
25975 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
25977 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
25978 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
25980 this.initialized = true;
25982 this.owner.fireEvent('initialize', this);
25987 onDestroy : function(){
25993 //for (var i =0; i < this.toolbars.length;i++) {
25994 // // fixme - ask toolbars for heights?
25995 // this.toolbars[i].onDestroy();
25998 //this.wrap.dom.innerHTML = '';
25999 //this.wrap.remove();
26004 onFirstFocus : function(){
26006 this.assignDocWin();
26009 this.activated = true;
26012 if(Roo.isGecko){ // prevent silly gecko errors
26014 var s = this.win.getSelection();
26015 if(!s.focusNode || s.focusNode.nodeType != 3){
26016 var r = s.getRangeAt(0);
26017 r.selectNodeContents((this.doc.body || this.doc.documentElement));
26022 this.execCmd('useCSS', true);
26023 this.execCmd('styleWithCSS', false);
26026 this.owner.fireEvent('activate', this);
26030 adjustFont: function(btn){
26031 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
26032 //if(Roo.isSafari){ // safari
26035 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
26036 if(Roo.isSafari){ // safari
26037 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
26038 v = (v < 10) ? 10 : v;
26039 v = (v > 48) ? 48 : v;
26040 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
26045 v = Math.max(1, v+adjust);
26047 this.execCmd('FontSize', v );
26050 onEditorEvent : function(e)
26052 this.owner.fireEvent('editorevent', this, e);
26053 // this.updateToolbar();
26054 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
26057 insertTag : function(tg)
26059 // could be a bit smarter... -> wrap the current selected tRoo..
26060 if (tg.toLowerCase() == 'span' ||
26061 tg.toLowerCase() == 'code' ||
26062 tg.toLowerCase() == 'sup' ||
26063 tg.toLowerCase() == 'sub'
26066 range = this.createRange(this.getSelection());
26067 var wrappingNode = this.doc.createElement(tg.toLowerCase());
26068 wrappingNode.appendChild(range.extractContents());
26069 range.insertNode(wrappingNode);
26076 this.execCmd("formatblock", tg);
26080 insertText : function(txt)
26084 var range = this.createRange();
26085 range.deleteContents();
26086 //alert(Sender.getAttribute('label'));
26088 range.insertNode(this.doc.createTextNode(txt));
26094 * Executes a Midas editor command on the editor document and performs necessary focus and
26095 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
26096 * @param {String} cmd The Midas command
26097 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
26099 relayCmd : function(cmd, value){
26101 this.execCmd(cmd, value);
26102 this.owner.fireEvent('editorevent', this);
26103 //this.updateToolbar();
26104 this.owner.deferFocus();
26108 * Executes a Midas editor command directly on the editor document.
26109 * For visual commands, you should use {@link #relayCmd} instead.
26110 * <b>This should only be called after the editor is initialized.</b>
26111 * @param {String} cmd The Midas command
26112 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
26114 execCmd : function(cmd, value){
26115 this.doc.execCommand(cmd, false, value === undefined ? null : value);
26122 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
26124 * @param {String} text | dom node..
26126 insertAtCursor : function(text)
26129 if(!this.activated){
26135 var r = this.doc.selection.createRange();
26146 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
26150 // from jquery ui (MIT licenced)
26152 var win = this.win;
26154 if (win.getSelection && win.getSelection().getRangeAt) {
26155 range = win.getSelection().getRangeAt(0);
26156 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
26157 range.insertNode(node);
26158 } else if (win.document.selection && win.document.selection.createRange) {
26159 // no firefox support
26160 var txt = typeof(text) == 'string' ? text : text.outerHTML;
26161 win.document.selection.createRange().pasteHTML(txt);
26163 // no firefox support
26164 var txt = typeof(text) == 'string' ? text : text.outerHTML;
26165 this.execCmd('InsertHTML', txt);
26174 mozKeyPress : function(e){
26176 var c = e.getCharCode(), cmd;
26179 c = String.fromCharCode(c).toLowerCase();
26193 this.cleanUpPaste.defer(100, this);
26201 e.preventDefault();
26209 fixKeys : function(){ // load time branching for fastest keydown performance
26211 return function(e){
26212 var k = e.getKey(), r;
26215 r = this.doc.selection.createRange();
26218 r.pasteHTML('    ');
26225 r = this.doc.selection.createRange();
26227 var target = r.parentElement();
26228 if(!target || target.tagName.toLowerCase() != 'li'){
26230 r.pasteHTML('<br />');
26236 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
26237 this.cleanUpPaste.defer(100, this);
26243 }else if(Roo.isOpera){
26244 return function(e){
26245 var k = e.getKey();
26249 this.execCmd('InsertHTML','    ');
26252 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
26253 this.cleanUpPaste.defer(100, this);
26258 }else if(Roo.isSafari){
26259 return function(e){
26260 var k = e.getKey();
26264 this.execCmd('InsertText','\t');
26268 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
26269 this.cleanUpPaste.defer(100, this);
26277 getAllAncestors: function()
26279 var p = this.getSelectedNode();
26282 a.push(p); // push blank onto stack..
26283 p = this.getParentElement();
26287 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
26291 a.push(this.doc.body);
26295 lastSelNode : false,
26298 getSelection : function()
26300 this.assignDocWin();
26301 return Roo.isIE ? this.doc.selection : this.win.getSelection();
26304 getSelectedNode: function()
26306 // this may only work on Gecko!!!
26308 // should we cache this!!!!
26313 var range = this.createRange(this.getSelection()).cloneRange();
26316 var parent = range.parentElement();
26318 var testRange = range.duplicate();
26319 testRange.moveToElementText(parent);
26320 if (testRange.inRange(range)) {
26323 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
26326 parent = parent.parentElement;
26331 // is ancestor a text element.
26332 var ac = range.commonAncestorContainer;
26333 if (ac.nodeType == 3) {
26334 ac = ac.parentNode;
26337 var ar = ac.childNodes;
26340 var other_nodes = [];
26341 var has_other_nodes = false;
26342 for (var i=0;i<ar.length;i++) {
26343 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
26346 // fullly contained node.
26348 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
26353 // probably selected..
26354 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
26355 other_nodes.push(ar[i]);
26359 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
26364 has_other_nodes = true;
26366 if (!nodes.length && other_nodes.length) {
26367 nodes= other_nodes;
26369 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
26375 createRange: function(sel)
26377 // this has strange effects when using with
26378 // top toolbar - not sure if it's a great idea.
26379 //this.editor.contentWindow.focus();
26380 if (typeof sel != "undefined") {
26382 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
26384 return this.doc.createRange();
26387 return this.doc.createRange();
26390 getParentElement: function()
26393 this.assignDocWin();
26394 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
26396 var range = this.createRange(sel);
26399 var p = range.commonAncestorContainer;
26400 while (p.nodeType == 3) { // text node
26411 * Range intersection.. the hard stuff...
26415 * [ -- selected range --- ]
26419 * if end is before start or hits it. fail.
26420 * if start is after end or hits it fail.
26422 * if either hits (but other is outside. - then it's not
26428 // @see http://www.thismuchiknow.co.uk/?p=64.
26429 rangeIntersectsNode : function(range, node)
26431 var nodeRange = node.ownerDocument.createRange();
26433 nodeRange.selectNode(node);
26435 nodeRange.selectNodeContents(node);
26438 var rangeStartRange = range.cloneRange();
26439 rangeStartRange.collapse(true);
26441 var rangeEndRange = range.cloneRange();
26442 rangeEndRange.collapse(false);
26444 var nodeStartRange = nodeRange.cloneRange();
26445 nodeStartRange.collapse(true);
26447 var nodeEndRange = nodeRange.cloneRange();
26448 nodeEndRange.collapse(false);
26450 return rangeStartRange.compareBoundaryPoints(
26451 Range.START_TO_START, nodeEndRange) == -1 &&
26452 rangeEndRange.compareBoundaryPoints(
26453 Range.START_TO_START, nodeStartRange) == 1;
26457 rangeCompareNode : function(range, node)
26459 var nodeRange = node.ownerDocument.createRange();
26461 nodeRange.selectNode(node);
26463 nodeRange.selectNodeContents(node);
26467 range.collapse(true);
26469 nodeRange.collapse(true);
26471 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
26472 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
26474 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
26476 var nodeIsBefore = ss == 1;
26477 var nodeIsAfter = ee == -1;
26479 if (nodeIsBefore && nodeIsAfter) {
26482 if (!nodeIsBefore && nodeIsAfter) {
26483 return 1; //right trailed.
26486 if (nodeIsBefore && !nodeIsAfter) {
26487 return 2; // left trailed.
26493 // private? - in a new class?
26494 cleanUpPaste : function()
26496 // cleans up the whole document..
26497 Roo.log('cleanuppaste');
26499 this.cleanUpChildren(this.doc.body);
26500 var clean = this.cleanWordChars(this.doc.body.innerHTML);
26501 if (clean != this.doc.body.innerHTML) {
26502 this.doc.body.innerHTML = clean;
26507 cleanWordChars : function(input) {// change the chars to hex code
26508 var he = Roo.HtmlEditorCore;
26510 var output = input;
26511 Roo.each(he.swapCodes, function(sw) {
26512 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
26514 output = output.replace(swapper, sw[1]);
26521 cleanUpChildren : function (n)
26523 if (!n.childNodes.length) {
26526 for (var i = n.childNodes.length-1; i > -1 ; i--) {
26527 this.cleanUpChild(n.childNodes[i]);
26534 cleanUpChild : function (node)
26537 //console.log(node);
26538 if (node.nodeName == "#text") {
26539 // clean up silly Windows -- stuff?
26542 if (node.nodeName == "#comment") {
26543 if (!this.allowComments) {
26544 node.parentNode.removeChild(node);
26546 // clean up silly Windows -- stuff?
26549 var lcname = node.tagName.toLowerCase();
26550 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
26551 // whitelist of tags..
26553 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
26555 node.parentNode.removeChild(node);
26560 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
26562 // spans with no attributes - just remove them..
26563 if ((!node.attributes || !node.attributes.length) && lcname == 'span') {
26564 remove_keep_children = true;
26567 // remove <a name=....> as rendering on yahoo mailer is borked with this.
26568 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
26570 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
26571 // remove_keep_children = true;
26574 if (remove_keep_children) {
26575 this.cleanUpChildren(node);
26576 // inserts everything just before this node...
26577 while (node.childNodes.length) {
26578 var cn = node.childNodes[0];
26579 node.removeChild(cn);
26580 node.parentNode.insertBefore(cn, node);
26582 node.parentNode.removeChild(node);
26586 if (!node.attributes || !node.attributes.length) {
26591 this.cleanUpChildren(node);
26595 function cleanAttr(n,v)
26598 if (v.match(/^\./) || v.match(/^\//)) {
26601 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/) || v.match(/^ftp:/)) {
26604 if (v.match(/^#/)) {
26607 if (v.match(/^\{/)) { // allow template editing.
26610 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
26611 node.removeAttribute(n);
26615 var cwhite = this.cwhite;
26616 var cblack = this.cblack;
26618 function cleanStyle(n,v)
26620 if (v.match(/expression/)) { //XSS?? should we even bother..
26621 node.removeAttribute(n);
26625 var parts = v.split(/;/);
26628 Roo.each(parts, function(p) {
26629 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
26633 var l = p.split(':').shift().replace(/\s+/g,'');
26634 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
26636 if ( cwhite.length && cblack.indexOf(l) > -1) {
26637 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
26638 //node.removeAttribute(n);
26642 // only allow 'c whitelisted system attributes'
26643 if ( cwhite.length && cwhite.indexOf(l) < 0) {
26644 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
26645 //node.removeAttribute(n);
26655 if (clean.length) {
26656 node.setAttribute(n, clean.join(';'));
26658 node.removeAttribute(n);
26664 for (var i = node.attributes.length-1; i > -1 ; i--) {
26665 var a = node.attributes[i];
26668 if (a.name.toLowerCase().substr(0,2)=='on') {
26669 node.removeAttribute(a.name);
26672 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
26673 node.removeAttribute(a.name);
26676 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
26677 cleanAttr(a.name,a.value); // fixme..
26680 if (a.name == 'style') {
26681 cleanStyle(a.name,a.value);
26684 /// clean up MS crap..
26685 // tecnically this should be a list of valid class'es..
26688 if (a.name == 'class') {
26689 if (a.value.match(/^Mso/)) {
26690 node.removeAttribute('class');
26693 if (a.value.match(/^body$/)) {
26694 node.removeAttribute('class');
26705 this.cleanUpChildren(node);
26711 * Clean up MS wordisms...
26713 cleanWord : function(node)
26716 this.cleanWord(this.doc.body);
26721 node.nodeName == 'SPAN' &&
26722 !node.hasAttributes() &&
26723 node.childNodes.length == 1 &&
26724 node.firstChild.nodeName == "#text"
26726 var textNode = node.firstChild;
26727 node.removeChild(textNode);
26728 if (node.getAttribute('lang') != 'zh-CN') { // do not space pad on chinese characters..
26729 node.parentNode.insertBefore(node.ownerDocument.createTextNode(" "), node);
26731 node.parentNode.insertBefore(textNode, node);
26732 if (node.getAttribute('lang') != 'zh-CN') { // do not space pad on chinese characters..
26733 node.parentNode.insertBefore(node.ownerDocument.createTextNode(" ") , node);
26735 node.parentNode.removeChild(node);
26738 if (node.nodeName == "#text") {
26739 // clean up silly Windows -- stuff?
26742 if (node.nodeName == "#comment") {
26743 node.parentNode.removeChild(node);
26744 // clean up silly Windows -- stuff?
26748 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
26749 node.parentNode.removeChild(node);
26752 //Roo.log(node.tagName);
26753 // remove - but keep children..
26754 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|v:|font)/)) {
26755 //Roo.log('-- removed');
26756 while (node.childNodes.length) {
26757 var cn = node.childNodes[0];
26758 node.removeChild(cn);
26759 node.parentNode.insertBefore(cn, node);
26760 // move node to parent - and clean it..
26761 this.cleanWord(cn);
26763 node.parentNode.removeChild(node);
26764 /// no need to iterate chidlren = it's got none..
26765 //this.iterateChildren(node, this.cleanWord);
26769 if (node.className.length) {
26771 var cn = node.className.split(/\W+/);
26773 Roo.each(cn, function(cls) {
26774 if (cls.match(/Mso[a-zA-Z]+/)) {
26779 node.className = cna.length ? cna.join(' ') : '';
26781 node.removeAttribute("class");
26785 if (node.hasAttribute("lang")) {
26786 node.removeAttribute("lang");
26789 if (node.hasAttribute("style")) {
26791 var styles = node.getAttribute("style").split(";");
26793 Roo.each(styles, function(s) {
26794 if (!s.match(/:/)) {
26797 var kv = s.split(":");
26798 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
26801 // what ever is left... we allow.
26804 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
26805 if (!nstyle.length) {
26806 node.removeAttribute('style');
26809 this.iterateChildren(node, this.cleanWord);
26815 * iterateChildren of a Node, calling fn each time, using this as the scole..
26816 * @param {DomNode} node node to iterate children of.
26817 * @param {Function} fn method of this class to call on each item.
26819 iterateChildren : function(node, fn)
26821 if (!node.childNodes.length) {
26824 for (var i = node.childNodes.length-1; i > -1 ; i--) {
26825 fn.call(this, node.childNodes[i])
26831 * cleanTableWidths.
26833 * Quite often pasting from word etc.. results in tables with column and widths.
26834 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
26837 cleanTableWidths : function(node)
26842 this.cleanTableWidths(this.doc.body);
26847 if (node.nodeName == "#text" || node.nodeName == "#comment") {
26850 Roo.log(node.tagName);
26851 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
26852 this.iterateChildren(node, this.cleanTableWidths);
26855 if (node.hasAttribute('width')) {
26856 node.removeAttribute('width');
26860 if (node.hasAttribute("style")) {
26863 var styles = node.getAttribute("style").split(";");
26865 Roo.each(styles, function(s) {
26866 if (!s.match(/:/)) {
26869 var kv = s.split(":");
26870 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
26873 // what ever is left... we allow.
26876 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
26877 if (!nstyle.length) {
26878 node.removeAttribute('style');
26882 this.iterateChildren(node, this.cleanTableWidths);
26890 domToHTML : function(currentElement, depth, nopadtext) {
26892 depth = depth || 0;
26893 nopadtext = nopadtext || false;
26895 if (!currentElement) {
26896 return this.domToHTML(this.doc.body);
26899 //Roo.log(currentElement);
26901 var allText = false;
26902 var nodeName = currentElement.nodeName;
26903 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
26905 if (nodeName == '#text') {
26907 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
26912 if (nodeName != 'BODY') {
26915 // Prints the node tagName, such as <A>, <IMG>, etc
26918 for(i = 0; i < currentElement.attributes.length;i++) {
26920 var aname = currentElement.attributes.item(i).name;
26921 if (!currentElement.attributes.item(i).value.length) {
26924 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
26927 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
26936 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
26939 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
26944 // Traverse the tree
26946 var currentElementChild = currentElement.childNodes.item(i);
26947 var allText = true;
26948 var innerHTML = '';
26950 while (currentElementChild) {
26951 // Formatting code (indent the tree so it looks nice on the screen)
26952 var nopad = nopadtext;
26953 if (lastnode == 'SPAN') {
26957 if (currentElementChild.nodeName == '#text') {
26958 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
26959 toadd = nopadtext ? toadd : toadd.trim();
26960 if (!nopad && toadd.length > 80) {
26961 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
26963 innerHTML += toadd;
26966 currentElementChild = currentElement.childNodes.item(i);
26972 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
26974 // Recursively traverse the tree structure of the child node
26975 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
26976 lastnode = currentElementChild.nodeName;
26978 currentElementChild=currentElement.childNodes.item(i);
26984 // The remaining code is mostly for formatting the tree
26985 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
26990 ret+= "</"+tagName+">";
26996 applyBlacklists : function()
26998 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
26999 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
27003 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
27004 if (b.indexOf(tag) > -1) {
27007 this.white.push(tag);
27011 Roo.each(w, function(tag) {
27012 if (b.indexOf(tag) > -1) {
27015 if (this.white.indexOf(tag) > -1) {
27018 this.white.push(tag);
27023 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
27024 if (w.indexOf(tag) > -1) {
27027 this.black.push(tag);
27031 Roo.each(b, function(tag) {
27032 if (w.indexOf(tag) > -1) {
27035 if (this.black.indexOf(tag) > -1) {
27038 this.black.push(tag);
27043 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
27044 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
27048 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
27049 if (b.indexOf(tag) > -1) {
27052 this.cwhite.push(tag);
27056 Roo.each(w, function(tag) {
27057 if (b.indexOf(tag) > -1) {
27060 if (this.cwhite.indexOf(tag) > -1) {
27063 this.cwhite.push(tag);
27068 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
27069 if (w.indexOf(tag) > -1) {
27072 this.cblack.push(tag);
27076 Roo.each(b, function(tag) {
27077 if (w.indexOf(tag) > -1) {
27080 if (this.cblack.indexOf(tag) > -1) {
27083 this.cblack.push(tag);
27088 setStylesheets : function(stylesheets)
27090 if(typeof(stylesheets) == 'string'){
27091 Roo.get(this.iframe.contentDocument.head).createChild({
27093 rel : 'stylesheet',
27102 Roo.each(stylesheets, function(s) {
27107 Roo.get(_this.iframe.contentDocument.head).createChild({
27109 rel : 'stylesheet',
27118 removeStylesheets : function()
27122 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
27127 setStyle : function(style)
27129 Roo.get(this.iframe.contentDocument.head).createChild({
27138 // hide stuff that is not compatible
27152 * @event specialkey
27156 * @cfg {String} fieldClass @hide
27159 * @cfg {String} focusClass @hide
27162 * @cfg {String} autoCreate @hide
27165 * @cfg {String} inputType @hide
27168 * @cfg {String} invalidClass @hide
27171 * @cfg {String} invalidText @hide
27174 * @cfg {String} msgFx @hide
27177 * @cfg {String} validateOnBlur @hide
27181 Roo.HtmlEditorCore.white = [
27182 'area', 'br', 'img', 'input', 'hr', 'wbr',
27184 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
27185 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
27186 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
27187 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
27188 'table', 'ul', 'xmp',
27190 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
27193 'dir', 'menu', 'ol', 'ul', 'dl',
27199 Roo.HtmlEditorCore.black = [
27200 // 'embed', 'object', // enable - backend responsiblity to clean thiese
27202 'base', 'basefont', 'bgsound', 'blink', 'body',
27203 'frame', 'frameset', 'head', 'html', 'ilayer',
27204 'iframe', 'layer', 'link', 'meta', 'object',
27205 'script', 'style' ,'title', 'xml' // clean later..
27207 Roo.HtmlEditorCore.clean = [
27208 'script', 'style', 'title', 'xml'
27210 Roo.HtmlEditorCore.remove = [
27215 Roo.HtmlEditorCore.ablack = [
27219 Roo.HtmlEditorCore.aclean = [
27220 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
27224 Roo.HtmlEditorCore.pwhite= [
27225 'http', 'https', 'mailto'
27228 // white listed style attributes.
27229 Roo.HtmlEditorCore.cwhite= [
27230 // 'text-align', /// default is to allow most things..
27236 // black listed style attributes.
27237 Roo.HtmlEditorCore.cblack= [
27238 // 'font-size' -- this can be set by the project
27242 Roo.HtmlEditorCore.swapCodes =[
27243 [ 8211, "–" ],
27244 [ 8212, "—" ],
27261 * @class Roo.bootstrap.HtmlEditor
27262 * @extends Roo.bootstrap.TextArea
27263 * Bootstrap HtmlEditor class
27266 * Create a new HtmlEditor
27267 * @param {Object} config The config object
27270 Roo.bootstrap.HtmlEditor = function(config){
27271 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
27272 if (!this.toolbars) {
27273 this.toolbars = [];
27276 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
27279 * @event initialize
27280 * Fires when the editor is fully initialized (including the iframe)
27281 * @param {HtmlEditor} this
27286 * Fires when the editor is first receives the focus. Any insertion must wait
27287 * until after this event.
27288 * @param {HtmlEditor} this
27292 * @event beforesync
27293 * Fires before the textarea is updated with content from the editor iframe. Return false
27294 * to cancel the sync.
27295 * @param {HtmlEditor} this
27296 * @param {String} html
27300 * @event beforepush
27301 * Fires before the iframe editor is updated with content from the textarea. Return false
27302 * to cancel the push.
27303 * @param {HtmlEditor} this
27304 * @param {String} html
27309 * Fires when the textarea is updated with content from the editor iframe.
27310 * @param {HtmlEditor} this
27311 * @param {String} html
27316 * Fires when the iframe editor is updated with content from the textarea.
27317 * @param {HtmlEditor} this
27318 * @param {String} html
27322 * @event editmodechange
27323 * Fires when the editor switches edit modes
27324 * @param {HtmlEditor} this
27325 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
27327 editmodechange: true,
27329 * @event editorevent
27330 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
27331 * @param {HtmlEditor} this
27335 * @event firstfocus
27336 * Fires when on first focus - needed by toolbars..
27337 * @param {HtmlEditor} this
27342 * Auto save the htmlEditor value as a file into Events
27343 * @param {HtmlEditor} this
27347 * @event savedpreview
27348 * preview the saved version of htmlEditor
27349 * @param {HtmlEditor} this
27356 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
27360 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
27365 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
27370 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
27375 * @cfg {Number} height (in pixels)
27379 * @cfg {Number} width (in pixels)
27384 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
27387 stylesheets: false,
27392 // private properties
27393 validationEvent : false,
27395 initialized : false,
27398 onFocus : Roo.emptyFn,
27400 hideMode:'offsets',
27402 tbContainer : false,
27406 toolbarContainer :function() {
27407 return this.wrap.select('.x-html-editor-tb',true).first();
27411 * Protected method that will not generally be called directly. It
27412 * is called when the editor creates its toolbar. Override this method if you need to
27413 * add custom toolbar buttons.
27414 * @param {HtmlEditor} editor
27416 createToolbar : function(){
27417 Roo.log('renewing');
27418 Roo.log("create toolbars");
27420 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
27421 this.toolbars[0].render(this.toolbarContainer());
27425 // if (!editor.toolbars || !editor.toolbars.length) {
27426 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
27429 // for (var i =0 ; i < editor.toolbars.length;i++) {
27430 // editor.toolbars[i] = Roo.factory(
27431 // typeof(editor.toolbars[i]) == 'string' ?
27432 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
27433 // Roo.bootstrap.HtmlEditor);
27434 // editor.toolbars[i].init(editor);
27440 onRender : function(ct, position)
27442 // Roo.log("Call onRender: " + this.xtype);
27444 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
27446 this.wrap = this.inputEl().wrap({
27447 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
27450 this.editorcore.onRender(ct, position);
27452 if (this.resizable) {
27453 this.resizeEl = new Roo.Resizable(this.wrap, {
27457 minHeight : this.height,
27458 height: this.height,
27459 handles : this.resizable,
27462 resize : function(r, w, h) {
27463 _t.onResize(w,h); // -something
27469 this.createToolbar(this);
27472 if(!this.width && this.resizable){
27473 this.setSize(this.wrap.getSize());
27475 if (this.resizeEl) {
27476 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
27477 // should trigger onReize..
27483 onResize : function(w, h)
27485 Roo.log('resize: ' +w + ',' + h );
27486 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
27490 if(this.inputEl() ){
27491 if(typeof w == 'number'){
27492 var aw = w - this.wrap.getFrameWidth('lr');
27493 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
27496 if(typeof h == 'number'){
27497 var tbh = -11; // fixme it needs to tool bar size!
27498 for (var i =0; i < this.toolbars.length;i++) {
27499 // fixme - ask toolbars for heights?
27500 tbh += this.toolbars[i].el.getHeight();
27501 //if (this.toolbars[i].footer) {
27502 // tbh += this.toolbars[i].footer.el.getHeight();
27510 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
27511 ah -= 5; // knock a few pixes off for look..
27512 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
27516 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
27517 this.editorcore.onResize(ew,eh);
27522 * Toggles the editor between standard and source edit mode.
27523 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
27525 toggleSourceEdit : function(sourceEditMode)
27527 this.editorcore.toggleSourceEdit(sourceEditMode);
27529 if(this.editorcore.sourceEditMode){
27530 Roo.log('editor - showing textarea');
27533 // Roo.log(this.syncValue());
27535 this.inputEl().removeClass(['hide', 'x-hidden']);
27536 this.inputEl().dom.removeAttribute('tabIndex');
27537 this.inputEl().focus();
27539 Roo.log('editor - hiding textarea');
27541 // Roo.log(this.pushValue());
27544 this.inputEl().addClass(['hide', 'x-hidden']);
27545 this.inputEl().dom.setAttribute('tabIndex', -1);
27546 //this.deferFocus();
27549 if(this.resizable){
27550 this.setSize(this.wrap.getSize());
27553 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
27556 // private (for BoxComponent)
27557 adjustSize : Roo.BoxComponent.prototype.adjustSize,
27559 // private (for BoxComponent)
27560 getResizeEl : function(){
27564 // private (for BoxComponent)
27565 getPositionEl : function(){
27570 initEvents : function(){
27571 this.originalValue = this.getValue();
27575 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
27578 // markInvalid : Roo.emptyFn,
27580 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
27583 // clearInvalid : Roo.emptyFn,
27585 setValue : function(v){
27586 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
27587 this.editorcore.pushValue();
27592 deferFocus : function(){
27593 this.focus.defer(10, this);
27597 focus : function(){
27598 this.editorcore.focus();
27604 onDestroy : function(){
27610 for (var i =0; i < this.toolbars.length;i++) {
27611 // fixme - ask toolbars for heights?
27612 this.toolbars[i].onDestroy();
27615 this.wrap.dom.innerHTML = '';
27616 this.wrap.remove();
27621 onFirstFocus : function(){
27622 //Roo.log("onFirstFocus");
27623 this.editorcore.onFirstFocus();
27624 for (var i =0; i < this.toolbars.length;i++) {
27625 this.toolbars[i].onFirstFocus();
27631 syncValue : function()
27633 this.editorcore.syncValue();
27636 pushValue : function()
27638 this.editorcore.pushValue();
27642 // hide stuff that is not compatible
27656 * @event specialkey
27660 * @cfg {String} fieldClass @hide
27663 * @cfg {String} focusClass @hide
27666 * @cfg {String} autoCreate @hide
27669 * @cfg {String} inputType @hide
27673 * @cfg {String} invalidText @hide
27676 * @cfg {String} msgFx @hide
27679 * @cfg {String} validateOnBlur @hide
27688 Roo.namespace('Roo.bootstrap.htmleditor');
27690 * @class Roo.bootstrap.HtmlEditorToolbar1
27696 new Roo.bootstrap.HtmlEditor({
27699 new Roo.bootstrap.HtmlEditorToolbar1({
27700 disable : { fonts: 1 , format: 1, ..., ... , ...],
27706 * @cfg {Object} disable List of elements to disable..
27707 * @cfg {Array} btns List of additional buttons.
27711 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
27714 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
27717 Roo.apply(this, config);
27719 // default disabled, based on 'good practice'..
27720 this.disable = this.disable || {};
27721 Roo.applyIf(this.disable, {
27724 specialElements : true
27726 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
27728 this.editor = config.editor;
27729 this.editorcore = config.editor.editorcore;
27731 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
27733 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
27734 // dont call parent... till later.
27736 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
27741 editorcore : false,
27746 "h1","h2","h3","h4","h5","h6",
27748 "abbr", "acronym", "address", "cite", "samp", "var",
27752 onRender : function(ct, position)
27754 // Roo.log("Call onRender: " + this.xtype);
27756 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
27758 this.el.dom.style.marginBottom = '0';
27760 var editorcore = this.editorcore;
27761 var editor= this.editor;
27764 var btn = function(id,cmd , toggle, handler, html){
27766 var event = toggle ? 'toggle' : 'click';
27771 xns: Roo.bootstrap,
27775 enableToggle:toggle !== false,
27777 pressed : toggle ? false : null,
27780 a.listeners[toggle ? 'toggle' : 'click'] = function() {
27781 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
27787 // var cb_box = function...
27792 xns: Roo.bootstrap,
27797 xns: Roo.bootstrap,
27801 Roo.each(this.formats, function(f) {
27802 style.menu.items.push({
27804 xns: Roo.bootstrap,
27805 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
27810 editorcore.insertTag(this.tagname);
27817 children.push(style);
27819 btn('bold',false,true);
27820 btn('italic',false,true);
27821 btn('align-left', 'justifyleft',true);
27822 btn('align-center', 'justifycenter',true);
27823 btn('align-right' , 'justifyright',true);
27824 btn('link', false, false, function(btn) {
27825 //Roo.log("create link?");
27826 var url = prompt(this.createLinkText, this.defaultLinkValue);
27827 if(url && url != 'http:/'+'/'){
27828 this.editorcore.relayCmd('createlink', url);
27831 btn('list','insertunorderedlist',true);
27832 btn('pencil', false,true, function(btn){
27834 this.toggleSourceEdit(btn.pressed);
27837 if (this.editor.btns.length > 0) {
27838 for (var i = 0; i<this.editor.btns.length; i++) {
27839 children.push(this.editor.btns[i]);
27847 xns: Roo.bootstrap,
27852 xns: Roo.bootstrap,
27857 cog.menu.items.push({
27859 xns: Roo.bootstrap,
27860 html : Clean styles,
27865 editorcore.insertTag(this.tagname);
27874 this.xtype = 'NavSimplebar';
27876 for(var i=0;i< children.length;i++) {
27878 this.buttons.add(this.addxtypeChild(children[i]));
27882 editor.on('editorevent', this.updateToolbar, this);
27884 onBtnClick : function(id)
27886 this.editorcore.relayCmd(id);
27887 this.editorcore.focus();
27891 * Protected method that will not generally be called directly. It triggers
27892 * a toolbar update by reading the markup state of the current selection in the editor.
27894 updateToolbar: function(){
27896 if(!this.editorcore.activated){
27897 this.editor.onFirstFocus(); // is this neeed?
27901 var btns = this.buttons;
27902 var doc = this.editorcore.doc;
27903 btns.get('bold').setActive(doc.queryCommandState('bold'));
27904 btns.get('italic').setActive(doc.queryCommandState('italic'));
27905 //btns.get('underline').setActive(doc.queryCommandState('underline'));
27907 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
27908 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
27909 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
27911 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
27912 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
27915 var ans = this.editorcore.getAllAncestors();
27916 if (this.formatCombo) {
27919 var store = this.formatCombo.store;
27920 this.formatCombo.setValue("");
27921 for (var i =0; i < ans.length;i++) {
27922 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
27924 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
27932 // hides menus... - so this cant be on a menu...
27933 Roo.bootstrap.MenuMgr.hideAll();
27935 Roo.bootstrap.MenuMgr.hideAll();
27936 //this.editorsyncValue();
27938 onFirstFocus: function() {
27939 this.buttons.each(function(item){
27943 toggleSourceEdit : function(sourceEditMode){
27946 if(sourceEditMode){
27947 Roo.log("disabling buttons");
27948 this.buttons.each( function(item){
27949 if(item.cmd != 'pencil'){
27955 Roo.log("enabling buttons");
27956 if(this.editorcore.initialized){
27957 this.buttons.each( function(item){
27963 Roo.log("calling toggole on editor");
27964 // tell the editor that it's been pressed..
27965 this.editor.toggleSourceEdit(sourceEditMode);
27979 * @class Roo.bootstrap.Markdown
27980 * @extends Roo.bootstrap.TextArea
27981 * Bootstrap Showdown editable area
27982 * @cfg {string} content
27985 * Create a new Showdown
27988 Roo.bootstrap.Markdown = function(config){
27989 Roo.bootstrap.Markdown.superclass.constructor.call(this, config);
27993 Roo.extend(Roo.bootstrap.Markdown, Roo.bootstrap.TextArea, {
27997 initEvents : function()
28000 Roo.bootstrap.TextArea.prototype.initEvents.call(this);
28001 this.markdownEl = this.el.createChild({
28002 cls : 'roo-markdown-area'
28004 this.inputEl().addClass('d-none');
28005 if (this.getValue() == '') {
28006 this.markdownEl.dom.innerHTML = String.format('<span class="roo-placeholder">{0}</span>', this.placeholder || '');
28009 this.markdownEl.dom.innerHTML = Roo.Markdown.toHtml(Roo.util.Format.htmlEncode(this.getValue()));
28011 this.markdownEl.on('click', this.toggleTextEdit, this);
28012 this.on('blur', this.toggleTextEdit, this);
28013 this.on('specialkey', this.resizeTextArea, this);
28016 toggleTextEdit : function()
28018 var sh = this.markdownEl.getHeight();
28019 this.inputEl().addClass('d-none');
28020 this.markdownEl.addClass('d-none');
28021 if (!this.editing) {
28023 this.inputEl().setHeight(Math.min(500, Math.max(sh,(this.getValue().split("\n").length+1) * 30)));
28024 this.inputEl().removeClass('d-none');
28025 this.inputEl().focus();
28026 this.editing = true;
28029 // show showdown...
28030 this.updateMarkdown();
28031 this.markdownEl.removeClass('d-none');
28032 this.editing = false;
28035 updateMarkdown : function()
28037 if (this.getValue() == '') {
28038 this.markdownEl.dom.innerHTML = String.format('<span class="roo-placeholder">{0}</span>', this.placeholder || '');
28042 this.markdownEl.dom.innerHTML = Roo.Markdown.toHtml(Roo.util.Format.htmlEncode(this.getValue()));
28045 resizeTextArea: function () {
28048 Roo.log([sh, this.getValue().split("\n").length * 30]);
28049 this.inputEl().setHeight(Math.min(500, Math.max(sh, (this.getValue().split("\n").length +1) * 30)));
28051 setValue : function(val)
28053 Roo.bootstrap.TextArea.prototype.setValue.call(this,val);
28054 if (!this.editing) {
28055 this.updateMarkdown();
28061 if (!this.editing) {
28062 this.toggleTextEdit();
28070 * Ext JS Library 1.1.1
28071 * Copyright(c) 2006-2007, Ext JS, LLC.
28073 * Originally Released Under LGPL - original licence link has changed is not relivant.
28076 * <script type="text/javascript">
28080 * @class Roo.bootstrap.PagingToolbar
28081 * @extends Roo.bootstrap.NavSimplebar
28082 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
28084 * Create a new PagingToolbar
28085 * @param {Object} config The config object
28086 * @param {Roo.data.Store} store
28088 Roo.bootstrap.PagingToolbar = function(config)
28090 // old args format still supported... - xtype is prefered..
28091 // created from xtype...
28093 this.ds = config.dataSource;
28095 if (config.store && !this.ds) {
28096 this.store= Roo.factory(config.store, Roo.data);
28097 this.ds = this.store;
28098 this.ds.xmodule = this.xmodule || false;
28101 this.toolbarItems = [];
28102 if (config.items) {
28103 this.toolbarItems = config.items;
28106 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
28111 this.bind(this.ds);
28114 if (Roo.bootstrap.version == 4) {
28115 this.navgroup = new Roo.bootstrap.ButtonGroup({ cls: 'pagination' });
28117 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
28122 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
28124 * @cfg {Roo.data.Store} dataSource
28125 * The underlying data store providing the paged data
28128 * @cfg {String/HTMLElement/Element} container
28129 * container The id or element that will contain the toolbar
28132 * @cfg {Boolean} displayInfo
28133 * True to display the displayMsg (defaults to false)
28136 * @cfg {Number} pageSize
28137 * The number of records to display per page (defaults to 20)
28141 * @cfg {String} displayMsg
28142 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
28144 displayMsg : 'Displaying {0} - {1} of {2}',
28146 * @cfg {String} emptyMsg
28147 * The message to display when no records are found (defaults to "No data to display")
28149 emptyMsg : 'No data to display',
28151 * Customizable piece of the default paging text (defaults to "Page")
28154 beforePageText : "Page",
28156 * Customizable piece of the default paging text (defaults to "of %0")
28159 afterPageText : "of {0}",
28161 * Customizable piece of the default paging text (defaults to "First Page")
28164 firstText : "First Page",
28166 * Customizable piece of the default paging text (defaults to "Previous Page")
28169 prevText : "Previous Page",
28171 * Customizable piece of the default paging text (defaults to "Next Page")
28174 nextText : "Next Page",
28176 * Customizable piece of the default paging text (defaults to "Last Page")
28179 lastText : "Last Page",
28181 * Customizable piece of the default paging text (defaults to "Refresh")
28184 refreshText : "Refresh",
28188 onRender : function(ct, position)
28190 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
28191 this.navgroup.parentId = this.id;
28192 this.navgroup.onRender(this.el, null);
28193 // add the buttons to the navgroup
28195 if(this.displayInfo){
28196 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
28197 this.displayEl = this.el.select('.x-paging-info', true).first();
28198 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
28199 // this.displayEl = navel.el.select('span',true).first();
28205 Roo.each(_this.buttons, function(e){ // this might need to use render????
28206 Roo.factory(e).render(_this.el);
28210 Roo.each(_this.toolbarItems, function(e) {
28211 _this.navgroup.addItem(e);
28215 this.first = this.navgroup.addItem({
28216 tooltip: this.firstText,
28217 cls: "prev btn-outline-secondary",
28218 html : ' <i class="fa fa-step-backward"></i>',
28220 preventDefault: true,
28221 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
28224 this.prev = this.navgroup.addItem({
28225 tooltip: this.prevText,
28226 cls: "prev btn-outline-secondary",
28227 html : ' <i class="fa fa-backward"></i>',
28229 preventDefault: true,
28230 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
28232 //this.addSeparator();
28235 var field = this.navgroup.addItem( {
28237 cls : 'x-paging-position btn-outline-secondary',
28239 html : this.beforePageText +
28240 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
28241 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
28244 this.field = field.el.select('input', true).first();
28245 this.field.on("keydown", this.onPagingKeydown, this);
28246 this.field.on("focus", function(){this.dom.select();});
28249 this.afterTextEl = field.el.select('.x-paging-after',true).first();
28250 //this.field.setHeight(18);
28251 //this.addSeparator();
28252 this.next = this.navgroup.addItem({
28253 tooltip: this.nextText,
28254 cls: "next btn-outline-secondary",
28255 html : ' <i class="fa fa-forward"></i>',
28257 preventDefault: true,
28258 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
28260 this.last = this.navgroup.addItem({
28261 tooltip: this.lastText,
28262 html : ' <i class="fa fa-step-forward"></i>',
28263 cls: "next btn-outline-secondary",
28265 preventDefault: true,
28266 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
28268 //this.addSeparator();
28269 this.loading = this.navgroup.addItem({
28270 tooltip: this.refreshText,
28271 cls: "btn-outline-secondary",
28272 html : ' <i class="fa fa-refresh"></i>',
28273 preventDefault: true,
28274 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
28280 updateInfo : function(){
28281 if(this.displayEl){
28282 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
28283 var msg = count == 0 ?
28287 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
28289 this.displayEl.update(msg);
28294 onLoad : function(ds, r, o)
28296 this.cursor = o.params && o.params.start ? o.params.start : 0;
28298 var d = this.getPageData(),
28303 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
28304 this.field.dom.value = ap;
28305 this.first.setDisabled(ap == 1);
28306 this.prev.setDisabled(ap == 1);
28307 this.next.setDisabled(ap == ps);
28308 this.last.setDisabled(ap == ps);
28309 this.loading.enable();
28314 getPageData : function(){
28315 var total = this.ds.getTotalCount();
28318 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
28319 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
28324 onLoadError : function(){
28325 this.loading.enable();
28329 onPagingKeydown : function(e){
28330 var k = e.getKey();
28331 var d = this.getPageData();
28333 var v = this.field.dom.value, pageNum;
28334 if(!v || isNaN(pageNum = parseInt(v, 10))){
28335 this.field.dom.value = d.activePage;
28338 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
28339 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
28342 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))
28344 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
28345 this.field.dom.value = pageNum;
28346 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
28349 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
28351 var v = this.field.dom.value, pageNum;
28352 var increment = (e.shiftKey) ? 10 : 1;
28353 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
28356 if(!v || isNaN(pageNum = parseInt(v, 10))) {
28357 this.field.dom.value = d.activePage;
28360 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
28362 this.field.dom.value = parseInt(v, 10) + increment;
28363 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
28364 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
28371 beforeLoad : function(){
28373 this.loading.disable();
28378 onClick : function(which){
28387 ds.load({params:{start: 0, limit: this.pageSize}});
28390 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
28393 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
28396 var total = ds.getTotalCount();
28397 var extra = total % this.pageSize;
28398 var lastStart = extra ? (total - extra) : total-this.pageSize;
28399 ds.load({params:{start: lastStart, limit: this.pageSize}});
28402 ds.load({params:{start: this.cursor, limit: this.pageSize}});
28408 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
28409 * @param {Roo.data.Store} store The data store to unbind
28411 unbind : function(ds){
28412 ds.un("beforeload", this.beforeLoad, this);
28413 ds.un("load", this.onLoad, this);
28414 ds.un("loadexception", this.onLoadError, this);
28415 ds.un("remove", this.updateInfo, this);
28416 ds.un("add", this.updateInfo, this);
28417 this.ds = undefined;
28421 * Binds the paging toolbar to the specified {@link Roo.data.Store}
28422 * @param {Roo.data.Store} store The data store to bind
28424 bind : function(ds){
28425 ds.on("beforeload", this.beforeLoad, this);
28426 ds.on("load", this.onLoad, this);
28427 ds.on("loadexception", this.onLoadError, this);
28428 ds.on("remove", this.updateInfo, this);
28429 ds.on("add", this.updateInfo, this);
28440 * @class Roo.bootstrap.MessageBar
28441 * @extends Roo.bootstrap.Component
28442 * Bootstrap MessageBar class
28443 * @cfg {String} html contents of the MessageBar
28444 * @cfg {String} weight (info | success | warning | danger) default info
28445 * @cfg {String} beforeClass insert the bar before the given class
28446 * @cfg {Boolean} closable (true | false) default false
28447 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
28450 * Create a new Element
28451 * @param {Object} config The config object
28454 Roo.bootstrap.MessageBar = function(config){
28455 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
28458 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
28464 beforeClass: 'bootstrap-sticky-wrap',
28466 getAutoCreate : function(){
28470 cls: 'alert alert-dismissable alert-' + this.weight,
28475 html: this.html || ''
28481 cfg.cls += ' alert-messages-fixed';
28495 onRender : function(ct, position)
28497 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
28500 var cfg = Roo.apply({}, this.getAutoCreate());
28504 cfg.cls += ' ' + this.cls;
28507 cfg.style = this.style;
28509 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
28511 this.el.setVisibilityMode(Roo.Element.DISPLAY);
28514 this.el.select('>button.close').on('click', this.hide, this);
28520 if (!this.rendered) {
28526 this.fireEvent('show', this);
28532 if (!this.rendered) {
28538 this.fireEvent('hide', this);
28541 update : function()
28543 // var e = this.el.dom.firstChild;
28545 // if(this.closable){
28546 // e = e.nextSibling;
28549 // e.data = this.html || '';
28551 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
28567 * @class Roo.bootstrap.Graph
28568 * @extends Roo.bootstrap.Component
28569 * Bootstrap Graph class
28573 @cfg {String} graphtype bar | vbar | pie
28574 @cfg {number} g_x coodinator | centre x (pie)
28575 @cfg {number} g_y coodinator | centre y (pie)
28576 @cfg {number} g_r radius (pie)
28577 @cfg {number} g_height height of the chart (respected by all elements in the set)
28578 @cfg {number} g_width width of the chart (respected by all elements in the set)
28579 @cfg {Object} title The title of the chart
28582 -opts (object) options for the chart
28584 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
28585 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
28587 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.
28588 o stacked (boolean) whether or not to tread values as in a stacked bar chart
28590 o stretch (boolean)
28592 -opts (object) options for the pie
28595 o startAngle (number)
28596 o endAngle (number)
28600 * Create a new Input
28601 * @param {Object} config The config object
28604 Roo.bootstrap.Graph = function(config){
28605 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
28611 * The img click event for the img.
28612 * @param {Roo.EventObject} e
28618 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
28629 //g_colors: this.colors,
28636 getAutoCreate : function(){
28647 onRender : function(ct,position){
28650 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
28652 if (typeof(Raphael) == 'undefined') {
28653 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
28657 this.raphael = Raphael(this.el.dom);
28659 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
28660 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
28661 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
28662 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
28664 r.text(160, 10, "Single Series Chart").attr(txtattr);
28665 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
28666 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
28667 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
28669 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
28670 r.barchart(330, 10, 300, 220, data1);
28671 r.barchart(10, 250, 300, 220, data2, {stacked: true});
28672 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
28675 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
28676 // r.barchart(30, 30, 560, 250, xdata, {
28677 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
28678 // axis : "0 0 1 1",
28679 // axisxlabels : xdata
28680 // //yvalues : cols,
28683 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
28685 // this.load(null,xdata,{
28686 // axis : "0 0 1 1",
28687 // axisxlabels : xdata
28692 load : function(graphtype,xdata,opts)
28694 this.raphael.clear();
28696 graphtype = this.graphtype;
28701 var r = this.raphael,
28702 fin = function () {
28703 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
28705 fout = function () {
28706 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
28708 pfin = function() {
28709 this.sector.stop();
28710 this.sector.scale(1.1, 1.1, this.cx, this.cy);
28713 this.label[0].stop();
28714 this.label[0].attr({ r: 7.5 });
28715 this.label[1].attr({ "font-weight": 800 });
28718 pfout = function() {
28719 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
28722 this.label[0].animate({ r: 5 }, 500, "bounce");
28723 this.label[1].attr({ "font-weight": 400 });
28729 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
28732 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
28735 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
28736 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
28738 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
28745 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
28750 setTitle: function(o)
28755 initEvents: function() {
28758 this.el.on('click', this.onClick, this);
28762 onClick : function(e)
28764 Roo.log('img onclick');
28765 this.fireEvent('click', this, e);
28777 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
28780 * @class Roo.bootstrap.dash.NumberBox
28781 * @extends Roo.bootstrap.Component
28782 * Bootstrap NumberBox class
28783 * @cfg {String} headline Box headline
28784 * @cfg {String} content Box content
28785 * @cfg {String} icon Box icon
28786 * @cfg {String} footer Footer text
28787 * @cfg {String} fhref Footer href
28790 * Create a new NumberBox
28791 * @param {Object} config The config object
28795 Roo.bootstrap.dash.NumberBox = function(config){
28796 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
28800 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
28809 getAutoCreate : function(){
28813 cls : 'small-box ',
28821 cls : 'roo-headline',
28822 html : this.headline
28826 cls : 'roo-content',
28827 html : this.content
28841 cls : 'ion ' + this.icon
28850 cls : 'small-box-footer',
28851 href : this.fhref || '#',
28855 cfg.cn.push(footer);
28862 onRender : function(ct,position){
28863 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
28870 setHeadline: function (value)
28872 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
28875 setFooter: function (value, href)
28877 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
28880 this.el.select('a.small-box-footer',true).first().attr('href', href);
28885 setContent: function (value)
28887 this.el.select('.roo-content',true).first().dom.innerHTML = value;
28890 initEvents: function()
28904 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
28907 * @class Roo.bootstrap.dash.TabBox
28908 * @extends Roo.bootstrap.Component
28909 * Bootstrap TabBox class
28910 * @cfg {String} title Title of the TabBox
28911 * @cfg {String} icon Icon of the TabBox
28912 * @cfg {Boolean} showtabs (true|false) show the tabs default true
28913 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
28916 * Create a new TabBox
28917 * @param {Object} config The config object
28921 Roo.bootstrap.dash.TabBox = function(config){
28922 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
28927 * When a pane is added
28928 * @param {Roo.bootstrap.dash.TabPane} pane
28932 * @event activatepane
28933 * When a pane is activated
28934 * @param {Roo.bootstrap.dash.TabPane} pane
28936 "activatepane" : true
28944 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
28949 tabScrollable : false,
28951 getChildContainer : function()
28953 return this.el.select('.tab-content', true).first();
28956 getAutoCreate : function(){
28960 cls: 'pull-left header',
28968 cls: 'fa ' + this.icon
28974 cls: 'nav nav-tabs pull-right',
28980 if(this.tabScrollable){
28987 cls: 'nav nav-tabs pull-right',
28998 cls: 'nav-tabs-custom',
29003 cls: 'tab-content no-padding',
29011 initEvents : function()
29013 //Roo.log('add add pane handler');
29014 this.on('addpane', this.onAddPane, this);
29017 * Updates the box title
29018 * @param {String} html to set the title to.
29020 setTitle : function(value)
29022 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
29024 onAddPane : function(pane)
29026 this.panes.push(pane);
29027 //Roo.log('addpane');
29029 // tabs are rendere left to right..
29030 if(!this.showtabs){
29034 var ctr = this.el.select('.nav-tabs', true).first();
29037 var existing = ctr.select('.nav-tab',true);
29038 var qty = existing.getCount();;
29041 var tab = ctr.createChild({
29043 cls : 'nav-tab' + (qty ? '' : ' active'),
29051 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
29054 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
29056 pane.el.addClass('active');
29061 onTabClick : function(ev,un,ob,pane)
29063 //Roo.log('tab - prev default');
29064 ev.preventDefault();
29067 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
29068 pane.tab.addClass('active');
29069 //Roo.log(pane.title);
29070 this.getChildContainer().select('.tab-pane',true).removeClass('active');
29071 // technically we should have a deactivate event.. but maybe add later.
29072 // and it should not de-activate the selected tab...
29073 this.fireEvent('activatepane', pane);
29074 pane.el.addClass('active');
29075 pane.fireEvent('activate');
29080 getActivePane : function()
29083 Roo.each(this.panes, function(p) {
29084 if(p.el.hasClass('active')){
29105 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
29107 * @class Roo.bootstrap.TabPane
29108 * @extends Roo.bootstrap.Component
29109 * Bootstrap TabPane class
29110 * @cfg {Boolean} active (false | true) Default false
29111 * @cfg {String} title title of panel
29115 * Create a new TabPane
29116 * @param {Object} config The config object
29119 Roo.bootstrap.dash.TabPane = function(config){
29120 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
29126 * When a pane is activated
29127 * @param {Roo.bootstrap.dash.TabPane} pane
29134 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
29139 // the tabBox that this is attached to.
29142 getAutoCreate : function()
29150 cfg.cls += ' active';
29155 initEvents : function()
29157 //Roo.log('trigger add pane handler');
29158 this.parent().fireEvent('addpane', this)
29162 * Updates the tab title
29163 * @param {String} html to set the title to.
29165 setTitle: function(str)
29171 this.tab.select('a', true).first().dom.innerHTML = str;
29188 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
29191 * @class Roo.bootstrap.menu.Menu
29192 * @extends Roo.bootstrap.Component
29193 * Bootstrap Menu class - container for Menu
29194 * @cfg {String} html Text of the menu
29195 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
29196 * @cfg {String} icon Font awesome icon
29197 * @cfg {String} pos Menu align to (top | bottom) default bottom
29201 * Create a new Menu
29202 * @param {Object} config The config object
29206 Roo.bootstrap.menu.Menu = function(config){
29207 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
29211 * @event beforeshow
29212 * Fires before this menu is displayed
29213 * @param {Roo.bootstrap.menu.Menu} this
29217 * @event beforehide
29218 * Fires before this menu is hidden
29219 * @param {Roo.bootstrap.menu.Menu} this
29224 * Fires after this menu is displayed
29225 * @param {Roo.bootstrap.menu.Menu} this
29230 * Fires after this menu is hidden
29231 * @param {Roo.bootstrap.menu.Menu} this
29236 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
29237 * @param {Roo.bootstrap.menu.Menu} this
29238 * @param {Roo.EventObject} e
29245 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
29249 weight : 'default',
29254 getChildContainer : function() {
29255 if(this.isSubMenu){
29259 return this.el.select('ul.dropdown-menu', true).first();
29262 getAutoCreate : function()
29267 cls : 'roo-menu-text',
29275 cls : 'fa ' + this.icon
29286 cls : 'dropdown-button btn btn-' + this.weight,
29291 cls : 'dropdown-toggle btn btn-' + this.weight,
29301 cls : 'dropdown-menu'
29307 if(this.pos == 'top'){
29308 cfg.cls += ' dropup';
29311 if(this.isSubMenu){
29314 cls : 'dropdown-menu'
29321 onRender : function(ct, position)
29323 this.isSubMenu = ct.hasClass('dropdown-submenu');
29325 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
29328 initEvents : function()
29330 if(this.isSubMenu){
29334 this.hidden = true;
29336 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
29337 this.triggerEl.on('click', this.onTriggerPress, this);
29339 this.buttonEl = this.el.select('button.dropdown-button', true).first();
29340 this.buttonEl.on('click', this.onClick, this);
29346 if(this.isSubMenu){
29350 return this.el.select('ul.dropdown-menu', true).first();
29353 onClick : function(e)
29355 this.fireEvent("click", this, e);
29358 onTriggerPress : function(e)
29360 if (this.isVisible()) {
29367 isVisible : function(){
29368 return !this.hidden;
29373 this.fireEvent("beforeshow", this);
29375 this.hidden = false;
29376 this.el.addClass('open');
29378 Roo.get(document).on("mouseup", this.onMouseUp, this);
29380 this.fireEvent("show", this);
29387 this.fireEvent("beforehide", this);
29389 this.hidden = true;
29390 this.el.removeClass('open');
29392 Roo.get(document).un("mouseup", this.onMouseUp);
29394 this.fireEvent("hide", this);
29397 onMouseUp : function()
29411 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
29414 * @class Roo.bootstrap.menu.Item
29415 * @extends Roo.bootstrap.Component
29416 * Bootstrap MenuItem class
29417 * @cfg {Boolean} submenu (true | false) default false
29418 * @cfg {String} html text of the item
29419 * @cfg {String} href the link
29420 * @cfg {Boolean} disable (true | false) default false
29421 * @cfg {Boolean} preventDefault (true | false) default true
29422 * @cfg {String} icon Font awesome icon
29423 * @cfg {String} pos Submenu align to (left | right) default right
29427 * Create a new Item
29428 * @param {Object} config The config object
29432 Roo.bootstrap.menu.Item = function(config){
29433 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
29437 * Fires when the mouse is hovering over this menu
29438 * @param {Roo.bootstrap.menu.Item} this
29439 * @param {Roo.EventObject} e
29444 * Fires when the mouse exits this menu
29445 * @param {Roo.bootstrap.menu.Item} this
29446 * @param {Roo.EventObject} e
29452 * The raw click event for the entire grid.
29453 * @param {Roo.EventObject} e
29459 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
29464 preventDefault: true,
29469 getAutoCreate : function()
29474 cls : 'roo-menu-item-text',
29482 cls : 'fa ' + this.icon
29491 href : this.href || '#',
29498 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
29502 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
29504 if(this.pos == 'left'){
29505 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
29512 initEvents : function()
29514 this.el.on('mouseover', this.onMouseOver, this);
29515 this.el.on('mouseout', this.onMouseOut, this);
29517 this.el.select('a', true).first().on('click', this.onClick, this);
29521 onClick : function(e)
29523 if(this.preventDefault){
29524 e.preventDefault();
29527 this.fireEvent("click", this, e);
29530 onMouseOver : function(e)
29532 if(this.submenu && this.pos == 'left'){
29533 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
29536 this.fireEvent("mouseover", this, e);
29539 onMouseOut : function(e)
29541 this.fireEvent("mouseout", this, e);
29553 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
29556 * @class Roo.bootstrap.menu.Separator
29557 * @extends Roo.bootstrap.Component
29558 * Bootstrap Separator class
29561 * Create a new Separator
29562 * @param {Object} config The config object
29566 Roo.bootstrap.menu.Separator = function(config){
29567 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
29570 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
29572 getAutoCreate : function(){
29575 cls: 'dropdown-divider divider'
29593 * @class Roo.bootstrap.Tooltip
29594 * Bootstrap Tooltip class
29595 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
29596 * to determine which dom element triggers the tooltip.
29598 * It needs to add support for additional attributes like tooltip-position
29601 * Create a new Toolti
29602 * @param {Object} config The config object
29605 Roo.bootstrap.Tooltip = function(config){
29606 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
29608 this.alignment = Roo.bootstrap.Tooltip.alignment;
29610 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
29611 this.alignment = config.alignment;
29616 Roo.apply(Roo.bootstrap.Tooltip, {
29618 * @function init initialize tooltip monitoring.
29622 currentTip : false,
29623 currentRegion : false,
29629 Roo.get(document).on('mouseover', this.enter ,this);
29630 Roo.get(document).on('mouseout', this.leave, this);
29633 this.currentTip = new Roo.bootstrap.Tooltip();
29636 enter : function(ev)
29638 var dom = ev.getTarget();
29640 //Roo.log(['enter',dom]);
29641 var el = Roo.fly(dom);
29642 if (this.currentEl) {
29644 //Roo.log(this.currentEl);
29645 //Roo.log(this.currentEl.contains(dom));
29646 if (this.currentEl == el) {
29649 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
29655 if (this.currentTip.el) {
29656 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
29660 if(!el || el.dom == document){
29666 if (!el.attr('tooltip')) {
29667 pel = el.findParent("[tooltip]");
29669 bindEl = Roo.get(pel);
29675 // you can not look for children, as if el is the body.. then everythign is the child..
29676 if (!pel && !el.attr('tooltip')) { //
29677 if (!el.select("[tooltip]").elements.length) {
29680 // is the mouse over this child...?
29681 bindEl = el.select("[tooltip]").first();
29682 var xy = ev.getXY();
29683 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
29684 //Roo.log("not in region.");
29687 //Roo.log("child element over..");
29690 this.currentEl = el;
29691 this.currentTip.bind(bindEl);
29692 this.currentRegion = Roo.lib.Region.getRegion(dom);
29693 this.currentTip.enter();
29696 leave : function(ev)
29698 var dom = ev.getTarget();
29699 //Roo.log(['leave',dom]);
29700 if (!this.currentEl) {
29705 if (dom != this.currentEl.dom) {
29708 var xy = ev.getXY();
29709 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
29712 // only activate leave if mouse cursor is outside... bounding box..
29717 if (this.currentTip) {
29718 this.currentTip.leave();
29720 //Roo.log('clear currentEl');
29721 this.currentEl = false;
29726 'left' : ['r-l', [-2,0], 'right'],
29727 'right' : ['l-r', [2,0], 'left'],
29728 'bottom' : ['t-b', [0,2], 'top'],
29729 'top' : [ 'b-t', [0,-2], 'bottom']
29735 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
29740 delay : null, // can be { show : 300 , hide: 500}
29744 hoverState : null, //???
29746 placement : 'bottom',
29750 getAutoCreate : function(){
29757 cls : 'tooltip-arrow arrow'
29760 cls : 'tooltip-inner'
29767 bind : function(el)
29772 initEvents : function()
29774 this.arrowEl = this.el.select('.arrow', true).first();
29775 this.innerEl = this.el.select('.tooltip-inner', true).first();
29778 enter : function () {
29780 if (this.timeout != null) {
29781 clearTimeout(this.timeout);
29784 this.hoverState = 'in';
29785 //Roo.log("enter - show");
29786 if (!this.delay || !this.delay.show) {
29791 this.timeout = setTimeout(function () {
29792 if (_t.hoverState == 'in') {
29795 }, this.delay.show);
29799 clearTimeout(this.timeout);
29801 this.hoverState = 'out';
29802 if (!this.delay || !this.delay.hide) {
29808 this.timeout = setTimeout(function () {
29809 //Roo.log("leave - timeout");
29811 if (_t.hoverState == 'out') {
29813 Roo.bootstrap.Tooltip.currentEl = false;
29818 show : function (msg)
29821 this.render(document.body);
29824 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
29826 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
29828 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
29830 this.el.removeClass(['fade','top','bottom', 'left', 'right','in',
29831 'bs-tooltip-top','bs-tooltip-bottom', 'bs-tooltip-left', 'bs-tooltip-right']);
29833 var placement = typeof this.placement == 'function' ?
29834 this.placement.call(this, this.el, on_el) :
29837 var autoToken = /\s?auto?\s?/i;
29838 var autoPlace = autoToken.test(placement);
29840 placement = placement.replace(autoToken, '') || 'top';
29844 //this.el.setXY([0,0]);
29846 //this.el.dom.style.display='block';
29848 //this.el.appendTo(on_el);
29850 var p = this.getPosition();
29851 var box = this.el.getBox();
29857 var align = this.alignment[placement];
29859 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
29861 if(placement == 'top' || placement == 'bottom'){
29863 placement = 'right';
29866 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
29867 placement = 'left';
29870 var scroll = Roo.select('body', true).first().getScroll();
29872 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
29876 align = this.alignment[placement];
29878 this.arrowEl.setLeft((this.innerEl.getWidth()/2) - 5);
29882 var elems = document.getElementsByTagName('div');
29883 var highest = Number.MIN_SAFE_INTEGER || -(Math.pow(2, 53) - 1);
29884 for (var i = 0; i < elems.length; i++) {
29885 var zindex = Number.parseInt(
29886 document.defaultView.getComputedStyle(elems[i], null).getPropertyValue("z-index"),
29889 if (zindex > highest) {
29896 this.el.dom.style.zIndex = highest;
29898 this.el.alignTo(this.bindEl, align[0],align[1]);
29899 //var arrow = this.el.select('.arrow',true).first();
29900 //arrow.set(align[2],
29902 this.el.addClass(placement);
29903 this.el.addClass("bs-tooltip-"+ placement);
29905 this.el.addClass('in fade show');
29907 this.hoverState = null;
29909 if (this.el.hasClass('fade')) {
29924 //this.el.setXY([0,0]);
29925 this.el.removeClass(['show', 'in']);
29941 * @class Roo.bootstrap.LocationPicker
29942 * @extends Roo.bootstrap.Component
29943 * Bootstrap LocationPicker class
29944 * @cfg {Number} latitude Position when init default 0
29945 * @cfg {Number} longitude Position when init default 0
29946 * @cfg {Number} zoom default 15
29947 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
29948 * @cfg {Boolean} mapTypeControl default false
29949 * @cfg {Boolean} disableDoubleClickZoom default false
29950 * @cfg {Boolean} scrollwheel default true
29951 * @cfg {Boolean} streetViewControl default false
29952 * @cfg {Number} radius default 0
29953 * @cfg {String} locationName
29954 * @cfg {Boolean} draggable default true
29955 * @cfg {Boolean} enableAutocomplete default false
29956 * @cfg {Boolean} enableReverseGeocode default true
29957 * @cfg {String} markerTitle
29960 * Create a new LocationPicker
29961 * @param {Object} config The config object
29965 Roo.bootstrap.LocationPicker = function(config){
29967 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
29972 * Fires when the picker initialized.
29973 * @param {Roo.bootstrap.LocationPicker} this
29974 * @param {Google Location} location
29978 * @event positionchanged
29979 * Fires when the picker position changed.
29980 * @param {Roo.bootstrap.LocationPicker} this
29981 * @param {Google Location} location
29983 positionchanged : true,
29986 * Fires when the map resize.
29987 * @param {Roo.bootstrap.LocationPicker} this
29992 * Fires when the map show.
29993 * @param {Roo.bootstrap.LocationPicker} this
29998 * Fires when the map hide.
29999 * @param {Roo.bootstrap.LocationPicker} this
30004 * Fires when click the map.
30005 * @param {Roo.bootstrap.LocationPicker} this
30006 * @param {Map event} e
30010 * @event mapRightClick
30011 * Fires when right click the map.
30012 * @param {Roo.bootstrap.LocationPicker} this
30013 * @param {Map event} e
30015 mapRightClick : true,
30017 * @event markerClick
30018 * Fires when click the marker.
30019 * @param {Roo.bootstrap.LocationPicker} this
30020 * @param {Map event} e
30022 markerClick : true,
30024 * @event markerRightClick
30025 * Fires when right click the marker.
30026 * @param {Roo.bootstrap.LocationPicker} this
30027 * @param {Map event} e
30029 markerRightClick : true,
30031 * @event OverlayViewDraw
30032 * Fires when OverlayView Draw
30033 * @param {Roo.bootstrap.LocationPicker} this
30035 OverlayViewDraw : true,
30037 * @event OverlayViewOnAdd
30038 * Fires when OverlayView Draw
30039 * @param {Roo.bootstrap.LocationPicker} this
30041 OverlayViewOnAdd : true,
30043 * @event OverlayViewOnRemove
30044 * Fires when OverlayView Draw
30045 * @param {Roo.bootstrap.LocationPicker} this
30047 OverlayViewOnRemove : true,
30049 * @event OverlayViewShow
30050 * Fires when OverlayView Draw
30051 * @param {Roo.bootstrap.LocationPicker} this
30052 * @param {Pixel} cpx
30054 OverlayViewShow : true,
30056 * @event OverlayViewHide
30057 * Fires when OverlayView Draw
30058 * @param {Roo.bootstrap.LocationPicker} this
30060 OverlayViewHide : true,
30062 * @event loadexception
30063 * Fires when load google lib failed.
30064 * @param {Roo.bootstrap.LocationPicker} this
30066 loadexception : true
30071 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
30073 gMapContext: false,
30079 mapTypeControl: false,
30080 disableDoubleClickZoom: false,
30082 streetViewControl: false,
30086 enableAutocomplete: false,
30087 enableReverseGeocode: true,
30090 getAutoCreate: function()
30095 cls: 'roo-location-picker'
30101 initEvents: function(ct, position)
30103 if(!this.el.getWidth() || this.isApplied()){
30107 this.el.setVisibilityMode(Roo.Element.DISPLAY);
30112 initial: function()
30114 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
30115 this.fireEvent('loadexception', this);
30119 if(!this.mapTypeId){
30120 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
30123 this.gMapContext = this.GMapContext();
30125 this.initOverlayView();
30127 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
30131 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
30132 _this.setPosition(_this.gMapContext.marker.position);
30135 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
30136 _this.fireEvent('mapClick', this, event);
30140 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
30141 _this.fireEvent('mapRightClick', this, event);
30145 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
30146 _this.fireEvent('markerClick', this, event);
30150 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
30151 _this.fireEvent('markerRightClick', this, event);
30155 this.setPosition(this.gMapContext.location);
30157 this.fireEvent('initial', this, this.gMapContext.location);
30160 initOverlayView: function()
30164 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
30168 _this.fireEvent('OverlayViewDraw', _this);
30173 _this.fireEvent('OverlayViewOnAdd', _this);
30176 onRemove: function()
30178 _this.fireEvent('OverlayViewOnRemove', _this);
30181 show: function(cpx)
30183 _this.fireEvent('OverlayViewShow', _this, cpx);
30188 _this.fireEvent('OverlayViewHide', _this);
30194 fromLatLngToContainerPixel: function(event)
30196 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
30199 isApplied: function()
30201 return this.getGmapContext() == false ? false : true;
30204 getGmapContext: function()
30206 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
30209 GMapContext: function()
30211 var position = new google.maps.LatLng(this.latitude, this.longitude);
30213 var _map = new google.maps.Map(this.el.dom, {
30216 mapTypeId: this.mapTypeId,
30217 mapTypeControl: this.mapTypeControl,
30218 disableDoubleClickZoom: this.disableDoubleClickZoom,
30219 scrollwheel: this.scrollwheel,
30220 streetViewControl: this.streetViewControl,
30221 locationName: this.locationName,
30222 draggable: this.draggable,
30223 enableAutocomplete: this.enableAutocomplete,
30224 enableReverseGeocode: this.enableReverseGeocode
30227 var _marker = new google.maps.Marker({
30228 position: position,
30230 title: this.markerTitle,
30231 draggable: this.draggable
30238 location: position,
30239 radius: this.radius,
30240 locationName: this.locationName,
30241 addressComponents: {
30242 formatted_address: null,
30243 addressLine1: null,
30244 addressLine2: null,
30246 streetNumber: null,
30250 stateOrProvince: null
30253 domContainer: this.el.dom,
30254 geodecoder: new google.maps.Geocoder()
30258 drawCircle: function(center, radius, options)
30260 if (this.gMapContext.circle != null) {
30261 this.gMapContext.circle.setMap(null);
30265 options = Roo.apply({}, options, {
30266 strokeColor: "#0000FF",
30267 strokeOpacity: .35,
30269 fillColor: "#0000FF",
30273 options.map = this.gMapContext.map;
30274 options.radius = radius;
30275 options.center = center;
30276 this.gMapContext.circle = new google.maps.Circle(options);
30277 return this.gMapContext.circle;
30283 setPosition: function(location)
30285 this.gMapContext.location = location;
30286 this.gMapContext.marker.setPosition(location);
30287 this.gMapContext.map.panTo(location);
30288 this.drawCircle(location, this.gMapContext.radius, {});
30292 if (this.gMapContext.settings.enableReverseGeocode) {
30293 this.gMapContext.geodecoder.geocode({
30294 latLng: this.gMapContext.location
30295 }, function(results, status) {
30297 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
30298 _this.gMapContext.locationName = results[0].formatted_address;
30299 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
30301 _this.fireEvent('positionchanged', this, location);
30308 this.fireEvent('positionchanged', this, location);
30313 google.maps.event.trigger(this.gMapContext.map, "resize");
30315 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
30317 this.fireEvent('resize', this);
30320 setPositionByLatLng: function(latitude, longitude)
30322 this.setPosition(new google.maps.LatLng(latitude, longitude));
30325 getCurrentPosition: function()
30328 latitude: this.gMapContext.location.lat(),
30329 longitude: this.gMapContext.location.lng()
30333 getAddressName: function()
30335 return this.gMapContext.locationName;
30338 getAddressComponents: function()
30340 return this.gMapContext.addressComponents;
30343 address_component_from_google_geocode: function(address_components)
30347 for (var i = 0; i < address_components.length; i++) {
30348 var component = address_components[i];
30349 if (component.types.indexOf("postal_code") >= 0) {
30350 result.postalCode = component.short_name;
30351 } else if (component.types.indexOf("street_number") >= 0) {
30352 result.streetNumber = component.short_name;
30353 } else if (component.types.indexOf("route") >= 0) {
30354 result.streetName = component.short_name;
30355 } else if (component.types.indexOf("neighborhood") >= 0) {
30356 result.city = component.short_name;
30357 } else if (component.types.indexOf("locality") >= 0) {
30358 result.city = component.short_name;
30359 } else if (component.types.indexOf("sublocality") >= 0) {
30360 result.district = component.short_name;
30361 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
30362 result.stateOrProvince = component.short_name;
30363 } else if (component.types.indexOf("country") >= 0) {
30364 result.country = component.short_name;
30368 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
30369 result.addressLine2 = "";
30373 setZoomLevel: function(zoom)
30375 this.gMapContext.map.setZoom(zoom);
30388 this.fireEvent('show', this);
30399 this.fireEvent('hide', this);
30404 Roo.apply(Roo.bootstrap.LocationPicker, {
30406 OverlayView : function(map, options)
30408 options = options || {};
30415 * @class Roo.bootstrap.Alert
30416 * @extends Roo.bootstrap.Component
30417 * Bootstrap Alert class - shows an alert area box
30419 * <div class="alert alert-danger" role="alert"><span class="fa fa-exclamation-triangle"></span><span class="sr-only">Error:</span>
30420 Enter a valid email address
30423 * @cfg {String} title The title of alert
30424 * @cfg {String} html The content of alert
30425 * @cfg {String} weight (success|info|warning|danger) Weight of the message
30426 * @cfg {String} fa font-awesomeicon
30427 * @cfg {Number} seconds default:-1 Number of seconds until it disapears (-1 means never.)
30428 * @cfg {Boolean} close true to show a x closer
30432 * Create a new alert
30433 * @param {Object} config The config object
30437 Roo.bootstrap.Alert = function(config){
30438 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
30442 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
30448 faicon: false, // BC
30452 getAutoCreate : function()
30464 style : this.close ? '' : 'display:none'
30468 cls : 'roo-alert-icon'
30473 cls : 'roo-alert-title',
30478 cls : 'roo-alert-text',
30485 cfg.cn[0].cls += ' fa ' + this.faicon;
30488 cfg.cn[0].cls += ' fa ' + this.fa;
30492 cfg.cls += ' alert-' + this.weight;
30498 initEvents: function()
30500 this.el.setVisibilityMode(Roo.Element.DISPLAY);
30501 this.titleEl = this.el.select('.roo-alert-title',true).first();
30502 this.iconEl = this.el.select('.roo-alert-icon',true).first();
30503 this.htmlEl = this.el.select('.roo-alert-text',true).first();
30504 if (this.seconds > 0) {
30505 this.hide.defer(this.seconds, this);
30509 * Set the Title Message HTML
30510 * @param {String} html
30512 setTitle : function(str)
30514 this.titleEl.dom.innerHTML = str;
30518 * Set the Body Message HTML
30519 * @param {String} html
30521 setHtml : function(str)
30523 this.htmlEl.dom.innerHTML = str;
30526 * Set the Weight of the alert
30527 * @param {String} (success|info|warning|danger) weight
30530 setWeight : function(weight)
30533 this.el.removeClass('alert-' + this.weight);
30536 this.weight = weight;
30538 this.el.addClass('alert-' + this.weight);
30541 * Set the Icon of the alert
30542 * @param {String} see fontawsome names (name without the 'fa-' bit)
30544 setIcon : function(icon)
30547 this.alertEl.removeClass(['fa', 'fa-' + this.faicon]);
30550 this.faicon = icon;
30552 this.alertEl.addClass(['fa', 'fa-' + this.faicon]);
30577 * @class Roo.bootstrap.UploadCropbox
30578 * @extends Roo.bootstrap.Component
30579 * Bootstrap UploadCropbox class
30580 * @cfg {String} emptyText show when image has been loaded
30581 * @cfg {String} rotateNotify show when image too small to rotate
30582 * @cfg {Number} errorTimeout default 3000
30583 * @cfg {Number} minWidth default 300
30584 * @cfg {Number} minHeight default 300
30585 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
30586 * @cfg {Boolean} isDocument (true|false) default false
30587 * @cfg {String} url action url
30588 * @cfg {String} paramName default 'imageUpload'
30589 * @cfg {String} method default POST
30590 * @cfg {Boolean} loadMask (true|false) default true
30591 * @cfg {Boolean} loadingText default 'Loading...'
30594 * Create a new UploadCropbox
30595 * @param {Object} config The config object
30598 Roo.bootstrap.UploadCropbox = function(config){
30599 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
30603 * @event beforeselectfile
30604 * Fire before select file
30605 * @param {Roo.bootstrap.UploadCropbox} this
30607 "beforeselectfile" : true,
30610 * Fire after initEvent
30611 * @param {Roo.bootstrap.UploadCropbox} this
30616 * Fire after initEvent
30617 * @param {Roo.bootstrap.UploadCropbox} this
30618 * @param {String} data
30623 * Fire when preparing the file data
30624 * @param {Roo.bootstrap.UploadCropbox} this
30625 * @param {Object} file
30630 * Fire when get exception
30631 * @param {Roo.bootstrap.UploadCropbox} this
30632 * @param {XMLHttpRequest} xhr
30634 "exception" : true,
30636 * @event beforeloadcanvas
30637 * Fire before load the canvas
30638 * @param {Roo.bootstrap.UploadCropbox} this
30639 * @param {String} src
30641 "beforeloadcanvas" : true,
30644 * Fire when trash image
30645 * @param {Roo.bootstrap.UploadCropbox} this
30650 * Fire when download the image
30651 * @param {Roo.bootstrap.UploadCropbox} this
30655 * @event footerbuttonclick
30656 * Fire when footerbuttonclick
30657 * @param {Roo.bootstrap.UploadCropbox} this
30658 * @param {String} type
30660 "footerbuttonclick" : true,
30664 * @param {Roo.bootstrap.UploadCropbox} this
30669 * Fire when rotate the image
30670 * @param {Roo.bootstrap.UploadCropbox} this
30671 * @param {String} pos
30676 * Fire when inspect the file
30677 * @param {Roo.bootstrap.UploadCropbox} this
30678 * @param {Object} file
30683 * Fire when xhr upload the file
30684 * @param {Roo.bootstrap.UploadCropbox} this
30685 * @param {Object} data
30690 * Fire when arrange the file data
30691 * @param {Roo.bootstrap.UploadCropbox} this
30692 * @param {Object} formData
30697 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
30700 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
30702 emptyText : 'Click to upload image',
30703 rotateNotify : 'Image is too small to rotate',
30704 errorTimeout : 3000,
30718 cropType : 'image/jpeg',
30720 canvasLoaded : false,
30721 isDocument : false,
30723 paramName : 'imageUpload',
30725 loadingText : 'Loading...',
30728 getAutoCreate : function()
30732 cls : 'roo-upload-cropbox',
30736 cls : 'roo-upload-cropbox-selector',
30741 cls : 'roo-upload-cropbox-body',
30742 style : 'cursor:pointer',
30746 cls : 'roo-upload-cropbox-preview'
30750 cls : 'roo-upload-cropbox-thumb'
30754 cls : 'roo-upload-cropbox-empty-notify',
30755 html : this.emptyText
30759 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
30760 html : this.rotateNotify
30766 cls : 'roo-upload-cropbox-footer',
30769 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
30779 onRender : function(ct, position)
30781 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
30783 if (this.buttons.length) {
30785 Roo.each(this.buttons, function(bb) {
30787 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
30789 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
30795 this.maskEl = this.el;
30799 initEvents : function()
30801 this.urlAPI = (window.createObjectURL && window) ||
30802 (window.URL && URL.revokeObjectURL && URL) ||
30803 (window.webkitURL && webkitURL);
30805 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
30806 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30808 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
30809 this.selectorEl.hide();
30811 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
30812 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30814 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
30815 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30816 this.thumbEl.hide();
30818 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
30819 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30821 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
30822 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30823 this.errorEl.hide();
30825 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
30826 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
30827 this.footerEl.hide();
30829 this.setThumbBoxSize();
30835 this.fireEvent('initial', this);
30842 window.addEventListener("resize", function() { _this.resize(); } );
30844 this.bodyEl.on('click', this.beforeSelectFile, this);
30847 this.bodyEl.on('touchstart', this.onTouchStart, this);
30848 this.bodyEl.on('touchmove', this.onTouchMove, this);
30849 this.bodyEl.on('touchend', this.onTouchEnd, this);
30853 this.bodyEl.on('mousedown', this.onMouseDown, this);
30854 this.bodyEl.on('mousemove', this.onMouseMove, this);
30855 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
30856 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
30857 Roo.get(document).on('mouseup', this.onMouseUp, this);
30860 this.selectorEl.on('change', this.onFileSelected, this);
30866 this.baseScale = 1;
30868 this.baseRotate = 1;
30869 this.dragable = false;
30870 this.pinching = false;
30873 this.cropData = false;
30874 this.notifyEl.dom.innerHTML = this.emptyText;
30876 this.selectorEl.dom.value = '';
30880 resize : function()
30882 if(this.fireEvent('resize', this) != false){
30883 this.setThumbBoxPosition();
30884 this.setCanvasPosition();
30888 onFooterButtonClick : function(e, el, o, type)
30891 case 'rotate-left' :
30892 this.onRotateLeft(e);
30894 case 'rotate-right' :
30895 this.onRotateRight(e);
30898 this.beforeSelectFile(e);
30913 this.fireEvent('footerbuttonclick', this, type);
30916 beforeSelectFile : function(e)
30918 e.preventDefault();
30920 if(this.fireEvent('beforeselectfile', this) != false){
30921 this.selectorEl.dom.click();
30925 onFileSelected : function(e)
30927 e.preventDefault();
30929 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
30933 var file = this.selectorEl.dom.files[0];
30935 if(this.fireEvent('inspect', this, file) != false){
30936 this.prepare(file);
30941 trash : function(e)
30943 this.fireEvent('trash', this);
30946 download : function(e)
30948 this.fireEvent('download', this);
30951 loadCanvas : function(src)
30953 if(this.fireEvent('beforeloadcanvas', this, src) != false){
30957 this.imageEl = document.createElement('img');
30961 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
30963 this.imageEl.src = src;
30967 onLoadCanvas : function()
30969 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
30970 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
30972 this.bodyEl.un('click', this.beforeSelectFile, this);
30974 this.notifyEl.hide();
30975 this.thumbEl.show();
30976 this.footerEl.show();
30978 this.baseRotateLevel();
30980 if(this.isDocument){
30981 this.setThumbBoxSize();
30984 this.setThumbBoxPosition();
30986 this.baseScaleLevel();
30992 this.canvasLoaded = true;
30995 this.maskEl.unmask();
31000 setCanvasPosition : function()
31002 if(!this.canvasEl){
31006 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
31007 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
31009 this.previewEl.setLeft(pw);
31010 this.previewEl.setTop(ph);
31014 onMouseDown : function(e)
31018 this.dragable = true;
31019 this.pinching = false;
31021 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
31022 this.dragable = false;
31026 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
31027 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
31031 onMouseMove : function(e)
31035 if(!this.canvasLoaded){
31039 if (!this.dragable){
31043 var minX = Math.ceil(this.thumbEl.getLeft(true));
31044 var minY = Math.ceil(this.thumbEl.getTop(true));
31046 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
31047 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
31049 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
31050 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
31052 x = x - this.mouseX;
31053 y = y - this.mouseY;
31055 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
31056 var bgY = Math.ceil(y + this.previewEl.getTop(true));
31058 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
31059 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
31061 this.previewEl.setLeft(bgX);
31062 this.previewEl.setTop(bgY);
31064 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
31065 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
31068 onMouseUp : function(e)
31072 this.dragable = false;
31075 onMouseWheel : function(e)
31079 this.startScale = this.scale;
31081 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
31083 if(!this.zoomable()){
31084 this.scale = this.startScale;
31093 zoomable : function()
31095 var minScale = this.thumbEl.getWidth() / this.minWidth;
31097 if(this.minWidth < this.minHeight){
31098 minScale = this.thumbEl.getHeight() / this.minHeight;
31101 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
31102 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
31106 (this.rotate == 0 || this.rotate == 180) &&
31108 width > this.imageEl.OriginWidth ||
31109 height > this.imageEl.OriginHeight ||
31110 (width < this.minWidth && height < this.minHeight)
31118 (this.rotate == 90 || this.rotate == 270) &&
31120 width > this.imageEl.OriginWidth ||
31121 height > this.imageEl.OriginHeight ||
31122 (width < this.minHeight && height < this.minWidth)
31129 !this.isDocument &&
31130 (this.rotate == 0 || this.rotate == 180) &&
31132 width < this.minWidth ||
31133 width > this.imageEl.OriginWidth ||
31134 height < this.minHeight ||
31135 height > this.imageEl.OriginHeight
31142 !this.isDocument &&
31143 (this.rotate == 90 || this.rotate == 270) &&
31145 width < this.minHeight ||
31146 width > this.imageEl.OriginWidth ||
31147 height < this.minWidth ||
31148 height > this.imageEl.OriginHeight
31158 onRotateLeft : function(e)
31160 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
31162 var minScale = this.thumbEl.getWidth() / this.minWidth;
31164 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
31165 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
31167 this.startScale = this.scale;
31169 while (this.getScaleLevel() < minScale){
31171 this.scale = this.scale + 1;
31173 if(!this.zoomable()){
31178 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
31179 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
31184 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
31191 this.scale = this.startScale;
31193 this.onRotateFail();
31198 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
31200 if(this.isDocument){
31201 this.setThumbBoxSize();
31202 this.setThumbBoxPosition();
31203 this.setCanvasPosition();
31208 this.fireEvent('rotate', this, 'left');
31212 onRotateRight : function(e)
31214 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
31216 var minScale = this.thumbEl.getWidth() / this.minWidth;
31218 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
31219 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
31221 this.startScale = this.scale;
31223 while (this.getScaleLevel() < minScale){
31225 this.scale = this.scale + 1;
31227 if(!this.zoomable()){
31232 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
31233 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
31238 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
31245 this.scale = this.startScale;
31247 this.onRotateFail();
31252 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
31254 if(this.isDocument){
31255 this.setThumbBoxSize();
31256 this.setThumbBoxPosition();
31257 this.setCanvasPosition();
31262 this.fireEvent('rotate', this, 'right');
31265 onRotateFail : function()
31267 this.errorEl.show(true);
31271 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
31276 this.previewEl.dom.innerHTML = '';
31278 var canvasEl = document.createElement("canvas");
31280 var contextEl = canvasEl.getContext("2d");
31282 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
31283 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
31284 var center = this.imageEl.OriginWidth / 2;
31286 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
31287 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
31288 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
31289 center = this.imageEl.OriginHeight / 2;
31292 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
31294 contextEl.translate(center, center);
31295 contextEl.rotate(this.rotate * Math.PI / 180);
31297 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
31299 this.canvasEl = document.createElement("canvas");
31301 this.contextEl = this.canvasEl.getContext("2d");
31303 switch (this.rotate) {
31306 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
31307 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
31309 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
31314 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
31315 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
31317 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
31318 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);
31322 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
31327 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
31328 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
31330 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
31331 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);
31335 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);
31340 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
31341 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
31343 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
31344 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
31348 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);
31355 this.previewEl.appendChild(this.canvasEl);
31357 this.setCanvasPosition();
31362 if(!this.canvasLoaded){
31366 var imageCanvas = document.createElement("canvas");
31368 var imageContext = imageCanvas.getContext("2d");
31370 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
31371 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
31373 var center = imageCanvas.width / 2;
31375 imageContext.translate(center, center);
31377 imageContext.rotate(this.rotate * Math.PI / 180);
31379 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
31381 var canvas = document.createElement("canvas");
31383 var context = canvas.getContext("2d");
31385 canvas.width = this.minWidth;
31386 canvas.height = this.minHeight;
31388 switch (this.rotate) {
31391 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
31392 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
31394 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
31395 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
31397 var targetWidth = this.minWidth - 2 * x;
31398 var targetHeight = this.minHeight - 2 * y;
31402 if((x == 0 && y == 0) || (x == 0 && y > 0)){
31403 scale = targetWidth / width;
31406 if(x > 0 && y == 0){
31407 scale = targetHeight / height;
31410 if(x > 0 && y > 0){
31411 scale = targetWidth / width;
31413 if(width < height){
31414 scale = targetHeight / height;
31418 context.scale(scale, scale);
31420 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
31421 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
31423 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
31424 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
31426 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
31431 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
31432 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
31434 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
31435 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
31437 var targetWidth = this.minWidth - 2 * x;
31438 var targetHeight = this.minHeight - 2 * y;
31442 if((x == 0 && y == 0) || (x == 0 && y > 0)){
31443 scale = targetWidth / width;
31446 if(x > 0 && y == 0){
31447 scale = targetHeight / height;
31450 if(x > 0 && y > 0){
31451 scale = targetWidth / width;
31453 if(width < height){
31454 scale = targetHeight / height;
31458 context.scale(scale, scale);
31460 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
31461 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
31463 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
31464 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
31466 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
31468 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
31473 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
31474 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
31476 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
31477 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
31479 var targetWidth = this.minWidth - 2 * x;
31480 var targetHeight = this.minHeight - 2 * y;
31484 if((x == 0 && y == 0) || (x == 0 && y > 0)){
31485 scale = targetWidth / width;
31488 if(x > 0 && y == 0){
31489 scale = targetHeight / height;
31492 if(x > 0 && y > 0){
31493 scale = targetWidth / width;
31495 if(width < height){
31496 scale = targetHeight / height;
31500 context.scale(scale, scale);
31502 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
31503 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
31505 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
31506 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
31508 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
31509 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
31511 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
31516 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
31517 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
31519 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
31520 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
31522 var targetWidth = this.minWidth - 2 * x;
31523 var targetHeight = this.minHeight - 2 * y;
31527 if((x == 0 && y == 0) || (x == 0 && y > 0)){
31528 scale = targetWidth / width;
31531 if(x > 0 && y == 0){
31532 scale = targetHeight / height;
31535 if(x > 0 && y > 0){
31536 scale = targetWidth / width;
31538 if(width < height){
31539 scale = targetHeight / height;
31543 context.scale(scale, scale);
31545 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
31546 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
31548 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
31549 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
31551 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
31553 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
31560 this.cropData = canvas.toDataURL(this.cropType);
31562 if(this.fireEvent('crop', this, this.cropData) !== false){
31563 this.process(this.file, this.cropData);
31570 setThumbBoxSize : function()
31574 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
31575 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
31576 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
31578 this.minWidth = width;
31579 this.minHeight = height;
31581 if(this.rotate == 90 || this.rotate == 270){
31582 this.minWidth = height;
31583 this.minHeight = width;
31588 width = Math.ceil(this.minWidth * height / this.minHeight);
31590 if(this.minWidth > this.minHeight){
31592 height = Math.ceil(this.minHeight * width / this.minWidth);
31595 this.thumbEl.setStyle({
31596 width : width + 'px',
31597 height : height + 'px'
31604 setThumbBoxPosition : function()
31606 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
31607 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
31609 this.thumbEl.setLeft(x);
31610 this.thumbEl.setTop(y);
31614 baseRotateLevel : function()
31616 this.baseRotate = 1;
31619 typeof(this.exif) != 'undefined' &&
31620 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
31621 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
31623 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
31626 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
31630 baseScaleLevel : function()
31634 if(this.isDocument){
31636 if(this.baseRotate == 6 || this.baseRotate == 8){
31638 height = this.thumbEl.getHeight();
31639 this.baseScale = height / this.imageEl.OriginWidth;
31641 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
31642 width = this.thumbEl.getWidth();
31643 this.baseScale = width / this.imageEl.OriginHeight;
31649 height = this.thumbEl.getHeight();
31650 this.baseScale = height / this.imageEl.OriginHeight;
31652 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
31653 width = this.thumbEl.getWidth();
31654 this.baseScale = width / this.imageEl.OriginWidth;
31660 if(this.baseRotate == 6 || this.baseRotate == 8){
31662 width = this.thumbEl.getHeight();
31663 this.baseScale = width / this.imageEl.OriginHeight;
31665 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
31666 height = this.thumbEl.getWidth();
31667 this.baseScale = height / this.imageEl.OriginHeight;
31670 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
31671 height = this.thumbEl.getWidth();
31672 this.baseScale = height / this.imageEl.OriginHeight;
31674 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
31675 width = this.thumbEl.getHeight();
31676 this.baseScale = width / this.imageEl.OriginWidth;
31683 width = this.thumbEl.getWidth();
31684 this.baseScale = width / this.imageEl.OriginWidth;
31686 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
31687 height = this.thumbEl.getHeight();
31688 this.baseScale = height / this.imageEl.OriginHeight;
31691 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
31693 height = this.thumbEl.getHeight();
31694 this.baseScale = height / this.imageEl.OriginHeight;
31696 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
31697 width = this.thumbEl.getWidth();
31698 this.baseScale = width / this.imageEl.OriginWidth;
31706 getScaleLevel : function()
31708 return this.baseScale * Math.pow(1.1, this.scale);
31711 onTouchStart : function(e)
31713 if(!this.canvasLoaded){
31714 this.beforeSelectFile(e);
31718 var touches = e.browserEvent.touches;
31724 if(touches.length == 1){
31725 this.onMouseDown(e);
31729 if(touches.length != 2){
31735 for(var i = 0, finger; finger = touches[i]; i++){
31736 coords.push(finger.pageX, finger.pageY);
31739 var x = Math.pow(coords[0] - coords[2], 2);
31740 var y = Math.pow(coords[1] - coords[3], 2);
31742 this.startDistance = Math.sqrt(x + y);
31744 this.startScale = this.scale;
31746 this.pinching = true;
31747 this.dragable = false;
31751 onTouchMove : function(e)
31753 if(!this.pinching && !this.dragable){
31757 var touches = e.browserEvent.touches;
31764 this.onMouseMove(e);
31770 for(var i = 0, finger; finger = touches[i]; i++){
31771 coords.push(finger.pageX, finger.pageY);
31774 var x = Math.pow(coords[0] - coords[2], 2);
31775 var y = Math.pow(coords[1] - coords[3], 2);
31777 this.endDistance = Math.sqrt(x + y);
31779 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
31781 if(!this.zoomable()){
31782 this.scale = this.startScale;
31790 onTouchEnd : function(e)
31792 this.pinching = false;
31793 this.dragable = false;
31797 process : function(file, crop)
31800 this.maskEl.mask(this.loadingText);
31803 this.xhr = new XMLHttpRequest();
31805 file.xhr = this.xhr;
31807 this.xhr.open(this.method, this.url, true);
31810 "Accept": "application/json",
31811 "Cache-Control": "no-cache",
31812 "X-Requested-With": "XMLHttpRequest"
31815 for (var headerName in headers) {
31816 var headerValue = headers[headerName];
31818 this.xhr.setRequestHeader(headerName, headerValue);
31824 this.xhr.onload = function()
31826 _this.xhrOnLoad(_this.xhr);
31829 this.xhr.onerror = function()
31831 _this.xhrOnError(_this.xhr);
31834 var formData = new FormData();
31836 formData.append('returnHTML', 'NO');
31839 formData.append('crop', crop);
31842 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
31843 formData.append(this.paramName, file, file.name);
31846 if(typeof(file.filename) != 'undefined'){
31847 formData.append('filename', file.filename);
31850 if(typeof(file.mimetype) != 'undefined'){
31851 formData.append('mimetype', file.mimetype);
31854 if(this.fireEvent('arrange', this, formData) != false){
31855 this.xhr.send(formData);
31859 xhrOnLoad : function(xhr)
31862 this.maskEl.unmask();
31865 if (xhr.readyState !== 4) {
31866 this.fireEvent('exception', this, xhr);
31870 var response = Roo.decode(xhr.responseText);
31872 if(!response.success){
31873 this.fireEvent('exception', this, xhr);
31877 var response = Roo.decode(xhr.responseText);
31879 this.fireEvent('upload', this, response);
31883 xhrOnError : function()
31886 this.maskEl.unmask();
31889 Roo.log('xhr on error');
31891 var response = Roo.decode(xhr.responseText);
31897 prepare : function(file)
31900 this.maskEl.mask(this.loadingText);
31906 if(typeof(file) === 'string'){
31907 this.loadCanvas(file);
31911 if(!file || !this.urlAPI){
31916 this.cropType = file.type;
31920 if(this.fireEvent('prepare', this, this.file) != false){
31922 var reader = new FileReader();
31924 reader.onload = function (e) {
31925 if (e.target.error) {
31926 Roo.log(e.target.error);
31930 var buffer = e.target.result,
31931 dataView = new DataView(buffer),
31933 maxOffset = dataView.byteLength - 4,
31937 if (dataView.getUint16(0) === 0xffd8) {
31938 while (offset < maxOffset) {
31939 markerBytes = dataView.getUint16(offset);
31941 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
31942 markerLength = dataView.getUint16(offset + 2) + 2;
31943 if (offset + markerLength > dataView.byteLength) {
31944 Roo.log('Invalid meta data: Invalid segment size.');
31948 if(markerBytes == 0xffe1){
31949 _this.parseExifData(
31956 offset += markerLength;
31966 var url = _this.urlAPI.createObjectURL(_this.file);
31968 _this.loadCanvas(url);
31973 reader.readAsArrayBuffer(this.file);
31979 parseExifData : function(dataView, offset, length)
31981 var tiffOffset = offset + 10,
31985 if (dataView.getUint32(offset + 4) !== 0x45786966) {
31986 // No Exif data, might be XMP data instead
31990 // Check for the ASCII code for "Exif" (0x45786966):
31991 if (dataView.getUint32(offset + 4) !== 0x45786966) {
31992 // No Exif data, might be XMP data instead
31995 if (tiffOffset + 8 > dataView.byteLength) {
31996 Roo.log('Invalid Exif data: Invalid segment size.');
31999 // Check for the two null bytes:
32000 if (dataView.getUint16(offset + 8) !== 0x0000) {
32001 Roo.log('Invalid Exif data: Missing byte alignment offset.');
32004 // Check the byte alignment:
32005 switch (dataView.getUint16(tiffOffset)) {
32007 littleEndian = true;
32010 littleEndian = false;
32013 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
32016 // Check for the TIFF tag marker (0x002A):
32017 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
32018 Roo.log('Invalid Exif data: Missing TIFF marker.');
32021 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
32022 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
32024 this.parseExifTags(
32027 tiffOffset + dirOffset,
32032 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
32037 if (dirOffset + 6 > dataView.byteLength) {
32038 Roo.log('Invalid Exif data: Invalid directory offset.');
32041 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
32042 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
32043 if (dirEndOffset + 4 > dataView.byteLength) {
32044 Roo.log('Invalid Exif data: Invalid directory size.');
32047 for (i = 0; i < tagsNumber; i += 1) {
32051 dirOffset + 2 + 12 * i, // tag offset
32055 // Return the offset to the next directory:
32056 return dataView.getUint32(dirEndOffset, littleEndian);
32059 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
32061 var tag = dataView.getUint16(offset, littleEndian);
32063 this.exif[tag] = this.getExifValue(
32067 dataView.getUint16(offset + 2, littleEndian), // tag type
32068 dataView.getUint32(offset + 4, littleEndian), // tag length
32073 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
32075 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
32084 Roo.log('Invalid Exif data: Invalid tag type.');
32088 tagSize = tagType.size * length;
32089 // Determine if the value is contained in the dataOffset bytes,
32090 // or if the value at the dataOffset is a pointer to the actual data:
32091 dataOffset = tagSize > 4 ?
32092 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
32093 if (dataOffset + tagSize > dataView.byteLength) {
32094 Roo.log('Invalid Exif data: Invalid data offset.');
32097 if (length === 1) {
32098 return tagType.getValue(dataView, dataOffset, littleEndian);
32101 for (i = 0; i < length; i += 1) {
32102 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
32105 if (tagType.ascii) {
32107 // Concatenate the chars:
32108 for (i = 0; i < values.length; i += 1) {
32110 // Ignore the terminating NULL byte(s):
32111 if (c === '\u0000') {
32123 Roo.apply(Roo.bootstrap.UploadCropbox, {
32125 'Orientation': 0x0112
32129 1: 0, //'top-left',
32131 3: 180, //'bottom-right',
32132 // 4: 'bottom-left',
32134 6: 90, //'right-top',
32135 // 7: 'right-bottom',
32136 8: 270 //'left-bottom'
32140 // byte, 8-bit unsigned int:
32142 getValue: function (dataView, dataOffset) {
32143 return dataView.getUint8(dataOffset);
32147 // ascii, 8-bit byte:
32149 getValue: function (dataView, dataOffset) {
32150 return String.fromCharCode(dataView.getUint8(dataOffset));
32155 // short, 16 bit int:
32157 getValue: function (dataView, dataOffset, littleEndian) {
32158 return dataView.getUint16(dataOffset, littleEndian);
32162 // long, 32 bit int:
32164 getValue: function (dataView, dataOffset, littleEndian) {
32165 return dataView.getUint32(dataOffset, littleEndian);
32169 // rational = two long values, first is numerator, second is denominator:
32171 getValue: function (dataView, dataOffset, littleEndian) {
32172 return dataView.getUint32(dataOffset, littleEndian) /
32173 dataView.getUint32(dataOffset + 4, littleEndian);
32177 // slong, 32 bit signed int:
32179 getValue: function (dataView, dataOffset, littleEndian) {
32180 return dataView.getInt32(dataOffset, littleEndian);
32184 // srational, two slongs, first is numerator, second is denominator:
32186 getValue: function (dataView, dataOffset, littleEndian) {
32187 return dataView.getInt32(dataOffset, littleEndian) /
32188 dataView.getInt32(dataOffset + 4, littleEndian);
32198 cls : 'btn-group roo-upload-cropbox-rotate-left',
32199 action : 'rotate-left',
32203 cls : 'btn btn-default',
32204 html : '<i class="fa fa-undo"></i>'
32210 cls : 'btn-group roo-upload-cropbox-picture',
32211 action : 'picture',
32215 cls : 'btn btn-default',
32216 html : '<i class="fa fa-picture-o"></i>'
32222 cls : 'btn-group roo-upload-cropbox-rotate-right',
32223 action : 'rotate-right',
32227 cls : 'btn btn-default',
32228 html : '<i class="fa fa-repeat"></i>'
32236 cls : 'btn-group roo-upload-cropbox-rotate-left',
32237 action : 'rotate-left',
32241 cls : 'btn btn-default',
32242 html : '<i class="fa fa-undo"></i>'
32248 cls : 'btn-group roo-upload-cropbox-download',
32249 action : 'download',
32253 cls : 'btn btn-default',
32254 html : '<i class="fa fa-download"></i>'
32260 cls : 'btn-group roo-upload-cropbox-crop',
32265 cls : 'btn btn-default',
32266 html : '<i class="fa fa-crop"></i>'
32272 cls : 'btn-group roo-upload-cropbox-trash',
32277 cls : 'btn btn-default',
32278 html : '<i class="fa fa-trash"></i>'
32284 cls : 'btn-group roo-upload-cropbox-rotate-right',
32285 action : 'rotate-right',
32289 cls : 'btn btn-default',
32290 html : '<i class="fa fa-repeat"></i>'
32298 cls : 'btn-group roo-upload-cropbox-rotate-left',
32299 action : 'rotate-left',
32303 cls : 'btn btn-default',
32304 html : '<i class="fa fa-undo"></i>'
32310 cls : 'btn-group roo-upload-cropbox-rotate-right',
32311 action : 'rotate-right',
32315 cls : 'btn btn-default',
32316 html : '<i class="fa fa-repeat"></i>'
32329 * @class Roo.bootstrap.DocumentManager
32330 * @extends Roo.bootstrap.Component
32331 * Bootstrap DocumentManager class
32332 * @cfg {String} paramName default 'imageUpload'
32333 * @cfg {String} toolTipName default 'filename'
32334 * @cfg {String} method default POST
32335 * @cfg {String} url action url
32336 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
32337 * @cfg {Boolean} multiple multiple upload default true
32338 * @cfg {Number} thumbSize default 300
32339 * @cfg {String} fieldLabel
32340 * @cfg {Number} labelWidth default 4
32341 * @cfg {String} labelAlign (left|top) default left
32342 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
32343 * @cfg {Number} labellg set the width of label (1-12)
32344 * @cfg {Number} labelmd set the width of label (1-12)
32345 * @cfg {Number} labelsm set the width of label (1-12)
32346 * @cfg {Number} labelxs set the width of label (1-12)
32349 * Create a new DocumentManager
32350 * @param {Object} config The config object
32353 Roo.bootstrap.DocumentManager = function(config){
32354 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
32357 this.delegates = [];
32362 * Fire when initial the DocumentManager
32363 * @param {Roo.bootstrap.DocumentManager} this
32368 * inspect selected file
32369 * @param {Roo.bootstrap.DocumentManager} this
32370 * @param {File} file
32375 * Fire when xhr load exception
32376 * @param {Roo.bootstrap.DocumentManager} this
32377 * @param {XMLHttpRequest} xhr
32379 "exception" : true,
32381 * @event afterupload
32382 * Fire when xhr load exception
32383 * @param {Roo.bootstrap.DocumentManager} this
32384 * @param {XMLHttpRequest} xhr
32386 "afterupload" : true,
32389 * prepare the form data
32390 * @param {Roo.bootstrap.DocumentManager} this
32391 * @param {Object} formData
32396 * Fire when remove the file
32397 * @param {Roo.bootstrap.DocumentManager} this
32398 * @param {Object} file
32403 * Fire after refresh the file
32404 * @param {Roo.bootstrap.DocumentManager} this
32409 * Fire after click the image
32410 * @param {Roo.bootstrap.DocumentManager} this
32411 * @param {Object} file
32416 * Fire when upload a image and editable set to true
32417 * @param {Roo.bootstrap.DocumentManager} this
32418 * @param {Object} file
32422 * @event beforeselectfile
32423 * Fire before select file
32424 * @param {Roo.bootstrap.DocumentManager} this
32426 "beforeselectfile" : true,
32429 * Fire before process file
32430 * @param {Roo.bootstrap.DocumentManager} this
32431 * @param {Object} file
32435 * @event previewrendered
32436 * Fire when preview rendered
32437 * @param {Roo.bootstrap.DocumentManager} this
32438 * @param {Object} file
32440 "previewrendered" : true,
32443 "previewResize" : true
32448 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
32457 paramName : 'imageUpload',
32458 toolTipName : 'filename',
32461 labelAlign : 'left',
32471 getAutoCreate : function()
32473 var managerWidget = {
32475 cls : 'roo-document-manager',
32479 cls : 'roo-document-manager-selector',
32484 cls : 'roo-document-manager-uploader',
32488 cls : 'roo-document-manager-upload-btn',
32489 html : '<i class="fa fa-plus"></i>'
32500 cls : 'column col-md-12',
32505 if(this.fieldLabel.length){
32510 cls : 'column col-md-12',
32511 html : this.fieldLabel
32515 cls : 'column col-md-12',
32520 if(this.labelAlign == 'left'){
32525 html : this.fieldLabel
32534 if(this.labelWidth > 12){
32535 content[0].style = "width: " + this.labelWidth + 'px';
32538 if(this.labelWidth < 13 && this.labelmd == 0){
32539 this.labelmd = this.labelWidth;
32542 if(this.labellg > 0){
32543 content[0].cls += ' col-lg-' + this.labellg;
32544 content[1].cls += ' col-lg-' + (12 - this.labellg);
32547 if(this.labelmd > 0){
32548 content[0].cls += ' col-md-' + this.labelmd;
32549 content[1].cls += ' col-md-' + (12 - this.labelmd);
32552 if(this.labelsm > 0){
32553 content[0].cls += ' col-sm-' + this.labelsm;
32554 content[1].cls += ' col-sm-' + (12 - this.labelsm);
32557 if(this.labelxs > 0){
32558 content[0].cls += ' col-xs-' + this.labelxs;
32559 content[1].cls += ' col-xs-' + (12 - this.labelxs);
32567 cls : 'row clearfix',
32575 initEvents : function()
32577 this.managerEl = this.el.select('.roo-document-manager', true).first();
32578 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
32580 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
32581 this.selectorEl.hide();
32584 this.selectorEl.attr('multiple', 'multiple');
32587 this.selectorEl.on('change', this.onFileSelected, this);
32589 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
32590 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
32592 this.uploader.on('click', this.onUploaderClick, this);
32594 this.renderProgressDialog();
32598 window.addEventListener("resize", function() { _this.refresh(); } );
32600 this.fireEvent('initial', this);
32603 renderProgressDialog : function()
32607 this.progressDialog = new Roo.bootstrap.Modal({
32608 cls : 'roo-document-manager-progress-dialog',
32609 allow_close : false,
32620 btnclick : function() {
32621 _this.uploadCancel();
32627 this.progressDialog.render(Roo.get(document.body));
32629 this.progress = new Roo.bootstrap.Progress({
32630 cls : 'roo-document-manager-progress',
32635 this.progress.render(this.progressDialog.getChildContainer());
32637 this.progressBar = new Roo.bootstrap.ProgressBar({
32638 cls : 'roo-document-manager-progress-bar',
32641 aria_valuemax : 12,
32645 this.progressBar.render(this.progress.getChildContainer());
32648 onUploaderClick : function(e)
32650 e.preventDefault();
32652 if(this.fireEvent('beforeselectfile', this) != false){
32653 this.selectorEl.dom.click();
32658 onFileSelected : function(e)
32660 e.preventDefault();
32662 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
32666 Roo.each(this.selectorEl.dom.files, function(file){
32667 if(this.fireEvent('inspect', this, file) != false){
32668 this.files.push(file);
32678 this.selectorEl.dom.value = '';
32680 if(!this.files || !this.files.length){
32684 if(this.boxes > 0 && this.files.length > this.boxes){
32685 this.files = this.files.slice(0, this.boxes);
32688 this.uploader.show();
32690 if(this.boxes > 0 && this.files.length > this.boxes - 1){
32691 this.uploader.hide();
32700 Roo.each(this.files, function(file){
32702 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
32703 var f = this.renderPreview(file);
32708 if(file.type.indexOf('image') != -1){
32709 this.delegates.push(
32711 _this.process(file);
32712 }).createDelegate(this)
32720 _this.process(file);
32721 }).createDelegate(this)
32726 this.files = files;
32728 this.delegates = this.delegates.concat(docs);
32730 if(!this.delegates.length){
32735 this.progressBar.aria_valuemax = this.delegates.length;
32742 arrange : function()
32744 if(!this.delegates.length){
32745 this.progressDialog.hide();
32750 var delegate = this.delegates.shift();
32752 this.progressDialog.show();
32754 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
32756 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
32761 refresh : function()
32763 this.uploader.show();
32765 if(this.boxes > 0 && this.files.length > this.boxes - 1){
32766 this.uploader.hide();
32769 Roo.isTouch ? this.closable(false) : this.closable(true);
32771 this.fireEvent('refresh', this);
32774 onRemove : function(e, el, o)
32776 e.preventDefault();
32778 this.fireEvent('remove', this, o);
32782 remove : function(o)
32786 Roo.each(this.files, function(file){
32787 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
32796 this.files = files;
32803 Roo.each(this.files, function(file){
32808 file.target.remove();
32817 onClick : function(e, el, o)
32819 e.preventDefault();
32821 this.fireEvent('click', this, o);
32825 closable : function(closable)
32827 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
32829 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
32841 xhrOnLoad : function(xhr)
32843 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
32847 if (xhr.readyState !== 4) {
32849 this.fireEvent('exception', this, xhr);
32853 var response = Roo.decode(xhr.responseText);
32855 if(!response.success){
32857 this.fireEvent('exception', this, xhr);
32861 var file = this.renderPreview(response.data);
32863 this.files.push(file);
32867 this.fireEvent('afterupload', this, xhr);
32871 xhrOnError : function(xhr)
32873 Roo.log('xhr on error');
32875 var response = Roo.decode(xhr.responseText);
32882 process : function(file)
32884 if(this.fireEvent('process', this, file) !== false){
32885 if(this.editable && file.type.indexOf('image') != -1){
32886 this.fireEvent('edit', this, file);
32890 this.uploadStart(file, false);
32897 uploadStart : function(file, crop)
32899 this.xhr = new XMLHttpRequest();
32901 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
32906 file.xhr = this.xhr;
32908 this.managerEl.createChild({
32910 cls : 'roo-document-manager-loading',
32914 tooltip : file.name,
32915 cls : 'roo-document-manager-thumb',
32916 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
32922 this.xhr.open(this.method, this.url, true);
32925 "Accept": "application/json",
32926 "Cache-Control": "no-cache",
32927 "X-Requested-With": "XMLHttpRequest"
32930 for (var headerName in headers) {
32931 var headerValue = headers[headerName];
32933 this.xhr.setRequestHeader(headerName, headerValue);
32939 this.xhr.onload = function()
32941 _this.xhrOnLoad(_this.xhr);
32944 this.xhr.onerror = function()
32946 _this.xhrOnError(_this.xhr);
32949 var formData = new FormData();
32951 formData.append('returnHTML', 'NO');
32954 formData.append('crop', crop);
32957 formData.append(this.paramName, file, file.name);
32964 if(this.fireEvent('prepare', this, formData, options) != false){
32966 if(options.manually){
32970 this.xhr.send(formData);
32974 this.uploadCancel();
32977 uploadCancel : function()
32983 this.delegates = [];
32985 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
32992 renderPreview : function(file)
32994 if(typeof(file.target) != 'undefined' && file.target){
32998 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
33000 var previewEl = this.managerEl.createChild({
33002 cls : 'roo-document-manager-preview',
33006 tooltip : file[this.toolTipName],
33007 cls : 'roo-document-manager-thumb',
33008 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
33013 html : '<i class="fa fa-times-circle"></i>'
33018 var close = previewEl.select('button.close', true).first();
33020 close.on('click', this.onRemove, this, file);
33022 file.target = previewEl;
33024 var image = previewEl.select('img', true).first();
33028 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
33030 image.on('click', this.onClick, this, file);
33032 this.fireEvent('previewrendered', this, file);
33038 onPreviewLoad : function(file, image)
33040 if(typeof(file.target) == 'undefined' || !file.target){
33044 var width = image.dom.naturalWidth || image.dom.width;
33045 var height = image.dom.naturalHeight || image.dom.height;
33047 if(!this.previewResize) {
33051 if(width > height){
33052 file.target.addClass('wide');
33056 file.target.addClass('tall');
33061 uploadFromSource : function(file, crop)
33063 this.xhr = new XMLHttpRequest();
33065 this.managerEl.createChild({
33067 cls : 'roo-document-manager-loading',
33071 tooltip : file.name,
33072 cls : 'roo-document-manager-thumb',
33073 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
33079 this.xhr.open(this.method, this.url, true);
33082 "Accept": "application/json",
33083 "Cache-Control": "no-cache",
33084 "X-Requested-With": "XMLHttpRequest"
33087 for (var headerName in headers) {
33088 var headerValue = headers[headerName];
33090 this.xhr.setRequestHeader(headerName, headerValue);
33096 this.xhr.onload = function()
33098 _this.xhrOnLoad(_this.xhr);
33101 this.xhr.onerror = function()
33103 _this.xhrOnError(_this.xhr);
33106 var formData = new FormData();
33108 formData.append('returnHTML', 'NO');
33110 formData.append('crop', crop);
33112 if(typeof(file.filename) != 'undefined'){
33113 formData.append('filename', file.filename);
33116 if(typeof(file.mimetype) != 'undefined'){
33117 formData.append('mimetype', file.mimetype);
33122 if(this.fireEvent('prepare', this, formData) != false){
33123 this.xhr.send(formData);
33133 * @class Roo.bootstrap.DocumentViewer
33134 * @extends Roo.bootstrap.Component
33135 * Bootstrap DocumentViewer class
33136 * @cfg {Boolean} showDownload (true|false) show download button (default true)
33137 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
33140 * Create a new DocumentViewer
33141 * @param {Object} config The config object
33144 Roo.bootstrap.DocumentViewer = function(config){
33145 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
33150 * Fire after initEvent
33151 * @param {Roo.bootstrap.DocumentViewer} this
33157 * @param {Roo.bootstrap.DocumentViewer} this
33162 * Fire after download button
33163 * @param {Roo.bootstrap.DocumentViewer} this
33168 * Fire after trash button
33169 * @param {Roo.bootstrap.DocumentViewer} this
33176 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
33178 showDownload : true,
33182 getAutoCreate : function()
33186 cls : 'roo-document-viewer',
33190 cls : 'roo-document-viewer-body',
33194 cls : 'roo-document-viewer-thumb',
33198 cls : 'roo-document-viewer-image'
33206 cls : 'roo-document-viewer-footer',
33209 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
33213 cls : 'btn-group roo-document-viewer-download',
33217 cls : 'btn btn-default',
33218 html : '<i class="fa fa-download"></i>'
33224 cls : 'btn-group roo-document-viewer-trash',
33228 cls : 'btn btn-default',
33229 html : '<i class="fa fa-trash"></i>'
33242 initEvents : function()
33244 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
33245 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
33247 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
33248 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
33250 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
33251 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
33253 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
33254 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
33256 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
33257 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
33259 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
33260 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
33262 this.bodyEl.on('click', this.onClick, this);
33263 this.downloadBtn.on('click', this.onDownload, this);
33264 this.trashBtn.on('click', this.onTrash, this);
33266 this.downloadBtn.hide();
33267 this.trashBtn.hide();
33269 if(this.showDownload){
33270 this.downloadBtn.show();
33273 if(this.showTrash){
33274 this.trashBtn.show();
33277 if(!this.showDownload && !this.showTrash) {
33278 this.footerEl.hide();
33283 initial : function()
33285 this.fireEvent('initial', this);
33289 onClick : function(e)
33291 e.preventDefault();
33293 this.fireEvent('click', this);
33296 onDownload : function(e)
33298 e.preventDefault();
33300 this.fireEvent('download', this);
33303 onTrash : function(e)
33305 e.preventDefault();
33307 this.fireEvent('trash', this);
33319 * @class Roo.bootstrap.NavProgressBar
33320 * @extends Roo.bootstrap.Component
33321 * Bootstrap NavProgressBar class
33324 * Create a new nav progress bar
33325 * @param {Object} config The config object
33328 Roo.bootstrap.NavProgressBar = function(config){
33329 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
33331 this.bullets = this.bullets || [];
33333 // Roo.bootstrap.NavProgressBar.register(this);
33337 * Fires when the active item changes
33338 * @param {Roo.bootstrap.NavProgressBar} this
33339 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
33340 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
33347 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
33352 getAutoCreate : function()
33354 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
33358 cls : 'roo-navigation-bar-group',
33362 cls : 'roo-navigation-top-bar'
33366 cls : 'roo-navigation-bullets-bar',
33370 cls : 'roo-navigation-bar'
33377 cls : 'roo-navigation-bottom-bar'
33387 initEvents: function()
33392 onRender : function(ct, position)
33394 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
33396 if(this.bullets.length){
33397 Roo.each(this.bullets, function(b){
33406 addItem : function(cfg)
33408 var item = new Roo.bootstrap.NavProgressItem(cfg);
33410 item.parentId = this.id;
33411 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
33414 var top = new Roo.bootstrap.Element({
33416 cls : 'roo-navigation-bar-text'
33419 var bottom = new Roo.bootstrap.Element({
33421 cls : 'roo-navigation-bar-text'
33424 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
33425 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
33427 var topText = new Roo.bootstrap.Element({
33429 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
33432 var bottomText = new Roo.bootstrap.Element({
33434 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
33437 topText.onRender(top.el, null);
33438 bottomText.onRender(bottom.el, null);
33441 item.bottomEl = bottom;
33444 this.barItems.push(item);
33449 getActive : function()
33451 var active = false;
33453 Roo.each(this.barItems, function(v){
33455 if (!v.isActive()) {
33467 setActiveItem : function(item)
33471 Roo.each(this.barItems, function(v){
33472 if (v.rid == item.rid) {
33476 if (v.isActive()) {
33477 v.setActive(false);
33482 item.setActive(true);
33484 this.fireEvent('changed', this, item, prev);
33487 getBarItem: function(rid)
33491 Roo.each(this.barItems, function(e) {
33492 if (e.rid != rid) {
33503 indexOfItem : function(item)
33507 Roo.each(this.barItems, function(v, i){
33509 if (v.rid != item.rid) {
33520 setActiveNext : function()
33522 var i = this.indexOfItem(this.getActive());
33524 if (i > this.barItems.length) {
33528 this.setActiveItem(this.barItems[i+1]);
33531 setActivePrev : function()
33533 var i = this.indexOfItem(this.getActive());
33539 this.setActiveItem(this.barItems[i-1]);
33542 format : function()
33544 if(!this.barItems.length){
33548 var width = 100 / this.barItems.length;
33550 Roo.each(this.barItems, function(i){
33551 i.el.setStyle('width', width + '%');
33552 i.topEl.el.setStyle('width', width + '%');
33553 i.bottomEl.el.setStyle('width', width + '%');
33562 * Nav Progress Item
33567 * @class Roo.bootstrap.NavProgressItem
33568 * @extends Roo.bootstrap.Component
33569 * Bootstrap NavProgressItem class
33570 * @cfg {String} rid the reference id
33571 * @cfg {Boolean} active (true|false) Is item active default false
33572 * @cfg {Boolean} disabled (true|false) Is item active default false
33573 * @cfg {String} html
33574 * @cfg {String} position (top|bottom) text position default bottom
33575 * @cfg {String} icon show icon instead of number
33578 * Create a new NavProgressItem
33579 * @param {Object} config The config object
33581 Roo.bootstrap.NavProgressItem = function(config){
33582 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
33587 * The raw click event for the entire grid.
33588 * @param {Roo.bootstrap.NavProgressItem} this
33589 * @param {Roo.EventObject} e
33596 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
33602 position : 'bottom',
33605 getAutoCreate : function()
33607 var iconCls = 'roo-navigation-bar-item-icon';
33609 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
33613 cls: 'roo-navigation-bar-item',
33623 cfg.cls += ' active';
33626 cfg.cls += ' disabled';
33632 disable : function()
33634 this.setDisabled(true);
33637 enable : function()
33639 this.setDisabled(false);
33642 initEvents: function()
33644 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
33646 this.iconEl.on('click', this.onClick, this);
33649 onClick : function(e)
33651 e.preventDefault();
33657 if(this.fireEvent('click', this, e) === false){
33661 this.parent().setActiveItem(this);
33664 isActive: function ()
33666 return this.active;
33669 setActive : function(state)
33671 if(this.active == state){
33675 this.active = state;
33678 this.el.addClass('active');
33682 this.el.removeClass('active');
33687 setDisabled : function(state)
33689 if(this.disabled == state){
33693 this.disabled = state;
33696 this.el.addClass('disabled');
33700 this.el.removeClass('disabled');
33703 tooltipEl : function()
33705 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
33718 * @class Roo.bootstrap.FieldLabel
33719 * @extends Roo.bootstrap.Component
33720 * Bootstrap FieldLabel class
33721 * @cfg {String} html contents of the element
33722 * @cfg {String} tag tag of the element default label
33723 * @cfg {String} cls class of the element
33724 * @cfg {String} target label target
33725 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
33726 * @cfg {String} invalidClass DEPRICATED - BS4 uses is-invalid
33727 * @cfg {String} validClass DEPRICATED - BS4 uses is-valid
33728 * @cfg {String} iconTooltip default "This field is required"
33729 * @cfg {String} indicatorpos (left|right) default left
33732 * Create a new FieldLabel
33733 * @param {Object} config The config object
33736 Roo.bootstrap.FieldLabel = function(config){
33737 Roo.bootstrap.Element.superclass.constructor.call(this, config);
33742 * Fires after the field has been marked as invalid.
33743 * @param {Roo.form.FieldLabel} this
33744 * @param {String} msg The validation message
33749 * Fires after the field has been validated with no errors.
33750 * @param {Roo.form.FieldLabel} this
33756 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
33763 invalidClass : 'has-warning',
33764 validClass : 'has-success',
33765 iconTooltip : 'This field is required',
33766 indicatorpos : 'left',
33768 getAutoCreate : function(){
33771 if (!this.allowBlank) {
33777 cls : 'roo-bootstrap-field-label ' + this.cls,
33782 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star ' + cls,
33783 tooltip : this.iconTooltip
33792 if(this.indicatorpos == 'right'){
33795 cls : 'roo-bootstrap-field-label ' + this.cls,
33804 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star '+ cls,
33805 tooltip : this.iconTooltip
33814 initEvents: function()
33816 Roo.bootstrap.Element.superclass.initEvents.call(this);
33818 this.indicator = this.indicatorEl();
33820 if(this.indicator){
33821 this.indicator.removeClass('visible');
33822 this.indicator.addClass('invisible');
33825 Roo.bootstrap.FieldLabel.register(this);
33828 indicatorEl : function()
33830 var indicator = this.el.select('i.roo-required-indicator',true).first();
33841 * Mark this field as valid
33843 markValid : function()
33845 if(this.indicator){
33846 this.indicator.removeClass('visible');
33847 this.indicator.addClass('invisible');
33849 if (Roo.bootstrap.version == 3) {
33850 this.el.removeClass(this.invalidClass);
33851 this.el.addClass(this.validClass);
33853 this.el.removeClass('is-invalid');
33854 this.el.addClass('is-valid');
33858 this.fireEvent('valid', this);
33862 * Mark this field as invalid
33863 * @param {String} msg The validation message
33865 markInvalid : function(msg)
33867 if(this.indicator){
33868 this.indicator.removeClass('invisible');
33869 this.indicator.addClass('visible');
33871 if (Roo.bootstrap.version == 3) {
33872 this.el.removeClass(this.validClass);
33873 this.el.addClass(this.invalidClass);
33875 this.el.removeClass('is-valid');
33876 this.el.addClass('is-invalid');
33880 this.fireEvent('invalid', this, msg);
33886 Roo.apply(Roo.bootstrap.FieldLabel, {
33891 * register a FieldLabel Group
33892 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
33894 register : function(label)
33896 if(this.groups.hasOwnProperty(label.target)){
33900 this.groups[label.target] = label;
33904 * fetch a FieldLabel Group based on the target
33905 * @param {string} target
33906 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
33908 get: function(target) {
33909 if (typeof(this.groups[target]) == 'undefined') {
33913 return this.groups[target] ;
33922 * page DateSplitField.
33928 * @class Roo.bootstrap.DateSplitField
33929 * @extends Roo.bootstrap.Component
33930 * Bootstrap DateSplitField class
33931 * @cfg {string} fieldLabel - the label associated
33932 * @cfg {Number} labelWidth set the width of label (0-12)
33933 * @cfg {String} labelAlign (top|left)
33934 * @cfg {Boolean} dayAllowBlank (true|false) default false
33935 * @cfg {Boolean} monthAllowBlank (true|false) default false
33936 * @cfg {Boolean} yearAllowBlank (true|false) default false
33937 * @cfg {string} dayPlaceholder
33938 * @cfg {string} monthPlaceholder
33939 * @cfg {string} yearPlaceholder
33940 * @cfg {string} dayFormat default 'd'
33941 * @cfg {string} monthFormat default 'm'
33942 * @cfg {string} yearFormat default 'Y'
33943 * @cfg {Number} labellg set the width of label (1-12)
33944 * @cfg {Number} labelmd set the width of label (1-12)
33945 * @cfg {Number} labelsm set the width of label (1-12)
33946 * @cfg {Number} labelxs set the width of label (1-12)
33950 * Create a new DateSplitField
33951 * @param {Object} config The config object
33954 Roo.bootstrap.DateSplitField = function(config){
33955 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
33961 * getting the data of years
33962 * @param {Roo.bootstrap.DateSplitField} this
33963 * @param {Object} years
33968 * getting the data of days
33969 * @param {Roo.bootstrap.DateSplitField} this
33970 * @param {Object} days
33975 * Fires after the field has been marked as invalid.
33976 * @param {Roo.form.Field} this
33977 * @param {String} msg The validation message
33982 * Fires after the field has been validated with no errors.
33983 * @param {Roo.form.Field} this
33989 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
33992 labelAlign : 'top',
33994 dayAllowBlank : false,
33995 monthAllowBlank : false,
33996 yearAllowBlank : false,
33997 dayPlaceholder : '',
33998 monthPlaceholder : '',
33999 yearPlaceholder : '',
34003 isFormField : true,
34009 getAutoCreate : function()
34013 cls : 'row roo-date-split-field-group',
34018 cls : 'form-hidden-field roo-date-split-field-group-value',
34024 var labelCls = 'col-md-12';
34025 var contentCls = 'col-md-4';
34027 if(this.fieldLabel){
34031 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
34035 html : this.fieldLabel
34040 if(this.labelAlign == 'left'){
34042 if(this.labelWidth > 12){
34043 label.style = "width: " + this.labelWidth + 'px';
34046 if(this.labelWidth < 13 && this.labelmd == 0){
34047 this.labelmd = this.labelWidth;
34050 if(this.labellg > 0){
34051 labelCls = ' col-lg-' + this.labellg;
34052 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
34055 if(this.labelmd > 0){
34056 labelCls = ' col-md-' + this.labelmd;
34057 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
34060 if(this.labelsm > 0){
34061 labelCls = ' col-sm-' + this.labelsm;
34062 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
34065 if(this.labelxs > 0){
34066 labelCls = ' col-xs-' + this.labelxs;
34067 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
34071 label.cls += ' ' + labelCls;
34073 cfg.cn.push(label);
34076 Roo.each(['day', 'month', 'year'], function(t){
34079 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
34086 inputEl: function ()
34088 return this.el.select('.roo-date-split-field-group-value', true).first();
34091 onRender : function(ct, position)
34095 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
34097 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
34099 this.dayField = new Roo.bootstrap.ComboBox({
34100 allowBlank : this.dayAllowBlank,
34101 alwaysQuery : true,
34102 displayField : 'value',
34105 forceSelection : true,
34107 placeholder : this.dayPlaceholder,
34108 selectOnFocus : true,
34109 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
34110 triggerAction : 'all',
34112 valueField : 'value',
34113 store : new Roo.data.SimpleStore({
34114 data : (function() {
34116 _this.fireEvent('days', _this, days);
34119 fields : [ 'value' ]
34122 select : function (_self, record, index)
34124 _this.setValue(_this.getValue());
34129 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
34131 this.monthField = new Roo.bootstrap.MonthField({
34132 after : '<i class=\"fa fa-calendar\"></i>',
34133 allowBlank : this.monthAllowBlank,
34134 placeholder : this.monthPlaceholder,
34137 render : function (_self)
34139 this.el.select('span.input-group-addon', true).first().on('click', function(e){
34140 e.preventDefault();
34144 select : function (_self, oldvalue, newvalue)
34146 _this.setValue(_this.getValue());
34151 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
34153 this.yearField = new Roo.bootstrap.ComboBox({
34154 allowBlank : this.yearAllowBlank,
34155 alwaysQuery : true,
34156 displayField : 'value',
34159 forceSelection : true,
34161 placeholder : this.yearPlaceholder,
34162 selectOnFocus : true,
34163 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
34164 triggerAction : 'all',
34166 valueField : 'value',
34167 store : new Roo.data.SimpleStore({
34168 data : (function() {
34170 _this.fireEvent('years', _this, years);
34173 fields : [ 'value' ]
34176 select : function (_self, record, index)
34178 _this.setValue(_this.getValue());
34183 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
34186 setValue : function(v, format)
34188 this.inputEl.dom.value = v;
34190 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
34192 var d = Date.parseDate(v, f);
34199 this.setDay(d.format(this.dayFormat));
34200 this.setMonth(d.format(this.monthFormat));
34201 this.setYear(d.format(this.yearFormat));
34208 setDay : function(v)
34210 this.dayField.setValue(v);
34211 this.inputEl.dom.value = this.getValue();
34216 setMonth : function(v)
34218 this.monthField.setValue(v, true);
34219 this.inputEl.dom.value = this.getValue();
34224 setYear : function(v)
34226 this.yearField.setValue(v);
34227 this.inputEl.dom.value = this.getValue();
34232 getDay : function()
34234 return this.dayField.getValue();
34237 getMonth : function()
34239 return this.monthField.getValue();
34242 getYear : function()
34244 return this.yearField.getValue();
34247 getValue : function()
34249 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
34251 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
34261 this.inputEl.dom.value = '';
34266 validate : function()
34268 var d = this.dayField.validate();
34269 var m = this.monthField.validate();
34270 var y = this.yearField.validate();
34275 (!this.dayAllowBlank && !d) ||
34276 (!this.monthAllowBlank && !m) ||
34277 (!this.yearAllowBlank && !y)
34282 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
34291 this.markInvalid();
34296 markValid : function()
34299 var label = this.el.select('label', true).first();
34300 var icon = this.el.select('i.fa-star', true).first();
34306 this.fireEvent('valid', this);
34310 * Mark this field as invalid
34311 * @param {String} msg The validation message
34313 markInvalid : function(msg)
34316 var label = this.el.select('label', true).first();
34317 var icon = this.el.select('i.fa-star', true).first();
34319 if(label && !icon){
34320 this.el.select('.roo-date-split-field-label', true).createChild({
34322 cls : 'text-danger fa fa-lg fa-star',
34323 tooltip : 'This field is required',
34324 style : 'margin-right:5px;'
34328 this.fireEvent('invalid', this, msg);
34331 clearInvalid : function()
34333 var label = this.el.select('label', true).first();
34334 var icon = this.el.select('i.fa-star', true).first();
34340 this.fireEvent('valid', this);
34343 getName: function()
34353 * http://masonry.desandro.com
34355 * The idea is to render all the bricks based on vertical width...
34357 * The original code extends 'outlayer' - we might need to use that....
34363 * @class Roo.bootstrap.LayoutMasonry
34364 * @extends Roo.bootstrap.Component
34365 * Bootstrap Layout Masonry class
34368 * Create a new Element
34369 * @param {Object} config The config object
34372 Roo.bootstrap.LayoutMasonry = function(config){
34374 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
34378 Roo.bootstrap.LayoutMasonry.register(this);
34384 * Fire after layout the items
34385 * @param {Roo.bootstrap.LayoutMasonry} this
34386 * @param {Roo.EventObject} e
34393 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
34396 * @cfg {Boolean} isLayoutInstant = no animation?
34398 isLayoutInstant : false, // needed?
34401 * @cfg {Number} boxWidth width of the columns
34406 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
34411 * @cfg {Number} padWidth padding below box..
34416 * @cfg {Number} gutter gutter width..
34421 * @cfg {Number} maxCols maximum number of columns
34427 * @cfg {Boolean} isAutoInitial defalut true
34429 isAutoInitial : true,
34434 * @cfg {Boolean} isHorizontal defalut false
34436 isHorizontal : false,
34438 currentSize : null,
34444 bricks: null, //CompositeElement
34448 _isLayoutInited : false,
34450 // isAlternative : false, // only use for vertical layout...
34453 * @cfg {Number} alternativePadWidth padding below box..
34455 alternativePadWidth : 50,
34457 selectedBrick : [],
34459 getAutoCreate : function(){
34461 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
34465 cls: 'blog-masonary-wrapper ' + this.cls,
34467 cls : 'mas-boxes masonary'
34474 getChildContainer: function( )
34476 if (this.boxesEl) {
34477 return this.boxesEl;
34480 this.boxesEl = this.el.select('.mas-boxes').first();
34482 return this.boxesEl;
34486 initEvents : function()
34490 if(this.isAutoInitial){
34491 Roo.log('hook children rendered');
34492 this.on('childrenrendered', function() {
34493 Roo.log('children rendered');
34499 initial : function()
34501 this.selectedBrick = [];
34503 this.currentSize = this.el.getBox(true);
34505 Roo.EventManager.onWindowResize(this.resize, this);
34507 if(!this.isAutoInitial){
34515 //this.layout.defer(500,this);
34519 resize : function()
34521 var cs = this.el.getBox(true);
34524 this.currentSize.width == cs.width &&
34525 this.currentSize.x == cs.x &&
34526 this.currentSize.height == cs.height &&
34527 this.currentSize.y == cs.y
34529 Roo.log("no change in with or X or Y");
34533 this.currentSize = cs;
34539 layout : function()
34541 this._resetLayout();
34543 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
34545 this.layoutItems( isInstant );
34547 this._isLayoutInited = true;
34549 this.fireEvent('layout', this);
34553 _resetLayout : function()
34555 if(this.isHorizontal){
34556 this.horizontalMeasureColumns();
34560 this.verticalMeasureColumns();
34564 verticalMeasureColumns : function()
34566 this.getContainerWidth();
34568 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
34569 // this.colWidth = Math.floor(this.containerWidth * 0.8);
34573 var boxWidth = this.boxWidth + this.padWidth;
34575 if(this.containerWidth < this.boxWidth){
34576 boxWidth = this.containerWidth
34579 var containerWidth = this.containerWidth;
34581 var cols = Math.floor(containerWidth / boxWidth);
34583 this.cols = Math.max( cols, 1 );
34585 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
34587 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
34589 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
34591 this.colWidth = boxWidth + avail - this.padWidth;
34593 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
34594 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
34597 horizontalMeasureColumns : function()
34599 this.getContainerWidth();
34601 var boxWidth = this.boxWidth;
34603 if(this.containerWidth < boxWidth){
34604 boxWidth = this.containerWidth;
34607 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
34609 this.el.setHeight(boxWidth);
34613 getContainerWidth : function()
34615 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
34618 layoutItems : function( isInstant )
34620 Roo.log(this.bricks);
34622 var items = Roo.apply([], this.bricks);
34624 if(this.isHorizontal){
34625 this._horizontalLayoutItems( items , isInstant );
34629 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
34630 // this._verticalAlternativeLayoutItems( items , isInstant );
34634 this._verticalLayoutItems( items , isInstant );
34638 _verticalLayoutItems : function ( items , isInstant)
34640 if ( !items || !items.length ) {
34645 ['xs', 'xs', 'xs', 'tall'],
34646 ['xs', 'xs', 'tall'],
34647 ['xs', 'xs', 'sm'],
34648 ['xs', 'xs', 'xs'],
34654 ['sm', 'xs', 'xs'],
34658 ['tall', 'xs', 'xs', 'xs'],
34659 ['tall', 'xs', 'xs'],
34671 Roo.each(items, function(item, k){
34673 switch (item.size) {
34674 // these layouts take up a full box,
34685 boxes.push([item]);
34708 var filterPattern = function(box, length)
34716 var pattern = box.slice(0, length);
34720 Roo.each(pattern, function(i){
34721 format.push(i.size);
34724 Roo.each(standard, function(s){
34726 if(String(s) != String(format)){
34735 if(!match && length == 1){
34740 filterPattern(box, length - 1);
34744 queue.push(pattern);
34746 box = box.slice(length, box.length);
34748 filterPattern(box, 4);
34754 Roo.each(boxes, function(box, k){
34760 if(box.length == 1){
34765 filterPattern(box, 4);
34769 this._processVerticalLayoutQueue( queue, isInstant );
34773 // _verticalAlternativeLayoutItems : function( items , isInstant )
34775 // if ( !items || !items.length ) {
34779 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
34783 _horizontalLayoutItems : function ( items , isInstant)
34785 if ( !items || !items.length || items.length < 3) {
34791 var eItems = items.slice(0, 3);
34793 items = items.slice(3, items.length);
34796 ['xs', 'xs', 'xs', 'wide'],
34797 ['xs', 'xs', 'wide'],
34798 ['xs', 'xs', 'sm'],
34799 ['xs', 'xs', 'xs'],
34805 ['sm', 'xs', 'xs'],
34809 ['wide', 'xs', 'xs', 'xs'],
34810 ['wide', 'xs', 'xs'],
34823 Roo.each(items, function(item, k){
34825 switch (item.size) {
34836 boxes.push([item]);
34860 var filterPattern = function(box, length)
34868 var pattern = box.slice(0, length);
34872 Roo.each(pattern, function(i){
34873 format.push(i.size);
34876 Roo.each(standard, function(s){
34878 if(String(s) != String(format)){
34887 if(!match && length == 1){
34892 filterPattern(box, length - 1);
34896 queue.push(pattern);
34898 box = box.slice(length, box.length);
34900 filterPattern(box, 4);
34906 Roo.each(boxes, function(box, k){
34912 if(box.length == 1){
34917 filterPattern(box, 4);
34924 var pos = this.el.getBox(true);
34928 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
34930 var hit_end = false;
34932 Roo.each(queue, function(box){
34936 Roo.each(box, function(b){
34938 b.el.setVisibilityMode(Roo.Element.DISPLAY);
34948 Roo.each(box, function(b){
34950 b.el.setVisibilityMode(Roo.Element.DISPLAY);
34953 mx = Math.max(mx, b.x);
34957 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
34961 Roo.each(box, function(b){
34963 b.el.setVisibilityMode(Roo.Element.DISPLAY);
34977 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
34980 /** Sets position of item in DOM
34981 * @param {Element} item
34982 * @param {Number} x - horizontal position
34983 * @param {Number} y - vertical position
34984 * @param {Boolean} isInstant - disables transitions
34986 _processVerticalLayoutQueue : function( queue, isInstant )
34988 var pos = this.el.getBox(true);
34993 for (var i = 0; i < this.cols; i++){
34997 Roo.each(queue, function(box, k){
34999 var col = k % this.cols;
35001 Roo.each(box, function(b,kk){
35003 b.el.position('absolute');
35005 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
35006 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
35008 if(b.size == 'md-left' || b.size == 'md-right'){
35009 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
35010 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
35013 b.el.setWidth(width);
35014 b.el.setHeight(height);
35016 b.el.select('iframe',true).setSize(width,height);
35020 for (var i = 0; i < this.cols; i++){
35022 if(maxY[i] < maxY[col]){
35027 col = Math.min(col, i);
35031 x = pos.x + col * (this.colWidth + this.padWidth);
35035 var positions = [];
35037 switch (box.length){
35039 positions = this.getVerticalOneBoxColPositions(x, y, box);
35042 positions = this.getVerticalTwoBoxColPositions(x, y, box);
35045 positions = this.getVerticalThreeBoxColPositions(x, y, box);
35048 positions = this.getVerticalFourBoxColPositions(x, y, box);
35054 Roo.each(box, function(b,kk){
35056 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
35058 var sz = b.el.getSize();
35060 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
35068 for (var i = 0; i < this.cols; i++){
35069 mY = Math.max(mY, maxY[i]);
35072 this.el.setHeight(mY - pos.y);
35076 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
35078 // var pos = this.el.getBox(true);
35081 // var maxX = pos.right;
35083 // var maxHeight = 0;
35085 // Roo.each(items, function(item, k){
35089 // item.el.position('absolute');
35091 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
35093 // item.el.setWidth(width);
35095 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
35097 // item.el.setHeight(height);
35100 // item.el.setXY([x, y], isInstant ? false : true);
35102 // item.el.setXY([maxX - width, y], isInstant ? false : true);
35105 // y = y + height + this.alternativePadWidth;
35107 // maxHeight = maxHeight + height + this.alternativePadWidth;
35111 // this.el.setHeight(maxHeight);
35115 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
35117 var pos = this.el.getBox(true);
35122 var maxX = pos.right;
35124 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
35126 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
35128 Roo.each(queue, function(box, k){
35130 Roo.each(box, function(b, kk){
35132 b.el.position('absolute');
35134 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
35135 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
35137 if(b.size == 'md-left' || b.size == 'md-right'){
35138 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
35139 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
35142 b.el.setWidth(width);
35143 b.el.setHeight(height);
35151 var positions = [];
35153 switch (box.length){
35155 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
35158 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
35161 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
35164 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
35170 Roo.each(box, function(b,kk){
35172 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
35174 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
35182 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
35184 Roo.each(eItems, function(b,k){
35186 b.size = (k == 0) ? 'sm' : 'xs';
35187 b.x = (k == 0) ? 2 : 1;
35188 b.y = (k == 0) ? 2 : 1;
35190 b.el.position('absolute');
35192 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
35194 b.el.setWidth(width);
35196 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
35198 b.el.setHeight(height);
35202 var positions = [];
35205 x : maxX - this.unitWidth * 2 - this.gutter,
35210 x : maxX - this.unitWidth,
35211 y : minY + (this.unitWidth + this.gutter) * 2
35215 x : maxX - this.unitWidth * 3 - this.gutter * 2,
35219 Roo.each(eItems, function(b,k){
35221 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
35227 getVerticalOneBoxColPositions : function(x, y, box)
35231 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
35233 if(box[0].size == 'md-left'){
35237 if(box[0].size == 'md-right'){
35242 x : x + (this.unitWidth + this.gutter) * rand,
35249 getVerticalTwoBoxColPositions : function(x, y, box)
35253 if(box[0].size == 'xs'){
35257 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
35261 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
35275 x : x + (this.unitWidth + this.gutter) * 2,
35276 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
35283 getVerticalThreeBoxColPositions : function(x, y, box)
35287 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
35295 x : x + (this.unitWidth + this.gutter) * 1,
35300 x : x + (this.unitWidth + this.gutter) * 2,
35308 if(box[0].size == 'xs' && box[1].size == 'xs'){
35317 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
35321 x : x + (this.unitWidth + this.gutter) * 1,
35335 x : x + (this.unitWidth + this.gutter) * 2,
35340 x : x + (this.unitWidth + this.gutter) * 2,
35341 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
35348 getVerticalFourBoxColPositions : function(x, y, box)
35352 if(box[0].size == 'xs'){
35361 y : y + (this.unitHeight + this.gutter) * 1
35366 y : y + (this.unitHeight + this.gutter) * 2
35370 x : x + (this.unitWidth + this.gutter) * 1,
35384 x : x + (this.unitWidth + this.gutter) * 2,
35389 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
35390 y : y + (this.unitHeight + this.gutter) * 1
35394 x : x + (this.unitWidth + this.gutter) * 2,
35395 y : y + (this.unitWidth + this.gutter) * 2
35402 getHorizontalOneBoxColPositions : function(maxX, minY, box)
35406 if(box[0].size == 'md-left'){
35408 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
35415 if(box[0].size == 'md-right'){
35417 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
35418 y : minY + (this.unitWidth + this.gutter) * 1
35424 var rand = Math.floor(Math.random() * (4 - box[0].y));
35427 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35428 y : minY + (this.unitWidth + this.gutter) * rand
35435 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
35439 if(box[0].size == 'xs'){
35442 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35447 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35448 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
35456 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35461 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35462 y : minY + (this.unitWidth + this.gutter) * 2
35469 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
35473 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
35476 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35481 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35482 y : minY + (this.unitWidth + this.gutter) * 1
35486 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
35487 y : minY + (this.unitWidth + this.gutter) * 2
35494 if(box[0].size == 'xs' && box[1].size == 'xs'){
35497 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35502 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35507 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
35508 y : minY + (this.unitWidth + this.gutter) * 1
35516 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35521 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35522 y : minY + (this.unitWidth + this.gutter) * 2
35526 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
35527 y : minY + (this.unitWidth + this.gutter) * 2
35534 getHorizontalFourBoxColPositions : function(maxX, minY, box)
35538 if(box[0].size == 'xs'){
35541 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35546 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35551 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
35556 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
35557 y : minY + (this.unitWidth + this.gutter) * 1
35565 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
35570 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
35571 y : minY + (this.unitWidth + this.gutter) * 2
35575 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
35576 y : minY + (this.unitWidth + this.gutter) * 2
35580 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1) - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
35581 y : minY + (this.unitWidth + this.gutter) * 2
35589 * remove a Masonry Brick
35590 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
35592 removeBrick : function(brick_id)
35598 for (var i = 0; i<this.bricks.length; i++) {
35599 if (this.bricks[i].id == brick_id) {
35600 this.bricks.splice(i,1);
35601 this.el.dom.removeChild(Roo.get(brick_id).dom);
35608 * adds a Masonry Brick
35609 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
35611 addBrick : function(cfg)
35613 var cn = new Roo.bootstrap.MasonryBrick(cfg);
35614 //this.register(cn);
35615 cn.parentId = this.id;
35616 cn.render(this.el);
35621 * register a Masonry Brick
35622 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
35625 register : function(brick)
35627 this.bricks.push(brick);
35628 brick.masonryId = this.id;
35632 * clear all the Masonry Brick
35634 clearAll : function()
35637 //this.getChildContainer().dom.innerHTML = "";
35638 this.el.dom.innerHTML = '';
35641 getSelected : function()
35643 if (!this.selectedBrick) {
35647 return this.selectedBrick;
35651 Roo.apply(Roo.bootstrap.LayoutMasonry, {
35655 * register a Masonry Layout
35656 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
35659 register : function(layout)
35661 this.groups[layout.id] = layout;
35664 * fetch a Masonry Layout based on the masonry layout ID
35665 * @param {string} the masonry layout to add
35666 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
35669 get: function(layout_id) {
35670 if (typeof(this.groups[layout_id]) == 'undefined') {
35673 return this.groups[layout_id] ;
35685 * http://masonry.desandro.com
35687 * The idea is to render all the bricks based on vertical width...
35689 * The original code extends 'outlayer' - we might need to use that....
35695 * @class Roo.bootstrap.LayoutMasonryAuto
35696 * @extends Roo.bootstrap.Component
35697 * Bootstrap Layout Masonry class
35700 * Create a new Element
35701 * @param {Object} config The config object
35704 Roo.bootstrap.LayoutMasonryAuto = function(config){
35705 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
35708 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
35711 * @cfg {Boolean} isFitWidth - resize the width..
35713 isFitWidth : false, // options..
35715 * @cfg {Boolean} isOriginLeft = left align?
35717 isOriginLeft : true,
35719 * @cfg {Boolean} isOriginTop = top align?
35721 isOriginTop : false,
35723 * @cfg {Boolean} isLayoutInstant = no animation?
35725 isLayoutInstant : false, // needed?
35727 * @cfg {Boolean} isResizingContainer = not sure if this is used..
35729 isResizingContainer : true,
35731 * @cfg {Number} columnWidth width of the columns
35737 * @cfg {Number} maxCols maximum number of columns
35742 * @cfg {Number} padHeight padding below box..
35748 * @cfg {Boolean} isAutoInitial defalut true
35751 isAutoInitial : true,
35757 initialColumnWidth : 0,
35758 currentSize : null,
35760 colYs : null, // array.
35767 bricks: null, //CompositeElement
35768 cols : 0, // array?
35769 // element : null, // wrapped now this.el
35770 _isLayoutInited : null,
35773 getAutoCreate : function(){
35777 cls: 'blog-masonary-wrapper ' + this.cls,
35779 cls : 'mas-boxes masonary'
35786 getChildContainer: function( )
35788 if (this.boxesEl) {
35789 return this.boxesEl;
35792 this.boxesEl = this.el.select('.mas-boxes').first();
35794 return this.boxesEl;
35798 initEvents : function()
35802 if(this.isAutoInitial){
35803 Roo.log('hook children rendered');
35804 this.on('childrenrendered', function() {
35805 Roo.log('children rendered');
35812 initial : function()
35814 this.reloadItems();
35816 this.currentSize = this.el.getBox(true);
35818 /// was window resize... - let's see if this works..
35819 Roo.EventManager.onWindowResize(this.resize, this);
35821 if(!this.isAutoInitial){
35826 this.layout.defer(500,this);
35829 reloadItems: function()
35831 this.bricks = this.el.select('.masonry-brick', true);
35833 this.bricks.each(function(b) {
35834 //Roo.log(b.getSize());
35835 if (!b.attr('originalwidth')) {
35836 b.attr('originalwidth', b.getSize().width);
35841 Roo.log(this.bricks.elements.length);
35844 resize : function()
35847 var cs = this.el.getBox(true);
35849 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
35850 Roo.log("no change in with or X");
35853 this.currentSize = cs;
35857 layout : function()
35860 this._resetLayout();
35861 //this._manageStamps();
35863 // don't animate first layout
35864 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
35865 this.layoutItems( isInstant );
35867 // flag for initalized
35868 this._isLayoutInited = true;
35871 layoutItems : function( isInstant )
35873 //var items = this._getItemsForLayout( this.items );
35874 // original code supports filtering layout items.. we just ignore it..
35876 this._layoutItems( this.bricks , isInstant );
35878 this._postLayout();
35880 _layoutItems : function ( items , isInstant)
35882 //this.fireEvent( 'layout', this, items );
35885 if ( !items || !items.elements.length ) {
35886 // no items, emit event with empty array
35891 items.each(function(item) {
35892 Roo.log("layout item");
35894 // get x/y object from method
35895 var position = this._getItemLayoutPosition( item );
35897 position.item = item;
35898 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
35899 queue.push( position );
35902 this._processLayoutQueue( queue );
35904 /** Sets position of item in DOM
35905 * @param {Element} item
35906 * @param {Number} x - horizontal position
35907 * @param {Number} y - vertical position
35908 * @param {Boolean} isInstant - disables transitions
35910 _processLayoutQueue : function( queue )
35912 for ( var i=0, len = queue.length; i < len; i++ ) {
35913 var obj = queue[i];
35914 obj.item.position('absolute');
35915 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
35921 * Any logic you want to do after each layout,
35922 * i.e. size the container
35924 _postLayout : function()
35926 this.resizeContainer();
35929 resizeContainer : function()
35931 if ( !this.isResizingContainer ) {
35934 var size = this._getContainerSize();
35936 this.el.setSize(size.width,size.height);
35937 this.boxesEl.setSize(size.width,size.height);
35943 _resetLayout : function()
35945 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
35946 this.colWidth = this.el.getWidth();
35947 //this.gutter = this.el.getWidth();
35949 this.measureColumns();
35955 this.colYs.push( 0 );
35961 measureColumns : function()
35963 this.getContainerWidth();
35964 // if columnWidth is 0, default to outerWidth of first item
35965 if ( !this.columnWidth ) {
35966 var firstItem = this.bricks.first();
35967 Roo.log(firstItem);
35968 this.columnWidth = this.containerWidth;
35969 if (firstItem && firstItem.attr('originalwidth') ) {
35970 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
35972 // columnWidth fall back to item of first element
35973 Roo.log("set column width?");
35974 this.initialColumnWidth = this.columnWidth ;
35976 // if first elem has no width, default to size of container
35981 if (this.initialColumnWidth) {
35982 this.columnWidth = this.initialColumnWidth;
35987 // column width is fixed at the top - however if container width get's smaller we should
35990 // this bit calcs how man columns..
35992 var columnWidth = this.columnWidth += this.gutter;
35994 // calculate columns
35995 var containerWidth = this.containerWidth + this.gutter;
35997 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
35998 // fix rounding errors, typically with gutters
35999 var excess = columnWidth - containerWidth % columnWidth;
36002 // if overshoot is less than a pixel, round up, otherwise floor it
36003 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
36004 cols = Math[ mathMethod ]( cols );
36005 this.cols = Math.max( cols, 1 );
36006 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
36008 // padding positioning..
36009 var totalColWidth = this.cols * this.columnWidth;
36010 var padavail = this.containerWidth - totalColWidth;
36011 // so for 2 columns - we need 3 'pads'
36013 var padNeeded = (1+this.cols) * this.padWidth;
36015 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
36017 this.columnWidth += padExtra
36018 //this.padWidth = Math.floor(padavail / ( this.cols));
36020 // adjust colum width so that padding is fixed??
36022 // we have 3 columns ... total = width * 3
36023 // we have X left over... that should be used by
36025 //if (this.expandC) {
36033 getContainerWidth : function()
36035 /* // container is parent if fit width
36036 var container = this.isFitWidth ? this.element.parentNode : this.element;
36037 // check that this.size and size are there
36038 // IE8 triggers resize on body size change, so they might not be
36040 var size = getSize( container ); //FIXME
36041 this.containerWidth = size && size.innerWidth; //FIXME
36044 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
36048 _getItemLayoutPosition : function( item ) // what is item?
36050 // we resize the item to our columnWidth..
36052 item.setWidth(this.columnWidth);
36053 item.autoBoxAdjust = false;
36055 var sz = item.getSize();
36057 // how many columns does this brick span
36058 var remainder = this.containerWidth % this.columnWidth;
36060 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
36061 // round if off by 1 pixel, otherwise use ceil
36062 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
36063 colSpan = Math.min( colSpan, this.cols );
36065 // normally this should be '1' as we dont' currently allow multi width columns..
36067 var colGroup = this._getColGroup( colSpan );
36068 // get the minimum Y value from the columns
36069 var minimumY = Math.min.apply( Math, colGroup );
36070 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
36072 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
36074 // position the brick
36076 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
36077 y: this.currentSize.y + minimumY + this.padHeight
36081 // apply setHeight to necessary columns
36082 var setHeight = minimumY + sz.height + this.padHeight;
36083 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
36085 var setSpan = this.cols + 1 - colGroup.length;
36086 for ( var i = 0; i < setSpan; i++ ) {
36087 this.colYs[ shortColIndex + i ] = setHeight ;
36094 * @param {Number} colSpan - number of columns the element spans
36095 * @returns {Array} colGroup
36097 _getColGroup : function( colSpan )
36099 if ( colSpan < 2 ) {
36100 // if brick spans only one column, use all the column Ys
36105 // how many different places could this brick fit horizontally
36106 var groupCount = this.cols + 1 - colSpan;
36107 // for each group potential horizontal position
36108 for ( var i = 0; i < groupCount; i++ ) {
36109 // make an array of colY values for that one group
36110 var groupColYs = this.colYs.slice( i, i + colSpan );
36111 // and get the max value of the array
36112 colGroup[i] = Math.max.apply( Math, groupColYs );
36117 _manageStamp : function( stamp )
36119 var stampSize = stamp.getSize();
36120 var offset = stamp.getBox();
36121 // get the columns that this stamp affects
36122 var firstX = this.isOriginLeft ? offset.x : offset.right;
36123 var lastX = firstX + stampSize.width;
36124 var firstCol = Math.floor( firstX / this.columnWidth );
36125 firstCol = Math.max( 0, firstCol );
36127 var lastCol = Math.floor( lastX / this.columnWidth );
36128 // lastCol should not go over if multiple of columnWidth #425
36129 lastCol -= lastX % this.columnWidth ? 0 : 1;
36130 lastCol = Math.min( this.cols - 1, lastCol );
36132 // set colYs to bottom of the stamp
36133 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
36136 for ( var i = firstCol; i <= lastCol; i++ ) {
36137 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
36142 _getContainerSize : function()
36144 this.maxY = Math.max.apply( Math, this.colYs );
36149 if ( this.isFitWidth ) {
36150 size.width = this._getContainerFitWidth();
36156 _getContainerFitWidth : function()
36158 var unusedCols = 0;
36159 // count unused columns
36162 if ( this.colYs[i] !== 0 ) {
36167 // fit container to columns that have been used
36168 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
36171 needsResizeLayout : function()
36173 var previousWidth = this.containerWidth;
36174 this.getContainerWidth();
36175 return previousWidth !== this.containerWidth;
36190 * @class Roo.bootstrap.MasonryBrick
36191 * @extends Roo.bootstrap.Component
36192 * Bootstrap MasonryBrick class
36195 * Create a new MasonryBrick
36196 * @param {Object} config The config object
36199 Roo.bootstrap.MasonryBrick = function(config){
36201 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
36203 Roo.bootstrap.MasonryBrick.register(this);
36209 * When a MasonryBrick is clcik
36210 * @param {Roo.bootstrap.MasonryBrick} this
36211 * @param {Roo.EventObject} e
36217 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
36220 * @cfg {String} title
36224 * @cfg {String} html
36228 * @cfg {String} bgimage
36232 * @cfg {String} videourl
36236 * @cfg {String} cls
36240 * @cfg {String} href
36244 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
36249 * @cfg {String} placetitle (center|bottom)
36254 * @cfg {Boolean} isFitContainer defalut true
36256 isFitContainer : true,
36259 * @cfg {Boolean} preventDefault defalut false
36261 preventDefault : false,
36264 * @cfg {Boolean} inverse defalut false
36266 maskInverse : false,
36268 getAutoCreate : function()
36270 if(!this.isFitContainer){
36271 return this.getSplitAutoCreate();
36274 var cls = 'masonry-brick masonry-brick-full';
36276 if(this.href.length){
36277 cls += ' masonry-brick-link';
36280 if(this.bgimage.length){
36281 cls += ' masonry-brick-image';
36284 if(this.maskInverse){
36285 cls += ' mask-inverse';
36288 if(!this.html.length && !this.maskInverse && !this.videourl.length){
36289 cls += ' enable-mask';
36293 cls += ' masonry-' + this.size + '-brick';
36296 if(this.placetitle.length){
36298 switch (this.placetitle) {
36300 cls += ' masonry-center-title';
36303 cls += ' masonry-bottom-title';
36310 if(!this.html.length && !this.bgimage.length){
36311 cls += ' masonry-center-title';
36314 if(!this.html.length && this.bgimage.length){
36315 cls += ' masonry-bottom-title';
36320 cls += ' ' + this.cls;
36324 tag: (this.href.length) ? 'a' : 'div',
36329 cls: 'masonry-brick-mask'
36333 cls: 'masonry-brick-paragraph',
36339 if(this.href.length){
36340 cfg.href = this.href;
36343 var cn = cfg.cn[1].cn;
36345 if(this.title.length){
36348 cls: 'masonry-brick-title',
36353 if(this.html.length){
36356 cls: 'masonry-brick-text',
36361 if (!this.title.length && !this.html.length) {
36362 cfg.cn[1].cls += ' hide';
36365 if(this.bgimage.length){
36368 cls: 'masonry-brick-image-view',
36373 if(this.videourl.length){
36374 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
36375 // youtube support only?
36378 cls: 'masonry-brick-image-view',
36381 allowfullscreen : true
36389 getSplitAutoCreate : function()
36391 var cls = 'masonry-brick masonry-brick-split';
36393 if(this.href.length){
36394 cls += ' masonry-brick-link';
36397 if(this.bgimage.length){
36398 cls += ' masonry-brick-image';
36402 cls += ' masonry-' + this.size + '-brick';
36405 switch (this.placetitle) {
36407 cls += ' masonry-center-title';
36410 cls += ' masonry-bottom-title';
36413 if(!this.bgimage.length){
36414 cls += ' masonry-center-title';
36417 if(this.bgimage.length){
36418 cls += ' masonry-bottom-title';
36424 cls += ' ' + this.cls;
36428 tag: (this.href.length) ? 'a' : 'div',
36433 cls: 'masonry-brick-split-head',
36437 cls: 'masonry-brick-paragraph',
36444 cls: 'masonry-brick-split-body',
36450 if(this.href.length){
36451 cfg.href = this.href;
36454 if(this.title.length){
36455 cfg.cn[0].cn[0].cn.push({
36457 cls: 'masonry-brick-title',
36462 if(this.html.length){
36463 cfg.cn[1].cn.push({
36465 cls: 'masonry-brick-text',
36470 if(this.bgimage.length){
36471 cfg.cn[0].cn.push({
36473 cls: 'masonry-brick-image-view',
36478 if(this.videourl.length){
36479 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
36480 // youtube support only?
36481 cfg.cn[0].cn.cn.push({
36483 cls: 'masonry-brick-image-view',
36486 allowfullscreen : true
36493 initEvents: function()
36495 switch (this.size) {
36528 this.el.on('touchstart', this.onTouchStart, this);
36529 this.el.on('touchmove', this.onTouchMove, this);
36530 this.el.on('touchend', this.onTouchEnd, this);
36531 this.el.on('contextmenu', this.onContextMenu, this);
36533 this.el.on('mouseenter' ,this.enter, this);
36534 this.el.on('mouseleave', this.leave, this);
36535 this.el.on('click', this.onClick, this);
36538 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
36539 this.parent().bricks.push(this);
36544 onClick: function(e, el)
36546 var time = this.endTimer - this.startTimer;
36547 // Roo.log(e.preventDefault());
36550 e.preventDefault();
36555 if(!this.preventDefault){
36559 e.preventDefault();
36561 if (this.activeClass != '') {
36562 this.selectBrick();
36565 this.fireEvent('click', this, e);
36568 enter: function(e, el)
36570 e.preventDefault();
36572 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
36576 if(this.bgimage.length && this.html.length){
36577 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
36581 leave: function(e, el)
36583 e.preventDefault();
36585 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
36589 if(this.bgimage.length && this.html.length){
36590 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
36594 onTouchStart: function(e, el)
36596 // e.preventDefault();
36598 this.touchmoved = false;
36600 if(!this.isFitContainer){
36604 if(!this.bgimage.length || !this.html.length){
36608 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
36610 this.timer = new Date().getTime();
36614 onTouchMove: function(e, el)
36616 this.touchmoved = true;
36619 onContextMenu : function(e,el)
36621 e.preventDefault();
36622 e.stopPropagation();
36626 onTouchEnd: function(e, el)
36628 // e.preventDefault();
36630 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
36637 if(!this.bgimage.length || !this.html.length){
36639 if(this.href.length){
36640 window.location.href = this.href;
36646 if(!this.isFitContainer){
36650 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
36652 window.location.href = this.href;
36655 //selection on single brick only
36656 selectBrick : function() {
36658 if (!this.parentId) {
36662 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
36663 var index = m.selectedBrick.indexOf(this.id);
36666 m.selectedBrick.splice(index,1);
36667 this.el.removeClass(this.activeClass);
36671 for(var i = 0; i < m.selectedBrick.length; i++) {
36672 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
36673 b.el.removeClass(b.activeClass);
36676 m.selectedBrick = [];
36678 m.selectedBrick.push(this.id);
36679 this.el.addClass(this.activeClass);
36683 isSelected : function(){
36684 return this.el.hasClass(this.activeClass);
36689 Roo.apply(Roo.bootstrap.MasonryBrick, {
36692 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
36694 * register a Masonry Brick
36695 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
36698 register : function(brick)
36700 //this.groups[brick.id] = brick;
36701 this.groups.add(brick.id, brick);
36704 * fetch a masonry brick based on the masonry brick ID
36705 * @param {string} the masonry brick to add
36706 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
36709 get: function(brick_id)
36711 // if (typeof(this.groups[brick_id]) == 'undefined') {
36714 // return this.groups[brick_id] ;
36716 if(this.groups.key(brick_id)) {
36717 return this.groups.key(brick_id);
36735 * @class Roo.bootstrap.Brick
36736 * @extends Roo.bootstrap.Component
36737 * Bootstrap Brick class
36740 * Create a new Brick
36741 * @param {Object} config The config object
36744 Roo.bootstrap.Brick = function(config){
36745 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
36751 * When a Brick is click
36752 * @param {Roo.bootstrap.Brick} this
36753 * @param {Roo.EventObject} e
36759 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
36762 * @cfg {String} title
36766 * @cfg {String} html
36770 * @cfg {String} bgimage
36774 * @cfg {String} cls
36778 * @cfg {String} href
36782 * @cfg {String} video
36786 * @cfg {Boolean} square
36790 getAutoCreate : function()
36792 var cls = 'roo-brick';
36794 if(this.href.length){
36795 cls += ' roo-brick-link';
36798 if(this.bgimage.length){
36799 cls += ' roo-brick-image';
36802 if(!this.html.length && !this.bgimage.length){
36803 cls += ' roo-brick-center-title';
36806 if(!this.html.length && this.bgimage.length){
36807 cls += ' roo-brick-bottom-title';
36811 cls += ' ' + this.cls;
36815 tag: (this.href.length) ? 'a' : 'div',
36820 cls: 'roo-brick-paragraph',
36826 if(this.href.length){
36827 cfg.href = this.href;
36830 var cn = cfg.cn[0].cn;
36832 if(this.title.length){
36835 cls: 'roo-brick-title',
36840 if(this.html.length){
36843 cls: 'roo-brick-text',
36850 if(this.bgimage.length){
36853 cls: 'roo-brick-image-view',
36861 initEvents: function()
36863 if(this.title.length || this.html.length){
36864 this.el.on('mouseenter' ,this.enter, this);
36865 this.el.on('mouseleave', this.leave, this);
36868 Roo.EventManager.onWindowResize(this.resize, this);
36870 if(this.bgimage.length){
36871 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
36872 this.imageEl.on('load', this.onImageLoad, this);
36879 onImageLoad : function()
36884 resize : function()
36886 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
36888 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
36890 if(this.bgimage.length){
36891 var image = this.el.select('.roo-brick-image-view', true).first();
36893 image.setWidth(paragraph.getWidth());
36896 image.setHeight(paragraph.getWidth());
36899 this.el.setHeight(image.getHeight());
36900 paragraph.setHeight(image.getHeight());
36906 enter: function(e, el)
36908 e.preventDefault();
36910 if(this.bgimage.length){
36911 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
36912 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
36916 leave: function(e, el)
36918 e.preventDefault();
36920 if(this.bgimage.length){
36921 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
36922 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
36937 * @class Roo.bootstrap.NumberField
36938 * @extends Roo.bootstrap.Input
36939 * Bootstrap NumberField class
36945 * Create a new NumberField
36946 * @param {Object} config The config object
36949 Roo.bootstrap.NumberField = function(config){
36950 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
36953 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
36956 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
36958 allowDecimals : true,
36960 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
36962 decimalSeparator : ".",
36964 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
36966 decimalPrecision : 2,
36968 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
36970 allowNegative : true,
36973 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
36977 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
36979 minValue : Number.NEGATIVE_INFINITY,
36981 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
36983 maxValue : Number.MAX_VALUE,
36985 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
36987 minText : "The minimum value for this field is {0}",
36989 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
36991 maxText : "The maximum value for this field is {0}",
36993 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
36994 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
36996 nanText : "{0} is not a valid number",
36998 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
37000 thousandsDelimiter : false,
37002 * @cfg {String} valueAlign alignment of value
37004 valueAlign : "left",
37006 getAutoCreate : function()
37008 var hiddenInput = {
37012 cls: 'hidden-number-input'
37016 hiddenInput.name = this.name;
37021 var cfg = Roo.bootstrap.NumberField.superclass.getAutoCreate.call(this);
37023 this.name = hiddenInput.name;
37025 if(cfg.cn.length > 0) {
37026 cfg.cn.push(hiddenInput);
37033 initEvents : function()
37035 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
37037 var allowed = "0123456789";
37039 if(this.allowDecimals){
37040 allowed += this.decimalSeparator;
37043 if(this.allowNegative){
37047 if(this.thousandsDelimiter) {
37051 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
37053 var keyPress = function(e){
37055 var k = e.getKey();
37057 var c = e.getCharCode();
37060 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
37061 allowed.indexOf(String.fromCharCode(c)) === -1
37067 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
37071 if(allowed.indexOf(String.fromCharCode(c)) === -1){
37076 this.el.on("keypress", keyPress, this);
37079 validateValue : function(value)
37082 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
37086 var num = this.parseValue(value);
37089 this.markInvalid(String.format(this.nanText, value));
37093 if(num < this.minValue){
37094 this.markInvalid(String.format(this.minText, this.minValue));
37098 if(num > this.maxValue){
37099 this.markInvalid(String.format(this.maxText, this.maxValue));
37106 getValue : function()
37108 var v = this.hiddenEl().getValue();
37110 return this.fixPrecision(this.parseValue(v));
37113 parseValue : function(value)
37115 if(this.thousandsDelimiter) {
37117 r = new RegExp(",", "g");
37118 value = value.replace(r, "");
37121 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
37122 return isNaN(value) ? '' : value;
37125 fixPrecision : function(value)
37127 if(this.thousandsDelimiter) {
37129 r = new RegExp(",", "g");
37130 value = value.replace(r, "");
37133 var nan = isNaN(value);
37135 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
37136 return nan ? '' : value;
37138 return parseFloat(value).toFixed(this.decimalPrecision);
37141 setValue : function(v)
37143 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
37149 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
37151 this.inputEl().dom.value = (v == '') ? '' :
37152 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
37154 if(!this.allowZero && v === '0') {
37155 this.hiddenEl().dom.value = '';
37156 this.inputEl().dom.value = '';
37163 decimalPrecisionFcn : function(v)
37165 return Math.floor(v);
37168 beforeBlur : function()
37170 var v = this.parseValue(this.getRawValue());
37172 if(v || v === 0 || v === ''){
37177 hiddenEl : function()
37179 return this.el.select('input.hidden-number-input',true).first();
37191 * @class Roo.bootstrap.DocumentSlider
37192 * @extends Roo.bootstrap.Component
37193 * Bootstrap DocumentSlider class
37196 * Create a new DocumentViewer
37197 * @param {Object} config The config object
37200 Roo.bootstrap.DocumentSlider = function(config){
37201 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
37208 * Fire after initEvent
37209 * @param {Roo.bootstrap.DocumentSlider} this
37214 * Fire after update
37215 * @param {Roo.bootstrap.DocumentSlider} this
37221 * @param {Roo.bootstrap.DocumentSlider} this
37227 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
37233 getAutoCreate : function()
37237 cls : 'roo-document-slider',
37241 cls : 'roo-document-slider-header',
37245 cls : 'roo-document-slider-header-title'
37251 cls : 'roo-document-slider-body',
37255 cls : 'roo-document-slider-prev',
37259 cls : 'fa fa-chevron-left'
37265 cls : 'roo-document-slider-thumb',
37269 cls : 'roo-document-slider-image'
37275 cls : 'roo-document-slider-next',
37279 cls : 'fa fa-chevron-right'
37291 initEvents : function()
37293 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
37294 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
37296 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
37297 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
37299 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
37300 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
37302 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
37303 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
37305 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
37306 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
37308 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
37309 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
37311 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
37312 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
37314 this.thumbEl.on('click', this.onClick, this);
37316 this.prevIndicator.on('click', this.prev, this);
37318 this.nextIndicator.on('click', this.next, this);
37322 initial : function()
37324 if(this.files.length){
37325 this.indicator = 1;
37329 this.fireEvent('initial', this);
37332 update : function()
37334 this.imageEl.attr('src', this.files[this.indicator - 1]);
37336 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
37338 this.prevIndicator.show();
37340 if(this.indicator == 1){
37341 this.prevIndicator.hide();
37344 this.nextIndicator.show();
37346 if(this.indicator == this.files.length){
37347 this.nextIndicator.hide();
37350 this.thumbEl.scrollTo('top');
37352 this.fireEvent('update', this);
37355 onClick : function(e)
37357 e.preventDefault();
37359 this.fireEvent('click', this);
37364 e.preventDefault();
37366 this.indicator = Math.max(1, this.indicator - 1);
37373 e.preventDefault();
37375 this.indicator = Math.min(this.files.length, this.indicator + 1);
37389 * @class Roo.bootstrap.RadioSet
37390 * @extends Roo.bootstrap.Input
37391 * Bootstrap RadioSet class
37392 * @cfg {String} indicatorpos (left|right) default left
37393 * @cfg {Boolean} inline (true|false) inline the element (default true)
37394 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
37396 * Create a new RadioSet
37397 * @param {Object} config The config object
37400 Roo.bootstrap.RadioSet = function(config){
37402 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
37406 Roo.bootstrap.RadioSet.register(this);
37411 * Fires when the element is checked or unchecked.
37412 * @param {Roo.bootstrap.RadioSet} this This radio
37413 * @param {Roo.bootstrap.Radio} item The checked item
37418 * Fires when the element is click.
37419 * @param {Roo.bootstrap.RadioSet} this This radio set
37420 * @param {Roo.bootstrap.Radio} item The checked item
37421 * @param {Roo.EventObject} e The event object
37428 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
37436 indicatorpos : 'left',
37438 getAutoCreate : function()
37442 cls : 'roo-radio-set-label',
37446 html : this.fieldLabel
37450 if (Roo.bootstrap.version == 3) {
37453 if(this.indicatorpos == 'left'){
37456 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
37457 tooltip : 'This field is required'
37462 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
37463 tooltip : 'This field is required'
37469 cls : 'roo-radio-set-items'
37472 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
37474 if (align === 'left' && this.fieldLabel.length) {
37477 cls : "roo-radio-set-right",
37483 if(this.labelWidth > 12){
37484 label.style = "width: " + this.labelWidth + 'px';
37487 if(this.labelWidth < 13 && this.labelmd == 0){
37488 this.labelmd = this.labelWidth;
37491 if(this.labellg > 0){
37492 label.cls += ' col-lg-' + this.labellg;
37493 items.cls += ' col-lg-' + (12 - this.labellg);
37496 if(this.labelmd > 0){
37497 label.cls += ' col-md-' + this.labelmd;
37498 items.cls += ' col-md-' + (12 - this.labelmd);
37501 if(this.labelsm > 0){
37502 label.cls += ' col-sm-' + this.labelsm;
37503 items.cls += ' col-sm-' + (12 - this.labelsm);
37506 if(this.labelxs > 0){
37507 label.cls += ' col-xs-' + this.labelxs;
37508 items.cls += ' col-xs-' + (12 - this.labelxs);
37514 cls : 'roo-radio-set',
37518 cls : 'roo-radio-set-input',
37521 value : this.value ? this.value : ''
37528 if(this.weight.length){
37529 cfg.cls += ' roo-radio-' + this.weight;
37533 cfg.cls += ' roo-radio-set-inline';
37537 ['xs','sm','md','lg'].map(function(size){
37538 if (settings[size]) {
37539 cfg.cls += ' col-' + size + '-' + settings[size];
37547 initEvents : function()
37549 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
37550 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
37552 if(!this.fieldLabel.length){
37553 this.labelEl.hide();
37556 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
37557 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
37559 this.indicator = this.indicatorEl();
37561 if(this.indicator){
37562 this.indicator.addClass('invisible');
37565 this.originalValue = this.getValue();
37569 inputEl: function ()
37571 return this.el.select('.roo-radio-set-input', true).first();
37574 getChildContainer : function()
37576 return this.itemsEl;
37579 register : function(item)
37581 this.radioes.push(item);
37585 validate : function()
37587 if(this.getVisibilityEl().hasClass('hidden')){
37593 Roo.each(this.radioes, function(i){
37602 if(this.allowBlank) {
37606 if(this.disabled || valid){
37611 this.markInvalid();
37616 markValid : function()
37618 if(this.labelEl.isVisible(true) && this.indicatorEl()){
37619 this.indicatorEl().removeClass('visible');
37620 this.indicatorEl().addClass('invisible');
37624 if (Roo.bootstrap.version == 3) {
37625 this.el.removeClass([this.invalidClass, this.validClass]);
37626 this.el.addClass(this.validClass);
37628 this.el.removeClass(['is-invalid','is-valid']);
37629 this.el.addClass(['is-valid']);
37631 this.fireEvent('valid', this);
37634 markInvalid : function(msg)
37636 if(this.allowBlank || this.disabled){
37640 if(this.labelEl.isVisible(true) && this.indicatorEl()){
37641 this.indicatorEl().removeClass('invisible');
37642 this.indicatorEl().addClass('visible');
37644 if (Roo.bootstrap.version == 3) {
37645 this.el.removeClass([this.invalidClass, this.validClass]);
37646 this.el.addClass(this.invalidClass);
37648 this.el.removeClass(['is-invalid','is-valid']);
37649 this.el.addClass(['is-invalid']);
37652 this.fireEvent('invalid', this, msg);
37656 setValue : function(v, suppressEvent)
37658 if(this.value === v){
37665 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
37668 Roo.each(this.radioes, function(i){
37670 i.el.removeClass('checked');
37673 Roo.each(this.radioes, function(i){
37675 if(i.value === v || i.value.toString() === v.toString()){
37677 i.el.addClass('checked');
37679 if(suppressEvent !== true){
37680 this.fireEvent('check', this, i);
37691 clearInvalid : function(){
37693 if(!this.el || this.preventMark){
37697 this.el.removeClass([this.invalidClass]);
37699 this.fireEvent('valid', this);
37704 Roo.apply(Roo.bootstrap.RadioSet, {
37708 register : function(set)
37710 this.groups[set.name] = set;
37713 get: function(name)
37715 if (typeof(this.groups[name]) == 'undefined') {
37719 return this.groups[name] ;
37725 * Ext JS Library 1.1.1
37726 * Copyright(c) 2006-2007, Ext JS, LLC.
37728 * Originally Released Under LGPL - original licence link has changed is not relivant.
37731 * <script type="text/javascript">
37736 * @class Roo.bootstrap.SplitBar
37737 * @extends Roo.util.Observable
37738 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
37742 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
37743 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
37744 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
37745 split.minSize = 100;
37746 split.maxSize = 600;
37747 split.animate = true;
37748 split.on('moved', splitterMoved);
37751 * Create a new SplitBar
37752 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
37753 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
37754 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
37755 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
37756 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
37757 position of the SplitBar).
37759 Roo.bootstrap.SplitBar = function(cfg){
37764 // dragElement : elm
37765 // resizingElement: el,
37767 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
37768 // placement : Roo.bootstrap.SplitBar.LEFT ,
37769 // existingProxy ???
37772 this.el = Roo.get(cfg.dragElement, true);
37773 this.el.dom.unselectable = "on";
37775 this.resizingEl = Roo.get(cfg.resizingElement, true);
37779 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
37780 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
37783 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
37786 * The minimum size of the resizing element. (Defaults to 0)
37792 * The maximum size of the resizing element. (Defaults to 2000)
37795 this.maxSize = 2000;
37798 * Whether to animate the transition to the new size
37801 this.animate = false;
37804 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
37807 this.useShim = false;
37812 if(!cfg.existingProxy){
37814 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
37816 this.proxy = Roo.get(cfg.existingProxy).dom;
37819 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
37822 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
37825 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
37828 this.dragSpecs = {};
37831 * @private The adapter to use to positon and resize elements
37833 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
37834 this.adapter.init(this);
37836 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
37838 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
37839 this.el.addClass("roo-splitbar-h");
37842 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
37843 this.el.addClass("roo-splitbar-v");
37849 * Fires when the splitter is moved (alias for {@link #event-moved})
37850 * @param {Roo.bootstrap.SplitBar} this
37851 * @param {Number} newSize the new width or height
37856 * Fires when the splitter is moved
37857 * @param {Roo.bootstrap.SplitBar} this
37858 * @param {Number} newSize the new width or height
37862 * @event beforeresize
37863 * Fires before the splitter is dragged
37864 * @param {Roo.bootstrap.SplitBar} this
37866 "beforeresize" : true,
37868 "beforeapply" : true
37871 Roo.util.Observable.call(this);
37874 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
37875 onStartProxyDrag : function(x, y){
37876 this.fireEvent("beforeresize", this);
37878 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
37880 o.enableDisplayMode("block");
37881 // all splitbars share the same overlay
37882 Roo.bootstrap.SplitBar.prototype.overlay = o;
37884 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
37885 this.overlay.show();
37886 Roo.get(this.proxy).setDisplayed("block");
37887 var size = this.adapter.getElementSize(this);
37888 this.activeMinSize = this.getMinimumSize();;
37889 this.activeMaxSize = this.getMaximumSize();;
37890 var c1 = size - this.activeMinSize;
37891 var c2 = Math.max(this.activeMaxSize - size, 0);
37892 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
37893 this.dd.resetConstraints();
37894 this.dd.setXConstraint(
37895 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
37896 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
37898 this.dd.setYConstraint(0, 0);
37900 this.dd.resetConstraints();
37901 this.dd.setXConstraint(0, 0);
37902 this.dd.setYConstraint(
37903 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
37904 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
37907 this.dragSpecs.startSize = size;
37908 this.dragSpecs.startPoint = [x, y];
37909 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
37913 * @private Called after the drag operation by the DDProxy
37915 onEndProxyDrag : function(e){
37916 Roo.get(this.proxy).setDisplayed(false);
37917 var endPoint = Roo.lib.Event.getXY(e);
37919 this.overlay.hide();
37922 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
37923 newSize = this.dragSpecs.startSize +
37924 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
37925 endPoint[0] - this.dragSpecs.startPoint[0] :
37926 this.dragSpecs.startPoint[0] - endPoint[0]
37929 newSize = this.dragSpecs.startSize +
37930 (this.placement == Roo.bootstrap.SplitBar.TOP ?
37931 endPoint[1] - this.dragSpecs.startPoint[1] :
37932 this.dragSpecs.startPoint[1] - endPoint[1]
37935 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
37936 if(newSize != this.dragSpecs.startSize){
37937 if(this.fireEvent('beforeapply', this, newSize) !== false){
37938 this.adapter.setElementSize(this, newSize);
37939 this.fireEvent("moved", this, newSize);
37940 this.fireEvent("resize", this, newSize);
37946 * Get the adapter this SplitBar uses
37947 * @return The adapter object
37949 getAdapter : function(){
37950 return this.adapter;
37954 * Set the adapter this SplitBar uses
37955 * @param {Object} adapter A SplitBar adapter object
37957 setAdapter : function(adapter){
37958 this.adapter = adapter;
37959 this.adapter.init(this);
37963 * Gets the minimum size for the resizing element
37964 * @return {Number} The minimum size
37966 getMinimumSize : function(){
37967 return this.minSize;
37971 * Sets the minimum size for the resizing element
37972 * @param {Number} minSize The minimum size
37974 setMinimumSize : function(minSize){
37975 this.minSize = minSize;
37979 * Gets the maximum size for the resizing element
37980 * @return {Number} The maximum size
37982 getMaximumSize : function(){
37983 return this.maxSize;
37987 * Sets the maximum size for the resizing element
37988 * @param {Number} maxSize The maximum size
37990 setMaximumSize : function(maxSize){
37991 this.maxSize = maxSize;
37995 * Sets the initialize size for the resizing element
37996 * @param {Number} size The initial size
37998 setCurrentSize : function(size){
37999 var oldAnimate = this.animate;
38000 this.animate = false;
38001 this.adapter.setElementSize(this, size);
38002 this.animate = oldAnimate;
38006 * Destroy this splitbar.
38007 * @param {Boolean} removeEl True to remove the element
38009 destroy : function(removeEl){
38011 this.shim.remove();
38014 this.proxy.parentNode.removeChild(this.proxy);
38022 * @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.
38024 Roo.bootstrap.SplitBar.createProxy = function(dir){
38025 var proxy = new Roo.Element(document.createElement("div"));
38026 proxy.unselectable();
38027 var cls = 'roo-splitbar-proxy';
38028 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
38029 document.body.appendChild(proxy.dom);
38034 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
38035 * Default Adapter. It assumes the splitter and resizing element are not positioned
38036 * elements and only gets/sets the width of the element. Generally used for table based layouts.
38038 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
38041 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
38042 // do nothing for now
38043 init : function(s){
38047 * Called before drag operations to get the current size of the resizing element.
38048 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
38050 getElementSize : function(s){
38051 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
38052 return s.resizingEl.getWidth();
38054 return s.resizingEl.getHeight();
38059 * Called after drag operations to set the size of the resizing element.
38060 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
38061 * @param {Number} newSize The new size to set
38062 * @param {Function} onComplete A function to be invoked when resizing is complete
38064 setElementSize : function(s, newSize, onComplete){
38065 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
38067 s.resizingEl.setWidth(newSize);
38069 onComplete(s, newSize);
38072 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
38077 s.resizingEl.setHeight(newSize);
38079 onComplete(s, newSize);
38082 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
38089 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
38090 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
38091 * Adapter that moves the splitter element to align with the resized sizing element.
38092 * Used with an absolute positioned SplitBar.
38093 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
38094 * document.body, make sure you assign an id to the body element.
38096 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
38097 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
38098 this.container = Roo.get(container);
38101 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
38102 init : function(s){
38103 this.basic.init(s);
38106 getElementSize : function(s){
38107 return this.basic.getElementSize(s);
38110 setElementSize : function(s, newSize, onComplete){
38111 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
38114 moveSplitter : function(s){
38115 var yes = Roo.bootstrap.SplitBar;
38116 switch(s.placement){
38118 s.el.setX(s.resizingEl.getRight());
38121 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
38124 s.el.setY(s.resizingEl.getBottom());
38127 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
38134 * Orientation constant - Create a vertical SplitBar
38138 Roo.bootstrap.SplitBar.VERTICAL = 1;
38141 * Orientation constant - Create a horizontal SplitBar
38145 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
38148 * Placement constant - The resizing element is to the left of the splitter element
38152 Roo.bootstrap.SplitBar.LEFT = 1;
38155 * Placement constant - The resizing element is to the right of the splitter element
38159 Roo.bootstrap.SplitBar.RIGHT = 2;
38162 * Placement constant - The resizing element is positioned above the splitter element
38166 Roo.bootstrap.SplitBar.TOP = 3;
38169 * Placement constant - The resizing element is positioned under splitter element
38173 Roo.bootstrap.SplitBar.BOTTOM = 4;
38174 Roo.namespace("Roo.bootstrap.layout");/*
38176 * Ext JS Library 1.1.1
38177 * Copyright(c) 2006-2007, Ext JS, LLC.
38179 * Originally Released Under LGPL - original licence link has changed is not relivant.
38182 * <script type="text/javascript">
38186 * @class Roo.bootstrap.layout.Manager
38187 * @extends Roo.bootstrap.Component
38188 * Base class for layout managers.
38190 Roo.bootstrap.layout.Manager = function(config)
38192 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
38198 /** false to disable window resize monitoring @type Boolean */
38199 this.monitorWindowResize = true;
38204 * Fires when a layout is performed.
38205 * @param {Roo.LayoutManager} this
38209 * @event regionresized
38210 * Fires when the user resizes a region.
38211 * @param {Roo.LayoutRegion} region The resized region
38212 * @param {Number} newSize The new size (width for east/west, height for north/south)
38214 "regionresized" : true,
38216 * @event regioncollapsed
38217 * Fires when a region is collapsed.
38218 * @param {Roo.LayoutRegion} region The collapsed region
38220 "regioncollapsed" : true,
38222 * @event regionexpanded
38223 * Fires when a region is expanded.
38224 * @param {Roo.LayoutRegion} region The expanded region
38226 "regionexpanded" : true
38228 this.updating = false;
38231 this.el = Roo.get(config.el);
38237 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
38242 monitorWindowResize : true,
38248 onRender : function(ct, position)
38251 this.el = Roo.get(ct);
38254 //this.fireEvent('render',this);
38258 initEvents: function()
38262 // ie scrollbar fix
38263 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
38264 document.body.scroll = "no";
38265 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
38266 this.el.position('relative');
38268 this.id = this.el.id;
38269 this.el.addClass("roo-layout-container");
38270 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
38271 if(this.el.dom != document.body ) {
38272 this.el.on('resize', this.layout,this);
38273 this.el.on('show', this.layout,this);
38279 * Returns true if this layout is currently being updated
38280 * @return {Boolean}
38282 isUpdating : function(){
38283 return this.updating;
38287 * Suspend the LayoutManager from doing auto-layouts while
38288 * making multiple add or remove calls
38290 beginUpdate : function(){
38291 this.updating = true;
38295 * Restore auto-layouts and optionally disable the manager from performing a layout
38296 * @param {Boolean} noLayout true to disable a layout update
38298 endUpdate : function(noLayout){
38299 this.updating = false;
38305 layout: function(){
38309 onRegionResized : function(region, newSize){
38310 this.fireEvent("regionresized", region, newSize);
38314 onRegionCollapsed : function(region){
38315 this.fireEvent("regioncollapsed", region);
38318 onRegionExpanded : function(region){
38319 this.fireEvent("regionexpanded", region);
38323 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
38324 * performs box-model adjustments.
38325 * @return {Object} The size as an object {width: (the width), height: (the height)}
38327 getViewSize : function()
38330 if(this.el.dom != document.body){
38331 size = this.el.getSize();
38333 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
38335 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
38336 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
38341 * Returns the Element this layout is bound to.
38342 * @return {Roo.Element}
38344 getEl : function(){
38349 * Returns the specified region.
38350 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
38351 * @return {Roo.LayoutRegion}
38353 getRegion : function(target){
38354 return this.regions[target.toLowerCase()];
38357 onWindowResize : function(){
38358 if(this.monitorWindowResize){
38365 * Ext JS Library 1.1.1
38366 * Copyright(c) 2006-2007, Ext JS, LLC.
38368 * Originally Released Under LGPL - original licence link has changed is not relivant.
38371 * <script type="text/javascript">
38374 * @class Roo.bootstrap.layout.Border
38375 * @extends Roo.bootstrap.layout.Manager
38377 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
38378 * please see: examples/bootstrap/nested.html<br><br>
38380 <b>The container the layout is rendered into can be either the body element or any other element.
38381 If it is not the body element, the container needs to either be an absolute positioned element,
38382 or you will need to add "position:relative" to the css of the container. You will also need to specify
38383 the container size if it is not the body element.</b>
38386 * Create a new Border
38387 * @param {Object} config Configuration options
38389 Roo.bootstrap.layout.Border = function(config){
38390 config = config || {};
38391 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
38395 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
38396 if(config[region]){
38397 config[region].region = region;
38398 this.addRegion(config[region]);
38404 Roo.bootstrap.layout.Border.regions = ["center", "north","south","east","west"];
38406 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
38408 parent : false, // this might point to a 'nest' or a ???
38411 * Creates and adds a new region if it doesn't already exist.
38412 * @param {String} target The target region key (north, south, east, west or center).
38413 * @param {Object} config The regions config object
38414 * @return {BorderLayoutRegion} The new region
38416 addRegion : function(config)
38418 if(!this.regions[config.region]){
38419 var r = this.factory(config);
38420 this.bindRegion(r);
38422 return this.regions[config.region];
38426 bindRegion : function(r){
38427 this.regions[r.config.region] = r;
38429 r.on("visibilitychange", this.layout, this);
38430 r.on("paneladded", this.layout, this);
38431 r.on("panelremoved", this.layout, this);
38432 r.on("invalidated", this.layout, this);
38433 r.on("resized", this.onRegionResized, this);
38434 r.on("collapsed", this.onRegionCollapsed, this);
38435 r.on("expanded", this.onRegionExpanded, this);
38439 * Performs a layout update.
38441 layout : function()
38443 if(this.updating) {
38447 // render all the rebions if they have not been done alreayd?
38448 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
38449 if(this.regions[region] && !this.regions[region].bodyEl){
38450 this.regions[region].onRender(this.el)
38454 var size = this.getViewSize();
38455 var w = size.width;
38456 var h = size.height;
38461 //var x = 0, y = 0;
38463 var rs = this.regions;
38464 var north = rs["north"];
38465 var south = rs["south"];
38466 var west = rs["west"];
38467 var east = rs["east"];
38468 var center = rs["center"];
38469 //if(this.hideOnLayout){ // not supported anymore
38470 //c.el.setStyle("display", "none");
38472 if(north && north.isVisible()){
38473 var b = north.getBox();
38474 var m = north.getMargins();
38475 b.width = w - (m.left+m.right);
38478 centerY = b.height + b.y + m.bottom;
38479 centerH -= centerY;
38480 north.updateBox(this.safeBox(b));
38482 if(south && south.isVisible()){
38483 var b = south.getBox();
38484 var m = south.getMargins();
38485 b.width = w - (m.left+m.right);
38487 var totalHeight = (b.height + m.top + m.bottom);
38488 b.y = h - totalHeight + m.top;
38489 centerH -= totalHeight;
38490 south.updateBox(this.safeBox(b));
38492 if(west && west.isVisible()){
38493 var b = west.getBox();
38494 var m = west.getMargins();
38495 b.height = centerH - (m.top+m.bottom);
38497 b.y = centerY + m.top;
38498 var totalWidth = (b.width + m.left + m.right);
38499 centerX += totalWidth;
38500 centerW -= totalWidth;
38501 west.updateBox(this.safeBox(b));
38503 if(east && east.isVisible()){
38504 var b = east.getBox();
38505 var m = east.getMargins();
38506 b.height = centerH - (m.top+m.bottom);
38507 var totalWidth = (b.width + m.left + m.right);
38508 b.x = w - totalWidth + m.left;
38509 b.y = centerY + m.top;
38510 centerW -= totalWidth;
38511 east.updateBox(this.safeBox(b));
38514 var m = center.getMargins();
38516 x: centerX + m.left,
38517 y: centerY + m.top,
38518 width: centerW - (m.left+m.right),
38519 height: centerH - (m.top+m.bottom)
38521 //if(this.hideOnLayout){
38522 //center.el.setStyle("display", "block");
38524 center.updateBox(this.safeBox(centerBox));
38527 this.fireEvent("layout", this);
38531 safeBox : function(box){
38532 box.width = Math.max(0, box.width);
38533 box.height = Math.max(0, box.height);
38538 * Adds a ContentPanel (or subclass) to this layout.
38539 * @param {String} target The target region key (north, south, east, west or center).
38540 * @param {Roo.ContentPanel} panel The panel to add
38541 * @return {Roo.ContentPanel} The added panel
38543 add : function(target, panel){
38545 target = target.toLowerCase();
38546 return this.regions[target].add(panel);
38550 * Remove a ContentPanel (or subclass) to this layout.
38551 * @param {String} target The target region key (north, south, east, west or center).
38552 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
38553 * @return {Roo.ContentPanel} The removed panel
38555 remove : function(target, panel){
38556 target = target.toLowerCase();
38557 return this.regions[target].remove(panel);
38561 * Searches all regions for a panel with the specified id
38562 * @param {String} panelId
38563 * @return {Roo.ContentPanel} The panel or null if it wasn't found
38565 findPanel : function(panelId){
38566 var rs = this.regions;
38567 for(var target in rs){
38568 if(typeof rs[target] != "function"){
38569 var p = rs[target].getPanel(panelId);
38579 * Searches all regions for a panel with the specified id and activates (shows) it.
38580 * @param {String/ContentPanel} panelId The panels id or the panel itself
38581 * @return {Roo.ContentPanel} The shown panel or null
38583 showPanel : function(panelId) {
38584 var rs = this.regions;
38585 for(var target in rs){
38586 var r = rs[target];
38587 if(typeof r != "function"){
38588 if(r.hasPanel(panelId)){
38589 return r.showPanel(panelId);
38597 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
38598 * @param {Roo.state.Provider} provider (optional) An alternate state provider
38601 restoreState : function(provider){
38603 provider = Roo.state.Manager;
38605 var sm = new Roo.LayoutStateManager();
38606 sm.init(this, provider);
38612 * Adds a xtype elements to the layout.
38616 xtype : 'ContentPanel',
38623 xtype : 'NestedLayoutPanel',
38629 items : [ ... list of content panels or nested layout panels.. ]
38633 * @param {Object} cfg Xtype definition of item to add.
38635 addxtype : function(cfg)
38637 // basically accepts a pannel...
38638 // can accept a layout region..!?!?
38639 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
38642 // theory? children can only be panels??
38644 //if (!cfg.xtype.match(/Panel$/)) {
38649 if (typeof(cfg.region) == 'undefined') {
38650 Roo.log("Failed to add Panel, region was not set");
38654 var region = cfg.region;
38660 xitems = cfg.items;
38665 if ( region == 'center') {
38666 Roo.log("Center: " + cfg.title);
38672 case 'Content': // ContentPanel (el, cfg)
38673 case 'Scroll': // ContentPanel (el, cfg)
38675 cfg.autoCreate = cfg.autoCreate || true;
38676 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
38678 // var el = this.el.createChild();
38679 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
38682 this.add(region, ret);
38686 case 'TreePanel': // our new panel!
38687 cfg.el = this.el.createChild();
38688 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
38689 this.add(region, ret);
38694 // create a new Layout (which is a Border Layout...
38696 var clayout = cfg.layout;
38697 clayout.el = this.el.createChild();
38698 clayout.items = clayout.items || [];
38702 // replace this exitems with the clayout ones..
38703 xitems = clayout.items;
38705 // force background off if it's in center...
38706 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
38707 cfg.background = false;
38709 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
38712 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
38713 //console.log('adding nested layout panel ' + cfg.toSource());
38714 this.add(region, ret);
38715 nb = {}; /// find first...
38720 // needs grid and region
38722 //var el = this.getRegion(region).el.createChild();
38724 *var el = this.el.createChild();
38725 // create the grid first...
38726 cfg.grid.container = el;
38727 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
38730 if (region == 'center' && this.active ) {
38731 cfg.background = false;
38734 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
38736 this.add(region, ret);
38738 if (cfg.background) {
38739 // render grid on panel activation (if panel background)
38740 ret.on('activate', function(gp) {
38741 if (!gp.grid.rendered) {
38742 // gp.grid.render(el);
38746 // cfg.grid.render(el);
38752 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
38753 // it was the old xcomponent building that caused this before.
38754 // espeically if border is the top element in the tree.
38764 if (typeof(Roo[cfg.xtype]) != 'undefined') {
38766 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
38767 this.add(region, ret);
38771 throw "Can not add '" + cfg.xtype + "' to Border";
38777 this.beginUpdate();
38781 Roo.each(xitems, function(i) {
38782 region = nb && i.region ? i.region : false;
38784 var add = ret.addxtype(i);
38787 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
38788 if (!i.background) {
38789 abn[region] = nb[region] ;
38796 // make the last non-background panel active..
38797 //if (nb) { Roo.log(abn); }
38800 for(var r in abn) {
38801 region = this.getRegion(r);
38803 // tried using nb[r], but it does not work..
38805 region.showPanel(abn[r]);
38816 factory : function(cfg)
38819 var validRegions = Roo.bootstrap.layout.Border.regions;
38821 var target = cfg.region;
38824 var r = Roo.bootstrap.layout;
38828 return new r.North(cfg);
38830 return new r.South(cfg);
38832 return new r.East(cfg);
38834 return new r.West(cfg);
38836 return new r.Center(cfg);
38838 throw 'Layout region "'+target+'" not supported.';
38845 * Ext JS Library 1.1.1
38846 * Copyright(c) 2006-2007, Ext JS, LLC.
38848 * Originally Released Under LGPL - original licence link has changed is not relivant.
38851 * <script type="text/javascript">
38855 * @class Roo.bootstrap.layout.Basic
38856 * @extends Roo.util.Observable
38857 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
38858 * and does not have a titlebar, tabs or any other features. All it does is size and position
38859 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
38860 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
38861 * @cfg {string} region the region that it inhabits..
38862 * @cfg {bool} skipConfig skip config?
38866 Roo.bootstrap.layout.Basic = function(config){
38868 this.mgr = config.mgr;
38870 this.position = config.region;
38872 var skipConfig = config.skipConfig;
38876 * @scope Roo.BasicLayoutRegion
38880 * @event beforeremove
38881 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
38882 * @param {Roo.LayoutRegion} this
38883 * @param {Roo.ContentPanel} panel The panel
38884 * @param {Object} e The cancel event object
38886 "beforeremove" : true,
38888 * @event invalidated
38889 * Fires when the layout for this region is changed.
38890 * @param {Roo.LayoutRegion} this
38892 "invalidated" : true,
38894 * @event visibilitychange
38895 * Fires when this region is shown or hidden
38896 * @param {Roo.LayoutRegion} this
38897 * @param {Boolean} visibility true or false
38899 "visibilitychange" : true,
38901 * @event paneladded
38902 * Fires when a panel is added.
38903 * @param {Roo.LayoutRegion} this
38904 * @param {Roo.ContentPanel} panel The panel
38906 "paneladded" : true,
38908 * @event panelremoved
38909 * Fires when a panel is removed.
38910 * @param {Roo.LayoutRegion} this
38911 * @param {Roo.ContentPanel} panel The panel
38913 "panelremoved" : true,
38915 * @event beforecollapse
38916 * Fires when this region before collapse.
38917 * @param {Roo.LayoutRegion} this
38919 "beforecollapse" : true,
38922 * Fires when this region is collapsed.
38923 * @param {Roo.LayoutRegion} this
38925 "collapsed" : true,
38928 * Fires when this region is expanded.
38929 * @param {Roo.LayoutRegion} this
38934 * Fires when this region is slid into view.
38935 * @param {Roo.LayoutRegion} this
38937 "slideshow" : true,
38940 * Fires when this region slides out of view.
38941 * @param {Roo.LayoutRegion} this
38943 "slidehide" : true,
38945 * @event panelactivated
38946 * Fires when a panel is activated.
38947 * @param {Roo.LayoutRegion} this
38948 * @param {Roo.ContentPanel} panel The activated panel
38950 "panelactivated" : true,
38953 * Fires when the user resizes this region.
38954 * @param {Roo.LayoutRegion} this
38955 * @param {Number} newSize The new size (width for east/west, height for north/south)
38959 /** A collection of panels in this region. @type Roo.util.MixedCollection */
38960 this.panels = new Roo.util.MixedCollection();
38961 this.panels.getKey = this.getPanelId.createDelegate(this);
38963 this.activePanel = null;
38964 // ensure listeners are added...
38966 if (config.listeners || config.events) {
38967 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
38968 listeners : config.listeners || {},
38969 events : config.events || {}
38973 if(skipConfig !== true){
38974 this.applyConfig(config);
38978 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
38980 getPanelId : function(p){
38984 applyConfig : function(config){
38985 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
38986 this.config = config;
38991 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
38992 * the width, for horizontal (north, south) the height.
38993 * @param {Number} newSize The new width or height
38995 resizeTo : function(newSize){
38996 var el = this.el ? this.el :
38997 (this.activePanel ? this.activePanel.getEl() : null);
38999 switch(this.position){
39002 el.setWidth(newSize);
39003 this.fireEvent("resized", this, newSize);
39007 el.setHeight(newSize);
39008 this.fireEvent("resized", this, newSize);
39014 getBox : function(){
39015 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
39018 getMargins : function(){
39019 return this.margins;
39022 updateBox : function(box){
39024 var el = this.activePanel.getEl();
39025 el.dom.style.left = box.x + "px";
39026 el.dom.style.top = box.y + "px";
39027 this.activePanel.setSize(box.width, box.height);
39031 * Returns the container element for this region.
39032 * @return {Roo.Element}
39034 getEl : function(){
39035 return this.activePanel;
39039 * Returns true if this region is currently visible.
39040 * @return {Boolean}
39042 isVisible : function(){
39043 return this.activePanel ? true : false;
39046 setActivePanel : function(panel){
39047 panel = this.getPanel(panel);
39048 if(this.activePanel && this.activePanel != panel){
39049 this.activePanel.setActiveState(false);
39050 this.activePanel.getEl().setLeftTop(-10000,-10000);
39052 this.activePanel = panel;
39053 panel.setActiveState(true);
39055 panel.setSize(this.box.width, this.box.height);
39057 this.fireEvent("panelactivated", this, panel);
39058 this.fireEvent("invalidated");
39062 * Show the specified panel.
39063 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
39064 * @return {Roo.ContentPanel} The shown panel or null
39066 showPanel : function(panel){
39067 panel = this.getPanel(panel);
39069 this.setActivePanel(panel);
39075 * Get the active panel for this region.
39076 * @return {Roo.ContentPanel} The active panel or null
39078 getActivePanel : function(){
39079 return this.activePanel;
39083 * Add the passed ContentPanel(s)
39084 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
39085 * @return {Roo.ContentPanel} The panel added (if only one was added)
39087 add : function(panel){
39088 if(arguments.length > 1){
39089 for(var i = 0, len = arguments.length; i < len; i++) {
39090 this.add(arguments[i]);
39094 if(this.hasPanel(panel)){
39095 this.showPanel(panel);
39098 var el = panel.getEl();
39099 if(el.dom.parentNode != this.mgr.el.dom){
39100 this.mgr.el.dom.appendChild(el.dom);
39102 if(panel.setRegion){
39103 panel.setRegion(this);
39105 this.panels.add(panel);
39106 el.setStyle("position", "absolute");
39107 if(!panel.background){
39108 this.setActivePanel(panel);
39109 if(this.config.initialSize && this.panels.getCount()==1){
39110 this.resizeTo(this.config.initialSize);
39113 this.fireEvent("paneladded", this, panel);
39118 * Returns true if the panel is in this region.
39119 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
39120 * @return {Boolean}
39122 hasPanel : function(panel){
39123 if(typeof panel == "object"){ // must be panel obj
39124 panel = panel.getId();
39126 return this.getPanel(panel) ? true : false;
39130 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
39131 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
39132 * @param {Boolean} preservePanel Overrides the config preservePanel option
39133 * @return {Roo.ContentPanel} The panel that was removed
39135 remove : function(panel, preservePanel){
39136 panel = this.getPanel(panel);
39141 this.fireEvent("beforeremove", this, panel, e);
39142 if(e.cancel === true){
39145 var panelId = panel.getId();
39146 this.panels.removeKey(panelId);
39151 * Returns the panel specified or null if it's not in this region.
39152 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
39153 * @return {Roo.ContentPanel}
39155 getPanel : function(id){
39156 if(typeof id == "object"){ // must be panel obj
39159 return this.panels.get(id);
39163 * Returns this regions position (north/south/east/west/center).
39166 getPosition: function(){
39167 return this.position;
39171 * Ext JS Library 1.1.1
39172 * Copyright(c) 2006-2007, Ext JS, LLC.
39174 * Originally Released Under LGPL - original licence link has changed is not relivant.
39177 * <script type="text/javascript">
39181 * @class Roo.bootstrap.layout.Region
39182 * @extends Roo.bootstrap.layout.Basic
39183 * This class represents a region in a layout manager.
39185 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
39186 * @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})
39187 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
39188 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
39189 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
39190 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
39191 * @cfg {String} title The title for the region (overrides panel titles)
39192 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
39193 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
39194 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
39195 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
39196 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
39197 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
39198 * the space available, similar to FireFox 1.5 tabs (defaults to false)
39199 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
39200 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
39201 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
39203 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
39204 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
39205 * @cfg {Boolean} disableTabTips True to disable tab tooltips
39206 * @cfg {Number} width For East/West panels
39207 * @cfg {Number} height For North/South panels
39208 * @cfg {Boolean} split To show the splitter
39209 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
39211 * @cfg {string} cls Extra CSS classes to add to region
39213 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
39214 * @cfg {string} region the region that it inhabits..
39217 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
39218 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
39220 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
39221 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
39222 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
39224 Roo.bootstrap.layout.Region = function(config)
39226 this.applyConfig(config);
39228 var mgr = config.mgr;
39229 var pos = config.region;
39230 config.skipConfig = true;
39231 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
39234 this.onRender(mgr.el);
39237 this.visible = true;
39238 this.collapsed = false;
39239 this.unrendered_panels = [];
39242 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
39244 position: '', // set by wrapper (eg. north/south etc..)
39245 unrendered_panels : null, // unrendered panels.
39247 tabPosition : false,
39249 mgr: false, // points to 'Border'
39252 createBody : function(){
39253 /** This region's body element
39254 * @type Roo.Element */
39255 this.bodyEl = this.el.createChild({
39257 cls: "roo-layout-panel-body tab-content" // bootstrap added...
39261 onRender: function(ctr, pos)
39263 var dh = Roo.DomHelper;
39264 /** This region's container element
39265 * @type Roo.Element */
39266 this.el = dh.append(ctr.dom, {
39268 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
39270 /** This region's title element
39271 * @type Roo.Element */
39273 this.titleEl = dh.append(this.el.dom, {
39275 unselectable: "on",
39276 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
39278 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
39279 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
39283 this.titleEl.enableDisplayMode();
39284 /** This region's title text element
39285 * @type HTMLElement */
39286 this.titleTextEl = this.titleEl.dom.firstChild;
39287 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
39289 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
39290 this.closeBtn.enableDisplayMode();
39291 this.closeBtn.on("click", this.closeClicked, this);
39292 this.closeBtn.hide();
39294 this.createBody(this.config);
39295 if(this.config.hideWhenEmpty){
39297 this.on("paneladded", this.validateVisibility, this);
39298 this.on("panelremoved", this.validateVisibility, this);
39300 if(this.autoScroll){
39301 this.bodyEl.setStyle("overflow", "auto");
39303 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
39305 //if(c.titlebar !== false){
39306 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
39307 this.titleEl.hide();
39309 this.titleEl.show();
39310 if(this.config.title){
39311 this.titleTextEl.innerHTML = this.config.title;
39315 if(this.config.collapsed){
39316 this.collapse(true);
39318 if(this.config.hidden){
39322 if (this.unrendered_panels && this.unrendered_panels.length) {
39323 for (var i =0;i< this.unrendered_panels.length; i++) {
39324 this.add(this.unrendered_panels[i]);
39326 this.unrendered_panels = null;
39332 applyConfig : function(c)
39335 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
39336 var dh = Roo.DomHelper;
39337 if(c.titlebar !== false){
39338 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
39339 this.collapseBtn.on("click", this.collapse, this);
39340 this.collapseBtn.enableDisplayMode();
39342 if(c.showPin === true || this.showPin){
39343 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
39344 this.stickBtn.enableDisplayMode();
39345 this.stickBtn.on("click", this.expand, this);
39346 this.stickBtn.hide();
39351 /** This region's collapsed element
39352 * @type Roo.Element */
39355 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
39356 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
39359 if(c.floatable !== false){
39360 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
39361 this.collapsedEl.on("click", this.collapseClick, this);
39364 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
39365 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
39366 id: "message", unselectable: "on", style:{"float":"left"}});
39367 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
39369 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
39370 this.expandBtn.on("click", this.expand, this);
39374 if(this.collapseBtn){
39375 this.collapseBtn.setVisible(c.collapsible == true);
39378 this.cmargins = c.cmargins || this.cmargins ||
39379 (this.position == "west" || this.position == "east" ?
39380 {top: 0, left: 2, right:2, bottom: 0} :
39381 {top: 2, left: 0, right:0, bottom: 2});
39383 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
39386 this.tabPosition = [ 'top','bottom', 'west'].indexOf(c.tabPosition) > -1 ? c.tabPosition : "top";
39388 this.autoScroll = c.autoScroll || false;
39393 this.duration = c.duration || .30;
39394 this.slideDuration = c.slideDuration || .45;
39399 * Returns true if this region is currently visible.
39400 * @return {Boolean}
39402 isVisible : function(){
39403 return this.visible;
39407 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
39408 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
39410 //setCollapsedTitle : function(title){
39411 // title = title || " ";
39412 // if(this.collapsedTitleTextEl){
39413 // this.collapsedTitleTextEl.innerHTML = title;
39417 getBox : function(){
39419 // if(!this.collapsed){
39420 b = this.el.getBox(false, true);
39422 // b = this.collapsedEl.getBox(false, true);
39427 getMargins : function(){
39428 return this.margins;
39429 //return this.collapsed ? this.cmargins : this.margins;
39432 highlight : function(){
39433 this.el.addClass("x-layout-panel-dragover");
39436 unhighlight : function(){
39437 this.el.removeClass("x-layout-panel-dragover");
39440 updateBox : function(box)
39442 if (!this.bodyEl) {
39443 return; // not rendered yet..
39447 if(!this.collapsed){
39448 this.el.dom.style.left = box.x + "px";
39449 this.el.dom.style.top = box.y + "px";
39450 this.updateBody(box.width, box.height);
39452 this.collapsedEl.dom.style.left = box.x + "px";
39453 this.collapsedEl.dom.style.top = box.y + "px";
39454 this.collapsedEl.setSize(box.width, box.height);
39457 this.tabs.autoSizeTabs();
39461 updateBody : function(w, h)
39464 this.el.setWidth(w);
39465 w -= this.el.getBorderWidth("rl");
39466 if(this.config.adjustments){
39467 w += this.config.adjustments[0];
39470 if(h !== null && h > 0){
39471 this.el.setHeight(h);
39472 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
39473 h -= this.el.getBorderWidth("tb");
39474 if(this.config.adjustments){
39475 h += this.config.adjustments[1];
39477 this.bodyEl.setHeight(h);
39479 h = this.tabs.syncHeight(h);
39482 if(this.panelSize){
39483 w = w !== null ? w : this.panelSize.width;
39484 h = h !== null ? h : this.panelSize.height;
39486 if(this.activePanel){
39487 var el = this.activePanel.getEl();
39488 w = w !== null ? w : el.getWidth();
39489 h = h !== null ? h : el.getHeight();
39490 this.panelSize = {width: w, height: h};
39491 this.activePanel.setSize(w, h);
39493 if(Roo.isIE && this.tabs){
39494 this.tabs.el.repaint();
39499 * Returns the container element for this region.
39500 * @return {Roo.Element}
39502 getEl : function(){
39507 * Hides this region.
39510 //if(!this.collapsed){
39511 this.el.dom.style.left = "-2000px";
39514 // this.collapsedEl.dom.style.left = "-2000px";
39515 // this.collapsedEl.hide();
39517 this.visible = false;
39518 this.fireEvent("visibilitychange", this, false);
39522 * Shows this region if it was previously hidden.
39525 //if(!this.collapsed){
39528 // this.collapsedEl.show();
39530 this.visible = true;
39531 this.fireEvent("visibilitychange", this, true);
39534 closeClicked : function(){
39535 if(this.activePanel){
39536 this.remove(this.activePanel);
39540 collapseClick : function(e){
39542 e.stopPropagation();
39545 e.stopPropagation();
39551 * Collapses this region.
39552 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
39555 collapse : function(skipAnim, skipCheck = false){
39556 if(this.collapsed) {
39560 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
39562 this.collapsed = true;
39564 this.split.el.hide();
39566 if(this.config.animate && skipAnim !== true){
39567 this.fireEvent("invalidated", this);
39568 this.animateCollapse();
39570 this.el.setLocation(-20000,-20000);
39572 this.collapsedEl.show();
39573 this.fireEvent("collapsed", this);
39574 this.fireEvent("invalidated", this);
39580 animateCollapse : function(){
39585 * Expands this region if it was previously collapsed.
39586 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
39587 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
39590 expand : function(e, skipAnim){
39592 e.stopPropagation();
39594 if(!this.collapsed || this.el.hasActiveFx()) {
39598 this.afterSlideIn();
39601 this.collapsed = false;
39602 if(this.config.animate && skipAnim !== true){
39603 this.animateExpand();
39607 this.split.el.show();
39609 this.collapsedEl.setLocation(-2000,-2000);
39610 this.collapsedEl.hide();
39611 this.fireEvent("invalidated", this);
39612 this.fireEvent("expanded", this);
39616 animateExpand : function(){
39620 initTabs : function()
39622 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
39624 var ts = new Roo.bootstrap.panel.Tabs({
39625 el: this.bodyEl.dom,
39627 tabPosition: this.tabPosition ? this.tabPosition : 'top',
39628 disableTooltips: this.config.disableTabTips,
39629 toolbar : this.config.toolbar
39632 if(this.config.hideTabs){
39633 ts.stripWrap.setDisplayed(false);
39636 ts.resizeTabs = this.config.resizeTabs === true;
39637 ts.minTabWidth = this.config.minTabWidth || 40;
39638 ts.maxTabWidth = this.config.maxTabWidth || 250;
39639 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
39640 ts.monitorResize = false;
39641 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
39642 ts.bodyEl.addClass('roo-layout-tabs-body');
39643 this.panels.each(this.initPanelAsTab, this);
39646 initPanelAsTab : function(panel){
39647 var ti = this.tabs.addTab(
39651 this.config.closeOnTab && panel.isClosable(),
39654 if(panel.tabTip !== undefined){
39655 ti.setTooltip(panel.tabTip);
39657 ti.on("activate", function(){
39658 this.setActivePanel(panel);
39661 if(this.config.closeOnTab){
39662 ti.on("beforeclose", function(t, e){
39664 this.remove(panel);
39668 panel.tabItem = ti;
39673 updatePanelTitle : function(panel, title)
39675 if(this.activePanel == panel){
39676 this.updateTitle(title);
39679 var ti = this.tabs.getTab(panel.getEl().id);
39681 if(panel.tabTip !== undefined){
39682 ti.setTooltip(panel.tabTip);
39687 updateTitle : function(title){
39688 if(this.titleTextEl && !this.config.title){
39689 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
39693 setActivePanel : function(panel)
39695 panel = this.getPanel(panel);
39696 if(this.activePanel && this.activePanel != panel){
39697 if(this.activePanel.setActiveState(false) === false){
39701 this.activePanel = panel;
39702 panel.setActiveState(true);
39703 if(this.panelSize){
39704 panel.setSize(this.panelSize.width, this.panelSize.height);
39707 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
39709 this.updateTitle(panel.getTitle());
39711 this.fireEvent("invalidated", this);
39713 this.fireEvent("panelactivated", this, panel);
39717 * Shows the specified panel.
39718 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
39719 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
39721 showPanel : function(panel)
39723 panel = this.getPanel(panel);
39726 var tab = this.tabs.getTab(panel.getEl().id);
39727 if(tab.isHidden()){
39728 this.tabs.unhideTab(tab.id);
39732 this.setActivePanel(panel);
39739 * Get the active panel for this region.
39740 * @return {Roo.ContentPanel} The active panel or null
39742 getActivePanel : function(){
39743 return this.activePanel;
39746 validateVisibility : function(){
39747 if(this.panels.getCount() < 1){
39748 this.updateTitle(" ");
39749 this.closeBtn.hide();
39752 if(!this.isVisible()){
39759 * Adds the passed ContentPanel(s) to this region.
39760 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
39761 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
39763 add : function(panel)
39765 if(arguments.length > 1){
39766 for(var i = 0, len = arguments.length; i < len; i++) {
39767 this.add(arguments[i]);
39772 // if we have not been rendered yet, then we can not really do much of this..
39773 if (!this.bodyEl) {
39774 this.unrendered_panels.push(panel);
39781 if(this.hasPanel(panel)){
39782 this.showPanel(panel);
39785 panel.setRegion(this);
39786 this.panels.add(panel);
39787 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
39788 // sinle panel - no tab...?? would it not be better to render it with the tabs,
39789 // and hide them... ???
39790 this.bodyEl.dom.appendChild(panel.getEl().dom);
39791 if(panel.background !== true){
39792 this.setActivePanel(panel);
39794 this.fireEvent("paneladded", this, panel);
39801 this.initPanelAsTab(panel);
39805 if(panel.background !== true){
39806 this.tabs.activate(panel.getEl().id);
39808 this.fireEvent("paneladded", this, panel);
39813 * Hides the tab for the specified panel.
39814 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
39816 hidePanel : function(panel){
39817 if(this.tabs && (panel = this.getPanel(panel))){
39818 this.tabs.hideTab(panel.getEl().id);
39823 * Unhides the tab for a previously hidden panel.
39824 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
39826 unhidePanel : function(panel){
39827 if(this.tabs && (panel = this.getPanel(panel))){
39828 this.tabs.unhideTab(panel.getEl().id);
39832 clearPanels : function(){
39833 while(this.panels.getCount() > 0){
39834 this.remove(this.panels.first());
39839 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
39840 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
39841 * @param {Boolean} preservePanel Overrides the config preservePanel option
39842 * @return {Roo.ContentPanel} The panel that was removed
39844 remove : function(panel, preservePanel)
39846 panel = this.getPanel(panel);
39851 this.fireEvent("beforeremove", this, panel, e);
39852 if(e.cancel === true){
39855 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
39856 var panelId = panel.getId();
39857 this.panels.removeKey(panelId);
39859 document.body.appendChild(panel.getEl().dom);
39862 this.tabs.removeTab(panel.getEl().id);
39863 }else if (!preservePanel){
39864 this.bodyEl.dom.removeChild(panel.getEl().dom);
39866 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
39867 var p = this.panels.first();
39868 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
39869 tempEl.appendChild(p.getEl().dom);
39870 this.bodyEl.update("");
39871 this.bodyEl.dom.appendChild(p.getEl().dom);
39873 this.updateTitle(p.getTitle());
39875 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
39876 this.setActivePanel(p);
39878 panel.setRegion(null);
39879 if(this.activePanel == panel){
39880 this.activePanel = null;
39882 if(this.config.autoDestroy !== false && preservePanel !== true){
39883 try{panel.destroy();}catch(e){}
39885 this.fireEvent("panelremoved", this, panel);
39890 * Returns the TabPanel component used by this region
39891 * @return {Roo.TabPanel}
39893 getTabs : function(){
39897 createTool : function(parentEl, className){
39898 var btn = Roo.DomHelper.append(parentEl, {
39900 cls: "x-layout-tools-button",
39903 cls: "roo-layout-tools-button-inner " + className,
39907 btn.addClassOnOver("roo-layout-tools-button-over");
39912 * Ext JS Library 1.1.1
39913 * Copyright(c) 2006-2007, Ext JS, LLC.
39915 * Originally Released Under LGPL - original licence link has changed is not relivant.
39918 * <script type="text/javascript">
39924 * @class Roo.SplitLayoutRegion
39925 * @extends Roo.LayoutRegion
39926 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
39928 Roo.bootstrap.layout.Split = function(config){
39929 this.cursor = config.cursor;
39930 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
39933 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
39935 splitTip : "Drag to resize.",
39936 collapsibleSplitTip : "Drag to resize. Double click to hide.",
39937 useSplitTips : false,
39939 applyConfig : function(config){
39940 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
39943 onRender : function(ctr,pos) {
39945 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
39946 if(!this.config.split){
39951 var splitEl = Roo.DomHelper.append(ctr.dom, {
39953 id: this.el.id + "-split",
39954 cls: "roo-layout-split roo-layout-split-"+this.position,
39957 /** The SplitBar for this region
39958 * @type Roo.SplitBar */
39959 // does not exist yet...
39960 Roo.log([this.position, this.orientation]);
39962 this.split = new Roo.bootstrap.SplitBar({
39963 dragElement : splitEl,
39964 resizingElement: this.el,
39965 orientation : this.orientation
39968 this.split.on("moved", this.onSplitMove, this);
39969 this.split.useShim = this.config.useShim === true;
39970 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
39971 if(this.useSplitTips){
39972 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
39974 //if(config.collapsible){
39975 // this.split.el.on("dblclick", this.collapse, this);
39978 if(typeof this.config.minSize != "undefined"){
39979 this.split.minSize = this.config.minSize;
39981 if(typeof this.config.maxSize != "undefined"){
39982 this.split.maxSize = this.config.maxSize;
39984 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
39985 this.hideSplitter();
39990 getHMaxSize : function(){
39991 var cmax = this.config.maxSize || 10000;
39992 var center = this.mgr.getRegion("center");
39993 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
39996 getVMaxSize : function(){
39997 var cmax = this.config.maxSize || 10000;
39998 var center = this.mgr.getRegion("center");
39999 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
40002 onSplitMove : function(split, newSize){
40003 this.fireEvent("resized", this, newSize);
40007 * Returns the {@link Roo.SplitBar} for this region.
40008 * @return {Roo.SplitBar}
40010 getSplitBar : function(){
40015 this.hideSplitter();
40016 Roo.bootstrap.layout.Split.superclass.hide.call(this);
40019 hideSplitter : function(){
40021 this.split.el.setLocation(-2000,-2000);
40022 this.split.el.hide();
40028 this.split.el.show();
40030 Roo.bootstrap.layout.Split.superclass.show.call(this);
40033 beforeSlide: function(){
40034 if(Roo.isGecko){// firefox overflow auto bug workaround
40035 this.bodyEl.clip();
40037 this.tabs.bodyEl.clip();
40039 if(this.activePanel){
40040 this.activePanel.getEl().clip();
40042 if(this.activePanel.beforeSlide){
40043 this.activePanel.beforeSlide();
40049 afterSlide : function(){
40050 if(Roo.isGecko){// firefox overflow auto bug workaround
40051 this.bodyEl.unclip();
40053 this.tabs.bodyEl.unclip();
40055 if(this.activePanel){
40056 this.activePanel.getEl().unclip();
40057 if(this.activePanel.afterSlide){
40058 this.activePanel.afterSlide();
40064 initAutoHide : function(){
40065 if(this.autoHide !== false){
40066 if(!this.autoHideHd){
40067 var st = new Roo.util.DelayedTask(this.slideIn, this);
40068 this.autoHideHd = {
40069 "mouseout": function(e){
40070 if(!e.within(this.el, true)){
40074 "mouseover" : function(e){
40080 this.el.on(this.autoHideHd);
40084 clearAutoHide : function(){
40085 if(this.autoHide !== false){
40086 this.el.un("mouseout", this.autoHideHd.mouseout);
40087 this.el.un("mouseover", this.autoHideHd.mouseover);
40091 clearMonitor : function(){
40092 Roo.get(document).un("click", this.slideInIf, this);
40095 // these names are backwards but not changed for compat
40096 slideOut : function(){
40097 if(this.isSlid || this.el.hasActiveFx()){
40100 this.isSlid = true;
40101 if(this.collapseBtn){
40102 this.collapseBtn.hide();
40104 this.closeBtnState = this.closeBtn.getStyle('display');
40105 this.closeBtn.hide();
40107 this.stickBtn.show();
40110 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
40111 this.beforeSlide();
40112 this.el.setStyle("z-index", 10001);
40113 this.el.slideIn(this.getSlideAnchor(), {
40114 callback: function(){
40116 this.initAutoHide();
40117 Roo.get(document).on("click", this.slideInIf, this);
40118 this.fireEvent("slideshow", this);
40125 afterSlideIn : function(){
40126 this.clearAutoHide();
40127 this.isSlid = false;
40128 this.clearMonitor();
40129 this.el.setStyle("z-index", "");
40130 if(this.collapseBtn){
40131 this.collapseBtn.show();
40133 this.closeBtn.setStyle('display', this.closeBtnState);
40135 this.stickBtn.hide();
40137 this.fireEvent("slidehide", this);
40140 slideIn : function(cb){
40141 if(!this.isSlid || this.el.hasActiveFx()){
40145 this.isSlid = false;
40146 this.beforeSlide();
40147 this.el.slideOut(this.getSlideAnchor(), {
40148 callback: function(){
40149 this.el.setLeftTop(-10000, -10000);
40151 this.afterSlideIn();
40159 slideInIf : function(e){
40160 if(!e.within(this.el)){
40165 animateCollapse : function(){
40166 this.beforeSlide();
40167 this.el.setStyle("z-index", 20000);
40168 var anchor = this.getSlideAnchor();
40169 this.el.slideOut(anchor, {
40170 callback : function(){
40171 this.el.setStyle("z-index", "");
40172 this.collapsedEl.slideIn(anchor, {duration:.3});
40174 this.el.setLocation(-10000,-10000);
40176 this.fireEvent("collapsed", this);
40183 animateExpand : function(){
40184 this.beforeSlide();
40185 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
40186 this.el.setStyle("z-index", 20000);
40187 this.collapsedEl.hide({
40190 this.el.slideIn(this.getSlideAnchor(), {
40191 callback : function(){
40192 this.el.setStyle("z-index", "");
40195 this.split.el.show();
40197 this.fireEvent("invalidated", this);
40198 this.fireEvent("expanded", this);
40226 getAnchor : function(){
40227 return this.anchors[this.position];
40230 getCollapseAnchor : function(){
40231 return this.canchors[this.position];
40234 getSlideAnchor : function(){
40235 return this.sanchors[this.position];
40238 getAlignAdj : function(){
40239 var cm = this.cmargins;
40240 switch(this.position){
40256 getExpandAdj : function(){
40257 var c = this.collapsedEl, cm = this.cmargins;
40258 switch(this.position){
40260 return [-(cm.right+c.getWidth()+cm.left), 0];
40263 return [cm.right+c.getWidth()+cm.left, 0];
40266 return [0, -(cm.top+cm.bottom+c.getHeight())];
40269 return [0, cm.top+cm.bottom+c.getHeight()];
40275 * Ext JS Library 1.1.1
40276 * Copyright(c) 2006-2007, Ext JS, LLC.
40278 * Originally Released Under LGPL - original licence link has changed is not relivant.
40281 * <script type="text/javascript">
40284 * These classes are private internal classes
40286 Roo.bootstrap.layout.Center = function(config){
40287 config.region = "center";
40288 Roo.bootstrap.layout.Region.call(this, config);
40289 this.visible = true;
40290 this.minWidth = config.minWidth || 20;
40291 this.minHeight = config.minHeight || 20;
40294 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
40296 // center panel can't be hidden
40300 // center panel can't be hidden
40303 getMinWidth: function(){
40304 return this.minWidth;
40307 getMinHeight: function(){
40308 return this.minHeight;
40322 Roo.bootstrap.layout.North = function(config)
40324 config.region = 'north';
40325 config.cursor = 'n-resize';
40327 Roo.bootstrap.layout.Split.call(this, config);
40331 this.split.placement = Roo.bootstrap.SplitBar.TOP;
40332 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
40333 this.split.el.addClass("roo-layout-split-v");
40335 //var size = config.initialSize || config.height;
40336 //if(this.el && typeof size != "undefined"){
40337 // this.el.setHeight(size);
40340 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
40342 orientation: Roo.bootstrap.SplitBar.VERTICAL,
40345 onRender : function(ctr, pos)
40347 Roo.bootstrap.layout.Split.prototype.onRender.call(this, ctr, pos);
40348 var size = this.config.initialSize || this.config.height;
40349 if(this.el && typeof size != "undefined"){
40350 this.el.setHeight(size);
40355 getBox : function(){
40356 if(this.collapsed){
40357 return this.collapsedEl.getBox();
40359 var box = this.el.getBox();
40361 box.height += this.split.el.getHeight();
40366 updateBox : function(box){
40367 if(this.split && !this.collapsed){
40368 box.height -= this.split.el.getHeight();
40369 this.split.el.setLeft(box.x);
40370 this.split.el.setTop(box.y+box.height);
40371 this.split.el.setWidth(box.width);
40373 if(this.collapsed){
40374 this.updateBody(box.width, null);
40376 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
40384 Roo.bootstrap.layout.South = function(config){
40385 config.region = 'south';
40386 config.cursor = 's-resize';
40387 Roo.bootstrap.layout.Split.call(this, config);
40389 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
40390 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
40391 this.split.el.addClass("roo-layout-split-v");
40396 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
40397 orientation: Roo.bootstrap.SplitBar.VERTICAL,
40399 onRender : function(ctr, pos)
40401 Roo.bootstrap.layout.Split.prototype.onRender.call(this, ctr, pos);
40402 var size = this.config.initialSize || this.config.height;
40403 if(this.el && typeof size != "undefined"){
40404 this.el.setHeight(size);
40409 getBox : function(){
40410 if(this.collapsed){
40411 return this.collapsedEl.getBox();
40413 var box = this.el.getBox();
40415 var sh = this.split.el.getHeight();
40422 updateBox : function(box){
40423 if(this.split && !this.collapsed){
40424 var sh = this.split.el.getHeight();
40427 this.split.el.setLeft(box.x);
40428 this.split.el.setTop(box.y-sh);
40429 this.split.el.setWidth(box.width);
40431 if(this.collapsed){
40432 this.updateBody(box.width, null);
40434 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
40438 Roo.bootstrap.layout.East = function(config){
40439 config.region = "east";
40440 config.cursor = "e-resize";
40441 Roo.bootstrap.layout.Split.call(this, config);
40443 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
40444 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
40445 this.split.el.addClass("roo-layout-split-h");
40449 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
40450 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
40452 onRender : function(ctr, pos)
40454 Roo.bootstrap.layout.Split.prototype.onRender.call(this, ctr, pos);
40455 var size = this.config.initialSize || this.config.width;
40456 if(this.el && typeof size != "undefined"){
40457 this.el.setWidth(size);
40462 getBox : function(){
40463 if(this.collapsed){
40464 return this.collapsedEl.getBox();
40466 var box = this.el.getBox();
40468 var sw = this.split.el.getWidth();
40475 updateBox : function(box){
40476 if(this.split && !this.collapsed){
40477 var sw = this.split.el.getWidth();
40479 this.split.el.setLeft(box.x);
40480 this.split.el.setTop(box.y);
40481 this.split.el.setHeight(box.height);
40484 if(this.collapsed){
40485 this.updateBody(null, box.height);
40487 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
40491 Roo.bootstrap.layout.West = function(config){
40492 config.region = "west";
40493 config.cursor = "w-resize";
40495 Roo.bootstrap.layout.Split.call(this, config);
40497 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
40498 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
40499 this.split.el.addClass("roo-layout-split-h");
40503 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
40504 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
40506 onRender: function(ctr, pos)
40508 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
40509 var size = this.config.initialSize || this.config.width;
40510 if(typeof size != "undefined"){
40511 this.el.setWidth(size);
40515 getBox : function(){
40516 if(this.collapsed){
40517 return this.collapsedEl.getBox();
40519 var box = this.el.getBox();
40520 if (box.width == 0) {
40521 box.width = this.config.width; // kludge?
40524 box.width += this.split.el.getWidth();
40529 updateBox : function(box){
40530 if(this.split && !this.collapsed){
40531 var sw = this.split.el.getWidth();
40533 this.split.el.setLeft(box.x+box.width);
40534 this.split.el.setTop(box.y);
40535 this.split.el.setHeight(box.height);
40537 if(this.collapsed){
40538 this.updateBody(null, box.height);
40540 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
40542 });Roo.namespace("Roo.bootstrap.panel");/*
40544 * Ext JS Library 1.1.1
40545 * Copyright(c) 2006-2007, Ext JS, LLC.
40547 * Originally Released Under LGPL - original licence link has changed is not relivant.
40550 * <script type="text/javascript">
40553 * @class Roo.ContentPanel
40554 * @extends Roo.util.Observable
40556 * A basic ContentPanel element.
40557 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
40558 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
40559 * @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
40560 * @cfg {Boolean} closable True if the panel can be closed/removed
40561 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
40562 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
40563 * @cfg {Toolbar} toolbar A toolbar for this panel
40564 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
40565 * @cfg {String} title The title for this panel
40566 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
40567 * @cfg {String} url Calls {@link #setUrl} with this value
40568 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
40569 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
40570 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
40571 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
40572 * @cfg {Boolean} iframe contents are an iframe - makes showing remote sources/CSS feasible..
40573 * @cfg {Boolean} badges render the badges
40574 * @cfg {String} cls extra classes to use
40575 * @cfg {String} background (primary|secondary|success|info|warning|danger|light|dark)
40578 * Create a new ContentPanel.
40579 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
40580 * @param {String/Object} config A string to set only the title or a config object
40581 * @param {String} content (optional) Set the HTML content for this panel
40582 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
40584 Roo.bootstrap.panel.Content = function( config){
40586 this.tpl = config.tpl || false;
40588 var el = config.el;
40589 var content = config.content;
40591 if(config.autoCreate){ // xtype is available if this is called from factory
40594 this.el = Roo.get(el);
40595 if(!this.el && config && config.autoCreate){
40596 if(typeof config.autoCreate == "object"){
40597 if(!config.autoCreate.id){
40598 config.autoCreate.id = config.id||el;
40600 this.el = Roo.DomHelper.append(document.body,
40601 config.autoCreate, true);
40605 cls: (config.cls || '') +
40606 (config.background ? ' bg-' + config.background : '') +
40607 " roo-layout-inactive-content",
40610 if (config.iframe) {
40614 style : 'border: 0px',
40615 src : 'about:blank'
40621 elcfg.html = config.html;
40625 this.el = Roo.DomHelper.append(document.body, elcfg , true);
40626 if (config.iframe) {
40627 this.iframeEl = this.el.select('iframe',true).first();
40632 this.closable = false;
40633 this.loaded = false;
40634 this.active = false;
40637 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
40639 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
40641 this.wrapEl = this.el; //this.el.wrap();
40643 if (config.toolbar.items) {
40644 ti = config.toolbar.items ;
40645 delete config.toolbar.items ;
40649 this.toolbar.render(this.wrapEl, 'before');
40650 for(var i =0;i < ti.length;i++) {
40651 // Roo.log(['add child', items[i]]);
40652 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
40654 this.toolbar.items = nitems;
40655 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
40656 delete config.toolbar;
40660 // xtype created footer. - not sure if will work as we normally have to render first..
40661 if (this.footer && !this.footer.el && this.footer.xtype) {
40662 if (!this.wrapEl) {
40663 this.wrapEl = this.el.wrap();
40666 this.footer.container = this.wrapEl.createChild();
40668 this.footer = Roo.factory(this.footer, Roo);
40673 if(typeof config == "string"){
40674 this.title = config;
40676 Roo.apply(this, config);
40680 this.resizeEl = Roo.get(this.resizeEl, true);
40682 this.resizeEl = this.el;
40684 // handle view.xtype
40692 * Fires when this panel is activated.
40693 * @param {Roo.ContentPanel} this
40697 * @event deactivate
40698 * Fires when this panel is activated.
40699 * @param {Roo.ContentPanel} this
40701 "deactivate" : true,
40705 * Fires when this panel is resized if fitToFrame is true.
40706 * @param {Roo.ContentPanel} this
40707 * @param {Number} width The width after any component adjustments
40708 * @param {Number} height The height after any component adjustments
40714 * Fires when this tab is created
40715 * @param {Roo.ContentPanel} this
40721 * Fires when this content is scrolled
40722 * @param {Roo.ContentPanel} this
40723 * @param {Event} scrollEvent
40734 if(this.autoScroll && !this.iframe){
40735 this.resizeEl.setStyle("overflow", "auto");
40736 this.resizeEl.on('scroll', this.onScroll, this);
40738 // fix randome scrolling
40739 //this.el.on('scroll', function() {
40740 // Roo.log('fix random scolling');
40741 // this.scrollTo('top',0);
40744 content = content || this.content;
40746 this.setContent(content);
40748 if(config && config.url){
40749 this.setUrl(this.url, this.params, this.loadOnce);
40754 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
40756 if (this.view && typeof(this.view.xtype) != 'undefined') {
40757 this.view.el = this.el.appendChild(document.createElement("div"));
40758 this.view = Roo.factory(this.view);
40759 this.view.render && this.view.render(false, '');
40763 this.fireEvent('render', this);
40766 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
40776 /* Resize Element - use this to work out scroll etc. */
40779 setRegion : function(region){
40780 this.region = region;
40781 this.setActiveClass(region && !this.background);
40785 setActiveClass: function(state)
40788 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
40789 this.el.setStyle('position','relative');
40791 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
40792 this.el.setStyle('position', 'absolute');
40797 * Returns the toolbar for this Panel if one was configured.
40798 * @return {Roo.Toolbar}
40800 getToolbar : function(){
40801 return this.toolbar;
40804 setActiveState : function(active)
40806 this.active = active;
40807 this.setActiveClass(active);
40809 if(this.fireEvent("deactivate", this) === false){
40814 this.fireEvent("activate", this);
40818 * Updates this panel's element (not for iframe)
40819 * @param {String} content The new content
40820 * @param {Boolean} loadScripts (optional) true to look for and process scripts
40822 setContent : function(content, loadScripts){
40827 this.el.update(content, loadScripts);
40830 ignoreResize : function(w, h){
40831 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
40834 this.lastSize = {width: w, height: h};
40839 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
40840 * @return {Roo.UpdateManager} The UpdateManager
40842 getUpdateManager : function(){
40846 return this.el.getUpdateManager();
40849 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
40850 * Does not work with IFRAME contents
40851 * @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:
40854 url: "your-url.php",
40855 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
40856 callback: yourFunction,
40857 scope: yourObject, //(optional scope)
40860 text: "Loading...",
40866 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
40867 * 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.
40868 * @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}
40869 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
40870 * @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.
40871 * @return {Roo.ContentPanel} this
40879 var um = this.el.getUpdateManager();
40880 um.update.apply(um, arguments);
40886 * 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.
40887 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
40888 * @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)
40889 * @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)
40890 * @return {Roo.UpdateManager|Boolean} The UpdateManager or false if IFRAME
40892 setUrl : function(url, params, loadOnce){
40894 this.iframeEl.dom.src = url;
40898 if(this.refreshDelegate){
40899 this.removeListener("activate", this.refreshDelegate);
40901 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
40902 this.on("activate", this.refreshDelegate);
40903 return this.el.getUpdateManager();
40906 _handleRefresh : function(url, params, loadOnce){
40907 if(!loadOnce || !this.loaded){
40908 var updater = this.el.getUpdateManager();
40909 updater.update(url, params, this._setLoaded.createDelegate(this));
40913 _setLoaded : function(){
40914 this.loaded = true;
40918 * Returns this panel's id
40921 getId : function(){
40926 * Returns this panel's element - used by regiosn to add.
40927 * @return {Roo.Element}
40929 getEl : function(){
40930 return this.wrapEl || this.el;
40935 adjustForComponents : function(width, height)
40937 //Roo.log('adjustForComponents ');
40938 if(this.resizeEl != this.el){
40939 width -= this.el.getFrameWidth('lr');
40940 height -= this.el.getFrameWidth('tb');
40943 var te = this.toolbar.getEl();
40944 te.setWidth(width);
40945 height -= te.getHeight();
40948 var te = this.footer.getEl();
40949 te.setWidth(width);
40950 height -= te.getHeight();
40954 if(this.adjustments){
40955 width += this.adjustments[0];
40956 height += this.adjustments[1];
40958 return {"width": width, "height": height};
40961 setSize : function(width, height){
40962 if(this.fitToFrame && !this.ignoreResize(width, height)){
40963 if(this.fitContainer && this.resizeEl != this.el){
40964 this.el.setSize(width, height);
40966 var size = this.adjustForComponents(width, height);
40968 this.iframeEl.setSize(width,height);
40971 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
40972 this.fireEvent('resize', this, size.width, size.height);
40979 * Returns this panel's title
40982 getTitle : function(){
40984 if (typeof(this.title) != 'object') {
40989 for (var k in this.title) {
40990 if (!this.title.hasOwnProperty(k)) {
40994 if (k.indexOf('-') >= 0) {
40995 var s = k.split('-');
40996 for (var i = 0; i<s.length; i++) {
40997 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
41000 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
41007 * Set this panel's title
41008 * @param {String} title
41010 setTitle : function(title){
41011 this.title = title;
41013 this.region.updatePanelTitle(this, title);
41018 * Returns true is this panel was configured to be closable
41019 * @return {Boolean}
41021 isClosable : function(){
41022 return this.closable;
41025 beforeSlide : function(){
41027 this.resizeEl.clip();
41030 afterSlide : function(){
41032 this.resizeEl.unclip();
41036 * Force a content refresh from the URL specified in the {@link #setUrl} method.
41037 * Will fail silently if the {@link #setUrl} method has not been called.
41038 * This does not activate the panel, just updates its content.
41040 refresh : function(){
41041 if(this.refreshDelegate){
41042 this.loaded = false;
41043 this.refreshDelegate();
41048 * Destroys this panel
41050 destroy : function(){
41051 this.el.removeAllListeners();
41052 var tempEl = document.createElement("span");
41053 tempEl.appendChild(this.el.dom);
41054 tempEl.innerHTML = "";
41060 * form - if the content panel contains a form - this is a reference to it.
41061 * @type {Roo.form.Form}
41065 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
41066 * This contains a reference to it.
41072 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
41082 * @param {Object} cfg Xtype definition of item to add.
41086 getChildContainer: function () {
41087 return this.getEl();
41091 onScroll : function(e)
41093 this.fireEvent('scroll', this, e);
41098 var ret = new Roo.factory(cfg);
41103 if (cfg.xtype.match(/^Form$/)) {
41106 //if (this.footer) {
41107 // el = this.footer.container.insertSibling(false, 'before');
41109 el = this.el.createChild();
41112 this.form = new Roo.form.Form(cfg);
41115 if ( this.form.allItems.length) {
41116 this.form.render(el.dom);
41120 // should only have one of theses..
41121 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
41122 // views.. should not be just added - used named prop 'view''
41124 cfg.el = this.el.appendChild(document.createElement("div"));
41127 var ret = new Roo.factory(cfg);
41129 ret.render && ret.render(false, ''); // render blank..
41139 * @class Roo.bootstrap.panel.Grid
41140 * @extends Roo.bootstrap.panel.Content
41142 * Create a new GridPanel.
41143 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
41144 * @param {Object} config A the config object
41150 Roo.bootstrap.panel.Grid = function(config)
41154 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
41155 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
41157 config.el = this.wrapper;
41158 //this.el = this.wrapper;
41160 if (config.container) {
41161 // ctor'ed from a Border/panel.grid
41164 this.wrapper.setStyle("overflow", "hidden");
41165 this.wrapper.addClass('roo-grid-container');
41170 if(config.toolbar){
41171 var tool_el = this.wrapper.createChild();
41172 this.toolbar = Roo.factory(config.toolbar);
41174 if (config.toolbar.items) {
41175 ti = config.toolbar.items ;
41176 delete config.toolbar.items ;
41180 this.toolbar.render(tool_el);
41181 for(var i =0;i < ti.length;i++) {
41182 // Roo.log(['add child', items[i]]);
41183 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
41185 this.toolbar.items = nitems;
41187 delete config.toolbar;
41190 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
41191 config.grid.scrollBody = true;;
41192 config.grid.monitorWindowResize = false; // turn off autosizing
41193 config.grid.autoHeight = false;
41194 config.grid.autoWidth = false;
41196 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
41198 if (config.background) {
41199 // render grid on panel activation (if panel background)
41200 this.on('activate', function(gp) {
41201 if (!gp.grid.rendered) {
41202 gp.grid.render(this.wrapper);
41203 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
41208 this.grid.render(this.wrapper);
41209 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
41212 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
41213 // ??? needed ??? config.el = this.wrapper;
41218 // xtype created footer. - not sure if will work as we normally have to render first..
41219 if (this.footer && !this.footer.el && this.footer.xtype) {
41221 var ctr = this.grid.getView().getFooterPanel(true);
41222 this.footer.dataSource = this.grid.dataSource;
41223 this.footer = Roo.factory(this.footer, Roo);
41224 this.footer.render(ctr);
41234 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
41235 getId : function(){
41236 return this.grid.id;
41240 * Returns the grid for this panel
41241 * @return {Roo.bootstrap.Table}
41243 getGrid : function(){
41247 setSize : function(width, height){
41248 if(!this.ignoreResize(width, height)){
41249 var grid = this.grid;
41250 var size = this.adjustForComponents(width, height);
41251 // tfoot is not a footer?
41254 var gridel = grid.getGridEl();
41255 gridel.setSize(size.width, size.height);
41257 var tbd = grid.getGridEl().select('tbody', true).first();
41258 var thd = grid.getGridEl().select('thead',true).first();
41259 var tbf= grid.getGridEl().select('tfoot', true).first();
41262 size.height -= tbf.getHeight();
41265 size.height -= thd.getHeight();
41268 tbd.setSize(size.width, size.height );
41269 // this is for the account management tab -seems to work there.
41270 var thd = grid.getGridEl().select('thead',true).first();
41272 // tbd.setSize(size.width, size.height - thd.getHeight());
41281 beforeSlide : function(){
41282 this.grid.getView().scroller.clip();
41285 afterSlide : function(){
41286 this.grid.getView().scroller.unclip();
41289 destroy : function(){
41290 this.grid.destroy();
41292 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
41297 * @class Roo.bootstrap.panel.Nest
41298 * @extends Roo.bootstrap.panel.Content
41300 * Create a new Panel, that can contain a layout.Border.
41303 * @param {Roo.BorderLayout} layout The layout for this panel
41304 * @param {String/Object} config A string to set only the title or a config object
41306 Roo.bootstrap.panel.Nest = function(config)
41308 // construct with only one argument..
41309 /* FIXME - implement nicer consturctors
41310 if (layout.layout) {
41312 layout = config.layout;
41313 delete config.layout;
41315 if (layout.xtype && !layout.getEl) {
41316 // then layout needs constructing..
41317 layout = Roo.factory(layout, Roo);
41321 config.el = config.layout.getEl();
41323 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
41325 config.layout.monitorWindowResize = false; // turn off autosizing
41326 this.layout = config.layout;
41327 this.layout.getEl().addClass("roo-layout-nested-layout");
41328 this.layout.parent = this;
41335 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
41337 setSize : function(width, height){
41338 if(!this.ignoreResize(width, height)){
41339 var size = this.adjustForComponents(width, height);
41340 var el = this.layout.getEl();
41341 if (size.height < 1) {
41342 el.setWidth(size.width);
41344 el.setSize(size.width, size.height);
41346 var touch = el.dom.offsetWidth;
41347 this.layout.layout();
41348 // ie requires a double layout on the first pass
41349 if(Roo.isIE && !this.initialized){
41350 this.initialized = true;
41351 this.layout.layout();
41356 // activate all subpanels if not currently active..
41358 setActiveState : function(active){
41359 this.active = active;
41360 this.setActiveClass(active);
41363 this.fireEvent("deactivate", this);
41367 this.fireEvent("activate", this);
41368 // not sure if this should happen before or after..
41369 if (!this.layout) {
41370 return; // should not happen..
41373 for (var r in this.layout.regions) {
41374 reg = this.layout.getRegion(r);
41375 if (reg.getActivePanel()) {
41376 //reg.showPanel(reg.getActivePanel()); // force it to activate..
41377 reg.setActivePanel(reg.getActivePanel());
41380 if (!reg.panels.length) {
41383 reg.showPanel(reg.getPanel(0));
41392 * Returns the nested BorderLayout for this panel
41393 * @return {Roo.BorderLayout}
41395 getLayout : function(){
41396 return this.layout;
41400 * Adds a xtype elements to the layout of the nested panel
41404 xtype : 'ContentPanel',
41411 xtype : 'NestedLayoutPanel',
41417 items : [ ... list of content panels or nested layout panels.. ]
41421 * @param {Object} cfg Xtype definition of item to add.
41423 addxtype : function(cfg) {
41424 return this.layout.addxtype(cfg);
41429 * Ext JS Library 1.1.1
41430 * Copyright(c) 2006-2007, Ext JS, LLC.
41432 * Originally Released Under LGPL - original licence link has changed is not relivant.
41435 * <script type="text/javascript">
41438 * @class Roo.TabPanel
41439 * @extends Roo.util.Observable
41440 * A lightweight tab container.
41444 // basic tabs 1, built from existing content
41445 var tabs = new Roo.TabPanel("tabs1");
41446 tabs.addTab("script", "View Script");
41447 tabs.addTab("markup", "View Markup");
41448 tabs.activate("script");
41450 // more advanced tabs, built from javascript
41451 var jtabs = new Roo.TabPanel("jtabs");
41452 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
41454 // set up the UpdateManager
41455 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
41456 var updater = tab2.getUpdateManager();
41457 updater.setDefaultUrl("ajax1.htm");
41458 tab2.on('activate', updater.refresh, updater, true);
41460 // Use setUrl for Ajax loading
41461 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
41462 tab3.setUrl("ajax2.htm", null, true);
41465 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
41468 jtabs.activate("jtabs-1");
41471 * Create a new TabPanel.
41472 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
41473 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
41475 Roo.bootstrap.panel.Tabs = function(config){
41477 * The container element for this TabPanel.
41478 * @type Roo.Element
41480 this.el = Roo.get(config.el);
41483 if(typeof config == "boolean"){
41484 this.tabPosition = config ? "bottom" : "top";
41486 Roo.apply(this, config);
41490 if(this.tabPosition == "bottom"){
41491 // if tabs are at the bottom = create the body first.
41492 this.bodyEl = Roo.get(this.createBody(this.el.dom));
41493 this.el.addClass("roo-tabs-bottom");
41495 // next create the tabs holders
41497 if (this.tabPosition == "west"){
41499 var reg = this.region; // fake it..
41501 if (!reg.mgr.parent) {
41504 reg = reg.mgr.parent.region;
41506 Roo.log("got nest?");
41508 if (reg.mgr.getRegion('west')) {
41509 var ctrdom = reg.mgr.getRegion('west').bodyEl.dom;
41510 this.stripWrap = Roo.get(this.createStrip(ctrdom ), true);
41511 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
41512 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
41513 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
41521 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
41522 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
41523 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
41524 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
41529 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
41532 // finally - if tabs are at the top, then create the body last..
41533 if(this.tabPosition != "bottom"){
41534 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
41535 * @type Roo.Element
41537 this.bodyEl = Roo.get(this.createBody(this.el.dom));
41538 this.el.addClass("roo-tabs-top");
41542 this.bodyEl.setStyle("position", "relative");
41544 this.active = null;
41545 this.activateDelegate = this.activate.createDelegate(this);
41550 * Fires when the active tab changes
41551 * @param {Roo.TabPanel} this
41552 * @param {Roo.TabPanelItem} activePanel The new active tab
41556 * @event beforetabchange
41557 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
41558 * @param {Roo.TabPanel} this
41559 * @param {Object} e Set cancel to true on this object to cancel the tab change
41560 * @param {Roo.TabPanelItem} tab The tab being changed to
41562 "beforetabchange" : true
41565 Roo.EventManager.onWindowResize(this.onResize, this);
41566 this.cpad = this.el.getPadding("lr");
41567 this.hiddenCount = 0;
41570 // toolbar on the tabbar support...
41571 if (this.toolbar) {
41572 alert("no toolbar support yet");
41573 this.toolbar = false;
41575 var tcfg = this.toolbar;
41576 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
41577 this.toolbar = new Roo.Toolbar(tcfg);
41578 if (Roo.isSafari) {
41579 var tbl = tcfg.container.child('table', true);
41580 tbl.setAttribute('width', '100%');
41588 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
41591 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
41593 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
41595 tabPosition : "top",
41597 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
41599 currentTabWidth : 0,
41601 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
41605 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
41609 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
41611 preferredTabWidth : 175,
41613 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
41615 resizeTabs : false,
41617 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
41619 monitorResize : true,
41621 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
41623 toolbar : false, // set by caller..
41625 region : false, /// set by caller
41627 disableTooltips : true, // not used yet...
41630 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
41631 * @param {String} id The id of the div to use <b>or create</b>
41632 * @param {String} text The text for the tab
41633 * @param {String} content (optional) Content to put in the TabPanelItem body
41634 * @param {Boolean} closable (optional) True to create a close icon on the tab
41635 * @return {Roo.TabPanelItem} The created TabPanelItem
41637 addTab : function(id, text, content, closable, tpl)
41639 var item = new Roo.bootstrap.panel.TabItem({
41643 closable : closable,
41646 this.addTabItem(item);
41648 item.setContent(content);
41654 * Returns the {@link Roo.TabPanelItem} with the specified id/index
41655 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
41656 * @return {Roo.TabPanelItem}
41658 getTab : function(id){
41659 return this.items[id];
41663 * Hides the {@link Roo.TabPanelItem} with the specified id/index
41664 * @param {String/Number} id The id or index of the TabPanelItem to hide.
41666 hideTab : function(id){
41667 var t = this.items[id];
41670 this.hiddenCount++;
41671 this.autoSizeTabs();
41676 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
41677 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
41679 unhideTab : function(id){
41680 var t = this.items[id];
41682 t.setHidden(false);
41683 this.hiddenCount--;
41684 this.autoSizeTabs();
41689 * Adds an existing {@link Roo.TabPanelItem}.
41690 * @param {Roo.TabPanelItem} item The TabPanelItem to add
41692 addTabItem : function(item)
41694 this.items[item.id] = item;
41695 this.items.push(item);
41696 this.autoSizeTabs();
41697 // if(this.resizeTabs){
41698 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
41699 // this.autoSizeTabs();
41701 // item.autoSize();
41706 * Removes a {@link Roo.TabPanelItem}.
41707 * @param {String/Number} id The id or index of the TabPanelItem to remove.
41709 removeTab : function(id){
41710 var items = this.items;
41711 var tab = items[id];
41712 if(!tab) { return; }
41713 var index = items.indexOf(tab);
41714 if(this.active == tab && items.length > 1){
41715 var newTab = this.getNextAvailable(index);
41720 this.stripEl.dom.removeChild(tab.pnode.dom);
41721 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
41722 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
41724 items.splice(index, 1);
41725 delete this.items[tab.id];
41726 tab.fireEvent("close", tab);
41727 tab.purgeListeners();
41728 this.autoSizeTabs();
41731 getNextAvailable : function(start){
41732 var items = this.items;
41734 // look for a next tab that will slide over to
41735 // replace the one being removed
41736 while(index < items.length){
41737 var item = items[++index];
41738 if(item && !item.isHidden()){
41742 // if one isn't found select the previous tab (on the left)
41745 var item = items[--index];
41746 if(item && !item.isHidden()){
41754 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
41755 * @param {String/Number} id The id or index of the TabPanelItem to disable.
41757 disableTab : function(id){
41758 var tab = this.items[id];
41759 if(tab && this.active != tab){
41765 * Enables a {@link Roo.TabPanelItem} that is disabled.
41766 * @param {String/Number} id The id or index of the TabPanelItem to enable.
41768 enableTab : function(id){
41769 var tab = this.items[id];
41774 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
41775 * @param {String/Number} id The id or index of the TabPanelItem to activate.
41776 * @return {Roo.TabPanelItem} The TabPanelItem.
41778 activate : function(id)
41780 //Roo.log('activite:' + id);
41782 var tab = this.items[id];
41786 if(tab == this.active || tab.disabled){
41790 this.fireEvent("beforetabchange", this, e, tab);
41791 if(e.cancel !== true && !tab.disabled){
41793 this.active.hide();
41795 this.active = this.items[id];
41796 this.active.show();
41797 this.fireEvent("tabchange", this, this.active);
41803 * Gets the active {@link Roo.TabPanelItem}.
41804 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
41806 getActiveTab : function(){
41807 return this.active;
41811 * Updates the tab body element to fit the height of the container element
41812 * for overflow scrolling
41813 * @param {Number} targetHeight (optional) Override the starting height from the elements height
41815 syncHeight : function(targetHeight){
41816 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
41817 var bm = this.bodyEl.getMargins();
41818 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
41819 this.bodyEl.setHeight(newHeight);
41823 onResize : function(){
41824 if(this.monitorResize){
41825 this.autoSizeTabs();
41830 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
41832 beginUpdate : function(){
41833 this.updating = true;
41837 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
41839 endUpdate : function(){
41840 this.updating = false;
41841 this.autoSizeTabs();
41845 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
41847 autoSizeTabs : function()
41849 var count = this.items.length;
41850 var vcount = count - this.hiddenCount;
41853 this.stripEl.hide();
41855 this.stripEl.show();
41858 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
41863 var w = Math.max(this.el.getWidth() - this.cpad, 10);
41864 var availWidth = Math.floor(w / vcount);
41865 var b = this.stripBody;
41866 if(b.getWidth() > w){
41867 var tabs = this.items;
41868 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
41869 if(availWidth < this.minTabWidth){
41870 /*if(!this.sleft){ // incomplete scrolling code
41871 this.createScrollButtons();
41874 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
41877 if(this.currentTabWidth < this.preferredTabWidth){
41878 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
41884 * Returns the number of tabs in this TabPanel.
41887 getCount : function(){
41888 return this.items.length;
41892 * Resizes all the tabs to the passed width
41893 * @param {Number} The new width
41895 setTabWidth : function(width){
41896 this.currentTabWidth = width;
41897 for(var i = 0, len = this.items.length; i < len; i++) {
41898 if(!this.items[i].isHidden()) {
41899 this.items[i].setWidth(width);
41905 * Destroys this TabPanel
41906 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
41908 destroy : function(removeEl){
41909 Roo.EventManager.removeResizeListener(this.onResize, this);
41910 for(var i = 0, len = this.items.length; i < len; i++){
41911 this.items[i].purgeListeners();
41913 if(removeEl === true){
41914 this.el.update("");
41919 createStrip : function(container)
41921 var strip = document.createElement("nav");
41922 strip.className = Roo.bootstrap.version == 4 ?
41923 "navbar-light bg-light" :
41924 "navbar navbar-default"; //"x-tabs-wrap";
41925 container.appendChild(strip);
41929 createStripList : function(strip)
41931 // div wrapper for retard IE
41932 // returns the "tr" element.
41933 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
41934 //'<div class="x-tabs-strip-wrap">'+
41935 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
41936 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
41937 return strip.firstChild; //.firstChild.firstChild.firstChild;
41939 createBody : function(container)
41941 var body = document.createElement("div");
41942 Roo.id(body, "tab-body");
41943 //Roo.fly(body).addClass("x-tabs-body");
41944 Roo.fly(body).addClass("tab-content");
41945 container.appendChild(body);
41948 createItemBody :function(bodyEl, id){
41949 var body = Roo.getDom(id);
41951 body = document.createElement("div");
41954 //Roo.fly(body).addClass("x-tabs-item-body");
41955 Roo.fly(body).addClass("tab-pane");
41956 bodyEl.insertBefore(body, bodyEl.firstChild);
41960 createStripElements : function(stripEl, text, closable, tpl)
41962 var td = document.createElement("li"); // was td..
41963 td.className = 'nav-item';
41965 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
41968 stripEl.appendChild(td);
41970 td.className = "x-tabs-closable";
41971 if(!this.closeTpl){
41972 this.closeTpl = new Roo.Template(
41973 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
41974 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
41975 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
41978 var el = this.closeTpl.overwrite(td, {"text": text});
41979 var close = el.getElementsByTagName("div")[0];
41980 var inner = el.getElementsByTagName("em")[0];
41981 return {"el": el, "close": close, "inner": inner};
41984 // not sure what this is..
41985 // if(!this.tabTpl){
41986 //this.tabTpl = new Roo.Template(
41987 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
41988 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
41990 // this.tabTpl = new Roo.Template(
41991 // '<a href="#">' +
41992 // '<span unselectable="on"' +
41993 // (this.disableTooltips ? '' : ' title="{text}"') +
41994 // ' >{text}</span></a>'
42000 var template = tpl || this.tabTpl || false;
42003 template = new Roo.Template(
42004 Roo.bootstrap.version == 4 ?
42006 '<a class="nav-link" href="#" unselectable="on"' +
42007 (this.disableTooltips ? '' : ' title="{text}"') +
42010 '<a class="nav-link" href="#">' +
42011 '<span unselectable="on"' +
42012 (this.disableTooltips ? '' : ' title="{text}"') +
42013 ' >{text}</span></a>'
42018 switch (typeof(template)) {
42022 template = new Roo.Template(template);
42028 var el = template.overwrite(td, {"text": text});
42030 var inner = el.getElementsByTagName("span")[0];
42032 return {"el": el, "inner": inner};
42040 * @class Roo.TabPanelItem
42041 * @extends Roo.util.Observable
42042 * Represents an individual item (tab plus body) in a TabPanel.
42043 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
42044 * @param {String} id The id of this TabPanelItem
42045 * @param {String} text The text for the tab of this TabPanelItem
42046 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
42048 Roo.bootstrap.panel.TabItem = function(config){
42050 * The {@link Roo.TabPanel} this TabPanelItem belongs to
42051 * @type Roo.TabPanel
42053 this.tabPanel = config.panel;
42055 * The id for this TabPanelItem
42058 this.id = config.id;
42060 this.disabled = false;
42062 this.text = config.text;
42064 this.loaded = false;
42065 this.closable = config.closable;
42068 * The body element for this TabPanelItem.
42069 * @type Roo.Element
42071 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
42072 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
42073 this.bodyEl.setStyle("display", "block");
42074 this.bodyEl.setStyle("zoom", "1");
42075 //this.hideAction();
42077 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
42079 this.el = Roo.get(els.el);
42080 this.inner = Roo.get(els.inner, true);
42081 this.textEl = Roo.bootstrap.version == 4 ?
42082 this.el : Roo.get(this.el.dom.firstChild, true);
42084 this.pnode = this.linode = Roo.get(els.el.parentNode, true);
42085 this.status_node = Roo.bootstrap.version == 4 ? this.el : this.linode;
42088 // this.el.on("mousedown", this.onTabMouseDown, this);
42089 this.el.on("click", this.onTabClick, this);
42091 if(config.closable){
42092 var c = Roo.get(els.close, true);
42093 c.dom.title = this.closeText;
42094 c.addClassOnOver("close-over");
42095 c.on("click", this.closeClick, this);
42101 * Fires when this tab becomes the active tab.
42102 * @param {Roo.TabPanel} tabPanel The parent TabPanel
42103 * @param {Roo.TabPanelItem} this
42107 * @event beforeclose
42108 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
42109 * @param {Roo.TabPanelItem} this
42110 * @param {Object} e Set cancel to true on this object to cancel the close.
42112 "beforeclose": true,
42115 * Fires when this tab is closed.
42116 * @param {Roo.TabPanelItem} this
42120 * @event deactivate
42121 * Fires when this tab is no longer the active tab.
42122 * @param {Roo.TabPanel} tabPanel The parent TabPanel
42123 * @param {Roo.TabPanelItem} this
42125 "deactivate" : true
42127 this.hidden = false;
42129 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
42132 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
42134 purgeListeners : function(){
42135 Roo.util.Observable.prototype.purgeListeners.call(this);
42136 this.el.removeAllListeners();
42139 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
42142 this.status_node.addClass("active");
42145 this.tabPanel.stripWrap.repaint();
42147 this.fireEvent("activate", this.tabPanel, this);
42151 * Returns true if this tab is the active tab.
42152 * @return {Boolean}
42154 isActive : function(){
42155 return this.tabPanel.getActiveTab() == this;
42159 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
42162 this.status_node.removeClass("active");
42164 this.fireEvent("deactivate", this.tabPanel, this);
42167 hideAction : function(){
42168 this.bodyEl.hide();
42169 this.bodyEl.setStyle("position", "absolute");
42170 this.bodyEl.setLeft("-20000px");
42171 this.bodyEl.setTop("-20000px");
42174 showAction : function(){
42175 this.bodyEl.setStyle("position", "relative");
42176 this.bodyEl.setTop("");
42177 this.bodyEl.setLeft("");
42178 this.bodyEl.show();
42182 * Set the tooltip for the tab.
42183 * @param {String} tooltip The tab's tooltip
42185 setTooltip : function(text){
42186 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
42187 this.textEl.dom.qtip = text;
42188 this.textEl.dom.removeAttribute('title');
42190 this.textEl.dom.title = text;
42194 onTabClick : function(e){
42195 e.preventDefault();
42196 this.tabPanel.activate(this.id);
42199 onTabMouseDown : function(e){
42200 e.preventDefault();
42201 this.tabPanel.activate(this.id);
42204 getWidth : function(){
42205 return this.inner.getWidth();
42208 setWidth : function(width){
42209 var iwidth = width - this.linode.getPadding("lr");
42210 this.inner.setWidth(iwidth);
42211 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
42212 this.linode.setWidth(width);
42216 * Show or hide the tab
42217 * @param {Boolean} hidden True to hide or false to show.
42219 setHidden : function(hidden){
42220 this.hidden = hidden;
42221 this.linode.setStyle("display", hidden ? "none" : "");
42225 * Returns true if this tab is "hidden"
42226 * @return {Boolean}
42228 isHidden : function(){
42229 return this.hidden;
42233 * Returns the text for this tab
42236 getText : function(){
42240 autoSize : function(){
42241 //this.el.beginMeasure();
42242 this.textEl.setWidth(1);
42244 * #2804 [new] Tabs in Roojs
42245 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
42247 //this.setWidth(this.textEl.dom.scrollWidth+this.linode.getPadding("lr")+this.inner.getPadding("lr") + 2);
42248 //this.el.endMeasure();
42252 * Sets the text for the tab (Note: this also sets the tooltip text)
42253 * @param {String} text The tab's text and tooltip
42255 setText : function(text){
42257 this.textEl.update(text);
42258 this.setTooltip(text);
42259 //if(!this.tabPanel.resizeTabs){
42260 // this.autoSize();
42264 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
42266 activate : function(){
42267 this.tabPanel.activate(this.id);
42271 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
42273 disable : function(){
42274 if(this.tabPanel.active != this){
42275 this.disabled = true;
42276 this.status_node.addClass("disabled");
42281 * Enables this TabPanelItem if it was previously disabled.
42283 enable : function(){
42284 this.disabled = false;
42285 this.status_node.removeClass("disabled");
42289 * Sets the content for this TabPanelItem.
42290 * @param {String} content The content
42291 * @param {Boolean} loadScripts true to look for and load scripts
42293 setContent : function(content, loadScripts){
42294 this.bodyEl.update(content, loadScripts);
42298 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
42299 * @return {Roo.UpdateManager} The UpdateManager
42301 getUpdateManager : function(){
42302 return this.bodyEl.getUpdateManager();
42306 * Set a URL to be used to load the content for this TabPanelItem.
42307 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
42308 * @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)
42309 * @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)
42310 * @return {Roo.UpdateManager} The UpdateManager
42312 setUrl : function(url, params, loadOnce){
42313 if(this.refreshDelegate){
42314 this.un('activate', this.refreshDelegate);
42316 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
42317 this.on("activate", this.refreshDelegate);
42318 return this.bodyEl.getUpdateManager();
42322 _handleRefresh : function(url, params, loadOnce){
42323 if(!loadOnce || !this.loaded){
42324 var updater = this.bodyEl.getUpdateManager();
42325 updater.update(url, params, this._setLoaded.createDelegate(this));
42330 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
42331 * Will fail silently if the setUrl method has not been called.
42332 * This does not activate the panel, just updates its content.
42334 refresh : function(){
42335 if(this.refreshDelegate){
42336 this.loaded = false;
42337 this.refreshDelegate();
42342 _setLoaded : function(){
42343 this.loaded = true;
42347 closeClick : function(e){
42350 this.fireEvent("beforeclose", this, o);
42351 if(o.cancel !== true){
42352 this.tabPanel.removeTab(this.id);
42356 * The text displayed in the tooltip for the close icon.
42359 closeText : "Close this tab"
42362 * This script refer to:
42363 * Title: International Telephone Input
42364 * Author: Jack O'Connor
42365 * Code version: v12.1.12
42366 * Availability: https://github.com/jackocnr/intl-tel-input.git
42369 Roo.bootstrap.PhoneInputData = function() {
42372 "Afghanistan (افغانستان)",
42377 "Albania (Shqipëri)",
42382 "Algeria (الجزائر)",
42407 "Antigua and Barbuda",
42417 "Armenia (Հայաստան)",
42433 "Austria (Österreich)",
42438 "Azerbaijan (Azərbaycan)",
42448 "Bahrain (البحرين)",
42453 "Bangladesh (বাংলাদেশ)",
42463 "Belarus (Беларусь)",
42468 "Belgium (België)",
42498 "Bosnia and Herzegovina (Босна и Херцеговина)",
42513 "British Indian Ocean Territory",
42518 "British Virgin Islands",
42528 "Bulgaria (България)",
42538 "Burundi (Uburundi)",
42543 "Cambodia (កម្ពុជា)",
42548 "Cameroon (Cameroun)",
42557 ["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"]
42560 "Cape Verde (Kabu Verdi)",
42565 "Caribbean Netherlands",
42576 "Central African Republic (République centrafricaine)",
42596 "Christmas Island",
42602 "Cocos (Keeling) Islands",
42613 "Comoros (جزر القمر)",
42618 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
42623 "Congo (Republic) (Congo-Brazzaville)",
42643 "Croatia (Hrvatska)",
42664 "Czech Republic (Česká republika)",
42669 "Denmark (Danmark)",
42684 "Dominican Republic (República Dominicana)",
42688 ["809", "829", "849"]
42706 "Equatorial Guinea (Guinea Ecuatorial)",
42726 "Falkland Islands (Islas Malvinas)",
42731 "Faroe Islands (Føroyar)",
42752 "French Guiana (Guyane française)",
42757 "French Polynesia (Polynésie française)",
42772 "Georgia (საქართველო)",
42777 "Germany (Deutschland)",
42797 "Greenland (Kalaallit Nunaat)",
42834 "Guinea-Bissau (Guiné Bissau)",
42859 "Hungary (Magyarország)",
42864 "Iceland (Ísland)",
42884 "Iraq (العراق)",
42900 "Israel (ישראל)",
42927 "Jordan (الأردن)",
42932 "Kazakhstan (Казахстан)",
42953 "Kuwait (الكويت)",
42958 "Kyrgyzstan (Кыргызстан)",
42968 "Latvia (Latvija)",
42973 "Lebanon (لبنان)",
42988 "Libya (ليبيا)",
42998 "Lithuania (Lietuva)",
43013 "Macedonia (FYROM) (Македонија)",
43018 "Madagascar (Madagasikara)",
43048 "Marshall Islands",
43058 "Mauritania (موريتانيا)",
43063 "Mauritius (Moris)",
43084 "Moldova (Republica Moldova)",
43094 "Mongolia (Монгол)",
43099 "Montenegro (Crna Gora)",
43109 "Morocco (المغرب)",
43115 "Mozambique (Moçambique)",
43120 "Myanmar (Burma) (မြန်မာ)",
43125 "Namibia (Namibië)",
43140 "Netherlands (Nederland)",
43145 "New Caledonia (Nouvelle-Calédonie)",
43180 "North Korea (조선 민주주의 인민 공화국)",
43185 "Northern Mariana Islands",
43201 "Pakistan (پاکستان)",
43211 "Palestine (فلسطين)",
43221 "Papua New Guinea",
43263 "Réunion (La Réunion)",
43269 "Romania (România)",
43285 "Saint Barthélemy",
43296 "Saint Kitts and Nevis",
43306 "Saint Martin (Saint-Martin (partie française))",
43312 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
43317 "Saint Vincent and the Grenadines",
43332 "São Tomé and Príncipe (São Tomé e Príncipe)",
43337 "Saudi Arabia (المملكة العربية السعودية)",
43342 "Senegal (Sénégal)",
43372 "Slovakia (Slovensko)",
43377 "Slovenia (Slovenija)",
43387 "Somalia (Soomaaliya)",
43397 "South Korea (대한민국)",
43402 "South Sudan (جنوب السودان)",
43412 "Sri Lanka (ශ්රී ලංකාව)",
43417 "Sudan (السودان)",
43427 "Svalbard and Jan Mayen",
43438 "Sweden (Sverige)",
43443 "Switzerland (Schweiz)",
43448 "Syria (سوريا)",
43493 "Trinidad and Tobago",
43498 "Tunisia (تونس)",
43503 "Turkey (Türkiye)",
43513 "Turks and Caicos Islands",
43523 "U.S. Virgin Islands",
43533 "Ukraine (Україна)",
43538 "United Arab Emirates (الإمارات العربية المتحدة)",
43560 "Uzbekistan (Oʻzbekiston)",
43570 "Vatican City (Città del Vaticano)",
43581 "Vietnam (Việt Nam)",
43586 "Wallis and Futuna (Wallis-et-Futuna)",
43591 "Western Sahara (الصحراء الغربية)",
43597 "Yemen (اليمن)",
43621 * This script refer to:
43622 * Title: International Telephone Input
43623 * Author: Jack O'Connor
43624 * Code version: v12.1.12
43625 * Availability: https://github.com/jackocnr/intl-tel-input.git
43629 * @class Roo.bootstrap.PhoneInput
43630 * @extends Roo.bootstrap.TriggerField
43631 * An input with International dial-code selection
43633 * @cfg {String} defaultDialCode default '+852'
43634 * @cfg {Array} preferedCountries default []
43637 * Create a new PhoneInput.
43638 * @param {Object} config Configuration options
43641 Roo.bootstrap.PhoneInput = function(config) {
43642 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
43645 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
43647 * @cfg {Roo.data.Store} store [required] The data store to which this combo is bound (defaults to undefined)
43649 listWidth: undefined,
43651 selectedClass: 'active',
43653 invalidClass : "has-warning",
43655 validClass: 'has-success',
43657 allowed: '0123456789',
43662 * @cfg {String} defaultDialCode The default dial code when initializing the input
43664 defaultDialCode: '+852',
43667 * @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
43669 preferedCountries: false,
43671 getAutoCreate : function()
43673 var data = Roo.bootstrap.PhoneInputData();
43674 var align = this.labelAlign || this.parentLabelAlign();
43677 this.allCountries = [];
43678 this.dialCodeMapping = [];
43680 for (var i = 0; i < data.length; i++) {
43682 this.allCountries[i] = {
43686 priority: c[3] || 0,
43687 areaCodes: c[4] || null
43689 this.dialCodeMapping[c[2]] = {
43692 priority: c[3] || 0,
43693 areaCodes: c[4] || null
43705 // type: 'number', -- do not use number - we get the flaky up/down arrows.
43706 maxlength: this.max_length,
43707 cls : 'form-control tel-input',
43708 autocomplete: 'new-password'
43711 var hiddenInput = {
43714 cls: 'hidden-tel-input'
43718 hiddenInput.name = this.name;
43721 if (this.disabled) {
43722 input.disabled = true;
43725 var flag_container = {
43742 cls: this.hasFeedback ? 'has-feedback' : '',
43748 cls: 'dial-code-holder',
43755 cls: 'roo-select2-container input-group',
43762 if (this.fieldLabel.length) {
43765 tooltip: 'This field is required'
43771 cls: 'control-label',
43777 html: this.fieldLabel
43780 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
43786 if(this.indicatorpos == 'right') {
43787 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
43794 if(align == 'left') {
43802 if(this.labelWidth > 12){
43803 label.style = "width: " + this.labelWidth + 'px';
43805 if(this.labelWidth < 13 && this.labelmd == 0){
43806 this.labelmd = this.labelWidth;
43808 if(this.labellg > 0){
43809 label.cls += ' col-lg-' + this.labellg;
43810 input.cls += ' col-lg-' + (12 - this.labellg);
43812 if(this.labelmd > 0){
43813 label.cls += ' col-md-' + this.labelmd;
43814 container.cls += ' col-md-' + (12 - this.labelmd);
43816 if(this.labelsm > 0){
43817 label.cls += ' col-sm-' + this.labelsm;
43818 container.cls += ' col-sm-' + (12 - this.labelsm);
43820 if(this.labelxs > 0){
43821 label.cls += ' col-xs-' + this.labelxs;
43822 container.cls += ' col-xs-' + (12 - this.labelxs);
43832 var settings = this;
43834 ['xs','sm','md','lg'].map(function(size){
43835 if (settings[size]) {
43836 cfg.cls += ' col-' + size + '-' + settings[size];
43840 this.store = new Roo.data.Store({
43841 proxy : new Roo.data.MemoryProxy({}),
43842 reader : new Roo.data.JsonReader({
43853 'name' : 'dialCode',
43857 'name' : 'priority',
43861 'name' : 'areaCodes',
43868 if(!this.preferedCountries) {
43869 this.preferedCountries = [
43876 var p = this.preferedCountries.reverse();
43879 for (var i = 0; i < p.length; i++) {
43880 for (var j = 0; j < this.allCountries.length; j++) {
43881 if(this.allCountries[j].iso2 == p[i]) {
43882 var t = this.allCountries[j];
43883 this.allCountries.splice(j,1);
43884 this.allCountries.unshift(t);
43890 this.store.proxy.data = {
43892 data: this.allCountries
43898 initEvents : function()
43901 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
43903 this.indicator = this.indicatorEl();
43904 this.flag = this.flagEl();
43905 this.dialCodeHolder = this.dialCodeHolderEl();
43907 this.trigger = this.el.select('div.flag-box',true).first();
43908 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
43913 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
43914 _this.list.setWidth(lw);
43917 this.list.on('mouseover', this.onViewOver, this);
43918 this.list.on('mousemove', this.onViewMove, this);
43919 this.inputEl().on("keyup", this.onKeyUp, this);
43920 this.inputEl().on("keypress", this.onKeyPress, this);
43922 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
43924 this.view = new Roo.View(this.list, this.tpl, {
43925 singleSelect:true, store: this.store, selectedClass: this.selectedClass
43928 this.view.on('click', this.onViewClick, this);
43929 this.setValue(this.defaultDialCode);
43932 onTriggerClick : function(e)
43934 Roo.log('trigger click');
43939 if(this.isExpanded()){
43941 this.hasFocus = false;
43943 this.store.load({});
43944 this.hasFocus = true;
43949 isExpanded : function()
43951 return this.list.isVisible();
43954 collapse : function()
43956 if(!this.isExpanded()){
43960 Roo.get(document).un('mousedown', this.collapseIf, this);
43961 Roo.get(document).un('mousewheel', this.collapseIf, this);
43962 this.fireEvent('collapse', this);
43966 expand : function()
43970 if(this.isExpanded() || !this.hasFocus){
43974 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
43975 this.list.setWidth(lw);
43978 this.restrictHeight();
43980 Roo.get(document).on('mousedown', this.collapseIf, this);
43981 Roo.get(document).on('mousewheel', this.collapseIf, this);
43983 this.fireEvent('expand', this);
43986 restrictHeight : function()
43988 this.list.alignTo(this.inputEl(), this.listAlign);
43989 this.list.alignTo(this.inputEl(), this.listAlign);
43992 onViewOver : function(e, t)
43994 if(this.inKeyMode){
43997 var item = this.view.findItemFromChild(t);
44000 var index = this.view.indexOf(item);
44001 this.select(index, false);
44006 onViewClick : function(view, doFocus, el, e)
44008 var index = this.view.getSelectedIndexes()[0];
44010 var r = this.store.getAt(index);
44013 this.onSelect(r, index);
44015 if(doFocus !== false && !this.blockFocus){
44016 this.inputEl().focus();
44020 onViewMove : function(e, t)
44022 this.inKeyMode = false;
44025 select : function(index, scrollIntoView)
44027 this.selectedIndex = index;
44028 this.view.select(index);
44029 if(scrollIntoView !== false){
44030 var el = this.view.getNode(index);
44032 this.list.scrollChildIntoView(el, false);
44037 createList : function()
44039 this.list = Roo.get(document.body).createChild({
44041 cls: 'typeahead typeahead-long dropdown-menu tel-list',
44042 style: 'display:none'
44045 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
44048 collapseIf : function(e)
44050 var in_combo = e.within(this.el);
44051 var in_list = e.within(this.list);
44052 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
44054 if (in_combo || in_list || is_list) {
44060 onSelect : function(record, index)
44062 if(this.fireEvent('beforeselect', this, record, index) !== false){
44064 this.setFlagClass(record.data.iso2);
44065 this.setDialCode(record.data.dialCode);
44066 this.hasFocus = false;
44068 this.fireEvent('select', this, record, index);
44072 flagEl : function()
44074 var flag = this.el.select('div.flag',true).first();
44081 dialCodeHolderEl : function()
44083 var d = this.el.select('input.dial-code-holder',true).first();
44090 setDialCode : function(v)
44092 this.dialCodeHolder.dom.value = '+'+v;
44095 setFlagClass : function(n)
44097 this.flag.dom.className = 'flag '+n;
44100 getValue : function()
44102 var v = this.inputEl().getValue();
44103 if(this.dialCodeHolder) {
44104 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
44109 setValue : function(v)
44111 var d = this.getDialCode(v);
44113 //invalid dial code
44114 if(v.length == 0 || !d || d.length == 0) {
44116 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
44117 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
44123 this.setFlagClass(this.dialCodeMapping[d].iso2);
44124 this.setDialCode(d);
44125 this.inputEl().dom.value = v.replace('+'+d,'');
44126 this.hiddenEl().dom.value = this.getValue();
44131 getDialCode : function(v)
44135 if (v.length == 0) {
44136 return this.dialCodeHolder.dom.value;
44140 if (v.charAt(0) != "+") {
44143 var numericChars = "";
44144 for (var i = 1; i < v.length; i++) {
44145 var c = v.charAt(i);
44148 if (this.dialCodeMapping[numericChars]) {
44149 dialCode = v.substr(1, i);
44151 if (numericChars.length == 4) {
44161 this.setValue(this.defaultDialCode);
44165 hiddenEl : function()
44167 return this.el.select('input.hidden-tel-input',true).first();
44170 // after setting val
44171 onKeyUp : function(e){
44172 this.setValue(this.getValue());
44175 onKeyPress : function(e){
44176 if(this.allowed.indexOf(String.fromCharCode(e.getCharCode())) === -1){
44183 * @class Roo.bootstrap.MoneyField
44184 * @extends Roo.bootstrap.ComboBox
44185 * Bootstrap MoneyField class
44188 * Create a new MoneyField.
44189 * @param {Object} config Configuration options
44192 Roo.bootstrap.MoneyField = function(config) {
44194 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
44198 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
44201 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
44203 allowDecimals : true,
44205 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
44207 decimalSeparator : ".",
44209 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
44211 decimalPrecision : 0,
44213 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
44215 allowNegative : true,
44217 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
44221 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
44223 minValue : Number.NEGATIVE_INFINITY,
44225 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
44227 maxValue : Number.MAX_VALUE,
44229 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
44231 minText : "The minimum value for this field is {0}",
44233 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
44235 maxText : "The maximum value for this field is {0}",
44237 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
44238 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
44240 nanText : "{0} is not a valid number",
44242 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
44246 * @cfg {String} defaults currency of the MoneyField
44247 * value should be in lkey
44249 defaultCurrency : false,
44251 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
44253 thousandsDelimiter : false,
44255 * @cfg {Number} max_length Maximum input field length allowed (defaults to Number.MAX_VALUE)
44266 getAutoCreate : function()
44268 var align = this.labelAlign || this.parentLabelAlign();
44280 cls : 'form-control roo-money-amount-input',
44281 autocomplete: 'new-password'
44284 var hiddenInput = {
44288 cls: 'hidden-number-input'
44291 if(this.max_length) {
44292 input.maxlength = this.max_length;
44296 hiddenInput.name = this.name;
44299 if (this.disabled) {
44300 input.disabled = true;
44303 var clg = 12 - this.inputlg;
44304 var cmd = 12 - this.inputmd;
44305 var csm = 12 - this.inputsm;
44306 var cxs = 12 - this.inputxs;
44310 cls : 'row roo-money-field',
44314 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
44318 cls: 'roo-select2-container input-group',
44322 cls : 'form-control roo-money-currency-input',
44323 autocomplete: 'new-password',
44325 name : this.currencyName
44329 cls : 'input-group-addon',
44343 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
44347 cls: this.hasFeedback ? 'has-feedback' : '',
44358 if (this.fieldLabel.length) {
44361 tooltip: 'This field is required'
44367 cls: 'control-label',
44373 html: this.fieldLabel
44376 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
44382 if(this.indicatorpos == 'right') {
44383 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
44390 if(align == 'left') {
44398 if(this.labelWidth > 12){
44399 label.style = "width: " + this.labelWidth + 'px';
44401 if(this.labelWidth < 13 && this.labelmd == 0){
44402 this.labelmd = this.labelWidth;
44404 if(this.labellg > 0){
44405 label.cls += ' col-lg-' + this.labellg;
44406 input.cls += ' col-lg-' + (12 - this.labellg);
44408 if(this.labelmd > 0){
44409 label.cls += ' col-md-' + this.labelmd;
44410 container.cls += ' col-md-' + (12 - this.labelmd);
44412 if(this.labelsm > 0){
44413 label.cls += ' col-sm-' + this.labelsm;
44414 container.cls += ' col-sm-' + (12 - this.labelsm);
44416 if(this.labelxs > 0){
44417 label.cls += ' col-xs-' + this.labelxs;
44418 container.cls += ' col-xs-' + (12 - this.labelxs);
44429 var settings = this;
44431 ['xs','sm','md','lg'].map(function(size){
44432 if (settings[size]) {
44433 cfg.cls += ' col-' + size + '-' + settings[size];
44440 initEvents : function()
44442 this.indicator = this.indicatorEl();
44444 this.initCurrencyEvent();
44446 this.initNumberEvent();
44449 initCurrencyEvent : function()
44452 throw "can not find store for combo";
44455 this.store = Roo.factory(this.store, Roo.data);
44456 this.store.parent = this;
44460 this.triggerEl = this.el.select('.input-group-addon', true).first();
44462 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
44467 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
44468 _this.list.setWidth(lw);
44471 this.list.on('mouseover', this.onViewOver, this);
44472 this.list.on('mousemove', this.onViewMove, this);
44473 this.list.on('scroll', this.onViewScroll, this);
44476 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
44479 this.view = new Roo.View(this.list, this.tpl, {
44480 singleSelect:true, store: this.store, selectedClass: this.selectedClass
44483 this.view.on('click', this.onViewClick, this);
44485 this.store.on('beforeload', this.onBeforeLoad, this);
44486 this.store.on('load', this.onLoad, this);
44487 this.store.on('loadexception', this.onLoadException, this);
44489 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
44490 "up" : function(e){
44491 this.inKeyMode = true;
44495 "down" : function(e){
44496 if(!this.isExpanded()){
44497 this.onTriggerClick();
44499 this.inKeyMode = true;
44504 "enter" : function(e){
44507 if(this.fireEvent("specialkey", this, e)){
44508 this.onViewClick(false);
44514 "esc" : function(e){
44518 "tab" : function(e){
44521 if(this.fireEvent("specialkey", this, e)){
44522 this.onViewClick(false);
44530 doRelay : function(foo, bar, hname){
44531 if(hname == 'down' || this.scope.isExpanded()){
44532 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
44540 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
44544 initNumberEvent : function(e)
44546 this.inputEl().on("keydown" , this.fireKey, this);
44547 this.inputEl().on("focus", this.onFocus, this);
44548 this.inputEl().on("blur", this.onBlur, this);
44550 this.inputEl().relayEvent('keyup', this);
44552 if(this.indicator){
44553 this.indicator.addClass('invisible');
44556 this.originalValue = this.getValue();
44558 if(this.validationEvent == 'keyup'){
44559 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
44560 this.inputEl().on('keyup', this.filterValidation, this);
44562 else if(this.validationEvent !== false){
44563 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
44566 if(this.selectOnFocus){
44567 this.on("focus", this.preFocus, this);
44570 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
44571 this.inputEl().on("keypress", this.filterKeys, this);
44573 this.inputEl().relayEvent('keypress', this);
44576 var allowed = "0123456789";
44578 if(this.allowDecimals){
44579 allowed += this.decimalSeparator;
44582 if(this.allowNegative){
44586 if(this.thousandsDelimiter) {
44590 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
44592 var keyPress = function(e){
44594 var k = e.getKey();
44596 var c = e.getCharCode();
44599 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
44600 allowed.indexOf(String.fromCharCode(c)) === -1
44606 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
44610 if(allowed.indexOf(String.fromCharCode(c)) === -1){
44615 this.inputEl().on("keypress", keyPress, this);
44619 onTriggerClick : function(e)
44626 this.loadNext = false;
44628 if(this.isExpanded()){
44633 this.hasFocus = true;
44635 if(this.triggerAction == 'all') {
44636 this.doQuery(this.allQuery, true);
44640 this.doQuery(this.getRawValue());
44643 getCurrency : function()
44645 var v = this.currencyEl().getValue();
44650 restrictHeight : function()
44652 this.list.alignTo(this.currencyEl(), this.listAlign);
44653 this.list.alignTo(this.currencyEl(), this.listAlign);
44656 onViewClick : function(view, doFocus, el, e)
44658 var index = this.view.getSelectedIndexes()[0];
44660 var r = this.store.getAt(index);
44663 this.onSelect(r, index);
44667 onSelect : function(record, index){
44669 if(this.fireEvent('beforeselect', this, record, index) !== false){
44671 this.setFromCurrencyData(index > -1 ? record.data : false);
44675 this.fireEvent('select', this, record, index);
44679 setFromCurrencyData : function(o)
44683 this.lastCurrency = o;
44685 if (this.currencyField) {
44686 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
44688 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
44691 this.lastSelectionText = currency;
44693 //setting default currency
44694 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
44695 this.setCurrency(this.defaultCurrency);
44699 this.setCurrency(currency);
44702 setFromData : function(o)
44706 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
44708 this.setFromCurrencyData(c);
44713 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
44715 Roo.log('no value set for '+ (this.name ? this.name : this.id));
44718 this.setValue(value);
44722 setCurrency : function(v)
44724 this.currencyValue = v;
44727 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
44732 setValue : function(v)
44734 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
44740 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
44742 this.inputEl().dom.value = (v == '') ? '' :
44743 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
44745 if(!this.allowZero && v === '0') {
44746 this.hiddenEl().dom.value = '';
44747 this.inputEl().dom.value = '';
44754 getRawValue : function()
44756 var v = this.inputEl().getValue();
44761 getValue : function()
44763 return this.fixPrecision(this.parseValue(this.getRawValue()));
44766 parseValue : function(value)
44768 if(this.thousandsDelimiter) {
44770 r = new RegExp(",", "g");
44771 value = value.replace(r, "");
44774 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
44775 return isNaN(value) ? '' : value;
44779 fixPrecision : function(value)
44781 if(this.thousandsDelimiter) {
44783 r = new RegExp(",", "g");
44784 value = value.replace(r, "");
44787 var nan = isNaN(value);
44789 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
44790 return nan ? '' : value;
44792 return parseFloat(value).toFixed(this.decimalPrecision);
44795 decimalPrecisionFcn : function(v)
44797 return Math.floor(v);
44800 validateValue : function(value)
44802 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
44806 var num = this.parseValue(value);
44809 this.markInvalid(String.format(this.nanText, value));
44813 if(num < this.minValue){
44814 this.markInvalid(String.format(this.minText, this.minValue));
44818 if(num > this.maxValue){
44819 this.markInvalid(String.format(this.maxText, this.maxValue));
44826 validate : function()
44828 if(this.disabled || this.allowBlank){
44833 var currency = this.getCurrency();
44835 if(this.validateValue(this.getRawValue()) && currency.length){
44840 this.markInvalid();
44844 getName: function()
44849 beforeBlur : function()
44855 var v = this.parseValue(this.getRawValue());
44862 onBlur : function()
44866 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
44867 //this.el.removeClass(this.focusClass);
44870 this.hasFocus = false;
44872 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
44876 var v = this.getValue();
44878 if(String(v) !== String(this.startValue)){
44879 this.fireEvent('change', this, v, this.startValue);
44882 this.fireEvent("blur", this);
44885 inputEl : function()
44887 return this.el.select('.roo-money-amount-input', true).first();
44890 currencyEl : function()
44892 return this.el.select('.roo-money-currency-input', true).first();
44895 hiddenEl : function()
44897 return this.el.select('input.hidden-number-input',true).first();
44901 * @class Roo.bootstrap.BezierSignature
44902 * @extends Roo.bootstrap.Component
44903 * Bootstrap BezierSignature class
44904 * This script refer to:
44905 * Title: Signature Pad
44907 * Availability: https://github.com/szimek/signature_pad
44910 * Create a new BezierSignature
44911 * @param {Object} config The config object
44914 Roo.bootstrap.BezierSignature = function(config){
44915 Roo.bootstrap.BezierSignature.superclass.constructor.call(this, config);
44921 Roo.extend(Roo.bootstrap.BezierSignature, Roo.bootstrap.Component,
44928 mouse_btn_down: true,
44931 * @cfg {int} canvas height
44933 canvas_height: '200px',
44936 * @cfg {float|function} Radius of a single dot.
44941 * @cfg {float} Minimum width of a line. Defaults to 0.5.
44946 * @cfg {float} Maximum width of a line. Defaults to 2.5.
44951 * @cfg {integer} Draw the next point at most once per every x milliseconds. Set it to 0 to turn off throttling. Defaults to 16.
44956 * @cfg {integer} Add the next point only if the previous one is farther than x pixels. Defaults to 5.
44961 * @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.
44963 bg_color: 'rgba(0, 0, 0, 0)',
44966 * @cfg {string} Color used to draw the lines. Can be any color format accepted by context.fillStyle. Defaults to "black".
44968 dot_color: 'black',
44971 * @cfg {float} Weight used to modify new velocity based on the previous velocity. Defaults to 0.7.
44973 velocity_filter_weight: 0.7,
44976 * @cfg {function} Callback when stroke begin.
44981 * @cfg {function} Callback when stroke end.
44985 getAutoCreate : function()
44987 var cls = 'roo-signature column';
44990 cls += ' ' + this.cls;
45000 for(var i = 0; i < col_sizes.length; i++) {
45001 if(this[col_sizes[i]]) {
45002 cls += " col-"+col_sizes[i]+"-"+this[col_sizes[i]];
45012 cls: 'roo-signature-body',
45016 cls: 'roo-signature-body-canvas',
45017 height: this.canvas_height,
45018 width: this.canvas_width
45025 style: 'display: none'
45033 initEvents: function()
45035 Roo.bootstrap.BezierSignature.superclass.initEvents.call(this);
45037 var canvas = this.canvasEl();
45039 // mouse && touch event swapping...
45040 canvas.dom.style.touchAction = 'none';
45041 canvas.dom.style.msTouchAction = 'none';
45043 this.mouse_btn_down = false;
45044 canvas.on('mousedown', this._handleMouseDown, this);
45045 canvas.on('mousemove', this._handleMouseMove, this);
45046 Roo.select('html').first().on('mouseup', this._handleMouseUp, this);
45048 if (window.PointerEvent) {
45049 canvas.on('pointerdown', this._handleMouseDown, this);
45050 canvas.on('pointermove', this._handleMouseMove, this);
45051 Roo.select('html').first().on('pointerup', this._handleMouseUp, this);
45054 if ('ontouchstart' in window) {
45055 canvas.on('touchstart', this._handleTouchStart, this);
45056 canvas.on('touchmove', this._handleTouchMove, this);
45057 canvas.on('touchend', this._handleTouchEnd, this);
45060 Roo.EventManager.onWindowResize(this.resize, this, true);
45062 // file input event
45063 this.fileEl().on('change', this.uploadImage, this);
45070 resize: function(){
45072 var canvas = this.canvasEl().dom;
45073 var ctx = this.canvasElCtx();
45074 var img_data = false;
45076 if(canvas.width > 0) {
45077 var img_data = ctx.getImageData(0, 0, canvas.width, canvas.height);
45079 // setting canvas width will clean img data
45082 var style = window.getComputedStyle ?
45083 getComputedStyle(this.el.dom, null) : this.el.dom.currentStyle;
45085 var padding_left = parseInt(style.paddingLeft) || 0;
45086 var padding_right = parseInt(style.paddingRight) || 0;
45088 canvas.width = this.el.dom.clientWidth - padding_left - padding_right;
45091 ctx.putImageData(img_data, 0, 0);
45095 _handleMouseDown: function(e)
45097 if (e.browserEvent.which === 1) {
45098 this.mouse_btn_down = true;
45099 this.strokeBegin(e);
45103 _handleMouseMove: function (e)
45105 if (this.mouse_btn_down) {
45106 this.strokeMoveUpdate(e);
45110 _handleMouseUp: function (e)
45112 if (e.browserEvent.which === 1 && this.mouse_btn_down) {
45113 this.mouse_btn_down = false;
45118 _handleTouchStart: function (e) {
45120 e.preventDefault();
45121 if (e.browserEvent.targetTouches.length === 1) {
45122 // var touch = e.browserEvent.changedTouches[0];
45123 // this.strokeBegin(touch);
45125 this.strokeBegin(e); // assume e catching the correct xy...
45129 _handleTouchMove: function (e) {
45130 e.preventDefault();
45131 // var touch = event.targetTouches[0];
45132 // _this._strokeMoveUpdate(touch);
45133 this.strokeMoveUpdate(e);
45136 _handleTouchEnd: function (e) {
45137 var wasCanvasTouched = e.target === this.canvasEl().dom;
45138 if (wasCanvasTouched) {
45139 e.preventDefault();
45140 // var touch = event.changedTouches[0];
45141 // _this._strokeEnd(touch);
45146 reset: function () {
45147 this._lastPoints = [];
45148 this._lastVelocity = 0;
45149 this._lastWidth = (this.min_width + this.max_width) / 2;
45150 this.canvasElCtx().fillStyle = this.dot_color;
45153 strokeMoveUpdate: function(e)
45155 this.strokeUpdate(e);
45157 if (this.throttle) {
45158 this.throttleStroke(this.strokeUpdate, this.throttle);
45161 this.strokeUpdate(e);
45165 strokeBegin: function(e)
45167 var newPointGroup = {
45168 color: this.dot_color,
45172 if (typeof this.onBegin === 'function') {
45176 this.curve_data.push(newPointGroup);
45178 this.strokeUpdate(e);
45181 strokeUpdate: function(e)
45183 var rect = this.canvasEl().dom.getBoundingClientRect();
45184 var point = new this.Point(e.xy[0] - rect.left, e.xy[1] - rect.top, new Date().getTime());
45185 var lastPointGroup = this.curve_data[this.curve_data.length - 1];
45186 var lastPoints = lastPointGroup.points;
45187 var lastPoint = lastPoints.length > 0 && lastPoints[lastPoints.length - 1];
45188 var isLastPointTooClose = lastPoint
45189 ? point.distanceTo(lastPoint) <= this.min_distance
45191 var color = lastPointGroup.color;
45192 if (!lastPoint || !(lastPoint && isLastPointTooClose)) {
45193 var curve = this.addPoint(point);
45195 this.drawDot({color: color, point: point});
45198 this.drawCurve({color: color, curve: curve});
45208 strokeEnd: function(e)
45210 this.strokeUpdate(e);
45211 if (typeof this.onEnd === 'function') {
45216 addPoint: function (point) {
45217 var _lastPoints = this._lastPoints;
45218 _lastPoints.push(point);
45219 if (_lastPoints.length > 2) {
45220 if (_lastPoints.length === 3) {
45221 _lastPoints.unshift(_lastPoints[0]);
45223 var widths = this.calculateCurveWidths(_lastPoints[1], _lastPoints[2]);
45224 var curve = this.Bezier.fromPoints(_lastPoints, widths, this);
45225 _lastPoints.shift();
45231 calculateCurveWidths: function (startPoint, endPoint) {
45232 var velocity = this.velocity_filter_weight * endPoint.velocityFrom(startPoint) +
45233 (1 - this.velocity_filter_weight) * this._lastVelocity;
45235 var newWidth = Math.max(this.max_width / (velocity + 1), this.min_width);
45238 start: this._lastWidth
45241 this._lastVelocity = velocity;
45242 this._lastWidth = newWidth;
45246 drawDot: function (_a) {
45247 var color = _a.color, point = _a.point;
45248 var ctx = this.canvasElCtx();
45249 var width = typeof this.dot_size === 'function' ? this.dot_size() : this.dot_size;
45251 this.drawCurveSegment(point.x, point.y, width);
45253 ctx.fillStyle = color;
45257 drawCurve: function (_a) {
45258 var color = _a.color, curve = _a.curve;
45259 var ctx = this.canvasElCtx();
45260 var widthDelta = curve.endWidth - curve.startWidth;
45261 var drawSteps = Math.floor(curve.length()) * 2;
45263 ctx.fillStyle = color;
45264 for (var i = 0; i < drawSteps; i += 1) {
45265 var t = i / drawSteps;
45271 var x = uuu * curve.startPoint.x;
45272 x += 3 * uu * t * curve.control1.x;
45273 x += 3 * u * tt * curve.control2.x;
45274 x += ttt * curve.endPoint.x;
45275 var y = uuu * curve.startPoint.y;
45276 y += 3 * uu * t * curve.control1.y;
45277 y += 3 * u * tt * curve.control2.y;
45278 y += ttt * curve.endPoint.y;
45279 var width = curve.startWidth + ttt * widthDelta;
45280 this.drawCurveSegment(x, y, width);
45286 drawCurveSegment: function (x, y, width) {
45287 var ctx = this.canvasElCtx();
45289 ctx.arc(x, y, width, 0, 2 * Math.PI, false);
45290 this.is_empty = false;
45295 var ctx = this.canvasElCtx();
45296 var canvas = this.canvasEl().dom;
45297 ctx.fillStyle = this.bg_color;
45298 ctx.clearRect(0, 0, canvas.width, canvas.height);
45299 ctx.fillRect(0, 0, canvas.width, canvas.height);
45300 this.curve_data = [];
45302 this.is_empty = true;
45307 return this.el.select('input',true).first();
45310 canvasEl: function()
45312 return this.el.select('canvas',true).first();
45315 canvasElCtx: function()
45317 return this.el.select('canvas',true).first().dom.getContext('2d');
45320 getImage: function(type)
45322 if(this.is_empty) {
45327 return this.canvasEl().dom.toDataURL('image/'+type, 1);
45330 drawFromImage: function(img_src)
45332 var img = new Image();
45334 img.onload = function(){
45335 this.canvasElCtx().drawImage(img, 0, 0);
45340 this.is_empty = false;
45343 selectImage: function()
45345 this.fileEl().dom.click();
45348 uploadImage: function(e)
45350 var reader = new FileReader();
45352 reader.onload = function(e){
45353 var img = new Image();
45354 img.onload = function(){
45356 this.canvasElCtx().drawImage(img, 0, 0);
45358 img.src = e.target.result;
45361 reader.readAsDataURL(e.target.files[0]);
45364 // Bezier Point Constructor
45365 Point: (function () {
45366 function Point(x, y, time) {
45369 this.time = time || Date.now();
45371 Point.prototype.distanceTo = function (start) {
45372 return Math.sqrt(Math.pow(this.x - start.x, 2) + Math.pow(this.y - start.y, 2));
45374 Point.prototype.equals = function (other) {
45375 return this.x === other.x && this.y === other.y && this.time === other.time;
45377 Point.prototype.velocityFrom = function (start) {
45378 return this.time !== start.time
45379 ? this.distanceTo(start) / (this.time - start.time)
45386 // Bezier Constructor
45387 Bezier: (function () {
45388 function Bezier(startPoint, control2, control1, endPoint, startWidth, endWidth) {
45389 this.startPoint = startPoint;
45390 this.control2 = control2;
45391 this.control1 = control1;
45392 this.endPoint = endPoint;
45393 this.startWidth = startWidth;
45394 this.endWidth = endWidth;
45396 Bezier.fromPoints = function (points, widths, scope) {
45397 var c2 = this.calculateControlPoints(points[0], points[1], points[2], scope).c2;
45398 var c3 = this.calculateControlPoints(points[1], points[2], points[3], scope).c1;
45399 return new Bezier(points[1], c2, c3, points[2], widths.start, widths.end);
45401 Bezier.calculateControlPoints = function (s1, s2, s3, scope) {
45402 var dx1 = s1.x - s2.x;
45403 var dy1 = s1.y - s2.y;
45404 var dx2 = s2.x - s3.x;
45405 var dy2 = s2.y - s3.y;
45406 var m1 = { x: (s1.x + s2.x) / 2.0, y: (s1.y + s2.y) / 2.0 };
45407 var m2 = { x: (s2.x + s3.x) / 2.0, y: (s2.y + s3.y) / 2.0 };
45408 var l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
45409 var l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
45410 var dxm = m1.x - m2.x;
45411 var dym = m1.y - m2.y;
45412 var k = l2 / (l1 + l2);
45413 var cm = { x: m2.x + dxm * k, y: m2.y + dym * k };
45414 var tx = s2.x - cm.x;
45415 var ty = s2.y - cm.y;
45417 c1: new scope.Point(m1.x + tx, m1.y + ty),
45418 c2: new scope.Point(m2.x + tx, m2.y + ty)
45421 Bezier.prototype.length = function () {
45426 for (var i = 0; i <= steps; i += 1) {
45428 var cx = this.point(t, this.startPoint.x, this.control1.x, this.control2.x, this.endPoint.x);
45429 var cy = this.point(t, this.startPoint.y, this.control1.y, this.control2.y, this.endPoint.y);
45431 var xdiff = cx - px;
45432 var ydiff = cy - py;
45433 length += Math.sqrt(xdiff * xdiff + ydiff * ydiff);
45440 Bezier.prototype.point = function (t, start, c1, c2, end) {
45441 return (start * (1.0 - t) * (1.0 - t) * (1.0 - t))
45442 + (3.0 * c1 * (1.0 - t) * (1.0 - t) * t)
45443 + (3.0 * c2 * (1.0 - t) * t * t)
45444 + (end * t * t * t);
45449 throttleStroke: function(fn, wait) {
45450 if (wait === void 0) { wait = 250; }
45452 var timeout = null;
45456 var later = function () {
45457 previous = Date.now();
45459 result = fn.apply(storedContext, storedArgs);
45461 storedContext = null;
45465 return function wrapper() {
45467 for (var _i = 0; _i < arguments.length; _i++) {
45468 args[_i] = arguments[_i];
45470 var now = Date.now();
45471 var remaining = wait - (now - previous);
45472 storedContext = this;
45474 if (remaining <= 0 || remaining > wait) {
45476 clearTimeout(timeout);
45480 result = fn.apply(storedContext, storedArgs);
45482 storedContext = null;
45486 else if (!timeout) {
45487 timeout = window.setTimeout(later, remaining);