2 * set the version of bootstrap based on the stylesheet...
6 Roo.bootstrap.version = (
9 Roo.each(document.styleSheets[0], function(s) {
10 if (s.href.match(/css-bootstrap4/)) {
18 * base class for bootstrap elements.
22 Roo.bootstrap = Roo.bootstrap || {};
24 * @class Roo.bootstrap.Component
25 * @extends Roo.Component
26 * Bootstrap Component base class
27 * @cfg {String} cls css class
28 * @cfg {String} style any extra css
29 * @cfg {Object} xattr extra attributes to add to 'element' (used by builder to store stuff.)
30 * @cfg {Boolean} can_build_overlaid True if element can be rebuild from a HTML page
31 * @cfg {string} dataId cutomer id
32 * @cfg {string} name Specifies name attribute
33 * @cfg {string} tooltip Text for the tooltip
34 * @cfg {string} container_method method to fetch parents container element (used by NavHeaderbar - getHeaderChildContainer)
35 * @cfg {string|object} visibilityEl (el|parent) What element to use for visibility (@see getVisibilityEl())
38 * Do not use directly - it does not do anything..
39 * @param {Object} config The config object
44 Roo.bootstrap.Component = function(config){
45 Roo.bootstrap.Component.superclass.constructor.call(this, config);
49 * @event childrenrendered
50 * Fires when the children have been rendered..
51 * @param {Roo.bootstrap.Component} this
53 "childrenrendered" : true
62 Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent, {
65 allowDomMove : false, // to stop relocations in parent onRender...
75 * Initialize Events for the element
77 initEvents : function() { },
83 can_build_overlaid : true,
85 container_method : false,
92 // returns the parent component..
93 return Roo.ComponentMgr.get(this.parentId)
99 onRender : function(ct, position)
101 // Roo.log("Call onRender: " + this.xtype);
103 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
106 if (this.el.attr('xtype')) {
107 this.el.attr('xtypex', this.el.attr('xtype'));
108 this.el.dom.removeAttribute('xtype');
118 var cfg = Roo.apply({}, this.getAutoCreate());
120 cfg.id = this.id || Roo.id();
122 // fill in the extra attributes
123 if (this.xattr && typeof(this.xattr) =='object') {
124 for (var i in this.xattr) {
125 cfg[i] = this.xattr[i];
130 cfg.dataId = this.dataId;
134 cfg.cls = (typeof(cfg.cls) == 'undefined') ? this.cls : cfg.cls + ' ' + this.cls;
137 if (this.style) { // fixme needs to support more complex style data.
138 cfg.style = this.style;
142 cfg.name = this.name;
145 this.el = ct.createChild(cfg, position);
148 this.tooltipEl().attr('tooltip', this.tooltip);
151 if(this.tabIndex !== undefined){
152 this.el.dom.setAttribute('tabIndex', this.tabIndex);
159 * Fetch the element to add children to
160 * @return {Roo.Element} defaults to this.el
162 getChildContainer : function()
167 * Fetch the element to display the tooltip on.
168 * @return {Roo.Element} defaults to this.el
170 tooltipEl : function()
175 addxtype : function(tree,cntr)
179 cn = Roo.factory(tree);
180 //Roo.log(['addxtype', cn]);
182 cn.parentType = this.xtype; //??
183 cn.parentId = this.id;
185 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
186 if (typeof(cn.container_method) == 'string') {
187 cntr = cn.container_method;
191 var has_flexy_each = (typeof(tree['flexy:foreach']) != 'undefined');
193 var has_flexy_if = (typeof(tree['flexy:if']) != 'undefined');
195 var build_from_html = Roo.XComponent.build_from_html;
197 var is_body = (tree.xtype == 'Body') ;
199 var page_has_body = (Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body');
201 var self_cntr_el = Roo.get(this[cntr](false));
203 // do not try and build conditional elements
204 if ((has_flexy_each || has_flexy_if || this.can_build_overlaid == false ) && build_from_html) {
208 if (!has_flexy_each || !build_from_html || is_body || !page_has_body) {
209 if(!has_flexy_if || typeof(tree.name) == 'undefined' || !build_from_html || is_body || !page_has_body){
210 return this.addxtypeChild(tree,cntr, is_body);
213 var echild =self_cntr_el ? self_cntr_el.child('>*[name=' + tree.name + ']') : false;
216 return this.addxtypeChild(Roo.apply({}, tree),cntr);
219 Roo.log('skipping render');
225 if (!build_from_html) {
229 // this i think handles overlaying multiple children of the same type
230 // with the sam eelement.. - which might be buggy..
232 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
238 if (echild && echild.attr('xtype').split('.').pop() != cn.xtype) {
242 ret = this.addxtypeChild(Roo.apply({}, tree),cntr);
249 addxtypeChild : function (tree, cntr, is_body)
251 Roo.debug && Roo.log('addxtypeChild:' + cntr);
253 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
256 var has_flexy = (typeof(tree['flexy:if']) != 'undefined') ||
257 (typeof(tree['flexy:foreach']) != 'undefined');
261 skip_children = false;
262 // render the element if it's not BODY.
265 // if parent was disabled, then do not try and create the children..
266 if(!this[cntr](true)){
271 cn = Roo.factory(tree);
273 cn.parentType = this.xtype; //??
274 cn.parentId = this.id;
276 var build_from_html = Roo.XComponent.build_from_html;
279 // does the container contain child eleemnts with 'xtype' attributes.
280 // that match this xtype..
281 // note - when we render we create these as well..
282 // so we should check to see if body has xtype set.
283 if (build_from_html && Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body') {
285 var self_cntr_el = Roo.get(this[cntr](false));
286 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
288 //Roo.log(Roo.XComponent.build_from_html);
289 //Roo.log("got echild:");
292 // there is a scenario where some of the child elements are flexy:if (and all of the same type)
293 // and are not displayed -this causes this to use up the wrong element when matching.
294 // at present the only work around for this is to nest flexy:if elements in another element that is always rendered.
297 if (echild && echild.attr('xtype').split('.').pop() == cn.xtype) {
298 // Roo.log("found child for " + this.xtype +": " + echild.attr('xtype') );
304 //echild.dom.removeAttribute('xtype');
306 Roo.debug && Roo.log("MISSING " + cn.xtype + " on child of " + (this.el ? this.el.attr('xbuilderid') : 'no parent'));
307 Roo.debug && Roo.log(self_cntr_el);
308 Roo.debug && Roo.log(echild);
309 Roo.debug && Roo.log(cn);
315 // if object has flexy:if - then it may or may not be rendered.
316 if (build_from_html && has_flexy && !cn.el && cn.can_build_overlaid) {
317 // skip a flexy if element.
318 Roo.debug && Roo.log('skipping render');
319 Roo.debug && Roo.log(tree);
321 Roo.debug && Roo.log('skipping all children');
322 skip_children = true;
327 // actually if flexy:foreach is found, we really want to create
328 // multiple copies here...
330 //Roo.log(this[cntr]());
331 // some elements do not have render methods.. like the layouts...
333 if(this[cntr](true) === false){
338 cn.render && cn.render(this[cntr](true));
341 // then add the element..
348 if (typeof (tree.menu) != 'undefined') {
349 tree.menu.parentType = cn.xtype;
350 tree.menu.triggerEl = cn.el;
351 nitems.push(cn.addxtype(Roo.apply({}, tree.menu)));
355 if (!tree.items || !tree.items.length) {
357 //Roo.log(["no children", this]);
362 var items = tree.items;
365 //Roo.log(items.length);
367 if (!skip_children) {
368 for(var i =0;i < items.length;i++) {
369 // Roo.log(['add child', items[i]]);
370 nitems.push(cn.addxtype(Roo.apply({}, items[i])));
376 //Roo.log("fire childrenrendered");
378 cn.fireEvent('childrenrendered', this);
384 * Set the element that will be used to show or hide
386 setVisibilityEl : function(el)
388 this.visibilityEl = el;
392 * Get the element that will be used to show or hide
394 getVisibilityEl : function()
396 if (typeof(this.visibilityEl) == 'object') {
397 return this.visibilityEl;
400 if (typeof(this.visibilityEl) == 'string') {
401 return this.visibilityEl == 'parent' ? this.parent().getEl() : this.getEl();
408 * Show a component - removes 'hidden' class
412 if(!this.getVisibilityEl()){
416 this.getVisibilityEl().removeClass('hidden');
418 this.fireEvent('show', this);
423 * Hide a component - adds 'hidden' class
427 if(!this.getVisibilityEl()){
431 this.getVisibilityEl().addClass('hidden');
433 this.fireEvent('hide', this);
446 * @class Roo.bootstrap.Body
447 * @extends Roo.bootstrap.Component
448 * Bootstrap Body class
452 * @param {Object} config The config object
455 Roo.bootstrap.Body = function(config){
457 config = config || {};
459 Roo.bootstrap.Body.superclass.constructor.call(this, config);
460 this.el = Roo.get(config.el ? config.el : document.body );
461 if (this.cls && this.cls.length) {
462 Roo.get(document.body).addClass(this.cls);
466 Roo.extend(Roo.bootstrap.Body, Roo.bootstrap.Component, {
468 is_body : true,// just to make sure it's constructed?
473 onRender : function(ct, position)
475 /* Roo.log("Roo.bootstrap.Body - onRender");
476 if (this.cls && this.cls.length) {
477 Roo.get(document.body).addClass(this.cls);
496 * @class Roo.bootstrap.ButtonGroup
497 * @extends Roo.bootstrap.Component
498 * Bootstrap ButtonGroup class
499 * @cfg {String} size lg | sm | xs (default empty normal)
500 * @cfg {String} align vertical | justified (default none)
501 * @cfg {String} direction up | down (default down)
502 * @cfg {Boolean} toolbar false | true
503 * @cfg {Boolean} btn true | false
508 * @param {Object} config The config object
511 Roo.bootstrap.ButtonGroup = function(config){
512 Roo.bootstrap.ButtonGroup.superclass.constructor.call(this, config);
515 Roo.extend(Roo.bootstrap.ButtonGroup, Roo.bootstrap.Component, {
523 getAutoCreate : function(){
529 cfg.html = this.html || cfg.html;
540 if (['vertical','justified'].indexOf(this.align)!==-1) {
541 cfg.cls = 'btn-group-' + this.align;
543 if (this.align == 'justified') {
544 console.log(this.items);
548 if (['lg','sm','xs'].indexOf(this.size)!==-1) {
549 cfg.cls += ' btn-group-' + this.size;
552 if (this.direction == 'up') {
553 cfg.cls += ' dropup' ;
559 * Add a button to the group (similar to NavItem API.)
561 addItem : function(cfg)
563 var cn = new Roo.bootstrap.Button(cfg);
565 cn.parentId = this.id;
566 cn.onRender(this.el, null);
580 * @class Roo.bootstrap.Button
581 * @extends Roo.bootstrap.Component
582 * Bootstrap Button class
583 * @cfg {String} html The button content
584 * @cfg {String} weight (default | primary | success | info | warning | danger | link ) default
585 * @cfg {String} size ( lg | sm | xs)
586 * @cfg {String} tag ( a | input | submit)
587 * @cfg {String} href empty or href
588 * @cfg {Boolean} disabled default false;
589 * @cfg {Boolean} isClose default false;
590 * @cfg {String} glyphicon (| adjust | align-center | align-justify | align-left | align-right | arrow-down | arrow-left | arrow-right | arrow-up | asterisk | backward | ban-circle | barcode | bell | bold | book | bookmark | briefcase | bullhorn | calendar | camera | certificate | check | chevron-down | chevron-left | chevron-right | chevron-up | circle-arrow-down | circle-arrow-left | circle-arrow-right | circle-arrow-up | cloud | cloud-download | cloud-upload | cog | collapse-down | collapse-up | comment | compressed | copyright-mark | credit-card | cutlery | dashboard | download | download-alt | earphone | edit | eject | envelope | euro | exclamation-sign | expand | export | eye-close | eye-open | facetime-video | fast-backward | fast-forward | file | film | filter | fire | flag | flash | floppy-disk | floppy-open | floppy-remove | floppy-save | floppy-saved | folder-close | folder-open | font | forward | fullscreen | gbp | gift | glass | globe | hand-down | hand-left | hand-right | hand-up | hd-video | hdd | header | headphones | heart | heart-empty | home | import | inbox | indent-left | indent-right | info-sign | italic | leaf | link | list | list-alt | lock | log-in | log-out | magnet | map-marker | minus | minus-sign | move | music | new-window | off | ok | ok-circle | ok-sign | open | paperclip | pause | pencil | phone | phone-alt | picture | plane | play | play-circle | plus | plus-sign | print | pushpin | qrcode | question-sign | random | record | refresh | registration-mark | remove | remove-circle | remove-sign | repeat | resize-full | resize-horizontal | resize-small | resize-vertical | retweet | road | save | saved | screenshot | sd-video | search | send | share | share-alt | shopping-cart | signal | sort | sort-by-alphabet | sort-by-alphabet-alt | sort-by-attributes | sort-by-attributes-alt | sort-by-order | sort-by-order-alt | sound-5-1 | sound-6-1 | sound-7-1 | sound-dolby | sound-stereo | star | star-empty | stats | step-backward | step-forward | stop | subtitles | tag | tags | tasks | text-height | text-width | th | th-large | th-list | thumbs-down | thumbs-up | time | tint | tower | transfer | trash | tree-conifer | tree-deciduous | unchecked | upload | usd | user | volume-down | volume-off | volume-up | warning-sign | wrench | zoom-in | zoom-out)
591 * @cfg {String} badge text for badge
592 * @cfg {String} theme (default|glow)
593 * @cfg {Boolean} inverse dark themed version
594 * @cfg {Boolean} toggle is it a slidy toggle button
595 * @cfg {Boolean} pressed (true|false) default null - if the button ahs active state
596 * @cfg {String} ontext text for on slidy toggle state
597 * @cfg {String} offtext text for off slidy toggle state
598 * @cfg {Boolean} preventDefault default true (stop click event triggering the URL if it's a link.)
599 * @cfg {Boolean} removeClass remove the standard class..
600 * @cfg {String} target target for a href. (_self|_blank|_parent|_top| other)
603 * Create a new button
604 * @param {Object} config The config object
608 Roo.bootstrap.Button = function(config){
609 Roo.bootstrap.Button.superclass.constructor.call(this, config);
610 this.weightClass = ["btn-default",
622 * When a butotn is pressed
623 * @param {Roo.bootstrap.Button} btn
624 * @param {Roo.EventObject} e
629 * After the button has been toggles
630 * @param {Roo.bootstrap.Button} btn
631 * @param {Roo.EventObject} e
632 * @param {boolean} pressed (also available as button.pressed)
638 Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, {
656 preventDefault: true,
664 getAutoCreate : function(){
672 if (['a', 'button', 'input', 'submit'].indexOf(this.tag) < 0) {
673 throw "Invalid value for tag: " + this.tag + ". must be a, button, input or submit.";
678 cfg.html = '<span class="roo-button-text">' + (this.html || cfg.html) + '</span>';
680 if (this.toggle == true) {
683 cls: 'slider-frame roo-button',
688 'data-off-text':'OFF',
689 cls: 'slider-button',
695 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
696 cfg.cls += ' '+this.weight;
705 cfg["aria-hidden"] = true;
707 cfg.html = "×";
713 if (this.theme==='default') {
714 cfg.cls = 'btn roo-button';
716 //if (this.parentType != 'Navbar') {
717 this.weight = this.weight.length ? this.weight : 'default';
719 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
721 cfg.cls += ' btn-' + this.weight;
723 } else if (this.theme==='glow') {
726 cfg.cls = 'btn-glow roo-button';
728 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
730 cfg.cls += ' ' + this.weight;
736 this.cls += ' inverse';
740 if (this.active || this.pressed === true) {
741 cfg.cls += ' active';
745 cfg.disabled = 'disabled';
749 Roo.log('changing to ul' );
751 this.glyphicon = 'caret';
754 cfg.cls += this.size.length ? (' btn-' + this.size) : '';
756 //gsRoo.log(this.parentType);
757 if (this.parentType === 'Navbar' && !this.parent().bar) {
758 Roo.log('changing to li?');
767 href : this.href || '#'
770 cfg.cn[0].html = this.html + ' <span class="caret"></span>';
771 cfg.cls += ' dropdown';
778 cfg.cls += this.parentType === 'Navbar' ? ' navbar-btn' : '';
780 if (this.glyphicon) {
781 cfg.html = ' ' + cfg.html;
786 cls: 'glyphicon glyphicon-' + this.glyphicon
796 // cfg.cls='btn roo-button';
800 var value = cfg.html;
805 cls: 'glyphicon glyphicon-' + this.glyphicon,
824 cfg.cls += ' dropdown';
825 cfg.html = typeof(cfg.html) != 'undefined' ?
826 cfg.html + ' <span class="caret"></span>' : '<span class="caret"></span>';
829 if (cfg.tag !== 'a' && this.href !== '') {
830 throw "Tag must be a to set href.";
831 } else if (this.href.length > 0) {
832 cfg.href = this.href;
835 if(this.removeClass){
840 cfg.target = this.target;
845 initEvents: function() {
846 // Roo.log('init events?');
847 // Roo.log(this.el.dom);
850 if (typeof (this.menu) != 'undefined') {
851 this.menu.parentType = this.xtype;
852 this.menu.triggerEl = this.el;
853 this.addxtype(Roo.apply({}, this.menu));
857 if (this.el.hasClass('roo-button')) {
858 this.el.on('click', this.onClick, this);
860 this.el.select('.roo-button').on('click', this.onClick, this);
863 if(this.removeClass){
864 this.el.on('click', this.onClick, this);
867 this.el.enableDisplayMode();
870 onClick : function(e)
876 Roo.log('button on click ');
877 if(this.preventDefault){
881 if (this.pressed === true || this.pressed === false) {
882 this.toggleActive(e);
886 this.fireEvent('click', this, e);
890 * Enables this button
894 this.disabled = false;
895 this.el.removeClass('disabled');
899 * Disable this button
903 this.disabled = true;
904 this.el.addClass('disabled');
907 * sets the active state on/off,
908 * @param {Boolean} state (optional) Force a particular state
910 setActive : function(v) {
912 this.el[v ? 'addClass' : 'removeClass']('active');
916 * toggles the current active state
918 toggleActive : function(e)
920 this.setActive(!this.pressed);
921 this.fireEvent('toggle', this, e, !this.pressed);
924 * get the current active state
925 * @return {boolean} true if it's active
927 isActive : function()
929 return this.el.hasClass('active');
932 * set the text of the first selected button
934 setText : function(str)
936 this.el.select('.roo-button-text',true).first().dom.innerHTML = str;
939 * get the text of the first selected button
943 return this.el.select('.roo-button-text',true).first().dom.innerHTML;
946 setWeight : function(str)
948 this.el.removeClass(this.weightClass);
949 this.el.addClass('btn-' + str);
963 * @class Roo.bootstrap.Column
964 * @extends Roo.bootstrap.Component
965 * Bootstrap Column class
966 * @cfg {Number} xs colspan out of 12 for mobile-sized screens or 0 for hidden
967 * @cfg {Number} sm colspan out of 12 for tablet-sized screens or 0 for hidden
968 * @cfg {Number} md colspan out of 12 for computer-sized screens or 0 for hidden
969 * @cfg {Number} lg colspan out of 12 for large computer-sized screens or 0 for hidden
970 * @cfg {Number} xsoff colspan offset out of 12 for mobile-sized screens or 0 for hidden
971 * @cfg {Number} smoff colspan offset out of 12 for tablet-sized screens or 0 for hidden
972 * @cfg {Number} mdoff colspan offset out of 12 for computer-sized screens or 0 for hidden
973 * @cfg {Number} lgoff colspan offset out of 12 for large computer-sized screens or 0 for hidden
976 * @cfg {Boolean} hidden (true|false) hide the element
977 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
978 * @cfg {String} fa (ban|check|...) font awesome icon
979 * @cfg {Number} fasize (1|2|....) font awsome size
981 * @cfg {String} icon (info-sign|check|...) glyphicon name
983 * @cfg {String} html content of column.
986 * Create a new Column
987 * @param {Object} config The config object
990 Roo.bootstrap.Column = function(config){
991 Roo.bootstrap.Column.superclass.constructor.call(this, config);
994 Roo.extend(Roo.bootstrap.Column, Roo.bootstrap.Component, {
1012 getAutoCreate : function(){
1013 var cfg = Roo.apply({}, Roo.bootstrap.Column.superclass.getAutoCreate.call(this));
1021 ['xs','sm','md','lg'].map(function(size){
1022 //Roo.log( size + ':' + settings[size]);
1024 if (settings[size+'off'] !== false) {
1025 cfg.cls += ' col-' + size + '-offset-' + settings[size+'off'] ;
1028 if (settings[size] === false) {
1032 if (!settings[size]) { // 0 = hidden
1033 cfg.cls += ' hidden-' + size;
1036 cfg.cls += ' col-' + size + '-' + settings[size];
1041 cfg.cls += ' hidden';
1044 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1045 cfg.cls +=' alert alert-' + this.alert;
1049 if (this.html.length) {
1050 cfg.html = this.html;
1054 if (this.fasize > 1) {
1055 fasize = ' fa-' + this.fasize + 'x';
1057 cfg.html = '<i class="fa fa-'+this.fa + fasize + '"></i>' + (cfg.html || '');
1062 cfg.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + (cfg.html || '');
1081 * @class Roo.bootstrap.Container
1082 * @extends Roo.bootstrap.Component
1083 * Bootstrap Container class
1084 * @cfg {Boolean} jumbotron is it a jumbotron element
1085 * @cfg {String} html content of element
1086 * @cfg {String} well (lg|sm|md) a well, large, small or medium.
1087 * @cfg {String} panel (default|primary|success|info|warning|danger) render as panel - type - primary/success.....
1088 * @cfg {String} header content of header (for panel)
1089 * @cfg {String} footer content of footer (for panel)
1090 * @cfg {String} sticky (footer|wrap|push) block to use as footer or body- needs css-bootstrap/sticky-footer.css
1091 * @cfg {String} tag (header|aside|section) type of HTML tag.
1092 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1093 * @cfg {String} fa font awesome icon
1094 * @cfg {String} icon (info-sign|check|...) glyphicon name
1095 * @cfg {Boolean} hidden (true|false) hide the element
1096 * @cfg {Boolean} expandable (true|false) default false
1097 * @cfg {Boolean} expanded (true|false) default true
1098 * @cfg {String} rheader contet on the right of header
1099 * @cfg {Boolean} clickable (true|false) default false
1103 * Create a new Container
1104 * @param {Object} config The config object
1107 Roo.bootstrap.Container = function(config){
1108 Roo.bootstrap.Container.superclass.constructor.call(this, config);
1114 * After the panel has been expand
1116 * @param {Roo.bootstrap.Container} this
1121 * After the panel has been collapsed
1123 * @param {Roo.bootstrap.Container} this
1128 * When a element is chick
1129 * @param {Roo.bootstrap.Container} this
1130 * @param {Roo.EventObject} e
1136 Roo.extend(Roo.bootstrap.Container, Roo.bootstrap.Component, {
1154 getChildContainer : function() {
1160 if (this.panel.length) {
1161 return this.el.select('.panel-body',true).first();
1168 getAutoCreate : function(){
1171 tag : this.tag || 'div',
1175 if (this.jumbotron) {
1176 cfg.cls = 'jumbotron';
1181 // - this is applied by the parent..
1183 // cfg.cls = this.cls + '';
1186 if (this.sticky.length) {
1188 var bd = Roo.get(document.body);
1189 if (!bd.hasClass('bootstrap-sticky')) {
1190 bd.addClass('bootstrap-sticky');
1191 Roo.select('html',true).setStyle('height', '100%');
1194 cfg.cls += 'bootstrap-sticky-' + this.sticky;
1198 if (this.well.length) {
1199 switch (this.well) {
1202 cfg.cls +=' well well-' +this.well;
1211 cfg.cls += ' hidden';
1215 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1216 cfg.cls +=' alert alert-' + this.alert;
1221 if (this.panel.length) {
1222 cfg.cls += ' panel panel-' + this.panel;
1224 if (this.header.length) {
1228 if(this.expandable){
1230 cfg.cls = cfg.cls + ' expandable';
1234 cls: (this.expanded ? 'fa fa-minus' : 'fa fa-plus')
1242 cls : 'panel-title',
1243 html : (this.expandable ? ' ' : '') + this.header
1247 cls: 'panel-header-right',
1253 cls : 'panel-heading',
1254 style : this.expandable ? 'cursor: pointer' : '',
1262 cls : 'panel-body' + (this.expanded ? '' : ' hide'),
1267 if (this.footer.length) {
1269 cls : 'panel-footer',
1278 body.html = this.html || cfg.html;
1279 // prefix with the icons..
1281 body.html = '<i class="fa fa-'+this.fa + '"></i>' + body.html ;
1284 body.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + body.html ;
1289 if ((!this.cls || !this.cls.length) && (!cfg.cls || !cfg.cls.length)) {
1290 cfg.cls = 'container';
1296 initEvents: function()
1298 if(this.expandable){
1299 var headerEl = this.headerEl();
1302 headerEl.on('click', this.onToggleClick, this);
1307 this.el.on('click', this.onClick, this);
1312 onToggleClick : function()
1314 var headerEl = this.headerEl();
1330 if(this.fireEvent('expand', this)) {
1332 this.expanded = true;
1334 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).show();
1336 this.el.select('.panel-body',true).first().removeClass('hide');
1338 var toggleEl = this.toggleEl();
1344 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-minus']);
1349 collapse : function()
1351 if(this.fireEvent('collapse', this)) {
1353 this.expanded = false;
1355 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).hide();
1356 this.el.select('.panel-body',true).first().addClass('hide');
1358 var toggleEl = this.toggleEl();
1364 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-plus']);
1368 toggleEl : function()
1370 if(!this.el || !this.panel.length || !this.header.length || !this.expandable){
1374 return this.el.select('.panel-heading .fa',true).first();
1377 headerEl : function()
1379 if(!this.el || !this.panel.length || !this.header.length){
1383 return this.el.select('.panel-heading',true).first()
1388 if(!this.el || !this.panel.length){
1392 return this.el.select('.panel-body',true).first()
1395 titleEl : function()
1397 if(!this.el || !this.panel.length || !this.header.length){
1401 return this.el.select('.panel-title',true).first();
1404 setTitle : function(v)
1406 var titleEl = this.titleEl();
1412 titleEl.dom.innerHTML = v;
1415 getTitle : function()
1418 var titleEl = this.titleEl();
1424 return titleEl.dom.innerHTML;
1427 setRightTitle : function(v)
1429 var t = this.el.select('.panel-header-right',true).first();
1435 t.dom.innerHTML = v;
1438 onClick : function(e)
1442 this.fireEvent('click', this, e);
1455 * @class Roo.bootstrap.Img
1456 * @extends Roo.bootstrap.Component
1457 * Bootstrap Img class
1458 * @cfg {Boolean} imgResponsive false | true
1459 * @cfg {String} border rounded | circle | thumbnail
1460 * @cfg {String} src image source
1461 * @cfg {String} alt image alternative text
1462 * @cfg {String} href a tag href
1463 * @cfg {String} target (_self|_blank|_parent|_top)target for a href.
1464 * @cfg {String} xsUrl xs image source
1465 * @cfg {String} smUrl sm image source
1466 * @cfg {String} mdUrl md image source
1467 * @cfg {String} lgUrl lg image source
1470 * Create a new Input
1471 * @param {Object} config The config object
1474 Roo.bootstrap.Img = function(config){
1475 Roo.bootstrap.Img.superclass.constructor.call(this, config);
1481 * The img click event for the img.
1482 * @param {Roo.EventObject} e
1488 Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, {
1490 imgResponsive: true,
1500 getAutoCreate : function()
1502 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1503 return this.createSingleImg();
1508 cls: 'roo-image-responsive-group',
1513 Roo.each(['xs', 'sm', 'md', 'lg'], function(size){
1515 if(!_this[size + 'Url']){
1521 cls: (_this.imgResponsive) ? 'img-responsive' : '',
1522 html: _this.html || cfg.html,
1523 src: _this[size + 'Url']
1526 img.cls += ' roo-image-responsive-' + size;
1528 var s = ['xs', 'sm', 'md', 'lg'];
1530 s.splice(s.indexOf(size), 1);
1532 Roo.each(s, function(ss){
1533 img.cls += ' hidden-' + ss;
1536 if (['rounded','circle','thumbnail'].indexOf(_this.border)>-1) {
1537 cfg.cls += ' img-' + _this.border;
1541 cfg.alt = _this.alt;
1554 a.target = _this.target;
1558 cfg.cn.push((_this.href) ? a : img);
1565 createSingleImg : function()
1569 cls: (this.imgResponsive) ? 'img-responsive' : '',
1571 src : 'about:blank' // just incase src get's set to undefined?!?
1574 cfg.html = this.html || cfg.html;
1576 cfg.src = this.src || cfg.src;
1578 if (['rounded','circle','thumbnail'].indexOf(this.border)>-1) {
1579 cfg.cls += ' img-' + this.border;
1596 a.target = this.target;
1601 return (this.href) ? a : cfg;
1604 initEvents: function()
1607 this.el.on('click', this.onClick, this);
1612 onClick : function(e)
1614 Roo.log('img onclick');
1615 this.fireEvent('click', this, e);
1618 * Sets the url of the image - used to update it
1619 * @param {String} url the url of the image
1622 setSrc : function(url)
1626 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1627 this.el.dom.src = url;
1631 this.el.select('img', true).first().dom.src = url;
1647 * @class Roo.bootstrap.Link
1648 * @extends Roo.bootstrap.Component
1649 * Bootstrap Link Class
1650 * @cfg {String} alt image alternative text
1651 * @cfg {String} href a tag href
1652 * @cfg {String} target (_self|_blank|_parent|_top) target for a href.
1653 * @cfg {String} html the content of the link.
1654 * @cfg {String} anchor name for the anchor link
1655 * @cfg {String} fa - favicon
1657 * @cfg {Boolean} preventDefault (true | false) default false
1661 * Create a new Input
1662 * @param {Object} config The config object
1665 Roo.bootstrap.Link = function(config){
1666 Roo.bootstrap.Link.superclass.constructor.call(this, config);
1672 * The img click event for the img.
1673 * @param {Roo.EventObject} e
1679 Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component, {
1683 preventDefault: false,
1689 getAutoCreate : function()
1691 var html = this.html || '';
1693 if (this.fa !== false) {
1694 html = '<i class="fa fa-' + this.fa + '"></i>';
1699 // anchor's do not require html/href...
1700 if (this.anchor === false) {
1702 cfg.href = this.href || '#';
1704 cfg.name = this.anchor;
1705 if (this.html !== false || this.fa !== false) {
1708 if (this.href !== false) {
1709 cfg.href = this.href;
1713 if(this.alt !== false){
1718 if(this.target !== false) {
1719 cfg.target = this.target;
1725 initEvents: function() {
1727 if(!this.href || this.preventDefault){
1728 this.el.on('click', this.onClick, this);
1732 onClick : function(e)
1734 if(this.preventDefault){
1737 //Roo.log('img onclick');
1738 this.fireEvent('click', this, e);
1751 * @class Roo.bootstrap.Header
1752 * @extends Roo.bootstrap.Component
1753 * Bootstrap Header class
1754 * @cfg {String} html content of header
1755 * @cfg {Number} level (1|2|3|4|5|6) default 1
1758 * Create a new Header
1759 * @param {Object} config The config object
1763 Roo.bootstrap.Header = function(config){
1764 Roo.bootstrap.Header.superclass.constructor.call(this, config);
1767 Roo.extend(Roo.bootstrap.Header, Roo.bootstrap.Component, {
1775 getAutoCreate : function(){
1780 tag: 'h' + (1 *this.level),
1781 html: this.html || ''
1793 * Ext JS Library 1.1.1
1794 * Copyright(c) 2006-2007, Ext JS, LLC.
1796 * Originally Released Under LGPL - original licence link has changed is not relivant.
1799 * <script type="text/javascript">
1803 * @class Roo.bootstrap.MenuMgr
1804 * Provides a common registry of all menu items on a page so that they can be easily accessed by id.
1807 Roo.bootstrap.MenuMgr = function(){
1808 var menus, active, groups = {}, attached = false, lastShow = new Date();
1810 // private - called when first menu is created
1813 active = new Roo.util.MixedCollection();
1814 Roo.get(document).addKeyListener(27, function(){
1815 if(active.length > 0){
1823 if(active && active.length > 0){
1824 var c = active.clone();
1834 if(active.length < 1){
1835 Roo.get(document).un("mouseup", onMouseDown);
1843 var last = active.last();
1844 lastShow = new Date();
1847 Roo.get(document).on("mouseup", onMouseDown);
1852 //m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
1853 m.parentMenu.activeChild = m;
1854 }else if(last && last.isVisible()){
1855 //m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
1860 function onBeforeHide(m){
1862 m.activeChild.hide();
1864 if(m.autoHideTimer){
1865 clearTimeout(m.autoHideTimer);
1866 delete m.autoHideTimer;
1871 function onBeforeShow(m){
1872 var pm = m.parentMenu;
1873 if(!pm && !m.allowOtherMenus){
1875 }else if(pm && pm.activeChild && active != m){
1876 pm.activeChild.hide();
1880 // private this should really trigger on mouseup..
1881 function onMouseDown(e){
1882 Roo.log("on Mouse Up");
1884 if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".dropdown-menu") && !e.getTarget('.user-menu')){
1885 Roo.log("MenuManager hideAll");
1894 function onBeforeCheck(mi, state){
1896 var g = groups[mi.group];
1897 for(var i = 0, l = g.length; i < l; i++){
1899 g[i].setChecked(false);
1908 * Hides all menus that are currently visible
1910 hideAll : function(){
1915 register : function(menu){
1919 menus[menu.id] = menu;
1920 menu.on("beforehide", onBeforeHide);
1921 menu.on("hide", onHide);
1922 menu.on("beforeshow", onBeforeShow);
1923 menu.on("show", onShow);
1925 if(g && menu.events["checkchange"]){
1929 groups[g].push(menu);
1930 menu.on("checkchange", onCheck);
1935 * Returns a {@link Roo.menu.Menu} object
1936 * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will
1937 * be used to generate and return a new Menu instance.
1939 get : function(menu){
1940 if(typeof menu == "string"){ // menu id
1942 }else if(menu.events){ // menu instance
1945 /*else if(typeof menu.length == 'number'){ // array of menu items?
1946 return new Roo.bootstrap.Menu({items:menu});
1947 }else{ // otherwise, must be a config
1948 return new Roo.bootstrap.Menu(menu);
1955 unregister : function(menu){
1956 delete menus[menu.id];
1957 menu.un("beforehide", onBeforeHide);
1958 menu.un("hide", onHide);
1959 menu.un("beforeshow", onBeforeShow);
1960 menu.un("show", onShow);
1962 if(g && menu.events["checkchange"]){
1963 groups[g].remove(menu);
1964 menu.un("checkchange", onCheck);
1969 registerCheckable : function(menuItem){
1970 var g = menuItem.group;
1975 groups[g].push(menuItem);
1976 menuItem.on("beforecheckchange", onBeforeCheck);
1981 unregisterCheckable : function(menuItem){
1982 var g = menuItem.group;
1984 groups[g].remove(menuItem);
1985 menuItem.un("beforecheckchange", onBeforeCheck);
1997 * @class Roo.bootstrap.Menu
1998 * @extends Roo.bootstrap.Component
1999 * Bootstrap Menu class - container for MenuItems
2000 * @cfg {String} type (dropdown|treeview|submenu) type of menu
2001 * @cfg {bool} hidden if the menu should be hidden when rendered.
2002 * @cfg {bool} stopEvent (true|false) Stop event after trigger press (default true)
2003 * @cfg {bool} isLink (true|false) the menu has link disable auto expand and collaspe (default false)
2007 * @param {Object} config The config object
2011 Roo.bootstrap.Menu = function(config){
2012 Roo.bootstrap.Menu.superclass.constructor.call(this, config);
2013 if (this.registerMenu && this.type != 'treeview') {
2014 Roo.bootstrap.MenuMgr.register(this);
2021 * Fires before this menu is displayed
2022 * @param {Roo.menu.Menu} this
2027 * Fires before this menu is hidden
2028 * @param {Roo.menu.Menu} this
2033 * Fires after this menu is displayed
2034 * @param {Roo.menu.Menu} this
2039 * Fires after this menu is hidden
2040 * @param {Roo.menu.Menu} this
2045 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
2046 * @param {Roo.menu.Menu} this
2047 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2048 * @param {Roo.EventObject} e
2053 * Fires when the mouse is hovering over this menu
2054 * @param {Roo.menu.Menu} this
2055 * @param {Roo.EventObject} e
2056 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2061 * Fires when the mouse exits this menu
2062 * @param {Roo.menu.Menu} this
2063 * @param {Roo.EventObject} e
2064 * @param {Roo.menu.Item} menuItem The menu item that was clicked
2069 * Fires when a menu item contained in this menu is clicked
2070 * @param {Roo.menu.BaseItem} baseItem The BaseItem that was clicked
2071 * @param {Roo.EventObject} e
2075 this.menuitems = new Roo.util.MixedCollection(false, function(o) { return o.el.id; });
2078 Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, {
2082 triggerEl : false, // is this set by component builder? -- it should really be fetched from parent()???
2085 * @cfg {Boolean} registerMenu True (default) - means that clicking on screen etc. hides it.
2087 registerMenu : true,
2089 menuItems :false, // stores the menu items..
2099 getChildContainer : function() {
2103 getAutoCreate : function(){
2105 //if (['right'].indexOf(this.align)!==-1) {
2106 // cfg.cn[1].cls += ' pull-right'
2112 cls : 'dropdown-menu' ,
2113 style : 'z-index:1000'
2117 if (this.type === 'submenu') {
2118 cfg.cls = 'submenu active';
2120 if (this.type === 'treeview') {
2121 cfg.cls = 'treeview-menu';
2126 initEvents : function() {
2128 // Roo.log("ADD event");
2129 // Roo.log(this.triggerEl.dom);
2131 this.triggerEl.on('click', this.onTriggerClick, this);
2133 this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this);
2136 if (this.triggerEl.hasClass('nav-item')) {
2137 // dropdown toggle on the 'a' in BS4?
2138 this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle');
2140 this.triggerEl.addClass('dropdown-toggle');
2143 this.el.on('touchstart' , this.onTouch, this);
2145 this.el.on('click' , this.onClick, this);
2147 this.el.on("mouseover", this.onMouseOver, this);
2148 this.el.on("mouseout", this.onMouseOut, this);
2152 findTargetItem : function(e)
2154 var t = e.getTarget(".dropdown-menu-item", this.el, true);
2158 //Roo.log(t); Roo.log(t.id);
2160 //Roo.log(this.menuitems);
2161 return this.menuitems.get(t.id);
2163 //return this.items.get(t.menuItemId);
2169 onTouch : function(e)
2171 Roo.log("menu.onTouch");
2172 //e.stopEvent(); this make the user popdown broken
2176 onClick : function(e)
2178 Roo.log("menu.onClick");
2180 var t = this.findTargetItem(e);
2181 if(!t || t.isContainer){
2186 if (Roo.isTouch && e.type == 'touchstart' && t.menu && !t.disabled) {
2187 if(t == this.activeItem && t.shouldDeactivate(e)){
2188 this.activeItem.deactivate();
2189 delete this.activeItem;
2193 this.setActiveItem(t, true);
2201 Roo.log('pass click event');
2205 this.fireEvent("click", this, t, e);
2209 if(!t.href.length || t.href == '#'){
2210 (function() { _this.hide(); }).defer(100);
2215 onMouseOver : function(e){
2216 var t = this.findTargetItem(e);
2219 // if(t.canActivate && !t.disabled){
2220 // this.setActiveItem(t, true);
2224 this.fireEvent("mouseover", this, e, t);
2226 isVisible : function(){
2227 return !this.hidden;
2229 onMouseOut : function(e){
2230 var t = this.findTargetItem(e);
2233 // if(t == this.activeItem && t.shouldDeactivate(e)){
2234 // this.activeItem.deactivate();
2235 // delete this.activeItem;
2238 this.fireEvent("mouseout", this, e, t);
2243 * Displays this menu relative to another element
2244 * @param {String/HTMLElement/Roo.Element} element The element to align to
2245 * @param {String} position (optional) The {@link Roo.Element#alignTo} anchor position to use in aligning to
2246 * the element (defaults to this.defaultAlign)
2247 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2249 show : function(el, pos, parentMenu){
2250 this.parentMenu = parentMenu;
2254 this.fireEvent("beforeshow", this);
2255 this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign), parentMenu, false);
2258 * Displays this menu at a specific xy position
2259 * @param {Array} xyPosition Contains X & Y [x, y] values for the position at which to show the menu (coordinates are page-based)
2260 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2262 showAt : function(xy, parentMenu, /* private: */_e){
2263 this.parentMenu = parentMenu;
2268 this.fireEvent("beforeshow", this);
2269 //xy = this.el.adjustForConstraints(xy);
2273 this.hideMenuItems();
2274 this.hidden = false;
2275 this.triggerEl.addClass('open');
2276 this.el.addClass('show');
2278 // reassign x when hitting right
2279 if(this.el.getWidth() + xy[0] >= Roo.lib.Dom.getViewWidth()){
2280 xy[0] = xy[0] - this.el.getWidth() + this.triggerEl.getWidth();
2283 // reassign y when hitting bottom
2284 if(this.el.getHeight() + xy[1] >= Roo.lib.Dom.getViewHeight()){
2285 xy[1] = xy[1] - this.el.getHeight() - this.triggerEl.getHeight();
2288 // but the list may align on trigger left or trigger top... should it be a properity?
2290 if(this.el.getStyle('top') != 'auto' && this.el.getStyle('top').slice(-1) != "%"){
2295 this.fireEvent("show", this);
2301 this.doFocus.defer(50, this);
2305 doFocus : function(){
2307 this.focusEl.focus();
2312 * Hides this menu and optionally all parent menus
2313 * @param {Boolean} deep (optional) True to hide all parent menus recursively, if any (defaults to false)
2315 hide : function(deep)
2318 this.hideMenuItems();
2319 if(this.el && this.isVisible()){
2320 this.fireEvent("beforehide", this);
2321 if(this.activeItem){
2322 this.activeItem.deactivate();
2323 this.activeItem = null;
2325 this.triggerEl.removeClass('open');;
2326 this.el.removeClass('show');
2328 this.fireEvent("hide", this);
2330 if(deep === true && this.parentMenu){
2331 this.parentMenu.hide(true);
2335 onTriggerClick : function(e)
2337 Roo.log('trigger click');
2339 var target = e.getTarget();
2341 Roo.log(target.nodeName.toLowerCase());
2343 if(target.nodeName.toLowerCase() === 'i'){
2349 onTriggerPress : function(e)
2351 Roo.log('trigger press');
2352 //Roo.log(e.getTarget());
2353 // Roo.log(this.triggerEl.dom);
2355 // trigger only occurs on normal menu's -- if it's a treeview or dropdown... do not hide/show..
2356 var pel = Roo.get(e.getTarget());
2357 if (pel.findParent('.dropdown-menu') || pel.findParent('.treeview-menu') ) {
2358 Roo.log('is treeview or dropdown?');
2362 if(e.getTarget().nodeName.toLowerCase() !== 'i' && this.isLink){
2366 if (this.isVisible()) {
2371 this.show(this.triggerEl, false, false);
2374 if(this.stopEvent || e.getTarget().nodeName.toLowerCase() === 'i'){
2381 hideMenuItems : function()
2383 Roo.log("hide Menu Items");
2387 //$(backdrop).remove()
2388 this.el.select('.open',true).each(function(aa) {
2390 aa.removeClass('open');
2391 //var parent = getParent($(this))
2392 //var relatedTarget = { relatedTarget: this }
2394 //$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
2395 //if (e.isDefaultPrevented()) return
2396 //$parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
2399 addxtypeChild : function (tree, cntr) {
2400 var comp= Roo.bootstrap.Menu.superclass.addxtypeChild.call(this, tree, cntr);
2402 this.menuitems.add(comp);
2414 this.getEl().dom.innerHTML = '';
2415 this.menuitems.clear();
2429 * @class Roo.bootstrap.MenuItem
2430 * @extends Roo.bootstrap.Component
2431 * Bootstrap MenuItem class
2432 * @cfg {String} html the menu label
2433 * @cfg {String} href the link
2434 * @cfg {Boolean} preventDefault do not trigger A href on clicks (default false).
2435 * @cfg {Boolean} isContainer is it a container - just returns a drop down item..
2436 * @cfg {Boolean} active used on sidebars to highlight active itesm
2437 * @cfg {String} fa favicon to show on left of menu item.
2438 * @cfg {Roo.bootsrap.Menu} menu the child menu.
2442 * Create a new MenuItem
2443 * @param {Object} config The config object
2447 Roo.bootstrap.MenuItem = function(config){
2448 Roo.bootstrap.MenuItem.superclass.constructor.call(this, config);
2453 * The raw click event for the entire grid.
2454 * @param {Roo.bootstrap.MenuItem} this
2455 * @param {Roo.EventObject} e
2461 Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component, {
2465 preventDefault: false,
2466 isContainer : false,
2470 getAutoCreate : function(){
2472 if(this.isContainer){
2475 cls: 'dropdown-menu-item dropdown-item'
2489 if (this.fa !== false) {
2492 cls : 'fa fa-' + this.fa
2501 cls: 'dropdown-menu-item dropdown-item',
2504 if (this.parent().type == 'treeview') {
2505 cfg.cls = 'treeview-menu';
2508 cfg.cls += ' active';
2513 anc.href = this.href || cfg.cn[0].href ;
2514 ctag.html = this.html || cfg.cn[0].html ;
2518 initEvents: function()
2520 if (this.parent().type == 'treeview') {
2521 this.el.select('a').on('click', this.onClick, this);
2525 this.menu.parentType = this.xtype;
2526 this.menu.triggerEl = this.el;
2527 this.menu = this.addxtype(Roo.apply({}, this.menu));
2531 onClick : function(e)
2533 Roo.log('item on click ');
2535 if(this.preventDefault){
2538 //this.parent().hideMenuItems();
2540 this.fireEvent('click', this, e);
2559 * @class Roo.bootstrap.MenuSeparator
2560 * @extends Roo.bootstrap.Component
2561 * Bootstrap MenuSeparator class
2564 * Create a new MenuItem
2565 * @param {Object} config The config object
2569 Roo.bootstrap.MenuSeparator = function(config){
2570 Roo.bootstrap.MenuSeparator.superclass.constructor.call(this, config);
2573 Roo.extend(Roo.bootstrap.MenuSeparator, Roo.bootstrap.Component, {
2575 getAutoCreate : function(){
2594 * @class Roo.bootstrap.Modal
2595 * @extends Roo.bootstrap.Component
2596 * Bootstrap Modal class
2597 * @cfg {String} title Title of dialog
2598 * @cfg {String} html - the body of the dialog (for simple ones) - you can also use template..
2599 * @cfg {Roo.Template} tmpl - a template with variables. to use it, add a handler in show:method adn
2600 * @cfg {Boolean} specificTitle default false
2601 * @cfg {Array} buttons Array of buttons or standard button set..
2602 * @cfg {String} buttonPosition (left|right|center) default right
2603 * @cfg {Boolean} animate default true
2604 * @cfg {Boolean} allow_close default true
2605 * @cfg {Boolean} fitwindow default false
2606 * @cfg {String} size (sm|lg) default empty
2607 * @cfg {Number} max_width set the max width of modal
2611 * Create a new Modal Dialog
2612 * @param {Object} config The config object
2615 Roo.bootstrap.Modal = function(config){
2616 Roo.bootstrap.Modal.superclass.constructor.call(this, config);
2621 * The raw btnclick event for the button
2622 * @param {Roo.EventObject} e
2627 * Fire when dialog resize
2628 * @param {Roo.bootstrap.Modal} this
2629 * @param {Roo.EventObject} e
2633 this.buttons = this.buttons || [];
2636 this.tmpl = Roo.factory(this.tmpl);
2641 Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, {
2643 title : 'test dialog',
2653 specificTitle: false,
2655 buttonPosition: 'right',
2678 onRender : function(ct, position)
2680 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
2683 var cfg = Roo.apply({}, this.getAutoCreate());
2686 // cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
2688 //if (!cfg.name.length) {
2692 cfg.cls += ' ' + this.cls;
2695 cfg.style = this.style;
2697 this.el = Roo.get(document.body).createChild(cfg, position);
2699 //var type = this.el.dom.type;
2702 if(this.tabIndex !== undefined){
2703 this.el.dom.setAttribute('tabIndex', this.tabIndex);
2706 this.dialogEl = this.el.select('.modal-dialog',true).first();
2707 this.bodyEl = this.el.select('.modal-body',true).first();
2708 this.closeEl = this.el.select('.modal-header .close', true).first();
2709 this.headerEl = this.el.select('.modal-header',true).first();
2710 this.titleEl = this.el.select('.modal-title',true).first();
2711 this.footerEl = this.el.select('.modal-footer',true).first();
2713 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
2715 //this.el.addClass("x-dlg-modal");
2717 if (this.buttons.length) {
2718 Roo.each(this.buttons, function(bb) {
2719 var b = Roo.apply({}, bb);
2720 b.xns = b.xns || Roo.bootstrap;
2721 b.xtype = b.xtype || 'Button';
2722 if (typeof(b.listeners) == 'undefined') {
2723 b.listeners = { click : this.onButtonClick.createDelegate(this) };
2726 var btn = Roo.factory(b);
2728 btn.render(this.el.select('.modal-footer div').first());
2732 // render the children.
2735 if(typeof(this.items) != 'undefined'){
2736 var items = this.items;
2739 for(var i =0;i < items.length;i++) {
2740 nitems.push(this.addxtype(Roo.apply({}, items[i])));
2744 this.items = nitems;
2746 // where are these used - they used to be body/close/footer
2750 //this.el.addClass([this.fieldClass, this.cls]);
2754 getAutoCreate : function()
2758 html : this.html || ''
2763 cls : 'modal-title',
2767 if(this.specificTitle){
2773 if (this.allow_close && Roo.bootstrap.version == 3) {
2783 if (this.allow_close && Roo.bootstrap.version == 4) {
2793 if(this.size.length){
2794 size = 'modal-' + this.size;
2801 cls: "modal-dialog " + size,
2804 cls : "modal-content",
2807 cls : 'modal-header',
2812 cls : 'modal-footer',
2816 cls: 'btn-' + this.buttonPosition
2833 modal.cls += ' fade';
2839 getChildContainer : function() {
2844 getButtonContainer : function() {
2845 return this.el.select('.modal-footer div',true).first();
2848 initEvents : function()
2850 if (this.allow_close) {
2851 this.closeEl.on('click', this.hide, this);
2853 Roo.EventManager.onWindowResize(this.resize, this, true);
2860 this.maskEl.setSize(
2861 Roo.lib.Dom.getViewWidth(true),
2862 Roo.lib.Dom.getViewHeight(true)
2865 if (this.fitwindow) {
2867 this.width || Roo.lib.Dom.getViewportWidth(true) - 30,
2868 this.height || Roo.lib.Dom.getViewportHeight(true) - 60
2873 if(this.max_width !== 0) {
2875 var w = Math.min(this.max_width, Roo.lib.Dom.getViewportWidth(true) - 30);
2878 this.setSize(w, this.height);
2882 if(this.max_height) {
2883 this.setSize(w,Math.min(
2885 Roo.lib.Dom.getViewportHeight(true) - 60
2891 if(!this.fit_content) {
2892 this.setSize(w, Roo.lib.Dom.getViewportHeight(true) - 60);
2896 this.setSize(w, Math.min(
2898 this.headerEl.getHeight() +
2899 this.footerEl.getHeight() +
2900 this.getChildHeight(this.bodyEl.dom.childNodes),
2901 Roo.lib.Dom.getViewportHeight(true) - 60)
2907 setSize : function(w,h)
2918 if (!this.rendered) {
2922 //this.el.setStyle('display', 'block');
2923 this.el.removeClass('hideing');
2924 this.el.dom.style.display='block';
2926 Roo.get(document.body).addClass('modal-open');
2928 if(this.animate){ // element has 'fade' - so stuff happens after .3s ?- not sure why the delay?
2931 this.el.addClass('show');
2932 this.el.addClass('in');
2935 this.el.addClass('show');
2936 this.el.addClass('in');
2939 // not sure how we can show data in here..
2941 // this.getChildContainer().dom.innerHTML = this.tmpl.applyTemplate(this);
2944 Roo.get(document.body).addClass("x-body-masked");
2946 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
2947 this.maskEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
2948 this.maskEl.dom.style.display = 'block';
2949 this.maskEl.addClass('show');
2954 this.fireEvent('show', this);
2956 // set zindex here - otherwise it appears to be ignored...
2957 this.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
2960 this.items.forEach( function(e) {
2961 e.layout ? e.layout() : false;
2969 if(this.fireEvent("beforehide", this) !== false){
2971 this.maskEl.removeClass('show');
2973 this.maskEl.dom.style.display = '';
2974 Roo.get(document.body).removeClass("x-body-masked");
2975 this.el.removeClass('in');
2976 this.el.select('.modal-dialog', true).first().setStyle('transform','');
2978 if(this.animate){ // why
2979 this.el.addClass('hideing');
2980 this.el.removeClass('show');
2982 if (!this.el.hasClass('hideing')) {
2983 return; // it's been shown again...
2986 this.el.dom.style.display='';
2988 Roo.get(document.body).removeClass('modal-open');
2989 this.el.removeClass('hideing');
2993 this.el.removeClass('show');
2994 this.el.dom.style.display='';
2995 Roo.get(document.body).removeClass('modal-open');
2998 this.fireEvent('hide', this);
3001 isVisible : function()
3004 return this.el.hasClass('show') && !this.el.hasClass('hideing');
3008 addButton : function(str, cb)
3012 var b = Roo.apply({}, { html : str } );
3013 b.xns = b.xns || Roo.bootstrap;
3014 b.xtype = b.xtype || 'Button';
3015 if (typeof(b.listeners) == 'undefined') {
3016 b.listeners = { click : cb.createDelegate(this) };
3019 var btn = Roo.factory(b);
3021 btn.render(this.el.select('.modal-footer div').first());
3027 setDefaultButton : function(btn)
3029 //this.el.select('.modal-footer').()
3033 resizeTo: function(w,h)
3037 this.dialogEl.setWidth(w);
3038 if (this.diff === false) {
3039 this.diff = this.dialogEl.getHeight() - this.bodyEl.getHeight();
3042 this.bodyEl.setHeight(h - this.diff);
3044 this.fireEvent('resize', this);
3047 setContentSize : function(w, h)
3051 onButtonClick: function(btn,e)
3054 this.fireEvent('btnclick', btn.name, e);
3057 * Set the title of the Dialog
3058 * @param {String} str new Title
3060 setTitle: function(str) {
3061 this.titleEl.dom.innerHTML = str;
3064 * Set the body of the Dialog
3065 * @param {String} str new Title
3067 setBody: function(str) {
3068 this.bodyEl.dom.innerHTML = str;
3071 * Set the body of the Dialog using the template
3072 * @param {Obj} data - apply this data to the template and replace the body contents.
3074 applyBody: function(obj)
3077 Roo.log("Error - using apply Body without a template");
3080 this.tmpl.overwrite(this.bodyEl, obj);
3083 getChildHeight : function(child_nodes)
3087 child_nodes.length == 0
3092 var child_height = 0;
3094 for(var i = 0; i < child_nodes.length; i++) {
3097 * for modal with tabs...
3098 if(child_nodes[i].classList.contains('roo-layout-panel')) {
3100 var layout_childs = child_nodes[i].childNodes;
3102 for(var j = 0; j < layout_childs.length; j++) {
3104 if(layout_childs[j].classList.contains('roo-layout-panel-body')) {
3106 var layout_body_childs = layout_childs[j].childNodes;
3108 for(var k = 0; k < layout_body_childs.length; k++) {
3110 if(layout_body_childs[k].classList.contains('navbar')) {
3111 child_height += layout_body_childs[k].offsetHeight;
3115 if(layout_body_childs[k].classList.contains('roo-layout-tabs-body')) {
3117 var layout_body_tab_childs = layout_body_childs[k].childNodes;
3119 for(var m = 0; m < layout_body_tab_childs.length; m++) {
3121 if(layout_body_tab_childs[m].classList.contains('roo-layout-active-content')) {
3122 child_height += this.getChildHeight(layout_body_tab_childs[m].childNodes);
3137 child_height += child_nodes[i].offsetHeight;
3138 // Roo.log(child_nodes[i].offsetHeight);
3141 return child_height;
3147 Roo.apply(Roo.bootstrap.Modal, {
3149 * Button config that displays a single OK button
3158 * Button config that displays Yes and No buttons
3174 * Button config that displays OK and Cancel buttons
3189 * Button config that displays Yes, No and Cancel buttons
3213 * messagebox - can be used as a replace
3217 * @class Roo.MessageBox
3218 * Utility class for generating different styles of message boxes. The alias Roo.Msg can also be used.
3222 Roo.Msg.alert('Status', 'Changes saved successfully.');
3224 // Prompt for user data:
3225 Roo.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
3227 // process text value...
3231 // Show a dialog using config options:
3233 title:'Save Changes?',
3234 msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',
3235 buttons: Roo.Msg.YESNOCANCEL,
3242 Roo.bootstrap.MessageBox = function(){
3243 var dlg, opt, mask, waitTimer;
3244 var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp;
3245 var buttons, activeTextEl, bwidth;
3249 var handleButton = function(button){
3251 Roo.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
3255 var handleHide = function(){
3257 dlg.el.removeClass(opt.cls);
3260 // Roo.TaskMgr.stop(waitTimer);
3261 // waitTimer = null;
3266 var updateButtons = function(b){
3269 buttons["ok"].hide();
3270 buttons["cancel"].hide();
3271 buttons["yes"].hide();
3272 buttons["no"].hide();
3273 //dlg.footer.dom.style.display = 'none';
3276 dlg.footerEl.dom.style.display = '';
3277 for(var k in buttons){
3278 if(typeof buttons[k] != "function"){
3281 buttons[k].setText(typeof b[k] == "string" ? b[k] : Roo.bootstrap.MessageBox.buttonText[k]);
3282 width += buttons[k].el.getWidth()+15;
3292 var handleEsc = function(d, k, e){
3293 if(opt && opt.closable !== false){
3303 * Returns a reference to the underlying {@link Roo.BasicDialog} element
3304 * @return {Roo.BasicDialog} The BasicDialog element
3306 getDialog : function(){
3308 dlg = new Roo.bootstrap.Modal( {
3311 //constraintoviewport:false,
3313 //collapsible : false,
3318 //buttonAlign:"center",
3319 closeClick : function(){
3320 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
3323 handleButton("cancel");
3328 dlg.on("hide", handleHide);
3330 //dlg.addKeyListener(27, handleEsc);
3332 this.buttons = buttons;
3333 var bt = this.buttonText;
3334 buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
3335 buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
3336 buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
3337 buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
3339 bodyEl = dlg.bodyEl.createChild({
3341 html:'<span class="roo-mb-text"></span><br /><input type="text" class="roo-mb-input" />' +
3342 '<textarea class="roo-mb-textarea"></textarea>' +
3343 '<div class="roo-mb-progress-wrap"><div class="roo-mb-progress"><div class="roo-mb-progress-bar"> </div></div></div>'
3345 msgEl = bodyEl.dom.firstChild;
3346 textboxEl = Roo.get(bodyEl.dom.childNodes[2]);
3347 textboxEl.enableDisplayMode();
3348 textboxEl.addKeyListener([10,13], function(){
3349 if(dlg.isVisible() && opt && opt.buttons){
3352 }else if(opt.buttons.yes){
3353 handleButton("yes");
3357 textareaEl = Roo.get(bodyEl.dom.childNodes[3]);
3358 textareaEl.enableDisplayMode();
3359 progressEl = Roo.get(bodyEl.dom.childNodes[4]);
3360 progressEl.enableDisplayMode();
3362 // This is supposed to be the progessElement.. but I think it's controlling the height of everything..
3363 var pf = progressEl.dom.firstChild;
3365 pp = Roo.get(pf.firstChild);
3366 pp.setHeight(pf.offsetHeight);
3374 * Updates the message box body text
3375 * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
3376 * the XHTML-compliant non-breaking space character '&#160;')
3377 * @return {Roo.MessageBox} This message box
3379 updateText : function(text)
3381 if(!dlg.isVisible() && !opt.width){
3382 dlg.dialogEl.setStyle({ 'max-width' : this.maxWidth});
3383 // dlg.resizeTo(this.maxWidth, 100); // forcing the height breaks long alerts()
3385 msgEl.innerHTML = text || ' ';
3387 var cw = Math.max(msgEl.offsetWidth, msgEl.parentNode.scrollWidth);
3388 //Roo.log("guesed size: " + JSON.stringify([cw,msgEl.offsetWidth, msgEl.parentNode.scrollWidth]));
3390 Math.min(opt.width || cw , this.maxWidth),
3391 Math.max(opt.minWidth || this.minWidth, bwidth)
3394 activeTextEl.setWidth(w);
3396 if(dlg.isVisible()){
3397 dlg.fixedcenter = false;
3399 // to big, make it scroll. = But as usual stupid IE does not support
3402 if ( bodyEl.getHeight() > (Roo.lib.Dom.getViewHeight() - 100)) {
3403 bodyEl.setHeight ( Roo.lib.Dom.getViewHeight() - 100 );
3404 bodyEl.dom.style.overflowY = 'auto' + ( Roo.isIE ? '' : ' !important');
3406 bodyEl.dom.style.height = '';
3407 bodyEl.dom.style.overflowY = '';
3410 bodyEl.dom.style.get = 'auto' + ( Roo.isIE ? '' : ' !important');
3412 bodyEl.dom.style.overflowX = '';
3415 dlg.setContentSize(w, bodyEl.getHeight());
3416 if(dlg.isVisible()){
3417 dlg.fixedcenter = true;
3423 * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
3424 * initiated via {@link Roo.MessageBox#progress} or by calling {@link Roo.MessageBox#show} with progress: true.
3425 * @param {Number} value Any number between 0 and 1 (e.g., .5)
3426 * @param {String} text (optional) If defined, the message box's body text is replaced with the specified string (defaults to undefined)
3427 * @return {Roo.MessageBox} This message box
3429 updateProgress : function(value, text){
3431 this.updateText(text);
3434 if (pp) { // weird bug on my firefox - for some reason this is not defined
3435 pp.setWidth(Math.floor(value*progressEl.dom.firstChild.offsetWidth));
3436 pp.setHeight(Math.floor(progressEl.dom.firstChild.offsetHeight));
3442 * Returns true if the message box is currently displayed
3443 * @return {Boolean} True if the message box is visible, else false
3445 isVisible : function(){
3446 return dlg && dlg.isVisible();
3450 * Hides the message box if it is displayed
3453 if(this.isVisible()){
3459 * Displays a new message box, or reinitializes an existing message box, based on the config options
3460 * passed in. All functions (e.g. prompt, alert, etc) on MessageBox call this function internally.
3461 * The following config object properties are supported:
3463 Property Type Description
3464 ---------- --------------- ------------------------------------------------------------------------------------
3465 animEl String/Element An id or Element from which the message box should animate as it opens and
3466 closes (defaults to undefined)
3467 buttons Object/Boolean A button config object (e.g., Roo.MessageBox.OKCANCEL or {ok:'Foo',
3468 cancel:'Bar'}), or false to not show any buttons (defaults to false)
3469 closable Boolean False to hide the top-right close button (defaults to true). Note that
3470 progress and wait dialogs will ignore this property and always hide the
3471 close button as they can only be closed programmatically.
3472 cls String A custom CSS class to apply to the message box element
3473 defaultTextHeight Number The default height in pixels of the message box's multiline textarea if
3474 displayed (defaults to 75)
3475 fn Function A callback function to execute after closing the dialog. The arguments to the
3476 function will be btn (the name of the button that was clicked, if applicable,
3477 e.g. "ok"), and text (the value of the active text field, if applicable).
3478 Progress and wait dialogs will ignore this option since they do not respond to
3479 user actions and can only be closed programmatically, so any required function
3480 should be called by the same code after it closes the dialog.
3481 icon String A CSS class that provides a background image to be used as an icon for
3482 the dialog (e.g., Roo.MessageBox.WARNING or 'custom-class', defaults to '')
3483 maxWidth Number The maximum width in pixels of the message box (defaults to 600)
3484 minWidth Number The minimum width in pixels of the message box (defaults to 100)
3485 modal Boolean False to allow user interaction with the page while the message box is
3486 displayed (defaults to true)
3487 msg String A string that will replace the existing message box body text (defaults
3488 to the XHTML-compliant non-breaking space character ' ')
3489 multiline Boolean True to prompt the user to enter multi-line text (defaults to false)
3490 progress Boolean True to display a progress bar (defaults to false)
3491 progressText String The text to display inside the progress bar if progress = true (defaults to '')
3492 prompt Boolean True to prompt the user to enter single-line text (defaults to false)
3493 proxyDrag Boolean True to display a lightweight proxy while dragging (defaults to false)
3494 title String The title text
3495 value String The string value to set into the active textbox element if displayed
3496 wait Boolean True to display a progress bar (defaults to false)
3497 width Number The width of the dialog in pixels
3504 msg: 'Please enter your address:',
3506 buttons: Roo.MessageBox.OKCANCEL,
3509 animEl: 'addAddressBtn'
3512 * @param {Object} config Configuration options
3513 * @return {Roo.MessageBox} This message box
3515 show : function(options)
3518 // this causes nightmares if you show one dialog after another
3519 // especially on callbacks..
3521 if(this.isVisible()){
3524 Roo.log("[Roo.Messagebox] Show called while message displayed:" );
3525 Roo.log("Old Dialog Message:" + msgEl.innerHTML );
3526 Roo.log("New Dialog Message:" + options.msg )
3527 //this.alert("ERROR", "Multiple dialogs where displayed at the same time");
3528 //throw "Roo.MessageBox ERROR : Multiple dialogs where displayed at the same time";
3531 var d = this.getDialog();
3533 d.setTitle(opt.title || " ");
3534 d.closeEl.setDisplayed(opt.closable !== false);
3535 activeTextEl = textboxEl;
3536 opt.prompt = opt.prompt || (opt.multiline ? true : false);
3541 textareaEl.setHeight(typeof opt.multiline == "number" ?
3542 opt.multiline : this.defaultTextHeight);
3543 activeTextEl = textareaEl;
3552 progressEl.setDisplayed(opt.progress === true);
3553 this.updateProgress(0);
3554 activeTextEl.dom.value = opt.value || "";
3556 dlg.setDefaultButton(activeTextEl);
3558 var bs = opt.buttons;
3562 }else if(bs && bs.yes){
3563 db = buttons["yes"];
3565 dlg.setDefaultButton(db);
3567 bwidth = updateButtons(opt.buttons);
3568 this.updateText(opt.msg);
3570 d.el.addClass(opt.cls);
3572 d.proxyDrag = opt.proxyDrag === true;
3573 d.modal = opt.modal !== false;
3574 d.mask = opt.modal !== false ? mask : false;
3576 // force it to the end of the z-index stack so it gets a cursor in FF
3577 document.body.appendChild(dlg.el.dom);
3578 d.animateTarget = null;
3579 d.show(options.animEl);
3585 * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
3586 * the user. You are responsible for updating the progress bar as needed via {@link Roo.MessageBox#updateProgress}
3587 * and closing the message box when the process is complete.
3588 * @param {String} title The title bar text
3589 * @param {String} msg The message box body text
3590 * @return {Roo.MessageBox} This message box
3592 progress : function(title, msg){
3599 minWidth: this.minProgressWidth,
3606 * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
3607 * If a callback function is passed it will be called after the user clicks the button, and the
3608 * id of the button that was clicked will be passed as the only parameter to the callback
3609 * (could also be the top-right close button).
3610 * @param {String} title The title bar text
3611 * @param {String} msg The message box body text
3612 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3613 * @param {Object} scope (optional) The scope of the callback function
3614 * @return {Roo.MessageBox} This message box
3616 alert : function(title, msg, fn, scope)
3631 * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
3632 * interaction while waiting for a long-running process to complete that does not have defined intervals.
3633 * You are responsible for closing the message box when the process is complete.
3634 * @param {String} msg The message box body text
3635 * @param {String} title (optional) The title bar text
3636 * @return {Roo.MessageBox} This message box
3638 wait : function(msg, title){
3649 waitTimer = Roo.TaskMgr.start({
3651 Roo.MessageBox.updateProgress(((((i+20)%20)+1)*5)*.01);
3659 * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
3660 * If a callback function is passed it will be called after the user clicks either button, and the id of the
3661 * button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
3662 * @param {String} title The title bar text
3663 * @param {String} msg The message box body text
3664 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3665 * @param {Object} scope (optional) The scope of the callback function
3666 * @return {Roo.MessageBox} This message box
3668 confirm : function(title, msg, fn, scope){
3672 buttons: this.YESNO,
3681 * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to
3682 * JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function
3683 * is passed it will be called after the user clicks either button, and the id of the button that was clicked
3684 * (could also be the top-right close button) and the text that was entered will be passed as the two
3685 * parameters to the callback.
3686 * @param {String} title The title bar text
3687 * @param {String} msg The message box body text
3688 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3689 * @param {Object} scope (optional) The scope of the callback function
3690 * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
3691 * property, or the height in pixels to create the textbox (defaults to false / single-line)
3692 * @return {Roo.MessageBox} This message box
3694 prompt : function(title, msg, fn, scope, multiline){
3698 buttons: this.OKCANCEL,
3703 multiline: multiline,
3710 * Button config that displays a single OK button
3715 * Button config that displays Yes and No buttons
3718 YESNO : {yes:true, no:true},
3720 * Button config that displays OK and Cancel buttons
3723 OKCANCEL : {ok:true, cancel:true},
3725 * Button config that displays Yes, No and Cancel buttons
3728 YESNOCANCEL : {yes:true, no:true, cancel:true},
3731 * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
3734 defaultTextHeight : 75,
3736 * The maximum width in pixels of the message box (defaults to 600)
3741 * The minimum width in pixels of the message box (defaults to 100)
3746 * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
3747 * for setting a different minimum width than text-only dialogs may need (defaults to 250)
3750 minProgressWidth : 250,
3752 * An object containing the default button text strings that can be overriden for localized language support.
3753 * Supported properties are: ok, cancel, yes and no.
3754 * Customize the default text like so: Roo.MessageBox.buttonText.yes = "S?";
3767 * Shorthand for {@link Roo.MessageBox}
3769 Roo.MessageBox = Roo.MessageBox || Roo.bootstrap.MessageBox;
3770 Roo.Msg = Roo.Msg || Roo.MessageBox;
3779 * @class Roo.bootstrap.Navbar
3780 * @extends Roo.bootstrap.Component
3781 * Bootstrap Navbar class
3784 * Create a new Navbar
3785 * @param {Object} config The config object
3789 Roo.bootstrap.Navbar = function(config){
3790 Roo.bootstrap.Navbar.superclass.constructor.call(this, config);
3794 * @event beforetoggle
3795 * Fire before toggle the menu
3796 * @param {Roo.EventObject} e
3798 "beforetoggle" : true
3802 Roo.extend(Roo.bootstrap.Navbar, Roo.bootstrap.Component, {
3811 getAutoCreate : function(){
3814 throw { message : "nav bar is now a abstract base class - use NavSimplebar / NavHeaderbar / NavSidebar etc..."};
3818 initEvents :function ()
3820 //Roo.log(this.el.select('.navbar-toggle',true));
3821 this.el.select('.navbar-toggle',true).on('click', function() {
3822 if(this.fireEvent('beforetoggle', this) !== false){
3823 this.el.select('.navbar-collapse',true).toggleClass('in');
3833 this.maskEl = Roo.DomHelper.append(this.el, mark, true);
3835 var size = this.el.getSize();
3836 this.maskEl.setSize(size.width, size.height);
3837 this.maskEl.enableDisplayMode("block");
3846 getChildContainer : function()
3848 if (this.el.select('.collapse').getCount()) {
3849 return this.el.select('.collapse',true).first();
3882 * @class Roo.bootstrap.NavSimplebar
3883 * @extends Roo.bootstrap.Navbar
3884 * Bootstrap Sidebar class
3886 * @cfg {Boolean} inverse is inverted color
3888 * @cfg {String} type (nav | pills | tabs)
3889 * @cfg {Boolean} arrangement stacked | justified
3890 * @cfg {String} align (left | right) alignment
3892 * @cfg {Boolean} main (true|false) main nav bar? default false
3893 * @cfg {Boolean} loadMask (true|false) loadMask on the bar
3895 * @cfg {String} tag (header|footer|nav|div) default is nav
3901 * Create a new Sidebar
3902 * @param {Object} config The config object
3906 Roo.bootstrap.NavSimplebar = function(config){
3907 Roo.bootstrap.NavSimplebar.superclass.constructor.call(this, config);
3910 Roo.extend(Roo.bootstrap.NavSimplebar, Roo.bootstrap.Navbar, {
3926 getAutoCreate : function(){
3930 tag : this.tag || 'div',
3943 this.type = this.type || 'nav';
3944 if (['tabs','pills'].indexOf(this.type)!==-1) {
3945 cfg.cn[0].cls += ' nav-' + this.type
3949 if (this.type!=='nav') {
3950 Roo.log('nav type must be nav/tabs/pills')
3952 cfg.cn[0].cls += ' navbar-nav'
3958 if (['stacked','justified'].indexOf(this.arrangement)!==-1) {
3959 cfg.cn[0].cls += ' nav-' + this.arrangement;
3963 if (this.align === 'right') {
3964 cfg.cn[0].cls += ' navbar-right';
3968 cfg.cls += ' navbar-inverse';
3992 * navbar-expand-md fixed-top
3996 * @class Roo.bootstrap.NavHeaderbar
3997 * @extends Roo.bootstrap.NavSimplebar
3998 * Bootstrap Sidebar class
4000 * @cfg {String} brand what is brand
4001 * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
4002 * @cfg {String} brand_href href of the brand
4003 * @cfg {Boolean} srButton generate the (screen reader / mobile) sr-only button default true
4004 * @cfg {Boolean} autohide a top nav bar header that hides on scroll.
4005 * @cfg {Boolean} desktopCenter should the header be centered on desktop using a container class
4006 * @cfg {Roo.bootstrap.Row} mobilerow - a row to display on mobile only..
4009 * Create a new Sidebar
4010 * @param {Object} config The config object
4014 Roo.bootstrap.NavHeaderbar = function(config){
4015 Roo.bootstrap.NavHeaderbar.superclass.constructor.call(this, config);
4019 Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar, {
4026 desktopCenter : false,
4029 getAutoCreate : function(){
4032 tag: this.nav || 'nav',
4033 cls: 'navbar navbar-expand-md',
4039 if (this.desktopCenter) {
4040 cn.push({cls : 'container', cn : []});
4047 cls: 'navbar-header',
4052 cls: 'navbar-toggle navbar-toggler',
4053 'data-toggle': 'collapse',
4058 html: 'Toggle navigation'
4062 cls: 'icon-bar navbar-toggler-icon'
4080 cls: 'collapse navbar-collapse',
4084 cfg.cls += this.inverse ? ' navbar-inverse navbar-dark bg-dark' : ' navbar-default';
4086 if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
4087 cfg.cls += ' navbar-' + this.position + ' ' + this.position ;
4089 // tag can override this..
4091 cfg.tag = this.tag || (this.position == 'fixed-bottom' ? 'footer' : 'header');
4094 if (this.brand !== '') {
4097 href: this.brand_href ? this.brand_href : '#',
4098 cls: 'navbar-brand',
4106 cfg.cls += ' main-nav';
4114 getHeaderChildContainer : function()
4116 if (this.srButton && this.el.select('.navbar-header').getCount()) {
4117 return this.el.select('.navbar-header',true).first();
4120 return this.getChildContainer();
4124 initEvents : function()
4126 Roo.bootstrap.NavHeaderbar.superclass.initEvents.call(this);
4128 if (this.autohide) {
4133 Roo.get(document).on('scroll',function(e) {
4134 var ns = Roo.get(document).getScroll().top;
4135 var os = prevScroll;
4139 ft.removeClass('slideDown');
4140 ft.addClass('slideUp');
4143 ft.removeClass('slideUp');
4144 ft.addClass('slideDown');
4165 * @class Roo.bootstrap.NavSidebar
4166 * @extends Roo.bootstrap.Navbar
4167 * Bootstrap Sidebar class
4170 * Create a new Sidebar
4171 * @param {Object} config The config object
4175 Roo.bootstrap.NavSidebar = function(config){
4176 Roo.bootstrap.NavSidebar.superclass.constructor.call(this, config);
4179 Roo.extend(Roo.bootstrap.NavSidebar, Roo.bootstrap.Navbar, {
4181 sidebar : true, // used by Navbar Item and NavbarGroup at present...
4183 getAutoCreate : function(){
4188 cls: 'sidebar sidebar-nav'
4210 * @class Roo.bootstrap.NavGroup
4211 * @extends Roo.bootstrap.Component
4212 * Bootstrap NavGroup class
4213 * @cfg {String} align (left|right)
4214 * @cfg {Boolean} inverse
4215 * @cfg {String} type (nav|pills|tab) default nav
4216 * @cfg {String} navId - reference Id for navbar.
4220 * Create a new nav group
4221 * @param {Object} config The config object
4224 Roo.bootstrap.NavGroup = function(config){
4225 Roo.bootstrap.NavGroup.superclass.constructor.call(this, config);
4228 Roo.bootstrap.NavGroup.register(this);
4232 * Fires when the active item changes
4233 * @param {Roo.bootstrap.NavGroup} this
4234 * @param {Roo.bootstrap.Navbar.Item} selected The item selected
4235 * @param {Roo.bootstrap.Navbar.Item} prev The previously selected item
4242 Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, {
4253 getAutoCreate : function()
4255 var cfg = Roo.apply({}, Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));
4262 if (['tabs','pills'].indexOf(this.type)!==-1) {
4263 cfg.cls += ' nav-' + this.type
4265 if (this.type!=='nav') {
4266 Roo.log('nav type must be nav/tabs/pills')
4268 cfg.cls += ' navbar-nav'
4271 if (this.parent() && this.parent().sidebar) {
4274 cls: 'dashboard-menu sidebar-menu'
4280 if (this.form === true) {
4286 if (this.align === 'right') {
4287 cfg.cls += ' navbar-right ml-md-auto';
4289 cfg.cls += ' navbar-left';
4293 if (this.align === 'right') {
4294 cfg.cls += ' navbar-right ml-md-auto';
4296 cfg.cls += ' mr-auto';
4300 cfg.cls += ' navbar-inverse';
4308 * sets the active Navigation item
4309 * @param {Roo.bootstrap.NavItem} the new current navitem
4311 setActiveItem : function(item)
4314 Roo.each(this.navItems, function(v){
4319 v.setActive(false, true);
4326 item.setActive(true, true);
4327 this.fireEvent('changed', this, item, prev);
4332 * gets the active Navigation item
4333 * @return {Roo.bootstrap.NavItem} the current navitem
4335 getActive : function()
4339 Roo.each(this.navItems, function(v){
4350 indexOfNav : function()
4354 Roo.each(this.navItems, function(v,i){
4365 * adds a Navigation item
4366 * @param {Roo.bootstrap.NavItem} the navitem to add
4368 addItem : function(cfg)
4370 var cn = new Roo.bootstrap.NavItem(cfg);
4372 cn.parentId = this.id;
4373 cn.onRender(this.el, null);
4377 * register a Navigation item
4378 * @param {Roo.bootstrap.NavItem} the navitem to add
4380 register : function(item)
4382 this.navItems.push( item);
4383 item.navId = this.navId;
4388 * clear all the Navigation item
4391 clearAll : function()
4394 this.el.dom.innerHTML = '';
4397 getNavItem: function(tabId)
4400 Roo.each(this.navItems, function(e) {
4401 if (e.tabId == tabId) {
4411 setActiveNext : function()
4413 var i = this.indexOfNav(this.getActive());
4414 if (i > this.navItems.length) {
4417 this.setActiveItem(this.navItems[i+1]);
4419 setActivePrev : function()
4421 var i = this.indexOfNav(this.getActive());
4425 this.setActiveItem(this.navItems[i-1]);
4427 clearWasActive : function(except) {
4428 Roo.each(this.navItems, function(e) {
4429 if (e.tabId != except.tabId && e.was_active) {
4430 e.was_active = false;
4437 getWasActive : function ()
4440 Roo.each(this.navItems, function(e) {
4455 Roo.apply(Roo.bootstrap.NavGroup, {
4459 * register a Navigation Group
4460 * @param {Roo.bootstrap.NavGroup} the navgroup to add
4462 register : function(navgrp)
4464 this.groups[navgrp.navId] = navgrp;
4468 * fetch a Navigation Group based on the navigation ID
4469 * @param {string} the navgroup to add
4470 * @returns {Roo.bootstrap.NavGroup} the navgroup
4472 get: function(navId) {
4473 if (typeof(this.groups[navId]) == 'undefined') {
4475 //this.register(new Roo.bootstrap.NavGroup({ navId : navId }));
4477 return this.groups[navId] ;
4492 * @class Roo.bootstrap.NavItem
4493 * @extends Roo.bootstrap.Component
4494 * Bootstrap Navbar.NavItem class
4495 * @cfg {String} href link to
4496 * @cfg {String} html content of button
4497 * @cfg {String} badge text inside badge
4498 * @cfg {String} badgecls (bg-green|bg-red|bg-yellow)the extra classes for the badge
4499 * @cfg {String} glyphicon name of glyphicon
4500 * @cfg {String} icon name of font awesome icon
4501 * @cfg {Boolean} active Is item active
4502 * @cfg {Boolean} disabled Is item disabled
4504 * @cfg {Boolean} preventDefault (true | false) default false
4505 * @cfg {String} tabId the tab that this item activates.
4506 * @cfg {String} tagtype (a|span) render as a href or span?
4507 * @cfg {Boolean} animateRef (true|false) link to element default false
4510 * Create a new Navbar Item
4511 * @param {Object} config The config object
4513 Roo.bootstrap.NavItem = function(config){
4514 Roo.bootstrap.NavItem.superclass.constructor.call(this, config);
4519 * The raw click event for the entire grid.
4520 * @param {Roo.EventObject} e
4525 * Fires when the active item active state changes
4526 * @param {Roo.bootstrap.NavItem} this
4527 * @param {boolean} state the new state
4533 * Fires when scroll to element
4534 * @param {Roo.bootstrap.NavItem} this
4535 * @param {Object} options
4536 * @param {Roo.EventObject} e
4544 Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, {
4552 preventDefault : false,
4559 getAutoCreate : function(){
4568 cfg.cls = typeof(cfg.cls) == 'undefined' ? 'active' : cfg.cls + ' active';
4570 if (this.disabled) {
4571 cfg.cls += ' disabled';
4574 if (this.href || this.html || this.glyphicon || this.icon) {
4578 href : this.href || "#",
4579 html: this.html || ''
4582 if (this.tagtype == 'a') {
4583 cfg.cn[0].cls = 'nav-link';
4586 cfg.cn[0].html = '<i class="'+this.icon+'"></i> <span>' + cfg.cn[0].html + '</span>'
4589 if(this.glyphicon) {
4590 cfg.cn[0].html = '<span class="glyphicon glyphicon-' + this.glyphicon + '"></span> ' + cfg.cn[0].html;
4595 cfg.cn[0].html += " <span class='caret'></span>";
4599 if (this.badge !== '') {
4601 cfg.cn[0].html += ' <span class="badge badge-secondary">' + this.badge + '</span>';
4609 initEvents: function()
4611 if (typeof (this.menu) != 'undefined') {
4612 this.menu.parentType = this.xtype;
4613 this.menu.triggerEl = this.el;
4614 this.menu = this.addxtype(Roo.apply({}, this.menu));
4617 this.el.select('a',true).on('click', this.onClick, this);
4619 if(this.tagtype == 'span'){
4620 this.el.select('span',true).on('click', this.onClick, this);
4623 // at this point parent should be available..
4624 this.parent().register(this);
4627 onClick : function(e)
4629 if (e.getTarget('.dropdown-menu-item')) {
4630 // did you click on a menu itemm.... - then don't trigger onclick..
4635 this.preventDefault ||
4638 Roo.log("NavItem - prevent Default?");
4642 if (this.disabled) {
4646 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4647 if (tg && tg.transition) {
4648 Roo.log("waiting for the transitionend");
4654 //Roo.log("fire event clicked");
4655 if(this.fireEvent('click', this, e) === false){
4659 if(this.tagtype == 'span'){
4663 //Roo.log(this.href);
4664 var ael = this.el.select('a',true).first();
4667 if(ael && this.animateRef && this.href.indexOf('#') > -1){
4668 //Roo.log(["test:",ael.dom.href.split("#")[0], document.location.toString().split("#")[0]]);
4669 if (ael.dom.href.split("#")[0] != document.location.toString().split("#")[0]) {
4670 return; // ignore... - it's a 'hash' to another page.
4672 Roo.log("NavItem - prevent Default?");
4674 this.scrollToElement(e);
4678 var p = this.parent();
4680 if (['tabs','pills'].indexOf(p.type)!==-1) {
4681 if (typeof(p.setActiveItem) !== 'undefined') {
4682 p.setActiveItem(this);
4686 // if parent is a navbarheader....- and link is probably a '#' page ref.. then remove the expanded menu.
4687 if (p.parentType == 'NavHeaderbar' && !this.menu) {
4688 // remove the collapsed menu expand...
4689 p.parent().el.select('.navbar-collapse',true).removeClass('in');
4693 isActive: function () {
4696 setActive : function(state, fire, is_was_active)
4698 if (this.active && !state && this.navId) {
4699 this.was_active = true;
4700 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4702 nv.clearWasActive(this);
4706 this.active = state;
4709 this.el.removeClass('active');
4710 } else if (!this.el.hasClass('active')) {
4711 this.el.addClass('active');
4714 this.fireEvent('changed', this, state);
4717 // show a panel if it's registered and related..
4719 if (!this.navId || !this.tabId || !state || is_was_active) {
4723 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4727 var pan = tg.getPanelByName(this.tabId);
4731 // if we can not flip to new panel - go back to old nav highlight..
4732 if (false == tg.showPanel(pan)) {
4733 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4735 var onav = nv.getWasActive();
4737 onav.setActive(true, false, true);
4746 // this should not be here...
4747 setDisabled : function(state)
4749 this.disabled = state;
4751 this.el.removeClass('disabled');
4752 } else if (!this.el.hasClass('disabled')) {
4753 this.el.addClass('disabled');
4759 * Fetch the element to display the tooltip on.
4760 * @return {Roo.Element} defaults to this.el
4762 tooltipEl : function()
4764 return this.el.select('' + this.tagtype + '', true).first();
4767 scrollToElement : function(e)
4769 var c = document.body;
4772 * Firefox / IE places the overflow at the html level, unless specifically styled to behave differently.
4774 if(Roo.isFirefox || Roo.isIE || Roo.isIE11){
4775 c = document.documentElement;
4778 var target = Roo.get(c).select('a[name=' + this.href.split('#')[1] +']', true).first();
4784 var o = target.calcOffsetsTo(c);
4791 this.fireEvent('scrollto', this, options, e);
4793 Roo.get(c).scrollTo('top', options.value, true);
4806 * <span> icon </span>
4807 * <span> text </span>
4808 * <span>badge </span>
4812 * @class Roo.bootstrap.NavSidebarItem
4813 * @extends Roo.bootstrap.NavItem
4814 * Bootstrap Navbar.NavSidebarItem class
4815 * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
4816 * {Boolean} open is the menu open
4817 * {Boolean} buttonView use button as the tigger el rather that a (default false)
4818 * {String} buttonWeight (default|primary|success|info|warning|danger)the extra classes for the button
4819 * {String} buttonSize (sm|md|lg)the extra classes for the button
4820 * {Boolean} showArrow show arrow next to the text (default true)
4822 * Create a new Navbar Button
4823 * @param {Object} config The config object
4825 Roo.bootstrap.NavSidebarItem = function(config){
4826 Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this, config);
4831 * The raw click event for the entire grid.
4832 * @param {Roo.EventObject} e
4837 * Fires when the active item active state changes
4838 * @param {Roo.bootstrap.NavSidebarItem} this
4839 * @param {boolean} state the new state
4847 Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem, {
4849 badgeWeight : 'default',
4855 buttonWeight : 'default',
4861 getAutoCreate : function(){
4866 href : this.href || '#',
4872 if(this.buttonView){
4875 href : this.href || '#',
4876 cls: 'btn btn-' + this.buttonWeight + ' btn-' + this.buttonSize + 'roo-button-dropdown-toggle',
4889 cfg.cls += ' active';
4892 if (this.disabled) {
4893 cfg.cls += ' disabled';
4896 cfg.cls += ' open x-open';
4899 if (this.glyphicon || this.icon) {
4900 var c = this.glyphicon ? ('glyphicon glyphicon-'+this.glyphicon) : this.icon;
4901 a.cn.push({ tag : 'i', cls : c }) ;
4904 if(!this.buttonView){
4907 html : this.html || ''
4914 if (this.badge !== '') {
4915 a.cn.push({ tag: 'span', cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge });
4921 a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
4924 a.cls += ' dropdown-toggle treeview' ;
4930 initEvents : function()
4932 if (typeof (this.menu) != 'undefined') {
4933 this.menu.parentType = this.xtype;
4934 this.menu.triggerEl = this.el;
4935 this.menu = this.addxtype(Roo.apply({}, this.menu));
4938 this.el.on('click', this.onClick, this);
4940 if(this.badge !== ''){
4941 this.badgeEl = this.el.select('.badge', true).first().setVisibilityMode(Roo.Element.DISPLAY);
4946 onClick : function(e)
4953 if(this.preventDefault){
4957 this.fireEvent('click', this);
4960 disable : function()
4962 this.setDisabled(true);
4967 this.setDisabled(false);
4970 setDisabled : function(state)
4972 if(this.disabled == state){
4976 this.disabled = state;
4979 this.el.addClass('disabled');
4983 this.el.removeClass('disabled');
4988 setActive : function(state)
4990 if(this.active == state){
4994 this.active = state;
4997 this.el.addClass('active');
5001 this.el.removeClass('active');
5006 isActive: function ()
5011 setBadge : function(str)
5017 this.badgeEl.dom.innerHTML = str;
5034 * @class Roo.bootstrap.Row
5035 * @extends Roo.bootstrap.Component
5036 * Bootstrap Row class (contains columns...)
5040 * @param {Object} config The config object
5043 Roo.bootstrap.Row = function(config){
5044 Roo.bootstrap.Row.superclass.constructor.call(this, config);
5047 Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component, {
5049 getAutoCreate : function(){
5068 * @class Roo.bootstrap.Element
5069 * @extends Roo.bootstrap.Component
5070 * Bootstrap Element class
5071 * @cfg {String} html contents of the element
5072 * @cfg {String} tag tag of the element
5073 * @cfg {String} cls class of the element
5074 * @cfg {Boolean} preventDefault (true|false) default false
5075 * @cfg {Boolean} clickable (true|false) default false
5078 * Create a new Element
5079 * @param {Object} config The config object
5082 Roo.bootstrap.Element = function(config){
5083 Roo.bootstrap.Element.superclass.constructor.call(this, config);
5089 * When a element is chick
5090 * @param {Roo.bootstrap.Element} this
5091 * @param {Roo.EventObject} e
5097 Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, {
5102 preventDefault: false,
5105 getAutoCreate : function(){
5109 // cls: this.cls, double assign in parent class Component.js :: onRender
5116 initEvents: function()
5118 Roo.bootstrap.Element.superclass.initEvents.call(this);
5121 this.el.on('click', this.onClick, this);
5126 onClick : function(e)
5128 if(this.preventDefault){
5132 this.fireEvent('click', this, e);
5135 getValue : function()
5137 return this.el.dom.innerHTML;
5140 setValue : function(value)
5142 this.el.dom.innerHTML = value;
5157 * @class Roo.bootstrap.Pagination
5158 * @extends Roo.bootstrap.Component
5159 * Bootstrap Pagination class
5160 * @cfg {String} size xs | sm | md | lg
5161 * @cfg {Boolean} inverse false | true
5164 * Create a new Pagination
5165 * @param {Object} config The config object
5168 Roo.bootstrap.Pagination = function(config){
5169 Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
5172 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component, {
5178 getAutoCreate : function(){
5184 cfg.cls += ' inverse';
5190 cfg.cls += " " + this.cls;
5208 * @class Roo.bootstrap.PaginationItem
5209 * @extends Roo.bootstrap.Component
5210 * Bootstrap PaginationItem class
5211 * @cfg {String} html text
5212 * @cfg {String} href the link
5213 * @cfg {Boolean} preventDefault (true | false) default true
5214 * @cfg {Boolean} active (true | false) default false
5215 * @cfg {Boolean} disabled default false
5219 * Create a new PaginationItem
5220 * @param {Object} config The config object
5224 Roo.bootstrap.PaginationItem = function(config){
5225 Roo.bootstrap.PaginationItem.superclass.constructor.call(this, config);
5230 * The raw click event for the entire grid.
5231 * @param {Roo.EventObject} e
5237 Roo.extend(Roo.bootstrap.PaginationItem, Roo.bootstrap.Component, {
5241 preventDefault: true,
5246 getAutoCreate : function(){
5252 href : this.href ? this.href : '#',
5253 html : this.html ? this.html : ''
5263 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' disabled' : 'disabled';
5267 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' active' : 'active';
5273 initEvents: function() {
5275 this.el.on('click', this.onClick, this);
5278 onClick : function(e)
5280 Roo.log('PaginationItem on click ');
5281 if(this.preventDefault){
5289 this.fireEvent('click', this, e);
5305 * @class Roo.bootstrap.Slider
5306 * @extends Roo.bootstrap.Component
5307 * Bootstrap Slider class
5310 * Create a new Slider
5311 * @param {Object} config The config object
5314 Roo.bootstrap.Slider = function(config){
5315 Roo.bootstrap.Slider.superclass.constructor.call(this, config);
5318 Roo.extend(Roo.bootstrap.Slider, Roo.bootstrap.Component, {
5320 getAutoCreate : function(){
5324 cls: 'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',
5328 cls: 'ui-slider-handle ui-state-default ui-corner-all'
5340 * Ext JS Library 1.1.1
5341 * Copyright(c) 2006-2007, Ext JS, LLC.
5343 * Originally Released Under LGPL - original licence link has changed is not relivant.
5346 * <script type="text/javascript">
5351 * @class Roo.grid.ColumnModel
5352 * @extends Roo.util.Observable
5353 * This is the default implementation of a ColumnModel used by the Grid. It defines
5354 * the columns in the grid.
5357 var colModel = new Roo.grid.ColumnModel([
5358 {header: "Ticker", width: 60, sortable: true, locked: true},
5359 {header: "Company Name", width: 150, sortable: true},
5360 {header: "Market Cap.", width: 100, sortable: true},
5361 {header: "$ Sales", width: 100, sortable: true, renderer: money},
5362 {header: "Employees", width: 100, sortable: true, resizable: false}
5367 * The config options listed for this class are options which may appear in each
5368 * individual column definition.
5369 * <br/>RooJS Fix - column id's are not sequential but use Roo.id() - fixes bugs with layouts.
5371 * @param {Object} config An Array of column config objects. See this class's
5372 * config objects for details.
5374 Roo.grid.ColumnModel = function(config){
5376 * The config passed into the constructor
5378 this.config = config;
5381 // if no id, create one
5382 // if the column does not have a dataIndex mapping,
5383 // map it to the order it is in the config
5384 for(var i = 0, len = config.length; i < len; i++){
5386 if(typeof c.dataIndex == "undefined"){
5389 if(typeof c.renderer == "string"){
5390 c.renderer = Roo.util.Format[c.renderer];
5392 if(typeof c.id == "undefined"){
5395 if(c.editor && c.editor.xtype){
5396 c.editor = Roo.factory(c.editor, Roo.grid);
5398 if(c.editor && c.editor.isFormField){
5399 c.editor = new Roo.grid.GridEditor(c.editor);
5401 this.lookup[c.id] = c;
5405 * The width of columns which have no width specified (defaults to 100)
5408 this.defaultWidth = 100;
5411 * Default sortable of columns which have no sortable specified (defaults to false)
5414 this.defaultSortable = false;
5418 * @event widthchange
5419 * Fires when the width of a column changes.
5420 * @param {ColumnModel} this
5421 * @param {Number} columnIndex The column index
5422 * @param {Number} newWidth The new width
5424 "widthchange": true,
5426 * @event headerchange
5427 * Fires when the text of a header changes.
5428 * @param {ColumnModel} this
5429 * @param {Number} columnIndex The column index
5430 * @param {Number} newText The new header text
5432 "headerchange": true,
5434 * @event hiddenchange
5435 * Fires when a column is hidden or "unhidden".
5436 * @param {ColumnModel} this
5437 * @param {Number} columnIndex The column index
5438 * @param {Boolean} hidden true if hidden, false otherwise
5440 "hiddenchange": true,
5442 * @event columnmoved
5443 * Fires when a column is moved.
5444 * @param {ColumnModel} this
5445 * @param {Number} oldIndex
5446 * @param {Number} newIndex
5448 "columnmoved" : true,
5450 * @event columlockchange
5451 * Fires when a column's locked state is changed
5452 * @param {ColumnModel} this
5453 * @param {Number} colIndex
5454 * @param {Boolean} locked true if locked
5456 "columnlockchange" : true
5458 Roo.grid.ColumnModel.superclass.constructor.call(this);
5460 Roo.extend(Roo.grid.ColumnModel, Roo.util.Observable, {
5462 * @cfg {String} header The header text to display in the Grid view.
5465 * @cfg {String} dataIndex (Optional) The name of the field in the grid's {@link Roo.data.Store}'s
5466 * {@link Roo.data.Record} definition from which to draw the column's value. If not
5467 * specified, the column's index is used as an index into the Record's data Array.
5470 * @cfg {Number} width (Optional) The initial width in pixels of the column. Using this
5471 * instead of {@link Roo.grid.Grid#autoSizeColumns} is more efficient.
5474 * @cfg {Boolean} sortable (Optional) True if sorting is to be allowed on this column.
5475 * Defaults to the value of the {@link #defaultSortable} property.
5476 * Whether local/remote sorting is used is specified in {@link Roo.data.Store#remoteSort}.
5479 * @cfg {Boolean} locked (Optional) True to lock the column in place while scrolling the Grid. Defaults to false.
5482 * @cfg {Boolean} fixed (Optional) True if the column width cannot be changed. Defaults to false.
5485 * @cfg {Boolean} resizable (Optional) False to disable column resizing. Defaults to true.
5488 * @cfg {Boolean} hidden (Optional) True to hide the column. Defaults to false.
5491 * @cfg {Function} renderer (Optional) A function used to generate HTML markup for a cell
5492 * given the cell's data value. See {@link #setRenderer}. If not specified, the
5493 * default renderer returns the escaped data value. If an object is returned (bootstrap only)
5494 * then it is treated as a Roo Component object instance, and it is rendered after the initial row is rendered
5497 * @cfg {Roo.grid.GridEditor} editor (Optional) For grid editors - returns the grid editor
5500 * @cfg {String} align (Optional) Set the CSS text-align property of the column. Defaults to undefined.
5503 * @cfg {String} valign (Optional) Set the CSS vertical-align property of the column (eg. middle, top, bottom etc). Defaults to undefined.
5506 * @cfg {String} cursor (Optional)
5509 * @cfg {String} tooltip (Optional)
5512 * @cfg {Number} xs (Optional)
5515 * @cfg {Number} sm (Optional)
5518 * @cfg {Number} md (Optional)
5521 * @cfg {Number} lg (Optional)
5524 * Returns the id of the column at the specified index.
5525 * @param {Number} index The column index
5526 * @return {String} the id
5528 getColumnId : function(index){
5529 return this.config[index].id;
5533 * Returns the column for a specified id.
5534 * @param {String} id The column id
5535 * @return {Object} the column
5537 getColumnById : function(id){
5538 return this.lookup[id];
5543 * Returns the column for a specified dataIndex.
5544 * @param {String} dataIndex The column dataIndex
5545 * @return {Object|Boolean} the column or false if not found
5547 getColumnByDataIndex: function(dataIndex){
5548 var index = this.findColumnIndex(dataIndex);
5549 return index > -1 ? this.config[index] : false;
5553 * Returns the index for a specified column id.
5554 * @param {String} id The column id
5555 * @return {Number} the index, or -1 if not found
5557 getIndexById : function(id){
5558 for(var i = 0, len = this.config.length; i < len; i++){
5559 if(this.config[i].id == id){
5567 * Returns the index for a specified column dataIndex.
5568 * @param {String} dataIndex The column dataIndex
5569 * @return {Number} the index, or -1 if not found
5572 findColumnIndex : function(dataIndex){
5573 for(var i = 0, len = this.config.length; i < len; i++){
5574 if(this.config[i].dataIndex == dataIndex){
5582 moveColumn : function(oldIndex, newIndex){
5583 var c = this.config[oldIndex];
5584 this.config.splice(oldIndex, 1);
5585 this.config.splice(newIndex, 0, c);
5586 this.dataMap = null;
5587 this.fireEvent("columnmoved", this, oldIndex, newIndex);
5590 isLocked : function(colIndex){
5591 return this.config[colIndex].locked === true;
5594 setLocked : function(colIndex, value, suppressEvent){
5595 if(this.isLocked(colIndex) == value){
5598 this.config[colIndex].locked = value;
5600 this.fireEvent("columnlockchange", this, colIndex, value);
5604 getTotalLockedWidth : function(){
5606 for(var i = 0; i < this.config.length; i++){
5607 if(this.isLocked(i) && !this.isHidden(i)){
5608 this.totalWidth += this.getColumnWidth(i);
5614 getLockedCount : function(){
5615 for(var i = 0, len = this.config.length; i < len; i++){
5616 if(!this.isLocked(i)){
5621 return this.config.length;
5625 * Returns the number of columns.
5628 getColumnCount : function(visibleOnly){
5629 if(visibleOnly === true){
5631 for(var i = 0, len = this.config.length; i < len; i++){
5632 if(!this.isHidden(i)){
5638 return this.config.length;
5642 * Returns the column configs that return true by the passed function that is called with (columnConfig, index)
5643 * @param {Function} fn
5644 * @param {Object} scope (optional)
5645 * @return {Array} result
5647 getColumnsBy : function(fn, scope){
5649 for(var i = 0, len = this.config.length; i < len; i++){
5650 var c = this.config[i];
5651 if(fn.call(scope||this, c, i) === true){
5659 * Returns true if the specified column is sortable.
5660 * @param {Number} col The column index
5663 isSortable : function(col){
5664 if(typeof this.config[col].sortable == "undefined"){
5665 return this.defaultSortable;
5667 return this.config[col].sortable;
5671 * Returns the rendering (formatting) function defined for the column.
5672 * @param {Number} col The column index.
5673 * @return {Function} The function used to render the cell. See {@link #setRenderer}.
5675 getRenderer : function(col){
5676 if(!this.config[col].renderer){
5677 return Roo.grid.ColumnModel.defaultRenderer;
5679 return this.config[col].renderer;
5683 * Sets the rendering (formatting) function for a column.
5684 * @param {Number} col The column index
5685 * @param {Function} fn The function to use to process the cell's raw data
5686 * to return HTML markup for the grid view. The render function is called with
5687 * the following parameters:<ul>
5688 * <li>Data value.</li>
5689 * <li>Cell metadata. An object in which you may set the following attributes:<ul>
5690 * <li>css A CSS style string to apply to the table cell.</li>
5691 * <li>attr An HTML attribute definition string to apply to the data container element <i>within</i> the table cell.</li></ul>
5692 * <li>The {@link Roo.data.Record} from which the data was extracted.</li>
5693 * <li>Row index</li>
5694 * <li>Column index</li>
5695 * <li>The {@link Roo.data.Store} object from which the Record was extracted</li></ul>
5697 setRenderer : function(col, fn){
5698 this.config[col].renderer = fn;
5702 * Returns the width for the specified column.
5703 * @param {Number} col The column index
5706 getColumnWidth : function(col){
5707 return this.config[col].width * 1 || this.defaultWidth;
5711 * Sets the width for a column.
5712 * @param {Number} col The column index
5713 * @param {Number} width The new width
5715 setColumnWidth : function(col, width, suppressEvent){
5716 this.config[col].width = width;
5717 this.totalWidth = null;
5719 this.fireEvent("widthchange", this, col, width);
5724 * Returns the total width of all columns.
5725 * @param {Boolean} includeHidden True to include hidden column widths
5728 getTotalWidth : function(includeHidden){
5729 if(!this.totalWidth){
5730 this.totalWidth = 0;
5731 for(var i = 0, len = this.config.length; i < len; i++){
5732 if(includeHidden || !this.isHidden(i)){
5733 this.totalWidth += this.getColumnWidth(i);
5737 return this.totalWidth;
5741 * Returns the header for the specified column.
5742 * @param {Number} col The column index
5745 getColumnHeader : function(col){
5746 return this.config[col].header;
5750 * Sets the header for a column.
5751 * @param {Number} col The column index
5752 * @param {String} header The new header
5754 setColumnHeader : function(col, header){
5755 this.config[col].header = header;
5756 this.fireEvent("headerchange", this, col, header);
5760 * Returns the tooltip for the specified column.
5761 * @param {Number} col The column index
5764 getColumnTooltip : function(col){
5765 return this.config[col].tooltip;
5768 * Sets the tooltip for a column.
5769 * @param {Number} col The column index
5770 * @param {String} tooltip The new tooltip
5772 setColumnTooltip : function(col, tooltip){
5773 this.config[col].tooltip = tooltip;
5777 * Returns the dataIndex for the specified column.
5778 * @param {Number} col The column index
5781 getDataIndex : function(col){
5782 return this.config[col].dataIndex;
5786 * Sets the dataIndex for a column.
5787 * @param {Number} col The column index
5788 * @param {Number} dataIndex The new dataIndex
5790 setDataIndex : function(col, dataIndex){
5791 this.config[col].dataIndex = dataIndex;
5797 * Returns true if the cell is editable.
5798 * @param {Number} colIndex The column index
5799 * @param {Number} rowIndex The row index - this is nto actually used..?
5802 isCellEditable : function(colIndex, rowIndex){
5803 return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
5807 * Returns the editor defined for the cell/column.
5808 * return false or null to disable editing.
5809 * @param {Number} colIndex The column index
5810 * @param {Number} rowIndex The row index
5813 getCellEditor : function(colIndex, rowIndex){
5814 return this.config[colIndex].editor;
5818 * Sets if a column is editable.
5819 * @param {Number} col The column index
5820 * @param {Boolean} editable True if the column is editable
5822 setEditable : function(col, editable){
5823 this.config[col].editable = editable;
5828 * Returns true if the column is hidden.
5829 * @param {Number} colIndex The column index
5832 isHidden : function(colIndex){
5833 return this.config[colIndex].hidden;
5838 * Returns true if the column width cannot be changed
5840 isFixed : function(colIndex){
5841 return this.config[colIndex].fixed;
5845 * Returns true if the column can be resized
5848 isResizable : function(colIndex){
5849 return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
5852 * Sets if a column is hidden.
5853 * @param {Number} colIndex The column index
5854 * @param {Boolean} hidden True if the column is hidden
5856 setHidden : function(colIndex, hidden){
5857 this.config[colIndex].hidden = hidden;
5858 this.totalWidth = null;
5859 this.fireEvent("hiddenchange", this, colIndex, hidden);
5863 * Sets the editor for a column.
5864 * @param {Number} col The column index
5865 * @param {Object} editor The editor object
5867 setEditor : function(col, editor){
5868 this.config[col].editor = editor;
5872 Roo.grid.ColumnModel.defaultRenderer = function(value)
5874 if(typeof value == "object") {
5877 if(typeof value == "string" && value.length < 1){
5881 return String.format("{0}", value);
5884 // Alias for backwards compatibility
5885 Roo.grid.DefaultColumnModel = Roo.grid.ColumnModel;
5888 * Ext JS Library 1.1.1
5889 * Copyright(c) 2006-2007, Ext JS, LLC.
5891 * Originally Released Under LGPL - original licence link has changed is not relivant.
5894 * <script type="text/javascript">
5898 * @class Roo.LoadMask
5899 * A simple utility class for generically masking elements while loading data. If the element being masked has
5900 * an underlying {@link Roo.data.Store}, the masking will be automatically synchronized with the store's loading
5901 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
5902 * element's UpdateManager load indicator and will be destroyed after the initial load.
5904 * Create a new LoadMask
5905 * @param {String/HTMLElement/Roo.Element} el The element or DOM node, or its id
5906 * @param {Object} config The config object
5908 Roo.LoadMask = function(el, config){
5909 this.el = Roo.get(el);
5910 Roo.apply(this, config);
5912 this.store.on('beforeload', this.onBeforeLoad, this);
5913 this.store.on('load', this.onLoad, this);
5914 this.store.on('loadexception', this.onLoadException, this);
5915 this.removeMask = false;
5917 var um = this.el.getUpdateManager();
5918 um.showLoadIndicator = false; // disable the default indicator
5919 um.on('beforeupdate', this.onBeforeLoad, this);
5920 um.on('update', this.onLoad, this);
5921 um.on('failure', this.onLoad, this);
5922 this.removeMask = true;
5926 Roo.LoadMask.prototype = {
5928 * @cfg {Boolean} removeMask
5929 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
5930 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
5934 * The text to display in a centered loading message box (defaults to 'Loading...')
5938 * @cfg {String} msgCls
5939 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
5941 msgCls : 'x-mask-loading',
5944 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
5950 * Disables the mask to prevent it from being displayed
5952 disable : function(){
5953 this.disabled = true;
5957 * Enables the mask so that it can be displayed
5959 enable : function(){
5960 this.disabled = false;
5963 onLoadException : function()
5967 if (typeof(arguments[3]) != 'undefined') {
5968 Roo.MessageBox.alert("Error loading",arguments[3]);
5972 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
5973 Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
5980 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
5985 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
5989 onBeforeLoad : function(){
5991 (function() { this.el.mask(this.msg, this.msgCls); }).defer(50, this);
5996 destroy : function(){
5998 this.store.un('beforeload', this.onBeforeLoad, this);
5999 this.store.un('load', this.onLoad, this);
6000 this.store.un('loadexception', this.onLoadException, this);
6002 var um = this.el.getUpdateManager();
6003 um.un('beforeupdate', this.onBeforeLoad, this);
6004 um.un('update', this.onLoad, this);
6005 um.un('failure', this.onLoad, this);
6016 * @class Roo.bootstrap.Table
6017 * @extends Roo.bootstrap.Component
6018 * Bootstrap Table class
6019 * @cfg {String} cls table class
6020 * @cfg {String} align (left|center|right) Specifies the alignment of a table according to surrounding text
6021 * @cfg {String} bgcolor Specifies the background color for a table
6022 * @cfg {Number} border Specifies whether the table cells should have borders or not
6023 * @cfg {Number} cellpadding Specifies the space between the cell wall and the cell content
6024 * @cfg {Number} cellspacing Specifies the space between cells
6025 * @cfg {String} frame Specifies which parts of the outside borders that should be visible
6026 * @cfg {String} rules Specifies which parts of the inside borders that should be visible
6027 * @cfg {String} sortable Specifies that the table should be sortable
6028 * @cfg {String} summary Specifies a summary of the content of a table
6029 * @cfg {Number} width Specifies the width of a table
6030 * @cfg {String} layout table layout (auto | fixed | initial | inherit)
6032 * @cfg {boolean} striped Should the rows be alternative striped
6033 * @cfg {boolean} bordered Add borders to the table
6034 * @cfg {boolean} hover Add hover highlighting
6035 * @cfg {boolean} condensed Format condensed
6036 * @cfg {boolean} responsive Format condensed
6037 * @cfg {Boolean} loadMask (true|false) default false
6038 * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
6039 * @cfg {Boolean} headerShow (true|false) generate thead, default true
6040 * @cfg {Boolean} rowSelection (true|false) default false
6041 * @cfg {Boolean} cellSelection (true|false) default false
6042 * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header
6043 * @cfg {Roo.bootstrap.PagingToolbar} footer a paging toolbar
6044 * @cfg {Boolean} lazyLoad auto load data while scrolling to the end (default false)
6045 * @cfg {Boolean} auto_hide_footer auto hide footer if only one page (default false)
6049 * Create a new Table
6050 * @param {Object} config The config object
6053 Roo.bootstrap.Table = function(config){
6054 Roo.bootstrap.Table.superclass.constructor.call(this, config);
6059 this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
6060 this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
6061 this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
6062 this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
6064 this.sm = this.sm || {xtype: 'RowSelectionModel'};
6066 this.sm.grid = this;
6067 this.selModel = Roo.factory(this.sm, Roo.bootstrap.Table);
6068 this.sm = this.selModel;
6069 this.sm.xmodule = this.xmodule || false;
6072 if (this.cm && typeof(this.cm.config) == 'undefined') {
6073 this.colModel = new Roo.grid.ColumnModel(this.cm);
6074 this.cm = this.colModel;
6075 this.cm.xmodule = this.xmodule || false;
6078 this.store= Roo.factory(this.store, Roo.data);
6079 this.ds = this.store;
6080 this.ds.xmodule = this.xmodule || false;
6083 if (this.footer && this.store) {
6084 this.footer.dataSource = this.ds;
6085 this.footer = Roo.factory(this.footer);
6092 * Fires when a cell is clicked
6093 * @param {Roo.bootstrap.Table} this
6094 * @param {Roo.Element} el
6095 * @param {Number} rowIndex
6096 * @param {Number} columnIndex
6097 * @param {Roo.EventObject} e
6101 * @event celldblclick
6102 * Fires when a cell is double clicked
6103 * @param {Roo.bootstrap.Table} this
6104 * @param {Roo.Element} el
6105 * @param {Number} rowIndex
6106 * @param {Number} columnIndex
6107 * @param {Roo.EventObject} e
6109 "celldblclick" : true,
6112 * Fires when a row is clicked
6113 * @param {Roo.bootstrap.Table} this
6114 * @param {Roo.Element} el
6115 * @param {Number} rowIndex
6116 * @param {Roo.EventObject} e
6120 * @event rowdblclick
6121 * Fires when a row is double clicked
6122 * @param {Roo.bootstrap.Table} this
6123 * @param {Roo.Element} el
6124 * @param {Number} rowIndex
6125 * @param {Roo.EventObject} e
6127 "rowdblclick" : true,
6130 * Fires when a mouseover occur
6131 * @param {Roo.bootstrap.Table} this
6132 * @param {Roo.Element} el
6133 * @param {Number} rowIndex
6134 * @param {Number} columnIndex
6135 * @param {Roo.EventObject} e
6140 * Fires when a mouseout occur
6141 * @param {Roo.bootstrap.Table} this
6142 * @param {Roo.Element} el
6143 * @param {Number} rowIndex
6144 * @param {Number} columnIndex
6145 * @param {Roo.EventObject} e
6150 * Fires when a row is rendered, so you can change add a style to it.
6151 * @param {Roo.bootstrap.Table} this
6152 * @param {Object} rowcfg contains record rowIndex colIndex and rowClass - set rowClass to add a style.
6156 * @event rowsrendered
6157 * Fires when all the rows have been rendered
6158 * @param {Roo.bootstrap.Table} this
6160 'rowsrendered' : true,
6162 * @event contextmenu
6163 * The raw contextmenu event for the entire grid.
6164 * @param {Roo.EventObject} e
6166 "contextmenu" : true,
6168 * @event rowcontextmenu
6169 * Fires when a row is right clicked
6170 * @param {Roo.bootstrap.Table} this
6171 * @param {Number} rowIndex
6172 * @param {Roo.EventObject} e
6174 "rowcontextmenu" : true,
6176 * @event cellcontextmenu
6177 * Fires when a cell is right clicked
6178 * @param {Roo.bootstrap.Table} this
6179 * @param {Number} rowIndex
6180 * @param {Number} cellIndex
6181 * @param {Roo.EventObject} e
6183 "cellcontextmenu" : true,
6185 * @event headercontextmenu
6186 * Fires when a header is right clicked
6187 * @param {Roo.bootstrap.Table} this
6188 * @param {Number} columnIndex
6189 * @param {Roo.EventObject} e
6191 "headercontextmenu" : true
6195 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
6221 rowSelection : false,
6222 cellSelection : false,
6225 // Roo.Element - the tbody
6227 // Roo.Element - thead element
6230 container: false, // used by gridpanel...
6236 auto_hide_footer : false,
6238 getAutoCreate : function()
6240 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
6247 if (this.scrollBody) {
6248 cfg.cls += ' table-body-fixed';
6251 cfg.cls += ' table-striped';
6255 cfg.cls += ' table-hover';
6257 if (this.bordered) {
6258 cfg.cls += ' table-bordered';
6260 if (this.condensed) {
6261 cfg.cls += ' table-condensed';
6263 if (this.responsive) {
6264 cfg.cls += ' table-responsive';
6268 cfg.cls+= ' ' +this.cls;
6271 // this lot should be simplifed...
6284 ].forEach(function(k) {
6292 cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
6295 if(this.store || this.cm){
6296 if(this.headerShow){
6297 cfg.cn.push(this.renderHeader());
6300 cfg.cn.push(this.renderBody());
6302 if(this.footerShow){
6303 cfg.cn.push(this.renderFooter());
6305 // where does this come from?
6306 //cfg.cls+= ' TableGrid';
6309 return { cn : [ cfg ] };
6312 initEvents : function()
6314 if(!this.store || !this.cm){
6317 if (this.selModel) {
6318 this.selModel.initEvents();
6322 //Roo.log('initEvents with ds!!!!');
6324 this.mainBody = this.el.select('tbody', true).first();
6325 this.mainHead = this.el.select('thead', true).first();
6326 this.mainFoot = this.el.select('tfoot', true).first();
6332 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6333 e.on('click', _this.sort, _this);
6336 this.mainBody.on("click", this.onClick, this);
6337 this.mainBody.on("dblclick", this.onDblClick, this);
6339 // why is this done????? = it breaks dialogs??
6340 //this.parent().el.setStyle('position', 'relative');
6344 this.footer.parentId = this.id;
6345 this.footer.onRender(this.el.select('tfoot tr td').first(), null);
6348 this.el.select('tfoot tr td').first().addClass('hide');
6353 this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
6356 this.store.on('load', this.onLoad, this);
6357 this.store.on('beforeload', this.onBeforeLoad, this);
6358 this.store.on('update', this.onUpdate, this);
6359 this.store.on('add', this.onAdd, this);
6360 this.store.on("clear", this.clear, this);
6362 this.el.on("contextmenu", this.onContextMenu, this);
6364 this.mainBody.on('scroll', this.onBodyScroll, this);
6366 this.cm.on("headerchange", this.onHeaderChange, this);
6368 this.cm.on("hiddenchange", this.onHiddenChange, this, arguments);
6372 onContextMenu : function(e, t)
6374 this.processEvent("contextmenu", e);
6377 processEvent : function(name, e)
6379 if (name != 'touchstart' ) {
6380 this.fireEvent(name, e);
6383 var t = e.getTarget();
6385 var cell = Roo.get(t);
6391 if(cell.findParent('tfoot', false, true)){
6395 if(cell.findParent('thead', false, true)){
6397 if(e.getTarget().nodeName.toLowerCase() != 'th'){
6398 cell = Roo.get(t).findParent('th', false, true);
6400 Roo.log("failed to find th in thead?");
6401 Roo.log(e.getTarget());
6406 var cellIndex = cell.dom.cellIndex;
6408 var ename = name == 'touchstart' ? 'click' : name;
6409 this.fireEvent("header" + ename, this, cellIndex, e);
6414 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6415 cell = Roo.get(t).findParent('td', false, true);
6417 Roo.log("failed to find th in tbody?");
6418 Roo.log(e.getTarget());
6423 var row = cell.findParent('tr', false, true);
6424 var cellIndex = cell.dom.cellIndex;
6425 var rowIndex = row.dom.rowIndex - 1;
6429 this.fireEvent("row" + name, this, rowIndex, e);
6433 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
6439 onMouseover : function(e, el)
6441 var cell = Roo.get(el);
6447 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6448 cell = cell.findParent('td', false, true);
6451 var row = cell.findParent('tr', false, true);
6452 var cellIndex = cell.dom.cellIndex;
6453 var rowIndex = row.dom.rowIndex - 1; // start from 0
6455 this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
6459 onMouseout : function(e, el)
6461 var cell = Roo.get(el);
6467 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6468 cell = cell.findParent('td', false, true);
6471 var row = cell.findParent('tr', false, true);
6472 var cellIndex = cell.dom.cellIndex;
6473 var rowIndex = row.dom.rowIndex - 1; // start from 0
6475 this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
6479 onClick : function(e, el)
6481 var cell = Roo.get(el);
6483 if(!cell || (!this.cellSelection && !this.rowSelection)){
6487 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6488 cell = cell.findParent('td', false, true);
6491 if(!cell || typeof(cell) == 'undefined'){
6495 var row = cell.findParent('tr', false, true);
6497 if(!row || typeof(row) == 'undefined'){
6501 var cellIndex = cell.dom.cellIndex;
6502 var rowIndex = this.getRowIndex(row);
6504 // why??? - should these not be based on SelectionModel?
6505 if(this.cellSelection){
6506 this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
6509 if(this.rowSelection){
6510 this.fireEvent('rowclick', this, row, rowIndex, e);
6516 onDblClick : function(e,el)
6518 var cell = Roo.get(el);
6520 if(!cell || (!this.cellSelection && !this.rowSelection)){
6524 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6525 cell = cell.findParent('td', false, true);
6528 if(!cell || typeof(cell) == 'undefined'){
6532 var row = cell.findParent('tr', false, true);
6534 if(!row || typeof(row) == 'undefined'){
6538 var cellIndex = cell.dom.cellIndex;
6539 var rowIndex = this.getRowIndex(row);
6541 if(this.cellSelection){
6542 this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
6545 if(this.rowSelection){
6546 this.fireEvent('rowdblclick', this, row, rowIndex, e);
6550 sort : function(e,el)
6552 var col = Roo.get(el);
6554 if(!col.hasClass('sortable')){
6558 var sort = col.attr('sort');
6561 if(col.select('i', true).first().hasClass('glyphicon-arrow-up')){
6565 this.store.sortInfo = {field : sort, direction : dir};
6568 Roo.log("calling footer first");
6569 this.footer.onClick('first');
6572 this.store.load({ params : { start : 0 } });
6576 renderHeader : function()
6584 this.totalWidth = 0;
6586 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
6588 var config = cm.config[i];
6592 cls : 'x-hcol-' + i,
6594 html: cm.getColumnHeader(i)
6599 if(typeof(config.sortable) != 'undefined' && config.sortable){
6601 c.html = '<i class="glyphicon"></i>' + c.html;
6604 if(typeof(config.lgHeader) != 'undefined'){
6605 hh += '<span class="hidden-xs hidden-sm hidden-md">' + config.lgHeader + '</span>';
6608 if(typeof(config.mdHeader) != 'undefined'){
6609 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
6612 if(typeof(config.smHeader) != 'undefined'){
6613 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
6616 if(typeof(config.xsHeader) != 'undefined'){
6617 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
6624 if(typeof(config.tooltip) != 'undefined'){
6625 c.tooltip = config.tooltip;
6628 if(typeof(config.colspan) != 'undefined'){
6629 c.colspan = config.colspan;
6632 if(typeof(config.hidden) != 'undefined' && config.hidden){
6633 c.style += ' display:none;';
6636 if(typeof(config.dataIndex) != 'undefined'){
6637 c.sort = config.dataIndex;
6642 if(typeof(config.align) != 'undefined' && config.align.length){
6643 c.style += ' text-align:' + config.align + ';';
6646 if(typeof(config.width) != 'undefined'){
6647 c.style += ' width:' + config.width + 'px;';
6648 this.totalWidth += config.width;
6650 this.totalWidth += 100; // assume minimum of 100 per column?
6653 if(typeof(config.cls) != 'undefined'){
6654 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
6657 ['xs','sm','md','lg'].map(function(size){
6659 if(typeof(config[size]) == 'undefined'){
6663 if (!config[size]) { // 0 = hidden
6664 c.cls += ' hidden-' + size;
6668 c.cls += ' col-' + size + '-' + config[size];
6678 renderBody : function()
6688 colspan : this.cm.getColumnCount()
6698 renderFooter : function()
6708 colspan : this.cm.getColumnCount()
6722 // Roo.log('ds onload');
6727 var ds = this.store;
6729 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6730 e.select('i', true).removeClass(['glyphicon-arrow-up', 'glyphicon-arrow-down']);
6731 if (_this.store.sortInfo) {
6733 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
6734 e.select('i', true).addClass(['glyphicon-arrow-up']);
6737 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
6738 e.select('i', true).addClass(['glyphicon-arrow-down']);
6743 var tbody = this.mainBody;
6745 if(ds.getCount() > 0){
6746 ds.data.each(function(d,rowIndex){
6747 var row = this.renderRow(cm, ds, rowIndex);
6749 tbody.createChild(row);
6753 if(row.cellObjects.length){
6754 Roo.each(row.cellObjects, function(r){
6755 _this.renderCellObject(r);
6762 var tfoot = this.el.select('tfoot', true).first();
6764 if(this.footerShow && this.auto_hide_footer && this.mainFoot){
6766 this.mainFoot.setVisibilityMode(Roo.Element.DISPLAY).hide();
6768 var total = this.ds.getTotalCount();
6770 if(this.footer.pageSize < total){
6771 this.mainFoot.show();
6775 Roo.each(this.el.select('tbody td', true).elements, function(e){
6776 e.on('mouseover', _this.onMouseover, _this);
6779 Roo.each(this.el.select('tbody td', true).elements, function(e){
6780 e.on('mouseout', _this.onMouseout, _this);
6782 this.fireEvent('rowsrendered', this);
6788 onUpdate : function(ds,record)
6790 this.refreshRow(record);
6794 onRemove : function(ds, record, index, isUpdate){
6795 if(isUpdate !== true){
6796 this.fireEvent("beforerowremoved", this, index, record);
6798 var bt = this.mainBody.dom;
6800 var rows = this.el.select('tbody > tr', true).elements;
6802 if(typeof(rows[index]) != 'undefined'){
6803 bt.removeChild(rows[index].dom);
6806 // if(bt.rows[index]){
6807 // bt.removeChild(bt.rows[index]);
6810 if(isUpdate !== true){
6811 //this.stripeRows(index);
6812 //this.syncRowHeights(index, index);
6814 this.fireEvent("rowremoved", this, index, record);
6818 onAdd : function(ds, records, rowIndex)
6820 //Roo.log('on Add called');
6821 // - note this does not handle multiple adding very well..
6822 var bt = this.mainBody.dom;
6823 for (var i =0 ; i < records.length;i++) {
6824 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
6825 //Roo.log(records[i]);
6826 //Roo.log(this.store.getAt(rowIndex+i));
6827 this.insertRow(this.store, rowIndex + i, false);
6834 refreshRow : function(record){
6835 var ds = this.store, index;
6836 if(typeof record == 'number'){
6838 record = ds.getAt(index);
6840 index = ds.indexOf(record);
6842 this.insertRow(ds, index, true);
6844 this.onRemove(ds, record, index+1, true);
6846 //this.syncRowHeights(index, index);
6848 this.fireEvent("rowupdated", this, index, record);
6851 insertRow : function(dm, rowIndex, isUpdate){
6854 this.fireEvent("beforerowsinserted", this, rowIndex);
6856 //var s = this.getScrollState();
6857 var row = this.renderRow(this.cm, this.store, rowIndex);
6858 // insert before rowIndex..
6859 var e = this.mainBody.createChild(row,this.getRowDom(rowIndex));
6863 if(row.cellObjects.length){
6864 Roo.each(row.cellObjects, function(r){
6865 _this.renderCellObject(r);
6870 this.fireEvent("rowsinserted", this, rowIndex);
6871 //this.syncRowHeights(firstRow, lastRow);
6872 //this.stripeRows(firstRow);
6879 getRowDom : function(rowIndex)
6881 var rows = this.el.select('tbody > tr', true).elements;
6883 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
6886 // returns the object tree for a tr..
6889 renderRow : function(cm, ds, rowIndex)
6891 var d = ds.getAt(rowIndex);
6895 cls : 'x-row-' + rowIndex,
6899 var cellObjects = [];
6901 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
6902 var config = cm.config[i];
6904 var renderer = cm.getRenderer(i);
6908 if(typeof(renderer) !== 'undefined'){
6909 value = renderer(d.data[cm.getDataIndex(i)], false, d);
6911 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
6912 // and are rendered into the cells after the row is rendered - using the id for the element.
6914 if(typeof(value) === 'object'){
6924 rowIndex : rowIndex,
6929 this.fireEvent('rowclass', this, rowcfg);
6933 cls : rowcfg.rowClass + ' x-col-' + i,
6935 html: (typeof(value) === 'object') ? '' : value
6942 if(typeof(config.colspan) != 'undefined'){
6943 td.colspan = config.colspan;
6946 if(typeof(config.hidden) != 'undefined' && config.hidden){
6947 td.style += ' display:none;';
6950 if(typeof(config.align) != 'undefined' && config.align.length){
6951 td.style += ' text-align:' + config.align + ';';
6953 if(typeof(config.valign) != 'undefined' && config.valign.length){
6954 td.style += ' vertical-align:' + config.valign + ';';
6957 if(typeof(config.width) != 'undefined'){
6958 td.style += ' width:' + config.width + 'px;';
6961 if(typeof(config.cursor) != 'undefined'){
6962 td.style += ' cursor:' + config.cursor + ';';
6965 if(typeof(config.cls) != 'undefined'){
6966 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
6969 ['xs','sm','md','lg'].map(function(size){
6971 if(typeof(config[size]) == 'undefined'){
6975 if (!config[size]) { // 0 = hidden
6976 td.cls += ' hidden-' + size;
6980 td.cls += ' col-' + size + '-' + config[size];
6988 row.cellObjects = cellObjects;
6996 onBeforeLoad : function()
7005 this.el.select('tbody', true).first().dom.innerHTML = '';
7008 * Show or hide a row.
7009 * @param {Number} rowIndex to show or hide
7010 * @param {Boolean} state hide
7012 setRowVisibility : function(rowIndex, state)
7014 var bt = this.mainBody.dom;
7016 var rows = this.el.select('tbody > tr', true).elements;
7018 if(typeof(rows[rowIndex]) == 'undefined'){
7021 rows[rowIndex].dom.style.display = state ? '' : 'none';
7025 getSelectionModel : function(){
7027 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
7029 return this.selModel;
7032 * Render the Roo.bootstrap object from renderder
7034 renderCellObject : function(r)
7038 r.cfg.parentId = (typeof(r.container) == 'string') ? r.container : r.container.id;
7040 var t = r.cfg.render(r.container);
7043 Roo.each(r.cfg.cn, function(c){
7045 container: t.getChildContainer(),
7048 _this.renderCellObject(child);
7053 getRowIndex : function(row)
7057 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
7068 * Returns the grid's underlying element = used by panel.Grid
7069 * @return {Element} The element
7071 getGridEl : function(){
7075 * Forces a resize - used by panel.Grid
7076 * @return {Element} The element
7078 autoSize : function()
7080 //var ctr = Roo.get(this.container.dom.parentElement);
7081 var ctr = Roo.get(this.el.dom);
7083 var thd = this.getGridEl().select('thead',true).first();
7084 var tbd = this.getGridEl().select('tbody', true).first();
7085 var tfd = this.getGridEl().select('tfoot', true).first();
7087 var cw = ctr.getWidth();
7091 tbd.setSize(ctr.getWidth(),
7092 ctr.getHeight() - ((thd ? thd.getHeight() : 0) + (tfd ? tfd.getHeight() : 0))
7094 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
7097 cw = Math.max(cw, this.totalWidth);
7098 this.getGridEl().select('tr',true).setWidth(cw);
7099 // resize 'expandable coloumn?
7101 return; // we doe not have a view in this design..
7104 onBodyScroll: function()
7106 //Roo.log("body scrolled');" + this.mainBody.dom.scrollLeft);
7108 this.mainHead.setStyle({
7109 'position' : 'relative',
7110 'left': (-1* this.mainBody.dom.scrollLeft) + 'px'
7116 var scrollHeight = this.mainBody.dom.scrollHeight;
7118 var scrollTop = Math.ceil(this.mainBody.getScroll().top);
7120 var height = this.mainBody.getHeight();
7122 if(scrollHeight - height == scrollTop) {
7124 var total = this.ds.getTotalCount();
7126 if(this.footer.cursor + this.footer.pageSize < total){
7128 this.footer.ds.load({
7130 start : this.footer.cursor + this.footer.pageSize,
7131 limit : this.footer.pageSize
7141 onHeaderChange : function()
7143 var header = this.renderHeader();
7144 var table = this.el.select('table', true).first();
7146 this.mainHead.remove();
7147 this.mainHead = table.createChild(header, this.mainBody, false);
7150 onHiddenChange : function(colModel, colIndex, hidden)
7152 var thSelector = '#' + this.id + ' .x-hcol-' + colIndex;
7153 var tdSelector = '#' + this.id + ' .x-col-' + colIndex;
7155 this.CSS.updateRule(thSelector, "display", "");
7156 this.CSS.updateRule(tdSelector, "display", "");
7159 this.CSS.updateRule(thSelector, "display", "none");
7160 this.CSS.updateRule(tdSelector, "display", "none");
7163 this.onHeaderChange();
7167 setColumnWidth: function(col_index, width)
7169 // width = "md-2 xs-2..."
7170 if(!this.colModel.config[col_index]) {
7174 var w = width.split(" ");
7176 var rows = this.el.dom.getElementsByClassName("x-col-"+col_index);
7178 var h_row = this.el.dom.getElementsByClassName("x-hcol-"+col_index);
7181 for(var j = 0; j < w.length; j++) {
7187 var size_cls = w[j].split("-");
7189 if(!Number.isInteger(size_cls[1] * 1)) {
7193 if(!this.colModel.config[col_index][size_cls[0]]) {
7197 if(!h_row[0].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
7201 h_row[0].classList.replace(
7202 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
7203 "col-"+size_cls[0]+"-"+size_cls[1]
7206 for(var i = 0; i < rows.length; i++) {
7208 var size_cls = w[j].split("-");
7210 if(!Number.isInteger(size_cls[1] * 1)) {
7214 if(!this.colModel.config[col_index][size_cls[0]]) {
7218 if(!rows[i].classList.contains("col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]])) {
7222 rows[i].classList.replace(
7223 "col-"+size_cls[0]+"-"+this.colModel.config[col_index][size_cls[0]],
7224 "col-"+size_cls[0]+"-"+size_cls[1]
7228 this.colModel.config[col_index][size_cls[0]] = size_cls[1];
7243 * @class Roo.bootstrap.TableCell
7244 * @extends Roo.bootstrap.Component
7245 * Bootstrap TableCell class
7246 * @cfg {String} html cell contain text
7247 * @cfg {String} cls cell class
7248 * @cfg {String} tag cell tag (td|th) default td
7249 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
7250 * @cfg {String} align Aligns the content in a cell
7251 * @cfg {String} axis Categorizes cells
7252 * @cfg {String} bgcolor Specifies the background color of a cell
7253 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7254 * @cfg {Number} colspan Specifies the number of columns a cell should span
7255 * @cfg {String} headers Specifies one or more header cells a cell is related to
7256 * @cfg {Number} height Sets the height of a cell
7257 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
7258 * @cfg {Number} rowspan Sets the number of rows a cell should span
7259 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
7260 * @cfg {String} valign Vertical aligns the content in a cell
7261 * @cfg {Number} width Specifies the width of a cell
7264 * Create a new TableCell
7265 * @param {Object} config The config object
7268 Roo.bootstrap.TableCell = function(config){
7269 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
7272 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
7292 getAutoCreate : function(){
7293 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
7313 cfg.align=this.align
7319 cfg.bgcolor=this.bgcolor
7322 cfg.charoff=this.charoff
7325 cfg.colspan=this.colspan
7328 cfg.headers=this.headers
7331 cfg.height=this.height
7334 cfg.nowrap=this.nowrap
7337 cfg.rowspan=this.rowspan
7340 cfg.scope=this.scope
7343 cfg.valign=this.valign
7346 cfg.width=this.width
7365 * @class Roo.bootstrap.TableRow
7366 * @extends Roo.bootstrap.Component
7367 * Bootstrap TableRow class
7368 * @cfg {String} cls row class
7369 * @cfg {String} align Aligns the content in a table row
7370 * @cfg {String} bgcolor Specifies a background color for a table row
7371 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
7372 * @cfg {String} valign Vertical aligns the content in a table row
7375 * Create a new TableRow
7376 * @param {Object} config The config object
7379 Roo.bootstrap.TableRow = function(config){
7380 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
7383 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
7391 getAutoCreate : function(){
7392 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
7402 cfg.align = this.align;
7405 cfg.bgcolor = this.bgcolor;
7408 cfg.charoff = this.charoff;
7411 cfg.valign = this.valign;
7429 * @class Roo.bootstrap.TableBody
7430 * @extends Roo.bootstrap.Component
7431 * Bootstrap TableBody class
7432 * @cfg {String} cls element class
7433 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
7434 * @cfg {String} align Aligns the content inside the element
7435 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
7436 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
7439 * Create a new TableBody
7440 * @param {Object} config The config object
7443 Roo.bootstrap.TableBody = function(config){
7444 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
7447 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
7455 getAutoCreate : function(){
7456 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
7470 cfg.align = this.align;
7473 cfg.charoff = this.charoff;
7476 cfg.valign = this.valign;
7483 // initEvents : function()
7490 // this.store = Roo.factory(this.store, Roo.data);
7491 // this.store.on('load', this.onLoad, this);
7493 // this.store.load();
7497 // onLoad: function ()
7499 // this.fireEvent('load', this);
7509 * Ext JS Library 1.1.1
7510 * Copyright(c) 2006-2007, Ext JS, LLC.
7512 * Originally Released Under LGPL - original licence link has changed is not relivant.
7515 * <script type="text/javascript">
7518 // as we use this in bootstrap.
7519 Roo.namespace('Roo.form');
7521 * @class Roo.form.Action
7522 * Internal Class used to handle form actions
7524 * @param {Roo.form.BasicForm} el The form element or its id
7525 * @param {Object} config Configuration options
7530 // define the action interface
7531 Roo.form.Action = function(form, options){
7533 this.options = options || {};
7536 * Client Validation Failed
7539 Roo.form.Action.CLIENT_INVALID = 'client';
7541 * Server Validation Failed
7544 Roo.form.Action.SERVER_INVALID = 'server';
7546 * Connect to Server Failed
7549 Roo.form.Action.CONNECT_FAILURE = 'connect';
7551 * Reading Data from Server Failed
7554 Roo.form.Action.LOAD_FAILURE = 'load';
7556 Roo.form.Action.prototype = {
7558 failureType : undefined,
7559 response : undefined,
7563 run : function(options){
7568 success : function(response){
7573 handleResponse : function(response){
7577 // default connection failure
7578 failure : function(response){
7580 this.response = response;
7581 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7582 this.form.afterAction(this, false);
7585 processResponse : function(response){
7586 this.response = response;
7587 if(!response.responseText){
7590 this.result = this.handleResponse(response);
7594 // utility functions used internally
7595 getUrl : function(appendParams){
7596 var url = this.options.url || this.form.url || this.form.el.dom.action;
7598 var p = this.getParams();
7600 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
7606 getMethod : function(){
7607 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
7610 getParams : function(){
7611 var bp = this.form.baseParams;
7612 var p = this.options.params;
7614 if(typeof p == "object"){
7615 p = Roo.urlEncode(Roo.applyIf(p, bp));
7616 }else if(typeof p == 'string' && bp){
7617 p += '&' + Roo.urlEncode(bp);
7620 p = Roo.urlEncode(bp);
7625 createCallback : function(){
7627 success: this.success,
7628 failure: this.failure,
7630 timeout: (this.form.timeout*1000),
7631 upload: this.form.fileUpload ? this.success : undefined
7636 Roo.form.Action.Submit = function(form, options){
7637 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
7640 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
7643 haveProgress : false,
7644 uploadComplete : false,
7646 // uploadProgress indicator.
7647 uploadProgress : function()
7649 if (!this.form.progressUrl) {
7653 if (!this.haveProgress) {
7654 Roo.MessageBox.progress("Uploading", "Uploading");
7656 if (this.uploadComplete) {
7657 Roo.MessageBox.hide();
7661 this.haveProgress = true;
7663 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
7665 var c = new Roo.data.Connection();
7667 url : this.form.progressUrl,
7672 success : function(req){
7673 //console.log(data);
7677 rdata = Roo.decode(req.responseText)
7679 Roo.log("Invalid data from server..");
7683 if (!rdata || !rdata.success) {
7685 Roo.MessageBox.alert(Roo.encode(rdata));
7688 var data = rdata.data;
7690 if (this.uploadComplete) {
7691 Roo.MessageBox.hide();
7696 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
7697 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
7700 this.uploadProgress.defer(2000,this);
7703 failure: function(data) {
7704 Roo.log('progress url failed ');
7715 // run get Values on the form, so it syncs any secondary forms.
7716 this.form.getValues();
7718 var o = this.options;
7719 var method = this.getMethod();
7720 var isPost = method == 'POST';
7721 if(o.clientValidation === false || this.form.isValid()){
7723 if (this.form.progressUrl) {
7724 this.form.findField('UPLOAD_IDENTIFIER').setValue(
7725 (new Date() * 1) + '' + Math.random());
7730 Roo.Ajax.request(Roo.apply(this.createCallback(), {
7731 form:this.form.el.dom,
7732 url:this.getUrl(!isPost),
7734 params:isPost ? this.getParams() : null,
7735 isUpload: this.form.fileUpload
7738 this.uploadProgress();
7740 }else if (o.clientValidation !== false){ // client validation failed
7741 this.failureType = Roo.form.Action.CLIENT_INVALID;
7742 this.form.afterAction(this, false);
7746 success : function(response)
7748 this.uploadComplete= true;
7749 if (this.haveProgress) {
7750 Roo.MessageBox.hide();
7754 var result = this.processResponse(response);
7755 if(result === true || result.success){
7756 this.form.afterAction(this, true);
7760 this.form.markInvalid(result.errors);
7761 this.failureType = Roo.form.Action.SERVER_INVALID;
7763 this.form.afterAction(this, false);
7765 failure : function(response)
7767 this.uploadComplete= true;
7768 if (this.haveProgress) {
7769 Roo.MessageBox.hide();
7772 this.response = response;
7773 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7774 this.form.afterAction(this, false);
7777 handleResponse : function(response){
7778 if(this.form.errorReader){
7779 var rs = this.form.errorReader.read(response);
7782 for(var i = 0, len = rs.records.length; i < len; i++) {
7783 var r = rs.records[i];
7787 if(errors.length < 1){
7791 success : rs.success,
7797 ret = Roo.decode(response.responseText);
7801 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
7811 Roo.form.Action.Load = function(form, options){
7812 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
7813 this.reader = this.form.reader;
7816 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
7821 Roo.Ajax.request(Roo.apply(
7822 this.createCallback(), {
7823 method:this.getMethod(),
7824 url:this.getUrl(false),
7825 params:this.getParams()
7829 success : function(response){
7831 var result = this.processResponse(response);
7832 if(result === true || !result.success || !result.data){
7833 this.failureType = Roo.form.Action.LOAD_FAILURE;
7834 this.form.afterAction(this, false);
7837 this.form.clearInvalid();
7838 this.form.setValues(result.data);
7839 this.form.afterAction(this, true);
7842 handleResponse : function(response){
7843 if(this.form.reader){
7844 var rs = this.form.reader.read(response);
7845 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
7847 success : rs.success,
7851 return Roo.decode(response.responseText);
7855 Roo.form.Action.ACTION_TYPES = {
7856 'load' : Roo.form.Action.Load,
7857 'submit' : Roo.form.Action.Submit
7866 * @class Roo.bootstrap.Form
7867 * @extends Roo.bootstrap.Component
7868 * Bootstrap Form class
7869 * @cfg {String} method GET | POST (default POST)
7870 * @cfg {String} labelAlign top | left (default top)
7871 * @cfg {String} align left | right - for navbars
7872 * @cfg {Boolean} loadMask load mask when submit (default true)
7877 * @param {Object} config The config object
7881 Roo.bootstrap.Form = function(config){
7883 Roo.bootstrap.Form.superclass.constructor.call(this, config);
7885 Roo.bootstrap.Form.popover.apply();
7889 * @event clientvalidation
7890 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
7891 * @param {Form} this
7892 * @param {Boolean} valid true if the form has passed client-side validation
7894 clientvalidation: true,
7896 * @event beforeaction
7897 * Fires before any action is performed. Return false to cancel the action.
7898 * @param {Form} this
7899 * @param {Action} action The action to be performed
7903 * @event actionfailed
7904 * Fires when an action fails.
7905 * @param {Form} this
7906 * @param {Action} action The action that failed
7908 actionfailed : true,
7910 * @event actioncomplete
7911 * Fires when an action is completed.
7912 * @param {Form} this
7913 * @param {Action} action The action that completed
7915 actioncomplete : true
7919 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
7922 * @cfg {String} method
7923 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
7928 * The URL to use for form actions if one isn't supplied in the action options.
7931 * @cfg {Boolean} fileUpload
7932 * Set to true if this form is a file upload.
7936 * @cfg {Object} baseParams
7937 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
7941 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
7945 * @cfg {Sting} align (left|right) for navbar forms
7950 activeAction : null,
7953 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
7954 * element by passing it or its id or mask the form itself by passing in true.
7957 waitMsgTarget : false,
7962 * @cfg {Boolean} errorMask (true|false) default false
7967 * @cfg {Number} maskOffset Default 100
7972 * @cfg {Boolean} maskBody
7976 getAutoCreate : function(){
7980 method : this.method || 'POST',
7981 id : this.id || Roo.id(),
7984 if (this.parent().xtype.match(/^Nav/)) {
7985 cfg.cls = 'navbar-form navbar-' + this.align;
7989 if (this.labelAlign == 'left' ) {
7990 cfg.cls += ' form-horizontal';
7996 initEvents : function()
7998 this.el.on('submit', this.onSubmit, this);
7999 // this was added as random key presses on the form where triggering form submit.
8000 this.el.on('keypress', function(e) {
8001 if (e.getCharCode() != 13) {
8004 // we might need to allow it for textareas.. and some other items.
8005 // check e.getTarget().
8007 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
8011 Roo.log("keypress blocked");
8019 onSubmit : function(e){
8024 * Returns true if client-side validation on the form is successful.
8027 isValid : function(){
8028 var items = this.getItems();
8032 items.each(function(f){
8038 Roo.log('invalid field: ' + f.name);
8042 if(!target && f.el.isVisible(true)){
8048 if(this.errorMask && !valid){
8049 Roo.bootstrap.Form.popover.mask(this, target);
8056 * Returns true if any fields in this form have changed since their original load.
8059 isDirty : function(){
8061 var items = this.getItems();
8062 items.each(function(f){
8072 * Performs a predefined action (submit or load) or custom actions you define on this form.
8073 * @param {String} actionName The name of the action type
8074 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
8075 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
8076 * accept other config options):
8078 Property Type Description
8079 ---------------- --------------- ----------------------------------------------------------------------------------
8080 url String The url for the action (defaults to the form's url)
8081 method String The form method to use (defaults to the form's method, or POST if not defined)
8082 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
8083 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
8084 validate the form on the client (defaults to false)
8086 * @return {BasicForm} this
8088 doAction : function(action, options){
8089 if(typeof action == 'string'){
8090 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
8092 if(this.fireEvent('beforeaction', this, action) !== false){
8093 this.beforeAction(action);
8094 action.run.defer(100, action);
8100 beforeAction : function(action){
8101 var o = action.options;
8106 Roo.get(document.body).mask(o.waitMsg || "Sending", 'x-mask-loading')
8108 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
8111 // not really supported yet.. ??
8113 //if(this.waitMsgTarget === true){
8114 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
8115 //}else if(this.waitMsgTarget){
8116 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
8117 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
8119 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
8125 afterAction : function(action, success){
8126 this.activeAction = null;
8127 var o = action.options;
8132 Roo.get(document.body).unmask();
8138 //if(this.waitMsgTarget === true){
8139 // this.el.unmask();
8140 //}else if(this.waitMsgTarget){
8141 // this.waitMsgTarget.unmask();
8143 // Roo.MessageBox.updateProgress(1);
8144 // Roo.MessageBox.hide();
8151 Roo.callback(o.success, o.scope, [this, action]);
8152 this.fireEvent('actioncomplete', this, action);
8156 // failure condition..
8157 // we have a scenario where updates need confirming.
8158 // eg. if a locking scenario exists..
8159 // we look for { errors : { needs_confirm : true }} in the response.
8161 (typeof(action.result) != 'undefined') &&
8162 (typeof(action.result.errors) != 'undefined') &&
8163 (typeof(action.result.errors.needs_confirm) != 'undefined')
8166 Roo.log("not supported yet");
8169 Roo.MessageBox.confirm(
8170 "Change requires confirmation",
8171 action.result.errorMsg,
8176 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
8186 Roo.callback(o.failure, o.scope, [this, action]);
8187 // show an error message if no failed handler is set..
8188 if (!this.hasListener('actionfailed')) {
8189 Roo.log("need to add dialog support");
8191 Roo.MessageBox.alert("Error",
8192 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
8193 action.result.errorMsg :
8194 "Saving Failed, please check your entries or try again"
8199 this.fireEvent('actionfailed', this, action);
8204 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
8205 * @param {String} id The value to search for
8208 findField : function(id){
8209 var items = this.getItems();
8210 var field = items.get(id);
8212 items.each(function(f){
8213 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
8220 return field || null;
8223 * Mark fields in this form invalid in bulk.
8224 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
8225 * @return {BasicForm} this
8227 markInvalid : function(errors){
8228 if(errors instanceof Array){
8229 for(var i = 0, len = errors.length; i < len; i++){
8230 var fieldError = errors[i];
8231 var f = this.findField(fieldError.id);
8233 f.markInvalid(fieldError.msg);
8239 if(typeof errors[id] != 'function' && (field = this.findField(id))){
8240 field.markInvalid(errors[id]);
8244 //Roo.each(this.childForms || [], function (f) {
8245 // f.markInvalid(errors);
8252 * Set values for fields in this form in bulk.
8253 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
8254 * @return {BasicForm} this
8256 setValues : function(values){
8257 if(values instanceof Array){ // array of objects
8258 for(var i = 0, len = values.length; i < len; i++){
8260 var f = this.findField(v.id);
8262 f.setValue(v.value);
8263 if(this.trackResetOnLoad){
8264 f.originalValue = f.getValue();
8268 }else{ // object hash
8271 if(typeof values[id] != 'function' && (field = this.findField(id))){
8273 if (field.setFromData &&
8275 field.displayField &&
8276 // combos' with local stores can
8277 // be queried via setValue()
8278 // to set their value..
8279 (field.store && !field.store.isLocal)
8283 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
8284 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
8285 field.setFromData(sd);
8287 } else if(field.setFromData && (field.store && !field.store.isLocal)) {
8289 field.setFromData(values);
8292 field.setValue(values[id]);
8296 if(this.trackResetOnLoad){
8297 field.originalValue = field.getValue();
8303 //Roo.each(this.childForms || [], function (f) {
8304 // f.setValues(values);
8311 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
8312 * they are returned as an array.
8313 * @param {Boolean} asString
8316 getValues : function(asString){
8317 //if (this.childForms) {
8318 // copy values from the child forms
8319 // Roo.each(this.childForms, function (f) {
8320 // this.setValues(f.getValues());
8326 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
8327 if(asString === true){
8330 return Roo.urlDecode(fs);
8334 * Returns the fields in this form as an object with key/value pairs.
8335 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
8338 getFieldValues : function(with_hidden)
8340 var items = this.getItems();
8342 items.each(function(f){
8348 var v = f.getValue();
8350 if (f.inputType =='radio') {
8351 if (typeof(ret[f.getName()]) == 'undefined') {
8352 ret[f.getName()] = ''; // empty..
8355 if (!f.el.dom.checked) {
8363 if(f.xtype == 'MoneyField'){
8364 ret[f.currencyName] = f.getCurrency();
8367 // not sure if this supported any more..
8368 if ((typeof(v) == 'object') && f.getRawValue) {
8369 v = f.getRawValue() ; // dates..
8371 // combo boxes where name != hiddenName...
8372 if (f.name !== false && f.name != '' && f.name != f.getName()) {
8373 ret[f.name] = f.getRawValue();
8375 ret[f.getName()] = v;
8382 * Clears all invalid messages in this form.
8383 * @return {BasicForm} this
8385 clearInvalid : function(){
8386 var items = this.getItems();
8388 items.each(function(f){
8397 * @return {BasicForm} this
8400 var items = this.getItems();
8401 items.each(function(f){
8405 Roo.each(this.childForms || [], function (f) {
8413 getItems : function()
8415 var r=new Roo.util.MixedCollection(false, function(o){
8416 return o.id || (o.id = Roo.id());
8418 var iter = function(el) {
8425 Roo.each(el.items,function(e) {
8434 hideFields : function(items)
8436 Roo.each(items, function(i){
8438 var f = this.findField(i);
8449 showFields : function(items)
8451 Roo.each(items, function(i){
8453 var f = this.findField(i);
8466 Roo.apply(Roo.bootstrap.Form, {
8493 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
8494 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
8495 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
8496 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
8499 this.maskEl.top.enableDisplayMode("block");
8500 this.maskEl.left.enableDisplayMode("block");
8501 this.maskEl.bottom.enableDisplayMode("block");
8502 this.maskEl.right.enableDisplayMode("block");
8504 this.toolTip = new Roo.bootstrap.Tooltip({
8505 cls : 'roo-form-error-popover',
8507 'left' : ['r-l', [-2,0], 'right'],
8508 'right' : ['l-r', [2,0], 'left'],
8509 'bottom' : ['tl-bl', [0,2], 'top'],
8510 'top' : [ 'bl-tl', [0,-2], 'bottom']
8514 this.toolTip.render(Roo.get(document.body));
8516 this.toolTip.el.enableDisplayMode("block");
8518 Roo.get(document.body).on('click', function(){
8522 Roo.get(document.body).on('touchstart', function(){
8526 this.isApplied = true
8529 mask : function(form, target)
8533 this.target = target;
8535 if(!this.form.errorMask || !target.el){
8539 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
8541 Roo.log(scrollable);
8543 var ot = this.target.el.calcOffsetsTo(scrollable);
8545 var scrollTo = ot[1] - this.form.maskOffset;
8547 scrollTo = Math.min(scrollTo, scrollable.dom.scrollHeight);
8549 scrollable.scrollTo('top', scrollTo);
8551 var box = this.target.el.getBox();
8553 var zIndex = Roo.bootstrap.Modal.zIndex++;
8556 this.maskEl.top.setStyle('position', 'absolute');
8557 this.maskEl.top.setStyle('z-index', zIndex);
8558 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
8559 this.maskEl.top.setLeft(0);
8560 this.maskEl.top.setTop(0);
8561 this.maskEl.top.show();
8563 this.maskEl.left.setStyle('position', 'absolute');
8564 this.maskEl.left.setStyle('z-index', zIndex);
8565 this.maskEl.left.setSize(box.x - this.padding, box.height + this.padding * 2);
8566 this.maskEl.left.setLeft(0);
8567 this.maskEl.left.setTop(box.y - this.padding);
8568 this.maskEl.left.show();
8570 this.maskEl.bottom.setStyle('position', 'absolute');
8571 this.maskEl.bottom.setStyle('z-index', zIndex);
8572 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
8573 this.maskEl.bottom.setLeft(0);
8574 this.maskEl.bottom.setTop(box.bottom + this.padding);
8575 this.maskEl.bottom.show();
8577 this.maskEl.right.setStyle('position', 'absolute');
8578 this.maskEl.right.setStyle('z-index', zIndex);
8579 this.maskEl.right.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
8580 this.maskEl.right.setLeft(box.right + this.padding);
8581 this.maskEl.right.setTop(box.y - this.padding);
8582 this.maskEl.right.show();
8584 this.toolTip.bindEl = this.target.el;
8586 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
8588 var tip = this.target.blankText;
8590 if(this.target.getValue() !== '' ) {
8592 if (this.target.invalidText.length) {
8593 tip = this.target.invalidText;
8594 } else if (this.target.regexText.length){
8595 tip = this.target.regexText;
8599 this.toolTip.show(tip);
8601 this.intervalID = window.setInterval(function() {
8602 Roo.bootstrap.Form.popover.unmask();
8605 window.onwheel = function(){ return false;};
8607 (function(){ this.isMasked = true; }).defer(500, this);
8613 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
8617 this.maskEl.top.setStyle('position', 'absolute');
8618 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
8619 this.maskEl.top.hide();
8621 this.maskEl.left.setStyle('position', 'absolute');
8622 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
8623 this.maskEl.left.hide();
8625 this.maskEl.bottom.setStyle('position', 'absolute');
8626 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
8627 this.maskEl.bottom.hide();
8629 this.maskEl.right.setStyle('position', 'absolute');
8630 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
8631 this.maskEl.right.hide();
8633 this.toolTip.hide();
8635 this.toolTip.el.hide();
8637 window.onwheel = function(){ return true;};
8639 if(this.intervalID){
8640 window.clearInterval(this.intervalID);
8641 this.intervalID = false;
8644 this.isMasked = false;
8654 * Ext JS Library 1.1.1
8655 * Copyright(c) 2006-2007, Ext JS, LLC.
8657 * Originally Released Under LGPL - original licence link has changed is not relivant.
8660 * <script type="text/javascript">
8663 * @class Roo.form.VTypes
8664 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
8667 Roo.form.VTypes = function(){
8668 // closure these in so they are only created once.
8669 var alpha = /^[a-zA-Z_]+$/;
8670 var alphanum = /^[a-zA-Z0-9_]+$/;
8671 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
8672 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
8674 // All these messages and functions are configurable
8677 * The function used to validate email addresses
8678 * @param {String} value The email address
8680 'email' : function(v){
8681 return email.test(v);
8684 * The error text to display when the email validation function returns false
8687 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
8689 * The keystroke filter mask to be applied on email input
8692 'emailMask' : /[a-z0-9_\.\-@]/i,
8695 * The function used to validate URLs
8696 * @param {String} value The URL
8698 'url' : function(v){
8702 * The error text to display when the url validation function returns false
8705 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
8708 * The function used to validate alpha values
8709 * @param {String} value The value
8711 'alpha' : function(v){
8712 return alpha.test(v);
8715 * The error text to display when the alpha validation function returns false
8718 'alphaText' : 'This field should only contain letters and _',
8720 * The keystroke filter mask to be applied on alpha input
8723 'alphaMask' : /[a-z_]/i,
8726 * The function used to validate alphanumeric values
8727 * @param {String} value The value
8729 'alphanum' : function(v){
8730 return alphanum.test(v);
8733 * The error text to display when the alphanumeric validation function returns false
8736 'alphanumText' : 'This field should only contain letters, numbers and _',
8738 * The keystroke filter mask to be applied on alphanumeric input
8741 'alphanumMask' : /[a-z0-9_]/i
8751 * @class Roo.bootstrap.Input
8752 * @extends Roo.bootstrap.Component
8753 * Bootstrap Input class
8754 * @cfg {Boolean} disabled is it disabled
8755 * @cfg {String} inputType button | checkbox | email | file | hidden | image | number | password | radio | range | reset | search | submit | text
8756 * @cfg {String} name name of the input
8757 * @cfg {string} fieldLabel - the label associated
8758 * @cfg {string} placeholder - placeholder to put in text.
8759 * @cfg {string} before - input group add on before
8760 * @cfg {string} after - input group add on after
8761 * @cfg {string} size - (lg|sm) or leave empty..
8762 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
8763 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
8764 * @cfg {Number} md colspan out of 12 for computer-sized screens
8765 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
8766 * @cfg {string} value default value of the input
8767 * @cfg {Number} labelWidth set the width of label
8768 * @cfg {Number} labellg set the width of label (1-12)
8769 * @cfg {Number} labelmd set the width of label (1-12)
8770 * @cfg {Number} labelsm set the width of label (1-12)
8771 * @cfg {Number} labelxs set the width of label (1-12)
8772 * @cfg {String} labelAlign (top|left)
8773 * @cfg {Boolean} readOnly Specifies that the field should be read-only
8774 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
8775 * @cfg {String} indicatorpos (left|right) default left
8776 * @cfg {String} capture (user|camera) use for file input only. (default empty)
8777 * @cfg {String} accept (image|video|audio) use for file input only. (default empty)
8779 * @cfg {String} align (left|center|right) Default left
8780 * @cfg {Boolean} forceFeedback (true|false) Default false
8783 * Create a new Input
8784 * @param {Object} config The config object
8787 Roo.bootstrap.Input = function(config){
8789 Roo.bootstrap.Input.superclass.constructor.call(this, config);
8794 * Fires when this field receives input focus.
8795 * @param {Roo.form.Field} this
8800 * Fires when this field loses input focus.
8801 * @param {Roo.form.Field} this
8806 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
8807 * {@link Roo.EventObject#getKey} to determine which key was pressed.
8808 * @param {Roo.form.Field} this
8809 * @param {Roo.EventObject} e The event object
8814 * Fires just before the field blurs if the field value has changed.
8815 * @param {Roo.form.Field} this
8816 * @param {Mixed} newValue The new value
8817 * @param {Mixed} oldValue The original value
8822 * Fires after the field has been marked as invalid.
8823 * @param {Roo.form.Field} this
8824 * @param {String} msg The validation message
8829 * Fires after the field has been validated with no errors.
8830 * @param {Roo.form.Field} this
8835 * Fires after the key up
8836 * @param {Roo.form.Field} this
8837 * @param {Roo.EventObject} e The event Object
8843 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
8845 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
8846 automatic validation (defaults to "keyup").
8848 validationEvent : "keyup",
8850 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
8852 validateOnBlur : true,
8854 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
8856 validationDelay : 250,
8858 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
8860 focusClass : "x-form-focus", // not needed???
8864 * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")
8866 invalidClass : "has-warning",
8869 * @cfg {String} validClass The CSS class to use when marking a field valid (defaults to "x-form-invalid")
8871 validClass : "has-success",
8874 * @cfg {Boolean} hasFeedback (true|false) default true
8879 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
8881 invalidFeedbackClass : "glyphicon-warning-sign",
8884 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
8886 validFeedbackClass : "glyphicon-ok",
8889 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
8891 selectOnFocus : false,
8894 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
8898 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
8903 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
8905 disableKeyFilter : false,
8908 * @cfg {Boolean} disabled True to disable the field (defaults to false).
8912 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
8916 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
8918 blankText : "Please complete this mandatory field",
8921 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
8925 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
8927 maxLength : Number.MAX_VALUE,
8929 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
8931 minLengthText : "The minimum length for this field is {0}",
8933 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
8935 maxLengthText : "The maximum length for this field is {0}",
8939 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
8940 * If available, this function will be called only after the basic validators all return true, and will be passed the
8941 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
8945 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
8946 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
8947 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
8951 * @cfg {String} regexText -- Depricated - use Invalid Text
8956 * @cfg {String} invalidText The error text to display if {@link #validator} test fails during validation (defaults to "")
8962 autocomplete: false,
8981 formatedValue : false,
8982 forceFeedback : false,
8984 indicatorpos : 'left',
8994 parentLabelAlign : function()
8997 while (parent.parent()) {
8998 parent = parent.parent();
8999 if (typeof(parent.labelAlign) !='undefined') {
9000 return parent.labelAlign;
9007 getAutoCreate : function()
9009 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
9015 if(this.inputType != 'hidden'){
9016 cfg.cls = 'form-group' //input-group
9022 type : this.inputType,
9024 cls : 'form-control',
9025 placeholder : this.placeholder || '',
9026 autocomplete : this.autocomplete || 'new-password'
9029 if(this.capture.length){
9030 input.capture = this.capture;
9033 if(this.accept.length){
9034 input.accept = this.accept + "/*";
9038 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
9041 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
9042 input.maxLength = this.maxLength;
9045 if (this.disabled) {
9046 input.disabled=true;
9049 if (this.readOnly) {
9050 input.readonly=true;
9054 input.name = this.name;
9058 input.cls += ' input-' + this.size;
9062 ['xs','sm','md','lg'].map(function(size){
9063 if (settings[size]) {
9064 cfg.cls += ' col-' + size + '-' + settings[size];
9068 var inputblock = input;
9072 cls: 'glyphicon form-control-feedback'
9075 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9078 cls : 'has-feedback',
9086 if (this.before || this.after) {
9089 cls : 'input-group',
9093 if (this.before && typeof(this.before) == 'string') {
9095 inputblock.cn.push({
9097 cls : 'roo-input-before input-group-addon',
9101 if (this.before && typeof(this.before) == 'object') {
9102 this.before = Roo.factory(this.before);
9104 inputblock.cn.push({
9106 cls : 'roo-input-before input-group-' +
9107 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
9111 inputblock.cn.push(input);
9113 if (this.after && typeof(this.after) == 'string') {
9114 inputblock.cn.push({
9116 cls : 'roo-input-after input-group-addon',
9120 if (this.after && typeof(this.after) == 'object') {
9121 this.after = Roo.factory(this.after);
9123 inputblock.cn.push({
9125 cls : 'roo-input-after input-group-' +
9126 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
9130 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9131 inputblock.cls += ' has-feedback';
9132 inputblock.cn.push(feedback);
9136 if (align ==='left' && this.fieldLabel.length) {
9138 cfg.cls += ' roo-form-group-label-left';
9143 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
9144 tooltip : 'This field is required'
9149 cls : 'control-label',
9150 html : this.fieldLabel
9161 var labelCfg = cfg.cn[1];
9162 var contentCfg = cfg.cn[2];
9164 if(this.indicatorpos == 'right'){
9169 cls : 'control-label',
9173 html : this.fieldLabel
9177 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
9178 tooltip : 'This field is required'
9191 labelCfg = cfg.cn[0];
9192 contentCfg = cfg.cn[1];
9196 if(this.labelWidth > 12){
9197 labelCfg.style = "width: " + this.labelWidth + 'px';
9200 if(this.labelWidth < 13 && this.labelmd == 0){
9201 this.labelmd = this.labelWidth;
9204 if(this.labellg > 0){
9205 labelCfg.cls += ' col-lg-' + this.labellg;
9206 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
9209 if(this.labelmd > 0){
9210 labelCfg.cls += ' col-md-' + this.labelmd;
9211 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
9214 if(this.labelsm > 0){
9215 labelCfg.cls += ' col-sm-' + this.labelsm;
9216 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
9219 if(this.labelxs > 0){
9220 labelCfg.cls += ' col-xs-' + this.labelxs;
9221 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
9225 } else if ( this.fieldLabel.length) {
9230 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
9231 tooltip : 'This field is required'
9235 //cls : 'input-group-addon',
9236 html : this.fieldLabel
9244 if(this.indicatorpos == 'right'){
9249 //cls : 'input-group-addon',
9250 html : this.fieldLabel
9255 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
9256 tooltip : 'This field is required'
9276 if (this.parentType === 'Navbar' && this.parent().bar) {
9277 cfg.cls += ' navbar-form';
9280 if (this.parentType === 'NavGroup') {
9281 cfg.cls += ' navbar-form';
9289 * return the real input element.
9291 inputEl: function ()
9293 return this.el.select('input.form-control',true).first();
9296 tooltipEl : function()
9298 return this.inputEl();
9301 indicatorEl : function()
9303 var indicator = this.el.select('i.roo-required-indicator',true).first();
9313 setDisabled : function(v)
9315 var i = this.inputEl().dom;
9317 i.removeAttribute('disabled');
9321 i.setAttribute('disabled','true');
9323 initEvents : function()
9326 this.inputEl().on("keydown" , this.fireKey, this);
9327 this.inputEl().on("focus", this.onFocus, this);
9328 this.inputEl().on("blur", this.onBlur, this);
9330 this.inputEl().relayEvent('keyup', this);
9332 this.indicator = this.indicatorEl();
9335 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible'); // changed from invisible??? -
9338 // reference to original value for reset
9339 this.originalValue = this.getValue();
9340 //Roo.form.TextField.superclass.initEvents.call(this);
9341 if(this.validationEvent == 'keyup'){
9342 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
9343 this.inputEl().on('keyup', this.filterValidation, this);
9345 else if(this.validationEvent !== false){
9346 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
9349 if(this.selectOnFocus){
9350 this.on("focus", this.preFocus, this);
9353 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
9354 this.inputEl().on("keypress", this.filterKeys, this);
9356 this.inputEl().relayEvent('keypress', this);
9359 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
9360 this.el.on("click", this.autoSize, this);
9363 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
9364 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
9367 if (typeof(this.before) == 'object') {
9368 this.before.render(this.el.select('.roo-input-before',true).first());
9370 if (typeof(this.after) == 'object') {
9371 this.after.render(this.el.select('.roo-input-after',true).first());
9374 this.inputEl().on('change', this.onChange, this);
9377 filterValidation : function(e){
9378 if(!e.isNavKeyPress()){
9379 this.validationTask.delay(this.validationDelay);
9383 * Validates the field value
9384 * @return {Boolean} True if the value is valid, else false
9386 validate : function(){
9387 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
9388 if(this.disabled || this.validateValue(this.getRawValue())){
9399 * Validates a value according to the field's validation rules and marks the field as invalid
9400 * if the validation fails
9401 * @param {Mixed} value The value to validate
9402 * @return {Boolean} True if the value is valid, else false
9404 validateValue : function(value)
9406 if(this.getVisibilityEl().hasClass('hidden')){
9410 if(value.length < 1) { // if it's blank
9411 if(this.allowBlank){
9417 if(value.length < this.minLength){
9420 if(value.length > this.maxLength){
9424 var vt = Roo.form.VTypes;
9425 if(!vt[this.vtype](value, this)){
9429 if(typeof this.validator == "function"){
9430 var msg = this.validator(value);
9434 if (typeof(msg) == 'string') {
9435 this.invalidText = msg;
9439 if(this.regex && !this.regex.test(value)){
9447 fireKey : function(e){
9448 //Roo.log('field ' + e.getKey());
9449 if(e.isNavKeyPress()){
9450 this.fireEvent("specialkey", this, e);
9453 focus : function (selectText){
9455 this.inputEl().focus();
9456 if(selectText === true){
9457 this.inputEl().dom.select();
9463 onFocus : function(){
9464 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9465 // this.el.addClass(this.focusClass);
9468 this.hasFocus = true;
9469 this.startValue = this.getValue();
9470 this.fireEvent("focus", this);
9474 beforeBlur : Roo.emptyFn,
9478 onBlur : function(){
9480 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
9481 //this.el.removeClass(this.focusClass);
9483 this.hasFocus = false;
9484 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
9487 var v = this.getValue();
9488 if(String(v) !== String(this.startValue)){
9489 this.fireEvent('change', this, v, this.startValue);
9491 this.fireEvent("blur", this);
9494 onChange : function(e)
9496 var v = this.getValue();
9497 if(String(v) !== String(this.startValue)){
9498 this.fireEvent('change', this, v, this.startValue);
9504 * Resets the current field value to the originally loaded value and clears any validation messages
9507 this.setValue(this.originalValue);
9511 * Returns the name of the field
9512 * @return {Mixed} name The name field
9514 getName: function(){
9518 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
9519 * @return {Mixed} value The field value
9521 getValue : function(){
9523 var v = this.inputEl().getValue();
9528 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
9529 * @return {Mixed} value The field value
9531 getRawValue : function(){
9532 var v = this.inputEl().getValue();
9538 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
9539 * @param {Mixed} value The value to set
9541 setRawValue : function(v){
9542 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9545 selectText : function(start, end){
9546 var v = this.getRawValue();
9548 start = start === undefined ? 0 : start;
9549 end = end === undefined ? v.length : end;
9550 var d = this.inputEl().dom;
9551 if(d.setSelectionRange){
9552 d.setSelectionRange(start, end);
9553 }else if(d.createTextRange){
9554 var range = d.createTextRange();
9555 range.moveStart("character", start);
9556 range.moveEnd("character", v.length-end);
9563 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
9564 * @param {Mixed} value The value to set
9566 setValue : function(v){
9569 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9575 processValue : function(value){
9576 if(this.stripCharsRe){
9577 var newValue = value.replace(this.stripCharsRe, '');
9578 if(newValue !== value){
9579 this.setRawValue(newValue);
9586 preFocus : function(){
9588 if(this.selectOnFocus){
9589 this.inputEl().dom.select();
9592 filterKeys : function(e){
9594 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
9597 var c = e.getCharCode(), cc = String.fromCharCode(c);
9598 if(Roo.isIE && (e.isSpecialKey() || !cc)){
9601 if(!this.maskRe.test(cc)){
9606 * Clear any invalid styles/messages for this field
9608 clearInvalid : function(){
9610 if(!this.el || this.preventMark){ // not rendered
9615 this.el.removeClass(this.invalidClass);
9617 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9619 var feedback = this.el.select('.form-control-feedback', true).first();
9622 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9628 this.indicator.removeClass('visible');
9629 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9632 this.fireEvent('valid', this);
9636 * Mark this field as valid
9638 markValid : function()
9640 if(!this.el || this.preventMark){ // not rendered...
9644 this.el.removeClass([this.invalidClass, this.validClass]);
9646 var feedback = this.el.select('.form-control-feedback', true).first();
9649 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9653 this.indicator.removeClass('visible');
9654 this.indicator.addClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9661 if(this.allowBlank && !this.getRawValue().length){
9665 this.el.addClass(this.validClass);
9667 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9669 var feedback = this.el.select('.form-control-feedback', true).first();
9672 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9673 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9678 this.fireEvent('valid', this);
9682 * Mark this field as invalid
9683 * @param {String} msg The validation message
9685 markInvalid : function(msg)
9687 if(!this.el || this.preventMark){ // not rendered
9691 this.el.removeClass([this.invalidClass, this.validClass]);
9693 var feedback = this.el.select('.form-control-feedback', true).first();
9696 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9703 if(this.allowBlank && !this.getRawValue().length){
9708 this.indicator.removeClass(this.indicatorpos == 'right' ? 'hidden' : 'invisible');
9709 this.indicator.addClass('visible');
9712 this.el.addClass(this.invalidClass);
9714 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9716 var feedback = this.el.select('.form-control-feedback', true).first();
9719 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9721 if(this.getValue().length || this.forceFeedback){
9722 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9729 this.fireEvent('invalid', this, msg);
9732 SafariOnKeyDown : function(event)
9734 // this is a workaround for a password hang bug on chrome/ webkit.
9735 if (this.inputEl().dom.type != 'password') {
9739 var isSelectAll = false;
9741 if(this.inputEl().dom.selectionEnd > 0){
9742 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
9744 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
9745 event.preventDefault();
9750 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
9752 event.preventDefault();
9753 // this is very hacky as keydown always get's upper case.
9755 var cc = String.fromCharCode(event.getCharCode());
9756 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
9760 adjustWidth : function(tag, w){
9761 tag = tag.toLowerCase();
9762 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
9763 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
9767 if(tag == 'textarea'){
9770 }else if(Roo.isOpera){
9774 if(tag == 'textarea'){
9782 setFieldLabel : function(v)
9789 var ar = this.el.select('label > span',true);
9791 if (ar.elements.length) {
9792 this.el.select('label > span',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9793 this.fieldLabel = v;
9797 var br = this.el.select('label',true);
9799 if(br.elements.length) {
9800 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9801 this.fieldLabel = v;
9805 Roo.log('Cannot Found any of label > span || label in input');
9809 this.el.select('label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
9810 this.fieldLabel = v;
9825 * @class Roo.bootstrap.TextArea
9826 * @extends Roo.bootstrap.Input
9827 * Bootstrap TextArea class
9828 * @cfg {Number} cols Specifies the visible width of a text area
9829 * @cfg {Number} rows Specifies the visible number of lines in a text area
9830 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
9831 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
9832 * @cfg {string} html text
9835 * Create a new TextArea
9836 * @param {Object} config The config object
9839 Roo.bootstrap.TextArea = function(config){
9840 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
9844 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
9854 getAutoCreate : function(){
9856 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
9862 if(this.inputType != 'hidden'){
9863 cfg.cls = 'form-group' //input-group
9871 value : this.value || '',
9872 html: this.html || '',
9873 cls : 'form-control',
9874 placeholder : this.placeholder || ''
9878 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
9879 input.maxLength = this.maxLength;
9883 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
9887 input.cols = this.cols;
9890 if (this.readOnly) {
9891 input.readonly = true;
9895 input.name = this.name;
9899 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
9903 ['xs','sm','md','lg'].map(function(size){
9904 if (settings[size]) {
9905 cfg.cls += ' col-' + size + '-' + settings[size];
9909 var inputblock = input;
9911 if(this.hasFeedback && !this.allowBlank){
9915 cls: 'glyphicon form-control-feedback'
9919 cls : 'has-feedback',
9928 if (this.before || this.after) {
9931 cls : 'input-group',
9935 inputblock.cn.push({
9937 cls : 'input-group-addon',
9942 inputblock.cn.push(input);
9944 if(this.hasFeedback && !this.allowBlank){
9945 inputblock.cls += ' has-feedback';
9946 inputblock.cn.push(feedback);
9950 inputblock.cn.push({
9952 cls : 'input-group-addon',
9959 if (align ==='left' && this.fieldLabel.length) {
9964 cls : 'control-label',
9965 html : this.fieldLabel
9976 if(this.labelWidth > 12){
9977 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
9980 if(this.labelWidth < 13 && this.labelmd == 0){
9981 this.labelmd = this.labelWidth;
9984 if(this.labellg > 0){
9985 cfg.cn[0].cls += ' col-lg-' + this.labellg;
9986 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
9989 if(this.labelmd > 0){
9990 cfg.cn[0].cls += ' col-md-' + this.labelmd;
9991 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
9994 if(this.labelsm > 0){
9995 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
9996 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
9999 if(this.labelxs > 0){
10000 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
10001 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
10004 } else if ( this.fieldLabel.length) {
10009 //cls : 'input-group-addon',
10010 html : this.fieldLabel
10028 if (this.disabled) {
10029 input.disabled=true;
10036 * return the real textarea element.
10038 inputEl: function ()
10040 return this.el.select('textarea.form-control',true).first();
10044 * Clear any invalid styles/messages for this field
10046 clearInvalid : function()
10049 if(!this.el || this.preventMark){ // not rendered
10053 var label = this.el.select('label', true).first();
10054 var icon = this.el.select('i.fa-star', true).first();
10060 this.el.removeClass(this.invalidClass);
10062 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10064 var feedback = this.el.select('.form-control-feedback', true).first();
10067 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
10072 this.fireEvent('valid', this);
10076 * Mark this field as valid
10078 markValid : function()
10080 if(!this.el || this.preventMark){ // not rendered
10084 this.el.removeClass([this.invalidClass, this.validClass]);
10086 var feedback = this.el.select('.form-control-feedback', true).first();
10089 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10092 if(this.disabled || this.allowBlank){
10096 var label = this.el.select('label', true).first();
10097 var icon = this.el.select('i.fa-star', true).first();
10103 this.el.addClass(this.validClass);
10105 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
10107 var feedback = this.el.select('.form-control-feedback', true).first();
10110 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10111 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
10116 this.fireEvent('valid', this);
10120 * Mark this field as invalid
10121 * @param {String} msg The validation message
10123 markInvalid : function(msg)
10125 if(!this.el || this.preventMark){ // not rendered
10129 this.el.removeClass([this.invalidClass, this.validClass]);
10131 var feedback = this.el.select('.form-control-feedback', true).first();
10134 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10137 if(this.disabled || this.allowBlank){
10141 var label = this.el.select('label', true).first();
10142 var icon = this.el.select('i.fa-star', true).first();
10144 if(!this.getValue().length && label && !icon){
10145 this.el.createChild({
10147 cls : 'text-danger fa fa-lg fa-star',
10148 tooltip : 'This field is required',
10149 style : 'margin-right:5px;'
10153 this.el.addClass(this.invalidClass);
10155 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
10157 var feedback = this.el.select('.form-control-feedback', true).first();
10160 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
10162 if(this.getValue().length || this.forceFeedback){
10163 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
10170 this.fireEvent('invalid', this, msg);
10178 * trigger field - base class for combo..
10183 * @class Roo.bootstrap.TriggerField
10184 * @extends Roo.bootstrap.Input
10185 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
10186 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
10187 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
10188 * for which you can provide a custom implementation. For example:
10190 var trigger = new Roo.bootstrap.TriggerField();
10191 trigger.onTriggerClick = myTriggerFn;
10192 trigger.applyTo('my-field');
10195 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
10196 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
10197 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
10198 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
10199 * @cfg {String} caret (search|calendar) a fontawesome for the trigger icon see http://fortawesome.github.io/Font-Awesome/icons/
10202 * Create a new TriggerField.
10203 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
10204 * to the base TextField)
10206 Roo.bootstrap.TriggerField = function(config){
10207 this.mimicing = false;
10208 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
10211 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
10213 * @cfg {String} triggerClass A CSS class to apply to the trigger
10216 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
10221 * @cfg {Boolean} removable (true|false) special filter default false
10225 /** @cfg {Boolean} grow @hide */
10226 /** @cfg {Number} growMin @hide */
10227 /** @cfg {Number} growMax @hide */
10233 autoSize: Roo.emptyFn,
10237 deferHeight : true,
10240 actionMode : 'wrap',
10245 getAutoCreate : function(){
10247 var align = this.labelAlign || this.parentLabelAlign();
10252 cls: 'form-group' //input-group
10259 type : this.inputType,
10260 cls : 'form-control',
10261 autocomplete: 'new-password',
10262 placeholder : this.placeholder || ''
10266 input.name = this.name;
10269 input.cls += ' input-' + this.size;
10272 if (this.disabled) {
10273 input.disabled=true;
10276 var inputblock = input;
10278 if(this.hasFeedback && !this.allowBlank){
10282 cls: 'glyphicon form-control-feedback'
10285 if(this.removable && !this.editable && !this.tickable){
10287 cls : 'has-feedback',
10293 cls : 'roo-combo-removable-btn close'
10300 cls : 'has-feedback',
10309 if(this.removable && !this.editable && !this.tickable){
10311 cls : 'roo-removable',
10317 cls : 'roo-combo-removable-btn close'
10324 if (this.before || this.after) {
10327 cls : 'input-group',
10331 inputblock.cn.push({
10333 cls : 'input-group-addon',
10338 inputblock.cn.push(input);
10340 if(this.hasFeedback && !this.allowBlank){
10341 inputblock.cls += ' has-feedback';
10342 inputblock.cn.push(feedback);
10346 inputblock.cn.push({
10348 cls : 'input-group-addon',
10361 cls: 'form-hidden-field'
10375 cls: 'form-hidden-field'
10379 cls: 'roo-select2-choices',
10383 cls: 'roo-select2-search-field',
10396 cls: 'roo-select2-container input-group',
10401 // cls: 'typeahead typeahead-long dropdown-menu',
10402 // style: 'display:none'
10407 if(!this.multiple && this.showToggleBtn){
10413 if (this.caret != false) {
10416 cls: 'fa fa-' + this.caret
10423 cls : 'input-group-addon btn dropdown-toggle',
10428 cls: 'combobox-clear',
10442 combobox.cls += ' roo-select2-container-multi';
10445 if (align ==='left' && this.fieldLabel.length) {
10447 cfg.cls += ' roo-form-group-label-left';
10452 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
10453 tooltip : 'This field is required'
10458 cls : 'control-label',
10459 html : this.fieldLabel
10471 var labelCfg = cfg.cn[1];
10472 var contentCfg = cfg.cn[2];
10474 if(this.indicatorpos == 'right'){
10479 cls : 'control-label',
10483 html : this.fieldLabel
10487 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
10488 tooltip : 'This field is required'
10501 labelCfg = cfg.cn[0];
10502 contentCfg = cfg.cn[1];
10505 if(this.labelWidth > 12){
10506 labelCfg.style = "width: " + this.labelWidth + 'px';
10509 if(this.labelWidth < 13 && this.labelmd == 0){
10510 this.labelmd = this.labelWidth;
10513 if(this.labellg > 0){
10514 labelCfg.cls += ' col-lg-' + this.labellg;
10515 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
10518 if(this.labelmd > 0){
10519 labelCfg.cls += ' col-md-' + this.labelmd;
10520 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
10523 if(this.labelsm > 0){
10524 labelCfg.cls += ' col-sm-' + this.labelsm;
10525 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
10528 if(this.labelxs > 0){
10529 labelCfg.cls += ' col-xs-' + this.labelxs;
10530 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
10533 } else if ( this.fieldLabel.length) {
10534 // Roo.log(" label");
10538 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
10539 tooltip : 'This field is required'
10543 //cls : 'input-group-addon',
10544 html : this.fieldLabel
10552 if(this.indicatorpos == 'right'){
10560 html : this.fieldLabel
10564 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
10565 tooltip : 'This field is required'
10578 // Roo.log(" no label && no align");
10585 ['xs','sm','md','lg'].map(function(size){
10586 if (settings[size]) {
10587 cfg.cls += ' col-' + size + '-' + settings[size];
10598 onResize : function(w, h){
10599 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
10600 // if(typeof w == 'number'){
10601 // var x = w - this.trigger.getWidth();
10602 // this.inputEl().setWidth(this.adjustWidth('input', x));
10603 // this.trigger.setStyle('left', x+'px');
10608 adjustSize : Roo.BoxComponent.prototype.adjustSize,
10611 getResizeEl : function(){
10612 return this.inputEl();
10616 getPositionEl : function(){
10617 return this.inputEl();
10621 alignErrorIcon : function(){
10622 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
10626 initEvents : function(){
10630 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
10631 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
10632 if(!this.multiple && this.showToggleBtn){
10633 this.trigger = this.el.select('span.dropdown-toggle',true).first();
10634 if(this.hideTrigger){
10635 this.trigger.setDisplayed(false);
10637 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
10641 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
10644 if(this.removable && !this.editable && !this.tickable){
10645 var close = this.closeTriggerEl();
10648 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
10649 close.on('click', this.removeBtnClick, this, close);
10653 //this.trigger.addClassOnOver('x-form-trigger-over');
10654 //this.trigger.addClassOnClick('x-form-trigger-click');
10657 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
10661 closeTriggerEl : function()
10663 var close = this.el.select('.roo-combo-removable-btn', true).first();
10664 return close ? close : false;
10667 removeBtnClick : function(e, h, el)
10669 e.preventDefault();
10671 if(this.fireEvent("remove", this) !== false){
10673 this.fireEvent("afterremove", this)
10677 createList : function()
10679 this.list = Roo.get(document.body).createChild({
10681 cls: 'typeahead typeahead-long dropdown-menu',
10682 style: 'display:none'
10685 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
10690 initTrigger : function(){
10695 onDestroy : function(){
10697 this.trigger.removeAllListeners();
10698 // this.trigger.remove();
10701 // this.wrap.remove();
10703 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
10707 onFocus : function(){
10708 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
10710 if(!this.mimicing){
10711 this.wrap.addClass('x-trigger-wrap-focus');
10712 this.mimicing = true;
10713 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
10714 if(this.monitorTab){
10715 this.el.on("keydown", this.checkTab, this);
10722 checkTab : function(e){
10723 if(e.getKey() == e.TAB){
10724 this.triggerBlur();
10729 onBlur : function(){
10734 mimicBlur : function(e, t){
10736 if(!this.wrap.contains(t) && this.validateBlur()){
10737 this.triggerBlur();
10743 triggerBlur : function(){
10744 this.mimicing = false;
10745 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
10746 if(this.monitorTab){
10747 this.el.un("keydown", this.checkTab, this);
10749 //this.wrap.removeClass('x-trigger-wrap-focus');
10750 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
10754 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
10755 validateBlur : function(e, t){
10760 onDisable : function(){
10761 this.inputEl().dom.disabled = true;
10762 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
10764 // this.wrap.addClass('x-item-disabled');
10769 onEnable : function(){
10770 this.inputEl().dom.disabled = false;
10771 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
10773 // this.el.removeClass('x-item-disabled');
10778 onShow : function(){
10779 var ae = this.getActionEl();
10782 ae.dom.style.display = '';
10783 ae.dom.style.visibility = 'visible';
10789 onHide : function(){
10790 var ae = this.getActionEl();
10791 ae.dom.style.display = 'none';
10795 * The function that should handle the trigger's click event. This method does nothing by default until overridden
10796 * by an implementing function.
10798 * @param {EventObject} e
10800 onTriggerClick : Roo.emptyFn
10804 * Ext JS Library 1.1.1
10805 * Copyright(c) 2006-2007, Ext JS, LLC.
10807 * Originally Released Under LGPL - original licence link has changed is not relivant.
10810 * <script type="text/javascript">
10815 * @class Roo.data.SortTypes
10817 * Defines the default sorting (casting?) comparison functions used when sorting data.
10819 Roo.data.SortTypes = {
10821 * Default sort that does nothing
10822 * @param {Mixed} s The value being converted
10823 * @return {Mixed} The comparison value
10825 none : function(s){
10830 * The regular expression used to strip tags
10834 stripTagsRE : /<\/?[^>]+>/gi,
10837 * Strips all HTML tags to sort on text only
10838 * @param {Mixed} s The value being converted
10839 * @return {String} The comparison value
10841 asText : function(s){
10842 return String(s).replace(this.stripTagsRE, "");
10846 * Strips all HTML tags to sort on text only - Case insensitive
10847 * @param {Mixed} s The value being converted
10848 * @return {String} The comparison value
10850 asUCText : function(s){
10851 return String(s).toUpperCase().replace(this.stripTagsRE, "");
10855 * Case insensitive string
10856 * @param {Mixed} s The value being converted
10857 * @return {String} The comparison value
10859 asUCString : function(s) {
10860 return String(s).toUpperCase();
10865 * @param {Mixed} s The value being converted
10866 * @return {Number} The comparison value
10868 asDate : function(s) {
10872 if(s instanceof Date){
10873 return s.getTime();
10875 return Date.parse(String(s));
10880 * @param {Mixed} s The value being converted
10881 * @return {Float} The comparison value
10883 asFloat : function(s) {
10884 var val = parseFloat(String(s).replace(/,/g, ""));
10893 * @param {Mixed} s The value being converted
10894 * @return {Number} The comparison value
10896 asInt : function(s) {
10897 var val = parseInt(String(s).replace(/,/g, ""));
10905 * Ext JS Library 1.1.1
10906 * Copyright(c) 2006-2007, Ext JS, LLC.
10908 * Originally Released Under LGPL - original licence link has changed is not relivant.
10911 * <script type="text/javascript">
10915 * @class Roo.data.Record
10916 * Instances of this class encapsulate both record <em>definition</em> information, and record
10917 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
10918 * to access Records cached in an {@link Roo.data.Store} object.<br>
10920 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
10921 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
10924 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
10926 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
10927 * {@link #create}. The parameters are the same.
10928 * @param {Array} data An associative Array of data values keyed by the field name.
10929 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
10930 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
10931 * not specified an integer id is generated.
10933 Roo.data.Record = function(data, id){
10934 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
10939 * Generate a constructor for a specific record layout.
10940 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
10941 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
10942 * Each field definition object may contain the following properties: <ul>
10943 * <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,
10944 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
10945 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
10946 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
10947 * is being used, then this is a string containing the javascript expression to reference the data relative to
10948 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
10949 * to the data item relative to the record element. If the mapping expression is the same as the field name,
10950 * this may be omitted.</p></li>
10951 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
10952 * <ul><li>auto (Default, implies no conversion)</li>
10957 * <li>date</li></ul></p></li>
10958 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
10959 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
10960 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
10961 * by the Reader into an object that will be stored in the Record. It is passed the
10962 * following parameters:<ul>
10963 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
10965 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
10967 * <br>usage:<br><pre><code>
10968 var TopicRecord = Roo.data.Record.create(
10969 {name: 'title', mapping: 'topic_title'},
10970 {name: 'author', mapping: 'username'},
10971 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
10972 {name: 'lastPost', mapping: 'post_time', type: 'date'},
10973 {name: 'lastPoster', mapping: 'user2'},
10974 {name: 'excerpt', mapping: 'post_text'}
10977 var myNewRecord = new TopicRecord({
10978 title: 'Do my job please',
10981 lastPost: new Date(),
10982 lastPoster: 'Animal',
10983 excerpt: 'No way dude!'
10985 myStore.add(myNewRecord);
10990 Roo.data.Record.create = function(o){
10991 var f = function(){
10992 f.superclass.constructor.apply(this, arguments);
10994 Roo.extend(f, Roo.data.Record);
10995 var p = f.prototype;
10996 p.fields = new Roo.util.MixedCollection(false, function(field){
10999 for(var i = 0, len = o.length; i < len; i++){
11000 p.fields.add(new Roo.data.Field(o[i]));
11002 f.getField = function(name){
11003 return p.fields.get(name);
11008 Roo.data.Record.AUTO_ID = 1000;
11009 Roo.data.Record.EDIT = 'edit';
11010 Roo.data.Record.REJECT = 'reject';
11011 Roo.data.Record.COMMIT = 'commit';
11013 Roo.data.Record.prototype = {
11015 * Readonly flag - true if this record has been modified.
11024 join : function(store){
11025 this.store = store;
11029 * Set the named field to the specified value.
11030 * @param {String} name The name of the field to set.
11031 * @param {Object} value The value to set the field to.
11033 set : function(name, value){
11034 if(this.data[name] == value){
11038 if(!this.modified){
11039 this.modified = {};
11041 if(typeof this.modified[name] == 'undefined'){
11042 this.modified[name] = this.data[name];
11044 this.data[name] = value;
11045 if(!this.editing && this.store){
11046 this.store.afterEdit(this);
11051 * Get the value of the named field.
11052 * @param {String} name The name of the field to get the value of.
11053 * @return {Object} The value of the field.
11055 get : function(name){
11056 return this.data[name];
11060 beginEdit : function(){
11061 this.editing = true;
11062 this.modified = {};
11066 cancelEdit : function(){
11067 this.editing = false;
11068 delete this.modified;
11072 endEdit : function(){
11073 this.editing = false;
11074 if(this.dirty && this.store){
11075 this.store.afterEdit(this);
11080 * Usually called by the {@link Roo.data.Store} which owns the Record.
11081 * Rejects all changes made to the Record since either creation, or the last commit operation.
11082 * Modified fields are reverted to their original values.
11084 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
11085 * of reject operations.
11087 reject : function(){
11088 var m = this.modified;
11090 if(typeof m[n] != "function"){
11091 this.data[n] = m[n];
11094 this.dirty = false;
11095 delete this.modified;
11096 this.editing = false;
11098 this.store.afterReject(this);
11103 * Usually called by the {@link Roo.data.Store} which owns the Record.
11104 * Commits all changes made to the Record since either creation, or the last commit operation.
11106 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
11107 * of commit operations.
11109 commit : function(){
11110 this.dirty = false;
11111 delete this.modified;
11112 this.editing = false;
11114 this.store.afterCommit(this);
11119 hasError : function(){
11120 return this.error != null;
11124 clearError : function(){
11129 * Creates a copy of this record.
11130 * @param {String} id (optional) A new record id if you don't want to use this record's id
11133 copy : function(newId) {
11134 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
11138 * Ext JS Library 1.1.1
11139 * Copyright(c) 2006-2007, Ext JS, LLC.
11141 * Originally Released Under LGPL - original licence link has changed is not relivant.
11144 * <script type="text/javascript">
11150 * @class Roo.data.Store
11151 * @extends Roo.util.Observable
11152 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
11153 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
11155 * 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
11156 * has no knowledge of the format of the data returned by the Proxy.<br>
11158 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
11159 * instances from the data object. These records are cached and made available through accessor functions.
11161 * Creates a new Store.
11162 * @param {Object} config A config object containing the objects needed for the Store to access data,
11163 * and read the data into Records.
11165 Roo.data.Store = function(config){
11166 this.data = new Roo.util.MixedCollection(false);
11167 this.data.getKey = function(o){
11170 this.baseParams = {};
11172 this.paramNames = {
11177 "multisort" : "_multisort"
11180 if(config && config.data){
11181 this.inlineData = config.data;
11182 delete config.data;
11185 Roo.apply(this, config);
11187 if(this.reader){ // reader passed
11188 this.reader = Roo.factory(this.reader, Roo.data);
11189 this.reader.xmodule = this.xmodule || false;
11190 if(!this.recordType){
11191 this.recordType = this.reader.recordType;
11193 if(this.reader.onMetaChange){
11194 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
11198 if(this.recordType){
11199 this.fields = this.recordType.prototype.fields;
11201 this.modified = [];
11205 * @event datachanged
11206 * Fires when the data cache has changed, and a widget which is using this Store
11207 * as a Record cache should refresh its view.
11208 * @param {Store} this
11210 datachanged : true,
11212 * @event metachange
11213 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
11214 * @param {Store} this
11215 * @param {Object} meta The JSON metadata
11220 * Fires when Records have been added to the Store
11221 * @param {Store} this
11222 * @param {Roo.data.Record[]} records The array of Records added
11223 * @param {Number} index The index at which the record(s) were added
11228 * Fires when a Record has been removed from the Store
11229 * @param {Store} this
11230 * @param {Roo.data.Record} record The Record that was removed
11231 * @param {Number} index The index at which the record was removed
11236 * Fires when a Record has been updated
11237 * @param {Store} this
11238 * @param {Roo.data.Record} record The Record that was updated
11239 * @param {String} operation The update operation being performed. Value may be one of:
11241 Roo.data.Record.EDIT
11242 Roo.data.Record.REJECT
11243 Roo.data.Record.COMMIT
11249 * Fires when the data cache has been cleared.
11250 * @param {Store} this
11254 * @event beforeload
11255 * Fires before a request is made for a new data object. If the beforeload handler returns false
11256 * the load action will be canceled.
11257 * @param {Store} this
11258 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11262 * @event beforeloadadd
11263 * Fires after a new set of Records has been loaded.
11264 * @param {Store} this
11265 * @param {Roo.data.Record[]} records The Records that were loaded
11266 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11268 beforeloadadd : true,
11271 * Fires after a new set of Records has been loaded, before they are added to the store.
11272 * @param {Store} this
11273 * @param {Roo.data.Record[]} records The Records that were loaded
11274 * @param {Object} options The loading options that were specified (see {@link #load} for details)
11275 * @params {Object} return from reader
11279 * @event loadexception
11280 * Fires if an exception occurs in the Proxy during loading.
11281 * Called with the signature of the Proxy's "loadexception" event.
11282 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
11285 * @param {Object} return from JsonData.reader() - success, totalRecords, records
11286 * @param {Object} load options
11287 * @param {Object} jsonData from your request (normally this contains the Exception)
11289 loadexception : true
11293 this.proxy = Roo.factory(this.proxy, Roo.data);
11294 this.proxy.xmodule = this.xmodule || false;
11295 this.relayEvents(this.proxy, ["loadexception"]);
11297 this.sortToggle = {};
11298 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
11300 Roo.data.Store.superclass.constructor.call(this);
11302 if(this.inlineData){
11303 this.loadData(this.inlineData);
11304 delete this.inlineData;
11308 Roo.extend(Roo.data.Store, Roo.util.Observable, {
11310 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
11311 * without a remote query - used by combo/forms at present.
11315 * @cfg {Roo.data.DataProxy} proxy The Proxy object which provides access to a data object.
11318 * @cfg {Array} data Inline data to be loaded when the store is initialized.
11321 * @cfg {Roo.data.Reader} reader The Reader object which processes the data object and returns
11322 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
11325 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
11326 * on any HTTP request
11329 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
11332 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
11336 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
11337 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
11339 remoteSort : false,
11342 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
11343 * loaded or when a record is removed. (defaults to false).
11345 pruneModifiedRecords : false,
11348 lastOptions : null,
11351 * Add Records to the Store and fires the add event.
11352 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11354 add : function(records){
11355 records = [].concat(records);
11356 for(var i = 0, len = records.length; i < len; i++){
11357 records[i].join(this);
11359 var index = this.data.length;
11360 this.data.addAll(records);
11361 this.fireEvent("add", this, records, index);
11365 * Remove a Record from the Store and fires the remove event.
11366 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
11368 remove : function(record){
11369 var index = this.data.indexOf(record);
11370 this.data.removeAt(index);
11372 if(this.pruneModifiedRecords){
11373 this.modified.remove(record);
11375 this.fireEvent("remove", this, record, index);
11379 * Remove all Records from the Store and fires the clear event.
11381 removeAll : function(){
11383 if(this.pruneModifiedRecords){
11384 this.modified = [];
11386 this.fireEvent("clear", this);
11390 * Inserts Records to the Store at the given index and fires the add event.
11391 * @param {Number} index The start index at which to insert the passed Records.
11392 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
11394 insert : function(index, records){
11395 records = [].concat(records);
11396 for(var i = 0, len = records.length; i < len; i++){
11397 this.data.insert(index, records[i]);
11398 records[i].join(this);
11400 this.fireEvent("add", this, records, index);
11404 * Get the index within the cache of the passed Record.
11405 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
11406 * @return {Number} The index of the passed Record. Returns -1 if not found.
11408 indexOf : function(record){
11409 return this.data.indexOf(record);
11413 * Get the index within the cache of the Record with the passed id.
11414 * @param {String} id The id of the Record to find.
11415 * @return {Number} The index of the Record. Returns -1 if not found.
11417 indexOfId : function(id){
11418 return this.data.indexOfKey(id);
11422 * Get the Record with the specified id.
11423 * @param {String} id The id of the Record to find.
11424 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
11426 getById : function(id){
11427 return this.data.key(id);
11431 * Get the Record at the specified index.
11432 * @param {Number} index The index of the Record to find.
11433 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
11435 getAt : function(index){
11436 return this.data.itemAt(index);
11440 * Returns a range of Records between specified indices.
11441 * @param {Number} startIndex (optional) The starting index (defaults to 0)
11442 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
11443 * @return {Roo.data.Record[]} An array of Records
11445 getRange : function(start, end){
11446 return this.data.getRange(start, end);
11450 storeOptions : function(o){
11451 o = Roo.apply({}, o);
11454 this.lastOptions = o;
11458 * Loads the Record cache from the configured Proxy using the configured Reader.
11460 * If using remote paging, then the first load call must specify the <em>start</em>
11461 * and <em>limit</em> properties in the options.params property to establish the initial
11462 * position within the dataset, and the number of Records to cache on each read from the Proxy.
11464 * <strong>It is important to note that for remote data sources, loading is asynchronous,
11465 * and this call will return before the new data has been loaded. Perform any post-processing
11466 * in a callback function, or in a "load" event handler.</strong>
11468 * @param {Object} options An object containing properties which control loading options:<ul>
11469 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
11470 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
11471 * passed the following arguments:<ul>
11472 * <li>r : Roo.data.Record[]</li>
11473 * <li>options: Options object from the load call</li>
11474 * <li>success: Boolean success indicator</li></ul></li>
11475 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
11476 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
11479 load : function(options){
11480 options = options || {};
11481 if(this.fireEvent("beforeload", this, options) !== false){
11482 this.storeOptions(options);
11483 var p = Roo.apply(options.params || {}, this.baseParams);
11484 // if meta was not loaded from remote source.. try requesting it.
11485 if (!this.reader.metaFromRemote) {
11486 p._requestMeta = 1;
11488 if(this.sortInfo && this.remoteSort){
11489 var pn = this.paramNames;
11490 p[pn["sort"]] = this.sortInfo.field;
11491 p[pn["dir"]] = this.sortInfo.direction;
11493 if (this.multiSort) {
11494 var pn = this.paramNames;
11495 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
11498 this.proxy.load(p, this.reader, this.loadRecords, this, options);
11503 * Reloads the Record cache from the configured Proxy using the configured Reader and
11504 * the options from the last load operation performed.
11505 * @param {Object} options (optional) An object containing properties which may override the options
11506 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
11507 * the most recently used options are reused).
11509 reload : function(options){
11510 this.load(Roo.applyIf(options||{}, this.lastOptions));
11514 // Called as a callback by the Reader during a load operation.
11515 loadRecords : function(o, options, success){
11516 if(!o || success === false){
11517 if(success !== false){
11518 this.fireEvent("load", this, [], options, o);
11520 if(options.callback){
11521 options.callback.call(options.scope || this, [], options, false);
11525 // if data returned failure - throw an exception.
11526 if (o.success === false) {
11527 // show a message if no listener is registered.
11528 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
11529 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
11531 // loadmask wil be hooked into this..
11532 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
11535 var r = o.records, t = o.totalRecords || r.length;
11537 this.fireEvent("beforeloadadd", this, r, options, o);
11539 if(!options || options.add !== true){
11540 if(this.pruneModifiedRecords){
11541 this.modified = [];
11543 for(var i = 0, len = r.length; i < len; i++){
11547 this.data = this.snapshot;
11548 delete this.snapshot;
11551 this.data.addAll(r);
11552 this.totalLength = t;
11554 this.fireEvent("datachanged", this);
11556 this.totalLength = Math.max(t, this.data.length+r.length);
11560 if(this.parent && !Roo.isIOS && !this.useNativeIOS && this.parent.emptyTitle.length) {
11562 var e = new Roo.data.Record({});
11564 e.set(this.parent.displayField, this.parent.emptyTitle);
11565 e.set(this.parent.valueField, '');
11570 this.fireEvent("load", this, r, options, o);
11571 if(options.callback){
11572 options.callback.call(options.scope || this, r, options, true);
11578 * Loads data from a passed data block. A Reader which understands the format of the data
11579 * must have been configured in the constructor.
11580 * @param {Object} data The data block from which to read the Records. The format of the data expected
11581 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
11582 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
11584 loadData : function(o, append){
11585 var r = this.reader.readRecords(o);
11586 this.loadRecords(r, {add: append}, true);
11590 * Gets the number of cached records.
11592 * <em>If using paging, this may not be the total size of the dataset. If the data object
11593 * used by the Reader contains the dataset size, then the getTotalCount() function returns
11594 * the data set size</em>
11596 getCount : function(){
11597 return this.data.length || 0;
11601 * Gets the total number of records in the dataset as returned by the server.
11603 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
11604 * the dataset size</em>
11606 getTotalCount : function(){
11607 return this.totalLength || 0;
11611 * Returns the sort state of the Store as an object with two properties:
11613 field {String} The name of the field by which the Records are sorted
11614 direction {String} The sort order, "ASC" or "DESC"
11617 getSortState : function(){
11618 return this.sortInfo;
11622 applySort : function(){
11623 if(this.sortInfo && !this.remoteSort){
11624 var s = this.sortInfo, f = s.field;
11625 var st = this.fields.get(f).sortType;
11626 var fn = function(r1, r2){
11627 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
11628 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
11630 this.data.sort(s.direction, fn);
11631 if(this.snapshot && this.snapshot != this.data){
11632 this.snapshot.sort(s.direction, fn);
11638 * Sets the default sort column and order to be used by the next load operation.
11639 * @param {String} fieldName The name of the field to sort by.
11640 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11642 setDefaultSort : function(field, dir){
11643 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
11647 * Sort the Records.
11648 * If remote sorting is used, the sort is performed on the server, and the cache is
11649 * reloaded. If local sorting is used, the cache is sorted internally.
11650 * @param {String} fieldName The name of the field to sort by.
11651 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11653 sort : function(fieldName, dir){
11654 var f = this.fields.get(fieldName);
11656 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
11658 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
11659 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
11664 this.sortToggle[f.name] = dir;
11665 this.sortInfo = {field: f.name, direction: dir};
11666 if(!this.remoteSort){
11668 this.fireEvent("datachanged", this);
11670 this.load(this.lastOptions);
11675 * Calls the specified function for each of the Records in the cache.
11676 * @param {Function} fn The function to call. The Record is passed as the first parameter.
11677 * Returning <em>false</em> aborts and exits the iteration.
11678 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
11680 each : function(fn, scope){
11681 this.data.each(fn, scope);
11685 * Gets all records modified since the last commit. Modified records are persisted across load operations
11686 * (e.g., during paging).
11687 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
11689 getModifiedRecords : function(){
11690 return this.modified;
11694 createFilterFn : function(property, value, anyMatch){
11695 if(!value.exec){ // not a regex
11696 value = String(value);
11697 if(value.length == 0){
11700 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
11702 return function(r){
11703 return value.test(r.data[property]);
11708 * Sums the value of <i>property</i> for each record between start and end and returns the result.
11709 * @param {String} property A field on your records
11710 * @param {Number} start The record index to start at (defaults to 0)
11711 * @param {Number} end The last record index to include (defaults to length - 1)
11712 * @return {Number} The sum
11714 sum : function(property, start, end){
11715 var rs = this.data.items, v = 0;
11716 start = start || 0;
11717 end = (end || end === 0) ? end : rs.length-1;
11719 for(var i = start; i <= end; i++){
11720 v += (rs[i].data[property] || 0);
11726 * Filter the records by a specified property.
11727 * @param {String} field A field on your records
11728 * @param {String/RegExp} value Either a string that the field
11729 * should start with or a RegExp to test against the field
11730 * @param {Boolean} anyMatch True to match any part not just the beginning
11732 filter : function(property, value, anyMatch){
11733 var fn = this.createFilterFn(property, value, anyMatch);
11734 return fn ? this.filterBy(fn) : this.clearFilter();
11738 * Filter by a function. The specified function will be called with each
11739 * record in this data source. If the function returns true the record is included,
11740 * otherwise it is filtered.
11741 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11742 * @param {Object} scope (optional) The scope of the function (defaults to this)
11744 filterBy : function(fn, scope){
11745 this.snapshot = this.snapshot || this.data;
11746 this.data = this.queryBy(fn, scope||this);
11747 this.fireEvent("datachanged", this);
11751 * Query the records by a specified property.
11752 * @param {String} field A field on your records
11753 * @param {String/RegExp} value Either a string that the field
11754 * should start with or a RegExp to test against the field
11755 * @param {Boolean} anyMatch True to match any part not just the beginning
11756 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11758 query : function(property, value, anyMatch){
11759 var fn = this.createFilterFn(property, value, anyMatch);
11760 return fn ? this.queryBy(fn) : this.data.clone();
11764 * Query by a function. The specified function will be called with each
11765 * record in this data source. If the function returns true the record is included
11767 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11768 * @param {Object} scope (optional) The scope of the function (defaults to this)
11769 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11771 queryBy : function(fn, scope){
11772 var data = this.snapshot || this.data;
11773 return data.filterBy(fn, scope||this);
11777 * Collects unique values for a particular dataIndex from this store.
11778 * @param {String} dataIndex The property to collect
11779 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
11780 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
11781 * @return {Array} An array of the unique values
11783 collect : function(dataIndex, allowNull, bypassFilter){
11784 var d = (bypassFilter === true && this.snapshot) ?
11785 this.snapshot.items : this.data.items;
11786 var v, sv, r = [], l = {};
11787 for(var i = 0, len = d.length; i < len; i++){
11788 v = d[i].data[dataIndex];
11790 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
11799 * Revert to a view of the Record cache with no filtering applied.
11800 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
11802 clearFilter : function(suppressEvent){
11803 if(this.snapshot && this.snapshot != this.data){
11804 this.data = this.snapshot;
11805 delete this.snapshot;
11806 if(suppressEvent !== true){
11807 this.fireEvent("datachanged", this);
11813 afterEdit : function(record){
11814 if(this.modified.indexOf(record) == -1){
11815 this.modified.push(record);
11817 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
11821 afterReject : function(record){
11822 this.modified.remove(record);
11823 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
11827 afterCommit : function(record){
11828 this.modified.remove(record);
11829 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
11833 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
11834 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
11836 commitChanges : function(){
11837 var m = this.modified.slice(0);
11838 this.modified = [];
11839 for(var i = 0, len = m.length; i < len; i++){
11845 * Cancel outstanding changes on all changed records.
11847 rejectChanges : function(){
11848 var m = this.modified.slice(0);
11849 this.modified = [];
11850 for(var i = 0, len = m.length; i < len; i++){
11855 onMetaChange : function(meta, rtype, o){
11856 this.recordType = rtype;
11857 this.fields = rtype.prototype.fields;
11858 delete this.snapshot;
11859 this.sortInfo = meta.sortInfo || this.sortInfo;
11860 this.modified = [];
11861 this.fireEvent('metachange', this, this.reader.meta);
11864 moveIndex : function(data, type)
11866 var index = this.indexOf(data);
11868 var newIndex = index + type;
11872 this.insert(newIndex, data);
11877 * Ext JS Library 1.1.1
11878 * Copyright(c) 2006-2007, Ext JS, LLC.
11880 * Originally Released Under LGPL - original licence link has changed is not relivant.
11883 * <script type="text/javascript">
11887 * @class Roo.data.SimpleStore
11888 * @extends Roo.data.Store
11889 * Small helper class to make creating Stores from Array data easier.
11890 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
11891 * @cfg {Array} fields An array of field definition objects, or field name strings.
11892 * @cfg {Array} data The multi-dimensional array of data
11894 * @param {Object} config
11896 Roo.data.SimpleStore = function(config){
11897 Roo.data.SimpleStore.superclass.constructor.call(this, {
11899 reader: new Roo.data.ArrayReader({
11902 Roo.data.Record.create(config.fields)
11904 proxy : new Roo.data.MemoryProxy(config.data)
11908 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
11910 * Ext JS Library 1.1.1
11911 * Copyright(c) 2006-2007, Ext JS, LLC.
11913 * Originally Released Under LGPL - original licence link has changed is not relivant.
11916 * <script type="text/javascript">
11921 * @extends Roo.data.Store
11922 * @class Roo.data.JsonStore
11923 * Small helper class to make creating Stores for JSON data easier. <br/>
11925 var store = new Roo.data.JsonStore({
11926 url: 'get-images.php',
11928 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
11931 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
11932 * JsonReader and HttpProxy (unless inline data is provided).</b>
11933 * @cfg {Array} fields An array of field definition objects, or field name strings.
11935 * @param {Object} config
11937 Roo.data.JsonStore = function(c){
11938 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
11939 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
11940 reader: new Roo.data.JsonReader(c, c.fields)
11943 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
11945 * Ext JS Library 1.1.1
11946 * Copyright(c) 2006-2007, Ext JS, LLC.
11948 * Originally Released Under LGPL - original licence link has changed is not relivant.
11951 * <script type="text/javascript">
11955 Roo.data.Field = function(config){
11956 if(typeof config == "string"){
11957 config = {name: config};
11959 Roo.apply(this, config);
11962 this.type = "auto";
11965 var st = Roo.data.SortTypes;
11966 // named sortTypes are supported, here we look them up
11967 if(typeof this.sortType == "string"){
11968 this.sortType = st[this.sortType];
11971 // set default sortType for strings and dates
11972 if(!this.sortType){
11975 this.sortType = st.asUCString;
11978 this.sortType = st.asDate;
11981 this.sortType = st.none;
11986 var stripRe = /[\$,%]/g;
11988 // prebuilt conversion function for this field, instead of
11989 // switching every time we're reading a value
11991 var cv, dateFormat = this.dateFormat;
11996 cv = function(v){ return v; };
11999 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
12003 return v !== undefined && v !== null && v !== '' ?
12004 parseInt(String(v).replace(stripRe, ""), 10) : '';
12009 return v !== undefined && v !== null && v !== '' ?
12010 parseFloat(String(v).replace(stripRe, ""), 10) : '';
12015 cv = function(v){ return v === true || v === "true" || v == 1; };
12022 if(v instanceof Date){
12026 if(dateFormat == "timestamp"){
12027 return new Date(v*1000);
12029 return Date.parseDate(v, dateFormat);
12031 var parsed = Date.parse(v);
12032 return parsed ? new Date(parsed) : null;
12041 Roo.data.Field.prototype = {
12049 * Ext JS Library 1.1.1
12050 * Copyright(c) 2006-2007, Ext JS, LLC.
12052 * Originally Released Under LGPL - original licence link has changed is not relivant.
12055 * <script type="text/javascript">
12058 // Base class for reading structured data from a data source. This class is intended to be
12059 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
12062 * @class Roo.data.DataReader
12063 * Base class for reading structured data from a data source. This class is intended to be
12064 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
12067 Roo.data.DataReader = function(meta, recordType){
12071 this.recordType = recordType instanceof Array ?
12072 Roo.data.Record.create(recordType) : recordType;
12075 Roo.data.DataReader.prototype = {
12077 * Create an empty record
12078 * @param {Object} data (optional) - overlay some values
12079 * @return {Roo.data.Record} record created.
12081 newRow : function(d) {
12083 this.recordType.prototype.fields.each(function(c) {
12085 case 'int' : da[c.name] = 0; break;
12086 case 'date' : da[c.name] = new Date(); break;
12087 case 'float' : da[c.name] = 0.0; break;
12088 case 'boolean' : da[c.name] = false; break;
12089 default : da[c.name] = ""; break;
12093 return new this.recordType(Roo.apply(da, d));
12098 * Ext JS Library 1.1.1
12099 * Copyright(c) 2006-2007, Ext JS, LLC.
12101 * Originally Released Under LGPL - original licence link has changed is not relivant.
12104 * <script type="text/javascript">
12108 * @class Roo.data.DataProxy
12109 * @extends Roo.data.Observable
12110 * This class is an abstract base class for implementations which provide retrieval of
12111 * unformatted data objects.<br>
12113 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
12114 * (of the appropriate type which knows how to parse the data object) to provide a block of
12115 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
12117 * Custom implementations must implement the load method as described in
12118 * {@link Roo.data.HttpProxy#load}.
12120 Roo.data.DataProxy = function(){
12123 * @event beforeload
12124 * Fires before a network request is made to retrieve a data object.
12125 * @param {Object} This DataProxy object.
12126 * @param {Object} params The params parameter to the load function.
12131 * Fires before the load method's callback is called.
12132 * @param {Object} This DataProxy object.
12133 * @param {Object} o The data object.
12134 * @param {Object} arg The callback argument object passed to the load function.
12138 * @event loadexception
12139 * Fires if an Exception occurs during data retrieval.
12140 * @param {Object} This DataProxy object.
12141 * @param {Object} o The data object.
12142 * @param {Object} arg The callback argument object passed to the load function.
12143 * @param {Object} e The Exception.
12145 loadexception : true
12147 Roo.data.DataProxy.superclass.constructor.call(this);
12150 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
12153 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
12157 * Ext JS Library 1.1.1
12158 * Copyright(c) 2006-2007, Ext JS, LLC.
12160 * Originally Released Under LGPL - original licence link has changed is not relivant.
12163 * <script type="text/javascript">
12166 * @class Roo.data.MemoryProxy
12167 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
12168 * to the Reader when its load method is called.
12170 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
12172 Roo.data.MemoryProxy = function(data){
12176 Roo.data.MemoryProxy.superclass.constructor.call(this);
12180 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
12183 * Load data from the requested source (in this case an in-memory
12184 * data object passed to the constructor), read the data object into
12185 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12186 * process that block using the passed callback.
12187 * @param {Object} params This parameter is not used by the MemoryProxy class.
12188 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12189 * object into a block of Roo.data.Records.
12190 * @param {Function} callback The function into which to pass the block of Roo.data.records.
12191 * The function must be passed <ul>
12192 * <li>The Record block object</li>
12193 * <li>The "arg" argument from the load function</li>
12194 * <li>A boolean success indicator</li>
12196 * @param {Object} scope The scope in which to call the callback
12197 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12199 load : function(params, reader, callback, scope, arg){
12200 params = params || {};
12203 result = reader.readRecords(this.data);
12205 this.fireEvent("loadexception", this, arg, null, e);
12206 callback.call(scope, null, arg, false);
12209 callback.call(scope, result, arg, true);
12213 update : function(params, records){
12218 * Ext JS Library 1.1.1
12219 * Copyright(c) 2006-2007, Ext JS, LLC.
12221 * Originally Released Under LGPL - original licence link has changed is not relivant.
12224 * <script type="text/javascript">
12227 * @class Roo.data.HttpProxy
12228 * @extends Roo.data.DataProxy
12229 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
12230 * configured to reference a certain URL.<br><br>
12232 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
12233 * from which the running page was served.<br><br>
12235 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
12237 * Be aware that to enable the browser to parse an XML document, the server must set
12238 * the Content-Type header in the HTTP response to "text/xml".
12240 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
12241 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
12242 * will be used to make the request.
12244 Roo.data.HttpProxy = function(conn){
12245 Roo.data.HttpProxy.superclass.constructor.call(this);
12246 // is conn a conn config or a real conn?
12248 this.useAjax = !conn || !conn.events;
12252 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
12253 // thse are take from connection...
12256 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
12259 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
12260 * extra parameters to each request made by this object. (defaults to undefined)
12263 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
12264 * to each request made by this object. (defaults to undefined)
12267 * @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)
12270 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
12273 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
12279 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
12283 * Return the {@link Roo.data.Connection} object being used by this Proxy.
12284 * @return {Connection} The Connection object. This object may be used to subscribe to events on
12285 * a finer-grained basis than the DataProxy events.
12287 getConnection : function(){
12288 return this.useAjax ? Roo.Ajax : this.conn;
12292 * Load data from the configured {@link Roo.data.Connection}, read the data object into
12293 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
12294 * process that block using the passed callback.
12295 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12296 * for the request to the remote server.
12297 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12298 * object into a block of Roo.data.Records.
12299 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12300 * The function must be passed <ul>
12301 * <li>The Record block object</li>
12302 * <li>The "arg" argument from the load function</li>
12303 * <li>A boolean success indicator</li>
12305 * @param {Object} scope The scope in which to call the callback
12306 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12308 load : function(params, reader, callback, scope, arg){
12309 if(this.fireEvent("beforeload", this, params) !== false){
12311 params : params || {},
12313 callback : callback,
12318 callback : this.loadResponse,
12322 Roo.applyIf(o, this.conn);
12323 if(this.activeRequest){
12324 Roo.Ajax.abort(this.activeRequest);
12326 this.activeRequest = Roo.Ajax.request(o);
12328 this.conn.request(o);
12331 callback.call(scope||this, null, arg, false);
12336 loadResponse : function(o, success, response){
12337 delete this.activeRequest;
12339 this.fireEvent("loadexception", this, o, response);
12340 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12345 result = o.reader.read(response);
12347 this.fireEvent("loadexception", this, o, response, e);
12348 o.request.callback.call(o.request.scope, null, o.request.arg, false);
12352 this.fireEvent("load", this, o, o.request.arg);
12353 o.request.callback.call(o.request.scope, result, o.request.arg, true);
12357 update : function(dataSet){
12362 updateResponse : function(dataSet){
12367 * Ext JS Library 1.1.1
12368 * Copyright(c) 2006-2007, Ext JS, LLC.
12370 * Originally Released Under LGPL - original licence link has changed is not relivant.
12373 * <script type="text/javascript">
12377 * @class Roo.data.ScriptTagProxy
12378 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
12379 * other than the originating domain of the running page.<br><br>
12381 * <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
12382 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
12384 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
12385 * source code that is used as the source inside a <script> tag.<br><br>
12387 * In order for the browser to process the returned data, the server must wrap the data object
12388 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
12389 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
12390 * depending on whether the callback name was passed:
12393 boolean scriptTag = false;
12394 String cb = request.getParameter("callback");
12397 response.setContentType("text/javascript");
12399 response.setContentType("application/x-json");
12401 Writer out = response.getWriter();
12403 out.write(cb + "(");
12405 out.print(dataBlock.toJsonString());
12412 * @param {Object} config A configuration object.
12414 Roo.data.ScriptTagProxy = function(config){
12415 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
12416 Roo.apply(this, config);
12417 this.head = document.getElementsByTagName("head")[0];
12420 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
12422 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
12424 * @cfg {String} url The URL from which to request the data object.
12427 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
12431 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
12432 * the server the name of the callback function set up by the load call to process the returned data object.
12433 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
12434 * javascript output which calls this named function passing the data object as its only parameter.
12436 callbackParam : "callback",
12438 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
12439 * name to the request.
12444 * Load data from the configured URL, read the data object into
12445 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
12446 * process that block using the passed callback.
12447 * @param {Object} params An object containing properties which are to be used as HTTP parameters
12448 * for the request to the remote server.
12449 * @param {Roo.data.DataReader} reader The Reader object which converts the data
12450 * object into a block of Roo.data.Records.
12451 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
12452 * The function must be passed <ul>
12453 * <li>The Record block object</li>
12454 * <li>The "arg" argument from the load function</li>
12455 * <li>A boolean success indicator</li>
12457 * @param {Object} scope The scope in which to call the callback
12458 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
12460 load : function(params, reader, callback, scope, arg){
12461 if(this.fireEvent("beforeload", this, params) !== false){
12463 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
12465 var url = this.url;
12466 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
12468 url += "&_dc=" + (new Date().getTime());
12470 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
12473 cb : "stcCallback"+transId,
12474 scriptId : "stcScript"+transId,
12478 callback : callback,
12484 window[trans.cb] = function(o){
12485 conn.handleResponse(o, trans);
12488 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
12490 if(this.autoAbort !== false){
12494 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
12496 var script = document.createElement("script");
12497 script.setAttribute("src", url);
12498 script.setAttribute("type", "text/javascript");
12499 script.setAttribute("id", trans.scriptId);
12500 this.head.appendChild(script);
12502 this.trans = trans;
12504 callback.call(scope||this, null, arg, false);
12509 isLoading : function(){
12510 return this.trans ? true : false;
12514 * Abort the current server request.
12516 abort : function(){
12517 if(this.isLoading()){
12518 this.destroyTrans(this.trans);
12523 destroyTrans : function(trans, isLoaded){
12524 this.head.removeChild(document.getElementById(trans.scriptId));
12525 clearTimeout(trans.timeoutId);
12527 window[trans.cb] = undefined;
12529 delete window[trans.cb];
12532 // if hasn't been loaded, wait for load to remove it to prevent script error
12533 window[trans.cb] = function(){
12534 window[trans.cb] = undefined;
12536 delete window[trans.cb];
12543 handleResponse : function(o, trans){
12544 this.trans = false;
12545 this.destroyTrans(trans, true);
12548 result = trans.reader.readRecords(o);
12550 this.fireEvent("loadexception", this, o, trans.arg, e);
12551 trans.callback.call(trans.scope||window, null, trans.arg, false);
12554 this.fireEvent("load", this, o, trans.arg);
12555 trans.callback.call(trans.scope||window, result, trans.arg, true);
12559 handleFailure : function(trans){
12560 this.trans = false;
12561 this.destroyTrans(trans, false);
12562 this.fireEvent("loadexception", this, null, trans.arg);
12563 trans.callback.call(trans.scope||window, null, trans.arg, false);
12567 * Ext JS Library 1.1.1
12568 * Copyright(c) 2006-2007, Ext JS, LLC.
12570 * Originally Released Under LGPL - original licence link has changed is not relivant.
12573 * <script type="text/javascript">
12577 * @class Roo.data.JsonReader
12578 * @extends Roo.data.DataReader
12579 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
12580 * based on mappings in a provided Roo.data.Record constructor.
12582 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
12583 * in the reply previously.
12588 var RecordDef = Roo.data.Record.create([
12589 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
12590 {name: 'occupation'} // This field will use "occupation" as the mapping.
12592 var myReader = new Roo.data.JsonReader({
12593 totalProperty: "results", // The property which contains the total dataset size (optional)
12594 root: "rows", // The property which contains an Array of row objects
12595 id: "id" // The property within each row object that provides an ID for the record (optional)
12599 * This would consume a JSON file like this:
12601 { 'results': 2, 'rows': [
12602 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
12603 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
12606 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
12607 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
12608 * paged from the remote server.
12609 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
12610 * @cfg {String} root name of the property which contains the Array of row objects.
12611 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
12612 * @cfg {Array} fields Array of field definition objects
12614 * Create a new JsonReader
12615 * @param {Object} meta Metadata configuration options
12616 * @param {Object} recordType Either an Array of field definition objects,
12617 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
12619 Roo.data.JsonReader = function(meta, recordType){
12622 // set some defaults:
12623 Roo.applyIf(meta, {
12624 totalProperty: 'total',
12625 successProperty : 'success',
12630 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
12632 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
12635 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
12636 * Used by Store query builder to append _requestMeta to params.
12639 metaFromRemote : false,
12641 * This method is only used by a DataProxy which has retrieved data from a remote server.
12642 * @param {Object} response The XHR object which contains the JSON data in its responseText.
12643 * @return {Object} data A data block which is used by an Roo.data.Store object as
12644 * a cache of Roo.data.Records.
12646 read : function(response){
12647 var json = response.responseText;
12649 var o = /* eval:var:o */ eval("("+json+")");
12651 throw {message: "JsonReader.read: Json object not found"};
12657 this.metaFromRemote = true;
12658 this.meta = o.metaData;
12659 this.recordType = Roo.data.Record.create(o.metaData.fields);
12660 this.onMetaChange(this.meta, this.recordType, o);
12662 return this.readRecords(o);
12665 // private function a store will implement
12666 onMetaChange : function(meta, recordType, o){
12673 simpleAccess: function(obj, subsc) {
12680 getJsonAccessor: function(){
12682 return function(expr) {
12684 return(re.test(expr))
12685 ? new Function("obj", "return obj." + expr)
12690 return Roo.emptyFn;
12695 * Create a data block containing Roo.data.Records from an XML document.
12696 * @param {Object} o An object which contains an Array of row objects in the property specified
12697 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
12698 * which contains the total size of the dataset.
12699 * @return {Object} data A data block which is used by an Roo.data.Store object as
12700 * a cache of Roo.data.Records.
12702 readRecords : function(o){
12704 * After any data loads, the raw JSON data is available for further custom processing.
12708 var s = this.meta, Record = this.recordType,
12709 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
12711 // Generate extraction functions for the totalProperty, the root, the id, and for each field
12713 if(s.totalProperty) {
12714 this.getTotal = this.getJsonAccessor(s.totalProperty);
12716 if(s.successProperty) {
12717 this.getSuccess = this.getJsonAccessor(s.successProperty);
12719 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
12721 var g = this.getJsonAccessor(s.id);
12722 this.getId = function(rec) {
12724 return (r === undefined || r === "") ? null : r;
12727 this.getId = function(){return null;};
12730 for(var jj = 0; jj < fl; jj++){
12732 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
12733 this.ef[jj] = this.getJsonAccessor(map);
12737 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
12738 if(s.totalProperty){
12739 var vt = parseInt(this.getTotal(o), 10);
12744 if(s.successProperty){
12745 var vs = this.getSuccess(o);
12746 if(vs === false || vs === 'false'){
12751 for(var i = 0; i < c; i++){
12754 var id = this.getId(n);
12755 for(var j = 0; j < fl; j++){
12757 var v = this.ef[j](n);
12759 Roo.log('missing convert for ' + f.name);
12763 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
12765 var record = new Record(values, id);
12767 records[i] = record;
12773 totalRecords : totalRecords
12778 * Ext JS Library 1.1.1
12779 * Copyright(c) 2006-2007, Ext JS, LLC.
12781 * Originally Released Under LGPL - original licence link has changed is not relivant.
12784 * <script type="text/javascript">
12788 * @class Roo.data.ArrayReader
12789 * @extends Roo.data.DataReader
12790 * Data reader class to create an Array of Roo.data.Record objects from an Array.
12791 * Each element of that Array represents a row of data fields. The
12792 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
12793 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
12797 var RecordDef = Roo.data.Record.create([
12798 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
12799 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
12801 var myReader = new Roo.data.ArrayReader({
12802 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
12806 * This would consume an Array like this:
12808 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
12810 * @cfg {String} id (optional) The subscript within row Array that provides an ID for the Record
12812 * Create a new JsonReader
12813 * @param {Object} meta Metadata configuration options.
12814 * @param {Object} recordType Either an Array of field definition objects
12815 * as specified to {@link Roo.data.Record#create},
12816 * or an {@link Roo.data.Record} object
12817 * created using {@link Roo.data.Record#create}.
12819 Roo.data.ArrayReader = function(meta, recordType){
12820 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType);
12823 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
12825 * Create a data block containing Roo.data.Records from an XML document.
12826 * @param {Object} o An Array of row objects which represents the dataset.
12827 * @return {Object} data A data block which is used by an Roo.data.Store object as
12828 * a cache of Roo.data.Records.
12830 readRecords : function(o){
12831 var sid = this.meta ? this.meta.id : null;
12832 var recordType = this.recordType, fields = recordType.prototype.fields;
12835 for(var i = 0; i < root.length; i++){
12838 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
12839 for(var j = 0, jlen = fields.length; j < jlen; j++){
12840 var f = fields.items[j];
12841 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
12842 var v = n[k] !== undefined ? n[k] : f.defaultValue;
12844 values[f.name] = v;
12846 var record = new recordType(values, id);
12848 records[records.length] = record;
12852 totalRecords : records.length
12861 * @class Roo.bootstrap.ComboBox
12862 * @extends Roo.bootstrap.TriggerField
12863 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
12864 * @cfg {Boolean} append (true|false) default false
12865 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
12866 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
12867 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
12868 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
12869 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
12870 * @cfg {Boolean} animate default true
12871 * @cfg {Boolean} emptyResultText only for touch device
12872 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
12873 * @cfg {String} emptyTitle default ''
12875 * Create a new ComboBox.
12876 * @param {Object} config Configuration options
12878 Roo.bootstrap.ComboBox = function(config){
12879 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
12883 * Fires when the dropdown list is expanded
12884 * @param {Roo.bootstrap.ComboBox} combo This combo box
12889 * Fires when the dropdown list is collapsed
12890 * @param {Roo.bootstrap.ComboBox} combo This combo box
12894 * @event beforeselect
12895 * Fires before a list item is selected. Return false to cancel the selection.
12896 * @param {Roo.bootstrap.ComboBox} combo This combo box
12897 * @param {Roo.data.Record} record The data record returned from the underlying store
12898 * @param {Number} index The index of the selected item in the dropdown list
12900 'beforeselect' : true,
12903 * Fires when a list item is selected
12904 * @param {Roo.bootstrap.ComboBox} combo This combo box
12905 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
12906 * @param {Number} index The index of the selected item in the dropdown list
12910 * @event beforequery
12911 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
12912 * The event object passed has these properties:
12913 * @param {Roo.bootstrap.ComboBox} combo This combo box
12914 * @param {String} query The query
12915 * @param {Boolean} forceAll true to force "all" query
12916 * @param {Boolean} cancel true to cancel the query
12917 * @param {Object} e The query event object
12919 'beforequery': true,
12922 * Fires when the 'add' icon is pressed (add a listener to enable add button)
12923 * @param {Roo.bootstrap.ComboBox} combo This combo box
12928 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
12929 * @param {Roo.bootstrap.ComboBox} combo This combo box
12930 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
12935 * Fires when the remove value from the combobox array
12936 * @param {Roo.bootstrap.ComboBox} combo This combo box
12940 * @event afterremove
12941 * Fires when the remove value from the combobox array
12942 * @param {Roo.bootstrap.ComboBox} combo This combo box
12944 'afterremove' : true,
12946 * @event specialfilter
12947 * Fires when specialfilter
12948 * @param {Roo.bootstrap.ComboBox} combo This combo box
12950 'specialfilter' : true,
12953 * Fires when tick the element
12954 * @param {Roo.bootstrap.ComboBox} combo This combo box
12958 * @event touchviewdisplay
12959 * Fires when touch view require special display (default is using displayField)
12960 * @param {Roo.bootstrap.ComboBox} combo This combo box
12961 * @param {Object} cfg set html .
12963 'touchviewdisplay' : true
12968 this.tickItems = [];
12970 this.selectedIndex = -1;
12971 if(this.mode == 'local'){
12972 if(config.queryDelay === undefined){
12973 this.queryDelay = 10;
12975 if(config.minChars === undefined){
12981 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
12984 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
12985 * rendering into an Roo.Editor, defaults to false)
12988 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
12989 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
12992 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
12995 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
12996 * the dropdown list (defaults to undefined, with no header element)
13000 * @cfg {String/Roo.Template} tpl The template to use to render the output
13004 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
13006 listWidth: undefined,
13008 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
13009 * mode = 'remote' or 'text' if mode = 'local')
13011 displayField: undefined,
13014 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
13015 * mode = 'remote' or 'value' if mode = 'local').
13016 * Note: use of a valueField requires the user make a selection
13017 * in order for a value to be mapped.
13019 valueField: undefined,
13021 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
13026 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
13027 * field's data value (defaults to the underlying DOM element's name)
13029 hiddenName: undefined,
13031 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
13035 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
13037 selectedClass: 'active',
13040 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
13044 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
13045 * anchor positions (defaults to 'tl-bl')
13047 listAlign: 'tl-bl?',
13049 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
13053 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
13054 * query specified by the allQuery config option (defaults to 'query')
13056 triggerAction: 'query',
13058 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
13059 * (defaults to 4, does not apply if editable = false)
13063 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
13064 * delay (typeAheadDelay) if it matches a known value (defaults to false)
13068 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
13069 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
13073 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
13074 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
13078 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
13079 * when editable = true (defaults to false)
13081 selectOnFocus:false,
13083 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
13085 queryParam: 'query',
13087 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
13088 * when mode = 'remote' (defaults to 'Loading...')
13090 loadingText: 'Loading...',
13092 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
13096 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
13100 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
13101 * traditional select (defaults to true)
13105 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
13109 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
13113 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
13114 * listWidth has a higher value)
13118 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
13119 * allow the user to set arbitrary text into the field (defaults to false)
13121 forceSelection:false,
13123 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
13124 * if typeAhead = true (defaults to 250)
13126 typeAheadDelay : 250,
13128 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
13129 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
13131 valueNotFoundText : undefined,
13133 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
13135 blockFocus : false,
13138 * @cfg {Boolean} disableClear Disable showing of clear button.
13140 disableClear : false,
13142 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
13144 alwaysQuery : false,
13147 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
13152 * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")
13154 invalidClass : "has-warning",
13157 * @cfg {String} validClass The CSS class to use when marking a field valid (defaults to "x-form-invalid")
13159 validClass : "has-success",
13162 * @cfg {Boolean} specialFilter (true|false) special filter default false
13164 specialFilter : false,
13167 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
13169 mobileTouchView : true,
13172 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
13174 useNativeIOS : false,
13177 * @cfg {Boolean} mobile_restrict_height (true|false) restrict height for touch view
13179 mobile_restrict_height : false,
13181 ios_options : false,
13193 btnPosition : 'right',
13194 triggerList : true,
13195 showToggleBtn : true,
13197 emptyResultText: 'Empty',
13198 triggerText : 'Select',
13201 // element that contains real text value.. (when hidden is used..)
13203 getAutoCreate : function()
13208 * Render classic select for iso
13211 if(Roo.isIOS && this.useNativeIOS){
13212 cfg = this.getAutoCreateNativeIOS();
13220 if(Roo.isTouch && this.mobileTouchView){
13221 cfg = this.getAutoCreateTouchView();
13228 if(!this.tickable){
13229 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
13234 * ComboBox with tickable selections
13237 var align = this.labelAlign || this.parentLabelAlign();
13240 cls : 'form-group roo-combobox-tickable' //input-group
13243 var btn_text_select = '';
13244 var btn_text_done = '';
13245 var btn_text_cancel = '';
13247 if (this.btn_text_show) {
13248 btn_text_select = 'Select';
13249 btn_text_done = 'Done';
13250 btn_text_cancel = 'Cancel';
13255 cls : 'tickable-buttons',
13260 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
13261 //html : this.triggerText
13262 html: btn_text_select
13268 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
13270 html: btn_text_done
13276 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
13278 html: btn_text_cancel
13284 buttons.cn.unshift({
13286 cls: 'roo-select2-search-field-input'
13292 Roo.each(buttons.cn, function(c){
13294 c.cls += ' btn-' + _this.size;
13297 if (_this.disabled) {
13308 cls: 'form-hidden-field'
13312 cls: 'roo-select2-choices',
13316 cls: 'roo-select2-search-field',
13327 cls: 'roo-select2-container input-group roo-select2-container-multi',
13332 // cls: 'typeahead typeahead-long dropdown-menu',
13333 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
13338 if(this.hasFeedback && !this.allowBlank){
13342 cls: 'glyphicon form-control-feedback'
13345 combobox.cn.push(feedback);
13349 if (align ==='left' && this.fieldLabel.length) {
13351 cfg.cls += ' roo-form-group-label-left';
13356 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
13357 tooltip : 'This field is required'
13362 cls : 'control-label',
13363 html : this.fieldLabel
13375 var labelCfg = cfg.cn[1];
13376 var contentCfg = cfg.cn[2];
13379 if(this.indicatorpos == 'right'){
13385 cls : 'control-label',
13389 html : this.fieldLabel
13393 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
13394 tooltip : 'This field is required'
13409 labelCfg = cfg.cn[0];
13410 contentCfg = cfg.cn[1];
13414 if(this.labelWidth > 12){
13415 labelCfg.style = "width: " + this.labelWidth + 'px';
13418 if(this.labelWidth < 13 && this.labelmd == 0){
13419 this.labelmd = this.labelWidth;
13422 if(this.labellg > 0){
13423 labelCfg.cls += ' col-lg-' + this.labellg;
13424 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
13427 if(this.labelmd > 0){
13428 labelCfg.cls += ' col-md-' + this.labelmd;
13429 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
13432 if(this.labelsm > 0){
13433 labelCfg.cls += ' col-sm-' + this.labelsm;
13434 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
13437 if(this.labelxs > 0){
13438 labelCfg.cls += ' col-xs-' + this.labelxs;
13439 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
13443 } else if ( this.fieldLabel.length) {
13444 // Roo.log(" label");
13448 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
13449 tooltip : 'This field is required'
13453 //cls : 'input-group-addon',
13454 html : this.fieldLabel
13459 if(this.indicatorpos == 'right'){
13463 //cls : 'input-group-addon',
13464 html : this.fieldLabel
13468 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
13469 tooltip : 'This field is required'
13478 // Roo.log(" no label && no align");
13485 ['xs','sm','md','lg'].map(function(size){
13486 if (settings[size]) {
13487 cfg.cls += ' col-' + size + '-' + settings[size];
13495 _initEventsCalled : false,
13498 initEvents: function()
13500 if (this._initEventsCalled) { // as we call render... prevent looping...
13503 this._initEventsCalled = true;
13506 throw "can not find store for combo";
13509 this.indicator = this.indicatorEl();
13511 this.store = Roo.factory(this.store, Roo.data);
13512 this.store.parent = this;
13514 // if we are building from html. then this element is so complex, that we can not really
13515 // use the rendered HTML.
13516 // so we have to trash and replace the previous code.
13517 if (Roo.XComponent.build_from_html) {
13518 // remove this element....
13519 var e = this.el.dom, k=0;
13520 while (e ) { e = e.previousSibling; ++k;}
13525 this.rendered = false;
13527 this.render(this.parent().getChildContainer(true), k);
13530 if(Roo.isIOS && this.useNativeIOS){
13531 this.initIOSView();
13539 if(Roo.isTouch && this.mobileTouchView){
13540 this.initTouchView();
13545 this.initTickableEvents();
13549 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
13551 if(this.hiddenName){
13553 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13555 this.hiddenField.dom.value =
13556 this.hiddenValue !== undefined ? this.hiddenValue :
13557 this.value !== undefined ? this.value : '';
13559 // prevent input submission
13560 this.el.dom.removeAttribute('name');
13561 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13566 // this.el.dom.setAttribute('autocomplete', 'off');
13569 var cls = 'x-combo-list';
13571 //this.list = new Roo.Layer({
13572 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
13578 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13579 _this.list.setWidth(lw);
13582 this.list.on('mouseover', this.onViewOver, this);
13583 this.list.on('mousemove', this.onViewMove, this);
13584 this.list.on('scroll', this.onViewScroll, this);
13587 this.list.swallowEvent('mousewheel');
13588 this.assetHeight = 0;
13591 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
13592 this.assetHeight += this.header.getHeight();
13595 this.innerList = this.list.createChild({cls:cls+'-inner'});
13596 this.innerList.on('mouseover', this.onViewOver, this);
13597 this.innerList.on('mousemove', this.onViewMove, this);
13598 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13600 if(this.allowBlank && !this.pageSize && !this.disableClear){
13601 this.footer = this.list.createChild({cls:cls+'-ft'});
13602 this.pageTb = new Roo.Toolbar(this.footer);
13606 this.footer = this.list.createChild({cls:cls+'-ft'});
13607 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
13608 {pageSize: this.pageSize});
13612 if (this.pageTb && this.allowBlank && !this.disableClear) {
13614 this.pageTb.add(new Roo.Toolbar.Fill(), {
13615 cls: 'x-btn-icon x-btn-clear',
13617 handler: function()
13620 _this.clearValue();
13621 _this.onSelect(false, -1);
13626 this.assetHeight += this.footer.getHeight();
13631 this.tpl = '<li><a href="#">{' + this.displayField + '}</a></li>';
13634 this.view = new Roo.View(this.list, this.tpl, {
13635 singleSelect:true, store: this.store, selectedClass: this.selectedClass
13637 //this.view.wrapEl.setDisplayed(false);
13638 this.view.on('click', this.onViewClick, this);
13641 this.store.on('beforeload', this.onBeforeLoad, this);
13642 this.store.on('load', this.onLoad, this);
13643 this.store.on('loadexception', this.onLoadException, this);
13645 if(this.resizable){
13646 this.resizer = new Roo.Resizable(this.list, {
13647 pinned:true, handles:'se'
13649 this.resizer.on('resize', function(r, w, h){
13650 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
13651 this.listWidth = w;
13652 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
13653 this.restrictHeight();
13655 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
13658 if(!this.editable){
13659 this.editable = true;
13660 this.setEditable(false);
13665 if (typeof(this.events.add.listeners) != 'undefined') {
13667 this.addicon = this.wrap.createChild(
13668 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
13670 this.addicon.on('click', function(e) {
13671 this.fireEvent('add', this);
13674 if (typeof(this.events.edit.listeners) != 'undefined') {
13676 this.editicon = this.wrap.createChild(
13677 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
13678 if (this.addicon) {
13679 this.editicon.setStyle('margin-left', '40px');
13681 this.editicon.on('click', function(e) {
13683 // we fire even if inothing is selected..
13684 this.fireEvent('edit', this, this.lastData );
13690 this.keyNav = new Roo.KeyNav(this.inputEl(), {
13691 "up" : function(e){
13692 this.inKeyMode = true;
13696 "down" : function(e){
13697 if(!this.isExpanded()){
13698 this.onTriggerClick();
13700 this.inKeyMode = true;
13705 "enter" : function(e){
13706 // this.onViewClick();
13710 if(this.fireEvent("specialkey", this, e)){
13711 this.onViewClick(false);
13717 "esc" : function(e){
13721 "tab" : function(e){
13724 if(this.fireEvent("specialkey", this, e)){
13725 this.onViewClick(false);
13733 doRelay : function(foo, bar, hname){
13734 if(hname == 'down' || this.scope.isExpanded()){
13735 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13744 this.queryDelay = Math.max(this.queryDelay || 10,
13745 this.mode == 'local' ? 10 : 250);
13748 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13750 if(this.typeAhead){
13751 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13753 if(this.editable !== false){
13754 this.inputEl().on("keyup", this.onKeyUp, this);
13756 if(this.forceSelection){
13757 this.inputEl().on('blur', this.doForce, this);
13761 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13762 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13766 initTickableEvents: function()
13770 if(this.hiddenName){
13772 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13774 this.hiddenField.dom.value =
13775 this.hiddenValue !== undefined ? this.hiddenValue :
13776 this.value !== undefined ? this.value : '';
13778 // prevent input submission
13779 this.el.dom.removeAttribute('name');
13780 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13785 // this.list = this.el.select('ul.dropdown-menu',true).first();
13787 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13788 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13789 if(this.triggerList){
13790 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
13793 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
13794 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
13796 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
13797 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
13799 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
13800 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
13802 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
13803 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
13804 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
13807 this.cancelBtn.hide();
13812 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13813 _this.list.setWidth(lw);
13816 this.list.on('mouseover', this.onViewOver, this);
13817 this.list.on('mousemove', this.onViewMove, this);
13819 this.list.on('scroll', this.onViewScroll, this);
13822 this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}"' +
13823 'type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
13826 this.view = new Roo.View(this.list, this.tpl, {
13831 selectedClass: this.selectedClass
13834 //this.view.wrapEl.setDisplayed(false);
13835 this.view.on('click', this.onViewClick, this);
13839 this.store.on('beforeload', this.onBeforeLoad, this);
13840 this.store.on('load', this.onLoad, this);
13841 this.store.on('loadexception', this.onLoadException, this);
13844 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
13845 "up" : function(e){
13846 this.inKeyMode = true;
13850 "down" : function(e){
13851 this.inKeyMode = true;
13855 "enter" : function(e){
13856 if(this.fireEvent("specialkey", this, e)){
13857 this.onViewClick(false);
13863 "esc" : function(e){
13864 this.onTickableFooterButtonClick(e, false, false);
13867 "tab" : function(e){
13868 this.fireEvent("specialkey", this, e);
13870 this.onTickableFooterButtonClick(e, false, false);
13877 doRelay : function(e, fn, key){
13878 if(this.scope.isExpanded()){
13879 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13888 this.queryDelay = Math.max(this.queryDelay || 10,
13889 this.mode == 'local' ? 10 : 250);
13892 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13894 if(this.typeAhead){
13895 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13898 if(this.editable !== false){
13899 this.tickableInputEl().on("keyup", this.onKeyUp, this);
13902 this.indicator = this.indicatorEl();
13904 if(this.indicator){
13905 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
13906 this.indicator.hide();
13911 onDestroy : function(){
13913 this.view.setStore(null);
13914 this.view.el.removeAllListeners();
13915 this.view.el.remove();
13916 this.view.purgeListeners();
13919 this.list.dom.innerHTML = '';
13923 this.store.un('beforeload', this.onBeforeLoad, this);
13924 this.store.un('load', this.onLoad, this);
13925 this.store.un('loadexception', this.onLoadException, this);
13927 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
13931 fireKey : function(e){
13932 if(e.isNavKeyPress() && !this.list.isVisible()){
13933 this.fireEvent("specialkey", this, e);
13938 onResize: function(w, h){
13939 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
13941 // if(typeof w != 'number'){
13942 // // we do not handle it!?!?
13945 // var tw = this.trigger.getWidth();
13946 // // tw += this.addicon ? this.addicon.getWidth() : 0;
13947 // // tw += this.editicon ? this.editicon.getWidth() : 0;
13949 // this.inputEl().setWidth( this.adjustWidth('input', x));
13951 // //this.trigger.setStyle('left', x+'px');
13953 // if(this.list && this.listWidth === undefined){
13954 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
13955 // this.list.setWidth(lw);
13956 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13964 * Allow or prevent the user from directly editing the field text. If false is passed,
13965 * the user will only be able to select from the items defined in the dropdown list. This method
13966 * is the runtime equivalent of setting the 'editable' config option at config time.
13967 * @param {Boolean} value True to allow the user to directly edit the field text
13969 setEditable : function(value){
13970 if(value == this.editable){
13973 this.editable = value;
13975 this.inputEl().dom.setAttribute('readOnly', true);
13976 this.inputEl().on('mousedown', this.onTriggerClick, this);
13977 this.inputEl().addClass('x-combo-noedit');
13979 this.inputEl().dom.setAttribute('readOnly', false);
13980 this.inputEl().un('mousedown', this.onTriggerClick, this);
13981 this.inputEl().removeClass('x-combo-noedit');
13987 onBeforeLoad : function(combo,opts){
13988 if(!this.hasFocus){
13992 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
13994 this.restrictHeight();
13995 this.selectedIndex = -1;
13999 onLoad : function(){
14001 this.hasQuery = false;
14003 if(!this.hasFocus){
14007 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
14008 this.loading.hide();
14011 if(this.store.getCount() > 0){
14014 this.restrictHeight();
14015 if(this.lastQuery == this.allQuery){
14016 if(this.editable && !this.tickable){
14017 this.inputEl().dom.select();
14021 !this.selectByValue(this.value, true) &&
14024 !this.store.lastOptions ||
14025 typeof(this.store.lastOptions.add) == 'undefined' ||
14026 this.store.lastOptions.add != true
14029 this.select(0, true);
14032 if(this.autoFocus){
14035 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
14036 this.taTask.delay(this.typeAheadDelay);
14040 this.onEmptyResults();
14046 onLoadException : function()
14048 this.hasQuery = false;
14050 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
14051 this.loading.hide();
14054 if(this.tickable && this.editable){
14059 // only causes errors at present
14060 //Roo.log(this.store.reader.jsonData);
14061 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
14063 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
14069 onTypeAhead : function(){
14070 if(this.store.getCount() > 0){
14071 var r = this.store.getAt(0);
14072 var newValue = r.data[this.displayField];
14073 var len = newValue.length;
14074 var selStart = this.getRawValue().length;
14076 if(selStart != len){
14077 this.setRawValue(newValue);
14078 this.selectText(selStart, newValue.length);
14084 onSelect : function(record, index){
14086 if(this.fireEvent('beforeselect', this, record, index) !== false){
14088 this.setFromData(index > -1 ? record.data : false);
14091 this.fireEvent('select', this, record, index);
14096 * Returns the currently selected field value or empty string if no value is set.
14097 * @return {String} value The selected value
14099 getValue : function()
14101 if(Roo.isIOS && this.useNativeIOS){
14102 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
14106 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
14109 if(this.valueField){
14110 return typeof this.value != 'undefined' ? this.value : '';
14112 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
14116 getRawValue : function()
14118 if(Roo.isIOS && this.useNativeIOS){
14119 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
14122 var v = this.inputEl().getValue();
14128 * Clears any text/value currently set in the field
14130 clearValue : function(){
14132 if(this.hiddenField){
14133 this.hiddenField.dom.value = '';
14136 this.setRawValue('');
14137 this.lastSelectionText = '';
14138 this.lastData = false;
14140 var close = this.closeTriggerEl();
14151 * Sets the specified value into the field. If the value finds a match, the corresponding record text
14152 * will be displayed in the field. If the value does not match the data value of an existing item,
14153 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
14154 * Otherwise the field will be blank (although the value will still be set).
14155 * @param {String} value The value to match
14157 setValue : function(v)
14159 if(Roo.isIOS && this.useNativeIOS){
14160 this.setIOSValue(v);
14170 if(this.valueField){
14171 var r = this.findRecord(this.valueField, v);
14173 text = r.data[this.displayField];
14174 }else if(this.valueNotFoundText !== undefined){
14175 text = this.valueNotFoundText;
14178 this.lastSelectionText = text;
14179 if(this.hiddenField){
14180 this.hiddenField.dom.value = v;
14182 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
14185 var close = this.closeTriggerEl();
14188 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
14194 * @property {Object} the last set data for the element
14199 * Sets the value of the field based on a object which is related to the record format for the store.
14200 * @param {Object} value the value to set as. or false on reset?
14202 setFromData : function(o){
14209 var dv = ''; // display value
14210 var vv = ''; // value value..
14212 if (this.displayField) {
14213 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14215 // this is an error condition!!!
14216 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
14219 if(this.valueField){
14220 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
14223 var close = this.closeTriggerEl();
14226 if(dv.length || vv * 1 > 0){
14228 this.blockFocus=true;
14234 if(this.hiddenField){
14235 this.hiddenField.dom.value = vv;
14237 this.lastSelectionText = dv;
14238 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
14242 // no hidden field.. - we store the value in 'value', but still display
14243 // display field!!!!
14244 this.lastSelectionText = dv;
14245 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
14252 reset : function(){
14253 // overridden so that last data is reset..
14260 this.setValue(this.originalValue);
14261 //this.clearInvalid();
14262 this.lastData = false;
14264 this.view.clearSelections();
14270 findRecord : function(prop, value){
14272 if(this.store.getCount() > 0){
14273 this.store.each(function(r){
14274 if(r.data[prop] == value){
14284 getName: function()
14286 // returns hidden if it's set..
14287 if (!this.rendered) {return ''};
14288 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
14292 onViewMove : function(e, t){
14293 this.inKeyMode = false;
14297 onViewOver : function(e, t){
14298 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
14301 var item = this.view.findItemFromChild(t);
14304 var index = this.view.indexOf(item);
14305 this.select(index, false);
14310 onViewClick : function(view, doFocus, el, e)
14312 var index = this.view.getSelectedIndexes()[0];
14314 var r = this.store.getAt(index);
14318 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
14325 Roo.each(this.tickItems, function(v,k){
14327 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
14329 _this.tickItems.splice(k, 1);
14331 if(typeof(e) == 'undefined' && view == false){
14332 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
14344 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
14345 this.tickItems.push(r.data);
14348 if(typeof(e) == 'undefined' && view == false){
14349 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
14356 this.onSelect(r, index);
14358 if(doFocus !== false && !this.blockFocus){
14359 this.inputEl().focus();
14364 restrictHeight : function(){
14365 //this.innerList.dom.style.height = '';
14366 //var inner = this.innerList.dom;
14367 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
14368 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
14369 //this.list.beginUpdate();
14370 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
14371 this.list.alignTo(this.inputEl(), this.listAlign);
14372 this.list.alignTo(this.inputEl(), this.listAlign);
14373 //this.list.endUpdate();
14377 onEmptyResults : function(){
14379 if(this.tickable && this.editable){
14380 this.hasFocus = false;
14381 this.restrictHeight();
14389 * Returns true if the dropdown list is expanded, else false.
14391 isExpanded : function(){
14392 return this.list.isVisible();
14396 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
14397 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14398 * @param {String} value The data value of the item to select
14399 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14400 * selected item if it is not currently in view (defaults to true)
14401 * @return {Boolean} True if the value matched an item in the list, else false
14403 selectByValue : function(v, scrollIntoView){
14404 if(v !== undefined && v !== null){
14405 var r = this.findRecord(this.valueField || this.displayField, v);
14407 this.select(this.store.indexOf(r), scrollIntoView);
14415 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
14416 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
14417 * @param {Number} index The zero-based index of the list item to select
14418 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
14419 * selected item if it is not currently in view (defaults to true)
14421 select : function(index, scrollIntoView){
14422 this.selectedIndex = index;
14423 this.view.select(index);
14424 if(scrollIntoView !== false){
14425 var el = this.view.getNode(index);
14427 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
14430 this.list.scrollChildIntoView(el, false);
14436 selectNext : function(){
14437 var ct = this.store.getCount();
14439 if(this.selectedIndex == -1){
14441 }else if(this.selectedIndex < ct-1){
14442 this.select(this.selectedIndex+1);
14448 selectPrev : function(){
14449 var ct = this.store.getCount();
14451 if(this.selectedIndex == -1){
14453 }else if(this.selectedIndex != 0){
14454 this.select(this.selectedIndex-1);
14460 onKeyUp : function(e){
14461 if(this.editable !== false && !e.isSpecialKey()){
14462 this.lastKey = e.getKey();
14463 this.dqTask.delay(this.queryDelay);
14468 validateBlur : function(){
14469 return !this.list || !this.list.isVisible();
14473 initQuery : function(){
14475 var v = this.getRawValue();
14477 if(this.tickable && this.editable){
14478 v = this.tickableInputEl().getValue();
14485 doForce : function(){
14486 if(this.inputEl().dom.value.length > 0){
14487 this.inputEl().dom.value =
14488 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
14494 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
14495 * query allowing the query action to be canceled if needed.
14496 * @param {String} query The SQL query to execute
14497 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
14498 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
14499 * saved in the current store (defaults to false)
14501 doQuery : function(q, forceAll){
14503 if(q === undefined || q === null){
14508 forceAll: forceAll,
14512 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
14517 forceAll = qe.forceAll;
14518 if(forceAll === true || (q.length >= this.minChars)){
14520 this.hasQuery = true;
14522 if(this.lastQuery != q || this.alwaysQuery){
14523 this.lastQuery = q;
14524 if(this.mode == 'local'){
14525 this.selectedIndex = -1;
14527 this.store.clearFilter();
14530 if(this.specialFilter){
14531 this.fireEvent('specialfilter', this);
14536 this.store.filter(this.displayField, q);
14539 this.store.fireEvent("datachanged", this.store);
14546 this.store.baseParams[this.queryParam] = q;
14548 var options = {params : this.getParams(q)};
14551 options.add = true;
14552 options.params.start = this.page * this.pageSize;
14555 this.store.load(options);
14558 * this code will make the page width larger, at the beginning, the list not align correctly,
14559 * we should expand the list on onLoad
14560 * so command out it
14565 this.selectedIndex = -1;
14570 this.loadNext = false;
14574 getParams : function(q){
14576 //p[this.queryParam] = q;
14580 p.limit = this.pageSize;
14586 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
14588 collapse : function(){
14589 if(!this.isExpanded()){
14595 this.hasFocus = false;
14599 this.cancelBtn.hide();
14600 this.trigger.show();
14603 this.tickableInputEl().dom.value = '';
14604 this.tickableInputEl().blur();
14609 Roo.get(document).un('mousedown', this.collapseIf, this);
14610 Roo.get(document).un('mousewheel', this.collapseIf, this);
14611 if (!this.editable) {
14612 Roo.get(document).un('keydown', this.listKeyPress, this);
14614 this.fireEvent('collapse', this);
14620 collapseIf : function(e){
14621 var in_combo = e.within(this.el);
14622 var in_list = e.within(this.list);
14623 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
14625 if (in_combo || in_list || is_list) {
14626 //e.stopPropagation();
14631 this.onTickableFooterButtonClick(e, false, false);
14639 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
14641 expand : function(){
14643 if(this.isExpanded() || !this.hasFocus){
14647 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
14648 this.list.setWidth(lw);
14654 this.restrictHeight();
14658 this.tickItems = Roo.apply([], this.item);
14661 this.cancelBtn.show();
14662 this.trigger.hide();
14665 this.tickableInputEl().focus();
14670 Roo.get(document).on('mousedown', this.collapseIf, this);
14671 Roo.get(document).on('mousewheel', this.collapseIf, this);
14672 if (!this.editable) {
14673 Roo.get(document).on('keydown', this.listKeyPress, this);
14676 this.fireEvent('expand', this);
14680 // Implements the default empty TriggerField.onTriggerClick function
14681 onTriggerClick : function(e)
14683 Roo.log('trigger click');
14685 if(this.disabled || !this.triggerList){
14690 this.loadNext = false;
14692 if(this.isExpanded()){
14694 if (!this.blockFocus) {
14695 this.inputEl().focus();
14699 this.hasFocus = true;
14700 if(this.triggerAction == 'all') {
14701 this.doQuery(this.allQuery, true);
14703 this.doQuery(this.getRawValue());
14705 if (!this.blockFocus) {
14706 this.inputEl().focus();
14711 onTickableTriggerClick : function(e)
14718 this.loadNext = false;
14719 this.hasFocus = true;
14721 if(this.triggerAction == 'all') {
14722 this.doQuery(this.allQuery, true);
14724 this.doQuery(this.getRawValue());
14728 onSearchFieldClick : function(e)
14730 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
14731 this.onTickableFooterButtonClick(e, false, false);
14735 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
14740 this.loadNext = false;
14741 this.hasFocus = true;
14743 if(this.triggerAction == 'all') {
14744 this.doQuery(this.allQuery, true);
14746 this.doQuery(this.getRawValue());
14750 listKeyPress : function(e)
14752 //Roo.log('listkeypress');
14753 // scroll to first matching element based on key pres..
14754 if (e.isSpecialKey()) {
14757 var k = String.fromCharCode(e.getKey()).toUpperCase();
14760 var csel = this.view.getSelectedNodes();
14761 var cselitem = false;
14763 var ix = this.view.indexOf(csel[0]);
14764 cselitem = this.store.getAt(ix);
14765 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
14771 this.store.each(function(v) {
14773 // start at existing selection.
14774 if (cselitem.id == v.id) {
14780 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
14781 match = this.store.indexOf(v);
14787 if (match === false) {
14788 return true; // no more action?
14791 this.view.select(match);
14792 var sn = Roo.get(this.view.getSelectedNodes()[0]);
14793 sn.scrollIntoView(sn.dom.parentNode, false);
14796 onViewScroll : function(e, t){
14798 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){
14802 this.hasQuery = true;
14804 this.loading = this.list.select('.loading', true).first();
14806 if(this.loading === null){
14807 this.list.createChild({
14809 cls: 'loading roo-select2-more-results roo-select2-active',
14810 html: 'Loading more results...'
14813 this.loading = this.list.select('.loading', true).first();
14815 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
14817 this.loading.hide();
14820 this.loading.show();
14825 this.loadNext = true;
14827 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
14832 addItem : function(o)
14834 var dv = ''; // display value
14836 if (this.displayField) {
14837 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14839 // this is an error condition!!!
14840 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
14847 var choice = this.choices.createChild({
14849 cls: 'roo-select2-search-choice',
14858 cls: 'roo-select2-search-choice-close fa fa-times',
14863 }, this.searchField);
14865 var close = choice.select('a.roo-select2-search-choice-close', true).first();
14867 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
14875 this.inputEl().dom.value = '';
14880 onRemoveItem : function(e, _self, o)
14882 e.preventDefault();
14884 this.lastItem = Roo.apply([], this.item);
14886 var index = this.item.indexOf(o.data) * 1;
14889 Roo.log('not this item?!');
14893 this.item.splice(index, 1);
14898 this.fireEvent('remove', this, e);
14904 syncValue : function()
14906 if(!this.item.length){
14913 Roo.each(this.item, function(i){
14914 if(_this.valueField){
14915 value.push(i[_this.valueField]);
14922 this.value = value.join(',');
14924 if(this.hiddenField){
14925 this.hiddenField.dom.value = this.value;
14928 this.store.fireEvent("datachanged", this.store);
14933 clearItem : function()
14935 if(!this.multiple){
14941 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
14949 if(this.tickable && !Roo.isTouch){
14950 this.view.refresh();
14954 inputEl: function ()
14956 if(Roo.isIOS && this.useNativeIOS){
14957 return this.el.select('select.roo-ios-select', true).first();
14960 if(Roo.isTouch && this.mobileTouchView){
14961 return this.el.select('input.form-control',true).first();
14965 return this.searchField;
14968 return this.el.select('input.form-control',true).first();
14971 onTickableFooterButtonClick : function(e, btn, el)
14973 e.preventDefault();
14975 this.lastItem = Roo.apply([], this.item);
14977 if(btn && btn.name == 'cancel'){
14978 this.tickItems = Roo.apply([], this.item);
14987 Roo.each(this.tickItems, function(o){
14995 validate : function()
14997 if(this.getVisibilityEl().hasClass('hidden')){
15001 var v = this.getRawValue();
15004 v = this.getValue();
15007 if(this.disabled || this.allowBlank || v.length){
15012 this.markInvalid();
15016 tickableInputEl : function()
15018 if(!this.tickable || !this.editable){
15019 return this.inputEl();
15022 return this.inputEl().select('.roo-select2-search-field-input', true).first();
15026 getAutoCreateTouchView : function()
15031 cls: 'form-group' //input-group
15037 type : this.inputType,
15038 cls : 'form-control x-combo-noedit',
15039 autocomplete: 'new-password',
15040 placeholder : this.placeholder || '',
15045 input.name = this.name;
15049 input.cls += ' input-' + this.size;
15052 if (this.disabled) {
15053 input.disabled = true;
15064 inputblock.cls += ' input-group';
15066 inputblock.cn.unshift({
15068 cls : 'input-group-addon',
15073 if(this.removable && !this.multiple){
15074 inputblock.cls += ' roo-removable';
15076 inputblock.cn.push({
15079 cls : 'roo-combo-removable-btn close'
15083 if(this.hasFeedback && !this.allowBlank){
15085 inputblock.cls += ' has-feedback';
15087 inputblock.cn.push({
15089 cls: 'glyphicon form-control-feedback'
15096 inputblock.cls += (this.before) ? '' : ' input-group';
15098 inputblock.cn.push({
15100 cls : 'input-group-addon',
15111 cls: 'form-hidden-field'
15125 cls: 'form-hidden-field'
15129 cls: 'roo-select2-choices',
15133 cls: 'roo-select2-search-field',
15146 cls: 'roo-select2-container input-group roo-touchview-combobox ',
15152 if(!this.multiple && this.showToggleBtn){
15159 if (this.caret != false) {
15162 cls: 'fa fa-' + this.caret
15169 cls : 'input-group-addon btn dropdown-toggle',
15174 cls: 'combobox-clear',
15188 combobox.cls += ' roo-select2-container-multi';
15191 var align = this.labelAlign || this.parentLabelAlign();
15193 if (align ==='left' && this.fieldLabel.length) {
15198 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
15199 tooltip : 'This field is required'
15203 cls : 'control-label',
15204 html : this.fieldLabel
15215 var labelCfg = cfg.cn[1];
15216 var contentCfg = cfg.cn[2];
15219 if(this.indicatorpos == 'right'){
15224 cls : 'control-label',
15228 html : this.fieldLabel
15232 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
15233 tooltip : 'This field is required'
15246 labelCfg = cfg.cn[0];
15247 contentCfg = cfg.cn[1];
15252 if(this.labelWidth > 12){
15253 labelCfg.style = "width: " + this.labelWidth + 'px';
15256 if(this.labelWidth < 13 && this.labelmd == 0){
15257 this.labelmd = this.labelWidth;
15260 if(this.labellg > 0){
15261 labelCfg.cls += ' col-lg-' + this.labellg;
15262 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
15265 if(this.labelmd > 0){
15266 labelCfg.cls += ' col-md-' + this.labelmd;
15267 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
15270 if(this.labelsm > 0){
15271 labelCfg.cls += ' col-sm-' + this.labelsm;
15272 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
15275 if(this.labelxs > 0){
15276 labelCfg.cls += ' col-xs-' + this.labelxs;
15277 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
15281 } else if ( this.fieldLabel.length) {
15285 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
15286 tooltip : 'This field is required'
15290 cls : 'control-label',
15291 html : this.fieldLabel
15302 if(this.indicatorpos == 'right'){
15306 cls : 'control-label',
15307 html : this.fieldLabel,
15311 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
15312 tooltip : 'This field is required'
15329 var settings = this;
15331 ['xs','sm','md','lg'].map(function(size){
15332 if (settings[size]) {
15333 cfg.cls += ' col-' + size + '-' + settings[size];
15340 initTouchView : function()
15342 this.renderTouchView();
15344 this.touchViewEl.on('scroll', function(){
15345 this.el.dom.scrollTop = 0;
15348 this.originalValue = this.getValue();
15350 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
15352 this.inputEl().on("click", this.showTouchView, this);
15353 if (this.triggerEl) {
15354 this.triggerEl.on("click", this.showTouchView, this);
15358 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
15359 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
15361 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
15363 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
15364 this.store.on('load', this.onTouchViewLoad, this);
15365 this.store.on('loadexception', this.onTouchViewLoadException, this);
15367 if(this.hiddenName){
15369 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
15371 this.hiddenField.dom.value =
15372 this.hiddenValue !== undefined ? this.hiddenValue :
15373 this.value !== undefined ? this.value : '';
15375 this.el.dom.removeAttribute('name');
15376 this.hiddenField.dom.setAttribute('name', this.hiddenName);
15380 this.choices = this.el.select('ul.roo-select2-choices', true).first();
15381 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
15384 if(this.removable && !this.multiple){
15385 var close = this.closeTriggerEl();
15387 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
15388 close.on('click', this.removeBtnClick, this, close);
15392 * fix the bug in Safari iOS8
15394 this.inputEl().on("focus", function(e){
15395 document.activeElement.blur();
15398 this._touchViewMask = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
15405 renderTouchView : function()
15407 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
15408 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15410 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
15411 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15413 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
15414 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15415 this.touchViewBodyEl.setStyle('overflow', 'auto');
15417 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
15418 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15420 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
15421 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
15425 showTouchView : function()
15431 this.touchViewHeaderEl.hide();
15433 if(this.modalTitle.length){
15434 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
15435 this.touchViewHeaderEl.show();
15438 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
15439 this.touchViewEl.show();
15441 this.touchViewEl.select('.modal-dialog', true).first().setStyle({ margin : '0px', width : '100%'});
15443 //this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
15444 // Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15446 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15448 if(this.modalTitle.length){
15449 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15452 this.touchViewBodyEl.setHeight(bodyHeight);
15456 (function(){ _this.touchViewEl.addClass('in'); }).defer(50);
15458 this.touchViewEl.addClass('in');
15461 if(this._touchViewMask){
15462 Roo.get(document.body).addClass("x-body-masked");
15463 this._touchViewMask.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
15464 this._touchViewMask.setStyle('z-index', 10000);
15465 this._touchViewMask.addClass('show');
15468 this.doTouchViewQuery();
15472 hideTouchView : function()
15474 this.touchViewEl.removeClass('in');
15478 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
15480 this.touchViewEl.setStyle('display', 'none');
15483 if(this._touchViewMask){
15484 this._touchViewMask.removeClass('show');
15485 Roo.get(document.body).removeClass("x-body-masked");
15489 setTouchViewValue : function()
15496 Roo.each(this.tickItems, function(o){
15501 this.hideTouchView();
15504 doTouchViewQuery : function()
15513 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
15517 if(!this.alwaysQuery || this.mode == 'local'){
15518 this.onTouchViewLoad();
15525 onTouchViewBeforeLoad : function(combo,opts)
15531 onTouchViewLoad : function()
15533 if(this.store.getCount() < 1){
15534 this.onTouchViewEmptyResults();
15538 this.clearTouchView();
15540 var rawValue = this.getRawValue();
15542 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
15544 this.tickItems = [];
15546 this.store.data.each(function(d, rowIndex){
15547 var row = this.touchViewListGroup.createChild(template);
15549 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
15550 row.addClass(d.data.cls);
15553 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15556 html : d.data[this.displayField]
15559 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
15560 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
15563 row.removeClass('selected');
15564 if(!this.multiple && this.valueField &&
15565 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
15568 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15569 row.addClass('selected');
15572 if(this.multiple && this.valueField &&
15573 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
15577 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15578 this.tickItems.push(d.data);
15581 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
15585 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
15587 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
15589 if(this.modalTitle.length){
15590 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
15593 var listHeight = this.touchViewListGroup.getHeight() + this.touchViewBodyEl.getPadding('tb') * 2;
15595 if(this.mobile_restrict_height && listHeight < bodyHeight){
15596 this.touchViewBodyEl.setHeight(listHeight);
15601 if(firstChecked && listHeight > bodyHeight){
15602 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
15607 onTouchViewLoadException : function()
15609 this.hideTouchView();
15612 onTouchViewEmptyResults : function()
15614 this.clearTouchView();
15616 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
15618 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
15622 clearTouchView : function()
15624 this.touchViewListGroup.dom.innerHTML = '';
15627 onTouchViewClick : function(e, el, o)
15629 e.preventDefault();
15632 var rowIndex = o.rowIndex;
15634 var r = this.store.getAt(rowIndex);
15636 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
15638 if(!this.multiple){
15639 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
15640 c.dom.removeAttribute('checked');
15643 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15645 this.setFromData(r.data);
15647 var close = this.closeTriggerEl();
15653 this.hideTouchView();
15655 this.fireEvent('select', this, r, rowIndex);
15660 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
15661 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
15662 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
15666 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15667 this.addItem(r.data);
15668 this.tickItems.push(r.data);
15672 getAutoCreateNativeIOS : function()
15675 cls: 'form-group' //input-group,
15680 cls : 'roo-ios-select'
15684 combobox.name = this.name;
15687 if (this.disabled) {
15688 combobox.disabled = true;
15691 var settings = this;
15693 ['xs','sm','md','lg'].map(function(size){
15694 if (settings[size]) {
15695 cfg.cls += ' col-' + size + '-' + settings[size];
15705 initIOSView : function()
15707 this.store.on('load', this.onIOSViewLoad, this);
15712 onIOSViewLoad : function()
15714 if(this.store.getCount() < 1){
15718 this.clearIOSView();
15720 if(this.allowBlank) {
15722 var default_text = '-- SELECT --';
15724 if(this.placeholder.length){
15725 default_text = this.placeholder;
15728 if(this.emptyTitle.length){
15729 default_text += ' - ' + this.emptyTitle + ' -';
15732 var opt = this.inputEl().createChild({
15735 html : default_text
15739 o[this.valueField] = 0;
15740 o[this.displayField] = default_text;
15742 this.ios_options.push({
15749 this.store.data.each(function(d, rowIndex){
15753 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15754 html = d.data[this.displayField];
15759 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
15760 value = d.data[this.valueField];
15769 if(this.value == d.data[this.valueField]){
15770 option['selected'] = true;
15773 var opt = this.inputEl().createChild(option);
15775 this.ios_options.push({
15782 this.inputEl().on('change', function(){
15783 this.fireEvent('select', this);
15788 clearIOSView: function()
15790 this.inputEl().dom.innerHTML = '';
15792 this.ios_options = [];
15795 setIOSValue: function(v)
15799 if(!this.ios_options){
15803 Roo.each(this.ios_options, function(opts){
15805 opts.el.dom.removeAttribute('selected');
15807 if(opts.data[this.valueField] != v){
15811 opts.el.dom.setAttribute('selected', true);
15817 * @cfg {Boolean} grow
15821 * @cfg {Number} growMin
15825 * @cfg {Number} growMax
15834 Roo.apply(Roo.bootstrap.ComboBox, {
15838 cls: 'modal-header',
15860 cls: 'list-group-item',
15864 cls: 'roo-combobox-list-group-item-value'
15868 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
15882 listItemCheckbox : {
15884 cls: 'list-group-item',
15888 cls: 'roo-combobox-list-group-item-value'
15892 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
15908 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
15913 cls: 'modal-footer',
15921 cls: 'col-xs-6 text-left',
15924 cls: 'btn btn-danger roo-touch-view-cancel',
15930 cls: 'col-xs-6 text-right',
15933 cls: 'btn btn-success roo-touch-view-ok',
15944 Roo.apply(Roo.bootstrap.ComboBox, {
15946 touchViewTemplate : {
15948 cls: 'modal fade roo-combobox-touch-view',
15952 cls: 'modal-dialog',
15953 style : 'position:fixed', // we have to fix position....
15957 cls: 'modal-content',
15959 Roo.bootstrap.ComboBox.header,
15960 Roo.bootstrap.ComboBox.body,
15961 Roo.bootstrap.ComboBox.footer
15970 * Ext JS Library 1.1.1
15971 * Copyright(c) 2006-2007, Ext JS, LLC.
15973 * Originally Released Under LGPL - original licence link has changed is not relivant.
15976 * <script type="text/javascript">
15981 * @extends Roo.util.Observable
15982 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
15983 * This class also supports single and multi selection modes. <br>
15984 * Create a data model bound view:
15986 var store = new Roo.data.Store(...);
15988 var view = new Roo.View({
15990 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
15992 singleSelect: true,
15993 selectedClass: "ydataview-selected",
15997 // listen for node click?
15998 view.on("click", function(vw, index, node, e){
15999 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
16003 dataModel.load("foobar.xml");
16005 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
16007 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
16008 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
16010 * Note: old style constructor is still suported (container, template, config)
16013 * Create a new View
16014 * @param {Object} config The config object
16017 Roo.View = function(config, depreciated_tpl, depreciated_config){
16019 this.parent = false;
16021 if (typeof(depreciated_tpl) == 'undefined') {
16022 // new way.. - universal constructor.
16023 Roo.apply(this, config);
16024 this.el = Roo.get(this.el);
16027 this.el = Roo.get(config);
16028 this.tpl = depreciated_tpl;
16029 Roo.apply(this, depreciated_config);
16031 this.wrapEl = this.el.wrap().wrap();
16032 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
16035 if(typeof(this.tpl) == "string"){
16036 this.tpl = new Roo.Template(this.tpl);
16038 // support xtype ctors..
16039 this.tpl = new Roo.factory(this.tpl, Roo);
16043 this.tpl.compile();
16048 * @event beforeclick
16049 * Fires before a click is processed. Returns false to cancel the default action.
16050 * @param {Roo.View} this
16051 * @param {Number} index The index of the target node
16052 * @param {HTMLElement} node The target node
16053 * @param {Roo.EventObject} e The raw event object
16055 "beforeclick" : true,
16058 * Fires when a template node is clicked.
16059 * @param {Roo.View} this
16060 * @param {Number} index The index of the target node
16061 * @param {HTMLElement} node The target node
16062 * @param {Roo.EventObject} e The raw event object
16067 * Fires when a template node is double clicked.
16068 * @param {Roo.View} this
16069 * @param {Number} index The index of the target node
16070 * @param {HTMLElement} node The target node
16071 * @param {Roo.EventObject} e The raw event object
16075 * @event contextmenu
16076 * Fires when a template node is right clicked.
16077 * @param {Roo.View} this
16078 * @param {Number} index The index of the target node
16079 * @param {HTMLElement} node The target node
16080 * @param {Roo.EventObject} e The raw event object
16082 "contextmenu" : true,
16084 * @event selectionchange
16085 * Fires when the selected nodes change.
16086 * @param {Roo.View} this
16087 * @param {Array} selections Array of the selected nodes
16089 "selectionchange" : true,
16092 * @event beforeselect
16093 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
16094 * @param {Roo.View} this
16095 * @param {HTMLElement} node The node to be selected
16096 * @param {Array} selections Array of currently selected nodes
16098 "beforeselect" : true,
16100 * @event preparedata
16101 * Fires on every row to render, to allow you to change the data.
16102 * @param {Roo.View} this
16103 * @param {Object} data to be rendered (change this)
16105 "preparedata" : true
16113 "click": this.onClick,
16114 "dblclick": this.onDblClick,
16115 "contextmenu": this.onContextMenu,
16119 this.selections = [];
16121 this.cmp = new Roo.CompositeElementLite([]);
16123 this.store = Roo.factory(this.store, Roo.data);
16124 this.setStore(this.store, true);
16127 if ( this.footer && this.footer.xtype) {
16129 var fctr = this.wrapEl.appendChild(document.createElement("div"));
16131 this.footer.dataSource = this.store;
16132 this.footer.container = fctr;
16133 this.footer = Roo.factory(this.footer, Roo);
16134 fctr.insertFirst(this.el);
16136 // this is a bit insane - as the paging toolbar seems to detach the el..
16137 // dom.parentNode.parentNode.parentNode
16138 // they get detached?
16142 Roo.View.superclass.constructor.call(this);
16147 Roo.extend(Roo.View, Roo.util.Observable, {
16150 * @cfg {Roo.data.Store} store Data store to load data from.
16155 * @cfg {String|Roo.Element} el The container element.
16160 * @cfg {String|Roo.Template} tpl The template used by this View
16164 * @cfg {String} dataName the named area of the template to use as the data area
16165 * Works with domtemplates roo-name="name"
16169 * @cfg {String} selectedClass The css class to add to selected nodes
16171 selectedClass : "x-view-selected",
16173 * @cfg {String} emptyText The empty text to show when nothing is loaded.
16178 * @cfg {String} text to display on mask (default Loading)
16182 * @cfg {Boolean} multiSelect Allow multiple selection
16184 multiSelect : false,
16186 * @cfg {Boolean} singleSelect Allow single selection
16188 singleSelect: false,
16191 * @cfg {Boolean} toggleSelect - selecting
16193 toggleSelect : false,
16196 * @cfg {Boolean} tickable - selecting
16201 * Returns the element this view is bound to.
16202 * @return {Roo.Element}
16204 getEl : function(){
16205 return this.wrapEl;
16211 * Refreshes the view. - called by datachanged on the store. - do not call directly.
16213 refresh : function(){
16214 //Roo.log('refresh');
16217 // if we are using something like 'domtemplate', then
16218 // the what gets used is:
16219 // t.applySubtemplate(NAME, data, wrapping data..)
16220 // the outer template then get' applied with
16221 // the store 'extra data'
16222 // and the body get's added to the
16223 // roo-name="data" node?
16224 // <span class='roo-tpl-{name}'></span> ?????
16228 this.clearSelections();
16229 this.el.update("");
16231 var records = this.store.getRange();
16232 if(records.length < 1) {
16234 // is this valid?? = should it render a template??
16236 this.el.update(this.emptyText);
16240 if (this.dataName) {
16241 this.el.update(t.apply(this.store.meta)); //????
16242 el = this.el.child('.roo-tpl-' + this.dataName);
16245 for(var i = 0, len = records.length; i < len; i++){
16246 var data = this.prepareData(records[i].data, i, records[i]);
16247 this.fireEvent("preparedata", this, data, i, records[i]);
16249 var d = Roo.apply({}, data);
16252 Roo.apply(d, {'roo-id' : Roo.id()});
16256 Roo.each(this.parent.item, function(item){
16257 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
16260 Roo.apply(d, {'roo-data-checked' : 'checked'});
16264 html[html.length] = Roo.util.Format.trim(
16266 t.applySubtemplate(this.dataName, d, this.store.meta) :
16273 el.update(html.join(""));
16274 this.nodes = el.dom.childNodes;
16275 this.updateIndexes(0);
16280 * Function to override to reformat the data that is sent to
16281 * the template for each node.
16282 * DEPRICATED - use the preparedata event handler.
16283 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
16284 * a JSON object for an UpdateManager bound view).
16286 prepareData : function(data, index, record)
16288 this.fireEvent("preparedata", this, data, index, record);
16292 onUpdate : function(ds, record){
16293 // Roo.log('on update');
16294 this.clearSelections();
16295 var index = this.store.indexOf(record);
16296 var n = this.nodes[index];
16297 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
16298 n.parentNode.removeChild(n);
16299 this.updateIndexes(index, index);
16305 onAdd : function(ds, records, index)
16307 //Roo.log(['on Add', ds, records, index] );
16308 this.clearSelections();
16309 if(this.nodes.length == 0){
16313 var n = this.nodes[index];
16314 for(var i = 0, len = records.length; i < len; i++){
16315 var d = this.prepareData(records[i].data, i, records[i]);
16317 this.tpl.insertBefore(n, d);
16320 this.tpl.append(this.el, d);
16323 this.updateIndexes(index);
16326 onRemove : function(ds, record, index){
16327 // Roo.log('onRemove');
16328 this.clearSelections();
16329 var el = this.dataName ?
16330 this.el.child('.roo-tpl-' + this.dataName) :
16333 el.dom.removeChild(this.nodes[index]);
16334 this.updateIndexes(index);
16338 * Refresh an individual node.
16339 * @param {Number} index
16341 refreshNode : function(index){
16342 this.onUpdate(this.store, this.store.getAt(index));
16345 updateIndexes : function(startIndex, endIndex){
16346 var ns = this.nodes;
16347 startIndex = startIndex || 0;
16348 endIndex = endIndex || ns.length - 1;
16349 for(var i = startIndex; i <= endIndex; i++){
16350 ns[i].nodeIndex = i;
16355 * Changes the data store this view uses and refresh the view.
16356 * @param {Store} store
16358 setStore : function(store, initial){
16359 if(!initial && this.store){
16360 this.store.un("datachanged", this.refresh);
16361 this.store.un("add", this.onAdd);
16362 this.store.un("remove", this.onRemove);
16363 this.store.un("update", this.onUpdate);
16364 this.store.un("clear", this.refresh);
16365 this.store.un("beforeload", this.onBeforeLoad);
16366 this.store.un("load", this.onLoad);
16367 this.store.un("loadexception", this.onLoad);
16371 store.on("datachanged", this.refresh, this);
16372 store.on("add", this.onAdd, this);
16373 store.on("remove", this.onRemove, this);
16374 store.on("update", this.onUpdate, this);
16375 store.on("clear", this.refresh, this);
16376 store.on("beforeload", this.onBeforeLoad, this);
16377 store.on("load", this.onLoad, this);
16378 store.on("loadexception", this.onLoad, this);
16386 * onbeforeLoad - masks the loading area.
16389 onBeforeLoad : function(store,opts)
16391 //Roo.log('onBeforeLoad');
16393 this.el.update("");
16395 this.el.mask(this.mask ? this.mask : "Loading" );
16397 onLoad : function ()
16404 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
16405 * @param {HTMLElement} node
16406 * @return {HTMLElement} The template node
16408 findItemFromChild : function(node){
16409 var el = this.dataName ?
16410 this.el.child('.roo-tpl-' + this.dataName,true) :
16413 if(!node || node.parentNode == el){
16416 var p = node.parentNode;
16417 while(p && p != el){
16418 if(p.parentNode == el){
16427 onClick : function(e){
16428 var item = this.findItemFromChild(e.getTarget());
16430 var index = this.indexOf(item);
16431 if(this.onItemClick(item, index, e) !== false){
16432 this.fireEvent("click", this, index, item, e);
16435 this.clearSelections();
16440 onContextMenu : function(e){
16441 var item = this.findItemFromChild(e.getTarget());
16443 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
16448 onDblClick : function(e){
16449 var item = this.findItemFromChild(e.getTarget());
16451 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
16455 onItemClick : function(item, index, e)
16457 if(this.fireEvent("beforeclick", this, index, item, e) === false){
16460 if (this.toggleSelect) {
16461 var m = this.isSelected(item) ? 'unselect' : 'select';
16464 _t[m](item, true, false);
16467 if(this.multiSelect || this.singleSelect){
16468 if(this.multiSelect && e.shiftKey && this.lastSelection){
16469 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
16471 this.select(item, this.multiSelect && e.ctrlKey);
16472 this.lastSelection = item;
16475 if(!this.tickable){
16476 e.preventDefault();
16484 * Get the number of selected nodes.
16487 getSelectionCount : function(){
16488 return this.selections.length;
16492 * Get the currently selected nodes.
16493 * @return {Array} An array of HTMLElements
16495 getSelectedNodes : function(){
16496 return this.selections;
16500 * Get the indexes of the selected nodes.
16503 getSelectedIndexes : function(){
16504 var indexes = [], s = this.selections;
16505 for(var i = 0, len = s.length; i < len; i++){
16506 indexes.push(s[i].nodeIndex);
16512 * Clear all selections
16513 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
16515 clearSelections : function(suppressEvent){
16516 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
16517 this.cmp.elements = this.selections;
16518 this.cmp.removeClass(this.selectedClass);
16519 this.selections = [];
16520 if(!suppressEvent){
16521 this.fireEvent("selectionchange", this, this.selections);
16527 * Returns true if the passed node is selected
16528 * @param {HTMLElement/Number} node The node or node index
16529 * @return {Boolean}
16531 isSelected : function(node){
16532 var s = this.selections;
16536 node = this.getNode(node);
16537 return s.indexOf(node) !== -1;
16542 * @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
16543 * @param {Boolean} keepExisting (optional) true to keep existing selections
16544 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16546 select : function(nodeInfo, keepExisting, suppressEvent){
16547 if(nodeInfo instanceof Array){
16549 this.clearSelections(true);
16551 for(var i = 0, len = nodeInfo.length; i < len; i++){
16552 this.select(nodeInfo[i], true, true);
16556 var node = this.getNode(nodeInfo);
16557 if(!node || this.isSelected(node)){
16558 return; // already selected.
16561 this.clearSelections(true);
16564 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
16565 Roo.fly(node).addClass(this.selectedClass);
16566 this.selections.push(node);
16567 if(!suppressEvent){
16568 this.fireEvent("selectionchange", this, this.selections);
16576 * @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
16577 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
16578 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
16580 unselect : function(nodeInfo, keepExisting, suppressEvent)
16582 if(nodeInfo instanceof Array){
16583 Roo.each(this.selections, function(s) {
16584 this.unselect(s, nodeInfo);
16588 var node = this.getNode(nodeInfo);
16589 if(!node || !this.isSelected(node)){
16590 //Roo.log("not selected");
16591 return; // not selected.
16595 Roo.each(this.selections, function(s) {
16597 Roo.fly(node).removeClass(this.selectedClass);
16604 this.selections= ns;
16605 this.fireEvent("selectionchange", this, this.selections);
16609 * Gets a template node.
16610 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16611 * @return {HTMLElement} The node or null if it wasn't found
16613 getNode : function(nodeInfo){
16614 if(typeof nodeInfo == "string"){
16615 return document.getElementById(nodeInfo);
16616 }else if(typeof nodeInfo == "number"){
16617 return this.nodes[nodeInfo];
16623 * Gets a range template nodes.
16624 * @param {Number} startIndex
16625 * @param {Number} endIndex
16626 * @return {Array} An array of nodes
16628 getNodes : function(start, end){
16629 var ns = this.nodes;
16630 start = start || 0;
16631 end = typeof end == "undefined" ? ns.length - 1 : end;
16634 for(var i = start; i <= end; i++){
16638 for(var i = start; i >= end; i--){
16646 * Finds the index of the passed node
16647 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16648 * @return {Number} The index of the node or -1
16650 indexOf : function(node){
16651 node = this.getNode(node);
16652 if(typeof node.nodeIndex == "number"){
16653 return node.nodeIndex;
16655 var ns = this.nodes;
16656 for(var i = 0, len = ns.length; i < len; i++){
16667 * based on jquery fullcalendar
16671 Roo.bootstrap = Roo.bootstrap || {};
16673 * @class Roo.bootstrap.Calendar
16674 * @extends Roo.bootstrap.Component
16675 * Bootstrap Calendar class
16676 * @cfg {Boolean} loadMask (true|false) default false
16677 * @cfg {Object} header generate the user specific header of the calendar, default false
16680 * Create a new Container
16681 * @param {Object} config The config object
16686 Roo.bootstrap.Calendar = function(config){
16687 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
16691 * Fires when a date is selected
16692 * @param {DatePicker} this
16693 * @param {Date} date The selected date
16697 * @event monthchange
16698 * Fires when the displayed month changes
16699 * @param {DatePicker} this
16700 * @param {Date} date The selected month
16702 'monthchange': true,
16704 * @event evententer
16705 * Fires when mouse over an event
16706 * @param {Calendar} this
16707 * @param {event} Event
16709 'evententer': true,
16711 * @event eventleave
16712 * Fires when the mouse leaves an
16713 * @param {Calendar} this
16716 'eventleave': true,
16718 * @event eventclick
16719 * Fires when the mouse click an
16720 * @param {Calendar} this
16729 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
16732 * @cfg {Number} startDay
16733 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
16741 getAutoCreate : function(){
16744 var fc_button = function(name, corner, style, content ) {
16745 return Roo.apply({},{
16747 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
16749 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
16752 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
16763 style : 'width:100%',
16770 cls : 'fc-header-left',
16772 fc_button('prev', 'left', 'arrow', '‹' ),
16773 fc_button('next', 'right', 'arrow', '›' ),
16774 { tag: 'span', cls: 'fc-header-space' },
16775 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
16783 cls : 'fc-header-center',
16787 cls: 'fc-header-title',
16790 html : 'month / year'
16798 cls : 'fc-header-right',
16800 /* fc_button('month', 'left', '', 'month' ),
16801 fc_button('week', '', '', 'week' ),
16802 fc_button('day', 'right', '', 'day' )
16814 header = this.header;
16817 var cal_heads = function() {
16819 // fixme - handle this.
16821 for (var i =0; i < Date.dayNames.length; i++) {
16822 var d = Date.dayNames[i];
16825 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
16826 html : d.substring(0,3)
16830 ret[0].cls += ' fc-first';
16831 ret[6].cls += ' fc-last';
16834 var cal_cell = function(n) {
16837 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
16842 cls: 'fc-day-number',
16846 cls: 'fc-day-content',
16850 style: 'position: relative;' // height: 17px;
16862 var cal_rows = function() {
16865 for (var r = 0; r < 6; r++) {
16872 for (var i =0; i < Date.dayNames.length; i++) {
16873 var d = Date.dayNames[i];
16874 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
16877 row.cn[0].cls+=' fc-first';
16878 row.cn[0].cn[0].style = 'min-height:90px';
16879 row.cn[6].cls+=' fc-last';
16883 ret[0].cls += ' fc-first';
16884 ret[4].cls += ' fc-prev-last';
16885 ret[5].cls += ' fc-last';
16892 cls: 'fc-border-separate',
16893 style : 'width:100%',
16901 cls : 'fc-first fc-last',
16919 cls : 'fc-content',
16920 style : "position: relative;",
16923 cls : 'fc-view fc-view-month fc-grid',
16924 style : 'position: relative',
16925 unselectable : 'on',
16928 cls : 'fc-event-container',
16929 style : 'position:absolute;z-index:8;top:0;left:0;'
16947 initEvents : function()
16950 throw "can not find store for calendar";
16956 style: "text-align:center",
16960 style: "background-color:white;width:50%;margin:250 auto",
16964 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
16975 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
16977 var size = this.el.select('.fc-content', true).first().getSize();
16978 this.maskEl.setSize(size.width, size.height);
16979 this.maskEl.enableDisplayMode("block");
16980 if(!this.loadMask){
16981 this.maskEl.hide();
16984 this.store = Roo.factory(this.store, Roo.data);
16985 this.store.on('load', this.onLoad, this);
16986 this.store.on('beforeload', this.onBeforeLoad, this);
16990 this.cells = this.el.select('.fc-day',true);
16991 //Roo.log(this.cells);
16992 this.textNodes = this.el.query('.fc-day-number');
16993 this.cells.addClassOnOver('fc-state-hover');
16995 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
16996 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
16997 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
16998 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
17000 this.on('monthchange', this.onMonthChange, this);
17002 this.update(new Date().clearTime());
17005 resize : function() {
17006 var sz = this.el.getSize();
17008 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
17009 this.el.select('.fc-day-content div',true).setHeight(34);
17014 showPrevMonth : function(e){
17015 this.update(this.activeDate.add("mo", -1));
17017 showToday : function(e){
17018 this.update(new Date().clearTime());
17021 showNextMonth : function(e){
17022 this.update(this.activeDate.add("mo", 1));
17026 showPrevYear : function(){
17027 this.update(this.activeDate.add("y", -1));
17031 showNextYear : function(){
17032 this.update(this.activeDate.add("y", 1));
17037 update : function(date)
17039 var vd = this.activeDate;
17040 this.activeDate = date;
17041 // if(vd && this.el){
17042 // var t = date.getTime();
17043 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
17044 // Roo.log('using add remove');
17046 // this.fireEvent('monthchange', this, date);
17048 // this.cells.removeClass("fc-state-highlight");
17049 // this.cells.each(function(c){
17050 // if(c.dateValue == t){
17051 // c.addClass("fc-state-highlight");
17052 // setTimeout(function(){
17053 // try{c.dom.firstChild.focus();}catch(e){}
17063 var days = date.getDaysInMonth();
17065 var firstOfMonth = date.getFirstDateOfMonth();
17066 var startingPos = firstOfMonth.getDay()-this.startDay;
17068 if(startingPos < this.startDay){
17072 var pm = date.add(Date.MONTH, -1);
17073 var prevStart = pm.getDaysInMonth()-startingPos;
17075 this.cells = this.el.select('.fc-day',true);
17076 this.textNodes = this.el.query('.fc-day-number');
17077 this.cells.addClassOnOver('fc-state-hover');
17079 var cells = this.cells.elements;
17080 var textEls = this.textNodes;
17082 Roo.each(cells, function(cell){
17083 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
17086 days += startingPos;
17088 // convert everything to numbers so it's fast
17089 var day = 86400000;
17090 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
17093 //Roo.log(prevStart);
17095 var today = new Date().clearTime().getTime();
17096 var sel = date.clearTime().getTime();
17097 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
17098 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
17099 var ddMatch = this.disabledDatesRE;
17100 var ddText = this.disabledDatesText;
17101 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
17102 var ddaysText = this.disabledDaysText;
17103 var format = this.format;
17105 var setCellClass = function(cal, cell){
17109 //Roo.log('set Cell Class');
17111 var t = d.getTime();
17115 cell.dateValue = t;
17117 cell.className += " fc-today";
17118 cell.className += " fc-state-highlight";
17119 cell.title = cal.todayText;
17122 // disable highlight in other month..
17123 //cell.className += " fc-state-highlight";
17128 cell.className = " fc-state-disabled";
17129 cell.title = cal.minText;
17133 cell.className = " fc-state-disabled";
17134 cell.title = cal.maxText;
17138 if(ddays.indexOf(d.getDay()) != -1){
17139 cell.title = ddaysText;
17140 cell.className = " fc-state-disabled";
17143 if(ddMatch && format){
17144 var fvalue = d.dateFormat(format);
17145 if(ddMatch.test(fvalue)){
17146 cell.title = ddText.replace("%0", fvalue);
17147 cell.className = " fc-state-disabled";
17151 if (!cell.initialClassName) {
17152 cell.initialClassName = cell.dom.className;
17155 cell.dom.className = cell.initialClassName + ' ' + cell.className;
17160 for(; i < startingPos; i++) {
17161 textEls[i].innerHTML = (++prevStart);
17162 d.setDate(d.getDate()+1);
17164 cells[i].className = "fc-past fc-other-month";
17165 setCellClass(this, cells[i]);
17170 for(; i < days; i++){
17171 intDay = i - startingPos + 1;
17172 textEls[i].innerHTML = (intDay);
17173 d.setDate(d.getDate()+1);
17175 cells[i].className = ''; // "x-date-active";
17176 setCellClass(this, cells[i]);
17180 for(; i < 42; i++) {
17181 textEls[i].innerHTML = (++extraDays);
17182 d.setDate(d.getDate()+1);
17184 cells[i].className = "fc-future fc-other-month";
17185 setCellClass(this, cells[i]);
17188 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
17190 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
17192 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
17193 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
17195 if(totalRows != 6){
17196 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
17197 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
17200 this.fireEvent('monthchange', this, date);
17204 if(!this.internalRender){
17205 var main = this.el.dom.firstChild;
17206 var w = main.offsetWidth;
17207 this.el.setWidth(w + this.el.getBorderWidth("lr"));
17208 Roo.fly(main).setWidth(w);
17209 this.internalRender = true;
17210 // opera does not respect the auto grow header center column
17211 // then, after it gets a width opera refuses to recalculate
17212 // without a second pass
17213 if(Roo.isOpera && !this.secondPass){
17214 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
17215 this.secondPass = true;
17216 this.update.defer(10, this, [date]);
17223 findCell : function(dt) {
17224 dt = dt.clearTime().getTime();
17226 this.cells.each(function(c){
17227 //Roo.log("check " +c.dateValue + '?=' + dt);
17228 if(c.dateValue == dt){
17238 findCells : function(ev) {
17239 var s = ev.start.clone().clearTime().getTime();
17241 var e= ev.end.clone().clearTime().getTime();
17244 this.cells.each(function(c){
17245 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
17247 if(c.dateValue > e){
17250 if(c.dateValue < s){
17259 // findBestRow: function(cells)
17263 // for (var i =0 ; i < cells.length;i++) {
17264 // ret = Math.max(cells[i].rows || 0,ret);
17271 addItem : function(ev)
17273 // look for vertical location slot in
17274 var cells = this.findCells(ev);
17276 // ev.row = this.findBestRow(cells);
17278 // work out the location.
17282 for(var i =0; i < cells.length; i++) {
17284 cells[i].row = cells[0].row;
17287 cells[i].row = cells[i].row + 1;
17297 if (crow.start.getY() == cells[i].getY()) {
17299 crow.end = cells[i];
17316 cells[0].events.push(ev);
17318 this.calevents.push(ev);
17321 clearEvents: function() {
17323 if(!this.calevents){
17327 Roo.each(this.cells.elements, function(c){
17333 Roo.each(this.calevents, function(e) {
17334 Roo.each(e.els, function(el) {
17335 el.un('mouseenter' ,this.onEventEnter, this);
17336 el.un('mouseleave' ,this.onEventLeave, this);
17341 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
17347 renderEvents: function()
17351 this.cells.each(function(c) {
17360 if(c.row != c.events.length){
17361 r = 4 - (4 - (c.row - c.events.length));
17364 c.events = ev.slice(0, r);
17365 c.more = ev.slice(r);
17367 if(c.more.length && c.more.length == 1){
17368 c.events.push(c.more.pop());
17371 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
17375 this.cells.each(function(c) {
17377 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
17380 for (var e = 0; e < c.events.length; e++){
17381 var ev = c.events[e];
17382 var rows = ev.rows;
17384 for(var i = 0; i < rows.length; i++) {
17386 // how many rows should it span..
17389 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
17390 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
17392 unselectable : "on",
17395 cls: 'fc-event-inner',
17399 // cls: 'fc-event-time',
17400 // html : cells.length > 1 ? '' : ev.time
17404 cls: 'fc-event-title',
17405 html : String.format('{0}', ev.title)
17412 cls: 'ui-resizable-handle ui-resizable-e',
17413 html : '  '
17420 cfg.cls += ' fc-event-start';
17422 if ((i+1) == rows.length) {
17423 cfg.cls += ' fc-event-end';
17426 var ctr = _this.el.select('.fc-event-container',true).first();
17427 var cg = ctr.createChild(cfg);
17429 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
17430 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
17432 var r = (c.more.length) ? 1 : 0;
17433 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
17434 cg.setWidth(ebox.right - sbox.x -2);
17436 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
17437 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
17438 cg.on('click', _this.onEventClick, _this, ev);
17449 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
17450 style : 'position: absolute',
17451 unselectable : "on",
17454 cls: 'fc-event-inner',
17458 cls: 'fc-event-title',
17466 cls: 'ui-resizable-handle ui-resizable-e',
17467 html : '  '
17473 var ctr = _this.el.select('.fc-event-container',true).first();
17474 var cg = ctr.createChild(cfg);
17476 var sbox = c.select('.fc-day-content',true).first().getBox();
17477 var ebox = c.select('.fc-day-content',true).first().getBox();
17479 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
17480 cg.setWidth(ebox.right - sbox.x -2);
17482 cg.on('click', _this.onMoreEventClick, _this, c.more);
17492 onEventEnter: function (e, el,event,d) {
17493 this.fireEvent('evententer', this, el, event);
17496 onEventLeave: function (e, el,event,d) {
17497 this.fireEvent('eventleave', this, el, event);
17500 onEventClick: function (e, el,event,d) {
17501 this.fireEvent('eventclick', this, el, event);
17504 onMonthChange: function () {
17508 onMoreEventClick: function(e, el, more)
17512 this.calpopover.placement = 'right';
17513 this.calpopover.setTitle('More');
17515 this.calpopover.setContent('');
17517 var ctr = this.calpopover.el.select('.popover-content', true).first();
17519 Roo.each(more, function(m){
17521 cls : 'fc-event-hori fc-event-draggable',
17524 var cg = ctr.createChild(cfg);
17526 cg.on('click', _this.onEventClick, _this, m);
17529 this.calpopover.show(el);
17534 onLoad: function ()
17536 this.calevents = [];
17539 if(this.store.getCount() > 0){
17540 this.store.data.each(function(d){
17543 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
17544 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
17545 time : d.data.start_time,
17546 title : d.data.title,
17547 description : d.data.description,
17548 venue : d.data.venue
17553 this.renderEvents();
17555 if(this.calevents.length && this.loadMask){
17556 this.maskEl.hide();
17560 onBeforeLoad: function()
17562 this.clearEvents();
17564 this.maskEl.show();
17578 * @class Roo.bootstrap.Popover
17579 * @extends Roo.bootstrap.Component
17580 * Bootstrap Popover class
17581 * @cfg {String} html contents of the popover (or false to use children..)
17582 * @cfg {String} title of popover (or false to hide)
17583 * @cfg {String} placement how it is placed
17584 * @cfg {String} trigger click || hover (or false to trigger manually)
17585 * @cfg {String} over what (parent or false to trigger manually.)
17586 * @cfg {Number} delay - delay before showing
17589 * Create a new Popover
17590 * @param {Object} config The config object
17593 Roo.bootstrap.Popover = function(config){
17594 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
17600 * After the popover show
17602 * @param {Roo.bootstrap.Popover} this
17607 * After the popover hide
17609 * @param {Roo.bootstrap.Popover} this
17615 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
17617 title: 'Fill in a title',
17620 placement : 'right',
17621 trigger : 'hover', // hover
17627 can_build_overlaid : false,
17629 getChildContainer : function()
17631 return this.el.select('.popover-content',true).first();
17634 getAutoCreate : function(){
17637 cls : 'popover roo-dynamic',
17638 style: 'display:block',
17644 cls : 'popover-inner',
17648 cls: 'popover-title',
17652 cls : 'popover-content',
17663 setTitle: function(str)
17666 this.el.select('.popover-title',true).first().dom.innerHTML = str;
17668 setContent: function(str)
17671 this.el.select('.popover-content',true).first().dom.innerHTML = str;
17673 // as it get's added to the bottom of the page.
17674 onRender : function(ct, position)
17676 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
17678 var cfg = Roo.apply({}, this.getAutoCreate());
17682 cfg.cls += ' ' + this.cls;
17685 cfg.style = this.style;
17687 //Roo.log("adding to ");
17688 this.el = Roo.get(document.body).createChild(cfg, position);
17689 // Roo.log(this.el);
17694 initEvents : function()
17696 this.el.select('.popover-title',true).setVisibilityMode(Roo.Element.DISPLAY);
17697 this.el.enableDisplayMode('block');
17699 if (this.over === false) {
17702 if (this.triggers === false) {
17705 var on_el = (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17706 var triggers = this.trigger ? this.trigger.split(' ') : [];
17707 Roo.each(triggers, function(trigger) {
17709 if (trigger == 'click') {
17710 on_el.on('click', this.toggle, this);
17711 } else if (trigger != 'manual') {
17712 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
17713 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
17715 on_el.on(eventIn ,this.enter, this);
17716 on_el.on(eventOut, this.leave, this);
17727 toggle : function () {
17728 this.hoverState == 'in' ? this.leave() : this.enter();
17731 enter : function () {
17733 clearTimeout(this.timeout);
17735 this.hoverState = 'in';
17737 if (!this.delay || !this.delay.show) {
17742 this.timeout = setTimeout(function () {
17743 if (_t.hoverState == 'in') {
17746 }, this.delay.show)
17749 leave : function() {
17750 clearTimeout(this.timeout);
17752 this.hoverState = 'out';
17754 if (!this.delay || !this.delay.hide) {
17759 this.timeout = setTimeout(function () {
17760 if (_t.hoverState == 'out') {
17763 }, this.delay.hide)
17766 show : function (on_el)
17769 on_el= (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17773 this.el.select('.popover-title',true).first().dom.innerHtml = this.title;
17774 if (this.html !== false) {
17775 this.el.select('.popover-content',true).first().dom.innerHtml = this.html;
17777 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
17778 if (!this.title.length) {
17779 this.el.select('.popover-title',true).hide();
17782 var placement = typeof this.placement == 'function' ?
17783 this.placement.call(this, this.el, on_el) :
17786 var autoToken = /\s?auto?\s?/i;
17787 var autoPlace = autoToken.test(placement);
17789 placement = placement.replace(autoToken, '') || 'top';
17793 //this.el.setXY([0,0]);
17795 this.el.dom.style.display='block';
17796 this.el.addClass(placement);
17798 //this.el.appendTo(on_el);
17800 var p = this.getPosition();
17801 var box = this.el.getBox();
17806 var align = Roo.bootstrap.Popover.alignment[placement];
17809 this.el.alignTo(on_el, align[0],align[1]);
17810 //var arrow = this.el.select('.arrow',true).first();
17811 //arrow.set(align[2],
17813 this.el.addClass('in');
17816 if (this.el.hasClass('fade')) {
17820 this.hoverState = 'in';
17822 this.fireEvent('show', this);
17827 this.el.setXY([0,0]);
17828 this.el.removeClass('in');
17830 this.hoverState = null;
17832 this.fireEvent('hide', this);
17837 Roo.bootstrap.Popover.alignment = {
17838 'left' : ['r-l', [-10,0], 'right'],
17839 'right' : ['l-r', [10,0], 'left'],
17840 'bottom' : ['t-b', [0,10], 'top'],
17841 'top' : [ 'b-t', [0,-10], 'bottom']
17852 * @class Roo.bootstrap.Progress
17853 * @extends Roo.bootstrap.Component
17854 * Bootstrap Progress class
17855 * @cfg {Boolean} striped striped of the progress bar
17856 * @cfg {Boolean} active animated of the progress bar
17860 * Create a new Progress
17861 * @param {Object} config The config object
17864 Roo.bootstrap.Progress = function(config){
17865 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
17868 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
17873 getAutoCreate : function(){
17881 cfg.cls += ' progress-striped';
17885 cfg.cls += ' active';
17904 * @class Roo.bootstrap.ProgressBar
17905 * @extends Roo.bootstrap.Component
17906 * Bootstrap ProgressBar class
17907 * @cfg {Number} aria_valuenow aria-value now
17908 * @cfg {Number} aria_valuemin aria-value min
17909 * @cfg {Number} aria_valuemax aria-value max
17910 * @cfg {String} label label for the progress bar
17911 * @cfg {String} panel (success | info | warning | danger )
17912 * @cfg {String} role role of the progress bar
17913 * @cfg {String} sr_only text
17917 * Create a new ProgressBar
17918 * @param {Object} config The config object
17921 Roo.bootstrap.ProgressBar = function(config){
17922 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
17925 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
17929 aria_valuemax : 100,
17935 getAutoCreate : function()
17940 cls: 'progress-bar',
17941 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
17953 cfg.role = this.role;
17956 if(this.aria_valuenow){
17957 cfg['aria-valuenow'] = this.aria_valuenow;
17960 if(this.aria_valuemin){
17961 cfg['aria-valuemin'] = this.aria_valuemin;
17964 if(this.aria_valuemax){
17965 cfg['aria-valuemax'] = this.aria_valuemax;
17968 if(this.label && !this.sr_only){
17969 cfg.html = this.label;
17973 cfg.cls += ' progress-bar-' + this.panel;
17979 update : function(aria_valuenow)
17981 this.aria_valuenow = aria_valuenow;
17983 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
17998 * @class Roo.bootstrap.TabGroup
17999 * @extends Roo.bootstrap.Column
18000 * Bootstrap Column class
18001 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
18002 * @cfg {Boolean} carousel true to make the group behave like a carousel
18003 * @cfg {Boolean} bullets show bullets for the panels
18004 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
18005 * @cfg {Number} timer auto slide timer .. default 0 millisecond
18006 * @cfg {Boolean} showarrow (true|false) show arrow default true
18009 * Create a new TabGroup
18010 * @param {Object} config The config object
18013 Roo.bootstrap.TabGroup = function(config){
18014 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
18016 this.navId = Roo.id();
18019 Roo.bootstrap.TabGroup.register(this);
18023 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
18026 transition : false,
18031 slideOnTouch : false,
18034 getAutoCreate : function()
18036 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
18038 cfg.cls += ' tab-content';
18040 if (this.carousel) {
18041 cfg.cls += ' carousel slide';
18044 cls : 'carousel-inner',
18048 if(this.bullets && !Roo.isTouch){
18051 cls : 'carousel-bullets',
18055 if(this.bullets_cls){
18056 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
18063 cfg.cn[0].cn.push(bullets);
18066 if(this.showarrow){
18067 cfg.cn[0].cn.push({
18069 class : 'carousel-arrow',
18073 class : 'carousel-prev',
18077 class : 'fa fa-chevron-left'
18083 class : 'carousel-next',
18087 class : 'fa fa-chevron-right'
18100 initEvents: function()
18102 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
18103 // this.el.on("touchstart", this.onTouchStart, this);
18106 if(this.autoslide){
18109 this.slideFn = window.setInterval(function() {
18110 _this.showPanelNext();
18114 if(this.showarrow){
18115 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
18116 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
18122 // onTouchStart : function(e, el, o)
18124 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
18128 // this.showPanelNext();
18132 getChildContainer : function()
18134 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
18138 * register a Navigation item
18139 * @param {Roo.bootstrap.NavItem} the navitem to add
18141 register : function(item)
18143 this.tabs.push( item);
18144 item.navId = this.navId; // not really needed..
18149 getActivePanel : function()
18152 Roo.each(this.tabs, function(t) {
18162 getPanelByName : function(n)
18165 Roo.each(this.tabs, function(t) {
18166 if (t.tabId == n) {
18174 indexOfPanel : function(p)
18177 Roo.each(this.tabs, function(t,i) {
18178 if (t.tabId == p.tabId) {
18187 * show a specific panel
18188 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
18189 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
18191 showPanel : function (pan)
18193 if(this.transition || typeof(pan) == 'undefined'){
18194 Roo.log("waiting for the transitionend");
18198 if (typeof(pan) == 'number') {
18199 pan = this.tabs[pan];
18202 if (typeof(pan) == 'string') {
18203 pan = this.getPanelByName(pan);
18206 var cur = this.getActivePanel();
18209 Roo.log('pan or acitve pan is undefined');
18213 if (pan.tabId == this.getActivePanel().tabId) {
18217 if (false === cur.fireEvent('beforedeactivate')) {
18221 if(this.bullets > 0 && !Roo.isTouch){
18222 this.setActiveBullet(this.indexOfPanel(pan));
18225 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
18227 this.transition = true;
18228 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
18229 var lr = dir == 'next' ? 'left' : 'right';
18230 pan.el.addClass(dir); // or prev
18231 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
18232 cur.el.addClass(lr); // or right
18233 pan.el.addClass(lr);
18236 cur.el.on('transitionend', function() {
18237 Roo.log("trans end?");
18239 pan.el.removeClass([lr,dir]);
18240 pan.setActive(true);
18242 cur.el.removeClass([lr]);
18243 cur.setActive(false);
18245 _this.transition = false;
18247 }, this, { single: true } );
18252 cur.setActive(false);
18253 pan.setActive(true);
18258 showPanelNext : function()
18260 var i = this.indexOfPanel(this.getActivePanel());
18262 if (i >= this.tabs.length - 1 && !this.autoslide) {
18266 if (i >= this.tabs.length - 1 && this.autoslide) {
18270 this.showPanel(this.tabs[i+1]);
18273 showPanelPrev : function()
18275 var i = this.indexOfPanel(this.getActivePanel());
18277 if (i < 1 && !this.autoslide) {
18281 if (i < 1 && this.autoslide) {
18282 i = this.tabs.length;
18285 this.showPanel(this.tabs[i-1]);
18289 addBullet: function()
18291 if(!this.bullets || Roo.isTouch){
18294 var ctr = this.el.select('.carousel-bullets',true).first();
18295 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
18296 var bullet = ctr.createChild({
18297 cls : 'bullet bullet-' + i
18298 },ctr.dom.lastChild);
18303 bullet.on('click', (function(e, el, o, ii, t){
18305 e.preventDefault();
18307 this.showPanel(ii);
18309 if(this.autoslide && this.slideFn){
18310 clearInterval(this.slideFn);
18311 this.slideFn = window.setInterval(function() {
18312 _this.showPanelNext();
18316 }).createDelegate(this, [i, bullet], true));
18321 setActiveBullet : function(i)
18327 Roo.each(this.el.select('.bullet', true).elements, function(el){
18328 el.removeClass('selected');
18331 var bullet = this.el.select('.bullet-' + i, true).first();
18337 bullet.addClass('selected');
18348 Roo.apply(Roo.bootstrap.TabGroup, {
18352 * register a Navigation Group
18353 * @param {Roo.bootstrap.NavGroup} the navgroup to add
18355 register : function(navgrp)
18357 this.groups[navgrp.navId] = navgrp;
18361 * fetch a Navigation Group based on the navigation ID
18362 * if one does not exist , it will get created.
18363 * @param {string} the navgroup to add
18364 * @returns {Roo.bootstrap.NavGroup} the navgroup
18366 get: function(navId) {
18367 if (typeof(this.groups[navId]) == 'undefined') {
18368 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
18370 return this.groups[navId] ;
18385 * @class Roo.bootstrap.TabPanel
18386 * @extends Roo.bootstrap.Component
18387 * Bootstrap TabPanel class
18388 * @cfg {Boolean} active panel active
18389 * @cfg {String} html panel content
18390 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
18391 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
18392 * @cfg {String} href click to link..
18396 * Create a new TabPanel
18397 * @param {Object} config The config object
18400 Roo.bootstrap.TabPanel = function(config){
18401 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
18405 * Fires when the active status changes
18406 * @param {Roo.bootstrap.TabPanel} this
18407 * @param {Boolean} state the new state
18412 * @event beforedeactivate
18413 * Fires before a tab is de-activated - can be used to do validation on a form.
18414 * @param {Roo.bootstrap.TabPanel} this
18415 * @return {Boolean} false if there is an error
18418 'beforedeactivate': true
18421 this.tabId = this.tabId || Roo.id();
18425 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
18433 getAutoCreate : function(){
18436 // item is needed for carousel - not sure if it has any effect otherwise
18437 cls: 'tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
18438 html: this.html || ''
18442 cfg.cls += ' active';
18446 cfg.tabId = this.tabId;
18453 initEvents: function()
18455 var p = this.parent();
18457 this.navId = this.navId || p.navId;
18459 if (typeof(this.navId) != 'undefined') {
18460 // not really needed.. but just in case.. parent should be a NavGroup.
18461 var tg = Roo.bootstrap.TabGroup.get(this.navId);
18465 var i = tg.tabs.length - 1;
18467 if(this.active && tg.bullets > 0 && i < tg.bullets){
18468 tg.setActiveBullet(i);
18472 this.el.on('click', this.onClick, this);
18475 this.el.on("touchstart", this.onTouchStart, this);
18476 this.el.on("touchmove", this.onTouchMove, this);
18477 this.el.on("touchend", this.onTouchEnd, this);
18482 onRender : function(ct, position)
18484 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
18487 setActive : function(state)
18489 Roo.log("panel - set active " + this.tabId + "=" + state);
18491 this.active = state;
18493 this.el.removeClass('active');
18495 } else if (!this.el.hasClass('active')) {
18496 this.el.addClass('active');
18499 this.fireEvent('changed', this, state);
18502 onClick : function(e)
18504 e.preventDefault();
18506 if(!this.href.length){
18510 window.location.href = this.href;
18519 onTouchStart : function(e)
18521 this.swiping = false;
18523 this.startX = e.browserEvent.touches[0].clientX;
18524 this.startY = e.browserEvent.touches[0].clientY;
18527 onTouchMove : function(e)
18529 this.swiping = true;
18531 this.endX = e.browserEvent.touches[0].clientX;
18532 this.endY = e.browserEvent.touches[0].clientY;
18535 onTouchEnd : function(e)
18542 var tabGroup = this.parent();
18544 if(this.endX > this.startX){ // swiping right
18545 tabGroup.showPanelPrev();
18549 if(this.startX > this.endX){ // swiping left
18550 tabGroup.showPanelNext();
18569 * @class Roo.bootstrap.DateField
18570 * @extends Roo.bootstrap.Input
18571 * Bootstrap DateField class
18572 * @cfg {Number} weekStart default 0
18573 * @cfg {String} viewMode default empty, (months|years)
18574 * @cfg {String} minViewMode default empty, (months|years)
18575 * @cfg {Number} startDate default -Infinity
18576 * @cfg {Number} endDate default Infinity
18577 * @cfg {Boolean} todayHighlight default false
18578 * @cfg {Boolean} todayBtn default false
18579 * @cfg {Boolean} calendarWeeks default false
18580 * @cfg {Object} daysOfWeekDisabled default empty
18581 * @cfg {Boolean} singleMode default false (true | false)
18583 * @cfg {Boolean} keyboardNavigation default true
18584 * @cfg {String} language default en
18587 * Create a new DateField
18588 * @param {Object} config The config object
18591 Roo.bootstrap.DateField = function(config){
18592 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
18596 * Fires when this field show.
18597 * @param {Roo.bootstrap.DateField} this
18598 * @param {Mixed} date The date value
18603 * Fires when this field hide.
18604 * @param {Roo.bootstrap.DateField} this
18605 * @param {Mixed} date The date value
18610 * Fires when select a date.
18611 * @param {Roo.bootstrap.DateField} this
18612 * @param {Mixed} date The date value
18616 * @event beforeselect
18617 * Fires when before select a date.
18618 * @param {Roo.bootstrap.DateField} this
18619 * @param {Mixed} date The date value
18621 beforeselect : true
18625 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
18628 * @cfg {String} format
18629 * The default date format string which can be overriden for localization support. The format must be
18630 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
18634 * @cfg {String} altFormats
18635 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
18636 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
18638 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
18646 todayHighlight : false,
18652 keyboardNavigation: true,
18654 calendarWeeks: false,
18656 startDate: -Infinity,
18660 daysOfWeekDisabled: [],
18664 singleMode : false,
18666 UTCDate: function()
18668 return new Date(Date.UTC.apply(Date, arguments));
18671 UTCToday: function()
18673 var today = new Date();
18674 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
18677 getDate: function() {
18678 var d = this.getUTCDate();
18679 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
18682 getUTCDate: function() {
18686 setDate: function(d) {
18687 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
18690 setUTCDate: function(d) {
18692 this.setValue(this.formatDate(this.date));
18695 onRender: function(ct, position)
18698 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
18700 this.language = this.language || 'en';
18701 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
18702 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
18704 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
18705 this.format = this.format || 'm/d/y';
18706 this.isInline = false;
18707 this.isInput = true;
18708 this.component = this.el.select('.add-on', true).first() || false;
18709 this.component = (this.component && this.component.length === 0) ? false : this.component;
18710 this.hasInput = this.component && this.inputEl().length;
18712 if (typeof(this.minViewMode === 'string')) {
18713 switch (this.minViewMode) {
18715 this.minViewMode = 1;
18718 this.minViewMode = 2;
18721 this.minViewMode = 0;
18726 if (typeof(this.viewMode === 'string')) {
18727 switch (this.viewMode) {
18740 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
18742 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
18744 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18746 this.picker().on('mousedown', this.onMousedown, this);
18747 this.picker().on('click', this.onClick, this);
18749 this.picker().addClass('datepicker-dropdown');
18751 this.startViewMode = this.viewMode;
18753 if(this.singleMode){
18754 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
18755 v.setVisibilityMode(Roo.Element.DISPLAY);
18759 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
18760 v.setStyle('width', '189px');
18764 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
18765 if(!this.calendarWeeks){
18770 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18771 v.attr('colspan', function(i, val){
18772 return parseInt(val) + 1;
18777 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
18779 this.setStartDate(this.startDate);
18780 this.setEndDate(this.endDate);
18782 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
18789 if(this.isInline) {
18794 picker : function()
18796 return this.pickerEl;
18797 // return this.el.select('.datepicker', true).first();
18800 fillDow: function()
18802 var dowCnt = this.weekStart;
18811 if(this.calendarWeeks){
18819 while (dowCnt < this.weekStart + 7) {
18823 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
18827 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
18830 fillMonths: function()
18833 var months = this.picker().select('>.datepicker-months td', true).first();
18835 months.dom.innerHTML = '';
18841 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
18844 months.createChild(month);
18851 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;
18853 if (this.date < this.startDate) {
18854 this.viewDate = new Date(this.startDate);
18855 } else if (this.date > this.endDate) {
18856 this.viewDate = new Date(this.endDate);
18858 this.viewDate = new Date(this.date);
18866 var d = new Date(this.viewDate),
18867 year = d.getUTCFullYear(),
18868 month = d.getUTCMonth(),
18869 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
18870 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
18871 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
18872 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
18873 currentDate = this.date && this.date.valueOf(),
18874 today = this.UTCToday();
18876 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
18878 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18880 // this.picker.select('>tfoot th.today').
18881 // .text(dates[this.language].today)
18882 // .toggle(this.todayBtn !== false);
18884 this.updateNavArrows();
18887 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
18889 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
18891 prevMonth.setUTCDate(day);
18893 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
18895 var nextMonth = new Date(prevMonth);
18897 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
18899 nextMonth = nextMonth.valueOf();
18901 var fillMonths = false;
18903 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
18905 while(prevMonth.valueOf() <= nextMonth) {
18908 if (prevMonth.getUTCDay() === this.weekStart) {
18910 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
18918 if(this.calendarWeeks){
18919 // ISO 8601: First week contains first thursday.
18920 // ISO also states week starts on Monday, but we can be more abstract here.
18922 // Start of current week: based on weekstart/current date
18923 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
18924 // Thursday of this week
18925 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
18926 // First Thursday of year, year from thursday
18927 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
18928 // Calendar week: ms between thursdays, div ms per day, div 7 days
18929 calWeek = (th - yth) / 864e5 / 7 + 1;
18931 fillMonths.cn.push({
18939 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
18941 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
18944 if (this.todayHighlight &&
18945 prevMonth.getUTCFullYear() == today.getFullYear() &&
18946 prevMonth.getUTCMonth() == today.getMonth() &&
18947 prevMonth.getUTCDate() == today.getDate()) {
18948 clsName += ' today';
18951 if (currentDate && prevMonth.valueOf() === currentDate) {
18952 clsName += ' active';
18955 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
18956 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
18957 clsName += ' disabled';
18960 fillMonths.cn.push({
18962 cls: 'day ' + clsName,
18963 html: prevMonth.getDate()
18966 prevMonth.setDate(prevMonth.getDate()+1);
18969 var currentYear = this.date && this.date.getUTCFullYear();
18970 var currentMonth = this.date && this.date.getUTCMonth();
18972 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
18974 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
18975 v.removeClass('active');
18977 if(currentYear === year && k === currentMonth){
18978 v.addClass('active');
18981 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
18982 v.addClass('disabled');
18988 year = parseInt(year/10, 10) * 10;
18990 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
18992 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
18995 for (var i = -1; i < 11; i++) {
18996 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
18998 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
19006 showMode: function(dir)
19009 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
19012 Roo.each(this.picker().select('>div',true).elements, function(v){
19013 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19016 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
19021 if(this.isInline) {
19025 this.picker().removeClass(['bottom', 'top']);
19027 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
19029 * place to the top of element!
19033 this.picker().addClass('top');
19034 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
19039 this.picker().addClass('bottom');
19041 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
19044 parseDate : function(value)
19046 if(!value || value instanceof Date){
19049 var v = Date.parseDate(value, this.format);
19050 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
19051 v = Date.parseDate(value, 'Y-m-d');
19053 if(!v && this.altFormats){
19054 if(!this.altFormatsArray){
19055 this.altFormatsArray = this.altFormats.split("|");
19057 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
19058 v = Date.parseDate(value, this.altFormatsArray[i]);
19064 formatDate : function(date, fmt)
19066 return (!date || !(date instanceof Date)) ?
19067 date : date.dateFormat(fmt || this.format);
19070 onFocus : function()
19072 Roo.bootstrap.DateField.superclass.onFocus.call(this);
19076 onBlur : function()
19078 Roo.bootstrap.DateField.superclass.onBlur.call(this);
19080 var d = this.inputEl().getValue();
19087 showPopup : function()
19089 this.picker().show();
19093 this.fireEvent('showpopup', this, this.date);
19096 hidePopup : function()
19098 if(this.isInline) {
19101 this.picker().hide();
19102 this.viewMode = this.startViewMode;
19105 this.fireEvent('hidepopup', this, this.date);
19109 onMousedown: function(e)
19111 e.stopPropagation();
19112 e.preventDefault();
19117 Roo.bootstrap.DateField.superclass.keyup.call(this);
19121 setValue: function(v)
19123 if(this.fireEvent('beforeselect', this, v) !== false){
19124 var d = new Date(this.parseDate(v) ).clearTime();
19126 if(isNaN(d.getTime())){
19127 this.date = this.viewDate = '';
19128 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19132 v = this.formatDate(d);
19134 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
19136 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
19140 this.fireEvent('select', this, this.date);
19144 getValue: function()
19146 return this.formatDate(this.date);
19149 fireKey: function(e)
19151 if (!this.picker().isVisible()){
19152 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19158 var dateChanged = false,
19160 newDate, newViewDate;
19165 e.preventDefault();
19169 if (!this.keyboardNavigation) {
19172 dir = e.keyCode == 37 ? -1 : 1;
19175 newDate = this.moveYear(this.date, dir);
19176 newViewDate = this.moveYear(this.viewDate, dir);
19177 } else if (e.shiftKey){
19178 newDate = this.moveMonth(this.date, dir);
19179 newViewDate = this.moveMonth(this.viewDate, dir);
19181 newDate = new Date(this.date);
19182 newDate.setUTCDate(this.date.getUTCDate() + dir);
19183 newViewDate = new Date(this.viewDate);
19184 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
19186 if (this.dateWithinRange(newDate)){
19187 this.date = newDate;
19188 this.viewDate = newViewDate;
19189 this.setValue(this.formatDate(this.date));
19191 e.preventDefault();
19192 dateChanged = true;
19197 if (!this.keyboardNavigation) {
19200 dir = e.keyCode == 38 ? -1 : 1;
19202 newDate = this.moveYear(this.date, dir);
19203 newViewDate = this.moveYear(this.viewDate, dir);
19204 } else if (e.shiftKey){
19205 newDate = this.moveMonth(this.date, dir);
19206 newViewDate = this.moveMonth(this.viewDate, dir);
19208 newDate = new Date(this.date);
19209 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
19210 newViewDate = new Date(this.viewDate);
19211 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
19213 if (this.dateWithinRange(newDate)){
19214 this.date = newDate;
19215 this.viewDate = newViewDate;
19216 this.setValue(this.formatDate(this.date));
19218 e.preventDefault();
19219 dateChanged = true;
19223 this.setValue(this.formatDate(this.date));
19225 e.preventDefault();
19228 this.setValue(this.formatDate(this.date));
19242 onClick: function(e)
19244 e.stopPropagation();
19245 e.preventDefault();
19247 var target = e.getTarget();
19249 if(target.nodeName.toLowerCase() === 'i'){
19250 target = Roo.get(target).dom.parentNode;
19253 var nodeName = target.nodeName;
19254 var className = target.className;
19255 var html = target.innerHTML;
19256 //Roo.log(nodeName);
19258 switch(nodeName.toLowerCase()) {
19260 switch(className) {
19266 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
19267 switch(this.viewMode){
19269 this.viewDate = this.moveMonth(this.viewDate, dir);
19273 this.viewDate = this.moveYear(this.viewDate, dir);
19279 var date = new Date();
19280 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
19282 this.setValue(this.formatDate(this.date));
19289 if (className.indexOf('disabled') < 0) {
19290 this.viewDate.setUTCDate(1);
19291 if (className.indexOf('month') > -1) {
19292 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
19294 var year = parseInt(html, 10) || 0;
19295 this.viewDate.setUTCFullYear(year);
19299 if(this.singleMode){
19300 this.setValue(this.formatDate(this.viewDate));
19311 //Roo.log(className);
19312 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
19313 var day = parseInt(html, 10) || 1;
19314 var year = this.viewDate.getUTCFullYear(),
19315 month = this.viewDate.getUTCMonth();
19317 if (className.indexOf('old') > -1) {
19324 } else if (className.indexOf('new') > -1) {
19332 //Roo.log([year,month,day]);
19333 this.date = this.UTCDate(year, month, day,0,0,0,0);
19334 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
19336 //Roo.log(this.formatDate(this.date));
19337 this.setValue(this.formatDate(this.date));
19344 setStartDate: function(startDate)
19346 this.startDate = startDate || -Infinity;
19347 if (this.startDate !== -Infinity) {
19348 this.startDate = this.parseDate(this.startDate);
19351 this.updateNavArrows();
19354 setEndDate: function(endDate)
19356 this.endDate = endDate || Infinity;
19357 if (this.endDate !== Infinity) {
19358 this.endDate = this.parseDate(this.endDate);
19361 this.updateNavArrows();
19364 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
19366 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
19367 if (typeof(this.daysOfWeekDisabled) !== 'object') {
19368 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
19370 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
19371 return parseInt(d, 10);
19374 this.updateNavArrows();
19377 updateNavArrows: function()
19379 if(this.singleMode){
19383 var d = new Date(this.viewDate),
19384 year = d.getUTCFullYear(),
19385 month = d.getUTCMonth();
19387 Roo.each(this.picker().select('.prev', true).elements, function(v){
19389 switch (this.viewMode) {
19392 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
19398 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
19405 Roo.each(this.picker().select('.next', true).elements, function(v){
19407 switch (this.viewMode) {
19410 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
19416 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
19424 moveMonth: function(date, dir)
19429 var new_date = new Date(date.valueOf()),
19430 day = new_date.getUTCDate(),
19431 month = new_date.getUTCMonth(),
19432 mag = Math.abs(dir),
19434 dir = dir > 0 ? 1 : -1;
19437 // If going back one month, make sure month is not current month
19438 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
19440 return new_date.getUTCMonth() == month;
19442 // If going forward one month, make sure month is as expected
19443 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
19445 return new_date.getUTCMonth() != new_month;
19447 new_month = month + dir;
19448 new_date.setUTCMonth(new_month);
19449 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
19450 if (new_month < 0 || new_month > 11) {
19451 new_month = (new_month + 12) % 12;
19454 // For magnitudes >1, move one month at a time...
19455 for (var i=0; i<mag; i++) {
19456 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
19457 new_date = this.moveMonth(new_date, dir);
19459 // ...then reset the day, keeping it in the new month
19460 new_month = new_date.getUTCMonth();
19461 new_date.setUTCDate(day);
19463 return new_month != new_date.getUTCMonth();
19466 // Common date-resetting loop -- if date is beyond end of month, make it
19469 new_date.setUTCDate(--day);
19470 new_date.setUTCMonth(new_month);
19475 moveYear: function(date, dir)
19477 return this.moveMonth(date, dir*12);
19480 dateWithinRange: function(date)
19482 return date >= this.startDate && date <= this.endDate;
19488 this.picker().remove();
19491 validateValue : function(value)
19493 if(this.getVisibilityEl().hasClass('hidden')){
19497 if(value.length < 1) {
19498 if(this.allowBlank){
19504 if(value.length < this.minLength){
19507 if(value.length > this.maxLength){
19511 var vt = Roo.form.VTypes;
19512 if(!vt[this.vtype](value, this)){
19516 if(typeof this.validator == "function"){
19517 var msg = this.validator(value);
19523 if(this.regex && !this.regex.test(value)){
19527 if(typeof(this.parseDate(value)) == 'undefined'){
19531 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
19535 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
19545 this.date = this.viewDate = '';
19547 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19552 Roo.apply(Roo.bootstrap.DateField, {
19563 html: '<i class="fa fa-arrow-left"/>'
19573 html: '<i class="fa fa-arrow-right"/>'
19615 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
19616 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
19617 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
19618 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
19619 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
19632 navFnc: 'FullYear',
19637 navFnc: 'FullYear',
19642 Roo.apply(Roo.bootstrap.DateField, {
19646 cls: 'datepicker dropdown-menu roo-dynamic',
19650 cls: 'datepicker-days',
19654 cls: 'table-condensed',
19656 Roo.bootstrap.DateField.head,
19660 Roo.bootstrap.DateField.footer
19667 cls: 'datepicker-months',
19671 cls: 'table-condensed',
19673 Roo.bootstrap.DateField.head,
19674 Roo.bootstrap.DateField.content,
19675 Roo.bootstrap.DateField.footer
19682 cls: 'datepicker-years',
19686 cls: 'table-condensed',
19688 Roo.bootstrap.DateField.head,
19689 Roo.bootstrap.DateField.content,
19690 Roo.bootstrap.DateField.footer
19709 * @class Roo.bootstrap.TimeField
19710 * @extends Roo.bootstrap.Input
19711 * Bootstrap DateField class
19715 * Create a new TimeField
19716 * @param {Object} config The config object
19719 Roo.bootstrap.TimeField = function(config){
19720 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
19724 * Fires when this field show.
19725 * @param {Roo.bootstrap.DateField} thisthis
19726 * @param {Mixed} date The date value
19731 * Fires when this field hide.
19732 * @param {Roo.bootstrap.DateField} this
19733 * @param {Mixed} date The date value
19738 * Fires when select a date.
19739 * @param {Roo.bootstrap.DateField} this
19740 * @param {Mixed} date The date value
19746 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
19749 * @cfg {String} format
19750 * The default time format string which can be overriden for localization support. The format must be
19751 * valid according to {@link Date#parseDate} (defaults to 'H:i').
19755 onRender: function(ct, position)
19758 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
19760 this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.TimeField.template);
19762 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19764 this.pop = this.picker().select('>.datepicker-time',true).first();
19765 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19767 this.picker().on('mousedown', this.onMousedown, this);
19768 this.picker().on('click', this.onClick, this);
19770 this.picker().addClass('datepicker-dropdown');
19775 this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
19776 this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
19777 this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
19778 this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
19779 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
19780 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
19784 fireKey: function(e){
19785 if (!this.picker().isVisible()){
19786 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19792 e.preventDefault();
19800 this.onTogglePeriod();
19803 this.onIncrementMinutes();
19806 this.onDecrementMinutes();
19815 onClick: function(e) {
19816 e.stopPropagation();
19817 e.preventDefault();
19820 picker : function()
19822 return this.el.select('.datepicker', true).first();
19825 fillTime: function()
19827 var time = this.pop.select('tbody', true).first();
19829 time.dom.innerHTML = '';
19844 cls: 'hours-up glyphicon glyphicon-chevron-up'
19864 cls: 'minutes-up glyphicon glyphicon-chevron-up'
19885 cls: 'timepicker-hour',
19900 cls: 'timepicker-minute',
19915 cls: 'btn btn-primary period',
19937 cls: 'hours-down glyphicon glyphicon-chevron-down'
19957 cls: 'minutes-down glyphicon glyphicon-chevron-down'
19975 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
19982 var hours = this.time.getHours();
19983 var minutes = this.time.getMinutes();
19996 hours = hours - 12;
20000 hours = '0' + hours;
20004 minutes = '0' + minutes;
20007 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
20008 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
20009 this.pop.select('button', true).first().dom.innerHTML = period;
20015 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
20017 var cls = ['bottom'];
20019 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
20026 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
20031 this.picker().addClass(cls.join('-'));
20035 Roo.each(cls, function(c){
20037 _this.picker().setTop(_this.inputEl().getHeight());
20041 _this.picker().setTop(0 - _this.picker().getHeight());
20046 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
20050 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
20057 onFocus : function()
20059 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
20063 onBlur : function()
20065 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
20071 this.picker().show();
20076 this.fireEvent('show', this, this.date);
20081 this.picker().hide();
20084 this.fireEvent('hide', this, this.date);
20087 setTime : function()
20090 this.setValue(this.time.format(this.format));
20092 this.fireEvent('select', this, this.date);
20097 onMousedown: function(e){
20098 e.stopPropagation();
20099 e.preventDefault();
20102 onIncrementHours: function()
20104 Roo.log('onIncrementHours');
20105 this.time = this.time.add(Date.HOUR, 1);
20110 onDecrementHours: function()
20112 Roo.log('onDecrementHours');
20113 this.time = this.time.add(Date.HOUR, -1);
20117 onIncrementMinutes: function()
20119 Roo.log('onIncrementMinutes');
20120 this.time = this.time.add(Date.MINUTE, 1);
20124 onDecrementMinutes: function()
20126 Roo.log('onDecrementMinutes');
20127 this.time = this.time.add(Date.MINUTE, -1);
20131 onTogglePeriod: function()
20133 Roo.log('onTogglePeriod');
20134 this.time = this.time.add(Date.HOUR, 12);
20141 Roo.apply(Roo.bootstrap.TimeField, {
20171 cls: 'btn btn-info ok',
20183 Roo.apply(Roo.bootstrap.TimeField, {
20187 cls: 'datepicker dropdown-menu',
20191 cls: 'datepicker-time',
20195 cls: 'table-condensed',
20197 Roo.bootstrap.TimeField.content,
20198 Roo.bootstrap.TimeField.footer
20217 * @class Roo.bootstrap.MonthField
20218 * @extends Roo.bootstrap.Input
20219 * Bootstrap MonthField class
20221 * @cfg {String} language default en
20224 * Create a new MonthField
20225 * @param {Object} config The config object
20228 Roo.bootstrap.MonthField = function(config){
20229 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
20234 * Fires when this field show.
20235 * @param {Roo.bootstrap.MonthField} this
20236 * @param {Mixed} date The date value
20241 * Fires when this field hide.
20242 * @param {Roo.bootstrap.MonthField} this
20243 * @param {Mixed} date The date value
20248 * Fires when select a date.
20249 * @param {Roo.bootstrap.MonthField} this
20250 * @param {String} oldvalue The old value
20251 * @param {String} newvalue The new value
20257 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
20259 onRender: function(ct, position)
20262 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
20264 this.language = this.language || 'en';
20265 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
20266 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
20268 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
20269 this.isInline = false;
20270 this.isInput = true;
20271 this.component = this.el.select('.add-on', true).first() || false;
20272 this.component = (this.component && this.component.length === 0) ? false : this.component;
20273 this.hasInput = this.component && this.inputEL().length;
20275 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
20277 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
20279 this.picker().on('mousedown', this.onMousedown, this);
20280 this.picker().on('click', this.onClick, this);
20282 this.picker().addClass('datepicker-dropdown');
20284 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
20285 v.setStyle('width', '189px');
20292 if(this.isInline) {
20298 setValue: function(v, suppressEvent)
20300 var o = this.getValue();
20302 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
20306 if(suppressEvent !== true){
20307 this.fireEvent('select', this, o, v);
20312 getValue: function()
20317 onClick: function(e)
20319 e.stopPropagation();
20320 e.preventDefault();
20322 var target = e.getTarget();
20324 if(target.nodeName.toLowerCase() === 'i'){
20325 target = Roo.get(target).dom.parentNode;
20328 var nodeName = target.nodeName;
20329 var className = target.className;
20330 var html = target.innerHTML;
20332 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
20336 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
20338 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20344 picker : function()
20346 return this.pickerEl;
20349 fillMonths: function()
20352 var months = this.picker().select('>.datepicker-months td', true).first();
20354 months.dom.innerHTML = '';
20360 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
20363 months.createChild(month);
20372 if(typeof(this.vIndex) == 'undefined' && this.value.length){
20373 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
20376 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
20377 e.removeClass('active');
20379 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
20380 e.addClass('active');
20387 if(this.isInline) {
20391 this.picker().removeClass(['bottom', 'top']);
20393 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
20395 * place to the top of element!
20399 this.picker().addClass('top');
20400 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
20405 this.picker().addClass('bottom');
20407 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
20410 onFocus : function()
20412 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
20416 onBlur : function()
20418 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
20420 var d = this.inputEl().getValue();
20429 this.picker().show();
20430 this.picker().select('>.datepicker-months', true).first().show();
20434 this.fireEvent('show', this, this.date);
20439 if(this.isInline) {
20442 this.picker().hide();
20443 this.fireEvent('hide', this, this.date);
20447 onMousedown: function(e)
20449 e.stopPropagation();
20450 e.preventDefault();
20455 Roo.bootstrap.MonthField.superclass.keyup.call(this);
20459 fireKey: function(e)
20461 if (!this.picker().isVisible()){
20462 if (e.keyCode == 27) {// allow escape to hide and re-show picker
20473 e.preventDefault();
20477 dir = e.keyCode == 37 ? -1 : 1;
20479 this.vIndex = this.vIndex + dir;
20481 if(this.vIndex < 0){
20485 if(this.vIndex > 11){
20489 if(isNaN(this.vIndex)){
20493 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20499 dir = e.keyCode == 38 ? -1 : 1;
20501 this.vIndex = this.vIndex + dir * 4;
20503 if(this.vIndex < 0){
20507 if(this.vIndex > 11){
20511 if(isNaN(this.vIndex)){
20515 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20520 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20521 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20525 e.preventDefault();
20528 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20529 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20545 this.picker().remove();
20550 Roo.apply(Roo.bootstrap.MonthField, {
20569 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
20570 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
20575 Roo.apply(Roo.bootstrap.MonthField, {
20579 cls: 'datepicker dropdown-menu roo-dynamic',
20583 cls: 'datepicker-months',
20587 cls: 'table-condensed',
20589 Roo.bootstrap.DateField.content
20609 * @class Roo.bootstrap.CheckBox
20610 * @extends Roo.bootstrap.Input
20611 * Bootstrap CheckBox class
20613 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
20614 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
20615 * @cfg {String} boxLabel The text that appears beside the checkbox
20616 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
20617 * @cfg {Boolean} checked initnal the element
20618 * @cfg {Boolean} inline inline the element (default false)
20619 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
20620 * @cfg {String} tooltip label tooltip
20623 * Create a new CheckBox
20624 * @param {Object} config The config object
20627 Roo.bootstrap.CheckBox = function(config){
20628 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
20633 * Fires when the element is checked or unchecked.
20634 * @param {Roo.bootstrap.CheckBox} this This input
20635 * @param {Boolean} checked The new checked value
20640 * Fires when the element is click.
20641 * @param {Roo.bootstrap.CheckBox} this This input
20648 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
20650 inputType: 'checkbox',
20659 getAutoCreate : function()
20661 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
20667 cfg.cls = 'form-group ' + this.inputType; //input-group
20670 cfg.cls += ' ' + this.inputType + '-inline';
20676 type : this.inputType,
20677 value : this.inputValue,
20678 cls : 'roo-' + this.inputType, //'form-box',
20679 placeholder : this.placeholder || ''
20683 if(this.inputType != 'radio'){
20687 cls : 'roo-hidden-value',
20688 value : this.checked ? this.inputValue : this.valueOff
20693 if (this.weight) { // Validity check?
20694 cfg.cls += " " + this.inputType + "-" + this.weight;
20697 if (this.disabled) {
20698 input.disabled=true;
20702 input.checked = this.checked;
20707 input.name = this.name;
20709 if(this.inputType != 'radio'){
20710 hidden.name = this.name;
20711 input.name = '_hidden_' + this.name;
20716 input.cls += ' input-' + this.size;
20721 ['xs','sm','md','lg'].map(function(size){
20722 if (settings[size]) {
20723 cfg.cls += ' col-' + size + '-' + settings[size];
20727 var inputblock = input;
20729 if (this.before || this.after) {
20732 cls : 'input-group',
20737 inputblock.cn.push({
20739 cls : 'input-group-addon',
20744 inputblock.cn.push(input);
20746 if(this.inputType != 'radio'){
20747 inputblock.cn.push(hidden);
20751 inputblock.cn.push({
20753 cls : 'input-group-addon',
20760 if (align ==='left' && this.fieldLabel.length) {
20761 // Roo.log("left and has label");
20766 cls : 'control-label',
20767 html : this.fieldLabel
20777 if(this.labelWidth > 12){
20778 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
20781 if(this.labelWidth < 13 && this.labelmd == 0){
20782 this.labelmd = this.labelWidth;
20785 if(this.labellg > 0){
20786 cfg.cn[0].cls += ' col-lg-' + this.labellg;
20787 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
20790 if(this.labelmd > 0){
20791 cfg.cn[0].cls += ' col-md-' + this.labelmd;
20792 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
20795 if(this.labelsm > 0){
20796 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
20797 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
20800 if(this.labelxs > 0){
20801 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
20802 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
20805 } else if ( this.fieldLabel.length) {
20806 // Roo.log(" label");
20810 tag: this.boxLabel ? 'span' : 'label',
20812 cls: 'control-label box-input-label',
20813 //cls : 'input-group-addon',
20814 html : this.fieldLabel
20823 // Roo.log(" no label && no align");
20824 cfg.cn = [ inputblock ] ;
20830 var boxLabelCfg = {
20832 //'for': id, // box label is handled by onclick - so no for...
20834 html: this.boxLabel
20838 boxLabelCfg.tooltip = this.tooltip;
20841 cfg.cn.push(boxLabelCfg);
20844 if(this.inputType != 'radio'){
20845 cfg.cn.push(hidden);
20853 * return the real input element.
20855 inputEl: function ()
20857 return this.el.select('input.roo-' + this.inputType,true).first();
20859 hiddenEl: function ()
20861 return this.el.select('input.roo-hidden-value',true).first();
20864 labelEl: function()
20866 return this.el.select('label.control-label',true).first();
20868 /* depricated... */
20872 return this.labelEl();
20875 boxLabelEl: function()
20877 return this.el.select('label.box-label',true).first();
20880 initEvents : function()
20882 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
20884 this.inputEl().on('click', this.onClick, this);
20886 if (this.boxLabel) {
20887 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
20890 this.startValue = this.getValue();
20893 Roo.bootstrap.CheckBox.register(this);
20897 onClick : function(e)
20899 if(this.fireEvent('click', this, e) !== false){
20900 this.setChecked(!this.checked);
20905 setChecked : function(state,suppressEvent)
20907 this.startValue = this.getValue();
20909 if(this.inputType == 'radio'){
20911 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20912 e.dom.checked = false;
20915 this.inputEl().dom.checked = true;
20917 this.inputEl().dom.value = this.inputValue;
20919 if(suppressEvent !== true){
20920 this.fireEvent('check', this, true);
20928 this.checked = state;
20930 this.inputEl().dom.checked = state;
20933 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
20935 if(suppressEvent !== true){
20936 this.fireEvent('check', this, state);
20942 getValue : function()
20944 if(this.inputType == 'radio'){
20945 return this.getGroupValue();
20948 return this.hiddenEl().dom.value;
20952 getGroupValue : function()
20954 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
20958 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
20961 setValue : function(v,suppressEvent)
20963 if(this.inputType == 'radio'){
20964 this.setGroupValue(v, suppressEvent);
20968 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
20973 setGroupValue : function(v, suppressEvent)
20975 this.startValue = this.getValue();
20977 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20978 e.dom.checked = false;
20980 if(e.dom.value == v){
20981 e.dom.checked = true;
20985 if(suppressEvent !== true){
20986 this.fireEvent('check', this, true);
20994 validate : function()
20996 if(this.getVisibilityEl().hasClass('hidden')){
21002 (this.inputType == 'radio' && this.validateRadio()) ||
21003 (this.inputType == 'checkbox' && this.validateCheckbox())
21009 this.markInvalid();
21013 validateRadio : function()
21015 if(this.getVisibilityEl().hasClass('hidden')){
21019 if(this.allowBlank){
21025 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21026 if(!e.dom.checked){
21038 validateCheckbox : function()
21041 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
21042 //return (this.getValue() == this.inputValue) ? true : false;
21045 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21053 for(var i in group){
21054 if(group[i].el.isVisible(true)){
21062 for(var i in group){
21067 r = (group[i].getValue() == group[i].inputValue) ? true : false;
21074 * Mark this field as valid
21076 markValid : function()
21080 this.fireEvent('valid', this);
21082 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21085 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21092 if(this.inputType == 'radio'){
21093 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21094 e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
21095 e.findParent('.form-group', false, true).addClass(_this.validClass);
21102 this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
21103 this.el.findParent('.form-group', false, true).addClass(this.validClass);
21107 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21113 for(var i in group){
21114 group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
21115 group[i].el.findParent('.form-group', false, true).addClass(this.validClass);
21120 * Mark this field as invalid
21121 * @param {String} msg The validation message
21123 markInvalid : function(msg)
21125 if(this.allowBlank){
21131 this.fireEvent('invalid', this, msg);
21133 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21136 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21140 label.markInvalid();
21143 if(this.inputType == 'radio'){
21144 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21145 e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
21146 e.findParent('.form-group', false, true).addClass(_this.invalidClass);
21153 this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
21154 this.el.findParent('.form-group', false, true).addClass(this.invalidClass);
21158 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21164 for(var i in group){
21165 group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
21166 group[i].el.findParent('.form-group', false, true).addClass(this.invalidClass);
21171 clearInvalid : function()
21173 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
21175 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
21177 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21179 if (label && label.iconEl) {
21180 label.iconEl.removeClass(label.validClass);
21181 label.iconEl.removeClass(label.invalidClass);
21185 disable : function()
21187 if(this.inputType != 'radio'){
21188 Roo.bootstrap.CheckBox.superclass.disable.call(this);
21195 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21196 _this.getActionEl().addClass(this.disabledClass);
21197 e.dom.disabled = true;
21201 this.disabled = true;
21202 this.fireEvent("disable", this);
21206 enable : function()
21208 if(this.inputType != 'radio'){
21209 Roo.bootstrap.CheckBox.superclass.enable.call(this);
21216 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21217 _this.getActionEl().removeClass(this.disabledClass);
21218 e.dom.disabled = false;
21222 this.disabled = false;
21223 this.fireEvent("enable", this);
21227 setBoxLabel : function(v)
21232 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21238 Roo.apply(Roo.bootstrap.CheckBox, {
21243 * register a CheckBox Group
21244 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
21246 register : function(checkbox)
21248 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
21249 this.groups[checkbox.groupId] = {};
21252 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
21256 this.groups[checkbox.groupId][checkbox.name] = checkbox;
21260 * fetch a CheckBox Group based on the group ID
21261 * @param {string} the group ID
21262 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
21264 get: function(groupId) {
21265 if (typeof(this.groups[groupId]) == 'undefined') {
21269 return this.groups[groupId] ;
21282 * @class Roo.bootstrap.Radio
21283 * @extends Roo.bootstrap.Component
21284 * Bootstrap Radio class
21285 * @cfg {String} boxLabel - the label associated
21286 * @cfg {String} value - the value of radio
21289 * Create a new Radio
21290 * @param {Object} config The config object
21292 Roo.bootstrap.Radio = function(config){
21293 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
21297 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
21303 getAutoCreate : function()
21307 cls : 'form-group radio',
21312 html : this.boxLabel
21320 initEvents : function()
21322 this.parent().register(this);
21324 this.el.on('click', this.onClick, this);
21328 onClick : function(e)
21330 if(this.parent().fireEvent('click', this.parent(), this, e) !== false){
21331 this.setChecked(true);
21335 setChecked : function(state, suppressEvent)
21337 this.parent().setValue(this.value, suppressEvent);
21341 setBoxLabel : function(v)
21346 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21361 * @class Roo.bootstrap.SecurePass
21362 * @extends Roo.bootstrap.Input
21363 * Bootstrap SecurePass class
21367 * Create a new SecurePass
21368 * @param {Object} config The config object
21371 Roo.bootstrap.SecurePass = function (config) {
21372 // these go here, so the translation tool can replace them..
21374 PwdEmpty: "Please type a password, and then retype it to confirm.",
21375 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21376 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21377 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21378 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21379 FNInPwd: "Your password can't contain your first name. Please type a different password.",
21380 LNInPwd: "Your password can't contain your last name. Please type a different password.",
21381 TooWeak: "Your password is Too Weak."
21383 this.meterLabel = "Password strength:";
21384 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
21385 this.meterClass = [
21386 "roo-password-meter-tooweak",
21387 "roo-password-meter-weak",
21388 "roo-password-meter-medium",
21389 "roo-password-meter-strong",
21390 "roo-password-meter-grey"
21395 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
21398 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
21400 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
21402 * PwdEmpty: "Please type a password, and then retype it to confirm.",
21403 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21404 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21405 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21406 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21407 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
21408 * LNInPwd: "Your password can't contain your last name. Please type a different password."
21418 * @cfg {String/Object} Label for the strength meter (defaults to
21419 * 'Password strength:')
21424 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
21425 * ['Weak', 'Medium', 'Strong'])
21428 pwdStrengths: false,
21441 initEvents: function ()
21443 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
21445 if (this.el.is('input[type=password]') && Roo.isSafari) {
21446 this.el.on('keydown', this.SafariOnKeyDown, this);
21449 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
21452 onRender: function (ct, position)
21454 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
21455 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
21456 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
21458 this.trigger.createChild({
21463 cls: 'roo-password-meter-grey col-xs-12',
21466 //width: this.meterWidth + 'px'
21470 cls: 'roo-password-meter-text'
21476 if (this.hideTrigger) {
21477 this.trigger.setDisplayed(false);
21479 this.setSize(this.width || '', this.height || '');
21482 onDestroy: function ()
21484 if (this.trigger) {
21485 this.trigger.removeAllListeners();
21486 this.trigger.remove();
21489 this.wrap.remove();
21491 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
21494 checkStrength: function ()
21496 var pwd = this.inputEl().getValue();
21497 if (pwd == this._lastPwd) {
21502 if (this.ClientSideStrongPassword(pwd)) {
21504 } else if (this.ClientSideMediumPassword(pwd)) {
21506 } else if (this.ClientSideWeakPassword(pwd)) {
21512 Roo.log('strength1: ' + strength);
21514 //var pm = this.trigger.child('div/div/div').dom;
21515 var pm = this.trigger.child('div/div');
21516 pm.removeClass(this.meterClass);
21517 pm.addClass(this.meterClass[strength]);
21520 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21522 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21524 this._lastPwd = pwd;
21528 Roo.bootstrap.SecurePass.superclass.reset.call(this);
21530 this._lastPwd = '';
21532 var pm = this.trigger.child('div/div');
21533 pm.removeClass(this.meterClass);
21534 pm.addClass('roo-password-meter-grey');
21537 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21540 this.inputEl().dom.type='password';
21543 validateValue: function (value)
21546 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
21549 if (value.length == 0) {
21550 if (this.allowBlank) {
21551 this.clearInvalid();
21555 this.markInvalid(this.errors.PwdEmpty);
21556 this.errorMsg = this.errors.PwdEmpty;
21564 if ('[\x21-\x7e]*'.match(value)) {
21565 this.markInvalid(this.errors.PwdBadChar);
21566 this.errorMsg = this.errors.PwdBadChar;
21569 if (value.length < 6) {
21570 this.markInvalid(this.errors.PwdShort);
21571 this.errorMsg = this.errors.PwdShort;
21574 if (value.length > 16) {
21575 this.markInvalid(this.errors.PwdLong);
21576 this.errorMsg = this.errors.PwdLong;
21580 if (this.ClientSideStrongPassword(value)) {
21582 } else if (this.ClientSideMediumPassword(value)) {
21584 } else if (this.ClientSideWeakPassword(value)) {
21591 if (strength < 2) {
21592 //this.markInvalid(this.errors.TooWeak);
21593 this.errorMsg = this.errors.TooWeak;
21598 console.log('strength2: ' + strength);
21600 //var pm = this.trigger.child('div/div/div').dom;
21602 var pm = this.trigger.child('div/div');
21603 pm.removeClass(this.meterClass);
21604 pm.addClass(this.meterClass[strength]);
21606 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21608 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21610 this.errorMsg = '';
21614 CharacterSetChecks: function (type)
21617 this.fResult = false;
21620 isctype: function (character, type)
21623 case this.kCapitalLetter:
21624 if (character >= 'A' && character <= 'Z') {
21629 case this.kSmallLetter:
21630 if (character >= 'a' && character <= 'z') {
21636 if (character >= '0' && character <= '9') {
21641 case this.kPunctuation:
21642 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
21653 IsLongEnough: function (pwd, size)
21655 return !(pwd == null || isNaN(size) || pwd.length < size);
21658 SpansEnoughCharacterSets: function (word, nb)
21660 if (!this.IsLongEnough(word, nb))
21665 var characterSetChecks = new Array(
21666 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
21667 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
21670 for (var index = 0; index < word.length; ++index) {
21671 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21672 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
21673 characterSetChecks[nCharSet].fResult = true;
21680 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21681 if (characterSetChecks[nCharSet].fResult) {
21686 if (nCharSets < nb) {
21692 ClientSideStrongPassword: function (pwd)
21694 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
21697 ClientSideMediumPassword: function (pwd)
21699 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
21702 ClientSideWeakPassword: function (pwd)
21704 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
21707 })//<script type="text/javascript">
21710 * Based Ext JS Library 1.1.1
21711 * Copyright(c) 2006-2007, Ext JS, LLC.
21717 * @class Roo.HtmlEditorCore
21718 * @extends Roo.Component
21719 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
21721 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
21724 Roo.HtmlEditorCore = function(config){
21727 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
21732 * @event initialize
21733 * Fires when the editor is fully initialized (including the iframe)
21734 * @param {Roo.HtmlEditorCore} this
21739 * Fires when the editor is first receives the focus. Any insertion must wait
21740 * until after this event.
21741 * @param {Roo.HtmlEditorCore} this
21745 * @event beforesync
21746 * Fires before the textarea is updated with content from the editor iframe. Return false
21747 * to cancel the sync.
21748 * @param {Roo.HtmlEditorCore} this
21749 * @param {String} html
21753 * @event beforepush
21754 * Fires before the iframe editor is updated with content from the textarea. Return false
21755 * to cancel the push.
21756 * @param {Roo.HtmlEditorCore} this
21757 * @param {String} html
21762 * Fires when the textarea is updated with content from the editor iframe.
21763 * @param {Roo.HtmlEditorCore} this
21764 * @param {String} html
21769 * Fires when the iframe editor is updated with content from the textarea.
21770 * @param {Roo.HtmlEditorCore} this
21771 * @param {String} html
21776 * @event editorevent
21777 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
21778 * @param {Roo.HtmlEditorCore} this
21784 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
21786 // defaults : white / black...
21787 this.applyBlacklists();
21794 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
21798 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
21804 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
21809 * @cfg {Number} height (in pixels)
21813 * @cfg {Number} width (in pixels)
21818 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
21821 stylesheets: false,
21826 // private properties
21827 validationEvent : false,
21829 initialized : false,
21831 sourceEditMode : false,
21832 onFocus : Roo.emptyFn,
21834 hideMode:'offsets',
21838 // blacklist + whitelisted elements..
21845 * Protected method that will not generally be called directly. It
21846 * is called when the editor initializes the iframe with HTML contents. Override this method if you
21847 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
21849 getDocMarkup : function(){
21853 // inherit styels from page...??
21854 if (this.stylesheets === false) {
21856 Roo.get(document.head).select('style').each(function(node) {
21857 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
21860 Roo.get(document.head).select('link').each(function(node) {
21861 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
21864 } else if (!this.stylesheets.length) {
21866 st = '<style type="text/css">' +
21867 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
21870 st = '<style type="text/css">' +
21875 st += '<style type="text/css">' +
21876 'IMG { cursor: pointer } ' +
21879 var cls = 'roo-htmleditor-body';
21881 if(this.bodyCls.length){
21882 cls += ' ' + this.bodyCls;
21885 return '<html><head>' + st +
21886 //<style type="text/css">' +
21887 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
21889 ' </head><body class="' + cls + '"></body></html>';
21893 onRender : function(ct, position)
21896 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
21897 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
21900 this.el.dom.style.border = '0 none';
21901 this.el.dom.setAttribute('tabIndex', -1);
21902 this.el.addClass('x-hidden hide');
21906 if(Roo.isIE){ // fix IE 1px bogus margin
21907 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
21911 this.frameId = Roo.id();
21915 var iframe = this.owner.wrap.createChild({
21917 cls: 'form-control', // bootstrap..
21919 name: this.frameId,
21920 frameBorder : 'no',
21921 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
21926 this.iframe = iframe.dom;
21928 this.assignDocWin();
21930 this.doc.designMode = 'on';
21933 this.doc.write(this.getDocMarkup());
21937 var task = { // must defer to wait for browser to be ready
21939 //console.log("run task?" + this.doc.readyState);
21940 this.assignDocWin();
21941 if(this.doc.body || this.doc.readyState == 'complete'){
21943 this.doc.designMode="on";
21947 Roo.TaskMgr.stop(task);
21948 this.initEditor.defer(10, this);
21955 Roo.TaskMgr.start(task);
21960 onResize : function(w, h)
21962 Roo.log('resize: ' +w + ',' + h );
21963 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
21967 if(typeof w == 'number'){
21969 this.iframe.style.width = w + 'px';
21971 if(typeof h == 'number'){
21973 this.iframe.style.height = h + 'px';
21975 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
21982 * Toggles the editor between standard and source edit mode.
21983 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
21985 toggleSourceEdit : function(sourceEditMode){
21987 this.sourceEditMode = sourceEditMode === true;
21989 if(this.sourceEditMode){
21991 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
21994 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
21995 //this.iframe.className = '';
21998 //this.setSize(this.owner.wrap.getSize());
21999 //this.fireEvent('editmodechange', this, this.sourceEditMode);
22006 * Protected method that will not generally be called directly. If you need/want
22007 * custom HTML cleanup, this is the method you should override.
22008 * @param {String} html The HTML to be cleaned
22009 * return {String} The cleaned HTML
22011 cleanHtml : function(html){
22012 html = String(html);
22013 if(html.length > 5){
22014 if(Roo.isSafari){ // strip safari nonsense
22015 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
22018 if(html == ' '){
22025 * HTML Editor -> Textarea
22026 * Protected method that will not generally be called directly. Syncs the contents
22027 * of the editor iframe with the textarea.
22029 syncValue : function(){
22030 if(this.initialized){
22031 var bd = (this.doc.body || this.doc.documentElement);
22032 //this.cleanUpPaste(); -- this is done else where and causes havoc..
22033 var html = bd.innerHTML;
22035 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
22036 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
22038 html = '<div style="'+m[0]+'">' + html + '</div>';
22041 html = this.cleanHtml(html);
22042 // fix up the special chars.. normaly like back quotes in word...
22043 // however we do not want to do this with chinese..
22044 html = html.replace(/([\x80-\uffff])/g, function (a, b) {
22045 var cc = b.charCodeAt();
22047 (cc >= 0x4E00 && cc < 0xA000 ) ||
22048 (cc >= 0x3400 && cc < 0x4E00 ) ||
22049 (cc >= 0xf900 && cc < 0xfb00 )
22055 if(this.owner.fireEvent('beforesync', this, html) !== false){
22056 this.el.dom.value = html;
22057 this.owner.fireEvent('sync', this, html);
22063 * Protected method that will not generally be called directly. Pushes the value of the textarea
22064 * into the iframe editor.
22066 pushValue : function(){
22067 if(this.initialized){
22068 var v = this.el.dom.value.trim();
22070 // if(v.length < 1){
22074 if(this.owner.fireEvent('beforepush', this, v) !== false){
22075 var d = (this.doc.body || this.doc.documentElement);
22077 this.cleanUpPaste();
22078 this.el.dom.value = d.innerHTML;
22079 this.owner.fireEvent('push', this, v);
22085 deferFocus : function(){
22086 this.focus.defer(10, this);
22090 focus : function(){
22091 if(this.win && !this.sourceEditMode){
22098 assignDocWin: function()
22100 var iframe = this.iframe;
22103 this.doc = iframe.contentWindow.document;
22104 this.win = iframe.contentWindow;
22106 // if (!Roo.get(this.frameId)) {
22109 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22110 // this.win = Roo.get(this.frameId).dom.contentWindow;
22112 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
22116 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22117 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
22122 initEditor : function(){
22123 //console.log("INIT EDITOR");
22124 this.assignDocWin();
22128 this.doc.designMode="on";
22130 this.doc.write(this.getDocMarkup());
22133 var dbody = (this.doc.body || this.doc.documentElement);
22134 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
22135 // this copies styles from the containing element into thsi one..
22136 // not sure why we need all of this..
22137 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
22139 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
22140 //ss['background-attachment'] = 'fixed'; // w3c
22141 dbody.bgProperties = 'fixed'; // ie
22142 //Roo.DomHelper.applyStyles(dbody, ss);
22143 Roo.EventManager.on(this.doc, {
22144 //'mousedown': this.onEditorEvent,
22145 'mouseup': this.onEditorEvent,
22146 'dblclick': this.onEditorEvent,
22147 'click': this.onEditorEvent,
22148 'keyup': this.onEditorEvent,
22153 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
22155 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
22156 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
22158 this.initialized = true;
22160 this.owner.fireEvent('initialize', this);
22165 onDestroy : function(){
22171 //for (var i =0; i < this.toolbars.length;i++) {
22172 // // fixme - ask toolbars for heights?
22173 // this.toolbars[i].onDestroy();
22176 //this.wrap.dom.innerHTML = '';
22177 //this.wrap.remove();
22182 onFirstFocus : function(){
22184 this.assignDocWin();
22187 this.activated = true;
22190 if(Roo.isGecko){ // prevent silly gecko errors
22192 var s = this.win.getSelection();
22193 if(!s.focusNode || s.focusNode.nodeType != 3){
22194 var r = s.getRangeAt(0);
22195 r.selectNodeContents((this.doc.body || this.doc.documentElement));
22200 this.execCmd('useCSS', true);
22201 this.execCmd('styleWithCSS', false);
22204 this.owner.fireEvent('activate', this);
22208 adjustFont: function(btn){
22209 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
22210 //if(Roo.isSafari){ // safari
22213 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
22214 if(Roo.isSafari){ // safari
22215 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
22216 v = (v < 10) ? 10 : v;
22217 v = (v > 48) ? 48 : v;
22218 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
22223 v = Math.max(1, v+adjust);
22225 this.execCmd('FontSize', v );
22228 onEditorEvent : function(e)
22230 this.owner.fireEvent('editorevent', this, e);
22231 // this.updateToolbar();
22232 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
22235 insertTag : function(tg)
22237 // could be a bit smarter... -> wrap the current selected tRoo..
22238 if (tg.toLowerCase() == 'span' || tg.toLowerCase() == 'code') {
22240 range = this.createRange(this.getSelection());
22241 var wrappingNode = this.doc.createElement(tg.toLowerCase());
22242 wrappingNode.appendChild(range.extractContents());
22243 range.insertNode(wrappingNode);
22250 this.execCmd("formatblock", tg);
22254 insertText : function(txt)
22258 var range = this.createRange();
22259 range.deleteContents();
22260 //alert(Sender.getAttribute('label'));
22262 range.insertNode(this.doc.createTextNode(txt));
22268 * Executes a Midas editor command on the editor document and performs necessary focus and
22269 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
22270 * @param {String} cmd The Midas command
22271 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22273 relayCmd : function(cmd, value){
22275 this.execCmd(cmd, value);
22276 this.owner.fireEvent('editorevent', this);
22277 //this.updateToolbar();
22278 this.owner.deferFocus();
22282 * Executes a Midas editor command directly on the editor document.
22283 * For visual commands, you should use {@link #relayCmd} instead.
22284 * <b>This should only be called after the editor is initialized.</b>
22285 * @param {String} cmd The Midas command
22286 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22288 execCmd : function(cmd, value){
22289 this.doc.execCommand(cmd, false, value === undefined ? null : value);
22296 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
22298 * @param {String} text | dom node..
22300 insertAtCursor : function(text)
22303 if(!this.activated){
22309 var r = this.doc.selection.createRange();
22320 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
22324 // from jquery ui (MIT licenced)
22326 var win = this.win;
22328 if (win.getSelection && win.getSelection().getRangeAt) {
22329 range = win.getSelection().getRangeAt(0);
22330 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
22331 range.insertNode(node);
22332 } else if (win.document.selection && win.document.selection.createRange) {
22333 // no firefox support
22334 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22335 win.document.selection.createRange().pasteHTML(txt);
22337 // no firefox support
22338 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22339 this.execCmd('InsertHTML', txt);
22348 mozKeyPress : function(e){
22350 var c = e.getCharCode(), cmd;
22353 c = String.fromCharCode(c).toLowerCase();
22367 this.cleanUpPaste.defer(100, this);
22375 e.preventDefault();
22383 fixKeys : function(){ // load time branching for fastest keydown performance
22385 return function(e){
22386 var k = e.getKey(), r;
22389 r = this.doc.selection.createRange();
22392 r.pasteHTML('    ');
22399 r = this.doc.selection.createRange();
22401 var target = r.parentElement();
22402 if(!target || target.tagName.toLowerCase() != 'li'){
22404 r.pasteHTML('<br />');
22410 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22411 this.cleanUpPaste.defer(100, this);
22417 }else if(Roo.isOpera){
22418 return function(e){
22419 var k = e.getKey();
22423 this.execCmd('InsertHTML','    ');
22426 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22427 this.cleanUpPaste.defer(100, this);
22432 }else if(Roo.isSafari){
22433 return function(e){
22434 var k = e.getKey();
22438 this.execCmd('InsertText','\t');
22442 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22443 this.cleanUpPaste.defer(100, this);
22451 getAllAncestors: function()
22453 var p = this.getSelectedNode();
22456 a.push(p); // push blank onto stack..
22457 p = this.getParentElement();
22461 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
22465 a.push(this.doc.body);
22469 lastSelNode : false,
22472 getSelection : function()
22474 this.assignDocWin();
22475 return Roo.isIE ? this.doc.selection : this.win.getSelection();
22478 getSelectedNode: function()
22480 // this may only work on Gecko!!!
22482 // should we cache this!!!!
22487 var range = this.createRange(this.getSelection()).cloneRange();
22490 var parent = range.parentElement();
22492 var testRange = range.duplicate();
22493 testRange.moveToElementText(parent);
22494 if (testRange.inRange(range)) {
22497 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
22500 parent = parent.parentElement;
22505 // is ancestor a text element.
22506 var ac = range.commonAncestorContainer;
22507 if (ac.nodeType == 3) {
22508 ac = ac.parentNode;
22511 var ar = ac.childNodes;
22514 var other_nodes = [];
22515 var has_other_nodes = false;
22516 for (var i=0;i<ar.length;i++) {
22517 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
22520 // fullly contained node.
22522 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
22527 // probably selected..
22528 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
22529 other_nodes.push(ar[i]);
22533 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
22538 has_other_nodes = true;
22540 if (!nodes.length && other_nodes.length) {
22541 nodes= other_nodes;
22543 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
22549 createRange: function(sel)
22551 // this has strange effects when using with
22552 // top toolbar - not sure if it's a great idea.
22553 //this.editor.contentWindow.focus();
22554 if (typeof sel != "undefined") {
22556 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
22558 return this.doc.createRange();
22561 return this.doc.createRange();
22564 getParentElement: function()
22567 this.assignDocWin();
22568 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
22570 var range = this.createRange(sel);
22573 var p = range.commonAncestorContainer;
22574 while (p.nodeType == 3) { // text node
22585 * Range intersection.. the hard stuff...
22589 * [ -- selected range --- ]
22593 * if end is before start or hits it. fail.
22594 * if start is after end or hits it fail.
22596 * if either hits (but other is outside. - then it's not
22602 // @see http://www.thismuchiknow.co.uk/?p=64.
22603 rangeIntersectsNode : function(range, node)
22605 var nodeRange = node.ownerDocument.createRange();
22607 nodeRange.selectNode(node);
22609 nodeRange.selectNodeContents(node);
22612 var rangeStartRange = range.cloneRange();
22613 rangeStartRange.collapse(true);
22615 var rangeEndRange = range.cloneRange();
22616 rangeEndRange.collapse(false);
22618 var nodeStartRange = nodeRange.cloneRange();
22619 nodeStartRange.collapse(true);
22621 var nodeEndRange = nodeRange.cloneRange();
22622 nodeEndRange.collapse(false);
22624 return rangeStartRange.compareBoundaryPoints(
22625 Range.START_TO_START, nodeEndRange) == -1 &&
22626 rangeEndRange.compareBoundaryPoints(
22627 Range.START_TO_START, nodeStartRange) == 1;
22631 rangeCompareNode : function(range, node)
22633 var nodeRange = node.ownerDocument.createRange();
22635 nodeRange.selectNode(node);
22637 nodeRange.selectNodeContents(node);
22641 range.collapse(true);
22643 nodeRange.collapse(true);
22645 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
22646 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
22648 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
22650 var nodeIsBefore = ss == 1;
22651 var nodeIsAfter = ee == -1;
22653 if (nodeIsBefore && nodeIsAfter) {
22656 if (!nodeIsBefore && nodeIsAfter) {
22657 return 1; //right trailed.
22660 if (nodeIsBefore && !nodeIsAfter) {
22661 return 2; // left trailed.
22667 // private? - in a new class?
22668 cleanUpPaste : function()
22670 // cleans up the whole document..
22671 Roo.log('cleanuppaste');
22673 this.cleanUpChildren(this.doc.body);
22674 var clean = this.cleanWordChars(this.doc.body.innerHTML);
22675 if (clean != this.doc.body.innerHTML) {
22676 this.doc.body.innerHTML = clean;
22681 cleanWordChars : function(input) {// change the chars to hex code
22682 var he = Roo.HtmlEditorCore;
22684 var output = input;
22685 Roo.each(he.swapCodes, function(sw) {
22686 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
22688 output = output.replace(swapper, sw[1]);
22695 cleanUpChildren : function (n)
22697 if (!n.childNodes.length) {
22700 for (var i = n.childNodes.length-1; i > -1 ; i--) {
22701 this.cleanUpChild(n.childNodes[i]);
22708 cleanUpChild : function (node)
22711 //console.log(node);
22712 if (node.nodeName == "#text") {
22713 // clean up silly Windows -- stuff?
22716 if (node.nodeName == "#comment") {
22717 node.parentNode.removeChild(node);
22718 // clean up silly Windows -- stuff?
22721 var lcname = node.tagName.toLowerCase();
22722 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
22723 // whitelist of tags..
22725 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
22727 node.parentNode.removeChild(node);
22732 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
22734 // remove <a name=....> as rendering on yahoo mailer is borked with this.
22735 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
22737 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
22738 // remove_keep_children = true;
22741 if (remove_keep_children) {
22742 this.cleanUpChildren(node);
22743 // inserts everything just before this node...
22744 while (node.childNodes.length) {
22745 var cn = node.childNodes[0];
22746 node.removeChild(cn);
22747 node.parentNode.insertBefore(cn, node);
22749 node.parentNode.removeChild(node);
22753 if (!node.attributes || !node.attributes.length) {
22754 this.cleanUpChildren(node);
22758 function cleanAttr(n,v)
22761 if (v.match(/^\./) || v.match(/^\//)) {
22764 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/) || v.match(/^ftp:/)) {
22767 if (v.match(/^#/)) {
22770 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
22771 node.removeAttribute(n);
22775 var cwhite = this.cwhite;
22776 var cblack = this.cblack;
22778 function cleanStyle(n,v)
22780 if (v.match(/expression/)) { //XSS?? should we even bother..
22781 node.removeAttribute(n);
22785 var parts = v.split(/;/);
22788 Roo.each(parts, function(p) {
22789 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
22793 var l = p.split(':').shift().replace(/\s+/g,'');
22794 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
22796 if ( cwhite.length && cblack.indexOf(l) > -1) {
22797 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22798 //node.removeAttribute(n);
22802 // only allow 'c whitelisted system attributes'
22803 if ( cwhite.length && cwhite.indexOf(l) < 0) {
22804 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22805 //node.removeAttribute(n);
22815 if (clean.length) {
22816 node.setAttribute(n, clean.join(';'));
22818 node.removeAttribute(n);
22824 for (var i = node.attributes.length-1; i > -1 ; i--) {
22825 var a = node.attributes[i];
22828 if (a.name.toLowerCase().substr(0,2)=='on') {
22829 node.removeAttribute(a.name);
22832 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
22833 node.removeAttribute(a.name);
22836 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
22837 cleanAttr(a.name,a.value); // fixme..
22840 if (a.name == 'style') {
22841 cleanStyle(a.name,a.value);
22844 /// clean up MS crap..
22845 // tecnically this should be a list of valid class'es..
22848 if (a.name == 'class') {
22849 if (a.value.match(/^Mso/)) {
22850 node.className = '';
22853 if (a.value.match(/^body$/)) {
22854 node.className = '';
22865 this.cleanUpChildren(node);
22871 * Clean up MS wordisms...
22873 cleanWord : function(node)
22878 this.cleanWord(this.doc.body);
22881 if (node.nodeName == "#text") {
22882 // clean up silly Windows -- stuff?
22885 if (node.nodeName == "#comment") {
22886 node.parentNode.removeChild(node);
22887 // clean up silly Windows -- stuff?
22891 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
22892 node.parentNode.removeChild(node);
22896 // remove - but keep children..
22897 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|font)/)) {
22898 while (node.childNodes.length) {
22899 var cn = node.childNodes[0];
22900 node.removeChild(cn);
22901 node.parentNode.insertBefore(cn, node);
22903 node.parentNode.removeChild(node);
22904 this.iterateChildren(node, this.cleanWord);
22908 if (node.className.length) {
22910 var cn = node.className.split(/\W+/);
22912 Roo.each(cn, function(cls) {
22913 if (cls.match(/Mso[a-zA-Z]+/)) {
22918 node.className = cna.length ? cna.join(' ') : '';
22920 node.removeAttribute("class");
22924 if (node.hasAttribute("lang")) {
22925 node.removeAttribute("lang");
22928 if (node.hasAttribute("style")) {
22930 var styles = node.getAttribute("style").split(";");
22932 Roo.each(styles, function(s) {
22933 if (!s.match(/:/)) {
22936 var kv = s.split(":");
22937 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
22940 // what ever is left... we allow.
22943 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
22944 if (!nstyle.length) {
22945 node.removeAttribute('style');
22948 this.iterateChildren(node, this.cleanWord);
22954 * iterateChildren of a Node, calling fn each time, using this as the scole..
22955 * @param {DomNode} node node to iterate children of.
22956 * @param {Function} fn method of this class to call on each item.
22958 iterateChildren : function(node, fn)
22960 if (!node.childNodes.length) {
22963 for (var i = node.childNodes.length-1; i > -1 ; i--) {
22964 fn.call(this, node.childNodes[i])
22970 * cleanTableWidths.
22972 * Quite often pasting from word etc.. results in tables with column and widths.
22973 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
22976 cleanTableWidths : function(node)
22981 this.cleanTableWidths(this.doc.body);
22986 if (node.nodeName == "#text" || node.nodeName == "#comment") {
22989 Roo.log(node.tagName);
22990 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
22991 this.iterateChildren(node, this.cleanTableWidths);
22994 if (node.hasAttribute('width')) {
22995 node.removeAttribute('width');
22999 if (node.hasAttribute("style")) {
23002 var styles = node.getAttribute("style").split(";");
23004 Roo.each(styles, function(s) {
23005 if (!s.match(/:/)) {
23008 var kv = s.split(":");
23009 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
23012 // what ever is left... we allow.
23015 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
23016 if (!nstyle.length) {
23017 node.removeAttribute('style');
23021 this.iterateChildren(node, this.cleanTableWidths);
23029 domToHTML : function(currentElement, depth, nopadtext) {
23031 depth = depth || 0;
23032 nopadtext = nopadtext || false;
23034 if (!currentElement) {
23035 return this.domToHTML(this.doc.body);
23038 //Roo.log(currentElement);
23040 var allText = false;
23041 var nodeName = currentElement.nodeName;
23042 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
23044 if (nodeName == '#text') {
23046 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
23051 if (nodeName != 'BODY') {
23054 // Prints the node tagName, such as <A>, <IMG>, etc
23057 for(i = 0; i < currentElement.attributes.length;i++) {
23059 var aname = currentElement.attributes.item(i).name;
23060 if (!currentElement.attributes.item(i).value.length) {
23063 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
23066 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
23075 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
23078 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
23083 // Traverse the tree
23085 var currentElementChild = currentElement.childNodes.item(i);
23086 var allText = true;
23087 var innerHTML = '';
23089 while (currentElementChild) {
23090 // Formatting code (indent the tree so it looks nice on the screen)
23091 var nopad = nopadtext;
23092 if (lastnode == 'SPAN') {
23096 if (currentElementChild.nodeName == '#text') {
23097 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
23098 toadd = nopadtext ? toadd : toadd.trim();
23099 if (!nopad && toadd.length > 80) {
23100 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
23102 innerHTML += toadd;
23105 currentElementChild = currentElement.childNodes.item(i);
23111 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
23113 // Recursively traverse the tree structure of the child node
23114 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
23115 lastnode = currentElementChild.nodeName;
23117 currentElementChild=currentElement.childNodes.item(i);
23123 // The remaining code is mostly for formatting the tree
23124 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
23129 ret+= "</"+tagName+">";
23135 applyBlacklists : function()
23137 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
23138 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
23142 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
23143 if (b.indexOf(tag) > -1) {
23146 this.white.push(tag);
23150 Roo.each(w, function(tag) {
23151 if (b.indexOf(tag) > -1) {
23154 if (this.white.indexOf(tag) > -1) {
23157 this.white.push(tag);
23162 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
23163 if (w.indexOf(tag) > -1) {
23166 this.black.push(tag);
23170 Roo.each(b, function(tag) {
23171 if (w.indexOf(tag) > -1) {
23174 if (this.black.indexOf(tag) > -1) {
23177 this.black.push(tag);
23182 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
23183 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
23187 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
23188 if (b.indexOf(tag) > -1) {
23191 this.cwhite.push(tag);
23195 Roo.each(w, function(tag) {
23196 if (b.indexOf(tag) > -1) {
23199 if (this.cwhite.indexOf(tag) > -1) {
23202 this.cwhite.push(tag);
23207 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
23208 if (w.indexOf(tag) > -1) {
23211 this.cblack.push(tag);
23215 Roo.each(b, function(tag) {
23216 if (w.indexOf(tag) > -1) {
23219 if (this.cblack.indexOf(tag) > -1) {
23222 this.cblack.push(tag);
23227 setStylesheets : function(stylesheets)
23229 if(typeof(stylesheets) == 'string'){
23230 Roo.get(this.iframe.contentDocument.head).createChild({
23232 rel : 'stylesheet',
23241 Roo.each(stylesheets, function(s) {
23246 Roo.get(_this.iframe.contentDocument.head).createChild({
23248 rel : 'stylesheet',
23257 removeStylesheets : function()
23261 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
23266 setStyle : function(style)
23268 Roo.get(this.iframe.contentDocument.head).createChild({
23277 // hide stuff that is not compatible
23291 * @event specialkey
23295 * @cfg {String} fieldClass @hide
23298 * @cfg {String} focusClass @hide
23301 * @cfg {String} autoCreate @hide
23304 * @cfg {String} inputType @hide
23307 * @cfg {String} invalidClass @hide
23310 * @cfg {String} invalidText @hide
23313 * @cfg {String} msgFx @hide
23316 * @cfg {String} validateOnBlur @hide
23320 Roo.HtmlEditorCore.white = [
23321 'area', 'br', 'img', 'input', 'hr', 'wbr',
23323 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
23324 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
23325 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
23326 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
23327 'table', 'ul', 'xmp',
23329 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
23332 'dir', 'menu', 'ol', 'ul', 'dl',
23338 Roo.HtmlEditorCore.black = [
23339 // 'embed', 'object', // enable - backend responsiblity to clean thiese
23341 'base', 'basefont', 'bgsound', 'blink', 'body',
23342 'frame', 'frameset', 'head', 'html', 'ilayer',
23343 'iframe', 'layer', 'link', 'meta', 'object',
23344 'script', 'style' ,'title', 'xml' // clean later..
23346 Roo.HtmlEditorCore.clean = [
23347 'script', 'style', 'title', 'xml'
23349 Roo.HtmlEditorCore.remove = [
23354 Roo.HtmlEditorCore.ablack = [
23358 Roo.HtmlEditorCore.aclean = [
23359 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
23363 Roo.HtmlEditorCore.pwhite= [
23364 'http', 'https', 'mailto'
23367 // white listed style attributes.
23368 Roo.HtmlEditorCore.cwhite= [
23369 // 'text-align', /// default is to allow most things..
23375 // black listed style attributes.
23376 Roo.HtmlEditorCore.cblack= [
23377 // 'font-size' -- this can be set by the project
23381 Roo.HtmlEditorCore.swapCodes =[
23400 * @class Roo.bootstrap.HtmlEditor
23401 * @extends Roo.bootstrap.TextArea
23402 * Bootstrap HtmlEditor class
23405 * Create a new HtmlEditor
23406 * @param {Object} config The config object
23409 Roo.bootstrap.HtmlEditor = function(config){
23410 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
23411 if (!this.toolbars) {
23412 this.toolbars = [];
23415 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
23418 * @event initialize
23419 * Fires when the editor is fully initialized (including the iframe)
23420 * @param {HtmlEditor} this
23425 * Fires when the editor is first receives the focus. Any insertion must wait
23426 * until after this event.
23427 * @param {HtmlEditor} this
23431 * @event beforesync
23432 * Fires before the textarea is updated with content from the editor iframe. Return false
23433 * to cancel the sync.
23434 * @param {HtmlEditor} this
23435 * @param {String} html
23439 * @event beforepush
23440 * Fires before the iframe editor is updated with content from the textarea. Return false
23441 * to cancel the push.
23442 * @param {HtmlEditor} this
23443 * @param {String} html
23448 * Fires when the textarea is updated with content from the editor iframe.
23449 * @param {HtmlEditor} this
23450 * @param {String} html
23455 * Fires when the iframe editor is updated with content from the textarea.
23456 * @param {HtmlEditor} this
23457 * @param {String} html
23461 * @event editmodechange
23462 * Fires when the editor switches edit modes
23463 * @param {HtmlEditor} this
23464 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
23466 editmodechange: true,
23468 * @event editorevent
23469 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
23470 * @param {HtmlEditor} this
23474 * @event firstfocus
23475 * Fires when on first focus - needed by toolbars..
23476 * @param {HtmlEditor} this
23481 * Auto save the htmlEditor value as a file into Events
23482 * @param {HtmlEditor} this
23486 * @event savedpreview
23487 * preview the saved version of htmlEditor
23488 * @param {HtmlEditor} this
23495 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
23499 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
23504 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
23509 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
23514 * @cfg {Number} height (in pixels)
23518 * @cfg {Number} width (in pixels)
23523 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
23526 stylesheets: false,
23531 // private properties
23532 validationEvent : false,
23534 initialized : false,
23537 onFocus : Roo.emptyFn,
23539 hideMode:'offsets',
23541 tbContainer : false,
23545 toolbarContainer :function() {
23546 return this.wrap.select('.x-html-editor-tb',true).first();
23550 * Protected method that will not generally be called directly. It
23551 * is called when the editor creates its toolbar. Override this method if you need to
23552 * add custom toolbar buttons.
23553 * @param {HtmlEditor} editor
23555 createToolbar : function(){
23556 Roo.log('renewing');
23557 Roo.log("create toolbars");
23559 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
23560 this.toolbars[0].render(this.toolbarContainer());
23564 // if (!editor.toolbars || !editor.toolbars.length) {
23565 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
23568 // for (var i =0 ; i < editor.toolbars.length;i++) {
23569 // editor.toolbars[i] = Roo.factory(
23570 // typeof(editor.toolbars[i]) == 'string' ?
23571 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
23572 // Roo.bootstrap.HtmlEditor);
23573 // editor.toolbars[i].init(editor);
23579 onRender : function(ct, position)
23581 // Roo.log("Call onRender: " + this.xtype);
23583 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
23585 this.wrap = this.inputEl().wrap({
23586 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
23589 this.editorcore.onRender(ct, position);
23591 if (this.resizable) {
23592 this.resizeEl = new Roo.Resizable(this.wrap, {
23596 minHeight : this.height,
23597 height: this.height,
23598 handles : this.resizable,
23601 resize : function(r, w, h) {
23602 _t.onResize(w,h); // -something
23608 this.createToolbar(this);
23611 if(!this.width && this.resizable){
23612 this.setSize(this.wrap.getSize());
23614 if (this.resizeEl) {
23615 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
23616 // should trigger onReize..
23622 onResize : function(w, h)
23624 Roo.log('resize: ' +w + ',' + h );
23625 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
23629 if(this.inputEl() ){
23630 if(typeof w == 'number'){
23631 var aw = w - this.wrap.getFrameWidth('lr');
23632 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
23635 if(typeof h == 'number'){
23636 var tbh = -11; // fixme it needs to tool bar size!
23637 for (var i =0; i < this.toolbars.length;i++) {
23638 // fixme - ask toolbars for heights?
23639 tbh += this.toolbars[i].el.getHeight();
23640 //if (this.toolbars[i].footer) {
23641 // tbh += this.toolbars[i].footer.el.getHeight();
23649 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
23650 ah -= 5; // knock a few pixes off for look..
23651 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
23655 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
23656 this.editorcore.onResize(ew,eh);
23661 * Toggles the editor between standard and source edit mode.
23662 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
23664 toggleSourceEdit : function(sourceEditMode)
23666 this.editorcore.toggleSourceEdit(sourceEditMode);
23668 if(this.editorcore.sourceEditMode){
23669 Roo.log('editor - showing textarea');
23672 // Roo.log(this.syncValue());
23674 this.inputEl().removeClass(['hide', 'x-hidden']);
23675 this.inputEl().dom.removeAttribute('tabIndex');
23676 this.inputEl().focus();
23678 Roo.log('editor - hiding textarea');
23680 // Roo.log(this.pushValue());
23683 this.inputEl().addClass(['hide', 'x-hidden']);
23684 this.inputEl().dom.setAttribute('tabIndex', -1);
23685 //this.deferFocus();
23688 if(this.resizable){
23689 this.setSize(this.wrap.getSize());
23692 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
23695 // private (for BoxComponent)
23696 adjustSize : Roo.BoxComponent.prototype.adjustSize,
23698 // private (for BoxComponent)
23699 getResizeEl : function(){
23703 // private (for BoxComponent)
23704 getPositionEl : function(){
23709 initEvents : function(){
23710 this.originalValue = this.getValue();
23714 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23717 // markInvalid : Roo.emptyFn,
23719 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23722 // clearInvalid : Roo.emptyFn,
23724 setValue : function(v){
23725 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
23726 this.editorcore.pushValue();
23731 deferFocus : function(){
23732 this.focus.defer(10, this);
23736 focus : function(){
23737 this.editorcore.focus();
23743 onDestroy : function(){
23749 for (var i =0; i < this.toolbars.length;i++) {
23750 // fixme - ask toolbars for heights?
23751 this.toolbars[i].onDestroy();
23754 this.wrap.dom.innerHTML = '';
23755 this.wrap.remove();
23760 onFirstFocus : function(){
23761 //Roo.log("onFirstFocus");
23762 this.editorcore.onFirstFocus();
23763 for (var i =0; i < this.toolbars.length;i++) {
23764 this.toolbars[i].onFirstFocus();
23770 syncValue : function()
23772 this.editorcore.syncValue();
23775 pushValue : function()
23777 this.editorcore.pushValue();
23781 // hide stuff that is not compatible
23795 * @event specialkey
23799 * @cfg {String} fieldClass @hide
23802 * @cfg {String} focusClass @hide
23805 * @cfg {String} autoCreate @hide
23808 * @cfg {String} inputType @hide
23811 * @cfg {String} invalidClass @hide
23814 * @cfg {String} invalidText @hide
23817 * @cfg {String} msgFx @hide
23820 * @cfg {String} validateOnBlur @hide
23829 Roo.namespace('Roo.bootstrap.htmleditor');
23831 * @class Roo.bootstrap.HtmlEditorToolbar1
23836 new Roo.bootstrap.HtmlEditor({
23839 new Roo.bootstrap.HtmlEditorToolbar1({
23840 disable : { fonts: 1 , format: 1, ..., ... , ...],
23846 * @cfg {Object} disable List of elements to disable..
23847 * @cfg {Array} btns List of additional buttons.
23851 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
23854 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
23857 Roo.apply(this, config);
23859 // default disabled, based on 'good practice'..
23860 this.disable = this.disable || {};
23861 Roo.applyIf(this.disable, {
23864 specialElements : true
23866 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
23868 this.editor = config.editor;
23869 this.editorcore = config.editor.editorcore;
23871 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
23873 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
23874 // dont call parent... till later.
23876 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
23881 editorcore : false,
23886 "h1","h2","h3","h4","h5","h6",
23888 "abbr", "acronym", "address", "cite", "samp", "var",
23892 onRender : function(ct, position)
23894 // Roo.log("Call onRender: " + this.xtype);
23896 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
23898 this.el.dom.style.marginBottom = '0';
23900 var editorcore = this.editorcore;
23901 var editor= this.editor;
23904 var btn = function(id,cmd , toggle, handler, html){
23906 var event = toggle ? 'toggle' : 'click';
23911 xns: Roo.bootstrap,
23914 enableToggle:toggle !== false,
23916 pressed : toggle ? false : null,
23919 a.listeners[toggle ? 'toggle' : 'click'] = function() {
23920 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
23926 // var cb_box = function...
23931 xns: Roo.bootstrap,
23932 glyphicon : 'font',
23936 xns: Roo.bootstrap,
23940 Roo.each(this.formats, function(f) {
23941 style.menu.items.push({
23943 xns: Roo.bootstrap,
23944 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
23949 editorcore.insertTag(this.tagname);
23956 children.push(style);
23958 btn('bold',false,true);
23959 btn('italic',false,true);
23960 btn('align-left', 'justifyleft',true);
23961 btn('align-center', 'justifycenter',true);
23962 btn('align-right' , 'justifyright',true);
23963 btn('link', false, false, function(btn) {
23964 //Roo.log("create link?");
23965 var url = prompt(this.createLinkText, this.defaultLinkValue);
23966 if(url && url != 'http:/'+'/'){
23967 this.editorcore.relayCmd('createlink', url);
23970 btn('list','insertunorderedlist',true);
23971 btn('pencil', false,true, function(btn){
23973 this.toggleSourceEdit(btn.pressed);
23976 if (this.editor.btns.length > 0) {
23977 for (var i = 0; i<this.editor.btns.length; i++) {
23978 children.push(this.editor.btns[i]);
23986 xns: Roo.bootstrap,
23991 xns: Roo.bootstrap,
23996 cog.menu.items.push({
23998 xns: Roo.bootstrap,
23999 html : Clean styles,
24004 editorcore.insertTag(this.tagname);
24013 this.xtype = 'NavSimplebar';
24015 for(var i=0;i< children.length;i++) {
24017 this.buttons.add(this.addxtypeChild(children[i]));
24021 editor.on('editorevent', this.updateToolbar, this);
24023 onBtnClick : function(id)
24025 this.editorcore.relayCmd(id);
24026 this.editorcore.focus();
24030 * Protected method that will not generally be called directly. It triggers
24031 * a toolbar update by reading the markup state of the current selection in the editor.
24033 updateToolbar: function(){
24035 if(!this.editorcore.activated){
24036 this.editor.onFirstFocus(); // is this neeed?
24040 var btns = this.buttons;
24041 var doc = this.editorcore.doc;
24042 btns.get('bold').setActive(doc.queryCommandState('bold'));
24043 btns.get('italic').setActive(doc.queryCommandState('italic'));
24044 //btns.get('underline').setActive(doc.queryCommandState('underline'));
24046 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
24047 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
24048 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
24050 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
24051 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
24054 var ans = this.editorcore.getAllAncestors();
24055 if (this.formatCombo) {
24058 var store = this.formatCombo.store;
24059 this.formatCombo.setValue("");
24060 for (var i =0; i < ans.length;i++) {
24061 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
24063 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
24071 // hides menus... - so this cant be on a menu...
24072 Roo.bootstrap.MenuMgr.hideAll();
24074 Roo.bootstrap.MenuMgr.hideAll();
24075 //this.editorsyncValue();
24077 onFirstFocus: function() {
24078 this.buttons.each(function(item){
24082 toggleSourceEdit : function(sourceEditMode){
24085 if(sourceEditMode){
24086 Roo.log("disabling buttons");
24087 this.buttons.each( function(item){
24088 if(item.cmd != 'pencil'){
24094 Roo.log("enabling buttons");
24095 if(this.editorcore.initialized){
24096 this.buttons.each( function(item){
24102 Roo.log("calling toggole on editor");
24103 // tell the editor that it's been pressed..
24104 this.editor.toggleSourceEdit(sourceEditMode);
24114 * @class Roo.bootstrap.Table.AbstractSelectionModel
24115 * @extends Roo.util.Observable
24116 * Abstract base class for grid SelectionModels. It provides the interface that should be
24117 * implemented by descendant classes. This class should not be directly instantiated.
24120 Roo.bootstrap.Table.AbstractSelectionModel = function(){
24121 this.locked = false;
24122 Roo.bootstrap.Table.AbstractSelectionModel.superclass.constructor.call(this);
24126 Roo.extend(Roo.bootstrap.Table.AbstractSelectionModel, Roo.util.Observable, {
24127 /** @ignore Called by the grid automatically. Do not call directly. */
24128 init : function(grid){
24134 * Locks the selections.
24137 this.locked = true;
24141 * Unlocks the selections.
24143 unlock : function(){
24144 this.locked = false;
24148 * Returns true if the selections are locked.
24149 * @return {Boolean}
24151 isLocked : function(){
24152 return this.locked;
24156 * @extends Roo.bootstrap.Table.AbstractSelectionModel
24157 * @class Roo.bootstrap.Table.RowSelectionModel
24158 * The default SelectionModel used by {@link Roo.bootstrap.Table}.
24159 * It supports multiple selections and keyboard selection/navigation.
24161 * @param {Object} config
24164 Roo.bootstrap.Table.RowSelectionModel = function(config){
24165 Roo.apply(this, config);
24166 this.selections = new Roo.util.MixedCollection(false, function(o){
24171 this.lastActive = false;
24175 * @event selectionchange
24176 * Fires when the selection changes
24177 * @param {SelectionModel} this
24179 "selectionchange" : true,
24181 * @event afterselectionchange
24182 * Fires after the selection changes (eg. by key press or clicking)
24183 * @param {SelectionModel} this
24185 "afterselectionchange" : true,
24187 * @event beforerowselect
24188 * Fires when a row is selected being selected, return false to cancel.
24189 * @param {SelectionModel} this
24190 * @param {Number} rowIndex The selected index
24191 * @param {Boolean} keepExisting False if other selections will be cleared
24193 "beforerowselect" : true,
24196 * Fires when a row is selected.
24197 * @param {SelectionModel} this
24198 * @param {Number} rowIndex The selected index
24199 * @param {Roo.data.Record} r The record
24201 "rowselect" : true,
24203 * @event rowdeselect
24204 * Fires when a row is deselected.
24205 * @param {SelectionModel} this
24206 * @param {Number} rowIndex The selected index
24208 "rowdeselect" : true
24210 Roo.bootstrap.Table.RowSelectionModel.superclass.constructor.call(this);
24211 this.locked = false;
24214 Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSelectionModel, {
24216 * @cfg {Boolean} singleSelect
24217 * True to allow selection of only one row at a time (defaults to false)
24219 singleSelect : false,
24222 initEvents : function()
24225 //if(!this.grid.enableDragDrop && !this.grid.enableDrag){
24226 // this.growclickrid.on("mousedown", this.handleMouseDown, this);
24227 //}else{ // allow click to work like normal
24228 // this.grid.on("rowclick", this.handleDragableRowClick, this);
24230 //this.grid.on("rowdblclick", this.handleMouseDBClick, this);
24231 this.grid.on("rowclick", this.handleMouseDown, this);
24233 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
24234 "up" : function(e){
24236 this.selectPrevious(e.shiftKey);
24237 }else if(this.last !== false && this.lastActive !== false){
24238 var last = this.last;
24239 this.selectRange(this.last, this.lastActive-1);
24240 this.grid.getView().focusRow(this.lastActive);
24241 if(last !== false){
24245 this.selectFirstRow();
24247 this.fireEvent("afterselectionchange", this);
24249 "down" : function(e){
24251 this.selectNext(e.shiftKey);
24252 }else if(this.last !== false && this.lastActive !== false){
24253 var last = this.last;
24254 this.selectRange(this.last, this.lastActive+1);
24255 this.grid.getView().focusRow(this.lastActive);
24256 if(last !== false){
24260 this.selectFirstRow();
24262 this.fireEvent("afterselectionchange", this);
24266 this.grid.store.on('load', function(){
24267 this.selections.clear();
24270 var view = this.grid.view;
24271 view.on("refresh", this.onRefresh, this);
24272 view.on("rowupdated", this.onRowUpdated, this);
24273 view.on("rowremoved", this.onRemove, this);
24278 onRefresh : function()
24280 var ds = this.grid.store, i, v = this.grid.view;
24281 var s = this.selections;
24282 s.each(function(r){
24283 if((i = ds.indexOfId(r.id)) != -1){
24292 onRemove : function(v, index, r){
24293 this.selections.remove(r);
24297 onRowUpdated : function(v, index, r){
24298 if(this.isSelected(r)){
24299 v.onRowSelect(index);
24305 * @param {Array} records The records to select
24306 * @param {Boolean} keepExisting (optional) True to keep existing selections
24308 selectRecords : function(records, keepExisting)
24311 this.clearSelections();
24313 var ds = this.grid.store;
24314 for(var i = 0, len = records.length; i < len; i++){
24315 this.selectRow(ds.indexOf(records[i]), true);
24320 * Gets the number of selected rows.
24323 getCount : function(){
24324 return this.selections.length;
24328 * Selects the first row in the grid.
24330 selectFirstRow : function(){
24335 * Select the last row.
24336 * @param {Boolean} keepExisting (optional) True to keep existing selections
24338 selectLastRow : function(keepExisting){
24339 //this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
24340 this.selectRow(this.grid.store.getCount() - 1, keepExisting);
24344 * Selects the row immediately following the last selected row.
24345 * @param {Boolean} keepExisting (optional) True to keep existing selections
24347 selectNext : function(keepExisting)
24349 if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
24350 this.selectRow(this.last+1, keepExisting);
24351 this.grid.getView().focusRow(this.last);
24356 * Selects the row that precedes the last selected row.
24357 * @param {Boolean} keepExisting (optional) True to keep existing selections
24359 selectPrevious : function(keepExisting){
24361 this.selectRow(this.last-1, keepExisting);
24362 this.grid.getView().focusRow(this.last);
24367 * Returns the selected records
24368 * @return {Array} Array of selected records
24370 getSelections : function(){
24371 return [].concat(this.selections.items);
24375 * Returns the first selected record.
24378 getSelected : function(){
24379 return this.selections.itemAt(0);
24384 * Clears all selections.
24386 clearSelections : function(fast)
24392 var ds = this.grid.store;
24393 var s = this.selections;
24394 s.each(function(r){
24395 this.deselectRow(ds.indexOfId(r.id));
24399 this.selections.clear();
24406 * Selects all rows.
24408 selectAll : function(){
24412 this.selections.clear();
24413 for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
24414 this.selectRow(i, true);
24419 * Returns True if there is a selection.
24420 * @return {Boolean}
24422 hasSelection : function(){
24423 return this.selections.length > 0;
24427 * Returns True if the specified row is selected.
24428 * @param {Number/Record} record The record or index of the record to check
24429 * @return {Boolean}
24431 isSelected : function(index){
24432 var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
24433 return (r && this.selections.key(r.id) ? true : false);
24437 * Returns True if the specified record id is selected.
24438 * @param {String} id The id of record to check
24439 * @return {Boolean}
24441 isIdSelected : function(id){
24442 return (this.selections.key(id) ? true : false);
24447 handleMouseDBClick : function(e, t){
24451 handleMouseDown : function(e, t)
24453 var rowIndex = this.grid.headerShow ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
24454 if(this.isLocked() || rowIndex < 0 ){
24457 if(e.shiftKey && this.last !== false){
24458 var last = this.last;
24459 this.selectRange(last, rowIndex, e.ctrlKey);
24460 this.last = last; // reset the last
24464 var isSelected = this.isSelected(rowIndex);
24465 //Roo.log("select row:" + rowIndex);
24467 this.deselectRow(rowIndex);
24469 this.selectRow(rowIndex, true);
24473 if(e.button !== 0 && isSelected){
24474 alert('rowIndex 2: ' + rowIndex);
24475 view.focusRow(rowIndex);
24476 }else if(e.ctrlKey && isSelected){
24477 this.deselectRow(rowIndex);
24478 }else if(!isSelected){
24479 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
24480 view.focusRow(rowIndex);
24484 this.fireEvent("afterselectionchange", this);
24487 handleDragableRowClick : function(grid, rowIndex, e)
24489 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
24490 this.selectRow(rowIndex, false);
24491 grid.view.focusRow(rowIndex);
24492 this.fireEvent("afterselectionchange", this);
24497 * Selects multiple rows.
24498 * @param {Array} rows Array of the indexes of the row to select
24499 * @param {Boolean} keepExisting (optional) True to keep existing selections
24501 selectRows : function(rows, keepExisting){
24503 this.clearSelections();
24505 for(var i = 0, len = rows.length; i < len; i++){
24506 this.selectRow(rows[i], true);
24511 * Selects a range of rows. All rows in between startRow and endRow are also selected.
24512 * @param {Number} startRow The index of the first row in the range
24513 * @param {Number} endRow The index of the last row in the range
24514 * @param {Boolean} keepExisting (optional) True to retain existing selections
24516 selectRange : function(startRow, endRow, keepExisting){
24521 this.clearSelections();
24523 if(startRow <= endRow){
24524 for(var i = startRow; i <= endRow; i++){
24525 this.selectRow(i, true);
24528 for(var i = startRow; i >= endRow; i--){
24529 this.selectRow(i, true);
24535 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
24536 * @param {Number} startRow The index of the first row in the range
24537 * @param {Number} endRow The index of the last row in the range
24539 deselectRange : function(startRow, endRow, preventViewNotify){
24543 for(var i = startRow; i <= endRow; i++){
24544 this.deselectRow(i, preventViewNotify);
24550 * @param {Number} row The index of the row to select
24551 * @param {Boolean} keepExisting (optional) True to keep existing selections
24553 selectRow : function(index, keepExisting, preventViewNotify)
24555 if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
24558 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
24559 if(!keepExisting || this.singleSelect){
24560 this.clearSelections();
24563 var r = this.grid.store.getAt(index);
24564 //console.log('selectRow - record id :' + r.id);
24566 this.selections.add(r);
24567 this.last = this.lastActive = index;
24568 if(!preventViewNotify){
24569 var proxy = new Roo.Element(
24570 this.grid.getRowDom(index)
24572 proxy.addClass('bg-info info');
24574 this.fireEvent("rowselect", this, index, r);
24575 this.fireEvent("selectionchange", this);
24581 * @param {Number} row The index of the row to deselect
24583 deselectRow : function(index, preventViewNotify)
24588 if(this.last == index){
24591 if(this.lastActive == index){
24592 this.lastActive = false;
24595 var r = this.grid.store.getAt(index);
24600 this.selections.remove(r);
24601 //.console.log('deselectRow - record id :' + r.id);
24602 if(!preventViewNotify){
24604 var proxy = new Roo.Element(
24605 this.grid.getRowDom(index)
24607 proxy.removeClass('bg-info info');
24609 this.fireEvent("rowdeselect", this, index);
24610 this.fireEvent("selectionchange", this);
24614 restoreLast : function(){
24616 this.last = this._last;
24621 acceptsNav : function(row, col, cm){
24622 return !cm.isHidden(col) && cm.isCellEditable(col, row);
24626 onEditorKey : function(field, e){
24627 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
24632 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
24634 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
24636 }else if(k == e.ENTER && !e.ctrlKey){
24640 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
24642 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
24644 }else if(k == e.ESC){
24648 g.startEditing(newCell[0], newCell[1]);
24654 * Ext JS Library 1.1.1
24655 * Copyright(c) 2006-2007, Ext JS, LLC.
24657 * Originally Released Under LGPL - original licence link has changed is not relivant.
24660 * <script type="text/javascript">
24664 * @class Roo.bootstrap.PagingToolbar
24665 * @extends Roo.bootstrap.NavSimplebar
24666 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
24668 * Create a new PagingToolbar
24669 * @param {Object} config The config object
24670 * @param {Roo.data.Store} store
24672 Roo.bootstrap.PagingToolbar = function(config)
24674 // old args format still supported... - xtype is prefered..
24675 // created from xtype...
24677 this.ds = config.dataSource;
24679 if (config.store && !this.ds) {
24680 this.store= Roo.factory(config.store, Roo.data);
24681 this.ds = this.store;
24682 this.ds.xmodule = this.xmodule || false;
24685 this.toolbarItems = [];
24686 if (config.items) {
24687 this.toolbarItems = config.items;
24690 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
24695 this.bind(this.ds);
24698 if (Roo.bootstrap.version == 4) {
24699 this.navgroup = new Roo.bootstrap.ButtonGroup({ cls: 'pagination' });
24701 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
24706 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
24708 * @cfg {Roo.data.Store} dataSource
24709 * The underlying data store providing the paged data
24712 * @cfg {String/HTMLElement/Element} container
24713 * container The id or element that will contain the toolbar
24716 * @cfg {Boolean} displayInfo
24717 * True to display the displayMsg (defaults to false)
24720 * @cfg {Number} pageSize
24721 * The number of records to display per page (defaults to 20)
24725 * @cfg {String} displayMsg
24726 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
24728 displayMsg : 'Displaying {0} - {1} of {2}',
24730 * @cfg {String} emptyMsg
24731 * The message to display when no records are found (defaults to "No data to display")
24733 emptyMsg : 'No data to display',
24735 * Customizable piece of the default paging text (defaults to "Page")
24738 beforePageText : "Page",
24740 * Customizable piece of the default paging text (defaults to "of %0")
24743 afterPageText : "of {0}",
24745 * Customizable piece of the default paging text (defaults to "First Page")
24748 firstText : "First Page",
24750 * Customizable piece of the default paging text (defaults to "Previous Page")
24753 prevText : "Previous Page",
24755 * Customizable piece of the default paging text (defaults to "Next Page")
24758 nextText : "Next Page",
24760 * Customizable piece of the default paging text (defaults to "Last Page")
24763 lastText : "Last Page",
24765 * Customizable piece of the default paging text (defaults to "Refresh")
24768 refreshText : "Refresh",
24772 onRender : function(ct, position)
24774 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
24775 this.navgroup.parentId = this.id;
24776 this.navgroup.onRender(this.el, null);
24777 // add the buttons to the navgroup
24779 if(this.displayInfo){
24780 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
24781 this.displayEl = this.el.select('.x-paging-info', true).first();
24782 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
24783 // this.displayEl = navel.el.select('span',true).first();
24789 Roo.each(_this.buttons, function(e){ // this might need to use render????
24790 Roo.factory(e).render(_this.el);
24794 Roo.each(_this.toolbarItems, function(e) {
24795 _this.navgroup.addItem(e);
24799 this.first = this.navgroup.addItem({
24800 tooltip: this.firstText,
24801 cls: "prev btn-outline-secondary",
24802 html : ' <i class="fa fa-step-backward"></i>',
24804 preventDefault: true,
24805 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
24808 this.prev = this.navgroup.addItem({
24809 tooltip: this.prevText,
24810 cls: "prev btn-outline-secondary",
24811 html : ' <i class="fa fa-backward"></i>',
24813 preventDefault: true,
24814 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
24816 //this.addSeparator();
24819 var field = this.navgroup.addItem( {
24821 cls : 'x-paging-position btn-outline-secondary',
24823 html : this.beforePageText +
24824 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
24825 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
24828 this.field = field.el.select('input', true).first();
24829 this.field.on("keydown", this.onPagingKeydown, this);
24830 this.field.on("focus", function(){this.dom.select();});
24833 this.afterTextEl = field.el.select('.x-paging-after',true).first();
24834 //this.field.setHeight(18);
24835 //this.addSeparator();
24836 this.next = this.navgroup.addItem({
24837 tooltip: this.nextText,
24838 cls: "next btn-outline-secondary",
24839 html : ' <i class="fa fa-forward"></i>',
24841 preventDefault: true,
24842 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
24844 this.last = this.navgroup.addItem({
24845 tooltip: this.lastText,
24846 html : ' <i class="fa fa-step-forward"></i>',
24847 cls: "next btn-outline-secondary",
24849 preventDefault: true,
24850 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
24852 //this.addSeparator();
24853 this.loading = this.navgroup.addItem({
24854 tooltip: this.refreshText,
24855 cls: "btn-outline-secondary",
24856 html : ' <i class="fa fa-refresh"></i>',
24857 preventDefault: true,
24858 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
24864 updateInfo : function(){
24865 if(this.displayEl){
24866 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
24867 var msg = count == 0 ?
24871 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
24873 this.displayEl.update(msg);
24878 onLoad : function(ds, r, o)
24880 this.cursor = o.params.start ? o.params.start : 0;
24882 var d = this.getPageData(),
24887 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
24888 this.field.dom.value = ap;
24889 this.first.setDisabled(ap == 1);
24890 this.prev.setDisabled(ap == 1);
24891 this.next.setDisabled(ap == ps);
24892 this.last.setDisabled(ap == ps);
24893 this.loading.enable();
24898 getPageData : function(){
24899 var total = this.ds.getTotalCount();
24902 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
24903 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
24908 onLoadError : function(){
24909 this.loading.enable();
24913 onPagingKeydown : function(e){
24914 var k = e.getKey();
24915 var d = this.getPageData();
24917 var v = this.field.dom.value, pageNum;
24918 if(!v || isNaN(pageNum = parseInt(v, 10))){
24919 this.field.dom.value = d.activePage;
24922 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
24923 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
24926 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))
24928 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
24929 this.field.dom.value = pageNum;
24930 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
24933 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
24935 var v = this.field.dom.value, pageNum;
24936 var increment = (e.shiftKey) ? 10 : 1;
24937 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
24940 if(!v || isNaN(pageNum = parseInt(v, 10))) {
24941 this.field.dom.value = d.activePage;
24944 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
24946 this.field.dom.value = parseInt(v, 10) + increment;
24947 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
24948 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
24955 beforeLoad : function(){
24957 this.loading.disable();
24962 onClick : function(which){
24971 ds.load({params:{start: 0, limit: this.pageSize}});
24974 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
24977 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
24980 var total = ds.getTotalCount();
24981 var extra = total % this.pageSize;
24982 var lastStart = extra ? (total - extra) : total-this.pageSize;
24983 ds.load({params:{start: lastStart, limit: this.pageSize}});
24986 ds.load({params:{start: this.cursor, limit: this.pageSize}});
24992 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
24993 * @param {Roo.data.Store} store The data store to unbind
24995 unbind : function(ds){
24996 ds.un("beforeload", this.beforeLoad, this);
24997 ds.un("load", this.onLoad, this);
24998 ds.un("loadexception", this.onLoadError, this);
24999 ds.un("remove", this.updateInfo, this);
25000 ds.un("add", this.updateInfo, this);
25001 this.ds = undefined;
25005 * Binds the paging toolbar to the specified {@link Roo.data.Store}
25006 * @param {Roo.data.Store} store The data store to bind
25008 bind : function(ds){
25009 ds.on("beforeload", this.beforeLoad, this);
25010 ds.on("load", this.onLoad, this);
25011 ds.on("loadexception", this.onLoadError, this);
25012 ds.on("remove", this.updateInfo, this);
25013 ds.on("add", this.updateInfo, this);
25024 * @class Roo.bootstrap.MessageBar
25025 * @extends Roo.bootstrap.Component
25026 * Bootstrap MessageBar class
25027 * @cfg {String} html contents of the MessageBar
25028 * @cfg {String} weight (info | success | warning | danger) default info
25029 * @cfg {String} beforeClass insert the bar before the given class
25030 * @cfg {Boolean} closable (true | false) default false
25031 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
25034 * Create a new Element
25035 * @param {Object} config The config object
25038 Roo.bootstrap.MessageBar = function(config){
25039 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
25042 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
25048 beforeClass: 'bootstrap-sticky-wrap',
25050 getAutoCreate : function(){
25054 cls: 'alert alert-dismissable alert-' + this.weight,
25059 html: this.html || ''
25065 cfg.cls += ' alert-messages-fixed';
25079 onRender : function(ct, position)
25081 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
25084 var cfg = Roo.apply({}, this.getAutoCreate());
25088 cfg.cls += ' ' + this.cls;
25091 cfg.style = this.style;
25093 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
25095 this.el.setVisibilityMode(Roo.Element.DISPLAY);
25098 this.el.select('>button.close').on('click', this.hide, this);
25104 if (!this.rendered) {
25110 this.fireEvent('show', this);
25116 if (!this.rendered) {
25122 this.fireEvent('hide', this);
25125 update : function()
25127 // var e = this.el.dom.firstChild;
25129 // if(this.closable){
25130 // e = e.nextSibling;
25133 // e.data = this.html || '';
25135 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
25151 * @class Roo.bootstrap.Graph
25152 * @extends Roo.bootstrap.Component
25153 * Bootstrap Graph class
25157 @cfg {String} graphtype bar | vbar | pie
25158 @cfg {number} g_x coodinator | centre x (pie)
25159 @cfg {number} g_y coodinator | centre y (pie)
25160 @cfg {number} g_r radius (pie)
25161 @cfg {number} g_height height of the chart (respected by all elements in the set)
25162 @cfg {number} g_width width of the chart (respected by all elements in the set)
25163 @cfg {Object} title The title of the chart
25166 -opts (object) options for the chart
25168 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
25169 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
25171 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.
25172 o stacked (boolean) whether or not to tread values as in a stacked bar chart
25174 o stretch (boolean)
25176 -opts (object) options for the pie
25179 o startAngle (number)
25180 o endAngle (number)
25184 * Create a new Input
25185 * @param {Object} config The config object
25188 Roo.bootstrap.Graph = function(config){
25189 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
25195 * The img click event for the img.
25196 * @param {Roo.EventObject} e
25202 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
25213 //g_colors: this.colors,
25220 getAutoCreate : function(){
25231 onRender : function(ct,position){
25234 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
25236 if (typeof(Raphael) == 'undefined') {
25237 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
25241 this.raphael = Raphael(this.el.dom);
25243 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25244 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25245 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25246 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
25248 r.text(160, 10, "Single Series Chart").attr(txtattr);
25249 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
25250 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
25251 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
25253 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
25254 r.barchart(330, 10, 300, 220, data1);
25255 r.barchart(10, 250, 300, 220, data2, {stacked: true});
25256 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
25259 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25260 // r.barchart(30, 30, 560, 250, xdata, {
25261 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
25262 // axis : "0 0 1 1",
25263 // axisxlabels : xdata
25264 // //yvalues : cols,
25267 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25269 // this.load(null,xdata,{
25270 // axis : "0 0 1 1",
25271 // axisxlabels : xdata
25276 load : function(graphtype,xdata,opts)
25278 this.raphael.clear();
25280 graphtype = this.graphtype;
25285 var r = this.raphael,
25286 fin = function () {
25287 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
25289 fout = function () {
25290 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
25292 pfin = function() {
25293 this.sector.stop();
25294 this.sector.scale(1.1, 1.1, this.cx, this.cy);
25297 this.label[0].stop();
25298 this.label[0].attr({ r: 7.5 });
25299 this.label[1].attr({ "font-weight": 800 });
25302 pfout = function() {
25303 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
25306 this.label[0].animate({ r: 5 }, 500, "bounce");
25307 this.label[1].attr({ "font-weight": 400 });
25313 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25316 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25319 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
25320 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
25322 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
25329 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
25334 setTitle: function(o)
25339 initEvents: function() {
25342 this.el.on('click', this.onClick, this);
25346 onClick : function(e)
25348 Roo.log('img onclick');
25349 this.fireEvent('click', this, e);
25361 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25364 * @class Roo.bootstrap.dash.NumberBox
25365 * @extends Roo.bootstrap.Component
25366 * Bootstrap NumberBox class
25367 * @cfg {String} headline Box headline
25368 * @cfg {String} content Box content
25369 * @cfg {String} icon Box icon
25370 * @cfg {String} footer Footer text
25371 * @cfg {String} fhref Footer href
25374 * Create a new NumberBox
25375 * @param {Object} config The config object
25379 Roo.bootstrap.dash.NumberBox = function(config){
25380 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
25384 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
25393 getAutoCreate : function(){
25397 cls : 'small-box ',
25405 cls : 'roo-headline',
25406 html : this.headline
25410 cls : 'roo-content',
25411 html : this.content
25425 cls : 'ion ' + this.icon
25434 cls : 'small-box-footer',
25435 href : this.fhref || '#',
25439 cfg.cn.push(footer);
25446 onRender : function(ct,position){
25447 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
25454 setHeadline: function (value)
25456 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
25459 setFooter: function (value, href)
25461 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
25464 this.el.select('a.small-box-footer',true).first().attr('href', href);
25469 setContent: function (value)
25471 this.el.select('.roo-content',true).first().dom.innerHTML = value;
25474 initEvents: function()
25488 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25491 * @class Roo.bootstrap.dash.TabBox
25492 * @extends Roo.bootstrap.Component
25493 * Bootstrap TabBox class
25494 * @cfg {String} title Title of the TabBox
25495 * @cfg {String} icon Icon of the TabBox
25496 * @cfg {Boolean} showtabs (true|false) show the tabs default true
25497 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
25500 * Create a new TabBox
25501 * @param {Object} config The config object
25505 Roo.bootstrap.dash.TabBox = function(config){
25506 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
25511 * When a pane is added
25512 * @param {Roo.bootstrap.dash.TabPane} pane
25516 * @event activatepane
25517 * When a pane is activated
25518 * @param {Roo.bootstrap.dash.TabPane} pane
25520 "activatepane" : true
25528 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
25533 tabScrollable : false,
25535 getChildContainer : function()
25537 return this.el.select('.tab-content', true).first();
25540 getAutoCreate : function(){
25544 cls: 'pull-left header',
25552 cls: 'fa ' + this.icon
25558 cls: 'nav nav-tabs pull-right',
25564 if(this.tabScrollable){
25571 cls: 'nav nav-tabs pull-right',
25582 cls: 'nav-tabs-custom',
25587 cls: 'tab-content no-padding',
25595 initEvents : function()
25597 //Roo.log('add add pane handler');
25598 this.on('addpane', this.onAddPane, this);
25601 * Updates the box title
25602 * @param {String} html to set the title to.
25604 setTitle : function(value)
25606 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
25608 onAddPane : function(pane)
25610 this.panes.push(pane);
25611 //Roo.log('addpane');
25613 // tabs are rendere left to right..
25614 if(!this.showtabs){
25618 var ctr = this.el.select('.nav-tabs', true).first();
25621 var existing = ctr.select('.nav-tab',true);
25622 var qty = existing.getCount();;
25625 var tab = ctr.createChild({
25627 cls : 'nav-tab' + (qty ? '' : ' active'),
25635 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
25638 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
25640 pane.el.addClass('active');
25645 onTabClick : function(ev,un,ob,pane)
25647 //Roo.log('tab - prev default');
25648 ev.preventDefault();
25651 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
25652 pane.tab.addClass('active');
25653 //Roo.log(pane.title);
25654 this.getChildContainer().select('.tab-pane',true).removeClass('active');
25655 // technically we should have a deactivate event.. but maybe add later.
25656 // and it should not de-activate the selected tab...
25657 this.fireEvent('activatepane', pane);
25658 pane.el.addClass('active');
25659 pane.fireEvent('activate');
25664 getActivePane : function()
25667 Roo.each(this.panes, function(p) {
25668 if(p.el.hasClass('active')){
25689 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25691 * @class Roo.bootstrap.TabPane
25692 * @extends Roo.bootstrap.Component
25693 * Bootstrap TabPane class
25694 * @cfg {Boolean} active (false | true) Default false
25695 * @cfg {String} title title of panel
25699 * Create a new TabPane
25700 * @param {Object} config The config object
25703 Roo.bootstrap.dash.TabPane = function(config){
25704 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
25710 * When a pane is activated
25711 * @param {Roo.bootstrap.dash.TabPane} pane
25718 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
25723 // the tabBox that this is attached to.
25726 getAutoCreate : function()
25734 cfg.cls += ' active';
25739 initEvents : function()
25741 //Roo.log('trigger add pane handler');
25742 this.parent().fireEvent('addpane', this)
25746 * Updates the tab title
25747 * @param {String} html to set the title to.
25749 setTitle: function(str)
25755 this.tab.select('a', true).first().dom.innerHTML = str;
25772 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25775 * @class Roo.bootstrap.menu.Menu
25776 * @extends Roo.bootstrap.Component
25777 * Bootstrap Menu class - container for Menu
25778 * @cfg {String} html Text of the menu
25779 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
25780 * @cfg {String} icon Font awesome icon
25781 * @cfg {String} pos Menu align to (top | bottom) default bottom
25785 * Create a new Menu
25786 * @param {Object} config The config object
25790 Roo.bootstrap.menu.Menu = function(config){
25791 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
25795 * @event beforeshow
25796 * Fires before this menu is displayed
25797 * @param {Roo.bootstrap.menu.Menu} this
25801 * @event beforehide
25802 * Fires before this menu is hidden
25803 * @param {Roo.bootstrap.menu.Menu} this
25808 * Fires after this menu is displayed
25809 * @param {Roo.bootstrap.menu.Menu} this
25814 * Fires after this menu is hidden
25815 * @param {Roo.bootstrap.menu.Menu} this
25820 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
25821 * @param {Roo.bootstrap.menu.Menu} this
25822 * @param {Roo.EventObject} e
25829 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
25833 weight : 'default',
25838 getChildContainer : function() {
25839 if(this.isSubMenu){
25843 return this.el.select('ul.dropdown-menu', true).first();
25846 getAutoCreate : function()
25851 cls : 'roo-menu-text',
25859 cls : 'fa ' + this.icon
25870 cls : 'dropdown-button btn btn-' + this.weight,
25875 cls : 'dropdown-toggle btn btn-' + this.weight,
25885 cls : 'dropdown-menu'
25891 if(this.pos == 'top'){
25892 cfg.cls += ' dropup';
25895 if(this.isSubMenu){
25898 cls : 'dropdown-menu'
25905 onRender : function(ct, position)
25907 this.isSubMenu = ct.hasClass('dropdown-submenu');
25909 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
25912 initEvents : function()
25914 if(this.isSubMenu){
25918 this.hidden = true;
25920 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
25921 this.triggerEl.on('click', this.onTriggerPress, this);
25923 this.buttonEl = this.el.select('button.dropdown-button', true).first();
25924 this.buttonEl.on('click', this.onClick, this);
25930 if(this.isSubMenu){
25934 return this.el.select('ul.dropdown-menu', true).first();
25937 onClick : function(e)
25939 this.fireEvent("click", this, e);
25942 onTriggerPress : function(e)
25944 if (this.isVisible()) {
25951 isVisible : function(){
25952 return !this.hidden;
25957 this.fireEvent("beforeshow", this);
25959 this.hidden = false;
25960 this.el.addClass('open');
25962 Roo.get(document).on("mouseup", this.onMouseUp, this);
25964 this.fireEvent("show", this);
25971 this.fireEvent("beforehide", this);
25973 this.hidden = true;
25974 this.el.removeClass('open');
25976 Roo.get(document).un("mouseup", this.onMouseUp);
25978 this.fireEvent("hide", this);
25981 onMouseUp : function()
25995 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25998 * @class Roo.bootstrap.menu.Item
25999 * @extends Roo.bootstrap.Component
26000 * Bootstrap MenuItem class
26001 * @cfg {Boolean} submenu (true | false) default false
26002 * @cfg {String} html text of the item
26003 * @cfg {String} href the link
26004 * @cfg {Boolean} disable (true | false) default false
26005 * @cfg {Boolean} preventDefault (true | false) default true
26006 * @cfg {String} icon Font awesome icon
26007 * @cfg {String} pos Submenu align to (left | right) default right
26011 * Create a new Item
26012 * @param {Object} config The config object
26016 Roo.bootstrap.menu.Item = function(config){
26017 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
26021 * Fires when the mouse is hovering over this menu
26022 * @param {Roo.bootstrap.menu.Item} this
26023 * @param {Roo.EventObject} e
26028 * Fires when the mouse exits this menu
26029 * @param {Roo.bootstrap.menu.Item} this
26030 * @param {Roo.EventObject} e
26036 * The raw click event for the entire grid.
26037 * @param {Roo.EventObject} e
26043 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
26048 preventDefault: true,
26053 getAutoCreate : function()
26058 cls : 'roo-menu-item-text',
26066 cls : 'fa ' + this.icon
26075 href : this.href || '#',
26082 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
26086 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
26088 if(this.pos == 'left'){
26089 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
26096 initEvents : function()
26098 this.el.on('mouseover', this.onMouseOver, this);
26099 this.el.on('mouseout', this.onMouseOut, this);
26101 this.el.select('a', true).first().on('click', this.onClick, this);
26105 onClick : function(e)
26107 if(this.preventDefault){
26108 e.preventDefault();
26111 this.fireEvent("click", this, e);
26114 onMouseOver : function(e)
26116 if(this.submenu && this.pos == 'left'){
26117 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
26120 this.fireEvent("mouseover", this, e);
26123 onMouseOut : function(e)
26125 this.fireEvent("mouseout", this, e);
26137 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26140 * @class Roo.bootstrap.menu.Separator
26141 * @extends Roo.bootstrap.Component
26142 * Bootstrap Separator class
26145 * Create a new Separator
26146 * @param {Object} config The config object
26150 Roo.bootstrap.menu.Separator = function(config){
26151 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
26154 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
26156 getAutoCreate : function(){
26177 * @class Roo.bootstrap.Tooltip
26178 * Bootstrap Tooltip class
26179 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
26180 * to determine which dom element triggers the tooltip.
26182 * It needs to add support for additional attributes like tooltip-position
26185 * Create a new Toolti
26186 * @param {Object} config The config object
26189 Roo.bootstrap.Tooltip = function(config){
26190 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
26192 this.alignment = Roo.bootstrap.Tooltip.alignment;
26194 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
26195 this.alignment = config.alignment;
26200 Roo.apply(Roo.bootstrap.Tooltip, {
26202 * @function init initialize tooltip monitoring.
26206 currentTip : false,
26207 currentRegion : false,
26213 Roo.get(document).on('mouseover', this.enter ,this);
26214 Roo.get(document).on('mouseout', this.leave, this);
26217 this.currentTip = new Roo.bootstrap.Tooltip();
26220 enter : function(ev)
26222 var dom = ev.getTarget();
26224 //Roo.log(['enter',dom]);
26225 var el = Roo.fly(dom);
26226 if (this.currentEl) {
26228 //Roo.log(this.currentEl);
26229 //Roo.log(this.currentEl.contains(dom));
26230 if (this.currentEl == el) {
26233 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
26239 if (this.currentTip.el) {
26240 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
26244 if(!el || el.dom == document){
26250 // you can not look for children, as if el is the body.. then everythign is the child..
26251 if (!el.attr('tooltip')) { //
26252 if (!el.select("[tooltip]").elements.length) {
26255 // is the mouse over this child...?
26256 bindEl = el.select("[tooltip]").first();
26257 var xy = ev.getXY();
26258 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
26259 //Roo.log("not in region.");
26262 //Roo.log("child element over..");
26265 this.currentEl = bindEl;
26266 this.currentTip.bind(bindEl);
26267 this.currentRegion = Roo.lib.Region.getRegion(dom);
26268 this.currentTip.enter();
26271 leave : function(ev)
26273 var dom = ev.getTarget();
26274 //Roo.log(['leave',dom]);
26275 if (!this.currentEl) {
26280 if (dom != this.currentEl.dom) {
26283 var xy = ev.getXY();
26284 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
26287 // only activate leave if mouse cursor is outside... bounding box..
26292 if (this.currentTip) {
26293 this.currentTip.leave();
26295 //Roo.log('clear currentEl');
26296 this.currentEl = false;
26301 'left' : ['r-l', [-2,0], 'right'],
26302 'right' : ['l-r', [2,0], 'left'],
26303 'bottom' : ['t-b', [0,2], 'top'],
26304 'top' : [ 'b-t', [0,-2], 'bottom']
26310 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
26315 delay : null, // can be { show : 300 , hide: 500}
26319 hoverState : null, //???
26321 placement : 'bottom',
26325 getAutoCreate : function(){
26332 cls : 'tooltip-arrow'
26335 cls : 'tooltip-inner'
26342 bind : function(el)
26348 enter : function () {
26350 if (this.timeout != null) {
26351 clearTimeout(this.timeout);
26354 this.hoverState = 'in';
26355 //Roo.log("enter - show");
26356 if (!this.delay || !this.delay.show) {
26361 this.timeout = setTimeout(function () {
26362 if (_t.hoverState == 'in') {
26365 }, this.delay.show);
26369 clearTimeout(this.timeout);
26371 this.hoverState = 'out';
26372 if (!this.delay || !this.delay.hide) {
26378 this.timeout = setTimeout(function () {
26379 //Roo.log("leave - timeout");
26381 if (_t.hoverState == 'out') {
26383 Roo.bootstrap.Tooltip.currentEl = false;
26388 show : function (msg)
26391 this.render(document.body);
26394 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
26396 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
26398 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
26400 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
26402 var placement = typeof this.placement == 'function' ?
26403 this.placement.call(this, this.el, on_el) :
26406 var autoToken = /\s?auto?\s?/i;
26407 var autoPlace = autoToken.test(placement);
26409 placement = placement.replace(autoToken, '') || 'top';
26413 //this.el.setXY([0,0]);
26415 //this.el.dom.style.display='block';
26417 //this.el.appendTo(on_el);
26419 var p = this.getPosition();
26420 var box = this.el.getBox();
26426 var align = this.alignment[placement];
26428 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
26430 if(placement == 'top' || placement == 'bottom'){
26432 placement = 'right';
26435 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
26436 placement = 'left';
26439 var scroll = Roo.select('body', true).first().getScroll();
26441 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
26445 align = this.alignment[placement];
26448 this.el.alignTo(this.bindEl, align[0],align[1]);
26449 //var arrow = this.el.select('.arrow',true).first();
26450 //arrow.set(align[2],
26452 this.el.addClass(placement);
26454 this.el.addClass('in fade');
26456 this.hoverState = null;
26458 if (this.el.hasClass('fade')) {
26469 //this.el.setXY([0,0]);
26470 this.el.removeClass('in');
26486 * @class Roo.bootstrap.LocationPicker
26487 * @extends Roo.bootstrap.Component
26488 * Bootstrap LocationPicker class
26489 * @cfg {Number} latitude Position when init default 0
26490 * @cfg {Number} longitude Position when init default 0
26491 * @cfg {Number} zoom default 15
26492 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
26493 * @cfg {Boolean} mapTypeControl default false
26494 * @cfg {Boolean} disableDoubleClickZoom default false
26495 * @cfg {Boolean} scrollwheel default true
26496 * @cfg {Boolean} streetViewControl default false
26497 * @cfg {Number} radius default 0
26498 * @cfg {String} locationName
26499 * @cfg {Boolean} draggable default true
26500 * @cfg {Boolean} enableAutocomplete default false
26501 * @cfg {Boolean} enableReverseGeocode default true
26502 * @cfg {String} markerTitle
26505 * Create a new LocationPicker
26506 * @param {Object} config The config object
26510 Roo.bootstrap.LocationPicker = function(config){
26512 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
26517 * Fires when the picker initialized.
26518 * @param {Roo.bootstrap.LocationPicker} this
26519 * @param {Google Location} location
26523 * @event positionchanged
26524 * Fires when the picker position changed.
26525 * @param {Roo.bootstrap.LocationPicker} this
26526 * @param {Google Location} location
26528 positionchanged : true,
26531 * Fires when the map resize.
26532 * @param {Roo.bootstrap.LocationPicker} this
26537 * Fires when the map show.
26538 * @param {Roo.bootstrap.LocationPicker} this
26543 * Fires when the map hide.
26544 * @param {Roo.bootstrap.LocationPicker} this
26549 * Fires when click the map.
26550 * @param {Roo.bootstrap.LocationPicker} this
26551 * @param {Map event} e
26555 * @event mapRightClick
26556 * Fires when right click the map.
26557 * @param {Roo.bootstrap.LocationPicker} this
26558 * @param {Map event} e
26560 mapRightClick : true,
26562 * @event markerClick
26563 * Fires when click the marker.
26564 * @param {Roo.bootstrap.LocationPicker} this
26565 * @param {Map event} e
26567 markerClick : true,
26569 * @event markerRightClick
26570 * Fires when right click the marker.
26571 * @param {Roo.bootstrap.LocationPicker} this
26572 * @param {Map event} e
26574 markerRightClick : true,
26576 * @event OverlayViewDraw
26577 * Fires when OverlayView Draw
26578 * @param {Roo.bootstrap.LocationPicker} this
26580 OverlayViewDraw : true,
26582 * @event OverlayViewOnAdd
26583 * Fires when OverlayView Draw
26584 * @param {Roo.bootstrap.LocationPicker} this
26586 OverlayViewOnAdd : true,
26588 * @event OverlayViewOnRemove
26589 * Fires when OverlayView Draw
26590 * @param {Roo.bootstrap.LocationPicker} this
26592 OverlayViewOnRemove : true,
26594 * @event OverlayViewShow
26595 * Fires when OverlayView Draw
26596 * @param {Roo.bootstrap.LocationPicker} this
26597 * @param {Pixel} cpx
26599 OverlayViewShow : true,
26601 * @event OverlayViewHide
26602 * Fires when OverlayView Draw
26603 * @param {Roo.bootstrap.LocationPicker} this
26605 OverlayViewHide : true,
26607 * @event loadexception
26608 * Fires when load google lib failed.
26609 * @param {Roo.bootstrap.LocationPicker} this
26611 loadexception : true
26616 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
26618 gMapContext: false,
26624 mapTypeControl: false,
26625 disableDoubleClickZoom: false,
26627 streetViewControl: false,
26631 enableAutocomplete: false,
26632 enableReverseGeocode: true,
26635 getAutoCreate: function()
26640 cls: 'roo-location-picker'
26646 initEvents: function(ct, position)
26648 if(!this.el.getWidth() || this.isApplied()){
26652 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26657 initial: function()
26659 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
26660 this.fireEvent('loadexception', this);
26664 if(!this.mapTypeId){
26665 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
26668 this.gMapContext = this.GMapContext();
26670 this.initOverlayView();
26672 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
26676 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
26677 _this.setPosition(_this.gMapContext.marker.position);
26680 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
26681 _this.fireEvent('mapClick', this, event);
26685 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
26686 _this.fireEvent('mapRightClick', this, event);
26690 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
26691 _this.fireEvent('markerClick', this, event);
26695 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
26696 _this.fireEvent('markerRightClick', this, event);
26700 this.setPosition(this.gMapContext.location);
26702 this.fireEvent('initial', this, this.gMapContext.location);
26705 initOverlayView: function()
26709 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
26713 _this.fireEvent('OverlayViewDraw', _this);
26718 _this.fireEvent('OverlayViewOnAdd', _this);
26721 onRemove: function()
26723 _this.fireEvent('OverlayViewOnRemove', _this);
26726 show: function(cpx)
26728 _this.fireEvent('OverlayViewShow', _this, cpx);
26733 _this.fireEvent('OverlayViewHide', _this);
26739 fromLatLngToContainerPixel: function(event)
26741 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
26744 isApplied: function()
26746 return this.getGmapContext() == false ? false : true;
26749 getGmapContext: function()
26751 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
26754 GMapContext: function()
26756 var position = new google.maps.LatLng(this.latitude, this.longitude);
26758 var _map = new google.maps.Map(this.el.dom, {
26761 mapTypeId: this.mapTypeId,
26762 mapTypeControl: this.mapTypeControl,
26763 disableDoubleClickZoom: this.disableDoubleClickZoom,
26764 scrollwheel: this.scrollwheel,
26765 streetViewControl: this.streetViewControl,
26766 locationName: this.locationName,
26767 draggable: this.draggable,
26768 enableAutocomplete: this.enableAutocomplete,
26769 enableReverseGeocode: this.enableReverseGeocode
26772 var _marker = new google.maps.Marker({
26773 position: position,
26775 title: this.markerTitle,
26776 draggable: this.draggable
26783 location: position,
26784 radius: this.radius,
26785 locationName: this.locationName,
26786 addressComponents: {
26787 formatted_address: null,
26788 addressLine1: null,
26789 addressLine2: null,
26791 streetNumber: null,
26795 stateOrProvince: null
26798 domContainer: this.el.dom,
26799 geodecoder: new google.maps.Geocoder()
26803 drawCircle: function(center, radius, options)
26805 if (this.gMapContext.circle != null) {
26806 this.gMapContext.circle.setMap(null);
26810 options = Roo.apply({}, options, {
26811 strokeColor: "#0000FF",
26812 strokeOpacity: .35,
26814 fillColor: "#0000FF",
26818 options.map = this.gMapContext.map;
26819 options.radius = radius;
26820 options.center = center;
26821 this.gMapContext.circle = new google.maps.Circle(options);
26822 return this.gMapContext.circle;
26828 setPosition: function(location)
26830 this.gMapContext.location = location;
26831 this.gMapContext.marker.setPosition(location);
26832 this.gMapContext.map.panTo(location);
26833 this.drawCircle(location, this.gMapContext.radius, {});
26837 if (this.gMapContext.settings.enableReverseGeocode) {
26838 this.gMapContext.geodecoder.geocode({
26839 latLng: this.gMapContext.location
26840 }, function(results, status) {
26842 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
26843 _this.gMapContext.locationName = results[0].formatted_address;
26844 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
26846 _this.fireEvent('positionchanged', this, location);
26853 this.fireEvent('positionchanged', this, location);
26858 google.maps.event.trigger(this.gMapContext.map, "resize");
26860 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
26862 this.fireEvent('resize', this);
26865 setPositionByLatLng: function(latitude, longitude)
26867 this.setPosition(new google.maps.LatLng(latitude, longitude));
26870 getCurrentPosition: function()
26873 latitude: this.gMapContext.location.lat(),
26874 longitude: this.gMapContext.location.lng()
26878 getAddressName: function()
26880 return this.gMapContext.locationName;
26883 getAddressComponents: function()
26885 return this.gMapContext.addressComponents;
26888 address_component_from_google_geocode: function(address_components)
26892 for (var i = 0; i < address_components.length; i++) {
26893 var component = address_components[i];
26894 if (component.types.indexOf("postal_code") >= 0) {
26895 result.postalCode = component.short_name;
26896 } else if (component.types.indexOf("street_number") >= 0) {
26897 result.streetNumber = component.short_name;
26898 } else if (component.types.indexOf("route") >= 0) {
26899 result.streetName = component.short_name;
26900 } else if (component.types.indexOf("neighborhood") >= 0) {
26901 result.city = component.short_name;
26902 } else if (component.types.indexOf("locality") >= 0) {
26903 result.city = component.short_name;
26904 } else if (component.types.indexOf("sublocality") >= 0) {
26905 result.district = component.short_name;
26906 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
26907 result.stateOrProvince = component.short_name;
26908 } else if (component.types.indexOf("country") >= 0) {
26909 result.country = component.short_name;
26913 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
26914 result.addressLine2 = "";
26918 setZoomLevel: function(zoom)
26920 this.gMapContext.map.setZoom(zoom);
26933 this.fireEvent('show', this);
26944 this.fireEvent('hide', this);
26949 Roo.apply(Roo.bootstrap.LocationPicker, {
26951 OverlayView : function(map, options)
26953 options = options || {};
26967 * @class Roo.bootstrap.Alert
26968 * @extends Roo.bootstrap.Component
26969 * Bootstrap Alert class
26970 * @cfg {String} title The title of alert
26971 * @cfg {String} html The content of alert
26972 * @cfg {String} weight ( success | info | warning | danger )
26973 * @cfg {String} faicon font-awesomeicon
26976 * Create a new alert
26977 * @param {Object} config The config object
26981 Roo.bootstrap.Alert = function(config){
26982 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
26986 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
26993 getAutoCreate : function()
27002 cls : 'roo-alert-icon'
27007 cls : 'roo-alert-title',
27012 cls : 'roo-alert-text',
27019 cfg.cn[0].cls += ' fa ' + this.faicon;
27023 cfg.cls += ' alert-' + this.weight;
27029 initEvents: function()
27031 this.el.setVisibilityMode(Roo.Element.DISPLAY);
27034 setTitle : function(str)
27036 this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
27039 setText : function(str)
27041 this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
27044 setWeight : function(weight)
27047 this.el.select('.alert',true).first().removeClass('alert-' + this.weight);
27050 this.weight = weight;
27052 this.el.select('.alert',true).first().addClass('alert-' + this.weight);
27055 setIcon : function(icon)
27058 this.el.select('.roo-alert-icon',true).first().removeClass(['fa', 'fa-' + this.faicon]);
27061 this.faicon = icon;
27063 this.el.select('.roo-alert-icon',true).first().addClass(['fa', 'fa-' + this.faicon]);
27084 * @class Roo.bootstrap.UploadCropbox
27085 * @extends Roo.bootstrap.Component
27086 * Bootstrap UploadCropbox class
27087 * @cfg {String} emptyText show when image has been loaded
27088 * @cfg {String} rotateNotify show when image too small to rotate
27089 * @cfg {Number} errorTimeout default 3000
27090 * @cfg {Number} minWidth default 300
27091 * @cfg {Number} minHeight default 300
27092 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
27093 * @cfg {Boolean} isDocument (true|false) default false
27094 * @cfg {String} url action url
27095 * @cfg {String} paramName default 'imageUpload'
27096 * @cfg {String} method default POST
27097 * @cfg {Boolean} loadMask (true|false) default true
27098 * @cfg {Boolean} loadingText default 'Loading...'
27101 * Create a new UploadCropbox
27102 * @param {Object} config The config object
27105 Roo.bootstrap.UploadCropbox = function(config){
27106 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
27110 * @event beforeselectfile
27111 * Fire before select file
27112 * @param {Roo.bootstrap.UploadCropbox} this
27114 "beforeselectfile" : true,
27117 * Fire after initEvent
27118 * @param {Roo.bootstrap.UploadCropbox} this
27123 * Fire after initEvent
27124 * @param {Roo.bootstrap.UploadCropbox} this
27125 * @param {String} data
27130 * Fire when preparing the file data
27131 * @param {Roo.bootstrap.UploadCropbox} this
27132 * @param {Object} file
27137 * Fire when get exception
27138 * @param {Roo.bootstrap.UploadCropbox} this
27139 * @param {XMLHttpRequest} xhr
27141 "exception" : true,
27143 * @event beforeloadcanvas
27144 * Fire before load the canvas
27145 * @param {Roo.bootstrap.UploadCropbox} this
27146 * @param {String} src
27148 "beforeloadcanvas" : true,
27151 * Fire when trash image
27152 * @param {Roo.bootstrap.UploadCropbox} this
27157 * Fire when download the image
27158 * @param {Roo.bootstrap.UploadCropbox} this
27162 * @event footerbuttonclick
27163 * Fire when footerbuttonclick
27164 * @param {Roo.bootstrap.UploadCropbox} this
27165 * @param {String} type
27167 "footerbuttonclick" : true,
27171 * @param {Roo.bootstrap.UploadCropbox} this
27176 * Fire when rotate the image
27177 * @param {Roo.bootstrap.UploadCropbox} this
27178 * @param {String} pos
27183 * Fire when inspect the file
27184 * @param {Roo.bootstrap.UploadCropbox} this
27185 * @param {Object} file
27190 * Fire when xhr upload the file
27191 * @param {Roo.bootstrap.UploadCropbox} this
27192 * @param {Object} data
27197 * Fire when arrange the file data
27198 * @param {Roo.bootstrap.UploadCropbox} this
27199 * @param {Object} formData
27204 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
27207 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
27209 emptyText : 'Click to upload image',
27210 rotateNotify : 'Image is too small to rotate',
27211 errorTimeout : 3000,
27225 cropType : 'image/jpeg',
27227 canvasLoaded : false,
27228 isDocument : false,
27230 paramName : 'imageUpload',
27232 loadingText : 'Loading...',
27235 getAutoCreate : function()
27239 cls : 'roo-upload-cropbox',
27243 cls : 'roo-upload-cropbox-selector',
27248 cls : 'roo-upload-cropbox-body',
27249 style : 'cursor:pointer',
27253 cls : 'roo-upload-cropbox-preview'
27257 cls : 'roo-upload-cropbox-thumb'
27261 cls : 'roo-upload-cropbox-empty-notify',
27262 html : this.emptyText
27266 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
27267 html : this.rotateNotify
27273 cls : 'roo-upload-cropbox-footer',
27276 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
27286 onRender : function(ct, position)
27288 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
27290 if (this.buttons.length) {
27292 Roo.each(this.buttons, function(bb) {
27294 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
27296 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
27302 this.maskEl = this.el;
27306 initEvents : function()
27308 this.urlAPI = (window.createObjectURL && window) ||
27309 (window.URL && URL.revokeObjectURL && URL) ||
27310 (window.webkitURL && webkitURL);
27312 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
27313 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27315 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
27316 this.selectorEl.hide();
27318 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
27319 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27321 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
27322 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27323 this.thumbEl.hide();
27325 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
27326 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27328 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
27329 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27330 this.errorEl.hide();
27332 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
27333 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27334 this.footerEl.hide();
27336 this.setThumbBoxSize();
27342 this.fireEvent('initial', this);
27349 window.addEventListener("resize", function() { _this.resize(); } );
27351 this.bodyEl.on('click', this.beforeSelectFile, this);
27354 this.bodyEl.on('touchstart', this.onTouchStart, this);
27355 this.bodyEl.on('touchmove', this.onTouchMove, this);
27356 this.bodyEl.on('touchend', this.onTouchEnd, this);
27360 this.bodyEl.on('mousedown', this.onMouseDown, this);
27361 this.bodyEl.on('mousemove', this.onMouseMove, this);
27362 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
27363 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
27364 Roo.get(document).on('mouseup', this.onMouseUp, this);
27367 this.selectorEl.on('change', this.onFileSelected, this);
27373 this.baseScale = 1;
27375 this.baseRotate = 1;
27376 this.dragable = false;
27377 this.pinching = false;
27380 this.cropData = false;
27381 this.notifyEl.dom.innerHTML = this.emptyText;
27383 this.selectorEl.dom.value = '';
27387 resize : function()
27389 if(this.fireEvent('resize', this) != false){
27390 this.setThumbBoxPosition();
27391 this.setCanvasPosition();
27395 onFooterButtonClick : function(e, el, o, type)
27398 case 'rotate-left' :
27399 this.onRotateLeft(e);
27401 case 'rotate-right' :
27402 this.onRotateRight(e);
27405 this.beforeSelectFile(e);
27420 this.fireEvent('footerbuttonclick', this, type);
27423 beforeSelectFile : function(e)
27425 e.preventDefault();
27427 if(this.fireEvent('beforeselectfile', this) != false){
27428 this.selectorEl.dom.click();
27432 onFileSelected : function(e)
27434 e.preventDefault();
27436 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
27440 var file = this.selectorEl.dom.files[0];
27442 if(this.fireEvent('inspect', this, file) != false){
27443 this.prepare(file);
27448 trash : function(e)
27450 this.fireEvent('trash', this);
27453 download : function(e)
27455 this.fireEvent('download', this);
27458 loadCanvas : function(src)
27460 if(this.fireEvent('beforeloadcanvas', this, src) != false){
27464 this.imageEl = document.createElement('img');
27468 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
27470 this.imageEl.src = src;
27474 onLoadCanvas : function()
27476 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
27477 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
27479 this.bodyEl.un('click', this.beforeSelectFile, this);
27481 this.notifyEl.hide();
27482 this.thumbEl.show();
27483 this.footerEl.show();
27485 this.baseRotateLevel();
27487 if(this.isDocument){
27488 this.setThumbBoxSize();
27491 this.setThumbBoxPosition();
27493 this.baseScaleLevel();
27499 this.canvasLoaded = true;
27502 this.maskEl.unmask();
27507 setCanvasPosition : function()
27509 if(!this.canvasEl){
27513 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
27514 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
27516 this.previewEl.setLeft(pw);
27517 this.previewEl.setTop(ph);
27521 onMouseDown : function(e)
27525 this.dragable = true;
27526 this.pinching = false;
27528 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
27529 this.dragable = false;
27533 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27534 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27538 onMouseMove : function(e)
27542 if(!this.canvasLoaded){
27546 if (!this.dragable){
27550 var minX = Math.ceil(this.thumbEl.getLeft(true));
27551 var minY = Math.ceil(this.thumbEl.getTop(true));
27553 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
27554 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
27556 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27557 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27559 x = x - this.mouseX;
27560 y = y - this.mouseY;
27562 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
27563 var bgY = Math.ceil(y + this.previewEl.getTop(true));
27565 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
27566 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
27568 this.previewEl.setLeft(bgX);
27569 this.previewEl.setTop(bgY);
27571 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27572 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27575 onMouseUp : function(e)
27579 this.dragable = false;
27582 onMouseWheel : function(e)
27586 this.startScale = this.scale;
27588 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
27590 if(!this.zoomable()){
27591 this.scale = this.startScale;
27600 zoomable : function()
27602 var minScale = this.thumbEl.getWidth() / this.minWidth;
27604 if(this.minWidth < this.minHeight){
27605 minScale = this.thumbEl.getHeight() / this.minHeight;
27608 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
27609 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
27613 (this.rotate == 0 || this.rotate == 180) &&
27615 width > this.imageEl.OriginWidth ||
27616 height > this.imageEl.OriginHeight ||
27617 (width < this.minWidth && height < this.minHeight)
27625 (this.rotate == 90 || this.rotate == 270) &&
27627 width > this.imageEl.OriginWidth ||
27628 height > this.imageEl.OriginHeight ||
27629 (width < this.minHeight && height < this.minWidth)
27636 !this.isDocument &&
27637 (this.rotate == 0 || this.rotate == 180) &&
27639 width < this.minWidth ||
27640 width > this.imageEl.OriginWidth ||
27641 height < this.minHeight ||
27642 height > this.imageEl.OriginHeight
27649 !this.isDocument &&
27650 (this.rotate == 90 || this.rotate == 270) &&
27652 width < this.minHeight ||
27653 width > this.imageEl.OriginWidth ||
27654 height < this.minWidth ||
27655 height > this.imageEl.OriginHeight
27665 onRotateLeft : function(e)
27667 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27669 var minScale = this.thumbEl.getWidth() / this.minWidth;
27671 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27672 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27674 this.startScale = this.scale;
27676 while (this.getScaleLevel() < minScale){
27678 this.scale = this.scale + 1;
27680 if(!this.zoomable()){
27685 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27686 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27691 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27698 this.scale = this.startScale;
27700 this.onRotateFail();
27705 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27707 if(this.isDocument){
27708 this.setThumbBoxSize();
27709 this.setThumbBoxPosition();
27710 this.setCanvasPosition();
27715 this.fireEvent('rotate', this, 'left');
27719 onRotateRight : function(e)
27721 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27723 var minScale = this.thumbEl.getWidth() / this.minWidth;
27725 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27726 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27728 this.startScale = this.scale;
27730 while (this.getScaleLevel() < minScale){
27732 this.scale = this.scale + 1;
27734 if(!this.zoomable()){
27739 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27740 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27745 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27752 this.scale = this.startScale;
27754 this.onRotateFail();
27759 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27761 if(this.isDocument){
27762 this.setThumbBoxSize();
27763 this.setThumbBoxPosition();
27764 this.setCanvasPosition();
27769 this.fireEvent('rotate', this, 'right');
27772 onRotateFail : function()
27774 this.errorEl.show(true);
27778 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
27783 this.previewEl.dom.innerHTML = '';
27785 var canvasEl = document.createElement("canvas");
27787 var contextEl = canvasEl.getContext("2d");
27789 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27790 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27791 var center = this.imageEl.OriginWidth / 2;
27793 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
27794 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27795 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27796 center = this.imageEl.OriginHeight / 2;
27799 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
27801 contextEl.translate(center, center);
27802 contextEl.rotate(this.rotate * Math.PI / 180);
27804 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
27806 this.canvasEl = document.createElement("canvas");
27808 this.contextEl = this.canvasEl.getContext("2d");
27810 switch (this.rotate) {
27813 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27814 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27816 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27821 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27822 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27824 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27825 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);
27829 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27834 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27835 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27837 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27838 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);
27842 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);
27847 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27848 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27850 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27851 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27855 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);
27862 this.previewEl.appendChild(this.canvasEl);
27864 this.setCanvasPosition();
27869 if(!this.canvasLoaded){
27873 var imageCanvas = document.createElement("canvas");
27875 var imageContext = imageCanvas.getContext("2d");
27877 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
27878 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
27880 var center = imageCanvas.width / 2;
27882 imageContext.translate(center, center);
27884 imageContext.rotate(this.rotate * Math.PI / 180);
27886 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
27888 var canvas = document.createElement("canvas");
27890 var context = canvas.getContext("2d");
27892 canvas.width = this.minWidth;
27893 canvas.height = this.minHeight;
27895 switch (this.rotate) {
27898 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
27899 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
27901 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27902 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27904 var targetWidth = this.minWidth - 2 * x;
27905 var targetHeight = this.minHeight - 2 * y;
27909 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27910 scale = targetWidth / width;
27913 if(x > 0 && y == 0){
27914 scale = targetHeight / height;
27917 if(x > 0 && y > 0){
27918 scale = targetWidth / width;
27920 if(width < height){
27921 scale = targetHeight / height;
27925 context.scale(scale, scale);
27927 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27928 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27930 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27931 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27933 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27938 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
27939 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
27941 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27942 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27944 var targetWidth = this.minWidth - 2 * x;
27945 var targetHeight = this.minHeight - 2 * y;
27949 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27950 scale = targetWidth / width;
27953 if(x > 0 && y == 0){
27954 scale = targetHeight / height;
27957 if(x > 0 && y > 0){
27958 scale = targetWidth / width;
27960 if(width < height){
27961 scale = targetHeight / height;
27965 context.scale(scale, scale);
27967 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27968 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27970 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27971 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27973 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
27975 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27980 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
27981 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
27983 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27984 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27986 var targetWidth = this.minWidth - 2 * x;
27987 var targetHeight = this.minHeight - 2 * y;
27991 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27992 scale = targetWidth / width;
27995 if(x > 0 && y == 0){
27996 scale = targetHeight / height;
27999 if(x > 0 && y > 0){
28000 scale = targetWidth / width;
28002 if(width < height){
28003 scale = targetHeight / height;
28007 context.scale(scale, scale);
28009 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28010 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28012 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28013 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28015 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28016 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
28018 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28023 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
28024 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
28026 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28027 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28029 var targetWidth = this.minWidth - 2 * x;
28030 var targetHeight = this.minHeight - 2 * y;
28034 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28035 scale = targetWidth / width;
28038 if(x > 0 && y == 0){
28039 scale = targetHeight / height;
28042 if(x > 0 && y > 0){
28043 scale = targetWidth / width;
28045 if(width < height){
28046 scale = targetHeight / height;
28050 context.scale(scale, scale);
28052 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28053 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28055 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28056 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28058 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28060 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28067 this.cropData = canvas.toDataURL(this.cropType);
28069 if(this.fireEvent('crop', this, this.cropData) !== false){
28070 this.process(this.file, this.cropData);
28077 setThumbBoxSize : function()
28081 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
28082 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
28083 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
28085 this.minWidth = width;
28086 this.minHeight = height;
28088 if(this.rotate == 90 || this.rotate == 270){
28089 this.minWidth = height;
28090 this.minHeight = width;
28095 width = Math.ceil(this.minWidth * height / this.minHeight);
28097 if(this.minWidth > this.minHeight){
28099 height = Math.ceil(this.minHeight * width / this.minWidth);
28102 this.thumbEl.setStyle({
28103 width : width + 'px',
28104 height : height + 'px'
28111 setThumbBoxPosition : function()
28113 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
28114 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
28116 this.thumbEl.setLeft(x);
28117 this.thumbEl.setTop(y);
28121 baseRotateLevel : function()
28123 this.baseRotate = 1;
28126 typeof(this.exif) != 'undefined' &&
28127 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
28128 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
28130 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
28133 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
28137 baseScaleLevel : function()
28141 if(this.isDocument){
28143 if(this.baseRotate == 6 || this.baseRotate == 8){
28145 height = this.thumbEl.getHeight();
28146 this.baseScale = height / this.imageEl.OriginWidth;
28148 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
28149 width = this.thumbEl.getWidth();
28150 this.baseScale = width / this.imageEl.OriginHeight;
28156 height = this.thumbEl.getHeight();
28157 this.baseScale = height / this.imageEl.OriginHeight;
28159 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
28160 width = this.thumbEl.getWidth();
28161 this.baseScale = width / this.imageEl.OriginWidth;
28167 if(this.baseRotate == 6 || this.baseRotate == 8){
28169 width = this.thumbEl.getHeight();
28170 this.baseScale = width / this.imageEl.OriginHeight;
28172 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
28173 height = this.thumbEl.getWidth();
28174 this.baseScale = height / this.imageEl.OriginHeight;
28177 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28178 height = this.thumbEl.getWidth();
28179 this.baseScale = height / this.imageEl.OriginHeight;
28181 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
28182 width = this.thumbEl.getHeight();
28183 this.baseScale = width / this.imageEl.OriginWidth;
28190 width = this.thumbEl.getWidth();
28191 this.baseScale = width / this.imageEl.OriginWidth;
28193 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
28194 height = this.thumbEl.getHeight();
28195 this.baseScale = height / this.imageEl.OriginHeight;
28198 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28200 height = this.thumbEl.getHeight();
28201 this.baseScale = height / this.imageEl.OriginHeight;
28203 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
28204 width = this.thumbEl.getWidth();
28205 this.baseScale = width / this.imageEl.OriginWidth;
28213 getScaleLevel : function()
28215 return this.baseScale * Math.pow(1.1, this.scale);
28218 onTouchStart : function(e)
28220 if(!this.canvasLoaded){
28221 this.beforeSelectFile(e);
28225 var touches = e.browserEvent.touches;
28231 if(touches.length == 1){
28232 this.onMouseDown(e);
28236 if(touches.length != 2){
28242 for(var i = 0, finger; finger = touches[i]; i++){
28243 coords.push(finger.pageX, finger.pageY);
28246 var x = Math.pow(coords[0] - coords[2], 2);
28247 var y = Math.pow(coords[1] - coords[3], 2);
28249 this.startDistance = Math.sqrt(x + y);
28251 this.startScale = this.scale;
28253 this.pinching = true;
28254 this.dragable = false;
28258 onTouchMove : function(e)
28260 if(!this.pinching && !this.dragable){
28264 var touches = e.browserEvent.touches;
28271 this.onMouseMove(e);
28277 for(var i = 0, finger; finger = touches[i]; i++){
28278 coords.push(finger.pageX, finger.pageY);
28281 var x = Math.pow(coords[0] - coords[2], 2);
28282 var y = Math.pow(coords[1] - coords[3], 2);
28284 this.endDistance = Math.sqrt(x + y);
28286 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
28288 if(!this.zoomable()){
28289 this.scale = this.startScale;
28297 onTouchEnd : function(e)
28299 this.pinching = false;
28300 this.dragable = false;
28304 process : function(file, crop)
28307 this.maskEl.mask(this.loadingText);
28310 this.xhr = new XMLHttpRequest();
28312 file.xhr = this.xhr;
28314 this.xhr.open(this.method, this.url, true);
28317 "Accept": "application/json",
28318 "Cache-Control": "no-cache",
28319 "X-Requested-With": "XMLHttpRequest"
28322 for (var headerName in headers) {
28323 var headerValue = headers[headerName];
28325 this.xhr.setRequestHeader(headerName, headerValue);
28331 this.xhr.onload = function()
28333 _this.xhrOnLoad(_this.xhr);
28336 this.xhr.onerror = function()
28338 _this.xhrOnError(_this.xhr);
28341 var formData = new FormData();
28343 formData.append('returnHTML', 'NO');
28346 formData.append('crop', crop);
28349 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
28350 formData.append(this.paramName, file, file.name);
28353 if(typeof(file.filename) != 'undefined'){
28354 formData.append('filename', file.filename);
28357 if(typeof(file.mimetype) != 'undefined'){
28358 formData.append('mimetype', file.mimetype);
28361 if(this.fireEvent('arrange', this, formData) != false){
28362 this.xhr.send(formData);
28366 xhrOnLoad : function(xhr)
28369 this.maskEl.unmask();
28372 if (xhr.readyState !== 4) {
28373 this.fireEvent('exception', this, xhr);
28377 var response = Roo.decode(xhr.responseText);
28379 if(!response.success){
28380 this.fireEvent('exception', this, xhr);
28384 var response = Roo.decode(xhr.responseText);
28386 this.fireEvent('upload', this, response);
28390 xhrOnError : function()
28393 this.maskEl.unmask();
28396 Roo.log('xhr on error');
28398 var response = Roo.decode(xhr.responseText);
28404 prepare : function(file)
28407 this.maskEl.mask(this.loadingText);
28413 if(typeof(file) === 'string'){
28414 this.loadCanvas(file);
28418 if(!file || !this.urlAPI){
28423 this.cropType = file.type;
28427 if(this.fireEvent('prepare', this, this.file) != false){
28429 var reader = new FileReader();
28431 reader.onload = function (e) {
28432 if (e.target.error) {
28433 Roo.log(e.target.error);
28437 var buffer = e.target.result,
28438 dataView = new DataView(buffer),
28440 maxOffset = dataView.byteLength - 4,
28444 if (dataView.getUint16(0) === 0xffd8) {
28445 while (offset < maxOffset) {
28446 markerBytes = dataView.getUint16(offset);
28448 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
28449 markerLength = dataView.getUint16(offset + 2) + 2;
28450 if (offset + markerLength > dataView.byteLength) {
28451 Roo.log('Invalid meta data: Invalid segment size.');
28455 if(markerBytes == 0xffe1){
28456 _this.parseExifData(
28463 offset += markerLength;
28473 var url = _this.urlAPI.createObjectURL(_this.file);
28475 _this.loadCanvas(url);
28480 reader.readAsArrayBuffer(this.file);
28486 parseExifData : function(dataView, offset, length)
28488 var tiffOffset = offset + 10,
28492 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28493 // No Exif data, might be XMP data instead
28497 // Check for the ASCII code for "Exif" (0x45786966):
28498 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28499 // No Exif data, might be XMP data instead
28502 if (tiffOffset + 8 > dataView.byteLength) {
28503 Roo.log('Invalid Exif data: Invalid segment size.');
28506 // Check for the two null bytes:
28507 if (dataView.getUint16(offset + 8) !== 0x0000) {
28508 Roo.log('Invalid Exif data: Missing byte alignment offset.');
28511 // Check the byte alignment:
28512 switch (dataView.getUint16(tiffOffset)) {
28514 littleEndian = true;
28517 littleEndian = false;
28520 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
28523 // Check for the TIFF tag marker (0x002A):
28524 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
28525 Roo.log('Invalid Exif data: Missing TIFF marker.');
28528 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
28529 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
28531 this.parseExifTags(
28534 tiffOffset + dirOffset,
28539 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
28544 if (dirOffset + 6 > dataView.byteLength) {
28545 Roo.log('Invalid Exif data: Invalid directory offset.');
28548 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
28549 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
28550 if (dirEndOffset + 4 > dataView.byteLength) {
28551 Roo.log('Invalid Exif data: Invalid directory size.');
28554 for (i = 0; i < tagsNumber; i += 1) {
28558 dirOffset + 2 + 12 * i, // tag offset
28562 // Return the offset to the next directory:
28563 return dataView.getUint32(dirEndOffset, littleEndian);
28566 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
28568 var tag = dataView.getUint16(offset, littleEndian);
28570 this.exif[tag] = this.getExifValue(
28574 dataView.getUint16(offset + 2, littleEndian), // tag type
28575 dataView.getUint32(offset + 4, littleEndian), // tag length
28580 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
28582 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
28591 Roo.log('Invalid Exif data: Invalid tag type.');
28595 tagSize = tagType.size * length;
28596 // Determine if the value is contained in the dataOffset bytes,
28597 // or if the value at the dataOffset is a pointer to the actual data:
28598 dataOffset = tagSize > 4 ?
28599 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
28600 if (dataOffset + tagSize > dataView.byteLength) {
28601 Roo.log('Invalid Exif data: Invalid data offset.');
28604 if (length === 1) {
28605 return tagType.getValue(dataView, dataOffset, littleEndian);
28608 for (i = 0; i < length; i += 1) {
28609 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
28612 if (tagType.ascii) {
28614 // Concatenate the chars:
28615 for (i = 0; i < values.length; i += 1) {
28617 // Ignore the terminating NULL byte(s):
28618 if (c === '\u0000') {
28630 Roo.apply(Roo.bootstrap.UploadCropbox, {
28632 'Orientation': 0x0112
28636 1: 0, //'top-left',
28638 3: 180, //'bottom-right',
28639 // 4: 'bottom-left',
28641 6: 90, //'right-top',
28642 // 7: 'right-bottom',
28643 8: 270 //'left-bottom'
28647 // byte, 8-bit unsigned int:
28649 getValue: function (dataView, dataOffset) {
28650 return dataView.getUint8(dataOffset);
28654 // ascii, 8-bit byte:
28656 getValue: function (dataView, dataOffset) {
28657 return String.fromCharCode(dataView.getUint8(dataOffset));
28662 // short, 16 bit int:
28664 getValue: function (dataView, dataOffset, littleEndian) {
28665 return dataView.getUint16(dataOffset, littleEndian);
28669 // long, 32 bit int:
28671 getValue: function (dataView, dataOffset, littleEndian) {
28672 return dataView.getUint32(dataOffset, littleEndian);
28676 // rational = two long values, first is numerator, second is denominator:
28678 getValue: function (dataView, dataOffset, littleEndian) {
28679 return dataView.getUint32(dataOffset, littleEndian) /
28680 dataView.getUint32(dataOffset + 4, littleEndian);
28684 // slong, 32 bit signed int:
28686 getValue: function (dataView, dataOffset, littleEndian) {
28687 return dataView.getInt32(dataOffset, littleEndian);
28691 // srational, two slongs, first is numerator, second is denominator:
28693 getValue: function (dataView, dataOffset, littleEndian) {
28694 return dataView.getInt32(dataOffset, littleEndian) /
28695 dataView.getInt32(dataOffset + 4, littleEndian);
28705 cls : 'btn-group roo-upload-cropbox-rotate-left',
28706 action : 'rotate-left',
28710 cls : 'btn btn-default',
28711 html : '<i class="fa fa-undo"></i>'
28717 cls : 'btn-group roo-upload-cropbox-picture',
28718 action : 'picture',
28722 cls : 'btn btn-default',
28723 html : '<i class="fa fa-picture-o"></i>'
28729 cls : 'btn-group roo-upload-cropbox-rotate-right',
28730 action : 'rotate-right',
28734 cls : 'btn btn-default',
28735 html : '<i class="fa fa-repeat"></i>'
28743 cls : 'btn-group roo-upload-cropbox-rotate-left',
28744 action : 'rotate-left',
28748 cls : 'btn btn-default',
28749 html : '<i class="fa fa-undo"></i>'
28755 cls : 'btn-group roo-upload-cropbox-download',
28756 action : 'download',
28760 cls : 'btn btn-default',
28761 html : '<i class="fa fa-download"></i>'
28767 cls : 'btn-group roo-upload-cropbox-crop',
28772 cls : 'btn btn-default',
28773 html : '<i class="fa fa-crop"></i>'
28779 cls : 'btn-group roo-upload-cropbox-trash',
28784 cls : 'btn btn-default',
28785 html : '<i class="fa fa-trash"></i>'
28791 cls : 'btn-group roo-upload-cropbox-rotate-right',
28792 action : 'rotate-right',
28796 cls : 'btn btn-default',
28797 html : '<i class="fa fa-repeat"></i>'
28805 cls : 'btn-group roo-upload-cropbox-rotate-left',
28806 action : 'rotate-left',
28810 cls : 'btn btn-default',
28811 html : '<i class="fa fa-undo"></i>'
28817 cls : 'btn-group roo-upload-cropbox-rotate-right',
28818 action : 'rotate-right',
28822 cls : 'btn btn-default',
28823 html : '<i class="fa fa-repeat"></i>'
28836 * @class Roo.bootstrap.DocumentManager
28837 * @extends Roo.bootstrap.Component
28838 * Bootstrap DocumentManager class
28839 * @cfg {String} paramName default 'imageUpload'
28840 * @cfg {String} toolTipName default 'filename'
28841 * @cfg {String} method default POST
28842 * @cfg {String} url action url
28843 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
28844 * @cfg {Boolean} multiple multiple upload default true
28845 * @cfg {Number} thumbSize default 300
28846 * @cfg {String} fieldLabel
28847 * @cfg {Number} labelWidth default 4
28848 * @cfg {String} labelAlign (left|top) default left
28849 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
28850 * @cfg {Number} labellg set the width of label (1-12)
28851 * @cfg {Number} labelmd set the width of label (1-12)
28852 * @cfg {Number} labelsm set the width of label (1-12)
28853 * @cfg {Number} labelxs set the width of label (1-12)
28856 * Create a new DocumentManager
28857 * @param {Object} config The config object
28860 Roo.bootstrap.DocumentManager = function(config){
28861 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
28864 this.delegates = [];
28869 * Fire when initial the DocumentManager
28870 * @param {Roo.bootstrap.DocumentManager} this
28875 * inspect selected file
28876 * @param {Roo.bootstrap.DocumentManager} this
28877 * @param {File} file
28882 * Fire when xhr load exception
28883 * @param {Roo.bootstrap.DocumentManager} this
28884 * @param {XMLHttpRequest} xhr
28886 "exception" : true,
28888 * @event afterupload
28889 * Fire when xhr load exception
28890 * @param {Roo.bootstrap.DocumentManager} this
28891 * @param {XMLHttpRequest} xhr
28893 "afterupload" : true,
28896 * prepare the form data
28897 * @param {Roo.bootstrap.DocumentManager} this
28898 * @param {Object} formData
28903 * Fire when remove the file
28904 * @param {Roo.bootstrap.DocumentManager} this
28905 * @param {Object} file
28910 * Fire after refresh the file
28911 * @param {Roo.bootstrap.DocumentManager} this
28916 * Fire after click the image
28917 * @param {Roo.bootstrap.DocumentManager} this
28918 * @param {Object} file
28923 * Fire when upload a image and editable set to true
28924 * @param {Roo.bootstrap.DocumentManager} this
28925 * @param {Object} file
28929 * @event beforeselectfile
28930 * Fire before select file
28931 * @param {Roo.bootstrap.DocumentManager} this
28933 "beforeselectfile" : true,
28936 * Fire before process file
28937 * @param {Roo.bootstrap.DocumentManager} this
28938 * @param {Object} file
28942 * @event previewrendered
28943 * Fire when preview rendered
28944 * @param {Roo.bootstrap.DocumentManager} this
28945 * @param {Object} file
28947 "previewrendered" : true,
28950 "previewResize" : true
28955 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
28964 paramName : 'imageUpload',
28965 toolTipName : 'filename',
28968 labelAlign : 'left',
28978 getAutoCreate : function()
28980 var managerWidget = {
28982 cls : 'roo-document-manager',
28986 cls : 'roo-document-manager-selector',
28991 cls : 'roo-document-manager-uploader',
28995 cls : 'roo-document-manager-upload-btn',
28996 html : '<i class="fa fa-plus"></i>'
29007 cls : 'column col-md-12',
29012 if(this.fieldLabel.length){
29017 cls : 'column col-md-12',
29018 html : this.fieldLabel
29022 cls : 'column col-md-12',
29027 if(this.labelAlign == 'left'){
29032 html : this.fieldLabel
29041 if(this.labelWidth > 12){
29042 content[0].style = "width: " + this.labelWidth + 'px';
29045 if(this.labelWidth < 13 && this.labelmd == 0){
29046 this.labelmd = this.labelWidth;
29049 if(this.labellg > 0){
29050 content[0].cls += ' col-lg-' + this.labellg;
29051 content[1].cls += ' col-lg-' + (12 - this.labellg);
29054 if(this.labelmd > 0){
29055 content[0].cls += ' col-md-' + this.labelmd;
29056 content[1].cls += ' col-md-' + (12 - this.labelmd);
29059 if(this.labelsm > 0){
29060 content[0].cls += ' col-sm-' + this.labelsm;
29061 content[1].cls += ' col-sm-' + (12 - this.labelsm);
29064 if(this.labelxs > 0){
29065 content[0].cls += ' col-xs-' + this.labelxs;
29066 content[1].cls += ' col-xs-' + (12 - this.labelxs);
29074 cls : 'row clearfix',
29082 initEvents : function()
29084 this.managerEl = this.el.select('.roo-document-manager', true).first();
29085 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29087 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
29088 this.selectorEl.hide();
29091 this.selectorEl.attr('multiple', 'multiple');
29094 this.selectorEl.on('change', this.onFileSelected, this);
29096 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
29097 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29099 this.uploader.on('click', this.onUploaderClick, this);
29101 this.renderProgressDialog();
29105 window.addEventListener("resize", function() { _this.refresh(); } );
29107 this.fireEvent('initial', this);
29110 renderProgressDialog : function()
29114 this.progressDialog = new Roo.bootstrap.Modal({
29115 cls : 'roo-document-manager-progress-dialog',
29116 allow_close : false,
29126 btnclick : function() {
29127 _this.uploadCancel();
29133 this.progressDialog.render(Roo.get(document.body));
29135 this.progress = new Roo.bootstrap.Progress({
29136 cls : 'roo-document-manager-progress',
29141 this.progress.render(this.progressDialog.getChildContainer());
29143 this.progressBar = new Roo.bootstrap.ProgressBar({
29144 cls : 'roo-document-manager-progress-bar',
29147 aria_valuemax : 12,
29151 this.progressBar.render(this.progress.getChildContainer());
29154 onUploaderClick : function(e)
29156 e.preventDefault();
29158 if(this.fireEvent('beforeselectfile', this) != false){
29159 this.selectorEl.dom.click();
29164 onFileSelected : function(e)
29166 e.preventDefault();
29168 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
29172 Roo.each(this.selectorEl.dom.files, function(file){
29173 if(this.fireEvent('inspect', this, file) != false){
29174 this.files.push(file);
29184 this.selectorEl.dom.value = '';
29186 if(!this.files || !this.files.length){
29190 if(this.boxes > 0 && this.files.length > this.boxes){
29191 this.files = this.files.slice(0, this.boxes);
29194 this.uploader.show();
29196 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29197 this.uploader.hide();
29206 Roo.each(this.files, function(file){
29208 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29209 var f = this.renderPreview(file);
29214 if(file.type.indexOf('image') != -1){
29215 this.delegates.push(
29217 _this.process(file);
29218 }).createDelegate(this)
29226 _this.process(file);
29227 }).createDelegate(this)
29232 this.files = files;
29234 this.delegates = this.delegates.concat(docs);
29236 if(!this.delegates.length){
29241 this.progressBar.aria_valuemax = this.delegates.length;
29248 arrange : function()
29250 if(!this.delegates.length){
29251 this.progressDialog.hide();
29256 var delegate = this.delegates.shift();
29258 this.progressDialog.show();
29260 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
29262 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
29267 refresh : function()
29269 this.uploader.show();
29271 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29272 this.uploader.hide();
29275 Roo.isTouch ? this.closable(false) : this.closable(true);
29277 this.fireEvent('refresh', this);
29280 onRemove : function(e, el, o)
29282 e.preventDefault();
29284 this.fireEvent('remove', this, o);
29288 remove : function(o)
29292 Roo.each(this.files, function(file){
29293 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
29302 this.files = files;
29309 Roo.each(this.files, function(file){
29314 file.target.remove();
29323 onClick : function(e, el, o)
29325 e.preventDefault();
29327 this.fireEvent('click', this, o);
29331 closable : function(closable)
29333 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
29335 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29347 xhrOnLoad : function(xhr)
29349 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29353 if (xhr.readyState !== 4) {
29355 this.fireEvent('exception', this, xhr);
29359 var response = Roo.decode(xhr.responseText);
29361 if(!response.success){
29363 this.fireEvent('exception', this, xhr);
29367 var file = this.renderPreview(response.data);
29369 this.files.push(file);
29373 this.fireEvent('afterupload', this, xhr);
29377 xhrOnError : function(xhr)
29379 Roo.log('xhr on error');
29381 var response = Roo.decode(xhr.responseText);
29388 process : function(file)
29390 if(this.fireEvent('process', this, file) !== false){
29391 if(this.editable && file.type.indexOf('image') != -1){
29392 this.fireEvent('edit', this, file);
29396 this.uploadStart(file, false);
29403 uploadStart : function(file, crop)
29405 this.xhr = new XMLHttpRequest();
29407 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29412 file.xhr = this.xhr;
29414 this.managerEl.createChild({
29416 cls : 'roo-document-manager-loading',
29420 tooltip : file.name,
29421 cls : 'roo-document-manager-thumb',
29422 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29428 this.xhr.open(this.method, this.url, true);
29431 "Accept": "application/json",
29432 "Cache-Control": "no-cache",
29433 "X-Requested-With": "XMLHttpRequest"
29436 for (var headerName in headers) {
29437 var headerValue = headers[headerName];
29439 this.xhr.setRequestHeader(headerName, headerValue);
29445 this.xhr.onload = function()
29447 _this.xhrOnLoad(_this.xhr);
29450 this.xhr.onerror = function()
29452 _this.xhrOnError(_this.xhr);
29455 var formData = new FormData();
29457 formData.append('returnHTML', 'NO');
29460 formData.append('crop', crop);
29463 formData.append(this.paramName, file, file.name);
29470 if(this.fireEvent('prepare', this, formData, options) != false){
29472 if(options.manually){
29476 this.xhr.send(formData);
29480 this.uploadCancel();
29483 uploadCancel : function()
29489 this.delegates = [];
29491 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29498 renderPreview : function(file)
29500 if(typeof(file.target) != 'undefined' && file.target){
29504 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
29506 var previewEl = this.managerEl.createChild({
29508 cls : 'roo-document-manager-preview',
29512 tooltip : file[this.toolTipName],
29513 cls : 'roo-document-manager-thumb',
29514 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
29519 html : '<i class="fa fa-times-circle"></i>'
29524 var close = previewEl.select('button.close', true).first();
29526 close.on('click', this.onRemove, this, file);
29528 file.target = previewEl;
29530 var image = previewEl.select('img', true).first();
29534 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
29536 image.on('click', this.onClick, this, file);
29538 this.fireEvent('previewrendered', this, file);
29544 onPreviewLoad : function(file, image)
29546 if(typeof(file.target) == 'undefined' || !file.target){
29550 var width = image.dom.naturalWidth || image.dom.width;
29551 var height = image.dom.naturalHeight || image.dom.height;
29553 if(!this.previewResize) {
29557 if(width > height){
29558 file.target.addClass('wide');
29562 file.target.addClass('tall');
29567 uploadFromSource : function(file, crop)
29569 this.xhr = new XMLHttpRequest();
29571 this.managerEl.createChild({
29573 cls : 'roo-document-manager-loading',
29577 tooltip : file.name,
29578 cls : 'roo-document-manager-thumb',
29579 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29585 this.xhr.open(this.method, this.url, true);
29588 "Accept": "application/json",
29589 "Cache-Control": "no-cache",
29590 "X-Requested-With": "XMLHttpRequest"
29593 for (var headerName in headers) {
29594 var headerValue = headers[headerName];
29596 this.xhr.setRequestHeader(headerName, headerValue);
29602 this.xhr.onload = function()
29604 _this.xhrOnLoad(_this.xhr);
29607 this.xhr.onerror = function()
29609 _this.xhrOnError(_this.xhr);
29612 var formData = new FormData();
29614 formData.append('returnHTML', 'NO');
29616 formData.append('crop', crop);
29618 if(typeof(file.filename) != 'undefined'){
29619 formData.append('filename', file.filename);
29622 if(typeof(file.mimetype) != 'undefined'){
29623 formData.append('mimetype', file.mimetype);
29628 if(this.fireEvent('prepare', this, formData) != false){
29629 this.xhr.send(formData);
29639 * @class Roo.bootstrap.DocumentViewer
29640 * @extends Roo.bootstrap.Component
29641 * Bootstrap DocumentViewer class
29642 * @cfg {Boolean} showDownload (true|false) show download button (default true)
29643 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
29646 * Create a new DocumentViewer
29647 * @param {Object} config The config object
29650 Roo.bootstrap.DocumentViewer = function(config){
29651 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
29656 * Fire after initEvent
29657 * @param {Roo.bootstrap.DocumentViewer} this
29663 * @param {Roo.bootstrap.DocumentViewer} this
29668 * Fire after download button
29669 * @param {Roo.bootstrap.DocumentViewer} this
29674 * Fire after trash button
29675 * @param {Roo.bootstrap.DocumentViewer} this
29682 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
29684 showDownload : true,
29688 getAutoCreate : function()
29692 cls : 'roo-document-viewer',
29696 cls : 'roo-document-viewer-body',
29700 cls : 'roo-document-viewer-thumb',
29704 cls : 'roo-document-viewer-image'
29712 cls : 'roo-document-viewer-footer',
29715 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
29719 cls : 'btn-group roo-document-viewer-download',
29723 cls : 'btn btn-default',
29724 html : '<i class="fa fa-download"></i>'
29730 cls : 'btn-group roo-document-viewer-trash',
29734 cls : 'btn btn-default',
29735 html : '<i class="fa fa-trash"></i>'
29748 initEvents : function()
29750 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
29751 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
29753 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
29754 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
29756 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
29757 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
29759 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
29760 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
29762 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
29763 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
29765 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
29766 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
29768 this.bodyEl.on('click', this.onClick, this);
29769 this.downloadBtn.on('click', this.onDownload, this);
29770 this.trashBtn.on('click', this.onTrash, this);
29772 this.downloadBtn.hide();
29773 this.trashBtn.hide();
29775 if(this.showDownload){
29776 this.downloadBtn.show();
29779 if(this.showTrash){
29780 this.trashBtn.show();
29783 if(!this.showDownload && !this.showTrash) {
29784 this.footerEl.hide();
29789 initial : function()
29791 this.fireEvent('initial', this);
29795 onClick : function(e)
29797 e.preventDefault();
29799 this.fireEvent('click', this);
29802 onDownload : function(e)
29804 e.preventDefault();
29806 this.fireEvent('download', this);
29809 onTrash : function(e)
29811 e.preventDefault();
29813 this.fireEvent('trash', this);
29825 * @class Roo.bootstrap.NavProgressBar
29826 * @extends Roo.bootstrap.Component
29827 * Bootstrap NavProgressBar class
29830 * Create a new nav progress bar
29831 * @param {Object} config The config object
29834 Roo.bootstrap.NavProgressBar = function(config){
29835 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
29837 this.bullets = this.bullets || [];
29839 // Roo.bootstrap.NavProgressBar.register(this);
29843 * Fires when the active item changes
29844 * @param {Roo.bootstrap.NavProgressBar} this
29845 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
29846 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
29853 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
29858 getAutoCreate : function()
29860 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
29864 cls : 'roo-navigation-bar-group',
29868 cls : 'roo-navigation-top-bar'
29872 cls : 'roo-navigation-bullets-bar',
29876 cls : 'roo-navigation-bar'
29883 cls : 'roo-navigation-bottom-bar'
29893 initEvents: function()
29898 onRender : function(ct, position)
29900 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
29902 if(this.bullets.length){
29903 Roo.each(this.bullets, function(b){
29912 addItem : function(cfg)
29914 var item = new Roo.bootstrap.NavProgressItem(cfg);
29916 item.parentId = this.id;
29917 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
29920 var top = new Roo.bootstrap.Element({
29922 cls : 'roo-navigation-bar-text'
29925 var bottom = new Roo.bootstrap.Element({
29927 cls : 'roo-navigation-bar-text'
29930 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
29931 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
29933 var topText = new Roo.bootstrap.Element({
29935 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
29938 var bottomText = new Roo.bootstrap.Element({
29940 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
29943 topText.onRender(top.el, null);
29944 bottomText.onRender(bottom.el, null);
29947 item.bottomEl = bottom;
29950 this.barItems.push(item);
29955 getActive : function()
29957 var active = false;
29959 Roo.each(this.barItems, function(v){
29961 if (!v.isActive()) {
29973 setActiveItem : function(item)
29977 Roo.each(this.barItems, function(v){
29978 if (v.rid == item.rid) {
29982 if (v.isActive()) {
29983 v.setActive(false);
29988 item.setActive(true);
29990 this.fireEvent('changed', this, item, prev);
29993 getBarItem: function(rid)
29997 Roo.each(this.barItems, function(e) {
29998 if (e.rid != rid) {
30009 indexOfItem : function(item)
30013 Roo.each(this.barItems, function(v, i){
30015 if (v.rid != item.rid) {
30026 setActiveNext : function()
30028 var i = this.indexOfItem(this.getActive());
30030 if (i > this.barItems.length) {
30034 this.setActiveItem(this.barItems[i+1]);
30037 setActivePrev : function()
30039 var i = this.indexOfItem(this.getActive());
30045 this.setActiveItem(this.barItems[i-1]);
30048 format : function()
30050 if(!this.barItems.length){
30054 var width = 100 / this.barItems.length;
30056 Roo.each(this.barItems, function(i){
30057 i.el.setStyle('width', width + '%');
30058 i.topEl.el.setStyle('width', width + '%');
30059 i.bottomEl.el.setStyle('width', width + '%');
30068 * Nav Progress Item
30073 * @class Roo.bootstrap.NavProgressItem
30074 * @extends Roo.bootstrap.Component
30075 * Bootstrap NavProgressItem class
30076 * @cfg {String} rid the reference id
30077 * @cfg {Boolean} active (true|false) Is item active default false
30078 * @cfg {Boolean} disabled (true|false) Is item active default false
30079 * @cfg {String} html
30080 * @cfg {String} position (top|bottom) text position default bottom
30081 * @cfg {String} icon show icon instead of number
30084 * Create a new NavProgressItem
30085 * @param {Object} config The config object
30087 Roo.bootstrap.NavProgressItem = function(config){
30088 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
30093 * The raw click event for the entire grid.
30094 * @param {Roo.bootstrap.NavProgressItem} this
30095 * @param {Roo.EventObject} e
30102 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
30108 position : 'bottom',
30111 getAutoCreate : function()
30113 var iconCls = 'roo-navigation-bar-item-icon';
30115 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
30119 cls: 'roo-navigation-bar-item',
30129 cfg.cls += ' active';
30132 cfg.cls += ' disabled';
30138 disable : function()
30140 this.setDisabled(true);
30143 enable : function()
30145 this.setDisabled(false);
30148 initEvents: function()
30150 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
30152 this.iconEl.on('click', this.onClick, this);
30155 onClick : function(e)
30157 e.preventDefault();
30163 if(this.fireEvent('click', this, e) === false){
30167 this.parent().setActiveItem(this);
30170 isActive: function ()
30172 return this.active;
30175 setActive : function(state)
30177 if(this.active == state){
30181 this.active = state;
30184 this.el.addClass('active');
30188 this.el.removeClass('active');
30193 setDisabled : function(state)
30195 if(this.disabled == state){
30199 this.disabled = state;
30202 this.el.addClass('disabled');
30206 this.el.removeClass('disabled');
30209 tooltipEl : function()
30211 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
30224 * @class Roo.bootstrap.FieldLabel
30225 * @extends Roo.bootstrap.Component
30226 * Bootstrap FieldLabel class
30227 * @cfg {String} html contents of the element
30228 * @cfg {String} tag tag of the element default label
30229 * @cfg {String} cls class of the element
30230 * @cfg {String} target label target
30231 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
30232 * @cfg {String} invalidClass default "text-warning"
30233 * @cfg {String} validClass default "text-success"
30234 * @cfg {String} iconTooltip default "This field is required"
30235 * @cfg {String} indicatorpos (left|right) default left
30238 * Create a new FieldLabel
30239 * @param {Object} config The config object
30242 Roo.bootstrap.FieldLabel = function(config){
30243 Roo.bootstrap.Element.superclass.constructor.call(this, config);
30248 * Fires after the field has been marked as invalid.
30249 * @param {Roo.form.FieldLabel} this
30250 * @param {String} msg The validation message
30255 * Fires after the field has been validated with no errors.
30256 * @param {Roo.form.FieldLabel} this
30262 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
30269 invalidClass : 'has-warning',
30270 validClass : 'has-success',
30271 iconTooltip : 'This field is required',
30272 indicatorpos : 'left',
30274 getAutoCreate : function(){
30277 if (!this.allowBlank) {
30283 cls : 'roo-bootstrap-field-label ' + this.cls,
30288 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star ' + cls,
30289 tooltip : this.iconTooltip
30298 if(this.indicatorpos == 'right'){
30301 cls : 'roo-bootstrap-field-label ' + this.cls,
30310 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star '+ cls,
30311 tooltip : this.iconTooltip
30320 initEvents: function()
30322 Roo.bootstrap.Element.superclass.initEvents.call(this);
30324 this.indicator = this.indicatorEl();
30326 if(this.indicator){
30327 this.indicator.removeClass('visible');
30328 this.indicator.addClass('invisible');
30331 Roo.bootstrap.FieldLabel.register(this);
30334 indicatorEl : function()
30336 var indicator = this.el.select('i.roo-required-indicator',true).first();
30347 * Mark this field as valid
30349 markValid : function()
30351 if(this.indicator){
30352 this.indicator.removeClass('visible');
30353 this.indicator.addClass('invisible');
30356 this.el.removeClass(this.invalidClass);
30358 this.el.addClass(this.validClass);
30360 this.fireEvent('valid', this);
30364 * Mark this field as invalid
30365 * @param {String} msg The validation message
30367 markInvalid : function(msg)
30369 if(this.indicator){
30370 this.indicator.removeClass('invisible');
30371 this.indicator.addClass('visible');
30374 this.el.removeClass(this.validClass);
30376 this.el.addClass(this.invalidClass);
30378 this.fireEvent('invalid', this, msg);
30384 Roo.apply(Roo.bootstrap.FieldLabel, {
30389 * register a FieldLabel Group
30390 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
30392 register : function(label)
30394 if(this.groups.hasOwnProperty(label.target)){
30398 this.groups[label.target] = label;
30402 * fetch a FieldLabel Group based on the target
30403 * @param {string} target
30404 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
30406 get: function(target) {
30407 if (typeof(this.groups[target]) == 'undefined') {
30411 return this.groups[target] ;
30420 * page DateSplitField.
30426 * @class Roo.bootstrap.DateSplitField
30427 * @extends Roo.bootstrap.Component
30428 * Bootstrap DateSplitField class
30429 * @cfg {string} fieldLabel - the label associated
30430 * @cfg {Number} labelWidth set the width of label (0-12)
30431 * @cfg {String} labelAlign (top|left)
30432 * @cfg {Boolean} dayAllowBlank (true|false) default false
30433 * @cfg {Boolean} monthAllowBlank (true|false) default false
30434 * @cfg {Boolean} yearAllowBlank (true|false) default false
30435 * @cfg {string} dayPlaceholder
30436 * @cfg {string} monthPlaceholder
30437 * @cfg {string} yearPlaceholder
30438 * @cfg {string} dayFormat default 'd'
30439 * @cfg {string} monthFormat default 'm'
30440 * @cfg {string} yearFormat default 'Y'
30441 * @cfg {Number} labellg set the width of label (1-12)
30442 * @cfg {Number} labelmd set the width of label (1-12)
30443 * @cfg {Number} labelsm set the width of label (1-12)
30444 * @cfg {Number} labelxs set the width of label (1-12)
30448 * Create a new DateSplitField
30449 * @param {Object} config The config object
30452 Roo.bootstrap.DateSplitField = function(config){
30453 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
30459 * getting the data of years
30460 * @param {Roo.bootstrap.DateSplitField} this
30461 * @param {Object} years
30466 * getting the data of days
30467 * @param {Roo.bootstrap.DateSplitField} this
30468 * @param {Object} days
30473 * Fires after the field has been marked as invalid.
30474 * @param {Roo.form.Field} this
30475 * @param {String} msg The validation message
30480 * Fires after the field has been validated with no errors.
30481 * @param {Roo.form.Field} this
30487 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
30490 labelAlign : 'top',
30492 dayAllowBlank : false,
30493 monthAllowBlank : false,
30494 yearAllowBlank : false,
30495 dayPlaceholder : '',
30496 monthPlaceholder : '',
30497 yearPlaceholder : '',
30501 isFormField : true,
30507 getAutoCreate : function()
30511 cls : 'row roo-date-split-field-group',
30516 cls : 'form-hidden-field roo-date-split-field-group-value',
30522 var labelCls = 'col-md-12';
30523 var contentCls = 'col-md-4';
30525 if(this.fieldLabel){
30529 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
30533 html : this.fieldLabel
30538 if(this.labelAlign == 'left'){
30540 if(this.labelWidth > 12){
30541 label.style = "width: " + this.labelWidth + 'px';
30544 if(this.labelWidth < 13 && this.labelmd == 0){
30545 this.labelmd = this.labelWidth;
30548 if(this.labellg > 0){
30549 labelCls = ' col-lg-' + this.labellg;
30550 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
30553 if(this.labelmd > 0){
30554 labelCls = ' col-md-' + this.labelmd;
30555 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
30558 if(this.labelsm > 0){
30559 labelCls = ' col-sm-' + this.labelsm;
30560 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
30563 if(this.labelxs > 0){
30564 labelCls = ' col-xs-' + this.labelxs;
30565 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
30569 label.cls += ' ' + labelCls;
30571 cfg.cn.push(label);
30574 Roo.each(['day', 'month', 'year'], function(t){
30577 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
30584 inputEl: function ()
30586 return this.el.select('.roo-date-split-field-group-value', true).first();
30589 onRender : function(ct, position)
30593 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30595 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
30597 this.dayField = new Roo.bootstrap.ComboBox({
30598 allowBlank : this.dayAllowBlank,
30599 alwaysQuery : true,
30600 displayField : 'value',
30603 forceSelection : true,
30605 placeholder : this.dayPlaceholder,
30606 selectOnFocus : true,
30607 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30608 triggerAction : 'all',
30610 valueField : 'value',
30611 store : new Roo.data.SimpleStore({
30612 data : (function() {
30614 _this.fireEvent('days', _this, days);
30617 fields : [ 'value' ]
30620 select : function (_self, record, index)
30622 _this.setValue(_this.getValue());
30627 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
30629 this.monthField = new Roo.bootstrap.MonthField({
30630 after : '<i class=\"fa fa-calendar\"></i>',
30631 allowBlank : this.monthAllowBlank,
30632 placeholder : this.monthPlaceholder,
30635 render : function (_self)
30637 this.el.select('span.input-group-addon', true).first().on('click', function(e){
30638 e.preventDefault();
30642 select : function (_self, oldvalue, newvalue)
30644 _this.setValue(_this.getValue());
30649 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
30651 this.yearField = new Roo.bootstrap.ComboBox({
30652 allowBlank : this.yearAllowBlank,
30653 alwaysQuery : true,
30654 displayField : 'value',
30657 forceSelection : true,
30659 placeholder : this.yearPlaceholder,
30660 selectOnFocus : true,
30661 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30662 triggerAction : 'all',
30664 valueField : 'value',
30665 store : new Roo.data.SimpleStore({
30666 data : (function() {
30668 _this.fireEvent('years', _this, years);
30671 fields : [ 'value' ]
30674 select : function (_self, record, index)
30676 _this.setValue(_this.getValue());
30681 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
30684 setValue : function(v, format)
30686 this.inputEl.dom.value = v;
30688 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
30690 var d = Date.parseDate(v, f);
30697 this.setDay(d.format(this.dayFormat));
30698 this.setMonth(d.format(this.monthFormat));
30699 this.setYear(d.format(this.yearFormat));
30706 setDay : function(v)
30708 this.dayField.setValue(v);
30709 this.inputEl.dom.value = this.getValue();
30714 setMonth : function(v)
30716 this.monthField.setValue(v, true);
30717 this.inputEl.dom.value = this.getValue();
30722 setYear : function(v)
30724 this.yearField.setValue(v);
30725 this.inputEl.dom.value = this.getValue();
30730 getDay : function()
30732 return this.dayField.getValue();
30735 getMonth : function()
30737 return this.monthField.getValue();
30740 getYear : function()
30742 return this.yearField.getValue();
30745 getValue : function()
30747 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
30749 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
30759 this.inputEl.dom.value = '';
30764 validate : function()
30766 var d = this.dayField.validate();
30767 var m = this.monthField.validate();
30768 var y = this.yearField.validate();
30773 (!this.dayAllowBlank && !d) ||
30774 (!this.monthAllowBlank && !m) ||
30775 (!this.yearAllowBlank && !y)
30780 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
30789 this.markInvalid();
30794 markValid : function()
30797 var label = this.el.select('label', true).first();
30798 var icon = this.el.select('i.fa-star', true).first();
30804 this.fireEvent('valid', this);
30808 * Mark this field as invalid
30809 * @param {String} msg The validation message
30811 markInvalid : function(msg)
30814 var label = this.el.select('label', true).first();
30815 var icon = this.el.select('i.fa-star', true).first();
30817 if(label && !icon){
30818 this.el.select('.roo-date-split-field-label', true).createChild({
30820 cls : 'text-danger fa fa-lg fa-star',
30821 tooltip : 'This field is required',
30822 style : 'margin-right:5px;'
30826 this.fireEvent('invalid', this, msg);
30829 clearInvalid : function()
30831 var label = this.el.select('label', true).first();
30832 var icon = this.el.select('i.fa-star', true).first();
30838 this.fireEvent('valid', this);
30841 getName: function()
30851 * http://masonry.desandro.com
30853 * The idea is to render all the bricks based on vertical width...
30855 * The original code extends 'outlayer' - we might need to use that....
30861 * @class Roo.bootstrap.LayoutMasonry
30862 * @extends Roo.bootstrap.Component
30863 * Bootstrap Layout Masonry class
30866 * Create a new Element
30867 * @param {Object} config The config object
30870 Roo.bootstrap.LayoutMasonry = function(config){
30872 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
30876 Roo.bootstrap.LayoutMasonry.register(this);
30882 * Fire after layout the items
30883 * @param {Roo.bootstrap.LayoutMasonry} this
30884 * @param {Roo.EventObject} e
30891 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
30894 * @cfg {Boolean} isLayoutInstant = no animation?
30896 isLayoutInstant : false, // needed?
30899 * @cfg {Number} boxWidth width of the columns
30904 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
30909 * @cfg {Number} padWidth padding below box..
30914 * @cfg {Number} gutter gutter width..
30919 * @cfg {Number} maxCols maximum number of columns
30925 * @cfg {Boolean} isAutoInitial defalut true
30927 isAutoInitial : true,
30932 * @cfg {Boolean} isHorizontal defalut false
30934 isHorizontal : false,
30936 currentSize : null,
30942 bricks: null, //CompositeElement
30946 _isLayoutInited : false,
30948 // isAlternative : false, // only use for vertical layout...
30951 * @cfg {Number} alternativePadWidth padding below box..
30953 alternativePadWidth : 50,
30955 selectedBrick : [],
30957 getAutoCreate : function(){
30959 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
30963 cls: 'blog-masonary-wrapper ' + this.cls,
30965 cls : 'mas-boxes masonary'
30972 getChildContainer: function( )
30974 if (this.boxesEl) {
30975 return this.boxesEl;
30978 this.boxesEl = this.el.select('.mas-boxes').first();
30980 return this.boxesEl;
30984 initEvents : function()
30988 if(this.isAutoInitial){
30989 Roo.log('hook children rendered');
30990 this.on('childrenrendered', function() {
30991 Roo.log('children rendered');
30997 initial : function()
30999 this.selectedBrick = [];
31001 this.currentSize = this.el.getBox(true);
31003 Roo.EventManager.onWindowResize(this.resize, this);
31005 if(!this.isAutoInitial){
31013 //this.layout.defer(500,this);
31017 resize : function()
31019 var cs = this.el.getBox(true);
31022 this.currentSize.width == cs.width &&
31023 this.currentSize.x == cs.x &&
31024 this.currentSize.height == cs.height &&
31025 this.currentSize.y == cs.y
31027 Roo.log("no change in with or X or Y");
31031 this.currentSize = cs;
31037 layout : function()
31039 this._resetLayout();
31041 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
31043 this.layoutItems( isInstant );
31045 this._isLayoutInited = true;
31047 this.fireEvent('layout', this);
31051 _resetLayout : function()
31053 if(this.isHorizontal){
31054 this.horizontalMeasureColumns();
31058 this.verticalMeasureColumns();
31062 verticalMeasureColumns : function()
31064 this.getContainerWidth();
31066 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31067 // this.colWidth = Math.floor(this.containerWidth * 0.8);
31071 var boxWidth = this.boxWidth + this.padWidth;
31073 if(this.containerWidth < this.boxWidth){
31074 boxWidth = this.containerWidth
31077 var containerWidth = this.containerWidth;
31079 var cols = Math.floor(containerWidth / boxWidth);
31081 this.cols = Math.max( cols, 1 );
31083 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
31085 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
31087 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
31089 this.colWidth = boxWidth + avail - this.padWidth;
31091 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
31092 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
31095 horizontalMeasureColumns : function()
31097 this.getContainerWidth();
31099 var boxWidth = this.boxWidth;
31101 if(this.containerWidth < boxWidth){
31102 boxWidth = this.containerWidth;
31105 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
31107 this.el.setHeight(boxWidth);
31111 getContainerWidth : function()
31113 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
31116 layoutItems : function( isInstant )
31118 Roo.log(this.bricks);
31120 var items = Roo.apply([], this.bricks);
31122 if(this.isHorizontal){
31123 this._horizontalLayoutItems( items , isInstant );
31127 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31128 // this._verticalAlternativeLayoutItems( items , isInstant );
31132 this._verticalLayoutItems( items , isInstant );
31136 _verticalLayoutItems : function ( items , isInstant)
31138 if ( !items || !items.length ) {
31143 ['xs', 'xs', 'xs', 'tall'],
31144 ['xs', 'xs', 'tall'],
31145 ['xs', 'xs', 'sm'],
31146 ['xs', 'xs', 'xs'],
31152 ['sm', 'xs', 'xs'],
31156 ['tall', 'xs', 'xs', 'xs'],
31157 ['tall', 'xs', 'xs'],
31169 Roo.each(items, function(item, k){
31171 switch (item.size) {
31172 // these layouts take up a full box,
31183 boxes.push([item]);
31206 var filterPattern = function(box, length)
31214 var pattern = box.slice(0, length);
31218 Roo.each(pattern, function(i){
31219 format.push(i.size);
31222 Roo.each(standard, function(s){
31224 if(String(s) != String(format)){
31233 if(!match && length == 1){
31238 filterPattern(box, length - 1);
31242 queue.push(pattern);
31244 box = box.slice(length, box.length);
31246 filterPattern(box, 4);
31252 Roo.each(boxes, function(box, k){
31258 if(box.length == 1){
31263 filterPattern(box, 4);
31267 this._processVerticalLayoutQueue( queue, isInstant );
31271 // _verticalAlternativeLayoutItems : function( items , isInstant )
31273 // if ( !items || !items.length ) {
31277 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
31281 _horizontalLayoutItems : function ( items , isInstant)
31283 if ( !items || !items.length || items.length < 3) {
31289 var eItems = items.slice(0, 3);
31291 items = items.slice(3, items.length);
31294 ['xs', 'xs', 'xs', 'wide'],
31295 ['xs', 'xs', 'wide'],
31296 ['xs', 'xs', 'sm'],
31297 ['xs', 'xs', 'xs'],
31303 ['sm', 'xs', 'xs'],
31307 ['wide', 'xs', 'xs', 'xs'],
31308 ['wide', 'xs', 'xs'],
31321 Roo.each(items, function(item, k){
31323 switch (item.size) {
31334 boxes.push([item]);
31358 var filterPattern = function(box, length)
31366 var pattern = box.slice(0, length);
31370 Roo.each(pattern, function(i){
31371 format.push(i.size);
31374 Roo.each(standard, function(s){
31376 if(String(s) != String(format)){
31385 if(!match && length == 1){
31390 filterPattern(box, length - 1);
31394 queue.push(pattern);
31396 box = box.slice(length, box.length);
31398 filterPattern(box, 4);
31404 Roo.each(boxes, function(box, k){
31410 if(box.length == 1){
31415 filterPattern(box, 4);
31422 var pos = this.el.getBox(true);
31426 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31428 var hit_end = false;
31430 Roo.each(queue, function(box){
31434 Roo.each(box, function(b){
31436 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31446 Roo.each(box, function(b){
31448 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31451 mx = Math.max(mx, b.x);
31455 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
31459 Roo.each(box, function(b){
31461 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31475 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
31478 /** Sets position of item in DOM
31479 * @param {Element} item
31480 * @param {Number} x - horizontal position
31481 * @param {Number} y - vertical position
31482 * @param {Boolean} isInstant - disables transitions
31484 _processVerticalLayoutQueue : function( queue, isInstant )
31486 var pos = this.el.getBox(true);
31491 for (var i = 0; i < this.cols; i++){
31495 Roo.each(queue, function(box, k){
31497 var col = k % this.cols;
31499 Roo.each(box, function(b,kk){
31501 b.el.position('absolute');
31503 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31504 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31506 if(b.size == 'md-left' || b.size == 'md-right'){
31507 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31508 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31511 b.el.setWidth(width);
31512 b.el.setHeight(height);
31514 b.el.select('iframe',true).setSize(width,height);
31518 for (var i = 0; i < this.cols; i++){
31520 if(maxY[i] < maxY[col]){
31525 col = Math.min(col, i);
31529 x = pos.x + col * (this.colWidth + this.padWidth);
31533 var positions = [];
31535 switch (box.length){
31537 positions = this.getVerticalOneBoxColPositions(x, y, box);
31540 positions = this.getVerticalTwoBoxColPositions(x, y, box);
31543 positions = this.getVerticalThreeBoxColPositions(x, y, box);
31546 positions = this.getVerticalFourBoxColPositions(x, y, box);
31552 Roo.each(box, function(b,kk){
31554 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31556 var sz = b.el.getSize();
31558 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
31566 for (var i = 0; i < this.cols; i++){
31567 mY = Math.max(mY, maxY[i]);
31570 this.el.setHeight(mY - pos.y);
31574 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
31576 // var pos = this.el.getBox(true);
31579 // var maxX = pos.right;
31581 // var maxHeight = 0;
31583 // Roo.each(items, function(item, k){
31587 // item.el.position('absolute');
31589 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
31591 // item.el.setWidth(width);
31593 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
31595 // item.el.setHeight(height);
31598 // item.el.setXY([x, y], isInstant ? false : true);
31600 // item.el.setXY([maxX - width, y], isInstant ? false : true);
31603 // y = y + height + this.alternativePadWidth;
31605 // maxHeight = maxHeight + height + this.alternativePadWidth;
31609 // this.el.setHeight(maxHeight);
31613 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
31615 var pos = this.el.getBox(true);
31620 var maxX = pos.right;
31622 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
31624 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31626 Roo.each(queue, function(box, k){
31628 Roo.each(box, function(b, kk){
31630 b.el.position('absolute');
31632 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31633 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31635 if(b.size == 'md-left' || b.size == 'md-right'){
31636 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31637 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31640 b.el.setWidth(width);
31641 b.el.setHeight(height);
31649 var positions = [];
31651 switch (box.length){
31653 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
31656 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
31659 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
31662 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
31668 Roo.each(box, function(b,kk){
31670 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31672 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
31680 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
31682 Roo.each(eItems, function(b,k){
31684 b.size = (k == 0) ? 'sm' : 'xs';
31685 b.x = (k == 0) ? 2 : 1;
31686 b.y = (k == 0) ? 2 : 1;
31688 b.el.position('absolute');
31690 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31692 b.el.setWidth(width);
31694 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31696 b.el.setHeight(height);
31700 var positions = [];
31703 x : maxX - this.unitWidth * 2 - this.gutter,
31708 x : maxX - this.unitWidth,
31709 y : minY + (this.unitWidth + this.gutter) * 2
31713 x : maxX - this.unitWidth * 3 - this.gutter * 2,
31717 Roo.each(eItems, function(b,k){
31719 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
31725 getVerticalOneBoxColPositions : function(x, y, box)
31729 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
31731 if(box[0].size == 'md-left'){
31735 if(box[0].size == 'md-right'){
31740 x : x + (this.unitWidth + this.gutter) * rand,
31747 getVerticalTwoBoxColPositions : function(x, y, box)
31751 if(box[0].size == 'xs'){
31755 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
31759 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
31773 x : x + (this.unitWidth + this.gutter) * 2,
31774 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
31781 getVerticalThreeBoxColPositions : function(x, y, box)
31785 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
31793 x : x + (this.unitWidth + this.gutter) * 1,
31798 x : x + (this.unitWidth + this.gutter) * 2,
31806 if(box[0].size == 'xs' && box[1].size == 'xs'){
31815 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
31819 x : x + (this.unitWidth + this.gutter) * 1,
31833 x : x + (this.unitWidth + this.gutter) * 2,
31838 x : x + (this.unitWidth + this.gutter) * 2,
31839 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
31846 getVerticalFourBoxColPositions : function(x, y, box)
31850 if(box[0].size == 'xs'){
31859 y : y + (this.unitHeight + this.gutter) * 1
31864 y : y + (this.unitHeight + this.gutter) * 2
31868 x : x + (this.unitWidth + this.gutter) * 1,
31882 x : x + (this.unitWidth + this.gutter) * 2,
31887 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
31888 y : y + (this.unitHeight + this.gutter) * 1
31892 x : x + (this.unitWidth + this.gutter) * 2,
31893 y : y + (this.unitWidth + this.gutter) * 2
31900 getHorizontalOneBoxColPositions : function(maxX, minY, box)
31904 if(box[0].size == 'md-left'){
31906 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
31913 if(box[0].size == 'md-right'){
31915 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
31916 y : minY + (this.unitWidth + this.gutter) * 1
31922 var rand = Math.floor(Math.random() * (4 - box[0].y));
31925 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31926 y : minY + (this.unitWidth + this.gutter) * rand
31933 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
31937 if(box[0].size == 'xs'){
31940 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31945 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31946 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
31954 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31959 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31960 y : minY + (this.unitWidth + this.gutter) * 2
31967 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
31971 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
31974 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31979 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31980 y : minY + (this.unitWidth + this.gutter) * 1
31984 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31985 y : minY + (this.unitWidth + this.gutter) * 2
31992 if(box[0].size == 'xs' && box[1].size == 'xs'){
31995 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32000 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32005 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32006 y : minY + (this.unitWidth + this.gutter) * 1
32014 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32019 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32020 y : minY + (this.unitWidth + this.gutter) * 2
32024 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32025 y : minY + (this.unitWidth + this.gutter) * 2
32032 getHorizontalFourBoxColPositions : function(maxX, minY, box)
32036 if(box[0].size == 'xs'){
32039 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32044 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32049 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),
32054 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
32055 y : minY + (this.unitWidth + this.gutter) * 1
32063 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32068 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32069 y : minY + (this.unitWidth + this.gutter) * 2
32073 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32074 y : minY + (this.unitWidth + this.gutter) * 2
32078 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),
32079 y : minY + (this.unitWidth + this.gutter) * 2
32087 * remove a Masonry Brick
32088 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
32090 removeBrick : function(brick_id)
32096 for (var i = 0; i<this.bricks.length; i++) {
32097 if (this.bricks[i].id == brick_id) {
32098 this.bricks.splice(i,1);
32099 this.el.dom.removeChild(Roo.get(brick_id).dom);
32106 * adds a Masonry Brick
32107 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32109 addBrick : function(cfg)
32111 var cn = new Roo.bootstrap.MasonryBrick(cfg);
32112 //this.register(cn);
32113 cn.parentId = this.id;
32114 cn.render(this.el);
32119 * register a Masonry Brick
32120 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32123 register : function(brick)
32125 this.bricks.push(brick);
32126 brick.masonryId = this.id;
32130 * clear all the Masonry Brick
32132 clearAll : function()
32135 //this.getChildContainer().dom.innerHTML = "";
32136 this.el.dom.innerHTML = '';
32139 getSelected : function()
32141 if (!this.selectedBrick) {
32145 return this.selectedBrick;
32149 Roo.apply(Roo.bootstrap.LayoutMasonry, {
32153 * register a Masonry Layout
32154 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
32157 register : function(layout)
32159 this.groups[layout.id] = layout;
32162 * fetch a Masonry Layout based on the masonry layout ID
32163 * @param {string} the masonry layout to add
32164 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
32167 get: function(layout_id) {
32168 if (typeof(this.groups[layout_id]) == 'undefined') {
32171 return this.groups[layout_id] ;
32183 * http://masonry.desandro.com
32185 * The idea is to render all the bricks based on vertical width...
32187 * The original code extends 'outlayer' - we might need to use that....
32193 * @class Roo.bootstrap.LayoutMasonryAuto
32194 * @extends Roo.bootstrap.Component
32195 * Bootstrap Layout Masonry class
32198 * Create a new Element
32199 * @param {Object} config The config object
32202 Roo.bootstrap.LayoutMasonryAuto = function(config){
32203 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
32206 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
32209 * @cfg {Boolean} isFitWidth - resize the width..
32211 isFitWidth : false, // options..
32213 * @cfg {Boolean} isOriginLeft = left align?
32215 isOriginLeft : true,
32217 * @cfg {Boolean} isOriginTop = top align?
32219 isOriginTop : false,
32221 * @cfg {Boolean} isLayoutInstant = no animation?
32223 isLayoutInstant : false, // needed?
32225 * @cfg {Boolean} isResizingContainer = not sure if this is used..
32227 isResizingContainer : true,
32229 * @cfg {Number} columnWidth width of the columns
32235 * @cfg {Number} maxCols maximum number of columns
32240 * @cfg {Number} padHeight padding below box..
32246 * @cfg {Boolean} isAutoInitial defalut true
32249 isAutoInitial : true,
32255 initialColumnWidth : 0,
32256 currentSize : null,
32258 colYs : null, // array.
32265 bricks: null, //CompositeElement
32266 cols : 0, // array?
32267 // element : null, // wrapped now this.el
32268 _isLayoutInited : null,
32271 getAutoCreate : function(){
32275 cls: 'blog-masonary-wrapper ' + this.cls,
32277 cls : 'mas-boxes masonary'
32284 getChildContainer: function( )
32286 if (this.boxesEl) {
32287 return this.boxesEl;
32290 this.boxesEl = this.el.select('.mas-boxes').first();
32292 return this.boxesEl;
32296 initEvents : function()
32300 if(this.isAutoInitial){
32301 Roo.log('hook children rendered');
32302 this.on('childrenrendered', function() {
32303 Roo.log('children rendered');
32310 initial : function()
32312 this.reloadItems();
32314 this.currentSize = this.el.getBox(true);
32316 /// was window resize... - let's see if this works..
32317 Roo.EventManager.onWindowResize(this.resize, this);
32319 if(!this.isAutoInitial){
32324 this.layout.defer(500,this);
32327 reloadItems: function()
32329 this.bricks = this.el.select('.masonry-brick', true);
32331 this.bricks.each(function(b) {
32332 //Roo.log(b.getSize());
32333 if (!b.attr('originalwidth')) {
32334 b.attr('originalwidth', b.getSize().width);
32339 Roo.log(this.bricks.elements.length);
32342 resize : function()
32345 var cs = this.el.getBox(true);
32347 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
32348 Roo.log("no change in with or X");
32351 this.currentSize = cs;
32355 layout : function()
32358 this._resetLayout();
32359 //this._manageStamps();
32361 // don't animate first layout
32362 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
32363 this.layoutItems( isInstant );
32365 // flag for initalized
32366 this._isLayoutInited = true;
32369 layoutItems : function( isInstant )
32371 //var items = this._getItemsForLayout( this.items );
32372 // original code supports filtering layout items.. we just ignore it..
32374 this._layoutItems( this.bricks , isInstant );
32376 this._postLayout();
32378 _layoutItems : function ( items , isInstant)
32380 //this.fireEvent( 'layout', this, items );
32383 if ( !items || !items.elements.length ) {
32384 // no items, emit event with empty array
32389 items.each(function(item) {
32390 Roo.log("layout item");
32392 // get x/y object from method
32393 var position = this._getItemLayoutPosition( item );
32395 position.item = item;
32396 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
32397 queue.push( position );
32400 this._processLayoutQueue( queue );
32402 /** Sets position of item in DOM
32403 * @param {Element} item
32404 * @param {Number} x - horizontal position
32405 * @param {Number} y - vertical position
32406 * @param {Boolean} isInstant - disables transitions
32408 _processLayoutQueue : function( queue )
32410 for ( var i=0, len = queue.length; i < len; i++ ) {
32411 var obj = queue[i];
32412 obj.item.position('absolute');
32413 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
32419 * Any logic you want to do after each layout,
32420 * i.e. size the container
32422 _postLayout : function()
32424 this.resizeContainer();
32427 resizeContainer : function()
32429 if ( !this.isResizingContainer ) {
32432 var size = this._getContainerSize();
32434 this.el.setSize(size.width,size.height);
32435 this.boxesEl.setSize(size.width,size.height);
32441 _resetLayout : function()
32443 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
32444 this.colWidth = this.el.getWidth();
32445 //this.gutter = this.el.getWidth();
32447 this.measureColumns();
32453 this.colYs.push( 0 );
32459 measureColumns : function()
32461 this.getContainerWidth();
32462 // if columnWidth is 0, default to outerWidth of first item
32463 if ( !this.columnWidth ) {
32464 var firstItem = this.bricks.first();
32465 Roo.log(firstItem);
32466 this.columnWidth = this.containerWidth;
32467 if (firstItem && firstItem.attr('originalwidth') ) {
32468 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
32470 // columnWidth fall back to item of first element
32471 Roo.log("set column width?");
32472 this.initialColumnWidth = this.columnWidth ;
32474 // if first elem has no width, default to size of container
32479 if (this.initialColumnWidth) {
32480 this.columnWidth = this.initialColumnWidth;
32485 // column width is fixed at the top - however if container width get's smaller we should
32488 // this bit calcs how man columns..
32490 var columnWidth = this.columnWidth += this.gutter;
32492 // calculate columns
32493 var containerWidth = this.containerWidth + this.gutter;
32495 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
32496 // fix rounding errors, typically with gutters
32497 var excess = columnWidth - containerWidth % columnWidth;
32500 // if overshoot is less than a pixel, round up, otherwise floor it
32501 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
32502 cols = Math[ mathMethod ]( cols );
32503 this.cols = Math.max( cols, 1 );
32504 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
32506 // padding positioning..
32507 var totalColWidth = this.cols * this.columnWidth;
32508 var padavail = this.containerWidth - totalColWidth;
32509 // so for 2 columns - we need 3 'pads'
32511 var padNeeded = (1+this.cols) * this.padWidth;
32513 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
32515 this.columnWidth += padExtra
32516 //this.padWidth = Math.floor(padavail / ( this.cols));
32518 // adjust colum width so that padding is fixed??
32520 // we have 3 columns ... total = width * 3
32521 // we have X left over... that should be used by
32523 //if (this.expandC) {
32531 getContainerWidth : function()
32533 /* // container is parent if fit width
32534 var container = this.isFitWidth ? this.element.parentNode : this.element;
32535 // check that this.size and size are there
32536 // IE8 triggers resize on body size change, so they might not be
32538 var size = getSize( container ); //FIXME
32539 this.containerWidth = size && size.innerWidth; //FIXME
32542 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
32546 _getItemLayoutPosition : function( item ) // what is item?
32548 // we resize the item to our columnWidth..
32550 item.setWidth(this.columnWidth);
32551 item.autoBoxAdjust = false;
32553 var sz = item.getSize();
32555 // how many columns does this brick span
32556 var remainder = this.containerWidth % this.columnWidth;
32558 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
32559 // round if off by 1 pixel, otherwise use ceil
32560 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
32561 colSpan = Math.min( colSpan, this.cols );
32563 // normally this should be '1' as we dont' currently allow multi width columns..
32565 var colGroup = this._getColGroup( colSpan );
32566 // get the minimum Y value from the columns
32567 var minimumY = Math.min.apply( Math, colGroup );
32568 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32570 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
32572 // position the brick
32574 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
32575 y: this.currentSize.y + minimumY + this.padHeight
32579 // apply setHeight to necessary columns
32580 var setHeight = minimumY + sz.height + this.padHeight;
32581 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32583 var setSpan = this.cols + 1 - colGroup.length;
32584 for ( var i = 0; i < setSpan; i++ ) {
32585 this.colYs[ shortColIndex + i ] = setHeight ;
32592 * @param {Number} colSpan - number of columns the element spans
32593 * @returns {Array} colGroup
32595 _getColGroup : function( colSpan )
32597 if ( colSpan < 2 ) {
32598 // if brick spans only one column, use all the column Ys
32603 // how many different places could this brick fit horizontally
32604 var groupCount = this.cols + 1 - colSpan;
32605 // for each group potential horizontal position
32606 for ( var i = 0; i < groupCount; i++ ) {
32607 // make an array of colY values for that one group
32608 var groupColYs = this.colYs.slice( i, i + colSpan );
32609 // and get the max value of the array
32610 colGroup[i] = Math.max.apply( Math, groupColYs );
32615 _manageStamp : function( stamp )
32617 var stampSize = stamp.getSize();
32618 var offset = stamp.getBox();
32619 // get the columns that this stamp affects
32620 var firstX = this.isOriginLeft ? offset.x : offset.right;
32621 var lastX = firstX + stampSize.width;
32622 var firstCol = Math.floor( firstX / this.columnWidth );
32623 firstCol = Math.max( 0, firstCol );
32625 var lastCol = Math.floor( lastX / this.columnWidth );
32626 // lastCol should not go over if multiple of columnWidth #425
32627 lastCol -= lastX % this.columnWidth ? 0 : 1;
32628 lastCol = Math.min( this.cols - 1, lastCol );
32630 // set colYs to bottom of the stamp
32631 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
32634 for ( var i = firstCol; i <= lastCol; i++ ) {
32635 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
32640 _getContainerSize : function()
32642 this.maxY = Math.max.apply( Math, this.colYs );
32647 if ( this.isFitWidth ) {
32648 size.width = this._getContainerFitWidth();
32654 _getContainerFitWidth : function()
32656 var unusedCols = 0;
32657 // count unused columns
32660 if ( this.colYs[i] !== 0 ) {
32665 // fit container to columns that have been used
32666 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
32669 needsResizeLayout : function()
32671 var previousWidth = this.containerWidth;
32672 this.getContainerWidth();
32673 return previousWidth !== this.containerWidth;
32688 * @class Roo.bootstrap.MasonryBrick
32689 * @extends Roo.bootstrap.Component
32690 * Bootstrap MasonryBrick class
32693 * Create a new MasonryBrick
32694 * @param {Object} config The config object
32697 Roo.bootstrap.MasonryBrick = function(config){
32699 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
32701 Roo.bootstrap.MasonryBrick.register(this);
32707 * When a MasonryBrick is clcik
32708 * @param {Roo.bootstrap.MasonryBrick} this
32709 * @param {Roo.EventObject} e
32715 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
32718 * @cfg {String} title
32722 * @cfg {String} html
32726 * @cfg {String} bgimage
32730 * @cfg {String} videourl
32734 * @cfg {String} cls
32738 * @cfg {String} href
32742 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
32747 * @cfg {String} placetitle (center|bottom)
32752 * @cfg {Boolean} isFitContainer defalut true
32754 isFitContainer : true,
32757 * @cfg {Boolean} preventDefault defalut false
32759 preventDefault : false,
32762 * @cfg {Boolean} inverse defalut false
32764 maskInverse : false,
32766 getAutoCreate : function()
32768 if(!this.isFitContainer){
32769 return this.getSplitAutoCreate();
32772 var cls = 'masonry-brick masonry-brick-full';
32774 if(this.href.length){
32775 cls += ' masonry-brick-link';
32778 if(this.bgimage.length){
32779 cls += ' masonry-brick-image';
32782 if(this.maskInverse){
32783 cls += ' mask-inverse';
32786 if(!this.html.length && !this.maskInverse && !this.videourl.length){
32787 cls += ' enable-mask';
32791 cls += ' masonry-' + this.size + '-brick';
32794 if(this.placetitle.length){
32796 switch (this.placetitle) {
32798 cls += ' masonry-center-title';
32801 cls += ' masonry-bottom-title';
32808 if(!this.html.length && !this.bgimage.length){
32809 cls += ' masonry-center-title';
32812 if(!this.html.length && this.bgimage.length){
32813 cls += ' masonry-bottom-title';
32818 cls += ' ' + this.cls;
32822 tag: (this.href.length) ? 'a' : 'div',
32827 cls: 'masonry-brick-mask'
32831 cls: 'masonry-brick-paragraph',
32837 if(this.href.length){
32838 cfg.href = this.href;
32841 var cn = cfg.cn[1].cn;
32843 if(this.title.length){
32846 cls: 'masonry-brick-title',
32851 if(this.html.length){
32854 cls: 'masonry-brick-text',
32859 if (!this.title.length && !this.html.length) {
32860 cfg.cn[1].cls += ' hide';
32863 if(this.bgimage.length){
32866 cls: 'masonry-brick-image-view',
32871 if(this.videourl.length){
32872 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
32873 // youtube support only?
32876 cls: 'masonry-brick-image-view',
32879 allowfullscreen : true
32887 getSplitAutoCreate : function()
32889 var cls = 'masonry-brick masonry-brick-split';
32891 if(this.href.length){
32892 cls += ' masonry-brick-link';
32895 if(this.bgimage.length){
32896 cls += ' masonry-brick-image';
32900 cls += ' masonry-' + this.size + '-brick';
32903 switch (this.placetitle) {
32905 cls += ' masonry-center-title';
32908 cls += ' masonry-bottom-title';
32911 if(!this.bgimage.length){
32912 cls += ' masonry-center-title';
32915 if(this.bgimage.length){
32916 cls += ' masonry-bottom-title';
32922 cls += ' ' + this.cls;
32926 tag: (this.href.length) ? 'a' : 'div',
32931 cls: 'masonry-brick-split-head',
32935 cls: 'masonry-brick-paragraph',
32942 cls: 'masonry-brick-split-body',
32948 if(this.href.length){
32949 cfg.href = this.href;
32952 if(this.title.length){
32953 cfg.cn[0].cn[0].cn.push({
32955 cls: 'masonry-brick-title',
32960 if(this.html.length){
32961 cfg.cn[1].cn.push({
32963 cls: 'masonry-brick-text',
32968 if(this.bgimage.length){
32969 cfg.cn[0].cn.push({
32971 cls: 'masonry-brick-image-view',
32976 if(this.videourl.length){
32977 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
32978 // youtube support only?
32979 cfg.cn[0].cn.cn.push({
32981 cls: 'masonry-brick-image-view',
32984 allowfullscreen : true
32991 initEvents: function()
32993 switch (this.size) {
33026 this.el.on('touchstart', this.onTouchStart, this);
33027 this.el.on('touchmove', this.onTouchMove, this);
33028 this.el.on('touchend', this.onTouchEnd, this);
33029 this.el.on('contextmenu', this.onContextMenu, this);
33031 this.el.on('mouseenter' ,this.enter, this);
33032 this.el.on('mouseleave', this.leave, this);
33033 this.el.on('click', this.onClick, this);
33036 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
33037 this.parent().bricks.push(this);
33042 onClick: function(e, el)
33044 var time = this.endTimer - this.startTimer;
33045 // Roo.log(e.preventDefault());
33048 e.preventDefault();
33053 if(!this.preventDefault){
33057 e.preventDefault();
33059 if (this.activeClass != '') {
33060 this.selectBrick();
33063 this.fireEvent('click', this, e);
33066 enter: function(e, el)
33068 e.preventDefault();
33070 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
33074 if(this.bgimage.length && this.html.length){
33075 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33079 leave: function(e, el)
33081 e.preventDefault();
33083 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
33087 if(this.bgimage.length && this.html.length){
33088 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
33092 onTouchStart: function(e, el)
33094 // e.preventDefault();
33096 this.touchmoved = false;
33098 if(!this.isFitContainer){
33102 if(!this.bgimage.length || !this.html.length){
33106 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33108 this.timer = new Date().getTime();
33112 onTouchMove: function(e, el)
33114 this.touchmoved = true;
33117 onContextMenu : function(e,el)
33119 e.preventDefault();
33120 e.stopPropagation();
33124 onTouchEnd: function(e, el)
33126 // e.preventDefault();
33128 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
33135 if(!this.bgimage.length || !this.html.length){
33137 if(this.href.length){
33138 window.location.href = this.href;
33144 if(!this.isFitContainer){
33148 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
33150 window.location.href = this.href;
33153 //selection on single brick only
33154 selectBrick : function() {
33156 if (!this.parentId) {
33160 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
33161 var index = m.selectedBrick.indexOf(this.id);
33164 m.selectedBrick.splice(index,1);
33165 this.el.removeClass(this.activeClass);
33169 for(var i = 0; i < m.selectedBrick.length; i++) {
33170 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
33171 b.el.removeClass(b.activeClass);
33174 m.selectedBrick = [];
33176 m.selectedBrick.push(this.id);
33177 this.el.addClass(this.activeClass);
33181 isSelected : function(){
33182 return this.el.hasClass(this.activeClass);
33187 Roo.apply(Roo.bootstrap.MasonryBrick, {
33190 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
33192 * register a Masonry Brick
33193 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
33196 register : function(brick)
33198 //this.groups[brick.id] = brick;
33199 this.groups.add(brick.id, brick);
33202 * fetch a masonry brick based on the masonry brick ID
33203 * @param {string} the masonry brick to add
33204 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
33207 get: function(brick_id)
33209 // if (typeof(this.groups[brick_id]) == 'undefined') {
33212 // return this.groups[brick_id] ;
33214 if(this.groups.key(brick_id)) {
33215 return this.groups.key(brick_id);
33233 * @class Roo.bootstrap.Brick
33234 * @extends Roo.bootstrap.Component
33235 * Bootstrap Brick class
33238 * Create a new Brick
33239 * @param {Object} config The config object
33242 Roo.bootstrap.Brick = function(config){
33243 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
33249 * When a Brick is click
33250 * @param {Roo.bootstrap.Brick} this
33251 * @param {Roo.EventObject} e
33257 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
33260 * @cfg {String} title
33264 * @cfg {String} html
33268 * @cfg {String} bgimage
33272 * @cfg {String} cls
33276 * @cfg {String} href
33280 * @cfg {String} video
33284 * @cfg {Boolean} square
33288 getAutoCreate : function()
33290 var cls = 'roo-brick';
33292 if(this.href.length){
33293 cls += ' roo-brick-link';
33296 if(this.bgimage.length){
33297 cls += ' roo-brick-image';
33300 if(!this.html.length && !this.bgimage.length){
33301 cls += ' roo-brick-center-title';
33304 if(!this.html.length && this.bgimage.length){
33305 cls += ' roo-brick-bottom-title';
33309 cls += ' ' + this.cls;
33313 tag: (this.href.length) ? 'a' : 'div',
33318 cls: 'roo-brick-paragraph',
33324 if(this.href.length){
33325 cfg.href = this.href;
33328 var cn = cfg.cn[0].cn;
33330 if(this.title.length){
33333 cls: 'roo-brick-title',
33338 if(this.html.length){
33341 cls: 'roo-brick-text',
33348 if(this.bgimage.length){
33351 cls: 'roo-brick-image-view',
33359 initEvents: function()
33361 if(this.title.length || this.html.length){
33362 this.el.on('mouseenter' ,this.enter, this);
33363 this.el.on('mouseleave', this.leave, this);
33366 Roo.EventManager.onWindowResize(this.resize, this);
33368 if(this.bgimage.length){
33369 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
33370 this.imageEl.on('load', this.onImageLoad, this);
33377 onImageLoad : function()
33382 resize : function()
33384 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
33386 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
33388 if(this.bgimage.length){
33389 var image = this.el.select('.roo-brick-image-view', true).first();
33391 image.setWidth(paragraph.getWidth());
33394 image.setHeight(paragraph.getWidth());
33397 this.el.setHeight(image.getHeight());
33398 paragraph.setHeight(image.getHeight());
33404 enter: function(e, el)
33406 e.preventDefault();
33408 if(this.bgimage.length){
33409 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
33410 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
33414 leave: function(e, el)
33416 e.preventDefault();
33418 if(this.bgimage.length){
33419 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
33420 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
33435 * @class Roo.bootstrap.NumberField
33436 * @extends Roo.bootstrap.Input
33437 * Bootstrap NumberField class
33443 * Create a new NumberField
33444 * @param {Object} config The config object
33447 Roo.bootstrap.NumberField = function(config){
33448 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
33451 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
33454 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
33456 allowDecimals : true,
33458 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
33460 decimalSeparator : ".",
33462 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
33464 decimalPrecision : 2,
33466 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
33468 allowNegative : true,
33471 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
33475 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
33477 minValue : Number.NEGATIVE_INFINITY,
33479 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
33481 maxValue : Number.MAX_VALUE,
33483 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
33485 minText : "The minimum value for this field is {0}",
33487 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
33489 maxText : "The maximum value for this field is {0}",
33491 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
33492 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
33494 nanText : "{0} is not a valid number",
33496 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
33498 thousandsDelimiter : false,
33500 * @cfg {String} valueAlign alignment of value
33502 valueAlign : "left",
33504 getAutoCreate : function()
33506 var hiddenInput = {
33510 cls: 'hidden-number-input'
33514 hiddenInput.name = this.name;
33519 var cfg = Roo.bootstrap.NumberField.superclass.getAutoCreate.call(this);
33521 this.name = hiddenInput.name;
33523 if(cfg.cn.length > 0) {
33524 cfg.cn.push(hiddenInput);
33531 initEvents : function()
33533 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
33535 var allowed = "0123456789";
33537 if(this.allowDecimals){
33538 allowed += this.decimalSeparator;
33541 if(this.allowNegative){
33545 if(this.thousandsDelimiter) {
33549 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
33551 var keyPress = function(e){
33553 var k = e.getKey();
33555 var c = e.getCharCode();
33558 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
33559 allowed.indexOf(String.fromCharCode(c)) === -1
33565 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
33569 if(allowed.indexOf(String.fromCharCode(c)) === -1){
33574 this.el.on("keypress", keyPress, this);
33577 validateValue : function(value)
33580 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
33584 var num = this.parseValue(value);
33587 this.markInvalid(String.format(this.nanText, value));
33591 if(num < this.minValue){
33592 this.markInvalid(String.format(this.minText, this.minValue));
33596 if(num > this.maxValue){
33597 this.markInvalid(String.format(this.maxText, this.maxValue));
33604 getValue : function()
33606 var v = this.hiddenEl().getValue();
33608 return this.fixPrecision(this.parseValue(v));
33611 parseValue : function(value)
33613 if(this.thousandsDelimiter) {
33615 r = new RegExp(",", "g");
33616 value = value.replace(r, "");
33619 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
33620 return isNaN(value) ? '' : value;
33623 fixPrecision : function(value)
33625 if(this.thousandsDelimiter) {
33627 r = new RegExp(",", "g");
33628 value = value.replace(r, "");
33631 var nan = isNaN(value);
33633 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
33634 return nan ? '' : value;
33636 return parseFloat(value).toFixed(this.decimalPrecision);
33639 setValue : function(v)
33641 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
33647 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
33649 this.inputEl().dom.value = (v == '') ? '' :
33650 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
33652 if(!this.allowZero && v === '0') {
33653 this.hiddenEl().dom.value = '';
33654 this.inputEl().dom.value = '';
33661 decimalPrecisionFcn : function(v)
33663 return Math.floor(v);
33666 beforeBlur : function()
33668 var v = this.parseValue(this.getRawValue());
33670 if(v || v === 0 || v === ''){
33675 hiddenEl : function()
33677 return this.el.select('input.hidden-number-input',true).first();
33689 * @class Roo.bootstrap.DocumentSlider
33690 * @extends Roo.bootstrap.Component
33691 * Bootstrap DocumentSlider class
33694 * Create a new DocumentViewer
33695 * @param {Object} config The config object
33698 Roo.bootstrap.DocumentSlider = function(config){
33699 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
33706 * Fire after initEvent
33707 * @param {Roo.bootstrap.DocumentSlider} this
33712 * Fire after update
33713 * @param {Roo.bootstrap.DocumentSlider} this
33719 * @param {Roo.bootstrap.DocumentSlider} this
33725 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
33731 getAutoCreate : function()
33735 cls : 'roo-document-slider',
33739 cls : 'roo-document-slider-header',
33743 cls : 'roo-document-slider-header-title'
33749 cls : 'roo-document-slider-body',
33753 cls : 'roo-document-slider-prev',
33757 cls : 'fa fa-chevron-left'
33763 cls : 'roo-document-slider-thumb',
33767 cls : 'roo-document-slider-image'
33773 cls : 'roo-document-slider-next',
33777 cls : 'fa fa-chevron-right'
33789 initEvents : function()
33791 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
33792 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
33794 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
33795 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
33797 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
33798 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
33800 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
33801 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
33803 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
33804 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
33806 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
33807 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33809 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
33810 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33812 this.thumbEl.on('click', this.onClick, this);
33814 this.prevIndicator.on('click', this.prev, this);
33816 this.nextIndicator.on('click', this.next, this);
33820 initial : function()
33822 if(this.files.length){
33823 this.indicator = 1;
33827 this.fireEvent('initial', this);
33830 update : function()
33832 this.imageEl.attr('src', this.files[this.indicator - 1]);
33834 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
33836 this.prevIndicator.show();
33838 if(this.indicator == 1){
33839 this.prevIndicator.hide();
33842 this.nextIndicator.show();
33844 if(this.indicator == this.files.length){
33845 this.nextIndicator.hide();
33848 this.thumbEl.scrollTo('top');
33850 this.fireEvent('update', this);
33853 onClick : function(e)
33855 e.preventDefault();
33857 this.fireEvent('click', this);
33862 e.preventDefault();
33864 this.indicator = Math.max(1, this.indicator - 1);
33871 e.preventDefault();
33873 this.indicator = Math.min(this.files.length, this.indicator + 1);
33887 * @class Roo.bootstrap.RadioSet
33888 * @extends Roo.bootstrap.Input
33889 * Bootstrap RadioSet class
33890 * @cfg {String} indicatorpos (left|right) default left
33891 * @cfg {Boolean} inline (true|false) inline the element (default true)
33892 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
33894 * Create a new RadioSet
33895 * @param {Object} config The config object
33898 Roo.bootstrap.RadioSet = function(config){
33900 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
33904 Roo.bootstrap.RadioSet.register(this);
33909 * Fires when the element is checked or unchecked.
33910 * @param {Roo.bootstrap.RadioSet} this This radio
33911 * @param {Roo.bootstrap.Radio} item The checked item
33916 * Fires when the element is click.
33917 * @param {Roo.bootstrap.RadioSet} this This radio set
33918 * @param {Roo.bootstrap.Radio} item The checked item
33919 * @param {Roo.EventObject} e The event object
33926 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
33934 indicatorpos : 'left',
33936 getAutoCreate : function()
33940 cls : 'roo-radio-set-label',
33944 html : this.fieldLabel
33949 if(this.indicatorpos == 'left'){
33952 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
33953 tooltip : 'This field is required'
33958 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
33959 tooltip : 'This field is required'
33965 cls : 'roo-radio-set-items'
33968 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
33970 if (align === 'left' && this.fieldLabel.length) {
33973 cls : "roo-radio-set-right",
33979 if(this.labelWidth > 12){
33980 label.style = "width: " + this.labelWidth + 'px';
33983 if(this.labelWidth < 13 && this.labelmd == 0){
33984 this.labelmd = this.labelWidth;
33987 if(this.labellg > 0){
33988 label.cls += ' col-lg-' + this.labellg;
33989 items.cls += ' col-lg-' + (12 - this.labellg);
33992 if(this.labelmd > 0){
33993 label.cls += ' col-md-' + this.labelmd;
33994 items.cls += ' col-md-' + (12 - this.labelmd);
33997 if(this.labelsm > 0){
33998 label.cls += ' col-sm-' + this.labelsm;
33999 items.cls += ' col-sm-' + (12 - this.labelsm);
34002 if(this.labelxs > 0){
34003 label.cls += ' col-xs-' + this.labelxs;
34004 items.cls += ' col-xs-' + (12 - this.labelxs);
34010 cls : 'roo-radio-set',
34014 cls : 'roo-radio-set-input',
34017 value : this.value ? this.value : ''
34024 if(this.weight.length){
34025 cfg.cls += ' roo-radio-' + this.weight;
34029 cfg.cls += ' roo-radio-set-inline';
34033 ['xs','sm','md','lg'].map(function(size){
34034 if (settings[size]) {
34035 cfg.cls += ' col-' + size + '-' + settings[size];
34043 initEvents : function()
34045 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
34046 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
34048 if(!this.fieldLabel.length){
34049 this.labelEl.hide();
34052 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
34053 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
34055 this.indicator = this.indicatorEl();
34057 if(this.indicator){
34058 this.indicator.addClass('invisible');
34061 this.originalValue = this.getValue();
34065 inputEl: function ()
34067 return this.el.select('.roo-radio-set-input', true).first();
34070 getChildContainer : function()
34072 return this.itemsEl;
34075 register : function(item)
34077 this.radioes.push(item);
34081 validate : function()
34083 if(this.getVisibilityEl().hasClass('hidden')){
34089 Roo.each(this.radioes, function(i){
34098 if(this.allowBlank) {
34102 if(this.disabled || valid){
34107 this.markInvalid();
34112 markValid : function()
34114 if(this.labelEl.isVisible(true)){
34115 this.indicatorEl().removeClass('visible');
34116 this.indicatorEl().addClass('invisible');
34119 this.el.removeClass([this.invalidClass, this.validClass]);
34120 this.el.addClass(this.validClass);
34122 this.fireEvent('valid', this);
34125 markInvalid : function(msg)
34127 if(this.allowBlank || this.disabled){
34131 if(this.labelEl.isVisible(true)){
34132 this.indicatorEl().removeClass('invisible');
34133 this.indicatorEl().addClass('visible');
34136 this.el.removeClass([this.invalidClass, this.validClass]);
34137 this.el.addClass(this.invalidClass);
34139 this.fireEvent('invalid', this, msg);
34143 setValue : function(v, suppressEvent)
34145 if(this.value === v){
34152 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
34155 Roo.each(this.radioes, function(i){
34157 i.el.removeClass('checked');
34160 Roo.each(this.radioes, function(i){
34162 if(i.value === v || i.value.toString() === v.toString()){
34164 i.el.addClass('checked');
34166 if(suppressEvent !== true){
34167 this.fireEvent('check', this, i);
34178 clearInvalid : function(){
34180 if(!this.el || this.preventMark){
34184 this.el.removeClass([this.invalidClass]);
34186 this.fireEvent('valid', this);
34191 Roo.apply(Roo.bootstrap.RadioSet, {
34195 register : function(set)
34197 this.groups[set.name] = set;
34200 get: function(name)
34202 if (typeof(this.groups[name]) == 'undefined') {
34206 return this.groups[name] ;
34212 * Ext JS Library 1.1.1
34213 * Copyright(c) 2006-2007, Ext JS, LLC.
34215 * Originally Released Under LGPL - original licence link has changed is not relivant.
34218 * <script type="text/javascript">
34223 * @class Roo.bootstrap.SplitBar
34224 * @extends Roo.util.Observable
34225 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
34229 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
34230 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
34231 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
34232 split.minSize = 100;
34233 split.maxSize = 600;
34234 split.animate = true;
34235 split.on('moved', splitterMoved);
34238 * Create a new SplitBar
34239 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
34240 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
34241 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34242 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
34243 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
34244 position of the SplitBar).
34246 Roo.bootstrap.SplitBar = function(cfg){
34251 // dragElement : elm
34252 // resizingElement: el,
34254 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
34255 // placement : Roo.bootstrap.SplitBar.LEFT ,
34256 // existingProxy ???
34259 this.el = Roo.get(cfg.dragElement, true);
34260 this.el.dom.unselectable = "on";
34262 this.resizingEl = Roo.get(cfg.resizingElement, true);
34266 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34267 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
34270 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
34273 * The minimum size of the resizing element. (Defaults to 0)
34279 * The maximum size of the resizing element. (Defaults to 2000)
34282 this.maxSize = 2000;
34285 * Whether to animate the transition to the new size
34288 this.animate = false;
34291 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
34294 this.useShim = false;
34299 if(!cfg.existingProxy){
34301 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
34303 this.proxy = Roo.get(cfg.existingProxy).dom;
34306 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
34309 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
34312 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
34315 this.dragSpecs = {};
34318 * @private The adapter to use to positon and resize elements
34320 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34321 this.adapter.init(this);
34323 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34325 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
34326 this.el.addClass("roo-splitbar-h");
34329 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
34330 this.el.addClass("roo-splitbar-v");
34336 * Fires when the splitter is moved (alias for {@link #event-moved})
34337 * @param {Roo.bootstrap.SplitBar} this
34338 * @param {Number} newSize the new width or height
34343 * Fires when the splitter is moved
34344 * @param {Roo.bootstrap.SplitBar} this
34345 * @param {Number} newSize the new width or height
34349 * @event beforeresize
34350 * Fires before the splitter is dragged
34351 * @param {Roo.bootstrap.SplitBar} this
34353 "beforeresize" : true,
34355 "beforeapply" : true
34358 Roo.util.Observable.call(this);
34361 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
34362 onStartProxyDrag : function(x, y){
34363 this.fireEvent("beforeresize", this);
34365 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
34367 o.enableDisplayMode("block");
34368 // all splitbars share the same overlay
34369 Roo.bootstrap.SplitBar.prototype.overlay = o;
34371 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
34372 this.overlay.show();
34373 Roo.get(this.proxy).setDisplayed("block");
34374 var size = this.adapter.getElementSize(this);
34375 this.activeMinSize = this.getMinimumSize();;
34376 this.activeMaxSize = this.getMaximumSize();;
34377 var c1 = size - this.activeMinSize;
34378 var c2 = Math.max(this.activeMaxSize - size, 0);
34379 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34380 this.dd.resetConstraints();
34381 this.dd.setXConstraint(
34382 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
34383 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
34385 this.dd.setYConstraint(0, 0);
34387 this.dd.resetConstraints();
34388 this.dd.setXConstraint(0, 0);
34389 this.dd.setYConstraint(
34390 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
34391 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
34394 this.dragSpecs.startSize = size;
34395 this.dragSpecs.startPoint = [x, y];
34396 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
34400 * @private Called after the drag operation by the DDProxy
34402 onEndProxyDrag : function(e){
34403 Roo.get(this.proxy).setDisplayed(false);
34404 var endPoint = Roo.lib.Event.getXY(e);
34406 this.overlay.hide();
34409 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34410 newSize = this.dragSpecs.startSize +
34411 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
34412 endPoint[0] - this.dragSpecs.startPoint[0] :
34413 this.dragSpecs.startPoint[0] - endPoint[0]
34416 newSize = this.dragSpecs.startSize +
34417 (this.placement == Roo.bootstrap.SplitBar.TOP ?
34418 endPoint[1] - this.dragSpecs.startPoint[1] :
34419 this.dragSpecs.startPoint[1] - endPoint[1]
34422 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
34423 if(newSize != this.dragSpecs.startSize){
34424 if(this.fireEvent('beforeapply', this, newSize) !== false){
34425 this.adapter.setElementSize(this, newSize);
34426 this.fireEvent("moved", this, newSize);
34427 this.fireEvent("resize", this, newSize);
34433 * Get the adapter this SplitBar uses
34434 * @return The adapter object
34436 getAdapter : function(){
34437 return this.adapter;
34441 * Set the adapter this SplitBar uses
34442 * @param {Object} adapter A SplitBar adapter object
34444 setAdapter : function(adapter){
34445 this.adapter = adapter;
34446 this.adapter.init(this);
34450 * Gets the minimum size for the resizing element
34451 * @return {Number} The minimum size
34453 getMinimumSize : function(){
34454 return this.minSize;
34458 * Sets the minimum size for the resizing element
34459 * @param {Number} minSize The minimum size
34461 setMinimumSize : function(minSize){
34462 this.minSize = minSize;
34466 * Gets the maximum size for the resizing element
34467 * @return {Number} The maximum size
34469 getMaximumSize : function(){
34470 return this.maxSize;
34474 * Sets the maximum size for the resizing element
34475 * @param {Number} maxSize The maximum size
34477 setMaximumSize : function(maxSize){
34478 this.maxSize = maxSize;
34482 * Sets the initialize size for the resizing element
34483 * @param {Number} size The initial size
34485 setCurrentSize : function(size){
34486 var oldAnimate = this.animate;
34487 this.animate = false;
34488 this.adapter.setElementSize(this, size);
34489 this.animate = oldAnimate;
34493 * Destroy this splitbar.
34494 * @param {Boolean} removeEl True to remove the element
34496 destroy : function(removeEl){
34498 this.shim.remove();
34501 this.proxy.parentNode.removeChild(this.proxy);
34509 * @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.
34511 Roo.bootstrap.SplitBar.createProxy = function(dir){
34512 var proxy = new Roo.Element(document.createElement("div"));
34513 proxy.unselectable();
34514 var cls = 'roo-splitbar-proxy';
34515 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
34516 document.body.appendChild(proxy.dom);
34521 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
34522 * Default Adapter. It assumes the splitter and resizing element are not positioned
34523 * elements and only gets/sets the width of the element. Generally used for table based layouts.
34525 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
34528 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
34529 // do nothing for now
34530 init : function(s){
34534 * Called before drag operations to get the current size of the resizing element.
34535 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34537 getElementSize : function(s){
34538 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34539 return s.resizingEl.getWidth();
34541 return s.resizingEl.getHeight();
34546 * Called after drag operations to set the size of the resizing element.
34547 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34548 * @param {Number} newSize The new size to set
34549 * @param {Function} onComplete A function to be invoked when resizing is complete
34551 setElementSize : function(s, newSize, onComplete){
34552 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34554 s.resizingEl.setWidth(newSize);
34556 onComplete(s, newSize);
34559 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
34564 s.resizingEl.setHeight(newSize);
34566 onComplete(s, newSize);
34569 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
34576 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
34577 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
34578 * Adapter that moves the splitter element to align with the resized sizing element.
34579 * Used with an absolute positioned SplitBar.
34580 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
34581 * document.body, make sure you assign an id to the body element.
34583 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
34584 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34585 this.container = Roo.get(container);
34588 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
34589 init : function(s){
34590 this.basic.init(s);
34593 getElementSize : function(s){
34594 return this.basic.getElementSize(s);
34597 setElementSize : function(s, newSize, onComplete){
34598 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
34601 moveSplitter : function(s){
34602 var yes = Roo.bootstrap.SplitBar;
34603 switch(s.placement){
34605 s.el.setX(s.resizingEl.getRight());
34608 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
34611 s.el.setY(s.resizingEl.getBottom());
34614 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
34621 * Orientation constant - Create a vertical SplitBar
34625 Roo.bootstrap.SplitBar.VERTICAL = 1;
34628 * Orientation constant - Create a horizontal SplitBar
34632 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
34635 * Placement constant - The resizing element is to the left of the splitter element
34639 Roo.bootstrap.SplitBar.LEFT = 1;
34642 * Placement constant - The resizing element is to the right of the splitter element
34646 Roo.bootstrap.SplitBar.RIGHT = 2;
34649 * Placement constant - The resizing element is positioned above the splitter element
34653 Roo.bootstrap.SplitBar.TOP = 3;
34656 * Placement constant - The resizing element is positioned under splitter element
34660 Roo.bootstrap.SplitBar.BOTTOM = 4;
34661 Roo.namespace("Roo.bootstrap.layout");/*
34663 * Ext JS Library 1.1.1
34664 * Copyright(c) 2006-2007, Ext JS, LLC.
34666 * Originally Released Under LGPL - original licence link has changed is not relivant.
34669 * <script type="text/javascript">
34673 * @class Roo.bootstrap.layout.Manager
34674 * @extends Roo.bootstrap.Component
34675 * Base class for layout managers.
34677 Roo.bootstrap.layout.Manager = function(config)
34679 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
34685 /** false to disable window resize monitoring @type Boolean */
34686 this.monitorWindowResize = true;
34691 * Fires when a layout is performed.
34692 * @param {Roo.LayoutManager} this
34696 * @event regionresized
34697 * Fires when the user resizes a region.
34698 * @param {Roo.LayoutRegion} region The resized region
34699 * @param {Number} newSize The new size (width for east/west, height for north/south)
34701 "regionresized" : true,
34703 * @event regioncollapsed
34704 * Fires when a region is collapsed.
34705 * @param {Roo.LayoutRegion} region The collapsed region
34707 "regioncollapsed" : true,
34709 * @event regionexpanded
34710 * Fires when a region is expanded.
34711 * @param {Roo.LayoutRegion} region The expanded region
34713 "regionexpanded" : true
34715 this.updating = false;
34718 this.el = Roo.get(config.el);
34724 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
34729 monitorWindowResize : true,
34735 onRender : function(ct, position)
34738 this.el = Roo.get(ct);
34741 //this.fireEvent('render',this);
34745 initEvents: function()
34749 // ie scrollbar fix
34750 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
34751 document.body.scroll = "no";
34752 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
34753 this.el.position('relative');
34755 this.id = this.el.id;
34756 this.el.addClass("roo-layout-container");
34757 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
34758 if(this.el.dom != document.body ) {
34759 this.el.on('resize', this.layout,this);
34760 this.el.on('show', this.layout,this);
34766 * Returns true if this layout is currently being updated
34767 * @return {Boolean}
34769 isUpdating : function(){
34770 return this.updating;
34774 * Suspend the LayoutManager from doing auto-layouts while
34775 * making multiple add or remove calls
34777 beginUpdate : function(){
34778 this.updating = true;
34782 * Restore auto-layouts and optionally disable the manager from performing a layout
34783 * @param {Boolean} noLayout true to disable a layout update
34785 endUpdate : function(noLayout){
34786 this.updating = false;
34792 layout: function(){
34796 onRegionResized : function(region, newSize){
34797 this.fireEvent("regionresized", region, newSize);
34801 onRegionCollapsed : function(region){
34802 this.fireEvent("regioncollapsed", region);
34805 onRegionExpanded : function(region){
34806 this.fireEvent("regionexpanded", region);
34810 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
34811 * performs box-model adjustments.
34812 * @return {Object} The size as an object {width: (the width), height: (the height)}
34814 getViewSize : function()
34817 if(this.el.dom != document.body){
34818 size = this.el.getSize();
34820 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
34822 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
34823 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
34828 * Returns the Element this layout is bound to.
34829 * @return {Roo.Element}
34831 getEl : function(){
34836 * Returns the specified region.
34837 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
34838 * @return {Roo.LayoutRegion}
34840 getRegion : function(target){
34841 return this.regions[target.toLowerCase()];
34844 onWindowResize : function(){
34845 if(this.monitorWindowResize){
34852 * Ext JS Library 1.1.1
34853 * Copyright(c) 2006-2007, Ext JS, LLC.
34855 * Originally Released Under LGPL - original licence link has changed is not relivant.
34858 * <script type="text/javascript">
34861 * @class Roo.bootstrap.layout.Border
34862 * @extends Roo.bootstrap.layout.Manager
34863 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
34864 * please see: examples/bootstrap/nested.html<br><br>
34866 <b>The container the layout is rendered into can be either the body element or any other element.
34867 If it is not the body element, the container needs to either be an absolute positioned element,
34868 or you will need to add "position:relative" to the css of the container. You will also need to specify
34869 the container size if it is not the body element.</b>
34872 * Create a new Border
34873 * @param {Object} config Configuration options
34875 Roo.bootstrap.layout.Border = function(config){
34876 config = config || {};
34877 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
34881 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
34882 if(config[region]){
34883 config[region].region = region;
34884 this.addRegion(config[region]);
34890 Roo.bootstrap.layout.Border.regions = ["north","south","east","west","center"];
34892 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
34894 * Creates and adds a new region if it doesn't already exist.
34895 * @param {String} target The target region key (north, south, east, west or center).
34896 * @param {Object} config The regions config object
34897 * @return {BorderLayoutRegion} The new region
34899 addRegion : function(config)
34901 if(!this.regions[config.region]){
34902 var r = this.factory(config);
34903 this.bindRegion(r);
34905 return this.regions[config.region];
34909 bindRegion : function(r){
34910 this.regions[r.config.region] = r;
34912 r.on("visibilitychange", this.layout, this);
34913 r.on("paneladded", this.layout, this);
34914 r.on("panelremoved", this.layout, this);
34915 r.on("invalidated", this.layout, this);
34916 r.on("resized", this.onRegionResized, this);
34917 r.on("collapsed", this.onRegionCollapsed, this);
34918 r.on("expanded", this.onRegionExpanded, this);
34922 * Performs a layout update.
34924 layout : function()
34926 if(this.updating) {
34930 // render all the rebions if they have not been done alreayd?
34931 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
34932 if(this.regions[region] && !this.regions[region].bodyEl){
34933 this.regions[region].onRender(this.el)
34937 var size = this.getViewSize();
34938 var w = size.width;
34939 var h = size.height;
34944 //var x = 0, y = 0;
34946 var rs = this.regions;
34947 var north = rs["north"];
34948 var south = rs["south"];
34949 var west = rs["west"];
34950 var east = rs["east"];
34951 var center = rs["center"];
34952 //if(this.hideOnLayout){ // not supported anymore
34953 //c.el.setStyle("display", "none");
34955 if(north && north.isVisible()){
34956 var b = north.getBox();
34957 var m = north.getMargins();
34958 b.width = w - (m.left+m.right);
34961 centerY = b.height + b.y + m.bottom;
34962 centerH -= centerY;
34963 north.updateBox(this.safeBox(b));
34965 if(south && south.isVisible()){
34966 var b = south.getBox();
34967 var m = south.getMargins();
34968 b.width = w - (m.left+m.right);
34970 var totalHeight = (b.height + m.top + m.bottom);
34971 b.y = h - totalHeight + m.top;
34972 centerH -= totalHeight;
34973 south.updateBox(this.safeBox(b));
34975 if(west && west.isVisible()){
34976 var b = west.getBox();
34977 var m = west.getMargins();
34978 b.height = centerH - (m.top+m.bottom);
34980 b.y = centerY + m.top;
34981 var totalWidth = (b.width + m.left + m.right);
34982 centerX += totalWidth;
34983 centerW -= totalWidth;
34984 west.updateBox(this.safeBox(b));
34986 if(east && east.isVisible()){
34987 var b = east.getBox();
34988 var m = east.getMargins();
34989 b.height = centerH - (m.top+m.bottom);
34990 var totalWidth = (b.width + m.left + m.right);
34991 b.x = w - totalWidth + m.left;
34992 b.y = centerY + m.top;
34993 centerW -= totalWidth;
34994 east.updateBox(this.safeBox(b));
34997 var m = center.getMargins();
34999 x: centerX + m.left,
35000 y: centerY + m.top,
35001 width: centerW - (m.left+m.right),
35002 height: centerH - (m.top+m.bottom)
35004 //if(this.hideOnLayout){
35005 //center.el.setStyle("display", "block");
35007 center.updateBox(this.safeBox(centerBox));
35010 this.fireEvent("layout", this);
35014 safeBox : function(box){
35015 box.width = Math.max(0, box.width);
35016 box.height = Math.max(0, box.height);
35021 * Adds a ContentPanel (or subclass) to this layout.
35022 * @param {String} target The target region key (north, south, east, west or center).
35023 * @param {Roo.ContentPanel} panel The panel to add
35024 * @return {Roo.ContentPanel} The added panel
35026 add : function(target, panel){
35028 target = target.toLowerCase();
35029 return this.regions[target].add(panel);
35033 * Remove a ContentPanel (or subclass) to this layout.
35034 * @param {String} target The target region key (north, south, east, west or center).
35035 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
35036 * @return {Roo.ContentPanel} The removed panel
35038 remove : function(target, panel){
35039 target = target.toLowerCase();
35040 return this.regions[target].remove(panel);
35044 * Searches all regions for a panel with the specified id
35045 * @param {String} panelId
35046 * @return {Roo.ContentPanel} The panel or null if it wasn't found
35048 findPanel : function(panelId){
35049 var rs = this.regions;
35050 for(var target in rs){
35051 if(typeof rs[target] != "function"){
35052 var p = rs[target].getPanel(panelId);
35062 * Searches all regions for a panel with the specified id and activates (shows) it.
35063 * @param {String/ContentPanel} panelId The panels id or the panel itself
35064 * @return {Roo.ContentPanel} The shown panel or null
35066 showPanel : function(panelId) {
35067 var rs = this.regions;
35068 for(var target in rs){
35069 var r = rs[target];
35070 if(typeof r != "function"){
35071 if(r.hasPanel(panelId)){
35072 return r.showPanel(panelId);
35080 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
35081 * @param {Roo.state.Provider} provider (optional) An alternate state provider
35084 restoreState : function(provider){
35086 provider = Roo.state.Manager;
35088 var sm = new Roo.LayoutStateManager();
35089 sm.init(this, provider);
35095 * Adds a xtype elements to the layout.
35099 xtype : 'ContentPanel',
35106 xtype : 'NestedLayoutPanel',
35112 items : [ ... list of content panels or nested layout panels.. ]
35116 * @param {Object} cfg Xtype definition of item to add.
35118 addxtype : function(cfg)
35120 // basically accepts a pannel...
35121 // can accept a layout region..!?!?
35122 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
35125 // theory? children can only be panels??
35127 //if (!cfg.xtype.match(/Panel$/)) {
35132 if (typeof(cfg.region) == 'undefined') {
35133 Roo.log("Failed to add Panel, region was not set");
35137 var region = cfg.region;
35143 xitems = cfg.items;
35150 case 'Content': // ContentPanel (el, cfg)
35151 case 'Scroll': // ContentPanel (el, cfg)
35153 cfg.autoCreate = true;
35154 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35156 // var el = this.el.createChild();
35157 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
35160 this.add(region, ret);
35164 case 'TreePanel': // our new panel!
35165 cfg.el = this.el.createChild();
35166 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35167 this.add(region, ret);
35172 // create a new Layout (which is a Border Layout...
35174 var clayout = cfg.layout;
35175 clayout.el = this.el.createChild();
35176 clayout.items = clayout.items || [];
35180 // replace this exitems with the clayout ones..
35181 xitems = clayout.items;
35183 // force background off if it's in center...
35184 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
35185 cfg.background = false;
35187 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
35190 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35191 //console.log('adding nested layout panel ' + cfg.toSource());
35192 this.add(region, ret);
35193 nb = {}; /// find first...
35198 // needs grid and region
35200 //var el = this.getRegion(region).el.createChild();
35202 *var el = this.el.createChild();
35203 // create the grid first...
35204 cfg.grid.container = el;
35205 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
35208 if (region == 'center' && this.active ) {
35209 cfg.background = false;
35212 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35214 this.add(region, ret);
35216 if (cfg.background) {
35217 // render grid on panel activation (if panel background)
35218 ret.on('activate', function(gp) {
35219 if (!gp.grid.rendered) {
35220 // gp.grid.render(el);
35224 // cfg.grid.render(el);
35230 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
35231 // it was the old xcomponent building that caused this before.
35232 // espeically if border is the top element in the tree.
35242 if (typeof(Roo[cfg.xtype]) != 'undefined') {
35244 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35245 this.add(region, ret);
35249 throw "Can not add '" + cfg.xtype + "' to Border";
35255 this.beginUpdate();
35259 Roo.each(xitems, function(i) {
35260 region = nb && i.region ? i.region : false;
35262 var add = ret.addxtype(i);
35265 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
35266 if (!i.background) {
35267 abn[region] = nb[region] ;
35274 // make the last non-background panel active..
35275 //if (nb) { Roo.log(abn); }
35278 for(var r in abn) {
35279 region = this.getRegion(r);
35281 // tried using nb[r], but it does not work..
35283 region.showPanel(abn[r]);
35294 factory : function(cfg)
35297 var validRegions = Roo.bootstrap.layout.Border.regions;
35299 var target = cfg.region;
35302 var r = Roo.bootstrap.layout;
35306 return new r.North(cfg);
35308 return new r.South(cfg);
35310 return new r.East(cfg);
35312 return new r.West(cfg);
35314 return new r.Center(cfg);
35316 throw 'Layout region "'+target+'" not supported.';
35323 * Ext JS Library 1.1.1
35324 * Copyright(c) 2006-2007, Ext JS, LLC.
35326 * Originally Released Under LGPL - original licence link has changed is not relivant.
35329 * <script type="text/javascript">
35333 * @class Roo.bootstrap.layout.Basic
35334 * @extends Roo.util.Observable
35335 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
35336 * and does not have a titlebar, tabs or any other features. All it does is size and position
35337 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
35338 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35339 * @cfg {string} region the region that it inhabits..
35340 * @cfg {bool} skipConfig skip config?
35344 Roo.bootstrap.layout.Basic = function(config){
35346 this.mgr = config.mgr;
35348 this.position = config.region;
35350 var skipConfig = config.skipConfig;
35354 * @scope Roo.BasicLayoutRegion
35358 * @event beforeremove
35359 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
35360 * @param {Roo.LayoutRegion} this
35361 * @param {Roo.ContentPanel} panel The panel
35362 * @param {Object} e The cancel event object
35364 "beforeremove" : true,
35366 * @event invalidated
35367 * Fires when the layout for this region is changed.
35368 * @param {Roo.LayoutRegion} this
35370 "invalidated" : true,
35372 * @event visibilitychange
35373 * Fires when this region is shown or hidden
35374 * @param {Roo.LayoutRegion} this
35375 * @param {Boolean} visibility true or false
35377 "visibilitychange" : true,
35379 * @event paneladded
35380 * Fires when a panel is added.
35381 * @param {Roo.LayoutRegion} this
35382 * @param {Roo.ContentPanel} panel The panel
35384 "paneladded" : true,
35386 * @event panelremoved
35387 * Fires when a panel is removed.
35388 * @param {Roo.LayoutRegion} this
35389 * @param {Roo.ContentPanel} panel The panel
35391 "panelremoved" : true,
35393 * @event beforecollapse
35394 * Fires when this region before collapse.
35395 * @param {Roo.LayoutRegion} this
35397 "beforecollapse" : true,
35400 * Fires when this region is collapsed.
35401 * @param {Roo.LayoutRegion} this
35403 "collapsed" : true,
35406 * Fires when this region is expanded.
35407 * @param {Roo.LayoutRegion} this
35412 * Fires when this region is slid into view.
35413 * @param {Roo.LayoutRegion} this
35415 "slideshow" : true,
35418 * Fires when this region slides out of view.
35419 * @param {Roo.LayoutRegion} this
35421 "slidehide" : true,
35423 * @event panelactivated
35424 * Fires when a panel is activated.
35425 * @param {Roo.LayoutRegion} this
35426 * @param {Roo.ContentPanel} panel The activated panel
35428 "panelactivated" : true,
35431 * Fires when the user resizes this region.
35432 * @param {Roo.LayoutRegion} this
35433 * @param {Number} newSize The new size (width for east/west, height for north/south)
35437 /** A collection of panels in this region. @type Roo.util.MixedCollection */
35438 this.panels = new Roo.util.MixedCollection();
35439 this.panels.getKey = this.getPanelId.createDelegate(this);
35441 this.activePanel = null;
35442 // ensure listeners are added...
35444 if (config.listeners || config.events) {
35445 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
35446 listeners : config.listeners || {},
35447 events : config.events || {}
35451 if(skipConfig !== true){
35452 this.applyConfig(config);
35456 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
35458 getPanelId : function(p){
35462 applyConfig : function(config){
35463 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35464 this.config = config;
35469 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
35470 * the width, for horizontal (north, south) the height.
35471 * @param {Number} newSize The new width or height
35473 resizeTo : function(newSize){
35474 var el = this.el ? this.el :
35475 (this.activePanel ? this.activePanel.getEl() : null);
35477 switch(this.position){
35480 el.setWidth(newSize);
35481 this.fireEvent("resized", this, newSize);
35485 el.setHeight(newSize);
35486 this.fireEvent("resized", this, newSize);
35492 getBox : function(){
35493 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
35496 getMargins : function(){
35497 return this.margins;
35500 updateBox : function(box){
35502 var el = this.activePanel.getEl();
35503 el.dom.style.left = box.x + "px";
35504 el.dom.style.top = box.y + "px";
35505 this.activePanel.setSize(box.width, box.height);
35509 * Returns the container element for this region.
35510 * @return {Roo.Element}
35512 getEl : function(){
35513 return this.activePanel;
35517 * Returns true if this region is currently visible.
35518 * @return {Boolean}
35520 isVisible : function(){
35521 return this.activePanel ? true : false;
35524 setActivePanel : function(panel){
35525 panel = this.getPanel(panel);
35526 if(this.activePanel && this.activePanel != panel){
35527 this.activePanel.setActiveState(false);
35528 this.activePanel.getEl().setLeftTop(-10000,-10000);
35530 this.activePanel = panel;
35531 panel.setActiveState(true);
35533 panel.setSize(this.box.width, this.box.height);
35535 this.fireEvent("panelactivated", this, panel);
35536 this.fireEvent("invalidated");
35540 * Show the specified panel.
35541 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
35542 * @return {Roo.ContentPanel} The shown panel or null
35544 showPanel : function(panel){
35545 panel = this.getPanel(panel);
35547 this.setActivePanel(panel);
35553 * Get the active panel for this region.
35554 * @return {Roo.ContentPanel} The active panel or null
35556 getActivePanel : function(){
35557 return this.activePanel;
35561 * Add the passed ContentPanel(s)
35562 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35563 * @return {Roo.ContentPanel} The panel added (if only one was added)
35565 add : function(panel){
35566 if(arguments.length > 1){
35567 for(var i = 0, len = arguments.length; i < len; i++) {
35568 this.add(arguments[i]);
35572 if(this.hasPanel(panel)){
35573 this.showPanel(panel);
35576 var el = panel.getEl();
35577 if(el.dom.parentNode != this.mgr.el.dom){
35578 this.mgr.el.dom.appendChild(el.dom);
35580 if(panel.setRegion){
35581 panel.setRegion(this);
35583 this.panels.add(panel);
35584 el.setStyle("position", "absolute");
35585 if(!panel.background){
35586 this.setActivePanel(panel);
35587 if(this.config.initialSize && this.panels.getCount()==1){
35588 this.resizeTo(this.config.initialSize);
35591 this.fireEvent("paneladded", this, panel);
35596 * Returns true if the panel is in this region.
35597 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35598 * @return {Boolean}
35600 hasPanel : function(panel){
35601 if(typeof panel == "object"){ // must be panel obj
35602 panel = panel.getId();
35604 return this.getPanel(panel) ? true : false;
35608 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35609 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35610 * @param {Boolean} preservePanel Overrides the config preservePanel option
35611 * @return {Roo.ContentPanel} The panel that was removed
35613 remove : function(panel, preservePanel){
35614 panel = this.getPanel(panel);
35619 this.fireEvent("beforeremove", this, panel, e);
35620 if(e.cancel === true){
35623 var panelId = panel.getId();
35624 this.panels.removeKey(panelId);
35629 * Returns the panel specified or null if it's not in this region.
35630 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35631 * @return {Roo.ContentPanel}
35633 getPanel : function(id){
35634 if(typeof id == "object"){ // must be panel obj
35637 return this.panels.get(id);
35641 * Returns this regions position (north/south/east/west/center).
35644 getPosition: function(){
35645 return this.position;
35649 * Ext JS Library 1.1.1
35650 * Copyright(c) 2006-2007, Ext JS, LLC.
35652 * Originally Released Under LGPL - original licence link has changed is not relivant.
35655 * <script type="text/javascript">
35659 * @class Roo.bootstrap.layout.Region
35660 * @extends Roo.bootstrap.layout.Basic
35661 * This class represents a region in a layout manager.
35663 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
35664 * @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})
35665 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
35666 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
35667 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
35668 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
35669 * @cfg {String} title The title for the region (overrides panel titles)
35670 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
35671 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
35672 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
35673 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
35674 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
35675 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
35676 * the space available, similar to FireFox 1.5 tabs (defaults to false)
35677 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
35678 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
35679 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
35681 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
35682 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
35683 * @cfg {Boolean} disableTabTips True to disable tab tooltips
35684 * @cfg {Number} width For East/West panels
35685 * @cfg {Number} height For North/South panels
35686 * @cfg {Boolean} split To show the splitter
35687 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
35689 * @cfg {string} cls Extra CSS classes to add to region
35691 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35692 * @cfg {string} region the region that it inhabits..
35695 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
35696 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
35698 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
35699 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
35700 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
35702 Roo.bootstrap.layout.Region = function(config)
35704 this.applyConfig(config);
35706 var mgr = config.mgr;
35707 var pos = config.region;
35708 config.skipConfig = true;
35709 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
35712 this.onRender(mgr.el);
35715 this.visible = true;
35716 this.collapsed = false;
35717 this.unrendered_panels = [];
35720 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
35722 position: '', // set by wrapper (eg. north/south etc..)
35723 unrendered_panels : null, // unrendered panels.
35724 createBody : function(){
35725 /** This region's body element
35726 * @type Roo.Element */
35727 this.bodyEl = this.el.createChild({
35729 cls: "roo-layout-panel-body tab-content" // bootstrap added...
35733 onRender: function(ctr, pos)
35735 var dh = Roo.DomHelper;
35736 /** This region's container element
35737 * @type Roo.Element */
35738 this.el = dh.append(ctr.dom, {
35740 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
35742 /** This region's title element
35743 * @type Roo.Element */
35745 this.titleEl = dh.append(this.el.dom,
35748 unselectable: "on",
35749 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
35751 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
35752 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
35755 this.titleEl.enableDisplayMode();
35756 /** This region's title text element
35757 * @type HTMLElement */
35758 this.titleTextEl = this.titleEl.dom.firstChild;
35759 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
35761 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
35762 this.closeBtn.enableDisplayMode();
35763 this.closeBtn.on("click", this.closeClicked, this);
35764 this.closeBtn.hide();
35766 this.createBody(this.config);
35767 if(this.config.hideWhenEmpty){
35769 this.on("paneladded", this.validateVisibility, this);
35770 this.on("panelremoved", this.validateVisibility, this);
35772 if(this.autoScroll){
35773 this.bodyEl.setStyle("overflow", "auto");
35775 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
35777 //if(c.titlebar !== false){
35778 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
35779 this.titleEl.hide();
35781 this.titleEl.show();
35782 if(this.config.title){
35783 this.titleTextEl.innerHTML = this.config.title;
35787 if(this.config.collapsed){
35788 this.collapse(true);
35790 if(this.config.hidden){
35794 if (this.unrendered_panels && this.unrendered_panels.length) {
35795 for (var i =0;i< this.unrendered_panels.length; i++) {
35796 this.add(this.unrendered_panels[i]);
35798 this.unrendered_panels = null;
35804 applyConfig : function(c)
35807 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
35808 var dh = Roo.DomHelper;
35809 if(c.titlebar !== false){
35810 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
35811 this.collapseBtn.on("click", this.collapse, this);
35812 this.collapseBtn.enableDisplayMode();
35814 if(c.showPin === true || this.showPin){
35815 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
35816 this.stickBtn.enableDisplayMode();
35817 this.stickBtn.on("click", this.expand, this);
35818 this.stickBtn.hide();
35823 /** This region's collapsed element
35824 * @type Roo.Element */
35827 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
35828 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
35831 if(c.floatable !== false){
35832 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
35833 this.collapsedEl.on("click", this.collapseClick, this);
35836 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
35837 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
35838 id: "message", unselectable: "on", style:{"float":"left"}});
35839 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
35841 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
35842 this.expandBtn.on("click", this.expand, this);
35846 if(this.collapseBtn){
35847 this.collapseBtn.setVisible(c.collapsible == true);
35850 this.cmargins = c.cmargins || this.cmargins ||
35851 (this.position == "west" || this.position == "east" ?
35852 {top: 0, left: 2, right:2, bottom: 0} :
35853 {top: 2, left: 0, right:0, bottom: 2});
35855 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35858 this.bottomTabs = c.tabPosition != "top";
35860 this.autoScroll = c.autoScroll || false;
35865 this.duration = c.duration || .30;
35866 this.slideDuration = c.slideDuration || .45;
35871 * Returns true if this region is currently visible.
35872 * @return {Boolean}
35874 isVisible : function(){
35875 return this.visible;
35879 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
35880 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
35882 //setCollapsedTitle : function(title){
35883 // title = title || " ";
35884 // if(this.collapsedTitleTextEl){
35885 // this.collapsedTitleTextEl.innerHTML = title;
35889 getBox : function(){
35891 // if(!this.collapsed){
35892 b = this.el.getBox(false, true);
35894 // b = this.collapsedEl.getBox(false, true);
35899 getMargins : function(){
35900 return this.margins;
35901 //return this.collapsed ? this.cmargins : this.margins;
35904 highlight : function(){
35905 this.el.addClass("x-layout-panel-dragover");
35908 unhighlight : function(){
35909 this.el.removeClass("x-layout-panel-dragover");
35912 updateBox : function(box)
35914 if (!this.bodyEl) {
35915 return; // not rendered yet..
35919 if(!this.collapsed){
35920 this.el.dom.style.left = box.x + "px";
35921 this.el.dom.style.top = box.y + "px";
35922 this.updateBody(box.width, box.height);
35924 this.collapsedEl.dom.style.left = box.x + "px";
35925 this.collapsedEl.dom.style.top = box.y + "px";
35926 this.collapsedEl.setSize(box.width, box.height);
35929 this.tabs.autoSizeTabs();
35933 updateBody : function(w, h)
35936 this.el.setWidth(w);
35937 w -= this.el.getBorderWidth("rl");
35938 if(this.config.adjustments){
35939 w += this.config.adjustments[0];
35942 if(h !== null && h > 0){
35943 this.el.setHeight(h);
35944 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
35945 h -= this.el.getBorderWidth("tb");
35946 if(this.config.adjustments){
35947 h += this.config.adjustments[1];
35949 this.bodyEl.setHeight(h);
35951 h = this.tabs.syncHeight(h);
35954 if(this.panelSize){
35955 w = w !== null ? w : this.panelSize.width;
35956 h = h !== null ? h : this.panelSize.height;
35958 if(this.activePanel){
35959 var el = this.activePanel.getEl();
35960 w = w !== null ? w : el.getWidth();
35961 h = h !== null ? h : el.getHeight();
35962 this.panelSize = {width: w, height: h};
35963 this.activePanel.setSize(w, h);
35965 if(Roo.isIE && this.tabs){
35966 this.tabs.el.repaint();
35971 * Returns the container element for this region.
35972 * @return {Roo.Element}
35974 getEl : function(){
35979 * Hides this region.
35982 //if(!this.collapsed){
35983 this.el.dom.style.left = "-2000px";
35986 // this.collapsedEl.dom.style.left = "-2000px";
35987 // this.collapsedEl.hide();
35989 this.visible = false;
35990 this.fireEvent("visibilitychange", this, false);
35994 * Shows this region if it was previously hidden.
35997 //if(!this.collapsed){
36000 // this.collapsedEl.show();
36002 this.visible = true;
36003 this.fireEvent("visibilitychange", this, true);
36006 closeClicked : function(){
36007 if(this.activePanel){
36008 this.remove(this.activePanel);
36012 collapseClick : function(e){
36014 e.stopPropagation();
36017 e.stopPropagation();
36023 * Collapses this region.
36024 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
36027 collapse : function(skipAnim, skipCheck = false){
36028 if(this.collapsed) {
36032 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
36034 this.collapsed = true;
36036 this.split.el.hide();
36038 if(this.config.animate && skipAnim !== true){
36039 this.fireEvent("invalidated", this);
36040 this.animateCollapse();
36042 this.el.setLocation(-20000,-20000);
36044 this.collapsedEl.show();
36045 this.fireEvent("collapsed", this);
36046 this.fireEvent("invalidated", this);
36052 animateCollapse : function(){
36057 * Expands this region if it was previously collapsed.
36058 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
36059 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
36062 expand : function(e, skipAnim){
36064 e.stopPropagation();
36066 if(!this.collapsed || this.el.hasActiveFx()) {
36070 this.afterSlideIn();
36073 this.collapsed = false;
36074 if(this.config.animate && skipAnim !== true){
36075 this.animateExpand();
36079 this.split.el.show();
36081 this.collapsedEl.setLocation(-2000,-2000);
36082 this.collapsedEl.hide();
36083 this.fireEvent("invalidated", this);
36084 this.fireEvent("expanded", this);
36088 animateExpand : function(){
36092 initTabs : function()
36094 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
36096 var ts = new Roo.bootstrap.panel.Tabs({
36097 el: this.bodyEl.dom,
36098 tabPosition: this.bottomTabs ? 'bottom' : 'top',
36099 disableTooltips: this.config.disableTabTips,
36100 toolbar : this.config.toolbar
36103 if(this.config.hideTabs){
36104 ts.stripWrap.setDisplayed(false);
36107 ts.resizeTabs = this.config.resizeTabs === true;
36108 ts.minTabWidth = this.config.minTabWidth || 40;
36109 ts.maxTabWidth = this.config.maxTabWidth || 250;
36110 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
36111 ts.monitorResize = false;
36112 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
36113 ts.bodyEl.addClass('roo-layout-tabs-body');
36114 this.panels.each(this.initPanelAsTab, this);
36117 initPanelAsTab : function(panel){
36118 var ti = this.tabs.addTab(
36122 this.config.closeOnTab && panel.isClosable(),
36125 if(panel.tabTip !== undefined){
36126 ti.setTooltip(panel.tabTip);
36128 ti.on("activate", function(){
36129 this.setActivePanel(panel);
36132 if(this.config.closeOnTab){
36133 ti.on("beforeclose", function(t, e){
36135 this.remove(panel);
36139 panel.tabItem = ti;
36144 updatePanelTitle : function(panel, title)
36146 if(this.activePanel == panel){
36147 this.updateTitle(title);
36150 var ti = this.tabs.getTab(panel.getEl().id);
36152 if(panel.tabTip !== undefined){
36153 ti.setTooltip(panel.tabTip);
36158 updateTitle : function(title){
36159 if(this.titleTextEl && !this.config.title){
36160 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
36164 setActivePanel : function(panel)
36166 panel = this.getPanel(panel);
36167 if(this.activePanel && this.activePanel != panel){
36168 if(this.activePanel.setActiveState(false) === false){
36172 this.activePanel = panel;
36173 panel.setActiveState(true);
36174 if(this.panelSize){
36175 panel.setSize(this.panelSize.width, this.panelSize.height);
36178 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
36180 this.updateTitle(panel.getTitle());
36182 this.fireEvent("invalidated", this);
36184 this.fireEvent("panelactivated", this, panel);
36188 * Shows the specified panel.
36189 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
36190 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
36192 showPanel : function(panel)
36194 panel = this.getPanel(panel);
36197 var tab = this.tabs.getTab(panel.getEl().id);
36198 if(tab.isHidden()){
36199 this.tabs.unhideTab(tab.id);
36203 this.setActivePanel(panel);
36210 * Get the active panel for this region.
36211 * @return {Roo.ContentPanel} The active panel or null
36213 getActivePanel : function(){
36214 return this.activePanel;
36217 validateVisibility : function(){
36218 if(this.panels.getCount() < 1){
36219 this.updateTitle(" ");
36220 this.closeBtn.hide();
36223 if(!this.isVisible()){
36230 * Adds the passed ContentPanel(s) to this region.
36231 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
36232 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
36234 add : function(panel)
36236 if(arguments.length > 1){
36237 for(var i = 0, len = arguments.length; i < len; i++) {
36238 this.add(arguments[i]);
36243 // if we have not been rendered yet, then we can not really do much of this..
36244 if (!this.bodyEl) {
36245 this.unrendered_panels.push(panel);
36252 if(this.hasPanel(panel)){
36253 this.showPanel(panel);
36256 panel.setRegion(this);
36257 this.panels.add(panel);
36258 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
36259 // sinle panel - no tab...?? would it not be better to render it with the tabs,
36260 // and hide them... ???
36261 this.bodyEl.dom.appendChild(panel.getEl().dom);
36262 if(panel.background !== true){
36263 this.setActivePanel(panel);
36265 this.fireEvent("paneladded", this, panel);
36272 this.initPanelAsTab(panel);
36276 if(panel.background !== true){
36277 this.tabs.activate(panel.getEl().id);
36279 this.fireEvent("paneladded", this, panel);
36284 * Hides the tab for the specified panel.
36285 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36287 hidePanel : function(panel){
36288 if(this.tabs && (panel = this.getPanel(panel))){
36289 this.tabs.hideTab(panel.getEl().id);
36294 * Unhides the tab for a previously hidden panel.
36295 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36297 unhidePanel : function(panel){
36298 if(this.tabs && (panel = this.getPanel(panel))){
36299 this.tabs.unhideTab(panel.getEl().id);
36303 clearPanels : function(){
36304 while(this.panels.getCount() > 0){
36305 this.remove(this.panels.first());
36310 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
36311 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36312 * @param {Boolean} preservePanel Overrides the config preservePanel option
36313 * @return {Roo.ContentPanel} The panel that was removed
36315 remove : function(panel, preservePanel)
36317 panel = this.getPanel(panel);
36322 this.fireEvent("beforeremove", this, panel, e);
36323 if(e.cancel === true){
36326 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
36327 var panelId = panel.getId();
36328 this.panels.removeKey(panelId);
36330 document.body.appendChild(panel.getEl().dom);
36333 this.tabs.removeTab(panel.getEl().id);
36334 }else if (!preservePanel){
36335 this.bodyEl.dom.removeChild(panel.getEl().dom);
36337 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
36338 var p = this.panels.first();
36339 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
36340 tempEl.appendChild(p.getEl().dom);
36341 this.bodyEl.update("");
36342 this.bodyEl.dom.appendChild(p.getEl().dom);
36344 this.updateTitle(p.getTitle());
36346 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
36347 this.setActivePanel(p);
36349 panel.setRegion(null);
36350 if(this.activePanel == panel){
36351 this.activePanel = null;
36353 if(this.config.autoDestroy !== false && preservePanel !== true){
36354 try{panel.destroy();}catch(e){}
36356 this.fireEvent("panelremoved", this, panel);
36361 * Returns the TabPanel component used by this region
36362 * @return {Roo.TabPanel}
36364 getTabs : function(){
36368 createTool : function(parentEl, className){
36369 var btn = Roo.DomHelper.append(parentEl, {
36371 cls: "x-layout-tools-button",
36374 cls: "roo-layout-tools-button-inner " + className,
36378 btn.addClassOnOver("roo-layout-tools-button-over");
36383 * Ext JS Library 1.1.1
36384 * Copyright(c) 2006-2007, Ext JS, LLC.
36386 * Originally Released Under LGPL - original licence link has changed is not relivant.
36389 * <script type="text/javascript">
36395 * @class Roo.SplitLayoutRegion
36396 * @extends Roo.LayoutRegion
36397 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
36399 Roo.bootstrap.layout.Split = function(config){
36400 this.cursor = config.cursor;
36401 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
36404 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
36406 splitTip : "Drag to resize.",
36407 collapsibleSplitTip : "Drag to resize. Double click to hide.",
36408 useSplitTips : false,
36410 applyConfig : function(config){
36411 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
36414 onRender : function(ctr,pos) {
36416 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
36417 if(!this.config.split){
36422 var splitEl = Roo.DomHelper.append(ctr.dom, {
36424 id: this.el.id + "-split",
36425 cls: "roo-layout-split roo-layout-split-"+this.position,
36428 /** The SplitBar for this region
36429 * @type Roo.SplitBar */
36430 // does not exist yet...
36431 Roo.log([this.position, this.orientation]);
36433 this.split = new Roo.bootstrap.SplitBar({
36434 dragElement : splitEl,
36435 resizingElement: this.el,
36436 orientation : this.orientation
36439 this.split.on("moved", this.onSplitMove, this);
36440 this.split.useShim = this.config.useShim === true;
36441 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
36442 if(this.useSplitTips){
36443 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
36445 //if(config.collapsible){
36446 // this.split.el.on("dblclick", this.collapse, this);
36449 if(typeof this.config.minSize != "undefined"){
36450 this.split.minSize = this.config.minSize;
36452 if(typeof this.config.maxSize != "undefined"){
36453 this.split.maxSize = this.config.maxSize;
36455 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
36456 this.hideSplitter();
36461 getHMaxSize : function(){
36462 var cmax = this.config.maxSize || 10000;
36463 var center = this.mgr.getRegion("center");
36464 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
36467 getVMaxSize : function(){
36468 var cmax = this.config.maxSize || 10000;
36469 var center = this.mgr.getRegion("center");
36470 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
36473 onSplitMove : function(split, newSize){
36474 this.fireEvent("resized", this, newSize);
36478 * Returns the {@link Roo.SplitBar} for this region.
36479 * @return {Roo.SplitBar}
36481 getSplitBar : function(){
36486 this.hideSplitter();
36487 Roo.bootstrap.layout.Split.superclass.hide.call(this);
36490 hideSplitter : function(){
36492 this.split.el.setLocation(-2000,-2000);
36493 this.split.el.hide();
36499 this.split.el.show();
36501 Roo.bootstrap.layout.Split.superclass.show.call(this);
36504 beforeSlide: function(){
36505 if(Roo.isGecko){// firefox overflow auto bug workaround
36506 this.bodyEl.clip();
36508 this.tabs.bodyEl.clip();
36510 if(this.activePanel){
36511 this.activePanel.getEl().clip();
36513 if(this.activePanel.beforeSlide){
36514 this.activePanel.beforeSlide();
36520 afterSlide : function(){
36521 if(Roo.isGecko){// firefox overflow auto bug workaround
36522 this.bodyEl.unclip();
36524 this.tabs.bodyEl.unclip();
36526 if(this.activePanel){
36527 this.activePanel.getEl().unclip();
36528 if(this.activePanel.afterSlide){
36529 this.activePanel.afterSlide();
36535 initAutoHide : function(){
36536 if(this.autoHide !== false){
36537 if(!this.autoHideHd){
36538 var st = new Roo.util.DelayedTask(this.slideIn, this);
36539 this.autoHideHd = {
36540 "mouseout": function(e){
36541 if(!e.within(this.el, true)){
36545 "mouseover" : function(e){
36551 this.el.on(this.autoHideHd);
36555 clearAutoHide : function(){
36556 if(this.autoHide !== false){
36557 this.el.un("mouseout", this.autoHideHd.mouseout);
36558 this.el.un("mouseover", this.autoHideHd.mouseover);
36562 clearMonitor : function(){
36563 Roo.get(document).un("click", this.slideInIf, this);
36566 // these names are backwards but not changed for compat
36567 slideOut : function(){
36568 if(this.isSlid || this.el.hasActiveFx()){
36571 this.isSlid = true;
36572 if(this.collapseBtn){
36573 this.collapseBtn.hide();
36575 this.closeBtnState = this.closeBtn.getStyle('display');
36576 this.closeBtn.hide();
36578 this.stickBtn.show();
36581 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
36582 this.beforeSlide();
36583 this.el.setStyle("z-index", 10001);
36584 this.el.slideIn(this.getSlideAnchor(), {
36585 callback: function(){
36587 this.initAutoHide();
36588 Roo.get(document).on("click", this.slideInIf, this);
36589 this.fireEvent("slideshow", this);
36596 afterSlideIn : function(){
36597 this.clearAutoHide();
36598 this.isSlid = false;
36599 this.clearMonitor();
36600 this.el.setStyle("z-index", "");
36601 if(this.collapseBtn){
36602 this.collapseBtn.show();
36604 this.closeBtn.setStyle('display', this.closeBtnState);
36606 this.stickBtn.hide();
36608 this.fireEvent("slidehide", this);
36611 slideIn : function(cb){
36612 if(!this.isSlid || this.el.hasActiveFx()){
36616 this.isSlid = false;
36617 this.beforeSlide();
36618 this.el.slideOut(this.getSlideAnchor(), {
36619 callback: function(){
36620 this.el.setLeftTop(-10000, -10000);
36622 this.afterSlideIn();
36630 slideInIf : function(e){
36631 if(!e.within(this.el)){
36636 animateCollapse : function(){
36637 this.beforeSlide();
36638 this.el.setStyle("z-index", 20000);
36639 var anchor = this.getSlideAnchor();
36640 this.el.slideOut(anchor, {
36641 callback : function(){
36642 this.el.setStyle("z-index", "");
36643 this.collapsedEl.slideIn(anchor, {duration:.3});
36645 this.el.setLocation(-10000,-10000);
36647 this.fireEvent("collapsed", this);
36654 animateExpand : function(){
36655 this.beforeSlide();
36656 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
36657 this.el.setStyle("z-index", 20000);
36658 this.collapsedEl.hide({
36661 this.el.slideIn(this.getSlideAnchor(), {
36662 callback : function(){
36663 this.el.setStyle("z-index", "");
36666 this.split.el.show();
36668 this.fireEvent("invalidated", this);
36669 this.fireEvent("expanded", this);
36697 getAnchor : function(){
36698 return this.anchors[this.position];
36701 getCollapseAnchor : function(){
36702 return this.canchors[this.position];
36705 getSlideAnchor : function(){
36706 return this.sanchors[this.position];
36709 getAlignAdj : function(){
36710 var cm = this.cmargins;
36711 switch(this.position){
36727 getExpandAdj : function(){
36728 var c = this.collapsedEl, cm = this.cmargins;
36729 switch(this.position){
36731 return [-(cm.right+c.getWidth()+cm.left), 0];
36734 return [cm.right+c.getWidth()+cm.left, 0];
36737 return [0, -(cm.top+cm.bottom+c.getHeight())];
36740 return [0, cm.top+cm.bottom+c.getHeight()];
36746 * Ext JS Library 1.1.1
36747 * Copyright(c) 2006-2007, Ext JS, LLC.
36749 * Originally Released Under LGPL - original licence link has changed is not relivant.
36752 * <script type="text/javascript">
36755 * These classes are private internal classes
36757 Roo.bootstrap.layout.Center = function(config){
36758 config.region = "center";
36759 Roo.bootstrap.layout.Region.call(this, config);
36760 this.visible = true;
36761 this.minWidth = config.minWidth || 20;
36762 this.minHeight = config.minHeight || 20;
36765 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
36767 // center panel can't be hidden
36771 // center panel can't be hidden
36774 getMinWidth: function(){
36775 return this.minWidth;
36778 getMinHeight: function(){
36779 return this.minHeight;
36792 Roo.bootstrap.layout.North = function(config)
36794 config.region = 'north';
36795 config.cursor = 'n-resize';
36797 Roo.bootstrap.layout.Split.call(this, config);
36801 this.split.placement = Roo.bootstrap.SplitBar.TOP;
36802 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
36803 this.split.el.addClass("roo-layout-split-v");
36805 var size = config.initialSize || config.height;
36806 if(typeof size != "undefined"){
36807 this.el.setHeight(size);
36810 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
36812 orientation: Roo.bootstrap.SplitBar.VERTICAL,
36816 getBox : function(){
36817 if(this.collapsed){
36818 return this.collapsedEl.getBox();
36820 var box = this.el.getBox();
36822 box.height += this.split.el.getHeight();
36827 updateBox : function(box){
36828 if(this.split && !this.collapsed){
36829 box.height -= this.split.el.getHeight();
36830 this.split.el.setLeft(box.x);
36831 this.split.el.setTop(box.y+box.height);
36832 this.split.el.setWidth(box.width);
36834 if(this.collapsed){
36835 this.updateBody(box.width, null);
36837 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36845 Roo.bootstrap.layout.South = function(config){
36846 config.region = 'south';
36847 config.cursor = 's-resize';
36848 Roo.bootstrap.layout.Split.call(this, config);
36850 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
36851 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
36852 this.split.el.addClass("roo-layout-split-v");
36854 var size = config.initialSize || config.height;
36855 if(typeof size != "undefined"){
36856 this.el.setHeight(size);
36860 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
36861 orientation: Roo.bootstrap.SplitBar.VERTICAL,
36862 getBox : function(){
36863 if(this.collapsed){
36864 return this.collapsedEl.getBox();
36866 var box = this.el.getBox();
36868 var sh = this.split.el.getHeight();
36875 updateBox : function(box){
36876 if(this.split && !this.collapsed){
36877 var sh = this.split.el.getHeight();
36880 this.split.el.setLeft(box.x);
36881 this.split.el.setTop(box.y-sh);
36882 this.split.el.setWidth(box.width);
36884 if(this.collapsed){
36885 this.updateBody(box.width, null);
36887 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36891 Roo.bootstrap.layout.East = function(config){
36892 config.region = "east";
36893 config.cursor = "e-resize";
36894 Roo.bootstrap.layout.Split.call(this, config);
36896 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
36897 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
36898 this.split.el.addClass("roo-layout-split-h");
36900 var size = config.initialSize || config.width;
36901 if(typeof size != "undefined"){
36902 this.el.setWidth(size);
36905 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
36906 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
36907 getBox : function(){
36908 if(this.collapsed){
36909 return this.collapsedEl.getBox();
36911 var box = this.el.getBox();
36913 var sw = this.split.el.getWidth();
36920 updateBox : function(box){
36921 if(this.split && !this.collapsed){
36922 var sw = this.split.el.getWidth();
36924 this.split.el.setLeft(box.x);
36925 this.split.el.setTop(box.y);
36926 this.split.el.setHeight(box.height);
36929 if(this.collapsed){
36930 this.updateBody(null, box.height);
36932 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36936 Roo.bootstrap.layout.West = function(config){
36937 config.region = "west";
36938 config.cursor = "w-resize";
36940 Roo.bootstrap.layout.Split.call(this, config);
36942 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
36943 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
36944 this.split.el.addClass("roo-layout-split-h");
36948 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
36949 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
36951 onRender: function(ctr, pos)
36953 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
36954 var size = this.config.initialSize || this.config.width;
36955 if(typeof size != "undefined"){
36956 this.el.setWidth(size);
36960 getBox : function(){
36961 if(this.collapsed){
36962 return this.collapsedEl.getBox();
36964 var box = this.el.getBox();
36966 box.width += this.split.el.getWidth();
36971 updateBox : function(box){
36972 if(this.split && !this.collapsed){
36973 var sw = this.split.el.getWidth();
36975 this.split.el.setLeft(box.x+box.width);
36976 this.split.el.setTop(box.y);
36977 this.split.el.setHeight(box.height);
36979 if(this.collapsed){
36980 this.updateBody(null, box.height);
36982 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36985 Roo.namespace("Roo.bootstrap.panel");/*
36987 * Ext JS Library 1.1.1
36988 * Copyright(c) 2006-2007, Ext JS, LLC.
36990 * Originally Released Under LGPL - original licence link has changed is not relivant.
36993 * <script type="text/javascript">
36996 * @class Roo.ContentPanel
36997 * @extends Roo.util.Observable
36998 * A basic ContentPanel element.
36999 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
37000 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
37001 * @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
37002 * @cfg {Boolean} closable True if the panel can be closed/removed
37003 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
37004 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
37005 * @cfg {Toolbar} toolbar A toolbar for this panel
37006 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
37007 * @cfg {String} title The title for this panel
37008 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
37009 * @cfg {String} url Calls {@link #setUrl} with this value
37010 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
37011 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
37012 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
37013 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
37014 * @cfg {Boolean} badges render the badges
37017 * Create a new ContentPanel.
37018 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
37019 * @param {String/Object} config A string to set only the title or a config object
37020 * @param {String} content (optional) Set the HTML content for this panel
37021 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
37023 Roo.bootstrap.panel.Content = function( config){
37025 this.tpl = config.tpl || false;
37027 var el = config.el;
37028 var content = config.content;
37030 if(config.autoCreate){ // xtype is available if this is called from factory
37033 this.el = Roo.get(el);
37034 if(!this.el && config && config.autoCreate){
37035 if(typeof config.autoCreate == "object"){
37036 if(!config.autoCreate.id){
37037 config.autoCreate.id = config.id||el;
37039 this.el = Roo.DomHelper.append(document.body,
37040 config.autoCreate, true);
37042 var elcfg = { tag: "div",
37043 cls: "roo-layout-inactive-content",
37047 elcfg.html = config.html;
37051 this.el = Roo.DomHelper.append(document.body, elcfg , true);
37054 this.closable = false;
37055 this.loaded = false;
37056 this.active = false;
37059 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
37061 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
37063 this.wrapEl = this.el; //this.el.wrap();
37065 if (config.toolbar.items) {
37066 ti = config.toolbar.items ;
37067 delete config.toolbar.items ;
37071 this.toolbar.render(this.wrapEl, 'before');
37072 for(var i =0;i < ti.length;i++) {
37073 // Roo.log(['add child', items[i]]);
37074 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37076 this.toolbar.items = nitems;
37077 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
37078 delete config.toolbar;
37082 // xtype created footer. - not sure if will work as we normally have to render first..
37083 if (this.footer && !this.footer.el && this.footer.xtype) {
37084 if (!this.wrapEl) {
37085 this.wrapEl = this.el.wrap();
37088 this.footer.container = this.wrapEl.createChild();
37090 this.footer = Roo.factory(this.footer, Roo);
37095 if(typeof config == "string"){
37096 this.title = config;
37098 Roo.apply(this, config);
37102 this.resizeEl = Roo.get(this.resizeEl, true);
37104 this.resizeEl = this.el;
37106 // handle view.xtype
37114 * Fires when this panel is activated.
37115 * @param {Roo.ContentPanel} this
37119 * @event deactivate
37120 * Fires when this panel is activated.
37121 * @param {Roo.ContentPanel} this
37123 "deactivate" : true,
37127 * Fires when this panel is resized if fitToFrame is true.
37128 * @param {Roo.ContentPanel} this
37129 * @param {Number} width The width after any component adjustments
37130 * @param {Number} height The height after any component adjustments
37136 * Fires when this tab is created
37137 * @param {Roo.ContentPanel} this
37148 if(this.autoScroll){
37149 this.resizeEl.setStyle("overflow", "auto");
37151 // fix randome scrolling
37152 //this.el.on('scroll', function() {
37153 // Roo.log('fix random scolling');
37154 // this.scrollTo('top',0);
37157 content = content || this.content;
37159 this.setContent(content);
37161 if(config && config.url){
37162 this.setUrl(this.url, this.params, this.loadOnce);
37167 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
37169 if (this.view && typeof(this.view.xtype) != 'undefined') {
37170 this.view.el = this.el.appendChild(document.createElement("div"));
37171 this.view = Roo.factory(this.view);
37172 this.view.render && this.view.render(false, '');
37176 this.fireEvent('render', this);
37179 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
37183 setRegion : function(region){
37184 this.region = region;
37185 this.setActiveClass(region && !this.background);
37189 setActiveClass: function(state)
37192 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
37193 this.el.setStyle('position','relative');
37195 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
37196 this.el.setStyle('position', 'absolute');
37201 * Returns the toolbar for this Panel if one was configured.
37202 * @return {Roo.Toolbar}
37204 getToolbar : function(){
37205 return this.toolbar;
37208 setActiveState : function(active)
37210 this.active = active;
37211 this.setActiveClass(active);
37213 if(this.fireEvent("deactivate", this) === false){
37218 this.fireEvent("activate", this);
37222 * Updates this panel's element
37223 * @param {String} content The new content
37224 * @param {Boolean} loadScripts (optional) true to look for and process scripts
37226 setContent : function(content, loadScripts){
37227 this.el.update(content, loadScripts);
37230 ignoreResize : function(w, h){
37231 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
37234 this.lastSize = {width: w, height: h};
37239 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
37240 * @return {Roo.UpdateManager} The UpdateManager
37242 getUpdateManager : function(){
37243 return this.el.getUpdateManager();
37246 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
37247 * @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:
37250 url: "your-url.php",
37251 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
37252 callback: yourFunction,
37253 scope: yourObject, //(optional scope)
37256 text: "Loading...",
37261 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
37262 * 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.
37263 * @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}
37264 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
37265 * @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.
37266 * @return {Roo.ContentPanel} this
37269 var um = this.el.getUpdateManager();
37270 um.update.apply(um, arguments);
37276 * 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.
37277 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
37278 * @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)
37279 * @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)
37280 * @return {Roo.UpdateManager} The UpdateManager
37282 setUrl : function(url, params, loadOnce){
37283 if(this.refreshDelegate){
37284 this.removeListener("activate", this.refreshDelegate);
37286 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
37287 this.on("activate", this.refreshDelegate);
37288 return this.el.getUpdateManager();
37291 _handleRefresh : function(url, params, loadOnce){
37292 if(!loadOnce || !this.loaded){
37293 var updater = this.el.getUpdateManager();
37294 updater.update(url, params, this._setLoaded.createDelegate(this));
37298 _setLoaded : function(){
37299 this.loaded = true;
37303 * Returns this panel's id
37306 getId : function(){
37311 * Returns this panel's element - used by regiosn to add.
37312 * @return {Roo.Element}
37314 getEl : function(){
37315 return this.wrapEl || this.el;
37320 adjustForComponents : function(width, height)
37322 //Roo.log('adjustForComponents ');
37323 if(this.resizeEl != this.el){
37324 width -= this.el.getFrameWidth('lr');
37325 height -= this.el.getFrameWidth('tb');
37328 var te = this.toolbar.getEl();
37329 te.setWidth(width);
37330 height -= te.getHeight();
37333 var te = this.footer.getEl();
37334 te.setWidth(width);
37335 height -= te.getHeight();
37339 if(this.adjustments){
37340 width += this.adjustments[0];
37341 height += this.adjustments[1];
37343 return {"width": width, "height": height};
37346 setSize : function(width, height){
37347 if(this.fitToFrame && !this.ignoreResize(width, height)){
37348 if(this.fitContainer && this.resizeEl != this.el){
37349 this.el.setSize(width, height);
37351 var size = this.adjustForComponents(width, height);
37352 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
37353 this.fireEvent('resize', this, size.width, size.height);
37358 * Returns this panel's title
37361 getTitle : function(){
37363 if (typeof(this.title) != 'object') {
37368 for (var k in this.title) {
37369 if (!this.title.hasOwnProperty(k)) {
37373 if (k.indexOf('-') >= 0) {
37374 var s = k.split('-');
37375 for (var i = 0; i<s.length; i++) {
37376 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
37379 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
37386 * Set this panel's title
37387 * @param {String} title
37389 setTitle : function(title){
37390 this.title = title;
37392 this.region.updatePanelTitle(this, title);
37397 * Returns true is this panel was configured to be closable
37398 * @return {Boolean}
37400 isClosable : function(){
37401 return this.closable;
37404 beforeSlide : function(){
37406 this.resizeEl.clip();
37409 afterSlide : function(){
37411 this.resizeEl.unclip();
37415 * Force a content refresh from the URL specified in the {@link #setUrl} method.
37416 * Will fail silently if the {@link #setUrl} method has not been called.
37417 * This does not activate the panel, just updates its content.
37419 refresh : function(){
37420 if(this.refreshDelegate){
37421 this.loaded = false;
37422 this.refreshDelegate();
37427 * Destroys this panel
37429 destroy : function(){
37430 this.el.removeAllListeners();
37431 var tempEl = document.createElement("span");
37432 tempEl.appendChild(this.el.dom);
37433 tempEl.innerHTML = "";
37439 * form - if the content panel contains a form - this is a reference to it.
37440 * @type {Roo.form.Form}
37444 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
37445 * This contains a reference to it.
37451 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
37461 * @param {Object} cfg Xtype definition of item to add.
37465 getChildContainer: function () {
37466 return this.getEl();
37471 var ret = new Roo.factory(cfg);
37476 if (cfg.xtype.match(/^Form$/)) {
37479 //if (this.footer) {
37480 // el = this.footer.container.insertSibling(false, 'before');
37482 el = this.el.createChild();
37485 this.form = new Roo.form.Form(cfg);
37488 if ( this.form.allItems.length) {
37489 this.form.render(el.dom);
37493 // should only have one of theses..
37494 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
37495 // views.. should not be just added - used named prop 'view''
37497 cfg.el = this.el.appendChild(document.createElement("div"));
37500 var ret = new Roo.factory(cfg);
37502 ret.render && ret.render(false, ''); // render blank..
37512 * @class Roo.bootstrap.panel.Grid
37513 * @extends Roo.bootstrap.panel.Content
37515 * Create a new GridPanel.
37516 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
37517 * @param {Object} config A the config object
37523 Roo.bootstrap.panel.Grid = function(config)
37527 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
37528 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
37530 config.el = this.wrapper;
37531 //this.el = this.wrapper;
37533 if (config.container) {
37534 // ctor'ed from a Border/panel.grid
37537 this.wrapper.setStyle("overflow", "hidden");
37538 this.wrapper.addClass('roo-grid-container');
37543 if(config.toolbar){
37544 var tool_el = this.wrapper.createChild();
37545 this.toolbar = Roo.factory(config.toolbar);
37547 if (config.toolbar.items) {
37548 ti = config.toolbar.items ;
37549 delete config.toolbar.items ;
37553 this.toolbar.render(tool_el);
37554 for(var i =0;i < ti.length;i++) {
37555 // Roo.log(['add child', items[i]]);
37556 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37558 this.toolbar.items = nitems;
37560 delete config.toolbar;
37563 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
37564 config.grid.scrollBody = true;;
37565 config.grid.monitorWindowResize = false; // turn off autosizing
37566 config.grid.autoHeight = false;
37567 config.grid.autoWidth = false;
37569 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
37571 if (config.background) {
37572 // render grid on panel activation (if panel background)
37573 this.on('activate', function(gp) {
37574 if (!gp.grid.rendered) {
37575 gp.grid.render(this.wrapper);
37576 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37581 this.grid.render(this.wrapper);
37582 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37585 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
37586 // ??? needed ??? config.el = this.wrapper;
37591 // xtype created footer. - not sure if will work as we normally have to render first..
37592 if (this.footer && !this.footer.el && this.footer.xtype) {
37594 var ctr = this.grid.getView().getFooterPanel(true);
37595 this.footer.dataSource = this.grid.dataSource;
37596 this.footer = Roo.factory(this.footer, Roo);
37597 this.footer.render(ctr);
37607 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
37608 getId : function(){
37609 return this.grid.id;
37613 * Returns the grid for this panel
37614 * @return {Roo.bootstrap.Table}
37616 getGrid : function(){
37620 setSize : function(width, height){
37621 if(!this.ignoreResize(width, height)){
37622 var grid = this.grid;
37623 var size = this.adjustForComponents(width, height);
37624 var gridel = grid.getGridEl();
37625 gridel.setSize(size.width, size.height);
37627 var thd = grid.getGridEl().select('thead',true).first();
37628 var tbd = grid.getGridEl().select('tbody', true).first();
37630 tbd.setSize(width, height - thd.getHeight());
37639 beforeSlide : function(){
37640 this.grid.getView().scroller.clip();
37643 afterSlide : function(){
37644 this.grid.getView().scroller.unclip();
37647 destroy : function(){
37648 this.grid.destroy();
37650 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
37655 * @class Roo.bootstrap.panel.Nest
37656 * @extends Roo.bootstrap.panel.Content
37658 * Create a new Panel, that can contain a layout.Border.
37661 * @param {Roo.BorderLayout} layout The layout for this panel
37662 * @param {String/Object} config A string to set only the title or a config object
37664 Roo.bootstrap.panel.Nest = function(config)
37666 // construct with only one argument..
37667 /* FIXME - implement nicer consturctors
37668 if (layout.layout) {
37670 layout = config.layout;
37671 delete config.layout;
37673 if (layout.xtype && !layout.getEl) {
37674 // then layout needs constructing..
37675 layout = Roo.factory(layout, Roo);
37679 config.el = config.layout.getEl();
37681 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
37683 config.layout.monitorWindowResize = false; // turn off autosizing
37684 this.layout = config.layout;
37685 this.layout.getEl().addClass("roo-layout-nested-layout");
37692 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
37694 setSize : function(width, height){
37695 if(!this.ignoreResize(width, height)){
37696 var size = this.adjustForComponents(width, height);
37697 var el = this.layout.getEl();
37698 if (size.height < 1) {
37699 el.setWidth(size.width);
37701 el.setSize(size.width, size.height);
37703 var touch = el.dom.offsetWidth;
37704 this.layout.layout();
37705 // ie requires a double layout on the first pass
37706 if(Roo.isIE && !this.initialized){
37707 this.initialized = true;
37708 this.layout.layout();
37713 // activate all subpanels if not currently active..
37715 setActiveState : function(active){
37716 this.active = active;
37717 this.setActiveClass(active);
37720 this.fireEvent("deactivate", this);
37724 this.fireEvent("activate", this);
37725 // not sure if this should happen before or after..
37726 if (!this.layout) {
37727 return; // should not happen..
37730 for (var r in this.layout.regions) {
37731 reg = this.layout.getRegion(r);
37732 if (reg.getActivePanel()) {
37733 //reg.showPanel(reg.getActivePanel()); // force it to activate..
37734 reg.setActivePanel(reg.getActivePanel());
37737 if (!reg.panels.length) {
37740 reg.showPanel(reg.getPanel(0));
37749 * Returns the nested BorderLayout for this panel
37750 * @return {Roo.BorderLayout}
37752 getLayout : function(){
37753 return this.layout;
37757 * Adds a xtype elements to the layout of the nested panel
37761 xtype : 'ContentPanel',
37768 xtype : 'NestedLayoutPanel',
37774 items : [ ... list of content panels or nested layout panels.. ]
37778 * @param {Object} cfg Xtype definition of item to add.
37780 addxtype : function(cfg) {
37781 return this.layout.addxtype(cfg);
37786 * Ext JS Library 1.1.1
37787 * Copyright(c) 2006-2007, Ext JS, LLC.
37789 * Originally Released Under LGPL - original licence link has changed is not relivant.
37792 * <script type="text/javascript">
37795 * @class Roo.TabPanel
37796 * @extends Roo.util.Observable
37797 * A lightweight tab container.
37801 // basic tabs 1, built from existing content
37802 var tabs = new Roo.TabPanel("tabs1");
37803 tabs.addTab("script", "View Script");
37804 tabs.addTab("markup", "View Markup");
37805 tabs.activate("script");
37807 // more advanced tabs, built from javascript
37808 var jtabs = new Roo.TabPanel("jtabs");
37809 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
37811 // set up the UpdateManager
37812 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
37813 var updater = tab2.getUpdateManager();
37814 updater.setDefaultUrl("ajax1.htm");
37815 tab2.on('activate', updater.refresh, updater, true);
37817 // Use setUrl for Ajax loading
37818 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
37819 tab3.setUrl("ajax2.htm", null, true);
37822 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
37825 jtabs.activate("jtabs-1");
37828 * Create a new TabPanel.
37829 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
37830 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
37832 Roo.bootstrap.panel.Tabs = function(config){
37834 * The container element for this TabPanel.
37835 * @type Roo.Element
37837 this.el = Roo.get(config.el);
37840 if(typeof config == "boolean"){
37841 this.tabPosition = config ? "bottom" : "top";
37843 Roo.apply(this, config);
37847 if(this.tabPosition == "bottom"){
37848 this.bodyEl = Roo.get(this.createBody(this.el.dom));
37849 this.el.addClass("roo-tabs-bottom");
37851 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
37852 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
37853 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
37855 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
37857 if(this.tabPosition != "bottom"){
37858 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
37859 * @type Roo.Element
37861 this.bodyEl = Roo.get(this.createBody(this.el.dom));
37862 this.el.addClass("roo-tabs-top");
37866 this.bodyEl.setStyle("position", "relative");
37868 this.active = null;
37869 this.activateDelegate = this.activate.createDelegate(this);
37874 * Fires when the active tab changes
37875 * @param {Roo.TabPanel} this
37876 * @param {Roo.TabPanelItem} activePanel The new active tab
37880 * @event beforetabchange
37881 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
37882 * @param {Roo.TabPanel} this
37883 * @param {Object} e Set cancel to true on this object to cancel the tab change
37884 * @param {Roo.TabPanelItem} tab The tab being changed to
37886 "beforetabchange" : true
37889 Roo.EventManager.onWindowResize(this.onResize, this);
37890 this.cpad = this.el.getPadding("lr");
37891 this.hiddenCount = 0;
37894 // toolbar on the tabbar support...
37895 if (this.toolbar) {
37896 alert("no toolbar support yet");
37897 this.toolbar = false;
37899 var tcfg = this.toolbar;
37900 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
37901 this.toolbar = new Roo.Toolbar(tcfg);
37902 if (Roo.isSafari) {
37903 var tbl = tcfg.container.child('table', true);
37904 tbl.setAttribute('width', '100%');
37912 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
37915 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
37917 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
37919 tabPosition : "top",
37921 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
37923 currentTabWidth : 0,
37925 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
37929 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
37933 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
37935 preferredTabWidth : 175,
37937 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
37939 resizeTabs : false,
37941 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
37943 monitorResize : true,
37945 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
37950 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
37951 * @param {String} id The id of the div to use <b>or create</b>
37952 * @param {String} text The text for the tab
37953 * @param {String} content (optional) Content to put in the TabPanelItem body
37954 * @param {Boolean} closable (optional) True to create a close icon on the tab
37955 * @return {Roo.TabPanelItem} The created TabPanelItem
37957 addTab : function(id, text, content, closable, tpl)
37959 var item = new Roo.bootstrap.panel.TabItem({
37963 closable : closable,
37966 this.addTabItem(item);
37968 item.setContent(content);
37974 * Returns the {@link Roo.TabPanelItem} with the specified id/index
37975 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
37976 * @return {Roo.TabPanelItem}
37978 getTab : function(id){
37979 return this.items[id];
37983 * Hides the {@link Roo.TabPanelItem} with the specified id/index
37984 * @param {String/Number} id The id or index of the TabPanelItem to hide.
37986 hideTab : function(id){
37987 var t = this.items[id];
37990 this.hiddenCount++;
37991 this.autoSizeTabs();
37996 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
37997 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
37999 unhideTab : function(id){
38000 var t = this.items[id];
38002 t.setHidden(false);
38003 this.hiddenCount--;
38004 this.autoSizeTabs();
38009 * Adds an existing {@link Roo.TabPanelItem}.
38010 * @param {Roo.TabPanelItem} item The TabPanelItem to add
38012 addTabItem : function(item){
38013 this.items[item.id] = item;
38014 this.items.push(item);
38015 // if(this.resizeTabs){
38016 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
38017 // this.autoSizeTabs();
38019 // item.autoSize();
38024 * Removes a {@link Roo.TabPanelItem}.
38025 * @param {String/Number} id The id or index of the TabPanelItem to remove.
38027 removeTab : function(id){
38028 var items = this.items;
38029 var tab = items[id];
38030 if(!tab) { return; }
38031 var index = items.indexOf(tab);
38032 if(this.active == tab && items.length > 1){
38033 var newTab = this.getNextAvailable(index);
38038 this.stripEl.dom.removeChild(tab.pnode.dom);
38039 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
38040 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
38042 items.splice(index, 1);
38043 delete this.items[tab.id];
38044 tab.fireEvent("close", tab);
38045 tab.purgeListeners();
38046 this.autoSizeTabs();
38049 getNextAvailable : function(start){
38050 var items = this.items;
38052 // look for a next tab that will slide over to
38053 // replace the one being removed
38054 while(index < items.length){
38055 var item = items[++index];
38056 if(item && !item.isHidden()){
38060 // if one isn't found select the previous tab (on the left)
38063 var item = items[--index];
38064 if(item && !item.isHidden()){
38072 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
38073 * @param {String/Number} id The id or index of the TabPanelItem to disable.
38075 disableTab : function(id){
38076 var tab = this.items[id];
38077 if(tab && this.active != tab){
38083 * Enables a {@link Roo.TabPanelItem} that is disabled.
38084 * @param {String/Number} id The id or index of the TabPanelItem to enable.
38086 enableTab : function(id){
38087 var tab = this.items[id];
38092 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
38093 * @param {String/Number} id The id or index of the TabPanelItem to activate.
38094 * @return {Roo.TabPanelItem} The TabPanelItem.
38096 activate : function(id){
38097 var tab = this.items[id];
38101 if(tab == this.active || tab.disabled){
38105 this.fireEvent("beforetabchange", this, e, tab);
38106 if(e.cancel !== true && !tab.disabled){
38108 this.active.hide();
38110 this.active = this.items[id];
38111 this.active.show();
38112 this.fireEvent("tabchange", this, this.active);
38118 * Gets the active {@link Roo.TabPanelItem}.
38119 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
38121 getActiveTab : function(){
38122 return this.active;
38126 * Updates the tab body element to fit the height of the container element
38127 * for overflow scrolling
38128 * @param {Number} targetHeight (optional) Override the starting height from the elements height
38130 syncHeight : function(targetHeight){
38131 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
38132 var bm = this.bodyEl.getMargins();
38133 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
38134 this.bodyEl.setHeight(newHeight);
38138 onResize : function(){
38139 if(this.monitorResize){
38140 this.autoSizeTabs();
38145 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
38147 beginUpdate : function(){
38148 this.updating = true;
38152 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
38154 endUpdate : function(){
38155 this.updating = false;
38156 this.autoSizeTabs();
38160 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
38162 autoSizeTabs : function(){
38163 var count = this.items.length;
38164 var vcount = count - this.hiddenCount;
38165 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
38168 var w = Math.max(this.el.getWidth() - this.cpad, 10);
38169 var availWidth = Math.floor(w / vcount);
38170 var b = this.stripBody;
38171 if(b.getWidth() > w){
38172 var tabs = this.items;
38173 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
38174 if(availWidth < this.minTabWidth){
38175 /*if(!this.sleft){ // incomplete scrolling code
38176 this.createScrollButtons();
38179 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
38182 if(this.currentTabWidth < this.preferredTabWidth){
38183 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
38189 * Returns the number of tabs in this TabPanel.
38192 getCount : function(){
38193 return this.items.length;
38197 * Resizes all the tabs to the passed width
38198 * @param {Number} The new width
38200 setTabWidth : function(width){
38201 this.currentTabWidth = width;
38202 for(var i = 0, len = this.items.length; i < len; i++) {
38203 if(!this.items[i].isHidden()) {
38204 this.items[i].setWidth(width);
38210 * Destroys this TabPanel
38211 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
38213 destroy : function(removeEl){
38214 Roo.EventManager.removeResizeListener(this.onResize, this);
38215 for(var i = 0, len = this.items.length; i < len; i++){
38216 this.items[i].purgeListeners();
38218 if(removeEl === true){
38219 this.el.update("");
38224 createStrip : function(container)
38226 var strip = document.createElement("nav");
38227 strip.className = "navbar navbar-default"; //"x-tabs-wrap";
38228 container.appendChild(strip);
38232 createStripList : function(strip)
38234 // div wrapper for retard IE
38235 // returns the "tr" element.
38236 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
38237 //'<div class="x-tabs-strip-wrap">'+
38238 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
38239 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
38240 return strip.firstChild; //.firstChild.firstChild.firstChild;
38242 createBody : function(container)
38244 var body = document.createElement("div");
38245 Roo.id(body, "tab-body");
38246 //Roo.fly(body).addClass("x-tabs-body");
38247 Roo.fly(body).addClass("tab-content");
38248 container.appendChild(body);
38251 createItemBody :function(bodyEl, id){
38252 var body = Roo.getDom(id);
38254 body = document.createElement("div");
38257 //Roo.fly(body).addClass("x-tabs-item-body");
38258 Roo.fly(body).addClass("tab-pane");
38259 bodyEl.insertBefore(body, bodyEl.firstChild);
38263 createStripElements : function(stripEl, text, closable, tpl)
38265 var td = document.createElement("li"); // was td..
38268 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
38271 stripEl.appendChild(td);
38273 td.className = "x-tabs-closable";
38274 if(!this.closeTpl){
38275 this.closeTpl = new Roo.Template(
38276 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38277 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
38278 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
38281 var el = this.closeTpl.overwrite(td, {"text": text});
38282 var close = el.getElementsByTagName("div")[0];
38283 var inner = el.getElementsByTagName("em")[0];
38284 return {"el": el, "close": close, "inner": inner};
38287 // not sure what this is..
38288 // if(!this.tabTpl){
38289 //this.tabTpl = new Roo.Template(
38290 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38291 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
38293 // this.tabTpl = new Roo.Template(
38294 // '<a href="#">' +
38295 // '<span unselectable="on"' +
38296 // (this.disableTooltips ? '' : ' title="{text}"') +
38297 // ' >{text}</span></a>'
38303 var template = tpl || this.tabTpl || false;
38307 template = new Roo.Template(
38309 '<span unselectable="on"' +
38310 (this.disableTooltips ? '' : ' title="{text}"') +
38311 ' >{text}</span></a>'
38315 switch (typeof(template)) {
38319 template = new Roo.Template(template);
38325 var el = template.overwrite(td, {"text": text});
38327 var inner = el.getElementsByTagName("span")[0];
38329 return {"el": el, "inner": inner};
38337 * @class Roo.TabPanelItem
38338 * @extends Roo.util.Observable
38339 * Represents an individual item (tab plus body) in a TabPanel.
38340 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
38341 * @param {String} id The id of this TabPanelItem
38342 * @param {String} text The text for the tab of this TabPanelItem
38343 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
38345 Roo.bootstrap.panel.TabItem = function(config){
38347 * The {@link Roo.TabPanel} this TabPanelItem belongs to
38348 * @type Roo.TabPanel
38350 this.tabPanel = config.panel;
38352 * The id for this TabPanelItem
38355 this.id = config.id;
38357 this.disabled = false;
38359 this.text = config.text;
38361 this.loaded = false;
38362 this.closable = config.closable;
38365 * The body element for this TabPanelItem.
38366 * @type Roo.Element
38368 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
38369 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
38370 this.bodyEl.setStyle("display", "block");
38371 this.bodyEl.setStyle("zoom", "1");
38372 //this.hideAction();
38374 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
38376 this.el = Roo.get(els.el);
38377 this.inner = Roo.get(els.inner, true);
38378 this.textEl = Roo.get(this.el.dom.firstChild, true);
38379 this.pnode = Roo.get(els.el.parentNode, true);
38380 // this.el.on("mousedown", this.onTabMouseDown, this);
38381 this.el.on("click", this.onTabClick, this);
38383 if(config.closable){
38384 var c = Roo.get(els.close, true);
38385 c.dom.title = this.closeText;
38386 c.addClassOnOver("close-over");
38387 c.on("click", this.closeClick, this);
38393 * Fires when this tab becomes the active tab.
38394 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38395 * @param {Roo.TabPanelItem} this
38399 * @event beforeclose
38400 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
38401 * @param {Roo.TabPanelItem} this
38402 * @param {Object} e Set cancel to true on this object to cancel the close.
38404 "beforeclose": true,
38407 * Fires when this tab is closed.
38408 * @param {Roo.TabPanelItem} this
38412 * @event deactivate
38413 * Fires when this tab is no longer the active tab.
38414 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38415 * @param {Roo.TabPanelItem} this
38417 "deactivate" : true
38419 this.hidden = false;
38421 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
38424 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
38426 purgeListeners : function(){
38427 Roo.util.Observable.prototype.purgeListeners.call(this);
38428 this.el.removeAllListeners();
38431 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
38434 this.pnode.addClass("active");
38437 this.tabPanel.stripWrap.repaint();
38439 this.fireEvent("activate", this.tabPanel, this);
38443 * Returns true if this tab is the active tab.
38444 * @return {Boolean}
38446 isActive : function(){
38447 return this.tabPanel.getActiveTab() == this;
38451 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
38454 this.pnode.removeClass("active");
38456 this.fireEvent("deactivate", this.tabPanel, this);
38459 hideAction : function(){
38460 this.bodyEl.hide();
38461 this.bodyEl.setStyle("position", "absolute");
38462 this.bodyEl.setLeft("-20000px");
38463 this.bodyEl.setTop("-20000px");
38466 showAction : function(){
38467 this.bodyEl.setStyle("position", "relative");
38468 this.bodyEl.setTop("");
38469 this.bodyEl.setLeft("");
38470 this.bodyEl.show();
38474 * Set the tooltip for the tab.
38475 * @param {String} tooltip The tab's tooltip
38477 setTooltip : function(text){
38478 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
38479 this.textEl.dom.qtip = text;
38480 this.textEl.dom.removeAttribute('title');
38482 this.textEl.dom.title = text;
38486 onTabClick : function(e){
38487 e.preventDefault();
38488 this.tabPanel.activate(this.id);
38491 onTabMouseDown : function(e){
38492 e.preventDefault();
38493 this.tabPanel.activate(this.id);
38496 getWidth : function(){
38497 return this.inner.getWidth();
38500 setWidth : function(width){
38501 var iwidth = width - this.pnode.getPadding("lr");
38502 this.inner.setWidth(iwidth);
38503 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
38504 this.pnode.setWidth(width);
38508 * Show or hide the tab
38509 * @param {Boolean} hidden True to hide or false to show.
38511 setHidden : function(hidden){
38512 this.hidden = hidden;
38513 this.pnode.setStyle("display", hidden ? "none" : "");
38517 * Returns true if this tab is "hidden"
38518 * @return {Boolean}
38520 isHidden : function(){
38521 return this.hidden;
38525 * Returns the text for this tab
38528 getText : function(){
38532 autoSize : function(){
38533 //this.el.beginMeasure();
38534 this.textEl.setWidth(1);
38536 * #2804 [new] Tabs in Roojs
38537 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
38539 //this.setWidth(this.textEl.dom.scrollWidth+this.pnode.getPadding("lr")+this.inner.getPadding("lr") + 2);
38540 //this.el.endMeasure();
38544 * Sets the text for the tab (Note: this also sets the tooltip text)
38545 * @param {String} text The tab's text and tooltip
38547 setText : function(text){
38549 this.textEl.update(text);
38550 this.setTooltip(text);
38551 //if(!this.tabPanel.resizeTabs){
38552 // this.autoSize();
38556 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
38558 activate : function(){
38559 this.tabPanel.activate(this.id);
38563 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
38565 disable : function(){
38566 if(this.tabPanel.active != this){
38567 this.disabled = true;
38568 this.pnode.addClass("disabled");
38573 * Enables this TabPanelItem if it was previously disabled.
38575 enable : function(){
38576 this.disabled = false;
38577 this.pnode.removeClass("disabled");
38581 * Sets the content for this TabPanelItem.
38582 * @param {String} content The content
38583 * @param {Boolean} loadScripts true to look for and load scripts
38585 setContent : function(content, loadScripts){
38586 this.bodyEl.update(content, loadScripts);
38590 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
38591 * @return {Roo.UpdateManager} The UpdateManager
38593 getUpdateManager : function(){
38594 return this.bodyEl.getUpdateManager();
38598 * Set a URL to be used to load the content for this TabPanelItem.
38599 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
38600 * @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)
38601 * @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)
38602 * @return {Roo.UpdateManager} The UpdateManager
38604 setUrl : function(url, params, loadOnce){
38605 if(this.refreshDelegate){
38606 this.un('activate', this.refreshDelegate);
38608 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
38609 this.on("activate", this.refreshDelegate);
38610 return this.bodyEl.getUpdateManager();
38614 _handleRefresh : function(url, params, loadOnce){
38615 if(!loadOnce || !this.loaded){
38616 var updater = this.bodyEl.getUpdateManager();
38617 updater.update(url, params, this._setLoaded.createDelegate(this));
38622 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
38623 * Will fail silently if the setUrl method has not been called.
38624 * This does not activate the panel, just updates its content.
38626 refresh : function(){
38627 if(this.refreshDelegate){
38628 this.loaded = false;
38629 this.refreshDelegate();
38634 _setLoaded : function(){
38635 this.loaded = true;
38639 closeClick : function(e){
38642 this.fireEvent("beforeclose", this, o);
38643 if(o.cancel !== true){
38644 this.tabPanel.removeTab(this.id);
38648 * The text displayed in the tooltip for the close icon.
38651 closeText : "Close this tab"
38654 * This script refer to:
38655 * Title: International Telephone Input
38656 * Author: Jack O'Connor
38657 * Code version: v12.1.12
38658 * Availability: https://github.com/jackocnr/intl-tel-input.git
38661 Roo.bootstrap.PhoneInputData = function() {
38664 "Afghanistan (افغانستان)",
38669 "Albania (Shqipëri)",
38674 "Algeria (الجزائر)",
38699 "Antigua and Barbuda",
38709 "Armenia (Հայաստան)",
38725 "Austria (Österreich)",
38730 "Azerbaijan (Azərbaycan)",
38740 "Bahrain (البحرين)",
38745 "Bangladesh (বাংলাদেশ)",
38755 "Belarus (Беларусь)",
38760 "Belgium (België)",
38790 "Bosnia and Herzegovina (Босна и Херцеговина)",
38805 "British Indian Ocean Territory",
38810 "British Virgin Islands",
38820 "Bulgaria (България)",
38830 "Burundi (Uburundi)",
38835 "Cambodia (កម្ពុជា)",
38840 "Cameroon (Cameroun)",
38849 ["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"]
38852 "Cape Verde (Kabu Verdi)",
38857 "Caribbean Netherlands",
38868 "Central African Republic (République centrafricaine)",
38888 "Christmas Island",
38894 "Cocos (Keeling) Islands",
38905 "Comoros (جزر القمر)",
38910 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
38915 "Congo (Republic) (Congo-Brazzaville)",
38935 "Croatia (Hrvatska)",
38956 "Czech Republic (Česká republika)",
38961 "Denmark (Danmark)",
38976 "Dominican Republic (República Dominicana)",
38980 ["809", "829", "849"]
38998 "Equatorial Guinea (Guinea Ecuatorial)",
39018 "Falkland Islands (Islas Malvinas)",
39023 "Faroe Islands (Føroyar)",
39044 "French Guiana (Guyane française)",
39049 "French Polynesia (Polynésie française)",
39064 "Georgia (საქართველო)",
39069 "Germany (Deutschland)",
39089 "Greenland (Kalaallit Nunaat)",
39126 "Guinea-Bissau (Guiné Bissau)",
39151 "Hungary (Magyarország)",
39156 "Iceland (Ísland)",
39176 "Iraq (العراق)",
39192 "Israel (ישראל)",
39219 "Jordan (الأردن)",
39224 "Kazakhstan (Казахстан)",
39245 "Kuwait (الكويت)",
39250 "Kyrgyzstan (Кыргызстан)",
39260 "Latvia (Latvija)",
39265 "Lebanon (لبنان)",
39280 "Libya (ليبيا)",
39290 "Lithuania (Lietuva)",
39305 "Macedonia (FYROM) (Македонија)",
39310 "Madagascar (Madagasikara)",
39340 "Marshall Islands",
39350 "Mauritania (موريتانيا)",
39355 "Mauritius (Moris)",
39376 "Moldova (Republica Moldova)",
39386 "Mongolia (Монгол)",
39391 "Montenegro (Crna Gora)",
39401 "Morocco (المغرب)",
39407 "Mozambique (Moçambique)",
39412 "Myanmar (Burma) (မြန်မာ)",
39417 "Namibia (Namibië)",
39432 "Netherlands (Nederland)",
39437 "New Caledonia (Nouvelle-Calédonie)",
39472 "North Korea (조선 민주주의 인민 공화국)",
39477 "Northern Mariana Islands",
39493 "Pakistan (پاکستان)",
39503 "Palestine (فلسطين)",
39513 "Papua New Guinea",
39555 "Réunion (La Réunion)",
39561 "Romania (România)",
39577 "Saint Barthélemy",
39588 "Saint Kitts and Nevis",
39598 "Saint Martin (Saint-Martin (partie française))",
39604 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
39609 "Saint Vincent and the Grenadines",
39624 "São Tomé and Príncipe (São Tomé e Príncipe)",
39629 "Saudi Arabia (المملكة العربية السعودية)",
39634 "Senegal (Sénégal)",
39664 "Slovakia (Slovensko)",
39669 "Slovenia (Slovenija)",
39679 "Somalia (Soomaaliya)",
39689 "South Korea (대한민국)",
39694 "South Sudan (جنوب السودان)",
39704 "Sri Lanka (ශ්රී ලංකාව)",
39709 "Sudan (السودان)",
39719 "Svalbard and Jan Mayen",
39730 "Sweden (Sverige)",
39735 "Switzerland (Schweiz)",
39740 "Syria (سوريا)",
39785 "Trinidad and Tobago",
39790 "Tunisia (تونس)",
39795 "Turkey (Türkiye)",
39805 "Turks and Caicos Islands",
39815 "U.S. Virgin Islands",
39825 "Ukraine (Україна)",
39830 "United Arab Emirates (الإمارات العربية المتحدة)",
39852 "Uzbekistan (Oʻzbekiston)",
39862 "Vatican City (Città del Vaticano)",
39873 "Vietnam (Việt Nam)",
39878 "Wallis and Futuna (Wallis-et-Futuna)",
39883 "Western Sahara (الصحراء الغربية)",
39889 "Yemen (اليمن)",
39913 * This script refer to:
39914 * Title: International Telephone Input
39915 * Author: Jack O'Connor
39916 * Code version: v12.1.12
39917 * Availability: https://github.com/jackocnr/intl-tel-input.git
39921 * @class Roo.bootstrap.PhoneInput
39922 * @extends Roo.bootstrap.TriggerField
39923 * An input with International dial-code selection
39925 * @cfg {String} defaultDialCode default '+852'
39926 * @cfg {Array} preferedCountries default []
39929 * Create a new PhoneInput.
39930 * @param {Object} config Configuration options
39933 Roo.bootstrap.PhoneInput = function(config) {
39934 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
39937 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
39939 listWidth: undefined,
39941 selectedClass: 'active',
39943 invalidClass : "has-warning",
39945 validClass: 'has-success',
39947 allowed: '0123456789',
39952 * @cfg {String} defaultDialCode The default dial code when initializing the input
39954 defaultDialCode: '+852',
39957 * @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
39959 preferedCountries: false,
39961 getAutoCreate : function()
39963 var data = Roo.bootstrap.PhoneInputData();
39964 var align = this.labelAlign || this.parentLabelAlign();
39967 this.allCountries = [];
39968 this.dialCodeMapping = [];
39970 for (var i = 0; i < data.length; i++) {
39972 this.allCountries[i] = {
39976 priority: c[3] || 0,
39977 areaCodes: c[4] || null
39979 this.dialCodeMapping[c[2]] = {
39982 priority: c[3] || 0,
39983 areaCodes: c[4] || null
39995 // type: 'number', -- do not use number - we get the flaky up/down arrows.
39996 maxlength: this.max_length,
39997 cls : 'form-control tel-input',
39998 autocomplete: 'new-password'
40001 var hiddenInput = {
40004 cls: 'hidden-tel-input'
40008 hiddenInput.name = this.name;
40011 if (this.disabled) {
40012 input.disabled = true;
40015 var flag_container = {
40032 cls: this.hasFeedback ? 'has-feedback' : '',
40038 cls: 'dial-code-holder',
40045 cls: 'roo-select2-container input-group',
40052 if (this.fieldLabel.length) {
40055 tooltip: 'This field is required'
40061 cls: 'control-label',
40067 html: this.fieldLabel
40070 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40076 if(this.indicatorpos == 'right') {
40077 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
40084 if(align == 'left') {
40092 if(this.labelWidth > 12){
40093 label.style = "width: " + this.labelWidth + 'px';
40095 if(this.labelWidth < 13 && this.labelmd == 0){
40096 this.labelmd = this.labelWidth;
40098 if(this.labellg > 0){
40099 label.cls += ' col-lg-' + this.labellg;
40100 input.cls += ' col-lg-' + (12 - this.labellg);
40102 if(this.labelmd > 0){
40103 label.cls += ' col-md-' + this.labelmd;
40104 container.cls += ' col-md-' + (12 - this.labelmd);
40106 if(this.labelsm > 0){
40107 label.cls += ' col-sm-' + this.labelsm;
40108 container.cls += ' col-sm-' + (12 - this.labelsm);
40110 if(this.labelxs > 0){
40111 label.cls += ' col-xs-' + this.labelxs;
40112 container.cls += ' col-xs-' + (12 - this.labelxs);
40122 var settings = this;
40124 ['xs','sm','md','lg'].map(function(size){
40125 if (settings[size]) {
40126 cfg.cls += ' col-' + size + '-' + settings[size];
40130 this.store = new Roo.data.Store({
40131 proxy : new Roo.data.MemoryProxy({}),
40132 reader : new Roo.data.JsonReader({
40143 'name' : 'dialCode',
40147 'name' : 'priority',
40151 'name' : 'areaCodes',
40158 if(!this.preferedCountries) {
40159 this.preferedCountries = [
40166 var p = this.preferedCountries.reverse();
40169 for (var i = 0; i < p.length; i++) {
40170 for (var j = 0; j < this.allCountries.length; j++) {
40171 if(this.allCountries[j].iso2 == p[i]) {
40172 var t = this.allCountries[j];
40173 this.allCountries.splice(j,1);
40174 this.allCountries.unshift(t);
40180 this.store.proxy.data = {
40182 data: this.allCountries
40188 initEvents : function()
40191 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
40193 this.indicator = this.indicatorEl();
40194 this.flag = this.flagEl();
40195 this.dialCodeHolder = this.dialCodeHolderEl();
40197 this.trigger = this.el.select('div.flag-box',true).first();
40198 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
40203 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40204 _this.list.setWidth(lw);
40207 this.list.on('mouseover', this.onViewOver, this);
40208 this.list.on('mousemove', this.onViewMove, this);
40209 this.inputEl().on("keyup", this.onKeyUp, this);
40210 this.inputEl().on("keypress", this.onKeyPress, this);
40212 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
40214 this.view = new Roo.View(this.list, this.tpl, {
40215 singleSelect:true, store: this.store, selectedClass: this.selectedClass
40218 this.view.on('click', this.onViewClick, this);
40219 this.setValue(this.defaultDialCode);
40222 onTriggerClick : function(e)
40224 Roo.log('trigger click');
40229 if(this.isExpanded()){
40231 this.hasFocus = false;
40233 this.store.load({});
40234 this.hasFocus = true;
40239 isExpanded : function()
40241 return this.list.isVisible();
40244 collapse : function()
40246 if(!this.isExpanded()){
40250 Roo.get(document).un('mousedown', this.collapseIf, this);
40251 Roo.get(document).un('mousewheel', this.collapseIf, this);
40252 this.fireEvent('collapse', this);
40256 expand : function()
40260 if(this.isExpanded() || !this.hasFocus){
40264 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
40265 this.list.setWidth(lw);
40268 this.restrictHeight();
40270 Roo.get(document).on('mousedown', this.collapseIf, this);
40271 Roo.get(document).on('mousewheel', this.collapseIf, this);
40273 this.fireEvent('expand', this);
40276 restrictHeight : function()
40278 this.list.alignTo(this.inputEl(), this.listAlign);
40279 this.list.alignTo(this.inputEl(), this.listAlign);
40282 onViewOver : function(e, t)
40284 if(this.inKeyMode){
40287 var item = this.view.findItemFromChild(t);
40290 var index = this.view.indexOf(item);
40291 this.select(index, false);
40296 onViewClick : function(view, doFocus, el, e)
40298 var index = this.view.getSelectedIndexes()[0];
40300 var r = this.store.getAt(index);
40303 this.onSelect(r, index);
40305 if(doFocus !== false && !this.blockFocus){
40306 this.inputEl().focus();
40310 onViewMove : function(e, t)
40312 this.inKeyMode = false;
40315 select : function(index, scrollIntoView)
40317 this.selectedIndex = index;
40318 this.view.select(index);
40319 if(scrollIntoView !== false){
40320 var el = this.view.getNode(index);
40322 this.list.scrollChildIntoView(el, false);
40327 createList : function()
40329 this.list = Roo.get(document.body).createChild({
40331 cls: 'typeahead typeahead-long dropdown-menu tel-list',
40332 style: 'display:none'
40335 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
40338 collapseIf : function(e)
40340 var in_combo = e.within(this.el);
40341 var in_list = e.within(this.list);
40342 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
40344 if (in_combo || in_list || is_list) {
40350 onSelect : function(record, index)
40352 if(this.fireEvent('beforeselect', this, record, index) !== false){
40354 this.setFlagClass(record.data.iso2);
40355 this.setDialCode(record.data.dialCode);
40356 this.hasFocus = false;
40358 this.fireEvent('select', this, record, index);
40362 flagEl : function()
40364 var flag = this.el.select('div.flag',true).first();
40371 dialCodeHolderEl : function()
40373 var d = this.el.select('input.dial-code-holder',true).first();
40380 setDialCode : function(v)
40382 this.dialCodeHolder.dom.value = '+'+v;
40385 setFlagClass : function(n)
40387 this.flag.dom.className = 'flag '+n;
40390 getValue : function()
40392 var v = this.inputEl().getValue();
40393 if(this.dialCodeHolder) {
40394 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
40399 setValue : function(v)
40401 var d = this.getDialCode(v);
40403 //invalid dial code
40404 if(v.length == 0 || !d || d.length == 0) {
40406 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
40407 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
40413 this.setFlagClass(this.dialCodeMapping[d].iso2);
40414 this.setDialCode(d);
40415 this.inputEl().dom.value = v.replace('+'+d,'');
40416 this.hiddenEl().dom.value = this.getValue();
40421 getDialCode : function(v)
40425 if (v.length == 0) {
40426 return this.dialCodeHolder.dom.value;
40430 if (v.charAt(0) != "+") {
40433 var numericChars = "";
40434 for (var i = 1; i < v.length; i++) {
40435 var c = v.charAt(i);
40438 if (this.dialCodeMapping[numericChars]) {
40439 dialCode = v.substr(1, i);
40441 if (numericChars.length == 4) {
40451 this.setValue(this.defaultDialCode);
40455 hiddenEl : function()
40457 return this.el.select('input.hidden-tel-input',true).first();
40460 // after setting val
40461 onKeyUp : function(e){
40462 this.setValue(this.getValue());
40465 onKeyPress : function(e){
40466 if(this.allowed.indexOf(String.fromCharCode(e.getCharCode())) === -1){
40473 * @class Roo.bootstrap.MoneyField
40474 * @extends Roo.bootstrap.ComboBox
40475 * Bootstrap MoneyField class
40478 * Create a new MoneyField.
40479 * @param {Object} config Configuration options
40482 Roo.bootstrap.MoneyField = function(config) {
40484 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
40488 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
40491 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
40493 allowDecimals : true,
40495 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
40497 decimalSeparator : ".",
40499 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
40501 decimalPrecision : 0,
40503 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
40505 allowNegative : true,
40507 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
40511 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
40513 minValue : Number.NEGATIVE_INFINITY,
40515 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
40517 maxValue : Number.MAX_VALUE,
40519 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
40521 minText : "The minimum value for this field is {0}",
40523 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
40525 maxText : "The maximum value for this field is {0}",
40527 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
40528 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
40530 nanText : "{0} is not a valid number",
40532 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
40536 * @cfg {String} defaults currency of the MoneyField
40537 * value should be in lkey
40539 defaultCurrency : false,
40541 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
40543 thousandsDelimiter : false,
40545 * @cfg {Number} max_length Maximum input field length allowed (defaults to Number.MAX_VALUE)
40556 getAutoCreate : function()
40558 var align = this.labelAlign || this.parentLabelAlign();
40570 cls : 'form-control roo-money-amount-input',
40571 autocomplete: 'new-password'
40574 var hiddenInput = {
40578 cls: 'hidden-number-input'
40581 if(this.max_length) {
40582 input.maxlength = this.max_length;
40586 hiddenInput.name = this.name;
40589 if (this.disabled) {
40590 input.disabled = true;
40593 var clg = 12 - this.inputlg;
40594 var cmd = 12 - this.inputmd;
40595 var csm = 12 - this.inputsm;
40596 var cxs = 12 - this.inputxs;
40600 cls : 'row roo-money-field',
40604 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
40608 cls: 'roo-select2-container input-group',
40612 cls : 'form-control roo-money-currency-input',
40613 autocomplete: 'new-password',
40615 name : this.currencyName
40619 cls : 'input-group-addon',
40633 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
40637 cls: this.hasFeedback ? 'has-feedback' : '',
40648 if (this.fieldLabel.length) {
40651 tooltip: 'This field is required'
40657 cls: 'control-label',
40663 html: this.fieldLabel
40666 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40672 if(this.indicatorpos == 'right') {
40673 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
40680 if(align == 'left') {
40688 if(this.labelWidth > 12){
40689 label.style = "width: " + this.labelWidth + 'px';
40691 if(this.labelWidth < 13 && this.labelmd == 0){
40692 this.labelmd = this.labelWidth;
40694 if(this.labellg > 0){
40695 label.cls += ' col-lg-' + this.labellg;
40696 input.cls += ' col-lg-' + (12 - this.labellg);
40698 if(this.labelmd > 0){
40699 label.cls += ' col-md-' + this.labelmd;
40700 container.cls += ' col-md-' + (12 - this.labelmd);
40702 if(this.labelsm > 0){
40703 label.cls += ' col-sm-' + this.labelsm;
40704 container.cls += ' col-sm-' + (12 - this.labelsm);
40706 if(this.labelxs > 0){
40707 label.cls += ' col-xs-' + this.labelxs;
40708 container.cls += ' col-xs-' + (12 - this.labelxs);
40719 var settings = this;
40721 ['xs','sm','md','lg'].map(function(size){
40722 if (settings[size]) {
40723 cfg.cls += ' col-' + size + '-' + settings[size];
40730 initEvents : function()
40732 this.indicator = this.indicatorEl();
40734 this.initCurrencyEvent();
40736 this.initNumberEvent();
40739 initCurrencyEvent : function()
40742 throw "can not find store for combo";
40745 this.store = Roo.factory(this.store, Roo.data);
40746 this.store.parent = this;
40750 this.triggerEl = this.el.select('.input-group-addon', true).first();
40752 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
40757 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40758 _this.list.setWidth(lw);
40761 this.list.on('mouseover', this.onViewOver, this);
40762 this.list.on('mousemove', this.onViewMove, this);
40763 this.list.on('scroll', this.onViewScroll, this);
40766 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
40769 this.view = new Roo.View(this.list, this.tpl, {
40770 singleSelect:true, store: this.store, selectedClass: this.selectedClass
40773 this.view.on('click', this.onViewClick, this);
40775 this.store.on('beforeload', this.onBeforeLoad, this);
40776 this.store.on('load', this.onLoad, this);
40777 this.store.on('loadexception', this.onLoadException, this);
40779 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
40780 "up" : function(e){
40781 this.inKeyMode = true;
40785 "down" : function(e){
40786 if(!this.isExpanded()){
40787 this.onTriggerClick();
40789 this.inKeyMode = true;
40794 "enter" : function(e){
40797 if(this.fireEvent("specialkey", this, e)){
40798 this.onViewClick(false);
40804 "esc" : function(e){
40808 "tab" : function(e){
40811 if(this.fireEvent("specialkey", this, e)){
40812 this.onViewClick(false);
40820 doRelay : function(foo, bar, hname){
40821 if(hname == 'down' || this.scope.isExpanded()){
40822 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
40830 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
40834 initNumberEvent : function(e)
40836 this.inputEl().on("keydown" , this.fireKey, this);
40837 this.inputEl().on("focus", this.onFocus, this);
40838 this.inputEl().on("blur", this.onBlur, this);
40840 this.inputEl().relayEvent('keyup', this);
40842 if(this.indicator){
40843 this.indicator.addClass('invisible');
40846 this.originalValue = this.getValue();
40848 if(this.validationEvent == 'keyup'){
40849 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
40850 this.inputEl().on('keyup', this.filterValidation, this);
40852 else if(this.validationEvent !== false){
40853 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
40856 if(this.selectOnFocus){
40857 this.on("focus", this.preFocus, this);
40860 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
40861 this.inputEl().on("keypress", this.filterKeys, this);
40863 this.inputEl().relayEvent('keypress', this);
40866 var allowed = "0123456789";
40868 if(this.allowDecimals){
40869 allowed += this.decimalSeparator;
40872 if(this.allowNegative){
40876 if(this.thousandsDelimiter) {
40880 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
40882 var keyPress = function(e){
40884 var k = e.getKey();
40886 var c = e.getCharCode();
40889 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
40890 allowed.indexOf(String.fromCharCode(c)) === -1
40896 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
40900 if(allowed.indexOf(String.fromCharCode(c)) === -1){
40905 this.inputEl().on("keypress", keyPress, this);
40909 onTriggerClick : function(e)
40916 this.loadNext = false;
40918 if(this.isExpanded()){
40923 this.hasFocus = true;
40925 if(this.triggerAction == 'all') {
40926 this.doQuery(this.allQuery, true);
40930 this.doQuery(this.getRawValue());
40933 getCurrency : function()
40935 var v = this.currencyEl().getValue();
40940 restrictHeight : function()
40942 this.list.alignTo(this.currencyEl(), this.listAlign);
40943 this.list.alignTo(this.currencyEl(), this.listAlign);
40946 onViewClick : function(view, doFocus, el, e)
40948 var index = this.view.getSelectedIndexes()[0];
40950 var r = this.store.getAt(index);
40953 this.onSelect(r, index);
40957 onSelect : function(record, index){
40959 if(this.fireEvent('beforeselect', this, record, index) !== false){
40961 this.setFromCurrencyData(index > -1 ? record.data : false);
40965 this.fireEvent('select', this, record, index);
40969 setFromCurrencyData : function(o)
40973 this.lastCurrency = o;
40975 if (this.currencyField) {
40976 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
40978 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
40981 this.lastSelectionText = currency;
40983 //setting default currency
40984 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
40985 this.setCurrency(this.defaultCurrency);
40989 this.setCurrency(currency);
40992 setFromData : function(o)
40996 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
40998 this.setFromCurrencyData(c);
41003 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
41005 Roo.log('no value set for '+ (this.name ? this.name : this.id));
41008 this.setValue(value);
41012 setCurrency : function(v)
41014 this.currencyValue = v;
41017 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
41022 setValue : function(v)
41024 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
41030 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
41032 this.inputEl().dom.value = (v == '') ? '' :
41033 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
41035 if(!this.allowZero && v === '0') {
41036 this.hiddenEl().dom.value = '';
41037 this.inputEl().dom.value = '';
41044 getRawValue : function()
41046 var v = this.inputEl().getValue();
41051 getValue : function()
41053 return this.fixPrecision(this.parseValue(this.getRawValue()));
41056 parseValue : function(value)
41058 if(this.thousandsDelimiter) {
41060 r = new RegExp(",", "g");
41061 value = value.replace(r, "");
41064 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
41065 return isNaN(value) ? '' : value;
41069 fixPrecision : function(value)
41071 if(this.thousandsDelimiter) {
41073 r = new RegExp(",", "g");
41074 value = value.replace(r, "");
41077 var nan = isNaN(value);
41079 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
41080 return nan ? '' : value;
41082 return parseFloat(value).toFixed(this.decimalPrecision);
41085 decimalPrecisionFcn : function(v)
41087 return Math.floor(v);
41090 validateValue : function(value)
41092 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
41096 var num = this.parseValue(value);
41099 this.markInvalid(String.format(this.nanText, value));
41103 if(num < this.minValue){
41104 this.markInvalid(String.format(this.minText, this.minValue));
41108 if(num > this.maxValue){
41109 this.markInvalid(String.format(this.maxText, this.maxValue));
41116 validate : function()
41118 if(this.disabled || this.allowBlank){
41123 var currency = this.getCurrency();
41125 if(this.validateValue(this.getRawValue()) && currency.length){
41130 this.markInvalid();
41134 getName: function()
41139 beforeBlur : function()
41145 var v = this.parseValue(this.getRawValue());
41152 onBlur : function()
41156 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
41157 //this.el.removeClass(this.focusClass);
41160 this.hasFocus = false;
41162 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
41166 var v = this.getValue();
41168 if(String(v) !== String(this.startValue)){
41169 this.fireEvent('change', this, v, this.startValue);
41172 this.fireEvent("blur", this);
41175 inputEl : function()
41177 return this.el.select('.roo-money-amount-input', true).first();
41180 currencyEl : function()
41182 return this.el.select('.roo-money-currency-input', true).first();
41185 hiddenEl : function()
41187 return this.el.select('input.hidden-number-input',true).first();