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)
99 * @cfg {String} offset
100 * The number of pixels to offset the shadow from the element (defaults to 4)
108 * Displays the shadow under the target element
109 * @param {String/HTMLElement/Element} targetEl The id or element under which the shadow should display
111 show : function(target){
112 target = Roo.get(target);
114 this.el = Roo.Shadow.Pool.pull();
115 if(this.el.dom.nextSibling != target.dom){
116 this.el.insertBefore(target);
119 this.el.setStyle("z-index", this.zIndex || parseInt(target.getStyle("z-index"), 10)-1);
121 this.el.dom.style.filter="progid:DXImageTransform.Microsoft.alpha(opacity=50) progid:DXImageTransform.Microsoft.Blur(pixelradius="+(this.offset)+")";
124 target.getLeft(true),
129 this.el.dom.style.display = "block";
133 * Returns true if the shadow is visible, else false
135 isVisible : function(){
136 return this.el ? true : false;
140 * Direct alignment when values are already available. Show must be called at least once before
141 * calling this method to ensure it is initialized.
142 * @param {Number} left The target element left position
143 * @param {Number} top The target element top position
144 * @param {Number} width The target element width
145 * @param {Number} height The target element height
147 realign : function(l, t, w, h){
151 var a = this.adjusts, d = this.el.dom, s = d.style;
153 s.left = (l+a.l)+"px";
154 s.top = (t+a.t)+"px";
155 var sw = (w+a.w), sh = (h+a.h), sws = sw +"px", shs = sh + "px";
157 if(s.width != sws || s.height != shs){
161 var cn = d.childNodes;
162 var sww = Math.max(0, (sw-12))+"px";
163 cn[0].childNodes[1].style.width = sww;
164 cn[1].childNodes[1].style.width = sww;
165 cn[2].childNodes[1].style.width = sww;
166 cn[1].style.height = Math.max(0, (sh-12))+"px";
176 this.el.dom.style.display = "none";
177 Roo.Shadow.Pool.push(this.el);
183 * Adjust the z-index of this shadow
184 * @param {Number} zindex The new z-index
186 setZIndex : function(z){
189 this.el.setStyle("z-index", z);
194 // Private utility class that manages the internal Shadow cache
195 Roo.Shadow.Pool = function(){
197 var markup = Roo.isIE ?
198 '<div class="x-ie-shadow"></div>' :
199 '<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>';
204 sh = Roo.get(Roo.DomHelper.insertHtml("beforeBegin", document.body.firstChild, markup));
205 sh.autoBoxAdjust = false;
217 * base class for bootstrap elements.
221 Roo.bootstrap = Roo.bootstrap || {};
223 * @class Roo.bootstrap.Component
224 * @extends Roo.Component
225 * Bootstrap Component base class
226 * @cfg {String} cls css class
227 * @cfg {String} style any extra css
228 * @cfg {Object} xattr extra attributes to add to 'element' (used by builder to store stuff.)
229 * @cfg {Boolean} can_build_overlaid True if element can be rebuild from a HTML page
230 * @cfg {string} dataId cutomer id
231 * @cfg {string} name Specifies name attribute
232 * @cfg {string} tooltip Text for the tooltip
233 * @cfg {string} container_method method to fetch parents container element (used by NavHeaderbar - getHeaderChildContainer)
234 * @cfg {string|object} visibilityEl (el|parent) What element to use for visibility (@see getVisibilityEl())
237 * Do not use directly - it does not do anything..
238 * @param {Object} config The config object
243 Roo.bootstrap.Component = function(config){
244 Roo.bootstrap.Component.superclass.constructor.call(this, config);
248 * @event childrenrendered
249 * Fires when the children have been rendered..
250 * @param {Roo.bootstrap.Component} this
252 "childrenrendered" : true
261 Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent, {
264 allowDomMove : false, // to stop relocations in parent onRender...
274 * Initialize Events for the element
276 initEvents : function() { },
282 can_build_overlaid : true,
284 container_method : false,
291 // returns the parent component..
292 return Roo.ComponentMgr.get(this.parentId)
298 onRender : function(ct, position)
300 // Roo.log("Call onRender: " + this.xtype);
302 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
305 if (this.el.attr('xtype')) {
306 this.el.attr('xtypex', this.el.attr('xtype'));
307 this.el.dom.removeAttribute('xtype');
317 var cfg = Roo.apply({}, this.getAutoCreate());
319 cfg.id = this.id || Roo.id();
321 // fill in the extra attributes
322 if (this.xattr && typeof(this.xattr) =='object') {
323 for (var i in this.xattr) {
324 cfg[i] = this.xattr[i];
329 cfg.dataId = this.dataId;
333 cfg.cls = (typeof(cfg.cls) == 'undefined') ? this.cls : cfg.cls + ' ' + this.cls;
336 if (this.style) { // fixme needs to support more complex style data.
337 cfg.style = this.style;
341 cfg.name = this.name;
344 this.el = ct.createChild(cfg, position);
347 this.tooltipEl().attr('tooltip', this.tooltip);
350 if(this.tabIndex !== undefined){
351 this.el.dom.setAttribute('tabIndex', this.tabIndex);
358 * Fetch the element to add children to
359 * @return {Roo.Element} defaults to this.el
361 getChildContainer : function()
366 * Fetch the element to display the tooltip on.
367 * @return {Roo.Element} defaults to this.el
369 tooltipEl : function()
374 addxtype : function(tree,cntr)
378 cn = Roo.factory(tree);
379 //Roo.log(['addxtype', cn]);
381 cn.parentType = this.xtype; //??
382 cn.parentId = this.id;
384 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
385 if (typeof(cn.container_method) == 'string') {
386 cntr = cn.container_method;
390 var has_flexy_each = (typeof(tree['flexy:foreach']) != 'undefined');
392 var has_flexy_if = (typeof(tree['flexy:if']) != 'undefined');
394 var build_from_html = Roo.XComponent.build_from_html;
396 var is_body = (tree.xtype == 'Body') ;
398 var page_has_body = (Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body');
400 var self_cntr_el = Roo.get(this[cntr](false));
402 // do not try and build conditional elements
403 if ((has_flexy_each || has_flexy_if || this.can_build_overlaid == false ) && build_from_html) {
407 if (!has_flexy_each || !build_from_html || is_body || !page_has_body) {
408 if(!has_flexy_if || typeof(tree.name) == 'undefined' || !build_from_html || is_body || !page_has_body){
409 return this.addxtypeChild(tree,cntr, is_body);
412 var echild =self_cntr_el ? self_cntr_el.child('>*[name=' + tree.name + ']') : false;
415 return this.addxtypeChild(Roo.apply({}, tree),cntr);
418 Roo.log('skipping render');
424 if (!build_from_html) {
428 // this i think handles overlaying multiple children of the same type
429 // with the sam eelement.. - which might be buggy..
431 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
437 if (echild && echild.attr('xtype').split('.').pop() != cn.xtype) {
441 ret = this.addxtypeChild(Roo.apply({}, tree),cntr);
448 addxtypeChild : function (tree, cntr, is_body)
450 Roo.debug && Roo.log('addxtypeChild:' + cntr);
452 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
455 var has_flexy = (typeof(tree['flexy:if']) != 'undefined') ||
456 (typeof(tree['flexy:foreach']) != 'undefined');
460 skip_children = false;
461 // render the element if it's not BODY.
464 // if parent was disabled, then do not try and create the children..
465 if(!this[cntr](true)){
470 cn = Roo.factory(tree);
472 cn.parentType = this.xtype; //??
473 cn.parentId = this.id;
475 var build_from_html = Roo.XComponent.build_from_html;
478 // does the container contain child eleemnts with 'xtype' attributes.
479 // that match this xtype..
480 // note - when we render we create these as well..
481 // so we should check to see if body has xtype set.
482 if (build_from_html && Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body') {
484 var self_cntr_el = Roo.get(this[cntr](false));
485 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
487 //Roo.log(Roo.XComponent.build_from_html);
488 //Roo.log("got echild:");
491 // there is a scenario where some of the child elements are flexy:if (and all of the same type)
492 // and are not displayed -this causes this to use up the wrong element when matching.
493 // at present the only work around for this is to nest flexy:if elements in another element that is always rendered.
496 if (echild && echild.attr('xtype').split('.').pop() == cn.xtype) {
497 // Roo.log("found child for " + this.xtype +": " + echild.attr('xtype') );
503 //echild.dom.removeAttribute('xtype');
505 Roo.debug && Roo.log("MISSING " + cn.xtype + " on child of " + (this.el ? this.el.attr('xbuilderid') : 'no parent'));
506 Roo.debug && Roo.log(self_cntr_el);
507 Roo.debug && Roo.log(echild);
508 Roo.debug && Roo.log(cn);
514 // if object has flexy:if - then it may or may not be rendered.
515 if (build_from_html && has_flexy && !cn.el && cn.can_build_overlaid) {
516 // skip a flexy if element.
517 Roo.debug && Roo.log('skipping render');
518 Roo.debug && Roo.log(tree);
520 Roo.debug && Roo.log('skipping all children');
521 skip_children = true;
526 // actually if flexy:foreach is found, we really want to create
527 // multiple copies here...
529 //Roo.log(this[cntr]());
530 // some elements do not have render methods.. like the layouts...
532 if(this[cntr](true) === false){
537 cn.render && cn.render(this[cntr](true));
540 // then add the element..
547 if (typeof (tree.menu) != 'undefined') {
548 tree.menu.parentType = cn.xtype;
549 tree.menu.triggerEl = cn.el;
550 nitems.push(cn.addxtype(Roo.apply({}, tree.menu)));
554 if (!tree.items || !tree.items.length) {
556 //Roo.log(["no children", this]);
561 var items = tree.items;
564 //Roo.log(items.length);
566 if (!skip_children) {
567 for(var i =0;i < items.length;i++) {
568 // Roo.log(['add child', items[i]]);
569 nitems.push(cn.addxtype(Roo.apply({}, items[i])));
575 //Roo.log("fire childrenrendered");
577 cn.fireEvent('childrenrendered', this);
583 * Set the element that will be used to show or hide
585 setVisibilityEl : function(el)
587 this.visibilityEl = el;
591 * Get the element that will be used to show or hide
593 getVisibilityEl : function()
595 if (typeof(this.visibilityEl) == 'object') {
596 return this.visibilityEl;
599 if (typeof(this.visibilityEl) == 'string') {
600 return this.visibilityEl == 'parent' ? this.parent().getEl() : this.getEl();
607 * Show a component - removes 'hidden' class
611 if(!this.getVisibilityEl()){
615 this.getVisibilityEl().removeClass(['hidden','d-none']);
617 this.fireEvent('show', this);
622 * Hide a component - adds 'hidden' class
626 if(!this.getVisibilityEl()){
630 this.getVisibilityEl().addClass(['hidden','d-none']);
632 this.fireEvent('hide', this);
645 * @class Roo.bootstrap.Element
646 * @extends Roo.bootstrap.Component
647 * Bootstrap Element class
648 * @cfg {String} html contents of the element
649 * @cfg {String} tag tag of the element
650 * @cfg {String} cls class of the element
651 * @cfg {Boolean} preventDefault (true|false) default false
652 * @cfg {Boolean} clickable (true|false) default false
655 * Create a new Element
656 * @param {Object} config The config object
659 Roo.bootstrap.Element = function(config){
660 Roo.bootstrap.Element.superclass.constructor.call(this, config);
666 * When a element is chick
667 * @param {Roo.bootstrap.Element} this
668 * @param {Roo.EventObject} e
674 Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, {
679 preventDefault: false,
682 getAutoCreate : function(){
686 // cls: this.cls, double assign in parent class Component.js :: onRender
693 initEvents: function()
695 Roo.bootstrap.Element.superclass.initEvents.call(this);
698 this.el.on('click', this.onClick, this);
703 onClick : function(e)
705 if(this.preventDefault){
709 this.fireEvent('click', this, e);
712 getValue : function()
714 return this.el.dom.innerHTML;
717 setValue : function(value)
719 this.el.dom.innerHTML = value;
734 * @class Roo.bootstrap.DropTarget
735 * @extends Roo.bootstrap.Element
736 * Bootstrap DropTarget class
738 * @cfg {string} name dropable name
741 * Create a new Dropable Area
742 * @param {Object} config The config object
745 Roo.bootstrap.DropTarget = function(config){
746 Roo.bootstrap.DropTarget.superclass.constructor.call(this, config);
752 * When a element is chick
753 * @param {Roo.bootstrap.Element} this
754 * @param {Roo.EventObject} e
760 Roo.extend(Roo.bootstrap.DropTarget, Roo.bootstrap.Element, {
763 getAutoCreate : function(){
768 initEvents: function()
770 Roo.bootstrap.DropTarget.superclass.initEvents.call(this);
771 this.dropZone = new Roo.dd.DropTarget(this.getEl(), {
774 drop : this.dragDrop.createDelegate(this),
775 enter : this.dragEnter.createDelegate(this),
776 out : this.dragOut.createDelegate(this),
777 over : this.dragOver.createDelegate(this)
781 this.dropZone.DDM.useCache = false // so data gets refreshed when we resize stuff
784 dragDrop : function(source,e,data)
786 // user has to decide how to impliment this.
789 //this.fireEvent('drop', this, source, e ,data);
793 dragEnter : function(n, dd, e, data)
795 // probably want to resize the element to match the dropped element..
797 this.originalSize = this.el.getSize();
798 this.el.setSize( n.el.getSize());
799 this.dropZone.DDM.refreshCache(this.name);
800 Roo.log([n, dd, e, data]);
803 dragOut : function(value)
805 // resize back to normal
807 this.el.setSize(this.originalSize);
808 this.dropZone.resetConstraints();
811 dragOver : function()
828 * @class Roo.bootstrap.Body
829 * @extends Roo.bootstrap.Component
830 * Bootstrap Body class
834 * @param {Object} config The config object
837 Roo.bootstrap.Body = function(config){
839 config = config || {};
841 Roo.bootstrap.Body.superclass.constructor.call(this, config);
842 this.el = Roo.get(config.el ? config.el : document.body );
843 if (this.cls && this.cls.length) {
844 Roo.get(document.body).addClass(this.cls);
848 Roo.extend(Roo.bootstrap.Body, Roo.bootstrap.Component, {
850 is_body : true,// just to make sure it's constructed?
855 onRender : function(ct, position)
857 /* Roo.log("Roo.bootstrap.Body - onRender");
858 if (this.cls && this.cls.length) {
859 Roo.get(document.body).addClass(this.cls);
878 * @class Roo.bootstrap.ButtonGroup
879 * @extends Roo.bootstrap.Component
880 * Bootstrap ButtonGroup class
881 * @cfg {String} size lg | sm | xs (default empty normal)
882 * @cfg {String} align vertical | justified (default none)
883 * @cfg {String} direction up | down (default down)
884 * @cfg {Boolean} toolbar false | true
885 * @cfg {Boolean} btn true | false
890 * @param {Object} config The config object
893 Roo.bootstrap.ButtonGroup = function(config){
894 Roo.bootstrap.ButtonGroup.superclass.constructor.call(this, config);
897 Roo.extend(Roo.bootstrap.ButtonGroup, Roo.bootstrap.Component, {
905 getAutoCreate : function(){
911 cfg.html = this.html || cfg.html;
922 if (['vertical','justified'].indexOf(this.align)!==-1) {
923 cfg.cls = 'btn-group-' + this.align;
925 if (this.align == 'justified') {
926 console.log(this.items);
930 if (['lg','sm','xs'].indexOf(this.size)!==-1) {
931 cfg.cls += ' btn-group-' + this.size;
934 if (this.direction == 'up') {
935 cfg.cls += ' dropup' ;
941 * Add a button to the group (similar to NavItem API.)
943 addItem : function(cfg)
945 var cn = new Roo.bootstrap.Button(cfg);
947 cn.parentId = this.id;
948 cn.onRender(this.el, null);
962 * @class Roo.bootstrap.Button
963 * @extends Roo.bootstrap.Component
964 * Bootstrap Button class
965 * @cfg {String} html The button content
966 * @cfg {String} weight (default|primary|secondary|success|info|warning|danger|link|light|dark) default
967 * @cfg {String} badge_weight (default|primary|secondary|success|info|warning|danger|link|light|dark) default (same as button)
968 * @cfg {Boolean} outline default false (except for weight=default which emulates old behaveiour with an outline)
969 * @cfg {String} size (lg|sm|xs)
970 * @cfg {String} tag (a|input|submit)
971 * @cfg {String} href empty or href
972 * @cfg {Boolean} disabled default false;
973 * @cfg {Boolean} isClose default false;
974 * @cfg {String} glyphicon depricated - use fa
975 * @cfg {String} fa fontawesome icon - eg. 'comment' - without the fa/fas etc..
976 * @cfg {String} badge text for badge
977 * @cfg {String} theme (default|glow)
978 * @cfg {Boolean} inverse dark themed version
979 * @cfg {Boolean} toggle is it a slidy toggle button
980 * @cfg {Boolean} pressed default null - if the button ahs active state
981 * @cfg {String} ontext text for on slidy toggle state
982 * @cfg {String} offtext text for off slidy toggle state
983 * @cfg {Boolean} preventDefault default true (stop click event triggering the URL if it's a link.)
984 * @cfg {Boolean} removeClass remove the standard class..
985 * @cfg {String} target (_self|_blank|_parent|_top|other) target for a href.
986 * @cfg {Boolean} grpup if parent is a btn group - then it turns it into a toogleGroup.
989 * Create a new button
990 * @param {Object} config The config object
994 Roo.bootstrap.Button = function(config){
995 Roo.bootstrap.Button.superclass.constructor.call(this, config);
1001 * When a button is pressed
1002 * @param {Roo.bootstrap.Button} btn
1003 * @param {Roo.EventObject} e
1008 * When a button is double clicked
1009 * @param {Roo.bootstrap.Button} btn
1010 * @param {Roo.EventObject} e
1015 * After the button has been toggles
1016 * @param {Roo.bootstrap.Button} btn
1017 * @param {Roo.EventObject} e
1018 * @param {boolean} pressed (also available as button.pressed)
1024 Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, {
1045 preventDefault: true,
1054 getAutoCreate : function(){
1062 if (['a', 'button', 'input', 'submit'].indexOf(this.tag) < 0) {
1063 throw "Invalid value for tag: " + this.tag + ". must be a, button, input or submit.";
1064 this.tag = 'button';
1068 cfg.html = '<span class="roo-button-text">' + (this.html || cfg.html) + '</span>';
1070 if (this.toggle == true) {
1073 cls: 'slider-frame roo-button',
1077 'data-on-text':'ON',
1078 'data-off-text':'OFF',
1079 cls: 'slider-button',
1084 // why are we validating the weights?
1085 if (Roo.bootstrap.Button.weights.indexOf(this.weight) > -1) {
1086 cfg.cls += ' ' + this.weight;
1093 cfg.cls += ' close';
1095 cfg["aria-hidden"] = true;
1097 cfg.html = "×";
1103 if (this.theme==='default') {
1104 cfg.cls = 'btn roo-button';
1106 //if (this.parentType != 'Navbar') {
1107 this.weight = this.weight.length ? this.weight : 'default';
1109 if (Roo.bootstrap.Button.weights.indexOf(this.weight) > -1) {
1111 var outline = this.outline || this.weight == 'default' ? 'outline-' : '';
1112 var weight = this.weight == 'default' ? 'secondary' : this.weight;
1113 cfg.cls += ' btn-' + outline + weight;
1114 if (this.weight == 'default') {
1116 cfg.cls += ' btn-' + this.weight;
1119 } else if (this.theme==='glow') {
1122 cfg.cls = 'btn-glow roo-button';
1124 if (Roo.bootstrap.Button.weights.indexOf(this.weight) > -1) {
1126 cfg.cls += ' ' + this.weight;
1132 this.cls += ' inverse';
1136 if (this.active || this.pressed === true) {
1137 cfg.cls += ' active';
1140 if (this.disabled) {
1141 cfg.disabled = 'disabled';
1145 Roo.log('changing to ul' );
1147 this.glyphicon = 'caret';
1148 if (Roo.bootstrap.version == 4) {
1149 this.fa = 'caret-down';
1154 cfg.cls += this.size.length ? (' btn-' + this.size) : '';
1156 //gsRoo.log(this.parentType);
1157 if (this.parentType === 'Navbar' && !this.parent().bar) {
1158 Roo.log('changing to li?');
1167 href : this.href || '#'
1170 cfg.cn[0].html = this.html + ' <span class="caret"></span>';
1171 cfg.cls += ' dropdown';
1178 cfg.cls += this.parentType === 'Navbar' ? ' navbar-btn' : '';
1180 if (this.glyphicon) {
1181 cfg.html = ' ' + cfg.html;
1186 cls: 'glyphicon glyphicon-' + this.glyphicon
1191 cfg.html = ' ' + cfg.html;
1196 cls: 'fa fas fa-' + this.fa
1206 // cfg.cls='btn roo-button';
1210 var value = cfg.html;
1215 cls: 'glyphicon glyphicon-' + this.glyphicon,
1222 cls: 'fa fas fa-' + this.fa,
1227 var bw = this.badge_weight.length ? this.badge_weight :
1228 (this.weight.length ? this.weight : 'secondary');
1229 bw = bw == 'default' ? 'secondary' : bw;
1235 cls: 'badge badge-' + bw,
1244 cfg.cls += ' dropdown';
1245 cfg.html = typeof(cfg.html) != 'undefined' ?
1246 cfg.html + ' <span class="caret"></span>' : '<span class="caret"></span>';
1249 if (cfg.tag !== 'a' && this.href !== '') {
1250 throw "Tag must be a to set href.";
1251 } else if (this.href.length > 0) {
1252 cfg.href = this.href;
1255 if(this.removeClass){
1260 cfg.target = this.target;
1265 initEvents: function() {
1266 // Roo.log('init events?');
1267 // Roo.log(this.el.dom);
1270 if (typeof (this.menu) != 'undefined') {
1271 this.menu.parentType = this.xtype;
1272 this.menu.triggerEl = this.el;
1273 this.addxtype(Roo.apply({}, this.menu));
1277 if (this.el.hasClass('roo-button')) {
1278 this.el.on('click', this.onClick, this);
1279 this.el.on('dblclick', this.onDblClick, this);
1281 this.el.select('.roo-button').on('click', this.onClick, this);
1282 this.el.select('.roo-button').on('dblclick', this.onDblClick, this);
1286 if(this.removeClass){
1287 this.el.on('click', this.onClick, this);
1290 if (this.group === true) {
1291 if (this.pressed === false || this.pressed === true) {
1294 this.pressed = false;
1295 this.setActive(this.pressed);
1300 this.el.enableDisplayMode();
1303 onClick : function(e)
1305 if (this.disabled) {
1309 Roo.log('button on click ');
1310 if(this.preventDefault){
1319 this.setActive(true);
1320 var pi = this.parent().items;
1321 for (var i = 0;i < pi.length;i++) {
1322 if (this == pi[i]) {
1325 if (pi[i].el.hasClass('roo-button')) {
1326 pi[i].setActive(false);
1329 this.fireEvent('click', this, e);
1333 if (this.pressed === true || this.pressed === false) {
1334 this.toggleActive(e);
1338 this.fireEvent('click', this, e);
1340 onDblClick: function(e)
1342 if (this.disabled) {
1345 if(this.preventDefault){
1348 this.fireEvent('dblclick', this, e);
1351 * Enables this button
1355 this.disabled = false;
1356 this.el.removeClass('disabled');
1360 * Disable this button
1362 disable : function()
1364 this.disabled = true;
1365 this.el.addClass('disabled');
1368 * sets the active state on/off,
1369 * @param {Boolean} state (optional) Force a particular state
1371 setActive : function(v) {
1373 this.el[v ? 'addClass' : 'removeClass']('active');
1377 * toggles the current active state
1379 toggleActive : function(e)
1381 this.setActive(!this.pressed); // this modifies pressed...
1382 this.fireEvent('toggle', this, e, this.pressed);
1385 * get the current active state
1386 * @return {boolean} true if it's active
1388 isActive : function()
1390 return this.el.hasClass('active');
1393 * set the text of the first selected button
1395 setText : function(str)
1397 this.el.select('.roo-button-text',true).first().dom.innerHTML = str;
1400 * get the text of the first selected button
1402 getText : function()
1404 return this.el.select('.roo-button-text',true).first().dom.innerHTML;
1407 setWeight : function(str)
1409 this.el.removeClass(Roo.bootstrap.Button.weights.map(function(w) { return 'btn-' + w; } ) );
1410 this.el.removeClass(Roo.bootstrap.Button.weights.map(function(w) { return 'btn-outline-' + w; } ) );
1412 var outline = this.outline ? 'outline-' : '';
1413 if (str == 'default') {
1414 this.el.addClass('btn-default btn-outline-secondary');
1417 this.el.addClass('btn-' + outline + str);
1422 // fixme - this is probably generic bootstrap - should go in some kind of enum file.. - like sizes.
1424 Roo.bootstrap.Button.weights = [
1444 * @class Roo.bootstrap.Column
1445 * @extends Roo.bootstrap.Component
1446 * Bootstrap Column class
1447 * @cfg {Number} xs colspan out of 12 for mobile-sized screens or 0 for hidden
1448 * @cfg {Number} sm colspan out of 12 for tablet-sized screens or 0 for hidden
1449 * @cfg {Number} md colspan out of 12 for computer-sized screens or 0 for hidden
1450 * @cfg {Number} lg colspan out of 12 for large computer-sized screens or 0 for hidden
1451 * @cfg {Number} xsoff colspan offset out of 12 for mobile-sized screens or 0 for hidden
1452 * @cfg {Number} smoff colspan offset out of 12 for tablet-sized screens or 0 for hidden
1453 * @cfg {Number} mdoff colspan offset out of 12 for computer-sized screens or 0 for hidden
1454 * @cfg {Number} lgoff colspan offset out of 12 for large computer-sized screens or 0 for hidden
1457 * @cfg {Boolean} hidden (true|false) hide the element
1458 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1459 * @cfg {String} fa (ban|check|...) font awesome icon
1460 * @cfg {Number} fasize (1|2|....) font awsome size
1462 * @cfg {String} icon (info-sign|check|...) glyphicon name
1464 * @cfg {String} html content of column.
1467 * Create a new Column
1468 * @param {Object} config The config object
1471 Roo.bootstrap.Column = function(config){
1472 Roo.bootstrap.Column.superclass.constructor.call(this, config);
1475 Roo.extend(Roo.bootstrap.Column, Roo.bootstrap.Component, {
1493 getAutoCreate : function(){
1494 var cfg = Roo.apply({}, Roo.bootstrap.Column.superclass.getAutoCreate.call(this));
1502 var sizes = ['xs','sm','md','lg'];
1503 sizes.map(function(size ,ix){
1504 //Roo.log( size + ':' + settings[size]);
1506 if (settings[size+'off'] !== false) {
1507 cfg.cls += ' col-' + size + '-offset-' + settings[size+'off'] ;
1510 if (settings[size] === false) {
1514 if (!settings[size]) { // 0 = hidden
1515 cfg.cls += ' hidden-' + size + ' hidden-' + size + '-down';
1517 for (var i = ix; i > -1; i--) {
1518 cfg.cls += ' d-' + sizes[i] + '-none';
1524 cfg.cls += ' col-' + size + '-' + settings[size] + (
1525 size == 'xs' ? (' col-' + settings[size] ) : '' // bs4 col-{num} replaces col-xs
1531 cfg.cls += ' hidden';
1534 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1535 cfg.cls +=' alert alert-' + this.alert;
1539 if (this.html.length) {
1540 cfg.html = this.html;
1544 if (this.fasize > 1) {
1545 fasize = ' fa-' + this.fasize + 'x';
1547 cfg.html = '<i class="fa fa-'+this.fa + fasize + '"></i>' + (cfg.html || '');
1552 cfg.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + (cfg.html || '');
1571 * @class Roo.bootstrap.Container
1572 * @extends Roo.bootstrap.Component
1573 * Bootstrap Container class
1574 * @cfg {Boolean} jumbotron is it a jumbotron element
1575 * @cfg {String} html content of element
1576 * @cfg {String} well (lg|sm|md) a well, large, small or medium.
1577 * @cfg {String} panel (default|primary|success|info|warning|danger) render as panel - type - primary/success.....
1578 * @cfg {String} header content of header (for panel)
1579 * @cfg {String} footer content of footer (for panel)
1580 * @cfg {String} sticky (footer|wrap|push) block to use as footer or body- needs css-bootstrap/sticky-footer.css
1581 * @cfg {String} tag (header|aside|section) type of HTML tag.
1582 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1583 * @cfg {String} fa font awesome icon
1584 * @cfg {String} icon (info-sign|check|...) glyphicon name
1585 * @cfg {Boolean} hidden (true|false) hide the element
1586 * @cfg {Boolean} expandable (true|false) default false
1587 * @cfg {Boolean} expanded (true|false) default true
1588 * @cfg {String} rheader contet on the right of header
1589 * @cfg {Boolean} clickable (true|false) default false
1593 * Create a new Container
1594 * @param {Object} config The config object
1597 Roo.bootstrap.Container = function(config){
1598 Roo.bootstrap.Container.superclass.constructor.call(this, config);
1604 * After the panel has been expand
1606 * @param {Roo.bootstrap.Container} this
1611 * After the panel has been collapsed
1613 * @param {Roo.bootstrap.Container} this
1618 * When a element is chick
1619 * @param {Roo.bootstrap.Container} this
1620 * @param {Roo.EventObject} e
1626 Roo.extend(Roo.bootstrap.Container, Roo.bootstrap.Component, {
1644 getChildContainer : function() {
1650 if (this.panel.length) {
1651 return this.el.select('.panel-body',true).first();
1658 getAutoCreate : function(){
1661 tag : this.tag || 'div',
1665 if (this.jumbotron) {
1666 cfg.cls = 'jumbotron';
1671 // - this is applied by the parent..
1673 // cfg.cls = this.cls + '';
1676 if (this.sticky.length) {
1678 var bd = Roo.get(document.body);
1679 if (!bd.hasClass('bootstrap-sticky')) {
1680 bd.addClass('bootstrap-sticky');
1681 Roo.select('html',true).setStyle('height', '100%');
1684 cfg.cls += 'bootstrap-sticky-' + this.sticky;
1688 if (this.well.length) {
1689 switch (this.well) {
1692 cfg.cls +=' well well-' +this.well;
1701 cfg.cls += ' hidden';
1705 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1706 cfg.cls +=' alert alert-' + this.alert;
1711 if (this.panel.length) {
1712 cfg.cls += ' panel panel-' + this.panel;
1714 if (this.header.length) {
1718 if(this.expandable){
1720 cfg.cls = cfg.cls + ' expandable';
1724 cls: (this.expanded ? 'fa fa-minus' : 'fa fa-plus')
1732 cls : 'panel-title',
1733 html : (this.expandable ? ' ' : '') + this.header
1737 cls: 'panel-header-right',
1743 cls : 'panel-heading',
1744 style : this.expandable ? 'cursor: pointer' : '',
1752 cls : 'panel-body' + (this.expanded ? '' : ' hide'),
1757 if (this.footer.length) {
1759 cls : 'panel-footer',
1768 body.html = this.html || cfg.html;
1769 // prefix with the icons..
1771 body.html = '<i class="fa fa-'+this.fa + '"></i>' + body.html ;
1774 body.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + body.html ;
1779 if ((!this.cls || !this.cls.length) && (!cfg.cls || !cfg.cls.length)) {
1780 cfg.cls = 'container';
1786 initEvents: function()
1788 if(this.expandable){
1789 var headerEl = this.headerEl();
1792 headerEl.on('click', this.onToggleClick, this);
1797 this.el.on('click', this.onClick, this);
1802 onToggleClick : function()
1804 var headerEl = this.headerEl();
1820 if(this.fireEvent('expand', this)) {
1822 this.expanded = true;
1824 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).show();
1826 this.el.select('.panel-body',true).first().removeClass('hide');
1828 var toggleEl = this.toggleEl();
1834 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-minus']);
1839 collapse : function()
1841 if(this.fireEvent('collapse', this)) {
1843 this.expanded = false;
1845 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).hide();
1846 this.el.select('.panel-body',true).first().addClass('hide');
1848 var toggleEl = this.toggleEl();
1854 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-plus']);
1858 toggleEl : function()
1860 if(!this.el || !this.panel.length || !this.header.length || !this.expandable){
1864 return this.el.select('.panel-heading .fa',true).first();
1867 headerEl : function()
1869 if(!this.el || !this.panel.length || !this.header.length){
1873 return this.el.select('.panel-heading',true).first()
1878 if(!this.el || !this.panel.length){
1882 return this.el.select('.panel-body',true).first()
1885 titleEl : function()
1887 if(!this.el || !this.panel.length || !this.header.length){
1891 return this.el.select('.panel-title',true).first();
1894 setTitle : function(v)
1896 var titleEl = this.titleEl();
1902 titleEl.dom.innerHTML = v;
1905 getTitle : function()
1908 var titleEl = this.titleEl();
1914 return titleEl.dom.innerHTML;
1917 setRightTitle : function(v)
1919 var t = this.el.select('.panel-header-right',true).first();
1925 t.dom.innerHTML = v;
1928 onClick : function(e)
1932 this.fireEvent('click', this, e);
1939 * This is BS4's Card element.. - similar to our containers probably..
1943 * @class Roo.bootstrap.Card
1944 * @extends Roo.bootstrap.Component
1945 * Bootstrap Card class
1948 * possible... may not be implemented..
1949 * @cfg {String} header_image src url of image.
1950 * @cfg {String|Object} header
1951 * @cfg {Number} header_size (0|1|2|3|4|5) H1 or H2 etc.. 0 indicates default
1952 * @cfg {Number} header_weight (primary|secondary|success|info|warning|danger|light|dark)
1954 * @cfg {String} title
1955 * @cfg {String} subtitle
1956 * @cfg {String|Boolean} html -- html contents - or just use children.. use false to hide it..
1957 * @cfg {String} footer
1959 * @cfg {String} weight (primary|warning|info|danger|secondary|success|light|dark)
1961 * @cfg {String} margin (0|1|2|3|4|5|auto)
1962 * @cfg {String} margin_top (0|1|2|3|4|5|auto)
1963 * @cfg {String} margin_bottom (0|1|2|3|4|5|auto)
1964 * @cfg {String} margin_left (0|1|2|3|4|5|auto)
1965 * @cfg {String} margin_right (0|1|2|3|4|5|auto)
1966 * @cfg {String} margin_x (0|1|2|3|4|5|auto)
1967 * @cfg {String} margin_y (0|1|2|3|4|5|auto)
1969 * @cfg {String} padding (0|1|2|3|4|5)
1970 * @cfg {String} padding_top (0|1|2|3|4|5)next_to_card
1971 * @cfg {String} padding_bottom (0|1|2|3|4|5)
1972 * @cfg {String} padding_left (0|1|2|3|4|5)
1973 * @cfg {String} padding_right (0|1|2|3|4|5)
1974 * @cfg {String} padding_x (0|1|2|3|4|5)
1975 * @cfg {String} padding_y (0|1|2|3|4|5)
1977 * @cfg {String} display (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
1978 * @cfg {String} display_xs (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
1979 * @cfg {String} display_sm (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
1980 * @cfg {String} display_lg (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
1981 * @cfg {String} display_xl (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
1983 * @config {Boolean} dragable if this card can be dragged.
1984 * @config {String} drag_group group for drag
1985 * @config {Boolean} dropable if this card can recieve other cards being dropped onto it..
1986 * @config {String} drop_group group for drag
1988 * @config {Boolean} collapsable can the body be collapsed.
1989 * @config {Boolean} collapsed is the body collapsed when rendered...
1990 * @config {Boolean} rotateable can the body be rotated by clicking on it..
1991 * @config {Boolean} rotated is the body rotated when rendered...
1994 * Create a new Container
1995 * @param {Object} config The config object
1998 Roo.bootstrap.Card = function(config){
1999 Roo.bootstrap.Card.superclass.constructor.call(this, config);
2005 * When a element a card is dropped
2006 * @param {Roo.bootstrap.Card} this
2009 * @param {Roo.bootstrap.Card} move_card the card being dropped?
2010 * @param {String} position 'above' or 'below'
2011 * @param {Roo.bootstrap.Card} next_to_card What card position is relative to of 'false' for empty list.
2017 * When a element a card is rotate
2018 * @param {Roo.bootstrap.Element} this
2019 * @param {Roo.Element} n the node being dropped?
2020 * @param {Boolean} rotate status
2028 Roo.extend(Roo.bootstrap.Card, Roo.bootstrap.Component, {
2033 margin: '', /// may be better in component?
2063 collapsable : false,
2072 childContainer : false,
2073 dropEl : false, /// the dom placeholde element that indicates drop location.
2074 containerEl: false, // body container
2075 bodyEl: false, // card-body
2076 headerContainerEl : false, //
2079 layoutCls : function()
2083 Roo.log(this.margin_bottom.length);
2084 ['', 'top', 'bottom', 'left', 'right', 'x', 'y' ].forEach(function(v) {
2085 // in theory these can do margin_top : ml-xs-3 ??? but we don't support that yet
2087 if (('' + t['margin' + (v.length ? '_' : '') + v]).length) {
2088 cls += ' m' + (v.length ? v[0] : '') + '-' + t['margin' + (v.length ? '_' : '') + v];
2090 if (('' + t['padding' + (v.length ? '_' : '') + v]).length) {
2091 cls += ' p' + (v.length ? v[0] : '') + '-' + t['padding' + (v.length ? '_' : '') + v];
2095 ['', 'xs', 'sm', 'lg', 'xl'].forEach(function(v) {
2096 if (('' + t['display' + (v.length ? '_' : '') + v]).length) {
2097 cls += ' d' + (v.length ? '-' : '') + v + '-' + t['display' + (v.length ? '_' : '') + v]
2101 // more generic support?
2109 // Roo.log("Call onRender: " + this.xtype);
2110 /* We are looking at something like this.
2112 <img src="..." class="card-img-top" alt="...">
2113 <div class="card-body">
2114 <h5 class="card-title">Card title</h5>
2115 <h6 class="card-subtitle mb-2 text-muted">Card subtitle</h6>
2117 >> this bit is really the body...
2118 <div> << we will ad dthis in hopefully it will not break shit.
2120 ** card text does not actually have any styling...
2122 <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>
2125 <a href="#" class="card-link">Card link</a>
2128 <div class="card-footer">
2129 <small class="text-muted">Last updated 3 mins ago</small>
2133 getAutoCreate : function(){
2141 if (this.weight.length && this.weight != 'light') {
2142 cfg.cls += ' text-white';
2144 cfg.cls += ' text-dark'; // need as it's nested..
2146 if (this.weight.length) {
2147 cfg.cls += ' bg-' + this.weight;
2150 cfg.cls += ' ' + this.layoutCls();
2153 var hdr_ctr = false;
2154 if (this.header.length) {
2156 tag : this.header_size > 0 ? 'h' + this.header_size : 'div',
2157 cls : 'card-header ' + (this.header_weight ? 'bg-' + this.header_weight : ''),
2165 cls : 'card-header d-none ' + (this.header_weight ? 'bg-' + this.header_weight : ''),
2171 if (this.collapsable) {
2174 cls : 'd-block user-select-none',
2178 cls : 'roo-collapse-toggle fa fa-chevron-down float-right ' + (this.collapsed ? 'collapsed' : '')
2183 hdr.cn.push(hdr_ctr);
2188 cls: 'roo-card-header-ctr' + ( this.header.length ? '' : ' d-none'),
2193 if (this.header_image.length) {
2196 cls : 'card-img-top',
2197 src: this.header_image // escape?
2202 cls : 'card-img-top d-none'
2208 cls : 'card-body' + (this.html === false ? ' d-none' : ''),
2212 if (this.collapsable || this.rotateable) {
2215 cls : 'roo-collapsable collapse ' + (this.collapsed || this.rotated ? '' : 'show'),
2222 if (this.title.length) {
2226 src: this.title // escape?
2230 if (this.subtitle.length) {
2234 src: this.subtitle // escape?
2240 cls : 'roo-card-body-ctr'
2243 if (this.html.length) {
2249 // fixme ? handle objects?
2251 if (this.footer.length) {
2254 cls : 'card-footer ' + (this.rotated ? 'd-none' : ''),
2259 cfg.cn.push({cls : 'card-footer d-none'});
2268 getCardHeader : function()
2270 var ret = this.el.select('.card-header',true).first();
2271 if (ret.hasClass('d-none')) {
2272 ret.removeClass('d-none');
2277 getCardFooter : function()
2279 var ret = this.el.select('.card-footer',true).first();
2280 if (ret.hasClass('d-none')) {
2281 ret.removeClass('d-none');
2286 getCardImageTop : function()
2288 var ret = this.el.select('.card-img-top',true).first();
2289 if (ret.hasClass('d-none')) {
2290 ret.removeClass('d-none');
2296 getChildContainer : function()
2302 return this.el.select('.roo-card-body-ctr',true).first();
2305 initEvents: function()
2307 this.bodyEl = this.el.select('.card-body',true).first();
2308 this.containerEl = this.getChildContainer();
2310 this.dragZone = new Roo.dd.DragZone(this.getEl(), {
2311 containerScroll: true,
2312 ddGroup: this.drag_group || 'default_card_drag_group'
2314 this.dragZone.getDragData = this.getDragData.createDelegate(this);
2316 if (this.dropable) {
2317 this.dropZone = new Roo.dd.DropZone(this.el.select('.card-body',true).first() , {
2318 containerScroll: true,
2319 ddGroup: this.drop_group || 'default_card_drag_group'
2321 this.dropZone.getTargetFromEvent = this.getTargetFromEvent.createDelegate(this);
2322 this.dropZone.onNodeEnter = this.onNodeEnter.createDelegate(this);
2323 this.dropZone.onNodeOver = this.onNodeOver.createDelegate(this);
2324 this.dropZone.onNodeOut = this.onNodeOut.createDelegate(this);
2325 this.dropZone.onNodeDrop = this.onNodeDrop.createDelegate(this);
2328 if (this.collapsable) {
2329 this.el.select('.card-header',true).on('click', this.onToggleCollapse, this);
2331 if (this.rotateable) {
2332 this.el.select('.card-header',true).on('click', this.onToggleRotate, this);
2334 this.collapsableEl = this.el.select('.roo-collapsable').first();
2336 this.footerEl = this.el.select('.card-footer').first();
2337 this.collapsableToggleEl = this.el.select('.roo-collapse-toggle');
2338 this.headerContainerEl = this.el.select('.roo-card-header-ctr').first();
2339 this.headerEl = this.el.select('.card-header',true).first();
2342 this.el.addClass('roo-card-rotated');
2343 this.fireEvent('rotate', this, true);
2347 getDragData : function(e)
2349 var target = this.getEl();
2351 //this.handleSelection(e);
2356 nodes: this.getEl(),
2361 dragData.ddel = target.dom ; // the div element
2362 Roo.log(target.getWidth( ));
2363 dragData.ddel.style.width = target.getWidth() + 'px';
2370 * Part of the Roo.dd.DropZone interface. If no target node is found, the
2371 * whole Element becomes the target, and this causes the drop gesture to append.
2373 getTargetFromEvent : function(e, dragged_card_el)
2375 var target = e.getTarget();
2376 while ((target !== null) && (target.parentNode != this.containerEl.dom)) {
2377 target = target.parentNode;
2388 //Roo.log([ 'target' , target ? target.id : '--nothing--']);
2389 // see if target is one of the 'cards'...
2392 //Roo.log(this.items.length);
2395 var last_card_n = 0;
2397 for (var i = 0;i< this.items.length;i++) {
2399 if (!this.items[i].el.hasClass('card')) {
2402 pos = this.getDropPoint(e, this.items[i].el.dom);
2404 cards_len = ret.cards.length;
2405 //Roo.log(this.items[i].el.dom.id);
2406 ret.cards.push(this.items[i]);
2408 if (ret.card_n < 0 && pos == 'above') {
2409 ret.position = cards_len > 0 ? 'below' : pos;
2410 ret.items_n = i > 0 ? i - 1 : 0;
2411 ret.card_n = cards_len > 0 ? cards_len - 1 : 0;
2412 ret.card = ret.cards[ret.card_n];
2415 if (!ret.cards.length) {
2417 ret.position = 'below';
2421 // could not find a card.. stick it at the end..
2422 if (ret.card_n < 0) {
2423 ret.card_n = last_card_n;
2424 ret.card = ret.cards[last_card_n];
2425 ret.items_n = this.items.indexOf(ret.cards[last_card_n]);
2426 ret.position = 'below';
2429 if (this.items[ret.items_n].el == dragged_card_el) {
2433 if (ret.position == 'below') {
2434 var card_after = ret.card_n+1 == ret.cards.length ? false : ret.cards[ret.card_n+1];
2436 if (card_after && card_after.el == dragged_card_el) {
2443 var card_before = ret.card_n > 0 ? ret.cards[ret.card_n-1] : false;
2445 if (card_before && card_before.el == dragged_card_el) {
2452 onNodeEnter : function(n, dd, e, data){
2455 onNodeOver : function(n, dd, e, data)
2458 var target_info = this.getTargetFromEvent(e,data.source.el);
2459 if (target_info === false) {
2460 this.dropPlaceHolder('hide');
2463 Roo.log(['getTargetFromEvent', target_info ]);
2466 this.dropPlaceHolder('show', target_info,data);
2470 onNodeOut : function(n, dd, e, data){
2471 this.dropPlaceHolder('hide');
2474 onNodeDrop : function(n, dd, e, data)
2477 // call drop - return false if
2479 // this could actually fail - if the Network drops..
2480 // we will ignore this at present..- client should probably reload
2481 // the whole set of cards if stuff like that fails.
2484 var info = this.getTargetFromEvent(e,data.source.el);
2485 if (info === false) {
2488 this.dropPlaceHolder('hide');
2494 this.acceptCard(data.source, info.position, info.card, info.items_n);
2498 firstChildCard : function()
2500 for (var i = 0;i< this.items.length;i++) {
2502 if (!this.items[i].el.hasClass('card')) {
2505 return this.items[i];
2507 return this.items.length ? this.items[this.items.length-1] : false; // don't try and put stuff after the cards...
2512 * - card.acceptCard(move_card, info.position, info.card, info.items_n);
2514 acceptCard : function(move_card, position, next_to_card )
2516 if (this.fireEvent("drop", this, move_card, position, next_to_card) === false) {
2520 var to_items_n = next_to_card ? this.items.indexOf(next_to_card) : 0;
2522 move_card.parent().removeCard(move_card);
2525 var dom = move_card.el.dom;
2526 dom.style.width = ''; // clear with - which is set by drag.
2528 if (next_to_card !== false && next_to_card !== true && next_to_card.el.dom.parentNode) {
2529 var cardel = next_to_card.el.dom;
2531 if (position == 'above' ) {
2532 cardel.parentNode.insertBefore(dom, cardel);
2533 } else if (cardel.nextSibling) {
2534 cardel.parentNode.insertBefore(dom,cardel.nextSibling);
2536 cardel.parentNode.append(dom);
2539 // card container???
2540 this.containerEl.dom.append(dom);
2543 //FIXME HANDLE card = true
2545 // add this to the correct place in items.
2547 // remove Card from items.
2550 if (this.items.length) {
2552 //Roo.log([info.items_n, info.position, this.items.length]);
2553 for (var i =0; i < this.items.length; i++) {
2554 if (i == to_items_n && position == 'above') {
2555 nitems.push(move_card);
2557 nitems.push(this.items[i]);
2558 if (i == to_items_n && position == 'below') {
2559 nitems.push(move_card);
2562 this.items = nitems;
2563 Roo.log(this.items);
2565 this.items.push(move_card);
2568 move_card.parentId = this.id;
2574 removeCard : function(c)
2576 this.items = this.items.filter(function(e) { return e != c });
2579 dom.parentNode.removeChild(dom);
2580 dom.style.width = ''; // clear with - which is set by drag.
2585 /** Decide whether to drop above or below a View node. */
2586 getDropPoint : function(e, n, dd)
2591 if (n == this.containerEl.dom) {
2594 var t = Roo.lib.Dom.getY(n), b = t + n.offsetHeight;
2595 var c = t + (b - t) / 2;
2596 var y = Roo.lib.Event.getPageY(e);
2603 onToggleCollapse : function(e)
2605 if (this.collapsed) {
2606 this.el.select('.roo-collapse-toggle').removeClass('collapsed');
2607 this.collapsableEl.addClass('show');
2608 this.collapsed = false;
2611 this.el.select('.roo-collapse-toggle').addClass('collapsed');
2612 this.collapsableEl.removeClass('show');
2613 this.collapsed = true;
2618 onToggleRotate : function(e)
2620 this.collapsableEl.removeClass('show');
2621 this.footerEl.removeClass('d-none');
2622 this.el.removeClass('roo-card-rotated');
2623 this.el.removeClass('d-none');
2626 this.collapsableEl.addClass('show');
2627 this.rotated = false;
2628 this.fireEvent('rotate', this, this.rotated);
2631 this.el.addClass('roo-card-rotated');
2632 this.footerEl.addClass('d-none');
2633 this.el.select('.roo-collapsable').removeClass('show');
2635 this.rotated = true;
2636 this.fireEvent('rotate', this, this.rotated);
2640 dropPlaceHolder: function (action, info, data)
2642 if (this.dropEl === false) {
2643 this.dropEl = Roo.DomHelper.append(this.containerEl, {
2647 this.dropEl.removeClass(['d-none', 'd-block']);
2648 if (action == 'hide') {
2650 this.dropEl.addClass('d-none');
2653 // FIXME - info.card == true!!!
2654 this.dropEl.dom.parentNode.removeChild(this.dropEl.dom);
2656 if (info.card !== true) {
2657 var cardel = info.card.el.dom;
2659 if (info.position == 'above') {
2660 cardel.parentNode.insertBefore(this.dropEl.dom, cardel);
2661 } else if (cardel.nextSibling) {
2662 cardel.parentNode.insertBefore(this.dropEl.dom,cardel.nextSibling);
2664 cardel.parentNode.append(this.dropEl.dom);
2667 // card container???
2668 this.containerEl.dom.append(this.dropEl.dom);
2671 this.dropEl.addClass('d-block roo-card-dropzone');
2673 this.dropEl.setHeight( Roo.get(data.ddel).getHeight() );
2680 setHeaderText: function(html)
2682 this.headerContainerEl.dom.innerHTML = html;
2691 * Card header - holder for the card header elements.
2696 * @class Roo.bootstrap.CardHeader
2697 * @extends Roo.bootstrap.Element
2698 * Bootstrap CardHeader class
2700 * Create a new Card Header - that you can embed children into
2701 * @param {Object} config The config object
2704 Roo.bootstrap.CardHeader = function(config){
2705 Roo.bootstrap.CardHeader.superclass.constructor.call(this, config);
2708 Roo.extend(Roo.bootstrap.CardHeader, Roo.bootstrap.Element, {
2711 container_method : 'getCardHeader'
2724 * Card footer - holder for the card footer elements.
2729 * @class Roo.bootstrap.CardFooter
2730 * @extends Roo.bootstrap.Element
2731 * Bootstrap CardFooter class
2733 * Create a new Card Footer - that you can embed children into
2734 * @param {Object} config The config object
2737 Roo.bootstrap.CardFooter = function(config){
2738 Roo.bootstrap.CardFooter.superclass.constructor.call(this, config);
2741 Roo.extend(Roo.bootstrap.CardFooter, Roo.bootstrap.Element, {
2744 container_method : 'getCardFooter'
2757 * Card header - holder for the card header elements.
2762 * @class Roo.bootstrap.CardImageTop
2763 * @extends Roo.bootstrap.Element
2764 * Bootstrap CardImageTop class
2766 * Create a new Card Image Top container
2767 * @param {Object} config The config object
2770 Roo.bootstrap.CardImageTop = function(config){
2771 Roo.bootstrap.CardImageTop.superclass.constructor.call(this, config);
2774 Roo.extend(Roo.bootstrap.CardImageTop, Roo.bootstrap.Element, {
2777 container_method : 'getCardImageTop'
2795 * @class Roo.bootstrap.Img
2796 * @extends Roo.bootstrap.Component
2797 * Bootstrap Img class
2798 * @cfg {Boolean} imgResponsive false | true
2799 * @cfg {String} border rounded | circle | thumbnail
2800 * @cfg {String} src image source
2801 * @cfg {String} alt image alternative text
2802 * @cfg {String} href a tag href
2803 * @cfg {String} target (_self|_blank|_parent|_top)target for a href.
2804 * @cfg {String} xsUrl xs image source
2805 * @cfg {String} smUrl sm image source
2806 * @cfg {String} mdUrl md image source
2807 * @cfg {String} lgUrl lg image source
2810 * Create a new Input
2811 * @param {Object} config The config object
2814 Roo.bootstrap.Img = function(config){
2815 Roo.bootstrap.Img.superclass.constructor.call(this, config);
2821 * The img click event for the img.
2822 * @param {Roo.EventObject} e
2828 Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, {
2830 imgResponsive: true,
2840 getAutoCreate : function()
2842 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
2843 return this.createSingleImg();
2848 cls: 'roo-image-responsive-group',
2853 Roo.each(['xs', 'sm', 'md', 'lg'], function(size){
2855 if(!_this[size + 'Url']){
2861 cls: (_this.imgResponsive) ? 'img-responsive' : '',
2862 html: _this.html || cfg.html,
2863 src: _this[size + 'Url']
2866 img.cls += ' roo-image-responsive-' + size;
2868 var s = ['xs', 'sm', 'md', 'lg'];
2870 s.splice(s.indexOf(size), 1);
2872 Roo.each(s, function(ss){
2873 img.cls += ' hidden-' + ss;
2876 if (['rounded','circle','thumbnail'].indexOf(_this.border)>-1) {
2877 cfg.cls += ' img-' + _this.border;
2881 cfg.alt = _this.alt;
2894 a.target = _this.target;
2898 cfg.cn.push((_this.href) ? a : img);
2905 createSingleImg : function()
2909 cls: (this.imgResponsive) ? 'img-responsive' : '',
2911 src : 'about:blank' // just incase src get's set to undefined?!?
2914 cfg.html = this.html || cfg.html;
2916 cfg.src = this.src || cfg.src;
2918 if (['rounded','circle','thumbnail'].indexOf(this.border)>-1) {
2919 cfg.cls += ' img-' + this.border;
2936 a.target = this.target;
2941 return (this.href) ? a : cfg;
2944 initEvents: function()
2947 this.el.on('click', this.onClick, this);
2952 onClick : function(e)
2954 Roo.log('img onclick');
2955 this.fireEvent('click', this, e);
2958 * Sets the url of the image - used to update it
2959 * @param {String} url the url of the image
2962 setSrc : function(url)
2966 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
2967 this.el.dom.src = url;
2971 this.el.select('img', true).first().dom.src = url;
2987 * @class Roo.bootstrap.Link
2988 * @extends Roo.bootstrap.Component
2989 * Bootstrap Link Class
2990 * @cfg {String} alt image alternative text
2991 * @cfg {String} href a tag href
2992 * @cfg {String} target (_self|_blank|_parent|_top) target for a href.
2993 * @cfg {String} html the content of the link.
2994 * @cfg {String} anchor name for the anchor link
2995 * @cfg {String} fa - favicon
2997 * @cfg {Boolean} preventDefault (true | false) default false
3001 * Create a new Input
3002 * @param {Object} config The config object
3005 Roo.bootstrap.Link = function(config){
3006 Roo.bootstrap.Link.superclass.constructor.call(this, config);
3012 * The img click event for the img.
3013 * @param {Roo.EventObject} e
3019 Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component, {
3023 preventDefault: false,
3029 getAutoCreate : function()
3031 var html = this.html || '';
3033 if (this.fa !== false) {
3034 html = '<i class="fa fa-' + this.fa + '"></i>';
3039 // anchor's do not require html/href...
3040 if (this.anchor === false) {
3042 cfg.href = this.href || '#';
3044 cfg.name = this.anchor;
3045 if (this.html !== false || this.fa !== false) {
3048 if (this.href !== false) {
3049 cfg.href = this.href;
3053 if(this.alt !== false){
3058 if(this.target !== false) {
3059 cfg.target = this.target;
3065 initEvents: function() {
3067 if(!this.href || this.preventDefault){
3068 this.el.on('click', this.onClick, this);
3072 onClick : function(e)
3074 if(this.preventDefault){
3077 //Roo.log('img onclick');
3078 this.fireEvent('click', this, e);
3091 * @class Roo.bootstrap.Header
3092 * @extends Roo.bootstrap.Component
3093 * Bootstrap Header class
3094 * @cfg {String} html content of header
3095 * @cfg {Number} level (1|2|3|4|5|6) default 1
3098 * Create a new Header
3099 * @param {Object} config The config object
3103 Roo.bootstrap.Header = function(config){
3104 Roo.bootstrap.Header.superclass.constructor.call(this, config);
3107 Roo.extend(Roo.bootstrap.Header, Roo.bootstrap.Component, {
3115 getAutoCreate : function(){
3120 tag: 'h' + (1 *this.level),
3121 html: this.html || ''
3133 * Ext JS Library 1.1.1
3134 * Copyright(c) 2006-2007, Ext JS, LLC.
3136 * Originally Released Under LGPL - original licence link has changed is not relivant.
3139 * <script type="text/javascript">
3143 * @class Roo.bootstrap.MenuMgr
3144 * Provides a common registry of all menu items on a page so that they can be easily accessed by id.
3147 Roo.bootstrap.MenuMgr = function(){
3148 var menus, active, groups = {}, attached = false, lastShow = new Date();
3150 // private - called when first menu is created
3153 active = new Roo.util.MixedCollection();
3154 Roo.get(document).addKeyListener(27, function(){
3155 if(active.length > 0){
3163 if(active && active.length > 0){
3164 var c = active.clone();
3174 if(active.length < 1){
3175 Roo.get(document).un("mouseup", onMouseDown);
3183 var last = active.last();
3184 lastShow = new Date();
3187 Roo.get(document).on("mouseup", onMouseDown);
3192 //m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
3193 m.parentMenu.activeChild = m;
3194 }else if(last && last.isVisible()){
3195 //m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
3200 function onBeforeHide(m){
3202 m.activeChild.hide();
3204 if(m.autoHideTimer){
3205 clearTimeout(m.autoHideTimer);
3206 delete m.autoHideTimer;
3211 function onBeforeShow(m){
3212 var pm = m.parentMenu;
3213 if(!pm && !m.allowOtherMenus){
3215 }else if(pm && pm.activeChild && active != m){
3216 pm.activeChild.hide();
3220 // private this should really trigger on mouseup..
3221 function onMouseDown(e){
3222 Roo.log("on Mouse Up");
3224 if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".dropdown-menu") && !e.getTarget('.user-menu')){
3225 Roo.log("MenuManager hideAll");
3234 function onBeforeCheck(mi, state){
3236 var g = groups[mi.group];
3237 for(var i = 0, l = g.length; i < l; i++){
3239 g[i].setChecked(false);
3248 * Hides all menus that are currently visible
3250 hideAll : function(){
3255 register : function(menu){
3259 menus[menu.id] = menu;
3260 menu.on("beforehide", onBeforeHide);
3261 menu.on("hide", onHide);
3262 menu.on("beforeshow", onBeforeShow);
3263 menu.on("show", onShow);
3265 if(g && menu.events["checkchange"]){
3269 groups[g].push(menu);
3270 menu.on("checkchange", onCheck);
3275 * Returns a {@link Roo.menu.Menu} object
3276 * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will
3277 * be used to generate and return a new Menu instance.
3279 get : function(menu){
3280 if(typeof menu == "string"){ // menu id
3282 }else if(menu.events){ // menu instance
3285 /*else if(typeof menu.length == 'number'){ // array of menu items?
3286 return new Roo.bootstrap.Menu({items:menu});
3287 }else{ // otherwise, must be a config
3288 return new Roo.bootstrap.Menu(menu);
3295 unregister : function(menu){
3296 delete menus[menu.id];
3297 menu.un("beforehide", onBeforeHide);
3298 menu.un("hide", onHide);
3299 menu.un("beforeshow", onBeforeShow);
3300 menu.un("show", onShow);
3302 if(g && menu.events["checkchange"]){
3303 groups[g].remove(menu);
3304 menu.un("checkchange", onCheck);
3309 registerCheckable : function(menuItem){
3310 var g = menuItem.group;
3315 groups[g].push(menuItem);
3316 menuItem.on("beforecheckchange", onBeforeCheck);
3321 unregisterCheckable : function(menuItem){
3322 var g = menuItem.group;
3324 groups[g].remove(menuItem);
3325 menuItem.un("beforecheckchange", onBeforeCheck);
3337 * @class Roo.bootstrap.Menu
3338 * @extends Roo.bootstrap.Component
3339 * Bootstrap Menu class - container for MenuItems
3340 * @cfg {String} type (dropdown|treeview|submenu) type of menu
3341 * @cfg {bool} hidden if the menu should be hidden when rendered.
3342 * @cfg {bool} stopEvent (true|false) Stop event after trigger press (default true)
3343 * @cfg {bool} isLink (true|false) the menu has link disable auto expand and collaspe (default false)
3347 * @param {Object} config The config object
3351 Roo.bootstrap.Menu = function(config){
3352 Roo.bootstrap.Menu.superclass.constructor.call(this, config);
3353 if (this.registerMenu && this.type != 'treeview') {
3354 Roo.bootstrap.MenuMgr.register(this);
3361 * Fires before this menu is displayed (return false to block)
3362 * @param {Roo.menu.Menu} this
3367 * Fires before this menu is hidden (return false to block)
3368 * @param {Roo.menu.Menu} this
3373 * Fires after this menu is displayed
3374 * @param {Roo.menu.Menu} this
3379 * Fires after this menu is hidden
3380 * @param {Roo.menu.Menu} this
3385 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
3386 * @param {Roo.menu.Menu} this
3387 * @param {Roo.menu.Item} menuItem The menu item that was clicked
3388 * @param {Roo.EventObject} e
3393 * Fires when the mouse is hovering over this menu
3394 * @param {Roo.menu.Menu} this
3395 * @param {Roo.EventObject} e
3396 * @param {Roo.menu.Item} menuItem The menu item that was clicked
3401 * Fires when the mouse exits this menu
3402 * @param {Roo.menu.Menu} this
3403 * @param {Roo.EventObject} e
3404 * @param {Roo.menu.Item} menuItem The menu item that was clicked
3409 * Fires when a menu item contained in this menu is clicked
3410 * @param {Roo.menu.BaseItem} baseItem The BaseItem that was clicked
3411 * @param {Roo.EventObject} e
3415 this.menuitems = new Roo.util.MixedCollection(false, function(o) { return o.el.id; });
3418 Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, {
3422 triggerEl : false, // is this set by component builder? -- it should really be fetched from parent()???
3425 * @cfg {Boolean} registerMenu True (default) - means that clicking on screen etc. hides it.
3427 registerMenu : true,
3429 menuItems :false, // stores the menu items..
3439 getChildContainer : function() {
3443 getAutoCreate : function(){
3445 //if (['right'].indexOf(this.align)!==-1) {
3446 // cfg.cn[1].cls += ' pull-right'
3452 cls : 'dropdown-menu' ,
3453 style : 'z-index:1000'
3457 if (this.type === 'submenu') {
3458 cfg.cls = 'submenu active';
3460 if (this.type === 'treeview') {
3461 cfg.cls = 'treeview-menu';
3466 initEvents : function() {
3468 // Roo.log("ADD event");
3469 // Roo.log(this.triggerEl.dom);
3471 this.triggerEl.on('click', this.onTriggerClick, this);
3473 this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this);
3476 if (this.triggerEl.hasClass('nav-item')) {
3477 // dropdown toggle on the 'a' in BS4?
3478 this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle');
3480 this.triggerEl.addClass('dropdown-toggle');
3483 this.el.on('touchstart' , this.onTouch, this);
3485 this.el.on('click' , this.onClick, this);
3487 this.el.on("mouseover", this.onMouseOver, this);
3488 this.el.on("mouseout", this.onMouseOut, this);
3492 findTargetItem : function(e)
3494 var t = e.getTarget(".dropdown-menu-item", this.el, true);
3498 //Roo.log(t); Roo.log(t.id);
3500 //Roo.log(this.menuitems);
3501 return this.menuitems.get(t.id);
3503 //return this.items.get(t.menuItemId);
3509 onTouch : function(e)
3511 Roo.log("menu.onTouch");
3512 //e.stopEvent(); this make the user popdown broken
3516 onClick : function(e)
3518 Roo.log("menu.onClick");
3520 var t = this.findTargetItem(e);
3521 if(!t || t.isContainer){
3526 if (Roo.isTouch && e.type == 'touchstart' && t.menu && !t.disabled) {
3527 if(t == this.activeItem && t.shouldDeactivate(e)){
3528 this.activeItem.deactivate();
3529 delete this.activeItem;
3533 this.setActiveItem(t, true);
3541 Roo.log('pass click event');
3545 this.fireEvent("click", this, t, e);
3549 if(!t.href.length || t.href == '#'){
3550 (function() { _this.hide(); }).defer(100);
3555 onMouseOver : function(e){
3556 var t = this.findTargetItem(e);
3559 // if(t.canActivate && !t.disabled){
3560 // this.setActiveItem(t, true);
3564 this.fireEvent("mouseover", this, e, t);
3566 isVisible : function(){
3567 return !this.hidden;
3569 onMouseOut : function(e){
3570 var t = this.findTargetItem(e);
3573 // if(t == this.activeItem && t.shouldDeactivate(e)){
3574 // this.activeItem.deactivate();
3575 // delete this.activeItem;
3578 this.fireEvent("mouseout", this, e, t);
3583 * Displays this menu relative to another element
3584 * @param {String/HTMLElement/Roo.Element} element The element to align to
3585 * @param {String} position (optional) The {@link Roo.Element#alignTo} anchor position to use in aligning to
3586 * the element (defaults to this.defaultAlign)
3587 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
3589 show : function(el, pos, parentMenu)
3591 if (false === this.fireEvent("beforeshow", this)) {
3592 Roo.log("show canceled");
3595 this.parentMenu = parentMenu;
3600 this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign), parentMenu, false);
3603 * Displays this menu at a specific xy position
3604 * @param {Array} xyPosition Contains X & Y [x, y] values for the position at which to show the menu (coordinates are page-based)
3605 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
3607 showAt : function(xy, parentMenu, /* private: */_e){
3608 this.parentMenu = parentMenu;
3613 this.fireEvent("beforeshow", this);
3614 //xy = this.el.adjustForConstraints(xy);
3618 this.hideMenuItems();
3619 this.hidden = false;
3620 this.triggerEl.addClass('open');
3621 this.el.addClass('show');
3623 // reassign x when hitting right
3624 if(this.el.getWidth() + xy[0] >= Roo.lib.Dom.getViewWidth()){
3625 xy[0] = xy[0] - this.el.getWidth() + this.triggerEl.getWidth();
3628 // reassign y when hitting bottom
3629 if(this.el.getHeight() + xy[1] >= Roo.lib.Dom.getViewHeight()){
3630 xy[1] = xy[1] - this.el.getHeight() - this.triggerEl.getHeight();
3633 // but the list may align on trigger left or trigger top... should it be a properity?
3635 if(this.el.getStyle('top') != 'auto' && this.el.getStyle('top').slice(-1) != "%"){
3640 this.fireEvent("show", this);
3646 this.doFocus.defer(50, this);
3650 doFocus : function(){
3652 this.focusEl.focus();
3657 * Hides this menu and optionally all parent menus
3658 * @param {Boolean} deep (optional) True to hide all parent menus recursively, if any (defaults to false)
3660 hide : function(deep)
3662 if (false === this.fireEvent("beforehide", this)) {
3663 Roo.log("hide canceled");
3666 this.hideMenuItems();
3667 if(this.el && this.isVisible()){
3669 if(this.activeItem){
3670 this.activeItem.deactivate();
3671 this.activeItem = null;
3673 this.triggerEl.removeClass('open');;
3674 this.el.removeClass('show');
3676 this.fireEvent("hide", this);
3678 if(deep === true && this.parentMenu){
3679 this.parentMenu.hide(true);
3683 onTriggerClick : function(e)
3685 Roo.log('trigger click');
3687 var target = e.getTarget();
3689 Roo.log(target.nodeName.toLowerCase());
3691 if(target.nodeName.toLowerCase() === 'i'){
3697 onTriggerPress : function(e)
3699 Roo.log('trigger press');
3700 //Roo.log(e.getTarget());
3701 // Roo.log(this.triggerEl.dom);
3703 // trigger only occurs on normal menu's -- if it's a treeview or dropdown... do not hide/show..
3704 var pel = Roo.get(e.getTarget());
3705 if (pel.findParent('.dropdown-menu') || pel.findParent('.treeview-menu') ) {
3706 Roo.log('is treeview or dropdown?');
3710 if(e.getTarget().nodeName.toLowerCase() !== 'i' && this.isLink){
3714 if (this.isVisible()) {
3719 this.show(this.triggerEl, '?', false);
3722 if(this.stopEvent || e.getTarget().nodeName.toLowerCase() === 'i'){
3729 hideMenuItems : function()
3731 Roo.log("hide Menu Items");
3736 this.el.select('.open',true).each(function(aa) {
3738 aa.removeClass('open');
3742 addxtypeChild : function (tree, cntr) {
3743 var comp= Roo.bootstrap.Menu.superclass.addxtypeChild.call(this, tree, cntr);
3745 this.menuitems.add(comp);
3757 this.getEl().dom.innerHTML = '';
3758 this.menuitems.clear();
3772 * @class Roo.bootstrap.MenuItem
3773 * @extends Roo.bootstrap.Component
3774 * Bootstrap MenuItem class
3775 * @cfg {String} html the menu label
3776 * @cfg {String} href the link
3777 * @cfg {Boolean} preventDefault do not trigger A href on clicks (default false).
3778 * @cfg {Boolean} isContainer is it a container - just returns a drop down item..
3779 * @cfg {Boolean} active used on sidebars to highlight active itesm
3780 * @cfg {String} fa favicon to show on left of menu item.
3781 * @cfg {Roo.bootsrap.Menu} menu the child menu.
3785 * Create a new MenuItem
3786 * @param {Object} config The config object
3790 Roo.bootstrap.MenuItem = function(config){
3791 Roo.bootstrap.MenuItem.superclass.constructor.call(this, config);
3796 * The raw click event for the entire grid.
3797 * @param {Roo.bootstrap.MenuItem} this
3798 * @param {Roo.EventObject} e
3804 Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component, {
3808 preventDefault: false,
3809 isContainer : false,
3813 getAutoCreate : function(){
3815 if(this.isContainer){
3818 cls: 'dropdown-menu-item '
3828 cls : 'dropdown-item',
3833 if (this.fa !== false) {
3836 cls : 'fa fa-' + this.fa
3845 cls: 'dropdown-menu-item',
3848 if (this.parent().type == 'treeview') {
3849 cfg.cls = 'treeview-menu';
3852 cfg.cls += ' active';
3857 anc.href = this.href || cfg.cn[0].href ;
3858 ctag.html = this.html || cfg.cn[0].html ;
3862 initEvents: function()
3864 if (this.parent().type == 'treeview') {
3865 this.el.select('a').on('click', this.onClick, this);
3869 this.menu.parentType = this.xtype;
3870 this.menu.triggerEl = this.el;
3871 this.menu = this.addxtype(Roo.apply({}, this.menu));
3875 onClick : function(e)
3877 Roo.log('item on click ');
3879 if(this.preventDefault){
3882 //this.parent().hideMenuItems();
3884 this.fireEvent('click', this, e);
3903 * @class Roo.bootstrap.MenuSeparator
3904 * @extends Roo.bootstrap.Component
3905 * Bootstrap MenuSeparator class
3908 * Create a new MenuItem
3909 * @param {Object} config The config object
3913 Roo.bootstrap.MenuSeparator = function(config){
3914 Roo.bootstrap.MenuSeparator.superclass.constructor.call(this, config);
3917 Roo.extend(Roo.bootstrap.MenuSeparator, Roo.bootstrap.Component, {
3919 getAutoCreate : function(){
3938 * @class Roo.bootstrap.Modal
3939 * @extends Roo.bootstrap.Component
3940 * Bootstrap Modal class
3941 * @cfg {String} title Title of dialog
3942 * @cfg {String} html - the body of the dialog (for simple ones) - you can also use template..
3943 * @cfg {Roo.Template} tmpl - a template with variables. to use it, add a handler in show:method adn
3944 * @cfg {Boolean} specificTitle default false
3945 * @cfg {Array} buttons Array of buttons or standard button set..
3946 * @cfg {String} buttonPosition (left|right|center) default right (DEPRICATED) - use mr-auto on buttons to put them on the left
3947 * @cfg {Boolean} animate default true
3948 * @cfg {Boolean} allow_close default true
3949 * @cfg {Boolean} fitwindow default false
3950 * @cfg {Boolean} bodyOverflow should the body element have overflow auto added default false
3951 * @cfg {Number} width fixed width - usefull for chrome extension only really.
3952 * @cfg {Number} height fixed height - usefull for chrome extension only really.
3953 * @cfg {String} size (sm|lg|xl) default empty
3954 * @cfg {Number} max_width set the max width of modal
3955 * @cfg {Boolean} editableTitle can the title be edited
3960 * Create a new Modal Dialog
3961 * @param {Object} config The config object
3964 Roo.bootstrap.Modal = function(config){
3965 Roo.bootstrap.Modal.superclass.constructor.call(this, config);
3970 * The raw btnclick event for the button
3971 * @param {Roo.EventObject} e
3976 * Fire when dialog resize
3977 * @param {Roo.bootstrap.Modal} this
3978 * @param {Roo.EventObject} e
3982 * @event titlechanged
3983 * Fire when the editable title has been changed
3984 * @param {Roo.bootstrap.Modal} this
3985 * @param {Roo.EventObject} value
3987 "titlechanged" : true
3990 this.buttons = this.buttons || [];
3993 this.tmpl = Roo.factory(this.tmpl);
3998 Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, {
4000 title : 'test dialog',
4010 specificTitle: false,
4012 buttonPosition: 'right',
4034 editableTitle : false,
4036 onRender : function(ct, position)
4038 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
4041 var cfg = Roo.apply({}, this.getAutoCreate());
4044 // cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
4046 //if (!cfg.name.length) {
4050 cfg.cls += ' ' + this.cls;
4053 cfg.style = this.style;
4055 this.el = Roo.get(document.body).createChild(cfg, position);
4057 //var type = this.el.dom.type;
4060 if(this.tabIndex !== undefined){
4061 this.el.dom.setAttribute('tabIndex', this.tabIndex);
4064 this.dialogEl = this.el.select('.modal-dialog',true).first();
4065 this.bodyEl = this.el.select('.modal-body',true).first();
4066 this.closeEl = this.el.select('.modal-header .close', true).first();
4067 this.headerEl = this.el.select('.modal-header',true).first();
4068 this.titleEl = this.el.select('.modal-title',true).first();
4069 this.footerEl = this.el.select('.modal-footer',true).first();
4071 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
4073 //this.el.addClass("x-dlg-modal");
4075 if (this.buttons.length) {
4076 Roo.each(this.buttons, function(bb) {
4077 var b = Roo.apply({}, bb);
4078 b.xns = b.xns || Roo.bootstrap;
4079 b.xtype = b.xtype || 'Button';
4080 if (typeof(b.listeners) == 'undefined') {
4081 b.listeners = { click : this.onButtonClick.createDelegate(this) };
4084 var btn = Roo.factory(b);
4086 btn.render(this.getButtonContainer());
4090 // render the children.
4093 if(typeof(this.items) != 'undefined'){
4094 var items = this.items;
4097 for(var i =0;i < items.length;i++) {
4098 nitems.push(this.addxtype(Roo.apply({}, items[i])));
4102 this.items = nitems;
4104 // where are these used - they used to be body/close/footer
4108 //this.el.addClass([this.fieldClass, this.cls]);
4112 getAutoCreate : function()
4114 // we will default to modal-body-overflow - might need to remove or make optional later.
4116 cls : 'modal-body ' + (this.bodyOverflow ? 'overflow-auto' : ''),
4117 html : this.html || ''
4122 cls : 'modal-title',
4126 if(this.specificTitle){ // WTF is this?
4131 if (this.allow_close && Roo.bootstrap.version == 3) {
4141 if (this.editableTitle) {
4143 cls: 'form-control roo-editable-title d-none',
4149 if (this.allow_close && Roo.bootstrap.version == 4) {
4159 if(this.size.length){
4160 size = 'modal-' + this.size;
4163 var footer = Roo.bootstrap.version == 3 ?
4165 cls : 'modal-footer',
4169 cls: 'btn-' + this.buttonPosition
4174 { // BS4 uses mr-auto on left buttons....
4175 cls : 'modal-footer'
4186 cls: "modal-dialog " + size,
4189 cls : "modal-content",
4192 cls : 'modal-header',
4207 modal.cls += ' fade';
4213 getChildContainer : function() {
4218 getButtonContainer : function() {
4220 return Roo.bootstrap.version == 4 ?
4221 this.el.select('.modal-footer',true).first()
4222 : this.el.select('.modal-footer div',true).first();
4225 initEvents : function()
4227 if (this.allow_close) {
4228 this.closeEl.on('click', this.hide, this);
4230 Roo.EventManager.onWindowResize(this.resize, this, true);
4231 if (this.editableTitle) {
4232 this.headerEditEl = this.headerEl.select('.form-control',true).first();
4233 this.headerEl.on('click', function() { this.toggleHeaderInput(true) } , this);
4234 this.headerEditEl.on('keyup', function(e) {
4235 if([ e.RETURN , e.TAB , e.ESC ].indexOf(e.keyCode) > -1) {
4236 this.toggleHeaderInput(false)
4239 this.headerEditEl.on('blur', function(e) {
4240 this.toggleHeaderInput(false)
4249 this.maskEl.setSize(
4250 Roo.lib.Dom.getViewWidth(true),
4251 Roo.lib.Dom.getViewHeight(true)
4254 if (this.fitwindow) {
4256 this.dialogEl.setStyle( { 'max-width' : '100%' });
4258 this.width || Roo.lib.Dom.getViewportWidth(true) - 30,
4259 this.height || Roo.lib.Dom.getViewportHeight(true) // catering margin-top 30 margin-bottom 30
4264 if(this.max_width !== 0) {
4266 var w = Math.min(this.max_width, Roo.lib.Dom.getViewportWidth(true) - 30);
4269 this.setSize(w, this.height);
4273 if(this.max_height) {
4274 this.setSize(w,Math.min(
4276 Roo.lib.Dom.getViewportHeight(true) - 60
4282 if(!this.fit_content) {
4283 this.setSize(w, Roo.lib.Dom.getViewportHeight(true) - 60);
4287 this.setSize(w, Math.min(
4289 this.headerEl.getHeight() +
4290 this.footerEl.getHeight() +
4291 this.getChildHeight(this.bodyEl.dom.childNodes),
4292 Roo.lib.Dom.getViewportHeight(true) - 60)
4298 setSize : function(w,h)
4309 if (!this.rendered) {
4312 this.toggleHeaderInput(false);
4313 //this.el.setStyle('display', 'block');
4314 this.el.removeClass('hideing');
4315 this.el.dom.style.display='block';
4317 Roo.get(document.body).addClass('modal-open');
4319 if(this.animate){ // element has 'fade' - so stuff happens after .3s ?- not sure why the delay?
4322 this.el.addClass('show');
4323 this.el.addClass('in');
4326 this.el.addClass('show');
4327 this.el.addClass('in');
4330 // not sure how we can show data in here..
4332 // this.getChildContainer().dom.innerHTML = this.tmpl.applyTemplate(this);
4335 Roo.get(document.body).addClass("x-body-masked");
4337 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
4338 this.maskEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
4339 this.maskEl.dom.style.display = 'block';
4340 this.maskEl.addClass('show');
4345 this.fireEvent('show', this);
4347 // set zindex here - otherwise it appears to be ignored...
4348 this.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
4351 this.items.forEach( function(e) {
4352 e.layout ? e.layout() : false;
4360 if(this.fireEvent("beforehide", this) !== false){
4362 this.maskEl.removeClass('show');
4364 this.maskEl.dom.style.display = '';
4365 Roo.get(document.body).removeClass("x-body-masked");
4366 this.el.removeClass('in');
4367 this.el.select('.modal-dialog', true).first().setStyle('transform','');
4369 if(this.animate){ // why
4370 this.el.addClass('hideing');
4371 this.el.removeClass('show');
4373 if (!this.el.hasClass('hideing')) {
4374 return; // it's been shown again...
4377 this.el.dom.style.display='';
4379 Roo.get(document.body).removeClass('modal-open');
4380 this.el.removeClass('hideing');
4384 this.el.removeClass('show');
4385 this.el.dom.style.display='';
4386 Roo.get(document.body).removeClass('modal-open');
4389 this.fireEvent('hide', this);
4392 isVisible : function()
4395 return this.el.hasClass('show') && !this.el.hasClass('hideing');
4399 addButton : function(str, cb)
4403 var b = Roo.apply({}, { html : str } );
4404 b.xns = b.xns || Roo.bootstrap;
4405 b.xtype = b.xtype || 'Button';
4406 if (typeof(b.listeners) == 'undefined') {
4407 b.listeners = { click : cb.createDelegate(this) };
4410 var btn = Roo.factory(b);
4412 btn.render(this.getButtonContainer());
4418 setDefaultButton : function(btn)
4420 //this.el.select('.modal-footer').()
4423 resizeTo: function(w,h)
4425 this.dialogEl.setWidth(w);
4427 var diff = this.headerEl.getHeight() + this.footerEl.getHeight() + 60; // dialog margin-bottom: 30
4429 this.bodyEl.setHeight(h - diff);
4431 this.fireEvent('resize', this);
4434 setContentSize : function(w, h)
4438 onButtonClick: function(btn,e)
4441 this.fireEvent('btnclick', btn.name, e);
4444 * Set the title of the Dialog
4445 * @param {String} str new Title
4447 setTitle: function(str) {
4448 this.titleEl.dom.innerHTML = str;
4452 * Set the body of the Dialog
4453 * @param {String} str new Title
4455 setBody: function(str) {
4456 this.bodyEl.dom.innerHTML = str;
4459 * Set the body of the Dialog using the template
4460 * @param {Obj} data - apply this data to the template and replace the body contents.
4462 applyBody: function(obj)
4465 Roo.log("Error - using apply Body without a template");
4468 this.tmpl.overwrite(this.bodyEl, obj);
4471 getChildHeight : function(child_nodes)
4475 child_nodes.length == 0
4480 var child_height = 0;
4482 for(var i = 0; i < child_nodes.length; i++) {
4485 * for modal with tabs...
4486 if(child_nodes[i].classList.contains('roo-layout-panel')) {
4488 var layout_childs = child_nodes[i].childNodes;
4490 for(var j = 0; j < layout_childs.length; j++) {
4492 if(layout_childs[j].classList.contains('roo-layout-panel-body')) {
4494 var layout_body_childs = layout_childs[j].childNodes;
4496 for(var k = 0; k < layout_body_childs.length; k++) {
4498 if(layout_body_childs[k].classList.contains('navbar')) {
4499 child_height += layout_body_childs[k].offsetHeight;
4503 if(layout_body_childs[k].classList.contains('roo-layout-tabs-body')) {
4505 var layout_body_tab_childs = layout_body_childs[k].childNodes;
4507 for(var m = 0; m < layout_body_tab_childs.length; m++) {
4509 if(layout_body_tab_childs[m].classList.contains('roo-layout-active-content')) {
4510 child_height += this.getChildHeight(layout_body_tab_childs[m].childNodes);
4525 child_height += child_nodes[i].offsetHeight;
4526 // Roo.log(child_nodes[i].offsetHeight);
4529 return child_height;
4531 toggleHeaderInput : function(is_edit)
4533 if (!this.editableTitle) {
4534 return; // not editable.
4536 if (is_edit && this.is_header_editing) {
4537 return; // already editing..
4541 this.headerEditEl.dom.value = this.title;
4542 this.headerEditEl.removeClass('d-none');
4543 this.headerEditEl.dom.focus();
4544 this.titleEl.addClass('d-none');
4546 this.is_header_editing = true;
4549 // flip back to not editing.
4550 this.title = this.headerEditEl.dom.value;
4551 this.headerEditEl.addClass('d-none');
4552 this.titleEl.removeClass('d-none');
4553 this.titleEl.dom.innerHTML = String.format('{0}', this.title);
4554 this.is_header_editing = false;
4555 this.fireEvent('titlechanged', this, this.title);
4564 Roo.apply(Roo.bootstrap.Modal, {
4566 * Button config that displays a single OK button
4575 * Button config that displays Yes and No buttons
4591 * Button config that displays OK and Cancel buttons
4606 * Button config that displays Yes, No and Cancel buttons
4631 * messagebox - can be used as a replace
4635 * @class Roo.MessageBox
4636 * Utility class for generating different styles of message boxes. The alias Roo.Msg can also be used.
4640 Roo.Msg.alert('Status', 'Changes saved successfully.');
4642 // Prompt for user data:
4643 Roo.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
4645 // process text value...
4649 // Show a dialog using config options:
4651 title:'Save Changes?',
4652 msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',
4653 buttons: Roo.Msg.YESNOCANCEL,
4660 Roo.bootstrap.MessageBox = function(){
4661 var dlg, opt, mask, waitTimer;
4662 var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp;
4663 var buttons, activeTextEl, bwidth;
4667 var handleButton = function(button){
4669 Roo.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
4673 var handleHide = function(){
4675 dlg.el.removeClass(opt.cls);
4678 // Roo.TaskMgr.stop(waitTimer);
4679 // waitTimer = null;
4684 var updateButtons = function(b){
4687 buttons["ok"].hide();
4688 buttons["cancel"].hide();
4689 buttons["yes"].hide();
4690 buttons["no"].hide();
4691 dlg.footerEl.hide();
4695 dlg.footerEl.show();
4696 for(var k in buttons){
4697 if(typeof buttons[k] != "function"){
4700 buttons[k].setText(typeof b[k] == "string" ? b[k] : Roo.bootstrap.MessageBox.buttonText[k]);
4701 width += buttons[k].el.getWidth()+15;
4711 var handleEsc = function(d, k, e){
4712 if(opt && opt.closable !== false){
4722 * Returns a reference to the underlying {@link Roo.BasicDialog} element
4723 * @return {Roo.BasicDialog} The BasicDialog element
4725 getDialog : function(){
4727 dlg = new Roo.bootstrap.Modal( {
4730 //constraintoviewport:false,
4732 //collapsible : false,
4737 //buttonAlign:"center",
4738 closeClick : function(){
4739 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
4742 handleButton("cancel");
4747 dlg.on("hide", handleHide);
4749 //dlg.addKeyListener(27, handleEsc);
4751 this.buttons = buttons;
4752 var bt = this.buttonText;
4753 buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
4754 buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
4755 buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
4756 buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
4758 bodyEl = dlg.bodyEl.createChild({
4760 html:'<span class="roo-mb-text"></span><br /><input type="text" class="roo-mb-input" />' +
4761 '<textarea class="roo-mb-textarea"></textarea>' +
4762 '<div class="roo-mb-progress-wrap"><div class="roo-mb-progress"><div class="roo-mb-progress-bar"> </div></div></div>'
4764 msgEl = bodyEl.dom.firstChild;
4765 textboxEl = Roo.get(bodyEl.dom.childNodes[2]);
4766 textboxEl.enableDisplayMode();
4767 textboxEl.addKeyListener([10,13], function(){
4768 if(dlg.isVisible() && opt && opt.buttons){
4771 }else if(opt.buttons.yes){
4772 handleButton("yes");
4776 textareaEl = Roo.get(bodyEl.dom.childNodes[3]);
4777 textareaEl.enableDisplayMode();
4778 progressEl = Roo.get(bodyEl.dom.childNodes[4]);
4779 progressEl.enableDisplayMode();
4781 // This is supposed to be the progessElement.. but I think it's controlling the height of everything..
4782 var pf = progressEl.dom.firstChild;
4784 pp = Roo.get(pf.firstChild);
4785 pp.setHeight(pf.offsetHeight);
4793 * Updates the message box body text
4794 * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
4795 * the XHTML-compliant non-breaking space character '&#160;')
4796 * @return {Roo.MessageBox} This message box
4798 updateText : function(text)
4800 if(!dlg.isVisible() && !opt.width){
4801 dlg.dialogEl.setStyle({ 'max-width' : this.maxWidth});
4802 // dlg.resizeTo(this.maxWidth, 100); // forcing the height breaks long alerts()
4804 msgEl.innerHTML = text || ' ';
4806 var cw = Math.max(msgEl.offsetWidth, msgEl.parentNode.scrollWidth);
4807 //Roo.log("guesed size: " + JSON.stringify([cw,msgEl.offsetWidth, msgEl.parentNode.scrollWidth]));
4809 Math.min(opt.width || cw , this.maxWidth),
4810 Math.max(opt.minWidth || this.minWidth, bwidth)
4813 activeTextEl.setWidth(w);
4815 if(dlg.isVisible()){
4816 dlg.fixedcenter = false;
4818 // to big, make it scroll. = But as usual stupid IE does not support
4821 if ( bodyEl.getHeight() > (Roo.lib.Dom.getViewHeight() - 100)) {
4822 bodyEl.setHeight ( Roo.lib.Dom.getViewHeight() - 100 );
4823 bodyEl.dom.style.overflowY = 'auto' + ( Roo.isIE ? '' : ' !important');
4825 bodyEl.dom.style.height = '';
4826 bodyEl.dom.style.overflowY = '';
4829 bodyEl.dom.style.get = 'auto' + ( Roo.isIE ? '' : ' !important');
4831 bodyEl.dom.style.overflowX = '';
4834 dlg.setContentSize(w, bodyEl.getHeight());
4835 if(dlg.isVisible()){
4836 dlg.fixedcenter = true;
4842 * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
4843 * initiated via {@link Roo.MessageBox#progress} or by calling {@link Roo.MessageBox#show} with progress: true.
4844 * @param {Number} value Any number between 0 and 1 (e.g., .5)
4845 * @param {String} text (optional) If defined, the message box's body text is replaced with the specified string (defaults to undefined)
4846 * @return {Roo.MessageBox} This message box
4848 updateProgress : function(value, text){
4850 this.updateText(text);
4853 if (pp) { // weird bug on my firefox - for some reason this is not defined
4854 pp.setWidth(Math.floor(value*progressEl.dom.firstChild.offsetWidth));
4855 pp.setHeight(Math.floor(progressEl.dom.firstChild.offsetHeight));
4861 * Returns true if the message box is currently displayed
4862 * @return {Boolean} True if the message box is visible, else false
4864 isVisible : function(){
4865 return dlg && dlg.isVisible();
4869 * Hides the message box if it is displayed
4872 if(this.isVisible()){
4878 * Displays a new message box, or reinitializes an existing message box, based on the config options
4879 * passed in. All functions (e.g. prompt, alert, etc) on MessageBox call this function internally.
4880 * The following config object properties are supported:
4882 Property Type Description
4883 ---------- --------------- ------------------------------------------------------------------------------------
4884 animEl String/Element An id or Element from which the message box should animate as it opens and
4885 closes (defaults to undefined)
4886 buttons Object/Boolean A button config object (e.g., Roo.MessageBox.OKCANCEL or {ok:'Foo',
4887 cancel:'Bar'}), or false to not show any buttons (defaults to false)
4888 closable Boolean False to hide the top-right close button (defaults to true). Note that
4889 progress and wait dialogs will ignore this property and always hide the
4890 close button as they can only be closed programmatically.
4891 cls String A custom CSS class to apply to the message box element
4892 defaultTextHeight Number The default height in pixels of the message box's multiline textarea if
4893 displayed (defaults to 75)
4894 fn Function A callback function to execute after closing the dialog. The arguments to the
4895 function will be btn (the name of the button that was clicked, if applicable,
4896 e.g. "ok"), and text (the value of the active text field, if applicable).
4897 Progress and wait dialogs will ignore this option since they do not respond to
4898 user actions and can only be closed programmatically, so any required function
4899 should be called by the same code after it closes the dialog.
4900 icon String A CSS class that provides a background image to be used as an icon for
4901 the dialog (e.g., Roo.MessageBox.WARNING or 'custom-class', defaults to '')
4902 maxWidth Number The maximum width in pixels of the message box (defaults to 600)
4903 minWidth Number The minimum width in pixels of the message box (defaults to 100)
4904 modal Boolean False to allow user interaction with the page while the message box is
4905 displayed (defaults to true)
4906 msg String A string that will replace the existing message box body text (defaults
4907 to the XHTML-compliant non-breaking space character ' ')
4908 multiline Boolean True to prompt the user to enter multi-line text (defaults to false)
4909 progress Boolean True to display a progress bar (defaults to false)
4910 progressText String The text to display inside the progress bar if progress = true (defaults to '')
4911 prompt Boolean True to prompt the user to enter single-line text (defaults to false)
4912 proxyDrag Boolean True to display a lightweight proxy while dragging (defaults to false)
4913 title String The title text
4914 value String The string value to set into the active textbox element if displayed
4915 wait Boolean True to display a progress bar (defaults to false)
4916 width Number The width of the dialog in pixels
4923 msg: 'Please enter your address:',
4925 buttons: Roo.MessageBox.OKCANCEL,
4928 animEl: 'addAddressBtn'
4931 * @param {Object} config Configuration options
4932 * @return {Roo.MessageBox} This message box
4934 show : function(options)
4937 // this causes nightmares if you show one dialog after another
4938 // especially on callbacks..
4940 if(this.isVisible()){
4943 Roo.log("[Roo.Messagebox] Show called while message displayed:" );
4944 Roo.log("Old Dialog Message:" + msgEl.innerHTML );
4945 Roo.log("New Dialog Message:" + options.msg )
4946 //this.alert("ERROR", "Multiple dialogs where displayed at the same time");
4947 //throw "Roo.MessageBox ERROR : Multiple dialogs where displayed at the same time";
4950 var d = this.getDialog();
4952 d.setTitle(opt.title || " ");
4953 d.closeEl.setDisplayed(opt.closable !== false);
4954 activeTextEl = textboxEl;
4955 opt.prompt = opt.prompt || (opt.multiline ? true : false);
4960 textareaEl.setHeight(typeof opt.multiline == "number" ?
4961 opt.multiline : this.defaultTextHeight);
4962 activeTextEl = textareaEl;
4971 progressEl.setDisplayed(opt.progress === true);
4973 d.animate = false; // do not animate progress, as it may not have finished animating before we close it..
4975 this.updateProgress(0);
4976 activeTextEl.dom.value = opt.value || "";
4978 dlg.setDefaultButton(activeTextEl);
4980 var bs = opt.buttons;
4984 }else if(bs && bs.yes){
4985 db = buttons["yes"];
4987 dlg.setDefaultButton(db);
4989 bwidth = updateButtons(opt.buttons);
4990 this.updateText(opt.msg);
4992 d.el.addClass(opt.cls);
4994 d.proxyDrag = opt.proxyDrag === true;
4995 d.modal = opt.modal !== false;
4996 d.mask = opt.modal !== false ? mask : false;
4998 // force it to the end of the z-index stack so it gets a cursor in FF
4999 document.body.appendChild(dlg.el.dom);
5000 d.animateTarget = null;
5001 d.show(options.animEl);
5007 * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
5008 * the user. You are responsible for updating the progress bar as needed via {@link Roo.MessageBox#updateProgress}
5009 * and closing the message box when the process is complete.
5010 * @param {String} title The title bar text
5011 * @param {String} msg The message box body text
5012 * @return {Roo.MessageBox} This message box
5014 progress : function(title, msg){
5021 minWidth: this.minProgressWidth,
5028 * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
5029 * If a callback function is passed it will be called after the user clicks the button, and the
5030 * id of the button that was clicked will be passed as the only parameter to the callback
5031 * (could also be the top-right close button).
5032 * @param {String} title The title bar text
5033 * @param {String} msg The message box body text
5034 * @param {Function} fn (optional) The callback function invoked after the message box is closed
5035 * @param {Object} scope (optional) The scope of the callback function
5036 * @return {Roo.MessageBox} This message box
5038 alert : function(title, msg, fn, scope)
5053 * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
5054 * interaction while waiting for a long-running process to complete that does not have defined intervals.
5055 * You are responsible for closing the message box when the process is complete.
5056 * @param {String} msg The message box body text
5057 * @param {String} title (optional) The title bar text
5058 * @return {Roo.MessageBox} This message box
5060 wait : function(msg, title){
5071 waitTimer = Roo.TaskMgr.start({
5073 Roo.MessageBox.updateProgress(((((i+20)%20)+1)*5)*.01);
5081 * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
5082 * If a callback function is passed it will be called after the user clicks either button, and the id of the
5083 * button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
5084 * @param {String} title The title bar text
5085 * @param {String} msg The message box body text
5086 * @param {Function} fn (optional) The callback function invoked after the message box is closed
5087 * @param {Object} scope (optional) The scope of the callback function
5088 * @return {Roo.MessageBox} This message box
5090 confirm : function(title, msg, fn, scope){
5094 buttons: this.YESNO,
5103 * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to
5104 * JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function
5105 * is passed it will be called after the user clicks either button, and the id of the button that was clicked
5106 * (could also be the top-right close button) and the text that was entered will be passed as the two
5107 * parameters to the callback.
5108 * @param {String} title The title bar text
5109 * @param {String} msg The message box body text
5110 * @param {Function} fn (optional) The callback function invoked after the message box is closed
5111 * @param {Object} scope (optional) The scope of the callback function
5112 * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
5113 * property, or the height in pixels to create the textbox (defaults to false / single-line)
5114 * @return {Roo.MessageBox} This message box
5116 prompt : function(title, msg, fn, scope, multiline){
5120 buttons: this.OKCANCEL,
5125 multiline: multiline,
5132 * Button config that displays a single OK button
5137 * Button config that displays Yes and No buttons
5140 YESNO : {yes:true, no:true},
5142 * Button config that displays OK and Cancel buttons
5145 OKCANCEL : {ok:true, cancel:true},
5147 * Button config that displays Yes, No and Cancel buttons
5150 YESNOCANCEL : {yes:true, no:true, cancel:true},
5153 * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
5156 defaultTextHeight : 75,
5158 * The maximum width in pixels of the message box (defaults to 600)
5163 * The minimum width in pixels of the message box (defaults to 100)
5168 * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
5169 * for setting a different minimum width than text-only dialogs may need (defaults to 250)
5172 minProgressWidth : 250,
5174 * An object containing the default button text strings that can be overriden for localized language support.
5175 * Supported properties are: ok, cancel, yes and no.
5176 * Customize the default text like so: Roo.MessageBox.buttonText.yes = "S?";
5189 * Shorthand for {@link Roo.MessageBox}
5191 Roo.MessageBox = Roo.MessageBox || Roo.bootstrap.MessageBox;
5192 Roo.Msg = Roo.Msg || Roo.MessageBox;
5201 * @class Roo.bootstrap.Navbar
5202 * @extends Roo.bootstrap.Component
5203 * Bootstrap Navbar class
5206 * Create a new Navbar
5207 * @param {Object} config The config object
5211 Roo.bootstrap.Navbar = function(config){
5212 Roo.bootstrap.Navbar.superclass.constructor.call(this, config);
5216 * @event beforetoggle
5217 * Fire before toggle the menu
5218 * @param {Roo.EventObject} e
5220 "beforetoggle" : true
5224 Roo.extend(Roo.bootstrap.Navbar, Roo.bootstrap.Component, {
5233 getAutoCreate : function(){
5236 throw { message : "nav bar is now a abstract base class - use NavSimplebar / NavHeaderbar / NavSidebar etc..."};
5240 initEvents :function ()
5242 //Roo.log(this.el.select('.navbar-toggle',true));
5243 this.el.select('.navbar-toggle',true).on('click', this.onToggle , this);
5250 this.maskEl = Roo.DomHelper.append(this.el, mark, true);
5252 var size = this.el.getSize();
5253 this.maskEl.setSize(size.width, size.height);
5254 this.maskEl.enableDisplayMode("block");
5263 getChildContainer : function()
5265 if (this.el && this.el.select('.collapse').getCount()) {
5266 return this.el.select('.collapse',true).first();
5281 onToggle : function()
5284 if(this.fireEvent('beforetoggle', this) === false){
5287 var ce = this.el.select('.navbar-collapse',true).first();
5289 if (!ce.hasClass('show')) {
5299 * Expand the navbar pulldown
5301 expand : function ()
5304 var ce = this.el.select('.navbar-collapse',true).first();
5305 if (ce.hasClass('collapsing')) {
5308 ce.dom.style.height = '';
5310 ce.addClass('in'); // old...
5311 ce.removeClass('collapse');
5312 ce.addClass('show');
5313 var h = ce.getHeight();
5315 ce.removeClass('show');
5316 // at this point we should be able to see it..
5317 ce.addClass('collapsing');
5319 ce.setHeight(0); // resize it ...
5320 ce.on('transitionend', function() {
5321 //Roo.log('done transition');
5322 ce.removeClass('collapsing');
5323 ce.addClass('show');
5324 ce.removeClass('collapse');
5326 ce.dom.style.height = '';
5327 }, this, { single: true} );
5329 ce.dom.scrollTop = 0;
5332 * Collapse the navbar pulldown
5334 collapse : function()
5336 var ce = this.el.select('.navbar-collapse',true).first();
5338 if (ce.hasClass('collapsing') || ce.hasClass('collapse') ) {
5339 // it's collapsed or collapsing..
5342 ce.removeClass('in'); // old...
5343 ce.setHeight(ce.getHeight());
5344 ce.removeClass('show');
5345 ce.addClass('collapsing');
5347 ce.on('transitionend', function() {
5348 ce.dom.style.height = '';
5349 ce.removeClass('collapsing');
5350 ce.addClass('collapse');
5351 }, this, { single: true} );
5371 * @class Roo.bootstrap.NavSimplebar
5372 * @extends Roo.bootstrap.Navbar
5373 * Bootstrap Sidebar class
5375 * @cfg {Boolean} inverse is inverted color
5377 * @cfg {String} type (nav | pills | tabs)
5378 * @cfg {Boolean} arrangement stacked | justified
5379 * @cfg {String} align (left | right) alignment
5381 * @cfg {Boolean} main (true|false) main nav bar? default false
5382 * @cfg {Boolean} loadMask (true|false) loadMask on the bar
5384 * @cfg {String} tag (header|footer|nav|div) default is nav
5386 * @cfg {String} weight (light|primary|secondary|success|danger|warning|info|dark|white) default is light.
5390 * Create a new Sidebar
5391 * @param {Object} config The config object
5395 Roo.bootstrap.NavSimplebar = function(config){
5396 Roo.bootstrap.NavSimplebar.superclass.constructor.call(this, config);
5399 Roo.extend(Roo.bootstrap.NavSimplebar, Roo.bootstrap.Navbar, {
5415 getAutoCreate : function(){
5419 tag : this.tag || 'div',
5420 cls : 'navbar roo-navbar-simple' //navbar-expand-lg ??
5422 if (['light','white'].indexOf(this.weight) > -1) {
5423 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
5425 cfg.cls += ' bg-' + this.weight;
5428 cfg.cls += ' navbar-inverse';
5432 // i'm not actually sure these are really used - normally we add a navGroup to a navbar
5434 if (Roo.bootstrap.version == 4 && this.xtype == 'NavSimplebar') {
5443 cls: 'nav nav-' + this.xtype,
5449 this.type = this.type || 'nav';
5450 if (['tabs','pills'].indexOf(this.type) != -1) {
5451 cfg.cn[0].cls += ' nav-' + this.type
5455 if (this.type!=='nav') {
5456 Roo.log('nav type must be nav/tabs/pills')
5458 cfg.cn[0].cls += ' navbar-nav'
5464 if (['stacked','justified'].indexOf(this.arrangement) != -1) {
5465 cfg.cn[0].cls += ' nav-' + this.arrangement;
5469 if (this.align === 'right') {
5470 cfg.cn[0].cls += ' navbar-right';
5495 * navbar-expand-md fixed-top
5499 * @class Roo.bootstrap.NavHeaderbar
5500 * @extends Roo.bootstrap.NavSimplebar
5501 * Bootstrap Sidebar class
5503 * @cfg {String} brand what is brand
5504 * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
5505 * @cfg {String} brand_href href of the brand
5506 * @cfg {Boolean} srButton generate the (screen reader / mobile) sr-only button default true
5507 * @cfg {Boolean} autohide a top nav bar header that hides on scroll.
5508 * @cfg {Boolean} desktopCenter should the header be centered on desktop using a container class
5509 * @cfg {Roo.bootstrap.Row} mobilerow - a row to display on mobile only..
5512 * Create a new Sidebar
5513 * @param {Object} config The config object
5517 Roo.bootstrap.NavHeaderbar = function(config){
5518 Roo.bootstrap.NavHeaderbar.superclass.constructor.call(this, config);
5522 Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar, {
5529 desktopCenter : false,
5532 getAutoCreate : function(){
5535 tag: this.nav || 'nav',
5536 cls: 'navbar navbar-expand-md',
5542 if (this.desktopCenter) {
5543 cn.push({cls : 'container', cn : []});
5551 cls: 'navbar-toggle navbar-toggler',
5552 'data-toggle': 'collapse',
5557 html: 'Toggle navigation'
5561 cls: 'icon-bar navbar-toggler-icon'
5574 cn.push( Roo.bootstrap.version == 4 ? btn : {
5576 cls: 'navbar-header',
5585 cls: Roo.bootstrap.version == 4 ? 'nav flex-row roo-navbar-collapse collapse navbar-collapse' : 'collapse navbar-collapse roo-navbar-collapse',
5589 cfg.cls += this.inverse ? ' navbar-inverse navbar-dark bg-dark' : ' navbar-default';
5591 if (['light','white'].indexOf(this.weight) > -1) {
5592 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
5594 cfg.cls += ' bg-' + this.weight;
5597 if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
5598 cfg.cls += ' navbar-' + this.position + ' ' + this.position ;
5600 // tag can override this..
5602 cfg.tag = this.tag || (this.position == 'fixed-bottom' ? 'footer' : 'header');
5605 if (this.brand !== '') {
5606 var cp = Roo.bootstrap.version == 4 ? cn : cn[0].cn;
5607 cp.unshift({ // changed from push ?? BS4 needs it at the start? - does this break or exsiting?
5609 href: this.brand_href ? this.brand_href : '#',
5610 cls: 'navbar-brand',
5618 cfg.cls += ' main-nav';
5626 getHeaderChildContainer : function()
5628 if (this.srButton && this.el.select('.navbar-header').getCount()) {
5629 return this.el.select('.navbar-header',true).first();
5632 return this.getChildContainer();
5635 getChildContainer : function()
5638 return this.el.select('.roo-navbar-collapse',true).first();
5643 initEvents : function()
5645 Roo.bootstrap.NavHeaderbar.superclass.initEvents.call(this);
5647 if (this.autohide) {
5652 Roo.get(document).on('scroll',function(e) {
5653 var ns = Roo.get(document).getScroll().top;
5654 var os = prevScroll;
5658 ft.removeClass('slideDown');
5659 ft.addClass('slideUp');
5662 ft.removeClass('slideUp');
5663 ft.addClass('slideDown');
5684 * @class Roo.bootstrap.NavSidebar
5685 * @extends Roo.bootstrap.Navbar
5686 * Bootstrap Sidebar class
5689 * Create a new Sidebar
5690 * @param {Object} config The config object
5694 Roo.bootstrap.NavSidebar = function(config){
5695 Roo.bootstrap.NavSidebar.superclass.constructor.call(this, config);
5698 Roo.extend(Roo.bootstrap.NavSidebar, Roo.bootstrap.Navbar, {
5700 sidebar : true, // used by Navbar Item and NavbarGroup at present...
5702 getAutoCreate : function(){
5707 cls: 'sidebar sidebar-nav'
5729 * @class Roo.bootstrap.NavGroup
5730 * @extends Roo.bootstrap.Component
5731 * Bootstrap NavGroup class
5732 * @cfg {String} align (left|right)
5733 * @cfg {Boolean} inverse
5734 * @cfg {String} type (nav|pills|tab) default nav
5735 * @cfg {String} navId - reference Id for navbar.
5736 * @cfg {Boolean} pilltype default true (turn to off to disable active toggle)
5739 * Create a new nav group
5740 * @param {Object} config The config object
5743 Roo.bootstrap.NavGroup = function(config){
5744 Roo.bootstrap.NavGroup.superclass.constructor.call(this, config);
5747 Roo.bootstrap.NavGroup.register(this);
5751 * Fires when the active item changes
5752 * @param {Roo.bootstrap.NavGroup} this
5753 * @param {Roo.bootstrap.Navbar.Item} selected The item selected
5754 * @param {Roo.bootstrap.Navbar.Item} prev The previously selected item
5761 Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, {
5773 getAutoCreate : function()
5775 var cfg = Roo.apply({}, Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));
5781 if (Roo.bootstrap.version == 4) {
5782 if (['tabs','pills'].indexOf(this.type) != -1) {
5783 cfg.cls += ' nav-' + this.type;
5785 // trying to remove so header bar can right align top?
5786 if (this.parent() && this.parent().xtype != 'NavHeaderbar') {
5787 // do not use on header bar...
5788 cfg.cls += ' navbar-nav';
5793 if (['tabs','pills'].indexOf(this.type) != -1) {
5794 cfg.cls += ' nav-' + this.type
5796 if (this.type !== 'nav') {
5797 Roo.log('nav type must be nav/tabs/pills')
5799 cfg.cls += ' navbar-nav'
5803 if (this.parent() && this.parent().sidebar) {
5806 cls: 'dashboard-menu sidebar-menu'
5812 if (this.form === true) {
5815 cls: 'navbar-form form-inline'
5817 //nav navbar-right ml-md-auto
5818 if (this.align === 'right') {
5819 cfg.cls += ' navbar-right ml-md-auto';
5821 cfg.cls += ' navbar-left';
5825 if (this.align === 'right') {
5826 cfg.cls += ' navbar-right ml-md-auto';
5828 cfg.cls += ' mr-auto';
5832 cfg.cls += ' navbar-inverse';
5840 * sets the active Navigation item
5841 * @param {Roo.bootstrap.NavItem} the new current navitem
5843 setActiveItem : function(item)
5846 Roo.each(this.navItems, function(v){
5851 v.setActive(false, true);
5858 item.setActive(true, true);
5859 this.fireEvent('changed', this, item, prev);
5864 * gets the active Navigation item
5865 * @return {Roo.bootstrap.NavItem} the current navitem
5867 getActive : function()
5871 Roo.each(this.navItems, function(v){
5882 indexOfNav : function()
5886 Roo.each(this.navItems, function(v,i){
5897 * adds a Navigation item
5898 * @param {Roo.bootstrap.NavItem} the navitem to add
5900 addItem : function(cfg)
5902 if (this.form && Roo.bootstrap.version == 4) {
5905 var cn = new Roo.bootstrap.NavItem(cfg);
5907 cn.parentId = this.id;
5908 cn.onRender(this.el, null);
5912 * register a Navigation item
5913 * @param {Roo.bootstrap.NavItem} the navitem to add
5915 register : function(item)
5917 this.navItems.push( item);
5918 item.navId = this.navId;
5923 * clear all the Navigation item
5926 clearAll : function()
5929 this.el.dom.innerHTML = '';
5932 getNavItem: function(tabId)
5935 Roo.each(this.navItems, function(e) {
5936 if (e.tabId == tabId) {
5946 setActiveNext : function()
5948 var i = this.indexOfNav(this.getActive());
5949 if (i > this.navItems.length) {
5952 this.setActiveItem(this.navItems[i+1]);
5954 setActivePrev : function()
5956 var i = this.indexOfNav(this.getActive());
5960 this.setActiveItem(this.navItems[i-1]);
5962 clearWasActive : function(except) {
5963 Roo.each(this.navItems, function(e) {
5964 if (e.tabId != except.tabId && e.was_active) {
5965 e.was_active = false;
5972 getWasActive : function ()
5975 Roo.each(this.navItems, function(e) {
5990 Roo.apply(Roo.bootstrap.NavGroup, {
5994 * register a Navigation Group
5995 * @param {Roo.bootstrap.NavGroup} the navgroup to add
5997 register : function(navgrp)
5999 this.groups[navgrp.navId] = navgrp;
6003 * fetch a Navigation Group based on the navigation ID
6004 * @param {string} the navgroup to add
6005 * @returns {Roo.bootstrap.NavGroup} the navgroup
6007 get: function(navId) {
6008 if (typeof(this.groups[navId]) == 'undefined') {
6010 //this.register(new Roo.bootstrap.NavGroup({ navId : navId }));
6012 return this.groups[navId] ;
6027 * @class Roo.bootstrap.NavItem
6028 * @extends Roo.bootstrap.Component
6029 * Bootstrap Navbar.NavItem class
6030 * @cfg {String} href link to
6031 * @cfg {String} button_weight (default|primary|secondary|success|info|warning|danger|link|light|dark) default none
6032 * @cfg {Boolean} button_outline show and outlined button
6033 * @cfg {String} html content of button
6034 * @cfg {String} badge text inside badge
6035 * @cfg {String} badgecls (bg-green|bg-red|bg-yellow)the extra classes for the badge
6036 * @cfg {String} glyphicon DEPRICATED - use fa
6037 * @cfg {String} icon DEPRICATED - use fa
6038 * @cfg {String} fa - Fontawsome icon name (can add stuff to it like fa-2x)
6039 * @cfg {Boolean} active Is item active
6040 * @cfg {Boolean} disabled Is item disabled
6041 * @cfg {String} linkcls Link Class
6042 * @cfg {Boolean} preventDefault (true | false) default false
6043 * @cfg {String} tabId the tab that this item activates.
6044 * @cfg {String} tagtype (a|span) render as a href or span?
6045 * @cfg {Boolean} animateRef (true|false) link to element default false
6048 * Create a new Navbar Item
6049 * @param {Object} config The config object
6051 Roo.bootstrap.NavItem = function(config){
6052 Roo.bootstrap.NavItem.superclass.constructor.call(this, config);
6057 * The raw click event for the entire grid.
6058 * @param {Roo.EventObject} e
6063 * Fires when the active item active state changes
6064 * @param {Roo.bootstrap.NavItem} this
6065 * @param {boolean} state the new state
6071 * Fires when scroll to element
6072 * @param {Roo.bootstrap.NavItem} this
6073 * @param {Object} options
6074 * @param {Roo.EventObject} e
6082 Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, {
6091 preventDefault : false,
6099 button_outline : false,
6103 getAutoCreate : function(){
6110 cfg.cls = typeof(cfg.cls) == 'undefined' ? '' : cfg.cls;
6113 cfg.cls += ' active' ;
6115 if (this.disabled) {
6116 cfg.cls += ' disabled';
6120 if (this.button_weight.length) {
6121 cfg.tag = this.href ? 'a' : 'button';
6122 cfg.html = this.html || '';
6123 cfg.cls += ' btn btn' + (this.button_outline ? '-outline' : '') + '-' + this.button_weight;
6125 cfg.href = this.href;
6128 cfg.html = '<i class="fa fas fa-'+this.fa+'"></i> <span>' + this.html + '</span>';
6131 // menu .. should add dropdown-menu class - so no need for carat..
6133 if (this.badge !== '') {
6135 cfg.html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
6140 if (this.href || this.html || this.glyphicon || this.icon || this.fa) {
6144 href : this.href || "#",
6145 html: this.html || ''
6148 if (this.tagtype == 'a') {
6149 cfg.cn[0].cls = 'nav-link' + (this.active ? ' active' : '') + ' ' + this.linkcls;
6153 cfg.cn[0].html = '<i class="'+this.icon+'"></i> <span>' + cfg.cn[0].html + '</span>';
6156 cfg.cn[0].html = '<i class="fa fas fa-'+this.fa+'"></i> <span>' + cfg.cn[0].html + '</span>';
6158 if(this.glyphicon) {
6159 cfg.cn[0].html = '<span class="glyphicon glyphicon-' + this.glyphicon + '"></span> ' + cfg.cn[0].html;
6164 cfg.cn[0].html += " <span class='caret'></span>";
6168 if (this.badge !== '') {
6170 cfg.cn[0].html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
6178 onRender : function(ct, position)
6180 // Roo.log("Call onRender: " + this.xtype);
6181 if (Roo.bootstrap.version == 4 && ct.dom.type != 'ul') {
6185 var ret = Roo.bootstrap.NavItem.superclass.onRender.call(this, ct, position);
6186 this.navLink = this.el.select('.nav-link',true).first();
6191 initEvents: function()
6193 if (typeof (this.menu) != 'undefined') {
6194 this.menu.parentType = this.xtype;
6195 this.menu.triggerEl = this.el;
6196 this.menu = this.addxtype(Roo.apply({}, this.menu));
6199 this.el.on('click', this.onClick, this);
6201 //if(this.tagtype == 'span'){
6202 // this.el.select('span',true).on('click', this.onClick, this);
6205 // at this point parent should be available..
6206 this.parent().register(this);
6209 onClick : function(e)
6211 if (e.getTarget('.dropdown-menu-item')) {
6212 // did you click on a menu itemm.... - then don't trigger onclick..
6217 this.preventDefault ||
6220 Roo.log("NavItem - prevent Default?");
6224 if (this.disabled) {
6228 var tg = Roo.bootstrap.TabGroup.get(this.navId);
6229 if (tg && tg.transition) {
6230 Roo.log("waiting for the transitionend");
6236 //Roo.log("fire event clicked");
6237 if(this.fireEvent('click', this, e) === false){
6241 if(this.tagtype == 'span'){
6245 //Roo.log(this.href);
6246 var ael = this.el.select('a',true).first();
6249 if(ael && this.animateRef && this.href.indexOf('#') > -1){
6250 //Roo.log(["test:",ael.dom.href.split("#")[0], document.location.toString().split("#")[0]]);
6251 if (ael.dom.href.split("#")[0] != document.location.toString().split("#")[0]) {
6252 return; // ignore... - it's a 'hash' to another page.
6254 Roo.log("NavItem - prevent Default?");
6256 this.scrollToElement(e);
6260 var p = this.parent();
6262 if (['tabs','pills'].indexOf(p.type)!==-1 && p.pilltype) {
6263 if (typeof(p.setActiveItem) !== 'undefined') {
6264 p.setActiveItem(this);
6268 // if parent is a navbarheader....- and link is probably a '#' page ref.. then remove the expanded menu.
6269 if (p.parentType == 'NavHeaderbar' && !this.menu) {
6270 // remove the collapsed menu expand...
6271 p.parent().el.select('.roo-navbar-collapse',true).removeClass('in');
6275 isActive: function () {
6278 setActive : function(state, fire, is_was_active)
6280 if (this.active && !state && this.navId) {
6281 this.was_active = true;
6282 var nv = Roo.bootstrap.NavGroup.get(this.navId);
6284 nv.clearWasActive(this);
6288 this.active = state;
6291 this.el.removeClass('active');
6292 this.navLink ? this.navLink.removeClass('active') : false;
6293 } else if (!this.el.hasClass('active')) {
6295 this.el.addClass('active');
6296 if (Roo.bootstrap.version == 4 && this.navLink ) {
6297 this.navLink.addClass('active');
6302 this.fireEvent('changed', this, state);
6305 // show a panel if it's registered and related..
6307 if (!this.navId || !this.tabId || !state || is_was_active) {
6311 var tg = Roo.bootstrap.TabGroup.get(this.navId);
6315 var pan = tg.getPanelByName(this.tabId);
6319 // if we can not flip to new panel - go back to old nav highlight..
6320 if (false == tg.showPanel(pan)) {
6321 var nv = Roo.bootstrap.NavGroup.get(this.navId);
6323 var onav = nv.getWasActive();
6325 onav.setActive(true, false, true);
6334 // this should not be here...
6335 setDisabled : function(state)
6337 this.disabled = state;
6339 this.el.removeClass('disabled');
6340 } else if (!this.el.hasClass('disabled')) {
6341 this.el.addClass('disabled');
6347 * Fetch the element to display the tooltip on.
6348 * @return {Roo.Element} defaults to this.el
6350 tooltipEl : function()
6352 return this.el; //this.tagtype == 'a' ? this.el : this.el.select('' + this.tagtype + '', true).first();
6355 scrollToElement : function(e)
6357 var c = document.body;
6360 * Firefox / IE places the overflow at the html level, unless specifically styled to behave differently.
6362 if(Roo.isFirefox || Roo.isIE || Roo.isIE11){
6363 c = document.documentElement;
6366 var target = Roo.get(c).select('a[name=' + this.href.split('#')[1] +']', true).first();
6372 var o = target.calcOffsetsTo(c);
6379 this.fireEvent('scrollto', this, options, e);
6381 Roo.get(c).scrollTo('top', options.value, true);
6394 * <span> icon </span>
6395 * <span> text </span>
6396 * <span>badge </span>
6400 * @class Roo.bootstrap.NavSidebarItem
6401 * @extends Roo.bootstrap.NavItem
6402 * Bootstrap Navbar.NavSidebarItem class
6403 * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
6404 * {Boolean} open is the menu open
6405 * {Boolean} buttonView use button as the tigger el rather that a (default false)
6406 * {String} buttonWeight (default|primary|success|info|warning|danger)the extra classes for the button
6407 * {String} buttonSize (sm|md|lg)the extra classes for the button
6408 * {Boolean} showArrow show arrow next to the text (default true)
6410 * Create a new Navbar Button
6411 * @param {Object} config The config object
6413 Roo.bootstrap.NavSidebarItem = function(config){
6414 Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this, config);
6419 * The raw click event for the entire grid.
6420 * @param {Roo.EventObject} e
6425 * Fires when the active item active state changes
6426 * @param {Roo.bootstrap.NavSidebarItem} this
6427 * @param {boolean} state the new state
6435 Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem, {
6437 badgeWeight : 'default',
6443 buttonWeight : 'default',
6449 getAutoCreate : function(){
6454 href : this.href || '#',
6460 if(this.buttonView){
6463 href : this.href || '#',
6464 cls: 'btn btn-' + this.buttonWeight + ' btn-' + this.buttonSize + 'roo-button-dropdown-toggle',
6477 cfg.cls += ' active';
6480 if (this.disabled) {
6481 cfg.cls += ' disabled';
6484 cfg.cls += ' open x-open';
6487 if (this.glyphicon || this.icon) {
6488 var c = this.glyphicon ? ('glyphicon glyphicon-'+this.glyphicon) : this.icon;
6489 a.cn.push({ tag : 'i', cls : c }) ;
6492 if(!this.buttonView){
6495 html : this.html || ''
6502 if (this.badge !== '') {
6503 a.cn.push({ tag: 'span', cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge });
6509 a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
6512 a.cls += ' dropdown-toggle treeview' ;
6518 initEvents : function()
6520 if (typeof (this.menu) != 'undefined') {
6521 this.menu.parentType = this.xtype;
6522 this.menu.triggerEl = this.el;
6523 this.menu = this.addxtype(Roo.apply({}, this.menu));
6526 this.el.on('click', this.onClick, this);
6528 if(this.badge !== ''){
6529 this.badgeEl = this.el.select('.badge', true).first().setVisibilityMode(Roo.Element.DISPLAY);
6534 onClick : function(e)
6541 if(this.preventDefault){
6545 this.fireEvent('click', this, e);
6548 disable : function()
6550 this.setDisabled(true);
6555 this.setDisabled(false);
6558 setDisabled : function(state)
6560 if(this.disabled == state){
6564 this.disabled = state;
6567 this.el.addClass('disabled');
6571 this.el.removeClass('disabled');
6576 setActive : function(state)
6578 if(this.active == state){
6582 this.active = state;
6585 this.el.addClass('active');
6589 this.el.removeClass('active');
6594 isActive: function ()
6599 setBadge : function(str)
6605 this.badgeEl.dom.innerHTML = str;
6620 Roo.namespace('Roo.bootstrap.breadcrumb');
6624 * @class Roo.bootstrap.breadcrumb.Nav
6625 * @extends Roo.bootstrap.Component
6626 * Bootstrap Breadcrumb Nav Class
6628 * @children Roo.bootstrap.breadcrumb.Item
6631 * Create a new breadcrumb.Nav
6632 * @param {Object} config The config object
6636 Roo.bootstrap.breadcrumb.Nav = function(config){
6637 Roo.bootstrap.breadcrumb.Nav.superclass.constructor.call(this, config);
6642 Roo.extend(Roo.bootstrap.breadcrumb.Nav, Roo.bootstrap.Component, {
6644 getAutoCreate : function()
6661 initEvents: function()
6663 this.olEl = this.el.select('ol',true).first();
6665 getChildContainer : function()
6681 * @class Roo.bootstrap.breadcrumb.Nav
6682 * @extends Roo.bootstrap.Component
6683 * Bootstrap Breadcrumb Nav Class
6685 * @children Roo.bootstrap.breadcrumb.Component
6686 * @cfg {String} html the content of the link.
6687 * @cfg {String} href where it links to if '#' is used the link will be handled by onClick.
6688 * @cfg {Boolean} active is it active
6692 * Create a new breadcrumb.Nav
6693 * @param {Object} config The config object
6696 Roo.bootstrap.breadcrumb.Item = function(config){
6697 Roo.bootstrap.breadcrumb.Item.superclass.constructor.call(this, config);
6702 * The img click event for the img.
6703 * @param {Roo.EventObject} e
6710 Roo.extend(Roo.bootstrap.breadcrumb.Item, Roo.bootstrap.Component, {
6715 getAutoCreate : function()
6720 cls : 'breadcrumb-item' + (this.active ? ' active' : '')
6722 if (this.href !== false) {
6729 cfg.html = this.html;
6735 initEvents: function()
6738 this.el.select('a', true).first().on('click',this.onClick, this)
6742 onClick : function(e)
6745 this.fireEvent('click',this, e);
6758 * @class Roo.bootstrap.Row
6759 * @extends Roo.bootstrap.Component
6760 * Bootstrap Row class (contains columns...)
6764 * @param {Object} config The config object
6767 Roo.bootstrap.Row = function(config){
6768 Roo.bootstrap.Row.superclass.constructor.call(this, config);
6771 Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component, {
6773 getAutoCreate : function(){
6792 * @class Roo.bootstrap.Pagination
6793 * @extends Roo.bootstrap.Component
6794 * Bootstrap Pagination class
6795 * @cfg {String} size xs | sm | md | lg
6796 * @cfg {Boolean} inverse false | true
6799 * Create a new Pagination
6800 * @param {Object} config The config object
6803 Roo.bootstrap.Pagination = function(config){
6804 Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
6807 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component, {
6813 getAutoCreate : function(){
6819 cfg.cls += ' inverse';
6825 cfg.cls += " " + this.cls;
6843 * @class Roo.bootstrap.PaginationItem
6844 * @extends Roo.bootstrap.Component
6845 * Bootstrap PaginationItem class
6846 * @cfg {String} html text
6847 * @cfg {String} href the link
6848 * @cfg {Boolean} preventDefault (true | false) default true
6849 * @cfg {Boolean} active (true | false) default false
6850 * @cfg {Boolean} disabled default false
6854 * Create a new PaginationItem
6855 * @param {Object} config The config object
6859 Roo.bootstrap.PaginationItem = function(config){
6860 Roo.bootstrap.PaginationItem.superclass.constructor.call(this, config);
6865 * The raw click event for the entire grid.
6866 * @param {Roo.EventObject} e
6872 Roo.extend(Roo.bootstrap.PaginationItem, Roo.bootstrap.Component, {
6876 preventDefault: true,
6881 getAutoCreate : function(){
6887 href : this.href ? this.href : '#',
6888 html : this.html ? this.html : ''
6898 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' disabled' : 'disabled';
6902 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' active' : 'active';
6908 initEvents: function() {
6910 this.el.on('click', this.onClick, this);
6913 onClick : function(e)
6915 Roo.log('PaginationItem on click ');
6916 if(this.preventDefault){
6924 this.fireEvent('click', this, e);
6940 * @class Roo.bootstrap.Slider
6941 * @extends Roo.bootstrap.Component
6942 * Bootstrap Slider class
6945 * Create a new Slider
6946 * @param {Object} config The config object
6949 Roo.bootstrap.Slider = function(config){
6950 Roo.bootstrap.Slider.superclass.constructor.call(this, config);
6953 Roo.extend(Roo.bootstrap.Slider, Roo.bootstrap.Component, {
6955 getAutoCreate : function(){
6959 cls: 'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',
6963 cls: 'ui-slider-handle ui-state-default ui-corner-all'
6975 * Ext JS Library 1.1.1
6976 * Copyright(c) 2006-2007, Ext JS, LLC.
6978 * Originally Released Under LGPL - original licence link has changed is not relivant.
6981 * <script type="text/javascript">
6986 * @class Roo.grid.ColumnModel
6987 * @extends Roo.util.Observable
6988 * This is the default implementation of a ColumnModel used by the Grid. It defines
6989 * the columns in the grid.
6992 var colModel = new Roo.grid.ColumnModel([
6993 {header: "Ticker", width: 60, sortable: true, locked: true},
6994 {header: "Company Name", width: 150, sortable: true},
6995 {header: "Market Cap.", width: 100, sortable: true},
6996 {header: "$ Sales", width: 100, sortable: true, renderer: money},
6997 {header: "Employees", width: 100, sortable: true, resizable: false}
7002 * The config options listed for this class are options which may appear in each
7003 * individual column definition.
7004 * <br/>RooJS Fix - column id's are not sequential but use Roo.id() - fixes bugs with layouts.
7006 * @param {Object} config An Array of column config objects. See this class's
7007 * config objects for details.
7009 Roo.grid.ColumnModel = function(config){
7011 * The config passed into the constructor
7013 this.config = config;
7016 // if no id, create one
7017 // if the column does not have a dataIndex mapping,
7018 // map it to the order it is in the config
7019 for(var i = 0, len = config.length; i < len; i++){
7021 if(typeof c.dataIndex == "undefined"){
7024 if(typeof c.renderer == "string"){
7025 c.renderer = Roo.util.Format[c.renderer];
7027 if(typeof c.id == "undefined"){
7030 if(c.editor && c.editor.xtype){
7031 c.editor = Roo.factory(c.editor, Roo.grid);
7033 if(c.editor && c.editor.isFormField){
7034 c.editor = new Roo.grid.GridEditor(c.editor);
7036 this.lookup[c.id] = c;
7040 * The width of columns which have no width specified (defaults to 100)
7043 this.defaultWidth = 100;
7046 * Default sortable of columns which have no sortable specified (defaults to false)
7049 this.defaultSortable = false;
7053 * @event widthchange
7054 * Fires when the width of a column changes.
7055 * @param {ColumnModel} this
7056 * @param {Number} columnIndex The column index
7057 * @param {Number} newWidth The new width
7059 "widthchange": true,
7061 * @event headerchange
7062 * Fires when the text of a header changes.
7063 * @param {ColumnModel} this
7064 * @param {Number} columnIndex The column index
7065 * @param {Number} newText The new header text
7067 "headerchange": true,
7069 * @event hiddenchange
7070 * Fires when a column is hidden or "unhidden".
7071 * @param {ColumnModel} this
7072 * @param {Number} columnIndex The column index
7073 * @param {Boolean} hidden true if hidden, false otherwise
7075 "hiddenchange": true,
7077 * @event columnmoved
7078 * Fires when a column is moved.
7079 * @param {ColumnModel} this
7080 * @param {Number} oldIndex
7081 * @param {Number} newIndex
7083 "columnmoved" : true,
7085 * @event columlockchange
7086 * Fires when a column's locked state is changed
7087 * @param {ColumnModel} this
7088 * @param {Number} colIndex
7089 * @param {Boolean} locked true if locked
7091 "columnlockchange" : true
7093 Roo.grid.ColumnModel.superclass.constructor.call(this);
7095 Roo.extend(Roo.grid.ColumnModel, Roo.util.Observable, {
7097 * @cfg {String} header The header text to display in the Grid view.
7100 * @cfg {String} dataIndex (Optional) The name of the field in the grid's {@link Roo.data.Store}'s
7101 * {@link Roo.data.Record} definition from which to draw the column's value. If not
7102 * specified, the column's index is used as an index into the Record's data Array.
7105 * @cfg {Number} width (Optional) The initial width in pixels of the column. Using this
7106 * instead of {@link Roo.grid.Grid#autoSizeColumns} is more efficient.
7109 * @cfg {Boolean} sortable (Optional) True if sorting is to be allowed on this column.
7110 * Defaults to the value of the {@link #defaultSortable} property.
7111 * Whether local/remote sorting is used is specified in {@link Roo.data.Store#remoteSort}.
7114 * @cfg {Boolean} locked (Optional) True to lock the column in place while scrolling the Grid. Defaults to false.
7117 * @cfg {Boolean} fixed (Optional) True if the column width cannot be changed. Defaults to false.
7120 * @cfg {Boolean} resizable (Optional) False to disable column resizing. Defaults to true.
7123 * @cfg {Boolean} hidden (Optional) True to hide the column. Defaults to false.
7126 * @cfg {Function} renderer (Optional) A function used to generate HTML markup for a cell
7127 * given the cell's data value. See {@link #setRenderer}. If not specified, the
7128 * default renderer returns the escaped data value. If an object is returned (bootstrap only)
7129 * then it is treated as a Roo Component object instance, and it is rendered after the initial row is rendered
7132 * @cfg {Roo.grid.GridEditor} editor (Optional) For grid editors - returns the grid editor
7135 * @cfg {String} align (Optional) Set the CSS text-align property of the column. Defaults to undefined.
7138 * @cfg {String} valign (Optional) Set the CSS vertical-align property of the column (eg. middle, top, bottom etc). Defaults to undefined.
7141 * @cfg {String} cursor (Optional)
7144 * @cfg {String} tooltip (Optional)
7147 * @cfg {Number} xs (Optional)
7150 * @cfg {Number} sm (Optional)
7153 * @cfg {Number} md (Optional)
7156 * @cfg {Number} lg (Optional)
7159 * Returns the id of the column at the specified index.
7160 * @param {Number} index The column index
7161 * @return {String} the id
7163 getColumnId : function(index){
7164 return this.config[index].id;
7168 * Returns the column for a specified id.
7169 * @param {String} id The column id
7170 * @return {Object} the column
7172 getColumnById : function(id){
7173 return this.lookup[id];
7178 * Returns the column for a specified dataIndex.
7179 * @param {String} dataIndex The column dataIndex
7180 * @return {Object|Boolean} the column or false if not found
7182 getColumnByDataIndex: function(dataIndex){
7183 var index = this.findColumnIndex(dataIndex);
7184 return index > -1 ? this.config[index] : false;
7188 * Returns the index for a specified column id.
7189 * @param {String} id The column id
7190 * @return {Number} the index, or -1 if not found
7192 getIndexById : function(id){
7193 for(var i = 0, len = this.config.length; i < len; i++){
7194 if(this.config[i].id == id){
7202 * Returns the index for a specified column dataIndex.
7203 * @param {String} dataIndex The column dataIndex
7204 * @return {Number} the index, or -1 if not found
7207 findColumnIndex : function(dataIndex){
7208 for(var i = 0, len = this.config.length; i < len; i++){
7209 if(this.config[i].dataIndex == dataIndex){
7217 moveColumn : function(oldIndex, newIndex){
7218 var c = this.config[oldIndex];
7219 this.config.splice(oldIndex, 1);
7220 this.config.splice(newIndex, 0, c);
7221 this.dataMap = null;
7222 this.fireEvent("columnmoved", this, oldIndex, newIndex);
7225 isLocked : function(colIndex){
7226 return this.config[colIndex].locked === true;
7229 setLocked : function(colIndex, value, suppressEvent){
7230 if(this.isLocked(colIndex) == value){
7233 this.config[colIndex].locked = value;
7235 this.fireEvent("columnlockchange", this, colIndex, value);
7239 getTotalLockedWidth : function(){
7241 for(var i = 0; i < this.config.length; i++){
7242 if(this.isLocked(i) && !this.isHidden(i)){
7243 this.totalWidth += this.getColumnWidth(i);
7249 getLockedCount : function(){
7250 for(var i = 0, len = this.config.length; i < len; i++){
7251 if(!this.isLocked(i)){
7256 return this.config.length;
7260 * Returns the number of columns.
7263 getColumnCount : function(visibleOnly){
7264 if(visibleOnly === true){
7266 for(var i = 0, len = this.config.length; i < len; i++){
7267 if(!this.isHidden(i)){
7273 return this.config.length;
7277 * Returns the column configs that return true by the passed function that is called with (columnConfig, index)
7278 * @param {Function} fn
7279 * @param {Object} scope (optional)
7280 * @return {Array} result
7282 getColumnsBy : function(fn, scope){
7284 for(var i = 0, len = this.config.length; i < len; i++){
7285 var c = this.config[i];
7286 if(fn.call(scope||this, c, i) === true){
7294 * Returns true if the specified column is sortable.
7295 * @param {Number} col The column index
7298 isSortable : function(col){
7299 if(typeof this.config[col].sortable == "undefined"){
7300 return this.defaultSortable;
7302 return this.config[col].sortable;
7306 * Returns the rendering (formatting) function defined for the column.
7307 * @param {Number} col The column index.
7308 * @return {Function} The function used to render the cell. See {@link #setRenderer}.
7310 getRenderer : function(col){
7311 if(!this.config[col].renderer){
7312 return Roo.grid.ColumnModel.defaultRenderer;
7314 return this.config[col].renderer;
7318 * Sets the rendering (formatting) function for a column.
7319 * @param {Number} col The column index
7320 * @param {Function} fn The function to use to process the cell's raw data
7321 * to return HTML markup for the grid view. The render function is called with
7322 * the following parameters:<ul>
7323 * <li>Data value.</li>
7324 * <li>Cell metadata. An object in which you may set the following attributes:<ul>
7325 * <li>css A CSS style string to apply to the table cell.</li>
7326 * <li>attr An HTML attribute definition string to apply to the data container element <i>within</i> the table cell.</li></ul>
7327 * <li>The {@link Roo.data.Record} from which the data was extracted.</li>
7328 * <li>Row index</li>
7329 * <li>Column index</li>
7330 * <li>The {@link Roo.data.Store} object from which the Record was extracted</li></ul>
7332 setRenderer : function(col, fn){
7333 this.config[col].renderer = fn;
7337 * Returns the width for the specified column.
7338 * @param {Number} col The column index
7341 getColumnWidth : function(col){
7342 return this.config[col].width * 1 || this.defaultWidth;
7346 * Sets the width for a column.
7347 * @param {Number} col The column index
7348 * @param {Number} width The new width
7350 setColumnWidth : function(col, width, suppressEvent){
7351 this.config[col].width = width;
7352 this.totalWidth = null;
7354 this.fireEvent("widthchange", this, col, width);
7359 * Returns the total width of all columns.
7360 * @param {Boolean} includeHidden True to include hidden column widths
7363 getTotalWidth : function(includeHidden){
7364 if(!this.totalWidth){
7365 this.totalWidth = 0;
7366 for(var i = 0, len = this.config.length; i < len; i++){
7367 if(includeHidden || !this.isHidden(i)){
7368 this.totalWidth += this.getColumnWidth(i);
7372 return this.totalWidth;
7376 * Returns the header for the specified column.
7377 * @param {Number} col The column index
7380 getColumnHeader : function(col){
7381 return this.config[col].header;
7385 * Sets the header for a column.
7386 * @param {Number} col The column index
7387 * @param {String} header The new header
7389 setColumnHeader : function(col, header){
7390 this.config[col].header = header;
7391 this.fireEvent("headerchange", this, col, header);
7395 * Returns the tooltip for the specified column.
7396 * @param {Number} col The column index
7399 getColumnTooltip : function(col){
7400 return this.config[col].tooltip;
7403 * Sets the tooltip for a column.
7404 * @param {Number} col The column index
7405 * @param {String} tooltip The new tooltip
7407 setColumnTooltip : function(col, tooltip){
7408 this.config[col].tooltip = tooltip;
7412 * Returns the dataIndex for the specified column.
7413 * @param {Number} col The column index
7416 getDataIndex : function(col){
7417 return this.config[col].dataIndex;
7421 * Sets the dataIndex for a column.
7422 * @param {Number} col The column index
7423 * @param {Number} dataIndex The new dataIndex
7425 setDataIndex : function(col, dataIndex){
7426 this.config[col].dataIndex = dataIndex;
7432 * Returns true if the cell is editable.
7433 * @param {Number} colIndex The column index
7434 * @param {Number} rowIndex The row index - this is nto actually used..?
7437 isCellEditable : function(colIndex, rowIndex){
7438 return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
7442 * Returns the editor defined for the cell/column.
7443 * return false or null to disable editing.
7444 * @param {Number} colIndex The column index
7445 * @param {Number} rowIndex The row index
7448 getCellEditor : function(colIndex, rowIndex){
7449 return this.config[colIndex].editor;
7453 * Sets if a column is editable.
7454 * @param {Number} col The column index
7455 * @param {Boolean} editable True if the column is editable
7457 setEditable : function(col, editable){
7458 this.config[col].editable = editable;
7463 * Returns true if the column is hidden.
7464 * @param {Number} colIndex The column index
7467 isHidden : function(colIndex){
7468 return this.config[colIndex].hidden;
7473 * Returns true if the column width cannot be changed
7475 isFixed : function(colIndex){
7476 return this.config[colIndex].fixed;
7480 * Returns true if the column can be resized
7483 isResizable : function(colIndex){
7484 return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
7487 * Sets if a column is hidden.
7488 * @param {Number} colIndex The column index
7489 * @param {Boolean} hidden True if the column is hidden
7491 setHidden : function(colIndex, hidden){
7492 this.config[colIndex].hidden = hidden;
7493 this.totalWidth = null;
7494 this.fireEvent("hiddenchange", this, colIndex, hidden);
7498 * Sets the editor for a column.
7499 * @param {Number} col The column index
7500 * @param {Object} editor The editor object
7502 setEditor : function(col, editor){
7503 this.config[col].editor = editor;
7507 Roo.grid.ColumnModel.defaultRenderer = function(value)
7509 if(typeof value == "object") {
7512 if(typeof value == "string" && value.length < 1){
7516 return String.format("{0}", value);
7519 // Alias for backwards compatibility
7520 Roo.grid.DefaultColumnModel = Roo.grid.ColumnModel;
7523 * Ext JS Library 1.1.1
7524 * Copyright(c) 2006-2007, Ext JS, LLC.
7526 * Originally Released Under LGPL - original licence link has changed is not relivant.
7529 * <script type="text/javascript">
7533 * @class Roo.LoadMask
7534 * A simple utility class for generically masking elements while loading data. If the element being masked has
7535 * an underlying {@link Roo.data.Store}, the masking will be automatically synchronized with the store's loading
7536 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
7537 * element's UpdateManager load indicator and will be destroyed after the initial load.
7539 * Create a new LoadMask
7540 * @param {String/HTMLElement/Roo.Element} el The element or DOM node, or its id
7541 * @param {Object} config The config object
7543 Roo.LoadMask = function(el, config){
7544 this.el = Roo.get(el);
7545 Roo.apply(this, config);
7547 this.store.on('beforeload', this.onBeforeLoad, this);
7548 this.store.on('load', this.onLoad, this);
7549 this.store.on('loadexception', this.onLoadException, this);
7550 this.removeMask = false;
7552 var um = this.el.getUpdateManager();
7553 um.showLoadIndicator = false; // disable the default indicator
7554 um.on('beforeupdate', this.onBeforeLoad, this);
7555 um.on('update', this.onLoad, this);
7556 um.on('failure', this.onLoad, this);
7557 this.removeMask = true;
7561 Roo.LoadMask.prototype = {
7563 * @cfg {Boolean} removeMask
7564 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
7565 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
7569 * The text to display in a centered loading message box (defaults to 'Loading...')
7573 * @cfg {String} msgCls
7574 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
7576 msgCls : 'x-mask-loading',
7579 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
7585 * Disables the mask to prevent it from being displayed
7587 disable : function(){
7588 this.disabled = true;
7592 * Enables the mask so that it can be displayed
7594 enable : function(){
7595 this.disabled = false;
7598 onLoadException : function()
7602 if (typeof(arguments[3]) != 'undefined') {
7603 Roo.MessageBox.alert("Error loading",arguments[3]);
7607 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
7608 Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
7615 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
7620 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
7624 onBeforeLoad : function(){
7626 (function() { this.el.mask(this.msg, this.msgCls); }).defer(50, this);
7631 destroy : function(){
7633 this.store.un('beforeload', this.onBeforeLoad, this);
7634 this.store.un('load', this.onLoad, this);
7635 this.store.un('loadexception', this.onLoadException, this);
7637 var um = this.el.getUpdateManager();
7638 um.un('beforeupdate', this.onBeforeLoad, this);
7639 um.un('update', this.onLoad, this);
7640 um.un('failure', this.onLoad, this);
7651 * @class Roo.bootstrap.Table
7652 * @extends Roo.bootstrap.Component
7653 * Bootstrap Table class
7654 * @cfg {String} cls table class
7655 * @cfg {String} align (left|center|right) Specifies the alignment of a table according to surrounding text
7656 * @cfg {String} bgcolor Specifies the background color for a table
7657 * @cfg {Number} border Specifies whether the table cells should have borders or not
7658 * @cfg {Number} cellpadding Specifies the space between the cell wall and the cell content
7659 * @cfg {Number} cellspacing Specifies the space between cells
7660 * @cfg {String} frame Specifies which parts of the outside borders that should be visible
7661 * @cfg {String} rules Specifies which parts of the inside borders that should be visible
7662 * @cfg {String} sortable Specifies that the table should be sortable
7663 * @cfg {String} summary Specifies a summary of the content of a table
7664 * @cfg {Number} width Specifies the width of a table
7665 * @cfg {String} layout table layout (auto | fixed | initial | inherit)
7667 * @cfg {boolean} striped Should the rows be alternative striped
7668 * @cfg {boolean} bordered Add borders to the table
7669 * @cfg {boolean} hover Add hover highlighting
7670 * @cfg {boolean} condensed Format condensed
7671 * @cfg {boolean} responsive Format condensed
7672 * @cfg {Boolean} loadMask (true|false) default false
7673 * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
7674 * @cfg {Boolean} headerShow (true|false) generate thead, default true
7675 * @cfg {Boolean} rowSelection (true|false) default false
7676 * @cfg {Boolean} cellSelection (true|false) default false
7677 * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header
7678 * @cfg {Roo.bootstrap.PagingToolbar} footer a paging toolbar
7679 * @cfg {Boolean} lazyLoad auto load data while scrolling to the end (default false)
7680 * @cfg {Boolean} auto_hide_footer auto hide footer if only one page (default false)
7684 * Create a new Table
7685 * @param {Object} config The config object
7688 Roo.bootstrap.Table = function(config){
7689 Roo.bootstrap.Table.superclass.constructor.call(this, config);
7694 this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
7695 this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
7696 this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
7697 this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
7699 this.sm = this.sm || {xtype: 'RowSelectionModel'};
7701 this.sm.grid = this;
7702 this.selModel = Roo.factory(this.sm, Roo.bootstrap.Table);
7703 this.sm = this.selModel;
7704 this.sm.xmodule = this.xmodule || false;
7707 if (this.cm && typeof(this.cm.config) == 'undefined') {
7708 this.colModel = new Roo.grid.ColumnModel(this.cm);
7709 this.cm = this.colModel;
7710 this.cm.xmodule = this.xmodule || false;
7713 this.store= Roo.factory(this.store, Roo.data);
7714 this.ds = this.store;
7715 this.ds.xmodule = this.xmodule || false;
7718 if (this.footer && this.store) {
7719 this.footer.dataSource = this.ds;
7720 this.footer = Roo.factory(this.footer);
7727 * Fires when a cell is clicked
7728 * @param {Roo.bootstrap.Table} this
7729 * @param {Roo.Element} el
7730 * @param {Number} rowIndex
7731 * @param {Number} columnIndex
7732 * @param {Roo.EventObject} e
7736 * @event celldblclick
7737 * Fires when a cell is double clicked
7738 * @param {Roo.bootstrap.Table} this
7739 * @param {Roo.Element} el
7740 * @param {Number} rowIndex
7741 * @param {Number} columnIndex
7742 * @param {Roo.EventObject} e
7744 "celldblclick" : true,
7747 * Fires when a row is clicked
7748 * @param {Roo.bootstrap.Table} this
7749 * @param {Roo.Element} el
7750 * @param {Number} rowIndex
7751 * @param {Roo.EventObject} e
7755 * @event rowdblclick
7756 * Fires when a row is double clicked
7757 * @param {Roo.bootstrap.Table} this
7758 * @param {Roo.Element} el
7759 * @param {Number} rowIndex
7760 * @param {Roo.EventObject} e
7762 "rowdblclick" : true,
7765 * Fires when a mouseover occur
7766 * @param {Roo.bootstrap.Table} this
7767 * @param {Roo.Element} el
7768 * @param {Number} rowIndex
7769 * @param {Number} columnIndex
7770 * @param {Roo.EventObject} e
7775 * Fires when a mouseout occur
7776 * @param {Roo.bootstrap.Table} this
7777 * @param {Roo.Element} el
7778 * @param {Number} rowIndex
7779 * @param {Number} columnIndex
7780 * @param {Roo.EventObject} e
7785 * Fires when a row is rendered, so you can change add a style to it.
7786 * @param {Roo.bootstrap.Table} this
7787 * @param {Object} rowcfg contains record rowIndex colIndex and rowClass - set rowClass to add a style.
7791 * @event rowsrendered
7792 * Fires when all the rows have been rendered
7793 * @param {Roo.bootstrap.Table} this
7795 'rowsrendered' : true,
7797 * @event contextmenu
7798 * The raw contextmenu event for the entire grid.
7799 * @param {Roo.EventObject} e
7801 "contextmenu" : true,
7803 * @event rowcontextmenu
7804 * Fires when a row is right clicked
7805 * @param {Roo.bootstrap.Table} this
7806 * @param {Number} rowIndex
7807 * @param {Roo.EventObject} e
7809 "rowcontextmenu" : true,
7811 * @event cellcontextmenu
7812 * Fires when a cell is right clicked
7813 * @param {Roo.bootstrap.Table} this
7814 * @param {Number} rowIndex
7815 * @param {Number} cellIndex
7816 * @param {Roo.EventObject} e
7818 "cellcontextmenu" : true,
7820 * @event headercontextmenu
7821 * Fires when a header is right clicked
7822 * @param {Roo.bootstrap.Table} this
7823 * @param {Number} columnIndex
7824 * @param {Roo.EventObject} e
7826 "headercontextmenu" : true
7830 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
7856 rowSelection : false,
7857 cellSelection : false,
7860 // Roo.Element - the tbody
7862 // Roo.Element - thead element
7865 container: false, // used by gridpanel...
7871 auto_hide_footer : false,
7873 getAutoCreate : function()
7875 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
7882 if (this.scrollBody) {
7883 cfg.cls += ' table-body-fixed';
7886 cfg.cls += ' table-striped';
7890 cfg.cls += ' table-hover';
7892 if (this.bordered) {
7893 cfg.cls += ' table-bordered';
7895 if (this.condensed) {
7896 cfg.cls += ' table-condensed';
7898 if (this.responsive) {
7899 cfg.cls += ' table-responsive';
7903 cfg.cls+= ' ' +this.cls;
7906 // this lot should be simplifed...
7919 ].forEach(function(k) {
7927 cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
7930 if(this.store || this.cm){
7931 if(this.headerShow){
7932 cfg.cn.push(this.renderHeader());
7935 cfg.cn.push(this.renderBody());
7937 if(this.footerShow){
7938 cfg.cn.push(this.renderFooter());
7940 // where does this come from?
7941 //cfg.cls+= ' TableGrid';
7944 return { cn : [ cfg ] };
7947 initEvents : function()
7949 if(!this.store || !this.cm){
7952 if (this.selModel) {
7953 this.selModel.initEvents();
7957 //Roo.log('initEvents with ds!!!!');
7959 this.mainBody = this.el.select('tbody', true).first();
7960 this.mainHead = this.el.select('thead', true).first();
7961 this.mainFoot = this.el.select('tfoot', true).first();
7967 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
7968 e.on('click', _this.sort, _this);
7971 this.mainBody.on("click", this.onClick, this);
7972 this.mainBody.on("dblclick", this.onDblClick, this);
7974 // why is this done????? = it breaks dialogs??
7975 //this.parent().el.setStyle('position', 'relative');
7979 this.footer.parentId = this.id;
7980 this.footer.onRender(this.el.select('tfoot tr td').first(), null);
7983 this.el.select('tfoot tr td').first().addClass('hide');
7988 this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
7991 this.store.on('load', this.onLoad, this);
7992 this.store.on('beforeload', this.onBeforeLoad, this);
7993 this.store.on('update', this.onUpdate, this);
7994 this.store.on('add', this.onAdd, this);
7995 this.store.on("clear", this.clear, this);
7997 this.el.on("contextmenu", this.onContextMenu, this);
7999 this.mainBody.on('scroll', this.onBodyScroll, this);
8001 this.cm.on("headerchange", this.onHeaderChange, this);
8003 this.cm.on("hiddenchange", this.onHiddenChange, this, arguments);
8007 onContextMenu : function(e, t)
8009 this.processEvent("contextmenu", e);
8012 processEvent : function(name, e)
8014 if (name != 'touchstart' ) {
8015 this.fireEvent(name, e);
8018 var t = e.getTarget();
8020 var cell = Roo.get(t);
8026 if(cell.findParent('tfoot', false, true)){
8030 if(cell.findParent('thead', false, true)){
8032 if(e.getTarget().nodeName.toLowerCase() != 'th'){
8033 cell = Roo.get(t).findParent('th', false, true);
8035 Roo.log("failed to find th in thead?");
8036 Roo.log(e.getTarget());
8041 var cellIndex = cell.dom.cellIndex;
8043 var ename = name == 'touchstart' ? 'click' : name;
8044 this.fireEvent("header" + ename, this, cellIndex, e);
8049 if(e.getTarget().nodeName.toLowerCase() != 'td'){
8050 cell = Roo.get(t).findParent('td', false, true);
8052 Roo.log("failed to find th in tbody?");
8053 Roo.log(e.getTarget());
8058 var row = cell.findParent('tr', false, true);
8059 var cellIndex = cell.dom.cellIndex;
8060 var rowIndex = row.dom.rowIndex - 1;
8064 this.fireEvent("row" + name, this, rowIndex, e);
8068 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
8074 onMouseover : function(e, el)
8076 var cell = Roo.get(el);
8082 if(e.getTarget().nodeName.toLowerCase() != 'td'){
8083 cell = cell.findParent('td', false, true);
8086 var row = cell.findParent('tr', false, true);
8087 var cellIndex = cell.dom.cellIndex;
8088 var rowIndex = row.dom.rowIndex - 1; // start from 0
8090 this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
8094 onMouseout : function(e, el)
8096 var cell = Roo.get(el);
8102 if(e.getTarget().nodeName.toLowerCase() != 'td'){
8103 cell = cell.findParent('td', false, true);
8106 var row = cell.findParent('tr', false, true);
8107 var cellIndex = cell.dom.cellIndex;
8108 var rowIndex = row.dom.rowIndex - 1; // start from 0
8110 this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
8114 onClick : function(e, el)
8116 var cell = Roo.get(el);
8118 if(!cell || (!this.cellSelection && !this.rowSelection)){
8122 if(e.getTarget().nodeName.toLowerCase() != 'td'){
8123 cell = cell.findParent('td', false, true);
8126 if(!cell || typeof(cell) == 'undefined'){
8130 var row = cell.findParent('tr', false, true);
8132 if(!row || typeof(row) == 'undefined'){
8136 var cellIndex = cell.dom.cellIndex;
8137 var rowIndex = this.getRowIndex(row);
8139 // why??? - should these not be based on SelectionModel?
8140 if(this.cellSelection){
8141 this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
8144 if(this.rowSelection){
8145 this.fireEvent('rowclick', this, row, rowIndex, e);
8151 onDblClick : function(e,el)
8153 var cell = Roo.get(el);
8155 if(!cell || (!this.cellSelection && !this.rowSelection)){
8159 if(e.getTarget().nodeName.toLowerCase() != 'td'){
8160 cell = cell.findParent('td', false, true);
8163 if(!cell || typeof(cell) == 'undefined'){
8167 var row = cell.findParent('tr', false, true);
8169 if(!row || typeof(row) == 'undefined'){
8173 var cellIndex = cell.dom.cellIndex;
8174 var rowIndex = this.getRowIndex(row);
8176 if(this.cellSelection){
8177 this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
8180 if(this.rowSelection){
8181 this.fireEvent('rowdblclick', this, row, rowIndex, e);
8185 sort : function(e,el)
8187 var col = Roo.get(el);
8189 if(!col.hasClass('sortable')){
8193 var sort = col.attr('sort');
8196 if(col.select('i', true).first().hasClass('glyphicon-arrow-up')){
8200 this.store.sortInfo = {field : sort, direction : dir};
8203 Roo.log("calling footer first");
8204 this.footer.onClick('first');
8207 this.store.load({ params : { start : 0 } });
8211 renderHeader : function()
8219 this.totalWidth = 0;
8221 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
8223 var config = cm.config[i];
8227 cls : 'x-hcol-' + i,
8229 html: cm.getColumnHeader(i)
8234 if(typeof(config.sortable) != 'undefined' && config.sortable){
8236 c.html = '<i class="glyphicon"></i>' + c.html;
8239 // could use BS4 hidden-..-down
8241 if(typeof(config.lgHeader) != 'undefined'){
8242 hh += '<span class="hidden-xs hidden-sm hidden-md ">' + config.lgHeader + '</span>';
8245 if(typeof(config.mdHeader) != 'undefined'){
8246 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
8249 if(typeof(config.smHeader) != 'undefined'){
8250 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
8253 if(typeof(config.xsHeader) != 'undefined'){
8254 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
8261 if(typeof(config.tooltip) != 'undefined'){
8262 c.tooltip = config.tooltip;
8265 if(typeof(config.colspan) != 'undefined'){
8266 c.colspan = config.colspan;
8269 if(typeof(config.hidden) != 'undefined' && config.hidden){
8270 c.style += ' display:none;';
8273 if(typeof(config.dataIndex) != 'undefined'){
8274 c.sort = config.dataIndex;
8279 if(typeof(config.align) != 'undefined' && config.align.length){
8280 c.style += ' text-align:' + config.align + ';';
8283 if(typeof(config.width) != 'undefined'){
8284 c.style += ' width:' + config.width + 'px;';
8285 this.totalWidth += config.width;
8287 this.totalWidth += 100; // assume minimum of 100 per column?
8290 if(typeof(config.cls) != 'undefined'){
8291 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
8294 ['xs','sm','md','lg'].map(function(size){
8296 if(typeof(config[size]) == 'undefined'){
8300 if (!config[size]) { // 0 = hidden
8301 // BS 4 '0' is treated as hide that column and below.
8302 c.cls += ' hidden-' + size + ' hidden' + size + '-down';
8306 c.cls += ' col-' + size + '-' + config[size] + (
8307 size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
8319 renderBody : function()
8329 colspan : this.cm.getColumnCount()
8339 renderFooter : function()
8349 colspan : this.cm.getColumnCount()
8363 // Roo.log('ds onload');
8368 var ds = this.store;
8370 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
8371 e.select('i', true).removeClass(['glyphicon-arrow-up', 'glyphicon-arrow-down']);
8372 if (_this.store.sortInfo) {
8374 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
8375 e.select('i', true).addClass(['glyphicon-arrow-up']);
8378 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
8379 e.select('i', true).addClass(['glyphicon-arrow-down']);
8384 var tbody = this.mainBody;
8386 if(ds.getCount() > 0){
8387 ds.data.each(function(d,rowIndex){
8388 var row = this.renderRow(cm, ds, rowIndex);
8390 tbody.createChild(row);
8394 if(row.cellObjects.length){
8395 Roo.each(row.cellObjects, function(r){
8396 _this.renderCellObject(r);
8403 var tfoot = this.el.select('tfoot', true).first();
8405 if(this.footerShow && this.auto_hide_footer && this.mainFoot){
8407 this.mainFoot.setVisibilityMode(Roo.Element.DISPLAY).hide();
8409 var total = this.ds.getTotalCount();
8411 if(this.footer.pageSize < total){
8412 this.mainFoot.show();
8416 Roo.each(this.el.select('tbody td', true).elements, function(e){
8417 e.on('mouseover', _this.onMouseover, _this);
8420 Roo.each(this.el.select('tbody td', true).elements, function(e){
8421 e.on('mouseout', _this.onMouseout, _this);
8423 this.fireEvent('rowsrendered', this);
8429 onUpdate : function(ds,record)
8431 this.refreshRow(record);
8435 onRemove : function(ds, record, index, isUpdate){
8436 if(isUpdate !== true){
8437 this.fireEvent("beforerowremoved", this, index, record);
8439 var bt = this.mainBody.dom;
8441 var rows = this.el.select('tbody > tr', true).elements;
8443 if(typeof(rows[index]) != 'undefined'){
8444 bt.removeChild(rows[index].dom);
8447 // if(bt.rows[index]){
8448 // bt.removeChild(bt.rows[index]);
8451 if(isUpdate !== true){
8452 //this.stripeRows(index);
8453 //this.syncRowHeights(index, index);
8455 this.fireEvent("rowremoved", this, index, record);
8459 onAdd : function(ds, records, rowIndex)
8461 //Roo.log('on Add called');
8462 // - note this does not handle multiple adding very well..
8463 var bt = this.mainBody.dom;
8464 for (var i =0 ; i < records.length;i++) {
8465 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
8466 //Roo.log(records[i]);
8467 //Roo.log(this.store.getAt(rowIndex+i));
8468 this.insertRow(this.store, rowIndex + i, false);
8475 refreshRow : function(record){
8476 var ds = this.store, index;
8477 if(typeof record == 'number'){
8479 record = ds.getAt(index);
8481 index = ds.indexOf(record);
8483 return; // should not happen - but seems to
8486 this.insertRow(ds, index, true);
8488 this.onRemove(ds, record, index+1, true);
8490 //this.syncRowHeights(index, index);
8492 this.fireEvent("rowupdated", this, index, record);
8495 insertRow : function(dm, rowIndex, isUpdate){
8498 this.fireEvent("beforerowsinserted", this, rowIndex);
8500 //var s = this.getScrollState();
8501 var row = this.renderRow(this.cm, this.store, rowIndex);
8502 // insert before rowIndex..
8503 var e = this.mainBody.createChild(row,this.getRowDom(rowIndex));
8507 if(row.cellObjects.length){
8508 Roo.each(row.cellObjects, function(r){
8509 _this.renderCellObject(r);
8514 this.fireEvent("rowsinserted", this, rowIndex);
8515 //this.syncRowHeights(firstRow, lastRow);
8516 //this.stripeRows(firstRow);
8523 getRowDom : function(rowIndex)
8525 var rows = this.el.select('tbody > tr', true).elements;
8527 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
8530 // returns the object tree for a tr..
8533 renderRow : function(cm, ds, rowIndex)
8535 var d = ds.getAt(rowIndex);
8539 cls : 'x-row-' + rowIndex,
8543 var cellObjects = [];
8545 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
8546 var config = cm.config[i];
8548 var renderer = cm.getRenderer(i);
8552 if(typeof(renderer) !== 'undefined'){
8553 value = renderer(d.data[cm.getDataIndex(i)], false, d);
8555 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
8556 // and are rendered into the cells after the row is rendered - using the id for the element.
8558 if(typeof(value) === 'object'){
8568 rowIndex : rowIndex,
8573 this.fireEvent('rowclass', this, rowcfg);
8577 cls : rowcfg.rowClass + ' x-col-' + i,
8579 html: (typeof(value) === 'object') ? '' : value
8586 if(typeof(config.colspan) != 'undefined'){
8587 td.colspan = config.colspan;
8590 if(typeof(config.hidden) != 'undefined' && config.hidden){
8591 td.style += ' display:none;';
8594 if(typeof(config.align) != 'undefined' && config.align.length){
8595 td.style += ' text-align:' + config.align + ';';
8597 if(typeof(config.valign) != 'undefined' && config.valign.length){
8598 td.style += ' vertical-align:' + config.valign + ';';
8601 if(typeof(config.width) != 'undefined'){
8602 td.style += ' width:' + config.width + 'px;';
8605 if(typeof(config.cursor) != 'undefined'){
8606 td.style += ' cursor:' + config.cursor + ';';
8609 if(typeof(config.cls) != 'undefined'){
8610 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
8613 ['xs','sm','md','lg'].map(function(size){
8615 if(typeof(config[size]) == 'undefined'){
8621 if (!config[size]) { // 0 = hidden
8622 // BS 4 '0' is treated as hide that column and below.
8623 td.cls += ' hidden-' + size + ' hidden' + size + '-down';
8627 td.cls += ' col-' + size + '-' + config[size] + (
8628 size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
8638 row.cellObjects = cellObjects;
8646 onBeforeLoad : function()
8655 this.el.select('tbody', true).first().dom.innerHTML = '';
8658 * Show or hide a row.
8659 * @param {Number} rowIndex to show or hide
8660 * @param {Boolean} state hide
8662 setRowVisibility : function(rowIndex, state)
8664 var bt = this.mainBody.dom;
8666 var rows = this.el.select('tbody > tr', true).elements;
8668 if(typeof(rows[rowIndex]) == 'undefined'){
8671 rows[rowIndex].dom.style.display = state ? '' : 'none';
8675 getSelectionModel : function(){
8677 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
8679 return this.selModel;
8682 * Render the Roo.bootstrap object from renderder
8684 renderCellObject : function(r)
8688 r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
8690 var t = r.cfg.render(r.container);
8693 Roo.each(r.cfg.cn, function(c){
8695 container: t.getChildContainer(),
8698 _this.renderCellObject(child);
8703 getRowIndex : function(row)
8707 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
8718 * Returns the grid's underlying element = used by panel.Grid
8719 * @return {Element} The element
8721 getGridEl : function(){
8725 * Forces a resize - used by panel.Grid
8726 * @return {Element} The element
8728 autoSize : function()
8730 //var ctr = Roo.get(this.container.dom.parentElement);
8731 var ctr = Roo.get(this.el.dom);
8733 var thd = this.getGridEl().select('thead',true).first();
8734 var tbd = this.getGridEl().select('tbody', true).first();
8735 var tfd = this.getGridEl().select('tfoot', true).first();
8737 var cw = ctr.getWidth();
8738 this.getGridEl().select('tfoot tr, tfoot td',true).setWidth(cw);
8742 tbd.setWidth(ctr.getWidth());
8743 // if the body has a max height - and then scrolls - we should perhaps set up the height here
8744 // this needs fixing for various usage - currently only hydra job advers I think..
8746 // ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
8748 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
8751 cw = Math.max(cw, this.totalWidth);
8752 this.getGridEl().select('tbody tr',true).setWidth(cw);
8754 // resize 'expandable coloumn?
8756 return; // we doe not have a view in this design..
8759 onBodyScroll: function()
8761 //Roo.log("body scrolled');" + this.mainBody.dom.scrollLeft);
8763 this.mainHead.setStyle({
8764 'position' : 'relative',
8765 'left': (-1* this.mainBody.dom.scrollLeft) + 'px'
8771 var scrollHeight = this.mainBody.dom.scrollHeight;
8773 var scrollTop = Math.ceil(this.mainBody.getScroll().top);
8775 var height = this.mainBody.getHeight();
8777 if(scrollHeight - height == scrollTop) {
8779 var total = this.ds.getTotalCount();
8781 if(this.footer.cursor + this.footer.pageSize < total){
8783 this.footer.ds.load({
8785 start : this.footer.cursor + this.footer.pageSize,
8786 limit : this.footer.pageSize
8796 onHeaderChange : function()
8798 var header = this.renderHeader();
8799 var table = this.el.select('table', true).first();
8801 this.mainHead.remove();
8802 this.mainHead = table.createChild(header, this.mainBody, false);
8805 onHiddenChange : function(colModel, colIndex, hidden)
8807 var thSelector = '#' + this.id + ' .x-hcol-' + colIndex;
8808 var tdSelector = '#' + this.id + ' .x-col-' + colIndex;
8810 this.CSS.updateRule(thSelector, "display", "");
8811 this.CSS.updateRule(tdSelector, "display", "");
8814 this.CSS.updateRule(thSelector, "display", "none");
8815 this.CSS.updateRule(tdSelector, "display", "none");
8818 this.onHeaderChange();
8822 setColumnWidth: function(col_index, width)
8824 // width = "md-2 xs-2..."
8825 if(!this.colModel.config[col_index]) {
8829 var w = width.split(" ");
8831 var rows = this.el.dom.getElementsByClassName("x-col-"+col_index);
8833 var h_row = this.el.dom.getElementsByClassName("x-hcol-"+col_index);
8836 for(var j = 0; j < w.length; j++) {
8842 var size_cls = w[j].split("-");
8844 if(!Number.isInteger(size_cls[1] * 1)) {
8848 if(!this.colModel.config[col_index][size_cls[0]]) {
8852 if(!h_row[0].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
8856 h_row[0].classList.replace(
8857 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
8858 "col-"+size_cls[0]+"-"+size_cls[1]
8861 for(var i = 0; i < rows.length; i++) {
8863 var size_cls = w[j].split("-");
8865 if(!Number.isInteger(size_cls[1] * 1)) {
8869 if(!this.colModel.config[col_index][size_cls[0]]) {
8873 if(!rows[i].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
8877 rows[i].classList.replace(
8878 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
8879 "col-"+size_cls[0]+"-"+size_cls[1]
8883 this.colModel.config[col_index][size_cls[0]] = size_cls[1];
8898 * @class Roo.bootstrap.TableCell
8899 * @extends Roo.bootstrap.Component
8900 * Bootstrap TableCell class
8901 * @cfg {String} html cell contain text
8902 * @cfg {String} cls cell class
8903 * @cfg {String} tag cell tag (td|th) default td
8904 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
8905 * @cfg {String} align Aligns the content in a cell
8906 * @cfg {String} axis Categorizes cells
8907 * @cfg {String} bgcolor Specifies the background color of a cell
8908 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
8909 * @cfg {Number} colspan Specifies the number of columns a cell should span
8910 * @cfg {String} headers Specifies one or more header cells a cell is related to
8911 * @cfg {Number} height Sets the height of a cell
8912 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
8913 * @cfg {Number} rowspan Sets the number of rows a cell should span
8914 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
8915 * @cfg {String} valign Vertical aligns the content in a cell
8916 * @cfg {Number} width Specifies the width of a cell
8919 * Create a new TableCell
8920 * @param {Object} config The config object
8923 Roo.bootstrap.TableCell = function(config){
8924 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
8927 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
8947 getAutoCreate : function(){
8948 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
8968 cfg.align=this.align
8974 cfg.bgcolor=this.bgcolor
8977 cfg.charoff=this.charoff
8980 cfg.colspan=this.colspan
8983 cfg.headers=this.headers
8986 cfg.height=this.height
8989 cfg.nowrap=this.nowrap
8992 cfg.rowspan=this.rowspan
8995 cfg.scope=this.scope
8998 cfg.valign=this.valign
9001 cfg.width=this.width
9020 * @class Roo.bootstrap.TableRow
9021 * @extends Roo.bootstrap.Component
9022 * Bootstrap TableRow class
9023 * @cfg {String} cls row class
9024 * @cfg {String} align Aligns the content in a table row
9025 * @cfg {String} bgcolor Specifies a background color for a table row
9026 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
9027 * @cfg {String} valign Vertical aligns the content in a table row
9030 * Create a new TableRow
9031 * @param {Object} config The config object
9034 Roo.bootstrap.TableRow = function(config){
9035 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
9038 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
9046 getAutoCreate : function(){
9047 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
9057 cfg.align = this.align;
9060 cfg.bgcolor = this.bgcolor;
9063 cfg.charoff = this.charoff;
9066 cfg.valign = this.valign;
9084 * @class Roo.bootstrap.TableBody
9085 * @extends Roo.bootstrap.Component
9086 * Bootstrap TableBody class
9087 * @cfg {String} cls element class
9088 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
9089 * @cfg {String} align Aligns the content inside the element
9090 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
9091 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
9094 * Create a new TableBody
9095 * @param {Object} config The config object
9098 Roo.bootstrap.TableBody = function(config){
9099 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
9102 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
9110 getAutoCreate : function(){
9111 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
9125 cfg.align = this.align;
9128 cfg.charoff = this.charoff;
9131 cfg.valign = this.valign;
9138 // initEvents : function()
9145 // this.store = Roo.factory(this.store, Roo.data);
9146 // this.store.on('load', this.onLoad, this);
9148 // this.store.load();
9152 // onLoad: function ()
9154 // this.fireEvent('load', this);
9164 * Ext JS Library 1.1.1
9165 * Copyright(c) 2006-2007, Ext JS, LLC.
9167 * Originally Released Under LGPL - original licence link has changed is not relivant.
9170 * <script type="text/javascript">
9173 // as we use this in bootstrap.
9174 Roo.namespace('Roo.form');
9176 * @class Roo.form.Action
9177 * Internal Class used to handle form actions
9179 * @param {Roo.form.BasicForm} el The form element or its id
9180 * @param {Object} config Configuration options
9185 // define the action interface
9186 Roo.form.Action = function(form, options){
9188 this.options = options || {};
9191 * Client Validation Failed
9194 Roo.form.Action.CLIENT_INVALID = 'client';
9196 * Server Validation Failed
9199 Roo.form.Action.SERVER_INVALID = 'server';
9201 * Connect to Server Failed
9204 Roo.form.Action.CONNECT_FAILURE = 'connect';
9206 * Reading Data from Server Failed
9209 Roo.form.Action.LOAD_FAILURE = 'load';
9211 Roo.form.Action.prototype = {
9213 failureType : undefined,
9214 response : undefined,
9218 run : function(options){
9223 success : function(response){
9228 handleResponse : function(response){
9232 // default connection failure
9233 failure : function(response){
9235 this.response = response;
9236 this.failureType = Roo.form.Action.CONNECT_FAILURE;
9237 this.form.afterAction(this, false);
9240 processResponse : function(response){
9241 this.response = response;
9242 if(!response.responseText){
9245 this.result = this.handleResponse(response);
9249 // utility functions used internally
9250 getUrl : function(appendParams){
9251 var url = this.options.url || this.form.url || this.form.el.dom.action;
9253 var p = this.getParams();
9255 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
9261 getMethod : function(){
9262 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
9265 getParams : function(){
9266 var bp = this.form.baseParams;
9267 var p = this.options.params;
9269 if(typeof p == "object"){
9270 p = Roo.urlEncode(Roo.applyIf(p, bp));
9271 }else if(typeof p == 'string' && bp){
9272 p += '&' + Roo.urlEncode(bp);
9275 p = Roo.urlEncode(bp);
9280 createCallback : function(){
9282 success: this.success,
9283 failure: this.failure,
9285 timeout: (this.form.timeout*1000),
9286 upload: this.form.fileUpload ? this.success : undefined
9291 Roo.form.Action.Submit = function(form, options){
9292 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
9295 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
9298 haveProgress : false,
9299 uploadComplete : false,
9301 // uploadProgress indicator.
9302 uploadProgress : function()
9304 if (!this.form.progressUrl) {
9308 if (!this.haveProgress) {
9309 Roo.MessageBox.progress("Uploading", "Uploading");
9311 if (this.uploadComplete) {
9312 Roo.MessageBox.hide();
9316 this.haveProgress = true;
9318 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
9320 var c = new Roo.data.Connection();
9322 url : this.form.progressUrl,
9327 success : function(req){
9328 //console.log(data);
9332 rdata = Roo.decode(req.responseText)
9334 Roo.log("Invalid data from server..");
9338 if (!rdata || !rdata.success) {
9340 Roo.MessageBox.alert(Roo.encode(rdata));
9343 var data = rdata.data;
9345 if (this.uploadComplete) {
9346 Roo.MessageBox.hide();
9351 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
9352 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
9355 this.uploadProgress.defer(2000,this);
9358 failure: function(data) {
9359 Roo.log('progress url failed ');
9370 // run get Values on the form, so it syncs any secondary forms.
9371 this.form.getValues();
9373 var o = this.options;
9374 var method = this.getMethod();
9375 var isPost = method == 'POST';
9376 if(o.clientValidation === false || this.form.isValid()){
9378 if (this.form.progressUrl) {
9379 this.form.findField('UPLOAD_IDENTIFIER').setValue(
9380 (new Date() * 1) + '' + Math.random());
9385 Roo.Ajax.request(Roo.apply(this.createCallback(), {
9386 form:this.form.el.dom,
9387 url:this.getUrl(!isPost),
9389 params:isPost ? this.getParams() : null,
9390 isUpload: this.form.fileUpload,
9391 formData : this.form.formData
9394 this.uploadProgress();
9396 }else if (o.clientValidation !== false){ // client validation failed
9397 this.failureType = Roo.form.Action.CLIENT_INVALID;
9398 this.form.afterAction(this, false);
9402 success : function(response)
9404 this.uploadComplete= true;
9405 if (this.haveProgress) {
9406 Roo.MessageBox.hide();
9410 var result = this.processResponse(response);
9411 if(result === true || result.success){
9412 this.form.afterAction(this, true);
9416 this.form.markInvalid(result.errors);
9417 this.failureType = Roo.form.Action.SERVER_INVALID;
9419 this.form.afterAction(this, false);
9421 failure : function(response)
9423 this.uploadComplete= true;
9424 if (this.haveProgress) {
9425 Roo.MessageBox.hide();
9428 this.response = response;
9429 this.failureType = Roo.form.Action.CONNECT_FAILURE;
9430 this.form.afterAction(this, false);
9433 handleResponse : function(response){
9434 if(this.form.errorReader){
9435 var rs = this.form.errorReader.read(response);
9438 for(var i = 0, len = rs.records.length; i < len; i++) {
9439 var r = rs.records[i];
9443 if(errors.length < 1){
9447 success : rs.success,
9453 ret = Roo.decode(response.responseText);
9457 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
9467 Roo.form.Action.Load = function(form, options){
9468 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
9469 this.reader = this.form.reader;
9472 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
9477 Roo.Ajax.request(Roo.apply(
9478 this.createCallback(), {
9479 method:this.getMethod(),
9480 url:this.getUrl(false),
9481 params:this.getParams()
9485 success : function(response){
9487 var result = this.processResponse(response);
9488 if(result === true || !result.success || !result.data){
9489 this.failureType = Roo.form.Action.LOAD_FAILURE;
9490 this.form.afterAction(this, false);
9493 this.form.clearInvalid();
9494 this.form.setValues(result.data);
9495 this.form.afterAction(this, true);
9498 handleResponse : function(response){
9499 if(this.form.reader){
9500 var rs = this.form.reader.read(response);
9501 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
9503 success : rs.success,
9507 return Roo.decode(response.responseText);
9511 Roo.form.Action.ACTION_TYPES = {
9512 'load' : Roo.form.Action.Load,
9513 'submit' : Roo.form.Action.Submit
9522 * @class Roo.bootstrap.Form
9523 * @extends Roo.bootstrap.Component
9524 * Bootstrap Form class
9525 * @cfg {String} method GET | POST (default POST)
9526 * @cfg {String} labelAlign top | left (default top)
9527 * @cfg {String} align left | right - for navbars
9528 * @cfg {Boolean} loadMask load mask when submit (default true)
9533 * @param {Object} config The config object
9537 Roo.bootstrap.Form = function(config){
9539 Roo.bootstrap.Form.superclass.constructor.call(this, config);
9541 Roo.bootstrap.Form.popover.apply();
9545 * @event clientvalidation
9546 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
9547 * @param {Form} this
9548 * @param {Boolean} valid true if the form has passed client-side validation
9550 clientvalidation: true,
9552 * @event beforeaction
9553 * Fires before any action is performed. Return false to cancel the action.
9554 * @param {Form} this
9555 * @param {Action} action The action to be performed
9559 * @event actionfailed
9560 * Fires when an action fails.
9561 * @param {Form} this
9562 * @param {Action} action The action that failed
9564 actionfailed : true,
9566 * @event actioncomplete
9567 * Fires when an action is completed.
9568 * @param {Form} this
9569 * @param {Action} action The action that completed
9571 actioncomplete : true
9575 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
9578 * @cfg {String} method
9579 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
9584 * The URL to use for form actions if one isn't supplied in the action options.
9587 * @cfg {Boolean} fileUpload
9588 * Set to true if this form is a file upload.
9592 * @cfg {Object} baseParams
9593 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
9597 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
9601 * @cfg {Sting} align (left|right) for navbar forms
9606 activeAction : null,
9609 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
9610 * element by passing it or its id or mask the form itself by passing in true.
9613 waitMsgTarget : false,
9618 * @cfg {Boolean} errorMask (true|false) default false
9623 * @cfg {Number} maskOffset Default 100
9628 * @cfg {Boolean} maskBody
9632 getAutoCreate : function(){
9636 method : this.method || 'POST',
9637 id : this.id || Roo.id(),
9640 if (this.parent().xtype.match(/^Nav/)) {
9641 cfg.cls = 'navbar-form form-inline navbar-' + this.align;
9645 if (this.labelAlign == 'left' ) {
9646 cfg.cls += ' form-horizontal';
9652 initEvents : function()
9654 this.el.on('submit', this.onSubmit, this);
9655 // this was added as random key presses on the form where triggering form submit.
9656 this.el.on('keypress', function(e) {
9657 if (e.getCharCode() != 13) {
9660 // we might need to allow it for textareas.. and some other items.
9661 // check e.getTarget().
9663 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
9667 Roo.log("keypress blocked");
9675 onSubmit : function(e){
9680 * Returns true if client-side validation on the form is successful.
9683 isValid : function(){
9684 var items = this.getItems();
9688 items.each(function(f){
9694 Roo.log('invalid field: ' + f.name);
9698 if(!target && f.el.isVisible(true)){
9704 if(this.errorMask && !valid){
9705 Roo.bootstrap.Form.popover.mask(this, target);
9712 * Returns true if any fields in this form have changed since their original load.
9715 isDirty : function(){
9717 var items = this.getItems();
9718 items.each(function(f){
9728 * Performs a predefined action (submit or load) or custom actions you define on this form.
9729 * @param {String} actionName The name of the action type
9730 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
9731 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
9732 * accept other config options):
9734 Property Type Description
9735 ---------------- --------------- ----------------------------------------------------------------------------------
9736 url String The url for the action (defaults to the form's url)
9737 method String The form method to use (defaults to the form's method, or POST if not defined)
9738 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
9739 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
9740 validate the form on the client (defaults to false)
9742 * @return {BasicForm} this
9744 doAction : function(action, options){
9745 if(typeof action == 'string'){
9746 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
9748 if(this.fireEvent('beforeaction', this, action) !== false){
9749 this.beforeAction(action);
9750 action.run.defer(100, action);
9756 beforeAction : function(action){
9757 var o = action.options;
9762 Roo.get(document.body).mask(o.waitMsg || "Sending", 'x-mask-loading')
9764 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
9767 // not really supported yet.. ??
9769 //if(this.waitMsgTarget === true){
9770 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
9771 //}else if(this.waitMsgTarget){
9772 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
9773 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
9775 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
9781 afterAction : function(action, success){
9782 this.activeAction = null;
9783 var o = action.options;
9788 Roo.get(document.body).unmask();
9794 //if(this.waitMsgTarget === true){
9795 // this.el.unmask();
9796 //}else if(this.waitMsgTarget){
9797 // this.waitMsgTarget.unmask();
9799 // Roo.MessageBox.updateProgress(1);
9800 // Roo.MessageBox.hide();
9807 Roo.callback(o.success, o.scope, [this, action]);
9808 this.fireEvent('actioncomplete', this, action);
9812 // failure condition..
9813 // we have a scenario where updates need confirming.
9814 // eg. if a locking scenario exists..
9815 // we look for { errors : { needs_confirm : true }} in the response.
9817 (typeof(action.result) != 'undefined') &&
9818 (typeof(action.result.errors) != 'undefined') &&
9819 (typeof(action.result.errors.needs_confirm) != 'undefined')
9822 Roo.log("not supported yet");
9825 Roo.MessageBox.confirm(
9826 "Change requires confirmation",
9827 action.result.errorMsg,
9832 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
9842 Roo.callback(o.failure, o.scope, [this, action]);
9843 // show an error message if no failed handler is set..
9844 if (!this.hasListener('actionfailed')) {
9845 Roo.log("need to add dialog support");
9847 Roo.MessageBox.alert("Error",
9848 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
9849 action.result.errorMsg :
9850 "Saving Failed, please check your entries or try again"
9855 this.fireEvent('actionfailed', this, action);
9860 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
9861 * @param {String} id The value to search for
9864 findField : function(id){
9865 var items = this.getItems();
9866 var field = items.get(id);
9868 items.each(function(f){
9869 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
9876 return field || null;
9879 * Mark fields in this form invalid in bulk.
9880 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
9881 * @return {BasicForm} this
9883 markInvalid : function(errors){
9884 if(errors instanceof Array){
9885 for(var i = 0, len = errors.length; i < len; i++){
9886 var fieldError = errors[i];
9887 var f = this.findField(fieldError.id);
9889 f.markInvalid(fieldError.msg);
9895 if(typeof errors[id] != 'function' && (field = this.findField(id))){
9896 field.markInvalid(errors[id]);
9900 //Roo.each(this.childForms || [], function (f) {
9901 // f.markInvalid(errors);
9908 * Set values for fields in this form in bulk.
9909 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
9910 * @return {BasicForm} this
9912 setValues : function(values){
9913 if(values instanceof Array){ // array of objects
9914 for(var i = 0, len = values.length; i < len; i++){
9916 var f = this.findField(v.id);
9918 f.setValue(v.value);
9919 if(this.trackResetOnLoad){
9920 f.originalValue = f.getValue();
9924 }else{ // object hash
9927 if(typeof values[id] != 'function' && (field = this.findField(id))){
9929 if (field.setFromData &&
9931 field.displayField &&
9932 // combos' with local stores can
9933 // be queried via setValue()
9934 // to set their value..
9935 (field.store && !field.store.isLocal)
9939 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
9940 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
9941 field.setFromData(sd);
9943 } else if(field.setFromData && (field.store && !field.store.isLocal)) {
9945 field.setFromData(values);
9948 field.setValue(values[id]);
9952 if(this.trackResetOnLoad){
9953 field.originalValue = field.getValue();
9959 //Roo.each(this.childForms || [], function (f) {
9960 // f.setValues(values);
9967 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
9968 * they are returned as an array.
9969 * @param {Boolean} asString
9972 getValues : function(asString){
9973 //if (this.childForms) {
9974 // copy values from the child forms
9975 // Roo.each(this.childForms, function (f) {
9976 // this.setValues(f.getValues());
9982 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
9983 if(asString === true){
9986 return Roo.urlDecode(fs);
9990 * Returns the fields in this form as an object with key/value pairs.
9991 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
9994 getFieldValues : function(with_hidden)
9996 var items = this.getItems();
9998 items.each(function(f){
10000 if (!f.getName()) {
10004 var v = f.getValue();
10006 if (f.inputType =='radio') {
10007 if (typeof(ret[f.getName()]) == 'undefined') {
10008 ret[f.getName()] = ''; // empty..
10011 if (!f.el.dom.checked) {
10015 v = f.el.dom.value;
10019 if(f.xtype == 'MoneyField'){
10020 ret[f.currencyName] = f.getCurrency();
10023 // not sure if this supported any more..
10024 if ((typeof(v) == 'object') && f.getRawValue) {
10025 v = f.getRawValue() ; // dates..
10027 // combo boxes where name != hiddenName...
10028 if (f.name !== false && f.name != '' && f.name != f.getName()) {
10029 ret[f.name] = f.getRawValue();
10031 ret[f.getName()] = v;
10038 * Clears all invalid messages in this form.
10039 * @return {BasicForm} this
10041 clearInvalid : function(){
10042 var items = this.getItems();
10044 items.each(function(f){
10052 * Resets this form.
10053 * @return {BasicForm} this
10055 reset : function(){
10056 var items = this.getItems();
10057 items.each(function(f){
10061 Roo.each(this.childForms || [], function (f) {
10069 getItems : function()
10071 var r=new Roo.util.MixedCollection(false, function(o){
10072 return o.id || (o.id = Roo.id());
10074 var iter = function(el) {
10081 Roo.each(el.items,function(e) {
10090 hideFields : function(items)
10092 Roo.each(items, function(i){
10094 var f = this.findField(i);
10105 showFields : function(items)
10107 Roo.each(items, function(i){
10109 var f = this.findField(i);
10122 Roo.apply(Roo.bootstrap.Form, {
10138 intervalID : false,
10144 if(this.isApplied){
10149 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
10150 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
10151 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
10152 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
10155 this.maskEl.top.enableDisplayMode("block");
10156 this.maskEl.left.enableDisplayMode("block");
10157 this.maskEl.bottom.enableDisplayMode("block");
10158 this.maskEl.right.enableDisplayMode("block");
10160 this.toolTip = new Roo.bootstrap.Tooltip({
10161 cls : 'roo-form-error-popover',
10163 'left' : ['r-l', [-2,0], 'right'],
10164 'right' : ['l-r', [2,0], 'left'],
10165 'bottom' : ['tl-bl', [0,2], 'top'],
10166 'top' : [ 'bl-tl', [0,-2], 'bottom']
10170 this.toolTip.render(Roo.get(document.body));
10172 this.toolTip.el.enableDisplayMode("block");
10174 Roo.get(document.body).on('click', function(){
10178 Roo.get(document.body).on('touchstart', function(){
10182 this.isApplied = true
10185 mask : function(form, target)
10189 this.target = target;
10191 if(!this.form.errorMask || !target.el){
10195 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
10197 Roo.log(scrollable);
10199 var ot = this.target.el.calcOffsetsTo(scrollable);
10201 var scrollTo = ot[1] - this.form.maskOffset;
10203 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
10205 scrollable.scrollTo('top', scrollTo);
10207 var box = this.target.el.getBox();
10209 var zIndex = Roo.bootstrap.Modal.zIndex++;
10212 this.maskEl.top.setStyle('position', 'absolute');
10213 this.maskEl.top.setStyle('z-index', zIndex);
10214 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
10215 this.maskEl.top.setLeft(0);
10216 this.maskEl.top.setTop(0);
10217 this.maskEl.top.show();
10219 this.maskEl.left.setStyle('position', 'absolute');
10220 this.maskEl.left.setStyle('z-index', zIndex);
10221 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
10222 this.maskEl.left.setLeft(0);
10223 this.maskEl.left.setTop(box.y - this.padding);
10224 this.maskEl.left.show();
10226 this.maskEl.bottom.setStyle('position', 'absolute');
10227 this.maskEl.bottom.setStyle('z-index', zIndex);
10228 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
10229 this.maskEl.bottom.setLeft(0);
10230 this.maskEl.bottom.setTop(box.bottom + this.padding);
10231 this.maskEl.bottom.show();
10233 this.maskEl.right.setStyle('position', 'absolute');
10234 this.maskEl.right.setStyle('z-index', zIndex);
10235 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
10236 this.maskEl.right.setLeft(box.right + this.padding);
10237 this.maskEl.right.setTop(box.y - this.padding);
10238 this.maskEl.right.show();
10240 this.toolTip.bindEl = this.target.el;
10242 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
10244 var tip = this.target.blankText;
10246 if(this.target.getValue() !== '' ) {
10248 if (this.target.invalidText.length) {
10249 tip = this.target.invalidText;
10250 } else if (this.target.regexText.length){
10251 tip = this.target.regexText;
10255 this.toolTip.show(tip);
10257 this.intervalID = window.setInterval(function() {
10258 Roo.bootstrap.Form.popover.unmask();
10261 window.onwheel = function(){ return false;};
10263 (function(){ this.isMasked = true; }).defer(500, this);
10267 unmask : function()
10269 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
10273 this.maskEl.top.setStyle('position', 'absolute');
10274 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
10275 this.maskEl.top.hide();
10277 this.maskEl.left.setStyle('position', 'absolute');
10278 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
10279 this.maskEl.left.hide();
10281 this.maskEl.bottom.setStyle('position', 'absolute');
10282 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
10283 this.maskEl.bottom.hide();
10285 this.maskEl.right.setStyle('position', 'absolute');
10286 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
10287 this.maskEl.right.hide();
10289 this.toolTip.hide();
10291 this.toolTip.el.hide();
10293 window.onwheel = function(){ return true;};
10295 if(this.intervalID){
10296 window.clearInterval(this.intervalID);
10297 this.intervalID = false;
10300 this.isMasked = false;
10310 * Ext JS Library 1.1.1
10311 * Copyright(c) 2006-2007, Ext JS, LLC.
10313 * Originally Released Under LGPL - original licence link has changed is not relivant.
10316 * <script type="text/javascript">
10319 * @class Roo.form.VTypes
10320 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
10323 Roo.form.VTypes = function(){
10324 // closure these in so they are only created once.
10325 var alpha = /^[a-zA-Z_]+$/;
10326 var alphanum = /^[a-zA-Z0-9_]+$/;
10327 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
10328 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
10330 // All these messages and functions are configurable
10333 * The function used to validate email addresses
10334 * @param {String} value The email address
10336 'email' : function(v){
10337 return email.test(v);
10340 * The error text to display when the email validation function returns false
10343 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
10345 * The keystroke filter mask to be applied on email input
10348 'emailMask' : /[a-z0-9_\.\-@]/i,
10351 * The function used to validate URLs
10352 * @param {String} value The URL
10354 'url' : function(v){
10355 return url.test(v);
10358 * The error text to display when the url validation function returns false
10361 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
10364 * The function used to validate alpha values
10365 * @param {String} value The value
10367 'alpha' : function(v){
10368 return alpha.test(v);
10371 * The error text to display when the alpha validation function returns false
10374 'alphaText' : 'This field should only contain letters and _',
10376 * The keystroke filter mask to be applied on alpha input
10379 'alphaMask' : /[a-z_]/i,
10382 * The function used to validate alphanumeric values
10383 * @param {String} value The value
10385 'alphanum' : function(v){
10386 return alphanum.test(v);
10389 * The error text to display when the alphanumeric validation function returns false
10392 'alphanumText' : 'This field should only contain letters, numbers and _',
10394 * The keystroke filter mask to be applied on alphanumeric input
10397 'alphanumMask' : /[a-z0-9_]/i
10407 * @class Roo.bootstrap.Input
10408 * @extends Roo.bootstrap.Component
10409 * Bootstrap Input class
10410 * @cfg {Boolean} disabled is it disabled
10411 * @cfg {String} (button|checkbox|email|file|hidden|image|number|password|radio|range|reset|search|submit|text) inputType
10412 * @cfg {String} name name of the input
10413 * @cfg {string} fieldLabel - the label associated
10414 * @cfg {string} placeholder - placeholder to put in text.
10415 * @cfg {string} before - input group add on before
10416 * @cfg {string} after - input group add on after
10417 * @cfg {string} size - (lg|sm) or leave empty..
10418 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
10419 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
10420 * @cfg {Number} md colspan out of 12 for computer-sized screens
10421 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
10422 * @cfg {string} value default value of the input
10423 * @cfg {Number} labelWidth set the width of label
10424 * @cfg {Number} labellg set the width of label (1-12)
10425 * @cfg {Number} labelmd set the width of label (1-12)
10426 * @cfg {Number} labelsm set the width of label (1-12)
10427 * @cfg {Number} labelxs set the width of label (1-12)
10428 * @cfg {String} labelAlign (top|left)
10429 * @cfg {Boolean} readOnly Specifies that the field should be read-only
10430 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
10431 * @cfg {String} indicatorpos (left|right) default left
10432 * @cfg {String} capture (user|camera) use for file input only. (default empty)
10433 * @cfg {String} accept (image|video|audio) use for file input only. (default empty)
10434 * @cfg {Boolean} preventMark Do not show tick or cross if error/success
10436 * @cfg {String} align (left|center|right) Default left
10437 * @cfg {Boolean} forceFeedback (true|false) Default false
10440 * Create a new Input
10441 * @param {Object} config The config object
10444 Roo.bootstrap.Input = function(config){
10446 Roo.bootstrap.Input.superclass.constructor.call(this, config);
10451 * Fires when this field receives input focus.
10452 * @param {Roo.form.Field} this
10457 * Fires when this field loses input focus.
10458 * @param {Roo.form.Field} this
10462 * @event specialkey
10463 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
10464 * {@link Roo.EventObject#getKey} to determine which key was pressed.
10465 * @param {Roo.form.Field} this
10466 * @param {Roo.EventObject} e The event object
10471 * Fires just before the field blurs if the field value has changed.
10472 * @param {Roo.form.Field} this
10473 * @param {Mixed} newValue The new value
10474 * @param {Mixed} oldValue The original value
10479 * Fires after the field has been marked as invalid.
10480 * @param {Roo.form.Field} this
10481 * @param {String} msg The validation message
10486 * Fires after the field has been validated with no errors.
10487 * @param {Roo.form.Field} this
10492 * Fires after the key up
10493 * @param {Roo.form.Field} this
10494 * @param {Roo.EventObject} e The event Object
10500 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
10502 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
10503 automatic validation (defaults to "keyup").
10505 validationEvent : "keyup",
10507 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
10509 validateOnBlur : true,
10511 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
10513 validationDelay : 250,
10515 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
10517 focusClass : "x-form-focus", // not needed???
10521 * @cfg {String} invalidClass DEPRICATED - code uses BS4 - is-valid / is-invalid
10523 invalidClass : "has-warning",
10526 * @cfg {String} validClass DEPRICATED - code uses BS4 - is-valid / is-invalid
10528 validClass : "has-success",
10531 * @cfg {Boolean} hasFeedback (true|false) default true
10533 hasFeedback : true,
10536 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
10538 invalidFeedbackClass : "glyphicon-warning-sign",
10541 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
10543 validFeedbackClass : "glyphicon-ok",
10546 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
10548 selectOnFocus : false,
10551 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
10555 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
10560 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
10562 disableKeyFilter : false,
10565 * @cfg {Boolean} disabled True to disable the field (defaults to false).
10569 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
10573 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
10575 blankText : "Please complete this mandatory field",
10578 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
10582 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
10584 maxLength : Number.MAX_VALUE,
10586 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
10588 minLengthText : "The minimum length for this field is {0}",
10590 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
10592 maxLengthText : "The maximum length for this field is {0}",
10596 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
10597 * If available, this function will be called only after the basic validators all return true, and will be passed the
10598 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
10602 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
10603 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
10604 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
10608 * @cfg {String} regexText -- Depricated - use Invalid Text
10613 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
10619 autocomplete: false,
10623 inputType : 'text',
10626 placeholder: false,
10631 preventMark: false,
10632 isFormField : true,
10635 labelAlign : false,
10638 formatedValue : false,
10639 forceFeedback : false,
10641 indicatorpos : 'left',
10651 parentLabelAlign : function()
10654 while (parent.parent()) {
10655 parent = parent.parent();
10656 if (typeof(parent.labelAlign) !='undefined') {
10657 return parent.labelAlign;
10664 getAutoCreate : function()
10666 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
10672 if(this.inputType != 'hidden'){
10673 cfg.cls = 'form-group' //input-group
10679 type : this.inputType,
10680 value : this.value,
10681 cls : 'form-control',
10682 placeholder : this.placeholder || '',
10683 autocomplete : this.autocomplete || 'new-password'
10685 if (this.inputType == 'file') {
10686 input.style = 'overflow:hidden'; // why not in CSS?
10689 if(this.capture.length){
10690 input.capture = this.capture;
10693 if(this.accept.length){
10694 input.accept = this.accept + "/*";
10698 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
10701 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
10702 input.maxLength = this.maxLength;
10705 if (this.disabled) {
10706 input.disabled=true;
10709 if (this.readOnly) {
10710 input.readonly=true;
10714 input.name = this.name;
10718 input.cls += ' input-' + this.size;
10722 ['xs','sm','md','lg'].map(function(size){
10723 if (settings[size]) {
10724 cfg.cls += ' col-' + size + '-' + settings[size];
10728 var inputblock = input;
10732 cls: 'glyphicon form-control-feedback'
10735 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10738 cls : 'has-feedback',
10746 if (this.before || this.after) {
10749 cls : 'input-group',
10753 if (this.before && typeof(this.before) == 'string') {
10755 inputblock.cn.push({
10757 cls : 'roo-input-before input-group-addon input-group-prepend input-group-text',
10761 if (this.before && typeof(this.before) == 'object') {
10762 this.before = Roo.factory(this.before);
10764 inputblock.cn.push({
10766 cls : 'roo-input-before input-group-prepend input-group-' +
10767 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
10771 inputblock.cn.push(input);
10773 if (this.after && typeof(this.after) == 'string') {
10774 inputblock.cn.push({
10776 cls : 'roo-input-after input-group-append input-group-text input-group-addon',
10780 if (this.after && typeof(this.after) == 'object') {
10781 this.after = Roo.factory(this.after);
10783 inputblock.cn.push({
10785 cls : 'roo-input-after input-group-append input-group-' +
10786 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
10790 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10791 inputblock.cls += ' has-feedback';
10792 inputblock.cn.push(feedback);
10797 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
10798 tooltip : 'This field is required'
10800 if (this.allowBlank ) {
10801 indicator.style = this.allowBlank ? ' display:none' : '';
10803 if (align ==='left' && this.fieldLabel.length) {
10805 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
10812 cls : 'control-label col-form-label',
10813 html : this.fieldLabel
10824 var labelCfg = cfg.cn[1];
10825 var contentCfg = cfg.cn[2];
10827 if(this.indicatorpos == 'right'){
10832 cls : 'control-label col-form-label',
10836 html : this.fieldLabel
10850 labelCfg = cfg.cn[0];
10851 contentCfg = cfg.cn[1];
10855 if(this.labelWidth > 12){
10856 labelCfg.style = "width: " + this.labelWidth + 'px';
10859 if(this.labelWidth < 13 && this.labelmd == 0){
10860 this.labelmd = this.labelWidth;
10863 if(this.labellg > 0){
10864 labelCfg.cls += ' col-lg-' + this.labellg;
10865 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
10868 if(this.labelmd > 0){
10869 labelCfg.cls += ' col-md-' + this.labelmd;
10870 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
10873 if(this.labelsm > 0){
10874 labelCfg.cls += ' col-sm-' + this.labelsm;
10875 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
10878 if(this.labelxs > 0){
10879 labelCfg.cls += ' col-xs-' + this.labelxs;
10880 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
10884 } else if ( this.fieldLabel.length) {
10891 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
10892 tooltip : 'This field is required',
10893 style : this.allowBlank ? ' display:none' : ''
10897 //cls : 'input-group-addon',
10898 html : this.fieldLabel
10906 if(this.indicatorpos == 'right'){
10911 //cls : 'input-group-addon',
10912 html : this.fieldLabel
10917 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
10918 tooltip : 'This field is required',
10919 style : this.allowBlank ? ' display:none' : ''
10939 if (this.parentType === 'Navbar' && this.parent().bar) {
10940 cfg.cls += ' navbar-form';
10943 if (this.parentType === 'NavGroup' && !(Roo.bootstrap.version == 4 && this.parent().form)) {
10944 // on BS4 we do this only if not form
10945 cfg.cls += ' navbar-form';
10953 * return the real input element.
10955 inputEl: function ()
10957 return this.el.select('input.form-control',true).first();
10960 tooltipEl : function()
10962 return this.inputEl();
10965 indicatorEl : function()
10967 if (Roo.bootstrap.version == 4) {
10968 return false; // not enabled in v4 yet.
10971 var indicator = this.el.select('i.roo-required-indicator',true).first();
10981 setDisabled : function(v)
10983 var i = this.inputEl().dom;
10985 i.removeAttribute('disabled');
10989 i.setAttribute('disabled','true');
10991 initEvents : function()
10994 this.inputEl().on("keydown" , this.fireKey, this);
10995 this.inputEl().on("focus", this.onFocus, this);
10996 this.inputEl().on("blur", this.onBlur, this);
10998 this.inputEl().relayEvent('keyup', this);
11000 this.indicator = this.indicatorEl();
11002 if(this.indicator){
11003 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible'); // changed from invisible??? -
11006 // reference to original value for reset
11007 this.originalValue = this.getValue();
11008 //Roo.form.TextField.superclass.initEvents.call(this);
11009 if(this.validationEvent == 'keyup'){
11010 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
11011 this.inputEl().on('keyup', this.filterValidation, this);
11013 else if(this.validationEvent !== false){
11014 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
11017 if(this.selectOnFocus){
11018 this.on("focus", this.preFocus, this);
11021 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
11022 this.inputEl().on("keypress", this.filterKeys, this);
11024 this.inputEl().relayEvent('keypress', this);
11027 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
11028 this.el.on("click", this.autoSize, this);
11031 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
11032 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
11035 if (typeof(this.before) == 'object') {
11036 this.before.render(this.el.select('.roo-input-before',true).first());
11038 if (typeof(this.after) == 'object') {
11039 this.after.render(this.el.select('.roo-input-after',true).first());
11042 this.inputEl().on('change', this.onChange, this);
11045 filterValidation : function(e){
11046 if(!e.isNavKeyPress()){
11047 this.validationTask.delay(this.validationDelay);
11051 * Validates the field value
11052 * @return {Boolean} True if the value is valid, else false
11054 validate : function(){
11055 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
11056 if(this.disabled || this.validateValue(this.getRawValue())){
11061 this.markInvalid();
11067 * Validates a value according to the field's validation rules and marks the field as invalid
11068 * if the validation fails
11069 * @param {Mixed} value The value to validate
11070 * @return {Boolean} True if the value is valid, else false
11072 validateValue : function(value)
11074 if(this.getVisibilityEl().hasClass('hidden')){
11078 if(value.length < 1) { // if it's blank
11079 if(this.allowBlank){
11085 if(value.length < this.minLength){
11088 if(value.length > this.maxLength){
11092 var vt = Roo.form.VTypes;
11093 if(!vt[this.vtype](value, this)){
11097 if(typeof this.validator == "function"){
11098 var msg = this.validator(value);
11102 if (typeof(msg) == 'string') {
11103 this.invalidText = msg;
11107 if(this.regex && !this.regex.test(value)){
11115 fireKey : function(e){
11116 //Roo.log('field ' + e.getKey());
11117 if(e.isNavKeyPress()){
11118 this.fireEvent("specialkey", this, e);
11121 focus : function (selectText){
11123 this.inputEl().focus();
11124 if(selectText === true){
11125 this.inputEl().dom.select();
11131 onFocus : function(){
11132 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
11133 // this.el.addClass(this.focusClass);
11135 if(!this.hasFocus){
11136 this.hasFocus = true;
11137 this.startValue = this.getValue();
11138 this.fireEvent("focus", this);
11142 beforeBlur : Roo.emptyFn,
11146 onBlur : function(){
11148 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
11149 //this.el.removeClass(this.focusClass);
11151 this.hasFocus = false;
11152 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
11155 var v = this.getValue();
11156 if(String(v) !== String(this.startValue)){
11157 this.fireEvent('change', this, v, this.startValue);
11159 this.fireEvent("blur", this);
11162 onChange : function(e)
11164 var v = this.getValue();
11165 if(String(v) !== String(this.startValue)){
11166 this.fireEvent('change', this, v, this.startValue);
11172 * Resets the current field value to the originally loaded value and clears any validation messages
11174 reset : function(){
11175 this.setValue(this.originalValue);
11179 * Returns the name of the field
11180 * @return {Mixed} name The name field
11182 getName: function(){
11186 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
11187 * @return {Mixed} value The field value
11189 getValue : function(){
11191 var v = this.inputEl().getValue();
11196 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
11197 * @return {Mixed} value The field value
11199 getRawValue : function(){
11200 var v = this.inputEl().getValue();
11206 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
11207 * @param {Mixed} value The value to set
11209 setRawValue : function(v){
11210 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
11213 selectText : function(start, end){
11214 var v = this.getRawValue();
11216 start = start === undefined ? 0 : start;
11217 end = end === undefined ? v.length : end;
11218 var d = this.inputEl().dom;
11219 if(d.setSelectionRange){
11220 d.setSelectionRange(start, end);
11221 }else if(d.createTextRange){
11222 var range = d.createTextRange();
11223 range.moveStart("character", start);
11224 range.moveEnd("character", v.length-end);
11231 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
11232 * @param {Mixed} value The value to set
11234 setValue : function(v){
11237 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
11243 processValue : function(value){
11244 if(this.stripCharsRe){
11245 var newValue = value.replace(this.stripCharsRe, '');
11246 if(newValue !== value){
11247 this.setRawValue(newValue);
11254 preFocus : function(){
11256 if(this.selectOnFocus){
11257 this.inputEl().dom.select();
11260 filterKeys : function(e){
11261 var k = e.getKey();
11262 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
11265 var c = e.getCharCode(), cc = String.fromCharCode(c);
11266 if(Roo.isIE && (e.isSpecialKey() || !cc)){
11269 if(!this.maskRe.test(cc)){
11274 * Clear any invalid styles/messages for this field
11276 clearInvalid : function(){
11278 if(!this.el || this.preventMark){ // not rendered
11283 this.el.removeClass([this.invalidClass, 'is-invalid']);
11285 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
11287 var feedback = this.el.select('.form-control-feedback', true).first();
11290 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
11295 if(this.indicator){
11296 this.indicator.removeClass('visible');
11297 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
11300 this.fireEvent('valid', this);
11304 * Mark this field as valid
11306 markValid : function()
11308 if(!this.el || this.preventMark){ // not rendered...
11312 this.el.removeClass([this.invalidClass, this.validClass]);
11313 this.inputEl().removeClass(['is-valid', 'is-invalid']);
11315 var feedback = this.el.select('.form-control-feedback', true).first();
11318 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
11321 if(this.indicator){
11322 this.indicator.removeClass('visible');
11323 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
11331 if(this.allowBlank && !this.getRawValue().length){
11334 if (Roo.bootstrap.version == 3) {
11335 this.el.addClass(this.validClass);
11337 this.inputEl().addClass('is-valid');
11340 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
11342 var feedback = this.el.select('.form-control-feedback', true).first();
11345 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
11346 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
11351 this.fireEvent('valid', this);
11355 * Mark this field as invalid
11356 * @param {String} msg The validation message
11358 markInvalid : function(msg)
11360 if(!this.el || this.preventMark){ // not rendered
11364 this.el.removeClass([this.invalidClass, this.validClass]);
11365 this.inputEl().removeClass(['is-valid', 'is-invalid']);
11367 var feedback = this.el.select('.form-control-feedback', true).first();
11370 this.el.select('.form-control-feedback', true).first().removeClass(
11371 [this.invalidFeedbackClass, this.validFeedbackClass]);
11378 if(this.allowBlank && !this.getRawValue().length){
11382 if(this.indicator){
11383 this.indicator.removeClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
11384 this.indicator.addClass('visible');
11386 if (Roo.bootstrap.version == 3) {
11387 this.el.addClass(this.invalidClass);
11389 this.inputEl().addClass('is-invalid');
11394 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
11396 var feedback = this.el.select('.form-control-feedback', true).first();
11399 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
11401 if(this.getValue().length || this.forceFeedback){
11402 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
11409 this.fireEvent('invalid', this, msg);
11412 SafariOnKeyDown : function(event)
11414 // this is a workaround for a password hang bug on chrome/ webkit.
11415 if (this.inputEl().dom.type != 'password') {
11419 var isSelectAll = false;
11421 if(this.inputEl().dom.selectionEnd > 0){
11422 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
11424 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
11425 event.preventDefault();
11430 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
11432 event.preventDefault();
11433 // this is very hacky as keydown always get's upper case.
11435 var cc = String.fromCharCode(event.getCharCode());
11436 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
11440 adjustWidth : function(tag, w){
11441 tag = tag.toLowerCase();
11442 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
11443 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
11444 if(tag == 'input'){
11447 if(tag == 'textarea'){
11450 }else if(Roo.isOpera){
11451 if(tag == 'input'){
11454 if(tag == 'textarea'){
11462 setFieldLabel : function(v)
11464 if(!this.rendered){
11468 if(this.indicatorEl()){
11469 var ar = this.el.select('label > span',true);
11471 if (ar.elements.length) {
11472 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
11473 this.fieldLabel = v;
11477 var br = this.el.select('label',true);
11479 if(br.elements.length) {
11480 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
11481 this.fieldLabel = v;
11485 Roo.log('Cannot Found any of label > span || label in input');
11489 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
11490 this.fieldLabel = v;
11505 * @class Roo.bootstrap.TextArea
11506 * @extends Roo.bootstrap.Input
11507 * Bootstrap TextArea class
11508 * @cfg {Number} cols Specifies the visible width of a text area
11509 * @cfg {Number} rows Specifies the visible number of lines in a text area
11510 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
11511 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
11512 * @cfg {string} html text
11515 * Create a new TextArea
11516 * @param {Object} config The config object
11519 Roo.bootstrap.TextArea = function(config){
11520 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
11524 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
11534 getAutoCreate : function(){
11536 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
11542 if(this.inputType != 'hidden'){
11543 cfg.cls = 'form-group' //input-group
11551 value : this.value || '',
11552 html: this.html || '',
11553 cls : 'form-control',
11554 placeholder : this.placeholder || ''
11558 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
11559 input.maxLength = this.maxLength;
11563 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
11567 input.cols = this.cols;
11570 if (this.readOnly) {
11571 input.readonly = true;
11575 input.name = this.name;
11579 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
11583 ['xs','sm','md','lg'].map(function(size){
11584 if (settings[size]) {
11585 cfg.cls += ' col-' + size + '-' + settings[size];
11589 var inputblock = input;
11591 if(this.hasFeedback && !this.allowBlank){
11595 cls: 'glyphicon form-control-feedback'
11599 cls : 'has-feedback',
11608 if (this.before || this.after) {
11611 cls : 'input-group',
11615 inputblock.cn.push({
11617 cls : 'input-group-addon',
11622 inputblock.cn.push(input);
11624 if(this.hasFeedback && !this.allowBlank){
11625 inputblock.cls += ' has-feedback';
11626 inputblock.cn.push(feedback);
11630 inputblock.cn.push({
11632 cls : 'input-group-addon',
11639 if (align ==='left' && this.fieldLabel.length) {
11644 cls : 'control-label',
11645 html : this.fieldLabel
11656 if(this.labelWidth > 12){
11657 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
11660 if(this.labelWidth < 13 && this.labelmd == 0){
11661 this.labelmd = this.labelWidth;
11664 if(this.labellg > 0){
11665 cfg.cn[0].cls += ' col-lg-' + this.labellg;
11666 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
11669 if(this.labelmd > 0){
11670 cfg.cn[0].cls += ' col-md-' + this.labelmd;
11671 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
11674 if(this.labelsm > 0){
11675 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
11676 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
11679 if(this.labelxs > 0){
11680 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
11681 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
11684 } else if ( this.fieldLabel.length) {
11689 //cls : 'input-group-addon',
11690 html : this.fieldLabel
11708 if (this.disabled) {
11709 input.disabled=true;
11716 * return the real textarea element.
11718 inputEl: function ()
11720 return this.el.select('textarea.form-control',true).first();
11724 * Clear any invalid styles/messages for this field
11726 clearInvalid : function()
11729 if(!this.el || this.preventMark){ // not rendered
11733 var label = this.el.select('label', true).first();
11734 var icon = this.el.select('i.fa-star', true).first();
11739 this.el.removeClass( this.validClass);
11740 this.inputEl().removeClass('is-invalid');
11742 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
11744 var feedback = this.el.select('.form-control-feedback', true).first();
11747 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
11752 this.fireEvent('valid', this);
11756 * Mark this field as valid
11758 markValid : function()
11760 if(!this.el || this.preventMark){ // not rendered
11764 this.el.removeClass([this.invalidClass, this.validClass]);
11765 this.inputEl().removeClass(['is-valid', 'is-invalid']);
11767 var feedback = this.el.select('.form-control-feedback', true).first();
11770 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
11773 if(this.disabled || this.allowBlank){
11777 var label = this.el.select('label', true).first();
11778 var icon = this.el.select('i.fa-star', true).first();
11783 if (Roo.bootstrap.version == 3) {
11784 this.el.addClass(this.validClass);
11786 this.inputEl().addClass('is-valid');
11790 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
11792 var feedback = this.el.select('.form-control-feedback', true).first();
11795 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
11796 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
11801 this.fireEvent('valid', this);
11805 * Mark this field as invalid
11806 * @param {String} msg The validation message
11808 markInvalid : function(msg)
11810 if(!this.el || this.preventMark){ // not rendered
11814 this.el.removeClass([this.invalidClass, this.validClass]);
11815 this.inputEl().removeClass(['is-valid', 'is-invalid']);
11817 var feedback = this.el.select('.form-control-feedback', true).first();
11820 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
11823 if(this.disabled || this.allowBlank){
11827 var label = this.el.select('label', true).first();
11828 var icon = this.el.select('i.fa-star', true).first();
11830 if(!this.getValue().length && label && !icon){
11831 this.el.createChild({
11833 cls : 'text-danger fa fa-lg fa-star',
11834 tooltip : 'This field is required',
11835 style : 'margin-right:5px;'
11839 if (Roo.bootstrap.version == 3) {
11840 this.el.addClass(this.invalidClass);
11842 this.inputEl().addClass('is-invalid');
11845 // fixme ... this may be depricated need to test..
11846 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
11848 var feedback = this.el.select('.form-control-feedback', true).first();
11851 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
11853 if(this.getValue().length || this.forceFeedback){
11854 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
11861 this.fireEvent('invalid', this, msg);
11869 * trigger field - base class for combo..
11874 * @class Roo.bootstrap.TriggerField
11875 * @extends Roo.bootstrap.Input
11876 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
11877 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
11878 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
11879 * for which you can provide a custom implementation. For example:
11881 var trigger = new Roo.bootstrap.TriggerField();
11882 trigger.onTriggerClick = myTriggerFn;
11883 trigger.applyTo('my-field');
11886 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
11887 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
11888 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
11889 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
11890 * @cfg {String} caret (search|calendar) BS3 only - carat fa name
11893 * Create a new TriggerField.
11894 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
11895 * to the base TextField)
11897 Roo.bootstrap.TriggerField = function(config){
11898 this.mimicing = false;
11899 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
11902 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
11904 * @cfg {String} triggerClass A CSS class to apply to the trigger
11907 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
11912 * @cfg {Boolean} removable (true|false) special filter default false
11916 /** @cfg {Boolean} grow @hide */
11917 /** @cfg {Number} growMin @hide */
11918 /** @cfg {Number} growMax @hide */
11924 autoSize: Roo.emptyFn,
11928 deferHeight : true,
11931 actionMode : 'wrap',
11936 getAutoCreate : function(){
11938 var align = this.labelAlign || this.parentLabelAlign();
11943 cls: 'form-group' //input-group
11950 type : this.inputType,
11951 cls : 'form-control',
11952 autocomplete: 'new-password',
11953 placeholder : this.placeholder || ''
11957 input.name = this.name;
11960 input.cls += ' input-' + this.size;
11963 if (this.disabled) {
11964 input.disabled=true;
11967 var inputblock = input;
11969 if(this.hasFeedback && !this.allowBlank){
11973 cls: 'glyphicon form-control-feedback'
11976 if(this.removable && !this.editable ){
11978 cls : 'has-feedback',
11984 cls : 'roo-combo-removable-btn close'
11991 cls : 'has-feedback',
12000 if(this.removable && !this.editable ){
12002 cls : 'roo-removable',
12008 cls : 'roo-combo-removable-btn close'
12015 if (this.before || this.after) {
12018 cls : 'input-group',
12022 inputblock.cn.push({
12024 cls : 'input-group-addon input-group-prepend input-group-text',
12029 inputblock.cn.push(input);
12031 if(this.hasFeedback && !this.allowBlank){
12032 inputblock.cls += ' has-feedback';
12033 inputblock.cn.push(feedback);
12037 inputblock.cn.push({
12039 cls : 'input-group-addon input-group-append input-group-text',
12048 var ibwrap = inputblock;
12053 cls: 'roo-select2-choices',
12057 cls: 'roo-select2-search-field',
12069 cls: 'roo-select2-container input-group',
12074 cls: 'form-hidden-field'
12080 if(!this.multiple && this.showToggleBtn){
12086 if (this.caret != false) {
12089 cls: 'fa fa-' + this.caret
12096 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
12098 Roo.bootstrap.version == 3 ? caret : '',
12101 cls: 'combobox-clear',
12115 combobox.cls += ' roo-select2-container-multi';
12119 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
12120 tooltip : 'This field is required'
12122 if (Roo.bootstrap.version == 4) {
12125 style : 'display:none'
12130 if (align ==='left' && this.fieldLabel.length) {
12132 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
12139 cls : 'control-label',
12140 html : this.fieldLabel
12152 var labelCfg = cfg.cn[1];
12153 var contentCfg = cfg.cn[2];
12155 if(this.indicatorpos == 'right'){
12160 cls : 'control-label',
12164 html : this.fieldLabel
12178 labelCfg = cfg.cn[0];
12179 contentCfg = cfg.cn[1];
12182 if(this.labelWidth > 12){
12183 labelCfg.style = "width: " + this.labelWidth + 'px';
12186 if(this.labelWidth < 13 && this.labelmd == 0){
12187 this.labelmd = this.labelWidth;
12190 if(this.labellg > 0){
12191 labelCfg.cls += ' col-lg-' + this.labellg;
12192 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
12195 if(this.labelmd > 0){
12196 labelCfg.cls += ' col-md-' + this.labelmd;
12197 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
12200 if(this.labelsm > 0){
12201 labelCfg.cls += ' col-sm-' + this.labelsm;
12202 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
12205 if(this.labelxs > 0){
12206 labelCfg.cls += ' col-xs-' + this.labelxs;
12207 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
12210 } else if ( this.fieldLabel.length) {
12211 // Roo.log(" label");
12216 //cls : 'input-group-addon',
12217 html : this.fieldLabel
12225 if(this.indicatorpos == 'right'){
12233 html : this.fieldLabel
12247 // Roo.log(" no label && no align");
12254 ['xs','sm','md','lg'].map(function(size){
12255 if (settings[size]) {
12256 cfg.cls += ' col-' + size + '-' + settings[size];
12267 onResize : function(w, h){
12268 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
12269 // if(typeof w == 'number'){
12270 // var x = w - this.trigger.getWidth();
12271 // this.inputEl().setWidth(this.adjustWidth('input', x));
12272 // this.trigger.setStyle('left', x+'px');
12277 adjustSize : Roo.BoxComponent.prototype.adjustSize,
12280 getResizeEl : function(){
12281 return this.inputEl();
12285 getPositionEl : function(){
12286 return this.inputEl();
12290 alignErrorIcon : function(){
12291 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
12295 initEvents : function(){
12299 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
12300 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
12301 if(!this.multiple && this.showToggleBtn){
12302 this.trigger = this.el.select('span.dropdown-toggle',true).first();
12303 if(this.hideTrigger){
12304 this.trigger.setDisplayed(false);
12306 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
12310 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
12313 if(this.removable && !this.editable && !this.tickable){
12314 var close = this.closeTriggerEl();
12317 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
12318 close.on('click', this.removeBtnClick, this, close);
12322 //this.trigger.addClassOnOver('x-form-trigger-over');
12323 //this.trigger.addClassOnClick('x-form-trigger-click');
12326 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
12330 closeTriggerEl : function()
12332 var close = this.el.select('.roo-combo-removable-btn', true).first();
12333 return close ? close : false;
12336 removeBtnClick : function(e, h, el)
12338 e.preventDefault();
12340 if(this.fireEvent("remove", this) !== false){
12342 this.fireEvent("afterremove", this)
12346 createList : function()
12348 this.list = Roo.get(document.body).createChild({
12349 tag: Roo.bootstrap.version == 4 ? 'div' : 'ul',
12350 cls: 'typeahead typeahead-long dropdown-menu shadow',
12351 style: 'display:none'
12354 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
12359 initTrigger : function(){
12364 onDestroy : function(){
12366 this.trigger.removeAllListeners();
12367 // this.trigger.remove();
12370 // this.wrap.remove();
12372 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
12376 onFocus : function(){
12377 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
12379 if(!this.mimicing){
12380 this.wrap.addClass('x-trigger-wrap-focus');
12381 this.mimicing = true;
12382 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
12383 if(this.monitorTab){
12384 this.el.on("keydown", this.checkTab, this);
12391 checkTab : function(e){
12392 if(e.getKey() == e.TAB){
12393 this.triggerBlur();
12398 onBlur : function(){
12403 mimicBlur : function(e, t){
12405 if(!this.wrap.contains(t) && this.validateBlur()){
12406 this.triggerBlur();
12412 triggerBlur : function(){
12413 this.mimicing = false;
12414 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
12415 if(this.monitorTab){
12416 this.el.un("keydown", this.checkTab, this);
12418 //this.wrap.removeClass('x-trigger-wrap-focus');
12419 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
12423 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
12424 validateBlur : function(e, t){
12429 onDisable : function(){
12430 this.inputEl().dom.disabled = true;
12431 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
12433 // this.wrap.addClass('x-item-disabled');
12438 onEnable : function(){
12439 this.inputEl().dom.disabled = false;
12440 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
12442 // this.el.removeClass('x-item-disabled');
12447 onShow : function(){
12448 var ae = this.getActionEl();
12451 ae.dom.style.display = '';
12452 ae.dom.style.visibility = 'visible';
12458 onHide : function(){
12459 var ae = this.getActionEl();
12460 ae.dom.style.display = 'none';
12464 * The function that should handle the trigger's click event. This method does nothing by default until overridden
12465 * by an implementing function.
12467 * @param {EventObject} e
12469 onTriggerClick : Roo.emptyFn
12477 * @class Roo.bootstrap.CardUploader
12478 * @extends Roo.bootstrap.Button
12479 * Bootstrap Card Uploader class - it's a button which when you add files to it, adds cards below with preview and the name...
12480 * @cfg {Number} errorTimeout default 3000
12481 * @cfg {Array} images an array of ?? Img objects ??? when loading existing files..
12482 * @cfg {Array} html The button text.
12486 * Create a new CardUploader
12487 * @param {Object} config The config object
12490 Roo.bootstrap.CardUploader = function(config){
12494 Roo.bootstrap.CardUploader.superclass.constructor.call(this, config);
12497 this.fileCollection = new Roo.util.MixedCollection(false,function(r) {
12504 Roo.extend(Roo.bootstrap.CardUploader, Roo.bootstrap.Input, {
12507 errorTimeout : 3000,
12511 fileCollection : false,
12514 getAutoCreate : function()
12518 cls :'form-group' ,
12523 //cls : 'input-group-addon',
12524 html : this.fieldLabel
12531 value : this.value,
12532 cls : 'd-none form-control'
12537 multiple : 'multiple',
12539 cls : 'd-none roo-card-upload-selector'
12543 cls : 'roo-card-uploader-button-container w-100 mb-2'
12546 cls : 'card-columns roo-card-uploader-container'
12556 getChildContainer : function() /// what children are added to.
12558 return this.containerEl;
12561 getButtonContainer : function() /// what children are added to.
12563 return this.el.select(".roo-card-uploader-button-container").first();
12566 initEvents : function()
12569 Roo.bootstrap.Input.prototype.initEvents.call(this);
12573 xns: Roo.bootstrap,
12576 container_method : 'getButtonContainer' ,
12577 html : this.html, // fix changable?
12580 'click' : function(btn, e) {
12589 this.urlAPI = (window.createObjectURL && window) ||
12590 (window.URL && URL.revokeObjectURL && URL) ||
12591 (window.webkitURL && webkitURL);
12596 this.selectorEl = this.el.select('.roo-card-upload-selector', true).first();
12598 this.selectorEl.on('change', this.onFileSelected, this);
12601 this.images.forEach(function(img) {
12604 this.images = false;
12606 this.containerEl = this.el.select('.roo-card-uploader-container', true).first();
12612 onClick : function(e)
12614 e.preventDefault();
12616 this.selectorEl.dom.click();
12620 onFileSelected : function(e)
12622 e.preventDefault();
12624 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
12628 Roo.each(this.selectorEl.dom.files, function(file){
12629 this.addFile(file);
12638 addFile : function(file)
12641 if(typeof(file) === 'string'){
12642 throw "Add file by name?"; // should not happen
12646 if(!file || !this.urlAPI){
12656 var url = _this.urlAPI.createObjectURL( file);
12659 id : Roo.bootstrap.CardUploader.ID--,
12660 is_uploaded : false,
12663 mimetype : file.type,
12670 addCard : function (data)
12672 // hidden input element?
12673 // if the file is not an image...
12674 //then we need to use something other that and header_image
12679 xns : Roo.bootstrap,
12680 xtype : 'CardFooter',
12683 xns : Roo.bootstrap,
12689 xns : Roo.bootstrap,
12691 html : String.format("<small>{0}</small>", data.title),
12692 cls : 'col-11 text-left',
12697 click : function() {
12698 this.downloadCard(data.id)
12704 xns : Roo.bootstrap,
12712 click : function() {
12713 t.removeCard(data.id)
12725 var cn = this.addxtype(
12728 xns : Roo.bootstrap,
12731 header : !data.mimetype.match(/image/) && !data.preview ? "Document": false,
12732 header_image : data.mimetype.match(/image/) ? data.src : data.preview,
12733 header_image_fit_square: true, // fixme - we probably need to use the 'Img' element to do stuff like this.
12738 initEvents : function() {
12739 Roo.bootstrap.Card.prototype.initEvents.call(this);
12740 this.imgEl = this.el.select('.card-img-top').first();
12742 this.imgEl.on('click', function() { t.previewCard( data.id); }, this);
12743 this.imgEl.set({ 'pointer' : 'cursor' });
12752 // dont' really need ot update items.
12753 // this.items.push(cn);
12754 this.fileCollection.add(cn);
12755 this.updateInput();
12758 removeCard : function(id)
12761 var card = this.fileCollection.get(id);
12762 card.data.is_deleted = 1;
12763 card.data.src = ''; /// delete the source - so it reduces size of not uploaded images etc.
12764 this.fileCollection.remove(card);
12765 //this.items = this.items.filter(function(e) { return e != card });
12766 // dont' really need ot update items.
12767 card.el.dom.parentNode.removeChild(card.el.dom);
12772 this.fileCollection.each(function(card) {
12773 card.el.dom.parentNode.removeChild(card.el.dom);
12775 this.fileCollection.clear();
12776 this.updateInput();
12779 updateInput : function()
12782 this.fileCollection.each(function(e) {
12786 this.inputEl().dom.value = JSON.stringify(data);
12793 Roo.bootstrap.CardUploader.ID = -1;/*
12795 * Ext JS Library 1.1.1
12796 * Copyright(c) 2006-2007, Ext JS, LLC.
12798 * Originally Released Under LGPL - original licence link has changed is not relivant.
12801 * <script type="text/javascript">
12806 * @class Roo.data.SortTypes
12808 * Defines the default sorting (casting?) comparison functions used when sorting data.
12810 Roo.data.SortTypes = {
12812 * Default sort that does nothing
12813 * @param {Mixed} s The value being converted
12814 * @return {Mixed} The comparison value
12816 none : function(s){
12821 * The regular expression used to strip tags
12825 stripTagsRE : /<\/?[^>]+>/gi,
12828 * Strips all HTML tags to sort on text only
12829 * @param {Mixed} s The value being converted
12830 * @return {String} The comparison value
12832 asText : function(s){
12833 return String(s).replace(this.stripTagsRE, "");
12837 * Strips all HTML tags to sort on text only - Case insensitive
12838 * @param {Mixed} s The value being converted
12839 * @return {String} The comparison value
12841 asUCText : function(s){
12842 return String(s).toUpperCase().replace(this.stripTagsRE, "");
12846 * Case insensitive string
12847 * @param {Mixed} s The value being converted
12848 * @return {String} The comparison value
12850 asUCString : function(s) {
12851 return String(s).toUpperCase();
12856 * @param {Mixed} s The value being converted
12857 * @return {Number} The comparison value
12859 asDate : function(s) {
12863 if(s instanceof Date){
12864 return s.getTime();
12866 return Date.parse(String(s));
12871 * @param {Mixed} s The value being converted
12872 * @return {Float} The comparison value
12874 asFloat : function(s) {
12875 var val = parseFloat(String(s).replace(/,/g, ""));
12884 * @param {Mixed} s The value being converted
12885 * @return {Number} The comparison value
12887 asInt : function(s) {
12888 var val = parseInt(String(s).replace(/,/g, ""));
12896 * Ext JS Library 1.1.1
12897 * Copyright(c) 2006-2007, Ext JS, LLC.
12899 * Originally Released Under LGPL - original licence link has changed is not relivant.
12902 * <script type="text/javascript">
12906 * @class Roo.data.Record
12907 * Instances of this class encapsulate both record <em>definition</em> information, and record
12908 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
12909 * to access Records cached in an {@link Roo.data.Store} object.<br>
12911 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
12912 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
12915 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
12917 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
12918 * {@link #create}. The parameters are the same.
12919 * @param {Array} data An associative Array of data values keyed by the field name.
12920 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
12921 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
12922 * not specified an integer id is generated.
12924 Roo.data.Record = function(data, id){
12925 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
12930 * Generate a constructor for a specific record layout.
12931 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
12932 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
12933 * Each field definition object may contain the following properties: <ul>
12934 * <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,
12935 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
12936 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
12937 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
12938 * is being used, then this is a string containing the javascript expression to reference the data relative to
12939 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
12940 * to the data item relative to the record element. If the mapping expression is the same as the field name,
12941 * this may be omitted.</p></li>
12942 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
12943 * <ul><li>auto (Default, implies no conversion)</li>
12948 * <li>date</li></ul></p></li>
12949 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
12950 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
12951 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
12952 * by the Reader into an object that will be stored in the Record. It is passed the
12953 * following parameters:<ul>
12954 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
12956 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
12958 * <br>usage:<br><pre><code>
12959 var TopicRecord = Roo.data.Record.create(
12960 {name: 'title', mapping: 'topic_title'},
12961 {name: 'author', mapping: 'username'},
12962 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
12963 {name: 'lastPost', mapping: 'post_time', type: 'date'},
12964 {name: 'lastPoster', mapping: 'user2'},
12965 {name: 'excerpt', mapping: 'post_text'}
12968 var myNewRecord = new TopicRecord({
12969 title: 'Do my job please',
12972 lastPost: new Date(),
12973 lastPoster: 'Animal',
12974 excerpt: 'No way dude!'
12976 myStore.add(myNewRecord);
12981 Roo.data.Record.create = function(o){
12982 var f = function(){
12983 f.superclass.constructor.apply(this, arguments);
12985 Roo.extend(f, Roo.data.Record);
12986 var p = f.prototype;
12987 p.fields = new Roo.util.MixedCollection(false, function(field){
12990 for(var i = 0, len = o.length; i < len; i++){
12991 p.fields.add(new Roo.data.Field(o[i]));
12993 f.getField = function(name){
12994 return p.fields.get(name);
12999 Roo.data.Record.AUTO_ID = 1000;
13000 Roo.data.Record.EDIT = 'edit';
13001 Roo.data.Record.REJECT = 'reject';
13002 Roo.data.Record.COMMIT = 'commit';
13004 Roo.data.Record.prototype = {
13006 * Readonly flag - true if this record has been modified.
13015 join : function(store){
13016 this.store = store;
13020 * Set the named field to the specified value.
13021 * @param {String} name The name of the field to set.
13022 * @param {Object} value The value to set the field to.
13024 set : function(name, value){
13025 if(this.data[name] == value){
13029 if(!this.modified){
13030 this.modified = {};
13032 if(typeof this.modified[name] == 'undefined'){
13033 this.modified[name] = this.data[name];
13035 this.data[name] = value;
13036 if(!this.editing && this.store){
13037 this.store.afterEdit(this);
13042 * Get the value of the named field.
13043 * @param {String} name The name of the field to get the value of.
13044 * @return {Object} The value of the field.
13046 get : function(name){
13047 return this.data[name];
13051 beginEdit : function(){
13052 this.editing = true;
13053 this.modified = {};
13057 cancelEdit : function(){
13058 this.editing = false;
13059 delete this.modified;
13063 endEdit : function(){
13064 this.editing = false;
13065 if(this.dirty && this.store){
13066 this.store.afterEdit(this);
13071 * Usually called by the {@link Roo.data.Store} which owns the Record.
13072 * Rejects all changes made to the Record since either creation, or the last commit operation.
13073 * Modified fields are reverted to their original values.
13075 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
13076 * of reject operations.
13078 reject : function(){
13079 var m = this.modified;
13081 if(typeof m[n] != "function"){
13082 this.data[n] = m[n];
13085 this.dirty = false;
13086 delete this.modified;
13087 this.editing = false;
13089 this.store.afterReject(this);
13094 * Usually called by the {@link Roo.data.Store} which owns the Record.
13095 * Commits all changes made to the Record since either creation, or the last commit operation.
13097 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
13098 * of commit operations.
13100 commit : function(){
13101 this.dirty = false;
13102 delete this.modified;
13103 this.editing = false;
13105 this.store.afterCommit(this);
13110 hasError : function(){
13111 return this.error != null;
13115 clearError : function(){
13120 * Creates a copy of this record.
13121 * @param {String} id (optional) A new record id if you don't want to use this record's id
13124 copy : function(newId) {
13125 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
13129 * Ext JS Library 1.1.1
13130 * Copyright(c) 2006-2007, Ext JS, LLC.
13132 * Originally Released Under LGPL - original licence link has changed is not relivant.
13135 * <script type="text/javascript">
13141 * @class Roo.data.Store
13142 * @extends Roo.util.Observable
13143 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
13144 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
13146 * 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
13147 * has no knowledge of the format of the data returned by the Proxy.<br>
13149 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
13150 * instances from the data object. These records are cached and made available through accessor functions.
13152 * Creates a new Store.
13153 * @param {Object} config A config object containing the objects needed for the Store to access data,
13154 * and read the data into Records.
13156 Roo.data.Store = function(config){
13157 this.data = new Roo.util.MixedCollection(false);
13158 this.data.getKey = function(o){
13161 this.baseParams = {};
13163 this.paramNames = {
13168 "multisort" : "_multisort"
13171 if(config && config.data){
13172 this.inlineData = config.data;
13173 delete config.data;
13176 Roo.apply(this, config);
13178 if(this.reader){ // reader passed
13179 this.reader = Roo.factory(this.reader, Roo.data);
13180 this.reader.xmodule = this.xmodule || false;
13181 if(!this.recordType){
13182 this.recordType = this.reader.recordType;
13184 if(this.reader.onMetaChange){
13185 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
13189 if(this.recordType){
13190 this.fields = this.recordType.prototype.fields;
13192 this.modified = [];
13196 * @event datachanged
13197 * Fires when the data cache has changed, and a widget which is using this Store
13198 * as a Record cache should refresh its view.
13199 * @param {Store} this
13201 datachanged : true,
13203 * @event metachange
13204 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
13205 * @param {Store} this
13206 * @param {Object} meta The JSON metadata
13211 * Fires when Records have been added to the Store
13212 * @param {Store} this
13213 * @param {Roo.data.Record[]} records The array of Records added
13214 * @param {Number} index The index at which the record(s) were added
13219 * Fires when a Record has been removed from the Store
13220 * @param {Store} this
13221 * @param {Roo.data.Record} record The Record that was removed
13222 * @param {Number} index The index at which the record was removed
13227 * Fires when a Record has been updated
13228 * @param {Store} this
13229 * @param {Roo.data.Record} record The Record that was updated
13230 * @param {String} operation The update operation being performed. Value may be one of:
13232 Roo.data.Record.EDIT
13233 Roo.data.Record.REJECT
13234 Roo.data.Record.COMMIT
13240 * Fires when the data cache has been cleared.
13241 * @param {Store} this
13245 * @event beforeload
13246 * Fires before a request is made for a new data object. If the beforeload handler returns false
13247 * the load action will be canceled.
13248 * @param {Store} this
13249 * @param {Object} options The loading options that were specified (see {@link #load} for details)
13253 * @event beforeloadadd
13254 * Fires after a new set of Records has been loaded.
13255 * @param {Store} this
13256 * @param {Roo.data.Record[]} records The Records that were loaded
13257 * @param {Object} options The loading options that were specified (see {@link #load} for details)
13259 beforeloadadd : true,
13262 * Fires after a new set of Records has been loaded, before they are added to the store.
13263 * @param {Store} this
13264 * @param {Roo.data.Record[]} records The Records that were loaded
13265 * @param {Object} options The loading options that were specified (see {@link #load} for details)
13266 * @params {Object} return from reader
13270 * @event loadexception
13271 * Fires if an exception occurs in the Proxy during loading.
13272 * Called with the signature of the Proxy's "loadexception" event.
13273 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
13276 * @param {Object} return from JsonData.reader() - success, totalRecords, records
13277 * @param {Object} load options
13278 * @param {Object} jsonData from your request (normally this contains the Exception)
13280 loadexception : true
13284 this.proxy = Roo.factory(this.proxy, Roo.data);
13285 this.proxy.xmodule = this.xmodule || false;
13286 this.relayEvents(this.proxy, ["loadexception"]);
13288 this.sortToggle = {};
13289 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
13291 Roo.data.Store.superclass.constructor.call(this);
13293 if(this.inlineData){
13294 this.loadData(this.inlineData);
13295 delete this.inlineData;
13299 Roo.extend(Roo.data.Store, Roo.util.Observable, {
13301 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
13302 * without a remote query - used by combo/forms at present.
13306 * @cfg {Roo.data.DataProxy} proxy The Proxy object which provides access to a data object.
13309 * @cfg {Array} data Inline data to be loaded when the store is initialized.
13312 * @cfg {Roo.data.Reader} reader The Reader object which processes the data object and returns
13313 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
13316 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
13317 * on any HTTP request
13320 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
13323 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
13327 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
13328 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
13330 remoteSort : false,
13333 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
13334 * loaded or when a record is removed. (defaults to false).
13336 pruneModifiedRecords : false,
13339 lastOptions : null,
13342 * Add Records to the Store and fires the add event.
13343 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
13345 add : function(records){
13346 records = [].concat(records);
13347 for(var i = 0, len = records.length; i < len; i++){
13348 records[i].join(this);
13350 var index = this.data.length;
13351 this.data.addAll(records);
13352 this.fireEvent("add", this, records, index);
13356 * Remove a Record from the Store and fires the remove event.
13357 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
13359 remove : function(record){
13360 var index = this.data.indexOf(record);
13361 this.data.removeAt(index);
13363 if(this.pruneModifiedRecords){
13364 this.modified.remove(record);
13366 this.fireEvent("remove", this, record, index);
13370 * Remove all Records from the Store and fires the clear event.
13372 removeAll : function(){
13374 if(this.pruneModifiedRecords){
13375 this.modified = [];
13377 this.fireEvent("clear", this);
13381 * Inserts Records to the Store at the given index and fires the add event.
13382 * @param {Number} index The start index at which to insert the passed Records.
13383 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
13385 insert : function(index, records){
13386 records = [].concat(records);
13387 for(var i = 0, len = records.length; i < len; i++){
13388 this.data.insert(index, records[i]);
13389 records[i].join(this);
13391 this.fireEvent("add", this, records, index);
13395 * Get the index within the cache of the passed Record.
13396 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
13397 * @return {Number} The index of the passed Record. Returns -1 if not found.
13399 indexOf : function(record){
13400 return this.data.indexOf(record);
13404 * Get the index within the cache of the Record with the passed id.
13405 * @param {String} id The id of the Record to find.
13406 * @return {Number} The index of the Record. Returns -1 if not found.
13408 indexOfId : function(id){
13409 return this.data.indexOfKey(id);
13413 * Get the Record with the specified id.
13414 * @param {String} id The id of the Record to find.
13415 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
13417 getById : function(id){
13418 return this.data.key(id);
13422 * Get the Record at the specified index.
13423 * @param {Number} index The index of the Record to find.
13424 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
13426 getAt : function(index){
13427 return this.data.itemAt(index);
13431 * Returns a range of Records between specified indices.
13432 * @param {Number} startIndex (optional) The starting index (defaults to 0)
13433 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
13434 * @return {Roo.data.Record[]} An array of Records
13436 getRange : function(start, end){
13437 return this.data.getRange(start, end);
13441 storeOptions : function(o){
13442 o = Roo.apply({}, o);
13445 this.lastOptions = o;
13449 * Loads the Record cache from the configured Proxy using the configured Reader.
13451 * If using remote paging, then the first load call must specify the <em>start</em>
13452 * and <em>limit</em> properties in the options.params property to establish the initial
13453 * position within the dataset, and the number of Records to cache on each read from the Proxy.
13455 * <strong>It is important to note that for remote data sources, loading is asynchronous,
13456 * and this call will return before the new data has been loaded. Perform any post-processing
13457 * in a callback function, or in a "load" event handler.</strong>
13459 * @param {Object} options An object containing properties which control loading options:<ul>
13460 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
13461 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
13462 * passed the following arguments:<ul>
13463 * <li>r : Roo.data.Record[]</li>
13464 * <li>options: Options object from the load call</li>
13465 * <li>success: Boolean success indicator</li></ul></li>
13466 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
13467 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
13470 load : function(options){
13471 options = options || {};
13472 if(this.fireEvent("beforeload", this, options) !== false){
13473 this.storeOptions(options);
13474 var p = Roo.apply(options.params || {}, this.baseParams);
13475 // if meta was not loaded from remote source.. try requesting it.
13476 if (!this.reader.metaFromRemote) {
13477 p._requestMeta = 1;
13479 if(this.sortInfo && this.remoteSort){
13480 var pn = this.paramNames;
13481 p[pn["sort"]] = this.sortInfo.field;
13482 p[pn["dir"]] = this.sortInfo.direction;
13484 if (this.multiSort) {
13485 var pn = this.paramNames;
13486 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
13489 this.proxy.load(p, this.reader, this.loadRecords, this, options);
13494 * Reloads the Record cache from the configured Proxy using the configured Reader and
13495 * the options from the last load operation performed.
13496 * @param {Object} options (optional) An object containing properties which may override the options
13497 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
13498 * the most recently used options are reused).
13500 reload : function(options){
13501 this.load(Roo.applyIf(options||{}, this.lastOptions));
13505 // Called as a callback by the Reader during a load operation.
13506 loadRecords : function(o, options, success){
13507 if(!o || success === false){
13508 if(success !== false){
13509 this.fireEvent("load", this, [], options, o);
13511 if(options.callback){
13512 options.callback.call(options.scope || this, [], options, false);
13516 // if data returned failure - throw an exception.
13517 if (o.success === false) {
13518 // show a message if no listener is registered.
13519 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
13520 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
13522 // loadmask wil be hooked into this..
13523 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
13526 var r = o.records, t = o.totalRecords || r.length;
13528 this.fireEvent("beforeloadadd", this, r, options, o);
13530 if(!options || options.add !== true){
13531 if(this.pruneModifiedRecords){
13532 this.modified = [];
13534 for(var i = 0, len = r.length; i < len; i++){
13538 this.data = this.snapshot;
13539 delete this.snapshot;
13542 this.data.addAll(r);
13543 this.totalLength = t;
13545 this.fireEvent("datachanged", this);
13547 this.totalLength = Math.max(t, this.data.length+r.length);
13551 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
13553 var e = new Roo.data.Record({});
13555 e.set(this.parent.displayField, this.parent.emptyTitle);
13556 e.set(this.parent.valueField, '');
13561 this.fireEvent("load", this, r, options, o);
13562 if(options.callback){
13563 options.callback.call(options.scope || this, r, options, true);
13569 * Loads data from a passed data block. A Reader which understands the format of the data
13570 * must have been configured in the constructor.
13571 * @param {Object} data The data block from which to read the Records. The format of the data expected
13572 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
13573 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
13575 loadData : function(o, append){
13576 var r = this.reader.readRecords(o);
13577 this.loadRecords(r, {add: append}, true);
13581 * using 'cn' the nested child reader read the child array into it's child stores.
13582 * @param {Object} rec The record with a 'children array
13584 loadDataFromChildren : function(rec)
13586 this.loadData(this.reader.toLoadData(rec));
13591 * Gets the number of cached records.
13593 * <em>If using paging, this may not be the total size of the dataset. If the data object
13594 * used by the Reader contains the dataset size, then the getTotalCount() function returns
13595 * the data set size</em>
13597 getCount : function(){
13598 return this.data.length || 0;
13602 * Gets the total number of records in the dataset as returned by the server.
13604 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
13605 * the dataset size</em>
13607 getTotalCount : function(){
13608 return this.totalLength || 0;
13612 * Returns the sort state of the Store as an object with two properties:
13614 field {String} The name of the field by which the Records are sorted
13615 direction {String} The sort order, "ASC" or "DESC"
13618 getSortState : function(){
13619 return this.sortInfo;
13623 applySort : function(){
13624 if(this.sortInfo && !this.remoteSort){
13625 var s = this.sortInfo, f = s.field;
13626 var st = this.fields.get(f).sortType;
13627 var fn = function(r1, r2){
13628 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
13629 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
13631 this.data.sort(s.direction, fn);
13632 if(this.snapshot && this.snapshot != this.data){
13633 this.snapshot.sort(s.direction, fn);
13639 * Sets the default sort column and order to be used by the next load operation.
13640 * @param {String} fieldName The name of the field to sort by.
13641 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
13643 setDefaultSort : function(field, dir){
13644 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
13648 * Sort the Records.
13649 * If remote sorting is used, the sort is performed on the server, and the cache is
13650 * reloaded. If local sorting is used, the cache is sorted internally.
13651 * @param {String} fieldName The name of the field to sort by.
13652 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
13654 sort : function(fieldName, dir){
13655 var f = this.fields.get(fieldName);
13657 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
13659 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
13660 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
13665 this.sortToggle[f.name] = dir;
13666 this.sortInfo = {field: f.name, direction: dir};
13667 if(!this.remoteSort){
13669 this.fireEvent("datachanged", this);
13671 this.load(this.lastOptions);
13676 * Calls the specified function for each of the Records in the cache.
13677 * @param {Function} fn The function to call. The Record is passed as the first parameter.
13678 * Returning <em>false</em> aborts and exits the iteration.
13679 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
13681 each : function(fn, scope){
13682 this.data.each(fn, scope);
13686 * Gets all records modified since the last commit. Modified records are persisted across load operations
13687 * (e.g., during paging).
13688 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
13690 getModifiedRecords : function(){
13691 return this.modified;
13695 createFilterFn : function(property, value, anyMatch){
13696 if(!value.exec){ // not a regex
13697 value = String(value);
13698 if(value.length == 0){
13701 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
13703 return function(r){
13704 return value.test(r.data[property]);
13709 * Sums the value of <i>property</i> for each record between start and end and returns the result.
13710 * @param {String} property A field on your records
13711 * @param {Number} start The record index to start at (defaults to 0)
13712 * @param {Number} end The last record index to include (defaults to length - 1)
13713 * @return {Number} The sum
13715 sum : function(property, start, end){
13716 var rs = this.data.items, v = 0;
13717 start = start || 0;
13718 end = (end || end === 0) ? end : rs.length-1;
13720 for(var i = start; i <= end; i++){
13721 v += (rs[i].data[property] || 0);
13727 * Filter the records by a specified property.
13728 * @param {String} field A field on your records
13729 * @param {String/RegExp} value Either a string that the field
13730 * should start with or a RegExp to test against the field
13731 * @param {Boolean} anyMatch True to match any part not just the beginning
13733 filter : function(property, value, anyMatch){
13734 var fn = this.createFilterFn(property, value, anyMatch);
13735 return fn ? this.filterBy(fn) : this.clearFilter();
13739 * Filter by a function. The specified function will be called with each
13740 * record in this data source. If the function returns true the record is included,
13741 * otherwise it is filtered.
13742 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
13743 * @param {Object} scope (optional) The scope of the function (defaults to this)
13745 filterBy : function(fn, scope){
13746 this.snapshot = this.snapshot || this.data;
13747 this.data = this.queryBy(fn, scope||this);
13748 this.fireEvent("datachanged", this);
13752 * Query the records by a specified property.
13753 * @param {String} field A field on your records
13754 * @param {String/RegExp} value Either a string that the field
13755 * should start with or a RegExp to test against the field
13756 * @param {Boolean} anyMatch True to match any part not just the beginning
13757 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
13759 query : function(property, value, anyMatch){
13760 var fn = this.createFilterFn(property, value, anyMatch);
13761 return fn ? this.queryBy(fn) : this.data.clone();
13765 * Query by a function. The specified function will be called with each
13766 * record in this data source. If the function returns true the record is included
13768 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
13769 * @param {Object} scope (optional) The scope of the function (defaults to this)
13770 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
13772 queryBy : function(fn, scope){
13773 var data = this.snapshot || this.data;
13774 return data.filterBy(fn, scope||this);
13778 * Collects unique values for a particular dataIndex from this store.
13779 * @param {String} dataIndex The property to collect
13780 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
13781 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
13782 * @return {Array} An array of the unique values
13784 collect : function(dataIndex, allowNull, bypassFilter){
13785 var d = (bypassFilter === true && this.snapshot) ?
13786 this.snapshot.items : this.data.items;
13787 var v, sv, r = [], l = {};
13788 for(var i = 0, len = d.length; i < len; i++){
13789 v = d[i].data[dataIndex];
13791 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
13800 * Revert to a view of the Record cache with no filtering applied.
13801 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
13803 clearFilter : function(suppressEvent){
13804 if(this.snapshot && this.snapshot != this.data){
13805 this.data = this.snapshot;
13806 delete this.snapshot;
13807 if(suppressEvent !== true){
13808 this.fireEvent("datachanged", this);
13814 afterEdit : function(record){
13815 if(this.modified.indexOf(record) == -1){
13816 this.modified.push(record);
13818 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
13822 afterReject : function(record){
13823 this.modified.remove(record);
13824 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
13828 afterCommit : function(record){
13829 this.modified.remove(record);
13830 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
13834 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
13835 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
13837 commitChanges : function(){
13838 var m = this.modified.slice(0);
13839 this.modified = [];
13840 for(var i = 0, len = m.length; i < len; i++){
13846 * Cancel outstanding changes on all changed records.
13848 rejectChanges : function(){
13849 var m = this.modified.slice(0);
13850 this.modified = [];
13851 for(var i = 0, len = m.length; i < len; i++){
13856 onMetaChange : function(meta, rtype, o){
13857 this.recordType = rtype;
13858 this.fields = rtype.prototype.fields;
13859 delete this.snapshot;
13860 this.sortInfo = meta.sortInfo || this.sortInfo;
13861 this.modified = [];
13862 this.fireEvent('metachange', this, this.reader.meta);
13865 moveIndex : function(data, type)
13867 var index = this.indexOf(data);
13869 var newIndex = index + type;
13873 this.insert(newIndex, data);
13878 * Ext JS Library 1.1.1
13879 * Copyright(c) 2006-2007, Ext JS, LLC.
13881 * Originally Released Under LGPL - original licence link has changed is not relivant.
13884 * <script type="text/javascript">
13888 * @class Roo.data.SimpleStore
13889 * @extends Roo.data.Store
13890 * Small helper class to make creating Stores from Array data easier.
13891 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
13892 * @cfg {Array} fields An array of field definition objects, or field name strings.
13893 * @cfg {Object} an existing reader (eg. copied from another store)
13894 * @cfg {Array} data The multi-dimensional array of data
13896 * @param {Object} config
13898 Roo.data.SimpleStore = function(config)
13900 Roo.data.SimpleStore.superclass.constructor.call(this, {
13902 reader: typeof(config.reader) != 'undefined' ? config.reader : new Roo.data.ArrayReader({
13905 Roo.data.Record.create(config.fields)
13907 proxy : new Roo.data.MemoryProxy(config.data)
13911 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
13913 * Ext JS Library 1.1.1
13914 * Copyright(c) 2006-2007, Ext JS, LLC.
13916 * Originally Released Under LGPL - original licence link has changed is not relivant.
13919 * <script type="text/javascript">
13924 * @extends Roo.data.Store
13925 * @class Roo.data.JsonStore
13926 * Small helper class to make creating Stores for JSON data easier. <br/>
13928 var store = new Roo.data.JsonStore({
13929 url: 'get-images.php',
13931 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
13934 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
13935 * JsonReader and HttpProxy (unless inline data is provided).</b>
13936 * @cfg {Array} fields An array of field definition objects, or field name strings.
13938 * @param {Object} config
13940 Roo.data.JsonStore = function(c){
13941 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
13942 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
13943 reader: new Roo.data.JsonReader(c, c.fields)
13946 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
13948 * Ext JS Library 1.1.1
13949 * Copyright(c) 2006-2007, Ext JS, LLC.
13951 * Originally Released Under LGPL - original licence link has changed is not relivant.
13954 * <script type="text/javascript">
13958 Roo.data.Field = function(config){
13959 if(typeof config == "string"){
13960 config = {name: config};
13962 Roo.apply(this, config);
13965 this.type = "auto";
13968 var st = Roo.data.SortTypes;
13969 // named sortTypes are supported, here we look them up
13970 if(typeof this.sortType == "string"){
13971 this.sortType = st[this.sortType];
13974 // set default sortType for strings and dates
13975 if(!this.sortType){
13978 this.sortType = st.asUCString;
13981 this.sortType = st.asDate;
13984 this.sortType = st.none;
13989 var stripRe = /[\$,%]/g;
13991 // prebuilt conversion function for this field, instead of
13992 // switching every time we're reading a value
13994 var cv, dateFormat = this.dateFormat;
13999 cv = function(v){ return v; };
14002 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
14006 return v !== undefined && v !== null && v !== '' ?
14007 parseInt(String(v).replace(stripRe, ""), 10) : '';
14012 return v !== undefined && v !== null && v !== '' ?
14013 parseFloat(String(v).replace(stripRe, ""), 10) : '';
14018 cv = function(v){ return v === true || v === "true" || v == 1; };
14025 if(v instanceof Date){
14029 if(dateFormat == "timestamp"){
14030 return new Date(v*1000);
14032 return Date.parseDate(v, dateFormat);
14034 var parsed = Date.parse(v);
14035 return parsed ? new Date(parsed) : null;
14044 Roo.data.Field.prototype = {
14052 * Ext JS Library 1.1.1
14053 * Copyright(c) 2006-2007, Ext JS, LLC.
14055 * Originally Released Under LGPL - original licence link has changed is not relivant.
14058 * <script type="text/javascript">
14061 // Base class for reading structured data from a data source. This class is intended to be
14062 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
14065 * @class Roo.data.DataReader
14066 * Base class for reading structured data from a data source. This class is intended to be
14067 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
14070 Roo.data.DataReader = function(meta, recordType){
14074 this.recordType = recordType instanceof Array ?
14075 Roo.data.Record.create(recordType) : recordType;
14078 Roo.data.DataReader.prototype = {
14081 readerType : 'Data',
14083 * Create an empty record
14084 * @param {Object} data (optional) - overlay some values
14085 * @return {Roo.data.Record} record created.
14087 newRow : function(d) {
14089 this.recordType.prototype.fields.each(function(c) {
14091 case 'int' : da[c.name] = 0; break;
14092 case 'date' : da[c.name] = new Date(); break;
14093 case 'float' : da[c.name] = 0.0; break;
14094 case 'boolean' : da[c.name] = false; break;
14095 default : da[c.name] = ""; break;
14099 return new this.recordType(Roo.apply(da, d));
14105 * Ext JS Library 1.1.1
14106 * Copyright(c) 2006-2007, Ext JS, LLC.
14108 * Originally Released Under LGPL - original licence link has changed is not relivant.
14111 * <script type="text/javascript">
14115 * @class Roo.data.DataProxy
14116 * @extends Roo.data.Observable
14117 * This class is an abstract base class for implementations which provide retrieval of
14118 * unformatted data objects.<br>
14120 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
14121 * (of the appropriate type which knows how to parse the data object) to provide a block of
14122 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
14124 * Custom implementations must implement the load method as described in
14125 * {@link Roo.data.HttpProxy#load}.
14127 Roo.data.DataProxy = function(){
14130 * @event beforeload
14131 * Fires before a network request is made to retrieve a data object.
14132 * @param {Object} This DataProxy object.
14133 * @param {Object} params The params parameter to the load function.
14138 * Fires before the load method's callback is called.
14139 * @param {Object} This DataProxy object.
14140 * @param {Object} o The data object.
14141 * @param {Object} arg The callback argument object passed to the load function.
14145 * @event loadexception
14146 * Fires if an Exception occurs during data retrieval.
14147 * @param {Object} This DataProxy object.
14148 * @param {Object} o The data object.
14149 * @param {Object} arg The callback argument object passed to the load function.
14150 * @param {Object} e The Exception.
14152 loadexception : true
14154 Roo.data.DataProxy.superclass.constructor.call(this);
14157 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
14160 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
14164 * Ext JS Library 1.1.1
14165 * Copyright(c) 2006-2007, Ext JS, LLC.
14167 * Originally Released Under LGPL - original licence link has changed is not relivant.
14170 * <script type="text/javascript">
14173 * @class Roo.data.MemoryProxy
14174 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
14175 * to the Reader when its load method is called.
14177 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
14179 Roo.data.MemoryProxy = function(data){
14183 Roo.data.MemoryProxy.superclass.constructor.call(this);
14187 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
14190 * Load data from the requested source (in this case an in-memory
14191 * data object passed to the constructor), read the data object into
14192 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
14193 * process that block using the passed callback.
14194 * @param {Object} params This parameter is not used by the MemoryProxy class.
14195 * @param {Roo.data.DataReader} reader The Reader object which converts the data
14196 * object into a block of Roo.data.Records.
14197 * @param {Function} callback The function into which to pass the block of Roo.data.records.
14198 * The function must be passed <ul>
14199 * <li>The Record block object</li>
14200 * <li>The "arg" argument from the load function</li>
14201 * <li>A boolean success indicator</li>
14203 * @param {Object} scope The scope in which to call the callback
14204 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
14206 load : function(params, reader, callback, scope, arg){
14207 params = params || {};
14210 result = reader.readRecords(params.data ? params.data :this.data);
14212 this.fireEvent("loadexception", this, arg, null, e);
14213 callback.call(scope, null, arg, false);
14216 callback.call(scope, result, arg, true);
14220 update : function(params, records){
14225 * Ext JS Library 1.1.1
14226 * Copyright(c) 2006-2007, Ext JS, LLC.
14228 * Originally Released Under LGPL - original licence link has changed is not relivant.
14231 * <script type="text/javascript">
14234 * @class Roo.data.HttpProxy
14235 * @extends Roo.data.DataProxy
14236 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
14237 * configured to reference a certain URL.<br><br>
14239 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
14240 * from which the running page was served.<br><br>
14242 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
14244 * Be aware that to enable the browser to parse an XML document, the server must set
14245 * the Content-Type header in the HTTP response to "text/xml".
14247 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
14248 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
14249 * will be used to make the request.
14251 Roo.data.HttpProxy = function(conn){
14252 Roo.data.HttpProxy.superclass.constructor.call(this);
14253 // is conn a conn config or a real conn?
14255 this.useAjax = !conn || !conn.events;
14259 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
14260 // thse are take from connection...
14263 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
14266 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
14267 * extra parameters to each request made by this object. (defaults to undefined)
14270 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
14271 * to each request made by this object. (defaults to undefined)
14274 * @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)
14277 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
14280 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
14286 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
14290 * Return the {@link Roo.data.Connection} object being used by this Proxy.
14291 * @return {Connection} The Connection object. This object may be used to subscribe to events on
14292 * a finer-grained basis than the DataProxy events.
14294 getConnection : function(){
14295 return this.useAjax ? Roo.Ajax : this.conn;
14299 * Load data from the configured {@link Roo.data.Connection}, read the data object into
14300 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
14301 * process that block using the passed callback.
14302 * @param {Object} params An object containing properties which are to be used as HTTP parameters
14303 * for the request to the remote server.
14304 * @param {Roo.data.DataReader} reader The Reader object which converts the data
14305 * object into a block of Roo.data.Records.
14306 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
14307 * The function must be passed <ul>
14308 * <li>The Record block object</li>
14309 * <li>The "arg" argument from the load function</li>
14310 * <li>A boolean success indicator</li>
14312 * @param {Object} scope The scope in which to call the callback
14313 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
14315 load : function(params, reader, callback, scope, arg){
14316 if(this.fireEvent("beforeload", this, params) !== false){
14318 params : params || {},
14320 callback : callback,
14325 callback : this.loadResponse,
14329 Roo.applyIf(o, this.conn);
14330 if(this.activeRequest){
14331 Roo.Ajax.abort(this.activeRequest);
14333 this.activeRequest = Roo.Ajax.request(o);
14335 this.conn.request(o);
14338 callback.call(scope||this, null, arg, false);
14343 loadResponse : function(o, success, response){
14344 delete this.activeRequest;
14346 this.fireEvent("loadexception", this, o, response);
14347 o.request.callback.call(o.request.scope, null, o.request.arg, false);
14352 result = o.reader.read(response);
14354 this.fireEvent("loadexception", this, o, response, e);
14355 o.request.callback.call(o.request.scope, null, o.request.arg, false);
14359 this.fireEvent("load", this, o, o.request.arg);
14360 o.request.callback.call(o.request.scope, result, o.request.arg, true);
14364 update : function(dataSet){
14369 updateResponse : function(dataSet){
14374 * Ext JS Library 1.1.1
14375 * Copyright(c) 2006-2007, Ext JS, LLC.
14377 * Originally Released Under LGPL - original licence link has changed is not relivant.
14380 * <script type="text/javascript">
14384 * @class Roo.data.ScriptTagProxy
14385 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
14386 * other than the originating domain of the running page.<br><br>
14388 * <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
14389 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
14391 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
14392 * source code that is used as the source inside a <script> tag.<br><br>
14394 * In order for the browser to process the returned data, the server must wrap the data object
14395 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
14396 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
14397 * depending on whether the callback name was passed:
14400 boolean scriptTag = false;
14401 String cb = request.getParameter("callback");
14404 response.setContentType("text/javascript");
14406 response.setContentType("application/x-json");
14408 Writer out = response.getWriter();
14410 out.write(cb + "(");
14412 out.print(dataBlock.toJsonString());
14419 * @param {Object} config A configuration object.
14421 Roo.data.ScriptTagProxy = function(config){
14422 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
14423 Roo.apply(this, config);
14424 this.head = document.getElementsByTagName("head")[0];
14427 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
14429 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
14431 * @cfg {String} url The URL from which to request the data object.
14434 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
14438 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
14439 * the server the name of the callback function set up by the load call to process the returned data object.
14440 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
14441 * javascript output which calls this named function passing the data object as its only parameter.
14443 callbackParam : "callback",
14445 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
14446 * name to the request.
14451 * Load data from the configured URL, read the data object into
14452 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
14453 * process that block using the passed callback.
14454 * @param {Object} params An object containing properties which are to be used as HTTP parameters
14455 * for the request to the remote server.
14456 * @param {Roo.data.DataReader} reader The Reader object which converts the data
14457 * object into a block of Roo.data.Records.
14458 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
14459 * The function must be passed <ul>
14460 * <li>The Record block object</li>
14461 * <li>The "arg" argument from the load function</li>
14462 * <li>A boolean success indicator</li>
14464 * @param {Object} scope The scope in which to call the callback
14465 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
14467 load : function(params, reader, callback, scope, arg){
14468 if(this.fireEvent("beforeload", this, params) !== false){
14470 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
14472 var url = this.url;
14473 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
14475 url += "&_dc=" + (new Date().getTime());
14477 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
14480 cb : "stcCallback"+transId,
14481 scriptId : "stcScript"+transId,
14485 callback : callback,
14491 window[trans.cb] = function(o){
14492 conn.handleResponse(o, trans);
14495 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
14497 if(this.autoAbort !== false){
14501 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
14503 var script = document.createElement("script");
14504 script.setAttribute("src", url);
14505 script.setAttribute("type", "text/javascript");
14506 script.setAttribute("id", trans.scriptId);
14507 this.head.appendChild(script);
14509 this.trans = trans;
14511 callback.call(scope||this, null, arg, false);
14516 isLoading : function(){
14517 return this.trans ? true : false;
14521 * Abort the current server request.
14523 abort : function(){
14524 if(this.isLoading()){
14525 this.destroyTrans(this.trans);
14530 destroyTrans : function(trans, isLoaded){
14531 this.head.removeChild(document.getElementById(trans.scriptId));
14532 clearTimeout(trans.timeoutId);
14534 window[trans.cb] = undefined;
14536 delete window[trans.cb];
14539 // if hasn't been loaded, wait for load to remove it to prevent script error
14540 window[trans.cb] = function(){
14541 window[trans.cb] = undefined;
14543 delete window[trans.cb];
14550 handleResponse : function(o, trans){
14551 this.trans = false;
14552 this.destroyTrans(trans, true);
14555 result = trans.reader.readRecords(o);
14557 this.fireEvent("loadexception", this, o, trans.arg, e);
14558 trans.callback.call(trans.scope||window, null, trans.arg, false);
14561 this.fireEvent("load", this, o, trans.arg);
14562 trans.callback.call(trans.scope||window, result, trans.arg, true);
14566 handleFailure : function(trans){
14567 this.trans = false;
14568 this.destroyTrans(trans, false);
14569 this.fireEvent("loadexception", this, null, trans.arg);
14570 trans.callback.call(trans.scope||window, null, trans.arg, false);
14574 * Ext JS Library 1.1.1
14575 * Copyright(c) 2006-2007, Ext JS, LLC.
14577 * Originally Released Under LGPL - original licence link has changed is not relivant.
14580 * <script type="text/javascript">
14584 * @class Roo.data.JsonReader
14585 * @extends Roo.data.DataReader
14586 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
14587 * based on mappings in a provided Roo.data.Record constructor.
14589 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
14590 * in the reply previously.
14595 var RecordDef = Roo.data.Record.create([
14596 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
14597 {name: 'occupation'} // This field will use "occupation" as the mapping.
14599 var myReader = new Roo.data.JsonReader({
14600 totalProperty: "results", // The property which contains the total dataset size (optional)
14601 root: "rows", // The property which contains an Array of row objects
14602 id: "id" // The property within each row object that provides an ID for the record (optional)
14606 * This would consume a JSON file like this:
14608 { 'results': 2, 'rows': [
14609 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
14610 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
14613 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
14614 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
14615 * paged from the remote server.
14616 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
14617 * @cfg {String} root name of the property which contains the Array of row objects.
14618 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
14619 * @cfg {Array} fields Array of field definition objects
14621 * Create a new JsonReader
14622 * @param {Object} meta Metadata configuration options
14623 * @param {Object} recordType Either an Array of field definition objects,
14624 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
14626 Roo.data.JsonReader = function(meta, recordType){
14629 // set some defaults:
14630 Roo.applyIf(meta, {
14631 totalProperty: 'total',
14632 successProperty : 'success',
14637 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
14639 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
14641 readerType : 'Json',
14644 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
14645 * Used by Store query builder to append _requestMeta to params.
14648 metaFromRemote : false,
14650 * This method is only used by a DataProxy which has retrieved data from a remote server.
14651 * @param {Object} response The XHR object which contains the JSON data in its responseText.
14652 * @return {Object} data A data block which is used by an Roo.data.Store object as
14653 * a cache of Roo.data.Records.
14655 read : function(response){
14656 var json = response.responseText;
14658 var o = /* eval:var:o */ eval("("+json+")");
14660 throw {message: "JsonReader.read: Json object not found"};
14666 this.metaFromRemote = true;
14667 this.meta = o.metaData;
14668 this.recordType = Roo.data.Record.create(o.metaData.fields);
14669 this.onMetaChange(this.meta, this.recordType, o);
14671 return this.readRecords(o);
14674 // private function a store will implement
14675 onMetaChange : function(meta, recordType, o){
14682 simpleAccess: function(obj, subsc) {
14689 getJsonAccessor: function(){
14691 return function(expr) {
14693 return(re.test(expr))
14694 ? new Function("obj", "return obj." + expr)
14699 return Roo.emptyFn;
14704 * Create a data block containing Roo.data.Records from an XML document.
14705 * @param {Object} o An object which contains an Array of row objects in the property specified
14706 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
14707 * which contains the total size of the dataset.
14708 * @return {Object} data A data block which is used by an Roo.data.Store object as
14709 * a cache of Roo.data.Records.
14711 readRecords : function(o){
14713 * After any data loads, the raw JSON data is available for further custom processing.
14717 var s = this.meta, Record = this.recordType,
14718 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
14720 // Generate extraction functions for the totalProperty, the root, the id, and for each field
14722 if(s.totalProperty) {
14723 this.getTotal = this.getJsonAccessor(s.totalProperty);
14725 if(s.successProperty) {
14726 this.getSuccess = this.getJsonAccessor(s.successProperty);
14728 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
14730 var g = this.getJsonAccessor(s.id);
14731 this.getId = function(rec) {
14733 return (r === undefined || r === "") ? null : r;
14736 this.getId = function(){return null;};
14739 for(var jj = 0; jj < fl; jj++){
14741 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
14742 this.ef[jj] = this.getJsonAccessor(map);
14746 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
14747 if(s.totalProperty){
14748 var vt = parseInt(this.getTotal(o), 10);
14753 if(s.successProperty){
14754 var vs = this.getSuccess(o);
14755 if(vs === false || vs === 'false'){
14760 for(var i = 0; i < c; i++){
14763 var id = this.getId(n);
14764 for(var j = 0; j < fl; j++){
14766 var v = this.ef[j](n);
14768 Roo.log('missing convert for ' + f.name);
14772 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
14774 var record = new Record(values, id);
14776 records[i] = record;
14782 totalRecords : totalRecords
14785 // used when loading children.. @see loadDataFromChildren
14786 toLoadData: function(rec)
14788 // expect rec just to be an array.. eg [a,b,c, [...] << cn ]
14789 var data = typeof(rec.data.cn) == 'undefined' ? [] : rec.data.cn;
14790 return { data : data, total : data.length };
14795 * Ext JS Library 1.1.1
14796 * Copyright(c) 2006-2007, Ext JS, LLC.
14798 * Originally Released Under LGPL - original licence link has changed is not relivant.
14801 * <script type="text/javascript">
14805 * @class Roo.data.ArrayReader
14806 * @extends Roo.data.DataReader
14807 * Data reader class to create an Array of Roo.data.Record objects from an Array.
14808 * Each element of that Array represents a row of data fields. The
14809 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
14810 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
14814 var RecordDef = Roo.data.Record.create([
14815 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
14816 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
14818 var myReader = new Roo.data.ArrayReader({
14819 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
14823 * This would consume an Array like this:
14825 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
14829 * Create a new JsonReader
14830 * @param {Object} meta Metadata configuration options.
14831 * @param {Object|Array} recordType Either an Array of field definition objects
14833 * @cfg {Array} fields Array of field definition objects
14834 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
14835 * as specified to {@link Roo.data.Record#create},
14836 * or an {@link Roo.data.Record} object
14839 * created using {@link Roo.data.Record#create}.
14841 Roo.data.ArrayReader = function(meta, recordType)
14843 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType||meta.fields);
14846 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
14849 * Create a data block containing Roo.data.Records from an XML document.
14850 * @param {Object} o An Array of row objects which represents the dataset.
14851 * @return {Object} A data block which is used by an {@link Roo.data.Store} object as
14852 * a cache of Roo.data.Records.
14854 readRecords : function(o)
14856 var sid = this.meta ? this.meta.id : null;
14857 var recordType = this.recordType, fields = recordType.prototype.fields;
14860 for(var i = 0; i < root.length; i++){
14863 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
14864 for(var j = 0, jlen = fields.length; j < jlen; j++){
14865 var f = fields.items[j];
14866 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
14867 var v = n[k] !== undefined ? n[k] : f.defaultValue;
14869 values[f.name] = v;
14871 var record = new recordType(values, id);
14873 records[records.length] = record;
14877 totalRecords : records.length
14880 // used when loading children.. @see loadDataFromChildren
14881 toLoadData: function(rec)
14883 // expect rec just to be an array.. eg [a,b,c, [...] << cn ]
14884 return typeof(rec.data.cn) == 'undefined' ? [] : rec.data.cn;
14895 * @class Roo.bootstrap.ComboBox
14896 * @extends Roo.bootstrap.TriggerField
14897 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
14898 * @cfg {Boolean} append (true|false) default false
14899 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
14900 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
14901 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
14902 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
14903 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
14904 * @cfg {Boolean} animate default true
14905 * @cfg {Boolean} emptyResultText only for touch device
14906 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
14907 * @cfg {String} emptyTitle default ''
14908 * @cfg {Number} width fixed with? experimental
14910 * Create a new ComboBox.
14911 * @param {Object} config Configuration options
14913 Roo.bootstrap.ComboBox = function(config){
14914 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
14918 * Fires when the dropdown list is expanded
14919 * @param {Roo.bootstrap.ComboBox} combo This combo box
14924 * Fires when the dropdown list is collapsed
14925 * @param {Roo.bootstrap.ComboBox} combo This combo box
14929 * @event beforeselect
14930 * Fires before a list item is selected. Return false to cancel the selection.
14931 * @param {Roo.bootstrap.ComboBox} combo This combo box
14932 * @param {Roo.data.Record} record The data record returned from the underlying store
14933 * @param {Number} index The index of the selected item in the dropdown list
14935 'beforeselect' : true,
14938 * Fires when a list item is selected
14939 * @param {Roo.bootstrap.ComboBox} combo This combo box
14940 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
14941 * @param {Number} index The index of the selected item in the dropdown list
14945 * @event beforequery
14946 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
14947 * The event object passed has these properties:
14948 * @param {Roo.bootstrap.ComboBox} combo This combo box
14949 * @param {String} query The query
14950 * @param {Boolean} forceAll true to force "all" query
14951 * @param {Boolean} cancel true to cancel the query
14952 * @param {Object} e The query event object
14954 'beforequery': true,
14957 * Fires when the 'add' icon is pressed (add a listener to enable add button)
14958 * @param {Roo.bootstrap.ComboBox} combo This combo box
14963 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
14964 * @param {Roo.bootstrap.ComboBox} combo This combo box
14965 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
14970 * Fires when the remove value from the combobox array
14971 * @param {Roo.bootstrap.ComboBox} combo This combo box
14975 * @event afterremove
14976 * Fires when the remove value from the combobox array
14977 * @param {Roo.bootstrap.ComboBox} combo This combo box
14979 'afterremove' : true,
14981 * @event specialfilter
14982 * Fires when specialfilter
14983 * @param {Roo.bootstrap.ComboBox} combo This combo box
14985 'specialfilter' : true,
14988 * Fires when tick the element
14989 * @param {Roo.bootstrap.ComboBox} combo This combo box
14993 * @event touchviewdisplay
14994 * Fires when touch view require special display (default is using displayField)
14995 * @param {Roo.bootstrap.ComboBox} combo This combo box
14996 * @param {Object} cfg set html .
14998 'touchviewdisplay' : true
15003 this.tickItems = [];
15005 this.selectedIndex = -1;
15006 if(this.mode == 'local'){
15007 if(config.queryDelay === undefined){
15008 this.queryDelay = 10;
15010 if(config.minChars === undefined){
15016 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
15019 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
15020 * rendering into an Roo.Editor, defaults to false)
15023 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
15024 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
15027 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
15030 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
15031 * the dropdown list (defaults to undefined, with no header element)
15035 * @cfg {String/Roo.Template} tpl The template to use to render the output default is '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>'
15039 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
15041 listWidth: undefined,
15043 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
15044 * mode = 'remote' or 'text' if mode = 'local')
15046 displayField: undefined,
15049 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
15050 * mode = 'remote' or 'value' if mode = 'local').
15051 * Note: use of a valueField requires the user make a selection
15052 * in order for a value to be mapped.
15054 valueField: undefined,
15056 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
15061 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
15062 * field's data value (defaults to the underlying DOM element's name)
15064 hiddenName: undefined,
15066 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
15070 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
15072 selectedClass: 'active',
15075 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
15079 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
15080 * anchor positions (defaults to 'tl-bl')
15082 listAlign: 'tl-bl?',
15084 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
15088 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
15089 * query specified by the allQuery config option (defaults to 'query')
15091 triggerAction: 'query',
15093 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
15094 * (defaults to 4, does not apply if editable = false)
15098 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
15099 * delay (typeAheadDelay) if it matches a known value (defaults to false)
15103 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
15104 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
15108 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
15109 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
15113 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
15114 * when editable = true (defaults to false)
15116 selectOnFocus:false,
15118 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
15120 queryParam: 'query',
15122 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
15123 * when mode = 'remote' (defaults to 'Loading...')
15125 loadingText: 'Loading...',
15127 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
15131 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
15135 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
15136 * traditional select (defaults to true)
15140 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
15144 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
15148 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
15149 * listWidth has a higher value)
15153 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
15154 * allow the user to set arbitrary text into the field (defaults to false)
15156 forceSelection:false,
15158 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
15159 * if typeAhead = true (defaults to 250)
15161 typeAheadDelay : 250,
15163 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
15164 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
15166 valueNotFoundText : undefined,
15168 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
15170 blockFocus : false,
15173 * @cfg {Boolean} disableClear Disable showing of clear button.
15175 disableClear : false,
15177 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
15179 alwaysQuery : false,
15182 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
15187 * @cfg {String} invalidClass DEPRICATED - uses BS4 is-valid now
15189 invalidClass : "has-warning",
15192 * @cfg {String} validClass DEPRICATED - uses BS4 is-valid now
15194 validClass : "has-success",
15197 * @cfg {Boolean} specialFilter (true|false) special filter default false
15199 specialFilter : false,
15202 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
15204 mobileTouchView : true,
15207 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
15209 useNativeIOS : false,
15212 * @cfg {Boolean} mobile_restrict_height (true|false) restrict height for touch view
15214 mobile_restrict_height : false,
15216 ios_options : false,
15228 btnPosition : 'right',
15229 triggerList : true,
15230 showToggleBtn : true,
15232 emptyResultText: 'Empty',
15233 triggerText : 'Select',
15237 // element that contains real text value.. (when hidden is used..)
15239 getAutoCreate : function()
15244 * Render classic select for iso
15247 if(Roo.isIOS && this.useNativeIOS){
15248 cfg = this.getAutoCreateNativeIOS();
15256 if(Roo.isTouch && this.mobileTouchView){
15257 cfg = this.getAutoCreateTouchView();
15264 if(!this.tickable){
15265 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
15270 * ComboBox with tickable selections
15273 var align = this.labelAlign || this.parentLabelAlign();
15276 cls : 'form-group roo-combobox-tickable' //input-group
15279 var btn_text_select = '';
15280 var btn_text_done = '';
15281 var btn_text_cancel = '';
15283 if (this.btn_text_show) {
15284 btn_text_select = 'Select';
15285 btn_text_done = 'Done';
15286 btn_text_cancel = 'Cancel';
15291 cls : 'tickable-buttons',
15296 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
15297 //html : this.triggerText
15298 html: btn_text_select
15304 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
15306 html: btn_text_done
15312 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
15314 html: btn_text_cancel
15320 buttons.cn.unshift({
15322 cls: 'roo-select2-search-field-input'
15328 Roo.each(buttons.cn, function(c){
15330 c.cls += ' btn-' + _this.size;
15333 if (_this.disabled) {
15340 style : 'display: contents',
15345 cls: 'form-hidden-field'
15349 cls: 'roo-select2-choices',
15353 cls: 'roo-select2-search-field',
15364 cls: 'roo-select2-container input-group roo-select2-container-multi',
15370 // cls: 'typeahead typeahead-long dropdown-menu',
15371 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
15376 if(this.hasFeedback && !this.allowBlank){
15380 cls: 'glyphicon form-control-feedback'
15383 combobox.cn.push(feedback);
15390 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
15391 tooltip : 'This field is required'
15393 if (Roo.bootstrap.version == 4) {
15396 style : 'display:none'
15399 if (align ==='left' && this.fieldLabel.length) {
15401 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
15408 cls : 'control-label col-form-label',
15409 html : this.fieldLabel
15421 var labelCfg = cfg.cn[1];
15422 var contentCfg = cfg.cn[2];
15425 if(this.indicatorpos == 'right'){
15431 cls : 'control-label col-form-label',
15435 html : this.fieldLabel
15451 labelCfg = cfg.cn[0];
15452 contentCfg = cfg.cn[1];
15456 if(this.labelWidth > 12){
15457 labelCfg.style = "width: " + this.labelWidth + 'px';
15459 if(this.width * 1 > 0){
15460 contentCfg.style = "width: " + this.width + 'px';
15462 if(this.labelWidth < 13 && this.labelmd == 0){
15463 this.labelmd = this.labelWidth;
15466 if(this.labellg > 0){
15467 labelCfg.cls += ' col-lg-' + this.labellg;
15468 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
15471 if(this.labelmd > 0){
15472 labelCfg.cls += ' col-md-' + this.labelmd;
15473 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
15476 if(this.labelsm > 0){
15477 labelCfg.cls += ' col-sm-' + this.labelsm;
15478 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
15481 if(this.labelxs > 0){
15482 labelCfg.cls += ' col-xs-' + this.labelxs;
15483 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
15487 } else if ( this.fieldLabel.length) {
15488 // Roo.log(" label");
15493 //cls : 'input-group-addon',
15494 html : this.fieldLabel
15499 if(this.indicatorpos == 'right'){
15503 //cls : 'input-group-addon',
15504 html : this.fieldLabel
15514 // Roo.log(" no label && no align");
15521 ['xs','sm','md','lg'].map(function(size){
15522 if (settings[size]) {
15523 cfg.cls += ' col-' + size + '-' + settings[size];
15531 _initEventsCalled : false,
15534 initEvents: function()
15536 if (this._initEventsCalled) { // as we call render... prevent looping...
15539 this._initEventsCalled = true;
15542 throw "can not find store for combo";
15545 this.indicator = this.indicatorEl();
15547 this.store = Roo.factory(this.store, Roo.data);
15548 this.store.parent = this;
15550 // if we are building from html. then this element is so complex, that we can not really
15551 // use the rendered HTML.
15552 // so we have to trash and replace the previous code.
15553 if (Roo.XComponent.build_from_html) {
15554 // remove this element....
15555 var e = this.el.dom, k=0;
15556 while (e ) { e = e.previousSibling; ++k;}
15561 this.rendered = false;
15563 this.render(this.parent().getChildContainer(true), k);
15566 if(Roo.isIOS && this.useNativeIOS){
15567 this.initIOSView();
15575 if(Roo.isTouch && this.mobileTouchView){
15576 this.initTouchView();
15581 this.initTickableEvents();
15585 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
15587 if(this.hiddenName){
15589 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
15591 this.hiddenField.dom.value =
15592 this.hiddenValue !== undefined ? this.hiddenValue :
15593 this.value !== undefined ? this.value : '';
15595 // prevent input submission
15596 this.el.dom.removeAttribute('name');
15597 this.hiddenField.dom.setAttribute('name', this.hiddenName);
15602 // this.el.dom.setAttribute('autocomplete', 'off');
15605 var cls = 'x-combo-list';
15607 //this.list = new Roo.Layer({
15608 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
15614 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
15615 _this.list.setWidth(lw);
15618 this.list.on('mouseover', this.onViewOver, this);
15619 this.list.on('mousemove', this.onViewMove, this);
15620 this.list.on('scroll', this.onViewScroll, this);
15623 this.list.swallowEvent('mousewheel');
15624 this.assetHeight = 0;
15627 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
15628 this.assetHeight += this.header.getHeight();
15631 this.innerList = this.list.createChild({cls:cls+'-inner'});
15632 this.innerList.on('mouseover', this.onViewOver, this);
15633 this.innerList.on('mousemove', this.onViewMove, this);
15634 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
15636 if(this.allowBlank && !this.pageSize && !this.disableClear){
15637 this.footer = this.list.createChild({cls:cls+'-ft'});
15638 this.pageTb = new Roo.Toolbar(this.footer);
15642 this.footer = this.list.createChild({cls:cls+'-ft'});
15643 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
15644 {pageSize: this.pageSize});
15648 if (this.pageTb && this.allowBlank && !this.disableClear) {
15650 this.pageTb.add(new Roo.Toolbar.Fill(), {
15651 cls: 'x-btn-icon x-btn-clear',
15653 handler: function()
15656 _this.clearValue();
15657 _this.onSelect(false, -1);
15662 this.assetHeight += this.footer.getHeight();
15667 this.tpl = Roo.bootstrap.version == 4 ?
15668 '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>' : // 4 does not need <li> and it get's really confisued.
15669 '<li><a class="dropdown-item" href="#">{' + this.displayField + '}</a></li>';
15672 this.view = new Roo.View(this.list, this.tpl, {
15673 singleSelect:true, store: this.store, selectedClass: this.selectedClass
15675 //this.view.wrapEl.setDisplayed(false);
15676 this.view.on('click', this.onViewClick, this);
15679 this.store.on('beforeload', this.onBeforeLoad, this);
15680 this.store.on('load', this.onLoad, this);
15681 this.store.on('loadexception', this.onLoadException, this);
15683 if(this.resizable){
15684 this.resizer = new Roo.Resizable(this.list, {
15685 pinned:true, handles:'se'
15687 this.resizer.on('resize', function(r, w, h){
15688 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
15689 this.listWidth = w;
15690 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
15691 this.restrictHeight();
15693 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
15696 if(!this.editable){
15697 this.editable = true;
15698 this.setEditable(false);
15703 if (typeof(this.events.add.listeners) != 'undefined') {
15705 this.addicon = this.wrap.createChild(
15706 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
15708 this.addicon.on('click', function(e) {
15709 this.fireEvent('add', this);
15712 if (typeof(this.events.edit.listeners) != 'undefined') {
15714 this.editicon = this.wrap.createChild(
15715 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
15716 if (this.addicon) {
15717 this.editicon.setStyle('margin-left', '40px');
15719 this.editicon.on('click', function(e) {
15721 // we fire even if inothing is selected..
15722 this.fireEvent('edit', this, this.lastData );
15728 this.keyNav = new Roo.KeyNav(this.inputEl(), {
15729 "up" : function(e){
15730 this.inKeyMode = true;
15734 "down" : function(e){
15735 if(!this.isExpanded()){
15736 this.onTriggerClick();
15738 this.inKeyMode = true;
15743 "enter" : function(e){
15744 // this.onViewClick();
15748 if(this.fireEvent("specialkey", this, e)){
15749 this.onViewClick(false);
15755 "esc" : function(e){
15759 "tab" : function(e){
15762 if(this.fireEvent("specialkey", this, e)){
15763 this.onViewClick(false);
15771 doRelay : function(foo, bar, hname){
15772 if(hname == 'down' || this.scope.isExpanded()){
15773 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
15782 this.queryDelay = Math.max(this.queryDelay || 10,
15783 this.mode == 'local' ? 10 : 250);
15786 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
15788 if(this.typeAhead){
15789 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
15791 if(this.editable !== false){
15792 this.inputEl().on("keyup", this.onKeyUp, this);
15794 if(this.forceSelection){
15795 this.inputEl().on('blur', this.doForce, this);
15799 this.choices = this.el.select('ul.roo-select2-choices', true).first();
15800 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
15804 initTickableEvents: function()
15808 if(this.hiddenName){
15810 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
15812 this.hiddenField.dom.value =
15813 this.hiddenValue !== undefined ? this.hiddenValue :
15814 this.value !== undefined ? this.value : '';
15816 // prevent input submission
15817 this.el.dom.removeAttribute('name');
15818 this.hiddenField.dom.setAttribute('name', this.hiddenName);
15823 // this.list = this.el.select('ul.dropdown-menu',true).first();
15825 this.choices = this.el.select('ul.roo-select2-choices', true).first();
15826 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
15827 if(this.triggerList){
15828 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
15831 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
15832 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
15834 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
15835 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
15837 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
15838 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
15840 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
15841 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
15842 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
15845 this.cancelBtn.hide();
15850 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
15851 _this.list.setWidth(lw);
15854 this.list.on('mouseover', this.onViewOver, this);
15855 this.list.on('mousemove', this.onViewMove, this);
15857 this.list.on('scroll', this.onViewScroll, this);
15860 this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}"' +
15861 'type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
15864 this.view = new Roo.View(this.list, this.tpl, {
15869 selectedClass: this.selectedClass
15872 //this.view.wrapEl.setDisplayed(false);
15873 this.view.on('click', this.onViewClick, this);
15877 this.store.on('beforeload', this.onBeforeLoad, this);
15878 this.store.on('load', this.onLoad, this);
15879 this.store.on('loadexception', this.onLoadException, this);
15882 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
15883 "up" : function(e){
15884 this.inKeyMode = true;
15888 "down" : function(e){
15889 this.inKeyMode = true;
15893 "enter" : function(e){
15894 if(this.fireEvent("specialkey", this, e)){
15895 this.onViewClick(false);
15901 "esc" : function(e){
15902 this.onTickableFooterButtonClick(e, false, false);
15905 "tab" : function(e){
15906 this.fireEvent("specialkey", this, e);
15908 this.onTickableFooterButtonClick(e, false, false);
15915 doRelay : function(e, fn, key){
15916 if(this.scope.isExpanded()){
15917 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
15926 this.queryDelay = Math.max(this.queryDelay || 10,
15927 this.mode == 'local' ? 10 : 250);
15930 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
15932 if(this.typeAhead){
15933 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
15936 if(this.editable !== false){
15937 this.tickableInputEl().on("keyup", this.onKeyUp, this);
15940 this.indicator = this.indicatorEl();
15942 if(this.indicator){
15943 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
15944 this.indicator.hide();
15949 onDestroy : function(){
15951 this.view.setStore(null);
15952 this.view.el.removeAllListeners();
15953 this.view.el.remove();
15954 this.view.purgeListeners();
15957 this.list.dom.innerHTML = '';
15961 this.store.un('beforeload', this.onBeforeLoad, this);
15962 this.store.un('load', this.onLoad, this);
15963 this.store.un('loadexception', this.onLoadException, this);
15965 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
15969 fireKey : function(e){
15970 if(e.isNavKeyPress() && !this.list.isVisible()){
15971 this.fireEvent("specialkey", this, e);
15976 onResize: function(w, h)
15980 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
15982 // if(typeof w != 'number'){
15983 // // we do not handle it!?!?
15986 // var tw = this.trigger.getWidth();
15987 // // tw += this.addicon ? this.addicon.getWidth() : 0;
15988 // // tw += this.editicon ? this.editicon.getWidth() : 0;
15990 // this.inputEl().setWidth( this.adjustWidth('input', x));
15992 // //this.trigger.setStyle('left', x+'px');
15994 // if(this.list && this.listWidth === undefined){
15995 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
15996 // this.list.setWidth(lw);
15997 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
16005 * Allow or prevent the user from directly editing the field text. If false is passed,
16006 * the user will only be able to select from the items defined in the dropdown list. This method
16007 * is the runtime equivalent of setting the 'editable' config option at config time.
16008 * @param {Boolean} value True to allow the user to directly edit the field text
16010 setEditable : function(value){
16011 if(value == this.editable){
16014 this.editable = value;
16016 this.inputEl().dom.setAttribute('readOnly', true);
16017 this.inputEl().on('mousedown', this.onTriggerClick, this);
16018 this.inputEl().addClass('x-combo-noedit');
16020 this.inputEl().dom.setAttribute('readOnly', false);
16021 this.inputEl().un('mousedown', this.onTriggerClick, this);
16022 this.inputEl().removeClass('x-combo-noedit');
16028 onBeforeLoad : function(combo,opts){
16029 if(!this.hasFocus){
16033 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
16035 this.restrictHeight();
16036 this.selectedIndex = -1;
16040 onLoad : function(){
16042 this.hasQuery = false;
16044 if(!this.hasFocus){
16048 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
16049 this.loading.hide();
16052 if(this.store.getCount() > 0){
16055 this.restrictHeight();
16056 if(this.lastQuery == this.allQuery){
16057 if(this.editable && !this.tickable){
16058 this.inputEl().dom.select();
16062 !this.selectByValue(this.value, true) &&
16065 !this.store.lastOptions ||
16066 typeof(this.store.lastOptions.add) == 'undefined' ||
16067 this.store.lastOptions.add != true
16070 this.select(0, true);
16073 if(this.autoFocus){
16076 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
16077 this.taTask.delay(this.typeAheadDelay);
16081 this.onEmptyResults();
16087 onLoadException : function()
16089 this.hasQuery = false;
16091 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
16092 this.loading.hide();
16095 if(this.tickable && this.editable){
16100 // only causes errors at present
16101 //Roo.log(this.store.reader.jsonData);
16102 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
16104 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
16110 onTypeAhead : function(){
16111 if(this.store.getCount() > 0){
16112 var r = this.store.getAt(0);
16113 var newValue = r.data[this.displayField];
16114 var len = newValue.length;
16115 var selStart = this.getRawValue().length;
16117 if(selStart != len){
16118 this.setRawValue(newValue);
16119 this.selectText(selStart, newValue.length);
16125 onSelect : function(record, index){
16127 if(this.fireEvent('beforeselect', this, record, index) !== false){
16129 this.setFromData(index > -1 ? record.data : false);
16132 this.fireEvent('select', this, record, index);
16137 * Returns the currently selected field value or empty string if no value is set.
16138 * @return {String} value The selected value
16140 getValue : function()
16142 if(Roo.isIOS && this.useNativeIOS){
16143 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
16147 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
16150 if(this.valueField){
16151 return typeof this.value != 'undefined' ? this.value : '';
16153 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
16157 getRawValue : function()
16159 if(Roo.isIOS && this.useNativeIOS){
16160 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
16163 var v = this.inputEl().getValue();
16169 * Clears any text/value currently set in the field
16171 clearValue : function(){
16173 if(this.hiddenField){
16174 this.hiddenField.dom.value = '';
16177 this.setRawValue('');
16178 this.lastSelectionText = '';
16179 this.lastData = false;
16181 var close = this.closeTriggerEl();
16192 * Sets the specified value into the field. If the value finds a match, the corresponding record text
16193 * will be displayed in the field. If the value does not match the data value of an existing item,
16194 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
16195 * Otherwise the field will be blank (although the value will still be set).
16196 * @param {String} value The value to match
16198 setValue : function(v)
16200 if(Roo.isIOS && this.useNativeIOS){
16201 this.setIOSValue(v);
16211 if(this.valueField){
16212 var r = this.findRecord(this.valueField, v);
16214 text = r.data[this.displayField];
16215 }else if(this.valueNotFoundText !== undefined){
16216 text = this.valueNotFoundText;
16219 this.lastSelectionText = text;
16220 if(this.hiddenField){
16221 this.hiddenField.dom.value = v;
16223 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
16226 var close = this.closeTriggerEl();
16229 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
16235 * @property {Object} the last set data for the element
16240 * Sets the value of the field based on a object which is related to the record format for the store.
16241 * @param {Object} value the value to set as. or false on reset?
16243 setFromData : function(o){
16250 var dv = ''; // display value
16251 var vv = ''; // value value..
16253 if (this.displayField) {
16254 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
16256 // this is an error condition!!!
16257 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
16260 if(this.valueField){
16261 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
16264 var close = this.closeTriggerEl();
16267 if(dv.length || vv * 1 > 0){
16269 this.blockFocus=true;
16275 if(this.hiddenField){
16276 this.hiddenField.dom.value = vv;
16278 this.lastSelectionText = dv;
16279 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
16283 // no hidden field.. - we store the value in 'value', but still display
16284 // display field!!!!
16285 this.lastSelectionText = dv;
16286 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
16293 reset : function(){
16294 // overridden so that last data is reset..
16301 this.setValue(this.originalValue);
16302 //this.clearInvalid();
16303 this.lastData = false;
16305 this.view.clearSelections();
16311 findRecord : function(prop, value){
16313 if(this.store.getCount() > 0){
16314 this.store.each(function(r){
16315 if(r.data[prop] == value){
16325 getName: function()
16327 // returns hidden if it's set..
16328 if (!this.rendered) {return ''};
16329 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
16333 onViewMove : function(e, t){
16334 this.inKeyMode = false;
16338 onViewOver : function(e, t){
16339 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
16342 var item = this.view.findItemFromChild(t);
16345 var index = this.view.indexOf(item);
16346 this.select(index, false);
16351 onViewClick : function(view, doFocus, el, e)
16353 var index = this.view.getSelectedIndexes()[0];
16355 var r = this.store.getAt(index);
16359 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
16366 Roo.each(this.tickItems, function(v,k){
16368 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
16370 _this.tickItems.splice(k, 1);
16372 if(typeof(e) == 'undefined' && view == false){
16373 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
16385 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
16386 this.tickItems.push(r.data);
16389 if(typeof(e) == 'undefined' && view == false){
16390 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
16397 this.onSelect(r, index);
16399 if(doFocus !== false && !this.blockFocus){
16400 this.inputEl().focus();
16405 restrictHeight : function(){
16406 //this.innerList.dom.style.height = '';
16407 //var inner = this.innerList.dom;
16408 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
16409 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
16410 //this.list.beginUpdate();
16411 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
16412 this.list.alignTo(this.inputEl(), this.listAlign);
16413 this.list.alignTo(this.inputEl(), this.listAlign);
16414 //this.list.endUpdate();
16418 onEmptyResults : function(){
16420 if(this.tickable && this.editable){
16421 this.hasFocus = false;
16422 this.restrictHeight();
16430 * Returns true if the dropdown list is expanded, else false.
16432 isExpanded : function(){
16433 return this.list.isVisible();
16437 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
16438 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
16439 * @param {String} value The data value of the item to select
16440 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
16441 * selected item if it is not currently in view (defaults to true)
16442 * @return {Boolean} True if the value matched an item in the list, else false
16444 selectByValue : function(v, scrollIntoView){
16445 if(v !== undefined && v !== null){
16446 var r = this.findRecord(this.valueField || this.displayField, v);
16448 this.select(this.store.indexOf(r), scrollIntoView);
16456 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
16457 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
16458 * @param {Number} index The zero-based index of the list item to select
16459 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
16460 * selected item if it is not currently in view (defaults to true)
16462 select : function(index, scrollIntoView){
16463 this.selectedIndex = index;
16464 this.view.select(index);
16465 if(scrollIntoView !== false){
16466 var el = this.view.getNode(index);
16468 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
16471 this.list.scrollChildIntoView(el, false);
16477 selectNext : function(){
16478 var ct = this.store.getCount();
16480 if(this.selectedIndex == -1){
16482 }else if(this.selectedIndex < ct-1){
16483 this.select(this.selectedIndex+1);
16489 selectPrev : function(){
16490 var ct = this.store.getCount();
16492 if(this.selectedIndex == -1){
16494 }else if(this.selectedIndex != 0){
16495 this.select(this.selectedIndex-1);
16501 onKeyUp : function(e){
16502 if(this.editable !== false && !e.isSpecialKey()){
16503 this.lastKey = e.getKey();
16504 this.dqTask.delay(this.queryDelay);
16509 validateBlur : function(){
16510 return !this.list || !this.list.isVisible();
16514 initQuery : function(){
16516 var v = this.getRawValue();
16518 if(this.tickable && this.editable){
16519 v = this.tickableInputEl().getValue();
16526 doForce : function(){
16527 if(this.inputEl().dom.value.length > 0){
16528 this.inputEl().dom.value =
16529 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
16535 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
16536 * query allowing the query action to be canceled if needed.
16537 * @param {String} query The SQL query to execute
16538 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
16539 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
16540 * saved in the current store (defaults to false)
16542 doQuery : function(q, forceAll){
16544 if(q === undefined || q === null){
16549 forceAll: forceAll,
16553 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
16558 forceAll = qe.forceAll;
16559 if(forceAll === true || (q.length >= this.minChars)){
16561 this.hasQuery = true;
16563 if(this.lastQuery != q || this.alwaysQuery){
16564 this.lastQuery = q;
16565 if(this.mode == 'local'){
16566 this.selectedIndex = -1;
16568 this.store.clearFilter();
16571 if(this.specialFilter){
16572 this.fireEvent('specialfilter', this);
16577 this.store.filter(this.displayField, q);
16580 this.store.fireEvent("datachanged", this.store);
16587 this.store.baseParams[this.queryParam] = q;
16589 var options = {params : this.getParams(q)};
16592 options.add = true;
16593 options.params.start = this.page * this.pageSize;
16596 this.store.load(options);
16599 * this code will make the page width larger, at the beginning, the list not align correctly,
16600 * we should expand the list on onLoad
16601 * so command out it
16606 this.selectedIndex = -1;
16611 this.loadNext = false;
16615 getParams : function(q){
16617 //p[this.queryParam] = q;
16621 p.limit = this.pageSize;
16627 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
16629 collapse : function(){
16630 if(!this.isExpanded()){
16636 this.hasFocus = false;
16640 this.cancelBtn.hide();
16641 this.trigger.show();
16644 this.tickableInputEl().dom.value = '';
16645 this.tickableInputEl().blur();
16650 Roo.get(document).un('mousedown', this.collapseIf, this);
16651 Roo.get(document).un('mousewheel', this.collapseIf, this);
16652 if (!this.editable) {
16653 Roo.get(document).un('keydown', this.listKeyPress, this);
16655 this.fireEvent('collapse', this);
16661 collapseIf : function(e){
16662 var in_combo = e.within(this.el);
16663 var in_list = e.within(this.list);
16664 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
16666 if (in_combo || in_list || is_list) {
16667 //e.stopPropagation();
16672 this.onTickableFooterButtonClick(e, false, false);
16680 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
16682 expand : function(){
16684 if(this.isExpanded() || !this.hasFocus){
16688 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
16689 this.list.setWidth(lw);
16695 this.restrictHeight();
16699 this.tickItems = Roo.apply([], this.item);
16702 this.cancelBtn.show();
16703 this.trigger.hide();
16706 this.tickableInputEl().focus();
16711 Roo.get(document).on('mousedown', this.collapseIf, this);
16712 Roo.get(document).on('mousewheel', this.collapseIf, this);
16713 if (!this.editable) {
16714 Roo.get(document).on('keydown', this.listKeyPress, this);
16717 this.fireEvent('expand', this);
16721 // Implements the default empty TriggerField.onTriggerClick function
16722 onTriggerClick : function(e)
16724 Roo.log('trigger click');
16726 if(this.disabled || !this.triggerList){
16731 this.loadNext = false;
16733 if(this.isExpanded()){
16735 if (!this.blockFocus) {
16736 this.inputEl().focus();
16740 this.hasFocus = true;
16741 if(this.triggerAction == 'all') {
16742 this.doQuery(this.allQuery, true);
16744 this.doQuery(this.getRawValue());
16746 if (!this.blockFocus) {
16747 this.inputEl().focus();
16752 onTickableTriggerClick : function(e)
16759 this.loadNext = false;
16760 this.hasFocus = true;
16762 if(this.triggerAction == 'all') {
16763 this.doQuery(this.allQuery, true);
16765 this.doQuery(this.getRawValue());
16769 onSearchFieldClick : function(e)
16771 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
16772 this.onTickableFooterButtonClick(e, false, false);
16776 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
16781 this.loadNext = false;
16782 this.hasFocus = true;
16784 if(this.triggerAction == 'all') {
16785 this.doQuery(this.allQuery, true);
16787 this.doQuery(this.getRawValue());
16791 listKeyPress : function(e)
16793 //Roo.log('listkeypress');
16794 // scroll to first matching element based on key pres..
16795 if (e.isSpecialKey()) {
16798 var k = String.fromCharCode(e.getKey()).toUpperCase();
16801 var csel = this.view.getSelectedNodes();
16802 var cselitem = false;
16804 var ix = this.view.indexOf(csel[0]);
16805 cselitem = this.store.getAt(ix);
16806 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
16812 this.store.each(function(v) {
16814 // start at existing selection.
16815 if (cselitem.id == v.id) {
16821 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
16822 match = this.store.indexOf(v);
16828 if (match === false) {
16829 return true; // no more action?
16832 this.view.select(match);
16833 var sn = Roo.get(this.view.getSelectedNodes()[0]);
16834 sn.scrollIntoView(sn.dom.parentNode, false);
16837 onViewScroll : function(e, t){
16839 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){
16843 this.hasQuery = true;
16845 this.loading = this.list.select('.loading', true).first();
16847 if(this.loading === null){
16848 this.list.createChild({
16850 cls: 'loading roo-select2-more-results roo-select2-active',
16851 html: 'Loading more results...'
16854 this.loading = this.list.select('.loading', true).first();
16856 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
16858 this.loading.hide();
16861 this.loading.show();
16866 this.loadNext = true;
16868 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
16873 addItem : function(o)
16875 var dv = ''; // display value
16877 if (this.displayField) {
16878 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
16880 // this is an error condition!!!
16881 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
16888 var choice = this.choices.createChild({
16890 cls: 'roo-select2-search-choice',
16899 cls: 'roo-select2-search-choice-close fa fa-times',
16904 }, this.searchField);
16906 var close = choice.select('a.roo-select2-search-choice-close', true).first();
16908 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
16916 this.inputEl().dom.value = '';
16921 onRemoveItem : function(e, _self, o)
16923 e.preventDefault();
16925 this.lastItem = Roo.apply([], this.item);
16927 var index = this.item.indexOf(o.data) * 1;
16930 Roo.log('not this item?!');
16934 this.item.splice(index, 1);
16939 this.fireEvent('remove', this, e);
16945 syncValue : function()
16947 if(!this.item.length){
16954 Roo.each(this.item, function(i){
16955 if(_this.valueField){
16956 value.push(i[_this.valueField]);
16963 this.value = value.join(',');
16965 if(this.hiddenField){
16966 this.hiddenField.dom.value = this.value;
16969 this.store.fireEvent("datachanged", this.store);
16974 clearItem : function()
16976 if(!this.multiple){
16982 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
16990 if(this.tickable && !Roo.isTouch){
16991 this.view.refresh();
16995 inputEl: function ()
16997 if(Roo.isIOS && this.useNativeIOS){
16998 return this.el.select('select.roo-ios-select', true).first();
17001 if(Roo.isTouch && this.mobileTouchView){
17002 return this.el.select('input.form-control',true).first();
17006 return this.searchField;
17009 return this.el.select('input.form-control',true).first();
17012 onTickableFooterButtonClick : function(e, btn, el)
17014 e.preventDefault();
17016 this.lastItem = Roo.apply([], this.item);
17018 if(btn && btn.name == 'cancel'){
17019 this.tickItems = Roo.apply([], this.item);
17028 Roo.each(this.tickItems, function(o){
17036 validate : function()
17038 if(this.getVisibilityEl().hasClass('hidden')){
17042 var v = this.getRawValue();
17045 v = this.getValue();
17048 if(this.disabled || this.allowBlank || v.length){
17053 this.markInvalid();
17057 tickableInputEl : function()
17059 if(!this.tickable || !this.editable){
17060 return this.inputEl();
17063 return this.inputEl().select('.roo-select2-search-field-input', true).first();
17067 getAutoCreateTouchView : function()
17072 cls: 'form-group' //input-group
17078 type : this.inputType,
17079 cls : 'form-control x-combo-noedit',
17080 autocomplete: 'new-password',
17081 placeholder : this.placeholder || '',
17086 input.name = this.name;
17090 input.cls += ' input-' + this.size;
17093 if (this.disabled) {
17094 input.disabled = true;
17098 cls : 'roo-combobox-wrap',
17105 inputblock.cls += ' input-group';
17107 inputblock.cn.unshift({
17109 cls : 'input-group-addon input-group-prepend input-group-text',
17114 if(this.removable && !this.multiple){
17115 inputblock.cls += ' roo-removable';
17117 inputblock.cn.push({
17120 cls : 'roo-combo-removable-btn close'
17124 if(this.hasFeedback && !this.allowBlank){
17126 inputblock.cls += ' has-feedback';
17128 inputblock.cn.push({
17130 cls: 'glyphicon form-control-feedback'
17137 inputblock.cls += (this.before) ? '' : ' input-group';
17139 inputblock.cn.push({
17141 cls : 'input-group-addon input-group-append input-group-text',
17147 var ibwrap = inputblock;
17152 cls: 'roo-select2-choices',
17156 cls: 'roo-select2-search-field',
17169 cls: 'roo-select2-container input-group roo-touchview-combobox ',
17174 cls: 'form-hidden-field'
17180 if(!this.multiple && this.showToggleBtn){
17186 if (this.caret != false) {
17189 cls: 'fa fa-' + this.caret
17196 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
17198 Roo.bootstrap.version == 3 ? caret : '',
17201 cls: 'combobox-clear',
17215 combobox.cls += ' roo-select2-container-multi';
17218 var align = this.labelAlign || this.parentLabelAlign();
17220 if (align ==='left' && this.fieldLabel.length) {
17225 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
17226 tooltip : 'This field is required'
17230 cls : 'control-label col-form-label',
17231 html : this.fieldLabel
17235 cls : 'roo-combobox-wrap ',
17242 var labelCfg = cfg.cn[1];
17243 var contentCfg = cfg.cn[2];
17246 if(this.indicatorpos == 'right'){
17251 cls : 'control-label col-form-label',
17255 html : this.fieldLabel
17259 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
17260 tooltip : 'This field is required'
17265 cls : "roo-combobox-wrap ",
17273 labelCfg = cfg.cn[0];
17274 contentCfg = cfg.cn[1];
17279 if(this.labelWidth > 12){
17280 labelCfg.style = "width: " + this.labelWidth + 'px';
17283 if(this.labelWidth < 13 && this.labelmd == 0){
17284 this.labelmd = this.labelWidth;
17287 if(this.labellg > 0){
17288 labelCfg.cls += ' col-lg-' + this.labellg;
17289 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
17292 if(this.labelmd > 0){
17293 labelCfg.cls += ' col-md-' + this.labelmd;
17294 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
17297 if(this.labelsm > 0){
17298 labelCfg.cls += ' col-sm-' + this.labelsm;
17299 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
17302 if(this.labelxs > 0){
17303 labelCfg.cls += ' col-xs-' + this.labelxs;
17304 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
17308 } else if ( this.fieldLabel.length) {
17312 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
17313 tooltip : 'This field is required'
17317 cls : 'control-label',
17318 html : this.fieldLabel
17329 if(this.indicatorpos == 'right'){
17333 cls : 'control-label',
17334 html : this.fieldLabel,
17338 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
17339 tooltip : 'This field is required'
17356 var settings = this;
17358 ['xs','sm','md','lg'].map(function(size){
17359 if (settings[size]) {
17360 cfg.cls += ' col-' + size + '-' + settings[size];
17367 initTouchView : function()
17369 this.renderTouchView();
17371 this.touchViewEl.on('scroll', function(){
17372 this.el.dom.scrollTop = 0;
17375 this.originalValue = this.getValue();
17377 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
17379 this.inputEl().on("click", this.showTouchView, this);
17380 if (this.triggerEl) {
17381 this.triggerEl.on("click", this.showTouchView, this);
17385 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
17386 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
17388 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
17390 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
17391 this.store.on('load', this.onTouchViewLoad, this);
17392 this.store.on('loadexception', this.onTouchViewLoadException, this);
17394 if(this.hiddenName){
17396 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
17398 this.hiddenField.dom.value =
17399 this.hiddenValue !== undefined ? this.hiddenValue :
17400 this.value !== undefined ? this.value : '';
17402 this.el.dom.removeAttribute('name');
17403 this.hiddenField.dom.setAttribute('name', this.hiddenName);
17407 this.choices = this.el.select('ul.roo-select2-choices', true).first();
17408 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
17411 if(this.removable && !this.multiple){
17412 var close = this.closeTriggerEl();
17414 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
17415 close.on('click', this.removeBtnClick, this, close);
17419 * fix the bug in Safari iOS8
17421 this.inputEl().on("focus", function(e){
17422 document.activeElement.blur();
17425 this._touchViewMask = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
17432 renderTouchView : function()
17434 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
17435 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
17437 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
17438 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
17440 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
17441 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
17442 this.touchViewBodyEl.setStyle('overflow', 'auto');
17444 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
17445 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
17447 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
17448 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
17452 showTouchView : function()
17458 this.touchViewHeaderEl.hide();
17460 if(this.modalTitle.length){
17461 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
17462 this.touchViewHeaderEl.show();
17465 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
17466 this.touchViewEl.show();
17468 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
17470 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
17471 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
17473 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
17475 if(this.modalTitle.length){
17476 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
17479 this.touchViewBodyEl.setHeight(bodyHeight);
17483 (function(){ _this.touchViewEl.addClass(['in','show']); }).defer(50);
17485 this.touchViewEl.addClass(['in','show']);
17488 if(this._touchViewMask){
17489 Roo.get(document.body).addClass("x-body-masked");
17490 this._touchViewMask.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
17491 this._touchViewMask.setStyle('z-index', 10000);
17492 this._touchViewMask.addClass('show');
17495 this.doTouchViewQuery();
17499 hideTouchView : function()
17501 this.touchViewEl.removeClass(['in','show']);
17505 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
17507 this.touchViewEl.setStyle('display', 'none');
17510 if(this._touchViewMask){
17511 this._touchViewMask.removeClass('show');
17512 Roo.get(document.body).removeClass("x-body-masked");
17516 setTouchViewValue : function()
17523 Roo.each(this.tickItems, function(o){
17528 this.hideTouchView();
17531 doTouchViewQuery : function()
17540 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
17544 if(!this.alwaysQuery || this.mode == 'local'){
17545 this.onTouchViewLoad();
17552 onTouchViewBeforeLoad : function(combo,opts)
17558 onTouchViewLoad : function()
17560 if(this.store.getCount() < 1){
17561 this.onTouchViewEmptyResults();
17565 this.clearTouchView();
17567 var rawValue = this.getRawValue();
17569 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
17571 this.tickItems = [];
17573 this.store.data.each(function(d, rowIndex){
17574 var row = this.touchViewListGroup.createChild(template);
17576 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
17577 row.addClass(d.data.cls);
17580 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
17583 html : d.data[this.displayField]
17586 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
17587 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
17590 row.removeClass('selected');
17591 if(!this.multiple && this.valueField &&
17592 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
17595 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
17596 row.addClass('selected');
17599 if(this.multiple && this.valueField &&
17600 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
17604 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
17605 this.tickItems.push(d.data);
17608 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
17612 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
17614 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
17616 if(this.modalTitle.length){
17617 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
17620 var listHeight = this.touchViewListGroup.getHeight() + this.touchViewBodyEl.getPadding('tb') * 2;
17622 if(this.mobile_restrict_height && listHeight < bodyHeight){
17623 this.touchViewBodyEl.setHeight(listHeight);
17628 if(firstChecked && listHeight > bodyHeight){
17629 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
17634 onTouchViewLoadException : function()
17636 this.hideTouchView();
17639 onTouchViewEmptyResults : function()
17641 this.clearTouchView();
17643 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
17645 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
17649 clearTouchView : function()
17651 this.touchViewListGroup.dom.innerHTML = '';
17654 onTouchViewClick : function(e, el, o)
17656 e.preventDefault();
17659 var rowIndex = o.rowIndex;
17661 var r = this.store.getAt(rowIndex);
17663 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
17665 if(!this.multiple){
17666 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
17667 c.dom.removeAttribute('checked');
17670 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
17672 this.setFromData(r.data);
17674 var close = this.closeTriggerEl();
17680 this.hideTouchView();
17682 this.fireEvent('select', this, r, rowIndex);
17687 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
17688 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
17689 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
17693 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
17694 this.addItem(r.data);
17695 this.tickItems.push(r.data);
17699 getAutoCreateNativeIOS : function()
17702 cls: 'form-group' //input-group,
17707 cls : 'roo-ios-select'
17711 combobox.name = this.name;
17714 if (this.disabled) {
17715 combobox.disabled = true;
17718 var settings = this;
17720 ['xs','sm','md','lg'].map(function(size){
17721 if (settings[size]) {
17722 cfg.cls += ' col-' + size + '-' + settings[size];
17732 initIOSView : function()
17734 this.store.on('load', this.onIOSViewLoad, this);
17739 onIOSViewLoad : function()
17741 if(this.store.getCount() < 1){
17745 this.clearIOSView();
17747 if(this.allowBlank) {
17749 var default_text = '-- SELECT --';
17751 if(this.placeholder.length){
17752 default_text = this.placeholder;
17755 if(this.emptyTitle.length){
17756 default_text += ' - ' + this.emptyTitle + ' -';
17759 var opt = this.inputEl().createChild({
17762 html : default_text
17766 o[this.valueField] = 0;
17767 o[this.displayField] = default_text;
17769 this.ios_options.push({
17776 this.store.data.each(function(d, rowIndex){
17780 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
17781 html = d.data[this.displayField];
17786 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
17787 value = d.data[this.valueField];
17796 if(this.value == d.data[this.valueField]){
17797 option['selected'] = true;
17800 var opt = this.inputEl().createChild(option);
17802 this.ios_options.push({
17809 this.inputEl().on('change', function(){
17810 this.fireEvent('select', this);
17815 clearIOSView: function()
17817 this.inputEl().dom.innerHTML = '';
17819 this.ios_options = [];
17822 setIOSValue: function(v)
17826 if(!this.ios_options){
17830 Roo.each(this.ios_options, function(opts){
17832 opts.el.dom.removeAttribute('selected');
17834 if(opts.data[this.valueField] != v){
17838 opts.el.dom.setAttribute('selected', true);
17844 * @cfg {Boolean} grow
17848 * @cfg {Number} growMin
17852 * @cfg {Number} growMax
17861 Roo.apply(Roo.bootstrap.ComboBox, {
17865 cls: 'modal-header',
17887 cls: 'list-group-item',
17891 cls: 'roo-combobox-list-group-item-value'
17895 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
17909 listItemCheckbox : {
17911 cls: 'list-group-item',
17915 cls: 'roo-combobox-list-group-item-value'
17919 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
17935 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
17940 cls: 'modal-footer',
17948 cls: 'col-xs-6 text-left',
17951 cls: 'btn btn-danger roo-touch-view-cancel',
17957 cls: 'col-xs-6 text-right',
17960 cls: 'btn btn-success roo-touch-view-ok',
17971 Roo.apply(Roo.bootstrap.ComboBox, {
17973 touchViewTemplate : {
17975 cls: 'modal fade roo-combobox-touch-view',
17979 cls: 'modal-dialog',
17980 style : 'position:fixed', // we have to fix position....
17984 cls: 'modal-content',
17986 Roo.bootstrap.ComboBox.header,
17987 Roo.bootstrap.ComboBox.body,
17988 Roo.bootstrap.ComboBox.footer
17997 * Ext JS Library 1.1.1
17998 * Copyright(c) 2006-2007, Ext JS, LLC.
18000 * Originally Released Under LGPL - original licence link has changed is not relivant.
18003 * <script type="text/javascript">
18008 * @extends Roo.util.Observable
18009 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
18010 * This class also supports single and multi selection modes. <br>
18011 * Create a data model bound view:
18013 var store = new Roo.data.Store(...);
18015 var view = new Roo.View({
18017 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
18019 singleSelect: true,
18020 selectedClass: "ydataview-selected",
18024 // listen for node click?
18025 view.on("click", function(vw, index, node, e){
18026 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
18030 dataModel.load("foobar.xml");
18032 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
18034 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
18035 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
18037 * Note: old style constructor is still suported (container, template, config)
18040 * Create a new View
18041 * @param {Object} config The config object
18044 Roo.View = function(config, depreciated_tpl, depreciated_config){
18046 this.parent = false;
18048 if (typeof(depreciated_tpl) == 'undefined') {
18049 // new way.. - universal constructor.
18050 Roo.apply(this, config);
18051 this.el = Roo.get(this.el);
18054 this.el = Roo.get(config);
18055 this.tpl = depreciated_tpl;
18056 Roo.apply(this, depreciated_config);
18058 this.wrapEl = this.el.wrap().wrap();
18059 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
18062 if(typeof(this.tpl) == "string"){
18063 this.tpl = new Roo.Template(this.tpl);
18065 // support xtype ctors..
18066 this.tpl = new Roo.factory(this.tpl, Roo);
18070 this.tpl.compile();
18075 * @event beforeclick
18076 * Fires before a click is processed. Returns false to cancel the default action.
18077 * @param {Roo.View} this
18078 * @param {Number} index The index of the target node
18079 * @param {HTMLElement} node The target node
18080 * @param {Roo.EventObject} e The raw event object
18082 "beforeclick" : true,
18085 * Fires when a template node is clicked.
18086 * @param {Roo.View} this
18087 * @param {Number} index The index of the target node
18088 * @param {HTMLElement} node The target node
18089 * @param {Roo.EventObject} e The raw event object
18094 * Fires when a template node is double clicked.
18095 * @param {Roo.View} this
18096 * @param {Number} index The index of the target node
18097 * @param {HTMLElement} node The target node
18098 * @param {Roo.EventObject} e The raw event object
18102 * @event contextmenu
18103 * Fires when a template node is right clicked.
18104 * @param {Roo.View} this
18105 * @param {Number} index The index of the target node
18106 * @param {HTMLElement} node The target node
18107 * @param {Roo.EventObject} e The raw event object
18109 "contextmenu" : true,
18111 * @event selectionchange
18112 * Fires when the selected nodes change.
18113 * @param {Roo.View} this
18114 * @param {Array} selections Array of the selected nodes
18116 "selectionchange" : true,
18119 * @event beforeselect
18120 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
18121 * @param {Roo.View} this
18122 * @param {HTMLElement} node The node to be selected
18123 * @param {Array} selections Array of currently selected nodes
18125 "beforeselect" : true,
18127 * @event preparedata
18128 * Fires on every row to render, to allow you to change the data.
18129 * @param {Roo.View} this
18130 * @param {Object} data to be rendered (change this)
18132 "preparedata" : true
18140 "click": this.onClick,
18141 "dblclick": this.onDblClick,
18142 "contextmenu": this.onContextMenu,
18146 this.selections = [];
18148 this.cmp = new Roo.CompositeElementLite([]);
18150 this.store = Roo.factory(this.store, Roo.data);
18151 this.setStore(this.store, true);
18154 if ( this.footer && this.footer.xtype) {
18156 var fctr = this.wrapEl.appendChild(document.createElement("div"));
18158 this.footer.dataSource = this.store;
18159 this.footer.container = fctr;
18160 this.footer = Roo.factory(this.footer, Roo);
18161 fctr.insertFirst(this.el);
18163 // this is a bit insane - as the paging toolbar seems to detach the el..
18164 // dom.parentNode.parentNode.parentNode
18165 // they get detached?
18169 Roo.View.superclass.constructor.call(this);
18174 Roo.extend(Roo.View, Roo.util.Observable, {
18177 * @cfg {Roo.data.Store} store Data store to load data from.
18182 * @cfg {String|Roo.Element} el The container element.
18187 * @cfg {String|Roo.Template} tpl The template used by this View
18191 * @cfg {String} dataName the named area of the template to use as the data area
18192 * Works with domtemplates roo-name="name"
18196 * @cfg {String} selectedClass The css class to add to selected nodes
18198 selectedClass : "x-view-selected",
18200 * @cfg {String} emptyText The empty text to show when nothing is loaded.
18205 * @cfg {String} text to display on mask (default Loading)
18209 * @cfg {Boolean} multiSelect Allow multiple selection
18211 multiSelect : false,
18213 * @cfg {Boolean} singleSelect Allow single selection
18215 singleSelect: false,
18218 * @cfg {Boolean} toggleSelect - selecting
18220 toggleSelect : false,
18223 * @cfg {Boolean} tickable - selecting
18228 * Returns the element this view is bound to.
18229 * @return {Roo.Element}
18231 getEl : function(){
18232 return this.wrapEl;
18238 * Refreshes the view. - called by datachanged on the store. - do not call directly.
18240 refresh : function(){
18241 //Roo.log('refresh');
18244 // if we are using something like 'domtemplate', then
18245 // the what gets used is:
18246 // t.applySubtemplate(NAME, data, wrapping data..)
18247 // the outer template then get' applied with
18248 // the store 'extra data'
18249 // and the body get's added to the
18250 // roo-name="data" node?
18251 // <span class='roo-tpl-{name}'></span> ?????
18255 this.clearSelections();
18256 this.el.update("");
18258 var records = this.store.getRange();
18259 if(records.length < 1) {
18261 // is this valid?? = should it render a template??
18263 this.el.update(this.emptyText);
18267 if (this.dataName) {
18268 this.el.update(t.apply(this.store.meta)); //????
18269 el = this.el.child('.roo-tpl-' + this.dataName);
18272 for(var i = 0, len = records.length; i < len; i++){
18273 var data = this.prepareData(records[i].data, i, records[i]);
18274 this.fireEvent("preparedata", this, data, i, records[i]);
18276 var d = Roo.apply({}, data);
18279 Roo.apply(d, {'roo-id' : Roo.id()});
18283 Roo.each(this.parent.item, function(item){
18284 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
18287 Roo.apply(d, {'roo-data-checked' : 'checked'});
18291 html[html.length] = Roo.util.Format.trim(
18293 t.applySubtemplate(this.dataName, d, this.store.meta) :
18300 el.update(html.join(""));
18301 this.nodes = el.dom.childNodes;
18302 this.updateIndexes(0);
18307 * Function to override to reformat the data that is sent to
18308 * the template for each node.
18309 * DEPRICATED - use the preparedata event handler.
18310 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
18311 * a JSON object for an UpdateManager bound view).
18313 prepareData : function(data, index, record)
18315 this.fireEvent("preparedata", this, data, index, record);
18319 onUpdate : function(ds, record){
18320 // Roo.log('on update');
18321 this.clearSelections();
18322 var index = this.store.indexOf(record);
18323 var n = this.nodes[index];
18324 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
18325 n.parentNode.removeChild(n);
18326 this.updateIndexes(index, index);
18332 onAdd : function(ds, records, index)
18334 //Roo.log(['on Add', ds, records, index] );
18335 this.clearSelections();
18336 if(this.nodes.length == 0){
18340 var n = this.nodes[index];
18341 for(var i = 0, len = records.length; i < len; i++){
18342 var d = this.prepareData(records[i].data, i, records[i]);
18344 this.tpl.insertBefore(n, d);
18347 this.tpl.append(this.el, d);
18350 this.updateIndexes(index);
18353 onRemove : function(ds, record, index){
18354 // Roo.log('onRemove');
18355 this.clearSelections();
18356 var el = this.dataName ?
18357 this.el.child('.roo-tpl-' + this.dataName) :
18360 el.dom.removeChild(this.nodes[index]);
18361 this.updateIndexes(index);
18365 * Refresh an individual node.
18366 * @param {Number} index
18368 refreshNode : function(index){
18369 this.onUpdate(this.store, this.store.getAt(index));
18372 updateIndexes : function(startIndex, endIndex){
18373 var ns = this.nodes;
18374 startIndex = startIndex || 0;
18375 endIndex = endIndex || ns.length - 1;
18376 for(var i = startIndex; i <= endIndex; i++){
18377 ns[i].nodeIndex = i;
18382 * Changes the data store this view uses and refresh the view.
18383 * @param {Store} store
18385 setStore : function(store, initial){
18386 if(!initial && this.store){
18387 this.store.un("datachanged", this.refresh);
18388 this.store.un("add", this.onAdd);
18389 this.store.un("remove", this.onRemove);
18390 this.store.un("update", this.onUpdate);
18391 this.store.un("clear", this.refresh);
18392 this.store.un("beforeload", this.onBeforeLoad);
18393 this.store.un("load", this.onLoad);
18394 this.store.un("loadexception", this.onLoad);
18398 store.on("datachanged", this.refresh, this);
18399 store.on("add", this.onAdd, this);
18400 store.on("remove", this.onRemove, this);
18401 store.on("update", this.onUpdate, this);
18402 store.on("clear", this.refresh, this);
18403 store.on("beforeload", this.onBeforeLoad, this);
18404 store.on("load", this.onLoad, this);
18405 store.on("loadexception", this.onLoad, this);
18413 * onbeforeLoad - masks the loading area.
18416 onBeforeLoad : function(store,opts)
18418 //Roo.log('onBeforeLoad');
18420 this.el.update("");
18422 this.el.mask(this.mask ? this.mask : "Loading" );
18424 onLoad : function ()
18431 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
18432 * @param {HTMLElement} node
18433 * @return {HTMLElement} The template node
18435 findItemFromChild : function(node){
18436 var el = this.dataName ?
18437 this.el.child('.roo-tpl-' + this.dataName,true) :
18440 if(!node || node.parentNode == el){
18443 var p = node.parentNode;
18444 while(p && p != el){
18445 if(p.parentNode == el){
18454 onClick : function(e){
18455 var item = this.findItemFromChild(e.getTarget());
18457 var index = this.indexOf(item);
18458 if(this.onItemClick(item, index, e) !== false){
18459 this.fireEvent("click", this, index, item, e);
18462 this.clearSelections();
18467 onContextMenu : function(e){
18468 var item = this.findItemFromChild(e.getTarget());
18470 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
18475 onDblClick : function(e){
18476 var item = this.findItemFromChild(e.getTarget());
18478 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
18482 onItemClick : function(item, index, e)
18484 if(this.fireEvent("beforeclick", this, index, item, e) === false){
18487 if (this.toggleSelect) {
18488 var m = this.isSelected(item) ? 'unselect' : 'select';
18491 _t[m](item, true, false);
18494 if(this.multiSelect || this.singleSelect){
18495 if(this.multiSelect && e.shiftKey && this.lastSelection){
18496 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
18498 this.select(item, this.multiSelect && e.ctrlKey);
18499 this.lastSelection = item;
18502 if(!this.tickable){
18503 e.preventDefault();
18511 * Get the number of selected nodes.
18514 getSelectionCount : function(){
18515 return this.selections.length;
18519 * Get the currently selected nodes.
18520 * @return {Array} An array of HTMLElements
18522 getSelectedNodes : function(){
18523 return this.selections;
18527 * Get the indexes of the selected nodes.
18530 getSelectedIndexes : function(){
18531 var indexes = [], s = this.selections;
18532 for(var i = 0, len = s.length; i < len; i++){
18533 indexes.push(s[i].nodeIndex);
18539 * Clear all selections
18540 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
18542 clearSelections : function(suppressEvent){
18543 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
18544 this.cmp.elements = this.selections;
18545 this.cmp.removeClass(this.selectedClass);
18546 this.selections = [];
18547 if(!suppressEvent){
18548 this.fireEvent("selectionchange", this, this.selections);
18554 * Returns true if the passed node is selected
18555 * @param {HTMLElement/Number} node The node or node index
18556 * @return {Boolean}
18558 isSelected : function(node){
18559 var s = this.selections;
18563 node = this.getNode(node);
18564 return s.indexOf(node) !== -1;
18569 * @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
18570 * @param {Boolean} keepExisting (optional) true to keep existing selections
18571 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
18573 select : function(nodeInfo, keepExisting, suppressEvent){
18574 if(nodeInfo instanceof Array){
18576 this.clearSelections(true);
18578 for(var i = 0, len = nodeInfo.length; i < len; i++){
18579 this.select(nodeInfo[i], true, true);
18583 var node = this.getNode(nodeInfo);
18584 if(!node || this.isSelected(node)){
18585 return; // already selected.
18588 this.clearSelections(true);
18591 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
18592 Roo.fly(node).addClass(this.selectedClass);
18593 this.selections.push(node);
18594 if(!suppressEvent){
18595 this.fireEvent("selectionchange", this, this.selections);
18603 * @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
18604 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
18605 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
18607 unselect : function(nodeInfo, keepExisting, suppressEvent)
18609 if(nodeInfo instanceof Array){
18610 Roo.each(this.selections, function(s) {
18611 this.unselect(s, nodeInfo);
18615 var node = this.getNode(nodeInfo);
18616 if(!node || !this.isSelected(node)){
18617 //Roo.log("not selected");
18618 return; // not selected.
18622 Roo.each(this.selections, function(s) {
18624 Roo.fly(node).removeClass(this.selectedClass);
18631 this.selections= ns;
18632 this.fireEvent("selectionchange", this, this.selections);
18636 * Gets a template node.
18637 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
18638 * @return {HTMLElement} The node or null if it wasn't found
18640 getNode : function(nodeInfo){
18641 if(typeof nodeInfo == "string"){
18642 return document.getElementById(nodeInfo);
18643 }else if(typeof nodeInfo == "number"){
18644 return this.nodes[nodeInfo];
18650 * Gets a range template nodes.
18651 * @param {Number} startIndex
18652 * @param {Number} endIndex
18653 * @return {Array} An array of nodes
18655 getNodes : function(start, end){
18656 var ns = this.nodes;
18657 start = start || 0;
18658 end = typeof end == "undefined" ? ns.length - 1 : end;
18661 for(var i = start; i <= end; i++){
18665 for(var i = start; i >= end; i--){
18673 * Finds the index of the passed node
18674 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
18675 * @return {Number} The index of the node or -1
18677 indexOf : function(node){
18678 node = this.getNode(node);
18679 if(typeof node.nodeIndex == "number"){
18680 return node.nodeIndex;
18682 var ns = this.nodes;
18683 for(var i = 0, len = ns.length; i < len; i++){
18694 * based on jquery fullcalendar
18698 Roo.bootstrap = Roo.bootstrap || {};
18700 * @class Roo.bootstrap.Calendar
18701 * @extends Roo.bootstrap.Component
18702 * Bootstrap Calendar class
18703 * @cfg {Boolean} loadMask (true|false) default false
18704 * @cfg {Object} header generate the user specific header of the calendar, default false
18707 * Create a new Container
18708 * @param {Object} config The config object
18713 Roo.bootstrap.Calendar = function(config){
18714 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
18718 * Fires when a date is selected
18719 * @param {DatePicker} this
18720 * @param {Date} date The selected date
18724 * @event monthchange
18725 * Fires when the displayed month changes
18726 * @param {DatePicker} this
18727 * @param {Date} date The selected month
18729 'monthchange': true,
18731 * @event evententer
18732 * Fires when mouse over an event
18733 * @param {Calendar} this
18734 * @param {event} Event
18736 'evententer': true,
18738 * @event eventleave
18739 * Fires when the mouse leaves an
18740 * @param {Calendar} this
18743 'eventleave': true,
18745 * @event eventclick
18746 * Fires when the mouse click an
18747 * @param {Calendar} this
18756 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
18759 * @cfg {Number} startDay
18760 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
18768 getAutoCreate : function(){
18771 var fc_button = function(name, corner, style, content ) {
18772 return Roo.apply({},{
18774 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
18776 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
18779 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
18790 style : 'width:100%',
18797 cls : 'fc-header-left',
18799 fc_button('prev', 'left', 'arrow', '‹' ),
18800 fc_button('next', 'right', 'arrow', '›' ),
18801 { tag: 'span', cls: 'fc-header-space' },
18802 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
18810 cls : 'fc-header-center',
18814 cls: 'fc-header-title',
18817 html : 'month / year'
18825 cls : 'fc-header-right',
18827 /* fc_button('month', 'left', '', 'month' ),
18828 fc_button('week', '', '', 'week' ),
18829 fc_button('day', 'right', '', 'day' )
18841 header = this.header;
18844 var cal_heads = function() {
18846 // fixme - handle this.
18848 for (var i =0; i < Date.dayNames.length; i++) {
18849 var d = Date.dayNames[i];
18852 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
18853 html : d.substring(0,3)
18857 ret[0].cls += ' fc-first';
18858 ret[6].cls += ' fc-last';
18861 var cal_cell = function(n) {
18864 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
18869 cls: 'fc-day-number',
18873 cls: 'fc-day-content',
18877 style: 'position: relative;' // height: 17px;
18889 var cal_rows = function() {
18892 for (var r = 0; r < 6; r++) {
18899 for (var i =0; i < Date.dayNames.length; i++) {
18900 var d = Date.dayNames[i];
18901 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
18904 row.cn[0].cls+=' fc-first';
18905 row.cn[0].cn[0].style = 'min-height:90px';
18906 row.cn[6].cls+=' fc-last';
18910 ret[0].cls += ' fc-first';
18911 ret[4].cls += ' fc-prev-last';
18912 ret[5].cls += ' fc-last';
18919 cls: 'fc-border-separate',
18920 style : 'width:100%',
18928 cls : 'fc-first fc-last',
18946 cls : 'fc-content',
18947 style : "position: relative;",
18950 cls : 'fc-view fc-view-month fc-grid',
18951 style : 'position: relative',
18952 unselectable : 'on',
18955 cls : 'fc-event-container',
18956 style : 'position:absolute;z-index:8;top:0;left:0;'
18974 initEvents : function()
18977 throw "can not find store for calendar";
18983 style: "text-align:center",
18987 style: "background-color:white;width:50%;margin:250 auto",
18991 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
19002 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
19004 var size = this.el.select('.fc-content', true).first().getSize();
19005 this.maskEl.setSize(size.width, size.height);
19006 this.maskEl.enableDisplayMode("block");
19007 if(!this.loadMask){
19008 this.maskEl.hide();
19011 this.store = Roo.factory(this.store, Roo.data);
19012 this.store.on('load', this.onLoad, this);
19013 this.store.on('beforeload', this.onBeforeLoad, this);
19017 this.cells = this.el.select('.fc-day',true);
19018 //Roo.log(this.cells);
19019 this.textNodes = this.el.query('.fc-day-number');
19020 this.cells.addClassOnOver('fc-state-hover');
19022 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
19023 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
19024 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
19025 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
19027 this.on('monthchange', this.onMonthChange, this);
19029 this.update(new Date().clearTime());
19032 resize : function() {
19033 var sz = this.el.getSize();
19035 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
19036 this.el.select('.fc-day-content div',true).setHeight(34);
19041 showPrevMonth : function(e){
19042 this.update(this.activeDate.add("mo", -1));
19044 showToday : function(e){
19045 this.update(new Date().clearTime());
19048 showNextMonth : function(e){
19049 this.update(this.activeDate.add("mo", 1));
19053 showPrevYear : function(){
19054 this.update(this.activeDate.add("y", -1));
19058 showNextYear : function(){
19059 this.update(this.activeDate.add("y", 1));
19064 update : function(date)
19066 var vd = this.activeDate;
19067 this.activeDate = date;
19068 // if(vd && this.el){
19069 // var t = date.getTime();
19070 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
19071 // Roo.log('using add remove');
19073 // this.fireEvent('monthchange', this, date);
19075 // this.cells.removeClass("fc-state-highlight");
19076 // this.cells.each(function(c){
19077 // if(c.dateValue == t){
19078 // c.addClass("fc-state-highlight");
19079 // setTimeout(function(){
19080 // try{c.dom.firstChild.focus();}catch(e){}
19090 var days = date.getDaysInMonth();
19092 var firstOfMonth = date.getFirstDateOfMonth();
19093 var startingPos = firstOfMonth.getDay()-this.startDay;
19095 if(startingPos < this.startDay){
19099 var pm = date.add(Date.MONTH, -1);
19100 var prevStart = pm.getDaysInMonth()-startingPos;
19102 this.cells = this.el.select('.fc-day',true);
19103 this.textNodes = this.el.query('.fc-day-number');
19104 this.cells.addClassOnOver('fc-state-hover');
19106 var cells = this.cells.elements;
19107 var textEls = this.textNodes;
19109 Roo.each(cells, function(cell){
19110 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
19113 days += startingPos;
19115 // convert everything to numbers so it's fast
19116 var day = 86400000;
19117 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
19120 //Roo.log(prevStart);
19122 var today = new Date().clearTime().getTime();
19123 var sel = date.clearTime().getTime();
19124 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
19125 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
19126 var ddMatch = this.disabledDatesRE;
19127 var ddText = this.disabledDatesText;
19128 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
19129 var ddaysText = this.disabledDaysText;
19130 var format = this.format;
19132 var setCellClass = function(cal, cell){
19136 //Roo.log('set Cell Class');
19138 var t = d.getTime();
19142 cell.dateValue = t;
19144 cell.className += " fc-today";
19145 cell.className += " fc-state-highlight";
19146 cell.title = cal.todayText;
19149 // disable highlight in other month..
19150 //cell.className += " fc-state-highlight";
19155 cell.className = " fc-state-disabled";
19156 cell.title = cal.minText;
19160 cell.className = " fc-state-disabled";
19161 cell.title = cal.maxText;
19165 if(ddays.indexOf(d.getDay()) != -1){
19166 cell.title = ddaysText;
19167 cell.className = " fc-state-disabled";
19170 if(ddMatch && format){
19171 var fvalue = d.dateFormat(format);
19172 if(ddMatch.test(fvalue)){
19173 cell.title = ddText.replace("%0", fvalue);
19174 cell.className = " fc-state-disabled";
19178 if (!cell.initialClassName) {
19179 cell.initialClassName = cell.dom.className;
19182 cell.dom.className = cell.initialClassName + ' ' + cell.className;
19187 for(; i < startingPos; i++) {
19188 textEls[i].innerHTML = (++prevStart);
19189 d.setDate(d.getDate()+1);
19191 cells[i].className = "fc-past fc-other-month";
19192 setCellClass(this, cells[i]);
19197 for(; i < days; i++){
19198 intDay = i - startingPos + 1;
19199 textEls[i].innerHTML = (intDay);
19200 d.setDate(d.getDate()+1);
19202 cells[i].className = ''; // "x-date-active";
19203 setCellClass(this, cells[i]);
19207 for(; i < 42; i++) {
19208 textEls[i].innerHTML = (++extraDays);
19209 d.setDate(d.getDate()+1);
19211 cells[i].className = "fc-future fc-other-month";
19212 setCellClass(this, cells[i]);
19215 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
19217 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
19219 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
19220 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
19222 if(totalRows != 6){
19223 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
19224 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
19227 this.fireEvent('monthchange', this, date);
19231 if(!this.internalRender){
19232 var main = this.el.dom.firstChild;
19233 var w = main.offsetWidth;
19234 this.el.setWidth(w + this.el.getBorderWidth("lr"));
19235 Roo.fly(main).setWidth(w);
19236 this.internalRender = true;
19237 // opera does not respect the auto grow header center column
19238 // then, after it gets a width opera refuses to recalculate
19239 // without a second pass
19240 if(Roo.isOpera && !this.secondPass){
19241 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
19242 this.secondPass = true;
19243 this.update.defer(10, this, [date]);
19250 findCell : function(dt) {
19251 dt = dt.clearTime().getTime();
19253 this.cells.each(function(c){
19254 //Roo.log("check " +c.dateValue + '?=' + dt);
19255 if(c.dateValue == dt){
19265 findCells : function(ev) {
19266 var s = ev.start.clone().clearTime().getTime();
19268 var e= ev.end.clone().clearTime().getTime();
19271 this.cells.each(function(c){
19272 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
19274 if(c.dateValue > e){
19277 if(c.dateValue < s){
19286 // findBestRow: function(cells)
19290 // for (var i =0 ; i < cells.length;i++) {
19291 // ret = Math.max(cells[i].rows || 0,ret);
19298 addItem : function(ev)
19300 // look for vertical location slot in
19301 var cells = this.findCells(ev);
19303 // ev.row = this.findBestRow(cells);
19305 // work out the location.
19309 for(var i =0; i < cells.length; i++) {
19311 cells[i].row = cells[0].row;
19314 cells[i].row = cells[i].row + 1;
19324 if (crow.start.getY() == cells[i].getY()) {
19326 crow.end = cells[i];
19343 cells[0].events.push(ev);
19345 this.calevents.push(ev);
19348 clearEvents: function() {
19350 if(!this.calevents){
19354 Roo.each(this.cells.elements, function(c){
19360 Roo.each(this.calevents, function(e) {
19361 Roo.each(e.els, function(el) {
19362 el.un('mouseenter' ,this.onEventEnter, this);
19363 el.un('mouseleave' ,this.onEventLeave, this);
19368 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
19374 renderEvents: function()
19378 this.cells.each(function(c) {
19387 if(c.row != c.events.length){
19388 r = 4 - (4 - (c.row - c.events.length));
19391 c.events = ev.slice(0, r);
19392 c.more = ev.slice(r);
19394 if(c.more.length && c.more.length == 1){
19395 c.events.push(c.more.pop());
19398 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
19402 this.cells.each(function(c) {
19404 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
19407 for (var e = 0; e < c.events.length; e++){
19408 var ev = c.events[e];
19409 var rows = ev.rows;
19411 for(var i = 0; i < rows.length; i++) {
19413 // how many rows should it span..
19416 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
19417 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
19419 unselectable : "on",
19422 cls: 'fc-event-inner',
19426 // cls: 'fc-event-time',
19427 // html : cells.length > 1 ? '' : ev.time
19431 cls: 'fc-event-title',
19432 html : String.format('{0}', ev.title)
19439 cls: 'ui-resizable-handle ui-resizable-e',
19440 html : '  '
19447 cfg.cls += ' fc-event-start';
19449 if ((i+1) == rows.length) {
19450 cfg.cls += ' fc-event-end';
19453 var ctr = _this.el.select('.fc-event-container',true).first();
19454 var cg = ctr.createChild(cfg);
19456 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
19457 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
19459 var r = (c.more.length) ? 1 : 0;
19460 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
19461 cg.setWidth(ebox.right - sbox.x -2);
19463 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
19464 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
19465 cg.on('click', _this.onEventClick, _this, ev);
19476 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
19477 style : 'position: absolute',
19478 unselectable : "on",
19481 cls: 'fc-event-inner',
19485 cls: 'fc-event-title',
19493 cls: 'ui-resizable-handle ui-resizable-e',
19494 html : '  '
19500 var ctr = _this.el.select('.fc-event-container',true).first();
19501 var cg = ctr.createChild(cfg);
19503 var sbox = c.select('.fc-day-content',true).first().getBox();
19504 var ebox = c.select('.fc-day-content',true).first().getBox();
19506 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
19507 cg.setWidth(ebox.right - sbox.x -2);
19509 cg.on('click', _this.onMoreEventClick, _this, c.more);
19519 onEventEnter: function (e, el,event,d) {
19520 this.fireEvent('evententer', this, el, event);
19523 onEventLeave: function (e, el,event,d) {
19524 this.fireEvent('eventleave', this, el, event);
19527 onEventClick: function (e, el,event,d) {
19528 this.fireEvent('eventclick', this, el, event);
19531 onMonthChange: function () {
19535 onMoreEventClick: function(e, el, more)
19539 this.calpopover.placement = 'right';
19540 this.calpopover.setTitle('More');
19542 this.calpopover.setContent('');
19544 var ctr = this.calpopover.el.select('.popover-content', true).first();
19546 Roo.each(more, function(m){
19548 cls : 'fc-event-hori fc-event-draggable',
19551 var cg = ctr.createChild(cfg);
19553 cg.on('click', _this.onEventClick, _this, m);
19556 this.calpopover.show(el);
19561 onLoad: function ()
19563 this.calevents = [];
19566 if(this.store.getCount() > 0){
19567 this.store.data.each(function(d){
19570 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
19571 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
19572 time : d.data.start_time,
19573 title : d.data.title,
19574 description : d.data.description,
19575 venue : d.data.venue
19580 this.renderEvents();
19582 if(this.calevents.length && this.loadMask){
19583 this.maskEl.hide();
19587 onBeforeLoad: function()
19589 this.clearEvents();
19591 this.maskEl.show();
19605 * @class Roo.bootstrap.Popover
19606 * @extends Roo.bootstrap.Component
19607 * Bootstrap Popover class
19608 * @cfg {String} html contents of the popover (or false to use children..)
19609 * @cfg {String} title of popover (or false to hide)
19610 * @cfg {String|function} (right|top|bottom|left|auto) placement how it is placed
19611 * @cfg {String} trigger click || hover (or false to trigger manually)
19612 * @cfg {Boolean} modal - popovers that are modal will mask the screen, and must be closed with another event.
19613 * @cfg {String|Boolean|Roo.Element} add click hander to trigger show over what element
19614 * - if false and it has a 'parent' then it will be automatically added to that element
19615 * - if string - Roo.get will be called
19616 * @cfg {Number} delay - delay before showing
19619 * Create a new Popover
19620 * @param {Object} config The config object
19623 Roo.bootstrap.Popover = function(config){
19624 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
19630 * After the popover show
19632 * @param {Roo.bootstrap.Popover} this
19637 * After the popover hide
19639 * @param {Roo.bootstrap.Popover} this
19645 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
19650 placement : 'right',
19651 trigger : 'hover', // hover
19657 can_build_overlaid : false,
19659 maskEl : false, // the mask element
19664 getChildContainer : function()
19666 return this.contentEl;
19669 getPopoverHeader : function()
19671 this.title = true; // flag not to hide it..
19672 this.headerEl.addClass('p-0');
19673 return this.headerEl
19677 getAutoCreate : function(){
19680 cls : 'popover roo-dynamic shadow roo-popover' + (this.modal ? '-modal' : ''),
19681 style: 'display:block',
19687 cls : 'popover-inner ',
19691 cls: 'popover-title popover-header',
19692 html : this.title === false ? '' : this.title
19695 cls : 'popover-content popover-body ' + (this.cls || ''),
19696 html : this.html || ''
19707 * @param {string} the title
19709 setTitle: function(str)
19713 this.headerEl.dom.innerHTML = str;
19718 * @param {string} the body content
19720 setContent: function(str)
19723 if (this.contentEl) {
19724 this.contentEl.dom.innerHTML = str;
19728 // as it get's added to the bottom of the page.
19729 onRender : function(ct, position)
19731 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
19736 var cfg = Roo.apply({}, this.getAutoCreate());
19740 cfg.cls += ' ' + this.cls;
19743 cfg.style = this.style;
19745 //Roo.log("adding to ");
19746 this.el = Roo.get(document.body).createChild(cfg, position);
19747 // Roo.log(this.el);
19750 this.contentEl = this.el.select('.popover-content',true).first();
19751 this.headerEl = this.el.select('.popover-title',true).first();
19754 if(typeof(this.items) != 'undefined'){
19755 var items = this.items;
19758 for(var i =0;i < items.length;i++) {
19759 nitems.push(this.addxtype(Roo.apply({}, items[i])));
19763 this.items = nitems;
19765 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
19766 Roo.EventManager.onWindowResize(this.resizeMask, this, true);
19773 resizeMask : function()
19775 this.maskEl.setSize(
19776 Roo.lib.Dom.getViewWidth(true),
19777 Roo.lib.Dom.getViewHeight(true)
19781 initEvents : function()
19785 Roo.bootstrap.Popover.register(this);
19789 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY); // probably not needed as it's default in BS4
19790 this.el.enableDisplayMode('block');
19792 if (this.over === false && !this.parent()) {
19795 if (this.triggers === false) {
19800 var on_el = (this.over == 'parent' || this.over === false) ? this.parent().el : Roo.get(this.over);
19801 var triggers = this.trigger ? this.trigger.split(' ') : [];
19802 Roo.each(triggers, function(trigger) {
19804 if (trigger == 'click') {
19805 on_el.on('click', this.toggle, this);
19806 } else if (trigger != 'manual') {
19807 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
19808 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
19810 on_el.on(eventIn ,this.enter, this);
19811 on_el.on(eventOut, this.leave, this);
19822 toggle : function () {
19823 this.hoverState == 'in' ? this.leave() : this.enter();
19826 enter : function () {
19828 clearTimeout(this.timeout);
19830 this.hoverState = 'in';
19832 if (!this.delay || !this.delay.show) {
19837 this.timeout = setTimeout(function () {
19838 if (_t.hoverState == 'in') {
19841 }, this.delay.show)
19844 leave : function() {
19845 clearTimeout(this.timeout);
19847 this.hoverState = 'out';
19849 if (!this.delay || !this.delay.hide) {
19854 this.timeout = setTimeout(function () {
19855 if (_t.hoverState == 'out') {
19858 }, this.delay.hide)
19862 * @param {Roo.Element|string|false} - element to align and point to.
19864 show : function (on_el)
19867 on_el = on_el || false; // default to false
19869 if (this.parent() && (this.over == 'parent' || (this.over === false))) {
19870 on_el = this.parent().el;
19871 } else if (this.over) {
19872 Roo.get(this.over);
19878 this.render(document.body);
19882 this.el.removeClass([
19883 'fade','top','bottom', 'left', 'right','in',
19884 'bs-popover-top','bs-popover-bottom', 'bs-popover-left', 'bs-popover-right'
19887 if (this.title === false) {
19888 this.headerEl.hide();
19892 var placement = typeof this.placement == 'function' ?
19893 this.placement.call(this, this.el, on_el) :
19897 var autoToken = /\s?auto?\s?/i; /// not sure how this was supposed to work? right auto ? what?
19899 // I think 'auto right' - but
19901 var autoPlace = autoToken.test(placement);
19903 placement = placement.replace(autoToken, '') || 'top';
19909 this.el.dom.style.display='block';
19911 //this.el.appendTo(on_el);
19913 var p = this.getPosition();
19914 var box = this.el.getBox();
19917 var align = Roo.bootstrap.Popover.alignment[placement];
19918 this.el.addClass(align[2]);
19923 this.el.alignTo(on_el, align[0],align[1]);
19925 // this is usually just done by the builder = to show the popoup in the middle of the scren.
19926 var es = this.el.getSize();
19927 var x = Roo.lib.Dom.getViewWidth()/2;
19928 var y = Roo.lib.Dom.getViewHeight()/2;
19929 this.el.setXY([ x-(es.width/2), y-(es.height/2)] );
19934 //var arrow = this.el.select('.arrow',true).first();
19935 //arrow.set(align[2],
19937 this.el.addClass('in');
19940 if (this.el.hasClass('fade')) {
19944 this.hoverState = 'in';
19947 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
19948 this.maskEl.setStyle('z-index', Roo.bootstrap.Popover.zIndex++);
19949 this.maskEl.dom.style.display = 'block';
19950 this.maskEl.addClass('show');
19952 this.el.setStyle('z-index', Roo.bootstrap.Popover.zIndex++);
19956 this.fireEvent('show', this);
19961 this.el.setXY([0,0]);
19962 this.el.removeClass('in');
19964 this.hoverState = null;
19965 this.maskEl.hide(); // always..
19966 this.fireEvent('hide', this);
19972 Roo.apply(Roo.bootstrap.Popover, {
19975 'left' : ['r-l', [-10,0], 'left bs-popover-left'],
19976 'right' : ['l-br', [10,0], 'right bs-popover-right'],
19977 'bottom' : ['t-b', [0,10], 'top bs-popover-top'],
19978 'top' : [ 'b-t', [0,-10], 'bottom bs-popover-bottom']
19983 clickHander : false,
19986 onMouseDown : function(e)
19988 if (!e.getTarget(".roo-popover")) {
19996 register : function(popup)
19998 if (!Roo.bootstrap.Popover.clickHandler) {
19999 Roo.bootstrap.Popover.clickHandler = Roo.get(document).on("mousedown", Roo.bootstrap.Popover.onMouseDown, Roo.bootstrap.Popover);
20001 // hide other popups.
20003 this.popups.push(popup);
20005 hideAll : function()
20007 this.popups.forEach(function(p) {
20015 * Card header - holder for the card header elements.
20020 * @class Roo.bootstrap.PopoverNav
20021 * @extends Roo.bootstrap.NavGroup
20022 * Bootstrap Popover header navigation class
20024 * Create a new Popover Header Navigation
20025 * @param {Object} config The config object
20028 Roo.bootstrap.PopoverNav = function(config){
20029 Roo.bootstrap.PopoverNav.superclass.constructor.call(this, config);
20032 Roo.extend(Roo.bootstrap.PopoverNav, Roo.bootstrap.NavSimplebar, {
20035 container_method : 'getPopoverHeader'
20053 * @class Roo.bootstrap.Progress
20054 * @extends Roo.bootstrap.Component
20055 * Bootstrap Progress class
20056 * @cfg {Boolean} striped striped of the progress bar
20057 * @cfg {Boolean} active animated of the progress bar
20061 * Create a new Progress
20062 * @param {Object} config The config object
20065 Roo.bootstrap.Progress = function(config){
20066 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
20069 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
20074 getAutoCreate : function(){
20082 cfg.cls += ' progress-striped';
20086 cfg.cls += ' active';
20105 * @class Roo.bootstrap.ProgressBar
20106 * @extends Roo.bootstrap.Component
20107 * Bootstrap ProgressBar class
20108 * @cfg {Number} aria_valuenow aria-value now
20109 * @cfg {Number} aria_valuemin aria-value min
20110 * @cfg {Number} aria_valuemax aria-value max
20111 * @cfg {String} label label for the progress bar
20112 * @cfg {String} panel (success | info | warning | danger )
20113 * @cfg {String} role role of the progress bar
20114 * @cfg {String} sr_only text
20118 * Create a new ProgressBar
20119 * @param {Object} config The config object
20122 Roo.bootstrap.ProgressBar = function(config){
20123 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
20126 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
20130 aria_valuemax : 100,
20136 getAutoCreate : function()
20141 cls: 'progress-bar',
20142 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
20154 cfg.role = this.role;
20157 if(this.aria_valuenow){
20158 cfg['aria-valuenow'] = this.aria_valuenow;
20161 if(this.aria_valuemin){
20162 cfg['aria-valuemin'] = this.aria_valuemin;
20165 if(this.aria_valuemax){
20166 cfg['aria-valuemax'] = this.aria_valuemax;
20169 if(this.label && !this.sr_only){
20170 cfg.html = this.label;
20174 cfg.cls += ' progress-bar-' + this.panel;
20180 update : function(aria_valuenow)
20182 this.aria_valuenow = aria_valuenow;
20184 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
20199 * @class Roo.bootstrap.TabGroup
20200 * @extends Roo.bootstrap.Column
20201 * Bootstrap Column class
20202 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
20203 * @cfg {Boolean} carousel true to make the group behave like a carousel
20204 * @cfg {Boolean} bullets show bullets for the panels
20205 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
20206 * @cfg {Number} timer auto slide timer .. default 0 millisecond
20207 * @cfg {Boolean} showarrow (true|false) show arrow default true
20210 * Create a new TabGroup
20211 * @param {Object} config The config object
20214 Roo.bootstrap.TabGroup = function(config){
20215 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
20217 this.navId = Roo.id();
20220 Roo.bootstrap.TabGroup.register(this);
20224 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
20227 transition : false,
20232 slideOnTouch : false,
20235 getAutoCreate : function()
20237 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
20239 cfg.cls += ' tab-content';
20241 if (this.carousel) {
20242 cfg.cls += ' carousel slide';
20245 cls : 'carousel-inner',
20249 if(this.bullets && !Roo.isTouch){
20252 cls : 'carousel-bullets',
20256 if(this.bullets_cls){
20257 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
20264 cfg.cn[0].cn.push(bullets);
20267 if(this.showarrow){
20268 cfg.cn[0].cn.push({
20270 class : 'carousel-arrow',
20274 class : 'carousel-prev',
20278 class : 'fa fa-chevron-left'
20284 class : 'carousel-next',
20288 class : 'fa fa-chevron-right'
20301 initEvents: function()
20303 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
20304 // this.el.on("touchstart", this.onTouchStart, this);
20307 if(this.autoslide){
20310 this.slideFn = window.setInterval(function() {
20311 _this.showPanelNext();
20315 if(this.showarrow){
20316 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
20317 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
20323 // onTouchStart : function(e, el, o)
20325 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
20329 // this.showPanelNext();
20333 getChildContainer : function()
20335 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
20339 * register a Navigation item
20340 * @param {Roo.bootstrap.NavItem} the navitem to add
20342 register : function(item)
20344 this.tabs.push( item);
20345 item.navId = this.navId; // not really needed..
20350 getActivePanel : function()
20353 Roo.each(this.tabs, function(t) {
20363 getPanelByName : function(n)
20366 Roo.each(this.tabs, function(t) {
20367 if (t.tabId == n) {
20375 indexOfPanel : function(p)
20378 Roo.each(this.tabs, function(t,i) {
20379 if (t.tabId == p.tabId) {
20388 * show a specific panel
20389 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
20390 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
20392 showPanel : function (pan)
20394 if(this.transition || typeof(pan) == 'undefined'){
20395 Roo.log("waiting for the transitionend");
20399 if (typeof(pan) == 'number') {
20400 pan = this.tabs[pan];
20403 if (typeof(pan) == 'string') {
20404 pan = this.getPanelByName(pan);
20407 var cur = this.getActivePanel();
20410 Roo.log('pan or acitve pan is undefined');
20414 if (pan.tabId == this.getActivePanel().tabId) {
20418 if (false === cur.fireEvent('beforedeactivate')) {
20422 if(this.bullets > 0 && !Roo.isTouch){
20423 this.setActiveBullet(this.indexOfPanel(pan));
20426 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
20428 //class="carousel-item carousel-item-next carousel-item-left"
20430 this.transition = true;
20431 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
20432 var lr = dir == 'next' ? 'left' : 'right';
20433 pan.el.addClass(dir); // or prev
20434 pan.el.addClass('carousel-item-' + dir); // or prev
20435 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
20436 cur.el.addClass(lr); // or right
20437 pan.el.addClass(lr);
20438 cur.el.addClass('carousel-item-' +lr); // or right
20439 pan.el.addClass('carousel-item-' +lr);
20443 cur.el.on('transitionend', function() {
20444 Roo.log("trans end?");
20446 pan.el.removeClass([lr,dir, 'carousel-item-' + lr, 'carousel-item-' + dir]);
20447 pan.setActive(true);
20449 cur.el.removeClass([lr, 'carousel-item-' + lr]);
20450 cur.setActive(false);
20452 _this.transition = false;
20454 }, this, { single: true } );
20459 cur.setActive(false);
20460 pan.setActive(true);
20465 showPanelNext : function()
20467 var i = this.indexOfPanel(this.getActivePanel());
20469 if (i >= this.tabs.length - 1 && !this.autoslide) {
20473 if (i >= this.tabs.length - 1 && this.autoslide) {
20477 this.showPanel(this.tabs[i+1]);
20480 showPanelPrev : function()
20482 var i = this.indexOfPanel(this.getActivePanel());
20484 if (i < 1 && !this.autoslide) {
20488 if (i < 1 && this.autoslide) {
20489 i = this.tabs.length;
20492 this.showPanel(this.tabs[i-1]);
20496 addBullet: function()
20498 if(!this.bullets || Roo.isTouch){
20501 var ctr = this.el.select('.carousel-bullets',true).first();
20502 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
20503 var bullet = ctr.createChild({
20504 cls : 'bullet bullet-' + i
20505 },ctr.dom.lastChild);
20510 bullet.on('click', (function(e, el, o, ii, t){
20512 e.preventDefault();
20514 this.showPanel(ii);
20516 if(this.autoslide && this.slideFn){
20517 clearInterval(this.slideFn);
20518 this.slideFn = window.setInterval(function() {
20519 _this.showPanelNext();
20523 }).createDelegate(this, [i, bullet], true));
20528 setActiveBullet : function(i)
20534 Roo.each(this.el.select('.bullet', true).elements, function(el){
20535 el.removeClass('selected');
20538 var bullet = this.el.select('.bullet-' + i, true).first();
20544 bullet.addClass('selected');
20555 Roo.apply(Roo.bootstrap.TabGroup, {
20559 * register a Navigation Group
20560 * @param {Roo.bootstrap.NavGroup} the navgroup to add
20562 register : function(navgrp)
20564 this.groups[navgrp.navId] = navgrp;
20568 * fetch a Navigation Group based on the navigation ID
20569 * if one does not exist , it will get created.
20570 * @param {string} the navgroup to add
20571 * @returns {Roo.bootstrap.NavGroup} the navgroup
20573 get: function(navId) {
20574 if (typeof(this.groups[navId]) == 'undefined') {
20575 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
20577 return this.groups[navId] ;
20592 * @class Roo.bootstrap.TabPanel
20593 * @extends Roo.bootstrap.Component
20594 * Bootstrap TabPanel class
20595 * @cfg {Boolean} active panel active
20596 * @cfg {String} html panel content
20597 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
20598 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
20599 * @cfg {String} href click to link..
20600 * @cfg {Boolean} touchSlide if swiping slides tab to next panel (default off)
20604 * Create a new TabPanel
20605 * @param {Object} config The config object
20608 Roo.bootstrap.TabPanel = function(config){
20609 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
20613 * Fires when the active status changes
20614 * @param {Roo.bootstrap.TabPanel} this
20615 * @param {Boolean} state the new state
20620 * @event beforedeactivate
20621 * Fires before a tab is de-activated - can be used to do validation on a form.
20622 * @param {Roo.bootstrap.TabPanel} this
20623 * @return {Boolean} false if there is an error
20626 'beforedeactivate': true
20629 this.tabId = this.tabId || Roo.id();
20633 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
20640 touchSlide : false,
20641 getAutoCreate : function(){
20646 // item is needed for carousel - not sure if it has any effect otherwise
20647 cls: 'carousel-item tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
20648 html: this.html || ''
20652 cfg.cls += ' active';
20656 cfg.tabId = this.tabId;
20664 initEvents: function()
20666 var p = this.parent();
20668 this.navId = this.navId || p.navId;
20670 if (typeof(this.navId) != 'undefined') {
20671 // not really needed.. but just in case.. parent should be a NavGroup.
20672 var tg = Roo.bootstrap.TabGroup.get(this.navId);
20676 var i = tg.tabs.length - 1;
20678 if(this.active && tg.bullets > 0 && i < tg.bullets){
20679 tg.setActiveBullet(i);
20683 this.el.on('click', this.onClick, this);
20685 if(Roo.isTouch && this.touchSlide){
20686 this.el.on("touchstart", this.onTouchStart, this);
20687 this.el.on("touchmove", this.onTouchMove, this);
20688 this.el.on("touchend", this.onTouchEnd, this);
20693 onRender : function(ct, position)
20695 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
20698 setActive : function(state)
20700 Roo.log("panel - set active " + this.tabId + "=" + state);
20702 this.active = state;
20704 this.el.removeClass('active');
20706 } else if (!this.el.hasClass('active')) {
20707 this.el.addClass('active');
20710 this.fireEvent('changed', this, state);
20713 onClick : function(e)
20715 e.preventDefault();
20717 if(!this.href.length){
20721 window.location.href = this.href;
20730 onTouchStart : function(e)
20732 this.swiping = false;
20734 this.startX = e.browserEvent.touches[0].clientX;
20735 this.startY = e.browserEvent.touches[0].clientY;
20738 onTouchMove : function(e)
20740 this.swiping = true;
20742 this.endX = e.browserEvent.touches[0].clientX;
20743 this.endY = e.browserEvent.touches[0].clientY;
20746 onTouchEnd : function(e)
20753 var tabGroup = this.parent();
20755 if(this.endX > this.startX){ // swiping right
20756 tabGroup.showPanelPrev();
20760 if(this.startX > this.endX){ // swiping left
20761 tabGroup.showPanelNext();
20780 * @class Roo.bootstrap.DateField
20781 * @extends Roo.bootstrap.Input
20782 * Bootstrap DateField class
20783 * @cfg {Number} weekStart default 0
20784 * @cfg {String} viewMode default empty, (months|years)
20785 * @cfg {String} minViewMode default empty, (months|years)
20786 * @cfg {Number} startDate default -Infinity
20787 * @cfg {Number} endDate default Infinity
20788 * @cfg {Boolean} todayHighlight default false
20789 * @cfg {Boolean} todayBtn default false
20790 * @cfg {Boolean} calendarWeeks default false
20791 * @cfg {Object} daysOfWeekDisabled default empty
20792 * @cfg {Boolean} singleMode default false (true | false)
20794 * @cfg {Boolean} keyboardNavigation default true
20795 * @cfg {String} language default en
20798 * Create a new DateField
20799 * @param {Object} config The config object
20802 Roo.bootstrap.DateField = function(config){
20803 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
20807 * Fires when this field show.
20808 * @param {Roo.bootstrap.DateField} this
20809 * @param {Mixed} date The date value
20814 * Fires when this field hide.
20815 * @param {Roo.bootstrap.DateField} this
20816 * @param {Mixed} date The date value
20821 * Fires when select a date.
20822 * @param {Roo.bootstrap.DateField} this
20823 * @param {Mixed} date The date value
20827 * @event beforeselect
20828 * Fires when before select a date.
20829 * @param {Roo.bootstrap.DateField} this
20830 * @param {Mixed} date The date value
20832 beforeselect : true
20836 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
20839 * @cfg {String} format
20840 * The default date format string which can be overriden for localization support. The format must be
20841 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
20845 * @cfg {String} altFormats
20846 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
20847 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
20849 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
20857 todayHighlight : false,
20863 keyboardNavigation: true,
20865 calendarWeeks: false,
20867 startDate: -Infinity,
20871 daysOfWeekDisabled: [],
20875 singleMode : false,
20877 UTCDate: function()
20879 return new Date(Date.UTC.apply(Date, arguments));
20882 UTCToday: function()
20884 var today = new Date();
20885 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
20888 getDate: function() {
20889 var d = this.getUTCDate();
20890 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
20893 getUTCDate: function() {
20897 setDate: function(d) {
20898 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
20901 setUTCDate: function(d) {
20903 this.setValue(this.formatDate(this.date));
20906 onRender: function(ct, position)
20909 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
20911 this.language = this.language || 'en';
20912 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
20913 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
20915 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
20916 this.format = this.format || 'm/d/y';
20917 this.isInline = false;
20918 this.isInput = true;
20919 this.component = this.el.select('.add-on', true).first() || false;
20920 this.component = (this.component && this.component.length === 0) ? false : this.component;
20921 this.hasInput = this.component && this.inputEl().length;
20923 if (typeof(this.minViewMode === 'string')) {
20924 switch (this.minViewMode) {
20926 this.minViewMode = 1;
20929 this.minViewMode = 2;
20932 this.minViewMode = 0;
20937 if (typeof(this.viewMode === 'string')) {
20938 switch (this.viewMode) {
20951 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
20953 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
20955 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
20957 this.picker().on('mousedown', this.onMousedown, this);
20958 this.picker().on('click', this.onClick, this);
20960 this.picker().addClass('datepicker-dropdown');
20962 this.startViewMode = this.viewMode;
20964 if(this.singleMode){
20965 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
20966 v.setVisibilityMode(Roo.Element.DISPLAY);
20970 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
20971 v.setStyle('width', '189px');
20975 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
20976 if(!this.calendarWeeks){
20981 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
20982 v.attr('colspan', function(i, val){
20983 return parseInt(val) + 1;
20988 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
20990 this.setStartDate(this.startDate);
20991 this.setEndDate(this.endDate);
20993 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
21000 if(this.isInline) {
21005 picker : function()
21007 return this.pickerEl;
21008 // return this.el.select('.datepicker', true).first();
21011 fillDow: function()
21013 var dowCnt = this.weekStart;
21022 if(this.calendarWeeks){
21030 while (dowCnt < this.weekStart + 7) {
21034 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
21038 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
21041 fillMonths: function()
21044 var months = this.picker().select('>.datepicker-months td', true).first();
21046 months.dom.innerHTML = '';
21052 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
21055 months.createChild(month);
21062 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;
21064 if (this.date < this.startDate) {
21065 this.viewDate = new Date(this.startDate);
21066 } else if (this.date > this.endDate) {
21067 this.viewDate = new Date(this.endDate);
21069 this.viewDate = new Date(this.date);
21077 var d = new Date(this.viewDate),
21078 year = d.getUTCFullYear(),
21079 month = d.getUTCMonth(),
21080 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
21081 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
21082 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
21083 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
21084 currentDate = this.date && this.date.valueOf(),
21085 today = this.UTCToday();
21087 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
21089 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
21091 // this.picker.select('>tfoot th.today').
21092 // .text(dates[this.language].today)
21093 // .toggle(this.todayBtn !== false);
21095 this.updateNavArrows();
21098 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
21100 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
21102 prevMonth.setUTCDate(day);
21104 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
21106 var nextMonth = new Date(prevMonth);
21108 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
21110 nextMonth = nextMonth.valueOf();
21112 var fillMonths = false;
21114 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
21116 while(prevMonth.valueOf() <= nextMonth) {
21119 if (prevMonth.getUTCDay() === this.weekStart) {
21121 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
21129 if(this.calendarWeeks){
21130 // ISO 8601: First week contains first thursday.
21131 // ISO also states week starts on Monday, but we can be more abstract here.
21133 // Start of current week: based on weekstart/current date
21134 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
21135 // Thursday of this week
21136 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
21137 // First Thursday of year, year from thursday
21138 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
21139 // Calendar week: ms between thursdays, div ms per day, div 7 days
21140 calWeek = (th - yth) / 864e5 / 7 + 1;
21142 fillMonths.cn.push({
21150 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
21152 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
21155 if (this.todayHighlight &&
21156 prevMonth.getUTCFullYear() == today.getFullYear() &&
21157 prevMonth.getUTCMonth() == today.getMonth() &&
21158 prevMonth.getUTCDate() == today.getDate()) {
21159 clsName += ' today';
21162 if (currentDate && prevMonth.valueOf() === currentDate) {
21163 clsName += ' active';
21166 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
21167 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
21168 clsName += ' disabled';
21171 fillMonths.cn.push({
21173 cls: 'day ' + clsName,
21174 html: prevMonth.getDate()
21177 prevMonth.setDate(prevMonth.getDate()+1);
21180 var currentYear = this.date && this.date.getUTCFullYear();
21181 var currentMonth = this.date && this.date.getUTCMonth();
21183 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
21185 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
21186 v.removeClass('active');
21188 if(currentYear === year && k === currentMonth){
21189 v.addClass('active');
21192 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
21193 v.addClass('disabled');
21199 year = parseInt(year/10, 10) * 10;
21201 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
21203 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
21206 for (var i = -1; i < 11; i++) {
21207 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
21209 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
21217 showMode: function(dir)
21220 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
21223 Roo.each(this.picker().select('>div',true).elements, function(v){
21224 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
21227 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
21232 if(this.isInline) {
21236 this.picker().removeClass(['bottom', 'top']);
21238 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
21240 * place to the top of element!
21244 this.picker().addClass('top');
21245 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
21250 this.picker().addClass('bottom');
21252 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
21255 parseDate : function(value)
21257 if(!value || value instanceof Date){
21260 var v = Date.parseDate(value, this.format);
21261 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
21262 v = Date.parseDate(value, 'Y-m-d');
21264 if(!v && this.altFormats){
21265 if(!this.altFormatsArray){
21266 this.altFormatsArray = this.altFormats.split("|");
21268 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
21269 v = Date.parseDate(value, this.altFormatsArray[i]);
21275 formatDate : function(date, fmt)
21277 return (!date || !(date instanceof Date)) ?
21278 date : date.dateFormat(fmt || this.format);
21281 onFocus : function()
21283 Roo.bootstrap.DateField.superclass.onFocus.call(this);
21287 onBlur : function()
21289 Roo.bootstrap.DateField.superclass.onBlur.call(this);
21291 var d = this.inputEl().getValue();
21298 showPopup : function()
21300 this.picker().show();
21304 this.fireEvent('showpopup', this, this.date);
21307 hidePopup : function()
21309 if(this.isInline) {
21312 this.picker().hide();
21313 this.viewMode = this.startViewMode;
21316 this.fireEvent('hidepopup', this, this.date);
21320 onMousedown: function(e)
21322 e.stopPropagation();
21323 e.preventDefault();
21328 Roo.bootstrap.DateField.superclass.keyup.call(this);
21332 setValue: function(v)
21334 if(this.fireEvent('beforeselect', this, v) !== false){
21335 var d = new Date(this.parseDate(v) ).clearTime();
21337 if(isNaN(d.getTime())){
21338 this.date = this.viewDate = '';
21339 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
21343 v = this.formatDate(d);
21345 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
21347 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
21351 this.fireEvent('select', this, this.date);
21355 getValue: function()
21357 return this.formatDate(this.date);
21360 fireKey: function(e)
21362 if (!this.picker().isVisible()){
21363 if (e.keyCode == 27) { // allow escape to hide and re-show picker
21369 var dateChanged = false,
21371 newDate, newViewDate;
21376 e.preventDefault();
21380 if (!this.keyboardNavigation) {
21383 dir = e.keyCode == 37 ? -1 : 1;
21386 newDate = this.moveYear(this.date, dir);
21387 newViewDate = this.moveYear(this.viewDate, dir);
21388 } else if (e.shiftKey){
21389 newDate = this.moveMonth(this.date, dir);
21390 newViewDate = this.moveMonth(this.viewDate, dir);
21392 newDate = new Date(this.date);
21393 newDate.setUTCDate(this.date.getUTCDate() + dir);
21394 newViewDate = new Date(this.viewDate);
21395 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
21397 if (this.dateWithinRange(newDate)){
21398 this.date = newDate;
21399 this.viewDate = newViewDate;
21400 this.setValue(this.formatDate(this.date));
21402 e.preventDefault();
21403 dateChanged = true;
21408 if (!this.keyboardNavigation) {
21411 dir = e.keyCode == 38 ? -1 : 1;
21413 newDate = this.moveYear(this.date, dir);
21414 newViewDate = this.moveYear(this.viewDate, dir);
21415 } else if (e.shiftKey){
21416 newDate = this.moveMonth(this.date, dir);
21417 newViewDate = this.moveMonth(this.viewDate, dir);
21419 newDate = new Date(this.date);
21420 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
21421 newViewDate = new Date(this.viewDate);
21422 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
21424 if (this.dateWithinRange(newDate)){
21425 this.date = newDate;
21426 this.viewDate = newViewDate;
21427 this.setValue(this.formatDate(this.date));
21429 e.preventDefault();
21430 dateChanged = true;
21434 this.setValue(this.formatDate(this.date));
21436 e.preventDefault();
21439 this.setValue(this.formatDate(this.date));
21453 onClick: function(e)
21455 e.stopPropagation();
21456 e.preventDefault();
21458 var target = e.getTarget();
21460 if(target.nodeName.toLowerCase() === 'i'){
21461 target = Roo.get(target).dom.parentNode;
21464 var nodeName = target.nodeName;
21465 var className = target.className;
21466 var html = target.innerHTML;
21467 //Roo.log(nodeName);
21469 switch(nodeName.toLowerCase()) {
21471 switch(className) {
21477 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
21478 switch(this.viewMode){
21480 this.viewDate = this.moveMonth(this.viewDate, dir);
21484 this.viewDate = this.moveYear(this.viewDate, dir);
21490 var date = new Date();
21491 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
21493 this.setValue(this.formatDate(this.date));
21500 if (className.indexOf('disabled') < 0) {
21501 this.viewDate.setUTCDate(1);
21502 if (className.indexOf('month') > -1) {
21503 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
21505 var year = parseInt(html, 10) || 0;
21506 this.viewDate.setUTCFullYear(year);
21510 if(this.singleMode){
21511 this.setValue(this.formatDate(this.viewDate));
21522 //Roo.log(className);
21523 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
21524 var day = parseInt(html, 10) || 1;
21525 var year = this.viewDate.getUTCFullYear(),
21526 month = this.viewDate.getUTCMonth();
21528 if (className.indexOf('old') > -1) {
21535 } else if (className.indexOf('new') > -1) {
21543 //Roo.log([year,month,day]);
21544 this.date = this.UTCDate(year, month, day,0,0,0,0);
21545 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
21547 //Roo.log(this.formatDate(this.date));
21548 this.setValue(this.formatDate(this.date));
21555 setStartDate: function(startDate)
21557 this.startDate = startDate || -Infinity;
21558 if (this.startDate !== -Infinity) {
21559 this.startDate = this.parseDate(this.startDate);
21562 this.updateNavArrows();
21565 setEndDate: function(endDate)
21567 this.endDate = endDate || Infinity;
21568 if (this.endDate !== Infinity) {
21569 this.endDate = this.parseDate(this.endDate);
21572 this.updateNavArrows();
21575 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
21577 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
21578 if (typeof(this.daysOfWeekDisabled) !== 'object') {
21579 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
21581 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
21582 return parseInt(d, 10);
21585 this.updateNavArrows();
21588 updateNavArrows: function()
21590 if(this.singleMode){
21594 var d = new Date(this.viewDate),
21595 year = d.getUTCFullYear(),
21596 month = d.getUTCMonth();
21598 Roo.each(this.picker().select('.prev', true).elements, function(v){
21600 switch (this.viewMode) {
21603 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
21609 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
21616 Roo.each(this.picker().select('.next', true).elements, function(v){
21618 switch (this.viewMode) {
21621 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
21627 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
21635 moveMonth: function(date, dir)
21640 var new_date = new Date(date.valueOf()),
21641 day = new_date.getUTCDate(),
21642 month = new_date.getUTCMonth(),
21643 mag = Math.abs(dir),
21645 dir = dir > 0 ? 1 : -1;
21648 // If going back one month, make sure month is not current month
21649 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
21651 return new_date.getUTCMonth() == month;
21653 // If going forward one month, make sure month is as expected
21654 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
21656 return new_date.getUTCMonth() != new_month;
21658 new_month = month + dir;
21659 new_date.setUTCMonth(new_month);
21660 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
21661 if (new_month < 0 || new_month > 11) {
21662 new_month = (new_month + 12) % 12;
21665 // For magnitudes >1, move one month at a time...
21666 for (var i=0; i<mag; i++) {
21667 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
21668 new_date = this.moveMonth(new_date, dir);
21670 // ...then reset the day, keeping it in the new month
21671 new_month = new_date.getUTCMonth();
21672 new_date.setUTCDate(day);
21674 return new_month != new_date.getUTCMonth();
21677 // Common date-resetting loop -- if date is beyond end of month, make it
21680 new_date.setUTCDate(--day);
21681 new_date.setUTCMonth(new_month);
21686 moveYear: function(date, dir)
21688 return this.moveMonth(date, dir*12);
21691 dateWithinRange: function(date)
21693 return date >= this.startDate && date <= this.endDate;
21699 this.picker().remove();
21702 validateValue : function(value)
21704 if(this.getVisibilityEl().hasClass('hidden')){
21708 if(value.length < 1) {
21709 if(this.allowBlank){
21715 if(value.length < this.minLength){
21718 if(value.length > this.maxLength){
21722 var vt = Roo.form.VTypes;
21723 if(!vt[this.vtype](value, this)){
21727 if(typeof this.validator == "function"){
21728 var msg = this.validator(value);
21734 if(this.regex && !this.regex.test(value)){
21738 if(typeof(this.parseDate(value)) == 'undefined'){
21742 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
21746 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
21756 this.date = this.viewDate = '';
21758 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
21763 Roo.apply(Roo.bootstrap.DateField, {
21774 html: '<i class="fa fa-arrow-left"/>'
21784 html: '<i class="fa fa-arrow-right"/>'
21826 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
21827 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
21828 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
21829 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
21830 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
21843 navFnc: 'FullYear',
21848 navFnc: 'FullYear',
21853 Roo.apply(Roo.bootstrap.DateField, {
21857 cls: 'datepicker dropdown-menu roo-dynamic shadow',
21861 cls: 'datepicker-days',
21865 cls: 'table-condensed',
21867 Roo.bootstrap.DateField.head,
21871 Roo.bootstrap.DateField.footer
21878 cls: 'datepicker-months',
21882 cls: 'table-condensed',
21884 Roo.bootstrap.DateField.head,
21885 Roo.bootstrap.DateField.content,
21886 Roo.bootstrap.DateField.footer
21893 cls: 'datepicker-years',
21897 cls: 'table-condensed',
21899 Roo.bootstrap.DateField.head,
21900 Roo.bootstrap.DateField.content,
21901 Roo.bootstrap.DateField.footer
21920 * @class Roo.bootstrap.TimeField
21921 * @extends Roo.bootstrap.Input
21922 * Bootstrap DateField class
21926 * Create a new TimeField
21927 * @param {Object} config The config object
21930 Roo.bootstrap.TimeField = function(config){
21931 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
21935 * Fires when this field show.
21936 * @param {Roo.bootstrap.DateField} thisthis
21937 * @param {Mixed} date The date value
21942 * Fires when this field hide.
21943 * @param {Roo.bootstrap.DateField} this
21944 * @param {Mixed} date The date value
21949 * Fires when select a date.
21950 * @param {Roo.bootstrap.DateField} this
21951 * @param {Mixed} date The date value
21957 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
21960 * @cfg {String} format
21961 * The default time format string which can be overriden for localization support. The format must be
21962 * valid according to {@link Date#parseDate} (defaults to 'H:i').
21966 getAutoCreate : function()
21968 this.after = '<i class="fa far fa-clock"></i>';
21969 return Roo.bootstrap.TimeField.superclass.getAutoCreate.call(this);
21973 onRender: function(ct, position)
21976 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
21978 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.TimeField.template);
21980 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
21982 this.pop = this.picker().select('>.datepicker-time',true).first();
21983 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
21985 this.picker().on('mousedown', this.onMousedown, this);
21986 this.picker().on('click', this.onClick, this);
21988 this.picker().addClass('datepicker-dropdown');
21993 this.pop.select('.hours-up', true).first().on('click', this.onIncrementHours, this);
21994 this.pop.select('.hours-down', true).first().on('click', this.onDecrementHours, this);
21995 this.pop.select('.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
21996 this.pop.select('.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
21997 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
21998 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
22002 fireKey: function(e){
22003 if (!this.picker().isVisible()){
22004 if (e.keyCode == 27) { // allow escape to hide and re-show picker
22010 e.preventDefault();
22018 this.onTogglePeriod();
22021 this.onIncrementMinutes();
22024 this.onDecrementMinutes();
22033 onClick: function(e) {
22034 e.stopPropagation();
22035 e.preventDefault();
22038 picker : function()
22040 return this.pickerEl;
22043 fillTime: function()
22045 var time = this.pop.select('tbody', true).first();
22047 time.dom.innerHTML = '';
22062 cls: 'hours-up fa fas fa-chevron-up'
22082 cls: 'minutes-up fa fas fa-chevron-up'
22103 cls: 'timepicker-hour',
22118 cls: 'timepicker-minute',
22133 cls: 'btn btn-primary period',
22155 cls: 'hours-down fa fas fa-chevron-down'
22175 cls: 'minutes-down fa fas fa-chevron-down'
22193 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
22200 var hours = this.time.getHours();
22201 var minutes = this.time.getMinutes();
22214 hours = hours - 12;
22218 hours = '0' + hours;
22222 minutes = '0' + minutes;
22225 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
22226 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
22227 this.pop.select('button', true).first().dom.innerHTML = period;
22233 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
22235 var cls = ['bottom'];
22237 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
22244 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
22249 this.picker().addClass(cls.join('-'));
22253 Roo.each(cls, function(c){
22255 _this.picker().alignTo(_this.inputEl(), 't-b');
22257 //_this.picker().setTop(_this.inputEl().getHeight());
22261 _this.picker().setTop(0 - _this.picker().getHeight());
22266 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
22270 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
22277 onFocus : function()
22279 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
22283 onBlur : function()
22285 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
22291 this.picker().show();
22296 this.fireEvent('show', this, this.date);
22301 this.picker().hide();
22304 this.fireEvent('hide', this, this.date);
22307 setTime : function()
22310 this.setValue(this.time.format(this.format));
22312 this.fireEvent('select', this, this.date);
22317 onMousedown: function(e){
22318 e.stopPropagation();
22319 e.preventDefault();
22322 onIncrementHours: function()
22324 Roo.log('onIncrementHours');
22325 this.time = this.time.add(Date.HOUR, 1);
22330 onDecrementHours: function()
22332 Roo.log('onDecrementHours');
22333 this.time = this.time.add(Date.HOUR, -1);
22337 onIncrementMinutes: function()
22339 Roo.log('onIncrementMinutes');
22340 this.time = this.time.add(Date.MINUTE, 1);
22344 onDecrementMinutes: function()
22346 Roo.log('onDecrementMinutes');
22347 this.time = this.time.add(Date.MINUTE, -1);
22351 onTogglePeriod: function()
22353 Roo.log('onTogglePeriod');
22354 this.time = this.time.add(Date.HOUR, 12);
22362 Roo.apply(Roo.bootstrap.TimeField, {
22366 cls: 'datepicker dropdown-menu',
22370 cls: 'datepicker-time',
22374 cls: 'table-condensed',
22403 cls: 'btn btn-info ok',
22431 * @class Roo.bootstrap.MonthField
22432 * @extends Roo.bootstrap.Input
22433 * Bootstrap MonthField class
22435 * @cfg {String} language default en
22438 * Create a new MonthField
22439 * @param {Object} config The config object
22442 Roo.bootstrap.MonthField = function(config){
22443 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
22448 * Fires when this field show.
22449 * @param {Roo.bootstrap.MonthField} this
22450 * @param {Mixed} date The date value
22455 * Fires when this field hide.
22456 * @param {Roo.bootstrap.MonthField} this
22457 * @param {Mixed} date The date value
22462 * Fires when select a date.
22463 * @param {Roo.bootstrap.MonthField} this
22464 * @param {String} oldvalue The old value
22465 * @param {String} newvalue The new value
22471 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
22473 onRender: function(ct, position)
22476 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
22478 this.language = this.language || 'en';
22479 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
22480 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
22482 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
22483 this.isInline = false;
22484 this.isInput = true;
22485 this.component = this.el.select('.add-on', true).first() || false;
22486 this.component = (this.component && this.component.length === 0) ? false : this.component;
22487 this.hasInput = this.component && this.inputEL().length;
22489 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
22491 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
22493 this.picker().on('mousedown', this.onMousedown, this);
22494 this.picker().on('click', this.onClick, this);
22496 this.picker().addClass('datepicker-dropdown');
22498 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
22499 v.setStyle('width', '189px');
22506 if(this.isInline) {
22512 setValue: function(v, suppressEvent)
22514 var o = this.getValue();
22516 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
22520 if(suppressEvent !== true){
22521 this.fireEvent('select', this, o, v);
22526 getValue: function()
22531 onClick: function(e)
22533 e.stopPropagation();
22534 e.preventDefault();
22536 var target = e.getTarget();
22538 if(target.nodeName.toLowerCase() === 'i'){
22539 target = Roo.get(target).dom.parentNode;
22542 var nodeName = target.nodeName;
22543 var className = target.className;
22544 var html = target.innerHTML;
22546 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
22550 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
22552 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
22558 picker : function()
22560 return this.pickerEl;
22563 fillMonths: function()
22566 var months = this.picker().select('>.datepicker-months td', true).first();
22568 months.dom.innerHTML = '';
22574 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
22577 months.createChild(month);
22586 if(typeof(this.vIndex) == 'undefined' && this.value.length){
22587 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
22590 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
22591 e.removeClass('active');
22593 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
22594 e.addClass('active');
22601 if(this.isInline) {
22605 this.picker().removeClass(['bottom', 'top']);
22607 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
22609 * place to the top of element!
22613 this.picker().addClass('top');
22614 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
22619 this.picker().addClass('bottom');
22621 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
22624 onFocus : function()
22626 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
22630 onBlur : function()
22632 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
22634 var d = this.inputEl().getValue();
22643 this.picker().show();
22644 this.picker().select('>.datepicker-months', true).first().show();
22648 this.fireEvent('show', this, this.date);
22653 if(this.isInline) {
22656 this.picker().hide();
22657 this.fireEvent('hide', this, this.date);
22661 onMousedown: function(e)
22663 e.stopPropagation();
22664 e.preventDefault();
22669 Roo.bootstrap.MonthField.superclass.keyup.call(this);
22673 fireKey: function(e)
22675 if (!this.picker().isVisible()){
22676 if (e.keyCode == 27) {// allow escape to hide and re-show picker
22687 e.preventDefault();
22691 dir = e.keyCode == 37 ? -1 : 1;
22693 this.vIndex = this.vIndex + dir;
22695 if(this.vIndex < 0){
22699 if(this.vIndex > 11){
22703 if(isNaN(this.vIndex)){
22707 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
22713 dir = e.keyCode == 38 ? -1 : 1;
22715 this.vIndex = this.vIndex + dir * 4;
22717 if(this.vIndex < 0){
22721 if(this.vIndex > 11){
22725 if(isNaN(this.vIndex)){
22729 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
22734 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
22735 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
22739 e.preventDefault();
22742 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
22743 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
22759 this.picker().remove();
22764 Roo.apply(Roo.bootstrap.MonthField, {
22783 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
22784 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
22789 Roo.apply(Roo.bootstrap.MonthField, {
22793 cls: 'datepicker dropdown-menu roo-dynamic',
22797 cls: 'datepicker-months',
22801 cls: 'table-condensed',
22803 Roo.bootstrap.DateField.content
22823 * @class Roo.bootstrap.CheckBox
22824 * @extends Roo.bootstrap.Input
22825 * Bootstrap CheckBox class
22827 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
22828 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
22829 * @cfg {String} boxLabel The text that appears beside the checkbox
22830 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
22831 * @cfg {Boolean} checked initnal the element
22832 * @cfg {Boolean} inline inline the element (default false)
22833 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
22834 * @cfg {String} tooltip label tooltip
22837 * Create a new CheckBox
22838 * @param {Object} config The config object
22841 Roo.bootstrap.CheckBox = function(config){
22842 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
22847 * Fires when the element is checked or unchecked.
22848 * @param {Roo.bootstrap.CheckBox} this This input
22849 * @param {Boolean} checked The new checked value
22854 * Fires when the element is click.
22855 * @param {Roo.bootstrap.CheckBox} this This input
22862 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
22864 inputType: 'checkbox',
22873 // checkbox success does not make any sense really..
22878 getAutoCreate : function()
22880 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
22886 cfg.cls = 'form-group form-check ' + this.inputType; //input-group
22889 cfg.cls += ' ' + this.inputType + '-inline form-check-inline';
22895 type : this.inputType,
22896 value : this.inputValue,
22897 cls : 'roo-' + this.inputType, //'form-box',
22898 placeholder : this.placeholder || ''
22902 if(this.inputType != 'radio'){
22906 cls : 'roo-hidden-value',
22907 value : this.checked ? this.inputValue : this.valueOff
22912 if (this.weight) { // Validity check?
22913 cfg.cls += " " + this.inputType + "-" + this.weight;
22916 if (this.disabled) {
22917 input.disabled=true;
22921 input.checked = this.checked;
22926 input.name = this.name;
22928 if(this.inputType != 'radio'){
22929 hidden.name = this.name;
22930 input.name = '_hidden_' + this.name;
22935 input.cls += ' input-' + this.size;
22940 ['xs','sm','md','lg'].map(function(size){
22941 if (settings[size]) {
22942 cfg.cls += ' col-' + size + '-' + settings[size];
22946 var inputblock = input;
22948 if (this.before || this.after) {
22951 cls : 'input-group',
22956 inputblock.cn.push({
22958 cls : 'input-group-addon',
22963 inputblock.cn.push(input);
22965 if(this.inputType != 'radio'){
22966 inputblock.cn.push(hidden);
22970 inputblock.cn.push({
22972 cls : 'input-group-addon',
22978 var boxLabelCfg = false;
22984 //'for': id, // box label is handled by onclick - so no for...
22986 html: this.boxLabel
22989 boxLabelCfg.tooltip = this.tooltip;
22995 if (align ==='left' && this.fieldLabel.length) {
22996 // Roo.log("left and has label");
23001 cls : 'control-label',
23002 html : this.fieldLabel
23013 cfg.cn[1].cn.push(boxLabelCfg);
23016 if(this.labelWidth > 12){
23017 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
23020 if(this.labelWidth < 13 && this.labelmd == 0){
23021 this.labelmd = this.labelWidth;
23024 if(this.labellg > 0){
23025 cfg.cn[0].cls += ' col-lg-' + this.labellg;
23026 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
23029 if(this.labelmd > 0){
23030 cfg.cn[0].cls += ' col-md-' + this.labelmd;
23031 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
23034 if(this.labelsm > 0){
23035 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
23036 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
23039 if(this.labelxs > 0){
23040 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
23041 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
23044 } else if ( this.fieldLabel.length) {
23045 // Roo.log(" label");
23049 tag: this.boxLabel ? 'span' : 'label',
23051 cls: 'control-label box-input-label',
23052 //cls : 'input-group-addon',
23053 html : this.fieldLabel
23060 cfg.cn.push(boxLabelCfg);
23065 // Roo.log(" no label && no align");
23066 cfg.cn = [ inputblock ] ;
23068 cfg.cn.push(boxLabelCfg);
23076 if(this.inputType != 'radio'){
23077 cfg.cn.push(hidden);
23085 * return the real input element.
23087 inputEl: function ()
23089 return this.el.select('input.roo-' + this.inputType,true).first();
23091 hiddenEl: function ()
23093 return this.el.select('input.roo-hidden-value',true).first();
23096 labelEl: function()
23098 return this.el.select('label.control-label',true).first();
23100 /* depricated... */
23104 return this.labelEl();
23107 boxLabelEl: function()
23109 return this.el.select('label.box-label',true).first();
23112 initEvents : function()
23114 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
23116 this.inputEl().on('click', this.onClick, this);
23118 if (this.boxLabel) {
23119 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
23122 this.startValue = this.getValue();
23125 Roo.bootstrap.CheckBox.register(this);
23129 onClick : function(e)
23131 if(this.fireEvent('click', this, e) !== false){
23132 this.setChecked(!this.checked);
23137 setChecked : function(state,suppressEvent)
23139 this.startValue = this.getValue();
23141 if(this.inputType == 'radio'){
23143 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
23144 e.dom.checked = false;
23147 this.inputEl().dom.checked = true;
23149 this.inputEl().dom.value = this.inputValue;
23151 if(suppressEvent !== true){
23152 this.fireEvent('check', this, true);
23160 this.checked = state;
23162 this.inputEl().dom.checked = state;
23165 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
23167 if(suppressEvent !== true){
23168 this.fireEvent('check', this, state);
23174 getValue : function()
23176 if(this.inputType == 'radio'){
23177 return this.getGroupValue();
23180 return this.hiddenEl().dom.value;
23184 getGroupValue : function()
23186 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
23190 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
23193 setValue : function(v,suppressEvent)
23195 if(this.inputType == 'radio'){
23196 this.setGroupValue(v, suppressEvent);
23200 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
23205 setGroupValue : function(v, suppressEvent)
23207 this.startValue = this.getValue();
23209 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
23210 e.dom.checked = false;
23212 if(e.dom.value == v){
23213 e.dom.checked = true;
23217 if(suppressEvent !== true){
23218 this.fireEvent('check', this, true);
23226 validate : function()
23228 if(this.getVisibilityEl().hasClass('hidden')){
23234 (this.inputType == 'radio' && this.validateRadio()) ||
23235 (this.inputType == 'checkbox' && this.validateCheckbox())
23241 this.markInvalid();
23245 validateRadio : function()
23247 if(this.getVisibilityEl().hasClass('hidden')){
23251 if(this.allowBlank){
23257 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
23258 if(!e.dom.checked){
23270 validateCheckbox : function()
23273 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
23274 //return (this.getValue() == this.inputValue) ? true : false;
23277 var group = Roo.bootstrap.CheckBox.get(this.groupId);
23285 for(var i in group){
23286 if(group[i].el.isVisible(true)){
23294 for(var i in group){
23299 r = (group[i].getValue() == group[i].inputValue) ? true : false;
23306 * Mark this field as valid
23308 markValid : function()
23312 this.fireEvent('valid', this);
23314 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
23317 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
23324 if(this.inputType == 'radio'){
23325 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
23326 var fg = e.findParent('.form-group', false, true);
23327 if (Roo.bootstrap.version == 3) {
23328 fg.removeClass([_this.invalidClass, _this.validClass]);
23329 fg.addClass(_this.validClass);
23331 fg.removeClass(['is-valid', 'is-invalid']);
23332 fg.addClass('is-valid');
23340 var fg = this.el.findParent('.form-group', false, true);
23341 if (Roo.bootstrap.version == 3) {
23342 fg.removeClass([this.invalidClass, this.validClass]);
23343 fg.addClass(this.validClass);
23345 fg.removeClass(['is-valid', 'is-invalid']);
23346 fg.addClass('is-valid');
23351 var group = Roo.bootstrap.CheckBox.get(this.groupId);
23357 for(var i in group){
23358 var fg = group[i].el.findParent('.form-group', false, true);
23359 if (Roo.bootstrap.version == 3) {
23360 fg.removeClass([this.invalidClass, this.validClass]);
23361 fg.addClass(this.validClass);
23363 fg.removeClass(['is-valid', 'is-invalid']);
23364 fg.addClass('is-valid');
23370 * Mark this field as invalid
23371 * @param {String} msg The validation message
23373 markInvalid : function(msg)
23375 if(this.allowBlank){
23381 this.fireEvent('invalid', this, msg);
23383 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
23386 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
23390 label.markInvalid();
23393 if(this.inputType == 'radio'){
23395 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
23396 var fg = e.findParent('.form-group', false, true);
23397 if (Roo.bootstrap.version == 3) {
23398 fg.removeClass([_this.invalidClass, _this.validClass]);
23399 fg.addClass(_this.invalidClass);
23401 fg.removeClass(['is-invalid', 'is-valid']);
23402 fg.addClass('is-invalid');
23410 var fg = this.el.findParent('.form-group', false, true);
23411 if (Roo.bootstrap.version == 3) {
23412 fg.removeClass([_this.invalidClass, _this.validClass]);
23413 fg.addClass(_this.invalidClass);
23415 fg.removeClass(['is-invalid', 'is-valid']);
23416 fg.addClass('is-invalid');
23421 var group = Roo.bootstrap.CheckBox.get(this.groupId);
23427 for(var i in group){
23428 var fg = group[i].el.findParent('.form-group', false, true);
23429 if (Roo.bootstrap.version == 3) {
23430 fg.removeClass([_this.invalidClass, _this.validClass]);
23431 fg.addClass(_this.invalidClass);
23433 fg.removeClass(['is-invalid', 'is-valid']);
23434 fg.addClass('is-invalid');
23440 clearInvalid : function()
23442 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
23444 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
23446 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
23448 if (label && label.iconEl) {
23449 label.iconEl.removeClass([ label.validClass, label.invalidClass ]);
23450 label.iconEl.removeClass(['is-invalid', 'is-valid']);
23454 disable : function()
23456 if(this.inputType != 'radio'){
23457 Roo.bootstrap.CheckBox.superclass.disable.call(this);
23464 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
23465 _this.getActionEl().addClass(this.disabledClass);
23466 e.dom.disabled = true;
23470 this.disabled = true;
23471 this.fireEvent("disable", this);
23475 enable : function()
23477 if(this.inputType != 'radio'){
23478 Roo.bootstrap.CheckBox.superclass.enable.call(this);
23485 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
23486 _this.getActionEl().removeClass(this.disabledClass);
23487 e.dom.disabled = false;
23491 this.disabled = false;
23492 this.fireEvent("enable", this);
23496 setBoxLabel : function(v)
23501 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
23507 Roo.apply(Roo.bootstrap.CheckBox, {
23512 * register a CheckBox Group
23513 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
23515 register : function(checkbox)
23517 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
23518 this.groups[checkbox.groupId] = {};
23521 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
23525 this.groups[checkbox.groupId][checkbox.name] = checkbox;
23529 * fetch a CheckBox Group based on the group ID
23530 * @param {string} the group ID
23531 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
23533 get: function(groupId) {
23534 if (typeof(this.groups[groupId]) == 'undefined') {
23538 return this.groups[groupId] ;
23551 * @class Roo.bootstrap.Radio
23552 * @extends Roo.bootstrap.Component
23553 * Bootstrap Radio class
23554 * @cfg {String} boxLabel - the label associated
23555 * @cfg {String} value - the value of radio
23558 * Create a new Radio
23559 * @param {Object} config The config object
23561 Roo.bootstrap.Radio = function(config){
23562 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
23566 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
23572 getAutoCreate : function()
23576 cls : 'form-group radio',
23581 html : this.boxLabel
23589 initEvents : function()
23591 this.parent().register(this);
23593 this.el.on('click', this.onClick, this);
23597 onClick : function(e)
23599 if(this.parent().fireEvent('click', this.parent(), this, e) !== false){
23600 this.setChecked(true);
23604 setChecked : function(state, suppressEvent)
23606 this.parent().setValue(this.value, suppressEvent);
23610 setBoxLabel : function(v)
23615 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
23630 * @class Roo.bootstrap.SecurePass
23631 * @extends Roo.bootstrap.Input
23632 * Bootstrap SecurePass class
23636 * Create a new SecurePass
23637 * @param {Object} config The config object
23640 Roo.bootstrap.SecurePass = function (config) {
23641 // these go here, so the translation tool can replace them..
23643 PwdEmpty: "Please type a password, and then retype it to confirm.",
23644 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
23645 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
23646 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
23647 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
23648 FNInPwd: "Your password can't contain your first name. Please type a different password.",
23649 LNInPwd: "Your password can't contain your last name. Please type a different password.",
23650 TooWeak: "Your password is Too Weak."
23652 this.meterLabel = "Password strength:";
23653 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
23654 this.meterClass = [
23655 "roo-password-meter-tooweak",
23656 "roo-password-meter-weak",
23657 "roo-password-meter-medium",
23658 "roo-password-meter-strong",
23659 "roo-password-meter-grey"
23664 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
23667 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
23669 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
23671 * PwdEmpty: "Please type a password, and then retype it to confirm.",
23672 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
23673 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
23674 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
23675 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
23676 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
23677 * LNInPwd: "Your password can't contain your last name. Please type a different password."
23687 * @cfg {String/Object} Label for the strength meter (defaults to
23688 * 'Password strength:')
23693 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
23694 * ['Weak', 'Medium', 'Strong'])
23697 pwdStrengths: false,
23710 initEvents: function ()
23712 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
23714 if (this.el.is('input[type=password]') && Roo.isSafari) {
23715 this.el.on('keydown', this.SafariOnKeyDown, this);
23718 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
23721 onRender: function (ct, position)
23723 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
23724 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
23725 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
23727 this.trigger.createChild({
23732 cls: 'roo-password-meter-grey col-xs-12',
23735 //width: this.meterWidth + 'px'
23739 cls: 'roo-password-meter-text'
23745 if (this.hideTrigger) {
23746 this.trigger.setDisplayed(false);
23748 this.setSize(this.width || '', this.height || '');
23751 onDestroy: function ()
23753 if (this.trigger) {
23754 this.trigger.removeAllListeners();
23755 this.trigger.remove();
23758 this.wrap.remove();
23760 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
23763 checkStrength: function ()
23765 var pwd = this.inputEl().getValue();
23766 if (pwd == this._lastPwd) {
23771 if (this.ClientSideStrongPassword(pwd)) {
23773 } else if (this.ClientSideMediumPassword(pwd)) {
23775 } else if (this.ClientSideWeakPassword(pwd)) {
23781 Roo.log('strength1: ' + strength);
23783 //var pm = this.trigger.child('div/div/div').dom;
23784 var pm = this.trigger.child('div/div');
23785 pm.removeClass(this.meterClass);
23786 pm.addClass(this.meterClass[strength]);
23789 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
23791 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
23793 this._lastPwd = pwd;
23797 Roo.bootstrap.SecurePass.superclass.reset.call(this);
23799 this._lastPwd = '';
23801 var pm = this.trigger.child('div/div');
23802 pm.removeClass(this.meterClass);
23803 pm.addClass('roo-password-meter-grey');
23806 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
23809 this.inputEl().dom.type='password';
23812 validateValue: function (value)
23814 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
23817 if (value.length == 0) {
23818 if (this.allowBlank) {
23819 this.clearInvalid();
23823 this.markInvalid(this.errors.PwdEmpty);
23824 this.errorMsg = this.errors.PwdEmpty;
23832 if (!value.match(/[\x21-\x7e]+/)) {
23833 this.markInvalid(this.errors.PwdBadChar);
23834 this.errorMsg = this.errors.PwdBadChar;
23837 if (value.length < 6) {
23838 this.markInvalid(this.errors.PwdShort);
23839 this.errorMsg = this.errors.PwdShort;
23842 if (value.length > 16) {
23843 this.markInvalid(this.errors.PwdLong);
23844 this.errorMsg = this.errors.PwdLong;
23848 if (this.ClientSideStrongPassword(value)) {
23850 } else if (this.ClientSideMediumPassword(value)) {
23852 } else if (this.ClientSideWeakPassword(value)) {
23859 if (strength < 2) {
23860 //this.markInvalid(this.errors.TooWeak);
23861 this.errorMsg = this.errors.TooWeak;
23866 console.log('strength2: ' + strength);
23868 //var pm = this.trigger.child('div/div/div').dom;
23870 var pm = this.trigger.child('div/div');
23871 pm.removeClass(this.meterClass);
23872 pm.addClass(this.meterClass[strength]);
23874 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
23876 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
23878 this.errorMsg = '';
23882 CharacterSetChecks: function (type)
23885 this.fResult = false;
23888 isctype: function (character, type)
23891 case this.kCapitalLetter:
23892 if (character >= 'A' && character <= 'Z') {
23897 case this.kSmallLetter:
23898 if (character >= 'a' && character <= 'z') {
23904 if (character >= '0' && character <= '9') {
23909 case this.kPunctuation:
23910 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
23921 IsLongEnough: function (pwd, size)
23923 return !(pwd == null || isNaN(size) || pwd.length < size);
23926 SpansEnoughCharacterSets: function (word, nb)
23928 if (!this.IsLongEnough(word, nb))
23933 var characterSetChecks = new Array(
23934 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
23935 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
23938 for (var index = 0; index < word.length; ++index) {
23939 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
23940 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
23941 characterSetChecks[nCharSet].fResult = true;
23948 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
23949 if (characterSetChecks[nCharSet].fResult) {
23954 if (nCharSets < nb) {
23960 ClientSideStrongPassword: function (pwd)
23962 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
23965 ClientSideMediumPassword: function (pwd)
23967 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
23970 ClientSideWeakPassword: function (pwd)
23972 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
23975 })//<script type="text/javascript">
23978 * Based Ext JS Library 1.1.1
23979 * Copyright(c) 2006-2007, Ext JS, LLC.
23985 * @class Roo.HtmlEditorCore
23986 * @extends Roo.Component
23987 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
23989 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
23992 Roo.HtmlEditorCore = function(config){
23995 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
24000 * @event initialize
24001 * Fires when the editor is fully initialized (including the iframe)
24002 * @param {Roo.HtmlEditorCore} this
24007 * Fires when the editor is first receives the focus. Any insertion must wait
24008 * until after this event.
24009 * @param {Roo.HtmlEditorCore} this
24013 * @event beforesync
24014 * Fires before the textarea is updated with content from the editor iframe. Return false
24015 * to cancel the sync.
24016 * @param {Roo.HtmlEditorCore} this
24017 * @param {String} html
24021 * @event beforepush
24022 * Fires before the iframe editor is updated with content from the textarea. Return false
24023 * to cancel the push.
24024 * @param {Roo.HtmlEditorCore} this
24025 * @param {String} html
24030 * Fires when the textarea is updated with content from the editor iframe.
24031 * @param {Roo.HtmlEditorCore} this
24032 * @param {String} html
24037 * Fires when the iframe editor is updated with content from the textarea.
24038 * @param {Roo.HtmlEditorCore} this
24039 * @param {String} html
24044 * @event editorevent
24045 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
24046 * @param {Roo.HtmlEditorCore} this
24052 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
24054 // defaults : white / black...
24055 this.applyBlacklists();
24062 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
24066 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
24072 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
24077 * @cfg {Number} height (in pixels)
24081 * @cfg {Number} width (in pixels)
24086 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
24089 stylesheets: false,
24094 // private properties
24095 validationEvent : false,
24097 initialized : false,
24099 sourceEditMode : false,
24100 onFocus : Roo.emptyFn,
24102 hideMode:'offsets',
24106 // blacklist + whitelisted elements..
24113 * Protected method that will not generally be called directly. It
24114 * is called when the editor initializes the iframe with HTML contents. Override this method if you
24115 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
24117 getDocMarkup : function(){
24121 // inherit styels from page...??
24122 if (this.stylesheets === false) {
24124 Roo.get(document.head).select('style').each(function(node) {
24125 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
24128 Roo.get(document.head).select('link').each(function(node) {
24129 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
24132 } else if (!this.stylesheets.length) {
24134 st = '<style type="text/css">' +
24135 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
24138 for (var i in this.stylesheets) {
24139 st += '<link rel="stylesheet" href="' + this.stylesheets[i] +'" type="text/css">';
24144 st += '<style type="text/css">' +
24145 'IMG { cursor: pointer } ' +
24148 var cls = 'roo-htmleditor-body';
24150 if(this.bodyCls.length){
24151 cls += ' ' + this.bodyCls;
24154 return '<html><head>' + st +
24155 //<style type="text/css">' +
24156 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
24158 ' </head><body contenteditable="true" data-enable-grammerly="true" class="' + cls + '"></body></html>';
24162 onRender : function(ct, position)
24165 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
24166 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
24169 this.el.dom.style.border = '0 none';
24170 this.el.dom.setAttribute('tabIndex', -1);
24171 this.el.addClass('x-hidden hide');
24175 if(Roo.isIE){ // fix IE 1px bogus margin
24176 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
24180 this.frameId = Roo.id();
24184 var iframe = this.owner.wrap.createChild({
24186 cls: 'form-control', // bootstrap..
24188 name: this.frameId,
24189 frameBorder : 'no',
24190 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
24195 this.iframe = iframe.dom;
24197 this.assignDocWin();
24199 this.doc.designMode = 'on';
24202 this.doc.write(this.getDocMarkup());
24206 var task = { // must defer to wait for browser to be ready
24208 //console.log("run task?" + this.doc.readyState);
24209 this.assignDocWin();
24210 if(this.doc.body || this.doc.readyState == 'complete'){
24212 this.doc.designMode="on";
24216 Roo.TaskMgr.stop(task);
24217 this.initEditor.defer(10, this);
24224 Roo.TaskMgr.start(task);
24229 onResize : function(w, h)
24231 Roo.log('resize: ' +w + ',' + h );
24232 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
24236 if(typeof w == 'number'){
24238 this.iframe.style.width = w + 'px';
24240 if(typeof h == 'number'){
24242 this.iframe.style.height = h + 'px';
24244 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
24251 * Toggles the editor between standard and source edit mode.
24252 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
24254 toggleSourceEdit : function(sourceEditMode){
24256 this.sourceEditMode = sourceEditMode === true;
24258 if(this.sourceEditMode){
24260 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
24263 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
24264 //this.iframe.className = '';
24267 //this.setSize(this.owner.wrap.getSize());
24268 //this.fireEvent('editmodechange', this, this.sourceEditMode);
24275 * Protected method that will not generally be called directly. If you need/want
24276 * custom HTML cleanup, this is the method you should override.
24277 * @param {String} html The HTML to be cleaned
24278 * return {String} The cleaned HTML
24280 cleanHtml : function(html){
24281 html = String(html);
24282 if(html.length > 5){
24283 if(Roo.isSafari){ // strip safari nonsense
24284 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
24287 if(html == ' '){
24294 * HTML Editor -> Textarea
24295 * Protected method that will not generally be called directly. Syncs the contents
24296 * of the editor iframe with the textarea.
24298 syncValue : function(){
24299 if(this.initialized){
24300 var bd = (this.doc.body || this.doc.documentElement);
24301 //this.cleanUpPaste(); -- this is done else where and causes havoc..
24302 var html = bd.innerHTML;
24304 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
24305 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
24307 html = '<div style="'+m[0]+'">' + html + '</div>';
24310 html = this.cleanHtml(html);
24311 // fix up the special chars.. normaly like back quotes in word...
24312 // however we do not want to do this with chinese..
24313 html = html.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[\u0080-\uFFFF]/g, function(match) {
24315 var cc = match.charCodeAt();
24317 // Get the character value, handling surrogate pairs
24318 if (match.length == 2) {
24319 // It's a surrogate pair, calculate the Unicode code point
24320 var high = match.charCodeAt(0) - 0xD800;
24321 var low = match.charCodeAt(1) - 0xDC00;
24322 cc = (high * 0x400) + low + 0x10000;
24324 (cc >= 0x4E00 && cc < 0xA000 ) ||
24325 (cc >= 0x3400 && cc < 0x4E00 ) ||
24326 (cc >= 0xf900 && cc < 0xfb00 )
24331 // No, use a numeric entity. Here we brazenly (and possibly mistakenly)
24332 return "&#" + cc + ";";
24339 if(this.owner.fireEvent('beforesync', this, html) !== false){
24340 this.el.dom.value = html;
24341 this.owner.fireEvent('sync', this, html);
24347 * Protected method that will not generally be called directly. Pushes the value of the textarea
24348 * into the iframe editor.
24350 pushValue : function(){
24351 if(this.initialized){
24352 var v = this.el.dom.value.trim();
24354 // if(v.length < 1){
24358 if(this.owner.fireEvent('beforepush', this, v) !== false){
24359 var d = (this.doc.body || this.doc.documentElement);
24361 this.cleanUpPaste();
24362 this.el.dom.value = d.innerHTML;
24363 this.owner.fireEvent('push', this, v);
24369 deferFocus : function(){
24370 this.focus.defer(10, this);
24374 focus : function(){
24375 if(this.win && !this.sourceEditMode){
24382 assignDocWin: function()
24384 var iframe = this.iframe;
24387 this.doc = iframe.contentWindow.document;
24388 this.win = iframe.contentWindow;
24390 // if (!Roo.get(this.frameId)) {
24393 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
24394 // this.win = Roo.get(this.frameId).dom.contentWindow;
24396 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
24400 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
24401 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
24406 initEditor : function(){
24407 //console.log("INIT EDITOR");
24408 this.assignDocWin();
24412 this.doc.designMode="on";
24414 this.doc.write(this.getDocMarkup());
24417 var dbody = (this.doc.body || this.doc.documentElement);
24418 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
24419 // this copies styles from the containing element into thsi one..
24420 // not sure why we need all of this..
24421 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
24423 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
24424 //ss['background-attachment'] = 'fixed'; // w3c
24425 dbody.bgProperties = 'fixed'; // ie
24426 //Roo.DomHelper.applyStyles(dbody, ss);
24427 Roo.EventManager.on(this.doc, {
24428 //'mousedown': this.onEditorEvent,
24429 'mouseup': this.onEditorEvent,
24430 'dblclick': this.onEditorEvent,
24431 'click': this.onEditorEvent,
24432 'keyup': this.onEditorEvent,
24437 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
24439 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
24440 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
24442 this.initialized = true;
24444 this.owner.fireEvent('initialize', this);
24449 onDestroy : function(){
24455 //for (var i =0; i < this.toolbars.length;i++) {
24456 // // fixme - ask toolbars for heights?
24457 // this.toolbars[i].onDestroy();
24460 //this.wrap.dom.innerHTML = '';
24461 //this.wrap.remove();
24466 onFirstFocus : function(){
24468 this.assignDocWin();
24471 this.activated = true;
24474 if(Roo.isGecko){ // prevent silly gecko errors
24476 var s = this.win.getSelection();
24477 if(!s.focusNode || s.focusNode.nodeType != 3){
24478 var r = s.getRangeAt(0);
24479 r.selectNodeContents((this.doc.body || this.doc.documentElement));
24484 this.execCmd('useCSS', true);
24485 this.execCmd('styleWithCSS', false);
24488 this.owner.fireEvent('activate', this);
24492 adjustFont: function(btn){
24493 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
24494 //if(Roo.isSafari){ // safari
24497 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
24498 if(Roo.isSafari){ // safari
24499 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
24500 v = (v < 10) ? 10 : v;
24501 v = (v > 48) ? 48 : v;
24502 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
24507 v = Math.max(1, v+adjust);
24509 this.execCmd('FontSize', v );
24512 onEditorEvent : function(e)
24514 this.owner.fireEvent('editorevent', this, e);
24515 // this.updateToolbar();
24516 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
24519 insertTag : function(tg)
24521 // could be a bit smarter... -> wrap the current selected tRoo..
24522 if (tg.toLowerCase() == 'span' ||
24523 tg.toLowerCase() == 'code' ||
24524 tg.toLowerCase() == 'sup' ||
24525 tg.toLowerCase() == 'sub'
24528 range = this.createRange(this.getSelection());
24529 var wrappingNode = this.doc.createElement(tg.toLowerCase());
24530 wrappingNode.appendChild(range.extractContents());
24531 range.insertNode(wrappingNode);
24538 this.execCmd("formatblock", tg);
24542 insertText : function(txt)
24546 var range = this.createRange();
24547 range.deleteContents();
24548 //alert(Sender.getAttribute('label'));
24550 range.insertNode(this.doc.createTextNode(txt));
24556 * Executes a Midas editor command on the editor document and performs necessary focus and
24557 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
24558 * @param {String} cmd The Midas command
24559 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
24561 relayCmd : function(cmd, value){
24563 this.execCmd(cmd, value);
24564 this.owner.fireEvent('editorevent', this);
24565 //this.updateToolbar();
24566 this.owner.deferFocus();
24570 * Executes a Midas editor command directly on the editor document.
24571 * For visual commands, you should use {@link #relayCmd} instead.
24572 * <b>This should only be called after the editor is initialized.</b>
24573 * @param {String} cmd The Midas command
24574 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
24576 execCmd : function(cmd, value){
24577 this.doc.execCommand(cmd, false, value === undefined ? null : value);
24584 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
24586 * @param {String} text | dom node..
24588 insertAtCursor : function(text)
24591 if(!this.activated){
24597 var r = this.doc.selection.createRange();
24608 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
24612 // from jquery ui (MIT licenced)
24614 var win = this.win;
24616 if (win.getSelection && win.getSelection().getRangeAt) {
24617 range = win.getSelection().getRangeAt(0);
24618 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
24619 range.insertNode(node);
24620 } else if (win.document.selection && win.document.selection.createRange) {
24621 // no firefox support
24622 var txt = typeof(text) == 'string' ? text : text.outerHTML;
24623 win.document.selection.createRange().pasteHTML(txt);
24625 // no firefox support
24626 var txt = typeof(text) == 'string' ? text : text.outerHTML;
24627 this.execCmd('InsertHTML', txt);
24636 mozKeyPress : function(e){
24638 var c = e.getCharCode(), cmd;
24641 c = String.fromCharCode(c).toLowerCase();
24655 this.cleanUpPaste.defer(100, this);
24663 e.preventDefault();
24671 fixKeys : function(){ // load time branching for fastest keydown performance
24673 return function(e){
24674 var k = e.getKey(), r;
24677 r = this.doc.selection.createRange();
24680 r.pasteHTML('    ');
24687 r = this.doc.selection.createRange();
24689 var target = r.parentElement();
24690 if(!target || target.tagName.toLowerCase() != 'li'){
24692 r.pasteHTML('<br />');
24698 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
24699 this.cleanUpPaste.defer(100, this);
24705 }else if(Roo.isOpera){
24706 return function(e){
24707 var k = e.getKey();
24711 this.execCmd('InsertHTML','    ');
24714 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
24715 this.cleanUpPaste.defer(100, this);
24720 }else if(Roo.isSafari){
24721 return function(e){
24722 var k = e.getKey();
24726 this.execCmd('InsertText','\t');
24730 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
24731 this.cleanUpPaste.defer(100, this);
24739 getAllAncestors: function()
24741 var p = this.getSelectedNode();
24744 a.push(p); // push blank onto stack..
24745 p = this.getParentElement();
24749 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
24753 a.push(this.doc.body);
24757 lastSelNode : false,
24760 getSelection : function()
24762 this.assignDocWin();
24763 return Roo.isIE ? this.doc.selection : this.win.getSelection();
24766 getSelectedNode: function()
24768 // this may only work on Gecko!!!
24770 // should we cache this!!!!
24775 var range = this.createRange(this.getSelection()).cloneRange();
24778 var parent = range.parentElement();
24780 var testRange = range.duplicate();
24781 testRange.moveToElementText(parent);
24782 if (testRange.inRange(range)) {
24785 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
24788 parent = parent.parentElement;
24793 // is ancestor a text element.
24794 var ac = range.commonAncestorContainer;
24795 if (ac.nodeType == 3) {
24796 ac = ac.parentNode;
24799 var ar = ac.childNodes;
24802 var other_nodes = [];
24803 var has_other_nodes = false;
24804 for (var i=0;i<ar.length;i++) {
24805 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
24808 // fullly contained node.
24810 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
24815 // probably selected..
24816 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
24817 other_nodes.push(ar[i]);
24821 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
24826 has_other_nodes = true;
24828 if (!nodes.length && other_nodes.length) {
24829 nodes= other_nodes;
24831 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
24837 createRange: function(sel)
24839 // this has strange effects when using with
24840 // top toolbar - not sure if it's a great idea.
24841 //this.editor.contentWindow.focus();
24842 if (typeof sel != "undefined") {
24844 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
24846 return this.doc.createRange();
24849 return this.doc.createRange();
24852 getParentElement: function()
24855 this.assignDocWin();
24856 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
24858 var range = this.createRange(sel);
24861 var p = range.commonAncestorContainer;
24862 while (p.nodeType == 3) { // text node
24873 * Range intersection.. the hard stuff...
24877 * [ -- selected range --- ]
24881 * if end is before start or hits it. fail.
24882 * if start is after end or hits it fail.
24884 * if either hits (but other is outside. - then it's not
24890 // @see http://www.thismuchiknow.co.uk/?p=64.
24891 rangeIntersectsNode : function(range, node)
24893 var nodeRange = node.ownerDocument.createRange();
24895 nodeRange.selectNode(node);
24897 nodeRange.selectNodeContents(node);
24900 var rangeStartRange = range.cloneRange();
24901 rangeStartRange.collapse(true);
24903 var rangeEndRange = range.cloneRange();
24904 rangeEndRange.collapse(false);
24906 var nodeStartRange = nodeRange.cloneRange();
24907 nodeStartRange.collapse(true);
24909 var nodeEndRange = nodeRange.cloneRange();
24910 nodeEndRange.collapse(false);
24912 return rangeStartRange.compareBoundaryPoints(
24913 Range.START_TO_START, nodeEndRange) == -1 &&
24914 rangeEndRange.compareBoundaryPoints(
24915 Range.START_TO_START, nodeStartRange) == 1;
24919 rangeCompareNode : function(range, node)
24921 var nodeRange = node.ownerDocument.createRange();
24923 nodeRange.selectNode(node);
24925 nodeRange.selectNodeContents(node);
24929 range.collapse(true);
24931 nodeRange.collapse(true);
24933 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
24934 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
24936 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
24938 var nodeIsBefore = ss == 1;
24939 var nodeIsAfter = ee == -1;
24941 if (nodeIsBefore && nodeIsAfter) {
24944 if (!nodeIsBefore && nodeIsAfter) {
24945 return 1; //right trailed.
24948 if (nodeIsBefore && !nodeIsAfter) {
24949 return 2; // left trailed.
24955 // private? - in a new class?
24956 cleanUpPaste : function()
24958 // cleans up the whole document..
24959 Roo.log('cleanuppaste');
24961 this.cleanUpChildren(this.doc.body);
24962 var clean = this.cleanWordChars(this.doc.body.innerHTML);
24963 if (clean != this.doc.body.innerHTML) {
24964 this.doc.body.innerHTML = clean;
24969 cleanWordChars : function(input) {// change the chars to hex code
24970 var he = Roo.HtmlEditorCore;
24972 var output = input;
24973 Roo.each(he.swapCodes, function(sw) {
24974 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
24976 output = output.replace(swapper, sw[1]);
24983 cleanUpChildren : function (n)
24985 if (!n.childNodes.length) {
24988 for (var i = n.childNodes.length-1; i > -1 ; i--) {
24989 this.cleanUpChild(n.childNodes[i]);
24996 cleanUpChild : function (node)
24999 //console.log(node);
25000 if (node.nodeName == "#text") {
25001 // clean up silly Windows -- stuff?
25004 if (node.nodeName == "#comment") {
25005 node.parentNode.removeChild(node);
25006 // clean up silly Windows -- stuff?
25009 var lcname = node.tagName.toLowerCase();
25010 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
25011 // whitelist of tags..
25013 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
25015 node.parentNode.removeChild(node);
25020 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
25022 // spans with no attributes - just remove them..
25023 if ((!node.attributes || !node.attributes.length) && lcname == 'span') {
25024 remove_keep_children = true;
25027 // remove <a name=....> as rendering on yahoo mailer is borked with this.
25028 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
25030 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
25031 // remove_keep_children = true;
25034 if (remove_keep_children) {
25035 this.cleanUpChildren(node);
25036 // inserts everything just before this node...
25037 while (node.childNodes.length) {
25038 var cn = node.childNodes[0];
25039 node.removeChild(cn);
25040 node.parentNode.insertBefore(cn, node);
25042 node.parentNode.removeChild(node);
25046 if (!node.attributes || !node.attributes.length) {
25051 this.cleanUpChildren(node);
25055 function cleanAttr(n,v)
25058 if (v.match(/^\./) || v.match(/^\//)) {
25061 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/) || v.match(/^ftp:/)) {
25064 if (v.match(/^#/)) {
25067 if (v.match(/^\{/)) { // allow template editing.
25070 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
25071 node.removeAttribute(n);
25075 var cwhite = this.cwhite;
25076 var cblack = this.cblack;
25078 function cleanStyle(n,v)
25080 if (v.match(/expression/)) { //XSS?? should we even bother..
25081 node.removeAttribute(n);
25085 var parts = v.split(/;/);
25088 Roo.each(parts, function(p) {
25089 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
25093 var l = p.split(':').shift().replace(/\s+/g,'');
25094 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
25096 if ( cwhite.length && cblack.indexOf(l) > -1) {
25097 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
25098 //node.removeAttribute(n);
25102 // only allow 'c whitelisted system attributes'
25103 if ( cwhite.length && cwhite.indexOf(l) < 0) {
25104 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
25105 //node.removeAttribute(n);
25115 if (clean.length) {
25116 node.setAttribute(n, clean.join(';'));
25118 node.removeAttribute(n);
25124 for (var i = node.attributes.length-1; i > -1 ; i--) {
25125 var a = node.attributes[i];
25128 if (a.name.toLowerCase().substr(0,2)=='on') {
25129 node.removeAttribute(a.name);
25132 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
25133 node.removeAttribute(a.name);
25136 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
25137 cleanAttr(a.name,a.value); // fixme..
25140 if (a.name == 'style') {
25141 cleanStyle(a.name,a.value);
25144 /// clean up MS crap..
25145 // tecnically this should be a list of valid class'es..
25148 if (a.name == 'class') {
25149 if (a.value.match(/^Mso/)) {
25150 node.removeAttribute('class');
25153 if (a.value.match(/^body$/)) {
25154 node.removeAttribute('class');
25165 this.cleanUpChildren(node);
25171 * Clean up MS wordisms...
25173 cleanWord : function(node)
25176 this.cleanWord(this.doc.body);
25181 node.nodeName == 'SPAN' &&
25182 !node.hasAttributes() &&
25183 node.childNodes.length == 1 &&
25184 node.firstChild.nodeName == "#text"
25186 var textNode = node.firstChild;
25187 node.removeChild(textNode);
25188 if (node.getAttribute('lang') != 'zh-CN') { // do not space pad on chinese characters..
25189 node.parentNode.insertBefore(node.ownerDocument.createTextNode(" "), node);
25191 node.parentNode.insertBefore(textNode, node);
25192 if (node.getAttribute('lang') != 'zh-CN') { // do not space pad on chinese characters..
25193 node.parentNode.insertBefore(node.ownerDocument.createTextNode(" ") , node);
25195 node.parentNode.removeChild(node);
25198 if (node.nodeName == "#text") {
25199 // clean up silly Windows -- stuff?
25202 if (node.nodeName == "#comment") {
25203 node.parentNode.removeChild(node);
25204 // clean up silly Windows -- stuff?
25208 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
25209 node.parentNode.removeChild(node);
25212 //Roo.log(node.tagName);
25213 // remove - but keep children..
25214 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|v:|font)/)) {
25215 //Roo.log('-- removed');
25216 while (node.childNodes.length) {
25217 var cn = node.childNodes[0];
25218 node.removeChild(cn);
25219 node.parentNode.insertBefore(cn, node);
25220 // move node to parent - and clean it..
25221 this.cleanWord(cn);
25223 node.parentNode.removeChild(node);
25224 /// no need to iterate chidlren = it's got none..
25225 //this.iterateChildren(node, this.cleanWord);
25229 if (node.className.length) {
25231 var cn = node.className.split(/\W+/);
25233 Roo.each(cn, function(cls) {
25234 if (cls.match(/Mso[a-zA-Z]+/)) {
25239 node.className = cna.length ? cna.join(' ') : '';
25241 node.removeAttribute("class");
25245 if (node.hasAttribute("lang")) {
25246 node.removeAttribute("lang");
25249 if (node.hasAttribute("style")) {
25251 var styles = node.getAttribute("style").split(";");
25253 Roo.each(styles, function(s) {
25254 if (!s.match(/:/)) {
25257 var kv = s.split(":");
25258 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
25261 // what ever is left... we allow.
25264 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
25265 if (!nstyle.length) {
25266 node.removeAttribute('style');
25269 this.iterateChildren(node, this.cleanWord);
25275 * iterateChildren of a Node, calling fn each time, using this as the scole..
25276 * @param {DomNode} node node to iterate children of.
25277 * @param {Function} fn method of this class to call on each item.
25279 iterateChildren : function(node, fn)
25281 if (!node.childNodes.length) {
25284 for (var i = node.childNodes.length-1; i > -1 ; i--) {
25285 fn.call(this, node.childNodes[i])
25291 * cleanTableWidths.
25293 * Quite often pasting from word etc.. results in tables with column and widths.
25294 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
25297 cleanTableWidths : function(node)
25302 this.cleanTableWidths(this.doc.body);
25307 if (node.nodeName == "#text" || node.nodeName == "#comment") {
25310 Roo.log(node.tagName);
25311 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
25312 this.iterateChildren(node, this.cleanTableWidths);
25315 if (node.hasAttribute('width')) {
25316 node.removeAttribute('width');
25320 if (node.hasAttribute("style")) {
25323 var styles = node.getAttribute("style").split(";");
25325 Roo.each(styles, function(s) {
25326 if (!s.match(/:/)) {
25329 var kv = s.split(":");
25330 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
25333 // what ever is left... we allow.
25336 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
25337 if (!nstyle.length) {
25338 node.removeAttribute('style');
25342 this.iterateChildren(node, this.cleanTableWidths);
25350 domToHTML : function(currentElement, depth, nopadtext) {
25352 depth = depth || 0;
25353 nopadtext = nopadtext || false;
25355 if (!currentElement) {
25356 return this.domToHTML(this.doc.body);
25359 //Roo.log(currentElement);
25361 var allText = false;
25362 var nodeName = currentElement.nodeName;
25363 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
25365 if (nodeName == '#text') {
25367 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
25372 if (nodeName != 'BODY') {
25375 // Prints the node tagName, such as <A>, <IMG>, etc
25378 for(i = 0; i < currentElement.attributes.length;i++) {
25380 var aname = currentElement.attributes.item(i).name;
25381 if (!currentElement.attributes.item(i).value.length) {
25384 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
25387 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
25396 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
25399 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
25404 // Traverse the tree
25406 var currentElementChild = currentElement.childNodes.item(i);
25407 var allText = true;
25408 var innerHTML = '';
25410 while (currentElementChild) {
25411 // Formatting code (indent the tree so it looks nice on the screen)
25412 var nopad = nopadtext;
25413 if (lastnode == 'SPAN') {
25417 if (currentElementChild.nodeName == '#text') {
25418 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
25419 toadd = nopadtext ? toadd : toadd.trim();
25420 if (!nopad && toadd.length > 80) {
25421 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
25423 innerHTML += toadd;
25426 currentElementChild = currentElement.childNodes.item(i);
25432 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
25434 // Recursively traverse the tree structure of the child node
25435 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
25436 lastnode = currentElementChild.nodeName;
25438 currentElementChild=currentElement.childNodes.item(i);
25444 // The remaining code is mostly for formatting the tree
25445 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
25450 ret+= "</"+tagName+">";
25456 applyBlacklists : function()
25458 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
25459 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
25463 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
25464 if (b.indexOf(tag) > -1) {
25467 this.white.push(tag);
25471 Roo.each(w, function(tag) {
25472 if (b.indexOf(tag) > -1) {
25475 if (this.white.indexOf(tag) > -1) {
25478 this.white.push(tag);
25483 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
25484 if (w.indexOf(tag) > -1) {
25487 this.black.push(tag);
25491 Roo.each(b, function(tag) {
25492 if (w.indexOf(tag) > -1) {
25495 if (this.black.indexOf(tag) > -1) {
25498 this.black.push(tag);
25503 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
25504 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
25508 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
25509 if (b.indexOf(tag) > -1) {
25512 this.cwhite.push(tag);
25516 Roo.each(w, function(tag) {
25517 if (b.indexOf(tag) > -1) {
25520 if (this.cwhite.indexOf(tag) > -1) {
25523 this.cwhite.push(tag);
25528 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
25529 if (w.indexOf(tag) > -1) {
25532 this.cblack.push(tag);
25536 Roo.each(b, function(tag) {
25537 if (w.indexOf(tag) > -1) {
25540 if (this.cblack.indexOf(tag) > -1) {
25543 this.cblack.push(tag);
25548 setStylesheets : function(stylesheets)
25550 if(typeof(stylesheets) == 'string'){
25551 Roo.get(this.iframe.contentDocument.head).createChild({
25553 rel : 'stylesheet',
25562 Roo.each(stylesheets, function(s) {
25567 Roo.get(_this.iframe.contentDocument.head).createChild({
25569 rel : 'stylesheet',
25578 removeStylesheets : function()
25582 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
25587 setStyle : function(style)
25589 Roo.get(this.iframe.contentDocument.head).createChild({
25598 // hide stuff that is not compatible
25612 * @event specialkey
25616 * @cfg {String} fieldClass @hide
25619 * @cfg {String} focusClass @hide
25622 * @cfg {String} autoCreate @hide
25625 * @cfg {String} inputType @hide
25628 * @cfg {String} invalidClass @hide
25631 * @cfg {String} invalidText @hide
25634 * @cfg {String} msgFx @hide
25637 * @cfg {String} validateOnBlur @hide
25641 Roo.HtmlEditorCore.white = [
25642 'area', 'br', 'img', 'input', 'hr', 'wbr',
25644 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
25645 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
25646 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
25647 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
25648 'table', 'ul', 'xmp',
25650 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
25653 'dir', 'menu', 'ol', 'ul', 'dl',
25659 Roo.HtmlEditorCore.black = [
25660 // 'embed', 'object', // enable - backend responsiblity to clean thiese
25662 'base', 'basefont', 'bgsound', 'blink', 'body',
25663 'frame', 'frameset', 'head', 'html', 'ilayer',
25664 'iframe', 'layer', 'link', 'meta', 'object',
25665 'script', 'style' ,'title', 'xml' // clean later..
25667 Roo.HtmlEditorCore.clean = [
25668 'script', 'style', 'title', 'xml'
25670 Roo.HtmlEditorCore.remove = [
25675 Roo.HtmlEditorCore.ablack = [
25679 Roo.HtmlEditorCore.aclean = [
25680 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
25684 Roo.HtmlEditorCore.pwhite= [
25685 'http', 'https', 'mailto'
25688 // white listed style attributes.
25689 Roo.HtmlEditorCore.cwhite= [
25690 // 'text-align', /// default is to allow most things..
25696 // black listed style attributes.
25697 Roo.HtmlEditorCore.cblack= [
25698 // 'font-size' -- this can be set by the project
25702 Roo.HtmlEditorCore.swapCodes =[
25721 * @class Roo.bootstrap.HtmlEditor
25722 * @extends Roo.bootstrap.TextArea
25723 * Bootstrap HtmlEditor class
25726 * Create a new HtmlEditor
25727 * @param {Object} config The config object
25730 Roo.bootstrap.HtmlEditor = function(config){
25731 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
25732 if (!this.toolbars) {
25733 this.toolbars = [];
25736 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
25739 * @event initialize
25740 * Fires when the editor is fully initialized (including the iframe)
25741 * @param {HtmlEditor} this
25746 * Fires when the editor is first receives the focus. Any insertion must wait
25747 * until after this event.
25748 * @param {HtmlEditor} this
25752 * @event beforesync
25753 * Fires before the textarea is updated with content from the editor iframe. Return false
25754 * to cancel the sync.
25755 * @param {HtmlEditor} this
25756 * @param {String} html
25760 * @event beforepush
25761 * Fires before the iframe editor is updated with content from the textarea. Return false
25762 * to cancel the push.
25763 * @param {HtmlEditor} this
25764 * @param {String} html
25769 * Fires when the textarea is updated with content from the editor iframe.
25770 * @param {HtmlEditor} this
25771 * @param {String} html
25776 * Fires when the iframe editor is updated with content from the textarea.
25777 * @param {HtmlEditor} this
25778 * @param {String} html
25782 * @event editmodechange
25783 * Fires when the editor switches edit modes
25784 * @param {HtmlEditor} this
25785 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
25787 editmodechange: true,
25789 * @event editorevent
25790 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
25791 * @param {HtmlEditor} this
25795 * @event firstfocus
25796 * Fires when on first focus - needed by toolbars..
25797 * @param {HtmlEditor} this
25802 * Auto save the htmlEditor value as a file into Events
25803 * @param {HtmlEditor} this
25807 * @event savedpreview
25808 * preview the saved version of htmlEditor
25809 * @param {HtmlEditor} this
25816 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
25820 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
25825 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
25830 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
25835 * @cfg {Number} height (in pixels)
25839 * @cfg {Number} width (in pixels)
25844 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
25847 stylesheets: false,
25852 // private properties
25853 validationEvent : false,
25855 initialized : false,
25858 onFocus : Roo.emptyFn,
25860 hideMode:'offsets',
25862 tbContainer : false,
25866 toolbarContainer :function() {
25867 return this.wrap.select('.x-html-editor-tb',true).first();
25871 * Protected method that will not generally be called directly. It
25872 * is called when the editor creates its toolbar. Override this method if you need to
25873 * add custom toolbar buttons.
25874 * @param {HtmlEditor} editor
25876 createToolbar : function(){
25877 Roo.log('renewing');
25878 Roo.log("create toolbars");
25880 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
25881 this.toolbars[0].render(this.toolbarContainer());
25885 // if (!editor.toolbars || !editor.toolbars.length) {
25886 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
25889 // for (var i =0 ; i < editor.toolbars.length;i++) {
25890 // editor.toolbars[i] = Roo.factory(
25891 // typeof(editor.toolbars[i]) == 'string' ?
25892 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
25893 // Roo.bootstrap.HtmlEditor);
25894 // editor.toolbars[i].init(editor);
25900 onRender : function(ct, position)
25902 // Roo.log("Call onRender: " + this.xtype);
25904 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
25906 this.wrap = this.inputEl().wrap({
25907 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
25910 this.editorcore.onRender(ct, position);
25912 if (this.resizable) {
25913 this.resizeEl = new Roo.Resizable(this.wrap, {
25917 minHeight : this.height,
25918 height: this.height,
25919 handles : this.resizable,
25922 resize : function(r, w, h) {
25923 _t.onResize(w,h); // -something
25929 this.createToolbar(this);
25932 if(!this.width && this.resizable){
25933 this.setSize(this.wrap.getSize());
25935 if (this.resizeEl) {
25936 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
25937 // should trigger onReize..
25943 onResize : function(w, h)
25945 Roo.log('resize: ' +w + ',' + h );
25946 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
25950 if(this.inputEl() ){
25951 if(typeof w == 'number'){
25952 var aw = w - this.wrap.getFrameWidth('lr');
25953 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
25956 if(typeof h == 'number'){
25957 var tbh = -11; // fixme it needs to tool bar size!
25958 for (var i =0; i < this.toolbars.length;i++) {
25959 // fixme - ask toolbars for heights?
25960 tbh += this.toolbars[i].el.getHeight();
25961 //if (this.toolbars[i].footer) {
25962 // tbh += this.toolbars[i].footer.el.getHeight();
25970 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
25971 ah -= 5; // knock a few pixes off for look..
25972 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
25976 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
25977 this.editorcore.onResize(ew,eh);
25982 * Toggles the editor between standard and source edit mode.
25983 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
25985 toggleSourceEdit : function(sourceEditMode)
25987 this.editorcore.toggleSourceEdit(sourceEditMode);
25989 if(this.editorcore.sourceEditMode){
25990 Roo.log('editor - showing textarea');
25993 // Roo.log(this.syncValue());
25995 this.inputEl().removeClass(['hide', 'x-hidden']);
25996 this.inputEl().dom.removeAttribute('tabIndex');
25997 this.inputEl().focus();
25999 Roo.log('editor - hiding textarea');
26001 // Roo.log(this.pushValue());
26004 this.inputEl().addClass(['hide', 'x-hidden']);
26005 this.inputEl().dom.setAttribute('tabIndex', -1);
26006 //this.deferFocus();
26009 if(this.resizable){
26010 this.setSize(this.wrap.getSize());
26013 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
26016 // private (for BoxComponent)
26017 adjustSize : Roo.BoxComponent.prototype.adjustSize,
26019 // private (for BoxComponent)
26020 getResizeEl : function(){
26024 // private (for BoxComponent)
26025 getPositionEl : function(){
26030 initEvents : function(){
26031 this.originalValue = this.getValue();
26035 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
26038 // markInvalid : Roo.emptyFn,
26040 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
26043 // clearInvalid : Roo.emptyFn,
26045 setValue : function(v){
26046 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
26047 this.editorcore.pushValue();
26052 deferFocus : function(){
26053 this.focus.defer(10, this);
26057 focus : function(){
26058 this.editorcore.focus();
26064 onDestroy : function(){
26070 for (var i =0; i < this.toolbars.length;i++) {
26071 // fixme - ask toolbars for heights?
26072 this.toolbars[i].onDestroy();
26075 this.wrap.dom.innerHTML = '';
26076 this.wrap.remove();
26081 onFirstFocus : function(){
26082 //Roo.log("onFirstFocus");
26083 this.editorcore.onFirstFocus();
26084 for (var i =0; i < this.toolbars.length;i++) {
26085 this.toolbars[i].onFirstFocus();
26091 syncValue : function()
26093 this.editorcore.syncValue();
26096 pushValue : function()
26098 this.editorcore.pushValue();
26102 // hide stuff that is not compatible
26116 * @event specialkey
26120 * @cfg {String} fieldClass @hide
26123 * @cfg {String} focusClass @hide
26126 * @cfg {String} autoCreate @hide
26129 * @cfg {String} inputType @hide
26133 * @cfg {String} invalidText @hide
26136 * @cfg {String} msgFx @hide
26139 * @cfg {String} validateOnBlur @hide
26148 Roo.namespace('Roo.bootstrap.htmleditor');
26150 * @class Roo.bootstrap.HtmlEditorToolbar1
26156 new Roo.bootstrap.HtmlEditor({
26159 new Roo.bootstrap.HtmlEditorToolbar1({
26160 disable : { fonts: 1 , format: 1, ..., ... , ...],
26166 * @cfg {Object} disable List of elements to disable..
26167 * @cfg {Array} btns List of additional buttons.
26171 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
26174 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
26177 Roo.apply(this, config);
26179 // default disabled, based on 'good practice'..
26180 this.disable = this.disable || {};
26181 Roo.applyIf(this.disable, {
26184 specialElements : true
26186 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
26188 this.editor = config.editor;
26189 this.editorcore = config.editor.editorcore;
26191 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
26193 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
26194 // dont call parent... till later.
26196 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
26201 editorcore : false,
26206 "h1","h2","h3","h4","h5","h6",
26208 "abbr", "acronym", "address", "cite", "samp", "var",
26212 onRender : function(ct, position)
26214 // Roo.log("Call onRender: " + this.xtype);
26216 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
26218 this.el.dom.style.marginBottom = '0';
26220 var editorcore = this.editorcore;
26221 var editor= this.editor;
26224 var btn = function(id,cmd , toggle, handler, html){
26226 var event = toggle ? 'toggle' : 'click';
26231 xns: Roo.bootstrap,
26235 enableToggle:toggle !== false,
26237 pressed : toggle ? false : null,
26240 a.listeners[toggle ? 'toggle' : 'click'] = function() {
26241 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
26247 // var cb_box = function...
26252 xns: Roo.bootstrap,
26257 xns: Roo.bootstrap,
26261 Roo.each(this.formats, function(f) {
26262 style.menu.items.push({
26264 xns: Roo.bootstrap,
26265 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
26270 editorcore.insertTag(this.tagname);
26277 children.push(style);
26279 btn('bold',false,true);
26280 btn('italic',false,true);
26281 btn('align-left', 'justifyleft',true);
26282 btn('align-center', 'justifycenter',true);
26283 btn('align-right' , 'justifyright',true);
26284 btn('link', false, false, function(btn) {
26285 //Roo.log("create link?");
26286 var url = prompt(this.createLinkText, this.defaultLinkValue);
26287 if(url && url != 'http:/'+'/'){
26288 this.editorcore.relayCmd('createlink', url);
26291 btn('list','insertunorderedlist',true);
26292 btn('pencil', false,true, function(btn){
26294 this.toggleSourceEdit(btn.pressed);
26297 if (this.editor.btns.length > 0) {
26298 for (var i = 0; i<this.editor.btns.length; i++) {
26299 children.push(this.editor.btns[i]);
26307 xns: Roo.bootstrap,
26312 xns: Roo.bootstrap,
26317 cog.menu.items.push({
26319 xns: Roo.bootstrap,
26320 html : Clean styles,
26325 editorcore.insertTag(this.tagname);
26334 this.xtype = 'NavSimplebar';
26336 for(var i=0;i< children.length;i++) {
26338 this.buttons.add(this.addxtypeChild(children[i]));
26342 editor.on('editorevent', this.updateToolbar, this);
26344 onBtnClick : function(id)
26346 this.editorcore.relayCmd(id);
26347 this.editorcore.focus();
26351 * Protected method that will not generally be called directly. It triggers
26352 * a toolbar update by reading the markup state of the current selection in the editor.
26354 updateToolbar: function(){
26356 if(!this.editorcore.activated){
26357 this.editor.onFirstFocus(); // is this neeed?
26361 var btns = this.buttons;
26362 var doc = this.editorcore.doc;
26363 btns.get('bold').setActive(doc.queryCommandState('bold'));
26364 btns.get('italic').setActive(doc.queryCommandState('italic'));
26365 //btns.get('underline').setActive(doc.queryCommandState('underline'));
26367 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
26368 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
26369 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
26371 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
26372 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
26375 var ans = this.editorcore.getAllAncestors();
26376 if (this.formatCombo) {
26379 var store = this.formatCombo.store;
26380 this.formatCombo.setValue("");
26381 for (var i =0; i < ans.length;i++) {
26382 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
26384 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
26392 // hides menus... - so this cant be on a menu...
26393 Roo.bootstrap.MenuMgr.hideAll();
26395 Roo.bootstrap.MenuMgr.hideAll();
26396 //this.editorsyncValue();
26398 onFirstFocus: function() {
26399 this.buttons.each(function(item){
26403 toggleSourceEdit : function(sourceEditMode){
26406 if(sourceEditMode){
26407 Roo.log("disabling buttons");
26408 this.buttons.each( function(item){
26409 if(item.cmd != 'pencil'){
26415 Roo.log("enabling buttons");
26416 if(this.editorcore.initialized){
26417 this.buttons.each( function(item){
26423 Roo.log("calling toggole on editor");
26424 // tell the editor that it's been pressed..
26425 this.editor.toggleSourceEdit(sourceEditMode);
26439 * @class Roo.bootstrap.Markdown
26440 * @extends Roo.bootstrap.TextArea
26441 * Bootstrap Showdown editable area
26442 * @cfg {string} content
26445 * Create a new Showdown
26448 Roo.bootstrap.Markdown = function(config){
26449 Roo.bootstrap.Markdown.superclass.constructor.call(this, config);
26453 Roo.extend(Roo.bootstrap.Markdown, Roo.bootstrap.TextArea, {
26457 initEvents : function()
26460 Roo.bootstrap.TextArea.prototype.initEvents.call(this);
26461 this.markdownEl = this.el.createChild({
26462 cls : 'roo-markdown-area'
26464 this.inputEl().addClass('d-none');
26465 if (this.getValue() == '') {
26466 this.markdownEl.dom.innerHTML = String.format('<span class="roo-placeholder">{0}</span>', this.placeholder || '');
26469 this.markdownEl.dom.innerHTML = Roo.Markdown.toHtml(Roo.util.Format.htmlEncode(this.getValue()));
26471 this.markdownEl.on('click', this.toggleTextEdit, this);
26472 this.on('blur', this.toggleTextEdit, this);
26473 this.on('specialkey', this.resizeTextArea, this);
26476 toggleTextEdit : function()
26478 var sh = this.markdownEl.getHeight();
26479 this.inputEl().addClass('d-none');
26480 this.markdownEl.addClass('d-none');
26481 if (!this.editing) {
26483 this.inputEl().setHeight(Math.min(500, Math.max(sh,(this.getValue().split("\n").length+1) * 30)));
26484 this.inputEl().removeClass('d-none');
26485 this.inputEl().focus();
26486 this.editing = true;
26489 // show showdown...
26490 this.updateMarkdown();
26491 this.markdownEl.removeClass('d-none');
26492 this.editing = false;
26495 updateMarkdown : function()
26497 if (this.getValue() == '') {
26498 this.markdownEl.dom.innerHTML = String.format('<span class="roo-placeholder">{0}</span>', this.placeholder || '');
26502 this.markdownEl.dom.innerHTML = Roo.Markdown.toHtml(Roo.util.Format.htmlEncode(this.getValue()));
26505 resizeTextArea: function () {
26508 Roo.log([sh, this.getValue().split("\n").length * 30]);
26509 this.inputEl().setHeight(Math.min(500, Math.max(sh, (this.getValue().split("\n").length +1) * 30)));
26511 setValue : function(val)
26513 Roo.bootstrap.TextArea.prototype.setValue.call(this,val);
26514 if (!this.editing) {
26515 this.updateMarkdown();
26521 if (!this.editing) {
26522 this.toggleTextEdit();
26530 * @class Roo.bootstrap.Table.AbstractSelectionModel
26531 * @extends Roo.util.Observable
26532 * Abstract base class for grid SelectionModels. It provides the interface that should be
26533 * implemented by descendant classes. This class should not be directly instantiated.
26536 Roo.bootstrap.Table.AbstractSelectionModel = function(){
26537 this.locked = false;
26538 Roo.bootstrap.Table.AbstractSelectionModel.superclass.constructor.call(this);
26542 Roo.extend(Roo.bootstrap.Table.AbstractSelectionModel, Roo.util.Observable, {
26543 /** @ignore Called by the grid automatically. Do not call directly. */
26544 init : function(grid){
26550 * Locks the selections.
26553 this.locked = true;
26557 * Unlocks the selections.
26559 unlock : function(){
26560 this.locked = false;
26564 * Returns true if the selections are locked.
26565 * @return {Boolean}
26567 isLocked : function(){
26568 return this.locked;
26572 initEvents : function ()
26578 * @extends Roo.bootstrap.Table.AbstractSelectionModel
26579 * @class Roo.bootstrap.Table.RowSelectionModel
26580 * The default SelectionModel used by {@link Roo.bootstrap.Table}.
26581 * It supports multiple selections and keyboard selection/navigation.
26583 * @param {Object} config
26586 Roo.bootstrap.Table.RowSelectionModel = function(config){
26587 Roo.apply(this, config);
26588 this.selections = new Roo.util.MixedCollection(false, function(o){
26593 this.lastActive = false;
26597 * @event selectionchange
26598 * Fires when the selection changes
26599 * @param {SelectionModel} this
26601 "selectionchange" : true,
26603 * @event afterselectionchange
26604 * Fires after the selection changes (eg. by key press or clicking)
26605 * @param {SelectionModel} this
26607 "afterselectionchange" : true,
26609 * @event beforerowselect
26610 * Fires when a row is selected being selected, return false to cancel.
26611 * @param {SelectionModel} this
26612 * @param {Number} rowIndex The selected index
26613 * @param {Boolean} keepExisting False if other selections will be cleared
26615 "beforerowselect" : true,
26618 * Fires when a row is selected.
26619 * @param {SelectionModel} this
26620 * @param {Number} rowIndex The selected index
26621 * @param {Roo.data.Record} r The record
26623 "rowselect" : true,
26625 * @event rowdeselect
26626 * Fires when a row is deselected.
26627 * @param {SelectionModel} this
26628 * @param {Number} rowIndex The selected index
26630 "rowdeselect" : true
26632 Roo.bootstrap.Table.RowSelectionModel.superclass.constructor.call(this);
26633 this.locked = false;
26636 Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSelectionModel, {
26638 * @cfg {Boolean} singleSelect
26639 * True to allow selection of only one row at a time (defaults to false)
26641 singleSelect : false,
26644 initEvents : function()
26647 //if(!this.grid.enableDragDrop && !this.grid.enableDrag){
26648 // this.growclickrid.on("mousedown", this.handleMouseDown, this);
26649 //}else{ // allow click to work like normal
26650 // this.grid.on("rowclick", this.handleDragableRowClick, this);
26652 //this.grid.on("rowdblclick", this.handleMouseDBClick, this);
26653 this.grid.on("rowclick", this.handleMouseDown, this);
26655 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
26656 "up" : function(e){
26658 this.selectPrevious(e.shiftKey);
26659 }else if(this.last !== false && this.lastActive !== false){
26660 var last = this.last;
26661 this.selectRange(this.last, this.lastActive-1);
26662 this.grid.getView().focusRow(this.lastActive);
26663 if(last !== false){
26667 this.selectFirstRow();
26669 this.fireEvent("afterselectionchange", this);
26671 "down" : function(e){
26673 this.selectNext(e.shiftKey);
26674 }else if(this.last !== false && this.lastActive !== false){
26675 var last = this.last;
26676 this.selectRange(this.last, this.lastActive+1);
26677 this.grid.getView().focusRow(this.lastActive);
26678 if(last !== false){
26682 this.selectFirstRow();
26684 this.fireEvent("afterselectionchange", this);
26688 this.grid.store.on('load', function(){
26689 this.selections.clear();
26692 var view = this.grid.view;
26693 view.on("refresh", this.onRefresh, this);
26694 view.on("rowupdated", this.onRowUpdated, this);
26695 view.on("rowremoved", this.onRemove, this);
26700 onRefresh : function()
26702 var ds = this.grid.store, i, v = this.grid.view;
26703 var s = this.selections;
26704 s.each(function(r){
26705 if((i = ds.indexOfId(r.id)) != -1){
26714 onRemove : function(v, index, r){
26715 this.selections.remove(r);
26719 onRowUpdated : function(v, index, r){
26720 if(this.isSelected(r)){
26721 v.onRowSelect(index);
26727 * @param {Array} records The records to select
26728 * @param {Boolean} keepExisting (optional) True to keep existing selections
26730 selectRecords : function(records, keepExisting)
26733 this.clearSelections();
26735 var ds = this.grid.store;
26736 for(var i = 0, len = records.length; i < len; i++){
26737 this.selectRow(ds.indexOf(records[i]), true);
26742 * Gets the number of selected rows.
26745 getCount : function(){
26746 return this.selections.length;
26750 * Selects the first row in the grid.
26752 selectFirstRow : function(){
26757 * Select the last row.
26758 * @param {Boolean} keepExisting (optional) True to keep existing selections
26760 selectLastRow : function(keepExisting){
26761 //this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
26762 this.selectRow(this.grid.store.getCount() - 1, keepExisting);
26766 * Selects the row immediately following the last selected row.
26767 * @param {Boolean} keepExisting (optional) True to keep existing selections
26769 selectNext : function(keepExisting)
26771 if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
26772 this.selectRow(this.last+1, keepExisting);
26773 this.grid.getView().focusRow(this.last);
26778 * Selects the row that precedes the last selected row.
26779 * @param {Boolean} keepExisting (optional) True to keep existing selections
26781 selectPrevious : function(keepExisting){
26783 this.selectRow(this.last-1, keepExisting);
26784 this.grid.getView().focusRow(this.last);
26789 * Returns the selected records
26790 * @return {Array} Array of selected records
26792 getSelections : function(){
26793 return [].concat(this.selections.items);
26797 * Returns the first selected record.
26800 getSelected : function(){
26801 return this.selections.itemAt(0);
26806 * Clears all selections.
26808 clearSelections : function(fast)
26814 var ds = this.grid.store;
26815 var s = this.selections;
26816 s.each(function(r){
26817 this.deselectRow(ds.indexOfId(r.id));
26821 this.selections.clear();
26828 * Selects all rows.
26830 selectAll : function(){
26834 this.selections.clear();
26835 for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
26836 this.selectRow(i, true);
26841 * Returns True if there is a selection.
26842 * @return {Boolean}
26844 hasSelection : function(){
26845 return this.selections.length > 0;
26849 * Returns True if the specified row is selected.
26850 * @param {Number/Record} record The record or index of the record to check
26851 * @return {Boolean}
26853 isSelected : function(index){
26854 var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
26855 return (r && this.selections.key(r.id) ? true : false);
26859 * Returns True if the specified record id is selected.
26860 * @param {String} id The id of record to check
26861 * @return {Boolean}
26863 isIdSelected : function(id){
26864 return (this.selections.key(id) ? true : false);
26869 handleMouseDBClick : function(e, t){
26873 handleMouseDown : function(e, t)
26875 var rowIndex = this.grid.headerShow ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
26876 if(this.isLocked() || rowIndex < 0 ){
26879 if(e.shiftKey && this.last !== false){
26880 var last = this.last;
26881 this.selectRange(last, rowIndex, e.ctrlKey);
26882 this.last = last; // reset the last
26886 var isSelected = this.isSelected(rowIndex);
26887 //Roo.log("select row:" + rowIndex);
26889 this.deselectRow(rowIndex);
26891 this.selectRow(rowIndex, true);
26895 if(e.button !== 0 && isSelected){
26896 alert('rowIndex 2: ' + rowIndex);
26897 view.focusRow(rowIndex);
26898 }else if(e.ctrlKey && isSelected){
26899 this.deselectRow(rowIndex);
26900 }else if(!isSelected){
26901 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
26902 view.focusRow(rowIndex);
26906 this.fireEvent("afterselectionchange", this);
26909 handleDragableRowClick : function(grid, rowIndex, e)
26911 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
26912 this.selectRow(rowIndex, false);
26913 grid.view.focusRow(rowIndex);
26914 this.fireEvent("afterselectionchange", this);
26919 * Selects multiple rows.
26920 * @param {Array} rows Array of the indexes of the row to select
26921 * @param {Boolean} keepExisting (optional) True to keep existing selections
26923 selectRows : function(rows, keepExisting){
26925 this.clearSelections();
26927 for(var i = 0, len = rows.length; i < len; i++){
26928 this.selectRow(rows[i], true);
26933 * Selects a range of rows. All rows in between startRow and endRow are also selected.
26934 * @param {Number} startRow The index of the first row in the range
26935 * @param {Number} endRow The index of the last row in the range
26936 * @param {Boolean} keepExisting (optional) True to retain existing selections
26938 selectRange : function(startRow, endRow, keepExisting){
26943 this.clearSelections();
26945 if(startRow <= endRow){
26946 for(var i = startRow; i <= endRow; i++){
26947 this.selectRow(i, true);
26950 for(var i = startRow; i >= endRow; i--){
26951 this.selectRow(i, true);
26957 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
26958 * @param {Number} startRow The index of the first row in the range
26959 * @param {Number} endRow The index of the last row in the range
26961 deselectRange : function(startRow, endRow, preventViewNotify){
26965 for(var i = startRow; i <= endRow; i++){
26966 this.deselectRow(i, preventViewNotify);
26972 * @param {Number} row The index of the row to select
26973 * @param {Boolean} keepExisting (optional) True to keep existing selections
26975 selectRow : function(index, keepExisting, preventViewNotify)
26977 if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
26980 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
26981 if(!keepExisting || this.singleSelect){
26982 this.clearSelections();
26985 var r = this.grid.store.getAt(index);
26986 //console.log('selectRow - record id :' + r.id);
26988 this.selections.add(r);
26989 this.last = this.lastActive = index;
26990 if(!preventViewNotify){
26991 var proxy = new Roo.Element(
26992 this.grid.getRowDom(index)
26994 proxy.addClass('bg-info info');
26996 this.fireEvent("rowselect", this, index, r);
26997 this.fireEvent("selectionchange", this);
27003 * @param {Number} row The index of the row to deselect
27005 deselectRow : function(index, preventViewNotify)
27010 if(this.last == index){
27013 if(this.lastActive == index){
27014 this.lastActive = false;
27017 var r = this.grid.store.getAt(index);
27022 this.selections.remove(r);
27023 //.console.log('deselectRow - record id :' + r.id);
27024 if(!preventViewNotify){
27026 var proxy = new Roo.Element(
27027 this.grid.getRowDom(index)
27029 proxy.removeClass('bg-info info');
27031 this.fireEvent("rowdeselect", this, index);
27032 this.fireEvent("selectionchange", this);
27036 restoreLast : function(){
27038 this.last = this._last;
27043 acceptsNav : function(row, col, cm){
27044 return !cm.isHidden(col) && cm.isCellEditable(col, row);
27048 onEditorKey : function(field, e){
27049 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
27054 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
27056 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
27058 }else if(k == e.ENTER && !e.ctrlKey){
27062 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
27064 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
27066 }else if(k == e.ESC){
27070 g.startEditing(newCell[0], newCell[1]);
27076 * Ext JS Library 1.1.1
27077 * Copyright(c) 2006-2007, Ext JS, LLC.
27079 * Originally Released Under LGPL - original licence link has changed is not relivant.
27082 * <script type="text/javascript">
27086 * @class Roo.bootstrap.PagingToolbar
27087 * @extends Roo.bootstrap.NavSimplebar
27088 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
27090 * Create a new PagingToolbar
27091 * @param {Object} config The config object
27092 * @param {Roo.data.Store} store
27094 Roo.bootstrap.PagingToolbar = function(config)
27096 // old args format still supported... - xtype is prefered..
27097 // created from xtype...
27099 this.ds = config.dataSource;
27101 if (config.store && !this.ds) {
27102 this.store= Roo.factory(config.store, Roo.data);
27103 this.ds = this.store;
27104 this.ds.xmodule = this.xmodule || false;
27107 this.toolbarItems = [];
27108 if (config.items) {
27109 this.toolbarItems = config.items;
27112 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
27117 this.bind(this.ds);
27120 if (Roo.bootstrap.version == 4) {
27121 this.navgroup = new Roo.bootstrap.ButtonGroup({ cls: 'pagination' });
27123 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
27128 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
27130 * @cfg {Roo.data.Store} dataSource
27131 * The underlying data store providing the paged data
27134 * @cfg {String/HTMLElement/Element} container
27135 * container The id or element that will contain the toolbar
27138 * @cfg {Boolean} displayInfo
27139 * True to display the displayMsg (defaults to false)
27142 * @cfg {Number} pageSize
27143 * The number of records to display per page (defaults to 20)
27147 * @cfg {String} displayMsg
27148 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
27150 displayMsg : 'Displaying {0} - {1} of {2}',
27152 * @cfg {String} emptyMsg
27153 * The message to display when no records are found (defaults to "No data to display")
27155 emptyMsg : 'No data to display',
27157 * Customizable piece of the default paging text (defaults to "Page")
27160 beforePageText : "Page",
27162 * Customizable piece of the default paging text (defaults to "of %0")
27165 afterPageText : "of {0}",
27167 * Customizable piece of the default paging text (defaults to "First Page")
27170 firstText : "First Page",
27172 * Customizable piece of the default paging text (defaults to "Previous Page")
27175 prevText : "Previous Page",
27177 * Customizable piece of the default paging text (defaults to "Next Page")
27180 nextText : "Next Page",
27182 * Customizable piece of the default paging text (defaults to "Last Page")
27185 lastText : "Last Page",
27187 * Customizable piece of the default paging text (defaults to "Refresh")
27190 refreshText : "Refresh",
27194 onRender : function(ct, position)
27196 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
27197 this.navgroup.parentId = this.id;
27198 this.navgroup.onRender(this.el, null);
27199 // add the buttons to the navgroup
27201 if(this.displayInfo){
27202 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
27203 this.displayEl = this.el.select('.x-paging-info', true).first();
27204 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
27205 // this.displayEl = navel.el.select('span',true).first();
27211 Roo.each(_this.buttons, function(e){ // this might need to use render????
27212 Roo.factory(e).render(_this.el);
27216 Roo.each(_this.toolbarItems, function(e) {
27217 _this.navgroup.addItem(e);
27221 this.first = this.navgroup.addItem({
27222 tooltip: this.firstText,
27223 cls: "prev btn-outline-secondary",
27224 html : ' <i class="fa fa-step-backward"></i>',
27226 preventDefault: true,
27227 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
27230 this.prev = this.navgroup.addItem({
27231 tooltip: this.prevText,
27232 cls: "prev btn-outline-secondary",
27233 html : ' <i class="fa fa-backward"></i>',
27235 preventDefault: true,
27236 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
27238 //this.addSeparator();
27241 var field = this.navgroup.addItem( {
27243 cls : 'x-paging-position btn-outline-secondary',
27245 html : this.beforePageText +
27246 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
27247 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
27250 this.field = field.el.select('input', true).first();
27251 this.field.on("keydown", this.onPagingKeydown, this);
27252 this.field.on("focus", function(){this.dom.select();});
27255 this.afterTextEl = field.el.select('.x-paging-after',true).first();
27256 //this.field.setHeight(18);
27257 //this.addSeparator();
27258 this.next = this.navgroup.addItem({
27259 tooltip: this.nextText,
27260 cls: "next btn-outline-secondary",
27261 html : ' <i class="fa fa-forward"></i>',
27263 preventDefault: true,
27264 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
27266 this.last = this.navgroup.addItem({
27267 tooltip: this.lastText,
27268 html : ' <i class="fa fa-step-forward"></i>',
27269 cls: "next btn-outline-secondary",
27271 preventDefault: true,
27272 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
27274 //this.addSeparator();
27275 this.loading = this.navgroup.addItem({
27276 tooltip: this.refreshText,
27277 cls: "btn-outline-secondary",
27278 html : ' <i class="fa fa-refresh"></i>',
27279 preventDefault: true,
27280 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
27286 updateInfo : function(){
27287 if(this.displayEl){
27288 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
27289 var msg = count == 0 ?
27293 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
27295 this.displayEl.update(msg);
27300 onLoad : function(ds, r, o)
27302 this.cursor = o.params.start ? o.params.start : 0;
27304 var d = this.getPageData(),
27309 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
27310 this.field.dom.value = ap;
27311 this.first.setDisabled(ap == 1);
27312 this.prev.setDisabled(ap == 1);
27313 this.next.setDisabled(ap == ps);
27314 this.last.setDisabled(ap == ps);
27315 this.loading.enable();
27320 getPageData : function(){
27321 var total = this.ds.getTotalCount();
27324 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
27325 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
27330 onLoadError : function(){
27331 this.loading.enable();
27335 onPagingKeydown : function(e){
27336 var k = e.getKey();
27337 var d = this.getPageData();
27339 var v = this.field.dom.value, pageNum;
27340 if(!v || isNaN(pageNum = parseInt(v, 10))){
27341 this.field.dom.value = d.activePage;
27344 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
27345 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
27348 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))
27350 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
27351 this.field.dom.value = pageNum;
27352 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
27355 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
27357 var v = this.field.dom.value, pageNum;
27358 var increment = (e.shiftKey) ? 10 : 1;
27359 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
27362 if(!v || isNaN(pageNum = parseInt(v, 10))) {
27363 this.field.dom.value = d.activePage;
27366 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
27368 this.field.dom.value = parseInt(v, 10) + increment;
27369 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
27370 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
27377 beforeLoad : function(){
27379 this.loading.disable();
27384 onClick : function(which){
27393 ds.load({params:{start: 0, limit: this.pageSize}});
27396 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
27399 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
27402 var total = ds.getTotalCount();
27403 var extra = total % this.pageSize;
27404 var lastStart = extra ? (total - extra) : total-this.pageSize;
27405 ds.load({params:{start: lastStart, limit: this.pageSize}});
27408 ds.load({params:{start: this.cursor, limit: this.pageSize}});
27414 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
27415 * @param {Roo.data.Store} store The data store to unbind
27417 unbind : function(ds){
27418 ds.un("beforeload", this.beforeLoad, this);
27419 ds.un("load", this.onLoad, this);
27420 ds.un("loadexception", this.onLoadError, this);
27421 ds.un("remove", this.updateInfo, this);
27422 ds.un("add", this.updateInfo, this);
27423 this.ds = undefined;
27427 * Binds the paging toolbar to the specified {@link Roo.data.Store}
27428 * @param {Roo.data.Store} store The data store to bind
27430 bind : function(ds){
27431 ds.on("beforeload", this.beforeLoad, this);
27432 ds.on("load", this.onLoad, this);
27433 ds.on("loadexception", this.onLoadError, this);
27434 ds.on("remove", this.updateInfo, this);
27435 ds.on("add", this.updateInfo, this);
27446 * @class Roo.bootstrap.MessageBar
27447 * @extends Roo.bootstrap.Component
27448 * Bootstrap MessageBar class
27449 * @cfg {String} html contents of the MessageBar
27450 * @cfg {String} weight (info | success | warning | danger) default info
27451 * @cfg {String} beforeClass insert the bar before the given class
27452 * @cfg {Boolean} closable (true | false) default false
27453 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
27456 * Create a new Element
27457 * @param {Object} config The config object
27460 Roo.bootstrap.MessageBar = function(config){
27461 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
27464 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
27470 beforeClass: 'bootstrap-sticky-wrap',
27472 getAutoCreate : function(){
27476 cls: 'alert alert-dismissable alert-' + this.weight,
27481 html: this.html || ''
27487 cfg.cls += ' alert-messages-fixed';
27501 onRender : function(ct, position)
27503 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
27506 var cfg = Roo.apply({}, this.getAutoCreate());
27510 cfg.cls += ' ' + this.cls;
27513 cfg.style = this.style;
27515 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
27517 this.el.setVisibilityMode(Roo.Element.DISPLAY);
27520 this.el.select('>button.close').on('click', this.hide, this);
27526 if (!this.rendered) {
27532 this.fireEvent('show', this);
27538 if (!this.rendered) {
27544 this.fireEvent('hide', this);
27547 update : function()
27549 // var e = this.el.dom.firstChild;
27551 // if(this.closable){
27552 // e = e.nextSibling;
27555 // e.data = this.html || '';
27557 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
27573 * @class Roo.bootstrap.Graph
27574 * @extends Roo.bootstrap.Component
27575 * Bootstrap Graph class
27579 @cfg {String} graphtype bar | vbar | pie
27580 @cfg {number} g_x coodinator | centre x (pie)
27581 @cfg {number} g_y coodinator | centre y (pie)
27582 @cfg {number} g_r radius (pie)
27583 @cfg {number} g_height height of the chart (respected by all elements in the set)
27584 @cfg {number} g_width width of the chart (respected by all elements in the set)
27585 @cfg {Object} title The title of the chart
27588 -opts (object) options for the chart
27590 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
27591 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
27593 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.
27594 o stacked (boolean) whether or not to tread values as in a stacked bar chart
27596 o stretch (boolean)
27598 -opts (object) options for the pie
27601 o startAngle (number)
27602 o endAngle (number)
27606 * Create a new Input
27607 * @param {Object} config The config object
27610 Roo.bootstrap.Graph = function(config){
27611 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
27617 * The img click event for the img.
27618 * @param {Roo.EventObject} e
27624 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
27635 //g_colors: this.colors,
27642 getAutoCreate : function(){
27653 onRender : function(ct,position){
27656 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
27658 if (typeof(Raphael) == 'undefined') {
27659 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
27663 this.raphael = Raphael(this.el.dom);
27665 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
27666 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
27667 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
27668 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
27670 r.text(160, 10, "Single Series Chart").attr(txtattr);
27671 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
27672 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
27673 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
27675 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
27676 r.barchart(330, 10, 300, 220, data1);
27677 r.barchart(10, 250, 300, 220, data2, {stacked: true});
27678 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
27681 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
27682 // r.barchart(30, 30, 560, 250, xdata, {
27683 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
27684 // axis : "0 0 1 1",
27685 // axisxlabels : xdata
27686 // //yvalues : cols,
27689 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
27691 // this.load(null,xdata,{
27692 // axis : "0 0 1 1",
27693 // axisxlabels : xdata
27698 load : function(graphtype,xdata,opts)
27700 this.raphael.clear();
27702 graphtype = this.graphtype;
27707 var r = this.raphael,
27708 fin = function () {
27709 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
27711 fout = function () {
27712 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
27714 pfin = function() {
27715 this.sector.stop();
27716 this.sector.scale(1.1, 1.1, this.cx, this.cy);
27719 this.label[0].stop();
27720 this.label[0].attr({ r: 7.5 });
27721 this.label[1].attr({ "font-weight": 800 });
27724 pfout = function() {
27725 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
27728 this.label[0].animate({ r: 5 }, 500, "bounce");
27729 this.label[1].attr({ "font-weight": 400 });
27735 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
27738 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
27741 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
27742 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
27744 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
27751 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
27756 setTitle: function(o)
27761 initEvents: function() {
27764 this.el.on('click', this.onClick, this);
27768 onClick : function(e)
27770 Roo.log('img onclick');
27771 this.fireEvent('click', this, e);
27783 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
27786 * @class Roo.bootstrap.dash.NumberBox
27787 * @extends Roo.bootstrap.Component
27788 * Bootstrap NumberBox class
27789 * @cfg {String} headline Box headline
27790 * @cfg {String} content Box content
27791 * @cfg {String} icon Box icon
27792 * @cfg {String} footer Footer text
27793 * @cfg {String} fhref Footer href
27796 * Create a new NumberBox
27797 * @param {Object} config The config object
27801 Roo.bootstrap.dash.NumberBox = function(config){
27802 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
27806 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
27815 getAutoCreate : function(){
27819 cls : 'small-box ',
27827 cls : 'roo-headline',
27828 html : this.headline
27832 cls : 'roo-content',
27833 html : this.content
27847 cls : 'ion ' + this.icon
27856 cls : 'small-box-footer',
27857 href : this.fhref || '#',
27861 cfg.cn.push(footer);
27868 onRender : function(ct,position){
27869 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
27876 setHeadline: function (value)
27878 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
27881 setFooter: function (value, href)
27883 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
27886 this.el.select('a.small-box-footer',true).first().attr('href', href);
27891 setContent: function (value)
27893 this.el.select('.roo-content',true).first().dom.innerHTML = value;
27896 initEvents: function()
27910 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
27913 * @class Roo.bootstrap.dash.TabBox
27914 * @extends Roo.bootstrap.Component
27915 * Bootstrap TabBox class
27916 * @cfg {String} title Title of the TabBox
27917 * @cfg {String} icon Icon of the TabBox
27918 * @cfg {Boolean} showtabs (true|false) show the tabs default true
27919 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
27922 * Create a new TabBox
27923 * @param {Object} config The config object
27927 Roo.bootstrap.dash.TabBox = function(config){
27928 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
27933 * When a pane is added
27934 * @param {Roo.bootstrap.dash.TabPane} pane
27938 * @event activatepane
27939 * When a pane is activated
27940 * @param {Roo.bootstrap.dash.TabPane} pane
27942 "activatepane" : true
27950 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
27955 tabScrollable : false,
27957 getChildContainer : function()
27959 return this.el.select('.tab-content', true).first();
27962 getAutoCreate : function(){
27966 cls: 'pull-left header',
27974 cls: 'fa ' + this.icon
27980 cls: 'nav nav-tabs pull-right',
27986 if(this.tabScrollable){
27993 cls: 'nav nav-tabs pull-right',
28004 cls: 'nav-tabs-custom',
28009 cls: 'tab-content no-padding',
28017 initEvents : function()
28019 //Roo.log('add add pane handler');
28020 this.on('addpane', this.onAddPane, this);
28023 * Updates the box title
28024 * @param {String} html to set the title to.
28026 setTitle : function(value)
28028 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
28030 onAddPane : function(pane)
28032 this.panes.push(pane);
28033 //Roo.log('addpane');
28035 // tabs are rendere left to right..
28036 if(!this.showtabs){
28040 var ctr = this.el.select('.nav-tabs', true).first();
28043 var existing = ctr.select('.nav-tab',true);
28044 var qty = existing.getCount();;
28047 var tab = ctr.createChild({
28049 cls : 'nav-tab' + (qty ? '' : ' active'),
28057 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
28060 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
28062 pane.el.addClass('active');
28067 onTabClick : function(ev,un,ob,pane)
28069 //Roo.log('tab - prev default');
28070 ev.preventDefault();
28073 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
28074 pane.tab.addClass('active');
28075 //Roo.log(pane.title);
28076 this.getChildContainer().select('.tab-pane',true).removeClass('active');
28077 // technically we should have a deactivate event.. but maybe add later.
28078 // and it should not de-activate the selected tab...
28079 this.fireEvent('activatepane', pane);
28080 pane.el.addClass('active');
28081 pane.fireEvent('activate');
28086 getActivePane : function()
28089 Roo.each(this.panes, function(p) {
28090 if(p.el.hasClass('active')){
28111 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
28113 * @class Roo.bootstrap.TabPane
28114 * @extends Roo.bootstrap.Component
28115 * Bootstrap TabPane class
28116 * @cfg {Boolean} active (false | true) Default false
28117 * @cfg {String} title title of panel
28121 * Create a new TabPane
28122 * @param {Object} config The config object
28125 Roo.bootstrap.dash.TabPane = function(config){
28126 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
28132 * When a pane is activated
28133 * @param {Roo.bootstrap.dash.TabPane} pane
28140 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
28145 // the tabBox that this is attached to.
28148 getAutoCreate : function()
28156 cfg.cls += ' active';
28161 initEvents : function()
28163 //Roo.log('trigger add pane handler');
28164 this.parent().fireEvent('addpane', this)
28168 * Updates the tab title
28169 * @param {String} html to set the title to.
28171 setTitle: function(str)
28177 this.tab.select('a', true).first().dom.innerHTML = str;
28194 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
28197 * @class Roo.bootstrap.menu.Menu
28198 * @extends Roo.bootstrap.Component
28199 * Bootstrap Menu class - container for Menu
28200 * @cfg {String} html Text of the menu
28201 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
28202 * @cfg {String} icon Font awesome icon
28203 * @cfg {String} pos Menu align to (top | bottom) default bottom
28207 * Create a new Menu
28208 * @param {Object} config The config object
28212 Roo.bootstrap.menu.Menu = function(config){
28213 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
28217 * @event beforeshow
28218 * Fires before this menu is displayed
28219 * @param {Roo.bootstrap.menu.Menu} this
28223 * @event beforehide
28224 * Fires before this menu is hidden
28225 * @param {Roo.bootstrap.menu.Menu} this
28230 * Fires after this menu is displayed
28231 * @param {Roo.bootstrap.menu.Menu} this
28236 * Fires after this menu is hidden
28237 * @param {Roo.bootstrap.menu.Menu} this
28242 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
28243 * @param {Roo.bootstrap.menu.Menu} this
28244 * @param {Roo.EventObject} e
28251 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
28255 weight : 'default',
28260 getChildContainer : function() {
28261 if(this.isSubMenu){
28265 return this.el.select('ul.dropdown-menu', true).first();
28268 getAutoCreate : function()
28273 cls : 'roo-menu-text',
28281 cls : 'fa ' + this.icon
28292 cls : 'dropdown-button btn btn-' + this.weight,
28297 cls : 'dropdown-toggle btn btn-' + this.weight,
28307 cls : 'dropdown-menu'
28313 if(this.pos == 'top'){
28314 cfg.cls += ' dropup';
28317 if(this.isSubMenu){
28320 cls : 'dropdown-menu'
28327 onRender : function(ct, position)
28329 this.isSubMenu = ct.hasClass('dropdown-submenu');
28331 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
28334 initEvents : function()
28336 if(this.isSubMenu){
28340 this.hidden = true;
28342 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
28343 this.triggerEl.on('click', this.onTriggerPress, this);
28345 this.buttonEl = this.el.select('button.dropdown-button', true).first();
28346 this.buttonEl.on('click', this.onClick, this);
28352 if(this.isSubMenu){
28356 return this.el.select('ul.dropdown-menu', true).first();
28359 onClick : function(e)
28361 this.fireEvent("click", this, e);
28364 onTriggerPress : function(e)
28366 if (this.isVisible()) {
28373 isVisible : function(){
28374 return !this.hidden;
28379 this.fireEvent("beforeshow", this);
28381 this.hidden = false;
28382 this.el.addClass('open');
28384 Roo.get(document).on("mouseup", this.onMouseUp, this);
28386 this.fireEvent("show", this);
28393 this.fireEvent("beforehide", this);
28395 this.hidden = true;
28396 this.el.removeClass('open');
28398 Roo.get(document).un("mouseup", this.onMouseUp);
28400 this.fireEvent("hide", this);
28403 onMouseUp : function()
28417 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
28420 * @class Roo.bootstrap.menu.Item
28421 * @extends Roo.bootstrap.Component
28422 * Bootstrap MenuItem class
28423 * @cfg {Boolean} submenu (true | false) default false
28424 * @cfg {String} html text of the item
28425 * @cfg {String} href the link
28426 * @cfg {Boolean} disable (true | false) default false
28427 * @cfg {Boolean} preventDefault (true | false) default true
28428 * @cfg {String} icon Font awesome icon
28429 * @cfg {String} pos Submenu align to (left | right) default right
28433 * Create a new Item
28434 * @param {Object} config The config object
28438 Roo.bootstrap.menu.Item = function(config){
28439 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
28443 * Fires when the mouse is hovering over this menu
28444 * @param {Roo.bootstrap.menu.Item} this
28445 * @param {Roo.EventObject} e
28450 * Fires when the mouse exits this menu
28451 * @param {Roo.bootstrap.menu.Item} this
28452 * @param {Roo.EventObject} e
28458 * The raw click event for the entire grid.
28459 * @param {Roo.EventObject} e
28465 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
28470 preventDefault: true,
28475 getAutoCreate : function()
28480 cls : 'roo-menu-item-text',
28488 cls : 'fa ' + this.icon
28497 href : this.href || '#',
28504 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
28508 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
28510 if(this.pos == 'left'){
28511 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
28518 initEvents : function()
28520 this.el.on('mouseover', this.onMouseOver, this);
28521 this.el.on('mouseout', this.onMouseOut, this);
28523 this.el.select('a', true).first().on('click', this.onClick, this);
28527 onClick : function(e)
28529 if(this.preventDefault){
28530 e.preventDefault();
28533 this.fireEvent("click", this, e);
28536 onMouseOver : function(e)
28538 if(this.submenu && this.pos == 'left'){
28539 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
28542 this.fireEvent("mouseover", this, e);
28545 onMouseOut : function(e)
28547 this.fireEvent("mouseout", this, e);
28559 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
28562 * @class Roo.bootstrap.menu.Separator
28563 * @extends Roo.bootstrap.Component
28564 * Bootstrap Separator class
28567 * Create a new Separator
28568 * @param {Object} config The config object
28572 Roo.bootstrap.menu.Separator = function(config){
28573 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
28576 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
28578 getAutoCreate : function(){
28599 * @class Roo.bootstrap.Tooltip
28600 * Bootstrap Tooltip class
28601 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
28602 * to determine which dom element triggers the tooltip.
28604 * It needs to add support for additional attributes like tooltip-position
28607 * Create a new Toolti
28608 * @param {Object} config The config object
28611 Roo.bootstrap.Tooltip = function(config){
28612 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
28614 this.alignment = Roo.bootstrap.Tooltip.alignment;
28616 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
28617 this.alignment = config.alignment;
28622 Roo.apply(Roo.bootstrap.Tooltip, {
28624 * @function init initialize tooltip monitoring.
28628 currentTip : false,
28629 currentRegion : false,
28635 Roo.get(document).on('mouseover', this.enter ,this);
28636 Roo.get(document).on('mouseout', this.leave, this);
28639 this.currentTip = new Roo.bootstrap.Tooltip();
28642 enter : function(ev)
28644 var dom = ev.getTarget();
28646 //Roo.log(['enter',dom]);
28647 var el = Roo.fly(dom);
28648 if (this.currentEl) {
28650 //Roo.log(this.currentEl);
28651 //Roo.log(this.currentEl.contains(dom));
28652 if (this.currentEl == el) {
28655 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
28661 if (this.currentTip.el) {
28662 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
28666 if(!el || el.dom == document){
28672 // you can not look for children, as if el is the body.. then everythign is the child..
28673 if (!el.attr('tooltip')) { //
28674 if (!el.select("[tooltip]").elements.length) {
28677 // is the mouse over this child...?
28678 bindEl = el.select("[tooltip]").first();
28679 var xy = ev.getXY();
28680 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
28681 //Roo.log("not in region.");
28684 //Roo.log("child element over..");
28687 this.currentEl = bindEl;
28688 this.currentTip.bind(bindEl);
28689 this.currentRegion = Roo.lib.Region.getRegion(dom);
28690 this.currentTip.enter();
28693 leave : function(ev)
28695 var dom = ev.getTarget();
28696 //Roo.log(['leave',dom]);
28697 if (!this.currentEl) {
28702 if (dom != this.currentEl.dom) {
28705 var xy = ev.getXY();
28706 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
28709 // only activate leave if mouse cursor is outside... bounding box..
28714 if (this.currentTip) {
28715 this.currentTip.leave();
28717 //Roo.log('clear currentEl');
28718 this.currentEl = false;
28723 'left' : ['r-l', [-2,0], 'right'],
28724 'right' : ['l-r', [2,0], 'left'],
28725 'bottom' : ['t-b', [0,2], 'top'],
28726 'top' : [ 'b-t', [0,-2], 'bottom']
28732 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
28737 delay : null, // can be { show : 300 , hide: 500}
28741 hoverState : null, //???
28743 placement : 'bottom',
28747 getAutoCreate : function(){
28754 cls : 'tooltip-arrow arrow'
28757 cls : 'tooltip-inner'
28764 bind : function(el)
28769 initEvents : function()
28771 this.arrowEl = this.el.select('.arrow', true).first();
28772 this.innerEl = this.el.select('.tooltip-inner', true).first();
28775 enter : function () {
28777 if (this.timeout != null) {
28778 clearTimeout(this.timeout);
28781 this.hoverState = 'in';
28782 //Roo.log("enter - show");
28783 if (!this.delay || !this.delay.show) {
28788 this.timeout = setTimeout(function () {
28789 if (_t.hoverState == 'in') {
28792 }, this.delay.show);
28796 clearTimeout(this.timeout);
28798 this.hoverState = 'out';
28799 if (!this.delay || !this.delay.hide) {
28805 this.timeout = setTimeout(function () {
28806 //Roo.log("leave - timeout");
28808 if (_t.hoverState == 'out') {
28810 Roo.bootstrap.Tooltip.currentEl = false;
28815 show : function (msg)
28818 this.render(document.body);
28821 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
28823 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
28825 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
28827 this.el.removeClass(['fade','top','bottom', 'left', 'right','in',
28828 'bs-tooltip-top','bs-tooltip-bottom', 'bs-tooltip-left', 'bs-tooltip-right']);
28830 var placement = typeof this.placement == 'function' ?
28831 this.placement.call(this, this.el, on_el) :
28834 var autoToken = /\s?auto?\s?/i;
28835 var autoPlace = autoToken.test(placement);
28837 placement = placement.replace(autoToken, '') || 'top';
28841 //this.el.setXY([0,0]);
28843 //this.el.dom.style.display='block';
28845 //this.el.appendTo(on_el);
28847 var p = this.getPosition();
28848 var box = this.el.getBox();
28854 var align = this.alignment[placement];
28856 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
28858 if(placement == 'top' || placement == 'bottom'){
28860 placement = 'right';
28863 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
28864 placement = 'left';
28867 var scroll = Roo.select('body', true).first().getScroll();
28869 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
28873 align = this.alignment[placement];
28875 this.arrowEl.setLeft((this.innerEl.getWidth()/2) - 5);
28879 this.el.alignTo(this.bindEl, align[0],align[1]);
28880 //var arrow = this.el.select('.arrow',true).first();
28881 //arrow.set(align[2],
28883 this.el.addClass(placement);
28884 this.el.addClass("bs-tooltip-"+ placement);
28886 this.el.addClass('in fade show');
28888 this.hoverState = null;
28890 if (this.el.hasClass('fade')) {
28905 //this.el.setXY([0,0]);
28906 this.el.removeClass(['show', 'in']);
28922 * @class Roo.bootstrap.LocationPicker
28923 * @extends Roo.bootstrap.Component
28924 * Bootstrap LocationPicker class
28925 * @cfg {Number} latitude Position when init default 0
28926 * @cfg {Number} longitude Position when init default 0
28927 * @cfg {Number} zoom default 15
28928 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
28929 * @cfg {Boolean} mapTypeControl default false
28930 * @cfg {Boolean} disableDoubleClickZoom default false
28931 * @cfg {Boolean} scrollwheel default true
28932 * @cfg {Boolean} streetViewControl default false
28933 * @cfg {Number} radius default 0
28934 * @cfg {String} locationName
28935 * @cfg {Boolean} draggable default true
28936 * @cfg {Boolean} enableAutocomplete default false
28937 * @cfg {Boolean} enableReverseGeocode default true
28938 * @cfg {String} markerTitle
28941 * Create a new LocationPicker
28942 * @param {Object} config The config object
28946 Roo.bootstrap.LocationPicker = function(config){
28948 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
28953 * Fires when the picker initialized.
28954 * @param {Roo.bootstrap.LocationPicker} this
28955 * @param {Google Location} location
28959 * @event positionchanged
28960 * Fires when the picker position changed.
28961 * @param {Roo.bootstrap.LocationPicker} this
28962 * @param {Google Location} location
28964 positionchanged : true,
28967 * Fires when the map resize.
28968 * @param {Roo.bootstrap.LocationPicker} this
28973 * Fires when the map show.
28974 * @param {Roo.bootstrap.LocationPicker} this
28979 * Fires when the map hide.
28980 * @param {Roo.bootstrap.LocationPicker} this
28985 * Fires when click the map.
28986 * @param {Roo.bootstrap.LocationPicker} this
28987 * @param {Map event} e
28991 * @event mapRightClick
28992 * Fires when right click the map.
28993 * @param {Roo.bootstrap.LocationPicker} this
28994 * @param {Map event} e
28996 mapRightClick : true,
28998 * @event markerClick
28999 * Fires when click the marker.
29000 * @param {Roo.bootstrap.LocationPicker} this
29001 * @param {Map event} e
29003 markerClick : true,
29005 * @event markerRightClick
29006 * Fires when right click the marker.
29007 * @param {Roo.bootstrap.LocationPicker} this
29008 * @param {Map event} e
29010 markerRightClick : true,
29012 * @event OverlayViewDraw
29013 * Fires when OverlayView Draw
29014 * @param {Roo.bootstrap.LocationPicker} this
29016 OverlayViewDraw : true,
29018 * @event OverlayViewOnAdd
29019 * Fires when OverlayView Draw
29020 * @param {Roo.bootstrap.LocationPicker} this
29022 OverlayViewOnAdd : true,
29024 * @event OverlayViewOnRemove
29025 * Fires when OverlayView Draw
29026 * @param {Roo.bootstrap.LocationPicker} this
29028 OverlayViewOnRemove : true,
29030 * @event OverlayViewShow
29031 * Fires when OverlayView Draw
29032 * @param {Roo.bootstrap.LocationPicker} this
29033 * @param {Pixel} cpx
29035 OverlayViewShow : true,
29037 * @event OverlayViewHide
29038 * Fires when OverlayView Draw
29039 * @param {Roo.bootstrap.LocationPicker} this
29041 OverlayViewHide : true,
29043 * @event loadexception
29044 * Fires when load google lib failed.
29045 * @param {Roo.bootstrap.LocationPicker} this
29047 loadexception : true
29052 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
29054 gMapContext: false,
29060 mapTypeControl: false,
29061 disableDoubleClickZoom: false,
29063 streetViewControl: false,
29067 enableAutocomplete: false,
29068 enableReverseGeocode: true,
29071 getAutoCreate: function()
29076 cls: 'roo-location-picker'
29082 initEvents: function(ct, position)
29084 if(!this.el.getWidth() || this.isApplied()){
29088 this.el.setVisibilityMode(Roo.Element.DISPLAY);
29093 initial: function()
29095 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
29096 this.fireEvent('loadexception', this);
29100 if(!this.mapTypeId){
29101 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
29104 this.gMapContext = this.GMapContext();
29106 this.initOverlayView();
29108 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
29112 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
29113 _this.setPosition(_this.gMapContext.marker.position);
29116 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
29117 _this.fireEvent('mapClick', this, event);
29121 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
29122 _this.fireEvent('mapRightClick', this, event);
29126 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
29127 _this.fireEvent('markerClick', this, event);
29131 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
29132 _this.fireEvent('markerRightClick', this, event);
29136 this.setPosition(this.gMapContext.location);
29138 this.fireEvent('initial', this, this.gMapContext.location);
29141 initOverlayView: function()
29145 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
29149 _this.fireEvent('OverlayViewDraw', _this);
29154 _this.fireEvent('OverlayViewOnAdd', _this);
29157 onRemove: function()
29159 _this.fireEvent('OverlayViewOnRemove', _this);
29162 show: function(cpx)
29164 _this.fireEvent('OverlayViewShow', _this, cpx);
29169 _this.fireEvent('OverlayViewHide', _this);
29175 fromLatLngToContainerPixel: function(event)
29177 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
29180 isApplied: function()
29182 return this.getGmapContext() == false ? false : true;
29185 getGmapContext: function()
29187 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
29190 GMapContext: function()
29192 var position = new google.maps.LatLng(this.latitude, this.longitude);
29194 var _map = new google.maps.Map(this.el.dom, {
29197 mapTypeId: this.mapTypeId,
29198 mapTypeControl: this.mapTypeControl,
29199 disableDoubleClickZoom: this.disableDoubleClickZoom,
29200 scrollwheel: this.scrollwheel,
29201 streetViewControl: this.streetViewControl,
29202 locationName: this.locationName,
29203 draggable: this.draggable,
29204 enableAutocomplete: this.enableAutocomplete,
29205 enableReverseGeocode: this.enableReverseGeocode
29208 var _marker = new google.maps.Marker({
29209 position: position,
29211 title: this.markerTitle,
29212 draggable: this.draggable
29219 location: position,
29220 radius: this.radius,
29221 locationName: this.locationName,
29222 addressComponents: {
29223 formatted_address: null,
29224 addressLine1: null,
29225 addressLine2: null,
29227 streetNumber: null,
29231 stateOrProvince: null
29234 domContainer: this.el.dom,
29235 geodecoder: new google.maps.Geocoder()
29239 drawCircle: function(center, radius, options)
29241 if (this.gMapContext.circle != null) {
29242 this.gMapContext.circle.setMap(null);
29246 options = Roo.apply({}, options, {
29247 strokeColor: "#0000FF",
29248 strokeOpacity: .35,
29250 fillColor: "#0000FF",
29254 options.map = this.gMapContext.map;
29255 options.radius = radius;
29256 options.center = center;
29257 this.gMapContext.circle = new google.maps.Circle(options);
29258 return this.gMapContext.circle;
29264 setPosition: function(location)
29266 this.gMapContext.location = location;
29267 this.gMapContext.marker.setPosition(location);
29268 this.gMapContext.map.panTo(location);
29269 this.drawCircle(location, this.gMapContext.radius, {});
29273 if (this.gMapContext.settings.enableReverseGeocode) {
29274 this.gMapContext.geodecoder.geocode({
29275 latLng: this.gMapContext.location
29276 }, function(results, status) {
29278 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
29279 _this.gMapContext.locationName = results[0].formatted_address;
29280 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
29282 _this.fireEvent('positionchanged', this, location);
29289 this.fireEvent('positionchanged', this, location);
29294 google.maps.event.trigger(this.gMapContext.map, "resize");
29296 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
29298 this.fireEvent('resize', this);
29301 setPositionByLatLng: function(latitude, longitude)
29303 this.setPosition(new google.maps.LatLng(latitude, longitude));
29306 getCurrentPosition: function()
29309 latitude: this.gMapContext.location.lat(),
29310 longitude: this.gMapContext.location.lng()
29314 getAddressName: function()
29316 return this.gMapContext.locationName;
29319 getAddressComponents: function()
29321 return this.gMapContext.addressComponents;
29324 address_component_from_google_geocode: function(address_components)
29328 for (var i = 0; i < address_components.length; i++) {
29329 var component = address_components[i];
29330 if (component.types.indexOf("postal_code") >= 0) {
29331 result.postalCode = component.short_name;
29332 } else if (component.types.indexOf("street_number") >= 0) {
29333 result.streetNumber = component.short_name;
29334 } else if (component.types.indexOf("route") >= 0) {
29335 result.streetName = component.short_name;
29336 } else if (component.types.indexOf("neighborhood") >= 0) {
29337 result.city = component.short_name;
29338 } else if (component.types.indexOf("locality") >= 0) {
29339 result.city = component.short_name;
29340 } else if (component.types.indexOf("sublocality") >= 0) {
29341 result.district = component.short_name;
29342 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
29343 result.stateOrProvince = component.short_name;
29344 } else if (component.types.indexOf("country") >= 0) {
29345 result.country = component.short_name;
29349 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
29350 result.addressLine2 = "";
29354 setZoomLevel: function(zoom)
29356 this.gMapContext.map.setZoom(zoom);
29369 this.fireEvent('show', this);
29380 this.fireEvent('hide', this);
29385 Roo.apply(Roo.bootstrap.LocationPicker, {
29387 OverlayView : function(map, options)
29389 options = options || {};
29396 * @class Roo.bootstrap.Alert
29397 * @extends Roo.bootstrap.Component
29398 * Bootstrap Alert class - shows an alert area box
29400 * <div class="alert alert-danger" role="alert"><span class="fa fa-exclamation-triangle"></span><span class="sr-only">Error:</span>
29401 Enter a valid email address
29404 * @cfg {String} title The title of alert
29405 * @cfg {String} html The content of alert
29406 * @cfg {String} weight ( success | info | warning | danger )
29407 * @cfg {String} faicon font-awesomeicon
29410 * Create a new alert
29411 * @param {Object} config The config object
29415 Roo.bootstrap.Alert = function(config){
29416 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
29420 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
29427 getAutoCreate : function()
29436 cls : 'roo-alert-icon'
29441 cls : 'roo-alert-title',
29446 cls : 'roo-alert-text',
29453 cfg.cn[0].cls += ' fa ' + this.faicon;
29457 cfg.cls += ' alert-' + this.weight;
29463 initEvents: function()
29465 this.el.setVisibilityMode(Roo.Element.DISPLAY);
29468 setTitle : function(str)
29470 this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
29473 setText : function(str)
29475 this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
29478 setWeight : function(weight)
29481 this.el.select('.alert',true).first().removeClass('alert-' + this.weight);
29484 this.weight = weight;
29486 this.el.select('.alert',true).first().addClass('alert-' + this.weight);
29489 setIcon : function(icon)
29492 this.el.select('.roo-alert-icon',true).first().removeClass(['fa', 'fa-' + this.faicon]);
29495 this.faicon = icon;
29497 this.el.select('.roo-alert-icon',true).first().addClass(['fa', 'fa-' + this.faicon]);
29518 * @class Roo.bootstrap.UploadCropbox
29519 * @extends Roo.bootstrap.Component
29520 * Bootstrap UploadCropbox class
29521 * @cfg {String} emptyText show when image has been loaded
29522 * @cfg {String} rotateNotify show when image too small to rotate
29523 * @cfg {Number} errorTimeout default 3000
29524 * @cfg {Number} minWidth default 300
29525 * @cfg {Number} minHeight default 300
29526 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
29527 * @cfg {Boolean} isDocument (true|false) default false
29528 * @cfg {String} url action url
29529 * @cfg {String} paramName default 'imageUpload'
29530 * @cfg {String} method default POST
29531 * @cfg {Boolean} loadMask (true|false) default true
29532 * @cfg {Boolean} loadingText default 'Loading...'
29535 * Create a new UploadCropbox
29536 * @param {Object} config The config object
29539 Roo.bootstrap.UploadCropbox = function(config){
29540 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
29544 * @event beforeselectfile
29545 * Fire before select file
29546 * @param {Roo.bootstrap.UploadCropbox} this
29548 "beforeselectfile" : true,
29551 * Fire after initEvent
29552 * @param {Roo.bootstrap.UploadCropbox} this
29557 * Fire after initEvent
29558 * @param {Roo.bootstrap.UploadCropbox} this
29559 * @param {String} data
29564 * Fire when preparing the file data
29565 * @param {Roo.bootstrap.UploadCropbox} this
29566 * @param {Object} file
29571 * Fire when get exception
29572 * @param {Roo.bootstrap.UploadCropbox} this
29573 * @param {XMLHttpRequest} xhr
29575 "exception" : true,
29577 * @event beforeloadcanvas
29578 * Fire before load the canvas
29579 * @param {Roo.bootstrap.UploadCropbox} this
29580 * @param {String} src
29582 "beforeloadcanvas" : true,
29585 * Fire when trash image
29586 * @param {Roo.bootstrap.UploadCropbox} this
29591 * Fire when download the image
29592 * @param {Roo.bootstrap.UploadCropbox} this
29596 * @event footerbuttonclick
29597 * Fire when footerbuttonclick
29598 * @param {Roo.bootstrap.UploadCropbox} this
29599 * @param {String} type
29601 "footerbuttonclick" : true,
29605 * @param {Roo.bootstrap.UploadCropbox} this
29610 * Fire when rotate the image
29611 * @param {Roo.bootstrap.UploadCropbox} this
29612 * @param {String} pos
29617 * Fire when inspect the file
29618 * @param {Roo.bootstrap.UploadCropbox} this
29619 * @param {Object} file
29624 * Fire when xhr upload the file
29625 * @param {Roo.bootstrap.UploadCropbox} this
29626 * @param {Object} data
29631 * Fire when arrange the file data
29632 * @param {Roo.bootstrap.UploadCropbox} this
29633 * @param {Object} formData
29638 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
29641 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
29643 emptyText : 'Click to upload image',
29644 rotateNotify : 'Image is too small to rotate',
29645 errorTimeout : 3000,
29659 cropType : 'image/jpeg',
29661 canvasLoaded : false,
29662 isDocument : false,
29664 paramName : 'imageUpload',
29666 loadingText : 'Loading...',
29669 getAutoCreate : function()
29673 cls : 'roo-upload-cropbox',
29677 cls : 'roo-upload-cropbox-selector',
29682 cls : 'roo-upload-cropbox-body',
29683 style : 'cursor:pointer',
29687 cls : 'roo-upload-cropbox-preview'
29691 cls : 'roo-upload-cropbox-thumb'
29695 cls : 'roo-upload-cropbox-empty-notify',
29696 html : this.emptyText
29700 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
29701 html : this.rotateNotify
29707 cls : 'roo-upload-cropbox-footer',
29710 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
29720 onRender : function(ct, position)
29722 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
29724 if (this.buttons.length) {
29726 Roo.each(this.buttons, function(bb) {
29728 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
29730 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
29736 this.maskEl = this.el;
29740 initEvents : function()
29742 this.urlAPI = (window.createObjectURL && window) ||
29743 (window.URL && URL.revokeObjectURL && URL) ||
29744 (window.webkitURL && webkitURL);
29746 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
29747 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29749 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
29750 this.selectorEl.hide();
29752 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
29753 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29755 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
29756 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29757 this.thumbEl.hide();
29759 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
29760 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29762 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
29763 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29764 this.errorEl.hide();
29766 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
29767 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29768 this.footerEl.hide();
29770 this.setThumbBoxSize();
29776 this.fireEvent('initial', this);
29783 window.addEventListener("resize", function() { _this.resize(); } );
29785 this.bodyEl.on('click', this.beforeSelectFile, this);
29788 this.bodyEl.on('touchstart', this.onTouchStart, this);
29789 this.bodyEl.on('touchmove', this.onTouchMove, this);
29790 this.bodyEl.on('touchend', this.onTouchEnd, this);
29794 this.bodyEl.on('mousedown', this.onMouseDown, this);
29795 this.bodyEl.on('mousemove', this.onMouseMove, this);
29796 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
29797 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
29798 Roo.get(document).on('mouseup', this.onMouseUp, this);
29801 this.selectorEl.on('change', this.onFileSelected, this);
29807 this.baseScale = 1;
29809 this.baseRotate = 1;
29810 this.dragable = false;
29811 this.pinching = false;
29814 this.cropData = false;
29815 this.notifyEl.dom.innerHTML = this.emptyText;
29817 this.selectorEl.dom.value = '';
29821 resize : function()
29823 if(this.fireEvent('resize', this) != false){
29824 this.setThumbBoxPosition();
29825 this.setCanvasPosition();
29829 onFooterButtonClick : function(e, el, o, type)
29832 case 'rotate-left' :
29833 this.onRotateLeft(e);
29835 case 'rotate-right' :
29836 this.onRotateRight(e);
29839 this.beforeSelectFile(e);
29854 this.fireEvent('footerbuttonclick', this, type);
29857 beforeSelectFile : function(e)
29859 e.preventDefault();
29861 if(this.fireEvent('beforeselectfile', this) != false){
29862 this.selectorEl.dom.click();
29866 onFileSelected : function(e)
29868 e.preventDefault();
29870 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
29874 var file = this.selectorEl.dom.files[0];
29876 if(this.fireEvent('inspect', this, file) != false){
29877 this.prepare(file);
29882 trash : function(e)
29884 this.fireEvent('trash', this);
29887 download : function(e)
29889 this.fireEvent('download', this);
29892 loadCanvas : function(src)
29894 if(this.fireEvent('beforeloadcanvas', this, src) != false){
29898 this.imageEl = document.createElement('img');
29902 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
29904 this.imageEl.src = src;
29908 onLoadCanvas : function()
29910 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
29911 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
29913 this.bodyEl.un('click', this.beforeSelectFile, this);
29915 this.notifyEl.hide();
29916 this.thumbEl.show();
29917 this.footerEl.show();
29919 this.baseRotateLevel();
29921 if(this.isDocument){
29922 this.setThumbBoxSize();
29925 this.setThumbBoxPosition();
29927 this.baseScaleLevel();
29933 this.canvasLoaded = true;
29936 this.maskEl.unmask();
29941 setCanvasPosition : function()
29943 if(!this.canvasEl){
29947 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
29948 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
29950 this.previewEl.setLeft(pw);
29951 this.previewEl.setTop(ph);
29955 onMouseDown : function(e)
29959 this.dragable = true;
29960 this.pinching = false;
29962 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
29963 this.dragable = false;
29967 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
29968 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
29972 onMouseMove : function(e)
29976 if(!this.canvasLoaded){
29980 if (!this.dragable){
29984 var minX = Math.ceil(this.thumbEl.getLeft(true));
29985 var minY = Math.ceil(this.thumbEl.getTop(true));
29987 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
29988 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
29990 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
29991 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
29993 x = x - this.mouseX;
29994 y = y - this.mouseY;
29996 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
29997 var bgY = Math.ceil(y + this.previewEl.getTop(true));
29999 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
30000 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
30002 this.previewEl.setLeft(bgX);
30003 this.previewEl.setTop(bgY);
30005 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
30006 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
30009 onMouseUp : function(e)
30013 this.dragable = false;
30016 onMouseWheel : function(e)
30020 this.startScale = this.scale;
30022 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
30024 if(!this.zoomable()){
30025 this.scale = this.startScale;
30034 zoomable : function()
30036 var minScale = this.thumbEl.getWidth() / this.minWidth;
30038 if(this.minWidth < this.minHeight){
30039 minScale = this.thumbEl.getHeight() / this.minHeight;
30042 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
30043 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
30047 (this.rotate == 0 || this.rotate == 180) &&
30049 width > this.imageEl.OriginWidth ||
30050 height > this.imageEl.OriginHeight ||
30051 (width < this.minWidth && height < this.minHeight)
30059 (this.rotate == 90 || this.rotate == 270) &&
30061 width > this.imageEl.OriginWidth ||
30062 height > this.imageEl.OriginHeight ||
30063 (width < this.minHeight && height < this.minWidth)
30070 !this.isDocument &&
30071 (this.rotate == 0 || this.rotate == 180) &&
30073 width < this.minWidth ||
30074 width > this.imageEl.OriginWidth ||
30075 height < this.minHeight ||
30076 height > this.imageEl.OriginHeight
30083 !this.isDocument &&
30084 (this.rotate == 90 || this.rotate == 270) &&
30086 width < this.minHeight ||
30087 width > this.imageEl.OriginWidth ||
30088 height < this.minWidth ||
30089 height > this.imageEl.OriginHeight
30099 onRotateLeft : function(e)
30101 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
30103 var minScale = this.thumbEl.getWidth() / this.minWidth;
30105 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
30106 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
30108 this.startScale = this.scale;
30110 while (this.getScaleLevel() < minScale){
30112 this.scale = this.scale + 1;
30114 if(!this.zoomable()){
30119 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
30120 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
30125 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
30132 this.scale = this.startScale;
30134 this.onRotateFail();
30139 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
30141 if(this.isDocument){
30142 this.setThumbBoxSize();
30143 this.setThumbBoxPosition();
30144 this.setCanvasPosition();
30149 this.fireEvent('rotate', this, 'left');
30153 onRotateRight : function(e)
30155 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
30157 var minScale = this.thumbEl.getWidth() / this.minWidth;
30159 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
30160 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
30162 this.startScale = this.scale;
30164 while (this.getScaleLevel() < minScale){
30166 this.scale = this.scale + 1;
30168 if(!this.zoomable()){
30173 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
30174 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
30179 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
30186 this.scale = this.startScale;
30188 this.onRotateFail();
30193 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
30195 if(this.isDocument){
30196 this.setThumbBoxSize();
30197 this.setThumbBoxPosition();
30198 this.setCanvasPosition();
30203 this.fireEvent('rotate', this, 'right');
30206 onRotateFail : function()
30208 this.errorEl.show(true);
30212 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
30217 this.previewEl.dom.innerHTML = '';
30219 var canvasEl = document.createElement("canvas");
30221 var contextEl = canvasEl.getContext("2d");
30223 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
30224 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
30225 var center = this.imageEl.OriginWidth / 2;
30227 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
30228 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
30229 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
30230 center = this.imageEl.OriginHeight / 2;
30233 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
30235 contextEl.translate(center, center);
30236 contextEl.rotate(this.rotate * Math.PI / 180);
30238 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
30240 this.canvasEl = document.createElement("canvas");
30242 this.contextEl = this.canvasEl.getContext("2d");
30244 switch (this.rotate) {
30247 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
30248 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
30250 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
30255 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
30256 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
30258 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
30259 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);
30263 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
30268 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
30269 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
30271 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
30272 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);
30276 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);
30281 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
30282 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
30284 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
30285 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
30289 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);
30296 this.previewEl.appendChild(this.canvasEl);
30298 this.setCanvasPosition();
30303 if(!this.canvasLoaded){
30307 var imageCanvas = document.createElement("canvas");
30309 var imageContext = imageCanvas.getContext("2d");
30311 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
30312 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
30314 var center = imageCanvas.width / 2;
30316 imageContext.translate(center, center);
30318 imageContext.rotate(this.rotate * Math.PI / 180);
30320 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
30322 var canvas = document.createElement("canvas");
30324 var context = canvas.getContext("2d");
30326 canvas.width = this.minWidth;
30327 canvas.height = this.minHeight;
30329 switch (this.rotate) {
30332 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
30333 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
30335 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
30336 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
30338 var targetWidth = this.minWidth - 2 * x;
30339 var targetHeight = this.minHeight - 2 * y;
30343 if((x == 0 && y == 0) || (x == 0 && y > 0)){
30344 scale = targetWidth / width;
30347 if(x > 0 && y == 0){
30348 scale = targetHeight / height;
30351 if(x > 0 && y > 0){
30352 scale = targetWidth / width;
30354 if(width < height){
30355 scale = targetHeight / height;
30359 context.scale(scale, scale);
30361 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
30362 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
30364 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
30365 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
30367 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
30372 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
30373 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
30375 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
30376 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
30378 var targetWidth = this.minWidth - 2 * x;
30379 var targetHeight = this.minHeight - 2 * y;
30383 if((x == 0 && y == 0) || (x == 0 && y > 0)){
30384 scale = targetWidth / width;
30387 if(x > 0 && y == 0){
30388 scale = targetHeight / height;
30391 if(x > 0 && y > 0){
30392 scale = targetWidth / width;
30394 if(width < height){
30395 scale = targetHeight / height;
30399 context.scale(scale, scale);
30401 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
30402 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
30404 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
30405 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
30407 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
30409 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
30414 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
30415 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
30417 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
30418 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
30420 var targetWidth = this.minWidth - 2 * x;
30421 var targetHeight = this.minHeight - 2 * y;
30425 if((x == 0 && y == 0) || (x == 0 && y > 0)){
30426 scale = targetWidth / width;
30429 if(x > 0 && y == 0){
30430 scale = targetHeight / height;
30433 if(x > 0 && y > 0){
30434 scale = targetWidth / width;
30436 if(width < height){
30437 scale = targetHeight / height;
30441 context.scale(scale, scale);
30443 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
30444 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
30446 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
30447 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
30449 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
30450 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
30452 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
30457 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
30458 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
30460 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
30461 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
30463 var targetWidth = this.minWidth - 2 * x;
30464 var targetHeight = this.minHeight - 2 * y;
30468 if((x == 0 && y == 0) || (x == 0 && y > 0)){
30469 scale = targetWidth / width;
30472 if(x > 0 && y == 0){
30473 scale = targetHeight / height;
30476 if(x > 0 && y > 0){
30477 scale = targetWidth / width;
30479 if(width < height){
30480 scale = targetHeight / height;
30484 context.scale(scale, scale);
30486 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
30487 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
30489 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
30490 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
30492 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
30494 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
30501 this.cropData = canvas.toDataURL(this.cropType);
30503 if(this.fireEvent('crop', this, this.cropData) !== false){
30504 this.process(this.file, this.cropData);
30511 setThumbBoxSize : function()
30515 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
30516 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
30517 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
30519 this.minWidth = width;
30520 this.minHeight = height;
30522 if(this.rotate == 90 || this.rotate == 270){
30523 this.minWidth = height;
30524 this.minHeight = width;
30529 width = Math.ceil(this.minWidth * height / this.minHeight);
30531 if(this.minWidth > this.minHeight){
30533 height = Math.ceil(this.minHeight * width / this.minWidth);
30536 this.thumbEl.setStyle({
30537 width : width + 'px',
30538 height : height + 'px'
30545 setThumbBoxPosition : function()
30547 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
30548 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
30550 this.thumbEl.setLeft(x);
30551 this.thumbEl.setTop(y);
30555 baseRotateLevel : function()
30557 this.baseRotate = 1;
30560 typeof(this.exif) != 'undefined' &&
30561 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
30562 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
30564 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
30567 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
30571 baseScaleLevel : function()
30575 if(this.isDocument){
30577 if(this.baseRotate == 6 || this.baseRotate == 8){
30579 height = this.thumbEl.getHeight();
30580 this.baseScale = height / this.imageEl.OriginWidth;
30582 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
30583 width = this.thumbEl.getWidth();
30584 this.baseScale = width / this.imageEl.OriginHeight;
30590 height = this.thumbEl.getHeight();
30591 this.baseScale = height / this.imageEl.OriginHeight;
30593 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
30594 width = this.thumbEl.getWidth();
30595 this.baseScale = width / this.imageEl.OriginWidth;
30601 if(this.baseRotate == 6 || this.baseRotate == 8){
30603 width = this.thumbEl.getHeight();
30604 this.baseScale = width / this.imageEl.OriginHeight;
30606 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
30607 height = this.thumbEl.getWidth();
30608 this.baseScale = height / this.imageEl.OriginHeight;
30611 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
30612 height = this.thumbEl.getWidth();
30613 this.baseScale = height / this.imageEl.OriginHeight;
30615 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
30616 width = this.thumbEl.getHeight();
30617 this.baseScale = width / this.imageEl.OriginWidth;
30624 width = this.thumbEl.getWidth();
30625 this.baseScale = width / this.imageEl.OriginWidth;
30627 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
30628 height = this.thumbEl.getHeight();
30629 this.baseScale = height / this.imageEl.OriginHeight;
30632 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
30634 height = this.thumbEl.getHeight();
30635 this.baseScale = height / this.imageEl.OriginHeight;
30637 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
30638 width = this.thumbEl.getWidth();
30639 this.baseScale = width / this.imageEl.OriginWidth;
30647 getScaleLevel : function()
30649 return this.baseScale * Math.pow(1.1, this.scale);
30652 onTouchStart : function(e)
30654 if(!this.canvasLoaded){
30655 this.beforeSelectFile(e);
30659 var touches = e.browserEvent.touches;
30665 if(touches.length == 1){
30666 this.onMouseDown(e);
30670 if(touches.length != 2){
30676 for(var i = 0, finger; finger = touches[i]; i++){
30677 coords.push(finger.pageX, finger.pageY);
30680 var x = Math.pow(coords[0] - coords[2], 2);
30681 var y = Math.pow(coords[1] - coords[3], 2);
30683 this.startDistance = Math.sqrt(x + y);
30685 this.startScale = this.scale;
30687 this.pinching = true;
30688 this.dragable = false;
30692 onTouchMove : function(e)
30694 if(!this.pinching && !this.dragable){
30698 var touches = e.browserEvent.touches;
30705 this.onMouseMove(e);
30711 for(var i = 0, finger; finger = touches[i]; i++){
30712 coords.push(finger.pageX, finger.pageY);
30715 var x = Math.pow(coords[0] - coords[2], 2);
30716 var y = Math.pow(coords[1] - coords[3], 2);
30718 this.endDistance = Math.sqrt(x + y);
30720 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
30722 if(!this.zoomable()){
30723 this.scale = this.startScale;
30731 onTouchEnd : function(e)
30733 this.pinching = false;
30734 this.dragable = false;
30738 process : function(file, crop)
30741 this.maskEl.mask(this.loadingText);
30744 this.xhr = new XMLHttpRequest();
30746 file.xhr = this.xhr;
30748 this.xhr.open(this.method, this.url, true);
30751 "Accept": "application/json",
30752 "Cache-Control": "no-cache",
30753 "X-Requested-With": "XMLHttpRequest"
30756 for (var headerName in headers) {
30757 var headerValue = headers[headerName];
30759 this.xhr.setRequestHeader(headerName, headerValue);
30765 this.xhr.onload = function()
30767 _this.xhrOnLoad(_this.xhr);
30770 this.xhr.onerror = function()
30772 _this.xhrOnError(_this.xhr);
30775 var formData = new FormData();
30777 formData.append('returnHTML', 'NO');
30780 formData.append('crop', crop);
30783 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
30784 formData.append(this.paramName, file, file.name);
30787 if(typeof(file.filename) != 'undefined'){
30788 formData.append('filename', file.filename);
30791 if(typeof(file.mimetype) != 'undefined'){
30792 formData.append('mimetype', file.mimetype);
30795 if(this.fireEvent('arrange', this, formData) != false){
30796 this.xhr.send(formData);
30800 xhrOnLoad : function(xhr)
30803 this.maskEl.unmask();
30806 if (xhr.readyState !== 4) {
30807 this.fireEvent('exception', this, xhr);
30811 var response = Roo.decode(xhr.responseText);
30813 if(!response.success){
30814 this.fireEvent('exception', this, xhr);
30818 var response = Roo.decode(xhr.responseText);
30820 this.fireEvent('upload', this, response);
30824 xhrOnError : function()
30827 this.maskEl.unmask();
30830 Roo.log('xhr on error');
30832 var response = Roo.decode(xhr.responseText);
30838 prepare : function(file)
30841 this.maskEl.mask(this.loadingText);
30847 if(typeof(file) === 'string'){
30848 this.loadCanvas(file);
30852 if(!file || !this.urlAPI){
30857 this.cropType = file.type;
30861 if(this.fireEvent('prepare', this, this.file) != false){
30863 var reader = new FileReader();
30865 reader.onload = function (e) {
30866 if (e.target.error) {
30867 Roo.log(e.target.error);
30871 var buffer = e.target.result,
30872 dataView = new DataView(buffer),
30874 maxOffset = dataView.byteLength - 4,
30878 if (dataView.getUint16(0) === 0xffd8) {
30879 while (offset < maxOffset) {
30880 markerBytes = dataView.getUint16(offset);
30882 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
30883 markerLength = dataView.getUint16(offset + 2) + 2;
30884 if (offset + markerLength > dataView.byteLength) {
30885 Roo.log('Invalid meta data: Invalid segment size.');
30889 if(markerBytes == 0xffe1){
30890 _this.parseExifData(
30897 offset += markerLength;
30907 var url = _this.urlAPI.createObjectURL(_this.file);
30909 _this.loadCanvas(url);
30914 reader.readAsArrayBuffer(this.file);
30920 parseExifData : function(dataView, offset, length)
30922 var tiffOffset = offset + 10,
30926 if (dataView.getUint32(offset + 4) !== 0x45786966) {
30927 // No Exif data, might be XMP data instead
30931 // Check for the ASCII code for "Exif" (0x45786966):
30932 if (dataView.getUint32(offset + 4) !== 0x45786966) {
30933 // No Exif data, might be XMP data instead
30936 if (tiffOffset + 8 > dataView.byteLength) {
30937 Roo.log('Invalid Exif data: Invalid segment size.');
30940 // Check for the two null bytes:
30941 if (dataView.getUint16(offset + 8) !== 0x0000) {
30942 Roo.log('Invalid Exif data: Missing byte alignment offset.');
30945 // Check the byte alignment:
30946 switch (dataView.getUint16(tiffOffset)) {
30948 littleEndian = true;
30951 littleEndian = false;
30954 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
30957 // Check for the TIFF tag marker (0x002A):
30958 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
30959 Roo.log('Invalid Exif data: Missing TIFF marker.');
30962 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
30963 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
30965 this.parseExifTags(
30968 tiffOffset + dirOffset,
30973 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
30978 if (dirOffset + 6 > dataView.byteLength) {
30979 Roo.log('Invalid Exif data: Invalid directory offset.');
30982 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
30983 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
30984 if (dirEndOffset + 4 > dataView.byteLength) {
30985 Roo.log('Invalid Exif data: Invalid directory size.');
30988 for (i = 0; i < tagsNumber; i += 1) {
30992 dirOffset + 2 + 12 * i, // tag offset
30996 // Return the offset to the next directory:
30997 return dataView.getUint32(dirEndOffset, littleEndian);
31000 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
31002 var tag = dataView.getUint16(offset, littleEndian);
31004 this.exif[tag] = this.getExifValue(
31008 dataView.getUint16(offset + 2, littleEndian), // tag type
31009 dataView.getUint32(offset + 4, littleEndian), // tag length
31014 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
31016 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
31025 Roo.log('Invalid Exif data: Invalid tag type.');
31029 tagSize = tagType.size * length;
31030 // Determine if the value is contained in the dataOffset bytes,
31031 // or if the value at the dataOffset is a pointer to the actual data:
31032 dataOffset = tagSize > 4 ?
31033 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
31034 if (dataOffset + tagSize > dataView.byteLength) {
31035 Roo.log('Invalid Exif data: Invalid data offset.');
31038 if (length === 1) {
31039 return tagType.getValue(dataView, dataOffset, littleEndian);
31042 for (i = 0; i < length; i += 1) {
31043 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
31046 if (tagType.ascii) {
31048 // Concatenate the chars:
31049 for (i = 0; i < values.length; i += 1) {
31051 // Ignore the terminating NULL byte(s):
31052 if (c === '\u0000') {
31064 Roo.apply(Roo.bootstrap.UploadCropbox, {
31066 'Orientation': 0x0112
31070 1: 0, //'top-left',
31072 3: 180, //'bottom-right',
31073 // 4: 'bottom-left',
31075 6: 90, //'right-top',
31076 // 7: 'right-bottom',
31077 8: 270 //'left-bottom'
31081 // byte, 8-bit unsigned int:
31083 getValue: function (dataView, dataOffset) {
31084 return dataView.getUint8(dataOffset);
31088 // ascii, 8-bit byte:
31090 getValue: function (dataView, dataOffset) {
31091 return String.fromCharCode(dataView.getUint8(dataOffset));
31096 // short, 16 bit int:
31098 getValue: function (dataView, dataOffset, littleEndian) {
31099 return dataView.getUint16(dataOffset, littleEndian);
31103 // long, 32 bit int:
31105 getValue: function (dataView, dataOffset, littleEndian) {
31106 return dataView.getUint32(dataOffset, littleEndian);
31110 // rational = two long values, first is numerator, second is denominator:
31112 getValue: function (dataView, dataOffset, littleEndian) {
31113 return dataView.getUint32(dataOffset, littleEndian) /
31114 dataView.getUint32(dataOffset + 4, littleEndian);
31118 // slong, 32 bit signed int:
31120 getValue: function (dataView, dataOffset, littleEndian) {
31121 return dataView.getInt32(dataOffset, littleEndian);
31125 // srational, two slongs, first is numerator, second is denominator:
31127 getValue: function (dataView, dataOffset, littleEndian) {
31128 return dataView.getInt32(dataOffset, littleEndian) /
31129 dataView.getInt32(dataOffset + 4, littleEndian);
31139 cls : 'btn-group roo-upload-cropbox-rotate-left',
31140 action : 'rotate-left',
31144 cls : 'btn btn-default',
31145 html : '<i class="fa fa-undo"></i>'
31151 cls : 'btn-group roo-upload-cropbox-picture',
31152 action : 'picture',
31156 cls : 'btn btn-default',
31157 html : '<i class="fa fa-picture-o"></i>'
31163 cls : 'btn-group roo-upload-cropbox-rotate-right',
31164 action : 'rotate-right',
31168 cls : 'btn btn-default',
31169 html : '<i class="fa fa-repeat"></i>'
31177 cls : 'btn-group roo-upload-cropbox-rotate-left',
31178 action : 'rotate-left',
31182 cls : 'btn btn-default',
31183 html : '<i class="fa fa-undo"></i>'
31189 cls : 'btn-group roo-upload-cropbox-download',
31190 action : 'download',
31194 cls : 'btn btn-default',
31195 html : '<i class="fa fa-download"></i>'
31201 cls : 'btn-group roo-upload-cropbox-crop',
31206 cls : 'btn btn-default',
31207 html : '<i class="fa fa-crop"></i>'
31213 cls : 'btn-group roo-upload-cropbox-trash',
31218 cls : 'btn btn-default',
31219 html : '<i class="fa fa-trash"></i>'
31225 cls : 'btn-group roo-upload-cropbox-rotate-right',
31226 action : 'rotate-right',
31230 cls : 'btn btn-default',
31231 html : '<i class="fa fa-repeat"></i>'
31239 cls : 'btn-group roo-upload-cropbox-rotate-left',
31240 action : 'rotate-left',
31244 cls : 'btn btn-default',
31245 html : '<i class="fa fa-undo"></i>'
31251 cls : 'btn-group roo-upload-cropbox-rotate-right',
31252 action : 'rotate-right',
31256 cls : 'btn btn-default',
31257 html : '<i class="fa fa-repeat"></i>'
31270 * @class Roo.bootstrap.DocumentManager
31271 * @extends Roo.bootstrap.Component
31272 * Bootstrap DocumentManager class
31273 * @cfg {String} paramName default 'imageUpload'
31274 * @cfg {String} toolTipName default 'filename'
31275 * @cfg {String} method default POST
31276 * @cfg {String} url action url
31277 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
31278 * @cfg {Boolean} multiple multiple upload default true
31279 * @cfg {Number} thumbSize default 300
31280 * @cfg {String} fieldLabel
31281 * @cfg {Number} labelWidth default 4
31282 * @cfg {String} labelAlign (left|top) default left
31283 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
31284 * @cfg {Number} labellg set the width of label (1-12)
31285 * @cfg {Number} labelmd set the width of label (1-12)
31286 * @cfg {Number} labelsm set the width of label (1-12)
31287 * @cfg {Number} labelxs set the width of label (1-12)
31290 * Create a new DocumentManager
31291 * @param {Object} config The config object
31294 Roo.bootstrap.DocumentManager = function(config){
31295 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
31298 this.delegates = [];
31303 * Fire when initial the DocumentManager
31304 * @param {Roo.bootstrap.DocumentManager} this
31309 * inspect selected file
31310 * @param {Roo.bootstrap.DocumentManager} this
31311 * @param {File} file
31316 * Fire when xhr load exception
31317 * @param {Roo.bootstrap.DocumentManager} this
31318 * @param {XMLHttpRequest} xhr
31320 "exception" : true,
31322 * @event afterupload
31323 * Fire when xhr load exception
31324 * @param {Roo.bootstrap.DocumentManager} this
31325 * @param {XMLHttpRequest} xhr
31327 "afterupload" : true,
31330 * prepare the form data
31331 * @param {Roo.bootstrap.DocumentManager} this
31332 * @param {Object} formData
31337 * Fire when remove the file
31338 * @param {Roo.bootstrap.DocumentManager} this
31339 * @param {Object} file
31344 * Fire after refresh the file
31345 * @param {Roo.bootstrap.DocumentManager} this
31350 * Fire after click the image
31351 * @param {Roo.bootstrap.DocumentManager} this
31352 * @param {Object} file
31357 * Fire when upload a image and editable set to true
31358 * @param {Roo.bootstrap.DocumentManager} this
31359 * @param {Object} file
31363 * @event beforeselectfile
31364 * Fire before select file
31365 * @param {Roo.bootstrap.DocumentManager} this
31367 "beforeselectfile" : true,
31370 * Fire before process file
31371 * @param {Roo.bootstrap.DocumentManager} this
31372 * @param {Object} file
31376 * @event previewrendered
31377 * Fire when preview rendered
31378 * @param {Roo.bootstrap.DocumentManager} this
31379 * @param {Object} file
31381 "previewrendered" : true,
31384 "previewResize" : true
31389 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
31398 paramName : 'imageUpload',
31399 toolTipName : 'filename',
31402 labelAlign : 'left',
31412 getAutoCreate : function()
31414 var managerWidget = {
31416 cls : 'roo-document-manager',
31420 cls : 'roo-document-manager-selector',
31425 cls : 'roo-document-manager-uploader',
31429 cls : 'roo-document-manager-upload-btn',
31430 html : '<i class="fa fa-plus"></i>'
31441 cls : 'column col-md-12',
31446 if(this.fieldLabel.length){
31451 cls : 'column col-md-12',
31452 html : this.fieldLabel
31456 cls : 'column col-md-12',
31461 if(this.labelAlign == 'left'){
31466 html : this.fieldLabel
31475 if(this.labelWidth > 12){
31476 content[0].style = "width: " + this.labelWidth + 'px';
31479 if(this.labelWidth < 13 && this.labelmd == 0){
31480 this.labelmd = this.labelWidth;
31483 if(this.labellg > 0){
31484 content[0].cls += ' col-lg-' + this.labellg;
31485 content[1].cls += ' col-lg-' + (12 - this.labellg);
31488 if(this.labelmd > 0){
31489 content[0].cls += ' col-md-' + this.labelmd;
31490 content[1].cls += ' col-md-' + (12 - this.labelmd);
31493 if(this.labelsm > 0){
31494 content[0].cls += ' col-sm-' + this.labelsm;
31495 content[1].cls += ' col-sm-' + (12 - this.labelsm);
31498 if(this.labelxs > 0){
31499 content[0].cls += ' col-xs-' + this.labelxs;
31500 content[1].cls += ' col-xs-' + (12 - this.labelxs);
31508 cls : 'row clearfix',
31516 initEvents : function()
31518 this.managerEl = this.el.select('.roo-document-manager', true).first();
31519 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
31521 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
31522 this.selectorEl.hide();
31525 this.selectorEl.attr('multiple', 'multiple');
31528 this.selectorEl.on('change', this.onFileSelected, this);
31530 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
31531 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
31533 this.uploader.on('click', this.onUploaderClick, this);
31535 this.renderProgressDialog();
31539 window.addEventListener("resize", function() { _this.refresh(); } );
31541 this.fireEvent('initial', this);
31544 renderProgressDialog : function()
31548 this.progressDialog = new Roo.bootstrap.Modal({
31549 cls : 'roo-document-manager-progress-dialog',
31550 allow_close : false,
31561 btnclick : function() {
31562 _this.uploadCancel();
31568 this.progressDialog.render(Roo.get(document.body));
31570 this.progress = new Roo.bootstrap.Progress({
31571 cls : 'roo-document-manager-progress',
31576 this.progress.render(this.progressDialog.getChildContainer());
31578 this.progressBar = new Roo.bootstrap.ProgressBar({
31579 cls : 'roo-document-manager-progress-bar',
31582 aria_valuemax : 12,
31586 this.progressBar.render(this.progress.getChildContainer());
31589 onUploaderClick : function(e)
31591 e.preventDefault();
31593 if(this.fireEvent('beforeselectfile', this) != false){
31594 this.selectorEl.dom.click();
31599 onFileSelected : function(e)
31601 e.preventDefault();
31603 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
31607 Roo.each(this.selectorEl.dom.files, function(file){
31608 if(this.fireEvent('inspect', this, file) != false){
31609 this.files.push(file);
31619 this.selectorEl.dom.value = '';
31621 if(!this.files || !this.files.length){
31625 if(this.boxes > 0 && this.files.length > this.boxes){
31626 this.files = this.files.slice(0, this.boxes);
31629 this.uploader.show();
31631 if(this.boxes > 0 && this.files.length > this.boxes - 1){
31632 this.uploader.hide();
31641 Roo.each(this.files, function(file){
31643 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
31644 var f = this.renderPreview(file);
31649 if(file.type.indexOf('image') != -1){
31650 this.delegates.push(
31652 _this.process(file);
31653 }).createDelegate(this)
31661 _this.process(file);
31662 }).createDelegate(this)
31667 this.files = files;
31669 this.delegates = this.delegates.concat(docs);
31671 if(!this.delegates.length){
31676 this.progressBar.aria_valuemax = this.delegates.length;
31683 arrange : function()
31685 if(!this.delegates.length){
31686 this.progressDialog.hide();
31691 var delegate = this.delegates.shift();
31693 this.progressDialog.show();
31695 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
31697 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
31702 refresh : function()
31704 this.uploader.show();
31706 if(this.boxes > 0 && this.files.length > this.boxes - 1){
31707 this.uploader.hide();
31710 Roo.isTouch ? this.closable(false) : this.closable(true);
31712 this.fireEvent('refresh', this);
31715 onRemove : function(e, el, o)
31717 e.preventDefault();
31719 this.fireEvent('remove', this, o);
31723 remove : function(o)
31727 Roo.each(this.files, function(file){
31728 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
31737 this.files = files;
31744 Roo.each(this.files, function(file){
31749 file.target.remove();
31758 onClick : function(e, el, o)
31760 e.preventDefault();
31762 this.fireEvent('click', this, o);
31766 closable : function(closable)
31768 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
31770 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
31782 xhrOnLoad : function(xhr)
31784 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
31788 if (xhr.readyState !== 4) {
31790 this.fireEvent('exception', this, xhr);
31794 var response = Roo.decode(xhr.responseText);
31796 if(!response.success){
31798 this.fireEvent('exception', this, xhr);
31802 var file = this.renderPreview(response.data);
31804 this.files.push(file);
31808 this.fireEvent('afterupload', this, xhr);
31812 xhrOnError : function(xhr)
31814 Roo.log('xhr on error');
31816 var response = Roo.decode(xhr.responseText);
31823 process : function(file)
31825 if(this.fireEvent('process', this, file) !== false){
31826 if(this.editable && file.type.indexOf('image') != -1){
31827 this.fireEvent('edit', this, file);
31831 this.uploadStart(file, false);
31838 uploadStart : function(file, crop)
31840 this.xhr = new XMLHttpRequest();
31842 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
31847 file.xhr = this.xhr;
31849 this.managerEl.createChild({
31851 cls : 'roo-document-manager-loading',
31855 tooltip : file.name,
31856 cls : 'roo-document-manager-thumb',
31857 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
31863 this.xhr.open(this.method, this.url, true);
31866 "Accept": "application/json",
31867 "Cache-Control": "no-cache",
31868 "X-Requested-With": "XMLHttpRequest"
31871 for (var headerName in headers) {
31872 var headerValue = headers[headerName];
31874 this.xhr.setRequestHeader(headerName, headerValue);
31880 this.xhr.onload = function()
31882 _this.xhrOnLoad(_this.xhr);
31885 this.xhr.onerror = function()
31887 _this.xhrOnError(_this.xhr);
31890 var formData = new FormData();
31892 formData.append('returnHTML', 'NO');
31895 formData.append('crop', crop);
31898 formData.append(this.paramName, file, file.name);
31905 if(this.fireEvent('prepare', this, formData, options) != false){
31907 if(options.manually){
31911 this.xhr.send(formData);
31915 this.uploadCancel();
31918 uploadCancel : function()
31924 this.delegates = [];
31926 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
31933 renderPreview : function(file)
31935 if(typeof(file.target) != 'undefined' && file.target){
31939 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
31941 var previewEl = this.managerEl.createChild({
31943 cls : 'roo-document-manager-preview',
31947 tooltip : file[this.toolTipName],
31948 cls : 'roo-document-manager-thumb',
31949 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
31954 html : '<i class="fa fa-times-circle"></i>'
31959 var close = previewEl.select('button.close', true).first();
31961 close.on('click', this.onRemove, this, file);
31963 file.target = previewEl;
31965 var image = previewEl.select('img', true).first();
31969 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
31971 image.on('click', this.onClick, this, file);
31973 this.fireEvent('previewrendered', this, file);
31979 onPreviewLoad : function(file, image)
31981 if(typeof(file.target) == 'undefined' || !file.target){
31985 var width = image.dom.naturalWidth || image.dom.width;
31986 var height = image.dom.naturalHeight || image.dom.height;
31988 if(!this.previewResize) {
31992 if(width > height){
31993 file.target.addClass('wide');
31997 file.target.addClass('tall');
32002 uploadFromSource : function(file, crop)
32004 this.xhr = new XMLHttpRequest();
32006 this.managerEl.createChild({
32008 cls : 'roo-document-manager-loading',
32012 tooltip : file.name,
32013 cls : 'roo-document-manager-thumb',
32014 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
32020 this.xhr.open(this.method, this.url, true);
32023 "Accept": "application/json",
32024 "Cache-Control": "no-cache",
32025 "X-Requested-With": "XMLHttpRequest"
32028 for (var headerName in headers) {
32029 var headerValue = headers[headerName];
32031 this.xhr.setRequestHeader(headerName, headerValue);
32037 this.xhr.onload = function()
32039 _this.xhrOnLoad(_this.xhr);
32042 this.xhr.onerror = function()
32044 _this.xhrOnError(_this.xhr);
32047 var formData = new FormData();
32049 formData.append('returnHTML', 'NO');
32051 formData.append('crop', crop);
32053 if(typeof(file.filename) != 'undefined'){
32054 formData.append('filename', file.filename);
32057 if(typeof(file.mimetype) != 'undefined'){
32058 formData.append('mimetype', file.mimetype);
32063 if(this.fireEvent('prepare', this, formData) != false){
32064 this.xhr.send(formData);
32074 * @class Roo.bootstrap.DocumentViewer
32075 * @extends Roo.bootstrap.Component
32076 * Bootstrap DocumentViewer class
32077 * @cfg {Boolean} showDownload (true|false) show download button (default true)
32078 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
32081 * Create a new DocumentViewer
32082 * @param {Object} config The config object
32085 Roo.bootstrap.DocumentViewer = function(config){
32086 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
32091 * Fire after initEvent
32092 * @param {Roo.bootstrap.DocumentViewer} this
32098 * @param {Roo.bootstrap.DocumentViewer} this
32103 * Fire after download button
32104 * @param {Roo.bootstrap.DocumentViewer} this
32109 * Fire after trash button
32110 * @param {Roo.bootstrap.DocumentViewer} this
32117 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
32119 showDownload : true,
32123 getAutoCreate : function()
32127 cls : 'roo-document-viewer',
32131 cls : 'roo-document-viewer-body',
32135 cls : 'roo-document-viewer-thumb',
32139 cls : 'roo-document-viewer-image'
32147 cls : 'roo-document-viewer-footer',
32150 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
32154 cls : 'btn-group roo-document-viewer-download',
32158 cls : 'btn btn-default',
32159 html : '<i class="fa fa-download"></i>'
32165 cls : 'btn-group roo-document-viewer-trash',
32169 cls : 'btn btn-default',
32170 html : '<i class="fa fa-trash"></i>'
32183 initEvents : function()
32185 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
32186 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
32188 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
32189 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
32191 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
32192 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
32194 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
32195 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
32197 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
32198 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
32200 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
32201 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
32203 this.bodyEl.on('click', this.onClick, this);
32204 this.downloadBtn.on('click', this.onDownload, this);
32205 this.trashBtn.on('click', this.onTrash, this);
32207 this.downloadBtn.hide();
32208 this.trashBtn.hide();
32210 if(this.showDownload){
32211 this.downloadBtn.show();
32214 if(this.showTrash){
32215 this.trashBtn.show();
32218 if(!this.showDownload && !this.showTrash) {
32219 this.footerEl.hide();
32224 initial : function()
32226 this.fireEvent('initial', this);
32230 onClick : function(e)
32232 e.preventDefault();
32234 this.fireEvent('click', this);
32237 onDownload : function(e)
32239 e.preventDefault();
32241 this.fireEvent('download', this);
32244 onTrash : function(e)
32246 e.preventDefault();
32248 this.fireEvent('trash', this);
32260 * @class Roo.bootstrap.NavProgressBar
32261 * @extends Roo.bootstrap.Component
32262 * Bootstrap NavProgressBar class
32265 * Create a new nav progress bar
32266 * @param {Object} config The config object
32269 Roo.bootstrap.NavProgressBar = function(config){
32270 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
32272 this.bullets = this.bullets || [];
32274 // Roo.bootstrap.NavProgressBar.register(this);
32278 * Fires when the active item changes
32279 * @param {Roo.bootstrap.NavProgressBar} this
32280 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
32281 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
32288 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
32293 getAutoCreate : function()
32295 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
32299 cls : 'roo-navigation-bar-group',
32303 cls : 'roo-navigation-top-bar'
32307 cls : 'roo-navigation-bullets-bar',
32311 cls : 'roo-navigation-bar'
32318 cls : 'roo-navigation-bottom-bar'
32328 initEvents: function()
32333 onRender : function(ct, position)
32335 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
32337 if(this.bullets.length){
32338 Roo.each(this.bullets, function(b){
32347 addItem : function(cfg)
32349 var item = new Roo.bootstrap.NavProgressItem(cfg);
32351 item.parentId = this.id;
32352 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
32355 var top = new Roo.bootstrap.Element({
32357 cls : 'roo-navigation-bar-text'
32360 var bottom = new Roo.bootstrap.Element({
32362 cls : 'roo-navigation-bar-text'
32365 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
32366 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
32368 var topText = new Roo.bootstrap.Element({
32370 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
32373 var bottomText = new Roo.bootstrap.Element({
32375 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
32378 topText.onRender(top.el, null);
32379 bottomText.onRender(bottom.el, null);
32382 item.bottomEl = bottom;
32385 this.barItems.push(item);
32390 getActive : function()
32392 var active = false;
32394 Roo.each(this.barItems, function(v){
32396 if (!v.isActive()) {
32408 setActiveItem : function(item)
32412 Roo.each(this.barItems, function(v){
32413 if (v.rid == item.rid) {
32417 if (v.isActive()) {
32418 v.setActive(false);
32423 item.setActive(true);
32425 this.fireEvent('changed', this, item, prev);
32428 getBarItem: function(rid)
32432 Roo.each(this.barItems, function(e) {
32433 if (e.rid != rid) {
32444 indexOfItem : function(item)
32448 Roo.each(this.barItems, function(v, i){
32450 if (v.rid != item.rid) {
32461 setActiveNext : function()
32463 var i = this.indexOfItem(this.getActive());
32465 if (i > this.barItems.length) {
32469 this.setActiveItem(this.barItems[i+1]);
32472 setActivePrev : function()
32474 var i = this.indexOfItem(this.getActive());
32480 this.setActiveItem(this.barItems[i-1]);
32483 format : function()
32485 if(!this.barItems.length){
32489 var width = 100 / this.barItems.length;
32491 Roo.each(this.barItems, function(i){
32492 i.el.setStyle('width', width + '%');
32493 i.topEl.el.setStyle('width', width + '%');
32494 i.bottomEl.el.setStyle('width', width + '%');
32503 * Nav Progress Item
32508 * @class Roo.bootstrap.NavProgressItem
32509 * @extends Roo.bootstrap.Component
32510 * Bootstrap NavProgressItem class
32511 * @cfg {String} rid the reference id
32512 * @cfg {Boolean} active (true|false) Is item active default false
32513 * @cfg {Boolean} disabled (true|false) Is item active default false
32514 * @cfg {String} html
32515 * @cfg {String} position (top|bottom) text position default bottom
32516 * @cfg {String} icon show icon instead of number
32519 * Create a new NavProgressItem
32520 * @param {Object} config The config object
32522 Roo.bootstrap.NavProgressItem = function(config){
32523 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
32528 * The raw click event for the entire grid.
32529 * @param {Roo.bootstrap.NavProgressItem} this
32530 * @param {Roo.EventObject} e
32537 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
32543 position : 'bottom',
32546 getAutoCreate : function()
32548 var iconCls = 'roo-navigation-bar-item-icon';
32550 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
32554 cls: 'roo-navigation-bar-item',
32564 cfg.cls += ' active';
32567 cfg.cls += ' disabled';
32573 disable : function()
32575 this.setDisabled(true);
32578 enable : function()
32580 this.setDisabled(false);
32583 initEvents: function()
32585 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
32587 this.iconEl.on('click', this.onClick, this);
32590 onClick : function(e)
32592 e.preventDefault();
32598 if(this.fireEvent('click', this, e) === false){
32602 this.parent().setActiveItem(this);
32605 isActive: function ()
32607 return this.active;
32610 setActive : function(state)
32612 if(this.active == state){
32616 this.active = state;
32619 this.el.addClass('active');
32623 this.el.removeClass('active');
32628 setDisabled : function(state)
32630 if(this.disabled == state){
32634 this.disabled = state;
32637 this.el.addClass('disabled');
32641 this.el.removeClass('disabled');
32644 tooltipEl : function()
32646 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
32659 * @class Roo.bootstrap.FieldLabel
32660 * @extends Roo.bootstrap.Component
32661 * Bootstrap FieldLabel class
32662 * @cfg {String} html contents of the element
32663 * @cfg {String} tag tag of the element default label
32664 * @cfg {String} cls class of the element
32665 * @cfg {String} target label target
32666 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
32667 * @cfg {String} invalidClass DEPRICATED - BS4 uses is-invalid
32668 * @cfg {String} validClass DEPRICATED - BS4 uses is-valid
32669 * @cfg {String} iconTooltip default "This field is required"
32670 * @cfg {String} indicatorpos (left|right) default left
32673 * Create a new FieldLabel
32674 * @param {Object} config The config object
32677 Roo.bootstrap.FieldLabel = function(config){
32678 Roo.bootstrap.Element.superclass.constructor.call(this, config);
32683 * Fires after the field has been marked as invalid.
32684 * @param {Roo.form.FieldLabel} this
32685 * @param {String} msg The validation message
32690 * Fires after the field has been validated with no errors.
32691 * @param {Roo.form.FieldLabel} this
32697 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
32704 invalidClass : 'has-warning',
32705 validClass : 'has-success',
32706 iconTooltip : 'This field is required',
32707 indicatorpos : 'left',
32709 getAutoCreate : function(){
32712 if (!this.allowBlank) {
32718 cls : 'roo-bootstrap-field-label ' + this.cls,
32723 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star ' + cls,
32724 tooltip : this.iconTooltip
32733 if(this.indicatorpos == 'right'){
32736 cls : 'roo-bootstrap-field-label ' + this.cls,
32745 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star '+ cls,
32746 tooltip : this.iconTooltip
32755 initEvents: function()
32757 Roo.bootstrap.Element.superclass.initEvents.call(this);
32759 this.indicator = this.indicatorEl();
32761 if(this.indicator){
32762 this.indicator.removeClass('visible');
32763 this.indicator.addClass('invisible');
32766 Roo.bootstrap.FieldLabel.register(this);
32769 indicatorEl : function()
32771 var indicator = this.el.select('i.roo-required-indicator',true).first();
32782 * Mark this field as valid
32784 markValid : function()
32786 if(this.indicator){
32787 this.indicator.removeClass('visible');
32788 this.indicator.addClass('invisible');
32790 if (Roo.bootstrap.version == 3) {
32791 this.el.removeClass(this.invalidClass);
32792 this.el.addClass(this.validClass);
32794 this.el.removeClass('is-invalid');
32795 this.el.addClass('is-valid');
32799 this.fireEvent('valid', this);
32803 * Mark this field as invalid
32804 * @param {String} msg The validation message
32806 markInvalid : function(msg)
32808 if(this.indicator){
32809 this.indicator.removeClass('invisible');
32810 this.indicator.addClass('visible');
32812 if (Roo.bootstrap.version == 3) {
32813 this.el.removeClass(this.validClass);
32814 this.el.addClass(this.invalidClass);
32816 this.el.removeClass('is-valid');
32817 this.el.addClass('is-invalid');
32821 this.fireEvent('invalid', this, msg);
32827 Roo.apply(Roo.bootstrap.FieldLabel, {
32832 * register a FieldLabel Group
32833 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
32835 register : function(label)
32837 if(this.groups.hasOwnProperty(label.target)){
32841 this.groups[label.target] = label;
32845 * fetch a FieldLabel Group based on the target
32846 * @param {string} target
32847 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
32849 get: function(target) {
32850 if (typeof(this.groups[target]) == 'undefined') {
32854 return this.groups[target] ;
32863 * page DateSplitField.
32869 * @class Roo.bootstrap.DateSplitField
32870 * @extends Roo.bootstrap.Component
32871 * Bootstrap DateSplitField class
32872 * @cfg {string} fieldLabel - the label associated
32873 * @cfg {Number} labelWidth set the width of label (0-12)
32874 * @cfg {String} labelAlign (top|left)
32875 * @cfg {Boolean} dayAllowBlank (true|false) default false
32876 * @cfg {Boolean} monthAllowBlank (true|false) default false
32877 * @cfg {Boolean} yearAllowBlank (true|false) default false
32878 * @cfg {string} dayPlaceholder
32879 * @cfg {string} monthPlaceholder
32880 * @cfg {string} yearPlaceholder
32881 * @cfg {string} dayFormat default 'd'
32882 * @cfg {string} monthFormat default 'm'
32883 * @cfg {string} yearFormat default 'Y'
32884 * @cfg {Number} labellg set the width of label (1-12)
32885 * @cfg {Number} labelmd set the width of label (1-12)
32886 * @cfg {Number} labelsm set the width of label (1-12)
32887 * @cfg {Number} labelxs set the width of label (1-12)
32891 * Create a new DateSplitField
32892 * @param {Object} config The config object
32895 Roo.bootstrap.DateSplitField = function(config){
32896 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
32902 * getting the data of years
32903 * @param {Roo.bootstrap.DateSplitField} this
32904 * @param {Object} years
32909 * getting the data of days
32910 * @param {Roo.bootstrap.DateSplitField} this
32911 * @param {Object} days
32916 * Fires after the field has been marked as invalid.
32917 * @param {Roo.form.Field} this
32918 * @param {String} msg The validation message
32923 * Fires after the field has been validated with no errors.
32924 * @param {Roo.form.Field} this
32930 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
32933 labelAlign : 'top',
32935 dayAllowBlank : false,
32936 monthAllowBlank : false,
32937 yearAllowBlank : false,
32938 dayPlaceholder : '',
32939 monthPlaceholder : '',
32940 yearPlaceholder : '',
32944 isFormField : true,
32950 getAutoCreate : function()
32954 cls : 'row roo-date-split-field-group',
32959 cls : 'form-hidden-field roo-date-split-field-group-value',
32965 var labelCls = 'col-md-12';
32966 var contentCls = 'col-md-4';
32968 if(this.fieldLabel){
32972 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
32976 html : this.fieldLabel
32981 if(this.labelAlign == 'left'){
32983 if(this.labelWidth > 12){
32984 label.style = "width: " + this.labelWidth + 'px';
32987 if(this.labelWidth < 13 && this.labelmd == 0){
32988 this.labelmd = this.labelWidth;
32991 if(this.labellg > 0){
32992 labelCls = ' col-lg-' + this.labellg;
32993 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
32996 if(this.labelmd > 0){
32997 labelCls = ' col-md-' + this.labelmd;
32998 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
33001 if(this.labelsm > 0){
33002 labelCls = ' col-sm-' + this.labelsm;
33003 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
33006 if(this.labelxs > 0){
33007 labelCls = ' col-xs-' + this.labelxs;
33008 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
33012 label.cls += ' ' + labelCls;
33014 cfg.cn.push(label);
33017 Roo.each(['day', 'month', 'year'], function(t){
33020 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
33027 inputEl: function ()
33029 return this.el.select('.roo-date-split-field-group-value', true).first();
33032 onRender : function(ct, position)
33036 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
33038 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
33040 this.dayField = new Roo.bootstrap.ComboBox({
33041 allowBlank : this.dayAllowBlank,
33042 alwaysQuery : true,
33043 displayField : 'value',
33046 forceSelection : true,
33048 placeholder : this.dayPlaceholder,
33049 selectOnFocus : true,
33050 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
33051 triggerAction : 'all',
33053 valueField : 'value',
33054 store : new Roo.data.SimpleStore({
33055 data : (function() {
33057 _this.fireEvent('days', _this, days);
33060 fields : [ 'value' ]
33063 select : function (_self, record, index)
33065 _this.setValue(_this.getValue());
33070 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
33072 this.monthField = new Roo.bootstrap.MonthField({
33073 after : '<i class=\"fa fa-calendar\"></i>',
33074 allowBlank : this.monthAllowBlank,
33075 placeholder : this.monthPlaceholder,
33078 render : function (_self)
33080 this.el.select('span.input-group-addon', true).first().on('click', function(e){
33081 e.preventDefault();
33085 select : function (_self, oldvalue, newvalue)
33087 _this.setValue(_this.getValue());
33092 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
33094 this.yearField = new Roo.bootstrap.ComboBox({
33095 allowBlank : this.yearAllowBlank,
33096 alwaysQuery : true,
33097 displayField : 'value',
33100 forceSelection : true,
33102 placeholder : this.yearPlaceholder,
33103 selectOnFocus : true,
33104 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
33105 triggerAction : 'all',
33107 valueField : 'value',
33108 store : new Roo.data.SimpleStore({
33109 data : (function() {
33111 _this.fireEvent('years', _this, years);
33114 fields : [ 'value' ]
33117 select : function (_self, record, index)
33119 _this.setValue(_this.getValue());
33124 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
33127 setValue : function(v, format)
33129 this.inputEl.dom.value = v;
33131 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
33133 var d = Date.parseDate(v, f);
33140 this.setDay(d.format(this.dayFormat));
33141 this.setMonth(d.format(this.monthFormat));
33142 this.setYear(d.format(this.yearFormat));
33149 setDay : function(v)
33151 this.dayField.setValue(v);
33152 this.inputEl.dom.value = this.getValue();
33157 setMonth : function(v)
33159 this.monthField.setValue(v, true);
33160 this.inputEl.dom.value = this.getValue();
33165 setYear : function(v)
33167 this.yearField.setValue(v);
33168 this.inputEl.dom.value = this.getValue();
33173 getDay : function()
33175 return this.dayField.getValue();
33178 getMonth : function()
33180 return this.monthField.getValue();
33183 getYear : function()
33185 return this.yearField.getValue();
33188 getValue : function()
33190 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
33192 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
33202 this.inputEl.dom.value = '';
33207 validate : function()
33209 var d = this.dayField.validate();
33210 var m = this.monthField.validate();
33211 var y = this.yearField.validate();
33216 (!this.dayAllowBlank && !d) ||
33217 (!this.monthAllowBlank && !m) ||
33218 (!this.yearAllowBlank && !y)
33223 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
33232 this.markInvalid();
33237 markValid : function()
33240 var label = this.el.select('label', true).first();
33241 var icon = this.el.select('i.fa-star', true).first();
33247 this.fireEvent('valid', this);
33251 * Mark this field as invalid
33252 * @param {String} msg The validation message
33254 markInvalid : function(msg)
33257 var label = this.el.select('label', true).first();
33258 var icon = this.el.select('i.fa-star', true).first();
33260 if(label && !icon){
33261 this.el.select('.roo-date-split-field-label', true).createChild({
33263 cls : 'text-danger fa fa-lg fa-star',
33264 tooltip : 'This field is required',
33265 style : 'margin-right:5px;'
33269 this.fireEvent('invalid', this, msg);
33272 clearInvalid : function()
33274 var label = this.el.select('label', true).first();
33275 var icon = this.el.select('i.fa-star', true).first();
33281 this.fireEvent('valid', this);
33284 getName: function()
33294 * http://masonry.desandro.com
33296 * The idea is to render all the bricks based on vertical width...
33298 * The original code extends 'outlayer' - we might need to use that....
33304 * @class Roo.bootstrap.LayoutMasonry
33305 * @extends Roo.bootstrap.Component
33306 * Bootstrap Layout Masonry class
33309 * Create a new Element
33310 * @param {Object} config The config object
33313 Roo.bootstrap.LayoutMasonry = function(config){
33315 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
33319 Roo.bootstrap.LayoutMasonry.register(this);
33325 * Fire after layout the items
33326 * @param {Roo.bootstrap.LayoutMasonry} this
33327 * @param {Roo.EventObject} e
33334 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
33337 * @cfg {Boolean} isLayoutInstant = no animation?
33339 isLayoutInstant : false, // needed?
33342 * @cfg {Number} boxWidth width of the columns
33347 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
33352 * @cfg {Number} padWidth padding below box..
33357 * @cfg {Number} gutter gutter width..
33362 * @cfg {Number} maxCols maximum number of columns
33368 * @cfg {Boolean} isAutoInitial defalut true
33370 isAutoInitial : true,
33375 * @cfg {Boolean} isHorizontal defalut false
33377 isHorizontal : false,
33379 currentSize : null,
33385 bricks: null, //CompositeElement
33389 _isLayoutInited : false,
33391 // isAlternative : false, // only use for vertical layout...
33394 * @cfg {Number} alternativePadWidth padding below box..
33396 alternativePadWidth : 50,
33398 selectedBrick : [],
33400 getAutoCreate : function(){
33402 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
33406 cls: 'blog-masonary-wrapper ' + this.cls,
33408 cls : 'mas-boxes masonary'
33415 getChildContainer: function( )
33417 if (this.boxesEl) {
33418 return this.boxesEl;
33421 this.boxesEl = this.el.select('.mas-boxes').first();
33423 return this.boxesEl;
33427 initEvents : function()
33431 if(this.isAutoInitial){
33432 Roo.log('hook children rendered');
33433 this.on('childrenrendered', function() {
33434 Roo.log('children rendered');
33440 initial : function()
33442 this.selectedBrick = [];
33444 this.currentSize = this.el.getBox(true);
33446 Roo.EventManager.onWindowResize(this.resize, this);
33448 if(!this.isAutoInitial){
33456 //this.layout.defer(500,this);
33460 resize : function()
33462 var cs = this.el.getBox(true);
33465 this.currentSize.width == cs.width &&
33466 this.currentSize.x == cs.x &&
33467 this.currentSize.height == cs.height &&
33468 this.currentSize.y == cs.y
33470 Roo.log("no change in with or X or Y");
33474 this.currentSize = cs;
33480 layout : function()
33482 this._resetLayout();
33484 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
33486 this.layoutItems( isInstant );
33488 this._isLayoutInited = true;
33490 this.fireEvent('layout', this);
33494 _resetLayout : function()
33496 if(this.isHorizontal){
33497 this.horizontalMeasureColumns();
33501 this.verticalMeasureColumns();
33505 verticalMeasureColumns : function()
33507 this.getContainerWidth();
33509 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
33510 // this.colWidth = Math.floor(this.containerWidth * 0.8);
33514 var boxWidth = this.boxWidth + this.padWidth;
33516 if(this.containerWidth < this.boxWidth){
33517 boxWidth = this.containerWidth
33520 var containerWidth = this.containerWidth;
33522 var cols = Math.floor(containerWidth / boxWidth);
33524 this.cols = Math.max( cols, 1 );
33526 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
33528 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
33530 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
33532 this.colWidth = boxWidth + avail - this.padWidth;
33534 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
33535 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
33538 horizontalMeasureColumns : function()
33540 this.getContainerWidth();
33542 var boxWidth = this.boxWidth;
33544 if(this.containerWidth < boxWidth){
33545 boxWidth = this.containerWidth;
33548 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
33550 this.el.setHeight(boxWidth);
33554 getContainerWidth : function()
33556 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
33559 layoutItems : function( isInstant )
33561 Roo.log(this.bricks);
33563 var items = Roo.apply([], this.bricks);
33565 if(this.isHorizontal){
33566 this._horizontalLayoutItems( items , isInstant );
33570 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
33571 // this._verticalAlternativeLayoutItems( items , isInstant );
33575 this._verticalLayoutItems( items , isInstant );
33579 _verticalLayoutItems : function ( items , isInstant)
33581 if ( !items || !items.length ) {
33586 ['xs', 'xs', 'xs', 'tall'],
33587 ['xs', 'xs', 'tall'],
33588 ['xs', 'xs', 'sm'],
33589 ['xs', 'xs', 'xs'],
33595 ['sm', 'xs', 'xs'],
33599 ['tall', 'xs', 'xs', 'xs'],
33600 ['tall', 'xs', 'xs'],
33612 Roo.each(items, function(item, k){
33614 switch (item.size) {
33615 // these layouts take up a full box,
33626 boxes.push([item]);
33649 var filterPattern = function(box, length)
33657 var pattern = box.slice(0, length);
33661 Roo.each(pattern, function(i){
33662 format.push(i.size);
33665 Roo.each(standard, function(s){
33667 if(String(s) != String(format)){
33676 if(!match && length == 1){
33681 filterPattern(box, length - 1);
33685 queue.push(pattern);
33687 box = box.slice(length, box.length);
33689 filterPattern(box, 4);
33695 Roo.each(boxes, function(box, k){
33701 if(box.length == 1){
33706 filterPattern(box, 4);
33710 this._processVerticalLayoutQueue( queue, isInstant );
33714 // _verticalAlternativeLayoutItems : function( items , isInstant )
33716 // if ( !items || !items.length ) {
33720 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
33724 _horizontalLayoutItems : function ( items , isInstant)
33726 if ( !items || !items.length || items.length < 3) {
33732 var eItems = items.slice(0, 3);
33734 items = items.slice(3, items.length);
33737 ['xs', 'xs', 'xs', 'wide'],
33738 ['xs', 'xs', 'wide'],
33739 ['xs', 'xs', 'sm'],
33740 ['xs', 'xs', 'xs'],
33746 ['sm', 'xs', 'xs'],
33750 ['wide', 'xs', 'xs', 'xs'],
33751 ['wide', 'xs', 'xs'],
33764 Roo.each(items, function(item, k){
33766 switch (item.size) {
33777 boxes.push([item]);
33801 var filterPattern = function(box, length)
33809 var pattern = box.slice(0, length);
33813 Roo.each(pattern, function(i){
33814 format.push(i.size);
33817 Roo.each(standard, function(s){
33819 if(String(s) != String(format)){
33828 if(!match && length == 1){
33833 filterPattern(box, length - 1);
33837 queue.push(pattern);
33839 box = box.slice(length, box.length);
33841 filterPattern(box, 4);
33847 Roo.each(boxes, function(box, k){
33853 if(box.length == 1){
33858 filterPattern(box, 4);
33865 var pos = this.el.getBox(true);
33869 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
33871 var hit_end = false;
33873 Roo.each(queue, function(box){
33877 Roo.each(box, function(b){
33879 b.el.setVisibilityMode(Roo.Element.DISPLAY);
33889 Roo.each(box, function(b){
33891 b.el.setVisibilityMode(Roo.Element.DISPLAY);
33894 mx = Math.max(mx, b.x);
33898 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
33902 Roo.each(box, function(b){
33904 b.el.setVisibilityMode(Roo.Element.DISPLAY);
33918 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
33921 /** Sets position of item in DOM
33922 * @param {Element} item
33923 * @param {Number} x - horizontal position
33924 * @param {Number} y - vertical position
33925 * @param {Boolean} isInstant - disables transitions
33927 _processVerticalLayoutQueue : function( queue, isInstant )
33929 var pos = this.el.getBox(true);
33934 for (var i = 0; i < this.cols; i++){
33938 Roo.each(queue, function(box, k){
33940 var col = k % this.cols;
33942 Roo.each(box, function(b,kk){
33944 b.el.position('absolute');
33946 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
33947 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
33949 if(b.size == 'md-left' || b.size == 'md-right'){
33950 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
33951 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
33954 b.el.setWidth(width);
33955 b.el.setHeight(height);
33957 b.el.select('iframe',true).setSize(width,height);
33961 for (var i = 0; i < this.cols; i++){
33963 if(maxY[i] < maxY[col]){
33968 col = Math.min(col, i);
33972 x = pos.x + col * (this.colWidth + this.padWidth);
33976 var positions = [];
33978 switch (box.length){
33980 positions = this.getVerticalOneBoxColPositions(x, y, box);
33983 positions = this.getVerticalTwoBoxColPositions(x, y, box);
33986 positions = this.getVerticalThreeBoxColPositions(x, y, box);
33989 positions = this.getVerticalFourBoxColPositions(x, y, box);
33995 Roo.each(box, function(b,kk){
33997 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
33999 var sz = b.el.getSize();
34001 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
34009 for (var i = 0; i < this.cols; i++){
34010 mY = Math.max(mY, maxY[i]);
34013 this.el.setHeight(mY - pos.y);
34017 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
34019 // var pos = this.el.getBox(true);
34022 // var maxX = pos.right;
34024 // var maxHeight = 0;
34026 // Roo.each(items, function(item, k){
34030 // item.el.position('absolute');
34032 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
34034 // item.el.setWidth(width);
34036 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
34038 // item.el.setHeight(height);
34041 // item.el.setXY([x, y], isInstant ? false : true);
34043 // item.el.setXY([maxX - width, y], isInstant ? false : true);
34046 // y = y + height + this.alternativePadWidth;
34048 // maxHeight = maxHeight + height + this.alternativePadWidth;
34052 // this.el.setHeight(maxHeight);
34056 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
34058 var pos = this.el.getBox(true);
34063 var maxX = pos.right;
34065 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
34067 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
34069 Roo.each(queue, function(box, k){
34071 Roo.each(box, function(b, kk){
34073 b.el.position('absolute');
34075 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
34076 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
34078 if(b.size == 'md-left' || b.size == 'md-right'){
34079 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
34080 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
34083 b.el.setWidth(width);
34084 b.el.setHeight(height);
34092 var positions = [];
34094 switch (box.length){
34096 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
34099 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
34102 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
34105 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
34111 Roo.each(box, function(b,kk){
34113 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
34115 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
34123 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
34125 Roo.each(eItems, function(b,k){
34127 b.size = (k == 0) ? 'sm' : 'xs';
34128 b.x = (k == 0) ? 2 : 1;
34129 b.y = (k == 0) ? 2 : 1;
34131 b.el.position('absolute');
34133 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
34135 b.el.setWidth(width);
34137 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
34139 b.el.setHeight(height);
34143 var positions = [];
34146 x : maxX - this.unitWidth * 2 - this.gutter,
34151 x : maxX - this.unitWidth,
34152 y : minY + (this.unitWidth + this.gutter) * 2
34156 x : maxX - this.unitWidth * 3 - this.gutter * 2,
34160 Roo.each(eItems, function(b,k){
34162 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
34168 getVerticalOneBoxColPositions : function(x, y, box)
34172 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
34174 if(box[0].size == 'md-left'){
34178 if(box[0].size == 'md-right'){
34183 x : x + (this.unitWidth + this.gutter) * rand,
34190 getVerticalTwoBoxColPositions : function(x, y, box)
34194 if(box[0].size == 'xs'){
34198 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
34202 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
34216 x : x + (this.unitWidth + this.gutter) * 2,
34217 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
34224 getVerticalThreeBoxColPositions : function(x, y, box)
34228 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
34236 x : x + (this.unitWidth + this.gutter) * 1,
34241 x : x + (this.unitWidth + this.gutter) * 2,
34249 if(box[0].size == 'xs' && box[1].size == 'xs'){
34258 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
34262 x : x + (this.unitWidth + this.gutter) * 1,
34276 x : x + (this.unitWidth + this.gutter) * 2,
34281 x : x + (this.unitWidth + this.gutter) * 2,
34282 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
34289 getVerticalFourBoxColPositions : function(x, y, box)
34293 if(box[0].size == 'xs'){
34302 y : y + (this.unitHeight + this.gutter) * 1
34307 y : y + (this.unitHeight + this.gutter) * 2
34311 x : x + (this.unitWidth + this.gutter) * 1,
34325 x : x + (this.unitWidth + this.gutter) * 2,
34330 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
34331 y : y + (this.unitHeight + this.gutter) * 1
34335 x : x + (this.unitWidth + this.gutter) * 2,
34336 y : y + (this.unitWidth + this.gutter) * 2
34343 getHorizontalOneBoxColPositions : function(maxX, minY, box)
34347 if(box[0].size == 'md-left'){
34349 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
34356 if(box[0].size == 'md-right'){
34358 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
34359 y : minY + (this.unitWidth + this.gutter) * 1
34365 var rand = Math.floor(Math.random() * (4 - box[0].y));
34368 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
34369 y : minY + (this.unitWidth + this.gutter) * rand
34376 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
34380 if(box[0].size == 'xs'){
34383 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
34388 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
34389 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
34397 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
34402 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
34403 y : minY + (this.unitWidth + this.gutter) * 2
34410 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
34414 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
34417 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
34422 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
34423 y : minY + (this.unitWidth + this.gutter) * 1
34427 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
34428 y : minY + (this.unitWidth + this.gutter) * 2
34435 if(box[0].size == 'xs' && box[1].size == 'xs'){
34438 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
34443 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
34448 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
34449 y : minY + (this.unitWidth + this.gutter) * 1
34457 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
34462 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
34463 y : minY + (this.unitWidth + this.gutter) * 2
34467 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
34468 y : minY + (this.unitWidth + this.gutter) * 2
34475 getHorizontalFourBoxColPositions : function(maxX, minY, box)
34479 if(box[0].size == 'xs'){
34482 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
34487 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
34492 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),
34497 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
34498 y : minY + (this.unitWidth + this.gutter) * 1
34506 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
34511 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
34512 y : minY + (this.unitWidth + this.gutter) * 2
34516 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
34517 y : minY + (this.unitWidth + this.gutter) * 2
34521 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),
34522 y : minY + (this.unitWidth + this.gutter) * 2
34530 * remove a Masonry Brick
34531 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
34533 removeBrick : function(brick_id)
34539 for (var i = 0; i<this.bricks.length; i++) {
34540 if (this.bricks[i].id == brick_id) {
34541 this.bricks.splice(i,1);
34542 this.el.dom.removeChild(Roo.get(brick_id).dom);
34549 * adds a Masonry Brick
34550 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
34552 addBrick : function(cfg)
34554 var cn = new Roo.bootstrap.MasonryBrick(cfg);
34555 //this.register(cn);
34556 cn.parentId = this.id;
34557 cn.render(this.el);
34562 * register a Masonry Brick
34563 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
34566 register : function(brick)
34568 this.bricks.push(brick);
34569 brick.masonryId = this.id;
34573 * clear all the Masonry Brick
34575 clearAll : function()
34578 //this.getChildContainer().dom.innerHTML = "";
34579 this.el.dom.innerHTML = '';
34582 getSelected : function()
34584 if (!this.selectedBrick) {
34588 return this.selectedBrick;
34592 Roo.apply(Roo.bootstrap.LayoutMasonry, {
34596 * register a Masonry Layout
34597 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
34600 register : function(layout)
34602 this.groups[layout.id] = layout;
34605 * fetch a Masonry Layout based on the masonry layout ID
34606 * @param {string} the masonry layout to add
34607 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
34610 get: function(layout_id) {
34611 if (typeof(this.groups[layout_id]) == 'undefined') {
34614 return this.groups[layout_id] ;
34626 * http://masonry.desandro.com
34628 * The idea is to render all the bricks based on vertical width...
34630 * The original code extends 'outlayer' - we might need to use that....
34636 * @class Roo.bootstrap.LayoutMasonryAuto
34637 * @extends Roo.bootstrap.Component
34638 * Bootstrap Layout Masonry class
34641 * Create a new Element
34642 * @param {Object} config The config object
34645 Roo.bootstrap.LayoutMasonryAuto = function(config){
34646 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
34649 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
34652 * @cfg {Boolean} isFitWidth - resize the width..
34654 isFitWidth : false, // options..
34656 * @cfg {Boolean} isOriginLeft = left align?
34658 isOriginLeft : true,
34660 * @cfg {Boolean} isOriginTop = top align?
34662 isOriginTop : false,
34664 * @cfg {Boolean} isLayoutInstant = no animation?
34666 isLayoutInstant : false, // needed?
34668 * @cfg {Boolean} isResizingContainer = not sure if this is used..
34670 isResizingContainer : true,
34672 * @cfg {Number} columnWidth width of the columns
34678 * @cfg {Number} maxCols maximum number of columns
34683 * @cfg {Number} padHeight padding below box..
34689 * @cfg {Boolean} isAutoInitial defalut true
34692 isAutoInitial : true,
34698 initialColumnWidth : 0,
34699 currentSize : null,
34701 colYs : null, // array.
34708 bricks: null, //CompositeElement
34709 cols : 0, // array?
34710 // element : null, // wrapped now this.el
34711 _isLayoutInited : null,
34714 getAutoCreate : function(){
34718 cls: 'blog-masonary-wrapper ' + this.cls,
34720 cls : 'mas-boxes masonary'
34727 getChildContainer: function( )
34729 if (this.boxesEl) {
34730 return this.boxesEl;
34733 this.boxesEl = this.el.select('.mas-boxes').first();
34735 return this.boxesEl;
34739 initEvents : function()
34743 if(this.isAutoInitial){
34744 Roo.log('hook children rendered');
34745 this.on('childrenrendered', function() {
34746 Roo.log('children rendered');
34753 initial : function()
34755 this.reloadItems();
34757 this.currentSize = this.el.getBox(true);
34759 /// was window resize... - let's see if this works..
34760 Roo.EventManager.onWindowResize(this.resize, this);
34762 if(!this.isAutoInitial){
34767 this.layout.defer(500,this);
34770 reloadItems: function()
34772 this.bricks = this.el.select('.masonry-brick', true);
34774 this.bricks.each(function(b) {
34775 //Roo.log(b.getSize());
34776 if (!b.attr('originalwidth')) {
34777 b.attr('originalwidth', b.getSize().width);
34782 Roo.log(this.bricks.elements.length);
34785 resize : function()
34788 var cs = this.el.getBox(true);
34790 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
34791 Roo.log("no change in with or X");
34794 this.currentSize = cs;
34798 layout : function()
34801 this._resetLayout();
34802 //this._manageStamps();
34804 // don't animate first layout
34805 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
34806 this.layoutItems( isInstant );
34808 // flag for initalized
34809 this._isLayoutInited = true;
34812 layoutItems : function( isInstant )
34814 //var items = this._getItemsForLayout( this.items );
34815 // original code supports filtering layout items.. we just ignore it..
34817 this._layoutItems( this.bricks , isInstant );
34819 this._postLayout();
34821 _layoutItems : function ( items , isInstant)
34823 //this.fireEvent( 'layout', this, items );
34826 if ( !items || !items.elements.length ) {
34827 // no items, emit event with empty array
34832 items.each(function(item) {
34833 Roo.log("layout item");
34835 // get x/y object from method
34836 var position = this._getItemLayoutPosition( item );
34838 position.item = item;
34839 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
34840 queue.push( position );
34843 this._processLayoutQueue( queue );
34845 /** Sets position of item in DOM
34846 * @param {Element} item
34847 * @param {Number} x - horizontal position
34848 * @param {Number} y - vertical position
34849 * @param {Boolean} isInstant - disables transitions
34851 _processLayoutQueue : function( queue )
34853 for ( var i=0, len = queue.length; i < len; i++ ) {
34854 var obj = queue[i];
34855 obj.item.position('absolute');
34856 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
34862 * Any logic you want to do after each layout,
34863 * i.e. size the container
34865 _postLayout : function()
34867 this.resizeContainer();
34870 resizeContainer : function()
34872 if ( !this.isResizingContainer ) {
34875 var size = this._getContainerSize();
34877 this.el.setSize(size.width,size.height);
34878 this.boxesEl.setSize(size.width,size.height);
34884 _resetLayout : function()
34886 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
34887 this.colWidth = this.el.getWidth();
34888 //this.gutter = this.el.getWidth();
34890 this.measureColumns();
34896 this.colYs.push( 0 );
34902 measureColumns : function()
34904 this.getContainerWidth();
34905 // if columnWidth is 0, default to outerWidth of first item
34906 if ( !this.columnWidth ) {
34907 var firstItem = this.bricks.first();
34908 Roo.log(firstItem);
34909 this.columnWidth = this.containerWidth;
34910 if (firstItem && firstItem.attr('originalwidth') ) {
34911 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
34913 // columnWidth fall back to item of first element
34914 Roo.log("set column width?");
34915 this.initialColumnWidth = this.columnWidth ;
34917 // if first elem has no width, default to size of container
34922 if (this.initialColumnWidth) {
34923 this.columnWidth = this.initialColumnWidth;
34928 // column width is fixed at the top - however if container width get's smaller we should
34931 // this bit calcs how man columns..
34933 var columnWidth = this.columnWidth += this.gutter;
34935 // calculate columns
34936 var containerWidth = this.containerWidth + this.gutter;
34938 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
34939 // fix rounding errors, typically with gutters
34940 var excess = columnWidth - containerWidth % columnWidth;
34943 // if overshoot is less than a pixel, round up, otherwise floor it
34944 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
34945 cols = Math[ mathMethod ]( cols );
34946 this.cols = Math.max( cols, 1 );
34947 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
34949 // padding positioning..
34950 var totalColWidth = this.cols * this.columnWidth;
34951 var padavail = this.containerWidth - totalColWidth;
34952 // so for 2 columns - we need 3 'pads'
34954 var padNeeded = (1+this.cols) * this.padWidth;
34956 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
34958 this.columnWidth += padExtra
34959 //this.padWidth = Math.floor(padavail / ( this.cols));
34961 // adjust colum width so that padding is fixed??
34963 // we have 3 columns ... total = width * 3
34964 // we have X left over... that should be used by
34966 //if (this.expandC) {
34974 getContainerWidth : function()
34976 /* // container is parent if fit width
34977 var container = this.isFitWidth ? this.element.parentNode : this.element;
34978 // check that this.size and size are there
34979 // IE8 triggers resize on body size change, so they might not be
34981 var size = getSize( container ); //FIXME
34982 this.containerWidth = size && size.innerWidth; //FIXME
34985 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
34989 _getItemLayoutPosition : function( item ) // what is item?
34991 // we resize the item to our columnWidth..
34993 item.setWidth(this.columnWidth);
34994 item.autoBoxAdjust = false;
34996 var sz = item.getSize();
34998 // how many columns does this brick span
34999 var remainder = this.containerWidth % this.columnWidth;
35001 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
35002 // round if off by 1 pixel, otherwise use ceil
35003 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
35004 colSpan = Math.min( colSpan, this.cols );
35006 // normally this should be '1' as we dont' currently allow multi width columns..
35008 var colGroup = this._getColGroup( colSpan );
35009 // get the minimum Y value from the columns
35010 var minimumY = Math.min.apply( Math, colGroup );
35011 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
35013 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
35015 // position the brick
35017 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
35018 y: this.currentSize.y + minimumY + this.padHeight
35022 // apply setHeight to necessary columns
35023 var setHeight = minimumY + sz.height + this.padHeight;
35024 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
35026 var setSpan = this.cols + 1 - colGroup.length;
35027 for ( var i = 0; i < setSpan; i++ ) {
35028 this.colYs[ shortColIndex + i ] = setHeight ;
35035 * @param {Number} colSpan - number of columns the element spans
35036 * @returns {Array} colGroup
35038 _getColGroup : function( colSpan )
35040 if ( colSpan < 2 ) {
35041 // if brick spans only one column, use all the column Ys
35046 // how many different places could this brick fit horizontally
35047 var groupCount = this.cols + 1 - colSpan;
35048 // for each group potential horizontal position
35049 for ( var i = 0; i < groupCount; i++ ) {
35050 // make an array of colY values for that one group
35051 var groupColYs = this.colYs.slice( i, i + colSpan );
35052 // and get the max value of the array
35053 colGroup[i] = Math.max.apply( Math, groupColYs );
35058 _manageStamp : function( stamp )
35060 var stampSize = stamp.getSize();
35061 var offset = stamp.getBox();
35062 // get the columns that this stamp affects
35063 var firstX = this.isOriginLeft ? offset.x : offset.right;
35064 var lastX = firstX + stampSize.width;
35065 var firstCol = Math.floor( firstX / this.columnWidth );
35066 firstCol = Math.max( 0, firstCol );
35068 var lastCol = Math.floor( lastX / this.columnWidth );
35069 // lastCol should not go over if multiple of columnWidth #425
35070 lastCol -= lastX % this.columnWidth ? 0 : 1;
35071 lastCol = Math.min( this.cols - 1, lastCol );
35073 // set colYs to bottom of the stamp
35074 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
35077 for ( var i = firstCol; i <= lastCol; i++ ) {
35078 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
35083 _getContainerSize : function()
35085 this.maxY = Math.max.apply( Math, this.colYs );
35090 if ( this.isFitWidth ) {
35091 size.width = this._getContainerFitWidth();
35097 _getContainerFitWidth : function()
35099 var unusedCols = 0;
35100 // count unused columns
35103 if ( this.colYs[i] !== 0 ) {
35108 // fit container to columns that have been used
35109 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
35112 needsResizeLayout : function()
35114 var previousWidth = this.containerWidth;
35115 this.getContainerWidth();
35116 return previousWidth !== this.containerWidth;
35131 * @class Roo.bootstrap.MasonryBrick
35132 * @extends Roo.bootstrap.Component
35133 * Bootstrap MasonryBrick class
35136 * Create a new MasonryBrick
35137 * @param {Object} config The config object
35140 Roo.bootstrap.MasonryBrick = function(config){
35142 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
35144 Roo.bootstrap.MasonryBrick.register(this);
35150 * When a MasonryBrick is clcik
35151 * @param {Roo.bootstrap.MasonryBrick} this
35152 * @param {Roo.EventObject} e
35158 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
35161 * @cfg {String} title
35165 * @cfg {String} html
35169 * @cfg {String} bgimage
35173 * @cfg {String} videourl
35177 * @cfg {String} cls
35181 * @cfg {String} href
35185 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
35190 * @cfg {String} placetitle (center|bottom)
35195 * @cfg {Boolean} isFitContainer defalut true
35197 isFitContainer : true,
35200 * @cfg {Boolean} preventDefault defalut false
35202 preventDefault : false,
35205 * @cfg {Boolean} inverse defalut false
35207 maskInverse : false,
35209 getAutoCreate : function()
35211 if(!this.isFitContainer){
35212 return this.getSplitAutoCreate();
35215 var cls = 'masonry-brick masonry-brick-full';
35217 if(this.href.length){
35218 cls += ' masonry-brick-link';
35221 if(this.bgimage.length){
35222 cls += ' masonry-brick-image';
35225 if(this.maskInverse){
35226 cls += ' mask-inverse';
35229 if(!this.html.length && !this.maskInverse && !this.videourl.length){
35230 cls += ' enable-mask';
35234 cls += ' masonry-' + this.size + '-brick';
35237 if(this.placetitle.length){
35239 switch (this.placetitle) {
35241 cls += ' masonry-center-title';
35244 cls += ' masonry-bottom-title';
35251 if(!this.html.length && !this.bgimage.length){
35252 cls += ' masonry-center-title';
35255 if(!this.html.length && this.bgimage.length){
35256 cls += ' masonry-bottom-title';
35261 cls += ' ' + this.cls;
35265 tag: (this.href.length) ? 'a' : 'div',
35270 cls: 'masonry-brick-mask'
35274 cls: 'masonry-brick-paragraph',
35280 if(this.href.length){
35281 cfg.href = this.href;
35284 var cn = cfg.cn[1].cn;
35286 if(this.title.length){
35289 cls: 'masonry-brick-title',
35294 if(this.html.length){
35297 cls: 'masonry-brick-text',
35302 if (!this.title.length && !this.html.length) {
35303 cfg.cn[1].cls += ' hide';
35306 if(this.bgimage.length){
35309 cls: 'masonry-brick-image-view',
35314 if(this.videourl.length){
35315 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
35316 // youtube support only?
35319 cls: 'masonry-brick-image-view',
35322 allowfullscreen : true
35330 getSplitAutoCreate : function()
35332 var cls = 'masonry-brick masonry-brick-split';
35334 if(this.href.length){
35335 cls += ' masonry-brick-link';
35338 if(this.bgimage.length){
35339 cls += ' masonry-brick-image';
35343 cls += ' masonry-' + this.size + '-brick';
35346 switch (this.placetitle) {
35348 cls += ' masonry-center-title';
35351 cls += ' masonry-bottom-title';
35354 if(!this.bgimage.length){
35355 cls += ' masonry-center-title';
35358 if(this.bgimage.length){
35359 cls += ' masonry-bottom-title';
35365 cls += ' ' + this.cls;
35369 tag: (this.href.length) ? 'a' : 'div',
35374 cls: 'masonry-brick-split-head',
35378 cls: 'masonry-brick-paragraph',
35385 cls: 'masonry-brick-split-body',
35391 if(this.href.length){
35392 cfg.href = this.href;
35395 if(this.title.length){
35396 cfg.cn[0].cn[0].cn.push({
35398 cls: 'masonry-brick-title',
35403 if(this.html.length){
35404 cfg.cn[1].cn.push({
35406 cls: 'masonry-brick-text',
35411 if(this.bgimage.length){
35412 cfg.cn[0].cn.push({
35414 cls: 'masonry-brick-image-view',
35419 if(this.videourl.length){
35420 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
35421 // youtube support only?
35422 cfg.cn[0].cn.cn.push({
35424 cls: 'masonry-brick-image-view',
35427 allowfullscreen : true
35434 initEvents: function()
35436 switch (this.size) {
35469 this.el.on('touchstart', this.onTouchStart, this);
35470 this.el.on('touchmove', this.onTouchMove, this);
35471 this.el.on('touchend', this.onTouchEnd, this);
35472 this.el.on('contextmenu', this.onContextMenu, this);
35474 this.el.on('mouseenter' ,this.enter, this);
35475 this.el.on('mouseleave', this.leave, this);
35476 this.el.on('click', this.onClick, this);
35479 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
35480 this.parent().bricks.push(this);
35485 onClick: function(e, el)
35487 var time = this.endTimer - this.startTimer;
35488 // Roo.log(e.preventDefault());
35491 e.preventDefault();
35496 if(!this.preventDefault){
35500 e.preventDefault();
35502 if (this.activeClass != '') {
35503 this.selectBrick();
35506 this.fireEvent('click', this, e);
35509 enter: function(e, el)
35511 e.preventDefault();
35513 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
35517 if(this.bgimage.length && this.html.length){
35518 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
35522 leave: function(e, el)
35524 e.preventDefault();
35526 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
35530 if(this.bgimage.length && this.html.length){
35531 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
35535 onTouchStart: function(e, el)
35537 // e.preventDefault();
35539 this.touchmoved = false;
35541 if(!this.isFitContainer){
35545 if(!this.bgimage.length || !this.html.length){
35549 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
35551 this.timer = new Date().getTime();
35555 onTouchMove: function(e, el)
35557 this.touchmoved = true;
35560 onContextMenu : function(e,el)
35562 e.preventDefault();
35563 e.stopPropagation();
35567 onTouchEnd: function(e, el)
35569 // e.preventDefault();
35571 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
35578 if(!this.bgimage.length || !this.html.length){
35580 if(this.href.length){
35581 window.location.href = this.href;
35587 if(!this.isFitContainer){
35591 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
35593 window.location.href = this.href;
35596 //selection on single brick only
35597 selectBrick : function() {
35599 if (!this.parentId) {
35603 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
35604 var index = m.selectedBrick.indexOf(this.id);
35607 m.selectedBrick.splice(index,1);
35608 this.el.removeClass(this.activeClass);
35612 for(var i = 0; i < m.selectedBrick.length; i++) {
35613 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
35614 b.el.removeClass(b.activeClass);
35617 m.selectedBrick = [];
35619 m.selectedBrick.push(this.id);
35620 this.el.addClass(this.activeClass);
35624 isSelected : function(){
35625 return this.el.hasClass(this.activeClass);
35630 Roo.apply(Roo.bootstrap.MasonryBrick, {
35633 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
35635 * register a Masonry Brick
35636 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
35639 register : function(brick)
35641 //this.groups[brick.id] = brick;
35642 this.groups.add(brick.id, brick);
35645 * fetch a masonry brick based on the masonry brick ID
35646 * @param {string} the masonry brick to add
35647 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
35650 get: function(brick_id)
35652 // if (typeof(this.groups[brick_id]) == 'undefined') {
35655 // return this.groups[brick_id] ;
35657 if(this.groups.key(brick_id)) {
35658 return this.groups.key(brick_id);
35676 * @class Roo.bootstrap.Brick
35677 * @extends Roo.bootstrap.Component
35678 * Bootstrap Brick class
35681 * Create a new Brick
35682 * @param {Object} config The config object
35685 Roo.bootstrap.Brick = function(config){
35686 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
35692 * When a Brick is click
35693 * @param {Roo.bootstrap.Brick} this
35694 * @param {Roo.EventObject} e
35700 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
35703 * @cfg {String} title
35707 * @cfg {String} html
35711 * @cfg {String} bgimage
35715 * @cfg {String} cls
35719 * @cfg {String} href
35723 * @cfg {String} video
35727 * @cfg {Boolean} square
35731 getAutoCreate : function()
35733 var cls = 'roo-brick';
35735 if(this.href.length){
35736 cls += ' roo-brick-link';
35739 if(this.bgimage.length){
35740 cls += ' roo-brick-image';
35743 if(!this.html.length && !this.bgimage.length){
35744 cls += ' roo-brick-center-title';
35747 if(!this.html.length && this.bgimage.length){
35748 cls += ' roo-brick-bottom-title';
35752 cls += ' ' + this.cls;
35756 tag: (this.href.length) ? 'a' : 'div',
35761 cls: 'roo-brick-paragraph',
35767 if(this.href.length){
35768 cfg.href = this.href;
35771 var cn = cfg.cn[0].cn;
35773 if(this.title.length){
35776 cls: 'roo-brick-title',
35781 if(this.html.length){
35784 cls: 'roo-brick-text',
35791 if(this.bgimage.length){
35794 cls: 'roo-brick-image-view',
35802 initEvents: function()
35804 if(this.title.length || this.html.length){
35805 this.el.on('mouseenter' ,this.enter, this);
35806 this.el.on('mouseleave', this.leave, this);
35809 Roo.EventManager.onWindowResize(this.resize, this);
35811 if(this.bgimage.length){
35812 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
35813 this.imageEl.on('load', this.onImageLoad, this);
35820 onImageLoad : function()
35825 resize : function()
35827 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
35829 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
35831 if(this.bgimage.length){
35832 var image = this.el.select('.roo-brick-image-view', true).first();
35834 image.setWidth(paragraph.getWidth());
35837 image.setHeight(paragraph.getWidth());
35840 this.el.setHeight(image.getHeight());
35841 paragraph.setHeight(image.getHeight());
35847 enter: function(e, el)
35849 e.preventDefault();
35851 if(this.bgimage.length){
35852 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
35853 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
35857 leave: function(e, el)
35859 e.preventDefault();
35861 if(this.bgimage.length){
35862 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
35863 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
35878 * @class Roo.bootstrap.NumberField
35879 * @extends Roo.bootstrap.Input
35880 * Bootstrap NumberField class
35886 * Create a new NumberField
35887 * @param {Object} config The config object
35890 Roo.bootstrap.NumberField = function(config){
35891 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
35894 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
35897 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
35899 allowDecimals : true,
35901 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
35903 decimalSeparator : ".",
35905 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
35907 decimalPrecision : 2,
35909 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
35911 allowNegative : true,
35914 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
35918 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
35920 minValue : Number.NEGATIVE_INFINITY,
35922 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
35924 maxValue : Number.MAX_VALUE,
35926 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
35928 minText : "The minimum value for this field is {0}",
35930 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
35932 maxText : "The maximum value for this field is {0}",
35934 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
35935 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
35937 nanText : "{0} is not a valid number",
35939 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
35941 thousandsDelimiter : false,
35943 * @cfg {String} valueAlign alignment of value
35945 valueAlign : "left",
35947 getAutoCreate : function()
35949 var hiddenInput = {
35953 cls: 'hidden-number-input'
35957 hiddenInput.name = this.name;
35962 var cfg = Roo.bootstrap.NumberField.superclass.getAutoCreate.call(this);
35964 this.name = hiddenInput.name;
35966 if(cfg.cn.length > 0) {
35967 cfg.cn.push(hiddenInput);
35974 initEvents : function()
35976 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
35978 var allowed = "0123456789";
35980 if(this.allowDecimals){
35981 allowed += this.decimalSeparator;
35984 if(this.allowNegative){
35988 if(this.thousandsDelimiter) {
35992 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
35994 var keyPress = function(e){
35996 var k = e.getKey();
35998 var c = e.getCharCode();
36001 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
36002 allowed.indexOf(String.fromCharCode(c)) === -1
36008 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
36012 if(allowed.indexOf(String.fromCharCode(c)) === -1){
36017 this.el.on("keypress", keyPress, this);
36020 validateValue : function(value)
36023 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
36027 var num = this.parseValue(value);
36030 this.markInvalid(String.format(this.nanText, value));
36034 if(num < this.minValue){
36035 this.markInvalid(String.format(this.minText, this.minValue));
36039 if(num > this.maxValue){
36040 this.markInvalid(String.format(this.maxText, this.maxValue));
36047 getValue : function()
36049 var v = this.hiddenEl().getValue();
36051 return this.fixPrecision(this.parseValue(v));
36054 parseValue : function(value)
36056 if(this.thousandsDelimiter) {
36058 r = new RegExp(",", "g");
36059 value = value.replace(r, "");
36062 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
36063 return isNaN(value) ? '' : value;
36066 fixPrecision : function(value)
36068 if(this.thousandsDelimiter) {
36070 r = new RegExp(",", "g");
36071 value = value.replace(r, "");
36074 var nan = isNaN(value);
36076 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
36077 return nan ? '' : value;
36079 return parseFloat(value).toFixed(this.decimalPrecision);
36082 setValue : function(v)
36084 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
36090 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
36092 this.inputEl().dom.value = (v == '') ? '' :
36093 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
36095 if(!this.allowZero && v === '0') {
36096 this.hiddenEl().dom.value = '';
36097 this.inputEl().dom.value = '';
36104 decimalPrecisionFcn : function(v)
36106 return Math.floor(v);
36109 beforeBlur : function()
36111 var v = this.parseValue(this.getRawValue());
36113 if(v || v === 0 || v === ''){
36118 hiddenEl : function()
36120 return this.el.select('input.hidden-number-input',true).first();
36132 * @class Roo.bootstrap.DocumentSlider
36133 * @extends Roo.bootstrap.Component
36134 * Bootstrap DocumentSlider class
36137 * Create a new DocumentViewer
36138 * @param {Object} config The config object
36141 Roo.bootstrap.DocumentSlider = function(config){
36142 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
36149 * Fire after initEvent
36150 * @param {Roo.bootstrap.DocumentSlider} this
36155 * Fire after update
36156 * @param {Roo.bootstrap.DocumentSlider} this
36162 * @param {Roo.bootstrap.DocumentSlider} this
36168 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
36174 getAutoCreate : function()
36178 cls : 'roo-document-slider',
36182 cls : 'roo-document-slider-header',
36186 cls : 'roo-document-slider-header-title'
36192 cls : 'roo-document-slider-body',
36196 cls : 'roo-document-slider-prev',
36200 cls : 'fa fa-chevron-left'
36206 cls : 'roo-document-slider-thumb',
36210 cls : 'roo-document-slider-image'
36216 cls : 'roo-document-slider-next',
36220 cls : 'fa fa-chevron-right'
36232 initEvents : function()
36234 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
36235 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
36237 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
36238 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
36240 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
36241 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
36243 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
36244 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
36246 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
36247 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
36249 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
36250 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
36252 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
36253 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
36255 this.thumbEl.on('click', this.onClick, this);
36257 this.prevIndicator.on('click', this.prev, this);
36259 this.nextIndicator.on('click', this.next, this);
36263 initial : function()
36265 if(this.files.length){
36266 this.indicator = 1;
36270 this.fireEvent('initial', this);
36273 update : function()
36275 this.imageEl.attr('src', this.files[this.indicator - 1]);
36277 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
36279 this.prevIndicator.show();
36281 if(this.indicator == 1){
36282 this.prevIndicator.hide();
36285 this.nextIndicator.show();
36287 if(this.indicator == this.files.length){
36288 this.nextIndicator.hide();
36291 this.thumbEl.scrollTo('top');
36293 this.fireEvent('update', this);
36296 onClick : function(e)
36298 e.preventDefault();
36300 this.fireEvent('click', this);
36305 e.preventDefault();
36307 this.indicator = Math.max(1, this.indicator - 1);
36314 e.preventDefault();
36316 this.indicator = Math.min(this.files.length, this.indicator + 1);
36330 * @class Roo.bootstrap.RadioSet
36331 * @extends Roo.bootstrap.Input
36332 * Bootstrap RadioSet class
36333 * @cfg {String} indicatorpos (left|right) default left
36334 * @cfg {Boolean} inline (true|false) inline the element (default true)
36335 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
36337 * Create a new RadioSet
36338 * @param {Object} config The config object
36341 Roo.bootstrap.RadioSet = function(config){
36343 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
36347 Roo.bootstrap.RadioSet.register(this);
36352 * Fires when the element is checked or unchecked.
36353 * @param {Roo.bootstrap.RadioSet} this This radio
36354 * @param {Roo.bootstrap.Radio} item The checked item
36359 * Fires when the element is click.
36360 * @param {Roo.bootstrap.RadioSet} this This radio set
36361 * @param {Roo.bootstrap.Radio} item The checked item
36362 * @param {Roo.EventObject} e The event object
36369 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
36377 indicatorpos : 'left',
36379 getAutoCreate : function()
36383 cls : 'roo-radio-set-label',
36387 html : this.fieldLabel
36391 if (Roo.bootstrap.version == 3) {
36394 if(this.indicatorpos == 'left'){
36397 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
36398 tooltip : 'This field is required'
36403 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
36404 tooltip : 'This field is required'
36410 cls : 'roo-radio-set-items'
36413 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
36415 if (align === 'left' && this.fieldLabel.length) {
36418 cls : "roo-radio-set-right",
36424 if(this.labelWidth > 12){
36425 label.style = "width: " + this.labelWidth + 'px';
36428 if(this.labelWidth < 13 && this.labelmd == 0){
36429 this.labelmd = this.labelWidth;
36432 if(this.labellg > 0){
36433 label.cls += ' col-lg-' + this.labellg;
36434 items.cls += ' col-lg-' + (12 - this.labellg);
36437 if(this.labelmd > 0){
36438 label.cls += ' col-md-' + this.labelmd;
36439 items.cls += ' col-md-' + (12 - this.labelmd);
36442 if(this.labelsm > 0){
36443 label.cls += ' col-sm-' + this.labelsm;
36444 items.cls += ' col-sm-' + (12 - this.labelsm);
36447 if(this.labelxs > 0){
36448 label.cls += ' col-xs-' + this.labelxs;
36449 items.cls += ' col-xs-' + (12 - this.labelxs);
36455 cls : 'roo-radio-set',
36459 cls : 'roo-radio-set-input',
36462 value : this.value ? this.value : ''
36469 if(this.weight.length){
36470 cfg.cls += ' roo-radio-' + this.weight;
36474 cfg.cls += ' roo-radio-set-inline';
36478 ['xs','sm','md','lg'].map(function(size){
36479 if (settings[size]) {
36480 cfg.cls += ' col-' + size + '-' + settings[size];
36488 initEvents : function()
36490 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
36491 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
36493 if(!this.fieldLabel.length){
36494 this.labelEl.hide();
36497 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
36498 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
36500 this.indicator = this.indicatorEl();
36502 if(this.indicator){
36503 this.indicator.addClass('invisible');
36506 this.originalValue = this.getValue();
36510 inputEl: function ()
36512 return this.el.select('.roo-radio-set-input', true).first();
36515 getChildContainer : function()
36517 return this.itemsEl;
36520 register : function(item)
36522 this.radioes.push(item);
36526 validate : function()
36528 if(this.getVisibilityEl().hasClass('hidden')){
36534 Roo.each(this.radioes, function(i){
36543 if(this.allowBlank) {
36547 if(this.disabled || valid){
36552 this.markInvalid();
36557 markValid : function()
36559 if(this.labelEl.isVisible(true) && this.indicatorEl()){
36560 this.indicatorEl().removeClass('visible');
36561 this.indicatorEl().addClass('invisible');
36565 if (Roo.bootstrap.version == 3) {
36566 this.el.removeClass([this.invalidClass, this.validClass]);
36567 this.el.addClass(this.validClass);
36569 this.el.removeClass(['is-invalid','is-valid']);
36570 this.el.addClass(['is-valid']);
36572 this.fireEvent('valid', this);
36575 markInvalid : function(msg)
36577 if(this.allowBlank || this.disabled){
36581 if(this.labelEl.isVisible(true) && this.indicatorEl()){
36582 this.indicatorEl().removeClass('invisible');
36583 this.indicatorEl().addClass('visible');
36585 if (Roo.bootstrap.version == 3) {
36586 this.el.removeClass([this.invalidClass, this.validClass]);
36587 this.el.addClass(this.invalidClass);
36589 this.el.removeClass(['is-invalid','is-valid']);
36590 this.el.addClass(['is-invalid']);
36593 this.fireEvent('invalid', this, msg);
36597 setValue : function(v, suppressEvent)
36599 if(this.value === v){
36606 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
36609 Roo.each(this.radioes, function(i){
36611 i.el.removeClass('checked');
36614 Roo.each(this.radioes, function(i){
36616 if(i.value === v || i.value.toString() === v.toString()){
36618 i.el.addClass('checked');
36620 if(suppressEvent !== true){
36621 this.fireEvent('check', this, i);
36632 clearInvalid : function(){
36634 if(!this.el || this.preventMark){
36638 this.el.removeClass([this.invalidClass]);
36640 this.fireEvent('valid', this);
36645 Roo.apply(Roo.bootstrap.RadioSet, {
36649 register : function(set)
36651 this.groups[set.name] = set;
36654 get: function(name)
36656 if (typeof(this.groups[name]) == 'undefined') {
36660 return this.groups[name] ;
36666 * Ext JS Library 1.1.1
36667 * Copyright(c) 2006-2007, Ext JS, LLC.
36669 * Originally Released Under LGPL - original licence link has changed is not relivant.
36672 * <script type="text/javascript">
36677 * @class Roo.bootstrap.SplitBar
36678 * @extends Roo.util.Observable
36679 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
36683 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
36684 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
36685 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
36686 split.minSize = 100;
36687 split.maxSize = 600;
36688 split.animate = true;
36689 split.on('moved', splitterMoved);
36692 * Create a new SplitBar
36693 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
36694 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
36695 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
36696 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
36697 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
36698 position of the SplitBar).
36700 Roo.bootstrap.SplitBar = function(cfg){
36705 // dragElement : elm
36706 // resizingElement: el,
36708 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
36709 // placement : Roo.bootstrap.SplitBar.LEFT ,
36710 // existingProxy ???
36713 this.el = Roo.get(cfg.dragElement, true);
36714 this.el.dom.unselectable = "on";
36716 this.resizingEl = Roo.get(cfg.resizingElement, true);
36720 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
36721 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
36724 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
36727 * The minimum size of the resizing element. (Defaults to 0)
36733 * The maximum size of the resizing element. (Defaults to 2000)
36736 this.maxSize = 2000;
36739 * Whether to animate the transition to the new size
36742 this.animate = false;
36745 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
36748 this.useShim = false;
36753 if(!cfg.existingProxy){
36755 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
36757 this.proxy = Roo.get(cfg.existingProxy).dom;
36760 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
36763 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
36766 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
36769 this.dragSpecs = {};
36772 * @private The adapter to use to positon and resize elements
36774 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
36775 this.adapter.init(this);
36777 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
36779 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
36780 this.el.addClass("roo-splitbar-h");
36783 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
36784 this.el.addClass("roo-splitbar-v");
36790 * Fires when the splitter is moved (alias for {@link #event-moved})
36791 * @param {Roo.bootstrap.SplitBar} this
36792 * @param {Number} newSize the new width or height
36797 * Fires when the splitter is moved
36798 * @param {Roo.bootstrap.SplitBar} this
36799 * @param {Number} newSize the new width or height
36803 * @event beforeresize
36804 * Fires before the splitter is dragged
36805 * @param {Roo.bootstrap.SplitBar} this
36807 "beforeresize" : true,
36809 "beforeapply" : true
36812 Roo.util.Observable.call(this);
36815 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
36816 onStartProxyDrag : function(x, y){
36817 this.fireEvent("beforeresize", this);
36819 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
36821 o.enableDisplayMode("block");
36822 // all splitbars share the same overlay
36823 Roo.bootstrap.SplitBar.prototype.overlay = o;
36825 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
36826 this.overlay.show();
36827 Roo.get(this.proxy).setDisplayed("block");
36828 var size = this.adapter.getElementSize(this);
36829 this.activeMinSize = this.getMinimumSize();;
36830 this.activeMaxSize = this.getMaximumSize();;
36831 var c1 = size - this.activeMinSize;
36832 var c2 = Math.max(this.activeMaxSize - size, 0);
36833 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
36834 this.dd.resetConstraints();
36835 this.dd.setXConstraint(
36836 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
36837 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
36839 this.dd.setYConstraint(0, 0);
36841 this.dd.resetConstraints();
36842 this.dd.setXConstraint(0, 0);
36843 this.dd.setYConstraint(
36844 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
36845 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
36848 this.dragSpecs.startSize = size;
36849 this.dragSpecs.startPoint = [x, y];
36850 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
36854 * @private Called after the drag operation by the DDProxy
36856 onEndProxyDrag : function(e){
36857 Roo.get(this.proxy).setDisplayed(false);
36858 var endPoint = Roo.lib.Event.getXY(e);
36860 this.overlay.hide();
36863 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
36864 newSize = this.dragSpecs.startSize +
36865 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
36866 endPoint[0] - this.dragSpecs.startPoint[0] :
36867 this.dragSpecs.startPoint[0] - endPoint[0]
36870 newSize = this.dragSpecs.startSize +
36871 (this.placement == Roo.bootstrap.SplitBar.TOP ?
36872 endPoint[1] - this.dragSpecs.startPoint[1] :
36873 this.dragSpecs.startPoint[1] - endPoint[1]
36876 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
36877 if(newSize != this.dragSpecs.startSize){
36878 if(this.fireEvent('beforeapply', this, newSize) !== false){
36879 this.adapter.setElementSize(this, newSize);
36880 this.fireEvent("moved", this, newSize);
36881 this.fireEvent("resize", this, newSize);
36887 * Get the adapter this SplitBar uses
36888 * @return The adapter object
36890 getAdapter : function(){
36891 return this.adapter;
36895 * Set the adapter this SplitBar uses
36896 * @param {Object} adapter A SplitBar adapter object
36898 setAdapter : function(adapter){
36899 this.adapter = adapter;
36900 this.adapter.init(this);
36904 * Gets the minimum size for the resizing element
36905 * @return {Number} The minimum size
36907 getMinimumSize : function(){
36908 return this.minSize;
36912 * Sets the minimum size for the resizing element
36913 * @param {Number} minSize The minimum size
36915 setMinimumSize : function(minSize){
36916 this.minSize = minSize;
36920 * Gets the maximum size for the resizing element
36921 * @return {Number} The maximum size
36923 getMaximumSize : function(){
36924 return this.maxSize;
36928 * Sets the maximum size for the resizing element
36929 * @param {Number} maxSize The maximum size
36931 setMaximumSize : function(maxSize){
36932 this.maxSize = maxSize;
36936 * Sets the initialize size for the resizing element
36937 * @param {Number} size The initial size
36939 setCurrentSize : function(size){
36940 var oldAnimate = this.animate;
36941 this.animate = false;
36942 this.adapter.setElementSize(this, size);
36943 this.animate = oldAnimate;
36947 * Destroy this splitbar.
36948 * @param {Boolean} removeEl True to remove the element
36950 destroy : function(removeEl){
36952 this.shim.remove();
36955 this.proxy.parentNode.removeChild(this.proxy);
36963 * @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.
36965 Roo.bootstrap.SplitBar.createProxy = function(dir){
36966 var proxy = new Roo.Element(document.createElement("div"));
36967 proxy.unselectable();
36968 var cls = 'roo-splitbar-proxy';
36969 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
36970 document.body.appendChild(proxy.dom);
36975 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
36976 * Default Adapter. It assumes the splitter and resizing element are not positioned
36977 * elements and only gets/sets the width of the element. Generally used for table based layouts.
36979 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
36982 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
36983 // do nothing for now
36984 init : function(s){
36988 * Called before drag operations to get the current size of the resizing element.
36989 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
36991 getElementSize : function(s){
36992 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
36993 return s.resizingEl.getWidth();
36995 return s.resizingEl.getHeight();
37000 * Called after drag operations to set the size of the resizing element.
37001 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
37002 * @param {Number} newSize The new size to set
37003 * @param {Function} onComplete A function to be invoked when resizing is complete
37005 setElementSize : function(s, newSize, onComplete){
37006 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
37008 s.resizingEl.setWidth(newSize);
37010 onComplete(s, newSize);
37013 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
37018 s.resizingEl.setHeight(newSize);
37020 onComplete(s, newSize);
37023 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
37030 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
37031 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
37032 * Adapter that moves the splitter element to align with the resized sizing element.
37033 * Used with an absolute positioned SplitBar.
37034 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
37035 * document.body, make sure you assign an id to the body element.
37037 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
37038 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
37039 this.container = Roo.get(container);
37042 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
37043 init : function(s){
37044 this.basic.init(s);
37047 getElementSize : function(s){
37048 return this.basic.getElementSize(s);
37051 setElementSize : function(s, newSize, onComplete){
37052 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
37055 moveSplitter : function(s){
37056 var yes = Roo.bootstrap.SplitBar;
37057 switch(s.placement){
37059 s.el.setX(s.resizingEl.getRight());
37062 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
37065 s.el.setY(s.resizingEl.getBottom());
37068 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
37075 * Orientation constant - Create a vertical SplitBar
37079 Roo.bootstrap.SplitBar.VERTICAL = 1;
37082 * Orientation constant - Create a horizontal SplitBar
37086 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
37089 * Placement constant - The resizing element is to the left of the splitter element
37093 Roo.bootstrap.SplitBar.LEFT = 1;
37096 * Placement constant - The resizing element is to the right of the splitter element
37100 Roo.bootstrap.SplitBar.RIGHT = 2;
37103 * Placement constant - The resizing element is positioned above the splitter element
37107 Roo.bootstrap.SplitBar.TOP = 3;
37110 * Placement constant - The resizing element is positioned under splitter element
37114 Roo.bootstrap.SplitBar.BOTTOM = 4;
37115 Roo.namespace("Roo.bootstrap.layout");/*
37117 * Ext JS Library 1.1.1
37118 * Copyright(c) 2006-2007, Ext JS, LLC.
37120 * Originally Released Under LGPL - original licence link has changed is not relivant.
37123 * <script type="text/javascript">
37127 * @class Roo.bootstrap.layout.Manager
37128 * @extends Roo.bootstrap.Component
37129 * Base class for layout managers.
37131 Roo.bootstrap.layout.Manager = function(config)
37133 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
37139 /** false to disable window resize monitoring @type Boolean */
37140 this.monitorWindowResize = true;
37145 * Fires when a layout is performed.
37146 * @param {Roo.LayoutManager} this
37150 * @event regionresized
37151 * Fires when the user resizes a region.
37152 * @param {Roo.LayoutRegion} region The resized region
37153 * @param {Number} newSize The new size (width for east/west, height for north/south)
37155 "regionresized" : true,
37157 * @event regioncollapsed
37158 * Fires when a region is collapsed.
37159 * @param {Roo.LayoutRegion} region The collapsed region
37161 "regioncollapsed" : true,
37163 * @event regionexpanded
37164 * Fires when a region is expanded.
37165 * @param {Roo.LayoutRegion} region The expanded region
37167 "regionexpanded" : true
37169 this.updating = false;
37172 this.el = Roo.get(config.el);
37178 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
37183 monitorWindowResize : true,
37189 onRender : function(ct, position)
37192 this.el = Roo.get(ct);
37195 //this.fireEvent('render',this);
37199 initEvents: function()
37203 // ie scrollbar fix
37204 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
37205 document.body.scroll = "no";
37206 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
37207 this.el.position('relative');
37209 this.id = this.el.id;
37210 this.el.addClass("roo-layout-container");
37211 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
37212 if(this.el.dom != document.body ) {
37213 this.el.on('resize', this.layout,this);
37214 this.el.on('show', this.layout,this);
37220 * Returns true if this layout is currently being updated
37221 * @return {Boolean}
37223 isUpdating : function(){
37224 return this.updating;
37228 * Suspend the LayoutManager from doing auto-layouts while
37229 * making multiple add or remove calls
37231 beginUpdate : function(){
37232 this.updating = true;
37236 * Restore auto-layouts and optionally disable the manager from performing a layout
37237 * @param {Boolean} noLayout true to disable a layout update
37239 endUpdate : function(noLayout){
37240 this.updating = false;
37246 layout: function(){
37250 onRegionResized : function(region, newSize){
37251 this.fireEvent("regionresized", region, newSize);
37255 onRegionCollapsed : function(region){
37256 this.fireEvent("regioncollapsed", region);
37259 onRegionExpanded : function(region){
37260 this.fireEvent("regionexpanded", region);
37264 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
37265 * performs box-model adjustments.
37266 * @return {Object} The size as an object {width: (the width), height: (the height)}
37268 getViewSize : function()
37271 if(this.el.dom != document.body){
37272 size = this.el.getSize();
37274 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
37276 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
37277 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
37282 * Returns the Element this layout is bound to.
37283 * @return {Roo.Element}
37285 getEl : function(){
37290 * Returns the specified region.
37291 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
37292 * @return {Roo.LayoutRegion}
37294 getRegion : function(target){
37295 return this.regions[target.toLowerCase()];
37298 onWindowResize : function(){
37299 if(this.monitorWindowResize){
37306 * Ext JS Library 1.1.1
37307 * Copyright(c) 2006-2007, Ext JS, LLC.
37309 * Originally Released Under LGPL - original licence link has changed is not relivant.
37312 * <script type="text/javascript">
37315 * @class Roo.bootstrap.layout.Border
37316 * @extends Roo.bootstrap.layout.Manager
37317 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
37318 * please see: examples/bootstrap/nested.html<br><br>
37320 <b>The container the layout is rendered into can be either the body element or any other element.
37321 If it is not the body element, the container needs to either be an absolute positioned element,
37322 or you will need to add "position:relative" to the css of the container. You will also need to specify
37323 the container size if it is not the body element.</b>
37326 * Create a new Border
37327 * @param {Object} config Configuration options
37329 Roo.bootstrap.layout.Border = function(config){
37330 config = config || {};
37331 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
37335 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
37336 if(config[region]){
37337 config[region].region = region;
37338 this.addRegion(config[region]);
37344 Roo.bootstrap.layout.Border.regions = ["center", "north","south","east","west"];
37346 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
37348 parent : false, // this might point to a 'nest' or a ???
37351 * Creates and adds a new region if it doesn't already exist.
37352 * @param {String} target The target region key (north, south, east, west or center).
37353 * @param {Object} config The regions config object
37354 * @return {BorderLayoutRegion} The new region
37356 addRegion : function(config)
37358 if(!this.regions[config.region]){
37359 var r = this.factory(config);
37360 this.bindRegion(r);
37362 return this.regions[config.region];
37366 bindRegion : function(r){
37367 this.regions[r.config.region] = r;
37369 r.on("visibilitychange", this.layout, this);
37370 r.on("paneladded", this.layout, this);
37371 r.on("panelremoved", this.layout, this);
37372 r.on("invalidated", this.layout, this);
37373 r.on("resized", this.onRegionResized, this);
37374 r.on("collapsed", this.onRegionCollapsed, this);
37375 r.on("expanded", this.onRegionExpanded, this);
37379 * Performs a layout update.
37381 layout : function()
37383 if(this.updating) {
37387 // render all the rebions if they have not been done alreayd?
37388 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
37389 if(this.regions[region] && !this.regions[region].bodyEl){
37390 this.regions[region].onRender(this.el)
37394 var size = this.getViewSize();
37395 var w = size.width;
37396 var h = size.height;
37401 //var x = 0, y = 0;
37403 var rs = this.regions;
37404 var north = rs["north"];
37405 var south = rs["south"];
37406 var west = rs["west"];
37407 var east = rs["east"];
37408 var center = rs["center"];
37409 //if(this.hideOnLayout){ // not supported anymore
37410 //c.el.setStyle("display", "none");
37412 if(north && north.isVisible()){
37413 var b = north.getBox();
37414 var m = north.getMargins();
37415 b.width = w - (m.left+m.right);
37418 centerY = b.height + b.y + m.bottom;
37419 centerH -= centerY;
37420 north.updateBox(this.safeBox(b));
37422 if(south && south.isVisible()){
37423 var b = south.getBox();
37424 var m = south.getMargins();
37425 b.width = w - (m.left+m.right);
37427 var totalHeight = (b.height + m.top + m.bottom);
37428 b.y = h - totalHeight + m.top;
37429 centerH -= totalHeight;
37430 south.updateBox(this.safeBox(b));
37432 if(west && west.isVisible()){
37433 var b = west.getBox();
37434 var m = west.getMargins();
37435 b.height = centerH - (m.top+m.bottom);
37437 b.y = centerY + m.top;
37438 var totalWidth = (b.width + m.left + m.right);
37439 centerX += totalWidth;
37440 centerW -= totalWidth;
37441 west.updateBox(this.safeBox(b));
37443 if(east && east.isVisible()){
37444 var b = east.getBox();
37445 var m = east.getMargins();
37446 b.height = centerH - (m.top+m.bottom);
37447 var totalWidth = (b.width + m.left + m.right);
37448 b.x = w - totalWidth + m.left;
37449 b.y = centerY + m.top;
37450 centerW -= totalWidth;
37451 east.updateBox(this.safeBox(b));
37454 var m = center.getMargins();
37456 x: centerX + m.left,
37457 y: centerY + m.top,
37458 width: centerW - (m.left+m.right),
37459 height: centerH - (m.top+m.bottom)
37461 //if(this.hideOnLayout){
37462 //center.el.setStyle("display", "block");
37464 center.updateBox(this.safeBox(centerBox));
37467 this.fireEvent("layout", this);
37471 safeBox : function(box){
37472 box.width = Math.max(0, box.width);
37473 box.height = Math.max(0, box.height);
37478 * Adds a ContentPanel (or subclass) to this layout.
37479 * @param {String} target The target region key (north, south, east, west or center).
37480 * @param {Roo.ContentPanel} panel The panel to add
37481 * @return {Roo.ContentPanel} The added panel
37483 add : function(target, panel){
37485 target = target.toLowerCase();
37486 return this.regions[target].add(panel);
37490 * Remove a ContentPanel (or subclass) to this layout.
37491 * @param {String} target The target region key (north, south, east, west or center).
37492 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
37493 * @return {Roo.ContentPanel} The removed panel
37495 remove : function(target, panel){
37496 target = target.toLowerCase();
37497 return this.regions[target].remove(panel);
37501 * Searches all regions for a panel with the specified id
37502 * @param {String} panelId
37503 * @return {Roo.ContentPanel} The panel or null if it wasn't found
37505 findPanel : function(panelId){
37506 var rs = this.regions;
37507 for(var target in rs){
37508 if(typeof rs[target] != "function"){
37509 var p = rs[target].getPanel(panelId);
37519 * Searches all regions for a panel with the specified id and activates (shows) it.
37520 * @param {String/ContentPanel} panelId The panels id or the panel itself
37521 * @return {Roo.ContentPanel} The shown panel or null
37523 showPanel : function(panelId) {
37524 var rs = this.regions;
37525 for(var target in rs){
37526 var r = rs[target];
37527 if(typeof r != "function"){
37528 if(r.hasPanel(panelId)){
37529 return r.showPanel(panelId);
37537 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
37538 * @param {Roo.state.Provider} provider (optional) An alternate state provider
37541 restoreState : function(provider){
37543 provider = Roo.state.Manager;
37545 var sm = new Roo.LayoutStateManager();
37546 sm.init(this, provider);
37552 * Adds a xtype elements to the layout.
37556 xtype : 'ContentPanel',
37563 xtype : 'NestedLayoutPanel',
37569 items : [ ... list of content panels or nested layout panels.. ]
37573 * @param {Object} cfg Xtype definition of item to add.
37575 addxtype : function(cfg)
37577 // basically accepts a pannel...
37578 // can accept a layout region..!?!?
37579 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
37582 // theory? children can only be panels??
37584 //if (!cfg.xtype.match(/Panel$/)) {
37589 if (typeof(cfg.region) == 'undefined') {
37590 Roo.log("Failed to add Panel, region was not set");
37594 var region = cfg.region;
37600 xitems = cfg.items;
37605 if ( region == 'center') {
37606 Roo.log("Center: " + cfg.title);
37612 case 'Content': // ContentPanel (el, cfg)
37613 case 'Scroll': // ContentPanel (el, cfg)
37615 cfg.autoCreate = cfg.autoCreate || true;
37616 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
37618 // var el = this.el.createChild();
37619 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
37622 this.add(region, ret);
37626 case 'TreePanel': // our new panel!
37627 cfg.el = this.el.createChild();
37628 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
37629 this.add(region, ret);
37634 // create a new Layout (which is a Border Layout...
37636 var clayout = cfg.layout;
37637 clayout.el = this.el.createChild();
37638 clayout.items = clayout.items || [];
37642 // replace this exitems with the clayout ones..
37643 xitems = clayout.items;
37645 // force background off if it's in center...
37646 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
37647 cfg.background = false;
37649 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
37652 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
37653 //console.log('adding nested layout panel ' + cfg.toSource());
37654 this.add(region, ret);
37655 nb = {}; /// find first...
37660 // needs grid and region
37662 //var el = this.getRegion(region).el.createChild();
37664 *var el = this.el.createChild();
37665 // create the grid first...
37666 cfg.grid.container = el;
37667 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
37670 if (region == 'center' && this.active ) {
37671 cfg.background = false;
37674 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
37676 this.add(region, ret);
37678 if (cfg.background) {
37679 // render grid on panel activation (if panel background)
37680 ret.on('activate', function(gp) {
37681 if (!gp.grid.rendered) {
37682 // gp.grid.render(el);
37686 // cfg.grid.render(el);
37692 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
37693 // it was the old xcomponent building that caused this before.
37694 // espeically if border is the top element in the tree.
37704 if (typeof(Roo[cfg.xtype]) != 'undefined') {
37706 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
37707 this.add(region, ret);
37711 throw "Can not add '" + cfg.xtype + "' to Border";
37717 this.beginUpdate();
37721 Roo.each(xitems, function(i) {
37722 region = nb && i.region ? i.region : false;
37724 var add = ret.addxtype(i);
37727 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
37728 if (!i.background) {
37729 abn[region] = nb[region] ;
37736 // make the last non-background panel active..
37737 //if (nb) { Roo.log(abn); }
37740 for(var r in abn) {
37741 region = this.getRegion(r);
37743 // tried using nb[r], but it does not work..
37745 region.showPanel(abn[r]);
37756 factory : function(cfg)
37759 var validRegions = Roo.bootstrap.layout.Border.regions;
37761 var target = cfg.region;
37764 var r = Roo.bootstrap.layout;
37768 return new r.North(cfg);
37770 return new r.South(cfg);
37772 return new r.East(cfg);
37774 return new r.West(cfg);
37776 return new r.Center(cfg);
37778 throw 'Layout region "'+target+'" not supported.';
37785 * Ext JS Library 1.1.1
37786 * Copyright(c) 2006-2007, Ext JS, LLC.
37788 * Originally Released Under LGPL - original licence link has changed is not relivant.
37791 * <script type="text/javascript">
37795 * @class Roo.bootstrap.layout.Basic
37796 * @extends Roo.util.Observable
37797 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
37798 * and does not have a titlebar, tabs or any other features. All it does is size and position
37799 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
37800 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
37801 * @cfg {string} region the region that it inhabits..
37802 * @cfg {bool} skipConfig skip config?
37806 Roo.bootstrap.layout.Basic = function(config){
37808 this.mgr = config.mgr;
37810 this.position = config.region;
37812 var skipConfig = config.skipConfig;
37816 * @scope Roo.BasicLayoutRegion
37820 * @event beforeremove
37821 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
37822 * @param {Roo.LayoutRegion} this
37823 * @param {Roo.ContentPanel} panel The panel
37824 * @param {Object} e The cancel event object
37826 "beforeremove" : true,
37828 * @event invalidated
37829 * Fires when the layout for this region is changed.
37830 * @param {Roo.LayoutRegion} this
37832 "invalidated" : true,
37834 * @event visibilitychange
37835 * Fires when this region is shown or hidden
37836 * @param {Roo.LayoutRegion} this
37837 * @param {Boolean} visibility true or false
37839 "visibilitychange" : true,
37841 * @event paneladded
37842 * Fires when a panel is added.
37843 * @param {Roo.LayoutRegion} this
37844 * @param {Roo.ContentPanel} panel The panel
37846 "paneladded" : true,
37848 * @event panelremoved
37849 * Fires when a panel is removed.
37850 * @param {Roo.LayoutRegion} this
37851 * @param {Roo.ContentPanel} panel The panel
37853 "panelremoved" : true,
37855 * @event beforecollapse
37856 * Fires when this region before collapse.
37857 * @param {Roo.LayoutRegion} this
37859 "beforecollapse" : true,
37862 * Fires when this region is collapsed.
37863 * @param {Roo.LayoutRegion} this
37865 "collapsed" : true,
37868 * Fires when this region is expanded.
37869 * @param {Roo.LayoutRegion} this
37874 * Fires when this region is slid into view.
37875 * @param {Roo.LayoutRegion} this
37877 "slideshow" : true,
37880 * Fires when this region slides out of view.
37881 * @param {Roo.LayoutRegion} this
37883 "slidehide" : true,
37885 * @event panelactivated
37886 * Fires when a panel is activated.
37887 * @param {Roo.LayoutRegion} this
37888 * @param {Roo.ContentPanel} panel The activated panel
37890 "panelactivated" : true,
37893 * Fires when the user resizes this region.
37894 * @param {Roo.LayoutRegion} this
37895 * @param {Number} newSize The new size (width for east/west, height for north/south)
37899 /** A collection of panels in this region. @type Roo.util.MixedCollection */
37900 this.panels = new Roo.util.MixedCollection();
37901 this.panels.getKey = this.getPanelId.createDelegate(this);
37903 this.activePanel = null;
37904 // ensure listeners are added...
37906 if (config.listeners || config.events) {
37907 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
37908 listeners : config.listeners || {},
37909 events : config.events || {}
37913 if(skipConfig !== true){
37914 this.applyConfig(config);
37918 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
37920 getPanelId : function(p){
37924 applyConfig : function(config){
37925 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
37926 this.config = config;
37931 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
37932 * the width, for horizontal (north, south) the height.
37933 * @param {Number} newSize The new width or height
37935 resizeTo : function(newSize){
37936 var el = this.el ? this.el :
37937 (this.activePanel ? this.activePanel.getEl() : null);
37939 switch(this.position){
37942 el.setWidth(newSize);
37943 this.fireEvent("resized", this, newSize);
37947 el.setHeight(newSize);
37948 this.fireEvent("resized", this, newSize);
37954 getBox : function(){
37955 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
37958 getMargins : function(){
37959 return this.margins;
37962 updateBox : function(box){
37964 var el = this.activePanel.getEl();
37965 el.dom.style.left = box.x + "px";
37966 el.dom.style.top = box.y + "px";
37967 this.activePanel.setSize(box.width, box.height);
37971 * Returns the container element for this region.
37972 * @return {Roo.Element}
37974 getEl : function(){
37975 return this.activePanel;
37979 * Returns true if this region is currently visible.
37980 * @return {Boolean}
37982 isVisible : function(){
37983 return this.activePanel ? true : false;
37986 setActivePanel : function(panel){
37987 panel = this.getPanel(panel);
37988 if(this.activePanel && this.activePanel != panel){
37989 this.activePanel.setActiveState(false);
37990 this.activePanel.getEl().setLeftTop(-10000,-10000);
37992 this.activePanel = panel;
37993 panel.setActiveState(true);
37995 panel.setSize(this.box.width, this.box.height);
37997 this.fireEvent("panelactivated", this, panel);
37998 this.fireEvent("invalidated");
38002 * Show the specified panel.
38003 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
38004 * @return {Roo.ContentPanel} The shown panel or null
38006 showPanel : function(panel){
38007 panel = this.getPanel(panel);
38009 this.setActivePanel(panel);
38015 * Get the active panel for this region.
38016 * @return {Roo.ContentPanel} The active panel or null
38018 getActivePanel : function(){
38019 return this.activePanel;
38023 * Add the passed ContentPanel(s)
38024 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
38025 * @return {Roo.ContentPanel} The panel added (if only one was added)
38027 add : function(panel){
38028 if(arguments.length > 1){
38029 for(var i = 0, len = arguments.length; i < len; i++) {
38030 this.add(arguments[i]);
38034 if(this.hasPanel(panel)){
38035 this.showPanel(panel);
38038 var el = panel.getEl();
38039 if(el.dom.parentNode != this.mgr.el.dom){
38040 this.mgr.el.dom.appendChild(el.dom);
38042 if(panel.setRegion){
38043 panel.setRegion(this);
38045 this.panels.add(panel);
38046 el.setStyle("position", "absolute");
38047 if(!panel.background){
38048 this.setActivePanel(panel);
38049 if(this.config.initialSize && this.panels.getCount()==1){
38050 this.resizeTo(this.config.initialSize);
38053 this.fireEvent("paneladded", this, panel);
38058 * Returns true if the panel is in this region.
38059 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
38060 * @return {Boolean}
38062 hasPanel : function(panel){
38063 if(typeof panel == "object"){ // must be panel obj
38064 panel = panel.getId();
38066 return this.getPanel(panel) ? true : false;
38070 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
38071 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
38072 * @param {Boolean} preservePanel Overrides the config preservePanel option
38073 * @return {Roo.ContentPanel} The panel that was removed
38075 remove : function(panel, preservePanel){
38076 panel = this.getPanel(panel);
38081 this.fireEvent("beforeremove", this, panel, e);
38082 if(e.cancel === true){
38085 var panelId = panel.getId();
38086 this.panels.removeKey(panelId);
38091 * Returns the panel specified or null if it's not in this region.
38092 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
38093 * @return {Roo.ContentPanel}
38095 getPanel : function(id){
38096 if(typeof id == "object"){ // must be panel obj
38099 return this.panels.get(id);
38103 * Returns this regions position (north/south/east/west/center).
38106 getPosition: function(){
38107 return this.position;
38111 * Ext JS Library 1.1.1
38112 * Copyright(c) 2006-2007, Ext JS, LLC.
38114 * Originally Released Under LGPL - original licence link has changed is not relivant.
38117 * <script type="text/javascript">
38121 * @class Roo.bootstrap.layout.Region
38122 * @extends Roo.bootstrap.layout.Basic
38123 * This class represents a region in a layout manager.
38125 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
38126 * @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})
38127 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
38128 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
38129 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
38130 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
38131 * @cfg {String} title The title for the region (overrides panel titles)
38132 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
38133 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
38134 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
38135 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
38136 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
38137 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
38138 * the space available, similar to FireFox 1.5 tabs (defaults to false)
38139 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
38140 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
38141 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
38143 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
38144 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
38145 * @cfg {Boolean} disableTabTips True to disable tab tooltips
38146 * @cfg {Number} width For East/West panels
38147 * @cfg {Number} height For North/South panels
38148 * @cfg {Boolean} split To show the splitter
38149 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
38151 * @cfg {string} cls Extra CSS classes to add to region
38153 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
38154 * @cfg {string} region the region that it inhabits..
38157 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
38158 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
38160 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
38161 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
38162 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
38164 Roo.bootstrap.layout.Region = function(config)
38166 this.applyConfig(config);
38168 var mgr = config.mgr;
38169 var pos = config.region;
38170 config.skipConfig = true;
38171 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
38174 this.onRender(mgr.el);
38177 this.visible = true;
38178 this.collapsed = false;
38179 this.unrendered_panels = [];
38182 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
38184 position: '', // set by wrapper (eg. north/south etc..)
38185 unrendered_panels : null, // unrendered panels.
38187 tabPosition : false,
38189 mgr: false, // points to 'Border'
38192 createBody : function(){
38193 /** This region's body element
38194 * @type Roo.Element */
38195 this.bodyEl = this.el.createChild({
38197 cls: "roo-layout-panel-body tab-content" // bootstrap added...
38201 onRender: function(ctr, pos)
38203 var dh = Roo.DomHelper;
38204 /** This region's container element
38205 * @type Roo.Element */
38206 this.el = dh.append(ctr.dom, {
38208 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
38210 /** This region's title element
38211 * @type Roo.Element */
38213 this.titleEl = dh.append(this.el.dom, {
38215 unselectable: "on",
38216 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
38218 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
38219 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
38223 this.titleEl.enableDisplayMode();
38224 /** This region's title text element
38225 * @type HTMLElement */
38226 this.titleTextEl = this.titleEl.dom.firstChild;
38227 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
38229 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
38230 this.closeBtn.enableDisplayMode();
38231 this.closeBtn.on("click", this.closeClicked, this);
38232 this.closeBtn.hide();
38234 this.createBody(this.config);
38235 if(this.config.hideWhenEmpty){
38237 this.on("paneladded", this.validateVisibility, this);
38238 this.on("panelremoved", this.validateVisibility, this);
38240 if(this.autoScroll){
38241 this.bodyEl.setStyle("overflow", "auto");
38243 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
38245 //if(c.titlebar !== false){
38246 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
38247 this.titleEl.hide();
38249 this.titleEl.show();
38250 if(this.config.title){
38251 this.titleTextEl.innerHTML = this.config.title;
38255 if(this.config.collapsed){
38256 this.collapse(true);
38258 if(this.config.hidden){
38262 if (this.unrendered_panels && this.unrendered_panels.length) {
38263 for (var i =0;i< this.unrendered_panels.length; i++) {
38264 this.add(this.unrendered_panels[i]);
38266 this.unrendered_panels = null;
38272 applyConfig : function(c)
38275 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
38276 var dh = Roo.DomHelper;
38277 if(c.titlebar !== false){
38278 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
38279 this.collapseBtn.on("click", this.collapse, this);
38280 this.collapseBtn.enableDisplayMode();
38282 if(c.showPin === true || this.showPin){
38283 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
38284 this.stickBtn.enableDisplayMode();
38285 this.stickBtn.on("click", this.expand, this);
38286 this.stickBtn.hide();
38291 /** This region's collapsed element
38292 * @type Roo.Element */
38295 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
38296 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
38299 if(c.floatable !== false){
38300 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
38301 this.collapsedEl.on("click", this.collapseClick, this);
38304 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
38305 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
38306 id: "message", unselectable: "on", style:{"float":"left"}});
38307 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
38309 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
38310 this.expandBtn.on("click", this.expand, this);
38314 if(this.collapseBtn){
38315 this.collapseBtn.setVisible(c.collapsible == true);
38318 this.cmargins = c.cmargins || this.cmargins ||
38319 (this.position == "west" || this.position == "east" ?
38320 {top: 0, left: 2, right:2, bottom: 0} :
38321 {top: 2, left: 0, right:0, bottom: 2});
38323 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
38326 this.tabPosition = [ 'top','bottom', 'west'].indexOf(c.tabPosition) > -1 ? c.tabPosition : "top";
38328 this.autoScroll = c.autoScroll || false;
38333 this.duration = c.duration || .30;
38334 this.slideDuration = c.slideDuration || .45;
38339 * Returns true if this region is currently visible.
38340 * @return {Boolean}
38342 isVisible : function(){
38343 return this.visible;
38347 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
38348 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
38350 //setCollapsedTitle : function(title){
38351 // title = title || " ";
38352 // if(this.collapsedTitleTextEl){
38353 // this.collapsedTitleTextEl.innerHTML = title;
38357 getBox : function(){
38359 // if(!this.collapsed){
38360 b = this.el.getBox(false, true);
38362 // b = this.collapsedEl.getBox(false, true);
38367 getMargins : function(){
38368 return this.margins;
38369 //return this.collapsed ? this.cmargins : this.margins;
38372 highlight : function(){
38373 this.el.addClass("x-layout-panel-dragover");
38376 unhighlight : function(){
38377 this.el.removeClass("x-layout-panel-dragover");
38380 updateBox : function(box)
38382 if (!this.bodyEl) {
38383 return; // not rendered yet..
38387 if(!this.collapsed){
38388 this.el.dom.style.left = box.x + "px";
38389 this.el.dom.style.top = box.y + "px";
38390 this.updateBody(box.width, box.height);
38392 this.collapsedEl.dom.style.left = box.x + "px";
38393 this.collapsedEl.dom.style.top = box.y + "px";
38394 this.collapsedEl.setSize(box.width, box.height);
38397 this.tabs.autoSizeTabs();
38401 updateBody : function(w, h)
38404 this.el.setWidth(w);
38405 w -= this.el.getBorderWidth("rl");
38406 if(this.config.adjustments){
38407 w += this.config.adjustments[0];
38410 if(h !== null && h > 0){
38411 this.el.setHeight(h);
38412 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
38413 h -= this.el.getBorderWidth("tb");
38414 if(this.config.adjustments){
38415 h += this.config.adjustments[1];
38417 this.bodyEl.setHeight(h);
38419 h = this.tabs.syncHeight(h);
38422 if(this.panelSize){
38423 w = w !== null ? w : this.panelSize.width;
38424 h = h !== null ? h : this.panelSize.height;
38426 if(this.activePanel){
38427 var el = this.activePanel.getEl();
38428 w = w !== null ? w : el.getWidth();
38429 h = h !== null ? h : el.getHeight();
38430 this.panelSize = {width: w, height: h};
38431 this.activePanel.setSize(w, h);
38433 if(Roo.isIE && this.tabs){
38434 this.tabs.el.repaint();
38439 * Returns the container element for this region.
38440 * @return {Roo.Element}
38442 getEl : function(){
38447 * Hides this region.
38450 //if(!this.collapsed){
38451 this.el.dom.style.left = "-2000px";
38454 // this.collapsedEl.dom.style.left = "-2000px";
38455 // this.collapsedEl.hide();
38457 this.visible = false;
38458 this.fireEvent("visibilitychange", this, false);
38462 * Shows this region if it was previously hidden.
38465 //if(!this.collapsed){
38468 // this.collapsedEl.show();
38470 this.visible = true;
38471 this.fireEvent("visibilitychange", this, true);
38474 closeClicked : function(){
38475 if(this.activePanel){
38476 this.remove(this.activePanel);
38480 collapseClick : function(e){
38482 e.stopPropagation();
38485 e.stopPropagation();
38491 * Collapses this region.
38492 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
38495 collapse : function(skipAnim, skipCheck = false){
38496 if(this.collapsed) {
38500 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
38502 this.collapsed = true;
38504 this.split.el.hide();
38506 if(this.config.animate && skipAnim !== true){
38507 this.fireEvent("invalidated", this);
38508 this.animateCollapse();
38510 this.el.setLocation(-20000,-20000);
38512 this.collapsedEl.show();
38513 this.fireEvent("collapsed", this);
38514 this.fireEvent("invalidated", this);
38520 animateCollapse : function(){
38525 * Expands this region if it was previously collapsed.
38526 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
38527 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
38530 expand : function(e, skipAnim){
38532 e.stopPropagation();
38534 if(!this.collapsed || this.el.hasActiveFx()) {
38538 this.afterSlideIn();
38541 this.collapsed = false;
38542 if(this.config.animate && skipAnim !== true){
38543 this.animateExpand();
38547 this.split.el.show();
38549 this.collapsedEl.setLocation(-2000,-2000);
38550 this.collapsedEl.hide();
38551 this.fireEvent("invalidated", this);
38552 this.fireEvent("expanded", this);
38556 animateExpand : function(){
38560 initTabs : function()
38562 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
38564 var ts = new Roo.bootstrap.panel.Tabs({
38565 el: this.bodyEl.dom,
38567 tabPosition: this.tabPosition ? this.tabPosition : 'top',
38568 disableTooltips: this.config.disableTabTips,
38569 toolbar : this.config.toolbar
38572 if(this.config.hideTabs){
38573 ts.stripWrap.setDisplayed(false);
38576 ts.resizeTabs = this.config.resizeTabs === true;
38577 ts.minTabWidth = this.config.minTabWidth || 40;
38578 ts.maxTabWidth = this.config.maxTabWidth || 250;
38579 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
38580 ts.monitorResize = false;
38581 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
38582 ts.bodyEl.addClass('roo-layout-tabs-body');
38583 this.panels.each(this.initPanelAsTab, this);
38586 initPanelAsTab : function(panel){
38587 var ti = this.tabs.addTab(
38591 this.config.closeOnTab && panel.isClosable(),
38594 if(panel.tabTip !== undefined){
38595 ti.setTooltip(panel.tabTip);
38597 ti.on("activate", function(){
38598 this.setActivePanel(panel);
38601 if(this.config.closeOnTab){
38602 ti.on("beforeclose", function(t, e){
38604 this.remove(panel);
38608 panel.tabItem = ti;
38613 updatePanelTitle : function(panel, title)
38615 if(this.activePanel == panel){
38616 this.updateTitle(title);
38619 var ti = this.tabs.getTab(panel.getEl().id);
38621 if(panel.tabTip !== undefined){
38622 ti.setTooltip(panel.tabTip);
38627 updateTitle : function(title){
38628 if(this.titleTextEl && !this.config.title){
38629 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
38633 setActivePanel : function(panel)
38635 panel = this.getPanel(panel);
38636 if(this.activePanel && this.activePanel != panel){
38637 if(this.activePanel.setActiveState(false) === false){
38641 this.activePanel = panel;
38642 panel.setActiveState(true);
38643 if(this.panelSize){
38644 panel.setSize(this.panelSize.width, this.panelSize.height);
38647 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
38649 this.updateTitle(panel.getTitle());
38651 this.fireEvent("invalidated", this);
38653 this.fireEvent("panelactivated", this, panel);
38657 * Shows the specified panel.
38658 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
38659 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
38661 showPanel : function(panel)
38663 panel = this.getPanel(panel);
38666 var tab = this.tabs.getTab(panel.getEl().id);
38667 if(tab.isHidden()){
38668 this.tabs.unhideTab(tab.id);
38672 this.setActivePanel(panel);
38679 * Get the active panel for this region.
38680 * @return {Roo.ContentPanel} The active panel or null
38682 getActivePanel : function(){
38683 return this.activePanel;
38686 validateVisibility : function(){
38687 if(this.panels.getCount() < 1){
38688 this.updateTitle(" ");
38689 this.closeBtn.hide();
38692 if(!this.isVisible()){
38699 * Adds the passed ContentPanel(s) to this region.
38700 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
38701 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
38703 add : function(panel)
38705 if(arguments.length > 1){
38706 for(var i = 0, len = arguments.length; i < len; i++) {
38707 this.add(arguments[i]);
38712 // if we have not been rendered yet, then we can not really do much of this..
38713 if (!this.bodyEl) {
38714 this.unrendered_panels.push(panel);
38721 if(this.hasPanel(panel)){
38722 this.showPanel(panel);
38725 panel.setRegion(this);
38726 this.panels.add(panel);
38727 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
38728 // sinle panel - no tab...?? would it not be better to render it with the tabs,
38729 // and hide them... ???
38730 this.bodyEl.dom.appendChild(panel.getEl().dom);
38731 if(panel.background !== true){
38732 this.setActivePanel(panel);
38734 this.fireEvent("paneladded", this, panel);
38741 this.initPanelAsTab(panel);
38745 if(panel.background !== true){
38746 this.tabs.activate(panel.getEl().id);
38748 this.fireEvent("paneladded", this, panel);
38753 * Hides the tab for the specified panel.
38754 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
38756 hidePanel : function(panel){
38757 if(this.tabs && (panel = this.getPanel(panel))){
38758 this.tabs.hideTab(panel.getEl().id);
38763 * Unhides the tab for a previously hidden panel.
38764 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
38766 unhidePanel : function(panel){
38767 if(this.tabs && (panel = this.getPanel(panel))){
38768 this.tabs.unhideTab(panel.getEl().id);
38772 clearPanels : function(){
38773 while(this.panels.getCount() > 0){
38774 this.remove(this.panels.first());
38779 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
38780 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
38781 * @param {Boolean} preservePanel Overrides the config preservePanel option
38782 * @return {Roo.ContentPanel} The panel that was removed
38784 remove : function(panel, preservePanel)
38786 panel = this.getPanel(panel);
38791 this.fireEvent("beforeremove", this, panel, e);
38792 if(e.cancel === true){
38795 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
38796 var panelId = panel.getId();
38797 this.panels.removeKey(panelId);
38799 document.body.appendChild(panel.getEl().dom);
38802 this.tabs.removeTab(panel.getEl().id);
38803 }else if (!preservePanel){
38804 this.bodyEl.dom.removeChild(panel.getEl().dom);
38806 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
38807 var p = this.panels.first();
38808 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
38809 tempEl.appendChild(p.getEl().dom);
38810 this.bodyEl.update("");
38811 this.bodyEl.dom.appendChild(p.getEl().dom);
38813 this.updateTitle(p.getTitle());
38815 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
38816 this.setActivePanel(p);
38818 panel.setRegion(null);
38819 if(this.activePanel == panel){
38820 this.activePanel = null;
38822 if(this.config.autoDestroy !== false && preservePanel !== true){
38823 try{panel.destroy();}catch(e){}
38825 this.fireEvent("panelremoved", this, panel);
38830 * Returns the TabPanel component used by this region
38831 * @return {Roo.TabPanel}
38833 getTabs : function(){
38837 createTool : function(parentEl, className){
38838 var btn = Roo.DomHelper.append(parentEl, {
38840 cls: "x-layout-tools-button",
38843 cls: "roo-layout-tools-button-inner " + className,
38847 btn.addClassOnOver("roo-layout-tools-button-over");
38852 * Ext JS Library 1.1.1
38853 * Copyright(c) 2006-2007, Ext JS, LLC.
38855 * Originally Released Under LGPL - original licence link has changed is not relivant.
38858 * <script type="text/javascript">
38864 * @class Roo.SplitLayoutRegion
38865 * @extends Roo.LayoutRegion
38866 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
38868 Roo.bootstrap.layout.Split = function(config){
38869 this.cursor = config.cursor;
38870 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
38873 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
38875 splitTip : "Drag to resize.",
38876 collapsibleSplitTip : "Drag to resize. Double click to hide.",
38877 useSplitTips : false,
38879 applyConfig : function(config){
38880 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
38883 onRender : function(ctr,pos) {
38885 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
38886 if(!this.config.split){
38891 var splitEl = Roo.DomHelper.append(ctr.dom, {
38893 id: this.el.id + "-split",
38894 cls: "roo-layout-split roo-layout-split-"+this.position,
38897 /** The SplitBar for this region
38898 * @type Roo.SplitBar */
38899 // does not exist yet...
38900 Roo.log([this.position, this.orientation]);
38902 this.split = new Roo.bootstrap.SplitBar({
38903 dragElement : splitEl,
38904 resizingElement: this.el,
38905 orientation : this.orientation
38908 this.split.on("moved", this.onSplitMove, this);
38909 this.split.useShim = this.config.useShim === true;
38910 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
38911 if(this.useSplitTips){
38912 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
38914 //if(config.collapsible){
38915 // this.split.el.on("dblclick", this.collapse, this);
38918 if(typeof this.config.minSize != "undefined"){
38919 this.split.minSize = this.config.minSize;
38921 if(typeof this.config.maxSize != "undefined"){
38922 this.split.maxSize = this.config.maxSize;
38924 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
38925 this.hideSplitter();
38930 getHMaxSize : function(){
38931 var cmax = this.config.maxSize || 10000;
38932 var center = this.mgr.getRegion("center");
38933 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
38936 getVMaxSize : function(){
38937 var cmax = this.config.maxSize || 10000;
38938 var center = this.mgr.getRegion("center");
38939 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
38942 onSplitMove : function(split, newSize){
38943 this.fireEvent("resized", this, newSize);
38947 * Returns the {@link Roo.SplitBar} for this region.
38948 * @return {Roo.SplitBar}
38950 getSplitBar : function(){
38955 this.hideSplitter();
38956 Roo.bootstrap.layout.Split.superclass.hide.call(this);
38959 hideSplitter : function(){
38961 this.split.el.setLocation(-2000,-2000);
38962 this.split.el.hide();
38968 this.split.el.show();
38970 Roo.bootstrap.layout.Split.superclass.show.call(this);
38973 beforeSlide: function(){
38974 if(Roo.isGecko){// firefox overflow auto bug workaround
38975 this.bodyEl.clip();
38977 this.tabs.bodyEl.clip();
38979 if(this.activePanel){
38980 this.activePanel.getEl().clip();
38982 if(this.activePanel.beforeSlide){
38983 this.activePanel.beforeSlide();
38989 afterSlide : function(){
38990 if(Roo.isGecko){// firefox overflow auto bug workaround
38991 this.bodyEl.unclip();
38993 this.tabs.bodyEl.unclip();
38995 if(this.activePanel){
38996 this.activePanel.getEl().unclip();
38997 if(this.activePanel.afterSlide){
38998 this.activePanel.afterSlide();
39004 initAutoHide : function(){
39005 if(this.autoHide !== false){
39006 if(!this.autoHideHd){
39007 var st = new Roo.util.DelayedTask(this.slideIn, this);
39008 this.autoHideHd = {
39009 "mouseout": function(e){
39010 if(!e.within(this.el, true)){
39014 "mouseover" : function(e){
39020 this.el.on(this.autoHideHd);
39024 clearAutoHide : function(){
39025 if(this.autoHide !== false){
39026 this.el.un("mouseout", this.autoHideHd.mouseout);
39027 this.el.un("mouseover", this.autoHideHd.mouseover);
39031 clearMonitor : function(){
39032 Roo.get(document).un("click", this.slideInIf, this);
39035 // these names are backwards but not changed for compat
39036 slideOut : function(){
39037 if(this.isSlid || this.el.hasActiveFx()){
39040 this.isSlid = true;
39041 if(this.collapseBtn){
39042 this.collapseBtn.hide();
39044 this.closeBtnState = this.closeBtn.getStyle('display');
39045 this.closeBtn.hide();
39047 this.stickBtn.show();
39050 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
39051 this.beforeSlide();
39052 this.el.setStyle("z-index", 10001);
39053 this.el.slideIn(this.getSlideAnchor(), {
39054 callback: function(){
39056 this.initAutoHide();
39057 Roo.get(document).on("click", this.slideInIf, this);
39058 this.fireEvent("slideshow", this);
39065 afterSlideIn : function(){
39066 this.clearAutoHide();
39067 this.isSlid = false;
39068 this.clearMonitor();
39069 this.el.setStyle("z-index", "");
39070 if(this.collapseBtn){
39071 this.collapseBtn.show();
39073 this.closeBtn.setStyle('display', this.closeBtnState);
39075 this.stickBtn.hide();
39077 this.fireEvent("slidehide", this);
39080 slideIn : function(cb){
39081 if(!this.isSlid || this.el.hasActiveFx()){
39085 this.isSlid = false;
39086 this.beforeSlide();
39087 this.el.slideOut(this.getSlideAnchor(), {
39088 callback: function(){
39089 this.el.setLeftTop(-10000, -10000);
39091 this.afterSlideIn();
39099 slideInIf : function(e){
39100 if(!e.within(this.el)){
39105 animateCollapse : function(){
39106 this.beforeSlide();
39107 this.el.setStyle("z-index", 20000);
39108 var anchor = this.getSlideAnchor();
39109 this.el.slideOut(anchor, {
39110 callback : function(){
39111 this.el.setStyle("z-index", "");
39112 this.collapsedEl.slideIn(anchor, {duration:.3});
39114 this.el.setLocation(-10000,-10000);
39116 this.fireEvent("collapsed", this);
39123 animateExpand : function(){
39124 this.beforeSlide();
39125 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
39126 this.el.setStyle("z-index", 20000);
39127 this.collapsedEl.hide({
39130 this.el.slideIn(this.getSlideAnchor(), {
39131 callback : function(){
39132 this.el.setStyle("z-index", "");
39135 this.split.el.show();
39137 this.fireEvent("invalidated", this);
39138 this.fireEvent("expanded", this);
39166 getAnchor : function(){
39167 return this.anchors[this.position];
39170 getCollapseAnchor : function(){
39171 return this.canchors[this.position];
39174 getSlideAnchor : function(){
39175 return this.sanchors[this.position];
39178 getAlignAdj : function(){
39179 var cm = this.cmargins;
39180 switch(this.position){
39196 getExpandAdj : function(){
39197 var c = this.collapsedEl, cm = this.cmargins;
39198 switch(this.position){
39200 return [-(cm.right+c.getWidth()+cm.left), 0];
39203 return [cm.right+c.getWidth()+cm.left, 0];
39206 return [0, -(cm.top+cm.bottom+c.getHeight())];
39209 return [0, cm.top+cm.bottom+c.getHeight()];
39215 * Ext JS Library 1.1.1
39216 * Copyright(c) 2006-2007, Ext JS, LLC.
39218 * Originally Released Under LGPL - original licence link has changed is not relivant.
39221 * <script type="text/javascript">
39224 * These classes are private internal classes
39226 Roo.bootstrap.layout.Center = function(config){
39227 config.region = "center";
39228 Roo.bootstrap.layout.Region.call(this, config);
39229 this.visible = true;
39230 this.minWidth = config.minWidth || 20;
39231 this.minHeight = config.minHeight || 20;
39234 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
39236 // center panel can't be hidden
39240 // center panel can't be hidden
39243 getMinWidth: function(){
39244 return this.minWidth;
39247 getMinHeight: function(){
39248 return this.minHeight;
39262 Roo.bootstrap.layout.North = function(config)
39264 config.region = 'north';
39265 config.cursor = 'n-resize';
39267 Roo.bootstrap.layout.Split.call(this, config);
39271 this.split.placement = Roo.bootstrap.SplitBar.TOP;
39272 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
39273 this.split.el.addClass("roo-layout-split-v");
39275 //var size = config.initialSize || config.height;
39276 //if(this.el && typeof size != "undefined"){
39277 // this.el.setHeight(size);
39280 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
39282 orientation: Roo.bootstrap.SplitBar.VERTICAL,
39285 onRender : function(ctr, pos)
39287 Roo.bootstrap.layout.Split.prototype.onRender.call(this, ctr, pos);
39288 var size = this.config.initialSize || this.config.height;
39289 if(this.el && typeof size != "undefined"){
39290 this.el.setHeight(size);
39295 getBox : function(){
39296 if(this.collapsed){
39297 return this.collapsedEl.getBox();
39299 var box = this.el.getBox();
39301 box.height += this.split.el.getHeight();
39306 updateBox : function(box){
39307 if(this.split && !this.collapsed){
39308 box.height -= this.split.el.getHeight();
39309 this.split.el.setLeft(box.x);
39310 this.split.el.setTop(box.y+box.height);
39311 this.split.el.setWidth(box.width);
39313 if(this.collapsed){
39314 this.updateBody(box.width, null);
39316 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
39324 Roo.bootstrap.layout.South = function(config){
39325 config.region = 'south';
39326 config.cursor = 's-resize';
39327 Roo.bootstrap.layout.Split.call(this, config);
39329 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
39330 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
39331 this.split.el.addClass("roo-layout-split-v");
39336 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
39337 orientation: Roo.bootstrap.SplitBar.VERTICAL,
39339 onRender : function(ctr, pos)
39341 Roo.bootstrap.layout.Split.prototype.onRender.call(this, ctr, pos);
39342 var size = this.config.initialSize || this.config.height;
39343 if(this.el && typeof size != "undefined"){
39344 this.el.setHeight(size);
39349 getBox : function(){
39350 if(this.collapsed){
39351 return this.collapsedEl.getBox();
39353 var box = this.el.getBox();
39355 var sh = this.split.el.getHeight();
39362 updateBox : function(box){
39363 if(this.split && !this.collapsed){
39364 var sh = this.split.el.getHeight();
39367 this.split.el.setLeft(box.x);
39368 this.split.el.setTop(box.y-sh);
39369 this.split.el.setWidth(box.width);
39371 if(this.collapsed){
39372 this.updateBody(box.width, null);
39374 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
39378 Roo.bootstrap.layout.East = function(config){
39379 config.region = "east";
39380 config.cursor = "e-resize";
39381 Roo.bootstrap.layout.Split.call(this, config);
39383 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
39384 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
39385 this.split.el.addClass("roo-layout-split-h");
39389 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
39390 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
39392 onRender : function(ctr, pos)
39394 Roo.bootstrap.layout.Split.prototype.onRender.call(this, ctr, pos);
39395 var size = this.config.initialSize || this.config.width;
39396 if(this.el && typeof size != "undefined"){
39397 this.el.setWidth(size);
39402 getBox : function(){
39403 if(this.collapsed){
39404 return this.collapsedEl.getBox();
39406 var box = this.el.getBox();
39408 var sw = this.split.el.getWidth();
39415 updateBox : function(box){
39416 if(this.split && !this.collapsed){
39417 var sw = this.split.el.getWidth();
39419 this.split.el.setLeft(box.x);
39420 this.split.el.setTop(box.y);
39421 this.split.el.setHeight(box.height);
39424 if(this.collapsed){
39425 this.updateBody(null, box.height);
39427 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
39431 Roo.bootstrap.layout.West = function(config){
39432 config.region = "west";
39433 config.cursor = "w-resize";
39435 Roo.bootstrap.layout.Split.call(this, config);
39437 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
39438 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
39439 this.split.el.addClass("roo-layout-split-h");
39443 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
39444 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
39446 onRender: function(ctr, pos)
39448 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
39449 var size = this.config.initialSize || this.config.width;
39450 if(typeof size != "undefined"){
39451 this.el.setWidth(size);
39455 getBox : function(){
39456 if(this.collapsed){
39457 return this.collapsedEl.getBox();
39459 var box = this.el.getBox();
39460 if (box.width == 0) {
39461 box.width = this.config.width; // kludge?
39464 box.width += this.split.el.getWidth();
39469 updateBox : function(box){
39470 if(this.split && !this.collapsed){
39471 var sw = this.split.el.getWidth();
39473 this.split.el.setLeft(box.x+box.width);
39474 this.split.el.setTop(box.y);
39475 this.split.el.setHeight(box.height);
39477 if(this.collapsed){
39478 this.updateBody(null, box.height);
39480 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
39482 });Roo.namespace("Roo.bootstrap.panel");/*
39484 * Ext JS Library 1.1.1
39485 * Copyright(c) 2006-2007, Ext JS, LLC.
39487 * Originally Released Under LGPL - original licence link has changed is not relivant.
39490 * <script type="text/javascript">
39493 * @class Roo.ContentPanel
39494 * @extends Roo.util.Observable
39495 * A basic ContentPanel element.
39496 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
39497 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
39498 * @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
39499 * @cfg {Boolean} closable True if the panel can be closed/removed
39500 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
39501 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
39502 * @cfg {Toolbar} toolbar A toolbar for this panel
39503 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
39504 * @cfg {String} title The title for this panel
39505 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
39506 * @cfg {String} url Calls {@link #setUrl} with this value
39507 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
39508 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
39509 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
39510 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
39511 * @cfg {Boolean} iframe contents are an iframe - makes showing remote sources/CSS feasible..
39512 * @cfg {Boolean} badges render the badges
39513 * @cfg {String} cls extra classes to use
39514 * @cfg {String} background (primary|secondary|success|info|warning|danger|light|dark)
39517 * Create a new ContentPanel.
39518 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
39519 * @param {String/Object} config A string to set only the title or a config object
39520 * @param {String} content (optional) Set the HTML content for this panel
39521 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
39523 Roo.bootstrap.panel.Content = function( config){
39525 this.tpl = config.tpl || false;
39527 var el = config.el;
39528 var content = config.content;
39530 if(config.autoCreate){ // xtype is available if this is called from factory
39533 this.el = Roo.get(el);
39534 if(!this.el && config && config.autoCreate){
39535 if(typeof config.autoCreate == "object"){
39536 if(!config.autoCreate.id){
39537 config.autoCreate.id = config.id||el;
39539 this.el = Roo.DomHelper.append(document.body,
39540 config.autoCreate, true);
39544 cls: (config.cls || '') +
39545 (config.background ? ' bg-' + config.background : '') +
39546 " roo-layout-inactive-content",
39549 if (config.iframe) {
39553 style : 'border: 0px',
39554 src : 'about:blank'
39560 elcfg.html = config.html;
39564 this.el = Roo.DomHelper.append(document.body, elcfg , true);
39565 if (config.iframe) {
39566 this.iframeEl = this.el.select('iframe',true).first();
39571 this.closable = false;
39572 this.loaded = false;
39573 this.active = false;
39576 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
39578 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
39580 this.wrapEl = this.el; //this.el.wrap();
39582 if (config.toolbar.items) {
39583 ti = config.toolbar.items ;
39584 delete config.toolbar.items ;
39588 this.toolbar.render(this.wrapEl, 'before');
39589 for(var i =0;i < ti.length;i++) {
39590 // Roo.log(['add child', items[i]]);
39591 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
39593 this.toolbar.items = nitems;
39594 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
39595 delete config.toolbar;
39599 // xtype created footer. - not sure if will work as we normally have to render first..
39600 if (this.footer && !this.footer.el && this.footer.xtype) {
39601 if (!this.wrapEl) {
39602 this.wrapEl = this.el.wrap();
39605 this.footer.container = this.wrapEl.createChild();
39607 this.footer = Roo.factory(this.footer, Roo);
39612 if(typeof config == "string"){
39613 this.title = config;
39615 Roo.apply(this, config);
39619 this.resizeEl = Roo.get(this.resizeEl, true);
39621 this.resizeEl = this.el;
39623 // handle view.xtype
39631 * Fires when this panel is activated.
39632 * @param {Roo.ContentPanel} this
39636 * @event deactivate
39637 * Fires when this panel is activated.
39638 * @param {Roo.ContentPanel} this
39640 "deactivate" : true,
39644 * Fires when this panel is resized if fitToFrame is true.
39645 * @param {Roo.ContentPanel} this
39646 * @param {Number} width The width after any component adjustments
39647 * @param {Number} height The height after any component adjustments
39653 * Fires when this tab is created
39654 * @param {Roo.ContentPanel} this
39665 if(this.autoScroll && !this.iframe){
39666 this.resizeEl.setStyle("overflow", "auto");
39668 // fix randome scrolling
39669 //this.el.on('scroll', function() {
39670 // Roo.log('fix random scolling');
39671 // this.scrollTo('top',0);
39674 content = content || this.content;
39676 this.setContent(content);
39678 if(config && config.url){
39679 this.setUrl(this.url, this.params, this.loadOnce);
39684 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
39686 if (this.view && typeof(this.view.xtype) != 'undefined') {
39687 this.view.el = this.el.appendChild(document.createElement("div"));
39688 this.view = Roo.factory(this.view);
39689 this.view.render && this.view.render(false, '');
39693 this.fireEvent('render', this);
39696 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
39706 setRegion : function(region){
39707 this.region = region;
39708 this.setActiveClass(region && !this.background);
39712 setActiveClass: function(state)
39715 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
39716 this.el.setStyle('position','relative');
39718 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
39719 this.el.setStyle('position', 'absolute');
39724 * Returns the toolbar for this Panel if one was configured.
39725 * @return {Roo.Toolbar}
39727 getToolbar : function(){
39728 return this.toolbar;
39731 setActiveState : function(active)
39733 this.active = active;
39734 this.setActiveClass(active);
39736 if(this.fireEvent("deactivate", this) === false){
39741 this.fireEvent("activate", this);
39745 * Updates this panel's element (not for iframe)
39746 * @param {String} content The new content
39747 * @param {Boolean} loadScripts (optional) true to look for and process scripts
39749 setContent : function(content, loadScripts){
39754 this.el.update(content, loadScripts);
39757 ignoreResize : function(w, h){
39758 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
39761 this.lastSize = {width: w, height: h};
39766 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
39767 * @return {Roo.UpdateManager} The UpdateManager
39769 getUpdateManager : function(){
39773 return this.el.getUpdateManager();
39776 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
39777 * Does not work with IFRAME contents
39778 * @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:
39781 url: "your-url.php",
39782 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
39783 callback: yourFunction,
39784 scope: yourObject, //(optional scope)
39787 text: "Loading...",
39793 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
39794 * 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.
39795 * @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}
39796 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
39797 * @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.
39798 * @return {Roo.ContentPanel} this
39806 var um = this.el.getUpdateManager();
39807 um.update.apply(um, arguments);
39813 * 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.
39814 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
39815 * @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)
39816 * @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)
39817 * @return {Roo.UpdateManager|Boolean} The UpdateManager or false if IFRAME
39819 setUrl : function(url, params, loadOnce){
39821 this.iframeEl.dom.src = url;
39825 if(this.refreshDelegate){
39826 this.removeListener("activate", this.refreshDelegate);
39828 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
39829 this.on("activate", this.refreshDelegate);
39830 return this.el.getUpdateManager();
39833 _handleRefresh : function(url, params, loadOnce){
39834 if(!loadOnce || !this.loaded){
39835 var updater = this.el.getUpdateManager();
39836 updater.update(url, params, this._setLoaded.createDelegate(this));
39840 _setLoaded : function(){
39841 this.loaded = true;
39845 * Returns this panel's id
39848 getId : function(){
39853 * Returns this panel's element - used by regiosn to add.
39854 * @return {Roo.Element}
39856 getEl : function(){
39857 return this.wrapEl || this.el;
39862 adjustForComponents : function(width, height)
39864 //Roo.log('adjustForComponents ');
39865 if(this.resizeEl != this.el){
39866 width -= this.el.getFrameWidth('lr');
39867 height -= this.el.getFrameWidth('tb');
39870 var te = this.toolbar.getEl();
39871 te.setWidth(width);
39872 height -= te.getHeight();
39875 var te = this.footer.getEl();
39876 te.setWidth(width);
39877 height -= te.getHeight();
39881 if(this.adjustments){
39882 width += this.adjustments[0];
39883 height += this.adjustments[1];
39885 return {"width": width, "height": height};
39888 setSize : function(width, height){
39889 if(this.fitToFrame && !this.ignoreResize(width, height)){
39890 if(this.fitContainer && this.resizeEl != this.el){
39891 this.el.setSize(width, height);
39893 var size = this.adjustForComponents(width, height);
39895 this.iframeEl.setSize(width,height);
39898 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
39899 this.fireEvent('resize', this, size.width, size.height);
39906 * Returns this panel's title
39909 getTitle : function(){
39911 if (typeof(this.title) != 'object') {
39916 for (var k in this.title) {
39917 if (!this.title.hasOwnProperty(k)) {
39921 if (k.indexOf('-') >= 0) {
39922 var s = k.split('-');
39923 for (var i = 0; i<s.length; i++) {
39924 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
39927 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
39934 * Set this panel's title
39935 * @param {String} title
39937 setTitle : function(title){
39938 this.title = title;
39940 this.region.updatePanelTitle(this, title);
39945 * Returns true is this panel was configured to be closable
39946 * @return {Boolean}
39948 isClosable : function(){
39949 return this.closable;
39952 beforeSlide : function(){
39954 this.resizeEl.clip();
39957 afterSlide : function(){
39959 this.resizeEl.unclip();
39963 * Force a content refresh from the URL specified in the {@link #setUrl} method.
39964 * Will fail silently if the {@link #setUrl} method has not been called.
39965 * This does not activate the panel, just updates its content.
39967 refresh : function(){
39968 if(this.refreshDelegate){
39969 this.loaded = false;
39970 this.refreshDelegate();
39975 * Destroys this panel
39977 destroy : function(){
39978 this.el.removeAllListeners();
39979 var tempEl = document.createElement("span");
39980 tempEl.appendChild(this.el.dom);
39981 tempEl.innerHTML = "";
39987 * form - if the content panel contains a form - this is a reference to it.
39988 * @type {Roo.form.Form}
39992 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
39993 * This contains a reference to it.
39999 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
40009 * @param {Object} cfg Xtype definition of item to add.
40013 getChildContainer: function () {
40014 return this.getEl();
40019 var ret = new Roo.factory(cfg);
40024 if (cfg.xtype.match(/^Form$/)) {
40027 //if (this.footer) {
40028 // el = this.footer.container.insertSibling(false, 'before');
40030 el = this.el.createChild();
40033 this.form = new Roo.form.Form(cfg);
40036 if ( this.form.allItems.length) {
40037 this.form.render(el.dom);
40041 // should only have one of theses..
40042 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
40043 // views.. should not be just added - used named prop 'view''
40045 cfg.el = this.el.appendChild(document.createElement("div"));
40048 var ret = new Roo.factory(cfg);
40050 ret.render && ret.render(false, ''); // render blank..
40060 * @class Roo.bootstrap.panel.Grid
40061 * @extends Roo.bootstrap.panel.Content
40063 * Create a new GridPanel.
40064 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
40065 * @param {Object} config A the config object
40071 Roo.bootstrap.panel.Grid = function(config)
40075 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
40076 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
40078 config.el = this.wrapper;
40079 //this.el = this.wrapper;
40081 if (config.container) {
40082 // ctor'ed from a Border/panel.grid
40085 this.wrapper.setStyle("overflow", "hidden");
40086 this.wrapper.addClass('roo-grid-container');
40091 if(config.toolbar){
40092 var tool_el = this.wrapper.createChild();
40093 this.toolbar = Roo.factory(config.toolbar);
40095 if (config.toolbar.items) {
40096 ti = config.toolbar.items ;
40097 delete config.toolbar.items ;
40101 this.toolbar.render(tool_el);
40102 for(var i =0;i < ti.length;i++) {
40103 // Roo.log(['add child', items[i]]);
40104 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
40106 this.toolbar.items = nitems;
40108 delete config.toolbar;
40111 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
40112 config.grid.scrollBody = true;;
40113 config.grid.monitorWindowResize = false; // turn off autosizing
40114 config.grid.autoHeight = false;
40115 config.grid.autoWidth = false;
40117 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
40119 if (config.background) {
40120 // render grid on panel activation (if panel background)
40121 this.on('activate', function(gp) {
40122 if (!gp.grid.rendered) {
40123 gp.grid.render(this.wrapper);
40124 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
40129 this.grid.render(this.wrapper);
40130 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
40133 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
40134 // ??? needed ??? config.el = this.wrapper;
40139 // xtype created footer. - not sure if will work as we normally have to render first..
40140 if (this.footer && !this.footer.el && this.footer.xtype) {
40142 var ctr = this.grid.getView().getFooterPanel(true);
40143 this.footer.dataSource = this.grid.dataSource;
40144 this.footer = Roo.factory(this.footer, Roo);
40145 this.footer.render(ctr);
40155 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
40156 getId : function(){
40157 return this.grid.id;
40161 * Returns the grid for this panel
40162 * @return {Roo.bootstrap.Table}
40164 getGrid : function(){
40168 setSize : function(width, height){
40169 if(!this.ignoreResize(width, height)){
40170 var grid = this.grid;
40171 var size = this.adjustForComponents(width, height);
40172 // tfoot is not a footer?
40175 var gridel = grid.getGridEl();
40176 gridel.setSize(size.width, size.height);
40178 var tbd = grid.getGridEl().select('tbody', true).first();
40179 var thd = grid.getGridEl().select('thead',true).first();
40180 var tbf= grid.getGridEl().select('tfoot', true).first();
40183 size.height -= tbf.getHeight();
40186 size.height -= thd.getHeight();
40189 tbd.setSize(size.width, size.height );
40190 // this is for the account management tab -seems to work there.
40191 var thd = grid.getGridEl().select('thead',true).first();
40193 // tbd.setSize(size.width, size.height - thd.getHeight());
40202 beforeSlide : function(){
40203 this.grid.getView().scroller.clip();
40206 afterSlide : function(){
40207 this.grid.getView().scroller.unclip();
40210 destroy : function(){
40211 this.grid.destroy();
40213 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
40218 * @class Roo.bootstrap.panel.Nest
40219 * @extends Roo.bootstrap.panel.Content
40221 * Create a new Panel, that can contain a layout.Border.
40224 * @param {Roo.BorderLayout} layout The layout for this panel
40225 * @param {String/Object} config A string to set only the title or a config object
40227 Roo.bootstrap.panel.Nest = function(config)
40229 // construct with only one argument..
40230 /* FIXME - implement nicer consturctors
40231 if (layout.layout) {
40233 layout = config.layout;
40234 delete config.layout;
40236 if (layout.xtype && !layout.getEl) {
40237 // then layout needs constructing..
40238 layout = Roo.factory(layout, Roo);
40242 config.el = config.layout.getEl();
40244 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
40246 config.layout.monitorWindowResize = false; // turn off autosizing
40247 this.layout = config.layout;
40248 this.layout.getEl().addClass("roo-layout-nested-layout");
40249 this.layout.parent = this;
40256 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
40258 setSize : function(width, height){
40259 if(!this.ignoreResize(width, height)){
40260 var size = this.adjustForComponents(width, height);
40261 var el = this.layout.getEl();
40262 if (size.height < 1) {
40263 el.setWidth(size.width);
40265 el.setSize(size.width, size.height);
40267 var touch = el.dom.offsetWidth;
40268 this.layout.layout();
40269 // ie requires a double layout on the first pass
40270 if(Roo.isIE && !this.initialized){
40271 this.initialized = true;
40272 this.layout.layout();
40277 // activate all subpanels if not currently active..
40279 setActiveState : function(active){
40280 this.active = active;
40281 this.setActiveClass(active);
40284 this.fireEvent("deactivate", this);
40288 this.fireEvent("activate", this);
40289 // not sure if this should happen before or after..
40290 if (!this.layout) {
40291 return; // should not happen..
40294 for (var r in this.layout.regions) {
40295 reg = this.layout.getRegion(r);
40296 if (reg.getActivePanel()) {
40297 //reg.showPanel(reg.getActivePanel()); // force it to activate..
40298 reg.setActivePanel(reg.getActivePanel());
40301 if (!reg.panels.length) {
40304 reg.showPanel(reg.getPanel(0));
40313 * Returns the nested BorderLayout for this panel
40314 * @return {Roo.BorderLayout}
40316 getLayout : function(){
40317 return this.layout;
40321 * Adds a xtype elements to the layout of the nested panel
40325 xtype : 'ContentPanel',
40332 xtype : 'NestedLayoutPanel',
40338 items : [ ... list of content panels or nested layout panels.. ]
40342 * @param {Object} cfg Xtype definition of item to add.
40344 addxtype : function(cfg) {
40345 return this.layout.addxtype(cfg);
40350 * Ext JS Library 1.1.1
40351 * Copyright(c) 2006-2007, Ext JS, LLC.
40353 * Originally Released Under LGPL - original licence link has changed is not relivant.
40356 * <script type="text/javascript">
40359 * @class Roo.TabPanel
40360 * @extends Roo.util.Observable
40361 * A lightweight tab container.
40365 // basic tabs 1, built from existing content
40366 var tabs = new Roo.TabPanel("tabs1");
40367 tabs.addTab("script", "View Script");
40368 tabs.addTab("markup", "View Markup");
40369 tabs.activate("script");
40371 // more advanced tabs, built from javascript
40372 var jtabs = new Roo.TabPanel("jtabs");
40373 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
40375 // set up the UpdateManager
40376 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
40377 var updater = tab2.getUpdateManager();
40378 updater.setDefaultUrl("ajax1.htm");
40379 tab2.on('activate', updater.refresh, updater, true);
40381 // Use setUrl for Ajax loading
40382 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
40383 tab3.setUrl("ajax2.htm", null, true);
40386 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
40389 jtabs.activate("jtabs-1");
40392 * Create a new TabPanel.
40393 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
40394 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
40396 Roo.bootstrap.panel.Tabs = function(config){
40398 * The container element for this TabPanel.
40399 * @type Roo.Element
40401 this.el = Roo.get(config.el);
40404 if(typeof config == "boolean"){
40405 this.tabPosition = config ? "bottom" : "top";
40407 Roo.apply(this, config);
40411 if(this.tabPosition == "bottom"){
40412 // if tabs are at the bottom = create the body first.
40413 this.bodyEl = Roo.get(this.createBody(this.el.dom));
40414 this.el.addClass("roo-tabs-bottom");
40416 // next create the tabs holders
40418 if (this.tabPosition == "west"){
40420 var reg = this.region; // fake it..
40422 if (!reg.mgr.parent) {
40425 reg = reg.mgr.parent.region;
40427 Roo.log("got nest?");
40429 if (reg.mgr.getRegion('west')) {
40430 var ctrdom = reg.mgr.getRegion('west').bodyEl.dom;
40431 this.stripWrap = Roo.get(this.createStrip(ctrdom ), true);
40432 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
40433 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
40434 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
40442 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
40443 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
40444 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
40445 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
40450 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
40453 // finally - if tabs are at the top, then create the body last..
40454 if(this.tabPosition != "bottom"){
40455 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
40456 * @type Roo.Element
40458 this.bodyEl = Roo.get(this.createBody(this.el.dom));
40459 this.el.addClass("roo-tabs-top");
40463 this.bodyEl.setStyle("position", "relative");
40465 this.active = null;
40466 this.activateDelegate = this.activate.createDelegate(this);
40471 * Fires when the active tab changes
40472 * @param {Roo.TabPanel} this
40473 * @param {Roo.TabPanelItem} activePanel The new active tab
40477 * @event beforetabchange
40478 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
40479 * @param {Roo.TabPanel} this
40480 * @param {Object} e Set cancel to true on this object to cancel the tab change
40481 * @param {Roo.TabPanelItem} tab The tab being changed to
40483 "beforetabchange" : true
40486 Roo.EventManager.onWindowResize(this.onResize, this);
40487 this.cpad = this.el.getPadding("lr");
40488 this.hiddenCount = 0;
40491 // toolbar on the tabbar support...
40492 if (this.toolbar) {
40493 alert("no toolbar support yet");
40494 this.toolbar = false;
40496 var tcfg = this.toolbar;
40497 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
40498 this.toolbar = new Roo.Toolbar(tcfg);
40499 if (Roo.isSafari) {
40500 var tbl = tcfg.container.child('table', true);
40501 tbl.setAttribute('width', '100%');
40509 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
40512 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
40514 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
40516 tabPosition : "top",
40518 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
40520 currentTabWidth : 0,
40522 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
40526 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
40530 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
40532 preferredTabWidth : 175,
40534 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
40536 resizeTabs : false,
40538 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
40540 monitorResize : true,
40542 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
40544 toolbar : false, // set by caller..
40546 region : false, /// set by caller
40548 disableTooltips : true, // not used yet...
40551 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
40552 * @param {String} id The id of the div to use <b>or create</b>
40553 * @param {String} text The text for the tab
40554 * @param {String} content (optional) Content to put in the TabPanelItem body
40555 * @param {Boolean} closable (optional) True to create a close icon on the tab
40556 * @return {Roo.TabPanelItem} The created TabPanelItem
40558 addTab : function(id, text, content, closable, tpl)
40560 var item = new Roo.bootstrap.panel.TabItem({
40564 closable : closable,
40567 this.addTabItem(item);
40569 item.setContent(content);
40575 * Returns the {@link Roo.TabPanelItem} with the specified id/index
40576 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
40577 * @return {Roo.TabPanelItem}
40579 getTab : function(id){
40580 return this.items[id];
40584 * Hides the {@link Roo.TabPanelItem} with the specified id/index
40585 * @param {String/Number} id The id or index of the TabPanelItem to hide.
40587 hideTab : function(id){
40588 var t = this.items[id];
40591 this.hiddenCount++;
40592 this.autoSizeTabs();
40597 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
40598 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
40600 unhideTab : function(id){
40601 var t = this.items[id];
40603 t.setHidden(false);
40604 this.hiddenCount--;
40605 this.autoSizeTabs();
40610 * Adds an existing {@link Roo.TabPanelItem}.
40611 * @param {Roo.TabPanelItem} item The TabPanelItem to add
40613 addTabItem : function(item)
40615 this.items[item.id] = item;
40616 this.items.push(item);
40617 this.autoSizeTabs();
40618 // if(this.resizeTabs){
40619 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
40620 // this.autoSizeTabs();
40622 // item.autoSize();
40627 * Removes a {@link Roo.TabPanelItem}.
40628 * @param {String/Number} id The id or index of the TabPanelItem to remove.
40630 removeTab : function(id){
40631 var items = this.items;
40632 var tab = items[id];
40633 if(!tab) { return; }
40634 var index = items.indexOf(tab);
40635 if(this.active == tab && items.length > 1){
40636 var newTab = this.getNextAvailable(index);
40641 this.stripEl.dom.removeChild(tab.pnode.dom);
40642 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
40643 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
40645 items.splice(index, 1);
40646 delete this.items[tab.id];
40647 tab.fireEvent("close", tab);
40648 tab.purgeListeners();
40649 this.autoSizeTabs();
40652 getNextAvailable : function(start){
40653 var items = this.items;
40655 // look for a next tab that will slide over to
40656 // replace the one being removed
40657 while(index < items.length){
40658 var item = items[++index];
40659 if(item && !item.isHidden()){
40663 // if one isn't found select the previous tab (on the left)
40666 var item = items[--index];
40667 if(item && !item.isHidden()){
40675 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
40676 * @param {String/Number} id The id or index of the TabPanelItem to disable.
40678 disableTab : function(id){
40679 var tab = this.items[id];
40680 if(tab && this.active != tab){
40686 * Enables a {@link Roo.TabPanelItem} that is disabled.
40687 * @param {String/Number} id The id or index of the TabPanelItem to enable.
40689 enableTab : function(id){
40690 var tab = this.items[id];
40695 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
40696 * @param {String/Number} id The id or index of the TabPanelItem to activate.
40697 * @return {Roo.TabPanelItem} The TabPanelItem.
40699 activate : function(id)
40701 //Roo.log('activite:' + id);
40703 var tab = this.items[id];
40707 if(tab == this.active || tab.disabled){
40711 this.fireEvent("beforetabchange", this, e, tab);
40712 if(e.cancel !== true && !tab.disabled){
40714 this.active.hide();
40716 this.active = this.items[id];
40717 this.active.show();
40718 this.fireEvent("tabchange", this, this.active);
40724 * Gets the active {@link Roo.TabPanelItem}.
40725 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
40727 getActiveTab : function(){
40728 return this.active;
40732 * Updates the tab body element to fit the height of the container element
40733 * for overflow scrolling
40734 * @param {Number} targetHeight (optional) Override the starting height from the elements height
40736 syncHeight : function(targetHeight){
40737 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
40738 var bm = this.bodyEl.getMargins();
40739 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
40740 this.bodyEl.setHeight(newHeight);
40744 onResize : function(){
40745 if(this.monitorResize){
40746 this.autoSizeTabs();
40751 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
40753 beginUpdate : function(){
40754 this.updating = true;
40758 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
40760 endUpdate : function(){
40761 this.updating = false;
40762 this.autoSizeTabs();
40766 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
40768 autoSizeTabs : function()
40770 var count = this.items.length;
40771 var vcount = count - this.hiddenCount;
40774 this.stripEl.hide();
40776 this.stripEl.show();
40779 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
40784 var w = Math.max(this.el.getWidth() - this.cpad, 10);
40785 var availWidth = Math.floor(w / vcount);
40786 var b = this.stripBody;
40787 if(b.getWidth() > w){
40788 var tabs = this.items;
40789 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
40790 if(availWidth < this.minTabWidth){
40791 /*if(!this.sleft){ // incomplete scrolling code
40792 this.createScrollButtons();
40795 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
40798 if(this.currentTabWidth < this.preferredTabWidth){
40799 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
40805 * Returns the number of tabs in this TabPanel.
40808 getCount : function(){
40809 return this.items.length;
40813 * Resizes all the tabs to the passed width
40814 * @param {Number} The new width
40816 setTabWidth : function(width){
40817 this.currentTabWidth = width;
40818 for(var i = 0, len = this.items.length; i < len; i++) {
40819 if(!this.items[i].isHidden()) {
40820 this.items[i].setWidth(width);
40826 * Destroys this TabPanel
40827 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
40829 destroy : function(removeEl){
40830 Roo.EventManager.removeResizeListener(this.onResize, this);
40831 for(var i = 0, len = this.items.length; i < len; i++){
40832 this.items[i].purgeListeners();
40834 if(removeEl === true){
40835 this.el.update("");
40840 createStrip : function(container)
40842 var strip = document.createElement("nav");
40843 strip.className = Roo.bootstrap.version == 4 ?
40844 "navbar-light bg-light" :
40845 "navbar navbar-default"; //"x-tabs-wrap";
40846 container.appendChild(strip);
40850 createStripList : function(strip)
40852 // div wrapper for retard IE
40853 // returns the "tr" element.
40854 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
40855 //'<div class="x-tabs-strip-wrap">'+
40856 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
40857 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
40858 return strip.firstChild; //.firstChild.firstChild.firstChild;
40860 createBody : function(container)
40862 var body = document.createElement("div");
40863 Roo.id(body, "tab-body");
40864 //Roo.fly(body).addClass("x-tabs-body");
40865 Roo.fly(body).addClass("tab-content");
40866 container.appendChild(body);
40869 createItemBody :function(bodyEl, id){
40870 var body = Roo.getDom(id);
40872 body = document.createElement("div");
40875 //Roo.fly(body).addClass("x-tabs-item-body");
40876 Roo.fly(body).addClass("tab-pane");
40877 bodyEl.insertBefore(body, bodyEl.firstChild);
40881 createStripElements : function(stripEl, text, closable, tpl)
40883 var td = document.createElement("li"); // was td..
40884 td.className = 'nav-item';
40886 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
40889 stripEl.appendChild(td);
40891 td.className = "x-tabs-closable";
40892 if(!this.closeTpl){
40893 this.closeTpl = new Roo.Template(
40894 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
40895 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
40896 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
40899 var el = this.closeTpl.overwrite(td, {"text": text});
40900 var close = el.getElementsByTagName("div")[0];
40901 var inner = el.getElementsByTagName("em")[0];
40902 return {"el": el, "close": close, "inner": inner};
40905 // not sure what this is..
40906 // if(!this.tabTpl){
40907 //this.tabTpl = new Roo.Template(
40908 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
40909 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
40911 // this.tabTpl = new Roo.Template(
40912 // '<a href="#">' +
40913 // '<span unselectable="on"' +
40914 // (this.disableTooltips ? '' : ' title="{text}"') +
40915 // ' >{text}</span></a>'
40921 var template = tpl || this.tabTpl || false;
40924 template = new Roo.Template(
40925 Roo.bootstrap.version == 4 ?
40927 '<a class="nav-link" href="#" unselectable="on"' +
40928 (this.disableTooltips ? '' : ' title="{text}"') +
40931 '<a class="nav-link" href="#">' +
40932 '<span unselectable="on"' +
40933 (this.disableTooltips ? '' : ' title="{text}"') +
40934 ' >{text}</span></a>'
40939 switch (typeof(template)) {
40943 template = new Roo.Template(template);
40949 var el = template.overwrite(td, {"text": text});
40951 var inner = el.getElementsByTagName("span")[0];
40953 return {"el": el, "inner": inner};
40961 * @class Roo.TabPanelItem
40962 * @extends Roo.util.Observable
40963 * Represents an individual item (tab plus body) in a TabPanel.
40964 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
40965 * @param {String} id The id of this TabPanelItem
40966 * @param {String} text The text for the tab of this TabPanelItem
40967 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
40969 Roo.bootstrap.panel.TabItem = function(config){
40971 * The {@link Roo.TabPanel} this TabPanelItem belongs to
40972 * @type Roo.TabPanel
40974 this.tabPanel = config.panel;
40976 * The id for this TabPanelItem
40979 this.id = config.id;
40981 this.disabled = false;
40983 this.text = config.text;
40985 this.loaded = false;
40986 this.closable = config.closable;
40989 * The body element for this TabPanelItem.
40990 * @type Roo.Element
40992 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
40993 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
40994 this.bodyEl.setStyle("display", "block");
40995 this.bodyEl.setStyle("zoom", "1");
40996 //this.hideAction();
40998 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
41000 this.el = Roo.get(els.el);
41001 this.inner = Roo.get(els.inner, true);
41002 this.textEl = Roo.bootstrap.version == 4 ?
41003 this.el : Roo.get(this.el.dom.firstChild, true);
41005 this.pnode = this.linode = Roo.get(els.el.parentNode, true);
41006 this.status_node = Roo.bootstrap.version == 4 ? this.el : this.linode;
41009 // this.el.on("mousedown", this.onTabMouseDown, this);
41010 this.el.on("click", this.onTabClick, this);
41012 if(config.closable){
41013 var c = Roo.get(els.close, true);
41014 c.dom.title = this.closeText;
41015 c.addClassOnOver("close-over");
41016 c.on("click", this.closeClick, this);
41022 * Fires when this tab becomes the active tab.
41023 * @param {Roo.TabPanel} tabPanel The parent TabPanel
41024 * @param {Roo.TabPanelItem} this
41028 * @event beforeclose
41029 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
41030 * @param {Roo.TabPanelItem} this
41031 * @param {Object} e Set cancel to true on this object to cancel the close.
41033 "beforeclose": true,
41036 * Fires when this tab is closed.
41037 * @param {Roo.TabPanelItem} this
41041 * @event deactivate
41042 * Fires when this tab is no longer the active tab.
41043 * @param {Roo.TabPanel} tabPanel The parent TabPanel
41044 * @param {Roo.TabPanelItem} this
41046 "deactivate" : true
41048 this.hidden = false;
41050 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
41053 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
41055 purgeListeners : function(){
41056 Roo.util.Observable.prototype.purgeListeners.call(this);
41057 this.el.removeAllListeners();
41060 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
41063 this.status_node.addClass("active");
41066 this.tabPanel.stripWrap.repaint();
41068 this.fireEvent("activate", this.tabPanel, this);
41072 * Returns true if this tab is the active tab.
41073 * @return {Boolean}
41075 isActive : function(){
41076 return this.tabPanel.getActiveTab() == this;
41080 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
41083 this.status_node.removeClass("active");
41085 this.fireEvent("deactivate", this.tabPanel, this);
41088 hideAction : function(){
41089 this.bodyEl.hide();
41090 this.bodyEl.setStyle("position", "absolute");
41091 this.bodyEl.setLeft("-20000px");
41092 this.bodyEl.setTop("-20000px");
41095 showAction : function(){
41096 this.bodyEl.setStyle("position", "relative");
41097 this.bodyEl.setTop("");
41098 this.bodyEl.setLeft("");
41099 this.bodyEl.show();
41103 * Set the tooltip for the tab.
41104 * @param {String} tooltip The tab's tooltip
41106 setTooltip : function(text){
41107 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
41108 this.textEl.dom.qtip = text;
41109 this.textEl.dom.removeAttribute('title');
41111 this.textEl.dom.title = text;
41115 onTabClick : function(e){
41116 e.preventDefault();
41117 this.tabPanel.activate(this.id);
41120 onTabMouseDown : function(e){
41121 e.preventDefault();
41122 this.tabPanel.activate(this.id);
41125 getWidth : function(){
41126 return this.inner.getWidth();
41129 setWidth : function(width){
41130 var iwidth = width - this.linode.getPadding("lr");
41131 this.inner.setWidth(iwidth);
41132 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
41133 this.linode.setWidth(width);
41137 * Show or hide the tab
41138 * @param {Boolean} hidden True to hide or false to show.
41140 setHidden : function(hidden){
41141 this.hidden = hidden;
41142 this.linode.setStyle("display", hidden ? "none" : "");
41146 * Returns true if this tab is "hidden"
41147 * @return {Boolean}
41149 isHidden : function(){
41150 return this.hidden;
41154 * Returns the text for this tab
41157 getText : function(){
41161 autoSize : function(){
41162 //this.el.beginMeasure();
41163 this.textEl.setWidth(1);
41165 * #2804 [new] Tabs in Roojs
41166 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
41168 //this.setWidth(this.textEl.dom.scrollWidth+this.linode.getPadding("lr")+this.inner.getPadding("lr") + 2);
41169 //this.el.endMeasure();
41173 * Sets the text for the tab (Note: this also sets the tooltip text)
41174 * @param {String} text The tab's text and tooltip
41176 setText : function(text){
41178 this.textEl.update(text);
41179 this.setTooltip(text);
41180 //if(!this.tabPanel.resizeTabs){
41181 // this.autoSize();
41185 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
41187 activate : function(){
41188 this.tabPanel.activate(this.id);
41192 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
41194 disable : function(){
41195 if(this.tabPanel.active != this){
41196 this.disabled = true;
41197 this.status_node.addClass("disabled");
41202 * Enables this TabPanelItem if it was previously disabled.
41204 enable : function(){
41205 this.disabled = false;
41206 this.status_node.removeClass("disabled");
41210 * Sets the content for this TabPanelItem.
41211 * @param {String} content The content
41212 * @param {Boolean} loadScripts true to look for and load scripts
41214 setContent : function(content, loadScripts){
41215 this.bodyEl.update(content, loadScripts);
41219 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
41220 * @return {Roo.UpdateManager} The UpdateManager
41222 getUpdateManager : function(){
41223 return this.bodyEl.getUpdateManager();
41227 * Set a URL to be used to load the content for this TabPanelItem.
41228 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
41229 * @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)
41230 * @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)
41231 * @return {Roo.UpdateManager} The UpdateManager
41233 setUrl : function(url, params, loadOnce){
41234 if(this.refreshDelegate){
41235 this.un('activate', this.refreshDelegate);
41237 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
41238 this.on("activate", this.refreshDelegate);
41239 return this.bodyEl.getUpdateManager();
41243 _handleRefresh : function(url, params, loadOnce){
41244 if(!loadOnce || !this.loaded){
41245 var updater = this.bodyEl.getUpdateManager();
41246 updater.update(url, params, this._setLoaded.createDelegate(this));
41251 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
41252 * Will fail silently if the setUrl method has not been called.
41253 * This does not activate the panel, just updates its content.
41255 refresh : function(){
41256 if(this.refreshDelegate){
41257 this.loaded = false;
41258 this.refreshDelegate();
41263 _setLoaded : function(){
41264 this.loaded = true;
41268 closeClick : function(e){
41271 this.fireEvent("beforeclose", this, o);
41272 if(o.cancel !== true){
41273 this.tabPanel.removeTab(this.id);
41277 * The text displayed in the tooltip for the close icon.
41280 closeText : "Close this tab"
41283 * This script refer to:
41284 * Title: International Telephone Input
41285 * Author: Jack O'Connor
41286 * Code version: v12.1.12
41287 * Availability: https://github.com/jackocnr/intl-tel-input.git
41290 Roo.bootstrap.PhoneInputData = function() {
41293 "Afghanistan (افغانستان)",
41298 "Albania (Shqipëri)",
41303 "Algeria (الجزائر)",
41328 "Antigua and Barbuda",
41338 "Armenia (Հայաստան)",
41354 "Austria (Österreich)",
41359 "Azerbaijan (Azərbaycan)",
41369 "Bahrain (البحرين)",
41374 "Bangladesh (বাংলাদেশ)",
41384 "Belarus (Беларусь)",
41389 "Belgium (België)",
41419 "Bosnia and Herzegovina (Босна и Херцеговина)",
41434 "British Indian Ocean Territory",
41439 "British Virgin Islands",
41449 "Bulgaria (България)",
41459 "Burundi (Uburundi)",
41464 "Cambodia (កម្ពុជា)",
41469 "Cameroon (Cameroun)",
41478 ["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"]
41481 "Cape Verde (Kabu Verdi)",
41486 "Caribbean Netherlands",
41497 "Central African Republic (République centrafricaine)",
41517 "Christmas Island",
41523 "Cocos (Keeling) Islands",
41534 "Comoros (جزر القمر)",
41539 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
41544 "Congo (Republic) (Congo-Brazzaville)",
41564 "Croatia (Hrvatska)",
41585 "Czech Republic (Česká republika)",
41590 "Denmark (Danmark)",
41605 "Dominican Republic (República Dominicana)",
41609 ["809", "829", "849"]
41627 "Equatorial Guinea (Guinea Ecuatorial)",
41647 "Falkland Islands (Islas Malvinas)",
41652 "Faroe Islands (Føroyar)",
41673 "French Guiana (Guyane française)",
41678 "French Polynesia (Polynésie française)",
41693 "Georgia (საქართველო)",
41698 "Germany (Deutschland)",
41718 "Greenland (Kalaallit Nunaat)",
41755 "Guinea-Bissau (Guiné Bissau)",
41780 "Hungary (Magyarország)",
41785 "Iceland (Ísland)",
41805 "Iraq (العراق)",
41821 "Israel (ישראל)",
41848 "Jordan (الأردن)",
41853 "Kazakhstan (Казахстан)",
41874 "Kuwait (الكويت)",
41879 "Kyrgyzstan (Кыргызстан)",
41889 "Latvia (Latvija)",
41894 "Lebanon (لبنان)",
41909 "Libya (ليبيا)",
41919 "Lithuania (Lietuva)",
41934 "Macedonia (FYROM) (Македонија)",
41939 "Madagascar (Madagasikara)",
41969 "Marshall Islands",
41979 "Mauritania (موريتانيا)",
41984 "Mauritius (Moris)",
42005 "Moldova (Republica Moldova)",
42015 "Mongolia (Монгол)",
42020 "Montenegro (Crna Gora)",
42030 "Morocco (المغرب)",
42036 "Mozambique (Moçambique)",
42041 "Myanmar (Burma) (မြန်မာ)",
42046 "Namibia (Namibië)",
42061 "Netherlands (Nederland)",
42066 "New Caledonia (Nouvelle-Calédonie)",
42101 "North Korea (조선 민주주의 인민 공화국)",
42106 "Northern Mariana Islands",
42122 "Pakistan (پاکستان)",
42132 "Palestine (فلسطين)",
42142 "Papua New Guinea",
42184 "Réunion (La Réunion)",
42190 "Romania (România)",
42206 "Saint Barthélemy",
42217 "Saint Kitts and Nevis",
42227 "Saint Martin (Saint-Martin (partie française))",
42233 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
42238 "Saint Vincent and the Grenadines",
42253 "São Tomé and Príncipe (São Tomé e Príncipe)",
42258 "Saudi Arabia (المملكة العربية السعودية)",
42263 "Senegal (Sénégal)",
42293 "Slovakia (Slovensko)",
42298 "Slovenia (Slovenija)",
42308 "Somalia (Soomaaliya)",
42318 "South Korea (대한민국)",
42323 "South Sudan (جنوب السودان)",
42333 "Sri Lanka (ශ්රී ලංකාව)",
42338 "Sudan (السودان)",
42348 "Svalbard and Jan Mayen",
42359 "Sweden (Sverige)",
42364 "Switzerland (Schweiz)",
42369 "Syria (سوريا)",
42414 "Trinidad and Tobago",
42419 "Tunisia (تونس)",
42424 "Turkey (Türkiye)",
42434 "Turks and Caicos Islands",
42444 "U.S. Virgin Islands",
42454 "Ukraine (Україна)",
42459 "United Arab Emirates (الإمارات العربية المتحدة)",
42481 "Uzbekistan (Oʻzbekiston)",
42491 "Vatican City (Città del Vaticano)",
42502 "Vietnam (Việt Nam)",
42507 "Wallis and Futuna (Wallis-et-Futuna)",
42512 "Western Sahara (الصحراء الغربية)",
42518 "Yemen (اليمن)",
42542 * This script refer to:
42543 * Title: International Telephone Input
42544 * Author: Jack O'Connor
42545 * Code version: v12.1.12
42546 * Availability: https://github.com/jackocnr/intl-tel-input.git
42550 * @class Roo.bootstrap.PhoneInput
42551 * @extends Roo.bootstrap.TriggerField
42552 * An input with International dial-code selection
42554 * @cfg {String} defaultDialCode default '+852'
42555 * @cfg {Array} preferedCountries default []
42558 * Create a new PhoneInput.
42559 * @param {Object} config Configuration options
42562 Roo.bootstrap.PhoneInput = function(config) {
42563 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
42566 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
42568 listWidth: undefined,
42570 selectedClass: 'active',
42572 invalidClass : "has-warning",
42574 validClass: 'has-success',
42576 allowed: '0123456789',
42581 * @cfg {String} defaultDialCode The default dial code when initializing the input
42583 defaultDialCode: '+852',
42586 * @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
42588 preferedCountries: false,
42590 getAutoCreate : function()
42592 var data = Roo.bootstrap.PhoneInputData();
42593 var align = this.labelAlign || this.parentLabelAlign();
42596 this.allCountries = [];
42597 this.dialCodeMapping = [];
42599 for (var i = 0; i < data.length; i++) {
42601 this.allCountries[i] = {
42605 priority: c[3] || 0,
42606 areaCodes: c[4] || null
42608 this.dialCodeMapping[c[2]] = {
42611 priority: c[3] || 0,
42612 areaCodes: c[4] || null
42624 // type: 'number', -- do not use number - we get the flaky up/down arrows.
42625 maxlength: this.max_length,
42626 cls : 'form-control tel-input',
42627 autocomplete: 'new-password'
42630 var hiddenInput = {
42633 cls: 'hidden-tel-input'
42637 hiddenInput.name = this.name;
42640 if (this.disabled) {
42641 input.disabled = true;
42644 var flag_container = {
42661 cls: this.hasFeedback ? 'has-feedback' : '',
42667 cls: 'dial-code-holder',
42674 cls: 'roo-select2-container input-group',
42681 if (this.fieldLabel.length) {
42684 tooltip: 'This field is required'
42690 cls: 'control-label',
42696 html: this.fieldLabel
42699 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
42705 if(this.indicatorpos == 'right') {
42706 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
42713 if(align == 'left') {
42721 if(this.labelWidth > 12){
42722 label.style = "width: " + this.labelWidth + 'px';
42724 if(this.labelWidth < 13 && this.labelmd == 0){
42725 this.labelmd = this.labelWidth;
42727 if(this.labellg > 0){
42728 label.cls += ' col-lg-' + this.labellg;
42729 input.cls += ' col-lg-' + (12 - this.labellg);
42731 if(this.labelmd > 0){
42732 label.cls += ' col-md-' + this.labelmd;
42733 container.cls += ' col-md-' + (12 - this.labelmd);
42735 if(this.labelsm > 0){
42736 label.cls += ' col-sm-' + this.labelsm;
42737 container.cls += ' col-sm-' + (12 - this.labelsm);
42739 if(this.labelxs > 0){
42740 label.cls += ' col-xs-' + this.labelxs;
42741 container.cls += ' col-xs-' + (12 - this.labelxs);
42751 var settings = this;
42753 ['xs','sm','md','lg'].map(function(size){
42754 if (settings[size]) {
42755 cfg.cls += ' col-' + size + '-' + settings[size];
42759 this.store = new Roo.data.Store({
42760 proxy : new Roo.data.MemoryProxy({}),
42761 reader : new Roo.data.JsonReader({
42772 'name' : 'dialCode',
42776 'name' : 'priority',
42780 'name' : 'areaCodes',
42787 if(!this.preferedCountries) {
42788 this.preferedCountries = [
42795 var p = this.preferedCountries.reverse();
42798 for (var i = 0; i < p.length; i++) {
42799 for (var j = 0; j < this.allCountries.length; j++) {
42800 if(this.allCountries[j].iso2 == p[i]) {
42801 var t = this.allCountries[j];
42802 this.allCountries.splice(j,1);
42803 this.allCountries.unshift(t);
42809 this.store.proxy.data = {
42811 data: this.allCountries
42817 initEvents : function()
42820 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
42822 this.indicator = this.indicatorEl();
42823 this.flag = this.flagEl();
42824 this.dialCodeHolder = this.dialCodeHolderEl();
42826 this.trigger = this.el.select('div.flag-box',true).first();
42827 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
42832 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
42833 _this.list.setWidth(lw);
42836 this.list.on('mouseover', this.onViewOver, this);
42837 this.list.on('mousemove', this.onViewMove, this);
42838 this.inputEl().on("keyup", this.onKeyUp, this);
42839 this.inputEl().on("keypress", this.onKeyPress, this);
42841 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
42843 this.view = new Roo.View(this.list, this.tpl, {
42844 singleSelect:true, store: this.store, selectedClass: this.selectedClass
42847 this.view.on('click', this.onViewClick, this);
42848 this.setValue(this.defaultDialCode);
42851 onTriggerClick : function(e)
42853 Roo.log('trigger click');
42858 if(this.isExpanded()){
42860 this.hasFocus = false;
42862 this.store.load({});
42863 this.hasFocus = true;
42868 isExpanded : function()
42870 return this.list.isVisible();
42873 collapse : function()
42875 if(!this.isExpanded()){
42879 Roo.get(document).un('mousedown', this.collapseIf, this);
42880 Roo.get(document).un('mousewheel', this.collapseIf, this);
42881 this.fireEvent('collapse', this);
42885 expand : function()
42889 if(this.isExpanded() || !this.hasFocus){
42893 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
42894 this.list.setWidth(lw);
42897 this.restrictHeight();
42899 Roo.get(document).on('mousedown', this.collapseIf, this);
42900 Roo.get(document).on('mousewheel', this.collapseIf, this);
42902 this.fireEvent('expand', this);
42905 restrictHeight : function()
42907 this.list.alignTo(this.inputEl(), this.listAlign);
42908 this.list.alignTo(this.inputEl(), this.listAlign);
42911 onViewOver : function(e, t)
42913 if(this.inKeyMode){
42916 var item = this.view.findItemFromChild(t);
42919 var index = this.view.indexOf(item);
42920 this.select(index, false);
42925 onViewClick : function(view, doFocus, el, e)
42927 var index = this.view.getSelectedIndexes()[0];
42929 var r = this.store.getAt(index);
42932 this.onSelect(r, index);
42934 if(doFocus !== false && !this.blockFocus){
42935 this.inputEl().focus();
42939 onViewMove : function(e, t)
42941 this.inKeyMode = false;
42944 select : function(index, scrollIntoView)
42946 this.selectedIndex = index;
42947 this.view.select(index);
42948 if(scrollIntoView !== false){
42949 var el = this.view.getNode(index);
42951 this.list.scrollChildIntoView(el, false);
42956 createList : function()
42958 this.list = Roo.get(document.body).createChild({
42960 cls: 'typeahead typeahead-long dropdown-menu tel-list',
42961 style: 'display:none'
42964 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
42967 collapseIf : function(e)
42969 var in_combo = e.within(this.el);
42970 var in_list = e.within(this.list);
42971 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
42973 if (in_combo || in_list || is_list) {
42979 onSelect : function(record, index)
42981 if(this.fireEvent('beforeselect', this, record, index) !== false){
42983 this.setFlagClass(record.data.iso2);
42984 this.setDialCode(record.data.dialCode);
42985 this.hasFocus = false;
42987 this.fireEvent('select', this, record, index);
42991 flagEl : function()
42993 var flag = this.el.select('div.flag',true).first();
43000 dialCodeHolderEl : function()
43002 var d = this.el.select('input.dial-code-holder',true).first();
43009 setDialCode : function(v)
43011 this.dialCodeHolder.dom.value = '+'+v;
43014 setFlagClass : function(n)
43016 this.flag.dom.className = 'flag '+n;
43019 getValue : function()
43021 var v = this.inputEl().getValue();
43022 if(this.dialCodeHolder) {
43023 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
43028 setValue : function(v)
43030 var d = this.getDialCode(v);
43032 //invalid dial code
43033 if(v.length == 0 || !d || d.length == 0) {
43035 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
43036 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
43042 this.setFlagClass(this.dialCodeMapping[d].iso2);
43043 this.setDialCode(d);
43044 this.inputEl().dom.value = v.replace('+'+d,'');
43045 this.hiddenEl().dom.value = this.getValue();
43050 getDialCode : function(v)
43054 if (v.length == 0) {
43055 return this.dialCodeHolder.dom.value;
43059 if (v.charAt(0) != "+") {
43062 var numericChars = "";
43063 for (var i = 1; i < v.length; i++) {
43064 var c = v.charAt(i);
43067 if (this.dialCodeMapping[numericChars]) {
43068 dialCode = v.substr(1, i);
43070 if (numericChars.length == 4) {
43080 this.setValue(this.defaultDialCode);
43084 hiddenEl : function()
43086 return this.el.select('input.hidden-tel-input',true).first();
43089 // after setting val
43090 onKeyUp : function(e){
43091 this.setValue(this.getValue());
43094 onKeyPress : function(e){
43095 if(this.allowed.indexOf(String.fromCharCode(e.getCharCode())) === -1){
43102 * @class Roo.bootstrap.MoneyField
43103 * @extends Roo.bootstrap.ComboBox
43104 * Bootstrap MoneyField class
43107 * Create a new MoneyField.
43108 * @param {Object} config Configuration options
43111 Roo.bootstrap.MoneyField = function(config) {
43113 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
43117 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
43120 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
43122 allowDecimals : true,
43124 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
43126 decimalSeparator : ".",
43128 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
43130 decimalPrecision : 0,
43132 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
43134 allowNegative : true,
43136 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
43140 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
43142 minValue : Number.NEGATIVE_INFINITY,
43144 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
43146 maxValue : Number.MAX_VALUE,
43148 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
43150 minText : "The minimum value for this field is {0}",
43152 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
43154 maxText : "The maximum value for this field is {0}",
43156 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
43157 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
43159 nanText : "{0} is not a valid number",
43161 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
43165 * @cfg {String} defaults currency of the MoneyField
43166 * value should be in lkey
43168 defaultCurrency : false,
43170 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
43172 thousandsDelimiter : false,
43174 * @cfg {Number} max_length Maximum input field length allowed (defaults to Number.MAX_VALUE)
43185 getAutoCreate : function()
43187 var align = this.labelAlign || this.parentLabelAlign();
43199 cls : 'form-control roo-money-amount-input',
43200 autocomplete: 'new-password'
43203 var hiddenInput = {
43207 cls: 'hidden-number-input'
43210 if(this.max_length) {
43211 input.maxlength = this.max_length;
43215 hiddenInput.name = this.name;
43218 if (this.disabled) {
43219 input.disabled = true;
43222 var clg = 12 - this.inputlg;
43223 var cmd = 12 - this.inputmd;
43224 var csm = 12 - this.inputsm;
43225 var cxs = 12 - this.inputxs;
43229 cls : 'row roo-money-field',
43233 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
43237 cls: 'roo-select2-container input-group',
43241 cls : 'form-control roo-money-currency-input',
43242 autocomplete: 'new-password',
43244 name : this.currencyName
43248 cls : 'input-group-addon',
43262 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
43266 cls: this.hasFeedback ? 'has-feedback' : '',
43277 if (this.fieldLabel.length) {
43280 tooltip: 'This field is required'
43286 cls: 'control-label',
43292 html: this.fieldLabel
43295 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
43301 if(this.indicatorpos == 'right') {
43302 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
43309 if(align == 'left') {
43317 if(this.labelWidth > 12){
43318 label.style = "width: " + this.labelWidth + 'px';
43320 if(this.labelWidth < 13 && this.labelmd == 0){
43321 this.labelmd = this.labelWidth;
43323 if(this.labellg > 0){
43324 label.cls += ' col-lg-' + this.labellg;
43325 input.cls += ' col-lg-' + (12 - this.labellg);
43327 if(this.labelmd > 0){
43328 label.cls += ' col-md-' + this.labelmd;
43329 container.cls += ' col-md-' + (12 - this.labelmd);
43331 if(this.labelsm > 0){
43332 label.cls += ' col-sm-' + this.labelsm;
43333 container.cls += ' col-sm-' + (12 - this.labelsm);
43335 if(this.labelxs > 0){
43336 label.cls += ' col-xs-' + this.labelxs;
43337 container.cls += ' col-xs-' + (12 - this.labelxs);
43348 var settings = this;
43350 ['xs','sm','md','lg'].map(function(size){
43351 if (settings[size]) {
43352 cfg.cls += ' col-' + size + '-' + settings[size];
43359 initEvents : function()
43361 this.indicator = this.indicatorEl();
43363 this.initCurrencyEvent();
43365 this.initNumberEvent();
43368 initCurrencyEvent : function()
43371 throw "can not find store for combo";
43374 this.store = Roo.factory(this.store, Roo.data);
43375 this.store.parent = this;
43379 this.triggerEl = this.el.select('.input-group-addon', true).first();
43381 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
43386 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
43387 _this.list.setWidth(lw);
43390 this.list.on('mouseover', this.onViewOver, this);
43391 this.list.on('mousemove', this.onViewMove, this);
43392 this.list.on('scroll', this.onViewScroll, this);
43395 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
43398 this.view = new Roo.View(this.list, this.tpl, {
43399 singleSelect:true, store: this.store, selectedClass: this.selectedClass
43402 this.view.on('click', this.onViewClick, this);
43404 this.store.on('beforeload', this.onBeforeLoad, this);
43405 this.store.on('load', this.onLoad, this);
43406 this.store.on('loadexception', this.onLoadException, this);
43408 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
43409 "up" : function(e){
43410 this.inKeyMode = true;
43414 "down" : function(e){
43415 if(!this.isExpanded()){
43416 this.onTriggerClick();
43418 this.inKeyMode = true;
43423 "enter" : function(e){
43426 if(this.fireEvent("specialkey", this, e)){
43427 this.onViewClick(false);
43433 "esc" : function(e){
43437 "tab" : function(e){
43440 if(this.fireEvent("specialkey", this, e)){
43441 this.onViewClick(false);
43449 doRelay : function(foo, bar, hname){
43450 if(hname == 'down' || this.scope.isExpanded()){
43451 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
43459 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
43463 initNumberEvent : function(e)
43465 this.inputEl().on("keydown" , this.fireKey, this);
43466 this.inputEl().on("focus", this.onFocus, this);
43467 this.inputEl().on("blur", this.onBlur, this);
43469 this.inputEl().relayEvent('keyup', this);
43471 if(this.indicator){
43472 this.indicator.addClass('invisible');
43475 this.originalValue = this.getValue();
43477 if(this.validationEvent == 'keyup'){
43478 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
43479 this.inputEl().on('keyup', this.filterValidation, this);
43481 else if(this.validationEvent !== false){
43482 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
43485 if(this.selectOnFocus){
43486 this.on("focus", this.preFocus, this);
43489 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
43490 this.inputEl().on("keypress", this.filterKeys, this);
43492 this.inputEl().relayEvent('keypress', this);
43495 var allowed = "0123456789";
43497 if(this.allowDecimals){
43498 allowed += this.decimalSeparator;
43501 if(this.allowNegative){
43505 if(this.thousandsDelimiter) {
43509 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
43511 var keyPress = function(e){
43513 var k = e.getKey();
43515 var c = e.getCharCode();
43518 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
43519 allowed.indexOf(String.fromCharCode(c)) === -1
43525 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
43529 if(allowed.indexOf(String.fromCharCode(c)) === -1){
43534 this.inputEl().on("keypress", keyPress, this);
43538 onTriggerClick : function(e)
43545 this.loadNext = false;
43547 if(this.isExpanded()){
43552 this.hasFocus = true;
43554 if(this.triggerAction == 'all') {
43555 this.doQuery(this.allQuery, true);
43559 this.doQuery(this.getRawValue());
43562 getCurrency : function()
43564 var v = this.currencyEl().getValue();
43569 restrictHeight : function()
43571 this.list.alignTo(this.currencyEl(), this.listAlign);
43572 this.list.alignTo(this.currencyEl(), this.listAlign);
43575 onViewClick : function(view, doFocus, el, e)
43577 var index = this.view.getSelectedIndexes()[0];
43579 var r = this.store.getAt(index);
43582 this.onSelect(r, index);
43586 onSelect : function(record, index){
43588 if(this.fireEvent('beforeselect', this, record, index) !== false){
43590 this.setFromCurrencyData(index > -1 ? record.data : false);
43594 this.fireEvent('select', this, record, index);
43598 setFromCurrencyData : function(o)
43602 this.lastCurrency = o;
43604 if (this.currencyField) {
43605 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
43607 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
43610 this.lastSelectionText = currency;
43612 //setting default currency
43613 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
43614 this.setCurrency(this.defaultCurrency);
43618 this.setCurrency(currency);
43621 setFromData : function(o)
43625 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
43627 this.setFromCurrencyData(c);
43632 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
43634 Roo.log('no value set for '+ (this.name ? this.name : this.id));
43637 this.setValue(value);
43641 setCurrency : function(v)
43643 this.currencyValue = v;
43646 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
43651 setValue : function(v)
43653 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
43659 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
43661 this.inputEl().dom.value = (v == '') ? '' :
43662 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
43664 if(!this.allowZero && v === '0') {
43665 this.hiddenEl().dom.value = '';
43666 this.inputEl().dom.value = '';
43673 getRawValue : function()
43675 var v = this.inputEl().getValue();
43680 getValue : function()
43682 return this.fixPrecision(this.parseValue(this.getRawValue()));
43685 parseValue : function(value)
43687 if(this.thousandsDelimiter) {
43689 r = new RegExp(",", "g");
43690 value = value.replace(r, "");
43693 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
43694 return isNaN(value) ? '' : value;
43698 fixPrecision : function(value)
43700 if(this.thousandsDelimiter) {
43702 r = new RegExp(",", "g");
43703 value = value.replace(r, "");
43706 var nan = isNaN(value);
43708 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
43709 return nan ? '' : value;
43711 return parseFloat(value).toFixed(this.decimalPrecision);
43714 decimalPrecisionFcn : function(v)
43716 return Math.floor(v);
43719 validateValue : function(value)
43721 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
43725 var num = this.parseValue(value);
43728 this.markInvalid(String.format(this.nanText, value));
43732 if(num < this.minValue){
43733 this.markInvalid(String.format(this.minText, this.minValue));
43737 if(num > this.maxValue){
43738 this.markInvalid(String.format(this.maxText, this.maxValue));
43745 validate : function()
43747 if(this.disabled || this.allowBlank){
43752 var currency = this.getCurrency();
43754 if(this.validateValue(this.getRawValue()) && currency.length){
43759 this.markInvalid();
43763 getName: function()
43768 beforeBlur : function()
43774 var v = this.parseValue(this.getRawValue());
43781 onBlur : function()
43785 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
43786 //this.el.removeClass(this.focusClass);
43789 this.hasFocus = false;
43791 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
43795 var v = this.getValue();
43797 if(String(v) !== String(this.startValue)){
43798 this.fireEvent('change', this, v, this.startValue);
43801 this.fireEvent("blur", this);
43804 inputEl : function()
43806 return this.el.select('.roo-money-amount-input', true).first();
43809 currencyEl : function()
43811 return this.el.select('.roo-money-currency-input', true).first();
43814 hiddenEl : function()
43816 return this.el.select('input.hidden-number-input',true).first();
43820 * @class Roo.bootstrap.BezierSignature
43821 * @extends Roo.bootstrap.Component
43822 * Bootstrap BezierSignature class
43823 * This script refer to:
43824 * Title: Signature Pad
43826 * Availability: https://github.com/szimek/signature_pad
43829 * Create a new BezierSignature
43830 * @param {Object} config The config object
43833 Roo.bootstrap.BezierSignature = function(config){
43834 Roo.bootstrap.BezierSignature.superclass.constructor.call(this, config);
43840 Roo.extend(Roo.bootstrap.BezierSignature, Roo.bootstrap.Component,
43847 mouse_btn_down: true,
43850 * @cfg {int} canvas height
43852 canvas_height: '200px',
43855 * @cfg {float|function} Radius of a single dot.
43860 * @cfg {float} Minimum width of a line. Defaults to 0.5.
43865 * @cfg {float} Maximum width of a line. Defaults to 2.5.
43870 * @cfg {integer} Draw the next point at most once per every x milliseconds. Set it to 0 to turn off throttling. Defaults to 16.
43875 * @cfg {integer} Add the next point only if the previous one is farther than x pixels. Defaults to 5.
43880 * @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.
43882 bg_color: 'rgba(0, 0, 0, 0)',
43885 * @cfg {string} Color used to draw the lines. Can be any color format accepted by context.fillStyle. Defaults to "black".
43887 dot_color: 'black',
43890 * @cfg {float} Weight used to modify new velocity based on the previous velocity. Defaults to 0.7.
43892 velocity_filter_weight: 0.7,
43895 * @cfg {function} Callback when stroke begin.
43900 * @cfg {function} Callback when stroke end.
43904 getAutoCreate : function()
43906 var cls = 'roo-signature column';
43909 cls += ' ' + this.cls;
43919 for(var i = 0; i < col_sizes.length; i++) {
43920 if(this[col_sizes[i]]) {
43921 cls += " col-"+col_sizes[i]+"-"+this[col_sizes[i]];
43931 cls: 'roo-signature-body',
43935 cls: 'roo-signature-body-canvas',
43936 height: this.canvas_height,
43937 width: this.canvas_width
43944 style: 'display: none'
43952 initEvents: function()
43954 Roo.bootstrap.BezierSignature.superclass.initEvents.call(this);
43956 var canvas = this.canvasEl();
43958 // mouse && touch event swapping...
43959 canvas.dom.style.touchAction = 'none';
43960 canvas.dom.style.msTouchAction = 'none';
43962 this.mouse_btn_down = false;
43963 canvas.on('mousedown', this._handleMouseDown, this);
43964 canvas.on('mousemove', this._handleMouseMove, this);
43965 Roo.select('html').first().on('mouseup', this._handleMouseUp, this);
43967 if (window.PointerEvent) {
43968 canvas.on('pointerdown', this._handleMouseDown, this);
43969 canvas.on('pointermove', this._handleMouseMove, this);
43970 Roo.select('html').first().on('pointerup', this._handleMouseUp, this);
43973 if ('ontouchstart' in window) {
43974 canvas.on('touchstart', this._handleTouchStart, this);
43975 canvas.on('touchmove', this._handleTouchMove, this);
43976 canvas.on('touchend', this._handleTouchEnd, this);
43979 Roo.EventManager.onWindowResize(this.resize, this, true);
43981 // file input event
43982 this.fileEl().on('change', this.uploadImage, this);
43989 resize: function(){
43991 var canvas = this.canvasEl().dom;
43992 var ctx = this.canvasElCtx();
43993 var img_data = false;
43995 if(canvas.width > 0) {
43996 var img_data = ctx.getImageData(0, 0, canvas.width, canvas.height);
43998 // setting canvas width will clean img data
44001 var style = window.getComputedStyle ?
44002 getComputedStyle(this.el.dom, null) : this.el.dom.currentStyle;
44004 var padding_left = parseInt(style.paddingLeft) || 0;
44005 var padding_right = parseInt(style.paddingRight) || 0;
44007 canvas.width = this.el.dom.clientWidth - padding_left - padding_right;
44010 ctx.putImageData(img_data, 0, 0);
44014 _handleMouseDown: function(e)
44016 if (e.browserEvent.which === 1) {
44017 this.mouse_btn_down = true;
44018 this.strokeBegin(e);
44022 _handleMouseMove: function (e)
44024 if (this.mouse_btn_down) {
44025 this.strokeMoveUpdate(e);
44029 _handleMouseUp: function (e)
44031 if (e.browserEvent.which === 1 && this.mouse_btn_down) {
44032 this.mouse_btn_down = false;
44037 _handleTouchStart: function (e) {
44039 e.preventDefault();
44040 if (e.browserEvent.targetTouches.length === 1) {
44041 // var touch = e.browserEvent.changedTouches[0];
44042 // this.strokeBegin(touch);
44044 this.strokeBegin(e); // assume e catching the correct xy...
44048 _handleTouchMove: function (e) {
44049 e.preventDefault();
44050 // var touch = event.targetTouches[0];
44051 // _this._strokeMoveUpdate(touch);
44052 this.strokeMoveUpdate(e);
44055 _handleTouchEnd: function (e) {
44056 var wasCanvasTouched = e.target === this.canvasEl().dom;
44057 if (wasCanvasTouched) {
44058 e.preventDefault();
44059 // var touch = event.changedTouches[0];
44060 // _this._strokeEnd(touch);
44065 reset: function () {
44066 this._lastPoints = [];
44067 this._lastVelocity = 0;
44068 this._lastWidth = (this.min_width + this.max_width) / 2;
44069 this.canvasElCtx().fillStyle = this.dot_color;
44072 strokeMoveUpdate: function(e)
44074 this.strokeUpdate(e);
44076 if (this.throttle) {
44077 this.throttleStroke(this.strokeUpdate, this.throttle);
44080 this.strokeUpdate(e);
44084 strokeBegin: function(e)
44086 var newPointGroup = {
44087 color: this.dot_color,
44091 if (typeof this.onBegin === 'function') {
44095 this.curve_data.push(newPointGroup);
44097 this.strokeUpdate(e);
44100 strokeUpdate: function(e)
44102 var rect = this.canvasEl().dom.getBoundingClientRect();
44103 var point = new this.Point(e.xy[0] - rect.left, e.xy[1] - rect.top, new Date().getTime());
44104 var lastPointGroup = this.curve_data[this.curve_data.length - 1];
44105 var lastPoints = lastPointGroup.points;
44106 var lastPoint = lastPoints.length > 0 && lastPoints[lastPoints.length - 1];
44107 var isLastPointTooClose = lastPoint
44108 ? point.distanceTo(lastPoint) <= this.min_distance
44110 var color = lastPointGroup.color;
44111 if (!lastPoint || !(lastPoint && isLastPointTooClose)) {
44112 var curve = this.addPoint(point);
44114 this.drawDot({color: color, point: point});
44117 this.drawCurve({color: color, curve: curve});
44127 strokeEnd: function(e)
44129 this.strokeUpdate(e);
44130 if (typeof this.onEnd === 'function') {
44135 addPoint: function (point) {
44136 var _lastPoints = this._lastPoints;
44137 _lastPoints.push(point);
44138 if (_lastPoints.length > 2) {
44139 if (_lastPoints.length === 3) {
44140 _lastPoints.unshift(_lastPoints[0]);
44142 var widths = this.calculateCurveWidths(_lastPoints[1], _lastPoints[2]);
44143 var curve = this.Bezier.fromPoints(_lastPoints, widths, this);
44144 _lastPoints.shift();
44150 calculateCurveWidths: function (startPoint, endPoint) {
44151 var velocity = this.velocity_filter_weight * endPoint.velocityFrom(startPoint) +
44152 (1 - this.velocity_filter_weight) * this._lastVelocity;
44154 var newWidth = Math.max(this.max_width / (velocity + 1), this.min_width);
44157 start: this._lastWidth
44160 this._lastVelocity = velocity;
44161 this._lastWidth = newWidth;
44165 drawDot: function (_a) {
44166 var color = _a.color, point = _a.point;
44167 var ctx = this.canvasElCtx();
44168 var width = typeof this.dot_size === 'function' ? this.dot_size() : this.dot_size;
44170 this.drawCurveSegment(point.x, point.y, width);
44172 ctx.fillStyle = color;
44176 drawCurve: function (_a) {
44177 var color = _a.color, curve = _a.curve;
44178 var ctx = this.canvasElCtx();
44179 var widthDelta = curve.endWidth - curve.startWidth;
44180 var drawSteps = Math.floor(curve.length()) * 2;
44182 ctx.fillStyle = color;
44183 for (var i = 0; i < drawSteps; i += 1) {
44184 var t = i / drawSteps;
44190 var x = uuu * curve.startPoint.x;
44191 x += 3 * uu * t * curve.control1.x;
44192 x += 3 * u * tt * curve.control2.x;
44193 x += ttt * curve.endPoint.x;
44194 var y = uuu * curve.startPoint.y;
44195 y += 3 * uu * t * curve.control1.y;
44196 y += 3 * u * tt * curve.control2.y;
44197 y += ttt * curve.endPoint.y;
44198 var width = curve.startWidth + ttt * widthDelta;
44199 this.drawCurveSegment(x, y, width);
44205 drawCurveSegment: function (x, y, width) {
44206 var ctx = this.canvasElCtx();
44208 ctx.arc(x, y, width, 0, 2 * Math.PI, false);
44209 this.is_empty = false;
44214 var ctx = this.canvasElCtx();
44215 var canvas = this.canvasEl().dom;
44216 ctx.fillStyle = this.bg_color;
44217 ctx.clearRect(0, 0, canvas.width, canvas.height);
44218 ctx.fillRect(0, 0, canvas.width, canvas.height);
44219 this.curve_data = [];
44221 this.is_empty = true;
44226 return this.el.select('input',true).first();
44229 canvasEl: function()
44231 return this.el.select('canvas',true).first();
44234 canvasElCtx: function()
44236 return this.el.select('canvas',true).first().dom.getContext('2d');
44239 getImage: function(type)
44241 if(this.is_empty) {
44246 return this.canvasEl().dom.toDataURL('image/'+type, 1);
44249 drawFromImage: function(img_src)
44251 var img = new Image();
44253 img.onload = function(){
44254 this.canvasElCtx().drawImage(img, 0, 0);
44259 this.is_empty = false;
44262 selectImage: function()
44264 this.fileEl().dom.click();
44267 uploadImage: function(e)
44269 var reader = new FileReader();
44271 reader.onload = function(e){
44272 var img = new Image();
44273 img.onload = function(){
44275 this.canvasElCtx().drawImage(img, 0, 0);
44277 img.src = e.target.result;
44280 reader.readAsDataURL(e.target.files[0]);
44283 // Bezier Point Constructor
44284 Point: (function () {
44285 function Point(x, y, time) {
44288 this.time = time || Date.now();
44290 Point.prototype.distanceTo = function (start) {
44291 return Math.sqrt(Math.pow(this.x - start.x, 2) + Math.pow(this.y - start.y, 2));
44293 Point.prototype.equals = function (other) {
44294 return this.x === other.x && this.y === other.y && this.time === other.time;
44296 Point.prototype.velocityFrom = function (start) {
44297 return this.time !== start.time
44298 ? this.distanceTo(start) / (this.time - start.time)
44305 // Bezier Constructor
44306 Bezier: (function () {
44307 function Bezier(startPoint, control2, control1, endPoint, startWidth, endWidth) {
44308 this.startPoint = startPoint;
44309 this.control2 = control2;
44310 this.control1 = control1;
44311 this.endPoint = endPoint;
44312 this.startWidth = startWidth;
44313 this.endWidth = endWidth;
44315 Bezier.fromPoints = function (points, widths, scope) {
44316 var c2 = this.calculateControlPoints(points[0], points[1], points[2], scope).c2;
44317 var c3 = this.calculateControlPoints(points[1], points[2], points[3], scope).c1;
44318 return new Bezier(points[1], c2, c3, points[2], widths.start, widths.end);
44320 Bezier.calculateControlPoints = function (s1, s2, s3, scope) {
44321 var dx1 = s1.x - s2.x;
44322 var dy1 = s1.y - s2.y;
44323 var dx2 = s2.x - s3.x;
44324 var dy2 = s2.y - s3.y;
44325 var m1 = { x: (s1.x + s2.x) / 2.0, y: (s1.y + s2.y) / 2.0 };
44326 var m2 = { x: (s2.x + s3.x) / 2.0, y: (s2.y + s3.y) / 2.0 };
44327 var l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
44328 var l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
44329 var dxm = m1.x - m2.x;
44330 var dym = m1.y - m2.y;
44331 var k = l2 / (l1 + l2);
44332 var cm = { x: m2.x + dxm * k, y: m2.y + dym * k };
44333 var tx = s2.x - cm.x;
44334 var ty = s2.y - cm.y;
44336 c1: new scope.Point(m1.x + tx, m1.y + ty),
44337 c2: new scope.Point(m2.x + tx, m2.y + ty)
44340 Bezier.prototype.length = function () {
44345 for (var i = 0; i <= steps; i += 1) {
44347 var cx = this.point(t, this.startPoint.x, this.control1.x, this.control2.x, this.endPoint.x);
44348 var cy = this.point(t, this.startPoint.y, this.control1.y, this.control2.y, this.endPoint.y);
44350 var xdiff = cx - px;
44351 var ydiff = cy - py;
44352 length += Math.sqrt(xdiff * xdiff + ydiff * ydiff);
44359 Bezier.prototype.point = function (t, start, c1, c2, end) {
44360 return (start * (1.0 - t) * (1.0 - t) * (1.0 - t))
44361 + (3.0 * c1 * (1.0 - t) * (1.0 - t) * t)
44362 + (3.0 * c2 * (1.0 - t) * t * t)
44363 + (end * t * t * t);
44368 throttleStroke: function(fn, wait) {
44369 if (wait === void 0) { wait = 250; }
44371 var timeout = null;
44375 var later = function () {
44376 previous = Date.now();
44378 result = fn.apply(storedContext, storedArgs);
44380 storedContext = null;
44384 return function wrapper() {
44386 for (var _i = 0; _i < arguments.length; _i++) {
44387 args[_i] = arguments[_i];
44389 var now = Date.now();
44390 var remaining = wait - (now - previous);
44391 storedContext = this;
44393 if (remaining <= 0 || remaining > wait) {
44395 clearTimeout(timeout);
44399 result = fn.apply(storedContext, storedArgs);
44401 storedContext = null;
44405 else if (!timeout) {
44406 timeout = window.setTimeout(later, remaining);