4 * base class for bootstrap elements.
8 Roo.bootstrap = Roo.bootstrap || {};
10 * @class Roo.bootstrap.Component
11 * @extends Roo.Component
12 * Bootstrap Component base class
13 * @cfg {String} cls css class
14 * @cfg {String} style any extra css
15 * @cfg {Object} xattr extra attributes to add to 'element' (used by builder to store stuff.)
16 * @cfg {Boolean} can_build_overlaid True if element can be rebuild from a HTML page
17 * @cfg {string} dataId cutomer id
18 * @cfg {string} name Specifies name attribute
19 * @cfg {string} tooltip Text for the tooltip
20 * @cfg {string} container_method method to fetch parents container element (used by NavHeaderbar - getHeaderChildContainer)
23 * Do not use directly - it does not do anything..
24 * @param {Object} config The config object
29 Roo.bootstrap.Component = function(config){
30 Roo.bootstrap.Component.superclass.constructor.call(this, config);
34 * @event childrenrendered
35 * Fires when the children have been rendered..
36 * @param {Roo.bootstrap.Component} this
38 "childrenrendered" : true
47 Roo.extend(Roo.bootstrap.Component, Roo.BoxComponent, {
50 allowDomMove : false, // to stop relocations in parent onRender...
60 * Initialize Events for the element
62 initEvents : function() { },
68 can_build_overlaid : true,
70 container_method : false,
77 // returns the parent component..
78 return Roo.ComponentMgr.get(this.parentId)
84 onRender : function(ct, position)
86 // Roo.log("Call onRender: " + this.xtype);
88 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
91 if (this.el.attr('xtype')) {
92 this.el.attr('xtypex', this.el.attr('xtype'));
93 this.el.dom.removeAttribute('xtype');
103 var cfg = Roo.apply({}, this.getAutoCreate());
105 cfg.id = this.id || Roo.id();
107 // fill in the extra attributes
108 if (this.xattr && typeof(this.xattr) =='object') {
109 for (var i in this.xattr) {
110 cfg[i] = this.xattr[i];
115 cfg.dataId = this.dataId;
119 cfg.cls = (typeof(cfg.cls) == 'undefined') ? this.cls : cfg.cls + ' ' + this.cls;
122 if (this.style) { // fixme needs to support more complex style data.
123 cfg.style = this.style;
127 cfg.name = this.name;
130 this.el = ct.createChild(cfg, position);
133 this.tooltipEl().attr('tooltip', this.tooltip);
136 if(this.tabIndex !== undefined){
137 this.el.dom.setAttribute('tabIndex', this.tabIndex);
144 * Fetch the element to add children to
145 * @return {Roo.Element} defaults to this.el
147 getChildContainer : function()
152 * Fetch the element to display the tooltip on.
153 * @return {Roo.Element} defaults to this.el
155 tooltipEl : function()
160 addxtype : function(tree,cntr)
164 cn = Roo.factory(tree);
165 //Roo.log(['addxtype', cn]);
167 cn.parentType = this.xtype; //??
168 cn.parentId = this.id;
170 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
171 if (typeof(cn.container_method) == 'string') {
172 cntr = cn.container_method;
176 var has_flexy_each = (typeof(tree['flexy:foreach']) != 'undefined');
178 var has_flexy_if = (typeof(tree['flexy:if']) != 'undefined');
180 var build_from_html = Roo.XComponent.build_from_html;
182 var is_body = (tree.xtype == 'Body') ;
184 var page_has_body = (Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body');
186 var self_cntr_el = Roo.get(this[cntr](false));
188 // do not try and build conditional elements
189 if ((has_flexy_each || has_flexy_if || this.can_build_overlaid == false ) && build_from_html) {
193 if (!has_flexy_each || !build_from_html || is_body || !page_has_body) {
194 if(!has_flexy_if || typeof(tree.name) == 'undefined' || !build_from_html || is_body || !page_has_body){
195 return this.addxtypeChild(tree,cntr, is_body);
198 var echild =self_cntr_el ? self_cntr_el.child('>*[name=' + tree.name + ']') : false;
201 return this.addxtypeChild(Roo.apply({}, tree),cntr);
204 Roo.log('skipping render');
210 if (!build_from_html) {
214 // this i think handles overlaying multiple children of the same type
215 // with the sam eelement.. - which might be buggy..
217 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
223 if (echild && echild.attr('xtype').split('.').pop() != cn.xtype) {
227 ret = this.addxtypeChild(Roo.apply({}, tree),cntr);
234 addxtypeChild : function (tree, cntr, is_body)
236 Roo.debug && Roo.log('addxtypeChild:' + cntr);
238 cntr = (typeof(cntr) == 'undefined' ) ? 'getChildContainer' : cntr;
241 var has_flexy = (typeof(tree['flexy:if']) != 'undefined') ||
242 (typeof(tree['flexy:foreach']) != 'undefined');
246 skip_children = false;
247 // render the element if it's not BODY.
250 cn = Roo.factory(tree);
252 cn.parentType = this.xtype; //??
253 cn.parentId = this.id;
255 var build_from_html = Roo.XComponent.build_from_html;
258 // does the container contain child eleemnts with 'xtype' attributes.
259 // that match this xtype..
260 // note - when we render we create these as well..
261 // so we should check to see if body has xtype set.
262 if (build_from_html && Roo.get(document.body).attr('xtype') == 'Roo.bootstrap.Body') {
264 var self_cntr_el = Roo.get(this[cntr](false));
265 var echild =self_cntr_el ? self_cntr_el.child('>*[xtype]') : false;
267 //Roo.log(Roo.XComponent.build_from_html);
268 //Roo.log("got echild:");
271 // there is a scenario where some of the child elements are flexy:if (and all of the same type)
272 // and are not displayed -this causes this to use up the wrong element when matching.
273 // at present the only work around for this is to nest flexy:if elements in another element that is always rendered.
276 if (echild && echild.attr('xtype').split('.').pop() == cn.xtype) {
277 // Roo.log("found child for " + this.xtype +": " + echild.attr('xtype') );
283 //echild.dom.removeAttribute('xtype');
285 Roo.debug && Roo.log("MISSING " + cn.xtype + " on child of " + (this.el ? this.el.attr('xbuilderid') : 'no parent'));
286 Roo.debug && Roo.log(self_cntr_el);
287 Roo.debug && Roo.log(echild);
288 Roo.debug && Roo.log(cn);
294 // if object has flexy:if - then it may or may not be rendered.
295 if (build_from_html && has_flexy && !cn.el && cn.can_build_overlaid) {
296 // skip a flexy if element.
297 Roo.debug && Roo.log('skipping render');
298 Roo.debug && Roo.log(tree);
300 Roo.debug && Roo.log('skipping all children');
301 skip_children = true;
306 // actually if flexy:foreach is found, we really want to create
307 // multiple copies here...
309 //Roo.log(this[cntr]());
310 // some elements do not have render methods.. like the layouts...
311 cn.render && cn.render(this[cntr](true));
313 // then add the element..
321 if (typeof (tree.menu) != 'undefined') {
322 tree.menu.parentType = cn.xtype;
323 tree.menu.triggerEl = cn.el;
324 nitems.push(cn.addxtype(Roo.apply({}, tree.menu)));
328 if (!tree.items || !tree.items.length) {
330 //Roo.log(["no children", this]);
335 var items = tree.items;
338 //Roo.log(items.length);
340 if (!skip_children) {
341 for(var i =0;i < items.length;i++) {
342 // Roo.log(['add child', items[i]]);
343 nitems.push(cn.addxtype(Roo.apply({}, items[i])));
349 //Roo.log("fire childrenrendered");
351 cn.fireEvent('childrenrendered', this);
356 * Show a component - removes 'hidden' class
361 this.el.removeClass('hidden');
365 * Hide a component - adds 'hidden' class
369 if (this.el && !this.el.hasClass('hidden')) {
370 this.el.addClass('hidden');
384 * @class Roo.bootstrap.Body
385 * @extends Roo.bootstrap.Component
386 * Bootstrap Body class
390 * @param {Object} config The config object
393 Roo.bootstrap.Body = function(config){
395 config = config || {};
397 Roo.bootstrap.Body.superclass.constructor.call(this, config);
398 this.el = Roo.get(config.el ? config.el : document.body );
399 if (this.cls && this.cls.length) {
400 Roo.get(document.body).addClass(this.cls);
404 Roo.extend(Roo.bootstrap.Body, Roo.bootstrap.Component, {
406 is_body : true,// just to make sure it's constructed?
411 onRender : function(ct, position)
413 /* Roo.log("Roo.bootstrap.Body - onRender");
414 if (this.cls && this.cls.length) {
415 Roo.get(document.body).addClass(this.cls);
434 * @class Roo.bootstrap.ButtonGroup
435 * @extends Roo.bootstrap.Component
436 * Bootstrap ButtonGroup class
437 * @cfg {String} size lg | sm | xs (default empty normal)
438 * @cfg {String} align vertical | justified (default none)
439 * @cfg {String} direction up | down (default down)
440 * @cfg {Boolean} toolbar false | true
441 * @cfg {Boolean} btn true | false
446 * @param {Object} config The config object
449 Roo.bootstrap.ButtonGroup = function(config){
450 Roo.bootstrap.ButtonGroup.superclass.constructor.call(this, config);
453 Roo.extend(Roo.bootstrap.ButtonGroup, Roo.bootstrap.Component, {
461 getAutoCreate : function(){
467 cfg.html = this.html || cfg.html;
478 if (['vertical','justified'].indexOf(this.align)!==-1) {
479 cfg.cls = 'btn-group-' + this.align;
481 if (this.align == 'justified') {
482 console.log(this.items);
486 if (['lg','sm','xs'].indexOf(this.size)!==-1) {
487 cfg.cls += ' btn-group-' + this.size;
490 if (this.direction == 'up') {
491 cfg.cls += ' dropup' ;
507 * @class Roo.bootstrap.Button
508 * @extends Roo.bootstrap.Component
509 * Bootstrap Button class
510 * @cfg {String} html The button content
511 * @cfg {String} weight (default | primary | success | info | warning | danger | link ) default
512 * @cfg {String} size ( lg | sm | xs)
513 * @cfg {String} tag ( a | input | submit)
514 * @cfg {String} href empty or href
515 * @cfg {Boolean} disabled default false;
516 * @cfg {Boolean} isClose default false;
517 * @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)
518 * @cfg {String} badge text for badge
519 * @cfg {String} theme default
520 * @cfg {Boolean} inverse
521 * @cfg {Boolean} toggle
522 * @cfg {String} ontext text for on toggle state
523 * @cfg {String} offtext text for off toggle state
524 * @cfg {Boolean} defaulton
525 * @cfg {Boolean} preventDefault default true
526 * @cfg {Boolean} removeClass remove the standard class..
527 * @cfg {String} target target for a href. (_self|_blank|_parent|_top| other)
530 * Create a new button
531 * @param {Object} config The config object
535 Roo.bootstrap.Button = function(config){
536 Roo.bootstrap.Button.superclass.constructor.call(this, config);
541 * When a butotn is pressed
542 * @param {Roo.bootstrap.Button} this
543 * @param {Roo.EventObject} e
548 * After the button has been toggles
549 * @param {Roo.EventObject} e
550 * @param {boolean} pressed (also available as button.pressed)
556 Roo.extend(Roo.bootstrap.Button, Roo.bootstrap.Component, {
574 preventDefault: true,
583 getAutoCreate : function(){
591 if (['a', 'button', 'input', 'submit'].indexOf(this.tag) < 0) {
592 throw "Invalid value for tag: " + this.tag + ". must be a, button, input or submit.";
597 cfg.html = '<span class="roo-button-text">' + (this.html || cfg.html) + '</span>';
599 if (this.toggle == true) {
602 cls: 'slider-frame roo-button',
607 'data-off-text':'OFF',
608 cls: 'slider-button',
614 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
615 cfg.cls += ' '+this.weight;
624 cfg["aria-hidden"] = true;
626 cfg.html = "×";
632 if (this.theme==='default') {
633 cfg.cls = 'btn roo-button';
635 //if (this.parentType != 'Navbar') {
636 this.weight = this.weight.length ? this.weight : 'default';
638 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
640 cfg.cls += ' btn-' + this.weight;
642 } else if (this.theme==='glow') {
645 cfg.cls = 'btn-glow roo-button';
647 if (['default', 'primary', 'success', 'info', 'warning', 'danger', 'link'].indexOf(this.weight) > -1) {
649 cfg.cls += ' ' + this.weight;
655 this.cls += ' inverse';
660 cfg.cls += ' active';
664 cfg.disabled = 'disabled';
668 Roo.log('changing to ul' );
670 this.glyphicon = 'caret';
673 cfg.cls += this.size.length ? (' btn-' + this.size) : '';
675 //gsRoo.log(this.parentType);
676 if (this.parentType === 'Navbar' && !this.parent().bar) {
677 Roo.log('changing to li?');
686 href : this.href || '#'
689 cfg.cn[0].html = this.html + ' <span class="caret"></span>';
690 cfg.cls += ' dropdown';
697 cfg.cls += this.parentType === 'Navbar' ? ' navbar-btn' : '';
699 if (this.glyphicon) {
700 cfg.html = ' ' + cfg.html;
705 cls: 'glyphicon glyphicon-' + this.glyphicon
715 // cfg.cls='btn roo-button';
719 var value = cfg.html;
724 cls: 'glyphicon glyphicon-' + this.glyphicon,
743 cfg.cls += ' dropdown';
744 cfg.html = typeof(cfg.html) != 'undefined' ? cfg.html + ' <span class="caret"></span>' : '<span class="caret"></span>';
747 if (cfg.tag !== 'a' && this.href !== '') {
748 throw "Tag must be a to set href.";
749 } else if (this.href.length > 0) {
750 cfg.href = this.href;
753 if(this.removeClass){
758 cfg.target = this.target;
763 initEvents: function() {
764 // Roo.log('init events?');
765 // Roo.log(this.el.dom);
768 if (typeof (this.menu) != 'undefined') {
769 this.menu.parentType = this.xtype;
770 this.menu.triggerEl = this.el;
771 this.addxtype(Roo.apply({}, this.menu));
775 if (this.el.hasClass('roo-button')) {
776 this.el.on('click', this.onClick, this);
778 this.el.select('.roo-button').on('click', this.onClick, this);
781 if(this.removeClass){
782 this.el.on('click', this.onClick, this);
785 this.el.enableDisplayMode();
788 onClick : function(e)
795 Roo.log('button on click ');
796 if(this.preventDefault){
799 if (this.pressed === true || this.pressed === false) {
800 this.pressed = !this.pressed;
801 this.el[this.pressed ? 'addClass' : 'removeClass']('active');
802 this.fireEvent('toggle', this, e, this.pressed);
806 this.fireEvent('click', this, e);
810 * Enables this button
814 this.disabled = false;
815 this.el.removeClass('disabled');
819 * Disable this button
823 this.disabled = true;
824 this.el.addClass('disabled');
827 * sets the active state on/off,
828 * @param {Boolean} state (optional) Force a particular state
830 setActive : function(v) {
832 this.el[v ? 'addClass' : 'removeClass']('active');
835 * toggles the current active state
837 toggleActive : function()
839 var active = this.el.hasClass('active');
840 this.setActive(!active);
844 setText : function(str)
846 this.el.select('.roo-button-text',true).first().dom.innerHTML = str;
850 return this.el.select('.roo-button-text',true).first().dom.innerHTML;
873 * @class Roo.bootstrap.Column
874 * @extends Roo.bootstrap.Component
875 * Bootstrap Column class
876 * @cfg {Number} xs colspan out of 12 for mobile-sized screens or 0 for hidden
877 * @cfg {Number} sm colspan out of 12 for tablet-sized screens or 0 for hidden
878 * @cfg {Number} md colspan out of 12 for computer-sized screens or 0 for hidden
879 * @cfg {Number} lg colspan out of 12 for large computer-sized screens or 0 for hidden
880 * @cfg {Number} xsoff colspan offset out of 12 for mobile-sized screens or 0 for hidden
881 * @cfg {Number} smoff colspan offset out of 12 for tablet-sized screens or 0 for hidden
882 * @cfg {Number} mdoff colspan offset out of 12 for computer-sized screens or 0 for hidden
883 * @cfg {Number} lgoff colspan offset out of 12 for large computer-sized screens or 0 for hidden
886 * @cfg {Boolean} hidden (true|false) hide the element
887 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
888 * @cfg {String} fa (ban|check|...) font awesome icon
889 * @cfg {Number} fasize (1|2|....) font awsome size
891 * @cfg {String} icon (info-sign|check|...) glyphicon name
893 * @cfg {String} html content of column.
896 * Create a new Column
897 * @param {Object} config The config object
900 Roo.bootstrap.Column = function(config){
901 Roo.bootstrap.Column.superclass.constructor.call(this, config);
904 Roo.extend(Roo.bootstrap.Column, Roo.bootstrap.Component, {
922 getAutoCreate : function(){
923 var cfg = Roo.apply({}, Roo.bootstrap.Column.superclass.getAutoCreate.call(this));
931 ['xs','sm','md','lg'].map(function(size){
932 //Roo.log( size + ':' + settings[size]);
934 if (settings[size+'off'] !== false) {
935 cfg.cls += ' col-' + size + '-offset-' + settings[size+'off'] ;
938 if (settings[size] === false) {
942 if (!settings[size]) { // 0 = hidden
943 cfg.cls += ' hidden-' + size;
946 cfg.cls += ' col-' + size + '-' + settings[size];
951 cfg.cls += ' hidden';
954 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
955 cfg.cls +=' alert alert-' + this.alert;
959 if (this.html.length) {
960 cfg.html = this.html;
964 if (this.fasize > 1) {
965 fasize = ' fa-' + this.fasize + 'x';
967 cfg.html = '<i class="fa fa-'+this.fa + fasize + '"></i>' + (cfg.html || '');
972 cfg.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + (cfg.html || '');
991 * @class Roo.bootstrap.Container
992 * @extends Roo.bootstrap.Component
993 * Bootstrap Container class
994 * @cfg {Boolean} jumbotron is it a jumbotron element
995 * @cfg {String} html content of element
996 * @cfg {String} well (lg|sm|md) a well, large, small or medium.
997 * @cfg {String} panel (primary|success|info|warning|danger) render as panel - type - primary/success.....
998 * @cfg {String} header content of header (for panel)
999 * @cfg {String} footer content of footer (for panel)
1000 * @cfg {String} sticky (footer|wrap|push) block to use as footer or body- needs css-bootstrap/sticky-footer.css
1001 * @cfg {String} tag (header|aside|section) type of HTML tag.
1002 * @cfg {String} alert (success|info|warning|danger) type alert (changes background / border...)
1003 * @cfg {String} fa font awesome icon
1004 * @cfg {String} icon (info-sign|check|...) glyphicon name
1005 * @cfg {Boolean} hidden (true|false) hide the element
1006 * @cfg {Boolean} expandable (true|false) default false
1007 * @cfg {Boolean} expanded (true|false) default true
1008 * @cfg {String} rheader contet on the right of header
1009 * @cfg {Boolean} clickable (true|false) default false
1013 * Create a new Container
1014 * @param {Object} config The config object
1017 Roo.bootstrap.Container = function(config){
1018 Roo.bootstrap.Container.superclass.constructor.call(this, config);
1024 * After the panel has been expand
1026 * @param {Roo.bootstrap.Container} this
1031 * After the panel has been collapsed
1033 * @param {Roo.bootstrap.Container} this
1038 * When a element is chick
1039 * @param {Roo.bootstrap.Container} this
1040 * @param {Roo.EventObject} e
1046 Roo.extend(Roo.bootstrap.Container, Roo.bootstrap.Component, {
1064 getChildContainer : function() {
1070 if (this.panel.length) {
1071 return this.el.select('.panel-body',true).first();
1078 getAutoCreate : function(){
1081 tag : this.tag || 'div',
1085 if (this.jumbotron) {
1086 cfg.cls = 'jumbotron';
1091 // - this is applied by the parent..
1093 // cfg.cls = this.cls + '';
1096 if (this.sticky.length) {
1098 var bd = Roo.get(document.body);
1099 if (!bd.hasClass('bootstrap-sticky')) {
1100 bd.addClass('bootstrap-sticky');
1101 Roo.select('html',true).setStyle('height', '100%');
1104 cfg.cls += 'bootstrap-sticky-' + this.sticky;
1108 if (this.well.length) {
1109 switch (this.well) {
1112 cfg.cls +=' well well-' +this.well;
1121 cfg.cls += ' hidden';
1125 if (this.alert && ["success","info","warning", "danger"].indexOf(this.alert) > -1) {
1126 cfg.cls +=' alert alert-' + this.alert;
1131 if (this.panel.length) {
1132 cfg.cls += ' panel panel-' + this.panel;
1134 if (this.header.length) {
1138 if(this.expandable){
1140 cfg.cls = cfg.cls + ' expandable';
1144 cls: (this.expanded ? 'fa fa-minus' : 'fa fa-plus')
1152 cls : 'panel-title',
1153 html : (this.expandable ? ' ' : '') + this.header
1157 cls: 'panel-header-right',
1163 cls : 'panel-heading',
1164 style : this.expandable ? 'cursor: pointer' : '',
1172 cls : 'panel-body' + (this.expanded ? '' : ' hide'),
1177 if (this.footer.length) {
1179 cls : 'panel-footer',
1188 body.html = this.html || cfg.html;
1189 // prefix with the icons..
1191 body.html = '<i class="fa fa-'+this.fa + '"></i>' + body.html ;
1194 body.html = '<i class="glyphicon glyphicon-'+this.icon + '"></i>' + body.html ;
1199 if ((!this.cls || !this.cls.length) && (!cfg.cls || !cfg.cls.length)) {
1200 cfg.cls = 'container';
1206 initEvents: function()
1208 if(this.expandable){
1209 var headerEl = this.headerEl();
1212 headerEl.on('click', this.onToggleClick, this);
1217 this.el.on('click', this.onClick, this);
1222 onToggleClick : function()
1224 var headerEl = this.headerEl();
1240 if(this.fireEvent('expand', this)) {
1242 this.expanded = true;
1244 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).show();
1246 this.el.select('.panel-body',true).first().removeClass('hide');
1248 var toggleEl = this.toggleEl();
1254 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-minus']);
1259 collapse : function()
1261 if(this.fireEvent('collapse', this)) {
1263 this.expanded = false;
1265 //this.el.select('.panel-body',true).first().setVisibilityMode(Roo.Element.DISPLAY).hide();
1266 this.el.select('.panel-body',true).first().addClass('hide');
1268 var toggleEl = this.toggleEl();
1274 toggleEl.removeClass(['fa-minus', 'fa-plus']).addClass(['fa-plus']);
1278 toggleEl : function()
1280 if(!this.el || !this.panel.length || !this.header.length || !this.expandable){
1284 return this.el.select('.panel-heading .fa',true).first();
1287 headerEl : function()
1289 if(!this.el || !this.panel.length || !this.header.length){
1293 return this.el.select('.panel-heading',true).first()
1298 if(!this.el || !this.panel.length){
1302 return this.el.select('.panel-body',true).first()
1305 titleEl : function()
1307 if(!this.el || !this.panel.length || !this.header.length){
1311 return this.el.select('.panel-title',true).first();
1314 setTitle : function(v)
1316 var titleEl = this.titleEl();
1322 titleEl.dom.innerHTML = v;
1325 getTitle : function()
1328 var titleEl = this.titleEl();
1334 return titleEl.dom.innerHTML;
1337 setRightTitle : function(v)
1339 var t = this.el.select('.panel-header-right',true).first();
1345 t.dom.innerHTML = v;
1348 onClick : function(e)
1352 this.fireEvent('click', this, e);
1366 * @class Roo.bootstrap.Img
1367 * @extends Roo.bootstrap.Component
1368 * Bootstrap Img class
1369 * @cfg {Boolean} imgResponsive false | true
1370 * @cfg {String} border rounded | circle | thumbnail
1371 * @cfg {String} src image source
1372 * @cfg {String} alt image alternative text
1373 * @cfg {String} href a tag href
1374 * @cfg {String} target (_self|_blank|_parent|_top)target for a href.
1375 * @cfg {String} xsUrl xs image source
1376 * @cfg {String} smUrl sm image source
1377 * @cfg {String} mdUrl md image source
1378 * @cfg {String} lgUrl lg image source
1381 * Create a new Input
1382 * @param {Object} config The config object
1385 Roo.bootstrap.Img = function(config){
1386 Roo.bootstrap.Img.superclass.constructor.call(this, config);
1392 * The img click event for the img.
1393 * @param {Roo.EventObject} e
1399 Roo.extend(Roo.bootstrap.Img, Roo.bootstrap.Component, {
1401 imgResponsive: true,
1411 getAutoCreate : function()
1413 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1414 return this.createSingleImg();
1419 cls: 'roo-image-responsive-group',
1424 Roo.each(['xs', 'sm', 'md', 'lg'], function(size){
1426 if(!_this[size + 'Url']){
1432 cls: (_this.imgResponsive) ? 'img-responsive' : '',
1433 html: _this.html || cfg.html,
1434 src: _this[size + 'Url']
1437 img.cls += ' roo-image-responsive-' + size;
1439 var s = ['xs', 'sm', 'md', 'lg'];
1441 s.splice(s.indexOf(size), 1);
1443 Roo.each(s, function(ss){
1444 img.cls += ' hidden-' + ss;
1447 if (['rounded','circle','thumbnail'].indexOf(_this.border)>-1) {
1448 cfg.cls += ' img-' + _this.border;
1452 cfg.alt = _this.alt;
1465 a.target = _this.target;
1469 cfg.cn.push((_this.href) ? a : img);
1476 createSingleImg : function()
1480 cls: (this.imgResponsive) ? 'img-responsive' : '',
1482 src : 'about:blank' // just incase src get's set to undefined?!?
1485 cfg.html = this.html || cfg.html;
1487 cfg.src = this.src || cfg.src;
1489 if (['rounded','circle','thumbnail'].indexOf(this.border)>-1) {
1490 cfg.cls += ' img-' + this.border;
1507 a.target = this.target;
1512 return (this.href) ? a : cfg;
1515 initEvents: function()
1518 this.el.on('click', this.onClick, this);
1523 onClick : function(e)
1525 Roo.log('img onclick');
1526 this.fireEvent('click', this, e);
1529 * Sets the url of the image - used to update it
1530 * @param {String} url the url of the image
1533 setSrc : function(url)
1537 if(this.src || (!this.xsUrl && !this.smUrl && !this.mdUrl && !this.lgUrl)){
1538 this.el.dom.src = url;
1542 this.el.select('img', true).first().dom.src = url;
1558 * @class Roo.bootstrap.Link
1559 * @extends Roo.bootstrap.Component
1560 * Bootstrap Link Class
1561 * @cfg {String} alt image alternative text
1562 * @cfg {String} href a tag href
1563 * @cfg {String} target (_self|_blank|_parent|_top) target for a href.
1564 * @cfg {String} html the content of the link.
1565 * @cfg {String} anchor name for the anchor link
1566 * @cfg {String} fa - favicon
1568 * @cfg {Boolean} preventDefault (true | false) default false
1572 * Create a new Input
1573 * @param {Object} config The config object
1576 Roo.bootstrap.Link = function(config){
1577 Roo.bootstrap.Link.superclass.constructor.call(this, config);
1583 * The img click event for the img.
1584 * @param {Roo.EventObject} e
1590 Roo.extend(Roo.bootstrap.Link, Roo.bootstrap.Component, {
1594 preventDefault: false,
1600 getAutoCreate : function()
1602 var html = this.html || '';
1604 if (this.fa !== false) {
1605 html = '<i class="fa fa-' + this.fa + '"></i>';
1610 // anchor's do not require html/href...
1611 if (this.anchor === false) {
1613 cfg.href = this.href || '#';
1615 cfg.name = this.anchor;
1616 if (this.html !== false || this.fa !== false) {
1619 if (this.href !== false) {
1620 cfg.href = this.href;
1624 if(this.alt !== false){
1629 if(this.target !== false) {
1630 cfg.target = this.target;
1636 initEvents: function() {
1638 if(!this.href || this.preventDefault){
1639 this.el.on('click', this.onClick, this);
1643 onClick : function(e)
1645 if(this.preventDefault){
1648 //Roo.log('img onclick');
1649 this.fireEvent('click', this, e);
1662 * @class Roo.bootstrap.Header
1663 * @extends Roo.bootstrap.Component
1664 * Bootstrap Header class
1665 * @cfg {String} html content of header
1666 * @cfg {Number} level (1|2|3|4|5|6) default 1
1669 * Create a new Header
1670 * @param {Object} config The config object
1674 Roo.bootstrap.Header = function(config){
1675 Roo.bootstrap.Header.superclass.constructor.call(this, config);
1678 Roo.extend(Roo.bootstrap.Header, Roo.bootstrap.Component, {
1686 getAutoCreate : function(){
1691 tag: 'h' + (1 *this.level),
1692 html: this.html || ''
1704 * Ext JS Library 1.1.1
1705 * Copyright(c) 2006-2007, Ext JS, LLC.
1707 * Originally Released Under LGPL - original licence link has changed is not relivant.
1710 * <script type="text/javascript">
1714 * @class Roo.bootstrap.MenuMgr
1715 * Provides a common registry of all menu items on a page so that they can be easily accessed by id.
1718 Roo.bootstrap.MenuMgr = function(){
1719 var menus, active, groups = {}, attached = false, lastShow = new Date();
1721 // private - called when first menu is created
1724 active = new Roo.util.MixedCollection();
1725 Roo.get(document).addKeyListener(27, function(){
1726 if(active.length > 0){
1734 if(active && active.length > 0){
1735 var c = active.clone();
1745 if(active.length < 1){
1746 Roo.get(document).un("mouseup", onMouseDown);
1754 var last = active.last();
1755 lastShow = new Date();
1758 Roo.get(document).on("mouseup", onMouseDown);
1763 //m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
1764 m.parentMenu.activeChild = m;
1765 }else if(last && last.isVisible()){
1766 //m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
1771 function onBeforeHide(m){
1773 m.activeChild.hide();
1775 if(m.autoHideTimer){
1776 clearTimeout(m.autoHideTimer);
1777 delete m.autoHideTimer;
1782 function onBeforeShow(m){
1783 var pm = m.parentMenu;
1784 if(!pm && !m.allowOtherMenus){
1786 }else if(pm && pm.activeChild && active != m){
1787 pm.activeChild.hide();
1791 // private this should really trigger on mouseup..
1792 function onMouseDown(e){
1793 Roo.log("on Mouse Up");
1795 if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".dropdown-menu") && !e.getTarget('.user-menu')){
1796 Roo.log("MenuManager hideAll");
1805 function onBeforeCheck(mi, state){
1807 var g = groups[mi.group];
1808 for(var i = 0, l = g.length; i < l; i++){
1810 g[i].setChecked(false);
1819 * Hides all menus that are currently visible
1821 hideAll : function(){
1826 register : function(menu){
1830 menus[menu.id] = menu;
1831 menu.on("beforehide", onBeforeHide);
1832 menu.on("hide", onHide);
1833 menu.on("beforeshow", onBeforeShow);
1834 menu.on("show", onShow);
1836 if(g && menu.events["checkchange"]){
1840 groups[g].push(menu);
1841 menu.on("checkchange", onCheck);
1846 * Returns a {@link Roo.menu.Menu} object
1847 * @param {String/Object} menu The string menu id, an existing menu object reference, or a Menu config that will
1848 * be used to generate and return a new Menu instance.
1850 get : function(menu){
1851 if(typeof menu == "string"){ // menu id
1853 }else if(menu.events){ // menu instance
1856 /*else if(typeof menu.length == 'number'){ // array of menu items?
1857 return new Roo.bootstrap.Menu({items:menu});
1858 }else{ // otherwise, must be a config
1859 return new Roo.bootstrap.Menu(menu);
1866 unregister : function(menu){
1867 delete menus[menu.id];
1868 menu.un("beforehide", onBeforeHide);
1869 menu.un("hide", onHide);
1870 menu.un("beforeshow", onBeforeShow);
1871 menu.un("show", onShow);
1873 if(g && menu.events["checkchange"]){
1874 groups[g].remove(menu);
1875 menu.un("checkchange", onCheck);
1880 registerCheckable : function(menuItem){
1881 var g = menuItem.group;
1886 groups[g].push(menuItem);
1887 menuItem.on("beforecheckchange", onBeforeCheck);
1892 unregisterCheckable : function(menuItem){
1893 var g = menuItem.group;
1895 groups[g].remove(menuItem);
1896 menuItem.un("beforecheckchange", onBeforeCheck);
1908 * @class Roo.bootstrap.Menu
1909 * @extends Roo.bootstrap.Component
1910 * Bootstrap Menu class - container for MenuItems
1911 * @cfg {String} type (dropdown|treeview|submenu) type of menu
1912 * @cfg {bool} hidden if the menu should be hidden when rendered.
1913 * @cfg {bool} stopEvent (true|false) Stop event after trigger press (default true)
1914 * @cfg {bool} isLink (true|false) the menu has link disable auto expand and collaspe (default false)
1918 * @param {Object} config The config object
1922 Roo.bootstrap.Menu = function(config){
1923 Roo.bootstrap.Menu.superclass.constructor.call(this, config);
1924 if (this.registerMenu && this.type != 'treeview') {
1925 Roo.bootstrap.MenuMgr.register(this);
1930 * Fires before this menu is displayed
1931 * @param {Roo.menu.Menu} this
1936 * Fires before this menu is hidden
1937 * @param {Roo.menu.Menu} this
1942 * Fires after this menu is displayed
1943 * @param {Roo.menu.Menu} this
1948 * Fires after this menu is hidden
1949 * @param {Roo.menu.Menu} this
1954 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
1955 * @param {Roo.menu.Menu} this
1956 * @param {Roo.menu.Item} menuItem The menu item that was clicked
1957 * @param {Roo.EventObject} e
1962 * Fires when the mouse is hovering over this menu
1963 * @param {Roo.menu.Menu} this
1964 * @param {Roo.EventObject} e
1965 * @param {Roo.menu.Item} menuItem The menu item that was clicked
1970 * Fires when the mouse exits this menu
1971 * @param {Roo.menu.Menu} this
1972 * @param {Roo.EventObject} e
1973 * @param {Roo.menu.Item} menuItem The menu item that was clicked
1978 * Fires when a menu item contained in this menu is clicked
1979 * @param {Roo.menu.BaseItem} baseItem The BaseItem that was clicked
1980 * @param {Roo.EventObject} e
1984 this.menuitems = new Roo.util.MixedCollection(false, function(o) { return o.el.id; });
1987 Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, {
1991 triggerEl : false, // is this set by component builder? -- it should really be fetched from parent()???
1994 * @cfg {Boolean} registerMenu True (default) - means that clicking on screen etc. hides it.
1996 registerMenu : true,
1998 menuItems :false, // stores the menu items..
2008 getChildContainer : function() {
2012 getAutoCreate : function(){
2014 //if (['right'].indexOf(this.align)!==-1) {
2015 // cfg.cn[1].cls += ' pull-right'
2021 cls : 'dropdown-menu' ,
2022 style : 'z-index:1000'
2026 if (this.type === 'submenu') {
2027 cfg.cls = 'submenu active';
2029 if (this.type === 'treeview') {
2030 cfg.cls = 'treeview-menu';
2035 initEvents : function() {
2037 // Roo.log("ADD event");
2038 // Roo.log(this.triggerEl.dom);
2040 this.triggerEl.on('click', this.onTriggerClick, this);
2042 this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this);
2044 this.triggerEl.addClass('dropdown-toggle');
2047 this.el.on('touchstart' , this.onTouch, this);
2049 this.el.on('click' , this.onClick, this);
2051 this.el.on("mouseover", this.onMouseOver, this);
2052 this.el.on("mouseout", this.onMouseOut, this);
2056 findTargetItem : function(e)
2058 var t = e.getTarget(".dropdown-menu-item", this.el, true);
2062 //Roo.log(t); Roo.log(t.id);
2064 //Roo.log(this.menuitems);
2065 return this.menuitems.get(t.id);
2067 //return this.items.get(t.menuItemId);
2073 onTouch : function(e)
2075 Roo.log("menu.onTouch");
2076 //e.stopEvent(); this make the user popdown broken
2080 onClick : function(e)
2082 Roo.log("menu.onClick");
2084 var t = this.findTargetItem(e);
2085 if(!t || t.isContainer){
2090 if (Roo.isTouch && e.type == 'touchstart' && t.menu && !t.disabled) {
2091 if(t == this.activeItem && t.shouldDeactivate(e)){
2092 this.activeItem.deactivate();
2093 delete this.activeItem;
2097 this.setActiveItem(t, true);
2105 Roo.log('pass click event');
2109 this.fireEvent("click", this, t, e);
2113 (function() { _this.hide(); }).defer(100);
2116 onMouseOver : function(e){
2117 var t = this.findTargetItem(e);
2120 // if(t.canActivate && !t.disabled){
2121 // this.setActiveItem(t, true);
2125 this.fireEvent("mouseover", this, e, t);
2127 isVisible : function(){
2128 return !this.hidden;
2130 onMouseOut : function(e){
2131 var t = this.findTargetItem(e);
2134 // if(t == this.activeItem && t.shouldDeactivate(e)){
2135 // this.activeItem.deactivate();
2136 // delete this.activeItem;
2139 this.fireEvent("mouseout", this, e, t);
2144 * Displays this menu relative to another element
2145 * @param {String/HTMLElement/Roo.Element} element The element to align to
2146 * @param {String} position (optional) The {@link Roo.Element#alignTo} anchor position to use in aligning to
2147 * the element (defaults to this.defaultAlign)
2148 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2150 show : function(el, pos, parentMenu){
2151 this.parentMenu = parentMenu;
2155 this.fireEvent("beforeshow", this);
2156 this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign), parentMenu, false);
2159 * Displays this menu at a specific xy position
2160 * @param {Array} xyPosition Contains X & Y [x, y] values for the position at which to show the menu (coordinates are page-based)
2161 * @param {Roo.menu.Menu} parentMenu (optional) This menu's parent menu, if applicable (defaults to undefined)
2163 showAt : function(xy, parentMenu, /* private: */_e){
2164 this.parentMenu = parentMenu;
2169 this.fireEvent("beforeshow", this);
2170 //xy = this.el.adjustForConstraints(xy);
2174 this.hideMenuItems();
2175 this.hidden = false;
2176 this.triggerEl.addClass('open');
2178 if(this.el.getWidth() + xy[0] > Roo.lib.Dom.getViewWidth()){
2179 xy[0] = xy[0] - this.el.getWidth() + this.triggerEl.getWidth();
2182 if(this.el.getStyle('top') != 'auto' && this.el.getStyle('top').slice(-1) != "%"){
2187 this.fireEvent("show", this);
2193 this.doFocus.defer(50, this);
2197 doFocus : function(){
2199 this.focusEl.focus();
2204 * Hides this menu and optionally all parent menus
2205 * @param {Boolean} deep (optional) True to hide all parent menus recursively, if any (defaults to false)
2207 hide : function(deep)
2210 this.hideMenuItems();
2211 if(this.el && this.isVisible()){
2212 this.fireEvent("beforehide", this);
2213 if(this.activeItem){
2214 this.activeItem.deactivate();
2215 this.activeItem = null;
2217 this.triggerEl.removeClass('open');;
2219 this.fireEvent("hide", this);
2221 if(deep === true && this.parentMenu){
2222 this.parentMenu.hide(true);
2226 onTriggerClick : function(e)
2228 Roo.log('trigger click');
2230 var target = e.getTarget();
2232 Roo.log(target.nodeName.toLowerCase());
2234 if(target.nodeName.toLowerCase() === 'i'){
2240 onTriggerPress : function(e)
2242 Roo.log('trigger press');
2243 //Roo.log(e.getTarget());
2244 // Roo.log(this.triggerEl.dom);
2246 // trigger only occurs on normal menu's -- if it's a treeview or dropdown... do not hide/show..
2247 var pel = Roo.get(e.getTarget());
2248 if (pel.findParent('.dropdown-menu') || pel.findParent('.treeview-menu') ) {
2249 Roo.log('is treeview or dropdown?');
2253 if(e.getTarget().nodeName.toLowerCase() !== 'i' && this.isLink){
2257 if (this.isVisible()) {
2262 this.show(this.triggerEl, false, false);
2265 if(this.stopEvent || e.getTarget().nodeName.toLowerCase() === 'i'){
2272 hideMenuItems : function()
2274 Roo.log("hide Menu Items");
2278 //$(backdrop).remove()
2279 this.el.select('.open',true).each(function(aa) {
2281 aa.removeClass('open');
2282 //var parent = getParent($(this))
2283 //var relatedTarget = { relatedTarget: this }
2285 //$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
2286 //if (e.isDefaultPrevented()) return
2287 //$parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
2290 addxtypeChild : function (tree, cntr) {
2291 var comp= Roo.bootstrap.Menu.superclass.addxtypeChild.call(this, tree, cntr);
2293 this.menuitems.add(comp);
2314 * @class Roo.bootstrap.MenuItem
2315 * @extends Roo.bootstrap.Component
2316 * Bootstrap MenuItem class
2317 * @cfg {String} html the menu label
2318 * @cfg {String} href the link
2319 * @cfg {Boolean} preventDefault do not trigger A href on clicks (default false).
2320 * @cfg {Boolean} isContainer is it a container - just returns a drop down item..
2321 * @cfg {Boolean} active used on sidebars to highlight active itesm
2322 * @cfg {String} fa favicon to show on left of menu item.
2323 * @cfg {Roo.bootsrap.Menu} menu the child menu.
2327 * Create a new MenuItem
2328 * @param {Object} config The config object
2332 Roo.bootstrap.MenuItem = function(config){
2333 Roo.bootstrap.MenuItem.superclass.constructor.call(this, config);
2338 * The raw click event for the entire grid.
2339 * @param {Roo.bootstrap.MenuItem} this
2340 * @param {Roo.EventObject} e
2346 Roo.extend(Roo.bootstrap.MenuItem, Roo.bootstrap.Component, {
2350 preventDefault: false,
2351 isContainer : false,
2355 getAutoCreate : function(){
2357 if(this.isContainer){
2360 cls: 'dropdown-menu-item'
2374 if (this.fa !== false) {
2377 cls : 'fa fa-' + this.fa
2386 cls: 'dropdown-menu-item',
2389 if (this.parent().type == 'treeview') {
2390 cfg.cls = 'treeview-menu';
2393 cfg.cls += ' active';
2398 anc.href = this.href || cfg.cn[0].href ;
2399 ctag.html = this.html || cfg.cn[0].html ;
2403 initEvents: function()
2405 if (this.parent().type == 'treeview') {
2406 this.el.select('a').on('click', this.onClick, this);
2409 this.menu.parentType = this.xtype;
2410 this.menu.triggerEl = this.el;
2411 this.menu = this.addxtype(Roo.apply({}, this.menu));
2415 onClick : function(e)
2417 Roo.log('item on click ');
2419 if(this.preventDefault){
2422 //this.parent().hideMenuItems();
2424 this.fireEvent('click', this, e);
2443 * @class Roo.bootstrap.MenuSeparator
2444 * @extends Roo.bootstrap.Component
2445 * Bootstrap MenuSeparator class
2448 * Create a new MenuItem
2449 * @param {Object} config The config object
2453 Roo.bootstrap.MenuSeparator = function(config){
2454 Roo.bootstrap.MenuSeparator.superclass.constructor.call(this, config);
2457 Roo.extend(Roo.bootstrap.MenuSeparator, Roo.bootstrap.Component, {
2459 getAutoCreate : function(){
2478 * @class Roo.bootstrap.Modal
2479 * @extends Roo.bootstrap.Component
2480 * Bootstrap Modal class
2481 * @cfg {String} title Title of dialog
2482 * @cfg {String} html - the body of the dialog (for simple ones) - you can also use template..
2483 * @cfg {Roo.Template} tmpl - a template with variables. to use it, add a handler in show:method adn
2484 * @cfg {Boolean} specificTitle default false
2485 * @cfg {Array} buttons Array of buttons or standard button set..
2486 * @cfg {String} buttonPosition (left|right|center) default right
2487 * @cfg {Boolean} animate default true
2488 * @cfg {Boolean} allow_close default true
2489 * @cfg {Boolean} fitwindow default false
2490 * @cfg {String} size (sm|lg) default empty
2494 * Create a new Modal Dialog
2495 * @param {Object} config The config object
2498 Roo.bootstrap.Modal = function(config){
2499 Roo.bootstrap.Modal.superclass.constructor.call(this, config);
2504 * The raw btnclick event for the button
2505 * @param {Roo.EventObject} e
2510 * Fire when dialog resize
2511 * @param {Roo.bootstrap.Modal} this
2512 * @param {Roo.EventObject} e
2516 this.buttons = this.buttons || [];
2519 this.tmpl = Roo.factory(this.tmpl);
2524 Roo.extend(Roo.bootstrap.Modal, Roo.bootstrap.Component, {
2526 title : 'test dialog',
2536 specificTitle: false,
2538 buttonPosition: 'right',
2557 onRender : function(ct, position)
2559 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
2562 var cfg = Roo.apply({}, this.getAutoCreate());
2565 // cfg.name = typeof(this.name) == 'undefined' ? this.id : this.name;
2567 //if (!cfg.name.length) {
2571 cfg.cls += ' ' + this.cls;
2574 cfg.style = this.style;
2576 this.el = Roo.get(document.body).createChild(cfg, position);
2578 //var type = this.el.dom.type;
2581 if(this.tabIndex !== undefined){
2582 this.el.dom.setAttribute('tabIndex', this.tabIndex);
2585 this.dialogEl = this.el.select('.modal-dialog',true).first();
2586 this.bodyEl = this.el.select('.modal-body',true).first();
2587 this.closeEl = this.el.select('.modal-header .close', true).first();
2588 this.headerEl = this.el.select('.modal-header',true).first();
2589 this.titleEl = this.el.select('.modal-title',true).first();
2590 this.footerEl = this.el.select('.modal-footer',true).first();
2592 this.maskEl = Roo.DomHelper.append(document.body, {tag: "div", cls:"x-dlg-mask"}, true);
2593 this.maskEl.enableDisplayMode("block");
2595 //this.el.addClass("x-dlg-modal");
2597 if (this.buttons.length) {
2598 Roo.each(this.buttons, function(bb) {
2599 var b = Roo.apply({}, bb);
2600 b.xns = b.xns || Roo.bootstrap;
2601 b.xtype = b.xtype || 'Button';
2602 if (typeof(b.listeners) == 'undefined') {
2603 b.listeners = { click : this.onButtonClick.createDelegate(this) };
2606 var btn = Roo.factory(b);
2608 btn.render(this.el.select('.modal-footer div').first());
2612 // render the children.
2615 if(typeof(this.items) != 'undefined'){
2616 var items = this.items;
2619 for(var i =0;i < items.length;i++) {
2620 nitems.push(this.addxtype(Roo.apply({}, items[i])));
2624 this.items = nitems;
2626 // where are these used - they used to be body/close/footer
2630 //this.el.addClass([this.fieldClass, this.cls]);
2634 getAutoCreate : function(){
2639 html : this.html || ''
2644 cls : 'modal-title',
2648 if(this.specificTitle){
2654 if (this.allow_close) {
2666 if(this.size.length){
2667 size = 'modal-' + this.size;
2672 style : 'display: none',
2675 cls: "modal-dialog " + size,
2678 cls : "modal-content",
2681 cls : 'modal-header',
2686 cls : 'modal-footer',
2690 cls: 'btn-' + this.buttonPosition
2707 modal.cls += ' fade';
2713 getChildContainer : function() {
2718 getButtonContainer : function() {
2719 return this.el.select('.modal-footer div',true).first();
2722 initEvents : function()
2724 if (this.allow_close) {
2725 this.closeEl.on('click', this.hide, this);
2727 Roo.EventManager.onWindowResize(this.resize, this, true);
2734 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
2735 if (this.fitwindow) {
2736 var w = this.width || Roo.lib.Dom.getViewportWidth(true) - 30;
2737 var h = this.height || Roo.lib.Dom.getViewportHeight(true) - 60;
2742 setSize : function(w,h)
2752 if (!this.rendered) {
2756 this.el.setStyle('display', 'block');
2758 if(this.animate){ // element has 'fade' - so stuff happens after .3s ?- not sure why the delay?
2761 this.el.addClass('in');
2764 this.el.addClass('in');
2768 // not sure how we can show data in here..
2770 // this.getChildContainer().dom.innerHTML = this.tmpl.applyTemplate(this);
2773 Roo.get(document.body).addClass("x-body-masked");
2775 this.maskEl.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
2776 this.maskEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
2781 this.fireEvent('show', this);
2783 // set zindex here - otherwise it appears to be ignored...
2784 this.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
2787 this.items.forEach( function(e) {
2788 e.layout ? e.layout() : false;
2796 if(this.fireEvent("beforehide", this) !== false){
2798 Roo.get(document.body).removeClass("x-body-masked");
2799 this.el.removeClass('in');
2800 this.el.select('.modal-dialog', true).first().setStyle('transform','');
2802 if(this.animate){ // why
2804 (function(){ _this.el.setStyle('display', 'none'); }).defer(150);
2806 this.el.setStyle('display', 'none');
2808 this.fireEvent('hide', this);
2812 addButton : function(str, cb)
2816 var b = Roo.apply({}, { html : str } );
2817 b.xns = b.xns || Roo.bootstrap;
2818 b.xtype = b.xtype || 'Button';
2819 if (typeof(b.listeners) == 'undefined') {
2820 b.listeners = { click : cb.createDelegate(this) };
2823 var btn = Roo.factory(b);
2825 btn.render(this.el.select('.modal-footer div').first());
2831 setDefaultButton : function(btn)
2833 //this.el.select('.modal-footer').()
2837 resizeTo: function(w,h)
2841 this.dialogEl.setWidth(w);
2842 if (this.diff === false) {
2843 this.diff = this.dialogEl.getHeight() - this.bodyEl.getHeight();
2846 this.bodyEl.setHeight(h-this.diff);
2848 this.fireEvent('resize', this);
2851 setContentSize : function(w, h)
2855 onButtonClick: function(btn,e)
2858 this.fireEvent('btnclick', btn.name, e);
2861 * Set the title of the Dialog
2862 * @param {String} str new Title
2864 setTitle: function(str) {
2865 this.titleEl.dom.innerHTML = str;
2868 * Set the body of the Dialog
2869 * @param {String} str new Title
2871 setBody: function(str) {
2872 this.bodyEl.dom.innerHTML = str;
2875 * Set the body of the Dialog using the template
2876 * @param {Obj} data - apply this data to the template and replace the body contents.
2878 applyBody: function(obj)
2881 Roo.log("Error - using apply Body without a template");
2884 this.tmpl.overwrite(this.bodyEl, obj);
2890 Roo.apply(Roo.bootstrap.Modal, {
2892 * Button config that displays a single OK button
2901 * Button config that displays Yes and No buttons
2917 * Button config that displays OK and Cancel buttons
2932 * Button config that displays Yes, No and Cancel buttons
2956 * messagebox - can be used as a replace
2960 * @class Roo.MessageBox
2961 * Utility class for generating different styles of message boxes. The alias Roo.Msg can also be used.
2965 Roo.Msg.alert('Status', 'Changes saved successfully.');
2967 // Prompt for user data:
2968 Roo.Msg.prompt('Name', 'Please enter your name:', function(btn, text){
2970 // process text value...
2974 // Show a dialog using config options:
2976 title:'Save Changes?',
2977 msg: 'Your are closing a tab that has unsaved changes. Would you like to save your changes?',
2978 buttons: Roo.Msg.YESNOCANCEL,
2985 Roo.bootstrap.MessageBox = function(){
2986 var dlg, opt, mask, waitTimer;
2987 var bodyEl, msgEl, textboxEl, textareaEl, progressEl, pp;
2988 var buttons, activeTextEl, bwidth;
2992 var handleButton = function(button){
2994 Roo.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
2998 var handleHide = function(){
3000 dlg.el.removeClass(opt.cls);
3003 // Roo.TaskMgr.stop(waitTimer);
3004 // waitTimer = null;
3009 var updateButtons = function(b){
3012 buttons["ok"].hide();
3013 buttons["cancel"].hide();
3014 buttons["yes"].hide();
3015 buttons["no"].hide();
3016 //dlg.footer.dom.style.display = 'none';
3019 dlg.footerEl.dom.style.display = '';
3020 for(var k in buttons){
3021 if(typeof buttons[k] != "function"){
3024 buttons[k].setText(typeof b[k] == "string" ? b[k] : Roo.bootstrap.MessageBox.buttonText[k]);
3025 width += buttons[k].el.getWidth()+15;
3035 var handleEsc = function(d, k, e){
3036 if(opt && opt.closable !== false){
3046 * Returns a reference to the underlying {@link Roo.BasicDialog} element
3047 * @return {Roo.BasicDialog} The BasicDialog element
3049 getDialog : function(){
3051 dlg = new Roo.bootstrap.Modal( {
3054 //constraintoviewport:false,
3056 //collapsible : false,
3061 //buttonAlign:"center",
3062 closeClick : function(){
3063 if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
3066 handleButton("cancel");
3071 dlg.on("hide", handleHide);
3073 //dlg.addKeyListener(27, handleEsc);
3075 this.buttons = buttons;
3076 var bt = this.buttonText;
3077 buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
3078 buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
3079 buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
3080 buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
3082 bodyEl = dlg.bodyEl.createChild({
3084 html:'<span class="roo-mb-text"></span><br /><input type="text" class="roo-mb-input" />' +
3085 '<textarea class="roo-mb-textarea"></textarea>' +
3086 '<div class="roo-mb-progress-wrap"><div class="roo-mb-progress"><div class="roo-mb-progress-bar"> </div></div></div>'
3088 msgEl = bodyEl.dom.firstChild;
3089 textboxEl = Roo.get(bodyEl.dom.childNodes[2]);
3090 textboxEl.enableDisplayMode();
3091 textboxEl.addKeyListener([10,13], function(){
3092 if(dlg.isVisible() && opt && opt.buttons){
3095 }else if(opt.buttons.yes){
3096 handleButton("yes");
3100 textareaEl = Roo.get(bodyEl.dom.childNodes[3]);
3101 textareaEl.enableDisplayMode();
3102 progressEl = Roo.get(bodyEl.dom.childNodes[4]);
3103 progressEl.enableDisplayMode();
3105 // This is supposed to be the progessElement.. but I think it's controlling the height of everything..
3106 //var pf = progressEl.dom.firstChild;
3108 //pp = Roo.get(pf.firstChild);
3109 //pp.setHeight(pf.offsetHeight);
3117 * Updates the message box body text
3118 * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to
3119 * the XHTML-compliant non-breaking space character '&#160;')
3120 * @return {Roo.MessageBox} This message box
3122 updateText : function(text)
3124 if(!dlg.isVisible() && !opt.width){
3125 dlg.dialogEl.setWidth(this.maxWidth);
3126 // dlg.resizeTo(this.maxWidth, 100); // forcing the height breaks long alerts()
3128 msgEl.innerHTML = text || ' ';
3130 var cw = Math.max(msgEl.offsetWidth, msgEl.parentNode.scrollWidth);
3131 //Roo.log("guesed size: " + JSON.stringify([cw,msgEl.offsetWidth, msgEl.parentNode.scrollWidth]));
3133 Math.min(opt.width || cw , this.maxWidth),
3134 Math.max(opt.minWidth || this.minWidth, bwidth)
3137 activeTextEl.setWidth(w);
3139 if(dlg.isVisible()){
3140 dlg.fixedcenter = false;
3142 // to big, make it scroll. = But as usual stupid IE does not support
3145 if ( bodyEl.getHeight() > (Roo.lib.Dom.getViewHeight() - 100)) {
3146 bodyEl.setHeight ( Roo.lib.Dom.getViewHeight() - 100 );
3147 bodyEl.dom.style.overflowY = 'auto' + ( Roo.isIE ? '' : ' !important');
3149 bodyEl.dom.style.height = '';
3150 bodyEl.dom.style.overflowY = '';
3153 bodyEl.dom.style.get = 'auto' + ( Roo.isIE ? '' : ' !important');
3155 bodyEl.dom.style.overflowX = '';
3158 dlg.setContentSize(w, bodyEl.getHeight());
3159 if(dlg.isVisible()){
3160 dlg.fixedcenter = true;
3166 * Updates a progress-style message box's text and progress bar. Only relevant on message boxes
3167 * initiated via {@link Roo.MessageBox#progress} or by calling {@link Roo.MessageBox#show} with progress: true.
3168 * @param {Number} value Any number between 0 and 1 (e.g., .5)
3169 * @param {String} text (optional) If defined, the message box's body text is replaced with the specified string (defaults to undefined)
3170 * @return {Roo.MessageBox} This message box
3172 updateProgress : function(value, text){
3174 this.updateText(text);
3176 if (pp) { // weird bug on my firefox - for some reason this is not defined
3177 pp.setWidth(Math.floor(value*progressEl.dom.firstChild.offsetWidth));
3183 * Returns true if the message box is currently displayed
3184 * @return {Boolean} True if the message box is visible, else false
3186 isVisible : function(){
3187 return dlg && dlg.isVisible();
3191 * Hides the message box if it is displayed
3194 if(this.isVisible()){
3200 * Displays a new message box, or reinitializes an existing message box, based on the config options
3201 * passed in. All functions (e.g. prompt, alert, etc) on MessageBox call this function internally.
3202 * The following config object properties are supported:
3204 Property Type Description
3205 ---------- --------------- ------------------------------------------------------------------------------------
3206 animEl String/Element An id or Element from which the message box should animate as it opens and
3207 closes (defaults to undefined)
3208 buttons Object/Boolean A button config object (e.g., Roo.MessageBox.OKCANCEL or {ok:'Foo',
3209 cancel:'Bar'}), or false to not show any buttons (defaults to false)
3210 closable Boolean False to hide the top-right close button (defaults to true). Note that
3211 progress and wait dialogs will ignore this property and always hide the
3212 close button as they can only be closed programmatically.
3213 cls String A custom CSS class to apply to the message box element
3214 defaultTextHeight Number The default height in pixels of the message box's multiline textarea if
3215 displayed (defaults to 75)
3216 fn Function A callback function to execute after closing the dialog. The arguments to the
3217 function will be btn (the name of the button that was clicked, if applicable,
3218 e.g. "ok"), and text (the value of the active text field, if applicable).
3219 Progress and wait dialogs will ignore this option since they do not respond to
3220 user actions and can only be closed programmatically, so any required function
3221 should be called by the same code after it closes the dialog.
3222 icon String A CSS class that provides a background image to be used as an icon for
3223 the dialog (e.g., Roo.MessageBox.WARNING or 'custom-class', defaults to '')
3224 maxWidth Number The maximum width in pixels of the message box (defaults to 600)
3225 minWidth Number The minimum width in pixels of the message box (defaults to 100)
3226 modal Boolean False to allow user interaction with the page while the message box is
3227 displayed (defaults to true)
3228 msg String A string that will replace the existing message box body text (defaults
3229 to the XHTML-compliant non-breaking space character ' ')
3230 multiline Boolean True to prompt the user to enter multi-line text (defaults to false)
3231 progress Boolean True to display a progress bar (defaults to false)
3232 progressText String The text to display inside the progress bar if progress = true (defaults to '')
3233 prompt Boolean True to prompt the user to enter single-line text (defaults to false)
3234 proxyDrag Boolean True to display a lightweight proxy while dragging (defaults to false)
3235 title String The title text
3236 value String The string value to set into the active textbox element if displayed
3237 wait Boolean True to display a progress bar (defaults to false)
3238 width Number The width of the dialog in pixels
3245 msg: 'Please enter your address:',
3247 buttons: Roo.MessageBox.OKCANCEL,
3250 animEl: 'addAddressBtn'
3253 * @param {Object} config Configuration options
3254 * @return {Roo.MessageBox} This message box
3256 show : function(options)
3259 // this causes nightmares if you show one dialog after another
3260 // especially on callbacks..
3262 if(this.isVisible()){
3265 Roo.log("[Roo.Messagebox] Show called while message displayed:" );
3266 Roo.log("Old Dialog Message:" + msgEl.innerHTML );
3267 Roo.log("New Dialog Message:" + options.msg )
3268 //this.alert("ERROR", "Multiple dialogs where displayed at the same time");
3269 //throw "Roo.MessageBox ERROR : Multiple dialogs where displayed at the same time";
3272 var d = this.getDialog();
3274 d.setTitle(opt.title || " ");
3275 d.closeEl.setDisplayed(opt.closable !== false);
3276 activeTextEl = textboxEl;
3277 opt.prompt = opt.prompt || (opt.multiline ? true : false);
3282 textareaEl.setHeight(typeof opt.multiline == "number" ?
3283 opt.multiline : this.defaultTextHeight);
3284 activeTextEl = textareaEl;
3293 progressEl.setDisplayed(opt.progress === true);
3294 this.updateProgress(0);
3295 activeTextEl.dom.value = opt.value || "";
3297 dlg.setDefaultButton(activeTextEl);
3299 var bs = opt.buttons;
3303 }else if(bs && bs.yes){
3304 db = buttons["yes"];
3306 dlg.setDefaultButton(db);
3308 bwidth = updateButtons(opt.buttons);
3309 this.updateText(opt.msg);
3311 d.el.addClass(opt.cls);
3313 d.proxyDrag = opt.proxyDrag === true;
3314 d.modal = opt.modal !== false;
3315 d.mask = opt.modal !== false ? mask : false;
3317 // force it to the end of the z-index stack so it gets a cursor in FF
3318 document.body.appendChild(dlg.el.dom);
3319 d.animateTarget = null;
3320 d.show(options.animEl);
3326 * Displays a message box with a progress bar. This message box has no buttons and is not closeable by
3327 * the user. You are responsible for updating the progress bar as needed via {@link Roo.MessageBox#updateProgress}
3328 * and closing the message box when the process is complete.
3329 * @param {String} title The title bar text
3330 * @param {String} msg The message box body text
3331 * @return {Roo.MessageBox} This message box
3333 progress : function(title, msg){
3340 minWidth: this.minProgressWidth,
3347 * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript Window.alert).
3348 * If a callback function is passed it will be called after the user clicks the button, and the
3349 * id of the button that was clicked will be passed as the only parameter to the callback
3350 * (could also be the top-right close button).
3351 * @param {String} title The title bar text
3352 * @param {String} msg The message box body text
3353 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3354 * @param {Object} scope (optional) The scope of the callback function
3355 * @return {Roo.MessageBox} This message box
3357 alert : function(title, msg, fn, scope)
3372 * Displays a message box with an infinitely auto-updating progress bar. This can be used to block user
3373 * interaction while waiting for a long-running process to complete that does not have defined intervals.
3374 * You are responsible for closing the message box when the process is complete.
3375 * @param {String} msg The message box body text
3376 * @param {String} title (optional) The title bar text
3377 * @return {Roo.MessageBox} This message box
3379 wait : function(msg, title){
3390 waitTimer = Roo.TaskMgr.start({
3392 Roo.MessageBox.updateProgress(((((i+20)%20)+1)*5)*.01);
3400 * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's Window.confirm).
3401 * If a callback function is passed it will be called after the user clicks either button, and the id of the
3402 * button that was clicked will be passed as the only parameter to the callback (could also be the top-right close button).
3403 * @param {String} title The title bar text
3404 * @param {String} msg The message box body text
3405 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3406 * @param {Object} scope (optional) The scope of the callback function
3407 * @return {Roo.MessageBox} This message box
3409 confirm : function(title, msg, fn, scope){
3413 buttons: this.YESNO,
3422 * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to
3423 * JavaScript's Window.prompt). The prompt can be a single-line or multi-line textbox. If a callback function
3424 * is passed it will be called after the user clicks either button, and the id of the button that was clicked
3425 * (could also be the top-right close button) and the text that was entered will be passed as the two
3426 * parameters to the callback.
3427 * @param {String} title The title bar text
3428 * @param {String} msg The message box body text
3429 * @param {Function} fn (optional) The callback function invoked after the message box is closed
3430 * @param {Object} scope (optional) The scope of the callback function
3431 * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight
3432 * property, or the height in pixels to create the textbox (defaults to false / single-line)
3433 * @return {Roo.MessageBox} This message box
3435 prompt : function(title, msg, fn, scope, multiline){
3439 buttons: this.OKCANCEL,
3444 multiline: multiline,
3451 * Button config that displays a single OK button
3456 * Button config that displays Yes and No buttons
3459 YESNO : {yes:true, no:true},
3461 * Button config that displays OK and Cancel buttons
3464 OKCANCEL : {ok:true, cancel:true},
3466 * Button config that displays Yes, No and Cancel buttons
3469 YESNOCANCEL : {yes:true, no:true, cancel:true},
3472 * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)
3475 defaultTextHeight : 75,
3477 * The maximum width in pixels of the message box (defaults to 600)
3482 * The minimum width in pixels of the message box (defaults to 100)
3487 * The minimum width in pixels of the message box if it is a progress-style dialog. This is useful
3488 * for setting a different minimum width than text-only dialogs may need (defaults to 250)
3491 minProgressWidth : 250,
3493 * An object containing the default button text strings that can be overriden for localized language support.
3494 * Supported properties are: ok, cancel, yes and no.
3495 * Customize the default text like so: Roo.MessageBox.buttonText.yes = "S?";
3508 * Shorthand for {@link Roo.MessageBox}
3510 Roo.MessageBox = Roo.MessageBox || Roo.bootstrap.MessageBox;
3511 Roo.Msg = Roo.Msg || Roo.MessageBox;
3520 * @class Roo.bootstrap.Navbar
3521 * @extends Roo.bootstrap.Component
3522 * Bootstrap Navbar class
3525 * Create a new Navbar
3526 * @param {Object} config The config object
3530 Roo.bootstrap.Navbar = function(config){
3531 Roo.bootstrap.Navbar.superclass.constructor.call(this, config);
3535 * @event beforetoggle
3536 * Fire before toggle the menu
3537 * @param {Roo.EventObject} e
3539 "beforetoggle" : true
3543 Roo.extend(Roo.bootstrap.Navbar, Roo.bootstrap.Component, {
3552 getAutoCreate : function(){
3555 throw { message : "nav bar is now a abstract base class - use NavSimplebar / NavHeaderbar / NavSidebar etc..."};
3559 initEvents :function ()
3561 //Roo.log(this.el.select('.navbar-toggle',true));
3562 this.el.select('.navbar-toggle',true).on('click', function() {
3563 if(this.fireEvent('beforetoggle', this) !== false){
3564 this.el.select('.navbar-collapse',true).toggleClass('in');
3574 this.maskEl = Roo.DomHelper.append(this.el, mark, true);
3576 var size = this.el.getSize();
3577 this.maskEl.setSize(size.width, size.height);
3578 this.maskEl.enableDisplayMode("block");
3587 getChildContainer : function()
3589 if (this.el.select('.collapse').getCount()) {
3590 return this.el.select('.collapse',true).first();
3623 * @class Roo.bootstrap.NavSimplebar
3624 * @extends Roo.bootstrap.Navbar
3625 * Bootstrap Sidebar class
3627 * @cfg {Boolean} inverse is inverted color
3629 * @cfg {String} type (nav | pills | tabs)
3630 * @cfg {Boolean} arrangement stacked | justified
3631 * @cfg {String} align (left | right) alignment
3633 * @cfg {Boolean} main (true|false) main nav bar? default false
3634 * @cfg {Boolean} loadMask (true|false) loadMask on the bar
3636 * @cfg {String} tag (header|footer|nav|div) default is nav
3642 * Create a new Sidebar
3643 * @param {Object} config The config object
3647 Roo.bootstrap.NavSimplebar = function(config){
3648 Roo.bootstrap.NavSimplebar.superclass.constructor.call(this, config);
3651 Roo.extend(Roo.bootstrap.NavSimplebar, Roo.bootstrap.Navbar, {
3667 getAutoCreate : function(){
3671 tag : this.tag || 'div',
3684 this.type = this.type || 'nav';
3685 if (['tabs','pills'].indexOf(this.type)!==-1) {
3686 cfg.cn[0].cls += ' nav-' + this.type
3690 if (this.type!=='nav') {
3691 Roo.log('nav type must be nav/tabs/pills')
3693 cfg.cn[0].cls += ' navbar-nav'
3699 if (['stacked','justified'].indexOf(this.arrangement)!==-1) {
3700 cfg.cn[0].cls += ' nav-' + this.arrangement;
3704 if (this.align === 'right') {
3705 cfg.cn[0].cls += ' navbar-right';
3709 cfg.cls += ' navbar-inverse';
3736 * @class Roo.bootstrap.NavHeaderbar
3737 * @extends Roo.bootstrap.NavSimplebar
3738 * Bootstrap Sidebar class
3740 * @cfg {String} brand what is brand
3741 * @cfg {String} position (fixed-top|fixed-bottom|static-top) position
3742 * @cfg {String} brand_href href of the brand
3743 * @cfg {Boolean} srButton generate the (screen reader / mobile) sr-only button default true
3744 * @cfg {Boolean} autohide a top nav bar header that hides on scroll.
3745 * @cfg {Boolean} desktopCenter should the header be centered on desktop using a container class
3746 * @cfg {Roo.bootstrap.Row} mobilerow - a row to display on mobile only..
3749 * Create a new Sidebar
3750 * @param {Object} config The config object
3754 Roo.bootstrap.NavHeaderbar = function(config){
3755 Roo.bootstrap.NavHeaderbar.superclass.constructor.call(this, config);
3759 Roo.extend(Roo.bootstrap.NavHeaderbar, Roo.bootstrap.NavSimplebar, {
3766 desktopCenter : false,
3769 getAutoCreate : function(){
3772 tag: this.nav || 'nav',
3779 if (this.desktopCenter) {
3780 cn.push({cls : 'container', cn : []});
3787 cls: 'navbar-header',
3792 cls: 'navbar-toggle',
3793 'data-toggle': 'collapse',
3798 html: 'Toggle navigation'
3820 cls: 'collapse navbar-collapse',
3824 cfg.cls += this.inverse ? ' navbar-inverse' : ' navbar-default';
3826 if (['fixed-top','fixed-bottom','static-top'].indexOf(this.position)>-1) {
3827 cfg.cls += ' navbar-' + this.position;
3829 // tag can override this..
3831 cfg.tag = this.tag || (this.position == 'fixed-bottom' ? 'footer' : 'header');
3834 if (this.brand !== '') {
3837 href: this.brand_href ? this.brand_href : '#',
3838 cls: 'navbar-brand',
3846 cfg.cls += ' main-nav';
3854 getHeaderChildContainer : function()
3856 if (this.srButton && this.el.select('.navbar-header').getCount()) {
3857 return this.el.select('.navbar-header',true).first();
3860 return this.getChildContainer();
3864 initEvents : function()
3866 Roo.bootstrap.NavHeaderbar.superclass.initEvents.call(this);
3868 if (this.autohide) {
3873 Roo.get(document).on('scroll',function(e) {
3874 var ns = Roo.get(document).getScroll().top;
3875 var os = prevScroll;
3879 ft.removeClass('slideDown');
3880 ft.addClass('slideUp');
3883 ft.removeClass('slideUp');
3884 ft.addClass('slideDown');
3905 * @class Roo.bootstrap.NavSidebar
3906 * @extends Roo.bootstrap.Navbar
3907 * Bootstrap Sidebar class
3910 * Create a new Sidebar
3911 * @param {Object} config The config object
3915 Roo.bootstrap.NavSidebar = function(config){
3916 Roo.bootstrap.NavSidebar.superclass.constructor.call(this, config);
3919 Roo.extend(Roo.bootstrap.NavSidebar, Roo.bootstrap.Navbar, {
3921 sidebar : true, // used by Navbar Item and NavbarGroup at present...
3923 getAutoCreate : function(){
3928 cls: 'sidebar sidebar-nav'
3950 * @class Roo.bootstrap.NavGroup
3951 * @extends Roo.bootstrap.Component
3952 * Bootstrap NavGroup class
3953 * @cfg {String} align (left|right)
3954 * @cfg {Boolean} inverse
3955 * @cfg {String} type (nav|pills|tab) default nav
3956 * @cfg {String} navId - reference Id for navbar.
3960 * Create a new nav group
3961 * @param {Object} config The config object
3964 Roo.bootstrap.NavGroup = function(config){
3965 Roo.bootstrap.NavGroup.superclass.constructor.call(this, config);
3968 Roo.bootstrap.NavGroup.register(this);
3972 * Fires when the active item changes
3973 * @param {Roo.bootstrap.NavGroup} this
3974 * @param {Roo.bootstrap.Navbar.Item} selected The item selected
3975 * @param {Roo.bootstrap.Navbar.Item} prev The previously selected item
3982 Roo.extend(Roo.bootstrap.NavGroup, Roo.bootstrap.Component, {
3993 getAutoCreate : function()
3995 var cfg = Roo.apply({}, Roo.bootstrap.NavGroup.superclass.getAutoCreate.call(this));
4002 if (['tabs','pills'].indexOf(this.type)!==-1) {
4003 cfg.cls += ' nav-' + this.type
4005 if (this.type!=='nav') {
4006 Roo.log('nav type must be nav/tabs/pills')
4008 cfg.cls += ' navbar-nav'
4011 if (this.parent().sidebar) {
4014 cls: 'dashboard-menu sidebar-menu'
4020 if (this.form === true) {
4026 if (this.align === 'right') {
4027 cfg.cls += ' navbar-right';
4029 cfg.cls += ' navbar-left';
4033 if (this.align === 'right') {
4034 cfg.cls += ' navbar-right';
4038 cfg.cls += ' navbar-inverse';
4046 * sets the active Navigation item
4047 * @param {Roo.bootstrap.NavItem} the new current navitem
4049 setActiveItem : function(item)
4052 Roo.each(this.navItems, function(v){
4057 v.setActive(false, true);
4064 item.setActive(true, true);
4065 this.fireEvent('changed', this, item, prev);
4070 * gets the active Navigation item
4071 * @return {Roo.bootstrap.NavItem} the current navitem
4073 getActive : function()
4077 Roo.each(this.navItems, function(v){
4088 indexOfNav : function()
4092 Roo.each(this.navItems, function(v,i){
4103 * adds a Navigation item
4104 * @param {Roo.bootstrap.NavItem} the navitem to add
4106 addItem : function(cfg)
4108 var cn = new Roo.bootstrap.NavItem(cfg);
4110 cn.parentId = this.id;
4111 cn.onRender(this.el, null);
4115 * register a Navigation item
4116 * @param {Roo.bootstrap.NavItem} the navitem to add
4118 register : function(item)
4120 this.navItems.push( item);
4121 item.navId = this.navId;
4126 * clear all the Navigation item
4129 clearAll : function()
4132 this.el.dom.innerHTML = '';
4135 getNavItem: function(tabId)
4138 Roo.each(this.navItems, function(e) {
4139 if (e.tabId == tabId) {
4149 setActiveNext : function()
4151 var i = this.indexOfNav(this.getActive());
4152 if (i > this.navItems.length) {
4155 this.setActiveItem(this.navItems[i+1]);
4157 setActivePrev : function()
4159 var i = this.indexOfNav(this.getActive());
4163 this.setActiveItem(this.navItems[i-1]);
4165 clearWasActive : function(except) {
4166 Roo.each(this.navItems, function(e) {
4167 if (e.tabId != except.tabId && e.was_active) {
4168 e.was_active = false;
4175 getWasActive : function ()
4178 Roo.each(this.navItems, function(e) {
4193 Roo.apply(Roo.bootstrap.NavGroup, {
4197 * register a Navigation Group
4198 * @param {Roo.bootstrap.NavGroup} the navgroup to add
4200 register : function(navgrp)
4202 this.groups[navgrp.navId] = navgrp;
4206 * fetch a Navigation Group based on the navigation ID
4207 * @param {string} the navgroup to add
4208 * @returns {Roo.bootstrap.NavGroup} the navgroup
4210 get: function(navId) {
4211 if (typeof(this.groups[navId]) == 'undefined') {
4213 //this.register(new Roo.bootstrap.NavGroup({ navId : navId }));
4215 return this.groups[navId] ;
4230 * @class Roo.bootstrap.NavItem
4231 * @extends Roo.bootstrap.Component
4232 * Bootstrap Navbar.NavItem class
4233 * @cfg {String} href link to
4234 * @cfg {String} html content of button
4235 * @cfg {String} badge text inside badge
4236 * @cfg {String} badgecls (bg-green|bg-red|bg-yellow)the extra classes for the badge
4237 * @cfg {String} glyphicon name of glyphicon
4238 * @cfg {String} icon name of font awesome icon
4239 * @cfg {Boolean} active Is item active
4240 * @cfg {Boolean} disabled Is item disabled
4242 * @cfg {Boolean} preventDefault (true | false) default false
4243 * @cfg {String} tabId the tab that this item activates.
4244 * @cfg {String} tagtype (a|span) render as a href or span?
4245 * @cfg {Boolean} animateRef (true|false) link to element default false
4248 * Create a new Navbar Item
4249 * @param {Object} config The config object
4251 Roo.bootstrap.NavItem = function(config){
4252 Roo.bootstrap.NavItem.superclass.constructor.call(this, config);
4257 * The raw click event for the entire grid.
4258 * @param {Roo.EventObject} e
4263 * Fires when the active item active state changes
4264 * @param {Roo.bootstrap.NavItem} this
4265 * @param {boolean} state the new state
4271 * Fires when scroll to element
4272 * @param {Roo.bootstrap.NavItem} this
4273 * @param {Object} options
4274 * @param {Roo.EventObject} e
4282 Roo.extend(Roo.bootstrap.NavItem, Roo.bootstrap.Component, {
4290 preventDefault : false,
4297 getAutoCreate : function(){
4306 cfg.cls = typeof(cfg.cls) == 'undefined' ? 'active' : cfg.cls + ' active';
4308 if (this.disabled) {
4309 cfg.cls += ' disabled';
4312 if (this.href || this.html || this.glyphicon || this.icon) {
4316 href : this.href || "#",
4317 html: this.html || ''
4322 cfg.cn[0].html = '<i class="'+this.icon+'"></i> <span>' + cfg.cn[0].html + '</span>'
4325 if(this.glyphicon) {
4326 cfg.cn[0].html = '<span class="glyphicon glyphicon-' + this.glyphicon + '"></span> ' + cfg.cn[0].html;
4331 cfg.cn[0].html += " <span class='caret'></span>";
4335 if (this.badge !== '') {
4337 cfg.cn[0].html += ' <span class="badge">' + this.badge + '</span>';
4345 initEvents: function()
4347 if (typeof (this.menu) != 'undefined') {
4348 this.menu.parentType = this.xtype;
4349 this.menu.triggerEl = this.el;
4350 this.menu = this.addxtype(Roo.apply({}, this.menu));
4353 this.el.select('a',true).on('click', this.onClick, this);
4355 if(this.tagtype == 'span'){
4356 this.el.select('span',true).on('click', this.onClick, this);
4359 // at this point parent should be available..
4360 this.parent().register(this);
4363 onClick : function(e)
4365 if (e.getTarget('.dropdown-menu-item')) {
4366 // did you click on a menu itemm.... - then don't trigger onclick..
4371 this.preventDefault ||
4374 Roo.log("NavItem - prevent Default?");
4378 if (this.disabled) {
4382 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4383 if (tg && tg.transition) {
4384 Roo.log("waiting for the transitionend");
4390 //Roo.log("fire event clicked");
4391 if(this.fireEvent('click', this, e) === false){
4395 if(this.tagtype == 'span'){
4399 //Roo.log(this.href);
4400 var ael = this.el.select('a',true).first();
4403 if(ael && this.animateRef && this.href.indexOf('#') > -1){
4404 //Roo.log(["test:",ael.dom.href.split("#")[0], document.location.toString().split("#")[0]]);
4405 if (ael.dom.href.split("#")[0] != document.location.toString().split("#")[0]) {
4406 return; // ignore... - it's a 'hash' to another page.
4408 Roo.log("NavItem - prevent Default?");
4410 this.scrollToElement(e);
4414 var p = this.parent();
4416 if (['tabs','pills'].indexOf(p.type)!==-1) {
4417 if (typeof(p.setActiveItem) !== 'undefined') {
4418 p.setActiveItem(this);
4422 // if parent is a navbarheader....- and link is probably a '#' page ref.. then remove the expanded menu.
4423 if (p.parentType == 'NavHeaderbar' && !this.menu) {
4424 // remove the collapsed menu expand...
4425 p.parent().el.select('.navbar-collapse',true).removeClass('in');
4429 isActive: function () {
4432 setActive : function(state, fire, is_was_active)
4434 if (this.active && !state && this.navId) {
4435 this.was_active = true;
4436 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4438 nv.clearWasActive(this);
4442 this.active = state;
4445 this.el.removeClass('active');
4446 } else if (!this.el.hasClass('active')) {
4447 this.el.addClass('active');
4450 this.fireEvent('changed', this, state);
4453 // show a panel if it's registered and related..
4455 if (!this.navId || !this.tabId || !state || is_was_active) {
4459 var tg = Roo.bootstrap.TabGroup.get(this.navId);
4463 var pan = tg.getPanelByName(this.tabId);
4467 // if we can not flip to new panel - go back to old nav highlight..
4468 if (false == tg.showPanel(pan)) {
4469 var nv = Roo.bootstrap.NavGroup.get(this.navId);
4471 var onav = nv.getWasActive();
4473 onav.setActive(true, false, true);
4482 // this should not be here...
4483 setDisabled : function(state)
4485 this.disabled = state;
4487 this.el.removeClass('disabled');
4488 } else if (!this.el.hasClass('disabled')) {
4489 this.el.addClass('disabled');
4495 * Fetch the element to display the tooltip on.
4496 * @return {Roo.Element} defaults to this.el
4498 tooltipEl : function()
4500 return this.el.select('' + this.tagtype + '', true).first();
4503 scrollToElement : function(e)
4505 var c = document.body;
4508 * Firefox / IE places the overflow at the html level, unless specifically styled to behave differently.
4510 if(Roo.isFirefox || Roo.isIE || Roo.isIE11){
4511 c = document.documentElement;
4514 var target = Roo.get(c).select('a[name=' + this.href.split('#')[1] +']', true).first();
4520 var o = target.calcOffsetsTo(c);
4527 this.fireEvent('scrollto', this, options, e);
4529 Roo.get(c).scrollTo('top', options.value, true);
4542 * <span> icon </span>
4543 * <span> text </span>
4544 * <span>badge </span>
4548 * @class Roo.bootstrap.NavSidebarItem
4549 * @extends Roo.bootstrap.NavItem
4550 * Bootstrap Navbar.NavSidebarItem class
4551 * {String} badgeWeight (default|primary|success|info|warning|danger)the extra classes for the badge
4552 * {bool} open is the menu open
4554 * Create a new Navbar Button
4555 * @param {Object} config The config object
4557 Roo.bootstrap.NavSidebarItem = function(config){
4558 Roo.bootstrap.NavSidebarItem.superclass.constructor.call(this, config);
4563 * The raw click event for the entire grid.
4564 * @param {Roo.EventObject} e
4569 * Fires when the active item active state changes
4570 * @param {Roo.bootstrap.NavSidebarItem} this
4571 * @param {boolean} state the new state
4579 Roo.extend(Roo.bootstrap.NavSidebarItem, Roo.bootstrap.NavItem, {
4581 badgeWeight : 'default',
4585 getAutoCreate : function(){
4590 href : this.href || '#',
4602 html : this.html || ''
4607 cfg.cls += ' active';
4610 if (this.disabled) {
4611 cfg.cls += ' disabled';
4614 cfg.cls += ' open x-open';
4617 if (this.glyphicon || this.icon) {
4618 var c = this.glyphicon ? ('glyphicon glyphicon-'+this.glyphicon) : this.icon;
4619 a.cn.push({ tag : 'i', cls : c }) ;
4624 if (this.badge !== '') {
4626 a.cn.push({ tag: 'span', cls : 'badge pull-right badge-' + this.badgeWeight, html: this.badge });
4630 a.cn.push({ tag : 'i', cls : 'glyphicon glyphicon-chevron-down pull-right'});
4631 a.cls += 'dropdown-toggle treeview' ;
4639 initEvents : function()
4641 if (typeof (this.menu) != 'undefined') {
4642 this.menu.parentType = this.xtype;
4643 this.menu.triggerEl = this.el;
4644 this.menu = this.addxtype(Roo.apply({}, this.menu));
4647 this.el.on('click', this.onClick, this);
4650 if(this.badge !== ''){
4652 this.badgeEl = this.el.select('.badge', true).first().setVisibilityMode(Roo.Element.DISPLAY);
4657 onClick : function(e)
4664 if(this.preventDefault){
4668 this.fireEvent('click', this);
4671 disable : function()
4673 this.setDisabled(true);
4678 this.setDisabled(false);
4681 setDisabled : function(state)
4683 if(this.disabled == state){
4687 this.disabled = state;
4690 this.el.addClass('disabled');
4694 this.el.removeClass('disabled');
4699 setActive : function(state)
4701 if(this.active == state){
4705 this.active = state;
4708 this.el.addClass('active');
4712 this.el.removeClass('active');
4717 isActive: function ()
4722 setBadge : function(str)
4728 this.badgeEl.dom.innerHTML = str;
4745 * @class Roo.bootstrap.Row
4746 * @extends Roo.bootstrap.Component
4747 * Bootstrap Row class (contains columns...)
4751 * @param {Object} config The config object
4754 Roo.bootstrap.Row = function(config){
4755 Roo.bootstrap.Row.superclass.constructor.call(this, config);
4758 Roo.extend(Roo.bootstrap.Row, Roo.bootstrap.Component, {
4760 getAutoCreate : function(){
4779 * @class Roo.bootstrap.Element
4780 * @extends Roo.bootstrap.Component
4781 * Bootstrap Element class
4782 * @cfg {String} html contents of the element
4783 * @cfg {String} tag tag of the element
4784 * @cfg {String} cls class of the element
4785 * @cfg {Boolean} preventDefault (true|false) default false
4786 * @cfg {Boolean} clickable (true|false) default false
4789 * Create a new Element
4790 * @param {Object} config The config object
4793 Roo.bootstrap.Element = function(config){
4794 Roo.bootstrap.Element.superclass.constructor.call(this, config);
4800 * When a element is chick
4801 * @param {Roo.bootstrap.Element} this
4802 * @param {Roo.EventObject} e
4808 Roo.extend(Roo.bootstrap.Element, Roo.bootstrap.Component, {
4813 preventDefault: false,
4816 getAutoCreate : function(){
4827 initEvents: function()
4829 Roo.bootstrap.Element.superclass.initEvents.call(this);
4832 this.el.on('click', this.onClick, this);
4837 onClick : function(e)
4839 if(this.preventDefault){
4843 this.fireEvent('click', this, e);
4846 getValue : function()
4848 return this.el.dom.innerHTML;
4851 setValue : function(value)
4853 this.el.dom.innerHTML = value;
4868 * @class Roo.bootstrap.Pagination
4869 * @extends Roo.bootstrap.Component
4870 * Bootstrap Pagination class
4871 * @cfg {String} size xs | sm | md | lg
4872 * @cfg {Boolean} inverse false | true
4875 * Create a new Pagination
4876 * @param {Object} config The config object
4879 Roo.bootstrap.Pagination = function(config){
4880 Roo.bootstrap.Pagination.superclass.constructor.call(this, config);
4883 Roo.extend(Roo.bootstrap.Pagination, Roo.bootstrap.Component, {
4889 getAutoCreate : function(){
4895 cfg.cls += ' inverse';
4901 cfg.cls += " " + this.cls;
4919 * @class Roo.bootstrap.PaginationItem
4920 * @extends Roo.bootstrap.Component
4921 * Bootstrap PaginationItem class
4922 * @cfg {String} html text
4923 * @cfg {String} href the link
4924 * @cfg {Boolean} preventDefault (true | false) default true
4925 * @cfg {Boolean} active (true | false) default false
4926 * @cfg {Boolean} disabled default false
4930 * Create a new PaginationItem
4931 * @param {Object} config The config object
4935 Roo.bootstrap.PaginationItem = function(config){
4936 Roo.bootstrap.PaginationItem.superclass.constructor.call(this, config);
4941 * The raw click event for the entire grid.
4942 * @param {Roo.EventObject} e
4948 Roo.extend(Roo.bootstrap.PaginationItem, Roo.bootstrap.Component, {
4952 preventDefault: true,
4957 getAutoCreate : function(){
4963 href : this.href ? this.href : '#',
4964 html : this.html ? this.html : ''
4974 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' disabled' : 'disabled';
4978 cfg.cls = typeof(cfg.cls) !== 'undefined' ? cfg.cls + ' active' : 'active';
4984 initEvents: function() {
4986 this.el.on('click', this.onClick, this);
4989 onClick : function(e)
4991 Roo.log('PaginationItem on click ');
4992 if(this.preventDefault){
5000 this.fireEvent('click', this, e);
5016 * @class Roo.bootstrap.Slider
5017 * @extends Roo.bootstrap.Component
5018 * Bootstrap Slider class
5021 * Create a new Slider
5022 * @param {Object} config The config object
5025 Roo.bootstrap.Slider = function(config){
5026 Roo.bootstrap.Slider.superclass.constructor.call(this, config);
5029 Roo.extend(Roo.bootstrap.Slider, Roo.bootstrap.Component, {
5031 getAutoCreate : function(){
5035 cls: 'slider slider-sample1 vertical-handler ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all',
5039 cls: 'ui-slider-handle ui-state-default ui-corner-all'
5051 * Ext JS Library 1.1.1
5052 * Copyright(c) 2006-2007, Ext JS, LLC.
5054 * Originally Released Under LGPL - original licence link has changed is not relivant.
5057 * <script type="text/javascript">
5062 * @class Roo.grid.ColumnModel
5063 * @extends Roo.util.Observable
5064 * This is the default implementation of a ColumnModel used by the Grid. It defines
5065 * the columns in the grid.
5068 var colModel = new Roo.grid.ColumnModel([
5069 {header: "Ticker", width: 60, sortable: true, locked: true},
5070 {header: "Company Name", width: 150, sortable: true},
5071 {header: "Market Cap.", width: 100, sortable: true},
5072 {header: "$ Sales", width: 100, sortable: true, renderer: money},
5073 {header: "Employees", width: 100, sortable: true, resizable: false}
5078 * The config options listed for this class are options which may appear in each
5079 * individual column definition.
5080 * <br/>RooJS Fix - column id's are not sequential but use Roo.id() - fixes bugs with layouts.
5082 * @param {Object} config An Array of column config objects. See this class's
5083 * config objects for details.
5085 Roo.grid.ColumnModel = function(config){
5087 * The config passed into the constructor
5089 this.config = config;
5092 // if no id, create one
5093 // if the column does not have a dataIndex mapping,
5094 // map it to the order it is in the config
5095 for(var i = 0, len = config.length; i < len; i++){
5097 if(typeof c.dataIndex == "undefined"){
5100 if(typeof c.renderer == "string"){
5101 c.renderer = Roo.util.Format[c.renderer];
5103 if(typeof c.id == "undefined"){
5106 if(c.editor && c.editor.xtype){
5107 c.editor = Roo.factory(c.editor, Roo.grid);
5109 if(c.editor && c.editor.isFormField){
5110 c.editor = new Roo.grid.GridEditor(c.editor);
5112 this.lookup[c.id] = c;
5116 * The width of columns which have no width specified (defaults to 100)
5119 this.defaultWidth = 100;
5122 * Default sortable of columns which have no sortable specified (defaults to false)
5125 this.defaultSortable = false;
5129 * @event widthchange
5130 * Fires when the width of a column changes.
5131 * @param {ColumnModel} this
5132 * @param {Number} columnIndex The column index
5133 * @param {Number} newWidth The new width
5135 "widthchange": true,
5137 * @event headerchange
5138 * Fires when the text of a header changes.
5139 * @param {ColumnModel} this
5140 * @param {Number} columnIndex The column index
5141 * @param {Number} newText The new header text
5143 "headerchange": true,
5145 * @event hiddenchange
5146 * Fires when a column is hidden or "unhidden".
5147 * @param {ColumnModel} this
5148 * @param {Number} columnIndex The column index
5149 * @param {Boolean} hidden true if hidden, false otherwise
5151 "hiddenchange": true,
5153 * @event columnmoved
5154 * Fires when a column is moved.
5155 * @param {ColumnModel} this
5156 * @param {Number} oldIndex
5157 * @param {Number} newIndex
5159 "columnmoved" : true,
5161 * @event columlockchange
5162 * Fires when a column's locked state is changed
5163 * @param {ColumnModel} this
5164 * @param {Number} colIndex
5165 * @param {Boolean} locked true if locked
5167 "columnlockchange" : true
5169 Roo.grid.ColumnModel.superclass.constructor.call(this);
5171 Roo.extend(Roo.grid.ColumnModel, Roo.util.Observable, {
5173 * @cfg {String} header The header text to display in the Grid view.
5176 * @cfg {String} dataIndex (Optional) The name of the field in the grid's {@link Roo.data.Store}'s
5177 * {@link Roo.data.Record} definition from which to draw the column's value. If not
5178 * specified, the column's index is used as an index into the Record's data Array.
5181 * @cfg {Number} width (Optional) The initial width in pixels of the column. Using this
5182 * instead of {@link Roo.grid.Grid#autoSizeColumns} is more efficient.
5185 * @cfg {Boolean} sortable (Optional) True if sorting is to be allowed on this column.
5186 * Defaults to the value of the {@link #defaultSortable} property.
5187 * Whether local/remote sorting is used is specified in {@link Roo.data.Store#remoteSort}.
5190 * @cfg {Boolean} locked (Optional) True to lock the column in place while scrolling the Grid. Defaults to false.
5193 * @cfg {Boolean} fixed (Optional) True if the column width cannot be changed. Defaults to false.
5196 * @cfg {Boolean} resizable (Optional) False to disable column resizing. Defaults to true.
5199 * @cfg {Boolean} hidden (Optional) True to hide the column. Defaults to false.
5202 * @cfg {Function} renderer (Optional) A function used to generate HTML markup for a cell
5203 * given the cell's data value. See {@link #setRenderer}. If not specified, the
5204 * default renderer returns the escaped data value. If an object is returned (bootstrap only)
5205 * then it is treated as a Roo Component object instance, and it is rendered after the initial row is rendered
5208 * @cfg {Roo.grid.GridEditor} editor (Optional) For grid editors - returns the grid editor
5211 * @cfg {String} align (Optional) Set the CSS text-align property of the column. Defaults to undefined.
5214 * @cfg {String} cursor (Optional)
5217 * @cfg {String} tooltip (Optional)
5220 * @cfg {Number} xs (Optional)
5223 * @cfg {Number} sm (Optional)
5226 * @cfg {Number} md (Optional)
5229 * @cfg {Number} lg (Optional)
5232 * Returns the id of the column at the specified index.
5233 * @param {Number} index The column index
5234 * @return {String} the id
5236 getColumnId : function(index){
5237 return this.config[index].id;
5241 * Returns the column for a specified id.
5242 * @param {String} id The column id
5243 * @return {Object} the column
5245 getColumnById : function(id){
5246 return this.lookup[id];
5251 * Returns the column for a specified dataIndex.
5252 * @param {String} dataIndex The column dataIndex
5253 * @return {Object|Boolean} the column or false if not found
5255 getColumnByDataIndex: function(dataIndex){
5256 var index = this.findColumnIndex(dataIndex);
5257 return index > -1 ? this.config[index] : false;
5261 * Returns the index for a specified column id.
5262 * @param {String} id The column id
5263 * @return {Number} the index, or -1 if not found
5265 getIndexById : function(id){
5266 for(var i = 0, len = this.config.length; i < len; i++){
5267 if(this.config[i].id == id){
5275 * Returns the index for a specified column dataIndex.
5276 * @param {String} dataIndex The column dataIndex
5277 * @return {Number} the index, or -1 if not found
5280 findColumnIndex : function(dataIndex){
5281 for(var i = 0, len = this.config.length; i < len; i++){
5282 if(this.config[i].dataIndex == dataIndex){
5290 moveColumn : function(oldIndex, newIndex){
5291 var c = this.config[oldIndex];
5292 this.config.splice(oldIndex, 1);
5293 this.config.splice(newIndex, 0, c);
5294 this.dataMap = null;
5295 this.fireEvent("columnmoved", this, oldIndex, newIndex);
5298 isLocked : function(colIndex){
5299 return this.config[colIndex].locked === true;
5302 setLocked : function(colIndex, value, suppressEvent){
5303 if(this.isLocked(colIndex) == value){
5306 this.config[colIndex].locked = value;
5308 this.fireEvent("columnlockchange", this, colIndex, value);
5312 getTotalLockedWidth : function(){
5314 for(var i = 0; i < this.config.length; i++){
5315 if(this.isLocked(i) && !this.isHidden(i)){
5316 this.totalWidth += this.getColumnWidth(i);
5322 getLockedCount : function(){
5323 for(var i = 0, len = this.config.length; i < len; i++){
5324 if(!this.isLocked(i)){
5329 return this.config.length;
5333 * Returns the number of columns.
5336 getColumnCount : function(visibleOnly){
5337 if(visibleOnly === true){
5339 for(var i = 0, len = this.config.length; i < len; i++){
5340 if(!this.isHidden(i)){
5346 return this.config.length;
5350 * Returns the column configs that return true by the passed function that is called with (columnConfig, index)
5351 * @param {Function} fn
5352 * @param {Object} scope (optional)
5353 * @return {Array} result
5355 getColumnsBy : function(fn, scope){
5357 for(var i = 0, len = this.config.length; i < len; i++){
5358 var c = this.config[i];
5359 if(fn.call(scope||this, c, i) === true){
5367 * Returns true if the specified column is sortable.
5368 * @param {Number} col The column index
5371 isSortable : function(col){
5372 if(typeof this.config[col].sortable == "undefined"){
5373 return this.defaultSortable;
5375 return this.config[col].sortable;
5379 * Returns the rendering (formatting) function defined for the column.
5380 * @param {Number} col The column index.
5381 * @return {Function} The function used to render the cell. See {@link #setRenderer}.
5383 getRenderer : function(col){
5384 if(!this.config[col].renderer){
5385 return Roo.grid.ColumnModel.defaultRenderer;
5387 return this.config[col].renderer;
5391 * Sets the rendering (formatting) function for a column.
5392 * @param {Number} col The column index
5393 * @param {Function} fn The function to use to process the cell's raw data
5394 * to return HTML markup for the grid view. The render function is called with
5395 * the following parameters:<ul>
5396 * <li>Data value.</li>
5397 * <li>Cell metadata. An object in which you may set the following attributes:<ul>
5398 * <li>css A CSS style string to apply to the table cell.</li>
5399 * <li>attr An HTML attribute definition string to apply to the data container element <i>within</i> the table cell.</li></ul>
5400 * <li>The {@link Roo.data.Record} from which the data was extracted.</li>
5401 * <li>Row index</li>
5402 * <li>Column index</li>
5403 * <li>The {@link Roo.data.Store} object from which the Record was extracted</li></ul>
5405 setRenderer : function(col, fn){
5406 this.config[col].renderer = fn;
5410 * Returns the width for the specified column.
5411 * @param {Number} col The column index
5414 getColumnWidth : function(col){
5415 return this.config[col].width * 1 || this.defaultWidth;
5419 * Sets the width for a column.
5420 * @param {Number} col The column index
5421 * @param {Number} width The new width
5423 setColumnWidth : function(col, width, suppressEvent){
5424 this.config[col].width = width;
5425 this.totalWidth = null;
5427 this.fireEvent("widthchange", this, col, width);
5432 * Returns the total width of all columns.
5433 * @param {Boolean} includeHidden True to include hidden column widths
5436 getTotalWidth : function(includeHidden){
5437 if(!this.totalWidth){
5438 this.totalWidth = 0;
5439 for(var i = 0, len = this.config.length; i < len; i++){
5440 if(includeHidden || !this.isHidden(i)){
5441 this.totalWidth += this.getColumnWidth(i);
5445 return this.totalWidth;
5449 * Returns the header for the specified column.
5450 * @param {Number} col The column index
5453 getColumnHeader : function(col){
5454 return this.config[col].header;
5458 * Sets the header for a column.
5459 * @param {Number} col The column index
5460 * @param {String} header The new header
5462 setColumnHeader : function(col, header){
5463 this.config[col].header = header;
5464 this.fireEvent("headerchange", this, col, header);
5468 * Returns the tooltip for the specified column.
5469 * @param {Number} col The column index
5472 getColumnTooltip : function(col){
5473 return this.config[col].tooltip;
5476 * Sets the tooltip for a column.
5477 * @param {Number} col The column index
5478 * @param {String} tooltip The new tooltip
5480 setColumnTooltip : function(col, tooltip){
5481 this.config[col].tooltip = tooltip;
5485 * Returns the dataIndex for the specified column.
5486 * @param {Number} col The column index
5489 getDataIndex : function(col){
5490 return this.config[col].dataIndex;
5494 * Sets the dataIndex for a column.
5495 * @param {Number} col The column index
5496 * @param {Number} dataIndex The new dataIndex
5498 setDataIndex : function(col, dataIndex){
5499 this.config[col].dataIndex = dataIndex;
5505 * Returns true if the cell is editable.
5506 * @param {Number} colIndex The column index
5507 * @param {Number} rowIndex The row index - this is nto actually used..?
5510 isCellEditable : function(colIndex, rowIndex){
5511 return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
5515 * Returns the editor defined for the cell/column.
5516 * return false or null to disable editing.
5517 * @param {Number} colIndex The column index
5518 * @param {Number} rowIndex The row index
5521 getCellEditor : function(colIndex, rowIndex){
5522 return this.config[colIndex].editor;
5526 * Sets if a column is editable.
5527 * @param {Number} col The column index
5528 * @param {Boolean} editable True if the column is editable
5530 setEditable : function(col, editable){
5531 this.config[col].editable = editable;
5536 * Returns true if the column is hidden.
5537 * @param {Number} colIndex The column index
5540 isHidden : function(colIndex){
5541 return this.config[colIndex].hidden;
5546 * Returns true if the column width cannot be changed
5548 isFixed : function(colIndex){
5549 return this.config[colIndex].fixed;
5553 * Returns true if the column can be resized
5556 isResizable : function(colIndex){
5557 return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
5560 * Sets if a column is hidden.
5561 * @param {Number} colIndex The column index
5562 * @param {Boolean} hidden True if the column is hidden
5564 setHidden : function(colIndex, hidden){
5565 this.config[colIndex].hidden = hidden;
5566 this.totalWidth = null;
5567 this.fireEvent("hiddenchange", this, colIndex, hidden);
5571 * Sets the editor for a column.
5572 * @param {Number} col The column index
5573 * @param {Object} editor The editor object
5575 setEditor : function(col, editor){
5576 this.config[col].editor = editor;
5580 Roo.grid.ColumnModel.defaultRenderer = function(value)
5582 if(typeof value == "object") {
5585 if(typeof value == "string" && value.length < 1){
5589 return String.format("{0}", value);
5592 // Alias for backwards compatibility
5593 Roo.grid.DefaultColumnModel = Roo.grid.ColumnModel;
5596 * Ext JS Library 1.1.1
5597 * Copyright(c) 2006-2007, Ext JS, LLC.
5599 * Originally Released Under LGPL - original licence link has changed is not relivant.
5602 * <script type="text/javascript">
5606 * @class Roo.LoadMask
5607 * A simple utility class for generically masking elements while loading data. If the element being masked has
5608 * an underlying {@link Roo.data.Store}, the masking will be automatically synchronized with the store's loading
5609 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
5610 * element's UpdateManager load indicator and will be destroyed after the initial load.
5612 * Create a new LoadMask
5613 * @param {String/HTMLElement/Roo.Element} el The element or DOM node, or its id
5614 * @param {Object} config The config object
5616 Roo.LoadMask = function(el, config){
5617 this.el = Roo.get(el);
5618 Roo.apply(this, config);
5620 this.store.on('beforeload', this.onBeforeLoad, this);
5621 this.store.on('load', this.onLoad, this);
5622 this.store.on('loadexception', this.onLoadException, this);
5623 this.removeMask = false;
5625 var um = this.el.getUpdateManager();
5626 um.showLoadIndicator = false; // disable the default indicator
5627 um.on('beforeupdate', this.onBeforeLoad, this);
5628 um.on('update', this.onLoad, this);
5629 um.on('failure', this.onLoad, this);
5630 this.removeMask = true;
5634 Roo.LoadMask.prototype = {
5636 * @cfg {Boolean} removeMask
5637 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
5638 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
5642 * The text to display in a centered loading message box (defaults to 'Loading...')
5646 * @cfg {String} msgCls
5647 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
5649 msgCls : 'x-mask-loading',
5652 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
5658 * Disables the mask to prevent it from being displayed
5660 disable : function(){
5661 this.disabled = true;
5665 * Enables the mask so that it can be displayed
5667 enable : function(){
5668 this.disabled = false;
5671 onLoadException : function()
5675 if (typeof(arguments[3]) != 'undefined') {
5676 Roo.MessageBox.alert("Error loading",arguments[3]);
5680 if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
5681 Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
5688 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
5693 (function() { this.el.unmask(this.removeMask); }).defer(50, this);
5697 onBeforeLoad : function(){
5699 (function() { this.el.mask(this.msg, this.msgCls); }).defer(50, this);
5704 destroy : function(){
5706 this.store.un('beforeload', this.onBeforeLoad, this);
5707 this.store.un('load', this.onLoad, this);
5708 this.store.un('loadexception', this.onLoadException, this);
5710 var um = this.el.getUpdateManager();
5711 um.un('beforeupdate', this.onBeforeLoad, this);
5712 um.un('update', this.onLoad, this);
5713 um.un('failure', this.onLoad, this);
5724 * @class Roo.bootstrap.Table
5725 * @extends Roo.bootstrap.Component
5726 * Bootstrap Table class
5727 * @cfg {String} cls table class
5728 * @cfg {String} align (left|center|right) Specifies the alignment of a table according to surrounding text
5729 * @cfg {String} bgcolor Specifies the background color for a table
5730 * @cfg {Number} border Specifies whether the table cells should have borders or not
5731 * @cfg {Number} cellpadding Specifies the space between the cell wall and the cell content
5732 * @cfg {Number} cellspacing Specifies the space between cells
5733 * @cfg {String} frame Specifies which parts of the outside borders that should be visible
5734 * @cfg {String} rules Specifies which parts of the inside borders that should be visible
5735 * @cfg {String} sortable Specifies that the table should be sortable
5736 * @cfg {String} summary Specifies a summary of the content of a table
5737 * @cfg {Number} width Specifies the width of a table
5738 * @cfg {String} layout table layout (auto | fixed | initial | inherit)
5740 * @cfg {boolean} striped Should the rows be alternative striped
5741 * @cfg {boolean} bordered Add borders to the table
5742 * @cfg {boolean} hover Add hover highlighting
5743 * @cfg {boolean} condensed Format condensed
5744 * @cfg {boolean} responsive Format condensed
5745 * @cfg {Boolean} loadMask (true|false) default false
5746 * @cfg {Boolean} footerShow (true|false) generate tfoot, default true
5747 * @cfg {Boolean} headerShow (true|false) generate thead, default true
5748 * @cfg {Boolean} rowSelection (true|false) default false
5749 * @cfg {Boolean} cellSelection (true|false) default false
5750 * @cfg {Boolean} scrollBody (true|false) default false - body scrolled / fixed header
5751 * @cfg {Roo.bootstrap.PagingToolbar} footer a paging toolbar
5755 * Create a new Table
5756 * @param {Object} config The config object
5759 Roo.bootstrap.Table = function(config){
5760 Roo.bootstrap.Table.superclass.constructor.call(this, config);
5765 this.rowSelection = (typeof(config.rowSelection) != 'undefined') ? config.rowSelection : this.rowSelection;
5766 this.cellSelection = (typeof(config.cellSelection) != 'undefined') ? config.cellSelection : this.cellSelection;
5767 this.headerShow = (typeof(config.thead) != 'undefined') ? config.thead : this.headerShow;
5768 this.footerShow = (typeof(config.tfoot) != 'undefined') ? config.tfoot : this.footerShow;
5770 this.sm = this.sm || {xtype: 'RowSelectionModel'};
5772 this.sm.grid = this;
5773 this.selModel = Roo.factory(this.sm, Roo.bootstrap.Table);
5774 this.sm = this.selModel;
5775 this.sm.xmodule = this.xmodule || false;
5778 if (this.cm && typeof(this.cm.config) == 'undefined') {
5779 this.colModel = new Roo.grid.ColumnModel(this.cm);
5780 this.cm = this.colModel;
5781 this.cm.xmodule = this.xmodule || false;
5784 this.store= Roo.factory(this.store, Roo.data);
5785 this.ds = this.store;
5786 this.ds.xmodule = this.xmodule || false;
5789 if (this.footer && this.store) {
5790 this.footer.dataSource = this.ds;
5791 this.footer = Roo.factory(this.footer);
5798 * Fires when a cell is clicked
5799 * @param {Roo.bootstrap.Table} this
5800 * @param {Roo.Element} el
5801 * @param {Number} rowIndex
5802 * @param {Number} columnIndex
5803 * @param {Roo.EventObject} e
5807 * @event celldblclick
5808 * Fires when a cell is double clicked
5809 * @param {Roo.bootstrap.Table} this
5810 * @param {Roo.Element} el
5811 * @param {Number} rowIndex
5812 * @param {Number} columnIndex
5813 * @param {Roo.EventObject} e
5815 "celldblclick" : true,
5818 * Fires when a row is clicked
5819 * @param {Roo.bootstrap.Table} this
5820 * @param {Roo.Element} el
5821 * @param {Number} rowIndex
5822 * @param {Roo.EventObject} e
5826 * @event rowdblclick
5827 * Fires when a row is double clicked
5828 * @param {Roo.bootstrap.Table} this
5829 * @param {Roo.Element} el
5830 * @param {Number} rowIndex
5831 * @param {Roo.EventObject} e
5833 "rowdblclick" : true,
5836 * Fires when a mouseover occur
5837 * @param {Roo.bootstrap.Table} this
5838 * @param {Roo.Element} el
5839 * @param {Number} rowIndex
5840 * @param {Number} columnIndex
5841 * @param {Roo.EventObject} e
5846 * Fires when a mouseout occur
5847 * @param {Roo.bootstrap.Table} this
5848 * @param {Roo.Element} el
5849 * @param {Number} rowIndex
5850 * @param {Number} columnIndex
5851 * @param {Roo.EventObject} e
5856 * Fires when a row is rendered, so you can change add a style to it.
5857 * @param {Roo.bootstrap.Table} this
5858 * @param {Object} rowcfg contains record rowIndex colIndex and rowClass - set rowClass to add a style.
5862 * @event rowsrendered
5863 * Fires when all the rows have been rendered
5864 * @param {Roo.bootstrap.Table} this
5866 'rowsrendered' : true,
5868 * @event contextmenu
5869 * The raw contextmenu event for the entire grid.
5870 * @param {Roo.EventObject} e
5872 "contextmenu" : true,
5874 * @event rowcontextmenu
5875 * Fires when a row is right clicked
5876 * @param {Roo.bootstrap.Table} this
5877 * @param {Number} rowIndex
5878 * @param {Roo.EventObject} e
5880 "rowcontextmenu" : true,
5882 * @event cellcontextmenu
5883 * Fires when a cell is right clicked
5884 * @param {Roo.bootstrap.Table} this
5885 * @param {Number} rowIndex
5886 * @param {Number} cellIndex
5887 * @param {Roo.EventObject} e
5889 "cellcontextmenu" : true,
5891 * @event headercontextmenu
5892 * Fires when a header is right clicked
5893 * @param {Roo.bootstrap.Table} this
5894 * @param {Number} columnIndex
5895 * @param {Roo.EventObject} e
5897 "headercontextmenu" : true
5901 Roo.extend(Roo.bootstrap.Table, Roo.bootstrap.Component, {
5927 rowSelection : false,
5928 cellSelection : false,
5931 // Roo.Element - the tbody
5933 // Roo.Element - thead element
5936 container: false, // used by gridpanel...
5938 getAutoCreate : function()
5940 var cfg = Roo.apply({}, Roo.bootstrap.Table.superclass.getAutoCreate.call(this));
5947 if (this.scrollBody) {
5948 cfg.cls += ' table-body-fixed';
5951 cfg.cls += ' table-striped';
5955 cfg.cls += ' table-hover';
5957 if (this.bordered) {
5958 cfg.cls += ' table-bordered';
5960 if (this.condensed) {
5961 cfg.cls += ' table-condensed';
5963 if (this.responsive) {
5964 cfg.cls += ' table-responsive';
5968 cfg.cls+= ' ' +this.cls;
5971 // this lot should be simplifed...
5974 cfg.align=this.align;
5977 cfg.bgcolor=this.bgcolor;
5980 cfg.border=this.border;
5982 if (this.cellpadding) {
5983 cfg.cellpadding=this.cellpadding;
5985 if (this.cellspacing) {
5986 cfg.cellspacing=this.cellspacing;
5989 cfg.frame=this.frame;
5992 cfg.rules=this.rules;
5994 if (this.sortable) {
5995 cfg.sortable=this.sortable;
5998 cfg.summary=this.summary;
6001 cfg.width=this.width;
6004 cfg.style = (typeof(cfg.style) == 'undefined') ? ('table-layout:' + this.layout + ';') : (cfg.style + ('table-layout:' + this.layout + ';'));
6007 if(this.store || this.cm){
6008 if(this.headerShow){
6009 cfg.cn.push(this.renderHeader());
6012 cfg.cn.push(this.renderBody());
6014 if(this.footerShow){
6015 cfg.cn.push(this.renderFooter());
6017 // where does this come from?
6018 //cfg.cls+= ' TableGrid';
6021 return { cn : [ cfg ] };
6024 initEvents : function()
6026 if(!this.store || !this.cm){
6029 if (this.selModel) {
6030 this.selModel.initEvents();
6034 //Roo.log('initEvents with ds!!!!');
6036 this.mainBody = this.el.select('tbody', true).first();
6037 this.mainHead = this.el.select('thead', true).first();
6044 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6045 e.on('click', _this.sort, _this);
6048 this.mainBody.on("click", this.onClick, this);
6049 this.mainBody.on("dblclick", this.onDblClick, this);
6051 // why is this done????? = it breaks dialogs??
6052 //this.parent().el.setStyle('position', 'relative');
6056 this.footer.parentId = this.id;
6057 this.footer.onRender(this.el.select('tfoot tr td').first(), null);
6060 this.maskEl = new Roo.LoadMask(this.el, { store : this.ds, msgCls: 'roo-el-mask-msg' });
6062 this.store.on('load', this.onLoad, this);
6063 this.store.on('beforeload', this.onBeforeLoad, this);
6064 this.store.on('update', this.onUpdate, this);
6065 this.store.on('add', this.onAdd, this);
6066 this.store.on("clear", this.clear, this);
6068 this.el.on("contextmenu", this.onContextMenu, this);
6070 this.mainBody.on('scroll', this.onBodyScroll, this);
6075 onContextMenu : function(e, t)
6077 this.processEvent("contextmenu", e);
6080 processEvent : function(name, e)
6082 if (name != 'touchstart' ) {
6083 this.fireEvent(name, e);
6086 var t = e.getTarget();
6088 var cell = Roo.get(t);
6094 if(cell.findParent('tfoot', false, true)){
6098 if(cell.findParent('thead', false, true)){
6100 if(e.getTarget().nodeName.toLowerCase() != 'th'){
6101 cell = Roo.get(t).findParent('th', false, true);
6103 Roo.log("failed to find th in thead?");
6104 Roo.log(e.getTarget());
6109 var cellIndex = cell.dom.cellIndex;
6111 var ename = name == 'touchstart' ? 'click' : name;
6112 this.fireEvent("header" + ename, this, cellIndex, e);
6117 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6118 cell = Roo.get(t).findParent('td', false, true);
6120 Roo.log("failed to find th in tbody?");
6121 Roo.log(e.getTarget());
6126 var row = cell.findParent('tr', false, true);
6127 var cellIndex = cell.dom.cellIndex;
6128 var rowIndex = row.dom.rowIndex - 1;
6132 this.fireEvent("row" + name, this, rowIndex, e);
6136 this.fireEvent("cell" + name, this, rowIndex, cellIndex, e);
6142 onMouseover : function(e, el)
6144 var cell = Roo.get(el);
6150 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6151 cell = cell.findParent('td', false, true);
6154 var row = cell.findParent('tr', false, true);
6155 var cellIndex = cell.dom.cellIndex;
6156 var rowIndex = row.dom.rowIndex - 1; // start from 0
6158 this.fireEvent('mouseover', this, cell, rowIndex, cellIndex, e);
6162 onMouseout : function(e, el)
6164 var cell = Roo.get(el);
6170 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6171 cell = cell.findParent('td', false, true);
6174 var row = cell.findParent('tr', false, true);
6175 var cellIndex = cell.dom.cellIndex;
6176 var rowIndex = row.dom.rowIndex - 1; // start from 0
6178 this.fireEvent('mouseout', this, cell, rowIndex, cellIndex, e);
6182 onClick : function(e, el)
6184 var cell = Roo.get(el);
6186 if(!cell || (!this.cellSelection && !this.rowSelection)){
6190 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6191 cell = cell.findParent('td', false, true);
6194 if(!cell || typeof(cell) == 'undefined'){
6198 var row = cell.findParent('tr', false, true);
6200 if(!row || typeof(row) == 'undefined'){
6204 var cellIndex = cell.dom.cellIndex;
6205 var rowIndex = this.getRowIndex(row);
6207 // why??? - should these not be based on SelectionModel?
6208 if(this.cellSelection){
6209 this.fireEvent('cellclick', this, cell, rowIndex, cellIndex, e);
6212 if(this.rowSelection){
6213 this.fireEvent('rowclick', this, row, rowIndex, e);
6219 onDblClick : function(e,el)
6221 var cell = Roo.get(el);
6223 if(!cell || (!this.cellSelection && !this.rowSelection)){
6227 if(e.getTarget().nodeName.toLowerCase() != 'td'){
6228 cell = cell.findParent('td', false, true);
6231 if(!cell || typeof(cell) == 'undefined'){
6235 var row = cell.findParent('tr', false, true);
6237 if(!row || typeof(row) == 'undefined'){
6241 var cellIndex = cell.dom.cellIndex;
6242 var rowIndex = this.getRowIndex(row);
6244 if(this.cellSelection){
6245 this.fireEvent('celldblclick', this, cell, rowIndex, cellIndex, e);
6248 if(this.rowSelection){
6249 this.fireEvent('rowdblclick', this, row, rowIndex, e);
6253 sort : function(e,el)
6255 var col = Roo.get(el);
6257 if(!col.hasClass('sortable')){
6261 var sort = col.attr('sort');
6264 if(col.select('i', true).first().hasClass('glyphicon-arrow-up')){
6268 this.store.sortInfo = {field : sort, direction : dir};
6271 Roo.log("calling footer first");
6272 this.footer.onClick('first');
6275 this.store.load({ params : { start : 0 } });
6279 renderHeader : function()
6287 this.totalWidth = 0;
6289 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
6291 var config = cm.config[i];
6296 html: cm.getColumnHeader(i)
6301 if(typeof(config.sortable) != 'undefined' && config.sortable){
6303 c.html = '<i class="glyphicon"></i>' + c.html;
6306 if(typeof(config.lgHeader) != 'undefined'){
6307 hh += '<span class="hidden-xs hidden-sm hidden-md">' + config.lgHeader + '</span>';
6310 if(typeof(config.mdHeader) != 'undefined'){
6311 hh += '<span class="hidden-xs hidden-sm hidden-lg">' + config.mdHeader + '</span>';
6314 if(typeof(config.smHeader) != 'undefined'){
6315 hh += '<span class="hidden-xs hidden-md hidden-lg">' + config.smHeader + '</span>';
6318 if(typeof(config.xsHeader) != 'undefined'){
6319 hh += '<span class="hidden-sm hidden-md hidden-lg">' + config.xsHeader + '</span>';
6326 if(typeof(config.tooltip) != 'undefined'){
6327 c.tooltip = config.tooltip;
6330 if(typeof(config.colspan) != 'undefined'){
6331 c.colspan = config.colspan;
6334 if(typeof(config.hidden) != 'undefined' && config.hidden){
6335 c.style += ' display:none;';
6338 if(typeof(config.dataIndex) != 'undefined'){
6339 c.sort = config.dataIndex;
6344 if(typeof(config.align) != 'undefined' && config.align.length){
6345 c.style += ' text-align:' + config.align + ';';
6348 if(typeof(config.width) != 'undefined'){
6349 c.style += ' width:' + config.width + 'px;';
6350 this.totalWidth += config.width;
6352 this.totalWidth += 100; // assume minimum of 100 per column?
6355 if(typeof(config.cls) != 'undefined'){
6356 c.cls = (typeof(c.cls) == 'undefined') ? config.cls : (c.cls + ' ' + config.cls);
6359 ['xs','sm','md','lg'].map(function(size){
6361 if(typeof(config[size]) == 'undefined'){
6365 if (!config[size]) { // 0 = hidden
6366 c.cls += ' hidden-' + size;
6370 c.cls += ' col-' + size + '-' + config[size];
6380 renderBody : function()
6390 colspan : this.cm.getColumnCount()
6400 renderFooter : function()
6410 colspan : this.cm.getColumnCount()
6424 // Roo.log('ds onload');
6429 var ds = this.store;
6431 Roo.each(this.el.select('thead th.sortable', true).elements, function(e){
6432 e.select('i', true).removeClass(['glyphicon-arrow-up', 'glyphicon-arrow-down']);
6433 if (_this.store.sortInfo) {
6435 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'ASC'){
6436 e.select('i', true).addClass(['glyphicon-arrow-up']);
6439 if(e.hasClass('sortable') && e.attr('sort') == _this.store.sortInfo.field && _this.store.sortInfo.direction.toUpperCase() == 'DESC'){
6440 e.select('i', true).addClass(['glyphicon-arrow-down']);
6445 var tbody = this.mainBody;
6447 if(ds.getCount() > 0){
6448 ds.data.each(function(d,rowIndex){
6449 var row = this.renderRow(cm, ds, rowIndex);
6451 tbody.createChild(row);
6455 if(row.cellObjects.length){
6456 Roo.each(row.cellObjects, function(r){
6457 _this.renderCellObject(r);
6464 Roo.each(this.el.select('tbody td', true).elements, function(e){
6465 e.on('mouseover', _this.onMouseover, _this);
6468 Roo.each(this.el.select('tbody td', true).elements, function(e){
6469 e.on('mouseout', _this.onMouseout, _this);
6471 this.fireEvent('rowsrendered', this);
6472 //if(this.loadMask){
6473 // this.maskEl.hide();
6480 onUpdate : function(ds,record)
6482 this.refreshRow(record);
6486 onRemove : function(ds, record, index, isUpdate){
6487 if(isUpdate !== true){
6488 this.fireEvent("beforerowremoved", this, index, record);
6490 var bt = this.mainBody.dom;
6492 var rows = this.el.select('tbody > tr', true).elements;
6494 if(typeof(rows[index]) != 'undefined'){
6495 bt.removeChild(rows[index].dom);
6498 // if(bt.rows[index]){
6499 // bt.removeChild(bt.rows[index]);
6502 if(isUpdate !== true){
6503 //this.stripeRows(index);
6504 //this.syncRowHeights(index, index);
6506 this.fireEvent("rowremoved", this, index, record);
6510 onAdd : function(ds, records, rowIndex)
6512 //Roo.log('on Add called');
6513 // - note this does not handle multiple adding very well..
6514 var bt = this.mainBody.dom;
6515 for (var i =0 ; i < records.length;i++) {
6516 //Roo.log('call insert row Add called on ' + rowIndex + ':' + i);
6517 //Roo.log(records[i]);
6518 //Roo.log(this.store.getAt(rowIndex+i));
6519 this.insertRow(this.store, rowIndex + i, false);
6526 refreshRow : function(record){
6527 var ds = this.store, index;
6528 if(typeof record == 'number'){
6530 record = ds.getAt(index);
6532 index = ds.indexOf(record);
6534 this.insertRow(ds, index, true);
6536 this.onRemove(ds, record, index+1, true);
6538 //this.syncRowHeights(index, index);
6540 this.fireEvent("rowupdated", this, index, record);
6543 insertRow : function(dm, rowIndex, isUpdate){
6546 this.fireEvent("beforerowsinserted", this, rowIndex);
6548 //var s = this.getScrollState();
6549 var row = this.renderRow(this.cm, this.store, rowIndex);
6550 // insert before rowIndex..
6551 var e = this.mainBody.createChild(row,this.getRowDom(rowIndex));
6555 if(row.cellObjects.length){
6556 Roo.each(row.cellObjects, function(r){
6557 _this.renderCellObject(r);
6562 this.fireEvent("rowsinserted", this, rowIndex);
6563 //this.syncRowHeights(firstRow, lastRow);
6564 //this.stripeRows(firstRow);
6571 getRowDom : function(rowIndex)
6573 var rows = this.el.select('tbody > tr', true).elements;
6575 return (typeof(rows[rowIndex]) == 'undefined') ? false : rows[rowIndex];
6578 // returns the object tree for a tr..
6581 renderRow : function(cm, ds, rowIndex)
6584 var d = ds.getAt(rowIndex);
6591 var cellObjects = [];
6593 for(var i = 0, len = cm.getColumnCount(); i < len; i++){
6594 var config = cm.config[i];
6596 var renderer = cm.getRenderer(i);
6600 if(typeof(renderer) !== 'undefined'){
6601 value = renderer(d.data[cm.getDataIndex(i)], false, d);
6603 // if object are returned, then they are expected to be Roo.bootstrap.Component instances
6604 // and are rendered into the cells after the row is rendered - using the id for the element.
6606 if(typeof(value) === 'object'){
6616 rowIndex : rowIndex,
6621 this.fireEvent('rowclass', this, rowcfg);
6625 cls : rowcfg.rowClass,
6627 html: (typeof(value) === 'object') ? '' : value
6634 if(typeof(config.colspan) != 'undefined'){
6635 td.colspan = config.colspan;
6638 if(typeof(config.hidden) != 'undefined' && config.hidden){
6639 td.style += ' display:none;';
6642 if(typeof(config.align) != 'undefined' && config.align.length){
6643 td.style += ' text-align:' + config.align + ';';
6646 if(typeof(config.width) != 'undefined'){
6647 td.style += ' width:' + config.width + 'px;';
6650 if(typeof(config.cursor) != 'undefined'){
6651 td.style += ' cursor:' + config.cursor + ';';
6654 if(typeof(config.cls) != 'undefined'){
6655 td.cls = (typeof(td.cls) == 'undefined') ? config.cls : (td.cls + ' ' + config.cls);
6658 ['xs','sm','md','lg'].map(function(size){
6660 if(typeof(config[size]) == 'undefined'){
6664 if (!config[size]) { // 0 = hidden
6665 td.cls += ' hidden-' + size;
6669 td.cls += ' col-' + size + '-' + config[size];
6677 row.cellObjects = cellObjects;
6685 onBeforeLoad : function()
6687 //Roo.log('ds onBeforeLoad');
6691 //if(this.loadMask){
6692 // this.maskEl.show();
6700 this.el.select('tbody', true).first().dom.innerHTML = '';
6703 * Show or hide a row.
6704 * @param {Number} rowIndex to show or hide
6705 * @param {Boolean} state hide
6707 setRowVisibility : function(rowIndex, state)
6709 var bt = this.mainBody.dom;
6711 var rows = this.el.select('tbody > tr', true).elements;
6713 if(typeof(rows[rowIndex]) == 'undefined'){
6716 rows[rowIndex].dom.style.display = state ? '' : 'none';
6720 getSelectionModel : function(){
6722 this.selModel = new Roo.bootstrap.Table.RowSelectionModel({grid: this});
6724 return this.selModel;
6727 * Render the Roo.bootstrap object from renderder
6729 renderCellObject : function(r)
6733 var t = r.cfg.render(r.container);
6736 Roo.each(r.cfg.cn, function(c){
6738 container: t.getChildContainer(),
6741 _this.renderCellObject(child);
6746 getRowIndex : function(row)
6750 Roo.each(this.el.select('tbody > tr', true).elements, function(el, index){
6761 * Returns the grid's underlying element = used by panel.Grid
6762 * @return {Element} The element
6764 getGridEl : function(){
6768 * Forces a resize - used by panel.Grid
6769 * @return {Element} The element
6771 autoSize : function()
6773 //var ctr = Roo.get(this.container.dom.parentElement);
6774 var ctr = Roo.get(this.el.dom);
6776 var thd = this.getGridEl().select('thead',true).first();
6777 var tbd = this.getGridEl().select('tbody', true).first();
6778 var tfd = this.getGridEl().select('tfoot', true).first();
6780 var cw = ctr.getWidth();
6784 tbd.setSize(ctr.getWidth(),
6785 ctr.getHeight() - (thd.getHeight() + (tfd ? tfd.getHeight() : 0))
6787 var barsize = (tbd.dom.offsetWidth - tbd.dom.clientWidth);
6790 cw = Math.max(cw, this.totalWidth);
6791 this.getGridEl().select('tr',true).setWidth(cw);
6792 // resize 'expandable coloumn?
6794 return; // we doe not have a view in this design..
6797 onBodyScroll: function()
6800 //Roo.log("body scrolled');" + this.mainBody.dom.scrollLeft);
6801 this.mainHead.setStyle({
6802 'position' : 'relative',
6803 'left': (-1* this.mainBody.dom.scrollLeft) + 'px'
6820 * @class Roo.bootstrap.TableCell
6821 * @extends Roo.bootstrap.Component
6822 * Bootstrap TableCell class
6823 * @cfg {String} html cell contain text
6824 * @cfg {String} cls cell class
6825 * @cfg {String} tag cell tag (td|th) default td
6826 * @cfg {String} abbr Specifies an abbreviated version of the content in a cell
6827 * @cfg {String} align Aligns the content in a cell
6828 * @cfg {String} axis Categorizes cells
6829 * @cfg {String} bgcolor Specifies the background color of a cell
6830 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
6831 * @cfg {Number} colspan Specifies the number of columns a cell should span
6832 * @cfg {String} headers Specifies one or more header cells a cell is related to
6833 * @cfg {Number} height Sets the height of a cell
6834 * @cfg {String} nowrap Specifies that the content inside a cell should not wrap
6835 * @cfg {Number} rowspan Sets the number of rows a cell should span
6836 * @cfg {String} scope Defines a way to associate header cells and data cells in a table
6837 * @cfg {String} valign Vertical aligns the content in a cell
6838 * @cfg {Number} width Specifies the width of a cell
6841 * Create a new TableCell
6842 * @param {Object} config The config object
6845 Roo.bootstrap.TableCell = function(config){
6846 Roo.bootstrap.TableCell.superclass.constructor.call(this, config);
6849 Roo.extend(Roo.bootstrap.TableCell, Roo.bootstrap.Component, {
6869 getAutoCreate : function(){
6870 var cfg = Roo.apply({}, Roo.bootstrap.TableCell.superclass.getAutoCreate.call(this));
6890 cfg.align=this.align
6896 cfg.bgcolor=this.bgcolor
6899 cfg.charoff=this.charoff
6902 cfg.colspan=this.colspan
6905 cfg.headers=this.headers
6908 cfg.height=this.height
6911 cfg.nowrap=this.nowrap
6914 cfg.rowspan=this.rowspan
6917 cfg.scope=this.scope
6920 cfg.valign=this.valign
6923 cfg.width=this.width
6942 * @class Roo.bootstrap.TableRow
6943 * @extends Roo.bootstrap.Component
6944 * Bootstrap TableRow class
6945 * @cfg {String} cls row class
6946 * @cfg {String} align Aligns the content in a table row
6947 * @cfg {String} bgcolor Specifies a background color for a table row
6948 * @cfg {Number} charoff Sets the number of characters the content will be aligned from the character specified by the char attribute
6949 * @cfg {String} valign Vertical aligns the content in a table row
6952 * Create a new TableRow
6953 * @param {Object} config The config object
6956 Roo.bootstrap.TableRow = function(config){
6957 Roo.bootstrap.TableRow.superclass.constructor.call(this, config);
6960 Roo.extend(Roo.bootstrap.TableRow, Roo.bootstrap.Component, {
6968 getAutoCreate : function(){
6969 var cfg = Roo.apply({}, Roo.bootstrap.TableRow.superclass.getAutoCreate.call(this));
6979 cfg.align = this.align;
6982 cfg.bgcolor = this.bgcolor;
6985 cfg.charoff = this.charoff;
6988 cfg.valign = this.valign;
7006 * @class Roo.bootstrap.TableBody
7007 * @extends Roo.bootstrap.Component
7008 * Bootstrap TableBody class
7009 * @cfg {String} cls element class
7010 * @cfg {String} tag element tag (thead|tbody|tfoot) default tbody
7011 * @cfg {String} align Aligns the content inside the element
7012 * @cfg {Number} charoff Sets the number of characters the content inside the element will be aligned from the character specified by the char attribute
7013 * @cfg {String} valign Vertical aligns the content inside the <tbody> element
7016 * Create a new TableBody
7017 * @param {Object} config The config object
7020 Roo.bootstrap.TableBody = function(config){
7021 Roo.bootstrap.TableBody.superclass.constructor.call(this, config);
7024 Roo.extend(Roo.bootstrap.TableBody, Roo.bootstrap.Component, {
7032 getAutoCreate : function(){
7033 var cfg = Roo.apply({}, Roo.bootstrap.TableBody.superclass.getAutoCreate.call(this));
7047 cfg.align = this.align;
7050 cfg.charoff = this.charoff;
7053 cfg.valign = this.valign;
7060 // initEvents : function()
7067 // this.store = Roo.factory(this.store, Roo.data);
7068 // this.store.on('load', this.onLoad, this);
7070 // this.store.load();
7074 // onLoad: function ()
7076 // this.fireEvent('load', this);
7086 * Ext JS Library 1.1.1
7087 * Copyright(c) 2006-2007, Ext JS, LLC.
7089 * Originally Released Under LGPL - original licence link has changed is not relivant.
7092 * <script type="text/javascript">
7095 // as we use this in bootstrap.
7096 Roo.namespace('Roo.form');
7098 * @class Roo.form.Action
7099 * Internal Class used to handle form actions
7101 * @param {Roo.form.BasicForm} el The form element or its id
7102 * @param {Object} config Configuration options
7107 // define the action interface
7108 Roo.form.Action = function(form, options){
7110 this.options = options || {};
7113 * Client Validation Failed
7116 Roo.form.Action.CLIENT_INVALID = 'client';
7118 * Server Validation Failed
7121 Roo.form.Action.SERVER_INVALID = 'server';
7123 * Connect to Server Failed
7126 Roo.form.Action.CONNECT_FAILURE = 'connect';
7128 * Reading Data from Server Failed
7131 Roo.form.Action.LOAD_FAILURE = 'load';
7133 Roo.form.Action.prototype = {
7135 failureType : undefined,
7136 response : undefined,
7140 run : function(options){
7145 success : function(response){
7150 handleResponse : function(response){
7154 // default connection failure
7155 failure : function(response){
7157 this.response = response;
7158 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7159 this.form.afterAction(this, false);
7162 processResponse : function(response){
7163 this.response = response;
7164 if(!response.responseText){
7167 this.result = this.handleResponse(response);
7171 // utility functions used internally
7172 getUrl : function(appendParams){
7173 var url = this.options.url || this.form.url || this.form.el.dom.action;
7175 var p = this.getParams();
7177 url += (url.indexOf('?') != -1 ? '&' : '?') + p;
7183 getMethod : function(){
7184 return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
7187 getParams : function(){
7188 var bp = this.form.baseParams;
7189 var p = this.options.params;
7191 if(typeof p == "object"){
7192 p = Roo.urlEncode(Roo.applyIf(p, bp));
7193 }else if(typeof p == 'string' && bp){
7194 p += '&' + Roo.urlEncode(bp);
7197 p = Roo.urlEncode(bp);
7202 createCallback : function(){
7204 success: this.success,
7205 failure: this.failure,
7207 timeout: (this.form.timeout*1000),
7208 upload: this.form.fileUpload ? this.success : undefined
7213 Roo.form.Action.Submit = function(form, options){
7214 Roo.form.Action.Submit.superclass.constructor.call(this, form, options);
7217 Roo.extend(Roo.form.Action.Submit, Roo.form.Action, {
7220 haveProgress : false,
7221 uploadComplete : false,
7223 // uploadProgress indicator.
7224 uploadProgress : function()
7226 if (!this.form.progressUrl) {
7230 if (!this.haveProgress) {
7231 Roo.MessageBox.progress("Uploading", "Uploading");
7233 if (this.uploadComplete) {
7234 Roo.MessageBox.hide();
7238 this.haveProgress = true;
7240 var uid = this.form.findField('UPLOAD_IDENTIFIER').getValue();
7242 var c = new Roo.data.Connection();
7244 url : this.form.progressUrl,
7249 success : function(req){
7250 //console.log(data);
7254 rdata = Roo.decode(req.responseText)
7256 Roo.log("Invalid data from server..");
7260 if (!rdata || !rdata.success) {
7262 Roo.MessageBox.alert(Roo.encode(rdata));
7265 var data = rdata.data;
7267 if (this.uploadComplete) {
7268 Roo.MessageBox.hide();
7273 Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
7274 Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
7277 this.uploadProgress.defer(2000,this);
7280 failure: function(data) {
7281 Roo.log('progress url failed ');
7292 // run get Values on the form, so it syncs any secondary forms.
7293 this.form.getValues();
7295 var o = this.options;
7296 var method = this.getMethod();
7297 var isPost = method == 'POST';
7298 if(o.clientValidation === false || this.form.isValid()){
7300 if (this.form.progressUrl) {
7301 this.form.findField('UPLOAD_IDENTIFIER').setValue(
7302 (new Date() * 1) + '' + Math.random());
7307 Roo.Ajax.request(Roo.apply(this.createCallback(), {
7308 form:this.form.el.dom,
7309 url:this.getUrl(!isPost),
7311 params:isPost ? this.getParams() : null,
7312 isUpload: this.form.fileUpload
7315 this.uploadProgress();
7317 }else if (o.clientValidation !== false){ // client validation failed
7318 this.failureType = Roo.form.Action.CLIENT_INVALID;
7319 this.form.afterAction(this, false);
7323 success : function(response)
7325 this.uploadComplete= true;
7326 if (this.haveProgress) {
7327 Roo.MessageBox.hide();
7331 var result = this.processResponse(response);
7332 if(result === true || result.success){
7333 this.form.afterAction(this, true);
7337 this.form.markInvalid(result.errors);
7338 this.failureType = Roo.form.Action.SERVER_INVALID;
7340 this.form.afterAction(this, false);
7342 failure : function(response)
7344 this.uploadComplete= true;
7345 if (this.haveProgress) {
7346 Roo.MessageBox.hide();
7349 this.response = response;
7350 this.failureType = Roo.form.Action.CONNECT_FAILURE;
7351 this.form.afterAction(this, false);
7354 handleResponse : function(response){
7355 if(this.form.errorReader){
7356 var rs = this.form.errorReader.read(response);
7359 for(var i = 0, len = rs.records.length; i < len; i++) {
7360 var r = rs.records[i];
7364 if(errors.length < 1){
7368 success : rs.success,
7374 ret = Roo.decode(response.responseText);
7378 errorMsg: "Failed to read server message: " + (response ? response.responseText : ' - no message'),
7388 Roo.form.Action.Load = function(form, options){
7389 Roo.form.Action.Load.superclass.constructor.call(this, form, options);
7390 this.reader = this.form.reader;
7393 Roo.extend(Roo.form.Action.Load, Roo.form.Action, {
7398 Roo.Ajax.request(Roo.apply(
7399 this.createCallback(), {
7400 method:this.getMethod(),
7401 url:this.getUrl(false),
7402 params:this.getParams()
7406 success : function(response){
7408 var result = this.processResponse(response);
7409 if(result === true || !result.success || !result.data){
7410 this.failureType = Roo.form.Action.LOAD_FAILURE;
7411 this.form.afterAction(this, false);
7414 this.form.clearInvalid();
7415 this.form.setValues(result.data);
7416 this.form.afterAction(this, true);
7419 handleResponse : function(response){
7420 if(this.form.reader){
7421 var rs = this.form.reader.read(response);
7422 var data = rs.records && rs.records[0] ? rs.records[0].data : null;
7424 success : rs.success,
7428 return Roo.decode(response.responseText);
7432 Roo.form.Action.ACTION_TYPES = {
7433 'load' : Roo.form.Action.Load,
7434 'submit' : Roo.form.Action.Submit
7443 * @class Roo.bootstrap.Form
7444 * @extends Roo.bootstrap.Component
7445 * Bootstrap Form class
7446 * @cfg {String} method GET | POST (default POST)
7447 * @cfg {String} labelAlign top | left (default top)
7448 * @cfg {String} align left | right - for navbars
7449 * @cfg {Boolean} loadMask load mask when submit (default true)
7454 * @param {Object} config The config object
7458 Roo.bootstrap.Form = function(config){
7459 Roo.bootstrap.Form.superclass.constructor.call(this, config);
7461 Roo.bootstrap.Form.popover.apply();
7465 * @event clientvalidation
7466 * If the monitorValid config option is true, this event fires repetitively to notify of valid state
7467 * @param {Form} this
7468 * @param {Boolean} valid true if the form has passed client-side validation
7470 clientvalidation: true,
7472 * @event beforeaction
7473 * Fires before any action is performed. Return false to cancel the action.
7474 * @param {Form} this
7475 * @param {Action} action The action to be performed
7479 * @event actionfailed
7480 * Fires when an action fails.
7481 * @param {Form} this
7482 * @param {Action} action The action that failed
7484 actionfailed : true,
7486 * @event actioncomplete
7487 * Fires when an action is completed.
7488 * @param {Form} this
7489 * @param {Action} action The action that completed
7491 actioncomplete : true
7496 Roo.extend(Roo.bootstrap.Form, Roo.bootstrap.Component, {
7499 * @cfg {String} method
7500 * The request method to use (GET or POST) for form actions if one isn't supplied in the action options.
7505 * The URL to use for form actions if one isn't supplied in the action options.
7508 * @cfg {Boolean} fileUpload
7509 * Set to true if this form is a file upload.
7513 * @cfg {Object} baseParams
7514 * Parameters to pass with all requests. e.g. baseParams: {id: '123', foo: 'bar'}.
7518 * @cfg {Number} timeout Timeout for form actions in seconds (default is 30 seconds).
7522 * @cfg {Sting} align (left|right) for navbar forms
7527 activeAction : null,
7530 * By default wait messages are displayed with Roo.MessageBox.wait. You can target a specific
7531 * element by passing it or its id or mask the form itself by passing in true.
7534 waitMsgTarget : false,
7539 * @cfg {Boolean} errorMask (true|false) default false
7543 getAutoCreate : function(){
7547 method : this.method || 'POST',
7548 id : this.id || Roo.id(),
7551 if (this.parent().xtype.match(/^Nav/)) {
7552 cfg.cls = 'navbar-form navbar-' + this.align;
7556 if (this.labelAlign == 'left' ) {
7557 cfg.cls += ' form-horizontal';
7563 initEvents : function()
7565 this.el.on('submit', this.onSubmit, this);
7566 // this was added as random key presses on the form where triggering form submit.
7567 this.el.on('keypress', function(e) {
7568 if (e.getCharCode() != 13) {
7571 // we might need to allow it for textareas.. and some other items.
7572 // check e.getTarget().
7574 if(e.getTarget().nodeName.toLowerCase() === 'textarea'){
7578 Roo.log("keypress blocked");
7586 onSubmit : function(e){
7591 * Returns true if client-side validation on the form is successful.
7594 isValid : function(){
7595 var items = this.getItems();
7599 items.each(function(f){
7606 if(!target && f.el.isVisible(true)){
7612 if(this.errorMask && !valid){
7613 Roo.bootstrap.Form.popover.mask(this, target);
7620 * Returns true if any fields in this form have changed since their original load.
7623 isDirty : function(){
7625 var items = this.getItems();
7626 items.each(function(f){
7636 * Performs a predefined action (submit or load) or custom actions you define on this form.
7637 * @param {String} actionName The name of the action type
7638 * @param {Object} options (optional) The options to pass to the action. All of the config options listed
7639 * below are supported by both the submit and load actions unless otherwise noted (custom actions could also
7640 * accept other config options):
7642 Property Type Description
7643 ---------------- --------------- ----------------------------------------------------------------------------------
7644 url String The url for the action (defaults to the form's url)
7645 method String The form method to use (defaults to the form's method, or POST if not defined)
7646 params String/Object The params to pass (defaults to the form's baseParams, or none if not defined)
7647 clientValidation Boolean Applies to submit only. Pass true to call form.isValid() prior to posting to
7648 validate the form on the client (defaults to false)
7650 * @return {BasicForm} this
7652 doAction : function(action, options){
7653 if(typeof action == 'string'){
7654 action = new Roo.form.Action.ACTION_TYPES[action](this, options);
7656 if(this.fireEvent('beforeaction', this, action) !== false){
7657 this.beforeAction(action);
7658 action.run.defer(100, action);
7664 beforeAction : function(action){
7665 var o = action.options;
7668 this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
7670 // not really supported yet.. ??
7672 //if(this.waitMsgTarget === true){
7673 // this.el.mask(o.waitMsg || "Sending", 'x-mask-loading');
7674 //}else if(this.waitMsgTarget){
7675 // this.waitMsgTarget = Roo.get(this.waitMsgTarget);
7676 // this.waitMsgTarget.mask(o.waitMsg || "Sending", 'x-mask-loading');
7678 // Roo.MessageBox.wait(o.waitMsg || "Sending", o.waitTitle || this.waitTitle || 'Please Wait...');
7684 afterAction : function(action, success){
7685 this.activeAction = null;
7686 var o = action.options;
7688 //if(this.waitMsgTarget === true){
7690 //}else if(this.waitMsgTarget){
7691 // this.waitMsgTarget.unmask();
7693 // Roo.MessageBox.updateProgress(1);
7694 // Roo.MessageBox.hide();
7701 Roo.callback(o.success, o.scope, [this, action]);
7702 this.fireEvent('actioncomplete', this, action);
7706 // failure condition..
7707 // we have a scenario where updates need confirming.
7708 // eg. if a locking scenario exists..
7709 // we look for { errors : { needs_confirm : true }} in the response.
7711 (typeof(action.result) != 'undefined') &&
7712 (typeof(action.result.errors) != 'undefined') &&
7713 (typeof(action.result.errors.needs_confirm) != 'undefined')
7716 Roo.log("not supported yet");
7719 Roo.MessageBox.confirm(
7720 "Change requires confirmation",
7721 action.result.errorMsg,
7726 _t.doAction('submit', { params : { _submit_confirmed : 1 } } );
7736 Roo.callback(o.failure, o.scope, [this, action]);
7737 // show an error message if no failed handler is set..
7738 if (!this.hasListener('actionfailed')) {
7739 Roo.log("need to add dialog support");
7741 Roo.MessageBox.alert("Error",
7742 (typeof(action.result) != 'undefined' && typeof(action.result.errorMsg) != 'undefined') ?
7743 action.result.errorMsg :
7744 "Saving Failed, please check your entries or try again"
7749 this.fireEvent('actionfailed', this, action);
7754 * Find a Roo.form.Field in this form by id, dataIndex, name or hiddenName
7755 * @param {String} id The value to search for
7758 findField : function(id){
7759 var items = this.getItems();
7760 var field = items.get(id);
7762 items.each(function(f){
7763 if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
7770 return field || null;
7773 * Mark fields in this form invalid in bulk.
7774 * @param {Array/Object} errors Either an array in the form [{id:'fieldId', msg:'The message'},...] or an object hash of {id: msg, id2: msg2}
7775 * @return {BasicForm} this
7777 markInvalid : function(errors){
7778 if(errors instanceof Array){
7779 for(var i = 0, len = errors.length; i < len; i++){
7780 var fieldError = errors[i];
7781 var f = this.findField(fieldError.id);
7783 f.markInvalid(fieldError.msg);
7789 if(typeof errors[id] != 'function' && (field = this.findField(id))){
7790 field.markInvalid(errors[id]);
7794 //Roo.each(this.childForms || [], function (f) {
7795 // f.markInvalid(errors);
7802 * Set values for fields in this form in bulk.
7803 * @param {Array/Object} values Either an array in the form [{id:'fieldId', value:'foo'},...] or an object hash of {id: value, id2: value2}
7804 * @return {BasicForm} this
7806 setValues : function(values){
7807 if(values instanceof Array){ // array of objects
7808 for(var i = 0, len = values.length; i < len; i++){
7810 var f = this.findField(v.id);
7812 f.setValue(v.value);
7813 if(this.trackResetOnLoad){
7814 f.originalValue = f.getValue();
7818 }else{ // object hash
7821 if(typeof values[id] != 'function' && (field = this.findField(id))){
7823 if (field.setFromData &&
7825 field.displayField &&
7826 // combos' with local stores can
7827 // be queried via setValue()
7828 // to set their value..
7829 (field.store && !field.store.isLocal)
7833 sd[field.valueField] = typeof(values[field.hiddenName]) == 'undefined' ? '' : values[field.hiddenName];
7834 sd[field.displayField] = typeof(values[field.name]) == 'undefined' ? '' : values[field.name];
7835 field.setFromData(sd);
7838 field.setValue(values[id]);
7842 if(this.trackResetOnLoad){
7843 field.originalValue = field.getValue();
7849 //Roo.each(this.childForms || [], function (f) {
7850 // f.setValues(values);
7857 * Returns the fields in this form as an object with key/value pairs. If multiple fields exist with the same name
7858 * they are returned as an array.
7859 * @param {Boolean} asString
7862 getValues : function(asString){
7863 //if (this.childForms) {
7864 // copy values from the child forms
7865 // Roo.each(this.childForms, function (f) {
7866 // this.setValues(f.getValues());
7872 var fs = Roo.lib.Ajax.serializeForm(this.el.dom);
7873 if(asString === true){
7876 return Roo.urlDecode(fs);
7880 * Returns the fields in this form as an object with key/value pairs.
7881 * This differs from getValues as it calls getValue on each child item, rather than using dom data.
7884 getFieldValues : function(with_hidden)
7886 var items = this.getItems();
7888 items.each(function(f){
7892 var v = f.getValue();
7893 if (f.inputType =='radio') {
7894 if (typeof(ret[f.getName()]) == 'undefined') {
7895 ret[f.getName()] = ''; // empty..
7898 if (!f.el.dom.checked) {
7906 // not sure if this supported any more..
7907 if ((typeof(v) == 'object') && f.getRawValue) {
7908 v = f.getRawValue() ; // dates..
7910 // combo boxes where name != hiddenName...
7911 if (f.name !== false && f.name != '' && f.name != f.getName()) {
7912 ret[f.name] = f.getRawValue();
7914 ret[f.getName()] = v;
7921 * Clears all invalid messages in this form.
7922 * @return {BasicForm} this
7924 clearInvalid : function(){
7925 var items = this.getItems();
7927 items.each(function(f){
7938 * @return {BasicForm} this
7941 var items = this.getItems();
7942 items.each(function(f){
7946 Roo.each(this.childForms || [], function (f) {
7953 getItems : function()
7955 var r=new Roo.util.MixedCollection(false, function(o){
7956 return o.id || (o.id = Roo.id());
7958 var iter = function(el) {
7965 Roo.each(el.items,function(e) {
7982 Roo.apply(Roo.bootstrap.Form, {
8009 top : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-top-mask" }, true),
8010 left : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-left-mask" }, true),
8011 bottom : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-bottom-mask" }, true),
8012 right : Roo.DomHelper.append(Roo.get(document.body), { tag: "div", cls:"x-dlg-mask roo-form-right-mask" }, true)
8015 this.maskEl.top.enableDisplayMode("block");
8016 this.maskEl.left.enableDisplayMode("block");
8017 this.maskEl.bottom.enableDisplayMode("block");
8018 this.maskEl.right.enableDisplayMode("block");
8020 this.toolTip = new Roo.bootstrap.Tooltip({
8021 cls : 'roo-form-error-popover',
8023 'left' : ['r-l', [-2,0], 'right'],
8024 'right' : ['l-r', [2,0], 'left'],
8025 'bottom' : ['tl-bl', [0,2], 'top'],
8026 'top' : [ 'bl-tl', [0,-2], 'bottom']
8030 this.toolTip.render(Roo.get(document.body));
8032 this.toolTip.el.enableDisplayMode("block");
8034 Roo.get(document.body).on('click', function(){
8038 this.isApplied = true
8041 mask : function(form, target)
8045 this.target = target;
8047 if(!this.form.errorMask || !target.el){
8051 var scrollable = this.target.el.findScrollableParent() || this.target.el.findParent('div.modal', 100, true) || Roo.get(document.body);
8053 var scrolled = scrollable.getScroll();
8055 var ot = this.target.el.calcOffsetsTo(scrollable);
8057 scrollTo = ot[1] - 100;
8059 scrollable.scrollTo('top', scrollTo);
8061 var box = this.target.el.getBox();
8063 var zIndex = Roo.bootstrap.Modal.zIndex++;
8065 this.maskEl.top.setStyle('position', 'fixed');
8066 this.maskEl.top.setStyle('z-index', zIndex);
8067 this.maskEl.top.setSize(Roo.lib.Dom.getDocumentWidth(), box.y - this.padding);
8068 this.maskEl.top.setXY([0, 0]);
8069 this.maskEl.top.show();
8071 this.maskEl.left.setStyle('position', 'fixed');
8072 this.maskEl.left.setStyle('z-index', zIndex);
8073 this.maskEl.left.setSize(Roo.lib.Dom.getDocumentWidth() - box.right - this.padding, box.height + this.padding * 2);
8074 this.maskEl.left.setXY([box.right + this.padding, box.y - this.padding]);
8075 this.maskEl.left.show();
8077 this.maskEl.bottom.setStyle('position', 'fixed');
8078 this.maskEl.bottom.setStyle('z-index', zIndex);
8079 this.maskEl.bottom.setSize(Roo.lib.Dom.getDocumentWidth(), Roo.lib.Dom.getDocumentHeight() - box.bottom - this.padding);
8080 this.maskEl.bottom.setXY([0, box.bottom + this.padding]);
8081 this.maskEl.bottom.show();
8083 this.maskEl.right.setStyle('position', 'fixed');
8084 this.maskEl.right.setStyle('z-index', zIndex);
8085 this.maskEl.right.setSize(box.x - this.padding, box.height + this.padding * 2);
8086 this.maskEl.right.setXY([0, box.y - this.padding]);
8087 this.maskEl.right.show();
8090 this.toolTip.bindEl = this.target.el;
8092 this.toolTip.el.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
8094 var tip = this.target.blankText;
8096 if(this.target.getValue() !== '' && this.target.regexText.length){
8097 tip = this.target.regexText;
8100 this.toolTip.show(tip);
8102 this.intervalID = window.setInterval(function() {
8103 Roo.bootstrap.Form.popover.unmask();
8106 window.onwheel = function(){ return false;};
8108 (function(){ this.isMasked = true; }).defer(500, this);
8116 if(!this.isApplied || !this.isMasked || !this.form || !this.target || !this.form.errorMask){
8120 this.maskEl.top.setStyle('position', 'absolute');
8121 this.maskEl.top.setSize(0, 0).setXY([0, 0]);
8122 this.maskEl.top.hide();
8124 this.maskEl.left.setStyle('position', 'absolute');
8125 this.maskEl.left.setSize(0, 0).setXY([0, 0]);
8126 this.maskEl.left.hide();
8128 this.maskEl.bottom.setStyle('position', 'absolute');
8129 this.maskEl.bottom.setSize(0, 0).setXY([0, 0]);
8130 this.maskEl.bottom.hide();
8132 this.maskEl.right.setStyle('position', 'absolute');
8133 this.maskEl.right.setSize(0, 0).setXY([0, 0]);
8134 this.maskEl.right.hide();
8136 this.toolTip.hide();
8138 this.toolTip.el.hide();
8140 window.onwheel = function(){ return true;};
8142 if(this.intervalID){
8143 window.clearInterval(this.intervalID);
8144 this.intervalID = false;
8147 this.isMasked = false;
8157 * Ext JS Library 1.1.1
8158 * Copyright(c) 2006-2007, Ext JS, LLC.
8160 * Originally Released Under LGPL - original licence link has changed is not relivant.
8163 * <script type="text/javascript">
8166 * @class Roo.form.VTypes
8167 * Overridable validation definitions. The validations provided are basic and intended to be easily customizable and extended.
8170 Roo.form.VTypes = function(){
8171 // closure these in so they are only created once.
8172 var alpha = /^[a-zA-Z_]+$/;
8173 var alphanum = /^[a-zA-Z0-9_]+$/;
8174 var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,24}$/;
8175 var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
8177 // All these messages and functions are configurable
8180 * The function used to validate email addresses
8181 * @param {String} value The email address
8183 'email' : function(v){
8184 return email.test(v);
8187 * The error text to display when the email validation function returns false
8190 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
8192 * The keystroke filter mask to be applied on email input
8195 'emailMask' : /[a-z0-9_\.\-@]/i,
8198 * The function used to validate URLs
8199 * @param {String} value The URL
8201 'url' : function(v){
8205 * The error text to display when the url validation function returns false
8208 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
8211 * The function used to validate alpha values
8212 * @param {String} value The value
8214 'alpha' : function(v){
8215 return alpha.test(v);
8218 * The error text to display when the alpha validation function returns false
8221 'alphaText' : 'This field should only contain letters and _',
8223 * The keystroke filter mask to be applied on alpha input
8226 'alphaMask' : /[a-z_]/i,
8229 * The function used to validate alphanumeric values
8230 * @param {String} value The value
8232 'alphanum' : function(v){
8233 return alphanum.test(v);
8236 * The error text to display when the alphanumeric validation function returns false
8239 'alphanumText' : 'This field should only contain letters, numbers and _',
8241 * The keystroke filter mask to be applied on alphanumeric input
8244 'alphanumMask' : /[a-z0-9_]/i
8254 * @class Roo.bootstrap.Input
8255 * @extends Roo.bootstrap.Component
8256 * Bootstrap Input class
8257 * @cfg {Boolean} disabled is it disabled
8258 * @cfg {String} inputType button | checkbox | email | file | hidden | image | number | password | radio | range | reset | search | submit | text
8259 * @cfg {String} name name of the input
8260 * @cfg {string} fieldLabel - the label associated
8261 * @cfg {string} placeholder - placeholder to put in text.
8262 * @cfg {string} before - input group add on before
8263 * @cfg {string} after - input group add on after
8264 * @cfg {string} size - (lg|sm) or leave empty..
8265 * @cfg {Number} xs colspan out of 12 for mobile-sized screens
8266 * @cfg {Number} sm colspan out of 12 for tablet-sized screens
8267 * @cfg {Number} md colspan out of 12 for computer-sized screens
8268 * @cfg {Number} lg colspan out of 12 for large computer-sized screens
8269 * @cfg {string} value default value of the input
8270 * @cfg {Number} labelWidth set the width of label
8271 * @cfg {Number} labellg set the width of label (1-12)
8272 * @cfg {Number} labelmd set the width of label (1-12)
8273 * @cfg {Number} labelsm set the width of label (1-12)
8274 * @cfg {Number} labelxs set the width of label (1-12)
8275 * @cfg {String} labelAlign (top|left)
8276 * @cfg {Boolean} readOnly Specifies that the field should be read-only
8277 * @cfg {String} autocomplete - default is new-password see: https://developers.google.com/web/fundamentals/input/form/label-and-name-inputs?hl=en
8278 * @cfg {String} indicatorpos (left|right) default left
8280 * @cfg {String} align (left|center|right) Default left
8281 * @cfg {Boolean} forceFeedback (true|false) Default false
8287 * Create a new Input
8288 * @param {Object} config The config object
8291 Roo.bootstrap.Input = function(config){
8293 Roo.bootstrap.Input.superclass.constructor.call(this, config);
8298 * Fires when this field receives input focus.
8299 * @param {Roo.form.Field} this
8304 * Fires when this field loses input focus.
8305 * @param {Roo.form.Field} this
8310 * Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed. You can check
8311 * {@link Roo.EventObject#getKey} to determine which key was pressed.
8312 * @param {Roo.form.Field} this
8313 * @param {Roo.EventObject} e The event object
8318 * Fires just before the field blurs if the field value has changed.
8319 * @param {Roo.form.Field} this
8320 * @param {Mixed} newValue The new value
8321 * @param {Mixed} oldValue The original value
8326 * Fires after the field has been marked as invalid.
8327 * @param {Roo.form.Field} this
8328 * @param {String} msg The validation message
8333 * Fires after the field has been validated with no errors.
8334 * @param {Roo.form.Field} this
8339 * Fires after the key up
8340 * @param {Roo.form.Field} this
8341 * @param {Roo.EventObject} e The event Object
8347 Roo.extend(Roo.bootstrap.Input, Roo.bootstrap.Component, {
8349 * @cfg {String/Boolean} validationEvent The event that should initiate field validation. Set to false to disable
8350 automatic validation (defaults to "keyup").
8352 validationEvent : "keyup",
8354 * @cfg {Boolean} validateOnBlur Whether the field should validate when it loses focus (defaults to true).
8356 validateOnBlur : true,
8358 * @cfg {Number} validationDelay The length of time in milliseconds after user input begins until validation is initiated (defaults to 250)
8360 validationDelay : 250,
8362 * @cfg {String} focusClass The CSS class to use when the field receives focus (defaults to "x-form-focus")
8364 focusClass : "x-form-focus", // not needed???
8368 * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")
8370 invalidClass : "has-warning",
8373 * @cfg {String} validClass The CSS class to use when marking a field valid (defaults to "x-form-invalid")
8375 validClass : "has-success",
8378 * @cfg {Boolean} hasFeedback (true|false) default true
8383 * @cfg {String} invalidFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
8385 invalidFeedbackClass : "glyphicon-warning-sign",
8388 * @cfg {String} validFeedbackIcon The CSS class to use when create feedback icon (defaults to "x-form-invalid")
8390 validFeedbackClass : "glyphicon-ok",
8393 * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false)
8395 selectOnFocus : false,
8398 * @cfg {String} maskRe An input mask regular expression that will be used to filter keystrokes that don't match (defaults to null)
8402 * @cfg {String} vtype A validation type name as defined in {@link Roo.form.VTypes} (defaults to null)
8407 * @cfg {Boolean} disableKeyFilter True to disable input keystroke filtering (defaults to false)
8409 disableKeyFilter : false,
8412 * @cfg {Boolean} disabled True to disable the field (defaults to false).
8416 * @cfg {Boolean} allowBlank False to validate that the value length > 0 (defaults to true)
8420 * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required")
8422 blankText : "Please complete this mandatory field",
8425 * @cfg {Number} minLength Minimum input field length required (defaults to 0)
8429 * @cfg {Number} maxLength Maximum input field length allowed (defaults to Number.MAX_VALUE)
8431 maxLength : Number.MAX_VALUE,
8433 * @cfg {String} minLengthText Error text to display if the minimum length validation fails (defaults to "The minimum length for this field is {minLength}")
8435 minLengthText : "The minimum length for this field is {0}",
8437 * @cfg {String} maxLengthText Error text to display if the maximum length validation fails (defaults to "The maximum length for this field is {maxLength}")
8439 maxLengthText : "The maximum length for this field is {0}",
8443 * @cfg {Function} validator A custom validation function to be called during field validation (defaults to null).
8444 * If available, this function will be called only after the basic validators all return true, and will be passed the
8445 * current field value and expected to return boolean true if the value is valid or a string error message if invalid.
8449 * @cfg {RegExp} regex A JavaScript RegExp object to be tested against the field value during validation (defaults to null).
8450 * If available, this regex will be evaluated only after the basic validators all return true, and will be passed the
8451 * current field value. If the test fails, the field will be marked invalid using {@link #regexText}.
8455 * @cfg {String} regexText The error text to display if {@link #regex} is used and the test fails during validation (defaults to "")
8459 autocomplete: false,
8478 formatedValue : false,
8479 forceFeedback : false,
8481 indicatorpos : 'left',
8488 parentLabelAlign : function()
8491 while (parent.parent()) {
8492 parent = parent.parent();
8493 if (typeof(parent.labelAlign) !='undefined') {
8494 return parent.labelAlign;
8501 getAutoCreate : function()
8503 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
8509 if(this.inputType != 'hidden'){
8510 cfg.cls = 'form-group' //input-group
8516 type : this.inputType,
8518 cls : 'form-control',
8519 placeholder : this.placeholder || '',
8520 autocomplete : this.autocomplete || 'new-password'
8524 input.style = (typeof(input.style) == 'undefined') ? ('text-align:' + this.align) : (input.style + 'text-align:' + this.align);
8527 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
8528 input.maxLength = this.maxLength;
8531 if (this.disabled) {
8532 input.disabled=true;
8535 if (this.readOnly) {
8536 input.readonly=true;
8540 input.name = this.name;
8544 input.cls += ' input-' + this.size;
8548 ['xs','sm','md','lg'].map(function(size){
8549 if (settings[size]) {
8550 cfg.cls += ' col-' + size + '-' + settings[size];
8554 var inputblock = input;
8558 cls: 'glyphicon form-control-feedback'
8561 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
8564 cls : 'has-feedback',
8572 if (this.before || this.after) {
8575 cls : 'input-group',
8579 if (this.before && typeof(this.before) == 'string') {
8581 inputblock.cn.push({
8583 cls : 'roo-input-before input-group-addon',
8587 if (this.before && typeof(this.before) == 'object') {
8588 this.before = Roo.factory(this.before);
8590 inputblock.cn.push({
8592 cls : 'roo-input-before input-group-' +
8593 (this.before.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
8597 inputblock.cn.push(input);
8599 if (this.after && typeof(this.after) == 'string') {
8600 inputblock.cn.push({
8602 cls : 'roo-input-after input-group-addon',
8606 if (this.after && typeof(this.after) == 'object') {
8607 this.after = Roo.factory(this.after);
8609 inputblock.cn.push({
8611 cls : 'roo-input-after input-group-' +
8612 (this.after.xtype == 'Button' ? 'btn' : 'addon') //?? what about checkboxes - that looks like a bit of a hack thought?
8616 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
8617 inputblock.cls += ' has-feedback';
8618 inputblock.cn.push(feedback);
8622 if (align ==='left' && this.fieldLabel.length) {
8624 cfg.cls += ' roo-form-group-label-left';
8629 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
8630 tooltip : 'This field is required'
8635 cls : 'control-label',
8636 html : this.fieldLabel
8647 var labelCfg = cfg.cn[1];
8648 var contentCfg = cfg.cn[2];
8650 if(this.indicatorpos == 'right'){
8655 cls : 'control-label',
8656 html : this.fieldLabel
8661 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
8662 tooltip : 'This field is required'
8673 labelCfg = cfg.cn[0];
8674 contentCfg = cfg.cn[2];
8678 if(this.labelWidth > 12){
8679 labelCfg.style = "width: " + this.labelWidth + 'px';
8682 if(this.labelWidth < 13 && this.labelmd == 0){
8683 this.labelmd = this.labelWidth;
8686 if(this.labellg > 0){
8687 labelCfg.cls += ' col-lg-' + this.labellg;
8688 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
8691 if(this.labelmd > 0){
8692 labelCfg.cls += ' col-md-' + this.labelmd;
8693 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
8696 if(this.labelsm > 0){
8697 labelCfg.cls += ' col-sm-' + this.labelsm;
8698 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
8701 if(this.labelxs > 0){
8702 labelCfg.cls += ' col-xs-' + this.labelxs;
8703 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
8707 } else if ( this.fieldLabel.length) {
8712 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
8713 tooltip : 'This field is required'
8717 //cls : 'input-group-addon',
8718 html : this.fieldLabel
8726 if(this.indicatorpos == 'right'){
8731 //cls : 'input-group-addon',
8732 html : this.fieldLabel
8737 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
8738 tooltip : 'This field is required'
8758 if (this.parentType === 'Navbar' && this.parent().bar) {
8759 cfg.cls += ' navbar-form';
8762 if (this.parentType === 'NavGroup') {
8763 cfg.cls += ' navbar-form';
8771 * return the real input element.
8773 inputEl: function ()
8775 return this.el.select('input.form-control',true).first();
8778 tooltipEl : function()
8780 return this.inputEl();
8783 indicatorEl : function()
8785 var indicator = this.el.select('i.roo-required-indicator',true).first();
8795 setDisabled : function(v)
8797 var i = this.inputEl().dom;
8799 i.removeAttribute('disabled');
8803 i.setAttribute('disabled','true');
8805 initEvents : function()
8808 this.inputEl().on("keydown" , this.fireKey, this);
8809 this.inputEl().on("focus", this.onFocus, this);
8810 this.inputEl().on("blur", this.onBlur, this);
8812 this.inputEl().relayEvent('keyup', this);
8814 this.indicator = this.indicatorEl();
8817 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
8818 this.indicator.hide();
8821 // reference to original value for reset
8822 this.originalValue = this.getValue();
8823 //Roo.form.TextField.superclass.initEvents.call(this);
8824 if(this.validationEvent == 'keyup'){
8825 this.validationTask = new Roo.util.DelayedTask(this.validate, this);
8826 this.inputEl().on('keyup', this.filterValidation, this);
8828 else if(this.validationEvent !== false){
8829 this.inputEl().on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
8832 if(this.selectOnFocus){
8833 this.on("focus", this.preFocus, this);
8836 if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){
8837 this.inputEl().on("keypress", this.filterKeys, this);
8839 this.inputEl().relayEvent('keypress', this);
8842 this.el.on("keyup", this.onKeyUp, this, {buffer:50});
8843 this.el.on("click", this.autoSize, this);
8846 if(this.inputEl().is('input[type=password]') && Roo.isSafari){
8847 this.inputEl().on('keydown', this.SafariOnKeyDown, this);
8850 if (typeof(this.before) == 'object') {
8851 this.before.render(this.el.select('.roo-input-before',true).first());
8853 if (typeof(this.after) == 'object') {
8854 this.after.render(this.el.select('.roo-input-after',true).first());
8859 filterValidation : function(e){
8860 if(!e.isNavKeyPress()){
8861 this.validationTask.delay(this.validationDelay);
8865 * Validates the field value
8866 * @return {Boolean} True if the value is valid, else false
8868 validate : function(){
8869 //if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
8870 if(this.disabled || this.validateValue(this.getRawValue())){
8881 * Validates a value according to the field's validation rules and marks the field as invalid
8882 * if the validation fails
8883 * @param {Mixed} value The value to validate
8884 * @return {Boolean} True if the value is valid, else false
8886 validateValue : function(value){
8887 if(value.length < 1) { // if it's blank
8888 if(this.allowBlank){
8894 if(value.length < this.minLength){
8897 if(value.length > this.maxLength){
8901 var vt = Roo.form.VTypes;
8902 if(!vt[this.vtype](value, this)){
8906 if(typeof this.validator == "function"){
8907 var msg = this.validator(value);
8913 if(this.regex && !this.regex.test(value)){
8923 fireKey : function(e){
8924 //Roo.log('field ' + e.getKey());
8925 if(e.isNavKeyPress()){
8926 this.fireEvent("specialkey", this, e);
8929 focus : function (selectText){
8931 this.inputEl().focus();
8932 if(selectText === true){
8933 this.inputEl().dom.select();
8939 onFocus : function(){
8940 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
8941 // this.el.addClass(this.focusClass);
8944 this.hasFocus = true;
8945 this.startValue = this.getValue();
8946 this.fireEvent("focus", this);
8950 beforeBlur : Roo.emptyFn,
8954 onBlur : function(){
8956 if(!Roo.isOpera && this.focusClass){ // don't touch in Opera
8957 //this.el.removeClass(this.focusClass);
8959 this.hasFocus = false;
8960 if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
8963 var v = this.getValue();
8964 if(String(v) !== String(this.startValue)){
8965 this.fireEvent('change', this, v, this.startValue);
8967 this.fireEvent("blur", this);
8971 * Resets the current field value to the originally loaded value and clears any validation messages
8974 this.setValue(this.originalValue);
8978 * Returns the name of the field
8979 * @return {Mixed} name The name field
8981 getName: function(){
8985 * Returns the normalized data value (undefined or emptyText will be returned as ''). To return the raw value see {@link #getRawValue}.
8986 * @return {Mixed} value The field value
8988 getValue : function(){
8990 var v = this.inputEl().getValue();
8995 * Returns the raw data value which may or may not be a valid, defined value. To return a normalized value see {@link #getValue}.
8996 * @return {Mixed} value The field value
8998 getRawValue : function(){
8999 var v = this.inputEl().getValue();
9005 * Sets the underlying DOM field's value directly, bypassing validation. To set the value with validation see {@link #setValue}.
9006 * @param {Mixed} value The value to set
9008 setRawValue : function(v){
9009 return this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9012 selectText : function(start, end){
9013 var v = this.getRawValue();
9015 start = start === undefined ? 0 : start;
9016 end = end === undefined ? v.length : end;
9017 var d = this.inputEl().dom;
9018 if(d.setSelectionRange){
9019 d.setSelectionRange(start, end);
9020 }else if(d.createTextRange){
9021 var range = d.createTextRange();
9022 range.moveStart("character", start);
9023 range.moveEnd("character", v.length-end);
9030 * Sets a data value into the field and validates it. To set the value directly without validation see {@link #setRawValue}.
9031 * @param {Mixed} value The value to set
9033 setValue : function(v){
9036 this.inputEl().dom.value = (v === null || v === undefined ? '' : v);
9042 processValue : function(value){
9043 if(this.stripCharsRe){
9044 var newValue = value.replace(this.stripCharsRe, '');
9045 if(newValue !== value){
9046 this.setRawValue(newValue);
9053 preFocus : function(){
9055 if(this.selectOnFocus){
9056 this.inputEl().dom.select();
9059 filterKeys : function(e){
9061 if(!Roo.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
9064 var c = e.getCharCode(), cc = String.fromCharCode(c);
9065 if(Roo.isIE && (e.isSpecialKey() || !cc)){
9068 if(!this.maskRe.test(cc)){
9073 * Clear any invalid styles/messages for this field
9075 clearInvalid : function(){
9077 if(!this.el || this.preventMark){ // not rendered
9082 this.indicator.hide();
9085 this.el.removeClass(this.invalidClass);
9087 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9089 var feedback = this.el.select('.form-control-feedback', true).first();
9092 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9097 this.fireEvent('valid', this);
9101 * Mark this field as valid
9103 markValid : function()
9105 if(!this.el || this.preventMark){ // not rendered...
9109 this.el.removeClass([this.invalidClass, this.validClass]);
9111 var feedback = this.el.select('.form-control-feedback', true).first();
9114 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9121 if(this.allowBlank && !this.getRawValue().length){
9126 this.indicator.hide();
9129 this.el.addClass(this.validClass);
9131 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9133 var feedback = this.el.select('.form-control-feedback', true).first();
9136 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9137 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9142 this.fireEvent('valid', this);
9146 * Mark this field as invalid
9147 * @param {String} msg The validation message
9149 markInvalid : function(msg)
9151 if(!this.el || this.preventMark){ // not rendered
9155 this.el.removeClass([this.invalidClass, this.validClass]);
9157 var feedback = this.el.select('.form-control-feedback', true).first();
9160 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9167 if(this.allowBlank && !this.getRawValue().length){
9172 this.indicator.show();
9175 this.el.addClass(this.invalidClass);
9177 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9179 var feedback = this.el.select('.form-control-feedback', true).first();
9182 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9184 if(this.getValue().length || this.forceFeedback){
9185 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9192 this.fireEvent('invalid', this, msg);
9195 SafariOnKeyDown : function(event)
9197 // this is a workaround for a password hang bug on chrome/ webkit.
9198 if (this.inputEl().dom.type != 'password') {
9202 var isSelectAll = false;
9204 if(this.inputEl().dom.selectionEnd > 0){
9205 isSelectAll = (this.inputEl().dom.selectionEnd - this.inputEl().dom.selectionStart - this.getValue().length == 0) ? true : false;
9207 if(((event.getKey() == 8 || event.getKey() == 46) && this.getValue().length ==1)){ // backspace and delete key
9208 event.preventDefault();
9213 if(isSelectAll && event.getCharCode() > 31 && !event.ctrlKey) { // not backspace and delete key (or ctrl-v)
9215 event.preventDefault();
9216 // this is very hacky as keydown always get's upper case.
9218 var cc = String.fromCharCode(event.getCharCode());
9219 this.setValue( event.shiftKey ? cc : cc.toLowerCase());
9223 adjustWidth : function(tag, w){
9224 tag = tag.toLowerCase();
9225 if(typeof w == 'number' && Roo.isStrict && !Roo.isSafari){
9226 if(Roo.isIE && (tag == 'input' || tag == 'textarea')){
9230 if(tag == 'textarea'){
9233 }else if(Roo.isOpera){
9237 if(tag == 'textarea'){
9256 * @class Roo.bootstrap.TextArea
9257 * @extends Roo.bootstrap.Input
9258 * Bootstrap TextArea class
9259 * @cfg {Number} cols Specifies the visible width of a text area
9260 * @cfg {Number} rows Specifies the visible number of lines in a text area
9261 * @cfg {string} wrap (soft|hard)Specifies how the text in a text area is to be wrapped when submitted in a form
9262 * @cfg {string} resize (none|both|horizontal|vertical|inherit|initial)
9263 * @cfg {string} html text
9266 * Create a new TextArea
9267 * @param {Object} config The config object
9270 Roo.bootstrap.TextArea = function(config){
9271 Roo.bootstrap.TextArea.superclass.constructor.call(this, config);
9275 Roo.extend(Roo.bootstrap.TextArea, Roo.bootstrap.Input, {
9285 getAutoCreate : function(){
9287 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
9298 value : this.value || '',
9299 html: this.html || '',
9300 cls : 'form-control',
9301 placeholder : this.placeholder || ''
9305 if(this.maxLength && this.maxLength != Number.MAX_VALUE){
9306 input.maxLength = this.maxLength;
9310 input.style = (typeof(input.style) == 'undefined') ? 'resize:' + this.resize : input.style + 'resize:' + this.resize;
9314 input.cols = this.cols;
9317 if (this.readOnly) {
9318 input.readonly = true;
9322 input.name = this.name;
9326 input.cls = (typeof(input.cls) == 'undefined') ? 'input-' + this.size : input.cls + ' input-' + this.size;
9330 ['xs','sm','md','lg'].map(function(size){
9331 if (settings[size]) {
9332 cfg.cls += ' col-' + size + '-' + settings[size];
9336 var inputblock = input;
9338 if(this.hasFeedback && !this.allowBlank){
9342 cls: 'glyphicon form-control-feedback'
9346 cls : 'has-feedback',
9355 if (this.before || this.after) {
9358 cls : 'input-group',
9362 inputblock.cn.push({
9364 cls : 'input-group-addon',
9369 inputblock.cn.push(input);
9371 if(this.hasFeedback && !this.allowBlank){
9372 inputblock.cls += ' has-feedback';
9373 inputblock.cn.push(feedback);
9377 inputblock.cn.push({
9379 cls : 'input-group-addon',
9386 if (align ==='left' && this.fieldLabel.length) {
9391 cls : 'control-label',
9392 html : this.fieldLabel
9403 if(this.labelWidth > 12){
9404 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
9407 if(this.labelWidth < 13 && this.labelmd == 0){
9408 this.labelmd = this.labelWidth;
9411 if(this.labellg > 0){
9412 cfg.cn[0].cls += ' col-lg-' + this.labellg;
9413 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
9416 if(this.labelmd > 0){
9417 cfg.cn[0].cls += ' col-md-' + this.labelmd;
9418 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
9421 if(this.labelsm > 0){
9422 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
9423 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
9426 if(this.labelxs > 0){
9427 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
9428 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
9431 } else if ( this.fieldLabel.length) {
9436 //cls : 'input-group-addon',
9437 html : this.fieldLabel
9455 if (this.disabled) {
9456 input.disabled=true;
9463 * return the real textarea element.
9465 inputEl: function ()
9467 return this.el.select('textarea.form-control',true).first();
9471 * Clear any invalid styles/messages for this field
9473 clearInvalid : function()
9476 if(!this.el || this.preventMark){ // not rendered
9480 var label = this.el.select('label', true).first();
9481 var icon = this.el.select('i.fa-star', true).first();
9487 this.el.removeClass(this.invalidClass);
9489 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9491 var feedback = this.el.select('.form-control-feedback', true).first();
9494 this.el.select('.form-control-feedback', true).first().removeClass(this.invalidFeedbackClass);
9499 this.fireEvent('valid', this);
9503 * Mark this field as valid
9505 markValid : function()
9507 if(!this.el || this.preventMark){ // not rendered
9511 this.el.removeClass([this.invalidClass, this.validClass]);
9513 var feedback = this.el.select('.form-control-feedback', true).first();
9516 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9519 if(this.disabled || this.allowBlank){
9523 var label = this.el.select('label', true).first();
9524 var icon = this.el.select('i.fa-star', true).first();
9530 this.el.addClass(this.validClass);
9532 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank && (this.getValue().length || this.forceFeedback)){
9534 var feedback = this.el.select('.form-control-feedback', true).first();
9537 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9538 this.el.select('.form-control-feedback', true).first().addClass([this.validFeedbackClass]);
9543 this.fireEvent('valid', this);
9547 * Mark this field as invalid
9548 * @param {String} msg The validation message
9550 markInvalid : function(msg)
9552 if(!this.el || this.preventMark){ // not rendered
9556 this.el.removeClass([this.invalidClass, this.validClass]);
9558 var feedback = this.el.select('.form-control-feedback', true).first();
9561 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9564 if(this.disabled || this.allowBlank){
9568 var label = this.el.select('label', true).first();
9569 var icon = this.el.select('i.fa-star', true).first();
9571 if(!this.getValue().length && label && !icon){
9572 this.el.createChild({
9574 cls : 'text-danger fa fa-lg fa-star',
9575 tooltip : 'This field is required',
9576 style : 'margin-right:5px;'
9580 this.el.addClass(this.invalidClass);
9582 if(this.hasFeedback && this.inputType != 'hidden' && !this.allowBlank){
9584 var feedback = this.el.select('.form-control-feedback', true).first();
9587 this.el.select('.form-control-feedback', true).first().removeClass([this.invalidFeedbackClass, this.validFeedbackClass]);
9589 if(this.getValue().length || this.forceFeedback){
9590 this.el.select('.form-control-feedback', true).first().addClass([this.invalidFeedbackClass]);
9597 this.fireEvent('invalid', this, msg);
9605 * trigger field - base class for combo..
9610 * @class Roo.bootstrap.TriggerField
9611 * @extends Roo.bootstrap.Input
9612 * Provides a convenient wrapper for TextFields that adds a clickable trigger button (looks like a combobox by default).
9613 * The trigger has no default action, so you must assign a function to implement the trigger click handler by
9614 * overriding {@link #onTriggerClick}. You can create a TriggerField directly, as it renders exactly like a combobox
9615 * for which you can provide a custom implementation. For example:
9617 var trigger = new Roo.bootstrap.TriggerField();
9618 trigger.onTriggerClick = myTriggerFn;
9619 trigger.applyTo('my-field');
9622 * However, in general you will most likely want to use TriggerField as the base class for a reusable component.
9623 * {@link Roo.bootstrap.DateField} and {@link Roo.bootstrap.ComboBox} are perfect examples of this.
9624 * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always get the
9625 * class 'x-form-trigger' by default and triggerClass will be <b>appended</b> if specified.
9626 * @cfg {String} caret (search|calendar) a fontawesome for the trigger icon see http://fortawesome.github.io/Font-Awesome/icons/
9629 * Create a new TriggerField.
9630 * @param {Object} config Configuration options (valid {@Roo.bootstrap.Input} config options will also be applied
9631 * to the base TextField)
9633 Roo.bootstrap.TriggerField = function(config){
9634 this.mimicing = false;
9635 Roo.bootstrap.TriggerField.superclass.constructor.call(this, config);
9638 Roo.extend(Roo.bootstrap.TriggerField, Roo.bootstrap.Input, {
9640 * @cfg {String} triggerClass A CSS class to apply to the trigger
9643 * @cfg {Boolean} hideTrigger True to hide the trigger element and display only the base text field (defaults to false)
9648 * @cfg {Boolean} removable (true|false) special filter default false
9652 /** @cfg {Boolean} grow @hide */
9653 /** @cfg {Number} growMin @hide */
9654 /** @cfg {Number} growMax @hide */
9660 autoSize: Roo.emptyFn,
9667 actionMode : 'wrap',
9672 getAutoCreate : function(){
9674 var align = this.labelAlign || this.parentLabelAlign();
9679 cls: 'form-group' //input-group
9686 type : this.inputType,
9687 cls : 'form-control',
9688 autocomplete: 'new-password',
9689 placeholder : this.placeholder || ''
9693 input.name = this.name;
9696 input.cls += ' input-' + this.size;
9699 if (this.disabled) {
9700 input.disabled=true;
9703 var inputblock = input;
9705 if(this.hasFeedback && !this.allowBlank){
9709 cls: 'glyphicon form-control-feedback'
9712 if(this.removable && !this.editable && !this.tickable){
9714 cls : 'has-feedback',
9720 cls : 'roo-combo-removable-btn close'
9727 cls : 'has-feedback',
9736 if(this.removable && !this.editable && !this.tickable){
9738 cls : 'roo-removable',
9744 cls : 'roo-combo-removable-btn close'
9751 if (this.before || this.after) {
9754 cls : 'input-group',
9758 inputblock.cn.push({
9760 cls : 'input-group-addon',
9765 inputblock.cn.push(input);
9767 if(this.hasFeedback && !this.allowBlank){
9768 inputblock.cls += ' has-feedback';
9769 inputblock.cn.push(feedback);
9773 inputblock.cn.push({
9775 cls : 'input-group-addon',
9788 cls: 'form-hidden-field'
9802 cls: 'form-hidden-field'
9806 cls: 'roo-select2-choices',
9810 cls: 'roo-select2-search-field',
9823 cls: 'roo-select2-container input-group',
9828 // cls: 'typeahead typeahead-long dropdown-menu',
9829 // style: 'display:none'
9834 if(!this.multiple && this.showToggleBtn){
9840 if (this.caret != false) {
9843 cls: 'fa fa-' + this.caret
9850 cls : 'input-group-addon btn dropdown-toggle',
9855 cls: 'combobox-clear',
9869 combobox.cls += ' roo-select2-container-multi';
9872 if (align ==='left' && this.fieldLabel.length) {
9874 cfg.cls += ' roo-form-group-label-left';
9879 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
9880 tooltip : 'This field is required'
9885 cls : 'control-label',
9886 html : this.fieldLabel
9898 var labelCfg = cfg.cn[1];
9899 var contentCfg = cfg.cn[2];
9901 if(this.indicatorpos == 'right'){
9906 cls : 'control-label',
9910 html : this.fieldLabel
9914 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
9915 tooltip : 'This field is required'
9928 labelCfg = cfg.cn[0];
9929 contentCfg = cfg.cn[1];
9932 if(this.labelWidth > 12){
9933 labelCfg.style = "width: " + this.labelWidth + 'px';
9936 if(this.labelWidth < 13 && this.labelmd == 0){
9937 this.labelmd = this.labelWidth;
9940 if(this.labellg > 0){
9941 labelCfg.cls += ' col-lg-' + this.labellg;
9942 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
9945 if(this.labelmd > 0){
9946 labelCfg.cls += ' col-md-' + this.labelmd;
9947 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
9950 if(this.labelsm > 0){
9951 labelCfg.cls += ' col-sm-' + this.labelsm;
9952 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
9955 if(this.labelxs > 0){
9956 labelCfg.cls += ' col-xs-' + this.labelxs;
9957 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
9960 } else if ( this.fieldLabel.length) {
9961 // Roo.log(" label");
9965 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
9966 tooltip : 'This field is required'
9970 //cls : 'input-group-addon',
9971 html : this.fieldLabel
9979 if(this.indicatorpos == 'right'){
9987 html : this.fieldLabel
9991 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
9992 tooltip : 'This field is required'
10005 // Roo.log(" no label && no align");
10012 ['xs','sm','md','lg'].map(function(size){
10013 if (settings[size]) {
10014 cfg.cls += ' col-' + size + '-' + settings[size];
10025 onResize : function(w, h){
10026 // Roo.bootstrap.TriggerField.superclass.onResize.apply(this, arguments);
10027 // if(typeof w == 'number'){
10028 // var x = w - this.trigger.getWidth();
10029 // this.inputEl().setWidth(this.adjustWidth('input', x));
10030 // this.trigger.setStyle('left', x+'px');
10035 adjustSize : Roo.BoxComponent.prototype.adjustSize,
10038 getResizeEl : function(){
10039 return this.inputEl();
10043 getPositionEl : function(){
10044 return this.inputEl();
10048 alignErrorIcon : function(){
10049 this.errorIcon.alignTo(this.inputEl(), 'tl-tr', [2, 0]);
10053 initEvents : function(){
10057 Roo.bootstrap.TriggerField.superclass.initEvents.call(this);
10058 //this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
10059 if(!this.multiple && this.showToggleBtn){
10060 this.trigger = this.el.select('span.dropdown-toggle',true).first();
10061 if(this.hideTrigger){
10062 this.trigger.setDisplayed(false);
10064 this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
10068 this.inputEl().on("click", this.onTriggerClick, this, {preventDefault:true});
10071 if(this.removable && !this.editable && !this.tickable){
10072 var close = this.closeTriggerEl();
10075 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
10076 close.on('click', this.removeBtnClick, this, close);
10080 //this.trigger.addClassOnOver('x-form-trigger-over');
10081 //this.trigger.addClassOnClick('x-form-trigger-click');
10084 // this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
10088 closeTriggerEl : function()
10090 var close = this.el.select('.roo-combo-removable-btn', true).first();
10091 return close ? close : false;
10094 removeBtnClick : function(e, h, el)
10096 e.preventDefault();
10098 if(this.fireEvent("remove", this) !== false){
10100 this.fireEvent("afterremove", this)
10104 createList : function()
10106 this.list = Roo.get(document.body).createChild({
10108 cls: 'typeahead typeahead-long dropdown-menu',
10109 style: 'display:none'
10112 this.list.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';;
10117 initTrigger : function(){
10122 onDestroy : function(){
10124 this.trigger.removeAllListeners();
10125 // this.trigger.remove();
10128 // this.wrap.remove();
10130 Roo.bootstrap.TriggerField.superclass.onDestroy.call(this);
10134 onFocus : function(){
10135 Roo.bootstrap.TriggerField.superclass.onFocus.call(this);
10137 if(!this.mimicing){
10138 this.wrap.addClass('x-trigger-wrap-focus');
10139 this.mimicing = true;
10140 Roo.get(Roo.isIE ? document.body : document).on("mousedown", this.mimicBlur, this);
10141 if(this.monitorTab){
10142 this.el.on("keydown", this.checkTab, this);
10149 checkTab : function(e){
10150 if(e.getKey() == e.TAB){
10151 this.triggerBlur();
10156 onBlur : function(){
10161 mimicBlur : function(e, t){
10163 if(!this.wrap.contains(t) && this.validateBlur()){
10164 this.triggerBlur();
10170 triggerBlur : function(){
10171 this.mimicing = false;
10172 Roo.get(Roo.isIE ? document.body : document).un("mousedown", this.mimicBlur);
10173 if(this.monitorTab){
10174 this.el.un("keydown", this.checkTab, this);
10176 //this.wrap.removeClass('x-trigger-wrap-focus');
10177 Roo.bootstrap.TriggerField.superclass.onBlur.call(this);
10181 // This should be overriden by any subclass that needs to check whether or not the field can be blurred.
10182 validateBlur : function(e, t){
10187 onDisable : function(){
10188 this.inputEl().dom.disabled = true;
10189 //Roo.bootstrap.TriggerField.superclass.onDisable.call(this);
10191 // this.wrap.addClass('x-item-disabled');
10196 onEnable : function(){
10197 this.inputEl().dom.disabled = false;
10198 //Roo.bootstrap.TriggerField.superclass.onEnable.call(this);
10200 // this.el.removeClass('x-item-disabled');
10205 onShow : function(){
10206 var ae = this.getActionEl();
10209 ae.dom.style.display = '';
10210 ae.dom.style.visibility = 'visible';
10216 onHide : function(){
10217 var ae = this.getActionEl();
10218 ae.dom.style.display = 'none';
10222 * The function that should handle the trigger's click event. This method does nothing by default until overridden
10223 * by an implementing function.
10225 * @param {EventObject} e
10227 onTriggerClick : Roo.emptyFn
10231 * Ext JS Library 1.1.1
10232 * Copyright(c) 2006-2007, Ext JS, LLC.
10234 * Originally Released Under LGPL - original licence link has changed is not relivant.
10237 * <script type="text/javascript">
10242 * @class Roo.data.SortTypes
10244 * Defines the default sorting (casting?) comparison functions used when sorting data.
10246 Roo.data.SortTypes = {
10248 * Default sort that does nothing
10249 * @param {Mixed} s The value being converted
10250 * @return {Mixed} The comparison value
10252 none : function(s){
10257 * The regular expression used to strip tags
10261 stripTagsRE : /<\/?[^>]+>/gi,
10264 * Strips all HTML tags to sort on text only
10265 * @param {Mixed} s The value being converted
10266 * @return {String} The comparison value
10268 asText : function(s){
10269 return String(s).replace(this.stripTagsRE, "");
10273 * Strips all HTML tags to sort on text only - Case insensitive
10274 * @param {Mixed} s The value being converted
10275 * @return {String} The comparison value
10277 asUCText : function(s){
10278 return String(s).toUpperCase().replace(this.stripTagsRE, "");
10282 * Case insensitive string
10283 * @param {Mixed} s The value being converted
10284 * @return {String} The comparison value
10286 asUCString : function(s) {
10287 return String(s).toUpperCase();
10292 * @param {Mixed} s The value being converted
10293 * @return {Number} The comparison value
10295 asDate : function(s) {
10299 if(s instanceof Date){
10300 return s.getTime();
10302 return Date.parse(String(s));
10307 * @param {Mixed} s The value being converted
10308 * @return {Float} The comparison value
10310 asFloat : function(s) {
10311 var val = parseFloat(String(s).replace(/,/g, ""));
10320 * @param {Mixed} s The value being converted
10321 * @return {Number} The comparison value
10323 asInt : function(s) {
10324 var val = parseInt(String(s).replace(/,/g, ""));
10332 * Ext JS Library 1.1.1
10333 * Copyright(c) 2006-2007, Ext JS, LLC.
10335 * Originally Released Under LGPL - original licence link has changed is not relivant.
10338 * <script type="text/javascript">
10342 * @class Roo.data.Record
10343 * Instances of this class encapsulate both record <em>definition</em> information, and record
10344 * <em>value</em> information for use in {@link Roo.data.Store} objects, or any code which needs
10345 * to access Records cached in an {@link Roo.data.Store} object.<br>
10347 * Constructors for this class are generated by passing an Array of field definition objects to {@link #create}.
10348 * Instances are usually only created by {@link Roo.data.Reader} implementations when processing unformatted data
10351 * Record objects generated by this constructor inherit all the methods of Roo.data.Record listed below.
10353 * This constructor should not be used to create Record objects. Instead, use the constructor generated by
10354 * {@link #create}. The parameters are the same.
10355 * @param {Array} data An associative Array of data values keyed by the field name.
10356 * @param {Object} id (Optional) The id of the record. This id should be unique, and is used by the
10357 * {@link Roo.data.Store} object which owns the Record to index its collection of Records. If
10358 * not specified an integer id is generated.
10360 Roo.data.Record = function(data, id){
10361 this.id = (id || id === 0) ? id : ++Roo.data.Record.AUTO_ID;
10366 * Generate a constructor for a specific record layout.
10367 * @param {Array} o An Array of field definition objects which specify field names, and optionally,
10368 * data types, and a mapping for an {@link Roo.data.Reader} to extract the field's value from a data object.
10369 * Each field definition object may contain the following properties: <ul>
10370 * <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,
10371 * for example the <em>dataIndex</em> property in column definition objects passed to {@link Roo.grid.ColumnModel}</p></li>
10372 * <li><b>mapping</b> : String<p style="margin-left:1em">(Optional) A path specification for use by the {@link Roo.data.Reader} implementation
10373 * that is creating the Record to access the data value from the data object. If an {@link Roo.data.JsonReader}
10374 * is being used, then this is a string containing the javascript expression to reference the data relative to
10375 * the record item's root. If an {@link Roo.data.XmlReader} is being used, this is an {@link Roo.DomQuery} path
10376 * to the data item relative to the record element. If the mapping expression is the same as the field name,
10377 * this may be omitted.</p></li>
10378 * <li><b>type</b> : String<p style="margin-left:1em">(Optional) The data type for conversion to displayable value. Possible values are
10379 * <ul><li>auto (Default, implies no conversion)</li>
10384 * <li>date</li></ul></p></li>
10385 * <li><b>sortType</b> : Mixed<p style="margin-left:1em">(Optional) A member of {@link Roo.data.SortTypes}.</p></li>
10386 * <li><b>sortDir</b> : String<p style="margin-left:1em">(Optional) Initial direction to sort. "ASC" or "DESC"</p></li>
10387 * <li><b>convert</b> : Function<p style="margin-left:1em">(Optional) A function which converts the value provided
10388 * by the Reader into an object that will be stored in the Record. It is passed the
10389 * following parameters:<ul>
10390 * <li><b>v</b> : Mixed<p style="margin-left:1em">The data value as read by the Reader.</p></li>
10392 * <li><b>dateFormat</b> : String<p style="margin-left:1em">(Optional) A format String for the Date.parseDate function.</p></li>
10394 * <br>usage:<br><pre><code>
10395 var TopicRecord = Roo.data.Record.create(
10396 {name: 'title', mapping: 'topic_title'},
10397 {name: 'author', mapping: 'username'},
10398 {name: 'totalPosts', mapping: 'topic_replies', type: 'int'},
10399 {name: 'lastPost', mapping: 'post_time', type: 'date'},
10400 {name: 'lastPoster', mapping: 'user2'},
10401 {name: 'excerpt', mapping: 'post_text'}
10404 var myNewRecord = new TopicRecord({
10405 title: 'Do my job please',
10408 lastPost: new Date(),
10409 lastPoster: 'Animal',
10410 excerpt: 'No way dude!'
10412 myStore.add(myNewRecord);
10417 Roo.data.Record.create = function(o){
10418 var f = function(){
10419 f.superclass.constructor.apply(this, arguments);
10421 Roo.extend(f, Roo.data.Record);
10422 var p = f.prototype;
10423 p.fields = new Roo.util.MixedCollection(false, function(field){
10426 for(var i = 0, len = o.length; i < len; i++){
10427 p.fields.add(new Roo.data.Field(o[i]));
10429 f.getField = function(name){
10430 return p.fields.get(name);
10435 Roo.data.Record.AUTO_ID = 1000;
10436 Roo.data.Record.EDIT = 'edit';
10437 Roo.data.Record.REJECT = 'reject';
10438 Roo.data.Record.COMMIT = 'commit';
10440 Roo.data.Record.prototype = {
10442 * Readonly flag - true if this record has been modified.
10451 join : function(store){
10452 this.store = store;
10456 * Set the named field to the specified value.
10457 * @param {String} name The name of the field to set.
10458 * @param {Object} value The value to set the field to.
10460 set : function(name, value){
10461 if(this.data[name] == value){
10465 if(!this.modified){
10466 this.modified = {};
10468 if(typeof this.modified[name] == 'undefined'){
10469 this.modified[name] = this.data[name];
10471 this.data[name] = value;
10472 if(!this.editing && this.store){
10473 this.store.afterEdit(this);
10478 * Get the value of the named field.
10479 * @param {String} name The name of the field to get the value of.
10480 * @return {Object} The value of the field.
10482 get : function(name){
10483 return this.data[name];
10487 beginEdit : function(){
10488 this.editing = true;
10489 this.modified = {};
10493 cancelEdit : function(){
10494 this.editing = false;
10495 delete this.modified;
10499 endEdit : function(){
10500 this.editing = false;
10501 if(this.dirty && this.store){
10502 this.store.afterEdit(this);
10507 * Usually called by the {@link Roo.data.Store} which owns the Record.
10508 * Rejects all changes made to the Record since either creation, or the last commit operation.
10509 * Modified fields are reverted to their original values.
10511 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
10512 * of reject operations.
10514 reject : function(){
10515 var m = this.modified;
10517 if(typeof m[n] != "function"){
10518 this.data[n] = m[n];
10521 this.dirty = false;
10522 delete this.modified;
10523 this.editing = false;
10525 this.store.afterReject(this);
10530 * Usually called by the {@link Roo.data.Store} which owns the Record.
10531 * Commits all changes made to the Record since either creation, or the last commit operation.
10533 * Developers should subscribe to the {@link Roo.data.Store#update} event to have their code notified
10534 * of commit operations.
10536 commit : function(){
10537 this.dirty = false;
10538 delete this.modified;
10539 this.editing = false;
10541 this.store.afterCommit(this);
10546 hasError : function(){
10547 return this.error != null;
10551 clearError : function(){
10556 * Creates a copy of this record.
10557 * @param {String} id (optional) A new record id if you don't want to use this record's id
10560 copy : function(newId) {
10561 return new this.constructor(Roo.apply({}, this.data), newId || this.id);
10565 * Ext JS Library 1.1.1
10566 * Copyright(c) 2006-2007, Ext JS, LLC.
10568 * Originally Released Under LGPL - original licence link has changed is not relivant.
10571 * <script type="text/javascript">
10577 * @class Roo.data.Store
10578 * @extends Roo.util.Observable
10579 * The Store class encapsulates a client side cache of {@link Roo.data.Record} objects which provide input data
10580 * for widgets such as the Roo.grid.Grid, or the Roo.form.ComboBox.<br>
10582 * 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
10583 * has no knowledge of the format of the data returned by the Proxy.<br>
10585 * A Store object uses its configured implementation of {@link Roo.data.DataReader} to create {@link Roo.data.Record}
10586 * instances from the data object. These records are cached and made available through accessor functions.
10588 * Creates a new Store.
10589 * @param {Object} config A config object containing the objects needed for the Store to access data,
10590 * and read the data into Records.
10592 Roo.data.Store = function(config){
10593 this.data = new Roo.util.MixedCollection(false);
10594 this.data.getKey = function(o){
10597 this.baseParams = {};
10599 this.paramNames = {
10604 "multisort" : "_multisort"
10607 if(config && config.data){
10608 this.inlineData = config.data;
10609 delete config.data;
10612 Roo.apply(this, config);
10614 if(this.reader){ // reader passed
10615 this.reader = Roo.factory(this.reader, Roo.data);
10616 this.reader.xmodule = this.xmodule || false;
10617 if(!this.recordType){
10618 this.recordType = this.reader.recordType;
10620 if(this.reader.onMetaChange){
10621 this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
10625 if(this.recordType){
10626 this.fields = this.recordType.prototype.fields;
10628 this.modified = [];
10632 * @event datachanged
10633 * Fires when the data cache has changed, and a widget which is using this Store
10634 * as a Record cache should refresh its view.
10635 * @param {Store} this
10637 datachanged : true,
10639 * @event metachange
10640 * Fires when this store's reader provides new metadata (fields). This is currently only support for JsonReaders.
10641 * @param {Store} this
10642 * @param {Object} meta The JSON metadata
10647 * Fires when Records have been added to the Store
10648 * @param {Store} this
10649 * @param {Roo.data.Record[]} records The array of Records added
10650 * @param {Number} index The index at which the record(s) were added
10655 * Fires when a Record has been removed from the Store
10656 * @param {Store} this
10657 * @param {Roo.data.Record} record The Record that was removed
10658 * @param {Number} index The index at which the record was removed
10663 * Fires when a Record has been updated
10664 * @param {Store} this
10665 * @param {Roo.data.Record} record The Record that was updated
10666 * @param {String} operation The update operation being performed. Value may be one of:
10668 Roo.data.Record.EDIT
10669 Roo.data.Record.REJECT
10670 Roo.data.Record.COMMIT
10676 * Fires when the data cache has been cleared.
10677 * @param {Store} this
10681 * @event beforeload
10682 * Fires before a request is made for a new data object. If the beforeload handler returns false
10683 * the load action will be canceled.
10684 * @param {Store} this
10685 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10689 * @event beforeloadadd
10690 * Fires after a new set of Records has been loaded.
10691 * @param {Store} this
10692 * @param {Roo.data.Record[]} records The Records that were loaded
10693 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10695 beforeloadadd : true,
10698 * Fires after a new set of Records has been loaded, before they are added to the store.
10699 * @param {Store} this
10700 * @param {Roo.data.Record[]} records The Records that were loaded
10701 * @param {Object} options The loading options that were specified (see {@link #load} for details)
10702 * @params {Object} return from reader
10706 * @event loadexception
10707 * Fires if an exception occurs in the Proxy during loading.
10708 * Called with the signature of the Proxy's "loadexception" event.
10709 * If you return Json { data: [] , success: false, .... } then this will be thrown with the following args
10712 * @param {Object} return from JsonData.reader() - success, totalRecords, records
10713 * @param {Object} load options
10714 * @param {Object} jsonData from your request (normally this contains the Exception)
10716 loadexception : true
10720 this.proxy = Roo.factory(this.proxy, Roo.data);
10721 this.proxy.xmodule = this.xmodule || false;
10722 this.relayEvents(this.proxy, ["loadexception"]);
10724 this.sortToggle = {};
10725 this.sortOrder = []; // array of order of sorting - updated by grid if multisort is enabled.
10727 Roo.data.Store.superclass.constructor.call(this);
10729 if(this.inlineData){
10730 this.loadData(this.inlineData);
10731 delete this.inlineData;
10735 Roo.extend(Roo.data.Store, Roo.util.Observable, {
10737 * @cfg {boolean} isLocal flag if data is locally available (and can be always looked up
10738 * without a remote query - used by combo/forms at present.
10742 * @cfg {Roo.data.DataProxy} proxy The Proxy object which provides access to a data object.
10745 * @cfg {Array} data Inline data to be loaded when the store is initialized.
10748 * @cfg {Roo.data.Reader} reader The Reader object which processes the data object and returns
10749 * an Array of Roo.data.record objects which are cached keyed by their <em>id</em> property.
10752 * @cfg {Object} baseParams An object containing properties which are to be sent as parameters
10753 * on any HTTP request
10756 * @cfg {Object} sortInfo A config object in the format: {field: "fieldName", direction: "ASC|DESC"}
10759 * @cfg {Boolean} multiSort enable multi column sorting (sort is based on the order of columns, remote only at present)
10763 * @cfg {boolean} remoteSort True if sorting is to be handled by requesting the Proxy to provide a refreshed
10764 * version of the data object in sorted order, as opposed to sorting the Record cache in place (defaults to false).
10766 remoteSort : false,
10769 * @cfg {boolean} pruneModifiedRecords True to clear all modified record information each time the store is
10770 * loaded or when a record is removed. (defaults to false).
10772 pruneModifiedRecords : false,
10775 lastOptions : null,
10778 * Add Records to the Store and fires the add event.
10779 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
10781 add : function(records){
10782 records = [].concat(records);
10783 for(var i = 0, len = records.length; i < len; i++){
10784 records[i].join(this);
10786 var index = this.data.length;
10787 this.data.addAll(records);
10788 this.fireEvent("add", this, records, index);
10792 * Remove a Record from the Store and fires the remove event.
10793 * @param {Ext.data.Record} record The Roo.data.Record object to remove from the cache.
10795 remove : function(record){
10796 var index = this.data.indexOf(record);
10797 this.data.removeAt(index);
10798 if(this.pruneModifiedRecords){
10799 this.modified.remove(record);
10801 this.fireEvent("remove", this, record, index);
10805 * Remove all Records from the Store and fires the clear event.
10807 removeAll : function(){
10809 if(this.pruneModifiedRecords){
10810 this.modified = [];
10812 this.fireEvent("clear", this);
10816 * Inserts Records to the Store at the given index and fires the add event.
10817 * @param {Number} index The start index at which to insert the passed Records.
10818 * @param {Roo.data.Record[]} records An Array of Roo.data.Record objects to add to the cache.
10820 insert : function(index, records){
10821 records = [].concat(records);
10822 for(var i = 0, len = records.length; i < len; i++){
10823 this.data.insert(index, records[i]);
10824 records[i].join(this);
10826 this.fireEvent("add", this, records, index);
10830 * Get the index within the cache of the passed Record.
10831 * @param {Roo.data.Record} record The Roo.data.Record object to to find.
10832 * @return {Number} The index of the passed Record. Returns -1 if not found.
10834 indexOf : function(record){
10835 return this.data.indexOf(record);
10839 * Get the index within the cache of the Record with the passed id.
10840 * @param {String} id The id of the Record to find.
10841 * @return {Number} The index of the Record. Returns -1 if not found.
10843 indexOfId : function(id){
10844 return this.data.indexOfKey(id);
10848 * Get the Record with the specified id.
10849 * @param {String} id The id of the Record to find.
10850 * @return {Roo.data.Record} The Record with the passed id. Returns undefined if not found.
10852 getById : function(id){
10853 return this.data.key(id);
10857 * Get the Record at the specified index.
10858 * @param {Number} index The index of the Record to find.
10859 * @return {Roo.data.Record} The Record at the passed index. Returns undefined if not found.
10861 getAt : function(index){
10862 return this.data.itemAt(index);
10866 * Returns a range of Records between specified indices.
10867 * @param {Number} startIndex (optional) The starting index (defaults to 0)
10868 * @param {Number} endIndex (optional) The ending index (defaults to the last Record in the Store)
10869 * @return {Roo.data.Record[]} An array of Records
10871 getRange : function(start, end){
10872 return this.data.getRange(start, end);
10876 storeOptions : function(o){
10877 o = Roo.apply({}, o);
10880 this.lastOptions = o;
10884 * Loads the Record cache from the configured Proxy using the configured Reader.
10886 * If using remote paging, then the first load call must specify the <em>start</em>
10887 * and <em>limit</em> properties in the options.params property to establish the initial
10888 * position within the dataset, and the number of Records to cache on each read from the Proxy.
10890 * <strong>It is important to note that for remote data sources, loading is asynchronous,
10891 * and this call will return before the new data has been loaded. Perform any post-processing
10892 * in a callback function, or in a "load" event handler.</strong>
10894 * @param {Object} options An object containing properties which control loading options:<ul>
10895 * <li>params {Object} An object containing properties to pass as HTTP parameters to a remote data source.</li>
10896 * <li>callback {Function} A function to be called after the Records have been loaded. The callback is
10897 * passed the following arguments:<ul>
10898 * <li>r : Roo.data.Record[]</li>
10899 * <li>options: Options object from the load call</li>
10900 * <li>success: Boolean success indicator</li></ul></li>
10901 * <li>scope {Object} Scope with which to call the callback (defaults to the Store object)</li>
10902 * <li>add {Boolean} indicator to append loaded records rather than replace the current cache.</li>
10905 load : function(options){
10906 options = options || {};
10907 if(this.fireEvent("beforeload", this, options) !== false){
10908 this.storeOptions(options);
10909 var p = Roo.apply(options.params || {}, this.baseParams);
10910 // if meta was not loaded from remote source.. try requesting it.
10911 if (!this.reader.metaFromRemote) {
10912 p._requestMeta = 1;
10914 if(this.sortInfo && this.remoteSort){
10915 var pn = this.paramNames;
10916 p[pn["sort"]] = this.sortInfo.field;
10917 p[pn["dir"]] = this.sortInfo.direction;
10919 if (this.multiSort) {
10920 var pn = this.paramNames;
10921 p[pn["multisort"]] = Roo.encode( { sort : this.sortToggle, order: this.sortOrder });
10924 this.proxy.load(p, this.reader, this.loadRecords, this, options);
10929 * Reloads the Record cache from the configured Proxy using the configured Reader and
10930 * the options from the last load operation performed.
10931 * @param {Object} options (optional) An object containing properties which may override the options
10932 * used in the last load operation. See {@link #load} for details (defaults to null, in which case
10933 * the most recently used options are reused).
10935 reload : function(options){
10936 this.load(Roo.applyIf(options||{}, this.lastOptions));
10940 // Called as a callback by the Reader during a load operation.
10941 loadRecords : function(o, options, success){
10942 if(!o || success === false){
10943 if(success !== false){
10944 this.fireEvent("load", this, [], options, o);
10946 if(options.callback){
10947 options.callback.call(options.scope || this, [], options, false);
10951 // if data returned failure - throw an exception.
10952 if (o.success === false) {
10953 // show a message if no listener is registered.
10954 if (!this.hasListener('loadexception') && typeof(o.raw.errorMsg) != 'undefined') {
10955 Roo.MessageBox.alert("Error loading",o.raw.errorMsg);
10957 // loadmask wil be hooked into this..
10958 this.fireEvent("loadexception", this, o, options, o.raw.errorMsg);
10961 var r = o.records, t = o.totalRecords || r.length;
10963 this.fireEvent("beforeloadadd", this, r, options, o);
10965 if(!options || options.add !== true){
10966 if(this.pruneModifiedRecords){
10967 this.modified = [];
10969 for(var i = 0, len = r.length; i < len; i++){
10973 this.data = this.snapshot;
10974 delete this.snapshot;
10977 this.data.addAll(r);
10978 this.totalLength = t;
10980 this.fireEvent("datachanged", this);
10982 this.totalLength = Math.max(t, this.data.length+r.length);
10985 this.fireEvent("load", this, r, options, o);
10986 if(options.callback){
10987 options.callback.call(options.scope || this, r, options, true);
10993 * Loads data from a passed data block. A Reader which understands the format of the data
10994 * must have been configured in the constructor.
10995 * @param {Object} data The data block from which to read the Records. The format of the data expected
10996 * is dependent on the type of Reader that is configured and should correspond to that Reader's readRecords parameter.
10997 * @param {Boolean} append (Optional) True to append the new Records rather than replace the existing cache.
10999 loadData : function(o, append){
11000 var r = this.reader.readRecords(o);
11001 this.loadRecords(r, {add: append}, true);
11005 * Gets the number of cached records.
11007 * <em>If using paging, this may not be the total size of the dataset. If the data object
11008 * used by the Reader contains the dataset size, then the getTotalCount() function returns
11009 * the data set size</em>
11011 getCount : function(){
11012 return this.data.length || 0;
11016 * Gets the total number of records in the dataset as returned by the server.
11018 * <em>If using paging, for this to be accurate, the data object used by the Reader must contain
11019 * the dataset size</em>
11021 getTotalCount : function(){
11022 return this.totalLength || 0;
11026 * Returns the sort state of the Store as an object with two properties:
11028 field {String} The name of the field by which the Records are sorted
11029 direction {String} The sort order, "ASC" or "DESC"
11032 getSortState : function(){
11033 return this.sortInfo;
11037 applySort : function(){
11038 if(this.sortInfo && !this.remoteSort){
11039 var s = this.sortInfo, f = s.field;
11040 var st = this.fields.get(f).sortType;
11041 var fn = function(r1, r2){
11042 var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
11043 return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
11045 this.data.sort(s.direction, fn);
11046 if(this.snapshot && this.snapshot != this.data){
11047 this.snapshot.sort(s.direction, fn);
11053 * Sets the default sort column and order to be used by the next load operation.
11054 * @param {String} fieldName The name of the field to sort by.
11055 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11057 setDefaultSort : function(field, dir){
11058 this.sortInfo = {field: field, direction: dir ? dir.toUpperCase() : "ASC"};
11062 * Sort the Records.
11063 * If remote sorting is used, the sort is performed on the server, and the cache is
11064 * reloaded. If local sorting is used, the cache is sorted internally.
11065 * @param {String} fieldName The name of the field to sort by.
11066 * @param {String} dir (optional) The sort order, "ASC" or "DESC" (defaults to "ASC")
11068 sort : function(fieldName, dir){
11069 var f = this.fields.get(fieldName);
11071 this.sortToggle[f.name] = this.sortToggle[f.name] || f.sortDir;
11073 if(this.multiSort || (this.sortInfo && this.sortInfo.field == f.name) ){ // toggle sort dir
11074 dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
11079 this.sortToggle[f.name] = dir;
11080 this.sortInfo = {field: f.name, direction: dir};
11081 if(!this.remoteSort){
11083 this.fireEvent("datachanged", this);
11085 this.load(this.lastOptions);
11090 * Calls the specified function for each of the Records in the cache.
11091 * @param {Function} fn The function to call. The Record is passed as the first parameter.
11092 * Returning <em>false</em> aborts and exits the iteration.
11093 * @param {Object} scope (optional) The scope in which to call the function (defaults to the Record).
11095 each : function(fn, scope){
11096 this.data.each(fn, scope);
11100 * Gets all records modified since the last commit. Modified records are persisted across load operations
11101 * (e.g., during paging).
11102 * @return {Roo.data.Record[]} An array of Records containing outstanding modifications.
11104 getModifiedRecords : function(){
11105 return this.modified;
11109 createFilterFn : function(property, value, anyMatch){
11110 if(!value.exec){ // not a regex
11111 value = String(value);
11112 if(value.length == 0){
11115 value = new RegExp((anyMatch === true ? '' : '^') + Roo.escapeRe(value), "i");
11117 return function(r){
11118 return value.test(r.data[property]);
11123 * Sums the value of <i>property</i> for each record between start and end and returns the result.
11124 * @param {String} property A field on your records
11125 * @param {Number} start The record index to start at (defaults to 0)
11126 * @param {Number} end The last record index to include (defaults to length - 1)
11127 * @return {Number} The sum
11129 sum : function(property, start, end){
11130 var rs = this.data.items, v = 0;
11131 start = start || 0;
11132 end = (end || end === 0) ? end : rs.length-1;
11134 for(var i = start; i <= end; i++){
11135 v += (rs[i].data[property] || 0);
11141 * Filter the records by a specified property.
11142 * @param {String} field A field on your records
11143 * @param {String/RegExp} value Either a string that the field
11144 * should start with or a RegExp to test against the field
11145 * @param {Boolean} anyMatch True to match any part not just the beginning
11147 filter : function(property, value, anyMatch){
11148 var fn = this.createFilterFn(property, value, anyMatch);
11149 return fn ? this.filterBy(fn) : this.clearFilter();
11153 * Filter by a function. The specified function will be called with each
11154 * record in this data source. If the function returns true the record is included,
11155 * otherwise it is filtered.
11156 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11157 * @param {Object} scope (optional) The scope of the function (defaults to this)
11159 filterBy : function(fn, scope){
11160 this.snapshot = this.snapshot || this.data;
11161 this.data = this.queryBy(fn, scope||this);
11162 this.fireEvent("datachanged", this);
11166 * Query the records by a specified property.
11167 * @param {String} field A field on your records
11168 * @param {String/RegExp} value Either a string that the field
11169 * should start with or a RegExp to test against the field
11170 * @param {Boolean} anyMatch True to match any part not just the beginning
11171 * @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11173 query : function(property, value, anyMatch){
11174 var fn = this.createFilterFn(property, value, anyMatch);
11175 return fn ? this.queryBy(fn) : this.data.clone();
11179 * Query by a function. The specified function will be called with each
11180 * record in this data source. If the function returns true the record is included
11182 * @param {Function} fn The function to be called, it will receive 2 args (record, id)
11183 * @param {Object} scope (optional) The scope of the function (defaults to this)
11184 @return {MixedCollection} Returns an Roo.util.MixedCollection of the matched records
11186 queryBy : function(fn, scope){
11187 var data = this.snapshot || this.data;
11188 return data.filterBy(fn, scope||this);
11192 * Collects unique values for a particular dataIndex from this store.
11193 * @param {String} dataIndex The property to collect
11194 * @param {Boolean} allowNull (optional) Pass true to allow null, undefined or empty string values
11195 * @param {Boolean} bypassFilter (optional) Pass true to collect from all records, even ones which are filtered
11196 * @return {Array} An array of the unique values
11198 collect : function(dataIndex, allowNull, bypassFilter){
11199 var d = (bypassFilter === true && this.snapshot) ?
11200 this.snapshot.items : this.data.items;
11201 var v, sv, r = [], l = {};
11202 for(var i = 0, len = d.length; i < len; i++){
11203 v = d[i].data[dataIndex];
11205 if((allowNull || !Roo.isEmpty(v)) && !l[sv]){
11214 * Revert to a view of the Record cache with no filtering applied.
11215 * @param {Boolean} suppressEvent If true the filter is cleared silently without notifying listeners
11217 clearFilter : function(suppressEvent){
11218 if(this.snapshot && this.snapshot != this.data){
11219 this.data = this.snapshot;
11220 delete this.snapshot;
11221 if(suppressEvent !== true){
11222 this.fireEvent("datachanged", this);
11228 afterEdit : function(record){
11229 if(this.modified.indexOf(record) == -1){
11230 this.modified.push(record);
11232 this.fireEvent("update", this, record, Roo.data.Record.EDIT);
11236 afterReject : function(record){
11237 this.modified.remove(record);
11238 this.fireEvent("update", this, record, Roo.data.Record.REJECT);
11242 afterCommit : function(record){
11243 this.modified.remove(record);
11244 this.fireEvent("update", this, record, Roo.data.Record.COMMIT);
11248 * Commit all Records with outstanding changes. To handle updates for changes, subscribe to the
11249 * Store's "update" event, and perform updating when the third parameter is Roo.data.Record.COMMIT.
11251 commitChanges : function(){
11252 var m = this.modified.slice(0);
11253 this.modified = [];
11254 for(var i = 0, len = m.length; i < len; i++){
11260 * Cancel outstanding changes on all changed records.
11262 rejectChanges : function(){
11263 var m = this.modified.slice(0);
11264 this.modified = [];
11265 for(var i = 0, len = m.length; i < len; i++){
11270 onMetaChange : function(meta, rtype, o){
11271 this.recordType = rtype;
11272 this.fields = rtype.prototype.fields;
11273 delete this.snapshot;
11274 this.sortInfo = meta.sortInfo || this.sortInfo;
11275 this.modified = [];
11276 this.fireEvent('metachange', this, this.reader.meta);
11279 moveIndex : function(data, type)
11281 var index = this.indexOf(data);
11283 var newIndex = index + type;
11287 this.insert(newIndex, data);
11292 * Ext JS Library 1.1.1
11293 * Copyright(c) 2006-2007, Ext JS, LLC.
11295 * Originally Released Under LGPL - original licence link has changed is not relivant.
11298 * <script type="text/javascript">
11302 * @class Roo.data.SimpleStore
11303 * @extends Roo.data.Store
11304 * Small helper class to make creating Stores from Array data easier.
11305 * @cfg {Number} id The array index of the record id. Leave blank to auto generate ids.
11306 * @cfg {Array} fields An array of field definition objects, or field name strings.
11307 * @cfg {Array} data The multi-dimensional array of data
11309 * @param {Object} config
11311 Roo.data.SimpleStore = function(config){
11312 Roo.data.SimpleStore.superclass.constructor.call(this, {
11314 reader: new Roo.data.ArrayReader({
11317 Roo.data.Record.create(config.fields)
11319 proxy : new Roo.data.MemoryProxy(config.data)
11323 Roo.extend(Roo.data.SimpleStore, Roo.data.Store);/*
11325 * Ext JS Library 1.1.1
11326 * Copyright(c) 2006-2007, Ext JS, LLC.
11328 * Originally Released Under LGPL - original licence link has changed is not relivant.
11331 * <script type="text/javascript">
11336 * @extends Roo.data.Store
11337 * @class Roo.data.JsonStore
11338 * Small helper class to make creating Stores for JSON data easier. <br/>
11340 var store = new Roo.data.JsonStore({
11341 url: 'get-images.php',
11343 fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date'}]
11346 * <b>Note: Although they are not listed, this class inherits all of the config options of Store,
11347 * JsonReader and HttpProxy (unless inline data is provided).</b>
11348 * @cfg {Array} fields An array of field definition objects, or field name strings.
11350 * @param {Object} config
11352 Roo.data.JsonStore = function(c){
11353 Roo.data.JsonStore.superclass.constructor.call(this, Roo.apply(c, {
11354 proxy: !c.data ? new Roo.data.HttpProxy({url: c.url}) : undefined,
11355 reader: new Roo.data.JsonReader(c, c.fields)
11358 Roo.extend(Roo.data.JsonStore, Roo.data.Store);/*
11360 * Ext JS Library 1.1.1
11361 * Copyright(c) 2006-2007, Ext JS, LLC.
11363 * Originally Released Under LGPL - original licence link has changed is not relivant.
11366 * <script type="text/javascript">
11370 Roo.data.Field = function(config){
11371 if(typeof config == "string"){
11372 config = {name: config};
11374 Roo.apply(this, config);
11377 this.type = "auto";
11380 var st = Roo.data.SortTypes;
11381 // named sortTypes are supported, here we look them up
11382 if(typeof this.sortType == "string"){
11383 this.sortType = st[this.sortType];
11386 // set default sortType for strings and dates
11387 if(!this.sortType){
11390 this.sortType = st.asUCString;
11393 this.sortType = st.asDate;
11396 this.sortType = st.none;
11401 var stripRe = /[\$,%]/g;
11403 // prebuilt conversion function for this field, instead of
11404 // switching every time we're reading a value
11406 var cv, dateFormat = this.dateFormat;
11411 cv = function(v){ return v; };
11414 cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
11418 return v !== undefined && v !== null && v !== '' ?
11419 parseInt(String(v).replace(stripRe, ""), 10) : '';
11424 return v !== undefined && v !== null && v !== '' ?
11425 parseFloat(String(v).replace(stripRe, ""), 10) : '';
11430 cv = function(v){ return v === true || v === "true" || v == 1; };
11437 if(v instanceof Date){
11441 if(dateFormat == "timestamp"){
11442 return new Date(v*1000);
11444 return Date.parseDate(v, dateFormat);
11446 var parsed = Date.parse(v);
11447 return parsed ? new Date(parsed) : null;
11456 Roo.data.Field.prototype = {
11464 * Ext JS Library 1.1.1
11465 * Copyright(c) 2006-2007, Ext JS, LLC.
11467 * Originally Released Under LGPL - original licence link has changed is not relivant.
11470 * <script type="text/javascript">
11473 // Base class for reading structured data from a data source. This class is intended to be
11474 // extended (see ArrayReader, JsonReader and XmlReader) and should not be created directly.
11477 * @class Roo.data.DataReader
11478 * Base class for reading structured data from a data source. This class is intended to be
11479 * extended (see {Roo.data.ArrayReader}, {Roo.data.JsonReader} and {Roo.data.XmlReader}) and should not be created directly.
11482 Roo.data.DataReader = function(meta, recordType){
11486 this.recordType = recordType instanceof Array ?
11487 Roo.data.Record.create(recordType) : recordType;
11490 Roo.data.DataReader.prototype = {
11492 * Create an empty record
11493 * @param {Object} data (optional) - overlay some values
11494 * @return {Roo.data.Record} record created.
11496 newRow : function(d) {
11498 this.recordType.prototype.fields.each(function(c) {
11500 case 'int' : da[c.name] = 0; break;
11501 case 'date' : da[c.name] = new Date(); break;
11502 case 'float' : da[c.name] = 0.0; break;
11503 case 'boolean' : da[c.name] = false; break;
11504 default : da[c.name] = ""; break;
11508 return new this.recordType(Roo.apply(da, d));
11513 * Ext JS Library 1.1.1
11514 * Copyright(c) 2006-2007, Ext JS, LLC.
11516 * Originally Released Under LGPL - original licence link has changed is not relivant.
11519 * <script type="text/javascript">
11523 * @class Roo.data.DataProxy
11524 * @extends Roo.data.Observable
11525 * This class is an abstract base class for implementations which provide retrieval of
11526 * unformatted data objects.<br>
11528 * DataProxy implementations are usually used in conjunction with an implementation of Roo.data.DataReader
11529 * (of the appropriate type which knows how to parse the data object) to provide a block of
11530 * {@link Roo.data.Records} to an {@link Roo.data.Store}.<br>
11532 * Custom implementations must implement the load method as described in
11533 * {@link Roo.data.HttpProxy#load}.
11535 Roo.data.DataProxy = function(){
11538 * @event beforeload
11539 * Fires before a network request is made to retrieve a data object.
11540 * @param {Object} This DataProxy object.
11541 * @param {Object} params The params parameter to the load function.
11546 * Fires before the load method's callback is called.
11547 * @param {Object} This DataProxy object.
11548 * @param {Object} o The data object.
11549 * @param {Object} arg The callback argument object passed to the load function.
11553 * @event loadexception
11554 * Fires if an Exception occurs during data retrieval.
11555 * @param {Object} This DataProxy object.
11556 * @param {Object} o The data object.
11557 * @param {Object} arg The callback argument object passed to the load function.
11558 * @param {Object} e The Exception.
11560 loadexception : true
11562 Roo.data.DataProxy.superclass.constructor.call(this);
11565 Roo.extend(Roo.data.DataProxy, Roo.util.Observable);
11568 * @cfg {void} listeners (Not available) Constructor blocks listeners from being set
11572 * Ext JS Library 1.1.1
11573 * Copyright(c) 2006-2007, Ext JS, LLC.
11575 * Originally Released Under LGPL - original licence link has changed is not relivant.
11578 * <script type="text/javascript">
11581 * @class Roo.data.MemoryProxy
11582 * An implementation of Roo.data.DataProxy that simply passes the data specified in its constructor
11583 * to the Reader when its load method is called.
11585 * @param {Object} data The data object which the Reader uses to construct a block of Roo.data.Records.
11587 Roo.data.MemoryProxy = function(data){
11591 Roo.data.MemoryProxy.superclass.constructor.call(this);
11595 Roo.extend(Roo.data.MemoryProxy, Roo.data.DataProxy, {
11598 * Load data from the requested source (in this case an in-memory
11599 * data object passed to the constructor), read the data object into
11600 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
11601 * process that block using the passed callback.
11602 * @param {Object} params This parameter is not used by the MemoryProxy class.
11603 * @param {Roo.data.DataReader} reader The Reader object which converts the data
11604 * object into a block of Roo.data.Records.
11605 * @param {Function} callback The function into which to pass the block of Roo.data.records.
11606 * The function must be passed <ul>
11607 * <li>The Record block object</li>
11608 * <li>The "arg" argument from the load function</li>
11609 * <li>A boolean success indicator</li>
11611 * @param {Object} scope The scope in which to call the callback
11612 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
11614 load : function(params, reader, callback, scope, arg){
11615 params = params || {};
11618 result = reader.readRecords(this.data);
11620 this.fireEvent("loadexception", this, arg, null, e);
11621 callback.call(scope, null, arg, false);
11624 callback.call(scope, result, arg, true);
11628 update : function(params, records){
11633 * Ext JS Library 1.1.1
11634 * Copyright(c) 2006-2007, Ext JS, LLC.
11636 * Originally Released Under LGPL - original licence link has changed is not relivant.
11639 * <script type="text/javascript">
11642 * @class Roo.data.HttpProxy
11643 * @extends Roo.data.DataProxy
11644 * An implementation of {@link Roo.data.DataProxy} that reads a data object from an {@link Roo.data.Connection} object
11645 * configured to reference a certain URL.<br><br>
11647 * <em>Note that this class cannot be used to retrieve data from a domain other than the domain
11648 * from which the running page was served.<br><br>
11650 * For cross-domain access to remote data, use an {@link Roo.data.ScriptTagProxy}.</em><br><br>
11652 * Be aware that to enable the browser to parse an XML document, the server must set
11653 * the Content-Type header in the HTTP response to "text/xml".
11655 * @param {Object} conn Connection config options to add to each request (e.g. {url: 'foo.php'} or
11656 * an {@link Roo.data.Connection} object. If a Connection config is passed, the singleton {@link Roo.Ajax} object
11657 * will be used to make the request.
11659 Roo.data.HttpProxy = function(conn){
11660 Roo.data.HttpProxy.superclass.constructor.call(this);
11661 // is conn a conn config or a real conn?
11663 this.useAjax = !conn || !conn.events;
11667 Roo.extend(Roo.data.HttpProxy, Roo.data.DataProxy, {
11668 // thse are take from connection...
11671 * @cfg {String} url (Optional) The default URL to be used for requests to the server. (defaults to undefined)
11674 * @cfg {Object} extraParams (Optional) An object containing properties which are used as
11675 * extra parameters to each request made by this object. (defaults to undefined)
11678 * @cfg {Object} defaultHeaders (Optional) An object containing request headers which are added
11679 * to each request made by this object. (defaults to undefined)
11682 * @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)
11685 * @cfg {Number} timeout (Optional) The timeout in milliseconds to be used for requests. (defaults to 30000)
11688 * @cfg {Boolean} autoAbort (Optional) Whether this request should abort any pending requests. (defaults to false)
11694 * @cfg {Boolean} disableCaching (Optional) True to add a unique cache-buster param to GET requests. (defaults to true)
11698 * Return the {@link Roo.data.Connection} object being used by this Proxy.
11699 * @return {Connection} The Connection object. This object may be used to subscribe to events on
11700 * a finer-grained basis than the DataProxy events.
11702 getConnection : function(){
11703 return this.useAjax ? Roo.Ajax : this.conn;
11707 * Load data from the configured {@link Roo.data.Connection}, read the data object into
11708 * a block of Roo.data.Records using the passed {@link Roo.data.DataReader} implementation, and
11709 * process that block using the passed callback.
11710 * @param {Object} params An object containing properties which are to be used as HTTP parameters
11711 * for the request to the remote server.
11712 * @param {Roo.data.DataReader} reader The Reader object which converts the data
11713 * object into a block of Roo.data.Records.
11714 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
11715 * The function must be passed <ul>
11716 * <li>The Record block object</li>
11717 * <li>The "arg" argument from the load function</li>
11718 * <li>A boolean success indicator</li>
11720 * @param {Object} scope The scope in which to call the callback
11721 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
11723 load : function(params, reader, callback, scope, arg){
11724 if(this.fireEvent("beforeload", this, params) !== false){
11726 params : params || {},
11728 callback : callback,
11733 callback : this.loadResponse,
11737 Roo.applyIf(o, this.conn);
11738 if(this.activeRequest){
11739 Roo.Ajax.abort(this.activeRequest);
11741 this.activeRequest = Roo.Ajax.request(o);
11743 this.conn.request(o);
11746 callback.call(scope||this, null, arg, false);
11751 loadResponse : function(o, success, response){
11752 delete this.activeRequest;
11754 this.fireEvent("loadexception", this, o, response);
11755 o.request.callback.call(o.request.scope, null, o.request.arg, false);
11760 result = o.reader.read(response);
11762 this.fireEvent("loadexception", this, o, response, e);
11763 o.request.callback.call(o.request.scope, null, o.request.arg, false);
11767 this.fireEvent("load", this, o, o.request.arg);
11768 o.request.callback.call(o.request.scope, result, o.request.arg, true);
11772 update : function(dataSet){
11777 updateResponse : function(dataSet){
11782 * Ext JS Library 1.1.1
11783 * Copyright(c) 2006-2007, Ext JS, LLC.
11785 * Originally Released Under LGPL - original licence link has changed is not relivant.
11788 * <script type="text/javascript">
11792 * @class Roo.data.ScriptTagProxy
11793 * An implementation of Roo.data.DataProxy that reads a data object from a URL which may be in a domain
11794 * other than the originating domain of the running page.<br><br>
11796 * <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
11797 * of the running page, you must use this class, rather than DataProxy.</em><br><br>
11799 * The content passed back from a server resource requested by a ScriptTagProxy is executable JavaScript
11800 * source code that is used as the source inside a <script> tag.<br><br>
11802 * In order for the browser to process the returned data, the server must wrap the data object
11803 * with a call to a callback function, the name of which is passed as a parameter by the ScriptTagProxy.
11804 * Below is a Java example for a servlet which returns data for either a ScriptTagProxy, or an HttpProxy
11805 * depending on whether the callback name was passed:
11808 boolean scriptTag = false;
11809 String cb = request.getParameter("callback");
11812 response.setContentType("text/javascript");
11814 response.setContentType("application/x-json");
11816 Writer out = response.getWriter();
11818 out.write(cb + "(");
11820 out.print(dataBlock.toJsonString());
11827 * @param {Object} config A configuration object.
11829 Roo.data.ScriptTagProxy = function(config){
11830 Roo.data.ScriptTagProxy.superclass.constructor.call(this);
11831 Roo.apply(this, config);
11832 this.head = document.getElementsByTagName("head")[0];
11835 Roo.data.ScriptTagProxy.TRANS_ID = 1000;
11837 Roo.extend(Roo.data.ScriptTagProxy, Roo.data.DataProxy, {
11839 * @cfg {String} url The URL from which to request the data object.
11842 * @cfg {Number} timeout (Optional) The number of milliseconds to wait for a response. Defaults to 30 seconds.
11846 * @cfg {String} callbackParam (Optional) The name of the parameter to pass to the server which tells
11847 * the server the name of the callback function set up by the load call to process the returned data object.
11848 * Defaults to "callback".<p>The server-side processing must read this parameter value, and generate
11849 * javascript output which calls this named function passing the data object as its only parameter.
11851 callbackParam : "callback",
11853 * @cfg {Boolean} nocache (Optional) Defaults to true. Disable cacheing by adding a unique parameter
11854 * name to the request.
11859 * Load data from the configured URL, read the data object into
11860 * a block of Roo.data.Records using the passed Roo.data.DataReader implementation, and
11861 * process that block using the passed callback.
11862 * @param {Object} params An object containing properties which are to be used as HTTP parameters
11863 * for the request to the remote server.
11864 * @param {Roo.data.DataReader} reader The Reader object which converts the data
11865 * object into a block of Roo.data.Records.
11866 * @param {Function} callback The function into which to pass the block of Roo.data.Records.
11867 * The function must be passed <ul>
11868 * <li>The Record block object</li>
11869 * <li>The "arg" argument from the load function</li>
11870 * <li>A boolean success indicator</li>
11872 * @param {Object} scope The scope in which to call the callback
11873 * @param {Object} arg An optional argument which is passed to the callback as its second parameter.
11875 load : function(params, reader, callback, scope, arg){
11876 if(this.fireEvent("beforeload", this, params) !== false){
11878 var p = Roo.urlEncode(Roo.apply(params, this.extraParams));
11880 var url = this.url;
11881 url += (url.indexOf("?") != -1 ? "&" : "?") + p;
11883 url += "&_dc=" + (new Date().getTime());
11885 var transId = ++Roo.data.ScriptTagProxy.TRANS_ID;
11888 cb : "stcCallback"+transId,
11889 scriptId : "stcScript"+transId,
11893 callback : callback,
11899 window[trans.cb] = function(o){
11900 conn.handleResponse(o, trans);
11903 url += String.format("&{0}={1}", this.callbackParam, trans.cb);
11905 if(this.autoAbort !== false){
11909 trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
11911 var script = document.createElement("script");
11912 script.setAttribute("src", url);
11913 script.setAttribute("type", "text/javascript");
11914 script.setAttribute("id", trans.scriptId);
11915 this.head.appendChild(script);
11917 this.trans = trans;
11919 callback.call(scope||this, null, arg, false);
11924 isLoading : function(){
11925 return this.trans ? true : false;
11929 * Abort the current server request.
11931 abort : function(){
11932 if(this.isLoading()){
11933 this.destroyTrans(this.trans);
11938 destroyTrans : function(trans, isLoaded){
11939 this.head.removeChild(document.getElementById(trans.scriptId));
11940 clearTimeout(trans.timeoutId);
11942 window[trans.cb] = undefined;
11944 delete window[trans.cb];
11947 // if hasn't been loaded, wait for load to remove it to prevent script error
11948 window[trans.cb] = function(){
11949 window[trans.cb] = undefined;
11951 delete window[trans.cb];
11958 handleResponse : function(o, trans){
11959 this.trans = false;
11960 this.destroyTrans(trans, true);
11963 result = trans.reader.readRecords(o);
11965 this.fireEvent("loadexception", this, o, trans.arg, e);
11966 trans.callback.call(trans.scope||window, null, trans.arg, false);
11969 this.fireEvent("load", this, o, trans.arg);
11970 trans.callback.call(trans.scope||window, result, trans.arg, true);
11974 handleFailure : function(trans){
11975 this.trans = false;
11976 this.destroyTrans(trans, false);
11977 this.fireEvent("loadexception", this, null, trans.arg);
11978 trans.callback.call(trans.scope||window, null, trans.arg, false);
11982 * Ext JS Library 1.1.1
11983 * Copyright(c) 2006-2007, Ext JS, LLC.
11985 * Originally Released Under LGPL - original licence link has changed is not relivant.
11988 * <script type="text/javascript">
11992 * @class Roo.data.JsonReader
11993 * @extends Roo.data.DataReader
11994 * Data reader class to create an Array of Roo.data.Record objects from a JSON response
11995 * based on mappings in a provided Roo.data.Record constructor.
11997 * The default behaviour of a store is to send ?_requestMeta=1, unless the class has recieved 'metaData' property
11998 * in the reply previously.
12003 var RecordDef = Roo.data.Record.create([
12004 {name: 'name', mapping: 'name'}, // "mapping" property not needed if it's the same as "name"
12005 {name: 'occupation'} // This field will use "occupation" as the mapping.
12007 var myReader = new Roo.data.JsonReader({
12008 totalProperty: "results", // The property which contains the total dataset size (optional)
12009 root: "rows", // The property which contains an Array of row objects
12010 id: "id" // The property within each row object that provides an ID for the record (optional)
12014 * This would consume a JSON file like this:
12016 { 'results': 2, 'rows': [
12017 { 'id': 1, 'name': 'Bill', occupation: 'Gardener' },
12018 { 'id': 2, 'name': 'Ben', occupation: 'Horticulturalist' } ]
12021 * @cfg {String} totalProperty Name of the property from which to retrieve the total number of records
12022 * in the dataset. This is only needed if the whole dataset is not passed in one go, but is being
12023 * paged from the remote server.
12024 * @cfg {String} successProperty Name of the property from which to retrieve the success attribute used by forms.
12025 * @cfg {String} root name of the property which contains the Array of row objects.
12026 * @cfg {String} id Name of the property within a row object that contains a record identifier value.
12027 * @cfg {Array} fields Array of field definition objects
12029 * Create a new JsonReader
12030 * @param {Object} meta Metadata configuration options
12031 * @param {Object} recordType Either an Array of field definition objects,
12032 * or an {@link Roo.data.Record} object created using {@link Roo.data.Record#create}.
12034 Roo.data.JsonReader = function(meta, recordType){
12037 // set some defaults:
12038 Roo.applyIf(meta, {
12039 totalProperty: 'total',
12040 successProperty : 'success',
12045 Roo.data.JsonReader.superclass.constructor.call(this, meta, recordType||meta.fields);
12047 Roo.extend(Roo.data.JsonReader, Roo.data.DataReader, {
12050 * @prop {Boolean} metaFromRemote - if the meta data was loaded from the remote source.
12051 * Used by Store query builder to append _requestMeta to params.
12054 metaFromRemote : false,
12056 * This method is only used by a DataProxy which has retrieved data from a remote server.
12057 * @param {Object} response The XHR object which contains the JSON data in its responseText.
12058 * @return {Object} data A data block which is used by an Roo.data.Store object as
12059 * a cache of Roo.data.Records.
12061 read : function(response){
12062 var json = response.responseText;
12064 var o = /* eval:var:o */ eval("("+json+")");
12066 throw {message: "JsonReader.read: Json object not found"};
12072 this.metaFromRemote = true;
12073 this.meta = o.metaData;
12074 this.recordType = Roo.data.Record.create(o.metaData.fields);
12075 this.onMetaChange(this.meta, this.recordType, o);
12077 return this.readRecords(o);
12080 // private function a store will implement
12081 onMetaChange : function(meta, recordType, o){
12088 simpleAccess: function(obj, subsc) {
12095 getJsonAccessor: function(){
12097 return function(expr) {
12099 return(re.test(expr))
12100 ? new Function("obj", "return obj." + expr)
12105 return Roo.emptyFn;
12110 * Create a data block containing Roo.data.Records from an XML document.
12111 * @param {Object} o An object which contains an Array of row objects in the property specified
12112 * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
12113 * which contains the total size of the dataset.
12114 * @return {Object} data A data block which is used by an Roo.data.Store object as
12115 * a cache of Roo.data.Records.
12117 readRecords : function(o){
12119 * After any data loads, the raw JSON data is available for further custom processing.
12123 var s = this.meta, Record = this.recordType,
12124 f = Record ? Record.prototype.fields : null, fi = f ? f.items : [], fl = f ? f.length : 0;
12126 // Generate extraction functions for the totalProperty, the root, the id, and for each field
12128 if(s.totalProperty) {
12129 this.getTotal = this.getJsonAccessor(s.totalProperty);
12131 if(s.successProperty) {
12132 this.getSuccess = this.getJsonAccessor(s.successProperty);
12134 this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
12136 var g = this.getJsonAccessor(s.id);
12137 this.getId = function(rec) {
12139 return (r === undefined || r === "") ? null : r;
12142 this.getId = function(){return null;};
12145 for(var jj = 0; jj < fl; jj++){
12147 var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
12148 this.ef[jj] = this.getJsonAccessor(map);
12152 var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
12153 if(s.totalProperty){
12154 var vt = parseInt(this.getTotal(o), 10);
12159 if(s.successProperty){
12160 var vs = this.getSuccess(o);
12161 if(vs === false || vs === 'false'){
12166 for(var i = 0; i < c; i++){
12169 var id = this.getId(n);
12170 for(var j = 0; j < fl; j++){
12172 var v = this.ef[j](n);
12174 Roo.log('missing convert for ' + f.name);
12178 values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue);
12180 var record = new Record(values, id);
12182 records[i] = record;
12188 totalRecords : totalRecords
12193 * Ext JS Library 1.1.1
12194 * Copyright(c) 2006-2007, Ext JS, LLC.
12196 * Originally Released Under LGPL - original licence link has changed is not relivant.
12199 * <script type="text/javascript">
12203 * @class Roo.data.ArrayReader
12204 * @extends Roo.data.DataReader
12205 * Data reader class to create an Array of Roo.data.Record objects from an Array.
12206 * Each element of that Array represents a row of data fields. The
12207 * fields are pulled into a Record object using as a subscript, the <em>mapping</em> property
12208 * of the field definition if it exists, or the field's ordinal position in the definition.<br>
12212 var RecordDef = Roo.data.Record.create([
12213 {name: 'name', mapping: 1}, // "mapping" only needed if an "id" field is present which
12214 {name: 'occupation', mapping: 2} // precludes using the ordinal position as the index.
12216 var myReader = new Roo.data.ArrayReader({
12217 id: 0 // The subscript within row Array that provides an ID for the Record (optional)
12221 * This would consume an Array like this:
12223 [ [1, 'Bill', 'Gardener'], [2, 'Ben', 'Horticulturalist'] ]
12225 * @cfg {String} id (optional) The subscript within row Array that provides an ID for the Record
12227 * Create a new JsonReader
12228 * @param {Object} meta Metadata configuration options.
12229 * @param {Object} recordType Either an Array of field definition objects
12230 * as specified to {@link Roo.data.Record#create},
12231 * or an {@link Roo.data.Record} object
12232 * created using {@link Roo.data.Record#create}.
12234 Roo.data.ArrayReader = function(meta, recordType){
12235 Roo.data.ArrayReader.superclass.constructor.call(this, meta, recordType);
12238 Roo.extend(Roo.data.ArrayReader, Roo.data.JsonReader, {
12240 * Create a data block containing Roo.data.Records from an XML document.
12241 * @param {Object} o An Array of row objects which represents the dataset.
12242 * @return {Object} data A data block which is used by an Roo.data.Store object as
12243 * a cache of Roo.data.Records.
12245 readRecords : function(o){
12246 var sid = this.meta ? this.meta.id : null;
12247 var recordType = this.recordType, fields = recordType.prototype.fields;
12250 for(var i = 0; i < root.length; i++){
12253 var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
12254 for(var j = 0, jlen = fields.length; j < jlen; j++){
12255 var f = fields.items[j];
12256 var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
12257 var v = n[k] !== undefined ? n[k] : f.defaultValue;
12259 values[f.name] = v;
12261 var record = new recordType(values, id);
12263 records[records.length] = record;
12267 totalRecords : records.length
12276 * @class Roo.bootstrap.ComboBox
12277 * @extends Roo.bootstrap.TriggerField
12278 * A combobox control with support for autocomplete, remote-loading, paging and many other features.
12279 * @cfg {Boolean} append (true|false) default false
12280 * @cfg {Boolean} autoFocus (true|false) auto focus the first item, default true
12281 * @cfg {Boolean} tickable ComboBox with tickable selections (true|false), default false
12282 * @cfg {Boolean} triggerList trigger show the list or not (true|false) default true
12283 * @cfg {Boolean} showToggleBtn show toggle button or not (true|false) default true
12284 * @cfg {String} btnPosition set the position of the trigger button (left | right) default right
12285 * @cfg {Boolean} animate default true
12286 * @cfg {Boolean} emptyResultText only for touch device
12287 * @cfg {String} triggerText multiple combobox trigger button text default 'Select'
12289 * Create a new ComboBox.
12290 * @param {Object} config Configuration options
12292 Roo.bootstrap.ComboBox = function(config){
12293 Roo.bootstrap.ComboBox.superclass.constructor.call(this, config);
12297 * Fires when the dropdown list is expanded
12298 * @param {Roo.bootstrap.ComboBox} combo This combo box
12303 * Fires when the dropdown list is collapsed
12304 * @param {Roo.bootstrap.ComboBox} combo This combo box
12308 * @event beforeselect
12309 * Fires before a list item is selected. Return false to cancel the selection.
12310 * @param {Roo.bootstrap.ComboBox} combo This combo box
12311 * @param {Roo.data.Record} record The data record returned from the underlying store
12312 * @param {Number} index The index of the selected item in the dropdown list
12314 'beforeselect' : true,
12317 * Fires when a list item is selected
12318 * @param {Roo.bootstrap.ComboBox} combo This combo box
12319 * @param {Roo.data.Record} record The data record returned from the underlying store (or false on clear)
12320 * @param {Number} index The index of the selected item in the dropdown list
12324 * @event beforequery
12325 * Fires before all queries are processed. Return false to cancel the query or set cancel to true.
12326 * The event object passed has these properties:
12327 * @param {Roo.bootstrap.ComboBox} combo This combo box
12328 * @param {String} query The query
12329 * @param {Boolean} forceAll true to force "all" query
12330 * @param {Boolean} cancel true to cancel the query
12331 * @param {Object} e The query event object
12333 'beforequery': true,
12336 * Fires when the 'add' icon is pressed (add a listener to enable add button)
12337 * @param {Roo.bootstrap.ComboBox} combo This combo box
12342 * Fires when the 'edit' icon is pressed (add a listener to enable add button)
12343 * @param {Roo.bootstrap.ComboBox} combo This combo box
12344 * @param {Roo.data.Record|false} record The data record returned from the underlying store (or false on nothing selected)
12349 * Fires when the remove value from the combobox array
12350 * @param {Roo.bootstrap.ComboBox} combo This combo box
12354 * @event afterremove
12355 * Fires when the remove value from the combobox array
12356 * @param {Roo.bootstrap.ComboBox} combo This combo box
12358 'afterremove' : true,
12360 * @event specialfilter
12361 * Fires when specialfilter
12362 * @param {Roo.bootstrap.ComboBox} combo This combo box
12364 'specialfilter' : true,
12367 * Fires when tick the element
12368 * @param {Roo.bootstrap.ComboBox} combo This combo box
12372 * @event touchviewdisplay
12373 * Fires when touch view require special display (default is using displayField)
12374 * @param {Roo.bootstrap.ComboBox} combo This combo box
12375 * @param {Object} cfg set html .
12377 'touchviewdisplay' : true
12382 this.tickItems = [];
12384 this.selectedIndex = -1;
12385 if(this.mode == 'local'){
12386 if(config.queryDelay === undefined){
12387 this.queryDelay = 10;
12389 if(config.minChars === undefined){
12395 Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, {
12398 * @cfg {Boolean} lazyRender True to prevent the ComboBox from rendering until requested (should always be used when
12399 * rendering into an Roo.Editor, defaults to false)
12402 * @cfg {Boolean/Object} autoCreate A DomHelper element spec, or true for a default element spec (defaults to:
12403 * {tag: "input", type: "text", size: "24", autocomplete: "off"})
12406 * @cfg {Roo.data.Store} store The data store to which this combo is bound (defaults to undefined)
12409 * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
12410 * the dropdown list (defaults to undefined, with no header element)
12414 * @cfg {String/Roo.Template} tpl The template to use to render the output
12418 * @cfg {Number} listWidth The width in pixels of the dropdown list (defaults to the width of the ComboBox field)
12420 listWidth: undefined,
12422 * @cfg {String} displayField The underlying data field name to bind to this CombBox (defaults to undefined if
12423 * mode = 'remote' or 'text' if mode = 'local')
12425 displayField: undefined,
12428 * @cfg {String} valueField The underlying data value name to bind to this CombBox (defaults to undefined if
12429 * mode = 'remote' or 'value' if mode = 'local').
12430 * Note: use of a valueField requires the user make a selection
12431 * in order for a value to be mapped.
12433 valueField: undefined,
12435 * @cfg {String} modalTitle The title of the dialog that pops up on mobile views.
12440 * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
12441 * field's data value (defaults to the underlying DOM element's name)
12443 hiddenName: undefined,
12445 * @cfg {String} listClass CSS class to apply to the dropdown list element (defaults to '')
12449 * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list (defaults to 'x-combo-selected')
12451 selectedClass: 'active',
12454 * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop" for bottom-right
12458 * @cfg {String} listAlign A valid anchor position value. See {@link Roo.Element#alignTo} for details on supported
12459 * anchor positions (defaults to 'tl-bl')
12461 listAlign: 'tl-bl?',
12463 * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown (defaults to 300)
12467 * @cfg {String} triggerAction The action to execute when the trigger field is activated. Use 'all' to run the
12468 * query specified by the allQuery config option (defaults to 'query')
12470 triggerAction: 'query',
12472 * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and typeahead activate
12473 * (defaults to 4, does not apply if editable = false)
12477 * @cfg {Boolean} typeAhead True to populate and autoselect the remainder of the text being typed after a configurable
12478 * delay (typeAheadDelay) if it matches a known value (defaults to false)
12482 * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and sending the
12483 * query to filter the dropdown list (defaults to 500 if mode = 'remote' or 10 if mode = 'local')
12487 * @cfg {Number} pageSize If greater than 0, a paging toolbar is displayed in the footer of the dropdown list and the
12488 * filter queries will execute with page start and limit parameters. Only applies when mode = 'remote' (defaults to 0)
12492 * @cfg {Boolean} selectOnFocus True to select any existing text in the field immediately on focus. Only applies
12493 * when editable = true (defaults to false)
12495 selectOnFocus:false,
12497 * @cfg {String} queryParam Name of the query as it will be passed on the querystring (defaults to 'query')
12499 queryParam: 'query',
12501 * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
12502 * when mode = 'remote' (defaults to 'Loading...')
12504 loadingText: 'Loading...',
12506 * @cfg {Boolean} resizable True to add a resize handle to the bottom of the dropdown list (defaults to false)
12510 * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if resizable = true (defaults to 8)
12514 * @cfg {Boolean} editable False to prevent the user from typing text directly into the field, just like a
12515 * traditional select (defaults to true)
12519 * @cfg {String} allQuery The text query to send to the server to return all records for the list with no filtering (defaults to '')
12523 * @cfg {String} mode Set to 'local' if the ComboBox loads local data (defaults to 'remote' which loads from the server)
12527 * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to 70, will be ignored if
12528 * listWidth has a higher value)
12532 * @cfg {Boolean} forceSelection True to restrict the selected value to one of the values in the list, false to
12533 * allow the user to set arbitrary text into the field (defaults to false)
12535 forceSelection:false,
12537 * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
12538 * if typeAhead = true (defaults to 250)
12540 typeAheadDelay : 250,
12542 * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
12543 * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined)
12545 valueNotFoundText : undefined,
12547 * @cfg {Boolean} blockFocus Prevents all focus calls, so it can work with things like HTML edtor bar
12549 blockFocus : false,
12552 * @cfg {Boolean} disableClear Disable showing of clear button.
12554 disableClear : false,
12556 * @cfg {Boolean} alwaysQuery Disable caching of results, and always send query
12558 alwaysQuery : false,
12561 * @cfg {Boolean} multiple (true|false) ComboBobArray, default false
12566 * @cfg {String} invalidClass The CSS class to use when marking a field invalid (defaults to "x-form-invalid")
12568 invalidClass : "has-warning",
12571 * @cfg {String} validClass The CSS class to use when marking a field valid (defaults to "x-form-invalid")
12573 validClass : "has-success",
12576 * @cfg {Boolean} specialFilter (true|false) special filter default false
12578 specialFilter : false,
12581 * @cfg {Boolean} mobileTouchView (true|false) show mobile touch view when using a mobile default true
12583 mobileTouchView : true,
12586 * @cfg {Boolean} useNativeIOS (true|false) render it as classic select for ios, not support dynamic load data (default false)
12588 useNativeIOS : false,
12590 ios_options : false,
12602 btnPosition : 'right',
12603 triggerList : true,
12604 showToggleBtn : true,
12606 emptyResultText: 'Empty',
12607 triggerText : 'Select',
12609 // element that contains real text value.. (when hidden is used..)
12611 getAutoCreate : function()
12616 * Render classic select for iso
12619 if(Roo.isIOS && this.useNativeIOS){
12620 cfg = this.getAutoCreateNativeIOS();
12628 if(Roo.isTouch && this.mobileTouchView){
12629 cfg = this.getAutoCreateTouchView();
12636 if(!this.tickable){
12637 cfg = Roo.bootstrap.ComboBox.superclass.getAutoCreate.call(this);
12638 if(this.name == 'info_year_invest_id_display_name'){
12639 Roo.log('cfg.................................................');
12646 * ComboBox with tickable selections
12649 var align = this.labelAlign || this.parentLabelAlign();
12652 cls : 'form-group roo-combobox-tickable' //input-group
12655 var btn_text_select = '';
12656 var btn_text_done = '';
12657 var btn_text_cancel = '';
12659 if (this.btn_text_show) {
12660 btn_text_select = 'Select';
12661 btn_text_done = 'Done';
12662 btn_text_cancel = 'Cancel';
12667 cls : 'tickable-buttons',
12672 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
12673 //html : this.triggerText
12674 html: btn_text_select
12680 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
12682 html: btn_text_done
12688 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
12690 html: btn_text_cancel
12696 buttons.cn.unshift({
12698 cls: 'roo-select2-search-field-input'
12704 Roo.each(buttons.cn, function(c){
12706 c.cls += ' btn-' + _this.size;
12709 if (_this.disabled) {
12720 cls: 'form-hidden-field'
12724 cls: 'roo-select2-choices',
12728 cls: 'roo-select2-search-field',
12739 cls: 'roo-select2-container input-group roo-select2-container-multi',
12744 // cls: 'typeahead typeahead-long dropdown-menu',
12745 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
12750 if(this.hasFeedback && !this.allowBlank){
12754 cls: 'glyphicon form-control-feedback'
12757 combobox.cn.push(feedback);
12761 if (align ==='left' && this.fieldLabel.length) {
12763 cfg.cls += ' roo-form-group-label-left';
12768 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
12769 tooltip : 'This field is required'
12774 cls : 'control-label',
12775 html : this.fieldLabel
12787 var labelCfg = cfg.cn[1];
12788 var contentCfg = cfg.cn[2];
12791 if(this.indicatorpos == 'right'){
12797 cls : 'control-label',
12801 html : this.fieldLabel
12805 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
12806 tooltip : 'This field is required'
12821 labelCfg = cfg.cn[0];
12822 contentCfg = cfg.cn[1];
12826 if(this.labelWidth > 12){
12827 labelCfg.style = "width: " + this.labelWidth + 'px';
12830 if(this.labelWidth < 13 && this.labelmd == 0){
12831 this.labelmd = this.labelWidth;
12834 if(this.labellg > 0){
12835 labelCfg.cls += ' col-lg-' + this.labellg;
12836 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
12839 if(this.labelmd > 0){
12840 labelCfg.cls += ' col-md-' + this.labelmd;
12841 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
12844 if(this.labelsm > 0){
12845 labelCfg.cls += ' col-sm-' + this.labelsm;
12846 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
12849 if(this.labelxs > 0){
12850 labelCfg.cls += ' col-xs-' + this.labelxs;
12851 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
12855 } else if ( this.fieldLabel.length) {
12856 // Roo.log(" label");
12860 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
12861 tooltip : 'This field is required'
12865 //cls : 'input-group-addon',
12866 html : this.fieldLabel
12874 if(this.indicatorpos == 'right'){
12879 //cls : 'input-group-addon',
12883 html : this.fieldLabel
12887 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
12888 tooltip : 'This field is required'
12903 // Roo.log(" no label && no align");
12910 ['xs','sm','md','lg'].map(function(size){
12911 if (settings[size]) {
12912 cfg.cls += ' col-' + size + '-' + settings[size];
12920 _initEventsCalled : false,
12923 initEvents: function()
12925 if (this._initEventsCalled) { // as we call render... prevent looping...
12928 this._initEventsCalled = true;
12931 throw "can not find store for combo";
12934 this.store = Roo.factory(this.store, Roo.data);
12936 // if we are building from html. then this element is so complex, that we can not really
12937 // use the rendered HTML.
12938 // so we have to trash and replace the previous code.
12939 if (Roo.XComponent.build_from_html) {
12941 // remove this element....
12942 var e = this.el.dom, k=0;
12943 while (e ) { e = e.previousSibling; ++k;}
12948 this.rendered = false;
12950 this.render(this.parent().getChildContainer(true), k);
12956 if(Roo.isIOS && this.useNativeIOS){
12957 this.initIOSView();
12965 if(Roo.isTouch && this.mobileTouchView){
12966 this.initTouchView();
12971 this.initTickableEvents();
12975 Roo.bootstrap.ComboBox.superclass.initEvents.call(this);
12977 if(this.hiddenName){
12979 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
12981 this.hiddenField.dom.value =
12982 this.hiddenValue !== undefined ? this.hiddenValue :
12983 this.value !== undefined ? this.value : '';
12985 // prevent input submission
12986 this.el.dom.removeAttribute('name');
12987 this.hiddenField.dom.setAttribute('name', this.hiddenName);
12992 // this.el.dom.setAttribute('autocomplete', 'off');
12995 var cls = 'x-combo-list';
12997 //this.list = new Roo.Layer({
12998 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
13004 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13005 _this.list.setWidth(lw);
13008 this.list.on('mouseover', this.onViewOver, this);
13009 this.list.on('mousemove', this.onViewMove, this);
13011 this.list.on('scroll', this.onViewScroll, this);
13014 this.list.swallowEvent('mousewheel');
13015 this.assetHeight = 0;
13018 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
13019 this.assetHeight += this.header.getHeight();
13022 this.innerList = this.list.createChild({cls:cls+'-inner'});
13023 this.innerList.on('mouseover', this.onViewOver, this);
13024 this.innerList.on('mousemove', this.onViewMove, this);
13025 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13027 if(this.allowBlank && !this.pageSize && !this.disableClear){
13028 this.footer = this.list.createChild({cls:cls+'-ft'});
13029 this.pageTb = new Roo.Toolbar(this.footer);
13033 this.footer = this.list.createChild({cls:cls+'-ft'});
13034 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
13035 {pageSize: this.pageSize});
13039 if (this.pageTb && this.allowBlank && !this.disableClear) {
13041 this.pageTb.add(new Roo.Toolbar.Fill(), {
13042 cls: 'x-btn-icon x-btn-clear',
13044 handler: function()
13047 _this.clearValue();
13048 _this.onSelect(false, -1);
13053 this.assetHeight += this.footer.getHeight();
13058 this.tpl = '<li><a href="#">{' + this.displayField + '}</a></li>';
13061 this.view = new Roo.View(this.list, this.tpl, {
13062 singleSelect:true, store: this.store, selectedClass: this.selectedClass
13064 //this.view.wrapEl.setDisplayed(false);
13065 this.view.on('click', this.onViewClick, this);
13069 this.store.on('beforeload', this.onBeforeLoad, this);
13070 this.store.on('load', this.onLoad, this);
13071 this.store.on('loadexception', this.onLoadException, this);
13073 if(this.resizable){
13074 this.resizer = new Roo.Resizable(this.list, {
13075 pinned:true, handles:'se'
13077 this.resizer.on('resize', function(r, w, h){
13078 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
13079 this.listWidth = w;
13080 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
13081 this.restrictHeight();
13083 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
13086 if(!this.editable){
13087 this.editable = true;
13088 this.setEditable(false);
13093 if (typeof(this.events.add.listeners) != 'undefined') {
13095 this.addicon = this.wrap.createChild(
13096 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
13098 this.addicon.on('click', function(e) {
13099 this.fireEvent('add', this);
13102 if (typeof(this.events.edit.listeners) != 'undefined') {
13104 this.editicon = this.wrap.createChild(
13105 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
13106 if (this.addicon) {
13107 this.editicon.setStyle('margin-left', '40px');
13109 this.editicon.on('click', function(e) {
13111 // we fire even if inothing is selected..
13112 this.fireEvent('edit', this, this.lastData );
13118 this.keyNav = new Roo.KeyNav(this.inputEl(), {
13119 "up" : function(e){
13120 this.inKeyMode = true;
13124 "down" : function(e){
13125 if(!this.isExpanded()){
13126 this.onTriggerClick();
13128 this.inKeyMode = true;
13133 "enter" : function(e){
13134 // this.onViewClick();
13138 if(this.fireEvent("specialkey", this, e)){
13139 this.onViewClick(false);
13145 "esc" : function(e){
13149 "tab" : function(e){
13152 if(this.fireEvent("specialkey", this, e)){
13153 this.onViewClick(false);
13161 doRelay : function(foo, bar, hname){
13162 if(hname == 'down' || this.scope.isExpanded()){
13163 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13172 this.queryDelay = Math.max(this.queryDelay || 10,
13173 this.mode == 'local' ? 10 : 250);
13176 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13178 if(this.typeAhead){
13179 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13181 if(this.editable !== false){
13182 this.inputEl().on("keyup", this.onKeyUp, this);
13184 if(this.forceSelection){
13185 this.inputEl().on('blur', this.doForce, this);
13189 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13190 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13194 initTickableEvents: function()
13198 if(this.hiddenName){
13200 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
13202 this.hiddenField.dom.value =
13203 this.hiddenValue !== undefined ? this.hiddenValue :
13204 this.value !== undefined ? this.value : '';
13206 // prevent input submission
13207 this.el.dom.removeAttribute('name');
13208 this.hiddenField.dom.setAttribute('name', this.hiddenName);
13213 // this.list = this.el.select('ul.dropdown-menu',true).first();
13215 this.choices = this.el.select('ul.roo-select2-choices', true).first();
13216 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
13217 if(this.triggerList){
13218 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
13221 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
13222 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
13224 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
13225 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
13227 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
13228 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
13230 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
13231 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
13232 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
13235 this.cancelBtn.hide();
13240 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
13241 _this.list.setWidth(lw);
13244 this.list.on('mouseover', this.onViewOver, this);
13245 this.list.on('mousemove', this.onViewMove, this);
13247 this.list.on('scroll', this.onViewScroll, this);
13250 this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}" type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
13253 this.view = new Roo.View(this.list, this.tpl, {
13254 singleSelect:true, tickable:true, parent:this, store: this.store, selectedClass: this.selectedClass
13257 //this.view.wrapEl.setDisplayed(false);
13258 this.view.on('click', this.onViewClick, this);
13262 this.store.on('beforeload', this.onBeforeLoad, this);
13263 this.store.on('load', this.onLoad, this);
13264 this.store.on('loadexception', this.onLoadException, this);
13267 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
13268 "up" : function(e){
13269 this.inKeyMode = true;
13273 "down" : function(e){
13274 this.inKeyMode = true;
13278 "enter" : function(e){
13279 if(this.fireEvent("specialkey", this, e)){
13280 this.onViewClick(false);
13286 "esc" : function(e){
13287 this.onTickableFooterButtonClick(e, false, false);
13290 "tab" : function(e){
13291 this.fireEvent("specialkey", this, e);
13293 this.onTickableFooterButtonClick(e, false, false);
13300 doRelay : function(e, fn, key){
13301 if(this.scope.isExpanded()){
13302 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
13311 this.queryDelay = Math.max(this.queryDelay || 10,
13312 this.mode == 'local' ? 10 : 250);
13315 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
13317 if(this.typeAhead){
13318 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
13321 if(this.editable !== false){
13322 this.tickableInputEl().on("keyup", this.onKeyUp, this);
13325 this.indicator = this.indicatorEl();
13327 if(this.indicator){
13328 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
13329 this.indicator.hide();
13334 onDestroy : function(){
13336 this.view.setStore(null);
13337 this.view.el.removeAllListeners();
13338 this.view.el.remove();
13339 this.view.purgeListeners();
13342 this.list.dom.innerHTML = '';
13346 this.store.un('beforeload', this.onBeforeLoad, this);
13347 this.store.un('load', this.onLoad, this);
13348 this.store.un('loadexception', this.onLoadException, this);
13350 Roo.bootstrap.ComboBox.superclass.onDestroy.call(this);
13354 fireKey : function(e){
13355 if(e.isNavKeyPress() && !this.list.isVisible()){
13356 this.fireEvent("specialkey", this, e);
13361 onResize: function(w, h){
13362 // Roo.bootstrap.ComboBox.superclass.onResize.apply(this, arguments);
13364 // if(typeof w != 'number'){
13365 // // we do not handle it!?!?
13368 // var tw = this.trigger.getWidth();
13369 // // tw += this.addicon ? this.addicon.getWidth() : 0;
13370 // // tw += this.editicon ? this.editicon.getWidth() : 0;
13372 // this.inputEl().setWidth( this.adjustWidth('input', x));
13374 // //this.trigger.setStyle('left', x+'px');
13376 // if(this.list && this.listWidth === undefined){
13377 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
13378 // this.list.setWidth(lw);
13379 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
13387 * Allow or prevent the user from directly editing the field text. If false is passed,
13388 * the user will only be able to select from the items defined in the dropdown list. This method
13389 * is the runtime equivalent of setting the 'editable' config option at config time.
13390 * @param {Boolean} value True to allow the user to directly edit the field text
13392 setEditable : function(value){
13393 if(value == this.editable){
13396 this.editable = value;
13398 this.inputEl().dom.setAttribute('readOnly', true);
13399 this.inputEl().on('mousedown', this.onTriggerClick, this);
13400 this.inputEl().addClass('x-combo-noedit');
13402 this.inputEl().dom.setAttribute('readOnly', false);
13403 this.inputEl().un('mousedown', this.onTriggerClick, this);
13404 this.inputEl().removeClass('x-combo-noedit');
13410 onBeforeLoad : function(combo,opts){
13411 if(!this.hasFocus){
13415 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
13417 this.restrictHeight();
13418 this.selectedIndex = -1;
13422 onLoad : function(){
13424 this.hasQuery = false;
13426 if(!this.hasFocus){
13430 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
13431 this.loading.hide();
13434 if(this.store.getCount() > 0){
13436 this.restrictHeight();
13437 if(this.lastQuery == this.allQuery){
13438 if(this.editable && !this.tickable){
13439 this.inputEl().dom.select();
13443 !this.selectByValue(this.value, true) &&
13446 !this.store.lastOptions ||
13447 typeof(this.store.lastOptions.add) == 'undefined' ||
13448 this.store.lastOptions.add != true
13451 this.select(0, true);
13454 if(this.autoFocus){
13457 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
13458 this.taTask.delay(this.typeAheadDelay);
13462 this.onEmptyResults();
13468 onLoadException : function()
13470 this.hasQuery = false;
13472 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
13473 this.loading.hide();
13476 if(this.tickable && this.editable){
13481 // only causes errors at present
13482 //Roo.log(this.store.reader.jsonData);
13483 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
13485 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
13491 onTypeAhead : function(){
13492 if(this.store.getCount() > 0){
13493 var r = this.store.getAt(0);
13494 var newValue = r.data[this.displayField];
13495 var len = newValue.length;
13496 var selStart = this.getRawValue().length;
13498 if(selStart != len){
13499 this.setRawValue(newValue);
13500 this.selectText(selStart, newValue.length);
13506 onSelect : function(record, index){
13508 if(this.fireEvent('beforeselect', this, record, index) !== false){
13510 this.setFromData(index > -1 ? record.data : false);
13513 this.fireEvent('select', this, record, index);
13518 * Returns the currently selected field value or empty string if no value is set.
13519 * @return {String} value The selected value
13521 getValue : function()
13523 if(Roo.isIOS && this.useNativeIOS){
13524 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
13528 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
13531 if(this.valueField){
13532 return typeof this.value != 'undefined' ? this.value : '';
13534 return Roo.bootstrap.ComboBox.superclass.getValue.call(this);
13538 getRawValue : function()
13540 if(Roo.isIOS && this.useNativeIOS){
13541 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
13544 var v = this.inputEl().getValue();
13550 * Clears any text/value currently set in the field
13552 clearValue : function(){
13554 if(this.hiddenField){
13555 this.hiddenField.dom.value = '';
13558 this.setRawValue('');
13559 this.lastSelectionText = '';
13560 this.lastData = false;
13562 var close = this.closeTriggerEl();
13573 * Sets the specified value into the field. If the value finds a match, the corresponding record text
13574 * will be displayed in the field. If the value does not match the data value of an existing item,
13575 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
13576 * Otherwise the field will be blank (although the value will still be set).
13577 * @param {String} value The value to match
13579 setValue : function(v)
13581 if(Roo.isIOS && this.useNativeIOS){
13582 this.setIOSValue(v);
13592 if(this.valueField){
13593 var r = this.findRecord(this.valueField, v);
13595 text = r.data[this.displayField];
13596 }else if(this.valueNotFoundText !== undefined){
13597 text = this.valueNotFoundText;
13600 this.lastSelectionText = text;
13601 if(this.hiddenField){
13602 this.hiddenField.dom.value = v;
13604 Roo.bootstrap.ComboBox.superclass.setValue.call(this, text);
13607 var close = this.closeTriggerEl();
13610 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
13616 * @property {Object} the last set data for the element
13621 * Sets the value of the field based on a object which is related to the record format for the store.
13622 * @param {Object} value the value to set as. or false on reset?
13624 setFromData : function(o){
13631 var dv = ''; // display value
13632 var vv = ''; // value value..
13634 if (this.displayField) {
13635 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
13637 // this is an error condition!!!
13638 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
13641 if(this.valueField){
13642 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
13645 var close = this.closeTriggerEl();
13648 (vv.length || vv * 1 > 0) ? close.show() : close.hide();
13651 if(this.hiddenField){
13652 this.hiddenField.dom.value = vv;
13654 this.lastSelectionText = dv;
13655 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
13659 // no hidden field.. - we store the value in 'value', but still display
13660 // display field!!!!
13661 this.lastSelectionText = dv;
13662 Roo.bootstrap.ComboBox.superclass.setValue.call(this, dv);
13669 reset : function(){
13670 // overridden so that last data is reset..
13677 this.setValue(this.originalValue);
13678 //this.clearInvalid();
13679 this.lastData = false;
13681 this.view.clearSelections();
13687 findRecord : function(prop, value){
13689 if(this.store.getCount() > 0){
13690 this.store.each(function(r){
13691 if(r.data[prop] == value){
13701 getName: function()
13703 // returns hidden if it's set..
13704 if (!this.rendered) {return ''};
13705 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
13709 onViewMove : function(e, t){
13710 this.inKeyMode = false;
13714 onViewOver : function(e, t){
13715 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
13718 var item = this.view.findItemFromChild(t);
13721 var index = this.view.indexOf(item);
13722 this.select(index, false);
13727 onViewClick : function(view, doFocus, el, e)
13729 var index = this.view.getSelectedIndexes()[0];
13731 var r = this.store.getAt(index);
13735 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
13742 Roo.each(this.tickItems, function(v,k){
13744 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
13746 _this.tickItems.splice(k, 1);
13748 if(typeof(e) == 'undefined' && view == false){
13749 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
13761 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
13762 this.tickItems.push(r.data);
13765 if(typeof(e) == 'undefined' && view == false){
13766 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
13773 this.onSelect(r, index);
13775 if(doFocus !== false && !this.blockFocus){
13776 this.inputEl().focus();
13781 restrictHeight : function(){
13782 //this.innerList.dom.style.height = '';
13783 //var inner = this.innerList.dom;
13784 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
13785 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
13786 //this.list.beginUpdate();
13787 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
13788 this.list.alignTo(this.inputEl(), this.listAlign);
13789 this.list.alignTo(this.inputEl(), this.listAlign);
13790 //this.list.endUpdate();
13794 onEmptyResults : function(){
13796 if(this.tickable && this.editable){
13797 this.restrictHeight();
13805 * Returns true if the dropdown list is expanded, else false.
13807 isExpanded : function(){
13808 return this.list.isVisible();
13812 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
13813 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
13814 * @param {String} value The data value of the item to select
13815 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
13816 * selected item if it is not currently in view (defaults to true)
13817 * @return {Boolean} True if the value matched an item in the list, else false
13819 selectByValue : function(v, scrollIntoView){
13820 if(v !== undefined && v !== null){
13821 var r = this.findRecord(this.valueField || this.displayField, v);
13823 this.select(this.store.indexOf(r), scrollIntoView);
13831 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
13832 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
13833 * @param {Number} index The zero-based index of the list item to select
13834 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
13835 * selected item if it is not currently in view (defaults to true)
13837 select : function(index, scrollIntoView){
13838 this.selectedIndex = index;
13839 this.view.select(index);
13840 if(scrollIntoView !== false){
13841 var el = this.view.getNode(index);
13843 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
13846 this.list.scrollChildIntoView(el, false);
13852 selectNext : function(){
13853 var ct = this.store.getCount();
13855 if(this.selectedIndex == -1){
13857 }else if(this.selectedIndex < ct-1){
13858 this.select(this.selectedIndex+1);
13864 selectPrev : function(){
13865 var ct = this.store.getCount();
13867 if(this.selectedIndex == -1){
13869 }else if(this.selectedIndex != 0){
13870 this.select(this.selectedIndex-1);
13876 onKeyUp : function(e){
13877 if(this.editable !== false && !e.isSpecialKey()){
13878 this.lastKey = e.getKey();
13879 this.dqTask.delay(this.queryDelay);
13884 validateBlur : function(){
13885 return !this.list || !this.list.isVisible();
13889 initQuery : function(){
13891 var v = this.getRawValue();
13893 if(this.tickable && this.editable){
13894 v = this.tickableInputEl().getValue();
13901 doForce : function(){
13902 if(this.inputEl().dom.value.length > 0){
13903 this.inputEl().dom.value =
13904 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
13910 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
13911 * query allowing the query action to be canceled if needed.
13912 * @param {String} query The SQL query to execute
13913 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
13914 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
13915 * saved in the current store (defaults to false)
13917 doQuery : function(q, forceAll){
13919 if(q === undefined || q === null){
13924 forceAll: forceAll,
13928 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
13933 forceAll = qe.forceAll;
13934 if(forceAll === true || (q.length >= this.minChars)){
13936 this.hasQuery = true;
13938 if(this.lastQuery != q || this.alwaysQuery){
13939 this.lastQuery = q;
13940 if(this.mode == 'local'){
13941 this.selectedIndex = -1;
13943 this.store.clearFilter();
13946 if(this.specialFilter){
13947 this.fireEvent('specialfilter', this);
13952 this.store.filter(this.displayField, q);
13955 this.store.fireEvent("datachanged", this.store);
13962 this.store.baseParams[this.queryParam] = q;
13964 var options = {params : this.getParams(q)};
13967 options.add = true;
13968 options.params.start = this.page * this.pageSize;
13971 this.store.load(options);
13974 * this code will make the page width larger, at the beginning, the list not align correctly,
13975 * we should expand the list on onLoad
13976 * so command out it
13981 this.selectedIndex = -1;
13986 this.loadNext = false;
13990 getParams : function(q){
13992 //p[this.queryParam] = q;
13996 p.limit = this.pageSize;
14002 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
14004 collapse : function(){
14005 if(!this.isExpanded()){
14011 this.hasFocus = false;
14015 this.cancelBtn.hide();
14016 this.trigger.show();
14019 this.tickableInputEl().dom.value = '';
14020 this.tickableInputEl().blur();
14025 Roo.get(document).un('mousedown', this.collapseIf, this);
14026 Roo.get(document).un('mousewheel', this.collapseIf, this);
14027 if (!this.editable) {
14028 Roo.get(document).un('keydown', this.listKeyPress, this);
14030 this.fireEvent('collapse', this);
14036 collapseIf : function(e){
14037 var in_combo = e.within(this.el);
14038 var in_list = e.within(this.list);
14039 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
14041 if (in_combo || in_list || is_list) {
14042 //e.stopPropagation();
14047 this.onTickableFooterButtonClick(e, false, false);
14055 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
14057 expand : function(){
14059 if(this.isExpanded() || !this.hasFocus){
14063 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
14064 this.list.setWidth(lw);
14070 this.restrictHeight();
14074 this.tickItems = Roo.apply([], this.item);
14077 this.cancelBtn.show();
14078 this.trigger.hide();
14081 this.tickableInputEl().focus();
14086 Roo.get(document).on('mousedown', this.collapseIf, this);
14087 Roo.get(document).on('mousewheel', this.collapseIf, this);
14088 if (!this.editable) {
14089 Roo.get(document).on('keydown', this.listKeyPress, this);
14092 this.fireEvent('expand', this);
14096 // Implements the default empty TriggerField.onTriggerClick function
14097 onTriggerClick : function(e)
14099 Roo.log('trigger click');
14101 if(this.disabled || !this.triggerList){
14106 this.loadNext = false;
14108 if(this.isExpanded()){
14110 if (!this.blockFocus) {
14111 this.inputEl().focus();
14115 this.hasFocus = true;
14116 if(this.triggerAction == 'all') {
14117 this.doQuery(this.allQuery, true);
14119 this.doQuery(this.getRawValue());
14121 if (!this.blockFocus) {
14122 this.inputEl().focus();
14127 onTickableTriggerClick : function(e)
14134 this.loadNext = false;
14135 this.hasFocus = true;
14137 if(this.triggerAction == 'all') {
14138 this.doQuery(this.allQuery, true);
14140 this.doQuery(this.getRawValue());
14144 onSearchFieldClick : function(e)
14146 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
14147 this.onTickableFooterButtonClick(e, false, false);
14151 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
14156 this.loadNext = false;
14157 this.hasFocus = true;
14159 if(this.triggerAction == 'all') {
14160 this.doQuery(this.allQuery, true);
14162 this.doQuery(this.getRawValue());
14166 listKeyPress : function(e)
14168 //Roo.log('listkeypress');
14169 // scroll to first matching element based on key pres..
14170 if (e.isSpecialKey()) {
14173 var k = String.fromCharCode(e.getKey()).toUpperCase();
14176 var csel = this.view.getSelectedNodes();
14177 var cselitem = false;
14179 var ix = this.view.indexOf(csel[0]);
14180 cselitem = this.store.getAt(ix);
14181 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
14187 this.store.each(function(v) {
14189 // start at existing selection.
14190 if (cselitem.id == v.id) {
14196 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
14197 match = this.store.indexOf(v);
14203 if (match === false) {
14204 return true; // no more action?
14207 this.view.select(match);
14208 var sn = Roo.get(this.view.getSelectedNodes()[0]);
14209 sn.scrollIntoView(sn.dom.parentNode, false);
14212 onViewScroll : function(e, t){
14214 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){
14218 this.hasQuery = true;
14220 this.loading = this.list.select('.loading', true).first();
14222 if(this.loading === null){
14223 this.list.createChild({
14225 cls: 'loading roo-select2-more-results roo-select2-active',
14226 html: 'Loading more results...'
14229 this.loading = this.list.select('.loading', true).first();
14231 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
14233 this.loading.hide();
14236 this.loading.show();
14241 this.loadNext = true;
14243 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
14248 addItem : function(o)
14250 var dv = ''; // display value
14252 if (this.displayField) {
14253 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
14255 // this is an error condition!!!
14256 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
14263 var choice = this.choices.createChild({
14265 cls: 'roo-select2-search-choice',
14274 cls: 'roo-select2-search-choice-close',
14279 }, this.searchField);
14281 var close = choice.select('a.roo-select2-search-choice-close', true).first();
14283 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
14291 this.inputEl().dom.value = '';
14296 onRemoveItem : function(e, _self, o)
14298 e.preventDefault();
14300 this.lastItem = Roo.apply([], this.item);
14302 var index = this.item.indexOf(o.data) * 1;
14305 Roo.log('not this item?!');
14309 this.item.splice(index, 1);
14314 this.fireEvent('remove', this, e);
14320 syncValue : function()
14322 if(!this.item.length){
14329 Roo.each(this.item, function(i){
14330 if(_this.valueField){
14331 value.push(i[_this.valueField]);
14338 this.value = value.join(',');
14340 if(this.hiddenField){
14341 this.hiddenField.dom.value = this.value;
14344 this.store.fireEvent("datachanged", this.store);
14349 clearItem : function()
14351 if(!this.multiple){
14357 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
14365 if(this.tickable && !Roo.isTouch){
14366 this.view.refresh();
14370 inputEl: function ()
14372 if(Roo.isIOS && this.useNativeIOS){
14373 return this.el.select('select.roo-ios-select', true).first();
14376 if(Roo.isTouch && this.mobileTouchView){
14377 return this.el.select('input.form-control',true).first();
14381 return this.searchField;
14384 return this.el.select('input.form-control',true).first();
14387 onTickableFooterButtonClick : function(e, btn, el)
14389 e.preventDefault();
14391 this.lastItem = Roo.apply([], this.item);
14393 if(btn && btn.name == 'cancel'){
14394 this.tickItems = Roo.apply([], this.item);
14403 Roo.each(this.tickItems, function(o){
14411 validate : function()
14413 var v = this.getRawValue();
14416 v = this.getValue();
14419 if(this.disabled || this.allowBlank || v.length){
14424 this.markInvalid();
14428 tickableInputEl : function()
14430 if(!this.tickable || !this.editable){
14431 return this.inputEl();
14434 return this.inputEl().select('.roo-select2-search-field-input', true).first();
14438 getAutoCreateTouchView : function()
14443 cls: 'form-group' //input-group
14449 type : this.inputType,
14450 cls : 'form-control x-combo-noedit',
14451 autocomplete: 'new-password',
14452 placeholder : this.placeholder || '',
14457 input.name = this.name;
14461 input.cls += ' input-' + this.size;
14464 if (this.disabled) {
14465 input.disabled = true;
14476 inputblock.cls += ' input-group';
14478 inputblock.cn.unshift({
14480 cls : 'input-group-addon',
14485 if(this.removable && !this.multiple){
14486 inputblock.cls += ' roo-removable';
14488 inputblock.cn.push({
14491 cls : 'roo-combo-removable-btn close'
14495 if(this.hasFeedback && !this.allowBlank){
14497 inputblock.cls += ' has-feedback';
14499 inputblock.cn.push({
14501 cls: 'glyphicon form-control-feedback'
14508 inputblock.cls += (this.before) ? '' : ' input-group';
14510 inputblock.cn.push({
14512 cls : 'input-group-addon',
14523 cls: 'form-hidden-field'
14537 cls: 'form-hidden-field'
14541 cls: 'roo-select2-choices',
14545 cls: 'roo-select2-search-field',
14558 cls: 'roo-select2-container input-group roo-touchview-combobox ',
14564 if(!this.multiple && this.showToggleBtn){
14571 if (this.caret != false) {
14574 cls: 'fa fa-' + this.caret
14581 cls : 'input-group-addon btn dropdown-toggle',
14586 cls: 'combobox-clear',
14600 combobox.cls += ' roo-select2-container-multi';
14603 var align = this.labelAlign || this.parentLabelAlign();
14605 if (align ==='left' && this.fieldLabel.length) {
14610 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
14611 tooltip : 'This field is required'
14615 cls : 'control-label',
14616 html : this.fieldLabel
14627 var labelCfg = cfg.cn[1];
14628 var contentCfg = cfg.cn[2];
14631 if(this.indicatorpos == 'right'){
14635 cls : 'control-label',
14636 html : this.fieldLabel,
14640 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
14641 tooltip : 'This field is required'
14654 labelCfg = cfg.cn[0];
14655 contentCfg = cfg.cn[2];
14657 if(this.labelWidth > 12){
14658 labelCfg.style = "width: " + this.labelWidth + 'px';
14661 if(this.labelWidth < 13 && this.labelmd == 0){
14662 this.labelmd = this.labelWidth;
14665 if(this.labellg > 0){
14666 labelCfg.cls += ' col-lg-' + this.labellg;
14667 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
14670 if(this.labelmd > 0){
14671 labelCfg.cls += ' col-md-' + this.labelmd;
14672 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
14675 if(this.labelsm > 0){
14676 labelCfg.cls += ' col-sm-' + this.labelsm;
14677 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
14680 if(this.labelxs > 0){
14681 labelCfg.cls += ' col-xs-' + this.labelxs;
14682 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
14686 } else if ( this.fieldLabel.length) {
14690 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
14691 tooltip : 'This field is required'
14695 cls : 'control-label',
14696 html : this.fieldLabel
14707 if(this.indicatorpos == 'right'){
14711 cls : 'control-label',
14712 html : this.fieldLabel,
14716 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
14717 tooltip : 'This field is required'
14734 var settings = this;
14736 ['xs','sm','md','lg'].map(function(size){
14737 if (settings[size]) {
14738 cfg.cls += ' col-' + size + '-' + settings[size];
14745 initTouchView : function()
14747 this.renderTouchView();
14749 this.touchViewEl.on('scroll', function(){
14750 this.el.dom.scrollTop = 0;
14753 this.originalValue = this.getValue();
14755 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
14757 this.inputEl().on("click", this.showTouchView, this);
14758 if (this.triggerEl) {
14759 this.triggerEl.on("click", this.showTouchView, this);
14763 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
14764 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
14766 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
14768 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
14769 this.store.on('load', this.onTouchViewLoad, this);
14770 this.store.on('loadexception', this.onTouchViewLoadException, this);
14772 if(this.hiddenName){
14774 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
14776 this.hiddenField.dom.value =
14777 this.hiddenValue !== undefined ? this.hiddenValue :
14778 this.value !== undefined ? this.value : '';
14780 this.el.dom.removeAttribute('name');
14781 this.hiddenField.dom.setAttribute('name', this.hiddenName);
14785 this.choices = this.el.select('ul.roo-select2-choices', true).first();
14786 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
14789 if(this.removable && !this.multiple){
14790 var close = this.closeTriggerEl();
14792 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
14793 close.on('click', this.removeBtnClick, this, close);
14797 * fix the bug in Safari iOS8
14799 this.inputEl().on("focus", function(e){
14800 document.activeElement.blur();
14808 renderTouchView : function()
14810 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.ComboBox.touchViewTemplate);
14811 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
14813 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
14814 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
14816 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
14817 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
14818 this.touchViewBodyEl.setStyle('overflow', 'auto');
14820 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
14821 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
14823 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
14824 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
14828 showTouchView : function()
14834 this.touchViewHeaderEl.hide();
14836 if(this.modalTitle.length){
14837 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
14838 this.touchViewHeaderEl.show();
14841 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
14842 this.touchViewEl.show();
14844 this.touchViewEl.select('.modal-dialog', true).first().setStyle('margin', '0px');
14845 this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
14846 Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
14848 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
14850 if(this.modalTitle.length){
14851 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
14854 this.touchViewBodyEl.setHeight(bodyHeight);
14858 (function(){ _this.touchViewEl.addClass('in'); }).defer(50);
14860 this.touchViewEl.addClass('in');
14863 this.doTouchViewQuery();
14867 hideTouchView : function()
14869 this.touchViewEl.removeClass('in');
14873 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
14875 this.touchViewEl.setStyle('display', 'none');
14880 setTouchViewValue : function()
14887 Roo.each(this.tickItems, function(o){
14892 this.hideTouchView();
14895 doTouchViewQuery : function()
14904 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
14908 if(!this.alwaysQuery || this.mode == 'local'){
14909 this.onTouchViewLoad();
14916 onTouchViewBeforeLoad : function(combo,opts)
14922 onTouchViewLoad : function()
14924 if(this.store.getCount() < 1){
14925 this.onTouchViewEmptyResults();
14929 this.clearTouchView();
14931 var rawValue = this.getRawValue();
14933 var template = (this.multiple) ? Roo.bootstrap.ComboBox.listItemCheckbox : Roo.bootstrap.ComboBox.listItemRadio;
14935 this.tickItems = [];
14937 this.store.data.each(function(d, rowIndex){
14938 var row = this.touchViewListGroup.createChild(template);
14940 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
14941 row.addClass(d.data.cls);
14944 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
14947 html : d.data[this.displayField]
14950 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
14951 row.select('.roo-combobox-list-group-item-value', true).first().dom.innerHTML = cfg.html;
14954 row.removeClass('selected');
14955 if(!this.multiple && this.valueField &&
14956 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
14959 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
14960 row.addClass('selected');
14963 if(this.multiple && this.valueField &&
14964 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
14968 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
14969 this.tickItems.push(d.data);
14972 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
14976 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).first();
14978 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
14980 if(this.modalTitle.length){
14981 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
14984 var listHeight = this.touchViewListGroup.getHeight();
14988 if(firstChecked && listHeight > bodyHeight){
14989 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
14994 onTouchViewLoadException : function()
14996 this.hideTouchView();
14999 onTouchViewEmptyResults : function()
15001 this.clearTouchView();
15003 this.touchViewListGroup.createChild(Roo.bootstrap.ComboBox.emptyResult);
15005 this.touchViewListGroup.select('.roo-combobox-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
15009 clearTouchView : function()
15011 this.touchViewListGroup.dom.innerHTML = '';
15014 onTouchViewClick : function(e, el, o)
15016 e.preventDefault();
15019 var rowIndex = o.rowIndex;
15021 var r = this.store.getAt(rowIndex);
15023 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
15025 if(!this.multiple){
15026 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-combobox-list-group-item-box > input:checked', true).elements, function(c){
15027 c.dom.removeAttribute('checked');
15030 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15032 this.setFromData(r.data);
15034 var close = this.closeTriggerEl();
15040 this.hideTouchView();
15042 this.fireEvent('select', this, r, rowIndex);
15047 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
15048 row.select('.roo-combobox-list-group-item-box > input', true).first().dom.removeAttribute('checked');
15049 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
15053 row.select('.roo-combobox-list-group-item-box > input', true).first().attr('checked', true);
15054 this.addItem(r.data);
15055 this.tickItems.push(r.data);
15059 getAutoCreateNativeIOS : function()
15062 cls: 'form-group' //input-group,
15067 cls : 'roo-ios-select'
15071 combobox.name = this.name;
15074 if (this.disabled) {
15075 combobox.disabled = true;
15078 var settings = this;
15080 ['xs','sm','md','lg'].map(function(size){
15081 if (settings[size]) {
15082 cfg.cls += ' col-' + size + '-' + settings[size];
15092 initIOSView : function()
15094 this.store.on('load', this.onIOSViewLoad, this);
15099 onIOSViewLoad : function()
15101 if(this.store.getCount() < 1){
15105 this.clearIOSView();
15107 if(this.allowBlank) {
15109 var default_text = '-- SELECT --';
15111 var opt = this.inputEl().createChild({
15114 html : default_text
15118 o[this.valueField] = 0;
15119 o[this.displayField] = default_text;
15121 this.ios_options.push({
15128 this.store.data.each(function(d, rowIndex){
15132 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
15133 html = d.data[this.displayField];
15138 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
15139 value = d.data[this.valueField];
15148 if(this.value == d.data[this.valueField]){
15149 option['selected'] = true;
15152 var opt = this.inputEl().createChild(option);
15154 this.ios_options.push({
15161 this.inputEl().on('change', function(){
15162 this.fireEvent('select', this);
15167 clearIOSView: function()
15169 this.inputEl().dom.innerHTML = '';
15171 this.ios_options = [];
15174 setIOSValue: function(v)
15178 if(!this.ios_options){
15182 Roo.each(this.ios_options, function(opts){
15184 opts.el.dom.removeAttribute('selected');
15186 if(opts.data[this.valueField] != v){
15190 opts.el.dom.setAttribute('selected', true);
15196 * @cfg {Boolean} grow
15200 * @cfg {Number} growMin
15204 * @cfg {Number} growMax
15213 Roo.apply(Roo.bootstrap.ComboBox, {
15217 cls: 'modal-header',
15239 cls: 'list-group-item',
15243 cls: 'roo-combobox-list-group-item-value'
15247 cls: 'roo-combobox-list-group-item-box pull-xs-right radio-inline radio radio-info',
15261 listItemCheckbox : {
15263 cls: 'list-group-item',
15267 cls: 'roo-combobox-list-group-item-value'
15271 cls: 'roo-combobox-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
15287 cls: 'alert alert-danger roo-combobox-touch-view-empty-result'
15292 cls: 'modal-footer',
15300 cls: 'col-xs-6 text-left',
15303 cls: 'btn btn-danger roo-touch-view-cancel',
15309 cls: 'col-xs-6 text-right',
15312 cls: 'btn btn-success roo-touch-view-ok',
15323 Roo.apply(Roo.bootstrap.ComboBox, {
15325 touchViewTemplate : {
15327 cls: 'modal fade roo-combobox-touch-view',
15331 cls: 'modal-dialog',
15332 style : 'position:fixed', // we have to fix position....
15336 cls: 'modal-content',
15338 Roo.bootstrap.ComboBox.header,
15339 Roo.bootstrap.ComboBox.body,
15340 Roo.bootstrap.ComboBox.footer
15349 * Ext JS Library 1.1.1
15350 * Copyright(c) 2006-2007, Ext JS, LLC.
15352 * Originally Released Under LGPL - original licence link has changed is not relivant.
15355 * <script type="text/javascript">
15360 * @extends Roo.util.Observable
15361 * Create a "View" for an element based on a data model or UpdateManager and the supplied DomHelper template.
15362 * This class also supports single and multi selection modes. <br>
15363 * Create a data model bound view:
15365 var store = new Roo.data.Store(...);
15367 var view = new Roo.View({
15369 tpl : '<div id="{0}">{2} - {1}</div>', // auto create template
15371 singleSelect: true,
15372 selectedClass: "ydataview-selected",
15376 // listen for node click?
15377 view.on("click", function(vw, index, node, e){
15378 alert('Node "' + node.id + '" at index: ' + index + " was clicked.");
15382 dataModel.load("foobar.xml");
15384 For an example of creating a JSON/UpdateManager view, see {@link Roo.JsonView}.
15386 * <b>Note: The root of your template must be a single node. Table/row implementations may work but are not supported due to
15387 * IE"s limited insertion support with tables and Opera"s faulty event bubbling.</b>
15389 * Note: old style constructor is still suported (container, template, config)
15392 * Create a new View
15393 * @param {Object} config The config object
15396 Roo.View = function(config, depreciated_tpl, depreciated_config){
15398 this.parent = false;
15400 if (typeof(depreciated_tpl) == 'undefined') {
15401 // new way.. - universal constructor.
15402 Roo.apply(this, config);
15403 this.el = Roo.get(this.el);
15406 this.el = Roo.get(config);
15407 this.tpl = depreciated_tpl;
15408 Roo.apply(this, depreciated_config);
15410 this.wrapEl = this.el.wrap().wrap();
15411 ///this.el = this.wrapEla.appendChild(document.createElement("div"));
15414 if(typeof(this.tpl) == "string"){
15415 this.tpl = new Roo.Template(this.tpl);
15417 // support xtype ctors..
15418 this.tpl = new Roo.factory(this.tpl, Roo);
15422 this.tpl.compile();
15427 * @event beforeclick
15428 * Fires before a click is processed. Returns false to cancel the default action.
15429 * @param {Roo.View} this
15430 * @param {Number} index The index of the target node
15431 * @param {HTMLElement} node The target node
15432 * @param {Roo.EventObject} e The raw event object
15434 "beforeclick" : true,
15437 * Fires when a template node is clicked.
15438 * @param {Roo.View} this
15439 * @param {Number} index The index of the target node
15440 * @param {HTMLElement} node The target node
15441 * @param {Roo.EventObject} e The raw event object
15446 * Fires when a template node is double clicked.
15447 * @param {Roo.View} this
15448 * @param {Number} index The index of the target node
15449 * @param {HTMLElement} node The target node
15450 * @param {Roo.EventObject} e The raw event object
15454 * @event contextmenu
15455 * Fires when a template node is right clicked.
15456 * @param {Roo.View} this
15457 * @param {Number} index The index of the target node
15458 * @param {HTMLElement} node The target node
15459 * @param {Roo.EventObject} e The raw event object
15461 "contextmenu" : true,
15463 * @event selectionchange
15464 * Fires when the selected nodes change.
15465 * @param {Roo.View} this
15466 * @param {Array} selections Array of the selected nodes
15468 "selectionchange" : true,
15471 * @event beforeselect
15472 * Fires before a selection is made. If any handlers return false, the selection is cancelled.
15473 * @param {Roo.View} this
15474 * @param {HTMLElement} node The node to be selected
15475 * @param {Array} selections Array of currently selected nodes
15477 "beforeselect" : true,
15479 * @event preparedata
15480 * Fires on every row to render, to allow you to change the data.
15481 * @param {Roo.View} this
15482 * @param {Object} data to be rendered (change this)
15484 "preparedata" : true
15492 "click": this.onClick,
15493 "dblclick": this.onDblClick,
15494 "contextmenu": this.onContextMenu,
15498 this.selections = [];
15500 this.cmp = new Roo.CompositeElementLite([]);
15502 this.store = Roo.factory(this.store, Roo.data);
15503 this.setStore(this.store, true);
15506 if ( this.footer && this.footer.xtype) {
15508 var fctr = this.wrapEl.appendChild(document.createElement("div"));
15510 this.footer.dataSource = this.store;
15511 this.footer.container = fctr;
15512 this.footer = Roo.factory(this.footer, Roo);
15513 fctr.insertFirst(this.el);
15515 // this is a bit insane - as the paging toolbar seems to detach the el..
15516 // dom.parentNode.parentNode.parentNode
15517 // they get detached?
15521 Roo.View.superclass.constructor.call(this);
15526 Roo.extend(Roo.View, Roo.util.Observable, {
15529 * @cfg {Roo.data.Store} store Data store to load data from.
15534 * @cfg {String|Roo.Element} el The container element.
15539 * @cfg {String|Roo.Template} tpl The template used by this View
15543 * @cfg {String} dataName the named area of the template to use as the data area
15544 * Works with domtemplates roo-name="name"
15548 * @cfg {String} selectedClass The css class to add to selected nodes
15550 selectedClass : "x-view-selected",
15552 * @cfg {String} emptyText The empty text to show when nothing is loaded.
15557 * @cfg {String} text to display on mask (default Loading)
15561 * @cfg {Boolean} multiSelect Allow multiple selection
15563 multiSelect : false,
15565 * @cfg {Boolean} singleSelect Allow single selection
15567 singleSelect: false,
15570 * @cfg {Boolean} toggleSelect - selecting
15572 toggleSelect : false,
15575 * @cfg {Boolean} tickable - selecting
15580 * Returns the element this view is bound to.
15581 * @return {Roo.Element}
15583 getEl : function(){
15584 return this.wrapEl;
15590 * Refreshes the view. - called by datachanged on the store. - do not call directly.
15592 refresh : function(){
15593 //Roo.log('refresh');
15596 // if we are using something like 'domtemplate', then
15597 // the what gets used is:
15598 // t.applySubtemplate(NAME, data, wrapping data..)
15599 // the outer template then get' applied with
15600 // the store 'extra data'
15601 // and the body get's added to the
15602 // roo-name="data" node?
15603 // <span class='roo-tpl-{name}'></span> ?????
15607 this.clearSelections();
15608 this.el.update("");
15610 var records = this.store.getRange();
15611 if(records.length < 1) {
15613 // is this valid?? = should it render a template??
15615 this.el.update(this.emptyText);
15619 if (this.dataName) {
15620 this.el.update(t.apply(this.store.meta)); //????
15621 el = this.el.child('.roo-tpl-' + this.dataName);
15624 for(var i = 0, len = records.length; i < len; i++){
15625 var data = this.prepareData(records[i].data, i, records[i]);
15626 this.fireEvent("preparedata", this, data, i, records[i]);
15628 var d = Roo.apply({}, data);
15631 Roo.apply(d, {'roo-id' : Roo.id()});
15635 Roo.each(this.parent.item, function(item){
15636 if(item[_this.parent.valueField] != data[_this.parent.valueField]){
15639 Roo.apply(d, {'roo-data-checked' : 'checked'});
15643 html[html.length] = Roo.util.Format.trim(
15645 t.applySubtemplate(this.dataName, d, this.store.meta) :
15652 el.update(html.join(""));
15653 this.nodes = el.dom.childNodes;
15654 this.updateIndexes(0);
15659 * Function to override to reformat the data that is sent to
15660 * the template for each node.
15661 * DEPRICATED - use the preparedata event handler.
15662 * @param {Array/Object} data The raw data (array of colData for a data model bound view or
15663 * a JSON object for an UpdateManager bound view).
15665 prepareData : function(data, index, record)
15667 this.fireEvent("preparedata", this, data, index, record);
15671 onUpdate : function(ds, record){
15672 // Roo.log('on update');
15673 this.clearSelections();
15674 var index = this.store.indexOf(record);
15675 var n = this.nodes[index];
15676 this.tpl.insertBefore(n, this.prepareData(record.data, index, record));
15677 n.parentNode.removeChild(n);
15678 this.updateIndexes(index, index);
15684 onAdd : function(ds, records, index)
15686 //Roo.log(['on Add', ds, records, index] );
15687 this.clearSelections();
15688 if(this.nodes.length == 0){
15692 var n = this.nodes[index];
15693 for(var i = 0, len = records.length; i < len; i++){
15694 var d = this.prepareData(records[i].data, i, records[i]);
15696 this.tpl.insertBefore(n, d);
15699 this.tpl.append(this.el, d);
15702 this.updateIndexes(index);
15705 onRemove : function(ds, record, index){
15706 // Roo.log('onRemove');
15707 this.clearSelections();
15708 var el = this.dataName ?
15709 this.el.child('.roo-tpl-' + this.dataName) :
15712 el.dom.removeChild(this.nodes[index]);
15713 this.updateIndexes(index);
15717 * Refresh an individual node.
15718 * @param {Number} index
15720 refreshNode : function(index){
15721 this.onUpdate(this.store, this.store.getAt(index));
15724 updateIndexes : function(startIndex, endIndex){
15725 var ns = this.nodes;
15726 startIndex = startIndex || 0;
15727 endIndex = endIndex || ns.length - 1;
15728 for(var i = startIndex; i <= endIndex; i++){
15729 ns[i].nodeIndex = i;
15734 * Changes the data store this view uses and refresh the view.
15735 * @param {Store} store
15737 setStore : function(store, initial){
15738 if(!initial && this.store){
15739 this.store.un("datachanged", this.refresh);
15740 this.store.un("add", this.onAdd);
15741 this.store.un("remove", this.onRemove);
15742 this.store.un("update", this.onUpdate);
15743 this.store.un("clear", this.refresh);
15744 this.store.un("beforeload", this.onBeforeLoad);
15745 this.store.un("load", this.onLoad);
15746 this.store.un("loadexception", this.onLoad);
15750 store.on("datachanged", this.refresh, this);
15751 store.on("add", this.onAdd, this);
15752 store.on("remove", this.onRemove, this);
15753 store.on("update", this.onUpdate, this);
15754 store.on("clear", this.refresh, this);
15755 store.on("beforeload", this.onBeforeLoad, this);
15756 store.on("load", this.onLoad, this);
15757 store.on("loadexception", this.onLoad, this);
15765 * onbeforeLoad - masks the loading area.
15768 onBeforeLoad : function(store,opts)
15770 //Roo.log('onBeforeLoad');
15772 this.el.update("");
15774 this.el.mask(this.mask ? this.mask : "Loading" );
15776 onLoad : function ()
15783 * Returns the template node the passed child belongs to or null if it doesn't belong to one.
15784 * @param {HTMLElement} node
15785 * @return {HTMLElement} The template node
15787 findItemFromChild : function(node){
15788 var el = this.dataName ?
15789 this.el.child('.roo-tpl-' + this.dataName,true) :
15792 if(!node || node.parentNode == el){
15795 var p = node.parentNode;
15796 while(p && p != el){
15797 if(p.parentNode == el){
15806 onClick : function(e){
15807 var item = this.findItemFromChild(e.getTarget());
15809 var index = this.indexOf(item);
15810 if(this.onItemClick(item, index, e) !== false){
15811 this.fireEvent("click", this, index, item, e);
15814 this.clearSelections();
15819 onContextMenu : function(e){
15820 var item = this.findItemFromChild(e.getTarget());
15822 this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
15827 onDblClick : function(e){
15828 var item = this.findItemFromChild(e.getTarget());
15830 this.fireEvent("dblclick", this, this.indexOf(item), item, e);
15834 onItemClick : function(item, index, e)
15836 if(this.fireEvent("beforeclick", this, index, item, e) === false){
15839 if (this.toggleSelect) {
15840 var m = this.isSelected(item) ? 'unselect' : 'select';
15843 _t[m](item, true, false);
15846 if(this.multiSelect || this.singleSelect){
15847 if(this.multiSelect && e.shiftKey && this.lastSelection){
15848 this.select(this.getNodes(this.indexOf(this.lastSelection), index), false);
15850 this.select(item, this.multiSelect && e.ctrlKey);
15851 this.lastSelection = item;
15854 if(!this.tickable){
15855 e.preventDefault();
15863 * Get the number of selected nodes.
15866 getSelectionCount : function(){
15867 return this.selections.length;
15871 * Get the currently selected nodes.
15872 * @return {Array} An array of HTMLElements
15874 getSelectedNodes : function(){
15875 return this.selections;
15879 * Get the indexes of the selected nodes.
15882 getSelectedIndexes : function(){
15883 var indexes = [], s = this.selections;
15884 for(var i = 0, len = s.length; i < len; i++){
15885 indexes.push(s[i].nodeIndex);
15891 * Clear all selections
15892 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange event
15894 clearSelections : function(suppressEvent){
15895 if(this.nodes && (this.multiSelect || this.singleSelect) && this.selections.length > 0){
15896 this.cmp.elements = this.selections;
15897 this.cmp.removeClass(this.selectedClass);
15898 this.selections = [];
15899 if(!suppressEvent){
15900 this.fireEvent("selectionchange", this, this.selections);
15906 * Returns true if the passed node is selected
15907 * @param {HTMLElement/Number} node The node or node index
15908 * @return {Boolean}
15910 isSelected : function(node){
15911 var s = this.selections;
15915 node = this.getNode(node);
15916 return s.indexOf(node) !== -1;
15921 * @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
15922 * @param {Boolean} keepExisting (optional) true to keep existing selections
15923 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
15925 select : function(nodeInfo, keepExisting, suppressEvent){
15926 if(nodeInfo instanceof Array){
15928 this.clearSelections(true);
15930 for(var i = 0, len = nodeInfo.length; i < len; i++){
15931 this.select(nodeInfo[i], true, true);
15935 var node = this.getNode(nodeInfo);
15936 if(!node || this.isSelected(node)){
15937 return; // already selected.
15940 this.clearSelections(true);
15943 if(this.fireEvent("beforeselect", this, node, this.selections) !== false){
15944 Roo.fly(node).addClass(this.selectedClass);
15945 this.selections.push(node);
15946 if(!suppressEvent){
15947 this.fireEvent("selectionchange", this, this.selections);
15955 * @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
15956 * @param {Boolean} keepExisting (optional) true IGNORED (for campatibility with select)
15957 * @param {Boolean} suppressEvent (optional) true to skip firing of the selectionchange vent
15959 unselect : function(nodeInfo, keepExisting, suppressEvent)
15961 if(nodeInfo instanceof Array){
15962 Roo.each(this.selections, function(s) {
15963 this.unselect(s, nodeInfo);
15967 var node = this.getNode(nodeInfo);
15968 if(!node || !this.isSelected(node)){
15969 //Roo.log("not selected");
15970 return; // not selected.
15974 Roo.each(this.selections, function(s) {
15976 Roo.fly(node).removeClass(this.selectedClass);
15983 this.selections= ns;
15984 this.fireEvent("selectionchange", this, this.selections);
15988 * Gets a template node.
15989 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
15990 * @return {HTMLElement} The node or null if it wasn't found
15992 getNode : function(nodeInfo){
15993 if(typeof nodeInfo == "string"){
15994 return document.getElementById(nodeInfo);
15995 }else if(typeof nodeInfo == "number"){
15996 return this.nodes[nodeInfo];
16002 * Gets a range template nodes.
16003 * @param {Number} startIndex
16004 * @param {Number} endIndex
16005 * @return {Array} An array of nodes
16007 getNodes : function(start, end){
16008 var ns = this.nodes;
16009 start = start || 0;
16010 end = typeof end == "undefined" ? ns.length - 1 : end;
16013 for(var i = start; i <= end; i++){
16017 for(var i = start; i >= end; i--){
16025 * Finds the index of the passed node
16026 * @param {HTMLElement/String/Number} nodeInfo An HTMLElement template node, index of a template node or the id of a template node
16027 * @return {Number} The index of the node or -1
16029 indexOf : function(node){
16030 node = this.getNode(node);
16031 if(typeof node.nodeIndex == "number"){
16032 return node.nodeIndex;
16034 var ns = this.nodes;
16035 for(var i = 0, len = ns.length; i < len; i++){
16046 * based on jquery fullcalendar
16050 Roo.bootstrap = Roo.bootstrap || {};
16052 * @class Roo.bootstrap.Calendar
16053 * @extends Roo.bootstrap.Component
16054 * Bootstrap Calendar class
16055 * @cfg {Boolean} loadMask (true|false) default false
16056 * @cfg {Object} header generate the user specific header of the calendar, default false
16059 * Create a new Container
16060 * @param {Object} config The config object
16065 Roo.bootstrap.Calendar = function(config){
16066 Roo.bootstrap.Calendar.superclass.constructor.call(this, config);
16070 * Fires when a date is selected
16071 * @param {DatePicker} this
16072 * @param {Date} date The selected date
16076 * @event monthchange
16077 * Fires when the displayed month changes
16078 * @param {DatePicker} this
16079 * @param {Date} date The selected month
16081 'monthchange': true,
16083 * @event evententer
16084 * Fires when mouse over an event
16085 * @param {Calendar} this
16086 * @param {event} Event
16088 'evententer': true,
16090 * @event eventleave
16091 * Fires when the mouse leaves an
16092 * @param {Calendar} this
16095 'eventleave': true,
16097 * @event eventclick
16098 * Fires when the mouse click an
16099 * @param {Calendar} this
16108 Roo.extend(Roo.bootstrap.Calendar, Roo.bootstrap.Component, {
16111 * @cfg {Number} startDay
16112 * Day index at which the week should begin, 0-based (defaults to 0, which is Sunday)
16120 getAutoCreate : function(){
16123 var fc_button = function(name, corner, style, content ) {
16124 return Roo.apply({},{
16126 cls : 'fc-button fc-button-'+name+' fc-state-default ' +
16128 'fc-corner-' + corner.split(' ').join(' fc-corner-') :
16131 html : '<SPAN class="fc-text-'+style+ '">'+content +'</SPAN>',
16142 style : 'width:100%',
16149 cls : 'fc-header-left',
16151 fc_button('prev', 'left', 'arrow', '‹' ),
16152 fc_button('next', 'right', 'arrow', '›' ),
16153 { tag: 'span', cls: 'fc-header-space' },
16154 fc_button('today', 'left right', '', 'today' ) // neds state disabled..
16162 cls : 'fc-header-center',
16166 cls: 'fc-header-title',
16169 html : 'month / year'
16177 cls : 'fc-header-right',
16179 /* fc_button('month', 'left', '', 'month' ),
16180 fc_button('week', '', '', 'week' ),
16181 fc_button('day', 'right', '', 'day' )
16193 header = this.header;
16196 var cal_heads = function() {
16198 // fixme - handle this.
16200 for (var i =0; i < Date.dayNames.length; i++) {
16201 var d = Date.dayNames[i];
16204 cls : 'fc-day-header fc-' + d.substring(0,3).toLowerCase() + ' fc-widget-header',
16205 html : d.substring(0,3)
16209 ret[0].cls += ' fc-first';
16210 ret[6].cls += ' fc-last';
16213 var cal_cell = function(n) {
16216 cls : 'fc-day fc-'+n + ' fc-widget-content', ///fc-other-month fc-past
16221 cls: 'fc-day-number',
16225 cls: 'fc-day-content',
16229 style: 'position: relative;' // height: 17px;
16241 var cal_rows = function() {
16244 for (var r = 0; r < 6; r++) {
16251 for (var i =0; i < Date.dayNames.length; i++) {
16252 var d = Date.dayNames[i];
16253 row.cn.push(cal_cell(d.substring(0,3).toLowerCase()));
16256 row.cn[0].cls+=' fc-first';
16257 row.cn[0].cn[0].style = 'min-height:90px';
16258 row.cn[6].cls+=' fc-last';
16262 ret[0].cls += ' fc-first';
16263 ret[4].cls += ' fc-prev-last';
16264 ret[5].cls += ' fc-last';
16271 cls: 'fc-border-separate',
16272 style : 'width:100%',
16280 cls : 'fc-first fc-last',
16298 cls : 'fc-content',
16299 style : "position: relative;",
16302 cls : 'fc-view fc-view-month fc-grid',
16303 style : 'position: relative',
16304 unselectable : 'on',
16307 cls : 'fc-event-container',
16308 style : 'position:absolute;z-index:8;top:0;left:0;'
16326 initEvents : function()
16329 throw "can not find store for calendar";
16335 style: "text-align:center",
16339 style: "background-color:white;width:50%;margin:250 auto",
16343 src: Roo.rootURL + '/images/ux/lightbox/loading.gif'
16354 this.maskEl = Roo.DomHelper.append(this.el.select('.fc-content', true).first(), mark, true);
16356 var size = this.el.select('.fc-content', true).first().getSize();
16357 this.maskEl.setSize(size.width, size.height);
16358 this.maskEl.enableDisplayMode("block");
16359 if(!this.loadMask){
16360 this.maskEl.hide();
16363 this.store = Roo.factory(this.store, Roo.data);
16364 this.store.on('load', this.onLoad, this);
16365 this.store.on('beforeload', this.onBeforeLoad, this);
16369 this.cells = this.el.select('.fc-day',true);
16370 //Roo.log(this.cells);
16371 this.textNodes = this.el.query('.fc-day-number');
16372 this.cells.addClassOnOver('fc-state-hover');
16374 this.el.select('.fc-button-prev',true).on('click', this.showPrevMonth, this);
16375 this.el.select('.fc-button-next',true).on('click', this.showNextMonth, this);
16376 this.el.select('.fc-button-today',true).on('click', this.showToday, this);
16377 this.el.select('.fc-button',true).addClassOnOver('fc-state-hover');
16379 this.on('monthchange', this.onMonthChange, this);
16381 this.update(new Date().clearTime());
16384 resize : function() {
16385 var sz = this.el.getSize();
16387 this.el.select('.fc-day-header',true).setWidth(sz.width / 7);
16388 this.el.select('.fc-day-content div',true).setHeight(34);
16393 showPrevMonth : function(e){
16394 this.update(this.activeDate.add("mo", -1));
16396 showToday : function(e){
16397 this.update(new Date().clearTime());
16400 showNextMonth : function(e){
16401 this.update(this.activeDate.add("mo", 1));
16405 showPrevYear : function(){
16406 this.update(this.activeDate.add("y", -1));
16410 showNextYear : function(){
16411 this.update(this.activeDate.add("y", 1));
16416 update : function(date)
16418 var vd = this.activeDate;
16419 this.activeDate = date;
16420 // if(vd && this.el){
16421 // var t = date.getTime();
16422 // if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
16423 // Roo.log('using add remove');
16425 // this.fireEvent('monthchange', this, date);
16427 // this.cells.removeClass("fc-state-highlight");
16428 // this.cells.each(function(c){
16429 // if(c.dateValue == t){
16430 // c.addClass("fc-state-highlight");
16431 // setTimeout(function(){
16432 // try{c.dom.firstChild.focus();}catch(e){}
16442 var days = date.getDaysInMonth();
16444 var firstOfMonth = date.getFirstDateOfMonth();
16445 var startingPos = firstOfMonth.getDay()-this.startDay;
16447 if(startingPos < this.startDay){
16451 var pm = date.add(Date.MONTH, -1);
16452 var prevStart = pm.getDaysInMonth()-startingPos;
16454 this.cells = this.el.select('.fc-day',true);
16455 this.textNodes = this.el.query('.fc-day-number');
16456 this.cells.addClassOnOver('fc-state-hover');
16458 var cells = this.cells.elements;
16459 var textEls = this.textNodes;
16461 Roo.each(cells, function(cell){
16462 cell.removeClass([ 'fc-past', 'fc-other-month', 'fc-future', 'fc-state-highlight', 'fc-state-disabled']);
16465 days += startingPos;
16467 // convert everything to numbers so it's fast
16468 var day = 86400000;
16469 var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
16472 //Roo.log(prevStart);
16474 var today = new Date().clearTime().getTime();
16475 var sel = date.clearTime().getTime();
16476 var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
16477 var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
16478 var ddMatch = this.disabledDatesRE;
16479 var ddText = this.disabledDatesText;
16480 var ddays = this.disabledDays ? this.disabledDays.join("") : false;
16481 var ddaysText = this.disabledDaysText;
16482 var format = this.format;
16484 var setCellClass = function(cal, cell){
16488 //Roo.log('set Cell Class');
16490 var t = d.getTime();
16494 cell.dateValue = t;
16496 cell.className += " fc-today";
16497 cell.className += " fc-state-highlight";
16498 cell.title = cal.todayText;
16501 // disable highlight in other month..
16502 //cell.className += " fc-state-highlight";
16507 cell.className = " fc-state-disabled";
16508 cell.title = cal.minText;
16512 cell.className = " fc-state-disabled";
16513 cell.title = cal.maxText;
16517 if(ddays.indexOf(d.getDay()) != -1){
16518 cell.title = ddaysText;
16519 cell.className = " fc-state-disabled";
16522 if(ddMatch && format){
16523 var fvalue = d.dateFormat(format);
16524 if(ddMatch.test(fvalue)){
16525 cell.title = ddText.replace("%0", fvalue);
16526 cell.className = " fc-state-disabled";
16530 if (!cell.initialClassName) {
16531 cell.initialClassName = cell.dom.className;
16534 cell.dom.className = cell.initialClassName + ' ' + cell.className;
16539 for(; i < startingPos; i++) {
16540 textEls[i].innerHTML = (++prevStart);
16541 d.setDate(d.getDate()+1);
16543 cells[i].className = "fc-past fc-other-month";
16544 setCellClass(this, cells[i]);
16549 for(; i < days; i++){
16550 intDay = i - startingPos + 1;
16551 textEls[i].innerHTML = (intDay);
16552 d.setDate(d.getDate()+1);
16554 cells[i].className = ''; // "x-date-active";
16555 setCellClass(this, cells[i]);
16559 for(; i < 42; i++) {
16560 textEls[i].innerHTML = (++extraDays);
16561 d.setDate(d.getDate()+1);
16563 cells[i].className = "fc-future fc-other-month";
16564 setCellClass(this, cells[i]);
16567 this.el.select('.fc-header-title h2',true).update(Date.monthNames[date.getMonth()] + " " + date.getFullYear());
16569 var totalRows = Math.ceil((date.getDaysInMonth() + date.getFirstDateOfMonth().getDay()) / 7);
16571 this.el.select('tr.fc-week.fc-prev-last',true).removeClass('fc-last');
16572 this.el.select('tr.fc-week.fc-next-last',true).addClass('fc-last').show();
16574 if(totalRows != 6){
16575 this.el.select('tr.fc-week.fc-last',true).removeClass('fc-last').addClass('fc-next-last').hide();
16576 this.el.select('tr.fc-week.fc-prev-last',true).addClass('fc-last');
16579 this.fireEvent('monthchange', this, date);
16583 if(!this.internalRender){
16584 var main = this.el.dom.firstChild;
16585 var w = main.offsetWidth;
16586 this.el.setWidth(w + this.el.getBorderWidth("lr"));
16587 Roo.fly(main).setWidth(w);
16588 this.internalRender = true;
16589 // opera does not respect the auto grow header center column
16590 // then, after it gets a width opera refuses to recalculate
16591 // without a second pass
16592 if(Roo.isOpera && !this.secondPass){
16593 main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
16594 this.secondPass = true;
16595 this.update.defer(10, this, [date]);
16602 findCell : function(dt) {
16603 dt = dt.clearTime().getTime();
16605 this.cells.each(function(c){
16606 //Roo.log("check " +c.dateValue + '?=' + dt);
16607 if(c.dateValue == dt){
16617 findCells : function(ev) {
16618 var s = ev.start.clone().clearTime().getTime();
16620 var e= ev.end.clone().clearTime().getTime();
16623 this.cells.each(function(c){
16624 ////Roo.log("check " +c.dateValue + '<' + e + ' > ' + s);
16626 if(c.dateValue > e){
16629 if(c.dateValue < s){
16638 // findBestRow: function(cells)
16642 // for (var i =0 ; i < cells.length;i++) {
16643 // ret = Math.max(cells[i].rows || 0,ret);
16650 addItem : function(ev)
16652 // look for vertical location slot in
16653 var cells = this.findCells(ev);
16655 // ev.row = this.findBestRow(cells);
16657 // work out the location.
16661 for(var i =0; i < cells.length; i++) {
16663 cells[i].row = cells[0].row;
16666 cells[i].row = cells[i].row + 1;
16676 if (crow.start.getY() == cells[i].getY()) {
16678 crow.end = cells[i];
16695 cells[0].events.push(ev);
16697 this.calevents.push(ev);
16700 clearEvents: function() {
16702 if(!this.calevents){
16706 Roo.each(this.cells.elements, function(c){
16712 Roo.each(this.calevents, function(e) {
16713 Roo.each(e.els, function(el) {
16714 el.un('mouseenter' ,this.onEventEnter, this);
16715 el.un('mouseleave' ,this.onEventLeave, this);
16720 Roo.each(Roo.select('.fc-more-event', true).elements, function(e){
16726 renderEvents: function()
16730 this.cells.each(function(c) {
16739 if(c.row != c.events.length){
16740 r = 4 - (4 - (c.row - c.events.length));
16743 c.events = ev.slice(0, r);
16744 c.more = ev.slice(r);
16746 if(c.more.length && c.more.length == 1){
16747 c.events.push(c.more.pop());
16750 c.row = (c.row - ev.length) + c.events.length + ((c.more.length) ? 1 : 0);
16754 this.cells.each(function(c) {
16756 c.select('.fc-day-content div',true).first().setHeight(Math.max(34, c.row * 20));
16759 for (var e = 0; e < c.events.length; e++){
16760 var ev = c.events[e];
16761 var rows = ev.rows;
16763 for(var i = 0; i < rows.length; i++) {
16765 // how many rows should it span..
16768 cls : 'roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable',
16769 style : 'position: absolute', // left: 387px; width: 121px; top: 359px;
16771 unselectable : "on",
16774 cls: 'fc-event-inner',
16778 // cls: 'fc-event-time',
16779 // html : cells.length > 1 ? '' : ev.time
16783 cls: 'fc-event-title',
16784 html : String.format('{0}', ev.title)
16791 cls: 'ui-resizable-handle ui-resizable-e',
16792 html : '  '
16799 cfg.cls += ' fc-event-start';
16801 if ((i+1) == rows.length) {
16802 cfg.cls += ' fc-event-end';
16805 var ctr = _this.el.select('.fc-event-container',true).first();
16806 var cg = ctr.createChild(cfg);
16808 var sbox = rows[i].start.select('.fc-day-content',true).first().getBox();
16809 var ebox = rows[i].end.select('.fc-day-content',true).first().getBox();
16811 var r = (c.more.length) ? 1 : 0;
16812 cg.setXY([sbox.x +2, sbox.y + ((c.row - c.events.length - r + e) * 20)]);
16813 cg.setWidth(ebox.right - sbox.x -2);
16815 cg.on('mouseenter' ,_this.onEventEnter, _this, ev);
16816 cg.on('mouseleave' ,_this.onEventLeave, _this, ev);
16817 cg.on('click', _this.onEventClick, _this, ev);
16828 cls : 'fc-more-event roo-dynamic fc-event fc-event-hori fc-event-draggable ui-draggable fc-event-start fc-event-end',
16829 style : 'position: absolute',
16830 unselectable : "on",
16833 cls: 'fc-event-inner',
16837 cls: 'fc-event-title',
16845 cls: 'ui-resizable-handle ui-resizable-e',
16846 html : '  '
16852 var ctr = _this.el.select('.fc-event-container',true).first();
16853 var cg = ctr.createChild(cfg);
16855 var sbox = c.select('.fc-day-content',true).first().getBox();
16856 var ebox = c.select('.fc-day-content',true).first().getBox();
16858 cg.setXY([sbox.x +2, sbox.y +((c.row - 1) * 20)]);
16859 cg.setWidth(ebox.right - sbox.x -2);
16861 cg.on('click', _this.onMoreEventClick, _this, c.more);
16871 onEventEnter: function (e, el,event,d) {
16872 this.fireEvent('evententer', this, el, event);
16875 onEventLeave: function (e, el,event,d) {
16876 this.fireEvent('eventleave', this, el, event);
16879 onEventClick: function (e, el,event,d) {
16880 this.fireEvent('eventclick', this, el, event);
16883 onMonthChange: function () {
16887 onMoreEventClick: function(e, el, more)
16891 this.calpopover.placement = 'right';
16892 this.calpopover.setTitle('More');
16894 this.calpopover.setContent('');
16896 var ctr = this.calpopover.el.select('.popover-content', true).first();
16898 Roo.each(more, function(m){
16900 cls : 'fc-event-hori fc-event-draggable',
16903 var cg = ctr.createChild(cfg);
16905 cg.on('click', _this.onEventClick, _this, m);
16908 this.calpopover.show(el);
16913 onLoad: function ()
16915 this.calevents = [];
16918 if(this.store.getCount() > 0){
16919 this.store.data.each(function(d){
16922 start: (typeof(d.data.start_dt) === 'string') ? new Date.parseDate(d.data.start_dt, 'Y-m-d H:i:s') : d.data.start_dt,
16923 end : (typeof(d.data.end_dt) === 'string') ? new Date.parseDate(d.data.end_dt, 'Y-m-d H:i:s') : d.data.end_dt,
16924 time : d.data.start_time,
16925 title : d.data.title,
16926 description : d.data.description,
16927 venue : d.data.venue
16932 this.renderEvents();
16934 if(this.calevents.length && this.loadMask){
16935 this.maskEl.hide();
16939 onBeforeLoad: function()
16941 this.clearEvents();
16943 this.maskEl.show();
16957 * @class Roo.bootstrap.Popover
16958 * @extends Roo.bootstrap.Component
16959 * Bootstrap Popover class
16960 * @cfg {String} html contents of the popover (or false to use children..)
16961 * @cfg {String} title of popover (or false to hide)
16962 * @cfg {String} placement how it is placed
16963 * @cfg {String} trigger click || hover (or false to trigger manually)
16964 * @cfg {String} over what (parent or false to trigger manually.)
16965 * @cfg {Number} delay - delay before showing
16968 * Create a new Popover
16969 * @param {Object} config The config object
16972 Roo.bootstrap.Popover = function(config){
16973 Roo.bootstrap.Popover.superclass.constructor.call(this, config);
16979 * After the popover show
16981 * @param {Roo.bootstrap.Popover} this
16986 * After the popover hide
16988 * @param {Roo.bootstrap.Popover} this
16994 Roo.extend(Roo.bootstrap.Popover, Roo.bootstrap.Component, {
16996 title: 'Fill in a title',
16999 placement : 'right',
17000 trigger : 'hover', // hover
17006 can_build_overlaid : false,
17008 getChildContainer : function()
17010 return this.el.select('.popover-content',true).first();
17013 getAutoCreate : function(){
17016 cls : 'popover roo-dynamic',
17017 style: 'display:block',
17023 cls : 'popover-inner',
17027 cls: 'popover-title',
17031 cls : 'popover-content',
17042 setTitle: function(str)
17045 this.el.select('.popover-title',true).first().dom.innerHTML = str;
17047 setContent: function(str)
17050 this.el.select('.popover-content',true).first().dom.innerHTML = str;
17052 // as it get's added to the bottom of the page.
17053 onRender : function(ct, position)
17055 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
17057 var cfg = Roo.apply({}, this.getAutoCreate());
17061 cfg.cls += ' ' + this.cls;
17064 cfg.style = this.style;
17066 //Roo.log("adding to ");
17067 this.el = Roo.get(document.body).createChild(cfg, position);
17068 // Roo.log(this.el);
17073 initEvents : function()
17075 this.el.select('.popover-title',true).setVisibilityMode(Roo.Element.DISPLAY);
17076 this.el.enableDisplayMode('block');
17078 if (this.over === false) {
17081 if (this.triggers === false) {
17084 var on_el = (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17085 var triggers = this.trigger ? this.trigger.split(' ') : [];
17086 Roo.each(triggers, function(trigger) {
17088 if (trigger == 'click') {
17089 on_el.on('click', this.toggle, this);
17090 } else if (trigger != 'manual') {
17091 var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin';
17092 var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout';
17094 on_el.on(eventIn ,this.enter, this);
17095 on_el.on(eventOut, this.leave, this);
17106 toggle : function () {
17107 this.hoverState == 'in' ? this.leave() : this.enter();
17110 enter : function () {
17112 clearTimeout(this.timeout);
17114 this.hoverState = 'in';
17116 if (!this.delay || !this.delay.show) {
17121 this.timeout = setTimeout(function () {
17122 if (_t.hoverState == 'in') {
17125 }, this.delay.show)
17128 leave : function() {
17129 clearTimeout(this.timeout);
17131 this.hoverState = 'out';
17133 if (!this.delay || !this.delay.hide) {
17138 this.timeout = setTimeout(function () {
17139 if (_t.hoverState == 'out') {
17142 }, this.delay.hide)
17145 show : function (on_el)
17148 on_el= (this.over == 'parent') ? this.parent().el : Roo.get(this.over);
17152 this.el.select('.popover-title',true).first().dom.innerHtml = this.title;
17153 if (this.html !== false) {
17154 this.el.select('.popover-content',true).first().dom.innerHtml = this.html;
17156 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
17157 if (!this.title.length) {
17158 this.el.select('.popover-title',true).hide();
17161 var placement = typeof this.placement == 'function' ?
17162 this.placement.call(this, this.el, on_el) :
17165 var autoToken = /\s?auto?\s?/i;
17166 var autoPlace = autoToken.test(placement);
17168 placement = placement.replace(autoToken, '') || 'top';
17172 //this.el.setXY([0,0]);
17174 this.el.dom.style.display='block';
17175 this.el.addClass(placement);
17177 //this.el.appendTo(on_el);
17179 var p = this.getPosition();
17180 var box = this.el.getBox();
17185 var align = Roo.bootstrap.Popover.alignment[placement];
17186 this.el.alignTo(on_el, align[0],align[1]);
17187 //var arrow = this.el.select('.arrow',true).first();
17188 //arrow.set(align[2],
17190 this.el.addClass('in');
17193 if (this.el.hasClass('fade')) {
17197 this.hoverState = 'in';
17199 this.fireEvent('show', this);
17204 this.el.setXY([0,0]);
17205 this.el.removeClass('in');
17207 this.hoverState = null;
17209 this.fireEvent('hide', this);
17214 Roo.bootstrap.Popover.alignment = {
17215 'left' : ['r-l', [-10,0], 'right'],
17216 'right' : ['l-r', [10,0], 'left'],
17217 'bottom' : ['t-b', [0,10], 'top'],
17218 'top' : [ 'b-t', [0,-10], 'bottom']
17229 * @class Roo.bootstrap.Progress
17230 * @extends Roo.bootstrap.Component
17231 * Bootstrap Progress class
17232 * @cfg {Boolean} striped striped of the progress bar
17233 * @cfg {Boolean} active animated of the progress bar
17237 * Create a new Progress
17238 * @param {Object} config The config object
17241 Roo.bootstrap.Progress = function(config){
17242 Roo.bootstrap.Progress.superclass.constructor.call(this, config);
17245 Roo.extend(Roo.bootstrap.Progress, Roo.bootstrap.Component, {
17250 getAutoCreate : function(){
17258 cfg.cls += ' progress-striped';
17262 cfg.cls += ' active';
17281 * @class Roo.bootstrap.ProgressBar
17282 * @extends Roo.bootstrap.Component
17283 * Bootstrap ProgressBar class
17284 * @cfg {Number} aria_valuenow aria-value now
17285 * @cfg {Number} aria_valuemin aria-value min
17286 * @cfg {Number} aria_valuemax aria-value max
17287 * @cfg {String} label label for the progress bar
17288 * @cfg {String} panel (success | info | warning | danger )
17289 * @cfg {String} role role of the progress bar
17290 * @cfg {String} sr_only text
17294 * Create a new ProgressBar
17295 * @param {Object} config The config object
17298 Roo.bootstrap.ProgressBar = function(config){
17299 Roo.bootstrap.ProgressBar.superclass.constructor.call(this, config);
17302 Roo.extend(Roo.bootstrap.ProgressBar, Roo.bootstrap.Component, {
17306 aria_valuemax : 100,
17312 getAutoCreate : function()
17317 cls: 'progress-bar',
17318 style: 'width:' + Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%'
17330 cfg.role = this.role;
17333 if(this.aria_valuenow){
17334 cfg['aria-valuenow'] = this.aria_valuenow;
17337 if(this.aria_valuemin){
17338 cfg['aria-valuemin'] = this.aria_valuemin;
17341 if(this.aria_valuemax){
17342 cfg['aria-valuemax'] = this.aria_valuemax;
17345 if(this.label && !this.sr_only){
17346 cfg.html = this.label;
17350 cfg.cls += ' progress-bar-' + this.panel;
17356 update : function(aria_valuenow)
17358 this.aria_valuenow = aria_valuenow;
17360 this.el.setStyle('width', Math.ceil((this.aria_valuenow / this.aria_valuemax) * 100) + '%');
17375 * @class Roo.bootstrap.TabGroup
17376 * @extends Roo.bootstrap.Column
17377 * Bootstrap Column class
17378 * @cfg {String} navId the navigation id (for use with navbars) - will be auto generated if it does not exist..
17379 * @cfg {Boolean} carousel true to make the group behave like a carousel
17380 * @cfg {Boolean} bullets show bullets for the panels
17381 * @cfg {Boolean} autoslide (true|false) auto slide .. default false
17382 * @cfg {Number} timer auto slide timer .. default 0 millisecond
17383 * @cfg {Boolean} showarrow (true|false) show arrow default true
17386 * Create a new TabGroup
17387 * @param {Object} config The config object
17390 Roo.bootstrap.TabGroup = function(config){
17391 Roo.bootstrap.TabGroup.superclass.constructor.call(this, config);
17393 this.navId = Roo.id();
17396 Roo.bootstrap.TabGroup.register(this);
17400 Roo.extend(Roo.bootstrap.TabGroup, Roo.bootstrap.Column, {
17403 transition : false,
17408 slideOnTouch : false,
17411 getAutoCreate : function()
17413 var cfg = Roo.apply({}, Roo.bootstrap.TabGroup.superclass.getAutoCreate.call(this));
17415 cfg.cls += ' tab-content';
17417 if (this.carousel) {
17418 cfg.cls += ' carousel slide';
17421 cls : 'carousel-inner',
17425 if(this.bullets && !Roo.isTouch){
17428 cls : 'carousel-bullets',
17432 if(this.bullets_cls){
17433 bullets.cls = bullets.cls + ' ' + this.bullets_cls;
17440 cfg.cn[0].cn.push(bullets);
17443 if(this.showarrow){
17444 cfg.cn[0].cn.push({
17446 class : 'carousel-arrow',
17450 class : 'carousel-prev',
17454 class : 'fa fa-chevron-left'
17460 class : 'carousel-next',
17464 class : 'fa fa-chevron-right'
17477 initEvents: function()
17479 // if(Roo.isTouch && this.slideOnTouch && !this.showarrow){
17480 // this.el.on("touchstart", this.onTouchStart, this);
17483 if(this.autoslide){
17486 this.slideFn = window.setInterval(function() {
17487 _this.showPanelNext();
17491 if(this.showarrow){
17492 this.el.select('.carousel-prev', true).first().on('click', this.showPanelPrev, this);
17493 this.el.select('.carousel-next', true).first().on('click', this.showPanelNext, this);
17499 // onTouchStart : function(e, el, o)
17501 // if(!this.slideOnTouch || !Roo.isTouch || Roo.get(e.getTarget()).hasClass('roo-button-text')){
17505 // this.showPanelNext();
17509 getChildContainer : function()
17511 return this.carousel ? this.el.select('.carousel-inner', true).first() : this.el;
17515 * register a Navigation item
17516 * @param {Roo.bootstrap.NavItem} the navitem to add
17518 register : function(item)
17520 this.tabs.push( item);
17521 item.navId = this.navId; // not really needed..
17526 getActivePanel : function()
17529 Roo.each(this.tabs, function(t) {
17539 getPanelByName : function(n)
17542 Roo.each(this.tabs, function(t) {
17543 if (t.tabId == n) {
17551 indexOfPanel : function(p)
17554 Roo.each(this.tabs, function(t,i) {
17555 if (t.tabId == p.tabId) {
17564 * show a specific panel
17565 * @param {Roo.bootstrap.TabPanel|number|string} panel to change to (use the tabId to specify a specific one)
17566 * @return {boolean} false if panel was not shown (invalid entry or beforedeactivate fails.)
17568 showPanel : function (pan)
17570 if(this.transition || typeof(pan) == 'undefined'){
17571 Roo.log("waiting for the transitionend");
17575 if (typeof(pan) == 'number') {
17576 pan = this.tabs[pan];
17579 if (typeof(pan) == 'string') {
17580 pan = this.getPanelByName(pan);
17583 var cur = this.getActivePanel();
17586 Roo.log('pan or acitve pan is undefined');
17590 if (pan.tabId == this.getActivePanel().tabId) {
17594 if (false === cur.fireEvent('beforedeactivate')) {
17598 if(this.bullets > 0 && !Roo.isTouch){
17599 this.setActiveBullet(this.indexOfPanel(pan));
17602 if (this.carousel && typeof(Roo.get(document.body).dom.style.transition) != 'undefined') {
17604 this.transition = true;
17605 var dir = this.indexOfPanel(pan) > this.indexOfPanel(cur) ? 'next' : 'prev';
17606 var lr = dir == 'next' ? 'left' : 'right';
17607 pan.el.addClass(dir); // or prev
17608 pan.el.dom.offsetWidth; // find the offset with - causing a reflow?
17609 cur.el.addClass(lr); // or right
17610 pan.el.addClass(lr);
17613 cur.el.on('transitionend', function() {
17614 Roo.log("trans end?");
17616 pan.el.removeClass([lr,dir]);
17617 pan.setActive(true);
17619 cur.el.removeClass([lr]);
17620 cur.setActive(false);
17622 _this.transition = false;
17624 }, this, { single: true } );
17629 cur.setActive(false);
17630 pan.setActive(true);
17635 showPanelNext : function()
17637 var i = this.indexOfPanel(this.getActivePanel());
17639 if (i >= this.tabs.length - 1 && !this.autoslide) {
17643 if (i >= this.tabs.length - 1 && this.autoslide) {
17647 this.showPanel(this.tabs[i+1]);
17650 showPanelPrev : function()
17652 var i = this.indexOfPanel(this.getActivePanel());
17654 if (i < 1 && !this.autoslide) {
17658 if (i < 1 && this.autoslide) {
17659 i = this.tabs.length;
17662 this.showPanel(this.tabs[i-1]);
17666 addBullet: function()
17668 if(!this.bullets || Roo.isTouch){
17671 var ctr = this.el.select('.carousel-bullets',true).first();
17672 var i = this.el.select('.carousel-bullets .bullet',true).getCount() ;
17673 var bullet = ctr.createChild({
17674 cls : 'bullet bullet-' + i
17675 },ctr.dom.lastChild);
17680 bullet.on('click', (function(e, el, o, ii, t){
17682 e.preventDefault();
17684 this.showPanel(ii);
17686 if(this.autoslide && this.slideFn){
17687 clearInterval(this.slideFn);
17688 this.slideFn = window.setInterval(function() {
17689 _this.showPanelNext();
17693 }).createDelegate(this, [i, bullet], true));
17698 setActiveBullet : function(i)
17704 Roo.each(this.el.select('.bullet', true).elements, function(el){
17705 el.removeClass('selected');
17708 var bullet = this.el.select('.bullet-' + i, true).first();
17714 bullet.addClass('selected');
17725 Roo.apply(Roo.bootstrap.TabGroup, {
17729 * register a Navigation Group
17730 * @param {Roo.bootstrap.NavGroup} the navgroup to add
17732 register : function(navgrp)
17734 this.groups[navgrp.navId] = navgrp;
17738 * fetch a Navigation Group based on the navigation ID
17739 * if one does not exist , it will get created.
17740 * @param {string} the navgroup to add
17741 * @returns {Roo.bootstrap.NavGroup} the navgroup
17743 get: function(navId) {
17744 if (typeof(this.groups[navId]) == 'undefined') {
17745 this.register(new Roo.bootstrap.TabGroup({ navId : navId }));
17747 return this.groups[navId] ;
17762 * @class Roo.bootstrap.TabPanel
17763 * @extends Roo.bootstrap.Component
17764 * Bootstrap TabPanel class
17765 * @cfg {Boolean} active panel active
17766 * @cfg {String} html panel content
17767 * @cfg {String} tabId unique tab ID (will be autogenerated if not set. - used to match TabItem to Panel)
17768 * @cfg {String} navId The Roo.bootstrap.NavGroup which triggers show hide ()
17769 * @cfg {String} href click to link..
17773 * Create a new TabPanel
17774 * @param {Object} config The config object
17777 Roo.bootstrap.TabPanel = function(config){
17778 Roo.bootstrap.TabPanel.superclass.constructor.call(this, config);
17782 * Fires when the active status changes
17783 * @param {Roo.bootstrap.TabPanel} this
17784 * @param {Boolean} state the new state
17789 * @event beforedeactivate
17790 * Fires before a tab is de-activated - can be used to do validation on a form.
17791 * @param {Roo.bootstrap.TabPanel} this
17792 * @return {Boolean} false if there is an error
17795 'beforedeactivate': true
17798 this.tabId = this.tabId || Roo.id();
17802 Roo.extend(Roo.bootstrap.TabPanel, Roo.bootstrap.Component, {
17810 getAutoCreate : function(){
17813 // item is needed for carousel - not sure if it has any effect otherwise
17814 cls: 'tab-pane item' + ((this.href.length) ? ' clickable ' : ''),
17815 html: this.html || ''
17819 cfg.cls += ' active';
17823 cfg.tabId = this.tabId;
17830 initEvents: function()
17832 var p = this.parent();
17834 this.navId = this.navId || p.navId;
17836 if (typeof(this.navId) != 'undefined') {
17837 // not really needed.. but just in case.. parent should be a NavGroup.
17838 var tg = Roo.bootstrap.TabGroup.get(this.navId);
17842 var i = tg.tabs.length - 1;
17844 if(this.active && tg.bullets > 0 && i < tg.bullets){
17845 tg.setActiveBullet(i);
17849 this.el.on('click', this.onClick, this);
17852 this.el.on("touchstart", this.onTouchStart, this);
17853 this.el.on("touchmove", this.onTouchMove, this);
17854 this.el.on("touchend", this.onTouchEnd, this);
17859 onRender : function(ct, position)
17861 Roo.bootstrap.TabPanel.superclass.onRender.call(this, ct, position);
17864 setActive : function(state)
17866 Roo.log("panel - set active " + this.tabId + "=" + state);
17868 this.active = state;
17870 this.el.removeClass('active');
17872 } else if (!this.el.hasClass('active')) {
17873 this.el.addClass('active');
17876 this.fireEvent('changed', this, state);
17879 onClick : function(e)
17881 e.preventDefault();
17883 if(!this.href.length){
17887 window.location.href = this.href;
17896 onTouchStart : function(e)
17898 this.swiping = false;
17900 this.startX = e.browserEvent.touches[0].clientX;
17901 this.startY = e.browserEvent.touches[0].clientY;
17904 onTouchMove : function(e)
17906 this.swiping = true;
17908 this.endX = e.browserEvent.touches[0].clientX;
17909 this.endY = e.browserEvent.touches[0].clientY;
17912 onTouchEnd : function(e)
17919 var tabGroup = this.parent();
17921 if(this.endX > this.startX){ // swiping right
17922 tabGroup.showPanelPrev();
17926 if(this.startX > this.endX){ // swiping left
17927 tabGroup.showPanelNext();
17946 * @class Roo.bootstrap.DateField
17947 * @extends Roo.bootstrap.Input
17948 * Bootstrap DateField class
17949 * @cfg {Number} weekStart default 0
17950 * @cfg {String} viewMode default empty, (months|years)
17951 * @cfg {String} minViewMode default empty, (months|years)
17952 * @cfg {Number} startDate default -Infinity
17953 * @cfg {Number} endDate default Infinity
17954 * @cfg {Boolean} todayHighlight default false
17955 * @cfg {Boolean} todayBtn default false
17956 * @cfg {Boolean} calendarWeeks default false
17957 * @cfg {Object} daysOfWeekDisabled default empty
17958 * @cfg {Boolean} singleMode default false (true | false)
17960 * @cfg {Boolean} keyboardNavigation default true
17961 * @cfg {String} language default en
17964 * Create a new DateField
17965 * @param {Object} config The config object
17968 Roo.bootstrap.DateField = function(config){
17969 Roo.bootstrap.DateField.superclass.constructor.call(this, config);
17973 * Fires when this field show.
17974 * @param {Roo.bootstrap.DateField} this
17975 * @param {Mixed} date The date value
17980 * Fires when this field hide.
17981 * @param {Roo.bootstrap.DateField} this
17982 * @param {Mixed} date The date value
17987 * Fires when select a date.
17988 * @param {Roo.bootstrap.DateField} this
17989 * @param {Mixed} date The date value
17993 * @event beforeselect
17994 * Fires when before select a date.
17995 * @param {Roo.bootstrap.DateField} this
17996 * @param {Mixed} date The date value
17998 beforeselect : true
18002 Roo.extend(Roo.bootstrap.DateField, Roo.bootstrap.Input, {
18005 * @cfg {String} format
18006 * The default date format string which can be overriden for localization support. The format must be
18007 * valid according to {@link Date#parseDate} (defaults to 'm/d/y').
18011 * @cfg {String} altFormats
18012 * Multiple date formats separated by "|" to try when parsing a user input value and it doesn't match the defined
18013 * format (defaults to 'm/d/Y|m-d-y|m-d-Y|m/d|m-d|d').
18015 altFormats : "m/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d",
18023 todayHighlight : false,
18029 keyboardNavigation: true,
18031 calendarWeeks: false,
18033 startDate: -Infinity,
18037 daysOfWeekDisabled: [],
18041 singleMode : false,
18043 UTCDate: function()
18045 return new Date(Date.UTC.apply(Date, arguments));
18048 UTCToday: function()
18050 var today = new Date();
18051 return this.UTCDate(today.getUTCFullYear(), today.getUTCMonth(), today.getUTCDate());
18054 getDate: function() {
18055 var d = this.getUTCDate();
18056 return new Date(d.getTime() + (d.getTimezoneOffset()*60000));
18059 getUTCDate: function() {
18063 setDate: function(d) {
18064 this.setUTCDate(new Date(d.getTime() - (d.getTimezoneOffset()*60000)));
18067 setUTCDate: function(d) {
18069 this.setValue(this.formatDate(this.date));
18072 onRender: function(ct, position)
18075 Roo.bootstrap.DateField.superclass.onRender.call(this, ct, position);
18077 this.language = this.language || 'en';
18078 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : this.language.split('-')[0];
18079 this.language = this.language in Roo.bootstrap.DateField.dates ? this.language : "en";
18081 this.isRTL = Roo.bootstrap.DateField.dates[this.language].rtl || false;
18082 this.format = this.format || 'm/d/y';
18083 this.isInline = false;
18084 this.isInput = true;
18085 this.component = this.el.select('.add-on', true).first() || false;
18086 this.component = (this.component && this.component.length === 0) ? false : this.component;
18087 this.hasInput = this.component && this.inputEl().length;
18089 if (typeof(this.minViewMode === 'string')) {
18090 switch (this.minViewMode) {
18092 this.minViewMode = 1;
18095 this.minViewMode = 2;
18098 this.minViewMode = 0;
18103 if (typeof(this.viewMode === 'string')) {
18104 switch (this.viewMode) {
18117 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.DateField.template);
18119 // this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.DateField.template);
18121 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18123 this.picker().on('mousedown', this.onMousedown, this);
18124 this.picker().on('click', this.onClick, this);
18126 this.picker().addClass('datepicker-dropdown');
18128 this.startViewMode = this.viewMode;
18130 if(this.singleMode){
18131 Roo.each(this.picker().select('thead > tr > th', true).elements, function(v){
18132 v.setVisibilityMode(Roo.Element.DISPLAY);
18136 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
18137 v.setStyle('width', '189px');
18141 Roo.each(this.picker().select('tfoot th.today', true).elements, function(v){
18142 if(!this.calendarWeeks){
18147 v.dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18148 v.attr('colspan', function(i, val){
18149 return parseInt(val) + 1;
18154 this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1;
18156 this.setStartDate(this.startDate);
18157 this.setEndDate(this.endDate);
18159 this.setDaysOfWeekDisabled(this.daysOfWeekDisabled);
18166 if(this.isInline) {
18171 picker : function()
18173 return this.pickerEl;
18174 // return this.el.select('.datepicker', true).first();
18177 fillDow: function()
18179 var dowCnt = this.weekStart;
18188 if(this.calendarWeeks){
18196 while (dowCnt < this.weekStart + 7) {
18200 html: Roo.bootstrap.DateField.dates[this.language].daysMin[(dowCnt++)%7]
18204 this.picker().select('>.datepicker-days thead', true).first().createChild(dow);
18207 fillMonths: function()
18210 var months = this.picker().select('>.datepicker-months td', true).first();
18212 months.dom.innerHTML = '';
18218 html: Roo.bootstrap.DateField.dates[this.language].monthsShort[i++]
18221 months.createChild(month);
18228 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;
18230 if (this.date < this.startDate) {
18231 this.viewDate = new Date(this.startDate);
18232 } else if (this.date > this.endDate) {
18233 this.viewDate = new Date(this.endDate);
18235 this.viewDate = new Date(this.date);
18243 var d = new Date(this.viewDate),
18244 year = d.getUTCFullYear(),
18245 month = d.getUTCMonth(),
18246 startYear = this.startDate !== -Infinity ? this.startDate.getUTCFullYear() : -Infinity,
18247 startMonth = this.startDate !== -Infinity ? this.startDate.getUTCMonth() : -Infinity,
18248 endYear = this.endDate !== Infinity ? this.endDate.getUTCFullYear() : Infinity,
18249 endMonth = this.endDate !== Infinity ? this.endDate.getUTCMonth() : Infinity,
18250 currentDate = this.date && this.date.valueOf(),
18251 today = this.UTCToday();
18253 this.picker().select('>.datepicker-days thead th.switch', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].months[month]+' '+year;
18255 // this.picker().select('>tfoot th.today', true).first().dom.innerHTML = Roo.bootstrap.DateField.dates[this.language].today;
18257 // this.picker.select('>tfoot th.today').
18258 // .text(dates[this.language].today)
18259 // .toggle(this.todayBtn !== false);
18261 this.updateNavArrows();
18264 var prevMonth = this.UTCDate(year, month-1, 28,0,0,0,0),
18266 day = prevMonth.getDaysInMonth(prevMonth.getUTCFullYear(), prevMonth.getUTCMonth());
18268 prevMonth.setUTCDate(day);
18270 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.weekStart + 7)%7);
18272 var nextMonth = new Date(prevMonth);
18274 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
18276 nextMonth = nextMonth.valueOf();
18278 var fillMonths = false;
18280 this.picker().select('>.datepicker-days tbody',true).first().dom.innerHTML = '';
18282 while(prevMonth.valueOf() < nextMonth) {
18285 if (prevMonth.getUTCDay() === this.weekStart) {
18287 this.picker().select('>.datepicker-days tbody',true).first().createChild(fillMonths);
18295 if(this.calendarWeeks){
18296 // ISO 8601: First week contains first thursday.
18297 // ISO also states week starts on Monday, but we can be more abstract here.
18299 // Start of current week: based on weekstart/current date
18300 ws = new Date(+prevMonth + (this.weekStart - prevMonth.getUTCDay() - 7) % 7 * 864e5),
18301 // Thursday of this week
18302 th = new Date(+ws + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
18303 // First Thursday of year, year from thursday
18304 yth = new Date(+(yth = this.UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay())%7*864e5),
18305 // Calendar week: ms between thursdays, div ms per day, div 7 days
18306 calWeek = (th - yth) / 864e5 / 7 + 1;
18308 fillMonths.cn.push({
18316 if (prevMonth.getUTCFullYear() < year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() < month)) {
18318 } else if (prevMonth.getUTCFullYear() > year || (prevMonth.getUTCFullYear() == year && prevMonth.getUTCMonth() > month)) {
18321 if (this.todayHighlight &&
18322 prevMonth.getUTCFullYear() == today.getFullYear() &&
18323 prevMonth.getUTCMonth() == today.getMonth() &&
18324 prevMonth.getUTCDate() == today.getDate()) {
18325 clsName += ' today';
18328 if (currentDate && prevMonth.valueOf() === currentDate) {
18329 clsName += ' active';
18332 if (prevMonth.valueOf() < this.startDate || prevMonth.valueOf() > this.endDate ||
18333 this.daysOfWeekDisabled.indexOf(prevMonth.getUTCDay()) !== -1) {
18334 clsName += ' disabled';
18337 fillMonths.cn.push({
18339 cls: 'day ' + clsName,
18340 html: prevMonth.getDate()
18343 prevMonth.setDate(prevMonth.getDate()+1);
18346 var currentYear = this.date && this.date.getUTCFullYear();
18347 var currentMonth = this.date && this.date.getUTCMonth();
18349 this.picker().select('>.datepicker-months th.switch',true).first().dom.innerHTML = year;
18351 Roo.each(this.picker().select('>.datepicker-months tbody span',true).elements, function(v,k){
18352 v.removeClass('active');
18354 if(currentYear === year && k === currentMonth){
18355 v.addClass('active');
18358 if (year < startYear || year > endYear || (year == startYear && k < startMonth) || (year == endYear && k > endMonth)) {
18359 v.addClass('disabled');
18365 year = parseInt(year/10, 10) * 10;
18367 this.picker().select('>.datepicker-years th.switch', true).first().dom.innerHTML = year + '-' + (year + 9);
18369 this.picker().select('>.datepicker-years tbody td',true).first().dom.innerHTML = '';
18372 for (var i = -1; i < 11; i++) {
18373 this.picker().select('>.datepicker-years tbody td',true).first().createChild({
18375 cls: 'year' + (i === -1 || i === 10 ? ' old' : '') + (currentYear === year ? ' active' : '') + (year < startYear || year > endYear ? ' disabled' : ''),
18383 showMode: function(dir)
18386 this.viewMode = Math.max(this.minViewMode, Math.min(2, this.viewMode + dir));
18389 Roo.each(this.picker().select('>div',true).elements, function(v){
18390 v.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
18393 this.picker().select('>.datepicker-'+Roo.bootstrap.DateField.modes[this.viewMode].clsName, true).first().show();
18398 if(this.isInline) {
18402 this.picker().removeClass(['bottom', 'top']);
18404 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
18406 * place to the top of element!
18410 this.picker().addClass('top');
18411 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
18416 this.picker().addClass('bottom');
18418 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
18421 parseDate : function(value)
18423 if(!value || value instanceof Date){
18426 var v = Date.parseDate(value, this.format);
18427 if (!v && (this.useIso || value.match(/^(\d{4})-0?(\d+)-0?(\d+)/))) {
18428 v = Date.parseDate(value, 'Y-m-d');
18430 if(!v && this.altFormats){
18431 if(!this.altFormatsArray){
18432 this.altFormatsArray = this.altFormats.split("|");
18434 for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
18435 v = Date.parseDate(value, this.altFormatsArray[i]);
18441 formatDate : function(date, fmt)
18443 return (!date || !(date instanceof Date)) ?
18444 date : date.dateFormat(fmt || this.format);
18447 onFocus : function()
18449 Roo.bootstrap.DateField.superclass.onFocus.call(this);
18453 onBlur : function()
18455 Roo.bootstrap.DateField.superclass.onBlur.call(this);
18457 var d = this.inputEl().getValue();
18466 this.picker().show();
18470 this.fireEvent('show', this, this.date);
18475 if(this.isInline) {
18478 this.picker().hide();
18479 this.viewMode = this.startViewMode;
18482 this.fireEvent('hide', this, this.date);
18486 onMousedown: function(e)
18488 e.stopPropagation();
18489 e.preventDefault();
18494 Roo.bootstrap.DateField.superclass.keyup.call(this);
18498 setValue: function(v)
18500 if(this.fireEvent('beforeselect', this, v) !== false){
18501 var d = new Date(this.parseDate(v) ).clearTime();
18503 if(isNaN(d.getTime())){
18504 this.date = this.viewDate = '';
18505 Roo.bootstrap.DateField.superclass.setValue.call(this, '');
18509 v = this.formatDate(d);
18511 Roo.bootstrap.DateField.superclass.setValue.call(this, v);
18513 this.date = new Date(d.getTime() - d.getTimezoneOffset()*60000);
18517 this.fireEvent('select', this, this.date);
18521 getValue: function()
18523 return this.formatDate(this.date);
18526 fireKey: function(e)
18528 if (!this.picker().isVisible()){
18529 if (e.keyCode == 27) { // allow escape to hide and re-show picker
18535 var dateChanged = false,
18537 newDate, newViewDate;
18542 e.preventDefault();
18546 if (!this.keyboardNavigation) {
18549 dir = e.keyCode == 37 ? -1 : 1;
18552 newDate = this.moveYear(this.date, dir);
18553 newViewDate = this.moveYear(this.viewDate, dir);
18554 } else if (e.shiftKey){
18555 newDate = this.moveMonth(this.date, dir);
18556 newViewDate = this.moveMonth(this.viewDate, dir);
18558 newDate = new Date(this.date);
18559 newDate.setUTCDate(this.date.getUTCDate() + dir);
18560 newViewDate = new Date(this.viewDate);
18561 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir);
18563 if (this.dateWithinRange(newDate)){
18564 this.date = newDate;
18565 this.viewDate = newViewDate;
18566 this.setValue(this.formatDate(this.date));
18568 e.preventDefault();
18569 dateChanged = true;
18574 if (!this.keyboardNavigation) {
18577 dir = e.keyCode == 38 ? -1 : 1;
18579 newDate = this.moveYear(this.date, dir);
18580 newViewDate = this.moveYear(this.viewDate, dir);
18581 } else if (e.shiftKey){
18582 newDate = this.moveMonth(this.date, dir);
18583 newViewDate = this.moveMonth(this.viewDate, dir);
18585 newDate = new Date(this.date);
18586 newDate.setUTCDate(this.date.getUTCDate() + dir * 7);
18587 newViewDate = new Date(this.viewDate);
18588 newViewDate.setUTCDate(this.viewDate.getUTCDate() + dir * 7);
18590 if (this.dateWithinRange(newDate)){
18591 this.date = newDate;
18592 this.viewDate = newViewDate;
18593 this.setValue(this.formatDate(this.date));
18595 e.preventDefault();
18596 dateChanged = true;
18600 this.setValue(this.formatDate(this.date));
18602 e.preventDefault();
18605 this.setValue(this.formatDate(this.date));
18619 onClick: function(e)
18621 e.stopPropagation();
18622 e.preventDefault();
18624 var target = e.getTarget();
18626 if(target.nodeName.toLowerCase() === 'i'){
18627 target = Roo.get(target).dom.parentNode;
18630 var nodeName = target.nodeName;
18631 var className = target.className;
18632 var html = target.innerHTML;
18633 //Roo.log(nodeName);
18635 switch(nodeName.toLowerCase()) {
18637 switch(className) {
18643 var dir = Roo.bootstrap.DateField.modes[this.viewMode].navStep * (className == 'prev' ? -1 : 1);
18644 switch(this.viewMode){
18646 this.viewDate = this.moveMonth(this.viewDate, dir);
18650 this.viewDate = this.moveYear(this.viewDate, dir);
18656 var date = new Date();
18657 this.date = this.UTCDate(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
18659 this.setValue(this.formatDate(this.date));
18666 if (className.indexOf('disabled') < 0) {
18667 this.viewDate.setUTCDate(1);
18668 if (className.indexOf('month') > -1) {
18669 this.viewDate.setUTCMonth(Roo.bootstrap.DateField.dates[this.language].monthsShort.indexOf(html));
18671 var year = parseInt(html, 10) || 0;
18672 this.viewDate.setUTCFullYear(year);
18676 if(this.singleMode){
18677 this.setValue(this.formatDate(this.viewDate));
18688 //Roo.log(className);
18689 if (className.indexOf('day') > -1 && className.indexOf('disabled') < 0 ){
18690 var day = parseInt(html, 10) || 1;
18691 var year = this.viewDate.getUTCFullYear(),
18692 month = this.viewDate.getUTCMonth();
18694 if (className.indexOf('old') > -1) {
18701 } else if (className.indexOf('new') > -1) {
18709 //Roo.log([year,month,day]);
18710 this.date = this.UTCDate(year, month, day,0,0,0,0);
18711 this.viewDate = this.UTCDate(year, month, Math.min(28, day),0,0,0,0);
18713 //Roo.log(this.formatDate(this.date));
18714 this.setValue(this.formatDate(this.date));
18721 setStartDate: function(startDate)
18723 this.startDate = startDate || -Infinity;
18724 if (this.startDate !== -Infinity) {
18725 this.startDate = this.parseDate(this.startDate);
18728 this.updateNavArrows();
18731 setEndDate: function(endDate)
18733 this.endDate = endDate || Infinity;
18734 if (this.endDate !== Infinity) {
18735 this.endDate = this.parseDate(this.endDate);
18738 this.updateNavArrows();
18741 setDaysOfWeekDisabled: function(daysOfWeekDisabled)
18743 this.daysOfWeekDisabled = daysOfWeekDisabled || [];
18744 if (typeof(this.daysOfWeekDisabled) !== 'object') {
18745 this.daysOfWeekDisabled = this.daysOfWeekDisabled.split(/,\s*/);
18747 this.daysOfWeekDisabled = this.daysOfWeekDisabled.map(function (d) {
18748 return parseInt(d, 10);
18751 this.updateNavArrows();
18754 updateNavArrows: function()
18756 if(this.singleMode){
18760 var d = new Date(this.viewDate),
18761 year = d.getUTCFullYear(),
18762 month = d.getUTCMonth();
18764 Roo.each(this.picker().select('.prev', true).elements, function(v){
18766 switch (this.viewMode) {
18769 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear() && month <= this.startDate.getUTCMonth()) {
18775 if (this.startDate !== -Infinity && year <= this.startDate.getUTCFullYear()) {
18782 Roo.each(this.picker().select('.next', true).elements, function(v){
18784 switch (this.viewMode) {
18787 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear() && month >= this.endDate.getUTCMonth()) {
18793 if (this.endDate !== Infinity && year >= this.endDate.getUTCFullYear()) {
18801 moveMonth: function(date, dir)
18806 var new_date = new Date(date.valueOf()),
18807 day = new_date.getUTCDate(),
18808 month = new_date.getUTCMonth(),
18809 mag = Math.abs(dir),
18811 dir = dir > 0 ? 1 : -1;
18814 // If going back one month, make sure month is not current month
18815 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
18817 return new_date.getUTCMonth() == month;
18819 // If going forward one month, make sure month is as expected
18820 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
18822 return new_date.getUTCMonth() != new_month;
18824 new_month = month + dir;
18825 new_date.setUTCMonth(new_month);
18826 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
18827 if (new_month < 0 || new_month > 11) {
18828 new_month = (new_month + 12) % 12;
18831 // For magnitudes >1, move one month at a time...
18832 for (var i=0; i<mag; i++) {
18833 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
18834 new_date = this.moveMonth(new_date, dir);
18836 // ...then reset the day, keeping it in the new month
18837 new_month = new_date.getUTCMonth();
18838 new_date.setUTCDate(day);
18840 return new_month != new_date.getUTCMonth();
18843 // Common date-resetting loop -- if date is beyond end of month, make it
18846 new_date.setUTCDate(--day);
18847 new_date.setUTCMonth(new_month);
18852 moveYear: function(date, dir)
18854 return this.moveMonth(date, dir*12);
18857 dateWithinRange: function(date)
18859 return date >= this.startDate && date <= this.endDate;
18865 this.picker().remove();
18868 validateValue : function(value)
18870 if(value.length < 1) {
18871 if(this.allowBlank){
18877 if(value.length < this.minLength){
18880 if(value.length > this.maxLength){
18884 var vt = Roo.form.VTypes;
18885 if(!vt[this.vtype](value, this)){
18889 if(typeof this.validator == "function"){
18890 var msg = this.validator(value);
18896 if(this.regex && !this.regex.test(value)){
18900 if(typeof(this.parseDate(value)) == 'undefined'){
18904 if (this.endDate !== Infinity && this.parseDate(value).getTime() > this.endDate.getTime()) {
18908 if (this.startDate !== -Infinity && this.parseDate(value).getTime() < this.startDate.getTime()) {
18918 Roo.apply(Roo.bootstrap.DateField, {
18929 html: '<i class="fa fa-arrow-left"/>'
18939 html: '<i class="fa fa-arrow-right"/>'
18981 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
18982 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
18983 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
18984 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
18985 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
18998 navFnc: 'FullYear',
19003 navFnc: 'FullYear',
19008 Roo.apply(Roo.bootstrap.DateField, {
19012 cls: 'datepicker dropdown-menu roo-dynamic',
19016 cls: 'datepicker-days',
19020 cls: 'table-condensed',
19022 Roo.bootstrap.DateField.head,
19026 Roo.bootstrap.DateField.footer
19033 cls: 'datepicker-months',
19037 cls: 'table-condensed',
19039 Roo.bootstrap.DateField.head,
19040 Roo.bootstrap.DateField.content,
19041 Roo.bootstrap.DateField.footer
19048 cls: 'datepicker-years',
19052 cls: 'table-condensed',
19054 Roo.bootstrap.DateField.head,
19055 Roo.bootstrap.DateField.content,
19056 Roo.bootstrap.DateField.footer
19075 * @class Roo.bootstrap.TimeField
19076 * @extends Roo.bootstrap.Input
19077 * Bootstrap DateField class
19081 * Create a new TimeField
19082 * @param {Object} config The config object
19085 Roo.bootstrap.TimeField = function(config){
19086 Roo.bootstrap.TimeField.superclass.constructor.call(this, config);
19090 * Fires when this field show.
19091 * @param {Roo.bootstrap.DateField} thisthis
19092 * @param {Mixed} date The date value
19097 * Fires when this field hide.
19098 * @param {Roo.bootstrap.DateField} this
19099 * @param {Mixed} date The date value
19104 * Fires when select a date.
19105 * @param {Roo.bootstrap.DateField} this
19106 * @param {Mixed} date The date value
19112 Roo.extend(Roo.bootstrap.TimeField, Roo.bootstrap.Input, {
19115 * @cfg {String} format
19116 * The default time format string which can be overriden for localization support. The format must be
19117 * valid according to {@link Date#parseDate} (defaults to 'H:i').
19121 onRender: function(ct, position)
19124 Roo.bootstrap.TimeField.superclass.onRender.call(this, ct, position);
19126 this.el.select('>.input-group', true).first().createChild(Roo.bootstrap.TimeField.template);
19128 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19130 this.pop = this.picker().select('>.datepicker-time',true).first();
19131 this.pop.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19133 this.picker().on('mousedown', this.onMousedown, this);
19134 this.picker().on('click', this.onClick, this);
19136 this.picker().addClass('datepicker-dropdown');
19141 this.pop.select('span.hours-up', true).first().on('click', this.onIncrementHours, this);
19142 this.pop.select('span.hours-down', true).first().on('click', this.onDecrementHours, this);
19143 this.pop.select('span.minutes-up', true).first().on('click', this.onIncrementMinutes, this);
19144 this.pop.select('span.minutes-down', true).first().on('click', this.onDecrementMinutes, this);
19145 this.pop.select('button.period', true).first().on('click', this.onTogglePeriod, this);
19146 this.pop.select('button.ok', true).first().on('click', this.setTime, this);
19150 fireKey: function(e){
19151 if (!this.picker().isVisible()){
19152 if (e.keyCode == 27) { // allow escape to hide and re-show picker
19158 e.preventDefault();
19166 this.onTogglePeriod();
19169 this.onIncrementMinutes();
19172 this.onDecrementMinutes();
19181 onClick: function(e) {
19182 e.stopPropagation();
19183 e.preventDefault();
19186 picker : function()
19188 return this.el.select('.datepicker', true).first();
19191 fillTime: function()
19193 var time = this.pop.select('tbody', true).first();
19195 time.dom.innerHTML = '';
19210 cls: 'hours-up glyphicon glyphicon-chevron-up'
19230 cls: 'minutes-up glyphicon glyphicon-chevron-up'
19251 cls: 'timepicker-hour',
19266 cls: 'timepicker-minute',
19281 cls: 'btn btn-primary period',
19303 cls: 'hours-down glyphicon glyphicon-chevron-down'
19323 cls: 'minutes-down glyphicon glyphicon-chevron-down'
19341 this.time = (typeof(this.time) === 'undefined') ? new Date() : this.time;
19348 var hours = this.time.getHours();
19349 var minutes = this.time.getMinutes();
19362 hours = hours - 12;
19366 hours = '0' + hours;
19370 minutes = '0' + minutes;
19373 this.pop.select('.timepicker-hour', true).first().dom.innerHTML = hours;
19374 this.pop.select('.timepicker-minute', true).first().dom.innerHTML = minutes;
19375 this.pop.select('button', true).first().dom.innerHTML = period;
19381 this.picker().removeClass(['bottom-left', 'bottom-right', 'top-left', 'top-right']);
19383 var cls = ['bottom'];
19385 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){ // top
19392 if((Roo.lib.Dom.getViewWidth() + Roo.get(document.body).getScroll().left) - (this.inputEl().getLeft() + this.picker().getWidth()) < 0){ // left
19397 this.picker().addClass(cls.join('-'));
19401 Roo.each(cls, function(c){
19403 _this.picker().setTop(_this.inputEl().getHeight());
19407 _this.picker().setTop(0 - _this.picker().getHeight());
19412 _this.picker().setLeft(_this.inputEl().getLeft() + _this.inputEl().getWidth() - _this.el.getLeft() - _this.picker().getWidth());
19416 _this.picker().setLeft(_this.inputEl().getLeft() - _this.el.getLeft());
19423 onFocus : function()
19425 Roo.bootstrap.TimeField.superclass.onFocus.call(this);
19429 onBlur : function()
19431 Roo.bootstrap.TimeField.superclass.onBlur.call(this);
19437 this.picker().show();
19442 this.fireEvent('show', this, this.date);
19447 this.picker().hide();
19450 this.fireEvent('hide', this, this.date);
19453 setTime : function()
19456 this.setValue(this.time.format(this.format));
19458 this.fireEvent('select', this, this.date);
19463 onMousedown: function(e){
19464 e.stopPropagation();
19465 e.preventDefault();
19468 onIncrementHours: function()
19470 Roo.log('onIncrementHours');
19471 this.time = this.time.add(Date.HOUR, 1);
19476 onDecrementHours: function()
19478 Roo.log('onDecrementHours');
19479 this.time = this.time.add(Date.HOUR, -1);
19483 onIncrementMinutes: function()
19485 Roo.log('onIncrementMinutes');
19486 this.time = this.time.add(Date.MINUTE, 1);
19490 onDecrementMinutes: function()
19492 Roo.log('onDecrementMinutes');
19493 this.time = this.time.add(Date.MINUTE, -1);
19497 onTogglePeriod: function()
19499 Roo.log('onTogglePeriod');
19500 this.time = this.time.add(Date.HOUR, 12);
19507 Roo.apply(Roo.bootstrap.TimeField, {
19537 cls: 'btn btn-info ok',
19549 Roo.apply(Roo.bootstrap.TimeField, {
19553 cls: 'datepicker dropdown-menu',
19557 cls: 'datepicker-time',
19561 cls: 'table-condensed',
19563 Roo.bootstrap.TimeField.content,
19564 Roo.bootstrap.TimeField.footer
19583 * @class Roo.bootstrap.MonthField
19584 * @extends Roo.bootstrap.Input
19585 * Bootstrap MonthField class
19587 * @cfg {String} language default en
19590 * Create a new MonthField
19591 * @param {Object} config The config object
19594 Roo.bootstrap.MonthField = function(config){
19595 Roo.bootstrap.MonthField.superclass.constructor.call(this, config);
19600 * Fires when this field show.
19601 * @param {Roo.bootstrap.MonthField} this
19602 * @param {Mixed} date The date value
19607 * Fires when this field hide.
19608 * @param {Roo.bootstrap.MonthField} this
19609 * @param {Mixed} date The date value
19614 * Fires when select a date.
19615 * @param {Roo.bootstrap.MonthField} this
19616 * @param {String} oldvalue The old value
19617 * @param {String} newvalue The new value
19623 Roo.extend(Roo.bootstrap.MonthField, Roo.bootstrap.Input, {
19625 onRender: function(ct, position)
19628 Roo.bootstrap.MonthField.superclass.onRender.call(this, ct, position);
19630 this.language = this.language || 'en';
19631 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : this.language.split('-')[0];
19632 this.language = this.language in Roo.bootstrap.MonthField.dates ? this.language : "en";
19634 this.isRTL = Roo.bootstrap.MonthField.dates[this.language].rtl || false;
19635 this.isInline = false;
19636 this.isInput = true;
19637 this.component = this.el.select('.add-on', true).first() || false;
19638 this.component = (this.component && this.component.length === 0) ? false : this.component;
19639 this.hasInput = this.component && this.inputEL().length;
19641 this.pickerEl = Roo.get(document.body).createChild(Roo.bootstrap.MonthField.template);
19643 this.picker().setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
19645 this.picker().on('mousedown', this.onMousedown, this);
19646 this.picker().on('click', this.onClick, this);
19648 this.picker().addClass('datepicker-dropdown');
19650 Roo.each(this.picker().select('tbody > tr > td', true).elements, function(v){
19651 v.setStyle('width', '189px');
19658 if(this.isInline) {
19664 setValue: function(v, suppressEvent)
19666 var o = this.getValue();
19668 Roo.bootstrap.MonthField.superclass.setValue.call(this, v);
19672 if(suppressEvent !== true){
19673 this.fireEvent('select', this, o, v);
19678 getValue: function()
19683 onClick: function(e)
19685 e.stopPropagation();
19686 e.preventDefault();
19688 var target = e.getTarget();
19690 if(target.nodeName.toLowerCase() === 'i'){
19691 target = Roo.get(target).dom.parentNode;
19694 var nodeName = target.nodeName;
19695 var className = target.className;
19696 var html = target.innerHTML;
19698 if(nodeName.toLowerCase() != 'span' || className.indexOf('disabled') > -1 || className.indexOf('month') == -1){
19702 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].monthsShort.indexOf(html);
19704 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
19710 picker : function()
19712 return this.pickerEl;
19715 fillMonths: function()
19718 var months = this.picker().select('>.datepicker-months td', true).first();
19720 months.dom.innerHTML = '';
19726 html: Roo.bootstrap.MonthField.dates[this.language].monthsShort[i++]
19729 months.createChild(month);
19738 if(typeof(this.vIndex) == 'undefined' && this.value.length){
19739 this.vIndex = Roo.bootstrap.MonthField.dates[this.language].months.indexOf(this.value);
19742 Roo.each(this.pickerEl.select('> .datepicker-months tbody > tr > td > span', true).elements, function(e, k){
19743 e.removeClass('active');
19745 if(typeof(_this.vIndex) != 'undefined' && k == _this.vIndex){
19746 e.addClass('active');
19753 if(this.isInline) {
19757 this.picker().removeClass(['bottom', 'top']);
19759 if((Roo.lib.Dom.getViewHeight() + Roo.get(document.body).getScroll().top) - (this.inputEl().getBottom() + this.picker().getHeight()) < 0){
19761 * place to the top of element!
19765 this.picker().addClass('top');
19766 this.picker().setTop(this.inputEl().getTop() - this.picker().getHeight()).setLeft(this.inputEl().getLeft());
19771 this.picker().addClass('bottom');
19773 this.picker().setTop(this.inputEl().getBottom()).setLeft(this.inputEl().getLeft());
19776 onFocus : function()
19778 Roo.bootstrap.MonthField.superclass.onFocus.call(this);
19782 onBlur : function()
19784 Roo.bootstrap.MonthField.superclass.onBlur.call(this);
19786 var d = this.inputEl().getValue();
19795 this.picker().show();
19796 this.picker().select('>.datepicker-months', true).first().show();
19800 this.fireEvent('show', this, this.date);
19805 if(this.isInline) {
19808 this.picker().hide();
19809 this.fireEvent('hide', this, this.date);
19813 onMousedown: function(e)
19815 e.stopPropagation();
19816 e.preventDefault();
19821 Roo.bootstrap.MonthField.superclass.keyup.call(this);
19825 fireKey: function(e)
19827 if (!this.picker().isVisible()){
19828 if (e.keyCode == 27) {// allow escape to hide and re-show picker
19839 e.preventDefault();
19843 dir = e.keyCode == 37 ? -1 : 1;
19845 this.vIndex = this.vIndex + dir;
19847 if(this.vIndex < 0){
19851 if(this.vIndex > 11){
19855 if(isNaN(this.vIndex)){
19859 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
19865 dir = e.keyCode == 38 ? -1 : 1;
19867 this.vIndex = this.vIndex + dir * 4;
19869 if(this.vIndex < 0){
19873 if(this.vIndex > 11){
19877 if(isNaN(this.vIndex)){
19881 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
19886 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
19887 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
19891 e.preventDefault();
19894 if(typeof(this.vIndex) != 'undefined' && !isNaN(this.vIndex)){
19895 this.setValue(Roo.bootstrap.MonthField.dates[this.language].months[this.vIndex]);
19911 this.picker().remove();
19916 Roo.apply(Roo.bootstrap.MonthField, {
19935 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
19936 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
19941 Roo.apply(Roo.bootstrap.MonthField, {
19945 cls: 'datepicker dropdown-menu roo-dynamic',
19949 cls: 'datepicker-months',
19953 cls: 'table-condensed',
19955 Roo.bootstrap.DateField.content
19975 * @class Roo.bootstrap.CheckBox
19976 * @extends Roo.bootstrap.Input
19977 * Bootstrap CheckBox class
19979 * @cfg {String} valueOff The value that should go into the generated input element's value when unchecked.
19980 * @cfg {String} inputValue The value that should go into the generated input element's value when checked.
19981 * @cfg {String} boxLabel The text that appears beside the checkbox
19982 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the checkbox
19983 * @cfg {Boolean} checked initnal the element
19984 * @cfg {Boolean} inline inline the element (default false)
19985 * @cfg {String} groupId the checkbox group id // normal just use for checkbox
19988 * Create a new CheckBox
19989 * @param {Object} config The config object
19992 Roo.bootstrap.CheckBox = function(config){
19993 Roo.bootstrap.CheckBox.superclass.constructor.call(this, config);
19998 * Fires when the element is checked or unchecked.
19999 * @param {Roo.bootstrap.CheckBox} this This input
20000 * @param {Boolean} checked The new checked value
20007 Roo.extend(Roo.bootstrap.CheckBox, Roo.bootstrap.Input, {
20009 inputType: 'checkbox',
20017 getAutoCreate : function()
20019 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
20025 cfg.cls = 'form-group ' + this.inputType; //input-group
20028 cfg.cls += ' ' + this.inputType + '-inline';
20034 type : this.inputType,
20035 value : this.inputValue,
20036 cls : 'roo-' + this.inputType, //'form-box',
20037 placeholder : this.placeholder || ''
20041 if(this.inputType != 'radio'){
20045 cls : 'roo-hidden-value',
20046 value : this.checked ? this.valueOff : this.inputValue
20051 if (this.weight) { // Validity check?
20052 cfg.cls += " " + this.inputType + "-" + this.weight;
20055 if (this.disabled) {
20056 input.disabled=true;
20060 input.checked = this.checked;
20067 input.name = this.name;
20069 if(this.inputType != 'radio'){
20070 hidden.name = this.name;
20071 input.name = '_hidden_' + this.name;
20076 input.cls += ' input-' + this.size;
20081 ['xs','sm','md','lg'].map(function(size){
20082 if (settings[size]) {
20083 cfg.cls += ' col-' + size + '-' + settings[size];
20087 var inputblock = input;
20089 if (this.before || this.after) {
20092 cls : 'input-group',
20097 inputblock.cn.push({
20099 cls : 'input-group-addon',
20104 inputblock.cn.push(input);
20106 if(this.inputType != 'radio'){
20107 inputblock.cn.push(hidden);
20111 inputblock.cn.push({
20113 cls : 'input-group-addon',
20120 if (align ==='left' && this.fieldLabel.length) {
20121 // Roo.log("left and has label");
20126 cls : 'control-label',
20127 html : this.fieldLabel
20138 if(this.labelWidth > 12){
20139 cfg.cn[0].style = "width: " + this.labelWidth + 'px';
20142 if(this.labelWidth < 13 && this.labelmd == 0){
20143 this.labelmd = this.labelWidth;
20146 if(this.labellg > 0){
20147 cfg.cn[0].cls += ' col-lg-' + this.labellg;
20148 cfg.cn[1].cls += ' col-lg-' + (12 - this.labellg);
20151 if(this.labelmd > 0){
20152 cfg.cn[0].cls += ' col-md-' + this.labelmd;
20153 cfg.cn[1].cls += ' col-md-' + (12 - this.labelmd);
20156 if(this.labelsm > 0){
20157 cfg.cn[0].cls += ' col-sm-' + this.labelsm;
20158 cfg.cn[1].cls += ' col-sm-' + (12 - this.labelsm);
20161 if(this.labelxs > 0){
20162 cfg.cn[0].cls += ' col-xs-' + this.labelxs;
20163 cfg.cn[1].cls += ' col-xs-' + (12 - this.labelxs);
20166 } else if ( this.fieldLabel.length) {
20167 // Roo.log(" label");
20171 tag: this.boxLabel ? 'span' : 'label',
20173 cls: 'control-label box-input-label',
20174 //cls : 'input-group-addon',
20175 html : this.fieldLabel
20185 // Roo.log(" no label && no align");
20186 cfg.cn = [ inputblock ] ;
20192 var boxLabelCfg = {
20194 //'for': id, // box label is handled by onclick - so no for...
20196 html: this.boxLabel
20200 boxLabelCfg.tooltip = this.tooltip;
20203 cfg.cn.push(boxLabelCfg);
20206 if(this.inputType != 'radio'){
20207 cfg.cn.push(hidden);
20215 * return the real input element.
20217 inputEl: function ()
20219 return this.el.select('input.roo-' + this.inputType,true).first();
20221 hiddenEl: function ()
20223 return this.el.select('input.roo-hidden-value',true).first();
20226 labelEl: function()
20228 return this.el.select('label.control-label',true).first();
20230 /* depricated... */
20234 return this.labelEl();
20237 boxLabelEl: function()
20239 return this.el.select('label.box-label',true).first();
20242 initEvents : function()
20244 // Roo.bootstrap.CheckBox.superclass.initEvents.call(this);
20246 this.inputEl().on('click', this.onClick, this);
20248 if (this.boxLabel) {
20249 this.el.select('label.box-label',true).first().on('click', this.onClick, this);
20252 this.startValue = this.getValue();
20255 Roo.bootstrap.CheckBox.register(this);
20259 onClick : function()
20261 this.setChecked(!this.checked);
20264 setChecked : function(state,suppressEvent)
20266 this.startValue = this.getValue();
20268 if(this.inputType == 'radio'){
20270 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20271 e.dom.checked = false;
20274 this.inputEl().dom.checked = true;
20276 this.inputEl().dom.value = this.inputValue;
20278 if(suppressEvent !== true){
20279 this.fireEvent('check', this, true);
20287 this.checked = state;
20289 this.inputEl().dom.checked = state;
20292 this.hiddenEl().dom.value = state ? this.inputValue : this.valueOff;
20294 if(suppressEvent !== true){
20295 this.fireEvent('check', this, state);
20301 getValue : function()
20303 if(this.inputType == 'radio'){
20304 return this.getGroupValue();
20307 return this.hiddenEl().dom.value;
20311 getGroupValue : function()
20313 if(typeof(this.el.up('form').child('input[name='+this.name+']:checked', true)) == 'undefined'){
20317 return this.el.up('form').child('input[name='+this.name+']:checked', true).value;
20320 setValue : function(v,suppressEvent)
20322 if(this.inputType == 'radio'){
20323 this.setGroupValue(v, suppressEvent);
20327 this.setChecked(((typeof(v) == 'undefined') ? this.checked : (String(v) === String(this.inputValue))), suppressEvent);
20332 setGroupValue : function(v, suppressEvent)
20334 this.startValue = this.getValue();
20336 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20337 e.dom.checked = false;
20339 if(e.dom.value == v){
20340 e.dom.checked = true;
20344 if(suppressEvent !== true){
20345 this.fireEvent('check', this, true);
20353 validate : function()
20357 (this.inputType == 'radio' && this.validateRadio()) ||
20358 (this.inputType == 'checkbox' && this.validateCheckbox())
20364 this.markInvalid();
20368 validateRadio : function()
20370 if(this.allowBlank){
20376 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20377 if(!e.dom.checked){
20389 validateCheckbox : function()
20392 return (this.getValue() == this.inputValue || this.allowBlank) ? true : false;
20393 //return (this.getValue() == this.inputValue) ? true : false;
20396 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20404 for(var i in group){
20409 r = (group[i].getValue() == group[i].inputValue) ? true : false;
20416 * Mark this field as valid
20418 markValid : function()
20422 this.fireEvent('valid', this);
20424 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20427 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
20434 if(this.inputType == 'radio'){
20435 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20436 e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
20437 e.findParent('.form-group', false, true).addClass(_this.validClass);
20444 this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20445 this.el.findParent('.form-group', false, true).addClass(this.validClass);
20449 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20455 for(var i in group){
20456 group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20457 group[i].el.findParent('.form-group', false, true).addClass(this.validClass);
20462 * Mark this field as invalid
20463 * @param {String} msg The validation message
20465 markInvalid : function(msg)
20467 if(this.allowBlank){
20473 this.fireEvent('invalid', this, msg);
20475 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20478 label = Roo.bootstrap.FieldLabel.get(this.groupId + '-group');
20482 label.markInvalid();
20485 if(this.inputType == 'radio'){
20486 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20487 e.findParent('.form-group', false, true).removeClass([_this.invalidClass, _this.validClass]);
20488 e.findParent('.form-group', false, true).addClass(_this.invalidClass);
20495 this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20496 this.el.findParent('.form-group', false, true).addClass(this.invalidClass);
20500 var group = Roo.bootstrap.CheckBox.get(this.groupId);
20506 for(var i in group){
20507 group[i].el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20508 group[i].el.findParent('.form-group', false, true).addClass(this.invalidClass);
20513 clearInvalid : function()
20515 Roo.bootstrap.Input.prototype.clearInvalid.call(this);
20517 // this.el.findParent('.form-group', false, true).removeClass([this.invalidClass, this.validClass]);
20519 var label = Roo.bootstrap.FieldLabel.get(this.name + '-group');
20522 label.iconEl.removeClass(label.validClass);
20523 label.iconEl.removeClass(label.invalidClass);
20527 disable : function()
20529 if(this.inputType != 'radio'){
20530 Roo.bootstrap.CheckBox.superclass.disable.call(this);
20537 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20538 _this.getActionEl().addClass(this.disabledClass);
20539 e.dom.disabled = true;
20543 this.disabled = true;
20544 this.fireEvent("disable", this);
20548 enable : function()
20550 if(this.inputType != 'radio'){
20551 Roo.bootstrap.CheckBox.superclass.enable.call(this);
20558 Roo.each(this.el.up('form').select('input[name='+this.name+']', true).elements, function(e){
20559 _this.getActionEl().removeClass(this.disabledClass);
20560 e.dom.disabled = false;
20564 this.disabled = false;
20565 this.fireEvent("enable", this);
20571 Roo.apply(Roo.bootstrap.CheckBox, {
20576 * register a CheckBox Group
20577 * @param {Roo.bootstrap.CheckBox} the CheckBox to add
20579 register : function(checkbox)
20581 if(typeof(this.groups[checkbox.groupId]) == 'undefined'){
20582 this.groups[checkbox.groupId] = {};
20585 if(this.groups[checkbox.groupId].hasOwnProperty(checkbox.name)){
20589 this.groups[checkbox.groupId][checkbox.name] = checkbox;
20593 * fetch a CheckBox Group based on the group ID
20594 * @param {string} the group ID
20595 * @returns {Roo.bootstrap.CheckBox} the CheckBox group
20597 get: function(groupId) {
20598 if (typeof(this.groups[groupId]) == 'undefined') {
20602 return this.groups[groupId] ;
20615 * @class Roo.bootstrap.Radio
20616 * @extends Roo.bootstrap.Component
20617 * Bootstrap Radio class
20618 * @cfg {String} boxLabel - the label associated
20619 * @cfg {String} value - the value of radio
20622 * Create a new Radio
20623 * @param {Object} config The config object
20625 Roo.bootstrap.Radio = function(config){
20626 Roo.bootstrap.Radio.superclass.constructor.call(this, config);
20630 Roo.extend(Roo.bootstrap.Radio, Roo.bootstrap.Component, {
20636 getAutoCreate : function()
20640 cls : 'form-group radio',
20645 html : this.boxLabel
20653 initEvents : function()
20655 this.parent().register(this);
20657 this.el.on('click', this.onClick, this);
20661 onClick : function()
20663 this.setChecked(true);
20666 setChecked : function(state, suppressEvent)
20668 this.parent().setValue(this.value, suppressEvent);
20675 //<script type="text/javascript">
20678 * Based Ext JS Library 1.1.1
20679 * Copyright(c) 2006-2007, Ext JS, LLC.
20685 * @class Roo.HtmlEditorCore
20686 * @extends Roo.Component
20687 * Provides a the editing component for the HTML editors in Roo. (bootstrap and Roo.form)
20689 * any element that has display set to 'none' can cause problems in Safari and Firefox.<br/><br/>
20692 Roo.HtmlEditorCore = function(config){
20695 Roo.HtmlEditorCore.superclass.constructor.call(this, config);
20700 * @event initialize
20701 * Fires when the editor is fully initialized (including the iframe)
20702 * @param {Roo.HtmlEditorCore} this
20707 * Fires when the editor is first receives the focus. Any insertion must wait
20708 * until after this event.
20709 * @param {Roo.HtmlEditorCore} this
20713 * @event beforesync
20714 * Fires before the textarea is updated with content from the editor iframe. Return false
20715 * to cancel the sync.
20716 * @param {Roo.HtmlEditorCore} this
20717 * @param {String} html
20721 * @event beforepush
20722 * Fires before the iframe editor is updated with content from the textarea. Return false
20723 * to cancel the push.
20724 * @param {Roo.HtmlEditorCore} this
20725 * @param {String} html
20730 * Fires when the textarea is updated with content from the editor iframe.
20731 * @param {Roo.HtmlEditorCore} this
20732 * @param {String} html
20737 * Fires when the iframe editor is updated with content from the textarea.
20738 * @param {Roo.HtmlEditorCore} this
20739 * @param {String} html
20744 * @event editorevent
20745 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
20746 * @param {Roo.HtmlEditorCore} this
20752 // at this point this.owner is set, so we can start working out the whitelisted / blacklisted elements
20754 // defaults : white / black...
20755 this.applyBlacklists();
20762 Roo.extend(Roo.HtmlEditorCore, Roo.Component, {
20766 * @cfg {Roo.form.HtmlEditor|Roo.bootstrap.HtmlEditor} the owner field
20772 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
20777 * @cfg {Number} height (in pixels)
20781 * @cfg {Number} width (in pixels)
20786 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
20789 stylesheets: false,
20794 // private properties
20795 validationEvent : false,
20797 initialized : false,
20799 sourceEditMode : false,
20800 onFocus : Roo.emptyFn,
20802 hideMode:'offsets',
20806 // blacklist + whitelisted elements..
20813 * Protected method that will not generally be called directly. It
20814 * is called when the editor initializes the iframe with HTML contents. Override this method if you
20815 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
20817 getDocMarkup : function(){
20821 // inherit styels from page...??
20822 if (this.stylesheets === false) {
20824 Roo.get(document.head).select('style').each(function(node) {
20825 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
20828 Roo.get(document.head).select('link').each(function(node) {
20829 st += node.dom.outerHTML || new XMLSerializer().serializeToString(node.dom);
20832 } else if (!this.stylesheets.length) {
20834 st = '<style type="text/css">' +
20835 'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
20841 st += '<style type="text/css">' +
20842 'IMG { cursor: pointer } ' +
20846 return '<html><head>' + st +
20847 //<style type="text/css">' +
20848 //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
20850 ' </head><body class="roo-htmleditor-body"></body></html>';
20854 onRender : function(ct, position)
20857 //Roo.HtmlEditorCore.superclass.onRender.call(this, ct, position);
20858 this.el = this.owner.inputEl ? this.owner.inputEl() : this.owner.el;
20861 this.el.dom.style.border = '0 none';
20862 this.el.dom.setAttribute('tabIndex', -1);
20863 this.el.addClass('x-hidden hide');
20867 if(Roo.isIE){ // fix IE 1px bogus margin
20868 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
20872 this.frameId = Roo.id();
20876 var iframe = this.owner.wrap.createChild({
20878 cls: 'form-control', // bootstrap..
20880 name: this.frameId,
20881 frameBorder : 'no',
20882 'src' : Roo.SSL_SECURE_URL ? Roo.SSL_SECURE_URL : "javascript:false"
20887 this.iframe = iframe.dom;
20889 this.assignDocWin();
20891 this.doc.designMode = 'on';
20894 this.doc.write(this.getDocMarkup());
20898 var task = { // must defer to wait for browser to be ready
20900 //console.log("run task?" + this.doc.readyState);
20901 this.assignDocWin();
20902 if(this.doc.body || this.doc.readyState == 'complete'){
20904 this.doc.designMode="on";
20908 Roo.TaskMgr.stop(task);
20909 this.initEditor.defer(10, this);
20916 Roo.TaskMgr.start(task);
20921 onResize : function(w, h)
20923 Roo.log('resize: ' +w + ',' + h );
20924 //Roo.HtmlEditorCore.superclass.onResize.apply(this, arguments);
20928 if(typeof w == 'number'){
20930 this.iframe.style.width = w + 'px';
20932 if(typeof h == 'number'){
20934 this.iframe.style.height = h + 'px';
20936 (this.doc.body || this.doc.documentElement).style.height = (h - (this.iframePad*2)) + 'px';
20943 * Toggles the editor between standard and source edit mode.
20944 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
20946 toggleSourceEdit : function(sourceEditMode){
20948 this.sourceEditMode = sourceEditMode === true;
20950 if(this.sourceEditMode){
20952 Roo.get(this.iframe).addClass(['x-hidden','hide']); //FIXME - what's the BS styles for these
20955 Roo.get(this.iframe).removeClass(['x-hidden','hide']);
20956 //this.iframe.className = '';
20959 //this.setSize(this.owner.wrap.getSize());
20960 //this.fireEvent('editmodechange', this, this.sourceEditMode);
20967 * Protected method that will not generally be called directly. If you need/want
20968 * custom HTML cleanup, this is the method you should override.
20969 * @param {String} html The HTML to be cleaned
20970 * return {String} The cleaned HTML
20972 cleanHtml : function(html){
20973 html = String(html);
20974 if(html.length > 5){
20975 if(Roo.isSafari){ // strip safari nonsense
20976 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
20979 if(html == ' '){
20986 * HTML Editor -> Textarea
20987 * Protected method that will not generally be called directly. Syncs the contents
20988 * of the editor iframe with the textarea.
20990 syncValue : function(){
20991 if(this.initialized){
20992 var bd = (this.doc.body || this.doc.documentElement);
20993 //this.cleanUpPaste(); -- this is done else where and causes havoc..
20994 var html = bd.innerHTML;
20996 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
20997 var m = bs ? bs.match(/text-align:(.*?);/i) : false;
20999 html = '<div style="'+m[0]+'">' + html + '</div>';
21002 html = this.cleanHtml(html);
21003 // fix up the special chars.. normaly like back quotes in word...
21004 // however we do not want to do this with chinese..
21005 html = html.replace(/([\x80-\uffff])/g, function (a, b) {
21006 var cc = b.charCodeAt();
21008 (cc >= 0x4E00 && cc < 0xA000 ) ||
21009 (cc >= 0x3400 && cc < 0x4E00 ) ||
21010 (cc >= 0xf900 && cc < 0xfb00 )
21016 if(this.owner.fireEvent('beforesync', this, html) !== false){
21017 this.el.dom.value = html;
21018 this.owner.fireEvent('sync', this, html);
21024 * Protected method that will not generally be called directly. Pushes the value of the textarea
21025 * into the iframe editor.
21027 pushValue : function(){
21028 if(this.initialized){
21029 var v = this.el.dom.value.trim();
21031 // if(v.length < 1){
21035 if(this.owner.fireEvent('beforepush', this, v) !== false){
21036 var d = (this.doc.body || this.doc.documentElement);
21038 this.cleanUpPaste();
21039 this.el.dom.value = d.innerHTML;
21040 this.owner.fireEvent('push', this, v);
21046 deferFocus : function(){
21047 this.focus.defer(10, this);
21051 focus : function(){
21052 if(this.win && !this.sourceEditMode){
21059 assignDocWin: function()
21061 var iframe = this.iframe;
21064 this.doc = iframe.contentWindow.document;
21065 this.win = iframe.contentWindow;
21067 // if (!Roo.get(this.frameId)) {
21070 // this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
21071 // this.win = Roo.get(this.frameId).dom.contentWindow;
21073 if (!Roo.get(this.frameId) && !iframe.contentDocument) {
21077 this.doc = (iframe.contentDocument || Roo.get(this.frameId).dom.document);
21078 this.win = (iframe.contentWindow || Roo.get(this.frameId).dom.contentWindow);
21083 initEditor : function(){
21084 //console.log("INIT EDITOR");
21085 this.assignDocWin();
21089 this.doc.designMode="on";
21091 this.doc.write(this.getDocMarkup());
21094 var dbody = (this.doc.body || this.doc.documentElement);
21095 //var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
21096 // this copies styles from the containing element into thsi one..
21097 // not sure why we need all of this..
21098 //var ss = this.el.getStyles('font-size', 'background-image', 'background-repeat');
21100 //var ss = this.el.getStyles( 'background-image', 'background-repeat');
21101 //ss['background-attachment'] = 'fixed'; // w3c
21102 dbody.bgProperties = 'fixed'; // ie
21103 //Roo.DomHelper.applyStyles(dbody, ss);
21104 Roo.EventManager.on(this.doc, {
21105 //'mousedown': this.onEditorEvent,
21106 'mouseup': this.onEditorEvent,
21107 'dblclick': this.onEditorEvent,
21108 'click': this.onEditorEvent,
21109 'keyup': this.onEditorEvent,
21114 Roo.EventManager.on(this.doc, 'keypress', this.mozKeyPress, this);
21116 if(Roo.isIE || Roo.isSafari || Roo.isOpera){
21117 Roo.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
21119 this.initialized = true;
21121 this.owner.fireEvent('initialize', this);
21126 onDestroy : function(){
21132 //for (var i =0; i < this.toolbars.length;i++) {
21133 // // fixme - ask toolbars for heights?
21134 // this.toolbars[i].onDestroy();
21137 //this.wrap.dom.innerHTML = '';
21138 //this.wrap.remove();
21143 onFirstFocus : function(){
21145 this.assignDocWin();
21148 this.activated = true;
21151 if(Roo.isGecko){ // prevent silly gecko errors
21153 var s = this.win.getSelection();
21154 if(!s.focusNode || s.focusNode.nodeType != 3){
21155 var r = s.getRangeAt(0);
21156 r.selectNodeContents((this.doc.body || this.doc.documentElement));
21161 this.execCmd('useCSS', true);
21162 this.execCmd('styleWithCSS', false);
21165 this.owner.fireEvent('activate', this);
21169 adjustFont: function(btn){
21170 var adjust = btn.cmd == 'increasefontsize' ? 1 : -1;
21171 //if(Roo.isSafari){ // safari
21174 var v = parseInt(this.doc.queryCommandValue('FontSize')|| 3, 10);
21175 if(Roo.isSafari){ // safari
21176 var sm = { 10 : 1, 13: 2, 16:3, 18:4, 24: 5, 32:6, 48: 7 };
21177 v = (v < 10) ? 10 : v;
21178 v = (v > 48) ? 48 : v;
21179 v = typeof(sm[v]) == 'undefined' ? 1 : sm[v];
21184 v = Math.max(1, v+adjust);
21186 this.execCmd('FontSize', v );
21189 onEditorEvent : function(e)
21191 this.owner.fireEvent('editorevent', this, e);
21192 // this.updateToolbar();
21193 this.syncValue(); //we can not sync so often.. sync cleans, so this breaks stuff
21196 insertTag : function(tg)
21198 // could be a bit smarter... -> wrap the current selected tRoo..
21199 if (tg.toLowerCase() == 'span' || tg.toLowerCase() == 'code') {
21201 range = this.createRange(this.getSelection());
21202 var wrappingNode = this.doc.createElement(tg.toLowerCase());
21203 wrappingNode.appendChild(range.extractContents());
21204 range.insertNode(wrappingNode);
21211 this.execCmd("formatblock", tg);
21215 insertText : function(txt)
21219 var range = this.createRange();
21220 range.deleteContents();
21221 //alert(Sender.getAttribute('label'));
21223 range.insertNode(this.doc.createTextNode(txt));
21229 * Executes a Midas editor command on the editor document and performs necessary focus and
21230 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
21231 * @param {String} cmd The Midas command
21232 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
21234 relayCmd : function(cmd, value){
21236 this.execCmd(cmd, value);
21237 this.owner.fireEvent('editorevent', this);
21238 //this.updateToolbar();
21239 this.owner.deferFocus();
21243 * Executes a Midas editor command directly on the editor document.
21244 * For visual commands, you should use {@link #relayCmd} instead.
21245 * <b>This should only be called after the editor is initialized.</b>
21246 * @param {String} cmd The Midas command
21247 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
21249 execCmd : function(cmd, value){
21250 this.doc.execCommand(cmd, false, value === undefined ? null : value);
21257 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
21259 * @param {String} text | dom node..
21261 insertAtCursor : function(text)
21266 if(!this.activated){
21272 var r = this.doc.selection.createRange();
21283 if(Roo.isGecko || Roo.isOpera || Roo.isSafari){
21287 // from jquery ui (MIT licenced)
21289 var win = this.win;
21291 if (win.getSelection && win.getSelection().getRangeAt) {
21292 range = win.getSelection().getRangeAt(0);
21293 node = typeof(text) == 'string' ? range.createContextualFragment(text) : text;
21294 range.insertNode(node);
21295 } else if (win.document.selection && win.document.selection.createRange) {
21296 // no firefox support
21297 var txt = typeof(text) == 'string' ? text : text.outerHTML;
21298 win.document.selection.createRange().pasteHTML(txt);
21300 // no firefox support
21301 var txt = typeof(text) == 'string' ? text : text.outerHTML;
21302 this.execCmd('InsertHTML', txt);
21311 mozKeyPress : function(e){
21313 var c = e.getCharCode(), cmd;
21316 c = String.fromCharCode(c).toLowerCase();
21330 this.cleanUpPaste.defer(100, this);
21338 e.preventDefault();
21346 fixKeys : function(){ // load time branching for fastest keydown performance
21348 return function(e){
21349 var k = e.getKey(), r;
21352 r = this.doc.selection.createRange();
21355 r.pasteHTML('    ');
21362 r = this.doc.selection.createRange();
21364 var target = r.parentElement();
21365 if(!target || target.tagName.toLowerCase() != 'li'){
21367 r.pasteHTML('<br />');
21373 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
21374 this.cleanUpPaste.defer(100, this);
21380 }else if(Roo.isOpera){
21381 return function(e){
21382 var k = e.getKey();
21386 this.execCmd('InsertHTML','    ');
21389 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
21390 this.cleanUpPaste.defer(100, this);
21395 }else if(Roo.isSafari){
21396 return function(e){
21397 var k = e.getKey();
21401 this.execCmd('InsertText','\t');
21405 if (String.fromCharCode(k).toLowerCase() == 'v') { // paste
21406 this.cleanUpPaste.defer(100, this);
21414 getAllAncestors: function()
21416 var p = this.getSelectedNode();
21419 a.push(p); // push blank onto stack..
21420 p = this.getParentElement();
21424 while (p && (p.nodeType == 1) && (p.tagName.toLowerCase() != 'body')) {
21428 a.push(this.doc.body);
21432 lastSelNode : false,
21435 getSelection : function()
21437 this.assignDocWin();
21438 return Roo.isIE ? this.doc.selection : this.win.getSelection();
21441 getSelectedNode: function()
21443 // this may only work on Gecko!!!
21445 // should we cache this!!!!
21450 var range = this.createRange(this.getSelection()).cloneRange();
21453 var parent = range.parentElement();
21455 var testRange = range.duplicate();
21456 testRange.moveToElementText(parent);
21457 if (testRange.inRange(range)) {
21460 if ((parent.nodeType != 1) || (parent.tagName.toLowerCase() == 'body')) {
21463 parent = parent.parentElement;
21468 // is ancestor a text element.
21469 var ac = range.commonAncestorContainer;
21470 if (ac.nodeType == 3) {
21471 ac = ac.parentNode;
21474 var ar = ac.childNodes;
21477 var other_nodes = [];
21478 var has_other_nodes = false;
21479 for (var i=0;i<ar.length;i++) {
21480 if ((ar[i].nodeType == 3) && (!ar[i].data.length)) { // empty text ?
21483 // fullly contained node.
21485 if (this.rangeIntersectsNode(range,ar[i]) && this.rangeCompareNode(range,ar[i]) == 3) {
21490 // probably selected..
21491 if ((ar[i].nodeType == 1) && this.rangeIntersectsNode(range,ar[i]) && (this.rangeCompareNode(range,ar[i]) > 0)) {
21492 other_nodes.push(ar[i]);
21496 if (!this.rangeIntersectsNode(range,ar[i])|| (this.rangeCompareNode(range,ar[i]) == 0)) {
21501 has_other_nodes = true;
21503 if (!nodes.length && other_nodes.length) {
21504 nodes= other_nodes;
21506 if (has_other_nodes || !nodes.length || (nodes.length > 1)) {
21512 createRange: function(sel)
21514 // this has strange effects when using with
21515 // top toolbar - not sure if it's a great idea.
21516 //this.editor.contentWindow.focus();
21517 if (typeof sel != "undefined") {
21519 return sel.getRangeAt ? sel.getRangeAt(0) : sel.createRange();
21521 return this.doc.createRange();
21524 return this.doc.createRange();
21527 getParentElement: function()
21530 this.assignDocWin();
21531 var sel = Roo.isIE ? this.doc.selection : this.win.getSelection();
21533 var range = this.createRange(sel);
21536 var p = range.commonAncestorContainer;
21537 while (p.nodeType == 3) { // text node
21548 * Range intersection.. the hard stuff...
21552 * [ -- selected range --- ]
21556 * if end is before start or hits it. fail.
21557 * if start is after end or hits it fail.
21559 * if either hits (but other is outside. - then it's not
21565 // @see http://www.thismuchiknow.co.uk/?p=64.
21566 rangeIntersectsNode : function(range, node)
21568 var nodeRange = node.ownerDocument.createRange();
21570 nodeRange.selectNode(node);
21572 nodeRange.selectNodeContents(node);
21575 var rangeStartRange = range.cloneRange();
21576 rangeStartRange.collapse(true);
21578 var rangeEndRange = range.cloneRange();
21579 rangeEndRange.collapse(false);
21581 var nodeStartRange = nodeRange.cloneRange();
21582 nodeStartRange.collapse(true);
21584 var nodeEndRange = nodeRange.cloneRange();
21585 nodeEndRange.collapse(false);
21587 return rangeStartRange.compareBoundaryPoints(
21588 Range.START_TO_START, nodeEndRange) == -1 &&
21589 rangeEndRange.compareBoundaryPoints(
21590 Range.START_TO_START, nodeStartRange) == 1;
21594 rangeCompareNode : function(range, node)
21596 var nodeRange = node.ownerDocument.createRange();
21598 nodeRange.selectNode(node);
21600 nodeRange.selectNodeContents(node);
21604 range.collapse(true);
21606 nodeRange.collapse(true);
21608 var ss = range.compareBoundaryPoints( Range.START_TO_START, nodeRange);
21609 var ee = range.compareBoundaryPoints( Range.END_TO_END, nodeRange);
21611 //Roo.log(node.tagName + ': ss='+ss +', ee='+ee)
21613 var nodeIsBefore = ss == 1;
21614 var nodeIsAfter = ee == -1;
21616 if (nodeIsBefore && nodeIsAfter) {
21619 if (!nodeIsBefore && nodeIsAfter) {
21620 return 1; //right trailed.
21623 if (nodeIsBefore && !nodeIsAfter) {
21624 return 2; // left trailed.
21630 // private? - in a new class?
21631 cleanUpPaste : function()
21633 // cleans up the whole document..
21634 Roo.log('cleanuppaste');
21636 this.cleanUpChildren(this.doc.body);
21637 var clean = this.cleanWordChars(this.doc.body.innerHTML);
21638 if (clean != this.doc.body.innerHTML) {
21639 this.doc.body.innerHTML = clean;
21644 cleanWordChars : function(input) {// change the chars to hex code
21645 var he = Roo.HtmlEditorCore;
21647 var output = input;
21648 Roo.each(he.swapCodes, function(sw) {
21649 var swapper = new RegExp("\\u" + sw[0].toString(16), "g"); // hex codes
21651 output = output.replace(swapper, sw[1]);
21658 cleanUpChildren : function (n)
21660 if (!n.childNodes.length) {
21663 for (var i = n.childNodes.length-1; i > -1 ; i--) {
21664 this.cleanUpChild(n.childNodes[i]);
21671 cleanUpChild : function (node)
21674 //console.log(node);
21675 if (node.nodeName == "#text") {
21676 // clean up silly Windows -- stuff?
21679 if (node.nodeName == "#comment") {
21680 node.parentNode.removeChild(node);
21681 // clean up silly Windows -- stuff?
21684 var lcname = node.tagName.toLowerCase();
21685 // we ignore whitelists... ?? = not really the way to go, but we probably have not got a full
21686 // whitelist of tags..
21688 if (this.black.indexOf(lcname) > -1 && this.clearUp ) {
21690 node.parentNode.removeChild(node);
21695 var remove_keep_children= Roo.HtmlEditorCore.remove.indexOf(node.tagName.toLowerCase()) > -1;
21697 // remove <a name=....> as rendering on yahoo mailer is borked with this.
21698 // this will have to be flaged elsewhere - perhaps ablack=name... on the mailer..
21700 //if (node.tagName.toLowerCase() == 'a' && !node.hasAttribute('href')) {
21701 // remove_keep_children = true;
21704 if (remove_keep_children) {
21705 this.cleanUpChildren(node);
21706 // inserts everything just before this node...
21707 while (node.childNodes.length) {
21708 var cn = node.childNodes[0];
21709 node.removeChild(cn);
21710 node.parentNode.insertBefore(cn, node);
21712 node.parentNode.removeChild(node);
21716 if (!node.attributes || !node.attributes.length) {
21717 this.cleanUpChildren(node);
21721 function cleanAttr(n,v)
21724 if (v.match(/^\./) || v.match(/^\//)) {
21727 if (v.match(/^(http|https):\/\//) || v.match(/^mailto:/)) {
21730 if (v.match(/^#/)) {
21733 // Roo.log("(REMOVE TAG)"+ node.tagName +'.' + n + '=' + v);
21734 node.removeAttribute(n);
21738 var cwhite = this.cwhite;
21739 var cblack = this.cblack;
21741 function cleanStyle(n,v)
21743 if (v.match(/expression/)) { //XSS?? should we even bother..
21744 node.removeAttribute(n);
21748 var parts = v.split(/;/);
21751 Roo.each(parts, function(p) {
21752 p = p.replace(/^\s+/g,'').replace(/\s+$/g,'');
21756 var l = p.split(':').shift().replace(/\s+/g,'');
21757 l = l.replace(/^\s+/g,'').replace(/\s+$/g,'');
21759 if ( cwhite.length && cblack.indexOf(l) > -1) {
21760 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
21761 //node.removeAttribute(n);
21765 // only allow 'c whitelisted system attributes'
21766 if ( cwhite.length && cwhite.indexOf(l) < 0) {
21767 // Roo.log('(REMOVE CSS)' + node.tagName +'.' + n + ':'+l + '=' + v);
21768 //node.removeAttribute(n);
21778 if (clean.length) {
21779 node.setAttribute(n, clean.join(';'));
21781 node.removeAttribute(n);
21787 for (var i = node.attributes.length-1; i > -1 ; i--) {
21788 var a = node.attributes[i];
21791 if (a.name.toLowerCase().substr(0,2)=='on') {
21792 node.removeAttribute(a.name);
21795 if (Roo.HtmlEditorCore.ablack.indexOf(a.name.toLowerCase()) > -1) {
21796 node.removeAttribute(a.name);
21799 if (Roo.HtmlEditorCore.aclean.indexOf(a.name.toLowerCase()) > -1) {
21800 cleanAttr(a.name,a.value); // fixme..
21803 if (a.name == 'style') {
21804 cleanStyle(a.name,a.value);
21807 /// clean up MS crap..
21808 // tecnically this should be a list of valid class'es..
21811 if (a.name == 'class') {
21812 if (a.value.match(/^Mso/)) {
21813 node.className = '';
21816 if (a.value.match(/body/)) {
21817 node.className = '';
21828 this.cleanUpChildren(node);
21834 * Clean up MS wordisms...
21836 cleanWord : function(node)
21841 this.cleanWord(this.doc.body);
21844 if (node.nodeName == "#text") {
21845 // clean up silly Windows -- stuff?
21848 if (node.nodeName == "#comment") {
21849 node.parentNode.removeChild(node);
21850 // clean up silly Windows -- stuff?
21854 if (node.tagName.toLowerCase().match(/^(style|script|applet|embed|noframes|noscript)$/)) {
21855 node.parentNode.removeChild(node);
21859 // remove - but keep children..
21860 if (node.tagName.toLowerCase().match(/^(meta|link|\\?xml:|st1:|o:|font)/)) {
21861 while (node.childNodes.length) {
21862 var cn = node.childNodes[0];
21863 node.removeChild(cn);
21864 node.parentNode.insertBefore(cn, node);
21866 node.parentNode.removeChild(node);
21867 this.iterateChildren(node, this.cleanWord);
21871 if (node.className.length) {
21873 var cn = node.className.split(/\W+/);
21875 Roo.each(cn, function(cls) {
21876 if (cls.match(/Mso[a-zA-Z]+/)) {
21881 node.className = cna.length ? cna.join(' ') : '';
21883 node.removeAttribute("class");
21887 if (node.hasAttribute("lang")) {
21888 node.removeAttribute("lang");
21891 if (node.hasAttribute("style")) {
21893 var styles = node.getAttribute("style").split(";");
21895 Roo.each(styles, function(s) {
21896 if (!s.match(/:/)) {
21899 var kv = s.split(":");
21900 if (kv[0].match(/^(mso-|line|font|background|margin|padding|color)/)) {
21903 // what ever is left... we allow.
21906 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
21907 if (!nstyle.length) {
21908 node.removeAttribute('style');
21911 this.iterateChildren(node, this.cleanWord);
21917 * iterateChildren of a Node, calling fn each time, using this as the scole..
21918 * @param {DomNode} node node to iterate children of.
21919 * @param {Function} fn method of this class to call on each item.
21921 iterateChildren : function(node, fn)
21923 if (!node.childNodes.length) {
21926 for (var i = node.childNodes.length-1; i > -1 ; i--) {
21927 fn.call(this, node.childNodes[i])
21933 * cleanTableWidths.
21935 * Quite often pasting from word etc.. results in tables with column and widths.
21936 * This does not work well on fluid HTML layouts - like emails. - so this code should hunt an destroy them..
21939 cleanTableWidths : function(node)
21944 this.cleanTableWidths(this.doc.body);
21949 if (node.nodeName == "#text" || node.nodeName == "#comment") {
21952 Roo.log(node.tagName);
21953 if (!node.tagName.toLowerCase().match(/^(table|td|tr)$/)) {
21954 this.iterateChildren(node, this.cleanTableWidths);
21957 if (node.hasAttribute('width')) {
21958 node.removeAttribute('width');
21962 if (node.hasAttribute("style")) {
21965 var styles = node.getAttribute("style").split(";");
21967 Roo.each(styles, function(s) {
21968 if (!s.match(/:/)) {
21971 var kv = s.split(":");
21972 if (kv[0].match(/^\s*(width|min-width)\s*$/)) {
21975 // what ever is left... we allow.
21978 node.setAttribute("style", nstyle.length ? nstyle.join(';') : '');
21979 if (!nstyle.length) {
21980 node.removeAttribute('style');
21984 this.iterateChildren(node, this.cleanTableWidths);
21992 domToHTML : function(currentElement, depth, nopadtext) {
21994 depth = depth || 0;
21995 nopadtext = nopadtext || false;
21997 if (!currentElement) {
21998 return this.domToHTML(this.doc.body);
22001 //Roo.log(currentElement);
22003 var allText = false;
22004 var nodeName = currentElement.nodeName;
22005 var tagName = Roo.util.Format.htmlEncode(currentElement.tagName);
22007 if (nodeName == '#text') {
22009 return nopadtext ? currentElement.nodeValue : currentElement.nodeValue.trim();
22014 if (nodeName != 'BODY') {
22017 // Prints the node tagName, such as <A>, <IMG>, etc
22020 for(i = 0; i < currentElement.attributes.length;i++) {
22022 var aname = currentElement.attributes.item(i).name;
22023 if (!currentElement.attributes.item(i).value.length) {
22026 attr.push(aname + '="' + Roo.util.Format.htmlEncode(currentElement.attributes.item(i).value) + '"' );
22029 ret = "<"+currentElement.tagName+ ( attr.length ? (' ' + attr.join(' ') ) : '') + ">";
22038 if (['IMG', 'BR', 'HR', 'INPUT'].indexOf(tagName) > -1) {
22041 if (['PRE', 'TEXTAREA', 'TD', 'A', 'SPAN'].indexOf(tagName) > -1) { // or code?
22046 // Traverse the tree
22048 var currentElementChild = currentElement.childNodes.item(i);
22049 var allText = true;
22050 var innerHTML = '';
22052 while (currentElementChild) {
22053 // Formatting code (indent the tree so it looks nice on the screen)
22054 var nopad = nopadtext;
22055 if (lastnode == 'SPAN') {
22059 if (currentElementChild.nodeName == '#text') {
22060 var toadd = Roo.util.Format.htmlEncode(currentElementChild.nodeValue);
22061 toadd = nopadtext ? toadd : toadd.trim();
22062 if (!nopad && toadd.length > 80) {
22063 innerHTML += "\n" + (new Array( depth + 1 )).join( " " );
22065 innerHTML += toadd;
22068 currentElementChild = currentElement.childNodes.item(i);
22074 innerHTML += nopad ? '' : "\n" + (new Array( depth + 1 )).join( " " );
22076 // Recursively traverse the tree structure of the child node
22077 innerHTML += this.domToHTML(currentElementChild, depth+1, nopadtext);
22078 lastnode = currentElementChild.nodeName;
22080 currentElementChild=currentElement.childNodes.item(i);
22086 // The remaining code is mostly for formatting the tree
22087 ret+= nopadtext ? '' : "\n" + (new Array( depth )).join( " " );
22092 ret+= "</"+tagName+">";
22098 applyBlacklists : function()
22100 var w = typeof(this.owner.white) != 'undefined' && this.owner.white ? this.owner.white : [];
22101 var b = typeof(this.owner.black) != 'undefined' && this.owner.black ? this.owner.black : [];
22105 Roo.each(Roo.HtmlEditorCore.white, function(tag) {
22106 if (b.indexOf(tag) > -1) {
22109 this.white.push(tag);
22113 Roo.each(w, function(tag) {
22114 if (b.indexOf(tag) > -1) {
22117 if (this.white.indexOf(tag) > -1) {
22120 this.white.push(tag);
22125 Roo.each(Roo.HtmlEditorCore.black, function(tag) {
22126 if (w.indexOf(tag) > -1) {
22129 this.black.push(tag);
22133 Roo.each(b, function(tag) {
22134 if (w.indexOf(tag) > -1) {
22137 if (this.black.indexOf(tag) > -1) {
22140 this.black.push(tag);
22145 w = typeof(this.owner.cwhite) != 'undefined' && this.owner.cwhite ? this.owner.cwhite : [];
22146 b = typeof(this.owner.cblack) != 'undefined' && this.owner.cblack ? this.owner.cblack : [];
22150 Roo.each(Roo.HtmlEditorCore.cwhite, function(tag) {
22151 if (b.indexOf(tag) > -1) {
22154 this.cwhite.push(tag);
22158 Roo.each(w, function(tag) {
22159 if (b.indexOf(tag) > -1) {
22162 if (this.cwhite.indexOf(tag) > -1) {
22165 this.cwhite.push(tag);
22170 Roo.each(Roo.HtmlEditorCore.cblack, function(tag) {
22171 if (w.indexOf(tag) > -1) {
22174 this.cblack.push(tag);
22178 Roo.each(b, function(tag) {
22179 if (w.indexOf(tag) > -1) {
22182 if (this.cblack.indexOf(tag) > -1) {
22185 this.cblack.push(tag);
22190 setStylesheets : function(stylesheets)
22192 if(typeof(stylesheets) == 'string'){
22193 Roo.get(this.iframe.contentDocument.head).createChild({
22195 rel : 'stylesheet',
22204 Roo.each(stylesheets, function(s) {
22209 Roo.get(_this.iframe.contentDocument.head).createChild({
22211 rel : 'stylesheet',
22220 removeStylesheets : function()
22224 Roo.each(Roo.get(_this.iframe.contentDocument.head).select('link[rel=stylesheet]', true).elements, function(s){
22229 // hide stuff that is not compatible
22243 * @event specialkey
22247 * @cfg {String} fieldClass @hide
22250 * @cfg {String} focusClass @hide
22253 * @cfg {String} autoCreate @hide
22256 * @cfg {String} inputType @hide
22259 * @cfg {String} invalidClass @hide
22262 * @cfg {String} invalidText @hide
22265 * @cfg {String} msgFx @hide
22268 * @cfg {String} validateOnBlur @hide
22272 Roo.HtmlEditorCore.white = [
22273 'area', 'br', 'img', 'input', 'hr', 'wbr',
22275 'address', 'blockquote', 'center', 'dd', 'dir', 'div',
22276 'dl', 'dt', 'h1', 'h2', 'h3', 'h4',
22277 'h5', 'h6', 'hr', 'isindex', 'listing', 'marquee',
22278 'menu', 'multicol', 'ol', 'p', 'plaintext', 'pre',
22279 'table', 'ul', 'xmp',
22281 'caption', 'col', 'colgroup', 'tbody', 'td', 'tfoot', 'th',
22284 'dir', 'menu', 'ol', 'ul', 'dl',
22290 Roo.HtmlEditorCore.black = [
22291 // 'embed', 'object', // enable - backend responsiblity to clean thiese
22293 'base', 'basefont', 'bgsound', 'blink', 'body',
22294 'frame', 'frameset', 'head', 'html', 'ilayer',
22295 'iframe', 'layer', 'link', 'meta', 'object',
22296 'script', 'style' ,'title', 'xml' // clean later..
22298 Roo.HtmlEditorCore.clean = [
22299 'script', 'style', 'title', 'xml'
22301 Roo.HtmlEditorCore.remove = [
22306 Roo.HtmlEditorCore.ablack = [
22310 Roo.HtmlEditorCore.aclean = [
22311 'action', 'background', 'codebase', 'dynsrc', 'href', 'lowsrc'
22315 Roo.HtmlEditorCore.pwhite= [
22316 'http', 'https', 'mailto'
22319 // white listed style attributes.
22320 Roo.HtmlEditorCore.cwhite= [
22321 // 'text-align', /// default is to allow most things..
22327 // black listed style attributes.
22328 Roo.HtmlEditorCore.cblack= [
22329 // 'font-size' -- this can be set by the project
22333 Roo.HtmlEditorCore.swapCodes =[
22352 * @class Roo.bootstrap.HtmlEditor
22353 * @extends Roo.bootstrap.TextArea
22354 * Bootstrap HtmlEditor class
22357 * Create a new HtmlEditor
22358 * @param {Object} config The config object
22361 Roo.bootstrap.HtmlEditor = function(config){
22362 Roo.bootstrap.HtmlEditor.superclass.constructor.call(this, config);
22363 if (!this.toolbars) {
22364 this.toolbars = [];
22366 this.editorcore = new Roo.HtmlEditorCore(Roo.apply({ owner : this} , config));
22369 * @event initialize
22370 * Fires when the editor is fully initialized (including the iframe)
22371 * @param {HtmlEditor} this
22376 * Fires when the editor is first receives the focus. Any insertion must wait
22377 * until after this event.
22378 * @param {HtmlEditor} this
22382 * @event beforesync
22383 * Fires before the textarea is updated with content from the editor iframe. Return false
22384 * to cancel the sync.
22385 * @param {HtmlEditor} this
22386 * @param {String} html
22390 * @event beforepush
22391 * Fires before the iframe editor is updated with content from the textarea. Return false
22392 * to cancel the push.
22393 * @param {HtmlEditor} this
22394 * @param {String} html
22399 * Fires when the textarea is updated with content from the editor iframe.
22400 * @param {HtmlEditor} this
22401 * @param {String} html
22406 * Fires when the iframe editor is updated with content from the textarea.
22407 * @param {HtmlEditor} this
22408 * @param {String} html
22412 * @event editmodechange
22413 * Fires when the editor switches edit modes
22414 * @param {HtmlEditor} this
22415 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
22417 editmodechange: true,
22419 * @event editorevent
22420 * Fires when on any editor (mouse up/down cursor movement etc.) - used for toolbar hooks.
22421 * @param {HtmlEditor} this
22425 * @event firstfocus
22426 * Fires when on first focus - needed by toolbars..
22427 * @param {HtmlEditor} this
22432 * Auto save the htmlEditor value as a file into Events
22433 * @param {HtmlEditor} this
22437 * @event savedpreview
22438 * preview the saved version of htmlEditor
22439 * @param {HtmlEditor} this
22446 Roo.extend(Roo.bootstrap.HtmlEditor, Roo.bootstrap.TextArea, {
22450 * @cfg {Array} toolbars Array of toolbars. - defaults to just the Standard one
22455 * @cfg {String} resizable 's' or 'se' or 'e' - wrapps the element in a
22460 * @cfg {Number} height (in pixels)
22464 * @cfg {Number} width (in pixels)
22469 * @cfg {Array} stylesheets url of stylesheets. set to [] to disable stylesheets.
22472 stylesheets: false,
22477 // private properties
22478 validationEvent : false,
22480 initialized : false,
22483 onFocus : Roo.emptyFn,
22485 hideMode:'offsets',
22488 tbContainer : false,
22490 toolbarContainer :function() {
22491 return this.wrap.select('.x-html-editor-tb',true).first();
22495 * Protected method that will not generally be called directly. It
22496 * is called when the editor creates its toolbar. Override this method if you need to
22497 * add custom toolbar buttons.
22498 * @param {HtmlEditor} editor
22500 createToolbar : function(){
22502 Roo.log("create toolbars");
22504 this.toolbars = [ new Roo.bootstrap.htmleditor.ToolbarStandard({editor: this} ) ];
22505 this.toolbars[0].render(this.toolbarContainer());
22509 // if (!editor.toolbars || !editor.toolbars.length) {
22510 // editor.toolbars = [ new Roo.bootstrap.HtmlEditor.ToolbarStandard() ]; // can be empty?
22513 // for (var i =0 ; i < editor.toolbars.length;i++) {
22514 // editor.toolbars[i] = Roo.factory(
22515 // typeof(editor.toolbars[i]) == 'string' ?
22516 // { xtype: editor.toolbars[i]} : editor.toolbars[i],
22517 // Roo.bootstrap.HtmlEditor);
22518 // editor.toolbars[i].init(editor);
22524 onRender : function(ct, position)
22526 // Roo.log("Call onRender: " + this.xtype);
22528 Roo.bootstrap.HtmlEditor.superclass.onRender.call(this, ct, position);
22530 this.wrap = this.inputEl().wrap({
22531 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
22534 this.editorcore.onRender(ct, position);
22536 if (this.resizable) {
22537 this.resizeEl = new Roo.Resizable(this.wrap, {
22541 minHeight : this.height,
22542 height: this.height,
22543 handles : this.resizable,
22546 resize : function(r, w, h) {
22547 _t.onResize(w,h); // -something
22553 this.createToolbar(this);
22556 if(!this.width && this.resizable){
22557 this.setSize(this.wrap.getSize());
22559 if (this.resizeEl) {
22560 this.resizeEl.resizeTo.defer(100, this.resizeEl,[ this.width,this.height ] );
22561 // should trigger onReize..
22567 onResize : function(w, h)
22569 Roo.log('resize: ' +w + ',' + h );
22570 Roo.bootstrap.HtmlEditor.superclass.onResize.apply(this, arguments);
22574 if(this.inputEl() ){
22575 if(typeof w == 'number'){
22576 var aw = w - this.wrap.getFrameWidth('lr');
22577 this.inputEl().setWidth(this.adjustWidth('textarea', aw));
22580 if(typeof h == 'number'){
22581 var tbh = -11; // fixme it needs to tool bar size!
22582 for (var i =0; i < this.toolbars.length;i++) {
22583 // fixme - ask toolbars for heights?
22584 tbh += this.toolbars[i].el.getHeight();
22585 //if (this.toolbars[i].footer) {
22586 // tbh += this.toolbars[i].footer.el.getHeight();
22594 var ah = h - this.wrap.getFrameWidth('tb') - tbh;// this.tb.el.getHeight();
22595 ah -= 5; // knock a few pixes off for look..
22596 this.inputEl().setHeight(this.adjustWidth('textarea', ah));
22600 Roo.log('onResize:' + [w,h,ew,eh].join(',') );
22601 this.editorcore.onResize(ew,eh);
22606 * Toggles the editor between standard and source edit mode.
22607 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
22609 toggleSourceEdit : function(sourceEditMode)
22611 this.editorcore.toggleSourceEdit(sourceEditMode);
22613 if(this.editorcore.sourceEditMode){
22614 Roo.log('editor - showing textarea');
22617 // Roo.log(this.syncValue());
22619 this.inputEl().removeClass(['hide', 'x-hidden']);
22620 this.inputEl().dom.removeAttribute('tabIndex');
22621 this.inputEl().focus();
22623 Roo.log('editor - hiding textarea');
22625 // Roo.log(this.pushValue());
22628 this.inputEl().addClass(['hide', 'x-hidden']);
22629 this.inputEl().dom.setAttribute('tabIndex', -1);
22630 //this.deferFocus();
22633 if(this.resizable){
22634 this.setSize(this.wrap.getSize());
22637 this.fireEvent('editmodechange', this, this.editorcore.sourceEditMode);
22640 // private (for BoxComponent)
22641 adjustSize : Roo.BoxComponent.prototype.adjustSize,
22643 // private (for BoxComponent)
22644 getResizeEl : function(){
22648 // private (for BoxComponent)
22649 getPositionEl : function(){
22654 initEvents : function(){
22655 this.originalValue = this.getValue();
22659 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
22662 // markInvalid : Roo.emptyFn,
22664 // * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
22667 // clearInvalid : Roo.emptyFn,
22669 setValue : function(v){
22670 Roo.bootstrap.HtmlEditor.superclass.setValue.call(this, v);
22671 this.editorcore.pushValue();
22676 deferFocus : function(){
22677 this.focus.defer(10, this);
22681 focus : function(){
22682 this.editorcore.focus();
22688 onDestroy : function(){
22694 for (var i =0; i < this.toolbars.length;i++) {
22695 // fixme - ask toolbars for heights?
22696 this.toolbars[i].onDestroy();
22699 this.wrap.dom.innerHTML = '';
22700 this.wrap.remove();
22705 onFirstFocus : function(){
22706 //Roo.log("onFirstFocus");
22707 this.editorcore.onFirstFocus();
22708 for (var i =0; i < this.toolbars.length;i++) {
22709 this.toolbars[i].onFirstFocus();
22715 syncValue : function()
22717 this.editorcore.syncValue();
22720 pushValue : function()
22722 this.editorcore.pushValue();
22726 // hide stuff that is not compatible
22740 * @event specialkey
22744 * @cfg {String} fieldClass @hide
22747 * @cfg {String} focusClass @hide
22750 * @cfg {String} autoCreate @hide
22753 * @cfg {String} inputType @hide
22756 * @cfg {String} invalidClass @hide
22759 * @cfg {String} invalidText @hide
22762 * @cfg {String} msgFx @hide
22765 * @cfg {String} validateOnBlur @hide
22774 Roo.namespace('Roo.bootstrap.htmleditor');
22776 * @class Roo.bootstrap.HtmlEditorToolbar1
22781 new Roo.bootstrap.HtmlEditor({
22784 new Roo.bootstrap.HtmlEditorToolbar1({
22785 disable : { fonts: 1 , format: 1, ..., ... , ...],
22791 * @cfg {Object} disable List of elements to disable..
22792 * @cfg {Array} btns List of additional buttons.
22796 * .x-html-editor-tb .x-edit-none .x-btn-text { background: none; }
22799 Roo.bootstrap.htmleditor.ToolbarStandard = function(config)
22802 Roo.apply(this, config);
22804 // default disabled, based on 'good practice'..
22805 this.disable = this.disable || {};
22806 Roo.applyIf(this.disable, {
22809 specialElements : true
22811 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.constructor.call(this, config);
22813 this.editor = config.editor;
22814 this.editorcore = config.editor.editorcore;
22816 this.buttons = new Roo.util.MixedCollection(false, function(o) { return o.cmd; });
22818 //Roo.form.HtmlEditorToolbar1.superclass.constructor.call(this, editor.wrap.dom.firstChild, [], config);
22819 // dont call parent... till later.
22821 Roo.extend(Roo.bootstrap.htmleditor.ToolbarStandard, Roo.bootstrap.NavSimplebar, {
22826 editorcore : false,
22831 "h1","h2","h3","h4","h5","h6",
22833 "abbr", "acronym", "address", "cite", "samp", "var",
22837 onRender : function(ct, position)
22839 // Roo.log("Call onRender: " + this.xtype);
22841 Roo.bootstrap.htmleditor.ToolbarStandard.superclass.onRender.call(this, ct, position);
22843 this.el.dom.style.marginBottom = '0';
22845 var editorcore = this.editorcore;
22846 var editor= this.editor;
22849 var btn = function(id,cmd , toggle, handler){
22851 var event = toggle ? 'toggle' : 'click';
22856 xns: Roo.bootstrap,
22859 enableToggle:toggle !== false,
22861 pressed : toggle ? false : null,
22864 a.listeners[toggle ? 'toggle' : 'click'] = function() {
22865 handler ? handler.call(_this,this) :_this.onBtnClick.call(_this, cmd || id);
22874 xns: Roo.bootstrap,
22875 glyphicon : 'font',
22879 xns: Roo.bootstrap,
22883 Roo.each(this.formats, function(f) {
22884 style.menu.items.push({
22886 xns: Roo.bootstrap,
22887 html : '<'+ f+' style="margin:2px">'+f +'</'+ f+'>',
22892 editorcore.insertTag(this.tagname);
22899 children.push(style);
22902 btn('bold',false,true);
22903 btn('italic',false,true);
22904 btn('align-left', 'justifyleft',true);
22905 btn('align-center', 'justifycenter',true);
22906 btn('align-right' , 'justifyright',true);
22907 btn('link', false, false, function(btn) {
22908 //Roo.log("create link?");
22909 var url = prompt(this.createLinkText, this.defaultLinkValue);
22910 if(url && url != 'http:/'+'/'){
22911 this.editorcore.relayCmd('createlink', url);
22914 btn('list','insertunorderedlist',true);
22915 btn('pencil', false,true, function(btn){
22918 this.toggleSourceEdit(btn.pressed);
22924 xns: Roo.bootstrap,
22929 xns: Roo.bootstrap,
22934 cog.menu.items.push({
22936 xns: Roo.bootstrap,
22937 html : Clean styles,
22942 editorcore.insertTag(this.tagname);
22951 this.xtype = 'NavSimplebar';
22953 for(var i=0;i< children.length;i++) {
22955 this.buttons.add(this.addxtypeChild(children[i]));
22959 editor.on('editorevent', this.updateToolbar, this);
22961 onBtnClick : function(id)
22963 this.editorcore.relayCmd(id);
22964 this.editorcore.focus();
22968 * Protected method that will not generally be called directly. It triggers
22969 * a toolbar update by reading the markup state of the current selection in the editor.
22971 updateToolbar: function(){
22973 if(!this.editorcore.activated){
22974 this.editor.onFirstFocus(); // is this neeed?
22978 var btns = this.buttons;
22979 var doc = this.editorcore.doc;
22980 btns.get('bold').setActive(doc.queryCommandState('bold'));
22981 btns.get('italic').setActive(doc.queryCommandState('italic'));
22982 //btns.get('underline').setActive(doc.queryCommandState('underline'));
22984 btns.get('align-left').setActive(doc.queryCommandState('justifyleft'));
22985 btns.get('align-center').setActive(doc.queryCommandState('justifycenter'));
22986 btns.get('align-right').setActive(doc.queryCommandState('justifyright'));
22988 //btns[frameId + '-insertorderedlist').setActive(doc.queryCommandState('insertorderedlist'));
22989 btns.get('list').setActive(doc.queryCommandState('insertunorderedlist'));
22992 var ans = this.editorcore.getAllAncestors();
22993 if (this.formatCombo) {
22996 var store = this.formatCombo.store;
22997 this.formatCombo.setValue("");
22998 for (var i =0; i < ans.length;i++) {
22999 if (ans[i] && store.query('tag',ans[i].tagName.toLowerCase(), false).length) {
23001 this.formatCombo.setValue(ans[i].tagName.toLowerCase());
23009 // hides menus... - so this cant be on a menu...
23010 Roo.bootstrap.MenuMgr.hideAll();
23012 Roo.bootstrap.MenuMgr.hideAll();
23013 //this.editorsyncValue();
23015 onFirstFocus: function() {
23016 this.buttons.each(function(item){
23020 toggleSourceEdit : function(sourceEditMode){
23023 if(sourceEditMode){
23024 Roo.log("disabling buttons");
23025 this.buttons.each( function(item){
23026 if(item.cmd != 'pencil'){
23032 Roo.log("enabling buttons");
23033 if(this.editorcore.initialized){
23034 this.buttons.each( function(item){
23040 Roo.log("calling toggole on editor");
23041 // tell the editor that it's been pressed..
23042 this.editor.toggleSourceEdit(sourceEditMode);
23052 * @class Roo.bootstrap.Table.AbstractSelectionModel
23053 * @extends Roo.util.Observable
23054 * Abstract base class for grid SelectionModels. It provides the interface that should be
23055 * implemented by descendant classes. This class should not be directly instantiated.
23058 Roo.bootstrap.Table.AbstractSelectionModel = function(){
23059 this.locked = false;
23060 Roo.bootstrap.Table.AbstractSelectionModel.superclass.constructor.call(this);
23064 Roo.extend(Roo.bootstrap.Table.AbstractSelectionModel, Roo.util.Observable, {
23065 /** @ignore Called by the grid automatically. Do not call directly. */
23066 init : function(grid){
23072 * Locks the selections.
23075 this.locked = true;
23079 * Unlocks the selections.
23081 unlock : function(){
23082 this.locked = false;
23086 * Returns true if the selections are locked.
23087 * @return {Boolean}
23089 isLocked : function(){
23090 return this.locked;
23094 * @extends Roo.bootstrap.Table.AbstractSelectionModel
23095 * @class Roo.bootstrap.Table.RowSelectionModel
23096 * The default SelectionModel used by {@link Roo.bootstrap.Table}.
23097 * It supports multiple selections and keyboard selection/navigation.
23099 * @param {Object} config
23102 Roo.bootstrap.Table.RowSelectionModel = function(config){
23103 Roo.apply(this, config);
23104 this.selections = new Roo.util.MixedCollection(false, function(o){
23109 this.lastActive = false;
23113 * @event selectionchange
23114 * Fires when the selection changes
23115 * @param {SelectionModel} this
23117 "selectionchange" : true,
23119 * @event afterselectionchange
23120 * Fires after the selection changes (eg. by key press or clicking)
23121 * @param {SelectionModel} this
23123 "afterselectionchange" : true,
23125 * @event beforerowselect
23126 * Fires when a row is selected being selected, return false to cancel.
23127 * @param {SelectionModel} this
23128 * @param {Number} rowIndex The selected index
23129 * @param {Boolean} keepExisting False if other selections will be cleared
23131 "beforerowselect" : true,
23134 * Fires when a row is selected.
23135 * @param {SelectionModel} this
23136 * @param {Number} rowIndex The selected index
23137 * @param {Roo.data.Record} r The record
23139 "rowselect" : true,
23141 * @event rowdeselect
23142 * Fires when a row is deselected.
23143 * @param {SelectionModel} this
23144 * @param {Number} rowIndex The selected index
23146 "rowdeselect" : true
23148 Roo.bootstrap.Table.RowSelectionModel.superclass.constructor.call(this);
23149 this.locked = false;
23152 Roo.extend(Roo.bootstrap.Table.RowSelectionModel, Roo.bootstrap.Table.AbstractSelectionModel, {
23154 * @cfg {Boolean} singleSelect
23155 * True to allow selection of only one row at a time (defaults to false)
23157 singleSelect : false,
23160 initEvents : function()
23163 //if(!this.grid.enableDragDrop && !this.grid.enableDrag){
23164 // this.growclickrid.on("mousedown", this.handleMouseDown, this);
23165 //}else{ // allow click to work like normal
23166 // this.grid.on("rowclick", this.handleDragableRowClick, this);
23168 //this.grid.on("rowdblclick", this.handleMouseDBClick, this);
23169 this.grid.on("rowclick", this.handleMouseDown, this);
23171 this.rowNav = new Roo.KeyNav(this.grid.getGridEl(), {
23172 "up" : function(e){
23174 this.selectPrevious(e.shiftKey);
23175 }else if(this.last !== false && this.lastActive !== false){
23176 var last = this.last;
23177 this.selectRange(this.last, this.lastActive-1);
23178 this.grid.getView().focusRow(this.lastActive);
23179 if(last !== false){
23183 this.selectFirstRow();
23185 this.fireEvent("afterselectionchange", this);
23187 "down" : function(e){
23189 this.selectNext(e.shiftKey);
23190 }else if(this.last !== false && this.lastActive !== false){
23191 var last = this.last;
23192 this.selectRange(this.last, this.lastActive+1);
23193 this.grid.getView().focusRow(this.lastActive);
23194 if(last !== false){
23198 this.selectFirstRow();
23200 this.fireEvent("afterselectionchange", this);
23204 this.grid.store.on('load', function(){
23205 this.selections.clear();
23208 var view = this.grid.view;
23209 view.on("refresh", this.onRefresh, this);
23210 view.on("rowupdated", this.onRowUpdated, this);
23211 view.on("rowremoved", this.onRemove, this);
23216 onRefresh : function()
23218 var ds = this.grid.store, i, v = this.grid.view;
23219 var s = this.selections;
23220 s.each(function(r){
23221 if((i = ds.indexOfId(r.id)) != -1){
23230 onRemove : function(v, index, r){
23231 this.selections.remove(r);
23235 onRowUpdated : function(v, index, r){
23236 if(this.isSelected(r)){
23237 v.onRowSelect(index);
23243 * @param {Array} records The records to select
23244 * @param {Boolean} keepExisting (optional) True to keep existing selections
23246 selectRecords : function(records, keepExisting)
23249 this.clearSelections();
23251 var ds = this.grid.store;
23252 for(var i = 0, len = records.length; i < len; i++){
23253 this.selectRow(ds.indexOf(records[i]), true);
23258 * Gets the number of selected rows.
23261 getCount : function(){
23262 return this.selections.length;
23266 * Selects the first row in the grid.
23268 selectFirstRow : function(){
23273 * Select the last row.
23274 * @param {Boolean} keepExisting (optional) True to keep existing selections
23276 selectLastRow : function(keepExisting){
23277 //this.selectRow(this.grid.dataSource.getCount() - 1, keepExisting);
23278 this.selectRow(this.grid.store.getCount() - 1, keepExisting);
23282 * Selects the row immediately following the last selected row.
23283 * @param {Boolean} keepExisting (optional) True to keep existing selections
23285 selectNext : function(keepExisting)
23287 if(this.last !== false && (this.last+1) < this.grid.store.getCount()){
23288 this.selectRow(this.last+1, keepExisting);
23289 this.grid.getView().focusRow(this.last);
23294 * Selects the row that precedes the last selected row.
23295 * @param {Boolean} keepExisting (optional) True to keep existing selections
23297 selectPrevious : function(keepExisting){
23299 this.selectRow(this.last-1, keepExisting);
23300 this.grid.getView().focusRow(this.last);
23305 * Returns the selected records
23306 * @return {Array} Array of selected records
23308 getSelections : function(){
23309 return [].concat(this.selections.items);
23313 * Returns the first selected record.
23316 getSelected : function(){
23317 return this.selections.itemAt(0);
23322 * Clears all selections.
23324 clearSelections : function(fast)
23330 var ds = this.grid.store;
23331 var s = this.selections;
23332 s.each(function(r){
23333 this.deselectRow(ds.indexOfId(r.id));
23337 this.selections.clear();
23344 * Selects all rows.
23346 selectAll : function(){
23350 this.selections.clear();
23351 for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
23352 this.selectRow(i, true);
23357 * Returns True if there is a selection.
23358 * @return {Boolean}
23360 hasSelection : function(){
23361 return this.selections.length > 0;
23365 * Returns True if the specified row is selected.
23366 * @param {Number/Record} record The record or index of the record to check
23367 * @return {Boolean}
23369 isSelected : function(index){
23370 var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
23371 return (r && this.selections.key(r.id) ? true : false);
23375 * Returns True if the specified record id is selected.
23376 * @param {String} id The id of record to check
23377 * @return {Boolean}
23379 isIdSelected : function(id){
23380 return (this.selections.key(id) ? true : false);
23385 handleMouseDBClick : function(e, t){
23389 handleMouseDown : function(e, t)
23391 var rowIndex = this.grid.headerShow ? t.dom.rowIndex - 1 : t.dom.rowIndex ; // first row is header???
23392 if(this.isLocked() || rowIndex < 0 ){
23395 if(e.shiftKey && this.last !== false){
23396 var last = this.last;
23397 this.selectRange(last, rowIndex, e.ctrlKey);
23398 this.last = last; // reset the last
23402 var isSelected = this.isSelected(rowIndex);
23403 //Roo.log("select row:" + rowIndex);
23405 this.deselectRow(rowIndex);
23407 this.selectRow(rowIndex, true);
23411 if(e.button !== 0 && isSelected){
23412 alert('rowIndex 2: ' + rowIndex);
23413 view.focusRow(rowIndex);
23414 }else if(e.ctrlKey && isSelected){
23415 this.deselectRow(rowIndex);
23416 }else if(!isSelected){
23417 this.selectRow(rowIndex, e.button === 0 && (e.ctrlKey || e.shiftKey));
23418 view.focusRow(rowIndex);
23422 this.fireEvent("afterselectionchange", this);
23425 handleDragableRowClick : function(grid, rowIndex, e)
23427 if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
23428 this.selectRow(rowIndex, false);
23429 grid.view.focusRow(rowIndex);
23430 this.fireEvent("afterselectionchange", this);
23435 * Selects multiple rows.
23436 * @param {Array} rows Array of the indexes of the row to select
23437 * @param {Boolean} keepExisting (optional) True to keep existing selections
23439 selectRows : function(rows, keepExisting){
23441 this.clearSelections();
23443 for(var i = 0, len = rows.length; i < len; i++){
23444 this.selectRow(rows[i], true);
23449 * Selects a range of rows. All rows in between startRow and endRow are also selected.
23450 * @param {Number} startRow The index of the first row in the range
23451 * @param {Number} endRow The index of the last row in the range
23452 * @param {Boolean} keepExisting (optional) True to retain existing selections
23454 selectRange : function(startRow, endRow, keepExisting){
23459 this.clearSelections();
23461 if(startRow <= endRow){
23462 for(var i = startRow; i <= endRow; i++){
23463 this.selectRow(i, true);
23466 for(var i = startRow; i >= endRow; i--){
23467 this.selectRow(i, true);
23473 * Deselects a range of rows. All rows in between startRow and endRow are also deselected.
23474 * @param {Number} startRow The index of the first row in the range
23475 * @param {Number} endRow The index of the last row in the range
23477 deselectRange : function(startRow, endRow, preventViewNotify){
23481 for(var i = startRow; i <= endRow; i++){
23482 this.deselectRow(i, preventViewNotify);
23488 * @param {Number} row The index of the row to select
23489 * @param {Boolean} keepExisting (optional) True to keep existing selections
23491 selectRow : function(index, keepExisting, preventViewNotify)
23493 if(this.locked || (index < 0 || index > this.grid.store.getCount())) {
23496 if(this.fireEvent("beforerowselect", this, index, keepExisting) !== false){
23497 if(!keepExisting || this.singleSelect){
23498 this.clearSelections();
23501 var r = this.grid.store.getAt(index);
23502 //console.log('selectRow - record id :' + r.id);
23504 this.selections.add(r);
23505 this.last = this.lastActive = index;
23506 if(!preventViewNotify){
23507 var proxy = new Roo.Element(
23508 this.grid.getRowDom(index)
23510 proxy.addClass('bg-info info');
23512 this.fireEvent("rowselect", this, index, r);
23513 this.fireEvent("selectionchange", this);
23519 * @param {Number} row The index of the row to deselect
23521 deselectRow : function(index, preventViewNotify)
23526 if(this.last == index){
23529 if(this.lastActive == index){
23530 this.lastActive = false;
23533 var r = this.grid.store.getAt(index);
23538 this.selections.remove(r);
23539 //.console.log('deselectRow - record id :' + r.id);
23540 if(!preventViewNotify){
23542 var proxy = new Roo.Element(
23543 this.grid.getRowDom(index)
23545 proxy.removeClass('bg-info info');
23547 this.fireEvent("rowdeselect", this, index);
23548 this.fireEvent("selectionchange", this);
23552 restoreLast : function(){
23554 this.last = this._last;
23559 acceptsNav : function(row, col, cm){
23560 return !cm.isHidden(col) && cm.isCellEditable(col, row);
23564 onEditorKey : function(field, e){
23565 var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
23570 newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
23572 newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
23574 }else if(k == e.ENTER && !e.ctrlKey){
23578 newCell = g.walkCells(ed.row-1, ed.col, -1, this.acceptsNav, this);
23580 newCell = g.walkCells(ed.row+1, ed.col, 1, this.acceptsNav, this);
23582 }else if(k == e.ESC){
23586 g.startEditing(newCell[0], newCell[1]);
23592 * Ext JS Library 1.1.1
23593 * Copyright(c) 2006-2007, Ext JS, LLC.
23595 * Originally Released Under LGPL - original licence link has changed is not relivant.
23598 * <script type="text/javascript">
23602 * @class Roo.bootstrap.PagingToolbar
23603 * @extends Roo.bootstrap.NavSimplebar
23604 * A specialized toolbar that is bound to a {@link Roo.data.Store} and provides automatic paging controls.
23606 * Create a new PagingToolbar
23607 * @param {Object} config The config object
23608 * @param {Roo.data.Store} store
23610 Roo.bootstrap.PagingToolbar = function(config)
23612 // old args format still supported... - xtype is prefered..
23613 // created from xtype...
23615 this.ds = config.dataSource;
23617 if (config.store && !this.ds) {
23618 this.store= Roo.factory(config.store, Roo.data);
23619 this.ds = this.store;
23620 this.ds.xmodule = this.xmodule || false;
23623 this.toolbarItems = [];
23624 if (config.items) {
23625 this.toolbarItems = config.items;
23628 Roo.bootstrap.PagingToolbar.superclass.constructor.call(this, config);
23633 this.bind(this.ds);
23636 this.navgroup = new Roo.bootstrap.NavGroup({ cls: 'pagination' });
23640 Roo.extend(Roo.bootstrap.PagingToolbar, Roo.bootstrap.NavSimplebar, {
23642 * @cfg {Roo.data.Store} dataSource
23643 * The underlying data store providing the paged data
23646 * @cfg {String/HTMLElement/Element} container
23647 * container The id or element that will contain the toolbar
23650 * @cfg {Boolean} displayInfo
23651 * True to display the displayMsg (defaults to false)
23654 * @cfg {Number} pageSize
23655 * The number of records to display per page (defaults to 20)
23659 * @cfg {String} displayMsg
23660 * The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
23662 displayMsg : 'Displaying {0} - {1} of {2}',
23664 * @cfg {String} emptyMsg
23665 * The message to display when no records are found (defaults to "No data to display")
23667 emptyMsg : 'No data to display',
23669 * Customizable piece of the default paging text (defaults to "Page")
23672 beforePageText : "Page",
23674 * Customizable piece of the default paging text (defaults to "of %0")
23677 afterPageText : "of {0}",
23679 * Customizable piece of the default paging text (defaults to "First Page")
23682 firstText : "First Page",
23684 * Customizable piece of the default paging text (defaults to "Previous Page")
23687 prevText : "Previous Page",
23689 * Customizable piece of the default paging text (defaults to "Next Page")
23692 nextText : "Next Page",
23694 * Customizable piece of the default paging text (defaults to "Last Page")
23697 lastText : "Last Page",
23699 * Customizable piece of the default paging text (defaults to "Refresh")
23702 refreshText : "Refresh",
23706 onRender : function(ct, position)
23708 Roo.bootstrap.PagingToolbar.superclass.onRender.call(this, ct, position);
23709 this.navgroup.parentId = this.id;
23710 this.navgroup.onRender(this.el, null);
23711 // add the buttons to the navgroup
23713 if(this.displayInfo){
23714 this.el.select('ul.navbar-nav',true).first().createChild({cls:'x-paging-info'});
23715 this.displayEl = this.el.select('.x-paging-info', true).first();
23716 // var navel = this.navgroup.addItem( { tagtype : 'span', html : '', cls : 'x-paging-info', preventDefault : true } );
23717 // this.displayEl = navel.el.select('span',true).first();
23723 Roo.each(_this.buttons, function(e){ // this might need to use render????
23724 Roo.factory(e).onRender(_this.el, null);
23728 Roo.each(_this.toolbarItems, function(e) {
23729 _this.navgroup.addItem(e);
23733 this.first = this.navgroup.addItem({
23734 tooltip: this.firstText,
23736 icon : 'fa fa-backward',
23738 preventDefault: true,
23739 listeners : { click : this.onClick.createDelegate(this, ["first"]) }
23742 this.prev = this.navgroup.addItem({
23743 tooltip: this.prevText,
23745 icon : 'fa fa-step-backward',
23747 preventDefault: true,
23748 listeners : { click : this.onClick.createDelegate(this, ["prev"]) }
23750 //this.addSeparator();
23753 var field = this.navgroup.addItem( {
23755 cls : 'x-paging-position',
23757 html : this.beforePageText +
23758 '<input type="text" size="3" value="1" class="x-grid-page-number">' +
23759 '<span class="x-paging-after">' + String.format(this.afterPageText, 1) + '</span>'
23762 this.field = field.el.select('input', true).first();
23763 this.field.on("keydown", this.onPagingKeydown, this);
23764 this.field.on("focus", function(){this.dom.select();});
23767 this.afterTextEl = field.el.select('.x-paging-after',true).first();
23768 //this.field.setHeight(18);
23769 //this.addSeparator();
23770 this.next = this.navgroup.addItem({
23771 tooltip: this.nextText,
23773 html : ' <i class="fa fa-step-forward">',
23775 preventDefault: true,
23776 listeners : { click : this.onClick.createDelegate(this, ["next"]) }
23778 this.last = this.navgroup.addItem({
23779 tooltip: this.lastText,
23780 icon : 'fa fa-forward',
23783 preventDefault: true,
23784 listeners : { click : this.onClick.createDelegate(this, ["last"]) }
23786 //this.addSeparator();
23787 this.loading = this.navgroup.addItem({
23788 tooltip: this.refreshText,
23789 icon: 'fa fa-refresh',
23790 preventDefault: true,
23791 listeners : { click : this.onClick.createDelegate(this, ["refresh"]) }
23797 updateInfo : function(){
23798 if(this.displayEl){
23799 var count = (typeof(this.getCount) == 'undefined') ? this.ds.getCount() : this.getCount();
23800 var msg = count == 0 ?
23804 this.cursor+1, this.cursor+count, this.ds.getTotalCount()
23806 this.displayEl.update(msg);
23811 onLoad : function(ds, r, o){
23812 this.cursor = o.params ? o.params.start : 0;
23813 var d = this.getPageData(),
23817 this.afterTextEl.dom.innerHTML = String.format(this.afterPageText, d.pages);
23818 this.field.dom.value = ap;
23819 this.first.setDisabled(ap == 1);
23820 this.prev.setDisabled(ap == 1);
23821 this.next.setDisabled(ap == ps);
23822 this.last.setDisabled(ap == ps);
23823 this.loading.enable();
23828 getPageData : function(){
23829 var total = this.ds.getTotalCount();
23832 activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
23833 pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
23838 onLoadError : function(){
23839 this.loading.enable();
23843 onPagingKeydown : function(e){
23844 var k = e.getKey();
23845 var d = this.getPageData();
23847 var v = this.field.dom.value, pageNum;
23848 if(!v || isNaN(pageNum = parseInt(v, 10))){
23849 this.field.dom.value = d.activePage;
23852 pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
23853 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
23856 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))
23858 var pageNum = (k == e.HOME || (k == e.DOWN && e.ctrlKey) || (k == e.LEFT && e.ctrlKey) || (k == e.PAGEDOWN && e.ctrlKey)) ? 1 : d.pages;
23859 this.field.dom.value = pageNum;
23860 this.ds.load({params:{start: (pageNum - 1) * this.pageSize, limit: this.pageSize}});
23863 else if(k == e.UP || k == e.RIGHT || k == e.PAGEUP || k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN)
23865 var v = this.field.dom.value, pageNum;
23866 var increment = (e.shiftKey) ? 10 : 1;
23867 if(k == e.DOWN || k == e.LEFT || k == e.PAGEDOWN) {
23870 if(!v || isNaN(pageNum = parseInt(v, 10))) {
23871 this.field.dom.value = d.activePage;
23874 else if(parseInt(v, 10) + increment >= 1 & parseInt(v, 10) + increment <= d.pages)
23876 this.field.dom.value = parseInt(v, 10) + increment;
23877 pageNum = Math.min(Math.max(1, pageNum + increment), d.pages) - 1;
23878 this.ds.load({params:{start: pageNum * this.pageSize, limit: this.pageSize}});
23885 beforeLoad : function(){
23887 this.loading.disable();
23892 onClick : function(which){
23901 ds.load({params:{start: 0, limit: this.pageSize}});
23904 ds.load({params:{start: Math.max(0, this.cursor-this.pageSize), limit: this.pageSize}});
23907 ds.load({params:{start: this.cursor+this.pageSize, limit: this.pageSize}});
23910 var total = ds.getTotalCount();
23911 var extra = total % this.pageSize;
23912 var lastStart = extra ? (total - extra) : total-this.pageSize;
23913 ds.load({params:{start: lastStart, limit: this.pageSize}});
23916 ds.load({params:{start: this.cursor, limit: this.pageSize}});
23922 * Unbinds the paging toolbar from the specified {@link Roo.data.Store}
23923 * @param {Roo.data.Store} store The data store to unbind
23925 unbind : function(ds){
23926 ds.un("beforeload", this.beforeLoad, this);
23927 ds.un("load", this.onLoad, this);
23928 ds.un("loadexception", this.onLoadError, this);
23929 ds.un("remove", this.updateInfo, this);
23930 ds.un("add", this.updateInfo, this);
23931 this.ds = undefined;
23935 * Binds the paging toolbar to the specified {@link Roo.data.Store}
23936 * @param {Roo.data.Store} store The data store to bind
23938 bind : function(ds){
23939 ds.on("beforeload", this.beforeLoad, this);
23940 ds.on("load", this.onLoad, this);
23941 ds.on("loadexception", this.onLoadError, this);
23942 ds.on("remove", this.updateInfo, this);
23943 ds.on("add", this.updateInfo, this);
23954 * @class Roo.bootstrap.MessageBar
23955 * @extends Roo.bootstrap.Component
23956 * Bootstrap MessageBar class
23957 * @cfg {String} html contents of the MessageBar
23958 * @cfg {String} weight (info | success | warning | danger) default info
23959 * @cfg {String} beforeClass insert the bar before the given class
23960 * @cfg {Boolean} closable (true | false) default false
23961 * @cfg {Boolean} fixed (true | false) default false, fix the bar at the top
23964 * Create a new Element
23965 * @param {Object} config The config object
23968 Roo.bootstrap.MessageBar = function(config){
23969 Roo.bootstrap.MessageBar.superclass.constructor.call(this, config);
23972 Roo.extend(Roo.bootstrap.MessageBar, Roo.bootstrap.Component, {
23978 beforeClass: 'bootstrap-sticky-wrap',
23980 getAutoCreate : function(){
23984 cls: 'alert alert-dismissable alert-' + this.weight,
23989 html: this.html || ''
23995 cfg.cls += ' alert-messages-fixed';
24009 onRender : function(ct, position)
24011 Roo.bootstrap.Component.superclass.onRender.call(this, ct, position);
24014 var cfg = Roo.apply({}, this.getAutoCreate());
24018 cfg.cls += ' ' + this.cls;
24021 cfg.style = this.style;
24023 this.el = Roo.get(document.body).createChild(cfg, Roo.select('.'+this.beforeClass, true).first());
24025 this.el.setVisibilityMode(Roo.Element.DISPLAY);
24028 this.el.select('>button.close').on('click', this.hide, this);
24034 if (!this.rendered) {
24040 this.fireEvent('show', this);
24046 if (!this.rendered) {
24052 this.fireEvent('hide', this);
24055 update : function()
24057 // var e = this.el.dom.firstChild;
24059 // if(this.closable){
24060 // e = e.nextSibling;
24063 // e.data = this.html || '';
24065 this.el.select('>.message', true).first().dom.innerHTML = this.html || '';
24081 * @class Roo.bootstrap.Graph
24082 * @extends Roo.bootstrap.Component
24083 * Bootstrap Graph class
24087 @cfg {String} graphtype bar | vbar | pie
24088 @cfg {number} g_x coodinator | centre x (pie)
24089 @cfg {number} g_y coodinator | centre y (pie)
24090 @cfg {number} g_r radius (pie)
24091 @cfg {number} g_height height of the chart (respected by all elements in the set)
24092 @cfg {number} g_width width of the chart (respected by all elements in the set)
24093 @cfg {Object} title The title of the chart
24096 -opts (object) options for the chart
24098 o type (string) type of endings of the bar. Default: 'square'. Other options are: 'round', 'sharp', 'soft'.
24099 o gutter (number)(string) default '20%' (WHAT DOES IT DO?)
24101 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.
24102 o stacked (boolean) whether or not to tread values as in a stacked bar chart
24104 o stretch (boolean)
24106 -opts (object) options for the pie
24109 o startAngle (number)
24110 o endAngle (number)
24114 * Create a new Input
24115 * @param {Object} config The config object
24118 Roo.bootstrap.Graph = function(config){
24119 Roo.bootstrap.Graph.superclass.constructor.call(this, config);
24125 * The img click event for the img.
24126 * @param {Roo.EventObject} e
24132 Roo.extend(Roo.bootstrap.Graph, Roo.bootstrap.Component, {
24143 //g_colors: this.colors,
24150 getAutoCreate : function(){
24161 onRender : function(ct,position){
24164 Roo.bootstrap.Graph.superclass.onRender.call(this,ct,position);
24166 if (typeof(Raphael) == 'undefined') {
24167 Roo.bootstrap.MessageBox.alert("Error","Raphael is not availabe");
24171 this.raphael = Raphael(this.el.dom);
24173 // data1 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24174 // data2 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24175 // data3 = [[55, 20, 13, 32, 5, 1, 2, 10], [10, 2, 1, 5, 32, 13, 20, 55], [12, 20, 30]],
24176 // txtattr = { font: "12px 'Fontin Sans', Fontin-Sans, sans-serif" };
24178 r.text(160, 10, "Single Series Chart").attr(txtattr);
24179 r.text(480, 10, "Multiline Series Chart").attr(txtattr);
24180 r.text(160, 250, "Multiple Series Stacked Chart").attr(txtattr);
24181 r.text(480, 250, 'Multiline Series Stacked Vertical Chart. Type "round"').attr(txtattr);
24183 r.barchart(10, 10, 300, 220, [[55, 20, 13, 32, 5, 1, 2, 10]], 0, {type: "sharp"});
24184 r.barchart(330, 10, 300, 220, data1);
24185 r.barchart(10, 250, 300, 220, data2, {stacked: true});
24186 r.barchart(330, 250, 300, 220, data3, {stacked: true, type: "round"});
24189 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
24190 // r.barchart(30, 30, 560, 250, xdata, {
24191 // labels : [55, 20, 13, 32, 5, 1, 2, 10,5 , 10],
24192 // axis : "0 0 1 1",
24193 // axisxlabels : xdata
24194 // //yvalues : cols,
24197 // var xdata = [55, 20, 13, 32, 5, 1, 2, 10,5 , 10];
24199 // this.load(null,xdata,{
24200 // axis : "0 0 1 1",
24201 // axisxlabels : xdata
24206 load : function(graphtype,xdata,opts)
24208 this.raphael.clear();
24210 graphtype = this.graphtype;
24215 var r = this.raphael,
24216 fin = function () {
24217 this.flag = r.popup(this.bar.x, this.bar.y, this.bar.value || "0").insertBefore(this);
24219 fout = function () {
24220 this.flag.animate({opacity: 0}, 300, function () {this.remove();});
24222 pfin = function() {
24223 this.sector.stop();
24224 this.sector.scale(1.1, 1.1, this.cx, this.cy);
24227 this.label[0].stop();
24228 this.label[0].attr({ r: 7.5 });
24229 this.label[1].attr({ "font-weight": 800 });
24232 pfout = function() {
24233 this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
24236 this.label[0].animate({ r: 5 }, 500, "bounce");
24237 this.label[1].attr({ "font-weight": 400 });
24243 this.raphael.barchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
24246 this.raphael.hbarchart(this.g_x,this.g_y,this.g_width,this.g_height,xdata,opts).hover(fin,fout);
24249 // opts = { legend: ["%% - Enterprise Users", "% - ddd","Chrome Users"], legendpos: "west",
24250 // href: ["http://raphaeljs.com", "http://g.raphaeljs.com"]};
24252 this.raphael.piechart(this.g_x,this.g_y,this.g_r,xdata,opts).hover(pfin, pfout);
24259 this.raphael.text(this.title.x, this.title.y, this.title.text).attr(this.title.attr);
24264 setTitle: function(o)
24269 initEvents: function() {
24272 this.el.on('click', this.onClick, this);
24276 onClick : function(e)
24278 Roo.log('img onclick');
24279 this.fireEvent('click', this, e);
24291 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
24294 * @class Roo.bootstrap.dash.NumberBox
24295 * @extends Roo.bootstrap.Component
24296 * Bootstrap NumberBox class
24297 * @cfg {String} headline Box headline
24298 * @cfg {String} content Box content
24299 * @cfg {String} icon Box icon
24300 * @cfg {String} footer Footer text
24301 * @cfg {String} fhref Footer href
24304 * Create a new NumberBox
24305 * @param {Object} config The config object
24309 Roo.bootstrap.dash.NumberBox = function(config){
24310 Roo.bootstrap.dash.NumberBox.superclass.constructor.call(this, config);
24314 Roo.extend(Roo.bootstrap.dash.NumberBox, Roo.bootstrap.Component, {
24323 getAutoCreate : function(){
24327 cls : 'small-box ',
24335 cls : 'roo-headline',
24336 html : this.headline
24340 cls : 'roo-content',
24341 html : this.content
24355 cls : 'ion ' + this.icon
24364 cls : 'small-box-footer',
24365 href : this.fhref || '#',
24369 cfg.cn.push(footer);
24376 onRender : function(ct,position){
24377 Roo.bootstrap.dash.NumberBox.superclass.onRender.call(this,ct,position);
24384 setHeadline: function (value)
24386 this.el.select('.roo-headline',true).first().dom.innerHTML = value;
24389 setFooter: function (value, href)
24391 this.el.select('a.small-box-footer',true).first().dom.innerHTML = value;
24394 this.el.select('a.small-box-footer',true).first().attr('href', href);
24399 setContent: function (value)
24401 this.el.select('.roo-content',true).first().dom.innerHTML = value;
24404 initEvents: function()
24418 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
24421 * @class Roo.bootstrap.dash.TabBox
24422 * @extends Roo.bootstrap.Component
24423 * Bootstrap TabBox class
24424 * @cfg {String} title Title of the TabBox
24425 * @cfg {String} icon Icon of the TabBox
24426 * @cfg {Boolean} showtabs (true|false) show the tabs default true
24427 * @cfg {Boolean} tabScrollable (true|false) tab scrollable when mobile view default false
24430 * Create a new TabBox
24431 * @param {Object} config The config object
24435 Roo.bootstrap.dash.TabBox = function(config){
24436 Roo.bootstrap.dash.TabBox.superclass.constructor.call(this, config);
24441 * When a pane is added
24442 * @param {Roo.bootstrap.dash.TabPane} pane
24446 * @event activatepane
24447 * When a pane is activated
24448 * @param {Roo.bootstrap.dash.TabPane} pane
24450 "activatepane" : true
24458 Roo.extend(Roo.bootstrap.dash.TabBox, Roo.bootstrap.Component, {
24463 tabScrollable : false,
24465 getChildContainer : function()
24467 return this.el.select('.tab-content', true).first();
24470 getAutoCreate : function(){
24474 cls: 'pull-left header',
24482 cls: 'fa ' + this.icon
24488 cls: 'nav nav-tabs pull-right',
24494 if(this.tabScrollable){
24501 cls: 'nav nav-tabs pull-right',
24512 cls: 'nav-tabs-custom',
24517 cls: 'tab-content no-padding',
24525 initEvents : function()
24527 //Roo.log('add add pane handler');
24528 this.on('addpane', this.onAddPane, this);
24531 * Updates the box title
24532 * @param {String} html to set the title to.
24534 setTitle : function(value)
24536 this.el.select('.nav-tabs .header', true).first().dom.innerHTML = value;
24538 onAddPane : function(pane)
24540 this.panes.push(pane);
24541 //Roo.log('addpane');
24543 // tabs are rendere left to right..
24544 if(!this.showtabs){
24548 var ctr = this.el.select('.nav-tabs', true).first();
24551 var existing = ctr.select('.nav-tab',true);
24552 var qty = existing.getCount();;
24555 var tab = ctr.createChild({
24557 cls : 'nav-tab' + (qty ? '' : ' active'),
24565 }, qty ? existing.first().dom : ctr.select('.header', true).first().dom );
24568 tab.on('click', this.onTabClick.createDelegate(this, [pane], true));
24570 pane.el.addClass('active');
24575 onTabClick : function(ev,un,ob,pane)
24577 //Roo.log('tab - prev default');
24578 ev.preventDefault();
24581 this.el.select('.nav-tabs li.nav-tab', true).removeClass('active');
24582 pane.tab.addClass('active');
24583 //Roo.log(pane.title);
24584 this.getChildContainer().select('.tab-pane',true).removeClass('active');
24585 // technically we should have a deactivate event.. but maybe add later.
24586 // and it should not de-activate the selected tab...
24587 this.fireEvent('activatepane', pane);
24588 pane.el.addClass('active');
24589 pane.fireEvent('activate');
24594 getActivePane : function()
24597 Roo.each(this.panes, function(p) {
24598 if(p.el.hasClass('active')){
24619 Roo.bootstrap.dash = Roo.bootstrap.dash || {};
24621 * @class Roo.bootstrap.TabPane
24622 * @extends Roo.bootstrap.Component
24623 * Bootstrap TabPane class
24624 * @cfg {Boolean} active (false | true) Default false
24625 * @cfg {String} title title of panel
24629 * Create a new TabPane
24630 * @param {Object} config The config object
24633 Roo.bootstrap.dash.TabPane = function(config){
24634 Roo.bootstrap.dash.TabPane.superclass.constructor.call(this, config);
24640 * When a pane is activated
24641 * @param {Roo.bootstrap.dash.TabPane} pane
24648 Roo.extend(Roo.bootstrap.dash.TabPane, Roo.bootstrap.Component, {
24653 // the tabBox that this is attached to.
24656 getAutoCreate : function()
24664 cfg.cls += ' active';
24669 initEvents : function()
24671 //Roo.log('trigger add pane handler');
24672 this.parent().fireEvent('addpane', this)
24676 * Updates the tab title
24677 * @param {String} html to set the title to.
24679 setTitle: function(str)
24685 this.tab.select('a', true).first().dom.innerHTML = str;
24702 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
24705 * @class Roo.bootstrap.menu.Menu
24706 * @extends Roo.bootstrap.Component
24707 * Bootstrap Menu class - container for Menu
24708 * @cfg {String} html Text of the menu
24709 * @cfg {String} weight (default | primary | success | info | warning | danger | inverse)
24710 * @cfg {String} icon Font awesome icon
24711 * @cfg {String} pos Menu align to (top | bottom) default bottom
24715 * Create a new Menu
24716 * @param {Object} config The config object
24720 Roo.bootstrap.menu.Menu = function(config){
24721 Roo.bootstrap.menu.Menu.superclass.constructor.call(this, config);
24725 * @event beforeshow
24726 * Fires before this menu is displayed
24727 * @param {Roo.bootstrap.menu.Menu} this
24731 * @event beforehide
24732 * Fires before this menu is hidden
24733 * @param {Roo.bootstrap.menu.Menu} this
24738 * Fires after this menu is displayed
24739 * @param {Roo.bootstrap.menu.Menu} this
24744 * Fires after this menu is hidden
24745 * @param {Roo.bootstrap.menu.Menu} this
24750 * Fires when this menu is clicked (or when the enter key is pressed while it is active)
24751 * @param {Roo.bootstrap.menu.Menu} this
24752 * @param {Roo.EventObject} e
24759 Roo.extend(Roo.bootstrap.menu.Menu, Roo.bootstrap.Component, {
24763 weight : 'default',
24768 getChildContainer : function() {
24769 if(this.isSubMenu){
24773 return this.el.select('ul.dropdown-menu', true).first();
24776 getAutoCreate : function()
24781 cls : 'roo-menu-text',
24789 cls : 'fa ' + this.icon
24800 cls : 'dropdown-button btn btn-' + this.weight,
24805 cls : 'dropdown-toggle btn btn-' + this.weight,
24815 cls : 'dropdown-menu'
24821 if(this.pos == 'top'){
24822 cfg.cls += ' dropup';
24825 if(this.isSubMenu){
24828 cls : 'dropdown-menu'
24835 onRender : function(ct, position)
24837 this.isSubMenu = ct.hasClass('dropdown-submenu');
24839 Roo.bootstrap.menu.Menu.superclass.onRender.call(this, ct, position);
24842 initEvents : function()
24844 if(this.isSubMenu){
24848 this.hidden = true;
24850 this.triggerEl = this.el.select('button.dropdown-toggle', true).first();
24851 this.triggerEl.on('click', this.onTriggerPress, this);
24853 this.buttonEl = this.el.select('button.dropdown-button', true).first();
24854 this.buttonEl.on('click', this.onClick, this);
24860 if(this.isSubMenu){
24864 return this.el.select('ul.dropdown-menu', true).first();
24867 onClick : function(e)
24869 this.fireEvent("click", this, e);
24872 onTriggerPress : function(e)
24874 if (this.isVisible()) {
24881 isVisible : function(){
24882 return !this.hidden;
24887 this.fireEvent("beforeshow", this);
24889 this.hidden = false;
24890 this.el.addClass('open');
24892 Roo.get(document).on("mouseup", this.onMouseUp, this);
24894 this.fireEvent("show", this);
24901 this.fireEvent("beforehide", this);
24903 this.hidden = true;
24904 this.el.removeClass('open');
24906 Roo.get(document).un("mouseup", this.onMouseUp);
24908 this.fireEvent("hide", this);
24911 onMouseUp : function()
24925 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
24928 * @class Roo.bootstrap.menu.Item
24929 * @extends Roo.bootstrap.Component
24930 * Bootstrap MenuItem class
24931 * @cfg {Boolean} submenu (true | false) default false
24932 * @cfg {String} html text of the item
24933 * @cfg {String} href the link
24934 * @cfg {Boolean} disable (true | false) default false
24935 * @cfg {Boolean} preventDefault (true | false) default true
24936 * @cfg {String} icon Font awesome icon
24937 * @cfg {String} pos Submenu align to (left | right) default right
24941 * Create a new Item
24942 * @param {Object} config The config object
24946 Roo.bootstrap.menu.Item = function(config){
24947 Roo.bootstrap.menu.Item.superclass.constructor.call(this, config);
24951 * Fires when the mouse is hovering over this menu
24952 * @param {Roo.bootstrap.menu.Item} this
24953 * @param {Roo.EventObject} e
24958 * Fires when the mouse exits this menu
24959 * @param {Roo.bootstrap.menu.Item} this
24960 * @param {Roo.EventObject} e
24966 * The raw click event for the entire grid.
24967 * @param {Roo.EventObject} e
24973 Roo.extend(Roo.bootstrap.menu.Item, Roo.bootstrap.Component, {
24978 preventDefault: true,
24983 getAutoCreate : function()
24988 cls : 'roo-menu-item-text',
24996 cls : 'fa ' + this.icon
25005 href : this.href || '#',
25012 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'disabled' : (cfg.cls + ' disabled');
25016 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'dropdown-submenu' : (cfg.cls + ' dropdown-submenu');
25018 if(this.pos == 'left'){
25019 cfg.cls = (typeof(cfg.cls) == 'undefined') ? 'pull-left' : (cfg.cls + ' pull-left');
25026 initEvents : function()
25028 this.el.on('mouseover', this.onMouseOver, this);
25029 this.el.on('mouseout', this.onMouseOut, this);
25031 this.el.select('a', true).first().on('click', this.onClick, this);
25035 onClick : function(e)
25037 if(this.preventDefault){
25038 e.preventDefault();
25041 this.fireEvent("click", this, e);
25044 onMouseOver : function(e)
25046 if(this.submenu && this.pos == 'left'){
25047 this.el.select('ul.dropdown-menu', true).first().setLeft(this.el.select('ul.dropdown-menu', true).first().getWidth() * -1);
25050 this.fireEvent("mouseover", this, e);
25053 onMouseOut : function(e)
25055 this.fireEvent("mouseout", this, e);
25067 Roo.bootstrap.menu = Roo.bootstrap.menu || {};
25070 * @class Roo.bootstrap.menu.Separator
25071 * @extends Roo.bootstrap.Component
25072 * Bootstrap Separator class
25075 * Create a new Separator
25076 * @param {Object} config The config object
25080 Roo.bootstrap.menu.Separator = function(config){
25081 Roo.bootstrap.menu.Separator.superclass.constructor.call(this, config);
25084 Roo.extend(Roo.bootstrap.menu.Separator, Roo.bootstrap.Component, {
25086 getAutoCreate : function(){
25107 * @class Roo.bootstrap.Tooltip
25108 * Bootstrap Tooltip class
25109 * This is basic at present - all componets support it by default, however they should add tooltipEl() method
25110 * to determine which dom element triggers the tooltip.
25112 * It needs to add support for additional attributes like tooltip-position
25115 * Create a new Toolti
25116 * @param {Object} config The config object
25119 Roo.bootstrap.Tooltip = function(config){
25120 Roo.bootstrap.Tooltip.superclass.constructor.call(this, config);
25122 this.alignment = Roo.bootstrap.Tooltip.alignment;
25124 if(typeof(config) != 'undefined' && typeof(config.alignment) != 'undefined'){
25125 this.alignment = config.alignment;
25130 Roo.apply(Roo.bootstrap.Tooltip, {
25132 * @function init initialize tooltip monitoring.
25136 currentTip : false,
25137 currentRegion : false,
25143 Roo.get(document).on('mouseover', this.enter ,this);
25144 Roo.get(document).on('mouseout', this.leave, this);
25147 this.currentTip = new Roo.bootstrap.Tooltip();
25150 enter : function(ev)
25152 var dom = ev.getTarget();
25154 //Roo.log(['enter',dom]);
25155 var el = Roo.fly(dom);
25156 if (this.currentEl) {
25158 //Roo.log(this.currentEl);
25159 //Roo.log(this.currentEl.contains(dom));
25160 if (this.currentEl == el) {
25163 if (dom != this.currentEl.dom && this.currentEl.contains(dom)) {
25169 if (this.currentTip.el) {
25170 this.currentTip.el.setVisibilityMode(Roo.Element.DISPLAY).hide(); // force hiding...
25174 if(!el || el.dom == document){
25180 // you can not look for children, as if el is the body.. then everythign is the child..
25181 if (!el.attr('tooltip')) { //
25182 if (!el.select("[tooltip]").elements.length) {
25185 // is the mouse over this child...?
25186 bindEl = el.select("[tooltip]").first();
25187 var xy = ev.getXY();
25188 if (!bindEl.getRegion().contains( { top : xy[1] ,right : xy[0] , bottom : xy[1], left : xy[0]})) {
25189 //Roo.log("not in region.");
25192 //Roo.log("child element over..");
25195 this.currentEl = bindEl;
25196 this.currentTip.bind(bindEl);
25197 this.currentRegion = Roo.lib.Region.getRegion(dom);
25198 this.currentTip.enter();
25201 leave : function(ev)
25203 var dom = ev.getTarget();
25204 //Roo.log(['leave',dom]);
25205 if (!this.currentEl) {
25210 if (dom != this.currentEl.dom) {
25213 var xy = ev.getXY();
25214 if (this.currentRegion.contains( new Roo.lib.Region( xy[1], xy[0] ,xy[1], xy[0] ))) {
25217 // only activate leave if mouse cursor is outside... bounding box..
25222 if (this.currentTip) {
25223 this.currentTip.leave();
25225 //Roo.log('clear currentEl');
25226 this.currentEl = false;
25231 'left' : ['r-l', [-2,0], 'right'],
25232 'right' : ['l-r', [2,0], 'left'],
25233 'bottom' : ['t-b', [0,2], 'top'],
25234 'top' : [ 'b-t', [0,-2], 'bottom']
25240 Roo.extend(Roo.bootstrap.Tooltip, Roo.bootstrap.Component, {
25245 delay : null, // can be { show : 300 , hide: 500}
25249 hoverState : null, //???
25251 placement : 'bottom',
25255 getAutoCreate : function(){
25262 cls : 'tooltip-arrow'
25265 cls : 'tooltip-inner'
25272 bind : function(el)
25278 enter : function () {
25280 if (this.timeout != null) {
25281 clearTimeout(this.timeout);
25284 this.hoverState = 'in';
25285 //Roo.log("enter - show");
25286 if (!this.delay || !this.delay.show) {
25291 this.timeout = setTimeout(function () {
25292 if (_t.hoverState == 'in') {
25295 }, this.delay.show);
25299 clearTimeout(this.timeout);
25301 this.hoverState = 'out';
25302 if (!this.delay || !this.delay.hide) {
25308 this.timeout = setTimeout(function () {
25309 //Roo.log("leave - timeout");
25311 if (_t.hoverState == 'out') {
25313 Roo.bootstrap.Tooltip.currentEl = false;
25318 show : function (msg)
25321 this.render(document.body);
25324 //Roo.log([this.bindEl, this.bindEl.attr('tooltip')]);
25326 var tip = msg || this.bindEl.attr('tooltip') || this.bindEl.select("[tooltip]").first().attr('tooltip');
25328 this.el.select('.tooltip-inner',true).first().dom.innerHTML = tip;
25330 this.el.removeClass(['fade','top','bottom', 'left', 'right','in']);
25332 var placement = typeof this.placement == 'function' ?
25333 this.placement.call(this, this.el, on_el) :
25336 var autoToken = /\s?auto?\s?/i;
25337 var autoPlace = autoToken.test(placement);
25339 placement = placement.replace(autoToken, '') || 'top';
25343 //this.el.setXY([0,0]);
25345 //this.el.dom.style.display='block';
25347 //this.el.appendTo(on_el);
25349 var p = this.getPosition();
25350 var box = this.el.getBox();
25356 var align = this.alignment[placement];
25358 var xy = this.el.getAlignToXY(this.bindEl, align[0], align[1]);
25360 if(placement == 'top' || placement == 'bottom'){
25362 placement = 'right';
25365 if(xy[0] + this.el.getWidth() > Roo.lib.Dom.getViewWidth()){
25366 placement = 'left';
25369 var scroll = Roo.select('body', true).first().getScroll();
25371 if(xy[1] > Roo.lib.Dom.getViewHeight() + scroll.top - this.el.getHeight()){
25377 this.el.alignTo(this.bindEl, align[0],align[1]);
25378 //var arrow = this.el.select('.arrow',true).first();
25379 //arrow.set(align[2],
25381 this.el.addClass(placement);
25383 this.el.addClass('in fade');
25385 this.hoverState = null;
25387 if (this.el.hasClass('fade')) {
25398 //this.el.setXY([0,0]);
25399 this.el.removeClass('in');
25415 * @class Roo.bootstrap.LocationPicker
25416 * @extends Roo.bootstrap.Component
25417 * Bootstrap LocationPicker class
25418 * @cfg {Number} latitude Position when init default 0
25419 * @cfg {Number} longitude Position when init default 0
25420 * @cfg {Number} zoom default 15
25421 * @cfg {String} mapTypeId default google.maps.MapTypeId.ROADMAP
25422 * @cfg {Boolean} mapTypeControl default false
25423 * @cfg {Boolean} disableDoubleClickZoom default false
25424 * @cfg {Boolean} scrollwheel default true
25425 * @cfg {Boolean} streetViewControl default false
25426 * @cfg {Number} radius default 0
25427 * @cfg {String} locationName
25428 * @cfg {Boolean} draggable default true
25429 * @cfg {Boolean} enableAutocomplete default false
25430 * @cfg {Boolean} enableReverseGeocode default true
25431 * @cfg {String} markerTitle
25434 * Create a new LocationPicker
25435 * @param {Object} config The config object
25439 Roo.bootstrap.LocationPicker = function(config){
25441 Roo.bootstrap.LocationPicker.superclass.constructor.call(this, config);
25446 * Fires when the picker initialized.
25447 * @param {Roo.bootstrap.LocationPicker} this
25448 * @param {Google Location} location
25452 * @event positionchanged
25453 * Fires when the picker position changed.
25454 * @param {Roo.bootstrap.LocationPicker} this
25455 * @param {Google Location} location
25457 positionchanged : true,
25460 * Fires when the map resize.
25461 * @param {Roo.bootstrap.LocationPicker} this
25466 * Fires when the map show.
25467 * @param {Roo.bootstrap.LocationPicker} this
25472 * Fires when the map hide.
25473 * @param {Roo.bootstrap.LocationPicker} this
25478 * Fires when click the map.
25479 * @param {Roo.bootstrap.LocationPicker} this
25480 * @param {Map event} e
25484 * @event mapRightClick
25485 * Fires when right click the map.
25486 * @param {Roo.bootstrap.LocationPicker} this
25487 * @param {Map event} e
25489 mapRightClick : true,
25491 * @event markerClick
25492 * Fires when click the marker.
25493 * @param {Roo.bootstrap.LocationPicker} this
25494 * @param {Map event} e
25496 markerClick : true,
25498 * @event markerRightClick
25499 * Fires when right click the marker.
25500 * @param {Roo.bootstrap.LocationPicker} this
25501 * @param {Map event} e
25503 markerRightClick : true,
25505 * @event OverlayViewDraw
25506 * Fires when OverlayView Draw
25507 * @param {Roo.bootstrap.LocationPicker} this
25509 OverlayViewDraw : true,
25511 * @event OverlayViewOnAdd
25512 * Fires when OverlayView Draw
25513 * @param {Roo.bootstrap.LocationPicker} this
25515 OverlayViewOnAdd : true,
25517 * @event OverlayViewOnRemove
25518 * Fires when OverlayView Draw
25519 * @param {Roo.bootstrap.LocationPicker} this
25521 OverlayViewOnRemove : true,
25523 * @event OverlayViewShow
25524 * Fires when OverlayView Draw
25525 * @param {Roo.bootstrap.LocationPicker} this
25526 * @param {Pixel} cpx
25528 OverlayViewShow : true,
25530 * @event OverlayViewHide
25531 * Fires when OverlayView Draw
25532 * @param {Roo.bootstrap.LocationPicker} this
25534 OverlayViewHide : true,
25536 * @event loadexception
25537 * Fires when load google lib failed.
25538 * @param {Roo.bootstrap.LocationPicker} this
25540 loadexception : true
25545 Roo.extend(Roo.bootstrap.LocationPicker, Roo.bootstrap.Component, {
25547 gMapContext: false,
25553 mapTypeControl: false,
25554 disableDoubleClickZoom: false,
25556 streetViewControl: false,
25560 enableAutocomplete: false,
25561 enableReverseGeocode: true,
25564 getAutoCreate: function()
25569 cls: 'roo-location-picker'
25575 initEvents: function(ct, position)
25577 if(!this.el.getWidth() || this.isApplied()){
25581 this.el.setVisibilityMode(Roo.Element.DISPLAY);
25586 initial: function()
25588 if(typeof(google) == 'undefined' || typeof(google.maps) == 'undefined'){
25589 this.fireEvent('loadexception', this);
25593 if(!this.mapTypeId){
25594 this.mapTypeId = google.maps.MapTypeId.ROADMAP;
25597 this.gMapContext = this.GMapContext();
25599 this.initOverlayView();
25601 this.OverlayView = new Roo.bootstrap.LocationPicker.OverlayView(this.gMapContext.map);
25605 google.maps.event.addListener(this.gMapContext.marker, "dragend", function(event) {
25606 _this.setPosition(_this.gMapContext.marker.position);
25609 google.maps.event.addListener(this.gMapContext.map, 'click', function(event){
25610 _this.fireEvent('mapClick', this, event);
25614 google.maps.event.addListener(this.gMapContext.map, 'rightclick', function(event){
25615 _this.fireEvent('mapRightClick', this, event);
25619 google.maps.event.addListener(this.gMapContext.marker, 'click', function(event){
25620 _this.fireEvent('markerClick', this, event);
25624 google.maps.event.addListener(this.gMapContext.marker, 'rightclick', function(event){
25625 _this.fireEvent('markerRightClick', this, event);
25629 this.setPosition(this.gMapContext.location);
25631 this.fireEvent('initial', this, this.gMapContext.location);
25634 initOverlayView: function()
25638 Roo.bootstrap.LocationPicker.OverlayView.prototype = Roo.apply(new google.maps.OverlayView(), {
25642 _this.fireEvent('OverlayViewDraw', _this);
25647 _this.fireEvent('OverlayViewOnAdd', _this);
25650 onRemove: function()
25652 _this.fireEvent('OverlayViewOnRemove', _this);
25655 show: function(cpx)
25657 _this.fireEvent('OverlayViewShow', _this, cpx);
25662 _this.fireEvent('OverlayViewHide', _this);
25668 fromLatLngToContainerPixel: function(event)
25670 return this.OverlayView.getProjection().fromLatLngToContainerPixel(event.latLng);
25673 isApplied: function()
25675 return this.getGmapContext() == false ? false : true;
25678 getGmapContext: function()
25680 return (typeof(this.gMapContext) == 'undefined') ? false : this.gMapContext;
25683 GMapContext: function()
25685 var position = new google.maps.LatLng(this.latitude, this.longitude);
25687 var _map = new google.maps.Map(this.el.dom, {
25690 mapTypeId: this.mapTypeId,
25691 mapTypeControl: this.mapTypeControl,
25692 disableDoubleClickZoom: this.disableDoubleClickZoom,
25693 scrollwheel: this.scrollwheel,
25694 streetViewControl: this.streetViewControl,
25695 locationName: this.locationName,
25696 draggable: this.draggable,
25697 enableAutocomplete: this.enableAutocomplete,
25698 enableReverseGeocode: this.enableReverseGeocode
25701 var _marker = new google.maps.Marker({
25702 position: position,
25704 title: this.markerTitle,
25705 draggable: this.draggable
25712 location: position,
25713 radius: this.radius,
25714 locationName: this.locationName,
25715 addressComponents: {
25716 formatted_address: null,
25717 addressLine1: null,
25718 addressLine2: null,
25720 streetNumber: null,
25724 stateOrProvince: null
25727 domContainer: this.el.dom,
25728 geodecoder: new google.maps.Geocoder()
25732 drawCircle: function(center, radius, options)
25734 if (this.gMapContext.circle != null) {
25735 this.gMapContext.circle.setMap(null);
25739 options = Roo.apply({}, options, {
25740 strokeColor: "#0000FF",
25741 strokeOpacity: .35,
25743 fillColor: "#0000FF",
25747 options.map = this.gMapContext.map;
25748 options.radius = radius;
25749 options.center = center;
25750 this.gMapContext.circle = new google.maps.Circle(options);
25751 return this.gMapContext.circle;
25757 setPosition: function(location)
25759 this.gMapContext.location = location;
25760 this.gMapContext.marker.setPosition(location);
25761 this.gMapContext.map.panTo(location);
25762 this.drawCircle(location, this.gMapContext.radius, {});
25766 if (this.gMapContext.settings.enableReverseGeocode) {
25767 this.gMapContext.geodecoder.geocode({
25768 latLng: this.gMapContext.location
25769 }, function(results, status) {
25771 if (status == google.maps.GeocoderStatus.OK && results.length > 0) {
25772 _this.gMapContext.locationName = results[0].formatted_address;
25773 _this.gMapContext.addressComponents = _this.address_component_from_google_geocode(results[0].address_components);
25775 _this.fireEvent('positionchanged', this, location);
25782 this.fireEvent('positionchanged', this, location);
25787 google.maps.event.trigger(this.gMapContext.map, "resize");
25789 this.gMapContext.map.setCenter(this.gMapContext.marker.position);
25791 this.fireEvent('resize', this);
25794 setPositionByLatLng: function(latitude, longitude)
25796 this.setPosition(new google.maps.LatLng(latitude, longitude));
25799 getCurrentPosition: function()
25802 latitude: this.gMapContext.location.lat(),
25803 longitude: this.gMapContext.location.lng()
25807 getAddressName: function()
25809 return this.gMapContext.locationName;
25812 getAddressComponents: function()
25814 return this.gMapContext.addressComponents;
25817 address_component_from_google_geocode: function(address_components)
25821 for (var i = 0; i < address_components.length; i++) {
25822 var component = address_components[i];
25823 if (component.types.indexOf("postal_code") >= 0) {
25824 result.postalCode = component.short_name;
25825 } else if (component.types.indexOf("street_number") >= 0) {
25826 result.streetNumber = component.short_name;
25827 } else if (component.types.indexOf("route") >= 0) {
25828 result.streetName = component.short_name;
25829 } else if (component.types.indexOf("neighborhood") >= 0) {
25830 result.city = component.short_name;
25831 } else if (component.types.indexOf("locality") >= 0) {
25832 result.city = component.short_name;
25833 } else if (component.types.indexOf("sublocality") >= 0) {
25834 result.district = component.short_name;
25835 } else if (component.types.indexOf("administrative_area_level_1") >= 0) {
25836 result.stateOrProvince = component.short_name;
25837 } else if (component.types.indexOf("country") >= 0) {
25838 result.country = component.short_name;
25842 result.addressLine1 = [ result.streetNumber, result.streetName ].join(" ").trim();
25843 result.addressLine2 = "";
25847 setZoomLevel: function(zoom)
25849 this.gMapContext.map.setZoom(zoom);
25862 this.fireEvent('show', this);
25873 this.fireEvent('hide', this);
25878 Roo.apply(Roo.bootstrap.LocationPicker, {
25880 OverlayView : function(map, options)
25882 options = options || {};
25896 * @class Roo.bootstrap.Alert
25897 * @extends Roo.bootstrap.Component
25898 * Bootstrap Alert class
25899 * @cfg {String} title The title of alert
25900 * @cfg {String} html The content of alert
25901 * @cfg {String} weight ( success | info | warning | danger )
25902 * @cfg {String} faicon font-awesomeicon
25905 * Create a new alert
25906 * @param {Object} config The config object
25910 Roo.bootstrap.Alert = function(config){
25911 Roo.bootstrap.Alert.superclass.constructor.call(this, config);
25915 Roo.extend(Roo.bootstrap.Alert, Roo.bootstrap.Component, {
25922 getAutoCreate : function()
25931 cls : 'roo-alert-icon'
25936 cls : 'roo-alert-title',
25941 cls : 'roo-alert-text',
25948 cfg.cn[0].cls += ' fa ' + this.faicon;
25952 cfg.cls += ' alert-' + this.weight;
25958 initEvents: function()
25960 this.el.setVisibilityMode(Roo.Element.DISPLAY);
25963 setTitle : function(str)
25965 this.el.select('.roo-alert-title',true).first().dom.innerHTML = str;
25968 setText : function(str)
25970 this.el.select('.roo-alert-text',true).first().dom.innerHTML = str;
25973 setWeight : function(weight)
25976 this.el.select('.alert',true).first().removeClass('alert-' + this.weight);
25979 this.weight = weight;
25981 this.el.select('.alert',true).first().addClass('alert-' + this.weight);
25984 setIcon : function(icon)
25987 this.el.select('.roo-alert-icon',true).first().removeClass(['fa', 'fa-' + this.faicon]);
25990 this.faicon = icon;
25992 this.el.select('.roo-alert-icon',true).first().addClass(['fa', 'fa-' + this.faicon]);
26013 * @class Roo.bootstrap.UploadCropbox
26014 * @extends Roo.bootstrap.Component
26015 * Bootstrap UploadCropbox class
26016 * @cfg {String} emptyText show when image has been loaded
26017 * @cfg {String} rotateNotify show when image too small to rotate
26018 * @cfg {Number} errorTimeout default 3000
26019 * @cfg {Number} minWidth default 300
26020 * @cfg {Number} minHeight default 300
26021 * @cfg {Array} buttons default ['rotateLeft', 'pictureBtn', 'rotateRight']
26022 * @cfg {Boolean} isDocument (true|false) default false
26023 * @cfg {String} url action url
26024 * @cfg {String} paramName default 'imageUpload'
26025 * @cfg {String} method default POST
26026 * @cfg {Boolean} loadMask (true|false) default true
26027 * @cfg {Boolean} loadingText default 'Loading...'
26030 * Create a new UploadCropbox
26031 * @param {Object} config The config object
26034 Roo.bootstrap.UploadCropbox = function(config){
26035 Roo.bootstrap.UploadCropbox.superclass.constructor.call(this, config);
26039 * @event beforeselectfile
26040 * Fire before select file
26041 * @param {Roo.bootstrap.UploadCropbox} this
26043 "beforeselectfile" : true,
26046 * Fire after initEvent
26047 * @param {Roo.bootstrap.UploadCropbox} this
26052 * Fire after initEvent
26053 * @param {Roo.bootstrap.UploadCropbox} this
26054 * @param {String} data
26059 * Fire when preparing the file data
26060 * @param {Roo.bootstrap.UploadCropbox} this
26061 * @param {Object} file
26066 * Fire when get exception
26067 * @param {Roo.bootstrap.UploadCropbox} this
26068 * @param {XMLHttpRequest} xhr
26070 "exception" : true,
26072 * @event beforeloadcanvas
26073 * Fire before load the canvas
26074 * @param {Roo.bootstrap.UploadCropbox} this
26075 * @param {String} src
26077 "beforeloadcanvas" : true,
26080 * Fire when trash image
26081 * @param {Roo.bootstrap.UploadCropbox} this
26086 * Fire when download the image
26087 * @param {Roo.bootstrap.UploadCropbox} this
26091 * @event footerbuttonclick
26092 * Fire when footerbuttonclick
26093 * @param {Roo.bootstrap.UploadCropbox} this
26094 * @param {String} type
26096 "footerbuttonclick" : true,
26100 * @param {Roo.bootstrap.UploadCropbox} this
26105 * Fire when rotate the image
26106 * @param {Roo.bootstrap.UploadCropbox} this
26107 * @param {String} pos
26112 * Fire when inspect the file
26113 * @param {Roo.bootstrap.UploadCropbox} this
26114 * @param {Object} file
26119 * Fire when xhr upload the file
26120 * @param {Roo.bootstrap.UploadCropbox} this
26121 * @param {Object} data
26126 * Fire when arrange the file data
26127 * @param {Roo.bootstrap.UploadCropbox} this
26128 * @param {Object} formData
26133 this.buttons = this.buttons || Roo.bootstrap.UploadCropbox.footer.STANDARD;
26136 Roo.extend(Roo.bootstrap.UploadCropbox, Roo.bootstrap.Component, {
26138 emptyText : 'Click to upload image',
26139 rotateNotify : 'Image is too small to rotate',
26140 errorTimeout : 3000,
26154 cropType : 'image/jpeg',
26156 canvasLoaded : false,
26157 isDocument : false,
26159 paramName : 'imageUpload',
26161 loadingText : 'Loading...',
26164 getAutoCreate : function()
26168 cls : 'roo-upload-cropbox',
26172 cls : 'roo-upload-cropbox-selector',
26177 cls : 'roo-upload-cropbox-body',
26178 style : 'cursor:pointer',
26182 cls : 'roo-upload-cropbox-preview'
26186 cls : 'roo-upload-cropbox-thumb'
26190 cls : 'roo-upload-cropbox-empty-notify',
26191 html : this.emptyText
26195 cls : 'roo-upload-cropbox-error-notify alert alert-danger',
26196 html : this.rotateNotify
26202 cls : 'roo-upload-cropbox-footer',
26205 cls : 'btn-group btn-group-justified roo-upload-cropbox-btn-group',
26215 onRender : function(ct, position)
26217 Roo.bootstrap.UploadCropbox.superclass.onRender.call(this, ct, position);
26219 if (this.buttons.length) {
26221 Roo.each(this.buttons, function(bb) {
26223 var btn = this.el.select('.roo-upload-cropbox-footer div.roo-upload-cropbox-btn-group').first().createChild(bb);
26225 btn.on('click', this.onFooterButtonClick.createDelegate(this, [bb.action], true));
26231 this.maskEl = this.el;
26235 initEvents : function()
26237 this.urlAPI = (window.createObjectURL && window) ||
26238 (window.URL && URL.revokeObjectURL && URL) ||
26239 (window.webkitURL && webkitURL);
26241 this.bodyEl = this.el.select('.roo-upload-cropbox-body', true).first();
26242 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26244 this.selectorEl = this.el.select('.roo-upload-cropbox-selector', true).first();
26245 this.selectorEl.hide();
26247 this.previewEl = this.el.select('.roo-upload-cropbox-preview', true).first();
26248 this.previewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26250 this.thumbEl = this.el.select('.roo-upload-cropbox-thumb', true).first();
26251 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26252 this.thumbEl.hide();
26254 this.notifyEl = this.el.select('.roo-upload-cropbox-empty-notify', true).first();
26255 this.notifyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26257 this.errorEl = this.el.select('.roo-upload-cropbox-error-notify', true).first();
26258 this.errorEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26259 this.errorEl.hide();
26261 this.footerEl = this.el.select('.roo-upload-cropbox-footer', true).first();
26262 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
26263 this.footerEl.hide();
26265 this.setThumbBoxSize();
26271 this.fireEvent('initial', this);
26278 window.addEventListener("resize", function() { _this.resize(); } );
26280 this.bodyEl.on('click', this.beforeSelectFile, this);
26283 this.bodyEl.on('touchstart', this.onTouchStart, this);
26284 this.bodyEl.on('touchmove', this.onTouchMove, this);
26285 this.bodyEl.on('touchend', this.onTouchEnd, this);
26289 this.bodyEl.on('mousedown', this.onMouseDown, this);
26290 this.bodyEl.on('mousemove', this.onMouseMove, this);
26291 var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel';
26292 this.bodyEl.on(mousewheel, this.onMouseWheel, this);
26293 Roo.get(document).on('mouseup', this.onMouseUp, this);
26296 this.selectorEl.on('change', this.onFileSelected, this);
26302 this.baseScale = 1;
26304 this.baseRotate = 1;
26305 this.dragable = false;
26306 this.pinching = false;
26309 this.cropData = false;
26310 this.notifyEl.dom.innerHTML = this.emptyText;
26312 this.selectorEl.dom.value = '';
26316 resize : function()
26318 if(this.fireEvent('resize', this) != false){
26319 this.setThumbBoxPosition();
26320 this.setCanvasPosition();
26324 onFooterButtonClick : function(e, el, o, type)
26327 case 'rotate-left' :
26328 this.onRotateLeft(e);
26330 case 'rotate-right' :
26331 this.onRotateRight(e);
26334 this.beforeSelectFile(e);
26349 this.fireEvent('footerbuttonclick', this, type);
26352 beforeSelectFile : function(e)
26354 e.preventDefault();
26356 if(this.fireEvent('beforeselectfile', this) != false){
26357 this.selectorEl.dom.click();
26361 onFileSelected : function(e)
26363 e.preventDefault();
26365 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
26369 var file = this.selectorEl.dom.files[0];
26371 if(this.fireEvent('inspect', this, file) != false){
26372 this.prepare(file);
26377 trash : function(e)
26379 this.fireEvent('trash', this);
26382 download : function(e)
26384 this.fireEvent('download', this);
26387 loadCanvas : function(src)
26389 if(this.fireEvent('beforeloadcanvas', this, src) != false){
26393 this.imageEl = document.createElement('img');
26397 this.imageEl.addEventListener("load", function(){ _this.onLoadCanvas(); });
26399 this.imageEl.src = src;
26403 onLoadCanvas : function()
26405 this.imageEl.OriginWidth = this.imageEl.naturalWidth || this.imageEl.width;
26406 this.imageEl.OriginHeight = this.imageEl.naturalHeight || this.imageEl.height;
26408 this.bodyEl.un('click', this.beforeSelectFile, this);
26410 this.notifyEl.hide();
26411 this.thumbEl.show();
26412 this.footerEl.show();
26414 this.baseRotateLevel();
26416 if(this.isDocument){
26417 this.setThumbBoxSize();
26420 this.setThumbBoxPosition();
26422 this.baseScaleLevel();
26428 this.canvasLoaded = true;
26431 this.maskEl.unmask();
26436 setCanvasPosition : function()
26438 if(!this.canvasEl){
26442 var pw = Math.ceil((this.bodyEl.getWidth() - this.canvasEl.width) / 2);
26443 var ph = Math.ceil((this.bodyEl.getHeight() - this.canvasEl.height) / 2);
26445 this.previewEl.setLeft(pw);
26446 this.previewEl.setTop(ph);
26450 onMouseDown : function(e)
26454 this.dragable = true;
26455 this.pinching = false;
26457 if(this.isDocument && (this.canvasEl.width < this.thumbEl.getWidth() || this.canvasEl.height < this.thumbEl.getHeight())){
26458 this.dragable = false;
26462 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
26463 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
26467 onMouseMove : function(e)
26471 if(!this.canvasLoaded){
26475 if (!this.dragable){
26479 var minX = Math.ceil(this.thumbEl.getLeft(true));
26480 var minY = Math.ceil(this.thumbEl.getTop(true));
26482 var maxX = Math.ceil(minX + this.thumbEl.getWidth() - this.canvasEl.width);
26483 var maxY = Math.ceil(minY + this.thumbEl.getHeight() - this.canvasEl.height);
26485 var x = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
26486 var y = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
26488 x = x - this.mouseX;
26489 y = y - this.mouseY;
26491 var bgX = Math.ceil(x + this.previewEl.getLeft(true));
26492 var bgY = Math.ceil(y + this.previewEl.getTop(true));
26494 bgX = (minX < bgX) ? minX : ((maxX > bgX) ? maxX : bgX);
26495 bgY = (minY < bgY) ? minY : ((maxY > bgY) ? maxY : bgY);
26497 this.previewEl.setLeft(bgX);
26498 this.previewEl.setTop(bgY);
26500 this.mouseX = Roo.isTouch ? e.browserEvent.touches[0].pageX : e.getPageX();
26501 this.mouseY = Roo.isTouch ? e.browserEvent.touches[0].pageY : e.getPageY();
26504 onMouseUp : function(e)
26508 this.dragable = false;
26511 onMouseWheel : function(e)
26515 this.startScale = this.scale;
26517 this.scale = (e.getWheelDelta() == 1) ? (this.scale + 1) : (this.scale - 1);
26519 if(!this.zoomable()){
26520 this.scale = this.startScale;
26529 zoomable : function()
26531 var minScale = this.thumbEl.getWidth() / this.minWidth;
26533 if(this.minWidth < this.minHeight){
26534 minScale = this.thumbEl.getHeight() / this.minHeight;
26537 var width = Math.ceil(this.imageEl.OriginWidth * this.getScaleLevel() / minScale);
26538 var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
26542 (this.rotate == 0 || this.rotate == 180) &&
26544 width > this.imageEl.OriginWidth ||
26545 height > this.imageEl.OriginHeight ||
26546 (width < this.minWidth && height < this.minHeight)
26554 (this.rotate == 90 || this.rotate == 270) &&
26556 width > this.imageEl.OriginWidth ||
26557 height > this.imageEl.OriginHeight ||
26558 (width < this.minHeight && height < this.minWidth)
26565 !this.isDocument &&
26566 (this.rotate == 0 || this.rotate == 180) &&
26568 width < this.minWidth ||
26569 width > this.imageEl.OriginWidth ||
26570 height < this.minHeight ||
26571 height > this.imageEl.OriginHeight
26578 !this.isDocument &&
26579 (this.rotate == 90 || this.rotate == 270) &&
26581 width < this.minHeight ||
26582 width > this.imageEl.OriginWidth ||
26583 height < this.minWidth ||
26584 height > this.imageEl.OriginHeight
26594 onRotateLeft : function(e)
26596 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
26598 var minScale = this.thumbEl.getWidth() / this.minWidth;
26600 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
26601 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
26603 this.startScale = this.scale;
26605 while (this.getScaleLevel() < minScale){
26607 this.scale = this.scale + 1;
26609 if(!this.zoomable()){
26614 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
26615 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
26620 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
26627 this.scale = this.startScale;
26629 this.onRotateFail();
26634 this.rotate = (this.rotate < 90) ? 270 : this.rotate - 90;
26636 if(this.isDocument){
26637 this.setThumbBoxSize();
26638 this.setThumbBoxPosition();
26639 this.setCanvasPosition();
26644 this.fireEvent('rotate', this, 'left');
26648 onRotateRight : function(e)
26650 if(!this.isDocument && (this.canvasEl.height < this.thumbEl.getWidth() || this.canvasEl.width < this.thumbEl.getHeight())){
26652 var minScale = this.thumbEl.getWidth() / this.minWidth;
26654 var bw = Math.ceil(this.canvasEl.width / this.getScaleLevel());
26655 var bh = Math.ceil(this.canvasEl.height / this.getScaleLevel());
26657 this.startScale = this.scale;
26659 while (this.getScaleLevel() < minScale){
26661 this.scale = this.scale + 1;
26663 if(!this.zoomable()){
26668 Math.ceil(bw * this.getScaleLevel()) < this.thumbEl.getHeight() ||
26669 Math.ceil(bh * this.getScaleLevel()) < this.thumbEl.getWidth()
26674 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
26681 this.scale = this.startScale;
26683 this.onRotateFail();
26688 this.rotate = (this.rotate > 180) ? 0 : this.rotate + 90;
26690 if(this.isDocument){
26691 this.setThumbBoxSize();
26692 this.setThumbBoxPosition();
26693 this.setCanvasPosition();
26698 this.fireEvent('rotate', this, 'right');
26701 onRotateFail : function()
26703 this.errorEl.show(true);
26707 (function() { _this.errorEl.hide(true); }).defer(this.errorTimeout);
26712 this.previewEl.dom.innerHTML = '';
26714 var canvasEl = document.createElement("canvas");
26716 var contextEl = canvasEl.getContext("2d");
26718 canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
26719 canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
26720 var center = this.imageEl.OriginWidth / 2;
26722 if(this.imageEl.OriginWidth < this.imageEl.OriginHeight){
26723 canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
26724 canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
26725 center = this.imageEl.OriginHeight / 2;
26728 contextEl.scale(this.getScaleLevel(), this.getScaleLevel());
26730 contextEl.translate(center, center);
26731 contextEl.rotate(this.rotate * Math.PI / 180);
26733 contextEl.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
26735 this.canvasEl = document.createElement("canvas");
26737 this.contextEl = this.canvasEl.getContext("2d");
26739 switch (this.rotate) {
26742 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
26743 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
26745 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
26750 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
26751 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
26753 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
26754 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);
26758 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
26763 this.canvasEl.width = this.imageEl.OriginWidth * this.getScaleLevel();
26764 this.canvasEl.height = this.imageEl.OriginHeight * this.getScaleLevel();
26766 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
26767 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);
26771 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);
26776 this.canvasEl.width = this.imageEl.OriginHeight * this.getScaleLevel();
26777 this.canvasEl.height = this.imageEl.OriginWidth * this.getScaleLevel();
26779 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
26780 this.contextEl.drawImage(canvasEl, 0, 0, this.canvasEl.width, this.canvasEl.height, 0, 0, this.canvasEl.width, this.canvasEl.height);
26784 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);
26791 this.previewEl.appendChild(this.canvasEl);
26793 this.setCanvasPosition();
26798 if(!this.canvasLoaded){
26802 var imageCanvas = document.createElement("canvas");
26804 var imageContext = imageCanvas.getContext("2d");
26806 imageCanvas.width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
26807 imageCanvas.height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? this.imageEl.OriginWidth : this.imageEl.OriginHeight;
26809 var center = imageCanvas.width / 2;
26811 imageContext.translate(center, center);
26813 imageContext.rotate(this.rotate * Math.PI / 180);
26815 imageContext.drawImage(this.imageEl, 0, 0, this.imageEl.OriginWidth, this.imageEl.OriginHeight, center * -1, center * -1, this.imageEl.OriginWidth, this.imageEl.OriginHeight);
26817 var canvas = document.createElement("canvas");
26819 var context = canvas.getContext("2d");
26821 canvas.width = this.minWidth;
26822 canvas.height = this.minHeight;
26824 switch (this.rotate) {
26827 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
26828 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
26830 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
26831 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
26833 var targetWidth = this.minWidth - 2 * x;
26834 var targetHeight = this.minHeight - 2 * y;
26838 if((x == 0 && y == 0) || (x == 0 && y > 0)){
26839 scale = targetWidth / width;
26842 if(x > 0 && y == 0){
26843 scale = targetHeight / height;
26846 if(x > 0 && y > 0){
26847 scale = targetWidth / width;
26849 if(width < height){
26850 scale = targetHeight / height;
26854 context.scale(scale, scale);
26856 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
26857 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
26859 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
26860 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
26862 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
26867 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
26868 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
26870 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
26871 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
26873 var targetWidth = this.minWidth - 2 * x;
26874 var targetHeight = this.minHeight - 2 * y;
26878 if((x == 0 && y == 0) || (x == 0 && y > 0)){
26879 scale = targetWidth / width;
26882 if(x > 0 && y == 0){
26883 scale = targetHeight / height;
26886 if(x > 0 && y > 0){
26887 scale = targetWidth / width;
26889 if(width < height){
26890 scale = targetHeight / height;
26894 context.scale(scale, scale);
26896 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
26897 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
26899 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
26900 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
26902 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
26904 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
26909 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
26910 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
26912 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
26913 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
26915 var targetWidth = this.minWidth - 2 * x;
26916 var targetHeight = this.minHeight - 2 * y;
26920 if((x == 0 && y == 0) || (x == 0 && y > 0)){
26921 scale = targetWidth / width;
26924 if(x > 0 && y == 0){
26925 scale = targetHeight / height;
26928 if(x > 0 && y > 0){
26929 scale = targetWidth / width;
26931 if(width < height){
26932 scale = targetHeight / height;
26936 context.scale(scale, scale);
26938 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
26939 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
26941 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
26942 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
26944 sx += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
26945 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight) : 0;
26947 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
26952 var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getWidth() / this.getScaleLevel());
26953 var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getHeight() / this.getScaleLevel());
26955 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
26956 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
26958 var targetWidth = this.minWidth - 2 * x;
26959 var targetHeight = this.minHeight - 2 * y;
26963 if((x == 0 && y == 0) || (x == 0 && y > 0)){
26964 scale = targetWidth / width;
26967 if(x > 0 && y == 0){
26968 scale = targetHeight / height;
26971 if(x > 0 && y > 0){
26972 scale = targetWidth / width;
26974 if(width < height){
26975 scale = targetHeight / height;
26979 context.scale(scale, scale);
26981 var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
26982 var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
26984 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
26985 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
26987 sy += (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? 0 : Math.abs(this.imageEl.OriginWidth - this.imageEl.OriginHeight);
26989 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
26996 this.cropData = canvas.toDataURL(this.cropType);
26998 if(this.fireEvent('crop', this, this.cropData) !== false){
26999 this.process(this.file, this.cropData);
27006 setThumbBoxSize : function()
27010 if(this.isDocument && typeof(this.imageEl) != 'undefined'){
27011 width = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.max(this.minWidth, this.minHeight) : Math.min(this.minWidth, this.minHeight);
27012 height = (this.imageEl.OriginWidth > this.imageEl.OriginHeight) ? Math.min(this.minWidth, this.minHeight) : Math.max(this.minWidth, this.minHeight);
27014 this.minWidth = width;
27015 this.minHeight = height;
27017 if(this.rotate == 90 || this.rotate == 270){
27018 this.minWidth = height;
27019 this.minHeight = width;
27024 width = Math.ceil(this.minWidth * height / this.minHeight);
27026 if(this.minWidth > this.minHeight){
27028 height = Math.ceil(this.minHeight * width / this.minWidth);
27031 this.thumbEl.setStyle({
27032 width : width + 'px',
27033 height : height + 'px'
27040 setThumbBoxPosition : function()
27042 var x = Math.ceil((this.bodyEl.getWidth() - this.thumbEl.getWidth()) / 2 );
27043 var y = Math.ceil((this.bodyEl.getHeight() - this.thumbEl.getHeight()) / 2);
27045 this.thumbEl.setLeft(x);
27046 this.thumbEl.setTop(y);
27050 baseRotateLevel : function()
27052 this.baseRotate = 1;
27055 typeof(this.exif) != 'undefined' &&
27056 typeof(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != 'undefined' &&
27057 [1, 3, 6, 8].indexOf(this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']]) != -1
27059 this.baseRotate = this.exif[Roo.bootstrap.UploadCropbox['tags']['Orientation']];
27062 this.rotate = Roo.bootstrap.UploadCropbox['Orientation'][this.baseRotate];
27066 baseScaleLevel : function()
27070 if(this.isDocument){
27072 if(this.baseRotate == 6 || this.baseRotate == 8){
27074 height = this.thumbEl.getHeight();
27075 this.baseScale = height / this.imageEl.OriginWidth;
27077 if(this.imageEl.OriginHeight * this.baseScale > this.thumbEl.getWidth()){
27078 width = this.thumbEl.getWidth();
27079 this.baseScale = width / this.imageEl.OriginHeight;
27085 height = this.thumbEl.getHeight();
27086 this.baseScale = height / this.imageEl.OriginHeight;
27088 if(this.imageEl.OriginWidth * this.baseScale > this.thumbEl.getWidth()){
27089 width = this.thumbEl.getWidth();
27090 this.baseScale = width / this.imageEl.OriginWidth;
27096 if(this.baseRotate == 6 || this.baseRotate == 8){
27098 width = this.thumbEl.getHeight();
27099 this.baseScale = width / this.imageEl.OriginHeight;
27101 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getWidth()){
27102 height = this.thumbEl.getWidth();
27103 this.baseScale = height / this.imageEl.OriginHeight;
27106 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27107 height = this.thumbEl.getWidth();
27108 this.baseScale = height / this.imageEl.OriginHeight;
27110 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getHeight()){
27111 width = this.thumbEl.getHeight();
27112 this.baseScale = width / this.imageEl.OriginWidth;
27119 width = this.thumbEl.getWidth();
27120 this.baseScale = width / this.imageEl.OriginWidth;
27122 if(this.imageEl.OriginHeight * this.baseScale < this.thumbEl.getHeight()){
27123 height = this.thumbEl.getHeight();
27124 this.baseScale = height / this.imageEl.OriginHeight;
27127 if(this.imageEl.OriginWidth > this.imageEl.OriginHeight){
27129 height = this.thumbEl.getHeight();
27130 this.baseScale = height / this.imageEl.OriginHeight;
27132 if(this.imageEl.OriginWidth * this.baseScale < this.thumbEl.getWidth()){
27133 width = this.thumbEl.getWidth();
27134 this.baseScale = width / this.imageEl.OriginWidth;
27142 getScaleLevel : function()
27144 return this.baseScale * Math.pow(1.1, this.scale);
27147 onTouchStart : function(e)
27149 if(!this.canvasLoaded){
27150 this.beforeSelectFile(e);
27154 var touches = e.browserEvent.touches;
27160 if(touches.length == 1){
27161 this.onMouseDown(e);
27165 if(touches.length != 2){
27171 for(var i = 0, finger; finger = touches[i]; i++){
27172 coords.push(finger.pageX, finger.pageY);
27175 var x = Math.pow(coords[0] - coords[2], 2);
27176 var y = Math.pow(coords[1] - coords[3], 2);
27178 this.startDistance = Math.sqrt(x + y);
27180 this.startScale = this.scale;
27182 this.pinching = true;
27183 this.dragable = false;
27187 onTouchMove : function(e)
27189 if(!this.pinching && !this.dragable){
27193 var touches = e.browserEvent.touches;
27200 this.onMouseMove(e);
27206 for(var i = 0, finger; finger = touches[i]; i++){
27207 coords.push(finger.pageX, finger.pageY);
27210 var x = Math.pow(coords[0] - coords[2], 2);
27211 var y = Math.pow(coords[1] - coords[3], 2);
27213 this.endDistance = Math.sqrt(x + y);
27215 this.scale = this.startScale + Math.floor(Math.log(this.endDistance / this.startDistance) / Math.log(1.1));
27217 if(!this.zoomable()){
27218 this.scale = this.startScale;
27226 onTouchEnd : function(e)
27228 this.pinching = false;
27229 this.dragable = false;
27233 process : function(file, crop)
27236 this.maskEl.mask(this.loadingText);
27239 this.xhr = new XMLHttpRequest();
27241 file.xhr = this.xhr;
27243 this.xhr.open(this.method, this.url, true);
27246 "Accept": "application/json",
27247 "Cache-Control": "no-cache",
27248 "X-Requested-With": "XMLHttpRequest"
27251 for (var headerName in headers) {
27252 var headerValue = headers[headerName];
27254 this.xhr.setRequestHeader(headerName, headerValue);
27260 this.xhr.onload = function()
27262 _this.xhrOnLoad(_this.xhr);
27265 this.xhr.onerror = function()
27267 _this.xhrOnError(_this.xhr);
27270 var formData = new FormData();
27272 formData.append('returnHTML', 'NO');
27275 formData.append('crop', crop);
27278 if(typeof(file) != 'undefined' && (typeof(file.id) == 'undefined' || file.id * 1 < 1)){
27279 formData.append(this.paramName, file, file.name);
27282 if(typeof(file.filename) != 'undefined'){
27283 formData.append('filename', file.filename);
27286 if(typeof(file.mimetype) != 'undefined'){
27287 formData.append('mimetype', file.mimetype);
27290 if(this.fireEvent('arrange', this, formData) != false){
27291 this.xhr.send(formData);
27295 xhrOnLoad : function(xhr)
27298 this.maskEl.unmask();
27301 if (xhr.readyState !== 4) {
27302 this.fireEvent('exception', this, xhr);
27306 var response = Roo.decode(xhr.responseText);
27308 if(!response.success){
27309 this.fireEvent('exception', this, xhr);
27313 var response = Roo.decode(xhr.responseText);
27315 this.fireEvent('upload', this, response);
27319 xhrOnError : function()
27322 this.maskEl.unmask();
27325 Roo.log('xhr on error');
27327 var response = Roo.decode(xhr.responseText);
27333 prepare : function(file)
27336 this.maskEl.mask(this.loadingText);
27342 if(typeof(file) === 'string'){
27343 this.loadCanvas(file);
27347 if(!file || !this.urlAPI){
27352 this.cropType = file.type;
27356 if(this.fireEvent('prepare', this, this.file) != false){
27358 var reader = new FileReader();
27360 reader.onload = function (e) {
27361 if (e.target.error) {
27362 Roo.log(e.target.error);
27366 var buffer = e.target.result,
27367 dataView = new DataView(buffer),
27369 maxOffset = dataView.byteLength - 4,
27373 if (dataView.getUint16(0) === 0xffd8) {
27374 while (offset < maxOffset) {
27375 markerBytes = dataView.getUint16(offset);
27377 if ((markerBytes >= 0xffe0 && markerBytes <= 0xffef) || markerBytes === 0xfffe) {
27378 markerLength = dataView.getUint16(offset + 2) + 2;
27379 if (offset + markerLength > dataView.byteLength) {
27380 Roo.log('Invalid meta data: Invalid segment size.');
27384 if(markerBytes == 0xffe1){
27385 _this.parseExifData(
27392 offset += markerLength;
27402 var url = _this.urlAPI.createObjectURL(_this.file);
27404 _this.loadCanvas(url);
27409 reader.readAsArrayBuffer(this.file);
27415 parseExifData : function(dataView, offset, length)
27417 var tiffOffset = offset + 10,
27421 if (dataView.getUint32(offset + 4) !== 0x45786966) {
27422 // No Exif data, might be XMP data instead
27426 // Check for the ASCII code for "Exif" (0x45786966):
27427 if (dataView.getUint32(offset + 4) !== 0x45786966) {
27428 // No Exif data, might be XMP data instead
27431 if (tiffOffset + 8 > dataView.byteLength) {
27432 Roo.log('Invalid Exif data: Invalid segment size.');
27435 // Check for the two null bytes:
27436 if (dataView.getUint16(offset + 8) !== 0x0000) {
27437 Roo.log('Invalid Exif data: Missing byte alignment offset.');
27440 // Check the byte alignment:
27441 switch (dataView.getUint16(tiffOffset)) {
27443 littleEndian = true;
27446 littleEndian = false;
27449 Roo.log('Invalid Exif data: Invalid byte alignment marker.');
27452 // Check for the TIFF tag marker (0x002A):
27453 if (dataView.getUint16(tiffOffset + 2, littleEndian) !== 0x002A) {
27454 Roo.log('Invalid Exif data: Missing TIFF marker.');
27457 // Retrieve the directory offset bytes, usually 0x00000008 or 8 decimal:
27458 dirOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
27460 this.parseExifTags(
27463 tiffOffset + dirOffset,
27468 parseExifTags : function(dataView, tiffOffset, dirOffset, littleEndian)
27473 if (dirOffset + 6 > dataView.byteLength) {
27474 Roo.log('Invalid Exif data: Invalid directory offset.');
27477 tagsNumber = dataView.getUint16(dirOffset, littleEndian);
27478 dirEndOffset = dirOffset + 2 + 12 * tagsNumber;
27479 if (dirEndOffset + 4 > dataView.byteLength) {
27480 Roo.log('Invalid Exif data: Invalid directory size.');
27483 for (i = 0; i < tagsNumber; i += 1) {
27487 dirOffset + 2 + 12 * i, // tag offset
27491 // Return the offset to the next directory:
27492 return dataView.getUint32(dirEndOffset, littleEndian);
27495 parseExifTag : function (dataView, tiffOffset, offset, littleEndian)
27497 var tag = dataView.getUint16(offset, littleEndian);
27499 this.exif[tag] = this.getExifValue(
27503 dataView.getUint16(offset + 2, littleEndian), // tag type
27504 dataView.getUint32(offset + 4, littleEndian), // tag length
27509 getExifValue : function (dataView, tiffOffset, offset, type, length, littleEndian)
27511 var tagType = Roo.bootstrap.UploadCropbox.exifTagTypes[type],
27520 Roo.log('Invalid Exif data: Invalid tag type.');
27524 tagSize = tagType.size * length;
27525 // Determine if the value is contained in the dataOffset bytes,
27526 // or if the value at the dataOffset is a pointer to the actual data:
27527 dataOffset = tagSize > 4 ?
27528 tiffOffset + dataView.getUint32(offset + 8, littleEndian) : (offset + 8);
27529 if (dataOffset + tagSize > dataView.byteLength) {
27530 Roo.log('Invalid Exif data: Invalid data offset.');
27533 if (length === 1) {
27534 return tagType.getValue(dataView, dataOffset, littleEndian);
27537 for (i = 0; i < length; i += 1) {
27538 values[i] = tagType.getValue(dataView, dataOffset + i * tagType.size, littleEndian);
27541 if (tagType.ascii) {
27543 // Concatenate the chars:
27544 for (i = 0; i < values.length; i += 1) {
27546 // Ignore the terminating NULL byte(s):
27547 if (c === '\u0000') {
27559 Roo.apply(Roo.bootstrap.UploadCropbox, {
27561 'Orientation': 0x0112
27565 1: 0, //'top-left',
27567 3: 180, //'bottom-right',
27568 // 4: 'bottom-left',
27570 6: 90, //'right-top',
27571 // 7: 'right-bottom',
27572 8: 270 //'left-bottom'
27576 // byte, 8-bit unsigned int:
27578 getValue: function (dataView, dataOffset) {
27579 return dataView.getUint8(dataOffset);
27583 // ascii, 8-bit byte:
27585 getValue: function (dataView, dataOffset) {
27586 return String.fromCharCode(dataView.getUint8(dataOffset));
27591 // short, 16 bit int:
27593 getValue: function (dataView, dataOffset, littleEndian) {
27594 return dataView.getUint16(dataOffset, littleEndian);
27598 // long, 32 bit int:
27600 getValue: function (dataView, dataOffset, littleEndian) {
27601 return dataView.getUint32(dataOffset, littleEndian);
27605 // rational = two long values, first is numerator, second is denominator:
27607 getValue: function (dataView, dataOffset, littleEndian) {
27608 return dataView.getUint32(dataOffset, littleEndian) /
27609 dataView.getUint32(dataOffset + 4, littleEndian);
27613 // slong, 32 bit signed int:
27615 getValue: function (dataView, dataOffset, littleEndian) {
27616 return dataView.getInt32(dataOffset, littleEndian);
27620 // srational, two slongs, first is numerator, second is denominator:
27622 getValue: function (dataView, dataOffset, littleEndian) {
27623 return dataView.getInt32(dataOffset, littleEndian) /
27624 dataView.getInt32(dataOffset + 4, littleEndian);
27634 cls : 'btn-group roo-upload-cropbox-rotate-left',
27635 action : 'rotate-left',
27639 cls : 'btn btn-default',
27640 html : '<i class="fa fa-undo"></i>'
27646 cls : 'btn-group roo-upload-cropbox-picture',
27647 action : 'picture',
27651 cls : 'btn btn-default',
27652 html : '<i class="fa fa-picture-o"></i>'
27658 cls : 'btn-group roo-upload-cropbox-rotate-right',
27659 action : 'rotate-right',
27663 cls : 'btn btn-default',
27664 html : '<i class="fa fa-repeat"></i>'
27672 cls : 'btn-group roo-upload-cropbox-rotate-left',
27673 action : 'rotate-left',
27677 cls : 'btn btn-default',
27678 html : '<i class="fa fa-undo"></i>'
27684 cls : 'btn-group roo-upload-cropbox-download',
27685 action : 'download',
27689 cls : 'btn btn-default',
27690 html : '<i class="fa fa-download"></i>'
27696 cls : 'btn-group roo-upload-cropbox-crop',
27701 cls : 'btn btn-default',
27702 html : '<i class="fa fa-crop"></i>'
27708 cls : 'btn-group roo-upload-cropbox-trash',
27713 cls : 'btn btn-default',
27714 html : '<i class="fa fa-trash"></i>'
27720 cls : 'btn-group roo-upload-cropbox-rotate-right',
27721 action : 'rotate-right',
27725 cls : 'btn btn-default',
27726 html : '<i class="fa fa-repeat"></i>'
27734 cls : 'btn-group roo-upload-cropbox-rotate-left',
27735 action : 'rotate-left',
27739 cls : 'btn btn-default',
27740 html : '<i class="fa fa-undo"></i>'
27746 cls : 'btn-group roo-upload-cropbox-rotate-right',
27747 action : 'rotate-right',
27751 cls : 'btn btn-default',
27752 html : '<i class="fa fa-repeat"></i>'
27765 * @class Roo.bootstrap.DocumentManager
27766 * @extends Roo.bootstrap.Component
27767 * Bootstrap DocumentManager class
27768 * @cfg {String} paramName default 'imageUpload'
27769 * @cfg {String} toolTipName default 'filename'
27770 * @cfg {String} method default POST
27771 * @cfg {String} url action url
27772 * @cfg {Number} boxes number of boxes, 0 is no limit.. default 0
27773 * @cfg {Boolean} multiple multiple upload default true
27774 * @cfg {Number} thumbSize default 300
27775 * @cfg {String} fieldLabel
27776 * @cfg {Number} labelWidth default 4
27777 * @cfg {String} labelAlign (left|top) default left
27778 * @cfg {Boolean} editable (true|false) allow edit when upload a image default true
27779 * @cfg {Number} labellg set the width of label (1-12)
27780 * @cfg {Number} labelmd set the width of label (1-12)
27781 * @cfg {Number} labelsm set the width of label (1-12)
27782 * @cfg {Number} labelxs set the width of label (1-12)
27785 * Create a new DocumentManager
27786 * @param {Object} config The config object
27789 Roo.bootstrap.DocumentManager = function(config){
27790 Roo.bootstrap.DocumentManager.superclass.constructor.call(this, config);
27793 this.delegates = [];
27798 * Fire when initial the DocumentManager
27799 * @param {Roo.bootstrap.DocumentManager} this
27804 * inspect selected file
27805 * @param {Roo.bootstrap.DocumentManager} this
27806 * @param {File} file
27811 * Fire when xhr load exception
27812 * @param {Roo.bootstrap.DocumentManager} this
27813 * @param {XMLHttpRequest} xhr
27815 "exception" : true,
27817 * @event afterupload
27818 * Fire when xhr load exception
27819 * @param {Roo.bootstrap.DocumentManager} this
27820 * @param {XMLHttpRequest} xhr
27822 "afterupload" : true,
27825 * prepare the form data
27826 * @param {Roo.bootstrap.DocumentManager} this
27827 * @param {Object} formData
27832 * Fire when remove the file
27833 * @param {Roo.bootstrap.DocumentManager} this
27834 * @param {Object} file
27839 * Fire after refresh the file
27840 * @param {Roo.bootstrap.DocumentManager} this
27845 * Fire after click the image
27846 * @param {Roo.bootstrap.DocumentManager} this
27847 * @param {Object} file
27852 * Fire when upload a image and editable set to true
27853 * @param {Roo.bootstrap.DocumentManager} this
27854 * @param {Object} file
27858 * @event beforeselectfile
27859 * Fire before select file
27860 * @param {Roo.bootstrap.DocumentManager} this
27862 "beforeselectfile" : true,
27865 * Fire before process file
27866 * @param {Roo.bootstrap.DocumentManager} this
27867 * @param {Object} file
27874 Roo.extend(Roo.bootstrap.DocumentManager, Roo.bootstrap.Component, {
27883 paramName : 'imageUpload',
27884 toolTipName : 'filename',
27887 labelAlign : 'left',
27897 getAutoCreate : function()
27899 var managerWidget = {
27901 cls : 'roo-document-manager',
27905 cls : 'roo-document-manager-selector',
27910 cls : 'roo-document-manager-uploader',
27914 cls : 'roo-document-manager-upload-btn',
27915 html : '<i class="fa fa-plus"></i>'
27926 cls : 'column col-md-12',
27931 if(this.fieldLabel.length){
27936 cls : 'column col-md-12',
27937 html : this.fieldLabel
27941 cls : 'column col-md-12',
27946 if(this.labelAlign == 'left'){
27951 html : this.fieldLabel
27960 if(this.labelWidth > 12){
27961 content[0].style = "width: " + this.labelWidth + 'px';
27964 if(this.labelWidth < 13 && this.labelmd == 0){
27965 this.labelmd = this.labelWidth;
27968 if(this.labellg > 0){
27969 content[0].cls += ' col-lg-' + this.labellg;
27970 content[1].cls += ' col-lg-' + (12 - this.labellg);
27973 if(this.labelmd > 0){
27974 content[0].cls += ' col-md-' + this.labelmd;
27975 content[1].cls += ' col-md-' + (12 - this.labelmd);
27978 if(this.labelsm > 0){
27979 content[0].cls += ' col-sm-' + this.labelsm;
27980 content[1].cls += ' col-sm-' + (12 - this.labelsm);
27983 if(this.labelxs > 0){
27984 content[0].cls += ' col-xs-' + this.labelxs;
27985 content[1].cls += ' col-xs-' + (12 - this.labelxs);
27993 cls : 'row clearfix',
28001 initEvents : function()
28003 this.managerEl = this.el.select('.roo-document-manager', true).first();
28004 this.managerEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
28006 this.selectorEl = this.el.select('.roo-document-manager-selector', true).first();
28007 this.selectorEl.hide();
28010 this.selectorEl.attr('multiple', 'multiple');
28013 this.selectorEl.on('change', this.onFileSelected, this);
28015 this.uploader = this.el.select('.roo-document-manager-uploader', true).first();
28016 this.uploader.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
28018 this.uploader.on('click', this.onUploaderClick, this);
28020 this.renderProgressDialog();
28024 window.addEventListener("resize", function() { _this.refresh(); } );
28026 this.fireEvent('initial', this);
28029 renderProgressDialog : function()
28033 this.progressDialog = new Roo.bootstrap.Modal({
28034 cls : 'roo-document-manager-progress-dialog',
28035 allow_close : false,
28045 btnclick : function() {
28046 _this.uploadCancel();
28052 this.progressDialog.render(Roo.get(document.body));
28054 this.progress = new Roo.bootstrap.Progress({
28055 cls : 'roo-document-manager-progress',
28060 this.progress.render(this.progressDialog.getChildContainer());
28062 this.progressBar = new Roo.bootstrap.ProgressBar({
28063 cls : 'roo-document-manager-progress-bar',
28066 aria_valuemax : 12,
28070 this.progressBar.render(this.progress.getChildContainer());
28073 onUploaderClick : function(e)
28075 e.preventDefault();
28077 if(this.fireEvent('beforeselectfile', this) != false){
28078 this.selectorEl.dom.click();
28083 onFileSelected : function(e)
28085 e.preventDefault();
28087 if(typeof(this.selectorEl.dom.files) == 'undefined' || !this.selectorEl.dom.files.length){
28091 Roo.each(this.selectorEl.dom.files, function(file){
28092 if(this.fireEvent('inspect', this, file) != false){
28093 this.files.push(file);
28103 this.selectorEl.dom.value = '';
28105 if(!this.files.length){
28109 if(this.boxes > 0 && this.files.length > this.boxes){
28110 this.files = this.files.slice(0, this.boxes);
28113 this.uploader.show();
28115 if(this.boxes > 0 && this.files.length > this.boxes - 1){
28116 this.uploader.hide();
28125 Roo.each(this.files, function(file){
28127 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
28128 var f = this.renderPreview(file);
28133 if(file.type.indexOf('image') != -1){
28134 this.delegates.push(
28136 _this.process(file);
28137 }).createDelegate(this)
28145 _this.process(file);
28146 }).createDelegate(this)
28151 this.files = files;
28153 this.delegates = this.delegates.concat(docs);
28155 if(!this.delegates.length){
28160 this.progressBar.aria_valuemax = this.delegates.length;
28167 arrange : function()
28169 if(!this.delegates.length){
28170 this.progressDialog.hide();
28175 var delegate = this.delegates.shift();
28177 this.progressDialog.show();
28179 this.progressDialog.setTitle((this.progressBar.aria_valuemax - this.delegates.length) + ' / ' + this.progressBar.aria_valuemax);
28181 this.progressBar.update(this.progressBar.aria_valuemax - this.delegates.length);
28186 refresh : function()
28188 this.uploader.show();
28190 if(this.boxes > 0 && this.files.length > this.boxes - 1){
28191 this.uploader.hide();
28194 Roo.isTouch ? this.closable(false) : this.closable(true);
28196 this.fireEvent('refresh', this);
28199 onRemove : function(e, el, o)
28201 e.preventDefault();
28203 this.fireEvent('remove', this, o);
28207 remove : function(o)
28211 Roo.each(this.files, function(file){
28212 if(typeof(file.id) == 'undefined' || file.id * 1 < 1 || file.id != o.id){
28221 this.files = files;
28228 Roo.each(this.files, function(file){
28233 file.target.remove();
28242 onClick : function(e, el, o)
28244 e.preventDefault();
28246 this.fireEvent('click', this, o);
28250 closable : function(closable)
28252 Roo.each(this.managerEl.select('.roo-document-manager-preview > button.close', true).elements, function(el){
28254 el.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
28266 xhrOnLoad : function(xhr)
28268 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
28272 if (xhr.readyState !== 4) {
28274 this.fireEvent('exception', this, xhr);
28278 var response = Roo.decode(xhr.responseText);
28280 if(!response.success){
28282 this.fireEvent('exception', this, xhr);
28286 var file = this.renderPreview(response.data);
28288 this.files.push(file);
28292 this.fireEvent('afterupload', this, xhr);
28296 xhrOnError : function(xhr)
28298 Roo.log('xhr on error');
28300 var response = Roo.decode(xhr.responseText);
28307 process : function(file)
28309 if(this.fireEvent('process', this, file) !== false){
28310 if(this.editable && file.type.indexOf('image') != -1){
28311 this.fireEvent('edit', this, file);
28315 this.uploadStart(file, false);
28322 uploadStart : function(file, crop)
28324 this.xhr = new XMLHttpRequest();
28326 if(typeof(file.id) != 'undefined' && file.id * 1 > 0){
28331 file.xhr = this.xhr;
28333 this.managerEl.createChild({
28335 cls : 'roo-document-manager-loading',
28339 tooltip : file.name,
28340 cls : 'roo-document-manager-thumb',
28341 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
28347 this.xhr.open(this.method, this.url, true);
28350 "Accept": "application/json",
28351 "Cache-Control": "no-cache",
28352 "X-Requested-With": "XMLHttpRequest"
28355 for (var headerName in headers) {
28356 var headerValue = headers[headerName];
28358 this.xhr.setRequestHeader(headerName, headerValue);
28364 this.xhr.onload = function()
28366 _this.xhrOnLoad(_this.xhr);
28369 this.xhr.onerror = function()
28371 _this.xhrOnError(_this.xhr);
28374 var formData = new FormData();
28376 formData.append('returnHTML', 'NO');
28379 formData.append('crop', crop);
28382 formData.append(this.paramName, file, file.name);
28389 if(this.fireEvent('prepare', this, formData, options) != false){
28391 if(options.manually){
28395 this.xhr.send(formData);
28399 this.uploadCancel();
28402 uploadCancel : function()
28408 this.delegates = [];
28410 Roo.each(this.managerEl.select('.roo-document-manager-loading', true).elements, function(el){
28417 renderPreview : function(file)
28419 if(typeof(file.target) != 'undefined' && file.target){
28423 var previewEl = this.managerEl.createChild({
28425 cls : 'roo-document-manager-preview',
28429 tooltip : file[this.toolTipName],
28430 cls : 'roo-document-manager-thumb',
28431 html : '<img tooltip="' + file[this.toolTipName] + '" src="' + baseURL +'/Images/Thumb/' + this.thumbSize + '/' + file.id + '/' + file.filename + '">'
28436 html : '<i class="fa fa-times-circle"></i>'
28441 var close = previewEl.select('button.close', true).first();
28443 close.on('click', this.onRemove, this, file);
28445 file.target = previewEl;
28447 var image = previewEl.select('img', true).first();
28451 image.dom.addEventListener("load", function(){ _this.onPreviewLoad(file, image); });
28453 image.on('click', this.onClick, this, file);
28459 onPreviewLoad : function(file, image)
28461 if(typeof(file.target) == 'undefined' || !file.target){
28465 var width = image.dom.naturalWidth || image.dom.width;
28466 var height = image.dom.naturalHeight || image.dom.height;
28468 if(width > height){
28469 file.target.addClass('wide');
28473 file.target.addClass('tall');
28478 uploadFromSource : function(file, crop)
28480 this.xhr = new XMLHttpRequest();
28482 this.managerEl.createChild({
28484 cls : 'roo-document-manager-loading',
28488 tooltip : file.name,
28489 cls : 'roo-document-manager-thumb',
28490 html : '<i class="fa fa-circle-o-notch fa-spin"></i>'
28496 this.xhr.open(this.method, this.url, true);
28499 "Accept": "application/json",
28500 "Cache-Control": "no-cache",
28501 "X-Requested-With": "XMLHttpRequest"
28504 for (var headerName in headers) {
28505 var headerValue = headers[headerName];
28507 this.xhr.setRequestHeader(headerName, headerValue);
28513 this.xhr.onload = function()
28515 _this.xhrOnLoad(_this.xhr);
28518 this.xhr.onerror = function()
28520 _this.xhrOnError(_this.xhr);
28523 var formData = new FormData();
28525 formData.append('returnHTML', 'NO');
28527 formData.append('crop', crop);
28529 if(typeof(file.filename) != 'undefined'){
28530 formData.append('filename', file.filename);
28533 if(typeof(file.mimetype) != 'undefined'){
28534 formData.append('mimetype', file.mimetype);
28539 if(this.fireEvent('prepare', this, formData) != false){
28540 this.xhr.send(formData);
28550 * @class Roo.bootstrap.DocumentViewer
28551 * @extends Roo.bootstrap.Component
28552 * Bootstrap DocumentViewer class
28553 * @cfg {Boolean} showDownload (true|false) show download button (default true)
28554 * @cfg {Boolean} showTrash (true|false) show trash button (default true)
28557 * Create a new DocumentViewer
28558 * @param {Object} config The config object
28561 Roo.bootstrap.DocumentViewer = function(config){
28562 Roo.bootstrap.DocumentViewer.superclass.constructor.call(this, config);
28567 * Fire after initEvent
28568 * @param {Roo.bootstrap.DocumentViewer} this
28574 * @param {Roo.bootstrap.DocumentViewer} this
28579 * Fire after download button
28580 * @param {Roo.bootstrap.DocumentViewer} this
28585 * Fire after trash button
28586 * @param {Roo.bootstrap.DocumentViewer} this
28593 Roo.extend(Roo.bootstrap.DocumentViewer, Roo.bootstrap.Component, {
28595 showDownload : true,
28599 getAutoCreate : function()
28603 cls : 'roo-document-viewer',
28607 cls : 'roo-document-viewer-body',
28611 cls : 'roo-document-viewer-thumb',
28615 cls : 'roo-document-viewer-image'
28623 cls : 'roo-document-viewer-footer',
28626 cls : 'btn-group btn-group-justified roo-document-viewer-btn-group',
28630 cls : 'btn-group roo-document-viewer-download',
28634 cls : 'btn btn-default',
28635 html : '<i class="fa fa-download"></i>'
28641 cls : 'btn-group roo-document-viewer-trash',
28645 cls : 'btn btn-default',
28646 html : '<i class="fa fa-trash"></i>'
28659 initEvents : function()
28661 this.bodyEl = this.el.select('.roo-document-viewer-body', true).first();
28662 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
28664 this.thumbEl = this.el.select('.roo-document-viewer-thumb', true).first();
28665 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
28667 this.imageEl = this.el.select('.roo-document-viewer-image', true).first();
28668 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
28670 this.footerEl = this.el.select('.roo-document-viewer-footer', true).first();
28671 this.footerEl.setVisibilityMode(Roo.Element.DISPLAY);
28673 this.downloadBtn = this.el.select('.roo-document-viewer-download', true).first();
28674 this.downloadBtn.setVisibilityMode(Roo.Element.DISPLAY);
28676 this.trashBtn = this.el.select('.roo-document-viewer-trash', true).first();
28677 this.trashBtn.setVisibilityMode(Roo.Element.DISPLAY);
28679 this.bodyEl.on('click', this.onClick, this);
28680 this.downloadBtn.on('click', this.onDownload, this);
28681 this.trashBtn.on('click', this.onTrash, this);
28683 this.downloadBtn.hide();
28684 this.trashBtn.hide();
28686 if(this.showDownload){
28687 this.downloadBtn.show();
28690 if(this.showTrash){
28691 this.trashBtn.show();
28694 if(!this.showDownload && !this.showTrash) {
28695 this.footerEl.hide();
28700 initial : function()
28702 this.fireEvent('initial', this);
28706 onClick : function(e)
28708 e.preventDefault();
28710 this.fireEvent('click', this);
28713 onDownload : function(e)
28715 e.preventDefault();
28717 this.fireEvent('download', this);
28720 onTrash : function(e)
28722 e.preventDefault();
28724 this.fireEvent('trash', this);
28736 * @class Roo.bootstrap.NavProgressBar
28737 * @extends Roo.bootstrap.Component
28738 * Bootstrap NavProgressBar class
28741 * Create a new nav progress bar
28742 * @param {Object} config The config object
28745 Roo.bootstrap.NavProgressBar = function(config){
28746 Roo.bootstrap.NavProgressBar.superclass.constructor.call(this, config);
28748 this.bullets = this.bullets || [];
28750 // Roo.bootstrap.NavProgressBar.register(this);
28754 * Fires when the active item changes
28755 * @param {Roo.bootstrap.NavProgressBar} this
28756 * @param {Roo.bootstrap.NavProgressItem} selected The item selected
28757 * @param {Roo.bootstrap.NavProgressItem} prev The previously selected item
28764 Roo.extend(Roo.bootstrap.NavProgressBar, Roo.bootstrap.Component, {
28769 getAutoCreate : function()
28771 var cfg = Roo.apply({}, Roo.bootstrap.NavProgressBar.superclass.getAutoCreate.call(this));
28775 cls : 'roo-navigation-bar-group',
28779 cls : 'roo-navigation-top-bar'
28783 cls : 'roo-navigation-bullets-bar',
28787 cls : 'roo-navigation-bar'
28794 cls : 'roo-navigation-bottom-bar'
28804 initEvents: function()
28809 onRender : function(ct, position)
28811 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
28813 if(this.bullets.length){
28814 Roo.each(this.bullets, function(b){
28823 addItem : function(cfg)
28825 var item = new Roo.bootstrap.NavProgressItem(cfg);
28827 item.parentId = this.id;
28828 item.render(this.el.select('.roo-navigation-bar', true).first(), null);
28831 var top = new Roo.bootstrap.Element({
28833 cls : 'roo-navigation-bar-text'
28836 var bottom = new Roo.bootstrap.Element({
28838 cls : 'roo-navigation-bar-text'
28841 top.onRender(this.el.select('.roo-navigation-top-bar', true).first(), null);
28842 bottom.onRender(this.el.select('.roo-navigation-bottom-bar', true).first(), null);
28844 var topText = new Roo.bootstrap.Element({
28846 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? cfg.html : ''
28849 var bottomText = new Roo.bootstrap.Element({
28851 html : (typeof(cfg.position) != 'undefined' && cfg.position == 'top') ? '' : cfg.html
28854 topText.onRender(top.el, null);
28855 bottomText.onRender(bottom.el, null);
28858 item.bottomEl = bottom;
28861 this.barItems.push(item);
28866 getActive : function()
28868 var active = false;
28870 Roo.each(this.barItems, function(v){
28872 if (!v.isActive()) {
28884 setActiveItem : function(item)
28888 Roo.each(this.barItems, function(v){
28889 if (v.rid == item.rid) {
28893 if (v.isActive()) {
28894 v.setActive(false);
28899 item.setActive(true);
28901 this.fireEvent('changed', this, item, prev);
28904 getBarItem: function(rid)
28908 Roo.each(this.barItems, function(e) {
28909 if (e.rid != rid) {
28920 indexOfItem : function(item)
28924 Roo.each(this.barItems, function(v, i){
28926 if (v.rid != item.rid) {
28937 setActiveNext : function()
28939 var i = this.indexOfItem(this.getActive());
28941 if (i > this.barItems.length) {
28945 this.setActiveItem(this.barItems[i+1]);
28948 setActivePrev : function()
28950 var i = this.indexOfItem(this.getActive());
28956 this.setActiveItem(this.barItems[i-1]);
28959 format : function()
28961 if(!this.barItems.length){
28965 var width = 100 / this.barItems.length;
28967 Roo.each(this.barItems, function(i){
28968 i.el.setStyle('width', width + '%');
28969 i.topEl.el.setStyle('width', width + '%');
28970 i.bottomEl.el.setStyle('width', width + '%');
28979 * Nav Progress Item
28984 * @class Roo.bootstrap.NavProgressItem
28985 * @extends Roo.bootstrap.Component
28986 * Bootstrap NavProgressItem class
28987 * @cfg {String} rid the reference id
28988 * @cfg {Boolean} active (true|false) Is item active default false
28989 * @cfg {Boolean} disabled (true|false) Is item active default false
28990 * @cfg {String} html
28991 * @cfg {String} position (top|bottom) text position default bottom
28992 * @cfg {String} icon show icon instead of number
28995 * Create a new NavProgressItem
28996 * @param {Object} config The config object
28998 Roo.bootstrap.NavProgressItem = function(config){
28999 Roo.bootstrap.NavProgressItem.superclass.constructor.call(this, config);
29004 * The raw click event for the entire grid.
29005 * @param {Roo.bootstrap.NavProgressItem} this
29006 * @param {Roo.EventObject} e
29013 Roo.extend(Roo.bootstrap.NavProgressItem, Roo.bootstrap.Component, {
29019 position : 'bottom',
29022 getAutoCreate : function()
29024 var iconCls = 'roo-navigation-bar-item-icon';
29026 iconCls += ((this.icon) ? (' ' + this.icon) : (' step-number')) ;
29030 cls: 'roo-navigation-bar-item',
29040 cfg.cls += ' active';
29043 cfg.cls += ' disabled';
29049 disable : function()
29051 this.setDisabled(true);
29054 enable : function()
29056 this.setDisabled(false);
29059 initEvents: function()
29061 this.iconEl = this.el.select('.roo-navigation-bar-item-icon', true).first();
29063 this.iconEl.on('click', this.onClick, this);
29066 onClick : function(e)
29068 e.preventDefault();
29074 if(this.fireEvent('click', this, e) === false){
29078 this.parent().setActiveItem(this);
29081 isActive: function ()
29083 return this.active;
29086 setActive : function(state)
29088 if(this.active == state){
29092 this.active = state;
29095 this.el.addClass('active');
29099 this.el.removeClass('active');
29104 setDisabled : function(state)
29106 if(this.disabled == state){
29110 this.disabled = state;
29113 this.el.addClass('disabled');
29117 this.el.removeClass('disabled');
29120 tooltipEl : function()
29122 return this.el.select('.roo-navigation-bar-item-icon', true).first();;
29135 * @class Roo.bootstrap.FieldLabel
29136 * @extends Roo.bootstrap.Component
29137 * Bootstrap FieldLabel class
29138 * @cfg {String} html contents of the element
29139 * @cfg {String} tag tag of the element default label
29140 * @cfg {String} cls class of the element
29141 * @cfg {String} target label target
29142 * @cfg {Boolean} allowBlank (true|false) target allowBlank default true
29143 * @cfg {String} invalidClass default "text-danger fa fa-lg fa-exclamation-triangle"
29144 * @cfg {String} validClass default "text-success fa fa-lg fa-check"
29145 * @cfg {String} iconTooltip default "This field is required"
29148 * Create a new FieldLabel
29149 * @param {Object} config The config object
29152 Roo.bootstrap.FieldLabel = function(config){
29153 Roo.bootstrap.Element.superclass.constructor.call(this, config);
29158 * Fires after the field has been marked as invalid.
29159 * @param {Roo.form.FieldLabel} this
29160 * @param {String} msg The validation message
29165 * Fires after the field has been validated with no errors.
29166 * @param {Roo.form.FieldLabel} this
29172 Roo.extend(Roo.bootstrap.FieldLabel, Roo.bootstrap.Component, {
29179 invalidClass : 'text-danger fa fa-lg fa-exclamation-triangle',
29180 validClass : 'text-success fa fa-lg fa-check',
29181 iconTooltip : 'This field is required',
29183 getAutoCreate : function(){
29187 cls : 'roo-bootstrap-field-label ' + this.cls,
29193 tooltip : this.iconTooltip
29205 initEvents: function()
29207 Roo.bootstrap.Element.superclass.initEvents.call(this);
29209 this.iconEl = this.el.select('i', true).first();
29211 this.iconEl.setVisibilityMode(Roo.Element.DISPLAY).hide();
29213 Roo.bootstrap.FieldLabel.register(this);
29217 * Mark this field as valid
29219 markValid : function()
29221 this.iconEl.show();
29223 this.iconEl.removeClass(this.invalidClass);
29225 this.iconEl.addClass(this.validClass);
29227 this.fireEvent('valid', this);
29231 * Mark this field as invalid
29232 * @param {String} msg The validation message
29234 markInvalid : function(msg)
29236 this.iconEl.show();
29238 this.iconEl.removeClass(this.validClass);
29240 this.iconEl.addClass(this.invalidClass);
29242 this.fireEvent('invalid', this, msg);
29248 Roo.apply(Roo.bootstrap.FieldLabel, {
29253 * register a FieldLabel Group
29254 * @param {Roo.bootstrap.FieldLabel} the FieldLabel to add
29256 register : function(label)
29258 if(this.groups.hasOwnProperty(label.target)){
29262 this.groups[label.target] = label;
29266 * fetch a FieldLabel Group based on the target
29267 * @param {string} target
29268 * @returns {Roo.bootstrap.FieldLabel} the CheckBox group
29270 get: function(target) {
29271 if (typeof(this.groups[target]) == 'undefined') {
29275 return this.groups[target] ;
29284 * page DateSplitField.
29290 * @class Roo.bootstrap.DateSplitField
29291 * @extends Roo.bootstrap.Component
29292 * Bootstrap DateSplitField class
29293 * @cfg {string} fieldLabel - the label associated
29294 * @cfg {Number} labelWidth set the width of label (0-12)
29295 * @cfg {String} labelAlign (top|left)
29296 * @cfg {Boolean} dayAllowBlank (true|false) default false
29297 * @cfg {Boolean} monthAllowBlank (true|false) default false
29298 * @cfg {Boolean} yearAllowBlank (true|false) default false
29299 * @cfg {string} dayPlaceholder
29300 * @cfg {string} monthPlaceholder
29301 * @cfg {string} yearPlaceholder
29302 * @cfg {string} dayFormat default 'd'
29303 * @cfg {string} monthFormat default 'm'
29304 * @cfg {string} yearFormat default 'Y'
29305 * @cfg {Number} labellg set the width of label (1-12)
29306 * @cfg {Number} labelmd set the width of label (1-12)
29307 * @cfg {Number} labelsm set the width of label (1-12)
29308 * @cfg {Number} labelxs set the width of label (1-12)
29312 * Create a new DateSplitField
29313 * @param {Object} config The config object
29316 Roo.bootstrap.DateSplitField = function(config){
29317 Roo.bootstrap.DateSplitField.superclass.constructor.call(this, config);
29323 * getting the data of years
29324 * @param {Roo.bootstrap.DateSplitField} this
29325 * @param {Object} years
29330 * getting the data of days
29331 * @param {Roo.bootstrap.DateSplitField} this
29332 * @param {Object} days
29337 * Fires after the field has been marked as invalid.
29338 * @param {Roo.form.Field} this
29339 * @param {String} msg The validation message
29344 * Fires after the field has been validated with no errors.
29345 * @param {Roo.form.Field} this
29351 Roo.extend(Roo.bootstrap.DateSplitField, Roo.bootstrap.Component, {
29354 labelAlign : 'top',
29356 dayAllowBlank : false,
29357 monthAllowBlank : false,
29358 yearAllowBlank : false,
29359 dayPlaceholder : '',
29360 monthPlaceholder : '',
29361 yearPlaceholder : '',
29365 isFormField : true,
29371 getAutoCreate : function()
29375 cls : 'row roo-date-split-field-group',
29380 cls : 'form-hidden-field roo-date-split-field-group-value',
29386 var labelCls = 'col-md-12';
29387 var contentCls = 'col-md-4';
29389 if(this.fieldLabel){
29393 cls : 'column roo-date-split-field-label col-md-' + ((this.labelAlign == 'top') ? '12' : this.labelWidth),
29397 html : this.fieldLabel
29402 if(this.labelAlign == 'left'){
29404 if(this.labelWidth > 12){
29405 label.style = "width: " + this.labelWidth + 'px';
29408 if(this.labelWidth < 13 && this.labelmd == 0){
29409 this.labelmd = this.labelWidth;
29412 if(this.labellg > 0){
29413 labelCls = ' col-lg-' + this.labellg;
29414 contentCls = ' col-lg-' + ((12 - this.labellg) / 3);
29417 if(this.labelmd > 0){
29418 labelCls = ' col-md-' + this.labelmd;
29419 contentCls = ' col-md-' + ((12 - this.labelmd) / 3);
29422 if(this.labelsm > 0){
29423 labelCls = ' col-sm-' + this.labelsm;
29424 contentCls = ' col-sm-' + ((12 - this.labelsm) / 3);
29427 if(this.labelxs > 0){
29428 labelCls = ' col-xs-' + this.labelxs;
29429 contentCls = ' col-xs-' + ((12 - this.labelxs) / 3);
29433 label.cls += ' ' + labelCls;
29435 cfg.cn.push(label);
29438 Roo.each(['day', 'month', 'year'], function(t){
29441 cls : 'column roo-date-split-field-' + t + ' ' + contentCls
29448 inputEl: function ()
29450 return this.el.select('.roo-date-split-field-group-value', true).first();
29453 onRender : function(ct, position)
29457 Roo.bootstrap.NavProgressBar.superclass.onRender.call(this, ct, position);
29459 this.inputEl = this.el.select('.roo-date-split-field-group-value', true).first();
29461 this.dayField = new Roo.bootstrap.ComboBox({
29462 allowBlank : this.dayAllowBlank,
29463 alwaysQuery : true,
29464 displayField : 'value',
29467 forceSelection : true,
29469 placeholder : this.dayPlaceholder,
29470 selectOnFocus : true,
29471 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
29472 triggerAction : 'all',
29474 valueField : 'value',
29475 store : new Roo.data.SimpleStore({
29476 data : (function() {
29478 _this.fireEvent('days', _this, days);
29481 fields : [ 'value' ]
29484 select : function (_self, record, index)
29486 _this.setValue(_this.getValue());
29491 this.dayField.render(this.el.select('.roo-date-split-field-day', true).first(), null);
29493 this.monthField = new Roo.bootstrap.MonthField({
29494 after : '<i class=\"fa fa-calendar\"></i>',
29495 allowBlank : this.monthAllowBlank,
29496 placeholder : this.monthPlaceholder,
29499 render : function (_self)
29501 this.el.select('span.input-group-addon', true).first().on('click', function(e){
29502 e.preventDefault();
29506 select : function (_self, oldvalue, newvalue)
29508 _this.setValue(_this.getValue());
29513 this.monthField.render(this.el.select('.roo-date-split-field-month', true).first(), null);
29515 this.yearField = new Roo.bootstrap.ComboBox({
29516 allowBlank : this.yearAllowBlank,
29517 alwaysQuery : true,
29518 displayField : 'value',
29521 forceSelection : true,
29523 placeholder : this.yearPlaceholder,
29524 selectOnFocus : true,
29525 tpl : '<div class="roo-select2-result"><b>{value}</b></div>',
29526 triggerAction : 'all',
29528 valueField : 'value',
29529 store : new Roo.data.SimpleStore({
29530 data : (function() {
29532 _this.fireEvent('years', _this, years);
29535 fields : [ 'value' ]
29538 select : function (_self, record, index)
29540 _this.setValue(_this.getValue());
29545 this.yearField.render(this.el.select('.roo-date-split-field-year', true).first(), null);
29548 setValue : function(v, format)
29550 this.inputEl.dom.value = v;
29552 var f = format || (this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat);
29554 var d = Date.parseDate(v, f);
29561 this.setDay(d.format(this.dayFormat));
29562 this.setMonth(d.format(this.monthFormat));
29563 this.setYear(d.format(this.yearFormat));
29570 setDay : function(v)
29572 this.dayField.setValue(v);
29573 this.inputEl.dom.value = this.getValue();
29578 setMonth : function(v)
29580 this.monthField.setValue(v, true);
29581 this.inputEl.dom.value = this.getValue();
29586 setYear : function(v)
29588 this.yearField.setValue(v);
29589 this.inputEl.dom.value = this.getValue();
29594 getDay : function()
29596 return this.dayField.getValue();
29599 getMonth : function()
29601 return this.monthField.getValue();
29604 getYear : function()
29606 return this.yearField.getValue();
29609 getValue : function()
29611 var f = this.yearFormat + '-' + this.monthFormat + '-' + this.dayFormat;
29613 var date = this.yearField.getValue() + '-' + this.monthField.getValue() + '-' + this.dayField.getValue();
29623 this.inputEl.dom.value = '';
29628 validate : function()
29630 var d = this.dayField.validate();
29631 var m = this.monthField.validate();
29632 var y = this.yearField.validate();
29637 (!this.dayAllowBlank && !d) ||
29638 (!this.monthAllowBlank && !m) ||
29639 (!this.yearAllowBlank && !y)
29644 if(this.dayAllowBlank && this.monthAllowBlank && this.yearAllowBlank){
29653 this.markInvalid();
29658 markValid : function()
29661 var label = this.el.select('label', true).first();
29662 var icon = this.el.select('i.fa-star', true).first();
29668 this.fireEvent('valid', this);
29672 * Mark this field as invalid
29673 * @param {String} msg The validation message
29675 markInvalid : function(msg)
29678 var label = this.el.select('label', true).first();
29679 var icon = this.el.select('i.fa-star', true).first();
29681 if(label && !icon){
29682 this.el.select('.roo-date-split-field-label', true).createChild({
29684 cls : 'text-danger fa fa-lg fa-star',
29685 tooltip : 'This field is required',
29686 style : 'margin-right:5px;'
29690 this.fireEvent('invalid', this, msg);
29693 clearInvalid : function()
29695 var label = this.el.select('label', true).first();
29696 var icon = this.el.select('i.fa-star', true).first();
29702 this.fireEvent('valid', this);
29705 getName: function()
29715 * http://masonry.desandro.com
29717 * The idea is to render all the bricks based on vertical width...
29719 * The original code extends 'outlayer' - we might need to use that....
29725 * @class Roo.bootstrap.LayoutMasonry
29726 * @extends Roo.bootstrap.Component
29727 * Bootstrap Layout Masonry class
29730 * Create a new Element
29731 * @param {Object} config The config object
29734 Roo.bootstrap.LayoutMasonry = function(config){
29735 Roo.bootstrap.LayoutMasonry.superclass.constructor.call(this, config);
29743 * Fire after layout the items
29744 * @param {Roo.bootstrap.LayoutMasonry} this
29745 * @param {Roo.EventObject} e
29752 Roo.extend(Roo.bootstrap.LayoutMasonry, Roo.bootstrap.Component, {
29755 * @cfg {Boolean} isLayoutInstant = no animation?
29757 isLayoutInstant : false, // needed?
29760 * @cfg {Number} boxWidth width of the columns
29765 * @cfg {Number} boxHeight - 0 for square, or fix it at a certian height
29770 * @cfg {Number} padWidth padding below box..
29775 * @cfg {Number} gutter gutter width..
29780 * @cfg {Number} maxCols maximum number of columns
29786 * @cfg {Boolean} isAutoInitial defalut true
29788 isAutoInitial : true,
29793 * @cfg {Boolean} isHorizontal defalut false
29795 isHorizontal : false,
29797 currentSize : null,
29803 bricks: null, //CompositeElement
29807 _isLayoutInited : false,
29809 // isAlternative : false, // only use for vertical layout...
29812 * @cfg {Number} alternativePadWidth padding below box..
29814 alternativePadWidth : 50,
29816 getAutoCreate : function(){
29820 cls: 'blog-masonary-wrapper ' + this.cls,
29822 cls : 'mas-boxes masonary'
29829 getChildContainer: function( )
29831 if (this.boxesEl) {
29832 return this.boxesEl;
29835 this.boxesEl = this.el.select('.mas-boxes').first();
29837 return this.boxesEl;
29841 initEvents : function()
29845 if(this.isAutoInitial){
29846 Roo.log('hook children rendered');
29847 this.on('childrenrendered', function() {
29848 Roo.log('children rendered');
29854 initial : function()
29856 this.currentSize = this.el.getBox(true);
29858 Roo.EventManager.onWindowResize(this.resize, this);
29860 if(!this.isAutoInitial){
29868 //this.layout.defer(500,this);
29872 addItem : function(cfg)
29874 Roo.log('adding item!!!!!!!!!!!!!!!!!!!!!!!!!!');
29875 var brick = Roo.factory(cfg);
29876 brick.render(this.getChildContainer());
29879 resize : function()
29881 var cs = this.el.getBox(true);
29884 this.currentSize.width == cs.width &&
29885 this.currentSize.x == cs.x &&
29886 this.currentSize.height == cs.height &&
29887 this.currentSize.y == cs.y
29889 Roo.log("no change in with or X or Y");
29893 this.currentSize = cs;
29899 layout : function()
29901 this._resetLayout();
29903 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
29905 this.layoutItems( isInstant );
29907 this._isLayoutInited = true;
29909 this.fireEvent('layout', this);
29913 _resetLayout : function()
29915 if(this.isHorizontal){
29916 this.horizontalMeasureColumns();
29920 this.verticalMeasureColumns();
29924 verticalMeasureColumns : function()
29926 this.getContainerWidth();
29928 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
29929 // this.colWidth = Math.floor(this.containerWidth * 0.8);
29933 var boxWidth = this.boxWidth + this.padWidth;
29935 if(this.containerWidth < this.boxWidth){
29936 boxWidth = this.containerWidth
29939 var containerWidth = this.containerWidth;
29941 var cols = Math.floor(containerWidth / boxWidth);
29943 this.cols = Math.max( cols, 1 );
29945 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
29947 var totalBoxWidth = this.cols * boxWidth - this.padWidth;
29949 var avail = Math.floor((containerWidth - totalBoxWidth) / this.cols);
29951 this.colWidth = boxWidth + avail - this.padWidth;
29953 this.unitWidth = Math.floor((this.colWidth - (this.gutter * 2)) / 3);
29954 this.unitHeight = this.boxHeight > 0 ? this.boxHeight : this.unitWidth;
29957 horizontalMeasureColumns : function()
29959 this.getContainerWidth();
29961 var boxWidth = this.boxWidth;
29963 if(this.containerWidth < boxWidth){
29964 boxWidth = this.containerWidth;
29967 this.unitWidth = Math.floor((boxWidth - (this.gutter * 2)) / 3);
29969 this.el.setHeight(boxWidth);
29973 getContainerWidth : function()
29975 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
29978 layoutItems : function( isInstant )
29980 Roo.log(this.bricks);
29982 var items = Roo.apply([], this.bricks);
29984 if(this.isHorizontal){
29985 this._horizontalLayoutItems( items , isInstant );
29989 // if(Roo.lib.Dom.getViewWidth() < 768 && this.isAlternative){
29990 // this._verticalAlternativeLayoutItems( items , isInstant );
29994 this._verticalLayoutItems( items , isInstant );
29998 _verticalLayoutItems : function ( items , isInstant)
30000 if ( !items || !items.length ) {
30005 ['xs', 'xs', 'xs', 'tall'],
30006 ['xs', 'xs', 'tall'],
30007 ['xs', 'xs', 'sm'],
30008 ['xs', 'xs', 'xs'],
30014 ['sm', 'xs', 'xs'],
30018 ['tall', 'xs', 'xs', 'xs'],
30019 ['tall', 'xs', 'xs'],
30031 Roo.each(items, function(item, k){
30033 switch (item.size) {
30034 // these layouts take up a full box,
30045 boxes.push([item]);
30068 var filterPattern = function(box, length)
30076 var pattern = box.slice(0, length);
30080 Roo.each(pattern, function(i){
30081 format.push(i.size);
30084 Roo.each(standard, function(s){
30086 if(String(s) != String(format)){
30095 if(!match && length == 1){
30100 filterPattern(box, length - 1);
30104 queue.push(pattern);
30106 box = box.slice(length, box.length);
30108 filterPattern(box, 4);
30114 Roo.each(boxes, function(box, k){
30120 if(box.length == 1){
30125 filterPattern(box, 4);
30129 this._processVerticalLayoutQueue( queue, isInstant );
30133 // _verticalAlternativeLayoutItems : function( items , isInstant )
30135 // if ( !items || !items.length ) {
30139 // this._processVerticalAlternativeLayoutQueue( items, isInstant );
30143 _horizontalLayoutItems : function ( items , isInstant)
30145 if ( !items || !items.length || items.length < 3) {
30151 var eItems = items.slice(0, 3);
30153 items = items.slice(3, items.length);
30156 ['xs', 'xs', 'xs', 'wide'],
30157 ['xs', 'xs', 'wide'],
30158 ['xs', 'xs', 'sm'],
30159 ['xs', 'xs', 'xs'],
30165 ['sm', 'xs', 'xs'],
30169 ['wide', 'xs', 'xs', 'xs'],
30170 ['wide', 'xs', 'xs'],
30183 Roo.each(items, function(item, k){
30185 switch (item.size) {
30196 boxes.push([item]);
30220 var filterPattern = function(box, length)
30228 var pattern = box.slice(0, length);
30232 Roo.each(pattern, function(i){
30233 format.push(i.size);
30236 Roo.each(standard, function(s){
30238 if(String(s) != String(format)){
30247 if(!match && length == 1){
30252 filterPattern(box, length - 1);
30256 queue.push(pattern);
30258 box = box.slice(length, box.length);
30260 filterPattern(box, 4);
30266 Roo.each(boxes, function(box, k){
30272 if(box.length == 1){
30277 filterPattern(box, 4);
30284 var pos = this.el.getBox(true);
30288 var maxX = pos.right - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
30290 var hit_end = false;
30292 Roo.each(queue, function(box){
30296 Roo.each(box, function(b){
30298 b.el.setVisibilityMode(Roo.Element.DISPLAY);
30308 Roo.each(box, function(b){
30310 b.el.setVisibilityMode(Roo.Element.DISPLAY);
30313 mx = Math.max(mx, b.x);
30317 maxX = maxX - this.unitWidth * mx - this.gutter * (mx - 1) - this.padWidth;
30321 Roo.each(box, function(b){
30323 b.el.setVisibilityMode(Roo.Element.DISPLAY);
30337 this._processHorizontalLayoutQueue( prune, eItems, isInstant );
30340 /** Sets position of item in DOM
30341 * @param {Element} item
30342 * @param {Number} x - horizontal position
30343 * @param {Number} y - vertical position
30344 * @param {Boolean} isInstant - disables transitions
30346 _processVerticalLayoutQueue : function( queue, isInstant )
30348 var pos = this.el.getBox(true);
30353 for (var i = 0; i < this.cols; i++){
30357 Roo.each(queue, function(box, k){
30359 var col = k % this.cols;
30361 Roo.each(box, function(b,kk){
30363 b.el.position('absolute');
30365 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
30366 var height = Math.floor(this.unitHeight * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
30368 if(b.size == 'md-left' || b.size == 'md-right'){
30369 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
30370 height = Math.floor(this.unitHeight * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
30373 b.el.setWidth(width);
30374 b.el.setHeight(height);
30376 b.el.select('iframe',true).setSize(width,height);
30380 for (var i = 0; i < this.cols; i++){
30382 if(maxY[i] < maxY[col]){
30387 col = Math.min(col, i);
30391 x = pos.x + col * (this.colWidth + this.padWidth);
30395 var positions = [];
30397 switch (box.length){
30399 positions = this.getVerticalOneBoxColPositions(x, y, box);
30402 positions = this.getVerticalTwoBoxColPositions(x, y, box);
30405 positions = this.getVerticalThreeBoxColPositions(x, y, box);
30408 positions = this.getVerticalFourBoxColPositions(x, y, box);
30414 Roo.each(box, function(b,kk){
30416 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
30418 var sz = b.el.getSize();
30420 maxY[col] = Math.max(maxY[col], positions[kk].y + sz.height + this.padWidth);
30428 for (var i = 0; i < this.cols; i++){
30429 mY = Math.max(mY, maxY[i]);
30432 this.el.setHeight(mY - pos.y);
30436 // _processVerticalAlternativeLayoutQueue : function( items, isInstant )
30438 // var pos = this.el.getBox(true);
30441 // var maxX = pos.right;
30443 // var maxHeight = 0;
30445 // Roo.each(items, function(item, k){
30449 // item.el.position('absolute');
30451 // var width = Math.floor(this.colWidth + item.el.getPadding('lr'));
30453 // item.el.setWidth(width);
30455 // var height = Math.floor(this.colWidth * item.y / item.x + item.el.getPadding('tb'));
30457 // item.el.setHeight(height);
30460 // item.el.setXY([x, y], isInstant ? false : true);
30462 // item.el.setXY([maxX - width, y], isInstant ? false : true);
30465 // y = y + height + this.alternativePadWidth;
30467 // maxHeight = maxHeight + height + this.alternativePadWidth;
30471 // this.el.setHeight(maxHeight);
30475 _processHorizontalLayoutQueue : function( queue, eItems, isInstant )
30477 var pos = this.el.getBox(true);
30482 var maxX = pos.right;
30484 this._processHorizontalEndItem(eItems, maxX, minX, minY, isInstant);
30486 var maxX = maxX - this.unitWidth * 3 - this.gutter * 2 - this.padWidth;
30488 Roo.each(queue, function(box, k){
30490 Roo.each(box, function(b, kk){
30492 b.el.position('absolute');
30494 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
30495 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
30497 if(b.size == 'md-left' || b.size == 'md-right'){
30498 width = Math.floor(this.unitWidth * (b.x - 1) + (this.gutter * (b.x - 2)) + b.el.getPadding('lr'));
30499 height = Math.floor(this.unitWidth * (b.y - 1) + (this.gutter * (b.y - 2)) + b.el.getPadding('tb'));
30502 b.el.setWidth(width);
30503 b.el.setHeight(height);
30511 var positions = [];
30513 switch (box.length){
30515 positions = this.getHorizontalOneBoxColPositions(maxX, minY, box);
30518 positions = this.getHorizontalTwoBoxColPositions(maxX, minY, box);
30521 positions = this.getHorizontalThreeBoxColPositions(maxX, minY, box);
30524 positions = this.getHorizontalFourBoxColPositions(maxX, minY, box);
30530 Roo.each(box, function(b,kk){
30532 b.el.setXY([positions[kk].x, positions[kk].y], isInstant ? false : true);
30534 maxX = Math.min(maxX, positions[kk].x - this.padWidth);
30542 _processHorizontalEndItem : function(eItems, maxX, minX, minY, isInstant)
30544 Roo.each(eItems, function(b,k){
30546 b.size = (k == 0) ? 'sm' : 'xs';
30547 b.x = (k == 0) ? 2 : 1;
30548 b.y = (k == 0) ? 2 : 1;
30550 b.el.position('absolute');
30552 var width = Math.floor(this.unitWidth * b.x + (this.gutter * (b.x - 1)) + b.el.getPadding('lr'));
30554 b.el.setWidth(width);
30556 var height = Math.floor(this.unitWidth * b.y + (this.gutter * (b.y - 1)) + b.el.getPadding('tb'));
30558 b.el.setHeight(height);
30562 var positions = [];
30565 x : maxX - this.unitWidth * 2 - this.gutter,
30570 x : maxX - this.unitWidth,
30571 y : minY + (this.unitWidth + this.gutter) * 2
30575 x : maxX - this.unitWidth * 3 - this.gutter * 2,
30579 Roo.each(eItems, function(b,k){
30581 b.el.setXY([positions[k].x, positions[k].y], isInstant ? false : true);
30587 getVerticalOneBoxColPositions : function(x, y, box)
30591 var rand = Math.floor(Math.random() * ((4 - box[0].x)));
30593 if(box[0].size == 'md-left'){
30597 if(box[0].size == 'md-right'){
30602 x : x + (this.unitWidth + this.gutter) * rand,
30609 getVerticalTwoBoxColPositions : function(x, y, box)
30613 if(box[0].size == 'xs'){
30617 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[1].y))
30621 x : x + (this.unitWidth + this.gutter) * (3 - box[1].x),
30635 x : x + (this.unitWidth + this.gutter) * 2,
30636 y : y + ((this.unitHeight + this.gutter) * Math.floor(Math.random() * box[0].y))
30643 getVerticalThreeBoxColPositions : function(x, y, box)
30647 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
30655 x : x + (this.unitWidth + this.gutter) * 1,
30660 x : x + (this.unitWidth + this.gutter) * 2,
30668 if(box[0].size == 'xs' && box[1].size == 'xs'){
30677 y : y + ((this.unitHeight + this.gutter) * (box[2].y - 1))
30681 x : x + (this.unitWidth + this.gutter) * 1,
30695 x : x + (this.unitWidth + this.gutter) * 2,
30700 x : x + (this.unitWidth + this.gutter) * 2,
30701 y : y + (this.unitHeight + this.gutter) * (box[0].y - 1)
30708 getVerticalFourBoxColPositions : function(x, y, box)
30712 if(box[0].size == 'xs'){
30721 y : y + (this.unitHeight + this.gutter) * 1
30726 y : y + (this.unitHeight + this.gutter) * 2
30730 x : x + (this.unitWidth + this.gutter) * 1,
30744 x : x + (this.unitWidth + this.gutter) * 2,
30749 x : x + (this.unitHeightunitWidth + this.gutter) * 2,
30750 y : y + (this.unitHeight + this.gutter) * 1
30754 x : x + (this.unitWidth + this.gutter) * 2,
30755 y : y + (this.unitWidth + this.gutter) * 2
30762 getHorizontalOneBoxColPositions : function(maxX, minY, box)
30766 if(box[0].size == 'md-left'){
30768 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
30775 if(box[0].size == 'md-right'){
30777 x : maxX - this.unitWidth * (box[0].x - 1) - this.gutter * (box[0].x - 2),
30778 y : minY + (this.unitWidth + this.gutter) * 1
30784 var rand = Math.floor(Math.random() * (4 - box[0].y));
30787 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
30788 y : minY + (this.unitWidth + this.gutter) * rand
30795 getHorizontalTwoBoxColPositions : function(maxX, minY, box)
30799 if(box[0].size == 'xs'){
30802 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
30807 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
30808 y : minY + (this.unitWidth + this.gutter) * (3 - box[1].y)
30816 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
30821 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
30822 y : minY + (this.unitWidth + this.gutter) * 2
30829 getHorizontalThreeBoxColPositions : function(maxX, minY, box)
30833 if(box[0].size == 'xs' && box[1].size == 'xs' && box[2].size == 'xs'){
30836 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
30841 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
30842 y : minY + (this.unitWidth + this.gutter) * 1
30846 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
30847 y : minY + (this.unitWidth + this.gutter) * 2
30854 if(box[0].size == 'xs' && box[1].size == 'xs'){
30857 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
30862 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
30867 x : maxX - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
30868 y : minY + (this.unitWidth + this.gutter) * 1
30876 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
30881 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
30882 y : minY + (this.unitWidth + this.gutter) * 2
30886 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
30887 y : minY + (this.unitWidth + this.gutter) * 2
30894 getHorizontalFourBoxColPositions : function(maxX, minY, box)
30898 if(box[0].size == 'xs'){
30901 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
30906 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1) - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
30911 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),
30916 x : maxX - this.unitWidth * box[3].x - this.gutter * (box[3].x - 1),
30917 y : minY + (this.unitWidth + this.gutter) * 1
30925 x : maxX - this.unitWidth * box[0].x - this.gutter * (box[0].x - 1),
30930 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1),
30931 y : minY + (this.unitWidth + this.gutter) * 2
30935 x : maxX - this.unitWidth * box[1].x - this.gutter * (box[1].x - 1) - this.unitWidth * box[2].x - this.gutter * (box[2].x - 1),
30936 y : minY + (this.unitWidth + this.gutter) * 2
30940 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),
30941 y : minY + (this.unitWidth + this.gutter) * 2
30955 * http://masonry.desandro.com
30957 * The idea is to render all the bricks based on vertical width...
30959 * The original code extends 'outlayer' - we might need to use that....
30965 * @class Roo.bootstrap.LayoutMasonryAuto
30966 * @extends Roo.bootstrap.Component
30967 * Bootstrap Layout Masonry class
30970 * Create a new Element
30971 * @param {Object} config The config object
30974 Roo.bootstrap.LayoutMasonryAuto = function(config){
30975 Roo.bootstrap.LayoutMasonryAuto.superclass.constructor.call(this, config);
30978 Roo.extend(Roo.bootstrap.LayoutMasonryAuto, Roo.bootstrap.Component, {
30981 * @cfg {Boolean} isFitWidth - resize the width..
30983 isFitWidth : false, // options..
30985 * @cfg {Boolean} isOriginLeft = left align?
30987 isOriginLeft : true,
30989 * @cfg {Boolean} isOriginTop = top align?
30991 isOriginTop : false,
30993 * @cfg {Boolean} isLayoutInstant = no animation?
30995 isLayoutInstant : false, // needed?
30997 * @cfg {Boolean} isResizingContainer = not sure if this is used..
30999 isResizingContainer : true,
31001 * @cfg {Number} columnWidth width of the columns
31007 * @cfg {Number} maxCols maximum number of columns
31012 * @cfg {Number} padHeight padding below box..
31018 * @cfg {Boolean} isAutoInitial defalut true
31021 isAutoInitial : true,
31027 initialColumnWidth : 0,
31028 currentSize : null,
31030 colYs : null, // array.
31037 bricks: null, //CompositeElement
31038 cols : 0, // array?
31039 // element : null, // wrapped now this.el
31040 _isLayoutInited : null,
31043 getAutoCreate : function(){
31047 cls: 'blog-masonary-wrapper ' + this.cls,
31049 cls : 'mas-boxes masonary'
31056 getChildContainer: function( )
31058 if (this.boxesEl) {
31059 return this.boxesEl;
31062 this.boxesEl = this.el.select('.mas-boxes').first();
31064 return this.boxesEl;
31068 initEvents : function()
31072 if(this.isAutoInitial){
31073 Roo.log('hook children rendered');
31074 this.on('childrenrendered', function() {
31075 Roo.log('children rendered');
31082 initial : function()
31084 this.reloadItems();
31086 this.currentSize = this.el.getBox(true);
31088 /// was window resize... - let's see if this works..
31089 Roo.EventManager.onWindowResize(this.resize, this);
31091 if(!this.isAutoInitial){
31096 this.layout.defer(500,this);
31099 reloadItems: function()
31101 this.bricks = this.el.select('.masonry-brick', true);
31103 this.bricks.each(function(b) {
31104 //Roo.log(b.getSize());
31105 if (!b.attr('originalwidth')) {
31106 b.attr('originalwidth', b.getSize().width);
31111 Roo.log(this.bricks.elements.length);
31114 resize : function()
31117 var cs = this.el.getBox(true);
31119 if (this.currentSize.width == cs.width && this.currentSize.x == cs.x ) {
31120 Roo.log("no change in with or X");
31123 this.currentSize = cs;
31127 layout : function()
31130 this._resetLayout();
31131 //this._manageStamps();
31133 // don't animate first layout
31134 var isInstant = this.isLayoutInstant !== undefined ? this.isLayoutInstant : !this._isLayoutInited;
31135 this.layoutItems( isInstant );
31137 // flag for initalized
31138 this._isLayoutInited = true;
31141 layoutItems : function( isInstant )
31143 //var items = this._getItemsForLayout( this.items );
31144 // original code supports filtering layout items.. we just ignore it..
31146 this._layoutItems( this.bricks , isInstant );
31148 this._postLayout();
31150 _layoutItems : function ( items , isInstant)
31152 //this.fireEvent( 'layout', this, items );
31155 if ( !items || !items.elements.length ) {
31156 // no items, emit event with empty array
31161 items.each(function(item) {
31162 Roo.log("layout item");
31164 // get x/y object from method
31165 var position = this._getItemLayoutPosition( item );
31167 position.item = item;
31168 position.isInstant = isInstant; // || item.isLayoutInstant; << not set yet...
31169 queue.push( position );
31172 this._processLayoutQueue( queue );
31174 /** Sets position of item in DOM
31175 * @param {Element} item
31176 * @param {Number} x - horizontal position
31177 * @param {Number} y - vertical position
31178 * @param {Boolean} isInstant - disables transitions
31180 _processLayoutQueue : function( queue )
31182 for ( var i=0, len = queue.length; i < len; i++ ) {
31183 var obj = queue[i];
31184 obj.item.position('absolute');
31185 obj.item.setXY([obj.x,obj.y], obj.isInstant ? false : true);
31191 * Any logic you want to do after each layout,
31192 * i.e. size the container
31194 _postLayout : function()
31196 this.resizeContainer();
31199 resizeContainer : function()
31201 if ( !this.isResizingContainer ) {
31204 var size = this._getContainerSize();
31206 this.el.setSize(size.width,size.height);
31207 this.boxesEl.setSize(size.width,size.height);
31213 _resetLayout : function()
31215 //this.getSize(); // -- does not really do anything.. it probably applies left/right etc. to obuject but not used
31216 this.colWidth = this.el.getWidth();
31217 //this.gutter = this.el.getWidth();
31219 this.measureColumns();
31225 this.colYs.push( 0 );
31231 measureColumns : function()
31233 this.getContainerWidth();
31234 // if columnWidth is 0, default to outerWidth of first item
31235 if ( !this.columnWidth ) {
31236 var firstItem = this.bricks.first();
31237 Roo.log(firstItem);
31238 this.columnWidth = this.containerWidth;
31239 if (firstItem && firstItem.attr('originalwidth') ) {
31240 this.columnWidth = 1* (firstItem.attr('originalwidth') || firstItem.getWidth());
31242 // columnWidth fall back to item of first element
31243 Roo.log("set column width?");
31244 this.initialColumnWidth = this.columnWidth ;
31246 // if first elem has no width, default to size of container
31251 if (this.initialColumnWidth) {
31252 this.columnWidth = this.initialColumnWidth;
31257 // column width is fixed at the top - however if container width get's smaller we should
31260 // this bit calcs how man columns..
31262 var columnWidth = this.columnWidth += this.gutter;
31264 // calculate columns
31265 var containerWidth = this.containerWidth + this.gutter;
31267 var cols = (containerWidth - this.padWidth) / (columnWidth - this.padWidth);
31268 // fix rounding errors, typically with gutters
31269 var excess = columnWidth - containerWidth % columnWidth;
31272 // if overshoot is less than a pixel, round up, otherwise floor it
31273 var mathMethod = excess && excess < 1 ? 'round' : 'floor';
31274 cols = Math[ mathMethod ]( cols );
31275 this.cols = Math.max( cols, 1 );
31276 this.cols = this.maxCols > 0 ? Math.min( this.cols, this.maxCols ) : this.cols;
31278 // padding positioning..
31279 var totalColWidth = this.cols * this.columnWidth;
31280 var padavail = this.containerWidth - totalColWidth;
31281 // so for 2 columns - we need 3 'pads'
31283 var padNeeded = (1+this.cols) * this.padWidth;
31285 var padExtra = Math.floor((padavail - padNeeded) / this.cols);
31287 this.columnWidth += padExtra
31288 //this.padWidth = Math.floor(padavail / ( this.cols));
31290 // adjust colum width so that padding is fixed??
31292 // we have 3 columns ... total = width * 3
31293 // we have X left over... that should be used by
31295 //if (this.expandC) {
31303 getContainerWidth : function()
31305 /* // container is parent if fit width
31306 var container = this.isFitWidth ? this.element.parentNode : this.element;
31307 // check that this.size and size are there
31308 // IE8 triggers resize on body size change, so they might not be
31310 var size = getSize( container ); //FIXME
31311 this.containerWidth = size && size.innerWidth; //FIXME
31314 this.containerWidth = this.el.getBox(true).width; //maybe use getComputedWidth
31318 _getItemLayoutPosition : function( item ) // what is item?
31320 // we resize the item to our columnWidth..
31322 item.setWidth(this.columnWidth);
31323 item.autoBoxAdjust = false;
31325 var sz = item.getSize();
31327 // how many columns does this brick span
31328 var remainder = this.containerWidth % this.columnWidth;
31330 var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
31331 // round if off by 1 pixel, otherwise use ceil
31332 var colSpan = Math[ mathMethod ]( sz.width / this.columnWidth );
31333 colSpan = Math.min( colSpan, this.cols );
31335 // normally this should be '1' as we dont' currently allow multi width columns..
31337 var colGroup = this._getColGroup( colSpan );
31338 // get the minimum Y value from the columns
31339 var minimumY = Math.min.apply( Math, colGroup );
31340 Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
31342 var shortColIndex = colGroup.indexOf( minimumY ); // broken on ie8..?? probably...
31344 // position the brick
31346 x: this.currentSize.x + (this.padWidth /2) + ((this.columnWidth + this.padWidth )* shortColIndex),
31347 y: this.currentSize.y + minimumY + this.padHeight
31351 // apply setHeight to necessary columns
31352 var setHeight = minimumY + sz.height + this.padHeight;
31353 //Roo.log([ 'setHeight', minimumY, sz.height, setHeight ]);
31355 var setSpan = this.cols + 1 - colGroup.length;
31356 for ( var i = 0; i < setSpan; i++ ) {
31357 this.colYs[ shortColIndex + i ] = setHeight ;
31364 * @param {Number} colSpan - number of columns the element spans
31365 * @returns {Array} colGroup
31367 _getColGroup : function( colSpan )
31369 if ( colSpan < 2 ) {
31370 // if brick spans only one column, use all the column Ys
31375 // how many different places could this brick fit horizontally
31376 var groupCount = this.cols + 1 - colSpan;
31377 // for each group potential horizontal position
31378 for ( var i = 0; i < groupCount; i++ ) {
31379 // make an array of colY values for that one group
31380 var groupColYs = this.colYs.slice( i, i + colSpan );
31381 // and get the max value of the array
31382 colGroup[i] = Math.max.apply( Math, groupColYs );
31387 _manageStamp : function( stamp )
31389 var stampSize = stamp.getSize();
31390 var offset = stamp.getBox();
31391 // get the columns that this stamp affects
31392 var firstX = this.isOriginLeft ? offset.x : offset.right;
31393 var lastX = firstX + stampSize.width;
31394 var firstCol = Math.floor( firstX / this.columnWidth );
31395 firstCol = Math.max( 0, firstCol );
31397 var lastCol = Math.floor( lastX / this.columnWidth );
31398 // lastCol should not go over if multiple of columnWidth #425
31399 lastCol -= lastX % this.columnWidth ? 0 : 1;
31400 lastCol = Math.min( this.cols - 1, lastCol );
31402 // set colYs to bottom of the stamp
31403 var stampMaxY = ( this.isOriginTop ? offset.y : offset.bottom ) +
31406 for ( var i = firstCol; i <= lastCol; i++ ) {
31407 this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
31412 _getContainerSize : function()
31414 this.maxY = Math.max.apply( Math, this.colYs );
31419 if ( this.isFitWidth ) {
31420 size.width = this._getContainerFitWidth();
31426 _getContainerFitWidth : function()
31428 var unusedCols = 0;
31429 // count unused columns
31432 if ( this.colYs[i] !== 0 ) {
31437 // fit container to columns that have been used
31438 return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
31441 needsResizeLayout : function()
31443 var previousWidth = this.containerWidth;
31444 this.getContainerWidth();
31445 return previousWidth !== this.containerWidth;
31460 * @class Roo.bootstrap.MasonryBrick
31461 * @extends Roo.bootstrap.Component
31462 * Bootstrap MasonryBrick class
31465 * Create a new MasonryBrick
31466 * @param {Object} config The config object
31469 Roo.bootstrap.MasonryBrick = function(config){
31470 Roo.bootstrap.MasonryBrick.superclass.constructor.call(this, config);
31476 * When a MasonryBrick is clcik
31477 * @param {Roo.bootstrap.MasonryBrick} this
31478 * @param {Roo.EventObject} e
31484 Roo.extend(Roo.bootstrap.MasonryBrick, Roo.bootstrap.Component, {
31487 * @cfg {String} title
31491 * @cfg {String} html
31495 * @cfg {String} bgimage
31499 * @cfg {String} videourl
31503 * @cfg {String} cls
31507 * @cfg {String} href
31511 * @cfg {String} size (xs|sm|md|md-left|md-right|tall|wide)
31516 * @cfg {String} placetitle (center|bottom)
31521 * @cfg {Boolean} isFitContainer defalut true
31523 isFitContainer : true,
31526 * @cfg {Boolean} preventDefault defalut false
31528 preventDefault : false,
31531 * @cfg {Boolean} inverse defalut false
31533 maskInverse : false,
31535 getAutoCreate : function()
31537 if(!this.isFitContainer){
31538 return this.getSplitAutoCreate();
31541 var cls = 'masonry-brick masonry-brick-full';
31543 if(this.href.length){
31544 cls += ' masonry-brick-link';
31547 if(this.bgimage.length){
31548 cls += ' masonry-brick-image';
31551 if(this.maskInverse){
31552 cls += ' mask-inverse';
31555 if(!this.html.length && !this.maskInverse){
31556 cls += ' enable-mask';
31560 cls += ' masonry-' + this.size + '-brick';
31563 if(this.placetitle.length){
31565 switch (this.placetitle) {
31567 cls += ' masonry-center-title';
31570 cls += ' masonry-bottom-title';
31577 if(!this.html.length && !this.bgimage.length){
31578 cls += ' masonry-center-title';
31581 if(!this.html.length && this.bgimage.length){
31582 cls += ' masonry-bottom-title';
31587 cls += ' ' + this.cls;
31591 tag: (this.href.length) ? 'a' : 'div',
31596 cls: 'masonry-brick-paragraph',
31602 if(this.href.length){
31603 cfg.href = this.href;
31606 var cn = cfg.cn[0].cn;
31608 if(this.title.length){
31611 cls: 'masonry-brick-title',
31616 if(this.html.length){
31619 cls: 'masonry-brick-text',
31623 if (!this.title.length && !this.html.length) {
31624 cfg.cn[0].cls += ' hide';
31627 if(this.bgimage.length){
31630 cls: 'masonry-brick-image-view',
31635 if(this.videourl.length){
31636 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
31637 // youtube support only?
31640 cls: 'masonry-brick-image-view',
31643 allowfullscreen : true
31651 cls: 'masonry-brick-mask'
31658 getSplitAutoCreate : function()
31660 var cls = 'masonry-brick masonry-brick-split';
31662 if(this.href.length){
31663 cls += ' masonry-brick-link';
31666 if(this.bgimage.length){
31667 cls += ' masonry-brick-image';
31671 cls += ' masonry-' + this.size + '-brick';
31674 switch (this.placetitle) {
31676 cls += ' masonry-center-title';
31679 cls += ' masonry-bottom-title';
31682 if(!this.bgimage.length){
31683 cls += ' masonry-center-title';
31686 if(this.bgimage.length){
31687 cls += ' masonry-bottom-title';
31693 cls += ' ' + this.cls;
31697 tag: (this.href.length) ? 'a' : 'div',
31702 cls: 'masonry-brick-split-head',
31706 cls: 'masonry-brick-paragraph',
31713 cls: 'masonry-brick-split-body',
31719 if(this.href.length){
31720 cfg.href = this.href;
31723 if(this.title.length){
31724 cfg.cn[0].cn[0].cn.push({
31726 cls: 'masonry-brick-title',
31731 if(this.html.length){
31732 cfg.cn[1].cn.push({
31734 cls: 'masonry-brick-text',
31739 if(this.bgimage.length){
31740 cfg.cn[0].cn.push({
31742 cls: 'masonry-brick-image-view',
31747 if(this.videourl.length){
31748 var vurl = this.videourl.replace(/https:\/\/youtu\.be/, 'https://www.youtube.com/embed/');
31749 // youtube support only?
31750 cfg.cn[0].cn.cn.push({
31752 cls: 'masonry-brick-image-view',
31755 allowfullscreen : true
31762 initEvents: function()
31764 switch (this.size) {
31797 this.el.on('touchstart', this.onTouchStart, this);
31798 this.el.on('touchmove', this.onTouchMove, this);
31799 this.el.on('touchend', this.onTouchEnd, this);
31800 this.el.on('contextmenu', this.onContextMenu, this);
31802 this.el.on('mouseenter' ,this.enter, this);
31803 this.el.on('mouseleave', this.leave, this);
31804 this.el.on('click', this.onClick, this);
31807 if (typeof(this.parent().bricks) == 'object' && this.parent().bricks != null) {
31808 this.parent().bricks.push(this);
31813 onClick: function(e, el)
31815 var time = this.endTimer - this.startTimer;
31819 e.preventDefault();
31824 if(!this.preventDefault){
31828 e.preventDefault();
31829 this.fireEvent('click', this);
31832 enter: function(e, el)
31834 e.preventDefault();
31836 if(!this.isFitContainer || this.maskInverse){
31840 if(this.bgimage.length && this.html.length){
31841 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
31845 leave: function(e, el)
31847 e.preventDefault();
31849 if(!this.isFitContainer || this.maskInverse){
31853 if(this.bgimage.length && this.html.length){
31854 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
31858 onTouchStart: function(e, el)
31860 // e.preventDefault();
31862 this.touchmoved = false;
31864 if(!this.isFitContainer){
31868 if(!this.bgimage.length || !this.html.length){
31872 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0.9, true);
31874 this.timer = new Date().getTime();
31878 onTouchMove: function(e, el)
31880 this.touchmoved = true;
31883 onContextMenu : function(e,el)
31885 e.preventDefault();
31886 e.stopPropagation();
31890 onTouchEnd: function(e, el)
31892 // e.preventDefault();
31894 if((new Date().getTime() - this.timer > 1000) || !this.href.length || this.touchmoved){
31901 if(!this.bgimage.length || !this.html.length){
31903 if(this.href.length){
31904 window.location.href = this.href;
31910 if(!this.isFitContainer){
31914 this.el.select('.masonry-brick-paragraph', true).first().setOpacity(0, true);
31916 window.location.href = this.href;
31931 * @class Roo.bootstrap.Brick
31932 * @extends Roo.bootstrap.Component
31933 * Bootstrap Brick class
31936 * Create a new Brick
31937 * @param {Object} config The config object
31940 Roo.bootstrap.Brick = function(config){
31941 Roo.bootstrap.Brick.superclass.constructor.call(this, config);
31947 * When a Brick is click
31948 * @param {Roo.bootstrap.Brick} this
31949 * @param {Roo.EventObject} e
31955 Roo.extend(Roo.bootstrap.Brick, Roo.bootstrap.Component, {
31958 * @cfg {String} title
31962 * @cfg {String} html
31966 * @cfg {String} bgimage
31970 * @cfg {String} cls
31974 * @cfg {String} href
31978 * @cfg {String} video
31982 * @cfg {Boolean} square
31986 getAutoCreate : function()
31988 var cls = 'roo-brick';
31990 if(this.href.length){
31991 cls += ' roo-brick-link';
31994 if(this.bgimage.length){
31995 cls += ' roo-brick-image';
31998 if(!this.html.length && !this.bgimage.length){
31999 cls += ' roo-brick-center-title';
32002 if(!this.html.length && this.bgimage.length){
32003 cls += ' roo-brick-bottom-title';
32007 cls += ' ' + this.cls;
32011 tag: (this.href.length) ? 'a' : 'div',
32016 cls: 'roo-brick-paragraph',
32022 if(this.href.length){
32023 cfg.href = this.href;
32026 var cn = cfg.cn[0].cn;
32028 if(this.title.length){
32031 cls: 'roo-brick-title',
32036 if(this.html.length){
32039 cls: 'roo-brick-text',
32046 if(this.bgimage.length){
32049 cls: 'roo-brick-image-view',
32057 initEvents: function()
32059 if(this.title.length || this.html.length){
32060 this.el.on('mouseenter' ,this.enter, this);
32061 this.el.on('mouseleave', this.leave, this);
32065 Roo.EventManager.onWindowResize(this.resize, this);
32070 resize : function()
32072 var paragraph = this.el.select('.roo-brick-paragraph', true).first();
32074 paragraph.setHeight(paragraph.getWidth() + paragraph.getPadding('tb'));
32076 if(this.bgimage.length){
32077 var image = this.el.select('.roo-brick-image-view', true).first();
32078 image.setWidth(paragraph.getWidth());
32079 image.setHeight(paragraph.getWidth());
32081 this.el.setHeight(paragraph.getWidth());
32087 enter: function(e, el)
32089 e.preventDefault();
32091 if(this.bgimage.length){
32092 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0.9, true);
32093 this.el.select('.roo-brick-image-view', true).first().setOpacity(0.1, true);
32097 leave: function(e, el)
32099 e.preventDefault();
32101 if(this.bgimage.length){
32102 this.el.select('.roo-brick-paragraph', true).first().setOpacity(0, true);
32103 this.el.select('.roo-brick-image-view', true).first().setOpacity(1, true);
32119 * @class Roo.bootstrap.NumberField
32120 * @extends Roo.bootstrap.Input
32121 * Bootstrap NumberField class
32127 * Create a new NumberField
32128 * @param {Object} config The config object
32131 Roo.bootstrap.NumberField = function(config){
32132 Roo.bootstrap.NumberField.superclass.constructor.call(this, config);
32135 Roo.extend(Roo.bootstrap.NumberField, Roo.bootstrap.Input, {
32138 * @cfg {Boolean} allowDecimals False to disallow decimal values (defaults to true)
32140 allowDecimals : true,
32142 * @cfg {String} decimalSeparator Character(s) to allow as the decimal separator (defaults to '.')
32144 decimalSeparator : ".",
32146 * @cfg {Number} decimalPrecision The maximum precision to display after the decimal separator (defaults to 2)
32148 decimalPrecision : 2,
32150 * @cfg {Boolean} allowNegative False to prevent entering a negative sign (defaults to true)
32152 allowNegative : true,
32154 * @cfg {Number} minValue The minimum allowed value (defaults to Number.NEGATIVE_INFINITY)
32156 minValue : Number.NEGATIVE_INFINITY,
32158 * @cfg {Number} maxValue The maximum allowed value (defaults to Number.MAX_VALUE)
32160 maxValue : Number.MAX_VALUE,
32162 * @cfg {String} minText Error text to display if the minimum value validation fails (defaults to "The minimum value for this field is {minValue}")
32164 minText : "The minimum value for this field is {0}",
32166 * @cfg {String} maxText Error text to display if the maximum value validation fails (defaults to "The maximum value for this field is {maxValue}")
32168 maxText : "The maximum value for this field is {0}",
32170 * @cfg {String} nanText Error text to display if the value is not a valid number. For example, this can happen
32171 * if a valid character like '.' or '-' is left in the field with no number (defaults to "{value} is not a valid number")
32173 nanText : "{0} is not a valid number",
32175 * @cfg {Boolean} castInt (true|false) cast int if true (defalut true)
32180 initEvents : function()
32182 Roo.bootstrap.NumberField.superclass.initEvents.call(this);
32184 var allowed = "0123456789";
32186 if(this.allowDecimals){
32187 allowed += this.decimalSeparator;
32190 if(this.allowNegative){
32194 this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
32196 var keyPress = function(e){
32198 var k = e.getKey();
32200 var c = e.getCharCode();
32203 (String.fromCharCode(c) == '.' || String.fromCharCode(c) == '-') &&
32204 allowed.indexOf(String.fromCharCode(c)) === -1
32210 if(!Roo.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
32214 if(allowed.indexOf(String.fromCharCode(c)) === -1){
32219 this.el.on("keypress", keyPress, this);
32222 validateValue : function(value)
32225 if(!Roo.bootstrap.NumberField.superclass.validateValue.call(this, value)){
32229 var num = this.parseValue(value);
32232 this.markInvalid(String.format(this.nanText, value));
32236 if(num < this.minValue){
32237 this.markInvalid(String.format(this.minText, this.minValue));
32241 if(num > this.maxValue){
32242 this.markInvalid(String.format(this.maxText, this.maxValue));
32249 getValue : function()
32251 return this.fixPrecision(this.parseValue(Roo.bootstrap.NumberField.superclass.getValue.call(this)));
32254 parseValue : function(value)
32256 value = parseFloat(String(value).replace(this.decimalSeparator, "."));
32257 return isNaN(value) ? '' : value;
32260 fixPrecision : function(value)
32262 var nan = isNaN(value);
32264 if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
32265 return nan ? '' : value;
32267 return parseFloat(value).toFixed(this.decimalPrecision);
32270 setValue : function(v)
32272 v = this.fixPrecision(v);
32273 Roo.bootstrap.NumberField.superclass.setValue.call(this, String(v).replace(".", this.decimalSeparator));
32276 decimalPrecisionFcn : function(v)
32278 return Math.floor(v);
32281 beforeBlur : function()
32287 var v = this.parseValue(this.getRawValue());
32302 * @class Roo.bootstrap.DocumentSlider
32303 * @extends Roo.bootstrap.Component
32304 * Bootstrap DocumentSlider class
32307 * Create a new DocumentViewer
32308 * @param {Object} config The config object
32311 Roo.bootstrap.DocumentSlider = function(config){
32312 Roo.bootstrap.DocumentSlider.superclass.constructor.call(this, config);
32319 * Fire after initEvent
32320 * @param {Roo.bootstrap.DocumentSlider} this
32325 * Fire after update
32326 * @param {Roo.bootstrap.DocumentSlider} this
32332 * @param {Roo.bootstrap.DocumentSlider} this
32338 Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component, {
32344 getAutoCreate : function()
32348 cls : 'roo-document-slider',
32352 cls : 'roo-document-slider-header',
32356 cls : 'roo-document-slider-header-title'
32362 cls : 'roo-document-slider-body',
32366 cls : 'roo-document-slider-prev',
32370 cls : 'fa fa-chevron-left'
32376 cls : 'roo-document-slider-thumb',
32380 cls : 'roo-document-slider-image'
32386 cls : 'roo-document-slider-next',
32390 cls : 'fa fa-chevron-right'
32402 initEvents : function()
32404 this.headerEl = this.el.select('.roo-document-slider-header', true).first();
32405 this.headerEl.setVisibilityMode(Roo.Element.DISPLAY);
32407 this.titleEl = this.el.select('.roo-document-slider-header .roo-document-slider-header-title', true).first();
32408 this.titleEl.setVisibilityMode(Roo.Element.DISPLAY);
32410 this.bodyEl = this.el.select('.roo-document-slider-body', true).first();
32411 this.bodyEl.setVisibilityMode(Roo.Element.DISPLAY);
32413 this.thumbEl = this.el.select('.roo-document-slider-thumb', true).first();
32414 this.thumbEl.setVisibilityMode(Roo.Element.DISPLAY);
32416 this.imageEl = this.el.select('.roo-document-slider-image', true).first();
32417 this.imageEl.setVisibilityMode(Roo.Element.DISPLAY);
32419 this.prevIndicator = this.el.select('.roo-document-slider-prev i', true).first();
32420 this.prevIndicator.setVisibilityMode(Roo.Element.DISPLAY);
32422 this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
32423 this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
32425 this.thumbEl.on('click', this.onClick, this);
32427 this.prevIndicator.on('click', this.prev, this);
32429 this.nextIndicator.on('click', this.next, this);
32433 initial : function()
32435 if(this.files.length){
32436 this.indicator = 1;
32440 this.fireEvent('initial', this);
32443 update : function()
32445 this.imageEl.attr('src', this.files[this.indicator - 1]);
32447 this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
32449 this.prevIndicator.show();
32451 if(this.indicator == 1){
32452 this.prevIndicator.hide();
32455 this.nextIndicator.show();
32457 if(this.indicator == this.files.length){
32458 this.nextIndicator.hide();
32461 this.thumbEl.scrollTo('top');
32463 this.fireEvent('update', this);
32466 onClick : function(e)
32468 e.preventDefault();
32470 this.fireEvent('click', this);
32475 e.preventDefault();
32477 this.indicator = Math.max(1, this.indicator - 1);
32484 e.preventDefault();
32486 this.indicator = Math.min(this.files.length, this.indicator + 1);
32500 * @class Roo.bootstrap.RadioSet
32501 * @extends Roo.bootstrap.Input
32502 * Bootstrap RadioSet class
32503 * @cfg {String} indicatorpos (left|right) default left
32504 * @cfg {Boolean} inline (true|false) inline the element (default true)
32505 * @cfg {String} weight (primary|warning|info|danger|success) The text that appears beside the radio
32507 * Create a new RadioSet
32508 * @param {Object} config The config object
32511 Roo.bootstrap.RadioSet = function(config){
32513 Roo.bootstrap.RadioSet.superclass.constructor.call(this, config);
32517 Roo.bootstrap.RadioSet.register(this);
32522 * Fires when the element is checked or unchecked.
32523 * @param {Roo.bootstrap.RadioSet} this This radio
32524 * @param {Roo.bootstrap.Radio} item The checked item
32531 Roo.extend(Roo.bootstrap.RadioSet, Roo.bootstrap.Input, {
32539 indicatorpos : 'left',
32541 getAutoCreate : function()
32545 cls : 'roo-radio-set-label',
32549 html : this.fieldLabel
32554 if(this.indicatorpos == 'left'){
32557 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
32558 tooltip : 'This field is required'
32563 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
32564 tooltip : 'This field is required'
32570 cls : 'roo-radio-set-items'
32573 var align = (!this.labelAlign) ? this.parentLabelAlign() : this.labelAlign;
32575 if (align === 'left' && this.fieldLabel.length) {
32578 cls : "roo-radio-set-right",
32584 if(this.labelWidth > 12){
32585 label.style = "width: " + this.labelWidth + 'px';
32588 if(this.labelWidth < 13 && this.labelmd == 0){
32589 this.labelmd = this.labelWidth;
32592 if(this.labellg > 0){
32593 label.cls += ' col-lg-' + this.labellg;
32594 items.cls += ' col-lg-' + (12 - this.labellg);
32597 if(this.labelmd > 0){
32598 label.cls += ' col-md-' + this.labelmd;
32599 items.cls += ' col-md-' + (12 - this.labelmd);
32602 if(this.labelsm > 0){
32603 label.cls += ' col-sm-' + this.labelsm;
32604 items.cls += ' col-sm-' + (12 - this.labelsm);
32607 if(this.labelxs > 0){
32608 label.cls += ' col-xs-' + this.labelxs;
32609 items.cls += ' col-xs-' + (12 - this.labelxs);
32615 cls : 'roo-radio-set',
32619 cls : 'roo-radio-set-input',
32622 value : this.value ? this.value : ''
32629 if(this.weight.length){
32630 cfg.cls += ' roo-radio-' + this.weight;
32634 cfg.cls += ' roo-radio-set-inline';
32641 initEvents : function()
32643 this.labelEl = this.el.select('.roo-radio-set-label', true).first();
32644 this.labelEl.setVisibilityMode(Roo.Element.DISPLAY);
32646 if(!this.fieldLabel.length){
32647 this.labelEl.hide();
32650 this.itemsEl = this.el.select('.roo-radio-set-items', true).first();
32651 this.itemsEl.setVisibilityMode(Roo.Element.DISPLAY);
32653 this.indicatorEl().setVisibilityMode(Roo.Element.DISPLAY);
32654 this.indicatorEl().hide();
32656 this.originalValue = this.getValue();
32660 inputEl: function ()
32662 return this.el.select('.roo-radio-set-input', true).first();
32665 getChildContainer : function()
32667 return this.itemsEl;
32670 register : function(item)
32672 this.radioes.push(item);
32676 validate : function()
32680 Roo.each(this.radioes, function(i){
32689 if(this.allowBlank) {
32693 if(this.disabled || valid){
32698 this.markInvalid();
32703 markValid : function()
32705 if(this.labelEl.isVisible(true)){
32706 this.indicatorEl().hide();
32709 this.el.removeClass([this.invalidClass, this.validClass]);
32710 this.el.addClass(this.validClass);
32712 this.fireEvent('valid', this);
32715 markInvalid : function(msg)
32717 if(this.allowBlank || this.disabled){
32721 if(this.labelEl.isVisible(true)){
32722 this.indicatorEl().show();
32725 this.el.removeClass([this.invalidClass, this.validClass]);
32726 this.el.addClass(this.invalidClass);
32728 this.fireEvent('invalid', this, msg);
32732 setValue : function(v, suppressEvent)
32734 Roo.each(this.radioes, function(i){
32737 i.el.removeClass('checked');
32739 if(i.value === v || i.value.toString() === v.toString()){
32741 i.el.addClass('checked');
32743 if(suppressEvent !== true){
32744 this.fireEvent('check', this, i);
32750 Roo.bootstrap.RadioSet.superclass.setValue.call(this, v);
32754 clearInvalid : function(){
32756 if(!this.el || this.preventMark){
32760 if(this.labelEl.isVisible(true)){
32761 this.indicatorEl().hide();
32764 this.el.removeClass([this.invalidClass]);
32766 this.fireEvent('valid', this);
32771 Roo.apply(Roo.bootstrap.RadioSet, {
32775 register : function(set)
32777 this.groups[set.name] = set;
32780 get: function(name)
32782 if (typeof(this.groups[name]) == 'undefined') {
32786 return this.groups[name] ;
32792 * Ext JS Library 1.1.1
32793 * Copyright(c) 2006-2007, Ext JS, LLC.
32795 * Originally Released Under LGPL - original licence link has changed is not relivant.
32798 * <script type="text/javascript">
32803 * @class Roo.bootstrap.SplitBar
32804 * @extends Roo.util.Observable
32805 * Creates draggable splitter bar functionality from two elements (element to be dragged and element to be resized).
32809 var split = new Roo.bootstrap.SplitBar("elementToDrag", "elementToSize",
32810 Roo.bootstrap.SplitBar.HORIZONTAL, Roo.bootstrap.SplitBar.LEFT);
32811 split.setAdapter(new Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter("container"));
32812 split.minSize = 100;
32813 split.maxSize = 600;
32814 split.animate = true;
32815 split.on('moved', splitterMoved);
32818 * Create a new SplitBar
32819 * @config {String/HTMLElement/Roo.Element} dragElement The element to be dragged and act as the SplitBar.
32820 * @config {String/HTMLElement/Roo.Element} resizingElement The element to be resized based on where the SplitBar element is dragged
32821 * @config {Number} orientation (optional) Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
32822 * @config {Number} placement (optional) Either Roo.bootstrap.SplitBar.LEFT or Roo.bootstrap.SplitBar.RIGHT for horizontal or
32823 Roo.bootstrap.SplitBar.TOP or Roo.bootstrap.SplitBar.BOTTOM for vertical. (By default, this is determined automatically by the initial
32824 position of the SplitBar).
32826 Roo.bootstrap.SplitBar = function(cfg){
32831 // dragElement : elm
32832 // resizingElement: el,
32834 // orientation : Either Roo.bootstrap.SplitBar.HORIZONTAL
32835 // placement : Roo.bootstrap.SplitBar.LEFT ,
32836 // existingProxy ???
32839 this.el = Roo.get(cfg.dragElement, true);
32840 this.el.dom.unselectable = "on";
32842 this.resizingEl = Roo.get(cfg.resizingElement, true);
32846 * The orientation of the split. Either Roo.bootstrap.SplitBar.HORIZONTAL or Roo.bootstrap.SplitBar.VERTICAL. (Defaults to HORIZONTAL)
32847 * Note: If this is changed after creating the SplitBar, the placement property must be manually updated
32850 this.orientation = cfg.orientation || Roo.bootstrap.SplitBar.HORIZONTAL;
32853 * The minimum size of the resizing element. (Defaults to 0)
32859 * The maximum size of the resizing element. (Defaults to 2000)
32862 this.maxSize = 2000;
32865 * Whether to animate the transition to the new size
32868 this.animate = false;
32871 * Whether to create a transparent shim that overlays the page when dragging, enables dragging across iframes.
32874 this.useShim = false;
32879 if(!cfg.existingProxy){
32881 this.proxy = Roo.bootstrap.SplitBar.createProxy(this.orientation);
32883 this.proxy = Roo.get(cfg.existingProxy).dom;
32886 this.dd = new Roo.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
32889 this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
32892 this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
32895 this.dragSpecs = {};
32898 * @private The adapter to use to positon and resize elements
32900 this.adapter = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
32901 this.adapter.init(this);
32903 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
32905 this.placement = cfg.placement || (this.el.getX() > this.resizingEl.getX() ? Roo.bootstrap.SplitBar.LEFT : Roo.bootstrap.SplitBar.RIGHT);
32906 this.el.addClass("roo-splitbar-h");
32909 this.placement = cfg.placement || (this.el.getY() > this.resizingEl.getY() ? Roo.bootstrap.SplitBar.TOP : Roo.bootstrap.SplitBar.BOTTOM);
32910 this.el.addClass("roo-splitbar-v");
32916 * Fires when the splitter is moved (alias for {@link #event-moved})
32917 * @param {Roo.bootstrap.SplitBar} this
32918 * @param {Number} newSize the new width or height
32923 * Fires when the splitter is moved
32924 * @param {Roo.bootstrap.SplitBar} this
32925 * @param {Number} newSize the new width or height
32929 * @event beforeresize
32930 * Fires before the splitter is dragged
32931 * @param {Roo.bootstrap.SplitBar} this
32933 "beforeresize" : true,
32935 "beforeapply" : true
32938 Roo.util.Observable.call(this);
32941 Roo.extend(Roo.bootstrap.SplitBar, Roo.util.Observable, {
32942 onStartProxyDrag : function(x, y){
32943 this.fireEvent("beforeresize", this);
32945 var o = Roo.DomHelper.insertFirst(document.body, {cls: "roo-drag-overlay", html: " "}, true);
32947 o.enableDisplayMode("block");
32948 // all splitbars share the same overlay
32949 Roo.bootstrap.SplitBar.prototype.overlay = o;
32951 this.overlay.setSize(Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
32952 this.overlay.show();
32953 Roo.get(this.proxy).setDisplayed("block");
32954 var size = this.adapter.getElementSize(this);
32955 this.activeMinSize = this.getMinimumSize();;
32956 this.activeMaxSize = this.getMaximumSize();;
32957 var c1 = size - this.activeMinSize;
32958 var c2 = Math.max(this.activeMaxSize - size, 0);
32959 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
32960 this.dd.resetConstraints();
32961 this.dd.setXConstraint(
32962 this.placement == Roo.bootstrap.SplitBar.LEFT ? c1 : c2,
32963 this.placement == Roo.bootstrap.SplitBar.LEFT ? c2 : c1
32965 this.dd.setYConstraint(0, 0);
32967 this.dd.resetConstraints();
32968 this.dd.setXConstraint(0, 0);
32969 this.dd.setYConstraint(
32970 this.placement == Roo.bootstrap.SplitBar.TOP ? c1 : c2,
32971 this.placement == Roo.bootstrap.SplitBar.TOP ? c2 : c1
32974 this.dragSpecs.startSize = size;
32975 this.dragSpecs.startPoint = [x, y];
32976 Roo.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
32980 * @private Called after the drag operation by the DDProxy
32982 onEndProxyDrag : function(e){
32983 Roo.get(this.proxy).setDisplayed(false);
32984 var endPoint = Roo.lib.Event.getXY(e);
32986 this.overlay.hide();
32989 if(this.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
32990 newSize = this.dragSpecs.startSize +
32991 (this.placement == Roo.bootstrap.SplitBar.LEFT ?
32992 endPoint[0] - this.dragSpecs.startPoint[0] :
32993 this.dragSpecs.startPoint[0] - endPoint[0]
32996 newSize = this.dragSpecs.startSize +
32997 (this.placement == Roo.bootstrap.SplitBar.TOP ?
32998 endPoint[1] - this.dragSpecs.startPoint[1] :
32999 this.dragSpecs.startPoint[1] - endPoint[1]
33002 newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
33003 if(newSize != this.dragSpecs.startSize){
33004 if(this.fireEvent('beforeapply', this, newSize) !== false){
33005 this.adapter.setElementSize(this, newSize);
33006 this.fireEvent("moved", this, newSize);
33007 this.fireEvent("resize", this, newSize);
33013 * Get the adapter this SplitBar uses
33014 * @return The adapter object
33016 getAdapter : function(){
33017 return this.adapter;
33021 * Set the adapter this SplitBar uses
33022 * @param {Object} adapter A SplitBar adapter object
33024 setAdapter : function(adapter){
33025 this.adapter = adapter;
33026 this.adapter.init(this);
33030 * Gets the minimum size for the resizing element
33031 * @return {Number} The minimum size
33033 getMinimumSize : function(){
33034 return this.minSize;
33038 * Sets the minimum size for the resizing element
33039 * @param {Number} minSize The minimum size
33041 setMinimumSize : function(minSize){
33042 this.minSize = minSize;
33046 * Gets the maximum size for the resizing element
33047 * @return {Number} The maximum size
33049 getMaximumSize : function(){
33050 return this.maxSize;
33054 * Sets the maximum size for the resizing element
33055 * @param {Number} maxSize The maximum size
33057 setMaximumSize : function(maxSize){
33058 this.maxSize = maxSize;
33062 * Sets the initialize size for the resizing element
33063 * @param {Number} size The initial size
33065 setCurrentSize : function(size){
33066 var oldAnimate = this.animate;
33067 this.animate = false;
33068 this.adapter.setElementSize(this, size);
33069 this.animate = oldAnimate;
33073 * Destroy this splitbar.
33074 * @param {Boolean} removeEl True to remove the element
33076 destroy : function(removeEl){
33078 this.shim.remove();
33081 this.proxy.parentNode.removeChild(this.proxy);
33089 * @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.
33091 Roo.bootstrap.SplitBar.createProxy = function(dir){
33092 var proxy = new Roo.Element(document.createElement("div"));
33093 proxy.unselectable();
33094 var cls = 'roo-splitbar-proxy';
33095 proxy.addClass(cls + ' ' + (dir == Roo.bootstrap.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
33096 document.body.appendChild(proxy.dom);
33101 * @class Roo.bootstrap.SplitBar.BasicLayoutAdapter
33102 * Default Adapter. It assumes the splitter and resizing element are not positioned
33103 * elements and only gets/sets the width of the element. Generally used for table based layouts.
33105 Roo.bootstrap.SplitBar.BasicLayoutAdapter = function(){
33108 Roo.bootstrap.SplitBar.BasicLayoutAdapter.prototype = {
33109 // do nothing for now
33110 init : function(s){
33114 * Called before drag operations to get the current size of the resizing element.
33115 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
33117 getElementSize : function(s){
33118 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33119 return s.resizingEl.getWidth();
33121 return s.resizingEl.getHeight();
33126 * Called after drag operations to set the size of the resizing element.
33127 * @param {Roo.bootstrap.SplitBar} s The SplitBar using this adapter
33128 * @param {Number} newSize The new size to set
33129 * @param {Function} onComplete A function to be invoked when resizing is complete
33131 setElementSize : function(s, newSize, onComplete){
33132 if(s.orientation == Roo.bootstrap.SplitBar.HORIZONTAL){
33134 s.resizingEl.setWidth(newSize);
33136 onComplete(s, newSize);
33139 s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
33144 s.resizingEl.setHeight(newSize);
33146 onComplete(s, newSize);
33149 s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
33156 *@class Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter
33157 * @extends Roo.bootstrap.SplitBar.BasicLayoutAdapter
33158 * Adapter that moves the splitter element to align with the resized sizing element.
33159 * Used with an absolute positioned SplitBar.
33160 * @param {String/HTMLElement/Roo.Element} container The container that wraps around the absolute positioned content. If it's
33161 * document.body, make sure you assign an id to the body element.
33163 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter = function(container){
33164 this.basic = new Roo.bootstrap.SplitBar.BasicLayoutAdapter();
33165 this.container = Roo.get(container);
33168 Roo.bootstrap.SplitBar.AbsoluteLayoutAdapter.prototype = {
33169 init : function(s){
33170 this.basic.init(s);
33173 getElementSize : function(s){
33174 return this.basic.getElementSize(s);
33177 setElementSize : function(s, newSize, onComplete){
33178 this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
33181 moveSplitter : function(s){
33182 var yes = Roo.bootstrap.SplitBar;
33183 switch(s.placement){
33185 s.el.setX(s.resizingEl.getRight());
33188 s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
33191 s.el.setY(s.resizingEl.getBottom());
33194 s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
33201 * Orientation constant - Create a vertical SplitBar
33205 Roo.bootstrap.SplitBar.VERTICAL = 1;
33208 * Orientation constant - Create a horizontal SplitBar
33212 Roo.bootstrap.SplitBar.HORIZONTAL = 2;
33215 * Placement constant - The resizing element is to the left of the splitter element
33219 Roo.bootstrap.SplitBar.LEFT = 1;
33222 * Placement constant - The resizing element is to the right of the splitter element
33226 Roo.bootstrap.SplitBar.RIGHT = 2;
33229 * Placement constant - The resizing element is positioned above the splitter element
33233 Roo.bootstrap.SplitBar.TOP = 3;
33236 * Placement constant - The resizing element is positioned under splitter element
33240 Roo.bootstrap.SplitBar.BOTTOM = 4;
33241 Roo.namespace("Roo.bootstrap.layout");/*
33243 * Ext JS Library 1.1.1
33244 * Copyright(c) 2006-2007, Ext JS, LLC.
33246 * Originally Released Under LGPL - original licence link has changed is not relivant.
33249 * <script type="text/javascript">
33253 * @class Roo.bootstrap.layout.Manager
33254 * @extends Roo.bootstrap.Component
33255 * Base class for layout managers.
33257 Roo.bootstrap.layout.Manager = function(config)
33259 Roo.bootstrap.layout.Manager.superclass.constructor.call(this,config);
33265 /** false to disable window resize monitoring @type Boolean */
33266 this.monitorWindowResize = true;
33271 * Fires when a layout is performed.
33272 * @param {Roo.LayoutManager} this
33276 * @event regionresized
33277 * Fires when the user resizes a region.
33278 * @param {Roo.LayoutRegion} region The resized region
33279 * @param {Number} newSize The new size (width for east/west, height for north/south)
33281 "regionresized" : true,
33283 * @event regioncollapsed
33284 * Fires when a region is collapsed.
33285 * @param {Roo.LayoutRegion} region The collapsed region
33287 "regioncollapsed" : true,
33289 * @event regionexpanded
33290 * Fires when a region is expanded.
33291 * @param {Roo.LayoutRegion} region The expanded region
33293 "regionexpanded" : true
33295 this.updating = false;
33298 this.el = Roo.get(config.el);
33304 Roo.extend(Roo.bootstrap.layout.Manager, Roo.bootstrap.Component, {
33309 monitorWindowResize : true,
33315 onRender : function(ct, position)
33318 this.el = Roo.get(ct);
33321 //this.fireEvent('render',this);
33325 initEvents: function()
33329 // ie scrollbar fix
33330 if(this.el.dom == document.body && Roo.isIE && !config.allowScroll){
33331 document.body.scroll = "no";
33332 }else if(this.el.dom != document.body && this.el.getStyle('position') == 'static'){
33333 this.el.position('relative');
33335 this.id = this.el.id;
33336 this.el.addClass("roo-layout-container");
33337 Roo.EventManager.onWindowResize(this.onWindowResize, this, true);
33338 if(this.el.dom != document.body ) {
33339 this.el.on('resize', this.layout,this);
33340 this.el.on('show', this.layout,this);
33346 * Returns true if this layout is currently being updated
33347 * @return {Boolean}
33349 isUpdating : function(){
33350 return this.updating;
33354 * Suspend the LayoutManager from doing auto-layouts while
33355 * making multiple add or remove calls
33357 beginUpdate : function(){
33358 this.updating = true;
33362 * Restore auto-layouts and optionally disable the manager from performing a layout
33363 * @param {Boolean} noLayout true to disable a layout update
33365 endUpdate : function(noLayout){
33366 this.updating = false;
33372 layout: function(){
33376 onRegionResized : function(region, newSize){
33377 this.fireEvent("regionresized", region, newSize);
33381 onRegionCollapsed : function(region){
33382 this.fireEvent("regioncollapsed", region);
33385 onRegionExpanded : function(region){
33386 this.fireEvent("regionexpanded", region);
33390 * Returns the size of the current view. This method normalizes document.body and element embedded layouts and
33391 * performs box-model adjustments.
33392 * @return {Object} The size as an object {width: (the width), height: (the height)}
33394 getViewSize : function()
33397 if(this.el.dom != document.body){
33398 size = this.el.getSize();
33400 size = {width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()};
33402 size.width -= this.el.getBorderWidth("lr")-this.el.getPadding("lr");
33403 size.height -= this.el.getBorderWidth("tb")-this.el.getPadding("tb");
33408 * Returns the Element this layout is bound to.
33409 * @return {Roo.Element}
33411 getEl : function(){
33416 * Returns the specified region.
33417 * @param {String} target The region key ('center', 'north', 'south', 'east' or 'west')
33418 * @return {Roo.LayoutRegion}
33420 getRegion : function(target){
33421 return this.regions[target.toLowerCase()];
33424 onWindowResize : function(){
33425 if(this.monitorWindowResize){
33432 * Ext JS Library 1.1.1
33433 * Copyright(c) 2006-2007, Ext JS, LLC.
33435 * Originally Released Under LGPL - original licence link has changed is not relivant.
33438 * <script type="text/javascript">
33441 * @class Roo.bootstrap.layout.Border
33442 * @extends Roo.bootstrap.layout.Manager
33443 * This class represents a common layout manager used in desktop applications. For screenshots and more details,
33444 * please see: examples/bootstrap/nested.html<br><br>
33446 <b>The container the layout is rendered into can be either the body element or any other element.
33447 If it is not the body element, the container needs to either be an absolute positioned element,
33448 or you will need to add "position:relative" to the css of the container. You will also need to specify
33449 the container size if it is not the body element.</b>
33452 * Create a new Border
33453 * @param {Object} config Configuration options
33455 Roo.bootstrap.layout.Border = function(config){
33456 config = config || {};
33457 Roo.bootstrap.layout.Border.superclass.constructor.call(this, config);
33461 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
33462 if(config[region]){
33463 config[region].region = region;
33464 this.addRegion(config[region]);
33470 Roo.bootstrap.layout.Border.regions = ["north","south","east","west","center"];
33472 Roo.extend(Roo.bootstrap.layout.Border, Roo.bootstrap.layout.Manager, {
33474 * Creates and adds a new region if it doesn't already exist.
33475 * @param {String} target The target region key (north, south, east, west or center).
33476 * @param {Object} config The regions config object
33477 * @return {BorderLayoutRegion} The new region
33479 addRegion : function(config)
33481 if(!this.regions[config.region]){
33482 var r = this.factory(config);
33483 this.bindRegion(r);
33485 return this.regions[config.region];
33489 bindRegion : function(r){
33490 this.regions[r.config.region] = r;
33492 r.on("visibilitychange", this.layout, this);
33493 r.on("paneladded", this.layout, this);
33494 r.on("panelremoved", this.layout, this);
33495 r.on("invalidated", this.layout, this);
33496 r.on("resized", this.onRegionResized, this);
33497 r.on("collapsed", this.onRegionCollapsed, this);
33498 r.on("expanded", this.onRegionExpanded, this);
33502 * Performs a layout update.
33504 layout : function()
33506 if(this.updating) {
33510 // render all the rebions if they have not been done alreayd?
33511 Roo.each(Roo.bootstrap.layout.Border.regions, function(region) {
33512 if(this.regions[region] && !this.regions[region].bodyEl){
33513 this.regions[region].onRender(this.el)
33517 var size = this.getViewSize();
33518 var w = size.width;
33519 var h = size.height;
33524 //var x = 0, y = 0;
33526 var rs = this.regions;
33527 var north = rs["north"];
33528 var south = rs["south"];
33529 var west = rs["west"];
33530 var east = rs["east"];
33531 var center = rs["center"];
33532 //if(this.hideOnLayout){ // not supported anymore
33533 //c.el.setStyle("display", "none");
33535 if(north && north.isVisible()){
33536 var b = north.getBox();
33537 var m = north.getMargins();
33538 b.width = w - (m.left+m.right);
33541 centerY = b.height + b.y + m.bottom;
33542 centerH -= centerY;
33543 north.updateBox(this.safeBox(b));
33545 if(south && south.isVisible()){
33546 var b = south.getBox();
33547 var m = south.getMargins();
33548 b.width = w - (m.left+m.right);
33550 var totalHeight = (b.height + m.top + m.bottom);
33551 b.y = h - totalHeight + m.top;
33552 centerH -= totalHeight;
33553 south.updateBox(this.safeBox(b));
33555 if(west && west.isVisible()){
33556 var b = west.getBox();
33557 var m = west.getMargins();
33558 b.height = centerH - (m.top+m.bottom);
33560 b.y = centerY + m.top;
33561 var totalWidth = (b.width + m.left + m.right);
33562 centerX += totalWidth;
33563 centerW -= totalWidth;
33564 west.updateBox(this.safeBox(b));
33566 if(east && east.isVisible()){
33567 var b = east.getBox();
33568 var m = east.getMargins();
33569 b.height = centerH - (m.top+m.bottom);
33570 var totalWidth = (b.width + m.left + m.right);
33571 b.x = w - totalWidth + m.left;
33572 b.y = centerY + m.top;
33573 centerW -= totalWidth;
33574 east.updateBox(this.safeBox(b));
33577 var m = center.getMargins();
33579 x: centerX + m.left,
33580 y: centerY + m.top,
33581 width: centerW - (m.left+m.right),
33582 height: centerH - (m.top+m.bottom)
33584 //if(this.hideOnLayout){
33585 //center.el.setStyle("display", "block");
33587 center.updateBox(this.safeBox(centerBox));
33590 this.fireEvent("layout", this);
33594 safeBox : function(box){
33595 box.width = Math.max(0, box.width);
33596 box.height = Math.max(0, box.height);
33601 * Adds a ContentPanel (or subclass) to this layout.
33602 * @param {String} target The target region key (north, south, east, west or center).
33603 * @param {Roo.ContentPanel} panel The panel to add
33604 * @return {Roo.ContentPanel} The added panel
33606 add : function(target, panel){
33608 target = target.toLowerCase();
33609 return this.regions[target].add(panel);
33613 * Remove a ContentPanel (or subclass) to this layout.
33614 * @param {String} target The target region key (north, south, east, west or center).
33615 * @param {Number/String/Roo.ContentPanel} panel The index, id or panel to remove
33616 * @return {Roo.ContentPanel} The removed panel
33618 remove : function(target, panel){
33619 target = target.toLowerCase();
33620 return this.regions[target].remove(panel);
33624 * Searches all regions for a panel with the specified id
33625 * @param {String} panelId
33626 * @return {Roo.ContentPanel} The panel or null if it wasn't found
33628 findPanel : function(panelId){
33629 var rs = this.regions;
33630 for(var target in rs){
33631 if(typeof rs[target] != "function"){
33632 var p = rs[target].getPanel(panelId);
33642 * Searches all regions for a panel with the specified id and activates (shows) it.
33643 * @param {String/ContentPanel} panelId The panels id or the panel itself
33644 * @return {Roo.ContentPanel} The shown panel or null
33646 showPanel : function(panelId) {
33647 var rs = this.regions;
33648 for(var target in rs){
33649 var r = rs[target];
33650 if(typeof r != "function"){
33651 if(r.hasPanel(panelId)){
33652 return r.showPanel(panelId);
33660 * Restores this layout's state using Roo.state.Manager or the state provided by the passed provider.
33661 * @param {Roo.state.Provider} provider (optional) An alternate state provider
33664 restoreState : function(provider){
33666 provider = Roo.state.Manager;
33668 var sm = new Roo.LayoutStateManager();
33669 sm.init(this, provider);
33675 * Adds a xtype elements to the layout.
33679 xtype : 'ContentPanel',
33686 xtype : 'NestedLayoutPanel',
33692 items : [ ... list of content panels or nested layout panels.. ]
33696 * @param {Object} cfg Xtype definition of item to add.
33698 addxtype : function(cfg)
33700 // basically accepts a pannel...
33701 // can accept a layout region..!?!?
33702 //Roo.log('Roo.BorderLayout add ' + cfg.xtype)
33705 // theory? children can only be panels??
33707 //if (!cfg.xtype.match(/Panel$/)) {
33712 if (typeof(cfg.region) == 'undefined') {
33713 Roo.log("Failed to add Panel, region was not set");
33717 var region = cfg.region;
33723 xitems = cfg.items;
33730 case 'Content': // ContentPanel (el, cfg)
33731 case 'Scroll': // ContentPanel (el, cfg)
33733 cfg.autoCreate = true;
33734 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
33736 // var el = this.el.createChild();
33737 // ret = new Roo[cfg.xtype](el, cfg); // new panel!!!!!
33740 this.add(region, ret);
33744 case 'TreePanel': // our new panel!
33745 cfg.el = this.el.createChild();
33746 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
33747 this.add(region, ret);
33752 // create a new Layout (which is a Border Layout...
33754 var clayout = cfg.layout;
33755 clayout.el = this.el.createChild();
33756 clayout.items = clayout.items || [];
33760 // replace this exitems with the clayout ones..
33761 xitems = clayout.items;
33763 // force background off if it's in center...
33764 if (region == 'center' && this.active && this.getRegion('center').panels.length < 1) {
33765 cfg.background = false;
33767 cfg.layout = new Roo.bootstrap.layout.Border(clayout);
33770 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
33771 //console.log('adding nested layout panel ' + cfg.toSource());
33772 this.add(region, ret);
33773 nb = {}; /// find first...
33778 // needs grid and region
33780 //var el = this.getRegion(region).el.createChild();
33782 *var el = this.el.createChild();
33783 // create the grid first...
33784 cfg.grid.container = el;
33785 cfg.grid = new cfg.grid.xns[cfg.grid.xtype](cfg.grid);
33788 if (region == 'center' && this.active ) {
33789 cfg.background = false;
33792 ret = new cfg.xns[cfg.xtype](cfg); // new panel!!!!!
33794 this.add(region, ret);
33796 if (cfg.background) {
33797 // render grid on panel activation (if panel background)
33798 ret.on('activate', function(gp) {
33799 if (!gp.grid.rendered) {
33800 // gp.grid.render(el);
33804 // cfg.grid.render(el);
33810 case 'Border': // it can get called on it'self... - might need to check if this is fixed?
33811 // it was the old xcomponent building that caused this before.
33812 // espeically if border is the top element in the tree.
33822 if (typeof(Roo[cfg.xtype]) != 'undefined') {
33824 ret = new Roo[cfg.xtype](cfg); // new panel!!!!!
33825 this.add(region, ret);
33829 throw "Can not add '" + cfg.xtype + "' to Border";
33835 this.beginUpdate();
33839 Roo.each(xitems, function(i) {
33840 region = nb && i.region ? i.region : false;
33842 var add = ret.addxtype(i);
33845 nb[region] = nb[region] == undefined ? 0 : nb[region]+1;
33846 if (!i.background) {
33847 abn[region] = nb[region] ;
33854 // make the last non-background panel active..
33855 //if (nb) { Roo.log(abn); }
33858 for(var r in abn) {
33859 region = this.getRegion(r);
33861 // tried using nb[r], but it does not work..
33863 region.showPanel(abn[r]);
33874 factory : function(cfg)
33877 var validRegions = Roo.bootstrap.layout.Border.regions;
33879 var target = cfg.region;
33882 var r = Roo.bootstrap.layout;
33886 return new r.North(cfg);
33888 return new r.South(cfg);
33890 return new r.East(cfg);
33892 return new r.West(cfg);
33894 return new r.Center(cfg);
33896 throw 'Layout region "'+target+'" not supported.';
33903 * Ext JS Library 1.1.1
33904 * Copyright(c) 2006-2007, Ext JS, LLC.
33906 * Originally Released Under LGPL - original licence link has changed is not relivant.
33909 * <script type="text/javascript">
33913 * @class Roo.bootstrap.layout.Basic
33914 * @extends Roo.util.Observable
33915 * This class represents a lightweight region in a layout manager. This region does not move dom nodes
33916 * and does not have a titlebar, tabs or any other features. All it does is size and position
33917 * panels. To create a BasicLayoutRegion, add lightweight:true or basic:true to your regions config.
33918 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
33919 * @cfg {string} region the region that it inhabits..
33920 * @cfg {bool} skipConfig skip config?
33924 Roo.bootstrap.layout.Basic = function(config){
33926 this.mgr = config.mgr;
33928 this.position = config.region;
33930 var skipConfig = config.skipConfig;
33934 * @scope Roo.BasicLayoutRegion
33938 * @event beforeremove
33939 * Fires before a panel is removed (or closed). To cancel the removal set "e.cancel = true" on the event argument.
33940 * @param {Roo.LayoutRegion} this
33941 * @param {Roo.ContentPanel} panel The panel
33942 * @param {Object} e The cancel event object
33944 "beforeremove" : true,
33946 * @event invalidated
33947 * Fires when the layout for this region is changed.
33948 * @param {Roo.LayoutRegion} this
33950 "invalidated" : true,
33952 * @event visibilitychange
33953 * Fires when this region is shown or hidden
33954 * @param {Roo.LayoutRegion} this
33955 * @param {Boolean} visibility true or false
33957 "visibilitychange" : true,
33959 * @event paneladded
33960 * Fires when a panel is added.
33961 * @param {Roo.LayoutRegion} this
33962 * @param {Roo.ContentPanel} panel The panel
33964 "paneladded" : true,
33966 * @event panelremoved
33967 * Fires when a panel is removed.
33968 * @param {Roo.LayoutRegion} this
33969 * @param {Roo.ContentPanel} panel The panel
33971 "panelremoved" : true,
33973 * @event beforecollapse
33974 * Fires when this region before collapse.
33975 * @param {Roo.LayoutRegion} this
33977 "beforecollapse" : true,
33980 * Fires when this region is collapsed.
33981 * @param {Roo.LayoutRegion} this
33983 "collapsed" : true,
33986 * Fires when this region is expanded.
33987 * @param {Roo.LayoutRegion} this
33992 * Fires when this region is slid into view.
33993 * @param {Roo.LayoutRegion} this
33995 "slideshow" : true,
33998 * Fires when this region slides out of view.
33999 * @param {Roo.LayoutRegion} this
34001 "slidehide" : true,
34003 * @event panelactivated
34004 * Fires when a panel is activated.
34005 * @param {Roo.LayoutRegion} this
34006 * @param {Roo.ContentPanel} panel The activated panel
34008 "panelactivated" : true,
34011 * Fires when the user resizes this region.
34012 * @param {Roo.LayoutRegion} this
34013 * @param {Number} newSize The new size (width for east/west, height for north/south)
34017 /** A collection of panels in this region. @type Roo.util.MixedCollection */
34018 this.panels = new Roo.util.MixedCollection();
34019 this.panels.getKey = this.getPanelId.createDelegate(this);
34021 this.activePanel = null;
34022 // ensure listeners are added...
34024 if (config.listeners || config.events) {
34025 Roo.bootstrap.layout.Basic.superclass.constructor.call(this, {
34026 listeners : config.listeners || {},
34027 events : config.events || {}
34031 if(skipConfig !== true){
34032 this.applyConfig(config);
34036 Roo.extend(Roo.bootstrap.layout.Basic, Roo.util.Observable,
34038 getPanelId : function(p){
34042 applyConfig : function(config){
34043 this.margins = config.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
34044 this.config = config;
34049 * Resizes the region to the specified size. For vertical regions (west, east) this adjusts
34050 * the width, for horizontal (north, south) the height.
34051 * @param {Number} newSize The new width or height
34053 resizeTo : function(newSize){
34054 var el = this.el ? this.el :
34055 (this.activePanel ? this.activePanel.getEl() : null);
34057 switch(this.position){
34060 el.setWidth(newSize);
34061 this.fireEvent("resized", this, newSize);
34065 el.setHeight(newSize);
34066 this.fireEvent("resized", this, newSize);
34072 getBox : function(){
34073 return this.activePanel ? this.activePanel.getEl().getBox(false, true) : null;
34076 getMargins : function(){
34077 return this.margins;
34080 updateBox : function(box){
34082 var el = this.activePanel.getEl();
34083 el.dom.style.left = box.x + "px";
34084 el.dom.style.top = box.y + "px";
34085 this.activePanel.setSize(box.width, box.height);
34089 * Returns the container element for this region.
34090 * @return {Roo.Element}
34092 getEl : function(){
34093 return this.activePanel;
34097 * Returns true if this region is currently visible.
34098 * @return {Boolean}
34100 isVisible : function(){
34101 return this.activePanel ? true : false;
34104 setActivePanel : function(panel){
34105 panel = this.getPanel(panel);
34106 if(this.activePanel && this.activePanel != panel){
34107 this.activePanel.setActiveState(false);
34108 this.activePanel.getEl().setLeftTop(-10000,-10000);
34110 this.activePanel = panel;
34111 panel.setActiveState(true);
34113 panel.setSize(this.box.width, this.box.height);
34115 this.fireEvent("panelactivated", this, panel);
34116 this.fireEvent("invalidated");
34120 * Show the specified panel.
34121 * @param {Number/String/ContentPanel} panelId The panels index, id or the panel itself
34122 * @return {Roo.ContentPanel} The shown panel or null
34124 showPanel : function(panel){
34125 panel = this.getPanel(panel);
34127 this.setActivePanel(panel);
34133 * Get the active panel for this region.
34134 * @return {Roo.ContentPanel} The active panel or null
34136 getActivePanel : function(){
34137 return this.activePanel;
34141 * Add the passed ContentPanel(s)
34142 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
34143 * @return {Roo.ContentPanel} The panel added (if only one was added)
34145 add : function(panel){
34146 if(arguments.length > 1){
34147 for(var i = 0, len = arguments.length; i < len; i++) {
34148 this.add(arguments[i]);
34152 if(this.hasPanel(panel)){
34153 this.showPanel(panel);
34156 var el = panel.getEl();
34157 if(el.dom.parentNode != this.mgr.el.dom){
34158 this.mgr.el.dom.appendChild(el.dom);
34160 if(panel.setRegion){
34161 panel.setRegion(this);
34163 this.panels.add(panel);
34164 el.setStyle("position", "absolute");
34165 if(!panel.background){
34166 this.setActivePanel(panel);
34167 if(this.config.initialSize && this.panels.getCount()==1){
34168 this.resizeTo(this.config.initialSize);
34171 this.fireEvent("paneladded", this, panel);
34176 * Returns true if the panel is in this region.
34177 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
34178 * @return {Boolean}
34180 hasPanel : function(panel){
34181 if(typeof panel == "object"){ // must be panel obj
34182 panel = panel.getId();
34184 return this.getPanel(panel) ? true : false;
34188 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
34189 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
34190 * @param {Boolean} preservePanel Overrides the config preservePanel option
34191 * @return {Roo.ContentPanel} The panel that was removed
34193 remove : function(panel, preservePanel){
34194 panel = this.getPanel(panel);
34199 this.fireEvent("beforeremove", this, panel, e);
34200 if(e.cancel === true){
34203 var panelId = panel.getId();
34204 this.panels.removeKey(panelId);
34209 * Returns the panel specified or null if it's not in this region.
34210 * @param {Number/String/ContentPanel} panel The panels index, id or the panel itself
34211 * @return {Roo.ContentPanel}
34213 getPanel : function(id){
34214 if(typeof id == "object"){ // must be panel obj
34217 return this.panels.get(id);
34221 * Returns this regions position (north/south/east/west/center).
34224 getPosition: function(){
34225 return this.position;
34229 * Ext JS Library 1.1.1
34230 * Copyright(c) 2006-2007, Ext JS, LLC.
34232 * Originally Released Under LGPL - original licence link has changed is not relivant.
34235 * <script type="text/javascript">
34239 * @class Roo.bootstrap.layout.Region
34240 * @extends Roo.bootstrap.layout.Basic
34241 * This class represents a region in a layout manager.
34243 * @cfg {Object} margins Margins for the element (defaults to {top: 0, left: 0, right:0, bottom: 0})
34244 * @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})
34245 * @cfg {String} tabPosition (top|bottom) "top" or "bottom" (defaults to "bottom")
34246 * @cfg {Boolean} alwaysShowTabs True to always display tabs even when there is only 1 panel (defaults to false)
34247 * @cfg {Boolean} autoScroll True to enable overflow scrolling (defaults to false)
34248 * @cfg {Boolean} titlebar True to display a title bar (defaults to true)
34249 * @cfg {String} title The title for the region (overrides panel titles)
34250 * @cfg {Boolean} animate True to animate expand/collapse (defaults to false)
34251 * @cfg {Boolean} autoHide False to disable auto hiding when the mouse leaves the "floated" region (defaults to true)
34252 * @cfg {Boolean} preservePanels True to preserve removed panels so they can be readded later (defaults to false)
34253 * @cfg {Boolean} closeOnTab True to place the close icon on the tabs instead of the region titlebar (defaults to false)
34254 * @cfg {Boolean} hideTabs True to hide the tab strip (defaults to false)
34255 * @cfg {Boolean} resizeTabs True to enable automatic tab resizing. This will resize the tabs so they are all the same size and fit within
34256 * the space available, similar to FireFox 1.5 tabs (defaults to false)
34257 * @cfg {Number} minTabWidth The minimum tab width (defaults to 40)
34258 * @cfg {Number} preferredTabWidth The preferred tab width (defaults to 150)
34259 * @cfg {String} overflow (hidden|visible) if you have menus in the region, then you need to set this to visible.
34261 * @cfg {Boolean} hidden True to start the region hidden (defaults to false)
34262 * @cfg {Boolean} hideWhenEmpty True to hide the region when it has no panels
34263 * @cfg {Boolean} disableTabTips True to disable tab tooltips
34264 * @cfg {Number} width For East/West panels
34265 * @cfg {Number} height For North/South panels
34266 * @cfg {Boolean} split To show the splitter
34267 * @cfg {Boolean} toolbar xtype configuration for a toolbar - shows on right of tabbar
34269 * @cfg {string} cls Extra CSS classes to add to region
34271 * @cfg {Roo.bootstrap.layout.Manager} mgr The manager
34272 * @cfg {string} region the region that it inhabits..
34275 * @xxxcfg {Boolean} collapsible DISABLED False to disable collapsing (defaults to true)
34276 * @xxxcfg {Boolean} collapsed DISABLED True to set the initial display to collapsed (defaults to false)
34278 * @xxxcfg {String} collapsedTitle DISABLED Optional string message to display in the collapsed block of a north or south region
34279 * @xxxxcfg {Boolean} floatable DISABLED False to disable floating (defaults to true)
34280 * @xxxxcfg {Boolean} showPin True to show a pin button NOT SUPPORTED YET
34282 Roo.bootstrap.layout.Region = function(config)
34284 this.applyConfig(config);
34286 var mgr = config.mgr;
34287 var pos = config.region;
34288 config.skipConfig = true;
34289 Roo.bootstrap.layout.Region.superclass.constructor.call(this, config);
34292 this.onRender(mgr.el);
34295 this.visible = true;
34296 this.collapsed = false;
34297 this.unrendered_panels = [];
34300 Roo.extend(Roo.bootstrap.layout.Region, Roo.bootstrap.layout.Basic, {
34302 position: '', // set by wrapper (eg. north/south etc..)
34303 unrendered_panels : null, // unrendered panels.
34304 createBody : function(){
34305 /** This region's body element
34306 * @type Roo.Element */
34307 this.bodyEl = this.el.createChild({
34309 cls: "roo-layout-panel-body tab-content" // bootstrap added...
34313 onRender: function(ctr, pos)
34315 var dh = Roo.DomHelper;
34316 /** This region's container element
34317 * @type Roo.Element */
34318 this.el = dh.append(ctr.dom, {
34320 cls: (this.config.cls || '') + " roo-layout-region roo-layout-panel roo-layout-panel-" + this.position
34322 /** This region's title element
34323 * @type Roo.Element */
34325 this.titleEl = dh.append(this.el.dom,
34328 unselectable: "on",
34329 cls: "roo-unselectable roo-layout-panel-hd breadcrumb roo-layout-title-" + this.position,
34331 {tag: "span", cls: "roo-unselectable roo-layout-panel-hd-text", unselectable: "on", html: " "},
34332 {tag: "div", cls: "roo-unselectable roo-layout-panel-hd-tools", unselectable: "on"}
34335 this.titleEl.enableDisplayMode();
34336 /** This region's title text element
34337 * @type HTMLElement */
34338 this.titleTextEl = this.titleEl.dom.firstChild;
34339 this.tools = Roo.get(this.titleEl.dom.childNodes[1], true);
34341 this.closeBtn = this.createTool(this.tools.dom, "roo-layout-close");
34342 this.closeBtn.enableDisplayMode();
34343 this.closeBtn.on("click", this.closeClicked, this);
34344 this.closeBtn.hide();
34346 this.createBody(this.config);
34347 if(this.config.hideWhenEmpty){
34349 this.on("paneladded", this.validateVisibility, this);
34350 this.on("panelremoved", this.validateVisibility, this);
34352 if(this.autoScroll){
34353 this.bodyEl.setStyle("overflow", "auto");
34355 this.bodyEl.setStyle("overflow", this.config.overflow || 'hidden');
34357 //if(c.titlebar !== false){
34358 if((!this.config.titlebar && !this.config.title) || this.config.titlebar === false){
34359 this.titleEl.hide();
34361 this.titleEl.show();
34362 if(this.config.title){
34363 this.titleTextEl.innerHTML = this.config.title;
34367 if(this.config.collapsed){
34368 this.collapse(true);
34370 if(this.config.hidden){
34374 if (this.unrendered_panels && this.unrendered_panels.length) {
34375 for (var i =0;i< this.unrendered_panels.length; i++) {
34376 this.add(this.unrendered_panels[i]);
34378 this.unrendered_panels = null;
34384 applyConfig : function(c)
34387 *if(c.collapsible && this.position != "center" && !this.collapsedEl){
34388 var dh = Roo.DomHelper;
34389 if(c.titlebar !== false){
34390 this.collapseBtn = this.createTool(this.tools.dom, "roo-layout-collapse-"+this.position);
34391 this.collapseBtn.on("click", this.collapse, this);
34392 this.collapseBtn.enableDisplayMode();
34394 if(c.showPin === true || this.showPin){
34395 this.stickBtn = this.createTool(this.tools.dom, "roo-layout-stick");
34396 this.stickBtn.enableDisplayMode();
34397 this.stickBtn.on("click", this.expand, this);
34398 this.stickBtn.hide();
34403 /** This region's collapsed element
34404 * @type Roo.Element */
34407 this.collapsedEl = dh.append(this.mgr.el.dom, {cls: "x-layout-collapsed x-layout-collapsed-"+this.position, children:[
34408 {cls: "x-layout-collapsed-tools", children:[{cls: "x-layout-ctools-inner"}]}
34411 if(c.floatable !== false){
34412 this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
34413 this.collapsedEl.on("click", this.collapseClick, this);
34416 if(c.collapsedTitle && (this.position == "north" || this.position== "south")) {
34417 this.collapsedTitleTextEl = dh.append(this.collapsedEl.dom, {tag: "div", cls: "x-unselectable x-layout-panel-hd-text",
34418 id: "message", unselectable: "on", style:{"float":"left"}});
34419 this.collapsedTitleTextEl.innerHTML = c.collapsedTitle;
34421 this.expandBtn = this.createTool(this.collapsedEl.dom.firstChild.firstChild, "x-layout-expand-"+this.position);
34422 this.expandBtn.on("click", this.expand, this);
34426 if(this.collapseBtn){
34427 this.collapseBtn.setVisible(c.collapsible == true);
34430 this.cmargins = c.cmargins || this.cmargins ||
34431 (this.position == "west" || this.position == "east" ?
34432 {top: 0, left: 2, right:2, bottom: 0} :
34433 {top: 2, left: 0, right:0, bottom: 2});
34435 this.margins = c.margins || this.margins || {top: 0, left: 0, right:0, bottom: 0};
34438 this.bottomTabs = c.tabPosition != "top";
34440 this.autoScroll = c.autoScroll || false;
34445 this.duration = c.duration || .30;
34446 this.slideDuration = c.slideDuration || .45;
34451 * Returns true if this region is currently visible.
34452 * @return {Boolean}
34454 isVisible : function(){
34455 return this.visible;
34459 * Updates the title for collapsed north/south regions (used with {@link #collapsedTitle} config option)
34460 * @param {String} title (optional) The title text (accepts HTML markup, defaults to the numeric character reference for a non-breaking space, "&#160;")
34462 //setCollapsedTitle : function(title){
34463 // title = title || " ";
34464 // if(this.collapsedTitleTextEl){
34465 // this.collapsedTitleTextEl.innerHTML = title;
34469 getBox : function(){
34471 // if(!this.collapsed){
34472 b = this.el.getBox(false, true);
34474 // b = this.collapsedEl.getBox(false, true);
34479 getMargins : function(){
34480 return this.margins;
34481 //return this.collapsed ? this.cmargins : this.margins;
34484 highlight : function(){
34485 this.el.addClass("x-layout-panel-dragover");
34488 unhighlight : function(){
34489 this.el.removeClass("x-layout-panel-dragover");
34492 updateBox : function(box)
34494 if (!this.bodyEl) {
34495 return; // not rendered yet..
34499 if(!this.collapsed){
34500 this.el.dom.style.left = box.x + "px";
34501 this.el.dom.style.top = box.y + "px";
34502 this.updateBody(box.width, box.height);
34504 this.collapsedEl.dom.style.left = box.x + "px";
34505 this.collapsedEl.dom.style.top = box.y + "px";
34506 this.collapsedEl.setSize(box.width, box.height);
34509 this.tabs.autoSizeTabs();
34513 updateBody : function(w, h)
34516 this.el.setWidth(w);
34517 w -= this.el.getBorderWidth("rl");
34518 if(this.config.adjustments){
34519 w += this.config.adjustments[0];
34522 if(h !== null && h > 0){
34523 this.el.setHeight(h);
34524 h = this.titleEl && this.titleEl.isDisplayed() ? h - (this.titleEl.getHeight()||0) : h;
34525 h -= this.el.getBorderWidth("tb");
34526 if(this.config.adjustments){
34527 h += this.config.adjustments[1];
34529 this.bodyEl.setHeight(h);
34531 h = this.tabs.syncHeight(h);
34534 if(this.panelSize){
34535 w = w !== null ? w : this.panelSize.width;
34536 h = h !== null ? h : this.panelSize.height;
34538 if(this.activePanel){
34539 var el = this.activePanel.getEl();
34540 w = w !== null ? w : el.getWidth();
34541 h = h !== null ? h : el.getHeight();
34542 this.panelSize = {width: w, height: h};
34543 this.activePanel.setSize(w, h);
34545 if(Roo.isIE && this.tabs){
34546 this.tabs.el.repaint();
34551 * Returns the container element for this region.
34552 * @return {Roo.Element}
34554 getEl : function(){
34559 * Hides this region.
34562 //if(!this.collapsed){
34563 this.el.dom.style.left = "-2000px";
34566 // this.collapsedEl.dom.style.left = "-2000px";
34567 // this.collapsedEl.hide();
34569 this.visible = false;
34570 this.fireEvent("visibilitychange", this, false);
34574 * Shows this region if it was previously hidden.
34577 //if(!this.collapsed){
34580 // this.collapsedEl.show();
34582 this.visible = true;
34583 this.fireEvent("visibilitychange", this, true);
34586 closeClicked : function(){
34587 if(this.activePanel){
34588 this.remove(this.activePanel);
34592 collapseClick : function(e){
34594 e.stopPropagation();
34597 e.stopPropagation();
34603 * Collapses this region.
34604 * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true)
34607 collapse : function(skipAnim, skipCheck = false){
34608 if(this.collapsed) {
34612 if(skipCheck || this.fireEvent("beforecollapse", this) != false){
34614 this.collapsed = true;
34616 this.split.el.hide();
34618 if(this.config.animate && skipAnim !== true){
34619 this.fireEvent("invalidated", this);
34620 this.animateCollapse();
34622 this.el.setLocation(-20000,-20000);
34624 this.collapsedEl.show();
34625 this.fireEvent("collapsed", this);
34626 this.fireEvent("invalidated", this);
34632 animateCollapse : function(){
34637 * Expands this region if it was previously collapsed.
34638 * @param {Roo.EventObject} e The event that triggered the expand (or null if calling manually)
34639 * @param {Boolean} skipAnim (optional) true to expand the element without animation (if animate is true)
34642 expand : function(e, skipAnim){
34644 e.stopPropagation();
34646 if(!this.collapsed || this.el.hasActiveFx()) {
34650 this.afterSlideIn();
34653 this.collapsed = false;
34654 if(this.config.animate && skipAnim !== true){
34655 this.animateExpand();
34659 this.split.el.show();
34661 this.collapsedEl.setLocation(-2000,-2000);
34662 this.collapsedEl.hide();
34663 this.fireEvent("invalidated", this);
34664 this.fireEvent("expanded", this);
34668 animateExpand : function(){
34672 initTabs : function()
34674 //this.bodyEl.setStyle("overflow", "hidden"); -- this is set in render?
34676 var ts = new Roo.bootstrap.panel.Tabs({
34677 el: this.bodyEl.dom,
34678 tabPosition: this.bottomTabs ? 'bottom' : 'top',
34679 disableTooltips: this.config.disableTabTips,
34680 toolbar : this.config.toolbar
34683 if(this.config.hideTabs){
34684 ts.stripWrap.setDisplayed(false);
34687 ts.resizeTabs = this.config.resizeTabs === true;
34688 ts.minTabWidth = this.config.minTabWidth || 40;
34689 ts.maxTabWidth = this.config.maxTabWidth || 250;
34690 ts.preferredTabWidth = this.config.preferredTabWidth || 150;
34691 ts.monitorResize = false;
34692 //ts.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden"); // this is set in render?
34693 ts.bodyEl.addClass('roo-layout-tabs-body');
34694 this.panels.each(this.initPanelAsTab, this);
34697 initPanelAsTab : function(panel){
34698 var ti = this.tabs.addTab(
34702 this.config.closeOnTab && panel.isClosable(),
34705 if(panel.tabTip !== undefined){
34706 ti.setTooltip(panel.tabTip);
34708 ti.on("activate", function(){
34709 this.setActivePanel(panel);
34712 if(this.config.closeOnTab){
34713 ti.on("beforeclose", function(t, e){
34715 this.remove(panel);
34719 panel.tabItem = ti;
34724 updatePanelTitle : function(panel, title)
34726 if(this.activePanel == panel){
34727 this.updateTitle(title);
34730 var ti = this.tabs.getTab(panel.getEl().id);
34732 if(panel.tabTip !== undefined){
34733 ti.setTooltip(panel.tabTip);
34738 updateTitle : function(title){
34739 if(this.titleTextEl && !this.config.title){
34740 this.titleTextEl.innerHTML = (typeof title != "undefined" && title.length > 0 ? title : " ");
34744 setActivePanel : function(panel)
34746 panel = this.getPanel(panel);
34747 if(this.activePanel && this.activePanel != panel){
34748 this.activePanel.setActiveState(false);
34750 this.activePanel = panel;
34751 panel.setActiveState(true);
34752 if(this.panelSize){
34753 panel.setSize(this.panelSize.width, this.panelSize.height);
34756 this.closeBtn.setVisible(!this.config.closeOnTab && !this.isSlid && panel.isClosable());
34758 this.updateTitle(panel.getTitle());
34760 this.fireEvent("invalidated", this);
34762 this.fireEvent("panelactivated", this, panel);
34766 * Shows the specified panel.
34767 * @param {Number/String/ContentPanel} panelId The panel's index, id or the panel itself
34768 * @return {Roo.ContentPanel} The shown panel, or null if a panel could not be found from panelId
34770 showPanel : function(panel)
34772 panel = this.getPanel(panel);
34775 var tab = this.tabs.getTab(panel.getEl().id);
34776 if(tab.isHidden()){
34777 this.tabs.unhideTab(tab.id);
34781 this.setActivePanel(panel);
34788 * Get the active panel for this region.
34789 * @return {Roo.ContentPanel} The active panel or null
34791 getActivePanel : function(){
34792 return this.activePanel;
34795 validateVisibility : function(){
34796 if(this.panels.getCount() < 1){
34797 this.updateTitle(" ");
34798 this.closeBtn.hide();
34801 if(!this.isVisible()){
34808 * Adds the passed ContentPanel(s) to this region.
34809 * @param {ContentPanel...} panel The ContentPanel(s) to add (you can pass more than one)
34810 * @return {Roo.ContentPanel} The panel added (if only one was added; null otherwise)
34812 add : function(panel)
34814 if(arguments.length > 1){
34815 for(var i = 0, len = arguments.length; i < len; i++) {
34816 this.add(arguments[i]);
34821 // if we have not been rendered yet, then we can not really do much of this..
34822 if (!this.bodyEl) {
34823 this.unrendered_panels.push(panel);
34830 if(this.hasPanel(panel)){
34831 this.showPanel(panel);
34834 panel.setRegion(this);
34835 this.panels.add(panel);
34836 /* if(this.panels.getCount() == 1 && !this.config.alwaysShowTabs){
34837 // sinle panel - no tab...?? would it not be better to render it with the tabs,
34838 // and hide them... ???
34839 this.bodyEl.dom.appendChild(panel.getEl().dom);
34840 if(panel.background !== true){
34841 this.setActivePanel(panel);
34843 this.fireEvent("paneladded", this, panel);
34850 this.initPanelAsTab(panel);
34854 if(panel.background !== true){
34855 this.tabs.activate(panel.getEl().id);
34857 this.fireEvent("paneladded", this, panel);
34862 * Hides the tab for the specified panel.
34863 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
34865 hidePanel : function(panel){
34866 if(this.tabs && (panel = this.getPanel(panel))){
34867 this.tabs.hideTab(panel.getEl().id);
34872 * Unhides the tab for a previously hidden panel.
34873 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
34875 unhidePanel : function(panel){
34876 if(this.tabs && (panel = this.getPanel(panel))){
34877 this.tabs.unhideTab(panel.getEl().id);
34881 clearPanels : function(){
34882 while(this.panels.getCount() > 0){
34883 this.remove(this.panels.first());
34888 * Removes the specified panel. If preservePanel is not true (either here or in the config), the panel is destroyed.
34889 * @param {Number/String/ContentPanel} panel The panel's index, id or the panel itself
34890 * @param {Boolean} preservePanel Overrides the config preservePanel option
34891 * @return {Roo.ContentPanel} The panel that was removed
34893 remove : function(panel, preservePanel)
34895 panel = this.getPanel(panel);
34900 this.fireEvent("beforeremove", this, panel, e);
34901 if(e.cancel === true){
34904 preservePanel = (typeof preservePanel != "undefined" ? preservePanel : (this.config.preservePanels === true || panel.preserve === true));
34905 var panelId = panel.getId();
34906 this.panels.removeKey(panelId);
34908 document.body.appendChild(panel.getEl().dom);
34911 this.tabs.removeTab(panel.getEl().id);
34912 }else if (!preservePanel){
34913 this.bodyEl.dom.removeChild(panel.getEl().dom);
34915 if(this.panels.getCount() == 1 && this.tabs && !this.config.alwaysShowTabs){
34916 var p = this.panels.first();
34917 var tempEl = document.createElement("div"); // temp holder to keep IE from deleting the node
34918 tempEl.appendChild(p.getEl().dom);
34919 this.bodyEl.update("");
34920 this.bodyEl.dom.appendChild(p.getEl().dom);
34922 this.updateTitle(p.getTitle());
34924 this.bodyEl.setStyle("overflow", this.config.autoScroll ? "auto" : "hidden");
34925 this.setActivePanel(p);
34927 panel.setRegion(null);
34928 if(this.activePanel == panel){
34929 this.activePanel = null;
34931 if(this.config.autoDestroy !== false && preservePanel !== true){
34932 try{panel.destroy();}catch(e){}
34934 this.fireEvent("panelremoved", this, panel);
34939 * Returns the TabPanel component used by this region
34940 * @return {Roo.TabPanel}
34942 getTabs : function(){
34946 createTool : function(parentEl, className){
34947 var btn = Roo.DomHelper.append(parentEl, {
34949 cls: "x-layout-tools-button",
34952 cls: "roo-layout-tools-button-inner " + className,
34956 btn.addClassOnOver("roo-layout-tools-button-over");
34961 * Ext JS Library 1.1.1
34962 * Copyright(c) 2006-2007, Ext JS, LLC.
34964 * Originally Released Under LGPL - original licence link has changed is not relivant.
34967 * <script type="text/javascript">
34973 * @class Roo.SplitLayoutRegion
34974 * @extends Roo.LayoutRegion
34975 * Adds a splitbar and other (private) useful functionality to a {@link Roo.LayoutRegion}.
34977 Roo.bootstrap.layout.Split = function(config){
34978 this.cursor = config.cursor;
34979 Roo.bootstrap.layout.Split.superclass.constructor.call(this, config);
34982 Roo.extend(Roo.bootstrap.layout.Split, Roo.bootstrap.layout.Region,
34984 splitTip : "Drag to resize.",
34985 collapsibleSplitTip : "Drag to resize. Double click to hide.",
34986 useSplitTips : false,
34988 applyConfig : function(config){
34989 Roo.bootstrap.layout.Split.superclass.applyConfig.call(this, config);
34992 onRender : function(ctr,pos) {
34994 Roo.bootstrap.layout.Split.superclass.onRender.call(this, ctr,pos);
34995 if(!this.config.split){
35000 var splitEl = Roo.DomHelper.append(ctr.dom, {
35002 id: this.el.id + "-split",
35003 cls: "roo-layout-split roo-layout-split-"+this.position,
35006 /** The SplitBar for this region
35007 * @type Roo.SplitBar */
35008 // does not exist yet...
35009 Roo.log([this.position, this.orientation]);
35011 this.split = new Roo.bootstrap.SplitBar({
35012 dragElement : splitEl,
35013 resizingElement: this.el,
35014 orientation : this.orientation
35017 this.split.on("moved", this.onSplitMove, this);
35018 this.split.useShim = this.config.useShim === true;
35019 this.split.getMaximumSize = this[this.position == 'north' || this.position == 'south' ? 'getVMaxSize' : 'getHMaxSize'].createDelegate(this);
35020 if(this.useSplitTips){
35021 this.split.el.dom.title = this.config.collapsible ? this.collapsibleSplitTip : this.splitTip;
35023 //if(config.collapsible){
35024 // this.split.el.on("dblclick", this.collapse, this);
35027 if(typeof this.config.minSize != "undefined"){
35028 this.split.minSize = this.config.minSize;
35030 if(typeof this.config.maxSize != "undefined"){
35031 this.split.maxSize = this.config.maxSize;
35033 if(this.config.hideWhenEmpty || this.config.hidden || this.config.collapsed){
35034 this.hideSplitter();
35039 getHMaxSize : function(){
35040 var cmax = this.config.maxSize || 10000;
35041 var center = this.mgr.getRegion("center");
35042 return Math.min(cmax, (this.el.getWidth()+center.getEl().getWidth())-center.getMinWidth());
35045 getVMaxSize : function(){
35046 var cmax = this.config.maxSize || 10000;
35047 var center = this.mgr.getRegion("center");
35048 return Math.min(cmax, (this.el.getHeight()+center.getEl().getHeight())-center.getMinHeight());
35051 onSplitMove : function(split, newSize){
35052 this.fireEvent("resized", this, newSize);
35056 * Returns the {@link Roo.SplitBar} for this region.
35057 * @return {Roo.SplitBar}
35059 getSplitBar : function(){
35064 this.hideSplitter();
35065 Roo.bootstrap.layout.Split.superclass.hide.call(this);
35068 hideSplitter : function(){
35070 this.split.el.setLocation(-2000,-2000);
35071 this.split.el.hide();
35077 this.split.el.show();
35079 Roo.bootstrap.layout.Split.superclass.show.call(this);
35082 beforeSlide: function(){
35083 if(Roo.isGecko){// firefox overflow auto bug workaround
35084 this.bodyEl.clip();
35086 this.tabs.bodyEl.clip();
35088 if(this.activePanel){
35089 this.activePanel.getEl().clip();
35091 if(this.activePanel.beforeSlide){
35092 this.activePanel.beforeSlide();
35098 afterSlide : function(){
35099 if(Roo.isGecko){// firefox overflow auto bug workaround
35100 this.bodyEl.unclip();
35102 this.tabs.bodyEl.unclip();
35104 if(this.activePanel){
35105 this.activePanel.getEl().unclip();
35106 if(this.activePanel.afterSlide){
35107 this.activePanel.afterSlide();
35113 initAutoHide : function(){
35114 if(this.autoHide !== false){
35115 if(!this.autoHideHd){
35116 var st = new Roo.util.DelayedTask(this.slideIn, this);
35117 this.autoHideHd = {
35118 "mouseout": function(e){
35119 if(!e.within(this.el, true)){
35123 "mouseover" : function(e){
35129 this.el.on(this.autoHideHd);
35133 clearAutoHide : function(){
35134 if(this.autoHide !== false){
35135 this.el.un("mouseout", this.autoHideHd.mouseout);
35136 this.el.un("mouseover", this.autoHideHd.mouseover);
35140 clearMonitor : function(){
35141 Roo.get(document).un("click", this.slideInIf, this);
35144 // these names are backwards but not changed for compat
35145 slideOut : function(){
35146 if(this.isSlid || this.el.hasActiveFx()){
35149 this.isSlid = true;
35150 if(this.collapseBtn){
35151 this.collapseBtn.hide();
35153 this.closeBtnState = this.closeBtn.getStyle('display');
35154 this.closeBtn.hide();
35156 this.stickBtn.show();
35159 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
35160 this.beforeSlide();
35161 this.el.setStyle("z-index", 10001);
35162 this.el.slideIn(this.getSlideAnchor(), {
35163 callback: function(){
35165 this.initAutoHide();
35166 Roo.get(document).on("click", this.slideInIf, this);
35167 this.fireEvent("slideshow", this);
35174 afterSlideIn : function(){
35175 this.clearAutoHide();
35176 this.isSlid = false;
35177 this.clearMonitor();
35178 this.el.setStyle("z-index", "");
35179 if(this.collapseBtn){
35180 this.collapseBtn.show();
35182 this.closeBtn.setStyle('display', this.closeBtnState);
35184 this.stickBtn.hide();
35186 this.fireEvent("slidehide", this);
35189 slideIn : function(cb){
35190 if(!this.isSlid || this.el.hasActiveFx()){
35194 this.isSlid = false;
35195 this.beforeSlide();
35196 this.el.slideOut(this.getSlideAnchor(), {
35197 callback: function(){
35198 this.el.setLeftTop(-10000, -10000);
35200 this.afterSlideIn();
35208 slideInIf : function(e){
35209 if(!e.within(this.el)){
35214 animateCollapse : function(){
35215 this.beforeSlide();
35216 this.el.setStyle("z-index", 20000);
35217 var anchor = this.getSlideAnchor();
35218 this.el.slideOut(anchor, {
35219 callback : function(){
35220 this.el.setStyle("z-index", "");
35221 this.collapsedEl.slideIn(anchor, {duration:.3});
35223 this.el.setLocation(-10000,-10000);
35225 this.fireEvent("collapsed", this);
35232 animateExpand : function(){
35233 this.beforeSlide();
35234 this.el.alignTo(this.collapsedEl, this.getCollapseAnchor(), this.getExpandAdj());
35235 this.el.setStyle("z-index", 20000);
35236 this.collapsedEl.hide({
35239 this.el.slideIn(this.getSlideAnchor(), {
35240 callback : function(){
35241 this.el.setStyle("z-index", "");
35244 this.split.el.show();
35246 this.fireEvent("invalidated", this);
35247 this.fireEvent("expanded", this);
35275 getAnchor : function(){
35276 return this.anchors[this.position];
35279 getCollapseAnchor : function(){
35280 return this.canchors[this.position];
35283 getSlideAnchor : function(){
35284 return this.sanchors[this.position];
35287 getAlignAdj : function(){
35288 var cm = this.cmargins;
35289 switch(this.position){
35305 getExpandAdj : function(){
35306 var c = this.collapsedEl, cm = this.cmargins;
35307 switch(this.position){
35309 return [-(cm.right+c.getWidth()+cm.left), 0];
35312 return [cm.right+c.getWidth()+cm.left, 0];
35315 return [0, -(cm.top+cm.bottom+c.getHeight())];
35318 return [0, cm.top+cm.bottom+c.getHeight()];
35324 * Ext JS Library 1.1.1
35325 * Copyright(c) 2006-2007, Ext JS, LLC.
35327 * Originally Released Under LGPL - original licence link has changed is not relivant.
35330 * <script type="text/javascript">
35333 * These classes are private internal classes
35335 Roo.bootstrap.layout.Center = function(config){
35336 config.region = "center";
35337 Roo.bootstrap.layout.Region.call(this, config);
35338 this.visible = true;
35339 this.minWidth = config.minWidth || 20;
35340 this.minHeight = config.minHeight || 20;
35343 Roo.extend(Roo.bootstrap.layout.Center, Roo.bootstrap.layout.Region, {
35345 // center panel can't be hidden
35349 // center panel can't be hidden
35352 getMinWidth: function(){
35353 return this.minWidth;
35356 getMinHeight: function(){
35357 return this.minHeight;
35370 Roo.bootstrap.layout.North = function(config)
35372 config.region = 'north';
35373 config.cursor = 'n-resize';
35375 Roo.bootstrap.layout.Split.call(this, config);
35379 this.split.placement = Roo.bootstrap.SplitBar.TOP;
35380 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
35381 this.split.el.addClass("roo-layout-split-v");
35383 var size = config.initialSize || config.height;
35384 if(typeof size != "undefined"){
35385 this.el.setHeight(size);
35388 Roo.extend(Roo.bootstrap.layout.North, Roo.bootstrap.layout.Split,
35390 orientation: Roo.bootstrap.SplitBar.VERTICAL,
35394 getBox : function(){
35395 if(this.collapsed){
35396 return this.collapsedEl.getBox();
35398 var box = this.el.getBox();
35400 box.height += this.split.el.getHeight();
35405 updateBox : function(box){
35406 if(this.split && !this.collapsed){
35407 box.height -= this.split.el.getHeight();
35408 this.split.el.setLeft(box.x);
35409 this.split.el.setTop(box.y+box.height);
35410 this.split.el.setWidth(box.width);
35412 if(this.collapsed){
35413 this.updateBody(box.width, null);
35415 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
35423 Roo.bootstrap.layout.South = function(config){
35424 config.region = 'south';
35425 config.cursor = 's-resize';
35426 Roo.bootstrap.layout.Split.call(this, config);
35428 this.split.placement = Roo.bootstrap.SplitBar.BOTTOM;
35429 this.split.orientation = Roo.bootstrap.SplitBar.VERTICAL;
35430 this.split.el.addClass("roo-layout-split-v");
35432 var size = config.initialSize || config.height;
35433 if(typeof size != "undefined"){
35434 this.el.setHeight(size);
35438 Roo.extend(Roo.bootstrap.layout.South, Roo.bootstrap.layout.Split, {
35439 orientation: Roo.bootstrap.SplitBar.VERTICAL,
35440 getBox : function(){
35441 if(this.collapsed){
35442 return this.collapsedEl.getBox();
35444 var box = this.el.getBox();
35446 var sh = this.split.el.getHeight();
35453 updateBox : function(box){
35454 if(this.split && !this.collapsed){
35455 var sh = this.split.el.getHeight();
35458 this.split.el.setLeft(box.x);
35459 this.split.el.setTop(box.y-sh);
35460 this.split.el.setWidth(box.width);
35462 if(this.collapsed){
35463 this.updateBody(box.width, null);
35465 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
35469 Roo.bootstrap.layout.East = function(config){
35470 config.region = "east";
35471 config.cursor = "e-resize";
35472 Roo.bootstrap.layout.Split.call(this, config);
35474 this.split.placement = Roo.bootstrap.SplitBar.RIGHT;
35475 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
35476 this.split.el.addClass("roo-layout-split-h");
35478 var size = config.initialSize || config.width;
35479 if(typeof size != "undefined"){
35480 this.el.setWidth(size);
35483 Roo.extend(Roo.bootstrap.layout.East, Roo.bootstrap.layout.Split, {
35484 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
35485 getBox : function(){
35486 if(this.collapsed){
35487 return this.collapsedEl.getBox();
35489 var box = this.el.getBox();
35491 var sw = this.split.el.getWidth();
35498 updateBox : function(box){
35499 if(this.split && !this.collapsed){
35500 var sw = this.split.el.getWidth();
35502 this.split.el.setLeft(box.x);
35503 this.split.el.setTop(box.y);
35504 this.split.el.setHeight(box.height);
35507 if(this.collapsed){
35508 this.updateBody(null, box.height);
35510 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
35514 Roo.bootstrap.layout.West = function(config){
35515 config.region = "west";
35516 config.cursor = "w-resize";
35518 Roo.bootstrap.layout.Split.call(this, config);
35520 this.split.placement = Roo.bootstrap.SplitBar.LEFT;
35521 this.split.orientation = Roo.bootstrap.SplitBar.HORIZONTAL;
35522 this.split.el.addClass("roo-layout-split-h");
35526 Roo.extend(Roo.bootstrap.layout.West, Roo.bootstrap.layout.Split, {
35527 orientation: Roo.bootstrap.SplitBar.HORIZONTAL,
35529 onRender: function(ctr, pos)
35531 Roo.bootstrap.layout.West.superclass.onRender.call(this, ctr,pos);
35532 var size = this.config.initialSize || this.config.width;
35533 if(typeof size != "undefined"){
35534 this.el.setWidth(size);
35538 getBox : function(){
35539 if(this.collapsed){
35540 return this.collapsedEl.getBox();
35542 var box = this.el.getBox();
35544 box.width += this.split.el.getWidth();
35549 updateBox : function(box){
35550 if(this.split && !this.collapsed){
35551 var sw = this.split.el.getWidth();
35553 this.split.el.setLeft(box.x+box.width);
35554 this.split.el.setTop(box.y);
35555 this.split.el.setHeight(box.height);
35557 if(this.collapsed){
35558 this.updateBody(null, box.height);
35560 Roo.bootstrap.layout.Region.prototype.updateBox.call(this, box);
35563 Roo.namespace("Roo.bootstrap.panel");/*
35565 * Ext JS Library 1.1.1
35566 * Copyright(c) 2006-2007, Ext JS, LLC.
35568 * Originally Released Under LGPL - original licence link has changed is not relivant.
35571 * <script type="text/javascript">
35574 * @class Roo.ContentPanel
35575 * @extends Roo.util.Observable
35576 * A basic ContentPanel element.
35577 * @cfg {Boolean} fitToFrame True for this panel to adjust its size to fit when the region resizes (defaults to false)
35578 * @cfg {Boolean} fitContainer When using {@link #fitToFrame} and {@link #resizeEl}, you can also fit the parent container (defaults to false)
35579 * @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
35580 * @cfg {Boolean} closable True if the panel can be closed/removed
35581 * @cfg {Boolean} background True if the panel should not be activated when it is added (defaults to false)
35582 * @cfg {String/HTMLElement/Element} resizeEl An element to resize if {@link #fitToFrame} is true (instead of this panel's element)
35583 * @cfg {Toolbar} toolbar A toolbar for this panel
35584 * @cfg {Boolean} autoScroll True to scroll overflow in this panel (use with {@link #fitToFrame})
35585 * @cfg {String} title The title for this panel
35586 * @cfg {Array} adjustments Values to <b>add</b> to the width/height when doing a {@link #fitToFrame} (default is [0, 0])
35587 * @cfg {String} url Calls {@link #setUrl} with this value
35588 * @cfg {String} region (center|north|south|east|west) which region to put this panel on (when used with xtype constructors)
35589 * @cfg {String/Object} params When used with {@link #url}, calls {@link #setUrl} with this value
35590 * @cfg {Boolean} loadOnce When used with {@link #url}, calls {@link #setUrl} with this value
35591 * @cfg {String} content Raw content to fill content panel with (uses setContent on construction.)
35592 * @cfg {Boolean} badges render the badges
35595 * Create a new ContentPanel.
35596 * @param {String/HTMLElement/Roo.Element} el The container element for this panel
35597 * @param {String/Object} config A string to set only the title or a config object
35598 * @param {String} content (optional) Set the HTML content for this panel
35599 * @param {String} region (optional) Used by xtype constructors to add to regions. (values center,east,west,south,north)
35601 Roo.bootstrap.panel.Content = function( config){
35603 this.tpl = config.tpl || false;
35605 var el = config.el;
35606 var content = config.content;
35608 if(config.autoCreate){ // xtype is available if this is called from factory
35611 this.el = Roo.get(el);
35612 if(!this.el && config && config.autoCreate){
35613 if(typeof config.autoCreate == "object"){
35614 if(!config.autoCreate.id){
35615 config.autoCreate.id = config.id||el;
35617 this.el = Roo.DomHelper.append(document.body,
35618 config.autoCreate, true);
35620 var elcfg = { tag: "div",
35621 cls: "roo-layout-inactive-content",
35625 elcfg.html = config.html;
35629 this.el = Roo.DomHelper.append(document.body, elcfg , true);
35632 this.closable = false;
35633 this.loaded = false;
35634 this.active = false;
35637 if (config.toolbar && !config.toolbar.el && config.toolbar.xtype) {
35639 this.toolbar = new config.toolbar.xns[config.toolbar.xtype](config.toolbar);
35641 this.wrapEl = this.el; //this.el.wrap();
35643 if (config.toolbar.items) {
35644 ti = config.toolbar.items ;
35645 delete config.toolbar.items ;
35649 this.toolbar.render(this.wrapEl, 'before');
35650 for(var i =0;i < ti.length;i++) {
35651 // Roo.log(['add child', items[i]]);
35652 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
35654 this.toolbar.items = nitems;
35655 this.toolbar.el.insertBefore(this.wrapEl.dom.firstChild);
35656 delete config.toolbar;
35660 // xtype created footer. - not sure if will work as we normally have to render first..
35661 if (this.footer && !this.footer.el && this.footer.xtype) {
35662 if (!this.wrapEl) {
35663 this.wrapEl = this.el.wrap();
35666 this.footer.container = this.wrapEl.createChild();
35668 this.footer = Roo.factory(this.footer, Roo);
35673 if(typeof config == "string"){
35674 this.title = config;
35676 Roo.apply(this, config);
35680 this.resizeEl = Roo.get(this.resizeEl, true);
35682 this.resizeEl = this.el;
35684 // handle view.xtype
35692 * Fires when this panel is activated.
35693 * @param {Roo.ContentPanel} this
35697 * @event deactivate
35698 * Fires when this panel is activated.
35699 * @param {Roo.ContentPanel} this
35701 "deactivate" : true,
35705 * Fires when this panel is resized if fitToFrame is true.
35706 * @param {Roo.ContentPanel} this
35707 * @param {Number} width The width after any component adjustments
35708 * @param {Number} height The height after any component adjustments
35714 * Fires when this tab is created
35715 * @param {Roo.ContentPanel} this
35726 if(this.autoScroll){
35727 this.resizeEl.setStyle("overflow", "auto");
35729 // fix randome scrolling
35730 //this.el.on('scroll', function() {
35731 // Roo.log('fix random scolling');
35732 // this.scrollTo('top',0);
35735 content = content || this.content;
35737 this.setContent(content);
35739 if(config && config.url){
35740 this.setUrl(this.url, this.params, this.loadOnce);
35745 Roo.bootstrap.panel.Content.superclass.constructor.call(this);
35747 if (this.view && typeof(this.view.xtype) != 'undefined') {
35748 this.view.el = this.el.appendChild(document.createElement("div"));
35749 this.view = Roo.factory(this.view);
35750 this.view.render && this.view.render(false, '');
35754 this.fireEvent('render', this);
35757 Roo.extend(Roo.bootstrap.panel.Content, Roo.bootstrap.Component, {
35761 setRegion : function(region){
35762 this.region = region;
35763 this.setActiveClass(region && !this.background);
35767 setActiveClass: function(state)
35770 this.el.replaceClass("roo-layout-inactive-content", "roo-layout-active-content");
35771 this.el.setStyle('position','relative');
35773 this.el.replaceClass("roo-layout-active-content", "roo-layout-inactive-content");
35774 this.el.setStyle('position', 'absolute');
35779 * Returns the toolbar for this Panel if one was configured.
35780 * @return {Roo.Toolbar}
35782 getToolbar : function(){
35783 return this.toolbar;
35786 setActiveState : function(active)
35788 this.active = active;
35789 this.setActiveClass(active);
35791 this.fireEvent("deactivate", this);
35793 this.fireEvent("activate", this);
35797 * Updates this panel's element
35798 * @param {String} content The new content
35799 * @param {Boolean} loadScripts (optional) true to look for and process scripts
35801 setContent : function(content, loadScripts){
35802 this.el.update(content, loadScripts);
35805 ignoreResize : function(w, h){
35806 if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
35809 this.lastSize = {width: w, height: h};
35814 * Get the {@link Roo.UpdateManager} for this panel. Enables you to perform Ajax updates.
35815 * @return {Roo.UpdateManager} The UpdateManager
35817 getUpdateManager : function(){
35818 return this.el.getUpdateManager();
35821 * Loads this content panel immediately with content from XHR. Note: to delay loading until the panel is activated, use {@link #setUrl}.
35822 * @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:
35825 url: "your-url.php",
35826 params: {param1: "foo", param2: "bar"}, // or a URL encoded string
35827 callback: yourFunction,
35828 scope: yourObject, //(optional scope)
35831 text: "Loading...",
35836 * The only required property is <i>url</i>. The optional properties <i>nocache</i>, <i>text</i> and <i>scripts</i>
35837 * 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.
35838 * @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}
35839 * @param {Function} callback (optional) Callback when transaction is complete -- called with signature (oElement, bSuccess, oResponse)
35840 * @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.
35841 * @return {Roo.ContentPanel} this
35844 var um = this.el.getUpdateManager();
35845 um.update.apply(um, arguments);
35851 * 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.
35852 * @param {String/Function} url The URL to load the content from or a function to call to get the URL
35853 * @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)
35854 * @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)
35855 * @return {Roo.UpdateManager} The UpdateManager
35857 setUrl : function(url, params, loadOnce){
35858 if(this.refreshDelegate){
35859 this.removeListener("activate", this.refreshDelegate);
35861 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
35862 this.on("activate", this.refreshDelegate);
35863 return this.el.getUpdateManager();
35866 _handleRefresh : function(url, params, loadOnce){
35867 if(!loadOnce || !this.loaded){
35868 var updater = this.el.getUpdateManager();
35869 updater.update(url, params, this._setLoaded.createDelegate(this));
35873 _setLoaded : function(){
35874 this.loaded = true;
35878 * Returns this panel's id
35881 getId : function(){
35886 * Returns this panel's element - used by regiosn to add.
35887 * @return {Roo.Element}
35889 getEl : function(){
35890 return this.wrapEl || this.el;
35895 adjustForComponents : function(width, height)
35897 //Roo.log('adjustForComponents ');
35898 if(this.resizeEl != this.el){
35899 width -= this.el.getFrameWidth('lr');
35900 height -= this.el.getFrameWidth('tb');
35903 var te = this.toolbar.getEl();
35904 te.setWidth(width);
35905 height -= te.getHeight();
35908 var te = this.footer.getEl();
35909 te.setWidth(width);
35910 height -= te.getHeight();
35914 if(this.adjustments){
35915 width += this.adjustments[0];
35916 height += this.adjustments[1];
35918 return {"width": width, "height": height};
35921 setSize : function(width, height){
35922 if(this.fitToFrame && !this.ignoreResize(width, height)){
35923 if(this.fitContainer && this.resizeEl != this.el){
35924 this.el.setSize(width, height);
35926 var size = this.adjustForComponents(width, height);
35927 this.resizeEl.setSize(this.autoWidth ? "auto" : size.width, this.autoHeight ? "auto" : size.height);
35928 this.fireEvent('resize', this, size.width, size.height);
35933 * Returns this panel's title
35936 getTitle : function(){
35938 if (typeof(this.title) != 'object') {
35943 for (var k in this.title) {
35944 if (!this.title.hasOwnProperty(k)) {
35948 if (k.indexOf('-') >= 0) {
35949 var s = k.split('-');
35950 for (var i = 0; i<s.length; i++) {
35951 t += "<span class='visible-"+s[i]+"'>"+this.title[k]+"</span>";
35954 t += "<span class='visible-"+k+"'>"+this.title[k]+"</span>";
35961 * Set this panel's title
35962 * @param {String} title
35964 setTitle : function(title){
35965 this.title = title;
35967 this.region.updatePanelTitle(this, title);
35972 * Returns true is this panel was configured to be closable
35973 * @return {Boolean}
35975 isClosable : function(){
35976 return this.closable;
35979 beforeSlide : function(){
35981 this.resizeEl.clip();
35984 afterSlide : function(){
35986 this.resizeEl.unclip();
35990 * Force a content refresh from the URL specified in the {@link #setUrl} method.
35991 * Will fail silently if the {@link #setUrl} method has not been called.
35992 * This does not activate the panel, just updates its content.
35994 refresh : function(){
35995 if(this.refreshDelegate){
35996 this.loaded = false;
35997 this.refreshDelegate();
36002 * Destroys this panel
36004 destroy : function(){
36005 this.el.removeAllListeners();
36006 var tempEl = document.createElement("span");
36007 tempEl.appendChild(this.el.dom);
36008 tempEl.innerHTML = "";
36014 * form - if the content panel contains a form - this is a reference to it.
36015 * @type {Roo.form.Form}
36019 * view - if the content panel contains a view (Roo.DatePicker / Roo.View / Roo.JsonView)
36020 * This contains a reference to it.
36026 * Adds a xtype elements to the panel - currently only supports Forms, View, JsonView.
36036 * @param {Object} cfg Xtype definition of item to add.
36040 getChildContainer: function () {
36041 return this.getEl();
36046 var ret = new Roo.factory(cfg);
36051 if (cfg.xtype.match(/^Form$/)) {
36054 //if (this.footer) {
36055 // el = this.footer.container.insertSibling(false, 'before');
36057 el = this.el.createChild();
36060 this.form = new Roo.form.Form(cfg);
36063 if ( this.form.allItems.length) {
36064 this.form.render(el.dom);
36068 // should only have one of theses..
36069 if ([ 'View', 'JsonView', 'DatePicker'].indexOf(cfg.xtype) > -1) {
36070 // views.. should not be just added - used named prop 'view''
36072 cfg.el = this.el.appendChild(document.createElement("div"));
36075 var ret = new Roo.factory(cfg);
36077 ret.render && ret.render(false, ''); // render blank..
36087 * @class Roo.bootstrap.panel.Grid
36088 * @extends Roo.bootstrap.panel.Content
36090 * Create a new GridPanel.
36091 * @cfg {Roo.bootstrap.Table} grid The grid for this panel
36092 * @param {Object} config A the config object
36098 Roo.bootstrap.panel.Grid = function(config)
36102 this.wrapper = Roo.DomHelper.append(document.body, // wrapper for IE7 strict & safari scroll issue
36103 {tag: "div", cls: "roo-layout-grid-wrapper roo-layout-inactive-content"}, true);
36105 config.el = this.wrapper;
36106 //this.el = this.wrapper;
36108 if (config.container) {
36109 // ctor'ed from a Border/panel.grid
36112 this.wrapper.setStyle("overflow", "hidden");
36113 this.wrapper.addClass('roo-grid-container');
36118 if(config.toolbar){
36119 var tool_el = this.wrapper.createChild();
36120 this.toolbar = Roo.factory(config.toolbar);
36122 if (config.toolbar.items) {
36123 ti = config.toolbar.items ;
36124 delete config.toolbar.items ;
36128 this.toolbar.render(tool_el);
36129 for(var i =0;i < ti.length;i++) {
36130 // Roo.log(['add child', items[i]]);
36131 nitems.push(this.toolbar.addxtype(Roo.apply({}, ti[i])));
36133 this.toolbar.items = nitems;
36135 delete config.toolbar;
36138 Roo.bootstrap.panel.Grid.superclass.constructor.call(this, config);
36139 config.grid.scrollBody = true;;
36140 config.grid.monitorWindowResize = false; // turn off autosizing
36141 config.grid.autoHeight = false;
36142 config.grid.autoWidth = false;
36144 this.grid = new config.grid.xns[config.grid.xtype](config.grid);
36146 if (config.background) {
36147 // render grid on panel activation (if panel background)
36148 this.on('activate', function(gp) {
36149 if (!gp.grid.rendered) {
36150 gp.grid.render(this.wrapper);
36151 gp.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
36156 this.grid.render(this.wrapper);
36157 this.grid.getGridEl().replaceClass("roo-layout-inactive-content", "roo-layout-component-panel");
36160 //this.wrapper.dom.appendChild(config.grid.getGridEl().dom);
36161 // ??? needed ??? config.el = this.wrapper;
36166 // xtype created footer. - not sure if will work as we normally have to render first..
36167 if (this.footer && !this.footer.el && this.footer.xtype) {
36169 var ctr = this.grid.getView().getFooterPanel(true);
36170 this.footer.dataSource = this.grid.dataSource;
36171 this.footer = Roo.factory(this.footer, Roo);
36172 this.footer.render(ctr);
36182 Roo.extend(Roo.bootstrap.panel.Grid, Roo.bootstrap.panel.Content, {
36183 getId : function(){
36184 return this.grid.id;
36188 * Returns the grid for this panel
36189 * @return {Roo.bootstrap.Table}
36191 getGrid : function(){
36195 setSize : function(width, height){
36196 if(!this.ignoreResize(width, height)){
36197 var grid = this.grid;
36198 var size = this.adjustForComponents(width, height);
36199 var gridel = grid.getGridEl();
36200 gridel.setSize(size.width, size.height);
36202 var thd = grid.getGridEl().select('thead',true).first();
36203 var tbd = grid.getGridEl().select('tbody', true).first();
36205 tbd.setSize(width, height - thd.getHeight());
36214 beforeSlide : function(){
36215 this.grid.getView().scroller.clip();
36218 afterSlide : function(){
36219 this.grid.getView().scroller.unclip();
36222 destroy : function(){
36223 this.grid.destroy();
36225 Roo.bootstrap.panel.Grid.superclass.destroy.call(this);
36230 * @class Roo.bootstrap.panel.Nest
36231 * @extends Roo.bootstrap.panel.Content
36233 * Create a new Panel, that can contain a layout.Border.
36236 * @param {Roo.BorderLayout} layout The layout for this panel
36237 * @param {String/Object} config A string to set only the title or a config object
36239 Roo.bootstrap.panel.Nest = function(config)
36241 // construct with only one argument..
36242 /* FIXME - implement nicer consturctors
36243 if (layout.layout) {
36245 layout = config.layout;
36246 delete config.layout;
36248 if (layout.xtype && !layout.getEl) {
36249 // then layout needs constructing..
36250 layout = Roo.factory(layout, Roo);
36254 config.el = config.layout.getEl();
36256 Roo.bootstrap.panel.Nest.superclass.constructor.call(this, config);
36258 config.layout.monitorWindowResize = false; // turn off autosizing
36259 this.layout = config.layout;
36260 this.layout.getEl().addClass("roo-layout-nested-layout");
36267 Roo.extend(Roo.bootstrap.panel.Nest, Roo.bootstrap.panel.Content, {
36269 setSize : function(width, height){
36270 if(!this.ignoreResize(width, height)){
36271 var size = this.adjustForComponents(width, height);
36272 var el = this.layout.getEl();
36273 if (size.height < 1) {
36274 el.setWidth(size.width);
36276 el.setSize(size.width, size.height);
36278 var touch = el.dom.offsetWidth;
36279 this.layout.layout();
36280 // ie requires a double layout on the first pass
36281 if(Roo.isIE && !this.initialized){
36282 this.initialized = true;
36283 this.layout.layout();
36288 // activate all subpanels if not currently active..
36290 setActiveState : function(active){
36291 this.active = active;
36292 this.setActiveClass(active);
36295 this.fireEvent("deactivate", this);
36299 this.fireEvent("activate", this);
36300 // not sure if this should happen before or after..
36301 if (!this.layout) {
36302 return; // should not happen..
36305 for (var r in this.layout.regions) {
36306 reg = this.layout.getRegion(r);
36307 if (reg.getActivePanel()) {
36308 //reg.showPanel(reg.getActivePanel()); // force it to activate..
36309 reg.setActivePanel(reg.getActivePanel());
36312 if (!reg.panels.length) {
36315 reg.showPanel(reg.getPanel(0));
36324 * Returns the nested BorderLayout for this panel
36325 * @return {Roo.BorderLayout}
36327 getLayout : function(){
36328 return this.layout;
36332 * Adds a xtype elements to the layout of the nested panel
36336 xtype : 'ContentPanel',
36343 xtype : 'NestedLayoutPanel',
36349 items : [ ... list of content panels or nested layout panels.. ]
36353 * @param {Object} cfg Xtype definition of item to add.
36355 addxtype : function(cfg) {
36356 return this.layout.addxtype(cfg);
36361 * Ext JS Library 1.1.1
36362 * Copyright(c) 2006-2007, Ext JS, LLC.
36364 * Originally Released Under LGPL - original licence link has changed is not relivant.
36367 * <script type="text/javascript">
36370 * @class Roo.TabPanel
36371 * @extends Roo.util.Observable
36372 * A lightweight tab container.
36376 // basic tabs 1, built from existing content
36377 var tabs = new Roo.TabPanel("tabs1");
36378 tabs.addTab("script", "View Script");
36379 tabs.addTab("markup", "View Markup");
36380 tabs.activate("script");
36382 // more advanced tabs, built from javascript
36383 var jtabs = new Roo.TabPanel("jtabs");
36384 jtabs.addTab("jtabs-1", "Normal Tab", "My content was added during construction.");
36386 // set up the UpdateManager
36387 var tab2 = jtabs.addTab("jtabs-2", "Ajax Tab 1");
36388 var updater = tab2.getUpdateManager();
36389 updater.setDefaultUrl("ajax1.htm");
36390 tab2.on('activate', updater.refresh, updater, true);
36392 // Use setUrl for Ajax loading
36393 var tab3 = jtabs.addTab("jtabs-3", "Ajax Tab 2");
36394 tab3.setUrl("ajax2.htm", null, true);
36397 var tab4 = jtabs.addTab("tabs1-5", "Disabled Tab", "Can't see me cause I'm disabled");
36400 jtabs.activate("jtabs-1");
36403 * Create a new TabPanel.
36404 * @param {String/HTMLElement/Roo.Element} container The id, DOM element or Roo.Element container where this TabPanel is to be rendered.
36405 * @param {Object/Boolean} config Config object to set any properties for this TabPanel, or true to render the tabs on the bottom.
36407 Roo.bootstrap.panel.Tabs = function(config){
36409 * The container element for this TabPanel.
36410 * @type Roo.Element
36412 this.el = Roo.get(config.el);
36415 if(typeof config == "boolean"){
36416 this.tabPosition = config ? "bottom" : "top";
36418 Roo.apply(this, config);
36422 if(this.tabPosition == "bottom"){
36423 this.bodyEl = Roo.get(this.createBody(this.el.dom));
36424 this.el.addClass("roo-tabs-bottom");
36426 this.stripWrap = Roo.get(this.createStrip(this.el.dom), true);
36427 this.stripEl = Roo.get(this.createStripList(this.stripWrap.dom), true);
36428 this.stripBody = Roo.get(this.stripWrap.dom.firstChild.firstChild, true);
36430 Roo.fly(this.stripWrap.dom.firstChild).setStyle("overflow-x", "hidden");
36432 if(this.tabPosition != "bottom"){
36433 /** The body element that contains {@link Roo.TabPanelItem} bodies. +
36434 * @type Roo.Element
36436 this.bodyEl = Roo.get(this.createBody(this.el.dom));
36437 this.el.addClass("roo-tabs-top");
36441 this.bodyEl.setStyle("position", "relative");
36443 this.active = null;
36444 this.activateDelegate = this.activate.createDelegate(this);
36449 * Fires when the active tab changes
36450 * @param {Roo.TabPanel} this
36451 * @param {Roo.TabPanelItem} activePanel The new active tab
36455 * @event beforetabchange
36456 * Fires before the active tab changes, set cancel to true on the "e" parameter to cancel the change
36457 * @param {Roo.TabPanel} this
36458 * @param {Object} e Set cancel to true on this object to cancel the tab change
36459 * @param {Roo.TabPanelItem} tab The tab being changed to
36461 "beforetabchange" : true
36464 Roo.EventManager.onWindowResize(this.onResize, this);
36465 this.cpad = this.el.getPadding("lr");
36466 this.hiddenCount = 0;
36469 // toolbar on the tabbar support...
36470 if (this.toolbar) {
36471 alert("no toolbar support yet");
36472 this.toolbar = false;
36474 var tcfg = this.toolbar;
36475 tcfg.container = this.stripEl.child('td.x-tab-strip-toolbar');
36476 this.toolbar = new Roo.Toolbar(tcfg);
36477 if (Roo.isSafari) {
36478 var tbl = tcfg.container.child('table', true);
36479 tbl.setAttribute('width', '100%');
36487 Roo.bootstrap.panel.Tabs.superclass.constructor.call(this);
36490 Roo.extend(Roo.bootstrap.panel.Tabs, Roo.util.Observable, {
36492 *@cfg {String} tabPosition "top" or "bottom" (defaults to "top")
36494 tabPosition : "top",
36496 *@cfg {Number} currentTabWidth The width of the current tab (defaults to 0)
36498 currentTabWidth : 0,
36500 *@cfg {Number} minTabWidth The minimum width of a tab (defaults to 40) (ignored if {@link #resizeTabs} is not true)
36504 *@cfg {Number} maxTabWidth The maximum width of a tab (defaults to 250) (ignored if {@link #resizeTabs} is not true)
36508 *@cfg {Number} preferredTabWidth The preferred (default) width of a tab (defaults to 175) (ignored if {@link #resizeTabs} is not true)
36510 preferredTabWidth : 175,
36512 *@cfg {Boolean} resizeTabs True to enable dynamic tab resizing (defaults to false)
36514 resizeTabs : false,
36516 *@cfg {Boolean} monitorResize Set this to true to turn on window resize monitoring (ignored if {@link #resizeTabs} is not true) (defaults to true)
36518 monitorResize : true,
36520 *@cfg {Object} toolbar xtype description of toolbar to show at the right of the tab bar.
36525 * Creates a new {@link Roo.TabPanelItem} by looking for an existing element with the provided id -- if it's not found it creates one.
36526 * @param {String} id The id of the div to use <b>or create</b>
36527 * @param {String} text The text for the tab
36528 * @param {String} content (optional) Content to put in the TabPanelItem body
36529 * @param {Boolean} closable (optional) True to create a close icon on the tab
36530 * @return {Roo.TabPanelItem} The created TabPanelItem
36532 addTab : function(id, text, content, closable, tpl)
36534 var item = new Roo.bootstrap.panel.TabItem({
36538 closable : closable,
36541 this.addTabItem(item);
36543 item.setContent(content);
36549 * Returns the {@link Roo.TabPanelItem} with the specified id/index
36550 * @param {String/Number} id The id or index of the TabPanelItem to fetch.
36551 * @return {Roo.TabPanelItem}
36553 getTab : function(id){
36554 return this.items[id];
36558 * Hides the {@link Roo.TabPanelItem} with the specified id/index
36559 * @param {String/Number} id The id or index of the TabPanelItem to hide.
36561 hideTab : function(id){
36562 var t = this.items[id];
36565 this.hiddenCount++;
36566 this.autoSizeTabs();
36571 * "Unhides" the {@link Roo.TabPanelItem} with the specified id/index.
36572 * @param {String/Number} id The id or index of the TabPanelItem to unhide.
36574 unhideTab : function(id){
36575 var t = this.items[id];
36577 t.setHidden(false);
36578 this.hiddenCount--;
36579 this.autoSizeTabs();
36584 * Adds an existing {@link Roo.TabPanelItem}.
36585 * @param {Roo.TabPanelItem} item The TabPanelItem to add
36587 addTabItem : function(item){
36588 this.items[item.id] = item;
36589 this.items.push(item);
36590 // if(this.resizeTabs){
36591 // item.setWidth(this.currentTabWidth || this.preferredTabWidth);
36592 // this.autoSizeTabs();
36594 // item.autoSize();
36599 * Removes a {@link Roo.TabPanelItem}.
36600 * @param {String/Number} id The id or index of the TabPanelItem to remove.
36602 removeTab : function(id){
36603 var items = this.items;
36604 var tab = items[id];
36605 if(!tab) { return; }
36606 var index = items.indexOf(tab);
36607 if(this.active == tab && items.length > 1){
36608 var newTab = this.getNextAvailable(index);
36613 this.stripEl.dom.removeChild(tab.pnode.dom);
36614 if(tab.bodyEl.dom.parentNode == this.bodyEl.dom){ // if it was moved already prevent error
36615 this.bodyEl.dom.removeChild(tab.bodyEl.dom);
36617 items.splice(index, 1);
36618 delete this.items[tab.id];
36619 tab.fireEvent("close", tab);
36620 tab.purgeListeners();
36621 this.autoSizeTabs();
36624 getNextAvailable : function(start){
36625 var items = this.items;
36627 // look for a next tab that will slide over to
36628 // replace the one being removed
36629 while(index < items.length){
36630 var item = items[++index];
36631 if(item && !item.isHidden()){
36635 // if one isn't found select the previous tab (on the left)
36638 var item = items[--index];
36639 if(item && !item.isHidden()){
36647 * Disables a {@link Roo.TabPanelItem}. It cannot be the active tab, if it is this call is ignored.
36648 * @param {String/Number} id The id or index of the TabPanelItem to disable.
36650 disableTab : function(id){
36651 var tab = this.items[id];
36652 if(tab && this.active != tab){
36658 * Enables a {@link Roo.TabPanelItem} that is disabled.
36659 * @param {String/Number} id The id or index of the TabPanelItem to enable.
36661 enableTab : function(id){
36662 var tab = this.items[id];
36667 * Activates a {@link Roo.TabPanelItem}. The currently active one will be deactivated.
36668 * @param {String/Number} id The id or index of the TabPanelItem to activate.
36669 * @return {Roo.TabPanelItem} The TabPanelItem.
36671 activate : function(id){
36672 var tab = this.items[id];
36676 if(tab == this.active || tab.disabled){
36680 this.fireEvent("beforetabchange", this, e, tab);
36681 if(e.cancel !== true && !tab.disabled){
36683 this.active.hide();
36685 this.active = this.items[id];
36686 this.active.show();
36687 this.fireEvent("tabchange", this, this.active);
36693 * Gets the active {@link Roo.TabPanelItem}.
36694 * @return {Roo.TabPanelItem} The active TabPanelItem or null if none are active.
36696 getActiveTab : function(){
36697 return this.active;
36701 * Updates the tab body element to fit the height of the container element
36702 * for overflow scrolling
36703 * @param {Number} targetHeight (optional) Override the starting height from the elements height
36705 syncHeight : function(targetHeight){
36706 var height = (targetHeight || this.el.getHeight())-this.el.getBorderWidth("tb")-this.el.getPadding("tb");
36707 var bm = this.bodyEl.getMargins();
36708 var newHeight = height-(this.stripWrap.getHeight()||0)-(bm.top+bm.bottom);
36709 this.bodyEl.setHeight(newHeight);
36713 onResize : function(){
36714 if(this.monitorResize){
36715 this.autoSizeTabs();
36720 * Disables tab resizing while tabs are being added (if {@link #resizeTabs} is false this does nothing)
36722 beginUpdate : function(){
36723 this.updating = true;
36727 * Stops an update and resizes the tabs (if {@link #resizeTabs} is false this does nothing)
36729 endUpdate : function(){
36730 this.updating = false;
36731 this.autoSizeTabs();
36735 * Manual call to resize the tabs (if {@link #resizeTabs} is false this does nothing)
36737 autoSizeTabs : function(){
36738 var count = this.items.length;
36739 var vcount = count - this.hiddenCount;
36740 if(!this.resizeTabs || count < 1 || vcount < 1 || this.updating) {
36743 var w = Math.max(this.el.getWidth() - this.cpad, 10);
36744 var availWidth = Math.floor(w / vcount);
36745 var b = this.stripBody;
36746 if(b.getWidth() > w){
36747 var tabs = this.items;
36748 this.setTabWidth(Math.max(availWidth, this.minTabWidth)-2);
36749 if(availWidth < this.minTabWidth){
36750 /*if(!this.sleft){ // incomplete scrolling code
36751 this.createScrollButtons();
36754 this.stripClip.setWidth(w - (this.sleft.getWidth()+this.sright.getWidth()));*/
36757 if(this.currentTabWidth < this.preferredTabWidth){
36758 this.setTabWidth(Math.min(availWidth, this.preferredTabWidth)-2);
36764 * Returns the number of tabs in this TabPanel.
36767 getCount : function(){
36768 return this.items.length;
36772 * Resizes all the tabs to the passed width
36773 * @param {Number} The new width
36775 setTabWidth : function(width){
36776 this.currentTabWidth = width;
36777 for(var i = 0, len = this.items.length; i < len; i++) {
36778 if(!this.items[i].isHidden()) {
36779 this.items[i].setWidth(width);
36785 * Destroys this TabPanel
36786 * @param {Boolean} removeEl (optional) True to remove the element from the DOM as well (defaults to undefined)
36788 destroy : function(removeEl){
36789 Roo.EventManager.removeResizeListener(this.onResize, this);
36790 for(var i = 0, len = this.items.length; i < len; i++){
36791 this.items[i].purgeListeners();
36793 if(removeEl === true){
36794 this.el.update("");
36799 createStrip : function(container)
36801 var strip = document.createElement("nav");
36802 strip.className = "navbar navbar-default"; //"x-tabs-wrap";
36803 container.appendChild(strip);
36807 createStripList : function(strip)
36809 // div wrapper for retard IE
36810 // returns the "tr" element.
36811 strip.innerHTML = '<ul class="nav nav-tabs" role="tablist"></ul>';
36812 //'<div class="x-tabs-strip-wrap">'+
36813 // '<table class="x-tabs-strip" cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
36814 // '<td class="x-tab-strip-toolbar"></td></tr></tbody></table></div>';
36815 return strip.firstChild; //.firstChild.firstChild.firstChild;
36817 createBody : function(container)
36819 var body = document.createElement("div");
36820 Roo.id(body, "tab-body");
36821 //Roo.fly(body).addClass("x-tabs-body");
36822 Roo.fly(body).addClass("tab-content");
36823 container.appendChild(body);
36826 createItemBody :function(bodyEl, id){
36827 var body = Roo.getDom(id);
36829 body = document.createElement("div");
36832 //Roo.fly(body).addClass("x-tabs-item-body");
36833 Roo.fly(body).addClass("tab-pane");
36834 bodyEl.insertBefore(body, bodyEl.firstChild);
36838 createStripElements : function(stripEl, text, closable, tpl)
36840 var td = document.createElement("li"); // was td..
36843 //stripEl.insertBefore(td, stripEl.childNodes[stripEl.childNodes.length-1]);
36846 stripEl.appendChild(td);
36848 td.className = "x-tabs-closable";
36849 if(!this.closeTpl){
36850 this.closeTpl = new Roo.Template(
36851 '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
36852 '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span>' +
36853 '<div unselectable="on" class="close-icon"> </div></em></span></a>'
36856 var el = this.closeTpl.overwrite(td, {"text": text});
36857 var close = el.getElementsByTagName("div")[0];
36858 var inner = el.getElementsByTagName("em")[0];
36859 return {"el": el, "close": close, "inner": inner};
36862 // not sure what this is..
36863 // if(!this.tabTpl){
36864 //this.tabTpl = new Roo.Template(
36865 // '<a href="#" class="x-tabs-right"><span class="x-tabs-left"><em class="x-tabs-inner">' +
36866 // '<span unselectable="on"' + (this.disableTooltips ? '' : ' title="{text}"') +' class="x-tabs-text">{text}</span></em></span></a>'
36868 // this.tabTpl = new Roo.Template(
36869 // '<a href="#">' +
36870 // '<span unselectable="on"' +
36871 // (this.disableTooltips ? '' : ' title="{text}"') +
36872 // ' >{text}</span></a>'
36878 var template = tpl || this.tabTpl || false;
36882 template = new Roo.Template(
36884 '<span unselectable="on"' +
36885 (this.disableTooltips ? '' : ' title="{text}"') +
36886 ' >{text}</span></a>'
36890 switch (typeof(template)) {
36894 template = new Roo.Template(template);
36900 var el = template.overwrite(td, {"text": text});
36902 var inner = el.getElementsByTagName("span")[0];
36904 return {"el": el, "inner": inner};
36912 * @class Roo.TabPanelItem
36913 * @extends Roo.util.Observable
36914 * Represents an individual item (tab plus body) in a TabPanel.
36915 * @param {Roo.TabPanel} tabPanel The {@link Roo.TabPanel} this TabPanelItem belongs to
36916 * @param {String} id The id of this TabPanelItem
36917 * @param {String} text The text for the tab of this TabPanelItem
36918 * @param {Boolean} closable True to allow this TabPanelItem to be closable (defaults to false)
36920 Roo.bootstrap.panel.TabItem = function(config){
36922 * The {@link Roo.TabPanel} this TabPanelItem belongs to
36923 * @type Roo.TabPanel
36925 this.tabPanel = config.panel;
36927 * The id for this TabPanelItem
36930 this.id = config.id;
36932 this.disabled = false;
36934 this.text = config.text;
36936 this.loaded = false;
36937 this.closable = config.closable;
36940 * The body element for this TabPanelItem.
36941 * @type Roo.Element
36943 this.bodyEl = Roo.get(this.tabPanel.createItemBody(this.tabPanel.bodyEl.dom, config.id));
36944 this.bodyEl.setVisibilityMode(Roo.Element.VISIBILITY);
36945 this.bodyEl.setStyle("display", "block");
36946 this.bodyEl.setStyle("zoom", "1");
36947 //this.hideAction();
36949 var els = this.tabPanel.createStripElements(this.tabPanel.stripEl.dom, config.text, config.closable, config.tpl);
36951 this.el = Roo.get(els.el);
36952 this.inner = Roo.get(els.inner, true);
36953 this.textEl = Roo.get(this.el.dom.firstChild, true);
36954 this.pnode = Roo.get(els.el.parentNode, true);
36955 this.el.on("mousedown", this.onTabMouseDown, this);
36956 this.el.on("click", this.onTabClick, this);
36958 if(config.closable){
36959 var c = Roo.get(els.close, true);
36960 c.dom.title = this.closeText;
36961 c.addClassOnOver("close-over");
36962 c.on("click", this.closeClick, this);
36968 * Fires when this tab becomes the active tab.
36969 * @param {Roo.TabPanel} tabPanel The parent TabPanel
36970 * @param {Roo.TabPanelItem} this
36974 * @event beforeclose
36975 * Fires before this tab is closed. To cancel the close, set cancel to true on e (e.cancel = true).
36976 * @param {Roo.TabPanelItem} this
36977 * @param {Object} e Set cancel to true on this object to cancel the close.
36979 "beforeclose": true,
36982 * Fires when this tab is closed.
36983 * @param {Roo.TabPanelItem} this
36987 * @event deactivate
36988 * Fires when this tab is no longer the active tab.
36989 * @param {Roo.TabPanel} tabPanel The parent TabPanel
36990 * @param {Roo.TabPanelItem} this
36992 "deactivate" : true
36994 this.hidden = false;
36996 Roo.bootstrap.panel.TabItem.superclass.constructor.call(this);
36999 Roo.extend(Roo.bootstrap.panel.TabItem, Roo.util.Observable,
37001 purgeListeners : function(){
37002 Roo.util.Observable.prototype.purgeListeners.call(this);
37003 this.el.removeAllListeners();
37006 * Shows this TabPanelItem -- this <b>does not</b> deactivate the currently active TabPanelItem.
37009 this.pnode.addClass("active");
37012 this.tabPanel.stripWrap.repaint();
37014 this.fireEvent("activate", this.tabPanel, this);
37018 * Returns true if this tab is the active tab.
37019 * @return {Boolean}
37021 isActive : function(){
37022 return this.tabPanel.getActiveTab() == this;
37026 * Hides this TabPanelItem -- if you don't activate another TabPanelItem this could look odd.
37029 this.pnode.removeClass("active");
37031 this.fireEvent("deactivate", this.tabPanel, this);
37034 hideAction : function(){
37035 this.bodyEl.hide();
37036 this.bodyEl.setStyle("position", "absolute");
37037 this.bodyEl.setLeft("-20000px");
37038 this.bodyEl.setTop("-20000px");
37041 showAction : function(){
37042 this.bodyEl.setStyle("position", "relative");
37043 this.bodyEl.setTop("");
37044 this.bodyEl.setLeft("");
37045 this.bodyEl.show();
37049 * Set the tooltip for the tab.
37050 * @param {String} tooltip The tab's tooltip
37052 setTooltip : function(text){
37053 if(Roo.QuickTips && Roo.QuickTips.isEnabled()){
37054 this.textEl.dom.qtip = text;
37055 this.textEl.dom.removeAttribute('title');
37057 this.textEl.dom.title = text;
37061 onTabClick : function(e){
37062 e.preventDefault();
37063 this.tabPanel.activate(this.id);
37066 onTabMouseDown : function(e){
37067 e.preventDefault();
37068 this.tabPanel.activate(this.id);
37071 getWidth : function(){
37072 return this.inner.getWidth();
37075 setWidth : function(width){
37076 var iwidth = width - this.pnode.getPadding("lr");
37077 this.inner.setWidth(iwidth);
37078 this.textEl.setWidth(iwidth-this.inner.getPadding("lr"));
37079 this.pnode.setWidth(width);
37083 * Show or hide the tab
37084 * @param {Boolean} hidden True to hide or false to show.
37086 setHidden : function(hidden){
37087 this.hidden = hidden;
37088 this.pnode.setStyle("display", hidden ? "none" : "");
37092 * Returns true if this tab is "hidden"
37093 * @return {Boolean}
37095 isHidden : function(){
37096 return this.hidden;
37100 * Returns the text for this tab
37103 getText : function(){
37107 autoSize : function(){
37108 //this.el.beginMeasure();
37109 this.textEl.setWidth(1);
37111 * #2804 [new] Tabs in Roojs
37112 * increase the width by 2-4 pixels to prevent the ellipssis showing in chrome
37114 //this.setWidth(this.textEl.dom.scrollWidth+this.pnode.getPadding("lr")+this.inner.getPadding("lr") + 2);
37115 //this.el.endMeasure();
37119 * Sets the text for the tab (Note: this also sets the tooltip text)
37120 * @param {String} text The tab's text and tooltip
37122 setText : function(text){
37124 this.textEl.update(text);
37125 this.setTooltip(text);
37126 //if(!this.tabPanel.resizeTabs){
37127 // this.autoSize();
37131 * Activates this TabPanelItem -- this <b>does</b> deactivate the currently active TabPanelItem.
37133 activate : function(){
37134 this.tabPanel.activate(this.id);
37138 * Disables this TabPanelItem -- this does nothing if this is the active TabPanelItem.
37140 disable : function(){
37141 if(this.tabPanel.active != this){
37142 this.disabled = true;
37143 this.pnode.addClass("disabled");
37148 * Enables this TabPanelItem if it was previously disabled.
37150 enable : function(){
37151 this.disabled = false;
37152 this.pnode.removeClass("disabled");
37156 * Sets the content for this TabPanelItem.
37157 * @param {String} content The content
37158 * @param {Boolean} loadScripts true to look for and load scripts
37160 setContent : function(content, loadScripts){
37161 this.bodyEl.update(content, loadScripts);
37165 * Gets the {@link Roo.UpdateManager} for the body of this TabPanelItem. Enables you to perform Ajax updates.
37166 * @return {Roo.UpdateManager} The UpdateManager
37168 getUpdateManager : function(){
37169 return this.bodyEl.getUpdateManager();
37173 * Set a URL to be used to load the content for this TabPanelItem.
37174 * @param {String/Function} url The URL to load the content from, or a function to call to get the URL
37175 * @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)
37176 * @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)
37177 * @return {Roo.UpdateManager} The UpdateManager
37179 setUrl : function(url, params, loadOnce){
37180 if(this.refreshDelegate){
37181 this.un('activate', this.refreshDelegate);
37183 this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
37184 this.on("activate", this.refreshDelegate);
37185 return this.bodyEl.getUpdateManager();
37189 _handleRefresh : function(url, params, loadOnce){
37190 if(!loadOnce || !this.loaded){
37191 var updater = this.bodyEl.getUpdateManager();
37192 updater.update(url, params, this._setLoaded.createDelegate(this));
37197 * Forces a content refresh from the URL specified in the {@link #setUrl} method.
37198 * Will fail silently if the setUrl method has not been called.
37199 * This does not activate the panel, just updates its content.
37201 refresh : function(){
37202 if(this.refreshDelegate){
37203 this.loaded = false;
37204 this.refreshDelegate();
37209 _setLoaded : function(){
37210 this.loaded = true;
37214 closeClick : function(e){
37217 this.fireEvent("beforeclose", this, o);
37218 if(o.cancel !== true){
37219 this.tabPanel.removeTab(this.id);
37223 * The text displayed in the tooltip for the close icon.
37226 closeText : "Close this tab"