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 {Number} width fixed width - usefull for chrome extension only really.
3951 * @cfg {Number} height fixed height - usefull for chrome extension only really.
3952 * @cfg {String} size (sm|lg|xl) default empty
3953 * @cfg {Number} max_width set the max width of modal
3954 * @cfg {Boolean} editableTitle can the title be edited
3959 * Create a new Modal Dialog
3960 * @param {Object} config The config object
3963 Roo.bootstrap.Modal = function(config){
3964 Roo.bootstrap.Modal.superclass.constructor.call(this, config);
3969 * The raw btnclick event for the button
3970 * @param {Roo.EventObject} e
3975 * Fire when dialog resize
3976 * @param {Roo.bootstrap.Modal} this
3977 * @param {Roo.EventObject} e
3981 * @event titlechanged
3982 * Fire when the editable title has been changed
3983 * @param {Roo.bootstrap.Modal} this
3984 * @param {Roo.EventObject} value
3986 "titlechanged" : true
3989 this.buttons = this.buttons || [];
3992 this.tmpl = Roo.factory(this.tmpl);
3997 Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, {
3999 title : 'test dialog',
4009 specificTitle: false,
4011 buttonPosition: 'right',
4033 editableTitle : false,
4035 onRender : function(ct, position)
4037 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
4040 var cfg = Roo.apply({}, this.getAutoCreate());
4043 // cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
4045 //if (!cfg.name.length) {
4049 cfg.cls += ' ' + this.cls;
4052 cfg.style = this.style;
4054 this.el = Roo.get(document.body).createChild(cfg, position);
4056 //var type = this.el.dom.type;
4059 if(this.tabIndex !== undefined){
4060 this.el.dom.setAttribute('tabIndex', this.tabIndex);
4063 this.dialogEl = this.el.select('.modal-dialog',true).first();
4064 this.bodyEl = this.el.select('.modal-body',true).first();
4065 this.closeEl = this.el.select('.modal-header .close', true).first();
4066 this.headerEl = this.el.select('.modal-header',true).first();
4067 this.titleEl = this.el.select('.modal-title',true).first();
4068 this.footerEl = this.el.select('.modal-footer',true).first();
4070 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
4072 //this.el.addClass("x-dlg-modal");
4074 if (this.buttons.length) {
4075 Roo.each(this.buttons, function(bb) {
4076 var b = Roo.apply({}, bb);
4077 b.xns = b.xns || Roo.bootstrap;
4078 b.xtype = b.xtype || 'Button';
4079 if (typeof(b.listeners) == 'undefined') {
4080 b.listeners = { click : this.onButtonClick.createDelegate(this) };
4083 var btn = Roo.factory(b);
4085 btn.render(this.getButtonContainer());
4089 // render the children.
4092 if(typeof(this.items) != 'undefined'){
4093 var items = this.items;
4096 for(var i =0;i < items.length;i++) {
4097 nitems.push(this.addxtype(Roo.apply({}, items[i])));
4101 this.items = nitems;
4103 // where are these used - they used to be body/close/footer
4107 //this.el.addClass([this.fieldClass, this.cls]);
4111 getAutoCreate : function()
4113 // we will default to modal-body-overflow - might need to remove or make optional later.
4115 cls : 'modal-body ' + (this.fitwindow ? 'overflow-auto' : ''),
4116 html : this.html || ''
4121 cls : 'modal-title',
4125 if(this.specificTitle){ // WTF is this?
4130 if (this.allow_close && Roo.bootstrap.version == 3) {
4140 if (this.editableTitle) {
4142 cls: 'form-control roo-editable-title d-none',
4148 if (this.allow_close && Roo.bootstrap.version == 4) {
4158 if(this.size.length){
4159 size = 'modal-' + this.size;
4162 var footer = Roo.bootstrap.version == 3 ?
4164 cls : 'modal-footer',
4168 cls: 'btn-' + this.buttonPosition
4173 { // BS4 uses mr-auto on left buttons....
4174 cls : 'modal-footer'
4185 cls: "modal-dialog " + size,
4188 cls : "modal-content",
4191 cls : 'modal-header',
4206 modal.cls += ' fade';
4212 getChildContainer : function() {
4217 getButtonContainer : function() {
4219 return Roo.bootstrap.version == 4 ?
4220 this.el.select('.modal-footer',true).first()
4221 : this.el.select('.modal-footer div',true).first();
4224 initEvents : function()
4226 if (this.allow_close) {
4227 this.closeEl.on('click', this.hide, this);
4229 Roo.EventManager.onWindowResize(this.resize, this, true);
4230 if (this.editableTitle) {
4231 this.headerEditEl = this.headerEl.select('.form-control',true).first();
4232 this.headerEl.on('click', function() { this.toggleHeaderInput(true) } , this);
4233 this.headerEditEl.on('keyup', function(e) {
4234 if([ e.RETURN , e.TAB , e.ESC ].indexOf(e.keyCode) > -1) {
4235 this.toggleHeaderInput(false)
4238 this.headerEditEl.on('blur', function(e) {
4239 this.toggleHeaderInput(false)
4248 this.maskEl.setSize(
4249 Roo.lib.Dom.getViewWidth(true),
4250 Roo.lib.Dom.getViewHeight(true)
4253 if (this.fitwindow) {
4257 this.width || Roo.lib.Dom.getViewportWidth(true) - 30,
4258 this.height || Roo.lib.Dom.getViewportHeight(true) // catering margin-top 30 margin-bottom 30
4263 if(this.max_width !== 0) {
4265 var w = Math.min(this.max_width, Roo.lib.Dom.getViewportWidth(true) - 30);
4268 this.setSize(w, this.height);
4272 if(this.max_height) {
4273 this.setSize(w,Math.min(
4275 Roo.lib.Dom.getViewportHeight(true) - 60
4281 if(!this.fit_content) {
4282 this.setSize(w, Roo.lib.Dom.getViewportHeight(true) - 60);
4286 this.setSize(w, Math.min(
4288 this.headerEl.getHeight() +
4289 this.footerEl.getHeight() +
4290 this.getChildHeight(this.bodyEl.dom.childNodes),
4291 Roo.lib.Dom.getViewportHeight(true) - 60)
4297 setSize : function(w,h)
4308 if (!this.rendered) {
4311 this.toggleHeaderInput(false);
4312 //this.el.setStyle('display', 'block');
4313 this.el.removeClass('hideing');
4314 this.el.dom.style.display='block';
4316 Roo.get(document.body).addClass('modal-open');
4318 if(this.animate){ // element has 'fade' - so stuff happens after .3s ?- not sure why the delay?
4321 this.el.addClass('show');
4322 this.el.addClass('in');
4325 this.el.addClass('show');
4326 this.el.addClass('in');
4329 // not sure how we can show data in here..
4331 // this.getChildContainer().dom.innerHTML = this.tmpl.applyTemplate(this);
4334 Roo.get(document.body).addClass("x-body-masked");
4336 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
4337 this.maskEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
4338 this.maskEl.dom.style.display = 'block';
4339 this.maskEl.addClass('show');
4344 this.fireEvent('show', this);
4346 // set zindex here - otherwise it appears to be ignored...
4347 this.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
4350 this.items.forEach( function(e) {
4351 e.layout ? e.layout() : false;
4359 if(this.fireEvent("beforehide", this) !== false){
4361 this.maskEl.removeClass('show');
4363 this.maskEl.dom.style.display = '';
4364 Roo.get(document.body).removeClass("x-body-masked");
4365 this.el.removeClass('in');
4366 this.el.select('.modal-dialog', true).first().setStyle('transform','');
4368 if(this.animate){ // why
4369 this.el.addClass('hideing');
4370 this.el.removeClass('show');
4372 if (!this.el.hasClass('hideing')) {
4373 return; // it's been shown again...
4376 this.el.dom.style.display='';
4378 Roo.get(document.body).removeClass('modal-open');
4379 this.el.removeClass('hideing');
4383 this.el.removeClass('show');
4384 this.el.dom.style.display='';
4385 Roo.get(document.body).removeClass('modal-open');
4388 this.fireEvent('hide', this);
4391 isVisible : function()
4394 return this.el.hasClass('show') && !this.el.hasClass('hideing');
4398 addButton : function(str, cb)
4402 var b = Roo.apply({}, { html : str } );
4403 b.xns = b.xns || Roo.bootstrap;
4404 b.xtype = b.xtype || 'Button';
4405 if (typeof(b.listeners) == 'undefined') {
4406 b.listeners = { click : cb.createDelegate(this) };
4409 var btn = Roo.factory(b);
4411 btn.render(this.getButtonContainer());
4417 setDefaultButton : function(btn)
4419 //this.el.select('.modal-footer').()
4422 resizeTo: function(w,h)
4424 this.dialogEl.setWidth(w);
4426 var diff = this.headerEl.getHeight() + this.footerEl.getHeight() + 60; // dialog margin-bottom: 30
4428 this.bodyEl.setHeight(h - diff);
4430 this.fireEvent('resize', this);
4433 setContentSize : function(w, h)
4437 onButtonClick: function(btn,e)
4440 this.fireEvent('btnclick', btn.name, e);
4443 * Set the title of the Dialog
4444 * @param {String} str new Title
4446 setTitle: function(str) {
4447 this.titleEl.dom.innerHTML = str;
4451 * Set the body of the Dialog
4452 * @param {String} str new Title
4454 setBody: function(str) {
4455 this.bodyEl.dom.innerHTML = str;
4458 * Set the body of the Dialog using the template
4459 * @param {Obj} data - apply this data to the template and replace the body contents.
4461 applyBody: function(obj)
4464 Roo.log("Error - using apply Body without a template");
4467 this.tmpl.overwrite(this.bodyEl, obj);
4470 getChildHeight : function(child_nodes)
4474 child_nodes.length == 0
4479 var child_height = 0;
4481 for(var i = 0; i < child_nodes.length; i++) {
4484 * for modal with tabs...
4485 if(child_nodes[i].classList.contains('roo-layout-panel')) {
4487 var layout_childs = child_nodes[i].childNodes;
4489 for(var j = 0; j < layout_childs.length; j++) {
4491 if(layout_childs[j].classList.contains('roo-layout-panel-body')) {
4493 var layout_body_childs = layout_childs[j].childNodes;
4495 for(var k = 0; k < layout_body_childs.length; k++) {
4497 if(layout_body_childs[k].classList.contains('navbar')) {
4498 child_height += layout_body_childs[k].offsetHeight;
4502 if(layout_body_childs[k].classList.contains('roo-layout-tabs-body')) {
4504 var layout_body_tab_childs = layout_body_childs[k].childNodes;
4506 for(var m = 0; m < layout_body_tab_childs.length; m++) {
4508 if(layout_body_tab_childs[m].classList.contains('roo-layout-active-content')) {
4509 child_height += this.getChildHeight(layout_body_tab_childs[m].childNodes);
4524 child_height += child_nodes[i].offsetHeight;
4525 // Roo.log(child_nodes[i].offsetHeight);
4528 return child_height;
4530 toggleHeaderInput : function(is_edit)
4532 if (!this.editableTitle) {
4533 return; // not editable.
4535 if (is_edit && this.is_header_editing) {
4536 return; // already editing..
4540 this.headerEditEl.dom.value = this.title;
4541 this.headerEditEl.removeClass('d-none');
4542 this.headerEditEl.dom.focus();
4543 this.titleEl.addClass('d-none');
4545 this.is_header_editing = true;
4548 // flip back to not editing.
4549 this.title = this.headerEditEl.dom.value;
4550 this.headerEditEl.addClass('d-none');
4551 this.titleEl.removeClass('d-none');
4552 this.titleEl.dom.innerHTML = String.format('{0}', this.title);
4553 this.is_header_editing = false;
4554 this.fireEvent('titlechanged', this, this.title);
4563 Roo.apply(Roo.bootstrap.Modal, {
4565 * Button config that displays a single OK button
4574 * Button config that displays Yes and No buttons
4590 * Button config that displays OK and Cancel buttons
4605 * Button config that displays Yes, No and Cancel buttons
4630 * messagebox - can be used as a replace
4634 * @class Roo.MessageBox
4635 * Utility class for generating different styles of message boxes. The alias Roo.Msg can also be used.
4639 Roo.Msg.alert('Status', 'Changes saved successfully.');
4641 // Prompt for user data:
4642 Roo.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
4644 // process text value...
4648 // Show a dialog using config options:
4650 title:'Save Changes?',
4651 msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',
4652 buttons: Roo.Msg.YESNOCANCEL,
4659 Roo.bootstrap.MessageBox = function(){
4660 var dlg, opt, mask, waitTimer;
4661 var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp;
4662 var buttons, activeTextEl, bwidth;
4666 var handleButton = function(button){
4668 Roo.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
4672 var handleHide = function(){
4674 dlg.el.removeClass(opt.cls);
4677 // Roo.TaskMgr.stop(waitTimer);
4678 // waitTimer = null;
4683 var updateButtons = function(b){
4686 buttons["ok"].hide();
4687 buttons["cancel"].hide();
4688 buttons["yes"].hide();
4689 buttons["no"].hide();
4690 dlg.footerEl.hide();
4694 dlg.footerEl.show();
4695 for(var k in buttons){
4696 if(typeof buttons[k] != "function"){
4699 buttons[k].setText(typeof b[k] == "string" ? b[k] : Roo.bootstrap.MessageBox.buttonText[k]);
4700 width += buttons[k].el.getWidth()+15;
4710 var handleEsc = function(d, k, e){
4711 if(opt && opt.closable !== false){
4721 * Returns a reference to the underlying {@link Roo.BasicDialog} element
4722 * @return {Roo.BasicDialog} The BasicDialog element
4724 getDialog : function(){
4726 dlg = new Roo.bootstrap.Modal( {
4729 //constraintoviewport:false,
4731 //collapsible : false,
4736 //buttonAlign:"center",
4737 closeClick : function(){
4738 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
4741 handleButton("cancel");
4746 dlg.on("hide", handleHide);
4748 //dlg.addKeyListener(27, handleEsc);
4750 this.buttons = buttons;
4751 var bt = this.buttonText;
4752 buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
4753 buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
4754 buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
4755 buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
4757 bodyEl = dlg.bodyEl.createChild({
4759 html:'<span class="roo-mb-text"></span><br /><input type="text" class="roo-mb-input" />' +
4760 '<textarea class="roo-mb-textarea"></textarea>' +
4761 '<div class="roo-mb-progress-wrap"><div class="roo-mb-progress"><div class="roo-mb-progress-bar"> </div></div></div>'
4763 msgEl = bodyEl.dom.firstChild;
4764 textboxEl = Roo.get(bodyEl.dom.childNodes[2]);
4765 textboxEl.enableDisplayMode();
4766 textboxEl.addKeyListener([10,13], function(){
4767 if(dlg.isVisible() && opt && opt.buttons){
4770 }else if(opt.buttons.yes){
4771 handleButton("yes");
4775 textareaEl = Roo.get(bodyEl.dom.childNodes[3]);
4776 textareaEl.enableDisplayMode();
4777 progressEl = Roo.get(bodyEl.dom.childNodes[4]);
4778 progressEl.enableDisplayMode();
4780 // This is supposed to be the progessElement.. but I think it's controlling the height of everything..
4781 var pf = progressEl.dom.firstChild;
4783 pp = Roo.get(pf.firstChild);
4784 pp.setHeight(pf.offsetHeight);
4792 * Updates the message box body text
4793 * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
4794 * the XHTML-compliant non-breaking space character '&#160;')
4795 * @return {Roo.MessageBox} This message box
4797 updateText : function(text)
4799 if(!dlg.isVisible() && !opt.width){
4800 dlg.dialogEl.setStyle({ 'max-width' : this.maxWidth});
4801 // dlg.resizeTo(this.maxWidth, 100); // forcing the height breaks long alerts()
4803 msgEl.innerHTML = text || ' ';
4805 var cw = Math.max(msgEl.offsetWidth, msgEl.parentNode.scrollWidth);
4806 //Roo.log("guesed size: " + JSON.stringify([cw,msgEl.offsetWidth, msgEl.parentNode.scrollWidth]));
4808 Math.min(opt.width || cw , this.maxWidth),
4809 Math.max(opt.minWidth || this.minWidth, bwidth)
4812 activeTextEl.setWidth(w);
4814 if(dlg.isVisible()){
4815 dlg.fixedcenter = false;
4817 // to big, make it scroll. = But as usual stupid IE does not support
4820 if ( bodyEl.getHeight() > (Roo.lib.Dom.getViewHeight() - 100)) {
4821 bodyEl.setHeight ( Roo.lib.Dom.getViewHeight() - 100 );
4822 bodyEl.dom.style.overflowY = 'auto' + ( Roo.isIE ? '' : ' !important');
4824 bodyEl.dom.style.height = '';
4825 bodyEl.dom.style.overflowY = '';
4828 bodyEl.dom.style.get = 'auto' + ( Roo.isIE ? '' : ' !important');
4830 bodyEl.dom.style.overflowX = '';
4833 dlg.setContentSize(w, bodyEl.getHeight());
4834 if(dlg.isVisible()){
4835 dlg.fixedcenter = true;
4841 * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
4842 * initiated via {@link Roo.MessageBox#progress} or by calling {@link Roo.MessageBox#show} with progress: true.
4843 * @param {Number} value Any number between 0 and 1 (e.g., .5)
4844 * @param {String} text (optional) If defined, the message box's body text is replaced with the specified string (defaults to undefined)
4845 * @return {Roo.MessageBox} This message box
4847 updateProgress : function(value, text){
4849 this.updateText(text);
4852 if (pp) { // weird bug on my firefox - for some reason this is not defined
4853 pp.setWidth(Math.floor(value*progressEl.dom.firstChild.offsetWidth));
4854 pp.setHeight(Math.floor(progressEl.dom.firstChild.offsetHeight));
4860 * Returns true if the message box is currently displayed
4861 * @return {Boolean} True if the message box is visible, else false
4863 isVisible : function(){
4864 return dlg && dlg.isVisible();
4868 * Hides the message box if it is displayed
4871 if(this.isVisible()){
4877 * Displays a new message box, or reinitializes an existing message box, based on the config options
4878 * passed in. All functions (e.g. prompt, alert, etc) on MessageBox call this function internally.
4879 * The following config object properties are supported:
4881 Property Type Description
4882 ---------- --------------- ------------------------------------------------------------------------------------
4883 animEl String/Element An id or Element from which the message box should animate as it opens and
4884 closes (defaults to undefined)
4885 buttons Object/Boolean A button config object (e.g., Roo.MessageBox.OKCANCEL or {ok:'Foo',
4886 cancel:'Bar'}), or false to not show any buttons (defaults to false)
4887 closable Boolean False to hide the top-right close button (defaults to true). Note that
4888 progress and wait dialogs will ignore this property and always hide the
4889 close button as they can only be closed programmatically.
4890 cls String A custom CSS class to apply to the message box element
4891 defaultTextHeight Number The default height in pixels of the message box's multiline textarea if
4892 displayed (defaults to 75)
4893 fn Function A callback function to execute after closing the dialog. The arguments to the
4894 function will be btn (the name of the button that was clicked, if applicable,
4895 e.g. "ok"), and text (the value of the active text field, if applicable).
4896 Progress and wait dialogs will ignore this option since they do not respond to
4897 user actions and can only be closed programmatically, so any required function
4898 should be called by the same code after it closes the dialog.
4899 icon String A CSS class that provides a background image to be used as an icon for
4900 the dialog (e.g., Roo.MessageBox.WARNING or 'custom-class', defaults to '')
4901 maxWidth Number The maximum width in pixels of the message box (defaults to 600)
4902 minWidth Number The minimum width in pixels of the message box (defaults to 100)
4903 modal Boolean False to allow user interaction with the page while the message box is
4904 displayed (defaults to true)
4905 msg String A string that will replace the existing message box body text (defaults
4906 to the XHTML-compliant non-breaking space character ' ')
4907 multiline Boolean True to prompt the user to enter multi-line text (defaults to false)
4908 progress Boolean True to display a progress bar (defaults to false)
4909 progressText String The text to display inside the progress bar if progress = true (defaults to '')
4910 prompt Boolean True to prompt the user to enter single-line text (defaults to false)
4911 proxyDrag Boolean True to display a lightweight proxy while dragging (defaults to false)
4912 title String The title text
4913 value String The string value to set into the active textbox element if displayed
4914 wait Boolean True to display a progress bar (defaults to false)
4915 width Number The width of the dialog in pixels
4922 msg: 'Please enter your address:',
4924 buttons: Roo.MessageBox.OKCANCEL,
4927 animEl: 'addAddressBtn'
4930 * @param {Object} config Configuration options
4931 * @return {Roo.MessageBox} This message box
4933 show : function(options)
4936 // this causes nightmares if you show one dialog after another
4937 // especially on callbacks..
4939 if(this.isVisible()){
4942 Roo.log("[Roo.Messagebox] Show called while message displayed:" );
4943 Roo.log("Old Dialog Message:" + msgEl.innerHTML );
4944 Roo.log("New Dialog Message:" + options.msg )
4945 //this.alert("ERROR", "Multiple dialogs where displayed at the same time");
4946 //throw "Roo.MessageBox ERROR : Multiple dialogs where displayed at the same time";
4949 var d = this.getDialog();
4951 d.setTitle(opt.title || " ");
4952 d.closeEl.setDisplayed(opt.closable !== false);
4953 activeTextEl = textboxEl;
4954 opt.prompt = opt.prompt || (opt.multiline ? true : false);
4959 textareaEl.setHeight(typeof opt.multiline == "number" ?
4960 opt.multiline : this.defaultTextHeight);
4961 activeTextEl = textareaEl;
4970 progressEl.setDisplayed(opt.progress === true);
4972 d.animate = false; // do not animate progress, as it may not have finished animating before we close it..
4974 this.updateProgress(0);
4975 activeTextEl.dom.value = opt.value || "";
4977 dlg.setDefaultButton(activeTextEl);
4979 var bs = opt.buttons;
4983 }else if(bs && bs.yes){
4984 db = buttons["yes"];
4986 dlg.setDefaultButton(db);
4988 bwidth = updateButtons(opt.buttons);
4989 this.updateText(opt.msg);
4991 d.el.addClass(opt.cls);
4993 d.proxyDrag = opt.proxyDrag === true;
4994 d.modal = opt.modal !== false;
4995 d.mask = opt.modal !== false ? mask : false;
4997 // force it to the end of the z-index stack so it gets a cursor in FF
4998 document.body.appendChild(dlg.el.dom);
4999 d.animateTarget = null;
5000 d.show(options.animEl);
5006 * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
5007 * the user. You are responsible for updating the progress bar as needed via {@link Roo.MessageBox#updateProgress}
5008 * and closing the message box when the process is complete.
5009 * @param {String} title The title bar text
5010 * @param {String} msg The message box body text
5011 * @return {Roo.MessageBox} This message box
5013 progress : function(title, msg){
5020 minWidth: this.minProgressWidth,
5027 * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
5028 * If a callback function is passed it will be called after the user clicks the button, and the
5029 * id of the button that was clicked will be passed as the only parameter to the callback
5030 * (could also be the top-right close button).
5031 * @param {String} title The title bar text
5032 * @param {String} msg The message box body text
5033 * @param {Function} fn (optional) The callback function invoked after the message box is closed
5034 * @param {Object} scope (optional) The scope of the callback function
5035 * @return {Roo.MessageBox} This message box
5037 alert : function(title, msg, fn, scope)
5052 * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
5053 * interaction while waiting for a long-running process to complete that does not have defined intervals.
5054 * You are responsible for closing the message box when the process is complete.
5055 * @param {String} msg The message box body text
5056 * @param {String} title (optional) The title bar text
5057 * @return {Roo.MessageBox} This message box
5059 wait : function(msg, title){
5070 waitTimer = Roo.TaskMgr.start({
5072 Roo.MessageBox.updateProgress(((((i+20)%20)+1)*5)*.01);
5080 * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
5081 * If a callback function is passed it will be called after the user clicks either button, and the id of the
5082 * button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
5083 * @param {String} title The title bar text
5084 * @param {String} msg The message box body text
5085 * @param {Function} fn (optional) The callback function invoked after the message box is closed
5086 * @param {Object} scope (optional) The scope of the callback function
5087 * @return {Roo.MessageBox} This message box
5089 confirm : function(title, msg, fn, scope){
5093 buttons: this.YESNO,
5102 * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to
5103 * JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function
5104 * is passed it will be called after the user clicks either button, and the id of the button that was clicked
5105 * (could also be the top-right close button) and the text that was entered will be passed as the two
5106 * parameters to the callback.
5107 * @param {String} title The title bar text
5108 * @param {String} msg The message box body text
5109 * @param {Function} fn (optional) The callback function invoked after the message box is closed
5110 * @param {Object} scope (optional) The scope of the callback function
5111 * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
5112 * property, or the height in pixels to create the textbox (defaults to false / single-line)
5113 * @return {Roo.MessageBox} This message box
5115 prompt : function(title, msg, fn, scope, multiline){
5119 buttons: this.OKCANCEL,
5124 multiline: multiline,
5131 * Button config that displays a single OK button
5136 * Button config that displays Yes and No buttons
5139 YESNO : {yes:true, no:true},
5141 * Button config that displays OK and Cancel buttons
5144 OKCANCEL : {ok:true, cancel:true},
5146 * Button config that displays Yes, No and Cancel buttons
5149 YESNOCANCEL : {yes:true, no:true, cancel:true},
5152 * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
5155 defaultTextHeight : 75,
5157 * The maximum width in pixels of the message box (defaults to 600)
5162 * The minimum width in pixels of the message box (defaults to 100)
5167 * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
5168 * for setting a different minimum width than text-only dialogs may need (defaults to 250)
5171 minProgressWidth : 250,
5173 * An object containing the default button text strings that can be overriden for localized language support.
5174 * Supported properties are: ok, cancel, yes and no.
5175 * Customize the default text like so: Roo.MessageBox.buttonText.yes = "S?";
5188 * Shorthand for {@link Roo.MessageBox}
5190 Roo.MessageBox = Roo.MessageBox || Roo.bootstrap.MessageBox;
5191 Roo.Msg = Roo.Msg || Roo.MessageBox;
5200 * @class Roo.bootstrap.Navbar
5201 * @extends Roo.bootstrap.Component
5202 * Bootstrap Navbar class
5205 * Create a new Navbar
5206 * @param {Object} config The config object
5210 Roo.bootstrap.Navbar = function(config){
5211 Roo.bootstrap.Navbar.superclass.constructor.call(this, config);
5215 * @event beforetoggle
5216 * Fire before toggle the menu
5217 * @param {Roo.EventObject} e
5219 "beforetoggle" : true
5223 Roo.extend(Roo.bootstrap.Navbar, Roo.bootstrap.Component, {
5232 getAutoCreate : function(){
5235 throw { message : "nav bar is now a abstract base class - use NavSimplebar / NavHeaderbar / NavSidebar etc..."};
5239 initEvents :function ()
5241 //Roo.log(this.el.select('.navbar-toggle',true));
5242 this.el.select('.navbar-toggle',true).on('click', this.onToggle , this);
5249 this.maskEl = Roo.DomHelper.append(this.el, mark, true);
5251 var size = this.el.getSize();
5252 this.maskEl.setSize(size.width, size.height);
5253 this.maskEl.enableDisplayMode("block");
5262 getChildContainer : function()
5264 if (this.el && this.el.select('.collapse').getCount()) {
5265 return this.el.select('.collapse',true).first();
5280 onToggle : function()
5283 if(this.fireEvent('beforetoggle', this) === false){
5286 var ce = this.el.select('.navbar-collapse',true).first();
5288 if (!ce.hasClass('show')) {
5298 * Expand the navbar pulldown
5300 expand : function ()
5303 var ce = this.el.select('.navbar-collapse',true).first();
5304 if (ce.hasClass('collapsing')) {
5307 ce.dom.style.height = '';
5309 ce.addClass('in'); // old...
5310 ce.removeClass('collapse');
5311 ce.addClass('show');
5312 var h = ce.getHeight();
5314 ce.removeClass('show');
5315 // at this point we should be able to see it..
5316 ce.addClass('collapsing');
5318 ce.setHeight(0); // resize it ...
5319 ce.on('transitionend', function() {
5320 //Roo.log('done transition');
5321 ce.removeClass('collapsing');
5322 ce.addClass('show');
5323 ce.removeClass('collapse');
5325 ce.dom.style.height = '';
5326 }, this, { single: true} );
5328 ce.dom.scrollTop = 0;
5331 * Collapse the navbar pulldown
5333 collapse : function()
5335 var ce = this.el.select('.navbar-collapse',true).first();
5337 if (ce.hasClass('collapsing') || ce.hasClass('collapse') ) {
5338 // it's collapsed or collapsing..
5341 ce.removeClass('in'); // old...
5342 ce.setHeight(ce.getHeight());
5343 ce.removeClass('show');
5344 ce.addClass('collapsing');
5346 ce.on('transitionend', function() {
5347 ce.dom.style.height = '';
5348 ce.removeClass('collapsing');
5349 ce.addClass('collapse');
5350 }, this, { single: true} );
5370 * @class Roo.bootstrap.NavSimplebar
5371 * @extends Roo.bootstrap.Navbar
5372 * Bootstrap Sidebar class
5374 * @cfg {Boolean} inverse is inverted color
5376 * @cfg {String} type (nav | pills | tabs)
5377 * @cfg {Boolean} arrangement stacked | justified
5378 * @cfg {String} align (left | right) alignment
5380 * @cfg {Boolean} main (true|false) main nav bar? default false
5381 * @cfg {Boolean} loadMask (true|false) loadMask on the bar
5383 * @cfg {String} tag (header|footer|nav|div) default is nav
5385 * @cfg {String} weight (light|primary|secondary|success|danger|warning|info|dark|white) default is light.
5389 * Create a new Sidebar
5390 * @param {Object} config The config object
5394 Roo.bootstrap.NavSimplebar = function(config){
5395 Roo.bootstrap.NavSimplebar.superclass.constructor.call(this, config);
5398 Roo.extend(Roo.bootstrap.NavSimplebar, Roo.bootstrap.Navbar, {
5414 getAutoCreate : function(){
5418 tag : this.tag || 'div',
5419 cls : 'navbar roo-navbar-simple' //navbar-expand-lg ??
5421 if (['light','white'].indexOf(this.weight) > -1) {
5422 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
5424 cfg.cls += ' bg-' + this.weight;
5427 cfg.cls += ' navbar-inverse';
5431 // i'm not actually sure these are really used - normally we add a navGroup to a navbar
5433 if (Roo.bootstrap.version == 4 && this.xtype == 'NavSimplebar') {
5442 cls: 'nav nav-' + this.xtype,
5448 this.type = this.type || 'nav';
5449 if (['tabs','pills'].indexOf(this.type) != -1) {
5450 cfg.cn[0].cls += ' nav-' + this.type
5454 if (this.type!=='nav') {
5455 Roo.log('nav type must be nav/tabs/pills')
5457 cfg.cn[0].cls += ' navbar-nav'
5463 if (['stacked','justified'].indexOf(this.arrangement) != -1) {
5464 cfg.cn[0].cls += ' nav-' + this.arrangement;
5468 if (this.align === 'right') {
5469 cfg.cn[0].cls += ' navbar-right';
5494 * navbar-expand-md fixed-top
5498 * @class Roo.bootstrap.NavHeaderbar
5499 * @extends Roo.bootstrap.NavSimplebar
5500 * Bootstrap Sidebar class
5502 * @cfg {String} brand what is brand
5503 * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
5504 * @cfg {String} brand_href href of the brand
5505 * @cfg {Boolean} srButton generate the (screen reader / mobile) sr-only button default true
5506 * @cfg {Boolean} autohide a top nav bar header that hides on scroll.
5507 * @cfg {Boolean} desktopCenter should the header be centered on desktop using a container class
5508 * @cfg {Roo.bootstrap.Row} mobilerow - a row to display on mobile only..
5511 * Create a new Sidebar
5512 * @param {Object} config The config object
5516 Roo.bootstrap.NavHeaderbar = function(config){
5517 Roo.bootstrap.NavHeaderbar.superclass.constructor.call(this, config);
5521 Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar, {
5528 desktopCenter : false,
5531 getAutoCreate : function(){
5534 tag: this.nav || 'nav',
5535 cls: 'navbar navbar-expand-md',
5541 if (this.desktopCenter) {
5542 cn.push({cls : 'container', cn : []});
5550 cls: 'navbar-toggle navbar-toggler',
5551 'data-toggle': 'collapse',
5556 html: 'Toggle navigation'
5560 cls: 'icon-bar navbar-toggler-icon'
5573 cn.push( Roo.bootstrap.version == 4 ? btn : {
5575 cls: 'navbar-header',
5584 cls: Roo.bootstrap.version == 4 ? 'nav flex-row roo-navbar-collapse collapse navbar-collapse' : 'collapse navbar-collapse roo-navbar-collapse',
5588 cfg.cls += this.inverse ? ' navbar-inverse navbar-dark bg-dark' : ' navbar-default';
5590 if (['light','white'].indexOf(this.weight) > -1) {
5591 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
5593 cfg.cls += ' bg-' + this.weight;
5596 if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
5597 cfg.cls += ' navbar-' + this.position + ' ' + this.position ;
5599 // tag can override this..
5601 cfg.tag = this.tag || (this.position == 'fixed-bottom' ? 'footer' : 'header');
5604 if (this.brand !== '') {
5605 var cp = Roo.bootstrap.version == 4 ? cn : cn[0].cn;
5606 cp.unshift({ // changed from push ?? BS4 needs it at the start? - does this break or exsiting?
5608 href: this.brand_href ? this.brand_href : '#',
5609 cls: 'navbar-brand',
5617 cfg.cls += ' main-nav';
5625 getHeaderChildContainer : function()
5627 if (this.srButton && this.el.select('.navbar-header').getCount()) {
5628 return this.el.select('.navbar-header',true).first();
5631 return this.getChildContainer();
5634 getChildContainer : function()
5637 return this.el.select('.roo-navbar-collapse',true).first();
5642 initEvents : function()
5644 Roo.bootstrap.NavHeaderbar.superclass.initEvents.call(this);
5646 if (this.autohide) {
5651 Roo.get(document).on('scroll',function(e) {
5652 var ns = Roo.get(document).getScroll().top;
5653 var os = prevScroll;
5657 ft.removeClass('slideDown');
5658 ft.addClass('slideUp');
5661 ft.removeClass('slideUp');
5662 ft.addClass('slideDown');
5683 * @class Roo.bootstrap.NavSidebar
5684 * @extends Roo.bootstrap.Navbar
5685 * Bootstrap Sidebar class
5688 * Create a new Sidebar
5689 * @param {Object} config The config object
5693 Roo.bootstrap.NavSidebar = function(config){
5694 Roo.bootstrap.NavSidebar.superclass.constructor.call(this, config);
5697 Roo.extend(Roo.bootstrap.NavSidebar, Roo.bootstrap.Navbar, {
5699 sidebar : true, // used by Navbar Item and NavbarGroup at present...
5701 getAutoCreate : function(){
5706 cls: 'sidebar sidebar-nav'
5728 * @class Roo.bootstrap.NavGroup
5729 * @extends Roo.bootstrap.Component
5730 * Bootstrap NavGroup class
5731 * @cfg {String} align (left|right)
5732 * @cfg {Boolean} inverse
5733 * @cfg {String} type (nav|pills|tab) default nav
5734 * @cfg {String} navId - reference Id for navbar.
5738 * Create a new nav group
5739 * @param {Object} config The config object
5742 Roo.bootstrap.NavGroup = function(config){
5743 Roo.bootstrap.NavGroup.superclass.constructor.call(this, config);
5746 Roo.bootstrap.NavGroup.register(this);
5750 * Fires when the active item changes
5751 * @param {Roo.bootstrap.NavGroup} this
5752 * @param {Roo.bootstrap.Navbar.Item} selected The item selected
5753 * @param {Roo.bootstrap.Navbar.Item} prev The previously selected item
5760 Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, {
5771 getAutoCreate : function()
5773 var cfg = Roo.apply({}, Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));
5779 if (Roo.bootstrap.version == 4) {
5780 if (['tabs','pills'].indexOf(this.type) != -1) {
5781 cfg.cls += ' nav-' + this.type;
5783 // trying to remove so header bar can right align top?
5784 if (this.parent() && this.parent().xtype != 'NavHeaderbar') {
5785 // do not use on header bar...
5786 cfg.cls += ' navbar-nav';
5791 if (['tabs','pills'].indexOf(this.type) != -1) {
5792 cfg.cls += ' nav-' + this.type
5794 if (this.type !== 'nav') {
5795 Roo.log('nav type must be nav/tabs/pills')
5797 cfg.cls += ' navbar-nav'
5801 if (this.parent() && this.parent().sidebar) {
5804 cls: 'dashboard-menu sidebar-menu'
5810 if (this.form === true) {
5813 cls: 'navbar-form form-inline'
5815 //nav navbar-right ml-md-auto
5816 if (this.align === 'right') {
5817 cfg.cls += ' navbar-right ml-md-auto';
5819 cfg.cls += ' navbar-left';
5823 if (this.align === 'right') {
5824 cfg.cls += ' navbar-right ml-md-auto';
5826 cfg.cls += ' mr-auto';
5830 cfg.cls += ' navbar-inverse';
5838 * sets the active Navigation item
5839 * @param {Roo.bootstrap.NavItem} the new current navitem
5841 setActiveItem : function(item)
5844 Roo.each(this.navItems, function(v){
5849 v.setActive(false, true);
5856 item.setActive(true, true);
5857 this.fireEvent('changed', this, item, prev);
5862 * gets the active Navigation item
5863 * @return {Roo.bootstrap.NavItem} the current navitem
5865 getActive : function()
5869 Roo.each(this.navItems, function(v){
5880 indexOfNav : function()
5884 Roo.each(this.navItems, function(v,i){
5895 * adds a Navigation item
5896 * @param {Roo.bootstrap.NavItem} the navitem to add
5898 addItem : function(cfg)
5900 if (this.form && Roo.bootstrap.version == 4) {
5903 var cn = new Roo.bootstrap.NavItem(cfg);
5905 cn.parentId = this.id;
5906 cn.onRender(this.el, null);
5910 * register a Navigation item
5911 * @param {Roo.bootstrap.NavItem} the navitem to add
5913 register : function(item)
5915 this.navItems.push( item);
5916 item.navId = this.navId;
5921 * clear all the Navigation item
5924 clearAll : function()
5927 this.el.dom.innerHTML = '';
5930 getNavItem: function(tabId)
5933 Roo.each(this.navItems, function(e) {
5934 if (e.tabId == tabId) {
5944 setActiveNext : function()
5946 var i = this.indexOfNav(this.getActive());
5947 if (i > this.navItems.length) {
5950 this.setActiveItem(this.navItems[i+1]);
5952 setActivePrev : function()
5954 var i = this.indexOfNav(this.getActive());
5958 this.setActiveItem(this.navItems[i-1]);
5960 clearWasActive : function(except) {
5961 Roo.each(this.navItems, function(e) {
5962 if (e.tabId != except.tabId && e.was_active) {
5963 e.was_active = false;
5970 getWasActive : function ()
5973 Roo.each(this.navItems, function(e) {
5988 Roo.apply(Roo.bootstrap.NavGroup, {
5992 * register a Navigation Group
5993 * @param {Roo.bootstrap.NavGroup} the navgroup to add
5995 register : function(navgrp)
5997 this.groups[navgrp.navId] = navgrp;
6001 * fetch a Navigation Group based on the navigation ID
6002 * @param {string} the navgroup to add
6003 * @returns {Roo.bootstrap.NavGroup} the navgroup
6005 get: function(navId) {
6006 if (typeof(this.groups[navId]) == 'undefined') {
6008 //this.register(new Roo.bootstrap.NavGroup({ navId : navId }));
6010 return this.groups[navId] ;
6025 * @class Roo.bootstrap.NavItem
6026 * @extends Roo.bootstrap.Component
6027 * Bootstrap Navbar.NavItem class
6028 * @cfg {String} href link to
6029 * @cfg {String} button_weight (default | primary | secondary | success | info | warning | danger | link ) default none
6031 * @cfg {String} html content of button
6032 * @cfg {String} badge text inside badge
6033 * @cfg {String} badgecls (bg-green|bg-red|bg-yellow)the extra classes for the badge
6034 * @cfg {String} glyphicon DEPRICATED - use fa
6035 * @cfg {String} icon DEPRICATED - use fa
6036 * @cfg {String} fa - Fontawsome icon name (can add stuff to it like fa-2x)
6037 * @cfg {Boolean} active Is item active
6038 * @cfg {Boolean} disabled Is item disabled
6040 * @cfg {Boolean} preventDefault (true | false) default false
6041 * @cfg {String} tabId the tab that this item activates.
6042 * @cfg {String} tagtype (a|span) render as a href or span?
6043 * @cfg {Boolean} animateRef (true|false) link to element default false
6046 * Create a new Navbar Item
6047 * @param {Object} config The config object
6049 Roo.bootstrap.NavItem = function(config){
6050 Roo.bootstrap.NavItem.superclass.constructor.call(this, config);
6055 * The raw click event for the entire grid.
6056 * @param {Roo.EventObject} e
6061 * Fires when the active item active state changes
6062 * @param {Roo.bootstrap.NavItem} this
6063 * @param {boolean} state the new state
6069 * Fires when scroll to element
6070 * @param {Roo.bootstrap.NavItem} this
6071 * @param {Object} options
6072 * @param {Roo.EventObject} e
6080 Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, {
6089 preventDefault : false,
6097 button_outline : false,
6101 getAutoCreate : function(){
6109 cfg.cls = typeof(cfg.cls) == 'undefined' ? 'active' : cfg.cls + ' active';
6111 if (this.disabled) {
6112 cfg.cls += ' disabled';
6116 if (this.button_weight.length) {
6117 cfg.tag = this.href ? 'a' : 'button';
6118 cfg.html = this.html || '';
6119 cfg.cls += ' btn btn' + (this.button_outline ? '-outline' : '') + '-' + this.button_weight;
6121 cfg.href = this.href;
6124 cfg.html = '<i class="fa fas fa-'+this.fa+'"></i> <span>' + this.html + '</span>';
6127 // menu .. should add dropdown-menu class - so no need for carat..
6129 if (this.badge !== '') {
6131 cfg.html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
6136 if (this.href || this.html || this.glyphicon || this.icon || this.fa) {
6140 href : this.href || "#",
6141 html: this.html || ''
6144 if (this.tagtype == 'a') {
6145 cfg.cn[0].cls = 'nav-link';
6148 cfg.cn[0].html = '<i class="'+this.icon+'"></i> <span>' + cfg.cn[0].html + '</span>';
6151 cfg.cn[0].html = '<i class="fa fas fa-'+this.fa+'"></i> <span>' + cfg.cn[0].html + '</span>';
6153 if(this.glyphicon) {
6154 cfg.cn[0].html = '<span class="glyphicon glyphicon-' + this.glyphicon + '"></span> ' + cfg.cn[0].html;
6159 cfg.cn[0].html += " <span class='caret'></span>";
6163 if (this.badge !== '') {
6165 cfg.cn[0].html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
6173 onRender : function(ct, position)
6175 // Roo.log("Call onRender: " + this.xtype);
6176 if (Roo.bootstrap.version == 4 && ct.dom.type != 'ul') {
6180 var ret = Roo.bootstrap.NavItem.superclass.onRender.call(this, ct, position);
6181 this.navLink = this.el.select('.nav-link',true).first();
6186 initEvents: function()
6188 if (typeof (this.menu) != 'undefined') {
6189 this.menu.parentType = this.xtype;
6190 this.menu.triggerEl = this.el;
6191 this.menu = this.addxtype(Roo.apply({}, this.menu));
6194 this.el.select('a',true).on('click', this.onClick, this);
6196 if(this.tagtype == 'span'){
6197 this.el.select('span',true).on('click', this.onClick, this);
6200 // at this point parent should be available..
6201 this.parent().register(this);
6204 onClick : function(e)
6206 if (e.getTarget('.dropdown-menu-item')) {
6207 // did you click on a menu itemm.... - then don't trigger onclick..
6212 this.preventDefault ||
6215 Roo.log("NavItem - prevent Default?");
6219 if (this.disabled) {
6223 var tg = Roo.bootstrap.TabGroup.get(this.navId);
6224 if (tg && tg.transition) {
6225 Roo.log("waiting for the transitionend");
6231 //Roo.log("fire event clicked");
6232 if(this.fireEvent('click', this, e) === false){
6236 if(this.tagtype == 'span'){
6240 //Roo.log(this.href);
6241 var ael = this.el.select('a',true).first();
6244 if(ael && this.animateRef && this.href.indexOf('#') > -1){
6245 //Roo.log(["test:",ael.dom.href.split("#")[0], document.location.toString().split("#")[0]]);
6246 if (ael.dom.href.split("#")[0] != document.location.toString().split("#")[0]) {
6247 return; // ignore... - it's a 'hash' to another page.
6249 Roo.log("NavItem - prevent Default?");
6251 this.scrollToElement(e);
6255 var p = this.parent();
6257 if (['tabs','pills'].indexOf(p.type)!==-1) {
6258 if (typeof(p.setActiveItem) !== 'undefined') {
6259 p.setActiveItem(this);
6263 // if parent is a navbarheader....- and link is probably a '#' page ref.. then remove the expanded menu.
6264 if (p.parentType == 'NavHeaderbar' && !this.menu) {
6265 // remove the collapsed menu expand...
6266 p.parent().el.select('.roo-navbar-collapse',true).removeClass('in');
6270 isActive: function () {
6273 setActive : function(state, fire, is_was_active)
6275 if (this.active && !state && this.navId) {
6276 this.was_active = true;
6277 var nv = Roo.bootstrap.NavGroup.get(this.navId);
6279 nv.clearWasActive(this);
6283 this.active = state;
6286 this.el.removeClass('active');
6287 this.navLink ? this.navLink.removeClass('active') : false;
6288 } else if (!this.el.hasClass('active')) {
6290 this.el.addClass('active');
6291 if (Roo.bootstrap.version == 4 && this.navLink ) {
6292 this.navLink.addClass('active');
6297 this.fireEvent('changed', this, state);
6300 // show a panel if it's registered and related..
6302 if (!this.navId || !this.tabId || !state || is_was_active) {
6306 var tg = Roo.bootstrap.TabGroup.get(this.navId);
6310 var pan = tg.getPanelByName(this.tabId);
6314 // if we can not flip to new panel - go back to old nav highlight..
6315 if (false == tg.showPanel(pan)) {
6316 var nv = Roo.bootstrap.NavGroup.get(this.navId);
6318 var onav = nv.getWasActive();
6320 onav.setActive(true, false, true);
6329 // this should not be here...
6330 setDisabled : function(state)
6332 this.disabled = state;
6334 this.el.removeClass('disabled');
6335 } else if (!this.el.hasClass('disabled')) {
6336 this.el.addClass('disabled');
6342 * Fetch the element to display the tooltip on.
6343 * @return {Roo.Element} defaults to this.el
6345 tooltipEl : function()
6347 return this.el.select('' + this.tagtype + '', true).first();
6350 scrollToElement : function(e)
6352 var c = document.body;
6355 * Firefox / IE places the overflow at the html level, unless specifically styled to behave differently.
6357 if(Roo.isFirefox || Roo.isIE || Roo.isIE11){
6358 c = document.documentElement;
6361 var target = Roo.get(c).select('a[name=' + this.href.split('#')[1] +']', true).first();
6367 var o = target.calcOffsetsTo(c);
6374 this.fireEvent('scrollto', this, options, e);
6376 Roo.get(c).scrollTo('top', options.value, true);
6389 * <span> icon </span>
6390 * <span> text </span>
6391 * <span>badge </span>
6395 * @class Roo.bootstrap.NavSidebarItem
6396 * @extends Roo.bootstrap.NavItem
6397 * Bootstrap Navbar.NavSidebarItem class
6398 * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
6399 * {Boolean} open is the menu open
6400 * {Boolean} buttonView use button as the tigger el rather that a (default false)
6401 * {String} buttonWeight (default|primary|success|info|warning|danger)the extra classes for the button
6402 * {String} buttonSize (sm|md|lg)the extra classes for the button
6403 * {Boolean} showArrow show arrow next to the text (default true)
6405 * Create a new Navbar Button
6406 * @param {Object} config The config object
6408 Roo.bootstrap.NavSidebarItem = function(config){
6409 Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this, config);
6414 * The raw click event for the entire grid.
6415 * @param {Roo.EventObject} e
6420 * Fires when the active item active state changes
6421 * @param {Roo.bootstrap.NavSidebarItem} this
6422 * @param {boolean} state the new state
6430 Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem, {
6432 badgeWeight : 'default',
6438 buttonWeight : 'default',
6444 getAutoCreate : function(){
6449 href : this.href || '#',
6455 if(this.buttonView){
6458 href : this.href || '#',
6459 cls: 'btn btn-' + this.buttonWeight + ' btn-' + this.buttonSize + 'roo-button-dropdown-toggle',
6472 cfg.cls += ' active';
6475 if (this.disabled) {
6476 cfg.cls += ' disabled';
6479 cfg.cls += ' open x-open';
6482 if (this.glyphicon || this.icon) {
6483 var c = this.glyphicon ? ('glyphicon glyphicon-'+this.glyphicon) : this.icon;
6484 a.cn.push({ tag : 'i', cls : c }) ;
6487 if(!this.buttonView){
6490 html : this.html || ''
6497 if (this.badge !== '') {
6498 a.cn.push({ tag: 'span', cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge });
6504 a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
6507 a.cls += ' dropdown-toggle treeview' ;
6513 initEvents : function()
6515 if (typeof (this.menu) != 'undefined') {
6516 this.menu.parentType = this.xtype;
6517 this.menu.triggerEl = this.el;
6518 this.menu = this.addxtype(Roo.apply({}, this.menu));
6521 this.el.on('click', this.onClick, this);
6523 if(this.badge !== ''){
6524 this.badgeEl = this.el.select('.badge', true).first().setVisibilityMode(Roo.Element.DISPLAY);
6529 onClick : function(e)
6536 if(this.preventDefault){
6540 this.fireEvent('click', this, e);
6543 disable : function()
6545 this.setDisabled(true);
6550 this.setDisabled(false);
6553 setDisabled : function(state)
6555 if(this.disabled == state){
6559 this.disabled = state;
6562 this.el.addClass('disabled');
6566 this.el.removeClass('disabled');
6571 setActive : function(state)
6573 if(this.active == state){
6577 this.active = state;
6580 this.el.addClass('active');
6584 this.el.removeClass('active');
6589 isActive: function ()
6594 setBadge : function(str)
6600 this.badgeEl.dom.innerHTML = str;
6615 Roo.namespace('Roo.bootstrap.breadcrumb');
6619 * @class Roo.bootstrap.breadcrumb.Nav
6620 * @extends Roo.bootstrap.Component
6621 * Bootstrap Breadcrumb Nav Class
6623 * @children Roo.bootstrap.breadcrumb.Item
6626 * Create a new breadcrumb.Nav
6627 * @param {Object} config The config object
6631 Roo.bootstrap.breadcrumb.Nav = function(config){
6632 Roo.bootstrap.breadcrumb.Nav.superclass.constructor.call(this, config);
6637 Roo.extend(Roo.bootstrap.breadcrumb.Nav, Roo.bootstrap.Component, {
6639 getAutoCreate : function()
6656 initEvents: function()
6658 this.olEl = this.el.select('ol',true).first();
6660 getChildContainer : function()
6676 * @class Roo.bootstrap.breadcrumb.Nav
6677 * @extends Roo.bootstrap.Component
6678 * Bootstrap Breadcrumb Nav Class
6680 * @children Roo.bootstrap.breadcrumb.Component
6681 * @cfg {String} html the content of the link.
6682 * @cfg {String} href where it links to if '#' is used the link will be handled by onClick.
6683 * @cfg {Boolean} active is it active
6687 * Create a new breadcrumb.Nav
6688 * @param {Object} config The config object
6691 Roo.bootstrap.breadcrumb.Item = function(config){
6692 Roo.bootstrap.breadcrumb.Item.superclass.constructor.call(this, config);
6697 * The img click event for the img.
6698 * @param {Roo.EventObject} e
6705 Roo.extend(Roo.bootstrap.breadcrumb.Item, Roo.bootstrap.Component, {
6710 getAutoCreate : function()
6715 cls : 'breadcrumb-item' + (this.active ? ' active' : '')
6717 if (this.href !== false) {
6724 cfg.html = this.html;
6730 initEvents: function()
6733 this.el.select('a', true).first().on('click',this.onClick, this)
6737 onClick : function(e)
6740 this.fireEvent('click',this, e);
6753 * @class Roo.bootstrap.Row
6754 * @extends Roo.bootstrap.Component
6755 * Bootstrap Row class (contains columns...)
6759 * @param {Object} config The config object
6762 Roo.bootstrap.Row = function(config){
6763 Roo.bootstrap.Row.superclass.constructor.call(this, config);
6766 Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component, {
6768 getAutoCreate : function(){
6787 * @class Roo.bootstrap.Pagination
6788 * @extends Roo.bootstrap.Component
6789 * Bootstrap Pagination class
6790 * @cfg {String} size xs | sm | md | lg
6791 * @cfg {Boolean} inverse false | true
6794 * Create a new Pagination
6795 * @param {Object} config The config object
6798 Roo.bootstrap.Pagination = function(config){
6799 Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
6802 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component, {
6808 getAutoCreate : function(){
6814 cfg.cls += ' inverse';
6820 cfg.cls += " " + this.cls;
6838 * @class Roo.bootstrap.PaginationItem
6839 * @extends Roo.bootstrap.Component
6840 * Bootstrap PaginationItem class
6841 * @cfg {String} html text
6842 * @cfg {String} href the link
6843 * @cfg {Boolean} preventDefault (true | false) default true
6844 * @cfg {Boolean} active (true | false) default false
6845 * @cfg {Boolean} disabled default false
6849 * Create a new PaginationItem
6850 * @param {Object} config The config object
6854 Roo.bootstrap.PaginationItem = function(config){
6855 Roo.bootstrap.PaginationItem.superclass.constructor.call(this, config);
6860 * The raw click event for the entire grid.
6861 * @param {Roo.EventObject} e
6867 Roo.extend(Roo.bootstrap.PaginationItem, Roo.bootstrap.Component, {
6871 preventDefault: true,
6876 getAutoCreate : function(){
6882 href : this.href ? this.href : '#',
6883 html : this.html ? this.html : ''
6893 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' disabled' : 'disabled';
6897 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' active' : 'active';
6903 initEvents: function() {
6905 this.el.on('click', this.onClick, this);
6908 onClick : function(e)
6910 Roo.log('PaginationItem on click ');
6911 if(this.preventDefault){
6919 this.fireEvent('click', this, e);
6935 * @class Roo.bootstrap.Slider
6936 * @extends Roo.bootstrap.Component
6937 * Bootstrap Slider class
6940 * Create a new Slider
6941 * @param {Object} config The config object
6944 Roo.bootstrap.Slider = function(config){
6945 Roo.bootstrap.Slider.superclass.constructor.call(this, config);
6948 Roo.extend(Roo.bootstrap.Slider, Roo.bootstrap.Component, {
6950 getAutoCreate : function(){
6954 cls: 'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',
6958 cls: 'ui-slider-handle ui-state-default ui-corner-all'
6970 * Ext JS Library 1.1.1
6971 * Copyright(c) 2006-2007, Ext JS, LLC.
6973 * Originally Released Under LGPL - original licence link has changed is not relivant.
6976 * <script type="text/javascript">
6981 * @class Roo.grid.ColumnModel
6982 * @extends Roo.util.Observable
6983 * This is the default implementation of a ColumnModel used by the Grid. It defines
6984 * the columns in the grid.
6987 var colModel = new Roo.grid.ColumnModel([
6988 {header: "Ticker", width: 60, sortable: true, locked: true},
6989 {header: "Company Name", width: 150, sortable: true},
6990 {header: "Market Cap.", width: 100, sortable: true},
6991 {header: "$ Sales", width: 100, sortable: true, renderer: money},
6992 {header: "Employees", width: 100, sortable: true, resizable: false}
6997 * The config options listed for this class are options which may appear in each
6998 * individual column definition.
6999 * <br/>RooJS Fix - column id's are not sequential but use Roo.id() - fixes bugs with layouts.
7001 * @param {Object} config An Array of column config objects. See this class's
7002 * config objects for details.
7004 Roo.grid.ColumnModel = function(config){
7006 * The config passed into the constructor
7008 this.config = config;
7011 // if no id, create one
7012 // if the column does not have a dataIndex mapping,
7013 // map it to the order it is in the config
7014 for(var i = 0, len = config.length; i < len; i++){
7016 if(typeof c.dataIndex == "undefined"){
7019 if(typeof c.renderer == "string"){
7020 c.renderer = Roo.util.Format[c.renderer];
7022 if(typeof c.id == "undefined"){
7025 if(c.editor && c.editor.xtype){
7026 c.editor = Roo.factory(c.editor, Roo.grid);
7028 if(c.editor && c.editor.isFormField){
7029 c.editor = new Roo.grid.GridEditor(c.editor);
7031 this.lookup[c.id] = c;
7035 * The width of columns which have no width specified (defaults to 100)
7038 this.defaultWidth = 100;
7041 * Default sortable of columns which have no sortable specified (defaults to false)
7044 this.defaultSortable = false;
7048 * @event widthchange
7049 * Fires when the width of a column changes.
7050 * @param {ColumnModel} this
7051 * @param {Number} columnIndex The column index
7052 * @param {Number} newWidth The new width
7054 "widthchange": true,
7056 * @event headerchange
7057 * Fires when the text of a header changes.
7058 * @param {ColumnModel} this
7059 * @param {Number} columnIndex The column index
7060 * @param {Number} newText The new header text
7062 "headerchange": true,
7064 * @event hiddenchange
7065 * Fires when a column is hidden or "unhidden".
7066 * @param {ColumnModel} this
7067 * @param {Number} columnIndex The column index
7068 * @param {Boolean} hidden true if hidden, false otherwise
7070 "hiddenchange": true,
7072 * @event columnmoved
7073 * Fires when a column is moved.
7074 * @param {ColumnModel} this
7075 * @param {Number} oldIndex
7076 * @param {Number} newIndex
7078 "columnmoved" : true,
7080 * @event columlockchange
7081 * Fires when a column's locked state is changed
7082 * @param {ColumnModel} this
7083 * @param {Number} colIndex
7084 * @param {Boolean} locked true if locked
7086 "columnlockchange" : true
7088 Roo.grid.ColumnModel.superclass.constructor.call(this);
7090 Roo.extend(Roo.grid.ColumnModel, Roo.util.Observable, {
7092 * @cfg {String} header The header text to display in the Grid view.
7095 * @cfg {String} dataIndex (Optional) The name of the field in the grid's {@link Roo.data.Store}'s
7096 * {@link Roo.data.Record} definition from which to draw the column's value. If not
7097 * specified, the column's index is used as an index into the Record's data Array.
7100 * @cfg {Number} width (Optional) The initial width in pixels of the column. Using this
7101 * instead of {@link Roo.grid.Grid#autoSizeColumns} is more efficient.
7104 * @cfg {Boolean} sortable (Optional) True if sorting is to be allowed on this column.
7105 * Defaults to the value of the {@link #defaultSortable} property.
7106 * Whether local/remote sorting is used is specified in {@link Roo.data.Store#remoteSort}.
7109 * @cfg {Boolean} locked (Optional) True to lock the column in place while scrolling the Grid. Defaults to false.
7112 * @cfg {Boolean} fixed (Optional) True if the column width cannot be changed. Defaults to false.
7115 * @cfg {Boolean} resizable (Optional) False to disable column resizing. Defaults to true.
7118 * @cfg {Boolean} hidden (Optional) True to hide the column. Defaults to false.
7121 * @cfg {Function} renderer (Optional) A function used to generate HTML markup for a cell
7122 * given the cell's data value. See {@link #setRenderer}. If not specified, the
7123 * default renderer returns the escaped data value. If an object is returned (bootstrap only)
7124 * then it is treated as a Roo Component object instance, and it is rendered after the initial row is rendered
7127 * @cfg {Roo.grid.GridEditor} editor (Optional) For grid editors - returns the grid editor
7130 * @cfg {String} align (Optional) Set the CSS text-align property of the column. Defaults to undefined.
7133 * @cfg {String} valign (Optional) Set the CSS vertical-align property of the column (eg. middle, top, bottom etc). Defaults to undefined.
7136 * @cfg {String} cursor (Optional)
7139 * @cfg {String} tooltip (Optional)
7142 * @cfg {Number} xs (Optional)
7145 * @cfg {Number} sm (Optional)
7148 * @cfg {Number} md (Optional)
7151 * @cfg {Number} lg (Optional)
7154 * Returns the id of the column at the specified index.
7155 * @param {Number} index The column index
7156 * @return {String} the id
7158 getColumnId : function(index){
7159 return this.config[index].id;
7163 * Returns the column for a specified id.
7164 * @param {String} id The column id
7165 * @return {Object} the column
7167 getColumnById : function(id){
7168 return this.lookup[id];
7173 * Returns the column for a specified dataIndex.
7174 * @param {String} dataIndex The column dataIndex
7175 * @return {Object|Boolean} the column or false if not found
7177 getColumnByDataIndex: function(dataIndex){
7178 var index = this.findColumnIndex(dataIndex);
7179 return index > -1 ? this.config[index] : false;
7183 * Returns the index for a specified column id.
7184 * @param {String} id The column id
7185 * @return {Number} the index, or -1 if not found
7187 getIndexById : function(id){
7188 for(var i = 0, len = this.config.length; i < len; i++){
7189 if(this.config[i].id == id){
7197 * Returns the index for a specified column dataIndex.
7198 * @param {String} dataIndex The column dataIndex
7199 * @return {Number} the index, or -1 if not found
7202 findColumnIndex : function(dataIndex){
7203 for(var i = 0, len = this.config.length; i < len; i++){
7204 if(this.config[i].dataIndex == dataIndex){
7212 moveColumn : function(oldIndex, newIndex){
7213 var c = this.config[oldIndex];
7214 this.config.splice(oldIndex, 1);
7215 this.config.splice(newIndex, 0, c);
7216 this.dataMap = null;
7217 this.fireEvent("columnmoved", this, oldIndex, newIndex);
7220 isLocked : function(colIndex){
7221 return this.config[colIndex].locked === true;
7224 setLocked : function(colIndex, value, suppressEvent){
7225 if(this.isLocked(colIndex) == value){
7228 this.config[colIndex].locked = value;
7230 this.fireEvent("columnlockchange", this, colIndex, value);
7234 getTotalLockedWidth : function(){
7236 for(var i = 0; i < this.config.length; i++){
7237 if(this.isLocked(i) && !this.isHidden(i)){
7238 this.totalWidth += this.getColumnWidth(i);
7244 getLockedCount : function(){
7245 for(var i = 0, len = this.config.length; i < len; i++){
7246 if(!this.isLocked(i)){
7251 return this.config.length;
7255 * Returns the number of columns.
7258 getColumnCount : function(visibleOnly){
7259 if(visibleOnly === true){
7261 for(var i = 0, len = this.config.length; i < len; i++){
7262 if(!this.isHidden(i)){
7268 return this.config.length;
7272 * Returns the column configs that return true by the passed function that is called with (columnConfig, index)
7273 * @param {Function} fn
7274 * @param {Object} scope (optional)
7275 * @return {Array} result
7277 getColumnsBy : function(fn, scope){
7279 for(var i = 0, len = this.config.length; i < len; i++){
7280 var c = this.config[i];
7281 if(fn.call(scope||this, c, i) === true){
7289 * Returns true if the specified column is sortable.
7290 * @param {Number} col The column index
7293 isSortable : function(col){
7294 if(typeof this.config[col].sortable == "undefined"){
7295 return this.defaultSortable;
7297 return this.config[col].sortable;
7301 * Returns the rendering (formatting) function defined for the column.
7302 * @param {Number} col The column index.
7303 * @return {Function} The function used to render the cell. See {@link #setRenderer}.
7305 getRenderer : function(col){
7306 if(!this.config[col].renderer){
7307 return Roo.grid.ColumnModel.defaultRenderer;
7309 return this.config[col].renderer;
7313 * Sets the rendering (formatting) function for a column.
7314 * @param {Number} col The column index
7315 * @param {Function} fn The function to use to process the cell's raw data
7316 * to return HTML markup for the grid view. The render function is called with
7317 * the following parameters:<ul>
7318 * <li>Data value.</li>
7319 * <li>Cell metadata. An object in which you may set the following attributes:<ul>
7320 * <li>css A CSS style string to apply to the table cell.</li>
7321 * <li>attr An HTML attribute definition string to apply to the data container element <i>within</i> the table cell.</li></ul>
7322 * <li>The {@link Roo.data.Record} from which the data was extracted.</li>
7323 * <li>Row index</li>
7324 * <li>Column index</li>
7325 * <li>The {@link Roo.data.Store} object from which the Record was extracted</li></ul>
7327 setRenderer : function(col, fn){
7328 this.config[col].renderer = fn;
7332 * Returns the width for the specified column.
7333 * @param {Number} col The column index
7336 getColumnWidth : function(col){
7337 return this.config[col].width * 1 || this.defaultWidth;
7341 * Sets the width for a column.
7342 * @param {Number} col The column index
7343 * @param {Number} width The new width
7345 setColumnWidth : function(col, width, suppressEvent){
7346 this.config[col].width = width;
7347 this.totalWidth = null;
7349 this.fireEvent("widthchange", this, col, width);
7354 * Returns the total width of all columns.
7355 * @param {Boolean} includeHidden True to include hidden column widths
7358 getTotalWidth : function(includeHidden){
7359 if(!this.totalWidth){
7360 this.totalWidth = 0;
7361 for(var i = 0, len = this.config.length; i < len; i++){
7362 if(includeHidden || !this.isHidden(i)){
7363 this.totalWidth += this.getColumnWidth(i);
7367 return this.totalWidth;
7371 * Returns the header for the specified column.
7372 * @param {Number} col The column index
7375 getColumnHeader : function(col){
7376 return this.config[col].header;
7380 * Sets the header for a column.
7381 * @param {Number} col The column index
7382 * @param {String} header The new header
7384 setColumnHeader : function(col, header){
7385 this.config[col].header = header;
7386 this.fireEvent("headerchange", this, col, header);
7390 * Returns the tooltip for the specified column.
7391 * @param {Number} col The column index
7394 getColumnTooltip : function(col){
7395 return this.config[col].tooltip;
7398 * Sets the tooltip for a column.
7399 * @param {Number} col The column index
7400 * @param {String} tooltip The new tooltip
7402 setColumnTooltip : function(col, tooltip){
7403 this.config[col].tooltip = tooltip;
7407 * Returns the dataIndex for the specified column.
7408 * @param {Number} col The column index
7411 getDataIndex : function(col){
7412 return this.config[col].dataIndex;
7416 * Sets the dataIndex for a column.
7417 * @param {Number} col The column index
7418 * @param {Number} dataIndex The new dataIndex
7420 setDataIndex : function(col, dataIndex){
7421 this.config[col].dataIndex = dataIndex;
7427 * Returns true if the cell is editable.
7428 * @param {Number} colIndex The column index
7429 * @param {Number} rowIndex The row index - this is nto actually used..?
7432 isCellEditable : function(colIndex, rowIndex){
7433 return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
7437 * Returns the editor defined for the cell/column.
7438 * return false or null to disable editing.
7439 * @param {Number} colIndex The column index
7440 * @param {Number} rowIndex The row index
7443 getCellEditor : function(colIndex, rowIndex){
7444 return this.config[colIndex].editor;
7448 * Sets if a column is editable.
7449 * @param {Number} col The column index
7450 * @param {Boolean} editable True if the column is editable
7452 setEditable : function(col, editable){
7453 this.config[col].editable = editable;
7458 * Returns true if the column is hidden.
7459 * @param {Number} colIndex The column index
7462 isHidden : function(colIndex){
7463 return this.config[colIndex].hidden;
7468 * Returns true if the column width cannot be changed
7470 isFixed : function(colIndex){
7471 return this.config[colIndex].fixed;
7475 * Returns true if the column can be resized
7478 isResizable : function(colIndex){
7479 return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
7482 * Sets if a column is hidden.
7483 * @param {Number} colIndex The column index
7484 * @param {Boolean} hidden True if the column is hidden
7486 setHidden : function(colIndex, hidden){
7487 this.config[colIndex].hidden = hidden;
7488 this.totalWidth = null;
7489 this.fireEvent("hiddenchange", this, colIndex, hidden);
7493 * Sets the editor for a column.
7494 * @param {Number} col The column index
7495 * @param {Object} editor The editor object
7497 setEditor : function(col, editor){
7498 this.config[col].editor = editor;
7502 Roo.grid.ColumnModel.defaultRenderer = function(value)
7504 if(typeof value == "object") {
7507 if(typeof value == "string" && value.length < 1){
7511 return String.format("{0}", value);
7514 // Alias for backwards compatibility
7515 Roo.grid.DefaultColumnModel = Roo.grid.ColumnModel;
7518 * Ext JS Library 1.1.1
7519 * Copyright(c) 2006-2007, Ext JS, LLC.
7521 * Originally Released Under LGPL - original licence link has changed is not relivant.
7524 * <script type="text/javascript">
7528 * @class Roo.LoadMask
7529 * A simple utility class for generically masking elements while loading data. If the element being masked has
7530 * an underlying {@link Roo.data.Store}, the masking will be automatically synchronized with the store's loading
7531 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
7532 * element's UpdateManager load indicator and will be destroyed after the initial load.
7534 * Create a new LoadMask
7535 * @param {String/HTMLElement/Roo.Element} el The element or DOM node, or its id
7536 * @param {Object} config The config object
7538 Roo.LoadMask = function(el, config){
7539 this.el = Roo.get(el);
7540 Roo.apply(this, config);
7542 this.store.on('beforeload', this.onBeforeLoad, this);
7543 this.store.on('load', this.onLoad, this);
7544 this.store.on('loadexception', this.onLoadException, this);
7545 this.removeMask = false;
7547 var um = this.el.getUpdateManager();
7548 um.showLoadIndicator = false; // disable the default indicator
7549 um.on('beforeupdate', this.onBeforeLoad, this);
7550 um.on('update', this.onLoad, this);
7551 um.on('failure', this.onLoad, this);
7552 this.removeMask = true;
7556 Roo.LoadMask.prototype = {
7558 * @cfg {Boolean} removeMask
7559 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
7560 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
7564 * The text to display in a centered loading message box (defaults to 'Loading...')
7568 * @cfg {String} msgCls
7569 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
7571 msgCls : 'x-mask-loading',
7574 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
7580 * Disables the mask to prevent it from being displayed
7582 disable : function(){
7583 this.disabled = true;
7587 * Enables the mask so that it can be displayed
7589 enable : function(){
7590 this.disabled = false;
7593 onLoadException : function()
7597 if (typeof(arguments[3]) != 'undefined') {
7598 Roo.MessageBox.alert("Error loading",arguments[3]);
7602 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
7603 Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
7610 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
7615 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
7619 onBeforeLoad : function(){
7621 (function() { this.el.mask(this.msg, this.msgCls); }).defer(50, this);
7626 destroy : function(){
7628 this.store.un('beforeload', this.onBeforeLoad, this);
7629 this.store.un('load', this.onLoad, this);
7630 this.store.un('loadexception', this.onLoadException, this);
7632 var um = this.el.getUpdateManager();
7633 um.un('beforeupdate', this.onBeforeLoad, this);
7634 um.un('update', this.onLoad, this);
7635 um.un('failure', this.onLoad, this);
7646 * @class Roo.bootstrap.Table
7647 * @extends Roo.bootstrap.Component
7648 * Bootstrap Table class
7649 * @cfg {String} cls table class
7650 * @cfg {String} align (left|center|right) Specifies the alignment of a table according to surrounding text
7651 * @cfg {String} bgcolor Specifies the background color for a table
7652 * @cfg {Number} border Specifies whether the table cells should have borders or not
7653 * @cfg {Number} cellpadding Specifies the space between the cell wall and the cell content
7654 * @cfg {Number} cellspacing Specifies the space between cells
7655 * @cfg {String} frame Specifies which parts of the outside borders that should be visible
7656 * @cfg {String} rules Specifies which parts of the inside borders that should be visible
7657 * @cfg {String} sortable Specifies that the table should be sortable
7658 * @cfg {String} summary Specifies a summary of the content of a table
7659 * @cfg {Number} width Specifies the width of a table
7660 * @cfg {String} layout table layout (auto | fixed | initial | inherit)
7662 * @cfg {boolean} striped Should the rows be alternative striped
7663 * @cfg {boolean} bordered Add borders to the table
7664 * @cfg {boolean} hover Add hover highlighting
7665 * @cfg {boolean} condensed Format condensed
7666 * @cfg {boolean} responsive Format condensed
7667 * @cfg {Boolean} loadMask (true|false) default false
7668 * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
7669 * @cfg {Boolean} headerShow (true|false) generate thead, default true
7670 * @cfg {Boolean} rowSelection (true|false) default false
7671 * @cfg {Boolean} cellSelection (true|false) default false
7672 * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header
7673 * @cfg {Roo.bootstrap.PagingToolbar} footer a paging toolbar
7674 * @cfg {Boolean} lazyLoad auto load data while scrolling to the end (default false)
7675 * @cfg {Boolean} auto_hide_footer auto hide footer if only one page (default false)
7679 * Create a new Table
7680 * @param {Object} config The config object
7683 Roo.bootstrap.Table = function(config){
7684 Roo.bootstrap.Table.superclass.constructor.call(this, config);
7689 this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
7690 this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
7691 this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
7692 this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
7694 this.sm = this.sm || {xtype: 'RowSelectionModel'};
7696 this.sm.grid = this;
7697 this.selModel = Roo.factory(this.sm, Roo.bootstrap.Table);
7698 this.sm = this.selModel;
7699 this.sm.xmodule = this.xmodule || false;
7702 if (this.cm && typeof(this.cm.config) == 'undefined') {
7703 this.colModel = new Roo.grid.ColumnModel(this.cm);
7704 this.cm = this.colModel;
7705 this.cm.xmodule = this.xmodule || false;
7708 this.store= Roo.factory(this.store, Roo.data);
7709 this.ds = this.store;
7710 this.ds.xmodule = this.xmodule || false;
7713 if (this.footer && this.store) {
7714 this.footer.dataSource = this.ds;
7715 this.footer = Roo.factory(this.footer);
7722 * Fires when a cell is clicked
7723 * @param {Roo.bootstrap.Table} this
7724 * @param {Roo.Element} el
7725 * @param {Number} rowIndex
7726 * @param {Number} columnIndex
7727 * @param {Roo.EventObject} e
7731 * @event celldblclick
7732 * Fires when a cell is double clicked
7733 * @param {Roo.bootstrap.Table} this
7734 * @param {Roo.Element} el
7735 * @param {Number} rowIndex
7736 * @param {Number} columnIndex
7737 * @param {Roo.EventObject} e
7739 "celldblclick" : true,
7742 * Fires when a row is clicked
7743 * @param {Roo.bootstrap.Table} this
7744 * @param {Roo.Element} el
7745 * @param {Number} rowIndex
7746 * @param {Roo.EventObject} e
7750 * @event rowdblclick
7751 * Fires when a row is double clicked
7752 * @param {Roo.bootstrap.Table} this
7753 * @param {Roo.Element} el
7754 * @param {Number} rowIndex
7755 * @param {Roo.EventObject} e
7757 "rowdblclick" : true,
7760 * Fires when a mouseover occur
7761 * @param {Roo.bootstrap.Table} this
7762 * @param {Roo.Element} el
7763 * @param {Number} rowIndex
7764 * @param {Number} columnIndex
7765 * @param {Roo.EventObject} e
7770 * Fires when a mouseout occur
7771 * @param {Roo.bootstrap.Table} this
7772 * @param {Roo.Element} el
7773 * @param {Number} rowIndex
7774 * @param {Number} columnIndex
7775 * @param {Roo.EventObject} e
7780 * Fires when a row is rendered, so you can change add a style to it.
7781 * @param {Roo.bootstrap.Table} this
7782 * @param {Object} rowcfg contains record rowIndex colIndex and rowClass - set rowClass to add a style.
7786 * @event rowsrendered
7787 * Fires when all the rows have been rendered
7788 * @param {Roo.bootstrap.Table} this
7790 'rowsrendered' : true,
7792 * @event contextmenu
7793 * The raw contextmenu event for the entire grid.
7794 * @param {Roo.EventObject} e
7796 "contextmenu" : true,
7798 * @event rowcontextmenu
7799 * Fires when a row is right clicked
7800 * @param {Roo.bootstrap.Table} this
7801 * @param {Number} rowIndex
7802 * @param {Roo.EventObject} e
7804 "rowcontextmenu" : true,
7806 * @event cellcontextmenu
7807 * Fires when a cell is right clicked
7808 * @param {Roo.bootstrap.Table} this
7809 * @param {Number} rowIndex
7810 * @param {Number} cellIndex
7811 * @param {Roo.EventObject} e
7813 "cellcontextmenu" : true,
7815 * @event headercontextmenu
7816 * Fires when a header is right clicked
7817 * @param {Roo.bootstrap.Table} this
7818 * @param {Number} columnIndex
7819 * @param {Roo.EventObject} e
7821 "headercontextmenu" : true
7825 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
7851 rowSelection : false,
7852 cellSelection : false,
7855 // Roo.Element - the tbody
7857 // Roo.Element - thead element
7860 container: false, // used by gridpanel...
7866 auto_hide_footer : false,
7868 getAutoCreate : function()
7870 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
7877 if (this.scrollBody) {
7878 cfg.cls += ' table-body-fixed';
7881 cfg.cls += ' table-striped';
7885 cfg.cls += ' table-hover';
7887 if (this.bordered) {
7888 cfg.cls += ' table-bordered';
7890 if (this.condensed) {
7891 cfg.cls += ' table-condensed';
7893 if (this.responsive) {
7894 cfg.cls += ' table-responsive';
7898 cfg.cls+= ' ' +this.cls;
7901 // this lot should be simplifed...
7914 ].forEach(function(k) {
7922 cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
7925 if(this.store || this.cm){
7926 if(this.headerShow){
7927 cfg.cn.push(this.renderHeader());
7930 cfg.cn.push(this.renderBody());
7932 if(this.footerShow){
7933 cfg.cn.push(this.renderFooter());
7935 // where does this come from?
7936 //cfg.cls+= ' TableGrid';
7939 return { cn : [ cfg ] };
7942 initEvents : function()
7944 if(!this.store || !this.cm){
7947 if (this.selModel) {
7948 this.selModel.initEvents();
7952 //Roo.log('initEvents with ds!!!!');
7954 this.mainBody = this.el.select('tbody', true).first();
7955 this.mainHead = this.el.select('thead', true).first();
7956 this.mainFoot = this.el.select('tfoot', true).first();
7962 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
7963 e.on('click', _this.sort, _this);
7966 this.mainBody.on("click", this.onClick, this);
7967 this.mainBody.on("dblclick", this.onDblClick, this);
7969 // why is this done????? = it breaks dialogs??
7970 //this.parent().el.setStyle('position', 'relative');
7974 this.footer.parentId = this.id;
7975 this.footer.onRender(this.el.select('tfoot tr td').first(), null);
7978 this.el.select('tfoot tr td').first().addClass('hide');
7983 this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
7986 this.store.on('load', this.onLoad, this);
7987 this.store.on('beforeload', this.onBeforeLoad, this);
7988 this.store.on('update', this.onUpdate, this);
7989 this.store.on('add', this.onAdd, this);
7990 this.store.on("clear", this.clear, this);
7992 this.el.on("contextmenu", this.onContextMenu, this);
7994 this.mainBody.on('scroll', this.onBodyScroll, this);
7996 this.cm.on("headerchange", this.onHeaderChange, this);
7998 this.cm.on("hiddenchange", this.onHiddenChange, this, arguments);
8002 onContextMenu : function(e, t)
8004 this.processEvent("contextmenu", e);
8007 processEvent : function(name, e)
8009 if (name != 'touchstart' ) {
8010 this.fireEvent(name, e);
8013 var t = e.getTarget();
8015 var cell = Roo.get(t);
8021 if(cell.findParent('tfoot', false, true)){
8025 if(cell.findParent('thead', false, true)){
8027 if(e.getTarget().nodeName.toLowerCase() != 'th'){
8028 cell = Roo.get(t).findParent('th', false, true);
8030 Roo.log("failed to find th in thead?");
8031 Roo.log(e.getTarget());
8036 var cellIndex = cell.dom.cellIndex;
8038 var ename = name == 'touchstart' ? 'click' : name;
8039 this.fireEvent("header" + ename, this, cellIndex, e);
8044 if(e.getTarget().nodeName.toLowerCase() != 'td'){
8045 cell = Roo.get(t).findParent('td', false, true);
8047 Roo.log("failed to find th in tbody?");
8048 Roo.log(e.getTarget());
8053 var row = cell.findParent('tr', false, true);
8054 var cellIndex = cell.dom.cellIndex;
8055 var rowIndex = row.dom.rowIndex - 1;
8059 this.fireEvent("row" + name, this, rowIndex, e);
8063 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
8069 onMouseover : function(e, el)
8071 var cell = Roo.get(el);
8077 if(e.getTarget().nodeName.toLowerCase() != 'td'){
8078 cell = cell.findParent('td', false, true);
8081 var row = cell.findParent('tr', false, true);
8082 var cellIndex = cell.dom.cellIndex;
8083 var rowIndex = row.dom.rowIndex - 1; // start from 0
8085 this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
8089 onMouseout : function(e, el)
8091 var cell = Roo.get(el);
8097 if(e.getTarget().nodeName.toLowerCase() != 'td'){
8098 cell = cell.findParent('td', false, true);
8101 var row = cell.findParent('tr', false, true);
8102 var cellIndex = cell.dom.cellIndex;
8103 var rowIndex = row.dom.rowIndex - 1; // start from 0
8105 this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
8109 onClick : function(e, el)
8111 var cell = Roo.get(el);
8113 if(!cell || (!this.cellSelection && !this.rowSelection)){
8117 if(e.getTarget().nodeName.toLowerCase() != 'td'){
8118 cell = cell.findParent('td', false, true);
8121 if(!cell || typeof(cell) == 'undefined'){
8125 var row = cell.findParent('tr', false, true);
8127 if(!row || typeof(row) == 'undefined'){
8131 var cellIndex = cell.dom.cellIndex;
8132 var rowIndex = this.getRowIndex(row);
8134 // why??? - should these not be based on SelectionModel?
8135 if(this.cellSelection){
8136 this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
8139 if(this.rowSelection){
8140 this.fireEvent('rowclick', this, row, rowIndex, e);
8146 onDblClick : function(e,el)
8148 var cell = Roo.get(el);
8150 if(!cell || (!this.cellSelection && !this.rowSelection)){
8154 if(e.getTarget().nodeName.toLowerCase() != 'td'){
8155 cell = cell.findParent('td', false, true);
8158 if(!cell || typeof(cell) == 'undefined'){
8162 var row = cell.findParent('tr', false, true);
8164 if(!row || typeof(row) == 'undefined'){
8168 var cellIndex = cell.dom.cellIndex;
8169 var rowIndex = this.getRowIndex(row);
8171 if(this.cellSelection){
8172 this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
8175 if(this.rowSelection){
8176 this.fireEvent('rowdblclick', this, row, rowIndex, e);
8180 sort : function(e,el)
8182 var col = Roo.get(el);
8184 if(!col.hasClass('sortable')){
8188 var sort = col.attr('sort');
8191 if(col.select('i', true).first().hasClass('glyphicon-arrow-up')){
8195 this.store.sortInfo = {field : sort, direction : dir};
8198 Roo.log("calling footer first");
8199 this.footer.onClick('first');
8202 this.store.load({ params : { start : 0 } });
8206 renderHeader : function()
8214 this.totalWidth = 0;
8216 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
8218 var config = cm.config[i];
8222 cls : 'x-hcol-' + i,
8224 html: cm.getColumnHeader(i)
8229 if(typeof(config.sortable) != 'undefined' && config.sortable){
8231 c.html = '<i class="glyphicon"></i>' + c.html;
8234 // could use BS4 hidden-..-down
8236 if(typeof(config.lgHeader) != 'undefined'){
8237 hh += '<span class="hidden-xs hidden-sm hidden-md ">' + config.lgHeader + '</span>';
8240 if(typeof(config.mdHeader) != 'undefined'){
8241 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
8244 if(typeof(config.smHeader) != 'undefined'){
8245 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
8248 if(typeof(config.xsHeader) != 'undefined'){
8249 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
8256 if(typeof(config.tooltip) != 'undefined'){
8257 c.tooltip = config.tooltip;
8260 if(typeof(config.colspan) != 'undefined'){
8261 c.colspan = config.colspan;
8264 if(typeof(config.hidden) != 'undefined' && config.hidden){
8265 c.style += ' display:none;';
8268 if(typeof(config.dataIndex) != 'undefined'){
8269 c.sort = config.dataIndex;
8274 if(typeof(config.align) != 'undefined' && config.align.length){
8275 c.style += ' text-align:' + config.align + ';';
8278 if(typeof(config.width) != 'undefined'){
8279 c.style += ' width:' + config.width + 'px;';
8280 this.totalWidth += config.width;
8282 this.totalWidth += 100; // assume minimum of 100 per column?
8285 if(typeof(config.cls) != 'undefined'){
8286 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
8289 ['xs','sm','md','lg'].map(function(size){
8291 if(typeof(config[size]) == 'undefined'){
8295 if (!config[size]) { // 0 = hidden
8296 // BS 4 '0' is treated as hide that column and below.
8297 c.cls += ' hidden-' + size + ' hidden' + size + '-down';
8301 c.cls += ' col-' + size + '-' + config[size] + (
8302 size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
8314 renderBody : function()
8324 colspan : this.cm.getColumnCount()
8334 renderFooter : function()
8344 colspan : this.cm.getColumnCount()
8358 // Roo.log('ds onload');
8363 var ds = this.store;
8365 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
8366 e.select('i', true).removeClass(['glyphicon-arrow-up', 'glyphicon-arrow-down']);
8367 if (_this.store.sortInfo) {
8369 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
8370 e.select('i', true).addClass(['glyphicon-arrow-up']);
8373 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
8374 e.select('i', true).addClass(['glyphicon-arrow-down']);
8379 var tbody = this.mainBody;
8381 if(ds.getCount() > 0){
8382 ds.data.each(function(d,rowIndex){
8383 var row = this.renderRow(cm, ds, rowIndex);
8385 tbody.createChild(row);
8389 if(row.cellObjects.length){
8390 Roo.each(row.cellObjects, function(r){
8391 _this.renderCellObject(r);
8398 var tfoot = this.el.select('tfoot', true).first();
8400 if(this.footerShow && this.auto_hide_footer && this.mainFoot){
8402 this.mainFoot.setVisibilityMode(Roo.Element.DISPLAY).hide();
8404 var total = this.ds.getTotalCount();
8406 if(this.footer.pageSize < total){
8407 this.mainFoot.show();
8411 Roo.each(this.el.select('tbody td', true).elements, function(e){
8412 e.on('mouseover', _this.onMouseover, _this);
8415 Roo.each(this.el.select('tbody td', true).elements, function(e){
8416 e.on('mouseout', _this.onMouseout, _this);
8418 this.fireEvent('rowsrendered', this);
8424 onUpdate : function(ds,record)
8426 this.refreshRow(record);
8430 onRemove : function(ds, record, index, isUpdate){
8431 if(isUpdate !== true){
8432 this.fireEvent("beforerowremoved", this, index, record);
8434 var bt = this.mainBody.dom;
8436 var rows = this.el.select('tbody > tr', true).elements;
8438 if(typeof(rows[index]) != 'undefined'){
8439 bt.removeChild(rows[index].dom);
8442 // if(bt.rows[index]){
8443 // bt.removeChild(bt.rows[index]);
8446 if(isUpdate !== true){
8447 //this.stripeRows(index);
8448 //this.syncRowHeights(index, index);
8450 this.fireEvent("rowremoved", this, index, record);
8454 onAdd : function(ds, records, rowIndex)
8456 //Roo.log('on Add called');
8457 // - note this does not handle multiple adding very well..
8458 var bt = this.mainBody.dom;
8459 for (var i =0 ; i < records.length;i++) {
8460 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
8461 //Roo.log(records[i]);
8462 //Roo.log(this.store.getAt(rowIndex+i));
8463 this.insertRow(this.store, rowIndex + i, false);
8470 refreshRow : function(record){
8471 var ds = this.store, index;
8472 if(typeof record == 'number'){
8474 record = ds.getAt(index);
8476 index = ds.indexOf(record);
8478 return; // should not happen - but seems to
8481 this.insertRow(ds, index, true);
8483 this.onRemove(ds, record, index+1, true);
8485 //this.syncRowHeights(index, index);
8487 this.fireEvent("rowupdated", this, index, record);
8490 insertRow : function(dm, rowIndex, isUpdate){
8493 this.fireEvent("beforerowsinserted", this, rowIndex);
8495 //var s = this.getScrollState();
8496 var row = this.renderRow(this.cm, this.store, rowIndex);
8497 // insert before rowIndex..
8498 var e = this.mainBody.createChild(row,this.getRowDom(rowIndex));
8502 if(row.cellObjects.length){
8503 Roo.each(row.cellObjects, function(r){
8504 _this.renderCellObject(r);
8509 this.fireEvent("rowsinserted", this, rowIndex);
8510 //this.syncRowHeights(firstRow, lastRow);
8511 //this.stripeRows(firstRow);
8518 getRowDom : function(rowIndex)
8520 var rows = this.el.select('tbody > tr', true).elements;
8522 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
8525 // returns the object tree for a tr..
8528 renderRow : function(cm, ds, rowIndex)
8530 var d = ds.getAt(rowIndex);
8534 cls : 'x-row-' + rowIndex,
8538 var cellObjects = [];
8540 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
8541 var config = cm.config[i];
8543 var renderer = cm.getRenderer(i);
8547 if(typeof(renderer) !== 'undefined'){
8548 value = renderer(d.data[cm.getDataIndex(i)], false, d);
8550 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
8551 // and are rendered into the cells after the row is rendered - using the id for the element.
8553 if(typeof(value) === 'object'){
8563 rowIndex : rowIndex,
8568 this.fireEvent('rowclass', this, rowcfg);
8572 cls : rowcfg.rowClass + ' x-col-' + i,
8574 html: (typeof(value) === 'object') ? '' : value
8581 if(typeof(config.colspan) != 'undefined'){
8582 td.colspan = config.colspan;
8585 if(typeof(config.hidden) != 'undefined' && config.hidden){
8586 td.style += ' display:none;';
8589 if(typeof(config.align) != 'undefined' && config.align.length){
8590 td.style += ' text-align:' + config.align + ';';
8592 if(typeof(config.valign) != 'undefined' && config.valign.length){
8593 td.style += ' vertical-align:' + config.valign + ';';
8596 if(typeof(config.width) != 'undefined'){
8597 td.style += ' width:' + config.width + 'px;';
8600 if(typeof(config.cursor) != 'undefined'){
8601 td.style += ' cursor:' + config.cursor + ';';
8604 if(typeof(config.cls) != 'undefined'){
8605 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
8608 ['xs','sm','md','lg'].map(function(size){
8610 if(typeof(config[size]) == 'undefined'){
8616 if (!config[size]) { // 0 = hidden
8617 // BS 4 '0' is treated as hide that column and below.
8618 td.cls += ' hidden-' + size + ' hidden' + size + '-down';
8622 td.cls += ' col-' + size + '-' + config[size] + (
8623 size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
8633 row.cellObjects = cellObjects;
8641 onBeforeLoad : function()
8650 this.el.select('tbody', true).first().dom.innerHTML = '';
8653 * Show or hide a row.
8654 * @param {Number} rowIndex to show or hide
8655 * @param {Boolean} state hide
8657 setRowVisibility : function(rowIndex, state)
8659 var bt = this.mainBody.dom;
8661 var rows = this.el.select('tbody > tr', true).elements;
8663 if(typeof(rows[rowIndex]) == 'undefined'){
8666 rows[rowIndex].dom.style.display = state ? '' : 'none';
8670 getSelectionModel : function(){
8672 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
8674 return this.selModel;
8677 * Render the Roo.bootstrap object from renderder
8679 renderCellObject : function(r)
8683 r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
8685 var t = r.cfg.render(r.container);
8688 Roo.each(r.cfg.cn, function(c){
8690 container: t.getChildContainer(),
8693 _this.renderCellObject(child);
8698 getRowIndex : function(row)
8702 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
8713 * Returns the grid's underlying element = used by panel.Grid
8714 * @return {Element} The element
8716 getGridEl : function(){
8720 * Forces a resize - used by panel.Grid
8721 * @return {Element} The element
8723 autoSize : function()
8725 //var ctr = Roo.get(this.container.dom.parentElement);
8726 var ctr = Roo.get(this.el.dom);
8728 var thd = this.getGridEl().select('thead',true).first();
8729 var tbd = this.getGridEl().select('tbody', true).first();
8730 var tfd = this.getGridEl().select('tfoot', true).first();
8732 var cw = ctr.getWidth();
8733 this.getGridEl().select('tfoot tr, tfoot td',true).setWidth(cw);
8737 tbd.setWidth(ctr.getWidth());
8738 // if the body has a max height - and then scrolls - we should perhaps set up the height here
8739 // this needs fixing for various usage - currently only hydra job advers I think..
8741 // ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
8743 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
8746 cw = Math.max(cw, this.totalWidth);
8747 this.getGridEl().select('tbody tr',true).setWidth(cw);
8749 // resize 'expandable coloumn?
8751 return; // we doe not have a view in this design..
8754 onBodyScroll: function()
8756 //Roo.log("body scrolled');" + this.mainBody.dom.scrollLeft);
8758 this.mainHead.setStyle({
8759 'position' : 'relative',
8760 'left': (-1* this.mainBody.dom.scrollLeft) + 'px'
8766 var scrollHeight = this.mainBody.dom.scrollHeight;
8768 var scrollTop = Math.ceil(this.mainBody.getScroll().top);
8770 var height = this.mainBody.getHeight();
8772 if(scrollHeight - height == scrollTop) {
8774 var total = this.ds.getTotalCount();
8776 if(this.footer.cursor + this.footer.pageSize < total){
8778 this.footer.ds.load({
8780 start : this.footer.cursor + this.footer.pageSize,
8781 limit : this.footer.pageSize
8791 onHeaderChange : function()
8793 var header = this.renderHeader();
8794 var table = this.el.select('table', true).first();
8796 this.mainHead.remove();
8797 this.mainHead = table.createChild(header, this.mainBody, false);
8800 onHiddenChange : function(colModel, colIndex, hidden)
8802 var thSelector = '#' + this.id + ' .x-hcol-' + colIndex;
8803 var tdSelector = '#' + this.id + ' .x-col-' + colIndex;
8805 this.CSS.updateRule(thSelector, "display", "");
8806 this.CSS.updateRule(tdSelector, "display", "");
8809 this.CSS.updateRule(thSelector, "display", "none");
8810 this.CSS.updateRule(tdSelector, "display", "none");
8813 this.onHeaderChange();
8817 setColumnWidth: function(col_index, width)
8819 // width = "md-2 xs-2..."
8820 if(!this.colModel.config[col_index]) {
8824 var w = width.split(" ");
8826 var rows = this.el.dom.getElementsByClassName("x-col-"+col_index);
8828 var h_row = this.el.dom.getElementsByClassName("x-hcol-"+col_index);
8831 for(var j = 0; j < w.length; j++) {
8837 var size_cls = w[j].split("-");
8839 if(!Number.isInteger(size_cls[1] * 1)) {
8843 if(!this.colModel.config[col_index][size_cls[0]]) {
8847 if(!h_row[0].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
8851 h_row[0].classList.replace(
8852 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
8853 "col-"+size_cls[0]+"-"+size_cls[1]
8856 for(var i = 0; i < rows.length; i++) {
8858 var size_cls = w[j].split("-");
8860 if(!Number.isInteger(size_cls[1] * 1)) {
8864 if(!this.colModel.config[col_index][size_cls[0]]) {
8868 if(!rows[i].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
8872 rows[i].classList.replace(
8873 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
8874 "col-"+size_cls[0]+"-"+size_cls[1]
8878 this.colModel.config[col_index][size_cls[0]] = size_cls[1];
8893 * @class Roo.bootstrap.TableCell
8894 * @extends Roo.bootstrap.Component
8895 * Bootstrap TableCell class
8896 * @cfg {String} html cell contain text
8897 * @cfg {String} cls cell class
8898 * @cfg {String} tag cell tag (td|th) default td
8899 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
8900 * @cfg {String} align Aligns the content in a cell
8901 * @cfg {String} axis Categorizes cells
8902 * @cfg {String} bgcolor Specifies the background color of a cell
8903 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
8904 * @cfg {Number} colspan Specifies the number of columns a cell should span
8905 * @cfg {String} headers Specifies one or more header cells a cell is related to
8906 * @cfg {Number} height Sets the height of a cell
8907 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
8908 * @cfg {Number} rowspan Sets the number of rows a cell should span
8909 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
8910 * @cfg {String} valign Vertical aligns the content in a cell
8911 * @cfg {Number} width Specifies the width of a cell
8914 * Create a new TableCell
8915 * @param {Object} config The config object
8918 Roo.bootstrap.TableCell = function(config){
8919 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
8922 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
8942 getAutoCreate : function(){
8943 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
8963 cfg.align=this.align
8969 cfg.bgcolor=this.bgcolor
8972 cfg.charoff=this.charoff
8975 cfg.colspan=this.colspan
8978 cfg.headers=this.headers
8981 cfg.height=this.height
8984 cfg.nowrap=this.nowrap
8987 cfg.rowspan=this.rowspan
8990 cfg.scope=this.scope
8993 cfg.valign=this.valign
8996 cfg.width=this.width
9015 * @class Roo.bootstrap.TableRow
9016 * @extends Roo.bootstrap.Component
9017 * Bootstrap TableRow class
9018 * @cfg {String} cls row class
9019 * @cfg {String} align Aligns the content in a table row
9020 * @cfg {String} bgcolor Specifies a background color for a table row
9021 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
9022 * @cfg {String} valign Vertical aligns the content in a table row
9025 * Create a new TableRow
9026 * @param {Object} config The config object
9029 Roo.bootstrap.TableRow = function(config){
9030 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
9033 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
9041 getAutoCreate : function(){
9042 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
9052 cfg.align = this.align;
9055 cfg.bgcolor = this.bgcolor;
9058 cfg.charoff = this.charoff;
9061 cfg.valign = this.valign;
9079 * @class Roo.bootstrap.TableBody
9080 * @extends Roo.bootstrap.Component
9081 * Bootstrap TableBody class
9082 * @cfg {String} cls element class
9083 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
9084 * @cfg {String} align Aligns the content inside the element
9085 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
9086 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
9089 * Create a new TableBody
9090 * @param {Object} config The config object
9093 Roo.bootstrap.TableBody = function(config){
9094 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
9097 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
9105 getAutoCreate : function(){
9106 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
9120 cfg.align = this.align;
9123 cfg.charoff = this.charoff;
9126 cfg.valign = this.valign;
9133 // initEvents : function()
9140 // this.store = Roo.factory(this.store, Roo.data);
9141 // this.store.on('load', this.onLoad, this);
9143 // this.store.load();
9147 // onLoad: function ()
9149 // this.fireEvent('load', this);
9159 * Ext JS Library 1.1.1
9160 * Copyright(c) 2006-2007, Ext JS, LLC.
9162 * Originally Released Under LGPL - original licence link has changed is not relivant.
9165 * <script type="text/javascript">
9168 // as we use this in bootstrap.
9169 Roo.namespace('Roo.form');
9171 * @class Roo.form.Action
9172 * Internal Class used to handle form actions
9174 * @param {Roo.form.BasicForm} el The form element or its id
9175 * @param {Object} config Configuration options
9180 // define the action interface
9181 Roo.form.Action = function(form, options){
9183 this.options = options || {};
9186 * Client Validation Failed
9189 Roo.form.Action.CLIENT_INVALID = 'client';
9191 * Server Validation Failed
9194 Roo.form.Action.SERVER_INVALID = 'server';
9196 * Connect to Server Failed
9199 Roo.form.Action.CONNECT_FAILURE = 'connect';
9201 * Reading Data from Server Failed
9204 Roo.form.Action.LOAD_FAILURE = 'load';
9206 Roo.form.Action.prototype = {
9208 failureType : undefined,
9209 response : undefined,
9213 run : function(options){
9218 success : function(response){
9223 handleResponse : function(response){
9227 // default connection failure
9228 failure : function(response){
9230 this.response = response;
9231 this.failureType = Roo.form.Action.CONNECT_FAILURE;
9232 this.form.afterAction(this, false);
9235 processResponse : function(response){
9236 this.response = response;
9237 if(!response.responseText){
9240 this.result = this.handleResponse(response);
9244 // utility functions used internally
9245 getUrl : function(appendParams){
9246 var url = this.options.url || this.form.url || this.form.el.dom.action;
9248 var p = this.getParams();
9250 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
9256 getMethod : function(){
9257 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
9260 getParams : function(){
9261 var bp = this.form.baseParams;
9262 var p = this.options.params;
9264 if(typeof p == "object"){
9265 p = Roo.urlEncode(Roo.applyIf(p, bp));
9266 }else if(typeof p == 'string' && bp){
9267 p += '&' + Roo.urlEncode(bp);
9270 p = Roo.urlEncode(bp);
9275 createCallback : function(){
9277 success: this.success,
9278 failure: this.failure,
9280 timeout: (this.form.timeout*1000),
9281 upload: this.form.fileUpload ? this.success : undefined
9286 Roo.form.Action.Submit = function(form, options){
9287 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
9290 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
9293 haveProgress : false,
9294 uploadComplete : false,
9296 // uploadProgress indicator.
9297 uploadProgress : function()
9299 if (!this.form.progressUrl) {
9303 if (!this.haveProgress) {
9304 Roo.MessageBox.progress("Uploading", "Uploading");
9306 if (this.uploadComplete) {
9307 Roo.MessageBox.hide();
9311 this.haveProgress = true;
9313 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
9315 var c = new Roo.data.Connection();
9317 url : this.form.progressUrl,
9322 success : function(req){
9323 //console.log(data);
9327 rdata = Roo.decode(req.responseText)
9329 Roo.log("Invalid data from server..");
9333 if (!rdata || !rdata.success) {
9335 Roo.MessageBox.alert(Roo.encode(rdata));
9338 var data = rdata.data;
9340 if (this.uploadComplete) {
9341 Roo.MessageBox.hide();
9346 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
9347 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
9350 this.uploadProgress.defer(2000,this);
9353 failure: function(data) {
9354 Roo.log('progress url failed ');
9365 // run get Values on the form, so it syncs any secondary forms.
9366 this.form.getValues();
9368 var o = this.options;
9369 var method = this.getMethod();
9370 var isPost = method == 'POST';
9371 if(o.clientValidation === false || this.form.isValid()){
9373 if (this.form.progressUrl) {
9374 this.form.findField('UPLOAD_IDENTIFIER').setValue(
9375 (new Date() * 1) + '' + Math.random());
9380 Roo.Ajax.request(Roo.apply(this.createCallback(), {
9381 form:this.form.el.dom,
9382 url:this.getUrl(!isPost),
9384 params:isPost ? this.getParams() : null,
9385 isUpload: this.form.fileUpload,
9386 formData : this.form.formData
9389 this.uploadProgress();
9391 }else if (o.clientValidation !== false){ // client validation failed
9392 this.failureType = Roo.form.Action.CLIENT_INVALID;
9393 this.form.afterAction(this, false);
9397 success : function(response)
9399 this.uploadComplete= true;
9400 if (this.haveProgress) {
9401 Roo.MessageBox.hide();
9405 var result = this.processResponse(response);
9406 if(result === true || result.success){
9407 this.form.afterAction(this, true);
9411 this.form.markInvalid(result.errors);
9412 this.failureType = Roo.form.Action.SERVER_INVALID;
9414 this.form.afterAction(this, false);
9416 failure : function(response)
9418 this.uploadComplete= true;
9419 if (this.haveProgress) {
9420 Roo.MessageBox.hide();
9423 this.response = response;
9424 this.failureType = Roo.form.Action.CONNECT_FAILURE;
9425 this.form.afterAction(this, false);
9428 handleResponse : function(response){
9429 if(this.form.errorReader){
9430 var rs = this.form.errorReader.read(response);
9433 for(var i = 0, len = rs.records.length; i < len; i++) {
9434 var r = rs.records[i];
9438 if(errors.length < 1){
9442 success : rs.success,
9448 ret = Roo.decode(response.responseText);
9452 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
9462 Roo.form.Action.Load = function(form, options){
9463 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
9464 this.reader = this.form.reader;
9467 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
9472 Roo.Ajax.request(Roo.apply(
9473 this.createCallback(), {
9474 method:this.getMethod(),
9475 url:this.getUrl(false),
9476 params:this.getParams()
9480 success : function(response){
9482 var result = this.processResponse(response);
9483 if(result === true || !result.success || !result.data){
9484 this.failureType = Roo.form.Action.LOAD_FAILURE;
9485 this.form.afterAction(this, false);
9488 this.form.clearInvalid();
9489 this.form.setValues(result.data);
9490 this.form.afterAction(this, true);
9493 handleResponse : function(response){
9494 if(this.form.reader){
9495 var rs = this.form.reader.read(response);
9496 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
9498 success : rs.success,
9502 return Roo.decode(response.responseText);
9506 Roo.form.Action.ACTION_TYPES = {
9507 'load' : Roo.form.Action.Load,
9508 'submit' : Roo.form.Action.Submit
9517 * @class Roo.bootstrap.Form
9518 * @extends Roo.bootstrap.Component
9519 * Bootstrap Form class
9520 * @cfg {String} method GET | POST (default POST)
9521 * @cfg {String} labelAlign top | left (default top)
9522 * @cfg {String} align left | right - for navbars
9523 * @cfg {Boolean} loadMask load mask when submit (default true)
9528 * @param {Object} config The config object
9532 Roo.bootstrap.Form = function(config){
9534 Roo.bootstrap.Form.superclass.constructor.call(this, config);
9536 Roo.bootstrap.Form.popover.apply();
9540 * @event clientvalidation
9541 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
9542 * @param {Form} this
9543 * @param {Boolean} valid true if the form has passed client-side validation
9545 clientvalidation: true,
9547 * @event beforeaction
9548 * Fires before any action is performed. Return false to cancel the action.
9549 * @param {Form} this
9550 * @param {Action} action The action to be performed
9554 * @event actionfailed
9555 * Fires when an action fails.
9556 * @param {Form} this
9557 * @param {Action} action The action that failed
9559 actionfailed : true,
9561 * @event actioncomplete
9562 * Fires when an action is completed.
9563 * @param {Form} this
9564 * @param {Action} action The action that completed
9566 actioncomplete : true
9570 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
9573 * @cfg {String} method
9574 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
9579 * The URL to use for form actions if one isn't supplied in the action options.
9582 * @cfg {Boolean} fileUpload
9583 * Set to true if this form is a file upload.
9587 * @cfg {Object} baseParams
9588 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
9592 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
9596 * @cfg {Sting} align (left|right) for navbar forms
9601 activeAction : null,
9604 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
9605 * element by passing it or its id or mask the form itself by passing in true.
9608 waitMsgTarget : false,
9613 * @cfg {Boolean} errorMask (true|false) default false
9618 * @cfg {Number} maskOffset Default 100
9623 * @cfg {Boolean} maskBody
9627 getAutoCreate : function(){
9631 method : this.method || 'POST',
9632 id : this.id || Roo.id(),
9635 if (this.parent().xtype.match(/^Nav/)) {
9636 cfg.cls = 'navbar-form form-inline navbar-' + this.align;
9640 if (this.labelAlign == 'left' ) {
9641 cfg.cls += ' form-horizontal';
9647 initEvents : function()
9649 this.el.on('submit', this.onSubmit, this);
9650 // this was added as random key presses on the form where triggering form submit.
9651 this.el.on('keypress', function(e) {
9652 if (e.getCharCode() != 13) {
9655 // we might need to allow it for textareas.. and some other items.
9656 // check e.getTarget().
9658 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
9662 Roo.log("keypress blocked");
9670 onSubmit : function(e){
9675 * Returns true if client-side validation on the form is successful.
9678 isValid : function(){
9679 var items = this.getItems();
9683 items.each(function(f){
9689 Roo.log('invalid field: ' + f.name);
9693 if(!target && f.el.isVisible(true)){
9699 if(this.errorMask && !valid){
9700 Roo.bootstrap.Form.popover.mask(this, target);
9707 * Returns true if any fields in this form have changed since their original load.
9710 isDirty : function(){
9712 var items = this.getItems();
9713 items.each(function(f){
9723 * Performs a predefined action (submit or load) or custom actions you define on this form.
9724 * @param {String} actionName The name of the action type
9725 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
9726 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
9727 * accept other config options):
9729 Property Type Description
9730 ---------------- --------------- ----------------------------------------------------------------------------------
9731 url String The url for the action (defaults to the form's url)
9732 method String The form method to use (defaults to the form's method, or POST if not defined)
9733 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
9734 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
9735 validate the form on the client (defaults to false)
9737 * @return {BasicForm} this
9739 doAction : function(action, options){
9740 if(typeof action == 'string'){
9741 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
9743 if(this.fireEvent('beforeaction', this, action) !== false){
9744 this.beforeAction(action);
9745 action.run.defer(100, action);
9751 beforeAction : function(action){
9752 var o = action.options;
9757 Roo.get(document.body).mask(o.waitMsg || "Sending", 'x-mask-loading')
9759 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
9762 // not really supported yet.. ??
9764 //if(this.waitMsgTarget === true){
9765 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
9766 //}else if(this.waitMsgTarget){
9767 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
9768 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
9770 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
9776 afterAction : function(action, success){
9777 this.activeAction = null;
9778 var o = action.options;
9783 Roo.get(document.body).unmask();
9789 //if(this.waitMsgTarget === true){
9790 // this.el.unmask();
9791 //}else if(this.waitMsgTarget){
9792 // this.waitMsgTarget.unmask();
9794 // Roo.MessageBox.updateProgress(1);
9795 // Roo.MessageBox.hide();
9802 Roo.callback(o.success, o.scope, [this, action]);
9803 this.fireEvent('actioncomplete', this, action);
9807 // failure condition..
9808 // we have a scenario where updates need confirming.
9809 // eg. if a locking scenario exists..
9810 // we look for { errors : { needs_confirm : true }} in the response.
9812 (typeof(action.result) != 'undefined') &&
9813 (typeof(action.result.errors) != 'undefined') &&
9814 (typeof(action.result.errors.needs_confirm) != 'undefined')
9817 Roo.log("not supported yet");
9820 Roo.MessageBox.confirm(
9821 "Change requires confirmation",
9822 action.result.errorMsg,
9827 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
9837 Roo.callback(o.failure, o.scope, [this, action]);
9838 // show an error message if no failed handler is set..
9839 if (!this.hasListener('actionfailed')) {
9840 Roo.log("need to add dialog support");
9842 Roo.MessageBox.alert("Error",
9843 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
9844 action.result.errorMsg :
9845 "Saving Failed, please check your entries or try again"
9850 this.fireEvent('actionfailed', this, action);
9855 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
9856 * @param {String} id The value to search for
9859 findField : function(id){
9860 var items = this.getItems();
9861 var field = items.get(id);
9863 items.each(function(f){
9864 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
9871 return field || null;
9874 * Mark fields in this form invalid in bulk.
9875 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
9876 * @return {BasicForm} this
9878 markInvalid : function(errors){
9879 if(errors instanceof Array){
9880 for(var i = 0, len = errors.length; i < len; i++){
9881 var fieldError = errors[i];
9882 var f = this.findField(fieldError.id);
9884 f.markInvalid(fieldError.msg);
9890 if(typeof errors[id] != 'function' && (field = this.findField(id))){
9891 field.markInvalid(errors[id]);
9895 //Roo.each(this.childForms || [], function (f) {
9896 // f.markInvalid(errors);
9903 * Set values for fields in this form in bulk.
9904 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
9905 * @return {BasicForm} this
9907 setValues : function(values){
9908 if(values instanceof Array){ // array of objects
9909 for(var i = 0, len = values.length; i < len; i++){
9911 var f = this.findField(v.id);
9913 f.setValue(v.value);
9914 if(this.trackResetOnLoad){
9915 f.originalValue = f.getValue();
9919 }else{ // object hash
9922 if(typeof values[id] != 'function' && (field = this.findField(id))){
9924 if (field.setFromData &&
9926 field.displayField &&
9927 // combos' with local stores can
9928 // be queried via setValue()
9929 // to set their value..
9930 (field.store && !field.store.isLocal)
9934 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
9935 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
9936 field.setFromData(sd);
9938 } else if(field.setFromData && (field.store && !field.store.isLocal)) {
9940 field.setFromData(values);
9943 field.setValue(values[id]);
9947 if(this.trackResetOnLoad){
9948 field.originalValue = field.getValue();
9954 //Roo.each(this.childForms || [], function (f) {
9955 // f.setValues(values);
9962 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
9963 * they are returned as an array.
9964 * @param {Boolean} asString
9967 getValues : function(asString){
9968 //if (this.childForms) {
9969 // copy values from the child forms
9970 // Roo.each(this.childForms, function (f) {
9971 // this.setValues(f.getValues());
9977 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
9978 if(asString === true){
9981 return Roo.urlDecode(fs);
9985 * Returns the fields in this form as an object with key/value pairs.
9986 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
9989 getFieldValues : function(with_hidden)
9991 var items = this.getItems();
9993 items.each(function(f){
9999 var v = f.getValue();
10001 if (f.inputType =='radio') {
10002 if (typeof(ret[f.getName()]) == 'undefined') {
10003 ret[f.getName()] = ''; // empty..
10006 if (!f.el.dom.checked) {
10010 v = f.el.dom.value;
10014 if(f.xtype == 'MoneyField'){
10015 ret[f.currencyName] = f.getCurrency();
10018 // not sure if this supported any more..
10019 if ((typeof(v) == 'object') && f.getRawValue) {
10020 v = f.getRawValue() ; // dates..
10022 // combo boxes where name != hiddenName...
10023 if (f.name !== false && f.name != '' && f.name != f.getName()) {
10024 ret[f.name] = f.getRawValue();
10026 ret[f.getName()] = v;
10033 * Clears all invalid messages in this form.
10034 * @return {BasicForm} this
10036 clearInvalid : function(){
10037 var items = this.getItems();
10039 items.each(function(f){
10047 * Resets this form.
10048 * @return {BasicForm} this
10050 reset : function(){
10051 var items = this.getItems();
10052 items.each(function(f){
10056 Roo.each(this.childForms || [], function (f) {
10064 getItems : function()
10066 var r=new Roo.util.MixedCollection(false, function(o){
10067 return o.id || (o.id = Roo.id());
10069 var iter = function(el) {
10076 Roo.each(el.items,function(e) {
10085 hideFields : function(items)
10087 Roo.each(items, function(i){
10089 var f = this.findField(i);
10100 showFields : function(items)
10102 Roo.each(items, function(i){
10104 var f = this.findField(i);
10117 Roo.apply(Roo.bootstrap.Form, {
10133 intervalID : false,
10139 if(this.isApplied){
10144 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
10145 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
10146 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
10147 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
10150 this.maskEl.top.enableDisplayMode("block");
10151 this.maskEl.left.enableDisplayMode("block");
10152 this.maskEl.bottom.enableDisplayMode("block");
10153 this.maskEl.right.enableDisplayMode("block");
10155 this.toolTip = new Roo.bootstrap.Tooltip({
10156 cls : 'roo-form-error-popover',
10158 'left' : ['r-l', [-2,0], 'right'],
10159 'right' : ['l-r', [2,0], 'left'],
10160 'bottom' : ['tl-bl', [0,2], 'top'],
10161 'top' : [ 'bl-tl', [0,-2], 'bottom']
10165 this.toolTip.render(Roo.get(document.body));
10167 this.toolTip.el.enableDisplayMode("block");
10169 Roo.get(document.body).on('click', function(){
10173 Roo.get(document.body).on('touchstart', function(){
10177 this.isApplied = true
10180 mask : function(form, target)
10184 this.target = target;
10186 if(!this.form.errorMask || !target.el){
10190 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
10192 Roo.log(scrollable);
10194 var ot = this.target.el.calcOffsetsTo(scrollable);
10196 var scrollTo = ot[1] - this.form.maskOffset;
10198 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
10200 scrollable.scrollTo('top', scrollTo);
10202 var box = this.target.el.getBox();
10204 var zIndex = Roo.bootstrap.Modal.zIndex++;
10207 this.maskEl.top.setStyle('position', 'absolute');
10208 this.maskEl.top.setStyle('z-index', zIndex);
10209 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
10210 this.maskEl.top.setLeft(0);
10211 this.maskEl.top.setTop(0);
10212 this.maskEl.top.show();
10214 this.maskEl.left.setStyle('position', 'absolute');
10215 this.maskEl.left.setStyle('z-index', zIndex);
10216 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
10217 this.maskEl.left.setLeft(0);
10218 this.maskEl.left.setTop(box.y - this.padding);
10219 this.maskEl.left.show();
10221 this.maskEl.bottom.setStyle('position', 'absolute');
10222 this.maskEl.bottom.setStyle('z-index', zIndex);
10223 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
10224 this.maskEl.bottom.setLeft(0);
10225 this.maskEl.bottom.setTop(box.bottom + this.padding);
10226 this.maskEl.bottom.show();
10228 this.maskEl.right.setStyle('position', 'absolute');
10229 this.maskEl.right.setStyle('z-index', zIndex);
10230 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
10231 this.maskEl.right.setLeft(box.right + this.padding);
10232 this.maskEl.right.setTop(box.y - this.padding);
10233 this.maskEl.right.show();
10235 this.toolTip.bindEl = this.target.el;
10237 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
10239 var tip = this.target.blankText;
10241 if(this.target.getValue() !== '' ) {
10243 if (this.target.invalidText.length) {
10244 tip = this.target.invalidText;
10245 } else if (this.target.regexText.length){
10246 tip = this.target.regexText;
10250 this.toolTip.show(tip);
10252 this.intervalID = window.setInterval(function() {
10253 Roo.bootstrap.Form.popover.unmask();
10256 window.onwheel = function(){ return false;};
10258 (function(){ this.isMasked = true; }).defer(500, this);
10262 unmask : function()
10264 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
10268 this.maskEl.top.setStyle('position', 'absolute');
10269 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
10270 this.maskEl.top.hide();
10272 this.maskEl.left.setStyle('position', 'absolute');
10273 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
10274 this.maskEl.left.hide();
10276 this.maskEl.bottom.setStyle('position', 'absolute');
10277 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
10278 this.maskEl.bottom.hide();
10280 this.maskEl.right.setStyle('position', 'absolute');
10281 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
10282 this.maskEl.right.hide();
10284 this.toolTip.hide();
10286 this.toolTip.el.hide();
10288 window.onwheel = function(){ return true;};
10290 if(this.intervalID){
10291 window.clearInterval(this.intervalID);
10292 this.intervalID = false;
10295 this.isMasked = false;
10305 * Ext JS Library 1.1.1
10306 * Copyright(c) 2006-2007, Ext JS, LLC.
10308 * Originally Released Under LGPL - original licence link has changed is not relivant.
10311 * <script type="text/javascript">
10314 * @class Roo.form.VTypes
10315 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
10318 Roo.form.VTypes = function(){
10319 // closure these in so they are only created once.
10320 var alpha = /^[a-zA-Z_]+$/;
10321 var alphanum = /^[a-zA-Z0-9_]+$/;
10322 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
10323 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
10325 // All these messages and functions are configurable
10328 * The function used to validate email addresses
10329 * @param {String} value The email address
10331 'email' : function(v){
10332 return email.test(v);
10335 * The error text to display when the email validation function returns false
10338 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
10340 * The keystroke filter mask to be applied on email input
10343 'emailMask' : /[a-z0-9_\.\-@]/i,
10346 * The function used to validate URLs
10347 * @param {String} value The URL
10349 'url' : function(v){
10350 return url.test(v);
10353 * The error text to display when the url validation function returns false
10356 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
10359 * The function used to validate alpha values
10360 * @param {String} value The value
10362 'alpha' : function(v){
10363 return alpha.test(v);
10366 * The error text to display when the alpha validation function returns false
10369 'alphaText' : 'This field should only contain letters and _',
10371 * The keystroke filter mask to be applied on alpha input
10374 'alphaMask' : /[a-z_]/i,
10377 * The function used to validate alphanumeric values
10378 * @param {String} value The value
10380 'alphanum' : function(v){
10381 return alphanum.test(v);
10384 * The error text to display when the alphanumeric validation function returns false
10387 'alphanumText' : 'This field should only contain letters, numbers and _',
10389 * The keystroke filter mask to be applied on alphanumeric input
10392 'alphanumMask' : /[a-z0-9_]/i
10402 * @class Roo.bootstrap.Input
10403 * @extends Roo.bootstrap.Component
10404 * Bootstrap Input class
10405 * @cfg {Boolean} disabled is it disabled
10406 * @cfg {String} (button|checkbox|email|file|hidden|image|number|password|radio|range|reset|search|submit|text) inputType
10407 * @cfg {String} name name of the input
10408 * @cfg {string} fieldLabel - the label associated
10409 * @cfg {string} placeholder - placeholder to put in text.
10410 * @cfg {string} before - input group add on before
10411 * @cfg {string} after - input group add on after
10412 * @cfg {string} size - (lg|sm) or leave empty..
10413 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
10414 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
10415 * @cfg {Number} md colspan out of 12 for computer-sized screens
10416 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
10417 * @cfg {string} value default value of the input
10418 * @cfg {Number} labelWidth set the width of label
10419 * @cfg {Number} labellg set the width of label (1-12)
10420 * @cfg {Number} labelmd set the width of label (1-12)
10421 * @cfg {Number} labelsm set the width of label (1-12)
10422 * @cfg {Number} labelxs set the width of label (1-12)
10423 * @cfg {String} labelAlign (top|left)
10424 * @cfg {Boolean} readOnly Specifies that the field should be read-only
10425 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
10426 * @cfg {String} indicatorpos (left|right) default left
10427 * @cfg {String} capture (user|camera) use for file input only. (default empty)
10428 * @cfg {String} accept (image|video|audio) use for file input only. (default empty)
10429 * @cfg {Boolean} preventMark Do not show tick or cross if error/success
10431 * @cfg {String} align (left|center|right) Default left
10432 * @cfg {Boolean} forceFeedback (true|false) Default false
10435 * Create a new Input
10436 * @param {Object} config The config object
10439 Roo.bootstrap.Input = function(config){
10441 Roo.bootstrap.Input.superclass.constructor.call(this, config);
10446 * Fires when this field receives input focus.
10447 * @param {Roo.form.Field} this
10452 * Fires when this field loses input focus.
10453 * @param {Roo.form.Field} this
10457 * @event specialkey
10458 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
10459 * {@link Roo.EventObject#getKey} to determine which key was pressed.
10460 * @param {Roo.form.Field} this
10461 * @param {Roo.EventObject} e The event object
10466 * Fires just before the field blurs if the field value has changed.
10467 * @param {Roo.form.Field} this
10468 * @param {Mixed} newValue The new value
10469 * @param {Mixed} oldValue The original value
10474 * Fires after the field has been marked as invalid.
10475 * @param {Roo.form.Field} this
10476 * @param {String} msg The validation message
10481 * Fires after the field has been validated with no errors.
10482 * @param {Roo.form.Field} this
10487 * Fires after the key up
10488 * @param {Roo.form.Field} this
10489 * @param {Roo.EventObject} e The event Object
10495 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
10497 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
10498 automatic validation (defaults to "keyup").
10500 validationEvent : "keyup",
10502 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
10504 validateOnBlur : true,
10506 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
10508 validationDelay : 250,
10510 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
10512 focusClass : "x-form-focus", // not needed???
10516 * @cfg {String} invalidClass DEPRICATED - code uses BS4 - is-valid / is-invalid
10518 invalidClass : "has-warning",
10521 * @cfg {String} validClass DEPRICATED - code uses BS4 - is-valid / is-invalid
10523 validClass : "has-success",
10526 * @cfg {Boolean} hasFeedback (true|false) default true
10528 hasFeedback : true,
10531 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
10533 invalidFeedbackClass : "glyphicon-warning-sign",
10536 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
10538 validFeedbackClass : "glyphicon-ok",
10541 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
10543 selectOnFocus : false,
10546 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
10550 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
10555 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
10557 disableKeyFilter : false,
10560 * @cfg {Boolean} disabled True to disable the field (defaults to false).
10564 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
10568 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
10570 blankText : "Please complete this mandatory field",
10573 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
10577 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
10579 maxLength : Number.MAX_VALUE,
10581 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
10583 minLengthText : "The minimum length for this field is {0}",
10585 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
10587 maxLengthText : "The maximum length for this field is {0}",
10591 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
10592 * If available, this function will be called only after the basic validators all return true, and will be passed the
10593 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
10597 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
10598 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
10599 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
10603 * @cfg {String} regexText -- Depricated - use Invalid Text
10608 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
10614 autocomplete: false,
10618 inputType : 'text',
10621 placeholder: false,
10626 preventMark: false,
10627 isFormField : true,
10630 labelAlign : false,
10633 formatedValue : false,
10634 forceFeedback : false,
10636 indicatorpos : 'left',
10646 parentLabelAlign : function()
10649 while (parent.parent()) {
10650 parent = parent.parent();
10651 if (typeof(parent.labelAlign) !='undefined') {
10652 return parent.labelAlign;
10659 getAutoCreate : function()
10661 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
10667 if(this.inputType != 'hidden'){
10668 cfg.cls = 'form-group' //input-group
10674 type : this.inputType,
10675 value : this.value,
10676 cls : 'form-control',
10677 placeholder : this.placeholder || '',
10678 autocomplete : this.autocomplete || 'new-password'
10680 if (this.inputType == 'file') {
10681 input.style = 'overflow:hidden'; // why not in CSS?
10684 if(this.capture.length){
10685 input.capture = this.capture;
10688 if(this.accept.length){
10689 input.accept = this.accept + "/*";
10693 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
10696 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
10697 input.maxLength = this.maxLength;
10700 if (this.disabled) {
10701 input.disabled=true;
10704 if (this.readOnly) {
10705 input.readonly=true;
10709 input.name = this.name;
10713 input.cls += ' input-' + this.size;
10717 ['xs','sm','md','lg'].map(function(size){
10718 if (settings[size]) {
10719 cfg.cls += ' col-' + size + '-' + settings[size];
10723 var inputblock = input;
10727 cls: 'glyphicon form-control-feedback'
10730 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10733 cls : 'has-feedback',
10741 if (this.before || this.after) {
10744 cls : 'input-group',
10748 if (this.before && typeof(this.before) == 'string') {
10750 inputblock.cn.push({
10752 cls : 'roo-input-before input-group-addon input-group-prepend input-group-text',
10756 if (this.before && typeof(this.before) == 'object') {
10757 this.before = Roo.factory(this.before);
10759 inputblock.cn.push({
10761 cls : 'roo-input-before input-group-prepend input-group-' +
10762 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
10766 inputblock.cn.push(input);
10768 if (this.after && typeof(this.after) == 'string') {
10769 inputblock.cn.push({
10771 cls : 'roo-input-after input-group-append input-group-text input-group-addon',
10775 if (this.after && typeof(this.after) == 'object') {
10776 this.after = Roo.factory(this.after);
10778 inputblock.cn.push({
10780 cls : 'roo-input-after input-group-append input-group-' +
10781 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
10785 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10786 inputblock.cls += ' has-feedback';
10787 inputblock.cn.push(feedback);
10792 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
10793 tooltip : 'This field is required'
10795 if (this.allowBlank ) {
10796 indicator.style = this.allowBlank ? ' display:none' : '';
10798 if (align ==='left' && this.fieldLabel.length) {
10800 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
10807 cls : 'control-label col-form-label',
10808 html : this.fieldLabel
10819 var labelCfg = cfg.cn[1];
10820 var contentCfg = cfg.cn[2];
10822 if(this.indicatorpos == 'right'){
10827 cls : 'control-label col-form-label',
10831 html : this.fieldLabel
10845 labelCfg = cfg.cn[0];
10846 contentCfg = cfg.cn[1];
10850 if(this.labelWidth > 12){
10851 labelCfg.style = "width: " + this.labelWidth + 'px';
10854 if(this.labelWidth < 13 && this.labelmd == 0){
10855 this.labelmd = this.labelWidth;
10858 if(this.labellg > 0){
10859 labelCfg.cls += ' col-lg-' + this.labellg;
10860 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
10863 if(this.labelmd > 0){
10864 labelCfg.cls += ' col-md-' + this.labelmd;
10865 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
10868 if(this.labelsm > 0){
10869 labelCfg.cls += ' col-sm-' + this.labelsm;
10870 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
10873 if(this.labelxs > 0){
10874 labelCfg.cls += ' col-xs-' + this.labelxs;
10875 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
10879 } else if ( this.fieldLabel.length) {
10886 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
10887 tooltip : 'This field is required',
10888 style : this.allowBlank ? ' display:none' : ''
10892 //cls : 'input-group-addon',
10893 html : this.fieldLabel
10901 if(this.indicatorpos == 'right'){
10906 //cls : 'input-group-addon',
10907 html : this.fieldLabel
10912 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
10913 tooltip : 'This field is required',
10914 style : this.allowBlank ? ' display:none' : ''
10934 if (this.parentType === 'Navbar' && this.parent().bar) {
10935 cfg.cls += ' navbar-form';
10938 if (this.parentType === 'NavGroup' && !(Roo.bootstrap.version == 4 && this.parent().form)) {
10939 // on BS4 we do this only if not form
10940 cfg.cls += ' navbar-form';
10948 * return the real input element.
10950 inputEl: function ()
10952 return this.el.select('input.form-control',true).first();
10955 tooltipEl : function()
10957 return this.inputEl();
10960 indicatorEl : function()
10962 if (Roo.bootstrap.version == 4) {
10963 return false; // not enabled in v4 yet.
10966 var indicator = this.el.select('i.roo-required-indicator',true).first();
10976 setDisabled : function(v)
10978 var i = this.inputEl().dom;
10980 i.removeAttribute('disabled');
10984 i.setAttribute('disabled','true');
10986 initEvents : function()
10989 this.inputEl().on("keydown" , this.fireKey, this);
10990 this.inputEl().on("focus", this.onFocus, this);
10991 this.inputEl().on("blur", this.onBlur, this);
10993 this.inputEl().relayEvent('keyup', this);
10995 this.indicator = this.indicatorEl();
10997 if(this.indicator){
10998 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible'); // changed from invisible??? -
11001 // reference to original value for reset
11002 this.originalValue = this.getValue();
11003 //Roo.form.TextField.superclass.initEvents.call(this);
11004 if(this.validationEvent == 'keyup'){
11005 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
11006 this.inputEl().on('keyup', this.filterValidation, this);
11008 else if(this.validationEvent !== false){
11009 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
11012 if(this.selectOnFocus){
11013 this.on("focus", this.preFocus, this);
11016 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
11017 this.inputEl().on("keypress", this.filterKeys, this);
11019 this.inputEl().relayEvent('keypress', this);
11022 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
11023 this.el.on("click", this.autoSize, this);
11026 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
11027 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
11030 if (typeof(this.before) == 'object') {
11031 this.before.render(this.el.select('.roo-input-before',true).first());
11033 if (typeof(this.after) == 'object') {
11034 this.after.render(this.el.select('.roo-input-after',true).first());
11037 this.inputEl().on('change', this.onChange, this);
11040 filterValidation : function(e){
11041 if(!e.isNavKeyPress()){
11042 this.validationTask.delay(this.validationDelay);
11046 * Validates the field value
11047 * @return {Boolean} True if the value is valid, else false
11049 validate : function(){
11050 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
11051 if(this.disabled || this.validateValue(this.getRawValue())){
11056 this.markInvalid();
11062 * Validates a value according to the field's validation rules and marks the field as invalid
11063 * if the validation fails
11064 * @param {Mixed} value The value to validate
11065 * @return {Boolean} True if the value is valid, else false
11067 validateValue : function(value)
11069 if(this.getVisibilityEl().hasClass('hidden')){
11073 if(value.length < 1) { // if it's blank
11074 if(this.allowBlank){
11080 if(value.length < this.minLength){
11083 if(value.length > this.maxLength){
11087 var vt = Roo.form.VTypes;
11088 if(!vt[this.vtype](value, this)){
11092 if(typeof this.validator == "function"){
11093 var msg = this.validator(value);
11097 if (typeof(msg) == 'string') {
11098 this.invalidText = msg;
11102 if(this.regex && !this.regex.test(value)){
11110 fireKey : function(e){
11111 //Roo.log('field ' + e.getKey());
11112 if(e.isNavKeyPress()){
11113 this.fireEvent("specialkey", this, e);
11116 focus : function (selectText){
11118 this.inputEl().focus();
11119 if(selectText === true){
11120 this.inputEl().dom.select();
11126 onFocus : function(){
11127 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
11128 // this.el.addClass(this.focusClass);
11130 if(!this.hasFocus){
11131 this.hasFocus = true;
11132 this.startValue = this.getValue();
11133 this.fireEvent("focus", this);
11137 beforeBlur : Roo.emptyFn,
11141 onBlur : function(){
11143 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
11144 //this.el.removeClass(this.focusClass);
11146 this.hasFocus = false;
11147 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
11150 var v = this.getValue();
11151 if(String(v) !== String(this.startValue)){
11152 this.fireEvent('change', this, v, this.startValue);
11154 this.fireEvent("blur", this);
11157 onChange : function(e)
11159 var v = this.getValue();
11160 if(String(v) !== String(this.startValue)){
11161 this.fireEvent('change', this, v, this.startValue);
11167 * Resets the current field value to the originally loaded value and clears any validation messages
11169 reset : function(){
11170 this.setValue(this.originalValue);
11174 * Returns the name of the field
11175 * @return {Mixed} name The name field
11177 getName: function(){
11181 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
11182 * @return {Mixed} value The field value
11184 getValue : function(){
11186 var v = this.inputEl().getValue();
11191 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
11192 * @return {Mixed} value The field value
11194 getRawValue : function(){
11195 var v = this.inputEl().getValue();
11201 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
11202 * @param {Mixed} value The value to set
11204 setRawValue : function(v){
11205 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
11208 selectText : function(start, end){
11209 var v = this.getRawValue();
11211 start = start === undefined ? 0 : start;
11212 end = end === undefined ? v.length : end;
11213 var d = this.inputEl().dom;
11214 if(d.setSelectionRange){
11215 d.setSelectionRange(start, end);
11216 }else if(d.createTextRange){
11217 var range = d.createTextRange();
11218 range.moveStart("character", start);
11219 range.moveEnd("character", v.length-end);
11226 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
11227 * @param {Mixed} value The value to set
11229 setValue : function(v){
11232 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
11238 processValue : function(value){
11239 if(this.stripCharsRe){
11240 var newValue = value.replace(this.stripCharsRe, '');
11241 if(newValue !== value){
11242 this.setRawValue(newValue);
11249 preFocus : function(){
11251 if(this.selectOnFocus){
11252 this.inputEl().dom.select();
11255 filterKeys : function(e){
11256 var k = e.getKey();
11257 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
11260 var c = e.getCharCode(), cc = String.fromCharCode(c);
11261 if(Roo.isIE && (e.isSpecialKey() || !cc)){
11264 if(!this.maskRe.test(cc)){
11269 * Clear any invalid styles/messages for this field
11271 clearInvalid : function(){
11273 if(!this.el || this.preventMark){ // not rendered
11278 this.el.removeClass([this.invalidClass, 'is-invalid']);
11280 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
11282 var feedback = this.el.select('.form-control-feedback', true).first();
11285 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
11290 if(this.indicator){
11291 this.indicator.removeClass('visible');
11292 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
11295 this.fireEvent('valid', this);
11299 * Mark this field as valid
11301 markValid : function()
11303 if(!this.el || this.preventMark){ // not rendered...
11307 this.el.removeClass([this.invalidClass, this.validClass]);
11308 this.inputEl().removeClass(['is-valid', 'is-invalid']);
11310 var feedback = this.el.select('.form-control-feedback', true).first();
11313 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
11316 if(this.indicator){
11317 this.indicator.removeClass('visible');
11318 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
11326 if(this.allowBlank && !this.getRawValue().length){
11329 if (Roo.bootstrap.version == 3) {
11330 this.el.addClass(this.validClass);
11332 this.inputEl().addClass('is-valid');
11335 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
11337 var feedback = this.el.select('.form-control-feedback', true).first();
11340 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
11341 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
11346 this.fireEvent('valid', this);
11350 * Mark this field as invalid
11351 * @param {String} msg The validation message
11353 markInvalid : function(msg)
11355 if(!this.el || this.preventMark){ // not rendered
11359 this.el.removeClass([this.invalidClass, this.validClass]);
11360 this.inputEl().removeClass(['is-valid', 'is-invalid']);
11362 var feedback = this.el.select('.form-control-feedback', true).first();
11365 this.el.select('.form-control-feedback', true).first().removeClass(
11366 [this.invalidFeedbackClass, this.validFeedbackClass]);
11373 if(this.allowBlank && !this.getRawValue().length){
11377 if(this.indicator){
11378 this.indicator.removeClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
11379 this.indicator.addClass('visible');
11381 if (Roo.bootstrap.version == 3) {
11382 this.el.addClass(this.invalidClass);
11384 this.inputEl().addClass('is-invalid');
11389 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
11391 var feedback = this.el.select('.form-control-feedback', true).first();
11394 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
11396 if(this.getValue().length || this.forceFeedback){
11397 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
11404 this.fireEvent('invalid', this, msg);
11407 SafariOnKeyDown : function(event)
11409 // this is a workaround for a password hang bug on chrome/ webkit.
11410 if (this.inputEl().dom.type != 'password') {
11414 var isSelectAll = false;
11416 if(this.inputEl().dom.selectionEnd > 0){
11417 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
11419 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
11420 event.preventDefault();
11425 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
11427 event.preventDefault();
11428 // this is very hacky as keydown always get's upper case.
11430 var cc = String.fromCharCode(event.getCharCode());
11431 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
11435 adjustWidth : function(tag, w){
11436 tag = tag.toLowerCase();
11437 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
11438 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
11439 if(tag == 'input'){
11442 if(tag == 'textarea'){
11445 }else if(Roo.isOpera){
11446 if(tag == 'input'){
11449 if(tag == 'textarea'){
11457 setFieldLabel : function(v)
11459 if(!this.rendered){
11463 if(this.indicatorEl()){
11464 var ar = this.el.select('label > span',true);
11466 if (ar.elements.length) {
11467 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
11468 this.fieldLabel = v;
11472 var br = this.el.select('label',true);
11474 if(br.elements.length) {
11475 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
11476 this.fieldLabel = v;
11480 Roo.log('Cannot Found any of label > span || label in input');
11484 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
11485 this.fieldLabel = v;
11500 * @class Roo.bootstrap.TextArea
11501 * @extends Roo.bootstrap.Input
11502 * Bootstrap TextArea class
11503 * @cfg {Number} cols Specifies the visible width of a text area
11504 * @cfg {Number} rows Specifies the visible number of lines in a text area
11505 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
11506 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
11507 * @cfg {string} html text
11510 * Create a new TextArea
11511 * @param {Object} config The config object
11514 Roo.bootstrap.TextArea = function(config){
11515 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
11519 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
11529 getAutoCreate : function(){
11531 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
11537 if(this.inputType != 'hidden'){
11538 cfg.cls = 'form-group' //input-group
11546 value : this.value || '',
11547 html: this.html || '',
11548 cls : 'form-control',
11549 placeholder : this.placeholder || ''
11553 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
11554 input.maxLength = this.maxLength;
11558 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
11562 input.cols = this.cols;
11565 if (this.readOnly) {
11566 input.readonly = true;
11570 input.name = this.name;
11574 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
11578 ['xs','sm','md','lg'].map(function(size){
11579 if (settings[size]) {
11580 cfg.cls += ' col-' + size + '-' + settings[size];
11584 var inputblock = input;
11586 if(this.hasFeedback && !this.allowBlank){
11590 cls: 'glyphicon form-control-feedback'
11594 cls : 'has-feedback',
11603 if (this.before || this.after) {
11606 cls : 'input-group',
11610 inputblock.cn.push({
11612 cls : 'input-group-addon',
11617 inputblock.cn.push(input);
11619 if(this.hasFeedback && !this.allowBlank){
11620 inputblock.cls += ' has-feedback';
11621 inputblock.cn.push(feedback);
11625 inputblock.cn.push({
11627 cls : 'input-group-addon',
11634 if (align ==='left' && this.fieldLabel.length) {
11639 cls : 'control-label',
11640 html : this.fieldLabel
11651 if(this.labelWidth > 12){
11652 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
11655 if(this.labelWidth < 13 && this.labelmd == 0){
11656 this.labelmd = this.labelWidth;
11659 if(this.labellg > 0){
11660 cfg.cn[0].cls += ' col-lg-' + this.labellg;
11661 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
11664 if(this.labelmd > 0){
11665 cfg.cn[0].cls += ' col-md-' + this.labelmd;
11666 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
11669 if(this.labelsm > 0){
11670 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
11671 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
11674 if(this.labelxs > 0){
11675 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
11676 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
11679 } else if ( this.fieldLabel.length) {
11684 //cls : 'input-group-addon',
11685 html : this.fieldLabel
11703 if (this.disabled) {
11704 input.disabled=true;
11711 * return the real textarea element.
11713 inputEl: function ()
11715 return this.el.select('textarea.form-control',true).first();
11719 * Clear any invalid styles/messages for this field
11721 clearInvalid : function()
11724 if(!this.el || this.preventMark){ // not rendered
11728 var label = this.el.select('label', true).first();
11729 var icon = this.el.select('i.fa-star', true).first();
11734 this.el.removeClass( this.validClass);
11735 this.inputEl().removeClass('is-invalid');
11737 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
11739 var feedback = this.el.select('.form-control-feedback', true).first();
11742 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
11747 this.fireEvent('valid', this);
11751 * Mark this field as valid
11753 markValid : function()
11755 if(!this.el || this.preventMark){ // not rendered
11759 this.el.removeClass([this.invalidClass, this.validClass]);
11760 this.inputEl().removeClass(['is-valid', 'is-invalid']);
11762 var feedback = this.el.select('.form-control-feedback', true).first();
11765 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
11768 if(this.disabled || this.allowBlank){
11772 var label = this.el.select('label', true).first();
11773 var icon = this.el.select('i.fa-star', true).first();
11778 if (Roo.bootstrap.version == 3) {
11779 this.el.addClass(this.validClass);
11781 this.inputEl().addClass('is-valid');
11785 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
11787 var feedback = this.el.select('.form-control-feedback', true).first();
11790 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
11791 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
11796 this.fireEvent('valid', this);
11800 * Mark this field as invalid
11801 * @param {String} msg The validation message
11803 markInvalid : function(msg)
11805 if(!this.el || this.preventMark){ // not rendered
11809 this.el.removeClass([this.invalidClass, this.validClass]);
11810 this.inputEl().removeClass(['is-valid', 'is-invalid']);
11812 var feedback = this.el.select('.form-control-feedback', true).first();
11815 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
11818 if(this.disabled || this.allowBlank){
11822 var label = this.el.select('label', true).first();
11823 var icon = this.el.select('i.fa-star', true).first();
11825 if(!this.getValue().length && label && !icon){
11826 this.el.createChild({
11828 cls : 'text-danger fa fa-lg fa-star',
11829 tooltip : 'This field is required',
11830 style : 'margin-right:5px;'
11834 if (Roo.bootstrap.version == 3) {
11835 this.el.addClass(this.invalidClass);
11837 this.inputEl().addClass('is-invalid');
11840 // fixme ... this may be depricated need to test..
11841 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
11843 var feedback = this.el.select('.form-control-feedback', true).first();
11846 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
11848 if(this.getValue().length || this.forceFeedback){
11849 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
11856 this.fireEvent('invalid', this, msg);
11864 * trigger field - base class for combo..
11869 * @class Roo.bootstrap.TriggerField
11870 * @extends Roo.bootstrap.Input
11871 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
11872 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
11873 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
11874 * for which you can provide a custom implementation. For example:
11876 var trigger = new Roo.bootstrap.TriggerField();
11877 trigger.onTriggerClick = myTriggerFn;
11878 trigger.applyTo('my-field');
11881 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
11882 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
11883 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
11884 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
11885 * @cfg {String} caret (search|calendar) BS3 only - carat fa name
11888 * Create a new TriggerField.
11889 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
11890 * to the base TextField)
11892 Roo.bootstrap.TriggerField = function(config){
11893 this.mimicing = false;
11894 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
11897 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
11899 * @cfg {String} triggerClass A CSS class to apply to the trigger
11902 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
11907 * @cfg {Boolean} removable (true|false) special filter default false
11911 /** @cfg {Boolean} grow @hide */
11912 /** @cfg {Number} growMin @hide */
11913 /** @cfg {Number} growMax @hide */
11919 autoSize: Roo.emptyFn,
11923 deferHeight : true,
11926 actionMode : 'wrap',
11931 getAutoCreate : function(){
11933 var align = this.labelAlign || this.parentLabelAlign();
11938 cls: 'form-group' //input-group
11945 type : this.inputType,
11946 cls : 'form-control',
11947 autocomplete: 'new-password',
11948 placeholder : this.placeholder || ''
11952 input.name = this.name;
11955 input.cls += ' input-' + this.size;
11958 if (this.disabled) {
11959 input.disabled=true;
11962 var inputblock = input;
11964 if(this.hasFeedback && !this.allowBlank){
11968 cls: 'glyphicon form-control-feedback'
11971 if(this.removable && !this.editable ){
11973 cls : 'has-feedback',
11979 cls : 'roo-combo-removable-btn close'
11986 cls : 'has-feedback',
11995 if(this.removable && !this.editable ){
11997 cls : 'roo-removable',
12003 cls : 'roo-combo-removable-btn close'
12010 if (this.before || this.after) {
12013 cls : 'input-group',
12017 inputblock.cn.push({
12019 cls : 'input-group-addon input-group-prepend input-group-text',
12024 inputblock.cn.push(input);
12026 if(this.hasFeedback && !this.allowBlank){
12027 inputblock.cls += ' has-feedback';
12028 inputblock.cn.push(feedback);
12032 inputblock.cn.push({
12034 cls : 'input-group-addon input-group-append input-group-text',
12043 var ibwrap = inputblock;
12048 cls: 'roo-select2-choices',
12052 cls: 'roo-select2-search-field',
12064 cls: 'roo-select2-container input-group',
12069 cls: 'form-hidden-field'
12075 if(!this.multiple && this.showToggleBtn){
12081 if (this.caret != false) {
12084 cls: 'fa fa-' + this.caret
12091 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
12093 Roo.bootstrap.version == 3 ? caret : '',
12096 cls: 'combobox-clear',
12110 combobox.cls += ' roo-select2-container-multi';
12114 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
12115 tooltip : 'This field is required'
12117 if (Roo.bootstrap.version == 4) {
12120 style : 'display:none'
12125 if (align ==='left' && this.fieldLabel.length) {
12127 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
12134 cls : 'control-label',
12135 html : this.fieldLabel
12147 var labelCfg = cfg.cn[1];
12148 var contentCfg = cfg.cn[2];
12150 if(this.indicatorpos == 'right'){
12155 cls : 'control-label',
12159 html : this.fieldLabel
12173 labelCfg = cfg.cn[0];
12174 contentCfg = cfg.cn[1];
12177 if(this.labelWidth > 12){
12178 labelCfg.style = "width: " + this.labelWidth + 'px';
12181 if(this.labelWidth < 13 && this.labelmd == 0){
12182 this.labelmd = this.labelWidth;
12185 if(this.labellg > 0){
12186 labelCfg.cls += ' col-lg-' + this.labellg;
12187 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
12190 if(this.labelmd > 0){
12191 labelCfg.cls += ' col-md-' + this.labelmd;
12192 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
12195 if(this.labelsm > 0){
12196 labelCfg.cls += ' col-sm-' + this.labelsm;
12197 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
12200 if(this.labelxs > 0){
12201 labelCfg.cls += ' col-xs-' + this.labelxs;
12202 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
12205 } else if ( this.fieldLabel.length) {
12206 // Roo.log(" label");
12211 //cls : 'input-group-addon',
12212 html : this.fieldLabel
12220 if(this.indicatorpos == 'right'){
12228 html : this.fieldLabel
12242 // Roo.log(" no label && no align");
12249 ['xs','sm','md','lg'].map(function(size){
12250 if (settings[size]) {
12251 cfg.cls += ' col-' + size + '-' + settings[size];
12262 onResize : function(w, h){
12263 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
12264 // if(typeof w == 'number'){
12265 // var x = w - this.trigger.getWidth();
12266 // this.inputEl().setWidth(this.adjustWidth('input', x));
12267 // this.trigger.setStyle('left', x+'px');
12272 adjustSize : Roo.BoxComponent.prototype.adjustSize,
12275 getResizeEl : function(){
12276 return this.inputEl();
12280 getPositionEl : function(){
12281 return this.inputEl();
12285 alignErrorIcon : function(){
12286 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
12290 initEvents : function(){
12294 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
12295 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
12296 if(!this.multiple && this.showToggleBtn){
12297 this.trigger = this.el.select('span.dropdown-toggle',true).first();
12298 if(this.hideTrigger){
12299 this.trigger.setDisplayed(false);
12301 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
12305 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
12308 if(this.removable && !this.editable && !this.tickable){
12309 var close = this.closeTriggerEl();
12312 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
12313 close.on('click', this.removeBtnClick, this, close);
12317 //this.trigger.addClassOnOver('x-form-trigger-over');
12318 //this.trigger.addClassOnClick('x-form-trigger-click');
12321 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
12325 closeTriggerEl : function()
12327 var close = this.el.select('.roo-combo-removable-btn', true).first();
12328 return close ? close : false;
12331 removeBtnClick : function(e, h, el)
12333 e.preventDefault();
12335 if(this.fireEvent("remove", this) !== false){
12337 this.fireEvent("afterremove", this)
12341 createList : function()
12343 this.list = Roo.get(document.body).createChild({
12344 tag: Roo.bootstrap.version == 4 ? 'div' : 'ul',
12345 cls: 'typeahead typeahead-long dropdown-menu shadow',
12346 style: 'display:none'
12349 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
12354 initTrigger : function(){
12359 onDestroy : function(){
12361 this.trigger.removeAllListeners();
12362 // this.trigger.remove();
12365 // this.wrap.remove();
12367 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
12371 onFocus : function(){
12372 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
12374 if(!this.mimicing){
12375 this.wrap.addClass('x-trigger-wrap-focus');
12376 this.mimicing = true;
12377 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
12378 if(this.monitorTab){
12379 this.el.on("keydown", this.checkTab, this);
12386 checkTab : function(e){
12387 if(e.getKey() == e.TAB){
12388 this.triggerBlur();
12393 onBlur : function(){
12398 mimicBlur : function(e, t){
12400 if(!this.wrap.contains(t) && this.validateBlur()){
12401 this.triggerBlur();
12407 triggerBlur : function(){
12408 this.mimicing = false;
12409 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
12410 if(this.monitorTab){
12411 this.el.un("keydown", this.checkTab, this);
12413 //this.wrap.removeClass('x-trigger-wrap-focus');
12414 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
12418 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
12419 validateBlur : function(e, t){
12424 onDisable : function(){
12425 this.inputEl().dom.disabled = true;
12426 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
12428 // this.wrap.addClass('x-item-disabled');
12433 onEnable : function(){
12434 this.inputEl().dom.disabled = false;
12435 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
12437 // this.el.removeClass('x-item-disabled');
12442 onShow : function(){
12443 var ae = this.getActionEl();
12446 ae.dom.style.display = '';
12447 ae.dom.style.visibility = 'visible';
12453 onHide : function(){
12454 var ae = this.getActionEl();
12455 ae.dom.style.display = 'none';
12459 * The function that should handle the trigger's click event. This method does nothing by default until overridden
12460 * by an implementing function.
12462 * @param {EventObject} e
12464 onTriggerClick : Roo.emptyFn
12472 * @class Roo.bootstrap.CardUploader
12473 * @extends Roo.bootstrap.Button
12474 * Bootstrap Card Uploader class - it's a button which when you add files to it, adds cards below with preview and the name...
12475 * @cfg {Number} errorTimeout default 3000
12476 * @cfg {Array} images an array of ?? Img objects ??? when loading existing files..
12477 * @cfg {Array} html The button text.
12481 * Create a new CardUploader
12482 * @param {Object} config The config object
12485 Roo.bootstrap.CardUploader = function(config){
12489 Roo.bootstrap.CardUploader.superclass.constructor.call(this, config);
12492 this.fileCollection = new Roo.util.MixedCollection(false,function(r) {
12499 Roo.extend(Roo.bootstrap.CardUploader, Roo.bootstrap.Input, {
12502 errorTimeout : 3000,
12506 fileCollection : false,
12509 getAutoCreate : function()
12513 cls :'form-group' ,
12518 //cls : 'input-group-addon',
12519 html : this.fieldLabel
12526 value : this.value,
12527 cls : 'd-none form-control'
12532 multiple : 'multiple',
12534 cls : 'd-none roo-card-upload-selector'
12538 cls : 'roo-card-uploader-button-container w-100 mb-2'
12541 cls : 'card-columns roo-card-uploader-container'
12551 getChildContainer : function() /// what children are added to.
12553 return this.containerEl;
12556 getButtonContainer : function() /// what children are added to.
12558 return this.el.select(".roo-card-uploader-button-container").first();
12561 initEvents : function()
12564 Roo.bootstrap.Input.prototype.initEvents.call(this);
12568 xns: Roo.bootstrap,
12571 container_method : 'getButtonContainer' ,
12572 html : this.html, // fix changable?
12575 'click' : function(btn, e) {
12584 this.urlAPI = (window.createObjectURL && window) ||
12585 (window.URL && URL.revokeObjectURL && URL) ||
12586 (window.webkitURL && webkitURL);
12591 this.selectorEl = this.el.select('.roo-card-upload-selector', true).first();
12593 this.selectorEl.on('change', this.onFileSelected, this);
12596 this.images.forEach(function(img) {
12599 this.images = false;
12601 this.containerEl = this.el.select('.roo-card-uploader-container', true).first();
12607 onClick : function(e)
12609 e.preventDefault();
12611 this.selectorEl.dom.click();
12615 onFileSelected : function(e)
12617 e.preventDefault();
12619 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
12623 Roo.each(this.selectorEl.dom.files, function(file){
12624 this.addFile(file);
12633 addFile : function(file)
12636 if(typeof(file) === 'string'){
12637 throw "Add file by name?"; // should not happen
12641 if(!file || !this.urlAPI){
12651 var url = _this.urlAPI.createObjectURL( file);
12654 id : Roo.bootstrap.CardUploader.ID--,
12655 is_uploaded : false,
12658 mimetype : file.type,
12665 addCard : function (data)
12667 // hidden input element?
12668 // if the file is not an image...
12669 //then we need to use something other that and header_image
12674 xns : Roo.bootstrap,
12675 xtype : 'CardFooter',
12678 xns : Roo.bootstrap,
12684 xns : Roo.bootstrap,
12686 html : String.format("<small>{0}</small>", data.title),
12687 cls : 'col-11 text-left',
12692 click : function() {
12693 this.downloadCard(data.id)
12699 xns : Roo.bootstrap,
12707 click : function() {
12708 t.removeCard(data.id)
12720 var cn = this.addxtype(
12723 xns : Roo.bootstrap,
12726 header : !data.mimetype.match(/image/) && !data.preview ? "Document": false,
12727 header_image : data.mimetype.match(/image/) ? data.src : data.preview,
12728 header_image_fit_square: true, // fixme - we probably need to use the 'Img' element to do stuff like this.
12733 initEvents : function() {
12734 Roo.bootstrap.Card.prototype.initEvents.call(this);
12735 this.imgEl = this.el.select('.card-img-top').first();
12737 this.imgEl.on('click', function() { t.previewCard( data.id); }, this);
12738 this.imgEl.set({ 'pointer' : 'cursor' });
12747 // dont' really need ot update items.
12748 // this.items.push(cn);
12749 this.fileCollection.add(cn);
12750 this.updateInput();
12753 removeCard : function(id)
12756 var card = this.fileCollection.get(id);
12757 card.data.is_deleted = 1;
12758 card.data.src = ''; /// delete the source - so it reduces size of not uploaded images etc.
12759 this.fileCollection.remove(card);
12760 //this.items = this.items.filter(function(e) { return e != card });
12761 // dont' really need ot update items.
12762 card.el.dom.parentNode.removeChild(card.el.dom);
12767 this.fileCollection.each(function(card) {
12768 card.el.dom.parentNode.removeChild(card.el.dom);
12770 this.fileCollection.clear();
12771 this.updateInput();
12774 updateInput : function()
12777 this.fileCollection.each(function(e) {
12781 this.inputEl().dom.value = JSON.stringify(data);
12788 Roo.bootstrap.CardUploader.ID = -1;/*
12790 * Ext JS Library 1.1.1
12791 * Copyright(c) 2006-2007, Ext JS, LLC.
12793 * Originally Released Under LGPL - original licence link has changed is not relivant.
12796 * <script type="text/javascript">
12801 * @class Roo.data.SortTypes
12803 * Defines the default sorting (casting?) comparison functions used when sorting data.
12805 Roo.data.SortTypes = {
12807 * Default sort that does nothing
12808 * @param {Mixed} s The value being converted
12809 * @return {Mixed} The comparison value
12811 none : function(s){
12816 * The regular expression used to strip tags
12820 stripTagsRE : /<\/?[^>]+>/gi,
12823 * Strips all HTML tags to sort on text only
12824 * @param {Mixed} s The value being converted
12825 * @return {String} The comparison value
12827 asText : function(s){
12828 return String(s).replace(this.stripTagsRE, "");
12832 * Strips all HTML tags to sort on text only - Case insensitive
12833 * @param {Mixed} s The value being converted
12834 * @return {String} The comparison value
12836 asUCText : function(s){
12837 return String(s).toUpperCase().replace(this.stripTagsRE, "");
12841 * Case insensitive string
12842 * @param {Mixed} s The value being converted
12843 * @return {String} The comparison value
12845 asUCString : function(s) {
12846 return String(s).toUpperCase();
12851 * @param {Mixed} s The value being converted
12852 * @return {Number} The comparison value
12854 asDate : function(s) {
12858 if(s instanceof Date){
12859 return s.getTime();
12861 return Date.parse(String(s));
12866 * @param {Mixed} s The value being converted
12867 * @return {Float} The comparison value
12869 asFloat : function(s) {
12870 var val = parseFloat(String(s).replace(/,/g, ""));
12879 * @param {Mixed} s The value being converted
12880 * @return {Number} The comparison value
12882 asInt : function(s) {
12883 var val = parseInt(String(s).replace(/,/g, ""));
12891 * Ext JS Library 1.1.1
12892 * Copyright(c) 2006-2007, Ext JS, LLC.
12894 * Originally Released Under LGPL - original licence link has changed is not relivant.
12897 * <script type="text/javascript">
12901 * @class Roo.data.Record
12902 * Instances of this class encapsulate both record <em>definition</em> information, and record
12903 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
12904 * to access Records cached in an {@link Roo.data.Store} object.<br>
12906 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
12907 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
12910 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
12912 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
12913 * {@link #create}. The parameters are the same.
12914 * @param {Array} data An associative Array of data values keyed by the field name.
12915 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
12916 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
12917 * not specified an integer id is generated.
12919 Roo.data.Record = function(data, id){
12920 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
12925 * Generate a constructor for a specific record layout.
12926 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
12927 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
12928 * Each field definition object may contain the following properties: <ul>
12929 * <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,
12930 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
12931 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
12932 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
12933 * is being used, then this is a string containing the javascript expression to reference the data relative to
12934 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
12935 * to the data item relative to the record element. If the mapping expression is the same as the field name,
12936 * this may be omitted.</p></li>
12937 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
12938 * <ul><li>auto (Default, implies no conversion)</li>
12943 * <li>date</li></ul></p></li>
12944 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
12945 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
12946 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
12947 * by the Reader into an object that will be stored in the Record. It is passed the
12948 * following parameters:<ul>
12949 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
12951 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
12953 * <br>usage:<br><pre><code>
12954 var TopicRecord = Roo.data.Record.create(
12955 {name: 'title', mapping: 'topic_title'},
12956 {name: 'author', mapping: 'username'},
12957 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
12958 {name: 'lastPost', mapping: 'post_time', type: 'date'},
12959 {name: 'lastPoster', mapping: 'user2'},
12960 {name: 'excerpt', mapping: 'post_text'}
12963 var myNewRecord = new TopicRecord({
12964 title: 'Do my job please',
12967 lastPost: new Date(),
12968 lastPoster: 'Animal',
12969 excerpt: 'No way dude!'
12971 myStore.add(myNewRecord);
12976 Roo.data.Record.create = function(o){
12977 var f = function(){
12978 f.superclass.constructor.apply(this, arguments);
12980 Roo.extend(f, Roo.data.Record);
12981 var p = f.prototype;
12982 p.fields = new Roo.util.MixedCollection(false, function(field){
12985 for(var i = 0, len = o.length; i < len; i++){
12986 p.fields.add(new Roo.data.Field(o[i]));
12988 f.getField = function(name){
12989 return p.fields.get(name);
12994 Roo.data.Record.AUTO_ID = 1000;
12995 Roo.data.Record.EDIT = 'edit';
12996 Roo.data.Record.REJECT = 'reject';
12997 Roo.data.Record.COMMIT = 'commit';
12999 Roo.data.Record.prototype = {
13001 * Readonly flag - true if this record has been modified.
13010 join : function(store){
13011 this.store = store;
13015 * Set the named field to the specified value.
13016 * @param {String} name The name of the field to set.
13017 * @param {Object} value The value to set the field to.
13019 set : function(name, value){
13020 if(this.data[name] == value){
13024 if(!this.modified){
13025 this.modified = {};
13027 if(typeof this.modified[name] == 'undefined'){
13028 this.modified[name] = this.data[name];
13030 this.data[name] = value;
13031 if(!this.editing && this.store){
13032 this.store.afterEdit(this);
13037 * Get the value of the named field.
13038 * @param {String} name The name of the field to get the value of.
13039 * @return {Object} The value of the field.
13041 get : function(name){
13042 return this.data[name];
13046 beginEdit : function(){
13047 this.editing = true;
13048 this.modified = {};
13052 cancelEdit : function(){
13053 this.editing = false;
13054 delete this.modified;
13058 endEdit : function(){
13059 this.editing = false;
13060 if(this.dirty && this.store){
13061 this.store.afterEdit(this);
13066 * Usually called by the {@link Roo.data.Store} which owns the Record.
13067 * Rejects all changes made to the Record since either creation, or the last commit operation.
13068 * Modified fields are reverted to their original values.
13070 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
13071 * of reject operations.
13073 reject : function(){
13074 var m = this.modified;
13076 if(typeof m[n] != "function"){
13077 this.data[n] = m[n];
13080 this.dirty = false;
13081 delete this.modified;
13082 this.editing = false;
13084 this.store.afterReject(this);
13089 * Usually called by the {@link Roo.data.Store} which owns the Record.
13090 * Commits all changes made to the Record since either creation, or the last commit operation.
13092 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
13093 * of commit operations.
13095 commit : function(){
13096 this.dirty = false;
13097 delete this.modified;
13098 this.editing = false;
13100 this.store.afterCommit(this);
13105 hasError : function(){
13106 return this.error != null;
13110 clearError : function(){
13115 * Creates a copy of this record.
13116 * @param {String} id (optional) A new record id if you don't want to use this record's id
13119 copy : function(newId) {
13120 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
13124 * Ext JS Library 1.1.1
13125 * Copyright(c) 2006-2007, Ext JS, LLC.
13127 * Originally Released Under LGPL - original licence link has changed is not relivant.
13130 * <script type="text/javascript">
13136 * @class Roo.data.Store
13137 * @extends Roo.util.Observable
13138 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
13139 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
13141 * 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
13142 * has no knowledge of the format of the data returned by the Proxy.<br>
13144 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
13145 * instances from the data object. These records are cached and made available through accessor functions.
13147 * Creates a new Store.
13148 * @param {Object} config A config object containing the objects needed for the Store to access data,
13149 * and read the data into Records.
13151 Roo.data.Store = function(config){
13152 this.data = new Roo.util.MixedCollection(false);
13153 this.data.getKey = function(o){
13156 this.baseParams = {};
13158 this.paramNames = {
13163 "multisort" : "_multisort"
13166 if(config && config.data){
13167 this.inlineData = config.data;
13168 delete config.data;
13171 Roo.apply(this, config);
13173 if(this.reader){ // reader passed
13174 this.reader = Roo.factory(this.reader, Roo.data);
13175 this.reader.xmodule = this.xmodule || false;
13176 if(!this.recordType){
13177 this.recordType = this.reader.recordType;
13179 if(this.reader.onMetaChange){
13180 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
13184 if(this.recordType){
13185 this.fields = this.recordType.prototype.fields;
13187 this.modified = [];
13191 * @event datachanged
13192 * Fires when the data cache has changed, and a widget which is using this Store
13193 * as a Record cache should refresh its view.
13194 * @param {Store} this
13196 datachanged : true,
13198 * @event metachange
13199 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
13200 * @param {Store} this
13201 * @param {Object} meta The JSON metadata
13206 * Fires when Records have been added to the Store
13207 * @param {Store} this
13208 * @param {Roo.data.Record[]} records The array of Records added
13209 * @param {Number} index The index at which the record(s) were added
13214 * Fires when a Record has been removed from the Store
13215 * @param {Store} this
13216 * @param {Roo.data.Record} record The Record that was removed
13217 * @param {Number} index The index at which the record was removed
13222 * Fires when a Record has been updated
13223 * @param {Store} this
13224 * @param {Roo.data.Record} record The Record that was updated
13225 * @param {String} operation The update operation being performed. Value may be one of:
13227 Roo.data.Record.EDIT
13228 Roo.data.Record.REJECT
13229 Roo.data.Record.COMMIT
13235 * Fires when the data cache has been cleared.
13236 * @param {Store} this
13240 * @event beforeload
13241 * Fires before a request is made for a new data object. If the beforeload handler returns false
13242 * the load action will be canceled.
13243 * @param {Store} this
13244 * @param {Object} options The loading options that were specified (see {@link #load} for details)
13248 * @event beforeloadadd
13249 * Fires after a new set of Records has been loaded.
13250 * @param {Store} this
13251 * @param {Roo.data.Record[]} records The Records that were loaded
13252 * @param {Object} options The loading options that were specified (see {@link #load} for details)
13254 beforeloadadd : true,
13257 * Fires after a new set of Records has been loaded, before they are added to the store.
13258 * @param {Store} this
13259 * @param {Roo.data.Record[]} records The Records that were loaded
13260 * @param {Object} options The loading options that were specified (see {@link #load} for details)
13261 * @params {Object} return from reader
13265 * @event loadexception
13266 * Fires if an exception occurs in the Proxy during loading.
13267 * Called with the signature of the Proxy's "loadexception" event.
13268 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
13271 * @param {Object} return from JsonData.reader() - success, totalRecords, records
13272 * @param {Object} load options
13273 * @param {Object} jsonData from your request (normally this contains the Exception)
13275 loadexception : true
13279 this.proxy = Roo.factory(this.proxy, Roo.data);
13280 this.proxy.xmodule = this.xmodule || false;
13281 this.relayEvents(this.proxy, ["loadexception"]);
13283 this.sortToggle = {};
13284 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
13286 Roo.data.Store.superclass.constructor.call(this);
13288 if(this.inlineData){
13289 this.loadData(this.inlineData);
13290 delete this.inlineData;
13294 Roo.extend(Roo.data.Store, Roo.util.Observable, {
13296 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
13297 * without a remote query - used by combo/forms at present.
13301 * @cfg {Roo.data.DataProxy} proxy The Proxy object which provides access to a data object.
13304 * @cfg {Array} data Inline data to be loaded when the store is initialized.
13307 * @cfg {Roo.data.Reader} reader The Reader object which processes the data object and returns
13308 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
13311 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
13312 * on any HTTP request
13315 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
13318 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
13322 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
13323 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
13325 remoteSort : false,
13328 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
13329 * loaded or when a record is removed. (defaults to false).
13331 pruneModifiedRecords : false,
13334 lastOptions : null,
13337 * Add Records to the Store and fires the add event.
13338 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
13340 add : function(records){
13341 records = [].concat(records);
13342 for(var i = 0, len = records.length; i < len; i++){
13343 records[i].join(this);
13345 var index = this.data.length;
13346 this.data.addAll(records);
13347 this.fireEvent("add", this, records, index);
13351 * Remove a Record from the Store and fires the remove event.
13352 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
13354 remove : function(record){
13355 var index = this.data.indexOf(record);
13356 this.data.removeAt(index);
13358 if(this.pruneModifiedRecords){
13359 this.modified.remove(record);
13361 this.fireEvent("remove", this, record, index);
13365 * Remove all Records from the Store and fires the clear event.
13367 removeAll : function(){
13369 if(this.pruneModifiedRecords){
13370 this.modified = [];
13372 this.fireEvent("clear", this);
13376 * Inserts Records to the Store at the given index and fires the add event.
13377 * @param {Number} index The start index at which to insert the passed Records.
13378 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
13380 insert : function(index, records){
13381 records = [].concat(records);
13382 for(var i = 0, len = records.length; i < len; i++){
13383 this.data.insert(index, records[i]);
13384 records[i].join(this);
13386 this.fireEvent("add", this, records, index);
13390 * Get the index within the cache of the passed Record.
13391 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
13392 * @return {Number} The index of the passed Record. Returns -1 if not found.
13394 indexOf : function(record){
13395 return this.data.indexOf(record);
13399 * Get the index within the cache of the Record with the passed id.
13400 * @param {String} id The id of the Record to find.
13401 * @return {Number} The index of the Record. Returns -1 if not found.
13403 indexOfId : function(id){
13404 return this.data.indexOfKey(id);
13408 * Get the Record with the specified id.
13409 * @param {String} id The id of the Record to find.
13410 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
13412 getById : function(id){
13413 return this.data.key(id);
13417 * Get the Record at the specified index.
13418 * @param {Number} index The index of the Record to find.
13419 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
13421 getAt : function(index){
13422 return this.data.itemAt(index);
13426 * Returns a range of Records between specified indices.
13427 * @param {Number} startIndex (optional) The starting index (defaults to 0)
13428 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
13429 * @return {Roo.data.Record[]} An array of Records
13431 getRange : function(start, end){
13432 return this.data.getRange(start, end);
13436 storeOptions : function(o){
13437 o = Roo.apply({}, o);
13440 this.lastOptions = o;
13444 * Loads the Record cache from the configured Proxy using the configured Reader.
13446 * If using remote paging, then the first load call must specify the <em>start</em>
13447 * and <em>limit</em> properties in the options.params property to establish the initial
13448 * position within the dataset, and the number of Records to cache on each read from the Proxy.
13450 * <strong>It is important to note that for remote data sources, loading is asynchronous,
13451 * and this call will return before the new data has been loaded. Perform any post-processing
13452 * in a callback function, or in a "load" event handler.</strong>
13454 * @param {Object} options An object containing properties which control loading options:<ul>
13455 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
13456 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
13457 * passed the following arguments:<ul>
13458 * <li>r : Roo.data.Record[]</li>
13459 * <li>options: Options object from the load call</li>
13460 * <li>success: Boolean success indicator</li></ul></li>
13461 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
13462 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
13465 load : function(options){
13466 options = options || {};
13467 if(this.fireEvent("beforeload", this, options) !== false){
13468 this.storeOptions(options);
13469 var p = Roo.apply(options.params || {}, this.baseParams);
13470 // if meta was not loaded from remote source.. try requesting it.
13471 if (!this.reader.metaFromRemote) {
13472 p._requestMeta = 1;
13474 if(this.sortInfo && this.remoteSort){
13475 var pn = this.paramNames;
13476 p[pn["sort"]] = this.sortInfo.field;
13477 p[pn["dir"]] = this.sortInfo.direction;
13479 if (this.multiSort) {
13480 var pn = this.paramNames;
13481 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
13484 this.proxy.load(p, this.reader, this.loadRecords, this, options);
13489 * Reloads the Record cache from the configured Proxy using the configured Reader and
13490 * the options from the last load operation performed.
13491 * @param {Object} options (optional) An object containing properties which may override the options
13492 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
13493 * the most recently used options are reused).
13495 reload : function(options){
13496 this.load(Roo.applyIf(options||{}, this.lastOptions));
13500 // Called as a callback by the Reader during a load operation.
13501 loadRecords : function(o, options, success){
13502 if(!o || success === false){
13503 if(success !== false){
13504 this.fireEvent("load", this, [], options, o);
13506 if(options.callback){
13507 options.callback.call(options.scope || this, [], options, false);
13511 // if data returned failure - throw an exception.
13512 if (o.success === false) {
13513 // show a message if no listener is registered.
13514 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
13515 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
13517 // loadmask wil be hooked into this..
13518 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
13521 var r = o.records, t = o.totalRecords || r.length;
13523 this.fireEvent("beforeloadadd", this, r, options, o);
13525 if(!options || options.add !== true){
13526 if(this.pruneModifiedRecords){
13527 this.modified = [];
13529 for(var i = 0, len = r.length; i < len; i++){
13533 this.data = this.snapshot;
13534 delete this.snapshot;
13537 this.data.addAll(r);
13538 this.totalLength = t;
13540 this.fireEvent("datachanged", this);
13542 this.totalLength = Math.max(t, this.data.length+r.length);
13546 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
13548 var e = new Roo.data.Record({});
13550 e.set(this.parent.displayField, this.parent.emptyTitle);
13551 e.set(this.parent.valueField, '');
13556 this.fireEvent("load", this, r, options, o);
13557 if(options.callback){
13558 options.callback.call(options.scope || this, r, options, true);
13564 * Loads data from a passed data block. A Reader which understands the format of the data
13565 * must have been configured in the constructor.
13566 * @param {Object} data The data block from which to read the Records. The format of the data expected
13567 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
13568 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
13570 loadData : function(o, append){
13571 var r = this.reader.readRecords(o);
13572 this.loadRecords(r, {add: append}, true);
13576 * using 'cn' the nested child reader read the child array into it's child stores.
13577 * @param {Object} rec The record with a 'children array
13579 loadDataFromChildren : function(rec)
13581 this.loadData(this.reader.toLoadData(rec));
13586 * Gets the number of cached records.
13588 * <em>If using paging, this may not be the total size of the dataset. If the data object
13589 * used by the Reader contains the dataset size, then the getTotalCount() function returns
13590 * the data set size</em>
13592 getCount : function(){
13593 return this.data.length || 0;
13597 * Gets the total number of records in the dataset as returned by the server.
13599 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
13600 * the dataset size</em>
13602 getTotalCount : function(){
13603 return this.totalLength || 0;
13607 * Returns the sort state of the Store as an object with two properties:
13609 field {String} The name of the field by which the Records are sorted
13610 direction {String} The sort order, "ASC" or "DESC"
13613 getSortState : function(){
13614 return this.sortInfo;
13618 applySort : function(){
13619 if(this.sortInfo && !this.remoteSort){
13620 var s = this.sortInfo, f = s.field;
13621 var st = this.fields.get(f).sortType;
13622 var fn = function(r1, r2){
13623 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
13624 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
13626 this.data.sort(s.direction, fn);
13627 if(this.snapshot && this.snapshot != this.data){
13628 this.snapshot.sort(s.direction, fn);
13634 * Sets the default sort column and order to be used by the next load operation.
13635 * @param {String} fieldName The name of the field to sort by.
13636 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
13638 setDefaultSort : function(field, dir){
13639 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
13643 * Sort the Records.
13644 * If remote sorting is used, the sort is performed on the server, and the cache is
13645 * reloaded. If local sorting is used, the cache is sorted internally.
13646 * @param {String} fieldName The name of the field to sort by.
13647 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
13649 sort : function(fieldName, dir){
13650 var f = this.fields.get(fieldName);
13652 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
13654 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
13655 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
13660 this.sortToggle[f.name] = dir;
13661 this.sortInfo = {field: f.name, direction: dir};
13662 if(!this.remoteSort){
13664 this.fireEvent("datachanged", this);
13666 this.load(this.lastOptions);
13671 * Calls the specified function for each of the Records in the cache.
13672 * @param {Function} fn The function to call. The Record is passed as the first parameter.
13673 * Returning <em>false</em> aborts and exits the iteration.
13674 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
13676 each : function(fn, scope){
13677 this.data.each(fn, scope);
13681 * Gets all records modified since the last commit. Modified records are persisted across load operations
13682 * (e.g., during paging).
13683 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
13685 getModifiedRecords : function(){
13686 return this.modified;
13690 createFilterFn : function(property, value, anyMatch){
13691 if(!value.exec){ // not a regex
13692 value = String(value);
13693 if(value.length == 0){
13696 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
13698 return function(r){
13699 return value.test(r.data[property]);
13704 * Sums the value of <i>property</i> for each record between start and end and returns the result.
13705 * @param {String} property A field on your records
13706 * @param {Number} start The record index to start at (defaults to 0)
13707 * @param {Number} end The last record index to include (defaults to length - 1)
13708 * @return {Number} The sum
13710 sum : function(property, start, end){
13711 var rs = this.data.items, v = 0;
13712 start = start || 0;
13713 end = (end || end === 0) ? end : rs.length-1;
13715 for(var i = start; i <= end; i++){
13716 v += (rs[i].data[property] || 0);
13722 * Filter the records by a specified property.
13723 * @param {String} field A field on your records
13724 * @param {String/RegExp} value Either a string that the field
13725 * should start with or a RegExp to test against the field
13726 * @param {Boolean} anyMatch True to match any part not just the beginning
13728 filter : function(property, value, anyMatch){
13729 var fn = this.createFilterFn(property, value, anyMatch);
13730 return fn ? this.filterBy(fn) : this.clearFilter();
13734 * Filter by a function. The specified function will be called with each
13735 * record in this data source. If the function returns true the record is included,
13736 * otherwise it is filtered.
13737 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
13738 * @param {Object} scope (optional) The scope of the function (defaults to this)
13740 filterBy : function(fn, scope){
13741 this.snapshot = this.snapshot || this.data;
13742 this.data = this.queryBy(fn, scope||this);
13743 this.fireEvent("datachanged", this);
13747 * Query the records by a specified property.
13748 * @param {String} field A field on your records
13749 * @param {String/RegExp} value Either a string that the field
13750 * should start with or a RegExp to test against the field
13751 * @param {Boolean} anyMatch True to match any part not just the beginning
13752 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
13754 query : function(property, value, anyMatch){
13755 var fn = this.createFilterFn(property, value, anyMatch);
13756 return fn ? this.queryBy(fn) : this.data.clone();
13760 * Query by a function. The specified function will be called with each
13761 * record in this data source. If the function returns true the record is included
13763 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
13764 * @param {Object} scope (optional) The scope of the function (defaults to this)
13765 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
13767 queryBy : function(fn, scope){
13768 var data = this.snapshot || this.data;
13769 return data.filterBy(fn, scope||this);
13773 * Collects unique values for a particular dataIndex from this store.
13774 * @param {String} dataIndex The property to collect
13775 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
13776 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
13777 * @return {Array} An array of the unique values
13779 collect : function(dataIndex, allowNull, bypassFilter){
13780 var d = (bypassFilter === true && this.snapshot) ?
13781 this.snapshot.items : this.data.items;
13782 var v, sv, r = [], l = {};
13783 for(var i = 0, len = d.length; i < len; i++){
13784 v = d[i].data[dataIndex];
13786 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
13795 * Revert to a view of the Record cache with no filtering applied.
13796 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
13798 clearFilter : function(suppressEvent){
13799 if(this.snapshot && this.snapshot != this.data){
13800 this.data = this.snapshot;
13801 delete this.snapshot;
13802 if(suppressEvent !== true){
13803 this.fireEvent("datachanged", this);
13809 afterEdit : function(record){
13810 if(this.modified.indexOf(record) == -1){
13811 this.modified.push(record);
13813 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
13817 afterReject : function(record){
13818 this.modified.remove(record);
13819 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
13823 afterCommit : function(record){
13824 this.modified.remove(record);
13825 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
13829 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
13830 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
13832 commitChanges : function(){
13833 var m = this.modified.slice(0);
13834 this.modified = [];
13835 for(var i = 0, len = m.length; i < len; i++){
13841 * Cancel outstanding changes on all changed records.
13843 rejectChanges : function(){
13844 var m = this.modified.slice(0);
13845 this.modified = [];
13846 for(var i = 0, len = m.length; i < len; i++){
13851 onMetaChange : function(meta, rtype, o){
13852 this.recordType = rtype;
13853 this.fields = rtype.prototype.fields;
13854 delete this.snapshot;
13855 this.sortInfo = meta.sortInfo || this.sortInfo;
13856 this.modified = [];
13857 this.fireEvent('metachange', this, this.reader.meta);
13860 moveIndex : function(data, type)
13862 var index = this.indexOf(data);
13864 var newIndex = index + type;
13868 this.insert(newIndex, data);
13873 * Ext JS Library 1.1.1
13874 * Copyright(c) 2006-2007, Ext JS, LLC.
13876 * Originally Released Under LGPL - original licence link has changed is not relivant.
13879 * <script type="text/javascript">
13883 * @class Roo.data.SimpleStore
13884 * @extends Roo.data.Store
13885 * Small helper class to make creating Stores from Array data easier.
13886 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
13887 * @cfg {Array} fields An array of field definition objects, or field name strings.
13888 * @cfg {Object} an existing reader (eg. copied from another store)
13889 * @cfg {Array} data The multi-dimensional array of data
13891 * @param {Object} config
13893 Roo.data.SimpleStore = function(config)
13895 Roo.data.SimpleStore.superclass.constructor.call(this, {
13897 reader: typeof(config.reader) != 'undefined' ? config.reader : new Roo.data.ArrayReader({
13900 Roo.data.Record.create(config.fields)
13902 proxy : new Roo.data.MemoryProxy(config.data)
13906 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
13908 * Ext JS Library 1.1.1
13909 * Copyright(c) 2006-2007, Ext JS, LLC.
13911 * Originally Released Under LGPL - original licence link has changed is not relivant.
13914 * <script type="text/javascript">
13919 * @extends Roo.data.Store
13920 * @class Roo.data.JsonStore
13921 * Small helper class to make creating Stores for JSON data easier. <br/>
13923 var store = new Roo.data.JsonStore({
13924 url: 'get-images.php',
13926 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
13929 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
13930 * JsonReader and HttpProxy (unless inline data is provided).</b>
13931 * @cfg {Array} fields An array of field definition objects, or field name strings.
13933 * @param {Object} config
13935 Roo.data.JsonStore = function(c){
13936 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
13937 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
13938 reader: new Roo.data.JsonReader(c, c.fields)
13941 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
13943 * Ext JS Library 1.1.1
13944 * Copyright(c) 2006-2007, Ext JS, LLC.
13946 * Originally Released Under LGPL - original licence link has changed is not relivant.
13949 * <script type="text/javascript">
13953 Roo.data.Field = function(config){
13954 if(typeof config == "string"){
13955 config = {name: config};
13957 Roo.apply(this, config);
13960 this.type = "auto";
13963 var st = Roo.data.SortTypes;
13964 // named sortTypes are supported, here we look them up
13965 if(typeof this.sortType == "string"){
13966 this.sortType = st[this.sortType];
13969 // set default sortType for strings and dates
13970 if(!this.sortType){
13973 this.sortType = st.asUCString;
13976 this.sortType = st.asDate;
13979 this.sortType = st.none;
13984 var stripRe = /[\$,%]/g;
13986 // prebuilt conversion function for this field, instead of
13987 // switching every time we're reading a value
13989 var cv, dateFormat = this.dateFormat;
13994 cv = function(v){ return v; };
13997 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
14001 return v !== undefined && v !== null && v !== '' ?
14002 parseInt(String(v).replace(stripRe, ""), 10) : '';
14007 return v !== undefined && v !== null && v !== '' ?
14008 parseFloat(String(v).replace(stripRe, ""), 10) : '';
14013 cv = function(v){ return v === true || v === "true" || v == 1; };
14020 if(v instanceof Date){
14024 if(dateFormat == "timestamp"){
14025 return new Date(v*1000);
14027 return Date.parseDate(v, dateFormat);
14029 var parsed = Date.parse(v);
14030 return parsed ? new Date(parsed) : null;
14039 Roo.data.Field.prototype = {
14047 * Ext JS Library 1.1.1
14048 * Copyright(c) 2006-2007, Ext JS, LLC.
14050 * Originally Released Under LGPL - original licence link has changed is not relivant.
14053 * <script type="text/javascript">
14056 // Base class for reading structured data from a data source. This class is intended to be
14057 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
14060 * @class Roo.data.DataReader
14061 * Base class for reading structured data from a data source. This class is intended to be
14062 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
14065 Roo.data.DataReader = function(meta, recordType){
14069 this.recordType = recordType instanceof Array ?
14070 Roo.data.Record.create(recordType) : recordType;
14073 Roo.data.DataReader.prototype = {
14076 readerType : 'Data',
14078 * Create an empty record
14079 * @param {Object} data (optional) - overlay some values
14080 * @return {Roo.data.Record} record created.
14082 newRow : function(d) {
14084 this.recordType.prototype.fields.each(function(c) {
14086 case 'int' : da[c.name] = 0; break;
14087 case 'date' : da[c.name] = new Date(); break;
14088 case 'float' : da[c.name] = 0.0; break;
14089 case 'boolean' : da[c.name] = false; break;
14090 default : da[c.name] = ""; break;
14094 return new this.recordType(Roo.apply(da, d));
14100 * Ext JS Library 1.1.1
14101 * Copyright(c) 2006-2007, Ext JS, LLC.
14103 * Originally Released Under LGPL - original licence link has changed is not relivant.
14106 * <script type="text/javascript">
14110 * @class Roo.data.DataProxy
14111 * @extends Roo.data.Observable
14112 * This class is an abstract base class for implementations which provide retrieval of
14113 * unformatted data objects.<br>
14115 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
14116 * (of the appropriate type which knows how to parse the data object) to provide a block of
14117 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
14119 * Custom implementations must implement the load method as described in
14120 * {@link Roo.data.HttpProxy#load}.
14122 Roo.data.DataProxy = function(){
14125 * @event beforeload
14126 * Fires before a network request is made to retrieve a data object.
14127 * @param {Object} This DataProxy object.
14128 * @param {Object} params The params parameter to the load function.
14133 * Fires before the load method's callback is called.
14134 * @param {Object} This DataProxy object.
14135 * @param {Object} o The data object.
14136 * @param {Object} arg The callback argument object passed to the load function.
14140 * @event loadexception
14141 * Fires if an Exception occurs during data retrieval.
14142 * @param {Object} This DataProxy object.
14143 * @param {Object} o The data object.
14144 * @param {Object} arg The callback argument object passed to the load function.
14145 * @param {Object} e The Exception.
14147 loadexception : true
14149 Roo.data.DataProxy.superclass.constructor.call(this);
14152 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
14155 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
14159 * Ext JS Library 1.1.1
14160 * Copyright(c) 2006-2007, Ext JS, LLC.
14162 * Originally Released Under LGPL - original licence link has changed is not relivant.
14165 * <script type="text/javascript">
14168 * @class Roo.data.MemoryProxy
14169 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
14170 * to the Reader when its load method is called.
14172 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
14174 Roo.data.MemoryProxy = function(data){
14178 Roo.data.MemoryProxy.superclass.constructor.call(this);
14182 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
14185 * Load data from the requested source (in this case an in-memory
14186 * data object passed to the constructor), read the data object into
14187 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
14188 * process that block using the passed callback.
14189 * @param {Object} params This parameter is not used by the MemoryProxy class.
14190 * @param {Roo.data.DataReader} reader The Reader object which converts the data
14191 * object into a block of Roo.data.Records.
14192 * @param {Function} callback The function into which to pass the block of Roo.data.records.
14193 * The function must be passed <ul>
14194 * <li>The Record block object</li>
14195 * <li>The "arg" argument from the load function</li>
14196 * <li>A boolean success indicator</li>
14198 * @param {Object} scope The scope in which to call the callback
14199 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
14201 load : function(params, reader, callback, scope, arg){
14202 params = params || {};
14205 result = reader.readRecords(params.data ? params.data :this.data);
14207 this.fireEvent("loadexception", this, arg, null, e);
14208 callback.call(scope, null, arg, false);
14211 callback.call(scope, result, arg, true);
14215 update : function(params, records){
14220 * Ext JS Library 1.1.1
14221 * Copyright(c) 2006-2007, Ext JS, LLC.
14223 * Originally Released Under LGPL - original licence link has changed is not relivant.
14226 * <script type="text/javascript">
14229 * @class Roo.data.HttpProxy
14230 * @extends Roo.data.DataProxy
14231 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
14232 * configured to reference a certain URL.<br><br>
14234 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
14235 * from which the running page was served.<br><br>
14237 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
14239 * Be aware that to enable the browser to parse an XML document, the server must set
14240 * the Content-Type header in the HTTP response to "text/xml".
14242 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
14243 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
14244 * will be used to make the request.
14246 Roo.data.HttpProxy = function(conn){
14247 Roo.data.HttpProxy.superclass.constructor.call(this);
14248 // is conn a conn config or a real conn?
14250 this.useAjax = !conn || !conn.events;
14254 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
14255 // thse are take from connection...
14258 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
14261 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
14262 * extra parameters to each request made by this object. (defaults to undefined)
14265 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
14266 * to each request made by this object. (defaults to undefined)
14269 * @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)
14272 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
14275 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
14281 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
14285 * Return the {@link Roo.data.Connection} object being used by this Proxy.
14286 * @return {Connection} The Connection object. This object may be used to subscribe to events on
14287 * a finer-grained basis than the DataProxy events.
14289 getConnection : function(){
14290 return this.useAjax ? Roo.Ajax : this.conn;
14294 * Load data from the configured {@link Roo.data.Connection}, read the data object into
14295 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
14296 * process that block using the passed callback.
14297 * @param {Object} params An object containing properties which are to be used as HTTP parameters
14298 * for the request to the remote server.
14299 * @param {Roo.data.DataReader} reader The Reader object which converts the data
14300 * object into a block of Roo.data.Records.
14301 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
14302 * The function must be passed <ul>
14303 * <li>The Record block object</li>
14304 * <li>The "arg" argument from the load function</li>
14305 * <li>A boolean success indicator</li>
14307 * @param {Object} scope The scope in which to call the callback
14308 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
14310 load : function(params, reader, callback, scope, arg){
14311 if(this.fireEvent("beforeload", this, params) !== false){
14313 params : params || {},
14315 callback : callback,
14320 callback : this.loadResponse,
14324 Roo.applyIf(o, this.conn);
14325 if(this.activeRequest){
14326 Roo.Ajax.abort(this.activeRequest);
14328 this.activeRequest = Roo.Ajax.request(o);
14330 this.conn.request(o);
14333 callback.call(scope||this, null, arg, false);
14338 loadResponse : function(o, success, response){
14339 delete this.activeRequest;
14341 this.fireEvent("loadexception", this, o, response);
14342 o.request.callback.call(o.request.scope, null, o.request.arg, false);
14347 result = o.reader.read(response);
14349 this.fireEvent("loadexception", this, o, response, e);
14350 o.request.callback.call(o.request.scope, null, o.request.arg, false);
14354 this.fireEvent("load", this, o, o.request.arg);
14355 o.request.callback.call(o.request.scope, result, o.request.arg, true);
14359 update : function(dataSet){
14364 updateResponse : function(dataSet){
14369 * Ext JS Library 1.1.1
14370 * Copyright(c) 2006-2007, Ext JS, LLC.
14372 * Originally Released Under LGPL - original licence link has changed is not relivant.
14375 * <script type="text/javascript">
14379 * @class Roo.data.ScriptTagProxy
14380 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
14381 * other than the originating domain of the running page.<br><br>
14383 * <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
14384 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
14386 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
14387 * source code that is used as the source inside a <script> tag.<br><br>
14389 * In order for the browser to process the returned data, the server must wrap the data object
14390 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
14391 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
14392 * depending on whether the callback name was passed:
14395 boolean scriptTag = false;
14396 String cb = request.getParameter("callback");
14399 response.setContentType("text/javascript");
14401 response.setContentType("application/x-json");
14403 Writer out = response.getWriter();
14405 out.write(cb + "(");
14407 out.print(dataBlock.toJsonString());
14414 * @param {Object} config A configuration object.
14416 Roo.data.ScriptTagProxy = function(config){
14417 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
14418 Roo.apply(this, config);
14419 this.head = document.getElementsByTagName("head")[0];
14422 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
14424 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
14426 * @cfg {String} url The URL from which to request the data object.
14429 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
14433 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
14434 * the server the name of the callback function set up by the load call to process the returned data object.
14435 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
14436 * javascript output which calls this named function passing the data object as its only parameter.
14438 callbackParam : "callback",
14440 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
14441 * name to the request.
14446 * Load data from the configured URL, read the data object into
14447 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
14448 * process that block using the passed callback.
14449 * @param {Object} params An object containing properties which are to be used as HTTP parameters
14450 * for the request to the remote server.
14451 * @param {Roo.data.DataReader} reader The Reader object which converts the data
14452 * object into a block of Roo.data.Records.
14453 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
14454 * The function must be passed <ul>
14455 * <li>The Record block object</li>
14456 * <li>The "arg" argument from the load function</li>
14457 * <li>A boolean success indicator</li>
14459 * @param {Object} scope The scope in which to call the callback
14460 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
14462 load : function(params, reader, callback, scope, arg){
14463 if(this.fireEvent("beforeload", this, params) !== false){
14465 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
14467 var url = this.url;
14468 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
14470 url += "&_dc=" + (new Date().getTime());
14472 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
14475 cb : "stcCallback"+transId,
14476 scriptId : "stcScript"+transId,
14480 callback : callback,
14486 window[trans.cb] = function(o){
14487 conn.handleResponse(o, trans);
14490 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
14492 if(this.autoAbort !== false){
14496 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
14498 var script = document.createElement("script");
14499 script.setAttribute("src", url);
14500 script.setAttribute("type", "text/javascript");
14501 script.setAttribute("id", trans.scriptId);
14502 this.head.appendChild(script);
14504 this.trans = trans;
14506 callback.call(scope||this, null, arg, false);
14511 isLoading : function(){
14512 return this.trans ? true : false;
14516 * Abort the current server request.
14518 abort : function(){
14519 if(this.isLoading()){
14520 this.destroyTrans(this.trans);
14525 destroyTrans : function(trans, isLoaded){
14526 this.head.removeChild(document.getElementById(trans.scriptId));
14527 clearTimeout(trans.timeoutId);
14529 window[trans.cb] = undefined;
14531 delete window[trans.cb];
14534 // if hasn't been loaded, wait for load to remove it to prevent script error
14535 window[trans.cb] = function(){
14536 window[trans.cb] = undefined;
14538 delete window[trans.cb];
14545 handleResponse : function(o, trans){
14546 this.trans = false;
14547 this.destroyTrans(trans, true);
14550 result = trans.reader.readRecords(o);
14552 this.fireEvent("loadexception", this, o, trans.arg, e);
14553 trans.callback.call(trans.scope||window, null, trans.arg, false);
14556 this.fireEvent("load", this, o, trans.arg);
14557 trans.callback.call(trans.scope||window, result, trans.arg, true);
14561 handleFailure : function(trans){
14562 this.trans = false;
14563 this.destroyTrans(trans, false);
14564 this.fireEvent("loadexception", this, null, trans.arg);
14565 trans.callback.call(trans.scope||window, null, trans.arg, false);
14569 * Ext JS Library 1.1.1
14570 * Copyright(c) 2006-2007, Ext JS, LLC.
14572 * Originally Released Under LGPL - original licence link has changed is not relivant.
14575 * <script type="text/javascript">
14579 * @class Roo.data.JsonReader
14580 * @extends Roo.data.DataReader
14581 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
14582 * based on mappings in a provided Roo.data.Record constructor.
14584 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
14585 * in the reply previously.
14590 var RecordDef = Roo.data.Record.create([
14591 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
14592 {name: 'occupation'} // This field will use "occupation" as the mapping.
14594 var myReader = new Roo.data.JsonReader({
14595 totalProperty: "results", // The property which contains the total dataset size (optional)
14596 root: "rows", // The property which contains an Array of row objects
14597 id: "id" // The property within each row object that provides an ID for the record (optional)
14601 * This would consume a JSON file like this:
14603 { 'results': 2, 'rows': [
14604 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
14605 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
14608 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
14609 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
14610 * paged from the remote server.
14611 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
14612 * @cfg {String} root name of the property which contains the Array of row objects.
14613 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
14614 * @cfg {Array} fields Array of field definition objects
14616 * Create a new JsonReader
14617 * @param {Object} meta Metadata configuration options
14618 * @param {Object} recordType Either an Array of field definition objects,
14619 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
14621 Roo.data.JsonReader = function(meta, recordType){
14624 // set some defaults:
14625 Roo.applyIf(meta, {
14626 totalProperty: 'total',
14627 successProperty : 'success',
14632 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
14634 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
14636 readerType : 'Json',
14639 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
14640 * Used by Store query builder to append _requestMeta to params.
14643 metaFromRemote : false,
14645 * This method is only used by a DataProxy which has retrieved data from a remote server.
14646 * @param {Object} response The XHR object which contains the JSON data in its responseText.
14647 * @return {Object} data A data block which is used by an Roo.data.Store object as
14648 * a cache of Roo.data.Records.
14650 read : function(response){
14651 var json = response.responseText;
14653 var o = /* eval:var:o */ eval("("+json+")");
14655 throw {message: "JsonReader.read: Json object not found"};
14661 this.metaFromRemote = true;
14662 this.meta = o.metaData;
14663 this.recordType = Roo.data.Record.create(o.metaData.fields);
14664 this.onMetaChange(this.meta, this.recordType, o);
14666 return this.readRecords(o);
14669 // private function a store will implement
14670 onMetaChange : function(meta, recordType, o){
14677 simpleAccess: function(obj, subsc) {
14684 getJsonAccessor: function(){
14686 return function(expr) {
14688 return(re.test(expr))
14689 ? new Function("obj", "return obj." + expr)
14694 return Roo.emptyFn;
14699 * Create a data block containing Roo.data.Records from an XML document.
14700 * @param {Object} o An object which contains an Array of row objects in the property specified
14701 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
14702 * which contains the total size of the dataset.
14703 * @return {Object} data A data block which is used by an Roo.data.Store object as
14704 * a cache of Roo.data.Records.
14706 readRecords : function(o){
14708 * After any data loads, the raw JSON data is available for further custom processing.
14712 var s = this.meta, Record = this.recordType,
14713 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
14715 // Generate extraction functions for the totalProperty, the root, the id, and for each field
14717 if(s.totalProperty) {
14718 this.getTotal = this.getJsonAccessor(s.totalProperty);
14720 if(s.successProperty) {
14721 this.getSuccess = this.getJsonAccessor(s.successProperty);
14723 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
14725 var g = this.getJsonAccessor(s.id);
14726 this.getId = function(rec) {
14728 return (r === undefined || r === "") ? null : r;
14731 this.getId = function(){return null;};
14734 for(var jj = 0; jj < fl; jj++){
14736 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
14737 this.ef[jj] = this.getJsonAccessor(map);
14741 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
14742 if(s.totalProperty){
14743 var vt = parseInt(this.getTotal(o), 10);
14748 if(s.successProperty){
14749 var vs = this.getSuccess(o);
14750 if(vs === false || vs === 'false'){
14755 for(var i = 0; i < c; i++){
14758 var id = this.getId(n);
14759 for(var j = 0; j < fl; j++){
14761 var v = this.ef[j](n);
14763 Roo.log('missing convert for ' + f.name);
14767 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
14769 var record = new Record(values, id);
14771 records[i] = record;
14777 totalRecords : totalRecords
14780 // used when loading children.. @see loadDataFromChildren
14781 toLoadData: function(rec)
14783 // expect rec just to be an array.. eg [a,b,c, [...] << cn ]
14784 var data = typeof(rec.data.cn) == 'undefined' ? [] : rec.data.cn;
14785 return { data : data, total : data.length };
14790 * Ext JS Library 1.1.1
14791 * Copyright(c) 2006-2007, Ext JS, LLC.
14793 * Originally Released Under LGPL - original licence link has changed is not relivant.
14796 * <script type="text/javascript">
14800 * @class Roo.data.ArrayReader
14801 * @extends Roo.data.DataReader
14802 * Data reader class to create an Array of Roo.data.Record objects from an Array.
14803 * Each element of that Array represents a row of data fields. The
14804 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
14805 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
14809 var RecordDef = Roo.data.Record.create([
14810 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
14811 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
14813 var myReader = new Roo.data.ArrayReader({
14814 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
14818 * This would consume an Array like this:
14820 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
14824 * Create a new JsonReader
14825 * @param {Object} meta Metadata configuration options.
14826 * @param {Object|Array} recordType Either an Array of field definition objects
14828 * @cfg {Array} fields Array of field definition objects
14829 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
14830 * as specified to {@link Roo.data.Record#create},
14831 * or an {@link Roo.data.Record} object
14834 * created using {@link Roo.data.Record#create}.
14836 Roo.data.ArrayReader = function(meta, recordType)
14838 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType||meta.fields);
14841 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
14844 * Create a data block containing Roo.data.Records from an XML document.
14845 * @param {Object} o An Array of row objects which represents the dataset.
14846 * @return {Object} A data block which is used by an {@link Roo.data.Store} object as
14847 * a cache of Roo.data.Records.
14849 readRecords : function(o)
14851 var sid = this.meta ? this.meta.id : null;
14852 var recordType = this.recordType, fields = recordType.prototype.fields;
14855 for(var i = 0; i < root.length; i++){
14858 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
14859 for(var j = 0, jlen = fields.length; j < jlen; j++){
14860 var f = fields.items[j];
14861 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
14862 var v = n[k] !== undefined ? n[k] : f.defaultValue;
14864 values[f.name] = v;
14866 var record = new recordType(values, id);
14868 records[records.length] = record;
14872 totalRecords : records.length
14875 // used when loading children.. @see loadDataFromChildren
14876 toLoadData: function(rec)
14878 // expect rec just to be an array.. eg [a,b,c, [...] << cn ]
14879 return typeof(rec.data.cn) == 'undefined' ? [] : rec.data.cn;
14890 * @class Roo.bootstrap.ComboBox
14891 * @extends Roo.bootstrap.TriggerField
14892 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
14893 * @cfg {Boolean} append (true|false) default false
14894 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
14895 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
14896 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
14897 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
14898 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
14899 * @cfg {Boolean} animate default true
14900 * @cfg {Boolean} emptyResultText only for touch device
14901 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
14902 * @cfg {String} emptyTitle default ''
14903 * @cfg {Number} width fixed with? experimental
14905 * Create a new ComboBox.
14906 * @param {Object} config Configuration options
14908 Roo.bootstrap.ComboBox = function(config){
14909 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
14913 * Fires when the dropdown list is expanded
14914 * @param {Roo.bootstrap.ComboBox} combo This combo box
14919 * Fires when the dropdown list is collapsed
14920 * @param {Roo.bootstrap.ComboBox} combo This combo box
14924 * @event beforeselect
14925 * Fires before a list item is selected. Return false to cancel the selection.
14926 * @param {Roo.bootstrap.ComboBox} combo This combo box
14927 * @param {Roo.data.Record} record The data record returned from the underlying store
14928 * @param {Number} index The index of the selected item in the dropdown list
14930 'beforeselect' : true,
14933 * Fires when a list item is selected
14934 * @param {Roo.bootstrap.ComboBox} combo This combo box
14935 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
14936 * @param {Number} index The index of the selected item in the dropdown list
14940 * @event beforequery
14941 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
14942 * The event object passed has these properties:
14943 * @param {Roo.bootstrap.ComboBox} combo This combo box
14944 * @param {String} query The query
14945 * @param {Boolean} forceAll true to force "all" query
14946 * @param {Boolean} cancel true to cancel the query
14947 * @param {Object} e The query event object
14949 'beforequery': true,
14952 * Fires when the 'add' icon is pressed (add a listener to enable add button)
14953 * @param {Roo.bootstrap.ComboBox} combo This combo box
14958 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
14959 * @param {Roo.bootstrap.ComboBox} combo This combo box
14960 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
14965 * Fires when the remove value from the combobox array
14966 * @param {Roo.bootstrap.ComboBox} combo This combo box
14970 * @event afterremove
14971 * Fires when the remove value from the combobox array
14972 * @param {Roo.bootstrap.ComboBox} combo This combo box
14974 'afterremove' : true,
14976 * @event specialfilter
14977 * Fires when specialfilter
14978 * @param {Roo.bootstrap.ComboBox} combo This combo box
14980 'specialfilter' : true,
14983 * Fires when tick the element
14984 * @param {Roo.bootstrap.ComboBox} combo This combo box
14988 * @event touchviewdisplay
14989 * Fires when touch view require special display (default is using displayField)
14990 * @param {Roo.bootstrap.ComboBox} combo This combo box
14991 * @param {Object} cfg set html .
14993 'touchviewdisplay' : true
14998 this.tickItems = [];
15000 this.selectedIndex = -1;
15001 if(this.mode == 'local'){
15002 if(config.queryDelay === undefined){
15003 this.queryDelay = 10;
15005 if(config.minChars === undefined){
15011 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
15014 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
15015 * rendering into an Roo.Editor, defaults to false)
15018 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
15019 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
15022 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
15025 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
15026 * the dropdown list (defaults to undefined, with no header element)
15030 * @cfg {String/Roo.Template} tpl The template to use to render the output default is '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>'
15034 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
15036 listWidth: undefined,
15038 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
15039 * mode = 'remote' or 'text' if mode = 'local')
15041 displayField: undefined,
15044 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
15045 * mode = 'remote' or 'value' if mode = 'local').
15046 * Note: use of a valueField requires the user make a selection
15047 * in order for a value to be mapped.
15049 valueField: undefined,
15051 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
15056 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
15057 * field's data value (defaults to the underlying DOM element's name)
15059 hiddenName: undefined,
15061 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
15065 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
15067 selectedClass: 'active',
15070 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
15074 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
15075 * anchor positions (defaults to 'tl-bl')
15077 listAlign: 'tl-bl?',
15079 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
15083 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
15084 * query specified by the allQuery config option (defaults to 'query')
15086 triggerAction: 'query',
15088 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
15089 * (defaults to 4, does not apply if editable = false)
15093 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
15094 * delay (typeAheadDelay) if it matches a known value (defaults to false)
15098 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
15099 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
15103 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
15104 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
15108 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
15109 * when editable = true (defaults to false)
15111 selectOnFocus:false,
15113 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
15115 queryParam: 'query',
15117 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
15118 * when mode = 'remote' (defaults to 'Loading...')
15120 loadingText: 'Loading...',
15122 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
15126 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
15130 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
15131 * traditional select (defaults to true)
15135 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
15139 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
15143 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
15144 * listWidth has a higher value)
15148 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
15149 * allow the user to set arbitrary text into the field (defaults to false)
15151 forceSelection:false,
15153 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
15154 * if typeAhead = true (defaults to 250)
15156 typeAheadDelay : 250,
15158 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
15159 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
15161 valueNotFoundText : undefined,
15163 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
15165 blockFocus : false,
15168 * @cfg {Boolean} disableClear Disable showing of clear button.
15170 disableClear : false,
15172 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
15174 alwaysQuery : false,
15177 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
15182 * @cfg {String} invalidClass DEPRICATED - uses BS4 is-valid now
15184 invalidClass : "has-warning",
15187 * @cfg {String} validClass DEPRICATED - uses BS4 is-valid now
15189 validClass : "has-success",
15192 * @cfg {Boolean} specialFilter (true|false) special filter default false
15194 specialFilter : false,
15197 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
15199 mobileTouchView : true,
15202 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
15204 useNativeIOS : false,
15207 * @cfg {Boolean} mobile_restrict_height (true|false) restrict height for touch view
15209 mobile_restrict_height : false,
15211 ios_options : false,
15223 btnPosition : 'right',
15224 triggerList : true,
15225 showToggleBtn : true,
15227 emptyResultText: 'Empty',
15228 triggerText : 'Select',
15232 // element that contains real text value.. (when hidden is used..)
15234 getAutoCreate : function()
15239 * Render classic select for iso
15242 if(Roo.isIOS && this.useNativeIOS){
15243 cfg = this.getAutoCreateNativeIOS();
15251 if(Roo.isTouch && this.mobileTouchView){
15252 cfg = this.getAutoCreateTouchView();
15259 if(!this.tickable){
15260 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
15265 * ComboBox with tickable selections
15268 var align = this.labelAlign || this.parentLabelAlign();
15271 cls : 'form-group roo-combobox-tickable' //input-group
15274 var btn_text_select = '';
15275 var btn_text_done = '';
15276 var btn_text_cancel = '';
15278 if (this.btn_text_show) {
15279 btn_text_select = 'Select';
15280 btn_text_done = 'Done';
15281 btn_text_cancel = 'Cancel';
15286 cls : 'tickable-buttons',
15291 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
15292 //html : this.triggerText
15293 html: btn_text_select
15299 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
15301 html: btn_text_done
15307 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
15309 html: btn_text_cancel
15315 buttons.cn.unshift({
15317 cls: 'roo-select2-search-field-input'
15323 Roo.each(buttons.cn, function(c){
15325 c.cls += ' btn-' + _this.size;
15328 if (_this.disabled) {
15335 style : 'display: contents',
15340 cls: 'form-hidden-field'
15344 cls: 'roo-select2-choices',
15348 cls: 'roo-select2-search-field',
15359 cls: 'roo-select2-container input-group roo-select2-container-multi',
15365 // cls: 'typeahead typeahead-long dropdown-menu',
15366 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
15371 if(this.hasFeedback && !this.allowBlank){
15375 cls: 'glyphicon form-control-feedback'
15378 combobox.cn.push(feedback);
15385 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
15386 tooltip : 'This field is required'
15388 if (Roo.bootstrap.version == 4) {
15391 style : 'display:none'
15394 if (align ==='left' && this.fieldLabel.length) {
15396 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
15403 cls : 'control-label col-form-label',
15404 html : this.fieldLabel
15416 var labelCfg = cfg.cn[1];
15417 var contentCfg = cfg.cn[2];
15420 if(this.indicatorpos == 'right'){
15426 cls : 'control-label col-form-label',
15430 html : this.fieldLabel
15446 labelCfg = cfg.cn[0];
15447 contentCfg = cfg.cn[1];
15451 if(this.labelWidth > 12){
15452 labelCfg.style = "width: " + this.labelWidth + 'px';
15454 if(this.width * 1 > 0){
15455 contentCfg.style = "width: " + this.width + 'px';
15457 if(this.labelWidth < 13 && this.labelmd == 0){
15458 this.labelmd = this.labelWidth;
15461 if(this.labellg > 0){
15462 labelCfg.cls += ' col-lg-' + this.labellg;
15463 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
15466 if(this.labelmd > 0){
15467 labelCfg.cls += ' col-md-' + this.labelmd;
15468 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
15471 if(this.labelsm > 0){
15472 labelCfg.cls += ' col-sm-' + this.labelsm;
15473 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
15476 if(this.labelxs > 0){
15477 labelCfg.cls += ' col-xs-' + this.labelxs;
15478 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
15482 } else if ( this.fieldLabel.length) {
15483 // Roo.log(" label");
15488 //cls : 'input-group-addon',
15489 html : this.fieldLabel
15494 if(this.indicatorpos == 'right'){
15498 //cls : 'input-group-addon',
15499 html : this.fieldLabel
15509 // Roo.log(" no label && no align");
15516 ['xs','sm','md','lg'].map(function(size){
15517 if (settings[size]) {
15518 cfg.cls += ' col-' + size + '-' + settings[size];
15526 _initEventsCalled : false,
15529 initEvents: function()
15531 if (this._initEventsCalled) { // as we call render... prevent looping...
15534 this._initEventsCalled = true;
15537 throw "can not find store for combo";
15540 this.indicator = this.indicatorEl();
15542 this.store = Roo.factory(this.store, Roo.data);
15543 this.store.parent = this;
15545 // if we are building from html. then this element is so complex, that we can not really
15546 // use the rendered HTML.
15547 // so we have to trash and replace the previous code.
15548 if (Roo.XComponent.build_from_html) {
15549 // remove this element....
15550 var e = this.el.dom, k=0;
15551 while (e ) { e = e.previousSibling; ++k;}
15556 this.rendered = false;
15558 this.render(this.parent().getChildContainer(true), k);
15561 if(Roo.isIOS && this.useNativeIOS){
15562 this.initIOSView();
15570 if(Roo.isTouch && this.mobileTouchView){
15571 this.initTouchView();
15576 this.initTickableEvents();
15580 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
15582 if(this.hiddenName){
15584 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
15586 this.hiddenField.dom.value =
15587 this.hiddenValue !== undefined ? this.hiddenValue :
15588 this.value !== undefined ? this.value : '';
15590 // prevent input submission
15591 this.el.dom.removeAttribute('name');
15592 this.hiddenField.dom.setAttribute('name', this.hiddenName);
15597 // this.el.dom.setAttribute('autocomplete', 'off');
15600 var cls = 'x-combo-list';
15602 //this.list = new Roo.Layer({
15603 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
15609 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
15610 _this.list.setWidth(lw);
15613 this.list.on('mouseover', this.onViewOver, this);
15614 this.list.on('mousemove', this.onViewMove, this);
15615 this.list.on('scroll', this.onViewScroll, this);
15618 this.list.swallowEvent('mousewheel');
15619 this.assetHeight = 0;
15622 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
15623 this.assetHeight += this.header.getHeight();
15626 this.innerList = this.list.createChild({cls:cls+'-inner'});
15627 this.innerList.on('mouseover', this.onViewOver, this);
15628 this.innerList.on('mousemove', this.onViewMove, this);
15629 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
15631 if(this.allowBlank && !this.pageSize && !this.disableClear){
15632 this.footer = this.list.createChild({cls:cls+'-ft'});
15633 this.pageTb = new Roo.Toolbar(this.footer);
15637 this.footer = this.list.createChild({cls:cls+'-ft'});
15638 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
15639 {pageSize: this.pageSize});
15643 if (this.pageTb && this.allowBlank && !this.disableClear) {
15645 this.pageTb.add(new Roo.Toolbar.Fill(), {
15646 cls: 'x-btn-icon x-btn-clear',
15648 handler: function()
15651 _this.clearValue();
15652 _this.onSelect(false, -1);
15657 this.assetHeight += this.footer.getHeight();
15662 this.tpl = Roo.bootstrap.version == 4 ?
15663 '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>' : // 4 does not need <li> and it get's really confisued.
15664 '<li><a class="dropdown-item" href="#">{' + this.displayField + '}</a></li>';
15667 this.view = new Roo.View(this.list, this.tpl, {
15668 singleSelect:true, store: this.store, selectedClass: this.selectedClass
15670 //this.view.wrapEl.setDisplayed(false);
15671 this.view.on('click', this.onViewClick, this);
15674 this.store.on('beforeload', this.onBeforeLoad, this);
15675 this.store.on('load', this.onLoad, this);
15676 this.store.on('loadexception', this.onLoadException, this);
15678 if(this.resizable){
15679 this.resizer = new Roo.Resizable(this.list, {
15680 pinned:true, handles:'se'
15682 this.resizer.on('resize', function(r, w, h){
15683 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
15684 this.listWidth = w;
15685 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
15686 this.restrictHeight();
15688 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
15691 if(!this.editable){
15692 this.editable = true;
15693 this.setEditable(false);
15698 if (typeof(this.events.add.listeners) != 'undefined') {
15700 this.addicon = this.wrap.createChild(
15701 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
15703 this.addicon.on('click', function(e) {
15704 this.fireEvent('add', this);
15707 if (typeof(this.events.edit.listeners) != 'undefined') {
15709 this.editicon = this.wrap.createChild(
15710 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
15711 if (this.addicon) {
15712 this.editicon.setStyle('margin-left', '40px');
15714 this.editicon.on('click', function(e) {
15716 // we fire even if inothing is selected..
15717 this.fireEvent('edit', this, this.lastData );
15723 this.keyNav = new Roo.KeyNav(this.inputEl(), {
15724 "up" : function(e){
15725 this.inKeyMode = true;
15729 "down" : function(e){
15730 if(!this.isExpanded()){
15731 this.onTriggerClick();
15733 this.inKeyMode = true;
15738 "enter" : function(e){
15739 // this.onViewClick();
15743 if(this.fireEvent("specialkey", this, e)){
15744 this.onViewClick(false);
15750 "esc" : function(e){
15754 "tab" : function(e){
15757 if(this.fireEvent("specialkey", this, e)){
15758 this.onViewClick(false);
15766 doRelay : function(foo, bar, hname){
15767 if(hname == 'down' || this.scope.isExpanded()){
15768 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
15777 this.queryDelay = Math.max(this.queryDelay || 10,
15778 this.mode == 'local' ? 10 : 250);
15781 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
15783 if(this.typeAhead){
15784 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
15786 if(this.editable !== false){
15787 this.inputEl().on("keyup", this.onKeyUp, this);
15789 if(this.forceSelection){
15790 this.inputEl().on('blur', this.doForce, this);
15794 this.choices = this.el.select('ul.roo-select2-choices', true).first();
15795 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
15799 initTickableEvents: function()
15803 if(this.hiddenName){
15805 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
15807 this.hiddenField.dom.value =
15808 this.hiddenValue !== undefined ? this.hiddenValue :
15809 this.value !== undefined ? this.value : '';
15811 // prevent input submission
15812 this.el.dom.removeAttribute('name');
15813 this.hiddenField.dom.setAttribute('name', this.hiddenName);
15818 // this.list = this.el.select('ul.dropdown-menu',true).first();
15820 this.choices = this.el.select('ul.roo-select2-choices', true).first();
15821 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
15822 if(this.triggerList){
15823 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
15826 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
15827 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
15829 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
15830 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
15832 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
15833 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
15835 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
15836 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
15837 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
15840 this.cancelBtn.hide();
15845 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
15846 _this.list.setWidth(lw);
15849 this.list.on('mouseover', this.onViewOver, this);
15850 this.list.on('mousemove', this.onViewMove, this);
15852 this.list.on('scroll', this.onViewScroll, this);
15855 this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}"' +
15856 'type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
15859 this.view = new Roo.View(this.list, this.tpl, {
15864 selectedClass: this.selectedClass
15867 //this.view.wrapEl.setDisplayed(false);
15868 this.view.on('click', this.onViewClick, this);
15872 this.store.on('beforeload', this.onBeforeLoad, this);
15873 this.store.on('load', this.onLoad, this);
15874 this.store.on('loadexception', this.onLoadException, this);
15877 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
15878 "up" : function(e){
15879 this.inKeyMode = true;
15883 "down" : function(e){
15884 this.inKeyMode = true;
15888 "enter" : function(e){
15889 if(this.fireEvent("specialkey", this, e)){
15890 this.onViewClick(false);
15896 "esc" : function(e){
15897 this.onTickableFooterButtonClick(e, false, false);
15900 "tab" : function(e){
15901 this.fireEvent("specialkey", this, e);
15903 this.onTickableFooterButtonClick(e, false, false);
15910 doRelay : function(e, fn, key){
15911 if(this.scope.isExpanded()){
15912 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
15921 this.queryDelay = Math.max(this.queryDelay || 10,
15922 this.mode == 'local' ? 10 : 250);
15925 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
15927 if(this.typeAhead){
15928 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
15931 if(this.editable !== false){
15932 this.tickableInputEl().on("keyup", this.onKeyUp, this);
15935 this.indicator = this.indicatorEl();
15937 if(this.indicator){
15938 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
15939 this.indicator.hide();
15944 onDestroy : function(){
15946 this.view.setStore(null);
15947 this.view.el.removeAllListeners();
15948 this.view.el.remove();
15949 this.view.purgeListeners();
15952 this.list.dom.innerHTML = '';
15956 this.store.un('beforeload', this.onBeforeLoad, this);
15957 this.store.un('load', this.onLoad, this);
15958 this.store.un('loadexception', this.onLoadException, this);
15960 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
15964 fireKey : function(e){
15965 if(e.isNavKeyPress() && !this.list.isVisible()){
15966 this.fireEvent("specialkey", this, e);
15971 onResize: function(w, h)
15975 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
15977 // if(typeof w != 'number'){
15978 // // we do not handle it!?!?
15981 // var tw = this.trigger.getWidth();
15982 // // tw += this.addicon ? this.addicon.getWidth() : 0;
15983 // // tw += this.editicon ? this.editicon.getWidth() : 0;
15985 // this.inputEl().setWidth( this.adjustWidth('input', x));
15987 // //this.trigger.setStyle('left', x+'px');
15989 // if(this.list && this.listWidth === undefined){
15990 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
15991 // this.list.setWidth(lw);
15992 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
16000 * Allow or prevent the user from directly editing the field text. If false is passed,
16001 * the user will only be able to select from the items defined in the dropdown list. This method
16002 * is the runtime equivalent of setting the 'editable' config option at config time.
16003 * @param {Boolean} value True to allow the user to directly edit the field text
16005 setEditable : function(value){
16006 if(value == this.editable){
16009 this.editable = value;
16011 this.inputEl().dom.setAttribute('readOnly', true);
16012 this.inputEl().on('mousedown', this.onTriggerClick, this);
16013 this.inputEl().addClass('x-combo-noedit');
16015 this.inputEl().dom.setAttribute('readOnly', false);
16016 this.inputEl().un('mousedown', this.onTriggerClick, this);
16017 this.inputEl().removeClass('x-combo-noedit');
16023 onBeforeLoad : function(combo,opts){
16024 if(!this.hasFocus){
16028 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
16030 this.restrictHeight();
16031 this.selectedIndex = -1;
16035 onLoad : function(){
16037 this.hasQuery = false;
16039 if(!this.hasFocus){
16043 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
16044 this.loading.hide();
16047 if(this.store.getCount() > 0){
16050 this.restrictHeight();
16051 if(this.lastQuery == this.allQuery){
16052 if(this.editable && !this.tickable){
16053 this.inputEl().dom.select();
16057 !this.selectByValue(this.value, true) &&
16060 !this.store.lastOptions ||
16061 typeof(this.store.lastOptions.add) == 'undefined' ||
16062 this.store.lastOptions.add != true
16065 this.select(0, true);
16068 if(this.autoFocus){
16071 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
16072 this.taTask.delay(this.typeAheadDelay);
16076 this.onEmptyResults();
16082 onLoadException : function()
16084 this.hasQuery = false;
16086 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
16087 this.loading.hide();
16090 if(this.tickable && this.editable){
16095 // only causes errors at present
16096 //Roo.log(this.store.reader.jsonData);
16097 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
16099 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
16105 onTypeAhead : function(){
16106 if(this.store.getCount() > 0){
16107 var r = this.store.getAt(0);
16108 var newValue = r.data[this.displayField];
16109 var len = newValue.length;
16110 var selStart = this.getRawValue().length;
16112 if(selStart != len){
16113 this.setRawValue(newValue);
16114 this.selectText(selStart, newValue.length);
16120 onSelect : function(record, index){
16122 if(this.fireEvent('beforeselect', this, record, index) !== false){
16124 this.setFromData(index > -1 ? record.data : false);
16127 this.fireEvent('select', this, record, index);
16132 * Returns the currently selected field value or empty string if no value is set.
16133 * @return {String} value The selected value
16135 getValue : function()
16137 if(Roo.isIOS && this.useNativeIOS){
16138 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
16142 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
16145 if(this.valueField){
16146 return typeof this.value != 'undefined' ? this.value : '';
16148 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
16152 getRawValue : function()
16154 if(Roo.isIOS && this.useNativeIOS){
16155 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
16158 var v = this.inputEl().getValue();
16164 * Clears any text/value currently set in the field
16166 clearValue : function(){
16168 if(this.hiddenField){
16169 this.hiddenField.dom.value = '';
16172 this.setRawValue('');
16173 this.lastSelectionText = '';
16174 this.lastData = false;
16176 var close = this.closeTriggerEl();
16187 * Sets the specified value into the field. If the value finds a match, the corresponding record text
16188 * will be displayed in the field. If the value does not match the data value of an existing item,
16189 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
16190 * Otherwise the field will be blank (although the value will still be set).
16191 * @param {String} value The value to match
16193 setValue : function(v)
16195 if(Roo.isIOS && this.useNativeIOS){
16196 this.setIOSValue(v);
16206 if(this.valueField){
16207 var r = this.findRecord(this.valueField, v);
16209 text = r.data[this.displayField];
16210 }else if(this.valueNotFoundText !== undefined){
16211 text = this.valueNotFoundText;
16214 this.lastSelectionText = text;
16215 if(this.hiddenField){
16216 this.hiddenField.dom.value = v;
16218 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
16221 var close = this.closeTriggerEl();
16224 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
16230 * @property {Object} the last set data for the element
16235 * Sets the value of the field based on a object which is related to the record format for the store.
16236 * @param {Object} value the value to set as. or false on reset?
16238 setFromData : function(o){
16245 var dv = ''; // display value
16246 var vv = ''; // value value..
16248 if (this.displayField) {
16249 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
16251 // this is an error condition!!!
16252 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
16255 if(this.valueField){
16256 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
16259 var close = this.closeTriggerEl();
16262 if(dv.length || vv * 1 > 0){
16264 this.blockFocus=true;
16270 if(this.hiddenField){
16271 this.hiddenField.dom.value = vv;
16273 this.lastSelectionText = dv;
16274 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
16278 // no hidden field.. - we store the value in 'value', but still display
16279 // display field!!!!
16280 this.lastSelectionText = dv;
16281 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
16288 reset : function(){
16289 // overridden so that last data is reset..
16296 this.setValue(this.originalValue);
16297 //this.clearInvalid();
16298 this.lastData = false;
16300 this.view.clearSelections();
16306 findRecord : function(prop, value){
16308 if(this.store.getCount() > 0){
16309 this.store.each(function(r){
16310 if(r.data[prop] == value){
16320 getName: function()
16322 // returns hidden if it's set..
16323 if (!this.rendered) {return ''};
16324 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
16328 onViewMove : function(e, t){
16329 this.inKeyMode = false;
16333 onViewOver : function(e, t){
16334 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
16337 var item = this.view.findItemFromChild(t);
16340 var index = this.view.indexOf(item);
16341 this.select(index, false);
16346 onViewClick : function(view, doFocus, el, e)
16348 var index = this.view.getSelectedIndexes()[0];
16350 var r = this.store.getAt(index);
16354 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
16361 Roo.each(this.tickItems, function(v,k){
16363 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
16365 _this.tickItems.splice(k, 1);
16367 if(typeof(e) == 'undefined' && view == false){
16368 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
16380 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
16381 this.tickItems.push(r.data);
16384 if(typeof(e) == 'undefined' && view == false){
16385 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
16392 this.onSelect(r, index);
16394 if(doFocus !== false && !this.blockFocus){
16395 this.inputEl().focus();
16400 restrictHeight : function(){
16401 //this.innerList.dom.style.height = '';
16402 //var inner = this.innerList.dom;
16403 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
16404 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
16405 //this.list.beginUpdate();
16406 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
16407 this.list.alignTo(this.inputEl(), this.listAlign);
16408 this.list.alignTo(this.inputEl(), this.listAlign);
16409 //this.list.endUpdate();
16413 onEmptyResults : function(){
16415 if(this.tickable && this.editable){
16416 this.hasFocus = false;
16417 this.restrictHeight();
16425 * Returns true if the dropdown list is expanded, else false.
16427 isExpanded : function(){
16428 return this.list.isVisible();
16432 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
16433 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
16434 * @param {String} value The data value of the item to select
16435 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
16436 * selected item if it is not currently in view (defaults to true)
16437 * @return {Boolean} True if the value matched an item in the list, else false
16439 selectByValue : function(v, scrollIntoView){
16440 if(v !== undefined && v !== null){
16441 var r = this.findRecord(this.valueField || this.displayField, v);
16443 this.select(this.store.indexOf(r), scrollIntoView);
16451 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
16452 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
16453 * @param {Number} index The zero-based index of the list item to select
16454 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
16455 * selected item if it is not currently in view (defaults to true)
16457 select : function(index, scrollIntoView){
16458 this.selectedIndex = index;
16459 this.view.select(index);
16460 if(scrollIntoView !== false){
16461 var el = this.view.getNode(index);
16463 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
16466 this.list.scrollChildIntoView(el, false);
16472 selectNext : function(){
16473 var ct = this.store.getCount();
16475 if(this.selectedIndex == -1){
16477 }else if(this.selectedIndex < ct-1){
16478 this.select(this.selectedIndex+1);
16484 selectPrev : function(){
16485 var ct = this.store.getCount();
16487 if(this.selectedIndex == -1){
16489 }else if(this.selectedIndex != 0){
16490 this.select(this.selectedIndex-1);
16496 onKeyUp : function(e){
16497 if(this.editable !== false && !e.isSpecialKey()){
16498 this.lastKey = e.getKey();
16499 this.dqTask.delay(this.queryDelay);
16504 validateBlur : function(){
16505 return !this.list || !this.list.isVisible();
16509 initQuery : function(){
16511 var v = this.getRawValue();
16513 if(this.tickable && this.editable){
16514 v = this.tickableInputEl().getValue();
16521 doForce : function(){
16522 if(this.inputEl().dom.value.length > 0){
16523 this.inputEl().dom.value =
16524 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
16530 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
16531 * query allowing the query action to be canceled if needed.
16532 * @param {String} query The SQL query to execute
16533 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
16534 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
16535 * saved in the current store (defaults to false)
16537 doQuery : function(q, forceAll){
16539 if(q === undefined || q === null){
16544 forceAll: forceAll,
16548 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
16553 forceAll = qe.forceAll;
16554 if(forceAll === true || (q.length >= this.minChars)){
16556 this.hasQuery = true;
16558 if(this.lastQuery != q || this.alwaysQuery){
16559 this.lastQuery = q;
16560 if(this.mode == 'local'){
16561 this.selectedIndex = -1;
16563 this.store.clearFilter();
16566 if(this.specialFilter){
16567 this.fireEvent('specialfilter', this);
16572 this.store.filter(this.displayField, q);
16575 this.store.fireEvent("datachanged", this.store);
16582 this.store.baseParams[this.queryParam] = q;
16584 var options = {params : this.getParams(q)};
16587 options.add = true;
16588 options.params.start = this.page * this.pageSize;
16591 this.store.load(options);
16594 * this code will make the page width larger, at the beginning, the list not align correctly,
16595 * we should expand the list on onLoad
16596 * so command out it
16601 this.selectedIndex = -1;
16606 this.loadNext = false;
16610 getParams : function(q){
16612 //p[this.queryParam] = q;
16616 p.limit = this.pageSize;
16622 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
16624 collapse : function(){
16625 if(!this.isExpanded()){
16631 this.hasFocus = false;
16635 this.cancelBtn.hide();
16636 this.trigger.show();
16639 this.tickableInputEl().dom.value = '';
16640 this.tickableInputEl().blur();
16645 Roo.get(document).un('mousedown', this.collapseIf, this);
16646 Roo.get(document).un('mousewheel', this.collapseIf, this);
16647 if (!this.editable) {
16648 Roo.get(document).un('keydown', this.listKeyPress, this);
16650 this.fireEvent('collapse', this);
16656 collapseIf : function(e){
16657 var in_combo = e.within(this.el);
16658 var in_list = e.within(this.list);
16659 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
16661 if (in_combo || in_list || is_list) {
16662 //e.stopPropagation();
16667 this.onTickableFooterButtonClick(e, false, false);
16675 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
16677 expand : function(){
16679 if(this.isExpanded() || !this.hasFocus){
16683 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
16684 this.list.setWidth(lw);
16690 this.restrictHeight();
16694 this.tickItems = Roo.apply([], this.item);
16697 this.cancelBtn.show();
16698 this.trigger.hide();
16701 this.tickableInputEl().focus();
16706 Roo.get(document).on('mousedown', this.collapseIf, this);
16707 Roo.get(document).on('mousewheel', this.collapseIf, this);
16708 if (!this.editable) {
16709 Roo.get(document).on('keydown', this.listKeyPress, this);
16712 this.fireEvent('expand', this);
16716 // Implements the default empty TriggerField.onTriggerClick function
16717 onTriggerClick : function(e)
16719 Roo.log('trigger click');
16721 if(this.disabled || !this.triggerList){
16726 this.loadNext = false;
16728 if(this.isExpanded()){
16730 if (!this.blockFocus) {
16731 this.inputEl().focus();
16735 this.hasFocus = true;
16736 if(this.triggerAction == 'all') {
16737 this.doQuery(this.allQuery, true);
16739 this.doQuery(this.getRawValue());
16741 if (!this.blockFocus) {
16742 this.inputEl().focus();
16747 onTickableTriggerClick : function(e)
16754 this.loadNext = false;
16755 this.hasFocus = true;
16757 if(this.triggerAction == 'all') {
16758 this.doQuery(this.allQuery, true);
16760 this.doQuery(this.getRawValue());
16764 onSearchFieldClick : function(e)
16766 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
16767 this.onTickableFooterButtonClick(e, false, false);
16771 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
16776 this.loadNext = false;
16777 this.hasFocus = true;
16779 if(this.triggerAction == 'all') {
16780 this.doQuery(this.allQuery, true);
16782 this.doQuery(this.getRawValue());
16786 listKeyPress : function(e)
16788 //Roo.log('listkeypress');
16789 // scroll to first matching element based on key pres..
16790 if (e.isSpecialKey()) {
16793 var k = String.fromCharCode(e.getKey()).toUpperCase();
16796 var csel = this.view.getSelectedNodes();
16797 var cselitem = false;
16799 var ix = this.view.indexOf(csel[0]);
16800 cselitem = this.store.getAt(ix);
16801 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
16807 this.store.each(function(v) {
16809 // start at existing selection.
16810 if (cselitem.id == v.id) {
16816 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
16817 match = this.store.indexOf(v);
16823 if (match === false) {
16824 return true; // no more action?
16827 this.view.select(match);
16828 var sn = Roo.get(this.view.getSelectedNodes()[0]);
16829 sn.scrollIntoView(sn.dom.parentNode, false);
16832 onViewScroll : function(e, t){
16834 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){
16838 this.hasQuery = true;
16840 this.loading = this.list.select('.loading', true).first();
16842 if(this.loading === null){
16843 this.list.createChild({
16845 cls: 'loading roo-select2-more-results roo-select2-active',
16846 html: 'Loading more results...'
16849 this.loading = this.list.select('.loading', true).first();
16851 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
16853 this.loading.hide();
16856 this.loading.show();
16861 this.loadNext = true;
16863 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
16868 addItem : function(o)
16870 var dv = ''; // display value
16872 if (this.displayField) {
16873 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
16875 // this is an error condition!!!
16876 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
16883 var choice = this.choices.createChild({
16885 cls: 'roo-select2-search-choice',
16894 cls: 'roo-select2-search-choice-close fa fa-times',
16899 }, this.searchField);
16901 var close = choice.select('a.roo-select2-search-choice-close', true).first();
16903 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
16911 this.inputEl().dom.value = '';
16916 onRemoveItem : function(e, _self, o)
16918 e.preventDefault();
16920 this.lastItem = Roo.apply([], this.item);
16922 var index = this.item.indexOf(o.data) * 1;
16925 Roo.log('not this item?!');
16929 this.item.splice(index, 1);
16934 this.fireEvent('remove', this, e);
16940 syncValue : function()
16942 if(!this.item.length){
16949 Roo.each(this.item, function(i){
16950 if(_this.valueField){
16951 value.push(i[_this.valueField]);
16958 this.value = value.join(',');
16960 if(this.hiddenField){
16961 this.hiddenField.dom.value = this.value;
16964 this.store.fireEvent("datachanged", this.store);
16969 clearItem : function()
16971 if(!this.multiple){
16977 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
16985 if(this.tickable && !Roo.isTouch){
16986 this.view.refresh();
16990 inputEl: function ()
16992 if(Roo.isIOS && this.useNativeIOS){
16993 return this.el.select('select.roo-ios-select', true).first();
16996 if(Roo.isTouch && this.mobileTouchView){
16997 return this.el.select('input.form-control',true).first();
17001 return this.searchField;
17004 return this.el.select('input.form-control',true).first();
17007 onTickableFooterButtonClick : function(e, btn, el)
17009 e.preventDefault();
17011 this.lastItem = Roo.apply([], this.item);
17013 if(btn && btn.name == 'cancel'){
17014 this.tickItems = Roo.apply([], this.item);
17023 Roo.each(this.tickItems, function(o){
17031 validate : function()
17033 if(this.getVisibilityEl().hasClass('hidden')){
17037 var v = this.getRawValue();
17040 v = this.getValue();
17043 if(this.disabled || this.allowBlank || v.length){
17048 this.markInvalid();
17052 tickableInputEl : function()
17054 if(!this.tickable || !this.editable){
17055 return this.inputEl();
17058 return this.inputEl().select('.roo-select2-search-field-input', true).first();
17062 getAutoCreateTouchView : function()
17067 cls: 'form-group' //input-group
17073 type : this.inputType,
17074 cls : 'form-control x-combo-noedit',
17075 autocomplete: 'new-password',
17076 placeholder : this.placeholder || '',
17081 input.name = this.name;
17085 input.cls += ' input-' + this.size;
17088 if (this.disabled) {
17089 input.disabled = true;
17093 cls : 'roo-combobox-wrap',
17100 inputblock.cls += ' input-group';
17102 inputblock.cn.unshift({
17104 cls : 'input-group-addon input-group-prepend input-group-text',
17109 if(this.removable && !this.multiple){
17110 inputblock.cls += ' roo-removable';
17112 inputblock.cn.push({
17115 cls : 'roo-combo-removable-btn close'
17119 if(this.hasFeedback && !this.allowBlank){
17121 inputblock.cls += ' has-feedback';
17123 inputblock.cn.push({
17125 cls: 'glyphicon form-control-feedback'
17132 inputblock.cls += (this.before) ? '' : ' input-group';
17134 inputblock.cn.push({
17136 cls : 'input-group-addon input-group-append input-group-text',
17142 var ibwrap = inputblock;
17147 cls: 'roo-select2-choices',
17151 cls: 'roo-select2-search-field',
17164 cls: 'roo-select2-container input-group roo-touchview-combobox ',
17169 cls: 'form-hidden-field'
17175 if(!this.multiple && this.showToggleBtn){
17181 if (this.caret != false) {
17184 cls: 'fa fa-' + this.caret
17191 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
17193 Roo.bootstrap.version == 3 ? caret : '',
17196 cls: 'combobox-clear',
17210 combobox.cls += ' roo-select2-container-multi';
17213 var align = this.labelAlign || this.parentLabelAlign();
17215 if (align ==='left' && this.fieldLabel.length) {
17220 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
17221 tooltip : 'This field is required'
17225 cls : 'control-label col-form-label',
17226 html : this.fieldLabel
17230 cls : 'roo-combobox-wrap ',
17237 var labelCfg = cfg.cn[1];
17238 var contentCfg = cfg.cn[2];
17241 if(this.indicatorpos == 'right'){
17246 cls : 'control-label col-form-label',
17250 html : this.fieldLabel
17254 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
17255 tooltip : 'This field is required'
17260 cls : "roo-combobox-wrap ",
17268 labelCfg = cfg.cn[0];
17269 contentCfg = cfg.cn[1];
17274 if(this.labelWidth > 12){
17275 labelCfg.style = "width: " + this.labelWidth + 'px';
17278 if(this.labelWidth < 13 && this.labelmd == 0){
17279 this.labelmd = this.labelWidth;
17282 if(this.labellg > 0){
17283 labelCfg.cls += ' col-lg-' + this.labellg;
17284 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
17287 if(this.labelmd > 0){
17288 labelCfg.cls += ' col-md-' + this.labelmd;
17289 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
17292 if(this.labelsm > 0){
17293 labelCfg.cls += ' col-sm-' + this.labelsm;
17294 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
17297 if(this.labelxs > 0){
17298 labelCfg.cls += ' col-xs-' + this.labelxs;
17299 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
17303 } else if ( this.fieldLabel.length) {
17307 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
17308 tooltip : 'This field is required'
17312 cls : 'control-label',
17313 html : this.fieldLabel
17324 if(this.indicatorpos == 'right'){
17328 cls : 'control-label',
17329 html : this.fieldLabel,
17333 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
17334 tooltip : 'This field is required'
17351 var settings = this;
17353 ['xs','sm','md','lg'].map(function(size){
17354 if (settings[size]) {
17355 cfg.cls += ' col-' + size + '-' + settings[size];
17362 initTouchView : function()
17364 this.renderTouchView();
17366 this.touchViewEl.on('scroll', function(){
17367 this.el.dom.scrollTop = 0;
17370 this.originalValue = this.getValue();
17372 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
17374 this.inputEl().on("click", this.showTouchView, this);
17375 if (this.triggerEl) {
17376 this.triggerEl.on("click", this.showTouchView, this);
17380 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
17381 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
17383 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
17385 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
17386 this.store.on('load', this.onTouchViewLoad, this);
17387 this.store.on('loadexception', this.onTouchViewLoadException, this);
17389 if(this.hiddenName){
17391 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
17393 this.hiddenField.dom.value =
17394 this.hiddenValue !== undefined ? this.hiddenValue :
17395 this.value !== undefined ? this.value : '';
17397 this.el.dom.removeAttribute('name');
17398 this.hiddenField.dom.setAttribute('name', this.hiddenName);
17402 this.choices = this.el.select('ul.roo-select2-choices', true).first();
17403 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
17406 if(this.removable && !this.multiple){
17407 var close = this.closeTriggerEl();
17409 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
17410 close.on('click', this.removeBtnClick, this, close);
17414 * fix the bug in Safari iOS8
17416 this.inputEl().on("focus", function(e){
17417 document.activeElement.blur();
17420 this._touchViewMask = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
17427 renderTouchView : function()
17429 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
17430 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
17432 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
17433 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
17435 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
17436 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
17437 this.touchViewBodyEl.setStyle('overflow', 'auto');
17439 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
17440 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
17442 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
17443 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
17447 showTouchView : function()
17453 this.touchViewHeaderEl.hide();
17455 if(this.modalTitle.length){
17456 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
17457 this.touchViewHeaderEl.show();
17460 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
17461 this.touchViewEl.show();
17463 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
17465 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
17466 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
17468 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
17470 if(this.modalTitle.length){
17471 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
17474 this.touchViewBodyEl.setHeight(bodyHeight);
17478 (function(){ _this.touchViewEl.addClass(['in','show']); }).defer(50);
17480 this.touchViewEl.addClass(['in','show']);
17483 if(this._touchViewMask){
17484 Roo.get(document.body).addClass("x-body-masked");
17485 this._touchViewMask.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
17486 this._touchViewMask.setStyle('z-index', 10000);
17487 this._touchViewMask.addClass('show');
17490 this.doTouchViewQuery();
17494 hideTouchView : function()
17496 this.touchViewEl.removeClass(['in','show']);
17500 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
17502 this.touchViewEl.setStyle('display', 'none');
17505 if(this._touchViewMask){
17506 this._touchViewMask.removeClass('show');
17507 Roo.get(document.body).removeClass("x-body-masked");
17511 setTouchViewValue : function()
17518 Roo.each(this.tickItems, function(o){
17523 this.hideTouchView();
17526 doTouchViewQuery : function()
17535 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
17539 if(!this.alwaysQuery || this.mode == 'local'){
17540 this.onTouchViewLoad();
17547 onTouchViewBeforeLoad : function(combo,opts)
17553 onTouchViewLoad : function()
17555 if(this.store.getCount() < 1){
17556 this.onTouchViewEmptyResults();
17560 this.clearTouchView();
17562 var rawValue = this.getRawValue();
17564 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
17566 this.tickItems = [];
17568 this.store.data.each(function(d, rowIndex){
17569 var row = this.touchViewListGroup.createChild(template);
17571 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
17572 row.addClass(d.data.cls);
17575 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
17578 html : d.data[this.displayField]
17581 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
17582 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
17585 row.removeClass('selected');
17586 if(!this.multiple && this.valueField &&
17587 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
17590 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
17591 row.addClass('selected');
17594 if(this.multiple && this.valueField &&
17595 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
17599 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
17600 this.tickItems.push(d.data);
17603 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
17607 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
17609 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
17611 if(this.modalTitle.length){
17612 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
17615 var listHeight = this.touchViewListGroup.getHeight() + this.touchViewBodyEl.getPadding('tb') * 2;
17617 if(this.mobile_restrict_height && listHeight < bodyHeight){
17618 this.touchViewBodyEl.setHeight(listHeight);
17623 if(firstChecked && listHeight > bodyHeight){
17624 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
17629 onTouchViewLoadException : function()
17631 this.hideTouchView();
17634 onTouchViewEmptyResults : function()
17636 this.clearTouchView();
17638 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
17640 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
17644 clearTouchView : function()
17646 this.touchViewListGroup.dom.innerHTML = '';
17649 onTouchViewClick : function(e, el, o)
17651 e.preventDefault();
17654 var rowIndex = o.rowIndex;
17656 var r = this.store.getAt(rowIndex);
17658 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
17660 if(!this.multiple){
17661 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
17662 c.dom.removeAttribute('checked');
17665 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
17667 this.setFromData(r.data);
17669 var close = this.closeTriggerEl();
17675 this.hideTouchView();
17677 this.fireEvent('select', this, r, rowIndex);
17682 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
17683 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
17684 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
17688 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
17689 this.addItem(r.data);
17690 this.tickItems.push(r.data);
17694 getAutoCreateNativeIOS : function()
17697 cls: 'form-group' //input-group,
17702 cls : 'roo-ios-select'
17706 combobox.name = this.name;
17709 if (this.disabled) {
17710 combobox.disabled = true;
17713 var settings = this;
17715 ['xs','sm','md','lg'].map(function(size){
17716 if (settings[size]) {
17717 cfg.cls += ' col-' + size + '-' + settings[size];
17727 initIOSView : function()
17729 this.store.on('load', this.onIOSViewLoad, this);
17734 onIOSViewLoad : function()
17736 if(this.store.getCount() < 1){
17740 this.clearIOSView();
17742 if(this.allowBlank) {
17744 var default_text = '-- SELECT --';
17746 if(this.placeholder.length){
17747 default_text = this.placeholder;
17750 if(this.emptyTitle.length){
17751 default_text += ' - ' + this.emptyTitle + ' -';
17754 var opt = this.inputEl().createChild({
17757 html : default_text
17761 o[this.valueField] = 0;
17762 o[this.displayField] = default_text;
17764 this.ios_options.push({
17771 this.store.data.each(function(d, rowIndex){
17775 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
17776 html = d.data[this.displayField];
17781 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
17782 value = d.data[this.valueField];
17791 if(this.value == d.data[this.valueField]){
17792 option['selected'] = true;
17795 var opt = this.inputEl().createChild(option);
17797 this.ios_options.push({
17804 this.inputEl().on('change', function(){
17805 this.fireEvent('select', this);
17810 clearIOSView: function()
17812 this.inputEl().dom.innerHTML = '';
17814 this.ios_options = [];
17817 setIOSValue: function(v)
17821 if(!this.ios_options){
17825 Roo.each(this.ios_options, function(opts){
17827 opts.el.dom.removeAttribute('selected');
17829 if(opts.data[this.valueField] != v){
17833 opts.el.dom.setAttribute('selected', true);
17839 * @cfg {Boolean} grow
17843 * @cfg {Number} growMin
17847 * @cfg {Number} growMax
17856 Roo.apply(Roo.bootstrap.ComboBox, {
17860 cls: 'modal-header',
17882 cls: 'list-group-item',
17886 cls: 'roo-combobox-list-group-item-value'
17890 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
17904 listItemCheckbox : {
17906 cls: 'list-group-item',
17910 cls: 'roo-combobox-list-group-item-value'
17914 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
17930 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
17935 cls: 'modal-footer',
17943 cls: 'col-xs-6 text-left',
17946 cls: 'btn btn-danger roo-touch-view-cancel',
17952 cls: 'col-xs-6 text-right',
17955 cls: 'btn btn-success roo-touch-view-ok',
17966 Roo.apply(Roo.bootstrap.ComboBox, {
17968 touchViewTemplate : {
17970 cls: 'modal fade roo-combobox-touch-view',
17974 cls: 'modal-dialog',
17975 style : 'position:fixed', // we have to fix position....
17979 cls: 'modal-content',
17981 Roo.bootstrap.ComboBox.header,
17982 Roo.bootstrap.ComboBox.body,
17983 Roo.bootstrap.ComboBox.footer
17992 * Ext JS Library 1.1.1
17993 * Copyright(c) 2006-2007, Ext JS, LLC.
17995 * Originally Released Under LGPL - original licence link has changed is not relivant.
17998 * <script type="text/javascript">
18003 * @extends Roo.util.Observable
18004 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
18005 * This class also supports single and multi selection modes. <br>
18006 * Create a data model bound view:
18008 var store = new Roo.data.Store(...);
18010 var view = new Roo.View({
18012 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
18014 singleSelect: true,
18015 selectedClass: "ydataview-selected",
18019 // listen for node click?
18020 view.on("click", function(vw, index, node, e){
18021 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
18025 dataModel.load("foobar.xml");
18027 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
18029 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
18030 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
18032 * Note: old style constructor is still suported (container, template, config)
18035 * Create a new View
18036 * @param {Object} config The config object
18039 Roo.View = function(config, depreciated_tpl, depreciated_config){
18041 this.parent = false;
18043 if (typeof(depreciated_tpl) == 'undefined') {
18044 // new way.. - universal constructor.
18045 Roo.apply(this, config);
18046 this.el = Roo.get(this.el);
18049 this.el = Roo.get(config);
18050 this.tpl = depreciated_tpl;
18051 Roo.apply(this, depreciated_config);
18053 this.wrapEl = this.el.wrap().wrap();
18054 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
18057 if(typeof(this.tpl) == "string"){
18058 this.tpl = new Roo.Template(this.tpl);
18060 // support xtype ctors..
18061 this.tpl = new Roo.factory(this.tpl, Roo);
18065 this.tpl.compile();
18070 * @event beforeclick
18071 * Fires before a click is processed. Returns false to cancel the default action.
18072 * @param {Roo.View} this
18073 * @param {Number} index The index of the target node
18074 * @param {HTMLElement} node The target node
18075 * @param {Roo.EventObject} e The raw event object
18077 "beforeclick" : true,
18080 * Fires when a template node is clicked.
18081 * @param {Roo.View} this
18082 * @param {Number} index The index of the target node
18083 * @param {HTMLElement} node The target node
18084 * @param {Roo.EventObject} e The raw event object
18089 * Fires when a template node is double clicked.
18090 * @param {Roo.View} this
18091 * @param {Number} index The index of the target node
18092 * @param {HTMLElement} node The target node
18093 * @param {Roo.EventObject} e The raw event object
18097 * @event contextmenu
18098 * Fires when a template node is right clicked.
18099 * @param {Roo.View} this
18100 * @param {Number} index The index of the target node
18101 * @param {HTMLElement} node The target node
18102 * @param {Roo.EventObject} e The raw event object
18104 "contextmenu" : true,
18106 * @event selectionchange
18107 * Fires when the selected nodes change.
18108 * @param {Roo.View} this
18109 * @param {Array} selections Array of the selected nodes
18111 "selectionchange" : true,
18114 * @event beforeselect
18115 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
18116 * @param {Roo.View} this
18117 * @param {HTMLElement} node The node to be selected
18118 * @param {Array} selections Array of currently selected nodes
18120 "beforeselect" : true,
18122 * @event preparedata
18123 * Fires on every row to render, to allow you to change the data.
18124 * @param {Roo.View} this
18125 * @param {Object} data to be rendered (change this)
18127 "preparedata" : true
18135 "click": this.onClick,
18136 "dblclick": this.onDblClick,
18137 "contextmenu": this.onContextMenu,
18141 this.selections = [];
18143 this.cmp = new Roo.CompositeElementLite([]);
18145 this.store = Roo.factory(this.store, Roo.data);
18146 this.setStore(this.store, true);
18149 if ( this.footer && this.footer.xtype) {
18151 var fctr = this.wrapEl.appendChild(document.createElement("div"));
18153 this.footer.dataSource = this.store;
18154 this.footer.container = fctr;
18155 this.footer = Roo.factory(this.footer, Roo);
18156 fctr.insertFirst(this.el);
18158 // this is a bit insane - as the paging toolbar seems to detach the el..
18159 // dom.parentNode.parentNode.parentNode
18160 // they get detached?
18164 Roo.View.superclass.constructor.call(this);
18169 Roo.extend(Roo.View, Roo.util.Observable, {
18172 * @cfg {Roo.data.Store} store Data store to load data from.
18177 * @cfg {String|Roo.Element} el The container element.
18182 * @cfg {String|Roo.Template} tpl The template used by this View
18186 * @cfg {String} dataName the named area of the template to use as the data area
18187 * Works with domtemplates roo-name="name"
18191 * @cfg {String} selectedClass The css class to add to selected nodes
18193 selectedClass : "x-view-selected",
18195 * @cfg {String} emptyText The empty text to show when nothing is loaded.
18200 * @cfg {String} text to display on mask (default Loading)
18204 * @cfg {Boolean} multiSelect Allow multiple selection
18206 multiSelect : false,
18208 * @cfg {Boolean} singleSelect Allow single selection
18210 singleSelect: false,
18213 * @cfg {Boolean} toggleSelect - selecting
18215 toggleSelect : false,
18218 * @cfg {Boolean} tickable - selecting
18223 * Returns the element this view is bound to.
18224 * @return {Roo.Element}
18226 getEl : function(){
18227 return this.wrapEl;
18233 * Refreshes the view. - called by datachanged on the store. - do not call directly.
18235 refresh : function(){
18236 //Roo.log('refresh');
18239 // if we are using something like 'domtemplate', then
18240 // the what gets used is:
18241 // t.applySubtemplate(NAME, data, wrapping data..)
18242 // the outer template then get' applied with
18243 // the store 'extra data'
18244 // and the body get's added to the
18245 // roo-name="data" node?
18246 // <span class='roo-tpl-{name}'></span> ?????
18250 this.clearSelections();
18251 this.el.update("");
18253 var records = this.store.getRange();
18254 if(records.length < 1) {
18256 // is this valid?? = should it render a template??
18258 this.el.update(this.emptyText);
18262 if (this.dataName) {
18263 this.el.update(t.apply(this.store.meta)); //????
18264 el = this.el.child('.roo-tpl-' + this.dataName);
18267 for(var i = 0, len = records.length; i < len; i++){
18268 var data = this.prepareData(records[i].data, i, records[i]);
18269 this.fireEvent("preparedata", this, data, i, records[i]);
18271 var d = Roo.apply({}, data);
18274 Roo.apply(d, {'roo-id' : Roo.id()});
18278 Roo.each(this.parent.item, function(item){
18279 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
18282 Roo.apply(d, {'roo-data-checked' : 'checked'});
18286 html[html.length] = Roo.util.Format.trim(
18288 t.applySubtemplate(this.dataName, d, this.store.meta) :
18295 el.update(html.join(""));
18296 this.nodes = el.dom.childNodes;
18297 this.updateIndexes(0);
18302 * Function to override to reformat the data that is sent to
18303 * the template for each node.
18304 * DEPRICATED - use the preparedata event handler.
18305 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
18306 * a JSON object for an UpdateManager bound view).
18308 prepareData : function(data, index, record)
18310 this.fireEvent("preparedata", this, data, index, record);
18314 onUpdate : function(ds, record){
18315 // Roo.log('on update');
18316 this.clearSelections();
18317 var index = this.store.indexOf(record);
18318 var n = this.nodes[index];
18319 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
18320 n.parentNode.removeChild(n);
18321 this.updateIndexes(index, index);
18327 onAdd : function(ds, records, index)
18329 //Roo.log(['on Add', ds, records, index] );
18330 this.clearSelections();
18331 if(this.nodes.length == 0){
18335 var n = this.nodes[index];
18336 for(var i = 0, len = records.length; i < len; i++){
18337 var d = this.prepareData(records[i].data, i, records[i]);
18339 this.tpl.insertBefore(n, d);
18342 this.tpl.append(this.el, d);
18345 this.updateIndexes(index);
18348 onRemove : function(ds, record, index){
18349 // Roo.log('onRemove');
18350 this.clearSelections();
18351 var el = this.dataName ?
18352 this.el.child('.roo-tpl-' + this.dataName) :
18355 el.dom.removeChild(this.nodes[index]);
18356 this.updateIndexes(index);
18360 * Refresh an individual node.
18361 * @param {Number} index
18363 refreshNode : function(index){
18364 this.onUpdate(this.store, this.store.getAt(index));
18367 updateIndexes : function(startIndex, endIndex){
18368 var ns = this.nodes;
18369 startIndex = startIndex || 0;
18370 endIndex = endIndex || ns.length - 1;
18371 for(var i = startIndex; i <= endIndex; i++){
18372 ns[i].nodeIndex = i;
18377 * Changes the data store this view uses and refresh the view.
18378 * @param {Store} store
18380 setStore : function(store, initial){
18381 if(!initial && this.store){
18382 this.store.un("datachanged", this.refresh);
18383 this.store.un("add", this.onAdd);
18384 this.store.un("remove", this.onRemove);
18385 this.store.un("update", this.onUpdate);
18386 this.store.un("clear", this.refresh);
18387 this.store.un("beforeload", this.onBeforeLoad);
18388 this.store.un("load", this.onLoad);
18389 this.store.un("loadexception", this.onLoad);
18393 store.on("datachanged", this.refresh, this);
18394 store.on("add", this.onAdd, this);
18395 store.on("remove", this.onRemove, this);
18396 store.on("update", this.onUpdate, this);
18397 store.on("clear", this.refresh, this);
18398 store.on("beforeload", this.onBeforeLoad, this);
18399 store.on("load", this.onLoad, this);
18400 store.on("loadexception", this.onLoad, this);
18408 * onbeforeLoad - masks the loading area.
18411 onBeforeLoad : function(store,opts)
18413 //Roo.log('onBeforeLoad');
18415 this.el.update("");
18417 this.el.mask(this.mask ? this.mask : "Loading" );
18419 onLoad : function ()
18426 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
18427 * @param {HTMLElement} node
18428 * @return {HTMLElement} The template node
18430 findItemFromChild : function(node){
18431 var el = this.dataName ?
18432 this.el.child('.roo-tpl-' + this.dataName,true) :
18435 if(!node || node.parentNode == el){
18438 var p = node.parentNode;
18439 while(p && p != el){
18440 if(p.parentNode == el){
18449 onClick : function(e){
18450 var item = this.findItemFromChild(e.getTarget());
18452 var index = this.indexOf(item);
18453 if(this.onItemClick(item, index, e) !== false){
18454 this.fireEvent("click", this, index, item, e);
18457 this.clearSelections();
18462 onContextMenu : function(e){
18463 var item = this.findItemFromChild(e.getTarget());
18465 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
18470 onDblClick : function(e){
18471 var item = this.findItemFromChild(e.getTarget());
18473 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
18477 onItemClick : function(item, index, e)
18479 if(this.fireEvent("beforeclick", this, index, item, e) === false){
18482 if (this.toggleSelect) {
18483 var m = this.isSelected(item) ? 'unselect' : 'select';
18486 _t[m](item, true, false);
18489 if(this.multiSelect || this.singleSelect){
18490 if(this.multiSelect && e.shiftKey && this.lastSelection){
18491 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
18493 this.select(item, this.multiSelect && e.ctrlKey);
18494 this.lastSelection = item;
18497 if(!this.tickable){
18498 e.preventDefault();
18506 * Get the number of selected nodes.
18509 getSelectionCount : function(){
18510 return this.selections.length;
18514 * Get the currently selected nodes.
18515 * @return {Array} An array of HTMLElements
18517 getSelectedNodes : function(){
18518 return this.selections;
18522 * Get the indexes of the selected nodes.
18525 getSelectedIndexes : function(){
18526 var indexes = [], s = this.selections;
18527 for(var i = 0, len = s.length; i < len; i++){
18528 indexes.push(s[i].nodeIndex);
18534 * Clear all selections
18535 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
18537 clearSelections : function(suppressEvent){
18538 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
18539 this.cmp.elements = this.selections;
18540 this.cmp.removeClass(this.selectedClass);
18541 this.selections = [];
18542 if(!suppressEvent){
18543 this.fireEvent("selectionchange", this, this.selections);
18549 * Returns true if the passed node is selected
18550 * @param {HTMLElement/Number} node The node or node index
18551 * @return {Boolean}
18553 isSelected : function(node){
18554 var s = this.selections;
18558 node = this.getNode(node);
18559 return s.indexOf(node) !== -1;
18564 * @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
18565 * @param {Boolean} keepExisting (optional) true to keep existing selections
18566 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
18568 select : function(nodeInfo, keepExisting, suppressEvent){
18569 if(nodeInfo instanceof Array){
18571 this.clearSelections(true);
18573 for(var i = 0, len = nodeInfo.length; i < len; i++){
18574 this.select(nodeInfo[i], true, true);
18578 var node = this.getNode(nodeInfo);
18579 if(!node || this.isSelected(node)){
18580 return; // already selected.
18583 this.clearSelections(true);
18586 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
18587 Roo.fly(node).addClass(this.selectedClass);
18588 this.selections.push(node);
18589 if(!suppressEvent){
18590 this.fireEvent("selectionchange", this, this.selections);
18598 * @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
18599 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
18600 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
18602 unselect : function(nodeInfo, keepExisting, suppressEvent)
18604 if(nodeInfo instanceof Array){
18605 Roo.each(this.selections, function(s) {
18606 this.unselect(s, nodeInfo);
18610 var node = this.getNode(nodeInfo);
18611 if(!node || !this.isSelected(node)){
18612 //Roo.log("not selected");
18613 return; // not selected.
18617 Roo.each(this.selections, function(s) {
18619 Roo.fly(node).removeClass(this.selectedClass);
18626 this.selections= ns;
18627 this.fireEvent("selectionchange", this, this.selections);
18631 * Gets a template node.
18632 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
18633 * @return {HTMLElement} The node or null if it wasn't found
18635 getNode : function(nodeInfo){
18636 if(typeof nodeInfo == "string"){
18637 return document.getElementById(nodeInfo);
18638 }else if(typeof nodeInfo == "number"){
18639 return this.nodes[nodeInfo];
18645 * Gets a range template nodes.
18646 * @param {Number} startIndex
18647 * @param {Number} endIndex
18648 * @return {Array} An array of nodes
18650 getNodes : function(start, end){
18651 var ns = this.nodes;
18652 start = start || 0;
18653 end = typeof end == "undefined" ? ns.length - 1 : end;
18656 for(var i = start; i <= end; i++){
18660 for(var i = start; i >= end; i--){
18668 * Finds the index of the passed node
18669 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
18670 * @return {Number} The index of the node or -1
18672 indexOf : function(node){
18673 node = this.getNode(node);
18674 if(typeof node.nodeIndex == "number"){
18675 return node.nodeIndex;
18677 var ns = this.nodes;
18678 for(var i = 0, len = ns.length; i < len; i++){
18689 * based on jquery fullcalendar
18693 Roo.bootstrap = Roo.bootstrap || {};
18695 * @class Roo.bootstrap.Calendar
18696 * @extends Roo.bootstrap.Component
18697 * Bootstrap Calendar class
18698 * @cfg {Boolean} loadMask (true|false) default false
18699 * @cfg {Object} header generate the user specific header of the calendar, default false
18702 * Create a new Container
18703 * @param {Object} config The config object
18708 Roo.bootstrap.Calendar = function(config){
18709 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
18713 * Fires when a date is selected
18714 * @param {DatePicker} this
18715 * @param {Date} date The selected date
18719 * @event monthchange
18720 * Fires when the displayed month changes
18721 * @param {DatePicker} this
18722 * @param {Date} date The selected month
18724 'monthchange': true,
18726 * @event evententer
18727 * Fires when mouse over an event
18728 * @param {Calendar} this
18729 * @param {event} Event
18731 'evententer': true,
18733 * @event eventleave
18734 * Fires when the mouse leaves an
18735 * @param {Calendar} this
18738 'eventleave': true,
18740 * @event eventclick
18741 * Fires when the mouse click an
18742 * @param {Calendar} this
18751 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
18754 * @cfg {Number} startDay
18755 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
18763 getAutoCreate : function(){
18766 var fc_button = function(name, corner, style, content ) {
18767 return Roo.apply({},{
18769 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
18771 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
18774 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
18785 style : 'width:100%',
18792 cls : 'fc-header-left',
18794 fc_button('prev', 'left', 'arrow', '‹' ),
18795 fc_button('next', 'right', 'arrow', '›' ),
18796 { tag: 'span', cls: 'fc-header-space' },
18797 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
18805 cls : 'fc-header-center',
18809 cls: 'fc-header-title',
18812 html : 'month / year'
18820 cls : 'fc-header-right',
18822 /* fc_button('month', 'left', '', 'month' ),
18823 fc_button('week', '', '', 'week' ),
18824 fc_button('day', 'right', '', 'day' )
18836 header = this.header;
18839 var cal_heads = function() {
18841 // fixme - handle this.
18843 for (var i =0; i < Date.dayNames.length; i++) {
18844 var d = Date.dayNames[i];
18847 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
18848 html : d.substring(0,3)
18852 ret[0].cls += ' fc-first';
18853 ret[6].cls += ' fc-last';
18856 var cal_cell = function(n) {
18859 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
18864 cls: 'fc-day-number',
18868 cls: 'fc-day-content',
18872 style: 'position: relative;' // height: 17px;
18884 var cal_rows = function() {
18887 for (var r = 0; r < 6; r++) {
18894 for (var i =0; i < Date.dayNames.length; i++) {
18895 var d = Date.dayNames[i];
18896 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
18899 row.cn[0].cls+=' fc-first';
18900 row.cn[0].cn[0].style = 'min-height:90px';
18901 row.cn[6].cls+=' fc-last';
18905 ret[0].cls += ' fc-first';
18906 ret[4].cls += ' fc-prev-last';
18907 ret[5].cls += ' fc-last';
18914 cls: 'fc-border-separate',
18915 style : 'width:100%',
18923 cls : 'fc-first fc-last',
18941 cls : 'fc-content',
18942 style : "position: relative;",
18945 cls : 'fc-view fc-view-month fc-grid',
18946 style : 'position: relative',
18947 unselectable : 'on',
18950 cls : 'fc-event-container',
18951 style : 'position:absolute;z-index:8;top:0;left:0;'
18969 initEvents : function()
18972 throw "can not find store for calendar";
18978 style: "text-align:center",
18982 style: "background-color:white;width:50%;margin:250 auto",
18986 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
18997 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
18999 var size = this.el.select('.fc-content', true).first().getSize();
19000 this.maskEl.setSize(size.width, size.height);
19001 this.maskEl.enableDisplayMode("block");
19002 if(!this.loadMask){
19003 this.maskEl.hide();
19006 this.store = Roo.factory(this.store, Roo.data);
19007 this.store.on('load', this.onLoad, this);
19008 this.store.on('beforeload', this.onBeforeLoad, this);
19012 this.cells = this.el.select('.fc-day',true);
19013 //Roo.log(this.cells);
19014 this.textNodes = this.el.query('.fc-day-number');
19015 this.cells.addClassOnOver('fc-state-hover');
19017 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
19018 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
19019 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
19020 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
19022 this.on('monthchange', this.onMonthChange, this);
19024 this.update(new Date().clearTime());
19027 resize : function() {
19028 var sz = this.el.getSize();
19030 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
19031 this.el.select('.fc-day-content div',true).setHeight(34);
19036 showPrevMonth : function(e){
19037 this.update(this.activeDate.add("mo", -1));
19039 showToday : function(e){
19040 this.update(new Date().clearTime());
19043 showNextMonth : function(e){
19044 this.update(this.activeDate.add("mo", 1));
19048 showPrevYear : function(){
19049 this.update(this.activeDate.add("y", -1));
19053 showNextYear : function(){
19054 this.update(this.activeDate.add("y", 1));
19059 update : function(date)
19061 var vd = this.activeDate;
19062 this.activeDate = date;
19063 // if(vd && this.el){
19064 // var t = date.getTime();
19065 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
19066 // Roo.log('using add remove');
19068 // this.fireEvent('monthchange', this, date);
19070 // this.cells.removeClass("fc-state-highlight");
19071 // this.cells.each(function(c){
19072 // if(c.dateValue == t){
19073 // c.addClass("fc-state-highlight");
19074 // setTimeout(function(){
19075 // try{c.dom.firstChild.focus();}catch(e){}
19085 var days = date.getDaysInMonth();
19087 var firstOfMonth = date.getFirstDateOfMonth();
19088 var startingPos = firstOfMonth.getDay()-this.startDay;
19090 if(startingPos < this.startDay){
19094 var pm = date.add(Date.MONTH, -1);
19095 var prevStart = pm.getDaysInMonth()-startingPos;
19097 this.cells = this.el.select('.fc-day',true);
19098 this.textNodes = this.el.query('.fc-day-number');
19099 this.cells.addClassOnOver('fc-state-hover');
19101 var cells = this.cells.elements;
19102 var textEls = this.textNodes;
19104 Roo.each(cells, function(cell){
19105 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
19108 days += startingPos;
19110 // convert everything to numbers so it's fast
19111 var day = 86400000;
19112 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
19115 //Roo.log(prevStart);
19117 var today = new Date().clearTime().getTime();
19118 var sel = date.clearTime().getTime();
19119 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
19120 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
19121 var ddMatch = this.disabledDatesRE;
19122 var ddText = this.disabledDatesText;
19123 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
19124 var ddaysText = this.disabledDaysText;
19125 var format = this.format;
19127 var setCellClass = function(cal, cell){
19131 //Roo.log('set Cell Class');
19133 var t = d.getTime();
19137 cell.dateValue = t;
19139 cell.className += " fc-today";
19140 cell.className += " fc-state-highlight";
19141 cell.title = cal.todayText;
19144 // disable highlight in other month..
19145 //cell.className += " fc-state-highlight";
19150 cell.className = " fc-state-disabled";
19151 cell.title = cal.minText;
19155 cell.className = " fc-state-disabled";
19156 cell.title = cal.maxText;
19160 if(ddays.indexOf(d.getDay()) != -1){
19161 cell.title = ddaysText;
19162 cell.className = " fc-state-disabled";
19165 if(ddMatch && format){
19166 var fvalue = d.dateFormat(format);
19167 if(ddMatch.test(fvalue)){
19168 cell.title = ddText.replace("%0", fvalue);
19169 cell.className = " fc-state-disabled";
19173 if (!cell.initialClassName) {
19174 cell.initialClassName = cell.dom.className;
19177 cell.dom.className = cell.initialClassName + ' ' + cell.className;
19182 for(; i < startingPos; i++) {
19183 textEls[i].innerHTML = (++prevStart);
19184 d.setDate(d.getDate()+1);
19186 cells[i].className = "fc-past fc-other-month";
19187 setCellClass(this, cells[i]);
19192 for(; i < days; i++){
19193 intDay = i - startingPos + 1;
19194 textEls[i].innerHTML = (intDay);
19195 d.setDate(d.getDate()+1);
19197 cells[i].className = ''; // "x-date-active";
19198 setCellClass(this, cells[i]);
19202 for(; i < 42; i++) {
19203 textEls[i].innerHTML = (++extraDays);
19204 d.setDate(d.getDate()+1);
19206 cells[i].className = "fc-future fc-other-month";
19207 setCellClass(this, cells[i]);
19210 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
19212 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
19214 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
19215 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
19217 if(totalRows != 6){
19218 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
19219 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
19222 this.fireEvent('monthchange', this, date);
19226 if(!this.internalRender){
19227 var main = this.el.dom.firstChild;
19228 var w = main.offsetWidth;
19229 this.el.setWidth(w + this.el.getBorderWidth("lr"));
19230 Roo.fly(main).setWidth(w);
19231 this.internalRender = true;
19232 // opera does not respect the auto grow header center column
19233 // then, after it gets a width opera refuses to recalculate
19234 // without a second pass
19235 if(Roo.isOpera && !this.secondPass){
19236 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
19237 this.secondPass = true;
19238 this.update.defer(10, this, [date]);
19245 findCell : function(dt) {
19246 dt = dt.clearTime().getTime();
19248 this.cells.each(function(c){
19249 //Roo.log("check " +c.dateValue + '?=' + dt);
19250 if(c.dateValue == dt){
19260 findCells : function(ev) {
19261 var s = ev.start.clone().clearTime().getTime();
19263 var e= ev.end.clone().clearTime().getTime();
19266 this.cells.each(function(c){
19267 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
19269 if(c.dateValue > e){
19272 if(c.dateValue < s){
19281 // findBestRow: function(cells)
19285 // for (var i =0 ; i < cells.length;i++) {
19286 // ret = Math.max(cells[i].rows || 0,ret);
19293 addItem : function(ev)
19295 // look for vertical location slot in
19296 var cells = this.findCells(ev);
19298 // ev.row = this.findBestRow(cells);
19300 // work out the location.
19304 for(var i =0; i < cells.length; i++) {
19306 cells[i].row = cells[0].row;
19309 cells[i].row = cells[i].row + 1;
19319 if (crow.start.getY() == cells[i].getY()) {
19321 crow.end = cells[i];
19338 cells[0].events.push(ev);
19340 this.calevents.push(ev);
19343 clearEvents: function() {
19345 if(!this.calevents){
19349 Roo.each(this.cells.elements, function(c){
19355 Roo.each(this.calevents, function(e) {
19356 Roo.each(e.els, function(el) {
19357 el.un('mouseenter' ,this.onEventEnter, this);
19358 el.un('mouseleave' ,this.onEventLeave, this);
19363 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
19369 renderEvents: function()
19373 this.cells.each(function(c) {
19382 if(c.row != c.events.length){
19383 r = 4 - (4 - (c.row - c.events.length));
19386 c.events = ev.slice(0, r);
19387 c.more = ev.slice(r);
19389 if(c.more.length && c.more.length == 1){
19390 c.events.push(c.more.pop());
19393 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
19397 this.cells.each(function(c) {
19399 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
19402 for (var e = 0; e < c.events.length; e++){
19403 var ev = c.events[e];
19404 var rows = ev.rows;
19406 for(var i = 0; i < rows.length; i++) {
19408 // how many rows should it span..
19411 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
19412 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
19414 unselectable : "on",
19417 cls: 'fc-event-inner',
19421 // cls: 'fc-event-time',
19422 // html : cells.length > 1 ? '' : ev.time
19426 cls: 'fc-event-title',
19427 html : String.format('{0}', ev.title)
19434 cls: 'ui-resizable-handle ui-resizable-e',
19435 html : '  '
19442 cfg.cls += ' fc-event-start';
19444 if ((i+1) == rows.length) {
19445 cfg.cls += ' fc-event-end';
19448 var ctr = _this.el.select('.fc-event-container',true).first();
19449 var cg = ctr.createChild(cfg);
19451 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
19452 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
19454 var r = (c.more.length) ? 1 : 0;
19455 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
19456 cg.setWidth(ebox.right - sbox.x -2);
19458 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
19459 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
19460 cg.on('click', _this.onEventClick, _this, ev);
19471 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
19472 style : 'position: absolute',
19473 unselectable : "on",
19476 cls: 'fc-event-inner',
19480 cls: 'fc-event-title',
19488 cls: 'ui-resizable-handle ui-resizable-e',
19489 html : '  '
19495 var ctr = _this.el.select('.fc-event-container',true).first();
19496 var cg = ctr.createChild(cfg);
19498 var sbox = c.select('.fc-day-content',true).first().getBox();
19499 var ebox = c.select('.fc-day-content',true).first().getBox();
19501 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
19502 cg.setWidth(ebox.right - sbox.x -2);
19504 cg.on('click', _this.onMoreEventClick, _this, c.more);
19514 onEventEnter: function (e, el,event,d) {
19515 this.fireEvent('evententer', this, el, event);
19518 onEventLeave: function (e, el,event,d) {
19519 this.fireEvent('eventleave', this, el, event);
19522 onEventClick: function (e, el,event,d) {
19523 this.fireEvent('eventclick', this, el, event);
19526 onMonthChange: function () {
19530 onMoreEventClick: function(e, el, more)
19534 this.calpopover.placement = 'right';
19535 this.calpopover.setTitle('More');
19537 this.calpopover.setContent('');
19539 var ctr = this.calpopover.el.select('.popover-content', true).first();
19541 Roo.each(more, function(m){
19543 cls : 'fc-event-hori fc-event-draggable',
19546 var cg = ctr.createChild(cfg);
19548 cg.on('click', _this.onEventClick, _this, m);
19551 this.calpopover.show(el);
19556 onLoad: function ()
19558 this.calevents = [];
19561 if(this.store.getCount() > 0){
19562 this.store.data.each(function(d){
19565 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
19566 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
19567 time : d.data.start_time,
19568 title : d.data.title,
19569 description : d.data.description,
19570 venue : d.data.venue
19575 this.renderEvents();
19577 if(this.calevents.length && this.loadMask){
19578 this.maskEl.hide();
19582 onBeforeLoad: function()
19584 this.clearEvents();
19586 this.maskEl.show();
19600 * @class Roo.bootstrap.Popover
19601 * @extends Roo.bootstrap.Component
19602 * Bootstrap Popover class
19603 * @cfg {String} html contents of the popover (or false to use children..)
19604 * @cfg {String} title of popover (or false to hide)
19605 * @cfg {String|function} (right|top|bottom|left|auto) placement how it is placed
19606 * @cfg {String} trigger click || hover (or false to trigger manually)
19607 * @cfg {Boolean} modal - popovers that are modal will mask the screen, and must be closed with another event.
19608 * @cfg {String|Boolean|Roo.Element} add click hander to trigger show over what element
19609 * - if false and it has a 'parent' then it will be automatically added to that element
19610 * - if string - Roo.get will be called
19611 * @cfg {Number} delay - delay before showing
19614 * Create a new Popover
19615 * @param {Object} config The config object
19618 Roo.bootstrap.Popover = function(config){
19619 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
19625 * After the popover show
19627 * @param {Roo.bootstrap.Popover} this
19632 * After the popover hide
19634 * @param {Roo.bootstrap.Popover} this
19640 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
19645 placement : 'right',
19646 trigger : 'hover', // hover
19652 can_build_overlaid : false,
19654 getChildContainer : function()
19656 return this.el.select('.popover-content',true).first();
19659 getAutoCreate : function(){
19662 cls : 'popover roo-dynamic shadow roo-popover',
19663 style: 'display:block',
19669 cls : 'popover-inner ',
19673 cls: 'popover-title popover-header',
19674 html : this.title || ''
19677 cls : 'popover-content popover-body' + this.cls,
19678 html : this.html || ''
19689 * @param {string} the title
19691 setTitle: function(str)
19695 this.el.select('.popover-title',true).first().dom.innerHTML = str;
19700 * @param {string} the body content
19702 setContent: function(str)
19706 this.el.select('.popover-content',true).first().dom.innerHTML = str;
19710 // as it get's added to the bottom of the page.
19711 onRender : function(ct, position)
19713 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
19715 var cfg = Roo.apply({}, this.getAutoCreate());
19719 cfg.cls += ' ' + this.cls;
19722 cfg.style = this.style;
19724 //Roo.log("adding to ");
19725 this.el = Roo.get(document.body).createChild(cfg, position);
19726 // Roo.log(this.el);
19730 if(typeof(this.items) != 'undefined'){
19731 var items = this.items;
19734 for(var i =0;i < items.length;i++) {
19735 nitems.push(this.addxtype(Roo.apply({}, items[i])));
19739 this.items = nitems;
19745 initEvents : function()
19748 Roo.bootstrap.Popover.register(this);
19749 this.el.select('.popover-title',true).setVisibilityMode(Roo.Element.DISPLAY);
19750 this.el.enableDisplayMode('block');
19752 if (this.over === false && !this.parent()) {
19755 if (this.triggers === false) {
19760 var on_el = (this.over == 'parent' || this.over === false) ? this.parent().el : Roo.get(this.over);
19761 var triggers = this.trigger ? this.trigger.split(' ') : [];
19762 Roo.each(triggers, function(trigger) {
19764 if (trigger == 'click') {
19765 on_el.on('click', this.toggle, this);
19766 } else if (trigger != 'manual') {
19767 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
19768 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
19770 on_el.on(eventIn ,this.enter, this);
19771 on_el.on(eventOut, this.leave, this);
19782 toggle : function () {
19783 this.hoverState == 'in' ? this.leave() : this.enter();
19786 enter : function () {
19788 clearTimeout(this.timeout);
19790 this.hoverState = 'in';
19792 if (!this.delay || !this.delay.show) {
19797 this.timeout = setTimeout(function () {
19798 if (_t.hoverState == 'in') {
19801 }, this.delay.show)
19804 leave : function() {
19805 clearTimeout(this.timeout);
19807 this.hoverState = 'out';
19809 if (!this.delay || !this.delay.hide) {
19814 this.timeout = setTimeout(function () {
19815 if (_t.hoverState == 'out') {
19818 }, this.delay.hide)
19822 * @param {Roo.Element|string|false} - element to align and point to.
19824 show : function (on_el)
19827 on_el = on_el || false; // default to false
19829 if (this.parent() && (this.over == 'parent' || (this.over === false))) {
19830 on_el = this.parent().el;
19831 } else if (this.over) {
19832 Roo.get(this.over);
19838 this.render(document.body);
19842 this.el.removeClass([
19843 'fade','top','bottom', 'left', 'right','in',
19844 'bs-popover-top','bs-popover-bottom', 'bs-popover-left', 'bs-popover-right'
19847 if (!this.title.length) {
19848 this.el.select('.popover-title',true).hide();
19852 var placement = typeof this.placement == 'function' ?
19853 this.placement.call(this, this.el, on_el) :
19857 var autoToken = /\s?auto?\s?/i; /// not sure how this was supposed to work? right auto ? what?
19859 // I think 'auto right' - but
19861 var autoPlace = autoToken.test(placement);
19863 placement = placement.replace(autoToken, '') || 'top';
19869 this.el.dom.style.display='block';
19871 //this.el.appendTo(on_el);
19873 var p = this.getPosition();
19874 var box = this.el.getBox();
19877 var align = Roo.bootstrap.Popover.alignment[placement];
19878 this.el.addClass(align[2]);
19883 this.el.alignTo(on_el, align[0],align[1]);
19885 // this is usually just done by the builder = to show the popoup in the middle of the scren.
19886 var es = this.el.getSize();
19887 var x = Roo.lib.Dom.getViewWidth()/2;
19888 var y = Roo.lib.Dom.getViewHeight()/2;
19889 this.el.setXY([ x-(es.width/2), y-(es.height/2)] );
19894 //var arrow = this.el.select('.arrow',true).first();
19895 //arrow.set(align[2],
19897 this.el.addClass('in');
19900 if (this.el.hasClass('fade')) {
19904 this.hoverState = 'in';
19906 this.fireEvent('show', this);
19911 this.el.setXY([0,0]);
19912 this.el.removeClass('in');
19914 this.hoverState = null;
19916 this.fireEvent('hide', this);
19922 Roo.apply(Roo.bootstrap.Popover, {
19925 'left' : ['r-l', [-10,0], 'left bs-popover-left'],
19926 'right' : ['l-br', [10,0], 'right bs-popover-right'],
19927 'bottom' : ['t-b', [0,10], 'top bs-popover-top'],
19928 'top' : [ 'b-t', [0,-10], 'bottom bs-popover-bottom']
19931 clickHander : false,
19934 onMouseDown : function(e)
19936 if (!e.getTarget(".roo-popover")) {
19944 register : function(popup)
19946 if (!Roo.bootstrap.Popover.clickHandler) {
19947 Roo.bootstrap.Popover.clickHandler = Roo.get(document).on("mousedown", Roo.bootstrap.Popover.onMouseDown, Roo.bootstrap.Popover);
19949 // hide other popups.
19951 this.popups.push(popup);
19953 hideAll : function()
19955 this.popups.forEach(function(p) {
19968 * @class Roo.bootstrap.Progress
19969 * @extends Roo.bootstrap.Component
19970 * Bootstrap Progress class
19971 * @cfg {Boolean} striped striped of the progress bar
19972 * @cfg {Boolean} active animated of the progress bar
19976 * Create a new Progress
19977 * @param {Object} config The config object
19980 Roo.bootstrap.Progress = function(config){
19981 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
19984 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
19989 getAutoCreate : function(){
19997 cfg.cls += ' progress-striped';
20001 cfg.cls += ' active';
20020 * @class Roo.bootstrap.ProgressBar
20021 * @extends Roo.bootstrap.Component
20022 * Bootstrap ProgressBar class
20023 * @cfg {Number} aria_valuenow aria-value now
20024 * @cfg {Number} aria_valuemin aria-value min
20025 * @cfg {Number} aria_valuemax aria-value max
20026 * @cfg {String} label label for the progress bar
20027 * @cfg {String} panel (success | info | warning | danger )
20028 * @cfg {String} role role of the progress bar
20029 * @cfg {String} sr_only text
20033 * Create a new ProgressBar
20034 * @param {Object} config The config object
20037 Roo.bootstrap.ProgressBar = function(config){
20038 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
20041 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
20045 aria_valuemax : 100,
20051 getAutoCreate : function()
20056 cls: 'progress-bar',
20057 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
20069 cfg.role = this.role;
20072 if(this.aria_valuenow){
20073 cfg['aria-valuenow'] = this.aria_valuenow;
20076 if(this.aria_valuemin){
20077 cfg['aria-valuemin'] = this.aria_valuemin;
20080 if(this.aria_valuemax){
20081 cfg['aria-valuemax'] = this.aria_valuemax;
20084 if(this.label && !this.sr_only){
20085 cfg.html = this.label;
20089 cfg.cls += ' progress-bar-' + this.panel;
20095 update : function(aria_valuenow)
20097 this.aria_valuenow = aria_valuenow;
20099 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
20114 * @class Roo.bootstrap.TabGroup
20115 * @extends Roo.bootstrap.Column
20116 * Bootstrap Column class
20117 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
20118 * @cfg {Boolean} carousel true to make the group behave like a carousel
20119 * @cfg {Boolean} bullets show bullets for the panels
20120 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
20121 * @cfg {Number} timer auto slide timer .. default 0 millisecond
20122 * @cfg {Boolean} showarrow (true|false) show arrow default true
20125 * Create a new TabGroup
20126 * @param {Object} config The config object
20129 Roo.bootstrap.TabGroup = function(config){
20130 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
20132 this.navId = Roo.id();
20135 Roo.bootstrap.TabGroup.register(this);
20139 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
20142 transition : false,
20147 slideOnTouch : false,
20150 getAutoCreate : function()
20152 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
20154 cfg.cls += ' tab-content';
20156 if (this.carousel) {
20157 cfg.cls += ' carousel slide';
20160 cls : 'carousel-inner',
20164 if(this.bullets && !Roo.isTouch){
20167 cls : 'carousel-bullets',
20171 if(this.bullets_cls){
20172 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
20179 cfg.cn[0].cn.push(bullets);
20182 if(this.showarrow){
20183 cfg.cn[0].cn.push({
20185 class : 'carousel-arrow',
20189 class : 'carousel-prev',
20193 class : 'fa fa-chevron-left'
20199 class : 'carousel-next',
20203 class : 'fa fa-chevron-right'
20216 initEvents: function()
20218 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
20219 // this.el.on("touchstart", this.onTouchStart, this);
20222 if(this.autoslide){
20225 this.slideFn = window.setInterval(function() {
20226 _this.showPanelNext();
20230 if(this.showarrow){
20231 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
20232 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
20238 // onTouchStart : function(e, el, o)
20240 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
20244 // this.showPanelNext();
20248 getChildContainer : function()
20250 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
20254 * register a Navigation item
20255 * @param {Roo.bootstrap.NavItem} the navitem to add
20257 register : function(item)
20259 this.tabs.push( item);
20260 item.navId = this.navId; // not really needed..
20265 getActivePanel : function()
20268 Roo.each(this.tabs, function(t) {
20278 getPanelByName : function(n)
20281 Roo.each(this.tabs, function(t) {
20282 if (t.tabId == n) {
20290 indexOfPanel : function(p)
20293 Roo.each(this.tabs, function(t,i) {
20294 if (t.tabId == p.tabId) {
20303 * show a specific panel
20304 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
20305 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
20307 showPanel : function (pan)
20309 if(this.transition || typeof(pan) == 'undefined'){
20310 Roo.log("waiting for the transitionend");
20314 if (typeof(pan) == 'number') {
20315 pan = this.tabs[pan];
20318 if (typeof(pan) == 'string') {
20319 pan = this.getPanelByName(pan);
20322 var cur = this.getActivePanel();
20325 Roo.log('pan or acitve pan is undefined');
20329 if (pan.tabId == this.getActivePanel().tabId) {
20333 if (false === cur.fireEvent('beforedeactivate')) {
20337 if(this.bullets > 0 && !Roo.isTouch){
20338 this.setActiveBullet(this.indexOfPanel(pan));
20341 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
20343 //class="carousel-item carousel-item-next carousel-item-left"
20345 this.transition = true;
20346 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
20347 var lr = dir == 'next' ? 'left' : 'right';
20348 pan.el.addClass(dir); // or prev
20349 pan.el.addClass('carousel-item-' + dir); // or prev
20350 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
20351 cur.el.addClass(lr); // or right
20352 pan.el.addClass(lr);
20353 cur.el.addClass('carousel-item-' +lr); // or right
20354 pan.el.addClass('carousel-item-' +lr);
20358 cur.el.on('transitionend', function() {
20359 Roo.log("trans end?");
20361 pan.el.removeClass([lr,dir, 'carousel-item-' + lr, 'carousel-item-' + dir]);
20362 pan.setActive(true);
20364 cur.el.removeClass([lr, 'carousel-item-' + lr]);
20365 cur.setActive(false);
20367 _this.transition = false;
20369 }, this, { single: true } );
20374 cur.setActive(false);
20375 pan.setActive(true);
20380 showPanelNext : function()
20382 var i = this.indexOfPanel(this.getActivePanel());
20384 if (i >= this.tabs.length - 1 && !this.autoslide) {
20388 if (i >= this.tabs.length - 1 && this.autoslide) {
20392 this.showPanel(this.tabs[i+1]);
20395 showPanelPrev : function()
20397 var i = this.indexOfPanel(this.getActivePanel());
20399 if (i < 1 && !this.autoslide) {
20403 if (i < 1 && this.autoslide) {
20404 i = this.tabs.length;
20407 this.showPanel(this.tabs[i-1]);
20411 addBullet: function()
20413 if(!this.bullets || Roo.isTouch){
20416 var ctr = this.el.select('.carousel-bullets',true).first();
20417 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
20418 var bullet = ctr.createChild({
20419 cls : 'bullet bullet-' + i
20420 },ctr.dom.lastChild);
20425 bullet.on('click', (function(e, el, o, ii, t){
20427 e.preventDefault();
20429 this.showPanel(ii);
20431 if(this.autoslide && this.slideFn){
20432 clearInterval(this.slideFn);
20433 this.slideFn = window.setInterval(function() {
20434 _this.showPanelNext();
20438 }).createDelegate(this, [i, bullet], true));
20443 setActiveBullet : function(i)
20449 Roo.each(this.el.select('.bullet', true).elements, function(el){
20450 el.removeClass('selected');
20453 var bullet = this.el.select('.bullet-' + i, true).first();
20459 bullet.addClass('selected');
20470 Roo.apply(Roo.bootstrap.TabGroup, {
20474 * register a Navigation Group
20475 * @param {Roo.bootstrap.NavGroup} the navgroup to add
20477 register : function(navgrp)
20479 this.groups[navgrp.navId] = navgrp;
20483 * fetch a Navigation Group based on the navigation ID
20484 * if one does not exist , it will get created.
20485 * @param {string} the navgroup to add
20486 * @returns {Roo.bootstrap.NavGroup} the navgroup
20488 get: function(navId) {
20489 if (typeof(this.groups[navId]) == 'undefined') {
20490 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
20492 return this.groups[navId] ;
20507 * @class Roo.bootstrap.TabPanel
20508 * @extends Roo.bootstrap.Component
20509 * Bootstrap TabPanel class
20510 * @cfg {Boolean} active panel active
20511 * @cfg {String} html panel content
20512 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
20513 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
20514 * @cfg {String} href click to link..
20515 * @cfg {Boolean} touchSlide if swiping slides tab to next panel (default off)
20519 * Create a new TabPanel
20520 * @param {Object} config The config object
20523 Roo.bootstrap.TabPanel = function(config){
20524 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
20528 * Fires when the active status changes
20529 * @param {Roo.bootstrap.TabPanel} this
20530 * @param {Boolean} state the new state
20535 * @event beforedeactivate
20536 * Fires before a tab is de-activated - can be used to do validation on a form.
20537 * @param {Roo.bootstrap.TabPanel} this
20538 * @return {Boolean} false if there is an error
20541 'beforedeactivate': true
20544 this.tabId = this.tabId || Roo.id();
20548 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
20555 touchSlide : false,
20556 getAutoCreate : function(){
20561 // item is needed for carousel - not sure if it has any effect otherwise
20562 cls: 'carousel-item tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
20563 html: this.html || ''
20567 cfg.cls += ' active';
20571 cfg.tabId = this.tabId;
20579 initEvents: function()
20581 var p = this.parent();
20583 this.navId = this.navId || p.navId;
20585 if (typeof(this.navId) != 'undefined') {
20586 // not really needed.. but just in case.. parent should be a NavGroup.
20587 var tg = Roo.bootstrap.TabGroup.get(this.navId);
20591 var i = tg.tabs.length - 1;
20593 if(this.active && tg.bullets > 0 && i < tg.bullets){
20594 tg.setActiveBullet(i);
20598 this.el.on('click', this.onClick, this);
20600 if(Roo.isTouch && this.touchSlide){
20601 this.el.on("touchstart", this.onTouchStart, this);
20602 this.el.on("touchmove", this.onTouchMove, this);
20603 this.el.on("touchend", this.onTouchEnd, this);
20608 onRender : function(ct, position)
20610 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
20613 setActive : function(state)
20615 Roo.log("panel - set active " + this.tabId + "=" + state);
20617 this.active = state;
20619 this.el.removeClass('active');
20621 } else if (!this.el.hasClass('active')) {
20622 this.el.addClass('active');
20625 this.fireEvent('changed', this, state);
20628 onClick : function(e)
20630 e.preventDefault();
20632 if(!this.href.length){
20636 window.location.href = this.href;
20645 onTouchStart : function(e)
20647 this.swiping = false;
20649 this.startX = e.browserEvent.touches[0].clientX;
20650 this.startY = e.browserEvent.touches[0].clientY;
20653 onTouchMove : function(e)
20655 this.swiping = true;
20657 this.endX = e.browserEvent.touches[0].clientX;
20658 this.endY = e.browserEvent.touches[0].clientY;
20661 onTouchEnd : function(e)
20668 var tabGroup = this.parent();
20670 if(this.endX > this.startX){ // swiping right
20671 tabGroup.showPanelPrev();
20675 if(this.startX > this.endX){ // swiping left
20676 tabGroup.showPanelNext();
20695 * @class Roo.bootstrap.DateField
20696 * @extends Roo.bootstrap.Input
20697 * Bootstrap DateField class
20698 * @cfg {Number} weekStart default 0
20699 * @cfg {String} viewMode default empty, (months|years)
20700 * @cfg {String} minViewMode default empty, (months|years)
20701 * @cfg {Number} startDate default -Infinity
20702 * @cfg {Number} endDate default Infinity
20703 * @cfg {Boolean} todayHighlight default false
20704 * @cfg {Boolean} todayBtn default false
20705 * @cfg {Boolean} calendarWeeks default false
20706 * @cfg {Object} daysOfWeekDisabled default empty
20707 * @cfg {Boolean} singleMode default false (true | false)
20709 * @cfg {Boolean} keyboardNavigation default true
20710 * @cfg {String} language default en
20713 * Create a new DateField
20714 * @param {Object} config The config object
20717 Roo.bootstrap.DateField = function(config){
20718 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
20722 * Fires when this field show.
20723 * @param {Roo.bootstrap.DateField} this
20724 * @param {Mixed} date The date value
20729 * Fires when this field hide.
20730 * @param {Roo.bootstrap.DateField} this
20731 * @param {Mixed} date The date value
20736 * Fires when select a date.
20737 * @param {Roo.bootstrap.DateField} this
20738 * @param {Mixed} date The date value
20742 * @event beforeselect
20743 * Fires when before select a date.
20744 * @param {Roo.bootstrap.DateField} this
20745 * @param {Mixed} date The date value
20747 beforeselect : true
20751 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
20754 * @cfg {String} format
20755 * The default date format string which can be overriden for localization support. The format must be
20756 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
20760 * @cfg {String} altFormats
20761 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
20762 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
20764 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
20772 todayHighlight : false,
20778 keyboardNavigation: true,
20780 calendarWeeks: false,
20782 startDate: -Infinity,
20786 daysOfWeekDisabled: [],
20790 singleMode : false,
20792 UTCDate: function()
20794 return new Date(Date.UTC.apply(Date, arguments));
20797 UTCToday: function()
20799 var today = new Date();
20800 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
20803 getDate: function() {
20804 var d = this.getUTCDate();
20805 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
20808 getUTCDate: function() {
20812 setDate: function(d) {
20813 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
20816 setUTCDate: function(d) {
20818 this.setValue(this.formatDate(this.date));
20821 onRender: function(ct, position)
20824 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
20826 this.language = this.language || 'en';
20827 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
20828 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
20830 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
20831 this.format = this.format || 'm/d/y';
20832 this.isInline = false;
20833 this.isInput = true;
20834 this.component = this.el.select('.add-on', true).first() || false;
20835 this.component = (this.component && this.component.length === 0) ? false : this.component;
20836 this.hasInput = this.component && this.inputEl().length;
20838 if (typeof(this.minViewMode === 'string')) {
20839 switch (this.minViewMode) {
20841 this.minViewMode = 1;
20844 this.minViewMode = 2;
20847 this.minViewMode = 0;
20852 if (typeof(this.viewMode === 'string')) {
20853 switch (this.viewMode) {
20866 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
20868 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
20870 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
20872 this.picker().on('mousedown', this.onMousedown, this);
20873 this.picker().on('click', this.onClick, this);
20875 this.picker().addClass('datepicker-dropdown');
20877 this.startViewMode = this.viewMode;
20879 if(this.singleMode){
20880 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
20881 v.setVisibilityMode(Roo.Element.DISPLAY);
20885 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
20886 v.setStyle('width', '189px');
20890 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
20891 if(!this.calendarWeeks){
20896 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
20897 v.attr('colspan', function(i, val){
20898 return parseInt(val) + 1;
20903 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
20905 this.setStartDate(this.startDate);
20906 this.setEndDate(this.endDate);
20908 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
20915 if(this.isInline) {
20920 picker : function()
20922 return this.pickerEl;
20923 // return this.el.select('.datepicker', true).first();
20926 fillDow: function()
20928 var dowCnt = this.weekStart;
20937 if(this.calendarWeeks){
20945 while (dowCnt < this.weekStart + 7) {
20949 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
20953 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
20956 fillMonths: function()
20959 var months = this.picker().select('>.datepicker-months td', true).first();
20961 months.dom.innerHTML = '';
20967 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
20970 months.createChild(month);
20977 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;
20979 if (this.date < this.startDate) {
20980 this.viewDate = new Date(this.startDate);
20981 } else if (this.date > this.endDate) {
20982 this.viewDate = new Date(this.endDate);
20984 this.viewDate = new Date(this.date);
20992 var d = new Date(this.viewDate),
20993 year = d.getUTCFullYear(),
20994 month = d.getUTCMonth(),
20995 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
20996 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
20997 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
20998 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
20999 currentDate = this.date && this.date.valueOf(),
21000 today = this.UTCToday();
21002 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
21004 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
21006 // this.picker.select('>tfoot th.today').
21007 // .text(dates[this.language].today)
21008 // .toggle(this.todayBtn !== false);
21010 this.updateNavArrows();
21013 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
21015 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
21017 prevMonth.setUTCDate(day);
21019 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
21021 var nextMonth = new Date(prevMonth);
21023 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
21025 nextMonth = nextMonth.valueOf();
21027 var fillMonths = false;
21029 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
21031 while(prevMonth.valueOf() <= nextMonth) {
21034 if (prevMonth.getUTCDay() === this.weekStart) {
21036 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
21044 if(this.calendarWeeks){
21045 // ISO 8601: First week contains first thursday.
21046 // ISO also states week starts on Monday, but we can be more abstract here.
21048 // Start of current week: based on weekstart/current date
21049 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
21050 // Thursday of this week
21051 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
21052 // First Thursday of year, year from thursday
21053 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
21054 // Calendar week: ms between thursdays, div ms per day, div 7 days
21055 calWeek = (th - yth) / 864e5 / 7 + 1;
21057 fillMonths.cn.push({
21065 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
21067 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
21070 if (this.todayHighlight &&
21071 prevMonth.getUTCFullYear() == today.getFullYear() &&
21072 prevMonth.getUTCMonth() == today.getMonth() &&
21073 prevMonth.getUTCDate() == today.getDate()) {
21074 clsName += ' today';
21077 if (currentDate && prevMonth.valueOf() === currentDate) {
21078 clsName += ' active';
21081 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
21082 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
21083 clsName += ' disabled';
21086 fillMonths.cn.push({
21088 cls: 'day ' + clsName,
21089 html: prevMonth.getDate()
21092 prevMonth.setDate(prevMonth.getDate()+1);
21095 var currentYear = this.date && this.date.getUTCFullYear();
21096 var currentMonth = this.date && this.date.getUTCMonth();
21098 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
21100 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
21101 v.removeClass('active');
21103 if(currentYear === year && k === currentMonth){
21104 v.addClass('active');
21107 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
21108 v.addClass('disabled');
21114 year = parseInt(year/10, 10) * 10;
21116 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
21118 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
21121 for (var i = -1; i < 11; i++) {
21122 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
21124 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
21132 showMode: function(dir)
21135 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
21138 Roo.each(this.picker().select('>div',true).elements, function(v){
21139 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
21142 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
21147 if(this.isInline) {
21151 this.picker().removeClass(['bottom', 'top']);
21153 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
21155 * place to the top of element!
21159 this.picker().addClass('top');
21160 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
21165 this.picker().addClass('bottom');
21167 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
21170 parseDate : function(value)
21172 if(!value || value instanceof Date){
21175 var v = Date.parseDate(value, this.format);
21176 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
21177 v = Date.parseDate(value, 'Y-m-d');
21179 if(!v && this.altFormats){
21180 if(!this.altFormatsArray){
21181 this.altFormatsArray = this.altFormats.split("|");
21183 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
21184 v = Date.parseDate(value, this.altFormatsArray[i]);
21190 formatDate : function(date, fmt)
21192 return (!date || !(date instanceof Date)) ?
21193 date : date.dateFormat(fmt || this.format);
21196 onFocus : function()
21198 Roo.bootstrap.DateField.superclass.onFocus.call(this);
21202 onBlur : function()
21204 Roo.bootstrap.DateField.superclass.onBlur.call(this);
21206 var d = this.inputEl().getValue();
21213 showPopup : function()
21215 this.picker().show();
21219 this.fireEvent('showpopup', this, this.date);
21222 hidePopup : function()
21224 if(this.isInline) {
21227 this.picker().hide();
21228 this.viewMode = this.startViewMode;
21231 this.fireEvent('hidepopup', this, this.date);
21235 onMousedown: function(e)
21237 e.stopPropagation();
21238 e.preventDefault();
21243 Roo.bootstrap.DateField.superclass.keyup.call(this);
21247 setValue: function(v)
21249 if(this.fireEvent('beforeselect', this, v) !== false){
21250 var d = new Date(this.parseDate(v) ).clearTime();
21252 if(isNaN(d.getTime())){
21253 this.date = this.viewDate = '';
21254 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
21258 v = this.formatDate(d);
21260 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
21262 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
21266 this.fireEvent('select', this, this.date);
21270 getValue: function()
21272 return this.formatDate(this.date);
21275 fireKey: function(e)
21277 if (!this.picker().isVisible()){
21278 if (e.keyCode == 27) { // allow escape to hide and re-show picker
21284 var dateChanged = false,
21286 newDate, newViewDate;
21291 e.preventDefault();
21295 if (!this.keyboardNavigation) {
21298 dir = e.keyCode == 37 ? -1 : 1;
21301 newDate = this.moveYear(this.date, dir);
21302 newViewDate = this.moveYear(this.viewDate, dir);
21303 } else if (e.shiftKey){
21304 newDate = this.moveMonth(this.date, dir);
21305 newViewDate = this.moveMonth(this.viewDate, dir);
21307 newDate = new Date(this.date);
21308 newDate.setUTCDate(this.date.getUTCDate() + dir);
21309 newViewDate = new Date(this.viewDate);
21310 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
21312 if (this.dateWithinRange(newDate)){
21313 this.date = newDate;
21314 this.viewDate = newViewDate;
21315 this.setValue(this.formatDate(this.date));
21317 e.preventDefault();
21318 dateChanged = true;
21323 if (!this.keyboardNavigation) {
21326 dir = e.keyCode == 38 ? -1 : 1;
21328 newDate = this.moveYear(this.date, dir);
21329 newViewDate = this.moveYear(this.viewDate, dir);
21330 } else if (e.shiftKey){
21331 newDate = this.moveMonth(this.date, dir);
21332 newViewDate = this.moveMonth(this.viewDate, dir);
21334 newDate = new Date(this.date);
21335 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
21336 newViewDate = new Date(this.viewDate);
21337 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
21339 if (this.dateWithinRange(newDate)){
21340 this.date = newDate;
21341 this.viewDate = newViewDate;
21342 this.setValue(this.formatDate(this.date));
21344 e.preventDefault();
21345 dateChanged = true;
21349 this.setValue(this.formatDate(this.date));
21351 e.preventDefault();
21354 this.setValue(this.formatDate(this.date));
21368 onClick: function(e)
21370 e.stopPropagation();
21371 e.preventDefault();
21373 var target = e.getTarget();
21375 if(target.nodeName.toLowerCase() === 'i'){
21376 target = Roo.get(target).dom.parentNode;
21379 var nodeName = target.nodeName;
21380 var className = target.className;
21381 var html = target.innerHTML;
21382 //Roo.log(nodeName);
21384 switch(nodeName.toLowerCase()) {
21386 switch(className) {
21392 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
21393 switch(this.viewMode){
21395 this.viewDate = this.moveMonth(this.viewDate, dir);
21399 this.viewDate = this.moveYear(this.viewDate, dir);
21405 var date = new Date();
21406 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
21408 this.setValue(this.formatDate(this.date));
21415 if (className.indexOf('disabled') < 0) {
21416 this.viewDate.setUTCDate(1);
21417 if (className.indexOf('month') > -1) {
21418 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
21420 var year = parseInt(html, 10) || 0;
21421 this.viewDate.setUTCFullYear(year);
21425 if(this.singleMode){
21426 this.setValue(this.formatDate(this.viewDate));
21437 //Roo.log(className);
21438 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
21439 var day = parseInt(html, 10) || 1;
21440 var year = this.viewDate.getUTCFullYear(),
21441 month = this.viewDate.getUTCMonth();
21443 if (className.indexOf('old') > -1) {
21450 } else if (className.indexOf('new') > -1) {
21458 //Roo.log([year,month,day]);
21459 this.date = this.UTCDate(year, month, day,0,0,0,0);
21460 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
21462 //Roo.log(this.formatDate(this.date));
21463 this.setValue(this.formatDate(this.date));
21470 setStartDate: function(startDate)
21472 this.startDate = startDate || -Infinity;
21473 if (this.startDate !== -Infinity) {
21474 this.startDate = this.parseDate(this.startDate);
21477 this.updateNavArrows();
21480 setEndDate: function(endDate)
21482 this.endDate = endDate || Infinity;
21483 if (this.endDate !== Infinity) {
21484 this.endDate = this.parseDate(this.endDate);
21487 this.updateNavArrows();
21490 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
21492 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
21493 if (typeof(this.daysOfWeekDisabled) !== 'object') {
21494 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
21496 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
21497 return parseInt(d, 10);
21500 this.updateNavArrows();
21503 updateNavArrows: function()
21505 if(this.singleMode){
21509 var d = new Date(this.viewDate),
21510 year = d.getUTCFullYear(),
21511 month = d.getUTCMonth();
21513 Roo.each(this.picker().select('.prev', true).elements, function(v){
21515 switch (this.viewMode) {
21518 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
21524 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
21531 Roo.each(this.picker().select('.next', true).elements, function(v){
21533 switch (this.viewMode) {
21536 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
21542 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
21550 moveMonth: function(date, dir)
21555 var new_date = new Date(date.valueOf()),
21556 day = new_date.getUTCDate(),
21557 month = new_date.getUTCMonth(),
21558 mag = Math.abs(dir),
21560 dir = dir > 0 ? 1 : -1;
21563 // If going back one month, make sure month is not current month
21564 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
21566 return new_date.getUTCMonth() == month;
21568 // If going forward one month, make sure month is as expected
21569 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
21571 return new_date.getUTCMonth() != new_month;
21573 new_month = month + dir;
21574 new_date.setUTCMonth(new_month);
21575 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
21576 if (new_month < 0 || new_month > 11) {
21577 new_month = (new_month + 12) % 12;
21580 // For magnitudes >1, move one month at a time...
21581 for (var i=0; i<mag; i++) {
21582 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
21583 new_date = this.moveMonth(new_date, dir);
21585 // ...then reset the day, keeping it in the new month
21586 new_month = new_date.getUTCMonth();
21587 new_date.setUTCDate(day);
21589 return new_month != new_date.getUTCMonth();
21592 // Common date-resetting loop -- if date is beyond end of month, make it
21595 new_date.setUTCDate(--day);
21596 new_date.setUTCMonth(new_month);
21601 moveYear: function(date, dir)
21603 return this.moveMonth(date, dir*12);
21606 dateWithinRange: function(date)
21608 return date >= this.startDate && date <= this.endDate;
21614 this.picker().remove();
21617 validateValue : function(value)
21619 if(this.getVisibilityEl().hasClass('hidden')){
21623 if(value.length < 1) {
21624 if(this.allowBlank){
21630 if(value.length < this.minLength){
21633 if(value.length > this.maxLength){
21637 var vt = Roo.form.VTypes;
21638 if(!vt[this.vtype](value, this)){
21642 if(typeof this.validator == "function"){
21643 var msg = this.validator(value);
21649 if(this.regex && !this.regex.test(value)){
21653 if(typeof(this.parseDate(value)) == 'undefined'){
21657 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
21661 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
21671 this.date = this.viewDate = '';
21673 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
21678 Roo.apply(Roo.bootstrap.DateField, {
21689 html: '<i class="fa fa-arrow-left"/>'
21699 html: '<i class="fa fa-arrow-right"/>'
21741 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
21742 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
21743 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
21744 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
21745 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
21758 navFnc: 'FullYear',
21763 navFnc: 'FullYear',
21768 Roo.apply(Roo.bootstrap.DateField, {
21772 cls: 'datepicker dropdown-menu roo-dynamic shadow',
21776 cls: 'datepicker-days',
21780 cls: 'table-condensed',
21782 Roo.bootstrap.DateField.head,
21786 Roo.bootstrap.DateField.footer
21793 cls: 'datepicker-months',
21797 cls: 'table-condensed',
21799 Roo.bootstrap.DateField.head,
21800 Roo.bootstrap.DateField.content,
21801 Roo.bootstrap.DateField.footer
21808 cls: 'datepicker-years',
21812 cls: 'table-condensed',
21814 Roo.bootstrap.DateField.head,
21815 Roo.bootstrap.DateField.content,
21816 Roo.bootstrap.DateField.footer
21835 * @class Roo.bootstrap.TimeField
21836 * @extends Roo.bootstrap.Input
21837 * Bootstrap DateField class
21841 * Create a new TimeField
21842 * @param {Object} config The config object
21845 Roo.bootstrap.TimeField = function(config){
21846 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
21850 * Fires when this field show.
21851 * @param {Roo.bootstrap.DateField} thisthis
21852 * @param {Mixed} date The date value
21857 * Fires when this field hide.
21858 * @param {Roo.bootstrap.DateField} this
21859 * @param {Mixed} date The date value
21864 * Fires when select a date.
21865 * @param {Roo.bootstrap.DateField} this
21866 * @param {Mixed} date The date value
21872 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
21875 * @cfg {String} format
21876 * The default time format string which can be overriden for localization support. The format must be
21877 * valid according to {@link Date#parseDate} (defaults to 'H:i').
21881 onRender: function(ct, position)
21884 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
21886 this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.TimeField.template);
21888 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
21890 this.pop = this.picker().select('>.datepicker-time',true).first();
21891 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
21893 this.picker().on('mousedown', this.onMousedown, this);
21894 this.picker().on('click', this.onClick, this);
21896 this.picker().addClass('datepicker-dropdown');
21901 this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
21902 this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
21903 this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
21904 this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
21905 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
21906 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
21910 fireKey: function(e){
21911 if (!this.picker().isVisible()){
21912 if (e.keyCode == 27) { // allow escape to hide and re-show picker
21918 e.preventDefault();
21926 this.onTogglePeriod();
21929 this.onIncrementMinutes();
21932 this.onDecrementMinutes();
21941 onClick: function(e) {
21942 e.stopPropagation();
21943 e.preventDefault();
21946 picker : function()
21948 return this.el.select('.datepicker', true).first();
21951 fillTime: function()
21953 var time = this.pop.select('tbody', true).first();
21955 time.dom.innerHTML = '';
21970 cls: 'hours-up glyphicon glyphicon-chevron-up'
21990 cls: 'minutes-up glyphicon glyphicon-chevron-up'
22011 cls: 'timepicker-hour',
22026 cls: 'timepicker-minute',
22041 cls: 'btn btn-primary period',
22063 cls: 'hours-down glyphicon glyphicon-chevron-down'
22083 cls: 'minutes-down glyphicon glyphicon-chevron-down'
22101 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
22108 var hours = this.time.getHours();
22109 var minutes = this.time.getMinutes();
22122 hours = hours - 12;
22126 hours = '0' + hours;
22130 minutes = '0' + minutes;
22133 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
22134 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
22135 this.pop.select('button', true).first().dom.innerHTML = period;
22141 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
22143 var cls = ['bottom'];
22145 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
22152 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
22157 this.picker().addClass(cls.join('-'));
22161 Roo.each(cls, function(c){
22163 _this.picker().setTop(_this.inputEl().getHeight());
22167 _this.picker().setTop(0 - _this.picker().getHeight());
22172 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
22176 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
22183 onFocus : function()
22185 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
22189 onBlur : function()
22191 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
22197 this.picker().show();
22202 this.fireEvent('show', this, this.date);
22207 this.picker().hide();
22210 this.fireEvent('hide', this, this.date);
22213 setTime : function()
22216 this.setValue(this.time.format(this.format));
22218 this.fireEvent('select', this, this.date);
22223 onMousedown: function(e){
22224 e.stopPropagation();
22225 e.preventDefault();
22228 onIncrementHours: function()
22230 Roo.log('onIncrementHours');
22231 this.time = this.time.add(Date.HOUR, 1);
22236 onDecrementHours: function()
22238 Roo.log('onDecrementHours');
22239 this.time = this.time.add(Date.HOUR, -1);
22243 onIncrementMinutes: function()
22245 Roo.log('onIncrementMinutes');
22246 this.time = this.time.add(Date.MINUTE, 1);
22250 onDecrementMinutes: function()
22252 Roo.log('onDecrementMinutes');
22253 this.time = this.time.add(Date.MINUTE, -1);
22257 onTogglePeriod: function()
22259 Roo.log('onTogglePeriod');
22260 this.time = this.time.add(Date.HOUR, 12);
22267 Roo.apply(Roo.bootstrap.TimeField, {
22297 cls: 'btn btn-info ok',
22309 Roo.apply(Roo.bootstrap.TimeField, {
22313 cls: 'datepicker dropdown-menu',
22317 cls: 'datepicker-time',
22321 cls: 'table-condensed',
22323 Roo.bootstrap.TimeField.content,
22324 Roo.bootstrap.TimeField.footer
22343 * @class Roo.bootstrap.MonthField
22344 * @extends Roo.bootstrap.Input
22345 * Bootstrap MonthField class
22347 * @cfg {String} language default en
22350 * Create a new MonthField
22351 * @param {Object} config The config object
22354 Roo.bootstrap.MonthField = function(config){
22355 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
22360 * Fires when this field show.
22361 * @param {Roo.bootstrap.MonthField} this
22362 * @param {Mixed} date The date value
22367 * Fires when this field hide.
22368 * @param {Roo.bootstrap.MonthField} this
22369 * @param {Mixed} date The date value
22374 * Fires when select a date.
22375 * @param {Roo.bootstrap.MonthField} this
22376 * @param {String} oldvalue The old value
22377 * @param {String} newvalue The new value
22383 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
22385 onRender: function(ct, position)
22388 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
22390 this.language = this.language || 'en';
22391 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
22392 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
22394 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
22395 this.isInline = false;
22396 this.isInput = true;
22397 this.component = this.el.select('.add-on', true).first() || false;
22398 this.component = (this.component && this.component.length === 0) ? false : this.component;
22399 this.hasInput = this.component && this.inputEL().length;
22401 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
22403 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
22405 this.picker().on('mousedown', this.onMousedown, this);
22406 this.picker().on('click', this.onClick, this);
22408 this.picker().addClass('datepicker-dropdown');
22410 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
22411 v.setStyle('width', '189px');
22418 if(this.isInline) {
22424 setValue: function(v, suppressEvent)
22426 var o = this.getValue();
22428 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
22432 if(suppressEvent !== true){
22433 this.fireEvent('select', this, o, v);
22438 getValue: function()
22443 onClick: function(e)
22445 e.stopPropagation();
22446 e.preventDefault();
22448 var target = e.getTarget();
22450 if(target.nodeName.toLowerCase() === 'i'){
22451 target = Roo.get(target).dom.parentNode;
22454 var nodeName = target.nodeName;
22455 var className = target.className;
22456 var html = target.innerHTML;
22458 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
22462 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
22464 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
22470 picker : function()
22472 return this.pickerEl;
22475 fillMonths: function()
22478 var months = this.picker().select('>.datepicker-months td', true).first();
22480 months.dom.innerHTML = '';
22486 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
22489 months.createChild(month);
22498 if(typeof(this.vIndex) == 'undefined' && this.value.length){
22499 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
22502 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
22503 e.removeClass('active');
22505 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
22506 e.addClass('active');
22513 if(this.isInline) {
22517 this.picker().removeClass(['bottom', 'top']);
22519 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
22521 * place to the top of element!
22525 this.picker().addClass('top');
22526 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
22531 this.picker().addClass('bottom');
22533 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
22536 onFocus : function()
22538 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
22542 onBlur : function()
22544 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
22546 var d = this.inputEl().getValue();
22555 this.picker().show();
22556 this.picker().select('>.datepicker-months', true).first().show();
22560 this.fireEvent('show', this, this.date);
22565 if(this.isInline) {
22568 this.picker().hide();
22569 this.fireEvent('hide', this, this.date);
22573 onMousedown: function(e)
22575 e.stopPropagation();
22576 e.preventDefault();
22581 Roo.bootstrap.MonthField.superclass.keyup.call(this);
22585 fireKey: function(e)
22587 if (!this.picker().isVisible()){
22588 if (e.keyCode == 27) {// allow escape to hide and re-show picker
22599 e.preventDefault();
22603 dir = e.keyCode == 37 ? -1 : 1;
22605 this.vIndex = this.vIndex + dir;
22607 if(this.vIndex < 0){
22611 if(this.vIndex > 11){
22615 if(isNaN(this.vIndex)){
22619 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
22625 dir = e.keyCode == 38 ? -1 : 1;
22627 this.vIndex = this.vIndex + dir * 4;
22629 if(this.vIndex < 0){
22633 if(this.vIndex > 11){
22637 if(isNaN(this.vIndex)){
22641 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
22646 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
22647 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
22651 e.preventDefault();
22654 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
22655 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
22671 this.picker().remove();
22676 Roo.apply(Roo.bootstrap.MonthField, {
22695 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
22696 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
22701 Roo.apply(Roo.bootstrap.MonthField, {
22705 cls: 'datepicker dropdown-menu roo-dynamic',
22709 cls: 'datepicker-months',
22713 cls: 'table-condensed',
22715 Roo.bootstrap.DateField.content
22735 * @class Roo.bootstrap.CheckBox
22736 * @extends Roo.bootstrap.Input
22737 * Bootstrap CheckBox class
22739 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
22740 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
22741 * @cfg {String} boxLabel The text that appears beside the checkbox
22742 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
22743 * @cfg {Boolean} checked initnal the element
22744 * @cfg {Boolean} inline inline the element (default false)
22745 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
22746 * @cfg {String} tooltip label tooltip
22749 * Create a new CheckBox
22750 * @param {Object} config The config object
22753 Roo.bootstrap.CheckBox = function(config){
22754 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
22759 * Fires when the element is checked or unchecked.
22760 * @param {Roo.bootstrap.CheckBox} this This input
22761 * @param {Boolean} checked The new checked value
22766 * Fires when the element is click.
22767 * @param {Roo.bootstrap.CheckBox} this This input
22774 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
22776 inputType: 'checkbox',
22785 // checkbox success does not make any sense really..
22790 getAutoCreate : function()
22792 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
22798 cfg.cls = 'form-group form-check ' + this.inputType; //input-group
22801 cfg.cls += ' ' + this.inputType + '-inline form-check-inline';
22807 type : this.inputType,
22808 value : this.inputValue,
22809 cls : 'roo-' + this.inputType, //'form-box',
22810 placeholder : this.placeholder || ''
22814 if(this.inputType != 'radio'){
22818 cls : 'roo-hidden-value',
22819 value : this.checked ? this.inputValue : this.valueOff
22824 if (this.weight) { // Validity check?
22825 cfg.cls += " " + this.inputType + "-" + this.weight;
22828 if (this.disabled) {
22829 input.disabled=true;
22833 input.checked = this.checked;
22838 input.name = this.name;
22840 if(this.inputType != 'radio'){
22841 hidden.name = this.name;
22842 input.name = '_hidden_' + this.name;
22847 input.cls += ' input-' + this.size;
22852 ['xs','sm','md','lg'].map(function(size){
22853 if (settings[size]) {
22854 cfg.cls += ' col-' + size + '-' + settings[size];
22858 var inputblock = input;
22860 if (this.before || this.after) {
22863 cls : 'input-group',
22868 inputblock.cn.push({
22870 cls : 'input-group-addon',
22875 inputblock.cn.push(input);
22877 if(this.inputType != 'radio'){
22878 inputblock.cn.push(hidden);
22882 inputblock.cn.push({
22884 cls : 'input-group-addon',
22890 var boxLabelCfg = false;
22896 //'for': id, // box label is handled by onclick - so no for...
22898 html: this.boxLabel
22901 boxLabelCfg.tooltip = this.tooltip;
22907 if (align ==='left' && this.fieldLabel.length) {
22908 // Roo.log("left and has label");
22913 cls : 'control-label',
22914 html : this.fieldLabel
22925 cfg.cn[1].cn.push(boxLabelCfg);
22928 if(this.labelWidth > 12){
22929 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
22932 if(this.labelWidth < 13 && this.labelmd == 0){
22933 this.labelmd = this.labelWidth;
22936 if(this.labellg > 0){
22937 cfg.cn[0].cls += ' col-lg-' + this.labellg;
22938 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
22941 if(this.labelmd > 0){
22942 cfg.cn[0].cls += ' col-md-' + this.labelmd;
22943 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
22946 if(this.labelsm > 0){
22947 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
22948 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
22951 if(this.labelxs > 0){
22952 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
22953 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
22956 } else if ( this.fieldLabel.length) {
22957 // Roo.log(" label");
22961 tag: this.boxLabel ? 'span' : 'label',
22963 cls: 'control-label box-input-label',
22964 //cls : 'input-group-addon',
22965 html : this.fieldLabel
22972 cfg.cn.push(boxLabelCfg);
22977 // Roo.log(" no label && no align");
22978 cfg.cn = [ inputblock ] ;
22980 cfg.cn.push(boxLabelCfg);
22988 if(this.inputType != 'radio'){
22989 cfg.cn.push(hidden);
22997 * return the real input element.
22999 inputEl: function ()
23001 return this.el.select('input.roo-' + this.inputType,true).first();
23003 hiddenEl: function ()
23005 return this.el.select('input.roo-hidden-value',true).first();
23008 labelEl: function()
23010 return this.el.select('label.control-label',true).first();
23012 /* depricated... */
23016 return this.labelEl();
23019 boxLabelEl: function()
23021 return this.el.select('label.box-label',true).first();
23024 initEvents : function()
23026 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
23028 this.inputEl().on('click', this.onClick, this);
23030 if (this.boxLabel) {
23031 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
23034 this.startValue = this.getValue();
23037 Roo.bootstrap.CheckBox.register(this);
23041 onClick : function(e)
23043 if(this.fireEvent('click', this, e) !== false){
23044 this.setChecked(!this.checked);
23049 setChecked : function(state,suppressEvent)
23051 this.startValue = this.getValue();
23053 if(this.inputType == 'radio'){
23055 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
23056 e.dom.checked = false;
23059 this.inputEl().dom.checked = true;
23061 this.inputEl().dom.value = this.inputValue;
23063 if(suppressEvent !== true){
23064 this.fireEvent('check', this, true);
23072 this.checked = state;
23074 this.inputEl().dom.checked = state;
23077 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
23079 if(suppressEvent !== true){
23080 this.fireEvent('check', this, state);
23086 getValue : function()
23088 if(this.inputType == 'radio'){
23089 return this.getGroupValue();
23092 return this.hiddenEl().dom.value;
23096 getGroupValue : function()
23098 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
23102 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
23105 setValue : function(v,suppressEvent)
23107 if(this.inputType == 'radio'){
23108 this.setGroupValue(v, suppressEvent);
23112 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
23117 setGroupValue : function(v, suppressEvent)
23119 this.startValue = this.getValue();
23121 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
23122 e.dom.checked = false;
23124 if(e.dom.value == v){
23125 e.dom.checked = true;
23129 if(suppressEvent !== true){
23130 this.fireEvent('check', this, true);
23138 validate : function()
23140 if(this.getVisibilityEl().hasClass('hidden')){
23146 (this.inputType == 'radio' && this.validateRadio()) ||
23147 (this.inputType == 'checkbox' && this.validateCheckbox())
23153 this.markInvalid();
23157 validateRadio : function()
23159 if(this.getVisibilityEl().hasClass('hidden')){
23163 if(this.allowBlank){
23169 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
23170 if(!e.dom.checked){
23182 validateCheckbox : function()
23185 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
23186 //return (this.getValue() == this.inputValue) ? true : false;
23189 var group = Roo.bootstrap.CheckBox.get(this.groupId);
23197 for(var i in group){
23198 if(group[i].el.isVisible(true)){
23206 for(var i in group){
23211 r = (group[i].getValue() == group[i].inputValue) ? true : false;
23218 * Mark this field as valid
23220 markValid : function()
23224 this.fireEvent('valid', this);
23226 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
23229 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
23236 if(this.inputType == 'radio'){
23237 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
23238 var fg = e.findParent('.form-group', false, true);
23239 if (Roo.bootstrap.version == 3) {
23240 fg.removeClass([_this.invalidClass, _this.validClass]);
23241 fg.addClass(_this.validClass);
23243 fg.removeClass(['is-valid', 'is-invalid']);
23244 fg.addClass('is-valid');
23252 var fg = this.el.findParent('.form-group', false, true);
23253 if (Roo.bootstrap.version == 3) {
23254 fg.removeClass([this.invalidClass, this.validClass]);
23255 fg.addClass(this.validClass);
23257 fg.removeClass(['is-valid', 'is-invalid']);
23258 fg.addClass('is-valid');
23263 var group = Roo.bootstrap.CheckBox.get(this.groupId);
23269 for(var i in group){
23270 var fg = group[i].el.findParent('.form-group', false, true);
23271 if (Roo.bootstrap.version == 3) {
23272 fg.removeClass([this.invalidClass, this.validClass]);
23273 fg.addClass(this.validClass);
23275 fg.removeClass(['is-valid', 'is-invalid']);
23276 fg.addClass('is-valid');
23282 * Mark this field as invalid
23283 * @param {String} msg The validation message
23285 markInvalid : function(msg)
23287 if(this.allowBlank){
23293 this.fireEvent('invalid', this, msg);
23295 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
23298 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
23302 label.markInvalid();
23305 if(this.inputType == 'radio'){
23307 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
23308 var fg = e.findParent('.form-group', false, true);
23309 if (Roo.bootstrap.version == 3) {
23310 fg.removeClass([_this.invalidClass, _this.validClass]);
23311 fg.addClass(_this.invalidClass);
23313 fg.removeClass(['is-invalid', 'is-valid']);
23314 fg.addClass('is-invalid');
23322 var fg = this.el.findParent('.form-group', false, true);
23323 if (Roo.bootstrap.version == 3) {
23324 fg.removeClass([_this.invalidClass, _this.validClass]);
23325 fg.addClass(_this.invalidClass);
23327 fg.removeClass(['is-invalid', 'is-valid']);
23328 fg.addClass('is-invalid');
23333 var group = Roo.bootstrap.CheckBox.get(this.groupId);
23339 for(var i in group){
23340 var fg = group[i].el.findParent('.form-group', false, true);
23341 if (Roo.bootstrap.version == 3) {
23342 fg.removeClass([_this.invalidClass, _this.validClass]);
23343 fg.addClass(_this.invalidClass);
23345 fg.removeClass(['is-invalid', 'is-valid']);
23346 fg.addClass('is-invalid');
23352 clearInvalid : function()
23354 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
23356 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
23358 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
23360 if (label && label.iconEl) {
23361 label.iconEl.removeClass([ label.validClass, label.invalidClass ]);
23362 label.iconEl.removeClass(['is-invalid', 'is-valid']);
23366 disable : function()
23368 if(this.inputType != 'radio'){
23369 Roo.bootstrap.CheckBox.superclass.disable.call(this);
23376 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
23377 _this.getActionEl().addClass(this.disabledClass);
23378 e.dom.disabled = true;
23382 this.disabled = true;
23383 this.fireEvent("disable", this);
23387 enable : function()
23389 if(this.inputType != 'radio'){
23390 Roo.bootstrap.CheckBox.superclass.enable.call(this);
23397 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
23398 _this.getActionEl().removeClass(this.disabledClass);
23399 e.dom.disabled = false;
23403 this.disabled = false;
23404 this.fireEvent("enable", this);
23408 setBoxLabel : function(v)
23413 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
23419 Roo.apply(Roo.bootstrap.CheckBox, {
23424 * register a CheckBox Group
23425 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
23427 register : function(checkbox)
23429 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
23430 this.groups[checkbox.groupId] = {};
23433 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
23437 this.groups[checkbox.groupId][checkbox.name] = checkbox;
23441 * fetch a CheckBox Group based on the group ID
23442 * @param {string} the group ID
23443 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
23445 get: function(groupId) {
23446 if (typeof(this.groups[groupId]) == 'undefined') {
23450 return this.groups[groupId] ;
23463 * @class Roo.bootstrap.Radio
23464 * @extends Roo.bootstrap.Component
23465 * Bootstrap Radio class
23466 * @cfg {String} boxLabel - the label associated
23467 * @cfg {String} value - the value of radio
23470 * Create a new Radio
23471 * @param {Object} config The config object
23473 Roo.bootstrap.Radio = function(config){
23474 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
23478 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
23484 getAutoCreate : function()
23488 cls : 'form-group radio',
23493 html : this.boxLabel
23501 initEvents : function()
23503 this.parent().register(this);
23505 this.el.on('click', this.onClick, this);
23509 onClick : function(e)
23511 if(this.parent().fireEvent('click', this.parent(), this, e) !== false){
23512 this.setChecked(true);
23516 setChecked : function(state, suppressEvent)
23518 this.parent().setValue(this.value, suppressEvent);
23522 setBoxLabel : function(v)
23527 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
23542 * @class Roo.bootstrap.SecurePass
23543 * @extends Roo.bootstrap.Input
23544 * Bootstrap SecurePass class
23548 * Create a new SecurePass
23549 * @param {Object} config The config object
23552 Roo.bootstrap.SecurePass = function (config) {
23553 // these go here, so the translation tool can replace them..
23555 PwdEmpty: "Please type a password, and then retype it to confirm.",
23556 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
23557 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
23558 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
23559 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
23560 FNInPwd: "Your password can't contain your first name. Please type a different password.",
23561 LNInPwd: "Your password can't contain your last name. Please type a different password.",
23562 TooWeak: "Your password is Too Weak."
23564 this.meterLabel = "Password strength:";
23565 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
23566 this.meterClass = [
23567 "roo-password-meter-tooweak",
23568 "roo-password-meter-weak",
23569 "roo-password-meter-medium",
23570 "roo-password-meter-strong",
23571 "roo-password-meter-grey"
23576 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
23579 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
23581 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
23583 * PwdEmpty: "Please type a password, and then retype it to confirm.",
23584 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
23585 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
23586 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
23587 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
23588 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
23589 * LNInPwd: "Your password can't contain your last name. Please type a different password."
23599 * @cfg {String/Object} Label for the strength meter (defaults to
23600 * 'Password strength:')
23605 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
23606 * ['Weak', 'Medium', 'Strong'])
23609 pwdStrengths: false,
23622 initEvents: function ()
23624 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
23626 if (this.el.is('input[type=password]') && Roo.isSafari) {
23627 this.el.on('keydown', this.SafariOnKeyDown, this);
23630 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
23633 onRender: function (ct, position)
23635 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
23636 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
23637 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
23639 this.trigger.createChild({
23644 cls: 'roo-password-meter-grey col-xs-12',
23647 //width: this.meterWidth + 'px'
23651 cls: 'roo-password-meter-text'
23657 if (this.hideTrigger) {
23658 this.trigger.setDisplayed(false);
23660 this.setSize(this.width || '', this.height || '');
23663 onDestroy: function ()
23665 if (this.trigger) {
23666 this.trigger.removeAllListeners();
23667 this.trigger.remove();
23670 this.wrap.remove();
23672 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
23675 checkStrength: function ()
23677 var pwd = this.inputEl().getValue();
23678 if (pwd == this._lastPwd) {
23683 if (this.ClientSideStrongPassword(pwd)) {
23685 } else if (this.ClientSideMediumPassword(pwd)) {
23687 } else if (this.ClientSideWeakPassword(pwd)) {
23693 Roo.log('strength1: ' + strength);
23695 //var pm = this.trigger.child('div/div/div').dom;
23696 var pm = this.trigger.child('div/div');
23697 pm.removeClass(this.meterClass);
23698 pm.addClass(this.meterClass[strength]);
23701 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
23703 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
23705 this._lastPwd = pwd;
23709 Roo.bootstrap.SecurePass.superclass.reset.call(this);
23711 this._lastPwd = '';
23713 var pm = this.trigger.child('div/div');
23714 pm.removeClass(this.meterClass);
23715 pm.addClass('roo-password-meter-grey');
23718 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
23721 this.inputEl().dom.type='password';
23724 validateValue: function (value)
23726 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
23729 if (value.length == 0) {
23730 if (this.allowBlank) {
23731 this.clearInvalid();
23735 this.markInvalid(this.errors.PwdEmpty);
23736 this.errorMsg = this.errors.PwdEmpty;
23744 if (!value.match(/[\x21-\x7e]+/)) {
23745 this.markInvalid(this.errors.PwdBadChar);
23746 this.errorMsg = this.errors.PwdBadChar;
23749 if (value.length < 6) {
23750 this.markInvalid(this.errors.PwdShort);
23751 this.errorMsg = this.errors.PwdShort;
23754 if (value.length > 16) {
23755 this.markInvalid(this.errors.PwdLong);
23756 this.errorMsg = this.errors.PwdLong;
23760 if (this.ClientSideStrongPassword(value)) {
23762 } else if (this.ClientSideMediumPassword(value)) {
23764 } else if (this.ClientSideWeakPassword(value)) {
23771 if (strength < 2) {
23772 //this.markInvalid(this.errors.TooWeak);
23773 this.errorMsg = this.errors.TooWeak;
23778 console.log('strength2: ' + strength);
23780 //var pm = this.trigger.child('div/div/div').dom;
23782 var pm = this.trigger.child('div/div');
23783 pm.removeClass(this.meterClass);
23784 pm.addClass(this.meterClass[strength]);
23786 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
23788 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
23790 this.errorMsg = '';
23794 CharacterSetChecks: function (type)
23797 this.fResult = false;
23800 isctype: function (character, type)
23803 case this.kCapitalLetter:
23804 if (character >= 'A' && character <= 'Z') {
23809 case this.kSmallLetter:
23810 if (character >= 'a' && character <= 'z') {
23816 if (character >= '0' && character <= '9') {
23821 case this.kPunctuation:
23822 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
23833 IsLongEnough: function (pwd, size)
23835 return !(pwd == null || isNaN(size) || pwd.length < size);
23838 SpansEnoughCharacterSets: function (word, nb)
23840 if (!this.IsLongEnough(word, nb))
23845 var characterSetChecks = new Array(
23846 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
23847 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
23850 for (var index = 0; index < word.length; ++index) {
23851 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
23852 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
23853 characterSetChecks[nCharSet].fResult = true;
23860 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
23861 if (characterSetChecks[nCharSet].fResult) {
23866 if (nCharSets < nb) {
23872 ClientSideStrongPassword: function (pwd)
23874 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
23877 ClientSideMediumPassword: function (pwd)
23879 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
23882 ClientSideWeakPassword: function (pwd)
23884 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
23887 })//<script type="text/javascript">
23890 * Based Ext JS Library 1.1.1
23891 * Copyright(c) 2006-2007, Ext JS, LLC.
23897 * @class Roo.HtmlEditorCore
23898 * @extends Roo.Component
23899 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
23901 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
23904 Roo.HtmlEditorCore = function(config){
23907 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
23912 * @event initialize
23913 * Fires when the editor is fully initialized (including the iframe)
23914 * @param {Roo.HtmlEditorCore} this
23919 * Fires when the editor is first receives the focus. Any insertion must wait
23920 * until after this event.
23921 * @param {Roo.HtmlEditorCore} this
23925 * @event beforesync
23926 * Fires before the textarea is updated with content from the editor iframe. Return false
23927 * to cancel the sync.
23928 * @param {Roo.HtmlEditorCore} this
23929 * @param {String} html
23933 * @event beforepush
23934 * Fires before the iframe editor is updated with content from the textarea. Return false
23935 * to cancel the push.
23936 * @param {Roo.HtmlEditorCore} this
23937 * @param {String} html
23942 * Fires when the textarea is updated with content from the editor iframe.
23943 * @param {Roo.HtmlEditorCore} this
23944 * @param {String} html
23949 * Fires when the iframe editor is updated with content from the textarea.
23950 * @param {Roo.HtmlEditorCore} this
23951 * @param {String} html
23956 * @event editorevent
23957 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
23958 * @param {Roo.HtmlEditorCore} this
23964 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
23966 // defaults : white / black...
23967 this.applyBlacklists();
23974 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
23978 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
23984 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
23989 * @cfg {Number} height (in pixels)
23993 * @cfg {Number} width (in pixels)
23998 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
24001 stylesheets: false,
24006 // private properties
24007 validationEvent : false,
24009 initialized : false,
24011 sourceEditMode : false,
24012 onFocus : Roo.emptyFn,
24014 hideMode:'offsets',
24018 // blacklist + whitelisted elements..
24025 * Protected method that will not generally be called directly. It
24026 * is called when the editor initializes the iframe with HTML contents. Override this method if you
24027 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
24029 getDocMarkup : function(){
24033 // inherit styels from page...??
24034 if (this.stylesheets === false) {
24036 Roo.get(document.head).select('style').each(function(node) {
24037 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
24040 Roo.get(document.head).select('link').each(function(node) {
24041 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
24044 } else if (!this.stylesheets.length) {
24046 st = '<style type="text/css">' +
24047 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
24050 for (var i in this.stylesheets) {
24051 st += '<link rel="stylesheet" href="' + this.stylesheets[i] +'" type="text/css">';
24056 st += '<style type="text/css">' +
24057 'IMG { cursor: pointer } ' +
24060 var cls = 'roo-htmleditor-body';
24062 if(this.bodyCls.length){
24063 cls += ' ' + this.bodyCls;
24066 return '<html><head>' + st +
24067 //<style type="text/css">' +
24068 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
24070 ' </head><body contenteditable="true" data-enable-grammerly="true" class="' + cls + '"></body></html>';
24074 onRender : function(ct, position)
24077 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
24078 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
24081 this.el.dom.style.border = '0 none';
24082 this.el.dom.setAttribute('tabIndex', -1);
24083 this.el.addClass('x-hidden hide');
24087 if(Roo.isIE){ // fix IE 1px bogus margin
24088 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
24092 this.frameId = Roo.id();
24096 var iframe = this.owner.wrap.createChild({
24098 cls: 'form-control', // bootstrap..
24100 name: this.frameId,
24101 frameBorder : 'no',
24102 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
24107 this.iframe = iframe.dom;
24109 this.assignDocWin();
24111 this.doc.designMode = 'on';
24114 this.doc.write(this.getDocMarkup());
24118 var task = { // must defer to wait for browser to be ready
24120 //console.log("run task?" + this.doc.readyState);
24121 this.assignDocWin();
24122 if(this.doc.body || this.doc.readyState == 'complete'){
24124 this.doc.designMode="on";
24128 Roo.TaskMgr.stop(task);
24129 this.initEditor.defer(10, this);
24136 Roo.TaskMgr.start(task);
24141 onResize : function(w, h)
24143 Roo.log('resize: ' +w + ',' + h );
24144 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
24148 if(typeof w == 'number'){
24150 this.iframe.style.width = w + 'px';
24152 if(typeof h == 'number'){
24154 this.iframe.style.height = h + 'px';
24156 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
24163 * Toggles the editor between standard and source edit mode.
24164 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
24166 toggleSourceEdit : function(sourceEditMode){
24168 this.sourceEditMode = sourceEditMode === true;
24170 if(this.sourceEditMode){
24172 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
24175 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
24176 //this.iframe.className = '';
24179 //this.setSize(this.owner.wrap.getSize());
24180 //this.fireEvent('editmodechange', this, this.sourceEditMode);
24187 * Protected method that will not generally be called directly. If you need/want
24188 * custom HTML cleanup, this is the method you should override.
24189 * @param {String} html The HTML to be cleaned
24190 * return {String} The cleaned HTML
24192 cleanHtml : function(html){
24193 html = String(html);
24194 if(html.length > 5){
24195 if(Roo.isSafari){ // strip safari nonsense
24196 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
24199 if(html == ' '){
24206 * HTML Editor -> Textarea
24207 * Protected method that will not generally be called directly. Syncs the contents
24208 * of the editor iframe with the textarea.
24210 syncValue : function(){
24211 if(this.initialized){
24212 var bd = (this.doc.body || this.doc.documentElement);
24213 //this.cleanUpPaste(); -- this is done else where and causes havoc..
24214 var html = bd.innerHTML;
24216 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
24217 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
24219 html = '<div style="'+m[0]+'">' + html + '</div>';
24222 html = this.cleanHtml(html);
24223 // fix up the special chars.. normaly like back quotes in word...
24224 // however we do not want to do this with chinese..
24225 html = html.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[\u0080-\uFFFF]/g, function(match) {
24227 var cc = match.charCodeAt();
24229 // Get the character value, handling surrogate pairs
24230 if (match.length == 2) {
24231 // It's a surrogate pair, calculate the Unicode code point
24232 var high = match.charCodeAt(0) - 0xD800;
24233 var low = match.charCodeAt(1) - 0xDC00;
24234 cc = (high * 0x400) + low + 0x10000;
24236 (cc >= 0x4E00 && cc < 0xA000 ) ||
24237 (cc >= 0x3400 && cc < 0x4E00 ) ||
24238 (cc >= 0xf900 && cc < 0xfb00 )
24243 // No, use a numeric entity. Here we brazenly (and possibly mistakenly)
24244 return "&#" + cc + ";";
24251 if(this.owner.fireEvent('beforesync', this, html) !== false){
24252 this.el.dom.value = html;
24253 this.owner.fireEvent('sync', this, html);
24259 * Protected method that will not generally be called directly. Pushes the value of the textarea
24260 * into the iframe editor.
24262 pushValue : function(){
24263 if(this.initialized){
24264 var v = this.el.dom.value.trim();
24266 // if(v.length < 1){
24270 if(this.owner.fireEvent('beforepush', this, v) !== false){
24271 var d = (this.doc.body || this.doc.documentElement);
24273 this.cleanUpPaste();
24274 this.el.dom.value = d.innerHTML;
24275 this.owner.fireEvent('push', this, v);
24281 deferFocus : function(){
24282 this.focus.defer(10, this);
24286 focus : function(){
24287 if(this.win && !this.sourceEditMode){
24294 assignDocWin: function()
24296 var iframe = this.iframe;
24299 this.doc = iframe.contentWindow.document;
24300 this.win = iframe.contentWindow;
24302 // if (!Roo.get(this.frameId)) {
24305 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
24306 // this.win = Roo.get(this.frameId).dom.contentWindow;
24308 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
24312 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
24313 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
24318 initEditor : function(){
24319 //console.log("INIT EDITOR");
24320 this.assignDocWin();
24324 this.doc.designMode="on";
24326 this.doc.write(this.getDocMarkup());
24329 var dbody = (this.doc.body || this.doc.documentElement);
24330 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
24331 // this copies styles from the containing element into thsi one..
24332 // not sure why we need all of this..
24333 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
24335 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
24336 //ss['background-attachment'] = 'fixed'; // w3c
24337 dbody.bgProperties = 'fixed'; // ie
24338 //Roo.DomHelper.applyStyles(dbody, ss);
24339 Roo.EventManager.on(this.doc, {
24340 //'mousedown': this.onEditorEvent,
24341 'mouseup': this.onEditorEvent,
24342 'dblclick': this.onEditorEvent,
24343 'click': this.onEditorEvent,
24344 'keyup': this.onEditorEvent,
24349 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
24351 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
24352 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
24354 this.initialized = true;
24356 this.owner.fireEvent('initialize', this);
24361 onDestroy : function(){
24367 //for (var i =0; i < this.toolbars.length;i++) {
24368 // // fixme - ask toolbars for heights?
24369 // this.toolbars[i].onDestroy();
24372 //this.wrap.dom.innerHTML = '';
24373 //this.wrap.remove();
24378 onFirstFocus : function(){
24380 this.assignDocWin();
24383 this.activated = true;
24386 if(Roo.isGecko){ // prevent silly gecko errors
24388 var s = this.win.getSelection();
24389 if(!s.focusNode || s.focusNode.nodeType != 3){
24390 var r = s.getRangeAt(0);
24391 r.selectNodeContents((this.doc.body || this.doc.documentElement));
24396 this.execCmd('useCSS', true);
24397 this.execCmd('styleWithCSS', false);
24400 this.owner.fireEvent('activate', this);
24404 adjustFont: function(btn){
24405 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
24406 //if(Roo.isSafari){ // safari
24409 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
24410 if(Roo.isSafari){ // safari
24411 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
24412 v = (v < 10) ? 10 : v;
24413 v = (v > 48) ? 48 : v;
24414 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
24419 v = Math.max(1, v+adjust);
24421 this.execCmd('FontSize', v );
24424 onEditorEvent : function(e)
24426 this.owner.fireEvent('editorevent', this, e);
24427 // this.updateToolbar();
24428 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
24431 insertTag : function(tg)
24433 // could be a bit smarter... -> wrap the current selected tRoo..
24434 if (tg.toLowerCase() == 'span' ||
24435 tg.toLowerCase() == 'code' ||
24436 tg.toLowerCase() == 'sup' ||
24437 tg.toLowerCase() == 'sub'
24440 range = this.createRange(this.getSelection());
24441 var wrappingNode = this.doc.createElement(tg.toLowerCase());
24442 wrappingNode.appendChild(range.extractContents());
24443 range.insertNode(wrappingNode);
24450 this.execCmd("formatblock", tg);
24454 insertText : function(txt)
24458 var range = this.createRange();
24459 range.deleteContents();
24460 //alert(Sender.getAttribute('label'));
24462 range.insertNode(this.doc.createTextNode(txt));
24468 * Executes a Midas editor command on the editor document and performs necessary focus and
24469 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
24470 * @param {String} cmd The Midas command
24471 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
24473 relayCmd : function(cmd, value){
24475 this.execCmd(cmd, value);
24476 this.owner.fireEvent('editorevent', this);
24477 //this.updateToolbar();
24478 this.owner.deferFocus();
24482 * Executes a Midas editor command directly on the editor document.
24483 * For visual commands, you should use {@link #relayCmd} instead.
24484 * <b>This should only be called after the editor is initialized.</b>
24485 * @param {String} cmd The Midas command
24486 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
24488 execCmd : function(cmd, value){
24489 this.doc.execCommand(cmd, false, value === undefined ? null : value);
24496 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
24498 * @param {String} text | dom node..
24500 insertAtCursor : function(text)
24503 if(!this.activated){
24509 var r = this.doc.selection.createRange();
24520 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
24524 // from jquery ui (MIT licenced)
24526 var win = this.win;
24528 if (win.getSelection && win.getSelection().getRangeAt) {
24529 range = win.getSelection().getRangeAt(0);
24530 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
24531 range.insertNode(node);
24532 } else if (win.document.selection && win.document.selection.createRange) {
24533 // no firefox support
24534 var txt = typeof(text) == 'string' ? text : text.outerHTML;
24535 win.document.selection.createRange().pasteHTML(txt);
24537 // no firefox support
24538 var txt = typeof(text) == 'string' ? text : text.outerHTML;
24539 this.execCmd('InsertHTML', txt);
24548 mozKeyPress : function(e){
24550 var c = e.getCharCode(), cmd;
24553 c = String.fromCharCode(c).toLowerCase();
24567 this.cleanUpPaste.defer(100, this);
24575 e.preventDefault();
24583 fixKeys : function(){ // load time branching for fastest keydown performance
24585 return function(e){
24586 var k = e.getKey(), r;
24589 r = this.doc.selection.createRange();
24592 r.pasteHTML('    ');
24599 r = this.doc.selection.createRange();
24601 var target = r.parentElement();
24602 if(!target || target.tagName.toLowerCase() != 'li'){
24604 r.pasteHTML('<br />');
24610 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
24611 this.cleanUpPaste.defer(100, this);
24617 }else if(Roo.isOpera){
24618 return function(e){
24619 var k = e.getKey();
24623 this.execCmd('InsertHTML','    ');
24626 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
24627 this.cleanUpPaste.defer(100, this);
24632 }else if(Roo.isSafari){
24633 return function(e){
24634 var k = e.getKey();
24638 this.execCmd('InsertText','\t');
24642 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
24643 this.cleanUpPaste.defer(100, this);
24651 getAllAncestors: function()
24653 var p = this.getSelectedNode();
24656 a.push(p); // push blank onto stack..
24657 p = this.getParentElement();
24661 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
24665 a.push(this.doc.body);
24669 lastSelNode : false,
24672 getSelection : function()
24674 this.assignDocWin();
24675 return Roo.isIE ? this.doc.selection : this.win.getSelection();
24678 getSelectedNode: function()
24680 // this may only work on Gecko!!!
24682 // should we cache this!!!!
24687 var range = this.createRange(this.getSelection()).cloneRange();
24690 var parent = range.parentElement();
24692 var testRange = range.duplicate();
24693 testRange.moveToElementText(parent);
24694 if (testRange.inRange(range)) {
24697 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
24700 parent = parent.parentElement;
24705 // is ancestor a text element.
24706 var ac = range.commonAncestorContainer;
24707 if (ac.nodeType == 3) {
24708 ac = ac.parentNode;
24711 var ar = ac.childNodes;
24714 var other_nodes = [];
24715 var has_other_nodes = false;
24716 for (var i=0;i<ar.length;i++) {
24717 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
24720 // fullly contained node.
24722 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
24727 // probably selected..
24728 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
24729 other_nodes.push(ar[i]);
24733 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
24738 has_other_nodes = true;
24740 if (!nodes.length && other_nodes.length) {
24741 nodes= other_nodes;
24743 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
24749 createRange: function(sel)
24751 // this has strange effects when using with
24752 // top toolbar - not sure if it's a great idea.
24753 //this.editor.contentWindow.focus();
24754 if (typeof sel != "undefined") {
24756 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
24758 return this.doc.createRange();
24761 return this.doc.createRange();
24764 getParentElement: function()
24767 this.assignDocWin();
24768 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
24770 var range = this.createRange(sel);
24773 var p = range.commonAncestorContainer;
24774 while (p.nodeType == 3) { // text node
24785 * Range intersection.. the hard stuff...
24789 * [ -- selected range --- ]
24793 * if end is before start or hits it. fail.
24794 * if start is after end or hits it fail.
24796 * if either hits (but other is outside. - then it's not
24802 // @see http://www.thismuchiknow.co.uk/?p=64.
24803 rangeIntersectsNode : function(range, node)
24805 var nodeRange = node.ownerDocument.createRange();
24807 nodeRange.selectNode(node);
24809 nodeRange.selectNodeContents(node);
24812 var rangeStartRange = range.cloneRange();
24813 rangeStartRange.collapse(true);
24815 var rangeEndRange = range.cloneRange();
24816 rangeEndRange.collapse(false);
24818 var nodeStartRange = nodeRange.cloneRange();
24819 nodeStartRange.collapse(true);
24821 var nodeEndRange = nodeRange.cloneRange();
24822 nodeEndRange.collapse(false);
24824 return rangeStartRange.compareBoundaryPoints(
24825 Range.START_TO_START, nodeEndRange) == -1 &&
24826 rangeEndRange.compareBoundaryPoints(
24827 Range.START_TO_START, nodeStartRange) == 1;
24831 rangeCompareNode : function(range, node)
24833 var nodeRange = node.ownerDocument.createRange();
24835 nodeRange.selectNode(node);
24837 nodeRange.selectNodeContents(node);
24841 range.collapse(true);
24843 nodeRange.collapse(true);
24845 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
24846 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
24848 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
24850 var nodeIsBefore = ss == 1;
24851 var nodeIsAfter = ee == -1;
24853 if (nodeIsBefore && nodeIsAfter) {
24856 if (!nodeIsBefore && nodeIsAfter) {
24857 return 1; //right trailed.
24860 if (nodeIsBefore && !nodeIsAfter) {
24861 return 2; // left trailed.
24867 // private? - in a new class?
24868 cleanUpPaste : function()
24870 // cleans up the whole document..
24871 Roo.log('cleanuppaste');
24873 this.cleanUpChildren(this.doc.body);
24874 var clean = this.cleanWordChars(this.doc.body.innerHTML);
24875 if (clean != this.doc.body.innerHTML) {
24876 this.doc.body.innerHTML = clean;
24881 cleanWordChars : function(input) {// change the chars to hex code
24882 var he = Roo.HtmlEditorCore;
24884 var output = input;
24885 Roo.each(he.swapCodes, function(sw) {
24886 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
24888 output = output.replace(swapper, sw[1]);
24895 cleanUpChildren : function (n)
24897 if (!n.childNodes.length) {
24900 for (var i = n.childNodes.length-1; i > -1 ; i--) {
24901 this.cleanUpChild(n.childNodes[i]);
24908 cleanUpChild : function (node)
24911 //console.log(node);
24912 if (node.nodeName == "#text") {
24913 // clean up silly Windows -- stuff?
24916 if (node.nodeName == "#comment") {
24917 node.parentNode.removeChild(node);
24918 // clean up silly Windows -- stuff?
24921 var lcname = node.tagName.toLowerCase();
24922 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
24923 // whitelist of tags..
24925 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
24927 node.parentNode.removeChild(node);
24932 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
24934 // spans with no attributes - just remove them..
24935 if ((!node.attributes || !node.attributes.length) && lcname == 'span') {
24936 remove_keep_children = true;
24939 // remove <a name=....> as rendering on yahoo mailer is borked with this.
24940 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
24942 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
24943 // remove_keep_children = true;
24946 if (remove_keep_children) {
24947 this.cleanUpChildren(node);
24948 // inserts everything just before this node...
24949 while (node.childNodes.length) {
24950 var cn = node.childNodes[0];
24951 node.removeChild(cn);
24952 node.parentNode.insertBefore(cn, node);
24954 node.parentNode.removeChild(node);
24958 if (!node.attributes || !node.attributes.length) {
24963 this.cleanUpChildren(node);
24967 function cleanAttr(n,v)
24970 if (v.match(/^\./) || v.match(/^\//)) {
24973 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/) || v.match(/^ftp:/)) {
24976 if (v.match(/^#/)) {
24979 if (v.match(/^\{/)) { // allow template editing.
24982 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
24983 node.removeAttribute(n);
24987 var cwhite = this.cwhite;
24988 var cblack = this.cblack;
24990 function cleanStyle(n,v)
24992 if (v.match(/expression/)) { //XSS?? should we even bother..
24993 node.removeAttribute(n);
24997 var parts = v.split(/;/);
25000 Roo.each(parts, function(p) {
25001 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
25005 var l = p.split(':').shift().replace(/\s+/g,'');
25006 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
25008 if ( cwhite.length && cblack.indexOf(l) > -1) {
25009 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
25010 //node.removeAttribute(n);
25014 // only allow 'c whitelisted system attributes'
25015 if ( cwhite.length && cwhite.indexOf(l) < 0) {
25016 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
25017 //node.removeAttribute(n);
25027 if (clean.length) {
25028 node.setAttribute(n, clean.join(';'));
25030 node.removeAttribute(n);
25036 for (var i = node.attributes.length-1; i > -1 ; i--) {
25037 var a = node.attributes[i];
25040 if (a.name.toLowerCase().substr(0,2)=='on') {
25041 node.removeAttribute(a.name);
25044 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
25045 node.removeAttribute(a.name);
25048 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
25049 cleanAttr(a.name,a.value); // fixme..
25052 if (a.name == 'style') {
25053 cleanStyle(a.name,a.value);
25056 /// clean up MS crap..
25057 // tecnically this should be a list of valid class'es..
25060 if (a.name == 'class') {
25061 if (a.value.match(/^Mso/)) {
25062 node.removeAttribute('class');
25065 if (a.value.match(/^body$/)) {
25066 node.removeAttribute('class');
25077 this.cleanUpChildren(node);
25083 * Clean up MS wordisms...
25085 cleanWord : function(node)
25088 this.cleanWord(this.doc.body);
25093 node.nodeName == 'SPAN' &&
25094 !node.hasAttributes() &&
25095 node.childNodes.length == 1 &&
25096 node.firstChild.nodeName == "#text"
25098 var textNode = node.firstChild;
25099 node.removeChild(textNode);
25100 if (node.getAttribute('lang') != 'zh-CN') { // do not space pad on chinese characters..
25101 node.parentNode.insertBefore(node.ownerDocument.createTextNode(" "), node);
25103 node.parentNode.insertBefore(textNode, node);
25104 if (node.getAttribute('lang') != 'zh-CN') { // do not space pad on chinese characters..
25105 node.parentNode.insertBefore(node.ownerDocument.createTextNode(" ") , node);
25107 node.parentNode.removeChild(node);
25110 if (node.nodeName == "#text") {
25111 // clean up silly Windows -- stuff?
25114 if (node.nodeName == "#comment") {
25115 node.parentNode.removeChild(node);
25116 // clean up silly Windows -- stuff?
25120 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
25121 node.parentNode.removeChild(node);
25124 //Roo.log(node.tagName);
25125 // remove - but keep children..
25126 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|v:|font)/)) {
25127 //Roo.log('-- removed');
25128 while (node.childNodes.length) {
25129 var cn = node.childNodes[0];
25130 node.removeChild(cn);
25131 node.parentNode.insertBefore(cn, node);
25132 // move node to parent - and clean it..
25133 this.cleanWord(cn);
25135 node.parentNode.removeChild(node);
25136 /// no need to iterate chidlren = it's got none..
25137 //this.iterateChildren(node, this.cleanWord);
25141 if (node.className.length) {
25143 var cn = node.className.split(/\W+/);
25145 Roo.each(cn, function(cls) {
25146 if (cls.match(/Mso[a-zA-Z]+/)) {
25151 node.className = cna.length ? cna.join(' ') : '';
25153 node.removeAttribute("class");
25157 if (node.hasAttribute("lang")) {
25158 node.removeAttribute("lang");
25161 if (node.hasAttribute("style")) {
25163 var styles = node.getAttribute("style").split(";");
25165 Roo.each(styles, function(s) {
25166 if (!s.match(/:/)) {
25169 var kv = s.split(":");
25170 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
25173 // what ever is left... we allow.
25176 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
25177 if (!nstyle.length) {
25178 node.removeAttribute('style');
25181 this.iterateChildren(node, this.cleanWord);
25187 * iterateChildren of a Node, calling fn each time, using this as the scole..
25188 * @param {DomNode} node node to iterate children of.
25189 * @param {Function} fn method of this class to call on each item.
25191 iterateChildren : function(node, fn)
25193 if (!node.childNodes.length) {
25196 for (var i = node.childNodes.length-1; i > -1 ; i--) {
25197 fn.call(this, node.childNodes[i])
25203 * cleanTableWidths.
25205 * Quite often pasting from word etc.. results in tables with column and widths.
25206 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
25209 cleanTableWidths : function(node)
25214 this.cleanTableWidths(this.doc.body);
25219 if (node.nodeName == "#text" || node.nodeName == "#comment") {
25222 Roo.log(node.tagName);
25223 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
25224 this.iterateChildren(node, this.cleanTableWidths);
25227 if (node.hasAttribute('width')) {
25228 node.removeAttribute('width');
25232 if (node.hasAttribute("style")) {
25235 var styles = node.getAttribute("style").split(";");
25237 Roo.each(styles, function(s) {
25238 if (!s.match(/:/)) {
25241 var kv = s.split(":");
25242 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
25245 // what ever is left... we allow.
25248 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
25249 if (!nstyle.length) {
25250 node.removeAttribute('style');
25254 this.iterateChildren(node, this.cleanTableWidths);
25262 domToHTML : function(currentElement, depth, nopadtext) {
25264 depth = depth || 0;
25265 nopadtext = nopadtext || false;
25267 if (!currentElement) {
25268 return this.domToHTML(this.doc.body);
25271 //Roo.log(currentElement);
25273 var allText = false;
25274 var nodeName = currentElement.nodeName;
25275 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
25277 if (nodeName == '#text') {
25279 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
25284 if (nodeName != 'BODY') {
25287 // Prints the node tagName, such as <A>, <IMG>, etc
25290 for(i = 0; i < currentElement.attributes.length;i++) {
25292 var aname = currentElement.attributes.item(i).name;
25293 if (!currentElement.attributes.item(i).value.length) {
25296 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
25299 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
25308 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
25311 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
25316 // Traverse the tree
25318 var currentElementChild = currentElement.childNodes.item(i);
25319 var allText = true;
25320 var innerHTML = '';
25322 while (currentElementChild) {
25323 // Formatting code (indent the tree so it looks nice on the screen)
25324 var nopad = nopadtext;
25325 if (lastnode == 'SPAN') {
25329 if (currentElementChild.nodeName == '#text') {
25330 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
25331 toadd = nopadtext ? toadd : toadd.trim();
25332 if (!nopad && toadd.length > 80) {
25333 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
25335 innerHTML += toadd;
25338 currentElementChild = currentElement.childNodes.item(i);
25344 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
25346 // Recursively traverse the tree structure of the child node
25347 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
25348 lastnode = currentElementChild.nodeName;
25350 currentElementChild=currentElement.childNodes.item(i);
25356 // The remaining code is mostly for formatting the tree
25357 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
25362 ret+= "</"+tagName+">";
25368 applyBlacklists : function()
25370 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
25371 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
25375 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
25376 if (b.indexOf(tag) > -1) {
25379 this.white.push(tag);
25383 Roo.each(w, function(tag) {
25384 if (b.indexOf(tag) > -1) {
25387 if (this.white.indexOf(tag) > -1) {
25390 this.white.push(tag);
25395 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
25396 if (w.indexOf(tag) > -1) {
25399 this.black.push(tag);
25403 Roo.each(b, function(tag) {
25404 if (w.indexOf(tag) > -1) {
25407 if (this.black.indexOf(tag) > -1) {
25410 this.black.push(tag);
25415 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
25416 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
25420 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
25421 if (b.indexOf(tag) > -1) {
25424 this.cwhite.push(tag);
25428 Roo.each(w, function(tag) {
25429 if (b.indexOf(tag) > -1) {
25432 if (this.cwhite.indexOf(tag) > -1) {
25435 this.cwhite.push(tag);
25440 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
25441 if (w.indexOf(tag) > -1) {
25444 this.cblack.push(tag);
25448 Roo.each(b, function(tag) {
25449 if (w.indexOf(tag) > -1) {
25452 if (this.cblack.indexOf(tag) > -1) {
25455 this.cblack.push(tag);
25460 setStylesheets : function(stylesheets)
25462 if(typeof(stylesheets) == 'string'){
25463 Roo.get(this.iframe.contentDocument.head).createChild({
25465 rel : 'stylesheet',
25474 Roo.each(stylesheets, function(s) {
25479 Roo.get(_this.iframe.contentDocument.head).createChild({
25481 rel : 'stylesheet',
25490 removeStylesheets : function()
25494 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
25499 setStyle : function(style)
25501 Roo.get(this.iframe.contentDocument.head).createChild({
25510 // hide stuff that is not compatible
25524 * @event specialkey
25528 * @cfg {String} fieldClass @hide
25531 * @cfg {String} focusClass @hide
25534 * @cfg {String} autoCreate @hide
25537 * @cfg {String} inputType @hide
25540 * @cfg {String} invalidClass @hide
25543 * @cfg {String} invalidText @hide
25546 * @cfg {String} msgFx @hide
25549 * @cfg {String} validateOnBlur @hide
25553 Roo.HtmlEditorCore.white = [
25554 'area', 'br', 'img', 'input', 'hr', 'wbr',
25556 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
25557 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
25558 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
25559 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
25560 'table', 'ul', 'xmp',
25562 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
25565 'dir', 'menu', 'ol', 'ul', 'dl',
25571 Roo.HtmlEditorCore.black = [
25572 // 'embed', 'object', // enable - backend responsiblity to clean thiese
25574 'base', 'basefont', 'bgsound', 'blink', 'body',
25575 'frame', 'frameset', 'head', 'html', 'ilayer',
25576 'iframe', 'layer', 'link', 'meta', 'object',
25577 'script', 'style' ,'title', 'xml' // clean later..
25579 Roo.HtmlEditorCore.clean = [
25580 'script', 'style', 'title', 'xml'
25582 Roo.HtmlEditorCore.remove = [
25587 Roo.HtmlEditorCore.ablack = [
25591 Roo.HtmlEditorCore.aclean = [
25592 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
25596 Roo.HtmlEditorCore.pwhite= [
25597 'http', 'https', 'mailto'
25600 // white listed style attributes.
25601 Roo.HtmlEditorCore.cwhite= [
25602 // 'text-align', /// default is to allow most things..
25608 // black listed style attributes.
25609 Roo.HtmlEditorCore.cblack= [
25610 // 'font-size' -- this can be set by the project
25614 Roo.HtmlEditorCore.swapCodes =[
25633 * @class Roo.bootstrap.HtmlEditor
25634 * @extends Roo.bootstrap.TextArea
25635 * Bootstrap HtmlEditor class
25638 * Create a new HtmlEditor
25639 * @param {Object} config The config object
25642 Roo.bootstrap.HtmlEditor = function(config){
25643 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
25644 if (!this.toolbars) {
25645 this.toolbars = [];
25648 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
25651 * @event initialize
25652 * Fires when the editor is fully initialized (including the iframe)
25653 * @param {HtmlEditor} this
25658 * Fires when the editor is first receives the focus. Any insertion must wait
25659 * until after this event.
25660 * @param {HtmlEditor} this
25664 * @event beforesync
25665 * Fires before the textarea is updated with content from the editor iframe. Return false
25666 * to cancel the sync.
25667 * @param {HtmlEditor} this
25668 * @param {String} html
25672 * @event beforepush
25673 * Fires before the iframe editor is updated with content from the textarea. Return false
25674 * to cancel the push.
25675 * @param {HtmlEditor} this
25676 * @param {String} html
25681 * Fires when the textarea is updated with content from the editor iframe.
25682 * @param {HtmlEditor} this
25683 * @param {String} html
25688 * Fires when the iframe editor is updated with content from the textarea.
25689 * @param {HtmlEditor} this
25690 * @param {String} html
25694 * @event editmodechange
25695 * Fires when the editor switches edit modes
25696 * @param {HtmlEditor} this
25697 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
25699 editmodechange: true,
25701 * @event editorevent
25702 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
25703 * @param {HtmlEditor} this
25707 * @event firstfocus
25708 * Fires when on first focus - needed by toolbars..
25709 * @param {HtmlEditor} this
25714 * Auto save the htmlEditor value as a file into Events
25715 * @param {HtmlEditor} this
25719 * @event savedpreview
25720 * preview the saved version of htmlEditor
25721 * @param {HtmlEditor} this
25728 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
25732 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
25737 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
25742 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
25747 * @cfg {Number} height (in pixels)
25751 * @cfg {Number} width (in pixels)
25756 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
25759 stylesheets: false,
25764 // private properties
25765 validationEvent : false,
25767 initialized : false,
25770 onFocus : Roo.emptyFn,
25772 hideMode:'offsets',
25774 tbContainer : false,
25778 toolbarContainer :function() {
25779 return this.wrap.select('.x-html-editor-tb',true).first();
25783 * Protected method that will not generally be called directly. It
25784 * is called when the editor creates its toolbar. Override this method if you need to
25785 * add custom toolbar buttons.
25786 * @param {HtmlEditor} editor
25788 createToolbar : function(){
25789 Roo.log('renewing');
25790 Roo.log("create toolbars");
25792 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
25793 this.toolbars[0].render(this.toolbarContainer());
25797 // if (!editor.toolbars || !editor.toolbars.length) {
25798 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
25801 // for (var i =0 ; i < editor.toolbars.length;i++) {
25802 // editor.toolbars[i] = Roo.factory(
25803 // typeof(editor.toolbars[i]) == 'string' ?
25804 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
25805 // Roo.bootstrap.HtmlEditor);
25806 // editor.toolbars[i].init(editor);
25812 onRender : function(ct, position)
25814 // Roo.log("Call onRender: " + this.xtype);
25816 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
25818 this.wrap = this.inputEl().wrap({
25819 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
25822 this.editorcore.onRender(ct, position);
25824 if (this.resizable) {
25825 this.resizeEl = new Roo.Resizable(this.wrap, {
25829 minHeight : this.height,
25830 height: this.height,
25831 handles : this.resizable,
25834 resize : function(r, w, h) {
25835 _t.onResize(w,h); // -something
25841 this.createToolbar(this);
25844 if(!this.width && this.resizable){
25845 this.setSize(this.wrap.getSize());
25847 if (this.resizeEl) {
25848 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
25849 // should trigger onReize..
25855 onResize : function(w, h)
25857 Roo.log('resize: ' +w + ',' + h );
25858 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
25862 if(this.inputEl() ){
25863 if(typeof w == 'number'){
25864 var aw = w - this.wrap.getFrameWidth('lr');
25865 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
25868 if(typeof h == 'number'){
25869 var tbh = -11; // fixme it needs to tool bar size!
25870 for (var i =0; i < this.toolbars.length;i++) {
25871 // fixme - ask toolbars for heights?
25872 tbh += this.toolbars[i].el.getHeight();
25873 //if (this.toolbars[i].footer) {
25874 // tbh += this.toolbars[i].footer.el.getHeight();
25882 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
25883 ah -= 5; // knock a few pixes off for look..
25884 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
25888 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
25889 this.editorcore.onResize(ew,eh);
25894 * Toggles the editor between standard and source edit mode.
25895 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
25897 toggleSourceEdit : function(sourceEditMode)
25899 this.editorcore.toggleSourceEdit(sourceEditMode);
25901 if(this.editorcore.sourceEditMode){
25902 Roo.log('editor - showing textarea');
25905 // Roo.log(this.syncValue());
25907 this.inputEl().removeClass(['hide', 'x-hidden']);
25908 this.inputEl().dom.removeAttribute('tabIndex');
25909 this.inputEl().focus();
25911 Roo.log('editor - hiding textarea');
25913 // Roo.log(this.pushValue());
25916 this.inputEl().addClass(['hide', 'x-hidden']);
25917 this.inputEl().dom.setAttribute('tabIndex', -1);
25918 //this.deferFocus();
25921 if(this.resizable){
25922 this.setSize(this.wrap.getSize());
25925 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
25928 // private (for BoxComponent)
25929 adjustSize : Roo.BoxComponent.prototype.adjustSize,
25931 // private (for BoxComponent)
25932 getResizeEl : function(){
25936 // private (for BoxComponent)
25937 getPositionEl : function(){
25942 initEvents : function(){
25943 this.originalValue = this.getValue();
25947 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
25950 // markInvalid : Roo.emptyFn,
25952 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
25955 // clearInvalid : Roo.emptyFn,
25957 setValue : function(v){
25958 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
25959 this.editorcore.pushValue();
25964 deferFocus : function(){
25965 this.focus.defer(10, this);
25969 focus : function(){
25970 this.editorcore.focus();
25976 onDestroy : function(){
25982 for (var i =0; i < this.toolbars.length;i++) {
25983 // fixme - ask toolbars for heights?
25984 this.toolbars[i].onDestroy();
25987 this.wrap.dom.innerHTML = '';
25988 this.wrap.remove();
25993 onFirstFocus : function(){
25994 //Roo.log("onFirstFocus");
25995 this.editorcore.onFirstFocus();
25996 for (var i =0; i < this.toolbars.length;i++) {
25997 this.toolbars[i].onFirstFocus();
26003 syncValue : function()
26005 this.editorcore.syncValue();
26008 pushValue : function()
26010 this.editorcore.pushValue();
26014 // hide stuff that is not compatible
26028 * @event specialkey
26032 * @cfg {String} fieldClass @hide
26035 * @cfg {String} focusClass @hide
26038 * @cfg {String} autoCreate @hide
26041 * @cfg {String} inputType @hide
26045 * @cfg {String} invalidText @hide
26048 * @cfg {String} msgFx @hide
26051 * @cfg {String} validateOnBlur @hide
26060 Roo.namespace('Roo.bootstrap.htmleditor');
26062 * @class Roo.bootstrap.HtmlEditorToolbar1
26068 new Roo.bootstrap.HtmlEditor({
26071 new Roo.bootstrap.HtmlEditorToolbar1({
26072 disable : { fonts: 1 , format: 1, ..., ... , ...],
26078 * @cfg {Object} disable List of elements to disable..
26079 * @cfg {Array} btns List of additional buttons.
26083 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
26086 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
26089 Roo.apply(this, config);
26091 // default disabled, based on 'good practice'..
26092 this.disable = this.disable || {};
26093 Roo.applyIf(this.disable, {
26096 specialElements : true
26098 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
26100 this.editor = config.editor;
26101 this.editorcore = config.editor.editorcore;
26103 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
26105 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
26106 // dont call parent... till later.
26108 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
26113 editorcore : false,
26118 "h1","h2","h3","h4","h5","h6",
26120 "abbr", "acronym", "address", "cite", "samp", "var",
26124 onRender : function(ct, position)
26126 // Roo.log("Call onRender: " + this.xtype);
26128 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
26130 this.el.dom.style.marginBottom = '0';
26132 var editorcore = this.editorcore;
26133 var editor= this.editor;
26136 var btn = function(id,cmd , toggle, handler, html){
26138 var event = toggle ? 'toggle' : 'click';
26143 xns: Roo.bootstrap,
26147 enableToggle:toggle !== false,
26149 pressed : toggle ? false : null,
26152 a.listeners[toggle ? 'toggle' : 'click'] = function() {
26153 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
26159 // var cb_box = function...
26164 xns: Roo.bootstrap,
26169 xns: Roo.bootstrap,
26173 Roo.each(this.formats, function(f) {
26174 style.menu.items.push({
26176 xns: Roo.bootstrap,
26177 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
26182 editorcore.insertTag(this.tagname);
26189 children.push(style);
26191 btn('bold',false,true);
26192 btn('italic',false,true);
26193 btn('align-left', 'justifyleft',true);
26194 btn('align-center', 'justifycenter',true);
26195 btn('align-right' , 'justifyright',true);
26196 btn('link', false, false, function(btn) {
26197 //Roo.log("create link?");
26198 var url = prompt(this.createLinkText, this.defaultLinkValue);
26199 if(url && url != 'http:/'+'/'){
26200 this.editorcore.relayCmd('createlink', url);
26203 btn('list','insertunorderedlist',true);
26204 btn('pencil', false,true, function(btn){
26206 this.toggleSourceEdit(btn.pressed);
26209 if (this.editor.btns.length > 0) {
26210 for (var i = 0; i<this.editor.btns.length; i++) {
26211 children.push(this.editor.btns[i]);
26219 xns: Roo.bootstrap,
26224 xns: Roo.bootstrap,
26229 cog.menu.items.push({
26231 xns: Roo.bootstrap,
26232 html : Clean styles,
26237 editorcore.insertTag(this.tagname);
26246 this.xtype = 'NavSimplebar';
26248 for(var i=0;i< children.length;i++) {
26250 this.buttons.add(this.addxtypeChild(children[i]));
26254 editor.on('editorevent', this.updateToolbar, this);
26256 onBtnClick : function(id)
26258 this.editorcore.relayCmd(id);
26259 this.editorcore.focus();
26263 * Protected method that will not generally be called directly. It triggers
26264 * a toolbar update by reading the markup state of the current selection in the editor.
26266 updateToolbar: function(){
26268 if(!this.editorcore.activated){
26269 this.editor.onFirstFocus(); // is this neeed?
26273 var btns = this.buttons;
26274 var doc = this.editorcore.doc;
26275 btns.get('bold').setActive(doc.queryCommandState('bold'));
26276 btns.get('italic').setActive(doc.queryCommandState('italic'));
26277 //btns.get('underline').setActive(doc.queryCommandState('underline'));
26279 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
26280 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
26281 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
26283 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
26284 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
26287 var ans = this.editorcore.getAllAncestors();
26288 if (this.formatCombo) {
26291 var store = this.formatCombo.store;
26292 this.formatCombo.setValue("");
26293 for (var i =0; i < ans.length;i++) {
26294 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
26296 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
26304 // hides menus... - so this cant be on a menu...
26305 Roo.bootstrap.MenuMgr.hideAll();
26307 Roo.bootstrap.MenuMgr.hideAll();
26308 //this.editorsyncValue();
26310 onFirstFocus: function() {
26311 this.buttons.each(function(item){
26315 toggleSourceEdit : function(sourceEditMode){
26318 if(sourceEditMode){
26319 Roo.log("disabling buttons");
26320 this.buttons.each( function(item){
26321 if(item.cmd != 'pencil'){
26327 Roo.log("enabling buttons");
26328 if(this.editorcore.initialized){
26329 this.buttons.each( function(item){
26335 Roo.log("calling toggole on editor");
26336 // tell the editor that it's been pressed..
26337 this.editor.toggleSourceEdit(sourceEditMode);
26351 * @class Roo.bootstrap.Markdown
26352 * @extends Roo.bootstrap.TextArea
26353 * Bootstrap Showdown editable area
26354 * @cfg {string} content
26357 * Create a new Showdown
26360 Roo.bootstrap.Markdown = function(config){
26361 Roo.bootstrap.Markdown.superclass.constructor.call(this, config);
26365 Roo.extend(Roo.bootstrap.Markdown, Roo.bootstrap.TextArea, {
26369 initEvents : function()
26372 Roo.bootstrap.TextArea.prototype.initEvents.call(this);
26373 this.markdownEl = this.el.createChild({
26374 cls : 'roo-markdown-area'
26376 this.inputEl().addClass('d-none');
26377 if (this.getValue() == '') {
26378 this.markdownEl.dom.innerHTML = String.format('<span class="roo-placeholder">{0}</span>', this.placeholder || '');
26381 this.markdownEl.dom.innerHTML = Roo.Markdown.toHtml(Roo.util.Format.htmlEncode(this.getValue()));
26383 this.markdownEl.on('click', this.toggleTextEdit, this);
26384 this.on('blur', this.toggleTextEdit, this);
26385 this.on('specialkey', this.resizeTextArea, this);
26388 toggleTextEdit : function()
26390 var sh = this.markdownEl.getHeight();
26391 this.inputEl().addClass('d-none');
26392 this.markdownEl.addClass('d-none');
26393 if (!this.editing) {
26395 this.inputEl().setHeight(Math.min(500, Math.max(sh,(this.getValue().split("\n").length+1) * 30)));
26396 this.inputEl().removeClass('d-none');
26397 this.inputEl().focus();
26398 this.editing = true;
26401 // show showdown...
26402 this.updateMarkdown();
26403 this.markdownEl.removeClass('d-none');
26404 this.editing = false;
26407 updateMarkdown : function()
26409 if (this.getValue() == '') {
26410 this.markdownEl.dom.innerHTML = String.format('<span class="roo-placeholder">{0}</span>', this.placeholder || '');
26414 this.markdownEl.dom.innerHTML = Roo.Markdown.toHtml(Roo.util.Format.htmlEncode(this.getValue()));
26417 resizeTextArea: function () {
26420 Roo.log([sh, this.getValue().split("\n").length * 30]);
26421 this.inputEl().setHeight(Math.min(500, Math.max(sh, (this.getValue().split("\n").length +1) * 30)));
26423 setValue : function(val)
26425 Roo.bootstrap.TextArea.prototype.setValue.call(this,val);
26426 if (!this.editing) {
26427 this.updateMarkdown();
26433 if (!this.editing) {
26434 this.toggleTextEdit();
26442 * @class Roo.bootstrap.Table.AbstractSelectionModel
26443 * @extends Roo.util.Observable
26444 * Abstract base class for grid SelectionModels. It provides the interface that should be
26445 * implemented by descendant classes. This class should not be directly instantiated.
26448 Roo.bootstrap.Table.AbstractSelectionModel = function(){
26449 this.locked = false;
26450 Roo.bootstrap.Table.AbstractSelectionModel.superclass.constructor.call(this);
26454 Roo.extend(Roo.bootstrap.Table.AbstractSelectionModel, Roo.util.Observable, {
26455 /** @ignore Called by the grid automatically. Do not call directly. */
26456 init : function(grid){
26462 * Locks the selections.
26465 this.locked = true;
26469 * Unlocks the selections.
26471 unlock : function(){
26472 this.locked = false;
26476 * Returns true if the selections are locked.
26477 * @return {Boolean}
26479 isLocked : function(){
26480 return this.locked;
26484 initEvents : function ()
26490 * @extends Roo.bootstrap.Table.AbstractSelectionModel
26491 * @class Roo.bootstrap.Table.RowSelectionModel
26492 * The default SelectionModel used by {@link Roo.bootstrap.Table}.
26493 * It supports multiple selections and keyboard selection/navigation.
26495 * @param {Object} config
26498 Roo.bootstrap.Table.RowSelectionModel = function(config){
26499 Roo.apply(this, config);
26500 this.selections = new Roo.util.MixedCollection(false, function(o){
26505 this.lastActive = false;
26509 * @event selectionchange
26510 * Fires when the selection changes
26511 * @param {SelectionModel} this
26513 "selectionchange" : true,
26515 * @event afterselectionchange
26516 * Fires after the selection changes (eg. by key press or clicking)
26517 * @param {SelectionModel} this
26519 "afterselectionchange" : true,
26521 * @event beforerowselect
26522 * Fires when a row is selected being selected, return false to cancel.
26523 * @param {SelectionModel} this
26524 * @param {Number} rowIndex The selected index
26525 * @param {Boolean} keepExisting False if other selections will be cleared
26527 "beforerowselect" : true,
26530 * Fires when a row is selected.
26531 * @param {SelectionModel} this
26532 * @param {Number} rowIndex The selected index
26533 * @param {Roo.data.Record} r The record
26535 "rowselect" : true,
26537 * @event rowdeselect
26538 * Fires when a row is deselected.
26539 * @param {SelectionModel} this
26540 * @param {Number} rowIndex The selected index
26542 "rowdeselect" : true
26544 Roo.bootstrap.Table.RowSelectionModel.superclass.constructor.call(this);
26545 this.locked = false;
26548 Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSelectionModel, {
26550 * @cfg {Boolean} singleSelect
26551 * True to allow selection of only one row at a time (defaults to false)
26553 singleSelect : false,
26556 initEvents : function()
26559 //if(!this.grid.enableDragDrop && !this.grid.enableDrag){
26560 // this.growclickrid.on("mousedown", this.handleMouseDown, this);
26561 //}else{ // allow click to work like normal
26562 // this.grid.on("rowclick", this.handleDragableRowClick, this);
26564 //this.grid.on("rowdblclick", this.handleMouseDBClick, this);
26565 this.grid.on("rowclick", this.handleMouseDown, this);
26567 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
26568 "up" : function(e){
26570 this.selectPrevious(e.shiftKey);
26571 }else if(this.last !== false && this.lastActive !== false){
26572 var last = this.last;
26573 this.selectRange(this.last, this.lastActive-1);
26574 this.grid.getView().focusRow(this.lastActive);
26575 if(last !== false){
26579 this.selectFirstRow();
26581 this.fireEvent("afterselectionchange", this);
26583 "down" : function(e){
26585 this.selectNext(e.shiftKey);
26586 }else if(this.last !== false && this.lastActive !== false){
26587 var last = this.last;
26588 this.selectRange(this.last, this.lastActive+1);
26589 this.grid.getView().focusRow(this.lastActive);
26590 if(last !== false){
26594 this.selectFirstRow();
26596 this.fireEvent("afterselectionchange", this);
26600 this.grid.store.on('load', function(){
26601 this.selections.clear();
26604 var view = this.grid.view;
26605 view.on("refresh", this.onRefresh, this);
26606 view.on("rowupdated", this.onRowUpdated, this);
26607 view.on("rowremoved", this.onRemove, this);
26612 onRefresh : function()
26614 var ds = this.grid.store, i, v = this.grid.view;
26615 var s = this.selections;
26616 s.each(function(r){
26617 if((i = ds.indexOfId(r.id)) != -1){
26626 onRemove : function(v, index, r){
26627 this.selections.remove(r);
26631 onRowUpdated : function(v, index, r){
26632 if(this.isSelected(r)){
26633 v.onRowSelect(index);
26639 * @param {Array} records The records to select
26640 * @param {Boolean} keepExisting (optional) True to keep existing selections
26642 selectRecords : function(records, keepExisting)
26645 this.clearSelections();
26647 var ds = this.grid.store;
26648 for(var i = 0, len = records.length; i < len; i++){
26649 this.selectRow(ds.indexOf(records[i]), true);
26654 * Gets the number of selected rows.
26657 getCount : function(){
26658 return this.selections.length;
26662 * Selects the first row in the grid.
26664 selectFirstRow : function(){
26669 * Select the last row.
26670 * @param {Boolean} keepExisting (optional) True to keep existing selections
26672 selectLastRow : function(keepExisting){
26673 //this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
26674 this.selectRow(this.grid.store.getCount() - 1, keepExisting);
26678 * Selects the row immediately following the last selected row.
26679 * @param {Boolean} keepExisting (optional) True to keep existing selections
26681 selectNext : function(keepExisting)
26683 if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
26684 this.selectRow(this.last+1, keepExisting);
26685 this.grid.getView().focusRow(this.last);
26690 * Selects the row that precedes the last selected row.
26691 * @param {Boolean} keepExisting (optional) True to keep existing selections
26693 selectPrevious : function(keepExisting){
26695 this.selectRow(this.last-1, keepExisting);
26696 this.grid.getView().focusRow(this.last);
26701 * Returns the selected records
26702 * @return {Array} Array of selected records
26704 getSelections : function(){
26705 return [].concat(this.selections.items);
26709 * Returns the first selected record.
26712 getSelected : function(){
26713 return this.selections.itemAt(0);
26718 * Clears all selections.
26720 clearSelections : function(fast)
26726 var ds = this.grid.store;
26727 var s = this.selections;
26728 s.each(function(r){
26729 this.deselectRow(ds.indexOfId(r.id));
26733 this.selections.clear();
26740 * Selects all rows.
26742 selectAll : function(){
26746 this.selections.clear();
26747 for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
26748 this.selectRow(i, true);
26753 * Returns True if there is a selection.
26754 * @return {Boolean}
26756 hasSelection : function(){
26757 return this.selections.length > 0;
26761 * Returns True if the specified row is selected.
26762 * @param {Number/Record} record The record or index of the record to check
26763 * @return {Boolean}
26765 isSelected : function(index){
26766 var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
26767 return (r && this.selections.key(r.id) ? true : false);
26771 * Returns True if the specified record id is selected.
26772 * @param {String} id The id of record to check
26773 * @return {Boolean}
26775 isIdSelected : function(id){
26776 return (this.selections.key(id) ? true : false);
26781 handleMouseDBClick : function(e, t){
26785 handleMouseDown : function(e, t)
26787 var rowIndex = this.grid.headerShow ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
26788 if(this.isLocked() || rowIndex < 0 ){
26791 if(e.shiftKey && this.last !== false){
26792 var last = this.last;
26793 this.selectRange(last, rowIndex, e.ctrlKey);
26794 this.last = last; // reset the last
26798 var isSelected = this.isSelected(rowIndex);
26799 //Roo.log("select row:" + rowIndex);
26801 this.deselectRow(rowIndex);
26803 this.selectRow(rowIndex, true);
26807 if(e.button !== 0 && isSelected){
26808 alert('rowIndex 2: ' + rowIndex);
26809 view.focusRow(rowIndex);
26810 }else if(e.ctrlKey && isSelected){
26811 this.deselectRow(rowIndex);
26812 }else if(!isSelected){
26813 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
26814 view.focusRow(rowIndex);
26818 this.fireEvent("afterselectionchange", this);
26821 handleDragableRowClick : function(grid, rowIndex, e)
26823 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
26824 this.selectRow(rowIndex, false);
26825 grid.view.focusRow(rowIndex);
26826 this.fireEvent("afterselectionchange", this);
26831 * Selects multiple rows.
26832 * @param {Array} rows Array of the indexes of the row to select
26833 * @param {Boolean} keepExisting (optional) True to keep existing selections
26835 selectRows : function(rows, keepExisting){
26837 this.clearSelections();
26839 for(var i = 0, len = rows.length; i < len; i++){
26840 this.selectRow(rows[i], true);
26845 * Selects a range of rows. All rows in between startRow and endRow are also selected.
26846 * @param {Number} startRow The index of the first row in the range
26847 * @param {Number} endRow The index of the last row in the range
26848 * @param {Boolean} keepExisting (optional) True to retain existing selections
26850 selectRange : function(startRow, endRow, keepExisting){
26855 this.clearSelections();
26857 if(startRow <= endRow){
26858 for(var i = startRow; i <= endRow; i++){
26859 this.selectRow(i, true);
26862 for(var i = startRow; i >= endRow; i--){
26863 this.selectRow(i, true);
26869 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
26870 * @param {Number} startRow The index of the first row in the range
26871 * @param {Number} endRow The index of the last row in the range
26873 deselectRange : function(startRow, endRow, preventViewNotify){
26877 for(var i = startRow; i <= endRow; i++){
26878 this.deselectRow(i, preventViewNotify);
26884 * @param {Number} row The index of the row to select
26885 * @param {Boolean} keepExisting (optional) True to keep existing selections
26887 selectRow : function(index, keepExisting, preventViewNotify)
26889 if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
26892 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
26893 if(!keepExisting || this.singleSelect){
26894 this.clearSelections();
26897 var r = this.grid.store.getAt(index);
26898 //console.log('selectRow - record id :' + r.id);
26900 this.selections.add(r);
26901 this.last = this.lastActive = index;
26902 if(!preventViewNotify){
26903 var proxy = new Roo.Element(
26904 this.grid.getRowDom(index)
26906 proxy.addClass('bg-info info');
26908 this.fireEvent("rowselect", this, index, r);
26909 this.fireEvent("selectionchange", this);
26915 * @param {Number} row The index of the row to deselect
26917 deselectRow : function(index, preventViewNotify)
26922 if(this.last == index){
26925 if(this.lastActive == index){
26926 this.lastActive = false;
26929 var r = this.grid.store.getAt(index);
26934 this.selections.remove(r);
26935 //.console.log('deselectRow - record id :' + r.id);
26936 if(!preventViewNotify){
26938 var proxy = new Roo.Element(
26939 this.grid.getRowDom(index)
26941 proxy.removeClass('bg-info info');
26943 this.fireEvent("rowdeselect", this, index);
26944 this.fireEvent("selectionchange", this);
26948 restoreLast : function(){
26950 this.last = this._last;
26955 acceptsNav : function(row, col, cm){
26956 return !cm.isHidden(col) && cm.isCellEditable(col, row);
26960 onEditorKey : function(field, e){
26961 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
26966 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
26968 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
26970 }else if(k == e.ENTER && !e.ctrlKey){
26974 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
26976 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
26978 }else if(k == e.ESC){
26982 g.startEditing(newCell[0], newCell[1]);
26988 * Ext JS Library 1.1.1
26989 * Copyright(c) 2006-2007, Ext JS, LLC.
26991 * Originally Released Under LGPL - original licence link has changed is not relivant.
26994 * <script type="text/javascript">
26998 * @class Roo.bootstrap.PagingToolbar
26999 * @extends Roo.bootstrap.NavSimplebar
27000 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
27002 * Create a new PagingToolbar
27003 * @param {Object} config The config object
27004 * @param {Roo.data.Store} store
27006 Roo.bootstrap.PagingToolbar = function(config)
27008 // old args format still supported... - xtype is prefered..
27009 // created from xtype...
27011 this.ds = config.dataSource;
27013 if (config.store && !this.ds) {
27014 this.store= Roo.factory(config.store, Roo.data);
27015 this.ds = this.store;
27016 this.ds.xmodule = this.xmodule || false;
27019 this.toolbarItems = [];
27020 if (config.items) {
27021 this.toolbarItems = config.items;
27024 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
27029 this.bind(this.ds);
27032 if (Roo.bootstrap.version == 4) {
27033 this.navgroup = new Roo.bootstrap.ButtonGroup({ cls: 'pagination' });
27035 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
27040 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
27042 * @cfg {Roo.data.Store} dataSource
27043 * The underlying data store providing the paged data
27046 * @cfg {String/HTMLElement/Element} container
27047 * container The id or element that will contain the toolbar
27050 * @cfg {Boolean} displayInfo
27051 * True to display the displayMsg (defaults to false)
27054 * @cfg {Number} pageSize
27055 * The number of records to display per page (defaults to 20)
27059 * @cfg {String} displayMsg
27060 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
27062 displayMsg : 'Displaying {0} - {1} of {2}',
27064 * @cfg {String} emptyMsg
27065 * The message to display when no records are found (defaults to "No data to display")
27067 emptyMsg : 'No data to display',
27069 * Customizable piece of the default paging text (defaults to "Page")
27072 beforePageText : "Page",
27074 * Customizable piece of the default paging text (defaults to "of %0")
27077 afterPageText : "of {0}",
27079 * Customizable piece of the default paging text (defaults to "First Page")
27082 firstText : "First Page",
27084 * Customizable piece of the default paging text (defaults to "Previous Page")
27087 prevText : "Previous Page",
27089 * Customizable piece of the default paging text (defaults to "Next Page")
27092 nextText : "Next Page",
27094 * Customizable piece of the default paging text (defaults to "Last Page")
27097 lastText : "Last Page",
27099 * Customizable piece of the default paging text (defaults to "Refresh")
27102 refreshText : "Refresh",
27106 onRender : function(ct, position)
27108 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
27109 this.navgroup.parentId = this.id;
27110 this.navgroup.onRender(this.el, null);
27111 // add the buttons to the navgroup
27113 if(this.displayInfo){
27114 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
27115 this.displayEl = this.el.select('.x-paging-info', true).first();
27116 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
27117 // this.displayEl = navel.el.select('span',true).first();
27123 Roo.each(_this.buttons, function(e){ // this might need to use render????
27124 Roo.factory(e).render(_this.el);
27128 Roo.each(_this.toolbarItems, function(e) {
27129 _this.navgroup.addItem(e);
27133 this.first = this.navgroup.addItem({
27134 tooltip: this.firstText,
27135 cls: "prev btn-outline-secondary",
27136 html : ' <i class="fa fa-step-backward"></i>',
27138 preventDefault: true,
27139 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
27142 this.prev = this.navgroup.addItem({
27143 tooltip: this.prevText,
27144 cls: "prev btn-outline-secondary",
27145 html : ' <i class="fa fa-backward"></i>',
27147 preventDefault: true,
27148 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
27150 //this.addSeparator();
27153 var field = this.navgroup.addItem( {
27155 cls : 'x-paging-position btn-outline-secondary',
27157 html : this.beforePageText +
27158 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
27159 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
27162 this.field = field.el.select('input', true).first();
27163 this.field.on("keydown", this.onPagingKeydown, this);
27164 this.field.on("focus", function(){this.dom.select();});
27167 this.afterTextEl = field.el.select('.x-paging-after',true).first();
27168 //this.field.setHeight(18);
27169 //this.addSeparator();
27170 this.next = this.navgroup.addItem({
27171 tooltip: this.nextText,
27172 cls: "next btn-outline-secondary",
27173 html : ' <i class="fa fa-forward"></i>',
27175 preventDefault: true,
27176 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
27178 this.last = this.navgroup.addItem({
27179 tooltip: this.lastText,
27180 html : ' <i class="fa fa-step-forward"></i>',
27181 cls: "next btn-outline-secondary",
27183 preventDefault: true,
27184 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
27186 //this.addSeparator();
27187 this.loading = this.navgroup.addItem({
27188 tooltip: this.refreshText,
27189 cls: "btn-outline-secondary",
27190 html : ' <i class="fa fa-refresh"></i>',
27191 preventDefault: true,
27192 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
27198 updateInfo : function(){
27199 if(this.displayEl){
27200 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
27201 var msg = count == 0 ?
27205 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
27207 this.displayEl.update(msg);
27212 onLoad : function(ds, r, o)
27214 this.cursor = o.params.start ? o.params.start : 0;
27216 var d = this.getPageData(),
27221 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
27222 this.field.dom.value = ap;
27223 this.first.setDisabled(ap == 1);
27224 this.prev.setDisabled(ap == 1);
27225 this.next.setDisabled(ap == ps);
27226 this.last.setDisabled(ap == ps);
27227 this.loading.enable();
27232 getPageData : function(){
27233 var total = this.ds.getTotalCount();
27236 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
27237 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
27242 onLoadError : function(){
27243 this.loading.enable();
27247 onPagingKeydown : function(e){
27248 var k = e.getKey();
27249 var d = this.getPageData();
27251 var v = this.field.dom.value, pageNum;
27252 if(!v || isNaN(pageNum = parseInt(v, 10))){
27253 this.field.dom.value = d.activePage;
27256 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
27257 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
27260 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))
27262 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
27263 this.field.dom.value = pageNum;
27264 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
27267 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
27269 var v = this.field.dom.value, pageNum;
27270 var increment = (e.shiftKey) ? 10 : 1;
27271 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
27274 if(!v || isNaN(pageNum = parseInt(v, 10))) {
27275 this.field.dom.value = d.activePage;
27278 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
27280 this.field.dom.value = parseInt(v, 10) + increment;
27281 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
27282 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
27289 beforeLoad : function(){
27291 this.loading.disable();
27296 onClick : function(which){
27305 ds.load({params:{start: 0, limit: this.pageSize}});
27308 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
27311 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
27314 var total = ds.getTotalCount();
27315 var extra = total % this.pageSize;
27316 var lastStart = extra ? (total - extra) : total-this.pageSize;
27317 ds.load({params:{start: lastStart, limit: this.pageSize}});
27320 ds.load({params:{start: this.cursor, limit: this.pageSize}});
27326 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
27327 * @param {Roo.data.Store} store The data store to unbind
27329 unbind : function(ds){
27330 ds.un("beforeload", this.beforeLoad, this);
27331 ds.un("load", this.onLoad, this);
27332 ds.un("loadexception", this.onLoadError, this);
27333 ds.un("remove", this.updateInfo, this);
27334 ds.un("add", this.updateInfo, this);
27335 this.ds = undefined;
27339 * Binds the paging toolbar to the specified {@link Roo.data.Store}
27340 * @param {Roo.data.Store} store The data store to bind
27342 bind : function(ds){
27343 ds.on("beforeload", this.beforeLoad, this);
27344 ds.on("load", this.onLoad, this);
27345 ds.on("loadexception", this.onLoadError, this);
27346 ds.on("remove", this.updateInfo, this);
27347 ds.on("add", this.updateInfo, this);
27358 * @class Roo.bootstrap.MessageBar
27359 * @extends Roo.bootstrap.Component
27360 * Bootstrap MessageBar class
27361 * @cfg {String} html contents of the MessageBar
27362 * @cfg {String} weight (info | success | warning | danger) default info
27363 * @cfg {String} beforeClass insert the bar before the given class
27364 * @cfg {Boolean} closable (true | false) default false
27365 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
27368 * Create a new Element
27369 * @param {Object} config The config object
27372 Roo.bootstrap.MessageBar = function(config){
27373 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
27376 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
27382 beforeClass: 'bootstrap-sticky-wrap',
27384 getAutoCreate : function(){
27388 cls: 'alert alert-dismissable alert-' + this.weight,
27393 html: this.html || ''
27399 cfg.cls += ' alert-messages-fixed';
27413 onRender : function(ct, position)
27415 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
27418 var cfg = Roo.apply({}, this.getAutoCreate());
27422 cfg.cls += ' ' + this.cls;
27425 cfg.style = this.style;
27427 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
27429 this.el.setVisibilityMode(Roo.Element.DISPLAY);
27432 this.el.select('>button.close').on('click', this.hide, this);
27438 if (!this.rendered) {
27444 this.fireEvent('show', this);
27450 if (!this.rendered) {
27456 this.fireEvent('hide', this);
27459 update : function()
27461 // var e = this.el.dom.firstChild;
27463 // if(this.closable){
27464 // e = e.nextSibling;
27467 // e.data = this.html || '';
27469 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
27485 * @class Roo.bootstrap.Graph
27486 * @extends Roo.bootstrap.Component
27487 * Bootstrap Graph class
27491 @cfg {String} graphtype bar | vbar | pie
27492 @cfg {number} g_x coodinator | centre x (pie)
27493 @cfg {number} g_y coodinator | centre y (pie)
27494 @cfg {number} g_r radius (pie)
27495 @cfg {number} g_height height of the chart (respected by all elements in the set)
27496 @cfg {number} g_width width of the chart (respected by all elements in the set)
27497 @cfg {Object} title The title of the chart
27500 -opts (object) options for the chart
27502 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
27503 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
27505 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.
27506 o stacked (boolean) whether or not to tread values as in a stacked bar chart
27508 o stretch (boolean)
27510 -opts (object) options for the pie
27513 o startAngle (number)
27514 o endAngle (number)
27518 * Create a new Input
27519 * @param {Object} config The config object
27522 Roo.bootstrap.Graph = function(config){
27523 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
27529 * The img click event for the img.
27530 * @param {Roo.EventObject} e
27536 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
27547 //g_colors: this.colors,
27554 getAutoCreate : function(){
27565 onRender : function(ct,position){
27568 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
27570 if (typeof(Raphael) == 'undefined') {
27571 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
27575 this.raphael = Raphael(this.el.dom);
27577 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
27578 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
27579 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
27580 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
27582 r.text(160, 10, "Single Series Chart").attr(txtattr);
27583 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
27584 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
27585 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
27587 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
27588 r.barchart(330, 10, 300, 220, data1);
27589 r.barchart(10, 250, 300, 220, data2, {stacked: true});
27590 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
27593 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
27594 // r.barchart(30, 30, 560, 250, xdata, {
27595 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
27596 // axis : "0 0 1 1",
27597 // axisxlabels : xdata
27598 // //yvalues : cols,
27601 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
27603 // this.load(null,xdata,{
27604 // axis : "0 0 1 1",
27605 // axisxlabels : xdata
27610 load : function(graphtype,xdata,opts)
27612 this.raphael.clear();
27614 graphtype = this.graphtype;
27619 var r = this.raphael,
27620 fin = function () {
27621 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
27623 fout = function () {
27624 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
27626 pfin = function() {
27627 this.sector.stop();
27628 this.sector.scale(1.1, 1.1, this.cx, this.cy);
27631 this.label[0].stop();
27632 this.label[0].attr({ r: 7.5 });
27633 this.label[1].attr({ "font-weight": 800 });
27636 pfout = function() {
27637 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
27640 this.label[0].animate({ r: 5 }, 500, "bounce");
27641 this.label[1].attr({ "font-weight": 400 });
27647 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
27650 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
27653 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
27654 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
27656 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
27663 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
27668 setTitle: function(o)
27673 initEvents: function() {
27676 this.el.on('click', this.onClick, this);
27680 onClick : function(e)
27682 Roo.log('img onclick');
27683 this.fireEvent('click', this, e);
27695 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
27698 * @class Roo.bootstrap.dash.NumberBox
27699 * @extends Roo.bootstrap.Component
27700 * Bootstrap NumberBox class
27701 * @cfg {String} headline Box headline
27702 * @cfg {String} content Box content
27703 * @cfg {String} icon Box icon
27704 * @cfg {String} footer Footer text
27705 * @cfg {String} fhref Footer href
27708 * Create a new NumberBox
27709 * @param {Object} config The config object
27713 Roo.bootstrap.dash.NumberBox = function(config){
27714 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
27718 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
27727 getAutoCreate : function(){
27731 cls : 'small-box ',
27739 cls : 'roo-headline',
27740 html : this.headline
27744 cls : 'roo-content',
27745 html : this.content
27759 cls : 'ion ' + this.icon
27768 cls : 'small-box-footer',
27769 href : this.fhref || '#',
27773 cfg.cn.push(footer);
27780 onRender : function(ct,position){
27781 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
27788 setHeadline: function (value)
27790 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
27793 setFooter: function (value, href)
27795 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
27798 this.el.select('a.small-box-footer',true).first().attr('href', href);
27803 setContent: function (value)
27805 this.el.select('.roo-content',true).first().dom.innerHTML = value;
27808 initEvents: function()
27822 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
27825 * @class Roo.bootstrap.dash.TabBox
27826 * @extends Roo.bootstrap.Component
27827 * Bootstrap TabBox class
27828 * @cfg {String} title Title of the TabBox
27829 * @cfg {String} icon Icon of the TabBox
27830 * @cfg {Boolean} showtabs (true|false) show the tabs default true
27831 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
27834 * Create a new TabBox
27835 * @param {Object} config The config object
27839 Roo.bootstrap.dash.TabBox = function(config){
27840 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
27845 * When a pane is added
27846 * @param {Roo.bootstrap.dash.TabPane} pane
27850 * @event activatepane
27851 * When a pane is activated
27852 * @param {Roo.bootstrap.dash.TabPane} pane
27854 "activatepane" : true
27862 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
27867 tabScrollable : false,
27869 getChildContainer : function()
27871 return this.el.select('.tab-content', true).first();
27874 getAutoCreate : function(){
27878 cls: 'pull-left header',
27886 cls: 'fa ' + this.icon
27892 cls: 'nav nav-tabs pull-right',
27898 if(this.tabScrollable){
27905 cls: 'nav nav-tabs pull-right',
27916 cls: 'nav-tabs-custom',
27921 cls: 'tab-content no-padding',
27929 initEvents : function()
27931 //Roo.log('add add pane handler');
27932 this.on('addpane', this.onAddPane, this);
27935 * Updates the box title
27936 * @param {String} html to set the title to.
27938 setTitle : function(value)
27940 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
27942 onAddPane : function(pane)
27944 this.panes.push(pane);
27945 //Roo.log('addpane');
27947 // tabs are rendere left to right..
27948 if(!this.showtabs){
27952 var ctr = this.el.select('.nav-tabs', true).first();
27955 var existing = ctr.select('.nav-tab',true);
27956 var qty = existing.getCount();;
27959 var tab = ctr.createChild({
27961 cls : 'nav-tab' + (qty ? '' : ' active'),
27969 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
27972 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
27974 pane.el.addClass('active');
27979 onTabClick : function(ev,un,ob,pane)
27981 //Roo.log('tab - prev default');
27982 ev.preventDefault();
27985 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
27986 pane.tab.addClass('active');
27987 //Roo.log(pane.title);
27988 this.getChildContainer().select('.tab-pane',true).removeClass('active');
27989 // technically we should have a deactivate event.. but maybe add later.
27990 // and it should not de-activate the selected tab...
27991 this.fireEvent('activatepane', pane);
27992 pane.el.addClass('active');
27993 pane.fireEvent('activate');
27998 getActivePane : function()
28001 Roo.each(this.panes, function(p) {
28002 if(p.el.hasClass('active')){
28023 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
28025 * @class Roo.bootstrap.TabPane
28026 * @extends Roo.bootstrap.Component
28027 * Bootstrap TabPane class
28028 * @cfg {Boolean} active (false | true) Default false
28029 * @cfg {String} title title of panel
28033 * Create a new TabPane
28034 * @param {Object} config The config object
28037 Roo.bootstrap.dash.TabPane = function(config){
28038 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
28044 * When a pane is activated
28045 * @param {Roo.bootstrap.dash.TabPane} pane
28052 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
28057 // the tabBox that this is attached to.
28060 getAutoCreate : function()
28068 cfg.cls += ' active';
28073 initEvents : function()
28075 //Roo.log('trigger add pane handler');
28076 this.parent().fireEvent('addpane', this)
28080 * Updates the tab title
28081 * @param {String} html to set the title to.
28083 setTitle: function(str)
28089 this.tab.select('a', true).first().dom.innerHTML = str;
28106 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
28109 * @class Roo.bootstrap.menu.Menu
28110 * @extends Roo.bootstrap.Component
28111 * Bootstrap Menu class - container for Menu
28112 * @cfg {String} html Text of the menu
28113 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
28114 * @cfg {String} icon Font awesome icon
28115 * @cfg {String} pos Menu align to (top | bottom) default bottom
28119 * Create a new Menu
28120 * @param {Object} config The config object
28124 Roo.bootstrap.menu.Menu = function(config){
28125 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
28129 * @event beforeshow
28130 * Fires before this menu is displayed
28131 * @param {Roo.bootstrap.menu.Menu} this
28135 * @event beforehide
28136 * Fires before this menu is hidden
28137 * @param {Roo.bootstrap.menu.Menu} this
28142 * Fires after this menu is displayed
28143 * @param {Roo.bootstrap.menu.Menu} this
28148 * Fires after this menu is hidden
28149 * @param {Roo.bootstrap.menu.Menu} this
28154 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
28155 * @param {Roo.bootstrap.menu.Menu} this
28156 * @param {Roo.EventObject} e
28163 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
28167 weight : 'default',
28172 getChildContainer : function() {
28173 if(this.isSubMenu){
28177 return this.el.select('ul.dropdown-menu', true).first();
28180 getAutoCreate : function()
28185 cls : 'roo-menu-text',
28193 cls : 'fa ' + this.icon
28204 cls : 'dropdown-button btn btn-' + this.weight,
28209 cls : 'dropdown-toggle btn btn-' + this.weight,
28219 cls : 'dropdown-menu'
28225 if(this.pos == 'top'){
28226 cfg.cls += ' dropup';
28229 if(this.isSubMenu){
28232 cls : 'dropdown-menu'
28239 onRender : function(ct, position)
28241 this.isSubMenu = ct.hasClass('dropdown-submenu');
28243 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
28246 initEvents : function()
28248 if(this.isSubMenu){
28252 this.hidden = true;
28254 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
28255 this.triggerEl.on('click', this.onTriggerPress, this);
28257 this.buttonEl = this.el.select('button.dropdown-button', true).first();
28258 this.buttonEl.on('click', this.onClick, this);
28264 if(this.isSubMenu){
28268 return this.el.select('ul.dropdown-menu', true).first();
28271 onClick : function(e)
28273 this.fireEvent("click", this, e);
28276 onTriggerPress : function(e)
28278 if (this.isVisible()) {
28285 isVisible : function(){
28286 return !this.hidden;
28291 this.fireEvent("beforeshow", this);
28293 this.hidden = false;
28294 this.el.addClass('open');
28296 Roo.get(document).on("mouseup", this.onMouseUp, this);
28298 this.fireEvent("show", this);
28305 this.fireEvent("beforehide", this);
28307 this.hidden = true;
28308 this.el.removeClass('open');
28310 Roo.get(document).un("mouseup", this.onMouseUp);
28312 this.fireEvent("hide", this);
28315 onMouseUp : function()
28329 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
28332 * @class Roo.bootstrap.menu.Item
28333 * @extends Roo.bootstrap.Component
28334 * Bootstrap MenuItem class
28335 * @cfg {Boolean} submenu (true | false) default false
28336 * @cfg {String} html text of the item
28337 * @cfg {String} href the link
28338 * @cfg {Boolean} disable (true | false) default false
28339 * @cfg {Boolean} preventDefault (true | false) default true
28340 * @cfg {String} icon Font awesome icon
28341 * @cfg {String} pos Submenu align to (left | right) default right
28345 * Create a new Item
28346 * @param {Object} config The config object
28350 Roo.bootstrap.menu.Item = function(config){
28351 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
28355 * Fires when the mouse is hovering over this menu
28356 * @param {Roo.bootstrap.menu.Item} this
28357 * @param {Roo.EventObject} e
28362 * Fires when the mouse exits this menu
28363 * @param {Roo.bootstrap.menu.Item} this
28364 * @param {Roo.EventObject} e
28370 * The raw click event for the entire grid.
28371 * @param {Roo.EventObject} e
28377 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
28382 preventDefault: true,
28387 getAutoCreate : function()
28392 cls : 'roo-menu-item-text',
28400 cls : 'fa ' + this.icon
28409 href : this.href || '#',
28416 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
28420 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
28422 if(this.pos == 'left'){
28423 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
28430 initEvents : function()
28432 this.el.on('mouseover', this.onMouseOver, this);
28433 this.el.on('mouseout', this.onMouseOut, this);
28435 this.el.select('a', true).first().on('click', this.onClick, this);
28439 onClick : function(e)
28441 if(this.preventDefault){
28442 e.preventDefault();
28445 this.fireEvent("click", this, e);
28448 onMouseOver : function(e)
28450 if(this.submenu && this.pos == 'left'){
28451 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
28454 this.fireEvent("mouseover", this, e);
28457 onMouseOut : function(e)
28459 this.fireEvent("mouseout", this, e);
28471 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
28474 * @class Roo.bootstrap.menu.Separator
28475 * @extends Roo.bootstrap.Component
28476 * Bootstrap Separator class
28479 * Create a new Separator
28480 * @param {Object} config The config object
28484 Roo.bootstrap.menu.Separator = function(config){
28485 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
28488 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
28490 getAutoCreate : function(){
28511 * @class Roo.bootstrap.Tooltip
28512 * Bootstrap Tooltip class
28513 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
28514 * to determine which dom element triggers the tooltip.
28516 * It needs to add support for additional attributes like tooltip-position
28519 * Create a new Toolti
28520 * @param {Object} config The config object
28523 Roo.bootstrap.Tooltip = function(config){
28524 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
28526 this.alignment = Roo.bootstrap.Tooltip.alignment;
28528 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
28529 this.alignment = config.alignment;
28534 Roo.apply(Roo.bootstrap.Tooltip, {
28536 * @function init initialize tooltip monitoring.
28540 currentTip : false,
28541 currentRegion : false,
28547 Roo.get(document).on('mouseover', this.enter ,this);
28548 Roo.get(document).on('mouseout', this.leave, this);
28551 this.currentTip = new Roo.bootstrap.Tooltip();
28554 enter : function(ev)
28556 var dom = ev.getTarget();
28558 //Roo.log(['enter',dom]);
28559 var el = Roo.fly(dom);
28560 if (this.currentEl) {
28562 //Roo.log(this.currentEl);
28563 //Roo.log(this.currentEl.contains(dom));
28564 if (this.currentEl == el) {
28567 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
28573 if (this.currentTip.el) {
28574 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
28578 if(!el || el.dom == document){
28584 // you can not look for children, as if el is the body.. then everythign is the child..
28585 if (!el.attr('tooltip')) { //
28586 if (!el.select("[tooltip]").elements.length) {
28589 // is the mouse over this child...?
28590 bindEl = el.select("[tooltip]").first();
28591 var xy = ev.getXY();
28592 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
28593 //Roo.log("not in region.");
28596 //Roo.log("child element over..");
28599 this.currentEl = bindEl;
28600 this.currentTip.bind(bindEl);
28601 this.currentRegion = Roo.lib.Region.getRegion(dom);
28602 this.currentTip.enter();
28605 leave : function(ev)
28607 var dom = ev.getTarget();
28608 //Roo.log(['leave',dom]);
28609 if (!this.currentEl) {
28614 if (dom != this.currentEl.dom) {
28617 var xy = ev.getXY();
28618 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
28621 // only activate leave if mouse cursor is outside... bounding box..
28626 if (this.currentTip) {
28627 this.currentTip.leave();
28629 //Roo.log('clear currentEl');
28630 this.currentEl = false;
28635 'left' : ['r-l', [-2,0], 'right'],
28636 'right' : ['l-r', [2,0], 'left'],
28637 'bottom' : ['t-b', [0,2], 'top'],
28638 'top' : [ 'b-t', [0,-2], 'bottom']
28644 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
28649 delay : null, // can be { show : 300 , hide: 500}
28653 hoverState : null, //???
28655 placement : 'bottom',
28659 getAutoCreate : function(){
28666 cls : 'tooltip-arrow arrow'
28669 cls : 'tooltip-inner'
28676 bind : function(el)
28681 initEvents : function()
28683 this.arrowEl = this.el.select('.arrow', true).first();
28684 this.innerEl = this.el.select('.tooltip-inner', true).first();
28687 enter : function () {
28689 if (this.timeout != null) {
28690 clearTimeout(this.timeout);
28693 this.hoverState = 'in';
28694 //Roo.log("enter - show");
28695 if (!this.delay || !this.delay.show) {
28700 this.timeout = setTimeout(function () {
28701 if (_t.hoverState == 'in') {
28704 }, this.delay.show);
28708 clearTimeout(this.timeout);
28710 this.hoverState = 'out';
28711 if (!this.delay || !this.delay.hide) {
28717 this.timeout = setTimeout(function () {
28718 //Roo.log("leave - timeout");
28720 if (_t.hoverState == 'out') {
28722 Roo.bootstrap.Tooltip.currentEl = false;
28727 show : function (msg)
28730 this.render(document.body);
28733 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
28735 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
28737 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
28739 this.el.removeClass(['fade','top','bottom', 'left', 'right','in',
28740 'bs-tooltip-top','bs-tooltip-bottom', 'bs-tooltip-left', 'bs-tooltip-right']);
28742 var placement = typeof this.placement == 'function' ?
28743 this.placement.call(this, this.el, on_el) :
28746 var autoToken = /\s?auto?\s?/i;
28747 var autoPlace = autoToken.test(placement);
28749 placement = placement.replace(autoToken, '') || 'top';
28753 //this.el.setXY([0,0]);
28755 //this.el.dom.style.display='block';
28757 //this.el.appendTo(on_el);
28759 var p = this.getPosition();
28760 var box = this.el.getBox();
28766 var align = this.alignment[placement];
28768 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
28770 if(placement == 'top' || placement == 'bottom'){
28772 placement = 'right';
28775 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
28776 placement = 'left';
28779 var scroll = Roo.select('body', true).first().getScroll();
28781 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
28785 align = this.alignment[placement];
28787 this.arrowEl.setLeft((this.innerEl.getWidth()/2) - 5);
28791 this.el.alignTo(this.bindEl, align[0],align[1]);
28792 //var arrow = this.el.select('.arrow',true).first();
28793 //arrow.set(align[2],
28795 this.el.addClass(placement);
28796 this.el.addClass("bs-tooltip-"+ placement);
28798 this.el.addClass('in fade show');
28800 this.hoverState = null;
28802 if (this.el.hasClass('fade')) {
28817 //this.el.setXY([0,0]);
28818 this.el.removeClass(['show', 'in']);
28834 * @class Roo.bootstrap.LocationPicker
28835 * @extends Roo.bootstrap.Component
28836 * Bootstrap LocationPicker class
28837 * @cfg {Number} latitude Position when init default 0
28838 * @cfg {Number} longitude Position when init default 0
28839 * @cfg {Number} zoom default 15
28840 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
28841 * @cfg {Boolean} mapTypeControl default false
28842 * @cfg {Boolean} disableDoubleClickZoom default false
28843 * @cfg {Boolean} scrollwheel default true
28844 * @cfg {Boolean} streetViewControl default false
28845 * @cfg {Number} radius default 0
28846 * @cfg {String} locationName
28847 * @cfg {Boolean} draggable default true
28848 * @cfg {Boolean} enableAutocomplete default false
28849 * @cfg {Boolean} enableReverseGeocode default true
28850 * @cfg {String} markerTitle
28853 * Create a new LocationPicker
28854 * @param {Object} config The config object
28858 Roo.bootstrap.LocationPicker = function(config){
28860 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
28865 * Fires when the picker initialized.
28866 * @param {Roo.bootstrap.LocationPicker} this
28867 * @param {Google Location} location
28871 * @event positionchanged
28872 * Fires when the picker position changed.
28873 * @param {Roo.bootstrap.LocationPicker} this
28874 * @param {Google Location} location
28876 positionchanged : true,
28879 * Fires when the map resize.
28880 * @param {Roo.bootstrap.LocationPicker} this
28885 * Fires when the map show.
28886 * @param {Roo.bootstrap.LocationPicker} this
28891 * Fires when the map hide.
28892 * @param {Roo.bootstrap.LocationPicker} this
28897 * Fires when click the map.
28898 * @param {Roo.bootstrap.LocationPicker} this
28899 * @param {Map event} e
28903 * @event mapRightClick
28904 * Fires when right click the map.
28905 * @param {Roo.bootstrap.LocationPicker} this
28906 * @param {Map event} e
28908 mapRightClick : true,
28910 * @event markerClick
28911 * Fires when click the marker.
28912 * @param {Roo.bootstrap.LocationPicker} this
28913 * @param {Map event} e
28915 markerClick : true,
28917 * @event markerRightClick
28918 * Fires when right click the marker.
28919 * @param {Roo.bootstrap.LocationPicker} this
28920 * @param {Map event} e
28922 markerRightClick : true,
28924 * @event OverlayViewDraw
28925 * Fires when OverlayView Draw
28926 * @param {Roo.bootstrap.LocationPicker} this
28928 OverlayViewDraw : true,
28930 * @event OverlayViewOnAdd
28931 * Fires when OverlayView Draw
28932 * @param {Roo.bootstrap.LocationPicker} this
28934 OverlayViewOnAdd : true,
28936 * @event OverlayViewOnRemove
28937 * Fires when OverlayView Draw
28938 * @param {Roo.bootstrap.LocationPicker} this
28940 OverlayViewOnRemove : true,
28942 * @event OverlayViewShow
28943 * Fires when OverlayView Draw
28944 * @param {Roo.bootstrap.LocationPicker} this
28945 * @param {Pixel} cpx
28947 OverlayViewShow : true,
28949 * @event OverlayViewHide
28950 * Fires when OverlayView Draw
28951 * @param {Roo.bootstrap.LocationPicker} this
28953 OverlayViewHide : true,
28955 * @event loadexception
28956 * Fires when load google lib failed.
28957 * @param {Roo.bootstrap.LocationPicker} this
28959 loadexception : true
28964 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
28966 gMapContext: false,
28972 mapTypeControl: false,
28973 disableDoubleClickZoom: false,
28975 streetViewControl: false,
28979 enableAutocomplete: false,
28980 enableReverseGeocode: true,
28983 getAutoCreate: function()
28988 cls: 'roo-location-picker'
28994 initEvents: function(ct, position)
28996 if(!this.el.getWidth() || this.isApplied()){
29000 this.el.setVisibilityMode(Roo.Element.DISPLAY);
29005 initial: function()
29007 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
29008 this.fireEvent('loadexception', this);
29012 if(!this.mapTypeId){
29013 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
29016 this.gMapContext = this.GMapContext();
29018 this.initOverlayView();
29020 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
29024 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
29025 _this.setPosition(_this.gMapContext.marker.position);
29028 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
29029 _this.fireEvent('mapClick', this, event);
29033 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
29034 _this.fireEvent('mapRightClick', this, event);
29038 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
29039 _this.fireEvent('markerClick', this, event);
29043 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
29044 _this.fireEvent('markerRightClick', this, event);
29048 this.setPosition(this.gMapContext.location);
29050 this.fireEvent('initial', this, this.gMapContext.location);
29053 initOverlayView: function()
29057 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
29061 _this.fireEvent('OverlayViewDraw', _this);
29066 _this.fireEvent('OverlayViewOnAdd', _this);
29069 onRemove: function()
29071 _this.fireEvent('OverlayViewOnRemove', _this);
29074 show: function(cpx)
29076 _this.fireEvent('OverlayViewShow', _this, cpx);
29081 _this.fireEvent('OverlayViewHide', _this);
29087 fromLatLngToContainerPixel: function(event)
29089 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
29092 isApplied: function()
29094 return this.getGmapContext() == false ? false : true;
29097 getGmapContext: function()
29099 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
29102 GMapContext: function()
29104 var position = new google.maps.LatLng(this.latitude, this.longitude);
29106 var _map = new google.maps.Map(this.el.dom, {
29109 mapTypeId: this.mapTypeId,
29110 mapTypeControl: this.mapTypeControl,
29111 disableDoubleClickZoom: this.disableDoubleClickZoom,
29112 scrollwheel: this.scrollwheel,
29113 streetViewControl: this.streetViewControl,
29114 locationName: this.locationName,
29115 draggable: this.draggable,
29116 enableAutocomplete: this.enableAutocomplete,
29117 enableReverseGeocode: this.enableReverseGeocode
29120 var _marker = new google.maps.Marker({
29121 position: position,
29123 title: this.markerTitle,
29124 draggable: this.draggable
29131 location: position,
29132 radius: this.radius,
29133 locationName: this.locationName,
29134 addressComponents: {
29135 formatted_address: null,
29136 addressLine1: null,
29137 addressLine2: null,
29139 streetNumber: null,
29143 stateOrProvince: null
29146 domContainer: this.el.dom,
29147 geodecoder: new google.maps.Geocoder()
29151 drawCircle: function(center, radius, options)
29153 if (this.gMapContext.circle != null) {
29154 this.gMapContext.circle.setMap(null);
29158 options = Roo.apply({}, options, {
29159 strokeColor: "#0000FF",
29160 strokeOpacity: .35,
29162 fillColor: "#0000FF",
29166 options.map = this.gMapContext.map;
29167 options.radius = radius;
29168 options.center = center;
29169 this.gMapContext.circle = new google.maps.Circle(options);
29170 return this.gMapContext.circle;
29176 setPosition: function(location)
29178 this.gMapContext.location = location;
29179 this.gMapContext.marker.setPosition(location);
29180 this.gMapContext.map.panTo(location);
29181 this.drawCircle(location, this.gMapContext.radius, {});
29185 if (this.gMapContext.settings.enableReverseGeocode) {
29186 this.gMapContext.geodecoder.geocode({
29187 latLng: this.gMapContext.location
29188 }, function(results, status) {
29190 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
29191 _this.gMapContext.locationName = results[0].formatted_address;
29192 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
29194 _this.fireEvent('positionchanged', this, location);
29201 this.fireEvent('positionchanged', this, location);
29206 google.maps.event.trigger(this.gMapContext.map, "resize");
29208 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
29210 this.fireEvent('resize', this);
29213 setPositionByLatLng: function(latitude, longitude)
29215 this.setPosition(new google.maps.LatLng(latitude, longitude));
29218 getCurrentPosition: function()
29221 latitude: this.gMapContext.location.lat(),
29222 longitude: this.gMapContext.location.lng()
29226 getAddressName: function()
29228 return this.gMapContext.locationName;
29231 getAddressComponents: function()
29233 return this.gMapContext.addressComponents;
29236 address_component_from_google_geocode: function(address_components)
29240 for (var i = 0; i < address_components.length; i++) {
29241 var component = address_components[i];
29242 if (component.types.indexOf("postal_code") >= 0) {
29243 result.postalCode = component.short_name;
29244 } else if (component.types.indexOf("street_number") >= 0) {
29245 result.streetNumber = component.short_name;
29246 } else if (component.types.indexOf("route") >= 0) {
29247 result.streetName = component.short_name;
29248 } else if (component.types.indexOf("neighborhood") >= 0) {
29249 result.city = component.short_name;
29250 } else if (component.types.indexOf("locality") >= 0) {
29251 result.city = component.short_name;
29252 } else if (component.types.indexOf("sublocality") >= 0) {
29253 result.district = component.short_name;
29254 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
29255 result.stateOrProvince = component.short_name;
29256 } else if (component.types.indexOf("country") >= 0) {
29257 result.country = component.short_name;
29261 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
29262 result.addressLine2 = "";
29266 setZoomLevel: function(zoom)
29268 this.gMapContext.map.setZoom(zoom);
29281 this.fireEvent('show', this);
29292 this.fireEvent('hide', this);
29297 Roo.apply(Roo.bootstrap.LocationPicker, {
29299 OverlayView : function(map, options)
29301 options = options || {};
29308 * @class Roo.bootstrap.Alert
29309 * @extends Roo.bootstrap.Component
29310 * Bootstrap Alert class - shows an alert area box
29312 * <div class="alert alert-danger" role="alert"><span class="fa fa-exclamation-triangle"></span><span class="sr-only">Error:</span>
29313 Enter a valid email address
29316 * @cfg {String} title The title of alert
29317 * @cfg {String} html The content of alert
29318 * @cfg {String} weight ( success | info | warning | danger )
29319 * @cfg {String} faicon font-awesomeicon
29322 * Create a new alert
29323 * @param {Object} config The config object
29327 Roo.bootstrap.Alert = function(config){
29328 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
29332 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
29339 getAutoCreate : function()
29348 cls : 'roo-alert-icon'
29353 cls : 'roo-alert-title',
29358 cls : 'roo-alert-text',
29365 cfg.cn[0].cls += ' fa ' + this.faicon;
29369 cfg.cls += ' alert-' + this.weight;
29375 initEvents: function()
29377 this.el.setVisibilityMode(Roo.Element.DISPLAY);
29380 setTitle : function(str)
29382 this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
29385 setText : function(str)
29387 this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
29390 setWeight : function(weight)
29393 this.el.select('.alert',true).first().removeClass('alert-' + this.weight);
29396 this.weight = weight;
29398 this.el.select('.alert',true).first().addClass('alert-' + this.weight);
29401 setIcon : function(icon)
29404 this.el.select('.roo-alert-icon',true).first().removeClass(['fa', 'fa-' + this.faicon]);
29407 this.faicon = icon;
29409 this.el.select('.roo-alert-icon',true).first().addClass(['fa', 'fa-' + this.faicon]);
29430 * @class Roo.bootstrap.UploadCropbox
29431 * @extends Roo.bootstrap.Component
29432 * Bootstrap UploadCropbox class
29433 * @cfg {String} emptyText show when image has been loaded
29434 * @cfg {String} rotateNotify show when image too small to rotate
29435 * @cfg {Number} errorTimeout default 3000
29436 * @cfg {Number} minWidth default 300
29437 * @cfg {Number} minHeight default 300
29438 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
29439 * @cfg {Boolean} isDocument (true|false) default false
29440 * @cfg {String} url action url
29441 * @cfg {String} paramName default 'imageUpload'
29442 * @cfg {String} method default POST
29443 * @cfg {Boolean} loadMask (true|false) default true
29444 * @cfg {Boolean} loadingText default 'Loading...'
29447 * Create a new UploadCropbox
29448 * @param {Object} config The config object
29451 Roo.bootstrap.UploadCropbox = function(config){
29452 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
29456 * @event beforeselectfile
29457 * Fire before select file
29458 * @param {Roo.bootstrap.UploadCropbox} this
29460 "beforeselectfile" : true,
29463 * Fire after initEvent
29464 * @param {Roo.bootstrap.UploadCropbox} this
29469 * Fire after initEvent
29470 * @param {Roo.bootstrap.UploadCropbox} this
29471 * @param {String} data
29476 * Fire when preparing the file data
29477 * @param {Roo.bootstrap.UploadCropbox} this
29478 * @param {Object} file
29483 * Fire when get exception
29484 * @param {Roo.bootstrap.UploadCropbox} this
29485 * @param {XMLHttpRequest} xhr
29487 "exception" : true,
29489 * @event beforeloadcanvas
29490 * Fire before load the canvas
29491 * @param {Roo.bootstrap.UploadCropbox} this
29492 * @param {String} src
29494 "beforeloadcanvas" : true,
29497 * Fire when trash image
29498 * @param {Roo.bootstrap.UploadCropbox} this
29503 * Fire when download the image
29504 * @param {Roo.bootstrap.UploadCropbox} this
29508 * @event footerbuttonclick
29509 * Fire when footerbuttonclick
29510 * @param {Roo.bootstrap.UploadCropbox} this
29511 * @param {String} type
29513 "footerbuttonclick" : true,
29517 * @param {Roo.bootstrap.UploadCropbox} this
29522 * Fire when rotate the image
29523 * @param {Roo.bootstrap.UploadCropbox} this
29524 * @param {String} pos
29529 * Fire when inspect the file
29530 * @param {Roo.bootstrap.UploadCropbox} this
29531 * @param {Object} file
29536 * Fire when xhr upload the file
29537 * @param {Roo.bootstrap.UploadCropbox} this
29538 * @param {Object} data
29543 * Fire when arrange the file data
29544 * @param {Roo.bootstrap.UploadCropbox} this
29545 * @param {Object} formData
29550 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
29553 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
29555 emptyText : 'Click to upload image',
29556 rotateNotify : 'Image is too small to rotate',
29557 errorTimeout : 3000,
29571 cropType : 'image/jpeg',
29573 canvasLoaded : false,
29574 isDocument : false,
29576 paramName : 'imageUpload',
29578 loadingText : 'Loading...',
29581 getAutoCreate : function()
29585 cls : 'roo-upload-cropbox',
29589 cls : 'roo-upload-cropbox-selector',
29594 cls : 'roo-upload-cropbox-body',
29595 style : 'cursor:pointer',
29599 cls : 'roo-upload-cropbox-preview'
29603 cls : 'roo-upload-cropbox-thumb'
29607 cls : 'roo-upload-cropbox-empty-notify',
29608 html : this.emptyText
29612 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
29613 html : this.rotateNotify
29619 cls : 'roo-upload-cropbox-footer',
29622 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
29632 onRender : function(ct, position)
29634 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
29636 if (this.buttons.length) {
29638 Roo.each(this.buttons, function(bb) {
29640 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
29642 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
29648 this.maskEl = this.el;
29652 initEvents : function()
29654 this.urlAPI = (window.createObjectURL && window) ||
29655 (window.URL && URL.revokeObjectURL && URL) ||
29656 (window.webkitURL && webkitURL);
29658 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
29659 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29661 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
29662 this.selectorEl.hide();
29664 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
29665 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29667 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
29668 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29669 this.thumbEl.hide();
29671 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
29672 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29674 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
29675 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29676 this.errorEl.hide();
29678 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
29679 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29680 this.footerEl.hide();
29682 this.setThumbBoxSize();
29688 this.fireEvent('initial', this);
29695 window.addEventListener("resize", function() { _this.resize(); } );
29697 this.bodyEl.on('click', this.beforeSelectFile, this);
29700 this.bodyEl.on('touchstart', this.onTouchStart, this);
29701 this.bodyEl.on('touchmove', this.onTouchMove, this);
29702 this.bodyEl.on('touchend', this.onTouchEnd, this);
29706 this.bodyEl.on('mousedown', this.onMouseDown, this);
29707 this.bodyEl.on('mousemove', this.onMouseMove, this);
29708 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
29709 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
29710 Roo.get(document).on('mouseup', this.onMouseUp, this);
29713 this.selectorEl.on('change', this.onFileSelected, this);
29719 this.baseScale = 1;
29721 this.baseRotate = 1;
29722 this.dragable = false;
29723 this.pinching = false;
29726 this.cropData = false;
29727 this.notifyEl.dom.innerHTML = this.emptyText;
29729 this.selectorEl.dom.value = '';
29733 resize : function()
29735 if(this.fireEvent('resize', this) != false){
29736 this.setThumbBoxPosition();
29737 this.setCanvasPosition();
29741 onFooterButtonClick : function(e, el, o, type)
29744 case 'rotate-left' :
29745 this.onRotateLeft(e);
29747 case 'rotate-right' :
29748 this.onRotateRight(e);
29751 this.beforeSelectFile(e);
29766 this.fireEvent('footerbuttonclick', this, type);
29769 beforeSelectFile : function(e)
29771 e.preventDefault();
29773 if(this.fireEvent('beforeselectfile', this) != false){
29774 this.selectorEl.dom.click();
29778 onFileSelected : function(e)
29780 e.preventDefault();
29782 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
29786 var file = this.selectorEl.dom.files[0];
29788 if(this.fireEvent('inspect', this, file) != false){
29789 this.prepare(file);
29794 trash : function(e)
29796 this.fireEvent('trash', this);
29799 download : function(e)
29801 this.fireEvent('download', this);
29804 loadCanvas : function(src)
29806 if(this.fireEvent('beforeloadcanvas', this, src) != false){
29810 this.imageEl = document.createElement('img');
29814 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
29816 this.imageEl.src = src;
29820 onLoadCanvas : function()
29822 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
29823 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
29825 this.bodyEl.un('click', this.beforeSelectFile, this);
29827 this.notifyEl.hide();
29828 this.thumbEl.show();
29829 this.footerEl.show();
29831 this.baseRotateLevel();
29833 if(this.isDocument){
29834 this.setThumbBoxSize();
29837 this.setThumbBoxPosition();
29839 this.baseScaleLevel();
29845 this.canvasLoaded = true;
29848 this.maskEl.unmask();
29853 setCanvasPosition : function()
29855 if(!this.canvasEl){
29859 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
29860 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
29862 this.previewEl.setLeft(pw);
29863 this.previewEl.setTop(ph);
29867 onMouseDown : function(e)
29871 this.dragable = true;
29872 this.pinching = false;
29874 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
29875 this.dragable = false;
29879 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
29880 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
29884 onMouseMove : function(e)
29888 if(!this.canvasLoaded){
29892 if (!this.dragable){
29896 var minX = Math.ceil(this.thumbEl.getLeft(true));
29897 var minY = Math.ceil(this.thumbEl.getTop(true));
29899 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
29900 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
29902 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
29903 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
29905 x = x - this.mouseX;
29906 y = y - this.mouseY;
29908 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
29909 var bgY = Math.ceil(y + this.previewEl.getTop(true));
29911 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
29912 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
29914 this.previewEl.setLeft(bgX);
29915 this.previewEl.setTop(bgY);
29917 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
29918 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
29921 onMouseUp : function(e)
29925 this.dragable = false;
29928 onMouseWheel : function(e)
29932 this.startScale = this.scale;
29934 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
29936 if(!this.zoomable()){
29937 this.scale = this.startScale;
29946 zoomable : function()
29948 var minScale = this.thumbEl.getWidth() / this.minWidth;
29950 if(this.minWidth < this.minHeight){
29951 minScale = this.thumbEl.getHeight() / this.minHeight;
29954 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
29955 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
29959 (this.rotate == 0 || this.rotate == 180) &&
29961 width > this.imageEl.OriginWidth ||
29962 height > this.imageEl.OriginHeight ||
29963 (width < this.minWidth && height < this.minHeight)
29971 (this.rotate == 90 || this.rotate == 270) &&
29973 width > this.imageEl.OriginWidth ||
29974 height > this.imageEl.OriginHeight ||
29975 (width < this.minHeight && height < this.minWidth)
29982 !this.isDocument &&
29983 (this.rotate == 0 || this.rotate == 180) &&
29985 width < this.minWidth ||
29986 width > this.imageEl.OriginWidth ||
29987 height < this.minHeight ||
29988 height > this.imageEl.OriginHeight
29995 !this.isDocument &&
29996 (this.rotate == 90 || this.rotate == 270) &&
29998 width < this.minHeight ||
29999 width > this.imageEl.OriginWidth ||
30000 height < this.minWidth ||
30001 height > this.imageEl.OriginHeight
30011 onRotateLeft : function(e)
30013 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
30015 var minScale = this.thumbEl.getWidth() / this.minWidth;
30017 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
30018 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
30020 this.startScale = this.scale;
30022 while (this.getScaleLevel() < minScale){
30024 this.scale = this.scale + 1;
30026 if(!this.zoomable()){
30031 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
30032 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
30037 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
30044 this.scale = this.startScale;
30046 this.onRotateFail();
30051 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
30053 if(this.isDocument){
30054 this.setThumbBoxSize();
30055 this.setThumbBoxPosition();
30056 this.setCanvasPosition();
30061 this.fireEvent('rotate', this, 'left');
30065 onRotateRight : function(e)
30067 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
30069 var minScale = this.thumbEl.getWidth() / this.minWidth;
30071 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
30072 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
30074 this.startScale = this.scale;
30076 while (this.getScaleLevel() < minScale){
30078 this.scale = this.scale + 1;
30080 if(!this.zoomable()){
30085 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
30086 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
30091 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
30098 this.scale = this.startScale;
30100 this.onRotateFail();
30105 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
30107 if(this.isDocument){
30108 this.setThumbBoxSize();
30109 this.setThumbBoxPosition();
30110 this.setCanvasPosition();
30115 this.fireEvent('rotate', this, 'right');
30118 onRotateFail : function()
30120 this.errorEl.show(true);
30124 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
30129 this.previewEl.dom.innerHTML = '';
30131 var canvasEl = document.createElement("canvas");
30133 var contextEl = canvasEl.getContext("2d");
30135 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
30136 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
30137 var center = this.imageEl.OriginWidth / 2;
30139 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
30140 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
30141 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
30142 center = this.imageEl.OriginHeight / 2;
30145 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
30147 contextEl.translate(center, center);
30148 contextEl.rotate(this.rotate * Math.PI / 180);
30150 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
30152 this.canvasEl = document.createElement("canvas");
30154 this.contextEl = this.canvasEl.getContext("2d");
30156 switch (this.rotate) {
30159 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
30160 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
30162 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
30167 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
30168 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
30170 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
30171 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);
30175 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
30180 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
30181 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
30183 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
30184 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);
30188 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);
30193 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
30194 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
30196 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
30197 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
30201 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);
30208 this.previewEl.appendChild(this.canvasEl);
30210 this.setCanvasPosition();
30215 if(!this.canvasLoaded){
30219 var imageCanvas = document.createElement("canvas");
30221 var imageContext = imageCanvas.getContext("2d");
30223 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
30224 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
30226 var center = imageCanvas.width / 2;
30228 imageContext.translate(center, center);
30230 imageContext.rotate(this.rotate * Math.PI / 180);
30232 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
30234 var canvas = document.createElement("canvas");
30236 var context = canvas.getContext("2d");
30238 canvas.width = this.minWidth;
30239 canvas.height = this.minHeight;
30241 switch (this.rotate) {
30244 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
30245 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
30247 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
30248 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
30250 var targetWidth = this.minWidth - 2 * x;
30251 var targetHeight = this.minHeight - 2 * y;
30255 if((x == 0 && y == 0) || (x == 0 && y > 0)){
30256 scale = targetWidth / width;
30259 if(x > 0 && y == 0){
30260 scale = targetHeight / height;
30263 if(x > 0 && y > 0){
30264 scale = targetWidth / width;
30266 if(width < height){
30267 scale = targetHeight / height;
30271 context.scale(scale, scale);
30273 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
30274 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
30276 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
30277 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
30279 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
30284 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
30285 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
30287 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
30288 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
30290 var targetWidth = this.minWidth - 2 * x;
30291 var targetHeight = this.minHeight - 2 * y;
30295 if((x == 0 && y == 0) || (x == 0 && y > 0)){
30296 scale = targetWidth / width;
30299 if(x > 0 && y == 0){
30300 scale = targetHeight / height;
30303 if(x > 0 && y > 0){
30304 scale = targetWidth / width;
30306 if(width < height){
30307 scale = targetHeight / height;
30311 context.scale(scale, scale);
30313 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
30314 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
30316 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
30317 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
30319 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
30321 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
30326 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
30327 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
30329 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
30330 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
30332 var targetWidth = this.minWidth - 2 * x;
30333 var targetHeight = this.minHeight - 2 * y;
30337 if((x == 0 && y == 0) || (x == 0 && y > 0)){
30338 scale = targetWidth / width;
30341 if(x > 0 && y == 0){
30342 scale = targetHeight / height;
30345 if(x > 0 && y > 0){
30346 scale = targetWidth / width;
30348 if(width < height){
30349 scale = targetHeight / height;
30353 context.scale(scale, scale);
30355 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
30356 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
30358 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
30359 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
30361 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
30362 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
30364 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
30369 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
30370 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
30372 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
30373 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
30375 var targetWidth = this.minWidth - 2 * x;
30376 var targetHeight = this.minHeight - 2 * y;
30380 if((x == 0 && y == 0) || (x == 0 && y > 0)){
30381 scale = targetWidth / width;
30384 if(x > 0 && y == 0){
30385 scale = targetHeight / height;
30388 if(x > 0 && y > 0){
30389 scale = targetWidth / width;
30391 if(width < height){
30392 scale = targetHeight / height;
30396 context.scale(scale, scale);
30398 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
30399 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
30401 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
30402 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
30404 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
30406 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
30413 this.cropData = canvas.toDataURL(this.cropType);
30415 if(this.fireEvent('crop', this, this.cropData) !== false){
30416 this.process(this.file, this.cropData);
30423 setThumbBoxSize : function()
30427 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
30428 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
30429 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
30431 this.minWidth = width;
30432 this.minHeight = height;
30434 if(this.rotate == 90 || this.rotate == 270){
30435 this.minWidth = height;
30436 this.minHeight = width;
30441 width = Math.ceil(this.minWidth * height / this.minHeight);
30443 if(this.minWidth > this.minHeight){
30445 height = Math.ceil(this.minHeight * width / this.minWidth);
30448 this.thumbEl.setStyle({
30449 width : width + 'px',
30450 height : height + 'px'
30457 setThumbBoxPosition : function()
30459 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
30460 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
30462 this.thumbEl.setLeft(x);
30463 this.thumbEl.setTop(y);
30467 baseRotateLevel : function()
30469 this.baseRotate = 1;
30472 typeof(this.exif) != 'undefined' &&
30473 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
30474 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
30476 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
30479 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
30483 baseScaleLevel : function()
30487 if(this.isDocument){
30489 if(this.baseRotate == 6 || this.baseRotate == 8){
30491 height = this.thumbEl.getHeight();
30492 this.baseScale = height / this.imageEl.OriginWidth;
30494 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
30495 width = this.thumbEl.getWidth();
30496 this.baseScale = width / this.imageEl.OriginHeight;
30502 height = this.thumbEl.getHeight();
30503 this.baseScale = height / this.imageEl.OriginHeight;
30505 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
30506 width = this.thumbEl.getWidth();
30507 this.baseScale = width / this.imageEl.OriginWidth;
30513 if(this.baseRotate == 6 || this.baseRotate == 8){
30515 width = this.thumbEl.getHeight();
30516 this.baseScale = width / this.imageEl.OriginHeight;
30518 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
30519 height = this.thumbEl.getWidth();
30520 this.baseScale = height / this.imageEl.OriginHeight;
30523 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
30524 height = this.thumbEl.getWidth();
30525 this.baseScale = height / this.imageEl.OriginHeight;
30527 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
30528 width = this.thumbEl.getHeight();
30529 this.baseScale = width / this.imageEl.OriginWidth;
30536 width = this.thumbEl.getWidth();
30537 this.baseScale = width / this.imageEl.OriginWidth;
30539 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
30540 height = this.thumbEl.getHeight();
30541 this.baseScale = height / this.imageEl.OriginHeight;
30544 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
30546 height = this.thumbEl.getHeight();
30547 this.baseScale = height / this.imageEl.OriginHeight;
30549 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
30550 width = this.thumbEl.getWidth();
30551 this.baseScale = width / this.imageEl.OriginWidth;
30559 getScaleLevel : function()
30561 return this.baseScale * Math.pow(1.1, this.scale);
30564 onTouchStart : function(e)
30566 if(!this.canvasLoaded){
30567 this.beforeSelectFile(e);
30571 var touches = e.browserEvent.touches;
30577 if(touches.length == 1){
30578 this.onMouseDown(e);
30582 if(touches.length != 2){
30588 for(var i = 0, finger; finger = touches[i]; i++){
30589 coords.push(finger.pageX, finger.pageY);
30592 var x = Math.pow(coords[0] - coords[2], 2);
30593 var y = Math.pow(coords[1] - coords[3], 2);
30595 this.startDistance = Math.sqrt(x + y);
30597 this.startScale = this.scale;
30599 this.pinching = true;
30600 this.dragable = false;
30604 onTouchMove : function(e)
30606 if(!this.pinching && !this.dragable){
30610 var touches = e.browserEvent.touches;
30617 this.onMouseMove(e);
30623 for(var i = 0, finger; finger = touches[i]; i++){
30624 coords.push(finger.pageX, finger.pageY);
30627 var x = Math.pow(coords[0] - coords[2], 2);
30628 var y = Math.pow(coords[1] - coords[3], 2);
30630 this.endDistance = Math.sqrt(x + y);
30632 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
30634 if(!this.zoomable()){
30635 this.scale = this.startScale;
30643 onTouchEnd : function(e)
30645 this.pinching = false;
30646 this.dragable = false;
30650 process : function(file, crop)
30653 this.maskEl.mask(this.loadingText);
30656 this.xhr = new XMLHttpRequest();
30658 file.xhr = this.xhr;
30660 this.xhr.open(this.method, this.url, true);
30663 "Accept": "application/json",
30664 "Cache-Control": "no-cache",
30665 "X-Requested-With": "XMLHttpRequest"
30668 for (var headerName in headers) {
30669 var headerValue = headers[headerName];
30671 this.xhr.setRequestHeader(headerName, headerValue);
30677 this.xhr.onload = function()
30679 _this.xhrOnLoad(_this.xhr);
30682 this.xhr.onerror = function()
30684 _this.xhrOnError(_this.xhr);
30687 var formData = new FormData();
30689 formData.append('returnHTML', 'NO');
30692 formData.append('crop', crop);
30695 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
30696 formData.append(this.paramName, file, file.name);
30699 if(typeof(file.filename) != 'undefined'){
30700 formData.append('filename', file.filename);
30703 if(typeof(file.mimetype) != 'undefined'){
30704 formData.append('mimetype', file.mimetype);
30707 if(this.fireEvent('arrange', this, formData) != false){
30708 this.xhr.send(formData);
30712 xhrOnLoad : function(xhr)
30715 this.maskEl.unmask();
30718 if (xhr.readyState !== 4) {
30719 this.fireEvent('exception', this, xhr);
30723 var response = Roo.decode(xhr.responseText);
30725 if(!response.success){
30726 this.fireEvent('exception', this, xhr);
30730 var response = Roo.decode(xhr.responseText);
30732 this.fireEvent('upload', this, response);
30736 xhrOnError : function()
30739 this.maskEl.unmask();
30742 Roo.log('xhr on error');
30744 var response = Roo.decode(xhr.responseText);
30750 prepare : function(file)
30753 this.maskEl.mask(this.loadingText);
30759 if(typeof(file) === 'string'){
30760 this.loadCanvas(file);
30764 if(!file || !this.urlAPI){
30769 this.cropType = file.type;
30773 if(this.fireEvent('prepare', this, this.file) != false){
30775 var reader = new FileReader();
30777 reader.onload = function (e) {
30778 if (e.target.error) {
30779 Roo.log(e.target.error);
30783 var buffer = e.target.result,
30784 dataView = new DataView(buffer),
30786 maxOffset = dataView.byteLength - 4,
30790 if (dataView.getUint16(0) === 0xffd8) {
30791 while (offset < maxOffset) {
30792 markerBytes = dataView.getUint16(offset);
30794 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
30795 markerLength = dataView.getUint16(offset + 2) + 2;
30796 if (offset + markerLength > dataView.byteLength) {
30797 Roo.log('Invalid meta data: Invalid segment size.');
30801 if(markerBytes == 0xffe1){
30802 _this.parseExifData(
30809 offset += markerLength;
30819 var url = _this.urlAPI.createObjectURL(_this.file);
30821 _this.loadCanvas(url);
30826 reader.readAsArrayBuffer(this.file);
30832 parseExifData : function(dataView, offset, length)
30834 var tiffOffset = offset + 10,
30838 if (dataView.getUint32(offset + 4) !== 0x45786966) {
30839 // No Exif data, might be XMP data instead
30843 // Check for the ASCII code for "Exif" (0x45786966):
30844 if (dataView.getUint32(offset + 4) !== 0x45786966) {
30845 // No Exif data, might be XMP data instead
30848 if (tiffOffset + 8 > dataView.byteLength) {
30849 Roo.log('Invalid Exif data: Invalid segment size.');
30852 // Check for the two null bytes:
30853 if (dataView.getUint16(offset + 8) !== 0x0000) {
30854 Roo.log('Invalid Exif data: Missing byte alignment offset.');
30857 // Check the byte alignment:
30858 switch (dataView.getUint16(tiffOffset)) {
30860 littleEndian = true;
30863 littleEndian = false;
30866 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
30869 // Check for the TIFF tag marker (0x002A):
30870 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
30871 Roo.log('Invalid Exif data: Missing TIFF marker.');
30874 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
30875 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
30877 this.parseExifTags(
30880 tiffOffset + dirOffset,
30885 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
30890 if (dirOffset + 6 > dataView.byteLength) {
30891 Roo.log('Invalid Exif data: Invalid directory offset.');
30894 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
30895 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
30896 if (dirEndOffset + 4 > dataView.byteLength) {
30897 Roo.log('Invalid Exif data: Invalid directory size.');
30900 for (i = 0; i < tagsNumber; i += 1) {
30904 dirOffset + 2 + 12 * i, // tag offset
30908 // Return the offset to the next directory:
30909 return dataView.getUint32(dirEndOffset, littleEndian);
30912 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
30914 var tag = dataView.getUint16(offset, littleEndian);
30916 this.exif[tag] = this.getExifValue(
30920 dataView.getUint16(offset + 2, littleEndian), // tag type
30921 dataView.getUint32(offset + 4, littleEndian), // tag length
30926 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
30928 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
30937 Roo.log('Invalid Exif data: Invalid tag type.');
30941 tagSize = tagType.size * length;
30942 // Determine if the value is contained in the dataOffset bytes,
30943 // or if the value at the dataOffset is a pointer to the actual data:
30944 dataOffset = tagSize > 4 ?
30945 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
30946 if (dataOffset + tagSize > dataView.byteLength) {
30947 Roo.log('Invalid Exif data: Invalid data offset.');
30950 if (length === 1) {
30951 return tagType.getValue(dataView, dataOffset, littleEndian);
30954 for (i = 0; i < length; i += 1) {
30955 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
30958 if (tagType.ascii) {
30960 // Concatenate the chars:
30961 for (i = 0; i < values.length; i += 1) {
30963 // Ignore the terminating NULL byte(s):
30964 if (c === '\u0000') {
30976 Roo.apply(Roo.bootstrap.UploadCropbox, {
30978 'Orientation': 0x0112
30982 1: 0, //'top-left',
30984 3: 180, //'bottom-right',
30985 // 4: 'bottom-left',
30987 6: 90, //'right-top',
30988 // 7: 'right-bottom',
30989 8: 270 //'left-bottom'
30993 // byte, 8-bit unsigned int:
30995 getValue: function (dataView, dataOffset) {
30996 return dataView.getUint8(dataOffset);
31000 // ascii, 8-bit byte:
31002 getValue: function (dataView, dataOffset) {
31003 return String.fromCharCode(dataView.getUint8(dataOffset));
31008 // short, 16 bit int:
31010 getValue: function (dataView, dataOffset, littleEndian) {
31011 return dataView.getUint16(dataOffset, littleEndian);
31015 // long, 32 bit int:
31017 getValue: function (dataView, dataOffset, littleEndian) {
31018 return dataView.getUint32(dataOffset, littleEndian);
31022 // rational = two long values, first is numerator, second is denominator:
31024 getValue: function (dataView, dataOffset, littleEndian) {
31025 return dataView.getUint32(dataOffset, littleEndian) /
31026 dataView.getUint32(dataOffset + 4, littleEndian);
31030 // slong, 32 bit signed int:
31032 getValue: function (dataView, dataOffset, littleEndian) {
31033 return dataView.getInt32(dataOffset, littleEndian);
31037 // srational, two slongs, first is numerator, second is denominator:
31039 getValue: function (dataView, dataOffset, littleEndian) {
31040 return dataView.getInt32(dataOffset, littleEndian) /
31041 dataView.getInt32(dataOffset + 4, littleEndian);
31051 cls : 'btn-group roo-upload-cropbox-rotate-left',
31052 action : 'rotate-left',
31056 cls : 'btn btn-default',
31057 html : '<i class="fa fa-undo"></i>'
31063 cls : 'btn-group roo-upload-cropbox-picture',
31064 action : 'picture',
31068 cls : 'btn btn-default',
31069 html : '<i class="fa fa-picture-o"></i>'
31075 cls : 'btn-group roo-upload-cropbox-rotate-right',
31076 action : 'rotate-right',
31080 cls : 'btn btn-default',
31081 html : '<i class="fa fa-repeat"></i>'
31089 cls : 'btn-group roo-upload-cropbox-rotate-left',
31090 action : 'rotate-left',
31094 cls : 'btn btn-default',
31095 html : '<i class="fa fa-undo"></i>'
31101 cls : 'btn-group roo-upload-cropbox-download',
31102 action : 'download',
31106 cls : 'btn btn-default',
31107 html : '<i class="fa fa-download"></i>'
31113 cls : 'btn-group roo-upload-cropbox-crop',
31118 cls : 'btn btn-default',
31119 html : '<i class="fa fa-crop"></i>'
31125 cls : 'btn-group roo-upload-cropbox-trash',
31130 cls : 'btn btn-default',
31131 html : '<i class="fa fa-trash"></i>'
31137 cls : 'btn-group roo-upload-cropbox-rotate-right',
31138 action : 'rotate-right',
31142 cls : 'btn btn-default',
31143 html : '<i class="fa fa-repeat"></i>'
31151 cls : 'btn-group roo-upload-cropbox-rotate-left',
31152 action : 'rotate-left',
31156 cls : 'btn btn-default',
31157 html : '<i class="fa fa-undo"></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>'
31182 * @class Roo.bootstrap.DocumentManager
31183 * @extends Roo.bootstrap.Component
31184 * Bootstrap DocumentManager class
31185 * @cfg {String} paramName default 'imageUpload'
31186 * @cfg {String} toolTipName default 'filename'
31187 * @cfg {String} method default POST
31188 * @cfg {String} url action url
31189 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
31190 * @cfg {Boolean} multiple multiple upload default true
31191 * @cfg {Number} thumbSize default 300
31192 * @cfg {String} fieldLabel
31193 * @cfg {Number} labelWidth default 4
31194 * @cfg {String} labelAlign (left|top) default left
31195 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
31196 * @cfg {Number} labellg set the width of label (1-12)
31197 * @cfg {Number} labelmd set the width of label (1-12)
31198 * @cfg {Number} labelsm set the width of label (1-12)
31199 * @cfg {Number} labelxs set the width of label (1-12)
31202 * Create a new DocumentManager
31203 * @param {Object} config The config object
31206 Roo.bootstrap.DocumentManager = function(config){
31207 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
31210 this.delegates = [];
31215 * Fire when initial the DocumentManager
31216 * @param {Roo.bootstrap.DocumentManager} this
31221 * inspect selected file
31222 * @param {Roo.bootstrap.DocumentManager} this
31223 * @param {File} file
31228 * Fire when xhr load exception
31229 * @param {Roo.bootstrap.DocumentManager} this
31230 * @param {XMLHttpRequest} xhr
31232 "exception" : true,
31234 * @event afterupload
31235 * Fire when xhr load exception
31236 * @param {Roo.bootstrap.DocumentManager} this
31237 * @param {XMLHttpRequest} xhr
31239 "afterupload" : true,
31242 * prepare the form data
31243 * @param {Roo.bootstrap.DocumentManager} this
31244 * @param {Object} formData
31249 * Fire when remove the file
31250 * @param {Roo.bootstrap.DocumentManager} this
31251 * @param {Object} file
31256 * Fire after refresh the file
31257 * @param {Roo.bootstrap.DocumentManager} this
31262 * Fire after click the image
31263 * @param {Roo.bootstrap.DocumentManager} this
31264 * @param {Object} file
31269 * Fire when upload a image and editable set to true
31270 * @param {Roo.bootstrap.DocumentManager} this
31271 * @param {Object} file
31275 * @event beforeselectfile
31276 * Fire before select file
31277 * @param {Roo.bootstrap.DocumentManager} this
31279 "beforeselectfile" : true,
31282 * Fire before process file
31283 * @param {Roo.bootstrap.DocumentManager} this
31284 * @param {Object} file
31288 * @event previewrendered
31289 * Fire when preview rendered
31290 * @param {Roo.bootstrap.DocumentManager} this
31291 * @param {Object} file
31293 "previewrendered" : true,
31296 "previewResize" : true
31301 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
31310 paramName : 'imageUpload',
31311 toolTipName : 'filename',
31314 labelAlign : 'left',
31324 getAutoCreate : function()
31326 var managerWidget = {
31328 cls : 'roo-document-manager',
31332 cls : 'roo-document-manager-selector',
31337 cls : 'roo-document-manager-uploader',
31341 cls : 'roo-document-manager-upload-btn',
31342 html : '<i class="fa fa-plus"></i>'
31353 cls : 'column col-md-12',
31358 if(this.fieldLabel.length){
31363 cls : 'column col-md-12',
31364 html : this.fieldLabel
31368 cls : 'column col-md-12',
31373 if(this.labelAlign == 'left'){
31378 html : this.fieldLabel
31387 if(this.labelWidth > 12){
31388 content[0].style = "width: " + this.labelWidth + 'px';
31391 if(this.labelWidth < 13 && this.labelmd == 0){
31392 this.labelmd = this.labelWidth;
31395 if(this.labellg > 0){
31396 content[0].cls += ' col-lg-' + this.labellg;
31397 content[1].cls += ' col-lg-' + (12 - this.labellg);
31400 if(this.labelmd > 0){
31401 content[0].cls += ' col-md-' + this.labelmd;
31402 content[1].cls += ' col-md-' + (12 - this.labelmd);
31405 if(this.labelsm > 0){
31406 content[0].cls += ' col-sm-' + this.labelsm;
31407 content[1].cls += ' col-sm-' + (12 - this.labelsm);
31410 if(this.labelxs > 0){
31411 content[0].cls += ' col-xs-' + this.labelxs;
31412 content[1].cls += ' col-xs-' + (12 - this.labelxs);
31420 cls : 'row clearfix',
31428 initEvents : function()
31430 this.managerEl = this.el.select('.roo-document-manager', true).first();
31431 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
31433 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
31434 this.selectorEl.hide();
31437 this.selectorEl.attr('multiple', 'multiple');
31440 this.selectorEl.on('change', this.onFileSelected, this);
31442 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
31443 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
31445 this.uploader.on('click', this.onUploaderClick, this);
31447 this.renderProgressDialog();
31451 window.addEventListener("resize", function() { _this.refresh(); } );
31453 this.fireEvent('initial', this);
31456 renderProgressDialog : function()
31460 this.progressDialog = new Roo.bootstrap.Modal({
31461 cls : 'roo-document-manager-progress-dialog',
31462 allow_close : false,
31473 btnclick : function() {
31474 _this.uploadCancel();
31480 this.progressDialog.render(Roo.get(document.body));
31482 this.progress = new Roo.bootstrap.Progress({
31483 cls : 'roo-document-manager-progress',
31488 this.progress.render(this.progressDialog.getChildContainer());
31490 this.progressBar = new Roo.bootstrap.ProgressBar({
31491 cls : 'roo-document-manager-progress-bar',
31494 aria_valuemax : 12,
31498 this.progressBar.render(this.progress.getChildContainer());
31501 onUploaderClick : function(e)
31503 e.preventDefault();
31505 if(this.fireEvent('beforeselectfile', this) != false){
31506 this.selectorEl.dom.click();
31511 onFileSelected : function(e)
31513 e.preventDefault();
31515 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
31519 Roo.each(this.selectorEl.dom.files, function(file){
31520 if(this.fireEvent('inspect', this, file) != false){
31521 this.files.push(file);
31531 this.selectorEl.dom.value = '';
31533 if(!this.files || !this.files.length){
31537 if(this.boxes > 0 && this.files.length > this.boxes){
31538 this.files = this.files.slice(0, this.boxes);
31541 this.uploader.show();
31543 if(this.boxes > 0 && this.files.length > this.boxes - 1){
31544 this.uploader.hide();
31553 Roo.each(this.files, function(file){
31555 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
31556 var f = this.renderPreview(file);
31561 if(file.type.indexOf('image') != -1){
31562 this.delegates.push(
31564 _this.process(file);
31565 }).createDelegate(this)
31573 _this.process(file);
31574 }).createDelegate(this)
31579 this.files = files;
31581 this.delegates = this.delegates.concat(docs);
31583 if(!this.delegates.length){
31588 this.progressBar.aria_valuemax = this.delegates.length;
31595 arrange : function()
31597 if(!this.delegates.length){
31598 this.progressDialog.hide();
31603 var delegate = this.delegates.shift();
31605 this.progressDialog.show();
31607 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
31609 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
31614 refresh : function()
31616 this.uploader.show();
31618 if(this.boxes > 0 && this.files.length > this.boxes - 1){
31619 this.uploader.hide();
31622 Roo.isTouch ? this.closable(false) : this.closable(true);
31624 this.fireEvent('refresh', this);
31627 onRemove : function(e, el, o)
31629 e.preventDefault();
31631 this.fireEvent('remove', this, o);
31635 remove : function(o)
31639 Roo.each(this.files, function(file){
31640 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
31649 this.files = files;
31656 Roo.each(this.files, function(file){
31661 file.target.remove();
31670 onClick : function(e, el, o)
31672 e.preventDefault();
31674 this.fireEvent('click', this, o);
31678 closable : function(closable)
31680 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
31682 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
31694 xhrOnLoad : function(xhr)
31696 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
31700 if (xhr.readyState !== 4) {
31702 this.fireEvent('exception', this, xhr);
31706 var response = Roo.decode(xhr.responseText);
31708 if(!response.success){
31710 this.fireEvent('exception', this, xhr);
31714 var file = this.renderPreview(response.data);
31716 this.files.push(file);
31720 this.fireEvent('afterupload', this, xhr);
31724 xhrOnError : function(xhr)
31726 Roo.log('xhr on error');
31728 var response = Roo.decode(xhr.responseText);
31735 process : function(file)
31737 if(this.fireEvent('process', this, file) !== false){
31738 if(this.editable && file.type.indexOf('image') != -1){
31739 this.fireEvent('edit', this, file);
31743 this.uploadStart(file, false);
31750 uploadStart : function(file, crop)
31752 this.xhr = new XMLHttpRequest();
31754 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
31759 file.xhr = this.xhr;
31761 this.managerEl.createChild({
31763 cls : 'roo-document-manager-loading',
31767 tooltip : file.name,
31768 cls : 'roo-document-manager-thumb',
31769 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
31775 this.xhr.open(this.method, this.url, true);
31778 "Accept": "application/json",
31779 "Cache-Control": "no-cache",
31780 "X-Requested-With": "XMLHttpRequest"
31783 for (var headerName in headers) {
31784 var headerValue = headers[headerName];
31786 this.xhr.setRequestHeader(headerName, headerValue);
31792 this.xhr.onload = function()
31794 _this.xhrOnLoad(_this.xhr);
31797 this.xhr.onerror = function()
31799 _this.xhrOnError(_this.xhr);
31802 var formData = new FormData();
31804 formData.append('returnHTML', 'NO');
31807 formData.append('crop', crop);
31810 formData.append(this.paramName, file, file.name);
31817 if(this.fireEvent('prepare', this, formData, options) != false){
31819 if(options.manually){
31823 this.xhr.send(formData);
31827 this.uploadCancel();
31830 uploadCancel : function()
31836 this.delegates = [];
31838 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
31845 renderPreview : function(file)
31847 if(typeof(file.target) != 'undefined' && file.target){
31851 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
31853 var previewEl = this.managerEl.createChild({
31855 cls : 'roo-document-manager-preview',
31859 tooltip : file[this.toolTipName],
31860 cls : 'roo-document-manager-thumb',
31861 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
31866 html : '<i class="fa fa-times-circle"></i>'
31871 var close = previewEl.select('button.close', true).first();
31873 close.on('click', this.onRemove, this, file);
31875 file.target = previewEl;
31877 var image = previewEl.select('img', true).first();
31881 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
31883 image.on('click', this.onClick, this, file);
31885 this.fireEvent('previewrendered', this, file);
31891 onPreviewLoad : function(file, image)
31893 if(typeof(file.target) == 'undefined' || !file.target){
31897 var width = image.dom.naturalWidth || image.dom.width;
31898 var height = image.dom.naturalHeight || image.dom.height;
31900 if(!this.previewResize) {
31904 if(width > height){
31905 file.target.addClass('wide');
31909 file.target.addClass('tall');
31914 uploadFromSource : function(file, crop)
31916 this.xhr = new XMLHttpRequest();
31918 this.managerEl.createChild({
31920 cls : 'roo-document-manager-loading',
31924 tooltip : file.name,
31925 cls : 'roo-document-manager-thumb',
31926 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
31932 this.xhr.open(this.method, this.url, true);
31935 "Accept": "application/json",
31936 "Cache-Control": "no-cache",
31937 "X-Requested-With": "XMLHttpRequest"
31940 for (var headerName in headers) {
31941 var headerValue = headers[headerName];
31943 this.xhr.setRequestHeader(headerName, headerValue);
31949 this.xhr.onload = function()
31951 _this.xhrOnLoad(_this.xhr);
31954 this.xhr.onerror = function()
31956 _this.xhrOnError(_this.xhr);
31959 var formData = new FormData();
31961 formData.append('returnHTML', 'NO');
31963 formData.append('crop', crop);
31965 if(typeof(file.filename) != 'undefined'){
31966 formData.append('filename', file.filename);
31969 if(typeof(file.mimetype) != 'undefined'){
31970 formData.append('mimetype', file.mimetype);
31975 if(this.fireEvent('prepare', this, formData) != false){
31976 this.xhr.send(formData);
31986 * @class Roo.bootstrap.DocumentViewer
31987 * @extends Roo.bootstrap.Component
31988 * Bootstrap DocumentViewer class
31989 * @cfg {Boolean} showDownload (true|false) show download button (default true)
31990 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
31993 * Create a new DocumentViewer
31994 * @param {Object} config The config object
31997 Roo.bootstrap.DocumentViewer = function(config){
31998 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
32003 * Fire after initEvent
32004 * @param {Roo.bootstrap.DocumentViewer} this
32010 * @param {Roo.bootstrap.DocumentViewer} this
32015 * Fire after download button
32016 * @param {Roo.bootstrap.DocumentViewer} this
32021 * Fire after trash button
32022 * @param {Roo.bootstrap.DocumentViewer} this
32029 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
32031 showDownload : true,
32035 getAutoCreate : function()
32039 cls : 'roo-document-viewer',
32043 cls : 'roo-document-viewer-body',
32047 cls : 'roo-document-viewer-thumb',
32051 cls : 'roo-document-viewer-image'
32059 cls : 'roo-document-viewer-footer',
32062 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
32066 cls : 'btn-group roo-document-viewer-download',
32070 cls : 'btn btn-default',
32071 html : '<i class="fa fa-download"></i>'
32077 cls : 'btn-group roo-document-viewer-trash',
32081 cls : 'btn btn-default',
32082 html : '<i class="fa fa-trash"></i>'
32095 initEvents : function()
32097 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
32098 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
32100 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
32101 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
32103 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
32104 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
32106 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
32107 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
32109 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
32110 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
32112 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
32113 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
32115 this.bodyEl.on('click', this.onClick, this);
32116 this.downloadBtn.on('click', this.onDownload, this);
32117 this.trashBtn.on('click', this.onTrash, this);
32119 this.downloadBtn.hide();
32120 this.trashBtn.hide();
32122 if(this.showDownload){
32123 this.downloadBtn.show();
32126 if(this.showTrash){
32127 this.trashBtn.show();
32130 if(!this.showDownload && !this.showTrash) {
32131 this.footerEl.hide();
32136 initial : function()
32138 this.fireEvent('initial', this);
32142 onClick : function(e)
32144 e.preventDefault();
32146 this.fireEvent('click', this);
32149 onDownload : function(e)
32151 e.preventDefault();
32153 this.fireEvent('download', this);
32156 onTrash : function(e)
32158 e.preventDefault();
32160 this.fireEvent('trash', this);
32172 * @class Roo.bootstrap.NavProgressBar
32173 * @extends Roo.bootstrap.Component
32174 * Bootstrap NavProgressBar class
32177 * Create a new nav progress bar
32178 * @param {Object} config The config object
32181 Roo.bootstrap.NavProgressBar = function(config){
32182 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
32184 this.bullets = this.bullets || [];
32186 // Roo.bootstrap.NavProgressBar.register(this);
32190 * Fires when the active item changes
32191 * @param {Roo.bootstrap.NavProgressBar} this
32192 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
32193 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
32200 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
32205 getAutoCreate : function()
32207 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
32211 cls : 'roo-navigation-bar-group',
32215 cls : 'roo-navigation-top-bar'
32219 cls : 'roo-navigation-bullets-bar',
32223 cls : 'roo-navigation-bar'
32230 cls : 'roo-navigation-bottom-bar'
32240 initEvents: function()
32245 onRender : function(ct, position)
32247 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
32249 if(this.bullets.length){
32250 Roo.each(this.bullets, function(b){
32259 addItem : function(cfg)
32261 var item = new Roo.bootstrap.NavProgressItem(cfg);
32263 item.parentId = this.id;
32264 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
32267 var top = new Roo.bootstrap.Element({
32269 cls : 'roo-navigation-bar-text'
32272 var bottom = new Roo.bootstrap.Element({
32274 cls : 'roo-navigation-bar-text'
32277 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
32278 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
32280 var topText = new Roo.bootstrap.Element({
32282 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
32285 var bottomText = new Roo.bootstrap.Element({
32287 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
32290 topText.onRender(top.el, null);
32291 bottomText.onRender(bottom.el, null);
32294 item.bottomEl = bottom;
32297 this.barItems.push(item);
32302 getActive : function()
32304 var active = false;
32306 Roo.each(this.barItems, function(v){
32308 if (!v.isActive()) {
32320 setActiveItem : function(item)
32324 Roo.each(this.barItems, function(v){
32325 if (v.rid == item.rid) {
32329 if (v.isActive()) {
32330 v.setActive(false);
32335 item.setActive(true);
32337 this.fireEvent('changed', this, item, prev);
32340 getBarItem: function(rid)
32344 Roo.each(this.barItems, function(e) {
32345 if (e.rid != rid) {
32356 indexOfItem : function(item)
32360 Roo.each(this.barItems, function(v, i){
32362 if (v.rid != item.rid) {
32373 setActiveNext : function()
32375 var i = this.indexOfItem(this.getActive());
32377 if (i > this.barItems.length) {
32381 this.setActiveItem(this.barItems[i+1]);
32384 setActivePrev : function()
32386 var i = this.indexOfItem(this.getActive());
32392 this.setActiveItem(this.barItems[i-1]);
32395 format : function()
32397 if(!this.barItems.length){
32401 var width = 100 / this.barItems.length;
32403 Roo.each(this.barItems, function(i){
32404 i.el.setStyle('width', width + '%');
32405 i.topEl.el.setStyle('width', width + '%');
32406 i.bottomEl.el.setStyle('width', width + '%');
32415 * Nav Progress Item
32420 * @class Roo.bootstrap.NavProgressItem
32421 * @extends Roo.bootstrap.Component
32422 * Bootstrap NavProgressItem class
32423 * @cfg {String} rid the reference id
32424 * @cfg {Boolean} active (true|false) Is item active default false
32425 * @cfg {Boolean} disabled (true|false) Is item active default false
32426 * @cfg {String} html
32427 * @cfg {String} position (top|bottom) text position default bottom
32428 * @cfg {String} icon show icon instead of number
32431 * Create a new NavProgressItem
32432 * @param {Object} config The config object
32434 Roo.bootstrap.NavProgressItem = function(config){
32435 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
32440 * The raw click event for the entire grid.
32441 * @param {Roo.bootstrap.NavProgressItem} this
32442 * @param {Roo.EventObject} e
32449 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
32455 position : 'bottom',
32458 getAutoCreate : function()
32460 var iconCls = 'roo-navigation-bar-item-icon';
32462 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
32466 cls: 'roo-navigation-bar-item',
32476 cfg.cls += ' active';
32479 cfg.cls += ' disabled';
32485 disable : function()
32487 this.setDisabled(true);
32490 enable : function()
32492 this.setDisabled(false);
32495 initEvents: function()
32497 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
32499 this.iconEl.on('click', this.onClick, this);
32502 onClick : function(e)
32504 e.preventDefault();
32510 if(this.fireEvent('click', this, e) === false){
32514 this.parent().setActiveItem(this);
32517 isActive: function ()
32519 return this.active;
32522 setActive : function(state)
32524 if(this.active == state){
32528 this.active = state;
32531 this.el.addClass('active');
32535 this.el.removeClass('active');
32540 setDisabled : function(state)
32542 if(this.disabled == state){
32546 this.disabled = state;
32549 this.el.addClass('disabled');
32553 this.el.removeClass('disabled');
32556 tooltipEl : function()
32558 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
32571 * @class Roo.bootstrap.FieldLabel
32572 * @extends Roo.bootstrap.Component
32573 * Bootstrap FieldLabel class
32574 * @cfg {String} html contents of the element
32575 * @cfg {String} tag tag of the element default label
32576 * @cfg {String} cls class of the element
32577 * @cfg {String} target label target
32578 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
32579 * @cfg {String} invalidClass DEPRICATED - BS4 uses is-invalid
32580 * @cfg {String} validClass DEPRICATED - BS4 uses is-valid
32581 * @cfg {String} iconTooltip default "This field is required"
32582 * @cfg {String} indicatorpos (left|right) default left
32585 * Create a new FieldLabel
32586 * @param {Object} config The config object
32589 Roo.bootstrap.FieldLabel = function(config){
32590 Roo.bootstrap.Element.superclass.constructor.call(this, config);
32595 * Fires after the field has been marked as invalid.
32596 * @param {Roo.form.FieldLabel} this
32597 * @param {String} msg The validation message
32602 * Fires after the field has been validated with no errors.
32603 * @param {Roo.form.FieldLabel} this
32609 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
32616 invalidClass : 'has-warning',
32617 validClass : 'has-success',
32618 iconTooltip : 'This field is required',
32619 indicatorpos : 'left',
32621 getAutoCreate : function(){
32624 if (!this.allowBlank) {
32630 cls : 'roo-bootstrap-field-label ' + this.cls,
32635 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star ' + cls,
32636 tooltip : this.iconTooltip
32645 if(this.indicatorpos == 'right'){
32648 cls : 'roo-bootstrap-field-label ' + this.cls,
32657 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star '+ cls,
32658 tooltip : this.iconTooltip
32667 initEvents: function()
32669 Roo.bootstrap.Element.superclass.initEvents.call(this);
32671 this.indicator = this.indicatorEl();
32673 if(this.indicator){
32674 this.indicator.removeClass('visible');
32675 this.indicator.addClass('invisible');
32678 Roo.bootstrap.FieldLabel.register(this);
32681 indicatorEl : function()
32683 var indicator = this.el.select('i.roo-required-indicator',true).first();
32694 * Mark this field as valid
32696 markValid : function()
32698 if(this.indicator){
32699 this.indicator.removeClass('visible');
32700 this.indicator.addClass('invisible');
32702 if (Roo.bootstrap.version == 3) {
32703 this.el.removeClass(this.invalidClass);
32704 this.el.addClass(this.validClass);
32706 this.el.removeClass('is-invalid');
32707 this.el.addClass('is-valid');
32711 this.fireEvent('valid', this);
32715 * Mark this field as invalid
32716 * @param {String} msg The validation message
32718 markInvalid : function(msg)
32720 if(this.indicator){
32721 this.indicator.removeClass('invisible');
32722 this.indicator.addClass('visible');
32724 if (Roo.bootstrap.version == 3) {
32725 this.el.removeClass(this.validClass);
32726 this.el.addClass(this.invalidClass);
32728 this.el.removeClass('is-valid');
32729 this.el.addClass('is-invalid');
32733 this.fireEvent('invalid', this, msg);
32739 Roo.apply(Roo.bootstrap.FieldLabel, {
32744 * register a FieldLabel Group
32745 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
32747 register : function(label)
32749 if(this.groups.hasOwnProperty(label.target)){
32753 this.groups[label.target] = label;
32757 * fetch a FieldLabel Group based on the target
32758 * @param {string} target
32759 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
32761 get: function(target) {
32762 if (typeof(this.groups[target]) == 'undefined') {
32766 return this.groups[target] ;
32775 * page DateSplitField.
32781 * @class Roo.bootstrap.DateSplitField
32782 * @extends Roo.bootstrap.Component
32783 * Bootstrap DateSplitField class
32784 * @cfg {string} fieldLabel - the label associated
32785 * @cfg {Number} labelWidth set the width of label (0-12)
32786 * @cfg {String} labelAlign (top|left)
32787 * @cfg {Boolean} dayAllowBlank (true|false) default false
32788 * @cfg {Boolean} monthAllowBlank (true|false) default false
32789 * @cfg {Boolean} yearAllowBlank (true|false) default false
32790 * @cfg {string} dayPlaceholder
32791 * @cfg {string} monthPlaceholder
32792 * @cfg {string} yearPlaceholder
32793 * @cfg {string} dayFormat default 'd'
32794 * @cfg {string} monthFormat default 'm'
32795 * @cfg {string} yearFormat default 'Y'
32796 * @cfg {Number} labellg set the width of label (1-12)
32797 * @cfg {Number} labelmd set the width of label (1-12)
32798 * @cfg {Number} labelsm set the width of label (1-12)
32799 * @cfg {Number} labelxs set the width of label (1-12)
32803 * Create a new DateSplitField
32804 * @param {Object} config The config object
32807 Roo.bootstrap.DateSplitField = function(config){
32808 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
32814 * getting the data of years
32815 * @param {Roo.bootstrap.DateSplitField} this
32816 * @param {Object} years
32821 * getting the data of days
32822 * @param {Roo.bootstrap.DateSplitField} this
32823 * @param {Object} days
32828 * Fires after the field has been marked as invalid.
32829 * @param {Roo.form.Field} this
32830 * @param {String} msg The validation message
32835 * Fires after the field has been validated with no errors.
32836 * @param {Roo.form.Field} this
32842 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
32845 labelAlign : 'top',
32847 dayAllowBlank : false,
32848 monthAllowBlank : false,
32849 yearAllowBlank : false,
32850 dayPlaceholder : '',
32851 monthPlaceholder : '',
32852 yearPlaceholder : '',
32856 isFormField : true,
32862 getAutoCreate : function()
32866 cls : 'row roo-date-split-field-group',
32871 cls : 'form-hidden-field roo-date-split-field-group-value',
32877 var labelCls = 'col-md-12';
32878 var contentCls = 'col-md-4';
32880 if(this.fieldLabel){
32884 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
32888 html : this.fieldLabel
32893 if(this.labelAlign == 'left'){
32895 if(this.labelWidth > 12){
32896 label.style = "width: " + this.labelWidth + 'px';
32899 if(this.labelWidth < 13 && this.labelmd == 0){
32900 this.labelmd = this.labelWidth;
32903 if(this.labellg > 0){
32904 labelCls = ' col-lg-' + this.labellg;
32905 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
32908 if(this.labelmd > 0){
32909 labelCls = ' col-md-' + this.labelmd;
32910 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
32913 if(this.labelsm > 0){
32914 labelCls = ' col-sm-' + this.labelsm;
32915 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
32918 if(this.labelxs > 0){
32919 labelCls = ' col-xs-' + this.labelxs;
32920 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
32924 label.cls += ' ' + labelCls;
32926 cfg.cn.push(label);
32929 Roo.each(['day', 'month', 'year'], function(t){
32932 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
32939 inputEl: function ()
32941 return this.el.select('.roo-date-split-field-group-value', true).first();
32944 onRender : function(ct, position)
32948 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
32950 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
32952 this.dayField = new Roo.bootstrap.ComboBox({
32953 allowBlank : this.dayAllowBlank,
32954 alwaysQuery : true,
32955 displayField : 'value',
32958 forceSelection : true,
32960 placeholder : this.dayPlaceholder,
32961 selectOnFocus : true,
32962 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
32963 triggerAction : 'all',
32965 valueField : 'value',
32966 store : new Roo.data.SimpleStore({
32967 data : (function() {
32969 _this.fireEvent('days', _this, days);
32972 fields : [ 'value' ]
32975 select : function (_self, record, index)
32977 _this.setValue(_this.getValue());
32982 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
32984 this.monthField = new Roo.bootstrap.MonthField({
32985 after : '<i class=\"fa fa-calendar\"></i>',
32986 allowBlank : this.monthAllowBlank,
32987 placeholder : this.monthPlaceholder,
32990 render : function (_self)
32992 this.el.select('span.input-group-addon', true).first().on('click', function(e){
32993 e.preventDefault();
32997 select : function (_self, oldvalue, newvalue)
32999 _this.setValue(_this.getValue());
33004 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
33006 this.yearField = new Roo.bootstrap.ComboBox({
33007 allowBlank : this.yearAllowBlank,
33008 alwaysQuery : true,
33009 displayField : 'value',
33012 forceSelection : true,
33014 placeholder : this.yearPlaceholder,
33015 selectOnFocus : true,
33016 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
33017 triggerAction : 'all',
33019 valueField : 'value',
33020 store : new Roo.data.SimpleStore({
33021 data : (function() {
33023 _this.fireEvent('years', _this, years);
33026 fields : [ 'value' ]
33029 select : function (_self, record, index)
33031 _this.setValue(_this.getValue());
33036 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
33039 setValue : function(v, format)
33041 this.inputEl.dom.value = v;
33043 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
33045 var d = Date.parseDate(v, f);
33052 this.setDay(d.format(this.dayFormat));
33053 this.setMonth(d.format(this.monthFormat));
33054 this.setYear(d.format(this.yearFormat));
33061 setDay : function(v)
33063 this.dayField.setValue(v);
33064 this.inputEl.dom.value = this.getValue();
33069 setMonth : function(v)
33071 this.monthField.setValue(v, true);
33072 this.inputEl.dom.value = this.getValue();
33077 setYear : function(v)
33079 this.yearField.setValue(v);
33080 this.inputEl.dom.value = this.getValue();
33085 getDay : function()
33087 return this.dayField.getValue();
33090 getMonth : function()
33092 return this.monthField.getValue();
33095 getYear : function()
33097 return this.yearField.getValue();
33100 getValue : function()
33102 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
33104 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
33114 this.inputEl.dom.value = '';
33119 validate : function()
33121 var d = this.dayField.validate();
33122 var m = this.monthField.validate();
33123 var y = this.yearField.validate();
33128 (!this.dayAllowBlank && !d) ||
33129 (!this.monthAllowBlank && !m) ||
33130 (!this.yearAllowBlank && !y)
33135 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
33144 this.markInvalid();
33149 markValid : function()
33152 var label = this.el.select('label', true).first();
33153 var icon = this.el.select('i.fa-star', true).first();
33159 this.fireEvent('valid', this);
33163 * Mark this field as invalid
33164 * @param {String} msg The validation message
33166 markInvalid : function(msg)
33169 var label = this.el.select('label', true).first();
33170 var icon = this.el.select('i.fa-star', true).first();
33172 if(label && !icon){
33173 this.el.select('.roo-date-split-field-label', true).createChild({
33175 cls : 'text-danger fa fa-lg fa-star',
33176 tooltip : 'This field is required',
33177 style : 'margin-right:5px;'
33181 this.fireEvent('invalid', this, msg);
33184 clearInvalid : function()
33186 var label = this.el.select('label', true).first();
33187 var icon = this.el.select('i.fa-star', true).first();
33193 this.fireEvent('valid', this);
33196 getName: function()
33206 * http://masonry.desandro.com
33208 * The idea is to render all the bricks based on vertical width...
33210 * The original code extends 'outlayer' - we might need to use that....
33216 * @class Roo.bootstrap.LayoutMasonry
33217 * @extends Roo.bootstrap.Component
33218 * Bootstrap Layout Masonry class
33221 * Create a new Element
33222 * @param {Object} config The config object
33225 Roo.bootstrap.LayoutMasonry = function(config){
33227 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
33231 Roo.bootstrap.LayoutMasonry.register(this);
33237 * Fire after layout the items
33238 * @param {Roo.bootstrap.LayoutMasonry} this
33239 * @param {Roo.EventObject} e
33246 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
33249 * @cfg {Boolean} isLayoutInstant = no animation?
33251 isLayoutInstant : false, // needed?
33254 * @cfg {Number} boxWidth width of the columns
33259 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
33264 * @cfg {Number} padWidth padding below box..
33269 * @cfg {Number} gutter gutter width..
33274 * @cfg {Number} maxCols maximum number of columns
33280 * @cfg {Boolean} isAutoInitial defalut true
33282 isAutoInitial : true,
33287 * @cfg {Boolean} isHorizontal defalut false
33289 isHorizontal : false,
33291 currentSize : null,
33297 bricks: null, //CompositeElement
33301 _isLayoutInited : false,
33303 // isAlternative : false, // only use for vertical layout...
33306 * @cfg {Number} alternativePadWidth padding below box..
33308 alternativePadWidth : 50,
33310 selectedBrick : [],
33312 getAutoCreate : function(){
33314 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
33318 cls: 'blog-masonary-wrapper ' + this.cls,
33320 cls : 'mas-boxes masonary'
33327 getChildContainer: function( )
33329 if (this.boxesEl) {
33330 return this.boxesEl;
33333 this.boxesEl = this.el.select('.mas-boxes').first();
33335 return this.boxesEl;
33339 initEvents : function()
33343 if(this.isAutoInitial){
33344 Roo.log('hook children rendered');
33345 this.on('childrenrendered', function() {
33346 Roo.log('children rendered');
33352 initial : function()
33354 this.selectedBrick = [];
33356 this.currentSize = this.el.getBox(true);
33358 Roo.EventManager.onWindowResize(this.resize, this);
33360 if(!this.isAutoInitial){
33368 //this.layout.defer(500,this);
33372 resize : function()
33374 var cs = this.el.getBox(true);
33377 this.currentSize.width == cs.width &&
33378 this.currentSize.x == cs.x &&
33379 this.currentSize.height == cs.height &&
33380 this.currentSize.y == cs.y
33382 Roo.log("no change in with or X or Y");
33386 this.currentSize = cs;
33392 layout : function()
33394 this._resetLayout();
33396 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
33398 this.layoutItems( isInstant );
33400 this._isLayoutInited = true;
33402 this.fireEvent('layout', this);
33406 _resetLayout : function()
33408 if(this.isHorizontal){
33409 this.horizontalMeasureColumns();
33413 this.verticalMeasureColumns();
33417 verticalMeasureColumns : function()
33419 this.getContainerWidth();
33421 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
33422 // this.colWidth = Math.floor(this.containerWidth * 0.8);
33426 var boxWidth = this.boxWidth + this.padWidth;
33428 if(this.containerWidth < this.boxWidth){
33429 boxWidth = this.containerWidth
33432 var containerWidth = this.containerWidth;
33434 var cols = Math.floor(containerWidth / boxWidth);
33436 this.cols = Math.max( cols, 1 );
33438 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
33440 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
33442 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
33444 this.colWidth = boxWidth + avail - this.padWidth;
33446 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
33447 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
33450 horizontalMeasureColumns : function()
33452 this.getContainerWidth();
33454 var boxWidth = this.boxWidth;
33456 if(this.containerWidth < boxWidth){
33457 boxWidth = this.containerWidth;
33460 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
33462 this.el.setHeight(boxWidth);
33466 getContainerWidth : function()
33468 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
33471 layoutItems : function( isInstant )
33473 Roo.log(this.bricks);
33475 var items = Roo.apply([], this.bricks);
33477 if(this.isHorizontal){
33478 this._horizontalLayoutItems( items , isInstant );
33482 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
33483 // this._verticalAlternativeLayoutItems( items , isInstant );
33487 this._verticalLayoutItems( items , isInstant );
33491 _verticalLayoutItems : function ( items , isInstant)
33493 if ( !items || !items.length ) {
33498 ['xs', 'xs', 'xs', 'tall'],
33499 ['xs', 'xs', 'tall'],
33500 ['xs', 'xs', 'sm'],
33501 ['xs', 'xs', 'xs'],
33507 ['sm', 'xs', 'xs'],
33511 ['tall', 'xs', 'xs', 'xs'],
33512 ['tall', 'xs', 'xs'],
33524 Roo.each(items, function(item, k){
33526 switch (item.size) {
33527 // these layouts take up a full box,
33538 boxes.push([item]);
33561 var filterPattern = function(box, length)
33569 var pattern = box.slice(0, length);
33573 Roo.each(pattern, function(i){
33574 format.push(i.size);
33577 Roo.each(standard, function(s){
33579 if(String(s) != String(format)){
33588 if(!match && length == 1){
33593 filterPattern(box, length - 1);
33597 queue.push(pattern);
33599 box = box.slice(length, box.length);
33601 filterPattern(box, 4);
33607 Roo.each(boxes, function(box, k){
33613 if(box.length == 1){
33618 filterPattern(box, 4);
33622 this._processVerticalLayoutQueue( queue, isInstant );
33626 // _verticalAlternativeLayoutItems : function( items , isInstant )
33628 // if ( !items || !items.length ) {
33632 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
33636 _horizontalLayoutItems : function ( items , isInstant)
33638 if ( !items || !items.length || items.length < 3) {
33644 var eItems = items.slice(0, 3);
33646 items = items.slice(3, items.length);
33649 ['xs', 'xs', 'xs', 'wide'],
33650 ['xs', 'xs', 'wide'],
33651 ['xs', 'xs', 'sm'],
33652 ['xs', 'xs', 'xs'],
33658 ['sm', 'xs', 'xs'],
33662 ['wide', 'xs', 'xs', 'xs'],
33663 ['wide', 'xs', 'xs'],
33676 Roo.each(items, function(item, k){
33678 switch (item.size) {
33689 boxes.push([item]);
33713 var filterPattern = function(box, length)
33721 var pattern = box.slice(0, length);
33725 Roo.each(pattern, function(i){
33726 format.push(i.size);
33729 Roo.each(standard, function(s){
33731 if(String(s) != String(format)){
33740 if(!match && length == 1){
33745 filterPattern(box, length - 1);
33749 queue.push(pattern);
33751 box = box.slice(length, box.length);
33753 filterPattern(box, 4);
33759 Roo.each(boxes, function(box, k){
33765 if(box.length == 1){
33770 filterPattern(box, 4);
33777 var pos = this.el.getBox(true);
33781 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
33783 var hit_end = false;
33785 Roo.each(queue, function(box){
33789 Roo.each(box, function(b){
33791 b.el.setVisibilityMode(Roo.Element.DISPLAY);
33801 Roo.each(box, function(b){
33803 b.el.setVisibilityMode(Roo.Element.DISPLAY);
33806 mx = Math.max(mx, b.x);
33810 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
33814 Roo.each(box, function(b){
33816 b.el.setVisibilityMode(Roo.Element.DISPLAY);
33830 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
33833 /** Sets position of item in DOM
33834 * @param {Element} item
33835 * @param {Number} x - horizontal position
33836 * @param {Number} y - vertical position
33837 * @param {Boolean} isInstant - disables transitions
33839 _processVerticalLayoutQueue : function( queue, isInstant )
33841 var pos = this.el.getBox(true);
33846 for (var i = 0; i < this.cols; i++){
33850 Roo.each(queue, function(box, k){
33852 var col = k % this.cols;
33854 Roo.each(box, function(b,kk){
33856 b.el.position('absolute');
33858 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
33859 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
33861 if(b.size == 'md-left' || b.size == 'md-right'){
33862 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
33863 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
33866 b.el.setWidth(width);
33867 b.el.setHeight(height);
33869 b.el.select('iframe',true).setSize(width,height);
33873 for (var i = 0; i < this.cols; i++){
33875 if(maxY[i] < maxY[col]){
33880 col = Math.min(col, i);
33884 x = pos.x + col * (this.colWidth + this.padWidth);
33888 var positions = [];
33890 switch (box.length){
33892 positions = this.getVerticalOneBoxColPositions(x, y, box);
33895 positions = this.getVerticalTwoBoxColPositions(x, y, box);
33898 positions = this.getVerticalThreeBoxColPositions(x, y, box);
33901 positions = this.getVerticalFourBoxColPositions(x, y, box);
33907 Roo.each(box, function(b,kk){
33909 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
33911 var sz = b.el.getSize();
33913 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
33921 for (var i = 0; i < this.cols; i++){
33922 mY = Math.max(mY, maxY[i]);
33925 this.el.setHeight(mY - pos.y);
33929 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
33931 // var pos = this.el.getBox(true);
33934 // var maxX = pos.right;
33936 // var maxHeight = 0;
33938 // Roo.each(items, function(item, k){
33942 // item.el.position('absolute');
33944 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
33946 // item.el.setWidth(width);
33948 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
33950 // item.el.setHeight(height);
33953 // item.el.setXY([x, y], isInstant ? false : true);
33955 // item.el.setXY([maxX - width, y], isInstant ? false : true);
33958 // y = y + height + this.alternativePadWidth;
33960 // maxHeight = maxHeight + height + this.alternativePadWidth;
33964 // this.el.setHeight(maxHeight);
33968 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
33970 var pos = this.el.getBox(true);
33975 var maxX = pos.right;
33977 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
33979 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
33981 Roo.each(queue, function(box, k){
33983 Roo.each(box, function(b, kk){
33985 b.el.position('absolute');
33987 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
33988 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
33990 if(b.size == 'md-left' || b.size == 'md-right'){
33991 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
33992 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
33995 b.el.setWidth(width);
33996 b.el.setHeight(height);
34004 var positions = [];
34006 switch (box.length){
34008 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
34011 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
34014 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
34017 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
34023 Roo.each(box, function(b,kk){
34025 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
34027 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
34035 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
34037 Roo.each(eItems, function(b,k){
34039 b.size = (k == 0) ? 'sm' : 'xs';
34040 b.x = (k == 0) ? 2 : 1;
34041 b.y = (k == 0) ? 2 : 1;
34043 b.el.position('absolute');
34045 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
34047 b.el.setWidth(width);
34049 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
34051 b.el.setHeight(height);
34055 var positions = [];
34058 x : maxX - this.unitWidth * 2 - this.gutter,
34063 x : maxX - this.unitWidth,
34064 y : minY + (this.unitWidth + this.gutter) * 2
34068 x : maxX - this.unitWidth * 3 - this.gutter * 2,
34072 Roo.each(eItems, function(b,k){
34074 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
34080 getVerticalOneBoxColPositions : function(x, y, box)
34084 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
34086 if(box[0].size == 'md-left'){
34090 if(box[0].size == 'md-right'){
34095 x : x + (this.unitWidth + this.gutter) * rand,
34102 getVerticalTwoBoxColPositions : function(x, y, box)
34106 if(box[0].size == 'xs'){
34110 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
34114 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
34128 x : x + (this.unitWidth + this.gutter) * 2,
34129 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
34136 getVerticalThreeBoxColPositions : function(x, y, box)
34140 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
34148 x : x + (this.unitWidth + this.gutter) * 1,
34153 x : x + (this.unitWidth + this.gutter) * 2,
34161 if(box[0].size == 'xs' && box[1].size == 'xs'){
34170 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
34174 x : x + (this.unitWidth + this.gutter) * 1,
34188 x : x + (this.unitWidth + this.gutter) * 2,
34193 x : x + (this.unitWidth + this.gutter) * 2,
34194 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
34201 getVerticalFourBoxColPositions : function(x, y, box)
34205 if(box[0].size == 'xs'){
34214 y : y + (this.unitHeight + this.gutter) * 1
34219 y : y + (this.unitHeight + this.gutter) * 2
34223 x : x + (this.unitWidth + this.gutter) * 1,
34237 x : x + (this.unitWidth + this.gutter) * 2,
34242 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
34243 y : y + (this.unitHeight + this.gutter) * 1
34247 x : x + (this.unitWidth + this.gutter) * 2,
34248 y : y + (this.unitWidth + this.gutter) * 2
34255 getHorizontalOneBoxColPositions : function(maxX, minY, box)
34259 if(box[0].size == 'md-left'){
34261 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
34268 if(box[0].size == 'md-right'){
34270 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
34271 y : minY + (this.unitWidth + this.gutter) * 1
34277 var rand = Math.floor(Math.random() * (4 - box[0].y));
34280 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
34281 y : minY + (this.unitWidth + this.gutter) * rand
34288 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
34292 if(box[0].size == 'xs'){
34295 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
34300 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
34301 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
34309 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
34314 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
34315 y : minY + (this.unitWidth + this.gutter) * 2
34322 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
34326 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
34329 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
34334 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
34335 y : minY + (this.unitWidth + this.gutter) * 1
34339 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
34340 y : minY + (this.unitWidth + this.gutter) * 2
34347 if(box[0].size == 'xs' && box[1].size == 'xs'){
34350 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
34355 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
34360 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
34361 y : minY + (this.unitWidth + this.gutter) * 1
34369 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
34374 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
34375 y : minY + (this.unitWidth + this.gutter) * 2
34379 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
34380 y : minY + (this.unitWidth + this.gutter) * 2
34387 getHorizontalFourBoxColPositions : function(maxX, minY, box)
34391 if(box[0].size == 'xs'){
34394 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
34399 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
34404 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),
34409 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
34410 y : minY + (this.unitWidth + this.gutter) * 1
34418 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
34423 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
34424 y : minY + (this.unitWidth + this.gutter) * 2
34428 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
34429 y : minY + (this.unitWidth + this.gutter) * 2
34433 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),
34434 y : minY + (this.unitWidth + this.gutter) * 2
34442 * remove a Masonry Brick
34443 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
34445 removeBrick : function(brick_id)
34451 for (var i = 0; i<this.bricks.length; i++) {
34452 if (this.bricks[i].id == brick_id) {
34453 this.bricks.splice(i,1);
34454 this.el.dom.removeChild(Roo.get(brick_id).dom);
34461 * adds a Masonry Brick
34462 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
34464 addBrick : function(cfg)
34466 var cn = new Roo.bootstrap.MasonryBrick(cfg);
34467 //this.register(cn);
34468 cn.parentId = this.id;
34469 cn.render(this.el);
34474 * register a Masonry Brick
34475 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
34478 register : function(brick)
34480 this.bricks.push(brick);
34481 brick.masonryId = this.id;
34485 * clear all the Masonry Brick
34487 clearAll : function()
34490 //this.getChildContainer().dom.innerHTML = "";
34491 this.el.dom.innerHTML = '';
34494 getSelected : function()
34496 if (!this.selectedBrick) {
34500 return this.selectedBrick;
34504 Roo.apply(Roo.bootstrap.LayoutMasonry, {
34508 * register a Masonry Layout
34509 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
34512 register : function(layout)
34514 this.groups[layout.id] = layout;
34517 * fetch a Masonry Layout based on the masonry layout ID
34518 * @param {string} the masonry layout to add
34519 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
34522 get: function(layout_id) {
34523 if (typeof(this.groups[layout_id]) == 'undefined') {
34526 return this.groups[layout_id] ;
34538 * http://masonry.desandro.com
34540 * The idea is to render all the bricks based on vertical width...
34542 * The original code extends 'outlayer' - we might need to use that....
34548 * @class Roo.bootstrap.LayoutMasonryAuto
34549 * @extends Roo.bootstrap.Component
34550 * Bootstrap Layout Masonry class
34553 * Create a new Element
34554 * @param {Object} config The config object
34557 Roo.bootstrap.LayoutMasonryAuto = function(config){
34558 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
34561 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
34564 * @cfg {Boolean} isFitWidth - resize the width..
34566 isFitWidth : false, // options..
34568 * @cfg {Boolean} isOriginLeft = left align?
34570 isOriginLeft : true,
34572 * @cfg {Boolean} isOriginTop = top align?
34574 isOriginTop : false,
34576 * @cfg {Boolean} isLayoutInstant = no animation?
34578 isLayoutInstant : false, // needed?
34580 * @cfg {Boolean} isResizingContainer = not sure if this is used..
34582 isResizingContainer : true,
34584 * @cfg {Number} columnWidth width of the columns
34590 * @cfg {Number} maxCols maximum number of columns
34595 * @cfg {Number} padHeight padding below box..
34601 * @cfg {Boolean} isAutoInitial defalut true
34604 isAutoInitial : true,
34610 initialColumnWidth : 0,
34611 currentSize : null,
34613 colYs : null, // array.
34620 bricks: null, //CompositeElement
34621 cols : 0, // array?
34622 // element : null, // wrapped now this.el
34623 _isLayoutInited : null,
34626 getAutoCreate : function(){
34630 cls: 'blog-masonary-wrapper ' + this.cls,
34632 cls : 'mas-boxes masonary'
34639 getChildContainer: function( )
34641 if (this.boxesEl) {
34642 return this.boxesEl;
34645 this.boxesEl = this.el.select('.mas-boxes').first();
34647 return this.boxesEl;
34651 initEvents : function()
34655 if(this.isAutoInitial){
34656 Roo.log('hook children rendered');
34657 this.on('childrenrendered', function() {
34658 Roo.log('children rendered');
34665 initial : function()
34667 this.reloadItems();
34669 this.currentSize = this.el.getBox(true);
34671 /// was window resize... - let's see if this works..
34672 Roo.EventManager.onWindowResize(this.resize, this);
34674 if(!this.isAutoInitial){
34679 this.layout.defer(500,this);
34682 reloadItems: function()
34684 this.bricks = this.el.select('.masonry-brick', true);
34686 this.bricks.each(function(b) {
34687 //Roo.log(b.getSize());
34688 if (!b.attr('originalwidth')) {
34689 b.attr('originalwidth', b.getSize().width);
34694 Roo.log(this.bricks.elements.length);
34697 resize : function()
34700 var cs = this.el.getBox(true);
34702 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
34703 Roo.log("no change in with or X");
34706 this.currentSize = cs;
34710 layout : function()
34713 this._resetLayout();
34714 //this._manageStamps();
34716 // don't animate first layout
34717 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
34718 this.layoutItems( isInstant );
34720 // flag for initalized
34721 this._isLayoutInited = true;
34724 layoutItems : function( isInstant )
34726 //var items = this._getItemsForLayout( this.items );
34727 // original code supports filtering layout items.. we just ignore it..
34729 this._layoutItems( this.bricks , isInstant );
34731 this._postLayout();
34733 _layoutItems : function ( items , isInstant)
34735 //this.fireEvent( 'layout', this, items );
34738 if ( !items || !items.elements.length ) {
34739 // no items, emit event with empty array
34744 items.each(function(item) {
34745 Roo.log("layout item");
34747 // get x/y object from method
34748 var position = this._getItemLayoutPosition( item );
34750 position.item = item;
34751 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
34752 queue.push( position );
34755 this._processLayoutQueue( queue );
34757 /** Sets position of item in DOM
34758 * @param {Element} item
34759 * @param {Number} x - horizontal position
34760 * @param {Number} y - vertical position
34761 * @param {Boolean} isInstant - disables transitions
34763 _processLayoutQueue : function( queue )
34765 for ( var i=0, len = queue.length; i < len; i++ ) {
34766 var obj = queue[i];
34767 obj.item.position('absolute');
34768 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
34774 * Any logic you want to do after each layout,
34775 * i.e. size the container
34777 _postLayout : function()
34779 this.resizeContainer();
34782 resizeContainer : function()
34784 if ( !this.isResizingContainer ) {
34787 var size = this._getContainerSize();
34789 this.el.setSize(size.width,size.height);
34790 this.boxesEl.setSize(size.width,size.height);
34796 _resetLayout : function()
34798 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
34799 this.colWidth = this.el.getWidth();
34800 //this.gutter = this.el.getWidth();
34802 this.measureColumns();
34808 this.colYs.push( 0 );
34814 measureColumns : function()
34816 this.getContainerWidth();
34817 // if columnWidth is 0, default to outerWidth of first item
34818 if ( !this.columnWidth ) {
34819 var firstItem = this.bricks.first();
34820 Roo.log(firstItem);
34821 this.columnWidth = this.containerWidth;
34822 if (firstItem && firstItem.attr('originalwidth') ) {
34823 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
34825 // columnWidth fall back to item of first element
34826 Roo.log("set column width?");
34827 this.initialColumnWidth = this.columnWidth ;
34829 // if first elem has no width, default to size of container
34834 if (this.initialColumnWidth) {
34835 this.columnWidth = this.initialColumnWidth;
34840 // column width is fixed at the top - however if container width get's smaller we should
34843 // this bit calcs how man columns..
34845 var columnWidth = this.columnWidth += this.gutter;
34847 // calculate columns
34848 var containerWidth = this.containerWidth + this.gutter;
34850 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
34851 // fix rounding errors, typically with gutters
34852 var excess = columnWidth - containerWidth % columnWidth;
34855 // if overshoot is less than a pixel, round up, otherwise floor it
34856 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
34857 cols = Math[ mathMethod ]( cols );
34858 this.cols = Math.max( cols, 1 );
34859 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
34861 // padding positioning..
34862 var totalColWidth = this.cols * this.columnWidth;
34863 var padavail = this.containerWidth - totalColWidth;
34864 // so for 2 columns - we need 3 'pads'
34866 var padNeeded = (1+this.cols) * this.padWidth;
34868 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
34870 this.columnWidth += padExtra
34871 //this.padWidth = Math.floor(padavail / ( this.cols));
34873 // adjust colum width so that padding is fixed??
34875 // we have 3 columns ... total = width * 3
34876 // we have X left over... that should be used by
34878 //if (this.expandC) {
34886 getContainerWidth : function()
34888 /* // container is parent if fit width
34889 var container = this.isFitWidth ? this.element.parentNode : this.element;
34890 // check that this.size and size are there
34891 // IE8 triggers resize on body size change, so they might not be
34893 var size = getSize( container ); //FIXME
34894 this.containerWidth = size && size.innerWidth; //FIXME
34897 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
34901 _getItemLayoutPosition : function( item ) // what is item?
34903 // we resize the item to our columnWidth..
34905 item.setWidth(this.columnWidth);
34906 item.autoBoxAdjust = false;
34908 var sz = item.getSize();
34910 // how many columns does this brick span
34911 var remainder = this.containerWidth % this.columnWidth;
34913 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
34914 // round if off by 1 pixel, otherwise use ceil
34915 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
34916 colSpan = Math.min( colSpan, this.cols );
34918 // normally this should be '1' as we dont' currently allow multi width columns..
34920 var colGroup = this._getColGroup( colSpan );
34921 // get the minimum Y value from the columns
34922 var minimumY = Math.min.apply( Math, colGroup );
34923 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
34925 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
34927 // position the brick
34929 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
34930 y: this.currentSize.y + minimumY + this.padHeight
34934 // apply setHeight to necessary columns
34935 var setHeight = minimumY + sz.height + this.padHeight;
34936 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
34938 var setSpan = this.cols + 1 - colGroup.length;
34939 for ( var i = 0; i < setSpan; i++ ) {
34940 this.colYs[ shortColIndex + i ] = setHeight ;
34947 * @param {Number} colSpan - number of columns the element spans
34948 * @returns {Array} colGroup
34950 _getColGroup : function( colSpan )
34952 if ( colSpan < 2 ) {
34953 // if brick spans only one column, use all the column Ys
34958 // how many different places could this brick fit horizontally
34959 var groupCount = this.cols + 1 - colSpan;
34960 // for each group potential horizontal position
34961 for ( var i = 0; i < groupCount; i++ ) {
34962 // make an array of colY values for that one group
34963 var groupColYs = this.colYs.slice( i, i + colSpan );
34964 // and get the max value of the array
34965 colGroup[i] = Math.max.apply( Math, groupColYs );
34970 _manageStamp : function( stamp )
34972 var stampSize = stamp.getSize();
34973 var offset = stamp.getBox();
34974 // get the columns that this stamp affects
34975 var firstX = this.isOriginLeft ? offset.x : offset.right;
34976 var lastX = firstX + stampSize.width;
34977 var firstCol = Math.floor( firstX / this.columnWidth );
34978 firstCol = Math.max( 0, firstCol );
34980 var lastCol = Math.floor( lastX / this.columnWidth );
34981 // lastCol should not go over if multiple of columnWidth #425
34982 lastCol -= lastX % this.columnWidth ? 0 : 1;
34983 lastCol = Math.min( this.cols - 1, lastCol );
34985 // set colYs to bottom of the stamp
34986 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
34989 for ( var i = firstCol; i <= lastCol; i++ ) {
34990 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
34995 _getContainerSize : function()
34997 this.maxY = Math.max.apply( Math, this.colYs );
35002 if ( this.isFitWidth ) {
35003 size.width = this._getContainerFitWidth();
35009 _getContainerFitWidth : function()
35011 var unusedCols = 0;
35012 // count unused columns
35015 if ( this.colYs[i] !== 0 ) {
35020 // fit container to columns that have been used
35021 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
35024 needsResizeLayout : function()
35026 var previousWidth = this.containerWidth;
35027 this.getContainerWidth();
35028 return previousWidth !== this.containerWidth;
35043 * @class Roo.bootstrap.MasonryBrick
35044 * @extends Roo.bootstrap.Component
35045 * Bootstrap MasonryBrick class
35048 * Create a new MasonryBrick
35049 * @param {Object} config The config object
35052 Roo.bootstrap.MasonryBrick = function(config){
35054 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
35056 Roo.bootstrap.MasonryBrick.register(this);
35062 * When a MasonryBrick is clcik
35063 * @param {Roo.bootstrap.MasonryBrick} this
35064 * @param {Roo.EventObject} e
35070 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
35073 * @cfg {String} title
35077 * @cfg {String} html
35081 * @cfg {String} bgimage
35085 * @cfg {String} videourl
35089 * @cfg {String} cls
35093 * @cfg {String} href
35097 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
35102 * @cfg {String} placetitle (center|bottom)
35107 * @cfg {Boolean} isFitContainer defalut true
35109 isFitContainer : true,
35112 * @cfg {Boolean} preventDefault defalut false
35114 preventDefault : false,
35117 * @cfg {Boolean} inverse defalut false
35119 maskInverse : false,
35121 getAutoCreate : function()
35123 if(!this.isFitContainer){
35124 return this.getSplitAutoCreate();
35127 var cls = 'masonry-brick masonry-brick-full';
35129 if(this.href.length){
35130 cls += ' masonry-brick-link';
35133 if(this.bgimage.length){
35134 cls += ' masonry-brick-image';
35137 if(this.maskInverse){
35138 cls += ' mask-inverse';
35141 if(!this.html.length && !this.maskInverse && !this.videourl.length){
35142 cls += ' enable-mask';
35146 cls += ' masonry-' + this.size + '-brick';
35149 if(this.placetitle.length){
35151 switch (this.placetitle) {
35153 cls += ' masonry-center-title';
35156 cls += ' masonry-bottom-title';
35163 if(!this.html.length && !this.bgimage.length){
35164 cls += ' masonry-center-title';
35167 if(!this.html.length && this.bgimage.length){
35168 cls += ' masonry-bottom-title';
35173 cls += ' ' + this.cls;
35177 tag: (this.href.length) ? 'a' : 'div',
35182 cls: 'masonry-brick-mask'
35186 cls: 'masonry-brick-paragraph',
35192 if(this.href.length){
35193 cfg.href = this.href;
35196 var cn = cfg.cn[1].cn;
35198 if(this.title.length){
35201 cls: 'masonry-brick-title',
35206 if(this.html.length){
35209 cls: 'masonry-brick-text',
35214 if (!this.title.length && !this.html.length) {
35215 cfg.cn[1].cls += ' hide';
35218 if(this.bgimage.length){
35221 cls: 'masonry-brick-image-view',
35226 if(this.videourl.length){
35227 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
35228 // youtube support only?
35231 cls: 'masonry-brick-image-view',
35234 allowfullscreen : true
35242 getSplitAutoCreate : function()
35244 var cls = 'masonry-brick masonry-brick-split';
35246 if(this.href.length){
35247 cls += ' masonry-brick-link';
35250 if(this.bgimage.length){
35251 cls += ' masonry-brick-image';
35255 cls += ' masonry-' + this.size + '-brick';
35258 switch (this.placetitle) {
35260 cls += ' masonry-center-title';
35263 cls += ' masonry-bottom-title';
35266 if(!this.bgimage.length){
35267 cls += ' masonry-center-title';
35270 if(this.bgimage.length){
35271 cls += ' masonry-bottom-title';
35277 cls += ' ' + this.cls;
35281 tag: (this.href.length) ? 'a' : 'div',
35286 cls: 'masonry-brick-split-head',
35290 cls: 'masonry-brick-paragraph',
35297 cls: 'masonry-brick-split-body',
35303 if(this.href.length){
35304 cfg.href = this.href;
35307 if(this.title.length){
35308 cfg.cn[0].cn[0].cn.push({
35310 cls: 'masonry-brick-title',
35315 if(this.html.length){
35316 cfg.cn[1].cn.push({
35318 cls: 'masonry-brick-text',
35323 if(this.bgimage.length){
35324 cfg.cn[0].cn.push({
35326 cls: 'masonry-brick-image-view',
35331 if(this.videourl.length){
35332 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
35333 // youtube support only?
35334 cfg.cn[0].cn.cn.push({
35336 cls: 'masonry-brick-image-view',
35339 allowfullscreen : true
35346 initEvents: function()
35348 switch (this.size) {
35381 this.el.on('touchstart', this.onTouchStart, this);
35382 this.el.on('touchmove', this.onTouchMove, this);
35383 this.el.on('touchend', this.onTouchEnd, this);
35384 this.el.on('contextmenu', this.onContextMenu, this);
35386 this.el.on('mouseenter' ,this.enter, this);
35387 this.el.on('mouseleave', this.leave, this);
35388 this.el.on('click', this.onClick, this);
35391 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
35392 this.parent().bricks.push(this);
35397 onClick: function(e, el)
35399 var time = this.endTimer - this.startTimer;
35400 // Roo.log(e.preventDefault());
35403 e.preventDefault();
35408 if(!this.preventDefault){
35412 e.preventDefault();
35414 if (this.activeClass != '') {
35415 this.selectBrick();
35418 this.fireEvent('click', this, e);
35421 enter: function(e, el)
35423 e.preventDefault();
35425 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
35429 if(this.bgimage.length && this.html.length){
35430 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
35434 leave: function(e, el)
35436 e.preventDefault();
35438 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
35442 if(this.bgimage.length && this.html.length){
35443 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
35447 onTouchStart: function(e, el)
35449 // e.preventDefault();
35451 this.touchmoved = false;
35453 if(!this.isFitContainer){
35457 if(!this.bgimage.length || !this.html.length){
35461 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
35463 this.timer = new Date().getTime();
35467 onTouchMove: function(e, el)
35469 this.touchmoved = true;
35472 onContextMenu : function(e,el)
35474 e.preventDefault();
35475 e.stopPropagation();
35479 onTouchEnd: function(e, el)
35481 // e.preventDefault();
35483 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
35490 if(!this.bgimage.length || !this.html.length){
35492 if(this.href.length){
35493 window.location.href = this.href;
35499 if(!this.isFitContainer){
35503 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
35505 window.location.href = this.href;
35508 //selection on single brick only
35509 selectBrick : function() {
35511 if (!this.parentId) {
35515 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
35516 var index = m.selectedBrick.indexOf(this.id);
35519 m.selectedBrick.splice(index,1);
35520 this.el.removeClass(this.activeClass);
35524 for(var i = 0; i < m.selectedBrick.length; i++) {
35525 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
35526 b.el.removeClass(b.activeClass);
35529 m.selectedBrick = [];
35531 m.selectedBrick.push(this.id);
35532 this.el.addClass(this.activeClass);
35536 isSelected : function(){
35537 return this.el.hasClass(this.activeClass);
35542 Roo.apply(Roo.bootstrap.MasonryBrick, {
35545 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
35547 * register a Masonry Brick
35548 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
35551 register : function(brick)
35553 //this.groups[brick.id] = brick;
35554 this.groups.add(brick.id, brick);
35557 * fetch a masonry brick based on the masonry brick ID
35558 * @param {string} the masonry brick to add
35559 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
35562 get: function(brick_id)
35564 // if (typeof(this.groups[brick_id]) == 'undefined') {
35567 // return this.groups[brick_id] ;
35569 if(this.groups.key(brick_id)) {
35570 return this.groups.key(brick_id);
35588 * @class Roo.bootstrap.Brick
35589 * @extends Roo.bootstrap.Component
35590 * Bootstrap Brick class
35593 * Create a new Brick
35594 * @param {Object} config The config object
35597 Roo.bootstrap.Brick = function(config){
35598 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
35604 * When a Brick is click
35605 * @param {Roo.bootstrap.Brick} this
35606 * @param {Roo.EventObject} e
35612 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
35615 * @cfg {String} title
35619 * @cfg {String} html
35623 * @cfg {String} bgimage
35627 * @cfg {String} cls
35631 * @cfg {String} href
35635 * @cfg {String} video
35639 * @cfg {Boolean} square
35643 getAutoCreate : function()
35645 var cls = 'roo-brick';
35647 if(this.href.length){
35648 cls += ' roo-brick-link';
35651 if(this.bgimage.length){
35652 cls += ' roo-brick-image';
35655 if(!this.html.length && !this.bgimage.length){
35656 cls += ' roo-brick-center-title';
35659 if(!this.html.length && this.bgimage.length){
35660 cls += ' roo-brick-bottom-title';
35664 cls += ' ' + this.cls;
35668 tag: (this.href.length) ? 'a' : 'div',
35673 cls: 'roo-brick-paragraph',
35679 if(this.href.length){
35680 cfg.href = this.href;
35683 var cn = cfg.cn[0].cn;
35685 if(this.title.length){
35688 cls: 'roo-brick-title',
35693 if(this.html.length){
35696 cls: 'roo-brick-text',
35703 if(this.bgimage.length){
35706 cls: 'roo-brick-image-view',
35714 initEvents: function()
35716 if(this.title.length || this.html.length){
35717 this.el.on('mouseenter' ,this.enter, this);
35718 this.el.on('mouseleave', this.leave, this);
35721 Roo.EventManager.onWindowResize(this.resize, this);
35723 if(this.bgimage.length){
35724 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
35725 this.imageEl.on('load', this.onImageLoad, this);
35732 onImageLoad : function()
35737 resize : function()
35739 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
35741 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
35743 if(this.bgimage.length){
35744 var image = this.el.select('.roo-brick-image-view', true).first();
35746 image.setWidth(paragraph.getWidth());
35749 image.setHeight(paragraph.getWidth());
35752 this.el.setHeight(image.getHeight());
35753 paragraph.setHeight(image.getHeight());
35759 enter: function(e, el)
35761 e.preventDefault();
35763 if(this.bgimage.length){
35764 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
35765 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
35769 leave: function(e, el)
35771 e.preventDefault();
35773 if(this.bgimage.length){
35774 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
35775 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
35790 * @class Roo.bootstrap.NumberField
35791 * @extends Roo.bootstrap.Input
35792 * Bootstrap NumberField class
35798 * Create a new NumberField
35799 * @param {Object} config The config object
35802 Roo.bootstrap.NumberField = function(config){
35803 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
35806 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
35809 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
35811 allowDecimals : true,
35813 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
35815 decimalSeparator : ".",
35817 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
35819 decimalPrecision : 2,
35821 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
35823 allowNegative : true,
35826 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
35830 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
35832 minValue : Number.NEGATIVE_INFINITY,
35834 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
35836 maxValue : Number.MAX_VALUE,
35838 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
35840 minText : "The minimum value for this field is {0}",
35842 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
35844 maxText : "The maximum value for this field is {0}",
35846 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
35847 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
35849 nanText : "{0} is not a valid number",
35851 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
35853 thousandsDelimiter : false,
35855 * @cfg {String} valueAlign alignment of value
35857 valueAlign : "left",
35859 getAutoCreate : function()
35861 var hiddenInput = {
35865 cls: 'hidden-number-input'
35869 hiddenInput.name = this.name;
35874 var cfg = Roo.bootstrap.NumberField.superclass.getAutoCreate.call(this);
35876 this.name = hiddenInput.name;
35878 if(cfg.cn.length > 0) {
35879 cfg.cn.push(hiddenInput);
35886 initEvents : function()
35888 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
35890 var allowed = "0123456789";
35892 if(this.allowDecimals){
35893 allowed += this.decimalSeparator;
35896 if(this.allowNegative){
35900 if(this.thousandsDelimiter) {
35904 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
35906 var keyPress = function(e){
35908 var k = e.getKey();
35910 var c = e.getCharCode();
35913 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
35914 allowed.indexOf(String.fromCharCode(c)) === -1
35920 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
35924 if(allowed.indexOf(String.fromCharCode(c)) === -1){
35929 this.el.on("keypress", keyPress, this);
35932 validateValue : function(value)
35935 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
35939 var num = this.parseValue(value);
35942 this.markInvalid(String.format(this.nanText, value));
35946 if(num < this.minValue){
35947 this.markInvalid(String.format(this.minText, this.minValue));
35951 if(num > this.maxValue){
35952 this.markInvalid(String.format(this.maxText, this.maxValue));
35959 getValue : function()
35961 var v = this.hiddenEl().getValue();
35963 return this.fixPrecision(this.parseValue(v));
35966 parseValue : function(value)
35968 if(this.thousandsDelimiter) {
35970 r = new RegExp(",", "g");
35971 value = value.replace(r, "");
35974 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
35975 return isNaN(value) ? '' : value;
35978 fixPrecision : function(value)
35980 if(this.thousandsDelimiter) {
35982 r = new RegExp(",", "g");
35983 value = value.replace(r, "");
35986 var nan = isNaN(value);
35988 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
35989 return nan ? '' : value;
35991 return parseFloat(value).toFixed(this.decimalPrecision);
35994 setValue : function(v)
35996 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
36002 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
36004 this.inputEl().dom.value = (v == '') ? '' :
36005 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
36007 if(!this.allowZero && v === '0') {
36008 this.hiddenEl().dom.value = '';
36009 this.inputEl().dom.value = '';
36016 decimalPrecisionFcn : function(v)
36018 return Math.floor(v);
36021 beforeBlur : function()
36023 var v = this.parseValue(this.getRawValue());
36025 if(v || v === 0 || v === ''){
36030 hiddenEl : function()
36032 return this.el.select('input.hidden-number-input',true).first();
36044 * @class Roo.bootstrap.DocumentSlider
36045 * @extends Roo.bootstrap.Component
36046 * Bootstrap DocumentSlider class
36049 * Create a new DocumentViewer
36050 * @param {Object} config The config object
36053 Roo.bootstrap.DocumentSlider = function(config){
36054 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
36061 * Fire after initEvent
36062 * @param {Roo.bootstrap.DocumentSlider} this
36067 * Fire after update
36068 * @param {Roo.bootstrap.DocumentSlider} this
36074 * @param {Roo.bootstrap.DocumentSlider} this
36080 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
36086 getAutoCreate : function()
36090 cls : 'roo-document-slider',
36094 cls : 'roo-document-slider-header',
36098 cls : 'roo-document-slider-header-title'
36104 cls : 'roo-document-slider-body',
36108 cls : 'roo-document-slider-prev',
36112 cls : 'fa fa-chevron-left'
36118 cls : 'roo-document-slider-thumb',
36122 cls : 'roo-document-slider-image'
36128 cls : 'roo-document-slider-next',
36132 cls : 'fa fa-chevron-right'
36144 initEvents : function()
36146 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
36147 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
36149 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
36150 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
36152 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
36153 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
36155 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
36156 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
36158 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
36159 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
36161 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
36162 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
36164 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
36165 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
36167 this.thumbEl.on('click', this.onClick, this);
36169 this.prevIndicator.on('click', this.prev, this);
36171 this.nextIndicator.on('click', this.next, this);
36175 initial : function()
36177 if(this.files.length){
36178 this.indicator = 1;
36182 this.fireEvent('initial', this);
36185 update : function()
36187 this.imageEl.attr('src', this.files[this.indicator - 1]);
36189 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
36191 this.prevIndicator.show();
36193 if(this.indicator == 1){
36194 this.prevIndicator.hide();
36197 this.nextIndicator.show();
36199 if(this.indicator == this.files.length){
36200 this.nextIndicator.hide();
36203 this.thumbEl.scrollTo('top');
36205 this.fireEvent('update', this);
36208 onClick : function(e)
36210 e.preventDefault();
36212 this.fireEvent('click', this);
36217 e.preventDefault();
36219 this.indicator = Math.max(1, this.indicator - 1);
36226 e.preventDefault();
36228 this.indicator = Math.min(this.files.length, this.indicator + 1);
36242 * @class Roo.bootstrap.RadioSet
36243 * @extends Roo.bootstrap.Input
36244 * Bootstrap RadioSet class
36245 * @cfg {String} indicatorpos (left|right) default left
36246 * @cfg {Boolean} inline (true|false) inline the element (default true)
36247 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
36249 * Create a new RadioSet
36250 * @param {Object} config The config object
36253 Roo.bootstrap.RadioSet = function(config){
36255 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
36259 Roo.bootstrap.RadioSet.register(this);
36264 * Fires when the element is checked or unchecked.
36265 * @param {Roo.bootstrap.RadioSet} this This radio
36266 * @param {Roo.bootstrap.Radio} item The checked item
36271 * Fires when the element is click.
36272 * @param {Roo.bootstrap.RadioSet} this This radio set
36273 * @param {Roo.bootstrap.Radio} item The checked item
36274 * @param {Roo.EventObject} e The event object
36281 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
36289 indicatorpos : 'left',
36291 getAutoCreate : function()
36295 cls : 'roo-radio-set-label',
36299 html : this.fieldLabel
36303 if (Roo.bootstrap.version == 3) {
36306 if(this.indicatorpos == 'left'){
36309 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
36310 tooltip : 'This field is required'
36315 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
36316 tooltip : 'This field is required'
36322 cls : 'roo-radio-set-items'
36325 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
36327 if (align === 'left' && this.fieldLabel.length) {
36330 cls : "roo-radio-set-right",
36336 if(this.labelWidth > 12){
36337 label.style = "width: " + this.labelWidth + 'px';
36340 if(this.labelWidth < 13 && this.labelmd == 0){
36341 this.labelmd = this.labelWidth;
36344 if(this.labellg > 0){
36345 label.cls += ' col-lg-' + this.labellg;
36346 items.cls += ' col-lg-' + (12 - this.labellg);
36349 if(this.labelmd > 0){
36350 label.cls += ' col-md-' + this.labelmd;
36351 items.cls += ' col-md-' + (12 - this.labelmd);
36354 if(this.labelsm > 0){
36355 label.cls += ' col-sm-' + this.labelsm;
36356 items.cls += ' col-sm-' + (12 - this.labelsm);
36359 if(this.labelxs > 0){
36360 label.cls += ' col-xs-' + this.labelxs;
36361 items.cls += ' col-xs-' + (12 - this.labelxs);
36367 cls : 'roo-radio-set',
36371 cls : 'roo-radio-set-input',
36374 value : this.value ? this.value : ''
36381 if(this.weight.length){
36382 cfg.cls += ' roo-radio-' + this.weight;
36386 cfg.cls += ' roo-radio-set-inline';
36390 ['xs','sm','md','lg'].map(function(size){
36391 if (settings[size]) {
36392 cfg.cls += ' col-' + size + '-' + settings[size];
36400 initEvents : function()
36402 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
36403 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
36405 if(!this.fieldLabel.length){
36406 this.labelEl.hide();
36409 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
36410 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
36412 this.indicator = this.indicatorEl();
36414 if(this.indicator){
36415 this.indicator.addClass('invisible');
36418 this.originalValue = this.getValue();
36422 inputEl: function ()
36424 return this.el.select('.roo-radio-set-input', true).first();
36427 getChildContainer : function()
36429 return this.itemsEl;
36432 register : function(item)
36434 this.radioes.push(item);
36438 validate : function()
36440 if(this.getVisibilityEl().hasClass('hidden')){
36446 Roo.each(this.radioes, function(i){
36455 if(this.allowBlank) {
36459 if(this.disabled || valid){
36464 this.markInvalid();
36469 markValid : function()
36471 if(this.labelEl.isVisible(true) && this.indicatorEl()){
36472 this.indicatorEl().removeClass('visible');
36473 this.indicatorEl().addClass('invisible');
36477 if (Roo.bootstrap.version == 3) {
36478 this.el.removeClass([this.invalidClass, this.validClass]);
36479 this.el.addClass(this.validClass);
36481 this.el.removeClass(['is-invalid','is-valid']);
36482 this.el.addClass(['is-valid']);
36484 this.fireEvent('valid', this);
36487 markInvalid : function(msg)
36489 if(this.allowBlank || this.disabled){
36493 if(this.labelEl.isVisible(true) && this.indicatorEl()){
36494 this.indicatorEl().removeClass('invisible');
36495 this.indicatorEl().addClass('visible');
36497 if (Roo.bootstrap.version == 3) {
36498 this.el.removeClass([this.invalidClass, this.validClass]);
36499 this.el.addClass(this.invalidClass);
36501 this.el.removeClass(['is-invalid','is-valid']);
36502 this.el.addClass(['is-invalid']);
36505 this.fireEvent('invalid', this, msg);
36509 setValue : function(v, suppressEvent)
36511 if(this.value === v){
36518 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
36521 Roo.each(this.radioes, function(i){
36523 i.el.removeClass('checked');
36526 Roo.each(this.radioes, function(i){
36528 if(i.value === v || i.value.toString() === v.toString()){
36530 i.el.addClass('checked');
36532 if(suppressEvent !== true){
36533 this.fireEvent('check', this, i);
36544 clearInvalid : function(){
36546 if(!this.el || this.preventMark){
36550 this.el.removeClass([this.invalidClass]);
36552 this.fireEvent('valid', this);
36557 Roo.apply(Roo.bootstrap.RadioSet, {
36561 register : function(set)
36563 this.groups[set.name] = set;
36566 get: function(name)
36568 if (typeof(this.groups[name]) == 'undefined') {
36572 return this.groups[name] ;
36578 * Ext JS Library 1.1.1
36579 * Copyright(c) 2006-2007, Ext JS, LLC.
36581 * Originally Released Under LGPL - original licence link has changed is not relivant.
36584 * <script type="text/javascript">
36589 * @class Roo.bootstrap.SplitBar
36590 * @extends Roo.util.Observable
36591 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
36595 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
36596 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
36597 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
36598 split.minSize = 100;
36599 split.maxSize = 600;
36600 split.animate = true;
36601 split.on('moved', splitterMoved);
36604 * Create a new SplitBar
36605 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
36606 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
36607 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
36608 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
36609 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
36610 position of the SplitBar).
36612 Roo.bootstrap.SplitBar = function(cfg){
36617 // dragElement : elm
36618 // resizingElement: el,
36620 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
36621 // placement : Roo.bootstrap.SplitBar.LEFT ,
36622 // existingProxy ???
36625 this.el = Roo.get(cfg.dragElement, true);
36626 this.el.dom.unselectable = "on";
36628 this.resizingEl = Roo.get(cfg.resizingElement, true);
36632 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
36633 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
36636 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
36639 * The minimum size of the resizing element. (Defaults to 0)
36645 * The maximum size of the resizing element. (Defaults to 2000)
36648 this.maxSize = 2000;
36651 * Whether to animate the transition to the new size
36654 this.animate = false;
36657 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
36660 this.useShim = false;
36665 if(!cfg.existingProxy){
36667 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
36669 this.proxy = Roo.get(cfg.existingProxy).dom;
36672 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
36675 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
36678 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
36681 this.dragSpecs = {};
36684 * @private The adapter to use to positon and resize elements
36686 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
36687 this.adapter.init(this);
36689 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
36691 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
36692 this.el.addClass("roo-splitbar-h");
36695 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
36696 this.el.addClass("roo-splitbar-v");
36702 * Fires when the splitter is moved (alias for {@link #event-moved})
36703 * @param {Roo.bootstrap.SplitBar} this
36704 * @param {Number} newSize the new width or height
36709 * Fires when the splitter is moved
36710 * @param {Roo.bootstrap.SplitBar} this
36711 * @param {Number} newSize the new width or height
36715 * @event beforeresize
36716 * Fires before the splitter is dragged
36717 * @param {Roo.bootstrap.SplitBar} this
36719 "beforeresize" : true,
36721 "beforeapply" : true
36724 Roo.util.Observable.call(this);
36727 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
36728 onStartProxyDrag : function(x, y){
36729 this.fireEvent("beforeresize", this);
36731 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
36733 o.enableDisplayMode("block");
36734 // all splitbars share the same overlay
36735 Roo.bootstrap.SplitBar.prototype.overlay = o;
36737 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
36738 this.overlay.show();
36739 Roo.get(this.proxy).setDisplayed("block");
36740 var size = this.adapter.getElementSize(this);
36741 this.activeMinSize = this.getMinimumSize();;
36742 this.activeMaxSize = this.getMaximumSize();;
36743 var c1 = size - this.activeMinSize;
36744 var c2 = Math.max(this.activeMaxSize - size, 0);
36745 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
36746 this.dd.resetConstraints();
36747 this.dd.setXConstraint(
36748 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
36749 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
36751 this.dd.setYConstraint(0, 0);
36753 this.dd.resetConstraints();
36754 this.dd.setXConstraint(0, 0);
36755 this.dd.setYConstraint(
36756 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
36757 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
36760 this.dragSpecs.startSize = size;
36761 this.dragSpecs.startPoint = [x, y];
36762 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
36766 * @private Called after the drag operation by the DDProxy
36768 onEndProxyDrag : function(e){
36769 Roo.get(this.proxy).setDisplayed(false);
36770 var endPoint = Roo.lib.Event.getXY(e);
36772 this.overlay.hide();
36775 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
36776 newSize = this.dragSpecs.startSize +
36777 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
36778 endPoint[0] - this.dragSpecs.startPoint[0] :
36779 this.dragSpecs.startPoint[0] - endPoint[0]
36782 newSize = this.dragSpecs.startSize +
36783 (this.placement == Roo.bootstrap.SplitBar.TOP ?
36784 endPoint[1] - this.dragSpecs.startPoint[1] :
36785 this.dragSpecs.startPoint[1] - endPoint[1]
36788 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
36789 if(newSize != this.dragSpecs.startSize){
36790 if(this.fireEvent('beforeapply', this, newSize) !== false){
36791 this.adapter.setElementSize(this, newSize);
36792 this.fireEvent("moved", this, newSize);
36793 this.fireEvent("resize", this, newSize);
36799 * Get the adapter this SplitBar uses
36800 * @return The adapter object
36802 getAdapter : function(){
36803 return this.adapter;
36807 * Set the adapter this SplitBar uses
36808 * @param {Object} adapter A SplitBar adapter object
36810 setAdapter : function(adapter){
36811 this.adapter = adapter;
36812 this.adapter.init(this);
36816 * Gets the minimum size for the resizing element
36817 * @return {Number} The minimum size
36819 getMinimumSize : function(){
36820 return this.minSize;
36824 * Sets the minimum size for the resizing element
36825 * @param {Number} minSize The minimum size
36827 setMinimumSize : function(minSize){
36828 this.minSize = minSize;
36832 * Gets the maximum size for the resizing element
36833 * @return {Number} The maximum size
36835 getMaximumSize : function(){
36836 return this.maxSize;
36840 * Sets the maximum size for the resizing element
36841 * @param {Number} maxSize The maximum size
36843 setMaximumSize : function(maxSize){
36844 this.maxSize = maxSize;
36848 * Sets the initialize size for the resizing element
36849 * @param {Number} size The initial size
36851 setCurrentSize : function(size){
36852 var oldAnimate = this.animate;
36853 this.animate = false;
36854 this.adapter.setElementSize(this, size);
36855 this.animate = oldAnimate;
36859 * Destroy this splitbar.
36860 * @param {Boolean} removeEl True to remove the element
36862 destroy : function(removeEl){
36864 this.shim.remove();
36867 this.proxy.parentNode.removeChild(this.proxy);
36875 * @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.
36877 Roo.bootstrap.SplitBar.createProxy = function(dir){
36878 var proxy = new Roo.Element(document.createElement("div"));
36879 proxy.unselectable();
36880 var cls = 'roo-splitbar-proxy';
36881 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
36882 document.body.appendChild(proxy.dom);
36887 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
36888 * Default Adapter. It assumes the splitter and resizing element are not positioned
36889 * elements and only gets/sets the width of the element. Generally used for table based layouts.
36891 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
36894 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
36895 // do nothing for now
36896 init : function(s){
36900 * Called before drag operations to get the current size of the resizing element.
36901 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
36903 getElementSize : function(s){
36904 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
36905 return s.resizingEl.getWidth();
36907 return s.resizingEl.getHeight();
36912 * Called after drag operations to set the size of the resizing element.
36913 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
36914 * @param {Number} newSize The new size to set
36915 * @param {Function} onComplete A function to be invoked when resizing is complete
36917 setElementSize : function(s, newSize, onComplete){
36918 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
36920 s.resizingEl.setWidth(newSize);
36922 onComplete(s, newSize);
36925 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
36930 s.resizingEl.setHeight(newSize);
36932 onComplete(s, newSize);
36935 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
36942 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
36943 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
36944 * Adapter that moves the splitter element to align with the resized sizing element.
36945 * Used with an absolute positioned SplitBar.
36946 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
36947 * document.body, make sure you assign an id to the body element.
36949 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
36950 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
36951 this.container = Roo.get(container);
36954 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
36955 init : function(s){
36956 this.basic.init(s);
36959 getElementSize : function(s){
36960 return this.basic.getElementSize(s);
36963 setElementSize : function(s, newSize, onComplete){
36964 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
36967 moveSplitter : function(s){
36968 var yes = Roo.bootstrap.SplitBar;
36969 switch(s.placement){
36971 s.el.setX(s.resizingEl.getRight());
36974 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
36977 s.el.setY(s.resizingEl.getBottom());
36980 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
36987 * Orientation constant - Create a vertical SplitBar
36991 Roo.bootstrap.SplitBar.VERTICAL = 1;
36994 * Orientation constant - Create a horizontal SplitBar
36998 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
37001 * Placement constant - The resizing element is to the left of the splitter element
37005 Roo.bootstrap.SplitBar.LEFT = 1;
37008 * Placement constant - The resizing element is to the right of the splitter element
37012 Roo.bootstrap.SplitBar.RIGHT = 2;
37015 * Placement constant - The resizing element is positioned above the splitter element
37019 Roo.bootstrap.SplitBar.TOP = 3;
37022 * Placement constant - The resizing element is positioned under splitter element
37026 Roo.bootstrap.SplitBar.BOTTOM = 4;
37027 Roo.namespace("Roo.bootstrap.layout");/*
37029 * Ext JS Library 1.1.1
37030 * Copyright(c) 2006-2007, Ext JS, LLC.
37032 * Originally Released Under LGPL - original licence link has changed is not relivant.
37035 * <script type="text/javascript">
37039 * @class Roo.bootstrap.layout.Manager
37040 * @extends Roo.bootstrap.Component
37041 * Base class for layout managers.
37043 Roo.bootstrap.layout.Manager = function(config)
37045 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
37051 /** false to disable window resize monitoring @type Boolean */
37052 this.monitorWindowResize = true;
37057 * Fires when a layout is performed.
37058 * @param {Roo.LayoutManager} this
37062 * @event regionresized
37063 * Fires when the user resizes a region.
37064 * @param {Roo.LayoutRegion} region The resized region
37065 * @param {Number} newSize The new size (width for east/west, height for north/south)
37067 "regionresized" : true,
37069 * @event regioncollapsed
37070 * Fires when a region is collapsed.
37071 * @param {Roo.LayoutRegion} region The collapsed region
37073 "regioncollapsed" : true,
37075 * @event regionexpanded
37076 * Fires when a region is expanded.
37077 * @param {Roo.LayoutRegion} region The expanded region
37079 "regionexpanded" : true
37081 this.updating = false;
37084 this.el = Roo.get(config.el);
37090 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
37095 monitorWindowResize : true,
37101 onRender : function(ct, position)
37104 this.el = Roo.get(ct);
37107 //this.fireEvent('render',this);
37111 initEvents: function()
37115 // ie scrollbar fix
37116 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
37117 document.body.scroll = "no";
37118 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
37119 this.el.position('relative');
37121 this.id = this.el.id;
37122 this.el.addClass("roo-layout-container");
37123 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
37124 if(this.el.dom != document.body ) {
37125 this.el.on('resize', this.layout,this);
37126 this.el.on('show', this.layout,this);
37132 * Returns true if this layout is currently being updated
37133 * @return {Boolean}
37135 isUpdating : function(){
37136 return this.updating;
37140 * Suspend the LayoutManager from doing auto-layouts while
37141 * making multiple add or remove calls
37143 beginUpdate : function(){
37144 this.updating = true;
37148 * Restore auto-layouts and optionally disable the manager from performing a layout
37149 * @param {Boolean} noLayout true to disable a layout update
37151 endUpdate : function(noLayout){
37152 this.updating = false;
37158 layout: function(){
37162 onRegionResized : function(region, newSize){
37163 this.fireEvent("regionresized", region, newSize);
37167 onRegionCollapsed : function(region){
37168 this.fireEvent("regioncollapsed", region);
37171 onRegionExpanded : function(region){
37172 this.fireEvent("regionexpanded", region);
37176 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
37177 * performs box-model adjustments.
37178 * @return {Object} The size as an object {width: (the width), height: (the height)}
37180 getViewSize : function()
37183 if(this.el.dom != document.body){
37184 size = this.el.getSize();
37186 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
37188 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
37189 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
37194 * Returns the Element this layout is bound to.
37195 * @return {Roo.Element}
37197 getEl : function(){
37202 * Returns the specified region.
37203 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
37204 * @return {Roo.LayoutRegion}
37206 getRegion : function(target){
37207 return this.regions[target.toLowerCase()];
37210 onWindowResize : function(){
37211 if(this.monitorWindowResize){
37218 * Ext JS Library 1.1.1
37219 * Copyright(c) 2006-2007, Ext JS, LLC.
37221 * Originally Released Under LGPL - original licence link has changed is not relivant.
37224 * <script type="text/javascript">
37227 * @class Roo.bootstrap.layout.Border
37228 * @extends Roo.bootstrap.layout.Manager
37229 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
37230 * please see: examples/bootstrap/nested.html<br><br>
37232 <b>The container the layout is rendered into can be either the body element or any other element.
37233 If it is not the body element, the container needs to either be an absolute positioned element,
37234 or you will need to add "position:relative" to the css of the container. You will also need to specify
37235 the container size if it is not the body element.</b>
37238 * Create a new Border
37239 * @param {Object} config Configuration options
37241 Roo.bootstrap.layout.Border = function(config){
37242 config = config || {};
37243 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
37247 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
37248 if(config[region]){
37249 config[region].region = region;
37250 this.addRegion(config[region]);
37256 Roo.bootstrap.layout.Border.regions = ["north","south","east","west","center"];
37258 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
37260 parent : false, // this might point to a 'nest' or a ???
37263 * Creates and adds a new region if it doesn't already exist.
37264 * @param {String} target The target region key (north, south, east, west or center).
37265 * @param {Object} config The regions config object
37266 * @return {BorderLayoutRegion} The new region
37268 addRegion : function(config)
37270 if(!this.regions[config.region]){
37271 var r = this.factory(config);
37272 this.bindRegion(r);
37274 return this.regions[config.region];
37278 bindRegion : function(r){
37279 this.regions[r.config.region] = r;
37281 r.on("visibilitychange", this.layout, this);
37282 r.on("paneladded", this.layout, this);
37283 r.on("panelremoved", this.layout, this);
37284 r.on("invalidated", this.layout, this);
37285 r.on("resized", this.onRegionResized, this);
37286 r.on("collapsed", this.onRegionCollapsed, this);
37287 r.on("expanded", this.onRegionExpanded, this);
37291 * Performs a layout update.
37293 layout : function()
37295 if(this.updating) {
37299 // render all the rebions if they have not been done alreayd?
37300 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
37301 if(this.regions[region] && !this.regions[region].bodyEl){
37302 this.regions[region].onRender(this.el)
37306 var size = this.getViewSize();
37307 var w = size.width;
37308 var h = size.height;
37313 //var x = 0, y = 0;
37315 var rs = this.regions;
37316 var north = rs["north"];
37317 var south = rs["south"];
37318 var west = rs["west"];
37319 var east = rs["east"];
37320 var center = rs["center"];
37321 //if(this.hideOnLayout){ // not supported anymore
37322 //c.el.setStyle("display", "none");
37324 if(north && north.isVisible()){
37325 var b = north.getBox();
37326 var m = north.getMargins();
37327 b.width = w - (m.left+m.right);
37330 centerY = b.height + b.y + m.bottom;
37331 centerH -= centerY;
37332 north.updateBox(this.safeBox(b));
37334 if(south && south.isVisible()){
37335 var b = south.getBox();
37336 var m = south.getMargins();
37337 b.width = w - (m.left+m.right);
37339 var totalHeight = (b.height + m.top + m.bottom);
37340 b.y = h - totalHeight + m.top;
37341 centerH -= totalHeight;
37342 south.updateBox(this.safeBox(b));
37344 if(west && west.isVisible()){
37345 var b = west.getBox();
37346 var m = west.getMargins();
37347 b.height = centerH - (m.top+m.bottom);
37349 b.y = centerY + m.top;
37350 var totalWidth = (b.width + m.left + m.right);
37351 centerX += totalWidth;
37352 centerW -= totalWidth;
37353 west.updateBox(this.safeBox(b));
37355 if(east && east.isVisible()){
37356 var b = east.getBox();
37357 var m = east.getMargins();
37358 b.height = centerH - (m.top+m.bottom);
37359 var totalWidth = (b.width + m.left + m.right);
37360 b.x = w - totalWidth + m.left;
37361 b.y = centerY + m.top;
37362 centerW -= totalWidth;
37363 east.updateBox(this.safeBox(b));
37366 var m = center.getMargins();
37368 x: centerX + m.left,
37369 y: centerY + m.top,
37370 width: centerW - (m.left+m.right),
37371 height: centerH - (m.top+m.bottom)
37373 //if(this.hideOnLayout){
37374 //center.el.setStyle("display", "block");
37376 center.updateBox(this.safeBox(centerBox));
37379 this.fireEvent("layout", this);
37383 safeBox : function(box){
37384 box.width = Math.max(0, box.width);
37385 box.height = Math.max(0, box.height);
37390 * Adds a ContentPanel (or subclass) to this layout.
37391 * @param {String} target The target region key (north, south, east, west or center).
37392 * @param {Roo.ContentPanel} panel The panel to add
37393 * @return {Roo.ContentPanel} The added panel
37395 add : function(target, panel){
37397 target = target.toLowerCase();
37398 return this.regions[target].add(panel);
37402 * Remove a ContentPanel (or subclass) to this layout.
37403 * @param {String} target The target region key (north, south, east, west or center).
37404 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
37405 * @return {Roo.ContentPanel} The removed panel
37407 remove : function(target, panel){
37408 target = target.toLowerCase();
37409 return this.regions[target].remove(panel);
37413 * Searches all regions for a panel with the specified id
37414 * @param {String} panelId
37415 * @return {Roo.ContentPanel} The panel or null if it wasn't found
37417 findPanel : function(panelId){
37418 var rs = this.regions;
37419 for(var target in rs){
37420 if(typeof rs[target] != "function"){
37421 var p = rs[target].getPanel(panelId);
37431 * Searches all regions for a panel with the specified id and activates (shows) it.
37432 * @param {String/ContentPanel} panelId The panels id or the panel itself
37433 * @return {Roo.ContentPanel} The shown panel or null
37435 showPanel : function(panelId) {
37436 var rs = this.regions;
37437 for(var target in rs){
37438 var r = rs[target];
37439 if(typeof r != "function"){
37440 if(r.hasPanel(panelId)){
37441 return r.showPanel(panelId);
37449 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
37450 * @param {Roo.state.Provider} provider (optional) An alternate state provider
37453 restoreState : function(provider){
37455 provider = Roo.state.Manager;
37457 var sm = new Roo.LayoutStateManager();
37458 sm.init(this, provider);
37464 * Adds a xtype elements to the layout.
37468 xtype : 'ContentPanel',
37475 xtype : 'NestedLayoutPanel',
37481 items : [ ... list of content panels or nested layout panels.. ]
37485 * @param {Object} cfg Xtype definition of item to add.
37487 addxtype : function(cfg)
37489 // basically accepts a pannel...
37490 // can accept a layout region..!?!?
37491 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
37494 // theory? children can only be panels??
37496 //if (!cfg.xtype.match(/Panel$/)) {
37501 if (typeof(cfg.region) == 'undefined') {
37502 Roo.log("Failed to add Panel, region was not set");
37506 var region = cfg.region;
37512 xitems = cfg.items;
37517 if ( region == 'center') {
37518 Roo.log("Center: " + cfg.title);
37524 case 'Content': // ContentPanel (el, cfg)
37525 case 'Scroll': // ContentPanel (el, cfg)
37527 cfg.autoCreate = cfg.autoCreate || true;
37528 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
37530 // var el = this.el.createChild();
37531 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
37534 this.add(region, ret);
37538 case 'TreePanel': // our new panel!
37539 cfg.el = this.el.createChild();
37540 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
37541 this.add(region, ret);
37546 // create a new Layout (which is a Border Layout...
37548 var clayout = cfg.layout;
37549 clayout.el = this.el.createChild();
37550 clayout.items = clayout.items || [];
37554 // replace this exitems with the clayout ones..
37555 xitems = clayout.items;
37557 // force background off if it's in center...
37558 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
37559 cfg.background = false;
37561 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
37564 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
37565 //console.log('adding nested layout panel ' + cfg.toSource());
37566 this.add(region, ret);
37567 nb = {}; /// find first...
37572 // needs grid and region
37574 //var el = this.getRegion(region).el.createChild();
37576 *var el = this.el.createChild();
37577 // create the grid first...
37578 cfg.grid.container = el;
37579 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
37582 if (region == 'center' && this.active ) {
37583 cfg.background = false;
37586 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
37588 this.add(region, ret);
37590 if (cfg.background) {
37591 // render grid on panel activation (if panel background)
37592 ret.on('activate', function(gp) {
37593 if (!gp.grid.rendered) {
37594 // gp.grid.render(el);
37598 // cfg.grid.render(el);
37604 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
37605 // it was the old xcomponent building that caused this before.
37606 // espeically if border is the top element in the tree.
37616 if (typeof(Roo[cfg.xtype]) != 'undefined') {
37618 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
37619 this.add(region, ret);
37623 throw "Can not add '" + cfg.xtype + "' to Border";
37629 this.beginUpdate();
37633 Roo.each(xitems, function(i) {
37634 region = nb && i.region ? i.region : false;
37636 var add = ret.addxtype(i);
37639 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
37640 if (!i.background) {
37641 abn[region] = nb[region] ;
37648 // make the last non-background panel active..
37649 //if (nb) { Roo.log(abn); }
37652 for(var r in abn) {
37653 region = this.getRegion(r);
37655 // tried using nb[r], but it does not work..
37657 region.showPanel(abn[r]);
37668 factory : function(cfg)
37671 var validRegions = Roo.bootstrap.layout.Border.regions;
37673 var target = cfg.region;
37676 var r = Roo.bootstrap.layout;
37680 return new r.North(cfg);
37682 return new r.South(cfg);
37684 return new r.East(cfg);
37686 return new r.West(cfg);
37688 return new r.Center(cfg);
37690 throw 'Layout region "'+target+'" not supported.';
37697 * Ext JS Library 1.1.1
37698 * Copyright(c) 2006-2007, Ext JS, LLC.
37700 * Originally Released Under LGPL - original licence link has changed is not relivant.
37703 * <script type="text/javascript">
37707 * @class Roo.bootstrap.layout.Basic
37708 * @extends Roo.util.Observable
37709 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
37710 * and does not have a titlebar, tabs or any other features. All it does is size and position
37711 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
37712 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
37713 * @cfg {string} region the region that it inhabits..
37714 * @cfg {bool} skipConfig skip config?
37718 Roo.bootstrap.layout.Basic = function(config){
37720 this.mgr = config.mgr;
37722 this.position = config.region;
37724 var skipConfig = config.skipConfig;
37728 * @scope Roo.BasicLayoutRegion
37732 * @event beforeremove
37733 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
37734 * @param {Roo.LayoutRegion} this
37735 * @param {Roo.ContentPanel} panel The panel
37736 * @param {Object} e The cancel event object
37738 "beforeremove" : true,
37740 * @event invalidated
37741 * Fires when the layout for this region is changed.
37742 * @param {Roo.LayoutRegion} this
37744 "invalidated" : true,
37746 * @event visibilitychange
37747 * Fires when this region is shown or hidden
37748 * @param {Roo.LayoutRegion} this
37749 * @param {Boolean} visibility true or false
37751 "visibilitychange" : true,
37753 * @event paneladded
37754 * Fires when a panel is added.
37755 * @param {Roo.LayoutRegion} this
37756 * @param {Roo.ContentPanel} panel The panel
37758 "paneladded" : true,
37760 * @event panelremoved
37761 * Fires when a panel is removed.
37762 * @param {Roo.LayoutRegion} this
37763 * @param {Roo.ContentPanel} panel The panel
37765 "panelremoved" : true,
37767 * @event beforecollapse
37768 * Fires when this region before collapse.
37769 * @param {Roo.LayoutRegion} this
37771 "beforecollapse" : true,
37774 * Fires when this region is collapsed.
37775 * @param {Roo.LayoutRegion} this
37777 "collapsed" : true,
37780 * Fires when this region is expanded.
37781 * @param {Roo.LayoutRegion} this
37786 * Fires when this region is slid into view.
37787 * @param {Roo.LayoutRegion} this
37789 "slideshow" : true,
37792 * Fires when this region slides out of view.
37793 * @param {Roo.LayoutRegion} this
37795 "slidehide" : true,
37797 * @event panelactivated
37798 * Fires when a panel is activated.
37799 * @param {Roo.LayoutRegion} this
37800 * @param {Roo.ContentPanel} panel The activated panel
37802 "panelactivated" : true,
37805 * Fires when the user resizes this region.
37806 * @param {Roo.LayoutRegion} this
37807 * @param {Number} newSize The new size (width for east/west, height for north/south)
37811 /** A collection of panels in this region. @type Roo.util.MixedCollection */
37812 this.panels = new Roo.util.MixedCollection();
37813 this.panels.getKey = this.getPanelId.createDelegate(this);
37815 this.activePanel = null;
37816 // ensure listeners are added...
37818 if (config.listeners || config.events) {
37819 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
37820 listeners : config.listeners || {},
37821 events : config.events || {}
37825 if(skipConfig !== true){
37826 this.applyConfig(config);
37830 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
37832 getPanelId : function(p){
37836 applyConfig : function(config){
37837 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
37838 this.config = config;
37843 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
37844 * the width, for horizontal (north, south) the height.
37845 * @param {Number} newSize The new width or height
37847 resizeTo : function(newSize){
37848 var el = this.el ? this.el :
37849 (this.activePanel ? this.activePanel.getEl() : null);
37851 switch(this.position){
37854 el.setWidth(newSize);
37855 this.fireEvent("resized", this, newSize);
37859 el.setHeight(newSize);
37860 this.fireEvent("resized", this, newSize);
37866 getBox : function(){
37867 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
37870 getMargins : function(){
37871 return this.margins;
37874 updateBox : function(box){
37876 var el = this.activePanel.getEl();
37877 el.dom.style.left = box.x + "px";
37878 el.dom.style.top = box.y + "px";
37879 this.activePanel.setSize(box.width, box.height);
37883 * Returns the container element for this region.
37884 * @return {Roo.Element}
37886 getEl : function(){
37887 return this.activePanel;
37891 * Returns true if this region is currently visible.
37892 * @return {Boolean}
37894 isVisible : function(){
37895 return this.activePanel ? true : false;
37898 setActivePanel : function(panel){
37899 panel = this.getPanel(panel);
37900 if(this.activePanel && this.activePanel != panel){
37901 this.activePanel.setActiveState(false);
37902 this.activePanel.getEl().setLeftTop(-10000,-10000);
37904 this.activePanel = panel;
37905 panel.setActiveState(true);
37907 panel.setSize(this.box.width, this.box.height);
37909 this.fireEvent("panelactivated", this, panel);
37910 this.fireEvent("invalidated");
37914 * Show the specified panel.
37915 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
37916 * @return {Roo.ContentPanel} The shown panel or null
37918 showPanel : function(panel){
37919 panel = this.getPanel(panel);
37921 this.setActivePanel(panel);
37927 * Get the active panel for this region.
37928 * @return {Roo.ContentPanel} The active panel or null
37930 getActivePanel : function(){
37931 return this.activePanel;
37935 * Add the passed ContentPanel(s)
37936 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
37937 * @return {Roo.ContentPanel} The panel added (if only one was added)
37939 add : function(panel){
37940 if(arguments.length > 1){
37941 for(var i = 0, len = arguments.length; i < len; i++) {
37942 this.add(arguments[i]);
37946 if(this.hasPanel(panel)){
37947 this.showPanel(panel);
37950 var el = panel.getEl();
37951 if(el.dom.parentNode != this.mgr.el.dom){
37952 this.mgr.el.dom.appendChild(el.dom);
37954 if(panel.setRegion){
37955 panel.setRegion(this);
37957 this.panels.add(panel);
37958 el.setStyle("position", "absolute");
37959 if(!panel.background){
37960 this.setActivePanel(panel);
37961 if(this.config.initialSize && this.panels.getCount()==1){
37962 this.resizeTo(this.config.initialSize);
37965 this.fireEvent("paneladded", this, panel);
37970 * Returns true if the panel is in this region.
37971 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
37972 * @return {Boolean}
37974 hasPanel : function(panel){
37975 if(typeof panel == "object"){ // must be panel obj
37976 panel = panel.getId();
37978 return this.getPanel(panel) ? true : false;
37982 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
37983 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
37984 * @param {Boolean} preservePanel Overrides the config preservePanel option
37985 * @return {Roo.ContentPanel} The panel that was removed
37987 remove : function(panel, preservePanel){
37988 panel = this.getPanel(panel);
37993 this.fireEvent("beforeremove", this, panel, e);
37994 if(e.cancel === true){
37997 var panelId = panel.getId();
37998 this.panels.removeKey(panelId);
38003 * Returns the panel specified or null if it's not in this region.
38004 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
38005 * @return {Roo.ContentPanel}
38007 getPanel : function(id){
38008 if(typeof id == "object"){ // must be panel obj
38011 return this.panels.get(id);
38015 * Returns this regions position (north/south/east/west/center).
38018 getPosition: function(){
38019 return this.position;
38023 * Ext JS Library 1.1.1
38024 * Copyright(c) 2006-2007, Ext JS, LLC.
38026 * Originally Released Under LGPL - original licence link has changed is not relivant.
38029 * <script type="text/javascript">
38033 * @class Roo.bootstrap.layout.Region
38034 * @extends Roo.bootstrap.layout.Basic
38035 * This class represents a region in a layout manager.
38037 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
38038 * @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})
38039 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
38040 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
38041 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
38042 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
38043 * @cfg {String} title The title for the region (overrides panel titles)
38044 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
38045 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
38046 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
38047 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
38048 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
38049 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
38050 * the space available, similar to FireFox 1.5 tabs (defaults to false)
38051 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
38052 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
38053 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
38055 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
38056 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
38057 * @cfg {Boolean} disableTabTips True to disable tab tooltips
38058 * @cfg {Number} width For East/West panels
38059 * @cfg {Number} height For North/South panels
38060 * @cfg {Boolean} split To show the splitter
38061 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
38063 * @cfg {string} cls Extra CSS classes to add to region
38065 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
38066 * @cfg {string} region the region that it inhabits..
38069 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
38070 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
38072 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
38073 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
38074 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
38076 Roo.bootstrap.layout.Region = function(config)
38078 this.applyConfig(config);
38080 var mgr = config.mgr;
38081 var pos = config.region;
38082 config.skipConfig = true;
38083 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
38086 this.onRender(mgr.el);
38089 this.visible = true;
38090 this.collapsed = false;
38091 this.unrendered_panels = [];
38094 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
38096 position: '', // set by wrapper (eg. north/south etc..)
38097 unrendered_panels : null, // unrendered panels.
38099 tabPosition : false,
38101 mgr: false, // points to 'Border'
38104 createBody : function(){
38105 /** This region's body element
38106 * @type Roo.Element */
38107 this.bodyEl = this.el.createChild({
38109 cls: "roo-layout-panel-body tab-content" // bootstrap added...
38113 onRender: function(ctr, pos)
38115 var dh = Roo.DomHelper;
38116 /** This region's container element
38117 * @type Roo.Element */
38118 this.el = dh.append(ctr.dom, {
38120 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
38122 /** This region's title element
38123 * @type Roo.Element */
38125 this.titleEl = dh.append(this.el.dom, {
38127 unselectable: "on",
38128 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
38130 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
38131 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
38135 this.titleEl.enableDisplayMode();
38136 /** This region's title text element
38137 * @type HTMLElement */
38138 this.titleTextEl = this.titleEl.dom.firstChild;
38139 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
38141 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
38142 this.closeBtn.enableDisplayMode();
38143 this.closeBtn.on("click", this.closeClicked, this);
38144 this.closeBtn.hide();
38146 this.createBody(this.config);
38147 if(this.config.hideWhenEmpty){
38149 this.on("paneladded", this.validateVisibility, this);
38150 this.on("panelremoved", this.validateVisibility, this);
38152 if(this.autoScroll){
38153 this.bodyEl.setStyle("overflow", "auto");
38155 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
38157 //if(c.titlebar !== false){
38158 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
38159 this.titleEl.hide();
38161 this.titleEl.show();
38162 if(this.config.title){
38163 this.titleTextEl.innerHTML = this.config.title;
38167 if(this.config.collapsed){
38168 this.collapse(true);
38170 if(this.config.hidden){
38174 if (this.unrendered_panels && this.unrendered_panels.length) {
38175 for (var i =0;i< this.unrendered_panels.length; i++) {
38176 this.add(this.unrendered_panels[i]);
38178 this.unrendered_panels = null;
38184 applyConfig : function(c)
38187 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
38188 var dh = Roo.DomHelper;
38189 if(c.titlebar !== false){
38190 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
38191 this.collapseBtn.on("click", this.collapse, this);
38192 this.collapseBtn.enableDisplayMode();
38194 if(c.showPin === true || this.showPin){
38195 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
38196 this.stickBtn.enableDisplayMode();
38197 this.stickBtn.on("click", this.expand, this);
38198 this.stickBtn.hide();
38203 /** This region's collapsed element
38204 * @type Roo.Element */
38207 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
38208 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
38211 if(c.floatable !== false){
38212 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
38213 this.collapsedEl.on("click", this.collapseClick, this);
38216 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
38217 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
38218 id: "message", unselectable: "on", style:{"float":"left"}});
38219 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
38221 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
38222 this.expandBtn.on("click", this.expand, this);
38226 if(this.collapseBtn){
38227 this.collapseBtn.setVisible(c.collapsible == true);
38230 this.cmargins = c.cmargins || this.cmargins ||
38231 (this.position == "west" || this.position == "east" ?
38232 {top: 0, left: 2, right:2, bottom: 0} :
38233 {top: 2, left: 0, right:0, bottom: 2});
38235 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
38238 this.tabPosition = [ 'top','bottom', 'west'].indexOf(c.tabPosition) > -1 ? c.tabPosition : "top";
38240 this.autoScroll = c.autoScroll || false;
38245 this.duration = c.duration || .30;
38246 this.slideDuration = c.slideDuration || .45;
38251 * Returns true if this region is currently visible.
38252 * @return {Boolean}
38254 isVisible : function(){
38255 return this.visible;
38259 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
38260 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
38262 //setCollapsedTitle : function(title){
38263 // title = title || " ";
38264 // if(this.collapsedTitleTextEl){
38265 // this.collapsedTitleTextEl.innerHTML = title;
38269 getBox : function(){
38271 // if(!this.collapsed){
38272 b = this.el.getBox(false, true);
38274 // b = this.collapsedEl.getBox(false, true);
38279 getMargins : function(){
38280 return this.margins;
38281 //return this.collapsed ? this.cmargins : this.margins;
38284 highlight : function(){
38285 this.el.addClass("x-layout-panel-dragover");
38288 unhighlight : function(){
38289 this.el.removeClass("x-layout-panel-dragover");
38292 updateBox : function(box)
38294 if (!this.bodyEl) {
38295 return; // not rendered yet..
38299 if(!this.collapsed){
38300 this.el.dom.style.left = box.x + "px";
38301 this.el.dom.style.top = box.y + "px";
38302 this.updateBody(box.width, box.height);
38304 this.collapsedEl.dom.style.left = box.x + "px";
38305 this.collapsedEl.dom.style.top = box.y + "px";
38306 this.collapsedEl.setSize(box.width, box.height);
38309 this.tabs.autoSizeTabs();
38313 updateBody : function(w, h)
38316 this.el.setWidth(w);
38317 w -= this.el.getBorderWidth("rl");
38318 if(this.config.adjustments){
38319 w += this.config.adjustments[0];
38322 if(h !== null && h > 0){
38323 this.el.setHeight(h);
38324 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
38325 h -= this.el.getBorderWidth("tb");
38326 if(this.config.adjustments){
38327 h += this.config.adjustments[1];
38329 this.bodyEl.setHeight(h);
38331 h = this.tabs.syncHeight(h);
38334 if(this.panelSize){
38335 w = w !== null ? w : this.panelSize.width;
38336 h = h !== null ? h : this.panelSize.height;
38338 if(this.activePanel){
38339 var el = this.activePanel.getEl();
38340 w = w !== null ? w : el.getWidth();
38341 h = h !== null ? h : el.getHeight();
38342 this.panelSize = {width: w, height: h};
38343 this.activePanel.setSize(w, h);
38345 if(Roo.isIE && this.tabs){
38346 this.tabs.el.repaint();
38351 * Returns the container element for this region.
38352 * @return {Roo.Element}
38354 getEl : function(){
38359 * Hides this region.
38362 //if(!this.collapsed){
38363 this.el.dom.style.left = "-2000px";
38366 // this.collapsedEl.dom.style.left = "-2000px";
38367 // this.collapsedEl.hide();
38369 this.visible = false;
38370 this.fireEvent("visibilitychange", this, false);
38374 * Shows this region if it was previously hidden.
38377 //if(!this.collapsed){
38380 // this.collapsedEl.show();
38382 this.visible = true;
38383 this.fireEvent("visibilitychange", this, true);
38386 closeClicked : function(){
38387 if(this.activePanel){
38388 this.remove(this.activePanel);
38392 collapseClick : function(e){
38394 e.stopPropagation();
38397 e.stopPropagation();
38403 * Collapses this region.
38404 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
38407 collapse : function(skipAnim, skipCheck = false){
38408 if(this.collapsed) {
38412 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
38414 this.collapsed = true;
38416 this.split.el.hide();
38418 if(this.config.animate && skipAnim !== true){
38419 this.fireEvent("invalidated", this);
38420 this.animateCollapse();
38422 this.el.setLocation(-20000,-20000);
38424 this.collapsedEl.show();
38425 this.fireEvent("collapsed", this);
38426 this.fireEvent("invalidated", this);
38432 animateCollapse : function(){
38437 * Expands this region if it was previously collapsed.
38438 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
38439 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
38442 expand : function(e, skipAnim){
38444 e.stopPropagation();
38446 if(!this.collapsed || this.el.hasActiveFx()) {
38450 this.afterSlideIn();
38453 this.collapsed = false;
38454 if(this.config.animate && skipAnim !== true){
38455 this.animateExpand();
38459 this.split.el.show();
38461 this.collapsedEl.setLocation(-2000,-2000);
38462 this.collapsedEl.hide();
38463 this.fireEvent("invalidated", this);
38464 this.fireEvent("expanded", this);
38468 animateExpand : function(){
38472 initTabs : function()
38474 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
38476 var ts = new Roo.bootstrap.panel.Tabs({
38477 el: this.bodyEl.dom,
38479 tabPosition: this.tabPosition ? this.tabPosition : 'top',
38480 disableTooltips: this.config.disableTabTips,
38481 toolbar : this.config.toolbar
38484 if(this.config.hideTabs){
38485 ts.stripWrap.setDisplayed(false);
38488 ts.resizeTabs = this.config.resizeTabs === true;
38489 ts.minTabWidth = this.config.minTabWidth || 40;
38490 ts.maxTabWidth = this.config.maxTabWidth || 250;
38491 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
38492 ts.monitorResize = false;
38493 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
38494 ts.bodyEl.addClass('roo-layout-tabs-body');
38495 this.panels.each(this.initPanelAsTab, this);
38498 initPanelAsTab : function(panel){
38499 var ti = this.tabs.addTab(
38503 this.config.closeOnTab && panel.isClosable(),
38506 if(panel.tabTip !== undefined){
38507 ti.setTooltip(panel.tabTip);
38509 ti.on("activate", function(){
38510 this.setActivePanel(panel);
38513 if(this.config.closeOnTab){
38514 ti.on("beforeclose", function(t, e){
38516 this.remove(panel);
38520 panel.tabItem = ti;
38525 updatePanelTitle : function(panel, title)
38527 if(this.activePanel == panel){
38528 this.updateTitle(title);
38531 var ti = this.tabs.getTab(panel.getEl().id);
38533 if(panel.tabTip !== undefined){
38534 ti.setTooltip(panel.tabTip);
38539 updateTitle : function(title){
38540 if(this.titleTextEl && !this.config.title){
38541 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
38545 setActivePanel : function(panel)
38547 panel = this.getPanel(panel);
38548 if(this.activePanel && this.activePanel != panel){
38549 if(this.activePanel.setActiveState(false) === false){
38553 this.activePanel = panel;
38554 panel.setActiveState(true);
38555 if(this.panelSize){
38556 panel.setSize(this.panelSize.width, this.panelSize.height);
38559 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
38561 this.updateTitle(panel.getTitle());
38563 this.fireEvent("invalidated", this);
38565 this.fireEvent("panelactivated", this, panel);
38569 * Shows the specified panel.
38570 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
38571 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
38573 showPanel : function(panel)
38575 panel = this.getPanel(panel);
38578 var tab = this.tabs.getTab(panel.getEl().id);
38579 if(tab.isHidden()){
38580 this.tabs.unhideTab(tab.id);
38584 this.setActivePanel(panel);
38591 * Get the active panel for this region.
38592 * @return {Roo.ContentPanel} The active panel or null
38594 getActivePanel : function(){
38595 return this.activePanel;
38598 validateVisibility : function(){
38599 if(this.panels.getCount() < 1){
38600 this.updateTitle(" ");
38601 this.closeBtn.hide();
38604 if(!this.isVisible()){
38611 * Adds the passed ContentPanel(s) to this region.
38612 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
38613 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
38615 add : function(panel)
38617 if(arguments.length > 1){
38618 for(var i = 0, len = arguments.length; i < len; i++) {
38619 this.add(arguments[i]);
38624 // if we have not been rendered yet, then we can not really do much of this..
38625 if (!this.bodyEl) {
38626 this.unrendered_panels.push(panel);
38633 if(this.hasPanel(panel)){
38634 this.showPanel(panel);
38637 panel.setRegion(this);
38638 this.panels.add(panel);
38639 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
38640 // sinle panel - no tab...?? would it not be better to render it with the tabs,
38641 // and hide them... ???
38642 this.bodyEl.dom.appendChild(panel.getEl().dom);
38643 if(panel.background !== true){
38644 this.setActivePanel(panel);
38646 this.fireEvent("paneladded", this, panel);
38653 this.initPanelAsTab(panel);
38657 if(panel.background !== true){
38658 this.tabs.activate(panel.getEl().id);
38660 this.fireEvent("paneladded", this, panel);
38665 * Hides the tab for the specified panel.
38666 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
38668 hidePanel : function(panel){
38669 if(this.tabs && (panel = this.getPanel(panel))){
38670 this.tabs.hideTab(panel.getEl().id);
38675 * Unhides the tab for a previously hidden panel.
38676 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
38678 unhidePanel : function(panel){
38679 if(this.tabs && (panel = this.getPanel(panel))){
38680 this.tabs.unhideTab(panel.getEl().id);
38684 clearPanels : function(){
38685 while(this.panels.getCount() > 0){
38686 this.remove(this.panels.first());
38691 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
38692 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
38693 * @param {Boolean} preservePanel Overrides the config preservePanel option
38694 * @return {Roo.ContentPanel} The panel that was removed
38696 remove : function(panel, preservePanel)
38698 panel = this.getPanel(panel);
38703 this.fireEvent("beforeremove", this, panel, e);
38704 if(e.cancel === true){
38707 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
38708 var panelId = panel.getId();
38709 this.panels.removeKey(panelId);
38711 document.body.appendChild(panel.getEl().dom);
38714 this.tabs.removeTab(panel.getEl().id);
38715 }else if (!preservePanel){
38716 this.bodyEl.dom.removeChild(panel.getEl().dom);
38718 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
38719 var p = this.panels.first();
38720 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
38721 tempEl.appendChild(p.getEl().dom);
38722 this.bodyEl.update("");
38723 this.bodyEl.dom.appendChild(p.getEl().dom);
38725 this.updateTitle(p.getTitle());
38727 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
38728 this.setActivePanel(p);
38730 panel.setRegion(null);
38731 if(this.activePanel == panel){
38732 this.activePanel = null;
38734 if(this.config.autoDestroy !== false && preservePanel !== true){
38735 try{panel.destroy();}catch(e){}
38737 this.fireEvent("panelremoved", this, panel);
38742 * Returns the TabPanel component used by this region
38743 * @return {Roo.TabPanel}
38745 getTabs : function(){
38749 createTool : function(parentEl, className){
38750 var btn = Roo.DomHelper.append(parentEl, {
38752 cls: "x-layout-tools-button",
38755 cls: "roo-layout-tools-button-inner " + className,
38759 btn.addClassOnOver("roo-layout-tools-button-over");
38764 * Ext JS Library 1.1.1
38765 * Copyright(c) 2006-2007, Ext JS, LLC.
38767 * Originally Released Under LGPL - original licence link has changed is not relivant.
38770 * <script type="text/javascript">
38776 * @class Roo.SplitLayoutRegion
38777 * @extends Roo.LayoutRegion
38778 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
38780 Roo.bootstrap.layout.Split = function(config){
38781 this.cursor = config.cursor;
38782 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
38785 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
38787 splitTip : "Drag to resize.",
38788 collapsibleSplitTip : "Drag to resize. Double click to hide.",
38789 useSplitTips : false,
38791 applyConfig : function(config){
38792 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
38795 onRender : function(ctr,pos) {
38797 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
38798 if(!this.config.split){
38803 var splitEl = Roo.DomHelper.append(ctr.dom, {
38805 id: this.el.id + "-split",
38806 cls: "roo-layout-split roo-layout-split-"+this.position,
38809 /** The SplitBar for this region
38810 * @type Roo.SplitBar */
38811 // does not exist yet...
38812 Roo.log([this.position, this.orientation]);
38814 this.split = new Roo.bootstrap.SplitBar({
38815 dragElement : splitEl,
38816 resizingElement: this.el,
38817 orientation : this.orientation
38820 this.split.on("moved", this.onSplitMove, this);
38821 this.split.useShim = this.config.useShim === true;
38822 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
38823 if(this.useSplitTips){
38824 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
38826 //if(config.collapsible){
38827 // this.split.el.on("dblclick", this.collapse, this);
38830 if(typeof this.config.minSize != "undefined"){
38831 this.split.minSize = this.config.minSize;
38833 if(typeof this.config.maxSize != "undefined"){
38834 this.split.maxSize = this.config.maxSize;
38836 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
38837 this.hideSplitter();
38842 getHMaxSize : function(){
38843 var cmax = this.config.maxSize || 10000;
38844 var center = this.mgr.getRegion("center");
38845 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
38848 getVMaxSize : function(){
38849 var cmax = this.config.maxSize || 10000;
38850 var center = this.mgr.getRegion("center");
38851 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
38854 onSplitMove : function(split, newSize){
38855 this.fireEvent("resized", this, newSize);
38859 * Returns the {@link Roo.SplitBar} for this region.
38860 * @return {Roo.SplitBar}
38862 getSplitBar : function(){
38867 this.hideSplitter();
38868 Roo.bootstrap.layout.Split.superclass.hide.call(this);
38871 hideSplitter : function(){
38873 this.split.el.setLocation(-2000,-2000);
38874 this.split.el.hide();
38880 this.split.el.show();
38882 Roo.bootstrap.layout.Split.superclass.show.call(this);
38885 beforeSlide: function(){
38886 if(Roo.isGecko){// firefox overflow auto bug workaround
38887 this.bodyEl.clip();
38889 this.tabs.bodyEl.clip();
38891 if(this.activePanel){
38892 this.activePanel.getEl().clip();
38894 if(this.activePanel.beforeSlide){
38895 this.activePanel.beforeSlide();
38901 afterSlide : function(){
38902 if(Roo.isGecko){// firefox overflow auto bug workaround
38903 this.bodyEl.unclip();
38905 this.tabs.bodyEl.unclip();
38907 if(this.activePanel){
38908 this.activePanel.getEl().unclip();
38909 if(this.activePanel.afterSlide){
38910 this.activePanel.afterSlide();
38916 initAutoHide : function(){
38917 if(this.autoHide !== false){
38918 if(!this.autoHideHd){
38919 var st = new Roo.util.DelayedTask(this.slideIn, this);
38920 this.autoHideHd = {
38921 "mouseout": function(e){
38922 if(!e.within(this.el, true)){
38926 "mouseover" : function(e){
38932 this.el.on(this.autoHideHd);
38936 clearAutoHide : function(){
38937 if(this.autoHide !== false){
38938 this.el.un("mouseout", this.autoHideHd.mouseout);
38939 this.el.un("mouseover", this.autoHideHd.mouseover);
38943 clearMonitor : function(){
38944 Roo.get(document).un("click", this.slideInIf, this);
38947 // these names are backwards but not changed for compat
38948 slideOut : function(){
38949 if(this.isSlid || this.el.hasActiveFx()){
38952 this.isSlid = true;
38953 if(this.collapseBtn){
38954 this.collapseBtn.hide();
38956 this.closeBtnState = this.closeBtn.getStyle('display');
38957 this.closeBtn.hide();
38959 this.stickBtn.show();
38962 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
38963 this.beforeSlide();
38964 this.el.setStyle("z-index", 10001);
38965 this.el.slideIn(this.getSlideAnchor(), {
38966 callback: function(){
38968 this.initAutoHide();
38969 Roo.get(document).on("click", this.slideInIf, this);
38970 this.fireEvent("slideshow", this);
38977 afterSlideIn : function(){
38978 this.clearAutoHide();
38979 this.isSlid = false;
38980 this.clearMonitor();
38981 this.el.setStyle("z-index", "");
38982 if(this.collapseBtn){
38983 this.collapseBtn.show();
38985 this.closeBtn.setStyle('display', this.closeBtnState);
38987 this.stickBtn.hide();
38989 this.fireEvent("slidehide", this);
38992 slideIn : function(cb){
38993 if(!this.isSlid || this.el.hasActiveFx()){
38997 this.isSlid = false;
38998 this.beforeSlide();
38999 this.el.slideOut(this.getSlideAnchor(), {
39000 callback: function(){
39001 this.el.setLeftTop(-10000, -10000);
39003 this.afterSlideIn();
39011 slideInIf : function(e){
39012 if(!e.within(this.el)){
39017 animateCollapse : function(){
39018 this.beforeSlide();
39019 this.el.setStyle("z-index", 20000);
39020 var anchor = this.getSlideAnchor();
39021 this.el.slideOut(anchor, {
39022 callback : function(){
39023 this.el.setStyle("z-index", "");
39024 this.collapsedEl.slideIn(anchor, {duration:.3});
39026 this.el.setLocation(-10000,-10000);
39028 this.fireEvent("collapsed", this);
39035 animateExpand : function(){
39036 this.beforeSlide();
39037 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
39038 this.el.setStyle("z-index", 20000);
39039 this.collapsedEl.hide({
39042 this.el.slideIn(this.getSlideAnchor(), {
39043 callback : function(){
39044 this.el.setStyle("z-index", "");
39047 this.split.el.show();
39049 this.fireEvent("invalidated", this);
39050 this.fireEvent("expanded", this);
39078 getAnchor : function(){
39079 return this.anchors[this.position];
39082 getCollapseAnchor : function(){
39083 return this.canchors[this.position];
39086 getSlideAnchor : function(){
39087 return this.sanchors[this.position];
39090 getAlignAdj : function(){
39091 var cm = this.cmargins;
39092 switch(this.position){
39108 getExpandAdj : function(){
39109 var c = this.collapsedEl, cm = this.cmargins;
39110 switch(this.position){
39112 return [-(cm.right+c.getWidth()+cm.left), 0];
39115 return [cm.right+c.getWidth()+cm.left, 0];
39118 return [0, -(cm.top+cm.bottom+c.getHeight())];
39121 return [0, cm.top+cm.bottom+c.getHeight()];
39127 * Ext JS Library 1.1.1
39128 * Copyright(c) 2006-2007, Ext JS, LLC.
39130 * Originally Released Under LGPL - original licence link has changed is not relivant.
39133 * <script type="text/javascript">
39136 * These classes are private internal classes
39138 Roo.bootstrap.layout.Center = function(config){
39139 config.region = "center";
39140 Roo.bootstrap.layout.Region.call(this, config);
39141 this.visible = true;
39142 this.minWidth = config.minWidth || 20;
39143 this.minHeight = config.minHeight || 20;
39146 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
39148 // center panel can't be hidden
39152 // center panel can't be hidden
39155 getMinWidth: function(){
39156 return this.minWidth;
39159 getMinHeight: function(){
39160 return this.minHeight;
39174 Roo.bootstrap.layout.North = function(config)
39176 config.region = 'north';
39177 config.cursor = 'n-resize';
39179 Roo.bootstrap.layout.Split.call(this, config);
39183 this.split.placement = Roo.bootstrap.SplitBar.TOP;
39184 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
39185 this.split.el.addClass("roo-layout-split-v");
39187 var size = config.initialSize || config.height;
39188 if(typeof size != "undefined"){
39189 this.el.setHeight(size);
39192 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
39194 orientation: Roo.bootstrap.SplitBar.VERTICAL,
39198 getBox : function(){
39199 if(this.collapsed){
39200 return this.collapsedEl.getBox();
39202 var box = this.el.getBox();
39204 box.height += this.split.el.getHeight();
39209 updateBox : function(box){
39210 if(this.split && !this.collapsed){
39211 box.height -= this.split.el.getHeight();
39212 this.split.el.setLeft(box.x);
39213 this.split.el.setTop(box.y+box.height);
39214 this.split.el.setWidth(box.width);
39216 if(this.collapsed){
39217 this.updateBody(box.width, null);
39219 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
39227 Roo.bootstrap.layout.South = function(config){
39228 config.region = 'south';
39229 config.cursor = 's-resize';
39230 Roo.bootstrap.layout.Split.call(this, config);
39232 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
39233 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
39234 this.split.el.addClass("roo-layout-split-v");
39236 var size = config.initialSize || config.height;
39237 if(typeof size != "undefined"){
39238 this.el.setHeight(size);
39242 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
39243 orientation: Roo.bootstrap.SplitBar.VERTICAL,
39244 getBox : function(){
39245 if(this.collapsed){
39246 return this.collapsedEl.getBox();
39248 var box = this.el.getBox();
39250 var sh = this.split.el.getHeight();
39257 updateBox : function(box){
39258 if(this.split && !this.collapsed){
39259 var sh = this.split.el.getHeight();
39262 this.split.el.setLeft(box.x);
39263 this.split.el.setTop(box.y-sh);
39264 this.split.el.setWidth(box.width);
39266 if(this.collapsed){
39267 this.updateBody(box.width, null);
39269 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
39273 Roo.bootstrap.layout.East = function(config){
39274 config.region = "east";
39275 config.cursor = "e-resize";
39276 Roo.bootstrap.layout.Split.call(this, config);
39278 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
39279 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
39280 this.split.el.addClass("roo-layout-split-h");
39282 var size = config.initialSize || config.width;
39283 if(typeof size != "undefined"){
39284 this.el.setWidth(size);
39287 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
39288 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
39289 getBox : function(){
39290 if(this.collapsed){
39291 return this.collapsedEl.getBox();
39293 var box = this.el.getBox();
39295 var sw = this.split.el.getWidth();
39302 updateBox : function(box){
39303 if(this.split && !this.collapsed){
39304 var sw = this.split.el.getWidth();
39306 this.split.el.setLeft(box.x);
39307 this.split.el.setTop(box.y);
39308 this.split.el.setHeight(box.height);
39311 if(this.collapsed){
39312 this.updateBody(null, box.height);
39314 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
39318 Roo.bootstrap.layout.West = function(config){
39319 config.region = "west";
39320 config.cursor = "w-resize";
39322 Roo.bootstrap.layout.Split.call(this, config);
39324 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
39325 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
39326 this.split.el.addClass("roo-layout-split-h");
39330 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
39331 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
39333 onRender: function(ctr, pos)
39335 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
39336 var size = this.config.initialSize || this.config.width;
39337 if(typeof size != "undefined"){
39338 this.el.setWidth(size);
39342 getBox : function(){
39343 if(this.collapsed){
39344 return this.collapsedEl.getBox();
39346 var box = this.el.getBox();
39348 box.width += this.split.el.getWidth();
39353 updateBox : function(box){
39354 if(this.split && !this.collapsed){
39355 var sw = this.split.el.getWidth();
39357 this.split.el.setLeft(box.x+box.width);
39358 this.split.el.setTop(box.y);
39359 this.split.el.setHeight(box.height);
39361 if(this.collapsed){
39362 this.updateBody(null, box.height);
39364 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
39366 });Roo.namespace("Roo.bootstrap.panel");/*
39368 * Ext JS Library 1.1.1
39369 * Copyright(c) 2006-2007, Ext JS, LLC.
39371 * Originally Released Under LGPL - original licence link has changed is not relivant.
39374 * <script type="text/javascript">
39377 * @class Roo.ContentPanel
39378 * @extends Roo.util.Observable
39379 * A basic ContentPanel element.
39380 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
39381 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
39382 * @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
39383 * @cfg {Boolean} closable True if the panel can be closed/removed
39384 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
39385 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
39386 * @cfg {Toolbar} toolbar A toolbar for this panel
39387 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
39388 * @cfg {String} title The title for this panel
39389 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
39390 * @cfg {String} url Calls {@link #setUrl} with this value
39391 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
39392 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
39393 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
39394 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
39395 * @cfg {Boolean} badges render the badges
39396 * @cfg {String} cls extra classes to use
39397 * @cfg {String} background (primary|secondary|success|info|warning|danger|light|dark)
39400 * Create a new ContentPanel.
39401 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
39402 * @param {String/Object} config A string to set only the title or a config object
39403 * @param {String} content (optional) Set the HTML content for this panel
39404 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
39406 Roo.bootstrap.panel.Content = function( config){
39408 this.tpl = config.tpl || false;
39410 var el = config.el;
39411 var content = config.content;
39413 if(config.autoCreate){ // xtype is available if this is called from factory
39416 this.el = Roo.get(el);
39417 if(!this.el && config && config.autoCreate){
39418 if(typeof config.autoCreate == "object"){
39419 if(!config.autoCreate.id){
39420 config.autoCreate.id = config.id||el;
39422 this.el = Roo.DomHelper.append(document.body,
39423 config.autoCreate, true);
39427 cls: (config.cls || '') +
39428 (config.background ? ' bg-' + config.background : '') +
39429 " roo-layout-inactive-content",
39433 elcfg.html = config.html;
39437 this.el = Roo.DomHelper.append(document.body, elcfg , true);
39440 this.closable = false;
39441 this.loaded = false;
39442 this.active = false;
39445 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
39447 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
39449 this.wrapEl = this.el; //this.el.wrap();
39451 if (config.toolbar.items) {
39452 ti = config.toolbar.items ;
39453 delete config.toolbar.items ;
39457 this.toolbar.render(this.wrapEl, 'before');
39458 for(var i =0;i < ti.length;i++) {
39459 // Roo.log(['add child', items[i]]);
39460 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
39462 this.toolbar.items = nitems;
39463 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
39464 delete config.toolbar;
39468 // xtype created footer. - not sure if will work as we normally have to render first..
39469 if (this.footer && !this.footer.el && this.footer.xtype) {
39470 if (!this.wrapEl) {
39471 this.wrapEl = this.el.wrap();
39474 this.footer.container = this.wrapEl.createChild();
39476 this.footer = Roo.factory(this.footer, Roo);
39481 if(typeof config == "string"){
39482 this.title = config;
39484 Roo.apply(this, config);
39488 this.resizeEl = Roo.get(this.resizeEl, true);
39490 this.resizeEl = this.el;
39492 // handle view.xtype
39500 * Fires when this panel is activated.
39501 * @param {Roo.ContentPanel} this
39505 * @event deactivate
39506 * Fires when this panel is activated.
39507 * @param {Roo.ContentPanel} this
39509 "deactivate" : true,
39513 * Fires when this panel is resized if fitToFrame is true.
39514 * @param {Roo.ContentPanel} this
39515 * @param {Number} width The width after any component adjustments
39516 * @param {Number} height The height after any component adjustments
39522 * Fires when this tab is created
39523 * @param {Roo.ContentPanel} this
39534 if(this.autoScroll){
39535 this.resizeEl.setStyle("overflow", "auto");
39537 // fix randome scrolling
39538 //this.el.on('scroll', function() {
39539 // Roo.log('fix random scolling');
39540 // this.scrollTo('top',0);
39543 content = content || this.content;
39545 this.setContent(content);
39547 if(config && config.url){
39548 this.setUrl(this.url, this.params, this.loadOnce);
39553 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
39555 if (this.view && typeof(this.view.xtype) != 'undefined') {
39556 this.view.el = this.el.appendChild(document.createElement("div"));
39557 this.view = Roo.factory(this.view);
39558 this.view.render && this.view.render(false, '');
39562 this.fireEvent('render', this);
39565 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
39572 setRegion : function(region){
39573 this.region = region;
39574 this.setActiveClass(region && !this.background);
39578 setActiveClass: function(state)
39581 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
39582 this.el.setStyle('position','relative');
39584 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
39585 this.el.setStyle('position', 'absolute');
39590 * Returns the toolbar for this Panel if one was configured.
39591 * @return {Roo.Toolbar}
39593 getToolbar : function(){
39594 return this.toolbar;
39597 setActiveState : function(active)
39599 this.active = active;
39600 this.setActiveClass(active);
39602 if(this.fireEvent("deactivate", this) === false){
39607 this.fireEvent("activate", this);
39611 * Updates this panel's element
39612 * @param {String} content The new content
39613 * @param {Boolean} loadScripts (optional) true to look for and process scripts
39615 setContent : function(content, loadScripts){
39616 this.el.update(content, loadScripts);
39619 ignoreResize : function(w, h){
39620 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
39623 this.lastSize = {width: w, height: h};
39628 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
39629 * @return {Roo.UpdateManager} The UpdateManager
39631 getUpdateManager : function(){
39632 return this.el.getUpdateManager();
39635 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
39636 * @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:
39639 url: "your-url.php",
39640 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
39641 callback: yourFunction,
39642 scope: yourObject, //(optional scope)
39645 text: "Loading...",
39650 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
39651 * 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.
39652 * @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}
39653 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
39654 * @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.
39655 * @return {Roo.ContentPanel} this
39658 var um = this.el.getUpdateManager();
39659 um.update.apply(um, arguments);
39665 * 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.
39666 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
39667 * @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)
39668 * @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)
39669 * @return {Roo.UpdateManager} The UpdateManager
39671 setUrl : function(url, params, loadOnce){
39672 if(this.refreshDelegate){
39673 this.removeListener("activate", this.refreshDelegate);
39675 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
39676 this.on("activate", this.refreshDelegate);
39677 return this.el.getUpdateManager();
39680 _handleRefresh : function(url, params, loadOnce){
39681 if(!loadOnce || !this.loaded){
39682 var updater = this.el.getUpdateManager();
39683 updater.update(url, params, this._setLoaded.createDelegate(this));
39687 _setLoaded : function(){
39688 this.loaded = true;
39692 * Returns this panel's id
39695 getId : function(){
39700 * Returns this panel's element - used by regiosn to add.
39701 * @return {Roo.Element}
39703 getEl : function(){
39704 return this.wrapEl || this.el;
39709 adjustForComponents : function(width, height)
39711 //Roo.log('adjustForComponents ');
39712 if(this.resizeEl != this.el){
39713 width -= this.el.getFrameWidth('lr');
39714 height -= this.el.getFrameWidth('tb');
39717 var te = this.toolbar.getEl();
39718 te.setWidth(width);
39719 height -= te.getHeight();
39722 var te = this.footer.getEl();
39723 te.setWidth(width);
39724 height -= te.getHeight();
39728 if(this.adjustments){
39729 width += this.adjustments[0];
39730 height += this.adjustments[1];
39732 return {"width": width, "height": height};
39735 setSize : function(width, height){
39736 if(this.fitToFrame && !this.ignoreResize(width, height)){
39737 if(this.fitContainer && this.resizeEl != this.el){
39738 this.el.setSize(width, height);
39740 var size = this.adjustForComponents(width, height);
39741 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
39742 this.fireEvent('resize', this, size.width, size.height);
39747 * Returns this panel's title
39750 getTitle : function(){
39752 if (typeof(this.title) != 'object') {
39757 for (var k in this.title) {
39758 if (!this.title.hasOwnProperty(k)) {
39762 if (k.indexOf('-') >= 0) {
39763 var s = k.split('-');
39764 for (var i = 0; i<s.length; i++) {
39765 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
39768 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
39775 * Set this panel's title
39776 * @param {String} title
39778 setTitle : function(title){
39779 this.title = title;
39781 this.region.updatePanelTitle(this, title);
39786 * Returns true is this panel was configured to be closable
39787 * @return {Boolean}
39789 isClosable : function(){
39790 return this.closable;
39793 beforeSlide : function(){
39795 this.resizeEl.clip();
39798 afterSlide : function(){
39800 this.resizeEl.unclip();
39804 * Force a content refresh from the URL specified in the {@link #setUrl} method.
39805 * Will fail silently if the {@link #setUrl} method has not been called.
39806 * This does not activate the panel, just updates its content.
39808 refresh : function(){
39809 if(this.refreshDelegate){
39810 this.loaded = false;
39811 this.refreshDelegate();
39816 * Destroys this panel
39818 destroy : function(){
39819 this.el.removeAllListeners();
39820 var tempEl = document.createElement("span");
39821 tempEl.appendChild(this.el.dom);
39822 tempEl.innerHTML = "";
39828 * form - if the content panel contains a form - this is a reference to it.
39829 * @type {Roo.form.Form}
39833 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
39834 * This contains a reference to it.
39840 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
39850 * @param {Object} cfg Xtype definition of item to add.
39854 getChildContainer: function () {
39855 return this.getEl();
39860 var ret = new Roo.factory(cfg);
39865 if (cfg.xtype.match(/^Form$/)) {
39868 //if (this.footer) {
39869 // el = this.footer.container.insertSibling(false, 'before');
39871 el = this.el.createChild();
39874 this.form = new Roo.form.Form(cfg);
39877 if ( this.form.allItems.length) {
39878 this.form.render(el.dom);
39882 // should only have one of theses..
39883 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
39884 // views.. should not be just added - used named prop 'view''
39886 cfg.el = this.el.appendChild(document.createElement("div"));
39889 var ret = new Roo.factory(cfg);
39891 ret.render && ret.render(false, ''); // render blank..
39901 * @class Roo.bootstrap.panel.Grid
39902 * @extends Roo.bootstrap.panel.Content
39904 * Create a new GridPanel.
39905 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
39906 * @param {Object} config A the config object
39912 Roo.bootstrap.panel.Grid = function(config)
39916 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
39917 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
39919 config.el = this.wrapper;
39920 //this.el = this.wrapper;
39922 if (config.container) {
39923 // ctor'ed from a Border/panel.grid
39926 this.wrapper.setStyle("overflow", "hidden");
39927 this.wrapper.addClass('roo-grid-container');
39932 if(config.toolbar){
39933 var tool_el = this.wrapper.createChild();
39934 this.toolbar = Roo.factory(config.toolbar);
39936 if (config.toolbar.items) {
39937 ti = config.toolbar.items ;
39938 delete config.toolbar.items ;
39942 this.toolbar.render(tool_el);
39943 for(var i =0;i < ti.length;i++) {
39944 // Roo.log(['add child', items[i]]);
39945 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
39947 this.toolbar.items = nitems;
39949 delete config.toolbar;
39952 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
39953 config.grid.scrollBody = true;;
39954 config.grid.monitorWindowResize = false; // turn off autosizing
39955 config.grid.autoHeight = false;
39956 config.grid.autoWidth = false;
39958 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
39960 if (config.background) {
39961 // render grid on panel activation (if panel background)
39962 this.on('activate', function(gp) {
39963 if (!gp.grid.rendered) {
39964 gp.grid.render(this.wrapper);
39965 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
39970 this.grid.render(this.wrapper);
39971 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
39974 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
39975 // ??? needed ??? config.el = this.wrapper;
39980 // xtype created footer. - not sure if will work as we normally have to render first..
39981 if (this.footer && !this.footer.el && this.footer.xtype) {
39983 var ctr = this.grid.getView().getFooterPanel(true);
39984 this.footer.dataSource = this.grid.dataSource;
39985 this.footer = Roo.factory(this.footer, Roo);
39986 this.footer.render(ctr);
39996 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
39997 getId : function(){
39998 return this.grid.id;
40002 * Returns the grid for this panel
40003 * @return {Roo.bootstrap.Table}
40005 getGrid : function(){
40009 setSize : function(width, height){
40010 if(!this.ignoreResize(width, height)){
40011 var grid = this.grid;
40012 var size = this.adjustForComponents(width, height);
40013 // tfoot is not a footer?
40016 var gridel = grid.getGridEl();
40017 gridel.setSize(size.width, size.height);
40019 var tbd = grid.getGridEl().select('tbody', true).first();
40020 var thd = grid.getGridEl().select('thead',true).first();
40021 var tbf= grid.getGridEl().select('tfoot', true).first();
40024 size.height -= thd.getHeight();
40027 size.height -= thd.getHeight();
40030 tbd.setSize(size.width, size.height );
40031 // this is for the account management tab -seems to work there.
40032 var thd = grid.getGridEl().select('thead',true).first();
40034 // tbd.setSize(size.width, size.height - thd.getHeight());
40043 beforeSlide : function(){
40044 this.grid.getView().scroller.clip();
40047 afterSlide : function(){
40048 this.grid.getView().scroller.unclip();
40051 destroy : function(){
40052 this.grid.destroy();
40054 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
40059 * @class Roo.bootstrap.panel.Nest
40060 * @extends Roo.bootstrap.panel.Content
40062 * Create a new Panel, that can contain a layout.Border.
40065 * @param {Roo.BorderLayout} layout The layout for this panel
40066 * @param {String/Object} config A string to set only the title or a config object
40068 Roo.bootstrap.panel.Nest = function(config)
40070 // construct with only one argument..
40071 /* FIXME - implement nicer consturctors
40072 if (layout.layout) {
40074 layout = config.layout;
40075 delete config.layout;
40077 if (layout.xtype && !layout.getEl) {
40078 // then layout needs constructing..
40079 layout = Roo.factory(layout, Roo);
40083 config.el = config.layout.getEl();
40085 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
40087 config.layout.monitorWindowResize = false; // turn off autosizing
40088 this.layout = config.layout;
40089 this.layout.getEl().addClass("roo-layout-nested-layout");
40090 this.layout.parent = this;
40097 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
40099 setSize : function(width, height){
40100 if(!this.ignoreResize(width, height)){
40101 var size = this.adjustForComponents(width, height);
40102 var el = this.layout.getEl();
40103 if (size.height < 1) {
40104 el.setWidth(size.width);
40106 el.setSize(size.width, size.height);
40108 var touch = el.dom.offsetWidth;
40109 this.layout.layout();
40110 // ie requires a double layout on the first pass
40111 if(Roo.isIE && !this.initialized){
40112 this.initialized = true;
40113 this.layout.layout();
40118 // activate all subpanels if not currently active..
40120 setActiveState : function(active){
40121 this.active = active;
40122 this.setActiveClass(active);
40125 this.fireEvent("deactivate", this);
40129 this.fireEvent("activate", this);
40130 // not sure if this should happen before or after..
40131 if (!this.layout) {
40132 return; // should not happen..
40135 for (var r in this.layout.regions) {
40136 reg = this.layout.getRegion(r);
40137 if (reg.getActivePanel()) {
40138 //reg.showPanel(reg.getActivePanel()); // force it to activate..
40139 reg.setActivePanel(reg.getActivePanel());
40142 if (!reg.panels.length) {
40145 reg.showPanel(reg.getPanel(0));
40154 * Returns the nested BorderLayout for this panel
40155 * @return {Roo.BorderLayout}
40157 getLayout : function(){
40158 return this.layout;
40162 * Adds a xtype elements to the layout of the nested panel
40166 xtype : 'ContentPanel',
40173 xtype : 'NestedLayoutPanel',
40179 items : [ ... list of content panels or nested layout panels.. ]
40183 * @param {Object} cfg Xtype definition of item to add.
40185 addxtype : function(cfg) {
40186 return this.layout.addxtype(cfg);
40191 * Ext JS Library 1.1.1
40192 * Copyright(c) 2006-2007, Ext JS, LLC.
40194 * Originally Released Under LGPL - original licence link has changed is not relivant.
40197 * <script type="text/javascript">
40200 * @class Roo.TabPanel
40201 * @extends Roo.util.Observable
40202 * A lightweight tab container.
40206 // basic tabs 1, built from existing content
40207 var tabs = new Roo.TabPanel("tabs1");
40208 tabs.addTab("script", "View Script");
40209 tabs.addTab("markup", "View Markup");
40210 tabs.activate("script");
40212 // more advanced tabs, built from javascript
40213 var jtabs = new Roo.TabPanel("jtabs");
40214 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
40216 // set up the UpdateManager
40217 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
40218 var updater = tab2.getUpdateManager();
40219 updater.setDefaultUrl("ajax1.htm");
40220 tab2.on('activate', updater.refresh, updater, true);
40222 // Use setUrl for Ajax loading
40223 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
40224 tab3.setUrl("ajax2.htm", null, true);
40227 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
40230 jtabs.activate("jtabs-1");
40233 * Create a new TabPanel.
40234 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
40235 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
40237 Roo.bootstrap.panel.Tabs = function(config){
40239 * The container element for this TabPanel.
40240 * @type Roo.Element
40242 this.el = Roo.get(config.el);
40245 if(typeof config == "boolean"){
40246 this.tabPosition = config ? "bottom" : "top";
40248 Roo.apply(this, config);
40252 if(this.tabPosition == "bottom"){
40253 // if tabs are at the bottom = create the body first.
40254 this.bodyEl = Roo.get(this.createBody(this.el.dom));
40255 this.el.addClass("roo-tabs-bottom");
40257 // next create the tabs holders
40259 if (this.tabPosition == "west"){
40261 var reg = this.region; // fake it..
40263 if (!reg.mgr.parent) {
40266 reg = reg.mgr.parent.region;
40268 Roo.log("got nest?");
40270 if (reg.mgr.getRegion('west')) {
40271 var ctrdom = reg.mgr.getRegion('west').bodyEl.dom;
40272 this.stripWrap = Roo.get(this.createStrip(ctrdom ), true);
40273 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
40274 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
40275 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
40283 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
40284 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
40285 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
40286 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
40291 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
40294 // finally - if tabs are at the top, then create the body last..
40295 if(this.tabPosition != "bottom"){
40296 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
40297 * @type Roo.Element
40299 this.bodyEl = Roo.get(this.createBody(this.el.dom));
40300 this.el.addClass("roo-tabs-top");
40304 this.bodyEl.setStyle("position", "relative");
40306 this.active = null;
40307 this.activateDelegate = this.activate.createDelegate(this);
40312 * Fires when the active tab changes
40313 * @param {Roo.TabPanel} this
40314 * @param {Roo.TabPanelItem} activePanel The new active tab
40318 * @event beforetabchange
40319 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
40320 * @param {Roo.TabPanel} this
40321 * @param {Object} e Set cancel to true on this object to cancel the tab change
40322 * @param {Roo.TabPanelItem} tab The tab being changed to
40324 "beforetabchange" : true
40327 Roo.EventManager.onWindowResize(this.onResize, this);
40328 this.cpad = this.el.getPadding("lr");
40329 this.hiddenCount = 0;
40332 // toolbar on the tabbar support...
40333 if (this.toolbar) {
40334 alert("no toolbar support yet");
40335 this.toolbar = false;
40337 var tcfg = this.toolbar;
40338 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
40339 this.toolbar = new Roo.Toolbar(tcfg);
40340 if (Roo.isSafari) {
40341 var tbl = tcfg.container.child('table', true);
40342 tbl.setAttribute('width', '100%');
40350 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
40353 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
40355 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
40357 tabPosition : "top",
40359 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
40361 currentTabWidth : 0,
40363 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
40367 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
40371 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
40373 preferredTabWidth : 175,
40375 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
40377 resizeTabs : false,
40379 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
40381 monitorResize : true,
40383 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
40385 toolbar : false, // set by caller..
40387 region : false, /// set by caller
40389 disableTooltips : true, // not used yet...
40392 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
40393 * @param {String} id The id of the div to use <b>or create</b>
40394 * @param {String} text The text for the tab
40395 * @param {String} content (optional) Content to put in the TabPanelItem body
40396 * @param {Boolean} closable (optional) True to create a close icon on the tab
40397 * @return {Roo.TabPanelItem} The created TabPanelItem
40399 addTab : function(id, text, content, closable, tpl)
40401 var item = new Roo.bootstrap.panel.TabItem({
40405 closable : closable,
40408 this.addTabItem(item);
40410 item.setContent(content);
40416 * Returns the {@link Roo.TabPanelItem} with the specified id/index
40417 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
40418 * @return {Roo.TabPanelItem}
40420 getTab : function(id){
40421 return this.items[id];
40425 * Hides the {@link Roo.TabPanelItem} with the specified id/index
40426 * @param {String/Number} id The id or index of the TabPanelItem to hide.
40428 hideTab : function(id){
40429 var t = this.items[id];
40432 this.hiddenCount++;
40433 this.autoSizeTabs();
40438 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
40439 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
40441 unhideTab : function(id){
40442 var t = this.items[id];
40444 t.setHidden(false);
40445 this.hiddenCount--;
40446 this.autoSizeTabs();
40451 * Adds an existing {@link Roo.TabPanelItem}.
40452 * @param {Roo.TabPanelItem} item The TabPanelItem to add
40454 addTabItem : function(item)
40456 this.items[item.id] = item;
40457 this.items.push(item);
40458 this.autoSizeTabs();
40459 // if(this.resizeTabs){
40460 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
40461 // this.autoSizeTabs();
40463 // item.autoSize();
40468 * Removes a {@link Roo.TabPanelItem}.
40469 * @param {String/Number} id The id or index of the TabPanelItem to remove.
40471 removeTab : function(id){
40472 var items = this.items;
40473 var tab = items[id];
40474 if(!tab) { return; }
40475 var index = items.indexOf(tab);
40476 if(this.active == tab && items.length > 1){
40477 var newTab = this.getNextAvailable(index);
40482 this.stripEl.dom.removeChild(tab.pnode.dom);
40483 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
40484 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
40486 items.splice(index, 1);
40487 delete this.items[tab.id];
40488 tab.fireEvent("close", tab);
40489 tab.purgeListeners();
40490 this.autoSizeTabs();
40493 getNextAvailable : function(start){
40494 var items = this.items;
40496 // look for a next tab that will slide over to
40497 // replace the one being removed
40498 while(index < items.length){
40499 var item = items[++index];
40500 if(item && !item.isHidden()){
40504 // if one isn't found select the previous tab (on the left)
40507 var item = items[--index];
40508 if(item && !item.isHidden()){
40516 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
40517 * @param {String/Number} id The id or index of the TabPanelItem to disable.
40519 disableTab : function(id){
40520 var tab = this.items[id];
40521 if(tab && this.active != tab){
40527 * Enables a {@link Roo.TabPanelItem} that is disabled.
40528 * @param {String/Number} id The id or index of the TabPanelItem to enable.
40530 enableTab : function(id){
40531 var tab = this.items[id];
40536 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
40537 * @param {String/Number} id The id or index of the TabPanelItem to activate.
40538 * @return {Roo.TabPanelItem} The TabPanelItem.
40540 activate : function(id)
40542 //Roo.log('activite:' + id);
40544 var tab = this.items[id];
40548 if(tab == this.active || tab.disabled){
40552 this.fireEvent("beforetabchange", this, e, tab);
40553 if(e.cancel !== true && !tab.disabled){
40555 this.active.hide();
40557 this.active = this.items[id];
40558 this.active.show();
40559 this.fireEvent("tabchange", this, this.active);
40565 * Gets the active {@link Roo.TabPanelItem}.
40566 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
40568 getActiveTab : function(){
40569 return this.active;
40573 * Updates the tab body element to fit the height of the container element
40574 * for overflow scrolling
40575 * @param {Number} targetHeight (optional) Override the starting height from the elements height
40577 syncHeight : function(targetHeight){
40578 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
40579 var bm = this.bodyEl.getMargins();
40580 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
40581 this.bodyEl.setHeight(newHeight);
40585 onResize : function(){
40586 if(this.monitorResize){
40587 this.autoSizeTabs();
40592 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
40594 beginUpdate : function(){
40595 this.updating = true;
40599 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
40601 endUpdate : function(){
40602 this.updating = false;
40603 this.autoSizeTabs();
40607 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
40609 autoSizeTabs : function()
40611 var count = this.items.length;
40612 var vcount = count - this.hiddenCount;
40615 this.stripEl.hide();
40617 this.stripEl.show();
40620 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
40625 var w = Math.max(this.el.getWidth() - this.cpad, 10);
40626 var availWidth = Math.floor(w / vcount);
40627 var b = this.stripBody;
40628 if(b.getWidth() > w){
40629 var tabs = this.items;
40630 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
40631 if(availWidth < this.minTabWidth){
40632 /*if(!this.sleft){ // incomplete scrolling code
40633 this.createScrollButtons();
40636 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
40639 if(this.currentTabWidth < this.preferredTabWidth){
40640 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
40646 * Returns the number of tabs in this TabPanel.
40649 getCount : function(){
40650 return this.items.length;
40654 * Resizes all the tabs to the passed width
40655 * @param {Number} The new width
40657 setTabWidth : function(width){
40658 this.currentTabWidth = width;
40659 for(var i = 0, len = this.items.length; i < len; i++) {
40660 if(!this.items[i].isHidden()) {
40661 this.items[i].setWidth(width);
40667 * Destroys this TabPanel
40668 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
40670 destroy : function(removeEl){
40671 Roo.EventManager.removeResizeListener(this.onResize, this);
40672 for(var i = 0, len = this.items.length; i < len; i++){
40673 this.items[i].purgeListeners();
40675 if(removeEl === true){
40676 this.el.update("");
40681 createStrip : function(container)
40683 var strip = document.createElement("nav");
40684 strip.className = Roo.bootstrap.version == 4 ?
40685 "navbar-light bg-light" :
40686 "navbar navbar-default"; //"x-tabs-wrap";
40687 container.appendChild(strip);
40691 createStripList : function(strip)
40693 // div wrapper for retard IE
40694 // returns the "tr" element.
40695 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
40696 //'<div class="x-tabs-strip-wrap">'+
40697 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
40698 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
40699 return strip.firstChild; //.firstChild.firstChild.firstChild;
40701 createBody : function(container)
40703 var body = document.createElement("div");
40704 Roo.id(body, "tab-body");
40705 //Roo.fly(body).addClass("x-tabs-body");
40706 Roo.fly(body).addClass("tab-content");
40707 container.appendChild(body);
40710 createItemBody :function(bodyEl, id){
40711 var body = Roo.getDom(id);
40713 body = document.createElement("div");
40716 //Roo.fly(body).addClass("x-tabs-item-body");
40717 Roo.fly(body).addClass("tab-pane");
40718 bodyEl.insertBefore(body, bodyEl.firstChild);
40722 createStripElements : function(stripEl, text, closable, tpl)
40724 var td = document.createElement("li"); // was td..
40725 td.className = 'nav-item';
40727 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
40730 stripEl.appendChild(td);
40732 td.className = "x-tabs-closable";
40733 if(!this.closeTpl){
40734 this.closeTpl = new Roo.Template(
40735 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
40736 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
40737 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
40740 var el = this.closeTpl.overwrite(td, {"text": text});
40741 var close = el.getElementsByTagName("div")[0];
40742 var inner = el.getElementsByTagName("em")[0];
40743 return {"el": el, "close": close, "inner": inner};
40746 // not sure what this is..
40747 // if(!this.tabTpl){
40748 //this.tabTpl = new Roo.Template(
40749 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
40750 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
40752 // this.tabTpl = new Roo.Template(
40753 // '<a href="#">' +
40754 // '<span unselectable="on"' +
40755 // (this.disableTooltips ? '' : ' title="{text}"') +
40756 // ' >{text}</span></a>'
40762 var template = tpl || this.tabTpl || false;
40765 template = new Roo.Template(
40766 Roo.bootstrap.version == 4 ?
40768 '<a class="nav-link" href="#" unselectable="on"' +
40769 (this.disableTooltips ? '' : ' title="{text}"') +
40772 '<a class="nav-link" href="#">' +
40773 '<span unselectable="on"' +
40774 (this.disableTooltips ? '' : ' title="{text}"') +
40775 ' >{text}</span></a>'
40780 switch (typeof(template)) {
40784 template = new Roo.Template(template);
40790 var el = template.overwrite(td, {"text": text});
40792 var inner = el.getElementsByTagName("span")[0];
40794 return {"el": el, "inner": inner};
40802 * @class Roo.TabPanelItem
40803 * @extends Roo.util.Observable
40804 * Represents an individual item (tab plus body) in a TabPanel.
40805 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
40806 * @param {String} id The id of this TabPanelItem
40807 * @param {String} text The text for the tab of this TabPanelItem
40808 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
40810 Roo.bootstrap.panel.TabItem = function(config){
40812 * The {@link Roo.TabPanel} this TabPanelItem belongs to
40813 * @type Roo.TabPanel
40815 this.tabPanel = config.panel;
40817 * The id for this TabPanelItem
40820 this.id = config.id;
40822 this.disabled = false;
40824 this.text = config.text;
40826 this.loaded = false;
40827 this.closable = config.closable;
40830 * The body element for this TabPanelItem.
40831 * @type Roo.Element
40833 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
40834 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
40835 this.bodyEl.setStyle("display", "block");
40836 this.bodyEl.setStyle("zoom", "1");
40837 //this.hideAction();
40839 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
40841 this.el = Roo.get(els.el);
40842 this.inner = Roo.get(els.inner, true);
40843 this.textEl = Roo.bootstrap.version == 4 ?
40844 this.el : Roo.get(this.el.dom.firstChild, true);
40846 this.pnode = this.linode = Roo.get(els.el.parentNode, true);
40847 this.status_node = Roo.bootstrap.version == 4 ? this.el : this.linode;
40850 // this.el.on("mousedown", this.onTabMouseDown, this);
40851 this.el.on("click", this.onTabClick, this);
40853 if(config.closable){
40854 var c = Roo.get(els.close, true);
40855 c.dom.title = this.closeText;
40856 c.addClassOnOver("close-over");
40857 c.on("click", this.closeClick, this);
40863 * Fires when this tab becomes the active tab.
40864 * @param {Roo.TabPanel} tabPanel The parent TabPanel
40865 * @param {Roo.TabPanelItem} this
40869 * @event beforeclose
40870 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
40871 * @param {Roo.TabPanelItem} this
40872 * @param {Object} e Set cancel to true on this object to cancel the close.
40874 "beforeclose": true,
40877 * Fires when this tab is closed.
40878 * @param {Roo.TabPanelItem} this
40882 * @event deactivate
40883 * Fires when this tab is no longer the active tab.
40884 * @param {Roo.TabPanel} tabPanel The parent TabPanel
40885 * @param {Roo.TabPanelItem} this
40887 "deactivate" : true
40889 this.hidden = false;
40891 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
40894 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
40896 purgeListeners : function(){
40897 Roo.util.Observable.prototype.purgeListeners.call(this);
40898 this.el.removeAllListeners();
40901 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
40904 this.status_node.addClass("active");
40907 this.tabPanel.stripWrap.repaint();
40909 this.fireEvent("activate", this.tabPanel, this);
40913 * Returns true if this tab is the active tab.
40914 * @return {Boolean}
40916 isActive : function(){
40917 return this.tabPanel.getActiveTab() == this;
40921 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
40924 this.status_node.removeClass("active");
40926 this.fireEvent("deactivate", this.tabPanel, this);
40929 hideAction : function(){
40930 this.bodyEl.hide();
40931 this.bodyEl.setStyle("position", "absolute");
40932 this.bodyEl.setLeft("-20000px");
40933 this.bodyEl.setTop("-20000px");
40936 showAction : function(){
40937 this.bodyEl.setStyle("position", "relative");
40938 this.bodyEl.setTop("");
40939 this.bodyEl.setLeft("");
40940 this.bodyEl.show();
40944 * Set the tooltip for the tab.
40945 * @param {String} tooltip The tab's tooltip
40947 setTooltip : function(text){
40948 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
40949 this.textEl.dom.qtip = text;
40950 this.textEl.dom.removeAttribute('title');
40952 this.textEl.dom.title = text;
40956 onTabClick : function(e){
40957 e.preventDefault();
40958 this.tabPanel.activate(this.id);
40961 onTabMouseDown : function(e){
40962 e.preventDefault();
40963 this.tabPanel.activate(this.id);
40966 getWidth : function(){
40967 return this.inner.getWidth();
40970 setWidth : function(width){
40971 var iwidth = width - this.linode.getPadding("lr");
40972 this.inner.setWidth(iwidth);
40973 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
40974 this.linode.setWidth(width);
40978 * Show or hide the tab
40979 * @param {Boolean} hidden True to hide or false to show.
40981 setHidden : function(hidden){
40982 this.hidden = hidden;
40983 this.linode.setStyle("display", hidden ? "none" : "");
40987 * Returns true if this tab is "hidden"
40988 * @return {Boolean}
40990 isHidden : function(){
40991 return this.hidden;
40995 * Returns the text for this tab
40998 getText : function(){
41002 autoSize : function(){
41003 //this.el.beginMeasure();
41004 this.textEl.setWidth(1);
41006 * #2804 [new] Tabs in Roojs
41007 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
41009 //this.setWidth(this.textEl.dom.scrollWidth+this.linode.getPadding("lr")+this.inner.getPadding("lr") + 2);
41010 //this.el.endMeasure();
41014 * Sets the text for the tab (Note: this also sets the tooltip text)
41015 * @param {String} text The tab's text and tooltip
41017 setText : function(text){
41019 this.textEl.update(text);
41020 this.setTooltip(text);
41021 //if(!this.tabPanel.resizeTabs){
41022 // this.autoSize();
41026 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
41028 activate : function(){
41029 this.tabPanel.activate(this.id);
41033 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
41035 disable : function(){
41036 if(this.tabPanel.active != this){
41037 this.disabled = true;
41038 this.status_node.addClass("disabled");
41043 * Enables this TabPanelItem if it was previously disabled.
41045 enable : function(){
41046 this.disabled = false;
41047 this.status_node.removeClass("disabled");
41051 * Sets the content for this TabPanelItem.
41052 * @param {String} content The content
41053 * @param {Boolean} loadScripts true to look for and load scripts
41055 setContent : function(content, loadScripts){
41056 this.bodyEl.update(content, loadScripts);
41060 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
41061 * @return {Roo.UpdateManager} The UpdateManager
41063 getUpdateManager : function(){
41064 return this.bodyEl.getUpdateManager();
41068 * Set a URL to be used to load the content for this TabPanelItem.
41069 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
41070 * @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)
41071 * @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)
41072 * @return {Roo.UpdateManager} The UpdateManager
41074 setUrl : function(url, params, loadOnce){
41075 if(this.refreshDelegate){
41076 this.un('activate', this.refreshDelegate);
41078 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
41079 this.on("activate", this.refreshDelegate);
41080 return this.bodyEl.getUpdateManager();
41084 _handleRefresh : function(url, params, loadOnce){
41085 if(!loadOnce || !this.loaded){
41086 var updater = this.bodyEl.getUpdateManager();
41087 updater.update(url, params, this._setLoaded.createDelegate(this));
41092 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
41093 * Will fail silently if the setUrl method has not been called.
41094 * This does not activate the panel, just updates its content.
41096 refresh : function(){
41097 if(this.refreshDelegate){
41098 this.loaded = false;
41099 this.refreshDelegate();
41104 _setLoaded : function(){
41105 this.loaded = true;
41109 closeClick : function(e){
41112 this.fireEvent("beforeclose", this, o);
41113 if(o.cancel !== true){
41114 this.tabPanel.removeTab(this.id);
41118 * The text displayed in the tooltip for the close icon.
41121 closeText : "Close this tab"
41124 * This script refer to:
41125 * Title: International Telephone Input
41126 * Author: Jack O'Connor
41127 * Code version: v12.1.12
41128 * Availability: https://github.com/jackocnr/intl-tel-input.git
41131 Roo.bootstrap.PhoneInputData = function() {
41134 "Afghanistan (افغانستان)",
41139 "Albania (Shqipëri)",
41144 "Algeria (الجزائر)",
41169 "Antigua and Barbuda",
41179 "Armenia (Հայաստան)",
41195 "Austria (Österreich)",
41200 "Azerbaijan (Azərbaycan)",
41210 "Bahrain (البحرين)",
41215 "Bangladesh (বাংলাদেশ)",
41225 "Belarus (Беларусь)",
41230 "Belgium (België)",
41260 "Bosnia and Herzegovina (Босна и Херцеговина)",
41275 "British Indian Ocean Territory",
41280 "British Virgin Islands",
41290 "Bulgaria (България)",
41300 "Burundi (Uburundi)",
41305 "Cambodia (កម្ពុជា)",
41310 "Cameroon (Cameroun)",
41319 ["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"]
41322 "Cape Verde (Kabu Verdi)",
41327 "Caribbean Netherlands",
41338 "Central African Republic (République centrafricaine)",
41358 "Christmas Island",
41364 "Cocos (Keeling) Islands",
41375 "Comoros (جزر القمر)",
41380 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
41385 "Congo (Republic) (Congo-Brazzaville)",
41405 "Croatia (Hrvatska)",
41426 "Czech Republic (Česká republika)",
41431 "Denmark (Danmark)",
41446 "Dominican Republic (República Dominicana)",
41450 ["809", "829", "849"]
41468 "Equatorial Guinea (Guinea Ecuatorial)",
41488 "Falkland Islands (Islas Malvinas)",
41493 "Faroe Islands (Føroyar)",
41514 "French Guiana (Guyane française)",
41519 "French Polynesia (Polynésie française)",
41534 "Georgia (საქართველო)",
41539 "Germany (Deutschland)",
41559 "Greenland (Kalaallit Nunaat)",
41596 "Guinea-Bissau (Guiné Bissau)",
41621 "Hungary (Magyarország)",
41626 "Iceland (Ísland)",
41646 "Iraq (العراق)",
41662 "Israel (ישראל)",
41689 "Jordan (الأردن)",
41694 "Kazakhstan (Казахстан)",
41715 "Kuwait (الكويت)",
41720 "Kyrgyzstan (Кыргызстан)",
41730 "Latvia (Latvija)",
41735 "Lebanon (لبنان)",
41750 "Libya (ليبيا)",
41760 "Lithuania (Lietuva)",
41775 "Macedonia (FYROM) (Македонија)",
41780 "Madagascar (Madagasikara)",
41810 "Marshall Islands",
41820 "Mauritania (موريتانيا)",
41825 "Mauritius (Moris)",
41846 "Moldova (Republica Moldova)",
41856 "Mongolia (Монгол)",
41861 "Montenegro (Crna Gora)",
41871 "Morocco (المغرب)",
41877 "Mozambique (Moçambique)",
41882 "Myanmar (Burma) (မြန်မာ)",
41887 "Namibia (Namibië)",
41902 "Netherlands (Nederland)",
41907 "New Caledonia (Nouvelle-Calédonie)",
41942 "North Korea (조선 민주주의 인민 공화국)",
41947 "Northern Mariana Islands",
41963 "Pakistan (پاکستان)",
41973 "Palestine (فلسطين)",
41983 "Papua New Guinea",
42025 "Réunion (La Réunion)",
42031 "Romania (România)",
42047 "Saint Barthélemy",
42058 "Saint Kitts and Nevis",
42068 "Saint Martin (Saint-Martin (partie française))",
42074 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
42079 "Saint Vincent and the Grenadines",
42094 "São Tomé and Príncipe (São Tomé e Príncipe)",
42099 "Saudi Arabia (المملكة العربية السعودية)",
42104 "Senegal (Sénégal)",
42134 "Slovakia (Slovensko)",
42139 "Slovenia (Slovenija)",
42149 "Somalia (Soomaaliya)",
42159 "South Korea (대한민국)",
42164 "South Sudan (جنوب السودان)",
42174 "Sri Lanka (ශ්රී ලංකාව)",
42179 "Sudan (السودان)",
42189 "Svalbard and Jan Mayen",
42200 "Sweden (Sverige)",
42205 "Switzerland (Schweiz)",
42210 "Syria (سوريا)",
42255 "Trinidad and Tobago",
42260 "Tunisia (تونس)",
42265 "Turkey (Türkiye)",
42275 "Turks and Caicos Islands",
42285 "U.S. Virgin Islands",
42295 "Ukraine (Україна)",
42300 "United Arab Emirates (الإمارات العربية المتحدة)",
42322 "Uzbekistan (Oʻzbekiston)",
42332 "Vatican City (Città del Vaticano)",
42343 "Vietnam (Việt Nam)",
42348 "Wallis and Futuna (Wallis-et-Futuna)",
42353 "Western Sahara (الصحراء الغربية)",
42359 "Yemen (اليمن)",
42383 * This script refer to:
42384 * Title: International Telephone Input
42385 * Author: Jack O'Connor
42386 * Code version: v12.1.12
42387 * Availability: https://github.com/jackocnr/intl-tel-input.git
42391 * @class Roo.bootstrap.PhoneInput
42392 * @extends Roo.bootstrap.TriggerField
42393 * An input with International dial-code selection
42395 * @cfg {String} defaultDialCode default '+852'
42396 * @cfg {Array} preferedCountries default []
42399 * Create a new PhoneInput.
42400 * @param {Object} config Configuration options
42403 Roo.bootstrap.PhoneInput = function(config) {
42404 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
42407 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
42409 listWidth: undefined,
42411 selectedClass: 'active',
42413 invalidClass : "has-warning",
42415 validClass: 'has-success',
42417 allowed: '0123456789',
42422 * @cfg {String} defaultDialCode The default dial code when initializing the input
42424 defaultDialCode: '+852',
42427 * @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
42429 preferedCountries: false,
42431 getAutoCreate : function()
42433 var data = Roo.bootstrap.PhoneInputData();
42434 var align = this.labelAlign || this.parentLabelAlign();
42437 this.allCountries = [];
42438 this.dialCodeMapping = [];
42440 for (var i = 0; i < data.length; i++) {
42442 this.allCountries[i] = {
42446 priority: c[3] || 0,
42447 areaCodes: c[4] || null
42449 this.dialCodeMapping[c[2]] = {
42452 priority: c[3] || 0,
42453 areaCodes: c[4] || null
42465 // type: 'number', -- do not use number - we get the flaky up/down arrows.
42466 maxlength: this.max_length,
42467 cls : 'form-control tel-input',
42468 autocomplete: 'new-password'
42471 var hiddenInput = {
42474 cls: 'hidden-tel-input'
42478 hiddenInput.name = this.name;
42481 if (this.disabled) {
42482 input.disabled = true;
42485 var flag_container = {
42502 cls: this.hasFeedback ? 'has-feedback' : '',
42508 cls: 'dial-code-holder',
42515 cls: 'roo-select2-container input-group',
42522 if (this.fieldLabel.length) {
42525 tooltip: 'This field is required'
42531 cls: 'control-label',
42537 html: this.fieldLabel
42540 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
42546 if(this.indicatorpos == 'right') {
42547 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
42554 if(align == 'left') {
42562 if(this.labelWidth > 12){
42563 label.style = "width: " + this.labelWidth + 'px';
42565 if(this.labelWidth < 13 && this.labelmd == 0){
42566 this.labelmd = this.labelWidth;
42568 if(this.labellg > 0){
42569 label.cls += ' col-lg-' + this.labellg;
42570 input.cls += ' col-lg-' + (12 - this.labellg);
42572 if(this.labelmd > 0){
42573 label.cls += ' col-md-' + this.labelmd;
42574 container.cls += ' col-md-' + (12 - this.labelmd);
42576 if(this.labelsm > 0){
42577 label.cls += ' col-sm-' + this.labelsm;
42578 container.cls += ' col-sm-' + (12 - this.labelsm);
42580 if(this.labelxs > 0){
42581 label.cls += ' col-xs-' + this.labelxs;
42582 container.cls += ' col-xs-' + (12 - this.labelxs);
42592 var settings = this;
42594 ['xs','sm','md','lg'].map(function(size){
42595 if (settings[size]) {
42596 cfg.cls += ' col-' + size + '-' + settings[size];
42600 this.store = new Roo.data.Store({
42601 proxy : new Roo.data.MemoryProxy({}),
42602 reader : new Roo.data.JsonReader({
42613 'name' : 'dialCode',
42617 'name' : 'priority',
42621 'name' : 'areaCodes',
42628 if(!this.preferedCountries) {
42629 this.preferedCountries = [
42636 var p = this.preferedCountries.reverse();
42639 for (var i = 0; i < p.length; i++) {
42640 for (var j = 0; j < this.allCountries.length; j++) {
42641 if(this.allCountries[j].iso2 == p[i]) {
42642 var t = this.allCountries[j];
42643 this.allCountries.splice(j,1);
42644 this.allCountries.unshift(t);
42650 this.store.proxy.data = {
42652 data: this.allCountries
42658 initEvents : function()
42661 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
42663 this.indicator = this.indicatorEl();
42664 this.flag = this.flagEl();
42665 this.dialCodeHolder = this.dialCodeHolderEl();
42667 this.trigger = this.el.select('div.flag-box',true).first();
42668 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
42673 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
42674 _this.list.setWidth(lw);
42677 this.list.on('mouseover', this.onViewOver, this);
42678 this.list.on('mousemove', this.onViewMove, this);
42679 this.inputEl().on("keyup", this.onKeyUp, this);
42680 this.inputEl().on("keypress", this.onKeyPress, this);
42682 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
42684 this.view = new Roo.View(this.list, this.tpl, {
42685 singleSelect:true, store: this.store, selectedClass: this.selectedClass
42688 this.view.on('click', this.onViewClick, this);
42689 this.setValue(this.defaultDialCode);
42692 onTriggerClick : function(e)
42694 Roo.log('trigger click');
42699 if(this.isExpanded()){
42701 this.hasFocus = false;
42703 this.store.load({});
42704 this.hasFocus = true;
42709 isExpanded : function()
42711 return this.list.isVisible();
42714 collapse : function()
42716 if(!this.isExpanded()){
42720 Roo.get(document).un('mousedown', this.collapseIf, this);
42721 Roo.get(document).un('mousewheel', this.collapseIf, this);
42722 this.fireEvent('collapse', this);
42726 expand : function()
42730 if(this.isExpanded() || !this.hasFocus){
42734 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
42735 this.list.setWidth(lw);
42738 this.restrictHeight();
42740 Roo.get(document).on('mousedown', this.collapseIf, this);
42741 Roo.get(document).on('mousewheel', this.collapseIf, this);
42743 this.fireEvent('expand', this);
42746 restrictHeight : function()
42748 this.list.alignTo(this.inputEl(), this.listAlign);
42749 this.list.alignTo(this.inputEl(), this.listAlign);
42752 onViewOver : function(e, t)
42754 if(this.inKeyMode){
42757 var item = this.view.findItemFromChild(t);
42760 var index = this.view.indexOf(item);
42761 this.select(index, false);
42766 onViewClick : function(view, doFocus, el, e)
42768 var index = this.view.getSelectedIndexes()[0];
42770 var r = this.store.getAt(index);
42773 this.onSelect(r, index);
42775 if(doFocus !== false && !this.blockFocus){
42776 this.inputEl().focus();
42780 onViewMove : function(e, t)
42782 this.inKeyMode = false;
42785 select : function(index, scrollIntoView)
42787 this.selectedIndex = index;
42788 this.view.select(index);
42789 if(scrollIntoView !== false){
42790 var el = this.view.getNode(index);
42792 this.list.scrollChildIntoView(el, false);
42797 createList : function()
42799 this.list = Roo.get(document.body).createChild({
42801 cls: 'typeahead typeahead-long dropdown-menu tel-list',
42802 style: 'display:none'
42805 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
42808 collapseIf : function(e)
42810 var in_combo = e.within(this.el);
42811 var in_list = e.within(this.list);
42812 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
42814 if (in_combo || in_list || is_list) {
42820 onSelect : function(record, index)
42822 if(this.fireEvent('beforeselect', this, record, index) !== false){
42824 this.setFlagClass(record.data.iso2);
42825 this.setDialCode(record.data.dialCode);
42826 this.hasFocus = false;
42828 this.fireEvent('select', this, record, index);
42832 flagEl : function()
42834 var flag = this.el.select('div.flag',true).first();
42841 dialCodeHolderEl : function()
42843 var d = this.el.select('input.dial-code-holder',true).first();
42850 setDialCode : function(v)
42852 this.dialCodeHolder.dom.value = '+'+v;
42855 setFlagClass : function(n)
42857 this.flag.dom.className = 'flag '+n;
42860 getValue : function()
42862 var v = this.inputEl().getValue();
42863 if(this.dialCodeHolder) {
42864 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
42869 setValue : function(v)
42871 var d = this.getDialCode(v);
42873 //invalid dial code
42874 if(v.length == 0 || !d || d.length == 0) {
42876 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
42877 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
42883 this.setFlagClass(this.dialCodeMapping[d].iso2);
42884 this.setDialCode(d);
42885 this.inputEl().dom.value = v.replace('+'+d,'');
42886 this.hiddenEl().dom.value = this.getValue();
42891 getDialCode : function(v)
42895 if (v.length == 0) {
42896 return this.dialCodeHolder.dom.value;
42900 if (v.charAt(0) != "+") {
42903 var numericChars = "";
42904 for (var i = 1; i < v.length; i++) {
42905 var c = v.charAt(i);
42908 if (this.dialCodeMapping[numericChars]) {
42909 dialCode = v.substr(1, i);
42911 if (numericChars.length == 4) {
42921 this.setValue(this.defaultDialCode);
42925 hiddenEl : function()
42927 return this.el.select('input.hidden-tel-input',true).first();
42930 // after setting val
42931 onKeyUp : function(e){
42932 this.setValue(this.getValue());
42935 onKeyPress : function(e){
42936 if(this.allowed.indexOf(String.fromCharCode(e.getCharCode())) === -1){
42943 * @class Roo.bootstrap.MoneyField
42944 * @extends Roo.bootstrap.ComboBox
42945 * Bootstrap MoneyField class
42948 * Create a new MoneyField.
42949 * @param {Object} config Configuration options
42952 Roo.bootstrap.MoneyField = function(config) {
42954 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
42958 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
42961 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
42963 allowDecimals : true,
42965 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
42967 decimalSeparator : ".",
42969 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
42971 decimalPrecision : 0,
42973 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
42975 allowNegative : true,
42977 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
42981 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
42983 minValue : Number.NEGATIVE_INFINITY,
42985 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
42987 maxValue : Number.MAX_VALUE,
42989 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
42991 minText : "The minimum value for this field is {0}",
42993 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
42995 maxText : "The maximum value for this field is {0}",
42997 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
42998 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
43000 nanText : "{0} is not a valid number",
43002 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
43006 * @cfg {String} defaults currency of the MoneyField
43007 * value should be in lkey
43009 defaultCurrency : false,
43011 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
43013 thousandsDelimiter : false,
43015 * @cfg {Number} max_length Maximum input field length allowed (defaults to Number.MAX_VALUE)
43026 getAutoCreate : function()
43028 var align = this.labelAlign || this.parentLabelAlign();
43040 cls : 'form-control roo-money-amount-input',
43041 autocomplete: 'new-password'
43044 var hiddenInput = {
43048 cls: 'hidden-number-input'
43051 if(this.max_length) {
43052 input.maxlength = this.max_length;
43056 hiddenInput.name = this.name;
43059 if (this.disabled) {
43060 input.disabled = true;
43063 var clg = 12 - this.inputlg;
43064 var cmd = 12 - this.inputmd;
43065 var csm = 12 - this.inputsm;
43066 var cxs = 12 - this.inputxs;
43070 cls : 'row roo-money-field',
43074 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
43078 cls: 'roo-select2-container input-group',
43082 cls : 'form-control roo-money-currency-input',
43083 autocomplete: 'new-password',
43085 name : this.currencyName
43089 cls : 'input-group-addon',
43103 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
43107 cls: this.hasFeedback ? 'has-feedback' : '',
43118 if (this.fieldLabel.length) {
43121 tooltip: 'This field is required'
43127 cls: 'control-label',
43133 html: this.fieldLabel
43136 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
43142 if(this.indicatorpos == 'right') {
43143 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
43150 if(align == 'left') {
43158 if(this.labelWidth > 12){
43159 label.style = "width: " + this.labelWidth + 'px';
43161 if(this.labelWidth < 13 && this.labelmd == 0){
43162 this.labelmd = this.labelWidth;
43164 if(this.labellg > 0){
43165 label.cls += ' col-lg-' + this.labellg;
43166 input.cls += ' col-lg-' + (12 - this.labellg);
43168 if(this.labelmd > 0){
43169 label.cls += ' col-md-' + this.labelmd;
43170 container.cls += ' col-md-' + (12 - this.labelmd);
43172 if(this.labelsm > 0){
43173 label.cls += ' col-sm-' + this.labelsm;
43174 container.cls += ' col-sm-' + (12 - this.labelsm);
43176 if(this.labelxs > 0){
43177 label.cls += ' col-xs-' + this.labelxs;
43178 container.cls += ' col-xs-' + (12 - this.labelxs);
43189 var settings = this;
43191 ['xs','sm','md','lg'].map(function(size){
43192 if (settings[size]) {
43193 cfg.cls += ' col-' + size + '-' + settings[size];
43200 initEvents : function()
43202 this.indicator = this.indicatorEl();
43204 this.initCurrencyEvent();
43206 this.initNumberEvent();
43209 initCurrencyEvent : function()
43212 throw "can not find store for combo";
43215 this.store = Roo.factory(this.store, Roo.data);
43216 this.store.parent = this;
43220 this.triggerEl = this.el.select('.input-group-addon', true).first();
43222 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
43227 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
43228 _this.list.setWidth(lw);
43231 this.list.on('mouseover', this.onViewOver, this);
43232 this.list.on('mousemove', this.onViewMove, this);
43233 this.list.on('scroll', this.onViewScroll, this);
43236 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
43239 this.view = new Roo.View(this.list, this.tpl, {
43240 singleSelect:true, store: this.store, selectedClass: this.selectedClass
43243 this.view.on('click', this.onViewClick, this);
43245 this.store.on('beforeload', this.onBeforeLoad, this);
43246 this.store.on('load', this.onLoad, this);
43247 this.store.on('loadexception', this.onLoadException, this);
43249 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
43250 "up" : function(e){
43251 this.inKeyMode = true;
43255 "down" : function(e){
43256 if(!this.isExpanded()){
43257 this.onTriggerClick();
43259 this.inKeyMode = true;
43264 "enter" : function(e){
43267 if(this.fireEvent("specialkey", this, e)){
43268 this.onViewClick(false);
43274 "esc" : function(e){
43278 "tab" : function(e){
43281 if(this.fireEvent("specialkey", this, e)){
43282 this.onViewClick(false);
43290 doRelay : function(foo, bar, hname){
43291 if(hname == 'down' || this.scope.isExpanded()){
43292 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
43300 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
43304 initNumberEvent : function(e)
43306 this.inputEl().on("keydown" , this.fireKey, this);
43307 this.inputEl().on("focus", this.onFocus, this);
43308 this.inputEl().on("blur", this.onBlur, this);
43310 this.inputEl().relayEvent('keyup', this);
43312 if(this.indicator){
43313 this.indicator.addClass('invisible');
43316 this.originalValue = this.getValue();
43318 if(this.validationEvent == 'keyup'){
43319 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
43320 this.inputEl().on('keyup', this.filterValidation, this);
43322 else if(this.validationEvent !== false){
43323 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
43326 if(this.selectOnFocus){
43327 this.on("focus", this.preFocus, this);
43330 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
43331 this.inputEl().on("keypress", this.filterKeys, this);
43333 this.inputEl().relayEvent('keypress', this);
43336 var allowed = "0123456789";
43338 if(this.allowDecimals){
43339 allowed += this.decimalSeparator;
43342 if(this.allowNegative){
43346 if(this.thousandsDelimiter) {
43350 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
43352 var keyPress = function(e){
43354 var k = e.getKey();
43356 var c = e.getCharCode();
43359 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
43360 allowed.indexOf(String.fromCharCode(c)) === -1
43366 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
43370 if(allowed.indexOf(String.fromCharCode(c)) === -1){
43375 this.inputEl().on("keypress", keyPress, this);
43379 onTriggerClick : function(e)
43386 this.loadNext = false;
43388 if(this.isExpanded()){
43393 this.hasFocus = true;
43395 if(this.triggerAction == 'all') {
43396 this.doQuery(this.allQuery, true);
43400 this.doQuery(this.getRawValue());
43403 getCurrency : function()
43405 var v = this.currencyEl().getValue();
43410 restrictHeight : function()
43412 this.list.alignTo(this.currencyEl(), this.listAlign);
43413 this.list.alignTo(this.currencyEl(), this.listAlign);
43416 onViewClick : function(view, doFocus, el, e)
43418 var index = this.view.getSelectedIndexes()[0];
43420 var r = this.store.getAt(index);
43423 this.onSelect(r, index);
43427 onSelect : function(record, index){
43429 if(this.fireEvent('beforeselect', this, record, index) !== false){
43431 this.setFromCurrencyData(index > -1 ? record.data : false);
43435 this.fireEvent('select', this, record, index);
43439 setFromCurrencyData : function(o)
43443 this.lastCurrency = o;
43445 if (this.currencyField) {
43446 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
43448 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
43451 this.lastSelectionText = currency;
43453 //setting default currency
43454 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
43455 this.setCurrency(this.defaultCurrency);
43459 this.setCurrency(currency);
43462 setFromData : function(o)
43466 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
43468 this.setFromCurrencyData(c);
43473 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
43475 Roo.log('no value set for '+ (this.name ? this.name : this.id));
43478 this.setValue(value);
43482 setCurrency : function(v)
43484 this.currencyValue = v;
43487 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
43492 setValue : function(v)
43494 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
43500 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
43502 this.inputEl().dom.value = (v == '') ? '' :
43503 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
43505 if(!this.allowZero && v === '0') {
43506 this.hiddenEl().dom.value = '';
43507 this.inputEl().dom.value = '';
43514 getRawValue : function()
43516 var v = this.inputEl().getValue();
43521 getValue : function()
43523 return this.fixPrecision(this.parseValue(this.getRawValue()));
43526 parseValue : function(value)
43528 if(this.thousandsDelimiter) {
43530 r = new RegExp(",", "g");
43531 value = value.replace(r, "");
43534 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
43535 return isNaN(value) ? '' : value;
43539 fixPrecision : function(value)
43541 if(this.thousandsDelimiter) {
43543 r = new RegExp(",", "g");
43544 value = value.replace(r, "");
43547 var nan = isNaN(value);
43549 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
43550 return nan ? '' : value;
43552 return parseFloat(value).toFixed(this.decimalPrecision);
43555 decimalPrecisionFcn : function(v)
43557 return Math.floor(v);
43560 validateValue : function(value)
43562 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
43566 var num = this.parseValue(value);
43569 this.markInvalid(String.format(this.nanText, value));
43573 if(num < this.minValue){
43574 this.markInvalid(String.format(this.minText, this.minValue));
43578 if(num > this.maxValue){
43579 this.markInvalid(String.format(this.maxText, this.maxValue));
43586 validate : function()
43588 if(this.disabled || this.allowBlank){
43593 var currency = this.getCurrency();
43595 if(this.validateValue(this.getRawValue()) && currency.length){
43600 this.markInvalid();
43604 getName: function()
43609 beforeBlur : function()
43615 var v = this.parseValue(this.getRawValue());
43622 onBlur : function()
43626 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
43627 //this.el.removeClass(this.focusClass);
43630 this.hasFocus = false;
43632 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
43636 var v = this.getValue();
43638 if(String(v) !== String(this.startValue)){
43639 this.fireEvent('change', this, v, this.startValue);
43642 this.fireEvent("blur", this);
43645 inputEl : function()
43647 return this.el.select('.roo-money-amount-input', true).first();
43650 currencyEl : function()
43652 return this.el.select('.roo-money-currency-input', true).first();
43655 hiddenEl : function()
43657 return this.el.select('input.hidden-number-input',true).first();
43661 * @class Roo.bootstrap.BezierSignature
43662 * @extends Roo.bootstrap.Component
43663 * Bootstrap BezierSignature class
43664 * This script refer to:
43665 * Title: Signature Pad
43667 * Availability: https://github.com/szimek/signature_pad
43670 * Create a new BezierSignature
43671 * @param {Object} config The config object
43674 Roo.bootstrap.BezierSignature = function(config){
43675 Roo.bootstrap.BezierSignature.superclass.constructor.call(this, config);
43681 Roo.extend(Roo.bootstrap.BezierSignature, Roo.bootstrap.Component,
43688 mouse_btn_down: true,
43691 * @cfg {int} canvas height
43693 canvas_height: '200px',
43696 * @cfg {float|function} Radius of a single dot.
43701 * @cfg {float} Minimum width of a line. Defaults to 0.5.
43706 * @cfg {float} Maximum width of a line. Defaults to 2.5.
43711 * @cfg {integer} Draw the next point at most once per every x milliseconds. Set it to 0 to turn off throttling. Defaults to 16.
43716 * @cfg {integer} Add the next point only if the previous one is farther than x pixels. Defaults to 5.
43721 * @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.
43723 bg_color: 'rgba(0, 0, 0, 0)',
43726 * @cfg {string} Color used to draw the lines. Can be any color format accepted by context.fillStyle. Defaults to "black".
43728 dot_color: 'black',
43731 * @cfg {float} Weight used to modify new velocity based on the previous velocity. Defaults to 0.7.
43733 velocity_filter_weight: 0.7,
43736 * @cfg {function} Callback when stroke begin.
43741 * @cfg {function} Callback when stroke end.
43745 getAutoCreate : function()
43747 var cls = 'roo-signature column';
43750 cls += ' ' + this.cls;
43760 for(var i = 0; i < col_sizes.length; i++) {
43761 if(this[col_sizes[i]]) {
43762 cls += " col-"+col_sizes[i]+"-"+this[col_sizes[i]];
43772 cls: 'roo-signature-body',
43776 cls: 'roo-signature-body-canvas',
43777 height: this.canvas_height,
43778 width: this.canvas_width
43785 style: 'display: none'
43793 initEvents: function()
43795 Roo.bootstrap.BezierSignature.superclass.initEvents.call(this);
43797 var canvas = this.canvasEl();
43799 // mouse && touch event swapping...
43800 canvas.dom.style.touchAction = 'none';
43801 canvas.dom.style.msTouchAction = 'none';
43803 this.mouse_btn_down = false;
43804 canvas.on('mousedown', this._handleMouseDown, this);
43805 canvas.on('mousemove', this._handleMouseMove, this);
43806 Roo.select('html').first().on('mouseup', this._handleMouseUp, this);
43808 if (window.PointerEvent) {
43809 canvas.on('pointerdown', this._handleMouseDown, this);
43810 canvas.on('pointermove', this._handleMouseMove, this);
43811 Roo.select('html').first().on('pointerup', this._handleMouseUp, this);
43814 if ('ontouchstart' in window) {
43815 canvas.on('touchstart', this._handleTouchStart, this);
43816 canvas.on('touchmove', this._handleTouchMove, this);
43817 canvas.on('touchend', this._handleTouchEnd, this);
43820 Roo.EventManager.onWindowResize(this.resize, this, true);
43822 // file input event
43823 this.fileEl().on('change', this.uploadImage, this);
43830 resize: function(){
43832 var canvas = this.canvasEl().dom;
43833 var ctx = this.canvasElCtx();
43834 var img_data = false;
43836 if(canvas.width > 0) {
43837 var img_data = ctx.getImageData(0, 0, canvas.width, canvas.height);
43839 // setting canvas width will clean img data
43842 var style = window.getComputedStyle ?
43843 getComputedStyle(this.el.dom, null) : this.el.dom.currentStyle;
43845 var padding_left = parseInt(style.paddingLeft) || 0;
43846 var padding_right = parseInt(style.paddingRight) || 0;
43848 canvas.width = this.el.dom.clientWidth - padding_left - padding_right;
43851 ctx.putImageData(img_data, 0, 0);
43855 _handleMouseDown: function(e)
43857 if (e.browserEvent.which === 1) {
43858 this.mouse_btn_down = true;
43859 this.strokeBegin(e);
43863 _handleMouseMove: function (e)
43865 if (this.mouse_btn_down) {
43866 this.strokeMoveUpdate(e);
43870 _handleMouseUp: function (e)
43872 if (e.browserEvent.which === 1 && this.mouse_btn_down) {
43873 this.mouse_btn_down = false;
43878 _handleTouchStart: function (e) {
43880 e.preventDefault();
43881 if (e.browserEvent.targetTouches.length === 1) {
43882 // var touch = e.browserEvent.changedTouches[0];
43883 // this.strokeBegin(touch);
43885 this.strokeBegin(e); // assume e catching the correct xy...
43889 _handleTouchMove: function (e) {
43890 e.preventDefault();
43891 // var touch = event.targetTouches[0];
43892 // _this._strokeMoveUpdate(touch);
43893 this.strokeMoveUpdate(e);
43896 _handleTouchEnd: function (e) {
43897 var wasCanvasTouched = e.target === this.canvasEl().dom;
43898 if (wasCanvasTouched) {
43899 e.preventDefault();
43900 // var touch = event.changedTouches[0];
43901 // _this._strokeEnd(touch);
43906 reset: function () {
43907 this._lastPoints = [];
43908 this._lastVelocity = 0;
43909 this._lastWidth = (this.min_width + this.max_width) / 2;
43910 this.canvasElCtx().fillStyle = this.dot_color;
43913 strokeMoveUpdate: function(e)
43915 this.strokeUpdate(e);
43917 if (this.throttle) {
43918 this.throttleStroke(this.strokeUpdate, this.throttle);
43921 this.strokeUpdate(e);
43925 strokeBegin: function(e)
43927 var newPointGroup = {
43928 color: this.dot_color,
43932 if (typeof this.onBegin === 'function') {
43936 this.curve_data.push(newPointGroup);
43938 this.strokeUpdate(e);
43941 strokeUpdate: function(e)
43943 var rect = this.canvasEl().dom.getBoundingClientRect();
43944 var point = new this.Point(e.xy[0] - rect.left, e.xy[1] - rect.top, new Date().getTime());
43945 var lastPointGroup = this.curve_data[this.curve_data.length - 1];
43946 var lastPoints = lastPointGroup.points;
43947 var lastPoint = lastPoints.length > 0 && lastPoints[lastPoints.length - 1];
43948 var isLastPointTooClose = lastPoint
43949 ? point.distanceTo(lastPoint) <= this.min_distance
43951 var color = lastPointGroup.color;
43952 if (!lastPoint || !(lastPoint && isLastPointTooClose)) {
43953 var curve = this.addPoint(point);
43955 this.drawDot({color: color, point: point});
43958 this.drawCurve({color: color, curve: curve});
43968 strokeEnd: function(e)
43970 this.strokeUpdate(e);
43971 if (typeof this.onEnd === 'function') {
43976 addPoint: function (point) {
43977 var _lastPoints = this._lastPoints;
43978 _lastPoints.push(point);
43979 if (_lastPoints.length > 2) {
43980 if (_lastPoints.length === 3) {
43981 _lastPoints.unshift(_lastPoints[0]);
43983 var widths = this.calculateCurveWidths(_lastPoints[1], _lastPoints[2]);
43984 var curve = this.Bezier.fromPoints(_lastPoints, widths, this);
43985 _lastPoints.shift();
43991 calculateCurveWidths: function (startPoint, endPoint) {
43992 var velocity = this.velocity_filter_weight * endPoint.velocityFrom(startPoint) +
43993 (1 - this.velocity_filter_weight) * this._lastVelocity;
43995 var newWidth = Math.max(this.max_width / (velocity + 1), this.min_width);
43998 start: this._lastWidth
44001 this._lastVelocity = velocity;
44002 this._lastWidth = newWidth;
44006 drawDot: function (_a) {
44007 var color = _a.color, point = _a.point;
44008 var ctx = this.canvasElCtx();
44009 var width = typeof this.dot_size === 'function' ? this.dot_size() : this.dot_size;
44011 this.drawCurveSegment(point.x, point.y, width);
44013 ctx.fillStyle = color;
44017 drawCurve: function (_a) {
44018 var color = _a.color, curve = _a.curve;
44019 var ctx = this.canvasElCtx();
44020 var widthDelta = curve.endWidth - curve.startWidth;
44021 var drawSteps = Math.floor(curve.length()) * 2;
44023 ctx.fillStyle = color;
44024 for (var i = 0; i < drawSteps; i += 1) {
44025 var t = i / drawSteps;
44031 var x = uuu * curve.startPoint.x;
44032 x += 3 * uu * t * curve.control1.x;
44033 x += 3 * u * tt * curve.control2.x;
44034 x += ttt * curve.endPoint.x;
44035 var y = uuu * curve.startPoint.y;
44036 y += 3 * uu * t * curve.control1.y;
44037 y += 3 * u * tt * curve.control2.y;
44038 y += ttt * curve.endPoint.y;
44039 var width = curve.startWidth + ttt * widthDelta;
44040 this.drawCurveSegment(x, y, width);
44046 drawCurveSegment: function (x, y, width) {
44047 var ctx = this.canvasElCtx();
44049 ctx.arc(x, y, width, 0, 2 * Math.PI, false);
44050 this.is_empty = false;
44055 var ctx = this.canvasElCtx();
44056 var canvas = this.canvasEl().dom;
44057 ctx.fillStyle = this.bg_color;
44058 ctx.clearRect(0, 0, canvas.width, canvas.height);
44059 ctx.fillRect(0, 0, canvas.width, canvas.height);
44060 this.curve_data = [];
44062 this.is_empty = true;
44067 return this.el.select('input',true).first();
44070 canvasEl: function()
44072 return this.el.select('canvas',true).first();
44075 canvasElCtx: function()
44077 return this.el.select('canvas',true).first().dom.getContext('2d');
44080 getImage: function(type)
44082 if(this.is_empty) {
44087 return this.canvasEl().dom.toDataURL('image/'+type, 1);
44090 drawFromImage: function(img_src)
44092 var img = new Image();
44094 img.onload = function(){
44095 this.canvasElCtx().drawImage(img, 0, 0);
44100 this.is_empty = false;
44103 selectImage: function()
44105 this.fileEl().dom.click();
44108 uploadImage: function(e)
44110 var reader = new FileReader();
44112 reader.onload = function(e){
44113 var img = new Image();
44114 img.onload = function(){
44116 this.canvasElCtx().drawImage(img, 0, 0);
44118 img.src = e.target.result;
44121 reader.readAsDataURL(e.target.files[0]);
44124 // Bezier Point Constructor
44125 Point: (function () {
44126 function Point(x, y, time) {
44129 this.time = time || Date.now();
44131 Point.prototype.distanceTo = function (start) {
44132 return Math.sqrt(Math.pow(this.x - start.x, 2) + Math.pow(this.y - start.y, 2));
44134 Point.prototype.equals = function (other) {
44135 return this.x === other.x && this.y === other.y && this.time === other.time;
44137 Point.prototype.velocityFrom = function (start) {
44138 return this.time !== start.time
44139 ? this.distanceTo(start) / (this.time - start.time)
44146 // Bezier Constructor
44147 Bezier: (function () {
44148 function Bezier(startPoint, control2, control1, endPoint, startWidth, endWidth) {
44149 this.startPoint = startPoint;
44150 this.control2 = control2;
44151 this.control1 = control1;
44152 this.endPoint = endPoint;
44153 this.startWidth = startWidth;
44154 this.endWidth = endWidth;
44156 Bezier.fromPoints = function (points, widths, scope) {
44157 var c2 = this.calculateControlPoints(points[0], points[1], points[2], scope).c2;
44158 var c3 = this.calculateControlPoints(points[1], points[2], points[3], scope).c1;
44159 return new Bezier(points[1], c2, c3, points[2], widths.start, widths.end);
44161 Bezier.calculateControlPoints = function (s1, s2, s3, scope) {
44162 var dx1 = s1.x - s2.x;
44163 var dy1 = s1.y - s2.y;
44164 var dx2 = s2.x - s3.x;
44165 var dy2 = s2.y - s3.y;
44166 var m1 = { x: (s1.x + s2.x) / 2.0, y: (s1.y + s2.y) / 2.0 };
44167 var m2 = { x: (s2.x + s3.x) / 2.0, y: (s2.y + s3.y) / 2.0 };
44168 var l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
44169 var l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
44170 var dxm = m1.x - m2.x;
44171 var dym = m1.y - m2.y;
44172 var k = l2 / (l1 + l2);
44173 var cm = { x: m2.x + dxm * k, y: m2.y + dym * k };
44174 var tx = s2.x - cm.x;
44175 var ty = s2.y - cm.y;
44177 c1: new scope.Point(m1.x + tx, m1.y + ty),
44178 c2: new scope.Point(m2.x + tx, m2.y + ty)
44181 Bezier.prototype.length = function () {
44186 for (var i = 0; i <= steps; i += 1) {
44188 var cx = this.point(t, this.startPoint.x, this.control1.x, this.control2.x, this.endPoint.x);
44189 var cy = this.point(t, this.startPoint.y, this.control1.y, this.control2.y, this.endPoint.y);
44191 var xdiff = cx - px;
44192 var ydiff = cy - py;
44193 length += Math.sqrt(xdiff * xdiff + ydiff * ydiff);
44200 Bezier.prototype.point = function (t, start, c1, c2, end) {
44201 return (start * (1.0 - t) * (1.0 - t) * (1.0 - t))
44202 + (3.0 * c1 * (1.0 - t) * (1.0 - t) * t)
44203 + (3.0 * c2 * (1.0 - t) * t * t)
44204 + (end * t * t * t);
44209 throttleStroke: function(fn, wait) {
44210 if (wait === void 0) { wait = 250; }
44212 var timeout = null;
44216 var later = function () {
44217 previous = Date.now();
44219 result = fn.apply(storedContext, storedArgs);
44221 storedContext = null;
44225 return function wrapper() {
44227 for (var _i = 0; _i < arguments.length; _i++) {
44228 args[_i] = arguments[_i];
44230 var now = Date.now();
44231 var remaining = wait - (now - previous);
44232 storedContext = this;
44234 if (remaining <= 0 || remaining > wait) {
44236 clearTimeout(timeout);
44240 result = fn.apply(storedContext, storedArgs);
44242 storedContext = null;
44246 else if (!timeout) {
44247 timeout = window.setTimeout(later, remaining);