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;
17 })(); Roo.bootstrap.menu = Roo.bootstrap.menu || {};
18 Roo.bootstrap.nav = {};
20 Roo.bootstrap.form = {};Roo.bootstrap.panel = {};Roo.bootstrap.layout = {};/*
22 * Ext JS Library 1.1.1
23 * Copyright(c) 2006-2007, Ext JS, LLC.
25 * Originally Released Under LGPL - original licence link has changed is not relivant.
28 * <script type="text/javascript">
34 * Simple class that can provide a shadow effect for any element. Note that the element MUST be absolutely positioned,
35 * and the shadow does not provide any shimming. This should be used only in simple cases -- for more advanced
36 * functionality that can also provide the same shadow effect, see the {@link Roo.Layer} class.
39 * @param {Object} config The config object
41 Roo.Shadow = function(config){
42 Roo.apply(this, config);
43 if(typeof this.mode != "string"){
44 this.mode = this.defaultMode;
46 var o = this.offset, a = {h: 0};
47 var rad = Math.floor(this.offset/2);
48 switch(this.mode.toLowerCase()){ // all this hideous nonsense calculates the various offsets for shadows
54 a.l -= this.offset + rad;
55 a.t -= this.offset + rad;
66 a.l -= (this.offset - rad);
67 a.t -= this.offset + rad;
69 a.w -= (this.offset - rad)*2;
80 a.l -= (this.offset - rad);
81 a.t -= (this.offset - rad);
83 a.w -= (this.offset + rad + 1);
84 a.h -= (this.offset + rad);
93 Roo.Shadow.prototype = {
96 * The shadow display mode. Supports the following options:<br />
97 * sides: Shadow displays on both sides and bottom only<br />
98 * frame: Shadow displays equally on all four sides<br />
99 * drop: Traditional bottom-right drop shadow (default)
103 * @cfg {String} offset
104 * The number of pixels to offset the shadow from the element (defaults to 4)
112 * Displays the shadow under the target element
113 * @param {String/HTMLElement/Element} targetEl The id or element under which the shadow should display
115 show : function(target){
116 target = Roo.get(target);
118 this.el = Roo.Shadow.Pool.pull();
119 if(this.el.dom.nextSibling != target.dom){
120 this.el.insertBefore(target);
123 this.el.setStyle("z-index", this.zIndex || parseInt(target.getStyle("z-index"), 10)-1);
125 this.el.dom.style.filter="progid:DXImageTransform.Microsoft.alpha(opacity=50) progid:DXImageTransform.Microsoft.Blur(pixelradius="+(this.offset)+")";
128 target.getLeft(true),
133 this.el.dom.style.display = "block";
137 * Returns true if the shadow is visible, else false
139 isVisible : function(){
140 return this.el ? true : false;
144 * Direct alignment when values are already available. Show must be called at least once before
145 * calling this method to ensure it is initialized.
146 * @param {Number} left The target element left position
147 * @param {Number} top The target element top position
148 * @param {Number} width The target element width
149 * @param {Number} height The target element height
151 realign : function(l, t, w, h){
155 var a = this.adjusts, d = this.el.dom, s = d.style;
157 s.left = (l+a.l)+"px";
158 s.top = (t+a.t)+"px";
159 var sw = (w+a.w), sh = (h+a.h), sws = sw +"px", shs = sh + "px";
161 if(s.width != sws || s.height != shs){
165 var cn = d.childNodes;
166 var sww = Math.max(0, (sw-12))+"px";
167 cn[0].childNodes[1].style.width = sww;
168 cn[1].childNodes[1].style.width = sww;
169 cn[2].childNodes[1].style.width = sww;
170 cn[1].style.height = Math.max(0, (sh-12))+"px";
180 this.el.dom.style.display = "none";
181 Roo.Shadow.Pool.push(this.el);
187 * Adjust the z-index of this shadow
188 * @param {Number} zindex The new z-index
190 setZIndex : function(z){
193 this.el.setStyle("z-index", z);
198 // Private utility class that manages the internal Shadow cache
199 Roo.Shadow.Pool = function(){
201 var markup = Roo.isIE ?
202 '<div class="x-ie-shadow"></div>' :
203 '<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>';
208 sh = Roo.get(Roo.DomHelper.insertHtml("beforeBegin", document.body.firstChild, markup));
209 sh.autoBoxAdjust = false;
221 * base class for bootstrap elements.
225 Roo.bootstrap = Roo.bootstrap || {};
227 * @class Roo.bootstrap.Component
228 * @extends Roo.Component
230 * @children Roo.bootstrap.Component
231 * Bootstrap Component base class
232 * @cfg {String} cls css class
233 * @cfg {String} style any extra css
234 * @cfg {Object} xattr extra attributes to add to 'element' (used by builder to store stuff.)
235 * @cfg {Boolean} can_build_overlaid True if element can be rebuild from a HTML page
236 * @cfg {string} dataId cutomer id
237 * @cfg {string} name Specifies name attribute
238 * @cfg {string} tooltip Text for the tooltip
239 * @cfg {string} tooltipClass Class for the tooltip element
240 * @cfg {string} container_method method to fetch parents container element (used by NavHeaderbar - getHeaderChildContainer)
241 * @cfg {string|object} visibilityEl (el|parent) What element to use for visibility (@see getVisibilityEl())
244 * Do not use directly - it does not do anything..
245 * @param {Object} config The config object
250 Roo.bootstrap.Component = function(config){
251 Roo.bootstrap.Component.superclass.constructor.call(this, config);
255 * @event childrenrendered
256 * Fires when the children have been rendered..
257 * @param {Roo.bootstrap.Component} this
259 "childrenrendered" : true
268 Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent, {
271 allowDomMove : false, // to stop relocations in parent onRender...
283 * Initialize Events for the element
285 initEvents : function() { },
291 can_build_overlaid : true,
293 container_method : false,
300 // returns the parent component..
301 return Roo.ComponentMgr.get(this.parentId)
307 onRender : function(ct, position)
309 // Roo.log("Call onRender: " + this.xtype);
311 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
314 if (this.el.attr('xtype')) {
315 this.el.attr('xtypex', this.el.attr('xtype'));
316 this.el.dom.removeAttribute('xtype');
326 var cfg = Roo.apply({}, this.getAutoCreate());
328 cfg.id = this.id || Roo.id();
330 // fill in the extra attributes
331 if (this.xattr && typeof(this.xattr) =='object') {
332 for (var i in this.xattr) {
333 cfg[i] = this.xattr[i];
338 cfg.dataId = this.dataId;
342 cfg.cls = (typeof(cfg.cls) == 'undefined' ? this.cls : cfg.cls) + ' ' + this.cls;
345 if (this.style) { // fixme needs to support more complex style data.
346 cfg.style = (typeof(cfg.style) == 'undefined' ? this.style : cfg.style) + '; ' + this.style;
350 cfg.name = this.name;
353 this.el = ct.createChild(cfg, position);
356 this.tooltipEl().attr('tooltip', this.tooltip);
359 if (this.tooltipClass) {
360 this.tooltipEl().attr('tooltip-class', this.tooltipClass);
363 if(this.tabIndex !== undefined){
364 this.el.dom.setAttribute('tabIndex', this.tabIndex);
371 * Fetch the element to add children to
372 * @return {Roo.Element} defaults to this.el
374 getChildContainer : function()
378 getDocumentBody : function() // used by menus - as they are attached to the body so zIndexes work
380 return Roo.get(document.body);
384 * Fetch the element to display the tooltip on.
385 * @return {Roo.Element} defaults to this.el
387 tooltipEl : function()
392 addxtype : function(tree,cntr)
396 cn = Roo.factory(tree);
397 //Roo.log(['addxtype', cn]);
399 cn.parentType = this.xtype; //??
400 cn.parentId = this.id;
402 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
403 if (typeof(cn.container_method) == 'string') {
404 cntr = cn.container_method;
408 var has_flexy_each = (typeof(tree['flexy:foreach']) != 'undefined');
410 var has_flexy_if = (typeof(tree['flexy:if']) != 'undefined');
412 var build_from_html = Roo.XComponent.build_from_html;
414 var is_body = (tree.xtype == 'Body') ;
416 var page_has_body = (Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body');
418 var self_cntr_el = Roo.get(this[cntr](false));
420 // do not try and build conditional elements
421 if ((has_flexy_each || has_flexy_if || this.can_build_overlaid == false ) && build_from_html) {
425 if (!has_flexy_each || !build_from_html || is_body || !page_has_body) {
426 if(!has_flexy_if || typeof(tree.name) == 'undefined' || !build_from_html || is_body || !page_has_body){
427 return this.addxtypeChild(tree,cntr, is_body);
430 var echild =self_cntr_el ? self_cntr_el.child('>*[name=' + tree.name + ']') : false;
433 return this.addxtypeChild(Roo.apply({}, tree),cntr);
436 Roo.log('skipping render');
442 if (!build_from_html) {
446 // this i think handles overlaying multiple children of the same type
447 // with the sam eelement.. - which might be buggy..
449 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
455 if (echild && echild.attr('xtype').split('.').pop() != cn.xtype) {
459 ret = this.addxtypeChild(Roo.apply({}, tree),cntr);
466 addxtypeChild : function (tree, cntr, is_body)
468 Roo.debug && Roo.log('addxtypeChild:' + cntr);
470 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
473 var has_flexy = (typeof(tree['flexy:if']) != 'undefined') ||
474 (typeof(tree['flexy:foreach']) != 'undefined');
478 skip_children = false;
479 // render the element if it's not BODY.
482 // if parent was disabled, then do not try and create the children..
483 if(!this[cntr](true)){
488 cn = Roo.factory(tree);
490 cn.parentType = this.xtype; //??
491 cn.parentId = this.id;
493 var build_from_html = Roo.XComponent.build_from_html;
496 // does the container contain child eleemnts with 'xtype' attributes.
497 // that match this xtype..
498 // note - when we render we create these as well..
499 // so we should check to see if body has xtype set.
500 if (build_from_html && Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body') {
502 var self_cntr_el = Roo.get(this[cntr](false));
503 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
505 //Roo.log(Roo.XComponent.build_from_html);
506 //Roo.log("got echild:");
509 // there is a scenario where some of the child elements are flexy:if (and all of the same type)
510 // and are not displayed -this causes this to use up the wrong element when matching.
511 // at present the only work around for this is to nest flexy:if elements in another element that is always rendered.
514 if (echild && echild.attr('xtype').split('.').pop() == cn.xtype) {
515 // Roo.log("found child for " + this.xtype +": " + echild.attr('xtype') );
521 //echild.dom.removeAttribute('xtype');
523 Roo.debug && Roo.log("MISSING " + cn.xtype + " on child of " + (this.el ? this.el.attr('xbuilderid') : 'no parent'));
524 Roo.debug && Roo.log(self_cntr_el);
525 Roo.debug && Roo.log(echild);
526 Roo.debug && Roo.log(cn);
532 // if object has flexy:if - then it may or may not be rendered.
533 if (build_from_html && has_flexy && !cn.el && cn.can_build_overlaid) {
534 // skip a flexy if element.
535 Roo.debug && Roo.log('skipping render');
536 Roo.debug && Roo.log(tree);
538 Roo.debug && Roo.log('skipping all children');
539 skip_children = true;
544 // actually if flexy:foreach is found, we really want to create
545 // multiple copies here...
547 //Roo.log(this[cntr]());
548 // some elements do not have render methods.. like the layouts...
550 if(this[cntr](true) === false){
555 cn.render && cn.render(this[cntr](true));
558 // then add the element..
565 if (typeof (tree.menu) != 'undefined') {
566 tree.menu.parentType = cn.xtype;
567 tree.menu.triggerEl = cn.el;
568 nitems.push(cn.addxtype(Roo.apply({}, tree.menu)));
572 if (!tree.items || !tree.items.length) {
574 //Roo.log(["no children", this]);
579 var items = tree.items;
582 //Roo.log(items.length);
584 if (!skip_children) {
585 for(var i =0;i < items.length;i++) {
586 // Roo.log(['add child', items[i]]);
587 nitems.push(cn.addxtype(Roo.apply({}, items[i])));
593 //Roo.log("fire childrenrendered");
595 cn.fireEvent('childrenrendered', this);
601 * Set the element that will be used to show or hide
603 setVisibilityEl : function(el)
605 this.visibilityEl = el;
609 * Get the element that will be used to show or hide
611 getVisibilityEl : function()
613 if (typeof(this.visibilityEl) == 'object') {
614 return this.visibilityEl;
617 if (typeof(this.visibilityEl) == 'string') {
618 return this.visibilityEl == 'parent' ? this.parent().getEl() : this.getEl();
625 * Show a component - removes 'hidden' class
629 if(!this.getVisibilityEl()){
633 this.getVisibilityEl().removeClass(['hidden','d-none']);
635 this.fireEvent('show', this);
640 * Hide a component - adds 'hidden' class
644 if(!this.getVisibilityEl()){
648 this.getVisibilityEl().addClass(['hidden','d-none']);
650 this.fireEvent('hide', this);
663 * @class Roo.bootstrap.Element
664 * @extends Roo.bootstrap.Component
665 * @children Roo.bootstrap.Component
666 * Bootstrap Element class (basically a DIV used to make random stuff )
668 * @cfg {String} html contents of the element
669 * @cfg {String} tag tag of the element
670 * @cfg {String} cls class of the element
671 * @cfg {Boolean} preventDefault (true|false) default false
672 * @cfg {Boolean} clickable (true|false) default false
673 * @cfg {String} role default blank - set to button to force cursor pointer
677 * Create a new Element
678 * @param {Object} config The config object
681 Roo.bootstrap.Element = function(config){
682 Roo.bootstrap.Element.superclass.constructor.call(this, config);
688 * When a element is chick
689 * @param {Roo.bootstrap.Element} this
690 * @param {Roo.EventObject} e
698 Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, {
703 preventDefault: false,
708 getAutoCreate : function(){
712 // cls: this.cls, double assign in parent class Component.js :: onRender
715 if (this.role !== false) {
716 cfg.role = this.role;
722 initEvents: function()
724 Roo.bootstrap.Element.superclass.initEvents.call(this);
727 this.el.on('click', this.onClick, this);
733 onClick : function(e)
735 if(this.preventDefault){
739 this.fireEvent('click', this, e); // why was this double click before?
747 getValue : function()
749 return this.el.dom.innerHTML;
752 setValue : function(value)
754 this.el.dom.innerHTML = value;
769 * @class Roo.bootstrap.DropTarget
770 * @extends Roo.bootstrap.Element
771 * Bootstrap DropTarget class
773 * @cfg {string} name dropable name
776 * Create a new Dropable Area
777 * @param {Object} config The config object
780 Roo.bootstrap.DropTarget = function(config){
781 Roo.bootstrap.DropTarget.superclass.constructor.call(this, config);
787 * When a element is chick
788 * @param {Roo.bootstrap.Element} this
789 * @param {Roo.EventObject} e
795 Roo.extend(Roo.bootstrap.DropTarget, Roo.bootstrap.Element, {
798 getAutoCreate : function(){
803 initEvents: function()
805 Roo.bootstrap.DropTarget.superclass.initEvents.call(this);
806 this.dropZone = new Roo.dd.DropTarget(this.getEl(), {
809 drop : this.dragDrop.createDelegate(this),
810 enter : this.dragEnter.createDelegate(this),
811 out : this.dragOut.createDelegate(this),
812 over : this.dragOver.createDelegate(this)
816 this.dropZone.DDM.useCache = false // so data gets refreshed when we resize stuff
819 dragDrop : function(source,e,data)
821 // user has to decide how to impliment this.
824 //this.fireEvent('drop', this, source, e ,data);
828 dragEnter : function(n, dd, e, data)
830 // probably want to resize the element to match the dropped element..
832 this.originalSize = this.el.getSize();
833 this.el.setSize( n.el.getSize());
834 this.dropZone.DDM.refreshCache(this.name);
835 Roo.log([n, dd, e, data]);
838 dragOut : function(value)
840 // resize back to normal
842 this.el.setSize(this.originalSize);
843 this.dropZone.resetConstraints();
846 dragOver : function()
863 * @class Roo.bootstrap.Body
864 * @extends Roo.bootstrap.Component
865 * @children Roo.bootstrap.Component
866 * @parent none builder
867 * Bootstrap Body class
871 * @param {Object} config The config object
874 Roo.bootstrap.Body = function(config){
876 config = config || {};
878 Roo.bootstrap.Body.superclass.constructor.call(this, config);
879 this.el = Roo.get(config.el ? config.el : document.body );
880 if (this.cls && this.cls.length) {
881 Roo.get(document.body).addClass(this.cls);
885 Roo.extend(Roo.bootstrap.Body, Roo.bootstrap.Component, {
887 is_body : true,// just to make sure it's constructed?
892 onRender : function(ct, position)
894 /* Roo.log("Roo.bootstrap.Body - onRender");
895 if (this.cls && this.cls.length) {
896 Roo.get(document.body).addClass(this.cls);
915 * @class Roo.bootstrap.ButtonGroup
916 * @extends Roo.bootstrap.Component
917 * Bootstrap ButtonGroup class
918 * @children Roo.bootstrap.Button Roo.bootstrap.form.Form
920 * @cfg {String} size lg | sm | xs (default empty normal)
921 * @cfg {String} align vertical | justified (default none)
922 * @cfg {String} direction up | down (default down)
923 * @cfg {Boolean} toolbar false | true
924 * @cfg {Boolean} btn true | false
929 * @param {Object} config The config object
932 Roo.bootstrap.ButtonGroup = function(config){
933 Roo.bootstrap.ButtonGroup.superclass.constructor.call(this, config);
936 Roo.extend(Roo.bootstrap.ButtonGroup, Roo.bootstrap.Component, {
944 getAutoCreate : function(){
950 cfg.html = this.html || cfg.html;
961 if (['vertical','justified'].indexOf(this.align)!==-1) {
962 cfg.cls = 'btn-group-' + this.align;
964 if (this.align == 'justified') {
965 console.log(this.items);
969 if (['lg','sm','xs'].indexOf(this.size)!==-1) {
970 cfg.cls += ' btn-group-' + this.size;
973 if (this.direction == 'up') {
974 cfg.cls += ' dropup' ;
980 * Add a button to the group (similar to NavItem API.)
982 addItem : function(cfg)
984 var cn = new Roo.bootstrap.Button(cfg);
986 cn.parentId = this.id;
987 cn.onRender(this.el, null);
1001 * @class Roo.bootstrap.Button
1002 * @extends Roo.bootstrap.Component
1003 * Bootstrap Button class
1004 * @cfg {String} html The button content
1005 * @cfg {String} weight (default|primary|secondary|success|info|warning|danger|link|light|dark) default
1006 * @cfg {String} badge_weight (default|primary|secondary|success|info|warning|danger|link|light|dark) default (same as button)
1007 * @cfg {Boolean} outline default false (except for weight=default which emulates old behaveiour with an outline)
1008 * @cfg {String} size (lg|sm|xs)
1009 * @cfg {String} tag (a|input|submit)
1010 * @cfg {String} href empty or href
1011 * @cfg {Boolean} disabled default false;
1012 * @cfg {Boolean} isClose default false;
1013 * @cfg {String} glyphicon depricated - use fa
1014 * @cfg {String} fa fontawesome icon - eg. 'comment' - without the fa/fas etc..
1015 * @cfg {String} badge text for badge
1016 * @cfg {String} theme (default|glow)
1017 * @cfg {Boolean} inverse dark themed version
1018 * @cfg {Boolean} toggle is it a slidy toggle button
1019 * @cfg {Boolean} pressed default null - if the button ahs active state
1020 * @cfg {String} ontext text for on slidy toggle state
1021 * @cfg {String} offtext text for off slidy toggle state
1022 * @cfg {Boolean} preventDefault default true (stop click event triggering the URL if it's a link.)
1023 * @cfg {Boolean} removeClass remove the standard class..
1024 * @cfg {String} target (_self|_blank|_parent|_top|other) target for a href.
1025 * @cfg {Boolean} grpup if parent is a btn group - then it turns it into a toogleGroup.
1026 * @cfg {Roo.bootstrap.menu.Menu} menu a Menu
1029 * Create a new button
1030 * @param {Object} config The config object
1034 Roo.bootstrap.Button = function(config){
1035 Roo.bootstrap.Button.superclass.constructor.call(this, config);
1041 * When a button is pressed
1042 * @param {Roo.bootstrap.Button} btn
1043 * @param {Roo.EventObject} e
1048 * When a button is double clicked
1049 * @param {Roo.bootstrap.Button} btn
1050 * @param {Roo.EventObject} e
1055 * After the button has been toggles
1056 * @param {Roo.bootstrap.Button} btn
1057 * @param {Roo.EventObject} e
1058 * @param {boolean} pressed (also available as button.pressed)
1064 Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, {
1085 preventDefault: true,
1094 getAutoCreate : function(){
1102 if (['a', 'button', 'input', 'submit'].indexOf(this.tag) < 0) {
1103 throw "Invalid value for tag: " + this.tag + ". must be a, button, input or submit.";
1104 this.tag = 'button';
1108 cfg.html = '<span class="roo-button-text">' + (this.html || cfg.html) + '</span>';
1110 if (this.toggle == true) {
1113 cls: 'slider-frame roo-button',
1117 'data-on-text':'ON',
1118 'data-off-text':'OFF',
1119 cls: 'slider-button',
1124 // why are we validating the weights?
1125 if (Roo.bootstrap.Button.weights.indexOf(this.weight) > -1) {
1126 cfg.cls += ' ' + this.weight;
1133 cfg.cls += ' close';
1135 cfg["aria-hidden"] = true;
1137 cfg.html = "×";
1143 if (this.theme==='default') {
1144 cfg.cls = 'btn roo-button';
1146 //if (this.parentType != 'Navbar') {
1147 this.weight = this.weight.length ? this.weight : 'default';
1149 if (Roo.bootstrap.Button.weights.indexOf(this.weight) > -1) {
1151 var outline = this.outline || this.weight == 'default' ? 'outline-' : '';
1152 var weight = this.weight == 'default' ? 'secondary' : this.weight;
1153 cfg.cls += ' btn-' + outline + weight;
1154 if (this.weight == 'default') {
1156 cfg.cls += ' btn-' + this.weight;
1159 } else if (this.theme==='glow') {
1162 cfg.cls = 'btn-glow roo-button';
1164 if (Roo.bootstrap.Button.weights.indexOf(this.weight) > -1) {
1166 cfg.cls += ' ' + this.weight;
1172 this.cls += ' inverse';
1176 if (this.active || this.pressed === true) {
1177 cfg.cls += ' active';
1180 if (this.disabled) {
1181 cfg.disabled = 'disabled';
1185 Roo.log('changing to ul' );
1187 this.glyphicon = 'caret';
1188 if (Roo.bootstrap.version == 4) {
1189 this.fa = 'caret-down';
1194 cfg.cls += this.size.length ? (' btn-' + this.size) : '';
1196 //gsRoo.log(this.parentType);
1197 if (this.parentType === 'Navbar' && !this.parent().bar) {
1198 Roo.log('changing to li?');
1207 href : this.href || '#'
1210 cfg.cn[0].html = this.html + ' <span class="caret"></span>';
1211 cfg.cls += ' dropdown';
1218 cfg.cls += this.parentType === 'Navbar' ? ' navbar-btn' : '';
1220 if (this.glyphicon) {
1221 cfg.html = ' ' + cfg.html;
1226 cls: 'glyphicon glyphicon-' + this.glyphicon
1231 cfg.html = ' ' + cfg.html;
1236 cls: 'fa fas fa-' + this.fa
1246 // cfg.cls='btn roo-button';
1250 var value = cfg.html;
1255 cls: 'glyphicon glyphicon-' + this.glyphicon,
1262 cls: 'fa fas fa-' + this.fa,
1267 var bw = this.badge_weight.length ? this.badge_weight :
1268 (this.weight.length ? this.weight : 'secondary');
1269 bw = bw == 'default' ? 'secondary' : bw;
1275 cls: 'badge badge-' + bw,
1284 cfg.cls += ' dropdown';
1285 cfg.html = typeof(cfg.html) != 'undefined' ?
1286 cfg.html + ' <span class="caret"></span>' : '<span class="caret"></span>';
1289 if (cfg.tag !== 'a' && this.href !== '') {
1290 throw "Tag must be a to set href.";
1291 } else if (this.href.length > 0) {
1292 cfg.href = this.href;
1295 if(this.removeClass){
1300 cfg.target = this.target;
1305 initEvents: function() {
1306 // Roo.log('init events?');
1307 // Roo.log(this.el.dom);
1310 if (typeof (this.menu) != 'undefined') {
1311 this.menu.parentType = this.xtype;
1312 this.menu.triggerEl = this.el;
1313 this.addxtype(Roo.apply({}, this.menu));
1317 if (this.el.hasClass('roo-button')) {
1318 this.el.on('click', this.onClick, this);
1319 this.el.on('dblclick', this.onDblClick, this);
1321 this.el.select('.roo-button').on('click', this.onClick, this);
1322 this.el.select('.roo-button').on('dblclick', this.onDblClick, this);
1326 if(this.removeClass){
1327 this.el.on('click', this.onClick, this);
1330 if (this.group === true) {
1331 if (this.pressed === false || this.pressed === true) {
1334 this.pressed = false;
1335 this.setActive(this.pressed);
1340 this.el.enableDisplayMode();
1343 onClick : function(e)
1345 if (this.disabled) {
1349 Roo.log('button on click ');
1350 if(this.href === '' || this.preventDefault){
1359 this.setActive(true);
1360 var pi = this.parent().items;
1361 for (var i = 0;i < pi.length;i++) {
1362 if (this == pi[i]) {
1365 if (pi[i].el.hasClass('roo-button')) {
1366 pi[i].setActive(false);
1369 this.fireEvent('click', this, e);
1373 if (this.pressed === true || this.pressed === false) {
1374 this.toggleActive(e);
1378 this.fireEvent('click', this, e);
1380 onDblClick: function(e)
1382 if (this.disabled) {
1385 if(this.preventDefault){
1388 this.fireEvent('dblclick', this, e);
1391 * Enables this button
1395 this.disabled = false;
1396 this.el.removeClass('disabled');
1397 this.el.dom.removeAttribute("disabled");
1401 * Disable this button
1403 disable : function()
1405 this.disabled = true;
1406 this.el.addClass('disabled');
1407 this.el.attr("disabled", "disabled")
1410 * sets the active state on/off,
1411 * @param {Boolean} state (optional) Force a particular state
1413 setActive : function(v) {
1415 this.el[v ? 'addClass' : 'removeClass']('active');
1419 * toggles the current active state
1421 toggleActive : function(e)
1423 this.setActive(!this.pressed); // this modifies pressed...
1424 this.fireEvent('toggle', this, e, this.pressed);
1427 * get the current active state
1428 * @return {boolean} true if it's active
1430 isActive : function()
1432 return this.el.hasClass('active');
1435 * set the text of the first selected button
1437 setText : function(str)
1439 this.el.select('.roo-button-text',true).first().dom.innerHTML = str;
1442 * get the text of the first selected button
1444 getText : function()
1446 return this.el.select('.roo-button-text',true).first().dom.innerHTML;
1449 setWeight : function(str)
1451 this.el.removeClass(Roo.bootstrap.Button.weights.map(function(w) { return 'btn-' + w; } ) );
1452 this.el.removeClass(Roo.bootstrap.Button.weights.map(function(w) { return 'btn-outline-' + w; } ) );
1454 var outline = this.outline ? 'outline-' : '';
1455 if (str == 'default') {
1456 this.el.addClass('btn-default btn-outline-secondary');
1459 this.el.addClass('btn-' + outline + str);
1464 // fixme - this is probably generic bootstrap - should go in some kind of enum file.. - like sizes.
1466 Roo.bootstrap.Button.weights = [
1486 * @class Roo.bootstrap.Column
1487 * @extends Roo.bootstrap.Component
1488 * @children Roo.bootstrap.Component
1489 * Bootstrap Column class
1490 * @cfg {Number} xs colspan out of 12 for mobile-sized screens or 0 for hidden
1491 * @cfg {Number} sm colspan out of 12 for tablet-sized screens or 0 for hidden
1492 * @cfg {Number} md colspan out of 12 for computer-sized screens or 0 for hidden
1493 * @cfg {Number} lg colspan out of 12 for large computer-sized screens or 0 for hidden
1494 * @cfg {Number} xsoff colspan offset out of 12 for mobile-sized screens or 0 for hidden
1495 * @cfg {Number} smoff colspan offset out of 12 for tablet-sized screens or 0 for hidden
1496 * @cfg {Number} mdoff colspan offset out of 12 for computer-sized screens or 0 for hidden
1497 * @cfg {Number} lgoff colspan offset out of 12 for large computer-sized screens or 0 for hidden
1500 * @cfg {Boolean} hidden (true|false) hide the element
1501 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1502 * @cfg {String} fa (ban|check|...) font awesome icon
1503 * @cfg {Number} fasize (1|2|....) font awsome size
1505 * @cfg {String} icon (info-sign|check|...) glyphicon name
1507 * @cfg {String} html content of column.
1510 * Create a new Column
1511 * @param {Object} config The config object
1514 Roo.bootstrap.Column = function(config){
1515 Roo.bootstrap.Column.superclass.constructor.call(this, config);
1518 Roo.extend(Roo.bootstrap.Column, Roo.bootstrap.Component, {
1536 getAutoCreate : function(){
1537 var cfg = Roo.apply({}, Roo.bootstrap.Column.superclass.getAutoCreate.call(this));
1545 var sizes = ['xs','sm','md','lg'];
1546 sizes.map(function(size ,ix){
1547 //Roo.log( size + ':' + settings[size]);
1549 if (settings[size+'off'] !== false) {
1550 cfg.cls += ' col-' + size + '-offset-' + settings[size+'off'] ;
1553 if (settings[size] === false) {
1557 if (!settings[size]) { // 0 = hidden
1558 cfg.cls += ' hidden-' + size + ' hidden-' + size + '-down';
1560 for (var i = ix; i > -1; i--) {
1561 cfg.cls += ' d-' + sizes[i] + '-none';
1567 cfg.cls += ' col-' + size + '-' + settings[size] + (
1568 size == 'xs' ? (' col-' + settings[size] ) : '' // bs4 col-{num} replaces col-xs
1574 cfg.cls += ' hidden';
1577 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1578 cfg.cls +=' alert alert-' + this.alert;
1582 if (this.html.length) {
1583 cfg.html = this.html;
1587 if (this.fasize > 1) {
1588 fasize = ' fa-' + this.fasize + 'x';
1590 cfg.html = '<i class="fa fa-'+this.fa + fasize + '"></i>' + (cfg.html || '');
1595 cfg.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + (cfg.html || '');
1614 * @class Roo.bootstrap.Container
1615 * @extends Roo.bootstrap.Component
1616 * @children Roo.bootstrap.Component
1618 * Bootstrap Container class
1619 * @cfg {Boolean} jumbotron is it a jumbotron element
1620 * @cfg {String} html content of element
1621 * @cfg {String} well (lg|sm|md) a well, large, small or medium.
1622 * @cfg {String} panel (default|primary|success|info|warning|danger) render as panel - type - primary/success.....
1623 * @cfg {String} header content of header (for panel)
1624 * @cfg {String} footer content of footer (for panel)
1625 * @cfg {String} sticky (footer|wrap|push) block to use as footer or body- needs css-bootstrap/sticky-footer.css
1626 * @cfg {String} tag (header|aside|section) type of HTML tag.
1627 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1628 * @cfg {String} fa font awesome icon
1629 * @cfg {String} icon (info-sign|check|...) glyphicon name
1630 * @cfg {Boolean} hidden (true|false) hide the element
1631 * @cfg {Boolean} expandable (true|false) default false
1632 * @cfg {Boolean} expanded (true|false) default true
1633 * @cfg {String} rheader contet on the right of header
1634 * @cfg {Boolean} clickable (true|false) default false
1638 * Create a new Container
1639 * @param {Object} config The config object
1642 Roo.bootstrap.Container = function(config){
1643 Roo.bootstrap.Container.superclass.constructor.call(this, config);
1649 * After the panel has been expand
1651 * @param {Roo.bootstrap.Container} this
1656 * After the panel has been collapsed
1658 * @param {Roo.bootstrap.Container} this
1663 * When a element is chick
1664 * @param {Roo.bootstrap.Container} this
1665 * @param {Roo.EventObject} e
1671 Roo.extend(Roo.bootstrap.Container, Roo.bootstrap.Component, {
1689 getChildContainer : function() {
1695 if (this.panel.length) {
1696 return this.el.select('.panel-body',true).first();
1703 getAutoCreate : function(){
1706 tag : this.tag || 'div',
1710 if (this.jumbotron) {
1711 cfg.cls = 'jumbotron';
1716 // - this is applied by the parent..
1718 // cfg.cls = this.cls + '';
1721 if (this.sticky.length) {
1723 var bd = Roo.get(document.body);
1724 if (!bd.hasClass('bootstrap-sticky')) {
1725 bd.addClass('bootstrap-sticky');
1726 Roo.select('html',true).setStyle('height', '100%');
1729 cfg.cls += 'bootstrap-sticky-' + this.sticky;
1733 if (this.well.length) {
1734 switch (this.well) {
1737 cfg.cls +=' well well-' +this.well;
1746 cfg.cls += ' hidden';
1750 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1751 cfg.cls +=' alert alert-' + this.alert;
1756 if (this.panel.length) {
1757 cfg.cls += ' panel panel-' + this.panel;
1759 if (this.header.length) {
1763 if(this.expandable){
1765 cfg.cls = cfg.cls + ' expandable';
1769 cls: (this.expanded ? 'fa fa-minus' : 'fa fa-plus')
1777 cls : 'panel-title',
1778 html : (this.expandable ? ' ' : '') + this.header
1782 cls: 'panel-header-right',
1788 cls : 'panel-heading',
1789 style : this.expandable ? 'cursor: pointer' : '',
1797 cls : 'panel-body' + (this.expanded ? '' : ' hide'),
1802 if (this.footer.length) {
1804 cls : 'panel-footer',
1813 body.html = this.html || cfg.html;
1814 // prefix with the icons..
1816 body.html = '<i class="fa fa-'+this.fa + '"></i>' + body.html ;
1819 body.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + body.html ;
1824 if ((!this.cls || !this.cls.length) && (!cfg.cls || !cfg.cls.length)) {
1825 cfg.cls = 'container';
1831 initEvents: function()
1833 if(this.expandable){
1834 var headerEl = this.headerEl();
1837 headerEl.on('click', this.onToggleClick, this);
1842 this.el.on('click', this.onClick, this);
1847 onToggleClick : function()
1849 var headerEl = this.headerEl();
1865 if(this.fireEvent('expand', this)) {
1867 this.expanded = true;
1869 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).show();
1871 this.el.select('.panel-body',true).first().removeClass('hide');
1873 var toggleEl = this.toggleEl();
1879 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-minus']);
1884 collapse : function()
1886 if(this.fireEvent('collapse', this)) {
1888 this.expanded = false;
1890 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).hide();
1891 this.el.select('.panel-body',true).first().addClass('hide');
1893 var toggleEl = this.toggleEl();
1899 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-plus']);
1903 toggleEl : function()
1905 if(!this.el || !this.panel.length || !this.header.length || !this.expandable){
1909 return this.el.select('.panel-heading .fa',true).first();
1912 headerEl : function()
1914 if(!this.el || !this.panel.length || !this.header.length){
1918 return this.el.select('.panel-heading',true).first()
1923 if(!this.el || !this.panel.length){
1927 return this.el.select('.panel-body',true).first()
1930 titleEl : function()
1932 if(!this.el || !this.panel.length || !this.header.length){
1936 return this.el.select('.panel-title',true).first();
1939 setTitle : function(v)
1941 var titleEl = this.titleEl();
1947 titleEl.dom.innerHTML = v;
1950 getTitle : function()
1953 var titleEl = this.titleEl();
1959 return titleEl.dom.innerHTML;
1962 setRightTitle : function(v)
1964 var t = this.el.select('.panel-header-right',true).first();
1970 t.dom.innerHTML = v;
1973 onClick : function(e)
1977 this.fireEvent('click', this, e);
1982 * @class Roo.bootstrap.Card
1983 * @extends Roo.bootstrap.Component
1984 * @children Roo.bootstrap.Component
1986 * Bootstrap Card class - note this has children as CardHeader/ImageTop/Footer.. - which should really be listed properties?
1989 * possible... may not be implemented..
1990 * @cfg {String} header_image src url of image.
1991 * @cfg {String|Object} header
1992 * @cfg {Number} header_size (0|1|2|3|4|5) H1 or H2 etc.. 0 indicates default
1993 * @cfg {Number} header_weight (primary|secondary|success|info|warning|danger|light|dark)
1995 * @cfg {String} title
1996 * @cfg {String} subtitle
1997 * @cfg {String|Boolean} html -- html contents - or just use children.. use false to hide it..
1998 * @cfg {String} footer
2000 * @cfg {String} weight (primary|warning|info|danger|secondary|success|light|dark)
2002 * @cfg {String} margin (0|1|2|3|4|5|auto)
2003 * @cfg {String} margin_top (0|1|2|3|4|5|auto)
2004 * @cfg {String} margin_bottom (0|1|2|3|4|5|auto)
2005 * @cfg {String} margin_left (0|1|2|3|4|5|auto)
2006 * @cfg {String} margin_right (0|1|2|3|4|5|auto)
2007 * @cfg {String} margin_x (0|1|2|3|4|5|auto)
2008 * @cfg {String} margin_y (0|1|2|3|4|5|auto)
2010 * @cfg {String} padding (0|1|2|3|4|5)
2011 * @cfg {String} padding_top (0|1|2|3|4|5)next_to_card
2012 * @cfg {String} padding_bottom (0|1|2|3|4|5)
2013 * @cfg {String} padding_left (0|1|2|3|4|5)
2014 * @cfg {String} padding_right (0|1|2|3|4|5)
2015 * @cfg {String} padding_x (0|1|2|3|4|5)
2016 * @cfg {String} padding_y (0|1|2|3|4|5)
2018 * @cfg {String} display (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
2019 * @cfg {String} display_xs (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
2020 * @cfg {String} display_sm (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
2021 * @cfg {String} display_lg (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
2022 * @cfg {String} display_xl (none|inline|inline-block|block|table|table-cell|table-row|flex|inline-flex)
2024 * @config {Boolean} dragable if this card can be dragged.
2025 * @config {String} drag_group group for drag
2026 * @config {Boolean} dropable if this card can recieve other cards being dropped onto it..
2027 * @config {String} drop_group group for drag
2029 * @config {Boolean} collapsable can the body be collapsed.
2030 * @config {Boolean} collapsed is the body collapsed when rendered...
2031 * @config {Boolean} rotateable can the body be rotated by clicking on it..
2032 * @config {Boolean} rotated is the body rotated when rendered...
2035 * Create a new Container
2036 * @param {Object} config The config object
2039 Roo.bootstrap.Card = function(config){
2040 Roo.bootstrap.Card.superclass.constructor.call(this, config);
2046 * When a element a card is dropped
2047 * @param {Roo.bootstrap.Card} this
2050 * @param {Roo.bootstrap.Card} move_card the card being dropped?
2051 * @param {String} position 'above' or 'below'
2052 * @param {Roo.bootstrap.Card} next_to_card What card position is relative to of 'false' for empty list.
2058 * When a element a card is rotate
2059 * @param {Roo.bootstrap.Card} this
2060 * @param {Roo.Element} n the node being dropped?
2061 * @param {Boolean} rotate status
2066 * When a card element is dragged over ready to drop (return false to block dropable)
2067 * @param {Roo.bootstrap.Card} this
2068 * @param {Object} data from dragdrop
2076 Roo.extend(Roo.bootstrap.Card, Roo.bootstrap.Component, {
2081 margin: '', /// may be better in component?
2111 collapsable : false,
2120 childContainer : false,
2121 dropEl : false, /// the dom placeholde element that indicates drop location.
2122 containerEl: false, // body container
2123 bodyEl: false, // card-body
2124 headerContainerEl : false, //
2126 header_imageEl : false,
2129 layoutCls : function()
2133 Roo.log(this.margin_bottom.length);
2134 ['', 'top', 'bottom', 'left', 'right', 'x', 'y' ].forEach(function(v) {
2135 // in theory these can do margin_top : ml-xs-3 ??? but we don't support that yet
2137 if (('' + t['margin' + (v.length ? '_' : '') + v]).length) {
2138 cls += ' m' + (v.length ? v[0] : '') + '-' + t['margin' + (v.length ? '_' : '') + v];
2140 if (('' + t['padding' + (v.length ? '_' : '') + v]).length) {
2141 cls += ' p' + (v.length ? v[0] : '') + '-' + t['padding' + (v.length ? '_' : '') + v];
2145 ['', 'xs', 'sm', 'lg', 'xl'].forEach(function(v) {
2146 if (('' + t['display' + (v.length ? '_' : '') + v]).length) {
2147 cls += ' d' + (v.length ? '-' : '') + v + '-' + t['display' + (v.length ? '_' : '') + v]
2151 // more generic support?
2159 // Roo.log("Call onRender: " + this.xtype);
2160 /* We are looking at something like this.
2162 <img src="..." class="card-img-top" alt="...">
2163 <div class="card-body">
2164 <h5 class="card-title">Card title</h5>
2165 <h6 class="card-subtitle mb-2 text-muted">Card subtitle</h6>
2167 >> this bit is really the body...
2168 <div> << we will ad dthis in hopefully it will not break shit.
2170 ** card text does not actually have any styling...
2172 <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>
2175 <a href="#" class="card-link">Card link</a>
2178 <div class="card-footer">
2179 <small class="text-muted">Last updated 3 mins ago</small>
2183 getAutoCreate : function(){
2191 if (this.weight.length && this.weight != 'light') {
2192 cfg.cls += ' text-white';
2194 cfg.cls += ' text-dark'; // need as it's nested..
2196 if (this.weight.length) {
2197 cfg.cls += ' bg-' + this.weight;
2200 cfg.cls += ' ' + this.layoutCls();
2203 var hdr_ctr = false;
2204 if (this.header.length) {
2206 tag : this.header_size > 0 ? 'h' + this.header_size : 'div',
2207 cls : 'card-header ' + (this.header_weight ? 'bg-' + this.header_weight : ''),
2215 cls : 'card-header d-none ' + (this.header_weight ? 'bg-' + this.header_weight : ''),
2221 if (this.collapsable) {
2224 cls : 'd-block user-select-none',
2228 cls : 'roo-collapse-toggle fa fa-chevron-down float-right ' + (this.collapsed ? 'collapsed' : '')
2233 hdr.cn.push(hdr_ctr);
2238 cls: 'roo-card-header-ctr' + ( this.header.length ? '' : ' d-none'),
2243 if (this.header_image.length) {
2246 cls : 'card-img-top',
2247 src: this.header_image // escape?
2252 cls : 'card-img-top d-none'
2258 cls : 'card-body' + (this.html === false ? ' d-none' : ''),
2262 if (this.collapsable || this.rotateable) {
2265 cls : 'roo-collapsable collapse ' + (this.collapsed || this.rotated ? '' : 'show'),
2272 if (this.title.length) {
2276 src: this.title // escape?
2280 if (this.subtitle.length) {
2284 src: this.subtitle // escape?
2290 cls : 'roo-card-body-ctr'
2293 if (this.html.length) {
2299 // fixme ? handle objects?
2301 if (this.footer.length) {
2304 cls : 'card-footer ' + (this.rotated ? 'd-none' : ''),
2309 cfg.cn.push({cls : 'card-footer d-none'});
2318 getCardHeader : function()
2320 var ret = this.el.select('.card-header',true).first();
2321 if (ret.hasClass('d-none')) {
2322 ret.removeClass('d-none');
2327 getCardFooter : function()
2329 var ret = this.el.select('.card-footer',true).first();
2330 if (ret.hasClass('d-none')) {
2331 ret.removeClass('d-none');
2336 getCardImageTop : function()
2338 var ret = this.header_imageEl;
2339 if (ret.hasClass('d-none')) {
2340 ret.removeClass('d-none');
2346 getChildContainer : function()
2352 return this.el.select('.roo-card-body-ctr',true).first();
2355 initEvents: function()
2357 this.bodyEl = this.el.select('.card-body',true).first();
2358 this.containerEl = this.getChildContainer();
2360 this.dragZone = new Roo.dd.DragZone(this.getEl(), {
2361 containerScroll: true,
2362 ddGroup: this.drag_group || 'default_card_drag_group'
2364 this.dragZone.getDragData = this.getDragData.createDelegate(this);
2366 if (this.dropable) {
2367 this.dropZone = new Roo.dd.DropZone(this.el.select('.card-body',true).first() , {
2368 containerScroll: true,
2369 ddGroup: this.drop_group || 'default_card_drag_group'
2371 this.dropZone.getTargetFromEvent = this.getTargetFromEvent.createDelegate(this);
2372 this.dropZone.onNodeEnter = this.onNodeEnter.createDelegate(this);
2373 this.dropZone.onNodeOver = this.onNodeOver.createDelegate(this);
2374 this.dropZone.onNodeOut = this.onNodeOut.createDelegate(this);
2375 this.dropZone.onNodeDrop = this.onNodeDrop.createDelegate(this);
2378 if (this.collapsable) {
2379 this.el.select('.card-header',true).on('click', this.onToggleCollapse, this);
2381 if (this.rotateable) {
2382 this.el.select('.card-header',true).on('click', this.onToggleRotate, this);
2384 this.collapsableEl = this.el.select('.roo-collapsable',true).first();
2386 this.footerEl = this.el.select('.card-footer',true).first();
2387 this.collapsableToggleEl = this.el.select('.roo-collapse-toggle',true).first();
2388 this.headerContainerEl = this.el.select('.roo-card-header-ctr',true).first();
2389 this.headerEl = this.el.select('.card-header',true).first();
2392 this.el.addClass('roo-card-rotated');
2393 this.fireEvent('rotate', this, true);
2395 this.header_imageEl = this.el.select('.card-img-top',true).first();
2396 this.header_imageEl.on('load', this.onHeaderImageLoad, this );
2399 getDragData : function(e)
2401 var target = this.getEl();
2403 //this.handleSelection(e);
2408 nodes: this.getEl(),
2413 dragData.ddel = target.dom ; // the div element
2414 Roo.log(target.getWidth( ));
2415 dragData.ddel.style.width = target.getWidth() + 'px';
2422 * Part of the Roo.dd.DropZone interface. If no target node is found, the
2423 * whole Element becomes the target, and this causes the drop gesture to append.
2425 * Returns an object:
2428 position : 'below' or 'above'
2429 card : relateive to card OBJECT (or true for no cards listed)
2430 items_n : relative to nth item in list
2431 card_n : relative to nth card in list
2436 getTargetFromEvent : function(e, dragged_card_el)
2438 var target = e.getTarget();
2439 while ((target !== null) && (target.parentNode != this.containerEl.dom)) {
2440 target = target.parentNode;
2451 //Roo.log([ 'target' , target ? target.id : '--nothing--']);
2452 // see if target is one of the 'cards'...
2455 //Roo.log(this.items.length);
2458 var last_card_n = 0;
2460 for (var i = 0;i< this.items.length;i++) {
2462 if (!this.items[i].el.hasClass('card')) {
2465 pos = this.getDropPoint(e, this.items[i].el.dom);
2467 cards_len = ret.cards.length;
2468 //Roo.log(this.items[i].el.dom.id);
2469 ret.cards.push(this.items[i]);
2471 if (ret.card_n < 0 && pos == 'above') {
2472 ret.position = cards_len > 0 ? 'below' : pos;
2473 ret.items_n = i > 0 ? i - 1 : 0;
2474 ret.card_n = cards_len > 0 ? cards_len - 1 : 0;
2475 ret.card = ret.cards[ret.card_n];
2478 if (!ret.cards.length) {
2480 ret.position = 'below';
2484 // could not find a card.. stick it at the end..
2485 if (ret.card_n < 0) {
2486 ret.card_n = last_card_n;
2487 ret.card = ret.cards[last_card_n];
2488 ret.items_n = this.items.indexOf(ret.cards[last_card_n]);
2489 ret.position = 'below';
2492 if (this.items[ret.items_n].el == dragged_card_el) {
2496 if (ret.position == 'below') {
2497 var card_after = ret.card_n+1 == ret.cards.length ? false : ret.cards[ret.card_n+1];
2499 if (card_after && card_after.el == dragged_card_el) {
2506 var card_before = ret.card_n > 0 ? ret.cards[ret.card_n-1] : false;
2508 if (card_before && card_before.el == dragged_card_el) {
2515 onNodeEnter : function(n, dd, e, data){
2518 onNodeOver : function(n, dd, e, data)
2521 var target_info = this.getTargetFromEvent(e,data.source.el);
2522 if (target_info === false) {
2523 this.dropPlaceHolder('hide');
2526 Roo.log(['getTargetFromEvent', target_info ]);
2529 if (this.fireEvent('cardover', this, [ data ]) === false) {
2533 this.dropPlaceHolder('show', target_info,data);
2537 onNodeOut : function(n, dd, e, data){
2538 this.dropPlaceHolder('hide');
2541 onNodeDrop : function(n, dd, e, data)
2544 // call drop - return false if
2546 // this could actually fail - if the Network drops..
2547 // we will ignore this at present..- client should probably reload
2548 // the whole set of cards if stuff like that fails.
2551 var info = this.getTargetFromEvent(e,data.source.el);
2552 if (info === false) {
2555 this.dropPlaceHolder('hide');
2559 this.acceptCard(data.source, info.position, info.card, info.items_n);
2563 firstChildCard : function()
2565 for (var i = 0;i< this.items.length;i++) {
2567 if (!this.items[i].el.hasClass('card')) {
2570 return this.items[i];
2572 return this.items.length ? this.items[this.items.length-1] : false; // don't try and put stuff after the cards...
2577 * - card.acceptCard(move_card, info.position, info.card, info.items_n);
2579 acceptCard : function(move_card, position, next_to_card )
2581 if (this.fireEvent("drop", this, move_card, position, next_to_card) === false) {
2585 var to_items_n = next_to_card ? this.items.indexOf(next_to_card) : 0;
2587 move_card.parent().removeCard(move_card);
2590 var dom = move_card.el.dom;
2591 dom.style.width = ''; // clear with - which is set by drag.
2593 if (next_to_card !== false && next_to_card !== true && next_to_card.el.dom.parentNode) {
2594 var cardel = next_to_card.el.dom;
2596 if (position == 'above' ) {
2597 cardel.parentNode.insertBefore(dom, cardel);
2598 } else if (cardel.nextSibling) {
2599 cardel.parentNode.insertBefore(dom,cardel.nextSibling);
2601 cardel.parentNode.append(dom);
2604 // card container???
2605 this.containerEl.dom.append(dom);
2608 //FIXME HANDLE card = true
2610 // add this to the correct place in items.
2612 // remove Card from items.
2615 if (this.items.length) {
2617 //Roo.log([info.items_n, info.position, this.items.length]);
2618 for (var i =0; i < this.items.length; i++) {
2619 if (i == to_items_n && position == 'above') {
2620 nitems.push(move_card);
2622 nitems.push(this.items[i]);
2623 if (i == to_items_n && position == 'below') {
2624 nitems.push(move_card);
2627 this.items = nitems;
2628 Roo.log(this.items);
2630 this.items.push(move_card);
2633 move_card.parentId = this.id;
2639 removeCard : function(c)
2641 this.items = this.items.filter(function(e) { return e != c });
2644 dom.parentNode.removeChild(dom);
2645 dom.style.width = ''; // clear with - which is set by drag.
2650 /** Decide whether to drop above or below a View node. */
2651 getDropPoint : function(e, n, dd)
2656 if (n == this.containerEl.dom) {
2659 var t = Roo.lib.Dom.getY(n), b = t + n.offsetHeight;
2660 var c = t + (b - t) / 2;
2661 var y = Roo.lib.Event.getPageY(e);
2668 onToggleCollapse : function(e)
2670 if (this.collapsed) {
2671 this.el.select('.roo-collapse-toggle').removeClass('collapsed');
2672 this.collapsableEl.addClass('show');
2673 this.collapsed = false;
2676 this.el.select('.roo-collapse-toggle').addClass('collapsed');
2677 this.collapsableEl.removeClass('show');
2678 this.collapsed = true;
2683 onToggleRotate : function(e)
2685 this.collapsableEl.removeClass('show');
2686 this.footerEl.removeClass('d-none');
2687 this.el.removeClass('roo-card-rotated');
2688 this.el.removeClass('d-none');
2691 this.collapsableEl.addClass('show');
2692 this.rotated = false;
2693 this.fireEvent('rotate', this, this.rotated);
2696 this.el.addClass('roo-card-rotated');
2697 this.footerEl.addClass('d-none');
2698 this.el.select('.roo-collapsable').removeClass('show');
2700 this.rotated = true;
2701 this.fireEvent('rotate', this, this.rotated);
2705 dropPlaceHolder: function (action, info, data)
2707 if (this.dropEl === false) {
2708 this.dropEl = Roo.DomHelper.append(this.containerEl, {
2712 this.dropEl.removeClass(['d-none', 'd-block']);
2713 if (action == 'hide') {
2715 this.dropEl.addClass('d-none');
2718 // FIXME - info.card == true!!!
2719 this.dropEl.dom.parentNode.removeChild(this.dropEl.dom);
2721 if (info.card !== true) {
2722 var cardel = info.card.el.dom;
2724 if (info.position == 'above') {
2725 cardel.parentNode.insertBefore(this.dropEl.dom, cardel);
2726 } else if (cardel.nextSibling) {
2727 cardel.parentNode.insertBefore(this.dropEl.dom,cardel.nextSibling);
2729 cardel.parentNode.append(this.dropEl.dom);
2732 // card container???
2733 this.containerEl.dom.append(this.dropEl.dom);
2736 this.dropEl.addClass('d-block roo-card-dropzone');
2738 this.dropEl.setHeight( Roo.get(data.ddel).getHeight() );
2745 setHeaderText: function(html)
2748 if (this.headerContainerEl) {
2749 this.headerContainerEl.dom.innerHTML = html;
2752 onHeaderImageLoad : function(ev, he)
2754 if (!this.header_image_fit_square) {
2758 var hw = he.naturalHeight / he.naturalWidth;
2761 //var w = he.dom.naturalWidth;
2764 he.style.position = 'relative';
2766 var nw = (ww * (1/hw));
2767 Roo.get(he).setSize( ww * (1/hw), ww);
2768 he.style.left = ((ww - nw)/ 2) + 'px';
2769 he.style.position = 'relative';
2780 * Card header - holder for the card header elements.
2785 * @class Roo.bootstrap.CardHeader
2786 * @extends Roo.bootstrap.Element
2787 * @parent Roo.bootstrap.Card
2788 * @children Roo.bootstrap.Component
2789 * Bootstrap CardHeader class
2791 * Create a new Card Header - that you can embed children into
2792 * @param {Object} config The config object
2795 Roo.bootstrap.CardHeader = function(config){
2796 Roo.bootstrap.CardHeader.superclass.constructor.call(this, config);
2799 Roo.extend(Roo.bootstrap.CardHeader, Roo.bootstrap.Element, {
2802 container_method : 'getCardHeader'
2815 * Card footer - holder for the card footer elements.
2820 * @class Roo.bootstrap.CardFooter
2821 * @extends Roo.bootstrap.Element
2822 * @parent Roo.bootstrap.Card
2823 * @children Roo.bootstrap.Component
2824 * Bootstrap CardFooter class
2827 * Create a new Card Footer - that you can embed children into
2828 * @param {Object} config The config object
2831 Roo.bootstrap.CardFooter = function(config){
2832 Roo.bootstrap.CardFooter.superclass.constructor.call(this, config);
2835 Roo.extend(Roo.bootstrap.CardFooter, Roo.bootstrap.Element, {
2838 container_method : 'getCardFooter'
2851 * Card header - holder for the card header elements.
2856 * @class Roo.bootstrap.CardImageTop
2857 * @extends Roo.bootstrap.Element
2858 * @parent Roo.bootstrap.Card
2859 * @children Roo.bootstrap.Component
2860 * Bootstrap CardImageTop class
2863 * Create a new Card Image Top container
2864 * @param {Object} config The config object
2867 Roo.bootstrap.CardImageTop = function(config){
2868 Roo.bootstrap.CardImageTop.superclass.constructor.call(this, config);
2871 Roo.extend(Roo.bootstrap.CardImageTop, Roo.bootstrap.Element, {
2874 container_method : 'getCardImageTop'
2889 * @class Roo.bootstrap.ButtonUploader
2890 * @extends Roo.bootstrap.Button
2891 * Bootstrap Button Uploader class - it's a button which when you add files to it
2894 * @cfg {Number} errorTimeout default 3000
2895 * @cfg {Array} images an array of ?? Img objects ??? when loading existing files..
2896 * @cfg {Array} html The button text.
2897 * @cfg {Boolean} multiple (default true) Should the upload allow multiple files to be uploaded.
2900 * Create a new CardUploader
2901 * @param {Object} config The config object
2904 Roo.bootstrap.ButtonUploader = function(config){
2908 Roo.bootstrap.ButtonUploader.superclass.constructor.call(this, config);
2914 * @event beforeselect
2915 * When button is pressed, before show upload files dialog is shown
2916 * @param {Roo.bootstrap.UploaderButton} this
2919 'beforeselect' : true,
2921 * @event fired when files have been selected,
2922 * When a the download link is clicked
2923 * @param {Roo.bootstrap.UploaderButton} this
2924 * @param {Array} Array of files that have been uploaded
2931 Roo.extend(Roo.bootstrap.ButtonUploader, Roo.bootstrap.Button, {
2934 errorTimeout : 3000,
2938 fileCollection : false,
2943 getAutoCreate : function()
2950 Roo.bootstrap.Button.prototype.getAutoCreate.call(this)
2958 initEvents : function()
2961 Roo.bootstrap.Button.prototype.initEvents.call(this);
2967 this.urlAPI = (window.createObjectURL && window) ||
2968 (window.URL && URL.revokeObjectURL && URL) ||
2969 (window.webkitURL && webkitURL);
2974 cls : 'd-none roo-card-upload-selector'
2977 if (this.multiple) {
2978 im.multiple = 'multiple';
2980 this.selectorEl = Roo.get(document.body).createChild(im); // so it does not capture click event for navitem.
2982 //this.selectorEl = this.el.select('.roo-card-upload-selector', true).first();
2984 this.selectorEl.on('change', this.onFileSelected, this);
2991 onClick : function(e)
2995 if ( this.fireEvent('beforeselect', this) === false) {
2999 this.selectorEl.dom.click();
3003 onFileSelected : function(e)
3007 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
3010 var files = Array.prototype.slice.call(this.selectorEl.dom.files);
3011 this.selectorEl.dom.value = '';// hopefully reset..
3013 this.fireEvent('uploaded', this, files );
3021 * addCard - add an Attachment to the uploader
3022 * @param data - the data about the image to upload
3026 title : "Title of file",
3027 is_uploaded : false,
3028 src : "http://.....",
3029 srcfile : { the File upload object },
3030 mimetype : file.type,
3033 .. any other data...
3058 * @class Roo.bootstrap.Img
3059 * @extends Roo.bootstrap.Component
3060 * Bootstrap Img class
3061 * @cfg {Boolean} imgResponsive false | true
3062 * @cfg {String} border rounded | circle | thumbnail
3063 * @cfg {String} src image source
3064 * @cfg {String} alt image alternative text
3065 * @cfg {String} href a tag href
3066 * @cfg {String} target (_self|_blank|_parent|_top)target for a href.
3067 * @cfg {String} xsUrl xs image source
3068 * @cfg {String} smUrl sm image source
3069 * @cfg {String} mdUrl md image source
3070 * @cfg {String} lgUrl lg image source
3071 * @cfg {Boolean} backgroundContain (use style background and contain image in content)
3074 * Create a new Input
3075 * @param {Object} config The config object
3078 Roo.bootstrap.Img = function(config){
3079 Roo.bootstrap.Img.superclass.constructor.call(this, config);
3085 * The img click event for the img.
3086 * @param {Roo.EventObject} e
3091 * The when any image loads
3092 * @param {Roo.EventObject} e
3098 Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, {
3100 imgResponsive: true,
3109 backgroundContain : false,
3111 getAutoCreate : function()
3113 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
3114 return this.createSingleImg();
3119 cls: 'roo-image-responsive-group',
3124 Roo.each(['xs', 'sm', 'md', 'lg'], function(size){
3126 if(!_this[size + 'Url']){
3132 cls: (_this.imgResponsive) ? 'img-responsive' : '',
3133 html: _this.html || cfg.html,
3134 src: _this[size + 'Url']
3137 img.cls += ' roo-image-responsive-' + size;
3139 var s = ['xs', 'sm', 'md', 'lg'];
3141 s.splice(s.indexOf(size), 1);
3143 Roo.each(s, function(ss){
3144 img.cls += ' hidden-' + ss;
3147 if (['rounded','circle','thumbnail'].indexOf(_this.border)>-1) {
3148 cfg.cls += ' img-' + _this.border;
3152 cfg.alt = _this.alt;
3165 a.target = _this.target;
3169 cfg.cn.push((_this.href) ? a : img);
3176 createSingleImg : function()
3180 cls: (this.imgResponsive) ? 'img-responsive' : '',
3182 src : Roo.BLANK_IMAGE_URL // just incase src get's set to undefined?!?
3185 if (this.backgroundContain) {
3186 cfg.cls += ' background-contain';
3189 cfg.html = this.html || cfg.html;
3191 if (this.backgroundContain) {
3192 cfg.style="background-image: url(" + this.src + ')';
3194 cfg.src = this.src || cfg.src;
3197 if (['rounded','circle','thumbnail'].indexOf(this.border)>-1) {
3198 cfg.cls += ' img-' + this.border;
3215 a.target = this.target;
3220 return (this.href) ? a : cfg;
3223 initEvents: function()
3226 this.el.on('click', this.onClick, this);
3228 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
3229 this.el.on('load', this.onImageLoad, this);
3231 // not sure if this works.. not tested
3232 this.el.select('img', true).on('load', this.onImageLoad, this);
3237 onClick : function(e)
3239 Roo.log('img onclick');
3240 this.fireEvent('click', this, e);
3242 onImageLoad: function(e)
3244 Roo.log('img load');
3245 this.fireEvent('load', this, e);
3249 * Sets the url of the image - used to update it
3250 * @param {String} url the url of the image
3253 setSrc : function(url)
3257 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
3258 if (this.backgroundContain) {
3259 this.el.dom.style.backgroundImage = 'url(' + url + ')';
3261 this.el.dom.src = url;
3266 this.el.select('img', true).first().dom.src = url;
3282 * @class Roo.bootstrap.Link
3283 * @extends Roo.bootstrap.Component
3284 * @children Roo.bootstrap.Component
3285 * Bootstrap Link Class (eg. '<a href>')
3287 * @cfg {String} alt image alternative text
3288 * @cfg {String} href a tag href
3289 * @cfg {String} target (_self|_blank|_parent|_top) target for a href.
3290 * @cfg {String} html the content of the link.
3291 * @cfg {String} anchor name for the anchor link
3292 * @cfg {String} fa - favicon
3294 * @cfg {Boolean} preventDefault (true | false) default false
3298 * Create a new Input
3299 * @param {Object} config The config object
3302 Roo.bootstrap.Link = function(config){
3303 Roo.bootstrap.Link.superclass.constructor.call(this, config);
3309 * The img click event for the img.
3310 * @param {Roo.EventObject} e
3316 Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component, {
3320 preventDefault: false,
3326 getAutoCreate : function()
3328 var html = this.html || '';
3330 if (this.fa !== false) {
3331 html = '<i class="fa fa-' + this.fa + '"></i>';
3336 // anchor's do not require html/href...
3337 if (this.anchor === false) {
3339 cfg.href = this.href || '#';
3341 cfg.name = this.anchor;
3342 if (this.html !== false || this.fa !== false) {
3345 if (this.href !== false) {
3346 cfg.href = this.href;
3350 if(this.alt !== false){
3355 if(this.target !== false) {
3356 cfg.target = this.target;
3362 initEvents: function() {
3364 if(!this.href || this.preventDefault){
3365 this.el.on('click', this.onClick, this);
3369 onClick : function(e)
3371 if(this.preventDefault){
3374 //Roo.log('img onclick');
3375 this.fireEvent('click', this, e);
3388 * @class Roo.bootstrap.Header
3389 * @extends Roo.bootstrap.Component
3390 * @children Roo.bootstrap.Component
3391 * Bootstrap Header class
3394 * @cfg {String} html content of header
3395 * @cfg {Number} level (1|2|3|4|5|6) default 1
3398 * Create a new Header
3399 * @param {Object} config The config object
3403 Roo.bootstrap.Header = function(config){
3404 Roo.bootstrap.Header.superclass.constructor.call(this, config);
3407 Roo.extend(Roo.bootstrap.Header, Roo.bootstrap.Component, {
3415 getAutoCreate : function(){
3420 tag: 'h' + (1 *this.level),
3421 html: this.html || ''
3432 * @class Roo.bootstrap.MenuMgr
3434 * Provides a common registry of all menu items on a page so that they can be easily accessed by id.
3437 Roo.bootstrap.menu.Manager = function(){
3438 var menus, active, groups = {}, attached = false, lastShow = new Date();
3440 // private - called when first menu is created
3443 active = new Roo.util.MixedCollection();
3444 Roo.get(document).addKeyListener(27, function(){
3445 if(active.length > 0){
3453 if(active && active.length > 0){
3454 var c = active.clone();
3464 if(active.length < 1){
3465 Roo.get(document).un("mouseup", onMouseDown);
3473 var last = active.last();
3474 lastShow = new Date();
3477 Roo.get(document).on("mouseup", onMouseDown);
3482 //m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
3483 m.parentMenu.activeChild = m;
3484 }else if(last && last.isVisible()){
3485 //m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
3490 function onBeforeHide(m){
3492 m.activeChild.hide();
3494 if(m.autoHideTimer){
3495 clearTimeout(m.autoHideTimer);
3496 delete m.autoHideTimer;
3501 function onBeforeShow(m){
3502 var pm = m.parentMenu;
3503 if(!pm && !m.allowOtherMenus){
3505 }else if(pm && pm.activeChild && active != m){
3506 pm.activeChild.hide();
3510 // private this should really trigger on mouseup..
3511 function onMouseDown(e){
3512 Roo.log("on Mouse Up");
3514 if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".dropdown-menu") && !e.getTarget('.user-menu')){
3515 Roo.log("MenuManager hideAll");
3524 function onBeforeCheck(mi, state){
3526 var g = groups[mi.group];
3527 for(var i = 0, l = g.length; i < l; i++){
3529 g[i].setChecked(false);
3538 * Hides all menus that are currently visible
3540 hideAll : function(){
3545 register : function(menu){
3549 menus[menu.id] = menu;
3550 menu.on("beforehide", onBeforeHide);
3551 menu.on("hide", onHide);
3552 menu.on("beforeshow", onBeforeShow);
3553 menu.on("show", onShow);
3555 if(g && menu.events["checkchange"]){
3559 groups[g].push(menu);
3560 menu.on("checkchange", onCheck);
3565 * Returns a {@link Roo.menu.Menu} object
3566 * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will
3567 * be used to generate and return a new Menu instance.
3569 get : function(menu){
3570 if(typeof menu == "string"){ // menu id
3572 }else if(menu.events){ // menu instance
3575 /*else if(typeof menu.length == 'number'){ // array of menu items?
3576 return new Roo.bootstrap.Menu({items:menu});
3577 }else{ // otherwise, must be a config
3578 return new Roo.bootstrap.Menu(menu);
3585 unregister : function(menu){
3586 delete menus[menu.id];
3587 menu.un("beforehide", onBeforeHide);
3588 menu.un("hide", onHide);
3589 menu.un("beforeshow", onBeforeShow);
3590 menu.un("show", onShow);
3592 if(g && menu.events["checkchange"]){
3593 groups[g].remove(menu);
3594 menu.un("checkchange", onCheck);
3599 registerCheckable : function(menuItem){
3600 var g = menuItem.group;
3605 groups[g].push(menuItem);
3606 menuItem.on("beforecheckchange", onBeforeCheck);
3611 unregisterCheckable : function(menuItem){
3612 var g = menuItem.group;
3614 groups[g].remove(menuItem);
3615 menuItem.un("beforecheckchange", onBeforeCheck);
3621 * @class Roo.bootstrap.menu.Menu
3622 * @extends Roo.bootstrap.Component
3624 * @children Roo.bootstrap.menu.Item Roo.bootstrap.menu.Separator
3626 * Bootstrap Menu class - container for MenuItems - normally has to be added to a object that supports the menu property
3628 * @cfg {String} type (dropdown|treeview|submenu) type of menu
3629 * @cfg {bool} hidden if the menu should be hidden when rendered.
3630 * @cfg {bool} stopEvent (true|false) Stop event after trigger press (default true)
3631 * @cfg {bool} isLink (true|false) the menu has link disable auto expand and collaspe (default false)
3632 * @cfg {bool} hideTrigger (true|false) default false - hide the carret for trigger.
3633 * @cfg {String} align default tl-bl? == below - how the menu should be aligned.
3637 * @param {Object} config The config objectQ
3641 Roo.bootstrap.menu.Menu = function(config){
3643 if (config.type == 'treeview') {
3644 // normally menu's are drawn attached to the document to handle layering etc..
3645 // however treeview (used by the docs menu is drawn into the parent element)
3646 this.container_method = 'getChildContainer';
3649 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
3650 if (this.registerMenu && this.type != 'treeview') {
3651 Roo.bootstrap.menu.Manager.register(this);
3658 * Fires before this menu is displayed (return false to block)
3659 * @param {Roo.menu.Menu} this
3664 * Fires before this menu is hidden (return false to block)
3665 * @param {Roo.menu.Menu} this
3670 * Fires after this menu is displayed
3671 * @param {Roo.menu.Menu} this
3676 * Fires after this menu is hidden
3677 * @param {Roo.menu.Menu} this
3682 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
3683 * @param {Roo.menu.Menu} this
3684 * @param {Roo.menu.Item} menuItem The menu item that was clicked
3685 * @param {Roo.EventObject} e
3690 * Fires when the mouse is hovering over this menu
3691 * @param {Roo.menu.Menu} this
3692 * @param {Roo.EventObject} e
3693 * @param {Roo.menu.Item} menuItem The menu item that was clicked
3698 * Fires when the mouse exits this menu
3699 * @param {Roo.menu.Menu} this
3700 * @param {Roo.EventObject} e
3701 * @param {Roo.menu.Item} menuItem The menu item that was clicked
3706 * Fires when a menu item contained in this menu is clicked
3707 * @param {Roo.menu.BaseItem} baseItem The BaseItem that was clicked
3708 * @param {Roo.EventObject} e
3712 this.menuitems = new Roo.util.MixedCollection(false, function(o) { return o.el.id; });
3715 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
3719 triggerEl : false, // is this set by component builder? -- it should really be fetched from parent()???
3722 * @cfg {Boolean} registerMenu True (default) - means that clicking on screen etc. hides it.
3724 registerMenu : true,
3726 menuItems :false, // stores the menu items..
3736 container_method : 'getDocumentBody', // so the menu is rendered on the body and zIndex works.
3738 hideTrigger : false,
3743 getChildContainer : function() {
3747 getAutoCreate : function(){
3749 //if (['right'].indexOf(this.align)!==-1) {
3750 // cfg.cn[1].cls += ' pull-right'
3755 cls : 'dropdown-menu shadow' ,
3756 style : 'z-index:1000'
3760 if (this.type === 'submenu') {
3761 cfg.cls = 'submenu active';
3763 if (this.type === 'treeview') {
3764 cfg.cls = 'treeview-menu';
3769 initEvents : function() {
3771 // Roo.log("ADD event");
3772 // Roo.log(this.triggerEl.dom);
3773 if (this.triggerEl) {
3775 this.triggerEl.on('click', this.onTriggerClick, this);
3777 this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this);
3779 if (!this.hideTrigger) {
3780 if (this.triggerEl.hasClass('nav-item') && this.triggerEl.select('.nav-link',true).length) {
3781 // dropdown toggle on the 'a' in BS4?
3782 this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle');
3784 this.triggerEl.addClass('dropdown-toggle');
3790 this.el.on('touchstart' , this.onTouch, this);
3792 this.el.on('click' , this.onClick, this);
3794 this.el.on("mouseover", this.onMouseOver, this);
3795 this.el.on("mouseout", this.onMouseOut, this);
3799 findTargetItem : function(e)
3801 var t = e.getTarget(".dropdown-menu-item", this.el, true);
3805 //Roo.log(t); Roo.log(t.id);
3807 //Roo.log(this.menuitems);
3808 return this.menuitems.get(t.id);
3810 //return this.items.get(t.menuItemId);
3816 onTouch : function(e)
3818 Roo.log("menu.onTouch");
3819 //e.stopEvent(); this make the user popdown broken
3823 onClick : function(e)
3825 Roo.log("menu.onClick");
3827 var t = this.findTargetItem(e);
3828 if(!t || t.isContainer){
3833 if (Roo.isTouch && e.type == 'touchstart' && t.menu && !t.disabled) {
3834 if(t == this.activeItem && t.shouldDeactivate(e)){
3835 this.activeItem.deactivate();
3836 delete this.activeItem;
3840 this.setActiveItem(t, true);
3848 Roo.log('pass click event');
3852 this.fireEvent("click", this, t, e);
3856 if(!t.href.length || t.href == '#'){
3857 (function() { _this.hide(); }).defer(100);
3862 onMouseOver : function(e){
3863 var t = this.findTargetItem(e);
3866 // if(t.canActivate && !t.disabled){
3867 // this.setActiveItem(t, true);
3871 this.fireEvent("mouseover", this, e, t);
3873 isVisible : function(){
3874 return !this.hidden;
3876 onMouseOut : function(e){
3877 var t = this.findTargetItem(e);
3880 // if(t == this.activeItem && t.shouldDeactivate(e)){
3881 // this.activeItem.deactivate();
3882 // delete this.activeItem;
3885 this.fireEvent("mouseout", this, e, t);
3890 * Displays this menu relative to another element
3891 * @param {String/HTMLElement/Roo.Element} element The element to align to
3892 * @param {String} position (optional) The {@link Roo.Element#alignTo} anchor position to use in aligning to
3893 * the element (defaults to this.defaultAlign)
3894 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
3896 show : function(el, pos, parentMenu)
3898 if (false === this.fireEvent("beforeshow", this)) {
3899 Roo.log("show canceled");
3902 this.parentMenu = parentMenu;
3906 this.el.addClass('show'); // show otherwise we do not know how big we are..
3908 var xy = this.el.getAlignToXY(el, pos);
3910 // bl-tl << left align below
3911 // tl-bl << left align
3913 if(this.el.getWidth() + xy[0] >= Roo.lib.Dom.getViewWidth()){
3914 // if it goes to far to the right.. -> align left.
3915 xy = this.el.getAlignToXY(el, this.align.replace('/l/g', 'r'))
3918 // was left align - go right?
3919 xy = this.el.getAlignToXY(el, this.align.replace('/r/g', 'l'))
3922 // goes down the bottom
3923 if(this.el.getHeight() + xy[1] >= Roo.lib.Dom.getViewHeight() ||
3925 var a = this.align.replace('?', '').split('-');
3926 xy = this.el.getAlignToXY(el, a[1] + '-' + a[0] + '?')
3930 this.showAt( xy , parentMenu, false);
3933 * Displays this menu at a specific xy position
3934 * @param {Array} xyPosition Contains X & Y [x, y] values for the position at which to show the menu (coordinates are page-based)
3935 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
3937 showAt : function(xy, parentMenu, /* private: */_e){
3938 this.parentMenu = parentMenu;
3943 this.fireEvent("beforeshow", this);
3944 //xy = this.el.adjustForConstraints(xy);
3948 this.hideMenuItems();
3949 this.hidden = false;
3950 if (this.triggerEl) {
3951 this.triggerEl.addClass('open');
3954 this.el.addClass('show');
3958 // reassign x when hitting right
3960 // reassign y when hitting bottom
3962 // but the list may align on trigger left or trigger top... should it be a properity?
3964 if(this.el.getStyle('top') != 'auto' && this.el.getStyle('top').slice(-1) != "%"){
3969 this.fireEvent("show", this);
3975 this.doFocus.defer(50, this);
3979 doFocus : function(){
3981 this.focusEl.focus();
3986 * Hides this menu and optionally all parent menus
3987 * @param {Boolean} deep (optional) True to hide all parent menus recursively, if any (defaults to false)
3989 hide : function(deep)
3991 if (false === this.fireEvent("beforehide", this)) {
3992 Roo.log("hide canceled");
3995 this.hideMenuItems();
3996 if(this.el && this.isVisible()){
3998 if(this.activeItem){
3999 this.activeItem.deactivate();
4000 this.activeItem = null;
4002 if (this.triggerEl) {
4003 this.triggerEl.removeClass('open');
4006 this.el.removeClass('show');
4008 this.fireEvent("hide", this);
4010 if(deep === true && this.parentMenu){
4011 this.parentMenu.hide(true);
4015 onTriggerClick : function(e)
4017 Roo.log('trigger click');
4019 var target = e.getTarget();
4021 Roo.log(target.nodeName.toLowerCase());
4023 if(target.nodeName.toLowerCase() === 'i'){
4029 onTriggerPress : function(e)
4031 Roo.log('trigger press');
4032 //Roo.log(e.getTarget());
4033 // Roo.log(this.triggerEl.dom);
4035 // trigger only occurs on normal menu's -- if it's a treeview or dropdown... do not hide/show..
4036 var pel = Roo.get(e.getTarget());
4037 if (pel.findParent('.dropdown-menu') || pel.findParent('.treeview-menu') ) {
4038 Roo.log('is treeview or dropdown?');
4042 if(e.getTarget().nodeName.toLowerCase() !== 'i' && this.isLink){
4046 if (this.isVisible()) {
4052 this.show(this.triggerEl, this.align, false);
4055 if(this.stopEvent || e.getTarget().nodeName.toLowerCase() === 'i'){
4062 hideMenuItems : function()
4064 Roo.log("hide Menu Items");
4069 this.el.select('.open',true).each(function(aa) {
4071 aa.removeClass('open');
4075 addxtypeChild : function (tree, cntr) {
4076 var comp= Roo.bootstrap.menu.Menu.superclass.addxtypeChild.call(this, tree, cntr);
4078 this.menuitems.add(comp);
4090 this.getEl().dom.innerHTML = '';
4091 this.menuitems.clear();
4097 * @class Roo.bootstrap.menu.Item
4098 * @extends Roo.bootstrap.Component
4099 * @children Roo.bootstrap.Button Roo.bootstrap.ButtonUploader Roo.bootstrap.Row Roo.bootstrap.Column Roo.bootstrap.Container
4100 * @parent Roo.bootstrap.menu.Menu
4102 * Bootstrap MenuItem class
4104 * @cfg {String} html the menu label
4105 * @cfg {String} href the link
4106 * @cfg {Boolean} preventDefault do not trigger A href on clicks (default false).
4107 * @cfg {Boolean} isContainer is it a container - just returns a drop down item..
4108 * @cfg {Boolean} active used on sidebars to highlight active itesm
4109 * @cfg {String} fa favicon to show on left of menu item.
4110 * @cfg {Roo.bootsrap.Menu} menu the child menu.
4114 * Create a new MenuItem
4115 * @param {Object} config The config object
4119 Roo.bootstrap.menu.Item = function(config){
4120 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
4125 * The raw click event for the entire grid.
4126 * @param {Roo.bootstrap.menu.Item} this
4127 * @param {Roo.EventObject} e
4133 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
4137 preventDefault: false,
4138 isContainer : false,
4142 getAutoCreate : function(){
4144 if(this.isContainer){
4147 cls: 'dropdown-menu-item '
4157 cls : 'dropdown-item',
4162 if (this.fa !== false) {
4165 cls : 'fa fa-' + this.fa
4174 cls: 'dropdown-menu-item',
4177 if (this.parent().type == 'treeview') {
4178 cfg.cls = 'treeview-menu';
4181 cfg.cls += ' active';
4186 anc.href = this.href || cfg.cn[0].href ;
4187 ctag.html = this.html || cfg.cn[0].html ;
4191 initEvents: function()
4193 if (this.parent().type == 'treeview') {
4194 this.el.select('a').on('click', this.onClick, this);
4198 this.menu.parentType = this.xtype;
4199 this.menu.triggerEl = this.el;
4200 this.menu = this.addxtype(Roo.apply({}, this.menu));
4204 onClick : function(e)
4206 //Roo.log('item on click ');
4208 if(this.href === false || this.preventDefault){
4211 //this.parent().hideMenuItems();
4213 this.fireEvent('click', this, e);
4227 * @class Roo.bootstrap.menu.Separator
4228 * @extends Roo.bootstrap.Component
4230 * @parent Roo.bootstrap.menu.Menu
4231 * Bootstrap Separator class
4234 * Create a new Separator
4235 * @param {Object} config The config object
4239 Roo.bootstrap.menu.Separator = function(config){
4240 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
4243 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
4245 getAutoCreate : function(){
4248 cls: 'dropdown-divider divider'
4264 * @class Roo.bootstrap.Modal
4265 * @extends Roo.bootstrap.Component
4266 * @parent none builder
4267 * @children Roo.bootstrap.Component
4268 * Bootstrap Modal class
4269 * @cfg {String} title Title of dialog
4270 * @cfg {String} html - the body of the dialog (for simple ones) - you can also use template..
4271 * @cfg {Roo.Template} tmpl - a template with variables. to use it, add a handler in show:method adn
4272 * @cfg {Boolean} specificTitle default false
4273 * @cfg {Roo.bootstrap.Button} buttons[] Array of buttons or standard button set..
4274 * @cfg {String} buttonPosition (left|right|center) default right (DEPRICATED) - use mr-auto on buttons to put them on the left
4275 * @cfg {Boolean} animate default true
4276 * @cfg {Boolean} allow_close default true
4277 * @cfg {Boolean} fitwindow default false
4278 * @cfg {Boolean} bodyOverflow should the body element have overflow auto added default false
4279 * @cfg {Number} width fixed width - usefull for chrome extension only really.
4280 * @cfg {Number} height fixed height - usefull for chrome extension only really.
4281 * @cfg {String} size (sm|lg|xl) default empty
4282 * @cfg {Number} max_width set the max width of modal
4283 * @cfg {Boolean} editableTitle can the title be edited
4288 * Create a new Modal Dialog
4289 * @param {Object} config The config object
4292 Roo.bootstrap.Modal = function(config){
4293 Roo.bootstrap.Modal.superclass.constructor.call(this, config);
4298 * The raw btnclick event for the button
4299 * @param {Roo.EventObject} e
4304 * Fire when dialog resize
4305 * @param {Roo.bootstrap.Modal} this
4306 * @param {Roo.EventObject} e
4310 * @event titlechanged
4311 * Fire when the editable title has been changed
4312 * @param {Roo.bootstrap.Modal} this
4313 * @param {Roo.EventObject} value
4315 "titlechanged" : true
4318 this.buttons = this.buttons || [];
4321 this.tmpl = Roo.factory(this.tmpl);
4326 Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, {
4328 title : 'test dialog',
4338 specificTitle: false,
4340 buttonPosition: 'right',
4362 editableTitle : false,
4364 onRender : function(ct, position)
4366 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
4369 var cfg = Roo.apply({}, this.getAutoCreate());
4372 // cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
4374 //if (!cfg.name.length) {
4378 cfg.cls += ' ' + this.cls;
4381 cfg.style = this.style;
4383 this.el = Roo.get(document.body).createChild(cfg, position);
4385 //var type = this.el.dom.type;
4388 if(this.tabIndex !== undefined){
4389 this.el.dom.setAttribute('tabIndex', this.tabIndex);
4392 this.dialogEl = this.el.select('.modal-dialog',true).first();
4393 this.bodyEl = this.el.select('.modal-body',true).first();
4394 this.closeEl = this.el.select('.modal-header .close', true).first();
4395 this.headerEl = this.el.select('.modal-header',true).first();
4396 this.titleEl = this.el.select('.modal-title',true).first();
4397 this.footerEl = this.el.select('.modal-footer',true).first();
4399 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
4401 //this.el.addClass("x-dlg-modal");
4403 if (this.buttons.length) {
4404 Roo.each(this.buttons, function(bb) {
4405 var b = Roo.apply({}, bb);
4406 b.xns = b.xns || Roo.bootstrap;
4407 b.xtype = b.xtype || 'Button';
4408 if (typeof(b.listeners) == 'undefined') {
4409 b.listeners = { click : this.onButtonClick.createDelegate(this) };
4412 var btn = Roo.factory(b);
4414 btn.render(this.getButtonContainer());
4418 // render the children.
4421 if(typeof(this.items) != 'undefined'){
4422 var items = this.items;
4425 for(var i =0;i < items.length;i++) {
4426 // we force children not to montor widnow resize - as we do that for them.
4427 items[i].monitorWindowResize = false;
4428 nitems.push(this.addxtype(Roo.apply({}, items[i])));
4432 this.items = nitems;
4434 // where are these used - they used to be body/close/footer
4438 //this.el.addClass([this.fieldClass, this.cls]);
4442 getAutoCreate : function()
4444 // we will default to modal-body-overflow - might need to remove or make optional later.
4446 cls : 'modal-body ' + (this.bodyOverflow ? 'overflow-auto' : ''),
4447 html : this.html || ''
4452 cls : 'modal-title',
4456 if(this.specificTitle){ // WTF is this?
4461 if (this.allow_close && Roo.bootstrap.version == 3) {
4471 if (this.editableTitle) {
4473 cls: 'form-control roo-editable-title d-none',
4479 if (this.allow_close && Roo.bootstrap.version == 4) {
4489 if(this.size.length){
4490 size = 'modal-' + this.size;
4493 var footer = Roo.bootstrap.version == 3 ?
4495 cls : 'modal-footer',
4499 cls: 'btn-' + this.buttonPosition
4504 { // BS4 uses mr-auto on left buttons....
4505 cls : 'modal-footer'
4516 cls: "modal-dialog " + size,
4519 cls : "modal-content",
4522 cls : 'modal-header',
4537 modal.cls += ' fade';
4543 getChildContainer : function() {
4548 getButtonContainer : function() {
4550 return Roo.bootstrap.version == 4 ?
4551 this.el.select('.modal-footer',true).first()
4552 : this.el.select('.modal-footer div',true).first();
4555 initEvents : function()
4557 if (this.allow_close) {
4558 this.closeEl.on('click', this.hide, this);
4560 Roo.EventManager.onWindowResize(this.resize, this, true);
4561 if (this.editableTitle) {
4562 this.headerEditEl = this.headerEl.select('.form-control',true).first();
4563 this.headerEl.on('click', function() { this.toggleHeaderInput(true) } , this);
4564 this.headerEditEl.on('keyup', function(e) {
4565 if([ e.RETURN , e.TAB , e.ESC ].indexOf(e.keyCode) > -1) {
4566 this.toggleHeaderInput(false)
4569 this.headerEditEl.on('blur', function(e) {
4570 this.toggleHeaderInput(false)
4579 this.maskEl.setSize(
4580 Roo.lib.Dom.getViewWidth(true),
4581 Roo.lib.Dom.getViewHeight(true)
4584 if (this.fitwindow) {
4586 this.dialogEl.setStyle( { 'max-width' : '100%' });
4588 this.width || Roo.lib.Dom.getViewportWidth(true) - 30,
4589 this.height || Roo.lib.Dom.getViewportHeight(true) // catering margin-top 30 margin-bottom 30
4594 if(this.max_width !== 0) {
4596 var w = Math.min(this.max_width, Roo.lib.Dom.getViewportWidth(true) - 30);
4599 this.setSize(w, this.height);
4603 if(this.max_height) {
4604 this.setSize(w,Math.min(
4606 Roo.lib.Dom.getViewportHeight(true) - 60
4612 if(!this.fit_content) {
4613 this.setSize(w, Roo.lib.Dom.getViewportHeight(true) - 60);
4617 this.setSize(w, Math.min(
4619 this.headerEl.getHeight() +
4620 this.footerEl.getHeight() +
4621 this.getChildHeight(this.bodyEl.dom.childNodes),
4622 Roo.lib.Dom.getViewportHeight(true) - 60)
4628 setSize : function(w,h)
4635 // any layout/border etc.. resize..
4637 this.items.forEach( function(e) {
4638 e.layout ? e.layout() : false;
4647 if (!this.rendered) {
4650 this.toggleHeaderInput(false);
4651 //this.el.setStyle('display', 'block');
4652 this.el.removeClass('hideing');
4653 this.el.dom.style.display='block';
4655 Roo.get(document.body).addClass('modal-open');
4657 if(this.animate){ // element has 'fade' - so stuff happens after .3s ?- not sure why the delay?
4660 this.el.addClass('show');
4661 this.el.addClass('in');
4664 this.el.addClass('show');
4665 this.el.addClass('in');
4668 // not sure how we can show data in here..
4670 // this.getChildContainer().dom.innerHTML = this.tmpl.applyTemplate(this);
4673 Roo.get(document.body).addClass("x-body-masked");
4675 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
4676 this.maskEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
4677 this.maskEl.dom.style.display = 'block';
4678 this.maskEl.addClass('show');
4683 this.fireEvent('show', this);
4685 // set zindex here - otherwise it appears to be ignored...
4686 this.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
4689 // this is for children that are... layout.Border
4691 this.items.forEach( function(e) {
4692 e.layout ? e.layout() : false;
4700 if(this.fireEvent("beforehide", this) !== false){
4702 this.maskEl.removeClass('show');
4704 this.maskEl.dom.style.display = '';
4705 Roo.get(document.body).removeClass("x-body-masked");
4706 this.el.removeClass('in');
4707 this.el.select('.modal-dialog', true).first().setStyle('transform','');
4709 if(this.animate){ // why
4710 this.el.addClass('hideing');
4711 this.el.removeClass('show');
4713 if (!this.el.hasClass('hideing')) {
4714 return; // it's been shown again...
4717 this.el.dom.style.display='';
4719 Roo.get(document.body).removeClass('modal-open');
4720 this.el.removeClass('hideing');
4724 this.el.removeClass('show');
4725 this.el.dom.style.display='';
4726 Roo.get(document.body).removeClass('modal-open');
4729 this.fireEvent('hide', this);
4732 isVisible : function()
4735 return this.el.hasClass('show') && !this.el.hasClass('hideing');
4739 addButton : function(str, cb)
4743 var b = Roo.apply({}, { html : str } );
4744 b.xns = b.xns || Roo.bootstrap;
4745 b.xtype = b.xtype || 'Button';
4746 if (typeof(b.listeners) == 'undefined') {
4747 b.listeners = { click : cb.createDelegate(this) };
4750 var btn = Roo.factory(b);
4752 btn.render(this.getButtonContainer());
4758 setDefaultButton : function(btn)
4760 //this.el.select('.modal-footer').()
4763 resizeTo: function(w,h)
4765 this.dialogEl.setWidth(w);
4767 var diff = this.headerEl.getHeight() + this.footerEl.getHeight() + 60; // dialog margin-bottom: 30
4769 this.bodyEl.setHeight(h - diff);
4771 this.fireEvent('resize', this);
4774 setContentSize : function(w, h)
4778 onButtonClick: function(btn,e)
4781 this.fireEvent('btnclick', btn.name, e);
4784 * Set the title of the Dialog
4785 * @param {String} str new Title
4787 setTitle: function(str) {
4788 this.titleEl.dom.innerHTML = str;
4792 * Set the body of the Dialog
4793 * @param {String} str new Title
4795 setBody: function(str) {
4796 this.bodyEl.dom.innerHTML = str;
4799 * Set the body of the Dialog using the template
4800 * @param {Obj} data - apply this data to the template and replace the body contents.
4802 applyBody: function(obj)
4805 Roo.log("Error - using apply Body without a template");
4808 this.tmpl.overwrite(this.bodyEl, obj);
4811 getChildHeight : function(child_nodes)
4815 child_nodes.length == 0
4820 var child_height = 0;
4822 for(var i = 0; i < child_nodes.length; i++) {
4825 * for modal with tabs...
4826 if(child_nodes[i].classList.contains('roo-layout-panel')) {
4828 var layout_childs = child_nodes[i].childNodes;
4830 for(var j = 0; j < layout_childs.length; j++) {
4832 if(layout_childs[j].classList.contains('roo-layout-panel-body')) {
4834 var layout_body_childs = layout_childs[j].childNodes;
4836 for(var k = 0; k < layout_body_childs.length; k++) {
4838 if(layout_body_childs[k].classList.contains('navbar')) {
4839 child_height += layout_body_childs[k].offsetHeight;
4843 if(layout_body_childs[k].classList.contains('roo-layout-tabs-body')) {
4845 var layout_body_tab_childs = layout_body_childs[k].childNodes;
4847 for(var m = 0; m < layout_body_tab_childs.length; m++) {
4849 if(layout_body_tab_childs[m].classList.contains('roo-layout-active-content')) {
4850 child_height += this.getChildHeight(layout_body_tab_childs[m].childNodes);
4865 child_height += child_nodes[i].offsetHeight;
4866 // Roo.log(child_nodes[i].offsetHeight);
4869 return child_height;
4871 toggleHeaderInput : function(is_edit)
4873 if (!this.editableTitle) {
4874 return; // not editable.
4876 if (is_edit && this.is_header_editing) {
4877 return; // already editing..
4881 this.headerEditEl.dom.value = this.title;
4882 this.headerEditEl.removeClass('d-none');
4883 this.headerEditEl.dom.focus();
4884 this.titleEl.addClass('d-none');
4886 this.is_header_editing = true;
4889 // flip back to not editing.
4890 this.title = this.headerEditEl.dom.value;
4891 this.headerEditEl.addClass('d-none');
4892 this.titleEl.removeClass('d-none');
4893 this.titleEl.dom.innerHTML = String.format('{0}', this.title);
4894 this.is_header_editing = false;
4895 this.fireEvent('titlechanged', this, this.title);
4904 Roo.apply(Roo.bootstrap.Modal, {
4906 * Button config that displays a single OK button
4915 * Button config that displays Yes and No buttons
4931 * Button config that displays OK and Cancel buttons
4946 * Button config that displays Yes, No and Cancel buttons
4971 * messagebox - can be used as a replace
4975 * @class Roo.MessageBox
4976 * Utility class for generating different styles of message boxes. The alias Roo.Msg can also be used.
4980 Roo.Msg.alert('Status', 'Changes saved successfully.');
4982 // Prompt for user data:
4983 Roo.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
4985 // process text value...
4989 // Show a dialog using config options:
4991 title:'Save Changes?',
4992 msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',
4993 buttons: Roo.Msg.YESNOCANCEL,
5000 Roo.bootstrap.MessageBox = function(){
5001 var dlg, opt, mask, waitTimer;
5002 var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp;
5003 var buttons, activeTextEl, bwidth;
5007 var handleButton = function(button){
5009 Roo.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
5013 var handleHide = function(){
5015 dlg.el.removeClass(opt.cls);
5018 // Roo.TaskMgr.stop(waitTimer);
5019 // waitTimer = null;
5024 var updateButtons = function(b){
5027 buttons["ok"].hide();
5028 buttons["cancel"].hide();
5029 buttons["yes"].hide();
5030 buttons["no"].hide();
5031 dlg.footerEl.hide();
5035 dlg.footerEl.show();
5036 for(var k in buttons){
5037 if(typeof buttons[k] != "function"){
5040 buttons[k].setText(typeof b[k] == "string" ? b[k] : Roo.bootstrap.MessageBox.buttonText[k]);
5041 width += buttons[k].el.getWidth()+15;
5051 var handleEsc = function(d, k, e){
5052 if(opt && opt.closable !== false){
5062 * Returns a reference to the underlying {@link Roo.BasicDialog} element
5063 * @return {Roo.BasicDialog} The BasicDialog element
5065 getDialog : function(){
5067 dlg = new Roo.bootstrap.Modal( {
5070 //constraintoviewport:false,
5072 //collapsible : false,
5077 //buttonAlign:"center",
5078 closeClick : function(){
5079 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
5082 handleButton("cancel");
5087 dlg.on("hide", handleHide);
5089 //dlg.addKeyListener(27, handleEsc);
5091 this.buttons = buttons;
5092 var bt = this.buttonText;
5093 buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
5094 buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
5095 buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
5096 buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
5098 bodyEl = dlg.bodyEl.createChild({
5100 html:'<span class="roo-mb-text"></span><br /><input type="text" class="roo-mb-input" />' +
5101 '<textarea class="roo-mb-textarea"></textarea>' +
5102 '<div class="roo-mb-progress-wrap"><div class="roo-mb-progress"><div class="roo-mb-progress-bar"> </div></div></div>'
5104 msgEl = bodyEl.dom.firstChild;
5105 textboxEl = Roo.get(bodyEl.dom.childNodes[2]);
5106 textboxEl.enableDisplayMode();
5107 textboxEl.addKeyListener([10,13], function(){
5108 if(dlg.isVisible() && opt && opt.buttons){
5111 }else if(opt.buttons.yes){
5112 handleButton("yes");
5116 textareaEl = Roo.get(bodyEl.dom.childNodes[3]);
5117 textareaEl.enableDisplayMode();
5118 progressEl = Roo.get(bodyEl.dom.childNodes[4]);
5119 progressEl.enableDisplayMode();
5121 // This is supposed to be the progessElement.. but I think it's controlling the height of everything..
5122 var pf = progressEl.dom.firstChild;
5124 pp = Roo.get(pf.firstChild);
5125 pp.setHeight(pf.offsetHeight);
5133 * Updates the message box body text
5134 * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
5135 * the XHTML-compliant non-breaking space character '&#160;')
5136 * @return {Roo.MessageBox} This message box
5138 updateText : function(text)
5140 if(!dlg.isVisible() && !opt.width){
5141 dlg.dialogEl.setStyle({ 'max-width' : this.maxWidth});
5142 // dlg.resizeTo(this.maxWidth, 100); // forcing the height breaks long alerts()
5144 msgEl.innerHTML = text || ' ';
5146 var cw = Math.max(msgEl.offsetWidth, msgEl.parentNode.scrollWidth);
5147 //Roo.log("guesed size: " + JSON.stringify([cw,msgEl.offsetWidth, msgEl.parentNode.scrollWidth]));
5149 Math.min(opt.width || cw , this.maxWidth),
5150 Math.max(opt.minWidth || this.minWidth, bwidth)
5153 activeTextEl.setWidth(w);
5155 if(dlg.isVisible()){
5156 dlg.fixedcenter = false;
5158 // to big, make it scroll. = But as usual stupid IE does not support
5161 if ( bodyEl.getHeight() > (Roo.lib.Dom.getViewHeight() - 100)) {
5162 bodyEl.setHeight ( Roo.lib.Dom.getViewHeight() - 100 );
5163 bodyEl.dom.style.overflowY = 'auto' + ( Roo.isIE ? '' : ' !important');
5165 bodyEl.dom.style.height = '';
5166 bodyEl.dom.style.overflowY = '';
5169 bodyEl.dom.style.get = 'auto' + ( Roo.isIE ? '' : ' !important');
5171 bodyEl.dom.style.overflowX = '';
5174 dlg.setContentSize(w, bodyEl.getHeight());
5175 if(dlg.isVisible()){
5176 dlg.fixedcenter = true;
5182 * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
5183 * initiated via {@link Roo.MessageBox#progress} or by calling {@link Roo.MessageBox#show} with progress: true.
5184 * @param {Number} value Any number between 0 and 1 (e.g., .5)
5185 * @param {String} text (optional) If defined, the message box's body text is replaced with the specified string (defaults to undefined)
5186 * @return {Roo.MessageBox} This message box
5188 updateProgress : function(value, text){
5190 this.updateText(text);
5193 if (pp) { // weird bug on my firefox - for some reason this is not defined
5194 pp.setWidth(Math.floor(value*progressEl.dom.firstChild.offsetWidth));
5195 pp.setHeight(Math.floor(progressEl.dom.firstChild.offsetHeight));
5201 * Returns true if the message box is currently displayed
5202 * @return {Boolean} True if the message box is visible, else false
5204 isVisible : function(){
5205 return dlg && dlg.isVisible();
5209 * Hides the message box if it is displayed
5212 if(this.isVisible()){
5218 * Displays a new message box, or reinitializes an existing message box, based on the config options
5219 * passed in. All functions (e.g. prompt, alert, etc) on MessageBox call this function internally.
5220 * The following config object properties are supported:
5222 Property Type Description
5223 ---------- --------------- ------------------------------------------------------------------------------------
5224 animEl String/Element An id or Element from which the message box should animate as it opens and
5225 closes (defaults to undefined)
5226 buttons Object/Boolean A button config object (e.g., Roo.MessageBox.OKCANCEL or {ok:'Foo',
5227 cancel:'Bar'}), or false to not show any buttons (defaults to false)
5228 closable Boolean False to hide the top-right close button (defaults to true). Note that
5229 progress and wait dialogs will ignore this property and always hide the
5230 close button as they can only be closed programmatically.
5231 cls String A custom CSS class to apply to the message box element
5232 defaultTextHeight Number The default height in pixels of the message box's multiline textarea if
5233 displayed (defaults to 75)
5234 fn Function A callback function to execute after closing the dialog. The arguments to the
5235 function will be btn (the name of the button that was clicked, if applicable,
5236 e.g. "ok"), and text (the value of the active text field, if applicable).
5237 Progress and wait dialogs will ignore this option since they do not respond to
5238 user actions and can only be closed programmatically, so any required function
5239 should be called by the same code after it closes the dialog.
5240 icon String A CSS class that provides a background image to be used as an icon for
5241 the dialog (e.g., Roo.MessageBox.WARNING or 'custom-class', defaults to '')
5242 maxWidth Number The maximum width in pixels of the message box (defaults to 600)
5243 minWidth Number The minimum width in pixels of the message box (defaults to 100)
5244 modal Boolean False to allow user interaction with the page while the message box is
5245 displayed (defaults to true)
5246 msg String A string that will replace the existing message box body text (defaults
5247 to the XHTML-compliant non-breaking space character ' ')
5248 multiline Boolean True to prompt the user to enter multi-line text (defaults to false)
5249 progress Boolean True to display a progress bar (defaults to false)
5250 progressText String The text to display inside the progress bar if progress = true (defaults to '')
5251 prompt Boolean True to prompt the user to enter single-line text (defaults to false)
5252 proxyDrag Boolean True to display a lightweight proxy while dragging (defaults to false)
5253 title String The title text
5254 value String The string value to set into the active textbox element if displayed
5255 wait Boolean True to display a progress bar (defaults to false)
5256 width Number The width of the dialog in pixels
5263 msg: 'Please enter your address:',
5265 buttons: Roo.MessageBox.OKCANCEL,
5268 animEl: 'addAddressBtn'
5271 * @param {Object} config Configuration options
5272 * @return {Roo.MessageBox} This message box
5274 show : function(options)
5277 // this causes nightmares if you show one dialog after another
5278 // especially on callbacks..
5280 if(this.isVisible()){
5283 Roo.log("[Roo.Messagebox] Show called while message displayed:" );
5284 Roo.log("Old Dialog Message:" + msgEl.innerHTML );
5285 Roo.log("New Dialog Message:" + options.msg )
5286 //this.alert("ERROR", "Multiple dialogs where displayed at the same time");
5287 //throw "Roo.MessageBox ERROR : Multiple dialogs where displayed at the same time";
5290 var d = this.getDialog();
5292 d.setTitle(opt.title || " ");
5293 d.closeEl.setDisplayed(opt.closable !== false);
5294 activeTextEl = textboxEl;
5295 opt.prompt = opt.prompt || (opt.multiline ? true : false);
5300 textareaEl.setHeight(typeof opt.multiline == "number" ?
5301 opt.multiline : this.defaultTextHeight);
5302 activeTextEl = textareaEl;
5311 progressEl.setDisplayed(opt.progress === true);
5313 d.animate = false; // do not animate progress, as it may not have finished animating before we close it..
5315 this.updateProgress(0);
5316 activeTextEl.dom.value = opt.value || "";
5318 dlg.setDefaultButton(activeTextEl);
5320 var bs = opt.buttons;
5324 }else if(bs && bs.yes){
5325 db = buttons["yes"];
5327 dlg.setDefaultButton(db);
5329 bwidth = updateButtons(opt.buttons);
5330 this.updateText(opt.msg);
5332 d.el.addClass(opt.cls);
5334 d.proxyDrag = opt.proxyDrag === true;
5335 d.modal = opt.modal !== false;
5336 d.mask = opt.modal !== false ? mask : false;
5338 // force it to the end of the z-index stack so it gets a cursor in FF
5339 document.body.appendChild(dlg.el.dom);
5340 d.animateTarget = null;
5341 d.show(options.animEl);
5347 * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
5348 * the user. You are responsible for updating the progress bar as needed via {@link Roo.MessageBox#updateProgress}
5349 * and closing the message box when the process is complete.
5350 * @param {String} title The title bar text
5351 * @param {String} msg The message box body text
5352 * @return {Roo.MessageBox} This message box
5354 progress : function(title, msg){
5361 minWidth: this.minProgressWidth,
5368 * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
5369 * If a callback function is passed it will be called after the user clicks the button, and the
5370 * id of the button that was clicked will be passed as the only parameter to the callback
5371 * (could also be the top-right close button).
5372 * @param {String} title The title bar text
5373 * @param {String} msg The message box body text
5374 * @param {Function} fn (optional) The callback function invoked after the message box is closed
5375 * @param {Object} scope (optional) The scope of the callback function
5376 * @return {Roo.MessageBox} This message box
5378 alert : function(title, msg, fn, scope)
5393 * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
5394 * interaction while waiting for a long-running process to complete that does not have defined intervals.
5395 * You are responsible for closing the message box when the process is complete.
5396 * @param {String} msg The message box body text
5397 * @param {String} title (optional) The title bar text
5398 * @return {Roo.MessageBox} This message box
5400 wait : function(msg, title){
5411 waitTimer = Roo.TaskMgr.start({
5413 Roo.MessageBox.updateProgress(((((i+20)%20)+1)*5)*.01);
5421 * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
5422 * If a callback function is passed it will be called after the user clicks either button, and the id of the
5423 * button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
5424 * @param {String} title The title bar text
5425 * @param {String} msg The message box body text
5426 * @param {Function} fn (optional) The callback function invoked after the message box is closed
5427 * @param {Object} scope (optional) The scope of the callback function
5428 * @return {Roo.MessageBox} This message box
5430 confirm : function(title, msg, fn, scope){
5434 buttons: this.YESNO,
5443 * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to
5444 * JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function
5445 * is passed it will be called after the user clicks either button, and the id of the button that was clicked
5446 * (could also be the top-right close button) and the text that was entered will be passed as the two
5447 * parameters to the callback.
5448 * @param {String} title The title bar text
5449 * @param {String} msg The message box body text
5450 * @param {Function} fn (optional) The callback function invoked after the message box is closed
5451 * @param {Object} scope (optional) The scope of the callback function
5452 * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
5453 * property, or the height in pixels to create the textbox (defaults to false / single-line)
5454 * @return {Roo.MessageBox} This message box
5456 prompt : function(title, msg, fn, scope, multiline){
5460 buttons: this.OKCANCEL,
5465 multiline: multiline,
5472 * Button config that displays a single OK button
5477 * Button config that displays Yes and No buttons
5480 YESNO : {yes:true, no:true},
5482 * Button config that displays OK and Cancel buttons
5485 OKCANCEL : {ok:true, cancel:true},
5487 * Button config that displays Yes, No and Cancel buttons
5490 YESNOCANCEL : {yes:true, no:true, cancel:true},
5493 * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
5496 defaultTextHeight : 75,
5498 * The maximum width in pixels of the message box (defaults to 600)
5503 * The minimum width in pixels of the message box (defaults to 100)
5508 * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
5509 * for setting a different minimum width than text-only dialogs may need (defaults to 250)
5512 minProgressWidth : 250,
5514 * An object containing the default button text strings that can be overriden for localized language support.
5515 * Supported properties are: ok, cancel, yes and no.
5516 * Customize the default text like so: Roo.MessageBox.buttonText.yes = "S?";
5529 * Shorthand for {@link Roo.MessageBox}
5531 Roo.MessageBox = Roo.MessageBox || Roo.bootstrap.MessageBox;
5532 Roo.Msg = Roo.Msg || Roo.MessageBox;
5541 * @class Roo.bootstrap.nav.Bar
5542 * @extends Roo.bootstrap.Component
5544 * Bootstrap Navbar class
5547 * Create a new Navbar
5548 * @param {Object} config The config object
5552 Roo.bootstrap.nav.Bar = function(config){
5553 Roo.bootstrap.nav.Bar.superclass.constructor.call(this, config);
5557 * @event beforetoggle
5558 * Fire before toggle the menu
5559 * @param {Roo.EventObject} e
5561 "beforetoggle" : true
5565 Roo.extend(Roo.bootstrap.nav.Bar, Roo.bootstrap.Component, {
5574 getAutoCreate : function(){
5577 throw { message : "nav bar is now a abstract base class - use NavSimplebar / NavHeaderbar / NavSidebar etc..."};
5581 initEvents :function ()
5583 //Roo.log(this.el.select('.navbar-toggle',true));
5584 this.el.select('.navbar-toggle',true).on('click', this.onToggle , this);
5591 this.maskEl = Roo.DomHelper.append(this.el, mark, true);
5593 var size = this.el.getSize();
5594 this.maskEl.setSize(size.width, size.height);
5595 this.maskEl.enableDisplayMode("block");
5604 getChildContainer : function()
5606 if (this.el && this.el.select('.collapse').getCount()) {
5607 return this.el.select('.collapse',true).first();
5622 onToggle : function()
5625 if(this.fireEvent('beforetoggle', this) === false){
5628 var ce = this.el.select('.navbar-collapse',true).first();
5630 if (!ce.hasClass('show')) {
5640 * Expand the navbar pulldown
5642 expand : function ()
5645 var ce = this.el.select('.navbar-collapse',true).first();
5646 if (ce.hasClass('collapsing')) {
5649 ce.dom.style.height = '';
5651 ce.addClass('in'); // old...
5652 ce.removeClass('collapse');
5653 ce.addClass('show');
5654 var h = ce.getHeight();
5656 ce.removeClass('show');
5657 // at this point we should be able to see it..
5658 ce.addClass('collapsing');
5660 ce.setHeight(0); // resize it ...
5661 ce.on('transitionend', function() {
5662 //Roo.log('done transition');
5663 ce.removeClass('collapsing');
5664 ce.addClass('show');
5665 ce.removeClass('collapse');
5667 ce.dom.style.height = '';
5668 }, this, { single: true} );
5670 ce.dom.scrollTop = 0;
5673 * Collapse the navbar pulldown
5675 collapse : function()
5677 var ce = this.el.select('.navbar-collapse',true).first();
5679 if (ce.hasClass('collapsing') || ce.hasClass('collapse') ) {
5680 // it's collapsed or collapsing..
5683 ce.removeClass('in'); // old...
5684 ce.setHeight(ce.getHeight());
5685 ce.removeClass('show');
5686 ce.addClass('collapsing');
5688 ce.on('transitionend', function() {
5689 ce.dom.style.height = '';
5690 ce.removeClass('collapsing');
5691 ce.addClass('collapse');
5692 }, this, { single: true} );
5712 * @class Roo.bootstrap.nav.Simplebar
5713 * @extends Roo.bootstrap.nav.Bar
5714 * @children Roo.bootstrap.nav.Group Roo.bootstrap.Container Roo.bootstrap.form.Form Roo.bootstrap.Row Roo.bootstrap.Column Roo.bootstrap.Link
5715 * Bootstrap Sidebar class
5717 * @cfg {Boolean} inverse is inverted color
5719 * @cfg {String} type (nav | pills | tabs)
5720 * @cfg {Boolean} arrangement stacked | justified
5721 * @cfg {String} align (left | right) alignment
5723 * @cfg {Boolean} main (true|false) main nav bar? default false
5724 * @cfg {Boolean} loadMask (true|false) loadMask on the bar
5726 * @cfg {String} tag (header|footer|nav|div) default is nav
5728 * @cfg {String} weight (light|primary|secondary|success|danger|warning|info|dark|white) default is light.
5732 * Create a new Sidebar
5733 * @param {Object} config The config object
5737 Roo.bootstrap.nav.Simplebar = function(config){
5738 Roo.bootstrap.nav.Simplebar.superclass.constructor.call(this, config);
5741 Roo.extend(Roo.bootstrap.nav.Simplebar, Roo.bootstrap.nav.Bar, {
5757 getAutoCreate : function(){
5761 tag : this.tag || 'div',
5762 cls : 'navbar roo-navbar-simple' //navbar-expand-lg ??
5764 if (['light','white'].indexOf(this.weight) > -1) {
5765 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
5767 cfg.cls += ' bg-' + this.weight;
5770 cfg.cls += ' navbar-inverse';
5774 // i'm not actually sure these are really used - normally we add a navGroup to a navbar
5776 if (Roo.bootstrap.version == 4 && this.xtype == 'NavSimplebar') {
5785 cls: 'nav nav-' + this.xtype,
5791 this.type = this.type || 'nav';
5792 if (['tabs','pills'].indexOf(this.type) != -1) {
5793 cfg.cn[0].cls += ' nav-' + this.type
5797 if (this.type!=='nav') {
5798 Roo.log('nav type must be nav/tabs/pills')
5800 cfg.cn[0].cls += ' navbar-nav'
5806 if (['stacked','justified'].indexOf(this.arrangement) != -1) {
5807 cfg.cn[0].cls += ' nav-' + this.arrangement;
5811 if (this.align === 'right') {
5812 cfg.cn[0].cls += ' navbar-right';
5837 * navbar-expand-md fixed-top
5841 * @class Roo.bootstrap.nav.Headerbar
5842 * @extends Roo.bootstrap.nav.Simplebar
5843 * @children Roo.bootstrap.nav.Group Roo.bootstrap.Container Roo.bootstrap.form.Form Roo.bootstrap.Row Roo.bootstrap.Column Roo.bootstrap.Link
5844 * Bootstrap Sidebar class
5846 * @cfg {String} brand what is brand
5847 * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
5848 * @cfg {String} brand_href href of the brand
5849 * @cfg {Boolean} srButton generate the (screen reader / mobile) sr-only button default true
5850 * @cfg {Boolean} autohide a top nav bar header that hides on scroll.
5851 * @cfg {Boolean} desktopCenter should the header be centered on desktop using a container class
5852 * @cfg {Roo.bootstrap.Row} mobilerow - a row to display on mobile only..
5855 * Create a new Sidebar
5856 * @param {Object} config The config object
5860 Roo.bootstrap.nav.Headerbar = function(config){
5861 Roo.bootstrap.nav.Headerbar.superclass.constructor.call(this, config);
5865 Roo.extend(Roo.bootstrap.nav.Headerbar, Roo.bootstrap.nav.Simplebar, {
5872 desktopCenter : false,
5875 getAutoCreate : function(){
5878 tag: this.nav || 'nav',
5879 cls: 'navbar navbar-expand-md',
5885 if (this.desktopCenter) {
5886 cn.push({cls : 'container', cn : []});
5894 cls: 'navbar-toggle navbar-toggler',
5895 'data-toggle': 'collapse',
5900 html: 'Toggle navigation'
5904 cls: 'icon-bar navbar-toggler-icon'
5917 cn.push( Roo.bootstrap.version == 4 ? btn : {
5919 cls: 'navbar-header',
5928 cls: Roo.bootstrap.version == 4 ? 'nav flex-row roo-navbar-collapse collapse navbar-collapse' : 'collapse navbar-collapse roo-navbar-collapse',
5932 cfg.cls += this.inverse ? ' navbar-inverse navbar-dark bg-dark' : ' navbar-default';
5934 if (['light','white'].indexOf(this.weight) > -1) {
5935 cfg.cls += ['light','white'].indexOf(this.weight) > -1 ? ' navbar-light' : ' navbar-dark';
5937 cfg.cls += ' bg-' + this.weight;
5940 if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
5941 cfg.cls += ' navbar-' + this.position + ' ' + this.position ;
5943 // tag can override this..
5945 cfg.tag = this.tag || (this.position == 'fixed-bottom' ? 'footer' : 'header');
5948 if (this.brand !== '') {
5949 var cp = Roo.bootstrap.version == 4 ? cn : cn[0].cn;
5950 cp.unshift({ // changed from push ?? BS4 needs it at the start? - does this break or exsiting?
5952 href: this.brand_href ? this.brand_href : '#',
5953 cls: 'navbar-brand',
5961 cfg.cls += ' main-nav';
5969 getHeaderChildContainer : function()
5971 if (this.srButton && this.el.select('.navbar-header').getCount()) {
5972 return this.el.select('.navbar-header',true).first();
5975 return this.getChildContainer();
5978 getChildContainer : function()
5981 return this.el.select('.roo-navbar-collapse',true).first();
5986 initEvents : function()
5988 Roo.bootstrap.nav.Headerbar.superclass.initEvents.call(this);
5990 if (this.autohide) {
5995 Roo.get(document).on('scroll',function(e) {
5996 var ns = Roo.get(document).getScroll().top;
5997 var os = prevScroll;
6001 ft.removeClass('slideDown');
6002 ft.addClass('slideUp');
6005 ft.removeClass('slideUp');
6006 ft.addClass('slideDown');
6027 * @class Roo.bootstrap.nav.Sidebar
6028 * @extends Roo.bootstrap.nav.Bar
6029 * @children Roo.bootstrap.nav.Group Roo.bootstrap.Container Roo.bootstrap.form.Form Roo.bootstrap.Row Roo.bootstrap.Column Roo.bootstrap.Link
6030 * Bootstrap Sidebar class
6033 * Create a new Sidebar
6034 * @param {Object} config The config object
6038 Roo.bootstrap.nav.Sidebar = function(config){
6039 Roo.bootstrap.nav.Sidebar.superclass.constructor.call(this, config);
6042 Roo.extend(Roo.bootstrap.nav.Sidebar, Roo.bootstrap.nav.Bar, {
6044 sidebar : true, // used by Navbar Item and NavbarGroup at present...
6046 getAutoCreate : function(){
6051 cls: 'sidebar sidebar-nav'
6073 * @class Roo.bootstrap.nav.Group
6074 * @extends Roo.bootstrap.Component
6075 * @children Roo.bootstrap.nav.Item
6076 * Bootstrap NavGroup class
6077 * @cfg {String} align (left|right)
6078 * @cfg {Boolean} inverse
6079 * @cfg {String} type (nav|pills|tab) default nav
6080 * @cfg {String} navId - reference Id for navbar.
6081 * @cfg {Boolean} pilltype default true (turn to off to disable active toggle)
6084 * Create a new nav group
6085 * @param {Object} config The config object
6088 Roo.bootstrap.nav.Group = function(config){
6089 Roo.bootstrap.nav.Group.superclass.constructor.call(this, config);
6092 Roo.bootstrap.nav.Group.register(this);
6096 * Fires when the active item changes
6097 * @param {Roo.bootstrap.nav.Group} this
6098 * @param {Roo.bootstrap.Navbar.Item} selected The item selected
6099 * @param {Roo.bootstrap.Navbar.Item} prev The previously selected item
6106 Roo.extend(Roo.bootstrap.nav.Group, Roo.bootstrap.Component, {
6118 getAutoCreate : function()
6120 var cfg = Roo.apply({}, Roo.bootstrap.nav.Group.superclass.getAutoCreate.call(this));
6126 if (Roo.bootstrap.version == 4) {
6127 if (['tabs','pills'].indexOf(this.type) != -1) {
6128 cfg.cls += ' nav-' + this.type;
6130 // trying to remove so header bar can right align top?
6131 if (this.parent() && this.parent().xtype != 'NavHeaderbar') {
6132 // do not use on header bar...
6133 cfg.cls += ' navbar-nav';
6138 if (['tabs','pills'].indexOf(this.type) != -1) {
6139 cfg.cls += ' nav-' + this.type
6141 if (this.type !== 'nav') {
6142 Roo.log('nav type must be nav/tabs/pills')
6144 cfg.cls += ' navbar-nav'
6148 if (this.parent() && this.parent().sidebar) {
6151 cls: 'dashboard-menu sidebar-menu'
6157 if (this.form === true) {
6160 cls: 'navbar-form form-inline'
6162 //nav navbar-right ml-md-auto
6163 if (this.align === 'right') {
6164 cfg.cls += ' navbar-right ml-md-auto';
6166 cfg.cls += ' navbar-left';
6170 if (this.align === 'right') {
6171 cfg.cls += ' navbar-right ml-md-auto';
6173 cfg.cls += ' mr-auto';
6177 cfg.cls += ' navbar-inverse';
6185 * sets the active Navigation item
6186 * @param {Roo.bootstrap.nav.Item} the new current navitem
6188 setActiveItem : function(item)
6191 Roo.each(this.navItems, function(v){
6196 v.setActive(false, true);
6203 item.setActive(true, true);
6204 this.fireEvent('changed', this, item, prev);
6209 * gets the active Navigation item
6210 * @return {Roo.bootstrap.nav.Item} the current navitem
6212 getActive : function()
6216 Roo.each(this.navItems, function(v){
6227 indexOfNav : function()
6231 Roo.each(this.navItems, function(v,i){
6242 * adds a Navigation item
6243 * @param {Roo.bootstrap.nav.Item} the navitem to add
6245 addItem : function(cfg)
6247 if (this.form && Roo.bootstrap.version == 4) {
6250 var cn = new Roo.bootstrap.nav.Item(cfg);
6252 cn.parentId = this.id;
6253 cn.onRender(this.el, null);
6257 * register a Navigation item
6258 * @param {Roo.bootstrap.nav.Item} the navitem to add
6260 register : function(item)
6262 this.navItems.push( item);
6263 item.navId = this.navId;
6268 * clear all the Navigation item
6271 clearAll : function()
6274 this.el.dom.innerHTML = '';
6277 getNavItem: function(tabId)
6280 Roo.each(this.navItems, function(e) {
6281 if (e.tabId == tabId) {
6291 setActiveNext : function()
6293 var i = this.indexOfNav(this.getActive());
6294 if (i > this.navItems.length) {
6297 this.setActiveItem(this.navItems[i+1]);
6299 setActivePrev : function()
6301 var i = this.indexOfNav(this.getActive());
6305 this.setActiveItem(this.navItems[i-1]);
6307 clearWasActive : function(except) {
6308 Roo.each(this.navItems, function(e) {
6309 if (e.tabId != except.tabId && e.was_active) {
6310 e.was_active = false;
6317 getWasActive : function ()
6320 Roo.each(this.navItems, function(e) {
6335 Roo.apply(Roo.bootstrap.nav.Group, {
6339 * register a Navigation Group
6340 * @param {Roo.bootstrap.nav.Group} the navgroup to add
6342 register : function(navgrp)
6344 this.groups[navgrp.navId] = navgrp;
6348 * fetch a Navigation Group based on the navigation ID
6349 * @param {string} the navgroup to add
6350 * @returns {Roo.bootstrap.nav.Group} the navgroup
6352 get: function(navId) {
6353 if (typeof(this.groups[navId]) == 'undefined') {
6355 //this.register(new Roo.bootstrap.nav.Group({ navId : navId }));
6357 return this.groups[navId] ;
6365 * @class Roo.bootstrap.nav.Item
6366 * @extends Roo.bootstrap.Component
6367 * @children Roo.bootstrap.Container Roo.bootstrap.Button
6368 * @parent Roo.bootstrap.nav.Group
6370 * Bootstrap Navbar.NavItem class
6372 * @cfg {String} href link to
6373 * @cfg {String} button_weight (default|primary|secondary|success|info|warning|danger|link|light|dark) default none
6374 * @cfg {Boolean} button_outline show and outlined button
6375 * @cfg {String} html content of button
6376 * @cfg {String} badge text inside badge
6377 * @cfg {String} badgecls (bg-green|bg-red|bg-yellow)the extra classes for the badge
6378 * @cfg {String} glyphicon DEPRICATED - use fa
6379 * @cfg {String} icon DEPRICATED - use fa
6380 * @cfg {String} fa - Fontawsome icon name (can add stuff to it like fa-2x)
6381 * @cfg {Boolean} active Is item active
6382 * @cfg {Boolean} disabled Is item disabled
6383 * @cfg {String} linkcls Link Class
6384 * @cfg {Boolean} preventDefault (true | false) default false
6385 * @cfg {String} tabId the tab that this item activates.
6386 * @cfg {String} tagtype (a|span) render as a href or span?
6387 * @cfg {Boolean} animateRef (true|false) link to element default false
6388 * @cfg {Roo.bootstrap.menu.Menu} menu a Menu
6391 * Create a new Navbar Item
6392 * @param {Object} config The config object
6394 Roo.bootstrap.nav.Item = function(config){
6395 Roo.bootstrap.nav.Item.superclass.constructor.call(this, config);
6400 * The raw click event for the entire grid.
6401 * @param {Roo.EventObject} e
6406 * Fires when the active item active state changes
6407 * @param {Roo.bootstrap.nav.Item} this
6408 * @param {boolean} state the new state
6414 * Fires when scroll to element
6415 * @param {Roo.bootstrap.nav.Item} this
6416 * @param {Object} options
6417 * @param {Roo.EventObject} e
6425 Roo.extend(Roo.bootstrap.nav.Item, Roo.bootstrap.Component, {
6434 preventDefault : false,
6442 button_outline : false,
6446 getAutoCreate : function(){
6453 cfg.cls = typeof(cfg.cls) == 'undefined' ? '' : cfg.cls;
6456 cfg.cls += ' active' ;
6458 if (this.disabled) {
6459 cfg.cls += ' disabled';
6463 if (this.button_weight.length) {
6464 cfg.tag = this.href ? 'a' : 'button';
6465 cfg.html = this.html || '';
6466 cfg.cls += ' btn btn' + (this.button_outline ? '-outline' : '') + '-' + this.button_weight;
6468 cfg.href = this.href;
6471 cfg.html = '<i class="fa fas fa-'+this.fa+'"></i> <span class="nav-html">' + this.html + '</span>';
6473 cfg.cls += " nav-html";
6476 // menu .. should add dropdown-menu class - so no need for carat..
6478 if (this.badge !== '') {
6480 cfg.html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
6485 if (this.href || this.html || this.glyphicon || this.icon || this.fa) {
6489 href : this.href || "#",
6490 html: this.html || '',
6494 if (this.tagtype == 'a') {
6495 cfg.cn[0].cls = 'nav-link' + (this.active ? ' active' : '') + ' ' + this.linkcls;
6499 cfg.cn[0].html = '<i class="'+this.icon+'"></i> <span class="nav-html">' + cfg.cn[0].html + '</span>';
6500 } else if (this.fa) {
6501 cfg.cn[0].html = '<i class="fa fas fa-'+this.fa+'"></i> <span class="nav-html">' + cfg.cn[0].html + '</span>';
6502 } else if(this.glyphicon) {
6503 cfg.cn[0].html = '<span class="glyphicon glyphicon-' + this.glyphicon + '"></span> ' + cfg.cn[0].html;
6505 cfg.cn[0].cls += " nav-html";
6509 cfg.cn[0].html += " <span class='caret'></span>";
6513 if (this.badge !== '') {
6514 cfg.cn[0].html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
6522 onRender : function(ct, position)
6524 // Roo.log("Call onRender: " + this.xtype);
6525 if (Roo.bootstrap.version == 4 && ct.dom.type != 'ul') {
6529 var ret = Roo.bootstrap.nav.Item.superclass.onRender.call(this, ct, position);
6530 this.navLink = this.el.select('.nav-link',true).first();
6531 this.htmlEl = this.el.hasClass('nav-html') ? this.el : this.el.select('.nav-html',true).first();
6536 initEvents: function()
6538 if (typeof (this.menu) != 'undefined') {
6539 this.menu.parentType = this.xtype;
6540 this.menu.triggerEl = this.el;
6541 this.menu = this.addxtype(Roo.apply({}, this.menu));
6544 this.el.on('click', this.onClick, this);
6546 //if(this.tagtype == 'span'){
6547 // this.el.select('span',true).on('click', this.onClick, this);
6550 // at this point parent should be available..
6551 this.parent().register(this);
6554 onClick : function(e)
6556 if (e.getTarget('.dropdown-menu-item')) {
6557 // did you click on a menu itemm.... - then don't trigger onclick..
6562 this.preventDefault ||
6563 this.href === false ||
6566 //Roo.log("NavItem - prevent Default?");
6570 if (this.disabled) {
6574 var tg = Roo.bootstrap.TabGroup.get(this.navId);
6575 if (tg && tg.transition) {
6576 Roo.log("waiting for the transitionend");
6582 //Roo.log("fire event clicked");
6583 if(this.fireEvent('click', this, e) === false){
6587 if(this.tagtype == 'span'){
6591 //Roo.log(this.href);
6592 var ael = this.el.select('a',true).first();
6595 if(ael && this.animateRef && this.href.indexOf('#') > -1){
6596 //Roo.log(["test:",ael.dom.href.split("#")[0], document.location.toString().split("#")[0]]);
6597 if (ael.dom.href.split("#")[0] != document.location.toString().split("#")[0]) {
6598 return; // ignore... - it's a 'hash' to another page.
6600 Roo.log("NavItem - prevent Default?");
6602 this.scrollToElement(e);
6606 var p = this.parent();
6608 if (['tabs','pills'].indexOf(p.type)!==-1 && p.pilltype) {
6609 if (typeof(p.setActiveItem) !== 'undefined') {
6610 p.setActiveItem(this);
6614 // if parent is a navbarheader....- and link is probably a '#' page ref.. then remove the expanded menu.
6615 if (p.parentType == 'NavHeaderbar' && !this.menu) {
6616 // remove the collapsed menu expand...
6617 p.parent().el.select('.roo-navbar-collapse',true).removeClass('in');
6621 isActive: function () {
6624 setActive : function(state, fire, is_was_active)
6626 if (this.active && !state && this.navId) {
6627 this.was_active = true;
6628 var nv = Roo.bootstrap.nav.Group.get(this.navId);
6630 nv.clearWasActive(this);
6634 this.active = state;
6637 this.el.removeClass('active');
6638 this.navLink ? this.navLink.removeClass('active') : false;
6639 } else if (!this.el.hasClass('active')) {
6641 this.el.addClass('active');
6642 if (Roo.bootstrap.version == 4 && this.navLink ) {
6643 this.navLink.addClass('active');
6648 this.fireEvent('changed', this, state);
6651 // show a panel if it's registered and related..
6653 if (!this.navId || !this.tabId || !state || is_was_active) {
6657 var tg = Roo.bootstrap.TabGroup.get(this.navId);
6661 var pan = tg.getPanelByName(this.tabId);
6665 // if we can not flip to new panel - go back to old nav highlight..
6666 if (false == tg.showPanel(pan)) {
6667 var nv = Roo.bootstrap.nav.Group.get(this.navId);
6669 var onav = nv.getWasActive();
6671 onav.setActive(true, false, true);
6680 // this should not be here...
6681 setDisabled : function(state)
6683 this.disabled = state;
6685 this.el.removeClass('disabled');
6686 } else if (!this.el.hasClass('disabled')) {
6687 this.el.addClass('disabled');
6693 * Fetch the element to display the tooltip on.
6694 * @return {Roo.Element} defaults to this.el
6696 tooltipEl : function()
6698 return this.el; //this.tagtype == 'a' ? this.el : this.el.select('' + this.tagtype + '', true).first();
6701 scrollToElement : function(e)
6703 var c = document.body;
6706 * Firefox / IE places the overflow at the html level, unless specifically styled to behave differently.
6708 if(Roo.isFirefox || Roo.isIE || Roo.isIE11){
6709 c = document.documentElement;
6712 var target = Roo.get(c).select('a[name=' + this.href.split('#')[1] +']', true).first();
6718 var o = target.calcOffsetsTo(c);
6725 this.fireEvent('scrollto', this, options, e);
6727 Roo.get(c).scrollTo('top', options.value, true);
6732 * Set the HTML (text content) of the item
6733 * @param {string} html content for the nav item
6735 setHtml : function(html)
6738 this.htmlEl.dom.innerHTML = html;
6750 * <span> icon </span>
6751 * <span> text </span>
6752 * <span>badge </span>
6756 * @class Roo.bootstrap.nav.SidebarItem
6757 * @extends Roo.bootstrap.nav.Item
6758 * Bootstrap Navbar.NavSidebarItem class
6760 * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
6761 * {Boolean} open is the menu open
6762 * {Boolean} buttonView use button as the tigger el rather that a (default false)
6763 * {String} buttonWeight (default|primary|success|info|warning|danger)the extra classes for the button
6764 * {String} buttonSize (sm|md|lg)the extra classes for the button
6765 * {Boolean} showArrow show arrow next to the text (default true)
6767 * Create a new Navbar Button
6768 * @param {Object} config The config object
6770 Roo.bootstrap.nav.SidebarItem = function(config){
6771 Roo.bootstrap.nav.SidebarItem.superclass.constructor.call(this, config);
6776 * The raw click event for the entire grid.
6777 * @param {Roo.EventObject} e
6782 * Fires when the active item active state changes
6783 * @param {Roo.bootstrap.nav.SidebarItem} this
6784 * @param {boolean} state the new state
6792 Roo.extend(Roo.bootstrap.nav.SidebarItem, Roo.bootstrap.nav.Item, {
6794 badgeWeight : 'default',
6800 buttonWeight : 'default',
6806 getAutoCreate : function(){
6811 href : this.href || '#',
6817 if(this.buttonView){
6820 href : this.href || '#',
6821 cls: 'btn btn-' + this.buttonWeight + ' btn-' + this.buttonSize + 'roo-button-dropdown-toggle',
6834 cfg.cls += ' active';
6837 if (this.disabled) {
6838 cfg.cls += ' disabled';
6841 cfg.cls += ' open x-open';
6844 if (this.glyphicon || this.icon) {
6845 var c = this.glyphicon ? ('glyphicon glyphicon-'+this.glyphicon) : this.icon;
6846 a.cn.push({ tag : 'i', cls : c }) ;
6849 if(!this.buttonView){
6852 html : this.html || ''
6859 if (this.badge !== '') {
6860 a.cn.push({ tag: 'span', cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge });
6866 a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
6869 a.cls += ' dropdown-toggle treeview' ;
6875 initEvents : function()
6877 if (typeof (this.menu) != 'undefined') {
6878 this.menu.parentType = this.xtype;
6879 this.menu.triggerEl = this.el;
6880 this.menu = this.addxtype(Roo.apply({}, this.menu));
6883 this.el.on('click', this.onClick, this);
6885 if(this.badge !== ''){
6886 this.badgeEl = this.el.select('.badge', true).first().setVisibilityMode(Roo.Element.DISPLAY);
6891 onClick : function(e)
6898 if(this.preventDefault){
6902 this.fireEvent('click', this, e);
6905 disable : function()
6907 this.setDisabled(true);
6912 this.setDisabled(false);
6915 setDisabled : function(state)
6917 if(this.disabled == state){
6921 this.disabled = state;
6924 this.el.addClass('disabled');
6928 this.el.removeClass('disabled');
6933 setActive : function(state)
6935 if(this.active == state){
6939 this.active = state;
6942 this.el.addClass('active');
6946 this.el.removeClass('active');
6951 isActive: function ()
6956 setBadge : function(str)
6962 this.badgeEl.dom.innerHTML = str;
6979 * @class Roo.bootstrap.nav.ProgressBar
6980 * @extends Roo.bootstrap.Component
6981 * @children Roo.bootstrap.nav.ProgressBarItem
6982 * Bootstrap NavProgressBar class
6985 * Create a new nav progress bar - a bar indicating step along a process
6986 * @param {Object} config The config object
6989 Roo.bootstrap.nav.ProgressBar = function(config){
6990 Roo.bootstrap.nav.ProgressBar.superclass.constructor.call(this, config);
6992 this.bullets = this.bullets || [];
6994 // Roo.bootstrap.nav.ProgressBar.register(this);
6998 * Fires when the active item changes
6999 * @param {Roo.bootstrap.nav.ProgressBar} this
7000 * @param {Roo.bootstrap.nav.ProgressItem} selected The item selected
7001 * @param {Roo.bootstrap.nav.ProgressItem} prev The previously selected item
7008 Roo.extend(Roo.bootstrap.nav.ProgressBar, Roo.bootstrap.Component, {
7010 * @cfg {Roo.bootstrap.nav.ProgressItem} NavProgressBar:bullets[]
7011 * Bullets for the Nav Progress bar for the toolbar
7016 getAutoCreate : function()
7018 var cfg = Roo.apply({}, Roo.bootstrap.nav.ProgressBar.superclass.getAutoCreate.call(this));
7022 cls : 'roo-navigation-bar-group',
7026 cls : 'roo-navigation-top-bar'
7030 cls : 'roo-navigation-bullets-bar',
7034 cls : 'roo-navigation-bar'
7041 cls : 'roo-navigation-bottom-bar'
7051 initEvents: function()
7056 onRender : function(ct, position)
7058 Roo.bootstrap.nav.ProgressBar.superclass.onRender.call(this, ct, position);
7060 if(this.bullets.length){
7061 Roo.each(this.bullets, function(b){
7070 addItem : function(cfg)
7072 var item = new Roo.bootstrap.nav.ProgressItem(cfg);
7074 item.parentId = this.id;
7075 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
7078 var top = new Roo.bootstrap.Element({
7080 cls : 'roo-navigation-bar-text'
7083 var bottom = new Roo.bootstrap.Element({
7085 cls : 'roo-navigation-bar-text'
7088 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
7089 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
7091 var topText = new Roo.bootstrap.Element({
7093 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
7096 var bottomText = new Roo.bootstrap.Element({
7098 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
7101 topText.onRender(top.el, null);
7102 bottomText.onRender(bottom.el, null);
7105 item.bottomEl = bottom;
7108 this.barItems.push(item);
7113 getActive : function()
7117 Roo.each(this.barItems, function(v){
7119 if (!v.isActive()) {
7131 setActiveItem : function(item)
7135 Roo.each(this.barItems, function(v){
7136 if (v.rid == item.rid) {
7146 item.setActive(true);
7148 this.fireEvent('changed', this, item, prev);
7151 getBarItem: function(rid)
7155 Roo.each(this.barItems, function(e) {
7167 indexOfItem : function(item)
7171 Roo.each(this.barItems, function(v, i){
7173 if (v.rid != item.rid) {
7184 setActiveNext : function()
7186 var i = this.indexOfItem(this.getActive());
7188 if (i > this.barItems.length) {
7192 this.setActiveItem(this.barItems[i+1]);
7195 setActivePrev : function()
7197 var i = this.indexOfItem(this.getActive());
7203 this.setActiveItem(this.barItems[i-1]);
7208 if(!this.barItems.length){
7212 var width = 100 / this.barItems.length;
7214 Roo.each(this.barItems, function(i){
7215 i.el.setStyle('width', width + '%');
7216 i.topEl.el.setStyle('width', width + '%');
7217 i.bottomEl.el.setStyle('width', width + '%');
7231 * @class Roo.bootstrap.nav.ProgressBarItem
7232 * @extends Roo.bootstrap.Component
7233 * Bootstrap NavProgressBarItem class
7234 * @cfg {String} rid the reference id
7235 * @cfg {Boolean} active (true|false) Is item active default false
7236 * @cfg {Boolean} disabled (true|false) Is item active default false
7237 * @cfg {String} html
7238 * @cfg {String} position (top|bottom) text position default bottom
7239 * @cfg {String} icon show icon instead of number
7242 * Create a new NavProgressBarItem
7243 * @param {Object} config The config object
7245 Roo.bootstrap.nav.ProgressBarItem = function(config){
7246 Roo.bootstrap.nav.ProgressBarItem.superclass.constructor.call(this, config);
7251 * The raw click event for the entire grid.
7252 * @param {Roo.bootstrap.nav.ProgressBarItem} this
7253 * @param {Roo.EventObject} e
7260 Roo.extend(Roo.bootstrap.nav.ProgressBarItem, Roo.bootstrap.Component, {
7266 position : 'bottom',
7269 getAutoCreate : function()
7271 var iconCls = 'roo-navigation-bar-item-icon';
7273 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
7277 cls: 'roo-navigation-bar-item',
7287 cfg.cls += ' active';
7290 cfg.cls += ' disabled';
7296 disable : function()
7298 this.setDisabled(true);
7303 this.setDisabled(false);
7306 initEvents: function()
7308 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
7310 this.iconEl.on('click', this.onClick, this);
7313 onClick : function(e)
7321 if(this.fireEvent('click', this, e) === false){
7325 this.parent().setActiveItem(this);
7328 isActive: function ()
7333 setActive : function(state)
7335 if(this.active == state){
7339 this.active = state;
7342 this.el.addClass('active');
7346 this.el.removeClass('active');
7351 setDisabled : function(state)
7353 if(this.disabled == state){
7357 this.disabled = state;
7360 this.el.addClass('disabled');
7364 this.el.removeClass('disabled');
7367 tooltipEl : function()
7369 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
7380 Roo.namespace('Roo.bootstrap.breadcrumb');
7384 * @class Roo.bootstrap.breadcrumb.Nav
7385 * @extends Roo.bootstrap.Component
7386 * Bootstrap Breadcrumb Nav Class
7388 * @children Roo.bootstrap.breadcrumb.Item
7391 * Create a new breadcrumb.Nav
7392 * @param {Object} config The config object
7396 Roo.bootstrap.breadcrumb.Nav = function(config){
7397 Roo.bootstrap.breadcrumb.Nav.superclass.constructor.call(this, config);
7402 Roo.extend(Roo.bootstrap.breadcrumb.Nav, Roo.bootstrap.Component, {
7404 getAutoCreate : function()
7421 initEvents: function()
7423 this.olEl = this.el.select('ol',true).first();
7425 getChildContainer : function()
7441 * @class Roo.bootstrap.breadcrumb.Nav
7442 * @extends Roo.bootstrap.Component
7443 * @children Roo.bootstrap.Component
7444 * @parent Roo.bootstrap.breadcrumb.Nav
7445 * Bootstrap Breadcrumb Nav Class
7448 * @cfg {String} html the content of the link.
7449 * @cfg {String} href where it links to if '#' is used the link will be handled by onClick.
7450 * @cfg {Boolean} active is it active
7454 * Create a new breadcrumb.Nav
7455 * @param {Object} config The config object
7458 Roo.bootstrap.breadcrumb.Item = function(config){
7459 Roo.bootstrap.breadcrumb.Item.superclass.constructor.call(this, config);
7464 * The img click event for the img.
7465 * @param {Roo.EventObject} e
7472 Roo.extend(Roo.bootstrap.breadcrumb.Item, Roo.bootstrap.Component, {
7477 getAutoCreate : function()
7482 cls : 'breadcrumb-item' + (this.active ? ' active' : '')
7484 if (this.href !== false) {
7491 cfg.html = this.html;
7497 initEvents: function()
7500 this.el.select('a', true).first().on('click',this.onClick, this)
7504 onClick : function(e)
7507 this.fireEvent('click',this, e);
7520 * @class Roo.bootstrap.Row
7521 * @extends Roo.bootstrap.Component
7522 * @children Roo.bootstrap.Component
7523 * Bootstrap Row class (contains columns...)
7527 * @param {Object} config The config object
7530 Roo.bootstrap.Row = function(config){
7531 Roo.bootstrap.Row.superclass.constructor.call(this, config);
7534 Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component, {
7536 getAutoCreate : function(){
7555 * @class Roo.bootstrap.Pagination
7556 * @extends Roo.bootstrap.Component
7557 * @children Roo.bootstrap.Pagination
7558 * Bootstrap Pagination class
7560 * @cfg {String} size (xs|sm|md|lg|xl)
7561 * @cfg {Boolean} inverse
7564 * Create a new Pagination
7565 * @param {Object} config The config object
7568 Roo.bootstrap.Pagination = function(config){
7569 Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
7572 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component, {
7578 getAutoCreate : function(){
7584 cfg.cls += ' inverse';
7590 cfg.cls += " " + this.cls;
7608 * @class Roo.bootstrap.PaginationItem
7609 * @extends Roo.bootstrap.Component
7610 * Bootstrap PaginationItem class
7611 * @cfg {String} html text
7612 * @cfg {String} href the link
7613 * @cfg {Boolean} preventDefault (true | false) default true
7614 * @cfg {Boolean} active (true | false) default false
7615 * @cfg {Boolean} disabled default false
7619 * Create a new PaginationItem
7620 * @param {Object} config The config object
7624 Roo.bootstrap.PaginationItem = function(config){
7625 Roo.bootstrap.PaginationItem.superclass.constructor.call(this, config);
7630 * The raw click event for the entire grid.
7631 * @param {Roo.EventObject} e
7637 Roo.extend(Roo.bootstrap.PaginationItem, Roo.bootstrap.Component, {
7641 preventDefault: true,
7646 getAutoCreate : function(){
7652 href : this.href ? this.href : '#',
7653 html : this.html ? this.html : ''
7663 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' disabled' : 'disabled';
7667 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' active' : 'active';
7673 initEvents: function() {
7675 this.el.on('click', this.onClick, this);
7678 onClick : function(e)
7680 Roo.log('PaginationItem on click ');
7681 if(this.preventDefault){
7689 this.fireEvent('click', this, e);
7705 * @class Roo.bootstrap.Slider
7706 * @extends Roo.bootstrap.Component
7707 * Bootstrap Slider class
7710 * Create a new Slider
7711 * @param {Object} config The config object
7714 Roo.bootstrap.Slider = function(config){
7715 Roo.bootstrap.Slider.superclass.constructor.call(this, config);
7718 Roo.extend(Roo.bootstrap.Slider, Roo.bootstrap.Component, {
7720 getAutoCreate : function(){
7724 cls: 'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',
7728 cls: 'ui-slider-handle ui-state-default ui-corner-all'
7740 * Ext JS Library 1.1.1
7741 * Copyright(c) 2006-2007, Ext JS, LLC.
7743 * Originally Released Under LGPL - original licence link has changed is not relivant.
7746 * <script type="text/javascript">
7749 * @extends Roo.dd.DDProxy
7750 * @class Roo.grid.SplitDragZone
7751 * Support for Column Header resizing
7753 * @param {Object} config
7756 // This is a support class used internally by the Grid components
7757 Roo.grid.SplitDragZone = function(grid, hd, hd2){
7759 this.view = grid.getView();
7760 this.proxy = this.view.resizeProxy;
7761 Roo.grid.SplitDragZone.superclass.constructor.call(
7764 "gridSplitters" + this.grid.getGridEl().id, // SGROUP
7766 dragElId : Roo.id(this.proxy.dom),
7771 this.setHandleElId(Roo.id(hd));
7772 if (hd2 !== false) {
7773 this.setOuterHandleElId(Roo.id(hd2));
7776 this.scroll = false;
7778 Roo.extend(Roo.grid.SplitDragZone, Roo.dd.DDProxy, {
7779 fly: Roo.Element.fly,
7781 b4StartDrag : function(x, y){
7782 this.view.headersDisabled = true;
7783 var h = this.view.mainWrap ? this.view.mainWrap.getHeight() : (
7784 this.view.headEl.getHeight() + this.view.bodyEl.getHeight()
7786 this.proxy.setHeight(h);
7788 // for old system colWidth really stored the actual width?
7789 // in bootstrap we tried using xs/ms/etc.. to do % sizing?
7790 // which in reality did not work.. - it worked only for fixed sizes
7791 // for resizable we need to use actual sizes.
7792 var w = this.cm.getColumnWidth(this.cellIndex);
7793 if (!this.view.mainWrap) {
7795 w = this.view.getHeaderIndex(this.cellIndex).getWidth();
7800 // this was w-this.grid.minColumnWidth;
7801 // doesnt really make sense? - w = thie curren width or the rendered one?
7802 var minw = Math.max(w-this.grid.minColumnWidth, 0);
7803 this.resetConstraints();
7804 this.setXConstraint(minw, 1000);
7805 this.setYConstraint(0, 0);
7806 this.minX = x - minw;
7807 this.maxX = x + 1000;
7809 if (!this.view.mainWrap) { // this is Bootstrap code..
7810 this.getDragEl().style.display='block';
7813 Roo.dd.DDProxy.prototype.b4StartDrag.call(this, x, y);
7817 handleMouseDown : function(e){
7818 ev = Roo.EventObject.setEvent(e);
7819 var t = this.fly(ev.getTarget());
7820 if(t.hasClass("x-grid-split")){
7821 this.cellIndex = this.view.getCellIndex(t.dom);
7823 this.cm = this.grid.colModel;
7824 if(this.cm.isResizable(this.cellIndex) && !this.cm.isFixed(this.cellIndex)){
7825 Roo.grid.SplitDragZone.superclass.handleMouseDown.apply(this, arguments);
7830 endDrag : function(e){
7831 this.view.headersDisabled = false;
7832 var endX = Math.max(this.minX, Roo.lib.Event.getPageX(e));
7833 var diff = endX - this.startPos;
7835 var w = this.cm.getColumnWidth(this.cellIndex);
7836 if (!this.view.mainWrap) {
7839 this.view.onColumnSplitterMoved(this.cellIndex, w+diff);
7842 autoOffset : function(){
7847 * Ext JS Library 1.1.1
7848 * Copyright(c) 2006-2007, Ext JS, LLC.
7850 * Originally Released Under LGPL - original licence link has changed is not relivant.
7853 * <script type="text/javascript">
7857 * @class Roo.grid.AbstractSelectionModel
7858 * @extends Roo.util.Observable
7860 * Abstract base class for grid SelectionModels. It provides the interface that should be
7861 * implemented by descendant classes. This class should not be directly instantiated.
7864 Roo.grid.AbstractSelectionModel = function(){
7865 this.locked = false;
7866 Roo.grid.AbstractSelectionModel.superclass.constructor.call(this);
7869 Roo.extend(Roo.grid.AbstractSelectionModel, Roo.util.Observable, {
7870 /** @ignore Called by the grid automatically. Do not call directly. */
7871 init : function(grid){
7877 * Locks the selections.
7884 * Unlocks the selections.
7886 unlock : function(){
7887 this.locked = false;
7891 * Returns true if the selections are locked.
7894 isLocked : function(){
7899 * Ext JS Library 1.1.1
7900 * Copyright(c) 2006-2007, Ext JS, LLC.
7902 * Originally Released Under LGPL - original licence link has changed is not relivant.
7905 * <script type="text/javascript">
7908 * @extends Roo.grid.AbstractSelectionModel
7909 * @class Roo.grid.RowSelectionModel
7910 * The default SelectionModel used by {@link Roo.grid.Grid}.
7911 * It supports multiple selections and keyboard selection/navigation.
7913 * @param {Object} config
7915 Roo.grid.RowSelectionModel = function(config){
7916 Roo.apply(this, config);
7917 this.selections = new Roo.util.MixedCollection(false, function(o){
7922 this.lastActive = false;
7926 * @event selectionchange
7927 * Fires when the selection changes
7928 * @param {SelectionModel} this
7930 "selectionchange" : true,
7932 * @event afterselectionchange
7933 * Fires after the selection changes (eg. by key press or clicking)
7934 * @param {SelectionModel} this
7936 "afterselectionchange" : true,
7938 * @event beforerowselect
7939 * Fires when a row is selected being selected, return false to cancel.
7940 * @param {SelectionModel} this
7941 * @param {Number} rowIndex The selected index
7942 * @param {Boolean} keepExisting False if other selections will be cleared
7944 "beforerowselect" : true,
7947 * Fires when a row is selected.
7948 * @param {SelectionModel} this
7949 * @param {Number} rowIndex The selected index
7950 * @param {Roo.data.Record} r The record
7954 * @event rowdeselect
7955 * Fires when a row is deselected.
7956 * @param {SelectionModel} this
7957 * @param {Number} rowIndex The selected index
7959 "rowdeselect" : true
7961 Roo.grid.RowSelectionModel.superclass.constructor.call(this);
7962 this.locked = false;
7965 Roo.extend(Roo.grid.RowSelectionModel, Roo.grid.AbstractSelectionModel, {
7967 * @cfg {Boolean} singleSelect
7968 * True to allow selection of only one row at a time (defaults to false)
7970 singleSelect : false,
7973 initEvents : function(){
7975 if(!this.grid.enableDragDrop && !this.grid.enableDrag){
7976 this.grid.on("mousedown", this.handleMouseDown, this);
7977 }else{ // allow click to work like normal
7978 this.grid.on("rowclick", this.handleDragableRowClick, this);
7980 // bootstrap does not have a view..
7981 var view = this.grid.view ? this.grid.view : this.grid;
7982 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
7985 this.selectPrevious(e.shiftKey);
7986 }else if(this.last !== false && this.lastActive !== false){
7987 var last = this.last;
7988 this.selectRange(this.last, this.lastActive-1);
7989 view.focusRow(this.lastActive);
7994 this.selectFirstRow();
7996 this.fireEvent("afterselectionchange", this);
7998 "down" : function(e){
8000 this.selectNext(e.shiftKey);
8001 }else if(this.last !== false && this.lastActive !== false){
8002 var last = this.last;
8003 this.selectRange(this.last, this.lastActive+1);
8004 view.focusRow(this.lastActive);
8009 this.selectFirstRow();
8011 this.fireEvent("afterselectionchange", this);
8017 view.on("refresh", this.onRefresh, this);
8018 view.on("rowupdated", this.onRowUpdated, this);
8019 view.on("rowremoved", this.onRemove, this);
8023 onRefresh : function(){
8024 var ds = this.grid.ds, i, v = this.grid.view;
8025 var s = this.selections;
8027 if((i = ds.indexOfId(r.id)) != -1){
8029 s.add(ds.getAt(i)); // updating the selection relate data
8037 onRemove : function(v, index, r){
8038 this.selections.remove(r);
8042 onRowUpdated : function(v, index, r){
8043 if(this.isSelected(r)){
8044 v.onRowSelect(index);
8050 * @param {Array} records The records to select
8051 * @param {Boolean} keepExisting (optional) True to keep existing selections
8053 selectRecords : function(records, keepExisting){
8055 this.clearSelections();
8057 var ds = this.grid.ds;
8058 for(var i = 0, len = records.length; i < len; i++){
8059 this.selectRow(ds.indexOf(records[i]), true);
8064 * Gets the number of selected rows.
8067 getCount : function(){
8068 return this.selections.length;
8072 * Selects the first row in the grid.
8074 selectFirstRow : function(){
8079 * Select the last row.
8080 * @param {Boolean} keepExisting (optional) True to keep existing selections
8082 selectLastRow : function(keepExisting){
8083 this.selectRow(this.grid.ds.getCount() - 1, keepExisting);
8087 * Selects the row immediately following the last selected row.
8088 * @param {Boolean} keepExisting (optional) True to keep existing selections
8090 selectNext : function(keepExisting){
8091 if(this.last !== false && (this.last+1) < this.grid.ds.getCount()){
8092 this.selectRow(this.last+1, keepExisting);
8093 var view = this.grid.view ? this.grid.view : this.grid;
8094 view.focusRow(this.last);
8099 * Selects the row that precedes the last selected row.
8100 * @param {Boolean} keepExisting (optional) True to keep existing selections
8102 selectPrevious : function(keepExisting){
8104 this.selectRow(this.last-1, keepExisting);
8105 var view = this.grid.view ? this.grid.view : this.grid;
8106 view.focusRow(this.last);
8111 * Returns the selected records
8112 * @return {Array} Array of selected records
8114 getSelections : function(){
8115 return [].concat(this.selections.items);
8119 * Returns the first selected record.
8122 getSelected : function(){
8123 return this.selections.itemAt(0);
8128 * Clears all selections.
8130 clearSelections : function(fast){
8135 var ds = this.grid.ds;
8136 var s = this.selections;
8138 this.deselectRow(ds.indexOfId(r.id));
8142 this.selections.clear();
8151 selectAll : function(){
8155 this.selections.clear();
8156 for(var i = 0, len = this.grid.ds.getCount(); i < len; i++){
8157 this.selectRow(i, true);
8162 * Returns True if there is a selection.
8165 hasSelection : function(){
8166 return this.selections.length > 0;
8170 * Returns True if the specified row is selected.
8171 * @param {Number/Record} record The record or index of the record to check
8174 isSelected : function(index){
8175 var r = typeof index == "number" ? this.grid.ds.getAt(index) : index;
8176 return (r && this.selections.key(r.id) ? true : false);
8180 * Returns True if the specified record id is selected.
8181 * @param {String} id The id of record to check
8184 isIdSelected : function(id){
8185 return (this.selections.key(id) ? true : false);
8189 handleMouseDown : function(e, t)
8191 var view = this.grid.view ? this.grid.view : this.grid;
8193 if(this.isLocked() || (rowIndex = view.findRowIndex(t)) === false){
8196 if(e.shiftKey && this.last !== false){
8197 var last = this.last;
8198 this.selectRange(last, rowIndex, e.ctrlKey);
8199 this.last = last; // reset the last
8200 view.focusRow(rowIndex);
8202 var isSelected = this.isSelected(rowIndex);
8203 if(e.button !== 0 && isSelected){
8204 view.focusRow(rowIndex);
8205 }else if(e.ctrlKey && isSelected){
8206 this.deselectRow(rowIndex);
8207 }else if(!isSelected){
8208 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
8209 view.focusRow(rowIndex);
8212 this.fireEvent("afterselectionchange", this);
8215 handleDragableRowClick : function(grid, rowIndex, e)
8217 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
8218 this.selectRow(rowIndex, false);
8219 var view = this.grid.view ? this.grid.view : this.grid;
8220 view.focusRow(rowIndex);
8221 this.fireEvent("afterselectionchange", this);
8226 * Selects multiple rows.
8227 * @param {Array} rows Array of the indexes of the row to select
8228 * @param {Boolean} keepExisting (optional) True to keep existing selections
8230 selectRows : function(rows, keepExisting){
8232 this.clearSelections();
8234 for(var i = 0, len = rows.length; i < len; i++){
8235 this.selectRow(rows[i], true);
8240 * Selects a range of rows. All rows in between startRow and endRow are also selected.
8241 * @param {Number} startRow The index of the first row in the range
8242 * @param {Number} endRow The index of the last row in the range
8243 * @param {Boolean} keepExisting (optional) True to retain existing selections
8245 selectRange : function(startRow, endRow, keepExisting){
8250 this.clearSelections();
8252 if(startRow <= endRow){
8253 for(var i = startRow; i <= endRow; i++){
8254 this.selectRow(i, true);
8257 for(var i = startRow; i >= endRow; i--){
8258 this.selectRow(i, true);
8264 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
8265 * @param {Number} startRow The index of the first row in the range
8266 * @param {Number} endRow The index of the last row in the range
8268 deselectRange : function(startRow, endRow, preventViewNotify){
8272 for(var i = startRow; i <= endRow; i++){
8273 this.deselectRow(i, preventViewNotify);
8279 * @param {Number} row The index of the row to select
8280 * @param {Boolean} keepExisting (optional) True to keep existing selections
8282 selectRow : function(index, keepExisting, preventViewNotify){
8283 if(this.locked || (index < 0 || index >= this.grid.ds.getCount())) {
8286 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
8287 if(!keepExisting || this.singleSelect){
8288 this.clearSelections();
8290 var r = this.grid.ds.getAt(index);
8291 this.selections.add(r);
8292 this.last = this.lastActive = index;
8293 if(!preventViewNotify){
8294 var view = this.grid.view ? this.grid.view : this.grid;
8295 view.onRowSelect(index);
8297 this.fireEvent("rowselect", this, index, r);
8298 this.fireEvent("selectionchange", this);
8304 * @param {Number} row The index of the row to deselect
8306 deselectRow : function(index, preventViewNotify){
8310 if(this.last == index){
8313 if(this.lastActive == index){
8314 this.lastActive = false;
8316 var r = this.grid.ds.getAt(index);
8317 this.selections.remove(r);
8318 if(!preventViewNotify){
8319 var view = this.grid.view ? this.grid.view : this.grid;
8320 view.onRowDeselect(index);
8322 this.fireEvent("rowdeselect", this, index);
8323 this.fireEvent("selectionchange", this);
8327 restoreLast : function(){
8329 this.last = this._last;
8334 acceptsNav : function(row, col, cm){
8335 return !cm.isHidden(col) && cm.isCellEditable(col, row);
8339 onEditorKey : function(field, e){
8340 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
8345 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
8347 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
8349 }else if(k == e.ENTER && !e.ctrlKey){
8353 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
8355 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
8357 }else if(k == e.ESC){
8361 g.startEditing(newCell[0], newCell[1]);
8366 * Ext JS Library 1.1.1
8367 * Copyright(c) 2006-2007, Ext JS, LLC.
8369 * Originally Released Under LGPL - original licence link has changed is not relivant.
8372 * <script type="text/javascript">
8377 * @class Roo.grid.ColumnModel
8378 * @extends Roo.util.Observable
8379 * This is the default implementation of a ColumnModel used by the Grid. It defines
8380 * the columns in the grid.
8383 var colModel = new Roo.grid.ColumnModel([
8384 {header: "Ticker", width: 60, sortable: true, locked: true},
8385 {header: "Company Name", width: 150, sortable: true},
8386 {header: "Market Cap.", width: 100, sortable: true},
8387 {header: "$ Sales", width: 100, sortable: true, renderer: money},
8388 {header: "Employees", width: 100, sortable: true, resizable: false}
8393 * The config options listed for this class are options which may appear in each
8394 * individual column definition.
8395 * <br/>RooJS Fix - column id's are not sequential but use Roo.id() - fixes bugs with layouts.
8397 * @param {Object} config An Array of column config objects. See this class's
8398 * config objects for details.
8400 Roo.grid.ColumnModel = function(config){
8402 * The config passed into the constructor
8404 this.config = []; //config;
8407 // if no id, create one
8408 // if the column does not have a dataIndex mapping,
8409 // map it to the order it is in the config
8410 for(var i = 0, len = config.length; i < len; i++){
8411 this.addColumn(config[i]);
8416 * The width of columns which have no width specified (defaults to 100)
8419 this.defaultWidth = 100;
8422 * Default sortable of columns which have no sortable specified (defaults to false)
8425 this.defaultSortable = false;
8429 * @event widthchange
8430 * Fires when the width of a column changes.
8431 * @param {ColumnModel} this
8432 * @param {Number} columnIndex The column index
8433 * @param {Number} newWidth The new width
8435 "widthchange": true,
8437 * @event headerchange
8438 * Fires when the text of a header changes.
8439 * @param {ColumnModel} this
8440 * @param {Number} columnIndex The column index
8441 * @param {Number} newText The new header text
8443 "headerchange": true,
8445 * @event hiddenchange
8446 * Fires when a column is hidden or "unhidden".
8447 * @param {ColumnModel} this
8448 * @param {Number} columnIndex The column index
8449 * @param {Boolean} hidden true if hidden, false otherwise
8451 "hiddenchange": true,
8453 * @event columnmoved
8454 * Fires when a column is moved.
8455 * @param {ColumnModel} this
8456 * @param {Number} oldIndex
8457 * @param {Number} newIndex
8459 "columnmoved" : true,
8461 * @event columlockchange
8462 * Fires when a column's locked state is changed
8463 * @param {ColumnModel} this
8464 * @param {Number} colIndex
8465 * @param {Boolean} locked true if locked
8467 "columnlockchange" : true
8469 Roo.grid.ColumnModel.superclass.constructor.call(this);
8471 Roo.extend(Roo.grid.ColumnModel, Roo.util.Observable, {
8473 * @cfg {String} header [required] The header text to display in the Grid view.
8476 * @cfg {String} xsHeader Header at Bootsrap Extra Small width (default for all)
8479 * @cfg {String} smHeader Header at Bootsrap Small width
8482 * @cfg {String} mdHeader Header at Bootsrap Medium width
8485 * @cfg {String} lgHeader Header at Bootsrap Large width
8488 * @cfg {String} xlHeader Header at Bootsrap extra Large width
8491 * @cfg {String} dataIndex The name of the field in the grid's {@link Roo.data.Store}'s
8492 * {@link Roo.data.Record} definition from which to draw the column's value. If not
8493 * specified, the column's index is used as an index into the Record's data Array.
8496 * @cfg {Number} width The initial width in pixels of the column. Using this
8497 * instead of {@link Roo.grid.Grid#autoSizeColumns} is more efficient.
8500 * @cfg {Boolean} sortable True if sorting is to be allowed on this column.
8501 * Defaults to the value of the {@link #defaultSortable} property.
8502 * Whether local/remote sorting is used is specified in {@link Roo.data.Store#remoteSort}.
8505 * @cfg {Boolean} locked True to lock the column in place while scrolling the Grid. Defaults to false.
8508 * @cfg {Boolean} fixed True if the column width cannot be changed. Defaults to false.
8511 * @cfg {Boolean} resizable False to disable column resizing. Defaults to true.
8514 * @cfg {Boolean} hidden True to hide the column. Defaults to false.
8517 * @cfg {Function} renderer A function used to generate HTML markup for a cell
8518 * given the cell's data value. See {@link #setRenderer}. If not specified, the
8519 * default renderer returns the escaped data value. If an object is returned (bootstrap only)
8520 * then it is treated as a Roo Component object instance, and it is rendered after the initial row is rendered
8523 * @cfg {Roo.grid.GridEditor} editor For grid editors - returns the grid editor
8526 * @cfg {String} align (left|right) Set the CSS text-align property of the column. Defaults to undefined (left).
8529 * @cfg {String} valign (top|bottom|middle) Set the CSS vertical-align property of the column (eg. middle, top, bottom etc). Defaults to undefined (middle)
8532 * @cfg {String} cursor ( auto|default|none|context-menu|help|pointer|progress|wait|cell|crosshair|text|vertical-text|alias|copy|move|no-drop|not-allowed|e-resize|n-resize|ne-resize|nw-resize|s-resize|se-resize|sw-resize|w-resize|ew-resize|ns-resize|nesw-resize|nwse-resize|col-resize|row-resize|all-scroll|zoom-in|zoom-out|grab|grabbing)
8535 * @cfg {String} tooltip mouse over tooltip text
8538 * @cfg {Number} xs can be '0' for hidden at this size (number less than 12)
8541 * @cfg {Number} sm can be '0' for hidden at this size (number less than 12)
8544 * @cfg {Number} md can be '0' for hidden at this size (number less than 12)
8547 * @cfg {Number} lg can be '0' for hidden at this size (number less than 12)
8550 * @cfg {Number} xl can be '0' for hidden at this size (number less than 12)
8553 * Returns the id of the column at the specified index.
8554 * @param {Number} index The column index
8555 * @return {String} the id
8557 getColumnId : function(index){
8558 return this.config[index].id;
8562 * Returns the column for a specified id.
8563 * @param {String} id The column id
8564 * @return {Object} the column
8566 getColumnById : function(id){
8567 return this.lookup[id];
8572 * Returns the column Object for a specified dataIndex.
8573 * @param {String} dataIndex The column dataIndex
8574 * @return {Object|Boolean} the column or false if not found
8576 getColumnByDataIndex: function(dataIndex){
8577 var index = this.findColumnIndex(dataIndex);
8578 return index > -1 ? this.config[index] : false;
8582 * Returns the index for a specified column id.
8583 * @param {String} id The column id
8584 * @return {Number} the index, or -1 if not found
8586 getIndexById : function(id){
8587 for(var i = 0, len = this.config.length; i < len; i++){
8588 if(this.config[i].id == id){
8596 * Returns the index for a specified column dataIndex.
8597 * @param {String} dataIndex The column dataIndex
8598 * @return {Number} the index, or -1 if not found
8601 findColumnIndex : function(dataIndex){
8602 for(var i = 0, len = this.config.length; i < len; i++){
8603 if(this.config[i].dataIndex == dataIndex){
8611 moveColumn : function(oldIndex, newIndex){
8612 var c = this.config[oldIndex];
8613 this.config.splice(oldIndex, 1);
8614 this.config.splice(newIndex, 0, c);
8615 this.dataMap = null;
8616 this.fireEvent("columnmoved", this, oldIndex, newIndex);
8619 isLocked : function(colIndex){
8620 return this.config[colIndex].locked === true;
8623 setLocked : function(colIndex, value, suppressEvent){
8624 if(this.isLocked(colIndex) == value){
8627 this.config[colIndex].locked = value;
8629 this.fireEvent("columnlockchange", this, colIndex, value);
8633 getTotalLockedWidth : function(){
8635 for(var i = 0; i < this.config.length; i++){
8636 if(this.isLocked(i) && !this.isHidden(i)){
8637 this.totalWidth += this.getColumnWidth(i);
8643 getLockedCount : function(){
8644 for(var i = 0, len = this.config.length; i < len; i++){
8645 if(!this.isLocked(i)){
8650 return this.config.length;
8654 * Returns the number of columns.
8657 getColumnCount : function(visibleOnly){
8658 if(visibleOnly === true){
8660 for(var i = 0, len = this.config.length; i < len; i++){
8661 if(!this.isHidden(i)){
8667 return this.config.length;
8671 * Returns the column configs that return true by the passed function that is called with (columnConfig, index)
8672 * @param {Function} fn
8673 * @param {Object} scope (optional)
8674 * @return {Array} result
8676 getColumnsBy : function(fn, scope){
8678 for(var i = 0, len = this.config.length; i < len; i++){
8679 var c = this.config[i];
8680 if(fn.call(scope||this, c, i) === true){
8688 * Returns true if the specified column is sortable.
8689 * @param {Number} col The column index
8692 isSortable : function(col){
8693 if(typeof this.config[col].sortable == "undefined"){
8694 return this.defaultSortable;
8696 return this.config[col].sortable;
8700 * Returns the rendering (formatting) function defined for the column.
8701 * @param {Number} col The column index.
8702 * @return {Function} The function used to render the cell. See {@link #setRenderer}.
8704 getRenderer : function(col){
8705 if(!this.config[col].renderer){
8706 return Roo.grid.ColumnModel.defaultRenderer;
8708 return this.config[col].renderer;
8712 * Sets the rendering (formatting) function for a column.
8713 * @param {Number} col The column index
8714 * @param {Function} fn The function to use to process the cell's raw data
8715 * to return HTML markup for the grid view. The render function is called with
8716 * the following parameters:<ul>
8717 * <li>Data value.</li>
8718 * <li>Cell metadata. An object in which you may set the following attributes:<ul>
8719 * <li>css A CSS style string to apply to the table cell.</li>
8720 * <li>attr An HTML attribute definition string to apply to the data container element <i>within</i> the table cell.</li></ul>
8721 * <li>The {@link Roo.data.Record} from which the data was extracted.</li>
8722 * <li>Row index</li>
8723 * <li>Column index</li>
8724 * <li>The {@link Roo.data.Store} object from which the Record was extracted</li></ul>
8726 setRenderer : function(col, fn){
8727 this.config[col].renderer = fn;
8731 * Returns the width for the specified column.
8732 * @param {Number} col The column index
8733 * @param (optional) {String} gridSize bootstrap width size.
8736 getColumnWidth : function(col, gridSize)
8738 var cfg = this.config[col];
8740 if (typeof(gridSize) == 'undefined') {
8741 return cfg.width * 1 || this.defaultWidth;
8743 if (gridSize === false) { // if we set it..
8744 return cfg.width || false;
8746 var sizes = ['xl', 'lg', 'md', 'sm', 'xs'];
8748 for(var i = sizes.indexOf(gridSize); i < sizes.length; i++) {
8749 if (typeof(cfg[ sizes[i] ] ) == 'undefined') {
8752 return cfg[ sizes[i] ];
8759 * Sets the width for a column.
8760 * @param {Number} col The column index
8761 * @param {Number} width The new width
8763 setColumnWidth : function(col, width, suppressEvent){
8764 this.config[col].width = width;
8765 this.totalWidth = null;
8767 this.fireEvent("widthchange", this, col, width);
8772 * Returns the total width of all columns.
8773 * @param {Boolean} includeHidden True to include hidden column widths
8776 getTotalWidth : function(includeHidden){
8777 if(!this.totalWidth){
8778 this.totalWidth = 0;
8779 for(var i = 0, len = this.config.length; i < len; i++){
8780 if(includeHidden || !this.isHidden(i)){
8781 this.totalWidth += this.getColumnWidth(i);
8785 return this.totalWidth;
8789 * Returns the header for the specified column.
8790 * @param {Number} col The column index
8793 getColumnHeader : function(col){
8794 return this.config[col].header;
8798 * Sets the header for a column.
8799 * @param {Number} col The column index
8800 * @param {String} header The new header
8802 setColumnHeader : function(col, header){
8803 this.config[col].header = header;
8804 this.fireEvent("headerchange", this, col, header);
8808 * Returns the tooltip for the specified column.
8809 * @param {Number} col The column index
8812 getColumnTooltip : function(col){
8813 return this.config[col].tooltip;
8816 * Sets the tooltip for a column.
8817 * @param {Number} col The column index
8818 * @param {String} tooltip The new tooltip
8820 setColumnTooltip : function(col, tooltip){
8821 this.config[col].tooltip = tooltip;
8825 * Returns the dataIndex for the specified column.
8826 * @param {Number} col The column index
8829 getDataIndex : function(col){
8830 return this.config[col].dataIndex;
8834 * Sets the dataIndex for a column.
8835 * @param {Number} col The column index
8836 * @param {Number} dataIndex The new dataIndex
8838 setDataIndex : function(col, dataIndex){
8839 this.config[col].dataIndex = dataIndex;
8845 * Returns true if the cell is editable.
8846 * @param {Number} colIndex The column index
8847 * @param {Number} rowIndex The row index - this is nto actually used..?
8850 isCellEditable : function(colIndex, rowIndex){
8851 return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
8855 * Returns the editor defined for the cell/column.
8856 * return false or null to disable editing.
8857 * @param {Number} colIndex The column index
8858 * @param {Number} rowIndex The row index
8861 getCellEditor : function(colIndex, rowIndex){
8862 return this.config[colIndex].editor;
8866 * Sets if a column is editable.
8867 * @param {Number} col The column index
8868 * @param {Boolean} editable True if the column is editable
8870 setEditable : function(col, editable){
8871 this.config[col].editable = editable;
8876 * Returns true if the column is hidden.
8877 * @param {Number} colIndex The column index
8880 isHidden : function(colIndex){
8881 return this.config[colIndex].hidden;
8886 * Returns true if the column width cannot be changed
8888 isFixed : function(colIndex){
8889 return this.config[colIndex].fixed;
8893 * Returns true if the column can be resized
8896 isResizable : function(colIndex){
8897 return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
8900 * Sets if a column is hidden.
8901 * @param {Number} colIndex The column index
8902 * @param {Boolean} hidden True if the column is hidden
8904 setHidden : function(colIndex, hidden){
8905 this.config[colIndex].hidden = hidden;
8906 this.totalWidth = null;
8907 this.fireEvent("hiddenchange", this, colIndex, hidden);
8911 * Sets the editor for a column.
8912 * @param {Number} col The column index
8913 * @param {Object} editor The editor object
8915 setEditor : function(col, editor){
8916 this.config[col].editor = editor;
8919 * Add a column (experimental...) - defaults to adding to the end..
8920 * @param {Object} config
8922 addColumn : function(c)
8925 var i = this.config.length;
8928 if(typeof c.dataIndex == "undefined"){
8931 if(typeof c.renderer == "string"){
8932 c.renderer = Roo.util.Format[c.renderer];
8934 if(typeof c.id == "undefined"){
8937 if(c.editor && c.editor.xtype){
8938 c.editor = Roo.factory(c.editor, Roo.grid);
8940 if(c.editor && c.editor.isFormField){
8941 c.editor = new Roo.grid.GridEditor(c.editor);
8943 this.lookup[c.id] = c;
8948 Roo.grid.ColumnModel.defaultRenderer = function(value)
8950 if(typeof value == "object") {
8953 if(typeof value == "string" && value.length < 1){
8957 return String.format("{0}", value);
8960 // Alias for backwards compatibility
8961 Roo.grid.DefaultColumnModel = Roo.grid.ColumnModel;
8964 * Ext JS Library 1.1.1
8965 * Copyright(c) 2006-2007, Ext JS, LLC.
8967 * Originally Released Under LGPL - original licence link has changed is not relivant.
8970 * <script type="text/javascript">
8974 * @class Roo.LoadMask
8975 * A simple utility class for generically masking elements while loading data. If the element being masked has
8976 * an underlying {@link Roo.data.Store}, the masking will be automatically synchronized with the store's loading
8977 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
8978 * element's UpdateManager load indicator and will be destroyed after the initial load.
8980 * Create a new LoadMask
8981 * @param {String/HTMLElement/Roo.Element} el The element or DOM node, or its id
8982 * @param {Object} config The config object
8984 Roo.LoadMask = function(el, config){
8985 this.el = Roo.get(el);
8986 Roo.apply(this, config);
8988 this.store.on('beforeload', this.onBeforeLoad, this);
8989 this.store.on('load', this.onLoad, this);
8990 this.store.on('loadexception', this.onLoadException, this);
8991 this.removeMask = false;
8993 var um = this.el.getUpdateManager();
8994 um.showLoadIndicator = false; // disable the default indicator
8995 um.on('beforeupdate', this.onBeforeLoad, this);
8996 um.on('update', this.onLoad, this);
8997 um.on('failure', this.onLoad, this);
8998 this.removeMask = true;
9002 Roo.LoadMask.prototype = {
9004 * @cfg {Boolean} removeMask
9005 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
9006 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
9011 * The text to display in a centered loading message box (defaults to 'Loading...')
9015 * @cfg {String} msgCls
9016 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
9018 msgCls : 'x-mask-loading',
9021 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
9027 * Disables the mask to prevent it from being displayed
9029 disable : function(){
9030 this.disabled = true;
9034 * Enables the mask so that it can be displayed
9036 enable : function(){
9037 this.disabled = false;
9040 onLoadException : function()
9044 if (typeof(arguments[3]) != 'undefined') {
9045 Roo.MessageBox.alert("Error loading",arguments[3]);
9049 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
9050 Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
9057 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
9062 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
9066 onBeforeLoad : function(){
9068 (function() { this.el.mask(this.msg, this.msgCls); }).defer(50, this);
9073 destroy : function(){
9075 this.store.un('beforeload', this.onBeforeLoad, this);
9076 this.store.un('load', this.onLoad, this);
9077 this.store.un('loadexception', this.onLoadException, this);
9079 var um = this.el.getUpdateManager();
9080 um.un('beforeupdate', this.onBeforeLoad, this);
9081 um.un('update', this.onLoad, this);
9082 um.un('failure', this.onLoad, this);
9086 * @class Roo.bootstrap.Table
9088 * @extends Roo.bootstrap.Component
9089 * @children Roo.bootstrap.TableBody
9090 * Bootstrap Table class. This class represents the primary interface of a component based grid control.
9091 * Similar to Roo.grid.Grid
9093 var table = Roo.factory({
9095 xns : Roo.bootstrap,
9096 autoSizeColumns: true,
9103 sortInfo : { direction : 'ASC', field: 'name' },
9105 xtype : 'HttpProxy',
9108 url : 'https://example.com/some.data.url.json'
9111 xtype : 'JsonReader',
9113 fields : [ 'id', 'name', whatever' ],
9120 xtype : 'ColumnModel',
9124 dataIndex : 'is_in_group',
9127 renderer : function(v, x , r) {
9129 return String.format("{0}", v)
9135 xtype : 'RowSelectionModel',
9136 xns : Roo.bootstrap.Table
9137 // you can add listeners to catch selection change here....
9143 grid.render(Roo.get("some-div"));
9146 Currently the Table uses multiple headers to try and handle XL / Medium etc... styling
9151 * @cfg {Roo.grid.AbstractSelectionModel} sm The selection model to use (cell selection is not supported yet)
9152 * @cfg {Roo.data.Store} store The data store to use
9153 * @cfg {Roo.grid.ColumnModel} cm[] A column for the grid.
9155 * @cfg {String} cls table class
9158 * @cfg {string} empty_results Text to display for no results
9159 * @cfg {boolean} striped Should the rows be alternative striped
9160 * @cfg {boolean} bordered Add borders to the table
9161 * @cfg {boolean} hover Add hover highlighting
9162 * @cfg {boolean} condensed Format condensed
9163 * @cfg {boolean} responsive default false - if this is on, columns are rendered with col-xs-4 etc. classes, otherwise columns will be sized by CSS,
9164 * also adds table-responsive (see bootstrap docs for details)
9165 * @cfg {Boolean} loadMask (true|false) default false
9166 * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
9167 * @cfg {Boolean} headerShow (true|false) generate thead, default true
9168 * @cfg {Boolean} rowSelection (true|false) default false
9169 * @cfg {Boolean} cellSelection (true|false) default false
9170 * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header (with resizable columns)
9171 * @cfg {Roo.bootstrap.PagingToolbar} footer a paging toolbar
9172 * @cfg {Boolean} lazyLoad auto load data while scrolling to the end (default false)
9173 * @cfg {Boolean} auto_hide_footer auto hide footer if only one page (default false)
9174 * @cfg {Boolean} enableColumnResize default true if columns can be resized = needs scrollBody to be set to work (drag/drop)
9175 * @cfg {Boolean} disableAutoSize disable autoSize() and initCSS()
9178 * @cfg {Number} minColumnWidth default 50 pixels minimum column width
9181 * Create a new Table
9182 * @param {Object} config The config object
9185 Roo.bootstrap.Table = function(config)
9187 Roo.bootstrap.Table.superclass.constructor.call(this, config);
9190 this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
9191 this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
9192 this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
9193 this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
9195 this.view = this; // compat with grid.
9197 this.sm = this.sm || {xtype: 'RowSelectionModel'};
9199 this.sm.grid = this;
9200 this.selModel = Roo.factory(this.sm, Roo.grid);
9201 this.sm = this.selModel;
9202 this.sm.xmodule = this.xmodule || false;
9205 if (this.cm && typeof(this.cm.config) == 'undefined') {
9206 this.colModel = new Roo.grid.ColumnModel(this.cm);
9207 this.cm = this.colModel;
9208 this.cm.xmodule = this.xmodule || false;
9211 this.store= Roo.factory(this.store, Roo.data);
9212 this.ds = this.store;
9213 this.ds.xmodule = this.xmodule || false;
9216 if (this.footer && this.store) {
9217 this.footer.dataSource = this.ds;
9218 this.footer = Roo.factory(this.footer);
9225 * Fires when a cell is clicked
9226 * @param {Roo.bootstrap.Table} this
9227 * @param {Roo.Element} el
9228 * @param {Number} rowIndex
9229 * @param {Number} columnIndex
9230 * @param {Roo.EventObject} e
9234 * @event celldblclick
9235 * Fires when a cell is double clicked
9236 * @param {Roo.bootstrap.Table} this
9237 * @param {Roo.Element} el
9238 * @param {Number} rowIndex
9239 * @param {Number} columnIndex
9240 * @param {Roo.EventObject} e
9242 "celldblclick" : true,
9245 * Fires when a row is clicked
9246 * @param {Roo.bootstrap.Table} this
9247 * @param {Roo.Element} el
9248 * @param {Number} rowIndex
9249 * @param {Roo.EventObject} e
9253 * @event rowdblclick
9254 * Fires when a row is double clicked
9255 * @param {Roo.bootstrap.Table} this
9256 * @param {Roo.Element} el
9257 * @param {Number} rowIndex
9258 * @param {Roo.EventObject} e
9260 "rowdblclick" : true,
9263 * Fires when a mouseover occur
9264 * @param {Roo.bootstrap.Table} this
9265 * @param {Roo.Element} el
9266 * @param {Number} rowIndex
9267 * @param {Number} columnIndex
9268 * @param {Roo.EventObject} e
9273 * Fires when a mouseout occur
9274 * @param {Roo.bootstrap.Table} this
9275 * @param {Roo.Element} el
9276 * @param {Number} rowIndex
9277 * @param {Number} columnIndex
9278 * @param {Roo.EventObject} e
9283 * Fires when a row is rendered, so you can change add a style to it.
9284 * @param {Roo.bootstrap.Table} this
9285 * @param {Object} rowcfg contains record rowIndex colIndex and rowClass - set rowClass to add a style.
9289 * @event rowsrendered
9290 * Fires when all the rows have been rendered
9291 * @param {Roo.bootstrap.Table} this
9293 'rowsrendered' : true,
9295 * @event contextmenu
9296 * The raw contextmenu event for the entire grid.
9297 * @param {Roo.EventObject} e
9299 "contextmenu" : true,
9301 * @event rowcontextmenu
9302 * Fires when a row is right clicked
9303 * @param {Roo.bootstrap.Table} this
9304 * @param {Number} rowIndex
9305 * @param {Roo.EventObject} e
9307 "rowcontextmenu" : true,
9309 * @event cellcontextmenu
9310 * Fires when a cell is right clicked
9311 * @param {Roo.bootstrap.Table} this
9312 * @param {Number} rowIndex
9313 * @param {Number} cellIndex
9314 * @param {Roo.EventObject} e
9316 "cellcontextmenu" : true,
9318 * @event headercontextmenu
9319 * Fires when a header is right clicked
9320 * @param {Roo.bootstrap.Table} this
9321 * @param {Number} columnIndex
9322 * @param {Roo.EventObject} e
9324 "headercontextmenu" : true,
9327 * The raw mousedown event for the entire grid.
9328 * @param {Roo.EventObject} e
9335 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
9352 enableColumnResize: true,
9353 disableAutoSize: false,
9355 rowSelection : false,
9356 cellSelection : false,
9359 minColumnWidth : 50,
9361 // Roo.Element - the tbody
9362 bodyEl: false, // <tbody> Roo.Element - thead element
9363 headEl: false, // <thead> Roo.Element - thead element
9364 resizeProxy : false, // proxy element for dragging?
9368 container: false, // used by gridpanel...
9374 auto_hide_footer : false,
9376 view: false, // actually points to this..
9378 getAutoCreate : function()
9380 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
9387 // this get's auto added by panel.Grid
9388 if (this.scrollBody) {
9389 cfg.cls += ' table-body-fixed';
9392 cfg.cls += ' table-striped';
9396 cfg.cls += ' table-hover';
9398 if (this.bordered) {
9399 cfg.cls += ' table-bordered';
9401 if (this.condensed) {
9402 cfg.cls += ' table-condensed';
9405 if (this.responsive) {
9406 cfg.cls += ' table-responsive';
9410 cfg.cls+= ' ' +this.cls;
9416 cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
9419 if(this.store || this.cm){
9420 if(this.headerShow){
9421 cfg.cn.push(this.renderHeader());
9424 cfg.cn.push(this.renderBody());
9426 if(this.footerShow){
9427 cfg.cn.push(this.renderFooter());
9429 // where does this come from?
9430 //cfg.cls+= ' TableGrid';
9433 return { cn : [ cfg ] };
9436 initEvents : function()
9438 if(!this.store || !this.cm){
9441 if (this.selModel) {
9442 this.selModel.initEvents();
9446 //Roo.log('initEvents with ds!!!!');
9448 this.bodyEl = this.el.select('tbody', true).first();
9449 this.headEl = this.el.select('thead', true).first();
9450 this.mainFoot = this.el.select('tfoot', true).first();
9455 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
9456 e.on('click', this.sort, this);
9460 // why is this done????? = it breaks dialogs??
9461 //this.parent().el.setStyle('position', 'relative');
9465 this.footer.parentId = this.id;
9466 this.footer.onRender(this.el.select('tfoot tr td').first(), null);
9469 this.el.select('tfoot tr td').first().addClass('hide');
9474 this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
9477 this.store.on('load', this.onLoad, this);
9478 this.store.on('beforeload', this.onBeforeLoad, this);
9479 this.store.on('update', this.onUpdate, this);
9480 this.store.on('add', this.onAdd, this);
9481 this.store.on("clear", this.clear, this);
9483 this.el.on("contextmenu", this.onContextMenu, this);
9486 this.cm.on("headerchange", this.onHeaderChange, this);
9487 this.cm.on("hiddenchange", this.onHiddenChange, this, arguments);
9489 //?? does bodyEl get replaced on render?
9490 this.bodyEl.on("click", this.onClick, this);
9491 this.bodyEl.on("dblclick", this.onDblClick, this);
9492 this.bodyEl.on('scroll', this.onBodyScroll, this);
9494 // guessing mainbody will work - this relays usually caught by selmodel at present.
9495 this.relayEvents(this.bodyEl, ["mousedown","mouseup","mouseover","mouseout","keypress"]);
9498 this.resizeProxy = Roo.get(document.body).createChild({ cls:"x-grid-resize-proxy", html: ' ' });
9501 if(this.headEl && this.enableColumnResize !== false && Roo.grid.SplitDragZone){
9502 new Roo.grid.SplitDragZone(this, this.headEl.dom, false); // not sure what 'lockedHd is for this implementation..)
9507 // Compatibility with grid - we implement all the view features at present.
9508 getView : function()
9513 initCSS : function()
9515 if(this.disableAutoSize) {
9519 var cm = this.cm, styles = [];
9520 this.CSS.removeStyleSheet(this.id + '-cssrules');
9521 var headHeight = this.headEl ? this.headEl.dom.clientHeight : 0;
9522 // we can honour xs/sm/md/xl as widths...
9523 // we first have to decide what widht we are currently at...
9524 var sz = Roo.getGridSize();
9528 var cols = []; // visable cols.
9530 for(var i = 0, len = cm.getColumnCount(); i < len; i++) {
9531 var w = cm.getColumnWidth(i, false);
9533 cols.push( { rel : false, abs : 0 });
9537 cols.push( { rel : false, abs : w });
9539 last = i; // not really..
9542 var w = cm.getColumnWidth(i, sz);
9547 cols.push( { rel : w, abs : false });
9550 var avail = this.bodyEl.dom.clientWidth - total_abs;
9552 var unitWidth = Math.floor(avail / total);
9553 var rem = avail - (unitWidth * total);
9555 var hidden, width, pos = 0 , splithide , left;
9556 for(var i = 0, len = cm.getColumnCount(); i < len; i++) {
9558 hidden = 'display:none;';
9560 width = 'width:0px;';
9562 if(!cm.isHidden(i)){
9566 // we can honour xs/sm/md/xl ?
9567 var w = cols[i].rel == false ? cols[i].abs : (cols[i].rel * unitWidth);
9569 hidden = 'display:none;';
9571 // width should return a small number...
9573 w+=rem; // add the remaining with..
9576 left = "left:" + (pos -4) + "px;";
9577 width = "width:" + w+ "px;";
9580 if (this.responsive) {
9583 hidden = cm.isHidden(i) ? 'display:none;' : '';
9584 splithide = 'display: none;';
9587 styles.push( '#' , this.id , ' .x-col-' , i, " {", cm.config[i].css, width, hidden, "}\n" );
9590 splithide = 'display:none;';
9593 styles.push('#' , this.id , ' .x-hcol-' , i, " { ", width, hidden," }\n",
9594 '#' , this.id , ' .x-grid-split-' , i, " { ", left, splithide, 'height:', (headHeight - 4), "px;}\n",
9595 // this is the popover version..
9596 '.popover-inner #' , this.id , ' .x-grid-split-' , i, " { ", left, splithide, 'height:', 100, "%;}\n"
9601 //Roo.log(styles.join(''));
9602 this.CSS.createStyleSheet( styles.join(''), this.id + '-cssrules');
9608 onContextMenu : function(e, t)
9610 this.processEvent("contextmenu", e);
9613 processEvent : function(name, e)
9615 if (name != 'touchstart' ) {
9616 this.fireEvent(name, e);
9619 var t = e.getTarget();
9621 var cell = Roo.get(t);
9627 if(cell.findParent('tfoot', false, true)){
9631 if(cell.findParent('thead', false, true)){
9633 if(e.getTarget().nodeName.toLowerCase() != 'th'){
9634 cell = Roo.get(t).findParent('th', false, true);
9636 Roo.log("failed to find th in thead?");
9637 Roo.log(e.getTarget());
9642 var cellIndex = cell.dom.cellIndex;
9644 var ename = name == 'touchstart' ? 'click' : name;
9645 this.fireEvent("header" + ename, this, cellIndex, e);
9650 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9651 cell = Roo.get(t).findParent('td', false, true);
9653 Roo.log("failed to find th in tbody?");
9654 Roo.log(e.getTarget());
9659 var row = cell.findParent('tr', false, true);
9660 var cellIndex = cell.dom.cellIndex;
9661 var rowIndex = row.dom.rowIndex - 1;
9665 this.fireEvent("row" + name, this, rowIndex, e);
9669 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
9675 onMouseover : function(e, el)
9677 var cell = Roo.get(el);
9683 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9684 cell = cell.findParent('td', false, true);
9687 var row = cell.findParent('tr', false, true);
9688 var cellIndex = cell.dom.cellIndex;
9689 var rowIndex = row.dom.rowIndex - 1; // start from 0
9691 this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
9695 onMouseout : function(e, el)
9697 var cell = Roo.get(el);
9703 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9704 cell = cell.findParent('td', false, true);
9707 var row = cell.findParent('tr', false, true);
9708 var cellIndex = cell.dom.cellIndex;
9709 var rowIndex = row.dom.rowIndex - 1; // start from 0
9711 this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
9715 onClick : function(e, el)
9717 var cell = Roo.get(el);
9719 if(!cell || (!this.cellSelection && !this.rowSelection)){
9723 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9724 cell = cell.findParent('td', false, true);
9727 if(!cell || typeof(cell) == 'undefined'){
9731 var row = cell.findParent('tr', false, true);
9733 if(!row || typeof(row) == 'undefined'){
9737 var cellIndex = cell.dom.cellIndex;
9738 var rowIndex = this.getRowIndex(row);
9740 // why??? - should these not be based on SelectionModel?
9741 //if(this.cellSelection){
9742 this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
9745 //if(this.rowSelection){
9746 this.fireEvent('rowclick', this, row, rowIndex, e);
9751 onDblClick : function(e,el)
9753 var cell = Roo.get(el);
9755 if(!cell || (!this.cellSelection && !this.rowSelection)){
9759 if(e.getTarget().nodeName.toLowerCase() != 'td'){
9760 cell = cell.findParent('td', false, true);
9763 if(!cell || typeof(cell) == 'undefined'){
9767 var row = cell.findParent('tr', false, true);
9769 if(!row || typeof(row) == 'undefined'){
9773 var cellIndex = cell.dom.cellIndex;
9774 var rowIndex = this.getRowIndex(row);
9776 if(this.cellSelection){
9777 this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
9780 if(this.rowSelection){
9781 this.fireEvent('rowdblclick', this, row, rowIndex, e);
9784 findRowIndex : function(el)
9786 var cell = Roo.get(el);
9790 var row = cell.findParent('tr', false, true);
9792 if(!row || typeof(row) == 'undefined'){
9795 return this.getRowIndex(row);
9797 sort : function(e,el)
9799 var col = Roo.get(el);
9801 if(!col.hasClass('sortable')){
9805 var sort = col.attr('sort');
9808 if(col.select('i', true).first().hasClass('fa-arrow-up')){
9812 this.store.sortInfo = {field : sort, direction : dir};
9815 Roo.log("calling footer first");
9816 this.footer.onClick('first');
9819 this.store.load({ params : { start : 0 } });
9823 renderHeader : function()
9831 this.totalWidth = 0;
9833 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
9835 var config = cm.config[i];
9839 cls : 'x-hcol-' + i,
9842 html: cm.getColumnHeader(i)
9845 var tooltip = cm.getColumnTooltip(i);
9847 c.tooltip = tooltip;
9853 if(typeof(config.sortable) != 'undefined' && config.sortable){
9854 c.cls += ' sortable';
9855 c.html = '<i class="fa"></i>' + c.html;
9858 // could use BS4 hidden-..-down
9860 if(typeof(config.lgHeader) != 'undefined'){
9861 hh += '<span class="hidden-xs hidden-sm hidden-md ">' + config.lgHeader + '</span>';
9864 if(typeof(config.mdHeader) != 'undefined'){
9865 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
9868 if(typeof(config.smHeader) != 'undefined'){
9869 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
9872 if(typeof(config.xsHeader) != 'undefined'){
9873 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
9880 if(typeof(config.tooltip) != 'undefined'){
9881 c.tooltip = config.tooltip;
9884 if(typeof(config.colspan) != 'undefined'){
9885 c.colspan = config.colspan;
9888 // hidden is handled by CSS now
9890 if(typeof(config.dataIndex) != 'undefined'){
9891 c.sort = config.dataIndex;
9896 if(typeof(config.align) != 'undefined' && config.align.length){
9897 c.style += ' text-align:' + config.align + ';';
9900 /* width is done in CSS
9901 *if(typeof(config.width) != 'undefined'){
9902 c.style += ' width:' + config.width + 'px;';
9903 this.totalWidth += config.width;
9905 this.totalWidth += 100; // assume minimum of 100 per column?
9909 if(typeof(config.cls) != 'undefined'){
9910 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
9912 // this is the bit that doesnt reall work at all...
9914 if (this.responsive) {
9917 ['xs','sm','md','lg'].map(function(size){
9919 if(typeof(config[size]) == 'undefined'){
9923 if (!config[size]) { // 0 = hidden
9924 // BS 4 '0' is treated as hide that column and below.
9925 c.cls += ' hidden-' + size + ' hidden' + size + '-down';
9929 c.cls += ' col-' + size + '-' + config[size] + (
9930 size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
9938 c.html +=' <span class="x-grid-split x-grid-split-' + i + '"></span>';
9949 renderBody : function()
9959 colspan : this.cm.getColumnCount()
9969 renderFooter : function()
9979 colspan : this.cm.getColumnCount()
9993 // Roo.log('ds onload');
9998 var ds = this.store;
10000 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
10001 e.select('i', true).removeClass(['fa-arrow-up', 'fa-arrow-down']);
10002 if (_this.store.sortInfo) {
10004 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
10005 e.select('i', true).addClass(['fa-arrow-up']);
10008 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
10009 e.select('i', true).addClass(['fa-arrow-down']);
10014 var tbody = this.bodyEl;
10016 if(ds.getCount() > 0){
10017 ds.data.each(function(d,rowIndex){
10018 var row = this.renderRow(cm, ds, rowIndex);
10020 tbody.createChild(row);
10024 if(row.cellObjects.length){
10025 Roo.each(row.cellObjects, function(r){
10026 _this.renderCellObject(r);
10031 } else if (this.empty_results.length) {
10032 this.el.mask(this.empty_results, 'no-spinner');
10035 var tfoot = this.el.select('tfoot', true).first();
10037 if(this.footerShow && this.auto_hide_footer && this.mainFoot){
10039 this.mainFoot.setVisibilityMode(Roo.Element.DISPLAY).hide();
10041 var total = this.ds.getTotalCount();
10043 if(this.footer.pageSize < total){
10044 this.mainFoot.show();
10048 Roo.each(this.el.select('tbody td', true).elements, function(e){
10049 e.on('mouseover', _this.onMouseover, _this);
10052 Roo.each(this.el.select('tbody td', true).elements, function(e){
10053 e.on('mouseout', _this.onMouseout, _this);
10055 this.fireEvent('rowsrendered', this);
10059 this.initCSS(); /// resize cols
10065 onUpdate : function(ds,record)
10067 this.refreshRow(record);
10071 onRemove : function(ds, record, index, isUpdate){
10072 if(isUpdate !== true){
10073 this.fireEvent("beforerowremoved", this, index, record);
10075 var bt = this.bodyEl.dom;
10077 var rows = this.el.select('tbody > tr', true).elements;
10079 if(typeof(rows[index]) != 'undefined'){
10080 bt.removeChild(rows[index].dom);
10083 // if(bt.rows[index]){
10084 // bt.removeChild(bt.rows[index]);
10087 if(isUpdate !== true){
10088 //this.stripeRows(index);
10089 //this.syncRowHeights(index, index);
10091 this.fireEvent("rowremoved", this, index, record);
10095 onAdd : function(ds, records, rowIndex)
10097 //Roo.log('on Add called');
10098 // - note this does not handle multiple adding very well..
10099 var bt = this.bodyEl.dom;
10100 for (var i =0 ; i < records.length;i++) {
10101 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
10102 //Roo.log(records[i]);
10103 //Roo.log(this.store.getAt(rowIndex+i));
10104 this.insertRow(this.store, rowIndex + i, false);
10111 refreshRow : function(record){
10112 var ds = this.store, index;
10113 if(typeof record == 'number'){
10115 record = ds.getAt(index);
10117 index = ds.indexOf(record);
10119 return; // should not happen - but seems to
10122 this.insertRow(ds, index, true);
10124 this.onRemove(ds, record, index+1, true);
10126 //this.syncRowHeights(index, index);
10128 this.fireEvent("rowupdated", this, index, record);
10130 // private - called by RowSelection
10131 onRowSelect : function(rowIndex){
10132 var row = this.getRowDom(rowIndex);
10133 row.addClass(['bg-info','info']);
10135 // private - called by RowSelection
10136 onRowDeselect : function(rowIndex)
10138 if (rowIndex < 0) {
10141 var row = this.getRowDom(rowIndex);
10142 row.removeClass(['bg-info','info']);
10145 * Focuses the specified row.
10146 * @param {Number} row The row index
10148 focusRow : function(row)
10150 //Roo.log('GridView.focusRow');
10151 var x = this.bodyEl.dom.scrollLeft;
10152 this.focusCell(row, 0, false);
10153 this.bodyEl.dom.scrollLeft = x;
10157 * Focuses the specified cell.
10158 * @param {Number} row The row index
10159 * @param {Number} col The column index
10160 * @param {Boolean} hscroll false to disable horizontal scrolling
10162 focusCell : function(row, col, hscroll)
10164 //Roo.log('GridView.focusCell');
10165 var el = this.ensureVisible(row, col, hscroll);
10166 // not sure what focusEL achives = it's a <a> pos relative
10167 //this.focusEl.alignTo(el, "tl-tl");
10169 // this.focusEl.focus();
10171 // this.focusEl.focus.defer(1, this.focusEl);
10176 * Scrolls the specified cell into view
10177 * @param {Number} row The row index
10178 * @param {Number} col The column index
10179 * @param {Boolean} hscroll false to disable horizontal scrolling
10181 ensureVisible : function(row, col, hscroll)
10183 //Roo.log('GridView.ensureVisible,' + row + ',' + col);
10184 //return null; //disable for testing.
10185 if(typeof row != "number"){
10186 row = row.rowIndex;
10188 if(row < 0 && row >= this.ds.getCount()){
10191 col = (col !== undefined ? col : 0);
10193 while(cm.isHidden(col)){
10197 var el = this.getCellDom(row, col);
10201 var c = this.bodyEl.dom;
10203 var ctop = parseInt(el.offsetTop, 10);
10204 var cleft = parseInt(el.offsetLeft, 10);
10205 var cbot = ctop + el.offsetHeight;
10206 var cright = cleft + el.offsetWidth;
10208 //var ch = c.clientHeight - this.mainHd.dom.offsetHeight;
10209 var ch = 0; //?? header is not withing the area?
10210 var stop = parseInt(c.scrollTop, 10);
10211 var sleft = parseInt(c.scrollLeft, 10);
10212 var sbot = stop + ch;
10213 var sright = sleft + c.clientWidth;
10215 Roo.log('GridView.ensureVisible:' +
10217 ' c.clientHeight:' + c.clientHeight +
10218 ' this.mainHd.dom.offsetHeight:' + this.mainHd.dom.offsetHeight +
10226 c.scrollTop = ctop;
10227 //Roo.log("set scrolltop to ctop DISABLE?");
10228 }else if(cbot > sbot){
10229 //Roo.log("set scrolltop to cbot-ch");
10230 c.scrollTop = cbot-ch;
10233 if(hscroll !== false){
10235 c.scrollLeft = cleft;
10236 }else if(cright > sright){
10237 c.scrollLeft = cright-c.clientWidth;
10245 insertRow : function(dm, rowIndex, isUpdate){
10248 this.fireEvent("beforerowsinserted", this, rowIndex);
10250 //var s = this.getScrollState();
10251 var row = this.renderRow(this.cm, this.store, rowIndex);
10252 // insert before rowIndex..
10253 var e = this.bodyEl.createChild(row,this.getRowDom(rowIndex));
10257 if(row.cellObjects.length){
10258 Roo.each(row.cellObjects, function(r){
10259 _this.renderCellObject(r);
10264 this.fireEvent("rowsinserted", this, rowIndex);
10265 //this.syncRowHeights(firstRow, lastRow);
10266 //this.stripeRows(firstRow);
10273 getRowDom : function(rowIndex)
10275 var rows = this.el.select('tbody > tr', true).elements;
10277 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
10280 getCellDom : function(rowIndex, colIndex)
10282 var row = this.getRowDom(rowIndex);
10283 if (row === false) {
10286 var cols = row.select('td', true).elements;
10287 return (typeof(cols[colIndex]) == 'undefined') ? false : cols[colIndex];
10291 // returns the object tree for a tr..
10294 renderRow : function(cm, ds, rowIndex)
10296 var d = ds.getAt(rowIndex);
10300 cls : 'x-row-' + rowIndex,
10304 var cellObjects = [];
10306 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
10307 var config = cm.config[i];
10309 var renderer = cm.getRenderer(i);
10313 if(typeof(renderer) !== 'undefined'){
10314 value = renderer(d.data[cm.getDataIndex(i)], false, d);
10316 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
10317 // and are rendered into the cells after the row is rendered - using the id for the element.
10319 if(typeof(value) === 'object'){
10329 rowIndex : rowIndex,
10334 this.fireEvent('rowclass', this, rowcfg);
10338 // this might end up displaying HTML?
10339 // this is too messy... - better to only do it on columsn you know are going to be too long
10340 //tooltip : (typeof(value) === 'object') ? '' : value,
10341 cls : rowcfg.rowClass + ' x-col-' + i,
10343 html: (typeof(value) === 'object') ? '' : value
10350 if(typeof(config.colspan) != 'undefined'){
10351 td.colspan = config.colspan;
10356 if(typeof(config.align) != 'undefined' && config.align.length){
10357 td.style += ' text-align:' + config.align + ';';
10359 if(typeof(config.valign) != 'undefined' && config.valign.length){
10360 td.style += ' vertical-align:' + config.valign + ';';
10363 if(typeof(config.width) != 'undefined'){
10364 td.style += ' width:' + config.width + 'px;';
10368 if(typeof(config.cursor) != 'undefined'){
10369 td.style += ' cursor:' + config.cursor + ';';
10372 if(typeof(config.cls) != 'undefined'){
10373 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
10375 if (this.responsive) {
10376 ['xs','sm','md','lg'].map(function(size){
10378 if(typeof(config[size]) == 'undefined'){
10384 if (!config[size]) { // 0 = hidden
10385 // BS 4 '0' is treated as hide that column and below.
10386 td.cls += ' hidden-' + size + ' hidden' + size + '-down';
10390 td.cls += ' col-' + size + '-' + config[size] + (
10391 size == 'xs' ? (' col-' + config[size] ) : '' // bs4 col-{num} replaces col-xs
10401 row.cellObjects = cellObjects;
10409 onBeforeLoad : function()
10411 this.el.unmask(); // if needed.
10418 this.el.select('tbody', true).first().dom.innerHTML = '';
10421 * Show or hide a row.
10422 * @param {Number} rowIndex to show or hide
10423 * @param {Boolean} state hide
10425 setRowVisibility : function(rowIndex, state)
10427 var bt = this.bodyEl.dom;
10429 var rows = this.el.select('tbody > tr', true).elements;
10431 if(typeof(rows[rowIndex]) == 'undefined'){
10434 rows[rowIndex][ state ? 'removeClass' : 'addClass']('d-none');
10439 getSelectionModel : function(){
10440 if(!this.selModel){
10441 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
10443 return this.selModel;
10446 * Render the Roo.bootstrap object from renderder
10448 renderCellObject : function(r)
10452 r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
10454 var t = r.cfg.render(r.container);
10457 Roo.each(r.cfg.cn, function(c){
10459 container: t.getChildContainer(),
10462 _this.renderCellObject(child);
10467 * get the Row Index from a dom element.
10468 * @param {Roo.Element} row The row to look for
10469 * @returns {Number} the row
10471 getRowIndex : function(row)
10475 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
10486 * get the header TH element for columnIndex
10487 * @param {Number} columnIndex
10488 * @returns {Roo.Element}
10490 getHeaderIndex: function(colIndex)
10492 var cols = this.headEl.select('th', true).elements;
10493 return cols[colIndex];
10496 * get the Column Index from a dom element. (using regex on x-hcol-{colid})
10497 * @param {domElement} cell to look for
10498 * @returns {Number} the column
10500 getCellIndex : function(cell)
10502 var id = String(cell.className).match(Roo.bootstrap.Table.cellRE);
10504 return parseInt(id[1], 10);
10509 * Returns the grid's underlying element = used by panel.Grid
10510 * @return {Element} The element
10512 getGridEl : function(){
10516 * Forces a resize - used by panel.Grid
10517 * @return {Element} The element
10519 autoSize : function()
10521 if(this.disableAutoSize) {
10524 //var ctr = Roo.get(this.container.dom.parentElement);
10525 var ctr = Roo.get(this.el.dom);
10527 var thd = this.getGridEl().select('thead',true).first();
10528 var tbd = this.getGridEl().select('tbody', true).first();
10529 var tfd = this.getGridEl().select('tfoot', true).first();
10531 var cw = ctr.getWidth();
10532 this.getGridEl().select('tfoot tr, tfoot td',true).setWidth(cw);
10536 tbd.setWidth(ctr.getWidth());
10537 // if the body has a max height - and then scrolls - we should perhaps set up the height here
10538 // this needs fixing for various usage - currently only hydra job advers I think..
10540 // ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
10542 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
10545 cw = Math.max(cw, this.totalWidth);
10546 this.getGridEl().select('tbody tr',true).setWidth(cw);
10549 // resize 'expandable coloumn?
10551 return; // we doe not have a view in this design..
10554 onBodyScroll: function()
10556 //Roo.log("body scrolled');" + this.bodyEl.dom.scrollLeft);
10558 this.headEl.setStyle({
10559 'position' : 'relative',
10560 'left': (-1* this.bodyEl.dom.scrollLeft) + 'px'
10566 var scrollHeight = this.bodyEl.dom.scrollHeight;
10568 var scrollTop = Math.ceil(this.bodyEl.getScroll().top);
10570 var height = this.bodyEl.getHeight();
10572 if(scrollHeight - height == scrollTop) {
10574 var total = this.ds.getTotalCount();
10576 if(this.footer.cursor + this.footer.pageSize < total){
10578 this.footer.ds.load({
10580 start : this.footer.cursor + this.footer.pageSize,
10581 limit : this.footer.pageSize
10590 onColumnSplitterMoved : function(i, diff)
10592 this.userResized = true;
10594 var cm = this.colModel;
10596 var w = this.getHeaderIndex(i).getWidth() + diff;
10599 cm.setColumnWidth(i, w, true);
10601 //var cid = cm.getColumnId(i); << not used in this version?
10602 /* Roo.log(['#' + this.id + ' .x-col-' + i, "width", w + "px"]);
10604 this.CSS.updateRule( '#' + this.id + ' .x-col-' + i, "width", w + "px");
10605 this.CSS.updateRule('#' + this.id + ' .x-hcol-' + i, "width", w + "px");
10606 this.CSS.updateRule('#' + this.id + ' .x-grid-split-' + i, "left", w + "px");
10608 //this.updateSplitters();
10609 //this.layout(); << ??
10610 this.fireEvent("columnresize", i, w);
10612 onHeaderChange : function()
10614 var header = this.renderHeader();
10615 var table = this.el.select('table', true).first();
10617 this.headEl.remove();
10618 this.headEl = table.createChild(header, this.bodyEl, false);
10620 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
10621 e.on('click', this.sort, this);
10624 if(this.enableColumnResize !== false && Roo.grid.SplitDragZone){
10625 new Roo.grid.SplitDragZone(this, this.headEl.dom, false); // not sure what 'lockedHd is for this implementation..)
10630 onHiddenChange : function(colModel, colIndex, hidden)
10633 this.cm.setHidden()
10634 var thSelector = '#' + this.id + ' .x-hcol-' + colIndex;
10635 var tdSelector = '#' + this.id + ' .x-col-' + colIndex;
10637 this.CSS.updateRule(thSelector, "display", "");
10638 this.CSS.updateRule(tdSelector, "display", "");
10641 this.CSS.updateRule(thSelector, "display", "none");
10642 this.CSS.updateRule(tdSelector, "display", "none");
10645 // onload calls initCSS()
10646 this.onHeaderChange();
10650 setColumnWidth: function(col_index, width)
10652 // width = "md-2 xs-2..."
10653 if(!this.colModel.config[col_index]) {
10657 var w = width.split(" ");
10659 var rows = this.el.dom.getElementsByClassName("x-col-"+col_index);
10661 var h_row = this.el.dom.getElementsByClassName("x-hcol-"+col_index);
10664 for(var j = 0; j < w.length; j++) {
10670 var size_cls = w[j].split("-");
10672 if(!Number.isInteger(size_cls[1] * 1)) {
10676 if(!this.colModel.config[col_index][size_cls[0]]) {
10680 if(!h_row[0].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
10684 h_row[0].classList.replace(
10685 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
10686 "col-"+size_cls[0]+"-"+size_cls[1]
10689 for(var i = 0; i < rows.length; i++) {
10691 var size_cls = w[j].split("-");
10693 if(!Number.isInteger(size_cls[1] * 1)) {
10697 if(!this.colModel.config[col_index][size_cls[0]]) {
10701 if(!rows[i].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
10705 rows[i].classList.replace(
10706 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
10707 "col-"+size_cls[0]+"-"+size_cls[1]
10711 this.colModel.config[col_index][size_cls[0]] = size_cls[1];
10716 // currently only used to find the split on drag..
10717 Roo.bootstrap.Table.cellRE = /(?:.*?)x-grid-(?:hd|cell|split)-([\d]+)(?:.*?)/;
10722 Roo.bootstrap.Table.AbstractSelectionModel = Roo.grid.AbstractSelectionModel;
10723 Roo.bootstrap.Table.RowSelectionModel = Roo.grid.RowSelectionModel;
10732 * @class Roo.bootstrap.TableCell
10733 * @extends Roo.bootstrap.Component
10734 * @children Roo.bootstrap.Component
10735 * @parent Roo.bootstrap.TableRow
10736 * Bootstrap TableCell class
10738 * @cfg {String} html cell contain text
10739 * @cfg {String} cls cell class
10740 * @cfg {String} tag cell tag (td|th) default td
10741 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
10742 * @cfg {String} align Aligns the content in a cell
10743 * @cfg {String} axis Categorizes cells
10744 * @cfg {String} bgcolor Specifies the background color of a cell
10745 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
10746 * @cfg {Number} colspan Specifies the number of columns a cell should span
10747 * @cfg {String} headers Specifies one or more header cells a cell is related to
10748 * @cfg {Number} height Sets the height of a cell
10749 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
10750 * @cfg {Number} rowspan Sets the number of rows a cell should span
10751 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
10752 * @cfg {String} valign Vertical aligns the content in a cell
10753 * @cfg {Number} width Specifies the width of a cell
10756 * Create a new TableCell
10757 * @param {Object} config The config object
10760 Roo.bootstrap.TableCell = function(config){
10761 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
10764 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
10784 getAutoCreate : function(){
10785 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
10792 cfg.tag = this.tag;
10805 cfg.align=this.align
10810 if (this.bgcolor) {
10811 cfg.bgcolor=this.bgcolor
10813 if (this.charoff) {
10814 cfg.charoff=this.charoff
10816 if (this.colspan) {
10817 cfg.colspan=this.colspan
10819 if (this.headers) {
10820 cfg.headers=this.headers
10823 cfg.height=this.height
10826 cfg.nowrap=this.nowrap
10828 if (this.rowspan) {
10829 cfg.rowspan=this.rowspan
10832 cfg.scope=this.scope
10835 cfg.valign=this.valign
10838 cfg.width=this.width
10857 * @class Roo.bootstrap.TableRow
10858 * @extends Roo.bootstrap.Component
10859 * @children Roo.bootstrap.TableCell
10860 * @parent Roo.bootstrap.TableBody
10861 * Bootstrap TableRow class
10862 * @cfg {String} cls row class
10863 * @cfg {String} align Aligns the content in a table row
10864 * @cfg {String} bgcolor Specifies a background color for a table row
10865 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
10866 * @cfg {String} valign Vertical aligns the content in a table row
10869 * Create a new TableRow
10870 * @param {Object} config The config object
10873 Roo.bootstrap.TableRow = function(config){
10874 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
10877 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
10885 getAutoCreate : function(){
10886 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
10893 cfg.cls = this.cls;
10896 cfg.align = this.align;
10899 cfg.bgcolor = this.bgcolor;
10902 cfg.charoff = this.charoff;
10905 cfg.valign = this.valign;
10923 * @class Roo.bootstrap.TableBody
10924 * @extends Roo.bootstrap.Component
10925 * @children Roo.bootstrap.TableRow
10926 * @parent Roo.bootstrap.Table
10927 * Bootstrap TableBody class
10928 * @cfg {String} cls element class
10929 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
10930 * @cfg {String} align Aligns the content inside the element
10931 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
10932 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
10935 * Create a new TableBody
10936 * @param {Object} config The config object
10939 Roo.bootstrap.TableBody = function(config){
10940 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
10943 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
10951 getAutoCreate : function(){
10952 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
10962 cfg.tag = this.tag;
10966 cfg.align = this.align;
10969 cfg.charoff = this.charoff;
10972 cfg.valign = this.valign;
10979 // initEvents : function()
10982 // if(!this.store){
10986 // this.store = Roo.factory(this.store, Roo.data);
10987 // this.store.on('load', this.onLoad, this);
10989 // this.store.load();
10993 // onLoad: function ()
10995 // this.fireEvent('load', this);
11005 * Ext JS Library 1.1.1
11006 * Copyright(c) 2006-2007, Ext JS, LLC.
11008 * Originally Released Under LGPL - original licence link has changed is not relivant.
11011 * <script type="text/javascript">
11014 // as we use this in bootstrap.
11015 Roo.namespace('Roo.form');
11017 * @class Roo.form.Action
11018 * Internal Class used to handle form actions
11020 * @param {Roo.form.BasicForm} el The form element or its id
11021 * @param {Object} config Configuration options
11026 // define the action interface
11027 Roo.form.Action = function(form, options){
11029 this.options = options || {};
11032 * Client Validation Failed
11035 Roo.form.Action.CLIENT_INVALID = 'client';
11037 * Server Validation Failed
11040 Roo.form.Action.SERVER_INVALID = 'server';
11042 * Connect to Server Failed
11045 Roo.form.Action.CONNECT_FAILURE = 'connect';
11047 * Reading Data from Server Failed
11050 Roo.form.Action.LOAD_FAILURE = 'load';
11052 Roo.form.Action.prototype = {
11054 failureType : undefined,
11055 response : undefined,
11056 result : undefined,
11058 // interface method
11059 run : function(options){
11063 // interface method
11064 success : function(response){
11068 // interface method
11069 handleResponse : function(response){
11073 // default connection failure
11074 failure : function(response){
11076 this.response = response;
11077 this.failureType = Roo.form.Action.CONNECT_FAILURE;
11078 this.form.afterAction(this, false);
11081 processResponse : function(response){
11082 this.response = response;
11083 if(!response.responseText){
11086 this.result = this.handleResponse(response);
11087 return this.result;
11090 // utility functions used internally
11091 getUrl : function(appendParams){
11092 var url = this.options.url || this.form.url || this.form.el.dom.action;
11094 var p = this.getParams();
11096 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
11102 getMethod : function(){
11103 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
11106 getParams : function(){
11107 var bp = this.form.baseParams;
11108 var p = this.options.params;
11110 if(typeof p == "object"){
11111 p = Roo.urlEncode(Roo.applyIf(p, bp));
11112 }else if(typeof p == 'string' && bp){
11113 p += '&' + Roo.urlEncode(bp);
11116 p = Roo.urlEncode(bp);
11121 createCallback : function(){
11123 success: this.success,
11124 failure: this.failure,
11126 timeout: (this.form.timeout*1000),
11127 upload: this.form.fileUpload ? this.success : undefined
11132 Roo.form.Action.Submit = function(form, options){
11133 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
11136 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
11139 haveProgress : false,
11140 uploadComplete : false,
11142 // uploadProgress indicator.
11143 uploadProgress : function()
11145 if (!this.form.progressUrl) {
11149 if (!this.haveProgress) {
11150 Roo.MessageBox.progress("Uploading", "Uploading");
11152 if (this.uploadComplete) {
11153 Roo.MessageBox.hide();
11157 this.haveProgress = true;
11159 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
11161 var c = new Roo.data.Connection();
11163 url : this.form.progressUrl,
11168 success : function(req){
11169 //console.log(data);
11173 rdata = Roo.decode(req.responseText)
11175 Roo.log("Invalid data from server..");
11179 if (!rdata || !rdata.success) {
11181 Roo.MessageBox.alert(Roo.encode(rdata));
11184 var data = rdata.data;
11186 if (this.uploadComplete) {
11187 Roo.MessageBox.hide();
11192 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
11193 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
11196 this.uploadProgress.defer(2000,this);
11199 failure: function(data) {
11200 Roo.log('progress url failed ');
11211 // run get Values on the form, so it syncs any secondary forms.
11212 this.form.getValues();
11214 var o = this.options;
11215 var method = this.getMethod();
11216 var isPost = method == 'POST';
11217 if(o.clientValidation === false || this.form.isValid()){
11219 if (this.form.progressUrl) {
11220 this.form.findField('UPLOAD_IDENTIFIER').setValue(
11221 (new Date() * 1) + '' + Math.random());
11226 Roo.Ajax.request(Roo.apply(this.createCallback(), {
11227 form:this.form.el.dom,
11228 url:this.getUrl(!isPost),
11230 params:isPost ? this.getParams() : null,
11231 isUpload: this.form.fileUpload,
11232 formData : this.form.formData
11235 this.uploadProgress();
11237 }else if (o.clientValidation !== false){ // client validation failed
11238 this.failureType = Roo.form.Action.CLIENT_INVALID;
11239 this.form.afterAction(this, false);
11243 success : function(response)
11245 this.uploadComplete= true;
11246 if (this.haveProgress) {
11247 Roo.MessageBox.hide();
11251 var result = this.processResponse(response);
11252 if(result === true || result.success){
11253 this.form.afterAction(this, true);
11257 this.form.markInvalid(result.errors);
11258 this.failureType = Roo.form.Action.SERVER_INVALID;
11260 this.form.afterAction(this, false);
11262 failure : function(response)
11264 this.uploadComplete= true;
11265 if (this.haveProgress) {
11266 Roo.MessageBox.hide();
11269 this.response = response;
11270 this.failureType = Roo.form.Action.CONNECT_FAILURE;
11271 this.form.afterAction(this, false);
11274 handleResponse : function(response){
11275 if(this.form.errorReader){
11276 var rs = this.form.errorReader.read(response);
11279 for(var i = 0, len = rs.records.length; i < len; i++) {
11280 var r = rs.records[i];
11281 errors[i] = r.data;
11284 if(errors.length < 1){
11288 success : rs.success,
11294 ret = Roo.decode(response.responseText);
11298 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
11308 Roo.form.Action.Load = function(form, options){
11309 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
11310 this.reader = this.form.reader;
11313 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
11318 Roo.Ajax.request(Roo.apply(
11319 this.createCallback(), {
11320 method:this.getMethod(),
11321 url:this.getUrl(false),
11322 params:this.getParams()
11326 success : function(response){
11328 var result = this.processResponse(response);
11329 if(result === true || !result.success || !result.data){
11330 this.failureType = Roo.form.Action.LOAD_FAILURE;
11331 this.form.afterAction(this, false);
11334 this.form.clearInvalid();
11335 this.form.setValues(result.data);
11336 this.form.afterAction(this, true);
11339 handleResponse : function(response){
11340 if(this.form.reader){
11341 var rs = this.form.reader.read(response);
11342 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
11344 success : rs.success,
11348 return Roo.decode(response.responseText);
11352 Roo.form.Action.ACTION_TYPES = {
11353 'load' : Roo.form.Action.Load,
11354 'submit' : Roo.form.Action.Submit
11363 * @class Roo.bootstrap.form.Form
11364 * @extends Roo.bootstrap.Component
11365 * @children Roo.bootstrap.Component
11366 * Bootstrap Form class
11367 * @cfg {String} method GET | POST (default POST)
11368 * @cfg {String} labelAlign top | left (default top)
11369 * @cfg {String} align left | right - for navbars
11370 * @cfg {Boolean} loadMask load mask when submit (default true)
11374 * Create a new Form
11375 * @param {Object} config The config object
11379 Roo.bootstrap.form.Form = function(config){
11381 Roo.bootstrap.form.Form.superclass.constructor.call(this, config);
11383 Roo.bootstrap.form.Form.popover.apply();
11387 * @event clientvalidation
11388 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
11389 * @param {Form} this
11390 * @param {Boolean} valid true if the form has passed client-side validation
11392 clientvalidation: true,
11394 * @event beforeaction
11395 * Fires before any action is performed. Return false to cancel the action.
11396 * @param {Form} this
11397 * @param {Action} action The action to be performed
11399 beforeaction: true,
11401 * @event actionfailed
11402 * Fires when an action fails.
11403 * @param {Form} this
11404 * @param {Action} action The action that failed
11406 actionfailed : true,
11408 * @event actioncomplete
11409 * Fires when an action is completed.
11410 * @param {Form} this
11411 * @param {Action} action The action that completed
11413 actioncomplete : true
11417 Roo.extend(Roo.bootstrap.form.Form, Roo.bootstrap.Component, {
11420 * @cfg {String} method
11421 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
11425 * @cfg {String} url
11426 * The URL to use for form actions if one isn't supplied in the action options.
11429 * @cfg {Boolean} fileUpload
11430 * Set to true if this form is a file upload.
11434 * @cfg {Object} baseParams
11435 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
11439 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
11443 * @cfg {Sting} align (left|right) for navbar forms
11448 activeAction : null,
11451 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
11452 * element by passing it or its id or mask the form itself by passing in true.
11455 waitMsgTarget : false,
11460 * @cfg {Boolean} errorMask (true|false) default false
11465 * @cfg {Number} maskOffset Default 100
11470 * @cfg {Boolean} maskBody
11474 getAutoCreate : function(){
11478 method : this.method || 'POST',
11479 id : this.id || Roo.id(),
11482 if (this.parent().xtype.match(/^Nav/)) {
11483 cfg.cls = 'navbar-form form-inline navbar-' + this.align;
11487 if (this.labelAlign == 'left' ) {
11488 cfg.cls += ' form-horizontal';
11494 initEvents : function()
11496 this.el.on('submit', this.onSubmit, this);
11497 // this was added as random key presses on the form where triggering form submit.
11498 this.el.on('keypress', function(e) {
11499 if (e.getCharCode() != 13) {
11502 // we might need to allow it for textareas.. and some other items.
11503 // check e.getTarget().
11505 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
11509 Roo.log("keypress blocked");
11511 e.preventDefault();
11517 onSubmit : function(e){
11522 * Returns true if client-side validation on the form is successful.
11525 isValid : function(){
11526 var items = this.getItems();
11528 var target = false;
11530 items.each(function(f){
11536 Roo.log('invalid field: ' + f.name);
11540 if(!target && f.el.isVisible(true)){
11546 if(this.errorMask && !valid){
11547 Roo.bootstrap.form.Form.popover.mask(this, target);
11554 * Returns true if any fields in this form have changed since their original load.
11557 isDirty : function(){
11559 var items = this.getItems();
11560 items.each(function(f){
11570 * Performs a predefined action (submit or load) or custom actions you define on this form.
11571 * @param {String} actionName The name of the action type
11572 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
11573 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
11574 * accept other config options):
11576 Property Type Description
11577 ---------------- --------------- ----------------------------------------------------------------------------------
11578 url String The url for the action (defaults to the form's url)
11579 method String The form method to use (defaults to the form's method, or POST if not defined)
11580 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
11581 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
11582 validate the form on the client (defaults to false)
11584 * @return {BasicForm} this
11586 doAction : function(action, options){
11587 if(typeof action == 'string'){
11588 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
11590 if(this.fireEvent('beforeaction', this, action) !== false){
11591 this.beforeAction(action);
11592 action.run.defer(100, action);
11598 beforeAction : function(action){
11599 var o = action.options;
11604 Roo.get(document.body).mask(o.waitMsg || "Sending", 'x-mask-loading')
11606 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
11609 // not really supported yet.. ??
11611 //if(this.waitMsgTarget === true){
11612 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
11613 //}else if(this.waitMsgTarget){
11614 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
11615 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
11617 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
11623 afterAction : function(action, success){
11624 this.activeAction = null;
11625 var o = action.options;
11630 Roo.get(document.body).unmask();
11636 //if(this.waitMsgTarget === true){
11637 // this.el.unmask();
11638 //}else if(this.waitMsgTarget){
11639 // this.waitMsgTarget.unmask();
11641 // Roo.MessageBox.updateProgress(1);
11642 // Roo.MessageBox.hide();
11649 Roo.callback(o.success, o.scope, [this, action]);
11650 this.fireEvent('actioncomplete', this, action);
11654 // failure condition..
11655 // we have a scenario where updates need confirming.
11656 // eg. if a locking scenario exists..
11657 // we look for { errors : { needs_confirm : true }} in the response.
11659 (typeof(action.result) != 'undefined') &&
11660 (typeof(action.result.errors) != 'undefined') &&
11661 (typeof(action.result.errors.needs_confirm) != 'undefined')
11664 Roo.log("not supported yet");
11667 Roo.MessageBox.confirm(
11668 "Change requires confirmation",
11669 action.result.errorMsg,
11674 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
11684 Roo.callback(o.failure, o.scope, [this, action]);
11685 // show an error message if no failed handler is set..
11686 if (!this.hasListener('actionfailed')) {
11687 Roo.log("need to add dialog support");
11689 Roo.MessageBox.alert("Error",
11690 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
11691 action.result.errorMsg :
11692 "Saving Failed, please check your entries or try again"
11697 this.fireEvent('actionfailed', this, action);
11702 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
11703 * @param {String} id The value to search for
11706 findField : function(id){
11707 var items = this.getItems();
11708 var field = items.get(id);
11710 items.each(function(f){
11711 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
11718 return field || null;
11721 * Mark fields in this form invalid in bulk.
11722 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
11723 * @return {BasicForm} this
11725 markInvalid : function(errors){
11726 if(errors instanceof Array){
11727 for(var i = 0, len = errors.length; i < len; i++){
11728 var fieldError = errors[i];
11729 var f = this.findField(fieldError.id);
11731 f.markInvalid(fieldError.msg);
11737 if(typeof errors[id] != 'function' && (field = this.findField(id))){
11738 field.markInvalid(errors[id]);
11742 //Roo.each(this.childForms || [], function (f) {
11743 // f.markInvalid(errors);
11750 * Set values for fields in this form in bulk.
11751 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
11752 * @return {BasicForm} this
11754 setValues : function(values){
11755 if(values instanceof Array){ // array of objects
11756 for(var i = 0, len = values.length; i < len; i++){
11758 var f = this.findField(v.id);
11760 f.setValue(v.value);
11761 if(this.trackResetOnLoad){
11762 f.originalValue = f.getValue();
11766 }else{ // object hash
11769 if(typeof values[id] != 'function' && (field = this.findField(id))){
11771 if (field.setFromData &&
11772 field.valueField &&
11773 field.displayField &&
11774 // combos' with local stores can
11775 // be queried via setValue()
11776 // to set their value..
11777 (field.store && !field.store.isLocal)
11781 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
11782 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
11783 field.setFromData(sd);
11785 } else if(field.setFromData && (field.store && !field.store.isLocal)) {
11787 field.setFromData(values);
11790 field.setValue(values[id]);
11794 if(this.trackResetOnLoad){
11795 field.originalValue = field.getValue();
11801 //Roo.each(this.childForms || [], function (f) {
11802 // f.setValues(values);
11809 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
11810 * they are returned as an array.
11811 * @param {Boolean} asString
11814 getValues : function(asString){
11815 //if (this.childForms) {
11816 // copy values from the child forms
11817 // Roo.each(this.childForms, function (f) {
11818 // this.setValues(f.getValues());
11824 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
11825 if(asString === true){
11828 return Roo.urlDecode(fs);
11832 * Returns the fields in this form as an object with key/value pairs.
11833 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
11836 getFieldValues : function(with_hidden)
11838 var items = this.getItems();
11840 items.each(function(f){
11842 if (!f.getName()) {
11846 var v = f.getValue();
11848 if (f.inputType =='radio') {
11849 if (typeof(ret[f.getName()]) == 'undefined') {
11850 ret[f.getName()] = ''; // empty..
11853 if (!f.el.dom.checked) {
11857 v = f.el.dom.value;
11861 if(f.xtype == 'MoneyField'){
11862 ret[f.currencyName] = f.getCurrency();
11865 // not sure if this supported any more..
11866 if ((typeof(v) == 'object') && f.getRawValue) {
11867 v = f.getRawValue() ; // dates..
11869 // combo boxes where name != hiddenName...
11870 if (f.name !== false && f.name != '' && f.name != f.getName()) {
11871 ret[f.name] = f.getRawValue();
11873 ret[f.getName()] = v;
11880 * Clears all invalid messages in this form.
11881 * @return {BasicForm} this
11883 clearInvalid : function(){
11884 var items = this.getItems();
11886 items.each(function(f){
11894 * Resets this form.
11895 * @return {BasicForm} this
11897 reset : function(){
11898 var items = this.getItems();
11899 items.each(function(f){
11903 Roo.each(this.childForms || [], function (f) {
11911 getItems : function()
11913 var r=new Roo.util.MixedCollection(false, function(o){
11914 return o.id || (o.id = Roo.id());
11916 var iter = function(el) {
11923 Roo.each(el.items,function(e) {
11932 hideFields : function(items)
11934 Roo.each(items, function(i){
11936 var f = this.findField(i);
11947 showFields : function(items)
11949 Roo.each(items, function(i){
11951 var f = this.findField(i);
11964 Roo.apply(Roo.bootstrap.form.Form, {
11980 intervalID : false,
11986 if(this.isApplied){
11991 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
11992 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
11993 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
11994 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
11997 this.maskEl.top.enableDisplayMode("block");
11998 this.maskEl.left.enableDisplayMode("block");
11999 this.maskEl.bottom.enableDisplayMode("block");
12000 this.maskEl.right.enableDisplayMode("block");
12002 this.toolTip = new Roo.bootstrap.Tooltip({
12003 cls : 'roo-form-error-popover',
12005 'left' : ['r-l', [-2,0], 'right'],
12006 'right' : ['l-r', [2,0], 'left'],
12007 'bottom' : ['tl-bl', [0,2], 'top'],
12008 'top' : [ 'bl-tl', [0,-2], 'bottom']
12012 this.toolTip.render(Roo.get(document.body));
12014 this.toolTip.el.enableDisplayMode("block");
12016 Roo.get(document.body).on('click', function(){
12020 Roo.get(document.body).on('touchstart', function(){
12024 this.isApplied = true
12027 mask : function(form, target)
12031 this.target = target;
12033 if(!this.form.errorMask || !target.el){
12037 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
12039 Roo.log(scrollable);
12041 var ot = this.target.el.calcOffsetsTo(scrollable);
12043 var scrollTo = ot[1] - this.form.maskOffset;
12045 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
12047 scrollable.scrollTo('top', scrollTo);
12049 var box = this.target.el.getBox();
12051 var zIndex = Roo.bootstrap.Modal.zIndex++;
12054 this.maskEl.top.setStyle('position', 'absolute');
12055 this.maskEl.top.setStyle('z-index', zIndex);
12056 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
12057 this.maskEl.top.setLeft(0);
12058 this.maskEl.top.setTop(0);
12059 this.maskEl.top.show();
12061 this.maskEl.left.setStyle('position', 'absolute');
12062 this.maskEl.left.setStyle('z-index', zIndex);
12063 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
12064 this.maskEl.left.setLeft(0);
12065 this.maskEl.left.setTop(box.y - this.padding);
12066 this.maskEl.left.show();
12068 this.maskEl.bottom.setStyle('position', 'absolute');
12069 this.maskEl.bottom.setStyle('z-index', zIndex);
12070 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
12071 this.maskEl.bottom.setLeft(0);
12072 this.maskEl.bottom.setTop(box.bottom + this.padding);
12073 this.maskEl.bottom.show();
12075 this.maskEl.right.setStyle('position', 'absolute');
12076 this.maskEl.right.setStyle('z-index', zIndex);
12077 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
12078 this.maskEl.right.setLeft(box.right + this.padding);
12079 this.maskEl.right.setTop(box.y - this.padding);
12080 this.maskEl.right.show();
12082 this.toolTip.bindEl = this.target.el;
12084 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
12086 var tip = this.target.blankText;
12088 if(this.target.getValue() !== '' ) {
12090 if (this.target.invalidText.length) {
12091 tip = this.target.invalidText;
12092 } else if (this.target.regexText.length){
12093 tip = this.target.regexText;
12097 this.toolTip.show(tip);
12099 this.intervalID = window.setInterval(function() {
12100 Roo.bootstrap.form.Form.popover.unmask();
12103 window.onwheel = function(){ return false;};
12105 (function(){ this.isMasked = true; }).defer(500, this);
12109 unmask : function()
12111 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
12115 this.maskEl.top.setStyle('position', 'absolute');
12116 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
12117 this.maskEl.top.hide();
12119 this.maskEl.left.setStyle('position', 'absolute');
12120 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
12121 this.maskEl.left.hide();
12123 this.maskEl.bottom.setStyle('position', 'absolute');
12124 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
12125 this.maskEl.bottom.hide();
12127 this.maskEl.right.setStyle('position', 'absolute');
12128 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
12129 this.maskEl.right.hide();
12131 this.toolTip.hide();
12133 this.toolTip.el.hide();
12135 window.onwheel = function(){ return true;};
12137 if(this.intervalID){
12138 window.clearInterval(this.intervalID);
12139 this.intervalID = false;
12142 this.isMasked = false;
12152 * Ext JS Library 1.1.1
12153 * Copyright(c) 2006-2007, Ext JS, LLC.
12155 * Originally Released Under LGPL - original licence link has changed is not relivant.
12158 * <script type="text/javascript">
12161 * @class Roo.form.VTypes
12162 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
12165 Roo.form.VTypes = function(){
12166 // closure these in so they are only created once.
12167 var alpha = /^[a-zA-Z_]+$/;
12168 var alphanum = /^[a-zA-Z0-9_]+$/;
12169 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
12170 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
12172 // All these messages and functions are configurable
12175 * The function used to validate email addresses
12176 * @param {String} value The email address
12178 'email' : function(v){
12179 return email.test(v);
12182 * The error text to display when the email validation function returns false
12185 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
12187 * The keystroke filter mask to be applied on email input
12190 'emailMask' : /[a-z0-9_\.\-@]/i,
12193 * The function used to validate URLs
12194 * @param {String} value The URL
12196 'url' : function(v){
12197 return url.test(v);
12200 * The error text to display when the url validation function returns false
12203 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
12206 * The function used to validate alpha values
12207 * @param {String} value The value
12209 'alpha' : function(v){
12210 return alpha.test(v);
12213 * The error text to display when the alpha validation function returns false
12216 'alphaText' : 'This field should only contain letters and _',
12218 * The keystroke filter mask to be applied on alpha input
12221 'alphaMask' : /[a-z_]/i,
12224 * The function used to validate alphanumeric values
12225 * @param {String} value The value
12227 'alphanum' : function(v){
12228 return alphanum.test(v);
12231 * The error text to display when the alphanumeric validation function returns false
12234 'alphanumText' : 'This field should only contain letters, numbers and _',
12236 * The keystroke filter mask to be applied on alphanumeric input
12239 'alphanumMask' : /[a-z0-9_]/i
12249 * @class Roo.bootstrap.form.Input
12250 * @extends Roo.bootstrap.Component
12251 * Bootstrap Input class
12252 * @cfg {Boolean} disabled is it disabled
12253 * @cfg {String} inputType (button|checkbox|email|file|hidden|image|number|password|radio|range|reset|search|submit|text)
12254 * @cfg {String} name name of the input
12255 * @cfg {string} fieldLabel - the label associated
12256 * @cfg {string} placeholder - placeholder to put in text.
12257 * @cfg {string} before - input group add on before
12258 * @cfg {string} after - input group add on after
12259 * @cfg {string} size - (lg|sm) or leave empty..
12260 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
12261 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
12262 * @cfg {Number} md colspan out of 12 for computer-sized screens
12263 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
12264 * @cfg {string} value default value of the input
12265 * @cfg {Number} labelWidth set the width of label
12266 * @cfg {Number} labellg set the width of label (1-12)
12267 * @cfg {Number} labelmd set the width of label (1-12)
12268 * @cfg {Number} labelsm set the width of label (1-12)
12269 * @cfg {Number} labelxs set the width of label (1-12)
12270 * @cfg {String} labelAlign (top|left)
12271 * @cfg {Boolean} readOnly Specifies that the field should be read-only
12272 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
12273 * @cfg {String} indicatorpos (left|right) default left
12274 * @cfg {String} capture (user|camera) use for file input only. (default empty)
12275 * @cfg {String} accept (image|video|audio) use for file input only. (default empty)
12276 * @cfg {Boolean} preventMark Do not show tick or cross if error/success
12277 * @cfg {Roo.bootstrap.Button} before Button to show before
12278 * @cfg {Roo.bootstrap.Button} afterButton to show before
12279 * @cfg {String} align (left|center|right) Default left
12280 * @cfg {Boolean} forceFeedback (true|false) Default false
12283 * Create a new Input
12284 * @param {Object} config The config object
12287 Roo.bootstrap.form.Input = function(config){
12289 Roo.bootstrap.form.Input.superclass.constructor.call(this, config);
12294 * Fires when this field receives input focus.
12295 * @param {Roo.form.Field} this
12300 * Fires when this field loses input focus.
12301 * @param {Roo.form.Field} this
12305 * @event specialkey
12306 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
12307 * {@link Roo.EventObject#getKey} to determine which key was pressed.
12308 * @param {Roo.form.Field} this
12309 * @param {Roo.EventObject} e The event object
12314 * Fires just before the field blurs if the field value has changed.
12315 * @param {Roo.form.Field} this
12316 * @param {Mixed} newValue The new value
12317 * @param {Mixed} oldValue The original value
12322 * Fires after the field has been marked as invalid.
12323 * @param {Roo.form.Field} this
12324 * @param {String} msg The validation message
12329 * Fires after the field has been validated with no errors.
12330 * @param {Roo.form.Field} this
12335 * Fires after the key up
12336 * @param {Roo.form.Field} this
12337 * @param {Roo.EventObject} e The event Object
12342 * Fires after the user pastes into input
12343 * @param {Roo.form.Field} this
12344 * @param {Roo.EventObject} e The event Object
12350 Roo.extend(Roo.bootstrap.form.Input, Roo.bootstrap.Component, {
12352 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
12353 automatic validation (defaults to "keyup").
12355 validationEvent : "keyup",
12357 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
12359 validateOnBlur : true,
12361 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
12363 validationDelay : 250,
12365 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
12367 focusClass : "x-form-focus", // not needed???
12371 * @cfg {String} invalidClass DEPRICATED - code uses BS4 - is-valid / is-invalid
12373 invalidClass : "has-warning",
12376 * @cfg {String} validClass DEPRICATED - code uses BS4 - is-valid / is-invalid
12378 validClass : "has-success",
12381 * @cfg {Boolean} hasFeedback (true|false) default true
12383 hasFeedback : true,
12386 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
12388 invalidFeedbackClass : "glyphicon-warning-sign",
12391 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
12393 validFeedbackClass : "glyphicon-ok",
12396 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
12398 selectOnFocus : false,
12401 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
12405 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
12410 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
12412 disableKeyFilter : false,
12415 * @cfg {Boolean} disabled True to disable the field (defaults to false).
12419 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
12423 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
12425 blankText : "Please complete this mandatory field",
12428 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
12432 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
12434 maxLength : Number.MAX_VALUE,
12436 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
12438 minLengthText : "The minimum length for this field is {0}",
12440 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
12442 maxLengthText : "The maximum length for this field is {0}",
12446 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
12447 * If available, this function will be called only after the basic validators all return true, and will be passed the
12448 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
12452 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
12453 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
12454 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
12458 * @cfg {String} regexText -- Depricated - use Invalid Text
12463 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
12469 autocomplete: false,
12473 inputType : 'text',
12476 placeholder: false,
12481 preventMark: false,
12482 isFormField : true,
12485 labelAlign : false,
12488 formatedValue : false,
12489 forceFeedback : false,
12491 indicatorpos : 'left',
12501 parentLabelAlign : function()
12504 while (parent.parent()) {
12505 parent = parent.parent();
12506 if (typeof(parent.labelAlign) !='undefined') {
12507 return parent.labelAlign;
12514 getAutoCreate : function()
12516 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
12522 if(this.inputType != 'hidden'){
12523 cfg.cls = 'form-group' //input-group
12529 type : this.inputType,
12530 value : this.value,
12531 cls : 'form-control',
12532 placeholder : this.placeholder || '',
12533 autocomplete : this.autocomplete || 'new-password'
12535 if (this.inputType == 'file') {
12536 input.style = 'overflow:hidden'; // why not in CSS?
12539 if(this.capture.length){
12540 input.capture = this.capture;
12543 if(this.accept.length){
12544 input.accept = this.accept + "/*";
12548 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
12551 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
12552 input.maxLength = this.maxLength;
12555 if (this.disabled) {
12556 input.disabled=true;
12559 if (this.readOnly) {
12560 input.readonly=true;
12564 input.name = this.name;
12568 input.cls += ' input-' + this.size;
12572 ['xs','sm','md','lg'].map(function(size){
12573 if (settings[size]) {
12574 cfg.cls += ' col-' + size + '-' + settings[size];
12578 var inputblock = input;
12582 cls: 'glyphicon form-control-feedback'
12585 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
12588 cls : 'has-feedback',
12596 if (this.before || this.after) {
12599 cls : 'input-group',
12603 if (this.before && typeof(this.before) == 'string') {
12605 inputblock.cn.push({
12607 cls : 'roo-input-before input-group-addon input-group-prepend input-group-text',
12611 if (this.before && typeof(this.before) == 'object') {
12612 this.before = Roo.factory(this.before);
12614 inputblock.cn.push({
12616 cls : 'roo-input-before input-group-prepend input-group-' +
12617 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
12621 inputblock.cn.push(input);
12623 if (this.after && typeof(this.after) == 'string') {
12624 inputblock.cn.push({
12626 cls : 'roo-input-after input-group-append input-group-text input-group-addon',
12630 if (this.after && typeof(this.after) == 'object') {
12631 this.after = Roo.factory(this.after);
12633 inputblock.cn.push({
12635 cls : 'roo-input-after input-group-append input-group-' +
12636 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
12640 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
12641 inputblock.cls += ' has-feedback';
12642 inputblock.cn.push(feedback);
12647 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
12648 tooltip : 'This field is required'
12650 if (this.allowBlank ) {
12651 indicator.style = this.allowBlank ? ' display:none' : '';
12653 if (align ==='left' && this.fieldLabel.length) {
12655 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
12662 cls : 'control-label col-form-label',
12663 html : this.fieldLabel
12674 var labelCfg = cfg.cn[1];
12675 var contentCfg = cfg.cn[2];
12677 if(this.indicatorpos == 'right'){
12682 cls : 'control-label col-form-label',
12686 html : this.fieldLabel
12700 labelCfg = cfg.cn[0];
12701 contentCfg = cfg.cn[1];
12705 if(this.labelWidth > 12){
12706 labelCfg.style = "width: " + this.labelWidth + 'px';
12709 if(this.labelWidth < 13 && this.labelmd == 0){
12710 this.labellg = this.labellg > 0 ? this.labellg : this.labelWidth;
12713 if(this.labellg > 0){
12714 labelCfg.cls += ' col-lg-' + this.labellg;
12715 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
12718 if(this.labelmd > 0){
12719 labelCfg.cls += ' col-md-' + this.labelmd;
12720 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
12723 if(this.labelsm > 0){
12724 labelCfg.cls += ' col-sm-' + this.labelsm;
12725 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
12728 if(this.labelxs > 0){
12729 labelCfg.cls += ' col-xs-' + this.labelxs;
12730 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
12734 } else if ( this.fieldLabel.length) {
12741 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
12742 tooltip : 'This field is required',
12743 style : this.allowBlank ? ' display:none' : ''
12747 //cls : 'input-group-addon',
12748 html : this.fieldLabel
12756 if(this.indicatorpos == 'right'){
12761 //cls : 'input-group-addon',
12762 html : this.fieldLabel
12767 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
12768 tooltip : 'This field is required',
12769 style : this.allowBlank ? ' display:none' : ''
12789 if (this.parentType === 'Navbar' && this.parent().bar) {
12790 cfg.cls += ' navbar-form';
12793 if (this.parentType === 'NavGroup' && !(Roo.bootstrap.version == 4 && this.parent().form)) {
12794 // on BS4 we do this only if not form
12795 cfg.cls += ' navbar-form';
12803 * return the real input element.
12805 inputEl: function ()
12807 return this.el.select('input.form-control',true).first();
12810 tooltipEl : function()
12812 return this.inputEl();
12815 indicatorEl : function()
12817 if (Roo.bootstrap.version == 4) {
12818 return false; // not enabled in v4 yet.
12821 var indicator = this.el.select('i.roo-required-indicator',true).first();
12831 setDisabled : function(v)
12833 var i = this.inputEl().dom;
12835 i.removeAttribute('disabled');
12839 i.setAttribute('disabled','true');
12841 initEvents : function()
12844 this.inputEl().on("keydown" , this.fireKey, this);
12845 this.inputEl().on("focus", this.onFocus, this);
12846 this.inputEl().on("blur", this.onBlur, this);
12848 this.inputEl().relayEvent('keyup', this);
12849 this.inputEl().relayEvent('paste', this);
12851 this.indicator = this.indicatorEl();
12853 if(this.indicator){
12854 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible'); // changed from invisible??? -
12857 // reference to original value for reset
12858 this.originalValue = this.getValue();
12859 //Roo.form.TextField.superclass.initEvents.call(this);
12860 if(this.validationEvent == 'keyup'){
12861 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
12862 this.inputEl().on('keyup', this.filterValidation, this);
12864 else if(this.validationEvent !== false){
12865 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
12868 if(this.selectOnFocus){
12869 this.on("focus", this.preFocus, this);
12872 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
12873 this.inputEl().on("keypress", this.filterKeys, this);
12875 this.inputEl().relayEvent('keypress', this);
12878 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
12879 this.el.on("click", this.autoSize, this);
12882 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
12883 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
12886 if (typeof(this.before) == 'object') {
12887 this.before.render(this.el.select('.roo-input-before',true).first());
12889 if (typeof(this.after) == 'object') {
12890 this.after.render(this.el.select('.roo-input-after',true).first());
12893 this.inputEl().on('change', this.onChange, this);
12896 filterValidation : function(e){
12897 if(!e.isNavKeyPress()){
12898 this.validationTask.delay(this.validationDelay);
12902 * Validates the field value
12903 * @return {Boolean} True if the value is valid, else false
12905 validate : function(){
12906 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
12907 if(this.disabled || this.validateValue(this.getRawValue())){
12912 this.markInvalid();
12918 * Validates a value according to the field's validation rules and marks the field as invalid
12919 * if the validation fails
12920 * @param {Mixed} value The value to validate
12921 * @return {Boolean} True if the value is valid, else false
12923 validateValue : function(value)
12925 if(this.getVisibilityEl().hasClass('hidden')){
12929 if(value.length < 1) { // if it's blank
12930 if(this.allowBlank){
12936 if(value.length < this.minLength){
12939 if(value.length > this.maxLength){
12943 var vt = Roo.form.VTypes;
12944 if(!vt[this.vtype](value, this)){
12948 if(typeof this.validator == "function"){
12949 var msg = this.validator(value);
12953 if (typeof(msg) == 'string') {
12954 this.invalidText = msg;
12958 if(this.regex && !this.regex.test(value)){
12966 fireKey : function(e){
12967 //Roo.log('field ' + e.getKey());
12968 if(e.isNavKeyPress()){
12969 this.fireEvent("specialkey", this, e);
12972 focus : function (selectText){
12974 this.inputEl().focus();
12975 if(selectText === true){
12976 this.inputEl().dom.select();
12982 onFocus : function(){
12983 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
12984 // this.el.addClass(this.focusClass);
12986 if(!this.hasFocus){
12987 this.hasFocus = true;
12988 this.startValue = this.getValue();
12989 this.fireEvent("focus", this);
12993 beforeBlur : Roo.emptyFn,
12997 onBlur : function(){
12999 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
13000 //this.el.removeClass(this.focusClass);
13002 this.hasFocus = false;
13003 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
13006 var v = this.getValue();
13007 if(String(v) !== String(this.startValue)){
13008 this.fireEvent('change', this, v, this.startValue);
13010 this.fireEvent("blur", this);
13013 onChange : function(e)
13015 var v = this.getValue();
13016 if(String(v) !== String(this.startValue)){
13017 this.fireEvent('change', this, v, this.startValue);
13023 * Resets the current field value to the originally loaded value and clears any validation messages
13025 reset : function(){
13026 this.setValue(this.originalValue);
13030 * Returns the name of the field
13031 * @return {Mixed} name The name field
13033 getName: function(){
13037 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
13038 * @return {Mixed} value The field value
13040 getValue : function(){
13042 var v = this.inputEl().getValue();
13047 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
13048 * @return {Mixed} value The field value
13050 getRawValue : function(){
13051 var v = this.inputEl().getValue();
13057 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
13058 * @param {Mixed} value The value to set
13060 setRawValue : function(v){
13061 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
13064 selectText : function(start, end){
13065 var v = this.getRawValue();
13067 start = start === undefined ? 0 : start;
13068 end = end === undefined ? v.length : end;
13069 var d = this.inputEl().dom;
13070 if(d.setSelectionRange){
13071 d.setSelectionRange(start, end);
13072 }else if(d.createTextRange){
13073 var range = d.createTextRange();
13074 range.moveStart("character", start);
13075 range.moveEnd("character", v.length-end);
13082 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
13083 * @param {Mixed} value The value to set
13085 setValue : function(v){
13088 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
13094 processValue : function(value){
13095 if(this.stripCharsRe){
13096 var newValue = value.replace(this.stripCharsRe, '');
13097 if(newValue !== value){
13098 this.setRawValue(newValue);
13105 preFocus : function(){
13107 if(this.selectOnFocus){
13108 this.inputEl().dom.select();
13111 filterKeys : function(e){
13112 var k = e.getKey();
13113 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
13116 var c = e.getCharCode(), cc = String.fromCharCode(c);
13117 if(Roo.isIE && (e.isSpecialKey() || !cc)){
13120 if(!this.maskRe.test(cc)){
13125 * Clear any invalid styles/messages for this field
13127 clearInvalid : function(){
13129 if(!this.el || this.preventMark){ // not rendered
13134 this.el.removeClass([this.invalidClass, 'is-invalid']);
13136 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
13138 var feedback = this.el.select('.form-control-feedback', true).first();
13141 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
13146 if(this.indicator){
13147 this.indicator.removeClass('visible');
13148 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
13151 this.fireEvent('valid', this);
13155 * Mark this field as valid
13157 markValid : function()
13159 if(!this.el || this.preventMark){ // not rendered...
13163 this.el.removeClass([this.invalidClass, this.validClass]);
13164 this.inputEl().removeClass(['is-valid', 'is-invalid']);
13166 var feedback = this.el.select('.form-control-feedback', true).first();
13169 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13172 if(this.indicator){
13173 this.indicator.removeClass('visible');
13174 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
13182 if(this.allowBlank && !this.getRawValue().length){
13185 if (Roo.bootstrap.version == 3) {
13186 this.el.addClass(this.validClass);
13188 this.inputEl().addClass('is-valid');
13191 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
13193 var feedback = this.el.select('.form-control-feedback', true).first();
13196 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13197 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
13202 this.fireEvent('valid', this);
13206 * Mark this field as invalid
13207 * @param {String} msg The validation message
13209 markInvalid : function(msg)
13211 if(!this.el || this.preventMark){ // not rendered
13215 this.el.removeClass([this.invalidClass, this.validClass]);
13216 this.inputEl().removeClass(['is-valid', 'is-invalid']);
13218 var feedback = this.el.select('.form-control-feedback', true).first();
13221 this.el.select('.form-control-feedback', true).first().removeClass(
13222 [this.invalidFeedbackClass, this.validFeedbackClass]);
13229 if(this.allowBlank && !this.getRawValue().length){
13233 if(this.indicator){
13234 this.indicator.removeClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
13235 this.indicator.addClass('visible');
13237 if (Roo.bootstrap.version == 3) {
13238 this.el.addClass(this.invalidClass);
13240 this.inputEl().addClass('is-invalid');
13245 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
13247 var feedback = this.el.select('.form-control-feedback', true).first();
13250 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13252 if(this.getValue().length || this.forceFeedback){
13253 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
13260 this.fireEvent('invalid', this, msg);
13263 SafariOnKeyDown : function(event)
13265 // this is a workaround for a password hang bug on chrome/ webkit.
13266 if (this.inputEl().dom.type != 'password') {
13270 var isSelectAll = false;
13272 if(this.inputEl().dom.selectionEnd > 0){
13273 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
13275 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
13276 event.preventDefault();
13281 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
13283 event.preventDefault();
13284 // this is very hacky as keydown always get's upper case.
13286 var cc = String.fromCharCode(event.getCharCode());
13287 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
13291 adjustWidth : function(tag, w){
13292 tag = tag.toLowerCase();
13293 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
13294 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
13295 if(tag == 'input'){
13298 if(tag == 'textarea'){
13301 }else if(Roo.isOpera){
13302 if(tag == 'input'){
13305 if(tag == 'textarea'){
13313 setFieldLabel : function(v)
13315 if(!this.rendered){
13319 if(this.indicatorEl()){
13320 var ar = this.el.select('label > span',true);
13322 if (ar.elements.length) {
13323 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
13324 this.fieldLabel = v;
13328 var br = this.el.select('label',true);
13330 if(br.elements.length) {
13331 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
13332 this.fieldLabel = v;
13336 Roo.log('Cannot Found any of label > span || label in input');
13340 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
13341 this.fieldLabel = v;
13356 * @class Roo.bootstrap.form.TextArea
13357 * @extends Roo.bootstrap.form.Input
13358 * Bootstrap TextArea class
13359 * @cfg {Number} cols Specifies the visible width of a text area
13360 * @cfg {Number} rows Specifies the visible number of lines in a text area
13361 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
13362 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
13363 * @cfg {string} html text
13366 * Create a new TextArea
13367 * @param {Object} config The config object
13370 Roo.bootstrap.form.TextArea = function(config){
13371 Roo.bootstrap.form.TextArea.superclass.constructor.call(this, config);
13375 Roo.extend(Roo.bootstrap.form.TextArea, Roo.bootstrap.form.Input, {
13385 getAutoCreate : function(){
13387 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
13393 if(this.inputType != 'hidden'){
13394 cfg.cls = 'form-group' //input-group
13402 value : this.value || '',
13403 html: this.html || '',
13404 cls : 'form-control',
13405 placeholder : this.placeholder || ''
13409 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
13410 input.maxLength = this.maxLength;
13414 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
13418 input.cols = this.cols;
13421 if (this.readOnly) {
13422 input.readonly = true;
13426 input.name = this.name;
13430 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
13434 ['xs','sm','md','lg'].map(function(size){
13435 if (settings[size]) {
13436 cfg.cls += ' col-' + size + '-' + settings[size];
13440 var inputblock = input;
13442 if(this.hasFeedback && !this.allowBlank){
13446 cls: 'glyphicon form-control-feedback'
13450 cls : 'has-feedback',
13459 if (this.before || this.after) {
13462 cls : 'input-group',
13466 inputblock.cn.push({
13468 cls : 'input-group-addon',
13473 inputblock.cn.push(input);
13475 if(this.hasFeedback && !this.allowBlank){
13476 inputblock.cls += ' has-feedback';
13477 inputblock.cn.push(feedback);
13481 inputblock.cn.push({
13483 cls : 'input-group-addon',
13490 if (align ==='left' && this.fieldLabel.length) {
13495 cls : 'control-label',
13496 html : this.fieldLabel
13507 if(this.labelWidth > 12){
13508 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
13511 if(this.labelWidth < 13 && this.labelmd == 0){
13512 this.labelmd = this.labelWidth;
13515 if(this.labellg > 0){
13516 cfg.cn[0].cls += ' col-lg-' + this.labellg;
13517 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
13520 if(this.labelmd > 0){
13521 cfg.cn[0].cls += ' col-md-' + this.labelmd;
13522 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
13525 if(this.labelsm > 0){
13526 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
13527 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
13530 if(this.labelxs > 0){
13531 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
13532 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
13535 } else if ( this.fieldLabel.length) {
13540 //cls : 'input-group-addon',
13541 html : this.fieldLabel
13559 if (this.disabled) {
13560 input.disabled=true;
13567 * return the real textarea element.
13569 inputEl: function ()
13571 return this.el.select('textarea.form-control',true).first();
13575 * Clear any invalid styles/messages for this field
13577 clearInvalid : function()
13580 if(!this.el || this.preventMark){ // not rendered
13584 var label = this.el.select('label', true).first();
13585 var icon = this.el.select('i.fa-star', true).first();
13590 this.el.removeClass( this.validClass);
13591 this.inputEl().removeClass('is-invalid');
13593 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
13595 var feedback = this.el.select('.form-control-feedback', true).first();
13598 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
13603 this.fireEvent('valid', this);
13607 * Mark this field as valid
13609 markValid : function()
13611 if(!this.el || this.preventMark){ // not rendered
13615 this.el.removeClass([this.invalidClass, this.validClass]);
13616 this.inputEl().removeClass(['is-valid', 'is-invalid']);
13618 var feedback = this.el.select('.form-control-feedback', true).first();
13621 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13624 if(this.disabled || this.allowBlank){
13628 var label = this.el.select('label', true).first();
13629 var icon = this.el.select('i.fa-star', true).first();
13634 if (Roo.bootstrap.version == 3) {
13635 this.el.addClass(this.validClass);
13637 this.inputEl().addClass('is-valid');
13641 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
13643 var feedback = this.el.select('.form-control-feedback', true).first();
13646 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13647 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
13652 this.fireEvent('valid', this);
13656 * Mark this field as invalid
13657 * @param {String} msg The validation message
13659 markInvalid : function(msg)
13661 if(!this.el || this.preventMark){ // not rendered
13665 this.el.removeClass([this.invalidClass, this.validClass]);
13666 this.inputEl().removeClass(['is-valid', 'is-invalid']);
13668 var feedback = this.el.select('.form-control-feedback', true).first();
13671 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13674 if(this.disabled || this.allowBlank){
13678 var label = this.el.select('label', true).first();
13679 var icon = this.el.select('i.fa-star', true).first();
13681 if(!this.getValue().length && label && !icon){
13682 this.el.createChild({
13684 cls : 'text-danger fa fa-lg fa-star',
13685 tooltip : 'This field is required',
13686 style : 'margin-right:5px;'
13690 if (Roo.bootstrap.version == 3) {
13691 this.el.addClass(this.invalidClass);
13693 this.inputEl().addClass('is-invalid');
13696 // fixme ... this may be depricated need to test..
13697 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
13699 var feedback = this.el.select('.form-control-feedback', true).first();
13702 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
13704 if(this.getValue().length || this.forceFeedback){
13705 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
13712 this.fireEvent('invalid', this, msg);
13720 * trigger field - base class for combo..
13725 * @class Roo.bootstrap.form.TriggerField
13726 * @extends Roo.bootstrap.form.Input
13727 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
13728 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
13729 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
13730 * for which you can provide a custom implementation. For example:
13732 var trigger = new Roo.bootstrap.form.TriggerField();
13733 trigger.onTriggerClick = myTriggerFn;
13734 trigger.applyTo('my-field');
13737 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
13738 * {@link Roo.bootstrap.form.DateField} and {@link Roo.bootstrap.form.ComboBox} are perfect examples of this.
13739 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
13740 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
13741 * @cfg {String} caret (search|calendar) BS3 only - carat fa name
13744 * Create a new TriggerField.
13745 * @param {Object} config Configuration options (valid {@Roo.bootstrap.form.Input} config options will also be applied
13746 * to the base TextField)
13748 Roo.bootstrap.form.TriggerField = function(config){
13749 this.mimicing = false;
13750 Roo.bootstrap.form.TriggerField.superclass.constructor.call(this, config);
13753 Roo.extend(Roo.bootstrap.form.TriggerField, Roo.bootstrap.form.Input, {
13755 * @cfg {String} triggerClass A CSS class to apply to the trigger
13758 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
13763 * @cfg {Boolean} removable (true|false) special filter default false
13767 /** @cfg {Boolean} grow @hide */
13768 /** @cfg {Number} growMin @hide */
13769 /** @cfg {Number} growMax @hide */
13775 autoSize: Roo.emptyFn,
13779 deferHeight : true,
13782 actionMode : 'wrap',
13787 getAutoCreate : function(){
13789 var align = this.labelAlign || this.parentLabelAlign();
13794 cls: 'form-group' //input-group
13801 type : this.inputType,
13802 cls : 'form-control',
13803 autocomplete: 'new-password',
13804 placeholder : this.placeholder || ''
13808 input.name = this.name;
13811 input.cls += ' input-' + this.size;
13814 if (this.disabled) {
13815 input.disabled=true;
13818 var inputblock = input;
13820 if(this.hasFeedback && !this.allowBlank){
13824 cls: 'glyphicon form-control-feedback'
13827 if(this.removable && !this.editable ){
13829 cls : 'has-feedback',
13835 cls : 'roo-combo-removable-btn close'
13842 cls : 'has-feedback',
13851 if(this.removable && !this.editable ){
13853 cls : 'roo-removable',
13859 cls : 'roo-combo-removable-btn close'
13866 if (this.before || this.after) {
13869 cls : 'input-group',
13873 inputblock.cn.push({
13875 cls : 'input-group-addon input-group-prepend input-group-text',
13880 inputblock.cn.push(input);
13882 if(this.hasFeedback && !this.allowBlank){
13883 inputblock.cls += ' has-feedback';
13884 inputblock.cn.push(feedback);
13888 inputblock.cn.push({
13890 cls : 'input-group-addon input-group-append input-group-text',
13899 var ibwrap = inputblock;
13904 cls: 'roo-select2-choices',
13908 cls: 'roo-select2-search-field',
13920 cls: 'roo-select2-container input-group',
13925 cls: 'form-hidden-field'
13931 if(!this.multiple && this.showToggleBtn){
13937 if (this.caret != false) {
13940 cls: 'fa fa-' + this.caret
13947 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
13949 Roo.bootstrap.version == 3 ? caret : '',
13952 cls: 'combobox-clear',
13966 combobox.cls += ' roo-select2-container-multi';
13970 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
13971 tooltip : 'This field is required'
13973 if (Roo.bootstrap.version == 4) {
13976 style : 'display:none'
13981 if (align ==='left' && this.fieldLabel.length) {
13983 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
13990 cls : 'control-label',
13991 html : this.fieldLabel
14003 var labelCfg = cfg.cn[1];
14004 var contentCfg = cfg.cn[2];
14006 if(this.indicatorpos == 'right'){
14011 cls : 'control-label',
14015 html : this.fieldLabel
14029 labelCfg = cfg.cn[0];
14030 contentCfg = cfg.cn[1];
14033 if(this.labelWidth > 12){
14034 labelCfg.style = "width: " + this.labelWidth + 'px';
14037 if(this.labelWidth < 13 && this.labelmd == 0){
14038 this.labelmd = this.labelWidth;
14041 if(this.labellg > 0){
14042 labelCfg.cls += ' col-lg-' + this.labellg;
14043 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
14046 if(this.labelmd > 0){
14047 labelCfg.cls += ' col-md-' + this.labelmd;
14048 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
14051 if(this.labelsm > 0){
14052 labelCfg.cls += ' col-sm-' + this.labelsm;
14053 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
14056 if(this.labelxs > 0){
14057 labelCfg.cls += ' col-xs-' + this.labelxs;
14058 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
14061 } else if ( this.fieldLabel.length) {
14062 // Roo.log(" label");
14067 //cls : 'input-group-addon',
14068 html : this.fieldLabel
14076 if(this.indicatorpos == 'right'){
14084 html : this.fieldLabel
14098 // Roo.log(" no label && no align");
14105 ['xs','sm','md','lg'].map(function(size){
14106 if (settings[size]) {
14107 cfg.cls += ' col-' + size + '-' + settings[size];
14118 onResize : function(w, h){
14119 // Roo.bootstrap.form.TriggerField.superclass.onResize.apply(this, arguments);
14120 // if(typeof w == 'number'){
14121 // var x = w - this.trigger.getWidth();
14122 // this.inputEl().setWidth(this.adjustWidth('input', x));
14123 // this.trigger.setStyle('left', x+'px');
14128 adjustSize : Roo.BoxComponent.prototype.adjustSize,
14131 getResizeEl : function(){
14132 return this.inputEl();
14136 getPositionEl : function(){
14137 return this.inputEl();
14141 alignErrorIcon : function(){
14142 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
14146 initEvents : function(){
14150 Roo.bootstrap.form.TriggerField.superclass.initEvents.call(this);
14151 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
14152 if(!this.multiple && this.showToggleBtn){
14153 this.trigger = this.el.select('span.dropdown-toggle',true).first();
14154 if(this.hideTrigger){
14155 this.trigger.setDisplayed(false);
14157 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
14161 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
14164 if(this.removable && !this.editable && !this.tickable){
14165 var close = this.closeTriggerEl();
14168 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
14169 close.on('click', this.removeBtnClick, this, close);
14173 //this.trigger.addClassOnOver('x-form-trigger-over');
14174 //this.trigger.addClassOnClick('x-form-trigger-click');
14177 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
14181 closeTriggerEl : function()
14183 var close = this.el.select('.roo-combo-removable-btn', true).first();
14184 return close ? close : false;
14187 removeBtnClick : function(e, h, el)
14189 e.preventDefault();
14191 if(this.fireEvent("remove", this) !== false){
14193 this.fireEvent("afterremove", this)
14197 createList : function()
14199 this.list = Roo.get(document.body).createChild({
14200 tag: Roo.bootstrap.version == 4 ? 'div' : 'ul',
14201 cls: 'typeahead typeahead-long dropdown-menu shadow',
14202 style: 'display:none'
14205 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
14210 initTrigger : function(){
14215 onDestroy : function(){
14217 this.trigger.removeAllListeners();
14218 // this.trigger.remove();
14221 // this.wrap.remove();
14223 Roo.bootstrap.form.TriggerField.superclass.onDestroy.call(this);
14227 onFocus : function(){
14228 Roo.bootstrap.form.TriggerField.superclass.onFocus.call(this);
14230 if(!this.mimicing){
14231 this.wrap.addClass('x-trigger-wrap-focus');
14232 this.mimicing = true;
14233 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
14234 if(this.monitorTab){
14235 this.el.on("keydown", this.checkTab, this);
14242 checkTab : function(e){
14243 if(e.getKey() == e.TAB){
14244 this.triggerBlur();
14249 onBlur : function(){
14254 mimicBlur : function(e, t){
14256 if(!this.wrap.contains(t) && this.validateBlur()){
14257 this.triggerBlur();
14263 triggerBlur : function(){
14264 this.mimicing = false;
14265 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
14266 if(this.monitorTab){
14267 this.el.un("keydown", this.checkTab, this);
14269 //this.wrap.removeClass('x-trigger-wrap-focus');
14270 Roo.bootstrap.form.TriggerField.superclass.onBlur.call(this);
14274 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
14275 validateBlur : function(e, t){
14280 onDisable : function(){
14281 this.inputEl().dom.disabled = true;
14282 //Roo.bootstrap.form.TriggerField.superclass.onDisable.call(this);
14284 // this.wrap.addClass('x-item-disabled');
14289 onEnable : function(){
14290 this.inputEl().dom.disabled = false;
14291 //Roo.bootstrap.form.TriggerField.superclass.onEnable.call(this);
14293 // this.el.removeClass('x-item-disabled');
14298 onShow : function(){
14299 var ae = this.getActionEl();
14302 ae.dom.style.display = '';
14303 ae.dom.style.visibility = 'visible';
14309 onHide : function(){
14310 var ae = this.getActionEl();
14311 ae.dom.style.display = 'none';
14315 * The function that should handle the trigger's click event. This method does nothing by default until overridden
14316 * by an implementing function.
14318 * @param {EventObject} e
14320 onTriggerClick : Roo.emptyFn
14328 * @class Roo.bootstrap.form.CardUploader
14329 * @extends Roo.bootstrap.Button
14330 * Bootstrap Card Uploader class - it's a button which when you add files to it, adds cards below with preview and the name...
14331 * @cfg {Number} errorTimeout default 3000
14332 * @cfg {Array} images an array of ?? Img objects ??? when loading existing files..
14333 * @cfg {Array} html The button text.
14337 * Create a new CardUploader
14338 * @param {Object} config The config object
14341 Roo.bootstrap.form.CardUploader = function(config){
14345 Roo.bootstrap.form.CardUploader.superclass.constructor.call(this, config);
14348 this.fileCollection = new Roo.util.MixedCollection(false,function(r) {
14356 * When a image is clicked on - and needs to display a slideshow or similar..
14357 * @param {Roo.bootstrap.Card} this
14358 * @param {Object} The image information data
14364 * When a the download link is clicked
14365 * @param {Roo.bootstrap.Card} this
14366 * @param {Object} The image information data contains
14373 Roo.extend(Roo.bootstrap.form.CardUploader, Roo.bootstrap.form.Input, {
14376 errorTimeout : 3000,
14380 fileCollection : false,
14383 getAutoCreate : function()
14387 cls :'form-group' ,
14392 //cls : 'input-group-addon',
14393 html : this.fieldLabel
14401 value : this.value,
14402 cls : 'd-none form-control'
14407 multiple : 'multiple',
14409 cls : 'd-none roo-card-upload-selector'
14413 cls : 'roo-card-uploader-button-container w-100 mb-2'
14416 cls : 'card-columns roo-card-uploader-container'
14426 getChildContainer : function() /// what children are added to.
14428 return this.containerEl;
14431 getButtonContainer : function() /// what children are added to.
14433 return this.el.select(".roo-card-uploader-button-container").first();
14436 initEvents : function()
14439 Roo.bootstrap.form.Input.prototype.initEvents.call(this);
14443 xns: Roo.bootstrap,
14446 container_method : 'getButtonContainer' ,
14447 html : this.html, // fix changable?
14450 'click' : function(btn, e) {
14459 this.urlAPI = (window.createObjectURL && window) ||
14460 (window.URL && URL.revokeObjectURL && URL) ||
14461 (window.webkitURL && webkitURL);
14466 this.selectorEl = this.el.select('.roo-card-upload-selector', true).first();
14468 this.selectorEl.on('change', this.onFileSelected, this);
14471 this.images.forEach(function(img) {
14474 this.images = false;
14476 this.containerEl = this.el.select('.roo-card-uploader-container', true).first();
14482 onClick : function(e)
14484 e.preventDefault();
14486 this.selectorEl.dom.click();
14490 onFileSelected : function(e)
14492 e.preventDefault();
14494 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
14498 Roo.each(this.selectorEl.dom.files, function(file){
14499 this.addFile(file);
14508 addFile : function(file)
14511 if(typeof(file) === 'string'){
14512 throw "Add file by name?"; // should not happen
14516 if(!file || !this.urlAPI){
14526 var url = _this.urlAPI.createObjectURL( file);
14529 id : Roo.bootstrap.form.CardUploader.ID--,
14530 is_uploaded : false,
14534 mimetype : file.type,
14542 * addCard - add an Attachment to the uploader
14543 * @param data - the data about the image to upload
14547 title : "Title of file",
14548 is_uploaded : false,
14549 src : "http://.....",
14550 srcfile : { the File upload object },
14551 mimetype : file.type,
14554 .. any other data...
14560 addCard : function (data)
14562 // hidden input element?
14563 // if the file is not an image...
14564 //then we need to use something other that and header_image
14569 xns : Roo.bootstrap,
14570 xtype : 'CardFooter',
14573 xns : Roo.bootstrap,
14579 xns : Roo.bootstrap,
14581 html : String.format("<small>{0}</small>", data.title),
14582 cls : 'col-10 text-left',
14587 click : function() {
14589 t.fireEvent( "download", t, data );
14595 xns : Roo.bootstrap,
14597 style: 'max-height: 28px; ',
14603 click : function() {
14604 t.removeCard(data.id)
14616 var cn = this.addxtype(
14619 xns : Roo.bootstrap,
14622 header : !data.mimetype.match(/image/) && !data.preview ? "Document": false,
14623 header_image : data.mimetype.match(/image/) ? data.src : data.preview,
14624 header_image_fit_square: true, // fixme - we probably need to use the 'Img' element to do stuff like this.
14629 initEvents : function() {
14630 Roo.bootstrap.Card.prototype.initEvents.call(this);
14632 this.imgEl = this.el.select('.card-img-top').first();
14634 this.imgEl.on('click', function() { t.fireEvent( "preview", t, data ); }, this);
14635 this.imgEl.set({ 'pointer' : 'cursor' });
14638 this.getCardFooter().addClass('p-1');
14645 // dont' really need ot update items.
14646 // this.items.push(cn);
14647 this.fileCollection.add(cn);
14649 if (!data.srcfile) {
14650 this.updateInput();
14655 var reader = new FileReader();
14656 reader.addEventListener("load", function() {
14657 data.srcdata = reader.result;
14660 reader.readAsDataURL(data.srcfile);
14665 removeCard : function(id)
14668 var card = this.fileCollection.get(id);
14669 card.data.is_deleted = 1;
14670 card.data.src = ''; /// delete the source - so it reduces size of not uploaded images etc.
14671 //this.fileCollection.remove(card);
14672 //this.items = this.items.filter(function(e) { return e != card });
14673 // dont' really need ot update items.
14674 card.el.dom.parentNode.removeChild(card.el.dom);
14675 this.updateInput();
14681 this.fileCollection.each(function(card) {
14682 if (card.el.dom && card.el.dom.parentNode) {
14683 card.el.dom.parentNode.removeChild(card.el.dom);
14686 this.fileCollection.clear();
14687 this.updateInput();
14690 updateInput : function()
14693 this.fileCollection.each(function(e) {
14697 this.inputEl().dom.value = JSON.stringify(data);
14707 Roo.bootstrap.form.CardUploader.ID = -1;/*
14709 * Ext JS Library 1.1.1
14710 * Copyright(c) 2006-2007, Ext JS, LLC.
14712 * Originally Released Under LGPL - original licence link has changed is not relivant.
14715 * <script type="text/javascript">
14720 * @class Roo.data.SortTypes
14722 * Defines the default sorting (casting?) comparison functions used when sorting data.
14724 Roo.data.SortTypes = {
14726 * Default sort that does nothing
14727 * @param {Mixed} s The value being converted
14728 * @return {Mixed} The comparison value
14730 none : function(s){
14735 * The regular expression used to strip tags
14739 stripTagsRE : /<\/?[^>]+>/gi,
14742 * Strips all HTML tags to sort on text only
14743 * @param {Mixed} s The value being converted
14744 * @return {String} The comparison value
14746 asText : function(s){
14747 return String(s).replace(this.stripTagsRE, "");
14751 * Strips all HTML tags to sort on text only - Case insensitive
14752 * @param {Mixed} s The value being converted
14753 * @return {String} The comparison value
14755 asUCText : function(s){
14756 return String(s).toUpperCase().replace(this.stripTagsRE, "");
14760 * Case insensitive string
14761 * @param {Mixed} s The value being converted
14762 * @return {String} The comparison value
14764 asUCString : function(s) {
14765 return String(s).toUpperCase();
14770 * @param {Mixed} s The value being converted
14771 * @return {Number} The comparison value
14773 asDate : function(s) {
14777 if(s instanceof Date){
14778 return s.getTime();
14780 return Date.parse(String(s));
14785 * @param {Mixed} s The value being converted
14786 * @return {Float} The comparison value
14788 asFloat : function(s) {
14789 var val = parseFloat(String(s).replace(/,/g, ""));
14798 * @param {Mixed} s The value being converted
14799 * @return {Number} The comparison value
14801 asInt : function(s) {
14802 var val = parseInt(String(s).replace(/,/g, ""));
14810 * Ext JS Library 1.1.1
14811 * Copyright(c) 2006-2007, Ext JS, LLC.
14813 * Originally Released Under LGPL - original licence link has changed is not relivant.
14816 * <script type="text/javascript">
14820 * @class Roo.data.Record
14821 * Instances of this class encapsulate both record <em>definition</em> information, and record
14822 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
14823 * to access Records cached in an {@link Roo.data.Store} object.<br>
14825 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
14826 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
14829 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
14831 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
14832 * {@link #create}. The parameters are the same.
14833 * @param {Array} data An associative Array of data values keyed by the field name.
14834 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
14835 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
14836 * not specified an integer id is generated.
14838 Roo.data.Record = function(data, id){
14839 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
14844 * Generate a constructor for a specific record layout.
14845 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
14846 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
14847 * Each field definition object may contain the following properties: <ul>
14848 * <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,
14849 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
14850 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
14851 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
14852 * is being used, then this is a string containing the javascript expression to reference the data relative to
14853 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
14854 * to the data item relative to the record element. If the mapping expression is the same as the field name,
14855 * this may be omitted.</p></li>
14856 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
14857 * <ul><li>auto (Default, implies no conversion)</li>
14862 * <li>date</li></ul></p></li>
14863 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
14864 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
14865 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
14866 * by the Reader into an object that will be stored in the Record. It is passed the
14867 * following parameters:<ul>
14868 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
14870 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
14872 * <br>usage:<br><pre><code>
14873 var TopicRecord = Roo.data.Record.create(
14874 {name: 'title', mapping: 'topic_title'},
14875 {name: 'author', mapping: 'username'},
14876 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
14877 {name: 'lastPost', mapping: 'post_time', type: 'date'},
14878 {name: 'lastPoster', mapping: 'user2'},
14879 {name: 'excerpt', mapping: 'post_text'}
14882 var myNewRecord = new TopicRecord({
14883 title: 'Do my job please',
14886 lastPost: new Date(),
14887 lastPoster: 'Animal',
14888 excerpt: 'No way dude!'
14890 myStore.add(myNewRecord);
14895 Roo.data.Record.create = function(o){
14896 var f = function(){
14897 f.superclass.constructor.apply(this, arguments);
14899 Roo.extend(f, Roo.data.Record);
14900 var p = f.prototype;
14901 p.fields = new Roo.util.MixedCollection(false, function(field){
14904 for(var i = 0, len = o.length; i < len; i++){
14905 p.fields.add(new Roo.data.Field(o[i]));
14907 f.getField = function(name){
14908 return p.fields.get(name);
14913 Roo.data.Record.AUTO_ID = 1000;
14914 Roo.data.Record.EDIT = 'edit';
14915 Roo.data.Record.REJECT = 'reject';
14916 Roo.data.Record.COMMIT = 'commit';
14918 Roo.data.Record.prototype = {
14920 * Readonly flag - true if this record has been modified.
14929 join : function(store){
14930 this.store = store;
14934 * Set the named field to the specified value.
14935 * @param {String} name The name of the field to set.
14936 * @param {Object} value The value to set the field to.
14938 set : function(name, value){
14939 if(this.data[name] == value){
14943 if(!this.modified){
14944 this.modified = {};
14946 if(typeof this.modified[name] == 'undefined'){
14947 this.modified[name] = this.data[name];
14949 this.data[name] = value;
14950 if(!this.editing && this.store){
14951 this.store.afterEdit(this);
14956 * Get the value of the named field.
14957 * @param {String} name The name of the field to get the value of.
14958 * @return {Object} The value of the field.
14960 get : function(name){
14961 return this.data[name];
14965 beginEdit : function(){
14966 this.editing = true;
14967 this.modified = {};
14971 cancelEdit : function(){
14972 this.editing = false;
14973 delete this.modified;
14977 endEdit : function(){
14978 this.editing = false;
14979 if(this.dirty && this.store){
14980 this.store.afterEdit(this);
14985 * Usually called by the {@link Roo.data.Store} which owns the Record.
14986 * Rejects all changes made to the Record since either creation, or the last commit operation.
14987 * Modified fields are reverted to their original values.
14989 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
14990 * of reject operations.
14992 reject : function(){
14993 var m = this.modified;
14995 if(typeof m[n] != "function"){
14996 this.data[n] = m[n];
14999 this.dirty = false;
15000 delete this.modified;
15001 this.editing = false;
15003 this.store.afterReject(this);
15008 * Usually called by the {@link Roo.data.Store} which owns the Record.
15009 * Commits all changes made to the Record since either creation, or the last commit operation.
15011 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
15012 * of commit operations.
15014 commit : function(){
15015 this.dirty = false;
15016 delete this.modified;
15017 this.editing = false;
15019 this.store.afterCommit(this);
15024 hasError : function(){
15025 return this.error != null;
15029 clearError : function(){
15034 * Creates a copy of this record.
15035 * @param {String} id (optional) A new record id if you don't want to use this record's id
15038 copy : function(newId) {
15039 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
15043 * Ext JS Library 1.1.1
15044 * Copyright(c) 2006-2007, Ext JS, LLC.
15046 * Originally Released Under LGPL - original licence link has changed is not relivant.
15049 * <script type="text/javascript">
15055 * @class Roo.data.Store
15056 * @extends Roo.util.Observable
15057 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
15058 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
15060 * 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
15061 * has no knowledge of the format of the data returned by the Proxy.<br>
15063 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
15064 * instances from the data object. These records are cached and made available through accessor functions.
15066 * Creates a new Store.
15067 * @param {Object} config A config object containing the objects needed for the Store to access data,
15068 * and read the data into Records.
15070 Roo.data.Store = function(config){
15071 this.data = new Roo.util.MixedCollection(false);
15072 this.data.getKey = function(o){
15075 this.baseParams = {};
15077 this.paramNames = {
15082 "multisort" : "_multisort"
15085 if(config && config.data){
15086 this.inlineData = config.data;
15087 delete config.data;
15090 Roo.apply(this, config);
15092 if(this.reader){ // reader passed
15093 this.reader = Roo.factory(this.reader, Roo.data);
15094 this.reader.xmodule = this.xmodule || false;
15095 if(!this.recordType){
15096 this.recordType = this.reader.recordType;
15098 if(this.reader.onMetaChange){
15099 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
15103 if(this.recordType){
15104 this.fields = this.recordType.prototype.fields;
15106 this.modified = [];
15110 * @event datachanged
15111 * Fires when the data cache has changed, and a widget which is using this Store
15112 * as a Record cache should refresh its view.
15113 * @param {Store} this
15115 datachanged : true,
15117 * @event metachange
15118 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
15119 * @param {Store} this
15120 * @param {Object} meta The JSON metadata
15125 * Fires when Records have been added to the Store
15126 * @param {Store} this
15127 * @param {Roo.data.Record[]} records The array of Records added
15128 * @param {Number} index The index at which the record(s) were added
15133 * Fires when a Record has been removed from the Store
15134 * @param {Store} this
15135 * @param {Roo.data.Record} record The Record that was removed
15136 * @param {Number} index The index at which the record was removed
15141 * Fires when a Record has been updated
15142 * @param {Store} this
15143 * @param {Roo.data.Record} record The Record that was updated
15144 * @param {String} operation The update operation being performed. Value may be one of:
15146 Roo.data.Record.EDIT
15147 Roo.data.Record.REJECT
15148 Roo.data.Record.COMMIT
15154 * Fires when the data cache has been cleared.
15155 * @param {Store} this
15159 * @event beforeload
15160 * Fires before a request is made for a new data object. If the beforeload handler returns false
15161 * the load action will be canceled.
15162 * @param {Store} this
15163 * @param {Object} options The loading options that were specified (see {@link #load} for details)
15167 * @event beforeloadadd
15168 * Fires after a new set of Records has been loaded.
15169 * @param {Store} this
15170 * @param {Roo.data.Record[]} records The Records that were loaded
15171 * @param {Object} options The loading options that were specified (see {@link #load} for details)
15173 beforeloadadd : true,
15176 * Fires after a new set of Records has been loaded, before they are added to the store.
15177 * @param {Store} this
15178 * @param {Roo.data.Record[]} records The Records that were loaded
15179 * @param {Object} options The loading options that were specified (see {@link #load} for details)
15180 * @params {Object} return from reader
15184 * @event loadexception
15185 * Fires if an exception occurs in the Proxy during loading.
15186 * Called with the signature of the Proxy's "loadexception" event.
15187 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
15190 * @param {Object} return from JsonData.reader() - success, totalRecords, records
15191 * @param {Object} load options
15192 * @param {Object} jsonData from your request (normally this contains the Exception)
15194 loadexception : true
15198 this.proxy = Roo.factory(this.proxy, Roo.data);
15199 this.proxy.xmodule = this.xmodule || false;
15200 this.relayEvents(this.proxy, ["loadexception"]);
15202 this.sortToggle = {};
15203 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
15205 Roo.data.Store.superclass.constructor.call(this);
15207 if(this.inlineData){
15208 this.loadData(this.inlineData);
15209 delete this.inlineData;
15213 Roo.extend(Roo.data.Store, Roo.util.Observable, {
15215 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
15216 * without a remote query - used by combo/forms at present.
15220 * @cfg {Roo.data.DataProxy} proxy [required] The Proxy object which provides access to a data object.
15223 * @cfg {Array} data Inline data to be loaded when the store is initialized.
15226 * @cfg {Roo.data.DataReader} reader [required] The Reader object which processes the data object and returns
15227 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
15230 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
15231 * on any HTTP request
15234 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
15237 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
15241 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
15242 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
15244 remoteSort : false,
15247 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
15248 * loaded or when a record is removed. (defaults to false).
15250 pruneModifiedRecords : false,
15253 lastOptions : null,
15256 * Add Records to the Store and fires the add event.
15257 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
15259 add : function(records){
15260 records = [].concat(records);
15261 for(var i = 0, len = records.length; i < len; i++){
15262 records[i].join(this);
15264 var index = this.data.length;
15265 this.data.addAll(records);
15266 this.fireEvent("add", this, records, index);
15270 * Remove a Record from the Store and fires the remove event.
15271 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
15273 remove : function(record){
15274 var index = this.data.indexOf(record);
15275 this.data.removeAt(index);
15277 if(this.pruneModifiedRecords){
15278 this.modified.remove(record);
15280 this.fireEvent("remove", this, record, index);
15284 * Remove all Records from the Store and fires the clear event.
15286 removeAll : function(){
15288 if(this.pruneModifiedRecords){
15289 this.modified = [];
15291 this.fireEvent("clear", this);
15295 * Inserts Records to the Store at the given index and fires the add event.
15296 * @param {Number} index The start index at which to insert the passed Records.
15297 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
15299 insert : function(index, records){
15300 records = [].concat(records);
15301 for(var i = 0, len = records.length; i < len; i++){
15302 this.data.insert(index, records[i]);
15303 records[i].join(this);
15305 this.fireEvent("add", this, records, index);
15309 * Get the index within the cache of the passed Record.
15310 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
15311 * @return {Number} The index of the passed Record. Returns -1 if not found.
15313 indexOf : function(record){
15314 return this.data.indexOf(record);
15318 * Get the index within the cache of the Record with the passed id.
15319 * @param {String} id The id of the Record to find.
15320 * @return {Number} The index of the Record. Returns -1 if not found.
15322 indexOfId : function(id){
15323 return this.data.indexOfKey(id);
15327 * Get the Record with the specified id.
15328 * @param {String} id The id of the Record to find.
15329 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
15331 getById : function(id){
15332 return this.data.key(id);
15336 * Get the Record at the specified index.
15337 * @param {Number} index The index of the Record to find.
15338 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
15340 getAt : function(index){
15341 return this.data.itemAt(index);
15345 * Returns a range of Records between specified indices.
15346 * @param {Number} startIndex (optional) The starting index (defaults to 0)
15347 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
15348 * @return {Roo.data.Record[]} An array of Records
15350 getRange : function(start, end){
15351 return this.data.getRange(start, end);
15355 storeOptions : function(o){
15356 o = Roo.apply({}, o);
15359 this.lastOptions = o;
15363 * Loads the Record cache from the configured Proxy using the configured Reader.
15365 * If using remote paging, then the first load call must specify the <em>start</em>
15366 * and <em>limit</em> properties in the options.params property to establish the initial
15367 * position within the dataset, and the number of Records to cache on each read from the Proxy.
15369 * <strong>It is important to note that for remote data sources, loading is asynchronous,
15370 * and this call will return before the new data has been loaded. Perform any post-processing
15371 * in a callback function, or in a "load" event handler.</strong>
15373 * @param {Object} options An object containing properties which control loading options:<ul>
15374 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
15375 * <li>params.data {Object} if you are using a MemoryProxy / JsonReader, use this as the data to load stuff..
15378 data : data, // array of key=>value data like JsonReader
15379 total : data.length,
15385 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
15386 * passed the following arguments:<ul>
15387 * <li>r : Roo.data.Record[]</li>
15388 * <li>options: Options object from the load call</li>
15389 * <li>success: Boolean success indicator</li></ul></li>
15390 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
15391 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
15394 load : function(options){
15395 options = options || {};
15396 if(this.fireEvent("beforeload", this, options) !== false){
15397 this.storeOptions(options);
15398 var p = Roo.apply(options.params || {}, this.baseParams);
15399 // if meta was not loaded from remote source.. try requesting it.
15400 if (!this.reader.metaFromRemote) {
15401 p._requestMeta = 1;
15403 if(this.sortInfo && this.remoteSort){
15404 var pn = this.paramNames;
15405 p[pn["sort"]] = this.sortInfo.field;
15406 p[pn["dir"]] = this.sortInfo.direction;
15408 if (this.multiSort) {
15409 var pn = this.paramNames;
15410 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
15413 this.proxy.load(p, this.reader, this.loadRecords, this, options);
15418 * Reloads the Record cache from the configured Proxy using the configured Reader and
15419 * the options from the last load operation performed.
15420 * @param {Object} options (optional) An object containing properties which may override the options
15421 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
15422 * the most recently used options are reused).
15424 reload : function(options){
15425 this.load(Roo.applyIf(options||{}, this.lastOptions));
15429 // Called as a callback by the Reader during a load operation.
15430 loadRecords : function(o, options, success){
15433 if(success !== false){
15434 this.fireEvent("load", this, [], options, o);
15436 if(options.callback){
15437 options.callback.call(options.scope || this, [], options, false);
15441 // if data returned failure - throw an exception.
15442 if (o.success === false) {
15443 // show a message if no listener is registered.
15444 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
15445 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
15447 // loadmask wil be hooked into this..
15448 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
15451 var r = o.records, t = o.totalRecords || r.length;
15453 this.fireEvent("beforeloadadd", this, r, options, o);
15455 if(!options || options.add !== true){
15456 if(this.pruneModifiedRecords){
15457 this.modified = [];
15459 for(var i = 0, len = r.length; i < len; i++){
15463 this.data = this.snapshot;
15464 delete this.snapshot;
15467 this.data.addAll(r);
15468 this.totalLength = t;
15470 this.fireEvent("datachanged", this);
15472 this.totalLength = Math.max(t, this.data.length+r.length);
15476 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
15478 var e = new Roo.data.Record({});
15480 e.set(this.parent.displayField, this.parent.emptyTitle);
15481 e.set(this.parent.valueField, '');
15486 this.fireEvent("load", this, r, options, o);
15487 if(options.callback){
15488 options.callback.call(options.scope || this, r, options, true);
15494 * Loads data from a passed data block. A Reader which understands the format of the data
15495 * must have been configured in the constructor.
15496 * @param {Object} data The data block from which to read the Records. The format of the data expected
15497 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
15498 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
15500 loadData : function(o, append){
15501 var r = this.reader.readRecords(o);
15502 this.loadRecords(r, {add: append}, true);
15506 * using 'cn' the nested child reader read the child array into it's child stores.
15507 * @param {Object} rec The record with a 'children array
15509 loadDataFromChildren : function(rec)
15511 this.loadData(this.reader.toLoadData(rec));
15516 * Gets the number of cached records.
15518 * <em>If using paging, this may not be the total size of the dataset. If the data object
15519 * used by the Reader contains the dataset size, then the getTotalCount() function returns
15520 * the data set size</em>
15522 getCount : function(){
15523 return this.data.length || 0;
15527 * Gets the total number of records in the dataset as returned by the server.
15529 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
15530 * the dataset size</em>
15532 getTotalCount : function(){
15533 return this.totalLength || 0;
15537 * Returns the sort state of the Store as an object with two properties:
15539 field {String} The name of the field by which the Records are sorted
15540 direction {String} The sort order, "ASC" or "DESC"
15543 getSortState : function(){
15544 return this.sortInfo;
15548 applySort : function(){
15549 if(this.sortInfo && !this.remoteSort){
15550 var s = this.sortInfo, f = s.field;
15551 var st = this.fields.get(f).sortType;
15552 var fn = function(r1, r2){
15553 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
15554 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
15556 this.data.sort(s.direction, fn);
15557 if(this.snapshot && this.snapshot != this.data){
15558 this.snapshot.sort(s.direction, fn);
15564 * Sets the default sort column and order to be used by the next load operation.
15565 * @param {String} fieldName The name of the field to sort by.
15566 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
15568 setDefaultSort : function(field, dir){
15569 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
15573 * Sort the Records.
15574 * If remote sorting is used, the sort is performed on the server, and the cache is
15575 * reloaded. If local sorting is used, the cache is sorted internally.
15576 * @param {String} fieldName The name of the field to sort by.
15577 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
15579 sort : function(fieldName, dir){
15580 var f = this.fields.get(fieldName);
15582 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
15584 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
15585 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
15590 this.sortToggle[f.name] = dir;
15591 this.sortInfo = {field: f.name, direction: dir};
15592 if(!this.remoteSort){
15594 this.fireEvent("datachanged", this);
15596 this.load(this.lastOptions);
15601 * Calls the specified function for each of the Records in the cache.
15602 * @param {Function} fn The function to call. The Record is passed as the first parameter.
15603 * Returning <em>false</em> aborts and exits the iteration.
15604 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
15606 each : function(fn, scope){
15607 this.data.each(fn, scope);
15611 * Gets all records modified since the last commit. Modified records are persisted across load operations
15612 * (e.g., during paging).
15613 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
15615 getModifiedRecords : function(){
15616 return this.modified;
15620 createFilterFn : function(property, value, anyMatch){
15621 if(!value.exec){ // not a regex
15622 value = String(value);
15623 if(value.length == 0){
15626 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
15628 return function(r){
15629 return value.test(r.data[property]);
15634 * Sums the value of <i>property</i> for each record between start and end and returns the result.
15635 * @param {String} property A field on your records
15636 * @param {Number} start The record index to start at (defaults to 0)
15637 * @param {Number} end The last record index to include (defaults to length - 1)
15638 * @return {Number} The sum
15640 sum : function(property, start, end){
15641 var rs = this.data.items, v = 0;
15642 start = start || 0;
15643 end = (end || end === 0) ? end : rs.length-1;
15645 for(var i = start; i <= end; i++){
15646 v += (rs[i].data[property] || 0);
15652 * Filter the records by a specified property.
15653 * @param {String} field A field on your records
15654 * @param {String/RegExp} value Either a string that the field
15655 * should start with or a RegExp to test against the field
15656 * @param {Boolean} anyMatch True to match any part not just the beginning
15658 filter : function(property, value, anyMatch){
15659 var fn = this.createFilterFn(property, value, anyMatch);
15660 return fn ? this.filterBy(fn) : this.clearFilter();
15664 * Filter by a function. The specified function will be called with each
15665 * record in this data source. If the function returns true the record is included,
15666 * otherwise it is filtered.
15667 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
15668 * @param {Object} scope (optional) The scope of the function (defaults to this)
15670 filterBy : function(fn, scope){
15671 this.snapshot = this.snapshot || this.data;
15672 this.data = this.queryBy(fn, scope||this);
15673 this.fireEvent("datachanged", this);
15677 * Query the records by a specified property.
15678 * @param {String} field A field on your records
15679 * @param {String/RegExp} value Either a string that the field
15680 * should start with or a RegExp to test against the field
15681 * @param {Boolean} anyMatch True to match any part not just the beginning
15682 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
15684 query : function(property, value, anyMatch){
15685 var fn = this.createFilterFn(property, value, anyMatch);
15686 return fn ? this.queryBy(fn) : this.data.clone();
15690 * Query by a function. The specified function will be called with each
15691 * record in this data source. If the function returns true the record is included
15693 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
15694 * @param {Object} scope (optional) The scope of the function (defaults to this)
15695 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
15697 queryBy : function(fn, scope){
15698 var data = this.snapshot || this.data;
15699 return data.filterBy(fn, scope||this);
15703 * Collects unique values for a particular dataIndex from this store.
15704 * @param {String} dataIndex The property to collect
15705 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
15706 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
15707 * @return {Array} An array of the unique values
15709 collect : function(dataIndex, allowNull, bypassFilter){
15710 var d = (bypassFilter === true && this.snapshot) ?
15711 this.snapshot.items : this.data.items;
15712 var v, sv, r = [], l = {};
15713 for(var i = 0, len = d.length; i < len; i++){
15714 v = d[i].data[dataIndex];
15716 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
15725 * Revert to a view of the Record cache with no filtering applied.
15726 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
15728 clearFilter : function(suppressEvent){
15729 if(this.snapshot && this.snapshot != this.data){
15730 this.data = this.snapshot;
15731 delete this.snapshot;
15732 if(suppressEvent !== true){
15733 this.fireEvent("datachanged", this);
15739 afterEdit : function(record){
15740 if(this.modified.indexOf(record) == -1){
15741 this.modified.push(record);
15743 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
15747 afterReject : function(record){
15748 this.modified.remove(record);
15749 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
15753 afterCommit : function(record){
15754 this.modified.remove(record);
15755 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
15759 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
15760 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
15762 commitChanges : function(){
15763 var m = this.modified.slice(0);
15764 this.modified = [];
15765 for(var i = 0, len = m.length; i < len; i++){
15771 * Cancel outstanding changes on all changed records.
15773 rejectChanges : function(){
15774 var m = this.modified.slice(0);
15775 this.modified = [];
15776 for(var i = 0, len = m.length; i < len; i++){
15781 onMetaChange : function(meta, rtype, o){
15782 this.recordType = rtype;
15783 this.fields = rtype.prototype.fields;
15784 delete this.snapshot;
15785 this.sortInfo = meta.sortInfo || this.sortInfo;
15786 this.modified = [];
15787 this.fireEvent('metachange', this, this.reader.meta);
15790 moveIndex : function(data, type)
15792 var index = this.indexOf(data);
15794 var newIndex = index + type;
15798 this.insert(newIndex, data);
15803 * Ext JS Library 1.1.1
15804 * Copyright(c) 2006-2007, Ext JS, LLC.
15806 * Originally Released Under LGPL - original licence link has changed is not relivant.
15809 * <script type="text/javascript">
15813 * @class Roo.data.SimpleStore
15814 * @extends Roo.data.Store
15815 * Small helper class to make creating Stores from Array data easier.
15816 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
15817 * @cfg {Array} fields An array of field definition objects, or field name strings.
15818 * @cfg {Object} an existing reader (eg. copied from another store)
15819 * @cfg {Array} data The multi-dimensional array of data
15820 * @cfg {Roo.data.DataProxy} proxy [not-required]
15821 * @cfg {Roo.data.Reader} reader [not-required]
15823 * @param {Object} config
15825 Roo.data.SimpleStore = function(config)
15827 Roo.data.SimpleStore.superclass.constructor.call(this, {
15829 reader: typeof(config.reader) != 'undefined' ? config.reader : new Roo.data.ArrayReader({
15832 Roo.data.Record.create(config.fields)
15834 proxy : new Roo.data.MemoryProxy(config.data)
15838 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
15840 * Ext JS Library 1.1.1
15841 * Copyright(c) 2006-2007, Ext JS, LLC.
15843 * Originally Released Under LGPL - original licence link has changed is not relivant.
15846 * <script type="text/javascript">
15851 * @extends Roo.data.Store
15852 * @class Roo.data.JsonStore
15853 * Small helper class to make creating Stores for JSON data easier. <br/>
15855 var store = new Roo.data.JsonStore({
15856 url: 'get-images.php',
15858 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
15861 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
15862 * JsonReader and HttpProxy (unless inline data is provided).</b>
15863 * @cfg {Array} fields An array of field definition objects, or field name strings.
15865 * @param {Object} config
15867 Roo.data.JsonStore = function(c){
15868 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
15869 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
15870 reader: new Roo.data.JsonReader(c, c.fields)
15873 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
15875 * Ext JS Library 1.1.1
15876 * Copyright(c) 2006-2007, Ext JS, LLC.
15878 * Originally Released Under LGPL - original licence link has changed is not relivant.
15881 * <script type="text/javascript">
15885 Roo.data.Field = function(config){
15886 if(typeof config == "string"){
15887 config = {name: config};
15889 Roo.apply(this, config);
15892 this.type = "auto";
15895 var st = Roo.data.SortTypes;
15896 // named sortTypes are supported, here we look them up
15897 if(typeof this.sortType == "string"){
15898 this.sortType = st[this.sortType];
15901 // set default sortType for strings and dates
15902 if(!this.sortType){
15905 this.sortType = st.asUCString;
15908 this.sortType = st.asDate;
15911 this.sortType = st.none;
15916 var stripRe = /[\$,%]/g;
15918 // prebuilt conversion function for this field, instead of
15919 // switching every time we're reading a value
15921 var cv, dateFormat = this.dateFormat;
15926 cv = function(v){ return v; };
15929 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
15933 return v !== undefined && v !== null && v !== '' ?
15934 parseInt(String(v).replace(stripRe, ""), 10) : '';
15939 return v !== undefined && v !== null && v !== '' ?
15940 parseFloat(String(v).replace(stripRe, ""), 10) : '';
15945 cv = function(v){ return v === true || v === "true" || v == 1; };
15952 if(v instanceof Date){
15956 if(dateFormat == "timestamp"){
15957 return new Date(v*1000);
15959 return Date.parseDate(v, dateFormat);
15961 var parsed = Date.parse(v);
15962 return parsed ? new Date(parsed) : null;
15971 Roo.data.Field.prototype = {
15979 * Ext JS Library 1.1.1
15980 * Copyright(c) 2006-2007, Ext JS, LLC.
15982 * Originally Released Under LGPL - original licence link has changed is not relivant.
15985 * <script type="text/javascript">
15988 // Base class for reading structured data from a data source. This class is intended to be
15989 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
15992 * @class Roo.data.DataReader
15994 * Base class for reading structured data from a data source. This class is intended to be
15995 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
15998 Roo.data.DataReader = function(meta, recordType){
16002 this.recordType = recordType instanceof Array ?
16003 Roo.data.Record.create(recordType) : recordType;
16006 Roo.data.DataReader.prototype = {
16009 readerType : 'Data',
16011 * Create an empty record
16012 * @param {Object} data (optional) - overlay some values
16013 * @return {Roo.data.Record} record created.
16015 newRow : function(d) {
16017 this.recordType.prototype.fields.each(function(c) {
16019 case 'int' : da[c.name] = 0; break;
16020 case 'date' : da[c.name] = new Date(); break;
16021 case 'float' : da[c.name] = 0.0; break;
16022 case 'boolean' : da[c.name] = false; break;
16023 default : da[c.name] = ""; break;
16027 return new this.recordType(Roo.apply(da, d));
16033 * Ext JS Library 1.1.1
16034 * Copyright(c) 2006-2007, Ext JS, LLC.
16036 * Originally Released Under LGPL - original licence link has changed is not relivant.
16039 * <script type="text/javascript">
16043 * @class Roo.data.DataProxy
16044 * @extends Roo.util.Observable
16046 * This class is an abstract base class for implementations which provide retrieval of
16047 * unformatted data objects.<br>
16049 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
16050 * (of the appropriate type which knows how to parse the data object) to provide a block of
16051 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
16053 * Custom implementations must implement the load method as described in
16054 * {@link Roo.data.HttpProxy#load}.
16056 Roo.data.DataProxy = function(){
16059 * @event beforeload
16060 * Fires before a network request is made to retrieve a data object.
16061 * @param {Object} This DataProxy object.
16062 * @param {Object} params The params parameter to the load function.
16067 * Fires before the load method's callback is called.
16068 * @param {Object} This DataProxy object.
16069 * @param {Object} o The data object.
16070 * @param {Object} arg The callback argument object passed to the load function.
16074 * @event loadexception
16075 * Fires if an Exception occurs during data retrieval.
16076 * @param {Object} This DataProxy object.
16077 * @param {Object} o The data object.
16078 * @param {Object} arg The callback argument object passed to the load function.
16079 * @param {Object} e The Exception.
16081 loadexception : true
16083 Roo.data.DataProxy.superclass.constructor.call(this);
16086 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
16089 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
16093 * Ext JS Library 1.1.1
16094 * Copyright(c) 2006-2007, Ext JS, LLC.
16096 * Originally Released Under LGPL - original licence link has changed is not relivant.
16099 * <script type="text/javascript">
16102 * @class Roo.data.MemoryProxy
16103 * @extends Roo.data.DataProxy
16104 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
16105 * to the Reader when its load method is called.
16107 * @param {Object} config A config object containing the objects needed for the Store to access data,
16109 Roo.data.MemoryProxy = function(config){
16111 if (typeof(config) != 'undefined' && typeof(config.data) != 'undefined') {
16112 data = config.data;
16114 Roo.data.MemoryProxy.superclass.constructor.call(this);
16118 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
16121 * @cfg {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
16124 * Load data from the requested source (in this case an in-memory
16125 * data object passed to the constructor), read the data object into
16126 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
16127 * process that block using the passed callback.
16128 * @param {Object} params This parameter is not used by the MemoryProxy class.
16129 * @param {Roo.data.DataReader} reader The Reader object which converts the data
16130 * object into a block of Roo.data.Records.
16131 * @param {Function} callback The function into which to pass the block of Roo.data.records.
16132 * The function must be passed <ul>
16133 * <li>The Record block object</li>
16134 * <li>The "arg" argument from the load function</li>
16135 * <li>A boolean success indicator</li>
16137 * @param {Object} scope The scope in which to call the callback
16138 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
16140 load : function(params, reader, callback, scope, arg){
16141 params = params || {};
16144 result = reader.readRecords(params.data ? params.data :this.data);
16146 this.fireEvent("loadexception", this, arg, null, e);
16147 callback.call(scope, null, arg, false);
16150 callback.call(scope, result, arg, true);
16154 update : function(params, records){
16159 * Ext JS Library 1.1.1
16160 * Copyright(c) 2006-2007, Ext JS, LLC.
16162 * Originally Released Under LGPL - original licence link has changed is not relivant.
16165 * <script type="text/javascript">
16168 * @class Roo.data.HttpProxy
16169 * @extends Roo.data.DataProxy
16170 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
16171 * configured to reference a certain URL.<br><br>
16173 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
16174 * from which the running page was served.<br><br>
16176 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
16178 * Be aware that to enable the browser to parse an XML document, the server must set
16179 * the Content-Type header in the HTTP response to "text/xml".
16181 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
16182 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
16183 * will be used to make the request.
16185 Roo.data.HttpProxy = function(conn){
16186 Roo.data.HttpProxy.superclass.constructor.call(this);
16187 // is conn a conn config or a real conn?
16189 this.useAjax = !conn || !conn.events;
16193 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
16194 // thse are take from connection...
16197 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
16200 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
16201 * extra parameters to each request made by this object. (defaults to undefined)
16204 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
16205 * to each request made by this object. (defaults to undefined)
16208 * @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)
16211 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
16214 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
16220 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
16224 * Return the {@link Roo.data.Connection} object being used by this Proxy.
16225 * @return {Connection} The Connection object. This object may be used to subscribe to events on
16226 * a finer-grained basis than the DataProxy events.
16228 getConnection : function(){
16229 return this.useAjax ? Roo.Ajax : this.conn;
16233 * Load data from the configured {@link Roo.data.Connection}, read the data object into
16234 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
16235 * process that block using the passed callback.
16236 * @param {Object} params An object containing properties which are to be used as HTTP parameters
16237 * for the request to the remote server.
16238 * @param {Roo.data.DataReader} reader The Reader object which converts the data
16239 * object into a block of Roo.data.Records.
16240 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
16241 * The function must be passed <ul>
16242 * <li>The Record block object</li>
16243 * <li>The "arg" argument from the load function</li>
16244 * <li>A boolean success indicator</li>
16246 * @param {Object} scope The scope in which to call the callback
16247 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
16249 load : function(params, reader, callback, scope, arg){
16250 if(this.fireEvent("beforeload", this, params) !== false){
16252 params : params || {},
16254 callback : callback,
16259 callback : this.loadResponse,
16263 Roo.applyIf(o, this.conn);
16264 if(this.activeRequest){
16265 Roo.Ajax.abort(this.activeRequest);
16267 this.activeRequest = Roo.Ajax.request(o);
16269 this.conn.request(o);
16272 callback.call(scope||this, null, arg, false);
16277 loadResponse : function(o, success, response){
16278 delete this.activeRequest;
16280 this.fireEvent("loadexception", this, o, response);
16281 o.request.callback.call(o.request.scope, null, o.request.arg, false);
16286 result = o.reader.read(response);
16289 o.raw = { errorMsg : response.responseText };
16290 this.fireEvent("loadexception", this, o, response, e);
16291 o.request.callback.call(o.request.scope, o, o.request.arg, false);
16295 this.fireEvent("load", this, o, o.request.arg);
16296 o.request.callback.call(o.request.scope, result, o.request.arg, true);
16300 update : function(dataSet){
16305 updateResponse : function(dataSet){
16310 * Ext JS Library 1.1.1
16311 * Copyright(c) 2006-2007, Ext JS, LLC.
16313 * Originally Released Under LGPL - original licence link has changed is not relivant.
16316 * <script type="text/javascript">
16320 * @class Roo.data.ScriptTagProxy
16321 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
16322 * other than the originating domain of the running page.<br><br>
16324 * <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
16325 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
16327 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
16328 * source code that is used as the source inside a <script> tag.<br><br>
16330 * In order for the browser to process the returned data, the server must wrap the data object
16331 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
16332 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
16333 * depending on whether the callback name was passed:
16336 boolean scriptTag = false;
16337 String cb = request.getParameter("callback");
16340 response.setContentType("text/javascript");
16342 response.setContentType("application/x-json");
16344 Writer out = response.getWriter();
16346 out.write(cb + "(");
16348 out.print(dataBlock.toJsonString());
16355 * @param {Object} config A configuration object.
16357 Roo.data.ScriptTagProxy = function(config){
16358 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
16359 Roo.apply(this, config);
16360 this.head = document.getElementsByTagName("head")[0];
16363 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
16365 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
16367 * @cfg {String} url The URL from which to request the data object.
16370 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
16374 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
16375 * the server the name of the callback function set up by the load call to process the returned data object.
16376 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
16377 * javascript output which calls this named function passing the data object as its only parameter.
16379 callbackParam : "callback",
16381 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
16382 * name to the request.
16387 * Load data from the configured URL, read the data object into
16388 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
16389 * process that block using the passed callback.
16390 * @param {Object} params An object containing properties which are to be used as HTTP parameters
16391 * for the request to the remote server.
16392 * @param {Roo.data.DataReader} reader The Reader object which converts the data
16393 * object into a block of Roo.data.Records.
16394 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
16395 * The function must be passed <ul>
16396 * <li>The Record block object</li>
16397 * <li>The "arg" argument from the load function</li>
16398 * <li>A boolean success indicator</li>
16400 * @param {Object} scope The scope in which to call the callback
16401 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
16403 load : function(params, reader, callback, scope, arg){
16404 if(this.fireEvent("beforeload", this, params) !== false){
16406 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
16408 var url = this.url;
16409 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
16411 url += "&_dc=" + (new Date().getTime());
16413 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
16416 cb : "stcCallback"+transId,
16417 scriptId : "stcScript"+transId,
16421 callback : callback,
16427 window[trans.cb] = function(o){
16428 conn.handleResponse(o, trans);
16431 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
16433 if(this.autoAbort !== false){
16437 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
16439 var script = document.createElement("script");
16440 script.setAttribute("src", url);
16441 script.setAttribute("type", "text/javascript");
16442 script.setAttribute("id", trans.scriptId);
16443 this.head.appendChild(script);
16445 this.trans = trans;
16447 callback.call(scope||this, null, arg, false);
16452 isLoading : function(){
16453 return this.trans ? true : false;
16457 * Abort the current server request.
16459 abort : function(){
16460 if(this.isLoading()){
16461 this.destroyTrans(this.trans);
16466 destroyTrans : function(trans, isLoaded){
16467 this.head.removeChild(document.getElementById(trans.scriptId));
16468 clearTimeout(trans.timeoutId);
16470 window[trans.cb] = undefined;
16472 delete window[trans.cb];
16475 // if hasn't been loaded, wait for load to remove it to prevent script error
16476 window[trans.cb] = function(){
16477 window[trans.cb] = undefined;
16479 delete window[trans.cb];
16486 handleResponse : function(o, trans){
16487 this.trans = false;
16488 this.destroyTrans(trans, true);
16491 result = trans.reader.readRecords(o);
16493 this.fireEvent("loadexception", this, o, trans.arg, e);
16494 trans.callback.call(trans.scope||window, null, trans.arg, false);
16497 this.fireEvent("load", this, o, trans.arg);
16498 trans.callback.call(trans.scope||window, result, trans.arg, true);
16502 handleFailure : function(trans){
16503 this.trans = false;
16504 this.destroyTrans(trans, false);
16505 this.fireEvent("loadexception", this, null, trans.arg);
16506 trans.callback.call(trans.scope||window, null, trans.arg, false);
16510 * Ext JS Library 1.1.1
16511 * Copyright(c) 2006-2007, Ext JS, LLC.
16513 * Originally Released Under LGPL - original licence link has changed is not relivant.
16516 * <script type="text/javascript">
16520 * @class Roo.data.JsonReader
16521 * @extends Roo.data.DataReader
16522 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
16523 * based on mappings in a provided Roo.data.Record constructor.
16525 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
16526 * in the reply previously.
16531 var RecordDef = Roo.data.Record.create([
16532 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
16533 {name: 'occupation'} // This field will use "occupation" as the mapping.
16535 var myReader = new Roo.data.JsonReader({
16536 totalProperty: "results", // The property which contains the total dataset size (optional)
16537 root: "rows", // The property which contains an Array of row objects
16538 id: "id" // The property within each row object that provides an ID for the record (optional)
16542 * This would consume a JSON file like this:
16544 { 'results': 2, 'rows': [
16545 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
16546 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
16549 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
16550 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
16551 * paged from the remote server.
16552 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
16553 * @cfg {String} root name of the property which contains the Array of row objects.
16554 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
16555 * @cfg {Array} fields Array of field definition objects
16557 * Create a new JsonReader
16558 * @param {Object} meta Metadata configuration options
16559 * @param {Object} recordType Either an Array of field definition objects,
16560 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
16562 Roo.data.JsonReader = function(meta, recordType){
16565 // set some defaults:
16566 Roo.applyIf(meta, {
16567 totalProperty: 'total',
16568 successProperty : 'success',
16573 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
16575 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
16577 readerType : 'Json',
16580 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
16581 * Used by Store query builder to append _requestMeta to params.
16584 metaFromRemote : false,
16586 * This method is only used by a DataProxy which has retrieved data from a remote server.
16587 * @param {Object} response The XHR object which contains the JSON data in its responseText.
16588 * @return {Object} data A data block which is used by an Roo.data.Store object as
16589 * a cache of Roo.data.Records.
16591 read : function(response){
16592 var json = response.responseText;
16594 var o = /* eval:var:o */ eval("("+json+")");
16596 throw {message: "JsonReader.read: Json object not found"};
16602 this.metaFromRemote = true;
16603 this.meta = o.metaData;
16604 this.recordType = Roo.data.Record.create(o.metaData.fields);
16605 this.onMetaChange(this.meta, this.recordType, o);
16607 return this.readRecords(o);
16610 // private function a store will implement
16611 onMetaChange : function(meta, recordType, o){
16618 simpleAccess: function(obj, subsc) {
16625 getJsonAccessor: function(){
16627 return function(expr) {
16629 return(re.test(expr))
16630 ? new Function("obj", "return obj." + expr)
16635 return Roo.emptyFn;
16640 * Create a data block containing Roo.data.Records from an XML document.
16641 * @param {Object} o An object which contains an Array of row objects in the property specified
16642 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
16643 * which contains the total size of the dataset.
16644 * @return {Object} data A data block which is used by an Roo.data.Store object as
16645 * a cache of Roo.data.Records.
16647 readRecords : function(o){
16649 * After any data loads, the raw JSON data is available for further custom processing.
16653 var s = this.meta, Record = this.recordType,
16654 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
16656 // Generate extraction functions for the totalProperty, the root, the id, and for each field
16658 if(s.totalProperty) {
16659 this.getTotal = this.getJsonAccessor(s.totalProperty);
16661 if(s.successProperty) {
16662 this.getSuccess = this.getJsonAccessor(s.successProperty);
16664 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
16666 var g = this.getJsonAccessor(s.id);
16667 this.getId = function(rec) {
16669 return (r === undefined || r === "") ? null : r;
16672 this.getId = function(){return null;};
16675 for(var jj = 0; jj < fl; jj++){
16677 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
16678 this.ef[jj] = this.getJsonAccessor(map);
16682 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
16683 if(s.totalProperty){
16684 var vt = parseInt(this.getTotal(o), 10);
16689 if(s.successProperty){
16690 var vs = this.getSuccess(o);
16691 if(vs === false || vs === 'false'){
16696 for(var i = 0; i < c; i++){
16699 var id = this.getId(n);
16700 for(var j = 0; j < fl; j++){
16702 var v = this.ef[j](n);
16704 Roo.log('missing convert for ' + f.name);
16708 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
16712 raw : { errorMsg : "JSON Reader Error: fields or metadata not available to create Record" },
16718 var record = new Record(values, id);
16720 records[i] = record;
16726 totalRecords : totalRecords
16729 // used when loading children.. @see loadDataFromChildren
16730 toLoadData: function(rec)
16732 // expect rec just to be an array.. eg [a,b,c, [...] << cn ]
16733 var data = typeof(rec.data.cn) == 'undefined' ? [] : rec.data.cn;
16734 return { data : data, total : data.length };
16739 * Ext JS Library 1.1.1
16740 * Copyright(c) 2006-2007, Ext JS, LLC.
16742 * Originally Released Under LGPL - original licence link has changed is not relivant.
16745 * <script type="text/javascript">
16749 * @class Roo.data.ArrayReader
16750 * @extends Roo.data.DataReader
16751 * Data reader class to create an Array of Roo.data.Record objects from an Array.
16752 * Each element of that Array represents a row of data fields. The
16753 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
16754 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
16758 var RecordDef = Roo.data.Record.create([
16759 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
16760 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
16762 var myReader = new Roo.data.ArrayReader({
16763 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
16767 * This would consume an Array like this:
16769 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
16773 * Create a new JsonReader
16774 * @param {Object} meta Metadata configuration options.
16775 * @param {Object|Array} recordType Either an Array of field definition objects
16777 * @cfg {Array} fields Array of field definition objects
16778 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
16779 * as specified to {@link Roo.data.Record#create},
16780 * or an {@link Roo.data.Record} object
16783 * created using {@link Roo.data.Record#create}.
16785 Roo.data.ArrayReader = function(meta, recordType)
16787 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType||meta.fields);
16790 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
16793 * Create a data block containing Roo.data.Records from an XML document.
16794 * @param {Object} o An Array of row objects which represents the dataset.
16795 * @return {Object} A data block which is used by an {@link Roo.data.Store} object as
16796 * a cache of Roo.data.Records.
16798 readRecords : function(o)
16800 var sid = this.meta ? this.meta.id : null;
16801 var recordType = this.recordType, fields = recordType.prototype.fields;
16804 for(var i = 0; i < root.length; i++){
16807 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
16808 for(var j = 0, jlen = fields.length; j < jlen; j++){
16809 var f = fields.items[j];
16810 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
16811 var v = n[k] !== undefined ? n[k] : f.defaultValue;
16813 values[f.name] = v;
16815 var record = new recordType(values, id);
16817 records[records.length] = record;
16821 totalRecords : records.length
16824 // used when loading children.. @see loadDataFromChildren
16825 toLoadData: function(rec)
16827 // expect rec just to be an array.. eg [a,b,c, [...] << cn ]
16828 return typeof(rec.data.cn) == 'undefined' ? [] : rec.data.cn;
16839 * @class Roo.bootstrap.form.ComboBox
16840 * @extends Roo.bootstrap.form.TriggerField
16841 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
16842 * @cfg {Boolean} append (true|false) default false
16843 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
16844 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
16845 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
16846 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
16847 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
16848 * @cfg {Boolean} animate default true
16849 * @cfg {Boolean} emptyResultText only for touch device
16850 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
16851 * @cfg {String} emptyTitle default ''
16852 * @cfg {Number} width fixed with? experimental
16854 * Create a new ComboBox.
16855 * @param {Object} config Configuration options
16857 Roo.bootstrap.form.ComboBox = function(config){
16858 Roo.bootstrap.form.ComboBox.superclass.constructor.call(this, config);
16862 * Fires when the dropdown list is expanded
16863 * @param {Roo.bootstrap.form.ComboBox} combo This combo box
16868 * Fires when the dropdown list is collapsed
16869 * @param {Roo.bootstrap.form.ComboBox} combo This combo box
16873 * @event beforeselect
16874 * Fires before a list item is selected. Return false to cancel the selection.
16875 * @param {Roo.bootstrap.form.ComboBox} combo This combo box
16876 * @param {Roo.data.Record} record The data record returned from the underlying store
16877 * @param {Number} index The index of the selected item in the dropdown list
16879 'beforeselect' : true,
16882 * Fires when a list item is selected
16883 * @param {Roo.bootstrap.form.ComboBox} combo This combo box
16884 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
16885 * @param {Number} index The index of the selected item in the dropdown list
16889 * @event beforequery
16890 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
16891 * The event object passed has these properties:
16892 * @param {Roo.bootstrap.form.ComboBox} combo This combo box
16893 * @param {String} query The query
16894 * @param {Boolean} forceAll true to force "all" query
16895 * @param {Boolean} cancel true to cancel the query
16896 * @param {Object} e The query event object
16898 'beforequery': true,
16901 * Fires when the 'add' icon is pressed (add a listener to enable add button)
16902 * @param {Roo.bootstrap.form.ComboBox} combo This combo box
16907 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
16908 * @param {Roo.bootstrap.form.ComboBox} combo This combo box
16909 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
16914 * Fires when the remove value from the combobox array
16915 * @param {Roo.bootstrap.form.ComboBox} combo This combo box
16919 * @event afterremove
16920 * Fires when the remove value from the combobox array
16921 * @param {Roo.bootstrap.form.ComboBox} combo This combo box
16923 'afterremove' : true,
16925 * @event specialfilter
16926 * Fires when specialfilter
16927 * @param {Roo.bootstrap.form.ComboBox} combo This combo box
16929 'specialfilter' : true,
16932 * Fires when tick the element
16933 * @param {Roo.bootstrap.form.ComboBox} combo This combo box
16937 * @event touchviewdisplay
16938 * Fires when touch view require special display (default is using displayField)
16939 * @param {Roo.bootstrap.form.ComboBox} combo This combo box
16940 * @param {Object} cfg set html .
16942 'touchviewdisplay' : true
16947 this.tickItems = [];
16949 this.selectedIndex = -1;
16950 if(this.mode == 'local'){
16951 if(config.queryDelay === undefined){
16952 this.queryDelay = 10;
16954 if(config.minChars === undefined){
16960 Roo.extend(Roo.bootstrap.form.ComboBox, Roo.bootstrap.form.TriggerField, {
16963 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
16964 * rendering into an Roo.Editor, defaults to false)
16967 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
16968 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
16971 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
16974 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
16975 * the dropdown list (defaults to undefined, with no header element)
16979 * @cfg {String/Roo.Template} tpl The template to use to render the output default is '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>'
16983 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
16985 listWidth: undefined,
16987 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
16988 * mode = 'remote' or 'text' if mode = 'local')
16990 displayField: undefined,
16993 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
16994 * mode = 'remote' or 'value' if mode = 'local').
16995 * Note: use of a valueField requires the user make a selection
16996 * in order for a value to be mapped.
16998 valueField: undefined,
17000 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
17005 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
17006 * field's data value (defaults to the underlying DOM element's name)
17008 hiddenName: undefined,
17010 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
17014 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
17016 selectedClass: 'active',
17019 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
17023 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
17024 * anchor positions (defaults to 'tl-bl')
17026 listAlign: 'tl-bl?',
17028 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
17032 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
17033 * query specified by the allQuery config option (defaults to 'query')
17035 triggerAction: 'query',
17037 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
17038 * (defaults to 4, does not apply if editable = false)
17042 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
17043 * delay (typeAheadDelay) if it matches a known value (defaults to false)
17047 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
17048 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
17052 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
17053 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
17057 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
17058 * when editable = true (defaults to false)
17060 selectOnFocus:false,
17062 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
17064 queryParam: 'query',
17066 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
17067 * when mode = 'remote' (defaults to 'Loading...')
17069 loadingText: 'Loading...',
17071 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
17075 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
17079 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
17080 * traditional select (defaults to true)
17084 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
17088 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
17092 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
17093 * listWidth has a higher value)
17097 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
17098 * allow the user to set arbitrary text into the field (defaults to false)
17100 forceSelection:false,
17102 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
17103 * if typeAhead = true (defaults to 250)
17105 typeAheadDelay : 250,
17107 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
17108 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
17110 valueNotFoundText : undefined,
17112 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
17114 blockFocus : false,
17117 * @cfg {Boolean} disableClear Disable showing of clear button.
17119 disableClear : false,
17121 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
17123 alwaysQuery : false,
17126 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
17131 * @cfg {String} invalidClass DEPRICATED - uses BS4 is-valid now
17133 invalidClass : "has-warning",
17136 * @cfg {String} validClass DEPRICATED - uses BS4 is-valid now
17138 validClass : "has-success",
17141 * @cfg {Boolean} specialFilter (true|false) special filter default false
17143 specialFilter : false,
17146 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
17148 mobileTouchView : true,
17151 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
17153 useNativeIOS : false,
17156 * @cfg {Boolean} mobile_restrict_height (true|false) restrict height for touch view
17158 mobile_restrict_height : false,
17160 ios_options : false,
17172 btnPosition : 'right',
17173 triggerList : true,
17174 showToggleBtn : true,
17176 emptyResultText: 'Empty',
17177 triggerText : 'Select',
17181 // element that contains real text value.. (when hidden is used..)
17183 getAutoCreate : function()
17188 * Render classic select for iso
17191 if(Roo.isIOS && this.useNativeIOS){
17192 cfg = this.getAutoCreateNativeIOS();
17200 if(Roo.isTouch && this.mobileTouchView){
17201 cfg = this.getAutoCreateTouchView();
17208 if(!this.tickable){
17209 cfg = Roo.bootstrap.form.ComboBox.superclass.getAutoCreate.call(this);
17214 * ComboBox with tickable selections
17217 var align = this.labelAlign || this.parentLabelAlign();
17220 cls : 'form-group roo-combobox-tickable' //input-group
17223 var btn_text_select = '';
17224 var btn_text_done = '';
17225 var btn_text_cancel = '';
17227 if (this.btn_text_show) {
17228 btn_text_select = 'Select';
17229 btn_text_done = 'Done';
17230 btn_text_cancel = 'Cancel';
17235 cls : 'tickable-buttons',
17240 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
17241 //html : this.triggerText
17242 html: btn_text_select
17248 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
17250 html: btn_text_done
17256 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
17258 html: btn_text_cancel
17264 buttons.cn.unshift({
17266 cls: 'roo-select2-search-field-input'
17272 Roo.each(buttons.cn, function(c){
17274 c.cls += ' btn-' + _this.size;
17277 if (_this.disabled) {
17284 style : 'display: contents',
17289 cls: 'form-hidden-field'
17293 cls: 'roo-select2-choices',
17297 cls: 'roo-select2-search-field',
17308 cls: 'roo-select2-container input-group roo-select2-container-multi',
17314 // cls: 'typeahead typeahead-long dropdown-menu',
17315 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
17320 if(this.hasFeedback && !this.allowBlank){
17324 cls: 'glyphicon form-control-feedback'
17327 combobox.cn.push(feedback);
17334 cls : 'roo-required-indicator ' + (this.indicatorpos == 'right' ? 'right' : 'left') +'-indicator text-danger fa fa-lg fa-star',
17335 tooltip : 'This field is required'
17337 if (Roo.bootstrap.version == 4) {
17340 style : 'display:none'
17343 if (align ==='left' && this.fieldLabel.length) {
17345 cfg.cls += ' roo-form-group-label-left' + (Roo.bootstrap.version == 4 ? ' row' : '');
17352 cls : 'control-label col-form-label',
17353 html : this.fieldLabel
17365 var labelCfg = cfg.cn[1];
17366 var contentCfg = cfg.cn[2];
17369 if(this.indicatorpos == 'right'){
17375 cls : 'control-label col-form-label',
17379 html : this.fieldLabel
17395 labelCfg = cfg.cn[0];
17396 contentCfg = cfg.cn[1];
17400 if(this.labelWidth > 12){
17401 labelCfg.style = "width: " + this.labelWidth + 'px';
17403 if(this.width * 1 > 0){
17404 contentCfg.style = "width: " + this.width + 'px';
17406 if(this.labelWidth < 13 && this.labelmd == 0){
17407 this.labelmd = this.labelWidth;
17410 if(this.labellg > 0){
17411 labelCfg.cls += ' col-lg-' + this.labellg;
17412 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
17415 if(this.labelmd > 0){
17416 labelCfg.cls += ' col-md-' + this.labelmd;
17417 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
17420 if(this.labelsm > 0){
17421 labelCfg.cls += ' col-sm-' + this.labelsm;
17422 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
17425 if(this.labelxs > 0){
17426 labelCfg.cls += ' col-xs-' + this.labelxs;
17427 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
17431 } else if ( this.fieldLabel.length) {
17432 // Roo.log(" label");
17437 //cls : 'input-group-addon',
17438 html : this.fieldLabel
17443 if(this.indicatorpos == 'right'){
17447 //cls : 'input-group-addon',
17448 html : this.fieldLabel
17458 // Roo.log(" no label && no align");
17465 ['xs','sm','md','lg'].map(function(size){
17466 if (settings[size]) {
17467 cfg.cls += ' col-' + size + '-' + settings[size];
17475 _initEventsCalled : false,
17478 initEvents: function()
17480 if (this._initEventsCalled) { // as we call render... prevent looping...
17483 this._initEventsCalled = true;
17486 throw "can not find store for combo";
17489 this.indicator = this.indicatorEl();
17491 this.store = Roo.factory(this.store, Roo.data);
17492 this.store.parent = this;
17494 // if we are building from html. then this element is so complex, that we can not really
17495 // use the rendered HTML.
17496 // so we have to trash and replace the previous code.
17497 if (Roo.XComponent.build_from_html) {
17498 // remove this element....
17499 var e = this.el.dom, k=0;
17500 while (e ) { e = e.previousSibling; ++k;}
17505 this.rendered = false;
17507 this.render(this.parent().getChildContainer(true), k);
17510 if(Roo.isIOS && this.useNativeIOS){
17511 this.initIOSView();
17519 if(Roo.isTouch && this.mobileTouchView){
17520 this.initTouchView();
17525 this.initTickableEvents();
17529 Roo.bootstrap.form.ComboBox.superclass.initEvents.call(this);
17531 if(this.hiddenName){
17533 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
17535 this.hiddenField.dom.value =
17536 this.hiddenValue !== undefined ? this.hiddenValue :
17537 this.value !== undefined ? this.value : '';
17539 // prevent input submission
17540 this.el.dom.removeAttribute('name');
17541 this.hiddenField.dom.setAttribute('name', this.hiddenName);
17546 // this.el.dom.setAttribute('autocomplete', 'off');
17549 var cls = 'x-combo-list';
17551 //this.list = new Roo.Layer({
17552 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
17558 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
17559 _this.list.setWidth(lw);
17562 this.list.on('mouseover', this.onViewOver, this);
17563 this.list.on('mousemove', this.onViewMove, this);
17564 this.list.on('scroll', this.onViewScroll, this);
17567 this.list.swallowEvent('mousewheel');
17568 this.assetHeight = 0;
17571 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
17572 this.assetHeight += this.header.getHeight();
17575 this.innerList = this.list.createChild({cls:cls+'-inner'});
17576 this.innerList.on('mouseover', this.onViewOver, this);
17577 this.innerList.on('mousemove', this.onViewMove, this);
17578 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
17580 if(this.allowBlank && !this.pageSize && !this.disableClear){
17581 this.footer = this.list.createChild({cls:cls+'-ft'});
17582 this.pageTb = new Roo.Toolbar(this.footer);
17586 this.footer = this.list.createChild({cls:cls+'-ft'});
17587 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
17588 {pageSize: this.pageSize});
17592 if (this.pageTb && this.allowBlank && !this.disableClear) {
17594 this.pageTb.add(new Roo.Toolbar.Fill(), {
17595 cls: 'x-btn-icon x-btn-clear',
17597 handler: function()
17600 _this.clearValue();
17601 _this.onSelect(false, -1);
17606 this.assetHeight += this.footer.getHeight();
17611 this.tpl = Roo.bootstrap.version == 4 ?
17612 '<a class="dropdown-item" href="#">{' + this.displayField + '}</a>' : // 4 does not need <li> and it get's really confisued.
17613 '<li><a class="dropdown-item" href="#">{' + this.displayField + '}</a></li>';
17616 this.view = new Roo.View(this.list, this.tpl, {
17617 singleSelect:true, store: this.store, selectedClass: this.selectedClass
17619 //this.view.wrapEl.setDisplayed(false);
17620 this.view.on('click', this.onViewClick, this);
17623 this.store.on('beforeload', this.onBeforeLoad, this);
17624 this.store.on('load', this.onLoad, this);
17625 this.store.on('loadexception', this.onLoadException, this);
17627 if(this.resizable){
17628 this.resizer = new Roo.Resizable(this.list, {
17629 pinned:true, handles:'se'
17631 this.resizer.on('resize', function(r, w, h){
17632 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
17633 this.listWidth = w;
17634 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
17635 this.restrictHeight();
17637 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
17640 if(!this.editable){
17641 this.editable = true;
17642 this.setEditable(false);
17647 if (typeof(this.events.add.listeners) != 'undefined') {
17649 this.addicon = this.wrap.createChild(
17650 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
17652 this.addicon.on('click', function(e) {
17653 this.fireEvent('add', this);
17656 if (typeof(this.events.edit.listeners) != 'undefined') {
17658 this.editicon = this.wrap.createChild(
17659 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
17660 if (this.addicon) {
17661 this.editicon.setStyle('margin-left', '40px');
17663 this.editicon.on('click', function(e) {
17665 // we fire even if inothing is selected..
17666 this.fireEvent('edit', this, this.lastData );
17672 this.keyNav = new Roo.KeyNav(this.inputEl(), {
17673 "up" : function(e){
17674 this.inKeyMode = true;
17678 "down" : function(e){
17679 if(!this.isExpanded()){
17680 this.onTriggerClick();
17682 this.inKeyMode = true;
17687 "enter" : function(e){
17688 // this.onViewClick();
17692 if(this.fireEvent("specialkey", this, e)){
17693 this.onViewClick(false);
17699 "esc" : function(e){
17703 "tab" : function(e){
17706 if(this.fireEvent("specialkey", this, e)){
17707 this.onViewClick(false);
17715 doRelay : function(foo, bar, hname){
17716 if(hname == 'down' || this.scope.isExpanded()){
17717 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
17726 this.queryDelay = Math.max(this.queryDelay || 10,
17727 this.mode == 'local' ? 10 : 250);
17730 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
17732 if(this.typeAhead){
17733 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
17735 if(this.editable !== false){
17736 this.inputEl().on("keyup", this.onKeyUp, this);
17738 if(this.forceSelection){
17739 this.inputEl().on('blur', this.doForce, this);
17743 this.choices = this.el.select('ul.roo-select2-choices', true).first();
17744 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
17748 initTickableEvents: function()
17752 if(this.hiddenName){
17754 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
17756 this.hiddenField.dom.value =
17757 this.hiddenValue !== undefined ? this.hiddenValue :
17758 this.value !== undefined ? this.value : '';
17760 // prevent input submission
17761 this.el.dom.removeAttribute('name');
17762 this.hiddenField.dom.setAttribute('name', this.hiddenName);
17767 // this.list = this.el.select('ul.dropdown-menu',true).first();
17769 this.choices = this.el.select('ul.roo-select2-choices', true).first();
17770 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
17771 if(this.triggerList){
17772 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
17775 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
17776 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
17778 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
17779 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
17781 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
17782 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
17784 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
17785 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
17786 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
17789 this.cancelBtn.hide();
17794 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
17795 _this.list.setWidth(lw);
17798 this.list.on('mouseover', this.onViewOver, this);
17799 this.list.on('mousemove', this.onViewMove, this);
17801 this.list.on('scroll', this.onViewScroll, this);
17804 this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}"' +
17805 'type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
17808 this.view = new Roo.View(this.list, this.tpl, {
17813 selectedClass: this.selectedClass
17816 //this.view.wrapEl.setDisplayed(false);
17817 this.view.on('click', this.onViewClick, this);
17821 this.store.on('beforeload', this.onBeforeLoad, this);
17822 this.store.on('load', this.onLoad, this);
17823 this.store.on('loadexception', this.onLoadException, this);
17826 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
17827 "up" : function(e){
17828 this.inKeyMode = true;
17832 "down" : function(e){
17833 this.inKeyMode = true;
17837 "enter" : function(e){
17838 if(this.fireEvent("specialkey", this, e)){
17839 this.onViewClick(false);
17845 "esc" : function(e){
17846 this.onTickableFooterButtonClick(e, false, false);
17849 "tab" : function(e){
17850 this.fireEvent("specialkey", this, e);
17852 this.onTickableFooterButtonClick(e, false, false);
17859 doRelay : function(e, fn, key){
17860 if(this.scope.isExpanded()){
17861 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
17870 this.queryDelay = Math.max(this.queryDelay || 10,
17871 this.mode == 'local' ? 10 : 250);
17874 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
17876 if(this.typeAhead){
17877 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
17880 if(this.editable !== false){
17881 this.tickableInputEl().on("keyup", this.onKeyUp, this);
17884 this.indicator = this.indicatorEl();
17886 if(this.indicator){
17887 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
17888 this.indicator.hide();
17893 onDestroy : function(){
17895 this.view.setStore(null);
17896 this.view.el.removeAllListeners();
17897 this.view.el.remove();
17898 this.view.purgeListeners();
17901 this.list.dom.innerHTML = '';
17905 this.store.un('beforeload', this.onBeforeLoad, this);
17906 this.store.un('load', this.onLoad, this);
17907 this.store.un('loadexception', this.onLoadException, this);
17909 Roo.bootstrap.form.ComboBox.superclass.onDestroy.call(this);
17913 fireKey : function(e){
17914 if(e.isNavKeyPress() && !this.list.isVisible()){
17915 this.fireEvent("specialkey", this, e);
17920 onResize: function(w, h)
17924 // Roo.bootstrap.form.ComboBox.superclass.onResize.apply(this, arguments);
17926 // if(typeof w != 'number'){
17927 // // we do not handle it!?!?
17930 // var tw = this.trigger.getWidth();
17931 // // tw += this.addicon ? this.addicon.getWidth() : 0;
17932 // // tw += this.editicon ? this.editicon.getWidth() : 0;
17934 // this.inputEl().setWidth( this.adjustWidth('input', x));
17936 // //this.trigger.setStyle('left', x+'px');
17938 // if(this.list && this.listWidth === undefined){
17939 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
17940 // this.list.setWidth(lw);
17941 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
17949 * Allow or prevent the user from directly editing the field text. If false is passed,
17950 * the user will only be able to select from the items defined in the dropdown list. This method
17951 * is the runtime equivalent of setting the 'editable' config option at config time.
17952 * @param {Boolean} value True to allow the user to directly edit the field text
17954 setEditable : function(value){
17955 if(value == this.editable){
17958 this.editable = value;
17960 this.inputEl().dom.setAttribute('readOnly', true);
17961 this.inputEl().on('mousedown', this.onTriggerClick, this);
17962 this.inputEl().addClass('x-combo-noedit');
17964 this.inputEl().dom.removeAttribute('readOnly');
17965 this.inputEl().un('mousedown', this.onTriggerClick, this);
17966 this.inputEl().removeClass('x-combo-noedit');
17972 onBeforeLoad : function(combo,opts){
17973 if(!this.hasFocus){
17977 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
17979 this.restrictHeight();
17980 this.selectedIndex = -1;
17984 onLoad : function(){
17986 this.hasQuery = false;
17988 if(!this.hasFocus){
17992 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
17993 this.loading.hide();
17996 if(this.store.getCount() > 0){
17999 this.restrictHeight();
18000 if(this.lastQuery == this.allQuery){
18001 if(this.editable && !this.tickable){
18002 this.inputEl().dom.select();
18006 !this.selectByValue(this.value, true) &&
18009 !this.store.lastOptions ||
18010 typeof(this.store.lastOptions.add) == 'undefined' ||
18011 this.store.lastOptions.add != true
18014 this.select(0, true);
18017 if(this.autoFocus){
18020 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
18021 this.taTask.delay(this.typeAheadDelay);
18025 this.onEmptyResults();
18031 onLoadException : function()
18033 this.hasQuery = false;
18035 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
18036 this.loading.hide();
18039 if(this.tickable && this.editable){
18044 // only causes errors at present
18045 //Roo.log(this.store.reader.jsonData);
18046 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
18048 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
18054 onTypeAhead : function(){
18055 if(this.store.getCount() > 0){
18056 var r = this.store.getAt(0);
18057 var newValue = r.data[this.displayField];
18058 var len = newValue.length;
18059 var selStart = this.getRawValue().length;
18061 if(selStart != len){
18062 this.setRawValue(newValue);
18063 this.selectText(selStart, newValue.length);
18069 onSelect : function(record, index){
18071 if(this.fireEvent('beforeselect', this, record, index) !== false){
18073 this.setFromData(index > -1 ? record.data : false);
18076 this.fireEvent('select', this, record, index);
18081 * Returns the currently selected field value or empty string if no value is set.
18082 * @return {String} value The selected value
18084 getValue : function()
18086 if(Roo.isIOS && this.useNativeIOS){
18087 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
18091 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
18094 if(this.valueField){
18095 return typeof this.value != 'undefined' ? this.value : '';
18097 return Roo.bootstrap.form.ComboBox.superclass.getValue.call(this);
18101 getRawValue : function()
18103 if(Roo.isIOS && this.useNativeIOS){
18104 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
18107 var v = this.inputEl().getValue();
18113 * Clears any text/value currently set in the field
18115 clearValue : function(){
18117 if(this.hiddenField){
18118 this.hiddenField.dom.value = '';
18121 this.setRawValue('');
18122 this.lastSelectionText = '';
18123 this.lastData = false;
18125 var close = this.closeTriggerEl();
18136 * Sets the specified value into the field. If the value finds a match, the corresponding record text
18137 * will be displayed in the field. If the value does not match the data value of an existing item,
18138 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
18139 * Otherwise the field will be blank (although the value will still be set).
18140 * @param {String} value The value to match
18142 setValue : function(v)
18144 if(Roo.isIOS && this.useNativeIOS){
18145 this.setIOSValue(v);
18155 if(this.valueField){
18156 var r = this.findRecord(this.valueField, v);
18158 text = r.data[this.displayField];
18159 }else if(this.valueNotFoundText !== undefined){
18160 text = this.valueNotFoundText;
18163 this.lastSelectionText = text;
18164 if(this.hiddenField){
18165 this.hiddenField.dom.value = v;
18167 Roo.bootstrap.form.ComboBox.superclass.setValue.call(this, text);
18170 var close = this.closeTriggerEl();
18173 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
18179 * @property {Object} the last set data for the element
18184 * Sets the value of the field based on a object which is related to the record format for the store.
18185 * @param {Object} value the value to set as. or false on reset?
18187 setFromData : function(o){
18194 var dv = ''; // display value
18195 var vv = ''; // value value..
18197 if (this.displayField) {
18198 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
18200 // this is an error condition!!!
18201 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
18204 if(this.valueField){
18205 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
18208 var close = this.closeTriggerEl();
18211 if(dv.length || vv * 1 > 0){
18213 this.blockFocus=true;
18219 if(this.hiddenField){
18220 this.hiddenField.dom.value = vv;
18222 this.lastSelectionText = dv;
18223 Roo.bootstrap.form.ComboBox.superclass.setValue.call(this, dv);
18227 // no hidden field.. - we store the value in 'value', but still display
18228 // display field!!!!
18229 this.lastSelectionText = dv;
18230 Roo.bootstrap.form.ComboBox.superclass.setValue.call(this, dv);
18237 reset : function(){
18238 // overridden so that last data is reset..
18245 this.setValue(this.originalValue);
18246 //this.clearInvalid();
18247 this.lastData = false;
18249 this.view.clearSelections();
18255 findRecord : function(prop, value){
18257 if(this.store.getCount() > 0){
18258 this.store.each(function(r){
18259 if(r.data[prop] == value){
18269 getName: function()
18271 // returns hidden if it's set..
18272 if (!this.rendered) {return ''};
18273 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
18277 onViewMove : function(e, t){
18278 this.inKeyMode = false;
18282 onViewOver : function(e, t){
18283 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
18286 var item = this.view.findItemFromChild(t);
18289 var index = this.view.indexOf(item);
18290 this.select(index, false);
18295 onViewClick : function(view, doFocus, el, e)
18297 var index = this.view.getSelectedIndexes()[0];
18299 var r = this.store.getAt(index);
18303 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
18310 Roo.each(this.tickItems, function(v,k){
18312 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
18314 _this.tickItems.splice(k, 1);
18316 if(typeof(e) == 'undefined' && view == false){
18317 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
18329 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
18330 this.tickItems.push(r.data);
18333 if(typeof(e) == 'undefined' && view == false){
18334 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
18341 this.onSelect(r, index);
18343 if(doFocus !== false && !this.blockFocus){
18344 this.inputEl().focus();
18349 restrictHeight : function(){
18350 //this.innerList.dom.style.height = '';
18351 //var inner = this.innerList.dom;
18352 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
18353 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
18354 //this.list.beginUpdate();
18355 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
18356 this.list.alignTo(this.inputEl(), this.listAlign);
18357 this.list.alignTo(this.inputEl(), this.listAlign);
18358 //this.list.endUpdate();
18362 onEmptyResults : function(){
18364 if(this.tickable && this.editable){
18365 this.hasFocus = false;
18366 this.restrictHeight();
18374 * Returns true if the dropdown list is expanded, else false.
18376 isExpanded : function(){
18377 return this.list.isVisible();
18381 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
18382 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
18383 * @param {String} value The data value of the item to select
18384 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
18385 * selected item if it is not currently in view (defaults to true)
18386 * @return {Boolean} True if the value matched an item in the list, else false
18388 selectByValue : function(v, scrollIntoView){
18389 if(v !== undefined && v !== null){
18390 var r = this.findRecord(this.valueField || this.displayField, v);
18392 this.select(this.store.indexOf(r), scrollIntoView);
18400 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
18401 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
18402 * @param {Number} index The zero-based index of the list item to select
18403 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
18404 * selected item if it is not currently in view (defaults to true)
18406 select : function(index, scrollIntoView){
18407 this.selectedIndex = index;
18408 this.view.select(index);
18409 if(scrollIntoView !== false){
18410 var el = this.view.getNode(index);
18412 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
18415 this.list.scrollChildIntoView(el, false);
18421 selectNext : function(){
18422 var ct = this.store.getCount();
18424 if(this.selectedIndex == -1){
18426 }else if(this.selectedIndex < ct-1){
18427 this.select(this.selectedIndex+1);
18433 selectPrev : function(){
18434 var ct = this.store.getCount();
18436 if(this.selectedIndex == -1){
18438 }else if(this.selectedIndex != 0){
18439 this.select(this.selectedIndex-1);
18445 onKeyUp : function(e){
18446 if(this.editable !== false && !e.isSpecialKey()){
18447 this.lastKey = e.getKey();
18448 this.dqTask.delay(this.queryDelay);
18453 validateBlur : function(){
18454 return !this.list || !this.list.isVisible();
18458 initQuery : function(){
18460 var v = this.getRawValue();
18462 if(this.tickable && this.editable){
18463 v = this.tickableInputEl().getValue();
18470 doForce : function(){
18471 if(this.inputEl().dom.value.length > 0){
18472 this.inputEl().dom.value =
18473 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
18479 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
18480 * query allowing the query action to be canceled if needed.
18481 * @param {String} query The SQL query to execute
18482 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
18483 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
18484 * saved in the current store (defaults to false)
18486 doQuery : function(q, forceAll){
18488 if(q === undefined || q === null){
18493 forceAll: forceAll,
18497 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
18502 forceAll = qe.forceAll;
18503 if(forceAll === true || (q.length >= this.minChars)){
18505 this.hasQuery = true;
18507 if(this.lastQuery != q || this.alwaysQuery){
18508 this.lastQuery = q;
18509 if(this.mode == 'local'){
18510 this.selectedIndex = -1;
18512 this.store.clearFilter();
18515 if(this.specialFilter){
18516 this.fireEvent('specialfilter', this);
18521 this.store.filter(this.displayField, q);
18524 this.store.fireEvent("datachanged", this.store);
18531 this.store.baseParams[this.queryParam] = q;
18533 var options = {params : this.getParams(q)};
18536 options.add = true;
18537 options.params.start = this.page * this.pageSize;
18540 this.store.load(options);
18543 * this code will make the page width larger, at the beginning, the list not align correctly,
18544 * we should expand the list on onLoad
18545 * so command out it
18550 this.selectedIndex = -1;
18555 this.loadNext = false;
18559 getParams : function(q){
18561 //p[this.queryParam] = q;
18565 p.limit = this.pageSize;
18571 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
18573 collapse : function(){
18574 if(!this.isExpanded()){
18580 this.hasFocus = false;
18584 this.cancelBtn.hide();
18585 this.trigger.show();
18588 this.tickableInputEl().dom.value = '';
18589 this.tickableInputEl().blur();
18594 Roo.get(document).un('mousedown', this.collapseIf, this);
18595 Roo.get(document).un('mousewheel', this.collapseIf, this);
18596 if (!this.editable) {
18597 Roo.get(document).un('keydown', this.listKeyPress, this);
18599 this.fireEvent('collapse', this);
18605 collapseIf : function(e){
18606 var in_combo = e.within(this.el);
18607 var in_list = e.within(this.list);
18608 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
18610 if (in_combo || in_list || is_list) {
18611 //e.stopPropagation();
18616 this.onTickableFooterButtonClick(e, false, false);
18624 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
18626 expand : function(){
18628 if(this.isExpanded() || !this.hasFocus){
18632 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
18633 this.list.setWidth(lw);
18639 this.restrictHeight();
18643 this.tickItems = Roo.apply([], this.item);
18646 this.cancelBtn.show();
18647 this.trigger.hide();
18650 this.tickableInputEl().focus();
18655 Roo.get(document).on('mousedown', this.collapseIf, this);
18656 Roo.get(document).on('mousewheel', this.collapseIf, this);
18657 if (!this.editable) {
18658 Roo.get(document).on('keydown', this.listKeyPress, this);
18661 this.fireEvent('expand', this);
18665 // Implements the default empty TriggerField.onTriggerClick function
18666 onTriggerClick : function(e)
18668 Roo.log('trigger click');
18670 if(this.disabled || !this.triggerList){
18675 this.loadNext = false;
18677 if(this.isExpanded()){
18679 if (!this.blockFocus) {
18680 this.inputEl().focus();
18684 this.hasFocus = true;
18685 if(this.triggerAction == 'all') {
18686 this.doQuery(this.allQuery, true);
18688 this.doQuery(this.getRawValue());
18690 if (!this.blockFocus) {
18691 this.inputEl().focus();
18696 onTickableTriggerClick : function(e)
18703 this.loadNext = false;
18704 this.hasFocus = true;
18706 if(this.triggerAction == 'all') {
18707 this.doQuery(this.allQuery, true);
18709 this.doQuery(this.getRawValue());
18713 onSearchFieldClick : function(e)
18715 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
18716 this.onTickableFooterButtonClick(e, false, false);
18720 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
18725 this.loadNext = false;
18726 this.hasFocus = true;
18728 if(this.triggerAction == 'all') {
18729 this.doQuery(this.allQuery, true);
18731 this.doQuery(this.getRawValue());
18735 listKeyPress : function(e)
18737 //Roo.log('listkeypress');
18738 // scroll to first matching element based on key pres..
18739 if (e.isSpecialKey()) {
18742 var k = String.fromCharCode(e.getKey()).toUpperCase();
18745 var csel = this.view.getSelectedNodes();
18746 var cselitem = false;
18748 var ix = this.view.indexOf(csel[0]);
18749 cselitem = this.store.getAt(ix);
18750 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
18756 this.store.each(function(v) {
18758 // start at existing selection.
18759 if (cselitem.id == v.id) {
18765 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
18766 match = this.store.indexOf(v);
18772 if (match === false) {
18773 return true; // no more action?
18776 this.view.select(match);
18777 var sn = Roo.get(this.view.getSelectedNodes()[0]);
18778 sn.scrollIntoView(sn.dom.parentNode, false);
18781 onViewScroll : function(e, t){
18783 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){
18787 this.hasQuery = true;
18789 this.loading = this.list.select('.loading', true).first();
18791 if(this.loading === null){
18792 this.list.createChild({
18794 cls: 'loading roo-select2-more-results roo-select2-active',
18795 html: 'Loading more results...'
18798 this.loading = this.list.select('.loading', true).first();
18800 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
18802 this.loading.hide();
18805 this.loading.show();
18810 this.loadNext = true;
18812 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
18817 addItem : function(o)
18819 var dv = ''; // display value
18821 if (this.displayField) {
18822 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
18824 // this is an error condition!!!
18825 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
18832 var choice = this.choices.createChild({
18834 cls: 'roo-select2-search-choice',
18843 cls: 'roo-select2-search-choice-close fa fa-times',
18848 }, this.searchField);
18850 var close = choice.select('a.roo-select2-search-choice-close', true).first();
18852 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
18860 this.inputEl().dom.value = '';
18865 onRemoveItem : function(e, _self, o)
18867 e.preventDefault();
18869 this.lastItem = Roo.apply([], this.item);
18871 var index = this.item.indexOf(o.data) * 1;
18874 Roo.log('not this item?!');
18878 this.item.splice(index, 1);
18883 this.fireEvent('remove', this, e);
18889 syncValue : function()
18891 if(!this.item.length){
18898 Roo.each(this.item, function(i){
18899 if(_this.valueField){
18900 value.push(i[_this.valueField]);
18907 this.value = value.join(',');
18909 if(this.hiddenField){
18910 this.hiddenField.dom.value = this.value;
18913 this.store.fireEvent("datachanged", this.store);
18918 clearItem : function()
18920 if(!this.multiple){
18926 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
18934 if(this.tickable && !Roo.isTouch){
18935 this.view.refresh();
18939 inputEl: function ()
18941 if(Roo.isIOS && this.useNativeIOS){
18942 return this.el.select('select.roo-ios-select', true).first();
18945 if(Roo.isTouch && this.mobileTouchView){
18946 return this.el.select('input.form-control',true).first();
18950 return this.searchField;
18953 return this.el.select('input.form-control',true).first();
18956 onTickableFooterButtonClick : function(e, btn, el)
18958 e.preventDefault();
18960 this.lastItem = Roo.apply([], this.item);
18962 if(btn && btn.name == 'cancel'){
18963 this.tickItems = Roo.apply([], this.item);
18972 Roo.each(this.tickItems, function(o){
18980 validate : function()
18982 if(this.getVisibilityEl().hasClass('hidden')){
18986 var v = this.getRawValue();
18989 v = this.getValue();
18992 if(this.disabled || this.allowBlank || v.length){
18997 this.markInvalid();
19001 tickableInputEl : function()
19003 if(!this.tickable || !this.editable){
19004 return this.inputEl();
19007 return this.inputEl().select('.roo-select2-search-field-input', true).first();
19011 getAutoCreateTouchView : function()
19016 cls: 'form-group' //input-group
19022 type : this.inputType,
19023 cls : 'form-control x-combo-noedit',
19024 autocomplete: 'new-password',
19025 placeholder : this.placeholder || '',
19030 input.name = this.name;
19034 input.cls += ' input-' + this.size;
19037 if (this.disabled) {
19038 input.disabled = true;
19042 cls : 'roo-combobox-wrap',
19049 inputblock.cls += ' input-group';
19051 inputblock.cn.unshift({
19053 cls : 'input-group-addon input-group-prepend input-group-text',
19058 if(this.removable && !this.multiple){
19059 inputblock.cls += ' roo-removable';
19061 inputblock.cn.push({
19064 cls : 'roo-combo-removable-btn close'
19068 if(this.hasFeedback && !this.allowBlank){
19070 inputblock.cls += ' has-feedback';
19072 inputblock.cn.push({
19074 cls: 'glyphicon form-control-feedback'
19081 inputblock.cls += (this.before) ? '' : ' input-group';
19083 inputblock.cn.push({
19085 cls : 'input-group-addon input-group-append input-group-text',
19091 var ibwrap = inputblock;
19096 cls: 'roo-select2-choices',
19100 cls: 'roo-select2-search-field',
19113 cls: 'roo-select2-container input-group roo-touchview-combobox ',
19118 cls: 'form-hidden-field'
19124 if(!this.multiple && this.showToggleBtn){
19130 if (this.caret != false) {
19133 cls: 'fa fa-' + this.caret
19140 cls : 'input-group-addon input-group-append input-group-text btn dropdown-toggle',
19142 Roo.bootstrap.version == 3 ? caret : '',
19145 cls: 'combobox-clear',
19159 combobox.cls += ' roo-select2-container-multi';
19162 var required = this.allowBlank ? {
19164 style: 'display: none'
19167 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
19168 tooltip : 'This field is required'
19171 var align = this.labelAlign || this.parentLabelAlign();
19173 if (align ==='left' && this.fieldLabel.length) {
19179 cls : 'control-label col-form-label',
19180 html : this.fieldLabel
19184 cls : 'roo-combobox-wrap ',
19191 var labelCfg = cfg.cn[1];
19192 var contentCfg = cfg.cn[2];
19195 if(this.indicatorpos == 'right'){
19200 cls : 'control-label col-form-label',
19204 html : this.fieldLabel
19210 cls : "roo-combobox-wrap ",
19218 labelCfg = cfg.cn[0];
19219 contentCfg = cfg.cn[1];
19224 if(this.labelWidth > 12){
19225 labelCfg.style = "width: " + this.labelWidth + 'px';
19228 if(this.labelWidth < 13 && this.labelmd == 0){
19229 this.labelmd = this.labelWidth;
19232 if(this.labellg > 0){
19233 labelCfg.cls += ' col-lg-' + this.labellg;
19234 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
19237 if(this.labelmd > 0){
19238 labelCfg.cls += ' col-md-' + this.labelmd;
19239 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
19242 if(this.labelsm > 0){
19243 labelCfg.cls += ' col-sm-' + this.labelsm;
19244 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
19247 if(this.labelxs > 0){
19248 labelCfg.cls += ' col-xs-' + this.labelxs;
19249 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
19253 } else if ( this.fieldLabel.length) {
19258 cls : 'control-label',
19259 html : this.fieldLabel
19270 if(this.indicatorpos == 'right'){
19274 cls : 'control-label',
19275 html : this.fieldLabel,
19293 var settings = this;
19295 ['xs','sm','md','lg'].map(function(size){
19296 if (settings[size]) {
19297 cfg.cls += ' col-' + size + '-' + settings[size];
19304 initTouchView : function()
19306 this.renderTouchView();
19308 this.touchViewEl.on('scroll', function(){
19309 this.el.dom.scrollTop = 0;
19312 this.originalValue = this.getValue();
19314 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
19316 this.inputEl().on("click", this.showTouchView, this);
19317 if (this.triggerEl) {
19318 this.triggerEl.on("click", this.showTouchView, this);
19322 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
19323 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
19325 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
19327 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
19328 this.store.on('load', this.onTouchViewLoad, this);
19329 this.store.on('loadexception', this.onTouchViewLoadException, this);
19331 if(this.hiddenName){
19333 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
19335 this.hiddenField.dom.value =
19336 this.hiddenValue !== undefined ? this.hiddenValue :
19337 this.value !== undefined ? this.value : '';
19339 this.el.dom.removeAttribute('name');
19340 this.hiddenField.dom.setAttribute('name', this.hiddenName);
19344 this.choices = this.el.select('ul.roo-select2-choices', true).first();
19345 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
19348 if(this.removable && !this.multiple){
19349 var close = this.closeTriggerEl();
19351 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
19352 close.on('click', this.removeBtnClick, this, close);
19356 * fix the bug in Safari iOS8
19358 this.inputEl().on("focus", function(e){
19359 document.activeElement.blur();
19362 this._touchViewMask = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
19369 renderTouchView : function()
19371 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.form.ComboBox.touchViewTemplate);
19372 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19374 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
19375 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19377 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
19378 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19379 this.touchViewBodyEl.setStyle('overflow', 'auto');
19381 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
19382 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19384 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
19385 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19389 showTouchView : function()
19395 this.touchViewHeaderEl.hide();
19397 if(this.modalTitle.length){
19398 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
19399 this.touchViewHeaderEl.show();
19402 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
19403 this.touchViewEl.show();
19405 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
19407 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
19408 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
19410 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
19412 if(this.modalTitle.length){
19413 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
19416 this.touchViewBodyEl.setHeight(bodyHeight);
19420 (function(){ _this.touchViewEl.addClass(['in','show']); }).defer(50);
19422 this.touchViewEl.addClass(['in','show']);
19425 if(this._touchViewMask){
19426 Roo.get(document.body).addClass("x-body-masked");
19427 this._touchViewMask.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
19428 this._touchViewMask.setStyle('z-index', 10000);
19429 this._touchViewMask.addClass('show');
19432 this.doTouchViewQuery();
19436 hideTouchView : function()
19438 this.touchViewEl.removeClass(['in','show']);
19442 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
19444 this.touchViewEl.setStyle('display', 'none');
19447 if(this._touchViewMask){
19448 this._touchViewMask.removeClass('show');
19449 Roo.get(document.body).removeClass("x-body-masked");
19453 setTouchViewValue : function()
19460 Roo.each(this.tickItems, function(o){
19465 this.hideTouchView();
19468 doTouchViewQuery : function()
19477 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
19481 if(!this.alwaysQuery || this.mode == 'local'){
19482 this.onTouchViewLoad();
19489 onTouchViewBeforeLoad : function(combo,opts)
19495 onTouchViewLoad : function()
19497 if(this.store.getCount() < 1){
19498 this.onTouchViewEmptyResults();
19502 this.clearTouchView();
19504 var rawValue = this.getRawValue();
19506 var template = (this.multiple) ? Roo.bootstrap.form.ComboBox.listItemCheckbox : Roo.bootstrap.form.ComboBox.listItemRadio;
19508 this.tickItems = [];
19510 this.store.data.each(function(d, rowIndex){
19511 var row = this.touchViewListGroup.createChild(template);
19513 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
19514 row.addClass(d.data.cls);
19517 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
19520 html : d.data[this.displayField]
19523 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
19524 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
19527 row.removeClass('selected');
19528 if(!this.multiple && this.valueField &&
19529 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
19532 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
19533 row.addClass('selected');
19536 if(this.multiple && this.valueField &&
19537 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
19541 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
19542 this.tickItems.push(d.data);
19545 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
19549 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
19551 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
19553 if(this.modalTitle.length){
19554 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
19557 var listHeight = this.touchViewListGroup.getHeight() + this.touchViewBodyEl.getPadding('tb') * 2;
19559 if(this.mobile_restrict_height && listHeight < bodyHeight){
19560 this.touchViewBodyEl.setHeight(listHeight);
19565 if(firstChecked && listHeight > bodyHeight){
19566 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
19571 onTouchViewLoadException : function()
19573 this.hideTouchView();
19576 onTouchViewEmptyResults : function()
19578 this.clearTouchView();
19580 this.touchViewListGroup.createChild(Roo.bootstrap.form.ComboBox.emptyResult);
19582 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
19586 clearTouchView : function()
19588 this.touchViewListGroup.dom.innerHTML = '';
19591 onTouchViewClick : function(e, el, o)
19593 e.preventDefault();
19596 var rowIndex = o.rowIndex;
19598 var r = this.store.getAt(rowIndex);
19600 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
19602 if(!this.multiple){
19603 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
19604 c.dom.removeAttribute('checked');
19607 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
19609 this.setFromData(r.data);
19611 var close = this.closeTriggerEl();
19617 this.hideTouchView();
19619 this.fireEvent('select', this, r, rowIndex);
19624 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
19625 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
19626 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
19630 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
19631 this.addItem(r.data);
19632 this.tickItems.push(r.data);
19636 getAutoCreateNativeIOS : function()
19639 cls: 'form-group' //input-group,
19644 cls : 'roo-ios-select'
19648 combobox.name = this.name;
19651 if (this.disabled) {
19652 combobox.disabled = true;
19655 var settings = this;
19657 ['xs','sm','md','lg'].map(function(size){
19658 if (settings[size]) {
19659 cfg.cls += ' col-' + size + '-' + settings[size];
19669 initIOSView : function()
19671 this.store.on('load', this.onIOSViewLoad, this);
19676 onIOSViewLoad : function()
19678 if(this.store.getCount() < 1){
19682 this.clearIOSView();
19684 if(this.allowBlank) {
19686 var default_text = '-- SELECT --';
19688 if(this.placeholder.length){
19689 default_text = this.placeholder;
19692 if(this.emptyTitle.length){
19693 default_text += ' - ' + this.emptyTitle + ' -';
19696 var opt = this.inputEl().createChild({
19699 html : default_text
19703 o[this.valueField] = 0;
19704 o[this.displayField] = default_text;
19706 this.ios_options.push({
19713 this.store.data.each(function(d, rowIndex){
19717 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
19718 html = d.data[this.displayField];
19723 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
19724 value = d.data[this.valueField];
19733 if(this.value == d.data[this.valueField]){
19734 option['selected'] = true;
19737 var opt = this.inputEl().createChild(option);
19739 this.ios_options.push({
19746 this.inputEl().on('change', function(){
19747 this.fireEvent('select', this);
19752 clearIOSView: function()
19754 this.inputEl().dom.innerHTML = '';
19756 this.ios_options = [];
19759 setIOSValue: function(v)
19763 if(!this.ios_options){
19767 Roo.each(this.ios_options, function(opts){
19769 opts.el.dom.removeAttribute('selected');
19771 if(opts.data[this.valueField] != v){
19775 opts.el.dom.setAttribute('selected', true);
19781 * @cfg {Boolean} grow
19785 * @cfg {Number} growMin
19789 * @cfg {Number} growMax
19798 Roo.apply(Roo.bootstrap.form.ComboBox, {
19802 cls: 'modal-header',
19824 cls: 'list-group-item',
19828 cls: 'roo-combobox-list-group-item-value'
19832 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
19846 listItemCheckbox : {
19848 cls: 'list-group-item',
19852 cls: 'roo-combobox-list-group-item-value'
19856 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
19872 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
19877 cls: 'modal-footer',
19885 cls: 'col-xs-6 text-left',
19888 cls: 'btn btn-danger roo-touch-view-cancel',
19894 cls: 'col-xs-6 text-right',
19897 cls: 'btn btn-success roo-touch-view-ok',
19908 Roo.apply(Roo.bootstrap.form.ComboBox, {
19910 touchViewTemplate : {
19912 cls: 'modal fade roo-combobox-touch-view',
19916 cls: 'modal-dialog',
19917 style : 'position:fixed', // we have to fix position....
19921 cls: 'modal-content',
19923 Roo.bootstrap.form.ComboBox.header,
19924 Roo.bootstrap.form.ComboBox.body,
19925 Roo.bootstrap.form.ComboBox.footer
19934 * Ext JS Library 1.1.1
19935 * Copyright(c) 2006-2007, Ext JS, LLC.
19937 * Originally Released Under LGPL - original licence link has changed is not relivant.
19940 * <script type="text/javascript">
19945 * @extends Roo.util.Observable
19946 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
19947 * This class also supports single and multi selection modes. <br>
19948 * Create a data model bound view:
19950 var store = new Roo.data.Store(...);
19952 var view = new Roo.View({
19954 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
19956 singleSelect: true,
19957 selectedClass: "ydataview-selected",
19961 // listen for node click?
19962 view.on("click", function(vw, index, node, e){
19963 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
19967 dataModel.load("foobar.xml");
19969 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
19971 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
19972 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
19974 * Note: old style constructor is still suported (container, template, config)
19977 * Create a new View
19978 * @param {Object} config The config object
19981 Roo.View = function(config, depreciated_tpl, depreciated_config){
19983 this.parent = false;
19985 if (typeof(depreciated_tpl) == 'undefined') {
19986 // new way.. - universal constructor.
19987 Roo.apply(this, config);
19988 this.el = Roo.get(this.el);
19991 this.el = Roo.get(config);
19992 this.tpl = depreciated_tpl;
19993 Roo.apply(this, depreciated_config);
19995 this.wrapEl = this.el.wrap().wrap();
19996 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
19999 if(typeof(this.tpl) == "string"){
20000 this.tpl = new Roo.Template(this.tpl);
20002 // support xtype ctors..
20003 this.tpl = new Roo.factory(this.tpl, Roo);
20007 this.tpl.compile();
20012 * @event beforeclick
20013 * Fires before a click is processed. Returns false to cancel the default action.
20014 * @param {Roo.View} this
20015 * @param {Number} index The index of the target node
20016 * @param {HTMLElement} node The target node
20017 * @param {Roo.EventObject} e The raw event object
20019 "beforeclick" : true,
20022 * Fires when a template node is clicked.
20023 * @param {Roo.View} this
20024 * @param {Number} index The index of the target node
20025 * @param {HTMLElement} node The target node
20026 * @param {Roo.EventObject} e The raw event object
20031 * Fires when a template node is double clicked.
20032 * @param {Roo.View} this
20033 * @param {Number} index The index of the target node
20034 * @param {HTMLElement} node The target node
20035 * @param {Roo.EventObject} e The raw event object
20039 * @event contextmenu
20040 * Fires when a template node is right clicked.
20041 * @param {Roo.View} this
20042 * @param {Number} index The index of the target node
20043 * @param {HTMLElement} node The target node
20044 * @param {Roo.EventObject} e The raw event object
20046 "contextmenu" : true,
20048 * @event selectionchange
20049 * Fires when the selected nodes change.
20050 * @param {Roo.View} this
20051 * @param {Array} selections Array of the selected nodes
20053 "selectionchange" : true,
20056 * @event beforeselect
20057 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
20058 * @param {Roo.View} this
20059 * @param {HTMLElement} node The node to be selected
20060 * @param {Array} selections Array of currently selected nodes
20062 "beforeselect" : true,
20064 * @event preparedata
20065 * Fires on every row to render, to allow you to change the data.
20066 * @param {Roo.View} this
20067 * @param {Object} data to be rendered (change this)
20069 "preparedata" : true
20077 "click": this.onClick,
20078 "dblclick": this.onDblClick,
20079 "contextmenu": this.onContextMenu,
20083 this.selections = [];
20085 this.cmp = new Roo.CompositeElementLite([]);
20087 this.store = Roo.factory(this.store, Roo.data);
20088 this.setStore(this.store, true);
20091 if ( this.footer && this.footer.xtype) {
20093 var fctr = this.wrapEl.appendChild(document.createElement("div"));
20095 this.footer.dataSource = this.store;
20096 this.footer.container = fctr;
20097 this.footer = Roo.factory(this.footer, Roo);
20098 fctr.insertFirst(this.el);
20100 // this is a bit insane - as the paging toolbar seems to detach the el..
20101 // dom.parentNode.parentNode.parentNode
20102 // they get detached?
20106 Roo.View.superclass.constructor.call(this);
20111 Roo.extend(Roo.View, Roo.util.Observable, {
20114 * @cfg {Roo.data.Store} store Data store to load data from.
20119 * @cfg {String|Roo.Element} el The container element.
20124 * @cfg {String|Roo.Template} tpl The template used by this View
20128 * @cfg {String} dataName the named area of the template to use as the data area
20129 * Works with domtemplates roo-name="name"
20133 * @cfg {String} selectedClass The css class to add to selected nodes
20135 selectedClass : "x-view-selected",
20137 * @cfg {String} emptyText The empty text to show when nothing is loaded.
20142 * @cfg {String} text to display on mask (default Loading)
20146 * @cfg {Boolean} multiSelect Allow multiple selection
20148 multiSelect : false,
20150 * @cfg {Boolean} singleSelect Allow single selection
20152 singleSelect: false,
20155 * @cfg {Boolean} toggleSelect - selecting
20157 toggleSelect : false,
20160 * @cfg {Boolean} tickable - selecting
20165 * Returns the element this view is bound to.
20166 * @return {Roo.Element}
20168 getEl : function(){
20169 return this.wrapEl;
20175 * Refreshes the view. - called by datachanged on the store. - do not call directly.
20177 refresh : function(){
20178 //Roo.log('refresh');
20181 // if we are using something like 'domtemplate', then
20182 // the what gets used is:
20183 // t.applySubtemplate(NAME, data, wrapping data..)
20184 // the outer template then get' applied with
20185 // the store 'extra data'
20186 // and the body get's added to the
20187 // roo-name="data" node?
20188 // <span class='roo-tpl-{name}'></span> ?????
20192 this.clearSelections();
20193 this.el.update("");
20195 var records = this.store.getRange();
20196 if(records.length < 1) {
20198 // is this valid?? = should it render a template??
20200 this.el.update(this.emptyText);
20204 if (this.dataName) {
20205 this.el.update(t.apply(this.store.meta)); //????
20206 el = this.el.child('.roo-tpl-' + this.dataName);
20209 for(var i = 0, len = records.length; i < len; i++){
20210 var data = this.prepareData(records[i].data, i, records[i]);
20211 this.fireEvent("preparedata", this, data, i, records[i]);
20213 var d = Roo.apply({}, data);
20216 Roo.apply(d, {'roo-id' : Roo.id()});
20220 Roo.each(this.parent.item, function(item){
20221 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
20224 Roo.apply(d, {'roo-data-checked' : 'checked'});
20228 html[html.length] = Roo.util.Format.trim(
20230 t.applySubtemplate(this.dataName, d, this.store.meta) :
20237 el.update(html.join(""));
20238 this.nodes = el.dom.childNodes;
20239 this.updateIndexes(0);
20244 * Function to override to reformat the data that is sent to
20245 * the template for each node.
20246 * DEPRICATED - use the preparedata event handler.
20247 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
20248 * a JSON object for an UpdateManager bound view).
20250 prepareData : function(data, index, record)
20252 this.fireEvent("preparedata", this, data, index, record);
20256 onUpdate : function(ds, record){
20257 // Roo.log('on update');
20258 this.clearSelections();
20259 var index = this.store.indexOf(record);
20260 var n = this.nodes[index];
20261 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
20262 n.parentNode.removeChild(n);
20263 this.updateIndexes(index, index);
20269 onAdd : function(ds, records, index)
20271 //Roo.log(['on Add', ds, records, index] );
20272 this.clearSelections();
20273 if(this.nodes.length == 0){
20277 var n = this.nodes[index];
20278 for(var i = 0, len = records.length; i < len; i++){
20279 var d = this.prepareData(records[i].data, i, records[i]);
20281 this.tpl.insertBefore(n, d);
20284 this.tpl.append(this.el, d);
20287 this.updateIndexes(index);
20290 onRemove : function(ds, record, index){
20291 // Roo.log('onRemove');
20292 this.clearSelections();
20293 var el = this.dataName ?
20294 this.el.child('.roo-tpl-' + this.dataName) :
20297 el.dom.removeChild(this.nodes[index]);
20298 this.updateIndexes(index);
20302 * Refresh an individual node.
20303 * @param {Number} index
20305 refreshNode : function(index){
20306 this.onUpdate(this.store, this.store.getAt(index));
20309 updateIndexes : function(startIndex, endIndex){
20310 var ns = this.nodes;
20311 startIndex = startIndex || 0;
20312 endIndex = endIndex || ns.length - 1;
20313 for(var i = startIndex; i <= endIndex; i++){
20314 ns[i].nodeIndex = i;
20319 * Changes the data store this view uses and refresh the view.
20320 * @param {Store} store
20322 setStore : function(store, initial){
20323 if(!initial && this.store){
20324 this.store.un("datachanged", this.refresh);
20325 this.store.un("add", this.onAdd);
20326 this.store.un("remove", this.onRemove);
20327 this.store.un("update", this.onUpdate);
20328 this.store.un("clear", this.refresh);
20329 this.store.un("beforeload", this.onBeforeLoad);
20330 this.store.un("load", this.onLoad);
20331 this.store.un("loadexception", this.onLoad);
20335 store.on("datachanged", this.refresh, this);
20336 store.on("add", this.onAdd, this);
20337 store.on("remove", this.onRemove, this);
20338 store.on("update", this.onUpdate, this);
20339 store.on("clear", this.refresh, this);
20340 store.on("beforeload", this.onBeforeLoad, this);
20341 store.on("load", this.onLoad, this);
20342 store.on("loadexception", this.onLoad, this);
20350 * onbeforeLoad - masks the loading area.
20353 onBeforeLoad : function(store,opts)
20355 //Roo.log('onBeforeLoad');
20357 this.el.update("");
20359 this.el.mask(this.mask ? this.mask : "Loading" );
20361 onLoad : function ()
20368 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
20369 * @param {HTMLElement} node
20370 * @return {HTMLElement} The template node
20372 findItemFromChild : function(node){
20373 var el = this.dataName ?
20374 this.el.child('.roo-tpl-' + this.dataName,true) :
20377 if(!node || node.parentNode == el){
20380 var p = node.parentNode;
20381 while(p && p != el){
20382 if(p.parentNode == el){
20391 onClick : function(e){
20392 var item = this.findItemFromChild(e.getTarget());
20394 var index = this.indexOf(item);
20395 if(this.onItemClick(item, index, e) !== false){
20396 this.fireEvent("click", this, index, item, e);
20399 this.clearSelections();
20404 onContextMenu : function(e){
20405 var item = this.findItemFromChild(e.getTarget());
20407 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
20412 onDblClick : function(e){
20413 var item = this.findItemFromChild(e.getTarget());
20415 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
20419 onItemClick : function(item, index, e)
20421 if(this.fireEvent("beforeclick", this, index, item, e) === false){
20424 if (this.toggleSelect) {
20425 var m = this.isSelected(item) ? 'unselect' : 'select';
20428 _t[m](item, true, false);
20431 if(this.multiSelect || this.singleSelect){
20432 if(this.multiSelect && e.shiftKey && this.lastSelection){
20433 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
20435 this.select(item, this.multiSelect && e.ctrlKey);
20436 this.lastSelection = item;
20439 if(!this.tickable){
20440 e.preventDefault();
20448 * Get the number of selected nodes.
20451 getSelectionCount : function(){
20452 return this.selections.length;
20456 * Get the currently selected nodes.
20457 * @return {Array} An array of HTMLElements
20459 getSelectedNodes : function(){
20460 return this.selections;
20464 * Get the indexes of the selected nodes.
20467 getSelectedIndexes : function(){
20468 var indexes = [], s = this.selections;
20469 for(var i = 0, len = s.length; i < len; i++){
20470 indexes.push(s[i].nodeIndex);
20476 * Clear all selections
20477 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
20479 clearSelections : function(suppressEvent){
20480 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
20481 this.cmp.elements = this.selections;
20482 this.cmp.removeClass(this.selectedClass);
20483 this.selections = [];
20484 if(!suppressEvent){
20485 this.fireEvent("selectionchange", this, this.selections);
20491 * Returns true if the passed node is selected
20492 * @param {HTMLElement/Number} node The node or node index
20493 * @return {Boolean}
20495 isSelected : function(node){
20496 var s = this.selections;
20500 node = this.getNode(node);
20501 return s.indexOf(node) !== -1;
20506 * @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
20507 * @param {Boolean} keepExisting (optional) true to keep existing selections
20508 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
20510 select : function(nodeInfo, keepExisting, suppressEvent){
20511 if(nodeInfo instanceof Array){
20513 this.clearSelections(true);
20515 for(var i = 0, len = nodeInfo.length; i < len; i++){
20516 this.select(nodeInfo[i], true, true);
20520 var node = this.getNode(nodeInfo);
20521 if(!node || this.isSelected(node)){
20522 return; // already selected.
20525 this.clearSelections(true);
20528 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
20529 Roo.fly(node).addClass(this.selectedClass);
20530 this.selections.push(node);
20531 if(!suppressEvent){
20532 this.fireEvent("selectionchange", this, this.selections);
20540 * @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
20541 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
20542 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
20544 unselect : function(nodeInfo, keepExisting, suppressEvent)
20546 if(nodeInfo instanceof Array){
20547 Roo.each(this.selections, function(s) {
20548 this.unselect(s, nodeInfo);
20552 var node = this.getNode(nodeInfo);
20553 if(!node || !this.isSelected(node)){
20554 //Roo.log("not selected");
20555 return; // not selected.
20559 Roo.each(this.selections, function(s) {
20561 Roo.fly(node).removeClass(this.selectedClass);
20568 this.selections= ns;
20569 this.fireEvent("selectionchange", this, this.selections);
20573 * Gets a template node.
20574 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
20575 * @return {HTMLElement} The node or null if it wasn't found
20577 getNode : function(nodeInfo){
20578 if(typeof nodeInfo == "string"){
20579 return document.getElementById(nodeInfo);
20580 }else if(typeof nodeInfo == "number"){
20581 return this.nodes[nodeInfo];
20587 * Gets a range template nodes.
20588 * @param {Number} startIndex
20589 * @param {Number} endIndex
20590 * @return {Array} An array of nodes
20592 getNodes : function(start, end){
20593 var ns = this.nodes;
20594 start = start || 0;
20595 end = typeof end == "undefined" ? ns.length - 1 : end;
20598 for(var i = start; i <= end; i++){
20602 for(var i = start; i >= end; i--){
20610 * Finds the index of the passed node
20611 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
20612 * @return {Number} The index of the node or -1
20614 indexOf : function(node){
20615 node = this.getNode(node);
20616 if(typeof node.nodeIndex == "number"){
20617 return node.nodeIndex;
20619 var ns = this.nodes;
20620 for(var i = 0, len = ns.length; i < len; i++){
20631 * based on jquery fullcalendar
20635 Roo.bootstrap = Roo.bootstrap || {};
20637 * @class Roo.bootstrap.Calendar
20638 * @extends Roo.bootstrap.Component
20639 * Bootstrap Calendar class
20640 * @cfg {Boolean} loadMask (true|false) default false
20641 * @cfg {Object} header generate the user specific header of the calendar, default false
20644 * Create a new Container
20645 * @param {Object} config The config object
20650 Roo.bootstrap.Calendar = function(config){
20651 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
20655 * Fires when a date is selected
20656 * @param {DatePicker} this
20657 * @param {Date} date The selected date
20661 * @event monthchange
20662 * Fires when the displayed month changes
20663 * @param {DatePicker} this
20664 * @param {Date} date The selected month
20666 'monthchange': true,
20668 * @event evententer
20669 * Fires when mouse over an event
20670 * @param {Calendar} this
20671 * @param {event} Event
20673 'evententer': true,
20675 * @event eventleave
20676 * Fires when the mouse leaves an
20677 * @param {Calendar} this
20680 'eventleave': true,
20682 * @event eventclick
20683 * Fires when the mouse click an
20684 * @param {Calendar} this
20693 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
20696 * @cfg {Roo.data.Store} store
20697 * The data source for the calendar
20701 * @cfg {Number} startDay
20702 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
20710 getAutoCreate : function(){
20713 var fc_button = function(name, corner, style, content ) {
20714 return Roo.apply({},{
20716 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
20718 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
20721 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
20732 style : 'width:100%',
20739 cls : 'fc-header-left',
20741 fc_button('prev', 'left', 'arrow', '‹' ),
20742 fc_button('next', 'right', 'arrow', '›' ),
20743 { tag: 'span', cls: 'fc-header-space' },
20744 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
20752 cls : 'fc-header-center',
20756 cls: 'fc-header-title',
20759 html : 'month / year'
20767 cls : 'fc-header-right',
20769 /* fc_button('month', 'left', '', 'month' ),
20770 fc_button('week', '', '', 'week' ),
20771 fc_button('day', 'right', '', 'day' )
20783 header = this.header;
20786 var cal_heads = function() {
20788 // fixme - handle this.
20790 for (var i =0; i < Date.dayNames.length; i++) {
20791 var d = Date.dayNames[i];
20794 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
20795 html : d.substring(0,3)
20799 ret[0].cls += ' fc-first';
20800 ret[6].cls += ' fc-last';
20803 var cal_cell = function(n) {
20806 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
20811 cls: 'fc-day-number',
20815 cls: 'fc-day-content',
20819 style: 'position: relative;' // height: 17px;
20831 var cal_rows = function() {
20834 for (var r = 0; r < 6; r++) {
20841 for (var i =0; i < Date.dayNames.length; i++) {
20842 var d = Date.dayNames[i];
20843 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
20846 row.cn[0].cls+=' fc-first';
20847 row.cn[0].cn[0].style = 'min-height:90px';
20848 row.cn[6].cls+=' fc-last';
20852 ret[0].cls += ' fc-first';
20853 ret[4].cls += ' fc-prev-last';
20854 ret[5].cls += ' fc-last';
20861 cls: 'fc-border-separate',
20862 style : 'width:100%',
20870 cls : 'fc-first fc-last',
20888 cls : 'fc-content',
20889 style : "position: relative;",
20892 cls : 'fc-view fc-view-month fc-grid',
20893 style : 'position: relative',
20894 unselectable : 'on',
20897 cls : 'fc-event-container',
20898 style : 'position:absolute;z-index:8;top:0;left:0;'
20916 initEvents : function()
20919 throw "can not find store for calendar";
20925 style: "text-align:center",
20929 style: "background-color:white;width:50%;margin:250 auto",
20933 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
20944 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
20946 var size = this.el.select('.fc-content', true).first().getSize();
20947 this.maskEl.setSize(size.width, size.height);
20948 this.maskEl.enableDisplayMode("block");
20949 if(!this.loadMask){
20950 this.maskEl.hide();
20953 this.store = Roo.factory(this.store, Roo.data);
20954 this.store.on('load', this.onLoad, this);
20955 this.store.on('beforeload', this.onBeforeLoad, this);
20959 this.cells = this.el.select('.fc-day',true);
20960 //Roo.log(this.cells);
20961 this.textNodes = this.el.query('.fc-day-number');
20962 this.cells.addClassOnOver('fc-state-hover');
20964 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
20965 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
20966 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
20967 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
20969 this.on('monthchange', this.onMonthChange, this);
20971 this.update(new Date().clearTime());
20974 resize : function() {
20975 var sz = this.el.getSize();
20977 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
20978 this.el.select('.fc-day-content div',true).setHeight(34);
20983 showPrevMonth : function(e){
20984 this.update(this.activeDate.add("mo", -1));
20986 showToday : function(e){
20987 this.update(new Date().clearTime());
20990 showNextMonth : function(e){
20991 this.update(this.activeDate.add("mo", 1));
20995 showPrevYear : function(){
20996 this.update(this.activeDate.add("y", -1));
21000 showNextYear : function(){
21001 this.update(this.activeDate.add("y", 1));
21006 update : function(date)
21008 var vd = this.activeDate;
21009 this.activeDate = date;
21010 // if(vd && this.el){
21011 // var t = date.getTime();
21012 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
21013 // Roo.log('using add remove');
21015 // this.fireEvent('monthchange', this, date);
21017 // this.cells.removeClass("fc-state-highlight");
21018 // this.cells.each(function(c){
21019 // if(c.dateValue == t){
21020 // c.addClass("fc-state-highlight");
21021 // setTimeout(function(){
21022 // try{c.dom.firstChild.focus();}catch(e){}
21032 var days = date.getDaysInMonth();
21034 var firstOfMonth = date.getFirstDateOfMonth();
21035 var startingPos = firstOfMonth.getDay()-this.startDay;
21037 if(startingPos < this.startDay){
21041 var pm = date.add(Date.MONTH, -1);
21042 var prevStart = pm.getDaysInMonth()-startingPos;
21044 this.cells = this.el.select('.fc-day',true);
21045 this.textNodes = this.el.query('.fc-day-number');
21046 this.cells.addClassOnOver('fc-state-hover');
21048 var cells = this.cells.elements;
21049 var textEls = this.textNodes;
21051 Roo.each(cells, function(cell){
21052 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
21055 days += startingPos;
21057 // convert everything to numbers so it's fast
21058 var day = 86400000;
21059 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
21062 //Roo.log(prevStart);
21064 var today = new Date().clearTime().getTime();
21065 var sel = date.clearTime().getTime();
21066 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
21067 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
21068 var ddMatch = this.disabledDatesRE;
21069 var ddText = this.disabledDatesText;
21070 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
21071 var ddaysText = this.disabledDaysText;
21072 var format = this.format;
21074 var setCellClass = function(cal, cell){
21078 //Roo.log('set Cell Class');
21080 var t = d.getTime();
21084 cell.dateValue = t;
21086 cell.className += " fc-today";
21087 cell.className += " fc-state-highlight";
21088 cell.title = cal.todayText;
21091 // disable highlight in other month..
21092 //cell.className += " fc-state-highlight";
21097 cell.className = " fc-state-disabled";
21098 cell.title = cal.minText;
21102 cell.className = " fc-state-disabled";
21103 cell.title = cal.maxText;
21107 if(ddays.indexOf(d.getDay()) != -1){
21108 cell.title = ddaysText;
21109 cell.className = " fc-state-disabled";
21112 if(ddMatch && format){
21113 var fvalue = d.dateFormat(format);
21114 if(ddMatch.test(fvalue)){
21115 cell.title = ddText.replace("%0", fvalue);
21116 cell.className = " fc-state-disabled";
21120 if (!cell.initialClassName) {
21121 cell.initialClassName = cell.dom.className;
21124 cell.dom.className = cell.initialClassName + ' ' + cell.className;
21129 for(; i < startingPos; i++) {
21130 textEls[i].innerHTML = (++prevStart);
21131 d.setDate(d.getDate()+1);
21133 cells[i].className = "fc-past fc-other-month";
21134 setCellClass(this, cells[i]);
21139 for(; i < days; i++){
21140 intDay = i - startingPos + 1;
21141 textEls[i].innerHTML = (intDay);
21142 d.setDate(d.getDate()+1);
21144 cells[i].className = ''; // "x-date-active";
21145 setCellClass(this, cells[i]);
21149 for(; i < 42; i++) {
21150 textEls[i].innerHTML = (++extraDays);
21151 d.setDate(d.getDate()+1);
21153 cells[i].className = "fc-future fc-other-month";
21154 setCellClass(this, cells[i]);
21157 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
21159 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
21161 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
21162 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
21164 if(totalRows != 6){
21165 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
21166 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
21169 this.fireEvent('monthchange', this, date);
21173 if(!this.internalRender){
21174 var main = this.el.dom.firstChild;
21175 var w = main.offsetWidth;
21176 this.el.setWidth(w + this.el.getBorderWidth("lr"));
21177 Roo.fly(main).setWidth(w);
21178 this.internalRender = true;
21179 // opera does not respect the auto grow header center column
21180 // then, after it gets a width opera refuses to recalculate
21181 // without a second pass
21182 if(Roo.isOpera && !this.secondPass){
21183 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
21184 this.secondPass = true;
21185 this.update.defer(10, this, [date]);
21192 findCell : function(dt) {
21193 dt = dt.clearTime().getTime();
21195 this.cells.each(function(c){
21196 //Roo.log("check " +c.dateValue + '?=' + dt);
21197 if(c.dateValue == dt){
21207 findCells : function(ev) {
21208 var s = ev.start.clone().clearTime().getTime();
21210 var e= ev.end.clone().clearTime().getTime();
21213 this.cells.each(function(c){
21214 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
21216 if(c.dateValue > e){
21219 if(c.dateValue < s){
21228 // findBestRow: function(cells)
21232 // for (var i =0 ; i < cells.length;i++) {
21233 // ret = Math.max(cells[i].rows || 0,ret);
21240 addItem : function(ev)
21242 // look for vertical location slot in
21243 var cells = this.findCells(ev);
21245 // ev.row = this.findBestRow(cells);
21247 // work out the location.
21251 for(var i =0; i < cells.length; i++) {
21253 cells[i].row = cells[0].row;
21256 cells[i].row = cells[i].row + 1;
21266 if (crow.start.getY() == cells[i].getY()) {
21268 crow.end = cells[i];
21285 cells[0].events.push(ev);
21287 this.calevents.push(ev);
21290 clearEvents: function() {
21292 if(!this.calevents){
21296 Roo.each(this.cells.elements, function(c){
21302 Roo.each(this.calevents, function(e) {
21303 Roo.each(e.els, function(el) {
21304 el.un('mouseenter' ,this.onEventEnter, this);
21305 el.un('mouseleave' ,this.onEventLeave, this);
21310 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
21316 renderEvents: function()
21320 this.cells.each(function(c) {
21329 if(c.row != c.events.length){
21330 r = 4 - (4 - (c.row - c.events.length));
21333 c.events = ev.slice(0, r);
21334 c.more = ev.slice(r);
21336 if(c.more.length && c.more.length == 1){
21337 c.events.push(c.more.pop());
21340 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
21344 this.cells.each(function(c) {
21346 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
21349 for (var e = 0; e < c.events.length; e++){
21350 var ev = c.events[e];
21351 var rows = ev.rows;
21353 for(var i = 0; i < rows.length; i++) {
21355 // how many rows should it span..
21358 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
21359 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
21361 unselectable : "on",
21364 cls: 'fc-event-inner',
21368 // cls: 'fc-event-time',
21369 // html : cells.length > 1 ? '' : ev.time
21373 cls: 'fc-event-title',
21374 html : String.format('{0}', ev.title)
21381 cls: 'ui-resizable-handle ui-resizable-e',
21382 html : '  '
21389 cfg.cls += ' fc-event-start';
21391 if ((i+1) == rows.length) {
21392 cfg.cls += ' fc-event-end';
21395 var ctr = _this.el.select('.fc-event-container',true).first();
21396 var cg = ctr.createChild(cfg);
21398 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
21399 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
21401 var r = (c.more.length) ? 1 : 0;
21402 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
21403 cg.setWidth(ebox.right - sbox.x -2);
21405 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
21406 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
21407 cg.on('click', _this.onEventClick, _this, ev);
21418 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
21419 style : 'position: absolute',
21420 unselectable : "on",
21423 cls: 'fc-event-inner',
21427 cls: 'fc-event-title',
21435 cls: 'ui-resizable-handle ui-resizable-e',
21436 html : '  '
21442 var ctr = _this.el.select('.fc-event-container',true).first();
21443 var cg = ctr.createChild(cfg);
21445 var sbox = c.select('.fc-day-content',true).first().getBox();
21446 var ebox = c.select('.fc-day-content',true).first().getBox();
21448 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
21449 cg.setWidth(ebox.right - sbox.x -2);
21451 cg.on('click', _this.onMoreEventClick, _this, c.more);
21461 onEventEnter: function (e, el,event,d) {
21462 this.fireEvent('evententer', this, el, event);
21465 onEventLeave: function (e, el,event,d) {
21466 this.fireEvent('eventleave', this, el, event);
21469 onEventClick: function (e, el,event,d) {
21470 this.fireEvent('eventclick', this, el, event);
21473 onMonthChange: function () {
21477 onMoreEventClick: function(e, el, more)
21481 this.calpopover.placement = 'right';
21482 this.calpopover.setTitle('More');
21484 this.calpopover.setContent('');
21486 var ctr = this.calpopover.el.select('.popover-content', true).first();
21488 Roo.each(more, function(m){
21490 cls : 'fc-event-hori fc-event-draggable',
21493 var cg = ctr.createChild(cfg);
21495 cg.on('click', _this.onEventClick, _this, m);
21498 this.calpopover.show(el);
21503 onLoad: function ()
21505 this.calevents = [];
21508 if(this.store.getCount() > 0){
21509 this.store.data.each(function(d){
21512 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
21513 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
21514 time : d.data.start_time,
21515 title : d.data.title,
21516 description : d.data.description,
21517 venue : d.data.venue
21522 this.renderEvents();
21524 if(this.calevents.length && this.loadMask){
21525 this.maskEl.hide();
21529 onBeforeLoad: function()
21531 this.clearEvents();
21533 this.maskEl.show();
21547 * @class Roo.bootstrap.Popover
21548 * @extends Roo.bootstrap.Component
21549 * @parent none builder
21550 * @children Roo.bootstrap.Component
21551 * Bootstrap Popover class
21552 * @cfg {String} html contents of the popover (or false to use children..)
21553 * @cfg {String} title of popover (or false to hide)
21554 * @cfg {String|function} (right|top|bottom|left|auto) placement how it is placed
21555 * @cfg {String} trigger click || hover (or false to trigger manually)
21556 * @cfg {Boolean} modal - popovers that are modal will mask the screen, and must be closed with another event.
21557 * @cfg {String|Boolean|Roo.Element} add click hander to trigger show over what element
21558 * - if false and it has a 'parent' then it will be automatically added to that element
21559 * - if string - Roo.get will be called
21560 * @cfg {Number} delay - delay before showing
21563 * Create a new Popover
21564 * @param {Object} config The config object
21567 Roo.bootstrap.Popover = function(config){
21568 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
21574 * After the popover show
21576 * @param {Roo.bootstrap.Popover} this
21581 * After the popover hide
21583 * @param {Roo.bootstrap.Popover} this
21589 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
21594 placement : 'right',
21595 trigger : 'hover', // hover
21601 can_build_overlaid : false,
21603 maskEl : false, // the mask element
21606 alignEl : false, // when show is called with an element - this get's stored.
21608 getChildContainer : function()
21610 return this.contentEl;
21613 getPopoverHeader : function()
21615 this.title = true; // flag not to hide it..
21616 this.headerEl.addClass('p-0');
21617 return this.headerEl
21621 getAutoCreate : function(){
21624 cls : 'popover roo-dynamic shadow roo-popover' + (this.modal ? '-modal' : ''),
21625 style: 'display:block',
21631 cls : 'popover-inner ',
21635 cls: 'popover-title popover-header',
21636 html : this.title === false ? '' : this.title
21639 cls : 'popover-content popover-body ' + (this.cls || ''),
21640 html : this.html || ''
21651 * @param {string} the title
21653 setTitle: function(str)
21657 this.headerEl.dom.innerHTML = str;
21662 * @param {string} the body content
21664 setContent: function(str)
21667 if (this.contentEl) {
21668 this.contentEl.dom.innerHTML = str;
21672 // as it get's added to the bottom of the page.
21673 onRender : function(ct, position)
21675 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
21680 var cfg = Roo.apply({}, this.getAutoCreate());
21684 cfg.cls += ' ' + this.cls;
21687 cfg.style = this.style;
21689 //Roo.log("adding to ");
21690 this.el = Roo.get(document.body).createChild(cfg, position);
21691 // Roo.log(this.el);
21694 this.contentEl = this.el.select('.popover-content',true).first();
21695 this.headerEl = this.el.select('.popover-title',true).first();
21698 if(typeof(this.items) != 'undefined'){
21699 var items = this.items;
21702 for(var i =0;i < items.length;i++) {
21703 nitems.push(this.addxtype(Roo.apply({}, items[i])));
21707 this.items = nitems;
21709 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
21710 Roo.EventManager.onWindowResize(this.resizeMask, this, true);
21717 resizeMask : function()
21719 this.maskEl.setSize(
21720 Roo.lib.Dom.getViewWidth(true),
21721 Roo.lib.Dom.getViewHeight(true)
21725 initEvents : function()
21729 Roo.bootstrap.Popover.register(this);
21732 this.arrowEl = this.el.select('.arrow',true).first();
21733 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY); // probably not needed as it's default in BS4
21734 this.el.enableDisplayMode('block');
21738 if (this.over === false && !this.parent()) {
21741 if (this.triggers === false) {
21746 var on_el = (this.over == 'parent' || this.over === false) ? this.parent().el : Roo.get(this.over);
21747 var triggers = this.trigger ? this.trigger.split(' ') : [];
21748 Roo.each(triggers, function(trigger) {
21750 if (trigger == 'click') {
21751 on_el.on('click', this.toggle, this);
21752 } else if (trigger != 'manual') {
21753 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
21754 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
21756 on_el.on(eventIn ,this.enter, this);
21757 on_el.on(eventOut, this.leave, this);
21767 toggle : function () {
21768 this.hoverState == 'in' ? this.leave() : this.enter();
21771 enter : function () {
21773 clearTimeout(this.timeout);
21775 this.hoverState = 'in';
21777 if (!this.delay || !this.delay.show) {
21782 this.timeout = setTimeout(function () {
21783 if (_t.hoverState == 'in') {
21786 }, this.delay.show)
21789 leave : function() {
21790 clearTimeout(this.timeout);
21792 this.hoverState = 'out';
21794 if (!this.delay || !this.delay.hide) {
21799 this.timeout = setTimeout(function () {
21800 if (_t.hoverState == 'out') {
21803 }, this.delay.hide)
21807 * update the position of the dialog
21808 * normally this is needed if the popover get's bigger - due to a Table reload etc..
21813 doAlign : function()
21816 if (this.alignEl) {
21817 this.updatePosition(this.placement, true);
21820 // this is usually just done by the builder = to show the popoup in the middle of the scren.
21821 var es = this.el.getSize();
21822 var x = Roo.lib.Dom.getViewWidth()/2;
21823 var y = Roo.lib.Dom.getViewHeight()/2;
21824 this.el.setXY([ x-(es.width/2), y-(es.height/2)] );
21836 * @param {Roo.Element|string|Boolean} - element to align and point to. (set align to [ pos, offset ])
21837 * @param {string} (left|right|top|bottom) position
21839 show : function (on_el, placement)
21841 this.placement = typeof(placement) == 'undefined' ? this.placement : placement;
21842 on_el = on_el || false; // default to false
21845 if (this.parent() && (this.over == 'parent' || (this.over === false))) {
21846 on_el = this.parent().el;
21847 } else if (this.over) {
21848 on_el = Roo.get(this.over);
21853 this.alignEl = Roo.get( on_el );
21856 this.render(document.body);
21862 if (this.title === false) {
21863 this.headerEl.hide();
21868 this.el.dom.style.display = 'block';
21872 //var arrow = this.el.select('.arrow',true).first();
21873 //arrow.set(align[2],
21875 this.el.addClass('in');
21879 this.hoverState = 'in';
21882 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
21883 this.maskEl.setStyle('z-index', Roo.bootstrap.Popover.zIndex++);
21884 this.maskEl.dom.style.display = 'block';
21885 this.maskEl.addClass('show');
21887 this.el.setStyle('z-index', Roo.bootstrap.Popover.zIndex++);
21889 this.fireEvent('show', this);
21893 * fire this manually after loading a grid in the table for example
21894 * @param {string} (left|right|top|bottom) where to try and put it (use false to use the last one)
21895 * @param {Boolean} try and move it if we cant get right position.
21897 updatePosition : function(placement, try_move)
21899 // allow for calling with no parameters
21900 placement = placement ? placement : this.placement;
21901 try_move = typeof(try_move) == 'undefined' ? true : try_move;
21903 this.el.removeClass([
21904 'fade','top','bottom', 'left', 'right','in',
21905 'bs-popover-top','bs-popover-bottom', 'bs-popover-left', 'bs-popover-right'
21907 this.el.addClass(placement + ' bs-popover-' + placement);
21909 if (!this.alignEl ) {
21913 switch (placement) {
21915 var exact = this.el.getAlignToXY(this.alignEl, 'tl-tr', [10,0]);
21916 var offset = this.el.getAlignToXY(this.alignEl, 'tl-tr?',[10,0]);
21917 if (!try_move || exact.equals(offset) || exact[0] == offset[0] ) {
21918 //normal display... or moved up/down.
21919 this.el.setXY(offset);
21920 var xy = this.alignEl.getAnchorXY('tr', false);
21922 this.arrowEl.setXY(xy);
21925 // continue through...
21926 return this.updatePosition('left', false);
21930 var exact = this.el.getAlignToXY(this.alignEl, 'tr-tl', [-10,0]);
21931 var offset = this.el.getAlignToXY(this.alignEl, 'tr-tl?',[-10,0]);
21932 if (!try_move || exact.equals(offset) || exact[0] == offset[0] ) {
21933 //normal display... or moved up/down.
21934 this.el.setXY(offset);
21935 var xy = this.alignEl.getAnchorXY('tl', false);
21936 xy[0]-=10;xy[1]+=5; // << fix me
21937 this.arrowEl.setXY(xy);
21941 return this.updatePosition('right', false);
21944 var exact = this.el.getAlignToXY(this.alignEl, 'b-t', [0,-10]);
21945 var offset = this.el.getAlignToXY(this.alignEl, 'b-t?',[0,-10]);
21946 if (!try_move || exact.equals(offset) || exact[1] == offset[1] ) {
21947 //normal display... or moved up/down.
21948 this.el.setXY(offset);
21949 var xy = this.alignEl.getAnchorXY('t', false);
21950 xy[1]-=10; // << fix me
21951 this.arrowEl.setXY(xy);
21955 return this.updatePosition('bottom', false);
21958 var exact = this.el.getAlignToXY(this.alignEl, 't-b', [0,10]);
21959 var offset = this.el.getAlignToXY(this.alignEl, 't-b?',[0,10]);
21960 if (!try_move || exact.equals(offset) || exact[1] == offset[1] ) {
21961 //normal display... or moved up/down.
21962 this.el.setXY(offset);
21963 var xy = this.alignEl.getAnchorXY('b', false);
21964 xy[1]+=2; // << fix me
21965 this.arrowEl.setXY(xy);
21969 return this.updatePosition('top', false);
21980 this.el.setXY([0,0]);
21981 this.el.removeClass('in');
21983 this.hoverState = null;
21984 this.maskEl.hide(); // always..
21985 this.fireEvent('hide', this);
21991 Roo.apply(Roo.bootstrap.Popover, {
21994 'left' : ['r-l', [-10,0], 'left bs-popover-left'],
21995 'right' : ['l-br', [10,0], 'right bs-popover-right'],
21996 'bottom' : ['t-b', [0,10], 'top bs-popover-top'],
21997 'top' : [ 'b-t', [0,-10], 'bottom bs-popover-bottom']
22002 clickHander : false,
22006 onMouseDown : function(e)
22008 if (this.popups.length && !e.getTarget(".roo-popover")) {
22009 /// what is nothing is showing..
22018 register : function(popup)
22020 if (!Roo.bootstrap.Popover.clickHandler) {
22021 Roo.bootstrap.Popover.clickHandler = Roo.get(document).on("mousedown", Roo.bootstrap.Popover.onMouseDown, Roo.bootstrap.Popover);
22023 // hide other popups.
22024 popup.on('show', Roo.bootstrap.Popover.onShow, popup);
22025 popup.on('hide', Roo.bootstrap.Popover.onHide, popup);
22026 this.hideAll(); //<< why?
22027 //this.popups.push(popup);
22029 hideAll : function()
22031 this.popups.forEach(function(p) {
22035 onShow : function() {
22036 Roo.bootstrap.Popover.popups.push(this);
22038 onHide : function() {
22039 Roo.bootstrap.Popover.popups.remove(this);
22044 * @class Roo.bootstrap.PopoverNav
22045 * @extends Roo.bootstrap.nav.Simplebar
22046 * @parent Roo.bootstrap.Popover
22047 * @children Roo.bootstrap.nav.Group Roo.bootstrap.Container
22049 * Bootstrap Popover header navigation class
22050 * FIXME? should this go under nav?
22054 * Create a new Popover Header Navigation
22055 * @param {Object} config The config object
22058 Roo.bootstrap.PopoverNav = function(config){
22059 Roo.bootstrap.PopoverNav.superclass.constructor.call(this, config);
22062 Roo.extend(Roo.bootstrap.PopoverNav, Roo.bootstrap.nav.Simplebar, {
22065 container_method : 'getPopoverHeader'
22083 * @class Roo.bootstrap.Progress
22084 * @extends Roo.bootstrap.Component
22085 * @children Roo.bootstrap.ProgressBar
22086 * Bootstrap Progress class
22087 * @cfg {Boolean} striped striped of the progress bar
22088 * @cfg {Boolean} active animated of the progress bar
22092 * Create a new Progress
22093 * @param {Object} config The config object
22096 Roo.bootstrap.Progress = function(config){
22097 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
22100 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
22105 getAutoCreate : function(){
22113 cfg.cls += ' progress-striped';
22117 cfg.cls += ' active';
22136 * @class Roo.bootstrap.ProgressBar
22137 * @extends Roo.bootstrap.Component
22138 * Bootstrap ProgressBar class
22139 * @cfg {Number} aria_valuenow aria-value now
22140 * @cfg {Number} aria_valuemin aria-value min
22141 * @cfg {Number} aria_valuemax aria-value max
22142 * @cfg {String} label label for the progress bar
22143 * @cfg {String} panel (success | info | warning | danger )
22144 * @cfg {String} role role of the progress bar
22145 * @cfg {String} sr_only text
22149 * Create a new ProgressBar
22150 * @param {Object} config The config object
22153 Roo.bootstrap.ProgressBar = function(config){
22154 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
22157 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
22161 aria_valuemax : 100,
22167 getAutoCreate : function()
22172 cls: 'progress-bar',
22173 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
22185 cfg.role = this.role;
22188 if(this.aria_valuenow){
22189 cfg['aria-valuenow'] = this.aria_valuenow;
22192 if(this.aria_valuemin){
22193 cfg['aria-valuemin'] = this.aria_valuemin;
22196 if(this.aria_valuemax){
22197 cfg['aria-valuemax'] = this.aria_valuemax;
22200 if(this.label && !this.sr_only){
22201 cfg.html = this.label;
22205 cfg.cls += ' progress-bar-' + this.panel;
22211 update : function(aria_valuenow)
22213 this.aria_valuenow = aria_valuenow;
22215 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
22223 * @class Roo.bootstrap.TabGroup
22224 * @extends Roo.bootstrap.Column
22225 * @children Roo.bootstrap.TabPanel
22226 * Bootstrap Column class
22227 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
22228 * @cfg {Boolean} carousel true to make the group behave like a carousel
22229 * @cfg {Boolean} bullets show bullets for the panels
22230 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
22231 * @cfg {Number} timer auto slide timer .. default 0 millisecond
22232 * @cfg {Boolean} showarrow (true|false) show arrow default true
22235 * Create a new TabGroup
22236 * @param {Object} config The config object
22239 Roo.bootstrap.TabGroup = function(config){
22240 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
22242 this.navId = Roo.id();
22245 Roo.bootstrap.TabGroup.register(this);
22249 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
22252 transition : false,
22257 slideOnTouch : false,
22260 getAutoCreate : function()
22262 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
22264 cfg.cls += ' tab-content';
22266 if (this.carousel) {
22267 cfg.cls += ' carousel slide';
22270 cls : 'carousel-inner',
22274 if(this.bullets && !Roo.isTouch){
22277 cls : 'carousel-bullets',
22281 if(this.bullets_cls){
22282 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
22289 cfg.cn[0].cn.push(bullets);
22292 if(this.showarrow){
22293 cfg.cn[0].cn.push({
22295 class : 'carousel-arrow',
22299 class : 'carousel-prev',
22303 class : 'fa fa-chevron-left'
22309 class : 'carousel-next',
22313 class : 'fa fa-chevron-right'
22326 initEvents: function()
22328 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
22329 // this.el.on("touchstart", this.onTouchStart, this);
22332 if(this.autoslide){
22335 this.slideFn = window.setInterval(function() {
22336 _this.showPanelNext();
22340 if(this.showarrow){
22341 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
22342 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
22348 // onTouchStart : function(e, el, o)
22350 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
22354 // this.showPanelNext();
22358 getChildContainer : function()
22360 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
22364 * register a Navigation item
22365 * @param {Roo.bootstrap.nav.Item} the navitem to add
22367 register : function(item)
22369 this.tabs.push( item);
22370 item.navId = this.navId; // not really needed..
22375 getActivePanel : function()
22378 Roo.each(this.tabs, function(t) {
22388 getPanelByName : function(n)
22391 Roo.each(this.tabs, function(t) {
22392 if (t.tabId == n) {
22400 indexOfPanel : function(p)
22403 Roo.each(this.tabs, function(t,i) {
22404 if (t.tabId == p.tabId) {
22413 * show a specific panel
22414 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
22415 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
22417 showPanel : function (pan)
22419 if(this.transition || typeof(pan) == 'undefined'){
22420 Roo.log("waiting for the transitionend");
22424 if (typeof(pan) == 'number') {
22425 pan = this.tabs[pan];
22428 if (typeof(pan) == 'string') {
22429 pan = this.getPanelByName(pan);
22432 var cur = this.getActivePanel();
22435 Roo.log('pan or acitve pan is undefined');
22439 if (pan.tabId == this.getActivePanel().tabId) {
22443 if (false === cur.fireEvent('beforedeactivate')) {
22447 if(this.bullets > 0 && !Roo.isTouch){
22448 this.setActiveBullet(this.indexOfPanel(pan));
22451 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
22453 //class="carousel-item carousel-item-next carousel-item-left"
22455 this.transition = true;
22456 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
22457 var lr = dir == 'next' ? 'left' : 'right';
22458 pan.el.addClass(dir); // or prev
22459 pan.el.addClass('carousel-item-' + dir); // or prev
22460 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
22461 cur.el.addClass(lr); // or right
22462 pan.el.addClass(lr);
22463 cur.el.addClass('carousel-item-' +lr); // or right
22464 pan.el.addClass('carousel-item-' +lr);
22468 cur.el.on('transitionend', function() {
22469 Roo.log("trans end?");
22471 pan.el.removeClass([lr,dir, 'carousel-item-' + lr, 'carousel-item-' + dir]);
22472 pan.setActive(true);
22474 cur.el.removeClass([lr, 'carousel-item-' + lr]);
22475 cur.setActive(false);
22477 _this.transition = false;
22479 }, this, { single: true } );
22484 cur.setActive(false);
22485 pan.setActive(true);
22490 showPanelNext : function()
22492 var i = this.indexOfPanel(this.getActivePanel());
22494 if (i >= this.tabs.length - 1 && !this.autoslide) {
22498 if (i >= this.tabs.length - 1 && this.autoslide) {
22502 this.showPanel(this.tabs[i+1]);
22505 showPanelPrev : function()
22507 var i = this.indexOfPanel(this.getActivePanel());
22509 if (i < 1 && !this.autoslide) {
22513 if (i < 1 && this.autoslide) {
22514 i = this.tabs.length;
22517 this.showPanel(this.tabs[i-1]);
22521 addBullet: function()
22523 if(!this.bullets || Roo.isTouch){
22526 var ctr = this.el.select('.carousel-bullets',true).first();
22527 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
22528 var bullet = ctr.createChild({
22529 cls : 'bullet bullet-' + i
22530 },ctr.dom.lastChild);
22535 bullet.on('click', (function(e, el, o, ii, t){
22537 e.preventDefault();
22539 this.showPanel(ii);
22541 if(this.autoslide && this.slideFn){
22542 clearInterval(this.slideFn);
22543 this.slideFn = window.setInterval(function() {
22544 _this.showPanelNext();
22548 }).createDelegate(this, [i, bullet], true));
22553 setActiveBullet : function(i)
22559 Roo.each(this.el.select('.bullet', true).elements, function(el){
22560 el.removeClass('selected');
22563 var bullet = this.el.select('.bullet-' + i, true).first();
22569 bullet.addClass('selected');
22580 Roo.apply(Roo.bootstrap.TabGroup, {
22584 * register a Navigation Group
22585 * @param {Roo.bootstrap.nav.Group} the navgroup to add
22587 register : function(navgrp)
22589 this.groups[navgrp.navId] = navgrp;
22593 * fetch a Navigation Group based on the navigation ID
22594 * if one does not exist , it will get created.
22595 * @param {string} the navgroup to add
22596 * @returns {Roo.bootstrap.nav.Group} the navgroup
22598 get: function(navId) {
22599 if (typeof(this.groups[navId]) == 'undefined') {
22600 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
22602 return this.groups[navId] ;
22617 * @class Roo.bootstrap.TabPanel
22618 * @extends Roo.bootstrap.Component
22619 * @children Roo.bootstrap.Component
22620 * Bootstrap TabPanel class
22621 * @cfg {Boolean} active panel active
22622 * @cfg {String} html panel content
22623 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
22624 * @cfg {String} navId The Roo.bootstrap.nav.Group which triggers show hide ()
22625 * @cfg {String} href click to link..
22626 * @cfg {Boolean} touchSlide if swiping slides tab to next panel (default off)
22630 * Create a new TabPanel
22631 * @param {Object} config The config object
22634 Roo.bootstrap.TabPanel = function(config){
22635 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
22639 * Fires when the active status changes
22640 * @param {Roo.bootstrap.TabPanel} this
22641 * @param {Boolean} state the new state
22646 * @event beforedeactivate
22647 * Fires before a tab is de-activated - can be used to do validation on a form.
22648 * @param {Roo.bootstrap.TabPanel} this
22649 * @return {Boolean} false if there is an error
22652 'beforedeactivate': true
22655 this.tabId = this.tabId || Roo.id();
22659 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
22666 touchSlide : false,
22667 getAutoCreate : function(){
22672 // item is needed for carousel - not sure if it has any effect otherwise
22673 cls: 'carousel-item tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
22674 html: this.html || ''
22678 cfg.cls += ' active';
22682 cfg.tabId = this.tabId;
22690 initEvents: function()
22692 var p = this.parent();
22694 this.navId = this.navId || p.navId;
22696 if (typeof(this.navId) != 'undefined') {
22697 // not really needed.. but just in case.. parent should be a NavGroup.
22698 var tg = Roo.bootstrap.TabGroup.get(this.navId);
22702 var i = tg.tabs.length - 1;
22704 if(this.active && tg.bullets > 0 && i < tg.bullets){
22705 tg.setActiveBullet(i);
22709 this.el.on('click', this.onClick, this);
22711 if(Roo.isTouch && this.touchSlide){
22712 this.el.on("touchstart", this.onTouchStart, this);
22713 this.el.on("touchmove", this.onTouchMove, this);
22714 this.el.on("touchend", this.onTouchEnd, this);
22719 onRender : function(ct, position)
22721 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
22724 setActive : function(state)
22726 Roo.log("panel - set active " + this.tabId + "=" + state);
22728 this.active = state;
22730 this.el.removeClass('active');
22732 } else if (!this.el.hasClass('active')) {
22733 this.el.addClass('active');
22736 this.fireEvent('changed', this, state);
22739 onClick : function(e)
22741 e.preventDefault();
22743 if(!this.href.length){
22747 window.location.href = this.href;
22756 onTouchStart : function(e)
22758 this.swiping = false;
22760 this.startX = e.browserEvent.touches[0].clientX;
22761 this.startY = e.browserEvent.touches[0].clientY;
22764 onTouchMove : function(e)
22766 this.swiping = true;
22768 this.endX = e.browserEvent.touches[0].clientX;
22769 this.endY = e.browserEvent.touches[0].clientY;
22772 onTouchEnd : function(e)
22779 var tabGroup = this.parent();
22781 if(this.endX > this.startX){ // swiping right
22782 tabGroup.showPanelPrev();
22786 if(this.startX > this.endX){ // swiping left
22787 tabGroup.showPanelNext();
22806 * @class Roo.bootstrap.form.DateField
22807 * @extends Roo.bootstrap.form.Input
22808 * Bootstrap DateField class
22809 * @cfg {Number} weekStart default 0
22810 * @cfg {String} viewMode default empty, (months|years)
22811 * @cfg {String} minViewMode default empty, (months|years)
22812 * @cfg {Number} startDate default -Infinity
22813 * @cfg {Number} endDate default Infinity
22814 * @cfg {Boolean} todayHighlight default false
22815 * @cfg {Boolean} todayBtn default false
22816 * @cfg {Boolean} calendarWeeks default false
22817 * @cfg {Object} daysOfWeekDisabled default empty
22818 * @cfg {Boolean} singleMode default false (true | false)
22820 * @cfg {Boolean} keyboardNavigation default true
22821 * @cfg {String} language default en
22824 * Create a new DateField
22825 * @param {Object} config The config object
22828 Roo.bootstrap.form.DateField = function(config){
22829 Roo.bootstrap.form.DateField.superclass.constructor.call(this, config);
22833 * Fires when this field show.
22834 * @param {Roo.bootstrap.form.DateField} this
22835 * @param {Mixed} date The date value
22840 * Fires when this field hide.
22841 * @param {Roo.bootstrap.form.DateField} this
22842 * @param {Mixed} date The date value
22847 * Fires when select a date.
22848 * @param {Roo.bootstrap.form.DateField} this
22849 * @param {Mixed} date The date value
22853 * @event beforeselect
22854 * Fires when before select a date.
22855 * @param {Roo.bootstrap.form.DateField} this
22856 * @param {Mixed} date The date value
22858 beforeselect : true
22862 Roo.extend(Roo.bootstrap.form.DateField, Roo.bootstrap.form.Input, {
22865 * @cfg {String} format
22866 * The default date format string which can be overriden for localization support. The format must be
22867 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
22871 * @cfg {String} altFormats
22872 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
22873 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
22875 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
22883 todayHighlight : false,
22889 keyboardNavigation: true,
22891 calendarWeeks: false,
22893 startDate: -Infinity,
22897 daysOfWeekDisabled: [],
22901 singleMode : false,
22903 UTCDate: function()
22905 return new Date(Date.UTC.apply(Date, arguments));
22908 UTCToday: function()
22910 var today = new Date();
22911 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
22914 getDate: function() {
22915 var d = this.getUTCDate();
22916 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
22919 getUTCDate: function() {
22923 setDate: function(d) {
22924 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
22927 setUTCDate: function(d) {
22929 this.setValue(this.formatDate(this.date));
22932 onRender: function(ct, position)
22935 Roo.bootstrap.form.DateField.superclass.onRender.call(this, ct, position);
22937 this.language = this.language || 'en';
22938 this.language = this.language in Roo.bootstrap.form.DateField.dates ? this.language : this.language.split('-')[0];
22939 this.language = this.language in Roo.bootstrap.form.DateField.dates ? this.language : "en";
22941 this.isRTL = Roo.bootstrap.form.DateField.dates[this.language].rtl || false;
22942 this.format = this.format || 'm/d/y';
22943 this.isInline = false;
22944 this.isInput = true;
22945 this.component = this.el.select('.add-on', true).first() || false;
22946 this.component = (this.component && this.component.length === 0) ? false : this.component;
22947 this.hasInput = this.component && this.inputEl().length;
22949 if (typeof(this.minViewMode === 'string')) {
22950 switch (this.minViewMode) {
22952 this.minViewMode = 1;
22955 this.minViewMode = 2;
22958 this.minViewMode = 0;
22963 if (typeof(this.viewMode === 'string')) {
22964 switch (this.viewMode) {
22977 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.form.DateField.template);
22979 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.form.DateField.template);
22981 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
22983 this.picker().on('mousedown', this.onMousedown, this);
22984 this.picker().on('click', this.onClick, this);
22986 this.picker().addClass('datepicker-dropdown');
22988 this.startViewMode = this.viewMode;
22990 if(this.singleMode){
22991 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
22992 v.setVisibilityMode(Roo.Element.DISPLAY);
22996 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
22997 v.setStyle('width', '189px');
23001 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
23002 if(!this.calendarWeeks){
23007 v.dom.innerHTML = Roo.bootstrap.form.DateField.dates[this.language].today;
23008 v.attr('colspan', function(i, val){
23009 return parseInt(val) + 1;
23014 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
23016 this.setStartDate(this.startDate);
23017 this.setEndDate(this.endDate);
23019 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
23026 if(this.isInline) {
23031 picker : function()
23033 return this.pickerEl;
23034 // return this.el.select('.datepicker', true).first();
23037 fillDow: function()
23039 var dowCnt = this.weekStart;
23048 if(this.calendarWeeks){
23056 while (dowCnt < this.weekStart + 7) {
23060 html: Roo.bootstrap.form.DateField.dates[this.language].daysMin[(dowCnt++)%7]
23064 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
23067 fillMonths: function()
23070 var months = this.picker().select('>.datepicker-months td', true).first();
23072 months.dom.innerHTML = '';
23078 html: Roo.bootstrap.form.DateField.dates[this.language].monthsShort[i++]
23081 months.createChild(month);
23088 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;
23090 if (this.date < this.startDate) {
23091 this.viewDate = new Date(this.startDate);
23092 } else if (this.date > this.endDate) {
23093 this.viewDate = new Date(this.endDate);
23095 this.viewDate = new Date(this.date);
23103 var d = new Date(this.viewDate),
23104 year = d.getUTCFullYear(),
23105 month = d.getUTCMonth(),
23106 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
23107 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
23108 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
23109 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
23110 currentDate = this.date && this.date.valueOf(),
23111 today = this.UTCToday();
23113 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.form.DateField.dates[this.language].months[month]+' '+year;
23115 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.form.DateField.dates[this.language].today;
23117 // this.picker.select('>tfoot th.today').
23118 // .text(dates[this.language].today)
23119 // .toggle(this.todayBtn !== false);
23121 this.updateNavArrows();
23124 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
23126 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
23128 prevMonth.setUTCDate(day);
23130 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
23132 var nextMonth = new Date(prevMonth);
23134 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
23136 nextMonth = nextMonth.valueOf();
23138 var fillMonths = false;
23140 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
23142 while(prevMonth.valueOf() <= nextMonth) {
23145 if (prevMonth.getUTCDay() === this.weekStart) {
23147 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
23155 if(this.calendarWeeks){
23156 // ISO 8601: First week contains first thursday.
23157 // ISO also states week starts on Monday, but we can be more abstract here.
23159 // Start of current week: based on weekstart/current date
23160 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
23161 // Thursday of this week
23162 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
23163 // First Thursday of year, year from thursday
23164 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
23165 // Calendar week: ms between thursdays, div ms per day, div 7 days
23166 calWeek = (th - yth) / 864e5 / 7 + 1;
23168 fillMonths.cn.push({
23176 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
23178 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
23181 if (this.todayHighlight &&
23182 prevMonth.getUTCFullYear() == today.getFullYear() &&
23183 prevMonth.getUTCMonth() == today.getMonth() &&
23184 prevMonth.getUTCDate() == today.getDate()) {
23185 clsName += ' today';
23188 if (currentDate && prevMonth.valueOf() === currentDate) {
23189 clsName += ' active';
23192 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
23193 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
23194 clsName += ' disabled';
23197 fillMonths.cn.push({
23199 cls: 'day ' + clsName,
23200 html: prevMonth.getDate()
23203 prevMonth.setDate(prevMonth.getDate()+1);
23206 var currentYear = this.date && this.date.getUTCFullYear();
23207 var currentMonth = this.date && this.date.getUTCMonth();
23209 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
23211 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
23212 v.removeClass('active');
23214 if(currentYear === year && k === currentMonth){
23215 v.addClass('active');
23218 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
23219 v.addClass('disabled');
23225 year = parseInt(year/10, 10) * 10;
23227 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
23229 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
23232 for (var i = -1; i < 11; i++) {
23233 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
23235 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
23243 showMode: function(dir)
23246 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
23249 Roo.each(this.picker().select('>div',true).elements, function(v){
23250 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
23253 this.picker().select('>.datepicker-'+Roo.bootstrap.form.DateField.modes[this.viewMode].clsName, true).first().show();
23258 if(this.isInline) {
23262 this.picker().removeClass(['bottom', 'top']);
23264 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
23266 * place to the top of element!
23270 this.picker().addClass('top');
23271 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
23276 this.picker().addClass('bottom');
23278 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
23281 parseDate : function(value)
23283 if(!value || value instanceof Date){
23286 var v = Date.parseDate(value, this.format);
23287 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
23288 v = Date.parseDate(value, 'Y-m-d');
23290 if(!v && this.altFormats){
23291 if(!this.altFormatsArray){
23292 this.altFormatsArray = this.altFormats.split("|");
23294 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
23295 v = Date.parseDate(value, this.altFormatsArray[i]);
23301 formatDate : function(date, fmt)
23303 return (!date || !(date instanceof Date)) ?
23304 date : date.dateFormat(fmt || this.format);
23307 onFocus : function()
23309 Roo.bootstrap.form.DateField.superclass.onFocus.call(this);
23313 onBlur : function()
23315 Roo.bootstrap.form.DateField.superclass.onBlur.call(this);
23317 var d = this.inputEl().getValue();
23324 showPopup : function()
23326 this.picker().show();
23330 this.fireEvent('showpopup', this, this.date);
23333 hidePopup : function()
23335 if(this.isInline) {
23338 this.picker().hide();
23339 this.viewMode = this.startViewMode;
23342 this.fireEvent('hidepopup', this, this.date);
23346 onMousedown: function(e)
23348 e.stopPropagation();
23349 e.preventDefault();
23354 Roo.bootstrap.form.DateField.superclass.keyup.call(this);
23358 setValue: function(v)
23360 if(this.fireEvent('beforeselect', this, v) !== false){
23361 var d = new Date(this.parseDate(v) ).clearTime();
23363 if(isNaN(d.getTime())){
23364 this.date = this.viewDate = '';
23365 Roo.bootstrap.form.DateField.superclass.setValue.call(this, '');
23369 v = this.formatDate(d);
23371 Roo.bootstrap.form.DateField.superclass.setValue.call(this, v);
23373 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
23377 this.fireEvent('select', this, this.date);
23381 getValue: function()
23383 return this.formatDate(this.date);
23386 fireKey: function(e)
23388 if (!this.picker().isVisible()){
23389 if (e.keyCode == 27) { // allow escape to hide and re-show picker
23395 var dateChanged = false,
23397 newDate, newViewDate;
23402 e.preventDefault();
23406 if (!this.keyboardNavigation) {
23409 dir = e.keyCode == 37 ? -1 : 1;
23412 newDate = this.moveYear(this.date, dir);
23413 newViewDate = this.moveYear(this.viewDate, dir);
23414 } else if (e.shiftKey){
23415 newDate = this.moveMonth(this.date, dir);
23416 newViewDate = this.moveMonth(this.viewDate, dir);
23418 newDate = new Date(this.date);
23419 newDate.setUTCDate(this.date.getUTCDate() + dir);
23420 newViewDate = new Date(this.viewDate);
23421 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
23423 if (this.dateWithinRange(newDate)){
23424 this.date = newDate;
23425 this.viewDate = newViewDate;
23426 this.setValue(this.formatDate(this.date));
23428 e.preventDefault();
23429 dateChanged = true;
23434 if (!this.keyboardNavigation) {
23437 dir = e.keyCode == 38 ? -1 : 1;
23439 newDate = this.moveYear(this.date, dir);
23440 newViewDate = this.moveYear(this.viewDate, dir);
23441 } else if (e.shiftKey){
23442 newDate = this.moveMonth(this.date, dir);
23443 newViewDate = this.moveMonth(this.viewDate, dir);
23445 newDate = new Date(this.date);
23446 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
23447 newViewDate = new Date(this.viewDate);
23448 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
23450 if (this.dateWithinRange(newDate)){
23451 this.date = newDate;
23452 this.viewDate = newViewDate;
23453 this.setValue(this.formatDate(this.date));
23455 e.preventDefault();
23456 dateChanged = true;
23460 this.setValue(this.formatDate(this.date));
23462 e.preventDefault();
23465 this.setValue(this.formatDate(this.date));
23479 onClick: function(e)
23481 e.stopPropagation();
23482 e.preventDefault();
23484 var target = e.getTarget();
23486 if(target.nodeName.toLowerCase() === 'i'){
23487 target = Roo.get(target).dom.parentNode;
23490 var nodeName = target.nodeName;
23491 var className = target.className;
23492 var html = target.innerHTML;
23493 //Roo.log(nodeName);
23495 switch(nodeName.toLowerCase()) {
23497 switch(className) {
23503 var dir = Roo.bootstrap.form.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
23504 switch(this.viewMode){
23506 this.viewDate = this.moveMonth(this.viewDate, dir);
23510 this.viewDate = this.moveYear(this.viewDate, dir);
23516 var date = new Date();
23517 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
23519 this.setValue(this.formatDate(this.date));
23526 if (className.indexOf('disabled') < 0) {
23527 if (!this.viewDate) {
23528 this.viewDate = new Date();
23530 this.viewDate.setUTCDate(1);
23531 if (className.indexOf('month') > -1) {
23532 this.viewDate.setUTCMonth(Roo.bootstrap.form.DateField.dates[this.language].monthsShort.indexOf(html));
23534 var year = parseInt(html, 10) || 0;
23535 this.viewDate.setUTCFullYear(year);
23539 if(this.singleMode){
23540 this.setValue(this.formatDate(this.viewDate));
23551 //Roo.log(className);
23552 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
23553 var day = parseInt(html, 10) || 1;
23554 var year = (this.viewDate || new Date()).getUTCFullYear(),
23555 month = (this.viewDate || new Date()).getUTCMonth();
23557 if (className.indexOf('old') > -1) {
23564 } else if (className.indexOf('new') > -1) {
23572 //Roo.log([year,month,day]);
23573 this.date = this.UTCDate(year, month, day,0,0,0,0);
23574 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
23576 //Roo.log(this.formatDate(this.date));
23577 this.setValue(this.formatDate(this.date));
23584 setStartDate: function(startDate)
23586 this.startDate = startDate || -Infinity;
23587 if (this.startDate !== -Infinity) {
23588 this.startDate = this.parseDate(this.startDate);
23591 this.updateNavArrows();
23594 setEndDate: function(endDate)
23596 this.endDate = endDate || Infinity;
23597 if (this.endDate !== Infinity) {
23598 this.endDate = this.parseDate(this.endDate);
23601 this.updateNavArrows();
23604 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
23606 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
23607 if (typeof(this.daysOfWeekDisabled) !== 'object') {
23608 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
23610 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
23611 return parseInt(d, 10);
23614 this.updateNavArrows();
23617 updateNavArrows: function()
23619 if(this.singleMode){
23623 var d = new Date(this.viewDate),
23624 year = d.getUTCFullYear(),
23625 month = d.getUTCMonth();
23627 Roo.each(this.picker().select('.prev', true).elements, function(v){
23629 switch (this.viewMode) {
23632 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
23638 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
23645 Roo.each(this.picker().select('.next', true).elements, function(v){
23647 switch (this.viewMode) {
23650 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
23656 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
23664 moveMonth: function(date, dir)
23669 var new_date = new Date(date.valueOf()),
23670 day = new_date.getUTCDate(),
23671 month = new_date.getUTCMonth(),
23672 mag = Math.abs(dir),
23674 dir = dir > 0 ? 1 : -1;
23677 // If going back one month, make sure month is not current month
23678 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
23680 return new_date.getUTCMonth() == month;
23682 // If going forward one month, make sure month is as expected
23683 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
23685 return new_date.getUTCMonth() != new_month;
23687 new_month = month + dir;
23688 new_date.setUTCMonth(new_month);
23689 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
23690 if (new_month < 0 || new_month > 11) {
23691 new_month = (new_month + 12) % 12;
23694 // For magnitudes >1, move one month at a time...
23695 for (var i=0; i<mag; i++) {
23696 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
23697 new_date = this.moveMonth(new_date, dir);
23699 // ...then reset the day, keeping it in the new month
23700 new_month = new_date.getUTCMonth();
23701 new_date.setUTCDate(day);
23703 return new_month != new_date.getUTCMonth();
23706 // Common date-resetting loop -- if date is beyond end of month, make it
23709 new_date.setUTCDate(--day);
23710 new_date.setUTCMonth(new_month);
23715 moveYear: function(date, dir)
23717 return this.moveMonth(date, dir*12);
23720 dateWithinRange: function(date)
23722 return date >= this.startDate && date <= this.endDate;
23728 this.picker().remove();
23731 validateValue : function(value)
23733 if(this.getVisibilityEl().hasClass('hidden')){
23737 if(value.length < 1) {
23738 if(this.allowBlank){
23744 if(value.length < this.minLength){
23747 if(value.length > this.maxLength){
23751 var vt = Roo.form.VTypes;
23752 if(!vt[this.vtype](value, this)){
23756 if(typeof this.validator == "function"){
23757 var msg = this.validator(value);
23763 if(this.regex && !this.regex.test(value)){
23767 if(typeof(this.parseDate(value)) == 'undefined'){
23771 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
23775 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
23785 this.date = this.viewDate = '';
23787 Roo.bootstrap.form.DateField.superclass.setValue.call(this, '');
23792 Roo.apply(Roo.bootstrap.form.DateField, {
23803 html: '<i class="fa fa-arrow-left"/>'
23813 html: '<i class="fa fa-arrow-right"/>'
23855 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
23856 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
23857 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
23858 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
23859 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
23872 navFnc: 'FullYear',
23877 navFnc: 'FullYear',
23882 Roo.apply(Roo.bootstrap.form.DateField, {
23886 cls: 'datepicker dropdown-menu roo-dynamic shadow',
23890 cls: 'datepicker-days',
23894 cls: 'table-condensed',
23896 Roo.bootstrap.form.DateField.head,
23900 Roo.bootstrap.form.DateField.footer
23907 cls: 'datepicker-months',
23911 cls: 'table-condensed',
23913 Roo.bootstrap.form.DateField.head,
23914 Roo.bootstrap.form.DateField.content,
23915 Roo.bootstrap.form.DateField.footer
23922 cls: 'datepicker-years',
23926 cls: 'table-condensed',
23928 Roo.bootstrap.form.DateField.head,
23929 Roo.bootstrap.form.DateField.content,
23930 Roo.bootstrap.form.DateField.footer
23949 * @class Roo.bootstrap.form.TimeField
23950 * @extends Roo.bootstrap.form.Input
23951 * Bootstrap DateField class
23955 * Create a new TimeField
23956 * @param {Object} config The config object
23959 Roo.bootstrap.form.TimeField = function(config){
23960 Roo.bootstrap.form.TimeField.superclass.constructor.call(this, config);
23964 * Fires when this field show.
23965 * @param {Roo.bootstrap.form.DateField} thisthis
23966 * @param {Mixed} date The date value
23971 * Fires when this field hide.
23972 * @param {Roo.bootstrap.form.DateField} this
23973 * @param {Mixed} date The date value
23978 * Fires when select a date.
23979 * @param {Roo.bootstrap.form.DateField} this
23980 * @param {Mixed} date The date value
23986 Roo.extend(Roo.bootstrap.form.TimeField, Roo.bootstrap.form.Input, {
23989 * @cfg {String} format
23990 * The default time format string which can be overriden for localization support. The format must be
23991 * valid according to {@link Date#parseDate} (defaults to 'H:i').
23995 getAutoCreate : function()
23997 this.after = '<i class="fa far fa-clock"></i>';
23998 return Roo.bootstrap.form.TimeField.superclass.getAutoCreate.call(this);
24002 onRender: function(ct, position)
24005 Roo.bootstrap.form.TimeField.superclass.onRender.call(this, ct, position);
24007 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.form.TimeField.template);
24009 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
24011 this.pop = this.picker().select('>.datepicker-time',true).first();
24012 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
24014 this.picker().on('mousedown', this.onMousedown, this);
24015 this.picker().on('click', this.onClick, this);
24017 this.picker().addClass('datepicker-dropdown');
24022 this.pop.select('.hours-up', true).first().on('click', this.onIncrementHours, this);
24023 this.pop.select('.hours-down', true).first().on('click', this.onDecrementHours, this);
24024 this.pop.select('.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
24025 this.pop.select('.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
24026 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
24027 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
24031 fireKey: function(e){
24032 if (!this.picker().isVisible()){
24033 if (e.keyCode == 27) { // allow escape to hide and re-show picker
24039 e.preventDefault();
24047 this.onTogglePeriod();
24050 this.onIncrementMinutes();
24053 this.onDecrementMinutes();
24062 onClick: function(e) {
24063 e.stopPropagation();
24064 e.preventDefault();
24067 picker : function()
24069 return this.pickerEl;
24072 fillTime: function()
24074 var time = this.pop.select('tbody', true).first();
24076 time.dom.innerHTML = '';
24091 cls: 'hours-up fa fas fa-chevron-up'
24111 cls: 'minutes-up fa fas fa-chevron-up'
24132 cls: 'timepicker-hour',
24147 cls: 'timepicker-minute',
24162 cls: 'btn btn-primary period',
24184 cls: 'hours-down fa fas fa-chevron-down'
24204 cls: 'minutes-down fa fas fa-chevron-down'
24222 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
24229 var hours = this.time.getHours();
24230 var minutes = this.time.getMinutes();
24243 hours = hours - 12;
24247 hours = '0' + hours;
24251 minutes = '0' + minutes;
24254 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
24255 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
24256 this.pop.select('button', true).first().dom.innerHTML = period;
24262 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
24264 var cls = ['bottom'];
24266 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
24273 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
24277 //this.picker().setXY(20000,20000);
24278 this.picker().addClass(cls.join('-'));
24282 Roo.each(cls, function(c){
24287 _this.picker().alignTo(_this.inputEl(), "tr-br", [0, 10], false);
24288 //_this.picker().setTop(_this.inputEl().getHeight());
24292 _this.picker().alignTo(_this.inputEl(), "br-tr", [0, 10], false);
24294 //_this.picker().setTop(0 - _this.picker().getHeight());
24299 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
24303 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
24311 onFocus : function()
24313 Roo.bootstrap.form.TimeField.superclass.onFocus.call(this);
24317 onBlur : function()
24319 Roo.bootstrap.form.TimeField.superclass.onBlur.call(this);
24325 this.picker().show();
24330 this.fireEvent('show', this, this.date);
24335 this.picker().hide();
24338 this.fireEvent('hide', this, this.date);
24341 setTime : function()
24344 this.setValue(this.time.format(this.format));
24346 this.fireEvent('select', this, this.date);
24351 onMousedown: function(e){
24352 e.stopPropagation();
24353 e.preventDefault();
24356 onIncrementHours: function()
24358 Roo.log('onIncrementHours');
24359 this.time = this.time.add(Date.HOUR, 1);
24364 onDecrementHours: function()
24366 Roo.log('onDecrementHours');
24367 this.time = this.time.add(Date.HOUR, -1);
24371 onIncrementMinutes: function()
24373 Roo.log('onIncrementMinutes');
24374 this.time = this.time.add(Date.MINUTE, 1);
24378 onDecrementMinutes: function()
24380 Roo.log('onDecrementMinutes');
24381 this.time = this.time.add(Date.MINUTE, -1);
24385 onTogglePeriod: function()
24387 Roo.log('onTogglePeriod');
24388 this.time = this.time.add(Date.HOUR, 12);
24396 Roo.apply(Roo.bootstrap.form.TimeField, {
24400 cls: 'datepicker dropdown-menu',
24404 cls: 'datepicker-time',
24408 cls: 'table-condensed',
24437 cls: 'btn btn-info ok',
24465 * @class Roo.bootstrap.form.MonthField
24466 * @extends Roo.bootstrap.form.Input
24467 * Bootstrap MonthField class
24469 * @cfg {String} language default en
24472 * Create a new MonthField
24473 * @param {Object} config The config object
24476 Roo.bootstrap.form.MonthField = function(config){
24477 Roo.bootstrap.form.MonthField.superclass.constructor.call(this, config);
24482 * Fires when this field show.
24483 * @param {Roo.bootstrap.form.MonthField} this
24484 * @param {Mixed} date The date value
24489 * Fires when this field hide.
24490 * @param {Roo.bootstrap.form.MonthField} this
24491 * @param {Mixed} date The date value
24496 * Fires when select a date.
24497 * @param {Roo.bootstrap.form.MonthField} this
24498 * @param {String} oldvalue The old value
24499 * @param {String} newvalue The new value
24505 Roo.extend(Roo.bootstrap.form.MonthField, Roo.bootstrap.form.Input, {
24507 onRender: function(ct, position)
24510 Roo.bootstrap.form.MonthField.superclass.onRender.call(this, ct, position);
24512 this.language = this.language || 'en';
24513 this.language = this.language in Roo.bootstrap.form.MonthField.dates ? this.language : this.language.split('-')[0];
24514 this.language = this.language in Roo.bootstrap.form.MonthField.dates ? this.language : "en";
24516 this.isRTL = Roo.bootstrap.form.MonthField.dates[this.language].rtl || false;
24517 this.isInline = false;
24518 this.isInput = true;
24519 this.component = this.el.select('.add-on', true).first() || false;
24520 this.component = (this.component && this.component.length === 0) ? false : this.component;
24521 this.hasInput = this.component && this.inputEL().length;
24523 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.form.MonthField.template);
24525 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
24527 this.picker().on('mousedown', this.onMousedown, this);
24528 this.picker().on('click', this.onClick, this);
24530 this.picker().addClass('datepicker-dropdown');
24532 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
24533 v.setStyle('width', '189px');
24540 if(this.isInline) {
24546 setValue: function(v, suppressEvent)
24548 var o = this.getValue();
24550 Roo.bootstrap.form.MonthField.superclass.setValue.call(this, v);
24554 if(suppressEvent !== true){
24555 this.fireEvent('select', this, o, v);
24560 getValue: function()
24565 onClick: function(e)
24567 e.stopPropagation();
24568 e.preventDefault();
24570 var target = e.getTarget();
24572 if(target.nodeName.toLowerCase() === 'i'){
24573 target = Roo.get(target).dom.parentNode;
24576 var nodeName = target.nodeName;
24577 var className = target.className;
24578 var html = target.innerHTML;
24580 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
24584 this.vIndex = Roo.bootstrap.form.MonthField.dates[this.language].monthsShort.indexOf(html);
24586 this.setValue(Roo.bootstrap.form.MonthField.dates[this.language].months[this.vIndex]);
24592 picker : function()
24594 return this.pickerEl;
24597 fillMonths: function()
24600 var months = this.picker().select('>.datepicker-months td', true).first();
24602 months.dom.innerHTML = '';
24608 html: Roo.bootstrap.form.MonthField.dates[this.language].monthsShort[i++]
24611 months.createChild(month);
24620 if(typeof(this.vIndex) == 'undefined' && this.value.length){
24621 this.vIndex = Roo.bootstrap.form.MonthField.dates[this.language].months.indexOf(this.value);
24624 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
24625 e.removeClass('active');
24627 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
24628 e.addClass('active');
24635 if(this.isInline) {
24639 this.picker().removeClass(['bottom', 'top']);
24641 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
24643 * place to the top of element!
24647 this.picker().addClass('top');
24648 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
24653 this.picker().addClass('bottom');
24655 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
24658 onFocus : function()
24660 Roo.bootstrap.form.MonthField.superclass.onFocus.call(this);
24664 onBlur : function()
24666 Roo.bootstrap.form.MonthField.superclass.onBlur.call(this);
24668 var d = this.inputEl().getValue();
24677 this.picker().show();
24678 this.picker().select('>.datepicker-months', true).first().show();
24682 this.fireEvent('show', this, this.date);
24687 if(this.isInline) {
24690 this.picker().hide();
24691 this.fireEvent('hide', this, this.date);
24695 onMousedown: function(e)
24697 e.stopPropagation();
24698 e.preventDefault();
24703 Roo.bootstrap.form.MonthField.superclass.keyup.call(this);
24707 fireKey: function(e)
24709 if (!this.picker().isVisible()){
24710 if (e.keyCode == 27) {// allow escape to hide and re-show picker
24721 e.preventDefault();
24725 dir = e.keyCode == 37 ? -1 : 1;
24727 this.vIndex = this.vIndex + dir;
24729 if(this.vIndex < 0){
24733 if(this.vIndex > 11){
24737 if(isNaN(this.vIndex)){
24741 this.setValue(Roo.bootstrap.form.MonthField.dates[this.language].months[this.vIndex]);
24747 dir = e.keyCode == 38 ? -1 : 1;
24749 this.vIndex = this.vIndex + dir * 4;
24751 if(this.vIndex < 0){
24755 if(this.vIndex > 11){
24759 if(isNaN(this.vIndex)){
24763 this.setValue(Roo.bootstrap.form.MonthField.dates[this.language].months[this.vIndex]);
24768 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
24769 this.setValue(Roo.bootstrap.form.MonthField.dates[this.language].months[this.vIndex]);
24773 e.preventDefault();
24776 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
24777 this.setValue(Roo.bootstrap.form.MonthField.dates[this.language].months[this.vIndex]);
24793 this.picker().remove();
24798 Roo.apply(Roo.bootstrap.form.MonthField, {
24817 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
24818 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
24823 Roo.apply(Roo.bootstrap.form.MonthField, {
24827 cls: 'datepicker dropdown-menu roo-dynamic',
24831 cls: 'datepicker-months',
24835 cls: 'table-condensed',
24837 Roo.bootstrap.form.DateField.content
24857 * @class Roo.bootstrap.form.CheckBox
24858 * @extends Roo.bootstrap.form.Input
24859 * Bootstrap CheckBox class
24861 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
24862 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
24863 * @cfg {String} boxLabel The text that appears beside the checkbox
24864 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
24865 * @cfg {Boolean} checked initnal the element
24866 * @cfg {Boolean} inline inline the element (default false)
24867 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
24868 * @cfg {String} tooltip label tooltip
24871 * Create a new CheckBox
24872 * @param {Object} config The config object
24875 Roo.bootstrap.form.CheckBox = function(config){
24876 Roo.bootstrap.form.CheckBox.superclass.constructor.call(this, config);
24881 * Fires when the element is checked or unchecked.
24882 * @param {Roo.bootstrap.form.CheckBox} this This input
24883 * @param {Boolean} checked The new checked value
24888 * Fires when the element is click.
24889 * @param {Roo.bootstrap.form.CheckBox} this This input
24896 Roo.extend(Roo.bootstrap.form.CheckBox, Roo.bootstrap.form.Input, {
24898 inputType: 'checkbox',
24907 // checkbox success does not make any sense really..
24912 getAutoCreate : function()
24914 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
24920 cfg.cls = 'form-group form-check ' + this.inputType; //input-group
24923 cfg.cls += ' ' + this.inputType + '-inline form-check-inline';
24929 type : this.inputType,
24930 value : this.inputValue,
24931 cls : 'roo-' + this.inputType, //'form-box',
24932 placeholder : this.placeholder || ''
24936 if(this.inputType != 'radio'){
24940 cls : 'roo-hidden-value',
24941 value : this.checked ? this.inputValue : this.valueOff
24946 if (this.weight) { // Validity check?
24947 cfg.cls += " " + this.inputType + "-" + this.weight;
24950 if (this.disabled) {
24951 input.disabled=true;
24955 input.checked = this.checked;
24960 input.name = this.name;
24962 if(this.inputType != 'radio'){
24963 hidden.name = this.name;
24964 input.name = '_hidden_' + this.name;
24969 input.cls += ' input-' + this.size;
24974 ['xs','sm','md','lg'].map(function(size){
24975 if (settings[size]) {
24976 cfg.cls += ' col-' + size + '-' + settings[size];
24980 var inputblock = input;
24982 if (this.before || this.after) {
24985 cls : 'input-group',
24990 inputblock.cn.push({
24992 cls : 'input-group-addon',
24997 inputblock.cn.push(input);
24999 if(this.inputType != 'radio'){
25000 inputblock.cn.push(hidden);
25004 inputblock.cn.push({
25006 cls : 'input-group-addon',
25012 var boxLabelCfg = false;
25018 //'for': id, // box label is handled by onclick - so no for...
25020 html: this.boxLabel
25023 boxLabelCfg.tooltip = this.tooltip;
25029 if (align ==='left' && this.fieldLabel.length) {
25030 // Roo.log("left and has label");
25035 cls : 'control-label',
25036 html : this.fieldLabel
25047 cfg.cn[1].cn.push(boxLabelCfg);
25050 if(this.labelWidth > 12){
25051 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
25054 if(this.labelWidth < 13 && this.labelmd == 0){
25055 this.labelmd = this.labelWidth;
25058 if(this.labellg > 0){
25059 cfg.cn[0].cls += ' col-lg-' + this.labellg;
25060 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
25063 if(this.labelmd > 0){
25064 cfg.cn[0].cls += ' col-md-' + this.labelmd;
25065 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
25068 if(this.labelsm > 0){
25069 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
25070 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
25073 if(this.labelxs > 0){
25074 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
25075 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
25078 } else if ( this.fieldLabel.length) {
25079 // Roo.log(" label");
25083 tag: this.boxLabel ? 'span' : 'label',
25085 cls: 'control-label box-input-label',
25086 //cls : 'input-group-addon',
25087 html : this.fieldLabel
25094 cfg.cn.push(boxLabelCfg);
25099 // Roo.log(" no label && no align");
25100 cfg.cn = [ inputblock ] ;
25102 cfg.cn.push(boxLabelCfg);
25110 if(this.inputType != 'radio'){
25111 cfg.cn.push(hidden);
25119 * return the real input element.
25121 inputEl: function ()
25123 return this.el.select('input.roo-' + this.inputType,true).first();
25125 hiddenEl: function ()
25127 return this.el.select('input.roo-hidden-value',true).first();
25130 labelEl: function()
25132 return this.el.select('label.control-label',true).first();
25134 /* depricated... */
25138 return this.labelEl();
25141 boxLabelEl: function()
25143 return this.el.select('label.box-label',true).first();
25146 initEvents : function()
25148 // Roo.bootstrap.form.CheckBox.superclass.initEvents.call(this);
25150 this.inputEl().on('click', this.onClick, this);
25152 if (this.boxLabel) {
25153 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
25156 this.startValue = this.getValue();
25159 Roo.bootstrap.form.CheckBox.register(this);
25163 onClick : function(e)
25165 if(this.fireEvent('click', this, e) !== false){
25166 this.setChecked(!this.checked);
25171 setChecked : function(state,suppressEvent)
25173 this.startValue = this.getValue();
25175 if(this.inputType == 'radio'){
25177 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
25178 e.dom.checked = false;
25181 this.inputEl().dom.checked = true;
25183 this.inputEl().dom.value = this.inputValue;
25185 if(suppressEvent !== true){
25186 this.fireEvent('check', this, true);
25194 this.checked = state;
25196 this.inputEl().dom.checked = state;
25199 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
25201 if(suppressEvent !== true){
25202 this.fireEvent('check', this, state);
25208 getValue : function()
25210 if(this.inputType == 'radio'){
25211 return this.getGroupValue();
25214 return this.hiddenEl().dom.value;
25218 getGroupValue : function()
25220 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
25224 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
25227 setValue : function(v,suppressEvent)
25229 if(this.inputType == 'radio'){
25230 this.setGroupValue(v, suppressEvent);
25234 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
25239 setGroupValue : function(v, suppressEvent)
25241 this.startValue = this.getValue();
25243 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
25244 e.dom.checked = false;
25246 if(e.dom.value == v){
25247 e.dom.checked = true;
25251 if(suppressEvent !== true){
25252 this.fireEvent('check', this, true);
25260 validate : function()
25262 if(this.getVisibilityEl().hasClass('hidden')){
25268 (this.inputType == 'radio' && this.validateRadio()) ||
25269 (this.inputType == 'checkbox' && this.validateCheckbox())
25275 this.markInvalid();
25279 validateRadio : function()
25281 if(this.getVisibilityEl().hasClass('hidden')){
25285 if(this.allowBlank){
25291 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
25292 if(!e.dom.checked){
25304 validateCheckbox : function()
25307 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
25308 //return (this.getValue() == this.inputValue) ? true : false;
25311 var group = Roo.bootstrap.form.CheckBox.get(this.groupId);
25319 for(var i in group){
25320 if(group[i].el.isVisible(true)){
25328 for(var i in group){
25333 r = (group[i].getValue() == group[i].inputValue) ? true : false;
25340 * Mark this field as valid
25342 markValid : function()
25346 this.fireEvent('valid', this);
25348 var label = Roo.bootstrap.form.FieldLabel.get(this.name + '-group');
25351 label = Roo.bootstrap.form.FieldLabel.get(this.groupId + '-group');
25358 if(this.inputType == 'radio'){
25359 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
25360 var fg = e.findParent('.form-group', false, true);
25361 if (Roo.bootstrap.version == 3) {
25362 fg.removeClass([_this.invalidClass, _this.validClass]);
25363 fg.addClass(_this.validClass);
25365 fg.removeClass(['is-valid', 'is-invalid']);
25366 fg.addClass('is-valid');
25374 var fg = this.el.findParent('.form-group', false, true);
25375 if (Roo.bootstrap.version == 3) {
25376 fg.removeClass([this.invalidClass, this.validClass]);
25377 fg.addClass(this.validClass);
25379 fg.removeClass(['is-valid', 'is-invalid']);
25380 fg.addClass('is-valid');
25385 var group = Roo.bootstrap.form.CheckBox.get(this.groupId);
25391 for(var i in group){
25392 var fg = group[i].el.findParent('.form-group', false, true);
25393 if (Roo.bootstrap.version == 3) {
25394 fg.removeClass([this.invalidClass, this.validClass]);
25395 fg.addClass(this.validClass);
25397 fg.removeClass(['is-valid', 'is-invalid']);
25398 fg.addClass('is-valid');
25404 * Mark this field as invalid
25405 * @param {String} msg The validation message
25407 markInvalid : function(msg)
25409 if(this.allowBlank){
25415 this.fireEvent('invalid', this, msg);
25417 var label = Roo.bootstrap.form.FieldLabel.get(this.name + '-group');
25420 label = Roo.bootstrap.form.FieldLabel.get(this.groupId + '-group');
25424 label.markInvalid();
25427 if(this.inputType == 'radio'){
25429 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
25430 var fg = e.findParent('.form-group', false, true);
25431 if (Roo.bootstrap.version == 3) {
25432 fg.removeClass([_this.invalidClass, _this.validClass]);
25433 fg.addClass(_this.invalidClass);
25435 fg.removeClass(['is-invalid', 'is-valid']);
25436 fg.addClass('is-invalid');
25444 var fg = this.el.findParent('.form-group', false, true);
25445 if (Roo.bootstrap.version == 3) {
25446 fg.removeClass([_this.invalidClass, _this.validClass]);
25447 fg.addClass(_this.invalidClass);
25449 fg.removeClass(['is-invalid', 'is-valid']);
25450 fg.addClass('is-invalid');
25455 var group = Roo.bootstrap.form.CheckBox.get(this.groupId);
25461 for(var i in group){
25462 var fg = group[i].el.findParent('.form-group', false, true);
25463 if (Roo.bootstrap.version == 3) {
25464 fg.removeClass([_this.invalidClass, _this.validClass]);
25465 fg.addClass(_this.invalidClass);
25467 fg.removeClass(['is-invalid', 'is-valid']);
25468 fg.addClass('is-invalid');
25474 clearInvalid : function()
25476 Roo.bootstrap.form.Input.prototype.clearInvalid.call(this);
25478 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
25480 var label = Roo.bootstrap.form.FieldLabel.get(this.name + '-group');
25482 if (label && label.iconEl) {
25483 label.iconEl.removeClass([ label.validClass, label.invalidClass ]);
25484 label.iconEl.removeClass(['is-invalid', 'is-valid']);
25488 disable : function()
25490 if(this.inputType != 'radio'){
25491 Roo.bootstrap.form.CheckBox.superclass.disable.call(this);
25498 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
25499 _this.getActionEl().addClass(this.disabledClass);
25500 e.dom.disabled = true;
25504 this.disabled = true;
25505 this.fireEvent("disable", this);
25509 enable : function()
25511 if(this.inputType != 'radio'){
25512 Roo.bootstrap.form.CheckBox.superclass.enable.call(this);
25519 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
25520 _this.getActionEl().removeClass(this.disabledClass);
25521 e.dom.disabled = false;
25525 this.disabled = false;
25526 this.fireEvent("enable", this);
25530 setBoxLabel : function(v)
25535 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
25541 Roo.apply(Roo.bootstrap.form.CheckBox, {
25546 * register a CheckBox Group
25547 * @param {Roo.bootstrap.form.CheckBox} the CheckBox to add
25549 register : function(checkbox)
25551 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
25552 this.groups[checkbox.groupId] = {};
25555 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
25559 this.groups[checkbox.groupId][checkbox.name] = checkbox;
25563 * fetch a CheckBox Group based on the group ID
25564 * @param {string} the group ID
25565 * @returns {Roo.bootstrap.form.CheckBox} the CheckBox group
25567 get: function(groupId) {
25568 if (typeof(this.groups[groupId]) == 'undefined') {
25572 return this.groups[groupId] ;
25585 * @class Roo.bootstrap.form.Radio
25586 * @extends Roo.bootstrap.Component
25587 * Bootstrap Radio class
25588 * @cfg {String} boxLabel - the label associated
25589 * @cfg {String} value - the value of radio
25592 * Create a new Radio
25593 * @param {Object} config The config object
25595 Roo.bootstrap.form.Radio = function(config){
25596 Roo.bootstrap.form.Radio.superclass.constructor.call(this, config);
25600 Roo.extend(Roo.bootstrap.form.Radio, Roo.bootstrap.Component, {
25606 getAutoCreate : function()
25610 cls : 'form-group radio',
25615 html : this.boxLabel
25623 initEvents : function()
25625 this.parent().register(this);
25627 this.el.on('click', this.onClick, this);
25631 onClick : function(e)
25633 if(this.parent().fireEvent('click', this.parent(), this, e) !== false){
25634 this.setChecked(true);
25638 setChecked : function(state, suppressEvent)
25640 this.parent().setValue(this.value, suppressEvent);
25644 setBoxLabel : function(v)
25649 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
25664 * @class Roo.bootstrap.form.SecurePass
25665 * @extends Roo.bootstrap.form.Input
25666 * Bootstrap SecurePass class
25670 * Create a new SecurePass
25671 * @param {Object} config The config object
25674 Roo.bootstrap.form.SecurePass = function (config) {
25675 // these go here, so the translation tool can replace them..
25677 PwdEmpty: "Please type a password, and then retype it to confirm.",
25678 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
25679 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
25680 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
25681 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
25682 FNInPwd: "Your password can't contain your first name. Please type a different password.",
25683 LNInPwd: "Your password can't contain your last name. Please type a different password.",
25684 TooWeak: "Your password is Too Weak."
25686 this.meterLabel = "Password strength:";
25687 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
25688 this.meterClass = [
25689 "roo-password-meter-tooweak",
25690 "roo-password-meter-weak",
25691 "roo-password-meter-medium",
25692 "roo-password-meter-strong",
25693 "roo-password-meter-grey"
25698 Roo.bootstrap.form.SecurePass.superclass.constructor.call(this, config);
25701 Roo.extend(Roo.bootstrap.form.SecurePass, Roo.bootstrap.form.Input, {
25703 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
25705 * PwdEmpty: "Please type a password, and then retype it to confirm.",
25706 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
25707 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
25708 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
25709 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
25710 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
25711 * LNInPwd: "Your password can't contain your last name. Please type a different password."
25721 * @cfg {String/Object} Label for the strength meter (defaults to
25722 * 'Password strength:')
25727 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
25728 * ['Weak', 'Medium', 'Strong'])
25731 pwdStrengths: false,
25744 initEvents: function ()
25746 Roo.bootstrap.form.SecurePass.superclass.initEvents.call(this);
25748 if (this.el.is('input[type=password]') && Roo.isSafari) {
25749 this.el.on('keydown', this.SafariOnKeyDown, this);
25752 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
25755 onRender: function (ct, position)
25757 Roo.bootstrap.form.SecurePass.superclass.onRender.call(this, ct, position);
25758 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
25759 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
25761 this.trigger.createChild({
25766 cls: 'roo-password-meter-grey col-xs-12',
25769 //width: this.meterWidth + 'px'
25773 cls: 'roo-password-meter-text'
25779 if (this.hideTrigger) {
25780 this.trigger.setDisplayed(false);
25782 this.setSize(this.width || '', this.height || '');
25785 onDestroy: function ()
25787 if (this.trigger) {
25788 this.trigger.removeAllListeners();
25789 this.trigger.remove();
25792 this.wrap.remove();
25794 Roo.bootstrap.form.TriggerField.superclass.onDestroy.call(this);
25797 checkStrength: function ()
25799 var pwd = this.inputEl().getValue();
25800 if (pwd == this._lastPwd) {
25805 if (this.ClientSideStrongPassword(pwd)) {
25807 } else if (this.ClientSideMediumPassword(pwd)) {
25809 } else if (this.ClientSideWeakPassword(pwd)) {
25815 Roo.log('strength1: ' + strength);
25817 //var pm = this.trigger.child('div/div/div').dom;
25818 var pm = this.trigger.child('div/div');
25819 pm.removeClass(this.meterClass);
25820 pm.addClass(this.meterClass[strength]);
25823 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
25825 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
25827 this._lastPwd = pwd;
25831 Roo.bootstrap.form.SecurePass.superclass.reset.call(this);
25833 this._lastPwd = '';
25835 var pm = this.trigger.child('div/div');
25836 pm.removeClass(this.meterClass);
25837 pm.addClass('roo-password-meter-grey');
25840 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
25843 this.inputEl().dom.type='password';
25846 validateValue: function (value)
25848 if (!Roo.bootstrap.form.SecurePass.superclass.validateValue.call(this, value)) {
25851 if (value.length == 0) {
25852 if (this.allowBlank) {
25853 this.clearInvalid();
25857 this.markInvalid(this.errors.PwdEmpty);
25858 this.errorMsg = this.errors.PwdEmpty;
25866 if (!value.match(/[\x21-\x7e]+/)) {
25867 this.markInvalid(this.errors.PwdBadChar);
25868 this.errorMsg = this.errors.PwdBadChar;
25871 if (value.length < 6) {
25872 this.markInvalid(this.errors.PwdShort);
25873 this.errorMsg = this.errors.PwdShort;
25876 if (value.length > 16) {
25877 this.markInvalid(this.errors.PwdLong);
25878 this.errorMsg = this.errors.PwdLong;
25882 if (this.ClientSideStrongPassword(value)) {
25884 } else if (this.ClientSideMediumPassword(value)) {
25886 } else if (this.ClientSideWeakPassword(value)) {
25893 if (strength < 2) {
25894 //this.markInvalid(this.errors.TooWeak);
25895 this.errorMsg = this.errors.TooWeak;
25900 console.log('strength2: ' + strength);
25902 //var pm = this.trigger.child('div/div/div').dom;
25904 var pm = this.trigger.child('div/div');
25905 pm.removeClass(this.meterClass);
25906 pm.addClass(this.meterClass[strength]);
25908 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
25910 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
25912 this.errorMsg = '';
25916 CharacterSetChecks: function (type)
25919 this.fResult = false;
25922 isctype: function (character, type)
25925 case this.kCapitalLetter:
25926 if (character >= 'A' && character <= 'Z') {
25931 case this.kSmallLetter:
25932 if (character >= 'a' && character <= 'z') {
25938 if (character >= '0' && character <= '9') {
25943 case this.kPunctuation:
25944 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
25955 IsLongEnough: function (pwd, size)
25957 return !(pwd == null || isNaN(size) || pwd.length < size);
25960 SpansEnoughCharacterSets: function (word, nb)
25962 if (!this.IsLongEnough(word, nb))
25967 var characterSetChecks = new Array(
25968 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
25969 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
25972 for (var index = 0; index < word.length; ++index) {
25973 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
25974 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
25975 characterSetChecks[nCharSet].fResult = true;
25982 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
25983 if (characterSetChecks[nCharSet].fResult) {
25988 if (nCharSets < nb) {
25994 ClientSideStrongPassword: function (pwd)
25996 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
25999 ClientSideMediumPassword: function (pwd)
26001 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
26004 ClientSideWeakPassword: function (pwd)
26006 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
26010 Roo.htmleditor = {};
26013 * @class Roo.htmleditor.Filter
26014 * Base Class for filtering htmleditor stuff. - do not use this directly - extend it.
26015 * @cfg {DomElement} node The node to iterate and filter
26016 * @cfg {boolean|String|Array} tag Tags to replace
26018 * Create a new Filter.
26019 * @param {Object} config Configuration options
26024 Roo.htmleditor.Filter = function(cfg) {
26025 Roo.apply(this.cfg);
26026 // this does not actually call walk as it's really just a abstract class
26030 Roo.htmleditor.Filter.prototype = {
26036 // overrride to do replace comments.
26037 replaceComment : false,
26039 // overrride to do replace or do stuff with tags..
26040 replaceTag : false,
26042 walk : function(dom)
26044 Roo.each( Array.from(dom.childNodes), function( e ) {
26047 case e.nodeType == 8 && this.replaceComment !== false: // comment
26048 this.replaceComment(e);
26051 case e.nodeType != 1: //not a node.
26054 case this.tag === true: // everything
26055 case e.tagName.indexOf(":") > -1 && typeof(this.tag) == 'object' && this.tag.indexOf(":") > -1:
26056 case e.tagName.indexOf(":") > -1 && typeof(this.tag) == 'string' && this.tag == ":":
26057 case typeof(this.tag) == 'object' && this.tag.indexOf(e.tagName) > -1: // array and it matches.
26058 case typeof(this.tag) == 'string' && this.tag == e.tagName: // array and it matches.
26059 if (this.replaceTag && false === this.replaceTag(e)) {
26062 if (e.hasChildNodes()) {
26067 default: // tags .. that do not match.
26068 if (e.hasChildNodes()) {
26078 removeNodeKeepChildren : function( node)
26081 ar = Array.from(node.childNodes);
26082 for (var i = 0; i < ar.length; i++) {
26084 node.removeChild(ar[i]);
26085 // what if we need to walk these???
26086 node.parentNode.insertBefore(ar[i], node);
26089 node.parentNode.removeChild(node);
26094 * @class Roo.htmleditor.FilterAttributes
26095 * clean attributes and styles including http:// etc.. in attribute
26097 * Run a new Attribute Filter
26098 * @param {Object} config Configuration options
26100 Roo.htmleditor.FilterAttributes = function(cfg)
26102 Roo.apply(this, cfg);
26103 this.attrib_black = this.attrib_black || [];
26104 this.attrib_white = this.attrib_white || [];
26106 this.attrib_clean = this.attrib_clean || [];
26107 this.style_white = this.style_white || [];
26108 this.style_black = this.style_black || [];
26109 this.walk(cfg.node);
26112 Roo.extend(Roo.htmleditor.FilterAttributes, Roo.htmleditor.Filter,
26114 tag: true, // all tags
26116 attrib_black : false, // array
26117 attrib_clean : false,
26118 attrib_white : false,
26120 style_white : false,
26121 style_black : false,
26124 replaceTag : function(node)
26126 if (!node.attributes || !node.attributes.length) {
26130 for (var i = node.attributes.length-1; i > -1 ; i--) {
26131 var a = node.attributes[i];
26133 if (this.attrib_white.length && this.attrib_white.indexOf(a.name.toLowerCase()) < 0) {
26134 node.removeAttribute(a.name);
26140 if (a.name.toLowerCase().substr(0,2)=='on') {
26141 node.removeAttribute(a.name);
26146 if (this.attrib_black.indexOf(a.name.toLowerCase()) > -1) {
26147 node.removeAttribute(a.name);
26150 if (this.attrib_clean.indexOf(a.name.toLowerCase()) > -1) {
26151 this.cleanAttr(node,a.name,a.value); // fixme..
26154 if (a.name == 'style') {
26155 this.cleanStyle(node,a.name,a.value);
26158 /// clean up MS crap..
26159 // tecnically this should be a list of valid class'es..
26162 if (a.name == 'class') {
26163 if (a.value.match(/^Mso/)) {
26164 node.removeAttribute('class');
26167 if (a.value.match(/^body$/)) {
26168 node.removeAttribute('class');
26178 return true; // clean children
26181 cleanAttr: function(node, n,v)
26184 if (v.match(/^\./) || v.match(/^\//)) {
26187 if (v.match(/^(http|https):\/\//)
26188 || v.match(/^mailto:/)
26189 || v.match(/^ftp:/)
26190 || v.match(/^data:/)
26194 if (v.match(/^#/)) {
26197 if (v.match(/^\{/)) { // allow template editing.
26200 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
26201 node.removeAttribute(n);
26204 cleanStyle : function(node, n,v)
26206 if (v.match(/expression/)) { //XSS?? should we even bother..
26207 node.removeAttribute(n);
26211 var parts = v.split(/;/);
26214 Roo.each(parts, function(p) {
26215 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
26219 var l = p.split(':').shift().replace(/\s+/g,'');
26220 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
26222 if ( this.style_black.length && (this.style_black.indexOf(l) > -1 || this.style_black.indexOf(l.toLowerCase()) > -1)) {
26226 // only allow 'c whitelisted system attributes'
26227 if ( this.style_white.length && style_white.indexOf(l) < 0 && style_white.indexOf(l.toLowerCase()) < 0 ) {
26235 if (clean.length) {
26236 node.setAttribute(n, clean.join(';'));
26238 node.removeAttribute(n);
26247 * @class Roo.htmleditor.FilterBlack
26248 * remove blacklisted elements.
26250 * Run a new Blacklisted Filter
26251 * @param {Object} config Configuration options
26254 Roo.htmleditor.FilterBlack = function(cfg)
26256 Roo.apply(this, cfg);
26257 this.walk(cfg.node);
26260 Roo.extend(Roo.htmleditor.FilterBlack, Roo.htmleditor.Filter,
26262 tag : true, // all elements.
26264 replaceTag : function(n)
26266 n.parentNode.removeChild(n);
26270 * @class Roo.htmleditor.FilterComment
26273 * Run a new Comments Filter
26274 * @param {Object} config Configuration options
26276 Roo.htmleditor.FilterComment = function(cfg)
26278 this.walk(cfg.node);
26281 Roo.extend(Roo.htmleditor.FilterComment, Roo.htmleditor.Filter,
26284 replaceComment : function(n)
26286 n.parentNode.removeChild(n);
26289 * @class Roo.htmleditor.FilterKeepChildren
26290 * remove tags but keep children
26292 * Run a new Keep Children Filter
26293 * @param {Object} config Configuration options
26296 Roo.htmleditor.FilterKeepChildren = function(cfg)
26298 Roo.apply(this, cfg);
26299 if (this.tag === false) {
26300 return; // dont walk.. (you can use this to use this just to do a child removal on a single tag )
26303 if ((typeof(this.tag) == 'object' && this.tag.indexOf(":") > -1)) {
26304 this.cleanNamespace = true;
26307 this.walk(cfg.node);
26310 Roo.extend(Roo.htmleditor.FilterKeepChildren, Roo.htmleditor.FilterBlack,
26312 cleanNamespace : false, // should really be an option, rather than using ':' inside of this tag.
26314 replaceTag : function(node)
26316 // walk children...
26317 //Roo.log(node.tagName);
26318 var ar = Array.from(node.childNodes);
26321 for (var i = 0; i < ar.length; i++) {
26323 if (e.nodeType == 1) {
26325 (typeof(this.tag) == 'object' && this.tag.indexOf(e.tagName) > -1)
26326 || // array and it matches
26327 (typeof(this.tag) == 'string' && this.tag == e.tagName)
26329 (e.tagName.indexOf(":") > -1 && typeof(this.tag) == 'object' && this.tag.indexOf(":") > -1)
26331 (e.tagName.indexOf(":") > -1 && typeof(this.tag) == 'string' && this.tag == ":")
26333 this.replaceTag(ar[i]); // child is blacklisted as well...
26338 ar = Array.from(node.childNodes);
26339 for (var i = 0; i < ar.length; i++) {
26341 node.removeChild(ar[i]);
26342 // what if we need to walk these???
26343 node.parentNode.insertBefore(ar[i], node);
26344 if (this.tag !== false) {
26349 //Roo.log("REMOVE:" + node.tagName);
26350 node.parentNode.removeChild(node);
26351 return false; // don't walk children
26356 * @class Roo.htmleditor.FilterParagraph
26357 * paragraphs cause a nightmare for shared content - this filter is designed to be called ? at various points when editing
26358 * like on 'push' to remove the <p> tags and replace them with line breaks.
26360 * Run a new Paragraph Filter
26361 * @param {Object} config Configuration options
26364 Roo.htmleditor.FilterParagraph = function(cfg)
26366 // no need to apply config.
26367 this.walk(cfg.node);
26370 Roo.extend(Roo.htmleditor.FilterParagraph, Roo.htmleditor.Filter,
26377 replaceTag : function(node)
26380 if (node.childNodes.length == 1 &&
26381 node.childNodes[0].nodeType == 3 &&
26382 node.childNodes[0].textContent.trim().length < 1
26384 // remove and replace with '<BR>';
26385 node.parentNode.replaceChild(node.ownerDocument.createElement('BR'),node);
26386 return false; // no need to walk..
26388 var ar = Array.from(node.childNodes);
26389 for (var i = 0; i < ar.length; i++) {
26390 node.removeChild(ar[i]);
26391 // what if we need to walk these???
26392 node.parentNode.insertBefore(ar[i], node);
26394 // now what about this?
26398 node.parentNode.insertBefore(node.ownerDocument.createElement('BR'), node);
26399 node.parentNode.insertBefore(node.ownerDocument.createElement('BR'), node);
26400 node.parentNode.removeChild(node);
26407 * @class Roo.htmleditor.FilterSpan
26408 * filter span's with no attributes out..
26410 * Run a new Span Filter
26411 * @param {Object} config Configuration options
26414 Roo.htmleditor.FilterSpan = function(cfg)
26416 // no need to apply config.
26417 this.walk(cfg.node);
26420 Roo.extend(Roo.htmleditor.FilterSpan, Roo.htmleditor.FilterKeepChildren,
26426 replaceTag : function(node)
26428 if (node.attributes && node.attributes.length > 0) {
26429 return true; // walk if there are any.
26431 Roo.htmleditor.FilterKeepChildren.prototype.replaceTag.call(this, node);
26437 * @class Roo.htmleditor.FilterTableWidth
26438 try and remove table width data - as that frequently messes up other stuff.
26440 * was cleanTableWidths.
26442 * Quite often pasting from word etc.. results in tables with column and widths.
26443 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
26446 * Run a new Table Filter
26447 * @param {Object} config Configuration options
26450 Roo.htmleditor.FilterTableWidth = function(cfg)
26452 // no need to apply config.
26453 this.tag = ['TABLE', 'TD', 'TR', 'TH', 'THEAD', 'TBODY' ];
26454 this.walk(cfg.node);
26457 Roo.extend(Roo.htmleditor.FilterTableWidth, Roo.htmleditor.Filter,
26462 replaceTag: function(node) {
26466 if (node.hasAttribute('width')) {
26467 node.removeAttribute('width');
26471 if (node.hasAttribute("style")) {
26474 var styles = node.getAttribute("style").split(";");
26476 Roo.each(styles, function(s) {
26477 if (!s.match(/:/)) {
26480 var kv = s.split(":");
26481 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
26484 // what ever is left... we allow.
26487 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
26488 if (!nstyle.length) {
26489 node.removeAttribute('style');
26493 return true; // continue doing children..
26496 * @class Roo.htmleditor.FilterWord
26497 * try and clean up all the mess that Word generates.
26499 * This is the 'nice version' - see 'Heavy' that white lists a very short list of elements, and multi-filters
26502 * Run a new Span Filter
26503 * @param {Object} config Configuration options
26506 Roo.htmleditor.FilterWord = function(cfg)
26508 // no need to apply config.
26509 this.replaceDocBullets(cfg.node);
26511 this.replaceAname(cfg.node);
26512 // this is disabled as the removal is done by other filters;
26513 // this.walk(cfg.node);
26518 Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter,
26524 * Clean up MS wordisms...
26526 replaceTag : function(node)
26529 // no idea what this does - span with text, replaceds with just text.
26531 node.nodeName == 'SPAN' &&
26532 !node.hasAttributes() &&
26533 node.childNodes.length == 1 &&
26534 node.firstChild.nodeName == "#text"
26536 var textNode = node.firstChild;
26537 node.removeChild(textNode);
26538 if (node.getAttribute('lang') != 'zh-CN') { // do not space pad on chinese characters..
26539 node.parentNode.insertBefore(node.ownerDocument.createTextNode(" "), node);
26541 node.parentNode.insertBefore(textNode, node);
26542 if (node.getAttribute('lang') != 'zh-CN') { // do not space pad on chinese characters..
26543 node.parentNode.insertBefore(node.ownerDocument.createTextNode(" ") , node);
26546 node.parentNode.removeChild(node);
26547 return false; // dont do chidren - we have remove our node - so no need to do chdhilren?
26552 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
26553 node.parentNode.removeChild(node);
26554 return false; // dont do chidlren
26556 //Roo.log(node.tagName);
26557 // remove - but keep children..
26558 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|v:|font)/)) {
26559 //Roo.log('-- removed');
26560 while (node.childNodes.length) {
26561 var cn = node.childNodes[0];
26562 node.removeChild(cn);
26563 node.parentNode.insertBefore(cn, node);
26564 // move node to parent - and clean it..
26565 if (cn.nodeType == 1) {
26566 this.replaceTag(cn);
26570 node.parentNode.removeChild(node);
26571 /// no need to iterate chidlren = it's got none..
26572 //this.iterateChildren(node, this.cleanWord);
26573 return false; // no need to iterate children.
26576 if (node.className.length) {
26578 var cn = node.className.split(/\W+/);
26580 Roo.each(cn, function(cls) {
26581 if (cls.match(/Mso[a-zA-Z]+/)) {
26586 node.className = cna.length ? cna.join(' ') : '';
26588 node.removeAttribute("class");
26592 if (node.hasAttribute("lang")) {
26593 node.removeAttribute("lang");
26596 if (node.hasAttribute("style")) {
26598 var styles = node.getAttribute("style").split(";");
26600 Roo.each(styles, function(s) {
26601 if (!s.match(/:/)) {
26604 var kv = s.split(":");
26605 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
26608 // what ever is left... we allow.
26611 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
26612 if (!nstyle.length) {
26613 node.removeAttribute('style');
26616 return true; // do children
26622 styleToObject: function(node)
26624 var styles = (node.getAttribute("style") || '').split(";");
26626 Roo.each(styles, function(s) {
26627 if (!s.match(/:/)) {
26630 var kv = s.split(":");
26632 // what ever is left... we allow.
26633 ret[kv[0].trim()] = kv[1];
26639 replaceAname : function (doc)
26641 // replace all the a/name without..
26642 var aa = Array.from(doc.getElementsByTagName('a'));
26643 for (var i = 0; i < aa.length; i++) {
26645 if (a.hasAttribute("name")) {
26646 a.removeAttribute("name");
26648 if (a.hasAttribute("href")) {
26651 // reparent children.
26652 this.removeNodeKeepChildren(a);
26662 replaceDocBullets : function(doc)
26664 // this is a bit odd - but it appears some indents use ql-indent-1
26665 //Roo.log(doc.innerHTML);
26667 var listpara = Array.from(doc.getElementsByClassName('MsoListParagraphCxSpFirst'));
26668 for( var i = 0; i < listpara.length; i ++) {
26669 listpara[i].className = "MsoListParagraph";
26672 listpara = Array.from(doc.getElementsByClassName('MsoListParagraphCxSpMiddle'));
26673 for( var i = 0; i < listpara.length; i ++) {
26674 listpara[i].className = "MsoListParagraph";
26676 listpara = Array.from(doc.getElementsByClassName('MsoListParagraphCxSpLast'));
26677 for( var i = 0; i < listpara.length; i ++) {
26678 listpara[i].className = "MsoListParagraph";
26680 listpara = Array.from(doc.getElementsByClassName('ql-indent-1'));
26681 for( var i = 0; i < listpara.length; i ++) {
26682 listpara[i].className = "MsoListParagraph";
26685 // this is a bit hacky - we had one word document where h2 had a miso-list attribute.
26686 var htwo = Array.from(doc.getElementsByTagName('h2'));
26687 for( var i = 0; i < htwo.length; i ++) {
26688 if (htwo[i].hasAttribute('style') && htwo[i].getAttribute('style').match(/mso-list:/)) {
26689 htwo[i].className = "MsoListParagraph";
26692 listpara = Array.from(doc.getElementsByClassName('MsoNormal'));
26693 for( var i = 0; i < listpara.length; i ++) {
26694 if (listpara[i].hasAttribute('style') && listpara[i].getAttribute('style').match(/mso-list:/)) {
26695 listpara[i].className = "MsoListParagraph";
26697 listpara[i].className = "MsoNormalx";
26701 listpara = doc.getElementsByClassName('MsoListParagraph');
26702 // Roo.log(doc.innerHTML);
26706 while(listpara.length) {
26708 this.replaceDocBullet(listpara.item(0));
26715 replaceDocBullet : function(p)
26717 // gather all the siblings.
26719 parent = p.parentNode,
26720 doc = parent.ownerDocument,
26723 var listtype = 'ul';
26725 if (ns.nodeType != 1) {
26726 ns = ns.nextSibling;
26729 if (!ns.className.match(/(MsoListParagraph|ql-indent-1)/i)) {
26732 var spans = ns.getElementsByTagName('span');
26733 if (ns.hasAttribute('style') && ns.getAttribute('style').match(/mso-list/)) {
26735 ns = ns.nextSibling;
26737 if (spans.length && spans[0].hasAttribute('style')) {
26738 var style = this.styleToObject(spans[0]);
26739 if (typeof(style['font-family']) != 'undefined' && !style['font-family'].match(/Symbol/)) {
26746 var spans = ns.getElementsByTagName('span');
26747 if (!spans.length) {
26750 var has_list = false;
26751 for(var i = 0; i < spans.length; i++) {
26752 if (spans[i].hasAttribute('style') && spans[i].getAttribute('style').match(/mso-list/)) {
26761 ns = ns.nextSibling;
26765 if (!items.length) {
26770 var ul = parent.ownerDocument.createElement(listtype); // what about number lists...
26771 parent.insertBefore(ul, p);
26773 var stack = [ ul ];
26774 var last_li = false;
26776 var margin_to_depth = {};
26779 items.forEach(function(n, ipos) {
26780 //Roo.log("got innertHMLT=" + n.innerHTML);
26782 var spans = n.getElementsByTagName('span');
26783 if (!spans.length) {
26784 //Roo.log("No spans found");
26786 parent.removeChild(n);
26789 return; // skip it...
26795 for(var i = 0; i < spans.length; i++) {
26797 style = this.styleToObject(spans[i]);
26798 if (typeof(style['mso-list']) == 'undefined') {
26801 if (listtype == 'ol') {
26802 num = spans[i].innerText.replace(/[^0-9]+]/g,'') * 1;
26804 spans[i].parentNode.removeChild(spans[i]); // remove the fake bullet.
26807 //Roo.log("NOW GOT innertHMLT=" + n.innerHTML);
26808 style = this.styleToObject(n); // mo-list is from the parent node.
26809 if (typeof(style['mso-list']) == 'undefined') {
26810 //Roo.log("parent is missing level");
26812 parent.removeChild(n);
26817 var margin = style['margin-left'];
26818 if (typeof(margin_to_depth[margin]) == 'undefined') {
26820 margin_to_depth[margin] = max_margins;
26822 nlvl = margin_to_depth[margin] ;
26826 var nul = doc.createElement(listtype); // what about number lists...
26828 last_li = doc.createElement('li');
26829 stack[lvl].appendChild(last_li);
26831 last_li.appendChild(nul);
26837 // not starting at 1..
26838 if (!stack[nlvl].hasAttribute("start") && listtype == "ol") {
26839 stack[nlvl].setAttribute("start", num);
26842 var nli = stack[nlvl].appendChild(doc.createElement('li'));
26844 nli.innerHTML = n.innerHTML;
26845 //Roo.log("innerHTML = " + n.innerHTML);
26846 parent.removeChild(n);
26862 * @class Roo.htmleditor.FilterStyleToTag
26863 * part of the word stuff... - certain 'styles' should be converted to tags.
26865 * font-weight: bold -> bold
26866 * ?? super / subscrit etc..
26869 * Run a new style to tag filter.
26870 * @param {Object} config Configuration options
26872 Roo.htmleditor.FilterStyleToTag = function(cfg)
26876 B : [ 'fontWeight' , 'bold'],
26877 I : [ 'fontStyle' , 'italic'],
26878 //pre : [ 'font-style' , 'italic'],
26879 // h1.. h6 ?? font-size?
26880 SUP : [ 'verticalAlign' , 'super' ],
26881 SUB : [ 'verticalAlign' , 'sub' ]
26886 Roo.apply(this, cfg);
26889 this.walk(cfg.node);
26896 Roo.extend(Roo.htmleditor.FilterStyleToTag, Roo.htmleditor.Filter,
26898 tag: true, // all tags
26903 replaceTag : function(node)
26907 if (node.getAttribute("style") === null) {
26911 for (var k in this.tags) {
26912 if (node.style[this.tags[k][0]] == this.tags[k][1]) {
26914 node.style.removeProperty(this.tags[k][0]);
26917 if (!inject.length) {
26920 var cn = Array.from(node.childNodes);
26922 Roo.each(inject, function(t) {
26923 var nc = node.ownerDocument.createElement(t);
26924 nn.appendChild(nc);
26927 for(var i = 0;i < cn.length;cn++) {
26928 node.removeChild(cn[i]);
26929 nn.appendChild(cn[i]);
26931 return true /// iterate thru
26935 * @class Roo.htmleditor.FilterLongBr
26936 * BR/BR/BR - keep a maximum of 2...
26938 * Run a new Long BR Filter
26939 * @param {Object} config Configuration options
26942 Roo.htmleditor.FilterLongBr = function(cfg)
26944 // no need to apply config.
26945 this.walk(cfg.node);
26948 Roo.extend(Roo.htmleditor.FilterLongBr, Roo.htmleditor.Filter,
26955 replaceTag : function(node)
26958 var ps = node.nextSibling;
26959 while (ps && ps.nodeType == 3 && ps.nodeValue.trim().length < 1) {
26960 ps = ps.nextSibling;
26963 if (!ps && [ 'TD', 'TH', 'LI', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6' ].indexOf(node.parentNode.tagName) > -1) {
26964 node.parentNode.removeChild(node); // remove last BR inside one fo these tags
26968 if (!ps || ps.nodeType != 1) {
26972 if (!ps || ps.tagName != 'BR') {
26981 if (!node.previousSibling) {
26984 var ps = node.previousSibling;
26986 while (ps && ps.nodeType == 3 && ps.nodeValue.trim().length < 1) {
26987 ps = ps.previousSibling;
26989 if (!ps || ps.nodeType != 1) {
26992 // if header or BR before.. then it's a candidate for removal.. - as we only want '2' of these..
26993 if (!ps || [ 'BR', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6' ].indexOf(ps.tagName) < 0) {
26997 node.parentNode.removeChild(node); // remove me...
26999 return false; // no need to do children
27006 * @class Roo.htmleditor.FilterBlock
27007 * removes id / data-block and contenteditable that are associated with blocks
27008 * usage should be done on a cloned copy of the dom
27010 * Run a new Attribute Filter { node : xxxx }}
27011 * @param {Object} config Configuration options
27013 Roo.htmleditor.FilterBlock = function(cfg)
27015 Roo.apply(this, cfg);
27016 var qa = cfg.node.querySelectorAll;
27017 this.removeAttributes('data-block');
27018 this.removeAttributes('contenteditable');
27019 this.removeAttributes('id');
27023 Roo.apply(Roo.htmleditor.FilterBlock.prototype,
27025 node: true, // all tags
27028 removeAttributes : function(attr)
27030 var ar = this.node.querySelectorAll('*[' + attr + ']');
27031 for (var i =0;i<ar.length;i++) {
27032 ar[i].removeAttribute(attr);
27041 * @class Roo.htmleditor.KeyEnter
27042 * Handle Enter press..
27043 * @cfg {Roo.HtmlEditorCore} core the editor.
27045 * Create a new Filter.
27046 * @param {Object} config Configuration options
27053 Roo.htmleditor.KeyEnter = function(cfg) {
27054 Roo.apply(this, cfg);
27055 // this does not actually call walk as it's really just a abstract class
27057 Roo.get(this.core.doc.body).on('keypress', this.keypress, this);
27060 //Roo.htmleditor.KeyEnter.i = 0;
27063 Roo.htmleditor.KeyEnter.prototype = {
27067 keypress : function(e)
27069 if (e.charCode != 13 && e.charCode != 10) {
27070 Roo.log([e.charCode,e]);
27073 e.preventDefault();
27074 // https://stackoverflow.com/questions/18552336/prevent-contenteditable-adding-div-on-enter-chrome
27075 var doc = this.core.doc;
27079 var sel = this.core.getSelection();
27080 var range = sel.getRangeAt(0);
27081 var n = range.commonAncestorContainer;
27082 var pc = range.closest([ 'ol', 'ul']);
27083 var pli = range.closest('li');
27084 if (!pc || e.ctrlKey) {
27085 // on it list, or ctrl pressed.
27087 sel.insertNode('br', 'after');
27089 // only do this if we have ctrl key..
27090 var br = doc.createElement('br');
27091 br.className = 'clear';
27092 br.setAttribute('style', 'clear: both');
27093 sel.insertNode(br, 'after');
27097 this.core.undoManager.addEvent();
27098 this.core.fireEditorEvent(e);
27102 // deal with <li> insetion
27103 if (pli.innerText.trim() == '' &&
27104 pli.previousSibling &&
27105 pli.previousSibling.nodeName == 'LI' &&
27106 pli.previousSibling.innerText.trim() == '') {
27107 pli.parentNode.removeChild(pli.previousSibling);
27108 sel.cursorAfter(pc);
27109 this.core.undoManager.addEvent();
27110 this.core.fireEditorEvent(e);
27114 var li = doc.createElement('LI');
27115 li.innerHTML = ' ';
27116 if (!pli || !pli.firstSibling) {
27117 pc.appendChild(li);
27119 pli.parentNode.insertBefore(li, pli.firstSibling);
27121 sel.cursorText (li.firstChild);
27123 this.core.undoManager.addEvent();
27124 this.core.fireEditorEvent(e);
27136 * @class Roo.htmleditor.Block
27137 * Base class for html editor blocks - do not use it directly .. extend it..
27138 * @cfg {DomElement} node The node to apply stuff to.
27139 * @cfg {String} friendly_name the name that appears in the context bar about this block
27140 * @cfg {Object} Context menu - see Roo.form.HtmlEditor.ToolbarContext
27143 * Create a new Filter.
27144 * @param {Object} config Configuration options
27147 Roo.htmleditor.Block = function(cfg)
27149 // do nothing .. should not be called really.
27152 * factory method to get the block from an element (using cache if necessary)
27154 * @param {HtmlElement} the dom element
27156 Roo.htmleditor.Block.factory = function(node)
27158 var cc = Roo.htmleditor.Block.cache;
27159 var id = Roo.get(node).id;
27160 if (typeof(cc[id]) != 'undefined' && (!cc[id].node || cc[id].node.closest('body'))) {
27161 Roo.htmleditor.Block.cache[id].readElement(node);
27162 return Roo.htmleditor.Block.cache[id];
27164 var db = node.getAttribute('data-block');
27166 db = node.nodeName.toLowerCase().toUpperCaseFirst();
27168 var cls = Roo.htmleditor['Block' + db];
27169 if (typeof(cls) == 'undefined') {
27170 //Roo.log(node.getAttribute('data-block'));
27171 Roo.log("OOps missing block : " + 'Block' + db);
27174 Roo.htmleditor.Block.cache[id] = new cls({ node: node });
27175 return Roo.htmleditor.Block.cache[id]; /// should trigger update element
27179 * initalize all Elements from content that are 'blockable'
27181 * @param the body element
27183 Roo.htmleditor.Block.initAll = function(body, type)
27185 if (typeof(type) == 'undefined') {
27186 var ia = Roo.htmleditor.Block.initAll;
27192 Roo.each(Roo.get(body).query(type), function(e) {
27193 Roo.htmleditor.Block.factory(e);
27196 // question goes here... do we need to clear out this cache sometimes?
27197 // or show we make it relivant to the htmleditor.
27198 Roo.htmleditor.Block.cache = {};
27200 Roo.htmleditor.Block.prototype = {
27204 // used by context menu
27205 friendly_name : 'Based Block',
27207 // text for button to delete this element
27208 deleteTitle : false,
27212 * Update a node with values from this object
27213 * @param {DomElement} node
27215 updateElement : function(node)
27217 Roo.DomHelper.update(node === undefined ? this.node : node, this.toObject());
27220 * convert to plain HTML for calling insertAtCursor..
27222 toHTML : function()
27224 return Roo.DomHelper.markup(this.toObject());
27227 * used by readEleemnt to extract data from a node
27228 * may need improving as it's pretty basic
27230 * @param {DomElement} node
27231 * @param {String} tag - tag to find, eg. IMG ?? might be better to use DomQuery ?
27232 * @param {String} attribute (use html - for contents, style for using next param as style, or false to return the node)
27233 * @param {String} style the style property - eg. text-align
27235 getVal : function(node, tag, attr, style)
27238 if (tag !== true && n.tagName != tag.toUpperCase()) {
27239 // in theory we could do figure[3] << 3rd figure? or some more complex search..?
27240 // but kiss for now.
27241 n = node.getElementsByTagName(tag).item(0);
27246 if (attr === false) {
27249 if (attr == 'html') {
27250 return n.innerHTML;
27252 if (attr == 'style') {
27253 return n.style[style];
27256 return n.hasAttribute(attr) ? n.getAttribute(attr) : '';
27260 * create a DomHelper friendly object - for use with
27261 * Roo.DomHelper.markup / overwrite / etc..
27264 toObject : function()
27269 * Read a node that has a 'data-block' property - and extract the values from it.
27270 * @param {DomElement} node - the node
27272 readElement : function(node)
27283 * @class Roo.htmleditor.BlockFigure
27284 * Block that has an image and a figcaption
27285 * @cfg {String} image_src the url for the image
27286 * @cfg {String} align (left|right) alignment for the block default left
27287 * @cfg {String} caption the text to appear below (and in the alt tag)
27288 * @cfg {String} caption_display (block|none) display or not the caption
27289 * @cfg {String|number} image_width the width of the image number or %?
27290 * @cfg {String|number} image_height the height of the image number or %?
27293 * Create a new Filter.
27294 * @param {Object} config Configuration options
27297 Roo.htmleditor.BlockFigure = function(cfg)
27300 this.readElement(cfg.node);
27301 this.updateElement(cfg.node);
27303 Roo.apply(this, cfg);
27305 Roo.extend(Roo.htmleditor.BlockFigure, Roo.htmleditor.Block, {
27312 caption_display : 'block',
27318 // margin: '2%', not used
27320 text_align: 'left', // (left|right) alignment for the text caption default left. - not used at present
27323 // used by context menu
27324 friendly_name : 'Image with caption',
27325 deleteTitle : "Delete Image and Caption",
27327 contextMenu : function(toolbar)
27330 var block = function() {
27331 return Roo.htmleditor.Block.factory(toolbar.tb.selectedNode);
27335 var rooui = typeof(Roo.bootstrap) == 'undefined' ? Roo : Roo.bootstrap;
27337 var syncValue = toolbar.editorcore.syncValue;
27343 xtype : 'TextItem',
27345 xns : rooui.Toolbar //Boostrap?
27349 text: 'Change Image URL',
27352 click: function (btn, state)
27356 Roo.MessageBox.show({
27357 title : "Image Source URL",
27358 msg : "Enter the url for the image",
27359 buttons: Roo.MessageBox.OKCANCEL,
27360 fn: function(btn, val){
27367 toolbar.editorcore.onEditorEvent();
27371 //multiline: multiline,
27373 value : b.image_src
27377 xns : rooui.Toolbar
27382 text: 'Change Link URL',
27385 click: function (btn, state)
27389 Roo.MessageBox.show({
27390 title : "Link URL",
27391 msg : "Enter the url for the link - leave blank to have no link",
27392 buttons: Roo.MessageBox.OKCANCEL,
27393 fn: function(btn, val){
27400 toolbar.editorcore.onEditorEvent();
27404 //multiline: multiline,
27410 xns : rooui.Toolbar
27414 text: 'Show Video URL',
27417 click: function (btn, state)
27419 Roo.MessageBox.alert("Video URL",
27420 block().video_url == '' ? 'This image is not linked ot a video' :
27421 'The image is linked to: <a target="_new" href="' + block().video_url + '">' + block().video_url + '</a>');
27424 xns : rooui.Toolbar
27429 xtype : 'TextItem',
27431 xns : rooui.Toolbar //Boostrap?
27434 xtype : 'ComboBox',
27435 allowBlank : false,
27436 displayField : 'val',
27439 triggerAction : 'all',
27441 valueField : 'val',
27445 select : function (combo, r, index)
27447 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
27449 b.width = r.get('val');
27452 toolbar.editorcore.onEditorEvent();
27457 xtype : 'SimpleStore',
27470 xtype : 'TextItem',
27472 xns : rooui.Toolbar //Boostrap?
27475 xtype : 'ComboBox',
27476 allowBlank : false,
27477 displayField : 'val',
27480 triggerAction : 'all',
27482 valueField : 'val',
27486 select : function (combo, r, index)
27488 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
27490 b.align = r.get('val');
27493 toolbar.editorcore.onEditorEvent();
27498 xtype : 'SimpleStore',
27512 text: 'Hide Caption',
27513 name : 'caption_display',
27515 enableToggle : true,
27516 setValue : function(v) {
27517 // this trigger toggle.
27519 this.setText(v ? "Hide Caption" : "Show Caption");
27520 this.setPressed(v != 'block');
27523 toggle: function (btn, state)
27526 b.caption_display = b.caption_display == 'block' ? 'none' : 'block';
27527 this.setText(b.caption_display == 'block' ? "Hide Caption" : "Show Caption");
27530 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
27531 toolbar.editorcore.onEditorEvent();
27534 xns : rooui.Toolbar
27540 * create a DomHelper friendly object - for use with
27541 * Roo.DomHelper.markup / overwrite / etc..
27543 toObject : function()
27545 var d = document.createElement('div');
27546 d.innerHTML = this.caption;
27548 var m = this.width != '100%' && this.align == 'center' ? '0 auto' : 0;
27550 var iw = this.align == 'center' ? this.width : '100%';
27553 contenteditable : 'false',
27554 src : this.image_src,
27555 alt : d.innerText.replace(/\n/g, " ").replace(/\s+/g, ' ').trim(), // removeHTML and reduce spaces..
27558 maxWidth : iw + ' !important', // this is not getting rendered?
27564 '<div class="{0}" width="420" height="315" src="{1}" frameborder="0" allowfullscreen>' +
27566 '<img class="{0}-thumbnail" src="{3}/Images/{4}/{5}#image-{4}" />' +
27571 if (this.href.length > 0) {
27575 contenteditable : 'true',
27583 if (this.video_url.length > 0) {
27588 allowfullscreen : true,
27589 width : 420, // these are for video tricks - that we replace the outer
27591 src : this.video_url,
27597 // we remove caption totally if its hidden... - will delete data.. but otherwise we end up with fake caption
27598 var captionhtml = this.caption_display == 'none' ? '' : (this.caption.length ? this.caption : "Caption");
27603 'data-block' : 'Figure',
27604 'data-width' : this.width,
27605 contenteditable : 'false',
27609 float : this.align ,
27610 maxWidth : this.align == 'center' ? '100% !important' : (this.width + ' !important'),
27611 width : this.align == 'center' ? '100%' : this.width,
27613 padding: this.align == 'center' ? '0' : '0 10px' ,
27614 textAlign : this.align // seems to work for email..
27619 align : this.align,
27625 'data-display' : this.caption_display,
27627 textAlign : 'left',
27629 lineHeight : '24px',
27630 display : this.caption_display,
27631 maxWidth : (this.align == 'center' ? this.width : '100%' ) + ' !important',
27633 width: this.align == 'center' ? this.width : '100%'
27637 cls : this.cls.length > 0 ? (this.cls + '-thumbnail' ) : '',
27642 marginTop : '16px',
27648 // we can not rely on yahoo syndication to use CSS elements - so have to use '<i>' to encase stuff.
27650 contenteditable : true,
27666 readElement : function(node)
27668 // this should not really come from the link...
27669 this.video_url = this.getVal(node, 'div', 'src');
27670 this.cls = this.getVal(node, 'div', 'class');
27671 this.href = this.getVal(node, 'a', 'href');
27674 this.image_src = this.getVal(node, 'img', 'src');
27676 this.align = this.getVal(node, 'figure', 'align');
27677 var figcaption = this.getVal(node, 'figcaption', false);
27678 if (figcaption !== '') {
27679 this.caption = this.getVal(figcaption, 'i', 'html');
27683 this.caption_display = this.getVal(node, 'figcaption', 'data-display');
27684 //this.text_align = this.getVal(node, 'figcaption', 'style','text-align');
27685 this.width = this.getVal(node, true, 'data-width');
27686 //this.margin = this.getVal(node, 'figure', 'style', 'margin');
27689 removeNode : function()
27706 * @class Roo.htmleditor.BlockTable
27707 * Block that manages a table
27710 * Create a new Filter.
27711 * @param {Object} config Configuration options
27714 Roo.htmleditor.BlockTable = function(cfg)
27717 this.readElement(cfg.node);
27718 this.updateElement(cfg.node);
27720 Roo.apply(this, cfg);
27723 for(var r = 0; r < this.no_row; r++) {
27725 for(var c = 0; c < this.no_col; c++) {
27726 this.rows[r][c] = this.emptyCell();
27733 Roo.extend(Roo.htmleditor.BlockTable, Roo.htmleditor.Block, {
27742 // used by context menu
27743 friendly_name : 'Table',
27744 deleteTitle : 'Delete Table',
27745 // context menu is drawn once..
27747 contextMenu : function(toolbar)
27750 var block = function() {
27751 return Roo.htmleditor.Block.factory(toolbar.tb.selectedNode);
27755 var rooui = typeof(Roo.bootstrap) == 'undefined' ? Roo : Roo.bootstrap;
27757 var syncValue = toolbar.editorcore.syncValue;
27763 xtype : 'TextItem',
27765 xns : rooui.Toolbar //Boostrap?
27768 xtype : 'ComboBox',
27769 allowBlank : false,
27770 displayField : 'val',
27773 triggerAction : 'all',
27775 valueField : 'val',
27779 select : function (combo, r, index)
27781 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
27783 b.width = r.get('val');
27786 toolbar.editorcore.onEditorEvent();
27791 xtype : 'SimpleStore',
27803 xtype : 'TextItem',
27804 text : "Columns: ",
27805 xns : rooui.Toolbar //Boostrap?
27812 click : function (_self, e)
27814 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
27815 block().removeColumn();
27817 toolbar.editorcore.onEditorEvent();
27820 xns : rooui.Toolbar
27826 click : function (_self, e)
27828 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
27829 block().addColumn();
27831 toolbar.editorcore.onEditorEvent();
27834 xns : rooui.Toolbar
27838 xtype : 'TextItem',
27840 xns : rooui.Toolbar //Boostrap?
27847 click : function (_self, e)
27849 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
27850 block().removeRow();
27852 toolbar.editorcore.onEditorEvent();
27855 xns : rooui.Toolbar
27861 click : function (_self, e)
27865 toolbar.editorcore.onEditorEvent();
27868 xns : rooui.Toolbar
27873 text: 'Reset Column Widths',
27876 click : function (_self, e)
27878 block().resetWidths();
27880 toolbar.editorcore.onEditorEvent();
27883 xns : rooui.Toolbar
27894 * create a DomHelper friendly object - for use with
27895 * Roo.DomHelper.markup / overwrite / etc..
27896 * ?? should it be called with option to hide all editing features?
27898 toObject : function()
27903 contenteditable : 'false', // this stops cell selection from picking the table.
27904 'data-block' : 'Table',
27907 border : 'solid 1px #000', // ??? hard coded?
27908 'border-collapse' : 'collapse'
27911 { tag : 'tbody' , cn : [] }
27915 // do we have a head = not really
27917 Roo.each(this.rows, function( row ) {
27922 border : 'solid 1px #000',
27928 ret.cn[0].cn.push(tr);
27929 // does the row have any properties? ?? height?
27931 Roo.each(row, function( cell ) {
27935 contenteditable : 'true',
27936 'data-block' : 'Td',
27940 if (cell.colspan > 1) {
27941 td.colspan = cell.colspan ;
27942 nc += cell.colspan;
27946 if (cell.rowspan > 1) {
27947 td.rowspan = cell.rowspan ;
27956 ncols = Math.max(nc, ncols);
27960 // add the header row..
27969 readElement : function(node)
27971 node = node ? node : this.node ;
27972 this.width = this.getVal(node, true, 'style', 'width') || '100%';
27976 var trs = Array.from(node.rows);
27977 trs.forEach(function(tr) {
27979 this.rows.push(row);
27983 Array.from(tr.cells).forEach(function(td) {
27986 colspan : td.hasAttribute('colspan') ? td.getAttribute('colspan')*1 : 1,
27987 rowspan : td.hasAttribute('rowspan') ? td.getAttribute('rowspan')*1 : 1,
27988 style : td.hasAttribute('style') ? td.getAttribute('style') : '',
27989 html : td.innerHTML
27991 no_column += add.colspan;
27998 this.no_col = Math.max(this.no_col, no_column);
28005 normalizeRows: function()
28009 this.rows.forEach(function(row) {
28012 row = this.normalizeRow(row);
28014 row.forEach(function(c) {
28015 while (typeof(ret[rid][cid]) != 'undefined') {
28018 if (typeof(ret[rid]) == 'undefined') {
28024 if (c.rowspan < 2) {
28028 for(var i = 1 ;i < c.rowspan; i++) {
28029 if (typeof(ret[rid+i]) == 'undefined') {
28032 ret[rid+i][cid] = c;
28040 normalizeRow: function(row)
28043 row.forEach(function(c) {
28044 if (c.colspan < 2) {
28048 for(var i =0 ;i < c.colspan; i++) {
28056 deleteColumn : function(sel)
28058 if (!sel || sel.type != 'col') {
28061 if (this.no_col < 2) {
28065 this.rows.forEach(function(row) {
28066 var cols = this.normalizeRow(row);
28067 var col = cols[sel.col];
28068 if (col.colspan > 1) {
28078 removeColumn : function()
28080 this.deleteColumn({
28082 col : this.no_col-1
28084 this.updateElement();
28088 addColumn : function()
28091 this.rows.forEach(function(row) {
28092 row.push(this.emptyCell());
28095 this.updateElement();
28098 deleteRow : function(sel)
28100 if (!sel || sel.type != 'row') {
28104 if (this.no_row < 2) {
28108 var rows = this.normalizeRows();
28111 rows[sel.row].forEach(function(col) {
28112 if (col.rowspan > 1) {
28115 col.remove = 1; // flage it as removed.
28120 this.rows.forEach(function(row) {
28122 row.forEach(function(c) {
28123 if (typeof(c.remove) == 'undefined') {
28128 if (newrow.length > 0) {
28132 this.rows = newrows;
28137 this.updateElement();
28140 removeRow : function()
28144 row : this.no_row-1
28150 addRow : function()
28154 for (var i = 0; i < this.no_col; i++ ) {
28156 row.push(this.emptyCell());
28159 this.rows.push(row);
28160 this.updateElement();
28164 // the default cell object... at present...
28165 emptyCell : function() {
28166 return (new Roo.htmleditor.BlockTd({})).toObject();
28171 removeNode : function()
28178 resetWidths : function()
28180 Array.from(this.node.getElementsByTagName('td')).forEach(function(n) {
28181 var nn = Roo.htmleditor.Block.factory(n);
28183 nn.updateElement(n);
28196 * since selections really work on the table cell, then editing really should work from there
28198 * The original plan was to support merging etc... - but that may not be needed yet..
28200 * So this simple version will support:
28202 * adjust the width +/-
28203 * reset the width...
28212 * @class Roo.htmleditor.BlockTable
28213 * Block that manages a table
28216 * Create a new Filter.
28217 * @param {Object} config Configuration options
28220 Roo.htmleditor.BlockTd = function(cfg)
28223 this.readElement(cfg.node);
28224 this.updateElement(cfg.node);
28226 Roo.apply(this, cfg);
28231 Roo.extend(Roo.htmleditor.BlockTd, Roo.htmleditor.Block, {
28236 textAlign : 'left',
28243 // used by context menu
28244 friendly_name : 'Table Cell',
28245 deleteTitle : false, // use our customer delete
28247 // context menu is drawn once..
28249 contextMenu : function(toolbar)
28252 var cell = function() {
28253 return Roo.htmleditor.Block.factory(toolbar.tb.selectedNode);
28256 var table = function() {
28257 return Roo.htmleditor.Block.factory(toolbar.tb.selectedNode.closest('table'));
28261 var saveSel = function()
28263 lr = toolbar.editorcore.getSelection().getRangeAt(0);
28265 var restoreSel = function()
28269 toolbar.editorcore.focus();
28270 var cr = toolbar.editorcore.getSelection();
28271 cr.removeAllRanges();
28273 toolbar.editorcore.onEditorEvent();
28274 }).defer(10, this);
28280 var rooui = typeof(Roo.bootstrap) == 'undefined' ? Roo : Roo.bootstrap;
28282 var syncValue = toolbar.editorcore.syncValue;
28289 text : 'Edit Table',
28291 click : function() {
28292 var t = toolbar.tb.selectedNode.closest('table');
28293 toolbar.editorcore.selectNode(t);
28294 toolbar.editorcore.onEditorEvent();
28303 xtype : 'TextItem',
28304 text : "Column Width: ",
28305 xns : rooui.Toolbar
28312 click : function (_self, e)
28314 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
28315 cell().shrinkColumn();
28317 toolbar.editorcore.onEditorEvent();
28320 xns : rooui.Toolbar
28326 click : function (_self, e)
28328 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
28329 cell().growColumn();
28331 toolbar.editorcore.onEditorEvent();
28334 xns : rooui.Toolbar
28338 xtype : 'TextItem',
28339 text : "Vertical Align: ",
28340 xns : rooui.Toolbar //Boostrap?
28343 xtype : 'ComboBox',
28344 allowBlank : false,
28345 displayField : 'val',
28348 triggerAction : 'all',
28350 valueField : 'val',
28354 select : function (combo, r, index)
28356 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
28358 b.valign = r.get('val');
28361 toolbar.editorcore.onEditorEvent();
28366 xtype : 'SimpleStore',
28370 ['bottom'] // there are afew more...
28378 xtype : 'TextItem',
28379 text : "Merge Cells: ",
28380 xns : rooui.Toolbar
28389 click : function (_self, e)
28391 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
28392 cell().mergeRight();
28393 //block().growColumn();
28395 toolbar.editorcore.onEditorEvent();
28398 xns : rooui.Toolbar
28405 click : function (_self, e)
28407 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
28408 cell().mergeBelow();
28409 //block().growColumn();
28411 toolbar.editorcore.onEditorEvent();
28414 xns : rooui.Toolbar
28417 xtype : 'TextItem',
28419 xns : rooui.Toolbar
28427 click : function (_self, e)
28429 //toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
28432 toolbar.editorcore.selectNode(toolbar.tb.selectedNode);
28433 toolbar.editorcore.onEditorEvent();
28437 xns : rooui.Toolbar
28441 xns : rooui.Toolbar
28450 xns : rooui.Toolbar,
28459 click : function (_self, e)
28463 cell().deleteColumn();
28465 toolbar.editorcore.selectNode(t.node);
28466 toolbar.editorcore.onEditorEvent();
28475 click : function (_self, e)
28478 cell().deleteRow();
28481 toolbar.editorcore.selectNode(t.node);
28482 toolbar.editorcore.onEditorEvent();
28489 xtype : 'Separator',
28496 click : function (_self, e)
28499 var nn = t.node.nextSibling || t.node.previousSibling;
28500 t.node.parentNode.removeChild(t.node);
28502 toolbar.editorcore.selectNode(nn, true);
28504 toolbar.editorcore.onEditorEvent();
28514 // align... << fixme
28522 * create a DomHelper friendly object - for use with
28523 * Roo.DomHelper.markup / overwrite / etc..
28524 * ?? should it be called with option to hide all editing features?
28527 * create a DomHelper friendly object - for use with
28528 * Roo.DomHelper.markup / overwrite / etc..
28529 * ?? should it be called with option to hide all editing features?
28531 toObject : function()
28535 contenteditable : 'true', // this stops cell selection from picking the table.
28536 'data-block' : 'Td',
28537 valign : this.valign,
28539 'text-align' : this.textAlign,
28540 border : 'solid 1px rgb(0, 0, 0)', // ??? hard coded?
28541 'border-collapse' : 'collapse',
28542 padding : '6px', // 8 for desktop / 4 for mobile
28543 'vertical-align': this.valign
28547 if (this.width != '') {
28548 ret.width = this.width;
28549 ret.style.width = this.width;
28553 if (this.colspan > 1) {
28554 ret.colspan = this.colspan ;
28556 if (this.rowspan > 1) {
28557 ret.rowspan = this.rowspan ;
28566 readElement : function(node)
28568 node = node ? node : this.node ;
28569 this.width = node.style.width;
28570 this.colspan = Math.max(1,1*node.getAttribute('colspan'));
28571 this.rowspan = Math.max(1,1*node.getAttribute('rowspan'));
28572 this.html = node.innerHTML;
28573 if (node.style.textAlign != '') {
28574 this.textAlign = node.style.textAlign;
28580 // the default cell object... at present...
28581 emptyCell : function() {
28585 textAlign : 'left',
28586 html : " " // is this going to be editable now?
28591 removeNode : function()
28593 return this.node.closest('table');
28601 toTableArray : function()
28604 var tab = this.node.closest('tr').closest('table');
28605 Array.from(tab.rows).forEach(function(r, ri){
28609 this.colWidths = [];
28610 var all_auto = true;
28611 Array.from(tab.rows).forEach(function(r, ri){
28614 Array.from(r.cells).forEach(function(ce, ci){
28619 colspan : ce.colSpan,
28620 rowspan : ce.rowSpan
28622 if (ce.isEqualNode(this.node)) {
28625 // if we have been filled up by a row?
28626 if (typeof(ret[rn][cn]) != 'undefined') {
28627 while(typeof(ret[rn][cn]) != 'undefined') {
28633 if (typeof(this.colWidths[cn]) == 'undefined' && c.colspan < 2) {
28634 this.colWidths[cn] = ce.style.width;
28635 if (this.colWidths[cn] != '') {
28641 if (c.colspan < 2 && c.rowspan < 2 ) {
28646 for(var j = 0; j < c.rowspan; j++) {
28647 if (typeof(ret[rn+j]) == 'undefined') {
28648 continue; // we have a problem..
28651 for(var i = 0; i < c.colspan; i++) {
28652 ret[rn+j][cn+i] = c;
28661 // initalize widths.?
28662 // either all widths or no widths..
28664 this.colWidths[0] = false; // no widths flag.
28675 mergeRight: function()
28678 // get the contents of the next cell along..
28679 var tr = this.node.closest('tr');
28680 var i = Array.prototype.indexOf.call(tr.childNodes, this.node);
28681 if (i >= tr.childNodes.length - 1) {
28682 return; // no cells on right to merge with.
28684 var table = this.toTableArray();
28686 if (typeof(table[this.cellData.row][this.cellData.col+this.cellData.colspan]) == 'undefined') {
28687 return; // nothing right?
28689 var rc = table[this.cellData.row][this.cellData.col+this.cellData.colspan];
28690 // right cell - must be same rowspan and on the same row.
28691 if (rc.rowspan != this.cellData.rowspan || rc.row != this.cellData.row) {
28692 return; // right hand side is not same rowspan.
28697 this.node.innerHTML += ' ' + rc.cell.innerHTML;
28698 tr.removeChild(rc.cell);
28699 this.colspan += rc.colspan;
28700 this.node.setAttribute('colspan', this.colspan);
28702 var table = this.toTableArray();
28703 this.normalizeWidths(table);
28704 this.updateWidths(table);
28708 mergeBelow : function()
28710 var table = this.toTableArray();
28711 if (typeof(table[this.cellData.row+this.cellData.rowspan]) == 'undefined') {
28712 return; // no row below
28714 if (typeof(table[this.cellData.row+this.cellData.rowspan][this.cellData.col]) == 'undefined') {
28715 return; // nothing right?
28717 var rc = table[this.cellData.row+this.cellData.rowspan][this.cellData.col];
28719 if (rc.colspan != this.cellData.colspan || rc.col != this.cellData.col) {
28720 return; // right hand side is not same rowspan.
28722 this.node.innerHTML = this.node.innerHTML + rc.cell.innerHTML ;
28723 rc.cell.parentNode.removeChild(rc.cell);
28724 this.rowspan += rc.rowspan;
28725 this.node.setAttribute('rowspan', this.rowspan);
28730 if (this.node.rowSpan < 2 && this.node.colSpan < 2) {
28733 var table = this.toTableArray();
28734 var cd = this.cellData;
28738 for(var r = cd.row; r < cd.row + cd.rowspan; r++) {
28741 for(var c = cd.col; c < cd.col + cd.colspan; c++) {
28742 if (r == cd.row && c == cd.col) {
28743 this.node.removeAttribute('rowspan');
28744 this.node.removeAttribute('colspan');
28747 var ntd = this.node.cloneNode(); // which col/row should be 0..
28748 ntd.removeAttribute('id');
28749 ntd.style.width = this.colWidths[c];
28750 ntd.innerHTML = '';
28751 table[r][c] = { cell : ntd, col : c, row: r , colspan : 1 , rowspan : 1 };
28755 this.redrawAllCells(table);
28761 redrawAllCells: function(table)
28765 var tab = this.node.closest('tr').closest('table');
28766 var ctr = tab.rows[0].parentNode;
28767 Array.from(tab.rows).forEach(function(r, ri){
28769 Array.from(r.cells).forEach(function(ce, ci){
28770 ce.parentNode.removeChild(ce);
28772 r.parentNode.removeChild(r);
28774 for(var r = 0 ; r < table.length; r++) {
28775 var re = tab.rows[r];
28777 var re = tab.ownerDocument.createElement('tr');
28778 ctr.appendChild(re);
28779 for(var c = 0 ; c < table[r].length; c++) {
28780 if (table[r][c].cell === false) {
28784 re.appendChild(table[r][c].cell);
28786 table[r][c].cell = false;
28791 updateWidths : function(table)
28793 for(var r = 0 ; r < table.length; r++) {
28795 for(var c = 0 ; c < table[r].length; c++) {
28796 if (table[r][c].cell === false) {
28800 if (this.colWidths[0] != false && table[r][c].colspan < 2) {
28801 var el = Roo.htmleditor.Block.factory(table[r][c].cell);
28802 el.width = Math.floor(this.colWidths[c]) +'%';
28803 el.updateElement(el.node);
28805 if (this.colWidths[0] != false && table[r][c].colspan > 1) {
28806 var el = Roo.htmleditor.Block.factory(table[r][c].cell);
28808 for(var i = 0; i < table[r][c].colspan; i ++) {
28809 width += Math.floor(this.colWidths[c + i]);
28811 el.width = width +'%';
28812 el.updateElement(el.node);
28814 table[r][c].cell = false; // done
28818 normalizeWidths : function(table)
28820 if (this.colWidths[0] === false) {
28821 var nw = 100.0 / this.colWidths.length;
28822 this.colWidths.forEach(function(w,i) {
28823 this.colWidths[i] = nw;
28828 var t = 0, missing = [];
28830 this.colWidths.forEach(function(w,i) {
28832 this.colWidths[i] = this.colWidths[i] == '' ? 0 : (this.colWidths[i]+'').replace(/[^0-9]+/g,'')*1;
28833 var add = this.colWidths[i];
28842 var nc = this.colWidths.length;
28843 if (missing.length) {
28844 var mult = (nc - missing.length) / (1.0 * nc);
28846 var ew = (100 -t) / (1.0 * missing.length);
28847 this.colWidths.forEach(function(w,i) {
28849 this.colWidths[i] = w * mult;
28853 this.colWidths[i] = ew;
28855 // have to make up numbers..
28858 // now we should have all the widths..
28863 shrinkColumn : function()
28865 var table = this.toTableArray();
28866 this.normalizeWidths(table);
28867 var col = this.cellData.col;
28868 var nw = this.colWidths[col] * 0.8;
28872 var otherAdd = (this.colWidths[col] * 0.2) / (this.colWidths.length -1);
28873 this.colWidths.forEach(function(w,i) {
28875 this.colWidths[i] = nw;
28878 this.colWidths[i] += otherAdd
28880 this.updateWidths(table);
28883 growColumn : function()
28885 var table = this.toTableArray();
28886 this.normalizeWidths(table);
28887 var col = this.cellData.col;
28888 var nw = this.colWidths[col] * 1.2;
28892 var otherSub = (this.colWidths[col] * 0.2) / (this.colWidths.length -1);
28893 this.colWidths.forEach(function(w,i) {
28895 this.colWidths[i] = nw;
28898 this.colWidths[i] -= otherSub
28900 this.updateWidths(table);
28903 deleteRow : function()
28905 // delete this rows 'tr'
28906 // if any of the cells in this row have a rowspan > 1 && row!= this row..
28907 // then reduce the rowspan.
28908 var table = this.toTableArray();
28909 // this.cellData.row;
28910 for (var i =0;i< table[this.cellData.row].length ; i++) {
28911 var c = table[this.cellData.row][i];
28912 if (c.row != this.cellData.row) {
28915 c.cell.setAttribute('rowspan', c.rowspan);
28918 if (c.rowspan > 1) {
28920 c.cell.setAttribute('rowspan', c.rowspan);
28923 table.splice(this.cellData.row,1);
28924 this.redrawAllCells(table);
28927 deleteColumn : function()
28929 var table = this.toTableArray();
28931 for (var i =0;i< table.length ; i++) {
28932 var c = table[i][this.cellData.col];
28933 if (c.col != this.cellData.col) {
28934 table[i][this.cellData.col].colspan--;
28935 } else if (c.colspan > 1) {
28937 c.cell.setAttribute('colspan', c.colspan);
28939 table[i].splice(this.cellData.col,1);
28942 this.redrawAllCells(table);
28950 //<script type="text/javascript">
28953 * Based Ext JS Library 1.1.1
28954 * Copyright(c) 2006-2007, Ext JS, LLC.
28960 * @class Roo.HtmlEditorCore
28961 * @extends Roo.Component
28962 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
28964 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
28967 Roo.HtmlEditorCore = function(config){
28970 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
28975 * @event initialize
28976 * Fires when the editor is fully initialized (including the iframe)
28977 * @param {Roo.HtmlEditorCore} this
28982 * Fires when the editor is first receives the focus. Any insertion must wait
28983 * until after this event.
28984 * @param {Roo.HtmlEditorCore} this
28988 * @event beforesync
28989 * Fires before the textarea is updated with content from the editor iframe. Return false
28990 * to cancel the sync.
28991 * @param {Roo.HtmlEditorCore} this
28992 * @param {String} html
28996 * @event beforepush
28997 * Fires before the iframe editor is updated with content from the textarea. Return false
28998 * to cancel the push.
28999 * @param {Roo.HtmlEditorCore} this
29000 * @param {String} html
29005 * Fires when the textarea is updated with content from the editor iframe.
29006 * @param {Roo.HtmlEditorCore} this
29007 * @param {String} html
29012 * Fires when the iframe editor is updated with content from the textarea.
29013 * @param {Roo.HtmlEditorCore} this
29014 * @param {String} html
29019 * @event editorevent
29020 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
29021 * @param {Roo.HtmlEditorCore} this
29028 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
29030 // defaults : white / black...
29031 this.applyBlacklists();
29038 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
29042 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
29048 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
29053 * @cfg {Number} height (in pixels)
29057 * @cfg {Number} width (in pixels)
29061 * @cfg {boolean} autoClean - default true - loading and saving will remove quite a bit of formating,
29062 * if you are doing an email editor, this probably needs disabling, it's designed
29067 * @cfg {boolean} enableBlocks - default true - if the block editor (table and figure should be enabled)
29069 enableBlocks : true,
29071 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
29074 stylesheets: false,
29076 * @cfg {String} language default en - language of text (usefull for rtl languages)
29082 * @cfg {boolean} allowComments - default false - allow comments in HTML source
29083 * - by default they are stripped - if you are editing email you may need this.
29085 allowComments: false,
29089 // private properties
29090 validationEvent : false,
29092 initialized : false,
29094 sourceEditMode : false,
29095 onFocus : Roo.emptyFn,
29097 hideMode:'offsets',
29101 // blacklist + whitelisted elements..
29108 undoManager : false,
29110 * Protected method that will not generally be called directly. It
29111 * is called when the editor initializes the iframe with HTML contents. Override this method if you
29112 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
29114 getDocMarkup : function(){
29118 // inherit styels from page...??
29119 if (this.stylesheets === false) {
29121 Roo.get(document.head).select('style').each(function(node) {
29122 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
29125 Roo.get(document.head).select('link').each(function(node) {
29126 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
29129 } else if (!this.stylesheets.length) {
29131 st = '<style type="text/css">' +
29132 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
29135 for (var i in this.stylesheets) {
29136 if (typeof(this.stylesheets[i]) != 'string') {
29139 st += '<link rel="stylesheet" href="' + this.stylesheets[i] +'" type="text/css">';
29144 st += '<style type="text/css">' +
29145 'IMG { cursor: pointer } ' +
29148 st += '<meta name="google" content="notranslate">';
29150 var cls = 'notranslate roo-htmleditor-body';
29152 if(this.bodyCls.length){
29153 cls += ' ' + this.bodyCls;
29156 return '<html class="notranslate" translate="no"><head>' + st +
29157 //<style type="text/css">' +
29158 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
29160 ' </head><body contenteditable="true" data-enable-grammerly="true" class="' + cls + '"></body></html>';
29164 onRender : function(ct, position)
29167 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
29168 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
29171 this.el.dom.style.border = '0 none';
29172 this.el.dom.setAttribute('tabIndex', -1);
29173 this.el.addClass('x-hidden hide');
29177 if(Roo.isIE){ // fix IE 1px bogus margin
29178 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
29182 this.frameId = Roo.id();
29186 var iframe = this.owner.wrap.createChild({
29188 cls: 'form-control', // bootstrap..
29190 name: this.frameId,
29191 frameBorder : 'no',
29192 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
29197 this.iframe = iframe.dom;
29199 this.assignDocWin();
29201 this.doc.designMode = 'on';
29204 this.doc.write(this.getDocMarkup());
29208 var task = { // must defer to wait for browser to be ready
29210 //console.log("run task?" + this.doc.readyState);
29211 this.assignDocWin();
29212 if(this.doc.body || this.doc.readyState == 'complete'){
29214 this.doc.designMode="on";
29219 Roo.TaskMgr.stop(task);
29220 this.initEditor.defer(10, this);
29227 Roo.TaskMgr.start(task);
29232 onResize : function(w, h)
29234 Roo.log('resize: ' +w + ',' + h );
29235 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
29239 if(typeof w == 'number'){
29241 this.iframe.style.width = w + 'px';
29243 if(typeof h == 'number'){
29245 this.iframe.style.height = h + 'px';
29247 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
29254 * Toggles the editor between standard and source edit mode.
29255 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
29257 toggleSourceEdit : function(sourceEditMode){
29259 this.sourceEditMode = sourceEditMode === true;
29261 if(this.sourceEditMode){
29263 Roo.get(this.iframe).addClass(['x-hidden','hide', 'd-none']); //FIXME - what's the BS styles for these
29266 Roo.get(this.iframe).removeClass(['x-hidden','hide', 'd-none']);
29267 //this.iframe.className = '';
29270 //this.setSize(this.owner.wrap.getSize());
29271 //this.fireEvent('editmodechange', this, this.sourceEditMode);
29278 * Protected method that will not generally be called directly. If you need/want
29279 * custom HTML cleanup, this is the method you should override.
29280 * @param {String} html The HTML to be cleaned
29281 * return {String} The cleaned HTML
29283 cleanHtml : function(html)
29285 html = String(html);
29286 if(html.length > 5){
29287 if(Roo.isSafari){ // strip safari nonsense
29288 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
29291 if(html == ' '){
29298 * HTML Editor -> Textarea
29299 * Protected method that will not generally be called directly. Syncs the contents
29300 * of the editor iframe with the textarea.
29302 syncValue : function()
29304 //Roo.log("HtmlEditorCore:syncValue (EDITOR->TEXT)");
29305 if(this.initialized){
29307 if (this.undoManager) {
29308 this.undoManager.addEvent();
29312 var bd = (this.doc.body || this.doc.documentElement);
29315 var sel = this.win.getSelection();
29317 var div = document.createElement('div');
29318 div.innerHTML = bd.innerHTML;
29319 var gtx = div.getElementsByClassName('gtx-trans-icon'); // google translate - really annoying and difficult to get rid of.
29320 if (gtx.length > 0) {
29321 var rm = gtx.item(0).parentNode;
29322 rm.parentNode.removeChild(rm);
29326 if (this.enableBlocks) {
29327 new Roo.htmleditor.FilterBlock({ node : div });
29330 var html = div.innerHTML;
29333 if (this.autoClean) {
29335 new Roo.htmleditor.FilterAttributes({
29337 attrib_white : ['href', 'src', 'name', 'align', 'colspan', 'rowspan', 'data-display', 'data-width', 'start'],
29338 attrib_clean : ['href', 'src' ]
29341 var tidy = new Roo.htmleditor.TidySerializer({
29344 html = tidy.serialize(div);
29350 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
29351 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
29353 html = '<div style="'+m[0]+'">' + html + '</div>';
29356 html = this.cleanHtml(html);
29357 // fix up the special chars.. normaly like back quotes in word...
29358 // however we do not want to do this with chinese..
29359 html = html.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[\u0080-\uFFFF]/g, function(match) {
29361 var cc = match.charCodeAt();
29363 // Get the character value, handling surrogate pairs
29364 if (match.length == 2) {
29365 // It's a surrogate pair, calculate the Unicode code point
29366 var high = match.charCodeAt(0) - 0xD800;
29367 var low = match.charCodeAt(1) - 0xDC00;
29368 cc = (high * 0x400) + low + 0x10000;
29370 (cc >= 0x4E00 && cc < 0xA000 ) ||
29371 (cc >= 0x3400 && cc < 0x4E00 ) ||
29372 (cc >= 0xf900 && cc < 0xfb00 )
29377 // No, use a numeric entity. Here we brazenly (and possibly mistakenly)
29378 return "&#" + cc + ";";
29385 if(this.owner.fireEvent('beforesync', this, html) !== false){
29386 this.el.dom.value = html;
29387 this.owner.fireEvent('sync', this, html);
29393 * TEXTAREA -> EDITABLE
29394 * Protected method that will not generally be called directly. Pushes the value of the textarea
29395 * into the iframe editor.
29397 pushValue : function()
29399 //Roo.log("HtmlEditorCore:pushValue (TEXT->EDITOR)");
29400 if(this.initialized){
29401 var v = this.el.dom.value.trim();
29404 if(this.owner.fireEvent('beforepush', this, v) !== false){
29405 var d = (this.doc.body || this.doc.documentElement);
29408 this.el.dom.value = d.innerHTML;
29409 this.owner.fireEvent('push', this, v);
29411 if (this.autoClean) {
29412 new Roo.htmleditor.FilterParagraph({node : this.doc.body}); // paragraphs
29413 new Roo.htmleditor.FilterSpan({node : this.doc.body}); // empty spans
29415 if (this.enableBlocks) {
29416 Roo.htmleditor.Block.initAll(this.doc.body);
29419 this.updateLanguage();
29421 var lc = this.doc.body.lastChild;
29422 if (lc && lc.nodeType == 1 && lc.getAttribute("contenteditable") == "false") {
29423 // add an extra line at the end.
29424 this.doc.body.appendChild(this.doc.createElement('br'));
29432 deferFocus : function(){
29433 this.focus.defer(10, this);
29437 focus : function(){
29438 if(this.win && !this.sourceEditMode){
29445 assignDocWin: function()
29447 var iframe = this.iframe;
29450 this.doc = iframe.contentWindow.document;
29451 this.win = iframe.contentWindow;
29453 // if (!Roo.get(this.frameId)) {
29456 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
29457 // this.win = Roo.get(this.frameId).dom.contentWindow;
29459 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
29463 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
29464 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
29469 initEditor : function(){
29470 //console.log("INIT EDITOR");
29471 this.assignDocWin();
29475 this.doc.designMode="on";
29477 this.doc.write(this.getDocMarkup());
29480 var dbody = (this.doc.body || this.doc.documentElement);
29481 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
29482 // this copies styles from the containing element into thsi one..
29483 // not sure why we need all of this..
29484 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
29486 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
29487 //ss['background-attachment'] = 'fixed'; // w3c
29488 dbody.bgProperties = 'fixed'; // ie
29489 dbody.setAttribute("translate", "no");
29491 //Roo.DomHelper.applyStyles(dbody, ss);
29492 Roo.EventManager.on(this.doc, {
29494 'mouseup': this.onEditorEvent,
29495 'dblclick': this.onEditorEvent,
29496 'click': this.onEditorEvent,
29497 'keyup': this.onEditorEvent,
29502 Roo.EventManager.on(this.doc, {
29503 'paste': this.onPasteEvent,
29507 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
29510 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
29511 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
29513 this.initialized = true;
29516 // initialize special key events - enter
29517 new Roo.htmleditor.KeyEnter({core : this});
29521 this.owner.fireEvent('initialize', this);
29524 // this is to prevent a href clicks resulting in a redirect?
29526 onPasteEvent : function(e,v)
29528 // I think we better assume paste is going to be a dirty load of rubish from word..
29530 // even pasting into a 'email version' of this widget will have to clean up that mess.
29531 var cd = (e.browserEvent.clipboardData || window.clipboardData);
29533 // check what type of paste - if it's an image, then handle it differently.
29534 if (cd.files && cd.files.length > 0) {
29536 var urlAPI = (window.createObjectURL && window) ||
29537 (window.URL && URL.revokeObjectURL && URL) ||
29538 (window.webkitURL && webkitURL);
29540 var url = urlAPI.createObjectURL( cd.files[0]);
29541 this.insertAtCursor('<img src=" + url + ">');
29544 if (cd.types.indexOf('text/html') < 0 ) {
29548 var html = cd.getData('text/html'); // clipboard event
29549 if (cd.types.indexOf('text/rtf') > -1) {
29550 var parser = new Roo.rtf.Parser(cd.getData('text/rtf'));
29551 images = parser.doc ? parser.doc.getElementsByType('pict') : [];
29556 images = images.filter(function(g) { return !g.path.match(/^rtf\/(head|pgdsctbl|listtable|footerf)/); }) // ignore headers/footers etc.
29557 .map(function(g) { return g.toDataURL(); })
29558 .filter(function(g) { return g != 'about:blank'; });
29561 html = this.cleanWordChars(html);
29563 var d = (new DOMParser().parseFromString(html, 'text/html')).body;
29566 var sn = this.getParentElement();
29567 // check if d contains a table, and prevent nesting??
29568 //Roo.log(d.getElementsByTagName('table'));
29570 //Roo.log(sn.closest('table'));
29571 if (d.getElementsByTagName('table').length && sn && sn.closest('table')) {
29572 e.preventDefault();
29573 this.insertAtCursor("You can not nest tables");
29574 //Roo.log("prevent?"); // fixme -
29580 if (images.length > 0) {
29581 // replace all v:imagedata - with img.
29582 var ar = Array.from(d.getElementsByTagName('v:imagedata'));
29583 Roo.each(ar, function(node) {
29584 node.parentNode.insertBefore(d.ownerDocument.createElement('img'), node );
29585 node.parentNode.removeChild(node);
29589 Roo.each(d.getElementsByTagName('img'), function(img, i) {
29590 img.setAttribute('src', images[i]);
29593 if (this.autoClean) {
29594 new Roo.htmleditor.FilterWord({ node : d });
29596 new Roo.htmleditor.FilterStyleToTag({ node : d });
29597 new Roo.htmleditor.FilterAttributes({
29599 attrib_white : ['href', 'src', 'name', 'align', 'colspan', 'rowspan', 'data-display', 'data-width', 'start'],
29600 attrib_clean : ['href', 'src' ]
29602 new Roo.htmleditor.FilterBlack({ node : d, tag : this.black});
29603 // should be fonts..
29604 new Roo.htmleditor.FilterKeepChildren({node : d, tag : [ 'FONT', ':' ]} );
29605 new Roo.htmleditor.FilterParagraph({ node : d });
29606 new Roo.htmleditor.FilterSpan({ node : d });
29607 new Roo.htmleditor.FilterLongBr({ node : d });
29608 new Roo.htmleditor.FilterComment({ node : d });
29612 if (this.enableBlocks) {
29614 Array.from(d.getElementsByTagName('img')).forEach(function(img) {
29615 if (img.closest('figure')) { // assume!! that it's aready
29618 var fig = new Roo.htmleditor.BlockFigure({
29619 image_src : img.src
29621 fig.updateElement(img); // replace it..
29627 this.insertAtCursor(d.innerHTML.replace(/ /g,' '));
29628 if (this.enableBlocks) {
29629 Roo.htmleditor.Block.initAll(this.doc.body);
29633 e.preventDefault();
29635 // default behaveiour should be our local cleanup paste? (optional?)
29636 // for simple editor - we want to hammer the paste and get rid of everything... - so over-rideable..
29637 //this.owner.fireEvent('paste', e, v);
29640 onDestroy : function(){
29646 //for (var i =0; i < this.toolbars.length;i++) {
29647 // // fixme - ask toolbars for heights?
29648 // this.toolbars[i].onDestroy();
29651 //this.wrap.dom.innerHTML = '';
29652 //this.wrap.remove();
29657 onFirstFocus : function(){
29659 this.assignDocWin();
29660 this.undoManager = new Roo.lib.UndoManager(100,(this.doc.body || this.doc.documentElement));
29662 this.activated = true;
29665 if(Roo.isGecko){ // prevent silly gecko errors
29667 var s = this.win.getSelection();
29668 if(!s.focusNode || s.focusNode.nodeType != 3){
29669 var r = s.getRangeAt(0);
29670 r.selectNodeContents((this.doc.body || this.doc.documentElement));
29675 this.execCmd('useCSS', true);
29676 this.execCmd('styleWithCSS', false);
29679 this.owner.fireEvent('activate', this);
29683 adjustFont: function(btn){
29684 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
29685 //if(Roo.isSafari){ // safari
29688 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
29689 if(Roo.isSafari){ // safari
29690 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
29691 v = (v < 10) ? 10 : v;
29692 v = (v > 48) ? 48 : v;
29693 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
29698 v = Math.max(1, v+adjust);
29700 this.execCmd('FontSize', v );
29703 onEditorEvent : function(e)
29707 if (e && (e.ctrlKey || e.metaKey) && e.keyCode === 90) {
29708 return; // we do not handle this.. (undo manager does..)
29710 // in theory this detects if the last element is not a br, then we try and do that.
29711 // its so clicking in space at bottom triggers adding a br and moving the cursor.
29713 e.target.nodeName == 'BODY' &&
29714 e.type == "mouseup" &&
29715 this.doc.body.lastChild
29717 var lc = this.doc.body.lastChild;
29718 // gtx-trans is google translate plugin adding crap.
29719 while ((lc.nodeType == 3 && lc.nodeValue == '') || lc.id == 'gtx-trans') {
29720 lc = lc.previousSibling;
29722 if (lc.nodeType == 1 && lc.nodeName != 'BR') {
29723 // if last element is <BR> - then dont do anything.
29725 var ns = this.doc.createElement('br');
29726 this.doc.body.appendChild(ns);
29727 range = this.doc.createRange();
29728 range.setStartAfter(ns);
29729 range.collapse(true);
29730 var sel = this.win.getSelection();
29731 sel.removeAllRanges();
29732 sel.addRange(range);
29738 this.fireEditorEvent(e);
29739 // this.updateToolbar();
29740 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
29743 fireEditorEvent: function(e)
29745 this.owner.fireEvent('editorevent', this, e);
29748 insertTag : function(tg)
29750 // could be a bit smarter... -> wrap the current selected tRoo..
29751 if (tg.toLowerCase() == 'span' ||
29752 tg.toLowerCase() == 'code' ||
29753 tg.toLowerCase() == 'sup' ||
29754 tg.toLowerCase() == 'sub'
29757 range = this.createRange(this.getSelection());
29758 var wrappingNode = this.doc.createElement(tg.toLowerCase());
29759 wrappingNode.appendChild(range.extractContents());
29760 range.insertNode(wrappingNode);
29767 this.execCmd("formatblock", tg);
29768 this.undoManager.addEvent();
29771 insertText : function(txt)
29775 var range = this.createRange();
29776 range.deleteContents();
29777 //alert(Sender.getAttribute('label'));
29779 range.insertNode(this.doc.createTextNode(txt));
29780 this.undoManager.addEvent();
29786 * Executes a Midas editor command on the editor document and performs necessary focus and
29787 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
29788 * @param {String} cmd The Midas command
29789 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
29791 relayCmd : function(cmd, value)
29795 case 'justifyleft':
29796 case 'justifyright':
29797 case 'justifycenter':
29798 // if we are in a cell, then we will adjust the
29799 var n = this.getParentElement();
29800 var td = n.closest('td');
29802 var bl = Roo.htmleditor.Block.factory(td);
29803 bl.textAlign = cmd.replace('justify','');
29804 bl.updateElement();
29805 this.owner.fireEvent('editorevent', this);
29808 this.execCmd('styleWithCSS', true); //
29812 // if there is no selection, then we insert, and set the curson inside it..
29813 this.execCmd('styleWithCSS', false);
29823 this.execCmd(cmd, value);
29824 this.owner.fireEvent('editorevent', this);
29825 //this.updateToolbar();
29826 this.owner.deferFocus();
29830 * Executes a Midas editor command directly on the editor document.
29831 * For visual commands, you should use {@link #relayCmd} instead.
29832 * <b>This should only be called after the editor is initialized.</b>
29833 * @param {String} cmd The Midas command
29834 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
29836 execCmd : function(cmd, value){
29837 this.doc.execCommand(cmd, false, value === undefined ? null : value);
29844 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
29846 * @param {String} text | dom node..
29848 insertAtCursor : function(text)
29851 if(!this.activated){
29855 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
29859 // from jquery ui (MIT licenced)
29861 var win = this.win;
29863 if (win.getSelection && win.getSelection().getRangeAt) {
29865 // delete the existing?
29867 this.createRange(this.getSelection()).deleteContents();
29868 range = win.getSelection().getRangeAt(0);
29869 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
29870 range.insertNode(node);
29871 range = range.cloneRange();
29872 range.collapse(false);
29874 win.getSelection().removeAllRanges();
29875 win.getSelection().addRange(range);
29879 } else if (win.document.selection && win.document.selection.createRange) {
29880 // no firefox support
29881 var txt = typeof(text) == 'string' ? text : text.outerHTML;
29882 win.document.selection.createRange().pasteHTML(txt);
29885 // no firefox support
29886 var txt = typeof(text) == 'string' ? text : text.outerHTML;
29887 this.execCmd('InsertHTML', txt);
29895 mozKeyPress : function(e){
29897 var c = e.getCharCode(), cmd;
29900 c = String.fromCharCode(c).toLowerCase();
29914 // this.cleanUpPaste.defer(100, this);
29920 this.relayCmd(cmd);
29921 //this.win.focus();
29922 //this.execCmd(cmd);
29923 //this.deferFocus();
29924 e.preventDefault();
29932 fixKeys : function(){ // load time branching for fastest keydown performance
29936 return function(e){
29937 var k = e.getKey(), r;
29940 r = this.doc.selection.createRange();
29943 r.pasteHTML('    ');
29948 /// this is handled by Roo.htmleditor.KeyEnter
29951 r = this.doc.selection.createRange();
29953 var target = r.parentElement();
29954 if(!target || target.tagName.toLowerCase() != 'li'){
29956 r.pasteHTML('<br/>');
29963 //if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
29964 // this.cleanUpPaste.defer(100, this);
29970 }else if(Roo.isOpera){
29971 return function(e){
29972 var k = e.getKey();
29976 this.execCmd('InsertHTML','    ');
29980 //if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
29981 // this.cleanUpPaste.defer(100, this);
29986 }else if(Roo.isSafari){
29987 return function(e){
29988 var k = e.getKey();
29992 this.execCmd('InsertText','\t');
29996 this.mozKeyPress(e);
29998 //if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
29999 // this.cleanUpPaste.defer(100, this);
30007 getAllAncestors: function()
30009 var p = this.getSelectedNode();
30012 a.push(p); // push blank onto stack..
30013 p = this.getParentElement();
30017 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
30021 a.push(this.doc.body);
30025 lastSelNode : false,
30028 getSelection : function()
30030 this.assignDocWin();
30031 return Roo.lib.Selection.wrap(Roo.isIE ? this.doc.selection : this.win.getSelection(), this.doc);
30034 * Select a dom node
30035 * @param {DomElement} node the node to select
30037 selectNode : function(node, collapse)
30039 var nodeRange = node.ownerDocument.createRange();
30041 nodeRange.selectNode(node);
30043 nodeRange.selectNodeContents(node);
30045 if (collapse === true) {
30046 nodeRange.collapse(true);
30049 var s = this.win.getSelection();
30050 s.removeAllRanges();
30051 s.addRange(nodeRange);
30054 getSelectedNode: function()
30056 // this may only work on Gecko!!!
30058 // should we cache this!!!!
30062 var range = this.createRange(this.getSelection()).cloneRange();
30065 var parent = range.parentElement();
30067 var testRange = range.duplicate();
30068 testRange.moveToElementText(parent);
30069 if (testRange.inRange(range)) {
30072 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
30075 parent = parent.parentElement;
30080 // is ancestor a text element.
30081 var ac = range.commonAncestorContainer;
30082 if (ac.nodeType == 3) {
30083 ac = ac.parentNode;
30086 var ar = ac.childNodes;
30089 var other_nodes = [];
30090 var has_other_nodes = false;
30091 for (var i=0;i<ar.length;i++) {
30092 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
30095 // fullly contained node.
30097 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
30102 // probably selected..
30103 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
30104 other_nodes.push(ar[i]);
30108 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
30113 has_other_nodes = true;
30115 if (!nodes.length && other_nodes.length) {
30116 nodes= other_nodes;
30118 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
30126 createRange: function(sel)
30128 // this has strange effects when using with
30129 // top toolbar - not sure if it's a great idea.
30130 //this.editor.contentWindow.focus();
30131 if (typeof sel != "undefined") {
30133 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
30135 return this.doc.createRange();
30138 return this.doc.createRange();
30141 getParentElement: function()
30144 this.assignDocWin();
30145 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
30147 var range = this.createRange(sel);
30150 var p = range.commonAncestorContainer;
30151 while (p.nodeType == 3) { // text node
30162 * Range intersection.. the hard stuff...
30166 * [ -- selected range --- ]
30170 * if end is before start or hits it. fail.
30171 * if start is after end or hits it fail.
30173 * if either hits (but other is outside. - then it's not
30179 // @see http://www.thismuchiknow.co.uk/?p=64.
30180 rangeIntersectsNode : function(range, node)
30182 var nodeRange = node.ownerDocument.createRange();
30184 nodeRange.selectNode(node);
30186 nodeRange.selectNodeContents(node);
30189 var rangeStartRange = range.cloneRange();
30190 rangeStartRange.collapse(true);
30192 var rangeEndRange = range.cloneRange();
30193 rangeEndRange.collapse(false);
30195 var nodeStartRange = nodeRange.cloneRange();
30196 nodeStartRange.collapse(true);
30198 var nodeEndRange = nodeRange.cloneRange();
30199 nodeEndRange.collapse(false);
30201 return rangeStartRange.compareBoundaryPoints(
30202 Range.START_TO_START, nodeEndRange) == -1 &&
30203 rangeEndRange.compareBoundaryPoints(
30204 Range.START_TO_START, nodeStartRange) == 1;
30208 rangeCompareNode : function(range, node)
30210 var nodeRange = node.ownerDocument.createRange();
30212 nodeRange.selectNode(node);
30214 nodeRange.selectNodeContents(node);
30218 range.collapse(true);
30220 nodeRange.collapse(true);
30222 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
30223 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
30225 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
30227 var nodeIsBefore = ss == 1;
30228 var nodeIsAfter = ee == -1;
30230 if (nodeIsBefore && nodeIsAfter) {
30233 if (!nodeIsBefore && nodeIsAfter) {
30234 return 1; //right trailed.
30237 if (nodeIsBefore && !nodeIsAfter) {
30238 return 2; // left trailed.
30244 cleanWordChars : function(input) {// change the chars to hex code
30247 [ 8211, "–" ],
30248 [ 8212, "—" ],
30256 var output = input;
30257 Roo.each(swapCodes, function(sw) {
30258 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
30260 output = output.replace(swapper, sw[1]);
30270 cleanUpChild : function (node)
30273 new Roo.htmleditor.FilterComment({node : node});
30274 new Roo.htmleditor.FilterAttributes({
30276 attrib_black : this.ablack,
30277 attrib_clean : this.aclean,
30278 style_white : this.cwhite,
30279 style_black : this.cblack
30281 new Roo.htmleditor.FilterBlack({ node : node, tag : this.black});
30282 new Roo.htmleditor.FilterKeepChildren({node : node, tag : this.tag_remove} );
30288 * Clean up MS wordisms...
30289 * @deprecated - use filter directly
30291 cleanWord : function(node)
30293 new Roo.htmleditor.FilterWord({ node : node ? node : this.doc.body });
30294 new Roo.htmleditor.FilterKeepChildren({node : node ? node : this.doc.body, tag : [ 'FONT', ':' ]} );
30301 * @deprecated - use filters
30303 cleanTableWidths : function(node)
30305 new Roo.htmleditor.FilterTableWidth({ node : node ? node : this.doc.body});
30312 applyBlacklists : function()
30314 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
30315 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
30317 this.aclean = typeof(this.owner.aclean) != 'undefined' && this.owner.aclean ? this.owner.aclean : Roo.HtmlEditorCore.aclean;
30318 this.ablack = typeof(this.owner.ablack) != 'undefined' && this.owner.ablack ? this.owner.ablack : Roo.HtmlEditorCore.ablack;
30319 this.tag_remove = typeof(this.owner.tag_remove) != 'undefined' && this.owner.tag_remove ? this.owner.tag_remove : Roo.HtmlEditorCore.tag_remove;
30323 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
30324 if (b.indexOf(tag) > -1) {
30327 this.white.push(tag);
30331 Roo.each(w, function(tag) {
30332 if (b.indexOf(tag) > -1) {
30335 if (this.white.indexOf(tag) > -1) {
30338 this.white.push(tag);
30343 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
30344 if (w.indexOf(tag) > -1) {
30347 this.black.push(tag);
30351 Roo.each(b, function(tag) {
30352 if (w.indexOf(tag) > -1) {
30355 if (this.black.indexOf(tag) > -1) {
30358 this.black.push(tag);
30363 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
30364 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
30368 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
30369 if (b.indexOf(tag) > -1) {
30372 this.cwhite.push(tag);
30376 Roo.each(w, function(tag) {
30377 if (b.indexOf(tag) > -1) {
30380 if (this.cwhite.indexOf(tag) > -1) {
30383 this.cwhite.push(tag);
30388 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
30389 if (w.indexOf(tag) > -1) {
30392 this.cblack.push(tag);
30396 Roo.each(b, function(tag) {
30397 if (w.indexOf(tag) > -1) {
30400 if (this.cblack.indexOf(tag) > -1) {
30403 this.cblack.push(tag);
30408 setStylesheets : function(stylesheets)
30410 if(typeof(stylesheets) == 'string'){
30411 Roo.get(this.iframe.contentDocument.head).createChild({
30413 rel : 'stylesheet',
30422 Roo.each(stylesheets, function(s) {
30427 Roo.get(_this.iframe.contentDocument.head).createChild({
30429 rel : 'stylesheet',
30439 updateLanguage : function()
30441 if (!this.iframe || !this.iframe.contentDocument) {
30444 Roo.get(this.iframe.contentDocument.body).attr("lang", this.language);
30448 removeStylesheets : function()
30452 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
30457 setStyle : function(style)
30459 Roo.get(this.iframe.contentDocument.head).createChild({
30468 // hide stuff that is not compatible
30482 * @event specialkey
30486 * @cfg {String} fieldClass @hide
30489 * @cfg {String} focusClass @hide
30492 * @cfg {String} autoCreate @hide
30495 * @cfg {String} inputType @hide
30498 * @cfg {String} invalidClass @hide
30501 * @cfg {String} invalidText @hide
30504 * @cfg {String} msgFx @hide
30507 * @cfg {String} validateOnBlur @hide
30511 Roo.HtmlEditorCore.white = [
30512 'AREA', 'BR', 'IMG', 'INPUT', 'HR', 'WBR',
30514 'ADDRESS', 'BLOCKQUOTE', 'CENTER', 'DD', 'DIR', 'DIV',
30515 'DL', 'DT', 'H1', 'H2', 'H3', 'H4',
30516 'H5', 'H6', 'HR', 'ISINDEX', 'LISTING', 'MARQUEE',
30517 'MENU', 'MULTICOL', 'OL', 'P', 'PLAINTEXT', 'PRE',
30518 'TABLE', 'UL', 'XMP',
30520 'CAPTION', 'COL', 'COLGROUP', 'TBODY', 'TD', 'TFOOT', 'TH',
30523 'DIR', 'MENU', 'OL', 'UL', 'DL',
30529 Roo.HtmlEditorCore.black = [
30530 // 'embed', 'object', // enable - backend responsiblity to clean thiese
30532 'BASE', 'BASEFONT', 'BGSOUND', 'BLINK', 'BODY',
30533 'FRAME', 'FRAMESET', 'HEAD', 'HTML', 'ILAYER',
30534 'IFRAME', 'LAYER', 'LINK', 'META', 'OBJECT',
30535 'SCRIPT', 'STYLE' ,'TITLE', 'XML',
30536 //'FONT' // CLEAN LATER..
30537 'COLGROUP', 'COL' // messy tables.
30541 Roo.HtmlEditorCore.clean = [ // ?? needed???
30542 'SCRIPT', 'STYLE', 'TITLE', 'XML'
30544 Roo.HtmlEditorCore.tag_remove = [
30549 Roo.HtmlEditorCore.ablack = [
30553 Roo.HtmlEditorCore.aclean = [
30554 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
30558 Roo.HtmlEditorCore.pwhite= [
30559 'http', 'https', 'mailto'
30562 // white listed style attributes.
30563 Roo.HtmlEditorCore.cwhite= [
30564 // 'text-align', /// default is to allow most things..
30570 // black listed style attributes.
30571 Roo.HtmlEditorCore.cblack= [
30572 // 'font-size' -- this can be set by the project
30586 * @class Roo.bootstrap.form.HtmlEditor
30587 * @extends Roo.bootstrap.form.TextArea
30588 * Bootstrap HtmlEditor class
30591 * Create a new HtmlEditor
30592 * @param {Object} config The config object
30595 Roo.bootstrap.form.HtmlEditor = function(config){
30596 Roo.bootstrap.form.HtmlEditor.superclass.constructor.call(this, config);
30597 if (!this.toolbars) {
30598 this.toolbars = [];
30601 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
30604 * @event initialize
30605 * Fires when the editor is fully initialized (including the iframe)
30606 * @param {HtmlEditor} this
30611 * Fires when the editor is first receives the focus. Any insertion must wait
30612 * until after this event.
30613 * @param {HtmlEditor} this
30617 * @event beforesync
30618 * Fires before the textarea is updated with content from the editor iframe. Return false
30619 * to cancel the sync.
30620 * @param {HtmlEditor} this
30621 * @param {String} html
30625 * @event beforepush
30626 * Fires before the iframe editor is updated with content from the textarea. Return false
30627 * to cancel the push.
30628 * @param {HtmlEditor} this
30629 * @param {String} html
30634 * Fires when the textarea is updated with content from the editor iframe.
30635 * @param {HtmlEditor} this
30636 * @param {String} html
30641 * Fires when the iframe editor is updated with content from the textarea.
30642 * @param {HtmlEditor} this
30643 * @param {String} html
30647 * @event editmodechange
30648 * Fires when the editor switches edit modes
30649 * @param {HtmlEditor} this
30650 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
30652 editmodechange: true,
30654 * @event editorevent
30655 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
30656 * @param {HtmlEditor} this
30660 * @event firstfocus
30661 * Fires when on first focus - needed by toolbars..
30662 * @param {HtmlEditor} this
30667 * Auto save the htmlEditor value as a file into Events
30668 * @param {HtmlEditor} this
30672 * @event savedpreview
30673 * preview the saved version of htmlEditor
30674 * @param {HtmlEditor} this
30681 Roo.extend(Roo.bootstrap.form.HtmlEditor, Roo.bootstrap.form.TextArea, {
30685 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
30690 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
30695 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
30700 * @cfg {Number} height (in pixels)
30704 * @cfg {Number} width (in pixels)
30709 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
30712 stylesheets: false,
30717 // private properties
30718 validationEvent : false,
30720 initialized : false,
30723 onFocus : Roo.emptyFn,
30725 hideMode:'offsets',
30727 tbContainer : false,
30731 toolbarContainer :function() {
30732 return this.wrap.select('.x-html-editor-tb',true).first();
30736 * Protected method that will not generally be called directly. It
30737 * is called when the editor creates its toolbar. Override this method if you need to
30738 * add custom toolbar buttons.
30739 * @param {HtmlEditor} editor
30741 createToolbar : function(){
30742 Roo.log('renewing');
30743 Roo.log("create toolbars");
30745 this.toolbars = [ new Roo.bootstrap.form.HtmlEditorToolbarStandard({editor: this} ) ];
30746 this.toolbars[0].render(this.toolbarContainer());
30750 // if (!editor.toolbars || !editor.toolbars.length) {
30751 // editor.toolbars = [ new Roo.bootstrap.form.HtmlEditorToolbarStandard() ]; // can be empty?
30754 // for (var i =0 ; i < editor.toolbars.length;i++) {
30755 // editor.toolbars[i] = Roo.factory(
30756 // typeof(editor.toolbars[i]) == 'string' ?
30757 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
30758 // Roo.bootstrap.form.HtmlEditor);
30759 // editor.toolbars[i].init(editor);
30765 onRender : function(ct, position)
30767 // Roo.log("Call onRender: " + this.xtype);
30769 Roo.bootstrap.form.HtmlEditor.superclass.onRender.call(this, ct, position);
30771 this.wrap = this.inputEl().wrap({
30772 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
30775 this.editorcore.onRender(ct, position);
30777 if (this.resizable) {
30778 this.resizeEl = new Roo.Resizable(this.wrap, {
30782 minHeight : this.height,
30783 height: this.height,
30784 handles : this.resizable,
30787 resize : function(r, w, h) {
30788 _t.onResize(w,h); // -something
30794 this.createToolbar(this);
30797 if(!this.width && this.resizable){
30798 this.setSize(this.wrap.getSize());
30800 if (this.resizeEl) {
30801 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
30802 // should trigger onReize..
30808 onResize : function(w, h)
30810 Roo.log('resize: ' +w + ',' + h );
30811 Roo.bootstrap.form.HtmlEditor.superclass.onResize.apply(this, arguments);
30815 if(this.inputEl() ){
30816 if(typeof w == 'number'){
30817 var aw = w - this.wrap.getFrameWidth('lr');
30818 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
30821 if(typeof h == 'number'){
30822 var tbh = -11; // fixme it needs to tool bar size!
30823 for (var i =0; i < this.toolbars.length;i++) {
30824 // fixme - ask toolbars for heights?
30825 tbh += this.toolbars[i].el.getHeight();
30826 //if (this.toolbars[i].footer) {
30827 // tbh += this.toolbars[i].footer.el.getHeight();
30835 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
30836 ah -= 5; // knock a few pixes off for look..
30837 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
30841 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
30842 this.editorcore.onResize(ew,eh);
30847 * Toggles the editor between standard and source edit mode.
30848 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
30850 toggleSourceEdit : function(sourceEditMode)
30852 this.editorcore.toggleSourceEdit(sourceEditMode);
30854 if(this.editorcore.sourceEditMode){
30855 Roo.log('editor - showing textarea');
30858 // Roo.log(this.syncValue());
30860 this.inputEl().removeClass(['hide', 'x-hidden']);
30861 this.inputEl().dom.removeAttribute('tabIndex');
30862 this.inputEl().focus();
30864 Roo.log('editor - hiding textarea');
30866 // Roo.log(this.pushValue());
30869 this.inputEl().addClass(['hide', 'x-hidden']);
30870 this.inputEl().dom.setAttribute('tabIndex', -1);
30871 //this.deferFocus();
30874 if(this.resizable){
30875 this.setSize(this.wrap.getSize());
30878 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
30881 // private (for BoxComponent)
30882 adjustSize : Roo.BoxComponent.prototype.adjustSize,
30884 // private (for BoxComponent)
30885 getResizeEl : function(){
30889 // private (for BoxComponent)
30890 getPositionEl : function(){
30895 initEvents : function(){
30896 this.originalValue = this.getValue();
30900 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
30903 // markInvalid : Roo.emptyFn,
30905 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
30908 // clearInvalid : Roo.emptyFn,
30910 setValue : function(v){
30911 Roo.bootstrap.form.HtmlEditor.superclass.setValue.call(this, v);
30912 this.editorcore.pushValue();
30917 deferFocus : function(){
30918 this.focus.defer(10, this);
30922 focus : function(){
30923 this.editorcore.focus();
30929 onDestroy : function(){
30935 for (var i =0; i < this.toolbars.length;i++) {
30936 // fixme - ask toolbars for heights?
30937 this.toolbars[i].onDestroy();
30940 this.wrap.dom.innerHTML = '';
30941 this.wrap.remove();
30946 onFirstFocus : function(){
30947 //Roo.log("onFirstFocus");
30948 this.editorcore.onFirstFocus();
30949 for (var i =0; i < this.toolbars.length;i++) {
30950 this.toolbars[i].onFirstFocus();
30956 syncValue : function()
30958 this.editorcore.syncValue();
30961 pushValue : function()
30963 this.editorcore.pushValue();
30967 // hide stuff that is not compatible
30981 * @event specialkey
30985 * @cfg {String} fieldClass @hide
30988 * @cfg {String} focusClass @hide
30991 * @cfg {String} autoCreate @hide
30994 * @cfg {String} inputType @hide
30998 * @cfg {String} invalidText @hide
31001 * @cfg {String} msgFx @hide
31004 * @cfg {String} validateOnBlur @hide
31013 Roo.namespace('Roo.bootstrap.form.HtmlEditor');
31015 * @class Roo.bootstrap.form.HtmlEditorToolbarStandard
31016 * @parent Roo.bootstrap.form.HtmlEditor
31017 * @extends Roo.bootstrap.nav.Simplebar
31023 new Roo.bootstrap.form.HtmlEditor({
31026 new Roo.bootstrap.form.HtmlEditorToolbarStandard({
31027 disable : { fonts: 1 , format: 1, ..., ... , ...],
31033 * @cfg {Object} disable List of elements to disable..
31034 * @cfg {Array} btns List of additional buttons.
31038 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
31041 Roo.bootstrap.form.HtmlEditorToolbarStandard = function(config)
31044 Roo.apply(this, config);
31046 // default disabled, based on 'good practice'..
31047 this.disable = this.disable || {};
31048 Roo.applyIf(this.disable, {
31051 specialElements : true
31053 Roo.bootstrap.form.HtmlEditorToolbarStandard.superclass.constructor.call(this, config);
31055 this.editor = config.editor;
31056 this.editorcore = config.editor.editorcore;
31058 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
31060 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
31061 // dont call parent... till later.
31063 Roo.extend(Roo.bootstrap.form.HtmlEditorToolbarStandard, Roo.bootstrap.nav.Simplebar, {
31068 editorcore : false,
31073 "h1","h2","h3","h4","h5","h6",
31075 "abbr", "acronym", "address", "cite", "samp", "var",
31079 onRender : function(ct, position)
31081 // Roo.log("Call onRender: " + this.xtype);
31083 Roo.bootstrap.form.HtmlEditorToolbarStandard.superclass.onRender.call(this, ct, position);
31085 this.el.dom.style.marginBottom = '0';
31087 var editorcore = this.editorcore;
31088 var editor= this.editor;
31091 var btn = function(id,cmd , toggle, handler, html){
31093 var event = toggle ? 'toggle' : 'click';
31098 xns: Roo.bootstrap,
31102 enableToggle:toggle !== false,
31104 pressed : toggle ? false : null,
31107 a.listeners[toggle ? 'toggle' : 'click'] = function() {
31108 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
31114 // var cb_box = function...
31119 xns: Roo.bootstrap,
31124 xns: Roo.bootstrap,
31128 Roo.each(this.formats, function(f) {
31129 style.menu.items.push({
31131 xns: Roo.bootstrap,
31132 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
31137 editorcore.insertTag(this.tagname);
31144 children.push(style);
31146 btn('bold',false,true);
31147 btn('italic',false,true);
31148 btn('align-left', 'justifyleft',true);
31149 btn('align-center', 'justifycenter',true);
31150 btn('align-right' , 'justifyright',true);
31151 btn('link', false, false, function(btn) {
31152 //Roo.log("create link?");
31153 var url = prompt(this.createLinkText, this.defaultLinkValue);
31154 if(url && url != 'http:/'+'/'){
31155 this.editorcore.relayCmd('createlink', url);
31158 btn('list','insertunorderedlist',true);
31159 btn('pencil', false,true, function(btn){
31161 this.toggleSourceEdit(btn.pressed);
31164 if (this.editor.btns.length > 0) {
31165 for (var i = 0; i<this.editor.btns.length; i++) {
31166 children.push(this.editor.btns[i]);
31174 xns: Roo.bootstrap,
31179 xns: Roo.bootstrap,
31184 cog.menu.items.push({
31186 xns: Roo.bootstrap,
31187 html : Clean styles,
31192 editorcore.insertTag(this.tagname);
31201 this.xtype = 'NavSimplebar';
31203 for(var i=0;i< children.length;i++) {
31205 this.buttons.add(this.addxtypeChild(children[i]));
31209 editor.on('editorevent', this.updateToolbar, this);
31211 onBtnClick : function(id)
31213 this.editorcore.relayCmd(id);
31214 this.editorcore.focus();
31218 * Protected method that will not generally be called directly. It triggers
31219 * a toolbar update by reading the markup state of the current selection in the editor.
31221 updateToolbar: function(){
31223 if(!this.editorcore.activated){
31224 this.editor.onFirstFocus(); // is this neeed?
31228 var btns = this.buttons;
31229 var doc = this.editorcore.doc;
31230 btns.get('bold').setActive(doc.queryCommandState('bold'));
31231 btns.get('italic').setActive(doc.queryCommandState('italic'));
31232 //btns.get('underline').setActive(doc.queryCommandState('underline'));
31234 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
31235 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
31236 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
31238 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
31239 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
31242 var ans = this.editorcore.getAllAncestors();
31243 if (this.formatCombo) {
31246 var store = this.formatCombo.store;
31247 this.formatCombo.setValue("");
31248 for (var i =0; i < ans.length;i++) {
31249 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
31251 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
31259 // hides menus... - so this cant be on a menu...
31260 Roo.bootstrap.MenuMgr.hideAll();
31262 Roo.bootstrap.menu.Manager.hideAll();
31263 //this.editorsyncValue();
31265 onFirstFocus: function() {
31266 this.buttons.each(function(item){
31270 toggleSourceEdit : function(sourceEditMode){
31273 if(sourceEditMode){
31274 Roo.log("disabling buttons");
31275 this.buttons.each( function(item){
31276 if(item.cmd != 'pencil'){
31282 Roo.log("enabling buttons");
31283 if(this.editorcore.initialized){
31284 this.buttons.each( function(item){
31290 Roo.log("calling toggole on editor");
31291 // tell the editor that it's been pressed..
31292 this.editor.toggleSourceEdit(sourceEditMode);
31306 * @class Roo.bootstrap.form.Markdown
31307 * @extends Roo.bootstrap.form.TextArea
31308 * Bootstrap Showdown editable area
31309 * @cfg {string} content
31312 * Create a new Showdown
31315 Roo.bootstrap.form.Markdown = function(config){
31316 Roo.bootstrap.form.Markdown.superclass.constructor.call(this, config);
31320 Roo.extend(Roo.bootstrap.form.Markdown, Roo.bootstrap.form.TextArea, {
31324 initEvents : function()
31327 Roo.bootstrap.form.TextArea.prototype.initEvents.call(this);
31328 this.markdownEl = this.el.createChild({
31329 cls : 'roo-markdown-area'
31331 this.inputEl().addClass('d-none');
31332 if (this.getValue() == '') {
31333 this.markdownEl.dom.innerHTML = String.format('<span class="roo-placeholder">{0}</span>', this.placeholder || '');
31336 this.markdownEl.dom.innerHTML = Roo.Markdown.toHtml(Roo.util.Format.htmlEncode(this.getValue()));
31338 this.markdownEl.on('click', this.toggleTextEdit, this);
31339 this.on('blur', this.toggleTextEdit, this);
31340 this.on('specialkey', this.resizeTextArea, this);
31343 toggleTextEdit : function()
31345 var sh = this.markdownEl.getHeight();
31346 this.inputEl().addClass('d-none');
31347 this.markdownEl.addClass('d-none');
31348 if (!this.editing) {
31350 this.inputEl().setHeight(Math.min(500, Math.max(sh,(this.getValue().split("\n").length+1) * 30)));
31351 this.inputEl().removeClass('d-none');
31352 this.inputEl().focus();
31353 this.editing = true;
31356 // show showdown...
31357 this.updateMarkdown();
31358 this.markdownEl.removeClass('d-none');
31359 this.editing = false;
31362 updateMarkdown : function()
31364 if (this.getValue() == '') {
31365 this.markdownEl.dom.innerHTML = String.format('<span class="roo-placeholder">{0}</span>', this.placeholder || '');
31369 this.markdownEl.dom.innerHTML = Roo.Markdown.toHtml(Roo.util.Format.htmlEncode(this.getValue()));
31372 resizeTextArea: function () {
31375 Roo.log([sh, this.getValue().split("\n").length * 30]);
31376 this.inputEl().setHeight(Math.min(500, Math.max(sh, (this.getValue().split("\n").length +1) * 30)));
31378 setValue : function(val)
31380 Roo.bootstrap.form.TextArea.prototype.setValue.call(this,val);
31381 if (!this.editing) {
31382 this.updateMarkdown();
31388 if (!this.editing) {
31389 this.toggleTextEdit();
31397 * Ext JS Library 1.1.1
31398 * Copyright(c) 2006-2007, Ext JS, LLC.
31400 * Originally Released Under LGPL - original licence link has changed is not relivant.
31403 * <script type="text/javascript">
31407 * @class Roo.bootstrap.PagingToolbar
31408 * @extends Roo.bootstrap.nav.Simplebar
31409 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
31411 * Create a new PagingToolbar
31412 * @param {Object} config The config object
31413 * @param {Roo.data.Store} store
31415 Roo.bootstrap.PagingToolbar = function(config)
31417 // old args format still supported... - xtype is prefered..
31418 // created from xtype...
31420 this.ds = config.dataSource;
31422 if (config.store && !this.ds) {
31423 this.store= Roo.factory(config.store, Roo.data);
31424 this.ds = this.store;
31425 this.ds.xmodule = this.xmodule || false;
31428 this.toolbarItems = [];
31429 if (config.items) {
31430 this.toolbarItems = config.items;
31433 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
31438 this.bind(this.ds);
31441 if (Roo.bootstrap.version == 4) {
31442 this.navgroup = new Roo.bootstrap.ButtonGroup({ cls: 'pagination' });
31444 this.navgroup = new Roo.bootstrap.nav.Group({ cls: 'pagination' });
31449 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.nav.Simplebar, {
31451 * @cfg {Roo.bootstrap.Button} buttons[]
31452 * Buttons for the toolbar
31455 * @cfg {Roo.data.Store} store
31456 * The underlying data store providing the paged data
31459 * @cfg {String/HTMLElement/Element} container
31460 * container The id or element that will contain the toolbar
31463 * @cfg {Boolean} displayInfo
31464 * True to display the displayMsg (defaults to false)
31467 * @cfg {Number} pageSize
31468 * The number of records to display per page (defaults to 20)
31472 * @cfg {String} displayMsg
31473 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
31475 displayMsg : 'Displaying {0} - {1} of {2}',
31477 * @cfg {String} emptyMsg
31478 * The message to display when no records are found (defaults to "No data to display")
31480 emptyMsg : 'No data to display',
31482 * Customizable piece of the default paging text (defaults to "Page")
31485 beforePageText : "Page",
31487 * Customizable piece of the default paging text (defaults to "of %0")
31490 afterPageText : "of {0}",
31492 * Customizable piece of the default paging text (defaults to "First Page")
31495 firstText : "First Page",
31497 * Customizable piece of the default paging text (defaults to "Previous Page")
31500 prevText : "Previous Page",
31502 * Customizable piece of the default paging text (defaults to "Next Page")
31505 nextText : "Next Page",
31507 * Customizable piece of the default paging text (defaults to "Last Page")
31510 lastText : "Last Page",
31512 * Customizable piece of the default paging text (defaults to "Refresh")
31515 refreshText : "Refresh",
31519 onRender : function(ct, position)
31521 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
31522 this.navgroup.parentId = this.id;
31523 this.navgroup.onRender(this.el, null);
31524 // add the buttons to the navgroup
31526 if(this.displayInfo){
31527 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
31528 this.displayEl = this.el.select('.x-paging-info', true).first();
31529 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
31530 // this.displayEl = navel.el.select('span',true).first();
31536 Roo.each(_this.buttons, function(e){ // this might need to use render????
31537 Roo.factory(e).render(_this.el);
31541 Roo.each(_this.toolbarItems, function(e) {
31542 _this.navgroup.addItem(e);
31546 this.first = this.navgroup.addItem({
31547 tooltip: this.firstText,
31548 cls: "prev btn-outline-secondary",
31549 html : ' <i class="fa fa-step-backward"></i>',
31551 preventDefault: true,
31552 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
31555 this.prev = this.navgroup.addItem({
31556 tooltip: this.prevText,
31557 cls: "prev btn-outline-secondary",
31558 html : ' <i class="fa fa-backward"></i>',
31560 preventDefault: true,
31561 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
31563 //this.addSeparator();
31566 var field = this.navgroup.addItem( {
31568 cls : 'x-paging-position btn-outline-secondary',
31570 html : this.beforePageText +
31571 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
31572 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
31575 this.field = field.el.select('input', true).first();
31576 this.field.on("keydown", this.onPagingKeydown, this);
31577 this.field.on("focus", function(){this.dom.select();});
31580 this.afterTextEl = field.el.select('.x-paging-after',true).first();
31581 //this.field.setHeight(18);
31582 //this.addSeparator();
31583 this.next = this.navgroup.addItem({
31584 tooltip: this.nextText,
31585 cls: "next btn-outline-secondary",
31586 html : ' <i class="fa fa-forward"></i>',
31588 preventDefault: true,
31589 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
31591 this.last = this.navgroup.addItem({
31592 tooltip: this.lastText,
31593 html : ' <i class="fa fa-step-forward"></i>',
31594 cls: "next btn-outline-secondary",
31596 preventDefault: true,
31597 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
31599 //this.addSeparator();
31600 this.loading = this.navgroup.addItem({
31601 tooltip: this.refreshText,
31602 cls: "btn-outline-secondary",
31603 html : ' <i class="fa fa-refresh"></i>',
31604 preventDefault: true,
31605 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
31611 updateInfo : function(){
31612 if(this.displayEl){
31613 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
31614 var msg = count == 0 ?
31618 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
31620 this.displayEl.update(msg);
31625 onLoad : function(ds, r, o)
31627 this.cursor = o.params && o.params.start ? o.params.start : 0;
31629 var d = this.getPageData(),
31634 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
31635 this.field.dom.value = ap;
31636 this.first.setDisabled(ap == 1);
31637 this.prev.setDisabled(ap == 1);
31638 this.next.setDisabled(ap == ps);
31639 this.last.setDisabled(ap == ps);
31640 this.loading.enable();
31645 getPageData : function(){
31646 var total = this.ds.getTotalCount();
31649 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
31650 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
31655 onLoadError : function(proxy, o){
31656 this.loading.enable();
31657 if (this.ds.events.loadexception.listeners.length < 2) {
31658 // nothing has been assigned to loadexception except this...
31660 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
31666 onPagingKeydown : function(e){
31667 var k = e.getKey();
31668 var d = this.getPageData();
31670 var v = this.field.dom.value, pageNum;
31671 if(!v || isNaN(pageNum = parseInt(v, 10))){
31672 this.field.dom.value = d.activePage;
31675 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
31676 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
31679 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))
31681 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
31682 this.field.dom.value = pageNum;
31683 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
31686 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
31688 var v = this.field.dom.value, pageNum;
31689 var increment = (e.shiftKey) ? 10 : 1;
31690 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
31693 if(!v || isNaN(pageNum = parseInt(v, 10))) {
31694 this.field.dom.value = d.activePage;
31697 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
31699 this.field.dom.value = parseInt(v, 10) + increment;
31700 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
31701 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
31708 beforeLoad : function(){
31710 this.loading.disable();
31715 onClick : function(which){
31724 ds.load({params:{start: 0, limit: this.pageSize}});
31727 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
31730 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
31733 var total = ds.getTotalCount();
31734 var extra = total % this.pageSize;
31735 var lastStart = extra ? (total - extra) : total-this.pageSize;
31736 ds.load({params:{start: lastStart, limit: this.pageSize}});
31739 ds.load({params:{start: this.cursor, limit: this.pageSize}});
31745 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
31746 * @param {Roo.data.Store} store The data store to unbind
31748 unbind : function(ds){
31749 ds.un("beforeload", this.beforeLoad, this);
31750 ds.un("load", this.onLoad, this);
31751 ds.un("loadexception", this.onLoadError, this);
31752 ds.un("remove", this.updateInfo, this);
31753 ds.un("add", this.updateInfo, this);
31754 this.ds = undefined;
31758 * Binds the paging toolbar to the specified {@link Roo.data.Store}
31759 * @param {Roo.data.Store} store The data store to bind
31761 bind : function(ds){
31762 ds.on("beforeload", this.beforeLoad, this);
31763 ds.on("load", this.onLoad, this);
31764 ds.on("loadexception", this.onLoadError, this);
31765 ds.on("remove", this.updateInfo, this);
31766 ds.on("add", this.updateInfo, this);
31777 * @class Roo.bootstrap.MessageBar
31778 * @extends Roo.bootstrap.Component
31779 * Bootstrap MessageBar class
31780 * @cfg {String} html contents of the MessageBar
31781 * @cfg {String} weight (info | success | warning | danger) default info
31782 * @cfg {String} beforeClass insert the bar before the given class
31783 * @cfg {Boolean} closable (true | false) default false
31784 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
31787 * Create a new Element
31788 * @param {Object} config The config object
31791 Roo.bootstrap.MessageBar = function(config){
31792 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
31795 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
31801 beforeClass: 'bootstrap-sticky-wrap',
31803 getAutoCreate : function(){
31807 cls: 'alert alert-dismissable alert-' + this.weight,
31812 html: this.html || ''
31818 cfg.cls += ' alert-messages-fixed';
31832 onRender : function(ct, position)
31834 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
31837 var cfg = Roo.apply({}, this.getAutoCreate());
31841 cfg.cls += ' ' + this.cls;
31844 cfg.style = this.style;
31846 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
31848 this.el.setVisibilityMode(Roo.Element.DISPLAY);
31851 this.el.select('>button.close').on('click', this.hide, this);
31857 if (!this.rendered) {
31863 this.fireEvent('show', this);
31869 if (!this.rendered) {
31875 this.fireEvent('hide', this);
31878 update : function()
31880 // var e = this.el.dom.firstChild;
31882 // if(this.closable){
31883 // e = e.nextSibling;
31886 // e.data = this.html || '';
31888 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
31904 * @class Roo.bootstrap.Graph
31905 * @extends Roo.bootstrap.Component
31906 * Bootstrap Graph class
31910 @cfg {String} graphtype bar | vbar | pie
31911 @cfg {number} g_x coodinator | centre x (pie)
31912 @cfg {number} g_y coodinator | centre y (pie)
31913 @cfg {number} g_r radius (pie)
31914 @cfg {number} g_height height of the chart (respected by all elements in the set)
31915 @cfg {number} g_width width of the chart (respected by all elements in the set)
31916 @cfg {Object} title The title of the chart
31919 -opts (object) options for the chart
31921 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
31922 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
31924 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.
31925 o stacked (boolean) whether or not to tread values as in a stacked bar chart
31927 o stretch (boolean)
31929 -opts (object) options for the pie
31932 o startAngle (number)
31933 o endAngle (number)
31937 * Create a new Input
31938 * @param {Object} config The config object
31941 Roo.bootstrap.Graph = function(config){
31942 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
31948 * The img click event for the img.
31949 * @param {Roo.EventObject} e
31955 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
31966 //g_colors: this.colors,
31973 getAutoCreate : function(){
31984 onRender : function(ct,position){
31987 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
31989 if (typeof(Raphael) == 'undefined') {
31990 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
31994 this.raphael = Raphael(this.el.dom);
31996 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
31997 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
31998 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
31999 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
32001 r.text(160, 10, "Single Series Chart").attr(txtattr);
32002 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
32003 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
32004 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
32006 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
32007 r.barchart(330, 10, 300, 220, data1);
32008 r.barchart(10, 250, 300, 220, data2, {stacked: true});
32009 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
32012 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
32013 // r.barchart(30, 30, 560, 250, xdata, {
32014 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
32015 // axis : "0 0 1 1",
32016 // axisxlabels : xdata
32017 // //yvalues : cols,
32020 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
32022 // this.load(null,xdata,{
32023 // axis : "0 0 1 1",
32024 // axisxlabels : xdata
32029 load : function(graphtype,xdata,opts)
32031 this.raphael.clear();
32033 graphtype = this.graphtype;
32038 var r = this.raphael,
32039 fin = function () {
32040 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
32042 fout = function () {
32043 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
32045 pfin = function() {
32046 this.sector.stop();
32047 this.sector.scale(1.1, 1.1, this.cx, this.cy);
32050 this.label[0].stop();
32051 this.label[0].attr({ r: 7.5 });
32052 this.label[1].attr({ "font-weight": 800 });
32055 pfout = function() {
32056 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
32059 this.label[0].animate({ r: 5 }, 500, "bounce");
32060 this.label[1].attr({ "font-weight": 400 });
32066 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
32069 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
32072 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
32073 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
32075 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
32082 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
32087 setTitle: function(o)
32092 initEvents: function() {
32095 this.el.on('click', this.onClick, this);
32099 onClick : function(e)
32101 Roo.log('img onclick');
32102 this.fireEvent('click', this, e);
32108 Roo.bootstrap.dash = {};/*
32114 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
32117 * @class Roo.bootstrap.dash.NumberBox
32118 * @extends Roo.bootstrap.Component
32119 * Bootstrap NumberBox class
32120 * @cfg {String} headline Box headline
32121 * @cfg {String} content Box content
32122 * @cfg {String} icon Box icon
32123 * @cfg {String} footer Footer text
32124 * @cfg {String} fhref Footer href
32127 * Create a new NumberBox
32128 * @param {Object} config The config object
32132 Roo.bootstrap.dash.NumberBox = function(config){
32133 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
32137 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
32146 getAutoCreate : function(){
32150 cls : 'small-box ',
32158 cls : 'roo-headline',
32159 html : this.headline
32163 cls : 'roo-content',
32164 html : this.content
32178 cls : 'ion ' + this.icon
32187 cls : 'small-box-footer',
32188 href : this.fhref || '#',
32192 cfg.cn.push(footer);
32199 onRender : function(ct,position){
32200 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
32207 setHeadline: function (value)
32209 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
32212 setFooter: function (value, href)
32214 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
32217 this.el.select('a.small-box-footer',true).first().attr('href', href);
32222 setContent: function (value)
32224 this.el.select('.roo-content',true).first().dom.innerHTML = value;
32227 initEvents: function()
32241 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
32244 * @class Roo.bootstrap.dash.TabBox
32245 * @extends Roo.bootstrap.Component
32246 * @children Roo.bootstrap.dash.TabPane
32247 * Bootstrap TabBox class
32248 * @cfg {String} title Title of the TabBox
32249 * @cfg {String} icon Icon of the TabBox
32250 * @cfg {Boolean} showtabs (true|false) show the tabs default true
32251 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
32254 * Create a new TabBox
32255 * @param {Object} config The config object
32259 Roo.bootstrap.dash.TabBox = function(config){
32260 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
32265 * When a pane is added
32266 * @param {Roo.bootstrap.dash.TabPane} pane
32270 * @event activatepane
32271 * When a pane is activated
32272 * @param {Roo.bootstrap.dash.TabPane} pane
32274 "activatepane" : true
32282 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
32287 tabScrollable : false,
32289 getChildContainer : function()
32291 return this.el.select('.tab-content', true).first();
32294 getAutoCreate : function(){
32298 cls: 'pull-left header',
32306 cls: 'fa ' + this.icon
32312 cls: 'nav nav-tabs pull-right',
32318 if(this.tabScrollable){
32325 cls: 'nav nav-tabs pull-right',
32336 cls: 'nav-tabs-custom',
32341 cls: 'tab-content no-padding',
32349 initEvents : function()
32351 //Roo.log('add add pane handler');
32352 this.on('addpane', this.onAddPane, this);
32355 * Updates the box title
32356 * @param {String} html to set the title to.
32358 setTitle : function(value)
32360 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
32362 onAddPane : function(pane)
32364 this.panes.push(pane);
32365 //Roo.log('addpane');
32367 // tabs are rendere left to right..
32368 if(!this.showtabs){
32372 var ctr = this.el.select('.nav-tabs', true).first();
32375 var existing = ctr.select('.nav-tab',true);
32376 var qty = existing.getCount();;
32379 var tab = ctr.createChild({
32381 cls : 'nav-tab' + (qty ? '' : ' active'),
32389 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
32392 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
32394 pane.el.addClass('active');
32399 onTabClick : function(ev,un,ob,pane)
32401 //Roo.log('tab - prev default');
32402 ev.preventDefault();
32405 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
32406 pane.tab.addClass('active');
32407 //Roo.log(pane.title);
32408 this.getChildContainer().select('.tab-pane',true).removeClass('active');
32409 // technically we should have a deactivate event.. but maybe add later.
32410 // and it should not de-activate the selected tab...
32411 this.fireEvent('activatepane', pane);
32412 pane.el.addClass('active');
32413 pane.fireEvent('activate');
32418 getActivePane : function()
32421 Roo.each(this.panes, function(p) {
32422 if(p.el.hasClass('active')){
32443 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
32445 * @class Roo.bootstrap.TabPane
32446 * @extends Roo.bootstrap.Component
32447 * @children Roo.bootstrap.Graph Roo.bootstrap.Column
32448 * Bootstrap TabPane class
32449 * @cfg {Boolean} active (false | true) Default false
32450 * @cfg {String} title title of panel
32454 * Create a new TabPane
32455 * @param {Object} config The config object
32458 Roo.bootstrap.dash.TabPane = function(config){
32459 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
32465 * When a pane is activated
32466 * @param {Roo.bootstrap.dash.TabPane} pane
32473 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
32478 // the tabBox that this is attached to.
32481 getAutoCreate : function()
32489 cfg.cls += ' active';
32494 initEvents : function()
32496 //Roo.log('trigger add pane handler');
32497 this.parent().fireEvent('addpane', this)
32501 * Updates the tab title
32502 * @param {String} html to set the title to.
32504 setTitle: function(str)
32510 this.tab.select('a', true).first().dom.innerHTML = str;
32529 * @class Roo.bootstrap.Tooltip
32530 * Bootstrap Tooltip class
32531 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
32532 * to determine which dom element triggers the tooltip.
32534 * It needs to add support for additional attributes like tooltip-position
32537 * Create a new Toolti
32538 * @param {Object} config The config object
32541 Roo.bootstrap.Tooltip = function(config){
32542 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
32544 this.alignment = Roo.bootstrap.Tooltip.alignment;
32546 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
32547 this.alignment = config.alignment;
32552 Roo.apply(Roo.bootstrap.Tooltip, {
32554 * @function init initialize tooltip monitoring.
32558 currentTip : false,
32559 currentRegion : false,
32565 Roo.get(document).on('mouseover', this.enter ,this);
32566 Roo.get(document).on('mouseout', this.leave, this);
32569 this.currentTip = new Roo.bootstrap.Tooltip();
32572 enter : function(ev)
32574 var dom = ev.getTarget();
32576 //Roo.log(['enter',dom]);
32577 var el = Roo.fly(dom);
32578 if (this.currentEl) {
32580 //Roo.log(this.currentEl);
32581 //Roo.log(this.currentEl.contains(dom));
32582 if (this.currentEl == el) {
32585 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
32591 if (this.currentTip.el) {
32592 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
32596 if(!el || el.dom == document){
32602 if (!el.attr('tooltip')) {
32603 pel = el.findParent("[tooltip]");
32605 bindEl = Roo.get(pel);
32611 // you can not look for children, as if el is the body.. then everythign is the child..
32612 if (!pel && !el.attr('tooltip')) { //
32613 if (!el.select("[tooltip]").elements.length) {
32616 // is the mouse over this child...?
32617 bindEl = el.select("[tooltip]").first();
32618 var xy = ev.getXY();
32619 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
32620 //Roo.log("not in region.");
32623 //Roo.log("child element over..");
32626 this.currentEl = el;
32627 this.currentTip.bind(bindEl);
32628 this.currentRegion = Roo.lib.Region.getRegion(dom);
32629 this.currentTip.enter();
32632 leave : function(ev)
32634 var dom = ev.getTarget();
32635 //Roo.log(['leave',dom]);
32636 if (!this.currentEl) {
32641 if (dom != this.currentEl.dom) {
32644 var xy = ev.getXY();
32645 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
32648 // only activate leave if mouse cursor is outside... bounding box..
32653 if (this.currentTip) {
32654 this.currentTip.leave();
32656 //Roo.log('clear currentEl');
32657 this.currentEl = false;
32662 'left' : ['r-l', [-2,0], 'right'],
32663 'right' : ['l-r', [2,0], 'left'],
32664 'bottom' : ['t-b', [0,2], 'top'],
32665 'top' : [ 'b-t', [0,-2], 'bottom']
32671 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
32676 delay : null, // can be { show : 300 , hide: 500}
32680 hoverState : null, //???
32682 placement : 'bottom',
32686 getAutoCreate : function(){
32693 cls : 'tooltip-arrow arrow'
32696 cls : 'tooltip-inner'
32703 bind : function(el)
32708 initEvents : function()
32710 this.arrowEl = this.el.select('.arrow', true).first();
32711 this.innerEl = this.el.select('.tooltip-inner', true).first();
32714 enter : function () {
32716 if (this.timeout != null) {
32717 clearTimeout(this.timeout);
32720 this.hoverState = 'in';
32721 //Roo.log("enter - show");
32722 if (!this.delay || !this.delay.show) {
32727 this.timeout = setTimeout(function () {
32728 if (_t.hoverState == 'in') {
32731 }, this.delay.show);
32735 clearTimeout(this.timeout);
32737 this.hoverState = 'out';
32738 if (!this.delay || !this.delay.hide) {
32744 this.timeout = setTimeout(function () {
32745 //Roo.log("leave - timeout");
32747 if (_t.hoverState == 'out') {
32749 Roo.bootstrap.Tooltip.currentEl = false;
32754 show : function (msg)
32757 this.render(document.body);
32760 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
32762 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
32764 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
32766 this.el.removeClass(['fade','top','bottom', 'left', 'right','in',
32767 'bs-tooltip-top','bs-tooltip-bottom', 'bs-tooltip-left', 'bs-tooltip-right']);
32769 this.el.addClass(this.bindEl.attr('tooltip-class'));
32771 var placement = typeof this.placement == 'function' ?
32772 this.placement.call(this, this.el, on_el) :
32775 var autoToken = /\s?auto?\s?/i;
32776 var autoPlace = autoToken.test(placement);
32778 placement = placement.replace(autoToken, '') || 'top';
32782 //this.el.setXY([0,0]);
32784 //this.el.dom.style.display='block';
32786 //this.el.appendTo(on_el);
32788 var p = this.getPosition();
32789 var box = this.el.getBox();
32795 var align = this.alignment[placement];
32797 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
32799 if(placement == 'top' || placement == 'bottom'){
32801 placement = 'right';
32804 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
32805 placement = 'left';
32808 var scroll = Roo.select('body', true).first().getScroll();
32810 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
32814 align = this.alignment[placement];
32816 this.arrowEl.setLeft((this.innerEl.getWidth()/2) - 5);
32820 var elems = document.getElementsByTagName('div');
32821 var highest = Number.MIN_SAFE_INTEGER || -(Math.pow(2, 53) - 1);
32822 for (var i = 0; i < elems.length; i++) {
32823 var zindex = Number.parseInt(
32824 document.defaultView.getComputedStyle(elems[i], null).getPropertyValue("z-index"),
32827 if (zindex > highest) {
32834 this.el.dom.style.zIndex = highest;
32836 this.el.alignTo(this.bindEl, align[0],align[1]);
32837 //var arrow = this.el.select('.arrow',true).first();
32838 //arrow.set(align[2],
32840 this.el.addClass(placement);
32841 this.el.addClass("bs-tooltip-"+ placement);
32843 this.el.addClass('in fade show');
32845 this.hoverState = null;
32847 if (this.el.hasClass('fade')) {
32862 //this.el.setXY([0,0]);
32863 this.el.addClass(this.bindEl.attr('tooltip-class'));
32864 this.el.removeClass(['show', 'in']);
32880 * @class Roo.bootstrap.LocationPicker
32881 * @extends Roo.bootstrap.Component
32882 * Bootstrap LocationPicker class
32883 * @cfg {Number} latitude Position when init default 0
32884 * @cfg {Number} longitude Position when init default 0
32885 * @cfg {Number} zoom default 15
32886 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
32887 * @cfg {Boolean} mapTypeControl default false
32888 * @cfg {Boolean} disableDoubleClickZoom default false
32889 * @cfg {Boolean} scrollwheel default true
32890 * @cfg {Boolean} streetViewControl default false
32891 * @cfg {Number} radius default 0
32892 * @cfg {String} locationName
32893 * @cfg {Boolean} draggable default true
32894 * @cfg {Boolean} enableAutocomplete default false
32895 * @cfg {Boolean} enableReverseGeocode default true
32896 * @cfg {String} markerTitle
32899 * Create a new LocationPicker
32900 * @param {Object} config The config object
32904 Roo.bootstrap.LocationPicker = function(config){
32906 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
32911 * Fires when the picker initialized.
32912 * @param {Roo.bootstrap.LocationPicker} this
32913 * @param {Google Location} location
32917 * @event positionchanged
32918 * Fires when the picker position changed.
32919 * @param {Roo.bootstrap.LocationPicker} this
32920 * @param {Google Location} location
32922 positionchanged : true,
32925 * Fires when the map resize.
32926 * @param {Roo.bootstrap.LocationPicker} this
32931 * Fires when the map show.
32932 * @param {Roo.bootstrap.LocationPicker} this
32937 * Fires when the map hide.
32938 * @param {Roo.bootstrap.LocationPicker} this
32943 * Fires when click the map.
32944 * @param {Roo.bootstrap.LocationPicker} this
32945 * @param {Map event} e
32949 * @event mapRightClick
32950 * Fires when right click the map.
32951 * @param {Roo.bootstrap.LocationPicker} this
32952 * @param {Map event} e
32954 mapRightClick : true,
32956 * @event markerClick
32957 * Fires when click the marker.
32958 * @param {Roo.bootstrap.LocationPicker} this
32959 * @param {Map event} e
32961 markerClick : true,
32963 * @event markerRightClick
32964 * Fires when right click the marker.
32965 * @param {Roo.bootstrap.LocationPicker} this
32966 * @param {Map event} e
32968 markerRightClick : true,
32970 * @event OverlayViewDraw
32971 * Fires when OverlayView Draw
32972 * @param {Roo.bootstrap.LocationPicker} this
32974 OverlayViewDraw : true,
32976 * @event OverlayViewOnAdd
32977 * Fires when OverlayView Draw
32978 * @param {Roo.bootstrap.LocationPicker} this
32980 OverlayViewOnAdd : true,
32982 * @event OverlayViewOnRemove
32983 * Fires when OverlayView Draw
32984 * @param {Roo.bootstrap.LocationPicker} this
32986 OverlayViewOnRemove : true,
32988 * @event OverlayViewShow
32989 * Fires when OverlayView Draw
32990 * @param {Roo.bootstrap.LocationPicker} this
32991 * @param {Pixel} cpx
32993 OverlayViewShow : true,
32995 * @event OverlayViewHide
32996 * Fires when OverlayView Draw
32997 * @param {Roo.bootstrap.LocationPicker} this
32999 OverlayViewHide : true,
33001 * @event loadexception
33002 * Fires when load google lib failed.
33003 * @param {Roo.bootstrap.LocationPicker} this
33005 loadexception : true
33010 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
33012 gMapContext: false,
33018 mapTypeControl: false,
33019 disableDoubleClickZoom: false,
33021 streetViewControl: false,
33025 enableAutocomplete: false,
33026 enableReverseGeocode: true,
33029 getAutoCreate: function()
33034 cls: 'roo-location-picker'
33040 initEvents: function(ct, position)
33042 if(!this.el.getWidth() || this.isApplied()){
33046 this.el.setVisibilityMode(Roo.Element.DISPLAY);
33051 initial: function()
33053 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
33054 this.fireEvent('loadexception', this);
33058 if(!this.mapTypeId){
33059 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
33062 this.gMapContext = this.GMapContext();
33064 this.initOverlayView();
33066 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
33070 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
33071 _this.setPosition(_this.gMapContext.marker.position);
33074 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
33075 _this.fireEvent('mapClick', this, event);
33079 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
33080 _this.fireEvent('mapRightClick', this, event);
33084 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
33085 _this.fireEvent('markerClick', this, event);
33089 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
33090 _this.fireEvent('markerRightClick', this, event);
33094 this.setPosition(this.gMapContext.location);
33096 this.fireEvent('initial', this, this.gMapContext.location);
33099 initOverlayView: function()
33103 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
33107 _this.fireEvent('OverlayViewDraw', _this);
33112 _this.fireEvent('OverlayViewOnAdd', _this);
33115 onRemove: function()
33117 _this.fireEvent('OverlayViewOnRemove', _this);
33120 show: function(cpx)
33122 _this.fireEvent('OverlayViewShow', _this, cpx);
33127 _this.fireEvent('OverlayViewHide', _this);
33133 fromLatLngToContainerPixel: function(event)
33135 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
33138 isApplied: function()
33140 return this.getGmapContext() == false ? false : true;
33143 getGmapContext: function()
33145 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
33148 GMapContext: function()
33150 var position = new google.maps.LatLng(this.latitude, this.longitude);
33152 var _map = new google.maps.Map(this.el.dom, {
33155 mapTypeId: this.mapTypeId,
33156 mapTypeControl: this.mapTypeControl,
33157 disableDoubleClickZoom: this.disableDoubleClickZoom,
33158 scrollwheel: this.scrollwheel,
33159 streetViewControl: this.streetViewControl,
33160 locationName: this.locationName,
33161 draggable: this.draggable,
33162 enableAutocomplete: this.enableAutocomplete,
33163 enableReverseGeocode: this.enableReverseGeocode
33166 var _marker = new google.maps.Marker({
33167 position: position,
33169 title: this.markerTitle,
33170 draggable: this.draggable
33177 location: position,
33178 radius: this.radius,
33179 locationName: this.locationName,
33180 addressComponents: {
33181 formatted_address: null,
33182 addressLine1: null,
33183 addressLine2: null,
33185 streetNumber: null,
33189 stateOrProvince: null
33192 domContainer: this.el.dom,
33193 geodecoder: new google.maps.Geocoder()
33197 drawCircle: function(center, radius, options)
33199 if (this.gMapContext.circle != null) {
33200 this.gMapContext.circle.setMap(null);
33204 options = Roo.apply({}, options, {
33205 strokeColor: "#0000FF",
33206 strokeOpacity: .35,
33208 fillColor: "#0000FF",
33212 options.map = this.gMapContext.map;
33213 options.radius = radius;
33214 options.center = center;
33215 this.gMapContext.circle = new google.maps.Circle(options);
33216 return this.gMapContext.circle;
33222 setPosition: function(location)
33224 this.gMapContext.location = location;
33225 this.gMapContext.marker.setPosition(location);
33226 this.gMapContext.map.panTo(location);
33227 this.drawCircle(location, this.gMapContext.radius, {});
33231 if (this.gMapContext.settings.enableReverseGeocode) {
33232 this.gMapContext.geodecoder.geocode({
33233 latLng: this.gMapContext.location
33234 }, function(results, status) {
33236 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
33237 _this.gMapContext.locationName = results[0].formatted_address;
33238 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
33240 _this.fireEvent('positionchanged', this, location);
33247 this.fireEvent('positionchanged', this, location);
33252 google.maps.event.trigger(this.gMapContext.map, "resize");
33254 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
33256 this.fireEvent('resize', this);
33259 setPositionByLatLng: function(latitude, longitude)
33261 this.setPosition(new google.maps.LatLng(latitude, longitude));
33264 getCurrentPosition: function()
33267 latitude: this.gMapContext.location.lat(),
33268 longitude: this.gMapContext.location.lng()
33272 getAddressName: function()
33274 return this.gMapContext.locationName;
33277 getAddressComponents: function()
33279 return this.gMapContext.addressComponents;
33282 address_component_from_google_geocode: function(address_components)
33286 for (var i = 0; i < address_components.length; i++) {
33287 var component = address_components[i];
33288 if (component.types.indexOf("postal_code") >= 0) {
33289 result.postalCode = component.short_name;
33290 } else if (component.types.indexOf("street_number") >= 0) {
33291 result.streetNumber = component.short_name;
33292 } else if (component.types.indexOf("route") >= 0) {
33293 result.streetName = component.short_name;
33294 } else if (component.types.indexOf("neighborhood") >= 0) {
33295 result.city = component.short_name;
33296 } else if (component.types.indexOf("locality") >= 0) {
33297 result.city = component.short_name;
33298 } else if (component.types.indexOf("sublocality") >= 0) {
33299 result.district = component.short_name;
33300 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
33301 result.stateOrProvince = component.short_name;
33302 } else if (component.types.indexOf("country") >= 0) {
33303 result.country = component.short_name;
33307 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
33308 result.addressLine2 = "";
33312 setZoomLevel: function(zoom)
33314 this.gMapContext.map.setZoom(zoom);
33327 this.fireEvent('show', this);
33338 this.fireEvent('hide', this);
33343 Roo.apply(Roo.bootstrap.LocationPicker, {
33345 OverlayView : function(map, options)
33347 options = options || {};
33354 * @class Roo.bootstrap.Alert
33355 * @extends Roo.bootstrap.Component
33356 * Bootstrap Alert class - shows an alert area box
33358 * <div class="alert alert-danger" role="alert"><span class="fa fa-exclamation-triangle"></span><span class="sr-only">Error:</span>
33359 Enter a valid email address
33362 * @cfg {String} title The title of alert
33363 * @cfg {String} html The content of alert
33364 * @cfg {String} weight (success|info|warning|danger) Weight of the message
33365 * @cfg {String} fa font-awesomeicon
33366 * @cfg {Number} seconds default:-1 Number of seconds until it disapears (-1 means never.)
33367 * @cfg {Boolean} close true to show a x closer
33371 * Create a new alert
33372 * @param {Object} config The config object
33376 Roo.bootstrap.Alert = function(config){
33377 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
33381 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
33387 faicon: false, // BC
33391 getAutoCreate : function()
33403 style : this.close ? '' : 'display:none'
33407 cls : 'roo-alert-icon'
33412 cls : 'roo-alert-title',
33417 cls : 'roo-alert-text',
33424 cfg.cn[0].cls += ' fa ' + this.faicon;
33427 cfg.cn[0].cls += ' fa ' + this.fa;
33431 cfg.cls += ' alert-' + this.weight;
33437 initEvents: function()
33439 this.el.setVisibilityMode(Roo.Element.DISPLAY);
33440 this.titleEl = this.el.select('.roo-alert-title',true).first();
33441 this.iconEl = this.el.select('.roo-alert-icon',true).first();
33442 this.htmlEl = this.el.select('.roo-alert-text',true).first();
33443 if (this.seconds > 0) {
33444 this.hide.defer(this.seconds, this);
33448 * Set the Title Message HTML
33449 * @param {String} html
33451 setTitle : function(str)
33453 this.titleEl.dom.innerHTML = str;
33457 * Set the Body Message HTML
33458 * @param {String} html
33460 setHtml : function(str)
33462 this.htmlEl.dom.innerHTML = str;
33465 * Set the Weight of the alert
33466 * @param {String} (success|info|warning|danger) weight
33469 setWeight : function(weight)
33472 this.el.removeClass('alert-' + this.weight);
33475 this.weight = weight;
33477 this.el.addClass('alert-' + this.weight);
33480 * Set the Icon of the alert
33481 * @param {String} see fontawsome names (name without the 'fa-' bit)
33483 setIcon : function(icon)
33486 this.alertEl.removeClass(['fa', 'fa-' + this.faicon]);
33489 this.faicon = icon;
33491 this.alertEl.addClass(['fa', 'fa-' + this.faicon]);
33516 * @class Roo.bootstrap.UploadCropbox
33517 * @extends Roo.bootstrap.Component
33518 * Bootstrap UploadCropbox class
33519 * @cfg {String} emptyText show when image has been loaded
33520 * @cfg {String} rotateNotify show when image too small to rotate
33521 * @cfg {Number} errorTimeout default 3000
33522 * @cfg {Number} minWidth default 300
33523 * @cfg {Number} minHeight default 300
33524 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
33525 * @cfg {Boolean} isDocument (true|false) default false
33526 * @cfg {String} url action url
33527 * @cfg {String} paramName default 'imageUpload'
33528 * @cfg {String} method default POST
33529 * @cfg {Boolean} loadMask (true|false) default true
33530 * @cfg {Boolean} loadingText default 'Loading...'
33533 * Create a new UploadCropbox
33534 * @param {Object} config The config object
33537 Roo.bootstrap.UploadCropbox = function(config){
33538 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
33542 * @event beforeselectfile
33543 * Fire before select file
33544 * @param {Roo.bootstrap.UploadCropbox} this
33546 "beforeselectfile" : true,
33549 * Fire after initEvent
33550 * @param {Roo.bootstrap.UploadCropbox} this
33555 * Fire after initEvent
33556 * @param {Roo.bootstrap.UploadCropbox} this
33557 * @param {String} data
33562 * Fire when preparing the file data
33563 * @param {Roo.bootstrap.UploadCropbox} this
33564 * @param {Object} file
33569 * Fire when get exception
33570 * @param {Roo.bootstrap.UploadCropbox} this
33571 * @param {XMLHttpRequest} xhr
33573 "exception" : true,
33575 * @event beforeloadcanvas
33576 * Fire before load the canvas
33577 * @param {Roo.bootstrap.UploadCropbox} this
33578 * @param {String} src
33580 "beforeloadcanvas" : true,
33583 * Fire when trash image
33584 * @param {Roo.bootstrap.UploadCropbox} this
33589 * Fire when download the image
33590 * @param {Roo.bootstrap.UploadCropbox} this
33594 * @event footerbuttonclick
33595 * Fire when footerbuttonclick
33596 * @param {Roo.bootstrap.UploadCropbox} this
33597 * @param {String} type
33599 "footerbuttonclick" : true,
33603 * @param {Roo.bootstrap.UploadCropbox} this
33608 * Fire when rotate the image
33609 * @param {Roo.bootstrap.UploadCropbox} this
33610 * @param {String} pos
33615 * Fire when inspect the file
33616 * @param {Roo.bootstrap.UploadCropbox} this
33617 * @param {Object} file
33622 * Fire when xhr upload the file
33623 * @param {Roo.bootstrap.UploadCropbox} this
33624 * @param {Object} data
33629 * Fire when arrange the file data
33630 * @param {Roo.bootstrap.UploadCropbox} this
33631 * @param {Object} formData
33636 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
33639 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
33641 emptyText : 'Click to upload image',
33642 rotateNotify : 'Image is too small to rotate',
33643 errorTimeout : 3000,
33657 cropType : 'image/jpeg',
33659 canvasLoaded : false,
33660 isDocument : false,
33662 paramName : 'imageUpload',
33664 loadingText : 'Loading...',
33667 getAutoCreate : function()
33671 cls : 'roo-upload-cropbox',
33675 cls : 'roo-upload-cropbox-selector',
33680 cls : 'roo-upload-cropbox-body',
33681 style : 'cursor:pointer',
33685 cls : 'roo-upload-cropbox-preview'
33689 cls : 'roo-upload-cropbox-thumb'
33693 cls : 'roo-upload-cropbox-empty-notify',
33694 html : this.emptyText
33698 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
33699 html : this.rotateNotify
33705 cls : 'roo-upload-cropbox-footer',
33708 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
33718 onRender : function(ct, position)
33720 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
33722 if (this.buttons.length) {
33724 Roo.each(this.buttons, function(bb) {
33726 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
33728 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
33734 this.maskEl = this.el;
33738 initEvents : function()
33740 this.urlAPI = (window.createObjectURL && window) ||
33741 (window.URL && URL.revokeObjectURL && URL) ||
33742 (window.webkitURL && webkitURL);
33744 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
33745 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
33747 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
33748 this.selectorEl.hide();
33750 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
33751 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
33753 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
33754 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
33755 this.thumbEl.hide();
33757 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
33758 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
33760 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
33761 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
33762 this.errorEl.hide();
33764 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
33765 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
33766 this.footerEl.hide();
33768 this.setThumbBoxSize();
33774 this.fireEvent('initial', this);
33781 window.addEventListener("resize", function() { _this.resize(); } );
33783 this.bodyEl.on('click', this.beforeSelectFile, this);
33786 this.bodyEl.on('touchstart', this.onTouchStart, this);
33787 this.bodyEl.on('touchmove', this.onTouchMove, this);
33788 this.bodyEl.on('touchend', this.onTouchEnd, this);
33792 this.bodyEl.on('mousedown', this.onMouseDown, this);
33793 this.bodyEl.on('mousemove', this.onMouseMove, this);
33794 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
33795 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
33796 Roo.get(document).on('mouseup', this.onMouseUp, this);
33799 this.selectorEl.on('change', this.onFileSelected, this);
33805 this.baseScale = 1;
33807 this.baseRotate = 1;
33808 this.dragable = false;
33809 this.pinching = false;
33812 this.cropData = false;
33813 this.notifyEl.dom.innerHTML = this.emptyText;
33815 this.selectorEl.dom.value = '';
33819 resize : function()
33821 if(this.fireEvent('resize', this) != false){
33822 this.setThumbBoxPosition();
33823 this.setCanvasPosition();
33827 onFooterButtonClick : function(e, el, o, type)
33830 case 'rotate-left' :
33831 this.onRotateLeft(e);
33833 case 'rotate-right' :
33834 this.onRotateRight(e);
33837 this.beforeSelectFile(e);
33852 this.fireEvent('footerbuttonclick', this, type);
33855 beforeSelectFile : function(e)
33857 e.preventDefault();
33859 if(this.fireEvent('beforeselectfile', this) != false){
33860 this.selectorEl.dom.click();
33864 onFileSelected : function(e)
33866 e.preventDefault();
33868 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
33872 var file = this.selectorEl.dom.files[0];
33874 if(this.fireEvent('inspect', this, file) != false){
33875 this.prepare(file);
33880 trash : function(e)
33882 this.fireEvent('trash', this);
33885 download : function(e)
33887 this.fireEvent('download', this);
33890 loadCanvas : function(src)
33892 if(this.fireEvent('beforeloadcanvas', this, src) != false){
33896 this.imageEl = document.createElement('img');
33900 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
33902 this.imageEl.src = src;
33906 onLoadCanvas : function()
33908 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
33909 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
33911 this.bodyEl.un('click', this.beforeSelectFile, this);
33913 this.notifyEl.hide();
33914 this.thumbEl.show();
33915 this.footerEl.show();
33917 this.baseRotateLevel();
33919 if(this.isDocument){
33920 this.setThumbBoxSize();
33923 this.setThumbBoxPosition();
33925 this.baseScaleLevel();
33931 this.canvasLoaded = true;
33934 this.maskEl.unmask();
33939 setCanvasPosition : function()
33941 if(!this.canvasEl){
33945 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
33946 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
33948 this.previewEl.setLeft(pw);
33949 this.previewEl.setTop(ph);
33953 onMouseDown : function(e)
33957 this.dragable = true;
33958 this.pinching = false;
33960 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
33961 this.dragable = false;
33965 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
33966 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
33970 onMouseMove : function(e)
33974 if(!this.canvasLoaded){
33978 if (!this.dragable){
33982 var minX = Math.ceil(this.thumbEl.getLeft(true));
33983 var minY = Math.ceil(this.thumbEl.getTop(true));
33985 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
33986 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
33988 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
33989 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
33991 x = x - this.mouseX;
33992 y = y - this.mouseY;
33994 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
33995 var bgY = Math.ceil(y + this.previewEl.getTop(true));
33997 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
33998 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
34000 this.previewEl.setLeft(bgX);
34001 this.previewEl.setTop(bgY);
34003 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
34004 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
34007 onMouseUp : function(e)
34011 this.dragable = false;
34014 onMouseWheel : function(e)
34018 this.startScale = this.scale;
34020 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
34022 if(!this.zoomable()){
34023 this.scale = this.startScale;
34032 zoomable : function()
34034 var minScale = this.thumbEl.getWidth() / this.minWidth;
34036 if(this.minWidth < this.minHeight){
34037 minScale = this.thumbEl.getHeight() / this.minHeight;
34040 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
34041 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
34045 (this.rotate == 0 || this.rotate == 180) &&
34047 width > this.imageEl.OriginWidth ||
34048 height > this.imageEl.OriginHeight ||
34049 (width < this.minWidth && height < this.minHeight)
34057 (this.rotate == 90 || this.rotate == 270) &&
34059 width > this.imageEl.OriginWidth ||
34060 height > this.imageEl.OriginHeight ||
34061 (width < this.minHeight && height < this.minWidth)
34068 !this.isDocument &&
34069 (this.rotate == 0 || this.rotate == 180) &&
34071 width < this.minWidth ||
34072 width > this.imageEl.OriginWidth ||
34073 height < this.minHeight ||
34074 height > this.imageEl.OriginHeight
34081 !this.isDocument &&
34082 (this.rotate == 90 || this.rotate == 270) &&
34084 width < this.minHeight ||
34085 width > this.imageEl.OriginWidth ||
34086 height < this.minWidth ||
34087 height > this.imageEl.OriginHeight
34097 onRotateLeft : function(e)
34099 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
34101 var minScale = this.thumbEl.getWidth() / this.minWidth;
34103 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
34104 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
34106 this.startScale = this.scale;
34108 while (this.getScaleLevel() < minScale){
34110 this.scale = this.scale + 1;
34112 if(!this.zoomable()){
34117 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
34118 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
34123 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
34130 this.scale = this.startScale;
34132 this.onRotateFail();
34137 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
34139 if(this.isDocument){
34140 this.setThumbBoxSize();
34141 this.setThumbBoxPosition();
34142 this.setCanvasPosition();
34147 this.fireEvent('rotate', this, 'left');
34151 onRotateRight : function(e)
34153 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
34155 var minScale = this.thumbEl.getWidth() / this.minWidth;
34157 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
34158 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
34160 this.startScale = this.scale;
34162 while (this.getScaleLevel() < minScale){
34164 this.scale = this.scale + 1;
34166 if(!this.zoomable()){
34171 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
34172 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
34177 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
34184 this.scale = this.startScale;
34186 this.onRotateFail();
34191 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
34193 if(this.isDocument){
34194 this.setThumbBoxSize();
34195 this.setThumbBoxPosition();
34196 this.setCanvasPosition();
34201 this.fireEvent('rotate', this, 'right');
34204 onRotateFail : function()
34206 this.errorEl.show(true);
34210 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
34215 this.previewEl.dom.innerHTML = '';
34217 var canvasEl = document.createElement("canvas");
34219 var contextEl = canvasEl.getContext("2d");
34221 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
34222 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
34223 var center = this.imageEl.OriginWidth / 2;
34225 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
34226 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
34227 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
34228 center = this.imageEl.OriginHeight / 2;
34231 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
34233 contextEl.translate(center, center);
34234 contextEl.rotate(this.rotate * Math.PI / 180);
34236 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
34238 this.canvasEl = document.createElement("canvas");
34240 this.contextEl = this.canvasEl.getContext("2d");
34242 switch (this.rotate) {
34245 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
34246 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
34248 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
34253 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
34254 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
34256 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
34257 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);
34261 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
34266 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
34267 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
34269 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
34270 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);
34274 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);
34279 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
34280 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
34282 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
34283 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
34287 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);
34294 this.previewEl.appendChild(this.canvasEl);
34296 this.setCanvasPosition();
34301 if(!this.canvasLoaded){
34305 var imageCanvas = document.createElement("canvas");
34307 var imageContext = imageCanvas.getContext("2d");
34309 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
34310 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
34312 var center = imageCanvas.width / 2;
34314 imageContext.translate(center, center);
34316 imageContext.rotate(this.rotate * Math.PI / 180);
34318 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
34320 var canvas = document.createElement("canvas");
34322 var context = canvas.getContext("2d");
34324 canvas.width = this.minWidth;
34325 canvas.height = this.minHeight;
34327 switch (this.rotate) {
34330 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
34331 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
34333 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
34334 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
34336 var targetWidth = this.minWidth - 2 * x;
34337 var targetHeight = this.minHeight - 2 * y;
34341 if((x == 0 && y == 0) || (x == 0 && y > 0)){
34342 scale = targetWidth / width;
34345 if(x > 0 && y == 0){
34346 scale = targetHeight / height;
34349 if(x > 0 && y > 0){
34350 scale = targetWidth / width;
34352 if(width < height){
34353 scale = targetHeight / height;
34357 context.scale(scale, scale);
34359 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
34360 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
34362 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
34363 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
34365 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
34370 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
34371 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
34373 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
34374 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
34376 var targetWidth = this.minWidth - 2 * x;
34377 var targetHeight = this.minHeight - 2 * y;
34381 if((x == 0 && y == 0) || (x == 0 && y > 0)){
34382 scale = targetWidth / width;
34385 if(x > 0 && y == 0){
34386 scale = targetHeight / height;
34389 if(x > 0 && y > 0){
34390 scale = targetWidth / width;
34392 if(width < height){
34393 scale = targetHeight / height;
34397 context.scale(scale, scale);
34399 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
34400 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
34402 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
34403 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
34405 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
34407 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
34412 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
34413 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
34415 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
34416 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
34418 var targetWidth = this.minWidth - 2 * x;
34419 var targetHeight = this.minHeight - 2 * y;
34423 if((x == 0 && y == 0) || (x == 0 && y > 0)){
34424 scale = targetWidth / width;
34427 if(x > 0 && y == 0){
34428 scale = targetHeight / height;
34431 if(x > 0 && y > 0){
34432 scale = targetWidth / width;
34434 if(width < height){
34435 scale = targetHeight / height;
34439 context.scale(scale, scale);
34441 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
34442 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
34444 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
34445 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
34447 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
34448 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
34450 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
34455 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
34456 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
34458 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
34459 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
34461 var targetWidth = this.minWidth - 2 * x;
34462 var targetHeight = this.minHeight - 2 * y;
34466 if((x == 0 && y == 0) || (x == 0 && y > 0)){
34467 scale = targetWidth / width;
34470 if(x > 0 && y == 0){
34471 scale = targetHeight / height;
34474 if(x > 0 && y > 0){
34475 scale = targetWidth / width;
34477 if(width < height){
34478 scale = targetHeight / height;
34482 context.scale(scale, scale);
34484 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
34485 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
34487 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
34488 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
34490 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
34492 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
34499 this.cropData = canvas.toDataURL(this.cropType);
34501 if(this.fireEvent('crop', this, this.cropData) !== false){
34502 this.process(this.file, this.cropData);
34509 setThumbBoxSize : function()
34513 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
34514 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
34515 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
34517 this.minWidth = width;
34518 this.minHeight = height;
34520 if(this.rotate == 90 || this.rotate == 270){
34521 this.minWidth = height;
34522 this.minHeight = width;
34527 width = Math.ceil(this.minWidth * height / this.minHeight);
34529 if(this.minWidth > this.minHeight){
34531 height = Math.ceil(this.minHeight * width / this.minWidth);
34534 this.thumbEl.setStyle({
34535 width : width + 'px',
34536 height : height + 'px'
34543 setThumbBoxPosition : function()
34545 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
34546 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
34548 this.thumbEl.setLeft(x);
34549 this.thumbEl.setTop(y);
34553 baseRotateLevel : function()
34555 this.baseRotate = 1;
34558 typeof(this.exif) != 'undefined' &&
34559 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
34560 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
34562 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
34565 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
34569 baseScaleLevel : function()
34573 if(this.isDocument){
34575 if(this.baseRotate == 6 || this.baseRotate == 8){
34577 height = this.thumbEl.getHeight();
34578 this.baseScale = height / this.imageEl.OriginWidth;
34580 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
34581 width = this.thumbEl.getWidth();
34582 this.baseScale = width / this.imageEl.OriginHeight;
34588 height = this.thumbEl.getHeight();
34589 this.baseScale = height / this.imageEl.OriginHeight;
34591 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
34592 width = this.thumbEl.getWidth();
34593 this.baseScale = width / this.imageEl.OriginWidth;
34599 if(this.baseRotate == 6 || this.baseRotate == 8){
34601 width = this.thumbEl.getHeight();
34602 this.baseScale = width / this.imageEl.OriginHeight;
34604 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
34605 height = this.thumbEl.getWidth();
34606 this.baseScale = height / this.imageEl.OriginHeight;
34609 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
34610 height = this.thumbEl.getWidth();
34611 this.baseScale = height / this.imageEl.OriginHeight;
34613 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
34614 width = this.thumbEl.getHeight();
34615 this.baseScale = width / this.imageEl.OriginWidth;
34622 width = this.thumbEl.getWidth();
34623 this.baseScale = width / this.imageEl.OriginWidth;
34625 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
34626 height = this.thumbEl.getHeight();
34627 this.baseScale = height / this.imageEl.OriginHeight;
34630 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
34632 height = this.thumbEl.getHeight();
34633 this.baseScale = height / this.imageEl.OriginHeight;
34635 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
34636 width = this.thumbEl.getWidth();
34637 this.baseScale = width / this.imageEl.OriginWidth;
34645 getScaleLevel : function()
34647 return this.baseScale * Math.pow(1.1, this.scale);
34650 onTouchStart : function(e)
34652 if(!this.canvasLoaded){
34653 this.beforeSelectFile(e);
34657 var touches = e.browserEvent.touches;
34663 if(touches.length == 1){
34664 this.onMouseDown(e);
34668 if(touches.length != 2){
34674 for(var i = 0, finger; finger = touches[i]; i++){
34675 coords.push(finger.pageX, finger.pageY);
34678 var x = Math.pow(coords[0] - coords[2], 2);
34679 var y = Math.pow(coords[1] - coords[3], 2);
34681 this.startDistance = Math.sqrt(x + y);
34683 this.startScale = this.scale;
34685 this.pinching = true;
34686 this.dragable = false;
34690 onTouchMove : function(e)
34692 if(!this.pinching && !this.dragable){
34696 var touches = e.browserEvent.touches;
34703 this.onMouseMove(e);
34709 for(var i = 0, finger; finger = touches[i]; i++){
34710 coords.push(finger.pageX, finger.pageY);
34713 var x = Math.pow(coords[0] - coords[2], 2);
34714 var y = Math.pow(coords[1] - coords[3], 2);
34716 this.endDistance = Math.sqrt(x + y);
34718 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
34720 if(!this.zoomable()){
34721 this.scale = this.startScale;
34729 onTouchEnd : function(e)
34731 this.pinching = false;
34732 this.dragable = false;
34736 process : function(file, crop)
34739 this.maskEl.mask(this.loadingText);
34742 this.xhr = new XMLHttpRequest();
34744 file.xhr = this.xhr;
34746 this.xhr.open(this.method, this.url, true);
34749 "Accept": "application/json",
34750 "Cache-Control": "no-cache",
34751 "X-Requested-With": "XMLHttpRequest"
34754 for (var headerName in headers) {
34755 var headerValue = headers[headerName];
34757 this.xhr.setRequestHeader(headerName, headerValue);
34763 this.xhr.onload = function()
34765 _this.xhrOnLoad(_this.xhr);
34768 this.xhr.onerror = function()
34770 _this.xhrOnError(_this.xhr);
34773 var formData = new FormData();
34775 formData.append('returnHTML', 'NO');
34778 formData.append('crop', crop);
34781 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
34782 formData.append(this.paramName, file, file.name);
34785 if(typeof(file.filename) != 'undefined'){
34786 formData.append('filename', file.filename);
34789 if(typeof(file.mimetype) != 'undefined'){
34790 formData.append('mimetype', file.mimetype);
34793 if(this.fireEvent('arrange', this, formData) != false){
34794 this.xhr.send(formData);
34798 xhrOnLoad : function(xhr)
34801 this.maskEl.unmask();
34804 if (xhr.readyState !== 4) {
34805 this.fireEvent('exception', this, xhr);
34809 var response = Roo.decode(xhr.responseText);
34811 if(!response.success){
34812 this.fireEvent('exception', this, xhr);
34816 var response = Roo.decode(xhr.responseText);
34818 this.fireEvent('upload', this, response);
34822 xhrOnError : function()
34825 this.maskEl.unmask();
34828 Roo.log('xhr on error');
34830 var response = Roo.decode(xhr.responseText);
34836 prepare : function(file)
34839 this.maskEl.mask(this.loadingText);
34845 if(typeof(file) === 'string'){
34846 this.loadCanvas(file);
34850 if(!file || !this.urlAPI){
34855 this.cropType = file.type;
34859 if(this.fireEvent('prepare', this, this.file) != false){
34861 var reader = new FileReader();
34863 reader.onload = function (e) {
34864 if (e.target.error) {
34865 Roo.log(e.target.error);
34869 var buffer = e.target.result,
34870 dataView = new DataView(buffer),
34872 maxOffset = dataView.byteLength - 4,
34876 if (dataView.getUint16(0) === 0xffd8) {
34877 while (offset < maxOffset) {
34878 markerBytes = dataView.getUint16(offset);
34880 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
34881 markerLength = dataView.getUint16(offset + 2) + 2;
34882 if (offset + markerLength > dataView.byteLength) {
34883 Roo.log('Invalid meta data: Invalid segment size.');
34887 if(markerBytes == 0xffe1){
34888 _this.parseExifData(
34895 offset += markerLength;
34905 var url = _this.urlAPI.createObjectURL(_this.file);
34907 _this.loadCanvas(url);
34912 reader.readAsArrayBuffer(this.file);
34918 parseExifData : function(dataView, offset, length)
34920 var tiffOffset = offset + 10,
34924 if (dataView.getUint32(offset + 4) !== 0x45786966) {
34925 // No Exif data, might be XMP data instead
34929 // Check for the ASCII code for "Exif" (0x45786966):
34930 if (dataView.getUint32(offset + 4) !== 0x45786966) {
34931 // No Exif data, might be XMP data instead
34934 if (tiffOffset + 8 > dataView.byteLength) {
34935 Roo.log('Invalid Exif data: Invalid segment size.');
34938 // Check for the two null bytes:
34939 if (dataView.getUint16(offset + 8) !== 0x0000) {
34940 Roo.log('Invalid Exif data: Missing byte alignment offset.');
34943 // Check the byte alignment:
34944 switch (dataView.getUint16(tiffOffset)) {
34946 littleEndian = true;
34949 littleEndian = false;
34952 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
34955 // Check for the TIFF tag marker (0x002A):
34956 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
34957 Roo.log('Invalid Exif data: Missing TIFF marker.');
34960 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
34961 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
34963 this.parseExifTags(
34966 tiffOffset + dirOffset,
34971 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
34976 if (dirOffset + 6 > dataView.byteLength) {
34977 Roo.log('Invalid Exif data: Invalid directory offset.');
34980 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
34981 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
34982 if (dirEndOffset + 4 > dataView.byteLength) {
34983 Roo.log('Invalid Exif data: Invalid directory size.');
34986 for (i = 0; i < tagsNumber; i += 1) {
34990 dirOffset + 2 + 12 * i, // tag offset
34994 // Return the offset to the next directory:
34995 return dataView.getUint32(dirEndOffset, littleEndian);
34998 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
35000 var tag = dataView.getUint16(offset, littleEndian);
35002 this.exif[tag] = this.getExifValue(
35006 dataView.getUint16(offset + 2, littleEndian), // tag type
35007 dataView.getUint32(offset + 4, littleEndian), // tag length
35012 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
35014 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
35023 Roo.log('Invalid Exif data: Invalid tag type.');
35027 tagSize = tagType.size * length;
35028 // Determine if the value is contained in the dataOffset bytes,
35029 // or if the value at the dataOffset is a pointer to the actual data:
35030 dataOffset = tagSize > 4 ?
35031 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
35032 if (dataOffset + tagSize > dataView.byteLength) {
35033 Roo.log('Invalid Exif data: Invalid data offset.');
35036 if (length === 1) {
35037 return tagType.getValue(dataView, dataOffset, littleEndian);
35040 for (i = 0; i < length; i += 1) {
35041 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
35044 if (tagType.ascii) {
35046 // Concatenate the chars:
35047 for (i = 0; i < values.length; i += 1) {
35049 // Ignore the terminating NULL byte(s):
35050 if (c === '\u0000') {
35062 Roo.apply(Roo.bootstrap.UploadCropbox, {
35064 'Orientation': 0x0112
35068 1: 0, //'top-left',
35070 3: 180, //'bottom-right',
35071 // 4: 'bottom-left',
35073 6: 90, //'right-top',
35074 // 7: 'right-bottom',
35075 8: 270 //'left-bottom'
35079 // byte, 8-bit unsigned int:
35081 getValue: function (dataView, dataOffset) {
35082 return dataView.getUint8(dataOffset);
35086 // ascii, 8-bit byte:
35088 getValue: function (dataView, dataOffset) {
35089 return String.fromCharCode(dataView.getUint8(dataOffset));
35094 // short, 16 bit int:
35096 getValue: function (dataView, dataOffset, littleEndian) {
35097 return dataView.getUint16(dataOffset, littleEndian);
35101 // long, 32 bit int:
35103 getValue: function (dataView, dataOffset, littleEndian) {
35104 return dataView.getUint32(dataOffset, littleEndian);
35108 // rational = two long values, first is numerator, second is denominator:
35110 getValue: function (dataView, dataOffset, littleEndian) {
35111 return dataView.getUint32(dataOffset, littleEndian) /
35112 dataView.getUint32(dataOffset + 4, littleEndian);
35116 // slong, 32 bit signed int:
35118 getValue: function (dataView, dataOffset, littleEndian) {
35119 return dataView.getInt32(dataOffset, littleEndian);
35123 // srational, two slongs, first is numerator, second is denominator:
35125 getValue: function (dataView, dataOffset, littleEndian) {
35126 return dataView.getInt32(dataOffset, littleEndian) /
35127 dataView.getInt32(dataOffset + 4, littleEndian);
35137 cls : 'btn-group roo-upload-cropbox-rotate-left',
35138 action : 'rotate-left',
35142 cls : 'btn btn-default',
35143 html : '<i class="fa fa-undo"></i>'
35149 cls : 'btn-group roo-upload-cropbox-picture',
35150 action : 'picture',
35154 cls : 'btn btn-default',
35155 html : '<i class="fa fa-picture-o"></i>'
35161 cls : 'btn-group roo-upload-cropbox-rotate-right',
35162 action : 'rotate-right',
35166 cls : 'btn btn-default',
35167 html : '<i class="fa fa-repeat"></i>'
35175 cls : 'btn-group roo-upload-cropbox-rotate-left',
35176 action : 'rotate-left',
35180 cls : 'btn btn-default',
35181 html : '<i class="fa fa-undo"></i>'
35187 cls : 'btn-group roo-upload-cropbox-download',
35188 action : 'download',
35192 cls : 'btn btn-default',
35193 html : '<i class="fa fa-download"></i>'
35199 cls : 'btn-group roo-upload-cropbox-crop',
35204 cls : 'btn btn-default',
35205 html : '<i class="fa fa-crop"></i>'
35211 cls : 'btn-group roo-upload-cropbox-trash',
35216 cls : 'btn btn-default',
35217 html : '<i class="fa fa-trash"></i>'
35223 cls : 'btn-group roo-upload-cropbox-rotate-right',
35224 action : 'rotate-right',
35228 cls : 'btn btn-default',
35229 html : '<i class="fa fa-repeat"></i>'
35237 cls : 'btn-group roo-upload-cropbox-rotate-left',
35238 action : 'rotate-left',
35242 cls : 'btn btn-default',
35243 html : '<i class="fa fa-undo"></i>'
35249 cls : 'btn-group roo-upload-cropbox-rotate-right',
35250 action : 'rotate-right',
35254 cls : 'btn btn-default',
35255 html : '<i class="fa fa-repeat"></i>'
35268 * @class Roo.bootstrap.DocumentManager
35269 * @extends Roo.bootstrap.Component
35270 * Bootstrap DocumentManager class
35271 * @cfg {String} paramName default 'imageUpload'
35272 * @cfg {String} toolTipName default 'filename'
35273 * @cfg {String} method default POST
35274 * @cfg {String} url action url
35275 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
35276 * @cfg {Boolean} multiple multiple upload default true
35277 * @cfg {Number} thumbSize default 300
35278 * @cfg {String} fieldLabel
35279 * @cfg {Number} labelWidth default 4
35280 * @cfg {String} labelAlign (left|top) default left
35281 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
35282 * @cfg {Number} labellg set the width of label (1-12)
35283 * @cfg {Number} labelmd set the width of label (1-12)
35284 * @cfg {Number} labelsm set the width of label (1-12)
35285 * @cfg {Number} labelxs set the width of label (1-12)
35288 * Create a new DocumentManager
35289 * @param {Object} config The config object
35292 Roo.bootstrap.DocumentManager = function(config){
35293 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
35296 this.delegates = [];
35301 * Fire when initial the DocumentManager
35302 * @param {Roo.bootstrap.DocumentManager} this
35307 * inspect selected file
35308 * @param {Roo.bootstrap.DocumentManager} this
35309 * @param {File} file
35314 * Fire when xhr load exception
35315 * @param {Roo.bootstrap.DocumentManager} this
35316 * @param {XMLHttpRequest} xhr
35318 "exception" : true,
35320 * @event afterupload
35321 * Fire when xhr load exception
35322 * @param {Roo.bootstrap.DocumentManager} this
35323 * @param {XMLHttpRequest} xhr
35325 "afterupload" : true,
35328 * prepare the form data
35329 * @param {Roo.bootstrap.DocumentManager} this
35330 * @param {Object} formData
35335 * Fire when remove the file
35336 * @param {Roo.bootstrap.DocumentManager} this
35337 * @param {Object} file
35342 * Fire after refresh the file
35343 * @param {Roo.bootstrap.DocumentManager} this
35348 * Fire after click the image
35349 * @param {Roo.bootstrap.DocumentManager} this
35350 * @param {Object} file
35355 * Fire when upload a image and editable set to true
35356 * @param {Roo.bootstrap.DocumentManager} this
35357 * @param {Object} file
35361 * @event beforeselectfile
35362 * Fire before select file
35363 * @param {Roo.bootstrap.DocumentManager} this
35365 "beforeselectfile" : true,
35368 * Fire before process file
35369 * @param {Roo.bootstrap.DocumentManager} this
35370 * @param {Object} file
35374 * @event previewrendered
35375 * Fire when preview rendered
35376 * @param {Roo.bootstrap.DocumentManager} this
35377 * @param {Object} file
35379 "previewrendered" : true,
35382 "previewResize" : true
35387 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
35396 paramName : 'imageUpload',
35397 toolTipName : 'filename',
35400 labelAlign : 'left',
35410 getAutoCreate : function()
35412 var managerWidget = {
35414 cls : 'roo-document-manager',
35418 cls : 'roo-document-manager-selector',
35423 cls : 'roo-document-manager-uploader',
35427 cls : 'roo-document-manager-upload-btn',
35428 html : '<i class="fa fa-plus"></i>'
35439 cls : 'column col-md-12',
35444 if(this.fieldLabel.length){
35449 cls : 'column col-md-12',
35450 html : this.fieldLabel
35454 cls : 'column col-md-12',
35459 if(this.labelAlign == 'left'){
35464 html : this.fieldLabel
35473 if(this.labelWidth > 12){
35474 content[0].style = "width: " + this.labelWidth + 'px';
35477 if(this.labelWidth < 13 && this.labelmd == 0){
35478 this.labelmd = this.labelWidth;
35481 if(this.labellg > 0){
35482 content[0].cls += ' col-lg-' + this.labellg;
35483 content[1].cls += ' col-lg-' + (12 - this.labellg);
35486 if(this.labelmd > 0){
35487 content[0].cls += ' col-md-' + this.labelmd;
35488 content[1].cls += ' col-md-' + (12 - this.labelmd);
35491 if(this.labelsm > 0){
35492 content[0].cls += ' col-sm-' + this.labelsm;
35493 content[1].cls += ' col-sm-' + (12 - this.labelsm);
35496 if(this.labelxs > 0){
35497 content[0].cls += ' col-xs-' + this.labelxs;
35498 content[1].cls += ' col-xs-' + (12 - this.labelxs);
35506 cls : 'row clearfix',
35514 initEvents : function()
35516 this.managerEl = this.el.select('.roo-document-manager', true).first();
35517 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
35519 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
35520 this.selectorEl.hide();
35523 this.selectorEl.attr('multiple', 'multiple');
35526 this.selectorEl.on('change', this.onFileSelected, this);
35528 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
35529 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
35531 this.uploader.on('click', this.onUploaderClick, this);
35533 this.renderProgressDialog();
35537 window.addEventListener("resize", function() { _this.refresh(); } );
35539 this.fireEvent('initial', this);
35542 renderProgressDialog : function()
35546 this.progressDialog = new Roo.bootstrap.Modal({
35547 cls : 'roo-document-manager-progress-dialog',
35548 allow_close : false,
35559 btnclick : function() {
35560 _this.uploadCancel();
35566 this.progressDialog.render(Roo.get(document.body));
35568 this.progress = new Roo.bootstrap.Progress({
35569 cls : 'roo-document-manager-progress',
35574 this.progress.render(this.progressDialog.getChildContainer());
35576 this.progressBar = new Roo.bootstrap.ProgressBar({
35577 cls : 'roo-document-manager-progress-bar',
35580 aria_valuemax : 12,
35584 this.progressBar.render(this.progress.getChildContainer());
35587 onUploaderClick : function(e)
35589 e.preventDefault();
35591 if(this.fireEvent('beforeselectfile', this) != false){
35592 this.selectorEl.dom.click();
35597 onFileSelected : function(e)
35599 e.preventDefault();
35601 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
35605 Roo.each(this.selectorEl.dom.files, function(file){
35606 if(this.fireEvent('inspect', this, file) != false){
35607 this.files.push(file);
35617 this.selectorEl.dom.value = '';
35619 if(!this.files || !this.files.length){
35623 if(this.boxes > 0 && this.files.length > this.boxes){
35624 this.files = this.files.slice(0, this.boxes);
35627 this.uploader.show();
35629 if(this.boxes > 0 && this.files.length > this.boxes - 1){
35630 this.uploader.hide();
35639 Roo.each(this.files, function(file){
35641 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
35642 var f = this.renderPreview(file);
35647 if(file.type.indexOf('image') != -1){
35648 this.delegates.push(
35650 _this.process(file);
35651 }).createDelegate(this)
35659 _this.process(file);
35660 }).createDelegate(this)
35665 this.files = files;
35667 this.delegates = this.delegates.concat(docs);
35669 if(!this.delegates.length){
35674 this.progressBar.aria_valuemax = this.delegates.length;
35681 arrange : function()
35683 if(!this.delegates.length){
35684 this.progressDialog.hide();
35689 var delegate = this.delegates.shift();
35691 this.progressDialog.show();
35693 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
35695 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
35700 refresh : function()
35702 this.uploader.show();
35704 if(this.boxes > 0 && this.files.length > this.boxes - 1){
35705 this.uploader.hide();
35708 Roo.isTouch ? this.closable(false) : this.closable(true);
35710 this.fireEvent('refresh', this);
35713 onRemove : function(e, el, o)
35715 e.preventDefault();
35717 this.fireEvent('remove', this, o);
35721 remove : function(o)
35725 Roo.each(this.files, function(file){
35726 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
35735 this.files = files;
35742 Roo.each(this.files, function(file){
35747 file.target.remove();
35756 onClick : function(e, el, o)
35758 e.preventDefault();
35760 this.fireEvent('click', this, o);
35764 closable : function(closable)
35766 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
35768 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
35780 xhrOnLoad : function(xhr)
35782 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
35786 if (xhr.readyState !== 4) {
35788 this.fireEvent('exception', this, xhr);
35792 var response = Roo.decode(xhr.responseText);
35794 if(!response.success){
35796 this.fireEvent('exception', this, xhr);
35800 var file = this.renderPreview(response.data);
35802 this.files.push(file);
35806 this.fireEvent('afterupload', this, xhr);
35810 xhrOnError : function(xhr)
35812 Roo.log('xhr on error');
35814 var response = Roo.decode(xhr.responseText);
35821 process : function(file)
35823 if(this.fireEvent('process', this, file) !== false){
35824 if(this.editable && file.type.indexOf('image') != -1){
35825 this.fireEvent('edit', this, file);
35829 this.uploadStart(file, false);
35836 uploadStart : function(file, crop)
35838 this.xhr = new XMLHttpRequest();
35840 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
35845 file.xhr = this.xhr;
35847 this.managerEl.createChild({
35849 cls : 'roo-document-manager-loading',
35853 tooltip : file.name,
35854 cls : 'roo-document-manager-thumb',
35855 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
35861 this.xhr.open(this.method, this.url, true);
35864 "Accept": "application/json",
35865 "Cache-Control": "no-cache",
35866 "X-Requested-With": "XMLHttpRequest"
35869 for (var headerName in headers) {
35870 var headerValue = headers[headerName];
35872 this.xhr.setRequestHeader(headerName, headerValue);
35878 this.xhr.onload = function()
35880 _this.xhrOnLoad(_this.xhr);
35883 this.xhr.onerror = function()
35885 _this.xhrOnError(_this.xhr);
35888 var formData = new FormData();
35890 formData.append('returnHTML', 'NO');
35893 formData.append('crop', crop);
35896 formData.append(this.paramName, file, file.name);
35903 if(this.fireEvent('prepare', this, formData, options) != false){
35905 if(options.manually){
35909 this.xhr.send(formData);
35913 this.uploadCancel();
35916 uploadCancel : function()
35922 this.delegates = [];
35924 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
35931 renderPreview : function(file)
35933 if(typeof(file.target) != 'undefined' && file.target){
35937 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
35939 var previewEl = this.managerEl.createChild({
35941 cls : 'roo-document-manager-preview',
35945 tooltip : file[this.toolTipName],
35946 cls : 'roo-document-manager-thumb',
35947 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
35952 html : '<i class="fa fa-times-circle"></i>'
35957 var close = previewEl.select('button.close', true).first();
35959 close.on('click', this.onRemove, this, file);
35961 file.target = previewEl;
35963 var image = previewEl.select('img', true).first();
35967 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
35969 image.on('click', this.onClick, this, file);
35971 this.fireEvent('previewrendered', this, file);
35977 onPreviewLoad : function(file, image)
35979 if(typeof(file.target) == 'undefined' || !file.target){
35983 var width = image.dom.naturalWidth || image.dom.width;
35984 var height = image.dom.naturalHeight || image.dom.height;
35986 if(!this.previewResize) {
35990 if(width > height){
35991 file.target.addClass('wide');
35995 file.target.addClass('tall');
36000 uploadFromSource : function(file, crop)
36002 this.xhr = new XMLHttpRequest();
36004 this.managerEl.createChild({
36006 cls : 'roo-document-manager-loading',
36010 tooltip : file.name,
36011 cls : 'roo-document-manager-thumb',
36012 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
36018 this.xhr.open(this.method, this.url, true);
36021 "Accept": "application/json",
36022 "Cache-Control": "no-cache",
36023 "X-Requested-With": "XMLHttpRequest"
36026 for (var headerName in headers) {
36027 var headerValue = headers[headerName];
36029 this.xhr.setRequestHeader(headerName, headerValue);
36035 this.xhr.onload = function()
36037 _this.xhrOnLoad(_this.xhr);
36040 this.xhr.onerror = function()
36042 _this.xhrOnError(_this.xhr);
36045 var formData = new FormData();
36047 formData.append('returnHTML', 'NO');
36049 formData.append('crop', crop);
36051 if(typeof(file.filename) != 'undefined'){
36052 formData.append('filename', file.filename);
36055 if(typeof(file.mimetype) != 'undefined'){
36056 formData.append('mimetype', file.mimetype);
36061 if(this.fireEvent('prepare', this, formData) != false){
36062 this.xhr.send(formData);
36072 * @class Roo.bootstrap.DocumentViewer
36073 * @extends Roo.bootstrap.Component
36074 * Bootstrap DocumentViewer class
36075 * @cfg {Boolean} showDownload (true|false) show download button (default true)
36076 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
36079 * Create a new DocumentViewer
36080 * @param {Object} config The config object
36083 Roo.bootstrap.DocumentViewer = function(config){
36084 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
36089 * Fire after initEvent
36090 * @param {Roo.bootstrap.DocumentViewer} this
36096 * @param {Roo.bootstrap.DocumentViewer} this
36101 * Fire after download button
36102 * @param {Roo.bootstrap.DocumentViewer} this
36107 * Fire after trash button
36108 * @param {Roo.bootstrap.DocumentViewer} this
36115 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
36117 showDownload : true,
36121 getAutoCreate : function()
36125 cls : 'roo-document-viewer',
36129 cls : 'roo-document-viewer-body',
36133 cls : 'roo-document-viewer-thumb',
36137 cls : 'roo-document-viewer-image'
36145 cls : 'roo-document-viewer-footer',
36148 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
36152 cls : 'btn-group roo-document-viewer-download',
36156 cls : 'btn btn-default',
36157 html : '<i class="fa fa-download"></i>'
36163 cls : 'btn-group roo-document-viewer-trash',
36167 cls : 'btn btn-default',
36168 html : '<i class="fa fa-trash"></i>'
36181 initEvents : function()
36183 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
36184 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
36186 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
36187 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
36189 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
36190 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
36192 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
36193 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
36195 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
36196 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
36198 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
36199 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
36201 this.bodyEl.on('click', this.onClick, this);
36202 this.downloadBtn.on('click', this.onDownload, this);
36203 this.trashBtn.on('click', this.onTrash, this);
36205 this.downloadBtn.hide();
36206 this.trashBtn.hide();
36208 if(this.showDownload){
36209 this.downloadBtn.show();
36212 if(this.showTrash){
36213 this.trashBtn.show();
36216 if(!this.showDownload && !this.showTrash) {
36217 this.footerEl.hide();
36222 initial : function()
36224 this.fireEvent('initial', this);
36228 onClick : function(e)
36230 e.preventDefault();
36232 this.fireEvent('click', this);
36235 onDownload : function(e)
36237 e.preventDefault();
36239 this.fireEvent('download', this);
36242 onTrash : function(e)
36244 e.preventDefault();
36246 this.fireEvent('trash', this);
36258 * @class Roo.bootstrap.form.FieldLabel
36259 * @extends Roo.bootstrap.Component
36260 * Bootstrap FieldLabel class
36261 * @cfg {String} html contents of the element
36262 * @cfg {String} tag tag of the element default label
36263 * @cfg {String} cls class of the element
36264 * @cfg {String} target label target
36265 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
36266 * @cfg {String} invalidClass DEPRICATED - BS4 uses is-invalid
36267 * @cfg {String} validClass DEPRICATED - BS4 uses is-valid
36268 * @cfg {String} iconTooltip default "This field is required"
36269 * @cfg {String} indicatorpos (left|right) default left
36272 * Create a new FieldLabel
36273 * @param {Object} config The config object
36276 Roo.bootstrap.form.FieldLabel = function(config){
36277 Roo.bootstrap.Element.superclass.constructor.call(this, config);
36282 * Fires after the field has been marked as invalid.
36283 * @param {Roo.form.FieldLabel} this
36284 * @param {String} msg The validation message
36289 * Fires after the field has been validated with no errors.
36290 * @param {Roo.form.FieldLabel} this
36296 Roo.extend(Roo.bootstrap.form.FieldLabel, Roo.bootstrap.Component, {
36303 invalidClass : 'has-warning',
36304 validClass : 'has-success',
36305 iconTooltip : 'This field is required',
36306 indicatorpos : 'left',
36308 getAutoCreate : function(){
36311 if (!this.allowBlank) {
36317 cls : 'roo-bootstrap-field-label ' + this.cls,
36322 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star ' + cls,
36323 tooltip : this.iconTooltip
36332 if(this.indicatorpos == 'right'){
36335 cls : 'roo-bootstrap-field-label ' + this.cls,
36344 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star '+ cls,
36345 tooltip : this.iconTooltip
36354 initEvents: function()
36356 Roo.bootstrap.Element.superclass.initEvents.call(this);
36358 this.indicator = this.indicatorEl();
36360 if(this.indicator){
36361 this.indicator.removeClass('visible');
36362 this.indicator.addClass('invisible');
36365 Roo.bootstrap.form.FieldLabel.register(this);
36368 indicatorEl : function()
36370 var indicator = this.el.select('i.roo-required-indicator',true).first();
36381 * Mark this field as valid
36383 markValid : function()
36385 if(this.indicator){
36386 this.indicator.removeClass('visible');
36387 this.indicator.addClass('invisible');
36389 if (Roo.bootstrap.version == 3) {
36390 this.el.removeClass(this.invalidClass);
36391 this.el.addClass(this.validClass);
36393 this.el.removeClass('is-invalid');
36394 this.el.addClass('is-valid');
36398 this.fireEvent('valid', this);
36402 * Mark this field as invalid
36403 * @param {String} msg The validation message
36405 markInvalid : function(msg)
36407 if(this.indicator){
36408 this.indicator.removeClass('invisible');
36409 this.indicator.addClass('visible');
36411 if (Roo.bootstrap.version == 3) {
36412 this.el.removeClass(this.validClass);
36413 this.el.addClass(this.invalidClass);
36415 this.el.removeClass('is-valid');
36416 this.el.addClass('is-invalid');
36420 this.fireEvent('invalid', this, msg);
36426 Roo.apply(Roo.bootstrap.form.FieldLabel, {
36431 * register a FieldLabel Group
36432 * @param {Roo.bootstrap.form.FieldLabel} the FieldLabel to add
36434 register : function(label)
36436 if(this.groups.hasOwnProperty(label.target)){
36440 this.groups[label.target] = label;
36444 * fetch a FieldLabel Group based on the target
36445 * @param {string} target
36446 * @returns {Roo.bootstrap.form.FieldLabel} the CheckBox group
36448 get: function(target) {
36449 if (typeof(this.groups[target]) == 'undefined') {
36453 return this.groups[target] ;
36462 * page DateSplitField.
36468 * @class Roo.bootstrap.form.DateSplitField
36469 * @extends Roo.bootstrap.Component
36470 * Bootstrap DateSplitField class
36471 * @cfg {string} fieldLabel - the label associated
36472 * @cfg {Number} labelWidth set the width of label (0-12)
36473 * @cfg {String} labelAlign (top|left)
36474 * @cfg {Boolean} dayAllowBlank (true|false) default false
36475 * @cfg {Boolean} monthAllowBlank (true|false) default false
36476 * @cfg {Boolean} yearAllowBlank (true|false) default false
36477 * @cfg {string} dayPlaceholder
36478 * @cfg {string} monthPlaceholder
36479 * @cfg {string} yearPlaceholder
36480 * @cfg {string} dayFormat default 'd'
36481 * @cfg {string} monthFormat default 'm'
36482 * @cfg {string} yearFormat default 'Y'
36483 * @cfg {Number} labellg set the width of label (1-12)
36484 * @cfg {Number} labelmd set the width of label (1-12)
36485 * @cfg {Number} labelsm set the width of label (1-12)
36486 * @cfg {Number} labelxs set the width of label (1-12)
36490 * Create a new DateSplitField
36491 * @param {Object} config The config object
36494 Roo.bootstrap.form.DateSplitField = function(config){
36495 Roo.bootstrap.form.DateSplitField.superclass.constructor.call(this, config);
36501 * getting the data of years
36502 * @param {Roo.bootstrap.form.DateSplitField} this
36503 * @param {Object} years
36508 * getting the data of days
36509 * @param {Roo.bootstrap.form.DateSplitField} this
36510 * @param {Object} days
36515 * Fires after the field has been marked as invalid.
36516 * @param {Roo.form.Field} this
36517 * @param {String} msg The validation message
36522 * Fires after the field has been validated with no errors.
36523 * @param {Roo.form.Field} this
36529 Roo.extend(Roo.bootstrap.form.DateSplitField, Roo.bootstrap.Component, {
36532 labelAlign : 'top',
36534 dayAllowBlank : false,
36535 monthAllowBlank : false,
36536 yearAllowBlank : false,
36537 dayPlaceholder : '',
36538 monthPlaceholder : '',
36539 yearPlaceholder : '',
36543 isFormField : true,
36549 getAutoCreate : function()
36553 cls : 'row roo-date-split-field-group',
36558 cls : 'form-hidden-field roo-date-split-field-group-value',
36564 var labelCls = 'col-md-12';
36565 var contentCls = 'col-md-4';
36567 if(this.fieldLabel){
36571 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
36575 html : this.fieldLabel
36580 if(this.labelAlign == 'left'){
36582 if(this.labelWidth > 12){
36583 label.style = "width: " + this.labelWidth + 'px';
36586 if(this.labelWidth < 13 && this.labelmd == 0){
36587 this.labelmd = this.labelWidth;
36590 if(this.labellg > 0){
36591 labelCls = ' col-lg-' + this.labellg;
36592 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
36595 if(this.labelmd > 0){
36596 labelCls = ' col-md-' + this.labelmd;
36597 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
36600 if(this.labelsm > 0){
36601 labelCls = ' col-sm-' + this.labelsm;
36602 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
36605 if(this.labelxs > 0){
36606 labelCls = ' col-xs-' + this.labelxs;
36607 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
36611 label.cls += ' ' + labelCls;
36613 cfg.cn.push(label);
36616 Roo.each(['day', 'month', 'year'], function(t){
36619 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
36626 inputEl: function ()
36628 return this.el.select('.roo-date-split-field-group-value', true).first();
36631 onRender : function(ct, position)
36635 Roo.bootstrap.DateSplitFiel.superclass.onRender.call(this, ct, position);
36637 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
36639 this.dayField = new Roo.bootstrap.form.ComboBox({
36640 allowBlank : this.dayAllowBlank,
36641 alwaysQuery : true,
36642 displayField : 'value',
36645 forceSelection : true,
36647 placeholder : this.dayPlaceholder,
36648 selectOnFocus : true,
36649 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
36650 triggerAction : 'all',
36652 valueField : 'value',
36653 store : new Roo.data.SimpleStore({
36654 data : (function() {
36656 _this.fireEvent('days', _this, days);
36659 fields : [ 'value' ]
36662 select : function (_self, record, index)
36664 _this.setValue(_this.getValue());
36669 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
36671 this.monthField = new Roo.bootstrap.form.MonthField({
36672 after : '<i class=\"fa fa-calendar\"></i>',
36673 allowBlank : this.monthAllowBlank,
36674 placeholder : this.monthPlaceholder,
36677 render : function (_self)
36679 this.el.select('span.input-group-addon', true).first().on('click', function(e){
36680 e.preventDefault();
36684 select : function (_self, oldvalue, newvalue)
36686 _this.setValue(_this.getValue());
36691 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
36693 this.yearField = new Roo.bootstrap.form.ComboBox({
36694 allowBlank : this.yearAllowBlank,
36695 alwaysQuery : true,
36696 displayField : 'value',
36699 forceSelection : true,
36701 placeholder : this.yearPlaceholder,
36702 selectOnFocus : true,
36703 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
36704 triggerAction : 'all',
36706 valueField : 'value',
36707 store : new Roo.data.SimpleStore({
36708 data : (function() {
36710 _this.fireEvent('years', _this, years);
36713 fields : [ 'value' ]
36716 select : function (_self, record, index)
36718 _this.setValue(_this.getValue());
36723 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
36726 setValue : function(v, format)
36728 this.inputEl.dom.value = v;
36730 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
36732 var d = Date.parseDate(v, f);
36739 this.setDay(d.format(this.dayFormat));
36740 this.setMonth(d.format(this.monthFormat));
36741 this.setYear(d.format(this.yearFormat));
36748 setDay : function(v)
36750 this.dayField.setValue(v);
36751 this.inputEl.dom.value = this.getValue();
36756 setMonth : function(v)
36758 this.monthField.setValue(v, true);
36759 this.inputEl.dom.value = this.getValue();
36764 setYear : function(v)
36766 this.yearField.setValue(v);
36767 this.inputEl.dom.value = this.getValue();
36772 getDay : function()
36774 return this.dayField.getValue();
36777 getMonth : function()
36779 return this.monthField.getValue();
36782 getYear : function()
36784 return this.yearField.getValue();
36787 getValue : function()
36789 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
36791 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
36801 this.inputEl.dom.value = '';
36806 validate : function()
36808 var d = this.dayField.validate();
36809 var m = this.monthField.validate();
36810 var y = this.yearField.validate();
36815 (!this.dayAllowBlank && !d) ||
36816 (!this.monthAllowBlank && !m) ||
36817 (!this.yearAllowBlank && !y)
36822 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
36831 this.markInvalid();
36836 markValid : function()
36839 var label = this.el.select('label', true).first();
36840 var icon = this.el.select('i.fa-star', true).first();
36846 this.fireEvent('valid', this);
36850 * Mark this field as invalid
36851 * @param {String} msg The validation message
36853 markInvalid : function(msg)
36856 var label = this.el.select('label', true).first();
36857 var icon = this.el.select('i.fa-star', true).first();
36859 if(label && !icon){
36860 this.el.select('.roo-date-split-field-label', true).createChild({
36862 cls : 'text-danger fa fa-lg fa-star',
36863 tooltip : 'This field is required',
36864 style : 'margin-right:5px;'
36868 this.fireEvent('invalid', this, msg);
36871 clearInvalid : function()
36873 var label = this.el.select('label', true).first();
36874 var icon = this.el.select('i.fa-star', true).first();
36880 this.fireEvent('valid', this);
36883 getName: function()
36893 * @class Roo.bootstrap.LayoutMasonry
36894 * @extends Roo.bootstrap.Component
36895 * @children Roo.bootstrap.Element Roo.bootstrap.Img Roo.bootstrap.MasonryBrick
36896 * Bootstrap Layout Masonry class
36899 * http://masonry.desandro.com
36901 * The idea is to render all the bricks based on vertical width...
36903 * The original code extends 'outlayer' - we might need to use that....
36906 * Create a new Element
36907 * @param {Object} config The config object
36910 Roo.bootstrap.LayoutMasonry = function(config){
36912 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
36916 Roo.bootstrap.LayoutMasonry.register(this);
36922 * Fire after layout the items
36923 * @param {Roo.bootstrap.LayoutMasonry} this
36924 * @param {Roo.EventObject} e
36931 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
36934 * @cfg {Boolean} isLayoutInstant = no animation?
36936 isLayoutInstant : false, // needed?
36939 * @cfg {Number} boxWidth width of the columns
36944 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
36949 * @cfg {Number} padWidth padding below box..
36954 * @cfg {Number} gutter gutter width..
36959 * @cfg {Number} maxCols maximum number of columns
36965 * @cfg {Boolean} isAutoInitial defalut true
36967 isAutoInitial : true,
36972 * @cfg {Boolean} isHorizontal defalut false
36974 isHorizontal : false,
36976 currentSize : null,
36982 bricks: null, //CompositeElement
36986 _isLayoutInited : false,
36988 // isAlternative : false, // only use for vertical layout...
36991 * @cfg {Number} alternativePadWidth padding below box..
36993 alternativePadWidth : 50,
36995 selectedBrick : [],
36997 getAutoCreate : function(){
36999 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
37003 cls: 'blog-masonary-wrapper ' + this.cls,
37005 cls : 'mas-boxes masonary'
37012 getChildContainer: function( )
37014 if (this.boxesEl) {
37015 return this.boxesEl;
37018 this.boxesEl = this.el.select('.mas-boxes').first();
37020 return this.boxesEl;
37024 initEvents : function()
37028 if(this.isAutoInitial){
37029 Roo.log('hook children rendered');
37030 this.on('childrenrendered', function() {
37031 Roo.log('children rendered');
37037 initial : function()
37039 this.selectedBrick = [];
37041 this.currentSize = this.el.getBox(true);
37043 Roo.EventManager.onWindowResize(this.resize, this);
37045 if(!this.isAutoInitial){
37053 //this.layout.defer(500,this);
37057 resize : function()
37059 var cs = this.el.getBox(true);
37062 this.currentSize.width == cs.width &&
37063 this.currentSize.x == cs.x &&
37064 this.currentSize.height == cs.height &&
37065 this.currentSize.y == cs.y
37067 Roo.log("no change in with or X or Y");
37071 this.currentSize = cs;
37077 layout : function()
37079 this._resetLayout();
37081 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
37083 this.layoutItems( isInstant );
37085 this._isLayoutInited = true;
37087 this.fireEvent('layout', this);
37091 _resetLayout : function()
37093 if(this.isHorizontal){
37094 this.horizontalMeasureColumns();
37098 this.verticalMeasureColumns();
37102 verticalMeasureColumns : function()
37104 this.getContainerWidth();
37106 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
37107 // this.colWidth = Math.floor(this.containerWidth * 0.8);
37111 var boxWidth = this.boxWidth + this.padWidth;
37113 if(this.containerWidth < this.boxWidth){
37114 boxWidth = this.containerWidth
37117 var containerWidth = this.containerWidth;
37119 var cols = Math.floor(containerWidth / boxWidth);
37121 this.cols = Math.max( cols, 1 );
37123 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
37125 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
37127 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
37129 this.colWidth = boxWidth + avail - this.padWidth;
37131 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
37132 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
37135 horizontalMeasureColumns : function()
37137 this.getContainerWidth();
37139 var boxWidth = this.boxWidth;
37141 if(this.containerWidth < boxWidth){
37142 boxWidth = this.containerWidth;
37145 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
37147 this.el.setHeight(boxWidth);
37151 getContainerWidth : function()
37153 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
37156 layoutItems : function( isInstant )
37158 Roo.log(this.bricks);
37160 var items = Roo.apply([], this.bricks);
37162 if(this.isHorizontal){
37163 this._horizontalLayoutItems( items , isInstant );
37167 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
37168 // this._verticalAlternativeLayoutItems( items , isInstant );
37172 this._verticalLayoutItems( items , isInstant );
37176 _verticalLayoutItems : function ( items , isInstant)
37178 if ( !items || !items.length ) {
37183 ['xs', 'xs', 'xs', 'tall'],
37184 ['xs', 'xs', 'tall'],
37185 ['xs', 'xs', 'sm'],
37186 ['xs', 'xs', 'xs'],
37192 ['sm', 'xs', 'xs'],
37196 ['tall', 'xs', 'xs', 'xs'],
37197 ['tall', 'xs', 'xs'],
37209 Roo.each(items, function(item, k){
37211 switch (item.size) {
37212 // these layouts take up a full box,
37223 boxes.push([item]);
37246 var filterPattern = function(box, length)
37254 var pattern = box.slice(0, length);
37258 Roo.each(pattern, function(i){
37259 format.push(i.size);
37262 Roo.each(standard, function(s){
37264 if(String(s) != String(format)){
37273 if(!match && length == 1){
37278 filterPattern(box, length - 1);
37282 queue.push(pattern);
37284 box = box.slice(length, box.length);
37286 filterPattern(box, 4);
37292 Roo.each(boxes, function(box, k){
37298 if(box.length == 1){
37303 filterPattern(box, 4);
37307 this._processVerticalLayoutQueue( queue, isInstant );
37311 // _verticalAlternativeLayoutItems : function( items , isInstant )
37313 // if ( !items || !items.length ) {
37317 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
37321 _horizontalLayoutItems : function ( items , isInstant)
37323 if ( !items || !items.length || items.length < 3) {
37329 var eItems = items.slice(0, 3);
37331 items = items.slice(3, items.length);
37334 ['xs', 'xs', 'xs', 'wide'],
37335 ['xs', 'xs', 'wide'],
37336 ['xs', 'xs', 'sm'],
37337 ['xs', 'xs', 'xs'],
37343 ['sm', 'xs', 'xs'],
37347 ['wide', 'xs', 'xs', 'xs'],
37348 ['wide', 'xs', 'xs'],
37361 Roo.each(items, function(item, k){
37363 switch (item.size) {
37374 boxes.push([item]);
37398 var filterPattern = function(box, length)
37406 var pattern = box.slice(0, length);
37410 Roo.each(pattern, function(i){
37411 format.push(i.size);
37414 Roo.each(standard, function(s){
37416 if(String(s) != String(format)){
37425 if(!match && length == 1){
37430 filterPattern(box, length - 1);
37434 queue.push(pattern);
37436 box = box.slice(length, box.length);
37438 filterPattern(box, 4);
37444 Roo.each(boxes, function(box, k){
37450 if(box.length == 1){
37455 filterPattern(box, 4);
37462 var pos = this.el.getBox(true);
37466 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
37468 var hit_end = false;
37470 Roo.each(queue, function(box){
37474 Roo.each(box, function(b){
37476 b.el.setVisibilityMode(Roo.Element.DISPLAY);
37486 Roo.each(box, function(b){
37488 b.el.setVisibilityMode(Roo.Element.DISPLAY);
37491 mx = Math.max(mx, b.x);
37495 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
37499 Roo.each(box, function(b){
37501 b.el.setVisibilityMode(Roo.Element.DISPLAY);
37515 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
37518 /** Sets position of item in DOM
37519 * @param {Element} item
37520 * @param {Number} x - horizontal position
37521 * @param {Number} y - vertical position
37522 * @param {Boolean} isInstant - disables transitions
37524 _processVerticalLayoutQueue : function( queue, isInstant )
37526 var pos = this.el.getBox(true);
37531 for (var i = 0; i < this.cols; i++){
37535 Roo.each(queue, function(box, k){
37537 var col = k % this.cols;
37539 Roo.each(box, function(b,kk){
37541 b.el.position('absolute');
37543 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
37544 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
37546 if(b.size == 'md-left' || b.size == 'md-right'){
37547 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
37548 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
37551 b.el.setWidth(width);
37552 b.el.setHeight(height);
37554 b.el.select('iframe',true).setSize(width,height);
37558 for (var i = 0; i < this.cols; i++){
37560 if(maxY[i] < maxY[col]){
37565 col = Math.min(col, i);
37569 x = pos.x + col * (this.colWidth + this.padWidth);
37573 var positions = [];
37575 switch (box.length){
37577 positions = this.getVerticalOneBoxColPositions(x, y, box);
37580 positions = this.getVerticalTwoBoxColPositions(x, y, box);
37583 positions = this.getVerticalThreeBoxColPositions(x, y, box);
37586 positions = this.getVerticalFourBoxColPositions(x, y, box);
37592 Roo.each(box, function(b,kk){
37594 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
37596 var sz = b.el.getSize();
37598 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
37606 for (var i = 0; i < this.cols; i++){
37607 mY = Math.max(mY, maxY[i]);
37610 this.el.setHeight(mY - pos.y);
37614 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
37616 // var pos = this.el.getBox(true);
37619 // var maxX = pos.right;
37621 // var maxHeight = 0;
37623 // Roo.each(items, function(item, k){
37627 // item.el.position('absolute');
37629 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
37631 // item.el.setWidth(width);
37633 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
37635 // item.el.setHeight(height);
37638 // item.el.setXY([x, y], isInstant ? false : true);
37640 // item.el.setXY([maxX - width, y], isInstant ? false : true);
37643 // y = y + height + this.alternativePadWidth;
37645 // maxHeight = maxHeight + height + this.alternativePadWidth;
37649 // this.el.setHeight(maxHeight);
37653 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
37655 var pos = this.el.getBox(true);
37660 var maxX = pos.right;
37662 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
37664 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
37666 Roo.each(queue, function(box, k){
37668 Roo.each(box, function(b, kk){
37670 b.el.position('absolute');
37672 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
37673 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
37675 if(b.size == 'md-left' || b.size == 'md-right'){
37676 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
37677 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
37680 b.el.setWidth(width);
37681 b.el.setHeight(height);
37689 var positions = [];
37691 switch (box.length){
37693 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
37696 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
37699 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
37702 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
37708 Roo.each(box, function(b,kk){
37710 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
37712 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
37720 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
37722 Roo.each(eItems, function(b,k){
37724 b.size = (k == 0) ? 'sm' : 'xs';
37725 b.x = (k == 0) ? 2 : 1;
37726 b.y = (k == 0) ? 2 : 1;
37728 b.el.position('absolute');
37730 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
37732 b.el.setWidth(width);
37734 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
37736 b.el.setHeight(height);
37740 var positions = [];
37743 x : maxX - this.unitWidth * 2 - this.gutter,
37748 x : maxX - this.unitWidth,
37749 y : minY + (this.unitWidth + this.gutter) * 2
37753 x : maxX - this.unitWidth * 3 - this.gutter * 2,
37757 Roo.each(eItems, function(b,k){
37759 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
37765 getVerticalOneBoxColPositions : function(x, y, box)
37769 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
37771 if(box[0].size == 'md-left'){
37775 if(box[0].size == 'md-right'){
37780 x : x + (this.unitWidth + this.gutter) * rand,
37787 getVerticalTwoBoxColPositions : function(x, y, box)
37791 if(box[0].size == 'xs'){
37795 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
37799 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
37813 x : x + (this.unitWidth + this.gutter) * 2,
37814 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
37821 getVerticalThreeBoxColPositions : function(x, y, box)
37825 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
37833 x : x + (this.unitWidth + this.gutter) * 1,
37838 x : x + (this.unitWidth + this.gutter) * 2,
37846 if(box[0].size == 'xs' && box[1].size == 'xs'){
37855 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
37859 x : x + (this.unitWidth + this.gutter) * 1,
37873 x : x + (this.unitWidth + this.gutter) * 2,
37878 x : x + (this.unitWidth + this.gutter) * 2,
37879 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
37886 getVerticalFourBoxColPositions : function(x, y, box)
37890 if(box[0].size == 'xs'){
37899 y : y + (this.unitHeight + this.gutter) * 1
37904 y : y + (this.unitHeight + this.gutter) * 2
37908 x : x + (this.unitWidth + this.gutter) * 1,
37922 x : x + (this.unitWidth + this.gutter) * 2,
37927 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
37928 y : y + (this.unitHeight + this.gutter) * 1
37932 x : x + (this.unitWidth + this.gutter) * 2,
37933 y : y + (this.unitWidth + this.gutter) * 2
37940 getHorizontalOneBoxColPositions : function(maxX, minY, box)
37944 if(box[0].size == 'md-left'){
37946 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
37953 if(box[0].size == 'md-right'){
37955 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
37956 y : minY + (this.unitWidth + this.gutter) * 1
37962 var rand = Math.floor(Math.random() * (4 - box[0].y));
37965 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
37966 y : minY + (this.unitWidth + this.gutter) * rand
37973 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
37977 if(box[0].size == 'xs'){
37980 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
37985 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
37986 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
37994 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
37999 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
38000 y : minY + (this.unitWidth + this.gutter) * 2
38007 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
38011 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
38014 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
38019 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
38020 y : minY + (this.unitWidth + this.gutter) * 1
38024 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
38025 y : minY + (this.unitWidth + this.gutter) * 2
38032 if(box[0].size == 'xs' && box[1].size == 'xs'){
38035 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
38040 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
38045 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
38046 y : minY + (this.unitWidth + this.gutter) * 1
38054 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
38059 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
38060 y : minY + (this.unitWidth + this.gutter) * 2
38064 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
38065 y : minY + (this.unitWidth + this.gutter) * 2
38072 getHorizontalFourBoxColPositions : function(maxX, minY, box)
38076 if(box[0].size == 'xs'){
38079 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
38084 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
38089 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),
38094 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
38095 y : minY + (this.unitWidth + this.gutter) * 1
38103 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
38108 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
38109 y : minY + (this.unitWidth + this.gutter) * 2
38113 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
38114 y : minY + (this.unitWidth + this.gutter) * 2
38118 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),
38119 y : minY + (this.unitWidth + this.gutter) * 2
38127 * remove a Masonry Brick
38128 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
38130 removeBrick : function(brick_id)
38136 for (var i = 0; i<this.bricks.length; i++) {
38137 if (this.bricks[i].id == brick_id) {
38138 this.bricks.splice(i,1);
38139 this.el.dom.removeChild(Roo.get(brick_id).dom);
38146 * adds a Masonry Brick
38147 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
38149 addBrick : function(cfg)
38151 var cn = new Roo.bootstrap.MasonryBrick(cfg);
38152 //this.register(cn);
38153 cn.parentId = this.id;
38154 cn.render(this.el);
38159 * register a Masonry Brick
38160 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
38163 register : function(brick)
38165 this.bricks.push(brick);
38166 brick.masonryId = this.id;
38170 * clear all the Masonry Brick
38172 clearAll : function()
38175 //this.getChildContainer().dom.innerHTML = "";
38176 this.el.dom.innerHTML = '';
38179 getSelected : function()
38181 if (!this.selectedBrick) {
38185 return this.selectedBrick;
38189 Roo.apply(Roo.bootstrap.LayoutMasonry, {
38193 * register a Masonry Layout
38194 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
38197 register : function(layout)
38199 this.groups[layout.id] = layout;
38202 * fetch a Masonry Layout based on the masonry layout ID
38203 * @param {string} the masonry layout to add
38204 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
38207 get: function(layout_id) {
38208 if (typeof(this.groups[layout_id]) == 'undefined') {
38211 return this.groups[layout_id] ;
38223 * http://masonry.desandro.com
38225 * The idea is to render all the bricks based on vertical width...
38227 * The original code extends 'outlayer' - we might need to use that....
38233 * @class Roo.bootstrap.LayoutMasonryAuto
38234 * @extends Roo.bootstrap.Component
38235 * Bootstrap Layout Masonry class
38238 * Create a new Element
38239 * @param {Object} config The config object
38242 Roo.bootstrap.LayoutMasonryAuto = function(config){
38243 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
38246 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
38249 * @cfg {Boolean} isFitWidth - resize the width..
38251 isFitWidth : false, // options..
38253 * @cfg {Boolean} isOriginLeft = left align?
38255 isOriginLeft : true,
38257 * @cfg {Boolean} isOriginTop = top align?
38259 isOriginTop : false,
38261 * @cfg {Boolean} isLayoutInstant = no animation?
38263 isLayoutInstant : false, // needed?
38265 * @cfg {Boolean} isResizingContainer = not sure if this is used..
38267 isResizingContainer : true,
38269 * @cfg {Number} columnWidth width of the columns
38275 * @cfg {Number} maxCols maximum number of columns
38280 * @cfg {Number} padHeight padding below box..
38286 * @cfg {Boolean} isAutoInitial defalut true
38289 isAutoInitial : true,
38295 initialColumnWidth : 0,
38296 currentSize : null,
38298 colYs : null, // array.
38305 bricks: null, //CompositeElement
38306 cols : 0, // array?
38307 // element : null, // wrapped now this.el
38308 _isLayoutInited : null,
38311 getAutoCreate : function(){
38315 cls: 'blog-masonary-wrapper ' + this.cls,
38317 cls : 'mas-boxes masonary'
38324 getChildContainer: function( )
38326 if (this.boxesEl) {
38327 return this.boxesEl;
38330 this.boxesEl = this.el.select('.mas-boxes').first();
38332 return this.boxesEl;
38336 initEvents : function()
38340 if(this.isAutoInitial){
38341 Roo.log('hook children rendered');
38342 this.on('childrenrendered', function() {
38343 Roo.log('children rendered');
38350 initial : function()
38352 this.reloadItems();
38354 this.currentSize = this.el.getBox(true);
38356 /// was window resize... - let's see if this works..
38357 Roo.EventManager.onWindowResize(this.resize, this);
38359 if(!this.isAutoInitial){
38364 this.layout.defer(500,this);
38367 reloadItems: function()
38369 this.bricks = this.el.select('.masonry-brick', true);
38371 this.bricks.each(function(b) {
38372 //Roo.log(b.getSize());
38373 if (!b.attr('originalwidth')) {
38374 b.attr('originalwidth', b.getSize().width);
38379 Roo.log(this.bricks.elements.length);
38382 resize : function()
38385 var cs = this.el.getBox(true);
38387 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
38388 Roo.log("no change in with or X");
38391 this.currentSize = cs;
38395 layout : function()
38398 this._resetLayout();
38399 //this._manageStamps();
38401 // don't animate first layout
38402 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
38403 this.layoutItems( isInstant );
38405 // flag for initalized
38406 this._isLayoutInited = true;
38409 layoutItems : function( isInstant )
38411 //var items = this._getItemsForLayout( this.items );
38412 // original code supports filtering layout items.. we just ignore it..
38414 this._layoutItems( this.bricks , isInstant );
38416 this._postLayout();
38418 _layoutItems : function ( items , isInstant)
38420 //this.fireEvent( 'layout', this, items );
38423 if ( !items || !items.elements.length ) {
38424 // no items, emit event with empty array
38429 items.each(function(item) {
38430 Roo.log("layout item");
38432 // get x/y object from method
38433 var position = this._getItemLayoutPosition( item );
38435 position.item = item;
38436 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
38437 queue.push( position );
38440 this._processLayoutQueue( queue );
38442 /** Sets position of item in DOM
38443 * @param {Element} item
38444 * @param {Number} x - horizontal position
38445 * @param {Number} y - vertical position
38446 * @param {Boolean} isInstant - disables transitions
38448 _processLayoutQueue : function( queue )
38450 for ( var i=0, len = queue.length; i < len; i++ ) {
38451 var obj = queue[i];
38452 obj.item.position('absolute');
38453 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
38459 * Any logic you want to do after each layout,
38460 * i.e. size the container
38462 _postLayout : function()
38464 this.resizeContainer();
38467 resizeContainer : function()
38469 if ( !this.isResizingContainer ) {
38472 var size = this._getContainerSize();
38474 this.el.setSize(size.width,size.height);
38475 this.boxesEl.setSize(size.width,size.height);
38481 _resetLayout : function()
38483 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
38484 this.colWidth = this.el.getWidth();
38485 //this.gutter = this.el.getWidth();
38487 this.measureColumns();
38493 this.colYs.push( 0 );
38499 measureColumns : function()
38501 this.getContainerWidth();
38502 // if columnWidth is 0, default to outerWidth of first item
38503 if ( !this.columnWidth ) {
38504 var firstItem = this.bricks.first();
38505 Roo.log(firstItem);
38506 this.columnWidth = this.containerWidth;
38507 if (firstItem && firstItem.attr('originalwidth') ) {
38508 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
38510 // columnWidth fall back to item of first element
38511 Roo.log("set column width?");
38512 this.initialColumnWidth = this.columnWidth ;
38514 // if first elem has no width, default to size of container
38519 if (this.initialColumnWidth) {
38520 this.columnWidth = this.initialColumnWidth;
38525 // column width is fixed at the top - however if container width get's smaller we should
38528 // this bit calcs how man columns..
38530 var columnWidth = this.columnWidth += this.gutter;
38532 // calculate columns
38533 var containerWidth = this.containerWidth + this.gutter;
38535 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
38536 // fix rounding errors, typically with gutters
38537 var excess = columnWidth - containerWidth % columnWidth;
38540 // if overshoot is less than a pixel, round up, otherwise floor it
38541 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
38542 cols = Math[ mathMethod ]( cols );
38543 this.cols = Math.max( cols, 1 );
38544 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
38546 // padding positioning..
38547 var totalColWidth = this.cols * this.columnWidth;
38548 var padavail = this.containerWidth - totalColWidth;
38549 // so for 2 columns - we need 3 'pads'
38551 var padNeeded = (1+this.cols) * this.padWidth;
38553 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
38555 this.columnWidth += padExtra
38556 //this.padWidth = Math.floor(padavail / ( this.cols));
38558 // adjust colum width so that padding is fixed??
38560 // we have 3 columns ... total = width * 3
38561 // we have X left over... that should be used by
38563 //if (this.expandC) {
38571 getContainerWidth : function()
38573 /* // container is parent if fit width
38574 var container = this.isFitWidth ? this.element.parentNode : this.element;
38575 // check that this.size and size are there
38576 // IE8 triggers resize on body size change, so they might not be
38578 var size = getSize( container ); //FIXME
38579 this.containerWidth = size && size.innerWidth; //FIXME
38582 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
38586 _getItemLayoutPosition : function( item ) // what is item?
38588 // we resize the item to our columnWidth..
38590 item.setWidth(this.columnWidth);
38591 item.autoBoxAdjust = false;
38593 var sz = item.getSize();
38595 // how many columns does this brick span
38596 var remainder = this.containerWidth % this.columnWidth;
38598 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
38599 // round if off by 1 pixel, otherwise use ceil
38600 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
38601 colSpan = Math.min( colSpan, this.cols );
38603 // normally this should be '1' as we dont' currently allow multi width columns..
38605 var colGroup = this._getColGroup( colSpan );
38606 // get the minimum Y value from the columns
38607 var minimumY = Math.min.apply( Math, colGroup );
38608 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
38610 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
38612 // position the brick
38614 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
38615 y: this.currentSize.y + minimumY + this.padHeight
38619 // apply setHeight to necessary columns
38620 var setHeight = minimumY + sz.height + this.padHeight;
38621 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
38623 var setSpan = this.cols + 1 - colGroup.length;
38624 for ( var i = 0; i < setSpan; i++ ) {
38625 this.colYs[ shortColIndex + i ] = setHeight ;
38632 * @param {Number} colSpan - number of columns the element spans
38633 * @returns {Array} colGroup
38635 _getColGroup : function( colSpan )
38637 if ( colSpan < 2 ) {
38638 // if brick spans only one column, use all the column Ys
38643 // how many different places could this brick fit horizontally
38644 var groupCount = this.cols + 1 - colSpan;
38645 // for each group potential horizontal position
38646 for ( var i = 0; i < groupCount; i++ ) {
38647 // make an array of colY values for that one group
38648 var groupColYs = this.colYs.slice( i, i + colSpan );
38649 // and get the max value of the array
38650 colGroup[i] = Math.max.apply( Math, groupColYs );
38655 _manageStamp : function( stamp )
38657 var stampSize = stamp.getSize();
38658 var offset = stamp.getBox();
38659 // get the columns that this stamp affects
38660 var firstX = this.isOriginLeft ? offset.x : offset.right;
38661 var lastX = firstX + stampSize.width;
38662 var firstCol = Math.floor( firstX / this.columnWidth );
38663 firstCol = Math.max( 0, firstCol );
38665 var lastCol = Math.floor( lastX / this.columnWidth );
38666 // lastCol should not go over if multiple of columnWidth #425
38667 lastCol -= lastX % this.columnWidth ? 0 : 1;
38668 lastCol = Math.min( this.cols - 1, lastCol );
38670 // set colYs to bottom of the stamp
38671 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
38674 for ( var i = firstCol; i <= lastCol; i++ ) {
38675 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
38680 _getContainerSize : function()
38682 this.maxY = Math.max.apply( Math, this.colYs );
38687 if ( this.isFitWidth ) {
38688 size.width = this._getContainerFitWidth();
38694 _getContainerFitWidth : function()
38696 var unusedCols = 0;
38697 // count unused columns
38700 if ( this.colYs[i] !== 0 ) {
38705 // fit container to columns that have been used
38706 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
38709 needsResizeLayout : function()
38711 var previousWidth = this.containerWidth;
38712 this.getContainerWidth();
38713 return previousWidth !== this.containerWidth;
38728 * @class Roo.bootstrap.MasonryBrick
38729 * @extends Roo.bootstrap.Component
38730 * Bootstrap MasonryBrick class
38733 * Create a new MasonryBrick
38734 * @param {Object} config The config object
38737 Roo.bootstrap.MasonryBrick = function(config){
38739 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
38741 Roo.bootstrap.MasonryBrick.register(this);
38747 * When a MasonryBrick is clcik
38748 * @param {Roo.bootstrap.MasonryBrick} this
38749 * @param {Roo.EventObject} e
38755 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
38758 * @cfg {String} title
38762 * @cfg {String} html
38766 * @cfg {String} bgimage
38770 * @cfg {String} videourl
38774 * @cfg {String} cls
38778 * @cfg {String} href
38782 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
38787 * @cfg {String} placetitle (center|bottom)
38792 * @cfg {Boolean} isFitContainer defalut true
38794 isFitContainer : true,
38797 * @cfg {Boolean} preventDefault defalut false
38799 preventDefault : false,
38802 * @cfg {Boolean} inverse defalut false
38804 maskInverse : false,
38806 getAutoCreate : function()
38808 if(!this.isFitContainer){
38809 return this.getSplitAutoCreate();
38812 var cls = 'masonry-brick masonry-brick-full';
38814 if(this.href.length){
38815 cls += ' masonry-brick-link';
38818 if(this.bgimage.length){
38819 cls += ' masonry-brick-image';
38822 if(this.maskInverse){
38823 cls += ' mask-inverse';
38826 if(!this.html.length && !this.maskInverse && !this.videourl.length){
38827 cls += ' enable-mask';
38831 cls += ' masonry-' + this.size + '-brick';
38834 if(this.placetitle.length){
38836 switch (this.placetitle) {
38838 cls += ' masonry-center-title';
38841 cls += ' masonry-bottom-title';
38848 if(!this.html.length && !this.bgimage.length){
38849 cls += ' masonry-center-title';
38852 if(!this.html.length && this.bgimage.length){
38853 cls += ' masonry-bottom-title';
38858 cls += ' ' + this.cls;
38862 tag: (this.href.length) ? 'a' : 'div',
38867 cls: 'masonry-brick-mask'
38871 cls: 'masonry-brick-paragraph',
38877 if(this.href.length){
38878 cfg.href = this.href;
38881 var cn = cfg.cn[1].cn;
38883 if(this.title.length){
38886 cls: 'masonry-brick-title',
38891 if(this.html.length){
38894 cls: 'masonry-brick-text',
38899 if (!this.title.length && !this.html.length) {
38900 cfg.cn[1].cls += ' hide';
38903 if(this.bgimage.length){
38906 cls: 'masonry-brick-image-view',
38911 if(this.videourl.length){
38912 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
38913 // youtube support only?
38916 cls: 'masonry-brick-image-view',
38919 allowfullscreen : true
38927 getSplitAutoCreate : function()
38929 var cls = 'masonry-brick masonry-brick-split';
38931 if(this.href.length){
38932 cls += ' masonry-brick-link';
38935 if(this.bgimage.length){
38936 cls += ' masonry-brick-image';
38940 cls += ' masonry-' + this.size + '-brick';
38943 switch (this.placetitle) {
38945 cls += ' masonry-center-title';
38948 cls += ' masonry-bottom-title';
38951 if(!this.bgimage.length){
38952 cls += ' masonry-center-title';
38955 if(this.bgimage.length){
38956 cls += ' masonry-bottom-title';
38962 cls += ' ' + this.cls;
38966 tag: (this.href.length) ? 'a' : 'div',
38971 cls: 'masonry-brick-split-head',
38975 cls: 'masonry-brick-paragraph',
38982 cls: 'masonry-brick-split-body',
38988 if(this.href.length){
38989 cfg.href = this.href;
38992 if(this.title.length){
38993 cfg.cn[0].cn[0].cn.push({
38995 cls: 'masonry-brick-title',
39000 if(this.html.length){
39001 cfg.cn[1].cn.push({
39003 cls: 'masonry-brick-text',
39008 if(this.bgimage.length){
39009 cfg.cn[0].cn.push({
39011 cls: 'masonry-brick-image-view',
39016 if(this.videourl.length){
39017 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
39018 // youtube support only?
39019 cfg.cn[0].cn.cn.push({
39021 cls: 'masonry-brick-image-view',
39024 allowfullscreen : true
39031 initEvents: function()
39033 switch (this.size) {
39066 this.el.on('touchstart', this.onTouchStart, this);
39067 this.el.on('touchmove', this.onTouchMove, this);
39068 this.el.on('touchend', this.onTouchEnd, this);
39069 this.el.on('contextmenu', this.onContextMenu, this);
39071 this.el.on('mouseenter' ,this.enter, this);
39072 this.el.on('mouseleave', this.leave, this);
39073 this.el.on('click', this.onClick, this);
39076 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
39077 this.parent().bricks.push(this);
39082 onClick: function(e, el)
39084 var time = this.endTimer - this.startTimer;
39085 // Roo.log(e.preventDefault());
39088 e.preventDefault();
39093 if(!this.preventDefault){
39097 e.preventDefault();
39099 if (this.activeClass != '') {
39100 this.selectBrick();
39103 this.fireEvent('click', this, e);
39106 enter: function(e, el)
39108 e.preventDefault();
39110 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
39114 if(this.bgimage.length && this.html.length){
39115 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
39119 leave: function(e, el)
39121 e.preventDefault();
39123 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
39127 if(this.bgimage.length && this.html.length){
39128 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
39132 onTouchStart: function(e, el)
39134 // e.preventDefault();
39136 this.touchmoved = false;
39138 if(!this.isFitContainer){
39142 if(!this.bgimage.length || !this.html.length){
39146 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
39148 this.timer = new Date().getTime();
39152 onTouchMove: function(e, el)
39154 this.touchmoved = true;
39157 onContextMenu : function(e,el)
39159 e.preventDefault();
39160 e.stopPropagation();
39164 onTouchEnd: function(e, el)
39166 // e.preventDefault();
39168 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
39175 if(!this.bgimage.length || !this.html.length){
39177 if(this.href.length){
39178 window.location.href = this.href;
39184 if(!this.isFitContainer){
39188 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
39190 window.location.href = this.href;
39193 //selection on single brick only
39194 selectBrick : function() {
39196 if (!this.parentId) {
39200 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
39201 var index = m.selectedBrick.indexOf(this.id);
39204 m.selectedBrick.splice(index,1);
39205 this.el.removeClass(this.activeClass);
39209 for(var i = 0; i < m.selectedBrick.length; i++) {
39210 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
39211 b.el.removeClass(b.activeClass);
39214 m.selectedBrick = [];
39216 m.selectedBrick.push(this.id);
39217 this.el.addClass(this.activeClass);
39221 isSelected : function(){
39222 return this.el.hasClass(this.activeClass);
39227 Roo.apply(Roo.bootstrap.MasonryBrick, {
39230 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
39232 * register a Masonry Brick
39233 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
39236 register : function(brick)
39238 //this.groups[brick.id] = brick;
39239 this.groups.add(brick.id, brick);
39242 * fetch a masonry brick based on the masonry brick ID
39243 * @param {string} the masonry brick to add
39244 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
39247 get: function(brick_id)
39249 // if (typeof(this.groups[brick_id]) == 'undefined') {
39252 // return this.groups[brick_id] ;
39254 if(this.groups.key(brick_id)) {
39255 return this.groups.key(brick_id);
39273 * @class Roo.bootstrap.Brick
39274 * @extends Roo.bootstrap.Component
39275 * Bootstrap Brick class
39278 * Create a new Brick
39279 * @param {Object} config The config object
39282 Roo.bootstrap.Brick = function(config){
39283 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
39289 * When a Brick is click
39290 * @param {Roo.bootstrap.Brick} this
39291 * @param {Roo.EventObject} e
39297 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
39300 * @cfg {String} title
39304 * @cfg {String} html
39308 * @cfg {String} bgimage
39312 * @cfg {String} cls
39316 * @cfg {String} href
39320 * @cfg {String} video
39324 * @cfg {Boolean} square
39328 getAutoCreate : function()
39330 var cls = 'roo-brick';
39332 if(this.href.length){
39333 cls += ' roo-brick-link';
39336 if(this.bgimage.length){
39337 cls += ' roo-brick-image';
39340 if(!this.html.length && !this.bgimage.length){
39341 cls += ' roo-brick-center-title';
39344 if(!this.html.length && this.bgimage.length){
39345 cls += ' roo-brick-bottom-title';
39349 cls += ' ' + this.cls;
39353 tag: (this.href.length) ? 'a' : 'div',
39358 cls: 'roo-brick-paragraph',
39364 if(this.href.length){
39365 cfg.href = this.href;
39368 var cn = cfg.cn[0].cn;
39370 if(this.title.length){
39373 cls: 'roo-brick-title',
39378 if(this.html.length){
39381 cls: 'roo-brick-text',
39388 if(this.bgimage.length){
39391 cls: 'roo-brick-image-view',
39399 initEvents: function()
39401 if(this.title.length || this.html.length){
39402 this.el.on('mouseenter' ,this.enter, this);
39403 this.el.on('mouseleave', this.leave, this);
39406 Roo.EventManager.onWindowResize(this.resize, this);
39408 if(this.bgimage.length){
39409 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
39410 this.imageEl.on('load', this.onImageLoad, this);
39417 onImageLoad : function()
39422 resize : function()
39424 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
39426 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
39428 if(this.bgimage.length){
39429 var image = this.el.select('.roo-brick-image-view', true).first();
39431 image.setWidth(paragraph.getWidth());
39434 image.setHeight(paragraph.getWidth());
39437 this.el.setHeight(image.getHeight());
39438 paragraph.setHeight(image.getHeight());
39444 enter: function(e, el)
39446 e.preventDefault();
39448 if(this.bgimage.length){
39449 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
39450 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
39454 leave: function(e, el)
39456 e.preventDefault();
39458 if(this.bgimage.length){
39459 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
39460 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
39475 * @class Roo.bootstrap.form.NumberField
39476 * @extends Roo.bootstrap.form.Input
39477 * Bootstrap NumberField class
39483 * Create a new NumberField
39484 * @param {Object} config The config object
39487 Roo.bootstrap.form.NumberField = function(config){
39488 Roo.bootstrap.form.NumberField.superclass.constructor.call(this, config);
39491 Roo.extend(Roo.bootstrap.form.NumberField, Roo.bootstrap.form.Input, {
39494 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
39496 allowDecimals : true,
39498 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
39500 decimalSeparator : ".",
39502 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
39504 decimalPrecision : 2,
39506 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
39508 allowNegative : true,
39511 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
39515 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
39517 minValue : Number.NEGATIVE_INFINITY,
39519 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
39521 maxValue : Number.MAX_VALUE,
39523 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
39525 minText : "The minimum value for this field is {0}",
39527 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
39529 maxText : "The maximum value for this field is {0}",
39531 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
39532 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
39534 nanText : "{0} is not a valid number",
39536 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
39538 thousandsDelimiter : false,
39540 * @cfg {String} valueAlign alignment of value
39542 valueAlign : "left",
39544 getAutoCreate : function()
39546 var hiddenInput = {
39550 cls: 'hidden-number-input'
39554 hiddenInput.name = this.name;
39559 var cfg = Roo.bootstrap.form.NumberField.superclass.getAutoCreate.call(this);
39561 this.name = hiddenInput.name;
39563 if(cfg.cn.length > 0) {
39564 cfg.cn.push(hiddenInput);
39571 initEvents : function()
39573 Roo.bootstrap.form.NumberField.superclass.initEvents.call(this);
39575 var allowed = "0123456789";
39577 if(this.allowDecimals){
39578 allowed += this.decimalSeparator;
39581 if(this.allowNegative){
39585 if(this.thousandsDelimiter) {
39589 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
39591 var keyPress = function(e){
39593 var k = e.getKey();
39595 var c = e.getCharCode();
39598 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
39599 allowed.indexOf(String.fromCharCode(c)) === -1
39605 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
39609 if(allowed.indexOf(String.fromCharCode(c)) === -1){
39614 this.el.on("keypress", keyPress, this);
39617 validateValue : function(value)
39620 if(!Roo.bootstrap.form.NumberField.superclass.validateValue.call(this, value)){
39624 var num = this.parseValue(value);
39627 this.markInvalid(String.format(this.nanText, value));
39631 if(num < this.minValue){
39632 this.markInvalid(String.format(this.minText, this.minValue));
39636 if(num > this.maxValue){
39637 this.markInvalid(String.format(this.maxText, this.maxValue));
39644 getValue : function()
39646 var v = this.hiddenEl().getValue();
39648 return this.fixPrecision(this.parseValue(v));
39651 parseValue : function(value)
39653 if(this.thousandsDelimiter) {
39655 r = new RegExp(",", "g");
39656 value = value.replace(r, "");
39659 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
39660 return isNaN(value) ? '' : value;
39663 fixPrecision : function(value)
39665 if(this.thousandsDelimiter) {
39667 r = new RegExp(",", "g");
39668 value = value.replace(r, "");
39671 var nan = isNaN(value);
39673 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
39674 return nan ? '' : value;
39676 return parseFloat(value).toFixed(this.decimalPrecision);
39679 setValue : function(v)
39681 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
39687 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
39689 this.inputEl().dom.value = (v == '') ? '' :
39690 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
39692 if(!this.allowZero && v === '0') {
39693 this.hiddenEl().dom.value = '';
39694 this.inputEl().dom.value = '';
39701 decimalPrecisionFcn : function(v)
39703 return Math.floor(v);
39706 beforeBlur : function()
39708 var v = this.parseValue(this.getRawValue());
39710 if(v || v === 0 || v === ''){
39715 hiddenEl : function()
39717 return this.el.select('input.hidden-number-input',true).first();
39729 * @class Roo.bootstrap.DocumentSlider
39730 * @extends Roo.bootstrap.Component
39731 * Bootstrap DocumentSlider class
39734 * Create a new DocumentViewer
39735 * @param {Object} config The config object
39738 Roo.bootstrap.DocumentSlider = function(config){
39739 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
39746 * Fire after initEvent
39747 * @param {Roo.bootstrap.DocumentSlider} this
39752 * Fire after update
39753 * @param {Roo.bootstrap.DocumentSlider} this
39759 * @param {Roo.bootstrap.DocumentSlider} this
39765 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
39771 getAutoCreate : function()
39775 cls : 'roo-document-slider',
39779 cls : 'roo-document-slider-header',
39783 cls : 'roo-document-slider-header-title'
39789 cls : 'roo-document-slider-body',
39793 cls : 'roo-document-slider-prev',
39797 cls : 'fa fa-chevron-left'
39803 cls : 'roo-document-slider-thumb',
39807 cls : 'roo-document-slider-image'
39813 cls : 'roo-document-slider-next',
39817 cls : 'fa fa-chevron-right'
39829 initEvents : function()
39831 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
39832 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
39834 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
39835 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
39837 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
39838 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
39840 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
39841 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
39843 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
39844 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
39846 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
39847 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
39849 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
39850 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
39852 this.thumbEl.on('click', this.onClick, this);
39854 this.prevIndicator.on('click', this.prev, this);
39856 this.nextIndicator.on('click', this.next, this);
39860 initial : function()
39862 if(this.files.length){
39863 this.indicator = 1;
39867 this.fireEvent('initial', this);
39870 update : function()
39872 this.imageEl.attr('src', this.files[this.indicator - 1]);
39874 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
39876 this.prevIndicator.show();
39878 if(this.indicator == 1){
39879 this.prevIndicator.hide();
39882 this.nextIndicator.show();
39884 if(this.indicator == this.files.length){
39885 this.nextIndicator.hide();
39888 this.thumbEl.scrollTo('top');
39890 this.fireEvent('update', this);
39893 onClick : function(e)
39895 e.preventDefault();
39897 this.fireEvent('click', this);
39902 e.preventDefault();
39904 this.indicator = Math.max(1, this.indicator - 1);
39911 e.preventDefault();
39913 this.indicator = Math.min(this.files.length, this.indicator + 1);
39927 * @class Roo.bootstrap.form.RadioSet
39928 * @extends Roo.bootstrap.form.Input
39929 * @children Roo.bootstrap.form.Radio
39930 * Bootstrap RadioSet class
39931 * @cfg {String} indicatorpos (left|right) default left
39932 * @cfg {Boolean} inline (true|false) inline the element (default true)
39933 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
39935 * Create a new RadioSet
39936 * @param {Object} config The config object
39939 Roo.bootstrap.form.RadioSet = function(config){
39941 Roo.bootstrap.form.RadioSet.superclass.constructor.call(this, config);
39945 Roo.bootstrap.form.RadioSet.register(this);
39950 * Fires when the element is checked or unchecked.
39951 * @param {Roo.bootstrap.form.RadioSet} this This radio
39952 * @param {Roo.bootstrap.form.Radio} item The checked item
39957 * Fires when the element is click.
39958 * @param {Roo.bootstrap.form.RadioSet} this This radio set
39959 * @param {Roo.bootstrap.form.Radio} item The checked item
39960 * @param {Roo.EventObject} e The event object
39967 Roo.extend(Roo.bootstrap.form.RadioSet, Roo.bootstrap.form.Input, {
39975 indicatorpos : 'left',
39977 getAutoCreate : function()
39981 cls : 'roo-radio-set-label',
39985 html : this.fieldLabel
39989 if (Roo.bootstrap.version == 3) {
39992 if(this.indicatorpos == 'left'){
39995 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
39996 tooltip : 'This field is required'
40001 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
40002 tooltip : 'This field is required'
40008 cls : 'roo-radio-set-items'
40011 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
40013 if (align === 'left' && this.fieldLabel.length) {
40016 cls : "roo-radio-set-right",
40022 if(this.labelWidth > 12){
40023 label.style = "width: " + this.labelWidth + 'px';
40026 if(this.labelWidth < 13 && this.labelmd == 0){
40027 this.labelmd = this.labelWidth;
40030 if(this.labellg > 0){
40031 label.cls += ' col-lg-' + this.labellg;
40032 items.cls += ' col-lg-' + (12 - this.labellg);
40035 if(this.labelmd > 0){
40036 label.cls += ' col-md-' + this.labelmd;
40037 items.cls += ' col-md-' + (12 - this.labelmd);
40040 if(this.labelsm > 0){
40041 label.cls += ' col-sm-' + this.labelsm;
40042 items.cls += ' col-sm-' + (12 - this.labelsm);
40045 if(this.labelxs > 0){
40046 label.cls += ' col-xs-' + this.labelxs;
40047 items.cls += ' col-xs-' + (12 - this.labelxs);
40053 cls : 'roo-radio-set',
40057 cls : 'roo-radio-set-input',
40060 value : this.value ? this.value : ''
40067 if(this.weight.length){
40068 cfg.cls += ' roo-radio-' + this.weight;
40072 cfg.cls += ' roo-radio-set-inline';
40076 ['xs','sm','md','lg'].map(function(size){
40077 if (settings[size]) {
40078 cfg.cls += ' col-' + size + '-' + settings[size];
40086 initEvents : function()
40088 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
40089 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
40091 if(!this.fieldLabel.length){
40092 this.labelEl.hide();
40095 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
40096 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
40098 this.indicator = this.indicatorEl();
40100 if(this.indicator){
40101 this.indicator.addClass('invisible');
40104 this.originalValue = this.getValue();
40108 inputEl: function ()
40110 return this.el.select('.roo-radio-set-input', true).first();
40113 getChildContainer : function()
40115 return this.itemsEl;
40118 register : function(item)
40120 this.radioes.push(item);
40124 validate : function()
40126 if(this.getVisibilityEl().hasClass('hidden')){
40132 Roo.each(this.radioes, function(i){
40141 if(this.allowBlank) {
40145 if(this.disabled || valid){
40150 this.markInvalid();
40155 markValid : function()
40157 if(this.labelEl.isVisible(true) && this.indicatorEl()){
40158 this.indicatorEl().removeClass('visible');
40159 this.indicatorEl().addClass('invisible');
40163 if (Roo.bootstrap.version == 3) {
40164 this.el.removeClass([this.invalidClass, this.validClass]);
40165 this.el.addClass(this.validClass);
40167 this.el.removeClass(['is-invalid','is-valid']);
40168 this.el.addClass(['is-valid']);
40170 this.fireEvent('valid', this);
40173 markInvalid : function(msg)
40175 if(this.allowBlank || this.disabled){
40179 if(this.labelEl.isVisible(true) && this.indicatorEl()){
40180 this.indicatorEl().removeClass('invisible');
40181 this.indicatorEl().addClass('visible');
40183 if (Roo.bootstrap.version == 3) {
40184 this.el.removeClass([this.invalidClass, this.validClass]);
40185 this.el.addClass(this.invalidClass);
40187 this.el.removeClass(['is-invalid','is-valid']);
40188 this.el.addClass(['is-invalid']);
40191 this.fireEvent('invalid', this, msg);
40195 setValue : function(v, suppressEvent)
40197 if(this.value === v){
40204 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
40207 Roo.each(this.radioes, function(i){
40209 i.el.removeClass('checked');
40212 Roo.each(this.radioes, function(i){
40214 if(i.value === v || i.value.toString() === v.toString()){
40216 i.el.addClass('checked');
40218 if(suppressEvent !== true){
40219 this.fireEvent('check', this, i);
40230 clearInvalid : function(){
40232 if(!this.el || this.preventMark){
40236 this.el.removeClass([this.invalidClass]);
40238 this.fireEvent('valid', this);
40243 Roo.apply(Roo.bootstrap.form.RadioSet, {
40247 register : function(set)
40249 this.groups[set.name] = set;
40252 get: function(name)
40254 if (typeof(this.groups[name]) == 'undefined') {
40258 return this.groups[name] ;
40264 * Ext JS Library 1.1.1
40265 * Copyright(c) 2006-2007, Ext JS, LLC.
40267 * Originally Released Under LGPL - original licence link has changed is not relivant.
40270 * <script type="text/javascript">
40275 * @class Roo.bootstrap.SplitBar
40276 * @extends Roo.util.Observable
40277 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
40281 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
40282 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
40283 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
40284 split.minSize = 100;
40285 split.maxSize = 600;
40286 split.animate = true;
40287 split.on('moved', splitterMoved);
40290 * Create a new SplitBar
40291 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
40292 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
40293 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
40294 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
40295 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
40296 position of the SplitBar).
40298 Roo.bootstrap.SplitBar = function(cfg){
40303 // dragElement : elm
40304 // resizingElement: el,
40306 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
40307 // placement : Roo.bootstrap.SplitBar.LEFT ,
40308 // existingProxy ???
40311 this.el = Roo.get(cfg.dragElement, true);
40312 this.el.dom.unselectable = "on";
40314 this.resizingEl = Roo.get(cfg.resizingElement, true);
40318 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
40319 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
40322 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
40325 * The minimum size of the resizing element. (Defaults to 0)
40331 * The maximum size of the resizing element. (Defaults to 2000)
40334 this.maxSize = 2000;
40337 * Whether to animate the transition to the new size
40340 this.animate = false;
40343 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
40346 this.useShim = false;
40351 if(!cfg.existingProxy){
40353 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
40355 this.proxy = Roo.get(cfg.existingProxy).dom;
40358 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
40361 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
40364 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
40367 this.dragSpecs = {};
40370 * @private The adapter to use to positon and resize elements
40372 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
40373 this.adapter.init(this);
40375 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
40377 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
40378 this.el.addClass("roo-splitbar-h");
40381 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
40382 this.el.addClass("roo-splitbar-v");
40388 * Fires when the splitter is moved (alias for {@link #event-moved})
40389 * @param {Roo.bootstrap.SplitBar} this
40390 * @param {Number} newSize the new width or height
40395 * Fires when the splitter is moved
40396 * @param {Roo.bootstrap.SplitBar} this
40397 * @param {Number} newSize the new width or height
40401 * @event beforeresize
40402 * Fires before the splitter is dragged
40403 * @param {Roo.bootstrap.SplitBar} this
40405 "beforeresize" : true,
40407 "beforeapply" : true
40410 Roo.util.Observable.call(this);
40413 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
40414 onStartProxyDrag : function(x, y){
40415 this.fireEvent("beforeresize", this);
40417 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
40419 o.enableDisplayMode("block");
40420 // all splitbars share the same overlay
40421 Roo.bootstrap.SplitBar.prototype.overlay = o;
40423 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
40424 this.overlay.show();
40425 Roo.get(this.proxy).setDisplayed("block");
40426 var size = this.adapter.getElementSize(this);
40427 this.activeMinSize = this.getMinimumSize();;
40428 this.activeMaxSize = this.getMaximumSize();;
40429 var c1 = size - this.activeMinSize;
40430 var c2 = Math.max(this.activeMaxSize - size, 0);
40431 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
40432 this.dd.resetConstraints();
40433 this.dd.setXConstraint(
40434 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
40435 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
40437 this.dd.setYConstraint(0, 0);
40439 this.dd.resetConstraints();
40440 this.dd.setXConstraint(0, 0);
40441 this.dd.setYConstraint(
40442 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
40443 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
40446 this.dragSpecs.startSize = size;
40447 this.dragSpecs.startPoint = [x, y];
40448 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
40452 * @private Called after the drag operation by the DDProxy
40454 onEndProxyDrag : function(e){
40455 Roo.get(this.proxy).setDisplayed(false);
40456 var endPoint = Roo.lib.Event.getXY(e);
40458 this.overlay.hide();
40461 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
40462 newSize = this.dragSpecs.startSize +
40463 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
40464 endPoint[0] - this.dragSpecs.startPoint[0] :
40465 this.dragSpecs.startPoint[0] - endPoint[0]
40468 newSize = this.dragSpecs.startSize +
40469 (this.placement == Roo.bootstrap.SplitBar.TOP ?
40470 endPoint[1] - this.dragSpecs.startPoint[1] :
40471 this.dragSpecs.startPoint[1] - endPoint[1]
40474 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
40475 if(newSize != this.dragSpecs.startSize){
40476 if(this.fireEvent('beforeapply', this, newSize) !== false){
40477 this.adapter.setElementSize(this, newSize);
40478 this.fireEvent("moved", this, newSize);
40479 this.fireEvent("resize", this, newSize);
40485 * Get the adapter this SplitBar uses
40486 * @return The adapter object
40488 getAdapter : function(){
40489 return this.adapter;
40493 * Set the adapter this SplitBar uses
40494 * @param {Object} adapter A SplitBar adapter object
40496 setAdapter : function(adapter){
40497 this.adapter = adapter;
40498 this.adapter.init(this);
40502 * Gets the minimum size for the resizing element
40503 * @return {Number} The minimum size
40505 getMinimumSize : function(){
40506 return this.minSize;
40510 * Sets the minimum size for the resizing element
40511 * @param {Number} minSize The minimum size
40513 setMinimumSize : function(minSize){
40514 this.minSize = minSize;
40518 * Gets the maximum size for the resizing element
40519 * @return {Number} The maximum size
40521 getMaximumSize : function(){
40522 return this.maxSize;
40526 * Sets the maximum size for the resizing element
40527 * @param {Number} maxSize The maximum size
40529 setMaximumSize : function(maxSize){
40530 this.maxSize = maxSize;
40534 * Sets the initialize size for the resizing element
40535 * @param {Number} size The initial size
40537 setCurrentSize : function(size){
40538 var oldAnimate = this.animate;
40539 this.animate = false;
40540 this.adapter.setElementSize(this, size);
40541 this.animate = oldAnimate;
40545 * Destroy this splitbar.
40546 * @param {Boolean} removeEl True to remove the element
40548 destroy : function(removeEl){
40550 this.shim.remove();
40553 this.proxy.parentNode.removeChild(this.proxy);
40561 * @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.
40563 Roo.bootstrap.SplitBar.createProxy = function(dir){
40564 var proxy = new Roo.Element(document.createElement("div"));
40565 proxy.unselectable();
40566 var cls = 'roo-splitbar-proxy';
40567 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
40568 document.body.appendChild(proxy.dom);
40573 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
40574 * Default Adapter. It assumes the splitter and resizing element are not positioned
40575 * elements and only gets/sets the width of the element. Generally used for table based layouts.
40577 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
40580 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
40581 // do nothing for now
40582 init : function(s){
40586 * Called before drag operations to get the current size of the resizing element.
40587 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
40589 getElementSize : function(s){
40590 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
40591 return s.resizingEl.getWidth();
40593 return s.resizingEl.getHeight();
40598 * Called after drag operations to set the size of the resizing element.
40599 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
40600 * @param {Number} newSize The new size to set
40601 * @param {Function} onComplete A function to be invoked when resizing is complete
40603 setElementSize : function(s, newSize, onComplete){
40604 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
40606 s.resizingEl.setWidth(newSize);
40608 onComplete(s, newSize);
40611 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
40616 s.resizingEl.setHeight(newSize);
40618 onComplete(s, newSize);
40621 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
40628 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
40629 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
40630 * Adapter that moves the splitter element to align with the resized sizing element.
40631 * Used with an absolute positioned SplitBar.
40632 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
40633 * document.body, make sure you assign an id to the body element.
40635 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
40636 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
40637 this.container = Roo.get(container);
40640 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
40641 init : function(s){
40642 this.basic.init(s);
40645 getElementSize : function(s){
40646 return this.basic.getElementSize(s);
40649 setElementSize : function(s, newSize, onComplete){
40650 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
40653 moveSplitter : function(s){
40654 var yes = Roo.bootstrap.SplitBar;
40655 switch(s.placement){
40657 s.el.setX(s.resizingEl.getRight());
40660 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
40663 s.el.setY(s.resizingEl.getBottom());
40666 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
40673 * Orientation constant - Create a vertical SplitBar
40677 Roo.bootstrap.SplitBar.VERTICAL = 1;
40680 * Orientation constant - Create a horizontal SplitBar
40684 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
40687 * Placement constant - The resizing element is to the left of the splitter element
40691 Roo.bootstrap.SplitBar.LEFT = 1;
40694 * Placement constant - The resizing element is to the right of the splitter element
40698 Roo.bootstrap.SplitBar.RIGHT = 2;
40701 * Placement constant - The resizing element is positioned above the splitter element
40705 Roo.bootstrap.SplitBar.TOP = 3;
40708 * Placement constant - The resizing element is positioned under splitter element
40712 Roo.bootstrap.SplitBar.BOTTOM = 4;
40715 * Ext JS Library 1.1.1
40716 * Copyright(c) 2006-2007, Ext JS, LLC.
40718 * Originally Released Under LGPL - original licence link has changed is not relivant.
40721 * <script type="text/javascript">
40725 * @class Roo.bootstrap.layout.Manager
40726 * @extends Roo.bootstrap.Component
40728 * Base class for layout managers.
40730 Roo.bootstrap.layout.Manager = function(config)
40732 this.monitorWindowResize = true; // do this before we apply configuration.
40734 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
40740 /** false to disable window resize monitoring @type Boolean */
40746 * Fires when a layout is performed.
40747 * @param {Roo.LayoutManager} this
40751 * @event regionresized
40752 * Fires when the user resizes a region.
40753 * @param {Roo.LayoutRegion} region The resized region
40754 * @param {Number} newSize The new size (width for east/west, height for north/south)
40756 "regionresized" : true,
40758 * @event regioncollapsed
40759 * Fires when a region is collapsed.
40760 * @param {Roo.LayoutRegion} region The collapsed region
40762 "regioncollapsed" : true,
40764 * @event regionexpanded
40765 * Fires when a region is expanded.
40766 * @param {Roo.LayoutRegion} region The expanded region
40768 "regionexpanded" : true
40770 this.updating = false;
40773 this.el = Roo.get(config.el);
40779 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
40784 monitorWindowResize : true,
40790 onRender : function(ct, position)
40793 this.el = Roo.get(ct);
40796 //this.fireEvent('render',this);
40800 initEvents: function()
40804 // ie scrollbar fix
40805 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
40806 document.body.scroll = "no";
40807 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
40808 this.el.position('relative');
40810 this.id = this.el.id;
40811 this.el.addClass("roo-layout-container");
40812 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
40813 if(this.el.dom != document.body ) {
40814 this.el.on('resize', this.layout,this);
40815 this.el.on('show', this.layout,this);
40821 * Returns true if this layout is currently being updated
40822 * @return {Boolean}
40824 isUpdating : function(){
40825 return this.updating;
40829 * Suspend the LayoutManager from doing auto-layouts while
40830 * making multiple add or remove calls
40832 beginUpdate : function(){
40833 this.updating = true;
40837 * Restore auto-layouts and optionally disable the manager from performing a layout
40838 * @param {Boolean} noLayout true to disable a layout update
40840 endUpdate : function(noLayout){
40841 this.updating = false;
40847 layout: function(){
40851 onRegionResized : function(region, newSize){
40852 this.fireEvent("regionresized", region, newSize);
40856 onRegionCollapsed : function(region){
40857 this.fireEvent("regioncollapsed", region);
40860 onRegionExpanded : function(region){
40861 this.fireEvent("regionexpanded", region);
40865 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
40866 * performs box-model adjustments.
40867 * @return {Object} The size as an object {width: (the width), height: (the height)}
40869 getViewSize : function()
40872 if(this.el.dom != document.body){
40873 size = this.el.getSize();
40875 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
40877 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
40878 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
40883 * Returns the Element this layout is bound to.
40884 * @return {Roo.Element}
40886 getEl : function(){
40891 * Returns the specified region.
40892 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
40893 * @return {Roo.LayoutRegion}
40895 getRegion : function(target){
40896 return this.regions[target.toLowerCase()];
40899 onWindowResize : function(){
40900 if(this.monitorWindowResize){
40907 * Ext JS Library 1.1.1
40908 * Copyright(c) 2006-2007, Ext JS, LLC.
40910 * Originally Released Under LGPL - original licence link has changed is not relivant.
40913 * <script type="text/javascript">
40916 * @class Roo.bootstrap.layout.Border
40917 * @extends Roo.bootstrap.layout.Manager
40918 * @children Roo.bootstrap.panel.Content Roo.bootstrap.panel.Nest Roo.bootstrap.panel.Grid
40919 * @parent builder Roo.bootstrap.panel.Nest Roo.bootstrap.panel.Nest Roo.bootstrap.Modal
40920 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
40921 * please see: examples/bootstrap/nested.html<br><br>
40923 <b>The container the layout is rendered into can be either the body element or any other element.
40924 If it is not the body element, the container needs to either be an absolute positioned element,
40925 or you will need to add "position:relative" to the css of the container. You will also need to specify
40926 the container size if it is not the body element.</b>
40929 * Create a new Border
40930 * @param {Object} config Configuration options
40932 Roo.bootstrap.layout.Border = function(config){
40933 config = config || {};
40934 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
40938 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
40939 if(config[region]){
40940 config[region].region = region;
40941 this.addRegion(config[region]);
40947 Roo.bootstrap.layout.Border.regions = ["center", "north","south","east","west"];
40949 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
40952 * @cfg {Roo.bootstrap.layout.Region} center region to go in center
40955 * @cfg {Roo.bootstrap.layout.Region} west region to go in west
40958 * @cfg {Roo.bootstrap.layout.Region} east region to go in east
40961 * @cfg {Roo.bootstrap.layout.Region} south region to go in south
40964 * @cfg {Roo.bootstrap.layout.Region} north region to go in north
40970 parent : false, // this might point to a 'nest' or a ???
40973 * Creates and adds a new region if it doesn't already exist.
40974 * @param {String} target The target region key (north, south, east, west or center).
40975 * @param {Object} config The regions config object
40976 * @return {BorderLayoutRegion} The new region
40978 addRegion : function(config)
40980 if(!this.regions[config.region]){
40981 var r = this.factory(config);
40982 this.bindRegion(r);
40984 return this.regions[config.region];
40988 bindRegion : function(r){
40989 this.regions[r.config.region] = r;
40991 r.on("visibilitychange", this.layout, this);
40992 r.on("paneladded", this.layout, this);
40993 r.on("panelremoved", this.layout, this);
40994 r.on("invalidated", this.layout, this);
40995 r.on("resized", this.onRegionResized, this);
40996 r.on("collapsed", this.onRegionCollapsed, this);
40997 r.on("expanded", this.onRegionExpanded, this);
41001 * Performs a layout update.
41003 layout : function()
41005 if(this.updating) {
41009 // render all the rebions if they have not been done alreayd?
41010 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
41011 if(this.regions[region] && !this.regions[region].bodyEl){
41012 this.regions[region].onRender(this.el)
41016 var size = this.getViewSize();
41017 var w = size.width;
41018 var h = size.height;
41023 //var x = 0, y = 0;
41025 var rs = this.regions;
41026 var north = rs["north"];
41027 var south = rs["south"];
41028 var west = rs["west"];
41029 var east = rs["east"];
41030 var center = rs["center"];
41031 //if(this.hideOnLayout){ // not supported anymore
41032 //c.el.setStyle("display", "none");
41034 if(north && north.isVisible()){
41035 var b = north.getBox();
41036 var m = north.getMargins();
41037 b.width = w - (m.left+m.right);
41040 centerY = b.height + b.y + m.bottom;
41041 centerH -= centerY;
41042 north.updateBox(this.safeBox(b));
41044 if(south && south.isVisible()){
41045 var b = south.getBox();
41046 var m = south.getMargins();
41047 b.width = w - (m.left+m.right);
41049 var totalHeight = (b.height + m.top + m.bottom);
41050 b.y = h - totalHeight + m.top;
41051 centerH -= totalHeight;
41052 south.updateBox(this.safeBox(b));
41054 if(west && west.isVisible()){
41055 var b = west.getBox();
41056 var m = west.getMargins();
41057 b.height = centerH - (m.top+m.bottom);
41059 b.y = centerY + m.top;
41060 var totalWidth = (b.width + m.left + m.right);
41061 centerX += totalWidth;
41062 centerW -= totalWidth;
41063 west.updateBox(this.safeBox(b));
41065 if(east && east.isVisible()){
41066 var b = east.getBox();
41067 var m = east.getMargins();
41068 b.height = centerH - (m.top+m.bottom);
41069 var totalWidth = (b.width + m.left + m.right);
41070 b.x = w - totalWidth + m.left;
41071 b.y = centerY + m.top;
41072 centerW -= totalWidth;
41073 east.updateBox(this.safeBox(b));
41076 var m = center.getMargins();
41078 x: centerX + m.left,
41079 y: centerY + m.top,
41080 width: centerW - (m.left+m.right),
41081 height: centerH - (m.top+m.bottom)
41083 //if(this.hideOnLayout){
41084 //center.el.setStyle("display", "block");
41086 center.updateBox(this.safeBox(centerBox));
41089 this.fireEvent("layout", this);
41093 safeBox : function(box){
41094 box.width = Math.max(0, box.width);
41095 box.height = Math.max(0, box.height);
41100 * Adds a ContentPanel (or subclass) to this layout.
41101 * @param {String} target The target region key (north, south, east, west or center).
41102 * @param {Roo.ContentPanel} panel The panel to add
41103 * @return {Roo.ContentPanel} The added panel
41105 add : function(target, panel){
41107 target = target.toLowerCase();
41108 return this.regions[target].add(panel);
41112 * Remove a ContentPanel (or subclass) to this layout.
41113 * @param {String} target The target region key (north, south, east, west or center).
41114 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
41115 * @return {Roo.ContentPanel} The removed panel
41117 remove : function(target, panel){
41118 target = target.toLowerCase();
41119 return this.regions[target].remove(panel);
41123 * Searches all regions for a panel with the specified id
41124 * @param {String} panelId
41125 * @return {Roo.ContentPanel} The panel or null if it wasn't found
41127 findPanel : function(panelId){
41128 var rs = this.regions;
41129 for(var target in rs){
41130 if(typeof rs[target] != "function"){
41131 var p = rs[target].getPanel(panelId);
41141 * Searches all regions for a panel with the specified id and activates (shows) it.
41142 * @param {String/ContentPanel} panelId The panels id or the panel itself
41143 * @return {Roo.ContentPanel} The shown panel or null
41145 showPanel : function(panelId) {
41146 var rs = this.regions;
41147 for(var target in rs){
41148 var r = rs[target];
41149 if(typeof r != "function"){
41150 if(r.hasPanel(panelId)){
41151 return r.showPanel(panelId);
41159 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
41160 * @param {Roo.state.Provider} provider (optional) An alternate state provider
41163 restoreState : function(provider){
41165 provider = Roo.state.Manager;
41167 var sm = new Roo.LayoutStateManager();
41168 sm.init(this, provider);
41174 * Adds a xtype elements to the layout.
41178 xtype : 'ContentPanel',
41185 xtype : 'NestedLayoutPanel',
41191 items : [ ... list of content panels or nested layout panels.. ]
41195 * @param {Object} cfg Xtype definition of item to add.
41197 addxtype : function(cfg)
41199 // basically accepts a pannel...
41200 // can accept a layout region..!?!?
41201 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
41204 // theory? children can only be panels??
41206 //if (!cfg.xtype.match(/Panel$/)) {
41211 if (typeof(cfg.region) == 'undefined') {
41212 Roo.log("Failed to add Panel, region was not set");
41216 var region = cfg.region;
41222 xitems = cfg.items;
41227 if ( region == 'center') {
41228 Roo.log("Center: " + cfg.title);
41234 case 'Content': // ContentPanel (el, cfg)
41235 case 'Scroll': // ContentPanel (el, cfg)
41237 cfg.autoCreate = cfg.autoCreate || true;
41238 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
41240 // var el = this.el.createChild();
41241 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
41244 this.add(region, ret);
41248 case 'TreePanel': // our new panel!
41249 cfg.el = this.el.createChild();
41250 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
41251 this.add(region, ret);
41256 // create a new Layout (which is a Border Layout...
41258 var clayout = cfg.layout;
41259 clayout.el = this.el.createChild();
41260 clayout.items = clayout.items || [];
41264 // replace this exitems with the clayout ones..
41265 xitems = clayout.items;
41267 // force background off if it's in center...
41268 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
41269 cfg.background = false;
41271 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
41274 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
41275 //console.log('adding nested layout panel ' + cfg.toSource());
41276 this.add(region, ret);
41277 nb = {}; /// find first...
41282 // needs grid and region
41284 //var el = this.getRegion(region).el.createChild();
41286 *var el = this.el.createChild();
41287 // create the grid first...
41288 cfg.grid.container = el;
41289 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
41292 if (region == 'center' && this.active ) {
41293 cfg.background = false;
41296 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
41298 this.add(region, ret);
41300 if (cfg.background) {
41301 // render grid on panel activation (if panel background)
41302 ret.on('activate', function(gp) {
41303 if (!gp.grid.rendered) {
41304 // gp.grid.render(el);
41308 // cfg.grid.render(el);
41314 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
41315 // it was the old xcomponent building that caused this before.
41316 // espeically if border is the top element in the tree.
41326 if (typeof(Roo[cfg.xtype]) != 'undefined') {
41328 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
41329 this.add(region, ret);
41333 throw "Can not add '" + cfg.xtype + "' to Border";
41339 this.beginUpdate();
41343 Roo.each(xitems, function(i) {
41344 region = nb && i.region ? i.region : false;
41346 var add = ret.addxtype(i);
41349 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
41350 if (!i.background) {
41351 abn[region] = nb[region] ;
41358 // make the last non-background panel active..
41359 //if (nb) { Roo.log(abn); }
41362 for(var r in abn) {
41363 region = this.getRegion(r);
41365 // tried using nb[r], but it does not work..
41367 region.showPanel(abn[r]);
41378 factory : function(cfg)
41381 var validRegions = Roo.bootstrap.layout.Border.regions;
41383 var target = cfg.region;
41386 var r = Roo.bootstrap.layout;
41390 return new r.North(cfg);
41392 return new r.South(cfg);
41394 return new r.East(cfg);
41396 return new r.West(cfg);
41398 return new r.Center(cfg);
41400 throw 'Layout region "'+target+'" not supported.';
41407 * Ext JS Library 1.1.1
41408 * Copyright(c) 2006-2007, Ext JS, LLC.
41410 * Originally Released Under LGPL - original licence link has changed is not relivant.
41413 * <script type="text/javascript">
41417 * @class Roo.bootstrap.layout.Basic
41418 * @extends Roo.util.Observable
41419 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
41420 * and does not have a titlebar, tabs or any other features. All it does is size and position
41421 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
41422 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
41423 * @cfg {string} region the region that it inhabits..
41424 * @cfg {bool} skipConfig skip config?
41428 Roo.bootstrap.layout.Basic = function(config){
41430 this.mgr = config.mgr;
41432 this.position = config.region;
41434 var skipConfig = config.skipConfig;
41438 * @scope Roo.BasicLayoutRegion
41442 * @event beforeremove
41443 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
41444 * @param {Roo.LayoutRegion} this
41445 * @param {Roo.ContentPanel} panel The panel
41446 * @param {Object} e The cancel event object
41448 "beforeremove" : true,
41450 * @event invalidated
41451 * Fires when the layout for this region is changed.
41452 * @param {Roo.LayoutRegion} this
41454 "invalidated" : true,
41456 * @event visibilitychange
41457 * Fires when this region is shown or hidden
41458 * @param {Roo.LayoutRegion} this
41459 * @param {Boolean} visibility true or false
41461 "visibilitychange" : true,
41463 * @event paneladded
41464 * Fires when a panel is added.
41465 * @param {Roo.LayoutRegion} this
41466 * @param {Roo.ContentPanel} panel The panel
41468 "paneladded" : true,
41470 * @event panelremoved
41471 * Fires when a panel is removed.
41472 * @param {Roo.LayoutRegion} this
41473 * @param {Roo.ContentPanel} panel The panel
41475 "panelremoved" : true,
41477 * @event beforecollapse
41478 * Fires when this region before collapse.
41479 * @param {Roo.LayoutRegion} this
41481 "beforecollapse" : true,
41484 * Fires when this region is collapsed.
41485 * @param {Roo.LayoutRegion} this
41487 "collapsed" : true,
41490 * Fires when this region is expanded.
41491 * @param {Roo.LayoutRegion} this
41496 * Fires when this region is slid into view.
41497 * @param {Roo.LayoutRegion} this
41499 "slideshow" : true,
41502 * Fires when this region slides out of view.
41503 * @param {Roo.LayoutRegion} this
41505 "slidehide" : true,
41507 * @event panelactivated
41508 * Fires when a panel is activated.
41509 * @param {Roo.LayoutRegion} this
41510 * @param {Roo.ContentPanel} panel The activated panel
41512 "panelactivated" : true,
41515 * Fires when the user resizes this region.
41516 * @param {Roo.LayoutRegion} this
41517 * @param {Number} newSize The new size (width for east/west, height for north/south)
41521 /** A collection of panels in this region. @type Roo.util.MixedCollection */
41522 this.panels = new Roo.util.MixedCollection();
41523 this.panels.getKey = this.getPanelId.createDelegate(this);
41525 this.activePanel = null;
41526 // ensure listeners are added...
41528 if (config.listeners || config.events) {
41529 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
41530 listeners : config.listeners || {},
41531 events : config.events || {}
41535 if(skipConfig !== true){
41536 this.applyConfig(config);
41540 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
41542 getPanelId : function(p){
41546 applyConfig : function(config){
41547 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
41548 this.config = config;
41553 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
41554 * the width, for horizontal (north, south) the height.
41555 * @param {Number} newSize The new width or height
41557 resizeTo : function(newSize){
41558 var el = this.el ? this.el :
41559 (this.activePanel ? this.activePanel.getEl() : null);
41561 switch(this.position){
41564 el.setWidth(newSize);
41565 this.fireEvent("resized", this, newSize);
41569 el.setHeight(newSize);
41570 this.fireEvent("resized", this, newSize);
41576 getBox : function(){
41577 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
41580 getMargins : function(){
41581 return this.margins;
41584 updateBox : function(box){
41586 var el = this.activePanel.getEl();
41587 el.dom.style.left = box.x + "px";
41588 el.dom.style.top = box.y + "px";
41589 this.activePanel.setSize(box.width, box.height);
41593 * Returns the container element for this region.
41594 * @return {Roo.Element}
41596 getEl : function(){
41597 return this.activePanel;
41601 * Returns true if this region is currently visible.
41602 * @return {Boolean}
41604 isVisible : function(){
41605 return this.activePanel ? true : false;
41608 setActivePanel : function(panel){
41609 panel = this.getPanel(panel);
41610 if(this.activePanel && this.activePanel != panel){
41611 this.activePanel.setActiveState(false);
41612 this.activePanel.getEl().setLeftTop(-10000,-10000);
41614 this.activePanel = panel;
41615 panel.setActiveState(true);
41617 panel.setSize(this.box.width, this.box.height);
41619 this.fireEvent("panelactivated", this, panel);
41620 this.fireEvent("invalidated");
41624 * Show the specified panel.
41625 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
41626 * @return {Roo.ContentPanel} The shown panel or null
41628 showPanel : function(panel){
41629 panel = this.getPanel(panel);
41631 this.setActivePanel(panel);
41637 * Get the active panel for this region.
41638 * @return {Roo.ContentPanel} The active panel or null
41640 getActivePanel : function(){
41641 return this.activePanel;
41645 * Add the passed ContentPanel(s)
41646 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
41647 * @return {Roo.ContentPanel} The panel added (if only one was added)
41649 add : function(panel){
41650 if(arguments.length > 1){
41651 for(var i = 0, len = arguments.length; i < len; i++) {
41652 this.add(arguments[i]);
41656 if(this.hasPanel(panel)){
41657 this.showPanel(panel);
41660 var el = panel.getEl();
41661 if(el.dom.parentNode != this.mgr.el.dom){
41662 this.mgr.el.dom.appendChild(el.dom);
41664 if(panel.setRegion){
41665 panel.setRegion(this);
41667 this.panels.add(panel);
41668 el.setStyle("position", "absolute");
41669 if(!panel.background){
41670 this.setActivePanel(panel);
41671 if(this.config.initialSize && this.panels.getCount()==1){
41672 this.resizeTo(this.config.initialSize);
41675 this.fireEvent("paneladded", this, panel);
41680 * Returns true if the panel is in this region.
41681 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
41682 * @return {Boolean}
41684 hasPanel : function(panel){
41685 if(typeof panel == "object"){ // must be panel obj
41686 panel = panel.getId();
41688 return this.getPanel(panel) ? true : false;
41692 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
41693 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
41694 * @param {Boolean} preservePanel Overrides the config preservePanel option
41695 * @return {Roo.ContentPanel} The panel that was removed
41697 remove : function(panel, preservePanel){
41698 panel = this.getPanel(panel);
41703 this.fireEvent("beforeremove", this, panel, e);
41704 if(e.cancel === true){
41707 var panelId = panel.getId();
41708 this.panels.removeKey(panelId);
41713 * Returns the panel specified or null if it's not in this region.
41714 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
41715 * @return {Roo.ContentPanel}
41717 getPanel : function(id){
41718 if(typeof id == "object"){ // must be panel obj
41721 return this.panels.get(id);
41725 * Returns this regions position (north/south/east/west/center).
41728 getPosition: function(){
41729 return this.position;
41733 * Ext JS Library 1.1.1
41734 * Copyright(c) 2006-2007, Ext JS, LLC.
41736 * Originally Released Under LGPL - original licence link has changed is not relivant.
41739 * <script type="text/javascript">
41743 * @class Roo.bootstrap.layout.Region
41744 * @extends Roo.bootstrap.layout.Basic
41745 * This class represents a region in a layout manager.
41747 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
41748 * @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})
41749 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
41750 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
41751 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
41752 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
41753 * @cfg {String} title The title for the region (overrides panel titles)
41754 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
41755 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
41756 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
41757 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
41758 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
41759 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
41760 * the space available, similar to FireFox 1.5 tabs (defaults to false)
41761 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
41762 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
41763 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
41765 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
41766 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
41767 * @cfg {Boolean} disableTabTips True to disable tab tooltips
41768 * @cfg {Number} width For East/West panels
41769 * @cfg {Number} height For North/South panels
41770 * @cfg {Boolean} split To show the splitter
41771 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
41773 * @cfg {string} cls Extra CSS classes to add to region
41775 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
41776 * @cfg {string} region the region that it inhabits..
41779 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
41780 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
41782 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
41783 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
41784 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
41786 Roo.bootstrap.layout.Region = function(config)
41788 this.applyConfig(config);
41790 var mgr = config.mgr;
41791 var pos = config.region;
41792 config.skipConfig = true;
41793 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
41796 this.onRender(mgr.el);
41799 this.visible = true;
41800 this.collapsed = false;
41801 this.unrendered_panels = [];
41804 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
41806 position: '', // set by wrapper (eg. north/south etc..)
41807 unrendered_panels : null, // unrendered panels.
41809 tabPosition : false,
41811 mgr: false, // points to 'Border'
41814 createBody : function(){
41815 /** This region's body element
41816 * @type Roo.Element */
41817 this.bodyEl = this.el.createChild({
41819 cls: "roo-layout-panel-body tab-content" // bootstrap added...
41823 onRender: function(ctr, pos)
41825 var dh = Roo.DomHelper;
41826 /** This region's container element
41827 * @type Roo.Element */
41828 this.el = dh.append(ctr.dom, {
41830 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
41832 /** This region's title element
41833 * @type Roo.Element */
41835 this.titleEl = dh.append(this.el.dom, {
41837 unselectable: "on",
41838 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
41840 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
41841 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
41845 this.titleEl.enableDisplayMode();
41846 /** This region's title text element
41847 * @type HTMLElement */
41848 this.titleTextEl = this.titleEl.dom.firstChild;
41849 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
41851 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
41852 this.closeBtn.enableDisplayMode();
41853 this.closeBtn.on("click", this.closeClicked, this);
41854 this.closeBtn.hide();
41856 this.createBody(this.config);
41857 if(this.config.hideWhenEmpty){
41859 this.on("paneladded", this.validateVisibility, this);
41860 this.on("panelremoved", this.validateVisibility, this);
41862 if(this.autoScroll){
41863 this.bodyEl.setStyle("overflow", "auto");
41865 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
41867 //if(c.titlebar !== false){
41868 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
41869 this.titleEl.hide();
41871 this.titleEl.show();
41872 if(this.config.title){
41873 this.titleTextEl.innerHTML = this.config.title;
41877 if(this.config.collapsed){
41878 this.collapse(true);
41880 if(this.config.hidden){
41884 if (this.unrendered_panels && this.unrendered_panels.length) {
41885 for (var i =0;i< this.unrendered_panels.length; i++) {
41886 this.add(this.unrendered_panels[i]);
41888 this.unrendered_panels = null;
41894 applyConfig : function(c)
41897 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
41898 var dh = Roo.DomHelper;
41899 if(c.titlebar !== false){
41900 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
41901 this.collapseBtn.on("click", this.collapse, this);
41902 this.collapseBtn.enableDisplayMode();
41904 if(c.showPin === true || this.showPin){
41905 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
41906 this.stickBtn.enableDisplayMode();
41907 this.stickBtn.on("click", this.expand, this);
41908 this.stickBtn.hide();
41913 /** This region's collapsed element
41914 * @type Roo.Element */
41917 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
41918 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
41921 if(c.floatable !== false){
41922 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
41923 this.collapsedEl.on("click", this.collapseClick, this);
41926 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
41927 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
41928 id: "message", unselectable: "on", style:{"float":"left"}});
41929 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
41931 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
41932 this.expandBtn.on("click", this.expand, this);
41936 if(this.collapseBtn){
41937 this.collapseBtn.setVisible(c.collapsible == true);
41940 this.cmargins = c.cmargins || this.cmargins ||
41941 (this.position == "west" || this.position == "east" ?
41942 {top: 0, left: 2, right:2, bottom: 0} :
41943 {top: 2, left: 0, right:0, bottom: 2});
41945 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
41948 this.tabPosition = [ 'top','bottom', 'west'].indexOf(c.tabPosition) > -1 ? c.tabPosition : "top";
41950 this.autoScroll = c.autoScroll || false;
41955 this.duration = c.duration || .30;
41956 this.slideDuration = c.slideDuration || .45;
41961 * Returns true if this region is currently visible.
41962 * @return {Boolean}
41964 isVisible : function(){
41965 return this.visible;
41969 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
41970 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
41972 //setCollapsedTitle : function(title){
41973 // title = title || " ";
41974 // if(this.collapsedTitleTextEl){
41975 // this.collapsedTitleTextEl.innerHTML = title;
41979 getBox : function(){
41981 // if(!this.collapsed){
41982 b = this.el.getBox(false, true);
41984 // b = this.collapsedEl.getBox(false, true);
41989 getMargins : function(){
41990 return this.margins;
41991 //return this.collapsed ? this.cmargins : this.margins;
41994 highlight : function(){
41995 this.el.addClass("x-layout-panel-dragover");
41998 unhighlight : function(){
41999 this.el.removeClass("x-layout-panel-dragover");
42002 updateBox : function(box)
42004 if (!this.bodyEl) {
42005 return; // not rendered yet..
42009 if(!this.collapsed){
42010 this.el.dom.style.left = box.x + "px";
42011 this.el.dom.style.top = box.y + "px";
42012 this.updateBody(box.width, box.height);
42014 this.collapsedEl.dom.style.left = box.x + "px";
42015 this.collapsedEl.dom.style.top = box.y + "px";
42016 this.collapsedEl.setSize(box.width, box.height);
42019 this.tabs.autoSizeTabs();
42023 updateBody : function(w, h)
42026 this.el.setWidth(w);
42027 w -= this.el.getBorderWidth("rl");
42028 if(this.config.adjustments){
42029 w += this.config.adjustments[0];
42032 if(h !== null && h > 0){
42033 this.el.setHeight(h);
42034 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
42035 h -= this.el.getBorderWidth("tb");
42036 if(this.config.adjustments){
42037 h += this.config.adjustments[1];
42039 this.bodyEl.setHeight(h);
42041 h = this.tabs.syncHeight(h);
42044 if(this.panelSize){
42045 w = w !== null ? w : this.panelSize.width;
42046 h = h !== null ? h : this.panelSize.height;
42048 if(this.activePanel){
42049 var el = this.activePanel.getEl();
42050 w = w !== null ? w : el.getWidth();
42051 h = h !== null ? h : el.getHeight();
42052 this.panelSize = {width: w, height: h};
42053 this.activePanel.setSize(w, h);
42055 if(Roo.isIE && this.tabs){
42056 this.tabs.el.repaint();
42061 * Returns the container element for this region.
42062 * @return {Roo.Element}
42064 getEl : function(){
42069 * Hides this region.
42072 //if(!this.collapsed){
42073 this.el.dom.style.left = "-2000px";
42076 // this.collapsedEl.dom.style.left = "-2000px";
42077 // this.collapsedEl.hide();
42079 this.visible = false;
42080 this.fireEvent("visibilitychange", this, false);
42084 * Shows this region if it was previously hidden.
42087 //if(!this.collapsed){
42090 // this.collapsedEl.show();
42092 this.visible = true;
42093 this.fireEvent("visibilitychange", this, true);
42096 closeClicked : function(){
42097 if(this.activePanel){
42098 this.remove(this.activePanel);
42102 collapseClick : function(e){
42104 e.stopPropagation();
42107 e.stopPropagation();
42113 * Collapses this region.
42114 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
42117 collapse : function(skipAnim, skipCheck = false){
42118 if(this.collapsed) {
42122 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
42124 this.collapsed = true;
42126 this.split.el.hide();
42128 if(this.config.animate && skipAnim !== true){
42129 this.fireEvent("invalidated", this);
42130 this.animateCollapse();
42132 this.el.setLocation(-20000,-20000);
42134 this.collapsedEl.show();
42135 this.fireEvent("collapsed", this);
42136 this.fireEvent("invalidated", this);
42142 animateCollapse : function(){
42147 * Expands this region if it was previously collapsed.
42148 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
42149 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
42152 expand : function(e, skipAnim){
42154 e.stopPropagation();
42156 if(!this.collapsed || this.el.hasActiveFx()) {
42160 this.afterSlideIn();
42163 this.collapsed = false;
42164 if(this.config.animate && skipAnim !== true){
42165 this.animateExpand();
42169 this.split.el.show();
42171 this.collapsedEl.setLocation(-2000,-2000);
42172 this.collapsedEl.hide();
42173 this.fireEvent("invalidated", this);
42174 this.fireEvent("expanded", this);
42178 animateExpand : function(){
42182 initTabs : function()
42184 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
42186 var ts = new Roo.bootstrap.panel.Tabs({
42187 el: this.bodyEl.dom,
42189 tabPosition: this.tabPosition ? this.tabPosition : 'top',
42190 disableTooltips: this.config.disableTabTips,
42191 toolbar : this.config.toolbar
42194 if(this.config.hideTabs){
42195 ts.stripWrap.setDisplayed(false);
42198 ts.resizeTabs = this.config.resizeTabs === true;
42199 ts.minTabWidth = this.config.minTabWidth || 40;
42200 ts.maxTabWidth = this.config.maxTabWidth || 250;
42201 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
42202 ts.monitorResize = false;
42203 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
42204 ts.bodyEl.addClass('roo-layout-tabs-body');
42205 this.panels.each(this.initPanelAsTab, this);
42208 initPanelAsTab : function(panel){
42209 var ti = this.tabs.addTab(
42213 this.config.closeOnTab && panel.isClosable(),
42216 if(panel.tabTip !== undefined){
42217 ti.setTooltip(panel.tabTip);
42219 ti.on("activate", function(){
42220 this.setActivePanel(panel);
42223 if(this.config.closeOnTab){
42224 ti.on("beforeclose", function(t, e){
42226 this.remove(panel);
42230 panel.tabItem = ti;
42235 updatePanelTitle : function(panel, title)
42237 if(this.activePanel == panel){
42238 this.updateTitle(title);
42241 var ti = this.tabs.getTab(panel.getEl().id);
42243 if(panel.tabTip !== undefined){
42244 ti.setTooltip(panel.tabTip);
42249 updateTitle : function(title){
42250 if(this.titleTextEl && !this.config.title){
42251 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
42255 setActivePanel : function(panel)
42257 panel = this.getPanel(panel);
42258 if(this.activePanel && this.activePanel != panel){
42259 if(this.activePanel.setActiveState(false) === false){
42263 this.activePanel = panel;
42264 panel.setActiveState(true);
42265 if(this.panelSize){
42266 panel.setSize(this.panelSize.width, this.panelSize.height);
42269 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
42271 this.updateTitle(panel.getTitle());
42273 this.fireEvent("invalidated", this);
42275 this.fireEvent("panelactivated", this, panel);
42279 * Shows the specified panel.
42280 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
42281 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
42283 showPanel : function(panel)
42285 panel = this.getPanel(panel);
42288 var tab = this.tabs.getTab(panel.getEl().id);
42289 if(tab.isHidden()){
42290 this.tabs.unhideTab(tab.id);
42294 this.setActivePanel(panel);
42301 * Get the active panel for this region.
42302 * @return {Roo.ContentPanel} The active panel or null
42304 getActivePanel : function(){
42305 return this.activePanel;
42308 validateVisibility : function(){
42309 if(this.panels.getCount() < 1){
42310 this.updateTitle(" ");
42311 this.closeBtn.hide();
42314 if(!this.isVisible()){
42321 * Adds the passed ContentPanel(s) to this region.
42322 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
42323 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
42325 add : function(panel)
42327 if(arguments.length > 1){
42328 for(var i = 0, len = arguments.length; i < len; i++) {
42329 this.add(arguments[i]);
42334 // if we have not been rendered yet, then we can not really do much of this..
42335 if (!this.bodyEl) {
42336 this.unrendered_panels.push(panel);
42343 if(this.hasPanel(panel)){
42344 this.showPanel(panel);
42347 panel.setRegion(this);
42348 this.panels.add(panel);
42349 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
42350 // sinle panel - no tab...?? would it not be better to render it with the tabs,
42351 // and hide them... ???
42352 this.bodyEl.dom.appendChild(panel.getEl().dom);
42353 if(panel.background !== true){
42354 this.setActivePanel(panel);
42356 this.fireEvent("paneladded", this, panel);
42363 this.initPanelAsTab(panel);
42367 if(panel.background !== true){
42368 this.tabs.activate(panel.getEl().id);
42370 this.fireEvent("paneladded", this, panel);
42375 * Hides the tab for the specified panel.
42376 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
42378 hidePanel : function(panel){
42379 if(this.tabs && (panel = this.getPanel(panel))){
42380 this.tabs.hideTab(panel.getEl().id);
42385 * Unhides the tab for a previously hidden panel.
42386 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
42388 unhidePanel : function(panel){
42389 if(this.tabs && (panel = this.getPanel(panel))){
42390 this.tabs.unhideTab(panel.getEl().id);
42394 clearPanels : function(){
42395 while(this.panels.getCount() > 0){
42396 this.remove(this.panels.first());
42401 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
42402 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
42403 * @param {Boolean} preservePanel Overrides the config preservePanel option
42404 * @return {Roo.ContentPanel} The panel that was removed
42406 remove : function(panel, preservePanel)
42408 panel = this.getPanel(panel);
42413 this.fireEvent("beforeremove", this, panel, e);
42414 if(e.cancel === true){
42417 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
42418 var panelId = panel.getId();
42419 this.panels.removeKey(panelId);
42421 document.body.appendChild(panel.getEl().dom);
42424 this.tabs.removeTab(panel.getEl().id);
42425 }else if (!preservePanel){
42426 this.bodyEl.dom.removeChild(panel.getEl().dom);
42428 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
42429 var p = this.panels.first();
42430 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
42431 tempEl.appendChild(p.getEl().dom);
42432 this.bodyEl.update("");
42433 this.bodyEl.dom.appendChild(p.getEl().dom);
42435 this.updateTitle(p.getTitle());
42437 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
42438 this.setActivePanel(p);
42440 panel.setRegion(null);
42441 if(this.activePanel == panel){
42442 this.activePanel = null;
42444 if(this.config.autoDestroy !== false && preservePanel !== true){
42445 try{panel.destroy();}catch(e){}
42447 this.fireEvent("panelremoved", this, panel);
42452 * Returns the TabPanel component used by this region
42453 * @return {Roo.TabPanel}
42455 getTabs : function(){
42459 createTool : function(parentEl, className){
42460 var btn = Roo.DomHelper.append(parentEl, {
42462 cls: "x-layout-tools-button",
42465 cls: "roo-layout-tools-button-inner " + className,
42469 btn.addClassOnOver("roo-layout-tools-button-over");
42474 * Ext JS Library 1.1.1
42475 * Copyright(c) 2006-2007, Ext JS, LLC.
42477 * Originally Released Under LGPL - original licence link has changed is not relivant.
42480 * <script type="text/javascript">
42486 * @class Roo.SplitLayoutRegion
42487 * @extends Roo.LayoutRegion
42488 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
42490 Roo.bootstrap.layout.Split = function(config){
42491 this.cursor = config.cursor;
42492 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
42495 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
42497 splitTip : "Drag to resize.",
42498 collapsibleSplitTip : "Drag to resize. Double click to hide.",
42499 useSplitTips : false,
42501 applyConfig : function(config){
42502 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
42505 onRender : function(ctr,pos) {
42507 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
42508 if(!this.config.split){
42513 var splitEl = Roo.DomHelper.append(ctr.dom, {
42515 id: this.el.id + "-split",
42516 cls: "roo-layout-split roo-layout-split-"+this.position,
42519 /** The SplitBar for this region
42520 * @type Roo.SplitBar */
42521 // does not exist yet...
42522 Roo.log([this.position, this.orientation]);
42524 this.split = new Roo.bootstrap.SplitBar({
42525 dragElement : splitEl,
42526 resizingElement: this.el,
42527 orientation : this.orientation
42530 this.split.on("moved", this.onSplitMove, this);
42531 this.split.useShim = this.config.useShim === true;
42532 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
42533 if(this.useSplitTips){
42534 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
42536 //if(config.collapsible){
42537 // this.split.el.on("dblclick", this.collapse, this);
42540 if(typeof this.config.minSize != "undefined"){
42541 this.split.minSize = this.config.minSize;
42543 if(typeof this.config.maxSize != "undefined"){
42544 this.split.maxSize = this.config.maxSize;
42546 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
42547 this.hideSplitter();
42552 getHMaxSize : function(){
42553 var cmax = this.config.maxSize || 10000;
42554 var center = this.mgr.getRegion("center");
42555 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
42558 getVMaxSize : function(){
42559 var cmax = this.config.maxSize || 10000;
42560 var center = this.mgr.getRegion("center");
42561 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
42564 onSplitMove : function(split, newSize){
42565 this.fireEvent("resized", this, newSize);
42569 * Returns the {@link Roo.SplitBar} for this region.
42570 * @return {Roo.SplitBar}
42572 getSplitBar : function(){
42577 this.hideSplitter();
42578 Roo.bootstrap.layout.Split.superclass.hide.call(this);
42581 hideSplitter : function(){
42583 this.split.el.setLocation(-2000,-2000);
42584 this.split.el.hide();
42590 this.split.el.show();
42592 Roo.bootstrap.layout.Split.superclass.show.call(this);
42595 beforeSlide: function(){
42596 if(Roo.isGecko){// firefox overflow auto bug workaround
42597 this.bodyEl.clip();
42599 this.tabs.bodyEl.clip();
42601 if(this.activePanel){
42602 this.activePanel.getEl().clip();
42604 if(this.activePanel.beforeSlide){
42605 this.activePanel.beforeSlide();
42611 afterSlide : function(){
42612 if(Roo.isGecko){// firefox overflow auto bug workaround
42613 this.bodyEl.unclip();
42615 this.tabs.bodyEl.unclip();
42617 if(this.activePanel){
42618 this.activePanel.getEl().unclip();
42619 if(this.activePanel.afterSlide){
42620 this.activePanel.afterSlide();
42626 initAutoHide : function(){
42627 if(this.autoHide !== false){
42628 if(!this.autoHideHd){
42629 var st = new Roo.util.DelayedTask(this.slideIn, this);
42630 this.autoHideHd = {
42631 "mouseout": function(e){
42632 if(!e.within(this.el, true)){
42636 "mouseover" : function(e){
42642 this.el.on(this.autoHideHd);
42646 clearAutoHide : function(){
42647 if(this.autoHide !== false){
42648 this.el.un("mouseout", this.autoHideHd.mouseout);
42649 this.el.un("mouseover", this.autoHideHd.mouseover);
42653 clearMonitor : function(){
42654 Roo.get(document).un("click", this.slideInIf, this);
42657 // these names are backwards but not changed for compat
42658 slideOut : function(){
42659 if(this.isSlid || this.el.hasActiveFx()){
42662 this.isSlid = true;
42663 if(this.collapseBtn){
42664 this.collapseBtn.hide();
42666 this.closeBtnState = this.closeBtn.getStyle('display');
42667 this.closeBtn.hide();
42669 this.stickBtn.show();
42672 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
42673 this.beforeSlide();
42674 this.el.setStyle("z-index", 10001);
42675 this.el.slideIn(this.getSlideAnchor(), {
42676 callback: function(){
42678 this.initAutoHide();
42679 Roo.get(document).on("click", this.slideInIf, this);
42680 this.fireEvent("slideshow", this);
42687 afterSlideIn : function(){
42688 this.clearAutoHide();
42689 this.isSlid = false;
42690 this.clearMonitor();
42691 this.el.setStyle("z-index", "");
42692 if(this.collapseBtn){
42693 this.collapseBtn.show();
42695 this.closeBtn.setStyle('display', this.closeBtnState);
42697 this.stickBtn.hide();
42699 this.fireEvent("slidehide", this);
42702 slideIn : function(cb){
42703 if(!this.isSlid || this.el.hasActiveFx()){
42707 this.isSlid = false;
42708 this.beforeSlide();
42709 this.el.slideOut(this.getSlideAnchor(), {
42710 callback: function(){
42711 this.el.setLeftTop(-10000, -10000);
42713 this.afterSlideIn();
42721 slideInIf : function(e){
42722 if(!e.within(this.el)){
42727 animateCollapse : function(){
42728 this.beforeSlide();
42729 this.el.setStyle("z-index", 20000);
42730 var anchor = this.getSlideAnchor();
42731 this.el.slideOut(anchor, {
42732 callback : function(){
42733 this.el.setStyle("z-index", "");
42734 this.collapsedEl.slideIn(anchor, {duration:.3});
42736 this.el.setLocation(-10000,-10000);
42738 this.fireEvent("collapsed", this);
42745 animateExpand : function(){
42746 this.beforeSlide();
42747 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
42748 this.el.setStyle("z-index", 20000);
42749 this.collapsedEl.hide({
42752 this.el.slideIn(this.getSlideAnchor(), {
42753 callback : function(){
42754 this.el.setStyle("z-index", "");
42757 this.split.el.show();
42759 this.fireEvent("invalidated", this);
42760 this.fireEvent("expanded", this);
42788 getAnchor : function(){
42789 return this.anchors[this.position];
42792 getCollapseAnchor : function(){
42793 return this.canchors[this.position];
42796 getSlideAnchor : function(){
42797 return this.sanchors[this.position];
42800 getAlignAdj : function(){
42801 var cm = this.cmargins;
42802 switch(this.position){
42818 getExpandAdj : function(){
42819 var c = this.collapsedEl, cm = this.cmargins;
42820 switch(this.position){
42822 return [-(cm.right+c.getWidth()+cm.left), 0];
42825 return [cm.right+c.getWidth()+cm.left, 0];
42828 return [0, -(cm.top+cm.bottom+c.getHeight())];
42831 return [0, cm.top+cm.bottom+c.getHeight()];
42837 * Ext JS Library 1.1.1
42838 * Copyright(c) 2006-2007, Ext JS, LLC.
42840 * Originally Released Under LGPL - original licence link has changed is not relivant.
42843 * <script type="text/javascript">
42846 * These classes are private internal classes
42848 Roo.bootstrap.layout.Center = function(config){
42849 config.region = "center";
42850 Roo.bootstrap.layout.Region.call(this, config);
42851 this.visible = true;
42852 this.minWidth = config.minWidth || 20;
42853 this.minHeight = config.minHeight || 20;
42856 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
42858 // center panel can't be hidden
42862 // center panel can't be hidden
42865 getMinWidth: function(){
42866 return this.minWidth;
42869 getMinHeight: function(){
42870 return this.minHeight;
42884 Roo.bootstrap.layout.North = function(config)
42886 config.region = 'north';
42887 config.cursor = 'n-resize';
42889 Roo.bootstrap.layout.Split.call(this, config);
42893 this.split.placement = Roo.bootstrap.SplitBar.TOP;
42894 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
42895 this.split.el.addClass("roo-layout-split-v");
42897 //var size = config.initialSize || config.height;
42898 //if(this.el && typeof size != "undefined"){
42899 // this.el.setHeight(size);
42902 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
42904 orientation: Roo.bootstrap.SplitBar.VERTICAL,
42907 onRender : function(ctr, pos)
42909 Roo.bootstrap.layout.Split.prototype.onRender.call(this, ctr, pos);
42910 var size = this.config.initialSize || this.config.height;
42911 if(this.el && typeof size != "undefined"){
42912 this.el.setHeight(size);
42917 getBox : function(){
42918 if(this.collapsed){
42919 return this.collapsedEl.getBox();
42921 var box = this.el.getBox();
42923 box.height += this.split.el.getHeight();
42928 updateBox : function(box){
42929 if(this.split && !this.collapsed){
42930 box.height -= this.split.el.getHeight();
42931 this.split.el.setLeft(box.x);
42932 this.split.el.setTop(box.y+box.height);
42933 this.split.el.setWidth(box.width);
42935 if(this.collapsed){
42936 this.updateBody(box.width, null);
42938 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
42946 Roo.bootstrap.layout.South = function(config){
42947 config.region = 'south';
42948 config.cursor = 's-resize';
42949 Roo.bootstrap.layout.Split.call(this, config);
42951 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
42952 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
42953 this.split.el.addClass("roo-layout-split-v");
42958 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
42959 orientation: Roo.bootstrap.SplitBar.VERTICAL,
42961 onRender : function(ctr, pos)
42963 Roo.bootstrap.layout.Split.prototype.onRender.call(this, ctr, pos);
42964 var size = this.config.initialSize || this.config.height;
42965 if(this.el && typeof size != "undefined"){
42966 this.el.setHeight(size);
42971 getBox : function(){
42972 if(this.collapsed){
42973 return this.collapsedEl.getBox();
42975 var box = this.el.getBox();
42977 var sh = this.split.el.getHeight();
42984 updateBox : function(box){
42985 if(this.split && !this.collapsed){
42986 var sh = this.split.el.getHeight();
42989 this.split.el.setLeft(box.x);
42990 this.split.el.setTop(box.y-sh);
42991 this.split.el.setWidth(box.width);
42993 if(this.collapsed){
42994 this.updateBody(box.width, null);
42996 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
43000 Roo.bootstrap.layout.East = function(config){
43001 config.region = "east";
43002 config.cursor = "e-resize";
43003 Roo.bootstrap.layout.Split.call(this, config);
43005 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
43006 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
43007 this.split.el.addClass("roo-layout-split-h");
43011 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
43012 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
43014 onRender : function(ctr, pos)
43016 Roo.bootstrap.layout.Split.prototype.onRender.call(this, ctr, pos);
43017 var size = this.config.initialSize || this.config.width;
43018 if(this.el && typeof size != "undefined"){
43019 this.el.setWidth(size);
43024 getBox : function(){
43025 if(this.collapsed){
43026 return this.collapsedEl.getBox();
43028 var box = this.el.getBox();
43030 var sw = this.split.el.getWidth();
43037 updateBox : function(box){
43038 if(this.split && !this.collapsed){
43039 var sw = this.split.el.getWidth();
43041 this.split.el.setLeft(box.x);
43042 this.split.el.setTop(box.y);
43043 this.split.el.setHeight(box.height);
43046 if(this.collapsed){
43047 this.updateBody(null, box.height);
43049 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
43053 Roo.bootstrap.layout.West = function(config){
43054 config.region = "west";
43055 config.cursor = "w-resize";
43057 Roo.bootstrap.layout.Split.call(this, config);
43059 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
43060 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
43061 this.split.el.addClass("roo-layout-split-h");
43065 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
43066 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
43068 onRender: function(ctr, pos)
43070 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
43071 var size = this.config.initialSize || this.config.width;
43072 if(typeof size != "undefined"){
43073 this.el.setWidth(size);
43077 getBox : function(){
43078 if(this.collapsed){
43079 return this.collapsedEl.getBox();
43081 var box = this.el.getBox();
43082 if (box.width == 0) {
43083 box.width = this.config.width; // kludge?
43086 box.width += this.split.el.getWidth();
43091 updateBox : function(box){
43092 if(this.split && !this.collapsed){
43093 var sw = this.split.el.getWidth();
43095 this.split.el.setLeft(box.x+box.width);
43096 this.split.el.setTop(box.y);
43097 this.split.el.setHeight(box.height);
43099 if(this.collapsed){
43100 this.updateBody(null, box.height);
43102 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
43106 * Ext JS Library 1.1.1
43107 * Copyright(c) 2006-2007, Ext JS, LLC.
43109 * Originally Released Under LGPL - original licence link has changed is not relivant.
43112 * <script type="text/javascript">
43115 * @class Roo.bootstrap.paenl.Content
43116 * @extends Roo.util.Observable
43117 * @children Roo.bootstrap.Component
43118 * @parent builder Roo.bootstrap.layout.Border
43119 * A basic ContentPanel element. - a panel that contain any content (eg. forms etc.)
43120 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
43121 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
43122 * @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
43123 * @cfg {Boolean} closable True if the panel can be closed/removed
43124 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
43125 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
43126 * @cfg {Toolbar} toolbar A toolbar for this panel
43127 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
43128 * @cfg {String} title The title for this panel
43129 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
43130 * @cfg {String} url Calls {@link #setUrl} with this value
43131 * @cfg {String} region [required] (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
43132 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
43133 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
43134 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
43135 * @cfg {Boolean} iframe contents are an iframe - makes showing remote sources/CSS feasible..
43136 * @cfg {Boolean} badges render the badges
43137 * @cfg {String} cls extra classes to use
43138 * @cfg {String} background (primary|secondary|success|info|warning|danger|light|dark)
43141 * Create a new ContentPanel.
43142 * @param {String/Object} config A string to set only the title or a config object
43145 Roo.bootstrap.panel.Content = function( config){
43147 this.tpl = config.tpl || false;
43149 var el = config.el;
43150 var content = config.content;
43152 if(config.autoCreate){ // xtype is available if this is called from factory
43155 this.el = Roo.get(el);
43156 if(!this.el && config && config.autoCreate){
43157 if(typeof config.autoCreate == "object"){
43158 if(!config.autoCreate.id){
43159 config.autoCreate.id = config.id||el;
43161 this.el = Roo.DomHelper.append(document.body,
43162 config.autoCreate, true);
43166 cls: (config.cls || '') +
43167 (config.background ? ' bg-' + config.background : '') +
43168 " roo-layout-inactive-content",
43171 if (config.iframe) {
43175 style : 'border: 0px',
43176 src : 'about:blank'
43182 elcfg.html = config.html;
43186 this.el = Roo.DomHelper.append(document.body, elcfg , true);
43187 if (config.iframe) {
43188 this.iframeEl = this.el.select('iframe',true).first();
43193 this.closable = false;
43194 this.loaded = false;
43195 this.active = false;
43198 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
43200 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
43202 this.wrapEl = this.el; //this.el.wrap();
43204 if (config.toolbar.items) {
43205 ti = config.toolbar.items ;
43206 delete config.toolbar.items ;
43210 this.toolbar.render(this.wrapEl, 'before');
43211 for(var i =0;i < ti.length;i++) {
43212 // Roo.log(['add child', items[i]]);
43213 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
43215 this.toolbar.items = nitems;
43216 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
43217 delete config.toolbar;
43221 // xtype created footer. - not sure if will work as we normally have to render first..
43222 if (this.footer && !this.footer.el && this.footer.xtype) {
43223 if (!this.wrapEl) {
43224 this.wrapEl = this.el.wrap();
43227 this.footer.container = this.wrapEl.createChild();
43229 this.footer = Roo.factory(this.footer, Roo);
43234 if(typeof config == "string"){
43235 this.title = config;
43237 Roo.apply(this, config);
43241 this.resizeEl = Roo.get(this.resizeEl, true);
43243 this.resizeEl = this.el;
43245 // handle view.xtype
43253 * Fires when this panel is activated.
43254 * @param {Roo.ContentPanel} this
43258 * @event deactivate
43259 * Fires when this panel is activated.
43260 * @param {Roo.ContentPanel} this
43262 "deactivate" : true,
43266 * Fires when this panel is resized if fitToFrame is true.
43267 * @param {Roo.ContentPanel} this
43268 * @param {Number} width The width after any component adjustments
43269 * @param {Number} height The height after any component adjustments
43275 * Fires when this tab is created
43276 * @param {Roo.ContentPanel} this
43282 * Fires when this content is scrolled
43283 * @param {Roo.ContentPanel} this
43284 * @param {Event} scrollEvent
43295 if(this.autoScroll && !this.iframe){
43296 this.resizeEl.setStyle("overflow", "auto");
43297 this.resizeEl.on('scroll', this.onScroll, this);
43299 // fix randome scrolling
43300 //this.el.on('scroll', function() {
43301 // Roo.log('fix random scolling');
43302 // this.scrollTo('top',0);
43305 content = content || this.content;
43307 this.setContent(content);
43309 if(config && config.url){
43310 this.setUrl(this.url, this.params, this.loadOnce);
43315 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
43317 if (this.view && typeof(this.view.xtype) != 'undefined') {
43318 this.view.el = this.el.appendChild(document.createElement("div"));
43319 this.view = Roo.factory(this.view);
43320 this.view.render && this.view.render(false, '');
43324 this.fireEvent('render', this);
43327 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
43337 /* Resize Element - use this to work out scroll etc. */
43340 setRegion : function(region){
43341 this.region = region;
43342 this.setActiveClass(region && !this.background);
43346 setActiveClass: function(state)
43349 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
43350 this.el.setStyle('position','relative');
43352 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
43353 this.el.setStyle('position', 'absolute');
43358 * Returns the toolbar for this Panel if one was configured.
43359 * @return {Roo.Toolbar}
43361 getToolbar : function(){
43362 return this.toolbar;
43365 setActiveState : function(active)
43367 this.active = active;
43368 this.setActiveClass(active);
43370 if(this.fireEvent("deactivate", this) === false){
43375 this.fireEvent("activate", this);
43379 * Updates this panel's element (not for iframe)
43380 * @param {String} content The new content
43381 * @param {Boolean} loadScripts (optional) true to look for and process scripts
43383 setContent : function(content, loadScripts){
43388 this.el.update(content, loadScripts);
43391 ignoreResize : function(w, h)
43393 //return false; // always resize?
43394 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
43397 this.lastSize = {width: w, height: h};
43402 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
43403 * @return {Roo.UpdateManager} The UpdateManager
43405 getUpdateManager : function(){
43409 return this.el.getUpdateManager();
43412 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
43413 * Does not work with IFRAME contents
43414 * @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:
43417 url: "your-url.php",
43418 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
43419 callback: yourFunction,
43420 scope: yourObject, //(optional scope)
43423 text: "Loading...",
43429 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
43430 * 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.
43431 * @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}
43432 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
43433 * @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.
43434 * @return {Roo.ContentPanel} this
43442 var um = this.el.getUpdateManager();
43443 um.update.apply(um, arguments);
43449 * 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.
43450 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
43451 * @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)
43452 * @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)
43453 * @return {Roo.UpdateManager|Boolean} The UpdateManager or false if IFRAME
43455 setUrl : function(url, params, loadOnce){
43457 this.iframeEl.dom.src = url;
43461 if(this.refreshDelegate){
43462 this.removeListener("activate", this.refreshDelegate);
43464 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
43465 this.on("activate", this.refreshDelegate);
43466 return this.el.getUpdateManager();
43469 _handleRefresh : function(url, params, loadOnce){
43470 if(!loadOnce || !this.loaded){
43471 var updater = this.el.getUpdateManager();
43472 updater.update(url, params, this._setLoaded.createDelegate(this));
43476 _setLoaded : function(){
43477 this.loaded = true;
43481 * Returns this panel's id
43484 getId : function(){
43489 * Returns this panel's element - used by regiosn to add.
43490 * @return {Roo.Element}
43492 getEl : function(){
43493 return this.wrapEl || this.el;
43498 adjustForComponents : function(width, height)
43500 //Roo.log('adjustForComponents ');
43501 if(this.resizeEl != this.el){
43502 width -= this.el.getFrameWidth('lr');
43503 height -= this.el.getFrameWidth('tb');
43506 var te = this.toolbar.getEl();
43507 te.setWidth(width);
43508 height -= te.getHeight();
43511 var te = this.footer.getEl();
43512 te.setWidth(width);
43513 height -= te.getHeight();
43517 if(this.adjustments){
43518 width += this.adjustments[0];
43519 height += this.adjustments[1];
43521 return {"width": width, "height": height};
43524 setSize : function(width, height){
43525 if(this.fitToFrame && !this.ignoreResize(width, height)){
43526 if(this.fitContainer && this.resizeEl != this.el){
43527 this.el.setSize(width, height);
43529 var size = this.adjustForComponents(width, height);
43531 this.iframeEl.setSize(width,height);
43534 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
43535 this.fireEvent('resize', this, size.width, size.height);
43542 * Returns this panel's title
43545 getTitle : function(){
43547 if (typeof(this.title) != 'object') {
43552 for (var k in this.title) {
43553 if (!this.title.hasOwnProperty(k)) {
43557 if (k.indexOf('-') >= 0) {
43558 var s = k.split('-');
43559 for (var i = 0; i<s.length; i++) {
43560 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
43563 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
43570 * Set this panel's title
43571 * @param {String} title
43573 setTitle : function(title){
43574 this.title = title;
43576 this.region.updatePanelTitle(this, title);
43581 * Returns true is this panel was configured to be closable
43582 * @return {Boolean}
43584 isClosable : function(){
43585 return this.closable;
43588 beforeSlide : function(){
43590 this.resizeEl.clip();
43593 afterSlide : function(){
43595 this.resizeEl.unclip();
43599 * Force a content refresh from the URL specified in the {@link #setUrl} method.
43600 * Will fail silently if the {@link #setUrl} method has not been called.
43601 * This does not activate the panel, just updates its content.
43603 refresh : function(){
43604 if(this.refreshDelegate){
43605 this.loaded = false;
43606 this.refreshDelegate();
43611 * Destroys this panel
43613 destroy : function(){
43614 this.el.removeAllListeners();
43615 var tempEl = document.createElement("span");
43616 tempEl.appendChild(this.el.dom);
43617 tempEl.innerHTML = "";
43623 * form - if the content panel contains a form - this is a reference to it.
43624 * @type {Roo.form.Form}
43628 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
43629 * This contains a reference to it.
43635 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
43645 * @param {Object} cfg Xtype definition of item to add.
43649 getChildContainer: function () {
43650 return this.getEl();
43654 onScroll : function(e)
43656 this.fireEvent('scroll', this, e);
43661 var ret = new Roo.factory(cfg);
43666 if (cfg.xtype.match(/^Form$/)) {
43669 //if (this.footer) {
43670 // el = this.footer.container.insertSibling(false, 'before');
43672 el = this.el.createChild();
43675 this.form = new Roo.form.Form(cfg);
43678 if ( this.form.allItems.length) {
43679 this.form.render(el.dom);
43683 // should only have one of theses..
43684 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
43685 // views.. should not be just added - used named prop 'view''
43687 cfg.el = this.el.appendChild(document.createElement("div"));
43690 var ret = new Roo.factory(cfg);
43692 ret.render && ret.render(false, ''); // render blank..
43702 * @class Roo.bootstrap.panel.Grid
43703 * @extends Roo.bootstrap.panel.Content
43705 * Create a new GridPanel.
43706 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
43707 * @cfg {Roo.bootstrap.nav.Simplebar} toolbar the toolbar at the top of the grid.
43708 * @param {Object} config A the config object
43714 Roo.bootstrap.panel.Grid = function(config)
43718 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
43719 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
43721 config.el = this.wrapper;
43722 //this.el = this.wrapper;
43724 if (config.container) {
43725 // ctor'ed from a Border/panel.grid
43728 this.wrapper.setStyle("overflow", "hidden");
43729 this.wrapper.addClass('roo-grid-container');
43734 if(config.toolbar){
43735 var tool_el = this.wrapper.createChild();
43736 this.toolbar = Roo.factory(config.toolbar);
43738 if (config.toolbar.items) {
43739 ti = config.toolbar.items ;
43740 delete config.toolbar.items ;
43744 this.toolbar.render(tool_el);
43745 for(var i =0;i < ti.length;i++) {
43746 // Roo.log(['add child', items[i]]);
43747 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
43749 this.toolbar.items = nitems;
43751 delete config.toolbar;
43754 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
43755 config.grid.scrollBody = true;;
43756 config.grid.monitorWindowResize = false; // turn off autosizing
43757 config.grid.autoHeight = false;
43758 config.grid.autoWidth = false;
43760 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
43762 if (config.background) {
43763 // render grid on panel activation (if panel background)
43764 this.on('activate', function(gp) {
43765 if (!gp.grid.rendered) {
43766 gp.grid.render(this.wrapper);
43767 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
43772 this.grid.render(this.wrapper);
43773 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
43776 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
43777 // ??? needed ??? config.el = this.wrapper;
43782 // xtype created footer. - not sure if will work as we normally have to render first..
43783 if (this.footer && !this.footer.el && this.footer.xtype) {
43785 var ctr = this.grid.getView().getFooterPanel(true);
43786 this.footer.dataSource = this.grid.dataSource;
43787 this.footer = Roo.factory(this.footer, Roo);
43788 this.footer.render(ctr);
43798 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content,
43801 getId : function(){
43802 return this.grid.id;
43806 * Returns the grid for this panel
43807 * @return {Roo.bootstrap.Table}
43809 getGrid : function(){
43813 setSize : function(width, height)
43816 //if(!this.ignoreResize(width, height)){
43817 var grid = this.grid;
43818 var size = this.adjustForComponents(width, height);
43819 // tfoot is not a footer?
43822 var gridel = grid.getGridEl();
43823 gridel.setSize(size.width, size.height);
43825 var tbd = grid.getGridEl().select('tbody', true).first();
43826 var thd = grid.getGridEl().select('thead',true).first();
43827 var tbf= grid.getGridEl().select('tfoot', true).first();
43830 size.height -= tbf.getHeight();
43833 size.height -= thd.getHeight();
43836 tbd.setSize(size.width, size.height );
43837 // this is for the account management tab -seems to work there.
43838 var thd = grid.getGridEl().select('thead',true).first();
43840 // tbd.setSize(size.width, size.height - thd.getHeight());
43850 beforeSlide : function(){
43851 this.grid.getView().scroller.clip();
43854 afterSlide : function(){
43855 this.grid.getView().scroller.unclip();
43858 destroy : function(){
43859 this.grid.destroy();
43861 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
43866 * @class Roo.bootstrap.panel.Nest
43867 * @extends Roo.bootstrap.panel.Content
43869 * Create a new Panel, that can contain a layout.Border.
43872 * @param {String/Object} config A string to set only the title or a config object
43874 Roo.bootstrap.panel.Nest = function(config)
43876 // construct with only one argument..
43877 /* FIXME - implement nicer consturctors
43878 if (layout.layout) {
43880 layout = config.layout;
43881 delete config.layout;
43883 if (layout.xtype && !layout.getEl) {
43884 // then layout needs constructing..
43885 layout = Roo.factory(layout, Roo);
43889 config.el = config.layout.getEl();
43891 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
43893 config.layout.monitorWindowResize = false; // turn off autosizing
43894 this.layout = config.layout;
43895 this.layout.getEl().addClass("roo-layout-nested-layout");
43896 this.layout.parent = this;
43903 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
43905 * @cfg {Roo.BorderLayout} layout The layout for this panel
43909 setSize : function(width, height){
43910 if(!this.ignoreResize(width, height)){
43911 var size = this.adjustForComponents(width, height);
43912 var el = this.layout.getEl();
43913 if (size.height < 1) {
43914 el.setWidth(size.width);
43916 el.setSize(size.width, size.height);
43918 var touch = el.dom.offsetWidth;
43919 this.layout.layout();
43920 // ie requires a double layout on the first pass
43921 if(Roo.isIE && !this.initialized){
43922 this.initialized = true;
43923 this.layout.layout();
43928 // activate all subpanels if not currently active..
43930 setActiveState : function(active){
43931 this.active = active;
43932 this.setActiveClass(active);
43935 this.fireEvent("deactivate", this);
43939 this.fireEvent("activate", this);
43940 // not sure if this should happen before or after..
43941 if (!this.layout) {
43942 return; // should not happen..
43945 for (var r in this.layout.regions) {
43946 reg = this.layout.getRegion(r);
43947 if (reg.getActivePanel()) {
43948 //reg.showPanel(reg.getActivePanel()); // force it to activate..
43949 reg.setActivePanel(reg.getActivePanel());
43952 if (!reg.panels.length) {
43955 reg.showPanel(reg.getPanel(0));
43964 * Returns the nested BorderLayout for this panel
43965 * @return {Roo.BorderLayout}
43967 getLayout : function(){
43968 return this.layout;
43972 * Adds a xtype elements to the layout of the nested panel
43976 xtype : 'ContentPanel',
43983 xtype : 'NestedLayoutPanel',
43989 items : [ ... list of content panels or nested layout panels.. ]
43993 * @param {Object} cfg Xtype definition of item to add.
43995 addxtype : function(cfg) {
43996 return this.layout.addxtype(cfg);
44001 * Ext JS Library 1.1.1
44002 * Copyright(c) 2006-2007, Ext JS, LLC.
44004 * Originally Released Under LGPL - original licence link has changed is not relivant.
44007 * <script type="text/javascript">
44010 * @class Roo.TabPanel
44011 * @extends Roo.util.Observable
44012 * A lightweight tab container.
44016 // basic tabs 1, built from existing content
44017 var tabs = new Roo.TabPanel("tabs1");
44018 tabs.addTab("script", "View Script");
44019 tabs.addTab("markup", "View Markup");
44020 tabs.activate("script");
44022 // more advanced tabs, built from javascript
44023 var jtabs = new Roo.TabPanel("jtabs");
44024 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
44026 // set up the UpdateManager
44027 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
44028 var updater = tab2.getUpdateManager();
44029 updater.setDefaultUrl("ajax1.htm");
44030 tab2.on('activate', updater.refresh, updater, true);
44032 // Use setUrl for Ajax loading
44033 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
44034 tab3.setUrl("ajax2.htm", null, true);
44037 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
44040 jtabs.activate("jtabs-1");
44043 * Create a new TabPanel.
44044 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
44045 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
44047 Roo.bootstrap.panel.Tabs = function(config){
44049 * The container element for this TabPanel.
44050 * @type Roo.Element
44052 this.el = Roo.get(config.el);
44055 if(typeof config == "boolean"){
44056 this.tabPosition = config ? "bottom" : "top";
44058 Roo.apply(this, config);
44062 if(this.tabPosition == "bottom"){
44063 // if tabs are at the bottom = create the body first.
44064 this.bodyEl = Roo.get(this.createBody(this.el.dom));
44065 this.el.addClass("roo-tabs-bottom");
44067 // next create the tabs holders
44069 if (this.tabPosition == "west"){
44071 var reg = this.region; // fake it..
44073 if (!reg.mgr.parent) {
44076 reg = reg.mgr.parent.region;
44078 Roo.log("got nest?");
44080 if (reg.mgr.getRegion('west')) {
44081 var ctrdom = reg.mgr.getRegion('west').bodyEl.dom;
44082 this.stripWrap = Roo.get(this.createStrip(ctrdom ), true);
44083 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
44084 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
44085 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
44093 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
44094 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
44095 this.stripEl.setVisibilityMode(Roo.Element.DISPLAY);
44096 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
44101 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
44104 // finally - if tabs are at the top, then create the body last..
44105 if(this.tabPosition != "bottom"){
44106 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
44107 * @type Roo.Element
44109 this.bodyEl = Roo.get(this.createBody(this.el.dom));
44110 this.el.addClass("roo-tabs-top");
44114 this.bodyEl.setStyle("position", "relative");
44116 this.active = null;
44117 this.activateDelegate = this.activate.createDelegate(this);
44122 * Fires when the active tab changes
44123 * @param {Roo.TabPanel} this
44124 * @param {Roo.TabPanelItem} activePanel The new active tab
44128 * @event beforetabchange
44129 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
44130 * @param {Roo.TabPanel} this
44131 * @param {Object} e Set cancel to true on this object to cancel the tab change
44132 * @param {Roo.TabPanelItem} tab The tab being changed to
44134 "beforetabchange" : true
44137 Roo.EventManager.onWindowResize(this.onResize, this);
44138 this.cpad = this.el.getPadding("lr");
44139 this.hiddenCount = 0;
44142 // toolbar on the tabbar support...
44143 if (this.toolbar) {
44144 alert("no toolbar support yet");
44145 this.toolbar = false;
44147 var tcfg = this.toolbar;
44148 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
44149 this.toolbar = new Roo.Toolbar(tcfg);
44150 if (Roo.isSafari) {
44151 var tbl = tcfg.container.child('table', true);
44152 tbl.setAttribute('width', '100%');
44160 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
44163 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
44165 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
44167 tabPosition : "top",
44169 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
44171 currentTabWidth : 0,
44173 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
44177 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
44181 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
44183 preferredTabWidth : 175,
44185 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
44187 resizeTabs : false,
44189 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
44191 monitorResize : true,
44193 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
44195 toolbar : false, // set by caller..
44197 region : false, /// set by caller
44199 disableTooltips : true, // not used yet...
44202 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
44203 * @param {String} id The id of the div to use <b>or create</b>
44204 * @param {String} text The text for the tab
44205 * @param {String} content (optional) Content to put in the TabPanelItem body
44206 * @param {Boolean} closable (optional) True to create a close icon on the tab
44207 * @return {Roo.TabPanelItem} The created TabPanelItem
44209 addTab : function(id, text, content, closable, tpl)
44211 var item = new Roo.bootstrap.panel.TabItem({
44215 closable : closable,
44218 this.addTabItem(item);
44220 item.setContent(content);
44226 * Returns the {@link Roo.TabPanelItem} with the specified id/index
44227 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
44228 * @return {Roo.TabPanelItem}
44230 getTab : function(id){
44231 return this.items[id];
44235 * Hides the {@link Roo.TabPanelItem} with the specified id/index
44236 * @param {String/Number} id The id or index of the TabPanelItem to hide.
44238 hideTab : function(id){
44239 var t = this.items[id];
44242 this.hiddenCount++;
44243 this.autoSizeTabs();
44248 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
44249 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
44251 unhideTab : function(id){
44252 var t = this.items[id];
44254 t.setHidden(false);
44255 this.hiddenCount--;
44256 this.autoSizeTabs();
44261 * Adds an existing {@link Roo.TabPanelItem}.
44262 * @param {Roo.TabPanelItem} item The TabPanelItem to add
44264 addTabItem : function(item)
44266 this.items[item.id] = item;
44267 this.items.push(item);
44268 this.autoSizeTabs();
44269 // if(this.resizeTabs){
44270 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
44271 // this.autoSizeTabs();
44273 // item.autoSize();
44278 * Removes a {@link Roo.TabPanelItem}.
44279 * @param {String/Number} id The id or index of the TabPanelItem to remove.
44281 removeTab : function(id){
44282 var items = this.items;
44283 var tab = items[id];
44284 if(!tab) { return; }
44285 var index = items.indexOf(tab);
44286 if(this.active == tab && items.length > 1){
44287 var newTab = this.getNextAvailable(index);
44292 this.stripEl.dom.removeChild(tab.pnode.dom);
44293 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
44294 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
44296 items.splice(index, 1);
44297 delete this.items[tab.id];
44298 tab.fireEvent("close", tab);
44299 tab.purgeListeners();
44300 this.autoSizeTabs();
44303 getNextAvailable : function(start){
44304 var items = this.items;
44306 // look for a next tab that will slide over to
44307 // replace the one being removed
44308 while(index < items.length){
44309 var item = items[++index];
44310 if(item && !item.isHidden()){
44314 // if one isn't found select the previous tab (on the left)
44317 var item = items[--index];
44318 if(item && !item.isHidden()){
44326 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
44327 * @param {String/Number} id The id or index of the TabPanelItem to disable.
44329 disableTab : function(id){
44330 var tab = this.items[id];
44331 if(tab && this.active != tab){
44337 * Enables a {@link Roo.TabPanelItem} that is disabled.
44338 * @param {String/Number} id The id or index of the TabPanelItem to enable.
44340 enableTab : function(id){
44341 var tab = this.items[id];
44346 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
44347 * @param {String/Number} id The id or index of the TabPanelItem to activate.
44348 * @return {Roo.TabPanelItem} The TabPanelItem.
44350 activate : function(id)
44352 //Roo.log('activite:' + id);
44354 var tab = this.items[id];
44358 if(tab == this.active || tab.disabled){
44362 this.fireEvent("beforetabchange", this, e, tab);
44363 if(e.cancel !== true && !tab.disabled){
44365 this.active.hide();
44367 this.active = this.items[id];
44368 this.active.show();
44369 this.fireEvent("tabchange", this, this.active);
44375 * Gets the active {@link Roo.TabPanelItem}.
44376 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
44378 getActiveTab : function(){
44379 return this.active;
44383 * Updates the tab body element to fit the height of the container element
44384 * for overflow scrolling
44385 * @param {Number} targetHeight (optional) Override the starting height from the elements height
44387 syncHeight : function(targetHeight){
44388 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
44389 var bm = this.bodyEl.getMargins();
44390 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
44391 this.bodyEl.setHeight(newHeight);
44395 onResize : function(){
44396 if(this.monitorResize){
44397 this.autoSizeTabs();
44402 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
44404 beginUpdate : function(){
44405 this.updating = true;
44409 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
44411 endUpdate : function(){
44412 this.updating = false;
44413 this.autoSizeTabs();
44417 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
44419 autoSizeTabs : function()
44421 var count = this.items.length;
44422 var vcount = count - this.hiddenCount;
44425 this.stripEl.hide();
44427 this.stripEl.show();
44430 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
44435 var w = Math.max(this.el.getWidth() - this.cpad, 10);
44436 var availWidth = Math.floor(w / vcount);
44437 var b = this.stripBody;
44438 if(b.getWidth() > w){
44439 var tabs = this.items;
44440 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
44441 if(availWidth < this.minTabWidth){
44442 /*if(!this.sleft){ // incomplete scrolling code
44443 this.createScrollButtons();
44446 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
44449 if(this.currentTabWidth < this.preferredTabWidth){
44450 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
44456 * Returns the number of tabs in this TabPanel.
44459 getCount : function(){
44460 return this.items.length;
44464 * Resizes all the tabs to the passed width
44465 * @param {Number} The new width
44467 setTabWidth : function(width){
44468 this.currentTabWidth = width;
44469 for(var i = 0, len = this.items.length; i < len; i++) {
44470 if(!this.items[i].isHidden()) {
44471 this.items[i].setWidth(width);
44477 * Destroys this TabPanel
44478 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
44480 destroy : function(removeEl){
44481 Roo.EventManager.removeResizeListener(this.onResize, this);
44482 for(var i = 0, len = this.items.length; i < len; i++){
44483 this.items[i].purgeListeners();
44485 if(removeEl === true){
44486 this.el.update("");
44491 createStrip : function(container)
44493 var strip = document.createElement("nav");
44494 strip.className = Roo.bootstrap.version == 4 ?
44495 "navbar-light bg-light" :
44496 "navbar navbar-default"; //"x-tabs-wrap";
44497 container.appendChild(strip);
44501 createStripList : function(strip)
44503 // div wrapper for retard IE
44504 // returns the "tr" element.
44505 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
44506 //'<div class="x-tabs-strip-wrap">'+
44507 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
44508 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
44509 return strip.firstChild; //.firstChild.firstChild.firstChild;
44511 createBody : function(container)
44513 var body = document.createElement("div");
44514 Roo.id(body, "tab-body");
44515 //Roo.fly(body).addClass("x-tabs-body");
44516 Roo.fly(body).addClass("tab-content");
44517 container.appendChild(body);
44520 createItemBody :function(bodyEl, id){
44521 var body = Roo.getDom(id);
44523 body = document.createElement("div");
44526 //Roo.fly(body).addClass("x-tabs-item-body");
44527 Roo.fly(body).addClass("tab-pane");
44528 bodyEl.insertBefore(body, bodyEl.firstChild);
44532 createStripElements : function(stripEl, text, closable, tpl)
44534 var td = document.createElement("li"); // was td..
44535 td.className = 'nav-item';
44537 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
44540 stripEl.appendChild(td);
44542 td.className = "x-tabs-closable";
44543 if(!this.closeTpl){
44544 this.closeTpl = new Roo.Template(
44545 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
44546 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
44547 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
44550 var el = this.closeTpl.overwrite(td, {"text": text});
44551 var close = el.getElementsByTagName("div")[0];
44552 var inner = el.getElementsByTagName("em")[0];
44553 return {"el": el, "close": close, "inner": inner};
44556 // not sure what this is..
44557 // if(!this.tabTpl){
44558 //this.tabTpl = new Roo.Template(
44559 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
44560 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
44562 // this.tabTpl = new Roo.Template(
44563 // '<a href="#">' +
44564 // '<span unselectable="on"' +
44565 // (this.disableTooltips ? '' : ' title="{text}"') +
44566 // ' >{text}</span></a>'
44572 var template = tpl || this.tabTpl || false;
44575 template = new Roo.Template(
44576 Roo.bootstrap.version == 4 ?
44578 '<a class="nav-link" href="#" unselectable="on"' +
44579 (this.disableTooltips ? '' : ' title="{text}"') +
44582 '<a class="nav-link" href="#">' +
44583 '<span unselectable="on"' +
44584 (this.disableTooltips ? '' : ' title="{text}"') +
44585 ' >{text}</span></a>'
44590 switch (typeof(template)) {
44594 template = new Roo.Template(template);
44600 var el = template.overwrite(td, {"text": text});
44602 var inner = el.getElementsByTagName("span")[0];
44604 return {"el": el, "inner": inner};
44612 * @class Roo.TabPanelItem
44613 * @extends Roo.util.Observable
44614 * Represents an individual item (tab plus body) in a TabPanel.
44615 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
44616 * @param {String} id The id of this TabPanelItem
44617 * @param {String} text The text for the tab of this TabPanelItem
44618 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
44620 Roo.bootstrap.panel.TabItem = function(config){
44622 * The {@link Roo.TabPanel} this TabPanelItem belongs to
44623 * @type Roo.TabPanel
44625 this.tabPanel = config.panel;
44627 * The id for this TabPanelItem
44630 this.id = config.id;
44632 this.disabled = false;
44634 this.text = config.text;
44636 this.loaded = false;
44637 this.closable = config.closable;
44640 * The body element for this TabPanelItem.
44641 * @type Roo.Element
44643 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
44644 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
44645 this.bodyEl.setStyle("display", "block");
44646 this.bodyEl.setStyle("zoom", "1");
44647 //this.hideAction();
44649 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
44651 this.el = Roo.get(els.el);
44652 this.inner = Roo.get(els.inner, true);
44653 this.textEl = Roo.bootstrap.version == 4 ?
44654 this.el : Roo.get(this.el.dom.firstChild, true);
44656 this.pnode = this.linode = Roo.get(els.el.parentNode, true);
44657 this.status_node = Roo.bootstrap.version == 4 ? this.el : this.linode;
44660 // this.el.on("mousedown", this.onTabMouseDown, this);
44661 this.el.on("click", this.onTabClick, this);
44663 if(config.closable){
44664 var c = Roo.get(els.close, true);
44665 c.dom.title = this.closeText;
44666 c.addClassOnOver("close-over");
44667 c.on("click", this.closeClick, this);
44673 * Fires when this tab becomes the active tab.
44674 * @param {Roo.TabPanel} tabPanel The parent TabPanel
44675 * @param {Roo.TabPanelItem} this
44679 * @event beforeclose
44680 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
44681 * @param {Roo.TabPanelItem} this
44682 * @param {Object} e Set cancel to true on this object to cancel the close.
44684 "beforeclose": true,
44687 * Fires when this tab is closed.
44688 * @param {Roo.TabPanelItem} this
44692 * @event deactivate
44693 * Fires when this tab is no longer the active tab.
44694 * @param {Roo.TabPanel} tabPanel The parent TabPanel
44695 * @param {Roo.TabPanelItem} this
44697 "deactivate" : true
44699 this.hidden = false;
44701 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
44704 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
44706 purgeListeners : function(){
44707 Roo.util.Observable.prototype.purgeListeners.call(this);
44708 this.el.removeAllListeners();
44711 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
44714 this.status_node.addClass("active");
44717 this.tabPanel.stripWrap.repaint();
44719 this.fireEvent("activate", this.tabPanel, this);
44723 * Returns true if this tab is the active tab.
44724 * @return {Boolean}
44726 isActive : function(){
44727 return this.tabPanel.getActiveTab() == this;
44731 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
44734 this.status_node.removeClass("active");
44736 this.fireEvent("deactivate", this.tabPanel, this);
44739 hideAction : function(){
44740 this.bodyEl.hide();
44741 this.bodyEl.setStyle("position", "absolute");
44742 this.bodyEl.setLeft("-20000px");
44743 this.bodyEl.setTop("-20000px");
44746 showAction : function(){
44747 this.bodyEl.setStyle("position", "relative");
44748 this.bodyEl.setTop("");
44749 this.bodyEl.setLeft("");
44750 this.bodyEl.show();
44754 * Set the tooltip for the tab.
44755 * @param {String} tooltip The tab's tooltip
44757 setTooltip : function(text){
44758 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
44759 this.textEl.dom.qtip = text;
44760 this.textEl.dom.removeAttribute('title');
44762 this.textEl.dom.title = text;
44766 onTabClick : function(e){
44767 e.preventDefault();
44768 this.tabPanel.activate(this.id);
44771 onTabMouseDown : function(e){
44772 e.preventDefault();
44773 this.tabPanel.activate(this.id);
44776 getWidth : function(){
44777 return this.inner.getWidth();
44780 setWidth : function(width){
44781 var iwidth = width - this.linode.getPadding("lr");
44782 this.inner.setWidth(iwidth);
44783 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
44784 this.linode.setWidth(width);
44788 * Show or hide the tab
44789 * @param {Boolean} hidden True to hide or false to show.
44791 setHidden : function(hidden){
44792 this.hidden = hidden;
44793 this.linode.setStyle("display", hidden ? "none" : "");
44797 * Returns true if this tab is "hidden"
44798 * @return {Boolean}
44800 isHidden : function(){
44801 return this.hidden;
44805 * Returns the text for this tab
44808 getText : function(){
44812 autoSize : function(){
44813 //this.el.beginMeasure();
44814 this.textEl.setWidth(1);
44816 * #2804 [new] Tabs in Roojs
44817 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
44819 //this.setWidth(this.textEl.dom.scrollWidth+this.linode.getPadding("lr")+this.inner.getPadding("lr") + 2);
44820 //this.el.endMeasure();
44824 * Sets the text for the tab (Note: this also sets the tooltip text)
44825 * @param {String} text The tab's text and tooltip
44827 setText : function(text){
44829 this.textEl.update(text);
44830 this.setTooltip(text);
44831 //if(!this.tabPanel.resizeTabs){
44832 // this.autoSize();
44836 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
44838 activate : function(){
44839 this.tabPanel.activate(this.id);
44843 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
44845 disable : function(){
44846 if(this.tabPanel.active != this){
44847 this.disabled = true;
44848 this.status_node.addClass("disabled");
44853 * Enables this TabPanelItem if it was previously disabled.
44855 enable : function(){
44856 this.disabled = false;
44857 this.status_node.removeClass("disabled");
44861 * Sets the content for this TabPanelItem.
44862 * @param {String} content The content
44863 * @param {Boolean} loadScripts true to look for and load scripts
44865 setContent : function(content, loadScripts){
44866 this.bodyEl.update(content, loadScripts);
44870 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
44871 * @return {Roo.UpdateManager} The UpdateManager
44873 getUpdateManager : function(){
44874 return this.bodyEl.getUpdateManager();
44878 * Set a URL to be used to load the content for this TabPanelItem.
44879 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
44880 * @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)
44881 * @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)
44882 * @return {Roo.UpdateManager} The UpdateManager
44884 setUrl : function(url, params, loadOnce){
44885 if(this.refreshDelegate){
44886 this.un('activate', this.refreshDelegate);
44888 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
44889 this.on("activate", this.refreshDelegate);
44890 return this.bodyEl.getUpdateManager();
44894 _handleRefresh : function(url, params, loadOnce){
44895 if(!loadOnce || !this.loaded){
44896 var updater = this.bodyEl.getUpdateManager();
44897 updater.update(url, params, this._setLoaded.createDelegate(this));
44902 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
44903 * Will fail silently if the setUrl method has not been called.
44904 * This does not activate the panel, just updates its content.
44906 refresh : function(){
44907 if(this.refreshDelegate){
44908 this.loaded = false;
44909 this.refreshDelegate();
44914 _setLoaded : function(){
44915 this.loaded = true;
44919 closeClick : function(e){
44922 this.fireEvent("beforeclose", this, o);
44923 if(o.cancel !== true){
44924 this.tabPanel.removeTab(this.id);
44928 * The text displayed in the tooltip for the close icon.
44931 closeText : "Close this tab"
44934 * This script refer to:
44935 * Title: International Telephone Input
44936 * Author: Jack O'Connor
44937 * Code version: v12.1.12
44938 * Availability: https://github.com/jackocnr/intl-tel-input.git
44941 Roo.bootstrap.form.PhoneInputData = function() {
44944 "Afghanistan (افغانستان)",
44949 "Albania (Shqipëri)",
44954 "Algeria (الجزائر)",
44979 "Antigua and Barbuda",
44989 "Armenia (Հայաստան)",
45005 "Austria (Österreich)",
45010 "Azerbaijan (Azərbaycan)",
45020 "Bahrain (البحرين)",
45025 "Bangladesh (বাংলাদেশ)",
45035 "Belarus (Беларусь)",
45040 "Belgium (België)",
45070 "Bosnia and Herzegovina (Босна и Херцеговина)",
45085 "British Indian Ocean Territory",
45090 "British Virgin Islands",
45100 "Bulgaria (България)",
45110 "Burundi (Uburundi)",
45115 "Cambodia (កម្ពុជា)",
45120 "Cameroon (Cameroun)",
45129 ["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"]
45132 "Cape Verde (Kabu Verdi)",
45137 "Caribbean Netherlands",
45148 "Central African Republic (République centrafricaine)",
45168 "Christmas Island",
45174 "Cocos (Keeling) Islands",
45185 "Comoros (جزر القمر)",
45190 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
45195 "Congo (Republic) (Congo-Brazzaville)",
45215 "Croatia (Hrvatska)",
45236 "Czech Republic (Česká republika)",
45241 "Denmark (Danmark)",
45256 "Dominican Republic (República Dominicana)",
45260 ["809", "829", "849"]
45278 "Equatorial Guinea (Guinea Ecuatorial)",
45298 "Falkland Islands (Islas Malvinas)",
45303 "Faroe Islands (Føroyar)",
45324 "French Guiana (Guyane française)",
45329 "French Polynesia (Polynésie française)",
45344 "Georgia (საქართველო)",
45349 "Germany (Deutschland)",
45369 "Greenland (Kalaallit Nunaat)",
45406 "Guinea-Bissau (Guiné Bissau)",
45431 "Hungary (Magyarország)",
45436 "Iceland (Ísland)",
45456 "Iraq (العراق)",
45472 "Israel (ישראל)",
45499 "Jordan (الأردن)",
45504 "Kazakhstan (Казахстан)",
45525 "Kuwait (الكويت)",
45530 "Kyrgyzstan (Кыргызстан)",
45540 "Latvia (Latvija)",
45545 "Lebanon (لبنان)",
45560 "Libya (ليبيا)",
45570 "Lithuania (Lietuva)",
45585 "Macedonia (FYROM) (Македонија)",
45590 "Madagascar (Madagasikara)",
45620 "Marshall Islands",
45630 "Mauritania (موريتانيا)",
45635 "Mauritius (Moris)",
45656 "Moldova (Republica Moldova)",
45666 "Mongolia (Монгол)",
45671 "Montenegro (Crna Gora)",
45681 "Morocco (المغرب)",
45687 "Mozambique (Moçambique)",
45692 "Myanmar (Burma) (မြန်မာ)",
45697 "Namibia (Namibië)",
45712 "Netherlands (Nederland)",
45717 "New Caledonia (Nouvelle-Calédonie)",
45752 "North Korea (조선 민주주의 인민 공화국)",
45757 "Northern Mariana Islands",
45773 "Pakistan (پاکستان)",
45783 "Palestine (فلسطين)",
45793 "Papua New Guinea",
45835 "Réunion (La Réunion)",
45841 "Romania (România)",
45857 "Saint Barthélemy",
45868 "Saint Kitts and Nevis",
45878 "Saint Martin (Saint-Martin (partie française))",
45884 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
45889 "Saint Vincent and the Grenadines",
45904 "São Tomé and Príncipe (São Tomé e Príncipe)",
45909 "Saudi Arabia (المملكة العربية السعودية)",
45914 "Senegal (Sénégal)",
45944 "Slovakia (Slovensko)",
45949 "Slovenia (Slovenija)",
45959 "Somalia (Soomaaliya)",
45969 "South Korea (대한민국)",
45974 "South Sudan (جنوب السودان)",
45984 "Sri Lanka (ශ්රී ලංකාව)",
45989 "Sudan (السودان)",
45999 "Svalbard and Jan Mayen",
46010 "Sweden (Sverige)",
46015 "Switzerland (Schweiz)",
46020 "Syria (سوريا)",
46065 "Trinidad and Tobago",
46070 "Tunisia (تونس)",
46075 "Turkey (Türkiye)",
46085 "Turks and Caicos Islands",
46095 "U.S. Virgin Islands",
46105 "Ukraine (Україна)",
46110 "United Arab Emirates (الإمارات العربية المتحدة)",
46132 "Uzbekistan (Oʻzbekiston)",
46142 "Vatican City (Città del Vaticano)",
46153 "Vietnam (Việt Nam)",
46158 "Wallis and Futuna (Wallis-et-Futuna)",
46163 "Western Sahara (الصحراء الغربية)",
46169 "Yemen (اليمن)",
46193 * This script refer to:
46194 * Title: International Telephone Input
46195 * Author: Jack O'Connor
46196 * Code version: v12.1.12
46197 * Availability: https://github.com/jackocnr/intl-tel-input.git
46201 * @class Roo.bootstrap.form.PhoneInput
46202 * @extends Roo.bootstrap.form.TriggerField
46203 * An input with International dial-code selection
46205 * @cfg {String} defaultDialCode default '+852'
46206 * @cfg {Array} preferedCountries default []
46209 * Create a new PhoneInput.
46210 * @param {Object} config Configuration options
46213 Roo.bootstrap.form.PhoneInput = function(config) {
46214 Roo.bootstrap.form.PhoneInput.superclass.constructor.call(this, config);
46217 Roo.extend(Roo.bootstrap.form.PhoneInput, Roo.bootstrap.form.TriggerField, {
46219 * @cfg {Roo.data.Store} store [required] The data store to which this combo is bound (defaults to undefined)
46221 listWidth: undefined,
46223 selectedClass: 'active',
46225 invalidClass : "has-warning",
46227 validClass: 'has-success',
46229 allowed: '0123456789',
46234 * @cfg {String} defaultDialCode The default dial code when initializing the input
46236 defaultDialCode: '+852',
46239 * @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
46241 preferedCountries: false,
46243 getAutoCreate : function()
46245 var data = Roo.bootstrap.form.PhoneInputData();
46246 var align = this.labelAlign || this.parentLabelAlign();
46249 this.allCountries = [];
46250 this.dialCodeMapping = [];
46252 for (var i = 0; i < data.length; i++) {
46254 this.allCountries[i] = {
46258 priority: c[3] || 0,
46259 areaCodes: c[4] || null
46261 this.dialCodeMapping[c[2]] = {
46264 priority: c[3] || 0,
46265 areaCodes: c[4] || null
46277 // type: 'number', -- do not use number - we get the flaky up/down arrows.
46278 maxlength: this.max_length,
46279 cls : 'form-control tel-input',
46280 autocomplete: 'new-password'
46283 var hiddenInput = {
46286 cls: 'hidden-tel-input'
46290 hiddenInput.name = this.name;
46293 if (this.disabled) {
46294 input.disabled = true;
46297 var flag_container = {
46314 cls: this.hasFeedback ? 'has-feedback' : '',
46320 cls: 'dial-code-holder',
46327 cls: 'roo-select2-container input-group',
46334 if (this.fieldLabel.length) {
46337 tooltip: 'This field is required'
46343 cls: 'control-label',
46349 html: this.fieldLabel
46352 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
46358 if(this.indicatorpos == 'right') {
46359 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
46366 if(align == 'left') {
46374 if(this.labelWidth > 12){
46375 label.style = "width: " + this.labelWidth + 'px';
46377 if(this.labelWidth < 13 && this.labelmd == 0){
46378 this.labelmd = this.labelWidth;
46380 if(this.labellg > 0){
46381 label.cls += ' col-lg-' + this.labellg;
46382 input.cls += ' col-lg-' + (12 - this.labellg);
46384 if(this.labelmd > 0){
46385 label.cls += ' col-md-' + this.labelmd;
46386 container.cls += ' col-md-' + (12 - this.labelmd);
46388 if(this.labelsm > 0){
46389 label.cls += ' col-sm-' + this.labelsm;
46390 container.cls += ' col-sm-' + (12 - this.labelsm);
46392 if(this.labelxs > 0){
46393 label.cls += ' col-xs-' + this.labelxs;
46394 container.cls += ' col-xs-' + (12 - this.labelxs);
46404 var settings = this;
46406 ['xs','sm','md','lg'].map(function(size){
46407 if (settings[size]) {
46408 cfg.cls += ' col-' + size + '-' + settings[size];
46412 this.store = new Roo.data.Store({
46413 proxy : new Roo.data.MemoryProxy({}),
46414 reader : new Roo.data.JsonReader({
46425 'name' : 'dialCode',
46429 'name' : 'priority',
46433 'name' : 'areaCodes',
46440 if(!this.preferedCountries) {
46441 this.preferedCountries = [
46448 var p = this.preferedCountries.reverse();
46451 for (var i = 0; i < p.length; i++) {
46452 for (var j = 0; j < this.allCountries.length; j++) {
46453 if(this.allCountries[j].iso2 == p[i]) {
46454 var t = this.allCountries[j];
46455 this.allCountries.splice(j,1);
46456 this.allCountries.unshift(t);
46462 this.store.proxy.data = {
46464 data: this.allCountries
46470 initEvents : function()
46473 Roo.bootstrap.form.PhoneInput.superclass.initEvents.call(this);
46475 this.indicator = this.indicatorEl();
46476 this.flag = this.flagEl();
46477 this.dialCodeHolder = this.dialCodeHolderEl();
46479 this.trigger = this.el.select('div.flag-box',true).first();
46480 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
46485 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
46486 _this.list.setWidth(lw);
46489 this.list.on('mouseover', this.onViewOver, this);
46490 this.list.on('mousemove', this.onViewMove, this);
46491 this.inputEl().on("keyup", this.onKeyUp, this);
46492 this.inputEl().on("keypress", this.onKeyPress, this);
46494 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
46496 this.view = new Roo.View(this.list, this.tpl, {
46497 singleSelect:true, store: this.store, selectedClass: this.selectedClass
46500 this.view.on('click', this.onViewClick, this);
46501 this.setValue(this.defaultDialCode);
46504 onTriggerClick : function(e)
46506 Roo.log('trigger click');
46511 if(this.isExpanded()){
46513 this.hasFocus = false;
46515 this.store.load({});
46516 this.hasFocus = true;
46521 isExpanded : function()
46523 return this.list.isVisible();
46526 collapse : function()
46528 if(!this.isExpanded()){
46532 Roo.get(document).un('mousedown', this.collapseIf, this);
46533 Roo.get(document).un('mousewheel', this.collapseIf, this);
46534 this.fireEvent('collapse', this);
46538 expand : function()
46542 if(this.isExpanded() || !this.hasFocus){
46546 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
46547 this.list.setWidth(lw);
46550 this.restrictHeight();
46552 Roo.get(document).on('mousedown', this.collapseIf, this);
46553 Roo.get(document).on('mousewheel', this.collapseIf, this);
46555 this.fireEvent('expand', this);
46558 restrictHeight : function()
46560 this.list.alignTo(this.inputEl(), this.listAlign);
46561 this.list.alignTo(this.inputEl(), this.listAlign);
46564 onViewOver : function(e, t)
46566 if(this.inKeyMode){
46569 var item = this.view.findItemFromChild(t);
46572 var index = this.view.indexOf(item);
46573 this.select(index, false);
46578 onViewClick : function(view, doFocus, el, e)
46580 var index = this.view.getSelectedIndexes()[0];
46582 var r = this.store.getAt(index);
46585 this.onSelect(r, index);
46587 if(doFocus !== false && !this.blockFocus){
46588 this.inputEl().focus();
46592 onViewMove : function(e, t)
46594 this.inKeyMode = false;
46597 select : function(index, scrollIntoView)
46599 this.selectedIndex = index;
46600 this.view.select(index);
46601 if(scrollIntoView !== false){
46602 var el = this.view.getNode(index);
46604 this.list.scrollChildIntoView(el, false);
46609 createList : function()
46611 this.list = Roo.get(document.body).createChild({
46613 cls: 'typeahead typeahead-long dropdown-menu tel-list',
46614 style: 'display:none'
46617 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
46620 collapseIf : function(e)
46622 var in_combo = e.within(this.el);
46623 var in_list = e.within(this.list);
46624 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
46626 if (in_combo || in_list || is_list) {
46632 onSelect : function(record, index)
46634 if(this.fireEvent('beforeselect', this, record, index) !== false){
46636 this.setFlagClass(record.data.iso2);
46637 this.setDialCode(record.data.dialCode);
46638 this.hasFocus = false;
46640 this.fireEvent('select', this, record, index);
46644 flagEl : function()
46646 var flag = this.el.select('div.flag',true).first();
46653 dialCodeHolderEl : function()
46655 var d = this.el.select('input.dial-code-holder',true).first();
46662 setDialCode : function(v)
46664 this.dialCodeHolder.dom.value = '+'+v;
46667 setFlagClass : function(n)
46669 this.flag.dom.className = 'flag '+n;
46672 getValue : function()
46674 var v = this.inputEl().getValue();
46675 if(this.dialCodeHolder) {
46676 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
46681 setValue : function(v)
46683 var d = this.getDialCode(v);
46685 //invalid dial code
46686 if(v.length == 0 || !d || d.length == 0) {
46688 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
46689 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
46695 this.setFlagClass(this.dialCodeMapping[d].iso2);
46696 this.setDialCode(d);
46697 this.inputEl().dom.value = v.replace('+'+d,'');
46698 this.hiddenEl().dom.value = this.getValue();
46703 getDialCode : function(v)
46707 if (v.length == 0) {
46708 return this.dialCodeHolder.dom.value;
46712 if (v.charAt(0) != "+") {
46715 var numericChars = "";
46716 for (var i = 1; i < v.length; i++) {
46717 var c = v.charAt(i);
46720 if (this.dialCodeMapping[numericChars]) {
46721 dialCode = v.substr(1, i);
46723 if (numericChars.length == 4) {
46733 this.setValue(this.defaultDialCode);
46737 hiddenEl : function()
46739 return this.el.select('input.hidden-tel-input',true).first();
46742 // after setting val
46743 onKeyUp : function(e){
46744 this.setValue(this.getValue());
46747 onKeyPress : function(e){
46748 if(this.allowed.indexOf(String.fromCharCode(e.getCharCode())) === -1){
46755 * @class Roo.bootstrap.form.MoneyField
46756 * @extends Roo.bootstrap.form.ComboBox
46757 * Bootstrap MoneyField class
46760 * Create a new MoneyField.
46761 * @param {Object} config Configuration options
46764 Roo.bootstrap.form.MoneyField = function(config) {
46766 Roo.bootstrap.form.MoneyField.superclass.constructor.call(this, config);
46770 Roo.extend(Roo.bootstrap.form.MoneyField, Roo.bootstrap.form.ComboBox, {
46773 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
46775 allowDecimals : true,
46777 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
46779 decimalSeparator : ".",
46781 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
46783 decimalPrecision : 0,
46785 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
46787 allowNegative : true,
46789 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
46793 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
46795 minValue : Number.NEGATIVE_INFINITY,
46797 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
46799 maxValue : Number.MAX_VALUE,
46801 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
46803 minText : "The minimum value for this field is {0}",
46805 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
46807 maxText : "The maximum value for this field is {0}",
46809 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
46810 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
46812 nanText : "{0} is not a valid number",
46814 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
46818 * @cfg {String} defaults currency of the MoneyField
46819 * value should be in lkey
46821 defaultCurrency : false,
46823 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
46825 thousandsDelimiter : false,
46827 * @cfg {Number} max_length Maximum input field length allowed (defaults to Number.MAX_VALUE)
46836 * @cfg {Roo.data.Store} store Store to lookup currency??
46840 getAutoCreate : function()
46842 var align = this.labelAlign || this.parentLabelAlign();
46854 cls : 'form-control roo-money-amount-input',
46855 autocomplete: 'new-password'
46858 var hiddenInput = {
46862 cls: 'hidden-number-input'
46865 if(this.max_length) {
46866 input.maxlength = this.max_length;
46870 hiddenInput.name = this.name;
46873 if (this.disabled) {
46874 input.disabled = true;
46877 var clg = 12 - this.inputlg;
46878 var cmd = 12 - this.inputmd;
46879 var csm = 12 - this.inputsm;
46880 var cxs = 12 - this.inputxs;
46884 cls : 'row roo-money-field',
46888 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
46892 cls: 'roo-select2-container input-group',
46896 cls : 'form-control roo-money-currency-input',
46897 autocomplete: 'new-password',
46899 name : this.currencyName
46903 cls : 'input-group-addon',
46917 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
46921 cls: this.hasFeedback ? 'has-feedback' : '',
46932 if (this.fieldLabel.length) {
46935 tooltip: 'This field is required'
46941 cls: 'control-label',
46947 html: this.fieldLabel
46950 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
46956 if(this.indicatorpos == 'right') {
46957 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
46964 if(align == 'left') {
46972 if(this.labelWidth > 12){
46973 label.style = "width: " + this.labelWidth + 'px';
46975 if(this.labelWidth < 13 && this.labelmd == 0){
46976 this.labelmd = this.labelWidth;
46978 if(this.labellg > 0){
46979 label.cls += ' col-lg-' + this.labellg;
46980 input.cls += ' col-lg-' + (12 - this.labellg);
46982 if(this.labelmd > 0){
46983 label.cls += ' col-md-' + this.labelmd;
46984 container.cls += ' col-md-' + (12 - this.labelmd);
46986 if(this.labelsm > 0){
46987 label.cls += ' col-sm-' + this.labelsm;
46988 container.cls += ' col-sm-' + (12 - this.labelsm);
46990 if(this.labelxs > 0){
46991 label.cls += ' col-xs-' + this.labelxs;
46992 container.cls += ' col-xs-' + (12 - this.labelxs);
47003 var settings = this;
47005 ['xs','sm','md','lg'].map(function(size){
47006 if (settings[size]) {
47007 cfg.cls += ' col-' + size + '-' + settings[size];
47014 initEvents : function()
47016 this.indicator = this.indicatorEl();
47018 this.initCurrencyEvent();
47020 this.initNumberEvent();
47023 initCurrencyEvent : function()
47026 throw "can not find store for combo";
47029 this.store = Roo.factory(this.store, Roo.data);
47030 this.store.parent = this;
47034 this.triggerEl = this.el.select('.input-group-addon', true).first();
47036 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
47041 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
47042 _this.list.setWidth(lw);
47045 this.list.on('mouseover', this.onViewOver, this);
47046 this.list.on('mousemove', this.onViewMove, this);
47047 this.list.on('scroll', this.onViewScroll, this);
47050 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
47053 this.view = new Roo.View(this.list, this.tpl, {
47054 singleSelect:true, store: this.store, selectedClass: this.selectedClass
47057 this.view.on('click', this.onViewClick, this);
47059 this.store.on('beforeload', this.onBeforeLoad, this);
47060 this.store.on('load', this.onLoad, this);
47061 this.store.on('loadexception', this.onLoadException, this);
47063 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
47064 "up" : function(e){
47065 this.inKeyMode = true;
47069 "down" : function(e){
47070 if(!this.isExpanded()){
47071 this.onTriggerClick();
47073 this.inKeyMode = true;
47078 "enter" : function(e){
47081 if(this.fireEvent("specialkey", this, e)){
47082 this.onViewClick(false);
47088 "esc" : function(e){
47092 "tab" : function(e){
47095 if(this.fireEvent("specialkey", this, e)){
47096 this.onViewClick(false);
47104 doRelay : function(foo, bar, hname){
47105 if(hname == 'down' || this.scope.isExpanded()){
47106 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
47114 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
47118 initNumberEvent : function(e)
47120 this.inputEl().on("keydown" , this.fireKey, this);
47121 this.inputEl().on("focus", this.onFocus, this);
47122 this.inputEl().on("blur", this.onBlur, this);
47124 this.inputEl().relayEvent('keyup', this);
47126 if(this.indicator){
47127 this.indicator.addClass('invisible');
47130 this.originalValue = this.getValue();
47132 if(this.validationEvent == 'keyup'){
47133 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
47134 this.inputEl().on('keyup', this.filterValidation, this);
47136 else if(this.validationEvent !== false){
47137 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
47140 if(this.selectOnFocus){
47141 this.on("focus", this.preFocus, this);
47144 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
47145 this.inputEl().on("keypress", this.filterKeys, this);
47147 this.inputEl().relayEvent('keypress', this);
47150 var allowed = "0123456789";
47152 if(this.allowDecimals){
47153 allowed += this.decimalSeparator;
47156 if(this.allowNegative){
47160 if(this.thousandsDelimiter) {
47164 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
47166 var keyPress = function(e){
47168 var k = e.getKey();
47170 var c = e.getCharCode();
47173 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
47174 allowed.indexOf(String.fromCharCode(c)) === -1
47180 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
47184 if(allowed.indexOf(String.fromCharCode(c)) === -1){
47189 this.inputEl().on("keypress", keyPress, this);
47193 onTriggerClick : function(e)
47200 this.loadNext = false;
47202 if(this.isExpanded()){
47207 this.hasFocus = true;
47209 if(this.triggerAction == 'all') {
47210 this.doQuery(this.allQuery, true);
47214 this.doQuery(this.getRawValue());
47217 getCurrency : function()
47219 var v = this.currencyEl().getValue();
47224 restrictHeight : function()
47226 this.list.alignTo(this.currencyEl(), this.listAlign);
47227 this.list.alignTo(this.currencyEl(), this.listAlign);
47230 onViewClick : function(view, doFocus, el, e)
47232 var index = this.view.getSelectedIndexes()[0];
47234 var r = this.store.getAt(index);
47237 this.onSelect(r, index);
47241 onSelect : function(record, index){
47243 if(this.fireEvent('beforeselect', this, record, index) !== false){
47245 this.setFromCurrencyData(index > -1 ? record.data : false);
47249 this.fireEvent('select', this, record, index);
47253 setFromCurrencyData : function(o)
47257 this.lastCurrency = o;
47259 if (this.currencyField) {
47260 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
47262 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
47265 this.lastSelectionText = currency;
47267 //setting default currency
47268 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
47269 this.setCurrency(this.defaultCurrency);
47273 this.setCurrency(currency);
47276 setFromData : function(o)
47280 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
47282 this.setFromCurrencyData(c);
47287 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
47289 Roo.log('no value set for '+ (this.name ? this.name : this.id));
47292 this.setValue(value);
47296 setCurrency : function(v)
47298 this.currencyValue = v;
47301 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
47306 setValue : function(v)
47308 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
47314 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
47316 this.inputEl().dom.value = (v == '') ? '' :
47317 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
47319 if(!this.allowZero && v === '0') {
47320 this.hiddenEl().dom.value = '';
47321 this.inputEl().dom.value = '';
47328 getRawValue : function()
47330 var v = this.inputEl().getValue();
47335 getValue : function()
47337 return this.fixPrecision(this.parseValue(this.getRawValue()));
47340 parseValue : function(value)
47342 if(this.thousandsDelimiter) {
47344 r = new RegExp(",", "g");
47345 value = value.replace(r, "");
47348 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
47349 return isNaN(value) ? '' : value;
47353 fixPrecision : function(value)
47355 if(this.thousandsDelimiter) {
47357 r = new RegExp(",", "g");
47358 value = value.replace(r, "");
47361 var nan = isNaN(value);
47363 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
47364 return nan ? '' : value;
47366 return parseFloat(value).toFixed(this.decimalPrecision);
47369 decimalPrecisionFcn : function(v)
47371 return Math.floor(v);
47374 validateValue : function(value)
47376 if(!Roo.bootstrap.form.MoneyField.superclass.validateValue.call(this, value)){
47380 var num = this.parseValue(value);
47383 this.markInvalid(String.format(this.nanText, value));
47387 if(num < this.minValue){
47388 this.markInvalid(String.format(this.minText, this.minValue));
47392 if(num > this.maxValue){
47393 this.markInvalid(String.format(this.maxText, this.maxValue));
47400 validate : function()
47402 if(this.disabled || this.allowBlank){
47407 var currency = this.getCurrency();
47409 if(this.validateValue(this.getRawValue()) && currency.length){
47414 this.markInvalid();
47418 getName: function()
47423 beforeBlur : function()
47429 var v = this.parseValue(this.getRawValue());
47436 onBlur : function()
47440 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
47441 //this.el.removeClass(this.focusClass);
47444 this.hasFocus = false;
47446 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
47450 var v = this.getValue();
47452 if(String(v) !== String(this.startValue)){
47453 this.fireEvent('change', this, v, this.startValue);
47456 this.fireEvent("blur", this);
47459 inputEl : function()
47461 return this.el.select('.roo-money-amount-input', true).first();
47464 currencyEl : function()
47466 return this.el.select('.roo-money-currency-input', true).first();
47469 hiddenEl : function()
47471 return this.el.select('input.hidden-number-input',true).first();
47475 * @class Roo.bootstrap.BezierSignature
47476 * @extends Roo.bootstrap.Component
47477 * Bootstrap BezierSignature class
47478 * This script refer to:
47479 * Title: Signature Pad
47481 * Availability: https://github.com/szimek/signature_pad
47484 * Create a new BezierSignature
47485 * @param {Object} config The config object
47488 Roo.bootstrap.BezierSignature = function(config){
47489 Roo.bootstrap.BezierSignature.superclass.constructor.call(this, config);
47495 Roo.extend(Roo.bootstrap.BezierSignature, Roo.bootstrap.Component,
47502 mouse_btn_down: true,
47505 * @cfg {int} canvas height
47507 canvas_height: '200px',
47510 * @cfg {float|function} Radius of a single dot.
47515 * @cfg {float} Minimum width of a line. Defaults to 0.5.
47520 * @cfg {float} Maximum width of a line. Defaults to 2.5.
47525 * @cfg {integer} Draw the next point at most once per every x milliseconds. Set it to 0 to turn off throttling. Defaults to 16.
47530 * @cfg {integer} Add the next point only if the previous one is farther than x pixels. Defaults to 5.
47535 * @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.
47537 bg_color: 'rgba(0, 0, 0, 0)',
47540 * @cfg {string} Color used to draw the lines. Can be any color format accepted by context.fillStyle. Defaults to "black".
47542 dot_color: 'black',
47545 * @cfg {float} Weight used to modify new velocity based on the previous velocity. Defaults to 0.7.
47547 velocity_filter_weight: 0.7,
47550 * @cfg {function} Callback when stroke begin.
47555 * @cfg {function} Callback when stroke end.
47559 getAutoCreate : function()
47561 var cls = 'roo-signature column';
47564 cls += ' ' + this.cls;
47574 for(var i = 0; i < col_sizes.length; i++) {
47575 if(this[col_sizes[i]]) {
47576 cls += " col-"+col_sizes[i]+"-"+this[col_sizes[i]];
47586 cls: 'roo-signature-body',
47590 cls: 'roo-signature-body-canvas',
47591 height: this.canvas_height,
47592 width: this.canvas_width
47599 style: 'display: none'
47607 initEvents: function()
47609 Roo.bootstrap.BezierSignature.superclass.initEvents.call(this);
47611 var canvas = this.canvasEl();
47613 // mouse && touch event swapping...
47614 canvas.dom.style.touchAction = 'none';
47615 canvas.dom.style.msTouchAction = 'none';
47617 this.mouse_btn_down = false;
47618 canvas.on('mousedown', this._handleMouseDown, this);
47619 canvas.on('mousemove', this._handleMouseMove, this);
47620 Roo.select('html').first().on('mouseup', this._handleMouseUp, this);
47622 if (window.PointerEvent) {
47623 canvas.on('pointerdown', this._handleMouseDown, this);
47624 canvas.on('pointermove', this._handleMouseMove, this);
47625 Roo.select('html').first().on('pointerup', this._handleMouseUp, this);
47628 if ('ontouchstart' in window) {
47629 canvas.on('touchstart', this._handleTouchStart, this);
47630 canvas.on('touchmove', this._handleTouchMove, this);
47631 canvas.on('touchend', this._handleTouchEnd, this);
47634 Roo.EventManager.onWindowResize(this.resize, this, true);
47636 // file input event
47637 this.fileEl().on('change', this.uploadImage, this);
47644 resize: function(){
47646 var canvas = this.canvasEl().dom;
47647 var ctx = this.canvasElCtx();
47648 var img_data = false;
47650 if(canvas.width > 0) {
47651 var img_data = ctx.getImageData(0, 0, canvas.width, canvas.height);
47653 // setting canvas width will clean img data
47656 var style = window.getComputedStyle ?
47657 getComputedStyle(this.el.dom, null) : this.el.dom.currentStyle;
47659 var padding_left = parseInt(style.paddingLeft) || 0;
47660 var padding_right = parseInt(style.paddingRight) || 0;
47662 canvas.width = this.el.dom.clientWidth - padding_left - padding_right;
47665 ctx.putImageData(img_data, 0, 0);
47669 _handleMouseDown: function(e)
47671 if (e.browserEvent.which === 1) {
47672 this.mouse_btn_down = true;
47673 this.strokeBegin(e);
47677 _handleMouseMove: function (e)
47679 if (this.mouse_btn_down) {
47680 this.strokeMoveUpdate(e);
47684 _handleMouseUp: function (e)
47686 if (e.browserEvent.which === 1 && this.mouse_btn_down) {
47687 this.mouse_btn_down = false;
47692 _handleTouchStart: function (e) {
47694 e.preventDefault();
47695 if (e.browserEvent.targetTouches.length === 1) {
47696 // var touch = e.browserEvent.changedTouches[0];
47697 // this.strokeBegin(touch);
47699 this.strokeBegin(e); // assume e catching the correct xy...
47703 _handleTouchMove: function (e) {
47704 e.preventDefault();
47705 // var touch = event.targetTouches[0];
47706 // _this._strokeMoveUpdate(touch);
47707 this.strokeMoveUpdate(e);
47710 _handleTouchEnd: function (e) {
47711 var wasCanvasTouched = e.target === this.canvasEl().dom;
47712 if (wasCanvasTouched) {
47713 e.preventDefault();
47714 // var touch = event.changedTouches[0];
47715 // _this._strokeEnd(touch);
47720 reset: function () {
47721 this._lastPoints = [];
47722 this._lastVelocity = 0;
47723 this._lastWidth = (this.min_width + this.max_width) / 2;
47724 this.canvasElCtx().fillStyle = this.dot_color;
47727 strokeMoveUpdate: function(e)
47729 this.strokeUpdate(e);
47731 if (this.throttle) {
47732 this.throttleStroke(this.strokeUpdate, this.throttle);
47735 this.strokeUpdate(e);
47739 strokeBegin: function(e)
47741 var newPointGroup = {
47742 color: this.dot_color,
47746 if (typeof this.onBegin === 'function') {
47750 this.curve_data.push(newPointGroup);
47752 this.strokeUpdate(e);
47755 strokeUpdate: function(e)
47757 var rect = this.canvasEl().dom.getBoundingClientRect();
47758 var point = new this.Point(e.xy[0] - rect.left, e.xy[1] - rect.top, new Date().getTime());
47759 var lastPointGroup = this.curve_data[this.curve_data.length - 1];
47760 var lastPoints = lastPointGroup.points;
47761 var lastPoint = lastPoints.length > 0 && lastPoints[lastPoints.length - 1];
47762 var isLastPointTooClose = lastPoint
47763 ? point.distanceTo(lastPoint) <= this.min_distance
47765 var color = lastPointGroup.color;
47766 if (!lastPoint || !(lastPoint && isLastPointTooClose)) {
47767 var curve = this.addPoint(point);
47769 this.drawDot({color: color, point: point});
47772 this.drawCurve({color: color, curve: curve});
47782 strokeEnd: function(e)
47784 this.strokeUpdate(e);
47785 if (typeof this.onEnd === 'function') {
47790 addPoint: function (point) {
47791 var _lastPoints = this._lastPoints;
47792 _lastPoints.push(point);
47793 if (_lastPoints.length > 2) {
47794 if (_lastPoints.length === 3) {
47795 _lastPoints.unshift(_lastPoints[0]);
47797 var widths = this.calculateCurveWidths(_lastPoints[1], _lastPoints[2]);
47798 var curve = this.Bezier.fromPoints(_lastPoints, widths, this);
47799 _lastPoints.shift();
47805 calculateCurveWidths: function (startPoint, endPoint) {
47806 var velocity = this.velocity_filter_weight * endPoint.velocityFrom(startPoint) +
47807 (1 - this.velocity_filter_weight) * this._lastVelocity;
47809 var newWidth = Math.max(this.max_width / (velocity + 1), this.min_width);
47812 start: this._lastWidth
47815 this._lastVelocity = velocity;
47816 this._lastWidth = newWidth;
47820 drawDot: function (_a) {
47821 var color = _a.color, point = _a.point;
47822 var ctx = this.canvasElCtx();
47823 var width = typeof this.dot_size === 'function' ? this.dot_size() : this.dot_size;
47825 this.drawCurveSegment(point.x, point.y, width);
47827 ctx.fillStyle = color;
47831 drawCurve: function (_a) {
47832 var color = _a.color, curve = _a.curve;
47833 var ctx = this.canvasElCtx();
47834 var widthDelta = curve.endWidth - curve.startWidth;
47835 var drawSteps = Math.floor(curve.length()) * 2;
47837 ctx.fillStyle = color;
47838 for (var i = 0; i < drawSteps; i += 1) {
47839 var t = i / drawSteps;
47845 var x = uuu * curve.startPoint.x;
47846 x += 3 * uu * t * curve.control1.x;
47847 x += 3 * u * tt * curve.control2.x;
47848 x += ttt * curve.endPoint.x;
47849 var y = uuu * curve.startPoint.y;
47850 y += 3 * uu * t * curve.control1.y;
47851 y += 3 * u * tt * curve.control2.y;
47852 y += ttt * curve.endPoint.y;
47853 var width = curve.startWidth + ttt * widthDelta;
47854 this.drawCurveSegment(x, y, width);
47860 drawCurveSegment: function (x, y, width) {
47861 var ctx = this.canvasElCtx();
47863 ctx.arc(x, y, width, 0, 2 * Math.PI, false);
47864 this.is_empty = false;
47869 var ctx = this.canvasElCtx();
47870 var canvas = this.canvasEl().dom;
47871 ctx.fillStyle = this.bg_color;
47872 ctx.clearRect(0, 0, canvas.width, canvas.height);
47873 ctx.fillRect(0, 0, canvas.width, canvas.height);
47874 this.curve_data = [];
47876 this.is_empty = true;
47881 return this.el.select('input',true).first();
47884 canvasEl: function()
47886 return this.el.select('canvas',true).first();
47889 canvasElCtx: function()
47891 return this.el.select('canvas',true).first().dom.getContext('2d');
47894 getImage: function(type)
47896 if(this.is_empty) {
47901 return this.canvasEl().dom.toDataURL('image/'+type, 1);
47904 drawFromImage: function(img_src)
47906 var img = new Image();
47908 img.onload = function(){
47909 this.canvasElCtx().drawImage(img, 0, 0);
47914 this.is_empty = false;
47917 selectImage: function()
47919 this.fileEl().dom.click();
47922 uploadImage: function(e)
47924 var reader = new FileReader();
47926 reader.onload = function(e){
47927 var img = new Image();
47928 img.onload = function(){
47930 this.canvasElCtx().drawImage(img, 0, 0);
47932 img.src = e.target.result;
47935 reader.readAsDataURL(e.target.files[0]);
47938 // Bezier Point Constructor
47939 Point: (function () {
47940 function Point(x, y, time) {
47943 this.time = time || Date.now();
47945 Point.prototype.distanceTo = function (start) {
47946 return Math.sqrt(Math.pow(this.x - start.x, 2) + Math.pow(this.y - start.y, 2));
47948 Point.prototype.equals = function (other) {
47949 return this.x === other.x && this.y === other.y && this.time === other.time;
47951 Point.prototype.velocityFrom = function (start) {
47952 return this.time !== start.time
47953 ? this.distanceTo(start) / (this.time - start.time)
47960 // Bezier Constructor
47961 Bezier: (function () {
47962 function Bezier(startPoint, control2, control1, endPoint, startWidth, endWidth) {
47963 this.startPoint = startPoint;
47964 this.control2 = control2;
47965 this.control1 = control1;
47966 this.endPoint = endPoint;
47967 this.startWidth = startWidth;
47968 this.endWidth = endWidth;
47970 Bezier.fromPoints = function (points, widths, scope) {
47971 var c2 = this.calculateControlPoints(points[0], points[1], points[2], scope).c2;
47972 var c3 = this.calculateControlPoints(points[1], points[2], points[3], scope).c1;
47973 return new Bezier(points[1], c2, c3, points[2], widths.start, widths.end);
47975 Bezier.calculateControlPoints = function (s1, s2, s3, scope) {
47976 var dx1 = s1.x - s2.x;
47977 var dy1 = s1.y - s2.y;
47978 var dx2 = s2.x - s3.x;
47979 var dy2 = s2.y - s3.y;
47980 var m1 = { x: (s1.x + s2.x) / 2.0, y: (s1.y + s2.y) / 2.0 };
47981 var m2 = { x: (s2.x + s3.x) / 2.0, y: (s2.y + s3.y) / 2.0 };
47982 var l1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
47983 var l2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
47984 var dxm = m1.x - m2.x;
47985 var dym = m1.y - m2.y;
47986 var k = l2 / (l1 + l2);
47987 var cm = { x: m2.x + dxm * k, y: m2.y + dym * k };
47988 var tx = s2.x - cm.x;
47989 var ty = s2.y - cm.y;
47991 c1: new scope.Point(m1.x + tx, m1.y + ty),
47992 c2: new scope.Point(m2.x + tx, m2.y + ty)
47995 Bezier.prototype.length = function () {
48000 for (var i = 0; i <= steps; i += 1) {
48002 var cx = this.point(t, this.startPoint.x, this.control1.x, this.control2.x, this.endPoint.x);
48003 var cy = this.point(t, this.startPoint.y, this.control1.y, this.control2.y, this.endPoint.y);
48005 var xdiff = cx - px;
48006 var ydiff = cy - py;
48007 length += Math.sqrt(xdiff * xdiff + ydiff * ydiff);
48014 Bezier.prototype.point = function (t, start, c1, c2, end) {
48015 return (start * (1.0 - t) * (1.0 - t) * (1.0 - t))
48016 + (3.0 * c1 * (1.0 - t) * (1.0 - t) * t)
48017 + (3.0 * c2 * (1.0 - t) * t * t)
48018 + (end * t * t * t);
48023 throttleStroke: function(fn, wait) {
48024 if (wait === void 0) { wait = 250; }
48026 var timeout = null;
48030 var later = function () {
48031 previous = Date.now();
48033 result = fn.apply(storedContext, storedArgs);
48035 storedContext = null;
48039 return function wrapper() {
48041 for (var _i = 0; _i < arguments.length; _i++) {
48042 args[_i] = arguments[_i];
48044 var now = Date.now();
48045 var remaining = wait - (now - previous);
48046 storedContext = this;
48048 if (remaining <= 0 || remaining > wait) {
48050 clearTimeout(timeout);
48054 result = fn.apply(storedContext, storedArgs);
48056 storedContext = null;
48060 else if (!timeout) {
48061 timeout = window.setTimeout(later, remaining);
48071 // old names for form elements
48072 Roo.bootstrap.Form = Roo.bootstrap.form.Form;
48073 Roo.bootstrap.Input = Roo.bootstrap.form.Input;
48074 Roo.bootstrap.TextArea = Roo.bootstrap.form.TextArea;
48075 Roo.bootstrap.TriggerField = Roo.bootstrap.form.TriggerField;
48076 Roo.bootstrap.ComboBox = Roo.bootstrap.form.ComboBox;
48077 Roo.bootstrap.DateField = Roo.bootstrap.form.DateField;
48078 Roo.bootstrap.TimeField = Roo.bootstrap.form.TimeField;
48079 Roo.bootstrap.MonthField = Roo.bootstrap.form.MonthField;
48080 Roo.bootstrap.CheckBox = Roo.bootstrap.form.CheckBox;
48081 Roo.bootstrap.Radio = Roo.bootstrap.form.Radio;
48082 Roo.bootstrap.RadioSet = Roo.bootstrap.form.RadioSet;
48083 Roo.bootstrap.SecurePass = Roo.bootstrap.form.SecurePass;
48084 Roo.bootstrap.FieldLabel = Roo.bootstrap.form.FieldLabel;
48085 Roo.bootstrap.DateSplitField= Roo.bootstrap.form.DateSplitField;
48086 Roo.bootstrap.NumberField = Roo.bootstrap.form.NumberField;
48087 Roo.bootstrap.PhoneInput = Roo.bootstrap.form.PhoneInput;
48088 Roo.bootstrap.PhoneInputData= Roo.bootstrap.form.PhoneInputData;
48089 Roo.bootstrap.MoneyField = Roo.bootstrap.form.MoneyField;
48090 Roo.bootstrap.HtmlEditor = Roo.bootstrap.form.HtmlEditor;
48091 Roo.bootstrap.HtmlEditor.ToolbarStandard = Roo.bootstrap.form.HtmlEditorToolbarStandard;
48092 Roo.bootstrap.Markdown = Roo.bootstrap.form.Markdown;
48093 Roo.bootstrap.CardUploader = Roo.bootstrap.form.CardUploader;// depricated.
48094 Roo.bootstrap.Navbar = Roo.bootstrap.nav.Bar;
48095 Roo.bootstrap.NavGroup = Roo.bootstrap.nav.Group;
48096 Roo.bootstrap.NavHeaderbar = Roo.bootstrap.nav.Headerbar;
48097 Roo.bootstrap.NavItem = Roo.bootstrap.nav.Item;
48099 Roo.bootstrap.NavProgressBar = Roo.bootstrap.nav.ProgressBar;
48100 Roo.bootstrap.NavProgressBarItem = Roo.bootstrap.nav.ProgressBarItem;
48102 Roo.bootstrap.NavSidebar = Roo.bootstrap.nav.Sidebar;
48103 Roo.bootstrap.NavSidebarItem = Roo.bootstrap.nav.SidebarItem;
48105 Roo.bootstrap.NavSimplebar = Roo.bootstrap.nav.Simplebar;// deprciated
48106 Roo.bootstrap.Menu = Roo.bootstrap.menu.Menu;
48107 Roo.bootstrap.MenuItem = Roo.bootstrap.menu.Item;
48108 Roo.bootstrap.MenuSeparator = Roo.bootstrap.menu.Separator