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 popover-header',
17652 cls : 'popover-content popover-body',
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([
17778 'fade','top','bottom', 'left', 'right','in',
17779 'bs-popover-top','bs-popover-bottom', 'bs-popover-left', 'bs-popover-right'
17781 if (!this.title.length) {
17782 this.el.select('.popover-title',true).hide();
17785 var placement = typeof this.placement == 'function' ?
17786 this.placement.call(this, this.el, on_el) :
17789 var autoToken = /\s?auto?\s?/i;
17790 var autoPlace = autoToken.test(placement);
17792 placement = placement.replace(autoToken, '') || 'top';
17796 //this.el.setXY([0,0]);
17798 this.el.dom.style.display='block';
17799 this.el.addClass(placement);
17801 //this.el.appendTo(on_el);
17803 var p = this.getPosition();
17804 var box = this.el.getBox();
17809 var align = Roo.bootstrap.Popover.alignment[placement];
17812 this.el.alignTo(on_el, align[0],align[1]);
17813 //var arrow = this.el.select('.arrow',true).first();
17814 //arrow.set(align[2],
17816 this.el.addClass('in');
17819 if (this.el.hasClass('fade')) {
17823 this.hoverState = 'in';
17825 this.fireEvent('show', this);
17830 this.el.setXY([0,0]);
17831 this.el.removeClass('in');
17833 this.hoverState = null;
17835 this.fireEvent('hide', this);
17840 Roo.bootstrap.Popover.alignment = {
17841 'left' : ['r-l', [-10,0], 'right bs-popover-right'],
17842 'right' : ['l-r', [10,0], 'left bs-popover-left'],
17843 'bottom' : ['t-b', [0,10], 'top bs-popover-top'],
17844 'top' : [ 'b-t', [0,-10], 'bottom bs-popover-bottom']
17855 * @class Roo.bootstrap.Progress
17856 * @extends Roo.bootstrap.Component
17857 * Bootstrap Progress class
17858 * @cfg {Boolean} striped striped of the progress bar
17859 * @cfg {Boolean} active animated of the progress bar
17863 * Create a new Progress
17864 * @param {Object} config The config object
17867 Roo.bootstrap.Progress = function(config){
17868 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
17871 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
17876 getAutoCreate : function(){
17884 cfg.cls += ' progress-striped';
17888 cfg.cls += ' active';
17907 * @class Roo.bootstrap.ProgressBar
17908 * @extends Roo.bootstrap.Component
17909 * Bootstrap ProgressBar class
17910 * @cfg {Number} aria_valuenow aria-value now
17911 * @cfg {Number} aria_valuemin aria-value min
17912 * @cfg {Number} aria_valuemax aria-value max
17913 * @cfg {String} label label for the progress bar
17914 * @cfg {String} panel (success | info | warning | danger )
17915 * @cfg {String} role role of the progress bar
17916 * @cfg {String} sr_only text
17920 * Create a new ProgressBar
17921 * @param {Object} config The config object
17924 Roo.bootstrap.ProgressBar = function(config){
17925 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
17928 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
17932 aria_valuemax : 100,
17938 getAutoCreate : function()
17943 cls: 'progress-bar',
17944 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
17956 cfg.role = this.role;
17959 if(this.aria_valuenow){
17960 cfg['aria-valuenow'] = this.aria_valuenow;
17963 if(this.aria_valuemin){
17964 cfg['aria-valuemin'] = this.aria_valuemin;
17967 if(this.aria_valuemax){
17968 cfg['aria-valuemax'] = this.aria_valuemax;
17971 if(this.label && !this.sr_only){
17972 cfg.html = this.label;
17976 cfg.cls += ' progress-bar-' + this.panel;
17982 update : function(aria_valuenow)
17984 this.aria_valuenow = aria_valuenow;
17986 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
18001 * @class Roo.bootstrap.TabGroup
18002 * @extends Roo.bootstrap.Column
18003 * Bootstrap Column class
18004 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
18005 * @cfg {Boolean} carousel true to make the group behave like a carousel
18006 * @cfg {Boolean} bullets show bullets for the panels
18007 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
18008 * @cfg {Number} timer auto slide timer .. default 0 millisecond
18009 * @cfg {Boolean} showarrow (true|false) show arrow default true
18012 * Create a new TabGroup
18013 * @param {Object} config The config object
18016 Roo.bootstrap.TabGroup = function(config){
18017 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
18019 this.navId = Roo.id();
18022 Roo.bootstrap.TabGroup.register(this);
18026 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
18029 transition : false,
18034 slideOnTouch : false,
18037 getAutoCreate : function()
18039 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
18041 cfg.cls += ' tab-content';
18043 if (this.carousel) {
18044 cfg.cls += ' carousel slide';
18047 cls : 'carousel-inner',
18051 if(this.bullets && !Roo.isTouch){
18054 cls : 'carousel-bullets',
18058 if(this.bullets_cls){
18059 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
18066 cfg.cn[0].cn.push(bullets);
18069 if(this.showarrow){
18070 cfg.cn[0].cn.push({
18072 class : 'carousel-arrow',
18076 class : 'carousel-prev',
18080 class : 'fa fa-chevron-left'
18086 class : 'carousel-next',
18090 class : 'fa fa-chevron-right'
18103 initEvents: function()
18105 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
18106 // this.el.on("touchstart", this.onTouchStart, this);
18109 if(this.autoslide){
18112 this.slideFn = window.setInterval(function() {
18113 _this.showPanelNext();
18117 if(this.showarrow){
18118 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
18119 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
18125 // onTouchStart : function(e, el, o)
18127 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
18131 // this.showPanelNext();
18135 getChildContainer : function()
18137 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
18141 * register a Navigation item
18142 * @param {Roo.bootstrap.NavItem} the navitem to add
18144 register : function(item)
18146 this.tabs.push( item);
18147 item.navId = this.navId; // not really needed..
18152 getActivePanel : function()
18155 Roo.each(this.tabs, function(t) {
18165 getPanelByName : function(n)
18168 Roo.each(this.tabs, function(t) {
18169 if (t.tabId == n) {
18177 indexOfPanel : function(p)
18180 Roo.each(this.tabs, function(t,i) {
18181 if (t.tabId == p.tabId) {
18190 * show a specific panel
18191 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
18192 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
18194 showPanel : function (pan)
18196 if(this.transition || typeof(pan) == 'undefined'){
18197 Roo.log("waiting for the transitionend");
18201 if (typeof(pan) == 'number') {
18202 pan = this.tabs[pan];
18205 if (typeof(pan) == 'string') {
18206 pan = this.getPanelByName(pan);
18209 var cur = this.getActivePanel();
18212 Roo.log('pan or acitve pan is undefined');
18216 if (pan.tabId == this.getActivePanel().tabId) {
18220 if (false === cur.fireEvent('beforedeactivate')) {
18224 if(this.bullets > 0 && !Roo.isTouch){
18225 this.setActiveBullet(this.indexOfPanel(pan));
18228 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
18230 this.transition = true;
18231 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
18232 var lr = dir == 'next' ? 'left' : 'right';
18233 pan.el.addClass(dir); // or prev
18234 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
18235 cur.el.addClass(lr); // or right
18236 pan.el.addClass(lr);
18239 cur.el.on('transitionend', function() {
18240 Roo.log("trans end?");
18242 pan.el.removeClass([lr,dir]);
18243 pan.setActive(true);
18245 cur.el.removeClass([lr]);
18246 cur.setActive(false);
18248 _this.transition = false;
18250 }, this, { single: true } );
18255 cur.setActive(false);
18256 pan.setActive(true);
18261 showPanelNext : function()
18263 var i = this.indexOfPanel(this.getActivePanel());
18265 if (i >= this.tabs.length - 1 && !this.autoslide) {
18269 if (i >= this.tabs.length - 1 && this.autoslide) {
18273 this.showPanel(this.tabs[i+1]);
18276 showPanelPrev : function()
18278 var i = this.indexOfPanel(this.getActivePanel());
18280 if (i < 1 && !this.autoslide) {
18284 if (i < 1 && this.autoslide) {
18285 i = this.tabs.length;
18288 this.showPanel(this.tabs[i-1]);
18292 addBullet: function()
18294 if(!this.bullets || Roo.isTouch){
18297 var ctr = this.el.select('.carousel-bullets',true).first();
18298 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
18299 var bullet = ctr.createChild({
18300 cls : 'bullet bullet-' + i
18301 },ctr.dom.lastChild);
18306 bullet.on('click', (function(e, el, o, ii, t){
18308 e.preventDefault();
18310 this.showPanel(ii);
18312 if(this.autoslide && this.slideFn){
18313 clearInterval(this.slideFn);
18314 this.slideFn = window.setInterval(function() {
18315 _this.showPanelNext();
18319 }).createDelegate(this, [i, bullet], true));
18324 setActiveBullet : function(i)
18330 Roo.each(this.el.select('.bullet', true).elements, function(el){
18331 el.removeClass('selected');
18334 var bullet = this.el.select('.bullet-' + i, true).first();
18340 bullet.addClass('selected');
18351 Roo.apply(Roo.bootstrap.TabGroup, {
18355 * register a Navigation Group
18356 * @param {Roo.bootstrap.NavGroup} the navgroup to add
18358 register : function(navgrp)
18360 this.groups[navgrp.navId] = navgrp;
18364 * fetch a Navigation Group based on the navigation ID
18365 * if one does not exist , it will get created.
18366 * @param {string} the navgroup to add
18367 * @returns {Roo.bootstrap.NavGroup} the navgroup
18369 get: function(navId) {
18370 if (typeof(this.groups[navId]) == 'undefined') {
18371 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
18373 return this.groups[navId] ;
18388 * @class Roo.bootstrap.TabPanel
18389 * @extends Roo.bootstrap.Component
18390 * Bootstrap TabPanel class
18391 * @cfg {Boolean} active panel active
18392 * @cfg {String} html panel content
18393 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
18394 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
18395 * @cfg {String} href click to link..
18399 * Create a new TabPanel
18400 * @param {Object} config The config object
18403 Roo.bootstrap.TabPanel = function(config){
18404 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
18408 * Fires when the active status changes
18409 * @param {Roo.bootstrap.TabPanel} this
18410 * @param {Boolean} state the new state
18415 * @event beforedeactivate
18416 * Fires before a tab is de-activated - can be used to do validation on a form.
18417 * @param {Roo.bootstrap.TabPanel} this
18418 * @return {Boolean} false if there is an error
18421 'beforedeactivate': true
18424 this.tabId = this.tabId || Roo.id();
18428 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
18436 getAutoCreate : function(){
18439 // item is needed for carousel - not sure if it has any effect otherwise
18440 cls: 'tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
18441 html: this.html || ''
18445 cfg.cls += ' active';
18449 cfg.tabId = this.tabId;
18456 initEvents: function()
18458 var p = this.parent();
18460 this.navId = this.navId || p.navId;
18462 if (typeof(this.navId) != 'undefined') {
18463 // not really needed.. but just in case.. parent should be a NavGroup.
18464 var tg = Roo.bootstrap.TabGroup.get(this.navId);
18468 var i = tg.tabs.length - 1;
18470 if(this.active && tg.bullets > 0 && i < tg.bullets){
18471 tg.setActiveBullet(i);
18475 this.el.on('click', this.onClick, this);
18478 this.el.on("touchstart", this.onTouchStart, this);
18479 this.el.on("touchmove", this.onTouchMove, this);
18480 this.el.on("touchend", this.onTouchEnd, this);
18485 onRender : function(ct, position)
18487 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
18490 setActive : function(state)
18492 Roo.log("panel - set active " + this.tabId + "=" + state);
18494 this.active = state;
18496 this.el.removeClass('active');
18498 } else if (!this.el.hasClass('active')) {
18499 this.el.addClass('active');
18502 this.fireEvent('changed', this, state);
18505 onClick : function(e)
18507 e.preventDefault();
18509 if(!this.href.length){
18513 window.location.href = this.href;
18522 onTouchStart : function(e)
18524 this.swiping = false;
18526 this.startX = e.browserEvent.touches[0].clientX;
18527 this.startY = e.browserEvent.touches[0].clientY;
18530 onTouchMove : function(e)
18532 this.swiping = true;
18534 this.endX = e.browserEvent.touches[0].clientX;
18535 this.endY = e.browserEvent.touches[0].clientY;
18538 onTouchEnd : function(e)
18545 var tabGroup = this.parent();
18547 if(this.endX > this.startX){ // swiping right
18548 tabGroup.showPanelPrev();
18552 if(this.startX > this.endX){ // swiping left
18553 tabGroup.showPanelNext();
18572 * @class Roo.bootstrap.DateField
18573 * @extends Roo.bootstrap.Input
18574 * Bootstrap DateField class
18575 * @cfg {Number} weekStart default 0
18576 * @cfg {String} viewMode default empty, (months|years)
18577 * @cfg {String} minViewMode default empty, (months|years)
18578 * @cfg {Number} startDate default -Infinity
18579 * @cfg {Number} endDate default Infinity
18580 * @cfg {Boolean} todayHighlight default false
18581 * @cfg {Boolean} todayBtn default false
18582 * @cfg {Boolean} calendarWeeks default false
18583 * @cfg {Object} daysOfWeekDisabled default empty
18584 * @cfg {Boolean} singleMode default false (true | false)
18586 * @cfg {Boolean} keyboardNavigation default true
18587 * @cfg {String} language default en
18590 * Create a new DateField
18591 * @param {Object} config The config object
18594 Roo.bootstrap.DateField = function(config){
18595 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
18599 * Fires when this field show.
18600 * @param {Roo.bootstrap.DateField} this
18601 * @param {Mixed} date The date value
18606 * Fires when this field hide.
18607 * @param {Roo.bootstrap.DateField} this
18608 * @param {Mixed} date The date value
18613 * Fires when select a date.
18614 * @param {Roo.bootstrap.DateField} this
18615 * @param {Mixed} date The date value
18619 * @event beforeselect
18620 * Fires when before select a date.
18621 * @param {Roo.bootstrap.DateField} this
18622 * @param {Mixed} date The date value
18624 beforeselect : true
18628 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
18631 * @cfg {String} format
18632 * The default date format string which can be overriden for localization support. The format must be
18633 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
18637 * @cfg {String} altFormats
18638 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
18639 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
18641 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
18649 todayHighlight : false,
18655 keyboardNavigation: true,
18657 calendarWeeks: false,
18659 startDate: -Infinity,
18663 daysOfWeekDisabled: [],
18667 singleMode : false,
18669 UTCDate: function()
18671 return new Date(Date.UTC.apply(Date, arguments));
18674 UTCToday: function()
18676 var today = new Date();
18677 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
18680 getDate: function() {
18681 var d = this.getUTCDate();
18682 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
18685 getUTCDate: function() {
18689 setDate: function(d) {
18690 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
18693 setUTCDate: function(d) {
18695 this.setValue(this.formatDate(this.date));
18698 onRender: function(ct, position)
18701 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
18703 this.language = this.language || 'en';
18704 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
18705 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
18707 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
18708 this.format = this.format || 'm/d/y';
18709 this.isInline = false;
18710 this.isInput = true;
18711 this.component = this.el.select('.add-on', true).first() || false;
18712 this.component = (this.component && this.component.length === 0) ? false : this.component;
18713 this.hasInput = this.component && this.inputEl().length;
18715 if (typeof(this.minViewMode === 'string')) {
18716 switch (this.minViewMode) {
18718 this.minViewMode = 1;
18721 this.minViewMode = 2;
18724 this.minViewMode = 0;
18729 if (typeof(this.viewMode === 'string')) {
18730 switch (this.viewMode) {
18743 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
18745 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
18747 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18749 this.picker().on('mousedown', this.onMousedown, this);
18750 this.picker().on('click', this.onClick, this);
18752 this.picker().addClass('datepicker-dropdown');
18754 this.startViewMode = this.viewMode;
18756 if(this.singleMode){
18757 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
18758 v.setVisibilityMode(Roo.Element.DISPLAY);
18762 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
18763 v.setStyle('width', '189px');
18767 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
18768 if(!this.calendarWeeks){
18773 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18774 v.attr('colspan', function(i, val){
18775 return parseInt(val) + 1;
18780 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
18782 this.setStartDate(this.startDate);
18783 this.setEndDate(this.endDate);
18785 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
18792 if(this.isInline) {
18797 picker : function()
18799 return this.pickerEl;
18800 // return this.el.select('.datepicker', true).first();
18803 fillDow: function()
18805 var dowCnt = this.weekStart;
18814 if(this.calendarWeeks){
18822 while (dowCnt < this.weekStart + 7) {
18826 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
18830 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
18833 fillMonths: function()
18836 var months = this.picker().select('>.datepicker-months td', true).first();
18838 months.dom.innerHTML = '';
18844 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
18847 months.createChild(month);
18854 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;
18856 if (this.date < this.startDate) {
18857 this.viewDate = new Date(this.startDate);
18858 } else if (this.date > this.endDate) {
18859 this.viewDate = new Date(this.endDate);
18861 this.viewDate = new Date(this.date);
18869 var d = new Date(this.viewDate),
18870 year = d.getUTCFullYear(),
18871 month = d.getUTCMonth(),
18872 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
18873 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
18874 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
18875 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
18876 currentDate = this.date && this.date.valueOf(),
18877 today = this.UTCToday();
18879 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
18881 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18883 // this.picker.select('>tfoot th.today').
18884 // .text(dates[this.language].today)
18885 // .toggle(this.todayBtn !== false);
18887 this.updateNavArrows();
18890 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
18892 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
18894 prevMonth.setUTCDate(day);
18896 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
18898 var nextMonth = new Date(prevMonth);
18900 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
18902 nextMonth = nextMonth.valueOf();
18904 var fillMonths = false;
18906 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
18908 while(prevMonth.valueOf() <= nextMonth) {
18911 if (prevMonth.getUTCDay() === this.weekStart) {
18913 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
18921 if(this.calendarWeeks){
18922 // ISO 8601: First week contains first thursday.
18923 // ISO also states week starts on Monday, but we can be more abstract here.
18925 // Start of current week: based on weekstart/current date
18926 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
18927 // Thursday of this week
18928 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
18929 // First Thursday of year, year from thursday
18930 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
18931 // Calendar week: ms between thursdays, div ms per day, div 7 days
18932 calWeek = (th - yth) / 864e5 / 7 + 1;
18934 fillMonths.cn.push({
18942 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
18944 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
18947 if (this.todayHighlight &&
18948 prevMonth.getUTCFullYear() == today.getFullYear() &&
18949 prevMonth.getUTCMonth() == today.getMonth() &&
18950 prevMonth.getUTCDate() == today.getDate()) {
18951 clsName += ' today';
18954 if (currentDate && prevMonth.valueOf() === currentDate) {
18955 clsName += ' active';
18958 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
18959 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
18960 clsName += ' disabled';
18963 fillMonths.cn.push({
18965 cls: 'day ' + clsName,
18966 html: prevMonth.getDate()
18969 prevMonth.setDate(prevMonth.getDate()+1);
18972 var currentYear = this.date && this.date.getUTCFullYear();
18973 var currentMonth = this.date && this.date.getUTCMonth();
18975 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
18977 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
18978 v.removeClass('active');
18980 if(currentYear === year && k === currentMonth){
18981 v.addClass('active');
18984 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
18985 v.addClass('disabled');
18991 year = parseInt(year/10, 10) * 10;
18993 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
18995 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
18998 for (var i = -1; i < 11; i++) {
18999 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
19001 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
19009 showMode: function(dir)
19012 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
19015 Roo.each(this.picker().select('>div',true).elements, function(v){
19016 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19019 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
19024 if(this.isInline) {
19028 this.picker().removeClass(['bottom', 'top']);
19030 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
19032 * place to the top of element!
19036 this.picker().addClass('top');
19037 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
19042 this.picker().addClass('bottom');
19044 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
19047 parseDate : function(value)
19049 if(!value || value instanceof Date){
19052 var v = Date.parseDate(value, this.format);
19053 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
19054 v = Date.parseDate(value, 'Y-m-d');
19056 if(!v && this.altFormats){
19057 if(!this.altFormatsArray){
19058 this.altFormatsArray = this.altFormats.split("|");
19060 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
19061 v = Date.parseDate(value, this.altFormatsArray[i]);
19067 formatDate : function(date, fmt)
19069 return (!date || !(date instanceof Date)) ?
19070 date : date.dateFormat(fmt || this.format);
19073 onFocus : function()
19075 Roo.bootstrap.DateField.superclass.onFocus.call(this);
19079 onBlur : function()
19081 Roo.bootstrap.DateField.superclass.onBlur.call(this);
19083 var d = this.inputEl().getValue();
19090 showPopup : function()
19092 this.picker().show();
19096 this.fireEvent('showpopup', this, this.date);
19099 hidePopup : function()
19101 if(this.isInline) {
19104 this.picker().hide();
19105 this.viewMode = this.startViewMode;
19108 this.fireEvent('hidepopup', this, this.date);
19112 onMousedown: function(e)
19114 e.stopPropagation();
19115 e.preventDefault();
19120 Roo.bootstrap.DateField.superclass.keyup.call(this);
19124 setValue: function(v)
19126 if(this.fireEvent('beforeselect', this, v) !== false){
19127 var d = new Date(this.parseDate(v) ).clearTime();
19129 if(isNaN(d.getTime())){
19130 this.date = this.viewDate = '';
19131 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19135 v = this.formatDate(d);
19137 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
19139 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
19143 this.fireEvent('select', this, this.date);
19147 getValue: function()
19149 return this.formatDate(this.date);
19152 fireKey: function(e)
19154 if (!this.picker().isVisible()){
19155 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19161 var dateChanged = false,
19163 newDate, newViewDate;
19168 e.preventDefault();
19172 if (!this.keyboardNavigation) {
19175 dir = e.keyCode == 37 ? -1 : 1;
19178 newDate = this.moveYear(this.date, dir);
19179 newViewDate = this.moveYear(this.viewDate, dir);
19180 } else if (e.shiftKey){
19181 newDate = this.moveMonth(this.date, dir);
19182 newViewDate = this.moveMonth(this.viewDate, dir);
19184 newDate = new Date(this.date);
19185 newDate.setUTCDate(this.date.getUTCDate() + dir);
19186 newViewDate = new Date(this.viewDate);
19187 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
19189 if (this.dateWithinRange(newDate)){
19190 this.date = newDate;
19191 this.viewDate = newViewDate;
19192 this.setValue(this.formatDate(this.date));
19194 e.preventDefault();
19195 dateChanged = true;
19200 if (!this.keyboardNavigation) {
19203 dir = e.keyCode == 38 ? -1 : 1;
19205 newDate = this.moveYear(this.date, dir);
19206 newViewDate = this.moveYear(this.viewDate, dir);
19207 } else if (e.shiftKey){
19208 newDate = this.moveMonth(this.date, dir);
19209 newViewDate = this.moveMonth(this.viewDate, dir);
19211 newDate = new Date(this.date);
19212 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
19213 newViewDate = new Date(this.viewDate);
19214 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
19216 if (this.dateWithinRange(newDate)){
19217 this.date = newDate;
19218 this.viewDate = newViewDate;
19219 this.setValue(this.formatDate(this.date));
19221 e.preventDefault();
19222 dateChanged = true;
19226 this.setValue(this.formatDate(this.date));
19228 e.preventDefault();
19231 this.setValue(this.formatDate(this.date));
19245 onClick: function(e)
19247 e.stopPropagation();
19248 e.preventDefault();
19250 var target = e.getTarget();
19252 if(target.nodeName.toLowerCase() === 'i'){
19253 target = Roo.get(target).dom.parentNode;
19256 var nodeName = target.nodeName;
19257 var className = target.className;
19258 var html = target.innerHTML;
19259 //Roo.log(nodeName);
19261 switch(nodeName.toLowerCase()) {
19263 switch(className) {
19269 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
19270 switch(this.viewMode){
19272 this.viewDate = this.moveMonth(this.viewDate, dir);
19276 this.viewDate = this.moveYear(this.viewDate, dir);
19282 var date = new Date();
19283 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
19285 this.setValue(this.formatDate(this.date));
19292 if (className.indexOf('disabled') < 0) {
19293 this.viewDate.setUTCDate(1);
19294 if (className.indexOf('month') > -1) {
19295 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
19297 var year = parseInt(html, 10) || 0;
19298 this.viewDate.setUTCFullYear(year);
19302 if(this.singleMode){
19303 this.setValue(this.formatDate(this.viewDate));
19314 //Roo.log(className);
19315 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
19316 var day = parseInt(html, 10) || 1;
19317 var year = this.viewDate.getUTCFullYear(),
19318 month = this.viewDate.getUTCMonth();
19320 if (className.indexOf('old') > -1) {
19327 } else if (className.indexOf('new') > -1) {
19335 //Roo.log([year,month,day]);
19336 this.date = this.UTCDate(year, month, day,0,0,0,0);
19337 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
19339 //Roo.log(this.formatDate(this.date));
19340 this.setValue(this.formatDate(this.date));
19347 setStartDate: function(startDate)
19349 this.startDate = startDate || -Infinity;
19350 if (this.startDate !== -Infinity) {
19351 this.startDate = this.parseDate(this.startDate);
19354 this.updateNavArrows();
19357 setEndDate: function(endDate)
19359 this.endDate = endDate || Infinity;
19360 if (this.endDate !== Infinity) {
19361 this.endDate = this.parseDate(this.endDate);
19364 this.updateNavArrows();
19367 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
19369 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
19370 if (typeof(this.daysOfWeekDisabled) !== 'object') {
19371 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
19373 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
19374 return parseInt(d, 10);
19377 this.updateNavArrows();
19380 updateNavArrows: function()
19382 if(this.singleMode){
19386 var d = new Date(this.viewDate),
19387 year = d.getUTCFullYear(),
19388 month = d.getUTCMonth();
19390 Roo.each(this.picker().select('.prev', true).elements, function(v){
19392 switch (this.viewMode) {
19395 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
19401 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
19408 Roo.each(this.picker().select('.next', true).elements, function(v){
19410 switch (this.viewMode) {
19413 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
19419 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
19427 moveMonth: function(date, dir)
19432 var new_date = new Date(date.valueOf()),
19433 day = new_date.getUTCDate(),
19434 month = new_date.getUTCMonth(),
19435 mag = Math.abs(dir),
19437 dir = dir > 0 ? 1 : -1;
19440 // If going back one month, make sure month is not current month
19441 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
19443 return new_date.getUTCMonth() == month;
19445 // If going forward one month, make sure month is as expected
19446 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
19448 return new_date.getUTCMonth() != new_month;
19450 new_month = month + dir;
19451 new_date.setUTCMonth(new_month);
19452 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
19453 if (new_month < 0 || new_month > 11) {
19454 new_month = (new_month + 12) % 12;
19457 // For magnitudes >1, move one month at a time...
19458 for (var i=0; i<mag; i++) {
19459 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
19460 new_date = this.moveMonth(new_date, dir);
19462 // ...then reset the day, keeping it in the new month
19463 new_month = new_date.getUTCMonth();
19464 new_date.setUTCDate(day);
19466 return new_month != new_date.getUTCMonth();
19469 // Common date-resetting loop -- if date is beyond end of month, make it
19472 new_date.setUTCDate(--day);
19473 new_date.setUTCMonth(new_month);
19478 moveYear: function(date, dir)
19480 return this.moveMonth(date, dir*12);
19483 dateWithinRange: function(date)
19485 return date >= this.startDate && date <= this.endDate;
19491 this.picker().remove();
19494 validateValue : function(value)
19496 if(this.getVisibilityEl().hasClass('hidden')){
19500 if(value.length < 1) {
19501 if(this.allowBlank){
19507 if(value.length < this.minLength){
19510 if(value.length > this.maxLength){
19514 var vt = Roo.form.VTypes;
19515 if(!vt[this.vtype](value, this)){
19519 if(typeof this.validator == "function"){
19520 var msg = this.validator(value);
19526 if(this.regex && !this.regex.test(value)){
19530 if(typeof(this.parseDate(value)) == 'undefined'){
19534 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
19538 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
19548 this.date = this.viewDate = '';
19550 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
19555 Roo.apply(Roo.bootstrap.DateField, {
19566 html: '<i class="fa fa-arrow-left"/>'
19576 html: '<i class="fa fa-arrow-right"/>'
19618 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
19619 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
19620 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
19621 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
19622 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
19635 navFnc: 'FullYear',
19640 navFnc: 'FullYear',
19645 Roo.apply(Roo.bootstrap.DateField, {
19649 cls: 'datepicker dropdown-menu roo-dynamic',
19653 cls: 'datepicker-days',
19657 cls: 'table-condensed',
19659 Roo.bootstrap.DateField.head,
19663 Roo.bootstrap.DateField.footer
19670 cls: 'datepicker-months',
19674 cls: 'table-condensed',
19676 Roo.bootstrap.DateField.head,
19677 Roo.bootstrap.DateField.content,
19678 Roo.bootstrap.DateField.footer
19685 cls: 'datepicker-years',
19689 cls: 'table-condensed',
19691 Roo.bootstrap.DateField.head,
19692 Roo.bootstrap.DateField.content,
19693 Roo.bootstrap.DateField.footer
19712 * @class Roo.bootstrap.TimeField
19713 * @extends Roo.bootstrap.Input
19714 * Bootstrap DateField class
19718 * Create a new TimeField
19719 * @param {Object} config The config object
19722 Roo.bootstrap.TimeField = function(config){
19723 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
19727 * Fires when this field show.
19728 * @param {Roo.bootstrap.DateField} thisthis
19729 * @param {Mixed} date The date value
19734 * Fires when this field hide.
19735 * @param {Roo.bootstrap.DateField} this
19736 * @param {Mixed} date The date value
19741 * Fires when select a date.
19742 * @param {Roo.bootstrap.DateField} this
19743 * @param {Mixed} date The date value
19749 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
19752 * @cfg {String} format
19753 * The default time format string which can be overriden for localization support. The format must be
19754 * valid according to {@link Date#parseDate} (defaults to 'H:i').
19758 onRender: function(ct, position)
19761 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
19763 this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.TimeField.template);
19765 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19767 this.pop = this.picker().select('>.datepicker-time',true).first();
19768 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19770 this.picker().on('mousedown', this.onMousedown, this);
19771 this.picker().on('click', this.onClick, this);
19773 this.picker().addClass('datepicker-dropdown');
19778 this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
19779 this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
19780 this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
19781 this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
19782 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
19783 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
19787 fireKey: function(e){
19788 if (!this.picker().isVisible()){
19789 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19795 e.preventDefault();
19803 this.onTogglePeriod();
19806 this.onIncrementMinutes();
19809 this.onDecrementMinutes();
19818 onClick: function(e) {
19819 e.stopPropagation();
19820 e.preventDefault();
19823 picker : function()
19825 return this.el.select('.datepicker', true).first();
19828 fillTime: function()
19830 var time = this.pop.select('tbody', true).first();
19832 time.dom.innerHTML = '';
19847 cls: 'hours-up glyphicon glyphicon-chevron-up'
19867 cls: 'minutes-up glyphicon glyphicon-chevron-up'
19888 cls: 'timepicker-hour',
19903 cls: 'timepicker-minute',
19918 cls: 'btn btn-primary period',
19940 cls: 'hours-down glyphicon glyphicon-chevron-down'
19960 cls: 'minutes-down glyphicon glyphicon-chevron-down'
19978 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
19985 var hours = this.time.getHours();
19986 var minutes = this.time.getMinutes();
19999 hours = hours - 12;
20003 hours = '0' + hours;
20007 minutes = '0' + minutes;
20010 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
20011 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
20012 this.pop.select('button', true).first().dom.innerHTML = period;
20018 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
20020 var cls = ['bottom'];
20022 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
20029 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
20034 this.picker().addClass(cls.join('-'));
20038 Roo.each(cls, function(c){
20040 _this.picker().setTop(_this.inputEl().getHeight());
20044 _this.picker().setTop(0 - _this.picker().getHeight());
20049 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
20053 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
20060 onFocus : function()
20062 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
20066 onBlur : function()
20068 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
20074 this.picker().show();
20079 this.fireEvent('show', this, this.date);
20084 this.picker().hide();
20087 this.fireEvent('hide', this, this.date);
20090 setTime : function()
20093 this.setValue(this.time.format(this.format));
20095 this.fireEvent('select', this, this.date);
20100 onMousedown: function(e){
20101 e.stopPropagation();
20102 e.preventDefault();
20105 onIncrementHours: function()
20107 Roo.log('onIncrementHours');
20108 this.time = this.time.add(Date.HOUR, 1);
20113 onDecrementHours: function()
20115 Roo.log('onDecrementHours');
20116 this.time = this.time.add(Date.HOUR, -1);
20120 onIncrementMinutes: function()
20122 Roo.log('onIncrementMinutes');
20123 this.time = this.time.add(Date.MINUTE, 1);
20127 onDecrementMinutes: function()
20129 Roo.log('onDecrementMinutes');
20130 this.time = this.time.add(Date.MINUTE, -1);
20134 onTogglePeriod: function()
20136 Roo.log('onTogglePeriod');
20137 this.time = this.time.add(Date.HOUR, 12);
20144 Roo.apply(Roo.bootstrap.TimeField, {
20174 cls: 'btn btn-info ok',
20186 Roo.apply(Roo.bootstrap.TimeField, {
20190 cls: 'datepicker dropdown-menu',
20194 cls: 'datepicker-time',
20198 cls: 'table-condensed',
20200 Roo.bootstrap.TimeField.content,
20201 Roo.bootstrap.TimeField.footer
20220 * @class Roo.bootstrap.MonthField
20221 * @extends Roo.bootstrap.Input
20222 * Bootstrap MonthField class
20224 * @cfg {String} language default en
20227 * Create a new MonthField
20228 * @param {Object} config The config object
20231 Roo.bootstrap.MonthField = function(config){
20232 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
20237 * Fires when this field show.
20238 * @param {Roo.bootstrap.MonthField} this
20239 * @param {Mixed} date The date value
20244 * Fires when this field hide.
20245 * @param {Roo.bootstrap.MonthField} this
20246 * @param {Mixed} date The date value
20251 * Fires when select a date.
20252 * @param {Roo.bootstrap.MonthField} this
20253 * @param {String} oldvalue The old value
20254 * @param {String} newvalue The new value
20260 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
20262 onRender: function(ct, position)
20265 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
20267 this.language = this.language || 'en';
20268 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
20269 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
20271 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
20272 this.isInline = false;
20273 this.isInput = true;
20274 this.component = this.el.select('.add-on', true).first() || false;
20275 this.component = (this.component && this.component.length === 0) ? false : this.component;
20276 this.hasInput = this.component && this.inputEL().length;
20278 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
20280 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
20282 this.picker().on('mousedown', this.onMousedown, this);
20283 this.picker().on('click', this.onClick, this);
20285 this.picker().addClass('datepicker-dropdown');
20287 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
20288 v.setStyle('width', '189px');
20295 if(this.isInline) {
20301 setValue: function(v, suppressEvent)
20303 var o = this.getValue();
20305 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
20309 if(suppressEvent !== true){
20310 this.fireEvent('select', this, o, v);
20315 getValue: function()
20320 onClick: function(e)
20322 e.stopPropagation();
20323 e.preventDefault();
20325 var target = e.getTarget();
20327 if(target.nodeName.toLowerCase() === 'i'){
20328 target = Roo.get(target).dom.parentNode;
20331 var nodeName = target.nodeName;
20332 var className = target.className;
20333 var html = target.innerHTML;
20335 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
20339 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
20341 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20347 picker : function()
20349 return this.pickerEl;
20352 fillMonths: function()
20355 var months = this.picker().select('>.datepicker-months td', true).first();
20357 months.dom.innerHTML = '';
20363 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
20366 months.createChild(month);
20375 if(typeof(this.vIndex) == 'undefined' && this.value.length){
20376 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
20379 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
20380 e.removeClass('active');
20382 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
20383 e.addClass('active');
20390 if(this.isInline) {
20394 this.picker().removeClass(['bottom', 'top']);
20396 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
20398 * place to the top of element!
20402 this.picker().addClass('top');
20403 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
20408 this.picker().addClass('bottom');
20410 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
20413 onFocus : function()
20415 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
20419 onBlur : function()
20421 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
20423 var d = this.inputEl().getValue();
20432 this.picker().show();
20433 this.picker().select('>.datepicker-months', true).first().show();
20437 this.fireEvent('show', this, this.date);
20442 if(this.isInline) {
20445 this.picker().hide();
20446 this.fireEvent('hide', this, this.date);
20450 onMousedown: function(e)
20452 e.stopPropagation();
20453 e.preventDefault();
20458 Roo.bootstrap.MonthField.superclass.keyup.call(this);
20462 fireKey: function(e)
20464 if (!this.picker().isVisible()){
20465 if (e.keyCode == 27) {// allow escape to hide and re-show picker
20476 e.preventDefault();
20480 dir = e.keyCode == 37 ? -1 : 1;
20482 this.vIndex = this.vIndex + dir;
20484 if(this.vIndex < 0){
20488 if(this.vIndex > 11){
20492 if(isNaN(this.vIndex)){
20496 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20502 dir = e.keyCode == 38 ? -1 : 1;
20504 this.vIndex = this.vIndex + dir * 4;
20506 if(this.vIndex < 0){
20510 if(this.vIndex > 11){
20514 if(isNaN(this.vIndex)){
20518 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20523 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20524 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20528 e.preventDefault();
20531 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
20532 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
20548 this.picker().remove();
20553 Roo.apply(Roo.bootstrap.MonthField, {
20572 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
20573 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
20578 Roo.apply(Roo.bootstrap.MonthField, {
20582 cls: 'datepicker dropdown-menu roo-dynamic',
20586 cls: 'datepicker-months',
20590 cls: 'table-condensed',
20592 Roo.bootstrap.DateField.content
20612 * @class Roo.bootstrap.CheckBox
20613 * @extends Roo.bootstrap.Input
20614 * Bootstrap CheckBox class
20616 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
20617 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
20618 * @cfg {String} boxLabel The text that appears beside the checkbox
20619 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
20620 * @cfg {Boolean} checked initnal the element
20621 * @cfg {Boolean} inline inline the element (default false)
20622 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
20623 * @cfg {String} tooltip label tooltip
20626 * Create a new CheckBox
20627 * @param {Object} config The config object
20630 Roo.bootstrap.CheckBox = function(config){
20631 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
20636 * Fires when the element is checked or unchecked.
20637 * @param {Roo.bootstrap.CheckBox} this This input
20638 * @param {Boolean} checked The new checked value
20643 * Fires when the element is click.
20644 * @param {Roo.bootstrap.CheckBox} this This input
20651 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
20653 inputType: 'checkbox',
20662 getAutoCreate : function()
20664 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
20670 cfg.cls = 'form-group ' + this.inputType; //input-group
20673 cfg.cls += ' ' + this.inputType + '-inline';
20679 type : this.inputType,
20680 value : this.inputValue,
20681 cls : 'roo-' + this.inputType, //'form-box',
20682 placeholder : this.placeholder || ''
20686 if(this.inputType != 'radio'){
20690 cls : 'roo-hidden-value',
20691 value : this.checked ? this.inputValue : this.valueOff
20696 if (this.weight) { // Validity check?
20697 cfg.cls += " " + this.inputType + "-" + this.weight;
20700 if (this.disabled) {
20701 input.disabled=true;
20705 input.checked = this.checked;
20710 input.name = this.name;
20712 if(this.inputType != 'radio'){
20713 hidden.name = this.name;
20714 input.name = '_hidden_' + this.name;
20719 input.cls += ' input-' + this.size;
20724 ['xs','sm','md','lg'].map(function(size){
20725 if (settings[size]) {
20726 cfg.cls += ' col-' + size + '-' + settings[size];
20730 var inputblock = input;
20732 if (this.before || this.after) {
20735 cls : 'input-group',
20740 inputblock.cn.push({
20742 cls : 'input-group-addon',
20747 inputblock.cn.push(input);
20749 if(this.inputType != 'radio'){
20750 inputblock.cn.push(hidden);
20754 inputblock.cn.push({
20756 cls : 'input-group-addon',
20763 if (align ==='left' && this.fieldLabel.length) {
20764 // Roo.log("left and has label");
20769 cls : 'control-label',
20770 html : this.fieldLabel
20780 if(this.labelWidth > 12){
20781 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
20784 if(this.labelWidth < 13 && this.labelmd == 0){
20785 this.labelmd = this.labelWidth;
20788 if(this.labellg > 0){
20789 cfg.cn[0].cls += ' col-lg-' + this.labellg;
20790 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
20793 if(this.labelmd > 0){
20794 cfg.cn[0].cls += ' col-md-' + this.labelmd;
20795 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
20798 if(this.labelsm > 0){
20799 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
20800 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
20803 if(this.labelxs > 0){
20804 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
20805 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
20808 } else if ( this.fieldLabel.length) {
20809 // Roo.log(" label");
20813 tag: this.boxLabel ? 'span' : 'label',
20815 cls: 'control-label box-input-label',
20816 //cls : 'input-group-addon',
20817 html : this.fieldLabel
20826 // Roo.log(" no label && no align");
20827 cfg.cn = [ inputblock ] ;
20833 var boxLabelCfg = {
20835 //'for': id, // box label is handled by onclick - so no for...
20837 html: this.boxLabel
20841 boxLabelCfg.tooltip = this.tooltip;
20844 cfg.cn.push(boxLabelCfg);
20847 if(this.inputType != 'radio'){
20848 cfg.cn.push(hidden);
20856 * return the real input element.
20858 inputEl: function ()
20860 return this.el.select('input.roo-' + this.inputType,true).first();
20862 hiddenEl: function ()
20864 return this.el.select('input.roo-hidden-value',true).first();
20867 labelEl: function()
20869 return this.el.select('label.control-label',true).first();
20871 /* depricated... */
20875 return this.labelEl();
20878 boxLabelEl: function()
20880 return this.el.select('label.box-label',true).first();
20883 initEvents : function()
20885 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
20887 this.inputEl().on('click', this.onClick, this);
20889 if (this.boxLabel) {
20890 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
20893 this.startValue = this.getValue();
20896 Roo.bootstrap.CheckBox.register(this);
20900 onClick : function(e)
20902 if(this.fireEvent('click', this, e) !== false){
20903 this.setChecked(!this.checked);
20908 setChecked : function(state,suppressEvent)
20910 this.startValue = this.getValue();
20912 if(this.inputType == 'radio'){
20914 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20915 e.dom.checked = false;
20918 this.inputEl().dom.checked = true;
20920 this.inputEl().dom.value = this.inputValue;
20922 if(suppressEvent !== true){
20923 this.fireEvent('check', this, true);
20931 this.checked = state;
20933 this.inputEl().dom.checked = state;
20936 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
20938 if(suppressEvent !== true){
20939 this.fireEvent('check', this, state);
20945 getValue : function()
20947 if(this.inputType == 'radio'){
20948 return this.getGroupValue();
20951 return this.hiddenEl().dom.value;
20955 getGroupValue : function()
20957 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
20961 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
20964 setValue : function(v,suppressEvent)
20966 if(this.inputType == 'radio'){
20967 this.setGroupValue(v, suppressEvent);
20971 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
20976 setGroupValue : function(v, suppressEvent)
20978 this.startValue = this.getValue();
20980 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20981 e.dom.checked = false;
20983 if(e.dom.value == v){
20984 e.dom.checked = true;
20988 if(suppressEvent !== true){
20989 this.fireEvent('check', this, true);
20997 validate : function()
20999 if(this.getVisibilityEl().hasClass('hidden')){
21005 (this.inputType == 'radio' && this.validateRadio()) ||
21006 (this.inputType == 'checkbox' && this.validateCheckbox())
21012 this.markInvalid();
21016 validateRadio : function()
21018 if(this.getVisibilityEl().hasClass('hidden')){
21022 if(this.allowBlank){
21028 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21029 if(!e.dom.checked){
21041 validateCheckbox : function()
21044 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
21045 //return (this.getValue() == this.inputValue) ? true : false;
21048 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21056 for(var i in group){
21057 if(group[i].el.isVisible(true)){
21065 for(var i in group){
21070 r = (group[i].getValue() == group[i].inputValue) ? true : false;
21077 * Mark this field as valid
21079 markValid : function()
21083 this.fireEvent('valid', this);
21085 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21088 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21095 if(this.inputType == 'radio'){
21096 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21097 e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
21098 e.findParent('.form-group', false, true).addClass(_this.validClass);
21105 this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
21106 this.el.findParent('.form-group', false, true).addClass(this.validClass);
21110 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21116 for(var i in group){
21117 group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
21118 group[i].el.findParent('.form-group', false, true).addClass(this.validClass);
21123 * Mark this field as invalid
21124 * @param {String} msg The validation message
21126 markInvalid : function(msg)
21128 if(this.allowBlank){
21134 this.fireEvent('invalid', this, msg);
21136 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21139 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
21143 label.markInvalid();
21146 if(this.inputType == 'radio'){
21147 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21148 e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
21149 e.findParent('.form-group', false, true).addClass(_this.invalidClass);
21156 this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
21157 this.el.findParent('.form-group', false, true).addClass(this.invalidClass);
21161 var group = Roo.bootstrap.CheckBox.get(this.groupId);
21167 for(var i in group){
21168 group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
21169 group[i].el.findParent('.form-group', false, true).addClass(this.invalidClass);
21174 clearInvalid : function()
21176 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
21178 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
21180 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
21182 if (label && label.iconEl) {
21183 label.iconEl.removeClass(label.validClass);
21184 label.iconEl.removeClass(label.invalidClass);
21188 disable : function()
21190 if(this.inputType != 'radio'){
21191 Roo.bootstrap.CheckBox.superclass.disable.call(this);
21198 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21199 _this.getActionEl().addClass(this.disabledClass);
21200 e.dom.disabled = true;
21204 this.disabled = true;
21205 this.fireEvent("disable", this);
21209 enable : function()
21211 if(this.inputType != 'radio'){
21212 Roo.bootstrap.CheckBox.superclass.enable.call(this);
21219 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
21220 _this.getActionEl().removeClass(this.disabledClass);
21221 e.dom.disabled = false;
21225 this.disabled = false;
21226 this.fireEvent("enable", this);
21230 setBoxLabel : function(v)
21235 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21241 Roo.apply(Roo.bootstrap.CheckBox, {
21246 * register a CheckBox Group
21247 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
21249 register : function(checkbox)
21251 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
21252 this.groups[checkbox.groupId] = {};
21255 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
21259 this.groups[checkbox.groupId][checkbox.name] = checkbox;
21263 * fetch a CheckBox Group based on the group ID
21264 * @param {string} the group ID
21265 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
21267 get: function(groupId) {
21268 if (typeof(this.groups[groupId]) == 'undefined') {
21272 return this.groups[groupId] ;
21285 * @class Roo.bootstrap.Radio
21286 * @extends Roo.bootstrap.Component
21287 * Bootstrap Radio class
21288 * @cfg {String} boxLabel - the label associated
21289 * @cfg {String} value - the value of radio
21292 * Create a new Radio
21293 * @param {Object} config The config object
21295 Roo.bootstrap.Radio = function(config){
21296 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
21300 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
21306 getAutoCreate : function()
21310 cls : 'form-group radio',
21315 html : this.boxLabel
21323 initEvents : function()
21325 this.parent().register(this);
21327 this.el.on('click', this.onClick, this);
21331 onClick : function(e)
21333 if(this.parent().fireEvent('click', this.parent(), this, e) !== false){
21334 this.setChecked(true);
21338 setChecked : function(state, suppressEvent)
21340 this.parent().setValue(this.value, suppressEvent);
21344 setBoxLabel : function(v)
21349 this.el.select('label.box-label',true).first().dom.innerHTML = (v === null || v === undefined ? '' : v);
21364 * @class Roo.bootstrap.SecurePass
21365 * @extends Roo.bootstrap.Input
21366 * Bootstrap SecurePass class
21370 * Create a new SecurePass
21371 * @param {Object} config The config object
21374 Roo.bootstrap.SecurePass = function (config) {
21375 // these go here, so the translation tool can replace them..
21377 PwdEmpty: "Please type a password, and then retype it to confirm.",
21378 PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21379 PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21380 PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21381 IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21382 FNInPwd: "Your password can't contain your first name. Please type a different password.",
21383 LNInPwd: "Your password can't contain your last name. Please type a different password.",
21384 TooWeak: "Your password is Too Weak."
21386 this.meterLabel = "Password strength:";
21387 this.pwdStrengths = ["Too Weak", "Weak", "Medium", "Strong"];
21388 this.meterClass = [
21389 "roo-password-meter-tooweak",
21390 "roo-password-meter-weak",
21391 "roo-password-meter-medium",
21392 "roo-password-meter-strong",
21393 "roo-password-meter-grey"
21398 Roo.bootstrap.SecurePass.superclass.constructor.call(this, config);
21401 Roo.extend(Roo.bootstrap.SecurePass, Roo.bootstrap.Input, {
21403 * @cfg {String/Object} errors A Error spec, or true for a default spec (defaults to
21405 * PwdEmpty: "Please type a password, and then retype it to confirm.",
21406 * PwdShort: "Your password must be at least 6 characters long. Please type a different password.",
21407 * PwdLong: "Your password can't contain more than 16 characters. Please type a different password.",
21408 * PwdBadChar: "The password contains characters that aren't allowed. Please type a different password.",
21409 * IDInPwd: "Your password can't include the part of your ID. Please type a different password.",
21410 * FNInPwd: "Your password can't contain your first name. Please type a different password.",
21411 * LNInPwd: "Your password can't contain your last name. Please type a different password."
21421 * @cfg {String/Object} Label for the strength meter (defaults to
21422 * 'Password strength:')
21427 * @cfg {String/Object} pwdStrengths A pwdStrengths spec, or true for a default spec (defaults to
21428 * ['Weak', 'Medium', 'Strong'])
21431 pwdStrengths: false,
21444 initEvents: function ()
21446 Roo.bootstrap.SecurePass.superclass.initEvents.call(this);
21448 if (this.el.is('input[type=password]') && Roo.isSafari) {
21449 this.el.on('keydown', this.SafariOnKeyDown, this);
21452 this.el.on('keyup', this.checkStrength, this, {buffer: 50});
21455 onRender: function (ct, position)
21457 Roo.bootstrap.SecurePass.superclass.onRender.call(this, ct, position);
21458 this.wrap = this.el.wrap({cls: 'x-form-field-wrap'});
21459 this.trigger = this.wrap.createChild({tag: 'div', cls: 'StrengthMeter ' + this.triggerClass});
21461 this.trigger.createChild({
21466 cls: 'roo-password-meter-grey col-xs-12',
21469 //width: this.meterWidth + 'px'
21473 cls: 'roo-password-meter-text'
21479 if (this.hideTrigger) {
21480 this.trigger.setDisplayed(false);
21482 this.setSize(this.width || '', this.height || '');
21485 onDestroy: function ()
21487 if (this.trigger) {
21488 this.trigger.removeAllListeners();
21489 this.trigger.remove();
21492 this.wrap.remove();
21494 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
21497 checkStrength: function ()
21499 var pwd = this.inputEl().getValue();
21500 if (pwd == this._lastPwd) {
21505 if (this.ClientSideStrongPassword(pwd)) {
21507 } else if (this.ClientSideMediumPassword(pwd)) {
21509 } else if (this.ClientSideWeakPassword(pwd)) {
21515 Roo.log('strength1: ' + strength);
21517 //var pm = this.trigger.child('div/div/div').dom;
21518 var pm = this.trigger.child('div/div');
21519 pm.removeClass(this.meterClass);
21520 pm.addClass(this.meterClass[strength]);
21523 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21525 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21527 this._lastPwd = pwd;
21531 Roo.bootstrap.SecurePass.superclass.reset.call(this);
21533 this._lastPwd = '';
21535 var pm = this.trigger.child('div/div');
21536 pm.removeClass(this.meterClass);
21537 pm.addClass('roo-password-meter-grey');
21540 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21543 this.inputEl().dom.type='password';
21546 validateValue: function (value)
21549 if (!Roo.bootstrap.SecurePass.superclass.validateValue.call(this, value)) {
21552 if (value.length == 0) {
21553 if (this.allowBlank) {
21554 this.clearInvalid();
21558 this.markInvalid(this.errors.PwdEmpty);
21559 this.errorMsg = this.errors.PwdEmpty;
21567 if ('[\x21-\x7e]*'.match(value)) {
21568 this.markInvalid(this.errors.PwdBadChar);
21569 this.errorMsg = this.errors.PwdBadChar;
21572 if (value.length < 6) {
21573 this.markInvalid(this.errors.PwdShort);
21574 this.errorMsg = this.errors.PwdShort;
21577 if (value.length > 16) {
21578 this.markInvalid(this.errors.PwdLong);
21579 this.errorMsg = this.errors.PwdLong;
21583 if (this.ClientSideStrongPassword(value)) {
21585 } else if (this.ClientSideMediumPassword(value)) {
21587 } else if (this.ClientSideWeakPassword(value)) {
21594 if (strength < 2) {
21595 //this.markInvalid(this.errors.TooWeak);
21596 this.errorMsg = this.errors.TooWeak;
21601 console.log('strength2: ' + strength);
21603 //var pm = this.trigger.child('div/div/div').dom;
21605 var pm = this.trigger.child('div/div');
21606 pm.removeClass(this.meterClass);
21607 pm.addClass(this.meterClass[strength]);
21609 var pt = this.trigger.child('/div').child('>*[class=roo-password-meter-text]').dom;
21611 pt.innerHTML = this.meterLabel + ' ' + this.pwdStrengths[strength];
21613 this.errorMsg = '';
21617 CharacterSetChecks: function (type)
21620 this.fResult = false;
21623 isctype: function (character, type)
21626 case this.kCapitalLetter:
21627 if (character >= 'A' && character <= 'Z') {
21632 case this.kSmallLetter:
21633 if (character >= 'a' && character <= 'z') {
21639 if (character >= '0' && character <= '9') {
21644 case this.kPunctuation:
21645 if ('!@#$%^&*()_+-=\'";:[{]}|.>,</?`~'.indexOf(character) >= 0) {
21656 IsLongEnough: function (pwd, size)
21658 return !(pwd == null || isNaN(size) || pwd.length < size);
21661 SpansEnoughCharacterSets: function (word, nb)
21663 if (!this.IsLongEnough(word, nb))
21668 var characterSetChecks = new Array(
21669 new this.CharacterSetChecks(this.kCapitalLetter), new this.CharacterSetChecks(this.kSmallLetter),
21670 new this.CharacterSetChecks(this.kDigit), new this.CharacterSetChecks(this.kPunctuation)
21673 for (var index = 0; index < word.length; ++index) {
21674 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21675 if (!characterSetChecks[nCharSet].fResult && this.isctype(word.charAt(index), characterSetChecks[nCharSet].type)) {
21676 characterSetChecks[nCharSet].fResult = true;
21683 for (var nCharSet = 0; nCharSet < characterSetChecks.length; ++nCharSet) {
21684 if (characterSetChecks[nCharSet].fResult) {
21689 if (nCharSets < nb) {
21695 ClientSideStrongPassword: function (pwd)
21697 return this.IsLongEnough(pwd, 8) && this.SpansEnoughCharacterSets(pwd, 3);
21700 ClientSideMediumPassword: function (pwd)
21702 return this.IsLongEnough(pwd, 7) && this.SpansEnoughCharacterSets(pwd, 2);
21705 ClientSideWeakPassword: function (pwd)
21707 return this.IsLongEnough(pwd, 6) || !this.IsLongEnough(pwd, 0);
21710 })//<script type="text/javascript">
21713 * Based Ext JS Library 1.1.1
21714 * Copyright(c) 2006-2007, Ext JS, LLC.
21720 * @class Roo.HtmlEditorCore
21721 * @extends Roo.Component
21722 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
21724 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
21727 Roo.HtmlEditorCore = function(config){
21730 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
21735 * @event initialize
21736 * Fires when the editor is fully initialized (including the iframe)
21737 * @param {Roo.HtmlEditorCore} this
21742 * Fires when the editor is first receives the focus. Any insertion must wait
21743 * until after this event.
21744 * @param {Roo.HtmlEditorCore} this
21748 * @event beforesync
21749 * Fires before the textarea is updated with content from the editor iframe. Return false
21750 * to cancel the sync.
21751 * @param {Roo.HtmlEditorCore} this
21752 * @param {String} html
21756 * @event beforepush
21757 * Fires before the iframe editor is updated with content from the textarea. Return false
21758 * to cancel the push.
21759 * @param {Roo.HtmlEditorCore} this
21760 * @param {String} html
21765 * Fires when the textarea is updated with content from the editor iframe.
21766 * @param {Roo.HtmlEditorCore} this
21767 * @param {String} html
21772 * Fires when the iframe editor is updated with content from the textarea.
21773 * @param {Roo.HtmlEditorCore} this
21774 * @param {String} html
21779 * @event editorevent
21780 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
21781 * @param {Roo.HtmlEditorCore} this
21787 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
21789 // defaults : white / black...
21790 this.applyBlacklists();
21797 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
21801 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
21807 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
21812 * @cfg {Number} height (in pixels)
21816 * @cfg {Number} width (in pixels)
21821 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
21824 stylesheets: false,
21829 // private properties
21830 validationEvent : false,
21832 initialized : false,
21834 sourceEditMode : false,
21835 onFocus : Roo.emptyFn,
21837 hideMode:'offsets',
21841 // blacklist + whitelisted elements..
21848 * Protected method that will not generally be called directly. It
21849 * is called when the editor initializes the iframe with HTML contents. Override this method if you
21850 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
21852 getDocMarkup : function(){
21856 // inherit styels from page...??
21857 if (this.stylesheets === false) {
21859 Roo.get(document.head).select('style').each(function(node) {
21860 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
21863 Roo.get(document.head).select('link').each(function(node) {
21864 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
21867 } else if (!this.stylesheets.length) {
21869 st = '<style type="text/css">' +
21870 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
21873 st = '<style type="text/css">' +
21878 st += '<style type="text/css">' +
21879 'IMG { cursor: pointer } ' +
21882 var cls = 'roo-htmleditor-body';
21884 if(this.bodyCls.length){
21885 cls += ' ' + this.bodyCls;
21888 return '<html><head>' + st +
21889 //<style type="text/css">' +
21890 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
21892 ' </head><body class="' + cls + '"></body></html>';
21896 onRender : function(ct, position)
21899 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
21900 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
21903 this.el.dom.style.border = '0 none';
21904 this.el.dom.setAttribute('tabIndex', -1);
21905 this.el.addClass('x-hidden hide');
21909 if(Roo.isIE){ // fix IE 1px bogus margin
21910 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
21914 this.frameId = Roo.id();
21918 var iframe = this.owner.wrap.createChild({
21920 cls: 'form-control', // bootstrap..
21922 name: this.frameId,
21923 frameBorder : 'no',
21924 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
21929 this.iframe = iframe.dom;
21931 this.assignDocWin();
21933 this.doc.designMode = 'on';
21936 this.doc.write(this.getDocMarkup());
21940 var task = { // must defer to wait for browser to be ready
21942 //console.log("run task?" + this.doc.readyState);
21943 this.assignDocWin();
21944 if(this.doc.body || this.doc.readyState == 'complete'){
21946 this.doc.designMode="on";
21950 Roo.TaskMgr.stop(task);
21951 this.initEditor.defer(10, this);
21958 Roo.TaskMgr.start(task);
21963 onResize : function(w, h)
21965 Roo.log('resize: ' +w + ',' + h );
21966 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
21970 if(typeof w == 'number'){
21972 this.iframe.style.width = w + 'px';
21974 if(typeof h == 'number'){
21976 this.iframe.style.height = h + 'px';
21978 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
21985 * Toggles the editor between standard and source edit mode.
21986 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
21988 toggleSourceEdit : function(sourceEditMode){
21990 this.sourceEditMode = sourceEditMode === true;
21992 if(this.sourceEditMode){
21994 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
21997 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
21998 //this.iframe.className = '';
22001 //this.setSize(this.owner.wrap.getSize());
22002 //this.fireEvent('editmodechange', this, this.sourceEditMode);
22009 * Protected method that will not generally be called directly. If you need/want
22010 * custom HTML cleanup, this is the method you should override.
22011 * @param {String} html The HTML to be cleaned
22012 * return {String} The cleaned HTML
22014 cleanHtml : function(html){
22015 html = String(html);
22016 if(html.length > 5){
22017 if(Roo.isSafari){ // strip safari nonsense
22018 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
22021 if(html == ' '){
22028 * HTML Editor -> Textarea
22029 * Protected method that will not generally be called directly. Syncs the contents
22030 * of the editor iframe with the textarea.
22032 syncValue : function(){
22033 if(this.initialized){
22034 var bd = (this.doc.body || this.doc.documentElement);
22035 //this.cleanUpPaste(); -- this is done else where and causes havoc..
22036 var html = bd.innerHTML;
22038 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
22039 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
22041 html = '<div style="'+m[0]+'">' + html + '</div>';
22044 html = this.cleanHtml(html);
22045 // fix up the special chars.. normaly like back quotes in word...
22046 // however we do not want to do this with chinese..
22047 html = html.replace(/([\x80-\uffff])/g, function (a, b) {
22048 var cc = b.charCodeAt();
22050 (cc >= 0x4E00 && cc < 0xA000 ) ||
22051 (cc >= 0x3400 && cc < 0x4E00 ) ||
22052 (cc >= 0xf900 && cc < 0xfb00 )
22058 if(this.owner.fireEvent('beforesync', this, html) !== false){
22059 this.el.dom.value = html;
22060 this.owner.fireEvent('sync', this, html);
22066 * Protected method that will not generally be called directly. Pushes the value of the textarea
22067 * into the iframe editor.
22069 pushValue : function(){
22070 if(this.initialized){
22071 var v = this.el.dom.value.trim();
22073 // if(v.length < 1){
22077 if(this.owner.fireEvent('beforepush', this, v) !== false){
22078 var d = (this.doc.body || this.doc.documentElement);
22080 this.cleanUpPaste();
22081 this.el.dom.value = d.innerHTML;
22082 this.owner.fireEvent('push', this, v);
22088 deferFocus : function(){
22089 this.focus.defer(10, this);
22093 focus : function(){
22094 if(this.win && !this.sourceEditMode){
22101 assignDocWin: function()
22103 var iframe = this.iframe;
22106 this.doc = iframe.contentWindow.document;
22107 this.win = iframe.contentWindow;
22109 // if (!Roo.get(this.frameId)) {
22112 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22113 // this.win = Roo.get(this.frameId).dom.contentWindow;
22115 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
22119 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
22120 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
22125 initEditor : function(){
22126 //console.log("INIT EDITOR");
22127 this.assignDocWin();
22131 this.doc.designMode="on";
22133 this.doc.write(this.getDocMarkup());
22136 var dbody = (this.doc.body || this.doc.documentElement);
22137 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
22138 // this copies styles from the containing element into thsi one..
22139 // not sure why we need all of this..
22140 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
22142 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
22143 //ss['background-attachment'] = 'fixed'; // w3c
22144 dbody.bgProperties = 'fixed'; // ie
22145 //Roo.DomHelper.applyStyles(dbody, ss);
22146 Roo.EventManager.on(this.doc, {
22147 //'mousedown': this.onEditorEvent,
22148 'mouseup': this.onEditorEvent,
22149 'dblclick': this.onEditorEvent,
22150 'click': this.onEditorEvent,
22151 'keyup': this.onEditorEvent,
22156 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
22158 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
22159 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
22161 this.initialized = true;
22163 this.owner.fireEvent('initialize', this);
22168 onDestroy : function(){
22174 //for (var i =0; i < this.toolbars.length;i++) {
22175 // // fixme - ask toolbars for heights?
22176 // this.toolbars[i].onDestroy();
22179 //this.wrap.dom.innerHTML = '';
22180 //this.wrap.remove();
22185 onFirstFocus : function(){
22187 this.assignDocWin();
22190 this.activated = true;
22193 if(Roo.isGecko){ // prevent silly gecko errors
22195 var s = this.win.getSelection();
22196 if(!s.focusNode || s.focusNode.nodeType != 3){
22197 var r = s.getRangeAt(0);
22198 r.selectNodeContents((this.doc.body || this.doc.documentElement));
22203 this.execCmd('useCSS', true);
22204 this.execCmd('styleWithCSS', false);
22207 this.owner.fireEvent('activate', this);
22211 adjustFont: function(btn){
22212 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
22213 //if(Roo.isSafari){ // safari
22216 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
22217 if(Roo.isSafari){ // safari
22218 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
22219 v = (v < 10) ? 10 : v;
22220 v = (v > 48) ? 48 : v;
22221 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
22226 v = Math.max(1, v+adjust);
22228 this.execCmd('FontSize', v );
22231 onEditorEvent : function(e)
22233 this.owner.fireEvent('editorevent', this, e);
22234 // this.updateToolbar();
22235 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
22238 insertTag : function(tg)
22240 // could be a bit smarter... -> wrap the current selected tRoo..
22241 if (tg.toLowerCase() == 'span' || tg.toLowerCase() == 'code') {
22243 range = this.createRange(this.getSelection());
22244 var wrappingNode = this.doc.createElement(tg.toLowerCase());
22245 wrappingNode.appendChild(range.extractContents());
22246 range.insertNode(wrappingNode);
22253 this.execCmd("formatblock", tg);
22257 insertText : function(txt)
22261 var range = this.createRange();
22262 range.deleteContents();
22263 //alert(Sender.getAttribute('label'));
22265 range.insertNode(this.doc.createTextNode(txt));
22271 * Executes a Midas editor command on the editor document and performs necessary focus and
22272 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
22273 * @param {String} cmd The Midas command
22274 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22276 relayCmd : function(cmd, value){
22278 this.execCmd(cmd, value);
22279 this.owner.fireEvent('editorevent', this);
22280 //this.updateToolbar();
22281 this.owner.deferFocus();
22285 * Executes a Midas editor command directly on the editor document.
22286 * For visual commands, you should use {@link #relayCmd} instead.
22287 * <b>This should only be called after the editor is initialized.</b>
22288 * @param {String} cmd The Midas command
22289 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
22291 execCmd : function(cmd, value){
22292 this.doc.execCommand(cmd, false, value === undefined ? null : value);
22299 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
22301 * @param {String} text | dom node..
22303 insertAtCursor : function(text)
22306 if(!this.activated){
22312 var r = this.doc.selection.createRange();
22323 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
22327 // from jquery ui (MIT licenced)
22329 var win = this.win;
22331 if (win.getSelection && win.getSelection().getRangeAt) {
22332 range = win.getSelection().getRangeAt(0);
22333 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
22334 range.insertNode(node);
22335 } else if (win.document.selection && win.document.selection.createRange) {
22336 // no firefox support
22337 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22338 win.document.selection.createRange().pasteHTML(txt);
22340 // no firefox support
22341 var txt = typeof(text) == 'string' ? text : text.outerHTML;
22342 this.execCmd('InsertHTML', txt);
22351 mozKeyPress : function(e){
22353 var c = e.getCharCode(), cmd;
22356 c = String.fromCharCode(c).toLowerCase();
22370 this.cleanUpPaste.defer(100, this);
22378 e.preventDefault();
22386 fixKeys : function(){ // load time branching for fastest keydown performance
22388 return function(e){
22389 var k = e.getKey(), r;
22392 r = this.doc.selection.createRange();
22395 r.pasteHTML('    ');
22402 r = this.doc.selection.createRange();
22404 var target = r.parentElement();
22405 if(!target || target.tagName.toLowerCase() != 'li'){
22407 r.pasteHTML('<br />');
22413 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22414 this.cleanUpPaste.defer(100, this);
22420 }else if(Roo.isOpera){
22421 return function(e){
22422 var k = e.getKey();
22426 this.execCmd('InsertHTML','    ');
22429 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22430 this.cleanUpPaste.defer(100, this);
22435 }else if(Roo.isSafari){
22436 return function(e){
22437 var k = e.getKey();
22441 this.execCmd('InsertText','\t');
22445 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
22446 this.cleanUpPaste.defer(100, this);
22454 getAllAncestors: function()
22456 var p = this.getSelectedNode();
22459 a.push(p); // push blank onto stack..
22460 p = this.getParentElement();
22464 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
22468 a.push(this.doc.body);
22472 lastSelNode : false,
22475 getSelection : function()
22477 this.assignDocWin();
22478 return Roo.isIE ? this.doc.selection : this.win.getSelection();
22481 getSelectedNode: function()
22483 // this may only work on Gecko!!!
22485 // should we cache this!!!!
22490 var range = this.createRange(this.getSelection()).cloneRange();
22493 var parent = range.parentElement();
22495 var testRange = range.duplicate();
22496 testRange.moveToElementText(parent);
22497 if (testRange.inRange(range)) {
22500 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
22503 parent = parent.parentElement;
22508 // is ancestor a text element.
22509 var ac = range.commonAncestorContainer;
22510 if (ac.nodeType == 3) {
22511 ac = ac.parentNode;
22514 var ar = ac.childNodes;
22517 var other_nodes = [];
22518 var has_other_nodes = false;
22519 for (var i=0;i<ar.length;i++) {
22520 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
22523 // fullly contained node.
22525 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
22530 // probably selected..
22531 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
22532 other_nodes.push(ar[i]);
22536 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
22541 has_other_nodes = true;
22543 if (!nodes.length && other_nodes.length) {
22544 nodes= other_nodes;
22546 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
22552 createRange: function(sel)
22554 // this has strange effects when using with
22555 // top toolbar - not sure if it's a great idea.
22556 //this.editor.contentWindow.focus();
22557 if (typeof sel != "undefined") {
22559 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
22561 return this.doc.createRange();
22564 return this.doc.createRange();
22567 getParentElement: function()
22570 this.assignDocWin();
22571 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
22573 var range = this.createRange(sel);
22576 var p = range.commonAncestorContainer;
22577 while (p.nodeType == 3) { // text node
22588 * Range intersection.. the hard stuff...
22592 * [ -- selected range --- ]
22596 * if end is before start or hits it. fail.
22597 * if start is after end or hits it fail.
22599 * if either hits (but other is outside. - then it's not
22605 // @see http://www.thismuchiknow.co.uk/?p=64.
22606 rangeIntersectsNode : function(range, node)
22608 var nodeRange = node.ownerDocument.createRange();
22610 nodeRange.selectNode(node);
22612 nodeRange.selectNodeContents(node);
22615 var rangeStartRange = range.cloneRange();
22616 rangeStartRange.collapse(true);
22618 var rangeEndRange = range.cloneRange();
22619 rangeEndRange.collapse(false);
22621 var nodeStartRange = nodeRange.cloneRange();
22622 nodeStartRange.collapse(true);
22624 var nodeEndRange = nodeRange.cloneRange();
22625 nodeEndRange.collapse(false);
22627 return rangeStartRange.compareBoundaryPoints(
22628 Range.START_TO_START, nodeEndRange) == -1 &&
22629 rangeEndRange.compareBoundaryPoints(
22630 Range.START_TO_START, nodeStartRange) == 1;
22634 rangeCompareNode : function(range, node)
22636 var nodeRange = node.ownerDocument.createRange();
22638 nodeRange.selectNode(node);
22640 nodeRange.selectNodeContents(node);
22644 range.collapse(true);
22646 nodeRange.collapse(true);
22648 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
22649 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
22651 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
22653 var nodeIsBefore = ss == 1;
22654 var nodeIsAfter = ee == -1;
22656 if (nodeIsBefore && nodeIsAfter) {
22659 if (!nodeIsBefore && nodeIsAfter) {
22660 return 1; //right trailed.
22663 if (nodeIsBefore && !nodeIsAfter) {
22664 return 2; // left trailed.
22670 // private? - in a new class?
22671 cleanUpPaste : function()
22673 // cleans up the whole document..
22674 Roo.log('cleanuppaste');
22676 this.cleanUpChildren(this.doc.body);
22677 var clean = this.cleanWordChars(this.doc.body.innerHTML);
22678 if (clean != this.doc.body.innerHTML) {
22679 this.doc.body.innerHTML = clean;
22684 cleanWordChars : function(input) {// change the chars to hex code
22685 var he = Roo.HtmlEditorCore;
22687 var output = input;
22688 Roo.each(he.swapCodes, function(sw) {
22689 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
22691 output = output.replace(swapper, sw[1]);
22698 cleanUpChildren : function (n)
22700 if (!n.childNodes.length) {
22703 for (var i = n.childNodes.length-1; i > -1 ; i--) {
22704 this.cleanUpChild(n.childNodes[i]);
22711 cleanUpChild : function (node)
22714 //console.log(node);
22715 if (node.nodeName == "#text") {
22716 // clean up silly Windows -- stuff?
22719 if (node.nodeName == "#comment") {
22720 node.parentNode.removeChild(node);
22721 // clean up silly Windows -- stuff?
22724 var lcname = node.tagName.toLowerCase();
22725 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
22726 // whitelist of tags..
22728 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
22730 node.parentNode.removeChild(node);
22735 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
22737 // remove <a name=....> as rendering on yahoo mailer is borked with this.
22738 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
22740 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
22741 // remove_keep_children = true;
22744 if (remove_keep_children) {
22745 this.cleanUpChildren(node);
22746 // inserts everything just before this node...
22747 while (node.childNodes.length) {
22748 var cn = node.childNodes[0];
22749 node.removeChild(cn);
22750 node.parentNode.insertBefore(cn, node);
22752 node.parentNode.removeChild(node);
22756 if (!node.attributes || !node.attributes.length) {
22757 this.cleanUpChildren(node);
22761 function cleanAttr(n,v)
22764 if (v.match(/^\./) || v.match(/^\//)) {
22767 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/) || v.match(/^ftp:/)) {
22770 if (v.match(/^#/)) {
22773 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
22774 node.removeAttribute(n);
22778 var cwhite = this.cwhite;
22779 var cblack = this.cblack;
22781 function cleanStyle(n,v)
22783 if (v.match(/expression/)) { //XSS?? should we even bother..
22784 node.removeAttribute(n);
22788 var parts = v.split(/;/);
22791 Roo.each(parts, function(p) {
22792 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
22796 var l = p.split(':').shift().replace(/\s+/g,'');
22797 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
22799 if ( cwhite.length && cblack.indexOf(l) > -1) {
22800 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22801 //node.removeAttribute(n);
22805 // only allow 'c whitelisted system attributes'
22806 if ( cwhite.length && cwhite.indexOf(l) < 0) {
22807 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
22808 //node.removeAttribute(n);
22818 if (clean.length) {
22819 node.setAttribute(n, clean.join(';'));
22821 node.removeAttribute(n);
22827 for (var i = node.attributes.length-1; i > -1 ; i--) {
22828 var a = node.attributes[i];
22831 if (a.name.toLowerCase().substr(0,2)=='on') {
22832 node.removeAttribute(a.name);
22835 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
22836 node.removeAttribute(a.name);
22839 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
22840 cleanAttr(a.name,a.value); // fixme..
22843 if (a.name == 'style') {
22844 cleanStyle(a.name,a.value);
22847 /// clean up MS crap..
22848 // tecnically this should be a list of valid class'es..
22851 if (a.name == 'class') {
22852 if (a.value.match(/^Mso/)) {
22853 node.className = '';
22856 if (a.value.match(/^body$/)) {
22857 node.className = '';
22868 this.cleanUpChildren(node);
22874 * Clean up MS wordisms...
22876 cleanWord : function(node)
22881 this.cleanWord(this.doc.body);
22884 if (node.nodeName == "#text") {
22885 // clean up silly Windows -- stuff?
22888 if (node.nodeName == "#comment") {
22889 node.parentNode.removeChild(node);
22890 // clean up silly Windows -- stuff?
22894 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
22895 node.parentNode.removeChild(node);
22899 // remove - but keep children..
22900 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|font)/)) {
22901 while (node.childNodes.length) {
22902 var cn = node.childNodes[0];
22903 node.removeChild(cn);
22904 node.parentNode.insertBefore(cn, node);
22906 node.parentNode.removeChild(node);
22907 this.iterateChildren(node, this.cleanWord);
22911 if (node.className.length) {
22913 var cn = node.className.split(/\W+/);
22915 Roo.each(cn, function(cls) {
22916 if (cls.match(/Mso[a-zA-Z]+/)) {
22921 node.className = cna.length ? cna.join(' ') : '';
22923 node.removeAttribute("class");
22927 if (node.hasAttribute("lang")) {
22928 node.removeAttribute("lang");
22931 if (node.hasAttribute("style")) {
22933 var styles = node.getAttribute("style").split(";");
22935 Roo.each(styles, function(s) {
22936 if (!s.match(/:/)) {
22939 var kv = s.split(":");
22940 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
22943 // what ever is left... we allow.
22946 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
22947 if (!nstyle.length) {
22948 node.removeAttribute('style');
22951 this.iterateChildren(node, this.cleanWord);
22957 * iterateChildren of a Node, calling fn each time, using this as the scole..
22958 * @param {DomNode} node node to iterate children of.
22959 * @param {Function} fn method of this class to call on each item.
22961 iterateChildren : function(node, fn)
22963 if (!node.childNodes.length) {
22966 for (var i = node.childNodes.length-1; i > -1 ; i--) {
22967 fn.call(this, node.childNodes[i])
22973 * cleanTableWidths.
22975 * Quite often pasting from word etc.. results in tables with column and widths.
22976 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
22979 cleanTableWidths : function(node)
22984 this.cleanTableWidths(this.doc.body);
22989 if (node.nodeName == "#text" || node.nodeName == "#comment") {
22992 Roo.log(node.tagName);
22993 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
22994 this.iterateChildren(node, this.cleanTableWidths);
22997 if (node.hasAttribute('width')) {
22998 node.removeAttribute('width');
23002 if (node.hasAttribute("style")) {
23005 var styles = node.getAttribute("style").split(";");
23007 Roo.each(styles, function(s) {
23008 if (!s.match(/:/)) {
23011 var kv = s.split(":");
23012 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
23015 // what ever is left... we allow.
23018 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
23019 if (!nstyle.length) {
23020 node.removeAttribute('style');
23024 this.iterateChildren(node, this.cleanTableWidths);
23032 domToHTML : function(currentElement, depth, nopadtext) {
23034 depth = depth || 0;
23035 nopadtext = nopadtext || false;
23037 if (!currentElement) {
23038 return this.domToHTML(this.doc.body);
23041 //Roo.log(currentElement);
23043 var allText = false;
23044 var nodeName = currentElement.nodeName;
23045 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
23047 if (nodeName == '#text') {
23049 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
23054 if (nodeName != 'BODY') {
23057 // Prints the node tagName, such as <A>, <IMG>, etc
23060 for(i = 0; i < currentElement.attributes.length;i++) {
23062 var aname = currentElement.attributes.item(i).name;
23063 if (!currentElement.attributes.item(i).value.length) {
23066 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
23069 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
23078 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
23081 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
23086 // Traverse the tree
23088 var currentElementChild = currentElement.childNodes.item(i);
23089 var allText = true;
23090 var innerHTML = '';
23092 while (currentElementChild) {
23093 // Formatting code (indent the tree so it looks nice on the screen)
23094 var nopad = nopadtext;
23095 if (lastnode == 'SPAN') {
23099 if (currentElementChild.nodeName == '#text') {
23100 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
23101 toadd = nopadtext ? toadd : toadd.trim();
23102 if (!nopad && toadd.length > 80) {
23103 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
23105 innerHTML += toadd;
23108 currentElementChild = currentElement.childNodes.item(i);
23114 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
23116 // Recursively traverse the tree structure of the child node
23117 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
23118 lastnode = currentElementChild.nodeName;
23120 currentElementChild=currentElement.childNodes.item(i);
23126 // The remaining code is mostly for formatting the tree
23127 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
23132 ret+= "</"+tagName+">";
23138 applyBlacklists : function()
23140 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
23141 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
23145 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
23146 if (b.indexOf(tag) > -1) {
23149 this.white.push(tag);
23153 Roo.each(w, function(tag) {
23154 if (b.indexOf(tag) > -1) {
23157 if (this.white.indexOf(tag) > -1) {
23160 this.white.push(tag);
23165 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
23166 if (w.indexOf(tag) > -1) {
23169 this.black.push(tag);
23173 Roo.each(b, function(tag) {
23174 if (w.indexOf(tag) > -1) {
23177 if (this.black.indexOf(tag) > -1) {
23180 this.black.push(tag);
23185 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
23186 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
23190 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
23191 if (b.indexOf(tag) > -1) {
23194 this.cwhite.push(tag);
23198 Roo.each(w, function(tag) {
23199 if (b.indexOf(tag) > -1) {
23202 if (this.cwhite.indexOf(tag) > -1) {
23205 this.cwhite.push(tag);
23210 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
23211 if (w.indexOf(tag) > -1) {
23214 this.cblack.push(tag);
23218 Roo.each(b, function(tag) {
23219 if (w.indexOf(tag) > -1) {
23222 if (this.cblack.indexOf(tag) > -1) {
23225 this.cblack.push(tag);
23230 setStylesheets : function(stylesheets)
23232 if(typeof(stylesheets) == 'string'){
23233 Roo.get(this.iframe.contentDocument.head).createChild({
23235 rel : 'stylesheet',
23244 Roo.each(stylesheets, function(s) {
23249 Roo.get(_this.iframe.contentDocument.head).createChild({
23251 rel : 'stylesheet',
23260 removeStylesheets : function()
23264 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
23269 setStyle : function(style)
23271 Roo.get(this.iframe.contentDocument.head).createChild({
23280 // hide stuff that is not compatible
23294 * @event specialkey
23298 * @cfg {String} fieldClass @hide
23301 * @cfg {String} focusClass @hide
23304 * @cfg {String} autoCreate @hide
23307 * @cfg {String} inputType @hide
23310 * @cfg {String} invalidClass @hide
23313 * @cfg {String} invalidText @hide
23316 * @cfg {String} msgFx @hide
23319 * @cfg {String} validateOnBlur @hide
23323 Roo.HtmlEditorCore.white = [
23324 'area', 'br', 'img', 'input', 'hr', 'wbr',
23326 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
23327 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
23328 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
23329 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
23330 'table', 'ul', 'xmp',
23332 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
23335 'dir', 'menu', 'ol', 'ul', 'dl',
23341 Roo.HtmlEditorCore.black = [
23342 // 'embed', 'object', // enable - backend responsiblity to clean thiese
23344 'base', 'basefont', 'bgsound', 'blink', 'body',
23345 'frame', 'frameset', 'head', 'html', 'ilayer',
23346 'iframe', 'layer', 'link', 'meta', 'object',
23347 'script', 'style' ,'title', 'xml' // clean later..
23349 Roo.HtmlEditorCore.clean = [
23350 'script', 'style', 'title', 'xml'
23352 Roo.HtmlEditorCore.remove = [
23357 Roo.HtmlEditorCore.ablack = [
23361 Roo.HtmlEditorCore.aclean = [
23362 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
23366 Roo.HtmlEditorCore.pwhite= [
23367 'http', 'https', 'mailto'
23370 // white listed style attributes.
23371 Roo.HtmlEditorCore.cwhite= [
23372 // 'text-align', /// default is to allow most things..
23378 // black listed style attributes.
23379 Roo.HtmlEditorCore.cblack= [
23380 // 'font-size' -- this can be set by the project
23384 Roo.HtmlEditorCore.swapCodes =[
23403 * @class Roo.bootstrap.HtmlEditor
23404 * @extends Roo.bootstrap.TextArea
23405 * Bootstrap HtmlEditor class
23408 * Create a new HtmlEditor
23409 * @param {Object} config The config object
23412 Roo.bootstrap.HtmlEditor = function(config){
23413 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
23414 if (!this.toolbars) {
23415 this.toolbars = [];
23418 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
23421 * @event initialize
23422 * Fires when the editor is fully initialized (including the iframe)
23423 * @param {HtmlEditor} this
23428 * Fires when the editor is first receives the focus. Any insertion must wait
23429 * until after this event.
23430 * @param {HtmlEditor} this
23434 * @event beforesync
23435 * Fires before the textarea is updated with content from the editor iframe. Return false
23436 * to cancel the sync.
23437 * @param {HtmlEditor} this
23438 * @param {String} html
23442 * @event beforepush
23443 * Fires before the iframe editor is updated with content from the textarea. Return false
23444 * to cancel the push.
23445 * @param {HtmlEditor} this
23446 * @param {String} html
23451 * Fires when the textarea is updated with content from the editor iframe.
23452 * @param {HtmlEditor} this
23453 * @param {String} html
23458 * Fires when the iframe editor is updated with content from the textarea.
23459 * @param {HtmlEditor} this
23460 * @param {String} html
23464 * @event editmodechange
23465 * Fires when the editor switches edit modes
23466 * @param {HtmlEditor} this
23467 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
23469 editmodechange: true,
23471 * @event editorevent
23472 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
23473 * @param {HtmlEditor} this
23477 * @event firstfocus
23478 * Fires when on first focus - needed by toolbars..
23479 * @param {HtmlEditor} this
23484 * Auto save the htmlEditor value as a file into Events
23485 * @param {HtmlEditor} this
23489 * @event savedpreview
23490 * preview the saved version of htmlEditor
23491 * @param {HtmlEditor} this
23498 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
23502 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
23507 * @cfg {Array} buttons Array of toolbar's buttons. - defaults to empty
23512 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
23517 * @cfg {Number} height (in pixels)
23521 * @cfg {Number} width (in pixels)
23526 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
23529 stylesheets: false,
23534 // private properties
23535 validationEvent : false,
23537 initialized : false,
23540 onFocus : Roo.emptyFn,
23542 hideMode:'offsets',
23544 tbContainer : false,
23548 toolbarContainer :function() {
23549 return this.wrap.select('.x-html-editor-tb',true).first();
23553 * Protected method that will not generally be called directly. It
23554 * is called when the editor creates its toolbar. Override this method if you need to
23555 * add custom toolbar buttons.
23556 * @param {HtmlEditor} editor
23558 createToolbar : function(){
23559 Roo.log('renewing');
23560 Roo.log("create toolbars");
23562 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
23563 this.toolbars[0].render(this.toolbarContainer());
23567 // if (!editor.toolbars || !editor.toolbars.length) {
23568 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
23571 // for (var i =0 ; i < editor.toolbars.length;i++) {
23572 // editor.toolbars[i] = Roo.factory(
23573 // typeof(editor.toolbars[i]) == 'string' ?
23574 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
23575 // Roo.bootstrap.HtmlEditor);
23576 // editor.toolbars[i].init(editor);
23582 onRender : function(ct, position)
23584 // Roo.log("Call onRender: " + this.xtype);
23586 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
23588 this.wrap = this.inputEl().wrap({
23589 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
23592 this.editorcore.onRender(ct, position);
23594 if (this.resizable) {
23595 this.resizeEl = new Roo.Resizable(this.wrap, {
23599 minHeight : this.height,
23600 height: this.height,
23601 handles : this.resizable,
23604 resize : function(r, w, h) {
23605 _t.onResize(w,h); // -something
23611 this.createToolbar(this);
23614 if(!this.width && this.resizable){
23615 this.setSize(this.wrap.getSize());
23617 if (this.resizeEl) {
23618 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
23619 // should trigger onReize..
23625 onResize : function(w, h)
23627 Roo.log('resize: ' +w + ',' + h );
23628 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
23632 if(this.inputEl() ){
23633 if(typeof w == 'number'){
23634 var aw = w - this.wrap.getFrameWidth('lr');
23635 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
23638 if(typeof h == 'number'){
23639 var tbh = -11; // fixme it needs to tool bar size!
23640 for (var i =0; i < this.toolbars.length;i++) {
23641 // fixme - ask toolbars for heights?
23642 tbh += this.toolbars[i].el.getHeight();
23643 //if (this.toolbars[i].footer) {
23644 // tbh += this.toolbars[i].footer.el.getHeight();
23652 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
23653 ah -= 5; // knock a few pixes off for look..
23654 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
23658 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
23659 this.editorcore.onResize(ew,eh);
23664 * Toggles the editor between standard and source edit mode.
23665 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
23667 toggleSourceEdit : function(sourceEditMode)
23669 this.editorcore.toggleSourceEdit(sourceEditMode);
23671 if(this.editorcore.sourceEditMode){
23672 Roo.log('editor - showing textarea');
23675 // Roo.log(this.syncValue());
23677 this.inputEl().removeClass(['hide', 'x-hidden']);
23678 this.inputEl().dom.removeAttribute('tabIndex');
23679 this.inputEl().focus();
23681 Roo.log('editor - hiding textarea');
23683 // Roo.log(this.pushValue());
23686 this.inputEl().addClass(['hide', 'x-hidden']);
23687 this.inputEl().dom.setAttribute('tabIndex', -1);
23688 //this.deferFocus();
23691 if(this.resizable){
23692 this.setSize(this.wrap.getSize());
23695 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
23698 // private (for BoxComponent)
23699 adjustSize : Roo.BoxComponent.prototype.adjustSize,
23701 // private (for BoxComponent)
23702 getResizeEl : function(){
23706 // private (for BoxComponent)
23707 getPositionEl : function(){
23712 initEvents : function(){
23713 this.originalValue = this.getValue();
23717 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23720 // markInvalid : Roo.emptyFn,
23722 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
23725 // clearInvalid : Roo.emptyFn,
23727 setValue : function(v){
23728 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
23729 this.editorcore.pushValue();
23734 deferFocus : function(){
23735 this.focus.defer(10, this);
23739 focus : function(){
23740 this.editorcore.focus();
23746 onDestroy : function(){
23752 for (var i =0; i < this.toolbars.length;i++) {
23753 // fixme - ask toolbars for heights?
23754 this.toolbars[i].onDestroy();
23757 this.wrap.dom.innerHTML = '';
23758 this.wrap.remove();
23763 onFirstFocus : function(){
23764 //Roo.log("onFirstFocus");
23765 this.editorcore.onFirstFocus();
23766 for (var i =0; i < this.toolbars.length;i++) {
23767 this.toolbars[i].onFirstFocus();
23773 syncValue : function()
23775 this.editorcore.syncValue();
23778 pushValue : function()
23780 this.editorcore.pushValue();
23784 // hide stuff that is not compatible
23798 * @event specialkey
23802 * @cfg {String} fieldClass @hide
23805 * @cfg {String} focusClass @hide
23808 * @cfg {String} autoCreate @hide
23811 * @cfg {String} inputType @hide
23814 * @cfg {String} invalidClass @hide
23817 * @cfg {String} invalidText @hide
23820 * @cfg {String} msgFx @hide
23823 * @cfg {String} validateOnBlur @hide
23832 Roo.namespace('Roo.bootstrap.htmleditor');
23834 * @class Roo.bootstrap.HtmlEditorToolbar1
23839 new Roo.bootstrap.HtmlEditor({
23842 new Roo.bootstrap.HtmlEditorToolbar1({
23843 disable : { fonts: 1 , format: 1, ..., ... , ...],
23849 * @cfg {Object} disable List of elements to disable..
23850 * @cfg {Array} btns List of additional buttons.
23854 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
23857 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
23860 Roo.apply(this, config);
23862 // default disabled, based on 'good practice'..
23863 this.disable = this.disable || {};
23864 Roo.applyIf(this.disable, {
23867 specialElements : true
23869 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
23871 this.editor = config.editor;
23872 this.editorcore = config.editor.editorcore;
23874 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
23876 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
23877 // dont call parent... till later.
23879 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
23884 editorcore : false,
23889 "h1","h2","h3","h4","h5","h6",
23891 "abbr", "acronym", "address", "cite", "samp", "var",
23895 onRender : function(ct, position)
23897 // Roo.log("Call onRender: " + this.xtype);
23899 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
23901 this.el.dom.style.marginBottom = '0';
23903 var editorcore = this.editorcore;
23904 var editor= this.editor;
23907 var btn = function(id,cmd , toggle, handler, html){
23909 var event = toggle ? 'toggle' : 'click';
23914 xns: Roo.bootstrap,
23917 enableToggle:toggle !== false,
23919 pressed : toggle ? false : null,
23922 a.listeners[toggle ? 'toggle' : 'click'] = function() {
23923 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
23929 // var cb_box = function...
23934 xns: Roo.bootstrap,
23935 glyphicon : 'font',
23939 xns: Roo.bootstrap,
23943 Roo.each(this.formats, function(f) {
23944 style.menu.items.push({
23946 xns: Roo.bootstrap,
23947 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
23952 editorcore.insertTag(this.tagname);
23959 children.push(style);
23961 btn('bold',false,true);
23962 btn('italic',false,true);
23963 btn('align-left', 'justifyleft',true);
23964 btn('align-center', 'justifycenter',true);
23965 btn('align-right' , 'justifyright',true);
23966 btn('link', false, false, function(btn) {
23967 //Roo.log("create link?");
23968 var url = prompt(this.createLinkText, this.defaultLinkValue);
23969 if(url && url != 'http:/'+'/'){
23970 this.editorcore.relayCmd('createlink', url);
23973 btn('list','insertunorderedlist',true);
23974 btn('pencil', false,true, function(btn){
23976 this.toggleSourceEdit(btn.pressed);
23979 if (this.editor.btns.length > 0) {
23980 for (var i = 0; i<this.editor.btns.length; i++) {
23981 children.push(this.editor.btns[i]);
23989 xns: Roo.bootstrap,
23994 xns: Roo.bootstrap,
23999 cog.menu.items.push({
24001 xns: Roo.bootstrap,
24002 html : Clean styles,
24007 editorcore.insertTag(this.tagname);
24016 this.xtype = 'NavSimplebar';
24018 for(var i=0;i< children.length;i++) {
24020 this.buttons.add(this.addxtypeChild(children[i]));
24024 editor.on('editorevent', this.updateToolbar, this);
24026 onBtnClick : function(id)
24028 this.editorcore.relayCmd(id);
24029 this.editorcore.focus();
24033 * Protected method that will not generally be called directly. It triggers
24034 * a toolbar update by reading the markup state of the current selection in the editor.
24036 updateToolbar: function(){
24038 if(!this.editorcore.activated){
24039 this.editor.onFirstFocus(); // is this neeed?
24043 var btns = this.buttons;
24044 var doc = this.editorcore.doc;
24045 btns.get('bold').setActive(doc.queryCommandState('bold'));
24046 btns.get('italic').setActive(doc.queryCommandState('italic'));
24047 //btns.get('underline').setActive(doc.queryCommandState('underline'));
24049 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
24050 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
24051 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
24053 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
24054 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
24057 var ans = this.editorcore.getAllAncestors();
24058 if (this.formatCombo) {
24061 var store = this.formatCombo.store;
24062 this.formatCombo.setValue("");
24063 for (var i =0; i < ans.length;i++) {
24064 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
24066 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
24074 // hides menus... - so this cant be on a menu...
24075 Roo.bootstrap.MenuMgr.hideAll();
24077 Roo.bootstrap.MenuMgr.hideAll();
24078 //this.editorsyncValue();
24080 onFirstFocus: function() {
24081 this.buttons.each(function(item){
24085 toggleSourceEdit : function(sourceEditMode){
24088 if(sourceEditMode){
24089 Roo.log("disabling buttons");
24090 this.buttons.each( function(item){
24091 if(item.cmd != 'pencil'){
24097 Roo.log("enabling buttons");
24098 if(this.editorcore.initialized){
24099 this.buttons.each( function(item){
24105 Roo.log("calling toggole on editor");
24106 // tell the editor that it's been pressed..
24107 this.editor.toggleSourceEdit(sourceEditMode);
24117 * @class Roo.bootstrap.Table.AbstractSelectionModel
24118 * @extends Roo.util.Observable
24119 * Abstract base class for grid SelectionModels. It provides the interface that should be
24120 * implemented by descendant classes. This class should not be directly instantiated.
24123 Roo.bootstrap.Table.AbstractSelectionModel = function(){
24124 this.locked = false;
24125 Roo.bootstrap.Table.AbstractSelectionModel.superclass.constructor.call(this);
24129 Roo.extend(Roo.bootstrap.Table.AbstractSelectionModel, Roo.util.Observable, {
24130 /** @ignore Called by the grid automatically. Do not call directly. */
24131 init : function(grid){
24137 * Locks the selections.
24140 this.locked = true;
24144 * Unlocks the selections.
24146 unlock : function(){
24147 this.locked = false;
24151 * Returns true if the selections are locked.
24152 * @return {Boolean}
24154 isLocked : function(){
24155 return this.locked;
24159 * @extends Roo.bootstrap.Table.AbstractSelectionModel
24160 * @class Roo.bootstrap.Table.RowSelectionModel
24161 * The default SelectionModel used by {@link Roo.bootstrap.Table}.
24162 * It supports multiple selections and keyboard selection/navigation.
24164 * @param {Object} config
24167 Roo.bootstrap.Table.RowSelectionModel = function(config){
24168 Roo.apply(this, config);
24169 this.selections = new Roo.util.MixedCollection(false, function(o){
24174 this.lastActive = false;
24178 * @event selectionchange
24179 * Fires when the selection changes
24180 * @param {SelectionModel} this
24182 "selectionchange" : true,
24184 * @event afterselectionchange
24185 * Fires after the selection changes (eg. by key press or clicking)
24186 * @param {SelectionModel} this
24188 "afterselectionchange" : true,
24190 * @event beforerowselect
24191 * Fires when a row is selected being selected, return false to cancel.
24192 * @param {SelectionModel} this
24193 * @param {Number} rowIndex The selected index
24194 * @param {Boolean} keepExisting False if other selections will be cleared
24196 "beforerowselect" : true,
24199 * Fires when a row is selected.
24200 * @param {SelectionModel} this
24201 * @param {Number} rowIndex The selected index
24202 * @param {Roo.data.Record} r The record
24204 "rowselect" : true,
24206 * @event rowdeselect
24207 * Fires when a row is deselected.
24208 * @param {SelectionModel} this
24209 * @param {Number} rowIndex The selected index
24211 "rowdeselect" : true
24213 Roo.bootstrap.Table.RowSelectionModel.superclass.constructor.call(this);
24214 this.locked = false;
24217 Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSelectionModel, {
24219 * @cfg {Boolean} singleSelect
24220 * True to allow selection of only one row at a time (defaults to false)
24222 singleSelect : false,
24225 initEvents : function()
24228 //if(!this.grid.enableDragDrop && !this.grid.enableDrag){
24229 // this.growclickrid.on("mousedown", this.handleMouseDown, this);
24230 //}else{ // allow click to work like normal
24231 // this.grid.on("rowclick", this.handleDragableRowClick, this);
24233 //this.grid.on("rowdblclick", this.handleMouseDBClick, this);
24234 this.grid.on("rowclick", this.handleMouseDown, this);
24236 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
24237 "up" : function(e){
24239 this.selectPrevious(e.shiftKey);
24240 }else if(this.last !== false && this.lastActive !== false){
24241 var last = this.last;
24242 this.selectRange(this.last, this.lastActive-1);
24243 this.grid.getView().focusRow(this.lastActive);
24244 if(last !== false){
24248 this.selectFirstRow();
24250 this.fireEvent("afterselectionchange", this);
24252 "down" : function(e){
24254 this.selectNext(e.shiftKey);
24255 }else if(this.last !== false && this.lastActive !== false){
24256 var last = this.last;
24257 this.selectRange(this.last, this.lastActive+1);
24258 this.grid.getView().focusRow(this.lastActive);
24259 if(last !== false){
24263 this.selectFirstRow();
24265 this.fireEvent("afterselectionchange", this);
24269 this.grid.store.on('load', function(){
24270 this.selections.clear();
24273 var view = this.grid.view;
24274 view.on("refresh", this.onRefresh, this);
24275 view.on("rowupdated", this.onRowUpdated, this);
24276 view.on("rowremoved", this.onRemove, this);
24281 onRefresh : function()
24283 var ds = this.grid.store, i, v = this.grid.view;
24284 var s = this.selections;
24285 s.each(function(r){
24286 if((i = ds.indexOfId(r.id)) != -1){
24295 onRemove : function(v, index, r){
24296 this.selections.remove(r);
24300 onRowUpdated : function(v, index, r){
24301 if(this.isSelected(r)){
24302 v.onRowSelect(index);
24308 * @param {Array} records The records to select
24309 * @param {Boolean} keepExisting (optional) True to keep existing selections
24311 selectRecords : function(records, keepExisting)
24314 this.clearSelections();
24316 var ds = this.grid.store;
24317 for(var i = 0, len = records.length; i < len; i++){
24318 this.selectRow(ds.indexOf(records[i]), true);
24323 * Gets the number of selected rows.
24326 getCount : function(){
24327 return this.selections.length;
24331 * Selects the first row in the grid.
24333 selectFirstRow : function(){
24338 * Select the last row.
24339 * @param {Boolean} keepExisting (optional) True to keep existing selections
24341 selectLastRow : function(keepExisting){
24342 //this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
24343 this.selectRow(this.grid.store.getCount() - 1, keepExisting);
24347 * Selects the row immediately following the last selected row.
24348 * @param {Boolean} keepExisting (optional) True to keep existing selections
24350 selectNext : function(keepExisting)
24352 if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
24353 this.selectRow(this.last+1, keepExisting);
24354 this.grid.getView().focusRow(this.last);
24359 * Selects the row that precedes the last selected row.
24360 * @param {Boolean} keepExisting (optional) True to keep existing selections
24362 selectPrevious : function(keepExisting){
24364 this.selectRow(this.last-1, keepExisting);
24365 this.grid.getView().focusRow(this.last);
24370 * Returns the selected records
24371 * @return {Array} Array of selected records
24373 getSelections : function(){
24374 return [].concat(this.selections.items);
24378 * Returns the first selected record.
24381 getSelected : function(){
24382 return this.selections.itemAt(0);
24387 * Clears all selections.
24389 clearSelections : function(fast)
24395 var ds = this.grid.store;
24396 var s = this.selections;
24397 s.each(function(r){
24398 this.deselectRow(ds.indexOfId(r.id));
24402 this.selections.clear();
24409 * Selects all rows.
24411 selectAll : function(){
24415 this.selections.clear();
24416 for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
24417 this.selectRow(i, true);
24422 * Returns True if there is a selection.
24423 * @return {Boolean}
24425 hasSelection : function(){
24426 return this.selections.length > 0;
24430 * Returns True if the specified row is selected.
24431 * @param {Number/Record} record The record or index of the record to check
24432 * @return {Boolean}
24434 isSelected : function(index){
24435 var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
24436 return (r && this.selections.key(r.id) ? true : false);
24440 * Returns True if the specified record id is selected.
24441 * @param {String} id The id of record to check
24442 * @return {Boolean}
24444 isIdSelected : function(id){
24445 return (this.selections.key(id) ? true : false);
24450 handleMouseDBClick : function(e, t){
24454 handleMouseDown : function(e, t)
24456 var rowIndex = this.grid.headerShow ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
24457 if(this.isLocked() || rowIndex < 0 ){
24460 if(e.shiftKey && this.last !== false){
24461 var last = this.last;
24462 this.selectRange(last, rowIndex, e.ctrlKey);
24463 this.last = last; // reset the last
24467 var isSelected = this.isSelected(rowIndex);
24468 //Roo.log("select row:" + rowIndex);
24470 this.deselectRow(rowIndex);
24472 this.selectRow(rowIndex, true);
24476 if(e.button !== 0 && isSelected){
24477 alert('rowIndex 2: ' + rowIndex);
24478 view.focusRow(rowIndex);
24479 }else if(e.ctrlKey && isSelected){
24480 this.deselectRow(rowIndex);
24481 }else if(!isSelected){
24482 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
24483 view.focusRow(rowIndex);
24487 this.fireEvent("afterselectionchange", this);
24490 handleDragableRowClick : function(grid, rowIndex, e)
24492 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
24493 this.selectRow(rowIndex, false);
24494 grid.view.focusRow(rowIndex);
24495 this.fireEvent("afterselectionchange", this);
24500 * Selects multiple rows.
24501 * @param {Array} rows Array of the indexes of the row to select
24502 * @param {Boolean} keepExisting (optional) True to keep existing selections
24504 selectRows : function(rows, keepExisting){
24506 this.clearSelections();
24508 for(var i = 0, len = rows.length; i < len; i++){
24509 this.selectRow(rows[i], true);
24514 * Selects a range of rows. All rows in between startRow and endRow are also selected.
24515 * @param {Number} startRow The index of the first row in the range
24516 * @param {Number} endRow The index of the last row in the range
24517 * @param {Boolean} keepExisting (optional) True to retain existing selections
24519 selectRange : function(startRow, endRow, keepExisting){
24524 this.clearSelections();
24526 if(startRow <= endRow){
24527 for(var i = startRow; i <= endRow; i++){
24528 this.selectRow(i, true);
24531 for(var i = startRow; i >= endRow; i--){
24532 this.selectRow(i, true);
24538 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
24539 * @param {Number} startRow The index of the first row in the range
24540 * @param {Number} endRow The index of the last row in the range
24542 deselectRange : function(startRow, endRow, preventViewNotify){
24546 for(var i = startRow; i <= endRow; i++){
24547 this.deselectRow(i, preventViewNotify);
24553 * @param {Number} row The index of the row to select
24554 * @param {Boolean} keepExisting (optional) True to keep existing selections
24556 selectRow : function(index, keepExisting, preventViewNotify)
24558 if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
24561 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
24562 if(!keepExisting || this.singleSelect){
24563 this.clearSelections();
24566 var r = this.grid.store.getAt(index);
24567 //console.log('selectRow - record id :' + r.id);
24569 this.selections.add(r);
24570 this.last = this.lastActive = index;
24571 if(!preventViewNotify){
24572 var proxy = new Roo.Element(
24573 this.grid.getRowDom(index)
24575 proxy.addClass('bg-info info');
24577 this.fireEvent("rowselect", this, index, r);
24578 this.fireEvent("selectionchange", this);
24584 * @param {Number} row The index of the row to deselect
24586 deselectRow : function(index, preventViewNotify)
24591 if(this.last == index){
24594 if(this.lastActive == index){
24595 this.lastActive = false;
24598 var r = this.grid.store.getAt(index);
24603 this.selections.remove(r);
24604 //.console.log('deselectRow - record id :' + r.id);
24605 if(!preventViewNotify){
24607 var proxy = new Roo.Element(
24608 this.grid.getRowDom(index)
24610 proxy.removeClass('bg-info info');
24612 this.fireEvent("rowdeselect", this, index);
24613 this.fireEvent("selectionchange", this);
24617 restoreLast : function(){
24619 this.last = this._last;
24624 acceptsNav : function(row, col, cm){
24625 return !cm.isHidden(col) && cm.isCellEditable(col, row);
24629 onEditorKey : function(field, e){
24630 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
24635 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
24637 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
24639 }else if(k == e.ENTER && !e.ctrlKey){
24643 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
24645 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
24647 }else if(k == e.ESC){
24651 g.startEditing(newCell[0], newCell[1]);
24657 * Ext JS Library 1.1.1
24658 * Copyright(c) 2006-2007, Ext JS, LLC.
24660 * Originally Released Under LGPL - original licence link has changed is not relivant.
24663 * <script type="text/javascript">
24667 * @class Roo.bootstrap.PagingToolbar
24668 * @extends Roo.bootstrap.NavSimplebar
24669 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
24671 * Create a new PagingToolbar
24672 * @param {Object} config The config object
24673 * @param {Roo.data.Store} store
24675 Roo.bootstrap.PagingToolbar = function(config)
24677 // old args format still supported... - xtype is prefered..
24678 // created from xtype...
24680 this.ds = config.dataSource;
24682 if (config.store && !this.ds) {
24683 this.store= Roo.factory(config.store, Roo.data);
24684 this.ds = this.store;
24685 this.ds.xmodule = this.xmodule || false;
24688 this.toolbarItems = [];
24689 if (config.items) {
24690 this.toolbarItems = config.items;
24693 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
24698 this.bind(this.ds);
24701 if (Roo.bootstrap.version == 4) {
24702 this.navgroup = new Roo.bootstrap.ButtonGroup({ cls: 'pagination' });
24704 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
24709 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
24711 * @cfg {Roo.data.Store} dataSource
24712 * The underlying data store providing the paged data
24715 * @cfg {String/HTMLElement/Element} container
24716 * container The id or element that will contain the toolbar
24719 * @cfg {Boolean} displayInfo
24720 * True to display the displayMsg (defaults to false)
24723 * @cfg {Number} pageSize
24724 * The number of records to display per page (defaults to 20)
24728 * @cfg {String} displayMsg
24729 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
24731 displayMsg : 'Displaying {0} - {1} of {2}',
24733 * @cfg {String} emptyMsg
24734 * The message to display when no records are found (defaults to "No data to display")
24736 emptyMsg : 'No data to display',
24738 * Customizable piece of the default paging text (defaults to "Page")
24741 beforePageText : "Page",
24743 * Customizable piece of the default paging text (defaults to "of %0")
24746 afterPageText : "of {0}",
24748 * Customizable piece of the default paging text (defaults to "First Page")
24751 firstText : "First Page",
24753 * Customizable piece of the default paging text (defaults to "Previous Page")
24756 prevText : "Previous Page",
24758 * Customizable piece of the default paging text (defaults to "Next Page")
24761 nextText : "Next Page",
24763 * Customizable piece of the default paging text (defaults to "Last Page")
24766 lastText : "Last Page",
24768 * Customizable piece of the default paging text (defaults to "Refresh")
24771 refreshText : "Refresh",
24775 onRender : function(ct, position)
24777 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
24778 this.navgroup.parentId = this.id;
24779 this.navgroup.onRender(this.el, null);
24780 // add the buttons to the navgroup
24782 if(this.displayInfo){
24783 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
24784 this.displayEl = this.el.select('.x-paging-info', true).first();
24785 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
24786 // this.displayEl = navel.el.select('span',true).first();
24792 Roo.each(_this.buttons, function(e){ // this might need to use render????
24793 Roo.factory(e).render(_this.el);
24797 Roo.each(_this.toolbarItems, function(e) {
24798 _this.navgroup.addItem(e);
24802 this.first = this.navgroup.addItem({
24803 tooltip: this.firstText,
24804 cls: "prev btn-outline-secondary",
24805 html : ' <i class="fa fa-step-backward"></i>',
24807 preventDefault: true,
24808 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
24811 this.prev = this.navgroup.addItem({
24812 tooltip: this.prevText,
24813 cls: "prev btn-outline-secondary",
24814 html : ' <i class="fa fa-backward"></i>',
24816 preventDefault: true,
24817 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
24819 //this.addSeparator();
24822 var field = this.navgroup.addItem( {
24824 cls : 'x-paging-position btn-outline-secondary',
24826 html : this.beforePageText +
24827 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
24828 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
24831 this.field = field.el.select('input', true).first();
24832 this.field.on("keydown", this.onPagingKeydown, this);
24833 this.field.on("focus", function(){this.dom.select();});
24836 this.afterTextEl = field.el.select('.x-paging-after',true).first();
24837 //this.field.setHeight(18);
24838 //this.addSeparator();
24839 this.next = this.navgroup.addItem({
24840 tooltip: this.nextText,
24841 cls: "next btn-outline-secondary",
24842 html : ' <i class="fa fa-forward"></i>',
24844 preventDefault: true,
24845 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
24847 this.last = this.navgroup.addItem({
24848 tooltip: this.lastText,
24849 html : ' <i class="fa fa-step-forward"></i>',
24850 cls: "next btn-outline-secondary",
24852 preventDefault: true,
24853 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
24855 //this.addSeparator();
24856 this.loading = this.navgroup.addItem({
24857 tooltip: this.refreshText,
24858 cls: "btn-outline-secondary",
24859 html : ' <i class="fa fa-refresh"></i>',
24860 preventDefault: true,
24861 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
24867 updateInfo : function(){
24868 if(this.displayEl){
24869 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
24870 var msg = count == 0 ?
24874 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
24876 this.displayEl.update(msg);
24881 onLoad : function(ds, r, o)
24883 this.cursor = o.params.start ? o.params.start : 0;
24885 var d = this.getPageData(),
24890 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
24891 this.field.dom.value = ap;
24892 this.first.setDisabled(ap == 1);
24893 this.prev.setDisabled(ap == 1);
24894 this.next.setDisabled(ap == ps);
24895 this.last.setDisabled(ap == ps);
24896 this.loading.enable();
24901 getPageData : function(){
24902 var total = this.ds.getTotalCount();
24905 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
24906 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
24911 onLoadError : function(){
24912 this.loading.enable();
24916 onPagingKeydown : function(e){
24917 var k = e.getKey();
24918 var d = this.getPageData();
24920 var v = this.field.dom.value, pageNum;
24921 if(!v || isNaN(pageNum = parseInt(v, 10))){
24922 this.field.dom.value = d.activePage;
24925 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
24926 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
24929 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))
24931 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
24932 this.field.dom.value = pageNum;
24933 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
24936 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
24938 var v = this.field.dom.value, pageNum;
24939 var increment = (e.shiftKey) ? 10 : 1;
24940 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
24943 if(!v || isNaN(pageNum = parseInt(v, 10))) {
24944 this.field.dom.value = d.activePage;
24947 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
24949 this.field.dom.value = parseInt(v, 10) + increment;
24950 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
24951 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
24958 beforeLoad : function(){
24960 this.loading.disable();
24965 onClick : function(which){
24974 ds.load({params:{start: 0, limit: this.pageSize}});
24977 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
24980 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
24983 var total = ds.getTotalCount();
24984 var extra = total % this.pageSize;
24985 var lastStart = extra ? (total - extra) : total-this.pageSize;
24986 ds.load({params:{start: lastStart, limit: this.pageSize}});
24989 ds.load({params:{start: this.cursor, limit: this.pageSize}});
24995 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
24996 * @param {Roo.data.Store} store The data store to unbind
24998 unbind : function(ds){
24999 ds.un("beforeload", this.beforeLoad, this);
25000 ds.un("load", this.onLoad, this);
25001 ds.un("loadexception", this.onLoadError, this);
25002 ds.un("remove", this.updateInfo, this);
25003 ds.un("add", this.updateInfo, this);
25004 this.ds = undefined;
25008 * Binds the paging toolbar to the specified {@link Roo.data.Store}
25009 * @param {Roo.data.Store} store The data store to bind
25011 bind : function(ds){
25012 ds.on("beforeload", this.beforeLoad, this);
25013 ds.on("load", this.onLoad, this);
25014 ds.on("loadexception", this.onLoadError, this);
25015 ds.on("remove", this.updateInfo, this);
25016 ds.on("add", this.updateInfo, this);
25027 * @class Roo.bootstrap.MessageBar
25028 * @extends Roo.bootstrap.Component
25029 * Bootstrap MessageBar class
25030 * @cfg {String} html contents of the MessageBar
25031 * @cfg {String} weight (info | success | warning | danger) default info
25032 * @cfg {String} beforeClass insert the bar before the given class
25033 * @cfg {Boolean} closable (true | false) default false
25034 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
25037 * Create a new Element
25038 * @param {Object} config The config object
25041 Roo.bootstrap.MessageBar = function(config){
25042 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
25045 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
25051 beforeClass: 'bootstrap-sticky-wrap',
25053 getAutoCreate : function(){
25057 cls: 'alert alert-dismissable alert-' + this.weight,
25062 html: this.html || ''
25068 cfg.cls += ' alert-messages-fixed';
25082 onRender : function(ct, position)
25084 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
25087 var cfg = Roo.apply({}, this.getAutoCreate());
25091 cfg.cls += ' ' + this.cls;
25094 cfg.style = this.style;
25096 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
25098 this.el.setVisibilityMode(Roo.Element.DISPLAY);
25101 this.el.select('>button.close').on('click', this.hide, this);
25107 if (!this.rendered) {
25113 this.fireEvent('show', this);
25119 if (!this.rendered) {
25125 this.fireEvent('hide', this);
25128 update : function()
25130 // var e = this.el.dom.firstChild;
25132 // if(this.closable){
25133 // e = e.nextSibling;
25136 // e.data = this.html || '';
25138 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
25154 * @class Roo.bootstrap.Graph
25155 * @extends Roo.bootstrap.Component
25156 * Bootstrap Graph class
25160 @cfg {String} graphtype bar | vbar | pie
25161 @cfg {number} g_x coodinator | centre x (pie)
25162 @cfg {number} g_y coodinator | centre y (pie)
25163 @cfg {number} g_r radius (pie)
25164 @cfg {number} g_height height of the chart (respected by all elements in the set)
25165 @cfg {number} g_width width of the chart (respected by all elements in the set)
25166 @cfg {Object} title The title of the chart
25169 -opts (object) options for the chart
25171 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
25172 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
25174 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.
25175 o stacked (boolean) whether or not to tread values as in a stacked bar chart
25177 o stretch (boolean)
25179 -opts (object) options for the pie
25182 o startAngle (number)
25183 o endAngle (number)
25187 * Create a new Input
25188 * @param {Object} config The config object
25191 Roo.bootstrap.Graph = function(config){
25192 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
25198 * The img click event for the img.
25199 * @param {Roo.EventObject} e
25205 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
25216 //g_colors: this.colors,
25223 getAutoCreate : function(){
25234 onRender : function(ct,position){
25237 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
25239 if (typeof(Raphael) == 'undefined') {
25240 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
25244 this.raphael = Raphael(this.el.dom);
25246 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25247 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25248 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
25249 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
25251 r.text(160, 10, "Single Series Chart").attr(txtattr);
25252 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
25253 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
25254 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
25256 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
25257 r.barchart(330, 10, 300, 220, data1);
25258 r.barchart(10, 250, 300, 220, data2, {stacked: true});
25259 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
25262 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25263 // r.barchart(30, 30, 560, 250, xdata, {
25264 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
25265 // axis : "0 0 1 1",
25266 // axisxlabels : xdata
25267 // //yvalues : cols,
25270 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
25272 // this.load(null,xdata,{
25273 // axis : "0 0 1 1",
25274 // axisxlabels : xdata
25279 load : function(graphtype,xdata,opts)
25281 this.raphael.clear();
25283 graphtype = this.graphtype;
25288 var r = this.raphael,
25289 fin = function () {
25290 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
25292 fout = function () {
25293 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
25295 pfin = function() {
25296 this.sector.stop();
25297 this.sector.scale(1.1, 1.1, this.cx, this.cy);
25300 this.label[0].stop();
25301 this.label[0].attr({ r: 7.5 });
25302 this.label[1].attr({ "font-weight": 800 });
25305 pfout = function() {
25306 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
25309 this.label[0].animate({ r: 5 }, 500, "bounce");
25310 this.label[1].attr({ "font-weight": 400 });
25316 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25319 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
25322 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
25323 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
25325 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
25332 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
25337 setTitle: function(o)
25342 initEvents: function() {
25345 this.el.on('click', this.onClick, this);
25349 onClick : function(e)
25351 Roo.log('img onclick');
25352 this.fireEvent('click', this, e);
25364 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25367 * @class Roo.bootstrap.dash.NumberBox
25368 * @extends Roo.bootstrap.Component
25369 * Bootstrap NumberBox class
25370 * @cfg {String} headline Box headline
25371 * @cfg {String} content Box content
25372 * @cfg {String} icon Box icon
25373 * @cfg {String} footer Footer text
25374 * @cfg {String} fhref Footer href
25377 * Create a new NumberBox
25378 * @param {Object} config The config object
25382 Roo.bootstrap.dash.NumberBox = function(config){
25383 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
25387 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
25396 getAutoCreate : function(){
25400 cls : 'small-box ',
25408 cls : 'roo-headline',
25409 html : this.headline
25413 cls : 'roo-content',
25414 html : this.content
25428 cls : 'ion ' + this.icon
25437 cls : 'small-box-footer',
25438 href : this.fhref || '#',
25442 cfg.cn.push(footer);
25449 onRender : function(ct,position){
25450 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
25457 setHeadline: function (value)
25459 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
25462 setFooter: function (value, href)
25464 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
25467 this.el.select('a.small-box-footer',true).first().attr('href', href);
25472 setContent: function (value)
25474 this.el.select('.roo-content',true).first().dom.innerHTML = value;
25477 initEvents: function()
25491 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25494 * @class Roo.bootstrap.dash.TabBox
25495 * @extends Roo.bootstrap.Component
25496 * Bootstrap TabBox class
25497 * @cfg {String} title Title of the TabBox
25498 * @cfg {String} icon Icon of the TabBox
25499 * @cfg {Boolean} showtabs (true|false) show the tabs default true
25500 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
25503 * Create a new TabBox
25504 * @param {Object} config The config object
25508 Roo.bootstrap.dash.TabBox = function(config){
25509 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
25514 * When a pane is added
25515 * @param {Roo.bootstrap.dash.TabPane} pane
25519 * @event activatepane
25520 * When a pane is activated
25521 * @param {Roo.bootstrap.dash.TabPane} pane
25523 "activatepane" : true
25531 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
25536 tabScrollable : false,
25538 getChildContainer : function()
25540 return this.el.select('.tab-content', true).first();
25543 getAutoCreate : function(){
25547 cls: 'pull-left header',
25555 cls: 'fa ' + this.icon
25561 cls: 'nav nav-tabs pull-right',
25567 if(this.tabScrollable){
25574 cls: 'nav nav-tabs pull-right',
25585 cls: 'nav-tabs-custom',
25590 cls: 'tab-content no-padding',
25598 initEvents : function()
25600 //Roo.log('add add pane handler');
25601 this.on('addpane', this.onAddPane, this);
25604 * Updates the box title
25605 * @param {String} html to set the title to.
25607 setTitle : function(value)
25609 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
25611 onAddPane : function(pane)
25613 this.panes.push(pane);
25614 //Roo.log('addpane');
25616 // tabs are rendere left to right..
25617 if(!this.showtabs){
25621 var ctr = this.el.select('.nav-tabs', true).first();
25624 var existing = ctr.select('.nav-tab',true);
25625 var qty = existing.getCount();;
25628 var tab = ctr.createChild({
25630 cls : 'nav-tab' + (qty ? '' : ' active'),
25638 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
25641 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
25643 pane.el.addClass('active');
25648 onTabClick : function(ev,un,ob,pane)
25650 //Roo.log('tab - prev default');
25651 ev.preventDefault();
25654 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
25655 pane.tab.addClass('active');
25656 //Roo.log(pane.title);
25657 this.getChildContainer().select('.tab-pane',true).removeClass('active');
25658 // technically we should have a deactivate event.. but maybe add later.
25659 // and it should not de-activate the selected tab...
25660 this.fireEvent('activatepane', pane);
25661 pane.el.addClass('active');
25662 pane.fireEvent('activate');
25667 getActivePane : function()
25670 Roo.each(this.panes, function(p) {
25671 if(p.el.hasClass('active')){
25692 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
25694 * @class Roo.bootstrap.TabPane
25695 * @extends Roo.bootstrap.Component
25696 * Bootstrap TabPane class
25697 * @cfg {Boolean} active (false | true) Default false
25698 * @cfg {String} title title of panel
25702 * Create a new TabPane
25703 * @param {Object} config The config object
25706 Roo.bootstrap.dash.TabPane = function(config){
25707 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
25713 * When a pane is activated
25714 * @param {Roo.bootstrap.dash.TabPane} pane
25721 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
25726 // the tabBox that this is attached to.
25729 getAutoCreate : function()
25737 cfg.cls += ' active';
25742 initEvents : function()
25744 //Roo.log('trigger add pane handler');
25745 this.parent().fireEvent('addpane', this)
25749 * Updates the tab title
25750 * @param {String} html to set the title to.
25752 setTitle: function(str)
25758 this.tab.select('a', true).first().dom.innerHTML = str;
25775 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25778 * @class Roo.bootstrap.menu.Menu
25779 * @extends Roo.bootstrap.Component
25780 * Bootstrap Menu class - container for Menu
25781 * @cfg {String} html Text of the menu
25782 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
25783 * @cfg {String} icon Font awesome icon
25784 * @cfg {String} pos Menu align to (top | bottom) default bottom
25788 * Create a new Menu
25789 * @param {Object} config The config object
25793 Roo.bootstrap.menu.Menu = function(config){
25794 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
25798 * @event beforeshow
25799 * Fires before this menu is displayed
25800 * @param {Roo.bootstrap.menu.Menu} this
25804 * @event beforehide
25805 * Fires before this menu is hidden
25806 * @param {Roo.bootstrap.menu.Menu} this
25811 * Fires after this menu is displayed
25812 * @param {Roo.bootstrap.menu.Menu} this
25817 * Fires after this menu is hidden
25818 * @param {Roo.bootstrap.menu.Menu} this
25823 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
25824 * @param {Roo.bootstrap.menu.Menu} this
25825 * @param {Roo.EventObject} e
25832 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
25836 weight : 'default',
25841 getChildContainer : function() {
25842 if(this.isSubMenu){
25846 return this.el.select('ul.dropdown-menu', true).first();
25849 getAutoCreate : function()
25854 cls : 'roo-menu-text',
25862 cls : 'fa ' + this.icon
25873 cls : 'dropdown-button btn btn-' + this.weight,
25878 cls : 'dropdown-toggle btn btn-' + this.weight,
25888 cls : 'dropdown-menu'
25894 if(this.pos == 'top'){
25895 cfg.cls += ' dropup';
25898 if(this.isSubMenu){
25901 cls : 'dropdown-menu'
25908 onRender : function(ct, position)
25910 this.isSubMenu = ct.hasClass('dropdown-submenu');
25912 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
25915 initEvents : function()
25917 if(this.isSubMenu){
25921 this.hidden = true;
25923 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
25924 this.triggerEl.on('click', this.onTriggerPress, this);
25926 this.buttonEl = this.el.select('button.dropdown-button', true).first();
25927 this.buttonEl.on('click', this.onClick, this);
25933 if(this.isSubMenu){
25937 return this.el.select('ul.dropdown-menu', true).first();
25940 onClick : function(e)
25942 this.fireEvent("click", this, e);
25945 onTriggerPress : function(e)
25947 if (this.isVisible()) {
25954 isVisible : function(){
25955 return !this.hidden;
25960 this.fireEvent("beforeshow", this);
25962 this.hidden = false;
25963 this.el.addClass('open');
25965 Roo.get(document).on("mouseup", this.onMouseUp, this);
25967 this.fireEvent("show", this);
25974 this.fireEvent("beforehide", this);
25976 this.hidden = true;
25977 this.el.removeClass('open');
25979 Roo.get(document).un("mouseup", this.onMouseUp);
25981 this.fireEvent("hide", this);
25984 onMouseUp : function()
25998 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26001 * @class Roo.bootstrap.menu.Item
26002 * @extends Roo.bootstrap.Component
26003 * Bootstrap MenuItem class
26004 * @cfg {Boolean} submenu (true | false) default false
26005 * @cfg {String} html text of the item
26006 * @cfg {String} href the link
26007 * @cfg {Boolean} disable (true | false) default false
26008 * @cfg {Boolean} preventDefault (true | false) default true
26009 * @cfg {String} icon Font awesome icon
26010 * @cfg {String} pos Submenu align to (left | right) default right
26014 * Create a new Item
26015 * @param {Object} config The config object
26019 Roo.bootstrap.menu.Item = function(config){
26020 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
26024 * Fires when the mouse is hovering over this menu
26025 * @param {Roo.bootstrap.menu.Item} this
26026 * @param {Roo.EventObject} e
26031 * Fires when the mouse exits this menu
26032 * @param {Roo.bootstrap.menu.Item} this
26033 * @param {Roo.EventObject} e
26039 * The raw click event for the entire grid.
26040 * @param {Roo.EventObject} e
26046 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
26051 preventDefault: true,
26056 getAutoCreate : function()
26061 cls : 'roo-menu-item-text',
26069 cls : 'fa ' + this.icon
26078 href : this.href || '#',
26085 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
26089 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
26091 if(this.pos == 'left'){
26092 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
26099 initEvents : function()
26101 this.el.on('mouseover', this.onMouseOver, this);
26102 this.el.on('mouseout', this.onMouseOut, this);
26104 this.el.select('a', true).first().on('click', this.onClick, this);
26108 onClick : function(e)
26110 if(this.preventDefault){
26111 e.preventDefault();
26114 this.fireEvent("click", this, e);
26117 onMouseOver : function(e)
26119 if(this.submenu && this.pos == 'left'){
26120 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
26123 this.fireEvent("mouseover", this, e);
26126 onMouseOut : function(e)
26128 this.fireEvent("mouseout", this, e);
26140 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
26143 * @class Roo.bootstrap.menu.Separator
26144 * @extends Roo.bootstrap.Component
26145 * Bootstrap Separator class
26148 * Create a new Separator
26149 * @param {Object} config The config object
26153 Roo.bootstrap.menu.Separator = function(config){
26154 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
26157 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
26159 getAutoCreate : function(){
26180 * @class Roo.bootstrap.Tooltip
26181 * Bootstrap Tooltip class
26182 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
26183 * to determine which dom element triggers the tooltip.
26185 * It needs to add support for additional attributes like tooltip-position
26188 * Create a new Toolti
26189 * @param {Object} config The config object
26192 Roo.bootstrap.Tooltip = function(config){
26193 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
26195 this.alignment = Roo.bootstrap.Tooltip.alignment;
26197 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
26198 this.alignment = config.alignment;
26203 Roo.apply(Roo.bootstrap.Tooltip, {
26205 * @function init initialize tooltip monitoring.
26209 currentTip : false,
26210 currentRegion : false,
26216 Roo.get(document).on('mouseover', this.enter ,this);
26217 Roo.get(document).on('mouseout', this.leave, this);
26220 this.currentTip = new Roo.bootstrap.Tooltip();
26223 enter : function(ev)
26225 var dom = ev.getTarget();
26227 //Roo.log(['enter',dom]);
26228 var el = Roo.fly(dom);
26229 if (this.currentEl) {
26231 //Roo.log(this.currentEl);
26232 //Roo.log(this.currentEl.contains(dom));
26233 if (this.currentEl == el) {
26236 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
26242 if (this.currentTip.el) {
26243 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
26247 if(!el || el.dom == document){
26253 // you can not look for children, as if el is the body.. then everythign is the child..
26254 if (!el.attr('tooltip')) { //
26255 if (!el.select("[tooltip]").elements.length) {
26258 // is the mouse over this child...?
26259 bindEl = el.select("[tooltip]").first();
26260 var xy = ev.getXY();
26261 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
26262 //Roo.log("not in region.");
26265 //Roo.log("child element over..");
26268 this.currentEl = bindEl;
26269 this.currentTip.bind(bindEl);
26270 this.currentRegion = Roo.lib.Region.getRegion(dom);
26271 this.currentTip.enter();
26274 leave : function(ev)
26276 var dom = ev.getTarget();
26277 //Roo.log(['leave',dom]);
26278 if (!this.currentEl) {
26283 if (dom != this.currentEl.dom) {
26286 var xy = ev.getXY();
26287 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
26290 // only activate leave if mouse cursor is outside... bounding box..
26295 if (this.currentTip) {
26296 this.currentTip.leave();
26298 //Roo.log('clear currentEl');
26299 this.currentEl = false;
26304 'left' : ['r-l', [-2,0], 'right'],
26305 'right' : ['l-r', [2,0], 'left'],
26306 'bottom' : ['t-b', [0,2], 'top'],
26307 'top' : [ 'b-t', [0,-2], 'bottom']
26313 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
26318 delay : null, // can be { show : 300 , hide: 500}
26322 hoverState : null, //???
26324 placement : 'bottom',
26328 getAutoCreate : function(){
26335 cls : 'tooltip-arrow'
26338 cls : 'tooltip-inner'
26345 bind : function(el)
26351 enter : function () {
26353 if (this.timeout != null) {
26354 clearTimeout(this.timeout);
26357 this.hoverState = 'in';
26358 //Roo.log("enter - show");
26359 if (!this.delay || !this.delay.show) {
26364 this.timeout = setTimeout(function () {
26365 if (_t.hoverState == 'in') {
26368 }, this.delay.show);
26372 clearTimeout(this.timeout);
26374 this.hoverState = 'out';
26375 if (!this.delay || !this.delay.hide) {
26381 this.timeout = setTimeout(function () {
26382 //Roo.log("leave - timeout");
26384 if (_t.hoverState == 'out') {
26386 Roo.bootstrap.Tooltip.currentEl = false;
26391 show : function (msg)
26394 this.render(document.body);
26397 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
26399 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
26401 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
26403 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
26405 var placement = typeof this.placement == 'function' ?
26406 this.placement.call(this, this.el, on_el) :
26409 var autoToken = /\s?auto?\s?/i;
26410 var autoPlace = autoToken.test(placement);
26412 placement = placement.replace(autoToken, '') || 'top';
26416 //this.el.setXY([0,0]);
26418 //this.el.dom.style.display='block';
26420 //this.el.appendTo(on_el);
26422 var p = this.getPosition();
26423 var box = this.el.getBox();
26429 var align = this.alignment[placement];
26431 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
26433 if(placement == 'top' || placement == 'bottom'){
26435 placement = 'right';
26438 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
26439 placement = 'left';
26442 var scroll = Roo.select('body', true).first().getScroll();
26444 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
26448 align = this.alignment[placement];
26451 this.el.alignTo(this.bindEl, align[0],align[1]);
26452 //var arrow = this.el.select('.arrow',true).first();
26453 //arrow.set(align[2],
26455 this.el.addClass(placement);
26457 this.el.addClass('in fade');
26459 this.hoverState = null;
26461 if (this.el.hasClass('fade')) {
26472 //this.el.setXY([0,0]);
26473 this.el.removeClass('in');
26489 * @class Roo.bootstrap.LocationPicker
26490 * @extends Roo.bootstrap.Component
26491 * Bootstrap LocationPicker class
26492 * @cfg {Number} latitude Position when init default 0
26493 * @cfg {Number} longitude Position when init default 0
26494 * @cfg {Number} zoom default 15
26495 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
26496 * @cfg {Boolean} mapTypeControl default false
26497 * @cfg {Boolean} disableDoubleClickZoom default false
26498 * @cfg {Boolean} scrollwheel default true
26499 * @cfg {Boolean} streetViewControl default false
26500 * @cfg {Number} radius default 0
26501 * @cfg {String} locationName
26502 * @cfg {Boolean} draggable default true
26503 * @cfg {Boolean} enableAutocomplete default false
26504 * @cfg {Boolean} enableReverseGeocode default true
26505 * @cfg {String} markerTitle
26508 * Create a new LocationPicker
26509 * @param {Object} config The config object
26513 Roo.bootstrap.LocationPicker = function(config){
26515 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
26520 * Fires when the picker initialized.
26521 * @param {Roo.bootstrap.LocationPicker} this
26522 * @param {Google Location} location
26526 * @event positionchanged
26527 * Fires when the picker position changed.
26528 * @param {Roo.bootstrap.LocationPicker} this
26529 * @param {Google Location} location
26531 positionchanged : true,
26534 * Fires when the map resize.
26535 * @param {Roo.bootstrap.LocationPicker} this
26540 * Fires when the map show.
26541 * @param {Roo.bootstrap.LocationPicker} this
26546 * Fires when the map hide.
26547 * @param {Roo.bootstrap.LocationPicker} this
26552 * Fires when click the map.
26553 * @param {Roo.bootstrap.LocationPicker} this
26554 * @param {Map event} e
26558 * @event mapRightClick
26559 * Fires when right click the map.
26560 * @param {Roo.bootstrap.LocationPicker} this
26561 * @param {Map event} e
26563 mapRightClick : true,
26565 * @event markerClick
26566 * Fires when click the marker.
26567 * @param {Roo.bootstrap.LocationPicker} this
26568 * @param {Map event} e
26570 markerClick : true,
26572 * @event markerRightClick
26573 * Fires when right click the marker.
26574 * @param {Roo.bootstrap.LocationPicker} this
26575 * @param {Map event} e
26577 markerRightClick : true,
26579 * @event OverlayViewDraw
26580 * Fires when OverlayView Draw
26581 * @param {Roo.bootstrap.LocationPicker} this
26583 OverlayViewDraw : true,
26585 * @event OverlayViewOnAdd
26586 * Fires when OverlayView Draw
26587 * @param {Roo.bootstrap.LocationPicker} this
26589 OverlayViewOnAdd : true,
26591 * @event OverlayViewOnRemove
26592 * Fires when OverlayView Draw
26593 * @param {Roo.bootstrap.LocationPicker} this
26595 OverlayViewOnRemove : true,
26597 * @event OverlayViewShow
26598 * Fires when OverlayView Draw
26599 * @param {Roo.bootstrap.LocationPicker} this
26600 * @param {Pixel} cpx
26602 OverlayViewShow : true,
26604 * @event OverlayViewHide
26605 * Fires when OverlayView Draw
26606 * @param {Roo.bootstrap.LocationPicker} this
26608 OverlayViewHide : true,
26610 * @event loadexception
26611 * Fires when load google lib failed.
26612 * @param {Roo.bootstrap.LocationPicker} this
26614 loadexception : true
26619 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
26621 gMapContext: false,
26627 mapTypeControl: false,
26628 disableDoubleClickZoom: false,
26630 streetViewControl: false,
26634 enableAutocomplete: false,
26635 enableReverseGeocode: true,
26638 getAutoCreate: function()
26643 cls: 'roo-location-picker'
26649 initEvents: function(ct, position)
26651 if(!this.el.getWidth() || this.isApplied()){
26655 this.el.setVisibilityMode(Roo.Element.DISPLAY);
26660 initial: function()
26662 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
26663 this.fireEvent('loadexception', this);
26667 if(!this.mapTypeId){
26668 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
26671 this.gMapContext = this.GMapContext();
26673 this.initOverlayView();
26675 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
26679 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
26680 _this.setPosition(_this.gMapContext.marker.position);
26683 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
26684 _this.fireEvent('mapClick', this, event);
26688 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
26689 _this.fireEvent('mapRightClick', this, event);
26693 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
26694 _this.fireEvent('markerClick', this, event);
26698 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
26699 _this.fireEvent('markerRightClick', this, event);
26703 this.setPosition(this.gMapContext.location);
26705 this.fireEvent('initial', this, this.gMapContext.location);
26708 initOverlayView: function()
26712 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
26716 _this.fireEvent('OverlayViewDraw', _this);
26721 _this.fireEvent('OverlayViewOnAdd', _this);
26724 onRemove: function()
26726 _this.fireEvent('OverlayViewOnRemove', _this);
26729 show: function(cpx)
26731 _this.fireEvent('OverlayViewShow', _this, cpx);
26736 _this.fireEvent('OverlayViewHide', _this);
26742 fromLatLngToContainerPixel: function(event)
26744 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
26747 isApplied: function()
26749 return this.getGmapContext() == false ? false : true;
26752 getGmapContext: function()
26754 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
26757 GMapContext: function()
26759 var position = new google.maps.LatLng(this.latitude, this.longitude);
26761 var _map = new google.maps.Map(this.el.dom, {
26764 mapTypeId: this.mapTypeId,
26765 mapTypeControl: this.mapTypeControl,
26766 disableDoubleClickZoom: this.disableDoubleClickZoom,
26767 scrollwheel: this.scrollwheel,
26768 streetViewControl: this.streetViewControl,
26769 locationName: this.locationName,
26770 draggable: this.draggable,
26771 enableAutocomplete: this.enableAutocomplete,
26772 enableReverseGeocode: this.enableReverseGeocode
26775 var _marker = new google.maps.Marker({
26776 position: position,
26778 title: this.markerTitle,
26779 draggable: this.draggable
26786 location: position,
26787 radius: this.radius,
26788 locationName: this.locationName,
26789 addressComponents: {
26790 formatted_address: null,
26791 addressLine1: null,
26792 addressLine2: null,
26794 streetNumber: null,
26798 stateOrProvince: null
26801 domContainer: this.el.dom,
26802 geodecoder: new google.maps.Geocoder()
26806 drawCircle: function(center, radius, options)
26808 if (this.gMapContext.circle != null) {
26809 this.gMapContext.circle.setMap(null);
26813 options = Roo.apply({}, options, {
26814 strokeColor: "#0000FF",
26815 strokeOpacity: .35,
26817 fillColor: "#0000FF",
26821 options.map = this.gMapContext.map;
26822 options.radius = radius;
26823 options.center = center;
26824 this.gMapContext.circle = new google.maps.Circle(options);
26825 return this.gMapContext.circle;
26831 setPosition: function(location)
26833 this.gMapContext.location = location;
26834 this.gMapContext.marker.setPosition(location);
26835 this.gMapContext.map.panTo(location);
26836 this.drawCircle(location, this.gMapContext.radius, {});
26840 if (this.gMapContext.settings.enableReverseGeocode) {
26841 this.gMapContext.geodecoder.geocode({
26842 latLng: this.gMapContext.location
26843 }, function(results, status) {
26845 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
26846 _this.gMapContext.locationName = results[0].formatted_address;
26847 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
26849 _this.fireEvent('positionchanged', this, location);
26856 this.fireEvent('positionchanged', this, location);
26861 google.maps.event.trigger(this.gMapContext.map, "resize");
26863 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
26865 this.fireEvent('resize', this);
26868 setPositionByLatLng: function(latitude, longitude)
26870 this.setPosition(new google.maps.LatLng(latitude, longitude));
26873 getCurrentPosition: function()
26876 latitude: this.gMapContext.location.lat(),
26877 longitude: this.gMapContext.location.lng()
26881 getAddressName: function()
26883 return this.gMapContext.locationName;
26886 getAddressComponents: function()
26888 return this.gMapContext.addressComponents;
26891 address_component_from_google_geocode: function(address_components)
26895 for (var i = 0; i < address_components.length; i++) {
26896 var component = address_components[i];
26897 if (component.types.indexOf("postal_code") >= 0) {
26898 result.postalCode = component.short_name;
26899 } else if (component.types.indexOf("street_number") >= 0) {
26900 result.streetNumber = component.short_name;
26901 } else if (component.types.indexOf("route") >= 0) {
26902 result.streetName = component.short_name;
26903 } else if (component.types.indexOf("neighborhood") >= 0) {
26904 result.city = component.short_name;
26905 } else if (component.types.indexOf("locality") >= 0) {
26906 result.city = component.short_name;
26907 } else if (component.types.indexOf("sublocality") >= 0) {
26908 result.district = component.short_name;
26909 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
26910 result.stateOrProvince = component.short_name;
26911 } else if (component.types.indexOf("country") >= 0) {
26912 result.country = component.short_name;
26916 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
26917 result.addressLine2 = "";
26921 setZoomLevel: function(zoom)
26923 this.gMapContext.map.setZoom(zoom);
26936 this.fireEvent('show', this);
26947 this.fireEvent('hide', this);
26952 Roo.apply(Roo.bootstrap.LocationPicker, {
26954 OverlayView : function(map, options)
26956 options = options || {};
26970 * @class Roo.bootstrap.Alert
26971 * @extends Roo.bootstrap.Component
26972 * Bootstrap Alert class
26973 * @cfg {String} title The title of alert
26974 * @cfg {String} html The content of alert
26975 * @cfg {String} weight ( success | info | warning | danger )
26976 * @cfg {String} faicon font-awesomeicon
26979 * Create a new alert
26980 * @param {Object} config The config object
26984 Roo.bootstrap.Alert = function(config){
26985 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
26989 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
26996 getAutoCreate : function()
27005 cls : 'roo-alert-icon'
27010 cls : 'roo-alert-title',
27015 cls : 'roo-alert-text',
27022 cfg.cn[0].cls += ' fa ' + this.faicon;
27026 cfg.cls += ' alert-' + this.weight;
27032 initEvents: function()
27034 this.el.setVisibilityMode(Roo.Element.DISPLAY);
27037 setTitle : function(str)
27039 this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
27042 setText : function(str)
27044 this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
27047 setWeight : function(weight)
27050 this.el.select('.alert',true).first().removeClass('alert-' + this.weight);
27053 this.weight = weight;
27055 this.el.select('.alert',true).first().addClass('alert-' + this.weight);
27058 setIcon : function(icon)
27061 this.el.select('.roo-alert-icon',true).first().removeClass(['fa', 'fa-' + this.faicon]);
27064 this.faicon = icon;
27066 this.el.select('.roo-alert-icon',true).first().addClass(['fa', 'fa-' + this.faicon]);
27087 * @class Roo.bootstrap.UploadCropbox
27088 * @extends Roo.bootstrap.Component
27089 * Bootstrap UploadCropbox class
27090 * @cfg {String} emptyText show when image has been loaded
27091 * @cfg {String} rotateNotify show when image too small to rotate
27092 * @cfg {Number} errorTimeout default 3000
27093 * @cfg {Number} minWidth default 300
27094 * @cfg {Number} minHeight default 300
27095 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
27096 * @cfg {Boolean} isDocument (true|false) default false
27097 * @cfg {String} url action url
27098 * @cfg {String} paramName default 'imageUpload'
27099 * @cfg {String} method default POST
27100 * @cfg {Boolean} loadMask (true|false) default true
27101 * @cfg {Boolean} loadingText default 'Loading...'
27104 * Create a new UploadCropbox
27105 * @param {Object} config The config object
27108 Roo.bootstrap.UploadCropbox = function(config){
27109 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
27113 * @event beforeselectfile
27114 * Fire before select file
27115 * @param {Roo.bootstrap.UploadCropbox} this
27117 "beforeselectfile" : true,
27120 * Fire after initEvent
27121 * @param {Roo.bootstrap.UploadCropbox} this
27126 * Fire after initEvent
27127 * @param {Roo.bootstrap.UploadCropbox} this
27128 * @param {String} data
27133 * Fire when preparing the file data
27134 * @param {Roo.bootstrap.UploadCropbox} this
27135 * @param {Object} file
27140 * Fire when get exception
27141 * @param {Roo.bootstrap.UploadCropbox} this
27142 * @param {XMLHttpRequest} xhr
27144 "exception" : true,
27146 * @event beforeloadcanvas
27147 * Fire before load the canvas
27148 * @param {Roo.bootstrap.UploadCropbox} this
27149 * @param {String} src
27151 "beforeloadcanvas" : true,
27154 * Fire when trash image
27155 * @param {Roo.bootstrap.UploadCropbox} this
27160 * Fire when download the image
27161 * @param {Roo.bootstrap.UploadCropbox} this
27165 * @event footerbuttonclick
27166 * Fire when footerbuttonclick
27167 * @param {Roo.bootstrap.UploadCropbox} this
27168 * @param {String} type
27170 "footerbuttonclick" : true,
27174 * @param {Roo.bootstrap.UploadCropbox} this
27179 * Fire when rotate the image
27180 * @param {Roo.bootstrap.UploadCropbox} this
27181 * @param {String} pos
27186 * Fire when inspect the file
27187 * @param {Roo.bootstrap.UploadCropbox} this
27188 * @param {Object} file
27193 * Fire when xhr upload the file
27194 * @param {Roo.bootstrap.UploadCropbox} this
27195 * @param {Object} data
27200 * Fire when arrange the file data
27201 * @param {Roo.bootstrap.UploadCropbox} this
27202 * @param {Object} formData
27207 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
27210 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
27212 emptyText : 'Click to upload image',
27213 rotateNotify : 'Image is too small to rotate',
27214 errorTimeout : 3000,
27228 cropType : 'image/jpeg',
27230 canvasLoaded : false,
27231 isDocument : false,
27233 paramName : 'imageUpload',
27235 loadingText : 'Loading...',
27238 getAutoCreate : function()
27242 cls : 'roo-upload-cropbox',
27246 cls : 'roo-upload-cropbox-selector',
27251 cls : 'roo-upload-cropbox-body',
27252 style : 'cursor:pointer',
27256 cls : 'roo-upload-cropbox-preview'
27260 cls : 'roo-upload-cropbox-thumb'
27264 cls : 'roo-upload-cropbox-empty-notify',
27265 html : this.emptyText
27269 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
27270 html : this.rotateNotify
27276 cls : 'roo-upload-cropbox-footer',
27279 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
27289 onRender : function(ct, position)
27291 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
27293 if (this.buttons.length) {
27295 Roo.each(this.buttons, function(bb) {
27297 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
27299 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
27305 this.maskEl = this.el;
27309 initEvents : function()
27311 this.urlAPI = (window.createObjectURL && window) ||
27312 (window.URL && URL.revokeObjectURL && URL) ||
27313 (window.webkitURL && webkitURL);
27315 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
27316 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27318 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
27319 this.selectorEl.hide();
27321 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
27322 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27324 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
27325 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27326 this.thumbEl.hide();
27328 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
27329 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27331 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
27332 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27333 this.errorEl.hide();
27335 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
27336 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
27337 this.footerEl.hide();
27339 this.setThumbBoxSize();
27345 this.fireEvent('initial', this);
27352 window.addEventListener("resize", function() { _this.resize(); } );
27354 this.bodyEl.on('click', this.beforeSelectFile, this);
27357 this.bodyEl.on('touchstart', this.onTouchStart, this);
27358 this.bodyEl.on('touchmove', this.onTouchMove, this);
27359 this.bodyEl.on('touchend', this.onTouchEnd, this);
27363 this.bodyEl.on('mousedown', this.onMouseDown, this);
27364 this.bodyEl.on('mousemove', this.onMouseMove, this);
27365 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
27366 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
27367 Roo.get(document).on('mouseup', this.onMouseUp, this);
27370 this.selectorEl.on('change', this.onFileSelected, this);
27376 this.baseScale = 1;
27378 this.baseRotate = 1;
27379 this.dragable = false;
27380 this.pinching = false;
27383 this.cropData = false;
27384 this.notifyEl.dom.innerHTML = this.emptyText;
27386 this.selectorEl.dom.value = '';
27390 resize : function()
27392 if(this.fireEvent('resize', this) != false){
27393 this.setThumbBoxPosition();
27394 this.setCanvasPosition();
27398 onFooterButtonClick : function(e, el, o, type)
27401 case 'rotate-left' :
27402 this.onRotateLeft(e);
27404 case 'rotate-right' :
27405 this.onRotateRight(e);
27408 this.beforeSelectFile(e);
27423 this.fireEvent('footerbuttonclick', this, type);
27426 beforeSelectFile : function(e)
27428 e.preventDefault();
27430 if(this.fireEvent('beforeselectfile', this) != false){
27431 this.selectorEl.dom.click();
27435 onFileSelected : function(e)
27437 e.preventDefault();
27439 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
27443 var file = this.selectorEl.dom.files[0];
27445 if(this.fireEvent('inspect', this, file) != false){
27446 this.prepare(file);
27451 trash : function(e)
27453 this.fireEvent('trash', this);
27456 download : function(e)
27458 this.fireEvent('download', this);
27461 loadCanvas : function(src)
27463 if(this.fireEvent('beforeloadcanvas', this, src) != false){
27467 this.imageEl = document.createElement('img');
27471 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
27473 this.imageEl.src = src;
27477 onLoadCanvas : function()
27479 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
27480 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
27482 this.bodyEl.un('click', this.beforeSelectFile, this);
27484 this.notifyEl.hide();
27485 this.thumbEl.show();
27486 this.footerEl.show();
27488 this.baseRotateLevel();
27490 if(this.isDocument){
27491 this.setThumbBoxSize();
27494 this.setThumbBoxPosition();
27496 this.baseScaleLevel();
27502 this.canvasLoaded = true;
27505 this.maskEl.unmask();
27510 setCanvasPosition : function()
27512 if(!this.canvasEl){
27516 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
27517 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
27519 this.previewEl.setLeft(pw);
27520 this.previewEl.setTop(ph);
27524 onMouseDown : function(e)
27528 this.dragable = true;
27529 this.pinching = false;
27531 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
27532 this.dragable = false;
27536 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27537 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27541 onMouseMove : function(e)
27545 if(!this.canvasLoaded){
27549 if (!this.dragable){
27553 var minX = Math.ceil(this.thumbEl.getLeft(true));
27554 var minY = Math.ceil(this.thumbEl.getTop(true));
27556 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
27557 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
27559 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27560 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27562 x = x - this.mouseX;
27563 y = y - this.mouseY;
27565 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
27566 var bgY = Math.ceil(y + this.previewEl.getTop(true));
27568 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
27569 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
27571 this.previewEl.setLeft(bgX);
27572 this.previewEl.setTop(bgY);
27574 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
27575 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
27578 onMouseUp : function(e)
27582 this.dragable = false;
27585 onMouseWheel : function(e)
27589 this.startScale = this.scale;
27591 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
27593 if(!this.zoomable()){
27594 this.scale = this.startScale;
27603 zoomable : function()
27605 var minScale = this.thumbEl.getWidth() / this.minWidth;
27607 if(this.minWidth < this.minHeight){
27608 minScale = this.thumbEl.getHeight() / this.minHeight;
27611 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
27612 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
27616 (this.rotate == 0 || this.rotate == 180) &&
27618 width > this.imageEl.OriginWidth ||
27619 height > this.imageEl.OriginHeight ||
27620 (width < this.minWidth && height < this.minHeight)
27628 (this.rotate == 90 || this.rotate == 270) &&
27630 width > this.imageEl.OriginWidth ||
27631 height > this.imageEl.OriginHeight ||
27632 (width < this.minHeight && height < this.minWidth)
27639 !this.isDocument &&
27640 (this.rotate == 0 || this.rotate == 180) &&
27642 width < this.minWidth ||
27643 width > this.imageEl.OriginWidth ||
27644 height < this.minHeight ||
27645 height > this.imageEl.OriginHeight
27652 !this.isDocument &&
27653 (this.rotate == 90 || this.rotate == 270) &&
27655 width < this.minHeight ||
27656 width > this.imageEl.OriginWidth ||
27657 height < this.minWidth ||
27658 height > this.imageEl.OriginHeight
27668 onRotateLeft : function(e)
27670 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27672 var minScale = this.thumbEl.getWidth() / this.minWidth;
27674 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27675 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27677 this.startScale = this.scale;
27679 while (this.getScaleLevel() < minScale){
27681 this.scale = this.scale + 1;
27683 if(!this.zoomable()){
27688 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27689 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27694 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27701 this.scale = this.startScale;
27703 this.onRotateFail();
27708 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
27710 if(this.isDocument){
27711 this.setThumbBoxSize();
27712 this.setThumbBoxPosition();
27713 this.setCanvasPosition();
27718 this.fireEvent('rotate', this, 'left');
27722 onRotateRight : function(e)
27724 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
27726 var minScale = this.thumbEl.getWidth() / this.minWidth;
27728 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
27729 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
27731 this.startScale = this.scale;
27733 while (this.getScaleLevel() < minScale){
27735 this.scale = this.scale + 1;
27737 if(!this.zoomable()){
27742 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
27743 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
27748 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27755 this.scale = this.startScale;
27757 this.onRotateFail();
27762 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
27764 if(this.isDocument){
27765 this.setThumbBoxSize();
27766 this.setThumbBoxPosition();
27767 this.setCanvasPosition();
27772 this.fireEvent('rotate', this, 'right');
27775 onRotateFail : function()
27777 this.errorEl.show(true);
27781 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
27786 this.previewEl.dom.innerHTML = '';
27788 var canvasEl = document.createElement("canvas");
27790 var contextEl = canvasEl.getContext("2d");
27792 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27793 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27794 var center = this.imageEl.OriginWidth / 2;
27796 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
27797 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27798 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27799 center = this.imageEl.OriginHeight / 2;
27802 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
27804 contextEl.translate(center, center);
27805 contextEl.rotate(this.rotate * Math.PI / 180);
27807 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
27809 this.canvasEl = document.createElement("canvas");
27811 this.contextEl = this.canvasEl.getContext("2d");
27813 switch (this.rotate) {
27816 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27817 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27819 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27824 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27825 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27827 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27828 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);
27832 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27837 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
27838 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
27840 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27841 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);
27845 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);
27850 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
27851 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
27853 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27854 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
27858 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);
27865 this.previewEl.appendChild(this.canvasEl);
27867 this.setCanvasPosition();
27872 if(!this.canvasLoaded){
27876 var imageCanvas = document.createElement("canvas");
27878 var imageContext = imageCanvas.getContext("2d");
27880 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
27881 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
27883 var center = imageCanvas.width / 2;
27885 imageContext.translate(center, center);
27887 imageContext.rotate(this.rotate * Math.PI / 180);
27889 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
27891 var canvas = document.createElement("canvas");
27893 var context = canvas.getContext("2d");
27895 canvas.width = this.minWidth;
27896 canvas.height = this.minHeight;
27898 switch (this.rotate) {
27901 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
27902 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
27904 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27905 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27907 var targetWidth = this.minWidth - 2 * x;
27908 var targetHeight = this.minHeight - 2 * y;
27912 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27913 scale = targetWidth / width;
27916 if(x > 0 && y == 0){
27917 scale = targetHeight / height;
27920 if(x > 0 && y > 0){
27921 scale = targetWidth / width;
27923 if(width < height){
27924 scale = targetHeight / height;
27928 context.scale(scale, scale);
27930 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27931 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27933 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27934 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27936 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27941 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
27942 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
27944 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27945 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27947 var targetWidth = this.minWidth - 2 * x;
27948 var targetHeight = this.minHeight - 2 * y;
27952 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27953 scale = targetWidth / width;
27956 if(x > 0 && y == 0){
27957 scale = targetHeight / height;
27960 if(x > 0 && y > 0){
27961 scale = targetWidth / width;
27963 if(width < height){
27964 scale = targetHeight / height;
27968 context.scale(scale, scale);
27970 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
27971 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
27973 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
27974 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
27976 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
27978 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
27983 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
27984 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
27986 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
27987 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
27989 var targetWidth = this.minWidth - 2 * x;
27990 var targetHeight = this.minHeight - 2 * y;
27994 if((x == 0 && y == 0) || (x == 0 && y > 0)){
27995 scale = targetWidth / width;
27998 if(x > 0 && y == 0){
27999 scale = targetHeight / height;
28002 if(x > 0 && y > 0){
28003 scale = targetWidth / width;
28005 if(width < height){
28006 scale = targetHeight / height;
28010 context.scale(scale, scale);
28012 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28013 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28015 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28016 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28018 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28019 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
28021 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28026 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
28027 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
28029 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
28030 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
28032 var targetWidth = this.minWidth - 2 * x;
28033 var targetHeight = this.minHeight - 2 * y;
28037 if((x == 0 && y == 0) || (x == 0 && y > 0)){
28038 scale = targetWidth / width;
28041 if(x > 0 && y == 0){
28042 scale = targetHeight / height;
28045 if(x > 0 && y > 0){
28046 scale = targetWidth / width;
28048 if(width < height){
28049 scale = targetHeight / height;
28053 context.scale(scale, scale);
28055 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
28056 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
28058 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
28059 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
28061 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
28063 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
28070 this.cropData = canvas.toDataURL(this.cropType);
28072 if(this.fireEvent('crop', this, this.cropData) !== false){
28073 this.process(this.file, this.cropData);
28080 setThumbBoxSize : function()
28084 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
28085 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
28086 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
28088 this.minWidth = width;
28089 this.minHeight = height;
28091 if(this.rotate == 90 || this.rotate == 270){
28092 this.minWidth = height;
28093 this.minHeight = width;
28098 width = Math.ceil(this.minWidth * height / this.minHeight);
28100 if(this.minWidth > this.minHeight){
28102 height = Math.ceil(this.minHeight * width / this.minWidth);
28105 this.thumbEl.setStyle({
28106 width : width + 'px',
28107 height : height + 'px'
28114 setThumbBoxPosition : function()
28116 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
28117 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
28119 this.thumbEl.setLeft(x);
28120 this.thumbEl.setTop(y);
28124 baseRotateLevel : function()
28126 this.baseRotate = 1;
28129 typeof(this.exif) != 'undefined' &&
28130 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
28131 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
28133 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
28136 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
28140 baseScaleLevel : function()
28144 if(this.isDocument){
28146 if(this.baseRotate == 6 || this.baseRotate == 8){
28148 height = this.thumbEl.getHeight();
28149 this.baseScale = height / this.imageEl.OriginWidth;
28151 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
28152 width = this.thumbEl.getWidth();
28153 this.baseScale = width / this.imageEl.OriginHeight;
28159 height = this.thumbEl.getHeight();
28160 this.baseScale = height / this.imageEl.OriginHeight;
28162 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
28163 width = this.thumbEl.getWidth();
28164 this.baseScale = width / this.imageEl.OriginWidth;
28170 if(this.baseRotate == 6 || this.baseRotate == 8){
28172 width = this.thumbEl.getHeight();
28173 this.baseScale = width / this.imageEl.OriginHeight;
28175 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
28176 height = this.thumbEl.getWidth();
28177 this.baseScale = height / this.imageEl.OriginHeight;
28180 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28181 height = this.thumbEl.getWidth();
28182 this.baseScale = height / this.imageEl.OriginHeight;
28184 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
28185 width = this.thumbEl.getHeight();
28186 this.baseScale = width / this.imageEl.OriginWidth;
28193 width = this.thumbEl.getWidth();
28194 this.baseScale = width / this.imageEl.OriginWidth;
28196 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
28197 height = this.thumbEl.getHeight();
28198 this.baseScale = height / this.imageEl.OriginHeight;
28201 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
28203 height = this.thumbEl.getHeight();
28204 this.baseScale = height / this.imageEl.OriginHeight;
28206 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
28207 width = this.thumbEl.getWidth();
28208 this.baseScale = width / this.imageEl.OriginWidth;
28216 getScaleLevel : function()
28218 return this.baseScale * Math.pow(1.1, this.scale);
28221 onTouchStart : function(e)
28223 if(!this.canvasLoaded){
28224 this.beforeSelectFile(e);
28228 var touches = e.browserEvent.touches;
28234 if(touches.length == 1){
28235 this.onMouseDown(e);
28239 if(touches.length != 2){
28245 for(var i = 0, finger; finger = touches[i]; i++){
28246 coords.push(finger.pageX, finger.pageY);
28249 var x = Math.pow(coords[0] - coords[2], 2);
28250 var y = Math.pow(coords[1] - coords[3], 2);
28252 this.startDistance = Math.sqrt(x + y);
28254 this.startScale = this.scale;
28256 this.pinching = true;
28257 this.dragable = false;
28261 onTouchMove : function(e)
28263 if(!this.pinching && !this.dragable){
28267 var touches = e.browserEvent.touches;
28274 this.onMouseMove(e);
28280 for(var i = 0, finger; finger = touches[i]; i++){
28281 coords.push(finger.pageX, finger.pageY);
28284 var x = Math.pow(coords[0] - coords[2], 2);
28285 var y = Math.pow(coords[1] - coords[3], 2);
28287 this.endDistance = Math.sqrt(x + y);
28289 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
28291 if(!this.zoomable()){
28292 this.scale = this.startScale;
28300 onTouchEnd : function(e)
28302 this.pinching = false;
28303 this.dragable = false;
28307 process : function(file, crop)
28310 this.maskEl.mask(this.loadingText);
28313 this.xhr = new XMLHttpRequest();
28315 file.xhr = this.xhr;
28317 this.xhr.open(this.method, this.url, true);
28320 "Accept": "application/json",
28321 "Cache-Control": "no-cache",
28322 "X-Requested-With": "XMLHttpRequest"
28325 for (var headerName in headers) {
28326 var headerValue = headers[headerName];
28328 this.xhr.setRequestHeader(headerName, headerValue);
28334 this.xhr.onload = function()
28336 _this.xhrOnLoad(_this.xhr);
28339 this.xhr.onerror = function()
28341 _this.xhrOnError(_this.xhr);
28344 var formData = new FormData();
28346 formData.append('returnHTML', 'NO');
28349 formData.append('crop', crop);
28352 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
28353 formData.append(this.paramName, file, file.name);
28356 if(typeof(file.filename) != 'undefined'){
28357 formData.append('filename', file.filename);
28360 if(typeof(file.mimetype) != 'undefined'){
28361 formData.append('mimetype', file.mimetype);
28364 if(this.fireEvent('arrange', this, formData) != false){
28365 this.xhr.send(formData);
28369 xhrOnLoad : function(xhr)
28372 this.maskEl.unmask();
28375 if (xhr.readyState !== 4) {
28376 this.fireEvent('exception', this, xhr);
28380 var response = Roo.decode(xhr.responseText);
28382 if(!response.success){
28383 this.fireEvent('exception', this, xhr);
28387 var response = Roo.decode(xhr.responseText);
28389 this.fireEvent('upload', this, response);
28393 xhrOnError : function()
28396 this.maskEl.unmask();
28399 Roo.log('xhr on error');
28401 var response = Roo.decode(xhr.responseText);
28407 prepare : function(file)
28410 this.maskEl.mask(this.loadingText);
28416 if(typeof(file) === 'string'){
28417 this.loadCanvas(file);
28421 if(!file || !this.urlAPI){
28426 this.cropType = file.type;
28430 if(this.fireEvent('prepare', this, this.file) != false){
28432 var reader = new FileReader();
28434 reader.onload = function (e) {
28435 if (e.target.error) {
28436 Roo.log(e.target.error);
28440 var buffer = e.target.result,
28441 dataView = new DataView(buffer),
28443 maxOffset = dataView.byteLength - 4,
28447 if (dataView.getUint16(0) === 0xffd8) {
28448 while (offset < maxOffset) {
28449 markerBytes = dataView.getUint16(offset);
28451 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
28452 markerLength = dataView.getUint16(offset + 2) + 2;
28453 if (offset + markerLength > dataView.byteLength) {
28454 Roo.log('Invalid meta data: Invalid segment size.');
28458 if(markerBytes == 0xffe1){
28459 _this.parseExifData(
28466 offset += markerLength;
28476 var url = _this.urlAPI.createObjectURL(_this.file);
28478 _this.loadCanvas(url);
28483 reader.readAsArrayBuffer(this.file);
28489 parseExifData : function(dataView, offset, length)
28491 var tiffOffset = offset + 10,
28495 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28496 // No Exif data, might be XMP data instead
28500 // Check for the ASCII code for "Exif" (0x45786966):
28501 if (dataView.getUint32(offset + 4) !== 0x45786966) {
28502 // No Exif data, might be XMP data instead
28505 if (tiffOffset + 8 > dataView.byteLength) {
28506 Roo.log('Invalid Exif data: Invalid segment size.');
28509 // Check for the two null bytes:
28510 if (dataView.getUint16(offset + 8) !== 0x0000) {
28511 Roo.log('Invalid Exif data: Missing byte alignment offset.');
28514 // Check the byte alignment:
28515 switch (dataView.getUint16(tiffOffset)) {
28517 littleEndian = true;
28520 littleEndian = false;
28523 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
28526 // Check for the TIFF tag marker (0x002A):
28527 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
28528 Roo.log('Invalid Exif data: Missing TIFF marker.');
28531 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
28532 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
28534 this.parseExifTags(
28537 tiffOffset + dirOffset,
28542 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
28547 if (dirOffset + 6 > dataView.byteLength) {
28548 Roo.log('Invalid Exif data: Invalid directory offset.');
28551 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
28552 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
28553 if (dirEndOffset + 4 > dataView.byteLength) {
28554 Roo.log('Invalid Exif data: Invalid directory size.');
28557 for (i = 0; i < tagsNumber; i += 1) {
28561 dirOffset + 2 + 12 * i, // tag offset
28565 // Return the offset to the next directory:
28566 return dataView.getUint32(dirEndOffset, littleEndian);
28569 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
28571 var tag = dataView.getUint16(offset, littleEndian);
28573 this.exif[tag] = this.getExifValue(
28577 dataView.getUint16(offset + 2, littleEndian), // tag type
28578 dataView.getUint32(offset + 4, littleEndian), // tag length
28583 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
28585 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
28594 Roo.log('Invalid Exif data: Invalid tag type.');
28598 tagSize = tagType.size * length;
28599 // Determine if the value is contained in the dataOffset bytes,
28600 // or if the value at the dataOffset is a pointer to the actual data:
28601 dataOffset = tagSize > 4 ?
28602 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
28603 if (dataOffset + tagSize > dataView.byteLength) {
28604 Roo.log('Invalid Exif data: Invalid data offset.');
28607 if (length === 1) {
28608 return tagType.getValue(dataView, dataOffset, littleEndian);
28611 for (i = 0; i < length; i += 1) {
28612 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
28615 if (tagType.ascii) {
28617 // Concatenate the chars:
28618 for (i = 0; i < values.length; i += 1) {
28620 // Ignore the terminating NULL byte(s):
28621 if (c === '\u0000') {
28633 Roo.apply(Roo.bootstrap.UploadCropbox, {
28635 'Orientation': 0x0112
28639 1: 0, //'top-left',
28641 3: 180, //'bottom-right',
28642 // 4: 'bottom-left',
28644 6: 90, //'right-top',
28645 // 7: 'right-bottom',
28646 8: 270 //'left-bottom'
28650 // byte, 8-bit unsigned int:
28652 getValue: function (dataView, dataOffset) {
28653 return dataView.getUint8(dataOffset);
28657 // ascii, 8-bit byte:
28659 getValue: function (dataView, dataOffset) {
28660 return String.fromCharCode(dataView.getUint8(dataOffset));
28665 // short, 16 bit int:
28667 getValue: function (dataView, dataOffset, littleEndian) {
28668 return dataView.getUint16(dataOffset, littleEndian);
28672 // long, 32 bit int:
28674 getValue: function (dataView, dataOffset, littleEndian) {
28675 return dataView.getUint32(dataOffset, littleEndian);
28679 // rational = two long values, first is numerator, second is denominator:
28681 getValue: function (dataView, dataOffset, littleEndian) {
28682 return dataView.getUint32(dataOffset, littleEndian) /
28683 dataView.getUint32(dataOffset + 4, littleEndian);
28687 // slong, 32 bit signed int:
28689 getValue: function (dataView, dataOffset, littleEndian) {
28690 return dataView.getInt32(dataOffset, littleEndian);
28694 // srational, two slongs, first is numerator, second is denominator:
28696 getValue: function (dataView, dataOffset, littleEndian) {
28697 return dataView.getInt32(dataOffset, littleEndian) /
28698 dataView.getInt32(dataOffset + 4, littleEndian);
28708 cls : 'btn-group roo-upload-cropbox-rotate-left',
28709 action : 'rotate-left',
28713 cls : 'btn btn-default',
28714 html : '<i class="fa fa-undo"></i>'
28720 cls : 'btn-group roo-upload-cropbox-picture',
28721 action : 'picture',
28725 cls : 'btn btn-default',
28726 html : '<i class="fa fa-picture-o"></i>'
28732 cls : 'btn-group roo-upload-cropbox-rotate-right',
28733 action : 'rotate-right',
28737 cls : 'btn btn-default',
28738 html : '<i class="fa fa-repeat"></i>'
28746 cls : 'btn-group roo-upload-cropbox-rotate-left',
28747 action : 'rotate-left',
28751 cls : 'btn btn-default',
28752 html : '<i class="fa fa-undo"></i>'
28758 cls : 'btn-group roo-upload-cropbox-download',
28759 action : 'download',
28763 cls : 'btn btn-default',
28764 html : '<i class="fa fa-download"></i>'
28770 cls : 'btn-group roo-upload-cropbox-crop',
28775 cls : 'btn btn-default',
28776 html : '<i class="fa fa-crop"></i>'
28782 cls : 'btn-group roo-upload-cropbox-trash',
28787 cls : 'btn btn-default',
28788 html : '<i class="fa fa-trash"></i>'
28794 cls : 'btn-group roo-upload-cropbox-rotate-right',
28795 action : 'rotate-right',
28799 cls : 'btn btn-default',
28800 html : '<i class="fa fa-repeat"></i>'
28808 cls : 'btn-group roo-upload-cropbox-rotate-left',
28809 action : 'rotate-left',
28813 cls : 'btn btn-default',
28814 html : '<i class="fa fa-undo"></i>'
28820 cls : 'btn-group roo-upload-cropbox-rotate-right',
28821 action : 'rotate-right',
28825 cls : 'btn btn-default',
28826 html : '<i class="fa fa-repeat"></i>'
28839 * @class Roo.bootstrap.DocumentManager
28840 * @extends Roo.bootstrap.Component
28841 * Bootstrap DocumentManager class
28842 * @cfg {String} paramName default 'imageUpload'
28843 * @cfg {String} toolTipName default 'filename'
28844 * @cfg {String} method default POST
28845 * @cfg {String} url action url
28846 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
28847 * @cfg {Boolean} multiple multiple upload default true
28848 * @cfg {Number} thumbSize default 300
28849 * @cfg {String} fieldLabel
28850 * @cfg {Number} labelWidth default 4
28851 * @cfg {String} labelAlign (left|top) default left
28852 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
28853 * @cfg {Number} labellg set the width of label (1-12)
28854 * @cfg {Number} labelmd set the width of label (1-12)
28855 * @cfg {Number} labelsm set the width of label (1-12)
28856 * @cfg {Number} labelxs set the width of label (1-12)
28859 * Create a new DocumentManager
28860 * @param {Object} config The config object
28863 Roo.bootstrap.DocumentManager = function(config){
28864 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
28867 this.delegates = [];
28872 * Fire when initial the DocumentManager
28873 * @param {Roo.bootstrap.DocumentManager} this
28878 * inspect selected file
28879 * @param {Roo.bootstrap.DocumentManager} this
28880 * @param {File} file
28885 * Fire when xhr load exception
28886 * @param {Roo.bootstrap.DocumentManager} this
28887 * @param {XMLHttpRequest} xhr
28889 "exception" : true,
28891 * @event afterupload
28892 * Fire when xhr load exception
28893 * @param {Roo.bootstrap.DocumentManager} this
28894 * @param {XMLHttpRequest} xhr
28896 "afterupload" : true,
28899 * prepare the form data
28900 * @param {Roo.bootstrap.DocumentManager} this
28901 * @param {Object} formData
28906 * Fire when remove the file
28907 * @param {Roo.bootstrap.DocumentManager} this
28908 * @param {Object} file
28913 * Fire after refresh the file
28914 * @param {Roo.bootstrap.DocumentManager} this
28919 * Fire after click the image
28920 * @param {Roo.bootstrap.DocumentManager} this
28921 * @param {Object} file
28926 * Fire when upload a image and editable set to true
28927 * @param {Roo.bootstrap.DocumentManager} this
28928 * @param {Object} file
28932 * @event beforeselectfile
28933 * Fire before select file
28934 * @param {Roo.bootstrap.DocumentManager} this
28936 "beforeselectfile" : true,
28939 * Fire before process file
28940 * @param {Roo.bootstrap.DocumentManager} this
28941 * @param {Object} file
28945 * @event previewrendered
28946 * Fire when preview rendered
28947 * @param {Roo.bootstrap.DocumentManager} this
28948 * @param {Object} file
28950 "previewrendered" : true,
28953 "previewResize" : true
28958 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
28967 paramName : 'imageUpload',
28968 toolTipName : 'filename',
28971 labelAlign : 'left',
28981 getAutoCreate : function()
28983 var managerWidget = {
28985 cls : 'roo-document-manager',
28989 cls : 'roo-document-manager-selector',
28994 cls : 'roo-document-manager-uploader',
28998 cls : 'roo-document-manager-upload-btn',
28999 html : '<i class="fa fa-plus"></i>'
29010 cls : 'column col-md-12',
29015 if(this.fieldLabel.length){
29020 cls : 'column col-md-12',
29021 html : this.fieldLabel
29025 cls : 'column col-md-12',
29030 if(this.labelAlign == 'left'){
29035 html : this.fieldLabel
29044 if(this.labelWidth > 12){
29045 content[0].style = "width: " + this.labelWidth + 'px';
29048 if(this.labelWidth < 13 && this.labelmd == 0){
29049 this.labelmd = this.labelWidth;
29052 if(this.labellg > 0){
29053 content[0].cls += ' col-lg-' + this.labellg;
29054 content[1].cls += ' col-lg-' + (12 - this.labellg);
29057 if(this.labelmd > 0){
29058 content[0].cls += ' col-md-' + this.labelmd;
29059 content[1].cls += ' col-md-' + (12 - this.labelmd);
29062 if(this.labelsm > 0){
29063 content[0].cls += ' col-sm-' + this.labelsm;
29064 content[1].cls += ' col-sm-' + (12 - this.labelsm);
29067 if(this.labelxs > 0){
29068 content[0].cls += ' col-xs-' + this.labelxs;
29069 content[1].cls += ' col-xs-' + (12 - this.labelxs);
29077 cls : 'row clearfix',
29085 initEvents : function()
29087 this.managerEl = this.el.select('.roo-document-manager', true).first();
29088 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29090 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
29091 this.selectorEl.hide();
29094 this.selectorEl.attr('multiple', 'multiple');
29097 this.selectorEl.on('change', this.onFileSelected, this);
29099 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
29100 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29102 this.uploader.on('click', this.onUploaderClick, this);
29104 this.renderProgressDialog();
29108 window.addEventListener("resize", function() { _this.refresh(); } );
29110 this.fireEvent('initial', this);
29113 renderProgressDialog : function()
29117 this.progressDialog = new Roo.bootstrap.Modal({
29118 cls : 'roo-document-manager-progress-dialog',
29119 allow_close : false,
29129 btnclick : function() {
29130 _this.uploadCancel();
29136 this.progressDialog.render(Roo.get(document.body));
29138 this.progress = new Roo.bootstrap.Progress({
29139 cls : 'roo-document-manager-progress',
29144 this.progress.render(this.progressDialog.getChildContainer());
29146 this.progressBar = new Roo.bootstrap.ProgressBar({
29147 cls : 'roo-document-manager-progress-bar',
29150 aria_valuemax : 12,
29154 this.progressBar.render(this.progress.getChildContainer());
29157 onUploaderClick : function(e)
29159 e.preventDefault();
29161 if(this.fireEvent('beforeselectfile', this) != false){
29162 this.selectorEl.dom.click();
29167 onFileSelected : function(e)
29169 e.preventDefault();
29171 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
29175 Roo.each(this.selectorEl.dom.files, function(file){
29176 if(this.fireEvent('inspect', this, file) != false){
29177 this.files.push(file);
29187 this.selectorEl.dom.value = '';
29189 if(!this.files || !this.files.length){
29193 if(this.boxes > 0 && this.files.length > this.boxes){
29194 this.files = this.files.slice(0, this.boxes);
29197 this.uploader.show();
29199 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29200 this.uploader.hide();
29209 Roo.each(this.files, function(file){
29211 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29212 var f = this.renderPreview(file);
29217 if(file.type.indexOf('image') != -1){
29218 this.delegates.push(
29220 _this.process(file);
29221 }).createDelegate(this)
29229 _this.process(file);
29230 }).createDelegate(this)
29235 this.files = files;
29237 this.delegates = this.delegates.concat(docs);
29239 if(!this.delegates.length){
29244 this.progressBar.aria_valuemax = this.delegates.length;
29251 arrange : function()
29253 if(!this.delegates.length){
29254 this.progressDialog.hide();
29259 var delegate = this.delegates.shift();
29261 this.progressDialog.show();
29263 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
29265 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
29270 refresh : function()
29272 this.uploader.show();
29274 if(this.boxes > 0 && this.files.length > this.boxes - 1){
29275 this.uploader.hide();
29278 Roo.isTouch ? this.closable(false) : this.closable(true);
29280 this.fireEvent('refresh', this);
29283 onRemove : function(e, el, o)
29285 e.preventDefault();
29287 this.fireEvent('remove', this, o);
29291 remove : function(o)
29295 Roo.each(this.files, function(file){
29296 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
29305 this.files = files;
29312 Roo.each(this.files, function(file){
29317 file.target.remove();
29326 onClick : function(e, el, o)
29328 e.preventDefault();
29330 this.fireEvent('click', this, o);
29334 closable : function(closable)
29336 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
29338 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
29350 xhrOnLoad : function(xhr)
29352 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29356 if (xhr.readyState !== 4) {
29358 this.fireEvent('exception', this, xhr);
29362 var response = Roo.decode(xhr.responseText);
29364 if(!response.success){
29366 this.fireEvent('exception', this, xhr);
29370 var file = this.renderPreview(response.data);
29372 this.files.push(file);
29376 this.fireEvent('afterupload', this, xhr);
29380 xhrOnError : function(xhr)
29382 Roo.log('xhr on error');
29384 var response = Roo.decode(xhr.responseText);
29391 process : function(file)
29393 if(this.fireEvent('process', this, file) !== false){
29394 if(this.editable && file.type.indexOf('image') != -1){
29395 this.fireEvent('edit', this, file);
29399 this.uploadStart(file, false);
29406 uploadStart : function(file, crop)
29408 this.xhr = new XMLHttpRequest();
29410 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
29415 file.xhr = this.xhr;
29417 this.managerEl.createChild({
29419 cls : 'roo-document-manager-loading',
29423 tooltip : file.name,
29424 cls : 'roo-document-manager-thumb',
29425 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29431 this.xhr.open(this.method, this.url, true);
29434 "Accept": "application/json",
29435 "Cache-Control": "no-cache",
29436 "X-Requested-With": "XMLHttpRequest"
29439 for (var headerName in headers) {
29440 var headerValue = headers[headerName];
29442 this.xhr.setRequestHeader(headerName, headerValue);
29448 this.xhr.onload = function()
29450 _this.xhrOnLoad(_this.xhr);
29453 this.xhr.onerror = function()
29455 _this.xhrOnError(_this.xhr);
29458 var formData = new FormData();
29460 formData.append('returnHTML', 'NO');
29463 formData.append('crop', crop);
29466 formData.append(this.paramName, file, file.name);
29473 if(this.fireEvent('prepare', this, formData, options) != false){
29475 if(options.manually){
29479 this.xhr.send(formData);
29483 this.uploadCancel();
29486 uploadCancel : function()
29492 this.delegates = [];
29494 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
29501 renderPreview : function(file)
29503 if(typeof(file.target) != 'undefined' && file.target){
29507 var img_src = encodeURI(baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename);
29509 var previewEl = this.managerEl.createChild({
29511 cls : 'roo-document-manager-preview',
29515 tooltip : file[this.toolTipName],
29516 cls : 'roo-document-manager-thumb',
29517 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + img_src + '">'
29522 html : '<i class="fa fa-times-circle"></i>'
29527 var close = previewEl.select('button.close', true).first();
29529 close.on('click', this.onRemove, this, file);
29531 file.target = previewEl;
29533 var image = previewEl.select('img', true).first();
29537 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
29539 image.on('click', this.onClick, this, file);
29541 this.fireEvent('previewrendered', this, file);
29547 onPreviewLoad : function(file, image)
29549 if(typeof(file.target) == 'undefined' || !file.target){
29553 var width = image.dom.naturalWidth || image.dom.width;
29554 var height = image.dom.naturalHeight || image.dom.height;
29556 if(!this.previewResize) {
29560 if(width > height){
29561 file.target.addClass('wide');
29565 file.target.addClass('tall');
29570 uploadFromSource : function(file, crop)
29572 this.xhr = new XMLHttpRequest();
29574 this.managerEl.createChild({
29576 cls : 'roo-document-manager-loading',
29580 tooltip : file.name,
29581 cls : 'roo-document-manager-thumb',
29582 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
29588 this.xhr.open(this.method, this.url, true);
29591 "Accept": "application/json",
29592 "Cache-Control": "no-cache",
29593 "X-Requested-With": "XMLHttpRequest"
29596 for (var headerName in headers) {
29597 var headerValue = headers[headerName];
29599 this.xhr.setRequestHeader(headerName, headerValue);
29605 this.xhr.onload = function()
29607 _this.xhrOnLoad(_this.xhr);
29610 this.xhr.onerror = function()
29612 _this.xhrOnError(_this.xhr);
29615 var formData = new FormData();
29617 formData.append('returnHTML', 'NO');
29619 formData.append('crop', crop);
29621 if(typeof(file.filename) != 'undefined'){
29622 formData.append('filename', file.filename);
29625 if(typeof(file.mimetype) != 'undefined'){
29626 formData.append('mimetype', file.mimetype);
29631 if(this.fireEvent('prepare', this, formData) != false){
29632 this.xhr.send(formData);
29642 * @class Roo.bootstrap.DocumentViewer
29643 * @extends Roo.bootstrap.Component
29644 * Bootstrap DocumentViewer class
29645 * @cfg {Boolean} showDownload (true|false) show download button (default true)
29646 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
29649 * Create a new DocumentViewer
29650 * @param {Object} config The config object
29653 Roo.bootstrap.DocumentViewer = function(config){
29654 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
29659 * Fire after initEvent
29660 * @param {Roo.bootstrap.DocumentViewer} this
29666 * @param {Roo.bootstrap.DocumentViewer} this
29671 * Fire after download button
29672 * @param {Roo.bootstrap.DocumentViewer} this
29677 * Fire after trash button
29678 * @param {Roo.bootstrap.DocumentViewer} this
29685 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
29687 showDownload : true,
29691 getAutoCreate : function()
29695 cls : 'roo-document-viewer',
29699 cls : 'roo-document-viewer-body',
29703 cls : 'roo-document-viewer-thumb',
29707 cls : 'roo-document-viewer-image'
29715 cls : 'roo-document-viewer-footer',
29718 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
29722 cls : 'btn-group roo-document-viewer-download',
29726 cls : 'btn btn-default',
29727 html : '<i class="fa fa-download"></i>'
29733 cls : 'btn-group roo-document-viewer-trash',
29737 cls : 'btn btn-default',
29738 html : '<i class="fa fa-trash"></i>'
29751 initEvents : function()
29753 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
29754 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
29756 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
29757 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
29759 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
29760 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
29762 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
29763 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
29765 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
29766 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
29768 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
29769 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
29771 this.bodyEl.on('click', this.onClick, this);
29772 this.downloadBtn.on('click', this.onDownload, this);
29773 this.trashBtn.on('click', this.onTrash, this);
29775 this.downloadBtn.hide();
29776 this.trashBtn.hide();
29778 if(this.showDownload){
29779 this.downloadBtn.show();
29782 if(this.showTrash){
29783 this.trashBtn.show();
29786 if(!this.showDownload && !this.showTrash) {
29787 this.footerEl.hide();
29792 initial : function()
29794 this.fireEvent('initial', this);
29798 onClick : function(e)
29800 e.preventDefault();
29802 this.fireEvent('click', this);
29805 onDownload : function(e)
29807 e.preventDefault();
29809 this.fireEvent('download', this);
29812 onTrash : function(e)
29814 e.preventDefault();
29816 this.fireEvent('trash', this);
29828 * @class Roo.bootstrap.NavProgressBar
29829 * @extends Roo.bootstrap.Component
29830 * Bootstrap NavProgressBar class
29833 * Create a new nav progress bar
29834 * @param {Object} config The config object
29837 Roo.bootstrap.NavProgressBar = function(config){
29838 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
29840 this.bullets = this.bullets || [];
29842 // Roo.bootstrap.NavProgressBar.register(this);
29846 * Fires when the active item changes
29847 * @param {Roo.bootstrap.NavProgressBar} this
29848 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
29849 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
29856 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
29861 getAutoCreate : function()
29863 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
29867 cls : 'roo-navigation-bar-group',
29871 cls : 'roo-navigation-top-bar'
29875 cls : 'roo-navigation-bullets-bar',
29879 cls : 'roo-navigation-bar'
29886 cls : 'roo-navigation-bottom-bar'
29896 initEvents: function()
29901 onRender : function(ct, position)
29903 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
29905 if(this.bullets.length){
29906 Roo.each(this.bullets, function(b){
29915 addItem : function(cfg)
29917 var item = new Roo.bootstrap.NavProgressItem(cfg);
29919 item.parentId = this.id;
29920 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
29923 var top = new Roo.bootstrap.Element({
29925 cls : 'roo-navigation-bar-text'
29928 var bottom = new Roo.bootstrap.Element({
29930 cls : 'roo-navigation-bar-text'
29933 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
29934 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
29936 var topText = new Roo.bootstrap.Element({
29938 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
29941 var bottomText = new Roo.bootstrap.Element({
29943 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
29946 topText.onRender(top.el, null);
29947 bottomText.onRender(bottom.el, null);
29950 item.bottomEl = bottom;
29953 this.barItems.push(item);
29958 getActive : function()
29960 var active = false;
29962 Roo.each(this.barItems, function(v){
29964 if (!v.isActive()) {
29976 setActiveItem : function(item)
29980 Roo.each(this.barItems, function(v){
29981 if (v.rid == item.rid) {
29985 if (v.isActive()) {
29986 v.setActive(false);
29991 item.setActive(true);
29993 this.fireEvent('changed', this, item, prev);
29996 getBarItem: function(rid)
30000 Roo.each(this.barItems, function(e) {
30001 if (e.rid != rid) {
30012 indexOfItem : function(item)
30016 Roo.each(this.barItems, function(v, i){
30018 if (v.rid != item.rid) {
30029 setActiveNext : function()
30031 var i = this.indexOfItem(this.getActive());
30033 if (i > this.barItems.length) {
30037 this.setActiveItem(this.barItems[i+1]);
30040 setActivePrev : function()
30042 var i = this.indexOfItem(this.getActive());
30048 this.setActiveItem(this.barItems[i-1]);
30051 format : function()
30053 if(!this.barItems.length){
30057 var width = 100 / this.barItems.length;
30059 Roo.each(this.barItems, function(i){
30060 i.el.setStyle('width', width + '%');
30061 i.topEl.el.setStyle('width', width + '%');
30062 i.bottomEl.el.setStyle('width', width + '%');
30071 * Nav Progress Item
30076 * @class Roo.bootstrap.NavProgressItem
30077 * @extends Roo.bootstrap.Component
30078 * Bootstrap NavProgressItem class
30079 * @cfg {String} rid the reference id
30080 * @cfg {Boolean} active (true|false) Is item active default false
30081 * @cfg {Boolean} disabled (true|false) Is item active default false
30082 * @cfg {String} html
30083 * @cfg {String} position (top|bottom) text position default bottom
30084 * @cfg {String} icon show icon instead of number
30087 * Create a new NavProgressItem
30088 * @param {Object} config The config object
30090 Roo.bootstrap.NavProgressItem = function(config){
30091 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
30096 * The raw click event for the entire grid.
30097 * @param {Roo.bootstrap.NavProgressItem} this
30098 * @param {Roo.EventObject} e
30105 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
30111 position : 'bottom',
30114 getAutoCreate : function()
30116 var iconCls = 'roo-navigation-bar-item-icon';
30118 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
30122 cls: 'roo-navigation-bar-item',
30132 cfg.cls += ' active';
30135 cfg.cls += ' disabled';
30141 disable : function()
30143 this.setDisabled(true);
30146 enable : function()
30148 this.setDisabled(false);
30151 initEvents: function()
30153 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
30155 this.iconEl.on('click', this.onClick, this);
30158 onClick : function(e)
30160 e.preventDefault();
30166 if(this.fireEvent('click', this, e) === false){
30170 this.parent().setActiveItem(this);
30173 isActive: function ()
30175 return this.active;
30178 setActive : function(state)
30180 if(this.active == state){
30184 this.active = state;
30187 this.el.addClass('active');
30191 this.el.removeClass('active');
30196 setDisabled : function(state)
30198 if(this.disabled == state){
30202 this.disabled = state;
30205 this.el.addClass('disabled');
30209 this.el.removeClass('disabled');
30212 tooltipEl : function()
30214 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
30227 * @class Roo.bootstrap.FieldLabel
30228 * @extends Roo.bootstrap.Component
30229 * Bootstrap FieldLabel class
30230 * @cfg {String} html contents of the element
30231 * @cfg {String} tag tag of the element default label
30232 * @cfg {String} cls class of the element
30233 * @cfg {String} target label target
30234 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
30235 * @cfg {String} invalidClass default "text-warning"
30236 * @cfg {String} validClass default "text-success"
30237 * @cfg {String} iconTooltip default "This field is required"
30238 * @cfg {String} indicatorpos (left|right) default left
30241 * Create a new FieldLabel
30242 * @param {Object} config The config object
30245 Roo.bootstrap.FieldLabel = function(config){
30246 Roo.bootstrap.Element.superclass.constructor.call(this, config);
30251 * Fires after the field has been marked as invalid.
30252 * @param {Roo.form.FieldLabel} this
30253 * @param {String} msg The validation message
30258 * Fires after the field has been validated with no errors.
30259 * @param {Roo.form.FieldLabel} this
30265 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
30272 invalidClass : 'has-warning',
30273 validClass : 'has-success',
30274 iconTooltip : 'This field is required',
30275 indicatorpos : 'left',
30277 getAutoCreate : function(){
30280 if (!this.allowBlank) {
30286 cls : 'roo-bootstrap-field-label ' + this.cls,
30291 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star ' + cls,
30292 tooltip : this.iconTooltip
30301 if(this.indicatorpos == 'right'){
30304 cls : 'roo-bootstrap-field-label ' + this.cls,
30313 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star '+ cls,
30314 tooltip : this.iconTooltip
30323 initEvents: function()
30325 Roo.bootstrap.Element.superclass.initEvents.call(this);
30327 this.indicator = this.indicatorEl();
30329 if(this.indicator){
30330 this.indicator.removeClass('visible');
30331 this.indicator.addClass('invisible');
30334 Roo.bootstrap.FieldLabel.register(this);
30337 indicatorEl : function()
30339 var indicator = this.el.select('i.roo-required-indicator',true).first();
30350 * Mark this field as valid
30352 markValid : function()
30354 if(this.indicator){
30355 this.indicator.removeClass('visible');
30356 this.indicator.addClass('invisible');
30359 this.el.removeClass(this.invalidClass);
30361 this.el.addClass(this.validClass);
30363 this.fireEvent('valid', this);
30367 * Mark this field as invalid
30368 * @param {String} msg The validation message
30370 markInvalid : function(msg)
30372 if(this.indicator){
30373 this.indicator.removeClass('invisible');
30374 this.indicator.addClass('visible');
30377 this.el.removeClass(this.validClass);
30379 this.el.addClass(this.invalidClass);
30381 this.fireEvent('invalid', this, msg);
30387 Roo.apply(Roo.bootstrap.FieldLabel, {
30392 * register a FieldLabel Group
30393 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
30395 register : function(label)
30397 if(this.groups.hasOwnProperty(label.target)){
30401 this.groups[label.target] = label;
30405 * fetch a FieldLabel Group based on the target
30406 * @param {string} target
30407 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
30409 get: function(target) {
30410 if (typeof(this.groups[target]) == 'undefined') {
30414 return this.groups[target] ;
30423 * page DateSplitField.
30429 * @class Roo.bootstrap.DateSplitField
30430 * @extends Roo.bootstrap.Component
30431 * Bootstrap DateSplitField class
30432 * @cfg {string} fieldLabel - the label associated
30433 * @cfg {Number} labelWidth set the width of label (0-12)
30434 * @cfg {String} labelAlign (top|left)
30435 * @cfg {Boolean} dayAllowBlank (true|false) default false
30436 * @cfg {Boolean} monthAllowBlank (true|false) default false
30437 * @cfg {Boolean} yearAllowBlank (true|false) default false
30438 * @cfg {string} dayPlaceholder
30439 * @cfg {string} monthPlaceholder
30440 * @cfg {string} yearPlaceholder
30441 * @cfg {string} dayFormat default 'd'
30442 * @cfg {string} monthFormat default 'm'
30443 * @cfg {string} yearFormat default 'Y'
30444 * @cfg {Number} labellg set the width of label (1-12)
30445 * @cfg {Number} labelmd set the width of label (1-12)
30446 * @cfg {Number} labelsm set the width of label (1-12)
30447 * @cfg {Number} labelxs set the width of label (1-12)
30451 * Create a new DateSplitField
30452 * @param {Object} config The config object
30455 Roo.bootstrap.DateSplitField = function(config){
30456 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
30462 * getting the data of years
30463 * @param {Roo.bootstrap.DateSplitField} this
30464 * @param {Object} years
30469 * getting the data of days
30470 * @param {Roo.bootstrap.DateSplitField} this
30471 * @param {Object} days
30476 * Fires after the field has been marked as invalid.
30477 * @param {Roo.form.Field} this
30478 * @param {String} msg The validation message
30483 * Fires after the field has been validated with no errors.
30484 * @param {Roo.form.Field} this
30490 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
30493 labelAlign : 'top',
30495 dayAllowBlank : false,
30496 monthAllowBlank : false,
30497 yearAllowBlank : false,
30498 dayPlaceholder : '',
30499 monthPlaceholder : '',
30500 yearPlaceholder : '',
30504 isFormField : true,
30510 getAutoCreate : function()
30514 cls : 'row roo-date-split-field-group',
30519 cls : 'form-hidden-field roo-date-split-field-group-value',
30525 var labelCls = 'col-md-12';
30526 var contentCls = 'col-md-4';
30528 if(this.fieldLabel){
30532 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
30536 html : this.fieldLabel
30541 if(this.labelAlign == 'left'){
30543 if(this.labelWidth > 12){
30544 label.style = "width: " + this.labelWidth + 'px';
30547 if(this.labelWidth < 13 && this.labelmd == 0){
30548 this.labelmd = this.labelWidth;
30551 if(this.labellg > 0){
30552 labelCls = ' col-lg-' + this.labellg;
30553 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
30556 if(this.labelmd > 0){
30557 labelCls = ' col-md-' + this.labelmd;
30558 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
30561 if(this.labelsm > 0){
30562 labelCls = ' col-sm-' + this.labelsm;
30563 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
30566 if(this.labelxs > 0){
30567 labelCls = ' col-xs-' + this.labelxs;
30568 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
30572 label.cls += ' ' + labelCls;
30574 cfg.cn.push(label);
30577 Roo.each(['day', 'month', 'year'], function(t){
30580 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
30587 inputEl: function ()
30589 return this.el.select('.roo-date-split-field-group-value', true).first();
30592 onRender : function(ct, position)
30596 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
30598 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
30600 this.dayField = new Roo.bootstrap.ComboBox({
30601 allowBlank : this.dayAllowBlank,
30602 alwaysQuery : true,
30603 displayField : 'value',
30606 forceSelection : true,
30608 placeholder : this.dayPlaceholder,
30609 selectOnFocus : true,
30610 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30611 triggerAction : 'all',
30613 valueField : 'value',
30614 store : new Roo.data.SimpleStore({
30615 data : (function() {
30617 _this.fireEvent('days', _this, days);
30620 fields : [ 'value' ]
30623 select : function (_self, record, index)
30625 _this.setValue(_this.getValue());
30630 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
30632 this.monthField = new Roo.bootstrap.MonthField({
30633 after : '<i class=\"fa fa-calendar\"></i>',
30634 allowBlank : this.monthAllowBlank,
30635 placeholder : this.monthPlaceholder,
30638 render : function (_self)
30640 this.el.select('span.input-group-addon', true).first().on('click', function(e){
30641 e.preventDefault();
30645 select : function (_self, oldvalue, newvalue)
30647 _this.setValue(_this.getValue());
30652 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
30654 this.yearField = new Roo.bootstrap.ComboBox({
30655 allowBlank : this.yearAllowBlank,
30656 alwaysQuery : true,
30657 displayField : 'value',
30660 forceSelection : true,
30662 placeholder : this.yearPlaceholder,
30663 selectOnFocus : true,
30664 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
30665 triggerAction : 'all',
30667 valueField : 'value',
30668 store : new Roo.data.SimpleStore({
30669 data : (function() {
30671 _this.fireEvent('years', _this, years);
30674 fields : [ 'value' ]
30677 select : function (_self, record, index)
30679 _this.setValue(_this.getValue());
30684 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
30687 setValue : function(v, format)
30689 this.inputEl.dom.value = v;
30691 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
30693 var d = Date.parseDate(v, f);
30700 this.setDay(d.format(this.dayFormat));
30701 this.setMonth(d.format(this.monthFormat));
30702 this.setYear(d.format(this.yearFormat));
30709 setDay : function(v)
30711 this.dayField.setValue(v);
30712 this.inputEl.dom.value = this.getValue();
30717 setMonth : function(v)
30719 this.monthField.setValue(v, true);
30720 this.inputEl.dom.value = this.getValue();
30725 setYear : function(v)
30727 this.yearField.setValue(v);
30728 this.inputEl.dom.value = this.getValue();
30733 getDay : function()
30735 return this.dayField.getValue();
30738 getMonth : function()
30740 return this.monthField.getValue();
30743 getYear : function()
30745 return this.yearField.getValue();
30748 getValue : function()
30750 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
30752 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
30762 this.inputEl.dom.value = '';
30767 validate : function()
30769 var d = this.dayField.validate();
30770 var m = this.monthField.validate();
30771 var y = this.yearField.validate();
30776 (!this.dayAllowBlank && !d) ||
30777 (!this.monthAllowBlank && !m) ||
30778 (!this.yearAllowBlank && !y)
30783 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
30792 this.markInvalid();
30797 markValid : function()
30800 var label = this.el.select('label', true).first();
30801 var icon = this.el.select('i.fa-star', true).first();
30807 this.fireEvent('valid', this);
30811 * Mark this field as invalid
30812 * @param {String} msg The validation message
30814 markInvalid : function(msg)
30817 var label = this.el.select('label', true).first();
30818 var icon = this.el.select('i.fa-star', true).first();
30820 if(label && !icon){
30821 this.el.select('.roo-date-split-field-label', true).createChild({
30823 cls : 'text-danger fa fa-lg fa-star',
30824 tooltip : 'This field is required',
30825 style : 'margin-right:5px;'
30829 this.fireEvent('invalid', this, msg);
30832 clearInvalid : function()
30834 var label = this.el.select('label', true).first();
30835 var icon = this.el.select('i.fa-star', true).first();
30841 this.fireEvent('valid', this);
30844 getName: function()
30854 * http://masonry.desandro.com
30856 * The idea is to render all the bricks based on vertical width...
30858 * The original code extends 'outlayer' - we might need to use that....
30864 * @class Roo.bootstrap.LayoutMasonry
30865 * @extends Roo.bootstrap.Component
30866 * Bootstrap Layout Masonry class
30869 * Create a new Element
30870 * @param {Object} config The config object
30873 Roo.bootstrap.LayoutMasonry = function(config){
30875 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
30879 Roo.bootstrap.LayoutMasonry.register(this);
30885 * Fire after layout the items
30886 * @param {Roo.bootstrap.LayoutMasonry} this
30887 * @param {Roo.EventObject} e
30894 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
30897 * @cfg {Boolean} isLayoutInstant = no animation?
30899 isLayoutInstant : false, // needed?
30902 * @cfg {Number} boxWidth width of the columns
30907 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
30912 * @cfg {Number} padWidth padding below box..
30917 * @cfg {Number} gutter gutter width..
30922 * @cfg {Number} maxCols maximum number of columns
30928 * @cfg {Boolean} isAutoInitial defalut true
30930 isAutoInitial : true,
30935 * @cfg {Boolean} isHorizontal defalut false
30937 isHorizontal : false,
30939 currentSize : null,
30945 bricks: null, //CompositeElement
30949 _isLayoutInited : false,
30951 // isAlternative : false, // only use for vertical layout...
30954 * @cfg {Number} alternativePadWidth padding below box..
30956 alternativePadWidth : 50,
30958 selectedBrick : [],
30960 getAutoCreate : function(){
30962 var cfg = Roo.apply({}, Roo.bootstrap.LayoutMasonry.superclass.getAutoCreate.call(this));
30966 cls: 'blog-masonary-wrapper ' + this.cls,
30968 cls : 'mas-boxes masonary'
30975 getChildContainer: function( )
30977 if (this.boxesEl) {
30978 return this.boxesEl;
30981 this.boxesEl = this.el.select('.mas-boxes').first();
30983 return this.boxesEl;
30987 initEvents : function()
30991 if(this.isAutoInitial){
30992 Roo.log('hook children rendered');
30993 this.on('childrenrendered', function() {
30994 Roo.log('children rendered');
31000 initial : function()
31002 this.selectedBrick = [];
31004 this.currentSize = this.el.getBox(true);
31006 Roo.EventManager.onWindowResize(this.resize, this);
31008 if(!this.isAutoInitial){
31016 //this.layout.defer(500,this);
31020 resize : function()
31022 var cs = this.el.getBox(true);
31025 this.currentSize.width == cs.width &&
31026 this.currentSize.x == cs.x &&
31027 this.currentSize.height == cs.height &&
31028 this.currentSize.y == cs.y
31030 Roo.log("no change in with or X or Y");
31034 this.currentSize = cs;
31040 layout : function()
31042 this._resetLayout();
31044 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
31046 this.layoutItems( isInstant );
31048 this._isLayoutInited = true;
31050 this.fireEvent('layout', this);
31054 _resetLayout : function()
31056 if(this.isHorizontal){
31057 this.horizontalMeasureColumns();
31061 this.verticalMeasureColumns();
31065 verticalMeasureColumns : function()
31067 this.getContainerWidth();
31069 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31070 // this.colWidth = Math.floor(this.containerWidth * 0.8);
31074 var boxWidth = this.boxWidth + this.padWidth;
31076 if(this.containerWidth < this.boxWidth){
31077 boxWidth = this.containerWidth
31080 var containerWidth = this.containerWidth;
31082 var cols = Math.floor(containerWidth / boxWidth);
31084 this.cols = Math.max( cols, 1 );
31086 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
31088 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
31090 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
31092 this.colWidth = boxWidth + avail - this.padWidth;
31094 this.unitWidth = Math.round((this.colWidth - (this.gutter * 2)) / 3);
31095 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
31098 horizontalMeasureColumns : function()
31100 this.getContainerWidth();
31102 var boxWidth = this.boxWidth;
31104 if(this.containerWidth < boxWidth){
31105 boxWidth = this.containerWidth;
31108 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
31110 this.el.setHeight(boxWidth);
31114 getContainerWidth : function()
31116 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
31119 layoutItems : function( isInstant )
31121 Roo.log(this.bricks);
31123 var items = Roo.apply([], this.bricks);
31125 if(this.isHorizontal){
31126 this._horizontalLayoutItems( items , isInstant );
31130 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
31131 // this._verticalAlternativeLayoutItems( items , isInstant );
31135 this._verticalLayoutItems( items , isInstant );
31139 _verticalLayoutItems : function ( items , isInstant)
31141 if ( !items || !items.length ) {
31146 ['xs', 'xs', 'xs', 'tall'],
31147 ['xs', 'xs', 'tall'],
31148 ['xs', 'xs', 'sm'],
31149 ['xs', 'xs', 'xs'],
31155 ['sm', 'xs', 'xs'],
31159 ['tall', 'xs', 'xs', 'xs'],
31160 ['tall', 'xs', 'xs'],
31172 Roo.each(items, function(item, k){
31174 switch (item.size) {
31175 // these layouts take up a full box,
31186 boxes.push([item]);
31209 var filterPattern = function(box, length)
31217 var pattern = box.slice(0, length);
31221 Roo.each(pattern, function(i){
31222 format.push(i.size);
31225 Roo.each(standard, function(s){
31227 if(String(s) != String(format)){
31236 if(!match && length == 1){
31241 filterPattern(box, length - 1);
31245 queue.push(pattern);
31247 box = box.slice(length, box.length);
31249 filterPattern(box, 4);
31255 Roo.each(boxes, function(box, k){
31261 if(box.length == 1){
31266 filterPattern(box, 4);
31270 this._processVerticalLayoutQueue( queue, isInstant );
31274 // _verticalAlternativeLayoutItems : function( items , isInstant )
31276 // if ( !items || !items.length ) {
31280 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
31284 _horizontalLayoutItems : function ( items , isInstant)
31286 if ( !items || !items.length || items.length < 3) {
31292 var eItems = items.slice(0, 3);
31294 items = items.slice(3, items.length);
31297 ['xs', 'xs', 'xs', 'wide'],
31298 ['xs', 'xs', 'wide'],
31299 ['xs', 'xs', 'sm'],
31300 ['xs', 'xs', 'xs'],
31306 ['sm', 'xs', 'xs'],
31310 ['wide', 'xs', 'xs', 'xs'],
31311 ['wide', 'xs', 'xs'],
31324 Roo.each(items, function(item, k){
31326 switch (item.size) {
31337 boxes.push([item]);
31361 var filterPattern = function(box, length)
31369 var pattern = box.slice(0, length);
31373 Roo.each(pattern, function(i){
31374 format.push(i.size);
31377 Roo.each(standard, function(s){
31379 if(String(s) != String(format)){
31388 if(!match && length == 1){
31393 filterPattern(box, length - 1);
31397 queue.push(pattern);
31399 box = box.slice(length, box.length);
31401 filterPattern(box, 4);
31407 Roo.each(boxes, function(box, k){
31413 if(box.length == 1){
31418 filterPattern(box, 4);
31425 var pos = this.el.getBox(true);
31429 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31431 var hit_end = false;
31433 Roo.each(queue, function(box){
31437 Roo.each(box, function(b){
31439 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31449 Roo.each(box, function(b){
31451 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31454 mx = Math.max(mx, b.x);
31458 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
31462 Roo.each(box, function(b){
31464 b.el.setVisibilityMode(Roo.Element.DISPLAY);
31478 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
31481 /** Sets position of item in DOM
31482 * @param {Element} item
31483 * @param {Number} x - horizontal position
31484 * @param {Number} y - vertical position
31485 * @param {Boolean} isInstant - disables transitions
31487 _processVerticalLayoutQueue : function( queue, isInstant )
31489 var pos = this.el.getBox(true);
31494 for (var i = 0; i < this.cols; i++){
31498 Roo.each(queue, function(box, k){
31500 var col = k % this.cols;
31502 Roo.each(box, function(b,kk){
31504 b.el.position('absolute');
31506 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31507 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31509 if(b.size == 'md-left' || b.size == 'md-right'){
31510 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31511 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31514 b.el.setWidth(width);
31515 b.el.setHeight(height);
31517 b.el.select('iframe',true).setSize(width,height);
31521 for (var i = 0; i < this.cols; i++){
31523 if(maxY[i] < maxY[col]){
31528 col = Math.min(col, i);
31532 x = pos.x + col * (this.colWidth + this.padWidth);
31536 var positions = [];
31538 switch (box.length){
31540 positions = this.getVerticalOneBoxColPositions(x, y, box);
31543 positions = this.getVerticalTwoBoxColPositions(x, y, box);
31546 positions = this.getVerticalThreeBoxColPositions(x, y, box);
31549 positions = this.getVerticalFourBoxColPositions(x, y, box);
31555 Roo.each(box, function(b,kk){
31557 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31559 var sz = b.el.getSize();
31561 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
31569 for (var i = 0; i < this.cols; i++){
31570 mY = Math.max(mY, maxY[i]);
31573 this.el.setHeight(mY - pos.y);
31577 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
31579 // var pos = this.el.getBox(true);
31582 // var maxX = pos.right;
31584 // var maxHeight = 0;
31586 // Roo.each(items, function(item, k){
31590 // item.el.position('absolute');
31592 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
31594 // item.el.setWidth(width);
31596 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
31598 // item.el.setHeight(height);
31601 // item.el.setXY([x, y], isInstant ? false : true);
31603 // item.el.setXY([maxX - width, y], isInstant ? false : true);
31606 // y = y + height + this.alternativePadWidth;
31608 // maxHeight = maxHeight + height + this.alternativePadWidth;
31612 // this.el.setHeight(maxHeight);
31616 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
31618 var pos = this.el.getBox(true);
31623 var maxX = pos.right;
31625 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
31627 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
31629 Roo.each(queue, function(box, k){
31631 Roo.each(box, function(b, kk){
31633 b.el.position('absolute');
31635 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31636 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31638 if(b.size == 'md-left' || b.size == 'md-right'){
31639 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
31640 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
31643 b.el.setWidth(width);
31644 b.el.setHeight(height);
31652 var positions = [];
31654 switch (box.length){
31656 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
31659 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
31662 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
31665 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
31671 Roo.each(box, function(b,kk){
31673 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
31675 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
31683 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
31685 Roo.each(eItems, function(b,k){
31687 b.size = (k == 0) ? 'sm' : 'xs';
31688 b.x = (k == 0) ? 2 : 1;
31689 b.y = (k == 0) ? 2 : 1;
31691 b.el.position('absolute');
31693 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
31695 b.el.setWidth(width);
31697 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
31699 b.el.setHeight(height);
31703 var positions = [];
31706 x : maxX - this.unitWidth * 2 - this.gutter,
31711 x : maxX - this.unitWidth,
31712 y : minY + (this.unitWidth + this.gutter) * 2
31716 x : maxX - this.unitWidth * 3 - this.gutter * 2,
31720 Roo.each(eItems, function(b,k){
31722 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
31728 getVerticalOneBoxColPositions : function(x, y, box)
31732 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
31734 if(box[0].size == 'md-left'){
31738 if(box[0].size == 'md-right'){
31743 x : x + (this.unitWidth + this.gutter) * rand,
31750 getVerticalTwoBoxColPositions : function(x, y, box)
31754 if(box[0].size == 'xs'){
31758 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
31762 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
31776 x : x + (this.unitWidth + this.gutter) * 2,
31777 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
31784 getVerticalThreeBoxColPositions : function(x, y, box)
31788 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
31796 x : x + (this.unitWidth + this.gutter) * 1,
31801 x : x + (this.unitWidth + this.gutter) * 2,
31809 if(box[0].size == 'xs' && box[1].size == 'xs'){
31818 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
31822 x : x + (this.unitWidth + this.gutter) * 1,
31836 x : x + (this.unitWidth + this.gutter) * 2,
31841 x : x + (this.unitWidth + this.gutter) * 2,
31842 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
31849 getVerticalFourBoxColPositions : function(x, y, box)
31853 if(box[0].size == 'xs'){
31862 y : y + (this.unitHeight + this.gutter) * 1
31867 y : y + (this.unitHeight + this.gutter) * 2
31871 x : x + (this.unitWidth + this.gutter) * 1,
31885 x : x + (this.unitWidth + this.gutter) * 2,
31890 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
31891 y : y + (this.unitHeight + this.gutter) * 1
31895 x : x + (this.unitWidth + this.gutter) * 2,
31896 y : y + (this.unitWidth + this.gutter) * 2
31903 getHorizontalOneBoxColPositions : function(maxX, minY, box)
31907 if(box[0].size == 'md-left'){
31909 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
31916 if(box[0].size == 'md-right'){
31918 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
31919 y : minY + (this.unitWidth + this.gutter) * 1
31925 var rand = Math.floor(Math.random() * (4 - box[0].y));
31928 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31929 y : minY + (this.unitWidth + this.gutter) * rand
31936 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
31940 if(box[0].size == 'xs'){
31943 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31948 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31949 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
31957 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31962 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31963 y : minY + (this.unitWidth + this.gutter) * 2
31970 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
31974 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
31977 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
31982 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
31983 y : minY + (this.unitWidth + this.gutter) * 1
31987 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
31988 y : minY + (this.unitWidth + this.gutter) * 2
31995 if(box[0].size == 'xs' && box[1].size == 'xs'){
31998 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32003 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32008 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32009 y : minY + (this.unitWidth + this.gutter) * 1
32017 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32022 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32023 y : minY + (this.unitWidth + this.gutter) * 2
32027 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32028 y : minY + (this.unitWidth + this.gutter) * 2
32035 getHorizontalFourBoxColPositions : function(maxX, minY, box)
32039 if(box[0].size == 'xs'){
32042 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32047 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32052 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),
32057 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
32058 y : minY + (this.unitWidth + this.gutter) * 1
32066 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
32071 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
32072 y : minY + (this.unitWidth + this.gutter) * 2
32076 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
32077 y : minY + (this.unitWidth + this.gutter) * 2
32081 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),
32082 y : minY + (this.unitWidth + this.gutter) * 2
32090 * remove a Masonry Brick
32091 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to remove
32093 removeBrick : function(brick_id)
32099 for (var i = 0; i<this.bricks.length; i++) {
32100 if (this.bricks[i].id == brick_id) {
32101 this.bricks.splice(i,1);
32102 this.el.dom.removeChild(Roo.get(brick_id).dom);
32109 * adds a Masonry Brick
32110 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32112 addBrick : function(cfg)
32114 var cn = new Roo.bootstrap.MasonryBrick(cfg);
32115 //this.register(cn);
32116 cn.parentId = this.id;
32117 cn.render(this.el);
32122 * register a Masonry Brick
32123 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
32126 register : function(brick)
32128 this.bricks.push(brick);
32129 brick.masonryId = this.id;
32133 * clear all the Masonry Brick
32135 clearAll : function()
32138 //this.getChildContainer().dom.innerHTML = "";
32139 this.el.dom.innerHTML = '';
32142 getSelected : function()
32144 if (!this.selectedBrick) {
32148 return this.selectedBrick;
32152 Roo.apply(Roo.bootstrap.LayoutMasonry, {
32156 * register a Masonry Layout
32157 * @param {Roo.bootstrap.LayoutMasonry} the masonry layout to add
32160 register : function(layout)
32162 this.groups[layout.id] = layout;
32165 * fetch a Masonry Layout based on the masonry layout ID
32166 * @param {string} the masonry layout to add
32167 * @returns {Roo.bootstrap.LayoutMasonry} the masonry layout
32170 get: function(layout_id) {
32171 if (typeof(this.groups[layout_id]) == 'undefined') {
32174 return this.groups[layout_id] ;
32186 * http://masonry.desandro.com
32188 * The idea is to render all the bricks based on vertical width...
32190 * The original code extends 'outlayer' - we might need to use that....
32196 * @class Roo.bootstrap.LayoutMasonryAuto
32197 * @extends Roo.bootstrap.Component
32198 * Bootstrap Layout Masonry class
32201 * Create a new Element
32202 * @param {Object} config The config object
32205 Roo.bootstrap.LayoutMasonryAuto = function(config){
32206 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
32209 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
32212 * @cfg {Boolean} isFitWidth - resize the width..
32214 isFitWidth : false, // options..
32216 * @cfg {Boolean} isOriginLeft = left align?
32218 isOriginLeft : true,
32220 * @cfg {Boolean} isOriginTop = top align?
32222 isOriginTop : false,
32224 * @cfg {Boolean} isLayoutInstant = no animation?
32226 isLayoutInstant : false, // needed?
32228 * @cfg {Boolean} isResizingContainer = not sure if this is used..
32230 isResizingContainer : true,
32232 * @cfg {Number} columnWidth width of the columns
32238 * @cfg {Number} maxCols maximum number of columns
32243 * @cfg {Number} padHeight padding below box..
32249 * @cfg {Boolean} isAutoInitial defalut true
32252 isAutoInitial : true,
32258 initialColumnWidth : 0,
32259 currentSize : null,
32261 colYs : null, // array.
32268 bricks: null, //CompositeElement
32269 cols : 0, // array?
32270 // element : null, // wrapped now this.el
32271 _isLayoutInited : null,
32274 getAutoCreate : function(){
32278 cls: 'blog-masonary-wrapper ' + this.cls,
32280 cls : 'mas-boxes masonary'
32287 getChildContainer: function( )
32289 if (this.boxesEl) {
32290 return this.boxesEl;
32293 this.boxesEl = this.el.select('.mas-boxes').first();
32295 return this.boxesEl;
32299 initEvents : function()
32303 if(this.isAutoInitial){
32304 Roo.log('hook children rendered');
32305 this.on('childrenrendered', function() {
32306 Roo.log('children rendered');
32313 initial : function()
32315 this.reloadItems();
32317 this.currentSize = this.el.getBox(true);
32319 /// was window resize... - let's see if this works..
32320 Roo.EventManager.onWindowResize(this.resize, this);
32322 if(!this.isAutoInitial){
32327 this.layout.defer(500,this);
32330 reloadItems: function()
32332 this.bricks = this.el.select('.masonry-brick', true);
32334 this.bricks.each(function(b) {
32335 //Roo.log(b.getSize());
32336 if (!b.attr('originalwidth')) {
32337 b.attr('originalwidth', b.getSize().width);
32342 Roo.log(this.bricks.elements.length);
32345 resize : function()
32348 var cs = this.el.getBox(true);
32350 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
32351 Roo.log("no change in with or X");
32354 this.currentSize = cs;
32358 layout : function()
32361 this._resetLayout();
32362 //this._manageStamps();
32364 // don't animate first layout
32365 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
32366 this.layoutItems( isInstant );
32368 // flag for initalized
32369 this._isLayoutInited = true;
32372 layoutItems : function( isInstant )
32374 //var items = this._getItemsForLayout( this.items );
32375 // original code supports filtering layout items.. we just ignore it..
32377 this._layoutItems( this.bricks , isInstant );
32379 this._postLayout();
32381 _layoutItems : function ( items , isInstant)
32383 //this.fireEvent( 'layout', this, items );
32386 if ( !items || !items.elements.length ) {
32387 // no items, emit event with empty array
32392 items.each(function(item) {
32393 Roo.log("layout item");
32395 // get x/y object from method
32396 var position = this._getItemLayoutPosition( item );
32398 position.item = item;
32399 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
32400 queue.push( position );
32403 this._processLayoutQueue( queue );
32405 /** Sets position of item in DOM
32406 * @param {Element} item
32407 * @param {Number} x - horizontal position
32408 * @param {Number} y - vertical position
32409 * @param {Boolean} isInstant - disables transitions
32411 _processLayoutQueue : function( queue )
32413 for ( var i=0, len = queue.length; i < len; i++ ) {
32414 var obj = queue[i];
32415 obj.item.position('absolute');
32416 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
32422 * Any logic you want to do after each layout,
32423 * i.e. size the container
32425 _postLayout : function()
32427 this.resizeContainer();
32430 resizeContainer : function()
32432 if ( !this.isResizingContainer ) {
32435 var size = this._getContainerSize();
32437 this.el.setSize(size.width,size.height);
32438 this.boxesEl.setSize(size.width,size.height);
32444 _resetLayout : function()
32446 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
32447 this.colWidth = this.el.getWidth();
32448 //this.gutter = this.el.getWidth();
32450 this.measureColumns();
32456 this.colYs.push( 0 );
32462 measureColumns : function()
32464 this.getContainerWidth();
32465 // if columnWidth is 0, default to outerWidth of first item
32466 if ( !this.columnWidth ) {
32467 var firstItem = this.bricks.first();
32468 Roo.log(firstItem);
32469 this.columnWidth = this.containerWidth;
32470 if (firstItem && firstItem.attr('originalwidth') ) {
32471 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
32473 // columnWidth fall back to item of first element
32474 Roo.log("set column width?");
32475 this.initialColumnWidth = this.columnWidth ;
32477 // if first elem has no width, default to size of container
32482 if (this.initialColumnWidth) {
32483 this.columnWidth = this.initialColumnWidth;
32488 // column width is fixed at the top - however if container width get's smaller we should
32491 // this bit calcs how man columns..
32493 var columnWidth = this.columnWidth += this.gutter;
32495 // calculate columns
32496 var containerWidth = this.containerWidth + this.gutter;
32498 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
32499 // fix rounding errors, typically with gutters
32500 var excess = columnWidth - containerWidth % columnWidth;
32503 // if overshoot is less than a pixel, round up, otherwise floor it
32504 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
32505 cols = Math[ mathMethod ]( cols );
32506 this.cols = Math.max( cols, 1 );
32507 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
32509 // padding positioning..
32510 var totalColWidth = this.cols * this.columnWidth;
32511 var padavail = this.containerWidth - totalColWidth;
32512 // so for 2 columns - we need 3 'pads'
32514 var padNeeded = (1+this.cols) * this.padWidth;
32516 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
32518 this.columnWidth += padExtra
32519 //this.padWidth = Math.floor(padavail / ( this.cols));
32521 // adjust colum width so that padding is fixed??
32523 // we have 3 columns ... total = width * 3
32524 // we have X left over... that should be used by
32526 //if (this.expandC) {
32534 getContainerWidth : function()
32536 /* // container is parent if fit width
32537 var container = this.isFitWidth ? this.element.parentNode : this.element;
32538 // check that this.size and size are there
32539 // IE8 triggers resize on body size change, so they might not be
32541 var size = getSize( container ); //FIXME
32542 this.containerWidth = size && size.innerWidth; //FIXME
32545 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
32549 _getItemLayoutPosition : function( item ) // what is item?
32551 // we resize the item to our columnWidth..
32553 item.setWidth(this.columnWidth);
32554 item.autoBoxAdjust = false;
32556 var sz = item.getSize();
32558 // how many columns does this brick span
32559 var remainder = this.containerWidth % this.columnWidth;
32561 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
32562 // round if off by 1 pixel, otherwise use ceil
32563 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
32564 colSpan = Math.min( colSpan, this.cols );
32566 // normally this should be '1' as we dont' currently allow multi width columns..
32568 var colGroup = this._getColGroup( colSpan );
32569 // get the minimum Y value from the columns
32570 var minimumY = Math.min.apply( Math, colGroup );
32571 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32573 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
32575 // position the brick
32577 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
32578 y: this.currentSize.y + minimumY + this.padHeight
32582 // apply setHeight to necessary columns
32583 var setHeight = minimumY + sz.height + this.padHeight;
32584 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
32586 var setSpan = this.cols + 1 - colGroup.length;
32587 for ( var i = 0; i < setSpan; i++ ) {
32588 this.colYs[ shortColIndex + i ] = setHeight ;
32595 * @param {Number} colSpan - number of columns the element spans
32596 * @returns {Array} colGroup
32598 _getColGroup : function( colSpan )
32600 if ( colSpan < 2 ) {
32601 // if brick spans only one column, use all the column Ys
32606 // how many different places could this brick fit horizontally
32607 var groupCount = this.cols + 1 - colSpan;
32608 // for each group potential horizontal position
32609 for ( var i = 0; i < groupCount; i++ ) {
32610 // make an array of colY values for that one group
32611 var groupColYs = this.colYs.slice( i, i + colSpan );
32612 // and get the max value of the array
32613 colGroup[i] = Math.max.apply( Math, groupColYs );
32618 _manageStamp : function( stamp )
32620 var stampSize = stamp.getSize();
32621 var offset = stamp.getBox();
32622 // get the columns that this stamp affects
32623 var firstX = this.isOriginLeft ? offset.x : offset.right;
32624 var lastX = firstX + stampSize.width;
32625 var firstCol = Math.floor( firstX / this.columnWidth );
32626 firstCol = Math.max( 0, firstCol );
32628 var lastCol = Math.floor( lastX / this.columnWidth );
32629 // lastCol should not go over if multiple of columnWidth #425
32630 lastCol -= lastX % this.columnWidth ? 0 : 1;
32631 lastCol = Math.min( this.cols - 1, lastCol );
32633 // set colYs to bottom of the stamp
32634 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
32637 for ( var i = firstCol; i <= lastCol; i++ ) {
32638 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
32643 _getContainerSize : function()
32645 this.maxY = Math.max.apply( Math, this.colYs );
32650 if ( this.isFitWidth ) {
32651 size.width = this._getContainerFitWidth();
32657 _getContainerFitWidth : function()
32659 var unusedCols = 0;
32660 // count unused columns
32663 if ( this.colYs[i] !== 0 ) {
32668 // fit container to columns that have been used
32669 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
32672 needsResizeLayout : function()
32674 var previousWidth = this.containerWidth;
32675 this.getContainerWidth();
32676 return previousWidth !== this.containerWidth;
32691 * @class Roo.bootstrap.MasonryBrick
32692 * @extends Roo.bootstrap.Component
32693 * Bootstrap MasonryBrick class
32696 * Create a new MasonryBrick
32697 * @param {Object} config The config object
32700 Roo.bootstrap.MasonryBrick = function(config){
32702 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
32704 Roo.bootstrap.MasonryBrick.register(this);
32710 * When a MasonryBrick is clcik
32711 * @param {Roo.bootstrap.MasonryBrick} this
32712 * @param {Roo.EventObject} e
32718 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
32721 * @cfg {String} title
32725 * @cfg {String} html
32729 * @cfg {String} bgimage
32733 * @cfg {String} videourl
32737 * @cfg {String} cls
32741 * @cfg {String} href
32745 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
32750 * @cfg {String} placetitle (center|bottom)
32755 * @cfg {Boolean} isFitContainer defalut true
32757 isFitContainer : true,
32760 * @cfg {Boolean} preventDefault defalut false
32762 preventDefault : false,
32765 * @cfg {Boolean} inverse defalut false
32767 maskInverse : false,
32769 getAutoCreate : function()
32771 if(!this.isFitContainer){
32772 return this.getSplitAutoCreate();
32775 var cls = 'masonry-brick masonry-brick-full';
32777 if(this.href.length){
32778 cls += ' masonry-brick-link';
32781 if(this.bgimage.length){
32782 cls += ' masonry-brick-image';
32785 if(this.maskInverse){
32786 cls += ' mask-inverse';
32789 if(!this.html.length && !this.maskInverse && !this.videourl.length){
32790 cls += ' enable-mask';
32794 cls += ' masonry-' + this.size + '-brick';
32797 if(this.placetitle.length){
32799 switch (this.placetitle) {
32801 cls += ' masonry-center-title';
32804 cls += ' masonry-bottom-title';
32811 if(!this.html.length && !this.bgimage.length){
32812 cls += ' masonry-center-title';
32815 if(!this.html.length && this.bgimage.length){
32816 cls += ' masonry-bottom-title';
32821 cls += ' ' + this.cls;
32825 tag: (this.href.length) ? 'a' : 'div',
32830 cls: 'masonry-brick-mask'
32834 cls: 'masonry-brick-paragraph',
32840 if(this.href.length){
32841 cfg.href = this.href;
32844 var cn = cfg.cn[1].cn;
32846 if(this.title.length){
32849 cls: 'masonry-brick-title',
32854 if(this.html.length){
32857 cls: 'masonry-brick-text',
32862 if (!this.title.length && !this.html.length) {
32863 cfg.cn[1].cls += ' hide';
32866 if(this.bgimage.length){
32869 cls: 'masonry-brick-image-view',
32874 if(this.videourl.length){
32875 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
32876 // youtube support only?
32879 cls: 'masonry-brick-image-view',
32882 allowfullscreen : true
32890 getSplitAutoCreate : function()
32892 var cls = 'masonry-brick masonry-brick-split';
32894 if(this.href.length){
32895 cls += ' masonry-brick-link';
32898 if(this.bgimage.length){
32899 cls += ' masonry-brick-image';
32903 cls += ' masonry-' + this.size + '-brick';
32906 switch (this.placetitle) {
32908 cls += ' masonry-center-title';
32911 cls += ' masonry-bottom-title';
32914 if(!this.bgimage.length){
32915 cls += ' masonry-center-title';
32918 if(this.bgimage.length){
32919 cls += ' masonry-bottom-title';
32925 cls += ' ' + this.cls;
32929 tag: (this.href.length) ? 'a' : 'div',
32934 cls: 'masonry-brick-split-head',
32938 cls: 'masonry-brick-paragraph',
32945 cls: 'masonry-brick-split-body',
32951 if(this.href.length){
32952 cfg.href = this.href;
32955 if(this.title.length){
32956 cfg.cn[0].cn[0].cn.push({
32958 cls: 'masonry-brick-title',
32963 if(this.html.length){
32964 cfg.cn[1].cn.push({
32966 cls: 'masonry-brick-text',
32971 if(this.bgimage.length){
32972 cfg.cn[0].cn.push({
32974 cls: 'masonry-brick-image-view',
32979 if(this.videourl.length){
32980 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
32981 // youtube support only?
32982 cfg.cn[0].cn.cn.push({
32984 cls: 'masonry-brick-image-view',
32987 allowfullscreen : true
32994 initEvents: function()
32996 switch (this.size) {
33029 this.el.on('touchstart', this.onTouchStart, this);
33030 this.el.on('touchmove', this.onTouchMove, this);
33031 this.el.on('touchend', this.onTouchEnd, this);
33032 this.el.on('contextmenu', this.onContextMenu, this);
33034 this.el.on('mouseenter' ,this.enter, this);
33035 this.el.on('mouseleave', this.leave, this);
33036 this.el.on('click', this.onClick, this);
33039 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
33040 this.parent().bricks.push(this);
33045 onClick: function(e, el)
33047 var time = this.endTimer - this.startTimer;
33048 // Roo.log(e.preventDefault());
33051 e.preventDefault();
33056 if(!this.preventDefault){
33060 e.preventDefault();
33062 if (this.activeClass != '') {
33063 this.selectBrick();
33066 this.fireEvent('click', this, e);
33069 enter: function(e, el)
33071 e.preventDefault();
33073 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
33077 if(this.bgimage.length && this.html.length){
33078 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33082 leave: function(e, el)
33084 e.preventDefault();
33086 if(!this.isFitContainer || this.maskInverse || this.videourl.length){
33090 if(this.bgimage.length && this.html.length){
33091 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
33095 onTouchStart: function(e, el)
33097 // e.preventDefault();
33099 this.touchmoved = false;
33101 if(!this.isFitContainer){
33105 if(!this.bgimage.length || !this.html.length){
33109 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
33111 this.timer = new Date().getTime();
33115 onTouchMove: function(e, el)
33117 this.touchmoved = true;
33120 onContextMenu : function(e,el)
33122 e.preventDefault();
33123 e.stopPropagation();
33127 onTouchEnd: function(e, el)
33129 // e.preventDefault();
33131 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
33138 if(!this.bgimage.length || !this.html.length){
33140 if(this.href.length){
33141 window.location.href = this.href;
33147 if(!this.isFitContainer){
33151 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
33153 window.location.href = this.href;
33156 //selection on single brick only
33157 selectBrick : function() {
33159 if (!this.parentId) {
33163 var m = Roo.bootstrap.LayoutMasonry.get(this.parentId);
33164 var index = m.selectedBrick.indexOf(this.id);
33167 m.selectedBrick.splice(index,1);
33168 this.el.removeClass(this.activeClass);
33172 for(var i = 0; i < m.selectedBrick.length; i++) {
33173 var b = Roo.bootstrap.MasonryBrick.get(m.selectedBrick[i]);
33174 b.el.removeClass(b.activeClass);
33177 m.selectedBrick = [];
33179 m.selectedBrick.push(this.id);
33180 this.el.addClass(this.activeClass);
33184 isSelected : function(){
33185 return this.el.hasClass(this.activeClass);
33190 Roo.apply(Roo.bootstrap.MasonryBrick, {
33193 groups : new Roo.util.MixedCollection(false, function(o) { return o.el.id; }),
33195 * register a Masonry Brick
33196 * @param {Roo.bootstrap.MasonryBrick} the masonry brick to add
33199 register : function(brick)
33201 //this.groups[brick.id] = brick;
33202 this.groups.add(brick.id, brick);
33205 * fetch a masonry brick based on the masonry brick ID
33206 * @param {string} the masonry brick to add
33207 * @returns {Roo.bootstrap.MasonryBrick} the masonry brick
33210 get: function(brick_id)
33212 // if (typeof(this.groups[brick_id]) == 'undefined') {
33215 // return this.groups[brick_id] ;
33217 if(this.groups.key(brick_id)) {
33218 return this.groups.key(brick_id);
33236 * @class Roo.bootstrap.Brick
33237 * @extends Roo.bootstrap.Component
33238 * Bootstrap Brick class
33241 * Create a new Brick
33242 * @param {Object} config The config object
33245 Roo.bootstrap.Brick = function(config){
33246 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
33252 * When a Brick is click
33253 * @param {Roo.bootstrap.Brick} this
33254 * @param {Roo.EventObject} e
33260 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
33263 * @cfg {String} title
33267 * @cfg {String} html
33271 * @cfg {String} bgimage
33275 * @cfg {String} cls
33279 * @cfg {String} href
33283 * @cfg {String} video
33287 * @cfg {Boolean} square
33291 getAutoCreate : function()
33293 var cls = 'roo-brick';
33295 if(this.href.length){
33296 cls += ' roo-brick-link';
33299 if(this.bgimage.length){
33300 cls += ' roo-brick-image';
33303 if(!this.html.length && !this.bgimage.length){
33304 cls += ' roo-brick-center-title';
33307 if(!this.html.length && this.bgimage.length){
33308 cls += ' roo-brick-bottom-title';
33312 cls += ' ' + this.cls;
33316 tag: (this.href.length) ? 'a' : 'div',
33321 cls: 'roo-brick-paragraph',
33327 if(this.href.length){
33328 cfg.href = this.href;
33331 var cn = cfg.cn[0].cn;
33333 if(this.title.length){
33336 cls: 'roo-brick-title',
33341 if(this.html.length){
33344 cls: 'roo-brick-text',
33351 if(this.bgimage.length){
33354 cls: 'roo-brick-image-view',
33362 initEvents: function()
33364 if(this.title.length || this.html.length){
33365 this.el.on('mouseenter' ,this.enter, this);
33366 this.el.on('mouseleave', this.leave, this);
33369 Roo.EventManager.onWindowResize(this.resize, this);
33371 if(this.bgimage.length){
33372 this.imageEl = this.el.select('.roo-brick-image-view', true).first();
33373 this.imageEl.on('load', this.onImageLoad, this);
33380 onImageLoad : function()
33385 resize : function()
33387 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
33389 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
33391 if(this.bgimage.length){
33392 var image = this.el.select('.roo-brick-image-view', true).first();
33394 image.setWidth(paragraph.getWidth());
33397 image.setHeight(paragraph.getWidth());
33400 this.el.setHeight(image.getHeight());
33401 paragraph.setHeight(image.getHeight());
33407 enter: function(e, el)
33409 e.preventDefault();
33411 if(this.bgimage.length){
33412 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
33413 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
33417 leave: function(e, el)
33419 e.preventDefault();
33421 if(this.bgimage.length){
33422 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
33423 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
33438 * @class Roo.bootstrap.NumberField
33439 * @extends Roo.bootstrap.Input
33440 * Bootstrap NumberField class
33446 * Create a new NumberField
33447 * @param {Object} config The config object
33450 Roo.bootstrap.NumberField = function(config){
33451 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
33454 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
33457 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
33459 allowDecimals : true,
33461 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
33463 decimalSeparator : ".",
33465 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
33467 decimalPrecision : 2,
33469 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
33471 allowNegative : true,
33474 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
33478 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
33480 minValue : Number.NEGATIVE_INFINITY,
33482 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
33484 maxValue : Number.MAX_VALUE,
33486 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
33488 minText : "The minimum value for this field is {0}",
33490 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
33492 maxText : "The maximum value for this field is {0}",
33494 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
33495 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
33497 nanText : "{0} is not a valid number",
33499 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
33501 thousandsDelimiter : false,
33503 * @cfg {String} valueAlign alignment of value
33505 valueAlign : "left",
33507 getAutoCreate : function()
33509 var hiddenInput = {
33513 cls: 'hidden-number-input'
33517 hiddenInput.name = this.name;
33522 var cfg = Roo.bootstrap.NumberField.superclass.getAutoCreate.call(this);
33524 this.name = hiddenInput.name;
33526 if(cfg.cn.length > 0) {
33527 cfg.cn.push(hiddenInput);
33534 initEvents : function()
33536 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
33538 var allowed = "0123456789";
33540 if(this.allowDecimals){
33541 allowed += this.decimalSeparator;
33544 if(this.allowNegative){
33548 if(this.thousandsDelimiter) {
33552 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
33554 var keyPress = function(e){
33556 var k = e.getKey();
33558 var c = e.getCharCode();
33561 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
33562 allowed.indexOf(String.fromCharCode(c)) === -1
33568 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
33572 if(allowed.indexOf(String.fromCharCode(c)) === -1){
33577 this.el.on("keypress", keyPress, this);
33580 validateValue : function(value)
33583 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
33587 var num = this.parseValue(value);
33590 this.markInvalid(String.format(this.nanText, value));
33594 if(num < this.minValue){
33595 this.markInvalid(String.format(this.minText, this.minValue));
33599 if(num > this.maxValue){
33600 this.markInvalid(String.format(this.maxText, this.maxValue));
33607 getValue : function()
33609 var v = this.hiddenEl().getValue();
33611 return this.fixPrecision(this.parseValue(v));
33614 parseValue : function(value)
33616 if(this.thousandsDelimiter) {
33618 r = new RegExp(",", "g");
33619 value = value.replace(r, "");
33622 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
33623 return isNaN(value) ? '' : value;
33626 fixPrecision : function(value)
33628 if(this.thousandsDelimiter) {
33630 r = new RegExp(",", "g");
33631 value = value.replace(r, "");
33634 var nan = isNaN(value);
33636 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
33637 return nan ? '' : value;
33639 return parseFloat(value).toFixed(this.decimalPrecision);
33642 setValue : function(v)
33644 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
33650 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
33652 this.inputEl().dom.value = (v == '') ? '' :
33653 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
33655 if(!this.allowZero && v === '0') {
33656 this.hiddenEl().dom.value = '';
33657 this.inputEl().dom.value = '';
33664 decimalPrecisionFcn : function(v)
33666 return Math.floor(v);
33669 beforeBlur : function()
33671 var v = this.parseValue(this.getRawValue());
33673 if(v || v === 0 || v === ''){
33678 hiddenEl : function()
33680 return this.el.select('input.hidden-number-input',true).first();
33692 * @class Roo.bootstrap.DocumentSlider
33693 * @extends Roo.bootstrap.Component
33694 * Bootstrap DocumentSlider class
33697 * Create a new DocumentViewer
33698 * @param {Object} config The config object
33701 Roo.bootstrap.DocumentSlider = function(config){
33702 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
33709 * Fire after initEvent
33710 * @param {Roo.bootstrap.DocumentSlider} this
33715 * Fire after update
33716 * @param {Roo.bootstrap.DocumentSlider} this
33722 * @param {Roo.bootstrap.DocumentSlider} this
33728 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
33734 getAutoCreate : function()
33738 cls : 'roo-document-slider',
33742 cls : 'roo-document-slider-header',
33746 cls : 'roo-document-slider-header-title'
33752 cls : 'roo-document-slider-body',
33756 cls : 'roo-document-slider-prev',
33760 cls : 'fa fa-chevron-left'
33766 cls : 'roo-document-slider-thumb',
33770 cls : 'roo-document-slider-image'
33776 cls : 'roo-document-slider-next',
33780 cls : 'fa fa-chevron-right'
33792 initEvents : function()
33794 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
33795 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
33797 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
33798 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
33800 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
33801 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
33803 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
33804 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
33806 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
33807 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
33809 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
33810 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33812 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
33813 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
33815 this.thumbEl.on('click', this.onClick, this);
33817 this.prevIndicator.on('click', this.prev, this);
33819 this.nextIndicator.on('click', this.next, this);
33823 initial : function()
33825 if(this.files.length){
33826 this.indicator = 1;
33830 this.fireEvent('initial', this);
33833 update : function()
33835 this.imageEl.attr('src', this.files[this.indicator - 1]);
33837 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
33839 this.prevIndicator.show();
33841 if(this.indicator == 1){
33842 this.prevIndicator.hide();
33845 this.nextIndicator.show();
33847 if(this.indicator == this.files.length){
33848 this.nextIndicator.hide();
33851 this.thumbEl.scrollTo('top');
33853 this.fireEvent('update', this);
33856 onClick : function(e)
33858 e.preventDefault();
33860 this.fireEvent('click', this);
33865 e.preventDefault();
33867 this.indicator = Math.max(1, this.indicator - 1);
33874 e.preventDefault();
33876 this.indicator = Math.min(this.files.length, this.indicator + 1);
33890 * @class Roo.bootstrap.RadioSet
33891 * @extends Roo.bootstrap.Input
33892 * Bootstrap RadioSet class
33893 * @cfg {String} indicatorpos (left|right) default left
33894 * @cfg {Boolean} inline (true|false) inline the element (default true)
33895 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
33897 * Create a new RadioSet
33898 * @param {Object} config The config object
33901 Roo.bootstrap.RadioSet = function(config){
33903 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
33907 Roo.bootstrap.RadioSet.register(this);
33912 * Fires when the element is checked or unchecked.
33913 * @param {Roo.bootstrap.RadioSet} this This radio
33914 * @param {Roo.bootstrap.Radio} item The checked item
33919 * Fires when the element is click.
33920 * @param {Roo.bootstrap.RadioSet} this This radio set
33921 * @param {Roo.bootstrap.Radio} item The checked item
33922 * @param {Roo.EventObject} e The event object
33929 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
33937 indicatorpos : 'left',
33939 getAutoCreate : function()
33943 cls : 'roo-radio-set-label',
33947 html : this.fieldLabel
33952 if(this.indicatorpos == 'left'){
33955 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
33956 tooltip : 'This field is required'
33961 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
33962 tooltip : 'This field is required'
33968 cls : 'roo-radio-set-items'
33971 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
33973 if (align === 'left' && this.fieldLabel.length) {
33976 cls : "roo-radio-set-right",
33982 if(this.labelWidth > 12){
33983 label.style = "width: " + this.labelWidth + 'px';
33986 if(this.labelWidth < 13 && this.labelmd == 0){
33987 this.labelmd = this.labelWidth;
33990 if(this.labellg > 0){
33991 label.cls += ' col-lg-' + this.labellg;
33992 items.cls += ' col-lg-' + (12 - this.labellg);
33995 if(this.labelmd > 0){
33996 label.cls += ' col-md-' + this.labelmd;
33997 items.cls += ' col-md-' + (12 - this.labelmd);
34000 if(this.labelsm > 0){
34001 label.cls += ' col-sm-' + this.labelsm;
34002 items.cls += ' col-sm-' + (12 - this.labelsm);
34005 if(this.labelxs > 0){
34006 label.cls += ' col-xs-' + this.labelxs;
34007 items.cls += ' col-xs-' + (12 - this.labelxs);
34013 cls : 'roo-radio-set',
34017 cls : 'roo-radio-set-input',
34020 value : this.value ? this.value : ''
34027 if(this.weight.length){
34028 cfg.cls += ' roo-radio-' + this.weight;
34032 cfg.cls += ' roo-radio-set-inline';
34036 ['xs','sm','md','lg'].map(function(size){
34037 if (settings[size]) {
34038 cfg.cls += ' col-' + size + '-' + settings[size];
34046 initEvents : function()
34048 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
34049 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
34051 if(!this.fieldLabel.length){
34052 this.labelEl.hide();
34055 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
34056 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
34058 this.indicator = this.indicatorEl();
34060 if(this.indicator){
34061 this.indicator.addClass('invisible');
34064 this.originalValue = this.getValue();
34068 inputEl: function ()
34070 return this.el.select('.roo-radio-set-input', true).first();
34073 getChildContainer : function()
34075 return this.itemsEl;
34078 register : function(item)
34080 this.radioes.push(item);
34084 validate : function()
34086 if(this.getVisibilityEl().hasClass('hidden')){
34092 Roo.each(this.radioes, function(i){
34101 if(this.allowBlank) {
34105 if(this.disabled || valid){
34110 this.markInvalid();
34115 markValid : function()
34117 if(this.labelEl.isVisible(true)){
34118 this.indicatorEl().removeClass('visible');
34119 this.indicatorEl().addClass('invisible');
34122 this.el.removeClass([this.invalidClass, this.validClass]);
34123 this.el.addClass(this.validClass);
34125 this.fireEvent('valid', this);
34128 markInvalid : function(msg)
34130 if(this.allowBlank || this.disabled){
34134 if(this.labelEl.isVisible(true)){
34135 this.indicatorEl().removeClass('invisible');
34136 this.indicatorEl().addClass('visible');
34139 this.el.removeClass([this.invalidClass, this.validClass]);
34140 this.el.addClass(this.invalidClass);
34142 this.fireEvent('invalid', this, msg);
34146 setValue : function(v, suppressEvent)
34148 if(this.value === v){
34155 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
34158 Roo.each(this.radioes, function(i){
34160 i.el.removeClass('checked');
34163 Roo.each(this.radioes, function(i){
34165 if(i.value === v || i.value.toString() === v.toString()){
34167 i.el.addClass('checked');
34169 if(suppressEvent !== true){
34170 this.fireEvent('check', this, i);
34181 clearInvalid : function(){
34183 if(!this.el || this.preventMark){
34187 this.el.removeClass([this.invalidClass]);
34189 this.fireEvent('valid', this);
34194 Roo.apply(Roo.bootstrap.RadioSet, {
34198 register : function(set)
34200 this.groups[set.name] = set;
34203 get: function(name)
34205 if (typeof(this.groups[name]) == 'undefined') {
34209 return this.groups[name] ;
34215 * Ext JS Library 1.1.1
34216 * Copyright(c) 2006-2007, Ext JS, LLC.
34218 * Originally Released Under LGPL - original licence link has changed is not relivant.
34221 * <script type="text/javascript">
34226 * @class Roo.bootstrap.SplitBar
34227 * @extends Roo.util.Observable
34228 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
34232 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
34233 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
34234 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
34235 split.minSize = 100;
34236 split.maxSize = 600;
34237 split.animate = true;
34238 split.on('moved', splitterMoved);
34241 * Create a new SplitBar
34242 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
34243 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
34244 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34245 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
34246 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
34247 position of the SplitBar).
34249 Roo.bootstrap.SplitBar = function(cfg){
34254 // dragElement : elm
34255 // resizingElement: el,
34257 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
34258 // placement : Roo.bootstrap.SplitBar.LEFT ,
34259 // existingProxy ???
34262 this.el = Roo.get(cfg.dragElement, true);
34263 this.el.dom.unselectable = "on";
34265 this.resizingEl = Roo.get(cfg.resizingElement, true);
34269 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
34270 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
34273 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
34276 * The minimum size of the resizing element. (Defaults to 0)
34282 * The maximum size of the resizing element. (Defaults to 2000)
34285 this.maxSize = 2000;
34288 * Whether to animate the transition to the new size
34291 this.animate = false;
34294 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
34297 this.useShim = false;
34302 if(!cfg.existingProxy){
34304 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
34306 this.proxy = Roo.get(cfg.existingProxy).dom;
34309 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
34312 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
34315 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
34318 this.dragSpecs = {};
34321 * @private The adapter to use to positon and resize elements
34323 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34324 this.adapter.init(this);
34326 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34328 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
34329 this.el.addClass("roo-splitbar-h");
34332 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
34333 this.el.addClass("roo-splitbar-v");
34339 * Fires when the splitter is moved (alias for {@link #event-moved})
34340 * @param {Roo.bootstrap.SplitBar} this
34341 * @param {Number} newSize the new width or height
34346 * Fires when the splitter is moved
34347 * @param {Roo.bootstrap.SplitBar} this
34348 * @param {Number} newSize the new width or height
34352 * @event beforeresize
34353 * Fires before the splitter is dragged
34354 * @param {Roo.bootstrap.SplitBar} this
34356 "beforeresize" : true,
34358 "beforeapply" : true
34361 Roo.util.Observable.call(this);
34364 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
34365 onStartProxyDrag : function(x, y){
34366 this.fireEvent("beforeresize", this);
34368 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
34370 o.enableDisplayMode("block");
34371 // all splitbars share the same overlay
34372 Roo.bootstrap.SplitBar.prototype.overlay = o;
34374 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
34375 this.overlay.show();
34376 Roo.get(this.proxy).setDisplayed("block");
34377 var size = this.adapter.getElementSize(this);
34378 this.activeMinSize = this.getMinimumSize();;
34379 this.activeMaxSize = this.getMaximumSize();;
34380 var c1 = size - this.activeMinSize;
34381 var c2 = Math.max(this.activeMaxSize - size, 0);
34382 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34383 this.dd.resetConstraints();
34384 this.dd.setXConstraint(
34385 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
34386 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
34388 this.dd.setYConstraint(0, 0);
34390 this.dd.resetConstraints();
34391 this.dd.setXConstraint(0, 0);
34392 this.dd.setYConstraint(
34393 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
34394 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
34397 this.dragSpecs.startSize = size;
34398 this.dragSpecs.startPoint = [x, y];
34399 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
34403 * @private Called after the drag operation by the DDProxy
34405 onEndProxyDrag : function(e){
34406 Roo.get(this.proxy).setDisplayed(false);
34407 var endPoint = Roo.lib.Event.getXY(e);
34409 this.overlay.hide();
34412 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34413 newSize = this.dragSpecs.startSize +
34414 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
34415 endPoint[0] - this.dragSpecs.startPoint[0] :
34416 this.dragSpecs.startPoint[0] - endPoint[0]
34419 newSize = this.dragSpecs.startSize +
34420 (this.placement == Roo.bootstrap.SplitBar.TOP ?
34421 endPoint[1] - this.dragSpecs.startPoint[1] :
34422 this.dragSpecs.startPoint[1] - endPoint[1]
34425 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
34426 if(newSize != this.dragSpecs.startSize){
34427 if(this.fireEvent('beforeapply', this, newSize) !== false){
34428 this.adapter.setElementSize(this, newSize);
34429 this.fireEvent("moved", this, newSize);
34430 this.fireEvent("resize", this, newSize);
34436 * Get the adapter this SplitBar uses
34437 * @return The adapter object
34439 getAdapter : function(){
34440 return this.adapter;
34444 * Set the adapter this SplitBar uses
34445 * @param {Object} adapter A SplitBar adapter object
34447 setAdapter : function(adapter){
34448 this.adapter = adapter;
34449 this.adapter.init(this);
34453 * Gets the minimum size for the resizing element
34454 * @return {Number} The minimum size
34456 getMinimumSize : function(){
34457 return this.minSize;
34461 * Sets the minimum size for the resizing element
34462 * @param {Number} minSize The minimum size
34464 setMinimumSize : function(minSize){
34465 this.minSize = minSize;
34469 * Gets the maximum size for the resizing element
34470 * @return {Number} The maximum size
34472 getMaximumSize : function(){
34473 return this.maxSize;
34477 * Sets the maximum size for the resizing element
34478 * @param {Number} maxSize The maximum size
34480 setMaximumSize : function(maxSize){
34481 this.maxSize = maxSize;
34485 * Sets the initialize size for the resizing element
34486 * @param {Number} size The initial size
34488 setCurrentSize : function(size){
34489 var oldAnimate = this.animate;
34490 this.animate = false;
34491 this.adapter.setElementSize(this, size);
34492 this.animate = oldAnimate;
34496 * Destroy this splitbar.
34497 * @param {Boolean} removeEl True to remove the element
34499 destroy : function(removeEl){
34501 this.shim.remove();
34504 this.proxy.parentNode.removeChild(this.proxy);
34512 * @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.
34514 Roo.bootstrap.SplitBar.createProxy = function(dir){
34515 var proxy = new Roo.Element(document.createElement("div"));
34516 proxy.unselectable();
34517 var cls = 'roo-splitbar-proxy';
34518 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
34519 document.body.appendChild(proxy.dom);
34524 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
34525 * Default Adapter. It assumes the splitter and resizing element are not positioned
34526 * elements and only gets/sets the width of the element. Generally used for table based layouts.
34528 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
34531 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
34532 // do nothing for now
34533 init : function(s){
34537 * Called before drag operations to get the current size of the resizing element.
34538 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34540 getElementSize : function(s){
34541 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34542 return s.resizingEl.getWidth();
34544 return s.resizingEl.getHeight();
34549 * Called after drag operations to set the size of the resizing element.
34550 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
34551 * @param {Number} newSize The new size to set
34552 * @param {Function} onComplete A function to be invoked when resizing is complete
34554 setElementSize : function(s, newSize, onComplete){
34555 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
34557 s.resizingEl.setWidth(newSize);
34559 onComplete(s, newSize);
34562 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
34567 s.resizingEl.setHeight(newSize);
34569 onComplete(s, newSize);
34572 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
34579 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
34580 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
34581 * Adapter that moves the splitter element to align with the resized sizing element.
34582 * Used with an absolute positioned SplitBar.
34583 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
34584 * document.body, make sure you assign an id to the body element.
34586 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
34587 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
34588 this.container = Roo.get(container);
34591 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
34592 init : function(s){
34593 this.basic.init(s);
34596 getElementSize : function(s){
34597 return this.basic.getElementSize(s);
34600 setElementSize : function(s, newSize, onComplete){
34601 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
34604 moveSplitter : function(s){
34605 var yes = Roo.bootstrap.SplitBar;
34606 switch(s.placement){
34608 s.el.setX(s.resizingEl.getRight());
34611 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
34614 s.el.setY(s.resizingEl.getBottom());
34617 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
34624 * Orientation constant - Create a vertical SplitBar
34628 Roo.bootstrap.SplitBar.VERTICAL = 1;
34631 * Orientation constant - Create a horizontal SplitBar
34635 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
34638 * Placement constant - The resizing element is to the left of the splitter element
34642 Roo.bootstrap.SplitBar.LEFT = 1;
34645 * Placement constant - The resizing element is to the right of the splitter element
34649 Roo.bootstrap.SplitBar.RIGHT = 2;
34652 * Placement constant - The resizing element is positioned above the splitter element
34656 Roo.bootstrap.SplitBar.TOP = 3;
34659 * Placement constant - The resizing element is positioned under splitter element
34663 Roo.bootstrap.SplitBar.BOTTOM = 4;
34664 Roo.namespace("Roo.bootstrap.layout");/*
34666 * Ext JS Library 1.1.1
34667 * Copyright(c) 2006-2007, Ext JS, LLC.
34669 * Originally Released Under LGPL - original licence link has changed is not relivant.
34672 * <script type="text/javascript">
34676 * @class Roo.bootstrap.layout.Manager
34677 * @extends Roo.bootstrap.Component
34678 * Base class for layout managers.
34680 Roo.bootstrap.layout.Manager = function(config)
34682 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
34688 /** false to disable window resize monitoring @type Boolean */
34689 this.monitorWindowResize = true;
34694 * Fires when a layout is performed.
34695 * @param {Roo.LayoutManager} this
34699 * @event regionresized
34700 * Fires when the user resizes a region.
34701 * @param {Roo.LayoutRegion} region The resized region
34702 * @param {Number} newSize The new size (width for east/west, height for north/south)
34704 "regionresized" : true,
34706 * @event regioncollapsed
34707 * Fires when a region is collapsed.
34708 * @param {Roo.LayoutRegion} region The collapsed region
34710 "regioncollapsed" : true,
34712 * @event regionexpanded
34713 * Fires when a region is expanded.
34714 * @param {Roo.LayoutRegion} region The expanded region
34716 "regionexpanded" : true
34718 this.updating = false;
34721 this.el = Roo.get(config.el);
34727 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
34732 monitorWindowResize : true,
34738 onRender : function(ct, position)
34741 this.el = Roo.get(ct);
34744 //this.fireEvent('render',this);
34748 initEvents: function()
34752 // ie scrollbar fix
34753 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
34754 document.body.scroll = "no";
34755 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
34756 this.el.position('relative');
34758 this.id = this.el.id;
34759 this.el.addClass("roo-layout-container");
34760 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
34761 if(this.el.dom != document.body ) {
34762 this.el.on('resize', this.layout,this);
34763 this.el.on('show', this.layout,this);
34769 * Returns true if this layout is currently being updated
34770 * @return {Boolean}
34772 isUpdating : function(){
34773 return this.updating;
34777 * Suspend the LayoutManager from doing auto-layouts while
34778 * making multiple add or remove calls
34780 beginUpdate : function(){
34781 this.updating = true;
34785 * Restore auto-layouts and optionally disable the manager from performing a layout
34786 * @param {Boolean} noLayout true to disable a layout update
34788 endUpdate : function(noLayout){
34789 this.updating = false;
34795 layout: function(){
34799 onRegionResized : function(region, newSize){
34800 this.fireEvent("regionresized", region, newSize);
34804 onRegionCollapsed : function(region){
34805 this.fireEvent("regioncollapsed", region);
34808 onRegionExpanded : function(region){
34809 this.fireEvent("regionexpanded", region);
34813 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
34814 * performs box-model adjustments.
34815 * @return {Object} The size as an object {width: (the width), height: (the height)}
34817 getViewSize : function()
34820 if(this.el.dom != document.body){
34821 size = this.el.getSize();
34823 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
34825 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
34826 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
34831 * Returns the Element this layout is bound to.
34832 * @return {Roo.Element}
34834 getEl : function(){
34839 * Returns the specified region.
34840 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
34841 * @return {Roo.LayoutRegion}
34843 getRegion : function(target){
34844 return this.regions[target.toLowerCase()];
34847 onWindowResize : function(){
34848 if(this.monitorWindowResize){
34855 * Ext JS Library 1.1.1
34856 * Copyright(c) 2006-2007, Ext JS, LLC.
34858 * Originally Released Under LGPL - original licence link has changed is not relivant.
34861 * <script type="text/javascript">
34864 * @class Roo.bootstrap.layout.Border
34865 * @extends Roo.bootstrap.layout.Manager
34866 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
34867 * please see: examples/bootstrap/nested.html<br><br>
34869 <b>The container the layout is rendered into can be either the body element or any other element.
34870 If it is not the body element, the container needs to either be an absolute positioned element,
34871 or you will need to add "position:relative" to the css of the container. You will also need to specify
34872 the container size if it is not the body element.</b>
34875 * Create a new Border
34876 * @param {Object} config Configuration options
34878 Roo.bootstrap.layout.Border = function(config){
34879 config = config || {};
34880 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
34884 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
34885 if(config[region]){
34886 config[region].region = region;
34887 this.addRegion(config[region]);
34893 Roo.bootstrap.layout.Border.regions = ["north","south","east","west","center"];
34895 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
34897 * Creates and adds a new region if it doesn't already exist.
34898 * @param {String} target The target region key (north, south, east, west or center).
34899 * @param {Object} config The regions config object
34900 * @return {BorderLayoutRegion} The new region
34902 addRegion : function(config)
34904 if(!this.regions[config.region]){
34905 var r = this.factory(config);
34906 this.bindRegion(r);
34908 return this.regions[config.region];
34912 bindRegion : function(r){
34913 this.regions[r.config.region] = r;
34915 r.on("visibilitychange", this.layout, this);
34916 r.on("paneladded", this.layout, this);
34917 r.on("panelremoved", this.layout, this);
34918 r.on("invalidated", this.layout, this);
34919 r.on("resized", this.onRegionResized, this);
34920 r.on("collapsed", this.onRegionCollapsed, this);
34921 r.on("expanded", this.onRegionExpanded, this);
34925 * Performs a layout update.
34927 layout : function()
34929 if(this.updating) {
34933 // render all the rebions if they have not been done alreayd?
34934 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
34935 if(this.regions[region] && !this.regions[region].bodyEl){
34936 this.regions[region].onRender(this.el)
34940 var size = this.getViewSize();
34941 var w = size.width;
34942 var h = size.height;
34947 //var x = 0, y = 0;
34949 var rs = this.regions;
34950 var north = rs["north"];
34951 var south = rs["south"];
34952 var west = rs["west"];
34953 var east = rs["east"];
34954 var center = rs["center"];
34955 //if(this.hideOnLayout){ // not supported anymore
34956 //c.el.setStyle("display", "none");
34958 if(north && north.isVisible()){
34959 var b = north.getBox();
34960 var m = north.getMargins();
34961 b.width = w - (m.left+m.right);
34964 centerY = b.height + b.y + m.bottom;
34965 centerH -= centerY;
34966 north.updateBox(this.safeBox(b));
34968 if(south && south.isVisible()){
34969 var b = south.getBox();
34970 var m = south.getMargins();
34971 b.width = w - (m.left+m.right);
34973 var totalHeight = (b.height + m.top + m.bottom);
34974 b.y = h - totalHeight + m.top;
34975 centerH -= totalHeight;
34976 south.updateBox(this.safeBox(b));
34978 if(west && west.isVisible()){
34979 var b = west.getBox();
34980 var m = west.getMargins();
34981 b.height = centerH - (m.top+m.bottom);
34983 b.y = centerY + m.top;
34984 var totalWidth = (b.width + m.left + m.right);
34985 centerX += totalWidth;
34986 centerW -= totalWidth;
34987 west.updateBox(this.safeBox(b));
34989 if(east && east.isVisible()){
34990 var b = east.getBox();
34991 var m = east.getMargins();
34992 b.height = centerH - (m.top+m.bottom);
34993 var totalWidth = (b.width + m.left + m.right);
34994 b.x = w - totalWidth + m.left;
34995 b.y = centerY + m.top;
34996 centerW -= totalWidth;
34997 east.updateBox(this.safeBox(b));
35000 var m = center.getMargins();
35002 x: centerX + m.left,
35003 y: centerY + m.top,
35004 width: centerW - (m.left+m.right),
35005 height: centerH - (m.top+m.bottom)
35007 //if(this.hideOnLayout){
35008 //center.el.setStyle("display", "block");
35010 center.updateBox(this.safeBox(centerBox));
35013 this.fireEvent("layout", this);
35017 safeBox : function(box){
35018 box.width = Math.max(0, box.width);
35019 box.height = Math.max(0, box.height);
35024 * Adds a ContentPanel (or subclass) to this layout.
35025 * @param {String} target The target region key (north, south, east, west or center).
35026 * @param {Roo.ContentPanel} panel The panel to add
35027 * @return {Roo.ContentPanel} The added panel
35029 add : function(target, panel){
35031 target = target.toLowerCase();
35032 return this.regions[target].add(panel);
35036 * Remove a ContentPanel (or subclass) to this layout.
35037 * @param {String} target The target region key (north, south, east, west or center).
35038 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
35039 * @return {Roo.ContentPanel} The removed panel
35041 remove : function(target, panel){
35042 target = target.toLowerCase();
35043 return this.regions[target].remove(panel);
35047 * Searches all regions for a panel with the specified id
35048 * @param {String} panelId
35049 * @return {Roo.ContentPanel} The panel or null if it wasn't found
35051 findPanel : function(panelId){
35052 var rs = this.regions;
35053 for(var target in rs){
35054 if(typeof rs[target] != "function"){
35055 var p = rs[target].getPanel(panelId);
35065 * Searches all regions for a panel with the specified id and activates (shows) it.
35066 * @param {String/ContentPanel} panelId The panels id or the panel itself
35067 * @return {Roo.ContentPanel} The shown panel or null
35069 showPanel : function(panelId) {
35070 var rs = this.regions;
35071 for(var target in rs){
35072 var r = rs[target];
35073 if(typeof r != "function"){
35074 if(r.hasPanel(panelId)){
35075 return r.showPanel(panelId);
35083 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
35084 * @param {Roo.state.Provider} provider (optional) An alternate state provider
35087 restoreState : function(provider){
35089 provider = Roo.state.Manager;
35091 var sm = new Roo.LayoutStateManager();
35092 sm.init(this, provider);
35098 * Adds a xtype elements to the layout.
35102 xtype : 'ContentPanel',
35109 xtype : 'NestedLayoutPanel',
35115 items : [ ... list of content panels or nested layout panels.. ]
35119 * @param {Object} cfg Xtype definition of item to add.
35121 addxtype : function(cfg)
35123 // basically accepts a pannel...
35124 // can accept a layout region..!?!?
35125 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
35128 // theory? children can only be panels??
35130 //if (!cfg.xtype.match(/Panel$/)) {
35135 if (typeof(cfg.region) == 'undefined') {
35136 Roo.log("Failed to add Panel, region was not set");
35140 var region = cfg.region;
35146 xitems = cfg.items;
35153 case 'Content': // ContentPanel (el, cfg)
35154 case 'Scroll': // ContentPanel (el, cfg)
35156 cfg.autoCreate = true;
35157 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35159 // var el = this.el.createChild();
35160 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
35163 this.add(region, ret);
35167 case 'TreePanel': // our new panel!
35168 cfg.el = this.el.createChild();
35169 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35170 this.add(region, ret);
35175 // create a new Layout (which is a Border Layout...
35177 var clayout = cfg.layout;
35178 clayout.el = this.el.createChild();
35179 clayout.items = clayout.items || [];
35183 // replace this exitems with the clayout ones..
35184 xitems = clayout.items;
35186 // force background off if it's in center...
35187 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
35188 cfg.background = false;
35190 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
35193 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35194 //console.log('adding nested layout panel ' + cfg.toSource());
35195 this.add(region, ret);
35196 nb = {}; /// find first...
35201 // needs grid and region
35203 //var el = this.getRegion(region).el.createChild();
35205 *var el = this.el.createChild();
35206 // create the grid first...
35207 cfg.grid.container = el;
35208 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
35211 if (region == 'center' && this.active ) {
35212 cfg.background = false;
35215 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
35217 this.add(region, ret);
35219 if (cfg.background) {
35220 // render grid on panel activation (if panel background)
35221 ret.on('activate', function(gp) {
35222 if (!gp.grid.rendered) {
35223 // gp.grid.render(el);
35227 // cfg.grid.render(el);
35233 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
35234 // it was the old xcomponent building that caused this before.
35235 // espeically if border is the top element in the tree.
35245 if (typeof(Roo[cfg.xtype]) != 'undefined') {
35247 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
35248 this.add(region, ret);
35252 throw "Can not add '" + cfg.xtype + "' to Border";
35258 this.beginUpdate();
35262 Roo.each(xitems, function(i) {
35263 region = nb && i.region ? i.region : false;
35265 var add = ret.addxtype(i);
35268 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
35269 if (!i.background) {
35270 abn[region] = nb[region] ;
35277 // make the last non-background panel active..
35278 //if (nb) { Roo.log(abn); }
35281 for(var r in abn) {
35282 region = this.getRegion(r);
35284 // tried using nb[r], but it does not work..
35286 region.showPanel(abn[r]);
35297 factory : function(cfg)
35300 var validRegions = Roo.bootstrap.layout.Border.regions;
35302 var target = cfg.region;
35305 var r = Roo.bootstrap.layout;
35309 return new r.North(cfg);
35311 return new r.South(cfg);
35313 return new r.East(cfg);
35315 return new r.West(cfg);
35317 return new r.Center(cfg);
35319 throw 'Layout region "'+target+'" not supported.';
35326 * Ext JS Library 1.1.1
35327 * Copyright(c) 2006-2007, Ext JS, LLC.
35329 * Originally Released Under LGPL - original licence link has changed is not relivant.
35332 * <script type="text/javascript">
35336 * @class Roo.bootstrap.layout.Basic
35337 * @extends Roo.util.Observable
35338 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
35339 * and does not have a titlebar, tabs or any other features. All it does is size and position
35340 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
35341 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35342 * @cfg {string} region the region that it inhabits..
35343 * @cfg {bool} skipConfig skip config?
35347 Roo.bootstrap.layout.Basic = function(config){
35349 this.mgr = config.mgr;
35351 this.position = config.region;
35353 var skipConfig = config.skipConfig;
35357 * @scope Roo.BasicLayoutRegion
35361 * @event beforeremove
35362 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
35363 * @param {Roo.LayoutRegion} this
35364 * @param {Roo.ContentPanel} panel The panel
35365 * @param {Object} e The cancel event object
35367 "beforeremove" : true,
35369 * @event invalidated
35370 * Fires when the layout for this region is changed.
35371 * @param {Roo.LayoutRegion} this
35373 "invalidated" : true,
35375 * @event visibilitychange
35376 * Fires when this region is shown or hidden
35377 * @param {Roo.LayoutRegion} this
35378 * @param {Boolean} visibility true or false
35380 "visibilitychange" : true,
35382 * @event paneladded
35383 * Fires when a panel is added.
35384 * @param {Roo.LayoutRegion} this
35385 * @param {Roo.ContentPanel} panel The panel
35387 "paneladded" : true,
35389 * @event panelremoved
35390 * Fires when a panel is removed.
35391 * @param {Roo.LayoutRegion} this
35392 * @param {Roo.ContentPanel} panel The panel
35394 "panelremoved" : true,
35396 * @event beforecollapse
35397 * Fires when this region before collapse.
35398 * @param {Roo.LayoutRegion} this
35400 "beforecollapse" : true,
35403 * Fires when this region is collapsed.
35404 * @param {Roo.LayoutRegion} this
35406 "collapsed" : true,
35409 * Fires when this region is expanded.
35410 * @param {Roo.LayoutRegion} this
35415 * Fires when this region is slid into view.
35416 * @param {Roo.LayoutRegion} this
35418 "slideshow" : true,
35421 * Fires when this region slides out of view.
35422 * @param {Roo.LayoutRegion} this
35424 "slidehide" : true,
35426 * @event panelactivated
35427 * Fires when a panel is activated.
35428 * @param {Roo.LayoutRegion} this
35429 * @param {Roo.ContentPanel} panel The activated panel
35431 "panelactivated" : true,
35434 * Fires when the user resizes this region.
35435 * @param {Roo.LayoutRegion} this
35436 * @param {Number} newSize The new size (width for east/west, height for north/south)
35440 /** A collection of panels in this region. @type Roo.util.MixedCollection */
35441 this.panels = new Roo.util.MixedCollection();
35442 this.panels.getKey = this.getPanelId.createDelegate(this);
35444 this.activePanel = null;
35445 // ensure listeners are added...
35447 if (config.listeners || config.events) {
35448 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
35449 listeners : config.listeners || {},
35450 events : config.events || {}
35454 if(skipConfig !== true){
35455 this.applyConfig(config);
35459 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
35461 getPanelId : function(p){
35465 applyConfig : function(config){
35466 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35467 this.config = config;
35472 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
35473 * the width, for horizontal (north, south) the height.
35474 * @param {Number} newSize The new width or height
35476 resizeTo : function(newSize){
35477 var el = this.el ? this.el :
35478 (this.activePanel ? this.activePanel.getEl() : null);
35480 switch(this.position){
35483 el.setWidth(newSize);
35484 this.fireEvent("resized", this, newSize);
35488 el.setHeight(newSize);
35489 this.fireEvent("resized", this, newSize);
35495 getBox : function(){
35496 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
35499 getMargins : function(){
35500 return this.margins;
35503 updateBox : function(box){
35505 var el = this.activePanel.getEl();
35506 el.dom.style.left = box.x + "px";
35507 el.dom.style.top = box.y + "px";
35508 this.activePanel.setSize(box.width, box.height);
35512 * Returns the container element for this region.
35513 * @return {Roo.Element}
35515 getEl : function(){
35516 return this.activePanel;
35520 * Returns true if this region is currently visible.
35521 * @return {Boolean}
35523 isVisible : function(){
35524 return this.activePanel ? true : false;
35527 setActivePanel : function(panel){
35528 panel = this.getPanel(panel);
35529 if(this.activePanel && this.activePanel != panel){
35530 this.activePanel.setActiveState(false);
35531 this.activePanel.getEl().setLeftTop(-10000,-10000);
35533 this.activePanel = panel;
35534 panel.setActiveState(true);
35536 panel.setSize(this.box.width, this.box.height);
35538 this.fireEvent("panelactivated", this, panel);
35539 this.fireEvent("invalidated");
35543 * Show the specified panel.
35544 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
35545 * @return {Roo.ContentPanel} The shown panel or null
35547 showPanel : function(panel){
35548 panel = this.getPanel(panel);
35550 this.setActivePanel(panel);
35556 * Get the active panel for this region.
35557 * @return {Roo.ContentPanel} The active panel or null
35559 getActivePanel : function(){
35560 return this.activePanel;
35564 * Add the passed ContentPanel(s)
35565 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
35566 * @return {Roo.ContentPanel} The panel added (if only one was added)
35568 add : function(panel){
35569 if(arguments.length > 1){
35570 for(var i = 0, len = arguments.length; i < len; i++) {
35571 this.add(arguments[i]);
35575 if(this.hasPanel(panel)){
35576 this.showPanel(panel);
35579 var el = panel.getEl();
35580 if(el.dom.parentNode != this.mgr.el.dom){
35581 this.mgr.el.dom.appendChild(el.dom);
35583 if(panel.setRegion){
35584 panel.setRegion(this);
35586 this.panels.add(panel);
35587 el.setStyle("position", "absolute");
35588 if(!panel.background){
35589 this.setActivePanel(panel);
35590 if(this.config.initialSize && this.panels.getCount()==1){
35591 this.resizeTo(this.config.initialSize);
35594 this.fireEvent("paneladded", this, panel);
35599 * Returns true if the panel is in this region.
35600 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35601 * @return {Boolean}
35603 hasPanel : function(panel){
35604 if(typeof panel == "object"){ // must be panel obj
35605 panel = panel.getId();
35607 return this.getPanel(panel) ? true : false;
35611 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
35612 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35613 * @param {Boolean} preservePanel Overrides the config preservePanel option
35614 * @return {Roo.ContentPanel} The panel that was removed
35616 remove : function(panel, preservePanel){
35617 panel = this.getPanel(panel);
35622 this.fireEvent("beforeremove", this, panel, e);
35623 if(e.cancel === true){
35626 var panelId = panel.getId();
35627 this.panels.removeKey(panelId);
35632 * Returns the panel specified or null if it's not in this region.
35633 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
35634 * @return {Roo.ContentPanel}
35636 getPanel : function(id){
35637 if(typeof id == "object"){ // must be panel obj
35640 return this.panels.get(id);
35644 * Returns this regions position (north/south/east/west/center).
35647 getPosition: function(){
35648 return this.position;
35652 * Ext JS Library 1.1.1
35653 * Copyright(c) 2006-2007, Ext JS, LLC.
35655 * Originally Released Under LGPL - original licence link has changed is not relivant.
35658 * <script type="text/javascript">
35662 * @class Roo.bootstrap.layout.Region
35663 * @extends Roo.bootstrap.layout.Basic
35664 * This class represents a region in a layout manager.
35666 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
35667 * @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})
35668 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
35669 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
35670 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
35671 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
35672 * @cfg {String} title The title for the region (overrides panel titles)
35673 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
35674 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
35675 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
35676 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
35677 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
35678 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
35679 * the space available, similar to FireFox 1.5 tabs (defaults to false)
35680 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
35681 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
35682 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
35684 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
35685 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
35686 * @cfg {Boolean} disableTabTips True to disable tab tooltips
35687 * @cfg {Number} width For East/West panels
35688 * @cfg {Number} height For North/South panels
35689 * @cfg {Boolean} split To show the splitter
35690 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
35692 * @cfg {string} cls Extra CSS classes to add to region
35694 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
35695 * @cfg {string} region the region that it inhabits..
35698 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
35699 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
35701 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
35702 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
35703 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
35705 Roo.bootstrap.layout.Region = function(config)
35707 this.applyConfig(config);
35709 var mgr = config.mgr;
35710 var pos = config.region;
35711 config.skipConfig = true;
35712 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
35715 this.onRender(mgr.el);
35718 this.visible = true;
35719 this.collapsed = false;
35720 this.unrendered_panels = [];
35723 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
35725 position: '', // set by wrapper (eg. north/south etc..)
35726 unrendered_panels : null, // unrendered panels.
35727 createBody : function(){
35728 /** This region's body element
35729 * @type Roo.Element */
35730 this.bodyEl = this.el.createChild({
35732 cls: "roo-layout-panel-body tab-content" // bootstrap added...
35736 onRender: function(ctr, pos)
35738 var dh = Roo.DomHelper;
35739 /** This region's container element
35740 * @type Roo.Element */
35741 this.el = dh.append(ctr.dom, {
35743 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
35745 /** This region's title element
35746 * @type Roo.Element */
35748 this.titleEl = dh.append(this.el.dom,
35751 unselectable: "on",
35752 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
35754 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
35755 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
35758 this.titleEl.enableDisplayMode();
35759 /** This region's title text element
35760 * @type HTMLElement */
35761 this.titleTextEl = this.titleEl.dom.firstChild;
35762 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
35764 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
35765 this.closeBtn.enableDisplayMode();
35766 this.closeBtn.on("click", this.closeClicked, this);
35767 this.closeBtn.hide();
35769 this.createBody(this.config);
35770 if(this.config.hideWhenEmpty){
35772 this.on("paneladded", this.validateVisibility, this);
35773 this.on("panelremoved", this.validateVisibility, this);
35775 if(this.autoScroll){
35776 this.bodyEl.setStyle("overflow", "auto");
35778 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
35780 //if(c.titlebar !== false){
35781 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
35782 this.titleEl.hide();
35784 this.titleEl.show();
35785 if(this.config.title){
35786 this.titleTextEl.innerHTML = this.config.title;
35790 if(this.config.collapsed){
35791 this.collapse(true);
35793 if(this.config.hidden){
35797 if (this.unrendered_panels && this.unrendered_panels.length) {
35798 for (var i =0;i< this.unrendered_panels.length; i++) {
35799 this.add(this.unrendered_panels[i]);
35801 this.unrendered_panels = null;
35807 applyConfig : function(c)
35810 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
35811 var dh = Roo.DomHelper;
35812 if(c.titlebar !== false){
35813 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
35814 this.collapseBtn.on("click", this.collapse, this);
35815 this.collapseBtn.enableDisplayMode();
35817 if(c.showPin === true || this.showPin){
35818 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
35819 this.stickBtn.enableDisplayMode();
35820 this.stickBtn.on("click", this.expand, this);
35821 this.stickBtn.hide();
35826 /** This region's collapsed element
35827 * @type Roo.Element */
35830 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
35831 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
35834 if(c.floatable !== false){
35835 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
35836 this.collapsedEl.on("click", this.collapseClick, this);
35839 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
35840 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
35841 id: "message", unselectable: "on", style:{"float":"left"}});
35842 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
35844 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
35845 this.expandBtn.on("click", this.expand, this);
35849 if(this.collapseBtn){
35850 this.collapseBtn.setVisible(c.collapsible == true);
35853 this.cmargins = c.cmargins || this.cmargins ||
35854 (this.position == "west" || this.position == "east" ?
35855 {top: 0, left: 2, right:2, bottom: 0} :
35856 {top: 2, left: 0, right:0, bottom: 2});
35858 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
35861 this.bottomTabs = c.tabPosition != "top";
35863 this.autoScroll = c.autoScroll || false;
35868 this.duration = c.duration || .30;
35869 this.slideDuration = c.slideDuration || .45;
35874 * Returns true if this region is currently visible.
35875 * @return {Boolean}
35877 isVisible : function(){
35878 return this.visible;
35882 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
35883 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
35885 //setCollapsedTitle : function(title){
35886 // title = title || " ";
35887 // if(this.collapsedTitleTextEl){
35888 // this.collapsedTitleTextEl.innerHTML = title;
35892 getBox : function(){
35894 // if(!this.collapsed){
35895 b = this.el.getBox(false, true);
35897 // b = this.collapsedEl.getBox(false, true);
35902 getMargins : function(){
35903 return this.margins;
35904 //return this.collapsed ? this.cmargins : this.margins;
35907 highlight : function(){
35908 this.el.addClass("x-layout-panel-dragover");
35911 unhighlight : function(){
35912 this.el.removeClass("x-layout-panel-dragover");
35915 updateBox : function(box)
35917 if (!this.bodyEl) {
35918 return; // not rendered yet..
35922 if(!this.collapsed){
35923 this.el.dom.style.left = box.x + "px";
35924 this.el.dom.style.top = box.y + "px";
35925 this.updateBody(box.width, box.height);
35927 this.collapsedEl.dom.style.left = box.x + "px";
35928 this.collapsedEl.dom.style.top = box.y + "px";
35929 this.collapsedEl.setSize(box.width, box.height);
35932 this.tabs.autoSizeTabs();
35936 updateBody : function(w, h)
35939 this.el.setWidth(w);
35940 w -= this.el.getBorderWidth("rl");
35941 if(this.config.adjustments){
35942 w += this.config.adjustments[0];
35945 if(h !== null && h > 0){
35946 this.el.setHeight(h);
35947 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
35948 h -= this.el.getBorderWidth("tb");
35949 if(this.config.adjustments){
35950 h += this.config.adjustments[1];
35952 this.bodyEl.setHeight(h);
35954 h = this.tabs.syncHeight(h);
35957 if(this.panelSize){
35958 w = w !== null ? w : this.panelSize.width;
35959 h = h !== null ? h : this.panelSize.height;
35961 if(this.activePanel){
35962 var el = this.activePanel.getEl();
35963 w = w !== null ? w : el.getWidth();
35964 h = h !== null ? h : el.getHeight();
35965 this.panelSize = {width: w, height: h};
35966 this.activePanel.setSize(w, h);
35968 if(Roo.isIE && this.tabs){
35969 this.tabs.el.repaint();
35974 * Returns the container element for this region.
35975 * @return {Roo.Element}
35977 getEl : function(){
35982 * Hides this region.
35985 //if(!this.collapsed){
35986 this.el.dom.style.left = "-2000px";
35989 // this.collapsedEl.dom.style.left = "-2000px";
35990 // this.collapsedEl.hide();
35992 this.visible = false;
35993 this.fireEvent("visibilitychange", this, false);
35997 * Shows this region if it was previously hidden.
36000 //if(!this.collapsed){
36003 // this.collapsedEl.show();
36005 this.visible = true;
36006 this.fireEvent("visibilitychange", this, true);
36009 closeClicked : function(){
36010 if(this.activePanel){
36011 this.remove(this.activePanel);
36015 collapseClick : function(e){
36017 e.stopPropagation();
36020 e.stopPropagation();
36026 * Collapses this region.
36027 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
36030 collapse : function(skipAnim, skipCheck = false){
36031 if(this.collapsed) {
36035 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
36037 this.collapsed = true;
36039 this.split.el.hide();
36041 if(this.config.animate && skipAnim !== true){
36042 this.fireEvent("invalidated", this);
36043 this.animateCollapse();
36045 this.el.setLocation(-20000,-20000);
36047 this.collapsedEl.show();
36048 this.fireEvent("collapsed", this);
36049 this.fireEvent("invalidated", this);
36055 animateCollapse : function(){
36060 * Expands this region if it was previously collapsed.
36061 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
36062 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
36065 expand : function(e, skipAnim){
36067 e.stopPropagation();
36069 if(!this.collapsed || this.el.hasActiveFx()) {
36073 this.afterSlideIn();
36076 this.collapsed = false;
36077 if(this.config.animate && skipAnim !== true){
36078 this.animateExpand();
36082 this.split.el.show();
36084 this.collapsedEl.setLocation(-2000,-2000);
36085 this.collapsedEl.hide();
36086 this.fireEvent("invalidated", this);
36087 this.fireEvent("expanded", this);
36091 animateExpand : function(){
36095 initTabs : function()
36097 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
36099 var ts = new Roo.bootstrap.panel.Tabs({
36100 el: this.bodyEl.dom,
36101 tabPosition: this.bottomTabs ? 'bottom' : 'top',
36102 disableTooltips: this.config.disableTabTips,
36103 toolbar : this.config.toolbar
36106 if(this.config.hideTabs){
36107 ts.stripWrap.setDisplayed(false);
36110 ts.resizeTabs = this.config.resizeTabs === true;
36111 ts.minTabWidth = this.config.minTabWidth || 40;
36112 ts.maxTabWidth = this.config.maxTabWidth || 250;
36113 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
36114 ts.monitorResize = false;
36115 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
36116 ts.bodyEl.addClass('roo-layout-tabs-body');
36117 this.panels.each(this.initPanelAsTab, this);
36120 initPanelAsTab : function(panel){
36121 var ti = this.tabs.addTab(
36125 this.config.closeOnTab && panel.isClosable(),
36128 if(panel.tabTip !== undefined){
36129 ti.setTooltip(panel.tabTip);
36131 ti.on("activate", function(){
36132 this.setActivePanel(panel);
36135 if(this.config.closeOnTab){
36136 ti.on("beforeclose", function(t, e){
36138 this.remove(panel);
36142 panel.tabItem = ti;
36147 updatePanelTitle : function(panel, title)
36149 if(this.activePanel == panel){
36150 this.updateTitle(title);
36153 var ti = this.tabs.getTab(panel.getEl().id);
36155 if(panel.tabTip !== undefined){
36156 ti.setTooltip(panel.tabTip);
36161 updateTitle : function(title){
36162 if(this.titleTextEl && !this.config.title){
36163 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
36167 setActivePanel : function(panel)
36169 panel = this.getPanel(panel);
36170 if(this.activePanel && this.activePanel != panel){
36171 if(this.activePanel.setActiveState(false) === false){
36175 this.activePanel = panel;
36176 panel.setActiveState(true);
36177 if(this.panelSize){
36178 panel.setSize(this.panelSize.width, this.panelSize.height);
36181 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
36183 this.updateTitle(panel.getTitle());
36185 this.fireEvent("invalidated", this);
36187 this.fireEvent("panelactivated", this, panel);
36191 * Shows the specified panel.
36192 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
36193 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
36195 showPanel : function(panel)
36197 panel = this.getPanel(panel);
36200 var tab = this.tabs.getTab(panel.getEl().id);
36201 if(tab.isHidden()){
36202 this.tabs.unhideTab(tab.id);
36206 this.setActivePanel(panel);
36213 * Get the active panel for this region.
36214 * @return {Roo.ContentPanel} The active panel or null
36216 getActivePanel : function(){
36217 return this.activePanel;
36220 validateVisibility : function(){
36221 if(this.panels.getCount() < 1){
36222 this.updateTitle(" ");
36223 this.closeBtn.hide();
36226 if(!this.isVisible()){
36233 * Adds the passed ContentPanel(s) to this region.
36234 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
36235 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
36237 add : function(panel)
36239 if(arguments.length > 1){
36240 for(var i = 0, len = arguments.length; i < len; i++) {
36241 this.add(arguments[i]);
36246 // if we have not been rendered yet, then we can not really do much of this..
36247 if (!this.bodyEl) {
36248 this.unrendered_panels.push(panel);
36255 if(this.hasPanel(panel)){
36256 this.showPanel(panel);
36259 panel.setRegion(this);
36260 this.panels.add(panel);
36261 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
36262 // sinle panel - no tab...?? would it not be better to render it with the tabs,
36263 // and hide them... ???
36264 this.bodyEl.dom.appendChild(panel.getEl().dom);
36265 if(panel.background !== true){
36266 this.setActivePanel(panel);
36268 this.fireEvent("paneladded", this, panel);
36275 this.initPanelAsTab(panel);
36279 if(panel.background !== true){
36280 this.tabs.activate(panel.getEl().id);
36282 this.fireEvent("paneladded", this, panel);
36287 * Hides the tab for the specified panel.
36288 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36290 hidePanel : function(panel){
36291 if(this.tabs && (panel = this.getPanel(panel))){
36292 this.tabs.hideTab(panel.getEl().id);
36297 * Unhides the tab for a previously hidden panel.
36298 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36300 unhidePanel : function(panel){
36301 if(this.tabs && (panel = this.getPanel(panel))){
36302 this.tabs.unhideTab(panel.getEl().id);
36306 clearPanels : function(){
36307 while(this.panels.getCount() > 0){
36308 this.remove(this.panels.first());
36313 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
36314 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
36315 * @param {Boolean} preservePanel Overrides the config preservePanel option
36316 * @return {Roo.ContentPanel} The panel that was removed
36318 remove : function(panel, preservePanel)
36320 panel = this.getPanel(panel);
36325 this.fireEvent("beforeremove", this, panel, e);
36326 if(e.cancel === true){
36329 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
36330 var panelId = panel.getId();
36331 this.panels.removeKey(panelId);
36333 document.body.appendChild(panel.getEl().dom);
36336 this.tabs.removeTab(panel.getEl().id);
36337 }else if (!preservePanel){
36338 this.bodyEl.dom.removeChild(panel.getEl().dom);
36340 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
36341 var p = this.panels.first();
36342 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
36343 tempEl.appendChild(p.getEl().dom);
36344 this.bodyEl.update("");
36345 this.bodyEl.dom.appendChild(p.getEl().dom);
36347 this.updateTitle(p.getTitle());
36349 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
36350 this.setActivePanel(p);
36352 panel.setRegion(null);
36353 if(this.activePanel == panel){
36354 this.activePanel = null;
36356 if(this.config.autoDestroy !== false && preservePanel !== true){
36357 try{panel.destroy();}catch(e){}
36359 this.fireEvent("panelremoved", this, panel);
36364 * Returns the TabPanel component used by this region
36365 * @return {Roo.TabPanel}
36367 getTabs : function(){
36371 createTool : function(parentEl, className){
36372 var btn = Roo.DomHelper.append(parentEl, {
36374 cls: "x-layout-tools-button",
36377 cls: "roo-layout-tools-button-inner " + className,
36381 btn.addClassOnOver("roo-layout-tools-button-over");
36386 * Ext JS Library 1.1.1
36387 * Copyright(c) 2006-2007, Ext JS, LLC.
36389 * Originally Released Under LGPL - original licence link has changed is not relivant.
36392 * <script type="text/javascript">
36398 * @class Roo.SplitLayoutRegion
36399 * @extends Roo.LayoutRegion
36400 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
36402 Roo.bootstrap.layout.Split = function(config){
36403 this.cursor = config.cursor;
36404 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
36407 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
36409 splitTip : "Drag to resize.",
36410 collapsibleSplitTip : "Drag to resize. Double click to hide.",
36411 useSplitTips : false,
36413 applyConfig : function(config){
36414 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
36417 onRender : function(ctr,pos) {
36419 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
36420 if(!this.config.split){
36425 var splitEl = Roo.DomHelper.append(ctr.dom, {
36427 id: this.el.id + "-split",
36428 cls: "roo-layout-split roo-layout-split-"+this.position,
36431 /** The SplitBar for this region
36432 * @type Roo.SplitBar */
36433 // does not exist yet...
36434 Roo.log([this.position, this.orientation]);
36436 this.split = new Roo.bootstrap.SplitBar({
36437 dragElement : splitEl,
36438 resizingElement: this.el,
36439 orientation : this.orientation
36442 this.split.on("moved", this.onSplitMove, this);
36443 this.split.useShim = this.config.useShim === true;
36444 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
36445 if(this.useSplitTips){
36446 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
36448 //if(config.collapsible){
36449 // this.split.el.on("dblclick", this.collapse, this);
36452 if(typeof this.config.minSize != "undefined"){
36453 this.split.minSize = this.config.minSize;
36455 if(typeof this.config.maxSize != "undefined"){
36456 this.split.maxSize = this.config.maxSize;
36458 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
36459 this.hideSplitter();
36464 getHMaxSize : function(){
36465 var cmax = this.config.maxSize || 10000;
36466 var center = this.mgr.getRegion("center");
36467 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
36470 getVMaxSize : function(){
36471 var cmax = this.config.maxSize || 10000;
36472 var center = this.mgr.getRegion("center");
36473 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
36476 onSplitMove : function(split, newSize){
36477 this.fireEvent("resized", this, newSize);
36481 * Returns the {@link Roo.SplitBar} for this region.
36482 * @return {Roo.SplitBar}
36484 getSplitBar : function(){
36489 this.hideSplitter();
36490 Roo.bootstrap.layout.Split.superclass.hide.call(this);
36493 hideSplitter : function(){
36495 this.split.el.setLocation(-2000,-2000);
36496 this.split.el.hide();
36502 this.split.el.show();
36504 Roo.bootstrap.layout.Split.superclass.show.call(this);
36507 beforeSlide: function(){
36508 if(Roo.isGecko){// firefox overflow auto bug workaround
36509 this.bodyEl.clip();
36511 this.tabs.bodyEl.clip();
36513 if(this.activePanel){
36514 this.activePanel.getEl().clip();
36516 if(this.activePanel.beforeSlide){
36517 this.activePanel.beforeSlide();
36523 afterSlide : function(){
36524 if(Roo.isGecko){// firefox overflow auto bug workaround
36525 this.bodyEl.unclip();
36527 this.tabs.bodyEl.unclip();
36529 if(this.activePanel){
36530 this.activePanel.getEl().unclip();
36531 if(this.activePanel.afterSlide){
36532 this.activePanel.afterSlide();
36538 initAutoHide : function(){
36539 if(this.autoHide !== false){
36540 if(!this.autoHideHd){
36541 var st = new Roo.util.DelayedTask(this.slideIn, this);
36542 this.autoHideHd = {
36543 "mouseout": function(e){
36544 if(!e.within(this.el, true)){
36548 "mouseover" : function(e){
36554 this.el.on(this.autoHideHd);
36558 clearAutoHide : function(){
36559 if(this.autoHide !== false){
36560 this.el.un("mouseout", this.autoHideHd.mouseout);
36561 this.el.un("mouseover", this.autoHideHd.mouseover);
36565 clearMonitor : function(){
36566 Roo.get(document).un("click", this.slideInIf, this);
36569 // these names are backwards but not changed for compat
36570 slideOut : function(){
36571 if(this.isSlid || this.el.hasActiveFx()){
36574 this.isSlid = true;
36575 if(this.collapseBtn){
36576 this.collapseBtn.hide();
36578 this.closeBtnState = this.closeBtn.getStyle('display');
36579 this.closeBtn.hide();
36581 this.stickBtn.show();
36584 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
36585 this.beforeSlide();
36586 this.el.setStyle("z-index", 10001);
36587 this.el.slideIn(this.getSlideAnchor(), {
36588 callback: function(){
36590 this.initAutoHide();
36591 Roo.get(document).on("click", this.slideInIf, this);
36592 this.fireEvent("slideshow", this);
36599 afterSlideIn : function(){
36600 this.clearAutoHide();
36601 this.isSlid = false;
36602 this.clearMonitor();
36603 this.el.setStyle("z-index", "");
36604 if(this.collapseBtn){
36605 this.collapseBtn.show();
36607 this.closeBtn.setStyle('display', this.closeBtnState);
36609 this.stickBtn.hide();
36611 this.fireEvent("slidehide", this);
36614 slideIn : function(cb){
36615 if(!this.isSlid || this.el.hasActiveFx()){
36619 this.isSlid = false;
36620 this.beforeSlide();
36621 this.el.slideOut(this.getSlideAnchor(), {
36622 callback: function(){
36623 this.el.setLeftTop(-10000, -10000);
36625 this.afterSlideIn();
36633 slideInIf : function(e){
36634 if(!e.within(this.el)){
36639 animateCollapse : function(){
36640 this.beforeSlide();
36641 this.el.setStyle("z-index", 20000);
36642 var anchor = this.getSlideAnchor();
36643 this.el.slideOut(anchor, {
36644 callback : function(){
36645 this.el.setStyle("z-index", "");
36646 this.collapsedEl.slideIn(anchor, {duration:.3});
36648 this.el.setLocation(-10000,-10000);
36650 this.fireEvent("collapsed", this);
36657 animateExpand : function(){
36658 this.beforeSlide();
36659 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
36660 this.el.setStyle("z-index", 20000);
36661 this.collapsedEl.hide({
36664 this.el.slideIn(this.getSlideAnchor(), {
36665 callback : function(){
36666 this.el.setStyle("z-index", "");
36669 this.split.el.show();
36671 this.fireEvent("invalidated", this);
36672 this.fireEvent("expanded", this);
36700 getAnchor : function(){
36701 return this.anchors[this.position];
36704 getCollapseAnchor : function(){
36705 return this.canchors[this.position];
36708 getSlideAnchor : function(){
36709 return this.sanchors[this.position];
36712 getAlignAdj : function(){
36713 var cm = this.cmargins;
36714 switch(this.position){
36730 getExpandAdj : function(){
36731 var c = this.collapsedEl, cm = this.cmargins;
36732 switch(this.position){
36734 return [-(cm.right+c.getWidth()+cm.left), 0];
36737 return [cm.right+c.getWidth()+cm.left, 0];
36740 return [0, -(cm.top+cm.bottom+c.getHeight())];
36743 return [0, cm.top+cm.bottom+c.getHeight()];
36749 * Ext JS Library 1.1.1
36750 * Copyright(c) 2006-2007, Ext JS, LLC.
36752 * Originally Released Under LGPL - original licence link has changed is not relivant.
36755 * <script type="text/javascript">
36758 * These classes are private internal classes
36760 Roo.bootstrap.layout.Center = function(config){
36761 config.region = "center";
36762 Roo.bootstrap.layout.Region.call(this, config);
36763 this.visible = true;
36764 this.minWidth = config.minWidth || 20;
36765 this.minHeight = config.minHeight || 20;
36768 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
36770 // center panel can't be hidden
36774 // center panel can't be hidden
36777 getMinWidth: function(){
36778 return this.minWidth;
36781 getMinHeight: function(){
36782 return this.minHeight;
36795 Roo.bootstrap.layout.North = function(config)
36797 config.region = 'north';
36798 config.cursor = 'n-resize';
36800 Roo.bootstrap.layout.Split.call(this, config);
36804 this.split.placement = Roo.bootstrap.SplitBar.TOP;
36805 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
36806 this.split.el.addClass("roo-layout-split-v");
36808 var size = config.initialSize || config.height;
36809 if(typeof size != "undefined"){
36810 this.el.setHeight(size);
36813 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
36815 orientation: Roo.bootstrap.SplitBar.VERTICAL,
36819 getBox : function(){
36820 if(this.collapsed){
36821 return this.collapsedEl.getBox();
36823 var box = this.el.getBox();
36825 box.height += this.split.el.getHeight();
36830 updateBox : function(box){
36831 if(this.split && !this.collapsed){
36832 box.height -= this.split.el.getHeight();
36833 this.split.el.setLeft(box.x);
36834 this.split.el.setTop(box.y+box.height);
36835 this.split.el.setWidth(box.width);
36837 if(this.collapsed){
36838 this.updateBody(box.width, null);
36840 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36848 Roo.bootstrap.layout.South = function(config){
36849 config.region = 'south';
36850 config.cursor = 's-resize';
36851 Roo.bootstrap.layout.Split.call(this, config);
36853 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
36854 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
36855 this.split.el.addClass("roo-layout-split-v");
36857 var size = config.initialSize || config.height;
36858 if(typeof size != "undefined"){
36859 this.el.setHeight(size);
36863 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
36864 orientation: Roo.bootstrap.SplitBar.VERTICAL,
36865 getBox : function(){
36866 if(this.collapsed){
36867 return this.collapsedEl.getBox();
36869 var box = this.el.getBox();
36871 var sh = this.split.el.getHeight();
36878 updateBox : function(box){
36879 if(this.split && !this.collapsed){
36880 var sh = this.split.el.getHeight();
36883 this.split.el.setLeft(box.x);
36884 this.split.el.setTop(box.y-sh);
36885 this.split.el.setWidth(box.width);
36887 if(this.collapsed){
36888 this.updateBody(box.width, null);
36890 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36894 Roo.bootstrap.layout.East = function(config){
36895 config.region = "east";
36896 config.cursor = "e-resize";
36897 Roo.bootstrap.layout.Split.call(this, config);
36899 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
36900 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
36901 this.split.el.addClass("roo-layout-split-h");
36903 var size = config.initialSize || config.width;
36904 if(typeof size != "undefined"){
36905 this.el.setWidth(size);
36908 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
36909 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
36910 getBox : function(){
36911 if(this.collapsed){
36912 return this.collapsedEl.getBox();
36914 var box = this.el.getBox();
36916 var sw = this.split.el.getWidth();
36923 updateBox : function(box){
36924 if(this.split && !this.collapsed){
36925 var sw = this.split.el.getWidth();
36927 this.split.el.setLeft(box.x);
36928 this.split.el.setTop(box.y);
36929 this.split.el.setHeight(box.height);
36932 if(this.collapsed){
36933 this.updateBody(null, box.height);
36935 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36939 Roo.bootstrap.layout.West = function(config){
36940 config.region = "west";
36941 config.cursor = "w-resize";
36943 Roo.bootstrap.layout.Split.call(this, config);
36945 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
36946 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
36947 this.split.el.addClass("roo-layout-split-h");
36951 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
36952 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
36954 onRender: function(ctr, pos)
36956 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
36957 var size = this.config.initialSize || this.config.width;
36958 if(typeof size != "undefined"){
36959 this.el.setWidth(size);
36963 getBox : function(){
36964 if(this.collapsed){
36965 return this.collapsedEl.getBox();
36967 var box = this.el.getBox();
36969 box.width += this.split.el.getWidth();
36974 updateBox : function(box){
36975 if(this.split && !this.collapsed){
36976 var sw = this.split.el.getWidth();
36978 this.split.el.setLeft(box.x+box.width);
36979 this.split.el.setTop(box.y);
36980 this.split.el.setHeight(box.height);
36982 if(this.collapsed){
36983 this.updateBody(null, box.height);
36985 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
36988 Roo.namespace("Roo.bootstrap.panel");/*
36990 * Ext JS Library 1.1.1
36991 * Copyright(c) 2006-2007, Ext JS, LLC.
36993 * Originally Released Under LGPL - original licence link has changed is not relivant.
36996 * <script type="text/javascript">
36999 * @class Roo.ContentPanel
37000 * @extends Roo.util.Observable
37001 * A basic ContentPanel element.
37002 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
37003 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
37004 * @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
37005 * @cfg {Boolean} closable True if the panel can be closed/removed
37006 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
37007 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
37008 * @cfg {Toolbar} toolbar A toolbar for this panel
37009 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
37010 * @cfg {String} title The title for this panel
37011 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
37012 * @cfg {String} url Calls {@link #setUrl} with this value
37013 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
37014 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
37015 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
37016 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
37017 * @cfg {Boolean} badges render the badges
37020 * Create a new ContentPanel.
37021 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
37022 * @param {String/Object} config A string to set only the title or a config object
37023 * @param {String} content (optional) Set the HTML content for this panel
37024 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
37026 Roo.bootstrap.panel.Content = function( config){
37028 this.tpl = config.tpl || false;
37030 var el = config.el;
37031 var content = config.content;
37033 if(config.autoCreate){ // xtype is available if this is called from factory
37036 this.el = Roo.get(el);
37037 if(!this.el && config && config.autoCreate){
37038 if(typeof config.autoCreate == "object"){
37039 if(!config.autoCreate.id){
37040 config.autoCreate.id = config.id||el;
37042 this.el = Roo.DomHelper.append(document.body,
37043 config.autoCreate, true);
37045 var elcfg = { tag: "div",
37046 cls: "roo-layout-inactive-content",
37050 elcfg.html = config.html;
37054 this.el = Roo.DomHelper.append(document.body, elcfg , true);
37057 this.closable = false;
37058 this.loaded = false;
37059 this.active = false;
37062 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
37064 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
37066 this.wrapEl = this.el; //this.el.wrap();
37068 if (config.toolbar.items) {
37069 ti = config.toolbar.items ;
37070 delete config.toolbar.items ;
37074 this.toolbar.render(this.wrapEl, 'before');
37075 for(var i =0;i < ti.length;i++) {
37076 // Roo.log(['add child', items[i]]);
37077 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37079 this.toolbar.items = nitems;
37080 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
37081 delete config.toolbar;
37085 // xtype created footer. - not sure if will work as we normally have to render first..
37086 if (this.footer && !this.footer.el && this.footer.xtype) {
37087 if (!this.wrapEl) {
37088 this.wrapEl = this.el.wrap();
37091 this.footer.container = this.wrapEl.createChild();
37093 this.footer = Roo.factory(this.footer, Roo);
37098 if(typeof config == "string"){
37099 this.title = config;
37101 Roo.apply(this, config);
37105 this.resizeEl = Roo.get(this.resizeEl, true);
37107 this.resizeEl = this.el;
37109 // handle view.xtype
37117 * Fires when this panel is activated.
37118 * @param {Roo.ContentPanel} this
37122 * @event deactivate
37123 * Fires when this panel is activated.
37124 * @param {Roo.ContentPanel} this
37126 "deactivate" : true,
37130 * Fires when this panel is resized if fitToFrame is true.
37131 * @param {Roo.ContentPanel} this
37132 * @param {Number} width The width after any component adjustments
37133 * @param {Number} height The height after any component adjustments
37139 * Fires when this tab is created
37140 * @param {Roo.ContentPanel} this
37151 if(this.autoScroll){
37152 this.resizeEl.setStyle("overflow", "auto");
37154 // fix randome scrolling
37155 //this.el.on('scroll', function() {
37156 // Roo.log('fix random scolling');
37157 // this.scrollTo('top',0);
37160 content = content || this.content;
37162 this.setContent(content);
37164 if(config && config.url){
37165 this.setUrl(this.url, this.params, this.loadOnce);
37170 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
37172 if (this.view && typeof(this.view.xtype) != 'undefined') {
37173 this.view.el = this.el.appendChild(document.createElement("div"));
37174 this.view = Roo.factory(this.view);
37175 this.view.render && this.view.render(false, '');
37179 this.fireEvent('render', this);
37182 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
37186 setRegion : function(region){
37187 this.region = region;
37188 this.setActiveClass(region && !this.background);
37192 setActiveClass: function(state)
37195 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
37196 this.el.setStyle('position','relative');
37198 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
37199 this.el.setStyle('position', 'absolute');
37204 * Returns the toolbar for this Panel if one was configured.
37205 * @return {Roo.Toolbar}
37207 getToolbar : function(){
37208 return this.toolbar;
37211 setActiveState : function(active)
37213 this.active = active;
37214 this.setActiveClass(active);
37216 if(this.fireEvent("deactivate", this) === false){
37221 this.fireEvent("activate", this);
37225 * Updates this panel's element
37226 * @param {String} content The new content
37227 * @param {Boolean} loadScripts (optional) true to look for and process scripts
37229 setContent : function(content, loadScripts){
37230 this.el.update(content, loadScripts);
37233 ignoreResize : function(w, h){
37234 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
37237 this.lastSize = {width: w, height: h};
37242 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
37243 * @return {Roo.UpdateManager} The UpdateManager
37245 getUpdateManager : function(){
37246 return this.el.getUpdateManager();
37249 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
37250 * @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:
37253 url: "your-url.php",
37254 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
37255 callback: yourFunction,
37256 scope: yourObject, //(optional scope)
37259 text: "Loading...",
37264 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
37265 * 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.
37266 * @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}
37267 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
37268 * @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.
37269 * @return {Roo.ContentPanel} this
37272 var um = this.el.getUpdateManager();
37273 um.update.apply(um, arguments);
37279 * 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.
37280 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
37281 * @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)
37282 * @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)
37283 * @return {Roo.UpdateManager} The UpdateManager
37285 setUrl : function(url, params, loadOnce){
37286 if(this.refreshDelegate){
37287 this.removeListener("activate", this.refreshDelegate);
37289 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
37290 this.on("activate", this.refreshDelegate);
37291 return this.el.getUpdateManager();
37294 _handleRefresh : function(url, params, loadOnce){
37295 if(!loadOnce || !this.loaded){
37296 var updater = this.el.getUpdateManager();
37297 updater.update(url, params, this._setLoaded.createDelegate(this));
37301 _setLoaded : function(){
37302 this.loaded = true;
37306 * Returns this panel's id
37309 getId : function(){
37314 * Returns this panel's element - used by regiosn to add.
37315 * @return {Roo.Element}
37317 getEl : function(){
37318 return this.wrapEl || this.el;
37323 adjustForComponents : function(width, height)
37325 //Roo.log('adjustForComponents ');
37326 if(this.resizeEl != this.el){
37327 width -= this.el.getFrameWidth('lr');
37328 height -= this.el.getFrameWidth('tb');
37331 var te = this.toolbar.getEl();
37332 te.setWidth(width);
37333 height -= te.getHeight();
37336 var te = this.footer.getEl();
37337 te.setWidth(width);
37338 height -= te.getHeight();
37342 if(this.adjustments){
37343 width += this.adjustments[0];
37344 height += this.adjustments[1];
37346 return {"width": width, "height": height};
37349 setSize : function(width, height){
37350 if(this.fitToFrame && !this.ignoreResize(width, height)){
37351 if(this.fitContainer && this.resizeEl != this.el){
37352 this.el.setSize(width, height);
37354 var size = this.adjustForComponents(width, height);
37355 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
37356 this.fireEvent('resize', this, size.width, size.height);
37361 * Returns this panel's title
37364 getTitle : function(){
37366 if (typeof(this.title) != 'object') {
37371 for (var k in this.title) {
37372 if (!this.title.hasOwnProperty(k)) {
37376 if (k.indexOf('-') >= 0) {
37377 var s = k.split('-');
37378 for (var i = 0; i<s.length; i++) {
37379 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
37382 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
37389 * Set this panel's title
37390 * @param {String} title
37392 setTitle : function(title){
37393 this.title = title;
37395 this.region.updatePanelTitle(this, title);
37400 * Returns true is this panel was configured to be closable
37401 * @return {Boolean}
37403 isClosable : function(){
37404 return this.closable;
37407 beforeSlide : function(){
37409 this.resizeEl.clip();
37412 afterSlide : function(){
37414 this.resizeEl.unclip();
37418 * Force a content refresh from the URL specified in the {@link #setUrl} method.
37419 * Will fail silently if the {@link #setUrl} method has not been called.
37420 * This does not activate the panel, just updates its content.
37422 refresh : function(){
37423 if(this.refreshDelegate){
37424 this.loaded = false;
37425 this.refreshDelegate();
37430 * Destroys this panel
37432 destroy : function(){
37433 this.el.removeAllListeners();
37434 var tempEl = document.createElement("span");
37435 tempEl.appendChild(this.el.dom);
37436 tempEl.innerHTML = "";
37442 * form - if the content panel contains a form - this is a reference to it.
37443 * @type {Roo.form.Form}
37447 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
37448 * This contains a reference to it.
37454 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
37464 * @param {Object} cfg Xtype definition of item to add.
37468 getChildContainer: function () {
37469 return this.getEl();
37474 var ret = new Roo.factory(cfg);
37479 if (cfg.xtype.match(/^Form$/)) {
37482 //if (this.footer) {
37483 // el = this.footer.container.insertSibling(false, 'before');
37485 el = this.el.createChild();
37488 this.form = new Roo.form.Form(cfg);
37491 if ( this.form.allItems.length) {
37492 this.form.render(el.dom);
37496 // should only have one of theses..
37497 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
37498 // views.. should not be just added - used named prop 'view''
37500 cfg.el = this.el.appendChild(document.createElement("div"));
37503 var ret = new Roo.factory(cfg);
37505 ret.render && ret.render(false, ''); // render blank..
37515 * @class Roo.bootstrap.panel.Grid
37516 * @extends Roo.bootstrap.panel.Content
37518 * Create a new GridPanel.
37519 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
37520 * @param {Object} config A the config object
37526 Roo.bootstrap.panel.Grid = function(config)
37530 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
37531 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
37533 config.el = this.wrapper;
37534 //this.el = this.wrapper;
37536 if (config.container) {
37537 // ctor'ed from a Border/panel.grid
37540 this.wrapper.setStyle("overflow", "hidden");
37541 this.wrapper.addClass('roo-grid-container');
37546 if(config.toolbar){
37547 var tool_el = this.wrapper.createChild();
37548 this.toolbar = Roo.factory(config.toolbar);
37550 if (config.toolbar.items) {
37551 ti = config.toolbar.items ;
37552 delete config.toolbar.items ;
37556 this.toolbar.render(tool_el);
37557 for(var i =0;i < ti.length;i++) {
37558 // Roo.log(['add child', items[i]]);
37559 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
37561 this.toolbar.items = nitems;
37563 delete config.toolbar;
37566 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
37567 config.grid.scrollBody = true;;
37568 config.grid.monitorWindowResize = false; // turn off autosizing
37569 config.grid.autoHeight = false;
37570 config.grid.autoWidth = false;
37572 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
37574 if (config.background) {
37575 // render grid on panel activation (if panel background)
37576 this.on('activate', function(gp) {
37577 if (!gp.grid.rendered) {
37578 gp.grid.render(this.wrapper);
37579 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37584 this.grid.render(this.wrapper);
37585 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
37588 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
37589 // ??? needed ??? config.el = this.wrapper;
37594 // xtype created footer. - not sure if will work as we normally have to render first..
37595 if (this.footer && !this.footer.el && this.footer.xtype) {
37597 var ctr = this.grid.getView().getFooterPanel(true);
37598 this.footer.dataSource = this.grid.dataSource;
37599 this.footer = Roo.factory(this.footer, Roo);
37600 this.footer.render(ctr);
37610 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
37611 getId : function(){
37612 return this.grid.id;
37616 * Returns the grid for this panel
37617 * @return {Roo.bootstrap.Table}
37619 getGrid : function(){
37623 setSize : function(width, height){
37624 if(!this.ignoreResize(width, height)){
37625 var grid = this.grid;
37626 var size = this.adjustForComponents(width, height);
37627 var gridel = grid.getGridEl();
37628 gridel.setSize(size.width, size.height);
37630 var thd = grid.getGridEl().select('thead',true).first();
37631 var tbd = grid.getGridEl().select('tbody', true).first();
37633 tbd.setSize(width, height - thd.getHeight());
37642 beforeSlide : function(){
37643 this.grid.getView().scroller.clip();
37646 afterSlide : function(){
37647 this.grid.getView().scroller.unclip();
37650 destroy : function(){
37651 this.grid.destroy();
37653 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
37658 * @class Roo.bootstrap.panel.Nest
37659 * @extends Roo.bootstrap.panel.Content
37661 * Create a new Panel, that can contain a layout.Border.
37664 * @param {Roo.BorderLayout} layout The layout for this panel
37665 * @param {String/Object} config A string to set only the title or a config object
37667 Roo.bootstrap.panel.Nest = function(config)
37669 // construct with only one argument..
37670 /* FIXME - implement nicer consturctors
37671 if (layout.layout) {
37673 layout = config.layout;
37674 delete config.layout;
37676 if (layout.xtype && !layout.getEl) {
37677 // then layout needs constructing..
37678 layout = Roo.factory(layout, Roo);
37682 config.el = config.layout.getEl();
37684 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
37686 config.layout.monitorWindowResize = false; // turn off autosizing
37687 this.layout = config.layout;
37688 this.layout.getEl().addClass("roo-layout-nested-layout");
37695 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
37697 setSize : function(width, height){
37698 if(!this.ignoreResize(width, height)){
37699 var size = this.adjustForComponents(width, height);
37700 var el = this.layout.getEl();
37701 if (size.height < 1) {
37702 el.setWidth(size.width);
37704 el.setSize(size.width, size.height);
37706 var touch = el.dom.offsetWidth;
37707 this.layout.layout();
37708 // ie requires a double layout on the first pass
37709 if(Roo.isIE && !this.initialized){
37710 this.initialized = true;
37711 this.layout.layout();
37716 // activate all subpanels if not currently active..
37718 setActiveState : function(active){
37719 this.active = active;
37720 this.setActiveClass(active);
37723 this.fireEvent("deactivate", this);
37727 this.fireEvent("activate", this);
37728 // not sure if this should happen before or after..
37729 if (!this.layout) {
37730 return; // should not happen..
37733 for (var r in this.layout.regions) {
37734 reg = this.layout.getRegion(r);
37735 if (reg.getActivePanel()) {
37736 //reg.showPanel(reg.getActivePanel()); // force it to activate..
37737 reg.setActivePanel(reg.getActivePanel());
37740 if (!reg.panels.length) {
37743 reg.showPanel(reg.getPanel(0));
37752 * Returns the nested BorderLayout for this panel
37753 * @return {Roo.BorderLayout}
37755 getLayout : function(){
37756 return this.layout;
37760 * Adds a xtype elements to the layout of the nested panel
37764 xtype : 'ContentPanel',
37771 xtype : 'NestedLayoutPanel',
37777 items : [ ... list of content panels or nested layout panels.. ]
37781 * @param {Object} cfg Xtype definition of item to add.
37783 addxtype : function(cfg) {
37784 return this.layout.addxtype(cfg);
37789 * Ext JS Library 1.1.1
37790 * Copyright(c) 2006-2007, Ext JS, LLC.
37792 * Originally Released Under LGPL - original licence link has changed is not relivant.
37795 * <script type="text/javascript">
37798 * @class Roo.TabPanel
37799 * @extends Roo.util.Observable
37800 * A lightweight tab container.
37804 // basic tabs 1, built from existing content
37805 var tabs = new Roo.TabPanel("tabs1");
37806 tabs.addTab("script", "View Script");
37807 tabs.addTab("markup", "View Markup");
37808 tabs.activate("script");
37810 // more advanced tabs, built from javascript
37811 var jtabs = new Roo.TabPanel("jtabs");
37812 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
37814 // set up the UpdateManager
37815 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
37816 var updater = tab2.getUpdateManager();
37817 updater.setDefaultUrl("ajax1.htm");
37818 tab2.on('activate', updater.refresh, updater, true);
37820 // Use setUrl for Ajax loading
37821 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
37822 tab3.setUrl("ajax2.htm", null, true);
37825 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
37828 jtabs.activate("jtabs-1");
37831 * Create a new TabPanel.
37832 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
37833 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
37835 Roo.bootstrap.panel.Tabs = function(config){
37837 * The container element for this TabPanel.
37838 * @type Roo.Element
37840 this.el = Roo.get(config.el);
37843 if(typeof config == "boolean"){
37844 this.tabPosition = config ? "bottom" : "top";
37846 Roo.apply(this, config);
37850 if(this.tabPosition == "bottom"){
37851 this.bodyEl = Roo.get(this.createBody(this.el.dom));
37852 this.el.addClass("roo-tabs-bottom");
37854 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
37855 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
37856 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
37858 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
37860 if(this.tabPosition != "bottom"){
37861 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
37862 * @type Roo.Element
37864 this.bodyEl = Roo.get(this.createBody(this.el.dom));
37865 this.el.addClass("roo-tabs-top");
37869 this.bodyEl.setStyle("position", "relative");
37871 this.active = null;
37872 this.activateDelegate = this.activate.createDelegate(this);
37877 * Fires when the active tab changes
37878 * @param {Roo.TabPanel} this
37879 * @param {Roo.TabPanelItem} activePanel The new active tab
37883 * @event beforetabchange
37884 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
37885 * @param {Roo.TabPanel} this
37886 * @param {Object} e Set cancel to true on this object to cancel the tab change
37887 * @param {Roo.TabPanelItem} tab The tab being changed to
37889 "beforetabchange" : true
37892 Roo.EventManager.onWindowResize(this.onResize, this);
37893 this.cpad = this.el.getPadding("lr");
37894 this.hiddenCount = 0;
37897 // toolbar on the tabbar support...
37898 if (this.toolbar) {
37899 alert("no toolbar support yet");
37900 this.toolbar = false;
37902 var tcfg = this.toolbar;
37903 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
37904 this.toolbar = new Roo.Toolbar(tcfg);
37905 if (Roo.isSafari) {
37906 var tbl = tcfg.container.child('table', true);
37907 tbl.setAttribute('width', '100%');
37915 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
37918 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
37920 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
37922 tabPosition : "top",
37924 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
37926 currentTabWidth : 0,
37928 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
37932 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
37936 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
37938 preferredTabWidth : 175,
37940 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
37942 resizeTabs : false,
37944 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
37946 monitorResize : true,
37948 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
37953 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
37954 * @param {String} id The id of the div to use <b>or create</b>
37955 * @param {String} text The text for the tab
37956 * @param {String} content (optional) Content to put in the TabPanelItem body
37957 * @param {Boolean} closable (optional) True to create a close icon on the tab
37958 * @return {Roo.TabPanelItem} The created TabPanelItem
37960 addTab : function(id, text, content, closable, tpl)
37962 var item = new Roo.bootstrap.panel.TabItem({
37966 closable : closable,
37969 this.addTabItem(item);
37971 item.setContent(content);
37977 * Returns the {@link Roo.TabPanelItem} with the specified id/index
37978 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
37979 * @return {Roo.TabPanelItem}
37981 getTab : function(id){
37982 return this.items[id];
37986 * Hides the {@link Roo.TabPanelItem} with the specified id/index
37987 * @param {String/Number} id The id or index of the TabPanelItem to hide.
37989 hideTab : function(id){
37990 var t = this.items[id];
37993 this.hiddenCount++;
37994 this.autoSizeTabs();
37999 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
38000 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
38002 unhideTab : function(id){
38003 var t = this.items[id];
38005 t.setHidden(false);
38006 this.hiddenCount--;
38007 this.autoSizeTabs();
38012 * Adds an existing {@link Roo.TabPanelItem}.
38013 * @param {Roo.TabPanelItem} item The TabPanelItem to add
38015 addTabItem : function(item){
38016 this.items[item.id] = item;
38017 this.items.push(item);
38018 // if(this.resizeTabs){
38019 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
38020 // this.autoSizeTabs();
38022 // item.autoSize();
38027 * Removes a {@link Roo.TabPanelItem}.
38028 * @param {String/Number} id The id or index of the TabPanelItem to remove.
38030 removeTab : function(id){
38031 var items = this.items;
38032 var tab = items[id];
38033 if(!tab) { return; }
38034 var index = items.indexOf(tab);
38035 if(this.active == tab && items.length > 1){
38036 var newTab = this.getNextAvailable(index);
38041 this.stripEl.dom.removeChild(tab.pnode.dom);
38042 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
38043 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
38045 items.splice(index, 1);
38046 delete this.items[tab.id];
38047 tab.fireEvent("close", tab);
38048 tab.purgeListeners();
38049 this.autoSizeTabs();
38052 getNextAvailable : function(start){
38053 var items = this.items;
38055 // look for a next tab that will slide over to
38056 // replace the one being removed
38057 while(index < items.length){
38058 var item = items[++index];
38059 if(item && !item.isHidden()){
38063 // if one isn't found select the previous tab (on the left)
38066 var item = items[--index];
38067 if(item && !item.isHidden()){
38075 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
38076 * @param {String/Number} id The id or index of the TabPanelItem to disable.
38078 disableTab : function(id){
38079 var tab = this.items[id];
38080 if(tab && this.active != tab){
38086 * Enables a {@link Roo.TabPanelItem} that is disabled.
38087 * @param {String/Number} id The id or index of the TabPanelItem to enable.
38089 enableTab : function(id){
38090 var tab = this.items[id];
38095 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
38096 * @param {String/Number} id The id or index of the TabPanelItem to activate.
38097 * @return {Roo.TabPanelItem} The TabPanelItem.
38099 activate : function(id){
38100 var tab = this.items[id];
38104 if(tab == this.active || tab.disabled){
38108 this.fireEvent("beforetabchange", this, e, tab);
38109 if(e.cancel !== true && !tab.disabled){
38111 this.active.hide();
38113 this.active = this.items[id];
38114 this.active.show();
38115 this.fireEvent("tabchange", this, this.active);
38121 * Gets the active {@link Roo.TabPanelItem}.
38122 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
38124 getActiveTab : function(){
38125 return this.active;
38129 * Updates the tab body element to fit the height of the container element
38130 * for overflow scrolling
38131 * @param {Number} targetHeight (optional) Override the starting height from the elements height
38133 syncHeight : function(targetHeight){
38134 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
38135 var bm = this.bodyEl.getMargins();
38136 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
38137 this.bodyEl.setHeight(newHeight);
38141 onResize : function(){
38142 if(this.monitorResize){
38143 this.autoSizeTabs();
38148 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
38150 beginUpdate : function(){
38151 this.updating = true;
38155 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
38157 endUpdate : function(){
38158 this.updating = false;
38159 this.autoSizeTabs();
38163 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
38165 autoSizeTabs : function(){
38166 var count = this.items.length;
38167 var vcount = count - this.hiddenCount;
38168 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
38171 var w = Math.max(this.el.getWidth() - this.cpad, 10);
38172 var availWidth = Math.floor(w / vcount);
38173 var b = this.stripBody;
38174 if(b.getWidth() > w){
38175 var tabs = this.items;
38176 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
38177 if(availWidth < this.minTabWidth){
38178 /*if(!this.sleft){ // incomplete scrolling code
38179 this.createScrollButtons();
38182 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
38185 if(this.currentTabWidth < this.preferredTabWidth){
38186 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
38192 * Returns the number of tabs in this TabPanel.
38195 getCount : function(){
38196 return this.items.length;
38200 * Resizes all the tabs to the passed width
38201 * @param {Number} The new width
38203 setTabWidth : function(width){
38204 this.currentTabWidth = width;
38205 for(var i = 0, len = this.items.length; i < len; i++) {
38206 if(!this.items[i].isHidden()) {
38207 this.items[i].setWidth(width);
38213 * Destroys this TabPanel
38214 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
38216 destroy : function(removeEl){
38217 Roo.EventManager.removeResizeListener(this.onResize, this);
38218 for(var i = 0, len = this.items.length; i < len; i++){
38219 this.items[i].purgeListeners();
38221 if(removeEl === true){
38222 this.el.update("");
38227 createStrip : function(container)
38229 var strip = document.createElement("nav");
38230 strip.className = "navbar navbar-default"; //"x-tabs-wrap";
38231 container.appendChild(strip);
38235 createStripList : function(strip)
38237 // div wrapper for retard IE
38238 // returns the "tr" element.
38239 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
38240 //'<div class="x-tabs-strip-wrap">'+
38241 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
38242 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
38243 return strip.firstChild; //.firstChild.firstChild.firstChild;
38245 createBody : function(container)
38247 var body = document.createElement("div");
38248 Roo.id(body, "tab-body");
38249 //Roo.fly(body).addClass("x-tabs-body");
38250 Roo.fly(body).addClass("tab-content");
38251 container.appendChild(body);
38254 createItemBody :function(bodyEl, id){
38255 var body = Roo.getDom(id);
38257 body = document.createElement("div");
38260 //Roo.fly(body).addClass("x-tabs-item-body");
38261 Roo.fly(body).addClass("tab-pane");
38262 bodyEl.insertBefore(body, bodyEl.firstChild);
38266 createStripElements : function(stripEl, text, closable, tpl)
38268 var td = document.createElement("li"); // was td..
38271 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
38274 stripEl.appendChild(td);
38276 td.className = "x-tabs-closable";
38277 if(!this.closeTpl){
38278 this.closeTpl = new Roo.Template(
38279 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38280 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
38281 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
38284 var el = this.closeTpl.overwrite(td, {"text": text});
38285 var close = el.getElementsByTagName("div")[0];
38286 var inner = el.getElementsByTagName("em")[0];
38287 return {"el": el, "close": close, "inner": inner};
38290 // not sure what this is..
38291 // if(!this.tabTpl){
38292 //this.tabTpl = new Roo.Template(
38293 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
38294 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
38296 // this.tabTpl = new Roo.Template(
38297 // '<a href="#">' +
38298 // '<span unselectable="on"' +
38299 // (this.disableTooltips ? '' : ' title="{text}"') +
38300 // ' >{text}</span></a>'
38306 var template = tpl || this.tabTpl || false;
38310 template = new Roo.Template(
38312 '<span unselectable="on"' +
38313 (this.disableTooltips ? '' : ' title="{text}"') +
38314 ' >{text}</span></a>'
38318 switch (typeof(template)) {
38322 template = new Roo.Template(template);
38328 var el = template.overwrite(td, {"text": text});
38330 var inner = el.getElementsByTagName("span")[0];
38332 return {"el": el, "inner": inner};
38340 * @class Roo.TabPanelItem
38341 * @extends Roo.util.Observable
38342 * Represents an individual item (tab plus body) in a TabPanel.
38343 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
38344 * @param {String} id The id of this TabPanelItem
38345 * @param {String} text The text for the tab of this TabPanelItem
38346 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
38348 Roo.bootstrap.panel.TabItem = function(config){
38350 * The {@link Roo.TabPanel} this TabPanelItem belongs to
38351 * @type Roo.TabPanel
38353 this.tabPanel = config.panel;
38355 * The id for this TabPanelItem
38358 this.id = config.id;
38360 this.disabled = false;
38362 this.text = config.text;
38364 this.loaded = false;
38365 this.closable = config.closable;
38368 * The body element for this TabPanelItem.
38369 * @type Roo.Element
38371 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
38372 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
38373 this.bodyEl.setStyle("display", "block");
38374 this.bodyEl.setStyle("zoom", "1");
38375 //this.hideAction();
38377 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
38379 this.el = Roo.get(els.el);
38380 this.inner = Roo.get(els.inner, true);
38381 this.textEl = Roo.get(this.el.dom.firstChild, true);
38382 this.pnode = Roo.get(els.el.parentNode, true);
38383 // this.el.on("mousedown", this.onTabMouseDown, this);
38384 this.el.on("click", this.onTabClick, this);
38386 if(config.closable){
38387 var c = Roo.get(els.close, true);
38388 c.dom.title = this.closeText;
38389 c.addClassOnOver("close-over");
38390 c.on("click", this.closeClick, this);
38396 * Fires when this tab becomes the active tab.
38397 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38398 * @param {Roo.TabPanelItem} this
38402 * @event beforeclose
38403 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
38404 * @param {Roo.TabPanelItem} this
38405 * @param {Object} e Set cancel to true on this object to cancel the close.
38407 "beforeclose": true,
38410 * Fires when this tab is closed.
38411 * @param {Roo.TabPanelItem} this
38415 * @event deactivate
38416 * Fires when this tab is no longer the active tab.
38417 * @param {Roo.TabPanel} tabPanel The parent TabPanel
38418 * @param {Roo.TabPanelItem} this
38420 "deactivate" : true
38422 this.hidden = false;
38424 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
38427 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
38429 purgeListeners : function(){
38430 Roo.util.Observable.prototype.purgeListeners.call(this);
38431 this.el.removeAllListeners();
38434 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
38437 this.pnode.addClass("active");
38440 this.tabPanel.stripWrap.repaint();
38442 this.fireEvent("activate", this.tabPanel, this);
38446 * Returns true if this tab is the active tab.
38447 * @return {Boolean}
38449 isActive : function(){
38450 return this.tabPanel.getActiveTab() == this;
38454 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
38457 this.pnode.removeClass("active");
38459 this.fireEvent("deactivate", this.tabPanel, this);
38462 hideAction : function(){
38463 this.bodyEl.hide();
38464 this.bodyEl.setStyle("position", "absolute");
38465 this.bodyEl.setLeft("-20000px");
38466 this.bodyEl.setTop("-20000px");
38469 showAction : function(){
38470 this.bodyEl.setStyle("position", "relative");
38471 this.bodyEl.setTop("");
38472 this.bodyEl.setLeft("");
38473 this.bodyEl.show();
38477 * Set the tooltip for the tab.
38478 * @param {String} tooltip The tab's tooltip
38480 setTooltip : function(text){
38481 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
38482 this.textEl.dom.qtip = text;
38483 this.textEl.dom.removeAttribute('title');
38485 this.textEl.dom.title = text;
38489 onTabClick : function(e){
38490 e.preventDefault();
38491 this.tabPanel.activate(this.id);
38494 onTabMouseDown : function(e){
38495 e.preventDefault();
38496 this.tabPanel.activate(this.id);
38499 getWidth : function(){
38500 return this.inner.getWidth();
38503 setWidth : function(width){
38504 var iwidth = width - this.pnode.getPadding("lr");
38505 this.inner.setWidth(iwidth);
38506 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
38507 this.pnode.setWidth(width);
38511 * Show or hide the tab
38512 * @param {Boolean} hidden True to hide or false to show.
38514 setHidden : function(hidden){
38515 this.hidden = hidden;
38516 this.pnode.setStyle("display", hidden ? "none" : "");
38520 * Returns true if this tab is "hidden"
38521 * @return {Boolean}
38523 isHidden : function(){
38524 return this.hidden;
38528 * Returns the text for this tab
38531 getText : function(){
38535 autoSize : function(){
38536 //this.el.beginMeasure();
38537 this.textEl.setWidth(1);
38539 * #2804 [new] Tabs in Roojs
38540 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
38542 //this.setWidth(this.textEl.dom.scrollWidth+this.pnode.getPadding("lr")+this.inner.getPadding("lr") + 2);
38543 //this.el.endMeasure();
38547 * Sets the text for the tab (Note: this also sets the tooltip text)
38548 * @param {String} text The tab's text and tooltip
38550 setText : function(text){
38552 this.textEl.update(text);
38553 this.setTooltip(text);
38554 //if(!this.tabPanel.resizeTabs){
38555 // this.autoSize();
38559 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
38561 activate : function(){
38562 this.tabPanel.activate(this.id);
38566 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
38568 disable : function(){
38569 if(this.tabPanel.active != this){
38570 this.disabled = true;
38571 this.pnode.addClass("disabled");
38576 * Enables this TabPanelItem if it was previously disabled.
38578 enable : function(){
38579 this.disabled = false;
38580 this.pnode.removeClass("disabled");
38584 * Sets the content for this TabPanelItem.
38585 * @param {String} content The content
38586 * @param {Boolean} loadScripts true to look for and load scripts
38588 setContent : function(content, loadScripts){
38589 this.bodyEl.update(content, loadScripts);
38593 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
38594 * @return {Roo.UpdateManager} The UpdateManager
38596 getUpdateManager : function(){
38597 return this.bodyEl.getUpdateManager();
38601 * Set a URL to be used to load the content for this TabPanelItem.
38602 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
38603 * @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)
38604 * @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)
38605 * @return {Roo.UpdateManager} The UpdateManager
38607 setUrl : function(url, params, loadOnce){
38608 if(this.refreshDelegate){
38609 this.un('activate', this.refreshDelegate);
38611 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
38612 this.on("activate", this.refreshDelegate);
38613 return this.bodyEl.getUpdateManager();
38617 _handleRefresh : function(url, params, loadOnce){
38618 if(!loadOnce || !this.loaded){
38619 var updater = this.bodyEl.getUpdateManager();
38620 updater.update(url, params, this._setLoaded.createDelegate(this));
38625 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
38626 * Will fail silently if the setUrl method has not been called.
38627 * This does not activate the panel, just updates its content.
38629 refresh : function(){
38630 if(this.refreshDelegate){
38631 this.loaded = false;
38632 this.refreshDelegate();
38637 _setLoaded : function(){
38638 this.loaded = true;
38642 closeClick : function(e){
38645 this.fireEvent("beforeclose", this, o);
38646 if(o.cancel !== true){
38647 this.tabPanel.removeTab(this.id);
38651 * The text displayed in the tooltip for the close icon.
38654 closeText : "Close this tab"
38657 * This script refer to:
38658 * Title: International Telephone Input
38659 * Author: Jack O'Connor
38660 * Code version: v12.1.12
38661 * Availability: https://github.com/jackocnr/intl-tel-input.git
38664 Roo.bootstrap.PhoneInputData = function() {
38667 "Afghanistan (افغانستان)",
38672 "Albania (Shqipëri)",
38677 "Algeria (الجزائر)",
38702 "Antigua and Barbuda",
38712 "Armenia (Հայաստան)",
38728 "Austria (Österreich)",
38733 "Azerbaijan (Azərbaycan)",
38743 "Bahrain (البحرين)",
38748 "Bangladesh (বাংলাদেশ)",
38758 "Belarus (Беларусь)",
38763 "Belgium (België)",
38793 "Bosnia and Herzegovina (Босна и Херцеговина)",
38808 "British Indian Ocean Territory",
38813 "British Virgin Islands",
38823 "Bulgaria (България)",
38833 "Burundi (Uburundi)",
38838 "Cambodia (កម្ពុជា)",
38843 "Cameroon (Cameroun)",
38852 ["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"]
38855 "Cape Verde (Kabu Verdi)",
38860 "Caribbean Netherlands",
38871 "Central African Republic (République centrafricaine)",
38891 "Christmas Island",
38897 "Cocos (Keeling) Islands",
38908 "Comoros (جزر القمر)",
38913 "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)",
38918 "Congo (Republic) (Congo-Brazzaville)",
38938 "Croatia (Hrvatska)",
38959 "Czech Republic (Česká republika)",
38964 "Denmark (Danmark)",
38979 "Dominican Republic (República Dominicana)",
38983 ["809", "829", "849"]
39001 "Equatorial Guinea (Guinea Ecuatorial)",
39021 "Falkland Islands (Islas Malvinas)",
39026 "Faroe Islands (Føroyar)",
39047 "French Guiana (Guyane française)",
39052 "French Polynesia (Polynésie française)",
39067 "Georgia (საქართველო)",
39072 "Germany (Deutschland)",
39092 "Greenland (Kalaallit Nunaat)",
39129 "Guinea-Bissau (Guiné Bissau)",
39154 "Hungary (Magyarország)",
39159 "Iceland (Ísland)",
39179 "Iraq (العراق)",
39195 "Israel (ישראל)",
39222 "Jordan (الأردن)",
39227 "Kazakhstan (Казахстан)",
39248 "Kuwait (الكويت)",
39253 "Kyrgyzstan (Кыргызстан)",
39263 "Latvia (Latvija)",
39268 "Lebanon (لبنان)",
39283 "Libya (ليبيا)",
39293 "Lithuania (Lietuva)",
39308 "Macedonia (FYROM) (Македонија)",
39313 "Madagascar (Madagasikara)",
39343 "Marshall Islands",
39353 "Mauritania (موريتانيا)",
39358 "Mauritius (Moris)",
39379 "Moldova (Republica Moldova)",
39389 "Mongolia (Монгол)",
39394 "Montenegro (Crna Gora)",
39404 "Morocco (المغرب)",
39410 "Mozambique (Moçambique)",
39415 "Myanmar (Burma) (မြန်မာ)",
39420 "Namibia (Namibië)",
39435 "Netherlands (Nederland)",
39440 "New Caledonia (Nouvelle-Calédonie)",
39475 "North Korea (조선 민주주의 인민 공화국)",
39480 "Northern Mariana Islands",
39496 "Pakistan (پاکستان)",
39506 "Palestine (فلسطين)",
39516 "Papua New Guinea",
39558 "Réunion (La Réunion)",
39564 "Romania (România)",
39580 "Saint Barthélemy",
39591 "Saint Kitts and Nevis",
39601 "Saint Martin (Saint-Martin (partie française))",
39607 "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)",
39612 "Saint Vincent and the Grenadines",
39627 "São Tomé and Príncipe (São Tomé e Príncipe)",
39632 "Saudi Arabia (المملكة العربية السعودية)",
39637 "Senegal (Sénégal)",
39667 "Slovakia (Slovensko)",
39672 "Slovenia (Slovenija)",
39682 "Somalia (Soomaaliya)",
39692 "South Korea (대한민국)",
39697 "South Sudan (جنوب السودان)",
39707 "Sri Lanka (ශ්රී ලංකාව)",
39712 "Sudan (السودان)",
39722 "Svalbard and Jan Mayen",
39733 "Sweden (Sverige)",
39738 "Switzerland (Schweiz)",
39743 "Syria (سوريا)",
39788 "Trinidad and Tobago",
39793 "Tunisia (تونس)",
39798 "Turkey (Türkiye)",
39808 "Turks and Caicos Islands",
39818 "U.S. Virgin Islands",
39828 "Ukraine (Україна)",
39833 "United Arab Emirates (الإمارات العربية المتحدة)",
39855 "Uzbekistan (Oʻzbekiston)",
39865 "Vatican City (Città del Vaticano)",
39876 "Vietnam (Việt Nam)",
39881 "Wallis and Futuna (Wallis-et-Futuna)",
39886 "Western Sahara (الصحراء الغربية)",
39892 "Yemen (اليمن)",
39916 * This script refer to:
39917 * Title: International Telephone Input
39918 * Author: Jack O'Connor
39919 * Code version: v12.1.12
39920 * Availability: https://github.com/jackocnr/intl-tel-input.git
39924 * @class Roo.bootstrap.PhoneInput
39925 * @extends Roo.bootstrap.TriggerField
39926 * An input with International dial-code selection
39928 * @cfg {String} defaultDialCode default '+852'
39929 * @cfg {Array} preferedCountries default []
39932 * Create a new PhoneInput.
39933 * @param {Object} config Configuration options
39936 Roo.bootstrap.PhoneInput = function(config) {
39937 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
39940 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
39942 listWidth: undefined,
39944 selectedClass: 'active',
39946 invalidClass : "has-warning",
39948 validClass: 'has-success',
39950 allowed: '0123456789',
39955 * @cfg {String} defaultDialCode The default dial code when initializing the input
39957 defaultDialCode: '+852',
39960 * @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
39962 preferedCountries: false,
39964 getAutoCreate : function()
39966 var data = Roo.bootstrap.PhoneInputData();
39967 var align = this.labelAlign || this.parentLabelAlign();
39970 this.allCountries = [];
39971 this.dialCodeMapping = [];
39973 for (var i = 0; i < data.length; i++) {
39975 this.allCountries[i] = {
39979 priority: c[3] || 0,
39980 areaCodes: c[4] || null
39982 this.dialCodeMapping[c[2]] = {
39985 priority: c[3] || 0,
39986 areaCodes: c[4] || null
39998 // type: 'number', -- do not use number - we get the flaky up/down arrows.
39999 maxlength: this.max_length,
40000 cls : 'form-control tel-input',
40001 autocomplete: 'new-password'
40004 var hiddenInput = {
40007 cls: 'hidden-tel-input'
40011 hiddenInput.name = this.name;
40014 if (this.disabled) {
40015 input.disabled = true;
40018 var flag_container = {
40035 cls: this.hasFeedback ? 'has-feedback' : '',
40041 cls: 'dial-code-holder',
40048 cls: 'roo-select2-container input-group',
40055 if (this.fieldLabel.length) {
40058 tooltip: 'This field is required'
40064 cls: 'control-label',
40070 html: this.fieldLabel
40073 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40079 if(this.indicatorpos == 'right') {
40080 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
40087 if(align == 'left') {
40095 if(this.labelWidth > 12){
40096 label.style = "width: " + this.labelWidth + 'px';
40098 if(this.labelWidth < 13 && this.labelmd == 0){
40099 this.labelmd = this.labelWidth;
40101 if(this.labellg > 0){
40102 label.cls += ' col-lg-' + this.labellg;
40103 input.cls += ' col-lg-' + (12 - this.labellg);
40105 if(this.labelmd > 0){
40106 label.cls += ' col-md-' + this.labelmd;
40107 container.cls += ' col-md-' + (12 - this.labelmd);
40109 if(this.labelsm > 0){
40110 label.cls += ' col-sm-' + this.labelsm;
40111 container.cls += ' col-sm-' + (12 - this.labelsm);
40113 if(this.labelxs > 0){
40114 label.cls += ' col-xs-' + this.labelxs;
40115 container.cls += ' col-xs-' + (12 - this.labelxs);
40125 var settings = this;
40127 ['xs','sm','md','lg'].map(function(size){
40128 if (settings[size]) {
40129 cfg.cls += ' col-' + size + '-' + settings[size];
40133 this.store = new Roo.data.Store({
40134 proxy : new Roo.data.MemoryProxy({}),
40135 reader : new Roo.data.JsonReader({
40146 'name' : 'dialCode',
40150 'name' : 'priority',
40154 'name' : 'areaCodes',
40161 if(!this.preferedCountries) {
40162 this.preferedCountries = [
40169 var p = this.preferedCountries.reverse();
40172 for (var i = 0; i < p.length; i++) {
40173 for (var j = 0; j < this.allCountries.length; j++) {
40174 if(this.allCountries[j].iso2 == p[i]) {
40175 var t = this.allCountries[j];
40176 this.allCountries.splice(j,1);
40177 this.allCountries.unshift(t);
40183 this.store.proxy.data = {
40185 data: this.allCountries
40191 initEvents : function()
40194 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
40196 this.indicator = this.indicatorEl();
40197 this.flag = this.flagEl();
40198 this.dialCodeHolder = this.dialCodeHolderEl();
40200 this.trigger = this.el.select('div.flag-box',true).first();
40201 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
40206 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40207 _this.list.setWidth(lw);
40210 this.list.on('mouseover', this.onViewOver, this);
40211 this.list.on('mousemove', this.onViewMove, this);
40212 this.inputEl().on("keyup", this.onKeyUp, this);
40213 this.inputEl().on("keypress", this.onKeyPress, this);
40215 this.tpl = '<li><a href="#"><div class="flag {iso2}"></div>{name} <span class="dial-code">+{dialCode}</span></a></li>';
40217 this.view = new Roo.View(this.list, this.tpl, {
40218 singleSelect:true, store: this.store, selectedClass: this.selectedClass
40221 this.view.on('click', this.onViewClick, this);
40222 this.setValue(this.defaultDialCode);
40225 onTriggerClick : function(e)
40227 Roo.log('trigger click');
40232 if(this.isExpanded()){
40234 this.hasFocus = false;
40236 this.store.load({});
40237 this.hasFocus = true;
40242 isExpanded : function()
40244 return this.list.isVisible();
40247 collapse : function()
40249 if(!this.isExpanded()){
40253 Roo.get(document).un('mousedown', this.collapseIf, this);
40254 Roo.get(document).un('mousewheel', this.collapseIf, this);
40255 this.fireEvent('collapse', this);
40259 expand : function()
40263 if(this.isExpanded() || !this.hasFocus){
40267 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
40268 this.list.setWidth(lw);
40271 this.restrictHeight();
40273 Roo.get(document).on('mousedown', this.collapseIf, this);
40274 Roo.get(document).on('mousewheel', this.collapseIf, this);
40276 this.fireEvent('expand', this);
40279 restrictHeight : function()
40281 this.list.alignTo(this.inputEl(), this.listAlign);
40282 this.list.alignTo(this.inputEl(), this.listAlign);
40285 onViewOver : function(e, t)
40287 if(this.inKeyMode){
40290 var item = this.view.findItemFromChild(t);
40293 var index = this.view.indexOf(item);
40294 this.select(index, false);
40299 onViewClick : function(view, doFocus, el, e)
40301 var index = this.view.getSelectedIndexes()[0];
40303 var r = this.store.getAt(index);
40306 this.onSelect(r, index);
40308 if(doFocus !== false && !this.blockFocus){
40309 this.inputEl().focus();
40313 onViewMove : function(e, t)
40315 this.inKeyMode = false;
40318 select : function(index, scrollIntoView)
40320 this.selectedIndex = index;
40321 this.view.select(index);
40322 if(scrollIntoView !== false){
40323 var el = this.view.getNode(index);
40325 this.list.scrollChildIntoView(el, false);
40330 createList : function()
40332 this.list = Roo.get(document.body).createChild({
40334 cls: 'typeahead typeahead-long dropdown-menu tel-list',
40335 style: 'display:none'
40338 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
40341 collapseIf : function(e)
40343 var in_combo = e.within(this.el);
40344 var in_list = e.within(this.list);
40345 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
40347 if (in_combo || in_list || is_list) {
40353 onSelect : function(record, index)
40355 if(this.fireEvent('beforeselect', this, record, index) !== false){
40357 this.setFlagClass(record.data.iso2);
40358 this.setDialCode(record.data.dialCode);
40359 this.hasFocus = false;
40361 this.fireEvent('select', this, record, index);
40365 flagEl : function()
40367 var flag = this.el.select('div.flag',true).first();
40374 dialCodeHolderEl : function()
40376 var d = this.el.select('input.dial-code-holder',true).first();
40383 setDialCode : function(v)
40385 this.dialCodeHolder.dom.value = '+'+v;
40388 setFlagClass : function(n)
40390 this.flag.dom.className = 'flag '+n;
40393 getValue : function()
40395 var v = this.inputEl().getValue();
40396 if(this.dialCodeHolder) {
40397 v = this.dialCodeHolder.dom.value+this.inputEl().getValue();
40402 setValue : function(v)
40404 var d = this.getDialCode(v);
40406 //invalid dial code
40407 if(v.length == 0 || !d || d.length == 0) {
40409 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
40410 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
40416 this.setFlagClass(this.dialCodeMapping[d].iso2);
40417 this.setDialCode(d);
40418 this.inputEl().dom.value = v.replace('+'+d,'');
40419 this.hiddenEl().dom.value = this.getValue();
40424 getDialCode : function(v)
40428 if (v.length == 0) {
40429 return this.dialCodeHolder.dom.value;
40433 if (v.charAt(0) != "+") {
40436 var numericChars = "";
40437 for (var i = 1; i < v.length; i++) {
40438 var c = v.charAt(i);
40441 if (this.dialCodeMapping[numericChars]) {
40442 dialCode = v.substr(1, i);
40444 if (numericChars.length == 4) {
40454 this.setValue(this.defaultDialCode);
40458 hiddenEl : function()
40460 return this.el.select('input.hidden-tel-input',true).first();
40463 // after setting val
40464 onKeyUp : function(e){
40465 this.setValue(this.getValue());
40468 onKeyPress : function(e){
40469 if(this.allowed.indexOf(String.fromCharCode(e.getCharCode())) === -1){
40476 * @class Roo.bootstrap.MoneyField
40477 * @extends Roo.bootstrap.ComboBox
40478 * Bootstrap MoneyField class
40481 * Create a new MoneyField.
40482 * @param {Object} config Configuration options
40485 Roo.bootstrap.MoneyField = function(config) {
40487 Roo.bootstrap.MoneyField.superclass.constructor.call(this, config);
40491 Roo.extend(Roo.bootstrap.MoneyField, Roo.bootstrap.ComboBox, {
40494 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
40496 allowDecimals : true,
40498 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
40500 decimalSeparator : ".",
40502 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
40504 decimalPrecision : 0,
40506 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
40508 allowNegative : true,
40510 * @cfg {Boolean} allowZero False to blank out if the user enters '0' (defaults to true)
40514 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
40516 minValue : Number.NEGATIVE_INFINITY,
40518 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
40520 maxValue : Number.MAX_VALUE,
40522 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
40524 minText : "The minimum value for this field is {0}",
40526 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
40528 maxText : "The maximum value for this field is {0}",
40530 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
40531 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
40533 nanText : "{0} is not a valid number",
40535 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
40539 * @cfg {String} defaults currency of the MoneyField
40540 * value should be in lkey
40542 defaultCurrency : false,
40544 * @cfg {String} thousandsDelimiter Symbol of thousandsDelimiter
40546 thousandsDelimiter : false,
40548 * @cfg {Number} max_length Maximum input field length allowed (defaults to Number.MAX_VALUE)
40559 getAutoCreate : function()
40561 var align = this.labelAlign || this.parentLabelAlign();
40573 cls : 'form-control roo-money-amount-input',
40574 autocomplete: 'new-password'
40577 var hiddenInput = {
40581 cls: 'hidden-number-input'
40584 if(this.max_length) {
40585 input.maxlength = this.max_length;
40589 hiddenInput.name = this.name;
40592 if (this.disabled) {
40593 input.disabled = true;
40596 var clg = 12 - this.inputlg;
40597 var cmd = 12 - this.inputmd;
40598 var csm = 12 - this.inputsm;
40599 var cxs = 12 - this.inputxs;
40603 cls : 'row roo-money-field',
40607 cls : 'roo-money-currency column col-lg-' + clg + ' col-md-' + cmd + ' col-sm-' + csm + ' col-xs-' + cxs,
40611 cls: 'roo-select2-container input-group',
40615 cls : 'form-control roo-money-currency-input',
40616 autocomplete: 'new-password',
40618 name : this.currencyName
40622 cls : 'input-group-addon',
40636 cls : 'roo-money-amount column col-lg-' + this.inputlg + ' col-md-' + this.inputmd + ' col-sm-' + this.inputsm + ' col-xs-' + this.inputxs,
40640 cls: this.hasFeedback ? 'has-feedback' : '',
40651 if (this.fieldLabel.length) {
40654 tooltip: 'This field is required'
40660 cls: 'control-label',
40666 html: this.fieldLabel
40669 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star left-indicator';
40675 if(this.indicatorpos == 'right') {
40676 indicator.cls = 'roo-required-indicator text-danger fa fa-lg fa-star right-indicator';
40683 if(align == 'left') {
40691 if(this.labelWidth > 12){
40692 label.style = "width: " + this.labelWidth + 'px';
40694 if(this.labelWidth < 13 && this.labelmd == 0){
40695 this.labelmd = this.labelWidth;
40697 if(this.labellg > 0){
40698 label.cls += ' col-lg-' + this.labellg;
40699 input.cls += ' col-lg-' + (12 - this.labellg);
40701 if(this.labelmd > 0){
40702 label.cls += ' col-md-' + this.labelmd;
40703 container.cls += ' col-md-' + (12 - this.labelmd);
40705 if(this.labelsm > 0){
40706 label.cls += ' col-sm-' + this.labelsm;
40707 container.cls += ' col-sm-' + (12 - this.labelsm);
40709 if(this.labelxs > 0){
40710 label.cls += ' col-xs-' + this.labelxs;
40711 container.cls += ' col-xs-' + (12 - this.labelxs);
40722 var settings = this;
40724 ['xs','sm','md','lg'].map(function(size){
40725 if (settings[size]) {
40726 cfg.cls += ' col-' + size + '-' + settings[size];
40733 initEvents : function()
40735 this.indicator = this.indicatorEl();
40737 this.initCurrencyEvent();
40739 this.initNumberEvent();
40742 initCurrencyEvent : function()
40745 throw "can not find store for combo";
40748 this.store = Roo.factory(this.store, Roo.data);
40749 this.store.parent = this;
40753 this.triggerEl = this.el.select('.input-group-addon', true).first();
40755 this.triggerEl.on("click", this.onTriggerClick, this, { preventDefault : true });
40760 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
40761 _this.list.setWidth(lw);
40764 this.list.on('mouseover', this.onViewOver, this);
40765 this.list.on('mousemove', this.onViewMove, this);
40766 this.list.on('scroll', this.onViewScroll, this);
40769 this.tpl = '<li><a href="#">{' + this.currencyField + '}</a></li>';
40772 this.view = new Roo.View(this.list, this.tpl, {
40773 singleSelect:true, store: this.store, selectedClass: this.selectedClass
40776 this.view.on('click', this.onViewClick, this);
40778 this.store.on('beforeload', this.onBeforeLoad, this);
40779 this.store.on('load', this.onLoad, this);
40780 this.store.on('loadexception', this.onLoadException, this);
40782 this.keyNav = new Roo.KeyNav(this.currencyEl(), {
40783 "up" : function(e){
40784 this.inKeyMode = true;
40788 "down" : function(e){
40789 if(!this.isExpanded()){
40790 this.onTriggerClick();
40792 this.inKeyMode = true;
40797 "enter" : function(e){
40800 if(this.fireEvent("specialkey", this, e)){
40801 this.onViewClick(false);
40807 "esc" : function(e){
40811 "tab" : function(e){
40814 if(this.fireEvent("specialkey", this, e)){
40815 this.onViewClick(false);
40823 doRelay : function(foo, bar, hname){
40824 if(hname == 'down' || this.scope.isExpanded()){
40825 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
40833 this.currencyEl().on("click", this.onTriggerClick, this, { preventDefault : true });
40837 initNumberEvent : function(e)
40839 this.inputEl().on("keydown" , this.fireKey, this);
40840 this.inputEl().on("focus", this.onFocus, this);
40841 this.inputEl().on("blur", this.onBlur, this);
40843 this.inputEl().relayEvent('keyup', this);
40845 if(this.indicator){
40846 this.indicator.addClass('invisible');
40849 this.originalValue = this.getValue();
40851 if(this.validationEvent == 'keyup'){
40852 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
40853 this.inputEl().on('keyup', this.filterValidation, this);
40855 else if(this.validationEvent !== false){
40856 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
40859 if(this.selectOnFocus){
40860 this.on("focus", this.preFocus, this);
40863 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
40864 this.inputEl().on("keypress", this.filterKeys, this);
40866 this.inputEl().relayEvent('keypress', this);
40869 var allowed = "0123456789";
40871 if(this.allowDecimals){
40872 allowed += this.decimalSeparator;
40875 if(this.allowNegative){
40879 if(this.thousandsDelimiter) {
40883 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
40885 var keyPress = function(e){
40887 var k = e.getKey();
40889 var c = e.getCharCode();
40892 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
40893 allowed.indexOf(String.fromCharCode(c)) === -1
40899 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
40903 if(allowed.indexOf(String.fromCharCode(c)) === -1){
40908 this.inputEl().on("keypress", keyPress, this);
40912 onTriggerClick : function(e)
40919 this.loadNext = false;
40921 if(this.isExpanded()){
40926 this.hasFocus = true;
40928 if(this.triggerAction == 'all') {
40929 this.doQuery(this.allQuery, true);
40933 this.doQuery(this.getRawValue());
40936 getCurrency : function()
40938 var v = this.currencyEl().getValue();
40943 restrictHeight : function()
40945 this.list.alignTo(this.currencyEl(), this.listAlign);
40946 this.list.alignTo(this.currencyEl(), this.listAlign);
40949 onViewClick : function(view, doFocus, el, e)
40951 var index = this.view.getSelectedIndexes()[0];
40953 var r = this.store.getAt(index);
40956 this.onSelect(r, index);
40960 onSelect : function(record, index){
40962 if(this.fireEvent('beforeselect', this, record, index) !== false){
40964 this.setFromCurrencyData(index > -1 ? record.data : false);
40968 this.fireEvent('select', this, record, index);
40972 setFromCurrencyData : function(o)
40976 this.lastCurrency = o;
40978 if (this.currencyField) {
40979 currency = !o || typeof(o[this.currencyField]) == 'undefined' ? '' : o[this.currencyField];
40981 Roo.log('no currencyField value set for '+ (this.name ? this.name : this.id));
40984 this.lastSelectionText = currency;
40986 //setting default currency
40987 if(o[this.currencyField] * 1 == 0 && this.defaultCurrency) {
40988 this.setCurrency(this.defaultCurrency);
40992 this.setCurrency(currency);
40995 setFromData : function(o)
40999 c[this.currencyField] = !o || typeof(o[this.currencyName]) == 'undefined' ? '' : o[this.currencyName];
41001 this.setFromCurrencyData(c);
41006 value = !o || typeof(o[this.name]) == 'undefined' ? '' : o[this.name];
41008 Roo.log('no value set for '+ (this.name ? this.name : this.id));
41011 this.setValue(value);
41015 setCurrency : function(v)
41017 this.currencyValue = v;
41020 this.currencyEl().dom.value = (v === null || v === undefined ? '' : v);
41025 setValue : function(v)
41027 v = String(this.fixPrecision(v)).replace(".", this.decimalSeparator);
41033 this.hiddenEl().dom.value = (v === null || v === undefined ? '' : v);
41035 this.inputEl().dom.value = (v == '') ? '' :
41036 Roo.util.Format.number(v, this.decimalPrecision, this.thousandsDelimiter || '');
41038 if(!this.allowZero && v === '0') {
41039 this.hiddenEl().dom.value = '';
41040 this.inputEl().dom.value = '';
41047 getRawValue : function()
41049 var v = this.inputEl().getValue();
41054 getValue : function()
41056 return this.fixPrecision(this.parseValue(this.getRawValue()));
41059 parseValue : function(value)
41061 if(this.thousandsDelimiter) {
41063 r = new RegExp(",", "g");
41064 value = value.replace(r, "");
41067 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
41068 return isNaN(value) ? '' : value;
41072 fixPrecision : function(value)
41074 if(this.thousandsDelimiter) {
41076 r = new RegExp(",", "g");
41077 value = value.replace(r, "");
41080 var nan = isNaN(value);
41082 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
41083 return nan ? '' : value;
41085 return parseFloat(value).toFixed(this.decimalPrecision);
41088 decimalPrecisionFcn : function(v)
41090 return Math.floor(v);
41093 validateValue : function(value)
41095 if(!Roo.bootstrap.MoneyField.superclass.validateValue.call(this, value)){
41099 var num = this.parseValue(value);
41102 this.markInvalid(String.format(this.nanText, value));
41106 if(num < this.minValue){
41107 this.markInvalid(String.format(this.minText, this.minValue));
41111 if(num > this.maxValue){
41112 this.markInvalid(String.format(this.maxText, this.maxValue));
41119 validate : function()
41121 if(this.disabled || this.allowBlank){
41126 var currency = this.getCurrency();
41128 if(this.validateValue(this.getRawValue()) && currency.length){
41133 this.markInvalid();
41137 getName: function()
41142 beforeBlur : function()
41148 var v = this.parseValue(this.getRawValue());
41155 onBlur : function()
41159 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
41160 //this.el.removeClass(this.focusClass);
41163 this.hasFocus = false;
41165 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
41169 var v = this.getValue();
41171 if(String(v) !== String(this.startValue)){
41172 this.fireEvent('change', this, v, this.startValue);
41175 this.fireEvent("blur", this);
41178 inputEl : function()
41180 return this.el.select('.roo-money-amount-input', true).first();
41183 currencyEl : function()
41185 return this.el.select('.roo-money-currency-input', true).first();
41188 hiddenEl : function()
41190 return this.el.select('input.hidden-number-input',true).first();